aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS8
-rw-r--r--Documentation/cputopology.txt48
-rw-r--r--Documentation/filesystems/ocfs2.txt3
-rw-r--r--Documentation/filesystems/ubifs.txt3
-rw-r--r--Documentation/ioctl/ioctl-number.txt4
-rw-r--r--Documentation/kbuild/00-INDEX6
-rw-r--r--Documentation/kbuild/kbuild.txt126
-rw-r--r--Documentation/kbuild/kconfig.txt188
-rw-r--r--Documentation/video4linux/CARDLIST.saa71341
-rw-r--r--Documentation/video4linux/si470x.txt1
-rw-r--r--Documentation/video4linux/v4l2-framework.txt19
-rw-r--r--Documentation/x86/boot.txt2
-rw-r--r--MAINTAINERS15
-rw-r--r--Makefile3
-rw-r--r--README32
-rw-r--r--arch/alpha/include/asm/topology.h17
-rw-r--r--arch/alpha/kernel/Makefile2
-rw-r--r--arch/alpha/kernel/binfmt_loader.c51
-rw-r--r--arch/alpha/kernel/irq.c3
-rw-r--r--arch/alpha/kernel/setup.c5
-rw-r--r--arch/arm/mach-omap2/clock24xx.h4
-rw-r--r--arch/avr32/include/asm/bitops.h5
-rw-r--r--arch/blackfin/include/asm/bitops.h1
-rw-r--r--arch/cris/include/asm/bitops.h1
-rw-r--r--arch/h8300/include/asm/bitops.h1
-rw-r--r--arch/ia64/Kconfig3
-rw-r--r--arch/ia64/include/asm/irq.h2
-rw-r--r--arch/ia64/include/asm/kvm_host.h2
-rw-r--r--arch/ia64/include/asm/topology.h9
-rw-r--r--arch/ia64/kernel/acpi.c3
-rw-r--r--arch/ia64/kernel/iosapic.c23
-rw-r--r--arch/ia64/kernel/irq.c4
-rw-r--r--arch/ia64/kernel/time.c18
-rw-r--r--arch/ia64/kvm/Makefile4
-rw-r--r--arch/ia64/kvm/kvm-ia64.c3
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c27
-rw-r--r--arch/m32r/kernel/smpboot.c2
-rw-r--r--arch/m68k/Kconfig1
-rw-r--r--arch/m68knommu/include/asm/bitops.h1
-rw-r--r--arch/mips/include/asm/mach-ip27/topology.h4
-rw-r--r--arch/parisc/include/asm/module.h6
-rw-r--r--arch/parisc/include/asm/smp.h2
-rw-r--r--arch/parisc/kernel/module.c216
-rw-r--r--arch/powerpc/include/asm/topology.h12
-rw-r--r--arch/powerpc/kernel/process.c1
-rw-r--r--arch/powerpc/kernel/time.c18
-rw-r--r--arch/powerpc/platforms/cell/spu_priv1_mmio.c6
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c1
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c4
-rw-r--r--arch/s390/hypfs/inode.c1
-rw-r--r--arch/s390/include/asm/cpu.h7
-rw-r--r--arch/s390/include/asm/cputime.h42
-rw-r--r--arch/s390/include/asm/lowcore.h49
-rw-r--r--arch/s390/include/asm/system.h4
-rw-r--r--arch/s390/include/asm/thread_info.h2
-rw-r--r--arch/s390/include/asm/timer.h16
-rw-r--r--arch/s390/include/asm/topology.h2
-rw-r--r--arch/s390/include/asm/vdso.h15
-rw-r--r--arch/s390/kernel/asm-offsets.c5
-rw-r--r--arch/s390/kernel/entry.S5
-rw-r--r--arch/s390/kernel/entry64.S50
-rw-r--r--arch/s390/kernel/head64.S2
-rw-r--r--arch/s390/kernel/process.c43
-rw-r--r--arch/s390/kernel/s390_ext.c2
-rw-r--r--arch/s390/kernel/setup.c2
-rw-r--r--arch/s390/kernel/smp.c34
-rw-r--r--arch/s390/kernel/topology.c5
-rw-r--r--arch/s390/kernel/vdso.c123
-rw-r--r--arch/s390/kernel/vdso64/clock_getres.S5
-rw-r--r--arch/s390/kernel/vdso64/clock_gettime.S39
-rw-r--r--arch/s390/kernel/vtime.c486
-rw-r--r--arch/sh/include/asm/topology.h1
-rw-r--r--arch/sparc/Kconfig57
-rw-r--r--arch/sparc/configs/sparc64_defconfig105
-rw-r--r--arch/sparc/include/asm/Kbuild20
-rw-r--r--arch/sparc/include/asm/byteorder.h12
-rw-r--r--arch/sparc/include/asm/ipcbuf.h38
-rw-r--r--arch/sparc/include/asm/ipcbuf_32.h31
-rw-r--r--arch/sparc/include/asm/ipcbuf_64.h28
-rw-r--r--arch/sparc/include/asm/jsflash.h2
-rw-r--r--arch/sparc/include/asm/openprom.h277
-rw-r--r--arch/sparc/include/asm/openprom_32.h255
-rw-r--r--arch/sparc/include/asm/openprom_64.h280
-rw-r--r--arch/sparc/include/asm/posix_types.h157
-rw-r--r--arch/sparc/include/asm/posix_types_32.h118
-rw-r--r--arch/sparc/include/asm/posix_types_64.h122
-rw-r--r--arch/sparc/include/asm/processor_32.h2
-rw-r--r--arch/sparc/include/asm/ptrace.h448
-rw-r--r--arch/sparc/include/asm/ptrace_32.h186
-rw-r--r--arch/sparc/include/asm/ptrace_64.h356
-rw-r--r--arch/sparc/include/asm/reg.h8
-rw-r--r--arch/sparc/include/asm/reg_32.h79
-rw-r--r--arch/sparc/include/asm/reg_64.h56
-rw-r--r--arch/sparc/include/asm/sigcontext.h102
-rw-r--r--arch/sparc/include/asm/sigcontext_32.h62
-rw-r--r--arch/sparc/include/asm/sigcontext_64.h87
-rw-r--r--arch/sparc/include/asm/siginfo.h43
-rw-r--r--arch/sparc/include/asm/siginfo_32.h17
-rw-r--r--arch/sparc/include/asm/siginfo_64.h32
-rw-r--r--arch/sparc/include/asm/signal.h212
-rw-r--r--arch/sparc/include/asm/signal_32.h207
-rw-r--r--arch/sparc/include/asm/signal_64.h194
-rw-r--r--arch/sparc/include/asm/smp_32.h3
-rw-r--r--arch/sparc/include/asm/stat.h111
-rw-r--r--arch/sparc/include/asm/stat_32.h76
-rw-r--r--arch/sparc/include/asm/stat_64.h47
-rw-r--r--arch/sparc/include/asm/thread_info_32.h2
-rw-r--r--arch/sparc/include/asm/topology_64.h13
-rw-r--r--arch/sparc/include/asm/traps.h11
-rw-r--r--arch/sparc/kernel/irq_32.c2
-rw-r--r--arch/sparc/kernel/kgdb_32.c12
-rw-r--r--arch/sparc/kernel/muldiv.c8
-rw-r--r--arch/sparc/kernel/of_device_64.c2
-rw-r--r--arch/sparc/kernel/pci_msi.c2
-rw-r--r--arch/sparc/kernel/pci_psycho.c5
-rw-r--r--arch/sparc/kernel/process_32.c16
-rw-r--r--arch/sparc/kernel/prom_common.c14
-rw-r--r--arch/sparc/kernel/signal_32.c6
-rw-r--r--arch/sparc/kernel/traps_32.c4
-rw-r--r--arch/sparc/kernel/unaligned_32.c12
-rw-r--r--arch/sparc/kernel/windows.c6
-rw-r--r--arch/um/Makefile25
-rw-r--r--arch/um/include/asm/system.h14
-rw-r--r--arch/x86/Kconfig13
-rw-r--r--arch/x86/Kconfig.cpu2
-rw-r--r--arch/x86/include/asm/amd_iommu_types.h61
-rw-r--r--arch/x86/include/asm/es7000/apic.h32
-rw-r--r--arch/x86/include/asm/es7000/mpparse.h3
-rw-r--r--arch/x86/include/asm/genapic_32.h8
-rw-r--r--arch/x86/include/asm/kvm_host.h2
-rw-r--r--arch/x86/include/asm/lguest.h2
-rw-r--r--arch/x86/include/asm/mach-default/mach_mpparse.h4
-rw-r--r--arch/x86/include/asm/mach-generic/mach_mpparse.h5
-rw-r--r--arch/x86/include/asm/mach-generic/mach_mpspec.h4
-rw-r--r--arch/x86/include/asm/mpspec_def.h102
-rw-r--r--arch/x86/include/asm/numaq/apic.h4
-rw-r--r--arch/x86/include/asm/numaq/mpparse.h3
-rw-r--r--arch/x86/include/asm/pci.h10
-rw-r--r--arch/x86/include/asm/setup.h14
-rw-r--r--arch/x86/include/asm/summit/apic.h42
-rw-r--r--arch/x86/include/asm/summit/mpparse.h2
-rw-r--r--arch/x86/include/asm/topology.h36
-rw-r--r--arch/x86/kernel/acpi/boot.c31
-rw-r--r--arch/x86/kernel/amd_iommu.c664
-rw-r--r--arch/x86/kernel/amd_iommu_init.c15
-rw-r--r--arch/x86/kernel/apic.c18
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c28
-rw-r--r--arch/x86/kernel/cpu/cpufreq/p4-clockmod.c6
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k7.c9
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.c24
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c51
-rw-r--r--arch/x86/kernel/cpu/cpufreq/speedstep-lib.c9
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c2
-rw-r--r--arch/x86/kernel/cpuid.c2
-rw-r--r--arch/x86/kernel/i8259.c8
-rw-r--r--arch/x86/kernel/io_apic.c6
-rw-r--r--arch/x86/kernel/ioport.c4
-rw-r--r--arch/x86/kernel/irq.c2
-rw-r--r--arch/x86/kernel/irq_32.c10
-rw-r--r--arch/x86/kernel/irq_64.c22
-rw-r--r--arch/x86/kernel/irqinit_32.c12
-rw-r--r--arch/x86/kernel/irqinit_64.c8
-rw-r--r--arch/x86/kernel/mpparse.c348
-rw-r--r--arch/x86/kernel/msr.c2
-rw-r--r--arch/x86/kernel/nmi.c1
-rw-r--r--arch/x86/kernel/numaq_32.c38
-rw-r--r--arch/x86/kernel/pci-swiotlb_64.c2
-rw-r--r--arch/x86/kernel/process_32.c19
-rw-r--r--arch/x86/kernel/reboot.c4
-rw-r--r--arch/x86/kernel/setup_percpu.c44
-rw-r--r--arch/x86/kernel/smpboot.c15
-rw-r--r--arch/x86/kernel/time_32.c4
-rw-r--r--arch/x86/kernel/time_64.c2
-rw-r--r--arch/x86/kernel/traps.c3
-rw-r--r--arch/x86/kernel/visws_quirks.c32
-rw-r--r--arch/x86/kvm/Makefile4
-rw-r--r--arch/x86/kvm/x86.c3
-rw-r--r--arch/x86/mach-generic/es7000.c10
-rw-r--r--arch/x86/mach-generic/numaq.c3
-rw-r--r--arch/x86/mach-generic/probe.c3
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c7
-rw-r--r--arch/x86/mm/k8topology_64.c20
-rw-r--r--arch/x86/xen/time.c10
-rw-r--r--block/blk.h4
-rw-r--r--drivers/acpi/processor_core.c14
-rw-r--r--drivers/acpi/processor_perflib.c28
-rw-r--r--drivers/acpi/processor_throttling.c80
-rw-r--r--drivers/base/Makefile1
-rw-r--r--drivers/base/cpu.c44
-rw-r--r--drivers/base/iommu.c100
-rw-r--r--drivers/char/random.c40
-rw-r--r--drivers/cpufreq/cpufreq.c55
-rw-r--r--drivers/hid/Kconfig70
-rw-r--r--drivers/hid/Makefile5
-rw-r--r--drivers/hid/hid-bright.c71
-rw-r--r--drivers/hid/hid-core.c120
-rw-r--r--drivers/hid/hid-dell.c76
-rw-r--r--drivers/hid/hid-dummy.c6
-rw-r--r--drivers/hid/hid-gaff.c185
-rw-r--r--drivers/hid/hid-ids.h21
-rw-r--r--drivers/hid/hid-lg.c7
-rw-r--r--drivers/hid/hid-ntrig.c82
-rw-r--r--drivers/hid/hid-sony.c2
-rw-r--r--drivers/hid/hid-topseed.c77
-rw-r--r--drivers/hid/hidraw.c32
-rw-r--r--drivers/hid/usbhid/Kconfig2
-rw-r--r--drivers/hid/usbhid/hid-core.c34
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c135
-rw-r--r--drivers/hid/usbhid/usbhid.h10
-rw-r--r--drivers/i2c/busses/i2c-omap.c420
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c185
-rw-r--r--drivers/i2c/chips/Kconfig23
-rw-r--r--drivers/i2c/chips/Makefile2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c17
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c3
-rw-r--r--drivers/isdn/capi/capidrv.c4
-rw-r--r--drivers/isdn/capi/capifs.c2
-rw-r--r--drivers/md/Makefile5
-rw-r--r--drivers/md/dm-crypt.c6
-rw-r--r--drivers/md/dm-delay.c6
-rw-r--r--drivers/md/dm-exception-store.c749
-rw-r--r--drivers/md/dm-exception-store.h148
-rw-r--r--drivers/md/dm-ioctl.c16
-rw-r--r--drivers/md/dm-linear.c6
-rw-r--r--drivers/md/dm-log.c40
-rw-r--r--drivers/md/dm-mpath.c14
-rw-r--r--drivers/md/dm-raid1.c24
-rw-r--r--drivers/md/dm-snap-persistent.c704
-rw-r--r--drivers/md/dm-snap-transient.c98
-rw-r--r--drivers/md/dm-snap.c48
-rw-r--r--drivers/md/dm-snap.h129
-rw-r--r--drivers/md/dm-stripe.c4
-rw-r--r--drivers/md/dm-sysfs.c99
-rw-r--r--drivers/md/dm-table.c47
-rw-r--r--drivers/md/dm-target.c15
-rw-r--r--drivers/md/dm-zero.c5
-rw-r--r--drivers/md/dm.c101
-rw-r--r--drivers/md/dm.h10
-rw-r--r--drivers/media/common/saa7146_fops.c21
-rw-r--r--drivers/media/common/saa7146_video.c5
-rw-r--r--drivers/media/common/tuners/tuner-simple.c16
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c3
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c2
-rw-r--r--drivers/media/dvb/frontends/cx24116.c1
-rw-r--r--drivers/media/dvb/frontends/cx24116.h3
-rw-r--r--drivers/media/dvb/frontends/stb0899_drv.c1
-rw-r--r--drivers/media/dvb/frontends/zl10353.c7
-rw-r--r--drivers/media/dvb/siano/sms-cards.c19
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c4
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c2
-rw-r--r--drivers/media/dvb/ttusb-budget/Kconfig2
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig2
-rw-r--r--drivers/media/radio/Kconfig19
-rw-r--r--drivers/media/radio/Makefile1
-rw-r--r--drivers/media/radio/dsbr100.c14
-rw-r--r--drivers/media/radio/radio-aimslab.c10
-rw-r--r--drivers/media/radio/radio-aztech.c10
-rw-r--r--drivers/media/radio/radio-cadet.c10
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c10
-rw-r--r--drivers/media/radio/radio-gemtek.c10
-rw-r--r--drivers/media/radio/radio-maestro.c10
-rw-r--r--drivers/media/radio/radio-maxiradio.c10
-rw-r--r--drivers/media/radio/radio-mr800.c14
-rw-r--r--drivers/media/radio/radio-rtrack2.c10
-rw-r--r--drivers/media/radio/radio-sf16fmi.c10
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c10
-rw-r--r--drivers/media/radio/radio-si470x.c14
-rw-r--r--drivers/media/radio/radio-tea5764.c634
-rw-r--r--drivers/media/radio/radio-terratec.c10
-rw-r--r--drivers/media/radio/radio-trust.c10
-rw-r--r--drivers/media/radio/radio-typhoon.c10
-rw-r--r--drivers/media/radio/radio-zoltrix.c10
-rw-r--r--drivers/media/video/Makefile5
-rw-r--r--drivers/media/video/arv.c14
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c30
-rw-r--r--drivers/media/video/bw-qcam.c14
-rw-r--r--drivers/media/video/c-qcam.c14
-rw-r--r--drivers/media/video/cafe_ccic.c16
-rw-r--r--drivers/media/video/cpia.c14
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c16
-rw-r--r--drivers/media/video/cs5345.c13
-rw-r--r--drivers/media/video/cs53l32a.c2
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c6
-rw-r--r--drivers/media/video/cx18/cx18-fileops.h4
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c28
-rw-r--r--drivers/media/video/cx18/cx18-i2c.h1
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c49
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.h2
-rw-r--r--drivers/media/video/cx18/cx18-streams.c13
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c15
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c22
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c13
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c13
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c3
-rw-r--r--drivers/media/video/cx88/cx88-video.c27
-rw-r--r--drivers/media/video/cx88/cx88.h2
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c91
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-reg.h2
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c44
-rw-r--r--drivers/media/video/em28xx/em28xx.h4
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c20
-rw-r--r--drivers/media/video/gspca/gspca.c12
-rw-r--r--drivers/media/video/hexium_gemini.c2
-rw-r--r--drivers/media/video/hexium_orion.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c7
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.h4
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c25
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c8
-rw-r--r--drivers/media/video/m52790.c13
-rw-r--r--drivers/media/video/meye.c12
-rw-r--r--drivers/media/video/msp3400-driver.c4
-rw-r--r--drivers/media/video/mt9m001.c19
-rw-r--r--drivers/media/video/mt9m111.c19
-rw-r--r--drivers/media/video/mt9t031.c18
-rw-r--r--drivers/media/video/mt9v022.c19
-rw-r--r--drivers/media/video/mxb.c2
-rw-r--r--drivers/media/video/omap24xxcam.c9
-rw-r--r--drivers/media/video/ov511.c16
-rw-r--r--drivers/media/video/ov7670.c2
-rw-r--r--drivers/media/video/ov772x.c7
-rw-r--r--drivers/media/video/pms.c14
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c11
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c29
-rw-r--r--drivers/media/video/pwc/pwc-ctrl.c4
-rw-r--r--drivers/media/video/pwc/pwc-if.c20
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c2
-rw-r--r--drivers/media/video/pwc/pwc.h4
-rw-r--r--drivers/media/video/s2255drv.c12
-rw-r--r--drivers/media/video/saa5246a.c13
-rw-r--r--drivers/media/video/saa5249.c16
-rw-r--r--drivers/media/video/saa7115.c13
-rw-r--r--drivers/media/video/saa7127.c13
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c44
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c18
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c23
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c23
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
-rw-r--r--drivers/media/video/saa717x.c9
-rw-r--r--drivers/media/video/se401.c14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c18
-rw-r--r--drivers/media/video/soc_camera.c13
-rw-r--r--drivers/media/video/stk-webcam.c10
-rw-r--r--drivers/media/video/stradis.c12
-rw-r--r--drivers/media/video/stv680.c14
-rw-r--r--drivers/media/video/tda9840.c2
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c2
-rw-r--r--drivers/media/video/tuner-core.c2
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/media/video/tvp5150.c13
-rw-r--r--drivers/media/video/tw9910.c6
-rw-r--r--drivers/media/video/upd64031a.c13
-rw-r--r--drivers/media/video/upd64083.c13
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c20
-rw-r--r--drivers/media/video/usbvideo/vicam.c16
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c37
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c14
-rw-r--r--drivers/media/video/uvc/uvcvideo.h2
-rw-r--r--drivers/media/video/v4l1-compat.c164
-rw-r--r--drivers/media/video/v4l2-common.c29
-rw-r--r--drivers/media/video/v4l2-compat-ioctl32.c27
-rw-r--r--drivers/media/video/v4l2-dev.c25
-rw-r--r--drivers/media/video/v4l2-ioctl.c36
-rw-r--r--drivers/media/video/v4l2-subdev.c2
-rw-r--r--drivers/media/video/vino.c13
-rw-r--r--drivers/media/video/vivi.c12
-rw-r--r--drivers/media/video/vp27smpx.c2
-rw-r--r--drivers/media/video/w9966.c16
-rw-r--r--drivers/media/video/w9968cf.c36
-rw-r--r--drivers/media/video/wm8739.c2
-rw-r--r--drivers/media/video/wm8775.c2
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c18
-rw-r--r--drivers/media/video/zoran/zoran_driver.c25
-rw-r--r--drivers/media/video/zr364xx.c8
-rw-r--r--drivers/message/i2o/exec-osm.c2
-rw-r--r--drivers/message/i2o/i2o_config.c2
-rw-r--r--drivers/message/i2o/iop.c2
-rw-r--r--drivers/message/i2o/pci.c2
-rw-r--r--drivers/mfd/Kconfig66
-rw-r--r--drivers/mfd/Makefile7
-rw-r--r--drivers/mfd/da903x.c16
-rw-r--r--drivers/mfd/dm355evm_msp.c420
-rw-r--r--drivers/mfd/menelaus.c (renamed from drivers/i2c/chips/menelaus.c)0
-rw-r--r--drivers/mfd/mfd-core.c1
-rw-r--r--drivers/mfd/tps65010.c (renamed from drivers/i2c/chips/tps65010.c)0
-rw-r--r--drivers/mfd/twl4030-core.c472
-rw-r--r--drivers/mfd/twl4030-irq.c30
-rw-r--r--drivers/mfd/wm8350-core.c266
-rw-r--r--drivers/mfd/wm8350-i2c.c4
-rw-r--r--drivers/mfd/wm8350-regmap.c2100
-rw-r--r--drivers/mfd/wm8400-core.c31
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c2
-rw-r--r--drivers/mmc/card/block.c122
-rw-r--r--drivers/mmc/core/core.c77
-rw-r--r--drivers/mmc/core/mmc.c18
-rw-r--r--drivers/mmc/host/Makefile3
-rw-r--r--drivers/mmc/host/at91_mci.c4
-rw-r--r--drivers/mmc/host/mmc_spi.c4
-rw-r--r--drivers/mmc/host/of_mmc_spi.c149
-rw-r--r--drivers/mmc/host/pxamci.c2
-rw-r--r--drivers/mmc/host/ricoh_mmc.c17
-rw-r--r--drivers/mmc/host/sdhci-pci.c2
-rw-r--r--drivers/mmc/host/sdhci.c17
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mmc/host/sdricoh_cs.c4
-rw-r--r--drivers/mmc/host/tmio_mmc.c3
-rw-r--r--drivers/mtd/ubi/build.c5
-rw-r--r--drivers/mtd/ubi/cdev.c3
-rw-r--r--drivers/mtd/ubi/debug.h10
-rw-r--r--drivers/mtd/ubi/eba.c51
-rw-r--r--drivers/mtd/ubi/io.c28
-rw-r--r--drivers/mtd/ubi/ubi.h45
-rw-r--r--drivers/mtd/ubi/wl.c489
-rw-r--r--drivers/net/acenic.c117
-rw-r--r--drivers/net/acenic.h4
-rw-r--r--drivers/net/e100.c268
-rw-r--r--drivers/net/ehea/ehea.h3
-rw-r--r--drivers/net/ehea/ehea_main.c2
-rw-r--r--drivers/net/enc28j60.c4
-rw-r--r--drivers/net/igb/igb_main.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c6
-rw-r--r--drivers/net/qlge/qlge.h57
-rw-r--r--drivers/net/qlge/qlge_dbg.c13
-rw-r--r--drivers/net/qlge/qlge_ethtool.c8
-rw-r--r--drivers/net/qlge/qlge_main.c116
-rw-r--r--drivers/net/starfire.c54
-rw-r--r--drivers/net/starfire_firmware.h346
-rw-r--r--drivers/net/starfire_firmware.pl31
-rw-r--r--drivers/net/tg3.c792
-rw-r--r--drivers/net/tg3.h4
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/oprofile/oprofilefs.c3
-rw-r--r--drivers/pci/dmar.c46
-rw-r--r--drivers/pci/intel-iommu.c944
-rw-r--r--drivers/pnp/pnpbios/bioscalls.c2
-rw-r--r--drivers/power/Kconfig14
-rw-r--r--drivers/power/Makefile2
-rw-r--r--drivers/power/da9030_battery.c600
-rw-r--r--drivers/power/power_supply_sysfs.c2
-rw-r--r--drivers/power/wm8350_power.c532
-rw-r--r--drivers/regulator/wm8350-regulator.c7
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/interface.c54
-rw-r--r--drivers/rtc/rtc-dev.c51
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--drivers/s390/net/qeth_core.h1
-rw-r--r--drivers/s390/net/qeth_core_main.c57
-rw-r--r--drivers/s390/net/qeth_l2_main.c8
-rw-r--r--drivers/s390/net/qeth_l3_main.c26
-rw-r--r--drivers/s390/s390mach.c3
-rw-r--r--drivers/usb/core/inode.c1
-rw-r--r--drivers/usb/gadget/file_storage.c18
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/video/via/viafbdev.c248
-rw-r--r--drivers/watchdog/Kconfig19
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/ib700wdt.c49
-rw-r--r--drivers/watchdog/sch311x_wdt.c578
-rw-r--r--drivers/watchdog/wm8350_wdt.c329
-rw-r--r--firmware/Makefile11
-rw-r--r--firmware/WHENCE49
-rw-r--r--firmware/acenic/tg1.bin.ihex4573
-rw-r--r--firmware/acenic/tg2.bin.ihex4844
-rw-r--r--firmware/adaptec/starfire_rx.bin.ihex53
-rw-r--r--firmware/adaptec/starfire_tx.bin.ihex53
-rw-r--r--firmware/tigon/tg3.bin.ihex175
-rw-r--r--firmware/tigon/tg3_tso.bin.ihex446
-rw-r--r--firmware/tigon/tg3_tso5.bin.ihex252
-rw-r--r--fs/Kconfig18
-rw-r--r--fs/Makefile1
-rw-r--r--fs/affs/file.c2
-rw-r--r--fs/affs/inode.c3
-rw-r--r--fs/afs/write.c2
-rw-r--r--fs/autofs/inode.c2
-rw-r--r--fs/autofs4/inode.c4
-rw-r--r--fs/binfmt_aout.c81
-rw-r--r--fs/binfmt_misc.c3
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/cifs/file.c2
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/coda/file.c12
-rw-r--r--fs/configfs/inode.c3
-rw-r--r--fs/cramfs/inode.c2
-rw-r--r--fs/debugfs/inode.c3
-rw-r--r--fs/devpts/inode.c4
-rw-r--r--fs/dlm/ast.c56
-rw-r--r--fs/dlm/ast.h4
-rw-r--r--fs/dlm/debug_fs.c310
-rw-r--r--fs/dlm/dir.c18
-rw-r--r--fs/dlm/dlm_internal.h4
-rw-r--r--fs/dlm/lock.c31
-rw-r--r--fs/dlm/lowcomms.c8
-rw-r--r--fs/dlm/memory.c6
-rw-r--r--fs/dlm/midcomms.c2
-rw-r--r--fs/dlm/netlink.c1
-rw-r--r--fs/dlm/user.c4
-rw-r--r--fs/dlm/user.h2
-rw-r--r--fs/dquot.c436
-rw-r--r--fs/ecryptfs/file.c15
-rw-r--r--fs/ecryptfs/inode.c3
-rw-r--r--fs/ecryptfs/mmap.c2
-rw-r--r--fs/exec.c44
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/namei.c3
-rw-r--r--fs/ext3/super.c16
-rw-r--r--fs/ext4/ext4_sb.h6
-rw-r--r--fs/ext4/inode.c4
-rw-r--r--fs/ext4/namei.c3
-rw-r--r--fs/ext4/super.c15
-rw-r--r--fs/filesystems.c23
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/gfs2/Makefile2
-rw-r--r--fs/gfs2/acl.c2
-rw-r--r--fs/gfs2/bmap.c77
-rw-r--r--fs/gfs2/bmap.h34
-rw-r--r--fs/gfs2/daemon.c136
-rw-r--r--fs/gfs2/daemon.h17
-rw-r--r--fs/gfs2/dir.c62
-rw-r--r--fs/gfs2/dir.h1
-rw-r--r--fs/gfs2/eattr.c40
-rw-r--r--fs/gfs2/glock.c303
-rw-r--r--fs/gfs2/glock.h2
-rw-r--r--fs/gfs2/glops.c56
-rw-r--r--fs/gfs2/incore.h55
-rw-r--r--fs/gfs2/inode.c53
-rw-r--r--fs/gfs2/inode.h13
-rw-r--r--fs/gfs2/locking/dlm/mount.c12
-rw-r--r--fs/gfs2/locking/dlm/sysfs.c16
-rw-r--r--fs/gfs2/main.c15
-rw-r--r--fs/gfs2/mount.c29
-rw-r--r--fs/gfs2/ops_address.c34
-rw-r--r--fs/gfs2/ops_dentry.c2
-rw-r--r--fs/gfs2/ops_dentry.h17
-rw-r--r--fs/gfs2/ops_export.c5
-rw-r--r--fs/gfs2/ops_file.c22
-rw-r--r--fs/gfs2/ops_fstype.c125
-rw-r--r--fs/gfs2/ops_fstype.h19
-rw-r--r--fs/gfs2/ops_inode.c75
-rw-r--r--fs/gfs2/ops_inode.h25
-rw-r--r--fs/gfs2/ops_super.c149
-rw-r--r--fs/gfs2/ops_super.h17
-rw-r--r--fs/gfs2/quota.c113
-rw-r--r--fs/gfs2/quota.h24
-rw-r--r--fs/gfs2/recovery.c48
-rw-r--r--fs/gfs2/recovery.h14
-rw-r--r--fs/gfs2/rgrp.c58
-rw-r--r--fs/gfs2/super.c246
-rw-r--r--fs/gfs2/super.h13
-rw-r--r--fs/gfs2/sys.c66
-rw-r--r--fs/gfs2/sys.h4
-rw-r--r--fs/gfs2/util.c1
-rw-r--r--fs/gfs2/util.h1
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hugetlbfs/inode.c1
-rw-r--r--fs/inode.c2
-rw-r--r--fs/ioctl.c44
-rw-r--r--fs/isofs/inode.c6
-rw-r--r--fs/jbd2/commit.c9
-rw-r--r--fs/jbd2/journal.c19
-rw-r--r--fs/jbd2/transaction.c47
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/jfs/jfs_imap.c10
-rw-r--r--fs/libfs.c7
-rw-r--r--fs/namei.c45
-rw-r--r--fs/nfs/file.c2
-rw-r--r--fs/nfsd/vfs.c43
-rw-r--r--fs/notify/inotify/inotify_user.c2
-rw-r--r--fs/ntfs/inode.c3
-rw-r--r--fs/ocfs2/Makefile7
-rw-r--r--fs/ocfs2/acl.c479
-rw-r--r--fs/ocfs2/acl.h58
-rw-r--r--fs/ocfs2/alloc.c710
-rw-r--r--fs/ocfs2/alloc.h30
-rw-r--r--fs/ocfs2/aops.c59
-rw-r--r--fs/ocfs2/blockcheck.c477
-rw-r--r--fs/ocfs2/blockcheck.h82
-rw-r--r--fs/ocfs2/buffer_head_io.c32
-rw-r--r--fs/ocfs2/buffer_head_io.h27
-rw-r--r--fs/ocfs2/cluster/masklog.c1
-rw-r--r--fs/ocfs2/cluster/masklog.h1
-rw-r--r--fs/ocfs2/dir.c399
-rw-r--r--fs/ocfs2/dir.h2
-rw-r--r--fs/ocfs2/dlm/dlmast.c52
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h3
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c53
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c1
-rw-r--r--fs/ocfs2/dlm/dlmfs.c2
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c42
-rw-r--r--fs/ocfs2/dlm/dlmthread.c3
-rw-r--r--fs/ocfs2/dlmglue.c168
-rw-r--r--fs/ocfs2/dlmglue.h19
-rw-r--r--fs/ocfs2/extent_map.c96
-rw-r--r--fs/ocfs2/extent_map.h24
-rw-r--r--fs/ocfs2/file.c209
-rw-r--r--fs/ocfs2/file.h3
-rw-r--r--fs/ocfs2/inode.c175
-rw-r--r--fs/ocfs2/inode.h18
-rw-r--r--fs/ocfs2/journal.c364
-rw-r--r--fs/ocfs2/journal.h128
-rw-r--r--fs/ocfs2/localalloc.c26
-rw-r--r--fs/ocfs2/namei.c318
-rw-r--r--fs/ocfs2/ocfs2.h46
-rw-r--r--fs/ocfs2/ocfs2_fs.h213
-rw-r--r--fs/ocfs2/ocfs2_jbd_compat.h82
-rw-r--r--fs/ocfs2/ocfs2_lockid.h5
-rw-r--r--fs/ocfs2/quota.h119
-rw-r--r--fs/ocfs2/quota_global.c1025
-rw-r--r--fs/ocfs2/quota_local.c1253
-rw-r--r--fs/ocfs2/resize.c76
-rw-r--r--fs/ocfs2/slot_map.c4
-rw-r--r--fs/ocfs2/suballoc.c363
-rw-r--r--fs/ocfs2/suballoc.h18
-rw-r--r--fs/ocfs2/super.c328
-rw-r--r--fs/ocfs2/symlink.c2
-rw-r--r--fs/ocfs2/xattr.c2984
-rw-r--r--fs/ocfs2/xattr.h45
-rw-r--r--fs/omfs/inode.c1
-rw-r--r--fs/open.c2
-rw-r--r--fs/openpromfs/inode.c3
-rw-r--r--fs/pipe.c7
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/proc/proc_sysctl.c1
-rw-r--r--fs/quota.c11
-rw-r--r--fs/quota_tree.c645
-rw-r--r--fs/quota_tree.h25
-rw-r--r--fs/quota_v1.c28
-rw-r--r--fs/quota_v2.c631
-rw-r--r--fs/quotaio_v1.h (renamed from include/linux/quotaio_v1.h)0
-rw-r--r--fs/quotaio_v2.h (renamed from include/linux/quotaio_v2.h)33
-rw-r--r--fs/ramfs/inode.c1
-rw-r--r--fs/read_write.c13
-rw-r--r--fs/reiserfs/inode.c15
-rw-r--r--fs/reiserfs/super.c10
-rw-r--r--fs/romfs/inode.c1
-rw-r--r--fs/seq_file.c3
-rw-r--r--fs/smbfs/file.c2
-rw-r--r--fs/stat.c2
-rw-r--r--fs/sync.c48
-rw-r--r--fs/sysfs/inode.c3
-rw-r--r--fs/ubifs/budget.c208
-rw-r--r--fs/ubifs/commit.c25
-rw-r--r--fs/ubifs/compress.c18
-rw-r--r--fs/ubifs/debug.c265
-rw-r--r--fs/ubifs/debug.h117
-rw-r--r--fs/ubifs/file.c17
-rw-r--r--fs/ubifs/ioctl.c2
-rw-r--r--fs/ubifs/journal.c4
-rw-r--r--fs/ubifs/key.h32
-rw-r--r--fs/ubifs/lprops.c14
-rw-r--r--fs/ubifs/lpt.c45
-rw-r--r--fs/ubifs/lpt_commit.c210
-rw-r--r--fs/ubifs/orphan.c2
-rw-r--r--fs/ubifs/replay.c15
-rw-r--r--fs/ubifs/sb.c20
-rw-r--r--fs/ubifs/super.c255
-rw-r--r--fs/ubifs/tnc.c31
-rw-r--r--fs/ubifs/tnc_commit.c9
-rw-r--r--fs/ubifs/ubifs-media.h7
-rw-r--r--fs/ubifs/ubifs.h111
-rw-r--r--fs/xattr.c2
-rw-r--r--include/acpi/processor.h4
-rw-r--r--include/asm-frv/bitops.h13
-rw-r--r--include/asm-m32r/bitops.h1
-rw-r--r--include/asm-m68k/bitops.h5
-rw-r--r--include/asm-mn10300/bitops.h11
-rw-r--r--include/asm-xtensa/bitops.h11
-rw-r--r--include/linux/Kbuild4
-rw-r--r--include/linux/audit.h98
-rw-r--r--include/linux/bitmap.h35
-rw-r--r--include/linux/bitops.h13
-rw-r--r--include/linux/blockgroup_lock.h7
-rw-r--r--include/linux/compiler-gcc3.h4
-rw-r--r--include/linux/cpufreq.h1
-rw-r--r--include/linux/cpumask.h221
-rw-r--r--include/linux/device-mapper.h28
-rw-r--r--include/linux/dma_remapping.h144
-rw-r--r--include/linux/dmar.h1
-rw-r--r--include/linux/dqblk_qtree.h56
-rw-r--r--include/linux/dqblk_v1.h7
-rw-r--r--include/linux/dqblk_v2.h22
-rw-r--r--include/linux/dvb/frontend.h27
-rw-r--r--include/linux/ext2_fs_sb.h6
-rw-r--r--include/linux/ext3_fs_sb.h6
-rw-r--r--include/linux/fs.h10
-rw-r--r--include/linux/hid.h16
-rw-r--r--include/linux/hidraw.h2
-rw-r--r--include/linux/i2c/dm355evm_msp.h79
-rw-r--r--include/linux/i2c/twl4030.h81
-rw-r--r--include/linux/intel-iommu.h25
-rw-r--r--include/linux/interrupt.h2
-rw-r--r--include/linux/iommu.h112
-rw-r--r--include/linux/jbd2.h32
-rw-r--r--include/linux/journal-head.h8
-rw-r--r--include/linux/kernel_stat.h13
-rw-r--r--include/linux/kvm_host.h30
-rw-r--r--include/linux/mfd/da903x.h44
-rw-r--r--include/linux/mfd/wm8350/comparator.h8
-rw-r--r--include/linux/mfd/wm8350/core.h52
-rw-r--r--include/linux/mfd/wm8350/pmic.h4
-rw-r--r--include/linux/mfd/wm8350/supply.h25
-rw-r--r--include/linux/mmc/core.h2
-rw-r--r--include/linux/mmc/host.h2
-rw-r--r--include/linux/moduleloader.h3
-rw-r--r--include/linux/netdevice.h16
-rw-r--r--include/linux/pagemap.h3
-rw-r--r--include/linux/power_supply.h1
-rw-r--r--include/linux/quota.h108
-rw-r--r--include/linux/quotaops.h96
-rw-r--r--include/linux/radix-tree.h2
-rw-r--r--include/linux/random.h50
-rw-r--r--include/linux/rcuclassic.h4
-rw-r--r--include/linux/rtc.h8
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/seq_file.h7
-rw-r--r--include/linux/smp.h18
-rw-r--r--include/linux/spi/mmc_spi.h15
-rw-r--r--include/linux/spi/spi.h2
-rw-r--r--include/linux/stop_machine.h28
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/threads.h16
-rw-r--r--include/linux/tick.h4
-rw-r--r--include/linux/videodev2.h51
-rw-r--r--include/media/saa7146_vv.h6
-rw-r--r--include/media/soc_camera.h6
-rw-r--r--include/media/v4l2-chip-ident.h4
-rw-r--r--include/media/v4l2-common.h6
-rw-r--r--include/media/v4l2-dev.h15
-rw-r--r--include/media/v4l2-device.h2
-rw-r--r--include/media/v4l2-int-device.h2
-rw-r--r--include/media/v4l2-ioctl.h31
-rw-r--r--include/media/v4l2-subdev.h8
-rw-r--r--include/net/ndisc.h4
-rw-r--r--include/sound/tea575x-tuner.h2
-rw-r--r--init/Kconfig6
-rw-r--r--init/main.c13
-rw-r--r--ipc/mqueue.c98
-rw-r--r--ipc/sem.c2
-rw-r--r--ipc/shm.c4
-rw-r--r--ipc/util.c18
-rw-r--r--kernel/audit.h5
-rw-r--r--kernel/audit_tree.c3
-rw-r--r--kernel/auditfilter.c325
-rw-r--r--kernel/auditsc.c739
-rw-r--r--kernel/capability.c4
-rw-r--r--kernel/cgroup.c7
-rw-r--r--kernel/compat.c49
-rw-r--r--kernel/cpu.c150
-rw-r--r--kernel/irq/manage.c11
-rw-r--r--kernel/irq/proc.c34
-rw-r--r--kernel/kexec.c2
-rw-r--r--kernel/module.c59
-rw-r--r--kernel/power/poweroff.c2
-rw-r--r--kernel/profile.c38
-rw-r--r--kernel/rcuclassic.c32
-rw-r--r--kernel/rcupreempt.c19
-rw-r--r--kernel/rcutorture.c27
-rw-r--r--kernel/sched.c168
-rw-r--r--kernel/sched_rt.c3
-rw-r--r--kernel/smp.c145
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/softlockup.c10
-rw-r--r--kernel/stop_machine.c63
-rw-r--r--kernel/taskstats.c39
-rw-r--r--kernel/time/clocksource.c9
-rw-r--r--kernel/time/tick-broadcast.c115
-rw-r--r--kernel/time/tick-common.c6
-rw-r--r--kernel/time/tick-sched.c12
-rw-r--r--kernel/timer.c15
-rw-r--r--kernel/trace/ring_buffer.c42
-rw-r--r--kernel/trace/trace.c72
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_boot.c2
-rw-r--r--kernel/trace/trace_functions_graph.c2
-rw-r--r--kernel/trace/trace_hw_branches.c6
-rw-r--r--kernel/trace/trace_power.c2
-rw-r--r--kernel/trace/trace_sysprof.c13
-rw-r--r--kernel/workqueue.c26
-rw-r--r--lib/Kconfig8
-rw-r--r--lib/Makefile1
-rw-r--r--lib/cpumask.c62
-rw-r--r--lib/find_last_bit.c45
-rw-r--r--lib/swiotlb.c3
-rw-r--r--lib/vsprintf.c3
-rw-r--r--mm/filemap.c15
-rw-r--r--mm/memory.c4
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/mprotect.c2
-rw-r--r--mm/mremap.c2
-rw-r--r--mm/msync.c2
-rw-r--r--mm/nommu.c2
-rw-r--r--mm/pdflush.c16
-rw-r--r--mm/slab.c2
-rw-r--r--mm/slub.c20
-rw-r--r--mm/vmalloc.c5
-rw-r--r--mm/vmscan.c4
-rw-r--r--mm/vmstat.c4
-rw-r--r--net/can/bcm.c208
-rw-r--r--net/core/dev.c93
-rw-r--r--net/core/skbuff.c15
-rw-r--r--net/dcb/dcbnl.c14
-rw-r--r--net/dccp/Kconfig4
-rw-r--r--net/dccp/Makefile15
-rw-r--r--net/dccp/ackvec.h49
-rw-r--r--net/dccp/ccid.c254
-rw-r--r--net/dccp/ccid.h14
-rw-r--r--net/dccp/ccids/Kconfig79
-rw-r--r--net/dccp/ccids/Makefile9
-rw-r--r--net/dccp/ccids/ccid2.c22
-rw-r--r--net/dccp/ccids/ccid3.c23
-rw-r--r--net/dccp/ccids/lib/Makefile3
-rw-r--r--net/dccp/ccids/lib/loss_interval.c3
-rw-r--r--net/dccp/ccids/lib/packet_history.c9
-rw-r--r--net/dccp/ccids/lib/tfrc.c19
-rw-r--r--net/dccp/ccids/lib/tfrc.h11
-rw-r--r--net/dccp/ccids/lib/tfrc_equation.c4
-rw-r--r--net/dccp/dccp.h2
-rw-r--r--net/dccp/feat.c6
-rw-r--r--net/dccp/input.c2
-rw-r--r--net/dccp/proto.c7
-rw-r--r--net/ipv4/tcp.c9
-rw-r--r--net/ipv6/ipv6_sockglue.c2
-rw-r--r--net/ipv6/route.c52
-rw-r--r--net/iucv/af_iucv.c28
-rw-r--r--net/iucv/iucv.c18
-rw-r--r--net/rfkill/rfkill.c4
-rw-r--r--net/sched/cls_u32.c3
-rw-r--r--net/socket.c13
-rw-r--r--net/sunrpc/rpc_pipe.c2
-rw-r--r--scripts/headers_check.pl70
-rw-r--r--scripts/headers_install.pl3
-rw-r--r--scripts/kconfig/expr.h82
-rw-r--r--scripts/kconfig/lex.zconf.c_shipped7
-rw-r--r--scripts/kconfig/zconf.l7
-rwxr-xr-xscripts/tags.sh1
-rw-r--r--security/commoncap.c6
-rw-r--r--security/inode.c3
-rw-r--r--security/selinux/selinuxfs.c4
-rw-r--r--security/selinux/ss/services.c26
-rw-r--r--security/smack/smack_lsm.c6
-rw-r--r--sound/i2c/other/tea575x-tuner.c6
-rw-r--r--sound/pci/hda/patch_conexant.c114
-rw-r--r--sound/pci/hda/patch_realtek.c3
-rw-r--r--sound/pci/ice1712/ice1724.c2
-rw-r--r--sound/soc/codecs/twl4030.c377
-rw-r--r--sound/soc/codecs/twl4030.h7
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c4
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c4
-rw-r--r--sound/soc/soc-core.c46
-rw-r--r--sound/soc/soc-dapm.c10
-rw-r--r--sound/usb/caiaq/caiaq-device.c4
-rw-r--r--sound/usb/usbaudio.c8
-rw-r--r--sound/usb/usbmidi.c39
-rw-r--r--sound/usb/usbmixer.c5
-rw-r--r--sound/usb/usx2y/us122l.c4
-rw-r--r--sound/usb/usx2y/usbusx2y.c4
-rw-r--r--virt/kvm/iommu.c (renamed from virt/kvm/vtd.c)135
-rw-r--r--virt/kvm/kvm_main.c50
865 files changed, 41692 insertions, 16540 deletions
diff --git a/CREDITS b/CREDITS
index b50db1767554..abe05a0be4ed 100644
--- a/CREDITS
+++ b/CREDITS
@@ -369,10 +369,10 @@ P: 1024/8462A731 4C 55 86 34 44 59 A7 99 2B 97 88 4A 88 9A 0D 97
369D: sun4 port, Sparc hacker 369D: sun4 port, Sparc hacker
370 370
371N: Hugh Blemings 371N: Hugh Blemings
372E: hugh@misc.nu 372E: hugh@blemings.org
373W: http://misc.nu/hugh/ 373W: http://blemings.org/hugh
374D: Author and maintainer of the Keyspan USB to Serial drivers 374D: Original author of the Keyspan USB to serial drivers, random PowerPC hacker
375S: Po Box 234 375S: PO Box 234
376S: Belconnen ACT 2616 376S: Belconnen ACT 2616
377S: Australia 377S: Australia
378 378
diff --git a/Documentation/cputopology.txt b/Documentation/cputopology.txt
index bd699da24666..45932ec21cee 100644
--- a/Documentation/cputopology.txt
+++ b/Documentation/cputopology.txt
@@ -31,3 +31,51 @@ not defined by include/asm-XXX/topology.h:
312) core_id: 0 312) core_id: 0
323) thread_siblings: just the given CPU 323) thread_siblings: just the given CPU
334) core_siblings: just the given CPU 334) core_siblings: just the given CPU
34
35Additionally, cpu topology information is provided under
36/sys/devices/system/cpu and includes these files. The internal
37source for the output is in brackets ("[]").
38
39 kernel_max: the maximum cpu index allowed by the kernel configuration.
40 [NR_CPUS-1]
41
42 offline: cpus that are not online because they have been
43 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
44 of cpus allowed by the kernel configuration (kernel_max
45 above). [~cpu_online_mask + cpus >= NR_CPUS]
46
47 online: cpus that are online and being scheduled [cpu_online_mask]
48
49 possible: cpus that have been allocated resources and can be
50 brought online if they are present. [cpu_possible_mask]
51
52 present: cpus that have been identified as being present in the
53 system. [cpu_present_mask]
54
55The format for the above output is compatible with cpulist_parse()
56[see <linux/cpumask.h>]. Some examples follow.
57
58In this example, there are 64 cpus in the system but cpus 32-63 exceed
59the kernel max which is limited to 0..31 by the NR_CPUS config option
60being 32. Note also that cpus 2 and 4-31 are not online but could be
61brought online as they are both present and possible.
62
63 kernel_max: 31
64 offline: 2,4-31,32-63
65 online: 0-1,3
66 possible: 0-31
67 present: 0-31
68
69In this example, the NR_CPUS config option is 128, but the kernel was
70started with possible_cpus=144. There are 4 cpus in the system and cpu2
71was manually taken offline (and is the only cpu that can be brought
72online.)
73
74 kernel_max: 127
75 offline: 2,4-127,128-143
76 online: 0-1,3
77 possible: 0-127
78 present: 0-3
79
80See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
81as well as more information on the various cpumask's.
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index 67310fbbb7df..c2a0871280a0 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -31,7 +31,6 @@ Features which OCFS2 does not support yet:
31 - quotas 31 - quotas
32 - Directory change notification (F_NOTIFY) 32 - Directory change notification (F_NOTIFY)
33 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease) 33 - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease)
34 - POSIX ACLs
35 34
36Mount options 35Mount options
37============= 36=============
@@ -79,3 +78,5 @@ inode64 Indicates that Ocfs2 is allowed to create inodes at
79 bits of significance. 78 bits of significance.
80user_xattr (*) Enables Extended User Attributes. 79user_xattr (*) Enables Extended User Attributes.
81nouser_xattr Disables Extended User Attributes. 80nouser_xattr Disables Extended User Attributes.
81acl Enables POSIX Access Control Lists support.
82noacl (*) Disables POSIX Access Control Lists support.
diff --git a/Documentation/filesystems/ubifs.txt b/Documentation/filesystems/ubifs.txt
index dd84ea3c10da..84da2a4ba25a 100644
--- a/Documentation/filesystems/ubifs.txt
+++ b/Documentation/filesystems/ubifs.txt
@@ -95,6 +95,9 @@ no_chk_data_crc skip checking of CRCs on data nodes in order to
95 of this option is that corruption of the contents 95 of this option is that corruption of the contents
96 of a file can go unnoticed. 96 of a file can go unnoticed.
97chk_data_crc (*) do not skip checking CRCs on data nodes 97chk_data_crc (*) do not skip checking CRCs on data nodes
98compr=none override default compressor and set it to "none"
99compr=lzo override default compressor and set it to "lzo"
100compr=zlib override default compressor and set it to "zlib"
98 101
99 102
100Quick usage instructions 103Quick usage instructions
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index b880ce5dbd33..824699174436 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -97,6 +97,7 @@ Code Seq# Include File Comments
97 <http://linux01.gwdg.de/~alatham/ppdd.html> 97 <http://linux01.gwdg.de/~alatham/ppdd.html>
98'M' all linux/soundcard.h 98'M' all linux/soundcard.h
99'N' 00-1F drivers/usb/scanner.h 99'N' 00-1F drivers/usb/scanner.h
100'O' 00-02 include/mtd/ubi-user.h UBI
100'P' all linux/soundcard.h 101'P' all linux/soundcard.h
101'Q' all linux/soundcard.h 102'Q' all linux/soundcard.h
102'R' 00-1F linux/random.h 103'R' 00-1F linux/random.h
@@ -142,6 +143,9 @@ Code Seq# Include File Comments
142'n' 00-7F linux/ncp_fs.h 143'n' 00-7F linux/ncp_fs.h
143'n' E0-FF video/matrox.h matroxfb 144'n' E0-FF video/matrox.h matroxfb
144'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 145'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2
146'o' 00-03 include/mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps)
147'o' 40-41 include/mtd/ubi-user.h UBI
148'o' 01-A1 include/linux/dvb/*.h DVB
145'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this) 149'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this)
146'p' 00-3F linux/mc146818rtc.h conflict! 150'p' 00-3F linux/mc146818rtc.h conflict!
147'p' 40-7F linux/nvram.h 151'p' 40-7F linux/nvram.h
diff --git a/Documentation/kbuild/00-INDEX b/Documentation/kbuild/00-INDEX
index 114644285454..e8d2b6d83a3d 100644
--- a/Documentation/kbuild/00-INDEX
+++ b/Documentation/kbuild/00-INDEX
@@ -1,5 +1,9 @@
100-INDEX 100-INDEX
2 - this file: info on the kernel build process 2 - this file: info on the kernel build process
3kbuild.txt
4 - developer information on kbuild
5kconfig.txt
6 - usage help for make *config
3kconfig-language.txt 7kconfig-language.txt
4 - specification of Config Language, the language in Kconfig files 8 - specification of Config Language, the language in Kconfig files
5makefiles.txt 9makefiles.txt
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
new file mode 100644
index 000000000000..51771847e816
--- /dev/null
+++ b/Documentation/kbuild/kbuild.txt
@@ -0,0 +1,126 @@
1Environment variables
2
3KCPPFLAGS
4--------------------------------------------------
5Additional options to pass when preprocessing. The preprocessing options
6will be used in all cases where kbuild do preprocessing including
7building C files and assembler files.
8
9KAFLAGS
10--------------------------------------------------
11Additional options to the assembler.
12
13KCFLAGS
14--------------------------------------------------
15Additional options to the C compiler.
16
17KBUILD_VERBOSE
18--------------------------------------------------
19Set the kbuild verbosity. Can be assinged same values as "V=...".
20See make help for the full list.
21Setting "V=..." takes precedence over KBUILD_VERBOSE.
22
23KBUILD_EXTMOD
24--------------------------------------------------
25Set the directory to look for the kernel source when building external
26modules.
27The directory can be specified in several ways:
281) Use "M=..." on the command line
292) Environmnet variable KBUILD_EXTMOD
303) Environmnet variable SUBDIRS
31The possibilities are listed in the order they take precedence.
32Using "M=..." will always override the others.
33
34KBUILD_OUTPUT
35--------------------------------------------------
36Specify the output directory when building the kernel.
37The output directory can also be specificed using "O=...".
38Setting "O=..." takes precedence over KBUILD_OUTPUT
39
40ARCH
41--------------------------------------------------
42Set ARCH to the architecture to be built.
43In most cases the name of the architecture is the same as the
44directory name found in the arch/ directory.
45But some architectures suach as x86 and sparc has aliases.
46x86: i386 for 32 bit, x86_64 for 64 bit
47sparc: sparc for 32 bit, sparc64 for 64 bit
48
49CROSS_COMPILE
50--------------------------------------------------
51Specify an optional fixed part of the binutils filename.
52CROSS_COMPILE can be a part of the filename or the full path.
53
54CROSS_COMPILE is also used for ccache is some setups.
55
56CF
57--------------------------------------------------
58Additional options for sparse.
59CF is often used on the command-line like this:
60
61 make CF=-Wbitwise C=2
62
63INSTALL_PATH
64--------------------------------------------------
65INSTALL_PATH specifies where to place the updated kernel and system map
66images. Default is /boot, but you can set it to other values
67
68
69MODLIB
70--------------------------------------------------
71Specify where to install modules.
72The default value is:
73
74 $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
75
76The value can be overridden in which case the default value is ignored.
77
78INSTALL_MOD_PATH
79--------------------------------------------------
80INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
81relocations required by build roots. This is not defined in the
82makefile but the argument can be passed to make if needed.
83
84INSTALL_MOD_STRIP
85--------------------------------------------------
86INSTALL_MOD_STRIP, if defined, will cause modules to be
87stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
88the default option --strip-debug will be used. Otherwise,
89INSTALL_MOD_STRIP will used as the options to the strip command.
90
91INSTALL_FW_PATH
92--------------------------------------------------
93INSTALL_FW_PATH specify where to install the firmware blobs.
94The default value is:
95
96 $(INSTALL_MOD_PATH)/lib/firmware
97
98The value can be overridden in which case the default value is ignored.
99
100INSTALL_HDR_PATH
101--------------------------------------------------
102INSTALL_HDR_PATH specify where to install user space headers when
103executing "make headers_*".
104The default value is:
105
106 $(objtree)/usr
107
108$(objtree) is the directory where output files are saved.
109The output directory is often set using "O=..." on the commandline.
110
111The value can be overridden in which case the default value is ignored.
112
113KBUILD_MODPOST_WARN
114--------------------------------------------------
115KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
116symbols in the final module linking stage.
117
118KBUILD_MODPOST_FINAL
119--------------------------------------------------
120KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
121This is solely usefull to speed up test compiles.
122
123KBUILD_EXTRA_SYMBOLS
124--------------------------------------------------
125For modules use symbols from another modules.
126See more details in modules.txt.
diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt
new file mode 100644
index 000000000000..26a7c0a93193
--- /dev/null
+++ b/Documentation/kbuild/kconfig.txt
@@ -0,0 +1,188 @@
1This file contains some assistance for using "make *config".
2
3Use "make help" to list all of the possible configuration targets.
4
5The xconfig ('qconf') and menuconfig ('mconf') programs also
6have embedded help text. Be sure to check it for navigation,
7search, and other general help text.
8
9======================================================================
10General
11--------------------------------------------------
12
13New kernel releases often introduce new config symbols. Often more
14important, new kernel releases may rename config symbols. When
15this happens, using a previously working .config file and running
16"make oldconfig" won't necessarily produce a working new kernel
17for you, so you may find that you need to see what NEW kernel
18symbols have been introduced.
19
20To see a list of new config symbols when using "make oldconfig", use
21
22 cp user/some/old.config .config
23 yes "" | make oldconfig >conf.new
24
25and the config program will list as (NEW) any new symbols that have
26unknown values. Of course, the .config file is also updated with
27new (default) values, so you can use:
28
29 grep "(NEW)" conf.new
30
31to see the new config symbols or you can 'diff' the previous and
32new .config files to see the differences:
33
34 diff .config.old .config | less
35
36(Yes, we need something better here.)
37
38
39======================================================================
40menuconfig
41--------------------------------------------------
42
43SEARCHING for CONFIG symbols
44
45Searching in menuconfig:
46
47 The Search function searches for kernel configuration symbol
48 names, so you have to know something close to what you are
49 looking for.
50
51 Example:
52 /hotplug
53 This lists all config symbols that contain "hotplug",
54 e.g., HOTPLUG, HOTPLUG_CPU, MEMORY_HOTPLUG.
55
56 For search help, enter / followed TAB-TAB-TAB (to highlight
57 <Help>) and Enter. This will tell you that you can also use
58 regular expressions (regexes) in the search string, so if you
59 are not interested in MEMORY_HOTPLUG, you could try
60
61 /^hotplug
62
63
64______________________________________________________________________
65Color Themes for 'menuconfig'
66
67It is possible to select different color themes using the variable
68MENUCONFIG_COLOR. To select a theme use:
69
70 make MENUCONFIG_COLOR=<theme> menuconfig
71
72Available themes are:
73 mono => selects colors suitable for monochrome displays
74 blackbg => selects a color scheme with black background
75 classic => theme with blue background. The classic look
76 bluetitle => a LCD friendly version of classic. (default)
77
78______________________________________________________________________
79Environment variables in 'menuconfig'
80
81KCONFIG_ALLCONFIG
82--------------------------------------------------
83(partially based on lkml email from/by Rob Landley, re: miniconfig)
84--------------------------------------------------
85The allyesconfig/allmodconfig/allnoconfig/randconfig variants can
86also use the environment variable KCONFIG_ALLCONFIG as a flag or a
87filename that contains config symbols that the user requires to be
88set to a specific value. If KCONFIG_ALLCONFIG is used without a
89filename, "make *config" checks for a file named
90"all{yes/mod/no/random}.config" (corresponding to the *config command
91that was used) for symbol values that are to be forced. If this file
92is not found, it checks for a file named "all.config" to contain forced
93values.
94
95This enables you to create "miniature" config (miniconfig) or custom
96config files containing just the config symbols that you are interested
97in. Then the kernel config system generates the full .config file,
98including dependencies of your miniconfig file, based on the miniconfig
99file.
100
101This 'KCONFIG_ALLCONFIG' file is a config file which contains
102(usually a subset of all) preset config symbols. These variable
103settings are still subject to normal dependency checks.
104
105Examples:
106 KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig
107or
108 KCONFIG_ALLCONFIG=mini.config make allnoconfig
109or
110 make KCONFIG_ALLCONFIG=mini.config allnoconfig
111
112These examples will disable most options (allnoconfig) but enable or
113disable the options that are explicitly listed in the specified
114mini-config files.
115
116KCONFIG_NOSILENTUPDATE
117--------------------------------------------------
118If this variable has a non-blank value, it prevents silent kernel
119config udpates (requires explicit updates).
120
121KCONFIG_CONFIG
122--------------------------------------------------
123This environment variable can be used to specify a default kernel config
124file name to override the default name of ".config".
125
126KCONFIG_OVERWRITECONFIG
127--------------------------------------------------
128If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
129break symlinks when .config is a symlink to somewhere else.
130
131KCONFIG_NOTIMESTAMP
132--------------------------------------------------
133If this environment variable exists and is non-null, the timestamp line
134in generated .config files is omitted.
135
136KCONFIG_AUTOCONFIG
137--------------------------------------------------
138This environment variable can be set to specify the path & name of the
139"auto.conf" file. Its default value is "include/config/auto.conf".
140
141KCONFIG_AUTOHEADER
142--------------------------------------------------
143This environment variable can be set to specify the path & name of the
144"autoconf.h" (header) file. Its default value is "include/linux/autoconf.h".
145
146______________________________________________________________________
147menuconfig User Interface Options
148----------------------------------------------------------------------
149MENUCONFIG_MODE
150--------------------------------------------------
151This mode shows all sub-menus in one large tree.
152
153Example:
154 MENUCONFIG_MODE=single_menu make menuconfig
155
156======================================================================
157xconfig
158--------------------------------------------------
159
160Searching in xconfig:
161
162 The Search function searches for kernel configuration symbol
163 names, so you have to know something close to what you are
164 looking for.
165
166 Example:
167 Ctrl-F hotplug
168 or
169 Menu: File, Search, hotplug
170
171 lists all config symbol entries that contain "hotplug" in
172 the symbol name. In this Search dialog, you may change the
173 config setting for any of the entries that are not grayed out.
174 You can also enter a different search string without having
175 to return to the main menu.
176
177
178======================================================================
179gconfig
180--------------------------------------------------
181
182Searching in gconfig:
183
184 None (gconfig isn't maintained as well as xconfig or menuconfig);
185 however, gconfig does have a few more viewing choices than
186 xconfig does.
187
188###
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index 335aef4dcaeb..b8d470596b0c 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -152,3 +152,4 @@
152151 -> ADS Tech Instant HDTV [1421:0380] 152151 -> ADS Tech Instant HDTV [1421:0380]
153152 -> Asus Tiger Rev:1.00 [1043:4857] 153152 -> Asus Tiger Rev:1.00 [1043:4857]
154153 -> Kworld Plus TV Analog Lite PCI [17de:7128] 154153 -> Kworld Plus TV Analog Lite PCI [17de:7128]
155154 -> Avermedia AVerTV GO 007 FM Plus [1461:f31d]
diff --git a/Documentation/video4linux/si470x.txt b/Documentation/video4linux/si470x.txt
index 11c5fd22a332..49679e6aaa76 100644
--- a/Documentation/video4linux/si470x.txt
+++ b/Documentation/video4linux/si470x.txt
@@ -41,6 +41,7 @@ chips are known to work:
41- 10c4:818a: Silicon Labs USB FM Radio Reference Design 41- 10c4:818a: Silicon Labs USB FM Radio Reference Design
42- 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music) (RDX-155-EF) 42- 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music) (RDX-155-EF)
43- 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700) 43- 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
44- 10c5:819a: DealExtreme USB Radio
44 45
45 46
46Software 47Software
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index eeae76c22a93..ff124374e9ba 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -184,7 +184,7 @@ may be NULL if the subdev driver does not support anything from that category.
184It looks like this: 184It looks like this:
185 185
186struct v4l2_subdev_core_ops { 186struct v4l2_subdev_core_ops {
187 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip); 187 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
188 int (*log_status)(struct v4l2_subdev *sd); 188 int (*log_status)(struct v4l2_subdev *sd);
189 int (*init)(struct v4l2_subdev *sd, u32 val); 189 int (*init)(struct v4l2_subdev *sd, u32 val);
190 ... 190 ...
@@ -390,16 +390,18 @@ allocated memory.
390 390
391You should also set these fields: 391You should also set these fields:
392 392
393- parent: set to the parent device (same device as was used to register 393- v4l2_dev: set to the v4l2_device parent device.
394 v4l2_device).
395- name: set to something descriptive and unique. 394- name: set to something descriptive and unique.
396- fops: set to the file_operations struct. 395- fops: set to the v4l2_file_operations struct.
397- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance 396- ioctl_ops: if you use the v4l2_ioctl_ops to simplify ioctl maintenance
398 (highly recommended to use this and it might become compulsory in the 397 (highly recommended to use this and it might become compulsory in the
399 future!), then set this to your v4l2_ioctl_ops struct. 398 future!), then set this to your v4l2_ioctl_ops struct.
400 399
401If you use v4l2_ioctl_ops, then you should set .unlocked_ioctl to 400If you use v4l2_ioctl_ops, then you should set either .unlocked_ioctl or
402__video_ioctl2 or .ioctl to video_ioctl2 in your file_operations struct. 401.ioctl to video_ioctl2 in your v4l2_file_operations struct.
402
403The v4l2_file_operations struct is a subset of file_operations. The main
404difference is that the inode argument is omitted since it is never used.
403 405
404 406
405video_device registration 407video_device registration
@@ -410,7 +412,7 @@ for you.
410 412
411 err = video_register_device(vdev, VFL_TYPE_GRABBER, -1); 413 err = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
412 if (err) { 414 if (err) {
413 video_device_release(vdev); // or kfree(my_vdev); 415 video_device_release(vdev); /* or kfree(my_vdev); */
414 return err; 416 return err;
415 } 417 }
416 418
@@ -516,5 +518,4 @@ void *video_drvdata(struct file *file);
516 518
517You can go from a video_device struct to the v4l2_device struct using: 519You can go from a video_device struct to the v4l2_device struct using:
518 520
519struct v4l2_device *v4l2_dev = dev_get_drvdata(vdev->parent); 521struct v4l2_device *v4l2_dev = vdev->v4l2_dev;
520
diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index fcdc62b3c3d8..7b4596ac4120 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -44,7 +44,7 @@ Protocol 2.07: (Kernel 2.6.24) Added paravirtualised boot protocol.
44 and KEEP_SEGMENTS flag in load_flags. 44 and KEEP_SEGMENTS flag in load_flags.
45 45
46Protocol 2.08: (Kernel 2.6.26) Added crc32 checksum and ELF format 46Protocol 2.08: (Kernel 2.6.26) Added crc32 checksum and ELF format
47 payload. Introduced payload_offset and payload length 47 payload. Introduced payload_offset and payload_length
48 fields to aid in locating the payload. 48 fields to aid in locating the payload.
49 49
50Protocol 2.09: (Kernel 2.6.26) Added a field of 64-bit physical 50Protocol 2.09: (Kernel 2.6.26) Added a field of 64-bit physical
diff --git a/MAINTAINERS b/MAINTAINERS
index befacf07729f..141aff67bd6d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4015,10 +4015,12 @@ L: alsa-devel@alsa-project.org (subscribers-only)
4015W: http://alsa-project.org/main/index.php/ASoC 4015W: http://alsa-project.org/main/index.php/ASoC
4016S: Supported 4016S: Supported
4017 4017
4018SPARC (sparc32) 4018SPARC + UltraSPARC (sparc/sparc64)
4019P: William L. Irwin 4019P: David S. Miller
4020M: wli@holomorphy.com 4020M: davem@davemloft.net
4021L: sparclinux@vger.kernel.org 4021L: sparclinux@vger.kernel.org
4022T: git kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.git
4023T: git kernel.org:/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git
4022S: Maintained 4024S: Maintained
4023 4025
4024SPECIALIX IO8+ MULTIPORT SERIAL CARD DRIVER 4026SPECIALIX IO8+ MULTIPORT SERIAL CARD DRIVER
@@ -4302,13 +4304,6 @@ M: dushistov@mail.ru
4302L: linux-kernel@vger.kernel.org 4304L: linux-kernel@vger.kernel.org
4303S: Maintained 4305S: Maintained
4304 4306
4305UltraSPARC (sparc64)
4306P: David S. Miller
4307M: davem@davemloft.net
4308L: sparclinux@vger.kernel.org
4309T: git kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.git
4310S: Maintained
4311
4312ULTRA-WIDEBAND (UWB) SUBSYSTEM: 4307ULTRA-WIDEBAND (UWB) SUBSYSTEM:
4313P: David Vrabel 4308P: David Vrabel
4314M: david.vrabel@csr.com 4309M: david.vrabel@csr.com
diff --git a/Makefile b/Makefile
index d13a9694e159..f9006663f01e 100644
--- a/Makefile
+++ b/Makefile
@@ -321,7 +321,8 @@ KALLSYMS = scripts/kallsyms
321PERL = perl 321PERL = perl
322CHECK = sparse 322CHECK = sparse
323 323
324CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) 324CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
325 -Wbitwise -Wno-return-void $(CF)
325MODFLAGS = -DMODULE 326MODFLAGS = -DMODULE
326CFLAGS_MODULE = $(MODFLAGS) 327CFLAGS_MODULE = $(MODFLAGS)
327AFLAGS_MODULE = $(MODFLAGS) 328AFLAGS_MODULE = $(MODFLAGS)
diff --git a/README b/README
index 159912cf5155..90a07658ede1 100644
--- a/README
+++ b/README
@@ -52,11 +52,11 @@ DOCUMENTATION:
52 52
53 - The Documentation/DocBook/ subdirectory contains several guides for 53 - The Documentation/DocBook/ subdirectory contains several guides for
54 kernel developers and users. These guides can be rendered in a 54 kernel developers and users. These guides can be rendered in a
55 number of formats: PostScript (.ps), PDF, and HTML, among others. 55 number of formats: PostScript (.ps), PDF, HTML, & man-pages, among others.
56 After installation, "make psdocs", "make pdfdocs", or "make htmldocs" 56 After installation, "make psdocs", "make pdfdocs", "make htmldocs",
57 will render the documentation in the requested format. 57 or "make mandocs" will render the documentation in the requested format.
58 58
59INSTALLING the kernel: 59INSTALLING the kernel source:
60 60
61 - If you install the full sources, put the kernel tarball in a 61 - If you install the full sources, put the kernel tarball in a
62 directory where you have permissions (eg. your home directory) and 62 directory where you have permissions (eg. your home directory) and
@@ -187,14 +187,9 @@ CONFIGURING the kernel:
187 "make randconfig" Create a ./.config file by setting symbol 187 "make randconfig" Create a ./.config file by setting symbol
188 values to random values. 188 values to random values.
189 189
190 The allyesconfig/allmodconfig/allnoconfig/randconfig variants can 190 You can find more information on using the Linux kernel config tools
191 also use the environment variable KCONFIG_ALLCONFIG to specify a 191 in Documentation/kbuild/make-configs.txt.
192 filename that contains config options that the user requires to be 192
193 set to a specific value. If KCONFIG_ALLCONFIG=filename is not used,
194 "make *config" checks for a file named "all{yes/mod/no/random}.config"
195 for symbol values that are to be forced. If this file is not found,
196 it checks for a file named "all.config" to contain forced values.
197
198 NOTES on "make config": 193 NOTES on "make config":
199 - having unnecessary drivers will make the kernel bigger, and can 194 - having unnecessary drivers will make the kernel bigger, and can
200 under some circumstances lead to problems: probing for a 195 under some circumstances lead to problems: probing for a
@@ -231,6 +226,19 @@ COMPILING the kernel:
231 - If you configured any of the parts of the kernel as `modules', you 226 - If you configured any of the parts of the kernel as `modules', you
232 will also have to do "make modules_install". 227 will also have to do "make modules_install".
233 228
229 - Verbose kernel compile/build output:
230
231 Normally the kernel build system runs in a fairly quiet mode (but not
232 totally silent). However, sometimes you or other kernel developers need
233 to see compile, link, or other commands exactly as they are executed.
234 For this, use "verbose" build mode. This is done by inserting
235 "V=1" in the "make" command. E.g.:
236
237 make V=1 all
238
239 To have the build system also tell the reason for the rebuild of each
240 target, use "V=2". The default is "V=0".
241
234 - Keep a backup kernel handy in case something goes wrong. This is 242 - Keep a backup kernel handy in case something goes wrong. This is
235 especially true for the development releases, since each new release 243 especially true for the development releases, since each new release
236 contains new code which has not been debugged. Make sure you keep a 244 contains new code which has not been debugged. Make sure you keep a
diff --git a/arch/alpha/include/asm/topology.h b/arch/alpha/include/asm/topology.h
index 149532e162c4..b4f284c72ff3 100644
--- a/arch/alpha/include/asm/topology.h
+++ b/arch/alpha/include/asm/topology.h
@@ -39,7 +39,24 @@ static inline cpumask_t node_to_cpumask(int node)
39 return node_cpu_mask; 39 return node_cpu_mask;
40} 40}
41 41
42extern struct cpumask node_to_cpumask_map[];
43/* FIXME: This is dumb, recalculating every time. But simple. */
44static const struct cpumask *cpumask_of_node(int node)
45{
46 int cpu;
47
48 cpumask_clear(&node_to_cpumask_map[node]);
49
50 for_each_online_cpu(cpu) {
51 if (cpu_to_node(cpu) == node)
52 cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
53 }
54
55 return &node_to_cpumask_map[node];
56}
57
42#define pcibus_to_cpumask(bus) (cpu_online_map) 58#define pcibus_to_cpumask(bus) (cpu_online_map)
59#define cpumask_of_pcibus(bus) (cpu_online_mask)
43 60
44#endif /* !CONFIG_NUMA */ 61#endif /* !CONFIG_NUMA */
45# include <asm-generic/topology.h> 62# include <asm-generic/topology.h>
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
index ac706c1d7ada..b4697759a123 100644
--- a/arch/alpha/kernel/Makefile
+++ b/arch/alpha/kernel/Makefile
@@ -8,7 +8,7 @@ EXTRA_CFLAGS := -Werror -Wno-sign-compare
8 8
9obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \ 9obj-y := entry.o traps.o process.o init_task.o osf_sys.o irq.o \
10 irq_alpha.o signal.o setup.o ptrace.o time.o \ 10 irq_alpha.o signal.o setup.o ptrace.o time.o \
11 alpha_ksyms.o systbls.o err_common.o io.o 11 alpha_ksyms.o systbls.o err_common.o io.o binfmt_loader.o
12 12
13obj-$(CONFIG_VGA_HOSE) += console.o 13obj-$(CONFIG_VGA_HOSE) += console.o
14obj-$(CONFIG_SMP) += smp.o 14obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/alpha/kernel/binfmt_loader.c b/arch/alpha/kernel/binfmt_loader.c
new file mode 100644
index 000000000000..4a0af906b00a
--- /dev/null
+++ b/arch/alpha/kernel/binfmt_loader.c
@@ -0,0 +1,51 @@
1#include <linux/init.h>
2#include <linux/fs.h>
3#include <linux/file.h>
4#include <linux/mm_types.h>
5#include <linux/binfmts.h>
6#include <linux/a.out.h>
7
8static int load_binary(struct linux_binprm *bprm, struct pt_regs *regs)
9{
10 struct exec *eh = (struct exec *)bprm->buf;
11 unsigned long loader;
12 struct file *file;
13 int retval;
14
15 if (eh->fh.f_magic != 0x183 || (eh->fh.f_flags & 0x3000) != 0x3000)
16 return -ENOEXEC;
17
18 if (bprm->loader)
19 return -ENOEXEC;
20
21 allow_write_access(bprm->file);
22 fput(bprm->file);
23 bprm->file = NULL;
24
25 loader = bprm->vma->vm_end - sizeof(void *);
26
27 file = open_exec("/sbin/loader");
28 retval = PTR_ERR(file);
29 if (IS_ERR(file))
30 return retval;
31
32 /* Remember if the application is TASO. */
33 bprm->taso = eh->ah.entry < 0x100000000UL;
34
35 bprm->file = file;
36 bprm->loader = loader;
37 retval = prepare_binprm(bprm);
38 if (retval < 0)
39 return retval;
40 return search_binary_handler(bprm,regs);
41}
42
43static struct linux_binfmt loader_format = {
44 .load_binary = load_binary,
45};
46
47static int __init init_loader_binfmt(void)
48{
49 return register_binfmt(&loader_format);
50}
51arch_initcall(init_loader_binfmt);
diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
index d0f1620007f7..703731accda6 100644
--- a/arch/alpha/kernel/irq.c
+++ b/arch/alpha/kernel/irq.c
@@ -50,7 +50,8 @@ int irq_select_affinity(unsigned int irq)
50 if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq]) 50 if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
51 return 1; 51 return 1;
52 52
53 while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity)) 53 while (!cpu_possible(cpu) ||
54 !cpumask_test_cpu(cpu, irq_default_affinity))
54 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); 55 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
55 last_cpu = cpu; 56 last_cpu = cpu;
56 57
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index a449e999027c..02bee6983ce2 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -79,6 +79,11 @@ int alpha_l3_cacheshape;
79unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON; 79unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
80#endif 80#endif
81 81
82#ifdef CONFIG_NUMA
83struct cpumask node_to_cpumask_map[MAX_NUMNODES] __read_mostly;
84EXPORT_SYMBOL(node_to_cpumask_map);
85#endif
86
82/* Which processor we booted from. */ 87/* Which processor we booted from. */
83int boot_cpuid; 88int boot_cpuid;
84 89
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h
index ff6cd14d254d..ad6d98d177c5 100644
--- a/arch/arm/mach-omap2/clock24xx.h
+++ b/arch/arm/mach-omap2/clock24xx.h
@@ -2321,7 +2321,7 @@ static struct clk i2c2_fck = {
2321}; 2321};
2322 2322
2323static struct clk i2chs2_fck = { 2323static struct clk i2chs2_fck = {
2324 .name = "i2chs_fck", 2324 .name = "i2c_fck",
2325 .id = 2, 2325 .id = 2,
2326 .parent = &func_96m_ck, 2326 .parent = &func_96m_ck,
2327 .flags = CLOCK_IN_OMAP243X, 2327 .flags = CLOCK_IN_OMAP243X,
@@ -2354,7 +2354,7 @@ static struct clk i2c1_fck = {
2354}; 2354};
2355 2355
2356static struct clk i2chs1_fck = { 2356static struct clk i2chs1_fck = {
2357 .name = "i2chs_fck", 2357 .name = "i2c_fck",
2358 .id = 1, 2358 .id = 1,
2359 .parent = &func_96m_ck, 2359 .parent = &func_96m_ck,
2360 .flags = CLOCK_IN_OMAP243X, 2360 .flags = CLOCK_IN_OMAP243X,
diff --git a/arch/avr32/include/asm/bitops.h b/arch/avr32/include/asm/bitops.h
index 1a50b69b1a19..f7dd5f71edf7 100644
--- a/arch/avr32/include/asm/bitops.h
+++ b/arch/avr32/include/asm/bitops.h
@@ -263,6 +263,11 @@ static inline int fls(unsigned long word)
263 return 32 - result; 263 return 32 - result;
264} 264}
265 265
266static inline int __fls(unsigned long word)
267{
268 return fls(word) - 1;
269}
270
266unsigned long find_first_zero_bit(const unsigned long *addr, 271unsigned long find_first_zero_bit(const unsigned long *addr,
267 unsigned long size); 272 unsigned long size);
268unsigned long find_next_zero_bit(const unsigned long *addr, 273unsigned long find_next_zero_bit(const unsigned long *addr,
diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h
index b39a175c79c1..c428e4106f89 100644
--- a/arch/blackfin/include/asm/bitops.h
+++ b/arch/blackfin/include/asm/bitops.h
@@ -213,6 +213,7 @@ static __inline__ int __test_bit(int nr, const void *addr)
213#endif /* __KERNEL__ */ 213#endif /* __KERNEL__ */
214 214
215#include <asm-generic/bitops/fls.h> 215#include <asm-generic/bitops/fls.h>
216#include <asm-generic/bitops/__fls.h>
216#include <asm-generic/bitops/fls64.h> 217#include <asm-generic/bitops/fls64.h>
217 218
218#endif /* _BLACKFIN_BITOPS_H */ 219#endif /* _BLACKFIN_BITOPS_H */
diff --git a/arch/cris/include/asm/bitops.h b/arch/cris/include/asm/bitops.h
index c0e62f811e09..9e69cfb7f134 100644
--- a/arch/cris/include/asm/bitops.h
+++ b/arch/cris/include/asm/bitops.h
@@ -148,6 +148,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
148#define ffs kernel_ffs 148#define ffs kernel_ffs
149 149
150#include <asm-generic/bitops/fls.h> 150#include <asm-generic/bitops/fls.h>
151#include <asm-generic/bitops/__fls.h>
151#include <asm-generic/bitops/fls64.h> 152#include <asm-generic/bitops/fls64.h>
152#include <asm-generic/bitops/hweight.h> 153#include <asm-generic/bitops/hweight.h>
153#include <asm-generic/bitops/find.h> 154#include <asm-generic/bitops/find.h>
diff --git a/arch/h8300/include/asm/bitops.h b/arch/h8300/include/asm/bitops.h
index cb18e3b0aa94..cb9ddf5fc54f 100644
--- a/arch/h8300/include/asm/bitops.h
+++ b/arch/h8300/include/asm/bitops.h
@@ -207,6 +207,7 @@ static __inline__ unsigned long __ffs(unsigned long word)
207#endif /* __KERNEL__ */ 207#endif /* __KERNEL__ */
208 208
209#include <asm-generic/bitops/fls.h> 209#include <asm-generic/bitops/fls.h>
210#include <asm-generic/bitops/__fls.h>
210#include <asm-generic/bitops/fls64.h> 211#include <asm-generic/bitops/fls64.h>
211 212
212#endif /* _H8300_BITOPS_H */ 213#endif /* _H8300_BITOPS_H */
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 7fa8f615ba6e..3d31636cbafb 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -687,3 +687,6 @@ config IRQ_PER_CPU
687 687
688config IOMMU_HELPER 688config IOMMU_HELPER
689 def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC || SWIOTLB) 689 def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC || SWIOTLB)
690
691config IOMMU_API
692 def_bool (DMAR)
diff --git a/arch/ia64/include/asm/irq.h b/arch/ia64/include/asm/irq.h
index 3627116fb0e2..36429a532630 100644
--- a/arch/ia64/include/asm/irq.h
+++ b/arch/ia64/include/asm/irq.h
@@ -27,7 +27,7 @@ irq_canonicalize (int irq)
27} 27}
28 28
29extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); 29extern void set_irq_affinity_info (unsigned int irq, int dest, int redir);
30bool is_affinity_mask_valid(cpumask_t cpumask); 30bool is_affinity_mask_valid(cpumask_var_t cpumask);
31 31
32#define is_affinity_mask_valid is_affinity_mask_valid 32#define is_affinity_mask_valid is_affinity_mask_valid
33 33
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 0560f3fae538..348663661659 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -467,7 +467,7 @@ struct kvm_arch {
467 struct kvm_sal_data rdv_sal_data; 467 struct kvm_sal_data rdv_sal_data;
468 468
469 struct list_head assigned_dev_head; 469 struct list_head assigned_dev_head;
470 struct dmar_domain *intel_iommu_domain; 470 struct iommu_domain *iommu_domain;
471 struct hlist_head irq_ack_notifier_list; 471 struct hlist_head irq_ack_notifier_list;
472 472
473 unsigned long irq_sources_bitmap; 473 unsigned long irq_sources_bitmap;
diff --git a/arch/ia64/include/asm/topology.h b/arch/ia64/include/asm/topology.h
index a3cc9f65f954..76a33a91ca69 100644
--- a/arch/ia64/include/asm/topology.h
+++ b/arch/ia64/include/asm/topology.h
@@ -34,6 +34,7 @@
34 * Returns a bitmask of CPUs on Node 'node'. 34 * Returns a bitmask of CPUs on Node 'node'.
35 */ 35 */
36#define node_to_cpumask(node) (node_to_cpu_mask[node]) 36#define node_to_cpumask(node) (node_to_cpu_mask[node])
37#define cpumask_of_node(node) (&node_to_cpu_mask[node])
37 38
38/* 39/*
39 * Returns the number of the node containing Node 'nid'. 40 * Returns the number of the node containing Node 'nid'.
@@ -45,7 +46,7 @@
45/* 46/*
46 * Returns the number of the first CPU on Node 'node'. 47 * Returns the number of the first CPU on Node 'node'.
47 */ 48 */
48#define node_to_first_cpu(node) (first_cpu(node_to_cpumask(node))) 49#define node_to_first_cpu(node) (cpumask_first(cpumask_of_node(node)))
49 50
50/* 51/*
51 * Determines the node for a given pci bus 52 * Determines the node for a given pci bus
@@ -109,6 +110,8 @@ void build_cpu_to_node_map(void);
109#define topology_core_id(cpu) (cpu_data(cpu)->core_id) 110#define topology_core_id(cpu) (cpu_data(cpu)->core_id)
110#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 111#define topology_core_siblings(cpu) (cpu_core_map[cpu])
111#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 112#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
113#define topology_core_cpumask(cpu) (&cpu_core_map[cpu])
114#define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
112#define smt_capable() (smp_num_siblings > 1) 115#define smt_capable() (smp_num_siblings > 1)
113#endif 116#endif
114 117
@@ -119,6 +122,10 @@ extern void arch_fix_phys_package_id(int num, u32 slot);
119 node_to_cpumask(pcibus_to_node(bus)) \ 122 node_to_cpumask(pcibus_to_node(bus)) \
120 ) 123 )
121 124
125#define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
126 cpu_all_mask : \
127 cpumask_from_node(pcibus_to_node(bus)))
128
122#include <asm-generic/topology.h> 129#include <asm-generic/topology.h>
123 130
124#endif /* _ASM_IA64_TOPOLOGY_H */ 131#endif /* _ASM_IA64_TOPOLOGY_H */
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index bd7acc71e8a9..0553648b7595 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -202,7 +202,6 @@ char *__init __acpi_map_table(unsigned long phys_addr, unsigned long size)
202 Boot-time Table Parsing 202 Boot-time Table Parsing
203 -------------------------------------------------------------------------- */ 203 -------------------------------------------------------------------------- */
204 204
205static int total_cpus __initdata;
206static int available_cpus __initdata; 205static int available_cpus __initdata;
207struct acpi_table_madt *acpi_madt __initdata; 206struct acpi_table_madt *acpi_madt __initdata;
208static u8 has_8259; 207static u8 has_8259;
@@ -1001,7 +1000,7 @@ acpi_map_iosapic(acpi_handle handle, u32 depth, void *context, void **ret)
1001 node = pxm_to_node(pxm); 1000 node = pxm_to_node(pxm);
1002 1001
1003 if (node >= MAX_NUMNODES || !node_online(node) || 1002 if (node >= MAX_NUMNODES || !node_online(node) ||
1004 cpus_empty(node_to_cpumask(node))) 1003 cpumask_empty(cpumask_of_node(node)))
1005 return AE_OK; 1004 return AE_OK;
1006 1005
1007 /* We know a gsi to node mapping! */ 1006 /* We know a gsi to node mapping! */
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index c8adecd5b416..5cfd3d91001a 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -695,32 +695,31 @@ get_target_cpu (unsigned int gsi, int irq)
695#ifdef CONFIG_NUMA 695#ifdef CONFIG_NUMA
696 { 696 {
697 int num_cpus, cpu_index, iosapic_index, numa_cpu, i = 0; 697 int num_cpus, cpu_index, iosapic_index, numa_cpu, i = 0;
698 cpumask_t cpu_mask; 698 const struct cpumask *cpu_mask;
699 699
700 iosapic_index = find_iosapic(gsi); 700 iosapic_index = find_iosapic(gsi);
701 if (iosapic_index < 0 || 701 if (iosapic_index < 0 ||
702 iosapic_lists[iosapic_index].node == MAX_NUMNODES) 702 iosapic_lists[iosapic_index].node == MAX_NUMNODES)
703 goto skip_numa_setup; 703 goto skip_numa_setup;
704 704
705 cpu_mask = node_to_cpumask(iosapic_lists[iosapic_index].node); 705 cpu_mask = cpumask_of_node(iosapic_lists[iosapic_index].node);
706 cpus_and(cpu_mask, cpu_mask, domain); 706 num_cpus = 0;
707 for_each_cpu_mask(numa_cpu, cpu_mask) { 707 for_each_cpu_and(numa_cpu, cpu_mask, &domain) {
708 if (!cpu_online(numa_cpu)) 708 if (cpu_online(numa_cpu))
709 cpu_clear(numa_cpu, cpu_mask); 709 num_cpus++;
710 } 710 }
711 711
712 num_cpus = cpus_weight(cpu_mask);
713
714 if (!num_cpus) 712 if (!num_cpus)
715 goto skip_numa_setup; 713 goto skip_numa_setup;
716 714
717 /* Use irq assignment to distribute across cpus in node */ 715 /* Use irq assignment to distribute across cpus in node */
718 cpu_index = irq % num_cpus; 716 cpu_index = irq % num_cpus;
719 717
720 for (numa_cpu = first_cpu(cpu_mask) ; i < cpu_index ; i++) 718 for_each_cpu_and(numa_cpu, cpu_mask, &domain)
721 numa_cpu = next_cpu(numa_cpu, cpu_mask); 719 if (cpu_online(numa_cpu) && i++ >= cpu_index)
720 break;
722 721
723 if (numa_cpu != NR_CPUS) 722 if (numa_cpu < nr_cpu_ids)
724 return cpu_physical_id(numa_cpu); 723 return cpu_physical_id(numa_cpu);
725 } 724 }
726skip_numa_setup: 725skip_numa_setup:
@@ -731,7 +730,7 @@ skip_numa_setup:
731 * case of NUMA.) 730 * case of NUMA.)
732 */ 731 */
733 do { 732 do {
734 if (++cpu >= NR_CPUS) 733 if (++cpu >= nr_cpu_ids)
735 cpu = 0; 734 cpu = 0;
736 } while (!cpu_online(cpu) || !cpu_isset(cpu, domain)); 735 } while (!cpu_online(cpu) || !cpu_isset(cpu, domain));
737 736
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index 0b6db53fedcf..95ff16cb05d8 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -112,11 +112,11 @@ void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
112 } 112 }
113} 113}
114 114
115bool is_affinity_mask_valid(cpumask_t cpumask) 115bool is_affinity_mask_valid(cpumask_var_t cpumask)
116{ 116{
117 if (ia64_platform_is("sn2")) { 117 if (ia64_platform_is("sn2")) {
118 /* Only allow one CPU to be specified in the smp_affinity mask */ 118 /* Only allow one CPU to be specified in the smp_affinity mask */
119 if (cpus_weight(cpumask) != 1) 119 if (cpumask_weight(cpumask) != 1)
120 return false; 120 return false;
121 } 121 }
122 return true; 122 return true;
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 65c10a42c88f..f0ebb342409d 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -93,13 +93,14 @@ void ia64_account_on_switch(struct task_struct *prev, struct task_struct *next)
93 now = ia64_get_itc(); 93 now = ia64_get_itc();
94 94
95 delta_stime = cycle_to_cputime(pi->ac_stime + (now - pi->ac_stamp)); 95 delta_stime = cycle_to_cputime(pi->ac_stime + (now - pi->ac_stamp));
96 account_system_time(prev, 0, delta_stime); 96 if (idle_task(smp_processor_id()) != prev)
97 account_system_time_scaled(prev, delta_stime); 97 account_system_time(prev, 0, delta_stime, delta_stime);
98 else
99 account_idle_time(delta_stime);
98 100
99 if (pi->ac_utime) { 101 if (pi->ac_utime) {
100 delta_utime = cycle_to_cputime(pi->ac_utime); 102 delta_utime = cycle_to_cputime(pi->ac_utime);
101 account_user_time(prev, delta_utime); 103 account_user_time(prev, delta_utime, delta_utime);
102 account_user_time_scaled(prev, delta_utime);
103 } 104 }
104 105
105 pi->ac_stamp = ni->ac_stamp = now; 106 pi->ac_stamp = ni->ac_stamp = now;
@@ -122,8 +123,10 @@ void account_system_vtime(struct task_struct *tsk)
122 now = ia64_get_itc(); 123 now = ia64_get_itc();
123 124
124 delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); 125 delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp));
125 account_system_time(tsk, 0, delta_stime); 126 if (irq_count() || idle_task(smp_processor_id()) != tsk)
126 account_system_time_scaled(tsk, delta_stime); 127 account_system_time(tsk, 0, delta_stime, delta_stime);
128 else
129 account_idle_time(delta_stime);
127 ti->ac_stime = 0; 130 ti->ac_stime = 0;
128 131
129 ti->ac_stamp = now; 132 ti->ac_stamp = now;
@@ -143,8 +146,7 @@ void account_process_tick(struct task_struct *p, int user_tick)
143 146
144 if (ti->ac_utime) { 147 if (ti->ac_utime) {
145 delta_utime = cycle_to_cputime(ti->ac_utime); 148 delta_utime = cycle_to_cputime(ti->ac_utime);
146 account_user_time(p, delta_utime); 149 account_user_time(p, delta_utime, delta_utime);
147 account_user_time_scaled(p, delta_utime);
148 ti->ac_utime = 0; 150 ti->ac_utime = 0;
149 } 151 }
150} 152}
diff --git a/arch/ia64/kvm/Makefile b/arch/ia64/kvm/Makefile
index 76464dc312e6..0bb99b732908 100644
--- a/arch/ia64/kvm/Makefile
+++ b/arch/ia64/kvm/Makefile
@@ -51,8 +51,8 @@ EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
51common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 51common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
52 coalesced_mmio.o irq_comm.o) 52 coalesced_mmio.o irq_comm.o)
53 53
54ifeq ($(CONFIG_DMAR),y) 54ifeq ($(CONFIG_IOMMU_API),y)
55common-objs += $(addprefix ../../../virt/kvm/, vtd.o) 55common-objs += $(addprefix ../../../virt/kvm/, iommu.o)
56endif 56endif
57 57
58kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o 58kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 0f5ebd948437..4e586f6110aa 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -31,6 +31,7 @@
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/hrtimer.h> 32#include <linux/hrtimer.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/iommu.h>
34#include <linux/intel-iommu.h> 35#include <linux/intel-iommu.h>
35 36
36#include <asm/pgtable.h> 37#include <asm/pgtable.h>
@@ -188,7 +189,7 @@ int kvm_dev_ioctl_check_extension(long ext)
188 r = KVM_COALESCED_MMIO_PAGE_OFFSET; 189 r = KVM_COALESCED_MMIO_PAGE_OFFSET;
189 break; 190 break;
190 case KVM_CAP_IOMMU: 191 case KVM_CAP_IOMMU:
191 r = intel_iommu_found(); 192 r = iommu_found();
192 break; 193 break;
193 default: 194 default:
194 r = 0; 195 r = 0;
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 636588e7e068..be339477f906 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -385,7 +385,6 @@ static int sn_topology_show(struct seq_file *s, void *d)
385 int j; 385 int j;
386 const char *slabname; 386 const char *slabname;
387 int ordinal; 387 int ordinal;
388 cpumask_t cpumask;
389 char slice; 388 char slice;
390 struct cpuinfo_ia64 *c; 389 struct cpuinfo_ia64 *c;
391 struct sn_hwperf_port_info *ptdata; 390 struct sn_hwperf_port_info *ptdata;
@@ -473,23 +472,21 @@ static int sn_topology_show(struct seq_file *s, void *d)
473 * CPUs on this node, if any 472 * CPUs on this node, if any
474 */ 473 */
475 if (!SN_HWPERF_IS_IONODE(obj)) { 474 if (!SN_HWPERF_IS_IONODE(obj)) {
476 cpumask = node_to_cpumask(ordinal); 475 for_each_cpu_and(i, cpu_online_mask,
477 for_each_online_cpu(i) { 476 cpumask_of_node(ordinal)) {
478 if (cpu_isset(i, cpumask)) { 477 slice = 'a' + cpuid_to_slice(i);
479 slice = 'a' + cpuid_to_slice(i); 478 c = cpu_data(i);
480 c = cpu_data(i); 479 seq_printf(s, "cpu %d %s%c local"
481 seq_printf(s, "cpu %d %s%c local" 480 " freq %luMHz, arch ia64",
482 " freq %luMHz, arch ia64", 481 i, obj->location, slice,
483 i, obj->location, slice, 482 c->proc_freq / 1000000);
484 c->proc_freq / 1000000); 483 for_each_online_cpu(j) {
485 for_each_online_cpu(j) { 484 seq_printf(s, j ? ":%d" : ", dist %d",
486 seq_printf(s, j ? ":%d" : ", dist %d", 485 node_distance(
487 node_distance(
488 cpu_to_node(i), 486 cpu_to_node(i),
489 cpu_to_node(j))); 487 cpu_to_node(j)));
490 }
491 seq_putc(s, '\n');
492 } 488 }
489 seq_putc(s, '\n');
493 } 490 }
494 } 491 }
495 } 492 }
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index 0f06b3722e96..2547d6c4a827 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -592,7 +592,7 @@ int setup_profiling_timer(unsigned int multiplier)
592 * accounting. At that time they also adjust their APIC timers 592 * accounting. At that time they also adjust their APIC timers
593 * accordingly. 593 * accordingly.
594 */ 594 */
595 for (i = 0; i < NR_CPUS; ++i) 595 for_each_possible_cpu(i)
596 per_cpu(prof_multiplier, i) = multiplier; 596 per_cpu(prof_multiplier, i) = multiplier;
597 597
598 return 0; 598 return 0;
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 836fb66f080d..c825bde17cb3 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -280,7 +280,6 @@ config M68060
280 280
281config MMU_MOTOROLA 281config MMU_MOTOROLA
282 bool 282 bool
283 depends on MMU && !MMU_SUN3
284 283
285config MMU_SUN3 284config MMU_SUN3
286 bool 285 bool
diff --git a/arch/m68knommu/include/asm/bitops.h b/arch/m68knommu/include/asm/bitops.h
index 6f3685eab44c..9d3cbe5fad1e 100644
--- a/arch/m68knommu/include/asm/bitops.h
+++ b/arch/m68knommu/include/asm/bitops.h
@@ -331,6 +331,7 @@ found_middle:
331#endif /* __KERNEL__ */ 331#endif /* __KERNEL__ */
332 332
333#include <asm-generic/bitops/fls.h> 333#include <asm-generic/bitops/fls.h>
334#include <asm-generic/bitops/__fls.h>
334#include <asm-generic/bitops/fls64.h> 335#include <asm-generic/bitops/fls64.h>
335 336
336#endif /* _M68KNOMMU_BITOPS_H */ 337#endif /* _M68KNOMMU_BITOPS_H */
diff --git a/arch/mips/include/asm/mach-ip27/topology.h b/arch/mips/include/asm/mach-ip27/topology.h
index 1fb959f98982..55d481569a1f 100644
--- a/arch/mips/include/asm/mach-ip27/topology.h
+++ b/arch/mips/include/asm/mach-ip27/topology.h
@@ -25,11 +25,13 @@ extern struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
25#define cpu_to_node(cpu) (sn_cpu_info[(cpu)].p_nodeid) 25#define cpu_to_node(cpu) (sn_cpu_info[(cpu)].p_nodeid)
26#define parent_node(node) (node) 26#define parent_node(node) (node)
27#define node_to_cpumask(node) (hub_data(node)->h_cpus) 27#define node_to_cpumask(node) (hub_data(node)->h_cpus)
28#define node_to_first_cpu(node) (first_cpu(node_to_cpumask(node))) 28#define cpumask_of_node(node) (&hub_data(node)->h_cpus)
29#define node_to_first_cpu(node) (cpumask_first(cpumask_of_node(node)))
29struct pci_bus; 30struct pci_bus;
30extern int pcibus_to_node(struct pci_bus *); 31extern int pcibus_to_node(struct pci_bus *);
31 32
32#define pcibus_to_cpumask(bus) (cpu_online_map) 33#define pcibus_to_cpumask(bus) (cpu_online_map)
34#define cpumask_of_pcibus(bus) (cpu_online_mask)
33 35
34extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES]; 36extern unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
35 37
diff --git a/arch/parisc/include/asm/module.h b/arch/parisc/include/asm/module.h
index c2cb49e934c1..1f4123427ea0 100644
--- a/arch/parisc/include/asm/module.h
+++ b/arch/parisc/include/asm/module.h
@@ -23,8 +23,10 @@ struct mod_arch_specific
23{ 23{
24 unsigned long got_offset, got_count, got_max; 24 unsigned long got_offset, got_count, got_max;
25 unsigned long fdesc_offset, fdesc_count, fdesc_max; 25 unsigned long fdesc_offset, fdesc_count, fdesc_max;
26 unsigned long stub_offset, stub_count, stub_max; 26 struct {
27 unsigned long init_stub_offset, init_stub_count, init_stub_max; 27 unsigned long stub_offset;
28 unsigned int stub_entries;
29 } *section;
28 int unwind_section; 30 int unwind_section;
29 struct unwind_table *unwind; 31 struct unwind_table *unwind;
30}; 32};
diff --git a/arch/parisc/include/asm/smp.h b/arch/parisc/include/asm/smp.h
index 409e698f4361..6ef4b7867b1b 100644
--- a/arch/parisc/include/asm/smp.h
+++ b/arch/parisc/include/asm/smp.h
@@ -16,8 +16,6 @@
16#include <linux/cpumask.h> 16#include <linux/cpumask.h>
17typedef unsigned long address_t; 17typedef unsigned long address_t;
18 18
19extern cpumask_t cpu_online_map;
20
21 19
22/* 20/*
23 * Private routines/data 21 * Private routines/data
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index 44138c3e6ea7..9013243cecca 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -6,6 +6,7 @@
6 * 6 *
7 * Linux/PA-RISC Project (http://www.parisc-linux.org/) 7 * Linux/PA-RISC Project (http://www.parisc-linux.org/)
8 * Copyright (C) 2003 Randolph Chung <tausq at debian . org> 8 * Copyright (C) 2003 Randolph Chung <tausq at debian . org>
9 * Copyright (C) 2008 Helge Deller <deller@gmx.de>
9 * 10 *
10 * 11 *
11 * 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
@@ -24,6 +25,19 @@
24 * 25 *
25 * 26 *
26 * Notes: 27 * Notes:
28 * - PLT stub handling
29 * On 32bit (and sometimes 64bit) and with big kernel modules like xfs or
30 * ipv6 the relocation types R_PARISC_PCREL17F and R_PARISC_PCREL22F may
31 * fail to reach their PLT stub if we only create one big stub array for
32 * all sections at the beginning of the core or init section.
33 * Instead we now insert individual PLT stub entries directly in front of
34 * of the code sections where the stubs are actually called.
35 * This reduces the distance between the PCREL location and the stub entry
36 * so that the relocations can be fulfilled.
37 * While calculating the final layout of the kernel module in memory, the
38 * kernel module loader calls arch_mod_section_prepend() to request the
39 * to be reserved amount of memory in front of each individual section.
40 *
27 * - SEGREL32 handling 41 * - SEGREL32 handling
28 * We are not doing SEGREL32 handling correctly. According to the ABI, we 42 * We are not doing SEGREL32 handling correctly. According to the ABI, we
29 * should do a value offset, like this: 43 * should do a value offset, like this:
@@ -58,9 +72,13 @@
58#define DEBUGP(fmt...) 72#define DEBUGP(fmt...)
59#endif 73#endif
60 74
75#define RELOC_REACHABLE(val, bits) \
76 (( ( !((val) & (1<<((bits)-1))) && ((val)>>(bits)) != 0 ) || \
77 ( ((val) & (1<<((bits)-1))) && ((val)>>(bits)) != (((__typeof__(val))(~0))>>((bits)+2)))) ? \
78 0 : 1)
79
61#define CHECK_RELOC(val, bits) \ 80#define CHECK_RELOC(val, bits) \
62 if ( ( !((val) & (1<<((bits)-1))) && ((val)>>(bits)) != 0 ) || \ 81 if (!RELOC_REACHABLE(val, bits)) { \
63 ( ((val) & (1<<((bits)-1))) && ((val)>>(bits)) != (((__typeof__(val))(~0))>>((bits)+2)))) { \
64 printk(KERN_ERR "module %s relocation of symbol %s is out of range (0x%lx in %d bits)\n", \ 82 printk(KERN_ERR "module %s relocation of symbol %s is out of range (0x%lx in %d bits)\n", \
65 me->name, strtab + sym->st_name, (unsigned long)val, bits); \ 83 me->name, strtab + sym->st_name, (unsigned long)val, bits); \
66 return -ENOEXEC; \ 84 return -ENOEXEC; \
@@ -92,13 +110,6 @@ static inline int in_local(struct module *me, void *loc)
92 return in_init(me, loc) || in_core(me, loc); 110 return in_init(me, loc) || in_core(me, loc);
93} 111}
94 112
95static inline int in_local_section(struct module *me, void *loc, void *dot)
96{
97 return (in_init(me, loc) && in_init(me, dot)) ||
98 (in_core(me, loc) && in_core(me, dot));
99}
100
101
102#ifndef CONFIG_64BIT 113#ifndef CONFIG_64BIT
103struct got_entry { 114struct got_entry {
104 Elf32_Addr addr; 115 Elf32_Addr addr;
@@ -258,23 +269,42 @@ static inline unsigned long count_stubs(const Elf_Rela *rela, unsigned long n)
258/* Free memory returned from module_alloc */ 269/* Free memory returned from module_alloc */
259void module_free(struct module *mod, void *module_region) 270void module_free(struct module *mod, void *module_region)
260{ 271{
272 kfree(mod->arch.section);
273 mod->arch.section = NULL;
274
261 vfree(module_region); 275 vfree(module_region);
262 /* FIXME: If module_region == mod->init_region, trim exception 276 /* FIXME: If module_region == mod->init_region, trim exception
263 table entries. */ 277 table entries. */
264} 278}
265 279
280/* Additional bytes needed in front of individual sections */
281unsigned int arch_mod_section_prepend(struct module *mod,
282 unsigned int section)
283{
284 /* size needed for all stubs of this section (including
285 * one additional for correct alignment of the stubs) */
286 return (mod->arch.section[section].stub_entries + 1)
287 * sizeof(struct stub_entry);
288}
289
266#define CONST 290#define CONST
267int module_frob_arch_sections(CONST Elf_Ehdr *hdr, 291int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
268 CONST Elf_Shdr *sechdrs, 292 CONST Elf_Shdr *sechdrs,
269 CONST char *secstrings, 293 CONST char *secstrings,
270 struct module *me) 294 struct module *me)
271{ 295{
272 unsigned long gots = 0, fdescs = 0, stubs = 0, init_stubs = 0; 296 unsigned long gots = 0, fdescs = 0, len;
273 unsigned int i; 297 unsigned int i;
274 298
299 len = hdr->e_shnum * sizeof(me->arch.section[0]);
300 me->arch.section = kzalloc(len, GFP_KERNEL);
301 if (!me->arch.section)
302 return -ENOMEM;
303
275 for (i = 1; i < hdr->e_shnum; i++) { 304 for (i = 1; i < hdr->e_shnum; i++) {
276 const Elf_Rela *rels = (void *)hdr + sechdrs[i].sh_offset; 305 const Elf_Rela *rels = (void *)sechdrs[i].sh_addr;
277 unsigned long nrels = sechdrs[i].sh_size / sizeof(*rels); 306 unsigned long nrels = sechdrs[i].sh_size / sizeof(*rels);
307 unsigned int count, s;
278 308
279 if (strncmp(secstrings + sechdrs[i].sh_name, 309 if (strncmp(secstrings + sechdrs[i].sh_name,
280 ".PARISC.unwind", 14) == 0) 310 ".PARISC.unwind", 14) == 0)
@@ -290,11 +320,23 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
290 */ 320 */
291 gots += count_gots(rels, nrels); 321 gots += count_gots(rels, nrels);
292 fdescs += count_fdescs(rels, nrels); 322 fdescs += count_fdescs(rels, nrels);
293 if(strncmp(secstrings + sechdrs[i].sh_name, 323
294 ".rela.init", 10) == 0) 324 /* XXX: By sorting the relocs and finding duplicate entries
295 init_stubs += count_stubs(rels, nrels); 325 * we could reduce the number of necessary stubs and save
296 else 326 * some memory. */
297 stubs += count_stubs(rels, nrels); 327 count = count_stubs(rels, nrels);
328 if (!count)
329 continue;
330
331 /* so we need relocation stubs. reserve necessary memory. */
332 /* sh_info gives the section for which we need to add stubs. */
333 s = sechdrs[i].sh_info;
334
335 /* each code section should only have one relocation section */
336 WARN_ON(me->arch.section[s].stub_entries);
337
338 /* store number of stubs we need for this section */
339 me->arch.section[s].stub_entries += count;
298 } 340 }
299 341
300 /* align things a bit */ 342 /* align things a bit */
@@ -306,18 +348,8 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
306 me->arch.fdesc_offset = me->core_size; 348 me->arch.fdesc_offset = me->core_size;
307 me->core_size += fdescs * sizeof(Elf_Fdesc); 349 me->core_size += fdescs * sizeof(Elf_Fdesc);
308 350
309 me->core_size = ALIGN(me->core_size, 16);
310 me->arch.stub_offset = me->core_size;
311 me->core_size += stubs * sizeof(struct stub_entry);
312
313 me->init_size = ALIGN(me->init_size, 16);
314 me->arch.init_stub_offset = me->init_size;
315 me->init_size += init_stubs * sizeof(struct stub_entry);
316
317 me->arch.got_max = gots; 351 me->arch.got_max = gots;
318 me->arch.fdesc_max = fdescs; 352 me->arch.fdesc_max = fdescs;
319 me->arch.stub_max = stubs;
320 me->arch.init_stub_max = init_stubs;
321 353
322 return 0; 354 return 0;
323} 355}
@@ -380,23 +412,27 @@ enum elf_stub_type {
380}; 412};
381 413
382static Elf_Addr get_stub(struct module *me, unsigned long value, long addend, 414static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
383 enum elf_stub_type stub_type, int init_section) 415 enum elf_stub_type stub_type, Elf_Addr loc0, unsigned int targetsec)
384{ 416{
385 unsigned long i;
386 struct stub_entry *stub; 417 struct stub_entry *stub;
387 418
388 if(init_section) { 419 /* initialize stub_offset to point in front of the section */
389 i = me->arch.init_stub_count++; 420 if (!me->arch.section[targetsec].stub_offset) {
390 BUG_ON(me->arch.init_stub_count > me->arch.init_stub_max); 421 loc0 -= (me->arch.section[targetsec].stub_entries + 1) *
391 stub = me->module_init + me->arch.init_stub_offset + 422 sizeof(struct stub_entry);
392 i * sizeof(struct stub_entry); 423 /* get correct alignment for the stubs */
393 } else { 424 loc0 = ALIGN(loc0, sizeof(struct stub_entry));
394 i = me->arch.stub_count++; 425 me->arch.section[targetsec].stub_offset = loc0;
395 BUG_ON(me->arch.stub_count > me->arch.stub_max);
396 stub = me->module_core + me->arch.stub_offset +
397 i * sizeof(struct stub_entry);
398 } 426 }
399 427
428 /* get address of stub entry */
429 stub = (void *) me->arch.section[targetsec].stub_offset;
430 me->arch.section[targetsec].stub_offset += sizeof(struct stub_entry);
431
432 /* do not write outside available stub area */
433 BUG_ON(0 == me->arch.section[targetsec].stub_entries--);
434
435
400#ifndef CONFIG_64BIT 436#ifndef CONFIG_64BIT
401/* for 32-bit the stub looks like this: 437/* for 32-bit the stub looks like this:
402 * ldil L'XXX,%r1 438 * ldil L'XXX,%r1
@@ -489,15 +525,19 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
489 Elf32_Addr val; 525 Elf32_Addr val;
490 Elf32_Sword addend; 526 Elf32_Sword addend;
491 Elf32_Addr dot; 527 Elf32_Addr dot;
528 Elf_Addr loc0;
529 unsigned int targetsec = sechdrs[relsec].sh_info;
492 //unsigned long dp = (unsigned long)$global$; 530 //unsigned long dp = (unsigned long)$global$;
493 register unsigned long dp asm ("r27"); 531 register unsigned long dp asm ("r27");
494 532
495 DEBUGP("Applying relocate section %u to %u\n", relsec, 533 DEBUGP("Applying relocate section %u to %u\n", relsec,
496 sechdrs[relsec].sh_info); 534 targetsec);
497 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 535 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
498 /* This is where to make the change */ 536 /* This is where to make the change */
499 loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr 537 loc = (void *)sechdrs[targetsec].sh_addr
500 + rel[i].r_offset; 538 + rel[i].r_offset;
539 /* This is the start of the target section */
540 loc0 = sechdrs[targetsec].sh_addr;
501 /* This is the symbol it is referring to */ 541 /* This is the symbol it is referring to */
502 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr 542 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
503 + ELF32_R_SYM(rel[i].r_info); 543 + ELF32_R_SYM(rel[i].r_info);
@@ -569,19 +609,32 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
569 break; 609 break;
570 case R_PARISC_PCREL17F: 610 case R_PARISC_PCREL17F:
571 /* 17-bit PC relative address */ 611 /* 17-bit PC relative address */
572 val = get_stub(me, val, addend, ELF_STUB_GOT, in_init(me, loc)); 612 /* calculate direct call offset */
613 val += addend;
573 val = (val - dot - 8)/4; 614 val = (val - dot - 8)/4;
574 CHECK_RELOC(val, 17) 615 if (!RELOC_REACHABLE(val, 17)) {
616 /* direct distance too far, create
617 * stub entry instead */
618 val = get_stub(me, sym->st_value, addend,
619 ELF_STUB_DIRECT, loc0, targetsec);
620 val = (val - dot - 8)/4;
621 CHECK_RELOC(val, 17);
622 }
575 *loc = (*loc & ~0x1f1ffd) | reassemble_17(val); 623 *loc = (*loc & ~0x1f1ffd) | reassemble_17(val);
576 break; 624 break;
577 case R_PARISC_PCREL22F: 625 case R_PARISC_PCREL22F:
578 /* 22-bit PC relative address; only defined for pa20 */ 626 /* 22-bit PC relative address; only defined for pa20 */
579 val = get_stub(me, val, addend, ELF_STUB_GOT, in_init(me, loc)); 627 /* calculate direct call offset */
580 DEBUGP("STUB FOR %s loc %lx+%lx at %lx\n", 628 val += addend;
581 strtab + sym->st_name, (unsigned long)loc, addend,
582 val)
583 val = (val - dot - 8)/4; 629 val = (val - dot - 8)/4;
584 CHECK_RELOC(val, 22); 630 if (!RELOC_REACHABLE(val, 22)) {
631 /* direct distance too far, create
632 * stub entry instead */
633 val = get_stub(me, sym->st_value, addend,
634 ELF_STUB_DIRECT, loc0, targetsec);
635 val = (val - dot - 8)/4;
636 CHECK_RELOC(val, 22);
637 }
585 *loc = (*loc & ~0x3ff1ffd) | reassemble_22(val); 638 *loc = (*loc & ~0x3ff1ffd) | reassemble_22(val);
586 break; 639 break;
587 640
@@ -610,13 +663,17 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
610 Elf64_Addr val; 663 Elf64_Addr val;
611 Elf64_Sxword addend; 664 Elf64_Sxword addend;
612 Elf64_Addr dot; 665 Elf64_Addr dot;
666 Elf_Addr loc0;
667 unsigned int targetsec = sechdrs[relsec].sh_info;
613 668
614 DEBUGP("Applying relocate section %u to %u\n", relsec, 669 DEBUGP("Applying relocate section %u to %u\n", relsec,
615 sechdrs[relsec].sh_info); 670 targetsec);
616 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) { 671 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
617 /* This is where to make the change */ 672 /* This is where to make the change */
618 loc = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr 673 loc = (void *)sechdrs[targetsec].sh_addr
619 + rel[i].r_offset; 674 + rel[i].r_offset;
675 /* This is the start of the target section */
676 loc0 = sechdrs[targetsec].sh_addr;
620 /* This is the symbol it is referring to */ 677 /* This is the symbol it is referring to */
621 sym = (Elf64_Sym *)sechdrs[symindex].sh_addr 678 sym = (Elf64_Sym *)sechdrs[symindex].sh_addr
622 + ELF64_R_SYM(rel[i].r_info); 679 + ELF64_R_SYM(rel[i].r_info);
@@ -672,42 +729,40 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
672 DEBUGP("PCREL22F Symbol %s loc %p val %lx\n", 729 DEBUGP("PCREL22F Symbol %s loc %p val %lx\n",
673 strtab + sym->st_name, 730 strtab + sym->st_name,
674 loc, val); 731 loc, val);
732 val += addend;
675 /* can we reach it locally? */ 733 /* can we reach it locally? */
676 if(!in_local_section(me, (void *)val, (void *)dot)) { 734 if (in_local(me, (void *)val)) {
677 735 /* this is the case where the symbol is local
678 if (in_local(me, (void *)val)) 736 * to the module, but in a different section,
679 /* this is the case where the 737 * so stub the jump in case it's more than 22
680 * symbol is local to the 738 * bits away */
681 * module, but in a different 739 val = (val - dot - 8)/4;
682 * section, so stub the jump 740 if (!RELOC_REACHABLE(val, 22)) {
683 * in case it's more than 22 741 /* direct distance too far, create
684 * bits away */ 742 * stub entry instead */
685 val = get_stub(me, val, addend, ELF_STUB_DIRECT, 743 val = get_stub(me, sym->st_value,
686 in_init(me, loc)); 744 addend, ELF_STUB_DIRECT,
687 else if (strncmp(strtab + sym->st_name, "$$", 2) 745 loc0, targetsec);
746 } else {
747 /* Ok, we can reach it directly. */
748 val = sym->st_value;
749 val += addend;
750 }
751 } else {
752 val = sym->st_value;
753 if (strncmp(strtab + sym->st_name, "$$", 2)
688 == 0) 754 == 0)
689 val = get_stub(me, val, addend, ELF_STUB_MILLI, 755 val = get_stub(me, val, addend, ELF_STUB_MILLI,
690 in_init(me, loc)); 756 loc0, targetsec);
691 else 757 else
692 val = get_stub(me, val, addend, ELF_STUB_GOT, 758 val = get_stub(me, val, addend, ELF_STUB_GOT,
693 in_init(me, loc)); 759 loc0, targetsec);
694 } 760 }
695 DEBUGP("STUB FOR %s loc %lx, val %lx+%lx at %lx\n", 761 DEBUGP("STUB FOR %s loc %lx, val %lx+%lx at %lx\n",
696 strtab + sym->st_name, loc, sym->st_value, 762 strtab + sym->st_name, loc, sym->st_value,
697 addend, val); 763 addend, val);
698 /* FIXME: local symbols work as long as the
699 * core and init pieces aren't separated too
700 * far. If this is ever broken, you will trip
701 * the check below. The way to fix it would
702 * be to generate local stubs to go between init
703 * and core */
704 if((Elf64_Sxword)(val - dot - 8) > 0x800000 -1 ||
705 (Elf64_Sxword)(val - dot - 8) < -0x800000) {
706 printk(KERN_ERR "Module %s, symbol %s is out of range for PCREL22F relocation\n",
707 me->name, strtab + sym->st_name);
708 return -ENOEXEC;
709 }
710 val = (val - dot - 8)/4; 764 val = (val - dot - 8)/4;
765 CHECK_RELOC(val, 22);
711 *loc = (*loc & ~0x3ff1ffd) | reassemble_22(val); 766 *loc = (*loc & ~0x3ff1ffd) | reassemble_22(val);
712 break; 767 break;
713 case R_PARISC_DIR64: 768 case R_PARISC_DIR64:
@@ -794,12 +849,8 @@ int module_finalize(const Elf_Ehdr *hdr,
794 addr = (u32 *)entry->addr; 849 addr = (u32 *)entry->addr;
795 printk("INSNS: %x %x %x %x\n", 850 printk("INSNS: %x %x %x %x\n",
796 addr[0], addr[1], addr[2], addr[3]); 851 addr[0], addr[1], addr[2], addr[3]);
797 printk("stubs used %ld, stubs max %ld\n" 852 printk("got entries used %ld, gots max %ld\n"
798 "init_stubs used %ld, init stubs max %ld\n"
799 "got entries used %ld, gots max %ld\n"
800 "fdescs used %ld, fdescs max %ld\n", 853 "fdescs used %ld, fdescs max %ld\n",
801 me->arch.stub_count, me->arch.stub_max,
802 me->arch.init_stub_count, me->arch.init_stub_max,
803 me->arch.got_count, me->arch.got_max, 854 me->arch.got_count, me->arch.got_max,
804 me->arch.fdesc_count, me->arch.fdesc_max); 855 me->arch.fdesc_count, me->arch.fdesc_max);
805#endif 856#endif
@@ -829,7 +880,10 @@ int module_finalize(const Elf_Ehdr *hdr,
829 me->name, me->arch.got_count, MAX_GOTS); 880 me->name, me->arch.got_count, MAX_GOTS);
830 return -EINVAL; 881 return -EINVAL;
831 } 882 }
832 883
884 kfree(me->arch.section);
885 me->arch.section = NULL;
886
833 /* no symbol table */ 887 /* no symbol table */
834 if(symhdr == NULL) 888 if(symhdr == NULL)
835 return 0; 889 return 0;
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 373fca394a54..375258559ae6 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -22,11 +22,11 @@ static inline cpumask_t node_to_cpumask(int node)
22 return numa_cpumask_lookup_table[node]; 22 return numa_cpumask_lookup_table[node];
23} 23}
24 24
25#define cpumask_of_node(node) (&numa_cpumask_lookup_table[node])
26
25static inline int node_to_first_cpu(int node) 27static inline int node_to_first_cpu(int node)
26{ 28{
27 cpumask_t tmp; 29 return cpumask_first(cpumask_of_node(node));
28 tmp = node_to_cpumask(node);
29 return first_cpu(tmp);
30} 30}
31 31
32int of_node_to_nid(struct device_node *device); 32int of_node_to_nid(struct device_node *device);
@@ -46,6 +46,10 @@ static inline int pcibus_to_node(struct pci_bus *bus)
46 node_to_cpumask(pcibus_to_node(bus)) \ 46 node_to_cpumask(pcibus_to_node(bus)) \
47 ) 47 )
48 48
49#define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
50 cpu_all_mask : \
51 cpumask_of_node(pcibus_to_node(bus)))
52
49/* sched_domains SD_NODE_INIT for PPC64 machines */ 53/* sched_domains SD_NODE_INIT for PPC64 machines */
50#define SD_NODE_INIT (struct sched_domain) { \ 54#define SD_NODE_INIT (struct sched_domain) { \
51 .parent = NULL, \ 55 .parent = NULL, \
@@ -108,6 +112,8 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
108 112
109#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 113#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
110#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu)) 114#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
115#define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
116#define topology_core_cpumask(cpu) (&per_cpu(cpu_core_map, cpu))
111#define topology_core_id(cpu) (cpu_to_core_id(cpu)) 117#define topology_core_id(cpu) (cpu_to_core_id(cpu))
112#endif 118#endif
113#endif 119#endif
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 51b201ddf9a1..fb7049c054c0 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -33,6 +33,7 @@
33#include <linux/mqueue.h> 33#include <linux/mqueue.h>
34#include <linux/hardirq.h> 34#include <linux/hardirq.h>
35#include <linux/utsname.h> 35#include <linux/utsname.h>
36#include <linux/kernel_stat.h>
36 37
37#include <asm/pgtable.h> 38#include <asm/pgtable.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 99f1ddd68582..c9564031a2a9 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -256,8 +256,10 @@ void account_system_vtime(struct task_struct *tsk)
256 delta += sys_time; 256 delta += sys_time;
257 get_paca()->system_time = 0; 257 get_paca()->system_time = 0;
258 } 258 }
259 account_system_time(tsk, 0, delta); 259 if (in_irq() || idle_task(smp_processor_id()) != tsk)
260 account_system_time_scaled(tsk, deltascaled); 260 account_system_time(tsk, 0, delta, deltascaled);
261 else
262 account_idle_time(delta);
261 per_cpu(cputime_last_delta, smp_processor_id()) = delta; 263 per_cpu(cputime_last_delta, smp_processor_id()) = delta;
262 per_cpu(cputime_scaled_last_delta, smp_processor_id()) = deltascaled; 264 per_cpu(cputime_scaled_last_delta, smp_processor_id()) = deltascaled;
263 local_irq_restore(flags); 265 local_irq_restore(flags);
@@ -275,10 +277,8 @@ void account_process_tick(struct task_struct *tsk, int user_tick)
275 277
276 utime = get_paca()->user_time; 278 utime = get_paca()->user_time;
277 get_paca()->user_time = 0; 279 get_paca()->user_time = 0;
278 account_user_time(tsk, utime);
279
280 utimescaled = cputime_to_scaled(utime); 280 utimescaled = cputime_to_scaled(utime);
281 account_user_time_scaled(tsk, utimescaled); 281 account_user_time(tsk, utime, utimescaled);
282} 282}
283 283
284/* 284/*
@@ -338,8 +338,12 @@ void calculate_steal_time(void)
338 tb = mftb(); 338 tb = mftb();
339 purr = mfspr(SPRN_PURR); 339 purr = mfspr(SPRN_PURR);
340 stolen = (tb - pme->tb) - (purr - pme->purr); 340 stolen = (tb - pme->tb) - (purr - pme->purr);
341 if (stolen > 0) 341 if (stolen > 0) {
342 account_steal_time(current, stolen); 342 if (idle_task(smp_processor_id()) != current)
343 account_steal_time(stolen);
344 else
345 account_idle_time(stolen);
346 }
343 pme->tb = tb; 347 pme->tb = tb;
344 pme->purr = purr; 348 pme->purr = purr;
345} 349}
diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.c b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
index 906a0a2a9fe1..1410443731eb 100644
--- a/arch/powerpc/platforms/cell/spu_priv1_mmio.c
+++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
@@ -80,10 +80,10 @@ static void cpu_affinity_set(struct spu *spu, int cpu)
80 u64 route; 80 u64 route;
81 81
82 if (nr_cpus_node(spu->node)) { 82 if (nr_cpus_node(spu->node)) {
83 cpumask_t spumask = node_to_cpumask(spu->node); 83 const struct cpumask *spumask = cpumask_of_node(spu->node),
84 cpumask_t cpumask = node_to_cpumask(cpu_to_node(cpu)); 84 *cpumask = cpumask_of_node(cpu_to_node(cpu));
85 85
86 if (!cpus_intersects(spumask, cpumask)) 86 if (!cpumask_intersects(spumask, cpumask))
87 return; 87 return;
88 } 88 }
89 89
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 6296bfd9cb0b..e309ef70a531 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -97,7 +97,6 @@ spufs_new_inode(struct super_block *sb, int mode)
97 inode->i_mode = mode; 97 inode->i_mode = mode;
98 inode->i_uid = current_fsuid(); 98 inode->i_uid = current_fsuid();
99 inode->i_gid = current_fsgid(); 99 inode->i_gid = current_fsgid();
100 inode->i_blocks = 0;
101 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 100 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
102out: 101out:
103 return inode; 102 return inode;
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 2ad914c47493..6a0ad196aeb3 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -166,9 +166,9 @@ void spu_update_sched_info(struct spu_context *ctx)
166static int __node_allowed(struct spu_context *ctx, int node) 166static int __node_allowed(struct spu_context *ctx, int node)
167{ 167{
168 if (nr_cpus_node(node)) { 168 if (nr_cpus_node(node)) {
169 cpumask_t mask = node_to_cpumask(node); 169 const struct cpumask *mask = cpumask_of_node(node);
170 170
171 if (cpus_intersects(mask, ctx->cpus_allowed)) 171 if (cpumask_intersects(mask, &ctx->cpus_allowed))
172 return 1; 172 return 1;
173 } 173 }
174 174
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 9d4f8e6c0800..5a805df216bb 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -106,7 +106,6 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode)
106 ret->i_mode = mode; 106 ret->i_mode = mode;
107 ret->i_uid = hypfs_info->uid; 107 ret->i_uid = hypfs_info->uid;
108 ret->i_gid = hypfs_info->gid; 108 ret->i_gid = hypfs_info->gid;
109 ret->i_blocks = 0;
110 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 109 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
111 if (mode & S_IFDIR) 110 if (mode & S_IFDIR)
112 ret->i_nlink = 2; 111 ret->i_nlink = 2;
diff --git a/arch/s390/include/asm/cpu.h b/arch/s390/include/asm/cpu.h
index e5a6a9ba3adf..d60a2eefb17b 100644
--- a/arch/s390/include/asm/cpu.h
+++ b/arch/s390/include/asm/cpu.h
@@ -14,7 +14,6 @@
14 14
15struct s390_idle_data { 15struct s390_idle_data {
16 spinlock_t lock; 16 spinlock_t lock;
17 unsigned int in_idle;
18 unsigned long long idle_count; 17 unsigned long long idle_count;
19 unsigned long long idle_enter; 18 unsigned long long idle_enter;
20 unsigned long long idle_time; 19 unsigned long long idle_time;
@@ -22,12 +21,12 @@ struct s390_idle_data {
22 21
23DECLARE_PER_CPU(struct s390_idle_data, s390_idle); 22DECLARE_PER_CPU(struct s390_idle_data, s390_idle);
24 23
25void s390_idle_leave(void); 24void vtime_start_cpu(void);
26 25
27static inline void s390_idle_check(void) 26static inline void s390_idle_check(void)
28{ 27{
29 if ((&__get_cpu_var(s390_idle))->in_idle) 28 if ((&__get_cpu_var(s390_idle))->idle_enter != 0ULL)
30 s390_idle_leave(); 29 vtime_start_cpu();
31} 30}
32 31
33#endif /* _ASM_S390_CPU_H_ */ 32#endif /* _ASM_S390_CPU_H_ */
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 133ce054fc89..521726430afa 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -11,7 +11,7 @@
11 11
12#include <asm/div64.h> 12#include <asm/div64.h>
13 13
14/* We want to use micro-second resolution. */ 14/* We want to use full resolution of the CPU timer: 2**-12 micro-seconds. */
15 15
16typedef unsigned long long cputime_t; 16typedef unsigned long long cputime_t;
17typedef unsigned long long cputime64_t; 17typedef unsigned long long cputime64_t;
@@ -53,9 +53,9 @@ __div(unsigned long long n, unsigned int base)
53#define cputime_ge(__a, __b) ((__a) >= (__b)) 53#define cputime_ge(__a, __b) ((__a) >= (__b))
54#define cputime_lt(__a, __b) ((__a) < (__b)) 54#define cputime_lt(__a, __b) ((__a) < (__b))
55#define cputime_le(__a, __b) ((__a) <= (__b)) 55#define cputime_le(__a, __b) ((__a) <= (__b))
56#define cputime_to_jiffies(__ct) (__div((__ct), 1000000 / HZ)) 56#define cputime_to_jiffies(__ct) (__div((__ct), 4096000000ULL / HZ))
57#define cputime_to_scaled(__ct) (__ct) 57#define cputime_to_scaled(__ct) (__ct)
58#define jiffies_to_cputime(__hz) ((cputime_t)(__hz) * (1000000 / HZ)) 58#define jiffies_to_cputime(__hz) ((cputime_t)(__hz) * (4096000000ULL / HZ))
59 59
60#define cputime64_zero (0ULL) 60#define cputime64_zero (0ULL)
61#define cputime64_add(__a, __b) ((__a) + (__b)) 61#define cputime64_add(__a, __b) ((__a) + (__b))
@@ -64,7 +64,7 @@ __div(unsigned long long n, unsigned int base)
64static inline u64 64static inline u64
65cputime64_to_jiffies64(cputime64_t cputime) 65cputime64_to_jiffies64(cputime64_t cputime)
66{ 66{
67 do_div(cputime, 1000000 / HZ); 67 do_div(cputime, 4096000000ULL / HZ);
68 return cputime; 68 return cputime;
69} 69}
70 70
@@ -74,13 +74,13 @@ cputime64_to_jiffies64(cputime64_t cputime)
74static inline unsigned int 74static inline unsigned int
75cputime_to_msecs(const cputime_t cputime) 75cputime_to_msecs(const cputime_t cputime)
76{ 76{
77 return __div(cputime, 1000); 77 return __div(cputime, 4096000);
78} 78}
79 79
80static inline cputime_t 80static inline cputime_t
81msecs_to_cputime(const unsigned int m) 81msecs_to_cputime(const unsigned int m)
82{ 82{
83 return (cputime_t) m * 1000; 83 return (cputime_t) m * 4096000;
84} 84}
85 85
86/* 86/*
@@ -89,13 +89,13 @@ msecs_to_cputime(const unsigned int m)
89static inline unsigned int 89static inline unsigned int
90cputime_to_secs(const cputime_t cputime) 90cputime_to_secs(const cputime_t cputime)
91{ 91{
92 return __div(cputime, 1000000); 92 return __div(cputime, 2048000000) >> 1;
93} 93}
94 94
95static inline cputime_t 95static inline cputime_t
96secs_to_cputime(const unsigned int s) 96secs_to_cputime(const unsigned int s)
97{ 97{
98 return (cputime_t) s * 1000000; 98 return (cputime_t) s * 4096000000ULL;
99} 99}
100 100
101/* 101/*
@@ -104,7 +104,7 @@ secs_to_cputime(const unsigned int s)
104static inline cputime_t 104static inline cputime_t
105timespec_to_cputime(const struct timespec *value) 105timespec_to_cputime(const struct timespec *value)
106{ 106{
107 return value->tv_nsec / 1000 + (u64) value->tv_sec * 1000000; 107 return value->tv_nsec * 4096 / 1000 + (u64) value->tv_sec * 4096000000ULL;
108} 108}
109 109
110static inline void 110static inline void
@@ -114,12 +114,12 @@ cputime_to_timespec(const cputime_t cputime, struct timespec *value)
114 register_pair rp; 114 register_pair rp;
115 115
116 rp.pair = cputime >> 1; 116 rp.pair = cputime >> 1;
117 asm ("dr %0,%1" : "+d" (rp) : "d" (1000000 >> 1)); 117 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL));
118 value->tv_nsec = rp.subreg.even * 1000; 118 value->tv_nsec = rp.subreg.even * 1000 / 4096;
119 value->tv_sec = rp.subreg.odd; 119 value->tv_sec = rp.subreg.odd;
120#else 120#else
121 value->tv_nsec = (cputime % 1000000) * 1000; 121 value->tv_nsec = (cputime % 4096000000ULL) * 1000 / 4096;
122 value->tv_sec = cputime / 1000000; 122 value->tv_sec = cputime / 4096000000ULL;
123#endif 123#endif
124} 124}
125 125
@@ -131,7 +131,7 @@ cputime_to_timespec(const cputime_t cputime, struct timespec *value)
131static inline cputime_t 131static inline cputime_t
132timeval_to_cputime(const struct timeval *value) 132timeval_to_cputime(const struct timeval *value)
133{ 133{
134 return value->tv_usec + (u64) value->tv_sec * 1000000; 134 return value->tv_usec * 4096 + (u64) value->tv_sec * 4096000000ULL;
135} 135}
136 136
137static inline void 137static inline void
@@ -141,12 +141,12 @@ cputime_to_timeval(const cputime_t cputime, struct timeval *value)
141 register_pair rp; 141 register_pair rp;
142 142
143 rp.pair = cputime >> 1; 143 rp.pair = cputime >> 1;
144 asm ("dr %0,%1" : "+d" (rp) : "d" (1000000 >> 1)); 144 asm ("dr %0,%1" : "+d" (rp) : "d" (2048000000UL));
145 value->tv_usec = rp.subreg.even; 145 value->tv_usec = rp.subreg.even / 4096;
146 value->tv_sec = rp.subreg.odd; 146 value->tv_sec = rp.subreg.odd;
147#else 147#else
148 value->tv_usec = cputime % 1000000; 148 value->tv_usec = cputime % 4096000000ULL;
149 value->tv_sec = cputime / 1000000; 149 value->tv_sec = cputime / 4096000000ULL;
150#endif 150#endif
151} 151}
152 152
@@ -156,13 +156,13 @@ cputime_to_timeval(const cputime_t cputime, struct timeval *value)
156static inline clock_t 156static inline clock_t
157cputime_to_clock_t(cputime_t cputime) 157cputime_to_clock_t(cputime_t cputime)
158{ 158{
159 return __div(cputime, 1000000 / USER_HZ); 159 return __div(cputime, 4096000000ULL / USER_HZ);
160} 160}
161 161
162static inline cputime_t 162static inline cputime_t
163clock_t_to_cputime(unsigned long x) 163clock_t_to_cputime(unsigned long x)
164{ 164{
165 return (cputime_t) x * (1000000 / USER_HZ); 165 return (cputime_t) x * (4096000000ULL / USER_HZ);
166} 166}
167 167
168/* 168/*
@@ -171,7 +171,7 @@ clock_t_to_cputime(unsigned long x)
171static inline clock_t 171static inline clock_t
172cputime64_to_clock_t(cputime64_t cputime) 172cputime64_to_clock_t(cputime64_t cputime)
173{ 173{
174 return __div(cputime, 1000000 / USER_HZ); 174 return __div(cputime, 4096000000ULL / USER_HZ);
175} 175}
176 176
177#endif /* _S390_CPUTIME_H */ 177#endif /* _S390_CPUTIME_H */
diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index 0bc51d52a899..ffdef5fe8587 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -67,11 +67,11 @@
67#define __LC_SYNC_ENTER_TIMER 0x248 67#define __LC_SYNC_ENTER_TIMER 0x248
68#define __LC_ASYNC_ENTER_TIMER 0x250 68#define __LC_ASYNC_ENTER_TIMER 0x250
69#define __LC_EXIT_TIMER 0x258 69#define __LC_EXIT_TIMER 0x258
70#define __LC_LAST_UPDATE_TIMER 0x260 70#define __LC_USER_TIMER 0x260
71#define __LC_USER_TIMER 0x268 71#define __LC_SYSTEM_TIMER 0x268
72#define __LC_SYSTEM_TIMER 0x270 72#define __LC_STEAL_TIMER 0x270
73#define __LC_LAST_UPDATE_CLOCK 0x278 73#define __LC_LAST_UPDATE_TIMER 0x278
74#define __LC_STEAL_CLOCK 0x280 74#define __LC_LAST_UPDATE_CLOCK 0x280
75#define __LC_RETURN_MCCK_PSW 0x288 75#define __LC_RETURN_MCCK_PSW 0x288
76#define __LC_KERNEL_STACK 0xC40 76#define __LC_KERNEL_STACK 0xC40
77#define __LC_THREAD_INFO 0xC44 77#define __LC_THREAD_INFO 0xC44
@@ -89,11 +89,11 @@
89#define __LC_SYNC_ENTER_TIMER 0x250 89#define __LC_SYNC_ENTER_TIMER 0x250
90#define __LC_ASYNC_ENTER_TIMER 0x258 90#define __LC_ASYNC_ENTER_TIMER 0x258
91#define __LC_EXIT_TIMER 0x260 91#define __LC_EXIT_TIMER 0x260
92#define __LC_LAST_UPDATE_TIMER 0x268 92#define __LC_USER_TIMER 0x268
93#define __LC_USER_TIMER 0x270 93#define __LC_SYSTEM_TIMER 0x270
94#define __LC_SYSTEM_TIMER 0x278 94#define __LC_STEAL_TIMER 0x278
95#define __LC_LAST_UPDATE_CLOCK 0x280 95#define __LC_LAST_UPDATE_TIMER 0x280
96#define __LC_STEAL_CLOCK 0x288 96#define __LC_LAST_UPDATE_CLOCK 0x288
97#define __LC_RETURN_MCCK_PSW 0x290 97#define __LC_RETURN_MCCK_PSW 0x290
98#define __LC_KERNEL_STACK 0xD40 98#define __LC_KERNEL_STACK 0xD40
99#define __LC_THREAD_INFO 0xD48 99#define __LC_THREAD_INFO 0xD48
@@ -106,8 +106,10 @@
106#define __LC_IPLDEV 0xDB8 106#define __LC_IPLDEV 0xDB8
107#define __LC_CURRENT 0xDD8 107#define __LC_CURRENT 0xDD8
108#define __LC_INT_CLOCK 0xDE8 108#define __LC_INT_CLOCK 0xDE8
109#define __LC_VDSO_PER_CPU 0xE38
109#endif /* __s390x__ */ 110#endif /* __s390x__ */
110 111
112#define __LC_PASTE 0xE40
111 113
112#define __LC_PANIC_MAGIC 0xE00 114#define __LC_PANIC_MAGIC 0xE00
113#ifndef __s390x__ 115#ifndef __s390x__
@@ -252,11 +254,11 @@ struct _lowcore
252 __u64 sync_enter_timer; /* 0x248 */ 254 __u64 sync_enter_timer; /* 0x248 */
253 __u64 async_enter_timer; /* 0x250 */ 255 __u64 async_enter_timer; /* 0x250 */
254 __u64 exit_timer; /* 0x258 */ 256 __u64 exit_timer; /* 0x258 */
255 __u64 last_update_timer; /* 0x260 */ 257 __u64 user_timer; /* 0x260 */
256 __u64 user_timer; /* 0x268 */ 258 __u64 system_timer; /* 0x268 */
257 __u64 system_timer; /* 0x270 */ 259 __u64 steal_timer; /* 0x270 */
258 __u64 last_update_clock; /* 0x278 */ 260 __u64 last_update_timer; /* 0x278 */
259 __u64 steal_clock; /* 0x280 */ 261 __u64 last_update_clock; /* 0x280 */
260 psw_t return_mcck_psw; /* 0x288 */ 262 psw_t return_mcck_psw; /* 0x288 */
261 __u8 pad8[0xc00-0x290]; /* 0x290 */ 263 __u8 pad8[0xc00-0x290]; /* 0x290 */
262 264
@@ -343,11 +345,11 @@ struct _lowcore
343 __u64 sync_enter_timer; /* 0x250 */ 345 __u64 sync_enter_timer; /* 0x250 */
344 __u64 async_enter_timer; /* 0x258 */ 346 __u64 async_enter_timer; /* 0x258 */
345 __u64 exit_timer; /* 0x260 */ 347 __u64 exit_timer; /* 0x260 */
346 __u64 last_update_timer; /* 0x268 */ 348 __u64 user_timer; /* 0x268 */
347 __u64 user_timer; /* 0x270 */ 349 __u64 system_timer; /* 0x270 */
348 __u64 system_timer; /* 0x278 */ 350 __u64 steal_timer; /* 0x278 */
349 __u64 last_update_clock; /* 0x280 */ 351 __u64 last_update_timer; /* 0x280 */
350 __u64 steal_clock; /* 0x288 */ 352 __u64 last_update_clock; /* 0x288 */
351 psw_t return_mcck_psw; /* 0x290 */ 353 psw_t return_mcck_psw; /* 0x290 */
352 __u8 pad8[0xc00-0x2a0]; /* 0x2a0 */ 354 __u8 pad8[0xc00-0x2a0]; /* 0x2a0 */
353 /* System info area */ 355 /* System info area */
@@ -381,7 +383,12 @@ struct _lowcore
381 /* whether the kernel died with panic() or not */ 383 /* whether the kernel died with panic() or not */
382 __u32 panic_magic; /* 0xe00 */ 384 __u32 panic_magic; /* 0xe00 */
383 385
384 __u8 pad13[0x11b8-0xe04]; /* 0xe04 */ 386 /* Per cpu primary space access list */
387 __u8 pad_0xe04[0xe3c-0xe04]; /* 0xe04 */
388 __u32 vdso_per_cpu_data; /* 0xe3c */
389 __u32 paste[16]; /* 0xe40 */
390
391 __u8 pad13[0x11b8-0xe80]; /* 0xe80 */
385 392
386 /* 64 bit extparam used for pfault, diag 250 etc */ 393 /* 64 bit extparam used for pfault, diag 250 etc */
387 __u64 ext_params2; /* 0x11B8 */ 394 __u64 ext_params2; /* 0x11B8 */
diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
index 024ef42ed6d7..3a8b26eb1f2e 100644
--- a/arch/s390/include/asm/system.h
+++ b/arch/s390/include/asm/system.h
@@ -99,7 +99,7 @@ static inline void restore_access_regs(unsigned int *acrs)
99 prev = __switch_to(prev,next); \ 99 prev = __switch_to(prev,next); \
100} while (0) 100} while (0)
101 101
102extern void account_vtime(struct task_struct *); 102extern void account_vtime(struct task_struct *, struct task_struct *);
103extern void account_tick_vtime(struct task_struct *); 103extern void account_tick_vtime(struct task_struct *);
104extern void account_system_vtime(struct task_struct *); 104extern void account_system_vtime(struct task_struct *);
105 105
@@ -121,7 +121,7 @@ static inline void cmma_init(void) { }
121 121
122#define finish_arch_switch(prev) do { \ 122#define finish_arch_switch(prev) do { \
123 set_fs(current->thread.mm_segment); \ 123 set_fs(current->thread.mm_segment); \
124 account_vtime(prev); \ 124 account_vtime(prev, current); \
125} while (0) 125} while (0)
126 126
127#define nop() asm volatile("nop") 127#define nop() asm volatile("nop")
diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h
index c1eaf9604da7..c544aa524535 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -47,6 +47,8 @@ struct thread_info {
47 unsigned int cpu; /* current CPU */ 47 unsigned int cpu; /* current CPU */
48 int preempt_count; /* 0 => preemptable, <0 => BUG */ 48 int preempt_count; /* 0 => preemptable, <0 => BUG */
49 struct restart_block restart_block; 49 struct restart_block restart_block;
50 __u64 user_timer;
51 __u64 system_timer;
50}; 52};
51 53
52/* 54/*
diff --git a/arch/s390/include/asm/timer.h b/arch/s390/include/asm/timer.h
index 61705d60f995..e4bcab739c19 100644
--- a/arch/s390/include/asm/timer.h
+++ b/arch/s390/include/asm/timer.h
@@ -23,20 +23,18 @@ struct vtimer_list {
23 __u64 expires; 23 __u64 expires;
24 __u64 interval; 24 __u64 interval;
25 25
26 spinlock_t lock;
27 unsigned long magic;
28
29 void (*function)(unsigned long); 26 void (*function)(unsigned long);
30 unsigned long data; 27 unsigned long data;
31}; 28};
32 29
33/* the offset value will wrap after ca. 71 years */ 30/* the vtimer value will wrap after ca. 71 years */
34struct vtimer_queue { 31struct vtimer_queue {
35 struct list_head list; 32 struct list_head list;
36 spinlock_t lock; 33 spinlock_t lock;
37 __u64 to_expire; /* current event expire time */ 34 __u64 timer; /* last programmed timer */
38 __u64 offset; /* list offset to zero */ 35 __u64 elapsed; /* elapsed time of timer expire values */
39 __u64 idle; /* temp var for idle */ 36 __u64 idle; /* temp var for idle */
37 int do_spt; /* =1: reprogram cpu timer in idle */
40}; 38};
41 39
42extern void init_virt_timer(struct vtimer_list *timer); 40extern void init_virt_timer(struct vtimer_list *timer);
@@ -48,8 +46,8 @@ extern int del_virt_timer(struct vtimer_list *timer);
48extern void init_cpu_vtimer(void); 46extern void init_cpu_vtimer(void);
49extern void vtime_init(void); 47extern void vtime_init(void);
50 48
51extern void vtime_start_cpu_timer(void); 49extern void vtime_stop_cpu(void);
52extern void vtime_stop_cpu_timer(void); 50extern void vtime_start_leave(void);
53 51
54#endif /* __KERNEL__ */ 52#endif /* __KERNEL__ */
55 53
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index d96c91643458..c93eb50e1d09 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -6,10 +6,12 @@
6#define mc_capable() (1) 6#define mc_capable() (1)
7 7
8cpumask_t cpu_coregroup_map(unsigned int cpu); 8cpumask_t cpu_coregroup_map(unsigned int cpu);
9const struct cpumask *cpu_coregroup_mask(unsigned int cpu);
9 10
10extern cpumask_t cpu_core_map[NR_CPUS]; 11extern cpumask_t cpu_core_map[NR_CPUS];
11 12
12#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 13#define topology_core_siblings(cpu) (cpu_core_map[cpu])
14#define topology_core_cpumask(cpu) (&cpu_core_map[cpu])
13 15
14int topology_set_cpu_management(int fc); 16int topology_set_cpu_management(int fc);
15void topology_schedule_update(void); 17void topology_schedule_update(void);
diff --git a/arch/s390/include/asm/vdso.h b/arch/s390/include/asm/vdso.h
index a44f4fe16a35..7bdd7c8ebc91 100644
--- a/arch/s390/include/asm/vdso.h
+++ b/arch/s390/include/asm/vdso.h
@@ -12,9 +12,9 @@
12#ifndef __ASSEMBLY__ 12#ifndef __ASSEMBLY__
13 13
14/* 14/*
15 * Note about this structure: 15 * Note about the vdso_data and vdso_per_cpu_data structures:
16 * 16 *
17 * NEVER USE THIS IN USERSPACE CODE DIRECTLY. The layout of this 17 * NEVER USE THEM IN USERSPACE CODE DIRECTLY. The layout of the
18 * structure is supposed to be known only to the function in the vdso 18 * structure is supposed to be known only to the function in the vdso
19 * itself and may change without notice. 19 * itself and may change without notice.
20 */ 20 */
@@ -28,10 +28,21 @@ struct vdso_data {
28 __u64 wtom_clock_nsec; /* 0x28 */ 28 __u64 wtom_clock_nsec; /* 0x28 */
29 __u32 tz_minuteswest; /* Minutes west of Greenwich 0x30 */ 29 __u32 tz_minuteswest; /* Minutes west of Greenwich 0x30 */
30 __u32 tz_dsttime; /* Type of dst correction 0x34 */ 30 __u32 tz_dsttime; /* Type of dst correction 0x34 */
31 __u32 ectg_available;
32};
33
34struct vdso_per_cpu_data {
35 __u64 ectg_timer_base;
36 __u64 ectg_user_time;
31}; 37};
32 38
33extern struct vdso_data *vdso_data; 39extern struct vdso_data *vdso_data;
34 40
41#ifdef CONFIG_64BIT
42int vdso_alloc_per_cpu(int cpu, struct _lowcore *lowcore);
43void vdso_free_per_cpu(int cpu, struct _lowcore *lowcore);
44#endif
45
35#endif /* __ASSEMBLY__ */ 46#endif /* __ASSEMBLY__ */
36 47
37#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index e641f60bac99..67a60016babb 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -48,6 +48,11 @@ int main(void)
48 DEFINE(__VDSO_WTOM_SEC, offsetof(struct vdso_data, wtom_clock_sec)); 48 DEFINE(__VDSO_WTOM_SEC, offsetof(struct vdso_data, wtom_clock_sec));
49 DEFINE(__VDSO_WTOM_NSEC, offsetof(struct vdso_data, wtom_clock_nsec)); 49 DEFINE(__VDSO_WTOM_NSEC, offsetof(struct vdso_data, wtom_clock_nsec));
50 DEFINE(__VDSO_TIMEZONE, offsetof(struct vdso_data, tz_minuteswest)); 50 DEFINE(__VDSO_TIMEZONE, offsetof(struct vdso_data, tz_minuteswest));
51 DEFINE(__VDSO_ECTG_OK, offsetof(struct vdso_data, ectg_available));
52 DEFINE(__VDSO_ECTG_BASE,
53 offsetof(struct vdso_per_cpu_data, ectg_timer_base));
54 DEFINE(__VDSO_ECTG_USER,
55 offsetof(struct vdso_per_cpu_data, ectg_user_time));
51 /* constants used by the vdso */ 56 /* constants used by the vdso */
52 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); 57 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
53 DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); 58 DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC);
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 55de521aef77..1268aa2991bf 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -583,8 +583,8 @@ kernel_per:
583 583
584 .globl io_int_handler 584 .globl io_int_handler
585io_int_handler: 585io_int_handler:
586 stpt __LC_ASYNC_ENTER_TIMER
587 stck __LC_INT_CLOCK 586 stck __LC_INT_CLOCK
587 stpt __LC_ASYNC_ENTER_TIMER
588 SAVE_ALL_BASE __LC_SAVE_AREA+16 588 SAVE_ALL_BASE __LC_SAVE_AREA+16
589 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16 589 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
590 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16 590 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
@@ -723,8 +723,8 @@ io_notify_resume:
723 723
724 .globl ext_int_handler 724 .globl ext_int_handler
725ext_int_handler: 725ext_int_handler:
726 stpt __LC_ASYNC_ENTER_TIMER
727 stck __LC_INT_CLOCK 726 stck __LC_INT_CLOCK
727 stpt __LC_ASYNC_ENTER_TIMER
728 SAVE_ALL_BASE __LC_SAVE_AREA+16 728 SAVE_ALL_BASE __LC_SAVE_AREA+16
729 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16 729 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
730 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16 730 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
@@ -750,6 +750,7 @@ __critical_end:
750 750
751 .globl mcck_int_handler 751 .globl mcck_int_handler
752mcck_int_handler: 752mcck_int_handler:
753 stck __LC_INT_CLOCK
753 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer 754 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
754 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs 755 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
755 SAVE_ALL_BASE __LC_SAVE_AREA+32 756 SAVE_ALL_BASE __LC_SAVE_AREA+32
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 16bb4fd1a403..c6fbde13971a 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -177,8 +177,11 @@ _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
177 .if !\sync 177 .if !\sync
178 ni \psworg+1,0xfd # clear wait state bit 178 ni \psworg+1,0xfd # clear wait state bit
179 .endif 179 .endif
180 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user 180 lg %r14,__LC_VDSO_PER_CPU
181 lmg %r0,%r13,SP_R0(%r15) # load gprs 0-13 of user
181 stpt __LC_EXIT_TIMER 182 stpt __LC_EXIT_TIMER
183 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
184 lmg %r14,%r15,SP_R14(%r15) # load grps 14-15 of user
182 lpswe \psworg # back to caller 185 lpswe \psworg # back to caller
183 .endm 186 .endm
184 187
@@ -559,8 +562,8 @@ kernel_per:
559 */ 562 */
560 .globl io_int_handler 563 .globl io_int_handler
561io_int_handler: 564io_int_handler:
562 stpt __LC_ASYNC_ENTER_TIMER
563 stck __LC_INT_CLOCK 565 stck __LC_INT_CLOCK
566 stpt __LC_ASYNC_ENTER_TIMER
564 SAVE_ALL_BASE __LC_SAVE_AREA+32 567 SAVE_ALL_BASE __LC_SAVE_AREA+32
565 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+32 568 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
566 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32 569 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
@@ -721,8 +724,8 @@ io_notify_resume:
721 */ 724 */
722 .globl ext_int_handler 725 .globl ext_int_handler
723ext_int_handler: 726ext_int_handler:
724 stpt __LC_ASYNC_ENTER_TIMER
725 stck __LC_INT_CLOCK 727 stck __LC_INT_CLOCK
728 stpt __LC_ASYNC_ENTER_TIMER
726 SAVE_ALL_BASE __LC_SAVE_AREA+32 729 SAVE_ALL_BASE __LC_SAVE_AREA+32
727 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32 730 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
728 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32 731 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
@@ -746,6 +749,7 @@ __critical_end:
746 */ 749 */
747 .globl mcck_int_handler 750 .globl mcck_int_handler
748mcck_int_handler: 751mcck_int_handler:
752 stck __LC_INT_CLOCK
749 la %r1,4095 # revalidate r1 753 la %r1,4095 # revalidate r1
750 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer 754 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
751 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs 755 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
@@ -979,23 +983,23 @@ cleanup_sysc_return:
979 983
980cleanup_sysc_leave: 984cleanup_sysc_leave:
981 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn) 985 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn)
982 je 2f 986 je 3f
983 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
984 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8) 987 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
985 je 2f 988 jhe 0f
986 mvc __LC_RETURN_PSW(16),SP_PSW(%r15) 989 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
9900: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
987 cghi %r12,__LC_MCK_OLD_PSW 991 cghi %r12,__LC_MCK_OLD_PSW
988 jne 0f 992 jne 1f
989 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15) 993 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
990 j 1f 994 j 2f
9910: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15) 9951: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
9921: lmg %r0,%r11,SP_R0(%r15) 9962: lmg %r0,%r11,SP_R0(%r15)
993 lg %r15,SP_R15(%r15) 997 lg %r15,SP_R15(%r15)
9942: la %r12,__LC_RETURN_PSW 9983: la %r12,__LC_RETURN_PSW
995 br %r14 999 br %r14
996cleanup_sysc_leave_insn: 1000cleanup_sysc_leave_insn:
997 .quad sysc_done - 4 1001 .quad sysc_done - 4
998 .quad sysc_done - 8 1002 .quad sysc_done - 16
999 1003
1000cleanup_io_return: 1004cleanup_io_return:
1001 mvc __LC_RETURN_PSW(8),0(%r12) 1005 mvc __LC_RETURN_PSW(8),0(%r12)
@@ -1005,23 +1009,23 @@ cleanup_io_return:
1005 1009
1006cleanup_io_leave: 1010cleanup_io_leave:
1007 clc 8(8,%r12),BASED(cleanup_io_leave_insn) 1011 clc 8(8,%r12),BASED(cleanup_io_leave_insn)
1008 je 2f 1012 je 3f
1009 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1010 clc 8(8,%r12),BASED(cleanup_io_leave_insn+8) 1013 clc 8(8,%r12),BASED(cleanup_io_leave_insn+8)
1011 je 2f 1014 jhe 0f
1012 mvc __LC_RETURN_PSW(16),SP_PSW(%r15) 1015 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
10160: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
1013 cghi %r12,__LC_MCK_OLD_PSW 1017 cghi %r12,__LC_MCK_OLD_PSW
1014 jne 0f 1018 jne 1f
1015 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15) 1019 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
1016 j 1f 1020 j 2f
10170: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15) 10211: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
10181: lmg %r0,%r11,SP_R0(%r15) 10222: lmg %r0,%r11,SP_R0(%r15)
1019 lg %r15,SP_R15(%r15) 1023 lg %r15,SP_R15(%r15)
10202: la %r12,__LC_RETURN_PSW 10243: la %r12,__LC_RETURN_PSW
1021 br %r14 1025 br %r14
1022cleanup_io_leave_insn: 1026cleanup_io_leave_insn:
1023 .quad io_done - 4 1027 .quad io_done - 4
1024 .quad io_done - 8 1028 .quad io_done - 16
1025 1029
1026/* 1030/*
1027 * Integer constants 1031 * Integer constants
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 3ccd36b24b8f..f9f70aa15244 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -87,6 +87,8 @@ startup_continue:
87 lg %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area 87 lg %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area
88 # move IPL device to lowcore 88 # move IPL device to lowcore
89 mvc __LC_IPLDEV(4),IPL_DEVICE+4-PARMAREA(%r12) 89 mvc __LC_IPLDEV(4),IPL_DEVICE+4-PARMAREA(%r12)
90 lghi %r0,__LC_PASTE
91 stg %r0,__LC_VDSO_PER_CPU
90# 92#
91# Setup stack 93# Setup stack
92# 94#
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 04f8c67a6101..b6110bdf8dc2 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -38,6 +38,7 @@
38#include <linux/utsname.h> 38#include <linux/utsname.h>
39#include <linux/tick.h> 39#include <linux/tick.h>
40#include <linux/elfcore.h> 40#include <linux/elfcore.h>
41#include <linux/kernel_stat.h>
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
43#include <asm/system.h> 44#include <asm/system.h>
@@ -45,7 +46,6 @@
45#include <asm/processor.h> 46#include <asm/processor.h>
46#include <asm/irq.h> 47#include <asm/irq.h>
47#include <asm/timer.h> 48#include <asm/timer.h>
48#include <asm/cpu.h>
49#include "entry.h" 49#include "entry.h"
50 50
51asmlinkage void ret_from_fork(void) asm ("ret_from_fork"); 51asmlinkage void ret_from_fork(void) asm ("ret_from_fork");
@@ -75,36 +75,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
75 return sf->gprs[8]; 75 return sf->gprs[8];
76} 76}
77 77
78DEFINE_PER_CPU(struct s390_idle_data, s390_idle) = {
79 .lock = __SPIN_LOCK_UNLOCKED(s390_idle.lock)
80};
81
82static int s390_idle_enter(void)
83{
84 struct s390_idle_data *idle;
85
86 idle = &__get_cpu_var(s390_idle);
87 spin_lock(&idle->lock);
88 idle->idle_count++;
89 idle->in_idle = 1;
90 idle->idle_enter = get_clock();
91 spin_unlock(&idle->lock);
92 vtime_stop_cpu_timer();
93 return NOTIFY_OK;
94}
95
96void s390_idle_leave(void)
97{
98 struct s390_idle_data *idle;
99
100 vtime_start_cpu_timer();
101 idle = &__get_cpu_var(s390_idle);
102 spin_lock(&idle->lock);
103 idle->idle_time += get_clock() - idle->idle_enter;
104 idle->in_idle = 0;
105 spin_unlock(&idle->lock);
106}
107
108extern void s390_handle_mcck(void); 78extern void s390_handle_mcck(void);
109/* 79/*
110 * The idle loop on a S390... 80 * The idle loop on a S390...
@@ -117,10 +87,6 @@ static void default_idle(void)
117 local_irq_enable(); 87 local_irq_enable();
118 return; 88 return;
119 } 89 }
120 if (s390_idle_enter() == NOTIFY_BAD) {
121 local_irq_enable();
122 return;
123 }
124#ifdef CONFIG_HOTPLUG_CPU 90#ifdef CONFIG_HOTPLUG_CPU
125 if (cpu_is_offline(smp_processor_id())) { 91 if (cpu_is_offline(smp_processor_id())) {
126 preempt_enable_no_resched(); 92 preempt_enable_no_resched();
@@ -130,7 +96,6 @@ static void default_idle(void)
130 local_mcck_disable(); 96 local_mcck_disable();
131 if (test_thread_flag(TIF_MCCK_PENDING)) { 97 if (test_thread_flag(TIF_MCCK_PENDING)) {
132 local_mcck_enable(); 98 local_mcck_enable();
133 s390_idle_leave();
134 local_irq_enable(); 99 local_irq_enable();
135 s390_handle_mcck(); 100 s390_handle_mcck();
136 return; 101 return;
@@ -138,9 +103,9 @@ static void default_idle(void)
138 trace_hardirqs_on(); 103 trace_hardirqs_on();
139 /* Don't trace preempt off for idle. */ 104 /* Don't trace preempt off for idle. */
140 stop_critical_timings(); 105 stop_critical_timings();
141 /* Wait for external, I/O or machine check interrupt. */ 106 /* Stop virtual timer and halt the cpu. */
142 __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT | 107 vtime_stop_cpu();
143 PSW_MASK_IO | PSW_MASK_EXT); 108 /* Reenable preemption tracer. */
144 start_critical_timings(); 109 start_critical_timings();
145} 110}
146 111
diff --git a/arch/s390/kernel/s390_ext.c b/arch/s390/kernel/s390_ext.c
index e019b419efc6..a0d2d55d7fb3 100644
--- a/arch/s390/kernel/s390_ext.c
+++ b/arch/s390/kernel/s390_ext.c
@@ -119,8 +119,8 @@ void do_extint(struct pt_regs *regs, unsigned short code)
119 struct pt_regs *old_regs; 119 struct pt_regs *old_regs;
120 120
121 old_regs = set_irq_regs(regs); 121 old_regs = set_irq_regs(regs);
122 irq_enter();
123 s390_idle_check(); 122 s390_idle_check();
123 irq_enter();
124 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator) 124 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator)
125 /* Serve timer interrupts first. */ 125 /* Serve timer interrupts first. */
126 clock_comparator_work(); 126 clock_comparator_work();
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index b7a1efd5522c..d825f4950e4e 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -427,6 +427,8 @@ setup_lowcore(void)
427 /* enable extended save area */ 427 /* enable extended save area */
428 __ctl_set_bit(14, 29); 428 __ctl_set_bit(14, 29);
429 } 429 }
430#else
431 lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0];
430#endif 432#endif
431 set_prefix((u32)(unsigned long) lc); 433 set_prefix((u32)(unsigned long) lc);
432} 434}
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 3ed5c7a83c6c..9c0ccb532a45 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -47,6 +47,7 @@
47#include <asm/lowcore.h> 47#include <asm/lowcore.h>
48#include <asm/sclp.h> 48#include <asm/sclp.h>
49#include <asm/cpu.h> 49#include <asm/cpu.h>
50#include <asm/vdso.h>
50#include "entry.h" 51#include "entry.h"
51 52
52/* 53/*
@@ -500,6 +501,9 @@ static int __cpuinit smp_alloc_lowcore(int cpu)
500 goto out; 501 goto out;
501 lowcore->extended_save_area_addr = (u32) save_area; 502 lowcore->extended_save_area_addr = (u32) save_area;
502 } 503 }
504#else
505 if (vdso_alloc_per_cpu(cpu, lowcore))
506 goto out;
503#endif 507#endif
504 lowcore_ptr[cpu] = lowcore; 508 lowcore_ptr[cpu] = lowcore;
505 return 0; 509 return 0;
@@ -522,6 +526,8 @@ static void smp_free_lowcore(int cpu)
522#ifndef CONFIG_64BIT 526#ifndef CONFIG_64BIT
523 if (MACHINE_HAS_IEEE) 527 if (MACHINE_HAS_IEEE)
524 free_page((unsigned long) lowcore->extended_save_area_addr); 528 free_page((unsigned long) lowcore->extended_save_area_addr);
529#else
530 vdso_free_per_cpu(cpu, lowcore);
525#endif 531#endif
526 free_page(lowcore->panic_stack - PAGE_SIZE); 532 free_page(lowcore->panic_stack - PAGE_SIZE);
527 free_pages(lowcore->async_stack - ASYNC_SIZE, ASYNC_ORDER); 533 free_pages(lowcore->async_stack - ASYNC_SIZE, ASYNC_ORDER);
@@ -664,6 +670,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
664 lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, lc_order); 670 lowcore = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, lc_order);
665 panic_stack = __get_free_page(GFP_KERNEL); 671 panic_stack = __get_free_page(GFP_KERNEL);
666 async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER); 672 async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
673 BUG_ON(!lowcore || !panic_stack || !async_stack);
667#ifndef CONFIG_64BIT 674#ifndef CONFIG_64BIT
668 if (MACHINE_HAS_IEEE) 675 if (MACHINE_HAS_IEEE)
669 save_area = get_zeroed_page(GFP_KERNEL); 676 save_area = get_zeroed_page(GFP_KERNEL);
@@ -677,6 +684,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
677#ifndef CONFIG_64BIT 684#ifndef CONFIG_64BIT
678 if (MACHINE_HAS_IEEE) 685 if (MACHINE_HAS_IEEE)
679 lowcore->extended_save_area_addr = (u32) save_area; 686 lowcore->extended_save_area_addr = (u32) save_area;
687#else
688 BUG_ON(vdso_alloc_per_cpu(smp_processor_id(), lowcore));
680#endif 689#endif
681 set_prefix((u32)(unsigned long) lowcore); 690 set_prefix((u32)(unsigned long) lowcore);
682 local_mcck_enable(); 691 local_mcck_enable();
@@ -845,9 +854,11 @@ static ssize_t show_idle_count(struct sys_device *dev,
845 unsigned long long idle_count; 854 unsigned long long idle_count;
846 855
847 idle = &per_cpu(s390_idle, dev->id); 856 idle = &per_cpu(s390_idle, dev->id);
848 spin_lock_irq(&idle->lock); 857 spin_lock(&idle->lock);
849 idle_count = idle->idle_count; 858 idle_count = idle->idle_count;
850 spin_unlock_irq(&idle->lock); 859 if (idle->idle_enter)
860 idle_count++;
861 spin_unlock(&idle->lock);
851 return sprintf(buf, "%llu\n", idle_count); 862 return sprintf(buf, "%llu\n", idle_count);
852} 863}
853static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL); 864static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL);
@@ -856,18 +867,17 @@ static ssize_t show_idle_time(struct sys_device *dev,
856 struct sysdev_attribute *attr, char *buf) 867 struct sysdev_attribute *attr, char *buf)
857{ 868{
858 struct s390_idle_data *idle; 869 struct s390_idle_data *idle;
859 unsigned long long new_time; 870 unsigned long long now, idle_time, idle_enter;
860 871
861 idle = &per_cpu(s390_idle, dev->id); 872 idle = &per_cpu(s390_idle, dev->id);
862 spin_lock_irq(&idle->lock); 873 spin_lock(&idle->lock);
863 if (idle->in_idle) { 874 now = get_clock();
864 new_time = get_clock(); 875 idle_time = idle->idle_time;
865 idle->idle_time += new_time - idle->idle_enter; 876 idle_enter = idle->idle_enter;
866 idle->idle_enter = new_time; 877 if (idle_enter != 0ULL && idle_enter < now)
867 } 878 idle_time += now - idle_enter;
868 new_time = idle->idle_time; 879 spin_unlock(&idle->lock);
869 spin_unlock_irq(&idle->lock); 880 return sprintf(buf, "%llu\n", idle_time >> 12);
870 return sprintf(buf, "%llu\n", new_time >> 12);
871} 881}
872static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL); 882static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL);
873 883
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 90e9ba11eba1..cc362c9ea8f1 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -97,6 +97,11 @@ cpumask_t cpu_coregroup_map(unsigned int cpu)
97 return mask; 97 return mask;
98} 98}
99 99
100const struct cpumask *cpu_coregroup_mask(unsigned int cpu)
101{
102 return &cpu_core_map[cpu];
103}
104
100static void add_cpus_to_core(struct tl_cpu *tl_cpu, struct core_info *core) 105static void add_cpus_to_core(struct tl_cpu *tl_cpu, struct core_info *core)
101{ 106{
102 unsigned int cpu; 107 unsigned int cpu;
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 10a6ccef4412..25a6a82f1c02 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -31,9 +31,6 @@
31#include <asm/sections.h> 31#include <asm/sections.h>
32#include <asm/vdso.h> 32#include <asm/vdso.h>
33 33
34/* Max supported size for symbol names */
35#define MAX_SYMNAME 64
36
37#if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT) 34#if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
38extern char vdso32_start, vdso32_end; 35extern char vdso32_start, vdso32_end;
39static void *vdso32_kbase = &vdso32_start; 36static void *vdso32_kbase = &vdso32_start;
@@ -71,6 +68,119 @@ static union {
71struct vdso_data *vdso_data = &vdso_data_store.data; 68struct vdso_data *vdso_data = &vdso_data_store.data;
72 69
73/* 70/*
71 * Setup vdso data page.
72 */
73static void vdso_init_data(struct vdso_data *vd)
74{
75 unsigned int facility_list;
76
77 facility_list = stfl();
78 vd->ectg_available = switch_amode && (facility_list & 1);
79}
80
81#ifdef CONFIG_64BIT
82/*
83 * Setup per cpu vdso data page.
84 */
85static void vdso_init_per_cpu_data(int cpu, struct vdso_per_cpu_data *vpcd)
86{
87}
88
89/*
90 * Allocate/free per cpu vdso data.
91 */
92#ifdef CONFIG_64BIT
93#define SEGMENT_ORDER 2
94#else
95#define SEGMENT_ORDER 1
96#endif
97
98int vdso_alloc_per_cpu(int cpu, struct _lowcore *lowcore)
99{
100 unsigned long segment_table, page_table, page_frame;
101 u32 *psal, *aste;
102 int i;
103
104 lowcore->vdso_per_cpu_data = __LC_PASTE;
105
106 if (!switch_amode || !vdso_enabled)
107 return 0;
108
109 segment_table = __get_free_pages(GFP_KERNEL, SEGMENT_ORDER);
110 page_table = get_zeroed_page(GFP_KERNEL | GFP_DMA);
111 page_frame = get_zeroed_page(GFP_KERNEL);
112 if (!segment_table || !page_table || !page_frame)
113 goto out;
114
115 clear_table((unsigned long *) segment_table, _SEGMENT_ENTRY_EMPTY,
116 PAGE_SIZE << SEGMENT_ORDER);
117 clear_table((unsigned long *) page_table, _PAGE_TYPE_EMPTY,
118 256*sizeof(unsigned long));
119
120 *(unsigned long *) segment_table = _SEGMENT_ENTRY + page_table;
121 *(unsigned long *) page_table = _PAGE_RO + page_frame;
122
123 psal = (u32 *) (page_table + 256*sizeof(unsigned long));
124 aste = psal + 32;
125
126 for (i = 4; i < 32; i += 4)
127 psal[i] = 0x80000000;
128
129 lowcore->paste[4] = (u32)(addr_t) psal;
130 psal[0] = 0x20000000;
131 psal[2] = (u32)(addr_t) aste;
132 *(unsigned long *) (aste + 2) = segment_table +
133 _ASCE_TABLE_LENGTH + _ASCE_USER_BITS + _ASCE_TYPE_SEGMENT;
134 aste[4] = (u32)(addr_t) psal;
135 lowcore->vdso_per_cpu_data = page_frame;
136
137 vdso_init_per_cpu_data(cpu, (struct vdso_per_cpu_data *) page_frame);
138 return 0;
139
140out:
141 free_page(page_frame);
142 free_page(page_table);
143 free_pages(segment_table, SEGMENT_ORDER);
144 return -ENOMEM;
145}
146
147#ifdef CONFIG_HOTPLUG_CPU
148void vdso_free_per_cpu(int cpu, struct _lowcore *lowcore)
149{
150 unsigned long segment_table, page_table, page_frame;
151 u32 *psal, *aste;
152
153 if (!switch_amode || !vdso_enabled)
154 return;
155
156 psal = (u32 *)(addr_t) lowcore->paste[4];
157 aste = (u32 *)(addr_t) psal[2];
158 segment_table = *(unsigned long *)(aste + 2) & PAGE_MASK;
159 page_table = *(unsigned long *) segment_table;
160 page_frame = *(unsigned long *) page_table;
161
162 free_page(page_frame);
163 free_page(page_table);
164 free_pages(segment_table, SEGMENT_ORDER);
165}
166#endif /* CONFIG_HOTPLUG_CPU */
167
168static void __vdso_init_cr5(void *dummy)
169{
170 unsigned long cr5;
171
172 cr5 = offsetof(struct _lowcore, paste);
173 __ctl_load(cr5, 5, 5);
174}
175
176static void vdso_init_cr5(void)
177{
178 if (switch_amode && vdso_enabled)
179 on_each_cpu(__vdso_init_cr5, NULL, 1);
180}
181#endif /* CONFIG_64BIT */
182
183/*
74 * This is called from binfmt_elf, we create the special vma for the 184 * This is called from binfmt_elf, we create the special vma for the
75 * vDSO and insert it into the mm struct tree 185 * vDSO and insert it into the mm struct tree
76 */ 186 */
@@ -172,6 +282,9 @@ static int __init vdso_init(void)
172{ 282{
173 int i; 283 int i;
174 284
285 if (!vdso_enabled)
286 return 0;
287 vdso_init_data(vdso_data);
175#if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT) 288#if defined(CONFIG_32BIT) || defined(CONFIG_COMPAT)
176 /* Calculate the size of the 32 bit vDSO */ 289 /* Calculate the size of the 32 bit vDSO */
177 vdso32_pages = ((&vdso32_end - &vdso32_start 290 vdso32_pages = ((&vdso32_end - &vdso32_start
@@ -208,6 +321,10 @@ static int __init vdso_init(void)
208 } 321 }
209 vdso64_pagelist[vdso64_pages - 1] = virt_to_page(vdso_data); 322 vdso64_pagelist[vdso64_pages - 1] = virt_to_page(vdso_data);
210 vdso64_pagelist[vdso64_pages] = NULL; 323 vdso64_pagelist[vdso64_pages] = NULL;
324#ifndef CONFIG_SMP
325 BUG_ON(vdso_alloc_per_cpu(0, S390_lowcore));
326#endif
327 vdso_init_cr5();
211#endif /* CONFIG_64BIT */ 328#endif /* CONFIG_64BIT */
212 329
213 get_page(virt_to_page(vdso_data)); 330 get_page(virt_to_page(vdso_data));
diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S
index 488e31a3c0e7..9ce8caafdb4e 100644
--- a/arch/s390/kernel/vdso64/clock_getres.S
+++ b/arch/s390/kernel/vdso64/clock_getres.S
@@ -22,7 +22,12 @@ __kernel_clock_getres:
22 cghi %r2,CLOCK_REALTIME 22 cghi %r2,CLOCK_REALTIME
23 je 0f 23 je 0f
24 cghi %r2,CLOCK_MONOTONIC 24 cghi %r2,CLOCK_MONOTONIC
25 je 0f
26 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */
25 jne 2f 27 jne 2f
28 larl %r5,_vdso_data
29 icm %r0,15,__LC_ECTG_OK(%r5)
30 jz 2f
260: ltgr %r3,%r3 310: ltgr %r3,%r3
27 jz 1f /* res == NULL */ 32 jz 1f /* res == NULL */
28 larl %r1,3f 33 larl %r1,3f
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
index 738a410b7eb2..79dbfee831ec 100644
--- a/arch/s390/kernel/vdso64/clock_gettime.S
+++ b/arch/s390/kernel/vdso64/clock_gettime.S
@@ -22,8 +22,10 @@ __kernel_clock_gettime:
22 larl %r5,_vdso_data 22 larl %r5,_vdso_data
23 cghi %r2,CLOCK_REALTIME 23 cghi %r2,CLOCK_REALTIME
24 je 4f 24 je 4f
25 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */
26 je 9f
25 cghi %r2,CLOCK_MONOTONIC 27 cghi %r2,CLOCK_MONOTONIC
26 jne 9f 28 jne 12f
27 29
28 /* CLOCK_MONOTONIC */ 30 /* CLOCK_MONOTONIC */
29 ltgr %r3,%r3 31 ltgr %r3,%r3
@@ -42,7 +44,7 @@ __kernel_clock_gettime:
42 alg %r0,__VDSO_WTOM_SEC(%r5) 44 alg %r0,__VDSO_WTOM_SEC(%r5)
43 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ 45 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
44 jne 0b 46 jne 0b
45 larl %r5,10f 47 larl %r5,13f
461: clg %r1,0(%r5) 481: clg %r1,0(%r5)
47 jl 2f 49 jl 2f
48 slg %r1,0(%r5) 50 slg %r1,0(%r5)
@@ -68,7 +70,7 @@ __kernel_clock_gettime:
68 lg %r0,__VDSO_XTIME_SEC(%r5) 70 lg %r0,__VDSO_XTIME_SEC(%r5)
69 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ 71 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
70 jne 5b 72 jne 5b
71 larl %r5,10f 73 larl %r5,13f
726: clg %r1,0(%r5) 746: clg %r1,0(%r5)
73 jl 7f 75 jl 7f
74 slg %r1,0(%r5) 76 slg %r1,0(%r5)
@@ -79,11 +81,38 @@ __kernel_clock_gettime:
798: lghi %r2,0 818: lghi %r2,0
80 br %r14 82 br %r14
81 83
84 /* CLOCK_THREAD_CPUTIME_ID for this thread */
859: icm %r0,15,__VDSO_ECTG_OK(%r5)
86 jz 12f
87 ear %r2,%a4
88 llilh %r4,0x0100
89 sar %a4,%r4
90 lghi %r4,0
91 sacf 512 /* Magic ectg instruction */
92 .insn ssf,0xc80100000000,__VDSO_ECTG_BASE(4),__VDSO_ECTG_USER(4),4
93 sacf 0
94 sar %a4,%r2
95 algr %r1,%r0 /* r1 = cputime as TOD value */
96 mghi %r1,1000 /* convert to nanoseconds */
97 srlg %r1,%r1,12 /* r1 = cputime in nanosec */
98 lgr %r4,%r1
99 larl %r5,13f
100 srlg %r1,%r1,9 /* divide by 1000000000 */
101 mlg %r0,8(%r5)
102 srlg %r0,%r0,11 /* r0 = tv_sec */
103 stg %r0,0(%r3)
104 msg %r0,0(%r5) /* calculate tv_nsec */
105 slgr %r4,%r0 /* r4 = tv_nsec */
106 stg %r4,8(%r3)
107 lghi %r2,0
108 br %r14
109
82 /* Fallback to system call */ 110 /* Fallback to system call */
839: lghi %r1,__NR_clock_gettime 11112: lghi %r1,__NR_clock_gettime
84 svc 0 112 svc 0
85 br %r14 113 br %r14
86 114
8710: .quad 1000000000 11513: .quad 1000000000
11614: .quad 19342813113834067
88 .cfi_endproc 117 .cfi_endproc
89 .size __kernel_clock_gettime,.-__kernel_clock_gettime 118 .size __kernel_clock_gettime,.-__kernel_clock_gettime
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 75a6e62ea973..2fb36e462194 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -23,19 +23,43 @@
23#include <asm/s390_ext.h> 23#include <asm/s390_ext.h>
24#include <asm/timer.h> 24#include <asm/timer.h>
25#include <asm/irq_regs.h> 25#include <asm/irq_regs.h>
26#include <asm/cpu.h>
26 27
27static ext_int_info_t ext_int_info_timer; 28static ext_int_info_t ext_int_info_timer;
29
28static DEFINE_PER_CPU(struct vtimer_queue, virt_cpu_timer); 30static DEFINE_PER_CPU(struct vtimer_queue, virt_cpu_timer);
29 31
32DEFINE_PER_CPU(struct s390_idle_data, s390_idle) = {
33 .lock = __SPIN_LOCK_UNLOCKED(s390_idle.lock)
34};
35
36static inline __u64 get_vtimer(void)
37{
38 __u64 timer;
39
40 asm volatile("STPT %0" : "=m" (timer));
41 return timer;
42}
43
44static inline void set_vtimer(__u64 expires)
45{
46 __u64 timer;
47
48 asm volatile (" STPT %0\n" /* Store current cpu timer value */
49 " SPT %1" /* Set new value immediatly afterwards */
50 : "=m" (timer) : "m" (expires) );
51 S390_lowcore.system_timer += S390_lowcore.last_update_timer - timer;
52 S390_lowcore.last_update_timer = expires;
53}
54
30/* 55/*
31 * Update process times based on virtual cpu times stored by entry.S 56 * Update process times based on virtual cpu times stored by entry.S
32 * to the lowcore fields user_timer, system_timer & steal_clock. 57 * to the lowcore fields user_timer, system_timer & steal_clock.
33 */ 58 */
34void account_process_tick(struct task_struct *tsk, int user_tick) 59static void do_account_vtime(struct task_struct *tsk, int hardirq_offset)
35{ 60{
36 cputime_t cputime; 61 struct thread_info *ti = task_thread_info(tsk);
37 __u64 timer, clock; 62 __u64 timer, clock, user, system, steal;
38 int rcu_user_flag;
39 63
40 timer = S390_lowcore.last_update_timer; 64 timer = S390_lowcore.last_update_timer;
41 clock = S390_lowcore.last_update_clock; 65 clock = S390_lowcore.last_update_clock;
@@ -44,50 +68,41 @@ void account_process_tick(struct task_struct *tsk, int user_tick)
44 : "=m" (S390_lowcore.last_update_timer), 68 : "=m" (S390_lowcore.last_update_timer),
45 "=m" (S390_lowcore.last_update_clock) ); 69 "=m" (S390_lowcore.last_update_clock) );
46 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer; 70 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
47 S390_lowcore.steal_clock += S390_lowcore.last_update_clock - clock; 71 S390_lowcore.steal_timer += S390_lowcore.last_update_clock - clock;
48 72
49 cputime = S390_lowcore.user_timer >> 12; 73 user = S390_lowcore.user_timer - ti->user_timer;
50 rcu_user_flag = cputime != 0; 74 S390_lowcore.steal_timer -= user;
51 S390_lowcore.user_timer -= cputime << 12; 75 ti->user_timer = S390_lowcore.user_timer;
52 S390_lowcore.steal_clock -= cputime << 12; 76 account_user_time(tsk, user, user);
53 account_user_time(tsk, cputime); 77
54 78 system = S390_lowcore.system_timer - ti->system_timer;
55 cputime = S390_lowcore.system_timer >> 12; 79 S390_lowcore.steal_timer -= system;
56 S390_lowcore.system_timer -= cputime << 12; 80 ti->system_timer = S390_lowcore.system_timer;
57 S390_lowcore.steal_clock -= cputime << 12; 81 account_system_time(tsk, hardirq_offset, system, system);
58 account_system_time(tsk, HARDIRQ_OFFSET, cputime); 82
59 83 steal = S390_lowcore.steal_timer;
60 cputime = S390_lowcore.steal_clock; 84 if ((s64) steal > 0) {
61 if ((__s64) cputime > 0) { 85 S390_lowcore.steal_timer = 0;
62 cputime >>= 12; 86 account_steal_time(steal);
63 S390_lowcore.steal_clock -= cputime << 12;
64 account_steal_time(tsk, cputime);
65 } 87 }
66} 88}
67 89
68/* 90void account_vtime(struct task_struct *prev, struct task_struct *next)
69 * Update process times based on virtual cpu times stored by entry.S
70 * to the lowcore fields user_timer, system_timer & steal_clock.
71 */
72void account_vtime(struct task_struct *tsk)
73{ 91{
74 cputime_t cputime; 92 struct thread_info *ti;
75 __u64 timer; 93
76 94 do_account_vtime(prev, 0);
77 timer = S390_lowcore.last_update_timer; 95 ti = task_thread_info(prev);
78 asm volatile (" STPT %0" /* Store current cpu timer value */ 96 ti->user_timer = S390_lowcore.user_timer;
79 : "=m" (S390_lowcore.last_update_timer) ); 97 ti->system_timer = S390_lowcore.system_timer;
80 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer; 98 ti = task_thread_info(next);
81 99 S390_lowcore.user_timer = ti->user_timer;
82 cputime = S390_lowcore.user_timer >> 12; 100 S390_lowcore.system_timer = ti->system_timer;
83 S390_lowcore.user_timer -= cputime << 12; 101}
84 S390_lowcore.steal_clock -= cputime << 12;
85 account_user_time(tsk, cputime);
86 102
87 cputime = S390_lowcore.system_timer >> 12; 103void account_process_tick(struct task_struct *tsk, int user_tick)
88 S390_lowcore.system_timer -= cputime << 12; 104{
89 S390_lowcore.steal_clock -= cputime << 12; 105 do_account_vtime(tsk, HARDIRQ_OFFSET);
90 account_system_time(tsk, 0, cputime);
91} 106}
92 107
93/* 108/*
@@ -96,80 +111,131 @@ void account_vtime(struct task_struct *tsk)
96 */ 111 */
97void account_system_vtime(struct task_struct *tsk) 112void account_system_vtime(struct task_struct *tsk)
98{ 113{
99 cputime_t cputime; 114 struct thread_info *ti = task_thread_info(tsk);
100 __u64 timer; 115 __u64 timer, system;
101 116
102 timer = S390_lowcore.last_update_timer; 117 timer = S390_lowcore.last_update_timer;
103 asm volatile (" STPT %0" /* Store current cpu timer value */ 118 S390_lowcore.last_update_timer = get_vtimer();
104 : "=m" (S390_lowcore.last_update_timer) );
105 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer; 119 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
106 120
107 cputime = S390_lowcore.system_timer >> 12; 121 system = S390_lowcore.system_timer - ti->system_timer;
108 S390_lowcore.system_timer -= cputime << 12; 122 S390_lowcore.steal_timer -= system;
109 S390_lowcore.steal_clock -= cputime << 12; 123 ti->system_timer = S390_lowcore.system_timer;
110 account_system_time(tsk, 0, cputime); 124 account_system_time(tsk, 0, system, system);
111} 125}
112EXPORT_SYMBOL_GPL(account_system_vtime); 126EXPORT_SYMBOL_GPL(account_system_vtime);
113 127
114static inline void set_vtimer(__u64 expires) 128void vtime_start_cpu(void)
115{
116 __u64 timer;
117
118 asm volatile (" STPT %0\n" /* Store current cpu timer value */
119 " SPT %1" /* Set new value immediatly afterwards */
120 : "=m" (timer) : "m" (expires) );
121 S390_lowcore.system_timer += S390_lowcore.last_update_timer - timer;
122 S390_lowcore.last_update_timer = expires;
123
124 /* store expire time for this CPU timer */
125 __get_cpu_var(virt_cpu_timer).to_expire = expires;
126}
127
128void vtime_start_cpu_timer(void)
129{ 129{
130 struct vtimer_queue *vt_list; 130 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
131 131 struct vtimer_queue *vq = &__get_cpu_var(virt_cpu_timer);
132 vt_list = &__get_cpu_var(virt_cpu_timer); 132 __u64 idle_time, expires;
133 133
134 /* CPU timer interrupt is pending, don't reprogramm it */ 134 /* Account time spent with enabled wait psw loaded as idle time. */
135 if (vt_list->idle & 1LL<<63) 135 idle_time = S390_lowcore.int_clock - idle->idle_enter;
136 return; 136 account_idle_time(idle_time);
137 S390_lowcore.last_update_clock = S390_lowcore.int_clock;
138
139 /* Account system time spent going idle. */
140 S390_lowcore.system_timer += S390_lowcore.last_update_timer - vq->idle;
141 S390_lowcore.last_update_timer = S390_lowcore.async_enter_timer;
142
143 /* Restart vtime CPU timer */
144 if (vq->do_spt) {
145 /* Program old expire value but first save progress. */
146 expires = vq->idle - S390_lowcore.async_enter_timer;
147 expires += get_vtimer();
148 set_vtimer(expires);
149 } else {
150 /* Don't account the CPU timer delta while the cpu was idle. */
151 vq->elapsed -= vq->idle - S390_lowcore.async_enter_timer;
152 }
137 153
138 if (!list_empty(&vt_list->list)) 154 spin_lock(&idle->lock);
139 set_vtimer(vt_list->idle); 155 idle->idle_time += idle_time;
156 idle->idle_enter = 0ULL;
157 idle->idle_count++;
158 spin_unlock(&idle->lock);
140} 159}
141 160
142void vtime_stop_cpu_timer(void) 161void vtime_stop_cpu(void)
143{ 162{
144 struct vtimer_queue *vt_list; 163 struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
145 164 struct vtimer_queue *vq = &__get_cpu_var(virt_cpu_timer);
146 vt_list = &__get_cpu_var(virt_cpu_timer); 165 psw_t psw;
147 166
148 /* nothing to do */ 167 /* Wait for external, I/O or machine check interrupt. */
149 if (list_empty(&vt_list->list)) { 168 psw.mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_IO | PSW_MASK_EXT;
150 vt_list->idle = VTIMER_MAX_SLICE; 169
151 goto fire; 170 /* Check if the CPU timer needs to be reprogrammed. */
171 if (vq->do_spt) {
172 __u64 vmax = VTIMER_MAX_SLICE;
173 /*
174 * The inline assembly is equivalent to
175 * vq->idle = get_cpu_timer();
176 * set_cpu_timer(VTIMER_MAX_SLICE);
177 * idle->idle_enter = get_clock();
178 * __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT |
179 * PSW_MASK_IO | PSW_MASK_EXT);
180 * The difference is that the inline assembly makes sure that
181 * the last three instruction are stpt, stck and lpsw in that
182 * order. This is done to increase the precision.
183 */
184 asm volatile(
185#ifndef CONFIG_64BIT
186 " basr 1,0\n"
187 "0: ahi 1,1f-0b\n"
188 " st 1,4(%2)\n"
189#else /* CONFIG_64BIT */
190 " larl 1,1f\n"
191 " stg 1,8(%2)\n"
192#endif /* CONFIG_64BIT */
193 " stpt 0(%4)\n"
194 " spt 0(%5)\n"
195 " stck 0(%3)\n"
196#ifndef CONFIG_64BIT
197 " lpsw 0(%2)\n"
198#else /* CONFIG_64BIT */
199 " lpswe 0(%2)\n"
200#endif /* CONFIG_64BIT */
201 "1:"
202 : "=m" (idle->idle_enter), "=m" (vq->idle)
203 : "a" (&psw), "a" (&idle->idle_enter),
204 "a" (&vq->idle), "a" (&vmax), "m" (vmax), "m" (psw)
205 : "memory", "cc", "1");
206 } else {
207 /*
208 * The inline assembly is equivalent to
209 * vq->idle = get_cpu_timer();
210 * idle->idle_enter = get_clock();
211 * __load_psw_mask(psw_kernel_bits | PSW_MASK_WAIT |
212 * PSW_MASK_IO | PSW_MASK_EXT);
213 * The difference is that the inline assembly makes sure that
214 * the last three instruction are stpt, stck and lpsw in that
215 * order. This is done to increase the precision.
216 */
217 asm volatile(
218#ifndef CONFIG_64BIT
219 " basr 1,0\n"
220 "0: ahi 1,1f-0b\n"
221 " st 1,4(%2)\n"
222#else /* CONFIG_64BIT */
223 " larl 1,1f\n"
224 " stg 1,8(%2)\n"
225#endif /* CONFIG_64BIT */
226 " stpt 0(%4)\n"
227 " stck 0(%3)\n"
228#ifndef CONFIG_64BIT
229 " lpsw 0(%2)\n"
230#else /* CONFIG_64BIT */
231 " lpswe 0(%2)\n"
232#endif /* CONFIG_64BIT */
233 "1:"
234 : "=m" (idle->idle_enter), "=m" (vq->idle)
235 : "a" (&psw), "a" (&idle->idle_enter),
236 "a" (&vq->idle), "m" (psw)
237 : "memory", "cc", "1");
152 } 238 }
153
154 /* store the actual expire value */
155 asm volatile ("STPT %0" : "=m" (vt_list->idle));
156
157 /*
158 * If the CPU timer is negative we don't reprogramm
159 * it because we will get instantly an interrupt.
160 */
161 if (vt_list->idle & 1LL<<63)
162 return;
163
164 vt_list->offset += vt_list->to_expire - vt_list->idle;
165
166 /*
167 * We cannot halt the CPU timer, we just write a value that
168 * nearly never expires (only after 71 years) and re-write
169 * the stored expire value if we continue the timer
170 */
171 fire:
172 set_vtimer(VTIMER_MAX_SLICE);
173} 239}
174 240
175/* 241/*
@@ -195,30 +261,23 @@ static void list_add_sorted(struct vtimer_list *timer, struct list_head *head)
195 */ 261 */
196static void do_callbacks(struct list_head *cb_list) 262static void do_callbacks(struct list_head *cb_list)
197{ 263{
198 struct vtimer_queue *vt_list; 264 struct vtimer_queue *vq;
199 struct vtimer_list *event, *tmp; 265 struct vtimer_list *event, *tmp;
200 void (*fn)(unsigned long);
201 unsigned long data;
202 266
203 if (list_empty(cb_list)) 267 if (list_empty(cb_list))
204 return; 268 return;
205 269
206 vt_list = &__get_cpu_var(virt_cpu_timer); 270 vq = &__get_cpu_var(virt_cpu_timer);
207 271
208 list_for_each_entry_safe(event, tmp, cb_list, entry) { 272 list_for_each_entry_safe(event, tmp, cb_list, entry) {
209 fn = event->function; 273 list_del_init(&event->entry);
210 data = event->data; 274 (event->function)(event->data);
211 fn(data); 275 if (event->interval) {
212 276 /* Recharge interval timer */
213 if (!event->interval) 277 event->expires = event->interval + vq->elapsed;
214 /* delete one shot timer */ 278 spin_lock(&vq->lock);
215 list_del_init(&event->entry); 279 list_add_sorted(event, &vq->list);
216 else { 280 spin_unlock(&vq->lock);
217 /* move interval timer back to list */
218 spin_lock(&vt_list->lock);
219 list_del_init(&event->entry);
220 list_add_sorted(event, &vt_list->list);
221 spin_unlock(&vt_list->lock);
222 } 281 }
223 } 282 }
224} 283}
@@ -228,64 +287,57 @@ static void do_callbacks(struct list_head *cb_list)
228 */ 287 */
229static void do_cpu_timer_interrupt(__u16 error_code) 288static void do_cpu_timer_interrupt(__u16 error_code)
230{ 289{
231 __u64 next, delta; 290 struct vtimer_queue *vq;
232 struct vtimer_queue *vt_list;
233 struct vtimer_list *event, *tmp; 291 struct vtimer_list *event, *tmp;
234 struct list_head *ptr; 292 struct list_head cb_list; /* the callback queue */
235 /* the callback queue */ 293 __u64 elapsed, next;
236 struct list_head cb_list;
237 294
238 INIT_LIST_HEAD(&cb_list); 295 INIT_LIST_HEAD(&cb_list);
239 vt_list = &__get_cpu_var(virt_cpu_timer); 296 vq = &__get_cpu_var(virt_cpu_timer);
240 297
241 /* walk timer list, fire all expired events */ 298 /* walk timer list, fire all expired events */
242 spin_lock(&vt_list->lock); 299 spin_lock(&vq->lock);
243 300
244 if (vt_list->to_expire < VTIMER_MAX_SLICE) 301 elapsed = vq->elapsed + (vq->timer - S390_lowcore.async_enter_timer);
245 vt_list->offset += vt_list->to_expire; 302 BUG_ON((s64) elapsed < 0);
246 303 vq->elapsed = 0;
247 list_for_each_entry_safe(event, tmp, &vt_list->list, entry) { 304 list_for_each_entry_safe(event, tmp, &vq->list, entry) {
248 if (event->expires > vt_list->offset) 305 if (event->expires < elapsed)
249 /* found first unexpired event, leave */ 306 /* move expired timer to the callback queue */
250 break; 307 list_move_tail(&event->entry, &cb_list);
251 308 else
252 /* re-charge interval timer, we have to add the offset */ 309 event->expires -= elapsed;
253 if (event->interval)
254 event->expires = event->interval + vt_list->offset;
255
256 /* move expired timer to the callback queue */
257 list_move_tail(&event->entry, &cb_list);
258 } 310 }
259 spin_unlock(&vt_list->lock); 311 spin_unlock(&vq->lock);
312
313 vq->do_spt = list_empty(&cb_list);
260 do_callbacks(&cb_list); 314 do_callbacks(&cb_list);
261 315
262 /* next event is first in list */ 316 /* next event is first in list */
263 spin_lock(&vt_list->lock); 317 next = VTIMER_MAX_SLICE;
264 if (!list_empty(&vt_list->list)) { 318 spin_lock(&vq->lock);
265 ptr = vt_list->list.next; 319 if (!list_empty(&vq->list)) {
266 event = list_entry(ptr, struct vtimer_list, entry); 320 event = list_first_entry(&vq->list, struct vtimer_list, entry);
267 next = event->expires - vt_list->offset; 321 next = event->expires;
268 322 } else
269 /* add the expired time from this interrupt handler 323 vq->do_spt = 0;
270 * and the callback functions 324 spin_unlock(&vq->lock);
271 */ 325 /*
272 asm volatile ("STPT %0" : "=m" (delta)); 326 * To improve precision add the time spent by the
273 delta = 0xffffffffffffffffLL - delta + 1; 327 * interrupt handler to the elapsed time.
274 vt_list->offset += delta; 328 * Note: CPU timer counts down and we got an interrupt,
275 next -= delta; 329 * the current content is negative
276 } else { 330 */
277 vt_list->offset = 0; 331 elapsed = S390_lowcore.async_enter_timer - get_vtimer();
278 next = VTIMER_MAX_SLICE; 332 set_vtimer(next - elapsed);
279 } 333 vq->timer = next - elapsed;
280 spin_unlock(&vt_list->lock); 334 vq->elapsed = elapsed;
281 set_vtimer(next);
282} 335}
283 336
284void init_virt_timer(struct vtimer_list *timer) 337void init_virt_timer(struct vtimer_list *timer)
285{ 338{
286 timer->function = NULL; 339 timer->function = NULL;
287 INIT_LIST_HEAD(&timer->entry); 340 INIT_LIST_HEAD(&timer->entry);
288 spin_lock_init(&timer->lock);
289} 341}
290EXPORT_SYMBOL(init_virt_timer); 342EXPORT_SYMBOL(init_virt_timer);
291 343
@@ -299,44 +351,40 @@ static inline int vtimer_pending(struct vtimer_list *timer)
299 */ 351 */
300static void internal_add_vtimer(struct vtimer_list *timer) 352static void internal_add_vtimer(struct vtimer_list *timer)
301{ 353{
354 struct vtimer_queue *vq;
302 unsigned long flags; 355 unsigned long flags;
303 __u64 done; 356 __u64 left, expires;
304 struct vtimer_list *event;
305 struct vtimer_queue *vt_list;
306 357
307 vt_list = &per_cpu(virt_cpu_timer, timer->cpu); 358 vq = &per_cpu(virt_cpu_timer, timer->cpu);
308 spin_lock_irqsave(&vt_list->lock, flags); 359 spin_lock_irqsave(&vq->lock, flags);
309 360
310 BUG_ON(timer->cpu != smp_processor_id()); 361 BUG_ON(timer->cpu != smp_processor_id());
311 362
312 /* if list is empty we only have to set the timer */ 363 if (list_empty(&vq->list)) {
313 if (list_empty(&vt_list->list)) { 364 /* First timer on this cpu, just program it. */
314 /* reset the offset, this may happen if the last timer was 365 list_add(&timer->entry, &vq->list);
315 * just deleted by mod_virt_timer and the interrupt 366 set_vtimer(timer->expires);
316 * didn't happen until here 367 vq->timer = timer->expires;
317 */ 368 vq->elapsed = 0;
318 vt_list->offset = 0; 369 } else {
319 goto fire; 370 /* Check progress of old timers. */
371 expires = timer->expires;
372 left = get_vtimer();
373 if (likely((s64) expires < (s64) left)) {
374 /* The new timer expires before the current timer. */
375 set_vtimer(expires);
376 vq->elapsed += vq->timer - left;
377 vq->timer = expires;
378 } else {
379 vq->elapsed += vq->timer - left;
380 vq->timer = left;
381 }
382 /* Insert new timer into per cpu list. */
383 timer->expires += vq->elapsed;
384 list_add_sorted(timer, &vq->list);
320 } 385 }
321 386
322 /* save progress */ 387 spin_unlock_irqrestore(&vq->lock, flags);
323 asm volatile ("STPT %0" : "=m" (done));
324
325 /* calculate completed work */
326 done = vt_list->to_expire - done + vt_list->offset;
327 vt_list->offset = 0;
328
329 list_for_each_entry(event, &vt_list->list, entry)
330 event->expires -= done;
331
332 fire:
333 list_add_sorted(timer, &vt_list->list);
334
335 /* get first element, which is the next vtimer slice */
336 event = list_entry(vt_list->list.next, struct vtimer_list, entry);
337
338 set_vtimer(event->expires);
339 spin_unlock_irqrestore(&vt_list->lock, flags);
340 /* release CPU acquired in prepare_vtimer or mod_virt_timer() */ 388 /* release CPU acquired in prepare_vtimer or mod_virt_timer() */
341 put_cpu(); 389 put_cpu();
342} 390}
@@ -381,14 +429,15 @@ EXPORT_SYMBOL(add_virt_timer_periodic);
381 * If we change a pending timer the function must be called on the CPU 429 * If we change a pending timer the function must be called on the CPU
382 * where the timer is running on, e.g. by smp_call_function_single() 430 * where the timer is running on, e.g. by smp_call_function_single()
383 * 431 *
384 * The original mod_timer adds the timer if it is not pending. For compatibility 432 * The original mod_timer adds the timer if it is not pending. For
385 * we do the same. The timer will be added on the current CPU as a oneshot timer. 433 * compatibility we do the same. The timer will be added on the current
434 * CPU as a oneshot timer.
386 * 435 *
387 * returns whether it has modified a pending timer (1) or not (0) 436 * returns whether it has modified a pending timer (1) or not (0)
388 */ 437 */
389int mod_virt_timer(struct vtimer_list *timer, __u64 expires) 438int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
390{ 439{
391 struct vtimer_queue *vt_list; 440 struct vtimer_queue *vq;
392 unsigned long flags; 441 unsigned long flags;
393 int cpu; 442 int cpu;
394 443
@@ -404,17 +453,17 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
404 return 1; 453 return 1;
405 454
406 cpu = get_cpu(); 455 cpu = get_cpu();
407 vt_list = &per_cpu(virt_cpu_timer, cpu); 456 vq = &per_cpu(virt_cpu_timer, cpu);
408 457
409 /* check if we run on the right CPU */ 458 /* check if we run on the right CPU */
410 BUG_ON(timer->cpu != cpu); 459 BUG_ON(timer->cpu != cpu);
411 460
412 /* disable interrupts before test if timer is pending */ 461 /* disable interrupts before test if timer is pending */
413 spin_lock_irqsave(&vt_list->lock, flags); 462 spin_lock_irqsave(&vq->lock, flags);
414 463
415 /* if timer isn't pending add it on the current CPU */ 464 /* if timer isn't pending add it on the current CPU */
416 if (!vtimer_pending(timer)) { 465 if (!vtimer_pending(timer)) {
417 spin_unlock_irqrestore(&vt_list->lock, flags); 466 spin_unlock_irqrestore(&vq->lock, flags);
418 /* we do not activate an interval timer with mod_virt_timer */ 467 /* we do not activate an interval timer with mod_virt_timer */
419 timer->interval = 0; 468 timer->interval = 0;
420 timer->expires = expires; 469 timer->expires = expires;
@@ -431,7 +480,7 @@ int mod_virt_timer(struct vtimer_list *timer, __u64 expires)
431 timer->interval = expires; 480 timer->interval = expires;
432 481
433 /* the timer can't expire anymore so we can release the lock */ 482 /* the timer can't expire anymore so we can release the lock */
434 spin_unlock_irqrestore(&vt_list->lock, flags); 483 spin_unlock_irqrestore(&vq->lock, flags);
435 internal_add_vtimer(timer); 484 internal_add_vtimer(timer);
436 return 1; 485 return 1;
437} 486}
@@ -445,25 +494,19 @@ EXPORT_SYMBOL(mod_virt_timer);
445int del_virt_timer(struct vtimer_list *timer) 494int del_virt_timer(struct vtimer_list *timer)
446{ 495{
447 unsigned long flags; 496 unsigned long flags;
448 struct vtimer_queue *vt_list; 497 struct vtimer_queue *vq;
449 498
450 /* check if timer is pending */ 499 /* check if timer is pending */
451 if (!vtimer_pending(timer)) 500 if (!vtimer_pending(timer))
452 return 0; 501 return 0;
453 502
454 vt_list = &per_cpu(virt_cpu_timer, timer->cpu); 503 vq = &per_cpu(virt_cpu_timer, timer->cpu);
455 spin_lock_irqsave(&vt_list->lock, flags); 504 spin_lock_irqsave(&vq->lock, flags);
456 505
457 /* we don't interrupt a running timer, just let it expire! */ 506 /* we don't interrupt a running timer, just let it expire! */
458 list_del_init(&timer->entry); 507 list_del_init(&timer->entry);
459 508
460 /* last timer removed */ 509 spin_unlock_irqrestore(&vq->lock, flags);
461 if (list_empty(&vt_list->list)) {
462 vt_list->to_expire = 0;
463 vt_list->offset = 0;
464 }
465
466 spin_unlock_irqrestore(&vt_list->lock, flags);
467 return 1; 510 return 1;
468} 511}
469EXPORT_SYMBOL(del_virt_timer); 512EXPORT_SYMBOL(del_virt_timer);
@@ -473,24 +516,19 @@ EXPORT_SYMBOL(del_virt_timer);
473 */ 516 */
474void init_cpu_vtimer(void) 517void init_cpu_vtimer(void)
475{ 518{
476 struct vtimer_queue *vt_list; 519 struct vtimer_queue *vq;
477 520
478 /* kick the virtual timer */ 521 /* kick the virtual timer */
479 S390_lowcore.exit_timer = VTIMER_MAX_SLICE;
480 S390_lowcore.last_update_timer = VTIMER_MAX_SLICE;
481 asm volatile ("SPT %0" : : "m" (S390_lowcore.last_update_timer));
482 asm volatile ("STCK %0" : "=m" (S390_lowcore.last_update_clock)); 522 asm volatile ("STCK %0" : "=m" (S390_lowcore.last_update_clock));
523 asm volatile ("STPT %0" : "=m" (S390_lowcore.last_update_timer));
524
525 /* initialize per cpu vtimer structure */
526 vq = &__get_cpu_var(virt_cpu_timer);
527 INIT_LIST_HEAD(&vq->list);
528 spin_lock_init(&vq->lock);
483 529
484 /* enable cpu timer interrupts */ 530 /* enable cpu timer interrupts */
485 __ctl_set_bit(0,10); 531 __ctl_set_bit(0,10);
486
487 vt_list = &__get_cpu_var(virt_cpu_timer);
488 INIT_LIST_HEAD(&vt_list->list);
489 spin_lock_init(&vt_list->lock);
490 vt_list->to_expire = 0;
491 vt_list->offset = 0;
492 vt_list->idle = 0;
493
494} 532}
495 533
496void __init vtime_init(void) 534void __init vtime_init(void)
diff --git a/arch/sh/include/asm/topology.h b/arch/sh/include/asm/topology.h
index 279d9cc4a007..066f0fba590e 100644
--- a/arch/sh/include/asm/topology.h
+++ b/arch/sh/include/asm/topology.h
@@ -32,6 +32,7 @@
32#define parent_node(node) ((void)(node),0) 32#define parent_node(node) ((void)(node),0)
33 33
34#define node_to_cpumask(node) ((void)node, cpu_online_map) 34#define node_to_cpumask(node) ((void)node, cpu_online_map)
35#define cpumask_of_node(node) ((void)node, cpu_online_mask)
35#define node_to_first_cpu(node) ((void)(node),0) 36#define node_to_first_cpu(node) ((void)(node),0)
36 37
37#define pcibus_to_node(bus) ((void)(bus), -1) 38#define pcibus_to_node(bus) ((void)(bus), -1)
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 0a94d9c9cde1..de58c02633b4 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -4,6 +4,17 @@
4 4
5mainmenu "Linux/SPARC Kernel Configuration" 5mainmenu "Linux/SPARC Kernel Configuration"
6 6
7config 64BIT
8 bool "64-bit kernel" if ARCH = "sparc"
9 default ARCH = "sparc64"
10 help
11 SPARC is a family of RISC microprocessors designed and marketed by
12 Sun Microsystems, incorporated. They are very widely found in Sun
13 workstations and clones.
14
15 Say yes to build a 64-bit kernel - formerly known as sparc64
16 Say no to build a 32-bit kernel - formerly known as sparc
17
7config SPARC 18config SPARC
8 bool 19 bool
9 default y 20 default y
@@ -15,22 +26,11 @@ config SPARC
15 select RTC_CLASS 26 select RTC_CLASS
16 select RTC_DRV_M48T59 27 select RTC_DRV_M48T59
17 28
18# Identify this as a Sparc32 build
19config SPARC32 29config SPARC32
20 bool 30 def_bool !64BIT
21 default y if ARCH = "sparc"
22 help
23 SPARC is a family of RISC microprocessors designed and marketed by
24 Sun Microsystems, incorporated. They are very widely found in Sun
25 workstations and clones. This port covers the original 32-bit SPARC;
26 it is old and stable and usually considered one of the "big three"
27 along with the Intel and Alpha ports. The UltraLinux project
28 maintains both the SPARC32 and SPARC64 ports; its web page is
29 available at <http://www.ultralinux.org/>.
30 31
31config SPARC64 32config SPARC64
32 bool 33 def_bool 64BIT
33 default y if ARCH = "sparc64"
34 select ARCH_SUPPORTS_MSI 34 select ARCH_SUPPORTS_MSI
35 select HAVE_FUNCTION_TRACER 35 select HAVE_FUNCTION_TRACER
36 select HAVE_KRETPROBES 36 select HAVE_KRETPROBES
@@ -53,9 +53,6 @@ config BITS
53 default 32 if SPARC32 53 default 32 if SPARC32
54 default 64 if SPARC64 54 default 64 if SPARC64
55 55
56config 64BIT
57 def_bool y if SPARC64
58
59config GENERIC_TIME 56config GENERIC_TIME
60 bool 57 bool
61 default y if SPARC64 58 default y if SPARC64
@@ -188,14 +185,6 @@ config ARCH_MAY_HAVE_PC_FDC
188 bool 185 bool
189 default y 186 default y
190 187
191config ARCH_HAS_ILOG2_U32
192 bool
193 default n
194
195config ARCH_HAS_ILOG2_U64
196 bool
197 default n
198
199config EMULATED_CMPXCHG 188config EMULATED_CMPXCHG
200 bool 189 bool
201 default y if SPARC32 190 default y if SPARC32
@@ -442,26 +431,6 @@ config SERIAL_CONSOLE
442endmenu 431endmenu
443 432
444menu "Bus options (PCI etc.)" 433menu "Bus options (PCI etc.)"
445config ISA
446 bool
447 help
448 ISA is found on Espresso only and is not supported currently.
449
450config ISAPNP
451 bool
452 help
453 ISAPNP is not supported
454
455config EISA
456 bool
457 help
458 EISA is not supported.
459
460config MCA
461 bool
462 help
463 MCA is not supported.
464
465config SBUS 434config SBUS
466 bool 435 bool
467 default y 436 default y
diff --git a/arch/sparc/configs/sparc64_defconfig b/arch/sparc/configs/sparc64_defconfig
index 05d19a3e590f..cde19ae78f5a 100644
--- a/arch/sparc/configs/sparc64_defconfig
+++ b/arch/sparc/configs/sparc64_defconfig
@@ -1,27 +1,27 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28-rc4 3# Linux kernel version: 2.6.28
4# Mon Nov 10 12:35:09 2008 4# Fri Jan 2 18:14:26 2009
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
8CONFIG_ARCH_DEFCONFIG="arch/sparc/configs/sparc64_defconfig"
9CONFIG_BITS=64
10CONFIG_64BIT=y
8CONFIG_GENERIC_TIME=y 11CONFIG_GENERIC_TIME=y
9CONFIG_GENERIC_CMOS_UPDATE=y 12CONFIG_GENERIC_CMOS_UPDATE=y
10CONFIG_GENERIC_CLOCKEVENTS=y 13CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_64BIT=y
12CONFIG_MMU=y
13CONFIG_IOMMU_HELPER=y 14CONFIG_IOMMU_HELPER=y
14CONFIG_QUICKLIST=y 15CONFIG_QUICKLIST=y
15CONFIG_STACKTRACE_SUPPORT=y 16CONFIG_STACKTRACE_SUPPORT=y
16CONFIG_LOCKDEP_SUPPORT=y 17CONFIG_LOCKDEP_SUPPORT=y
17CONFIG_ARCH_MAY_HAVE_PC_FDC=y 18CONFIG_HAVE_LATENCYTOP_SUPPORT=y
18# CONFIG_ARCH_HAS_ILOG2_U32 is not set
19# CONFIG_ARCH_HAS_ILOG2_U64 is not set
20CONFIG_AUDIT_ARCH=y 19CONFIG_AUDIT_ARCH=y
21CONFIG_HAVE_SETUP_PER_CPU_AREA=y 20CONFIG_HAVE_SETUP_PER_CPU_AREA=y
21CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
22CONFIG_MMU=y
22CONFIG_ARCH_NO_VIRT_TO_BUS=y 23CONFIG_ARCH_NO_VIRT_TO_BUS=y
23CONFIG_OF=y 24CONFIG_OF=y
24CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
25CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 25CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
26 26
27# 27#
@@ -86,6 +86,7 @@ CONFIG_SLUB_DEBUG=y
86CONFIG_SLUB=y 86CONFIG_SLUB=y
87# CONFIG_SLOB is not set 87# CONFIG_SLOB is not set
88CONFIG_PROFILING=y 88CONFIG_PROFILING=y
89CONFIG_TRACEPOINTS=y
89# CONFIG_MARKERS is not set 90# CONFIG_MARKERS is not set
90CONFIG_OPROFILE=m 91CONFIG_OPROFILE=m
91CONFIG_HAVE_OPROFILE=y 92CONFIG_HAVE_OPROFILE=y
@@ -127,34 +128,40 @@ CONFIG_DEFAULT_AS=y
127# CONFIG_DEFAULT_NOOP is not set 128# CONFIG_DEFAULT_NOOP is not set
128CONFIG_DEFAULT_IOSCHED="anticipatory" 129CONFIG_DEFAULT_IOSCHED="anticipatory"
129CONFIG_CLASSIC_RCU=y 130CONFIG_CLASSIC_RCU=y
131# CONFIG_TREE_RCU is not set
132# CONFIG_PREEMPT_RCU is not set
133# CONFIG_TREE_RCU_TRACE is not set
134# CONFIG_PREEMPT_RCU_TRACE is not set
130# CONFIG_FREEZER is not set 135# CONFIG_FREEZER is not set
131 136
132# 137#
133# Processor type and features 138# Processor type and features
134# 139#
135CONFIG_SPARC64_PAGE_SIZE_8KB=y 140CONFIG_SMP=y
136# CONFIG_SPARC64_PAGE_SIZE_64KB is not set 141CONFIG_NR_CPUS=64
137CONFIG_SECCOMP=y
138CONFIG_HZ_100=y 142CONFIG_HZ_100=y
139# CONFIG_HZ_250 is not set 143# CONFIG_HZ_250 is not set
140# CONFIG_HZ_300 is not set 144# CONFIG_HZ_300 is not set
141# CONFIG_HZ_1000 is not set 145# CONFIG_HZ_1000 is not set
142CONFIG_HZ=100 146CONFIG_HZ=100
143CONFIG_SCHED_HRTICK=y 147CONFIG_SCHED_HRTICK=y
148CONFIG_RWSEM_XCHGADD_ALGORITHM=y
149CONFIG_GENERIC_FIND_NEXT_BIT=y
150CONFIG_GENERIC_HWEIGHT=y
151CONFIG_GENERIC_CALIBRATE_DELAY=y
152CONFIG_ARCH_MAY_HAVE_PC_FDC=y
153CONFIG_SPARC64_SMP=y
154CONFIG_SPARC64_PAGE_SIZE_8KB=y
155# CONFIG_SPARC64_PAGE_SIZE_64KB is not set
156CONFIG_SECCOMP=y
144CONFIG_HOTPLUG_CPU=y 157CONFIG_HOTPLUG_CPU=y
145CONFIG_GENERIC_HARDIRQS=y 158CONFIG_GENERIC_HARDIRQS=y
146CONFIG_TICK_ONESHOT=y 159CONFIG_TICK_ONESHOT=y
147CONFIG_NO_HZ=y 160CONFIG_NO_HZ=y
148CONFIG_HIGH_RES_TIMERS=y 161CONFIG_HIGH_RES_TIMERS=y
149CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 162CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
150CONFIG_SMP=y
151CONFIG_NR_CPUS=64
152# CONFIG_CPU_FREQ is not set 163# CONFIG_CPU_FREQ is not set
153CONFIG_US3_MC=y 164CONFIG_US3_MC=y
154CONFIG_RWSEM_XCHGADD_ALGORITHM=y
155CONFIG_GENERIC_FIND_NEXT_BIT=y
156CONFIG_GENERIC_HWEIGHT=y
157CONFIG_GENERIC_CALIBRATE_DELAY=y
158CONFIG_HUGETLB_PAGE_SIZE_4MB=y 165CONFIG_HUGETLB_PAGE_SIZE_4MB=y
159# CONFIG_HUGETLB_PAGE_SIZE_512K is not set 166# CONFIG_HUGETLB_PAGE_SIZE_512K is not set
160# CONFIG_HUGETLB_PAGE_SIZE_64K is not set 167# CONFIG_HUGETLB_PAGE_SIZE_64K is not set
@@ -183,10 +190,18 @@ CONFIG_PHYS_ADDR_T_64BIT=y
183CONFIG_ZONE_DMA_FLAG=0 190CONFIG_ZONE_DMA_FLAG=0
184CONFIG_NR_QUICK=1 191CONFIG_NR_QUICK=1
185CONFIG_UNEVICTABLE_LRU=y 192CONFIG_UNEVICTABLE_LRU=y
193CONFIG_SCHED_SMT=y
194CONFIG_SCHED_MC=y
195# CONFIG_PREEMPT_NONE is not set
196CONFIG_PREEMPT_VOLUNTARY=y
197# CONFIG_PREEMPT is not set
198# CONFIG_CMDLINE_BOOL is not set
199
200#
201# Bus options (PCI etc.)
202#
186CONFIG_SBUS=y 203CONFIG_SBUS=y
187CONFIG_SBUSCHAR=y 204CONFIG_SBUSCHAR=y
188CONFIG_SUN_AUXIO=y
189CONFIG_SUN_IO=y
190CONFIG_SUN_LDOMS=y 205CONFIG_SUN_LDOMS=y
191CONFIG_PCI=y 206CONFIG_PCI=y
192CONFIG_PCI_DOMAINS=y 207CONFIG_PCI_DOMAINS=y
@@ -195,7 +210,9 @@ CONFIG_ARCH_SUPPORTS_MSI=y
195CONFIG_PCI_MSI=y 210CONFIG_PCI_MSI=y
196# CONFIG_PCI_LEGACY is not set 211# CONFIG_PCI_LEGACY is not set
197# CONFIG_PCI_DEBUG is not set 212# CONFIG_PCI_DEBUG is not set
213# CONFIG_PCCARD is not set
198CONFIG_SUN_OPENPROMFS=m 214CONFIG_SUN_OPENPROMFS=m
215CONFIG_SPARC64_PCI=y
199 216
200# 217#
201# Executable file formats 218# Executable file formats
@@ -207,17 +224,13 @@ CONFIG_COMPAT_BINFMT_ELF=y
207CONFIG_BINFMT_MISC=m 224CONFIG_BINFMT_MISC=m
208CONFIG_COMPAT=y 225CONFIG_COMPAT=y
209CONFIG_SYSVIPC_COMPAT=y 226CONFIG_SYSVIPC_COMPAT=y
210CONFIG_SCHED_SMT=y
211CONFIG_SCHED_MC=y
212# CONFIG_PREEMPT_NONE is not set
213CONFIG_PREEMPT_VOLUNTARY=y
214# CONFIG_PREEMPT is not set
215# CONFIG_CMDLINE_BOOL is not set
216CONFIG_NET=y 227CONFIG_NET=y
217 228
218# 229#
219# Networking options 230# Networking options
220# 231#
232# CONFIG_NET_NS is not set
233CONFIG_COMPAT_NET_DEV_OPS=y
221CONFIG_PACKET=y 234CONFIG_PACKET=y
222CONFIG_PACKET_MMAP=y 235CONFIG_PACKET_MMAP=y
223CONFIG_UNIX=y 236CONFIG_UNIX=y
@@ -314,6 +327,7 @@ CONFIG_VLAN_8021Q=m
314# CONFIG_ECONET is not set 327# CONFIG_ECONET is not set
315# CONFIG_WAN_ROUTER is not set 328# CONFIG_WAN_ROUTER is not set
316# CONFIG_NET_SCHED is not set 329# CONFIG_NET_SCHED is not set
330# CONFIG_DCB is not set
317 331
318# 332#
319# Network testing 333# Network testing
@@ -330,8 +344,8 @@ CONFIG_WIRELESS=y
330# CONFIG_CFG80211 is not set 344# CONFIG_CFG80211 is not set
331CONFIG_WIRELESS_OLD_REGULATORY=y 345CONFIG_WIRELESS_OLD_REGULATORY=y
332# CONFIG_WIRELESS_EXT is not set 346# CONFIG_WIRELESS_EXT is not set
347# CONFIG_LIB80211 is not set
333# CONFIG_MAC80211 is not set 348# CONFIG_MAC80211 is not set
334# CONFIG_IEEE80211 is not set
335# CONFIG_RFKILL is not set 349# CONFIG_RFKILL is not set
336# CONFIG_NET_9P is not set 350# CONFIG_NET_9P is not set
337 351
@@ -378,8 +392,10 @@ CONFIG_MISC_DEVICES=y
378# CONFIG_EEPROM_93CX6 is not set 392# CONFIG_EEPROM_93CX6 is not set
379# CONFIG_SGI_IOC4 is not set 393# CONFIG_SGI_IOC4 is not set
380# CONFIG_TIFM_CORE is not set 394# CONFIG_TIFM_CORE is not set
395# CONFIG_ICS932S401 is not set
381# CONFIG_ENCLOSURE_SERVICES is not set 396# CONFIG_ENCLOSURE_SERVICES is not set
382# CONFIG_HP_ILO is not set 397# CONFIG_HP_ILO is not set
398# CONFIG_C2PORT is not set
383CONFIG_HAVE_IDE=y 399CONFIG_HAVE_IDE=y
384CONFIG_IDE=y 400CONFIG_IDE=y
385 401
@@ -387,6 +403,7 @@ CONFIG_IDE=y
387# Please see Documentation/ide/ide.txt for help/info on IDE drives 403# Please see Documentation/ide/ide.txt for help/info on IDE drives
388# 404#
389CONFIG_IDE_TIMINGS=y 405CONFIG_IDE_TIMINGS=y
406CONFIG_IDE_ATAPI=y
390# CONFIG_BLK_DEV_IDE_SATA is not set 407# CONFIG_BLK_DEV_IDE_SATA is not set
391CONFIG_IDE_GD=y 408CONFIG_IDE_GD=y
392CONFIG_IDE_GD_ATA=y 409CONFIG_IDE_GD_ATA=y
@@ -394,7 +411,6 @@ CONFIG_IDE_GD_ATA=y
394CONFIG_BLK_DEV_IDECD=y 411CONFIG_BLK_DEV_IDECD=y
395CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y 412CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
396# CONFIG_BLK_DEV_IDETAPE is not set 413# CONFIG_BLK_DEV_IDETAPE is not set
397# CONFIG_BLK_DEV_IDESCSI is not set
398# CONFIG_IDE_TASK_IOCTL is not set 414# CONFIG_IDE_TASK_IOCTL is not set
399CONFIG_IDE_PROC_FS=y 415CONFIG_IDE_PROC_FS=y
400 416
@@ -477,6 +493,7 @@ CONFIG_SCSI_FC_ATTRS=y
477# CONFIG_SCSI_SRP_ATTRS is not set 493# CONFIG_SCSI_SRP_ATTRS is not set
478CONFIG_SCSI_LOWLEVEL=y 494CONFIG_SCSI_LOWLEVEL=y
479# CONFIG_ISCSI_TCP is not set 495# CONFIG_ISCSI_TCP is not set
496# CONFIG_SCSI_CXGB3_ISCSI is not set
480# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 497# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
481# CONFIG_SCSI_3W_9XXX is not set 498# CONFIG_SCSI_3W_9XXX is not set
482# CONFIG_SCSI_ACARD is not set 499# CONFIG_SCSI_ACARD is not set
@@ -490,6 +507,8 @@ CONFIG_SCSI_LOWLEVEL=y
490# CONFIG_MEGARAID_LEGACY is not set 507# CONFIG_MEGARAID_LEGACY is not set
491# CONFIG_MEGARAID_SAS is not set 508# CONFIG_MEGARAID_SAS is not set
492# CONFIG_SCSI_HPTIOP is not set 509# CONFIG_SCSI_HPTIOP is not set
510# CONFIG_LIBFC is not set
511# CONFIG_FCOE is not set
493# CONFIG_SCSI_DMX3191D is not set 512# CONFIG_SCSI_DMX3191D is not set
494# CONFIG_SCSI_FUTURE_DOMAIN is not set 513# CONFIG_SCSI_FUTURE_DOMAIN is not set
495# CONFIG_SCSI_IPS is not set 514# CONFIG_SCSI_IPS is not set
@@ -564,6 +583,9 @@ CONFIG_PHYLIB=m
564# CONFIG_BROADCOM_PHY is not set 583# CONFIG_BROADCOM_PHY is not set
565# CONFIG_ICPLUS_PHY is not set 584# CONFIG_ICPLUS_PHY is not set
566# CONFIG_REALTEK_PHY is not set 585# CONFIG_REALTEK_PHY is not set
586# CONFIG_NATIONAL_PHY is not set
587# CONFIG_STE10XP is not set
588# CONFIG_LSI_ET1011C_PHY is not set
567# CONFIG_MDIO_BITBANG is not set 589# CONFIG_MDIO_BITBANG is not set
568CONFIG_NET_ETHERNET=y 590CONFIG_NET_ETHERNET=y
569CONFIG_MII=m 591CONFIG_MII=m
@@ -590,7 +612,6 @@ CONFIG_NET_PCI=y
590# CONFIG_ADAPTEC_STARFIRE is not set 612# CONFIG_ADAPTEC_STARFIRE is not set
591# CONFIG_B44 is not set 613# CONFIG_B44 is not set
592# CONFIG_FORCEDETH is not set 614# CONFIG_FORCEDETH is not set
593# CONFIG_EEPRO100 is not set
594# CONFIG_E100 is not set 615# CONFIG_E100 is not set
595# CONFIG_FEALNX is not set 616# CONFIG_FEALNX is not set
596# CONFIG_NATSEMI is not set 617# CONFIG_NATSEMI is not set
@@ -600,6 +621,7 @@ CONFIG_NET_PCI=y
600# CONFIG_R6040 is not set 621# CONFIG_R6040 is not set
601# CONFIG_SIS900 is not set 622# CONFIG_SIS900 is not set
602# CONFIG_EPIC100 is not set 623# CONFIG_EPIC100 is not set
624# CONFIG_SMSC9420 is not set
603# CONFIG_SUNDANCE is not set 625# CONFIG_SUNDANCE is not set
604# CONFIG_TLAN is not set 626# CONFIG_TLAN is not set
605# CONFIG_VIA_RHINE is not set 627# CONFIG_VIA_RHINE is not set
@@ -629,6 +651,7 @@ CONFIG_BNX2=m
629# CONFIG_JME is not set 651# CONFIG_JME is not set
630CONFIG_NETDEV_10000=y 652CONFIG_NETDEV_10000=y
631# CONFIG_CHELSIO_T1 is not set 653# CONFIG_CHELSIO_T1 is not set
654CONFIG_CHELSIO_T3_DEPENDS=y
632# CONFIG_CHELSIO_T3 is not set 655# CONFIG_CHELSIO_T3 is not set
633# CONFIG_ENIC is not set 656# CONFIG_ENIC is not set
634# CONFIG_IXGBE is not set 657# CONFIG_IXGBE is not set
@@ -778,6 +801,7 @@ CONFIG_SERIAL_CORE=y
778CONFIG_SERIAL_CORE_CONSOLE=y 801CONFIG_SERIAL_CORE_CONSOLE=y
779# CONFIG_SERIAL_JSM is not set 802# CONFIG_SERIAL_JSM is not set
780CONFIG_UNIX98_PTYS=y 803CONFIG_UNIX98_PTYS=y
804# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
781# CONFIG_LEGACY_PTYS is not set 805# CONFIG_LEGACY_PTYS is not set
782# CONFIG_IPMI_HANDLER is not set 806# CONFIG_IPMI_HANDLER is not set
783CONFIG_HW_RANDOM=m 807CONFIG_HW_RANDOM=m
@@ -870,6 +894,7 @@ CONFIG_HWMON=y
870# CONFIG_SENSORS_ADM1029 is not set 894# CONFIG_SENSORS_ADM1029 is not set
871# CONFIG_SENSORS_ADM1031 is not set 895# CONFIG_SENSORS_ADM1031 is not set
872# CONFIG_SENSORS_ADM9240 is not set 896# CONFIG_SENSORS_ADM9240 is not set
897# CONFIG_SENSORS_ADT7462 is not set
873# CONFIG_SENSORS_ADT7470 is not set 898# CONFIG_SENSORS_ADT7470 is not set
874# CONFIG_SENSORS_ADT7473 is not set 899# CONFIG_SENSORS_ADT7473 is not set
875# CONFIG_SENSORS_ATXP1 is not set 900# CONFIG_SENSORS_ATXP1 is not set
@@ -919,11 +944,11 @@ CONFIG_HWMON=y
919# CONFIG_THERMAL is not set 944# CONFIG_THERMAL is not set
920# CONFIG_THERMAL_HWMON is not set 945# CONFIG_THERMAL_HWMON is not set
921# CONFIG_WATCHDOG is not set 946# CONFIG_WATCHDOG is not set
947CONFIG_SSB_POSSIBLE=y
922 948
923# 949#
924# Sonics Silicon Backplane 950# Sonics Silicon Backplane
925# 951#
926CONFIG_SSB_POSSIBLE=y
927# CONFIG_SSB is not set 952# CONFIG_SSB is not set
928 953
929# 954#
@@ -1071,6 +1096,7 @@ CONFIG_SND_MIXER_OSS=m
1071CONFIG_SND_PCM_OSS=m 1096CONFIG_SND_PCM_OSS=m
1072CONFIG_SND_PCM_OSS_PLUGINS=y 1097CONFIG_SND_PCM_OSS_PLUGINS=y
1073CONFIG_SND_SEQUENCER_OSS=y 1098CONFIG_SND_SEQUENCER_OSS=y
1099# CONFIG_SND_HRTIMER is not set
1074# CONFIG_SND_DYNAMIC_MINORS is not set 1100# CONFIG_SND_DYNAMIC_MINORS is not set
1075CONFIG_SND_SUPPORT_OLD_API=y 1101CONFIG_SND_SUPPORT_OLD_API=y
1076CONFIG_SND_VERBOSE_PROCFS=y 1102CONFIG_SND_VERBOSE_PROCFS=y
@@ -1242,11 +1268,11 @@ CONFIG_USB_UHCI_HCD=m
1242# CONFIG_USB_TMC is not set 1268# CONFIG_USB_TMC is not set
1243 1269
1244# 1270#
1245# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1271# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
1246# 1272#
1247 1273
1248# 1274#
1249# may also be needed; see USB_STORAGE Help for more information 1275# see USB_STORAGE Help for more information
1250# 1276#
1251CONFIG_USB_STORAGE=m 1277CONFIG_USB_STORAGE=m
1252# CONFIG_USB_STORAGE_DEBUG is not set 1278# CONFIG_USB_STORAGE_DEBUG is not set
@@ -1337,6 +1363,7 @@ CONFIG_RTC_INTF_DEV=y
1337# CONFIG_RTC_DRV_M41T80 is not set 1363# CONFIG_RTC_DRV_M41T80 is not set
1338# CONFIG_RTC_DRV_S35390A is not set 1364# CONFIG_RTC_DRV_S35390A is not set
1339# CONFIG_RTC_DRV_FM3130 is not set 1365# CONFIG_RTC_DRV_FM3130 is not set
1366# CONFIG_RTC_DRV_RX8581 is not set
1340 1367
1341# 1368#
1342# SPI RTC drivers 1369# SPI RTC drivers
@@ -1365,7 +1392,6 @@ CONFIG_RTC_DRV_STARFIRE=y
1365# CONFIG_DMADEVICES is not set 1392# CONFIG_DMADEVICES is not set
1366# CONFIG_UIO is not set 1393# CONFIG_UIO is not set
1367# CONFIG_STAGING is not set 1394# CONFIG_STAGING is not set
1368CONFIG_STAGING_EXCLUDE_BUILD=y
1369 1395
1370# 1396#
1371# Misc Linux/SPARC drivers 1397# Misc Linux/SPARC drivers
@@ -1544,6 +1570,7 @@ CONFIG_SCHEDSTATS=y
1544# CONFIG_LOCK_STAT is not set 1570# CONFIG_LOCK_STAT is not set
1545# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1571# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1546# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1572# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1573CONFIG_STACKTRACE=y
1547# CONFIG_DEBUG_KOBJECT is not set 1574# CONFIG_DEBUG_KOBJECT is not set
1548CONFIG_DEBUG_BUGVERBOSE=y 1575CONFIG_DEBUG_BUGVERBOSE=y
1549# CONFIG_DEBUG_INFO is not set 1576# CONFIG_DEBUG_INFO is not set
@@ -1552,6 +1579,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
1552CONFIG_DEBUG_MEMORY_INIT=y 1579CONFIG_DEBUG_MEMORY_INIT=y
1553# CONFIG_DEBUG_LIST is not set 1580# CONFIG_DEBUG_LIST is not set
1554# CONFIG_DEBUG_SG is not set 1581# CONFIG_DEBUG_SG is not set
1582# CONFIG_DEBUG_NOTIFIERS is not set
1555# CONFIG_BOOT_PRINTK_DELAY is not set 1583# CONFIG_BOOT_PRINTK_DELAY is not set
1556# CONFIG_RCU_TORTURE_TEST is not set 1584# CONFIG_RCU_TORTURE_TEST is not set
1557# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1585# CONFIG_RCU_CPU_STALL_DETECTOR is not set
@@ -1560,8 +1588,12 @@ CONFIG_DEBUG_MEMORY_INIT=y
1560# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set 1588# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1561# CONFIG_LKDTM is not set 1589# CONFIG_LKDTM is not set
1562# CONFIG_FAULT_INJECTION is not set 1590# CONFIG_FAULT_INJECTION is not set
1591# CONFIG_LATENCYTOP is not set
1563CONFIG_SYSCTL_SYSCALL_CHECK=y 1592CONFIG_SYSCTL_SYSCALL_CHECK=y
1593CONFIG_NOP_TRACER=y
1564CONFIG_HAVE_FUNCTION_TRACER=y 1594CONFIG_HAVE_FUNCTION_TRACER=y
1595CONFIG_RING_BUFFER=y
1596CONFIG_TRACING=y
1565 1597
1566# 1598#
1567# Tracers 1599# Tracers
@@ -1571,7 +1603,9 @@ CONFIG_HAVE_FUNCTION_TRACER=y
1571# CONFIG_SCHED_TRACER is not set 1603# CONFIG_SCHED_TRACER is not set
1572# CONFIG_CONTEXT_SWITCH_TRACER is not set 1604# CONFIG_CONTEXT_SWITCH_TRACER is not set
1573# CONFIG_BOOT_TRACER is not set 1605# CONFIG_BOOT_TRACER is not set
1606# CONFIG_TRACE_BRANCH_PROFILING is not set
1574# CONFIG_STACK_TRACER is not set 1607# CONFIG_STACK_TRACER is not set
1608# CONFIG_FTRACE_STARTUP_TEST is not set
1575# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 1609# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
1576# CONFIG_SAMPLES is not set 1610# CONFIG_SAMPLES is not set
1577CONFIG_HAVE_ARCH_KGDB=y 1611CONFIG_HAVE_ARCH_KGDB=y
@@ -1600,11 +1634,16 @@ CONFIG_CRYPTO=y
1600# 1634#
1601# CONFIG_CRYPTO_FIPS is not set 1635# CONFIG_CRYPTO_FIPS is not set
1602CONFIG_CRYPTO_ALGAPI=y 1636CONFIG_CRYPTO_ALGAPI=y
1637CONFIG_CRYPTO_ALGAPI2=y
1603CONFIG_CRYPTO_AEAD=y 1638CONFIG_CRYPTO_AEAD=y
1639CONFIG_CRYPTO_AEAD2=y
1604CONFIG_CRYPTO_BLKCIPHER=y 1640CONFIG_CRYPTO_BLKCIPHER=y
1641CONFIG_CRYPTO_BLKCIPHER2=y
1605CONFIG_CRYPTO_HASH=y 1642CONFIG_CRYPTO_HASH=y
1606CONFIG_CRYPTO_RNG=y 1643CONFIG_CRYPTO_HASH2=y
1644CONFIG_CRYPTO_RNG2=y
1607CONFIG_CRYPTO_MANAGER=y 1645CONFIG_CRYPTO_MANAGER=y
1646CONFIG_CRYPTO_MANAGER2=y
1608CONFIG_CRYPTO_GF128MUL=m 1647CONFIG_CRYPTO_GF128MUL=m
1609CONFIG_CRYPTO_NULL=m 1648CONFIG_CRYPTO_NULL=m
1610# CONFIG_CRYPTO_CRYPTD is not set 1649# CONFIG_CRYPTO_CRYPTD is not set
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index 89c260aab45c..deeb0fba8029 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -1,21 +1,6 @@
1# User exported sparc header files 1# User exported sparc header files
2include include/asm-generic/Kbuild.asm 2include include/asm-generic/Kbuild.asm
3 3
4header-y += ipcbuf_32.h
5header-y += ipcbuf_64.h
6header-y += posix_types_32.h
7header-y += posix_types_64.h
8header-y += ptrace_32.h
9header-y += ptrace_64.h
10header-y += sigcontext_32.h
11header-y += sigcontext_64.h
12header-y += siginfo_32.h
13header-y += siginfo_64.h
14header-y += signal_32.h
15header-y += signal_64.h
16header-y += stat_32.h
17header-y += stat_64.h
18
19header-y += apc.h 4header-y += apc.h
20header-y += asi.h 5header-y += asi.h
21header-y += display7seg.h 6header-y += display7seg.h
@@ -23,16 +8,11 @@ header-y += envctrl.h
23header-y += fbio.h 8header-y += fbio.h
24header-y += jsflash.h 9header-y += jsflash.h
25header-y += openprom.h 10header-y += openprom.h
26header-y += openprom_32.h
27header-y += openprom_64.h
28header-y += openpromio.h 11header-y += openpromio.h
29header-y += perfctr.h 12header-y += perfctr.h
30header-y += psrcompat.h 13header-y += psrcompat.h
31header-y += psr.h 14header-y += psr.h
32header-y += pstate.h 15header-y += pstate.h
33header-y += reg.h
34header-y += reg_32.h
35header-y += reg_64.h
36header-y += traps.h 16header-y += traps.h
37header-y += uctx.h 17header-y += uctx.h
38header-y += utrap.h 18header-y += utrap.h
diff --git a/arch/sparc/include/asm/byteorder.h b/arch/sparc/include/asm/byteorder.h
index 5a70f137f1f7..738414b26558 100644
--- a/arch/sparc/include/asm/byteorder.h
+++ b/arch/sparc/include/asm/byteorder.h
@@ -1,16 +1,12 @@
1#ifndef _SPARC_BYTEORDER_H 1#ifndef _SPARC_BYTEORDER_H
2#define _SPARC_BYTEORDER_H 2#define _SPARC_BYTEORDER_H
3 3
4#include <asm/types.h> 4#include <linux/types.h>
5#include <asm/asi.h> 5#include <asm/asi.h>
6 6
7#define __BIG_ENDIAN 7#define __BIG_ENDIAN
8 8
9#ifdef CONFIG_SPARC32 9#if defined(__sparc__) && defined(__arch64__)
10#define __SWAB_64_THRU_32__
11#endif
12
13#ifdef CONFIG_SPARC64
14static inline __u16 __arch_swab16p(const __u16 *addr) 10static inline __u16 __arch_swab16p(const __u16 *addr)
15{ 11{
16 __u16 ret; 12 __u16 ret;
@@ -44,7 +40,9 @@ static inline __u64 __arch_swab64p(const __u64 *addr)
44} 40}
45#define __arch_swab64p __arch_swab64p 41#define __arch_swab64p __arch_swab64p
46 42
47#endif /* CONFIG_SPARC64 */ 43#else
44#define __SWAB_64_THRU_32__
45#endif /* defined(__sparc__) && defined(__arch64__) */
48 46
49#include <linux/byteorder.h> 47#include <linux/byteorder.h>
50 48
diff --git a/arch/sparc/include/asm/ipcbuf.h b/arch/sparc/include/asm/ipcbuf.h
index 17d6ef7b23a4..66013b4fe10d 100644
--- a/arch/sparc/include/asm/ipcbuf.h
+++ b/arch/sparc/include/asm/ipcbuf.h
@@ -1,8 +1,32 @@
1#ifndef ___ASM_SPARC_IPCBUF_H 1#ifndef __SPARC_IPCBUF_H
2#define ___ASM_SPARC_IPCBUF_H 2#define __SPARC_IPCBUF_H
3#if defined(__sparc__) && defined(__arch64__) 3
4#include <asm/ipcbuf_64.h> 4/*
5#else 5 * The ipc64_perm structure for sparc/sparc64 architecture.
6#include <asm/ipcbuf_32.h> 6 * Note extra padding because this structure is passed back and forth
7#endif 7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit seq
11 * - on sparc for 32 bit mode (it is 32 bit on sparc64)
12 * - 2 miscellaneous 64-bit values
13 */
14
15struct ipc64_perm
16{
17 __kernel_key_t key;
18 __kernel_uid_t uid;
19 __kernel_gid_t gid;
20 __kernel_uid_t cuid;
21 __kernel_gid_t cgid;
22#ifndef __arch64__
23 unsigned short __pad0;
8#endif 24#endif
25 __kernel_mode_t mode;
26 unsigned short __pad1;
27 unsigned short seq;
28 unsigned long long __unused1;
29 unsigned long long __unused2;
30};
31
32#endif /* __SPARC_IPCBUF_H */
diff --git a/arch/sparc/include/asm/ipcbuf_32.h b/arch/sparc/include/asm/ipcbuf_32.h
deleted file mode 100644
index 6387209518f2..000000000000
--- a/arch/sparc/include/asm/ipcbuf_32.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef _SPARC_IPCBUF_H
2#define _SPARC_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for sparc architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit mode
11 * - 32-bit seq
12 * - 2 miscellaneous 64-bit values (so that this structure matches
13 * sparc64 ipc64_perm)
14 */
15
16struct ipc64_perm
17{
18 __kernel_key_t key;
19 __kernel_uid32_t uid;
20 __kernel_gid32_t gid;
21 __kernel_uid32_t cuid;
22 __kernel_gid32_t cgid;
23 unsigned short __pad1;
24 __kernel_mode_t mode;
25 unsigned short __pad2;
26 unsigned short seq;
27 unsigned long long __unused1;
28 unsigned long long __unused2;
29};
30
31#endif /* _SPARC_IPCBUF_H */
diff --git a/arch/sparc/include/asm/ipcbuf_64.h b/arch/sparc/include/asm/ipcbuf_64.h
deleted file mode 100644
index a44b855b98db..000000000000
--- a/arch/sparc/include/asm/ipcbuf_64.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef _SPARC64_IPCBUF_H
2#define _SPARC64_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for sparc64 architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit seq
11 * - 2 miscellaneous 64-bit values
12 */
13
14struct ipc64_perm
15{
16 __kernel_key_t key;
17 __kernel_uid_t uid;
18 __kernel_gid_t gid;
19 __kernel_uid_t cuid;
20 __kernel_gid_t cgid;
21 __kernel_mode_t mode;
22 unsigned short __pad1;
23 unsigned short seq;
24 unsigned long __unused1;
25 unsigned long __unused2;
26};
27
28#endif /* _SPARC64_IPCBUF_H */
diff --git a/arch/sparc/include/asm/jsflash.h b/arch/sparc/include/asm/jsflash.h
index 3457f29bd73b..0717d9e39d2d 100644
--- a/arch/sparc/include/asm/jsflash.h
+++ b/arch/sparc/include/asm/jsflash.h
@@ -8,7 +8,7 @@
8#define _SPARC_JSFLASH_H 8#define _SPARC_JSFLASH_H
9 9
10#ifndef _SPARC_TYPES_H 10#ifndef _SPARC_TYPES_H
11#include <asm/types.h> 11#include <linux/types.h>
12#endif 12#endif
13 13
14/* 14/*
diff --git a/arch/sparc/include/asm/openprom.h b/arch/sparc/include/asm/openprom.h
index aaeae905ed3f..963e1a45c35f 100644
--- a/arch/sparc/include/asm/openprom.h
+++ b/arch/sparc/include/asm/openprom.h
@@ -1,8 +1,277 @@
1#ifndef ___ASM_SPARC_OPENPROM_H 1#ifndef __SPARC_OPENPROM_H
2#define ___ASM_SPARC_OPENPROM_H 2#define __SPARC_OPENPROM_H
3
4/* openprom.h: Prom structures and defines for access to the OPENBOOT
5 * prom routines and data areas.
6 *
7 * Copyright (C) 1995,1996 David S. Miller (davem@caip.rutgers.edu)
8 */
9
10/* Empirical constants... */
11#define LINUX_OPPROM_MAGIC 0x10010407
12
13#ifndef __ASSEMBLY__
14/* V0 prom device operations. */
15struct linux_dev_v0_funcs {
16 int (*v0_devopen)(char *device_str);
17 int (*v0_devclose)(int dev_desc);
18 int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
19 int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
20 int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
21 int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
22 int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
23 int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
24 int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
25};
26
27/* V2 and later prom device operations. */
28struct linux_dev_v2_funcs {
29 int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
30 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
31 void (*v2_dumb_mem_free)(char *va, unsigned sz);
32
33 /* To map devices into virtual I/O space. */
34 char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
35 void (*v2_dumb_munmap)(char *virta, unsigned size);
36
37 int (*v2_dev_open)(char *devpath);
38 void (*v2_dev_close)(int d);
39 int (*v2_dev_read)(int d, char *buf, int nbytes);
40 int (*v2_dev_write)(int d, char *buf, int nbytes);
41 int (*v2_dev_seek)(int d, int hi, int lo);
42
43 /* Never issued (multistage load support) */
44 void (*v2_wheee2)(void);
45 void (*v2_wheee3)(void);
46};
47
48struct linux_mlist_v0 {
49 struct linux_mlist_v0 *theres_more;
50 unsigned int start_adr;
51 unsigned num_bytes;
52};
53
54struct linux_mem_v0 {
55 struct linux_mlist_v0 **v0_totphys;
56 struct linux_mlist_v0 **v0_prommap;
57 struct linux_mlist_v0 **v0_available; /* What we can use */
58};
59
60/* Arguments sent to the kernel from the boot prompt. */
61struct linux_arguments_v0 {
62 char *argv[8];
63 char args[100];
64 char boot_dev[2];
65 int boot_dev_ctrl;
66 int boot_dev_unit;
67 int dev_partition;
68 char *kernel_file_name;
69 void *aieee1; /* XXX */
70};
71
72/* V2 and up boot things. */
73struct linux_bootargs_v2 {
74 char **bootpath;
75 char **bootargs;
76 int *fd_stdin;
77 int *fd_stdout;
78};
79
80/* The top level PROM vector. */
81struct linux_romvec {
82 /* Version numbers. */
83 unsigned int pv_magic_cookie;
84 unsigned int pv_romvers;
85 unsigned int pv_plugin_revision;
86 unsigned int pv_printrev;
87
88 /* Version 0 memory descriptors. */
89 struct linux_mem_v0 pv_v0mem;
90
91 /* Node operations. */
92 struct linux_nodeops *pv_nodeops;
93
94 char **pv_bootstr;
95 struct linux_dev_v0_funcs pv_v0devops;
96
97 char *pv_stdin;
98 char *pv_stdout;
99#define PROMDEV_KBD 0 /* input from keyboard */
100#define PROMDEV_SCREEN 0 /* output to screen */
101#define PROMDEV_TTYA 1 /* in/out to ttya */
102#define PROMDEV_TTYB 2 /* in/out to ttyb */
103
104 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
105 int (*pv_getchar)(void);
106 void (*pv_putchar)(int ch);
107
108 /* Non-blocking variants. */
109 int (*pv_nbgetchar)(void);
110 int (*pv_nbputchar)(int ch);
111
112 void (*pv_putstr)(char *str, int len);
113
114 /* Miscellany. */
115 void (*pv_reboot)(char *bootstr);
116 void (*pv_printf)(__const__ char *fmt, ...);
117 void (*pv_abort)(void);
118 __volatile__ int *pv_ticks;
119 void (*pv_halt)(void);
120 void (**pv_synchook)(void);
121
122 /* Evaluate a forth string, not different proto for V0 and V2->up. */
123 union {
124 void (*v0_eval)(int len, char *str);
125 void (*v2_eval)(char *str);
126 } pv_fortheval;
127
128 struct linux_arguments_v0 **pv_v0bootargs;
129
130 /* Get ether address. */
131 unsigned int (*pv_enaddr)(int d, char *enaddr);
132
133 struct linux_bootargs_v2 pv_v2bootargs;
134 struct linux_dev_v2_funcs pv_v2devops;
135
136 int filler[15];
137
138 /* This one is sun4c/sun4 only. */
139 void (*pv_setctxt)(int ctxt, char *va, int pmeg);
140
141 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
142 * No joke. Calling these when there is only one cpu probably
143 * crashes the machine, have to test this. :-)
144 */
145
146 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
147 * 'thiscontext' executing at address 'prog_counter'
148 */
149 int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
150 int thiscontext, char *prog_counter);
151
152 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
153 * until a resume cpu call is made.
154 */
155 int (*v3_cpustop)(unsigned int whichcpu);
156
157 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
158 * resume cpu call is made.
159 */
160 int (*v3_cpuidle)(unsigned int whichcpu);
161
162 /* v3_cpuresume() will resume processor 'whichcpu' executing
163 * starting with whatever 'pc' and 'npc' were left at the
164 * last 'idle' or 'stop' call.
165 */
166 int (*v3_cpuresume)(unsigned int whichcpu);
167};
168
169/* Routines for traversing the prom device tree. */
170struct linux_nodeops {
171 int (*no_nextnode)(int node);
172 int (*no_child)(int node);
173 int (*no_proplen)(int node, const char *name);
174 int (*no_getprop)(int node, const char *name, char *val);
175 int (*no_setprop)(int node, const char *name, char *val, int len);
176 char * (*no_nextprop)(int node, char *name);
177};
178
179/* More fun PROM structures for device probing. */
3#if defined(__sparc__) && defined(__arch64__) 180#if defined(__sparc__) && defined(__arch64__)
4#include <asm/openprom_64.h> 181#define PROMREG_MAX 24
182#define PROMVADDR_MAX 16
183#define PROMINTR_MAX 32
5#else 184#else
6#include <asm/openprom_32.h> 185#define PROMREG_MAX 16
186#define PROMVADDR_MAX 16
187#define PROMINTR_MAX 15
7#endif 188#endif
189
190struct linux_prom_registers {
191 unsigned int which_io; /* hi part of physical address */
192 unsigned int phys_addr; /* The physical address of this register */
193 unsigned int reg_size; /* How many bytes does this register take up? */
194};
195
196struct linux_prom64_registers {
197 unsigned long phys_addr;
198 unsigned long reg_size;
199};
200
201struct linux_prom_irqs {
202 int pri; /* IRQ priority */
203 int vector; /* This is foobar, what does it do? */
204};
205
206/* Element of the "ranges" vector */
207struct linux_prom_ranges {
208 unsigned int ot_child_space;
209 unsigned int ot_child_base; /* Bus feels this */
210 unsigned int ot_parent_space;
211 unsigned int ot_parent_base; /* CPU looks from here */
212 unsigned int or_size;
213};
214
215/*
216 * Ranges and reg properties are a bit different for PCI.
217 */
218#if defined(__sparc__) && defined(__arch64__)
219struct linux_prom_pci_registers {
220 unsigned int phys_hi;
221 unsigned int phys_mid;
222 unsigned int phys_lo;
223
224 unsigned int size_hi;
225 unsigned int size_lo;
226};
227#else
228struct linux_prom_pci_registers {
229 /*
230 * We don't know what information this field contain.
231 * We guess, PCI device function is in bits 15:8
232 * So, ...
233 */
234 unsigned int which_io; /* Let it be which_io */
235
236 unsigned int phys_hi;
237 unsigned int phys_lo;
238
239 unsigned int size_hi;
240 unsigned int size_lo;
241};
242
8#endif 243#endif
244
245struct linux_prom_pci_ranges {
246 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
247 unsigned int child_phys_mid;
248 unsigned int child_phys_lo;
249
250 unsigned int parent_phys_hi;
251 unsigned int parent_phys_lo;
252
253 unsigned int size_hi;
254 unsigned int size_lo;
255};
256
257struct linux_prom_pci_intmap {
258 unsigned int phys_hi;
259 unsigned int phys_mid;
260 unsigned int phys_lo;
261
262 unsigned int interrupt;
263
264 int cnode;
265 unsigned int cinterrupt;
266};
267
268struct linux_prom_pci_intmask {
269 unsigned int phys_hi;
270 unsigned int phys_mid;
271 unsigned int phys_lo;
272 unsigned int interrupt;
273};
274
275#endif /* !(__ASSEMBLY__) */
276
277#endif /* !(__SPARC_OPENPROM_H) */
diff --git a/arch/sparc/include/asm/openprom_32.h b/arch/sparc/include/asm/openprom_32.h
deleted file mode 100644
index 875da3552d80..000000000000
--- a/arch/sparc/include/asm/openprom_32.h
+++ /dev/null
@@ -1,255 +0,0 @@
1#ifndef __SPARC_OPENPROM_H
2#define __SPARC_OPENPROM_H
3
4/* openprom.h: Prom structures and defines for access to the OPENBOOT
5 * prom routines and data areas.
6 *
7 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
8 */
9
10/* Empirical constants... */
11#define LINUX_OPPROM_MAGIC 0x10010407
12
13#ifndef __ASSEMBLY__
14/* V0 prom device operations. */
15struct linux_dev_v0_funcs {
16 int (*v0_devopen)(char *device_str);
17 int (*v0_devclose)(int dev_desc);
18 int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
19 int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
20 int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
21 int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
22 int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
23 int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
24 int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
25};
26
27/* V2 and later prom device operations. */
28struct linux_dev_v2_funcs {
29 int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
30 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
31 void (*v2_dumb_mem_free)(char *va, unsigned sz);
32
33 /* To map devices into virtual I/O space. */
34 char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
35 void (*v2_dumb_munmap)(char *virta, unsigned size);
36
37 int (*v2_dev_open)(char *devpath);
38 void (*v2_dev_close)(int d);
39 int (*v2_dev_read)(int d, char *buf, int nbytes);
40 int (*v2_dev_write)(int d, char *buf, int nbytes);
41 int (*v2_dev_seek)(int d, int hi, int lo);
42
43 /* Never issued (multistage load support) */
44 void (*v2_wheee2)(void);
45 void (*v2_wheee3)(void);
46};
47
48struct linux_mlist_v0 {
49 struct linux_mlist_v0 *theres_more;
50 char *start_adr;
51 unsigned num_bytes;
52};
53
54struct linux_mem_v0 {
55 struct linux_mlist_v0 **v0_totphys;
56 struct linux_mlist_v0 **v0_prommap;
57 struct linux_mlist_v0 **v0_available; /* What we can use */
58};
59
60/* Arguments sent to the kernel from the boot prompt. */
61struct linux_arguments_v0 {
62 char *argv[8];
63 char args[100];
64 char boot_dev[2];
65 int boot_dev_ctrl;
66 int boot_dev_unit;
67 int dev_partition;
68 char *kernel_file_name;
69 void *aieee1; /* XXX */
70};
71
72/* V2 and up boot things. */
73struct linux_bootargs_v2 {
74 char **bootpath;
75 char **bootargs;
76 int *fd_stdin;
77 int *fd_stdout;
78};
79
80/* The top level PROM vector. */
81struct linux_romvec {
82 /* Version numbers. */
83 unsigned int pv_magic_cookie;
84 unsigned int pv_romvers;
85 unsigned int pv_plugin_revision;
86 unsigned int pv_printrev;
87
88 /* Version 0 memory descriptors. */
89 struct linux_mem_v0 pv_v0mem;
90
91 /* Node operations. */
92 struct linux_nodeops *pv_nodeops;
93
94 char **pv_bootstr;
95 struct linux_dev_v0_funcs pv_v0devops;
96
97 char *pv_stdin;
98 char *pv_stdout;
99#define PROMDEV_KBD 0 /* input from keyboard */
100#define PROMDEV_SCREEN 0 /* output to screen */
101#define PROMDEV_TTYA 1 /* in/out to ttya */
102#define PROMDEV_TTYB 2 /* in/out to ttyb */
103
104 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
105 int (*pv_getchar)(void);
106 void (*pv_putchar)(int ch);
107
108 /* Non-blocking variants. */
109 int (*pv_nbgetchar)(void);
110 int (*pv_nbputchar)(int ch);
111
112 void (*pv_putstr)(char *str, int len);
113
114 /* Miscellany. */
115 void (*pv_reboot)(char *bootstr);
116 void (*pv_printf)(__const__ char *fmt, ...);
117 void (*pv_abort)(void);
118 __volatile__ int *pv_ticks;
119 void (*pv_halt)(void);
120 void (**pv_synchook)(void);
121
122 /* Evaluate a forth string, not different proto for V0 and V2->up. */
123 union {
124 void (*v0_eval)(int len, char *str);
125 void (*v2_eval)(char *str);
126 } pv_fortheval;
127
128 struct linux_arguments_v0 **pv_v0bootargs;
129
130 /* Get ether address. */
131 unsigned int (*pv_enaddr)(int d, char *enaddr);
132
133 struct linux_bootargs_v2 pv_v2bootargs;
134 struct linux_dev_v2_funcs pv_v2devops;
135
136 int filler[15];
137
138 /* This one is sun4c/sun4 only. */
139 void (*pv_setctxt)(int ctxt, char *va, int pmeg);
140
141 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
142 * No joke. Calling these when there is only one cpu probably
143 * crashes the machine, have to test this. :-)
144 */
145
146 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
147 * 'thiscontext' executing at address 'prog_counter'
148 */
149 int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
150 int thiscontext, char *prog_counter);
151
152 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
153 * until a resume cpu call is made.
154 */
155 int (*v3_cpustop)(unsigned int whichcpu);
156
157 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
158 * resume cpu call is made.
159 */
160 int (*v3_cpuidle)(unsigned int whichcpu);
161
162 /* v3_cpuresume() will resume processor 'whichcpu' executing
163 * starting with whatever 'pc' and 'npc' were left at the
164 * last 'idle' or 'stop' call.
165 */
166 int (*v3_cpuresume)(unsigned int whichcpu);
167};
168
169/* Routines for traversing the prom device tree. */
170struct linux_nodeops {
171 int (*no_nextnode)(int node);
172 int (*no_child)(int node);
173 int (*no_proplen)(int node, const char *name);
174 int (*no_getprop)(int node, const char *name, char *val);
175 int (*no_setprop)(int node, const char *name, char *val, int len);
176 char * (*no_nextprop)(int node, char *name);
177};
178
179/* More fun PROM structures for device probing. */
180#define PROMREG_MAX 16
181#define PROMVADDR_MAX 16
182#define PROMINTR_MAX 15
183
184struct linux_prom_registers {
185 unsigned int which_io; /* is this in OBIO space? */
186 unsigned int phys_addr; /* The physical address of this register */
187 unsigned int reg_size; /* How many bytes does this register take up? */
188};
189
190struct linux_prom_irqs {
191 int pri; /* IRQ priority */
192 int vector; /* This is foobar, what does it do? */
193};
194
195/* Element of the "ranges" vector */
196struct linux_prom_ranges {
197 unsigned int ot_child_space;
198 unsigned int ot_child_base; /* Bus feels this */
199 unsigned int ot_parent_space;
200 unsigned int ot_parent_base; /* CPU looks from here */
201 unsigned int or_size;
202};
203
204/* Ranges and reg properties are a bit different for PCI. */
205struct linux_prom_pci_registers {
206 /*
207 * We don't know what information this field contain.
208 * We guess, PCI device function is in bits 15:8
209 * So, ...
210 */
211 unsigned int which_io; /* Let it be which_io */
212
213 unsigned int phys_hi;
214 unsigned int phys_lo;
215
216 unsigned int size_hi;
217 unsigned int size_lo;
218};
219
220struct linux_prom_pci_ranges {
221 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
222 unsigned int child_phys_mid;
223 unsigned int child_phys_lo;
224
225 unsigned int parent_phys_hi;
226 unsigned int parent_phys_lo;
227
228 unsigned int size_hi;
229 unsigned int size_lo;
230};
231
232struct linux_prom_pci_assigned_addresses {
233 unsigned int which_io;
234
235 unsigned int phys_hi;
236 unsigned int phys_lo;
237
238 unsigned int size_hi;
239 unsigned int size_lo;
240};
241
242struct linux_prom_ebus_ranges {
243 unsigned int child_phys_hi;
244 unsigned int child_phys_lo;
245
246 unsigned int parent_phys_hi;
247 unsigned int parent_phys_mid;
248 unsigned int parent_phys_lo;
249
250 unsigned int size;
251};
252
253#endif /* !(__ASSEMBLY__) */
254
255#endif /* !(__SPARC_OPENPROM_H) */
diff --git a/arch/sparc/include/asm/openprom_64.h b/arch/sparc/include/asm/openprom_64.h
deleted file mode 100644
index b69e4a8c9170..000000000000
--- a/arch/sparc/include/asm/openprom_64.h
+++ /dev/null
@@ -1,280 +0,0 @@
1#ifndef __SPARC64_OPENPROM_H
2#define __SPARC64_OPENPROM_H
3
4/* openprom.h: Prom structures and defines for access to the OPENBOOT
5 * prom routines and data areas.
6 *
7 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
8 */
9
10#ifndef __ASSEMBLY__
11/* V0 prom device operations. */
12struct linux_dev_v0_funcs {
13 int (*v0_devopen)(char *device_str);
14 int (*v0_devclose)(int dev_desc);
15 int (*v0_rdblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
16 int (*v0_wrblkdev)(int dev_desc, int num_blks, int blk_st, char *buf);
17 int (*v0_wrnetdev)(int dev_desc, int num_bytes, char *buf);
18 int (*v0_rdnetdev)(int dev_desc, int num_bytes, char *buf);
19 int (*v0_rdchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
20 int (*v0_wrchardev)(int dev_desc, int num_bytes, int dummy, char *buf);
21 int (*v0_seekdev)(int dev_desc, long logical_offst, int from);
22};
23
24/* V2 and later prom device operations. */
25struct linux_dev_v2_funcs {
26 int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
27 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
28 void (*v2_dumb_mem_free)(char *va, unsigned sz);
29
30 /* To map devices into virtual I/O space. */
31 char * (*v2_dumb_mmap)(char *virta, int which_io, unsigned paddr, unsigned sz);
32 void (*v2_dumb_munmap)(char *virta, unsigned size);
33
34 int (*v2_dev_open)(char *devpath);
35 void (*v2_dev_close)(int d);
36 int (*v2_dev_read)(int d, char *buf, int nbytes);
37 int (*v2_dev_write)(int d, char *buf, int nbytes);
38 int (*v2_dev_seek)(int d, int hi, int lo);
39
40 /* Never issued (multistage load support) */
41 void (*v2_wheee2)(void);
42 void (*v2_wheee3)(void);
43};
44
45struct linux_mlist_v0 {
46 struct linux_mlist_v0 *theres_more;
47 unsigned start_adr;
48 unsigned num_bytes;
49};
50
51struct linux_mem_v0 {
52 struct linux_mlist_v0 **v0_totphys;
53 struct linux_mlist_v0 **v0_prommap;
54 struct linux_mlist_v0 **v0_available; /* What we can use */
55};
56
57/* Arguments sent to the kernel from the boot prompt. */
58struct linux_arguments_v0 {
59 char *argv[8];
60 char args[100];
61 char boot_dev[2];
62 int boot_dev_ctrl;
63 int boot_dev_unit;
64 int dev_partition;
65 char *kernel_file_name;
66 void *aieee1; /* XXX */
67};
68
69/* V2 and up boot things. */
70struct linux_bootargs_v2 {
71 char **bootpath;
72 char **bootargs;
73 int *fd_stdin;
74 int *fd_stdout;
75};
76
77/* The top level PROM vector. */
78struct linux_romvec {
79 /* Version numbers. */
80 unsigned int pv_magic_cookie;
81 unsigned int pv_romvers;
82 unsigned int pv_plugin_revision;
83 unsigned int pv_printrev;
84
85 /* Version 0 memory descriptors. */
86 struct linux_mem_v0 pv_v0mem;
87
88 /* Node operations. */
89 struct linux_nodeops *pv_nodeops;
90
91 char **pv_bootstr;
92 struct linux_dev_v0_funcs pv_v0devops;
93
94 char *pv_stdin;
95 char *pv_stdout;
96#define PROMDEV_KBD 0 /* input from keyboard */
97#define PROMDEV_SCREEN 0 /* output to screen */
98#define PROMDEV_TTYA 1 /* in/out to ttya */
99#define PROMDEV_TTYB 2 /* in/out to ttyb */
100
101 /* Blocking getchar/putchar. NOT REENTRANT! (grr) */
102 int (*pv_getchar)(void);
103 void (*pv_putchar)(int ch);
104
105 /* Non-blocking variants. */
106 int (*pv_nbgetchar)(void);
107 int (*pv_nbputchar)(int ch);
108
109 void (*pv_putstr)(char *str, int len);
110
111 /* Miscellany. */
112 void (*pv_reboot)(char *bootstr);
113 void (*pv_printf)(__const__ char *fmt, ...);
114 void (*pv_abort)(void);
115 __volatile__ int *pv_ticks;
116 void (*pv_halt)(void);
117 void (**pv_synchook)(void);
118
119 /* Evaluate a forth string, not different proto for V0 and V2->up. */
120 union {
121 void (*v0_eval)(int len, char *str);
122 void (*v2_eval)(char *str);
123 } pv_fortheval;
124
125 struct linux_arguments_v0 **pv_v0bootargs;
126
127 /* Get ether address. */
128 unsigned int (*pv_enaddr)(int d, char *enaddr);
129
130 struct linux_bootargs_v2 pv_v2bootargs;
131 struct linux_dev_v2_funcs pv_v2devops;
132
133 int filler[15];
134
135 /* This one is sun4c/sun4 only. */
136 void (*pv_setctxt)(int ctxt, char *va, int pmeg);
137
138 /* Prom version 3 Multiprocessor routines. This stuff is crazy.
139 * No joke. Calling these when there is only one cpu probably
140 * crashes the machine, have to test this. :-)
141 */
142
143 /* v3_cpustart() will start the cpu 'whichcpu' in mmu-context
144 * 'thiscontext' executing at address 'prog_counter'
145 */
146 int (*v3_cpustart)(unsigned int whichcpu, int ctxtbl_ptr,
147 int thiscontext, char *prog_counter);
148
149 /* v3_cpustop() will cause cpu 'whichcpu' to stop executing
150 * until a resume cpu call is made.
151 */
152 int (*v3_cpustop)(unsigned int whichcpu);
153
154 /* v3_cpuidle() will idle cpu 'whichcpu' until a stop or
155 * resume cpu call is made.
156 */
157 int (*v3_cpuidle)(unsigned int whichcpu);
158
159 /* v3_cpuresume() will resume processor 'whichcpu' executing
160 * starting with whatever 'pc' and 'npc' were left at the
161 * last 'idle' or 'stop' call.
162 */
163 int (*v3_cpuresume)(unsigned int whichcpu);
164};
165
166/* Routines for traversing the prom device tree. */
167struct linux_nodeops {
168 int (*no_nextnode)(int node);
169 int (*no_child)(int node);
170 int (*no_proplen)(int node, char *name);
171 int (*no_getprop)(int node, char *name, char *val);
172 int (*no_setprop)(int node, char *name, char *val, int len);
173 char * (*no_nextprop)(int node, char *name);
174};
175
176/* More fun PROM structures for device probing. */
177#define PROMREG_MAX 24
178#define PROMVADDR_MAX 16
179#define PROMINTR_MAX 32
180
181struct linux_prom_registers {
182 unsigned which_io; /* hi part of physical address */
183 unsigned phys_addr; /* The physical address of this register */
184 int reg_size; /* How many bytes does this register take up? */
185};
186
187struct linux_prom64_registers {
188 unsigned long phys_addr;
189 unsigned long reg_size;
190};
191
192struct linux_prom_irqs {
193 int pri; /* IRQ priority */
194 int vector; /* This is foobar, what does it do? */
195};
196
197/* Element of the "ranges" vector */
198struct linux_prom_ranges {
199 unsigned int ot_child_space;
200 unsigned int ot_child_base; /* Bus feels this */
201 unsigned int ot_parent_space;
202 unsigned int ot_parent_base; /* CPU looks from here */
203 unsigned int or_size;
204};
205
206struct linux_prom64_ranges {
207 unsigned long ot_child_base; /* Bus feels this */
208 unsigned long ot_parent_base; /* CPU looks from here */
209 unsigned long or_size;
210};
211
212/* Ranges and reg properties are a bit different for PCI. */
213struct linux_prom_pci_registers {
214 unsigned int phys_hi;
215 unsigned int phys_mid;
216 unsigned int phys_lo;
217
218 unsigned int size_hi;
219 unsigned int size_lo;
220};
221
222struct linux_prom_pci_ranges {
223 unsigned int child_phys_hi; /* Only certain bits are encoded here. */
224 unsigned int child_phys_mid;
225 unsigned int child_phys_lo;
226
227 unsigned int parent_phys_hi;
228 unsigned int parent_phys_lo;
229
230 unsigned int size_hi;
231 unsigned int size_lo;
232};
233
234struct linux_prom_pci_intmap {
235 unsigned int phys_hi;
236 unsigned int phys_mid;
237 unsigned int phys_lo;
238
239 unsigned int interrupt;
240
241 int cnode;
242 unsigned int cinterrupt;
243};
244
245struct linux_prom_pci_intmask {
246 unsigned int phys_hi;
247 unsigned int phys_mid;
248 unsigned int phys_lo;
249 unsigned int interrupt;
250};
251
252struct linux_prom_ebus_ranges {
253 unsigned int child_phys_hi;
254 unsigned int child_phys_lo;
255
256 unsigned int parent_phys_hi;
257 unsigned int parent_phys_mid;
258 unsigned int parent_phys_lo;
259
260 unsigned int size;
261};
262
263struct linux_prom_ebus_intmap {
264 unsigned int phys_hi;
265 unsigned int phys_lo;
266
267 unsigned int interrupt;
268
269 int cnode;
270 unsigned int cinterrupt;
271};
272
273struct linux_prom_ebus_intmask {
274 unsigned int phys_hi;
275 unsigned int phys_lo;
276 unsigned int interrupt;
277};
278#endif /* !(__ASSEMBLY__) */
279
280#endif /* !(__SPARC64_OPENPROM_H) */
diff --git a/arch/sparc/include/asm/posix_types.h b/arch/sparc/include/asm/posix_types.h
index 03a0e091a884..98d6ebb922fb 100644
--- a/arch/sparc/include/asm/posix_types.h
+++ b/arch/sparc/include/asm/posix_types.h
@@ -1,8 +1,155 @@
1#ifndef ___ASM_SPARC_POSIX_TYPES_H 1/*
2#define ___ASM_SPARC_POSIX_TYPES_H 2 * This file is generally used by user-level software, so you need to
3 * be a little careful about namespace pollution etc. Also, we cannot
4 * assume GCC is being used.
5 */
6
7#ifndef __SPARC_POSIX_TYPES_H
8#define __SPARC_POSIX_TYPES_H
9
3#if defined(__sparc__) && defined(__arch64__) 10#if defined(__sparc__) && defined(__arch64__)
4#include <asm/posix_types_64.h> 11/* sparc 64 bit */
12typedef unsigned long __kernel_size_t;
13typedef long __kernel_ssize_t;
14typedef long __kernel_ptrdiff_t;
15typedef long __kernel_time_t;
16typedef long __kernel_clock_t;
17typedef int __kernel_pid_t;
18typedef int __kernel_ipc_pid_t;
19typedef unsigned int __kernel_uid_t;
20typedef unsigned int __kernel_gid_t;
21typedef unsigned long __kernel_ino_t;
22typedef unsigned int __kernel_mode_t;
23typedef unsigned short __kernel_umode_t;
24typedef unsigned int __kernel_nlink_t;
25typedef int __kernel_daddr_t;
26typedef long __kernel_off_t;
27typedef char * __kernel_caddr_t;
28typedef unsigned short __kernel_uid16_t;
29typedef unsigned short __kernel_gid16_t;
30typedef int __kernel_clockid_t;
31typedef int __kernel_timer_t;
32
33typedef unsigned short __kernel_old_uid_t;
34typedef unsigned short __kernel_old_gid_t;
35typedef __kernel_uid_t __kernel_uid32_t;
36typedef __kernel_gid_t __kernel_gid32_t;
37
38typedef unsigned int __kernel_old_dev_t;
39
40/* Note this piece of asymmetry from the v9 ABI. */
41typedef int __kernel_suseconds_t;
42
5#else 43#else
6#include <asm/posix_types_32.h> 44/* sparc 32 bit */
7#endif 45
46typedef unsigned int __kernel_size_t;
47typedef int __kernel_ssize_t;
48typedef long int __kernel_ptrdiff_t;
49typedef long __kernel_time_t;
50typedef long __kernel_suseconds_t;
51typedef long __kernel_clock_t;
52typedef int __kernel_pid_t;
53typedef unsigned short __kernel_ipc_pid_t;
54typedef unsigned short __kernel_uid_t;
55typedef unsigned short __kernel_gid_t;
56typedef unsigned long __kernel_ino_t;
57typedef unsigned short __kernel_mode_t;
58typedef unsigned short __kernel_umode_t;
59typedef short __kernel_nlink_t;
60typedef long __kernel_daddr_t;
61typedef long __kernel_off_t;
62typedef char * __kernel_caddr_t;
63typedef unsigned short __kernel_uid16_t;
64typedef unsigned short __kernel_gid16_t;
65typedef unsigned int __kernel_uid32_t;
66typedef unsigned int __kernel_gid32_t;
67typedef unsigned short __kernel_old_uid_t;
68typedef unsigned short __kernel_old_gid_t;
69typedef unsigned short __kernel_old_dev_t;
70typedef int __kernel_clockid_t;
71typedef int __kernel_timer_t;
72
73#endif /* defined(__sparc__) && defined(__arch64__) */
74
75#ifdef __GNUC__
76typedef long long __kernel_loff_t;
8#endif 77#endif
78
79typedef struct {
80 int val[2];
81} __kernel_fsid_t;
82
83#ifdef __KERNEL__
84
85#undef __FD_SET
86static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
87{
88 unsigned long _tmp = fd / __NFDBITS;
89 unsigned long _rem = fd % __NFDBITS;
90 fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
91}
92
93#undef __FD_CLR
94static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
95{
96 unsigned long _tmp = fd / __NFDBITS;
97 unsigned long _rem = fd % __NFDBITS;
98 fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
99}
100
101#undef __FD_ISSET
102static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
103{
104 unsigned long _tmp = fd / __NFDBITS;
105 unsigned long _rem = fd % __NFDBITS;
106 return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
107}
108
109/*
110 * This will unroll the loop for the normal constant cases (8 or 32 longs,
111 * for 256 and 1024-bit fd_sets respectively)
112 */
113#undef __FD_ZERO
114static inline void __FD_ZERO(__kernel_fd_set *p)
115{
116 unsigned long *tmp = p->fds_bits;
117 int i;
118
119 if (__builtin_constant_p(__FDSET_LONGS)) {
120 switch (__FDSET_LONGS) {
121 case 32:
122 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
123 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
124 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
125 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
126 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
127 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
128 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
129 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
130 return;
131 case 16:
132 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
133 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
134 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
135 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
136 return;
137 case 8:
138 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
139 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
140 return;
141 case 4:
142 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
143 return;
144 }
145 }
146 i = __FDSET_LONGS;
147 while (i) {
148 i--;
149 *tmp = 0;
150 tmp++;
151 }
152}
153
154#endif /* __KERNEL__ */
155#endif /* __SPARC_POSIX_TYPES_H */
diff --git a/arch/sparc/include/asm/posix_types_32.h b/arch/sparc/include/asm/posix_types_32.h
deleted file mode 100644
index 6bb6eb1ca0f2..000000000000
--- a/arch/sparc/include/asm/posix_types_32.h
+++ /dev/null
@@ -1,118 +0,0 @@
1#ifndef __ARCH_SPARC_POSIX_TYPES_H
2#define __ARCH_SPARC_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned int __kernel_size_t;
11typedef int __kernel_ssize_t;
12typedef long int __kernel_ptrdiff_t;
13typedef long __kernel_time_t;
14typedef long __kernel_suseconds_t;
15typedef long __kernel_clock_t;
16typedef int __kernel_pid_t;
17typedef unsigned short __kernel_ipc_pid_t;
18typedef unsigned short __kernel_uid_t;
19typedef unsigned short __kernel_gid_t;
20typedef unsigned long __kernel_ino_t;
21typedef unsigned short __kernel_mode_t;
22typedef unsigned short __kernel_umode_t;
23typedef short __kernel_nlink_t;
24typedef long __kernel_daddr_t;
25typedef long __kernel_off_t;
26typedef char * __kernel_caddr_t;
27typedef unsigned short __kernel_uid16_t;
28typedef unsigned short __kernel_gid16_t;
29typedef unsigned int __kernel_uid32_t;
30typedef unsigned int __kernel_gid32_t;
31typedef unsigned short __kernel_old_uid_t;
32typedef unsigned short __kernel_old_gid_t;
33typedef unsigned short __kernel_old_dev_t;
34typedef int __kernel_clockid_t;
35typedef int __kernel_timer_t;
36
37#ifdef __GNUC__
38typedef long long __kernel_loff_t;
39#endif
40
41typedef struct {
42 int val[2];
43} __kernel_fsid_t;
44
45#if defined(__KERNEL__)
46
47#undef __FD_SET
48static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
49{
50 unsigned long _tmp = fd / __NFDBITS;
51 unsigned long _rem = fd % __NFDBITS;
52 fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
53}
54
55#undef __FD_CLR
56static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
57{
58 unsigned long _tmp = fd / __NFDBITS;
59 unsigned long _rem = fd % __NFDBITS;
60 fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
61}
62
63#undef __FD_ISSET
64static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
65{
66 unsigned long _tmp = fd / __NFDBITS;
67 unsigned long _rem = fd % __NFDBITS;
68 return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
69}
70
71/*
72 * This will unroll the loop for the normal constant cases (8 or 32 longs,
73 * for 256 and 1024-bit fd_sets respectively)
74 */
75#undef __FD_ZERO
76static inline void __FD_ZERO(__kernel_fd_set *p)
77{
78 unsigned long *tmp = p->fds_bits;
79 int i;
80
81 if (__builtin_constant_p(__FDSET_LONGS)) {
82 switch (__FDSET_LONGS) {
83 case 32:
84 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
85 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
86 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
87 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
88 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
89 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
90 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
91 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
92 return;
93 case 16:
94 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
95 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
96 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
97 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
98 return;
99 case 8:
100 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
101 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
102 return;
103 case 4:
104 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
105 return;
106 }
107 }
108 i = __FDSET_LONGS;
109 while (i) {
110 i--;
111 *tmp = 0;
112 tmp++;
113 }
114}
115
116#endif /* defined(__KERNEL__) */
117
118#endif /* !(__ARCH_SPARC_POSIX_TYPES_H) */
diff --git a/arch/sparc/include/asm/posix_types_64.h b/arch/sparc/include/asm/posix_types_64.h
deleted file mode 100644
index ba8f93295763..000000000000
--- a/arch/sparc/include/asm/posix_types_64.h
+++ /dev/null
@@ -1,122 +0,0 @@
1#ifndef __ARCH_SPARC64_POSIX_TYPES_H
2#define __ARCH_SPARC64_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned long __kernel_size_t;
11typedef long __kernel_ssize_t;
12typedef long __kernel_ptrdiff_t;
13typedef long __kernel_time_t;
14typedef long __kernel_clock_t;
15typedef int __kernel_pid_t;
16typedef int __kernel_ipc_pid_t;
17typedef unsigned int __kernel_uid_t;
18typedef unsigned int __kernel_gid_t;
19typedef unsigned long __kernel_ino_t;
20typedef unsigned int __kernel_mode_t;
21typedef unsigned short __kernel_umode_t;
22typedef unsigned int __kernel_nlink_t;
23typedef int __kernel_daddr_t;
24typedef long __kernel_off_t;
25typedef char * __kernel_caddr_t;
26typedef unsigned short __kernel_uid16_t;
27typedef unsigned short __kernel_gid16_t;
28typedef int __kernel_clockid_t;
29typedef int __kernel_timer_t;
30
31typedef unsigned short __kernel_old_uid_t;
32typedef unsigned short __kernel_old_gid_t;
33typedef __kernel_uid_t __kernel_uid32_t;
34typedef __kernel_gid_t __kernel_gid32_t;
35
36typedef unsigned int __kernel_old_dev_t;
37
38/* Note this piece of asymmetry from the v9 ABI. */
39typedef int __kernel_suseconds_t;
40
41#ifdef __GNUC__
42typedef long long __kernel_loff_t;
43#endif
44
45typedef struct {
46 int val[2];
47} __kernel_fsid_t;
48
49#if defined(__KERNEL__)
50
51#undef __FD_SET
52static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
53{
54 unsigned long _tmp = fd / __NFDBITS;
55 unsigned long _rem = fd % __NFDBITS;
56 fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
57}
58
59#undef __FD_CLR
60static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
61{
62 unsigned long _tmp = fd / __NFDBITS;
63 unsigned long _rem = fd % __NFDBITS;
64 fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
65}
66
67#undef __FD_ISSET
68static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
69{
70 unsigned long _tmp = fd / __NFDBITS;
71 unsigned long _rem = fd % __NFDBITS;
72 return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
73}
74
75/*
76 * This will unroll the loop for the normal constant cases (8 or 32 longs,
77 * for 256 and 1024-bit fd_sets respectively)
78 */
79#undef __FD_ZERO
80static inline void __FD_ZERO(__kernel_fd_set *p)
81{
82 unsigned long *tmp = p->fds_bits;
83 int i;
84
85 if (__builtin_constant_p(__FDSET_LONGS)) {
86 switch (__FDSET_LONGS) {
87 case 32:
88 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
89 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
90 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
91 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
92 tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
93 tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
94 tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
95 tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
96 return;
97 case 16:
98 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
99 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
100 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
101 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
102 return;
103 case 8:
104 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
105 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
106 return;
107 case 4:
108 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
109 return;
110 }
111 }
112 i = __FDSET_LONGS;
113 while (i) {
114 i--;
115 *tmp = 0;
116 tmp++;
117 }
118}
119
120#endif /* defined(__KERNEL__) */
121
122#endif /* !(__ARCH_SPARC64_POSIX_TYPES_H) */
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h
index 2ae67a2e7f3a..09521c6a5edb 100644
--- a/arch/sparc/include/asm/processor_32.h
+++ b/arch/sparc/include/asm/processor_32.h
@@ -99,7 +99,7 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,
99 "st\t%%g0, [%0 + %3 + 0x3c]" 99 "st\t%%g0, [%0 + %3 + 0x3c]"
100 : /* no outputs */ 100 : /* no outputs */
101 : "r" (regs), 101 : "r" (regs),
102 "r" (sp - sizeof(struct reg_window)), 102 "r" (sp - sizeof(struct reg_window32)),
103 "r" (zero), 103 "r" (zero),
104 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])) 104 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))
105 : "memory"); 105 : "memory");
diff --git a/arch/sparc/include/asm/ptrace.h b/arch/sparc/include/asm/ptrace.h
index 6dcbe2eed2e2..30b0b797dc0c 100644
--- a/arch/sparc/include/asm/ptrace.h
+++ b/arch/sparc/include/asm/ptrace.h
@@ -1,8 +1,448 @@
1#ifndef ___ASM_SPARC_PTRACE_H 1#ifndef __SPARC_PTRACE_H
2#define ___ASM_SPARC_PTRACE_H 2#define __SPARC_PTRACE_H
3
3#if defined(__sparc__) && defined(__arch64__) 4#if defined(__sparc__) && defined(__arch64__)
4#include <asm/ptrace_64.h> 5/* 64 bit sparc */
6#include <asm/pstate.h>
7
8/* This struct defines the way the registers are stored on the
9 * stack during a system call and basically all traps.
10 */
11
12/* This magic value must have the low 9 bits clear,
13 * as that is where we encode the %tt value, see below.
14 */
15#define PT_REGS_MAGIC 0x57ac6c00
16
17#ifndef __ASSEMBLY__
18
19#include <linux/types.h>
20
21struct pt_regs {
22 unsigned long u_regs[16]; /* globals and ins */
23 unsigned long tstate;
24 unsigned long tpc;
25 unsigned long tnpc;
26 unsigned int y;
27
28 /* We encode a magic number, PT_REGS_MAGIC, along
29 * with the %tt (trap type) register value at trap
30 * entry time. The magic number allows us to identify
31 * accurately a trap stack frame in the stack
32 * unwinder, and the %tt value allows us to test
33 * things like "in a system call" etc. for an arbitray
34 * process.
35 *
36 * The PT_REGS_MAGIC is choosen such that it can be
37 * loaded completely using just a sethi instruction.
38 */
39 unsigned int magic;
40};
41
42struct pt_regs32 {
43 unsigned int psr;
44 unsigned int pc;
45 unsigned int npc;
46 unsigned int y;
47 unsigned int u_regs[16]; /* globals and ins */
48};
49
50/* A V9 register window */
51struct reg_window {
52 unsigned long locals[8];
53 unsigned long ins[8];
54};
55
56/* A 32-bit register window. */
57struct reg_window32 {
58 unsigned int locals[8];
59 unsigned int ins[8];
60};
61
62/* A V9 Sparc stack frame */
63struct sparc_stackf {
64 unsigned long locals[8];
65 unsigned long ins[6];
66 struct sparc_stackf *fp;
67 unsigned long callers_pc;
68 char *structptr;
69 unsigned long xargs[6];
70 unsigned long xxargs[1];
71};
72
73/* A 32-bit Sparc stack frame */
74struct sparc_stackf32 {
75 unsigned int locals[8];
76 unsigned int ins[6];
77 unsigned int fp;
78 unsigned int callers_pc;
79 unsigned int structptr;
80 unsigned int xargs[6];
81 unsigned int xxargs[1];
82};
83
84struct sparc_trapf {
85 unsigned long locals[8];
86 unsigned long ins[8];
87 unsigned long _unused;
88 struct pt_regs *regs;
89};
90#endif /* (!__ASSEMBLY__) */
5#else 91#else
6#include <asm/ptrace_32.h> 92/* 32 bit sparc */
93
94#include <asm/psr.h>
95
96/* This struct defines the way the registers are stored on the
97 * stack during a system call and basically all traps.
98 */
99#ifndef __ASSEMBLY__
100
101struct pt_regs {
102 unsigned long psr;
103 unsigned long pc;
104 unsigned long npc;
105 unsigned long y;
106 unsigned long u_regs[16]; /* globals and ins */
107};
108
109/* A 32-bit register window. */
110struct reg_window32 {
111 unsigned long locals[8];
112 unsigned long ins[8];
113};
114
115/* A Sparc stack frame */
116struct sparc_stackf {
117 unsigned long locals[8];
118 unsigned long ins[6];
119 struct sparc_stackf *fp;
120 unsigned long callers_pc;
121 char *structptr;
122 unsigned long xargs[6];
123 unsigned long xxargs[1];
124};
125#endif /* (!__ASSEMBLY__) */
126
127#endif /* (defined(__sparc__) && defined(__arch64__))*/
128
129#ifndef __ASSEMBLY__
130
131#define TRACEREG_SZ sizeof(struct pt_regs)
132#define STACKFRAME_SZ sizeof(struct sparc_stackf)
133
134#define TRACEREG32_SZ sizeof(struct pt_regs32)
135#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
136
137#endif /* (!__ASSEMBLY__) */
138
139#define UREG_G0 0
140#define UREG_G1 1
141#define UREG_G2 2
142#define UREG_G3 3
143#define UREG_G4 4
144#define UREG_G5 5
145#define UREG_G6 6
146#define UREG_G7 7
147#define UREG_I0 8
148#define UREG_I1 9
149#define UREG_I2 10
150#define UREG_I3 11
151#define UREG_I4 12
152#define UREG_I5 13
153#define UREG_I6 14
154#define UREG_I7 15
155#define UREG_FP UREG_I6
156#define UREG_RETPC UREG_I7
157
158#if defined(__sparc__) && defined(__arch64__)
159/* 64 bit sparc */
160
161#ifndef __ASSEMBLY__
162
163#ifdef __KERNEL__
164
165#include <linux/threads.h>
166#include <asm/system.h>
167
168static inline int pt_regs_trap_type(struct pt_regs *regs)
169{
170 return regs->magic & 0x1ff;
171}
172
173static inline bool pt_regs_is_syscall(struct pt_regs *regs)
174{
175 return (regs->tstate & TSTATE_SYSCALL);
176}
177
178static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
179{
180 return (regs->tstate &= ~TSTATE_SYSCALL);
181}
182
183#define arch_ptrace_stop_needed(exit_code, info) \
184({ flush_user_windows(); \
185 get_thread_wsaved() != 0; \
186})
187
188#define arch_ptrace_stop(exit_code, info) \
189 synchronize_user_stack()
190
191struct global_reg_snapshot {
192 unsigned long tstate;
193 unsigned long tpc;
194 unsigned long tnpc;
195 unsigned long o7;
196 unsigned long i7;
197 unsigned long rpc;
198 struct thread_info *thread;
199 unsigned long pad1;
200};
201extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
202
203#define force_successful_syscall_return() \
204do { current_thread_info()->syscall_noerror = 1; \
205} while (0)
206#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
207#define instruction_pointer(regs) ((regs)->tpc)
208#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
209#define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
210#ifdef CONFIG_SMP
211extern unsigned long profile_pc(struct pt_regs *);
212#else
213#define profile_pc(regs) instruction_pointer(regs)
7#endif 214#endif
215extern void show_regs(struct pt_regs *);
216#endif /* (__KERNEL__) */
217
218#else /* __ASSEMBLY__ */
219/* For assembly code. */
220#define TRACEREG_SZ 0xa0
221#define STACKFRAME_SZ 0xc0
222
223#define TRACEREG32_SZ 0x50
224#define STACKFRAME32_SZ 0x60
225#endif /* __ASSEMBLY__ */
226
227#else /* (defined(__sparc__) && defined(__arch64__)) */
228
229/* 32 bit sparc */
230
231#ifndef __ASSEMBLY__
232
233#ifdef __KERNEL__
234
235#include <asm/system.h>
236
237static inline bool pt_regs_is_syscall(struct pt_regs *regs)
238{
239 return (regs->psr & PSR_SYSCALL);
240}
241
242static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
243{
244 return (regs->psr &= ~PSR_SYSCALL);
245}
246
247#define arch_ptrace_stop_needed(exit_code, info) \
248({ flush_user_windows(); \
249 current_thread_info()->w_saved != 0; \
250})
251
252#define arch_ptrace_stop(exit_code, info) \
253 synchronize_user_stack()
254
255#define user_mode(regs) (!((regs)->psr & PSR_PS))
256#define instruction_pointer(regs) ((regs)->pc)
257#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
258unsigned long profile_pc(struct pt_regs *);
259extern void show_regs(struct pt_regs *);
260#endif /* (__KERNEL__) */
261
262#else /* (!__ASSEMBLY__) */
263/* For assembly code. */
264#define TRACEREG_SZ 0x50
265#define STACKFRAME_SZ 0x60
266#endif /* (!__ASSEMBLY__) */
267
268#endif /* (defined(__sparc__) && defined(__arch64__)) */
269
270#ifdef __KERNEL__
271#define STACK_BIAS 2047
8#endif 272#endif
273
274/* These are for pt_regs. */
275#define PT_V9_G0 0x00
276#define PT_V9_G1 0x08
277#define PT_V9_G2 0x10
278#define PT_V9_G3 0x18
279#define PT_V9_G4 0x20
280#define PT_V9_G5 0x28
281#define PT_V9_G6 0x30
282#define PT_V9_G7 0x38
283#define PT_V9_I0 0x40
284#define PT_V9_I1 0x48
285#define PT_V9_I2 0x50
286#define PT_V9_I3 0x58
287#define PT_V9_I4 0x60
288#define PT_V9_I5 0x68
289#define PT_V9_I6 0x70
290#define PT_V9_FP PT_V9_I6
291#define PT_V9_I7 0x78
292#define PT_V9_TSTATE 0x80
293#define PT_V9_TPC 0x88
294#define PT_V9_TNPC 0x90
295#define PT_V9_Y 0x98
296#define PT_V9_MAGIC 0x9c
297#define PT_TSTATE PT_V9_TSTATE
298#define PT_TPC PT_V9_TPC
299#define PT_TNPC PT_V9_TNPC
300
301/* These for pt_regs32. */
302#define PT_PSR 0x0
303#define PT_PC 0x4
304#define PT_NPC 0x8
305#define PT_Y 0xc
306#define PT_G0 0x10
307#define PT_WIM PT_G0
308#define PT_G1 0x14
309#define PT_G2 0x18
310#define PT_G3 0x1c
311#define PT_G4 0x20
312#define PT_G5 0x24
313#define PT_G6 0x28
314#define PT_G7 0x2c
315#define PT_I0 0x30
316#define PT_I1 0x34
317#define PT_I2 0x38
318#define PT_I3 0x3c
319#define PT_I4 0x40
320#define PT_I5 0x44
321#define PT_I6 0x48
322#define PT_FP PT_I6
323#define PT_I7 0x4c
324
325/* Reg_window offsets */
326#define RW_V9_L0 0x00
327#define RW_V9_L1 0x08
328#define RW_V9_L2 0x10
329#define RW_V9_L3 0x18
330#define RW_V9_L4 0x20
331#define RW_V9_L5 0x28
332#define RW_V9_L6 0x30
333#define RW_V9_L7 0x38
334#define RW_V9_I0 0x40
335#define RW_V9_I1 0x48
336#define RW_V9_I2 0x50
337#define RW_V9_I3 0x58
338#define RW_V9_I4 0x60
339#define RW_V9_I5 0x68
340#define RW_V9_I6 0x70
341#define RW_V9_I7 0x78
342
343#define RW_L0 0x00
344#define RW_L1 0x04
345#define RW_L2 0x08
346#define RW_L3 0x0c
347#define RW_L4 0x10
348#define RW_L5 0x14
349#define RW_L6 0x18
350#define RW_L7 0x1c
351#define RW_I0 0x20
352#define RW_I1 0x24
353#define RW_I2 0x28
354#define RW_I3 0x2c
355#define RW_I4 0x30
356#define RW_I5 0x34
357#define RW_I6 0x38
358#define RW_I7 0x3c
359
360/* Stack_frame offsets */
361#define SF_V9_L0 0x00
362#define SF_V9_L1 0x08
363#define SF_V9_L2 0x10
364#define SF_V9_L3 0x18
365#define SF_V9_L4 0x20
366#define SF_V9_L5 0x28
367#define SF_V9_L6 0x30
368#define SF_V9_L7 0x38
369#define SF_V9_I0 0x40
370#define SF_V9_I1 0x48
371#define SF_V9_I2 0x50
372#define SF_V9_I3 0x58
373#define SF_V9_I4 0x60
374#define SF_V9_I5 0x68
375#define SF_V9_FP 0x70
376#define SF_V9_PC 0x78
377#define SF_V9_RETP 0x80
378#define SF_V9_XARG0 0x88
379#define SF_V9_XARG1 0x90
380#define SF_V9_XARG2 0x98
381#define SF_V9_XARG3 0xa0
382#define SF_V9_XARG4 0xa8
383#define SF_V9_XARG5 0xb0
384#define SF_V9_XXARG 0xb8
385
386#define SF_L0 0x00
387#define SF_L1 0x04
388#define SF_L2 0x08
389#define SF_L3 0x0c
390#define SF_L4 0x10
391#define SF_L5 0x14
392#define SF_L6 0x18
393#define SF_L7 0x1c
394#define SF_I0 0x20
395#define SF_I1 0x24
396#define SF_I2 0x28
397#define SF_I3 0x2c
398#define SF_I4 0x30
399#define SF_I5 0x34
400#define SF_FP 0x38
401#define SF_PC 0x3c
402#define SF_RETP 0x40
403#define SF_XARG0 0x44
404#define SF_XARG1 0x48
405#define SF_XARG2 0x4c
406#define SF_XARG3 0x50
407#define SF_XARG4 0x54
408#define SF_XARG5 0x58
409#define SF_XXARG 0x5c
410
411#ifdef __KERNEL__
412
413/* global_reg_snapshot offsets */
414#define GR_SNAP_TSTATE 0x00
415#define GR_SNAP_TPC 0x08
416#define GR_SNAP_TNPC 0x10
417#define GR_SNAP_O7 0x18
418#define GR_SNAP_I7 0x20
419#define GR_SNAP_RPC 0x28
420#define GR_SNAP_THREAD 0x30
421#define GR_SNAP_PAD1 0x38
422
423#endif /* __KERNEL__ */
424
425/* Stuff for the ptrace system call */
426#define PTRACE_SPARC_DETACH 11
427#define PTRACE_GETREGS 12
428#define PTRACE_SETREGS 13
429#define PTRACE_GETFPREGS 14
430#define PTRACE_SETFPREGS 15
431#define PTRACE_READDATA 16
432#define PTRACE_WRITEDATA 17
433#define PTRACE_READTEXT 18
434#define PTRACE_WRITETEXT 19
435#define PTRACE_GETFPAREGS 20
436#define PTRACE_SETFPAREGS 21
437
438/* There are for debugging 64-bit processes, either from a 32 or 64 bit
439 * parent. Thus their complements are for debugging 32-bit processes only.
440 */
441
442#define PTRACE_GETREGS64 22
443#define PTRACE_SETREGS64 23
444/* PTRACE_SYSCALL is 24 */
445#define PTRACE_GETFPREGS64 25
446#define PTRACE_SETFPREGS64 26
447
448#endif /* !(__SPARC_PTRACE_H) */
diff --git a/arch/sparc/include/asm/ptrace_32.h b/arch/sparc/include/asm/ptrace_32.h
deleted file mode 100644
index 4cef450167dd..000000000000
--- a/arch/sparc/include/asm/ptrace_32.h
+++ /dev/null
@@ -1,186 +0,0 @@
1#ifndef _SPARC_PTRACE_H
2#define _SPARC_PTRACE_H
3
4#include <asm/psr.h>
5
6/* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
8 */
9
10#ifndef __ASSEMBLY__
11
12#include <linux/types.h>
13
14struct pt_regs {
15 unsigned long psr;
16 unsigned long pc;
17 unsigned long npc;
18 unsigned long y;
19 unsigned long u_regs[16]; /* globals and ins */
20};
21
22#define UREG_G0 0
23#define UREG_G1 1
24#define UREG_G2 2
25#define UREG_G3 3
26#define UREG_G4 4
27#define UREG_G5 5
28#define UREG_G6 6
29#define UREG_G7 7
30#define UREG_I0 8
31#define UREG_I1 9
32#define UREG_I2 10
33#define UREG_I3 11
34#define UREG_I4 12
35#define UREG_I5 13
36#define UREG_I6 14
37#define UREG_I7 15
38#define UREG_WIM UREG_G0
39#define UREG_FADDR UREG_G0
40#define UREG_FP UREG_I6
41#define UREG_RETPC UREG_I7
42
43/* A register window */
44struct reg_window {
45 unsigned long locals[8];
46 unsigned long ins[8];
47};
48
49/* A Sparc stack frame */
50struct sparc_stackf {
51 unsigned long locals[8];
52 unsigned long ins[6];
53 struct sparc_stackf *fp;
54 unsigned long callers_pc;
55 char *structptr;
56 unsigned long xargs[6];
57 unsigned long xxargs[1];
58};
59
60#define TRACEREG_SZ sizeof(struct pt_regs)
61#define STACKFRAME_SZ sizeof(struct sparc_stackf)
62
63#ifdef __KERNEL__
64
65#include <asm/system.h>
66
67static inline bool pt_regs_is_syscall(struct pt_regs *regs)
68{
69 return (regs->psr & PSR_SYSCALL);
70}
71
72static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
73{
74 return (regs->psr &= ~PSR_SYSCALL);
75}
76
77#define arch_ptrace_stop_needed(exit_code, info) \
78({ flush_user_windows(); \
79 current_thread_info()->w_saved != 0; \
80})
81
82#define arch_ptrace_stop(exit_code, info) \
83 synchronize_user_stack()
84
85#define user_mode(regs) (!((regs)->psr & PSR_PS))
86#define instruction_pointer(regs) ((regs)->pc)
87#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
88unsigned long profile_pc(struct pt_regs *);
89extern void show_regs(struct pt_regs *);
90#endif
91
92#else /* __ASSEMBLY__ */
93/* For assembly code. */
94#define TRACEREG_SZ 0x50
95#define STACKFRAME_SZ 0x60
96#endif
97
98/*
99 * The asm-offsets.h is a generated file, so we cannot include it.
100 * It may be OK for glibc headers, but it's utterly pointless for C code.
101 * The assembly code using those offsets has to include it explicitly.
102 */
103/* #include <asm/asm-offsets.h> */
104
105/* These are for pt_regs. */
106#define PT_PSR 0x0
107#define PT_PC 0x4
108#define PT_NPC 0x8
109#define PT_Y 0xc
110#define PT_G0 0x10
111#define PT_WIM PT_G0
112#define PT_G1 0x14
113#define PT_G2 0x18
114#define PT_G3 0x1c
115#define PT_G4 0x20
116#define PT_G5 0x24
117#define PT_G6 0x28
118#define PT_G7 0x2c
119#define PT_I0 0x30
120#define PT_I1 0x34
121#define PT_I2 0x38
122#define PT_I3 0x3c
123#define PT_I4 0x40
124#define PT_I5 0x44
125#define PT_I6 0x48
126#define PT_FP PT_I6
127#define PT_I7 0x4c
128
129/* Reg_window offsets */
130#define RW_L0 0x00
131#define RW_L1 0x04
132#define RW_L2 0x08
133#define RW_L3 0x0c
134#define RW_L4 0x10
135#define RW_L5 0x14
136#define RW_L6 0x18
137#define RW_L7 0x1c
138#define RW_I0 0x20
139#define RW_I1 0x24
140#define RW_I2 0x28
141#define RW_I3 0x2c
142#define RW_I4 0x30
143#define RW_I5 0x34
144#define RW_I6 0x38
145#define RW_I7 0x3c
146
147/* Stack_frame offsets */
148#define SF_L0 0x00
149#define SF_L1 0x04
150#define SF_L2 0x08
151#define SF_L3 0x0c
152#define SF_L4 0x10
153#define SF_L5 0x14
154#define SF_L6 0x18
155#define SF_L7 0x1c
156#define SF_I0 0x20
157#define SF_I1 0x24
158#define SF_I2 0x28
159#define SF_I3 0x2c
160#define SF_I4 0x30
161#define SF_I5 0x34
162#define SF_FP 0x38
163#define SF_PC 0x3c
164#define SF_RETP 0x40
165#define SF_XARG0 0x44
166#define SF_XARG1 0x48
167#define SF_XARG2 0x4c
168#define SF_XARG3 0x50
169#define SF_XARG4 0x54
170#define SF_XARG5 0x58
171#define SF_XXARG 0x5c
172
173/* Stuff for the ptrace system call */
174#define PTRACE_SPARC_DETACH 11
175#define PTRACE_GETREGS 12
176#define PTRACE_SETREGS 13
177#define PTRACE_GETFPREGS 14
178#define PTRACE_SETFPREGS 15
179#define PTRACE_READDATA 16
180#define PTRACE_WRITEDATA 17
181#define PTRACE_READTEXT 18
182#define PTRACE_WRITETEXT 19
183#define PTRACE_GETFPAREGS 20
184#define PTRACE_SETFPAREGS 21
185
186#endif /* !(_SPARC_PTRACE_H) */
diff --git a/arch/sparc/include/asm/ptrace_64.h b/arch/sparc/include/asm/ptrace_64.h
deleted file mode 100644
index cd6fbfc20435..000000000000
--- a/arch/sparc/include/asm/ptrace_64.h
+++ /dev/null
@@ -1,356 +0,0 @@
1#ifndef _SPARC64_PTRACE_H
2#define _SPARC64_PTRACE_H
3
4#include <asm/pstate.h>
5
6/* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
8 */
9
10/* This magic value must have the low 9 bits clear,
11 * as that is where we encode the %tt value, see below.
12 */
13#define PT_REGS_MAGIC 0x57ac6c00
14
15#ifndef __ASSEMBLY__
16
17#include <linux/types.h>
18
19struct pt_regs {
20 unsigned long u_regs[16]; /* globals and ins */
21 unsigned long tstate;
22 unsigned long tpc;
23 unsigned long tnpc;
24 unsigned int y;
25
26 /* We encode a magic number, PT_REGS_MAGIC, along
27 * with the %tt (trap type) register value at trap
28 * entry time. The magic number allows us to identify
29 * accurately a trap stack frame in the stack
30 * unwinder, and the %tt value allows us to test
31 * things like "in a system call" etc. for an arbitray
32 * process.
33 *
34 * The PT_REGS_MAGIC is choosen such that it can be
35 * loaded completely using just a sethi instruction.
36 */
37 unsigned int magic;
38};
39
40struct pt_regs32 {
41 unsigned int psr;
42 unsigned int pc;
43 unsigned int npc;
44 unsigned int y;
45 unsigned int u_regs[16]; /* globals and ins */
46};
47
48#define UREG_G0 0
49#define UREG_G1 1
50#define UREG_G2 2
51#define UREG_G3 3
52#define UREG_G4 4
53#define UREG_G5 5
54#define UREG_G6 6
55#define UREG_G7 7
56#define UREG_I0 8
57#define UREG_I1 9
58#define UREG_I2 10
59#define UREG_I3 11
60#define UREG_I4 12
61#define UREG_I5 13
62#define UREG_I6 14
63#define UREG_I7 15
64#define UREG_FP UREG_I6
65#define UREG_RETPC UREG_I7
66
67/* A V9 register window */
68struct reg_window {
69 unsigned long locals[8];
70 unsigned long ins[8];
71};
72
73/* A 32-bit register window. */
74struct reg_window32 {
75 unsigned int locals[8];
76 unsigned int ins[8];
77};
78
79/* A V9 Sparc stack frame */
80struct sparc_stackf {
81 unsigned long locals[8];
82 unsigned long ins[6];
83 struct sparc_stackf *fp;
84 unsigned long callers_pc;
85 char *structptr;
86 unsigned long xargs[6];
87 unsigned long xxargs[1];
88};
89
90/* A 32-bit Sparc stack frame */
91struct sparc_stackf32 {
92 unsigned int locals[8];
93 unsigned int ins[6];
94 unsigned int fp;
95 unsigned int callers_pc;
96 unsigned int structptr;
97 unsigned int xargs[6];
98 unsigned int xxargs[1];
99};
100
101struct sparc_trapf {
102 unsigned long locals[8];
103 unsigned long ins[8];
104 unsigned long _unused;
105 struct pt_regs *regs;
106};
107
108#define TRACEREG_SZ sizeof(struct pt_regs)
109#define STACKFRAME_SZ sizeof(struct sparc_stackf)
110
111#define TRACEREG32_SZ sizeof(struct pt_regs32)
112#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
113
114#ifdef __KERNEL__
115
116#include <linux/threads.h>
117#include <asm/system.h>
118
119static inline int pt_regs_trap_type(struct pt_regs *regs)
120{
121 return regs->magic & 0x1ff;
122}
123
124static inline bool pt_regs_is_syscall(struct pt_regs *regs)
125{
126 return (regs->tstate & TSTATE_SYSCALL);
127}
128
129static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
130{
131 return (regs->tstate &= ~TSTATE_SYSCALL);
132}
133
134#define arch_ptrace_stop_needed(exit_code, info) \
135({ flush_user_windows(); \
136 get_thread_wsaved() != 0; \
137})
138
139#define arch_ptrace_stop(exit_code, info) \
140 synchronize_user_stack()
141
142struct global_reg_snapshot {
143 unsigned long tstate;
144 unsigned long tpc;
145 unsigned long tnpc;
146 unsigned long o7;
147 unsigned long i7;
148 unsigned long rpc;
149 struct thread_info *thread;
150 unsigned long pad1;
151};
152extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
153
154#define force_successful_syscall_return() \
155do { current_thread_info()->syscall_noerror = 1; \
156} while (0)
157#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
158#define instruction_pointer(regs) ((regs)->tpc)
159#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
160#define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
161#ifdef CONFIG_SMP
162extern unsigned long profile_pc(struct pt_regs *);
163#else
164#define profile_pc(regs) instruction_pointer(regs)
165#endif
166extern void show_regs(struct pt_regs *);
167#endif
168
169#else /* __ASSEMBLY__ */
170/* For assembly code. */
171#define TRACEREG_SZ 0xa0
172#define STACKFRAME_SZ 0xc0
173
174#define TRACEREG32_SZ 0x50
175#define STACKFRAME32_SZ 0x60
176#endif
177
178#ifdef __KERNEL__
179#define STACK_BIAS 2047
180#endif
181
182/* These are for pt_regs. */
183#define PT_V9_G0 0x00
184#define PT_V9_G1 0x08
185#define PT_V9_G2 0x10
186#define PT_V9_G3 0x18
187#define PT_V9_G4 0x20
188#define PT_V9_G5 0x28
189#define PT_V9_G6 0x30
190#define PT_V9_G7 0x38
191#define PT_V9_I0 0x40
192#define PT_V9_I1 0x48
193#define PT_V9_I2 0x50
194#define PT_V9_I3 0x58
195#define PT_V9_I4 0x60
196#define PT_V9_I5 0x68
197#define PT_V9_I6 0x70
198#define PT_V9_FP PT_V9_I6
199#define PT_V9_I7 0x78
200#define PT_V9_TSTATE 0x80
201#define PT_V9_TPC 0x88
202#define PT_V9_TNPC 0x90
203#define PT_V9_Y 0x98
204#define PT_V9_MAGIC 0x9c
205#define PT_TSTATE PT_V9_TSTATE
206#define PT_TPC PT_V9_TPC
207#define PT_TNPC PT_V9_TNPC
208
209/* These for pt_regs32. */
210#define PT_PSR 0x0
211#define PT_PC 0x4
212#define PT_NPC 0x8
213#define PT_Y 0xc
214#define PT_G0 0x10
215#define PT_WIM PT_G0
216#define PT_G1 0x14
217#define PT_G2 0x18
218#define PT_G3 0x1c
219#define PT_G4 0x20
220#define PT_G5 0x24
221#define PT_G6 0x28
222#define PT_G7 0x2c
223#define PT_I0 0x30
224#define PT_I1 0x34
225#define PT_I2 0x38
226#define PT_I3 0x3c
227#define PT_I4 0x40
228#define PT_I5 0x44
229#define PT_I6 0x48
230#define PT_FP PT_I6
231#define PT_I7 0x4c
232
233/* Reg_window offsets */
234#define RW_V9_L0 0x00
235#define RW_V9_L1 0x08
236#define RW_V9_L2 0x10
237#define RW_V9_L3 0x18
238#define RW_V9_L4 0x20
239#define RW_V9_L5 0x28
240#define RW_V9_L6 0x30
241#define RW_V9_L7 0x38
242#define RW_V9_I0 0x40
243#define RW_V9_I1 0x48
244#define RW_V9_I2 0x50
245#define RW_V9_I3 0x58
246#define RW_V9_I4 0x60
247#define RW_V9_I5 0x68
248#define RW_V9_I6 0x70
249#define RW_V9_I7 0x78
250
251#define RW_L0 0x00
252#define RW_L1 0x04
253#define RW_L2 0x08
254#define RW_L3 0x0c
255#define RW_L4 0x10
256#define RW_L5 0x14
257#define RW_L6 0x18
258#define RW_L7 0x1c
259#define RW_I0 0x20
260#define RW_I1 0x24
261#define RW_I2 0x28
262#define RW_I3 0x2c
263#define RW_I4 0x30
264#define RW_I5 0x34
265#define RW_I6 0x38
266#define RW_I7 0x3c
267
268/* Stack_frame offsets */
269#define SF_V9_L0 0x00
270#define SF_V9_L1 0x08
271#define SF_V9_L2 0x10
272#define SF_V9_L3 0x18
273#define SF_V9_L4 0x20
274#define SF_V9_L5 0x28
275#define SF_V9_L6 0x30
276#define SF_V9_L7 0x38
277#define SF_V9_I0 0x40
278#define SF_V9_I1 0x48
279#define SF_V9_I2 0x50
280#define SF_V9_I3 0x58
281#define SF_V9_I4 0x60
282#define SF_V9_I5 0x68
283#define SF_V9_FP 0x70
284#define SF_V9_PC 0x78
285#define SF_V9_RETP 0x80
286#define SF_V9_XARG0 0x88
287#define SF_V9_XARG1 0x90
288#define SF_V9_XARG2 0x98
289#define SF_V9_XARG3 0xa0
290#define SF_V9_XARG4 0xa8
291#define SF_V9_XARG5 0xb0
292#define SF_V9_XXARG 0xb8
293
294#define SF_L0 0x00
295#define SF_L1 0x04
296#define SF_L2 0x08
297#define SF_L3 0x0c
298#define SF_L4 0x10
299#define SF_L5 0x14
300#define SF_L6 0x18
301#define SF_L7 0x1c
302#define SF_I0 0x20
303#define SF_I1 0x24
304#define SF_I2 0x28
305#define SF_I3 0x2c
306#define SF_I4 0x30
307#define SF_I5 0x34
308#define SF_FP 0x38
309#define SF_PC 0x3c
310#define SF_RETP 0x40
311#define SF_XARG0 0x44
312#define SF_XARG1 0x48
313#define SF_XARG2 0x4c
314#define SF_XARG3 0x50
315#define SF_XARG4 0x54
316#define SF_XARG5 0x58
317#define SF_XXARG 0x5c
318
319#ifdef __KERNEL__
320
321/* global_reg_snapshot offsets */
322#define GR_SNAP_TSTATE 0x00
323#define GR_SNAP_TPC 0x08
324#define GR_SNAP_TNPC 0x10
325#define GR_SNAP_O7 0x18
326#define GR_SNAP_I7 0x20
327#define GR_SNAP_RPC 0x28
328#define GR_SNAP_THREAD 0x30
329#define GR_SNAP_PAD1 0x38
330
331#endif /* __KERNEL__ */
332
333/* Stuff for the ptrace system call */
334#define PTRACE_SPARC_DETACH 11
335#define PTRACE_GETREGS 12
336#define PTRACE_SETREGS 13
337#define PTRACE_GETFPREGS 14
338#define PTRACE_SETFPREGS 15
339#define PTRACE_READDATA 16
340#define PTRACE_WRITEDATA 17
341#define PTRACE_READTEXT 18
342#define PTRACE_WRITETEXT 19
343#define PTRACE_GETFPAREGS 20
344#define PTRACE_SETFPAREGS 21
345
346/* There are for debugging 64-bit processes, either from a 32 or 64 bit
347 * parent. Thus their complements are for debugging 32-bit processes only.
348 */
349
350#define PTRACE_GETREGS64 22
351#define PTRACE_SETREGS64 23
352/* PTRACE_SYSCALL is 24 */
353#define PTRACE_GETFPREGS64 25
354#define PTRACE_SETFPREGS64 26
355
356#endif /* !(_SPARC64_PTRACE_H) */
diff --git a/arch/sparc/include/asm/reg.h b/arch/sparc/include/asm/reg.h
deleted file mode 100644
index 0c16e19cae4d..000000000000
--- a/arch/sparc/include/asm/reg.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef ___ASM_SPARC_REG_H
2#define ___ASM_SPARC_REG_H
3#if defined(__sparc__) && defined(__arch64__)
4#include <asm/reg_64.h>
5#else
6#include <asm/reg_32.h>
7#endif
8#endif
diff --git a/arch/sparc/include/asm/reg_32.h b/arch/sparc/include/asm/reg_32.h
deleted file mode 100644
index 1efb056fb3d1..000000000000
--- a/arch/sparc/include/asm/reg_32.h
+++ /dev/null
@@ -1,79 +0,0 @@
1/*
2 * linux/include/asm/reg.h
3 * Layout of the registers as expected by gdb on the Sparc
4 * we should replace the user.h definitions with those in
5 * this file, we don't even use the other
6 * -miguel
7 *
8 * The names of the structures, constants and aliases in this file
9 * have the same names as the sunos ones, some programs rely on these
10 * names (gdb for example).
11 *
12 */
13
14#ifndef __SPARC_REG_H
15#define __SPARC_REG_H
16
17struct regs {
18 int r_psr;
19#define r_ps r_psr
20 int r_pc;
21 int r_npc;
22 int r_y;
23 int r_g1;
24 int r_g2;
25 int r_g3;
26 int r_g4;
27 int r_g5;
28 int r_g6;
29 int r_g7;
30 int r_o0;
31 int r_o1;
32 int r_o2;
33 int r_o3;
34 int r_o4;
35 int r_o5;
36 int r_o6;
37 int r_o7;
38};
39
40struct fpq {
41 unsigned long *addr;
42 unsigned long instr;
43};
44
45struct fq {
46 union {
47 double whole;
48 struct fpq fpq;
49 } FQu;
50};
51
52#define FPU_REGS_TYPE unsigned int
53#define FPU_FSR_TYPE unsigned
54
55struct fp_status {
56 union {
57 FPU_REGS_TYPE Fpu_regs[32];
58 double Fpu_dregs[16];
59 } fpu_fr;
60 FPU_FSR_TYPE Fpu_fsr;
61 unsigned Fpu_flags;
62 unsigned Fpu_extra;
63 unsigned Fpu_qcnt;
64 struct fq Fpu_q[16];
65};
66
67#define fpu_regs f_fpstatus.fpu_fr.Fpu_regs
68#define fpu_dregs f_fpstatus.fpu_fr.Fpu_dregs
69#define fpu_fsr f_fpstatus.Fpu_fsr
70#define fpu_flags f_fpstatus.Fpu_flags
71#define fpu_extra f_fpstatus.Fpu_extra
72#define fpu_q f_fpstatus.Fpu_q
73#define fpu_qcnt f_fpstatus.Fpu_qcnt
74
75struct fpu {
76 struct fp_status f_fpstatus;
77};
78
79#endif /* __SPARC_REG_H */
diff --git a/arch/sparc/include/asm/reg_64.h b/arch/sparc/include/asm/reg_64.h
deleted file mode 100644
index 6f277d7c7d88..000000000000
--- a/arch/sparc/include/asm/reg_64.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * linux/asm/reg.h
3 * Layout of the registers as expected by gdb on the Sparc
4 * we should replace the user.h definitions with those in
5 * this file, we don't even use the other
6 * -miguel
7 *
8 * The names of the structures, constants and aliases in this file
9 * have the same names as the sunos ones, some programs rely on these
10 * names (gdb for example).
11 *
12 */
13
14#ifndef __SPARC64_REG_H
15#define __SPARC64_REG_H
16
17struct regs {
18 unsigned long r_g1;
19 unsigned long r_g2;
20 unsigned long r_g3;
21 unsigned long r_g4;
22 unsigned long r_g5;
23 unsigned long r_g6;
24 unsigned long r_g7;
25 unsigned long r_o0;
26 unsigned long r_o1;
27 unsigned long r_o2;
28 unsigned long r_o3;
29 unsigned long r_o4;
30 unsigned long r_o5;
31 unsigned long r_o6;
32 unsigned long r_o7;
33 unsigned long __pad;
34 unsigned long r_tstate;
35 unsigned long r_tpc;
36 unsigned long r_tnpc;
37 unsigned int r_y;
38 unsigned int r_fprs;
39};
40
41#define FPU_REGS_TYPE unsigned int
42#define FPU_FSR_TYPE unsigned long
43
44struct fp_status {
45 unsigned long fpu_fr[32];
46 unsigned long Fpu_fsr;
47};
48
49struct fpu {
50 struct fp_status f_fpstatus;
51};
52
53#define fpu_regs f_fpstatus.fpu_fr
54#define fpu_fsr f_fpstatus.Fpu_fsr
55
56#endif /* __SPARC64_REG_H */
diff --git a/arch/sparc/include/asm/sigcontext.h b/arch/sparc/include/asm/sigcontext.h
index e92de7e286b5..a1607d180354 100644
--- a/arch/sparc/include/asm/sigcontext.h
+++ b/arch/sparc/include/asm/sigcontext.h
@@ -1,8 +1,96 @@
1#ifndef ___ASM_SPARC_SIGCONTEXT_H 1#ifndef __SPARC_SIGCONTEXT_H
2#define ___ASM_SPARC_SIGCONTEXT_H 2#define __SPARC_SIGCONTEXT_H
3#if defined(__sparc__) && defined(__arch64__) 3
4#include <asm/sigcontext_64.h> 4#ifdef __KERNEL__
5#include <asm/ptrace.h>
6
7#ifndef __ASSEMBLY__
8
9#define __SUNOS_MAXWIN 31
10
11/* This is what SunOS does, so shall I unless we use new 32bit signals or rt signals. */
12struct sigcontext32 {
13 int sigc_onstack; /* state to restore */
14 int sigc_mask; /* sigmask to restore */
15 int sigc_sp; /* stack pointer */
16 int sigc_pc; /* program counter */
17 int sigc_npc; /* next program counter */
18 int sigc_psr; /* for condition codes etc */
19 int sigc_g1; /* User uses these two registers */
20 int sigc_o0; /* within the trampoline code. */
21
22 /* Now comes information regarding the users window set
23 * at the time of the signal.
24 */
25 int sigc_oswins; /* outstanding windows */
26
27 /* stack ptrs for each regwin buf */
28 unsigned sigc_spbuf[__SUNOS_MAXWIN];
29
30 /* Windows to restore after signal */
31 struct reg_window32 sigc_wbuf[__SUNOS_MAXWIN];
32};
33
34
35/* This is what we use for 32bit new non-rt signals. */
36
37typedef struct {
38 struct {
39 unsigned int psr;
40 unsigned int pc;
41 unsigned int npc;
42 unsigned int y;
43 unsigned int u_regs[16]; /* globals and ins */
44 } si_regs;
45 int si_mask;
46} __siginfo32_t;
47
48#ifdef CONFIG_SPARC64
49typedef struct {
50 unsigned int si_float_regs [64];
51 unsigned long si_fsr;
52 unsigned long si_gsr;
53 unsigned long si_fprs;
54} __siginfo_fpu_t;
55
56/* This is what SunOS doesn't, so we have to write this alone
57 and do it properly. */
58struct sigcontext {
59 /* The size of this array has to match SI_MAX_SIZE from siginfo.h */
60 char sigc_info[128];
61 struct {
62 unsigned long u_regs[16]; /* globals and ins */
63 unsigned long tstate;
64 unsigned long tpc;
65 unsigned long tnpc;
66 unsigned int y;
67 unsigned int fprs;
68 } sigc_regs;
69 __siginfo_fpu_t * sigc_fpu_save;
70 struct {
71 void * ss_sp;
72 int ss_flags;
73 unsigned long ss_size;
74 } sigc_stack;
75 unsigned long sigc_mask;
76};
77
5#else 78#else
6#include <asm/sigcontext_32.h> 79
7#endif 80typedef struct {
8#endif 81 unsigned long si_float_regs [32];
82 unsigned long si_fsr;
83 unsigned long si_fpqdepth;
84 struct {
85 unsigned long *insn_addr;
86 unsigned long insn;
87 } si_fpqueue [16];
88} __siginfo_fpu_t;
89#endif /* (CONFIG_SPARC64) */
90
91
92#endif /* !(__ASSEMBLY__) */
93
94#endif /* (__KERNEL__) */
95
96#endif /* !(__SPARC_SIGCONTEXT_H) */
diff --git a/arch/sparc/include/asm/sigcontext_32.h b/arch/sparc/include/asm/sigcontext_32.h
deleted file mode 100644
index c5fb60dcbd75..000000000000
--- a/arch/sparc/include/asm/sigcontext_32.h
+++ /dev/null
@@ -1,62 +0,0 @@
1#ifndef __SPARC_SIGCONTEXT_H
2#define __SPARC_SIGCONTEXT_H
3
4#ifdef __KERNEL__
5#include <asm/ptrace.h>
6
7#ifndef __ASSEMBLY__
8
9#define __SUNOS_MAXWIN 31
10
11/* This is what SunOS does, so shall I. */
12struct sigcontext {
13 int sigc_onstack; /* state to restore */
14 int sigc_mask; /* sigmask to restore */
15 int sigc_sp; /* stack pointer */
16 int sigc_pc; /* program counter */
17 int sigc_npc; /* next program counter */
18 int sigc_psr; /* for condition codes etc */
19 int sigc_g1; /* User uses these two registers */
20 int sigc_o0; /* within the trampoline code. */
21
22 /* Now comes information regarding the users window set
23 * at the time of the signal.
24 */
25 int sigc_oswins; /* outstanding windows */
26
27 /* stack ptrs for each regwin buf */
28 char *sigc_spbuf[__SUNOS_MAXWIN];
29
30 /* Windows to restore after signal */
31 struct {
32 unsigned long locals[8];
33 unsigned long ins[8];
34 } sigc_wbuf[__SUNOS_MAXWIN];
35};
36
37typedef struct {
38 struct {
39 unsigned long psr;
40 unsigned long pc;
41 unsigned long npc;
42 unsigned long y;
43 unsigned long u_regs[16]; /* globals and ins */
44 } si_regs;
45 int si_mask;
46} __siginfo_t;
47
48typedef struct {
49 unsigned long si_float_regs [32];
50 unsigned long si_fsr;
51 unsigned long si_fpqdepth;
52 struct {
53 unsigned long *insn_addr;
54 unsigned long insn;
55 } si_fpqueue [16];
56} __siginfo_fpu_t;
57
58#endif /* !(__ASSEMBLY__) */
59
60#endif /* (__KERNEL__) */
61
62#endif /* !(__SPARC_SIGCONTEXT_H) */
diff --git a/arch/sparc/include/asm/sigcontext_64.h b/arch/sparc/include/asm/sigcontext_64.h
deleted file mode 100644
index 1c868d680cfc..000000000000
--- a/arch/sparc/include/asm/sigcontext_64.h
+++ /dev/null
@@ -1,87 +0,0 @@
1#ifndef __SPARC64_SIGCONTEXT_H
2#define __SPARC64_SIGCONTEXT_H
3
4#ifdef __KERNEL__
5#include <asm/ptrace.h>
6#endif
7
8#ifndef __ASSEMBLY__
9
10#ifdef __KERNEL__
11
12#define __SUNOS_MAXWIN 31
13
14/* This is what SunOS does, so shall I unless we use new 32bit signals or rt signals. */
15struct sigcontext32 {
16 int sigc_onstack; /* state to restore */
17 int sigc_mask; /* sigmask to restore */
18 int sigc_sp; /* stack pointer */
19 int sigc_pc; /* program counter */
20 int sigc_npc; /* next program counter */
21 int sigc_psr; /* for condition codes etc */
22 int sigc_g1; /* User uses these two registers */
23 int sigc_o0; /* within the trampoline code. */
24
25 /* Now comes information regarding the users window set
26 * at the time of the signal.
27 */
28 int sigc_oswins; /* outstanding windows */
29
30 /* stack ptrs for each regwin buf */
31 unsigned sigc_spbuf[__SUNOS_MAXWIN];
32
33 /* Windows to restore after signal */
34 struct reg_window32 sigc_wbuf[__SUNOS_MAXWIN];
35};
36
37#endif
38
39#ifdef __KERNEL__
40
41/* This is what we use for 32bit new non-rt signals. */
42
43typedef struct {
44 struct {
45 unsigned int psr;
46 unsigned int pc;
47 unsigned int npc;
48 unsigned int y;
49 unsigned int u_regs[16]; /* globals and ins */
50 } si_regs;
51 int si_mask;
52} __siginfo32_t;
53
54#endif
55
56typedef struct {
57 unsigned int si_float_regs [64];
58 unsigned long si_fsr;
59 unsigned long si_gsr;
60 unsigned long si_fprs;
61} __siginfo_fpu_t;
62
63/* This is what SunOS doesn't, so we have to write this alone
64 and do it properly. */
65struct sigcontext {
66 /* The size of this array has to match SI_MAX_SIZE from siginfo.h */
67 char sigc_info[128];
68 struct {
69 unsigned long u_regs[16]; /* globals and ins */
70 unsigned long tstate;
71 unsigned long tpc;
72 unsigned long tnpc;
73 unsigned int y;
74 unsigned int fprs;
75 } sigc_regs;
76 __siginfo_fpu_t * sigc_fpu_save;
77 struct {
78 void * ss_sp;
79 int ss_flags;
80 unsigned long ss_size;
81 } sigc_stack;
82 unsigned long sigc_mask;
83};
84
85#endif /* !(__ASSEMBLY__) */
86
87#endif /* !(__SPARC64_SIGCONTEXT_H) */
diff --git a/arch/sparc/include/asm/siginfo.h b/arch/sparc/include/asm/siginfo.h
index bd81f8d7f5ce..988e5d8ed11a 100644
--- a/arch/sparc/include/asm/siginfo.h
+++ b/arch/sparc/include/asm/siginfo.h
@@ -1,8 +1,37 @@
1#ifndef ___ASM_SPARC_SIGINFO_H 1#ifndef __SPARC_SIGINFO_H
2#define ___ASM_SPARC_SIGINFO_H 2#define __SPARC_SIGINFO_H
3
3#if defined(__sparc__) && defined(__arch64__) 4#if defined(__sparc__) && defined(__arch64__)
4#include <asm/siginfo_64.h> 5
5#else 6#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
6#include <asm/siginfo_32.h> 7#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
7#endif 8#define __ARCH_SI_BAND_T int
8#endif 9
10#endif /* defined(__sparc__) && defined(__arch64__) */
11
12
13#define __ARCH_SI_TRAPNO
14
15#include <asm-generic/siginfo.h>
16
17#ifdef __KERNEL__
18
19#include <linux/compat.h>
20
21#ifdef CONFIG_COMPAT
22
23struct compat_siginfo;
24
25#endif /* CONFIG_COMPAT */
26
27#endif /* __KERNEL__ */
28
29#define SI_NOINFO 32767 /* no information in siginfo_t */
30
31/*
32 * SIGEMT si_codes
33 */
34#define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */
35#define NSIGEMT 1
36
37#endif /* !(__SPARC_SIGINFO_H) */
diff --git a/arch/sparc/include/asm/siginfo_32.h b/arch/sparc/include/asm/siginfo_32.h
deleted file mode 100644
index 3c71af135c52..000000000000
--- a/arch/sparc/include/asm/siginfo_32.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _SPARC_SIGINFO_H
2#define _SPARC_SIGINFO_H
3
4#define __ARCH_SI_UID_T unsigned int
5#define __ARCH_SI_TRAPNO
6
7#include <asm-generic/siginfo.h>
8
9#define SI_NOINFO 32767 /* no information in siginfo_t */
10
11/*
12 * SIGEMT si_codes
13 */
14#define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */
15#define NSIGEMT 1
16
17#endif /* !(_SPARC_SIGINFO_H) */
diff --git a/arch/sparc/include/asm/siginfo_64.h b/arch/sparc/include/asm/siginfo_64.h
deleted file mode 100644
index c96e6c30f8b0..000000000000
--- a/arch/sparc/include/asm/siginfo_64.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef _SPARC64_SIGINFO_H
2#define _SPARC64_SIGINFO_H
3
4#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
5
6#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
7#define __ARCH_SI_TRAPNO
8#define __ARCH_SI_BAND_T int
9
10#include <asm-generic/siginfo.h>
11
12#ifdef __KERNEL__
13
14#include <linux/compat.h>
15
16#ifdef CONFIG_COMPAT
17
18struct compat_siginfo;
19
20#endif /* CONFIG_COMPAT */
21
22#endif /* __KERNEL__ */
23
24#define SI_NOINFO 32767 /* no information in siginfo_t */
25
26/*
27 * SIGEMT si_codes
28 */
29#define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */
30#define NSIGEMT 1
31
32#endif
diff --git a/arch/sparc/include/asm/signal.h b/arch/sparc/include/asm/signal.h
index 27ab05dc203e..41535e77b255 100644
--- a/arch/sparc/include/asm/signal.h
+++ b/arch/sparc/include/asm/signal.h
@@ -1,8 +1,210 @@
1#ifndef ___ASM_SPARC_SIGNAL_H 1#ifndef __SPARC_SIGNAL_H
2#define ___ASM_SPARC_SIGNAL_H 2#define __SPARC_SIGNAL_H
3#if defined(__sparc__) && defined(__arch64__) 3
4#include <asm/signal_64.h> 4#include <asm/sigcontext.h>
5#include <linux/compiler.h>
6
7#ifdef __KERNEL__
8#ifndef __ASSEMBLY__
9#include <linux/personality.h>
10#include <linux/types.h>
11#endif
12#endif
13
14/* On the Sparc the signal handlers get passed a 'sub-signal' code
15 * for certain signal types, which we document here.
16 */
17#define SIGHUP 1
18#define SIGINT 2
19#define SIGQUIT 3
20#define SIGILL 4
21#define SUBSIG_STACK 0
22#define SUBSIG_ILLINST 2
23#define SUBSIG_PRIVINST 3
24#define SUBSIG_BADTRAP(t) (0x80 + (t))
25
26#define SIGTRAP 5
27#define SIGABRT 6
28#define SIGIOT 6
29
30#define SIGEMT 7
31#define SUBSIG_TAG 10
32
33#define SIGFPE 8
34#define SUBSIG_FPDISABLED 0x400
35#define SUBSIG_FPERROR 0x404
36#define SUBSIG_FPINTOVFL 0x001
37#define SUBSIG_FPSTSIG 0x002
38#define SUBSIG_IDIVZERO 0x014
39#define SUBSIG_FPINEXACT 0x0c4
40#define SUBSIG_FPDIVZERO 0x0c8
41#define SUBSIG_FPUNFLOW 0x0cc
42#define SUBSIG_FPOPERROR 0x0d0
43#define SUBSIG_FPOVFLOW 0x0d4
44
45#define SIGKILL 9
46#define SIGBUS 10
47#define SUBSIG_BUSTIMEOUT 1
48#define SUBSIG_ALIGNMENT 2
49#define SUBSIG_MISCERROR 5
50
51#define SIGSEGV 11
52#define SUBSIG_NOMAPPING 3
53#define SUBSIG_PROTECTION 4
54#define SUBSIG_SEGERROR 5
55
56#define SIGSYS 12
57
58#define SIGPIPE 13
59#define SIGALRM 14
60#define SIGTERM 15
61#define SIGURG 16
62
63/* SunOS values which deviate from the Linux/i386 ones */
64#define SIGSTOP 17
65#define SIGTSTP 18
66#define SIGCONT 19
67#define SIGCHLD 20
68#define SIGTTIN 21
69#define SIGTTOU 22
70#define SIGIO 23
71#define SIGPOLL SIGIO /* SysV name for SIGIO */
72#define SIGXCPU 24
73#define SIGXFSZ 25
74#define SIGVTALRM 26
75#define SIGPROF 27
76#define SIGWINCH 28
77#define SIGLOST 29
78#define SIGPWR SIGLOST
79#define SIGUSR1 30
80#define SIGUSR2 31
81
82/* Most things should be clean enough to redefine this at will, if care
83 is taken to make libc match. */
84
85#define __OLD_NSIG 32
86#define __NEW_NSIG 64
87#define _NSIG_BPW 64
88#define _NSIG_WORDS (__NEW_NSIG / _NSIG_BPW)
89
90#define SIGRTMIN 32
91#define SIGRTMAX __NEW_NSIG
92
93#if defined(__KERNEL__) || defined(__WANT_POSIX1B_SIGNALS__)
94#define _NSIG __NEW_NSIG
95#define __new_sigset_t sigset_t
96#define __new_sigaction sigaction
97#define __new_sigaction32 sigaction32
98#define __old_sigset_t old_sigset_t
99#define __old_sigaction old_sigaction
100#define __old_sigaction32 old_sigaction32
5#else 101#else
6#include <asm/signal_32.h> 102#define _NSIG __OLD_NSIG
103#define NSIG _NSIG
104#define __old_sigset_t sigset_t
105#define __old_sigaction sigaction
106#define __old_sigaction32 sigaction32
7#endif 107#endif
108
109#ifndef __ASSEMBLY__
110
111typedef unsigned long __old_sigset_t; /* at least 32 bits */
112
113typedef struct {
114 unsigned long sig[_NSIG_WORDS];
115} __new_sigset_t;
116
117/* A SunOS sigstack */
118struct sigstack {
119 /* XXX 32-bit pointers pinhead XXX */
120 char *the_stack;
121 int cur_status;
122};
123
124/* Sigvec flags */
125#define _SV_SSTACK 1u /* This signal handler should use sig-stack */
126#define _SV_INTR 2u /* Sig return should not restart system call */
127#define _SV_RESET 4u /* Set handler to SIG_DFL upon taken signal */
128#define _SV_IGNCHILD 8u /* Do not send SIGCHLD */
129
130/*
131 * sa_flags values: SA_STACK is not currently supported, but will allow the
132 * usage of signal stacks by using the (now obsolete) sa_restorer field in
133 * the sigaction structure as a stack pointer. This is now possible due to
134 * the changes in signal handling. LBT 010493.
135 * SA_RESTART flag to get restarting signals (which were the default long ago)
136 */
137#define SA_NOCLDSTOP _SV_IGNCHILD
138#define SA_STACK _SV_SSTACK
139#define SA_ONSTACK _SV_SSTACK
140#define SA_RESTART _SV_INTR
141#define SA_ONESHOT _SV_RESET
142#define SA_NOMASK 0x20u
143#define SA_NOCLDWAIT 0x100u
144#define SA_SIGINFO 0x200u
145
146
147#define SIG_BLOCK 0x01 /* for blocking signals */
148#define SIG_UNBLOCK 0x02 /* for unblocking signals */
149#define SIG_SETMASK 0x04 /* for setting the signal mask */
150
151/*
152 * sigaltstack controls
153 */
154#define SS_ONSTACK 1
155#define SS_DISABLE 2
156
157#define MINSIGSTKSZ 4096
158#define SIGSTKSZ 16384
159
160#ifdef __KERNEL__
161/*
162 * DJHR
163 * SA_STATIC_ALLOC is used for the sparc32 system to indicate that this
164 * interrupt handler's irq structure should be statically allocated
165 * by the request_irq routine.
166 * The alternative is that arch/sparc/kernel/irq.c has carnal knowledge
167 * of interrupt usage and that sucks. Also without a flag like this
168 * it may be possible for the free_irq routine to attempt to free
169 * statically allocated data.. which is NOT GOOD.
170 *
171 */
172#define SA_STATIC_ALLOC 0x8000
8#endif 173#endif
174
175#include <asm-generic/signal.h>
176
177struct __new_sigaction {
178 __sighandler_t sa_handler;
179 unsigned long sa_flags;
180 __sigrestore_t sa_restorer; /* not used by Linux/SPARC yet */
181 __new_sigset_t sa_mask;
182};
183
184struct __old_sigaction {
185 __sighandler_t sa_handler;
186 __old_sigset_t sa_mask;
187 unsigned long sa_flags;
188 void (*sa_restorer)(void); /* not used by Linux/SPARC yet */
189};
190
191typedef struct sigaltstack {
192 void __user *ss_sp;
193 int ss_flags;
194 size_t ss_size;
195} stack_t;
196
197#ifdef __KERNEL__
198
199struct k_sigaction {
200 struct __new_sigaction sa;
201 void __user *ka_restorer;
202};
203
204#define ptrace_signal_deliver(regs, cookie) do { } while (0)
205
206#endif /* !(__KERNEL__) */
207
208#endif /* !(__ASSEMBLY__) */
209
210#endif /* !(__SPARC_SIGNAL_H) */
diff --git a/arch/sparc/include/asm/signal_32.h b/arch/sparc/include/asm/signal_32.h
deleted file mode 100644
index 96a60ab03ca1..000000000000
--- a/arch/sparc/include/asm/signal_32.h
+++ /dev/null
@@ -1,207 +0,0 @@
1#ifndef _ASMSPARC_SIGNAL_H
2#define _ASMSPARC_SIGNAL_H
3
4#include <asm/sigcontext.h>
5#include <linux/compiler.h>
6
7#ifdef __KERNEL__
8#ifndef __ASSEMBLY__
9#include <linux/personality.h>
10#include <linux/types.h>
11#endif
12#endif
13
14/* On the Sparc the signal handlers get passed a 'sub-signal' code
15 * for certain signal types, which we document here.
16 */
17#define SIGHUP 1
18#define SIGINT 2
19#define SIGQUIT 3
20#define SIGILL 4
21#define SUBSIG_STACK 0
22#define SUBSIG_ILLINST 2
23#define SUBSIG_PRIVINST 3
24#define SUBSIG_BADTRAP(t) (0x80 + (t))
25
26#define SIGTRAP 5
27#define SIGABRT 6
28#define SIGIOT 6
29
30#define SIGEMT 7
31#define SUBSIG_TAG 10
32
33#define SIGFPE 8
34#define SUBSIG_FPDISABLED 0x400
35#define SUBSIG_FPERROR 0x404
36#define SUBSIG_FPINTOVFL 0x001
37#define SUBSIG_FPSTSIG 0x002
38#define SUBSIG_IDIVZERO 0x014
39#define SUBSIG_FPINEXACT 0x0c4
40#define SUBSIG_FPDIVZERO 0x0c8
41#define SUBSIG_FPUNFLOW 0x0cc
42#define SUBSIG_FPOPERROR 0x0d0
43#define SUBSIG_FPOVFLOW 0x0d4
44
45#define SIGKILL 9
46#define SIGBUS 10
47#define SUBSIG_BUSTIMEOUT 1
48#define SUBSIG_ALIGNMENT 2
49#define SUBSIG_MISCERROR 5
50
51#define SIGSEGV 11
52#define SUBSIG_NOMAPPING 3
53#define SUBSIG_PROTECTION 4
54#define SUBSIG_SEGERROR 5
55
56#define SIGSYS 12
57
58#define SIGPIPE 13
59#define SIGALRM 14
60#define SIGTERM 15
61#define SIGURG 16
62
63/* SunOS values which deviate from the Linux/i386 ones */
64#define SIGSTOP 17
65#define SIGTSTP 18
66#define SIGCONT 19
67#define SIGCHLD 20
68#define SIGTTIN 21
69#define SIGTTOU 22
70#define SIGIO 23
71#define SIGPOLL SIGIO /* SysV name for SIGIO */
72#define SIGXCPU 24
73#define SIGXFSZ 25
74#define SIGVTALRM 26
75#define SIGPROF 27
76#define SIGWINCH 28
77#define SIGLOST 29
78#define SIGPWR SIGLOST
79#define SIGUSR1 30
80#define SIGUSR2 31
81
82/* Most things should be clean enough to redefine this at will, if care
83 * is taken to make libc match.
84 */
85
86#define __OLD_NSIG 32
87#define __NEW_NSIG 64
88#define _NSIG_BPW 32
89#define _NSIG_WORDS (__NEW_NSIG / _NSIG_BPW)
90
91#define SIGRTMIN 32
92#define SIGRTMAX __NEW_NSIG
93
94#if defined(__KERNEL__) || defined(__WANT_POSIX1B_SIGNALS__)
95#define _NSIG __NEW_NSIG
96#define __new_sigset_t sigset_t
97#define __new_sigaction sigaction
98#define __old_sigset_t old_sigset_t
99#define __old_sigaction old_sigaction
100#else
101#define _NSIG __OLD_NSIG
102#define __old_sigset_t sigset_t
103#define __old_sigaction sigaction
104#endif
105
106#ifndef __ASSEMBLY__
107
108typedef unsigned long __old_sigset_t;
109
110typedef struct {
111 unsigned long sig[_NSIG_WORDS];
112} __new_sigset_t;
113
114
115#ifdef __KERNEL__
116/* A SunOS sigstack */
117struct sigstack {
118 char *the_stack;
119 int cur_status;
120};
121#endif
122
123/* Sigvec flags */
124#define _SV_SSTACK 1u /* This signal handler should use sig-stack */
125#define _SV_INTR 2u /* Sig return should not restart system call */
126#define _SV_RESET 4u /* Set handler to SIG_DFL upon taken signal */
127#define _SV_IGNCHILD 8u /* Do not send SIGCHLD */
128
129/*
130 * sa_flags values: SA_STACK is not currently supported, but will allow the
131 * usage of signal stacks by using the (now obsolete) sa_restorer field in
132 * the sigaction structure as a stack pointer. This is now possible due to
133 * the changes in signal handling. LBT 010493.
134 * SA_RESTART flag to get restarting signals (which were the default long ago)
135 */
136#define SA_NOCLDSTOP _SV_IGNCHILD
137#define SA_STACK _SV_SSTACK
138#define SA_ONSTACK _SV_SSTACK
139#define SA_RESTART _SV_INTR
140#define SA_ONESHOT _SV_RESET
141#define SA_NOMASK 0x20u
142#define SA_NOCLDWAIT 0x100u
143#define SA_SIGINFO 0x200u
144
145#define SIG_BLOCK 0x01 /* for blocking signals */
146#define SIG_UNBLOCK 0x02 /* for unblocking signals */
147#define SIG_SETMASK 0x04 /* for setting the signal mask */
148
149/*
150 * sigaltstack controls
151 */
152#define SS_ONSTACK 1
153#define SS_DISABLE 2
154
155#define MINSIGSTKSZ 4096
156#define SIGSTKSZ 16384
157
158#ifdef __KERNEL__
159/*
160 * DJHR
161 * SA_STATIC_ALLOC is used for the SPARC system to indicate that this
162 * interrupt handler's irq structure should be statically allocated
163 * by the request_irq routine.
164 * The alternative is that arch/sparc/kernel/irq.c has carnal knowledge
165 * of interrupt usage and that sucks. Also without a flag like this
166 * it may be possible for the free_irq routine to attempt to free
167 * statically allocated data.. which is NOT GOOD.
168 *
169 */
170#define SA_STATIC_ALLOC 0x8000
171#endif
172
173#include <asm-generic/signal.h>
174
175#ifdef __KERNEL__
176struct __new_sigaction {
177 __sighandler_t sa_handler;
178 unsigned long sa_flags;
179 void (*sa_restorer)(void); /* Not used by Linux/SPARC */
180 __new_sigset_t sa_mask;
181};
182
183struct k_sigaction {
184 struct __new_sigaction sa;
185 void __user *ka_restorer;
186};
187
188struct __old_sigaction {
189 __sighandler_t sa_handler;
190 __old_sigset_t sa_mask;
191 unsigned long sa_flags;
192 void (*sa_restorer) (void); /* not used by Linux/SPARC */
193};
194
195typedef struct sigaltstack {
196 void __user *ss_sp;
197 int ss_flags;
198 size_t ss_size;
199} stack_t;
200
201#define ptrace_signal_deliver(regs, cookie) do { } while (0)
202
203#endif /* !(__KERNEL__) */
204
205#endif /* !(__ASSEMBLY__) */
206
207#endif /* !(_ASMSPARC_SIGNAL_H) */
diff --git a/arch/sparc/include/asm/signal_64.h b/arch/sparc/include/asm/signal_64.h
deleted file mode 100644
index ab1509a101c5..000000000000
--- a/arch/sparc/include/asm/signal_64.h
+++ /dev/null
@@ -1,194 +0,0 @@
1#ifndef _ASMSPARC64_SIGNAL_H
2#define _ASMSPARC64_SIGNAL_H
3
4#include <asm/sigcontext.h>
5
6#ifdef __KERNEL__
7#ifndef __ASSEMBLY__
8#include <linux/personality.h>
9#include <linux/types.h>
10#endif
11#endif
12
13/* On the Sparc the signal handlers get passed a 'sub-signal' code
14 * for certain signal types, which we document here.
15 */
16#define SIGHUP 1
17#define SIGINT 2
18#define SIGQUIT 3
19#define SIGILL 4
20#define SUBSIG_STACK 0
21#define SUBSIG_ILLINST 2
22#define SUBSIG_PRIVINST 3
23#define SUBSIG_BADTRAP(t) (0x80 + (t))
24
25#define SIGTRAP 5
26#define SIGABRT 6
27#define SIGIOT 6
28
29#define SIGEMT 7
30#define SUBSIG_TAG 10
31
32#define SIGFPE 8
33#define SUBSIG_FPDISABLED 0x400
34#define SUBSIG_FPERROR 0x404
35#define SUBSIG_FPINTOVFL 0x001
36#define SUBSIG_FPSTSIG 0x002
37#define SUBSIG_IDIVZERO 0x014
38#define SUBSIG_FPINEXACT 0x0c4
39#define SUBSIG_FPDIVZERO 0x0c8
40#define SUBSIG_FPUNFLOW 0x0cc
41#define SUBSIG_FPOPERROR 0x0d0
42#define SUBSIG_FPOVFLOW 0x0d4
43
44#define SIGKILL 9
45#define SIGBUS 10
46#define SUBSIG_BUSTIMEOUT 1
47#define SUBSIG_ALIGNMENT 2
48#define SUBSIG_MISCERROR 5
49
50#define SIGSEGV 11
51#define SUBSIG_NOMAPPING 3
52#define SUBSIG_PROTECTION 4
53#define SUBSIG_SEGERROR 5
54
55#define SIGSYS 12
56
57#define SIGPIPE 13
58#define SIGALRM 14
59#define SIGTERM 15
60#define SIGURG 16
61
62/* SunOS values which deviate from the Linux/i386 ones */
63#define SIGSTOP 17
64#define SIGTSTP 18
65#define SIGCONT 19
66#define SIGCHLD 20
67#define SIGTTIN 21
68#define SIGTTOU 22
69#define SIGIO 23
70#define SIGPOLL SIGIO /* SysV name for SIGIO */
71#define SIGXCPU 24
72#define SIGXFSZ 25
73#define SIGVTALRM 26
74#define SIGPROF 27
75#define SIGWINCH 28
76#define SIGLOST 29
77#define SIGPWR SIGLOST
78#define SIGUSR1 30
79#define SIGUSR2 31
80
81/* Most things should be clean enough to redefine this at will, if care
82 is taken to make libc match. */
83
84#define __OLD_NSIG 32
85#define __NEW_NSIG 64
86#define _NSIG_BPW 64
87#define _NSIG_WORDS (__NEW_NSIG / _NSIG_BPW)
88
89#define SIGRTMIN 32
90#define SIGRTMAX __NEW_NSIG
91
92#if defined(__KERNEL__) || defined(__WANT_POSIX1B_SIGNALS__)
93#define _NSIG __NEW_NSIG
94#define __new_sigset_t sigset_t
95#define __new_sigaction sigaction
96#define __new_sigaction32 sigaction32
97#define __old_sigset_t old_sigset_t
98#define __old_sigaction old_sigaction
99#define __old_sigaction32 old_sigaction32
100#else
101#define _NSIG __OLD_NSIG
102#define NSIG _NSIG
103#define __old_sigset_t sigset_t
104#define __old_sigaction sigaction
105#define __old_sigaction32 sigaction32
106#endif
107
108#ifndef __ASSEMBLY__
109
110typedef unsigned long __old_sigset_t; /* at least 32 bits */
111
112typedef struct {
113 unsigned long sig[_NSIG_WORDS];
114} __new_sigset_t;
115
116/* A SunOS sigstack */
117struct sigstack {
118 /* XXX 32-bit pointers pinhead XXX */
119 char *the_stack;
120 int cur_status;
121};
122
123/* Sigvec flags */
124#define _SV_SSTACK 1u /* This signal handler should use sig-stack */
125#define _SV_INTR 2u /* Sig return should not restart system call */
126#define _SV_RESET 4u /* Set handler to SIG_DFL upon taken signal */
127#define _SV_IGNCHILD 8u /* Do not send SIGCHLD */
128
129/*
130 * sa_flags values: SA_STACK is not currently supported, but will allow the
131 * usage of signal stacks by using the (now obsolete) sa_restorer field in
132 * the sigaction structure as a stack pointer. This is now possible due to
133 * the changes in signal handling. LBT 010493.
134 * SA_RESTART flag to get restarting signals (which were the default long ago)
135 */
136#define SA_NOCLDSTOP _SV_IGNCHILD
137#define SA_STACK _SV_SSTACK
138#define SA_ONSTACK _SV_SSTACK
139#define SA_RESTART _SV_INTR
140#define SA_ONESHOT _SV_RESET
141#define SA_NOMASK 0x20u
142#define SA_NOCLDWAIT 0x100u
143#define SA_SIGINFO 0x200u
144
145
146#define SIG_BLOCK 0x01 /* for blocking signals */
147#define SIG_UNBLOCK 0x02 /* for unblocking signals */
148#define SIG_SETMASK 0x04 /* for setting the signal mask */
149
150/*
151 * sigaltstack controls
152 */
153#define SS_ONSTACK 1
154#define SS_DISABLE 2
155
156#define MINSIGSTKSZ 4096
157#define SIGSTKSZ 16384
158
159#include <asm-generic/signal.h>
160
161struct __new_sigaction {
162 __sighandler_t sa_handler;
163 unsigned long sa_flags;
164 __sigrestore_t sa_restorer; /* not used by Linux/SPARC yet */
165 __new_sigset_t sa_mask;
166};
167
168struct __old_sigaction {
169 __sighandler_t sa_handler;
170 __old_sigset_t sa_mask;
171 unsigned long sa_flags;
172 void (*sa_restorer)(void); /* not used by Linux/SPARC yet */
173};
174
175typedef struct sigaltstack {
176 void __user *ss_sp;
177 int ss_flags;
178 size_t ss_size;
179} stack_t;
180
181#ifdef __KERNEL__
182
183struct k_sigaction {
184 struct __new_sigaction sa;
185 void __user *ka_restorer;
186};
187
188#define ptrace_signal_deliver(regs, cookie) do { } while (0)
189
190#endif /* !(__KERNEL__) */
191
192#endif /* !(__ASSEMBLY__) */
193
194#endif /* !(_ASMSPARC64_SIGNAL_H) */
diff --git a/arch/sparc/include/asm/smp_32.h b/arch/sparc/include/asm/smp_32.h
index 8408d9d2a662..58101dc70493 100644
--- a/arch/sparc/include/asm/smp_32.h
+++ b/arch/sparc/include/asm/smp_32.h
@@ -170,7 +170,4 @@ void smp_setup_cpu_possible_map(void);
170#define smp_setup_cpu_possible_map() do { } while (0) 170#define smp_setup_cpu_possible_map() do { } while (0)
171 171
172#endif /* !(SMP) */ 172#endif /* !(SMP) */
173
174#define NO_PROC_ID 0xFF
175
176#endif /* !(_SPARC_SMP_H) */ 173#endif /* !(_SPARC_SMP_H) */
diff --git a/arch/sparc/include/asm/stat.h b/arch/sparc/include/asm/stat.h
index d8153013df72..55db5eca08e2 100644
--- a/arch/sparc/include/asm/stat.h
+++ b/arch/sparc/include/asm/stat.h
@@ -1,8 +1,107 @@
1#ifndef ___ASM_SPARC_STAT_H 1#ifndef __SPARC_STAT_H
2#define ___ASM_SPARC_STAT_H 2#define __SPARC_STAT_H
3
4#include <linux/types.h>
5
3#if defined(__sparc__) && defined(__arch64__) 6#if defined(__sparc__) && defined(__arch64__)
4#include <asm/stat_64.h> 7/* 64 bit sparc */
8struct stat {
9 unsigned st_dev;
10 ino_t st_ino;
11 mode_t st_mode;
12 short st_nlink;
13 uid_t st_uid;
14 gid_t st_gid;
15 unsigned st_rdev;
16 off_t st_size;
17 time_t st_atime;
18 time_t st_mtime;
19 time_t st_ctime;
20 off_t st_blksize;
21 off_t st_blocks;
22 unsigned long __unused4[2];
23};
24
25struct stat64 {
26 unsigned long st_dev;
27 unsigned long st_ino;
28 unsigned long st_nlink;
29
30 unsigned int st_mode;
31 unsigned int st_uid;
32 unsigned int st_gid;
33 unsigned int __pad0;
34
35 unsigned long st_rdev;
36 long st_size;
37 long st_blksize;
38 long st_blocks;
39
40 unsigned long st_atime;
41 unsigned long st_atime_nsec;
42 unsigned long st_mtime;
43 unsigned long st_mtime_nsec;
44 unsigned long st_ctime;
45 unsigned long st_ctime_nsec;
46 long __unused[3];
47};
48
5#else 49#else
6#include <asm/stat_32.h> 50/* 32 bit sparc */
7#endif 51struct stat {
8#endif 52 unsigned short st_dev;
53 ino_t st_ino;
54 mode_t st_mode;
55 short st_nlink;
56 uid_t st_uid;
57 gid_t st_gid;
58 unsigned short st_rdev;
59 off_t st_size;
60 time_t st_atime;
61 unsigned long st_atime_nsec;
62 time_t st_mtime;
63 unsigned long st_mtime_nsec;
64 time_t st_ctime;
65 unsigned long st_ctime_nsec;
66 off_t st_blksize;
67 off_t st_blocks;
68 unsigned long __unused4[2];
69};
70
71#define STAT_HAVE_NSEC 1
72
73struct stat64 {
74 unsigned long long st_dev;
75
76 unsigned long long st_ino;
77
78 unsigned int st_mode;
79 unsigned int st_nlink;
80
81 unsigned int st_uid;
82 unsigned int st_gid;
83
84 unsigned long long st_rdev;
85
86 unsigned char __pad3[8];
87
88 long long st_size;
89 unsigned int st_blksize;
90
91 unsigned char __pad4[8];
92 unsigned int st_blocks;
93
94 unsigned int st_atime;
95 unsigned int st_atime_nsec;
96
97 unsigned int st_mtime;
98 unsigned int st_mtime_nsec;
99
100 unsigned int st_ctime;
101 unsigned int st_ctime_nsec;
102
103 unsigned int __unused4;
104 unsigned int __unused5;
105};
106#endif /* defined(__sparc__) && defined(__arch64__) */
107#endif /* __SPARC_STAT_H */
diff --git a/arch/sparc/include/asm/stat_32.h b/arch/sparc/include/asm/stat_32.h
deleted file mode 100644
index 2299e1d5d94c..000000000000
--- a/arch/sparc/include/asm/stat_32.h
+++ /dev/null
@@ -1,76 +0,0 @@
1#ifndef _SPARC_STAT_H
2#define _SPARC_STAT_H
3
4#include <linux/types.h>
5
6struct __old_kernel_stat {
7 unsigned short st_dev;
8 unsigned short st_ino;
9 unsigned short st_mode;
10 unsigned short st_nlink;
11 unsigned short st_uid;
12 unsigned short st_gid;
13 unsigned short st_rdev;
14 unsigned long st_size;
15 unsigned long st_atime;
16 unsigned long st_mtime;
17 unsigned long st_ctime;
18};
19
20struct stat {
21 unsigned short st_dev;
22 unsigned long st_ino;
23 unsigned short st_mode;
24 short st_nlink;
25 unsigned short st_uid;
26 unsigned short st_gid;
27 unsigned short st_rdev;
28 long st_size;
29 long st_atime;
30 unsigned long st_atime_nsec;
31 long st_mtime;
32 unsigned long st_mtime_nsec;
33 long st_ctime;
34 unsigned long st_ctime_nsec;
35 long st_blksize;
36 long st_blocks;
37 unsigned long __unused4[2];
38};
39
40#define STAT_HAVE_NSEC 1
41
42struct stat64 {
43 unsigned long long st_dev;
44
45 unsigned long long st_ino;
46
47 unsigned int st_mode;
48 unsigned int st_nlink;
49
50 unsigned int st_uid;
51 unsigned int st_gid;
52
53 unsigned long long st_rdev;
54
55 unsigned char __pad3[8];
56
57 long long st_size;
58 unsigned int st_blksize;
59
60 unsigned char __pad4[8];
61 unsigned int st_blocks;
62
63 unsigned int st_atime;
64 unsigned int st_atime_nsec;
65
66 unsigned int st_mtime;
67 unsigned int st_mtime_nsec;
68
69 unsigned int st_ctime;
70 unsigned int st_ctime_nsec;
71
72 unsigned int __unused4;
73 unsigned int __unused5;
74};
75
76#endif
diff --git a/arch/sparc/include/asm/stat_64.h b/arch/sparc/include/asm/stat_64.h
deleted file mode 100644
index 9650fdea847f..000000000000
--- a/arch/sparc/include/asm/stat_64.h
+++ /dev/null
@@ -1,47 +0,0 @@
1#ifndef _SPARC64_STAT_H
2#define _SPARC64_STAT_H
3
4#include <linux/types.h>
5
6struct stat {
7 unsigned st_dev;
8 ino_t st_ino;
9 mode_t st_mode;
10 short st_nlink;
11 uid_t st_uid;
12 gid_t st_gid;
13 unsigned st_rdev;
14 off_t st_size;
15 time_t st_atime;
16 time_t st_mtime;
17 time_t st_ctime;
18 off_t st_blksize;
19 off_t st_blocks;
20 unsigned long __unused4[2];
21};
22
23struct stat64 {
24 unsigned long st_dev;
25 unsigned long st_ino;
26 unsigned long st_nlink;
27
28 unsigned int st_mode;
29 unsigned int st_uid;
30 unsigned int st_gid;
31 unsigned int __pad0;
32
33 unsigned long st_rdev;
34 long st_size;
35 long st_blksize;
36 long st_blocks;
37
38 unsigned long st_atime;
39 unsigned long st_atime_nsec;
40 unsigned long st_mtime;
41 unsigned long st_mtime_nsec;
42 unsigned long st_ctime;
43 unsigned long st_ctime_nsec;
44 long __unused[3];
45};
46
47#endif
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index 80fe547c3f45..0f7b0e5fb1c7 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -45,7 +45,7 @@ struct thread_info {
45 /* A place to store user windows and stack pointers 45 /* A place to store user windows and stack pointers
46 * when the stack needs inspection. 46 * when the stack needs inspection.
47 */ 47 */
48 struct reg_window reg_window[NSWINS]; /* align for ldd! */ 48 struct reg_window32 reg_window[NSWINS]; /* align for ldd! */
49 unsigned long rwbuf_stkptrs[NSWINS]; 49 unsigned long rwbuf_stkptrs[NSWINS];
50 unsigned long w_saved; 50 unsigned long w_saved;
51 51
diff --git a/arch/sparc/include/asm/topology_64.h b/arch/sparc/include/asm/topology_64.h
index 001c04027c82..b8a65b64e1df 100644
--- a/arch/sparc/include/asm/topology_64.h
+++ b/arch/sparc/include/asm/topology_64.h
@@ -16,8 +16,12 @@ static inline cpumask_t node_to_cpumask(int node)
16{ 16{
17 return numa_cpumask_lookup_table[node]; 17 return numa_cpumask_lookup_table[node];
18} 18}
19#define cpumask_of_node(node) (&numa_cpumask_lookup_table[node])
19 20
20/* Returns a pointer to the cpumask of CPUs on Node 'node'. */ 21/*
22 * Returns a pointer to the cpumask of CPUs on Node 'node'.
23 * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
24 */
21#define node_to_cpumask_ptr(v, node) \ 25#define node_to_cpumask_ptr(v, node) \
22 cpumask_t *v = &(numa_cpumask_lookup_table[node]) 26 cpumask_t *v = &(numa_cpumask_lookup_table[node])
23 27
@@ -26,9 +30,7 @@ static inline cpumask_t node_to_cpumask(int node)
26 30
27static inline int node_to_first_cpu(int node) 31static inline int node_to_first_cpu(int node)
28{ 32{
29 cpumask_t tmp; 33 return cpumask_first(cpumask_of_node(node));
30 tmp = node_to_cpumask(node);
31 return first_cpu(tmp);
32} 34}
33 35
34struct pci_bus; 36struct pci_bus;
@@ -77,10 +79,13 @@ static inline int pcibus_to_node(struct pci_bus *pbus)
77#define topology_core_id(cpu) (cpu_data(cpu).core_id) 79#define topology_core_id(cpu) (cpu_data(cpu).core_id)
78#define topology_core_siblings(cpu) (cpu_core_map[cpu]) 80#define topology_core_siblings(cpu) (cpu_core_map[cpu])
79#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 81#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
82#define topology_core_cpumask(cpu) (&cpu_core_map[cpu])
83#define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
80#define mc_capable() (sparc64_multi_core) 84#define mc_capable() (sparc64_multi_core)
81#define smt_capable() (sparc64_multi_core) 85#define smt_capable() (sparc64_multi_core)
82#endif /* CONFIG_SMP */ 86#endif /* CONFIG_SMP */
83 87
84#define cpu_coregroup_map(cpu) (cpu_core_map[cpu]) 88#define cpu_coregroup_map(cpu) (cpu_core_map[cpu])
89#define cpu_coregroup_mask(cpu) (&cpu_core_map[cpu])
85 90
86#endif /* _ASM_SPARC64_TOPOLOGY_H */ 91#endif /* _ASM_SPARC64_TOPOLOGY_H */
diff --git a/arch/sparc/include/asm/traps.h b/arch/sparc/include/asm/traps.h
index bebdbf8f43a8..3aa62dde343f 100644
--- a/arch/sparc/include/asm/traps.h
+++ b/arch/sparc/include/asm/traps.h
@@ -10,7 +10,7 @@
10#define NUM_SPARC_TRAPS 255 10#define NUM_SPARC_TRAPS 255
11 11
12#ifndef __ASSEMBLY__ 12#ifndef __ASSEMBLY__
13 13#ifdef __KERNEL__
14/* This is for V8 compliant Sparc CPUS */ 14/* This is for V8 compliant Sparc CPUS */
15struct tt_entry { 15struct tt_entry {
16 unsigned long inst_one; 16 unsigned long inst_one;
@@ -22,14 +22,7 @@ struct tt_entry {
22/* We set this to _start in system setup. */ 22/* We set this to _start in system setup. */
23extern struct tt_entry *sparc_ttable; 23extern struct tt_entry *sparc_ttable;
24 24
25static inline unsigned long get_tbr(void) 25#endif /* (__KERNEL__) */
26{
27 unsigned long tbr;
28
29 __asm__ __volatile__("rd %%tbr, %0\n\t" : "=r" (tbr));
30 return tbr;
31}
32
33#endif /* !(__ASSEMBLY__) */ 26#endif /* !(__ASSEMBLY__) */
34 27
35/* For patching the trap table at boot time, we need to know how to 28/* For patching the trap table at boot time, we need to know how to
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index f3488c45d57a..1eff942fe22f 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -669,7 +669,9 @@ void __init init_IRQ(void)
669 btfixup(); 669 btfixup();
670} 670}
671 671
672#ifdef CONFIG_PROC_FS
672void init_irq_proc(void) 673void init_irq_proc(void)
673{ 674{
674 /* For now, nothing... */ 675 /* For now, nothing... */
675} 676}
677#endif /* CONFIG_PROC_FS */
diff --git a/arch/sparc/kernel/kgdb_32.c b/arch/sparc/kernel/kgdb_32.c
index 757805ce02ee..04df4edc0073 100644
--- a/arch/sparc/kernel/kgdb_32.c
+++ b/arch/sparc/kernel/kgdb_32.c
@@ -14,14 +14,14 @@ extern unsigned long trapbase;
14 14
15void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) 15void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
16{ 16{
17 struct reg_window *win; 17 struct reg_window32 *win;
18 int i; 18 int i;
19 19
20 gdb_regs[GDB_G0] = 0; 20 gdb_regs[GDB_G0] = 0;
21 for (i = 0; i < 15; i++) 21 for (i = 0; i < 15; i++)
22 gdb_regs[GDB_G1 + i] = regs->u_regs[UREG_G1 + i]; 22 gdb_regs[GDB_G1 + i] = regs->u_regs[UREG_G1 + i];
23 23
24 win = (struct reg_window *) regs->u_regs[UREG_FP]; 24 win = (struct reg_window32 *) regs->u_regs[UREG_FP];
25 for (i = 0; i < 8; i++) 25 for (i = 0; i < 8; i++)
26 gdb_regs[GDB_L0 + i] = win->locals[i]; 26 gdb_regs[GDB_L0 + i] = win->locals[i];
27 for (i = 0; i < 8; i++) 27 for (i = 0; i < 8; i++)
@@ -43,7 +43,7 @@ void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
43void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) 43void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
44{ 44{
45 struct thread_info *t = task_thread_info(p); 45 struct thread_info *t = task_thread_info(p);
46 struct reg_window *win; 46 struct reg_window32 *win;
47 int i; 47 int i;
48 48
49 for (i = GDB_G0; i < GDB_G6; i++) 49 for (i = GDB_G0; i < GDB_G6; i++)
@@ -55,7 +55,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
55 gdb_regs[GDB_SP] = t->ksp; 55 gdb_regs[GDB_SP] = t->ksp;
56 gdb_regs[GDB_O7] = 0; 56 gdb_regs[GDB_O7] = 0;
57 57
58 win = (struct reg_window *) t->ksp; 58 win = (struct reg_window32 *) t->ksp;
59 for (i = 0; i < 8; i++) 59 for (i = 0; i < 8; i++)
60 gdb_regs[GDB_L0 + i] = win->locals[i]; 60 gdb_regs[GDB_L0 + i] = win->locals[i];
61 for (i = 0; i < 8; i++) 61 for (i = 0; i < 8; i++)
@@ -77,7 +77,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
77 77
78void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) 78void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
79{ 79{
80 struct reg_window *win; 80 struct reg_window32 *win;
81 int i; 81 int i;
82 82
83 for (i = 0; i < 15; i++) 83 for (i = 0; i < 15; i++)
@@ -96,7 +96,7 @@ void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
96 regs->npc = gdb_regs[GDB_NPC]; 96 regs->npc = gdb_regs[GDB_NPC];
97 regs->y = gdb_regs[GDB_Y]; 97 regs->y = gdb_regs[GDB_Y];
98 98
99 win = (struct reg_window *) regs->u_regs[UREG_FP]; 99 win = (struct reg_window32 *) regs->u_regs[UREG_FP];
100 for (i = 0; i < 8; i++) 100 for (i = 0; i < 8; i++)
101 win->locals[i] = gdb_regs[GDB_L0 + i]; 101 win->locals[i] = gdb_regs[GDB_L0 + i];
102 for (i = 0; i < 8; i++) 102 for (i = 0; i < 8; i++)
diff --git a/arch/sparc/kernel/muldiv.c b/arch/sparc/kernel/muldiv.c
index ba960c02bb55..6ce1021d487c 100644
--- a/arch/sparc/kernel/muldiv.c
+++ b/arch/sparc/kernel/muldiv.c
@@ -60,7 +60,7 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
60} 60}
61 61
62#define fetch_reg(reg, regs) ({ \ 62#define fetch_reg(reg, regs) ({ \
63 struct reg_window __user *win; \ 63 struct reg_window32 __user *win; \
64 register unsigned long ret; \ 64 register unsigned long ret; \
65 \ 65 \
66 if (!(reg)) ret = 0; \ 66 if (!(reg)) ret = 0; \
@@ -68,7 +68,7 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
68 ret = regs->u_regs[(reg)]; \ 68 ret = regs->u_regs[(reg)]; \
69 } else { \ 69 } else { \
70 /* Ho hum, the slightly complicated case. */ \ 70 /* Ho hum, the slightly complicated case. */ \
71 win = (struct reg_window __user *)regs->u_regs[UREG_FP];\ 71 win = (struct reg_window32 __user *)regs->u_regs[UREG_FP];\
72 if (get_user (ret, &win->locals[(reg) - 16])) return -1;\ 72 if (get_user (ret, &win->locals[(reg) - 16])) return -1;\
73 } \ 73 } \
74 ret; \ 74 ret; \
@@ -77,7 +77,7 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
77static inline int 77static inline int
78store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs) 78store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs)
79{ 79{
80 struct reg_window __user *win; 80 struct reg_window32 __user *win;
81 81
82 if (!reg) 82 if (!reg)
83 return 0; 83 return 0;
@@ -86,7 +86,7 @@ store_reg(unsigned int result, unsigned int reg, struct pt_regs *regs)
86 return 0; 86 return 0;
87 } else { 87 } else {
88 /* need to use put_user() in this case: */ 88 /* need to use put_user() in this case: */
89 win = (struct reg_window __user *) regs->u_regs[UREG_FP]; 89 win = (struct reg_window32 __user *) regs->u_regs[UREG_FP];
90 return (put_user(result, &win->locals[reg - 16])); 90 return (put_user(result, &win->locals[reg - 16]));
91 } 91 }
92} 92}
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 322046cdf85f..4873f28905b0 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -778,7 +778,7 @@ static unsigned int __init build_one_device_irq(struct of_device *op,
778out: 778out:
779 nid = of_node_to_nid(dp); 779 nid = of_node_to_nid(dp);
780 if (nid != -1) { 780 if (nid != -1) {
781 cpumask_t numa_mask = node_to_cpumask(nid); 781 cpumask_t numa_mask = *cpumask_of_node(nid);
782 782
783 irq_set_affinity(irq, &numa_mask); 783 irq_set_affinity(irq, &numa_mask);
784 } 784 }
diff --git a/arch/sparc/kernel/pci_msi.c b/arch/sparc/kernel/pci_msi.c
index 0d0cd815e83e..4ef282e81912 100644
--- a/arch/sparc/kernel/pci_msi.c
+++ b/arch/sparc/kernel/pci_msi.c
@@ -286,7 +286,7 @@ static int bringup_one_msi_queue(struct pci_pbm_info *pbm,
286 286
287 nid = pbm->numa_node; 287 nid = pbm->numa_node;
288 if (nid != -1) { 288 if (nid != -1) {
289 cpumask_t numa_mask = node_to_cpumask(nid); 289 cpumask_t numa_mask = *cpumask_of_node(nid);
290 290
291 irq_set_affinity(irq, &numa_mask); 291 irq_set_affinity(irq, &numa_mask);
292 } 292 }
diff --git a/arch/sparc/kernel/pci_psycho.c b/arch/sparc/kernel/pci_psycho.c
index dfb3ec892987..3b34344082ef 100644
--- a/arch/sparc/kernel/pci_psycho.c
+++ b/arch/sparc/kernel/pci_psycho.c
@@ -307,10 +307,7 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm)
307 307
308 /* We really mean to ignore the return result here. Two 308 /* We really mean to ignore the return result here. Two
309 * PCI controller share the same interrupt numbers and 309 * PCI controller share the same interrupt numbers and
310 * drive the same front-end hardware. Whichever of the 310 * drive the same front-end hardware.
311 * two get in here first will register the IRQ handler
312 * the second will just error out since we do not pass in
313 * IRQF_SHARED.
314 */ 311 */
315 err = request_irq(op->irqs[1], psycho_ue_intr, IRQF_SHARED, 312 err = request_irq(op->irqs[1], psycho_ue_intr, IRQF_SHARED,
316 "PSYCHO_UE", pbm); 313 "PSYCHO_UE", pbm);
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 69d9315f4a93..5a8d8ced33da 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -180,13 +180,13 @@ static DEFINE_SPINLOCK(sparc_backtrace_lock);
180 180
181void __show_backtrace(unsigned long fp) 181void __show_backtrace(unsigned long fp)
182{ 182{
183 struct reg_window *rw; 183 struct reg_window32 *rw;
184 unsigned long flags; 184 unsigned long flags;
185 int cpu = smp_processor_id(); 185 int cpu = smp_processor_id();
186 186
187 spin_lock_irqsave(&sparc_backtrace_lock, flags); 187 spin_lock_irqsave(&sparc_backtrace_lock, flags);
188 188
189 rw = (struct reg_window *)fp; 189 rw = (struct reg_window32 *)fp;
190 while(rw && (((unsigned long) rw) >= PAGE_OFFSET) && 190 while(rw && (((unsigned long) rw) >= PAGE_OFFSET) &&
191 !(((unsigned long) rw) & 0x7)) { 191 !(((unsigned long) rw) & 0x7)) {
192 printk("CPU[%d]: ARGS[%08lx,%08lx,%08lx,%08lx,%08lx,%08lx] " 192 printk("CPU[%d]: ARGS[%08lx,%08lx,%08lx,%08lx,%08lx,%08lx] "
@@ -196,7 +196,7 @@ void __show_backtrace(unsigned long fp)
196 rw->ins[6], 196 rw->ins[6],
197 rw->ins[7]); 197 rw->ins[7]);
198 printk("%pS\n", (void *) rw->ins[7]); 198 printk("%pS\n", (void *) rw->ins[7]);
199 rw = (struct reg_window *) rw->ins[6]; 199 rw = (struct reg_window32 *) rw->ins[6];
200 } 200 }
201 spin_unlock_irqrestore(&sparc_backtrace_lock, flags); 201 spin_unlock_irqrestore(&sparc_backtrace_lock, flags);
202} 202}
@@ -258,7 +258,7 @@ void show_stackframe(struct sparc_stackf *sf)
258 258
259void show_regs(struct pt_regs *r) 259void show_regs(struct pt_regs *r)
260{ 260{
261 struct reg_window *rw = (struct reg_window *) r->u_regs[14]; 261 struct reg_window32 *rw = (struct reg_window32 *) r->u_regs[14];
262 262
263 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n", 263 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
264 r->psr, r->pc, r->npc, r->y, print_tainted()); 264 r->psr, r->pc, r->npc, r->y, print_tainted());
@@ -287,7 +287,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
287{ 287{
288 unsigned long pc, fp; 288 unsigned long pc, fp;
289 unsigned long task_base; 289 unsigned long task_base;
290 struct reg_window *rw; 290 struct reg_window32 *rw;
291 int count = 0; 291 int count = 0;
292 292
293 if (tsk != NULL) 293 if (tsk != NULL)
@@ -301,7 +301,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
301 if (fp < (task_base + sizeof(struct thread_info)) || 301 if (fp < (task_base + sizeof(struct thread_info)) ||
302 fp >= (task_base + (PAGE_SIZE << 1))) 302 fp >= (task_base + (PAGE_SIZE << 1)))
303 break; 303 break;
304 rw = (struct reg_window *) fp; 304 rw = (struct reg_window32 *) fp;
305 pc = rw->ins[7]; 305 pc = rw->ins[7];
306 printk("[%08lx : ", pc); 306 printk("[%08lx : ", pc);
307 printk("%pS ] ", (void *) pc); 307 printk("%pS ] ", (void *) pc);
@@ -679,7 +679,7 @@ unsigned long get_wchan(struct task_struct *task)
679 unsigned long pc, fp, bias = 0; 679 unsigned long pc, fp, bias = 0;
680 unsigned long task_base = (unsigned long) task; 680 unsigned long task_base = (unsigned long) task;
681 unsigned long ret = 0; 681 unsigned long ret = 0;
682 struct reg_window *rw; 682 struct reg_window32 *rw;
683 int count = 0; 683 int count = 0;
684 684
685 if (!task || task == current || 685 if (!task || task == current ||
@@ -692,7 +692,7 @@ unsigned long get_wchan(struct task_struct *task)
692 if (fp < (task_base + sizeof(struct thread_info)) || 692 if (fp < (task_base + sizeof(struct thread_info)) ||
693 fp >= (task_base + (2 * PAGE_SIZE))) 693 fp >= (task_base + (2 * PAGE_SIZE)))
694 break; 694 break;
695 rw = (struct reg_window *) fp; 695 rw = (struct reg_window32 *) fp;
696 pc = rw->ins[7]; 696 pc = rw->ins[7];
697 if (!in_sched_functions(pc)) { 697 if (!in_sched_functions(pc)) {
698 ret = pc; 698 ret = pc;
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 4e9af593db49..ff7b591c8946 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -155,20 +155,12 @@ static struct property * __init build_one_prop(phandle node, char *prev,
155 p->value = prom_early_alloc(special_len); 155 p->value = prom_early_alloc(special_len);
156 memcpy(p->value, special_val, special_len); 156 memcpy(p->value, special_val, special_len);
157 } else { 157 } else {
158#ifdef CONFIG_SPARC32
159 if (prev == NULL) {
160 name = prom_firstprop(node, NULL);
161 } else {
162 name = prom_nextprop(node, prev, NULL);
163 }
164#else
165 if (prev == NULL) { 158 if (prev == NULL) {
166 prom_firstprop(node, p->name); 159 name = prom_firstprop(node, p->name);
167 } else { 160 } else {
168 prom_nextprop(node, prev, p->name); 161 name = prom_nextprop(node, prev, p->name);
169 } 162 }
170 name = p->name; 163
171#endif
172 if (strlen(name) == 0) { 164 if (strlen(name) == 0) {
173 tmp = p; 165 tmp = p;
174 return NULL; 166 return NULL;
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
index c94f91c8b6e0..181d069a2d44 100644
--- a/arch/sparc/kernel/signal_32.c
+++ b/arch/sparc/kernel/signal_32.c
@@ -34,7 +34,7 @@ extern void fpload(unsigned long *fpregs, unsigned long *fsr);
34 34
35struct signal_frame { 35struct signal_frame {
36 struct sparc_stackf ss; 36 struct sparc_stackf ss;
37 __siginfo_t info; 37 __siginfo32_t info;
38 __siginfo_fpu_t __user *fpu_save; 38 __siginfo_fpu_t __user *fpu_save;
39 unsigned long insns[2] __attribute__ ((aligned (8))); 39 unsigned long insns[2] __attribute__ ((aligned (8)));
40 unsigned int extramask[_NSIG_WORDS - 1]; 40 unsigned int extramask[_NSIG_WORDS - 1];
@@ -351,7 +351,7 @@ static void setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
351 err |= __copy_to_user(sf->extramask, &oldset->sig[1], 351 err |= __copy_to_user(sf->extramask, &oldset->sig[1],
352 (_NSIG_WORDS - 1) * sizeof(unsigned int)); 352 (_NSIG_WORDS - 1) * sizeof(unsigned int));
353 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], 353 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
354 sizeof(struct reg_window)); 354 sizeof(struct reg_window32));
355 if (err) 355 if (err)
356 goto sigsegv; 356 goto sigsegv;
357 357
@@ -433,7 +433,7 @@ static void setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
433 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size); 433 err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
434 434
435 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP], 435 err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
436 sizeof(struct reg_window)); 436 sizeof(struct reg_window32));
437 437
438 err |= copy_siginfo_to_user(&sf->info, info); 438 err |= copy_siginfo_to_user(&sf->info, info);
439 439
diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
index 716f3946c494..213645be6e92 100644
--- a/arch/sparc/kernel/traps_32.c
+++ b/arch/sparc/kernel/traps_32.c
@@ -67,7 +67,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
67 __RESTORE; __RESTORE; __RESTORE; __RESTORE; 67 __RESTORE; __RESTORE; __RESTORE; __RESTORE;
68 68
69 { 69 {
70 struct reg_window *rw = (struct reg_window *)regs->u_regs[UREG_FP]; 70 struct reg_window32 *rw = (struct reg_window32 *)regs->u_regs[UREG_FP];
71 71
72 /* Stop the back trace when we hit userland or we 72 /* Stop the back trace when we hit userland or we
73 * find some badly aligned kernel stack. Set an upper 73 * find some badly aligned kernel stack. Set an upper
@@ -79,7 +79,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
79 !(((unsigned long) rw) & 0x7)) { 79 !(((unsigned long) rw) & 0x7)) {
80 printk("Caller[%08lx]: %pS\n", rw->ins[7], 80 printk("Caller[%08lx]: %pS\n", rw->ins[7],
81 (void *) rw->ins[7]); 81 (void *) rw->ins[7]);
82 rw = (struct reg_window *)rw->ins[6]; 82 rw = (struct reg_window32 *)rw->ins[6];
83 } 83 }
84 } 84 }
85 printk("Instruction DUMP:"); 85 printk("Instruction DUMP:");
diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
index c2a28c5ad650..6b1e6cde6fff 100644
--- a/arch/sparc/kernel/unaligned_32.c
+++ b/arch/sparc/kernel/unaligned_32.c
@@ -97,26 +97,26 @@ static inline int sign_extend_imm13(int imm)
97 97
98static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs) 98static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
99{ 99{
100 struct reg_window *win; 100 struct reg_window32 *win;
101 101
102 if(reg < 16) 102 if(reg < 16)
103 return (!reg ? 0 : regs->u_regs[reg]); 103 return (!reg ? 0 : regs->u_regs[reg]);
104 104
105 /* Ho hum, the slightly complicated case. */ 105 /* Ho hum, the slightly complicated case. */
106 win = (struct reg_window *) regs->u_regs[UREG_FP]; 106 win = (struct reg_window32 *) regs->u_regs[UREG_FP];
107 return win->locals[reg - 16]; /* yes, I know what this does... */ 107 return win->locals[reg - 16]; /* yes, I know what this does... */
108} 108}
109 109
110static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs) 110static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs)
111{ 111{
112 struct reg_window __user *win; 112 struct reg_window32 __user *win;
113 unsigned long ret; 113 unsigned long ret;
114 114
115 if (reg < 16) 115 if (reg < 16)
116 return (!reg ? 0 : regs->u_regs[reg]); 116 return (!reg ? 0 : regs->u_regs[reg]);
117 117
118 /* Ho hum, the slightly complicated case. */ 118 /* Ho hum, the slightly complicated case. */
119 win = (struct reg_window __user *) regs->u_regs[UREG_FP]; 119 win = (struct reg_window32 __user *) regs->u_regs[UREG_FP];
120 120
121 if ((unsigned long)win & 3) 121 if ((unsigned long)win & 3)
122 return -1; 122 return -1;
@@ -129,11 +129,11 @@ static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *reg
129 129
130static inline unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs) 130static inline unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
131{ 131{
132 struct reg_window *win; 132 struct reg_window32 *win;
133 133
134 if(reg < 16) 134 if(reg < 16)
135 return &regs->u_regs[reg]; 135 return &regs->u_regs[reg];
136 win = (struct reg_window *) regs->u_regs[UREG_FP]; 136 win = (struct reg_window32 *) regs->u_regs[UREG_FP];
137 return &win->locals[reg - 16]; 137 return &win->locals[reg - 16];
138} 138}
139 139
diff --git a/arch/sparc/kernel/windows.c b/arch/sparc/kernel/windows.c
index 9cc93eaa4abf..f24d298bda29 100644
--- a/arch/sparc/kernel/windows.c
+++ b/arch/sparc/kernel/windows.c
@@ -42,7 +42,7 @@ static inline void shift_window_buffer(int first_win, int last_win, struct threa
42 42
43 for(i = first_win; i < last_win; i++) { 43 for(i = first_win; i < last_win; i++) {
44 tp->rwbuf_stkptrs[i] = tp->rwbuf_stkptrs[i+1]; 44 tp->rwbuf_stkptrs[i] = tp->rwbuf_stkptrs[i+1];
45 memcpy(&tp->reg_window[i], &tp->reg_window[i+1], sizeof(struct reg_window)); 45 memcpy(&tp->reg_window[i], &tp->reg_window[i+1], sizeof(struct reg_window32));
46 } 46 }
47} 47}
48 48
@@ -70,7 +70,7 @@ void synchronize_user_stack(void)
70 70
71 /* Ok, let it rip. */ 71 /* Ok, let it rip. */
72 if (copy_to_user((char __user *) sp, &tp->reg_window[window], 72 if (copy_to_user((char __user *) sp, &tp->reg_window[window],
73 sizeof(struct reg_window))) 73 sizeof(struct reg_window32)))
74 continue; 74 continue;
75 75
76 shift_window_buffer(window, tp->w_saved - 1, tp); 76 shift_window_buffer(window, tp->w_saved - 1, tp);
@@ -119,7 +119,7 @@ void try_to_clear_window_buffer(struct pt_regs *regs, int who)
119 119
120 if ((sp & 7) || 120 if ((sp & 7) ||
121 copy_to_user((char __user *) sp, &tp->reg_window[window], 121 copy_to_user((char __user *) sp, &tp->reg_window[window],
122 sizeof(struct reg_window))) 122 sizeof(struct reg_window32)))
123 do_exit(SIGILL); 123 do_exit(SIGILL);
124 } 124 }
125 tp->w_saved = 0; 125 tp->w_saved = 0;
diff --git a/arch/um/Makefile b/arch/um/Makefile
index d944c343acdb..0728def32234 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -22,10 +22,11 @@ MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas
22 22
23include $(srctree)/$(ARCH_DIR)/Makefile-skas 23include $(srctree)/$(ARCH_DIR)/Makefile-skas
24 24
25ARCH_INCLUDE := -I$(srctree)/$(ARCH_DIR)/include/shared 25SHARED_HEADERS := $(ARCH_DIR)/include/shared
26ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS)
26ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared 27ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared
27ifneq ($(KBUILD_SRC),) 28ifneq ($(KBUILD_SRC),)
28ARCH_INCLUDE += -I$(ARCH_DIR)/include/shared # for two generated files 29ARCH_INCLUDE += -I$(SHARED_HEADERS)
29endif 30endif
30KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) 31KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
31 32
@@ -85,8 +86,8 @@ endef
85 86
86KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH) 87KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH)
87 88
88archprepare: $(ARCH_DIR)/include/shared/user_constants.h 89archprepare: $(SHARED_HEADERS)/user_constants.h
89prepare: $(ARCH_DIR)/include/shared/kern_constants.h 90archprepare: $(SHARED_HEADERS)/kern_constants.h
90 91
91LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 92LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
92LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib 93LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
@@ -119,17 +120,13 @@ endef
119# When cleaning we don't include .config, so we don't include 120# When cleaning we don't include .config, so we don't include
120# TT or skas makefiles and don't clean skas_ptregs.h. 121# TT or skas makefiles and don't clean skas_ptregs.h.
121CLEAN_FILES += linux x.i gmon.out \ 122CLEAN_FILES += linux x.i gmon.out \
122 $(ARCH_DIR)/include/shared/user_constants.h \ 123 $(SHARED_HEADERS)/user_constants.h \
123 $(ARCH_DIR)/include/shared/kern_constants.h 124 $(SHARED_HEADERS)/kern_constants.h
124 125
125archclean: 126archclean:
126 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 127 @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
127 -o -name '*.gcov' \) -type f -print | xargs rm -f 128 -o -name '*.gcov' \) -type f -print | xargs rm -f
128 129
129$(objtree)/$(ARCH_DIR)/include/shared:
130 @echo ' MKDIR $@'
131 $(Q)mkdir -p $@
132
133# Generated files 130# Generated files
134 131
135$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE 132$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
@@ -148,11 +145,11 @@ define filechk_gen-asm-offsets
148 echo ""; ) 145 echo ""; )
149endef 146endef
150 147
151$(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s 148$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
152 $(call filechk,gen-asm-offsets) 149 $(call filechk,gen-asm-offsets)
153 150
154$(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared 151$(SHARED_HEADERS)/kern_constants.h:
155 @echo ' SYMLINK $@' 152 $(Q)mkdir -p $(dir $@)
156 $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@ 153 $(Q)echo '#include "../../../../include/asm/asm-offsets.h"' >$@
157 154
158export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH 155export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h
index ae5f94d6317d..753346e2cdfd 100644
--- a/arch/um/include/asm/system.h
+++ b/arch/um/include/asm/system.h
@@ -11,21 +11,21 @@ extern int get_signals(void);
11extern void block_signals(void); 11extern void block_signals(void);
12extern void unblock_signals(void); 12extern void unblock_signals(void);
13 13
14#define raw_local_save_flags(flags) do { typecheck(unsigned long, flags); \ 14#define local_save_flags(flags) do { typecheck(unsigned long, flags); \
15 (flags) = get_signals(); } while(0) 15 (flags) = get_signals(); } while(0)
16#define raw_local_irq_restore(flags) do { typecheck(unsigned long, flags); \ 16#define local_irq_restore(flags) do { typecheck(unsigned long, flags); \
17 set_signals(flags); } while(0) 17 set_signals(flags); } while(0)
18 18
19#define raw_local_irq_save(flags) do { raw_local_save_flags(flags); \ 19#define local_irq_save(flags) do { local_save_flags(flags); \
20 raw_local_irq_disable(); } while(0) 20 local_irq_disable(); } while(0)
21 21
22#define raw_local_irq_enable() unblock_signals() 22#define local_irq_enable() unblock_signals()
23#define raw_local_irq_disable() block_signals() 23#define local_irq_disable() block_signals()
24 24
25#define irqs_disabled() \ 25#define irqs_disabled() \
26({ \ 26({ \
27 unsigned long flags; \ 27 unsigned long flags; \
28 raw_local_save_flags(flags); \ 28 local_save_flags(flags); \
29 (flags == 0); \ 29 (flags == 0); \
30}) 30})
31 31
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 249d1e0824b5..862adb9bf0d4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -586,6 +586,16 @@ config AMD_IOMMU
586 your BIOS for an option to enable it or if you have an IVRS ACPI 586 your BIOS for an option to enable it or if you have an IVRS ACPI
587 table. 587 table.
588 588
589config AMD_IOMMU_STATS
590 bool "Export AMD IOMMU statistics to debugfs"
591 depends on AMD_IOMMU
592 select DEBUG_FS
593 help
594 This option enables code in the AMD IOMMU driver to collect various
595 statistics about whats happening in the driver and exports that
596 information to userspace via debugfs.
597 If unsure, say N.
598
589# need this always selected by IOMMU for the VIA workaround 599# need this always selected by IOMMU for the VIA workaround
590config SWIOTLB 600config SWIOTLB
591 def_bool y if X86_64 601 def_bool y if X86_64
@@ -599,6 +609,9 @@ config SWIOTLB
599config IOMMU_HELPER 609config IOMMU_HELPER
600 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU) 610 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU)
601 611
612config IOMMU_API
613 def_bool (AMD_IOMMU || DMAR)
614
602config MAXSMP 615config MAXSMP
603 bool "Configure Maximum number of SMP Processors and NUMA Nodes" 616 bool "Configure Maximum number of SMP Processors and NUMA Nodes"
604 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL 617 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 85a78575956c..8078955845ae 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -408,7 +408,7 @@ config X86_MINIMUM_CPU_FAMILY
408 408
409config X86_DEBUGCTLMSR 409config X86_DEBUGCTLMSR
410 def_bool y 410 def_bool y
411 depends on !(MK6 || MWINCHIPC6 || MWINCHIP3D || MCYRIXIII || M586MMX || M586TSC || M586 || M486 || M386) 411 depends on !(MK6 || MWINCHIPC6 || MWINCHIP3D || MCYRIXIII || M586MMX || M586TSC || M586 || M486 || M386) && !UML
412 412
413menuconfig PROCESSOR_SELECT 413menuconfig PROCESSOR_SELECT
414 bool "Supported processor vendors" if EMBEDDED 414 bool "Supported processor vendors" if EMBEDDED
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index ac302a2fa339..95c8cd9d22b5 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -190,16 +190,23 @@
190/* FIXME: move this macro to <linux/pci.h> */ 190/* FIXME: move this macro to <linux/pci.h> */
191#define PCI_BUS(x) (((x) >> 8) & 0xff) 191#define PCI_BUS(x) (((x) >> 8) & 0xff)
192 192
193/* Protection domain flags */
194#define PD_DMA_OPS_MASK (1UL << 0) /* domain used for dma_ops */
195#define PD_DEFAULT_MASK (1UL << 1) /* domain is a default dma_ops
196 domain for an IOMMU */
197
193/* 198/*
194 * This structure contains generic data for IOMMU protection domains 199 * This structure contains generic data for IOMMU protection domains
195 * independent of their use. 200 * independent of their use.
196 */ 201 */
197struct protection_domain { 202struct protection_domain {
198 spinlock_t lock; /* mostly used to lock the page table*/ 203 spinlock_t lock; /* mostly used to lock the page table*/
199 u16 id; /* the domain id written to the device table */ 204 u16 id; /* the domain id written to the device table */
200 int mode; /* paging mode (0-6 levels) */ 205 int mode; /* paging mode (0-6 levels) */
201 u64 *pt_root; /* page table root pointer */ 206 u64 *pt_root; /* page table root pointer */
202 void *priv; /* private data */ 207 unsigned long flags; /* flags to find out type of domain */
208 unsigned dev_cnt; /* devices assigned to this domain */
209 void *priv; /* private data */
203}; 210};
204 211
205/* 212/*
@@ -295,7 +302,7 @@ struct amd_iommu {
295 bool int_enabled; 302 bool int_enabled;
296 303
297 /* if one, we need to send a completion wait command */ 304 /* if one, we need to send a completion wait command */
298 int need_sync; 305 bool need_sync;
299 306
300 /* default dma_ops domain for that IOMMU */ 307 /* default dma_ops domain for that IOMMU */
301 struct dma_ops_domain *default_dom; 308 struct dma_ops_domain *default_dom;
@@ -374,7 +381,7 @@ extern struct protection_domain **amd_iommu_pd_table;
374extern unsigned long *amd_iommu_pd_alloc_bitmap; 381extern unsigned long *amd_iommu_pd_alloc_bitmap;
375 382
376/* will be 1 if device isolation is enabled */ 383/* will be 1 if device isolation is enabled */
377extern int amd_iommu_isolate; 384extern bool amd_iommu_isolate;
378 385
379/* 386/*
380 * If true, the addresses will be flushed on unmap time, not when 387 * If true, the addresses will be flushed on unmap time, not when
@@ -382,18 +389,6 @@ extern int amd_iommu_isolate;
382 */ 389 */
383extern bool amd_iommu_unmap_flush; 390extern bool amd_iommu_unmap_flush;
384 391
385/* takes a PCI device id and prints it out in a readable form */
386static inline void print_devid(u16 devid, int nl)
387{
388 int bus = devid >> 8;
389 int dev = devid >> 3 & 0x1f;
390 int fn = devid & 0x07;
391
392 printk("%02x:%02x.%x", bus, dev, fn);
393 if (nl)
394 printk("\n");
395}
396
397/* takes bus and device/function and returns the device id 392/* takes bus and device/function and returns the device id
398 * FIXME: should that be in generic PCI code? */ 393 * FIXME: should that be in generic PCI code? */
399static inline u16 calc_devid(u8 bus, u8 devfn) 394static inline u16 calc_devid(u8 bus, u8 devfn)
@@ -401,4 +396,32 @@ static inline u16 calc_devid(u8 bus, u8 devfn)
401 return (((u16)bus) << 8) | devfn; 396 return (((u16)bus) << 8) | devfn;
402} 397}
403 398
399#ifdef CONFIG_AMD_IOMMU_STATS
400
401struct __iommu_counter {
402 char *name;
403 struct dentry *dent;
404 u64 value;
405};
406
407#define DECLARE_STATS_COUNTER(nm) \
408 static struct __iommu_counter nm = { \
409 .name = #nm, \
410 }
411
412#define INC_STATS_COUNTER(name) name.value += 1
413#define ADD_STATS_COUNTER(name, x) name.value += (x)
414#define SUB_STATS_COUNTER(name, x) name.value -= (x)
415
416#else /* CONFIG_AMD_IOMMU_STATS */
417
418#define DECLARE_STATS_COUNTER(name)
419#define INC_STATS_COUNTER(name)
420#define ADD_STATS_COUNTER(name, x)
421#define SUB_STATS_COUNTER(name, x)
422
423static inline void amd_iommu_stats_init(void) { }
424
425#endif /* CONFIG_AMD_IOMMU_STATS */
426
404#endif /* _ASM_X86_AMD_IOMMU_TYPES_H */ 427#endif /* _ASM_X86_AMD_IOMMU_TYPES_H */
diff --git a/arch/x86/include/asm/es7000/apic.h b/arch/x86/include/asm/es7000/apic.h
index 51ac1230294e..bc53d5ef1386 100644
--- a/arch/x86/include/asm/es7000/apic.h
+++ b/arch/x86/include/asm/es7000/apic.h
@@ -157,7 +157,7 @@ cpu_mask_to_apicid_cluster(const struct cpumask *cpumask)
157 157
158 num_bits_set = cpumask_weight(cpumask); 158 num_bits_set = cpumask_weight(cpumask);
159 /* Return id to all */ 159 /* Return id to all */
160 if (num_bits_set == NR_CPUS) 160 if (num_bits_set == nr_cpu_ids)
161 return 0xFF; 161 return 0xFF;
162 /* 162 /*
163 * The cpus in the mask must all be on the apic cluster. If are not 163 * The cpus in the mask must all be on the apic cluster. If are not
@@ -190,7 +190,7 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
190 190
191 num_bits_set = cpus_weight(*cpumask); 191 num_bits_set = cpus_weight(*cpumask);
192 /* Return id to all */ 192 /* Return id to all */
193 if (num_bits_set == NR_CPUS) 193 if (num_bits_set == nr_cpu_ids)
194 return cpu_to_logical_apicid(0); 194 return cpu_to_logical_apicid(0);
195 /* 195 /*
196 * The cpus in the mask must all be on the apic cluster. If are not 196 * The cpus in the mask must all be on the apic cluster. If are not
@@ -218,9 +218,6 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
218static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, 218static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
219 const struct cpumask *andmask) 219 const struct cpumask *andmask)
220{ 220{
221 int num_bits_set;
222 int cpus_found = 0;
223 int cpu;
224 int apicid = cpu_to_logical_apicid(0); 221 int apicid = cpu_to_logical_apicid(0);
225 cpumask_var_t cpumask; 222 cpumask_var_t cpumask;
226 223
@@ -229,31 +226,8 @@ static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
229 226
230 cpumask_and(cpumask, inmask, andmask); 227 cpumask_and(cpumask, inmask, andmask);
231 cpumask_and(cpumask, cpumask, cpu_online_mask); 228 cpumask_and(cpumask, cpumask, cpu_online_mask);
229 apicid = cpu_mask_to_apicid(cpumask);
232 230
233 num_bits_set = cpumask_weight(cpumask);
234 /* Return id to all */
235 if (num_bits_set == NR_CPUS)
236 goto exit;
237 /*
238 * The cpus in the mask must all be on the apic cluster. If are not
239 * on the same apicid cluster return default value of TARGET_CPUS.
240 */
241 cpu = cpumask_first(cpumask);
242 apicid = cpu_to_logical_apicid(cpu);
243 while (cpus_found < num_bits_set) {
244 if (cpumask_test_cpu(cpu, cpumask)) {
245 int new_apicid = cpu_to_logical_apicid(cpu);
246 if (apicid_cluster(apicid) !=
247 apicid_cluster(new_apicid)){
248 printk ("%s: Not a valid mask!\n", __func__);
249 return cpu_to_logical_apicid(0);
250 }
251 apicid = new_apicid;
252 cpus_found++;
253 }
254 cpu++;
255 }
256exit:
257 free_cpumask_var(cpumask); 231 free_cpumask_var(cpumask);
258 return apicid; 232 return apicid;
259} 233}
diff --git a/arch/x86/include/asm/es7000/mpparse.h b/arch/x86/include/asm/es7000/mpparse.h
index ed5a3caae141..c1629b090ec2 100644
--- a/arch/x86/include/asm/es7000/mpparse.h
+++ b/arch/x86/include/asm/es7000/mpparse.h
@@ -10,8 +10,7 @@ extern void setup_unisys(void);
10 10
11#ifndef CONFIG_X86_GENERICARCH 11#ifndef CONFIG_X86_GENERICARCH
12extern int acpi_madt_oem_check(char *oem_id, char *oem_table_id); 12extern int acpi_madt_oem_check(char *oem_id, char *oem_table_id);
13extern int mps_oem_check(struct mp_config_table *mpc, char *oem, 13extern int mps_oem_check(struct mpc_table *mpc, char *oem, char *productid);
14 char *productid);
15#endif 14#endif
16 15
17#ifdef CONFIG_ACPI 16#ifdef CONFIG_ACPI
diff --git a/arch/x86/include/asm/genapic_32.h b/arch/x86/include/asm/genapic_32.h
index 746f37a7963a..2c05b737ee22 100644
--- a/arch/x86/include/asm/genapic_32.h
+++ b/arch/x86/include/asm/genapic_32.h
@@ -15,9 +15,9 @@
15 * Copyright 2003 Andi Kleen, SuSE Labs. 15 * Copyright 2003 Andi Kleen, SuSE Labs.
16 */ 16 */
17 17
18struct mpc_config_bus; 18struct mpc_bus;
19struct mp_config_table; 19struct mpc_table;
20struct mpc_config_processor; 20struct mpc_cpu;
21 21
22struct genapic { 22struct genapic {
23 char *name; 23 char *name;
@@ -51,7 +51,7 @@ struct genapic {
51 /* When one of the next two hooks returns 1 the genapic 51 /* When one of the next two hooks returns 1 the genapic
52 is switched to this. Essentially they are additional probe 52 is switched to this. Essentially they are additional probe
53 functions. */ 53 functions. */
54 int (*mps_oem_check)(struct mp_config_table *mpc, char *oem, 54 int (*mps_oem_check)(struct mpc_table *mpc, char *oem,
55 char *productid); 55 char *productid);
56 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); 56 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
57 57
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 97215a458e5f..730843d1d2fb 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -360,7 +360,7 @@ struct kvm_arch{
360 struct list_head active_mmu_pages; 360 struct list_head active_mmu_pages;
361 struct list_head assigned_dev_head; 361 struct list_head assigned_dev_head;
362 struct list_head oos_global_pages; 362 struct list_head oos_global_pages;
363 struct dmar_domain *intel_iommu_domain; 363 struct iommu_domain *iommu_domain;
364 struct kvm_pic *vpic; 364 struct kvm_pic *vpic;
365 struct kvm_ioapic *vioapic; 365 struct kvm_ioapic *vioapic;
366 struct kvm_pit *vpit; 366 struct kvm_pit *vpit;
diff --git a/arch/x86/include/asm/lguest.h b/arch/x86/include/asm/lguest.h
index d28a507cef39..1caf57628b9c 100644
--- a/arch/x86/include/asm/lguest.h
+++ b/arch/x86/include/asm/lguest.h
@@ -15,7 +15,7 @@
15#define SHARED_SWITCHER_PAGES \ 15#define SHARED_SWITCHER_PAGES \
16 DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE) 16 DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE)
17/* Pages for switcher itself, then two pages per cpu */ 17/* Pages for switcher itself, then two pages per cpu */
18#define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * NR_CPUS) 18#define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * nr_cpu_ids)
19 19
20/* We map at -4M for ease of mapping into the guest (one PTE page). */ 20/* We map at -4M for ease of mapping into the guest (one PTE page). */
21#define SWITCHER_ADDR 0xFFC00000 21#define SWITCHER_ADDR 0xFFC00000
diff --git a/arch/x86/include/asm/mach-default/mach_mpparse.h b/arch/x86/include/asm/mach-default/mach_mpparse.h
index 8c1ea21238a7..c70a263d68cd 100644
--- a/arch/x86/include/asm/mach-default/mach_mpparse.h
+++ b/arch/x86/include/asm/mach-default/mach_mpparse.h
@@ -1,8 +1,8 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H 1#ifndef _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H
2#define _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H 2#define _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H
3 3
4static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 4static inline int
5 char *productid) 5mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
6{ 6{
7 return 0; 7 return 0;
8} 8}
diff --git a/arch/x86/include/asm/mach-generic/mach_mpparse.h b/arch/x86/include/asm/mach-generic/mach_mpparse.h
index 048f1d468535..9444ab8dca94 100644
--- a/arch/x86/include/asm/mach-generic/mach_mpparse.h
+++ b/arch/x86/include/asm/mach-generic/mach_mpparse.h
@@ -2,9 +2,8 @@
2#define _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H 2#define _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H
3 3
4 4
5extern int mps_oem_check(struct mp_config_table *mpc, char *oem, 5extern int mps_oem_check(struct mpc_table *, char *, char *);
6 char *productid);
7 6
8extern int acpi_madt_oem_check(char *oem_id, char *oem_table_id); 7extern int acpi_madt_oem_check(char *, char *);
9 8
10#endif /* _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H */ 9#endif /* _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_mpspec.h b/arch/x86/include/asm/mach-generic/mach_mpspec.h
index bbab5ccfd4fe..3bc407226578 100644
--- a/arch/x86/include/asm/mach-generic/mach_mpspec.h
+++ b/arch/x86/include/asm/mach-generic/mach_mpspec.h
@@ -7,6 +7,6 @@
7/* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */ 7/* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */
8#define MAX_MP_BUSSES 260 8#define MAX_MP_BUSSES 260
9 9
10extern void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, 10extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
11 char *productid); 11
12#endif /* _ASM_X86_MACH_GENERIC_MACH_MPSPEC_H */ 12#endif /* _ASM_X86_MACH_GENERIC_MACH_MPSPEC_H */
diff --git a/arch/x86/include/asm/mpspec_def.h b/arch/x86/include/asm/mpspec_def.h
index e3ace7d1d35d..59568bc4767f 100644
--- a/arch/x86/include/asm/mpspec_def.h
+++ b/arch/x86/include/asm/mpspec_def.h
@@ -39,17 +39,17 @@ struct intel_mp_floating {
39 39
40#define MPC_SIGNATURE "PCMP" 40#define MPC_SIGNATURE "PCMP"
41 41
42struct mp_config_table { 42struct mpc_table {
43 char mpc_signature[4]; 43 char signature[4];
44 unsigned short mpc_length; /* Size of table */ 44 unsigned short length; /* Size of table */
45 char mpc_spec; /* 0x01 */ 45 char spec; /* 0x01 */
46 char mpc_checksum; 46 char checksum;
47 char mpc_oem[8]; 47 char oem[8];
48 char mpc_productid[12]; 48 char productid[12];
49 unsigned int mpc_oemptr; /* 0 if not present */ 49 unsigned int oemptr; /* 0 if not present */
50 unsigned short mpc_oemsize; /* 0 if not present */ 50 unsigned short oemsize; /* 0 if not present */
51 unsigned short mpc_oemcount; 51 unsigned short oemcount;
52 unsigned int mpc_lapic; /* APIC address */ 52 unsigned int lapic; /* APIC address */
53 unsigned int reserved; 53 unsigned int reserved;
54}; 54};
55 55
@@ -70,20 +70,20 @@ struct mp_config_table {
70#define CPU_MODEL_MASK 0x00F0 70#define CPU_MODEL_MASK 0x00F0
71#define CPU_FAMILY_MASK 0x0F00 71#define CPU_FAMILY_MASK 0x0F00
72 72
73struct mpc_config_processor { 73struct mpc_cpu {
74 unsigned char mpc_type; 74 unsigned char type;
75 unsigned char mpc_apicid; /* Local APIC number */ 75 unsigned char apicid; /* Local APIC number */
76 unsigned char mpc_apicver; /* Its versions */ 76 unsigned char apicver; /* Its versions */
77 unsigned char mpc_cpuflag; 77 unsigned char cpuflag;
78 unsigned int mpc_cpufeature; 78 unsigned int cpufeature;
79 unsigned int mpc_featureflag; /* CPUID feature value */ 79 unsigned int featureflag; /* CPUID feature value */
80 unsigned int mpc_reserved[2]; 80 unsigned int reserved[2];
81}; 81};
82 82
83struct mpc_config_bus { 83struct mpc_bus {
84 unsigned char mpc_type; 84 unsigned char type;
85 unsigned char mpc_busid; 85 unsigned char busid;
86 unsigned char mpc_bustype[6]; 86 unsigned char bustype[6];
87}; 87};
88 88
89/* List of Bus Type string values, Intel MP Spec. */ 89/* List of Bus Type string values, Intel MP Spec. */
@@ -108,22 +108,22 @@ struct mpc_config_bus {
108 108
109#define MPC_APIC_USABLE 0x01 109#define MPC_APIC_USABLE 0x01
110 110
111struct mpc_config_ioapic { 111struct mpc_ioapic {
112 unsigned char mpc_type; 112 unsigned char type;
113 unsigned char mpc_apicid; 113 unsigned char apicid;
114 unsigned char mpc_apicver; 114 unsigned char apicver;
115 unsigned char mpc_flags; 115 unsigned char flags;
116 unsigned int mpc_apicaddr; 116 unsigned int apicaddr;
117}; 117};
118 118
119struct mpc_config_intsrc { 119struct mpc_intsrc {
120 unsigned char mpc_type; 120 unsigned char type;
121 unsigned char mpc_irqtype; 121 unsigned char irqtype;
122 unsigned short mpc_irqflag; 122 unsigned short irqflag;
123 unsigned char mpc_srcbus; 123 unsigned char srcbus;
124 unsigned char mpc_srcbusirq; 124 unsigned char srcbusirq;
125 unsigned char mpc_dstapic; 125 unsigned char dstapic;
126 unsigned char mpc_dstirq; 126 unsigned char dstirq;
127}; 127};
128 128
129enum mp_irq_source_types { 129enum mp_irq_source_types {
@@ -139,24 +139,24 @@ enum mp_irq_source_types {
139 139
140#define MP_APIC_ALL 0xFF 140#define MP_APIC_ALL 0xFF
141 141
142struct mpc_config_lintsrc { 142struct mpc_lintsrc {
143 unsigned char mpc_type; 143 unsigned char type;
144 unsigned char mpc_irqtype; 144 unsigned char irqtype;
145 unsigned short mpc_irqflag; 145 unsigned short irqflag;
146 unsigned char mpc_srcbusid; 146 unsigned char srcbusid;
147 unsigned char mpc_srcbusirq; 147 unsigned char srcbusirq;
148 unsigned char mpc_destapic; 148 unsigned char destapic;
149 unsigned char mpc_destapiclint; 149 unsigned char destapiclint;
150}; 150};
151 151
152#define MPC_OEM_SIGNATURE "_OEM" 152#define MPC_OEM_SIGNATURE "_OEM"
153 153
154struct mp_config_oemtable { 154struct mpc_oemtable {
155 char oem_signature[4]; 155 char signature[4];
156 unsigned short oem_length; /* Size of table */ 156 unsigned short length; /* Size of table */
157 char oem_rev; /* 0x01 */ 157 char rev; /* 0x01 */
158 char oem_checksum; 158 char checksum;
159 char mpc_oem[8]; 159 char mpc[8];
160}; 160};
161 161
162/* 162/*
diff --git a/arch/x86/include/asm/numaq/apic.h b/arch/x86/include/asm/numaq/apic.h
index c80f00d29965..bf37bc49bd8e 100644
--- a/arch/x86/include/asm/numaq/apic.h
+++ b/arch/x86/include/asm/numaq/apic.h
@@ -63,8 +63,8 @@ static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
63extern u8 cpu_2_logical_apicid[]; 63extern u8 cpu_2_logical_apicid[];
64static inline int cpu_to_logical_apicid(int cpu) 64static inline int cpu_to_logical_apicid(int cpu)
65{ 65{
66 if (cpu >= NR_CPUS) 66 if (cpu >= nr_cpu_ids)
67 return BAD_APICID; 67 return BAD_APICID;
68 return (int)cpu_2_logical_apicid[cpu]; 68 return (int)cpu_2_logical_apicid[cpu];
69} 69}
70 70
diff --git a/arch/x86/include/asm/numaq/mpparse.h b/arch/x86/include/asm/numaq/mpparse.h
index 252292e077b6..a2eeefcd1cc7 100644
--- a/arch/x86/include/asm/numaq/mpparse.h
+++ b/arch/x86/include/asm/numaq/mpparse.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_NUMAQ_MPPARSE_H 1#ifndef __ASM_NUMAQ_MPPARSE_H
2#define __ASM_NUMAQ_MPPARSE_H 2#define __ASM_NUMAQ_MPPARSE_H
3 3
4extern void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, 4extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
5 char *productid);
6 5
7#endif /* __ASM_NUMAQ_MPPARSE_H */ 6#endif /* __ASM_NUMAQ_MPPARSE_H */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 66834c41c049..a977de23cb4d 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -102,9 +102,9 @@ extern void pci_iommu_alloc(void);
102 102
103#ifdef CONFIG_NUMA 103#ifdef CONFIG_NUMA
104/* Returns the node based on pci bus */ 104/* Returns the node based on pci bus */
105static inline int __pcibus_to_node(struct pci_bus *bus) 105static inline int __pcibus_to_node(const struct pci_bus *bus)
106{ 106{
107 struct pci_sysdata *sd = bus->sysdata; 107 const struct pci_sysdata *sd = bus->sysdata;
108 108
109 return sd->node; 109 return sd->node;
110} 110}
@@ -113,6 +113,12 @@ static inline cpumask_t __pcibus_to_cpumask(struct pci_bus *bus)
113{ 113{
114 return node_to_cpumask(__pcibus_to_node(bus)); 114 return node_to_cpumask(__pcibus_to_node(bus));
115} 115}
116
117static inline const struct cpumask *
118cpumask_of_pcibus(const struct pci_bus *bus)
119{
120 return cpumask_of_node(__pcibus_to_node(bus));
121}
116#endif 122#endif
117 123
118#endif /* _ASM_X86_PCI_H */ 124#endif /* _ASM_X86_PCI_H */
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 4fcd53fd5f43..ebe858cdc8a3 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -25,9 +25,9 @@ extern int wakeup_secondary_cpu_via_init(int apicid, unsigned long start_eip);
25/* 25/*
26 * Any setup quirks to be performed? 26 * Any setup quirks to be performed?
27 */ 27 */
28struct mpc_config_processor; 28struct mpc_cpu;
29struct mpc_config_bus; 29struct mpc_bus;
30struct mp_config_oemtable; 30struct mpc_oemtable;
31struct x86_quirks { 31struct x86_quirks {
32 int (*arch_pre_time_init)(void); 32 int (*arch_pre_time_init)(void);
33 int (*arch_time_init)(void); 33 int (*arch_time_init)(void);
@@ -39,10 +39,10 @@ struct x86_quirks {
39 int (*mach_find_smp_config)(unsigned int reserve); 39 int (*mach_find_smp_config)(unsigned int reserve);
40 40
41 int *mpc_record; 41 int *mpc_record;
42 int (*mpc_apic_id)(struct mpc_config_processor *m); 42 int (*mpc_apic_id)(struct mpc_cpu *m);
43 void (*mpc_oem_bus_info)(struct mpc_config_bus *m, char *name); 43 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name);
44 void (*mpc_oem_pci_bus)(struct mpc_config_bus *m); 44 void (*mpc_oem_pci_bus)(struct mpc_bus *m);
45 void (*smp_read_mpc_oem)(struct mp_config_oemtable *oemtable, 45 void (*smp_read_mpc_oem)(struct mpc_oemtable *oemtable,
46 unsigned short oemsize); 46 unsigned short oemsize);
47 int (*setup_ioapic_ids)(void); 47 int (*setup_ioapic_ids)(void);
48 int (*update_genapic)(void); 48 int (*update_genapic)(void);
diff --git a/arch/x86/include/asm/summit/apic.h b/arch/x86/include/asm/summit/apic.h
index 99327d1be49f..4bb5fb34f030 100644
--- a/arch/x86/include/asm/summit/apic.h
+++ b/arch/x86/include/asm/summit/apic.h
@@ -52,7 +52,7 @@ static inline void init_apic_ldr(void)
52 int i; 52 int i;
53 53
54 /* Create logical APIC IDs by counting CPUs already in cluster. */ 54 /* Create logical APIC IDs by counting CPUs already in cluster. */
55 for (count = 0, i = NR_CPUS; --i >= 0; ) { 55 for (count = 0, i = nr_cpu_ids; --i >= 0; ) {
56 lid = cpu_2_logical_apicid[i]; 56 lid = cpu_2_logical_apicid[i];
57 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster) 57 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
58 ++count; 58 ++count;
@@ -97,8 +97,8 @@ static inline int apicid_to_node(int logical_apicid)
97static inline int cpu_to_logical_apicid(int cpu) 97static inline int cpu_to_logical_apicid(int cpu)
98{ 98{
99#ifdef CONFIG_SMP 99#ifdef CONFIG_SMP
100 if (cpu >= NR_CPUS) 100 if (cpu >= nr_cpu_ids)
101 return BAD_APICID; 101 return BAD_APICID;
102 return (int)cpu_2_logical_apicid[cpu]; 102 return (int)cpu_2_logical_apicid[cpu];
103#else 103#else
104 return logical_smp_processor_id(); 104 return logical_smp_processor_id();
@@ -107,7 +107,7 @@ static inline int cpu_to_logical_apicid(int cpu)
107 107
108static inline int cpu_present_to_apicid(int mps_cpu) 108static inline int cpu_present_to_apicid(int mps_cpu)
109{ 109{
110 if (mps_cpu < NR_CPUS) 110 if (mps_cpu < nr_cpu_ids)
111 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu); 111 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
112 else 112 else
113 return BAD_APICID; 113 return BAD_APICID;
@@ -146,7 +146,7 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
146 146
147 num_bits_set = cpus_weight(*cpumask); 147 num_bits_set = cpus_weight(*cpumask);
148 /* Return id to all */ 148 /* Return id to all */
149 if (num_bits_set == NR_CPUS) 149 if (num_bits_set >= nr_cpu_ids)
150 return (int) 0xFF; 150 return (int) 0xFF;
151 /* 151 /*
152 * The cpus in the mask must all be on the apic cluster. If are not 152 * The cpus in the mask must all be on the apic cluster. If are not
@@ -173,42 +173,16 @@ static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
173static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask, 173static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
174 const struct cpumask *andmask) 174 const struct cpumask *andmask)
175{ 175{
176 int num_bits_set; 176 int apicid = cpu_to_logical_apicid(0);
177 int cpus_found = 0;
178 int cpu;
179 int apicid = 0xFF;
180 cpumask_var_t cpumask; 177 cpumask_var_t cpumask;
181 178
182 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) 179 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
183 return (int) 0xFF; 180 return apicid;
184 181
185 cpumask_and(cpumask, inmask, andmask); 182 cpumask_and(cpumask, inmask, andmask);
186 cpumask_and(cpumask, cpumask, cpu_online_mask); 183 cpumask_and(cpumask, cpumask, cpu_online_mask);
184 apicid = cpu_mask_to_apicid(cpumask);
187 185
188 num_bits_set = cpumask_weight(cpumask);
189 /* Return id to all */
190 if (num_bits_set == nr_cpu_ids)
191 goto exit;
192 /*
193 * The cpus in the mask must all be on the apic cluster. If are not
194 * on the same apicid cluster return default value of TARGET_CPUS.
195 */
196 cpu = cpumask_first(cpumask);
197 apicid = cpu_to_logical_apicid(cpu);
198 while (cpus_found < num_bits_set) {
199 if (cpumask_test_cpu(cpu, cpumask)) {
200 int new_apicid = cpu_to_logical_apicid(cpu);
201 if (apicid_cluster(apicid) !=
202 apicid_cluster(new_apicid)){
203 printk ("%s: Not a valid mask!\n", __func__);
204 return 0xFF;
205 }
206 apicid = apicid | new_apicid;
207 cpus_found++;
208 }
209 cpu++;
210 }
211exit:
212 free_cpumask_var(cpumask); 186 free_cpumask_var(cpumask);
213 return apicid; 187 return apicid;
214} 188}
diff --git a/arch/x86/include/asm/summit/mpparse.h b/arch/x86/include/asm/summit/mpparse.h
index 013ce6fab2d5..380e86c02363 100644
--- a/arch/x86/include/asm/summit/mpparse.h
+++ b/arch/x86/include/asm/summit/mpparse.h
@@ -11,7 +11,7 @@ extern void setup_summit(void);
11#define setup_summit() {} 11#define setup_summit() {}
12#endif 12#endif
13 13
14static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 14static inline int mps_oem_check(struct mpc_table *mpc, char *oem,
15 char *productid) 15 char *productid)
16{ 16{
17 if (!strncmp(oem, "IBM ENSW", 8) && 17 if (!strncmp(oem, "IBM ENSW", 8) &&
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 79e31e9dcdda..4e2f2e0aab27 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -61,13 +61,19 @@ static inline int cpu_to_node(int cpu)
61 * 61 *
62 * Side note: this function creates the returned cpumask on the stack 62 * Side note: this function creates the returned cpumask on the stack
63 * so with a high NR_CPUS count, excessive stack space is used. The 63 * so with a high NR_CPUS count, excessive stack space is used. The
64 * node_to_cpumask_ptr function should be used whenever possible. 64 * cpumask_of_node function should be used whenever possible.
65 */ 65 */
66static inline cpumask_t node_to_cpumask(int node) 66static inline cpumask_t node_to_cpumask(int node)
67{ 67{
68 return node_to_cpumask_map[node]; 68 return node_to_cpumask_map[node];
69} 69}
70 70
71/* Returns a bitmask of CPUs on Node 'node'. */
72static inline const struct cpumask *cpumask_of_node(int node)
73{
74 return &node_to_cpumask_map[node];
75}
76
71#else /* CONFIG_X86_64 */ 77#else /* CONFIG_X86_64 */
72 78
73/* Mappings between node number and cpus on that node. */ 79/* Mappings between node number and cpus on that node. */
@@ -82,7 +88,7 @@ DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map);
82#ifdef CONFIG_DEBUG_PER_CPU_MAPS 88#ifdef CONFIG_DEBUG_PER_CPU_MAPS
83extern int cpu_to_node(int cpu); 89extern int cpu_to_node(int cpu);
84extern int early_cpu_to_node(int cpu); 90extern int early_cpu_to_node(int cpu);
85extern const cpumask_t *_node_to_cpumask_ptr(int node); 91extern const cpumask_t *cpumask_of_node(int node);
86extern cpumask_t node_to_cpumask(int node); 92extern cpumask_t node_to_cpumask(int node);
87 93
88#else /* !CONFIG_DEBUG_PER_CPU_MAPS */ 94#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
@@ -103,7 +109,7 @@ static inline int early_cpu_to_node(int cpu)
103} 109}
104 110
105/* Returns a pointer to the cpumask of CPUs on Node 'node'. */ 111/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
106static inline const cpumask_t *_node_to_cpumask_ptr(int node) 112static inline const cpumask_t *cpumask_of_node(int node)
107{ 113{
108 return &node_to_cpumask_map[node]; 114 return &node_to_cpumask_map[node];
109} 115}
@@ -116,12 +122,15 @@ static inline cpumask_t node_to_cpumask(int node)
116 122
117#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ 123#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
118 124
119/* Replace default node_to_cpumask_ptr with optimized version */ 125/*
126 * Replace default node_to_cpumask_ptr with optimized version
127 * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
128 */
120#define node_to_cpumask_ptr(v, node) \ 129#define node_to_cpumask_ptr(v, node) \
121 const cpumask_t *v = _node_to_cpumask_ptr(node) 130 const cpumask_t *v = cpumask_of_node(node)
122 131
123#define node_to_cpumask_ptr_next(v, node) \ 132#define node_to_cpumask_ptr_next(v, node) \
124 v = _node_to_cpumask_ptr(node) 133 v = cpumask_of_node(node)
125 134
126#endif /* CONFIG_X86_64 */ 135#endif /* CONFIG_X86_64 */
127 136
@@ -187,7 +196,7 @@ extern int __node_distance(int, int);
187#define cpu_to_node(cpu) 0 196#define cpu_to_node(cpu) 0
188#define early_cpu_to_node(cpu) 0 197#define early_cpu_to_node(cpu) 0
189 198
190static inline const cpumask_t *_node_to_cpumask_ptr(int node) 199static inline const cpumask_t *cpumask_of_node(int node)
191{ 200{
192 return &cpu_online_map; 201 return &cpu_online_map;
193} 202}
@@ -200,12 +209,15 @@ static inline int node_to_first_cpu(int node)
200 return first_cpu(cpu_online_map); 209 return first_cpu(cpu_online_map);
201} 210}
202 211
203/* Replace default node_to_cpumask_ptr with optimized version */ 212/*
213 * Replace default node_to_cpumask_ptr with optimized version
214 * Deprecated: use "const struct cpumask *mask = cpumask_of_node(node)"
215 */
204#define node_to_cpumask_ptr(v, node) \ 216#define node_to_cpumask_ptr(v, node) \
205 const cpumask_t *v = _node_to_cpumask_ptr(node) 217 const cpumask_t *v = cpumask_of_node(node)
206 218
207#define node_to_cpumask_ptr_next(v, node) \ 219#define node_to_cpumask_ptr_next(v, node) \
208 v = _node_to_cpumask_ptr(node) 220 v = cpumask_of_node(node)
209#endif 221#endif
210 222
211#include <asm-generic/topology.h> 223#include <asm-generic/topology.h>
@@ -214,12 +226,12 @@ static inline int node_to_first_cpu(int node)
214/* Returns the number of the first CPU on Node 'node'. */ 226/* Returns the number of the first CPU on Node 'node'. */
215static inline int node_to_first_cpu(int node) 227static inline int node_to_first_cpu(int node)
216{ 228{
217 node_to_cpumask_ptr(mask, node); 229 return cpumask_first(cpumask_of_node(node));
218 return first_cpu(*mask);
219} 230}
220#endif 231#endif
221 232
222extern cpumask_t cpu_coregroup_map(int cpu); 233extern cpumask_t cpu_coregroup_map(int cpu);
234extern const struct cpumask *cpu_coregroup_mask(int cpu);
223 235
224#ifdef ENABLE_TOPO_DEFINES 236#ifdef ENABLE_TOPO_DEFINES
225#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id) 237#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 65d0b72777ea..29dc0c89d4af 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -538,9 +538,10 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
538 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 538 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
539 union acpi_object *obj; 539 union acpi_object *obj;
540 struct acpi_madt_local_apic *lapic; 540 struct acpi_madt_local_apic *lapic;
541 cpumask_t tmp_map, new_map; 541 cpumask_var_t tmp_map, new_map;
542 u8 physid; 542 u8 physid;
543 int cpu; 543 int cpu;
544 int retval = -ENOMEM;
544 545
545 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 546 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
546 return -EINVAL; 547 return -EINVAL;
@@ -569,23 +570,37 @@ static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
569 buffer.length = ACPI_ALLOCATE_BUFFER; 570 buffer.length = ACPI_ALLOCATE_BUFFER;
570 buffer.pointer = NULL; 571 buffer.pointer = NULL;
571 572
572 tmp_map = cpu_present_map; 573 if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
574 goto out;
575
576 if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
577 goto free_tmp_map;
578
579 cpumask_copy(tmp_map, cpu_present_mask);
573 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED); 580 acpi_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);
574 581
575 /* 582 /*
576 * If mp_register_lapic successfully generates a new logical cpu 583 * If mp_register_lapic successfully generates a new logical cpu
577 * number, then the following will get us exactly what was mapped 584 * number, then the following will get us exactly what was mapped
578 */ 585 */
579 cpus_andnot(new_map, cpu_present_map, tmp_map); 586 cpumask_andnot(new_map, cpu_present_mask, tmp_map);
580 if (cpus_empty(new_map)) { 587 if (cpumask_empty(new_map)) {
581 printk ("Unable to map lapic to logical cpu number\n"); 588 printk ("Unable to map lapic to logical cpu number\n");
582 return -EINVAL; 589 retval = -EINVAL;
590 goto free_new_map;
583 } 591 }
584 592
585 cpu = first_cpu(new_map); 593 cpu = cpumask_first(new_map);
586 594
587 *pcpu = cpu; 595 *pcpu = cpu;
588 return 0; 596 retval = 0;
597
598free_new_map:
599 free_cpumask_var(new_map);
600free_tmp_map:
601 free_cpumask_var(tmp_map);
602out:
603 return retval;
589} 604}
590 605
591/* wrapper to silence section mismatch warning */ 606/* wrapper to silence section mismatch warning */
@@ -598,7 +613,7 @@ EXPORT_SYMBOL(acpi_map_lsapic);
598int acpi_unmap_lsapic(int cpu) 613int acpi_unmap_lsapic(int cpu)
599{ 614{
600 per_cpu(x86_cpu_to_apicid, cpu) = -1; 615 per_cpu(x86_cpu_to_apicid, cpu) = -1;
601 cpu_clear(cpu, cpu_present_map); 616 set_cpu_present(cpu, false);
602 num_processors--; 617 num_processors--;
603 618
604 return (0); 619 return (0);
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 658e29e0f49b..5113c080f0c4 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -20,8 +20,12 @@
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/gfp.h> 21#include <linux/gfp.h>
22#include <linux/bitops.h> 22#include <linux/bitops.h>
23#include <linux/debugfs.h>
23#include <linux/scatterlist.h> 24#include <linux/scatterlist.h>
24#include <linux/iommu-helper.h> 25#include <linux/iommu-helper.h>
26#ifdef CONFIG_IOMMU_API
27#include <linux/iommu.h>
28#endif
25#include <asm/proto.h> 29#include <asm/proto.h>
26#include <asm/iommu.h> 30#include <asm/iommu.h>
27#include <asm/gart.h> 31#include <asm/gart.h>
@@ -38,6 +42,10 @@ static DEFINE_RWLOCK(amd_iommu_devtable_lock);
38static LIST_HEAD(iommu_pd_list); 42static LIST_HEAD(iommu_pd_list);
39static DEFINE_SPINLOCK(iommu_pd_list_lock); 43static DEFINE_SPINLOCK(iommu_pd_list_lock);
40 44
45#ifdef CONFIG_IOMMU_API
46static struct iommu_ops amd_iommu_ops;
47#endif
48
41/* 49/*
42 * general struct to manage commands send to an IOMMU 50 * general struct to manage commands send to an IOMMU
43 */ 51 */
@@ -47,6 +55,68 @@ struct iommu_cmd {
47 55
48static int dma_ops_unity_map(struct dma_ops_domain *dma_dom, 56static int dma_ops_unity_map(struct dma_ops_domain *dma_dom,
49 struct unity_map_entry *e); 57 struct unity_map_entry *e);
58static struct dma_ops_domain *find_protection_domain(u16 devid);
59
60
61#ifdef CONFIG_AMD_IOMMU_STATS
62
63/*
64 * Initialization code for statistics collection
65 */
66
67DECLARE_STATS_COUNTER(compl_wait);
68DECLARE_STATS_COUNTER(cnt_map_single);
69DECLARE_STATS_COUNTER(cnt_unmap_single);
70DECLARE_STATS_COUNTER(cnt_map_sg);
71DECLARE_STATS_COUNTER(cnt_unmap_sg);
72DECLARE_STATS_COUNTER(cnt_alloc_coherent);
73DECLARE_STATS_COUNTER(cnt_free_coherent);
74DECLARE_STATS_COUNTER(cross_page);
75DECLARE_STATS_COUNTER(domain_flush_single);
76DECLARE_STATS_COUNTER(domain_flush_all);
77DECLARE_STATS_COUNTER(alloced_io_mem);
78DECLARE_STATS_COUNTER(total_map_requests);
79
80static struct dentry *stats_dir;
81static struct dentry *de_isolate;
82static struct dentry *de_fflush;
83
84static void amd_iommu_stats_add(struct __iommu_counter *cnt)
85{
86 if (stats_dir == NULL)
87 return;
88
89 cnt->dent = debugfs_create_u64(cnt->name, 0444, stats_dir,
90 &cnt->value);
91}
92
93static void amd_iommu_stats_init(void)
94{
95 stats_dir = debugfs_create_dir("amd-iommu", NULL);
96 if (stats_dir == NULL)
97 return;
98
99 de_isolate = debugfs_create_bool("isolation", 0444, stats_dir,
100 (u32 *)&amd_iommu_isolate);
101
102 de_fflush = debugfs_create_bool("fullflush", 0444, stats_dir,
103 (u32 *)&amd_iommu_unmap_flush);
104
105 amd_iommu_stats_add(&compl_wait);
106 amd_iommu_stats_add(&cnt_map_single);
107 amd_iommu_stats_add(&cnt_unmap_single);
108 amd_iommu_stats_add(&cnt_map_sg);
109 amd_iommu_stats_add(&cnt_unmap_sg);
110 amd_iommu_stats_add(&cnt_alloc_coherent);
111 amd_iommu_stats_add(&cnt_free_coherent);
112 amd_iommu_stats_add(&cross_page);
113 amd_iommu_stats_add(&domain_flush_single);
114 amd_iommu_stats_add(&domain_flush_all);
115 amd_iommu_stats_add(&alloced_io_mem);
116 amd_iommu_stats_add(&total_map_requests);
117}
118
119#endif
50 120
51/* returns !0 if the IOMMU is caching non-present entries in its TLB */ 121/* returns !0 if the IOMMU is caching non-present entries in its TLB */
52static int iommu_has_npcache(struct amd_iommu *iommu) 122static int iommu_has_npcache(struct amd_iommu *iommu)
@@ -189,13 +259,55 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
189 spin_lock_irqsave(&iommu->lock, flags); 259 spin_lock_irqsave(&iommu->lock, flags);
190 ret = __iommu_queue_command(iommu, cmd); 260 ret = __iommu_queue_command(iommu, cmd);
191 if (!ret) 261 if (!ret)
192 iommu->need_sync = 1; 262 iommu->need_sync = true;
193 spin_unlock_irqrestore(&iommu->lock, flags); 263 spin_unlock_irqrestore(&iommu->lock, flags);
194 264
195 return ret; 265 return ret;
196} 266}
197 267
198/* 268/*
269 * This function waits until an IOMMU has completed a completion
270 * wait command
271 */
272static void __iommu_wait_for_completion(struct amd_iommu *iommu)
273{
274 int ready = 0;
275 unsigned status = 0;
276 unsigned long i = 0;
277
278 INC_STATS_COUNTER(compl_wait);
279
280 while (!ready && (i < EXIT_LOOP_COUNT)) {
281 ++i;
282 /* wait for the bit to become one */
283 status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);
284 ready = status & MMIO_STATUS_COM_WAIT_INT_MASK;
285 }
286
287 /* set bit back to zero */
288 status &= ~MMIO_STATUS_COM_WAIT_INT_MASK;
289 writel(status, iommu->mmio_base + MMIO_STATUS_OFFSET);
290
291 if (unlikely(i == EXIT_LOOP_COUNT))
292 panic("AMD IOMMU: Completion wait loop failed\n");
293}
294
295/*
296 * This function queues a completion wait command into the command
297 * buffer of an IOMMU
298 */
299static int __iommu_completion_wait(struct amd_iommu *iommu)
300{
301 struct iommu_cmd cmd;
302
303 memset(&cmd, 0, sizeof(cmd));
304 cmd.data[0] = CMD_COMPL_WAIT_INT_MASK;
305 CMD_SET_TYPE(&cmd, CMD_COMPL_WAIT);
306
307 return __iommu_queue_command(iommu, &cmd);
308}
309
310/*
199 * This function is called whenever we need to ensure that the IOMMU has 311 * This function is called whenever we need to ensure that the IOMMU has
200 * completed execution of all commands we sent. It sends a 312 * completed execution of all commands we sent. It sends a
201 * COMPLETION_WAIT command and waits for it to finish. The IOMMU informs 313 * COMPLETION_WAIT command and waits for it to finish. The IOMMU informs
@@ -204,40 +316,22 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)
204 */ 316 */
205static int iommu_completion_wait(struct amd_iommu *iommu) 317static int iommu_completion_wait(struct amd_iommu *iommu)
206{ 318{
207 int ret = 0, ready = 0; 319 int ret = 0;
208 unsigned status = 0; 320 unsigned long flags;
209 struct iommu_cmd cmd;
210 unsigned long flags, i = 0;
211
212 memset(&cmd, 0, sizeof(cmd));
213 cmd.data[0] = CMD_COMPL_WAIT_INT_MASK;
214 CMD_SET_TYPE(&cmd, CMD_COMPL_WAIT);
215 321
216 spin_lock_irqsave(&iommu->lock, flags); 322 spin_lock_irqsave(&iommu->lock, flags);
217 323
218 if (!iommu->need_sync) 324 if (!iommu->need_sync)
219 goto out; 325 goto out;
220 326
221 iommu->need_sync = 0; 327 ret = __iommu_completion_wait(iommu);
222 328
223 ret = __iommu_queue_command(iommu, &cmd); 329 iommu->need_sync = false;
224 330
225 if (ret) 331 if (ret)
226 goto out; 332 goto out;
227 333
228 while (!ready && (i < EXIT_LOOP_COUNT)) { 334 __iommu_wait_for_completion(iommu);
229 ++i;
230 /* wait for the bit to become one */
231 status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);
232 ready = status & MMIO_STATUS_COM_WAIT_INT_MASK;
233 }
234
235 /* set bit back to zero */
236 status &= ~MMIO_STATUS_COM_WAIT_INT_MASK;
237 writel(status, iommu->mmio_base + MMIO_STATUS_OFFSET);
238
239 if (unlikely(i == EXIT_LOOP_COUNT))
240 panic("AMD IOMMU: Completion wait loop failed\n");
241 335
242out: 336out:
243 spin_unlock_irqrestore(&iommu->lock, flags); 337 spin_unlock_irqrestore(&iommu->lock, flags);
@@ -264,6 +358,21 @@ static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid)
264 return ret; 358 return ret;
265} 359}
266 360
361static void __iommu_build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address,
362 u16 domid, int pde, int s)
363{
364 memset(cmd, 0, sizeof(*cmd));
365 address &= PAGE_MASK;
366 CMD_SET_TYPE(cmd, CMD_INV_IOMMU_PAGES);
367 cmd->data[1] |= domid;
368 cmd->data[2] = lower_32_bits(address);
369 cmd->data[3] = upper_32_bits(address);
370 if (s) /* size bit - we flush more than one 4kb page */
371 cmd->data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
372 if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
373 cmd->data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;
374}
375
267/* 376/*
268 * Generic command send function for invalidaing TLB entries 377 * Generic command send function for invalidaing TLB entries
269 */ 378 */
@@ -273,16 +382,7 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,
273 struct iommu_cmd cmd; 382 struct iommu_cmd cmd;
274 int ret; 383 int ret;
275 384
276 memset(&cmd, 0, sizeof(cmd)); 385 __iommu_build_inv_iommu_pages(&cmd, address, domid, pde, s);
277 address &= PAGE_MASK;
278 CMD_SET_TYPE(&cmd, CMD_INV_IOMMU_PAGES);
279 cmd.data[1] |= domid;
280 cmd.data[2] = lower_32_bits(address);
281 cmd.data[3] = upper_32_bits(address);
282 if (s) /* size bit - we flush more than one 4kb page */
283 cmd.data[2] |= CMD_INV_IOMMU_PAGES_SIZE_MASK;
284 if (pde) /* PDE bit - we wan't flush everything not only the PTEs */
285 cmd.data[2] |= CMD_INV_IOMMU_PAGES_PDE_MASK;
286 386
287 ret = iommu_queue_command(iommu, &cmd); 387 ret = iommu_queue_command(iommu, &cmd);
288 388
@@ -321,9 +421,35 @@ static void iommu_flush_tlb(struct amd_iommu *iommu, u16 domid)
321{ 421{
322 u64 address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS; 422 u64 address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS;
323 423
424 INC_STATS_COUNTER(domain_flush_single);
425
324 iommu_queue_inv_iommu_pages(iommu, address, domid, 0, 1); 426 iommu_queue_inv_iommu_pages(iommu, address, domid, 0, 1);
325} 427}
326 428
429/*
430 * This function is used to flush the IO/TLB for a given protection domain
431 * on every IOMMU in the system
432 */
433static void iommu_flush_domain(u16 domid)
434{
435 unsigned long flags;
436 struct amd_iommu *iommu;
437 struct iommu_cmd cmd;
438
439 INC_STATS_COUNTER(domain_flush_all);
440
441 __iommu_build_inv_iommu_pages(&cmd, CMD_INV_IOMMU_ALL_PAGES_ADDRESS,
442 domid, 1, 1);
443
444 list_for_each_entry(iommu, &amd_iommu_list, list) {
445 spin_lock_irqsave(&iommu->lock, flags);
446 __iommu_queue_command(iommu, &cmd);
447 __iommu_completion_wait(iommu);
448 __iommu_wait_for_completion(iommu);
449 spin_unlock_irqrestore(&iommu->lock, flags);
450 }
451}
452
327/**************************************************************************** 453/****************************************************************************
328 * 454 *
329 * The functions below are used the create the page table mappings for 455 * The functions below are used the create the page table mappings for
@@ -338,10 +464,10 @@ static void iommu_flush_tlb(struct amd_iommu *iommu, u16 domid)
338 * supporting all features of AMD IOMMU page tables like level skipping 464 * supporting all features of AMD IOMMU page tables like level skipping
339 * and full 64 bit address spaces. 465 * and full 64 bit address spaces.
340 */ 466 */
341static int iommu_map(struct protection_domain *dom, 467static int iommu_map_page(struct protection_domain *dom,
342 unsigned long bus_addr, 468 unsigned long bus_addr,
343 unsigned long phys_addr, 469 unsigned long phys_addr,
344 int prot) 470 int prot)
345{ 471{
346 u64 __pte, *pte, *page; 472 u64 __pte, *pte, *page;
347 473
@@ -388,6 +514,28 @@ static int iommu_map(struct protection_domain *dom,
388 return 0; 514 return 0;
389} 515}
390 516
517static void iommu_unmap_page(struct protection_domain *dom,
518 unsigned long bus_addr)
519{
520 u64 *pte;
521
522 pte = &dom->pt_root[IOMMU_PTE_L2_INDEX(bus_addr)];
523
524 if (!IOMMU_PTE_PRESENT(*pte))
525 return;
526
527 pte = IOMMU_PTE_PAGE(*pte);
528 pte = &pte[IOMMU_PTE_L1_INDEX(bus_addr)];
529
530 if (!IOMMU_PTE_PRESENT(*pte))
531 return;
532
533 pte = IOMMU_PTE_PAGE(*pte);
534 pte = &pte[IOMMU_PTE_L1_INDEX(bus_addr)];
535
536 *pte = 0;
537}
538
391/* 539/*
392 * This function checks if a specific unity mapping entry is needed for 540 * This function checks if a specific unity mapping entry is needed for
393 * this specific IOMMU. 541 * this specific IOMMU.
@@ -440,7 +588,7 @@ static int dma_ops_unity_map(struct dma_ops_domain *dma_dom,
440 588
441 for (addr = e->address_start; addr < e->address_end; 589 for (addr = e->address_start; addr < e->address_end;
442 addr += PAGE_SIZE) { 590 addr += PAGE_SIZE) {
443 ret = iommu_map(&dma_dom->domain, addr, addr, e->prot); 591 ret = iommu_map_page(&dma_dom->domain, addr, addr, e->prot);
444 if (ret) 592 if (ret)
445 return ret; 593 return ret;
446 /* 594 /*
@@ -571,6 +719,16 @@ static u16 domain_id_alloc(void)
571 return id; 719 return id;
572} 720}
573 721
722static void domain_id_free(int id)
723{
724 unsigned long flags;
725
726 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
727 if (id > 0 && id < MAX_DOMAIN_ID)
728 __clear_bit(id, amd_iommu_pd_alloc_bitmap);
729 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
730}
731
574/* 732/*
575 * Used to reserve address ranges in the aperture (e.g. for exclusion 733 * Used to reserve address ranges in the aperture (e.g. for exclusion
576 * ranges. 734 * ranges.
@@ -587,12 +745,12 @@ static void dma_ops_reserve_addresses(struct dma_ops_domain *dom,
587 iommu_area_reserve(dom->bitmap, start_page, pages); 745 iommu_area_reserve(dom->bitmap, start_page, pages);
588} 746}
589 747
590static void dma_ops_free_pagetable(struct dma_ops_domain *dma_dom) 748static void free_pagetable(struct protection_domain *domain)
591{ 749{
592 int i, j; 750 int i, j;
593 u64 *p1, *p2, *p3; 751 u64 *p1, *p2, *p3;
594 752
595 p1 = dma_dom->domain.pt_root; 753 p1 = domain->pt_root;
596 754
597 if (!p1) 755 if (!p1)
598 return; 756 return;
@@ -613,6 +771,8 @@ static void dma_ops_free_pagetable(struct dma_ops_domain *dma_dom)
613 } 771 }
614 772
615 free_page((unsigned long)p1); 773 free_page((unsigned long)p1);
774
775 domain->pt_root = NULL;
616} 776}
617 777
618/* 778/*
@@ -624,7 +784,7 @@ static void dma_ops_domain_free(struct dma_ops_domain *dom)
624 if (!dom) 784 if (!dom)
625 return; 785 return;
626 786
627 dma_ops_free_pagetable(dom); 787 free_pagetable(&dom->domain);
628 788
629 kfree(dom->pte_pages); 789 kfree(dom->pte_pages);
630 790
@@ -663,6 +823,7 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu,
663 goto free_dma_dom; 823 goto free_dma_dom;
664 dma_dom->domain.mode = PAGE_MODE_3_LEVEL; 824 dma_dom->domain.mode = PAGE_MODE_3_LEVEL;
665 dma_dom->domain.pt_root = (void *)get_zeroed_page(GFP_KERNEL); 825 dma_dom->domain.pt_root = (void *)get_zeroed_page(GFP_KERNEL);
826 dma_dom->domain.flags = PD_DMA_OPS_MASK;
666 dma_dom->domain.priv = dma_dom; 827 dma_dom->domain.priv = dma_dom;
667 if (!dma_dom->domain.pt_root) 828 if (!dma_dom->domain.pt_root)
668 goto free_dma_dom; 829 goto free_dma_dom;
@@ -725,6 +886,15 @@ free_dma_dom:
725} 886}
726 887
727/* 888/*
889 * little helper function to check whether a given protection domain is a
890 * dma_ops domain
891 */
892static bool dma_ops_domain(struct protection_domain *domain)
893{
894 return domain->flags & PD_DMA_OPS_MASK;
895}
896
897/*
728 * Find out the protection domain structure for a given PCI device. This 898 * Find out the protection domain structure for a given PCI device. This
729 * will give us the pointer to the page table root for example. 899 * will give us the pointer to the page table root for example.
730 */ 900 */
@@ -744,14 +914,15 @@ static struct protection_domain *domain_for_device(u16 devid)
744 * If a device is not yet associated with a domain, this function does 914 * If a device is not yet associated with a domain, this function does
745 * assigns it visible for the hardware 915 * assigns it visible for the hardware
746 */ 916 */
747static void set_device_domain(struct amd_iommu *iommu, 917static void attach_device(struct amd_iommu *iommu,
748 struct protection_domain *domain, 918 struct protection_domain *domain,
749 u16 devid) 919 u16 devid)
750{ 920{
751 unsigned long flags; 921 unsigned long flags;
752
753 u64 pte_root = virt_to_phys(domain->pt_root); 922 u64 pte_root = virt_to_phys(domain->pt_root);
754 923
924 domain->dev_cnt += 1;
925
755 pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK) 926 pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
756 << DEV_ENTRY_MODE_SHIFT; 927 << DEV_ENTRY_MODE_SHIFT;
757 pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV; 928 pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV;
@@ -767,6 +938,116 @@ static void set_device_domain(struct amd_iommu *iommu,
767 iommu_queue_inv_dev_entry(iommu, devid); 938 iommu_queue_inv_dev_entry(iommu, devid);
768} 939}
769 940
941/*
942 * Removes a device from a protection domain (unlocked)
943 */
944static void __detach_device(struct protection_domain *domain, u16 devid)
945{
946
947 /* lock domain */
948 spin_lock(&domain->lock);
949
950 /* remove domain from the lookup table */
951 amd_iommu_pd_table[devid] = NULL;
952
953 /* remove entry from the device table seen by the hardware */
954 amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
955 amd_iommu_dev_table[devid].data[1] = 0;
956 amd_iommu_dev_table[devid].data[2] = 0;
957
958 /* decrease reference counter */
959 domain->dev_cnt -= 1;
960
961 /* ready */
962 spin_unlock(&domain->lock);
963}
964
965/*
966 * Removes a device from a protection domain (with devtable_lock held)
967 */
968static void detach_device(struct protection_domain *domain, u16 devid)
969{
970 unsigned long flags;
971
972 /* lock device table */
973 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
974 __detach_device(domain, devid);
975 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
976}
977
978static int device_change_notifier(struct notifier_block *nb,
979 unsigned long action, void *data)
980{
981 struct device *dev = data;
982 struct pci_dev *pdev = to_pci_dev(dev);
983 u16 devid = calc_devid(pdev->bus->number, pdev->devfn);
984 struct protection_domain *domain;
985 struct dma_ops_domain *dma_domain;
986 struct amd_iommu *iommu;
987 int order = amd_iommu_aperture_order;
988 unsigned long flags;
989
990 if (devid > amd_iommu_last_bdf)
991 goto out;
992
993 devid = amd_iommu_alias_table[devid];
994
995 iommu = amd_iommu_rlookup_table[devid];
996 if (iommu == NULL)
997 goto out;
998
999 domain = domain_for_device(devid);
1000
1001 if (domain && !dma_ops_domain(domain))
1002 WARN_ONCE(1, "AMD IOMMU WARNING: device %s already bound "
1003 "to a non-dma-ops domain\n", dev_name(dev));
1004
1005 switch (action) {
1006 case BUS_NOTIFY_BOUND_DRIVER:
1007 if (domain)
1008 goto out;
1009 dma_domain = find_protection_domain(devid);
1010 if (!dma_domain)
1011 dma_domain = iommu->default_dom;
1012 attach_device(iommu, &dma_domain->domain, devid);
1013 printk(KERN_INFO "AMD IOMMU: Using protection domain %d for "
1014 "device %s\n", dma_domain->domain.id, dev_name(dev));
1015 break;
1016 case BUS_NOTIFY_UNBIND_DRIVER:
1017 if (!domain)
1018 goto out;
1019 detach_device(domain, devid);
1020 break;
1021 case BUS_NOTIFY_ADD_DEVICE:
1022 /* allocate a protection domain if a device is added */
1023 dma_domain = find_protection_domain(devid);
1024 if (dma_domain)
1025 goto out;
1026 dma_domain = dma_ops_domain_alloc(iommu, order);
1027 if (!dma_domain)
1028 goto out;
1029 dma_domain->target_dev = devid;
1030
1031 spin_lock_irqsave(&iommu_pd_list_lock, flags);
1032 list_add_tail(&dma_domain->list, &iommu_pd_list);
1033 spin_unlock_irqrestore(&iommu_pd_list_lock, flags);
1034
1035 break;
1036 default:
1037 goto out;
1038 }
1039
1040 iommu_queue_inv_dev_entry(iommu, devid);
1041 iommu_completion_wait(iommu);
1042
1043out:
1044 return 0;
1045}
1046
1047struct notifier_block device_nb = {
1048 .notifier_call = device_change_notifier,
1049};
1050
770/***************************************************************************** 1051/*****************************************************************************
771 * 1052 *
772 * The next functions belong to the dma_ops mapping/unmapping code. 1053 * The next functions belong to the dma_ops mapping/unmapping code.
@@ -802,7 +1083,6 @@ static struct dma_ops_domain *find_protection_domain(u16 devid)
802 list_for_each_entry(entry, &iommu_pd_list, list) { 1083 list_for_each_entry(entry, &iommu_pd_list, list) {
803 if (entry->target_dev == devid) { 1084 if (entry->target_dev == devid) {
804 ret = entry; 1085 ret = entry;
805 list_del(&ret->list);
806 break; 1086 break;
807 } 1087 }
808 } 1088 }
@@ -853,14 +1133,13 @@ static int get_device_resources(struct device *dev,
853 if (!dma_dom) 1133 if (!dma_dom)
854 dma_dom = (*iommu)->default_dom; 1134 dma_dom = (*iommu)->default_dom;
855 *domain = &dma_dom->domain; 1135 *domain = &dma_dom->domain;
856 set_device_domain(*iommu, *domain, *bdf); 1136 attach_device(*iommu, *domain, *bdf);
857 printk(KERN_INFO "AMD IOMMU: Using protection domain %d for " 1137 printk(KERN_INFO "AMD IOMMU: Using protection domain %d for "
858 "device ", (*domain)->id); 1138 "device %s\n", (*domain)->id, dev_name(dev));
859 print_devid(_bdf, 1);
860 } 1139 }
861 1140
862 if (domain_for_device(_bdf) == NULL) 1141 if (domain_for_device(_bdf) == NULL)
863 set_device_domain(*iommu, *domain, _bdf); 1142 attach_device(*iommu, *domain, _bdf);
864 1143
865 return 1; 1144 return 1;
866} 1145}
@@ -946,6 +1225,11 @@ static dma_addr_t __map_single(struct device *dev,
946 pages = iommu_num_pages(paddr, size, PAGE_SIZE); 1225 pages = iommu_num_pages(paddr, size, PAGE_SIZE);
947 paddr &= PAGE_MASK; 1226 paddr &= PAGE_MASK;
948 1227
1228 INC_STATS_COUNTER(total_map_requests);
1229
1230 if (pages > 1)
1231 INC_STATS_COUNTER(cross_page);
1232
949 if (align) 1233 if (align)
950 align_mask = (1UL << get_order(size)) - 1; 1234 align_mask = (1UL << get_order(size)) - 1;
951 1235
@@ -962,6 +1246,8 @@ static dma_addr_t __map_single(struct device *dev,
962 } 1246 }
963 address += offset; 1247 address += offset;
964 1248
1249 ADD_STATS_COUNTER(alloced_io_mem, size);
1250
965 if (unlikely(dma_dom->need_flush && !amd_iommu_unmap_flush)) { 1251 if (unlikely(dma_dom->need_flush && !amd_iommu_unmap_flush)) {
966 iommu_flush_tlb(iommu, dma_dom->domain.id); 1252 iommu_flush_tlb(iommu, dma_dom->domain.id);
967 dma_dom->need_flush = false; 1253 dma_dom->need_flush = false;
@@ -998,6 +1284,8 @@ static void __unmap_single(struct amd_iommu *iommu,
998 start += PAGE_SIZE; 1284 start += PAGE_SIZE;
999 } 1285 }
1000 1286
1287 SUB_STATS_COUNTER(alloced_io_mem, size);
1288
1001 dma_ops_free_addresses(dma_dom, dma_addr, pages); 1289 dma_ops_free_addresses(dma_dom, dma_addr, pages);
1002 1290
1003 if (amd_iommu_unmap_flush || dma_dom->need_flush) { 1291 if (amd_iommu_unmap_flush || dma_dom->need_flush) {
@@ -1019,6 +1307,8 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr,
1019 dma_addr_t addr; 1307 dma_addr_t addr;
1020 u64 dma_mask; 1308 u64 dma_mask;
1021 1309
1310 INC_STATS_COUNTER(cnt_map_single);
1311
1022 if (!check_device(dev)) 1312 if (!check_device(dev))
1023 return bad_dma_address; 1313 return bad_dma_address;
1024 1314
@@ -1030,6 +1320,9 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr,
1030 /* device not handled by any AMD IOMMU */ 1320 /* device not handled by any AMD IOMMU */
1031 return (dma_addr_t)paddr; 1321 return (dma_addr_t)paddr;
1032 1322
1323 if (!dma_ops_domain(domain))
1324 return bad_dma_address;
1325
1033 spin_lock_irqsave(&domain->lock, flags); 1326 spin_lock_irqsave(&domain->lock, flags);
1034 addr = __map_single(dev, iommu, domain->priv, paddr, size, dir, false, 1327 addr = __map_single(dev, iommu, domain->priv, paddr, size, dir, false,
1035 dma_mask); 1328 dma_mask);
@@ -1055,11 +1348,16 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr,
1055 struct protection_domain *domain; 1348 struct protection_domain *domain;
1056 u16 devid; 1349 u16 devid;
1057 1350
1351 INC_STATS_COUNTER(cnt_unmap_single);
1352
1058 if (!check_device(dev) || 1353 if (!check_device(dev) ||
1059 !get_device_resources(dev, &iommu, &domain, &devid)) 1354 !get_device_resources(dev, &iommu, &domain, &devid))
1060 /* device not handled by any AMD IOMMU */ 1355 /* device not handled by any AMD IOMMU */
1061 return; 1356 return;
1062 1357
1358 if (!dma_ops_domain(domain))
1359 return;
1360
1063 spin_lock_irqsave(&domain->lock, flags); 1361 spin_lock_irqsave(&domain->lock, flags);
1064 1362
1065 __unmap_single(iommu, domain->priv, dma_addr, size, dir); 1363 __unmap_single(iommu, domain->priv, dma_addr, size, dir);
@@ -1104,6 +1402,8 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
1104 int mapped_elems = 0; 1402 int mapped_elems = 0;
1105 u64 dma_mask; 1403 u64 dma_mask;
1106 1404
1405 INC_STATS_COUNTER(cnt_map_sg);
1406
1107 if (!check_device(dev)) 1407 if (!check_device(dev))
1108 return 0; 1408 return 0;
1109 1409
@@ -1114,6 +1414,9 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
1114 if (!iommu || !domain) 1414 if (!iommu || !domain)
1115 return map_sg_no_iommu(dev, sglist, nelems, dir); 1415 return map_sg_no_iommu(dev, sglist, nelems, dir);
1116 1416
1417 if (!dma_ops_domain(domain))
1418 return 0;
1419
1117 spin_lock_irqsave(&domain->lock, flags); 1420 spin_lock_irqsave(&domain->lock, flags);
1118 1421
1119 for_each_sg(sglist, s, nelems, i) { 1422 for_each_sg(sglist, s, nelems, i) {
@@ -1163,10 +1466,15 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
1163 u16 devid; 1466 u16 devid;
1164 int i; 1467 int i;
1165 1468
1469 INC_STATS_COUNTER(cnt_unmap_sg);
1470
1166 if (!check_device(dev) || 1471 if (!check_device(dev) ||
1167 !get_device_resources(dev, &iommu, &domain, &devid)) 1472 !get_device_resources(dev, &iommu, &domain, &devid))
1168 return; 1473 return;
1169 1474
1475 if (!dma_ops_domain(domain))
1476 return;
1477
1170 spin_lock_irqsave(&domain->lock, flags); 1478 spin_lock_irqsave(&domain->lock, flags);
1171 1479
1172 for_each_sg(sglist, s, nelems, i) { 1480 for_each_sg(sglist, s, nelems, i) {
@@ -1194,6 +1502,8 @@ static void *alloc_coherent(struct device *dev, size_t size,
1194 phys_addr_t paddr; 1502 phys_addr_t paddr;
1195 u64 dma_mask = dev->coherent_dma_mask; 1503 u64 dma_mask = dev->coherent_dma_mask;
1196 1504
1505 INC_STATS_COUNTER(cnt_alloc_coherent);
1506
1197 if (!check_device(dev)) 1507 if (!check_device(dev))
1198 return NULL; 1508 return NULL;
1199 1509
@@ -1212,6 +1522,9 @@ static void *alloc_coherent(struct device *dev, size_t size,
1212 return virt_addr; 1522 return virt_addr;
1213 } 1523 }
1214 1524
1525 if (!dma_ops_domain(domain))
1526 goto out_free;
1527
1215 if (!dma_mask) 1528 if (!dma_mask)
1216 dma_mask = *dev->dma_mask; 1529 dma_mask = *dev->dma_mask;
1217 1530
@@ -1220,18 +1533,20 @@ static void *alloc_coherent(struct device *dev, size_t size,
1220 *dma_addr = __map_single(dev, iommu, domain->priv, paddr, 1533 *dma_addr = __map_single(dev, iommu, domain->priv, paddr,
1221 size, DMA_BIDIRECTIONAL, true, dma_mask); 1534 size, DMA_BIDIRECTIONAL, true, dma_mask);
1222 1535
1223 if (*dma_addr == bad_dma_address) { 1536 if (*dma_addr == bad_dma_address)
1224 free_pages((unsigned long)virt_addr, get_order(size)); 1537 goto out_free;
1225 virt_addr = NULL;
1226 goto out;
1227 }
1228 1538
1229 iommu_completion_wait(iommu); 1539 iommu_completion_wait(iommu);
1230 1540
1231out:
1232 spin_unlock_irqrestore(&domain->lock, flags); 1541 spin_unlock_irqrestore(&domain->lock, flags);
1233 1542
1234 return virt_addr; 1543 return virt_addr;
1544
1545out_free:
1546
1547 free_pages((unsigned long)virt_addr, get_order(size));
1548
1549 return NULL;
1235} 1550}
1236 1551
1237/* 1552/*
@@ -1245,6 +1560,8 @@ static void free_coherent(struct device *dev, size_t size,
1245 struct protection_domain *domain; 1560 struct protection_domain *domain;
1246 u16 devid; 1561 u16 devid;
1247 1562
1563 INC_STATS_COUNTER(cnt_free_coherent);
1564
1248 if (!check_device(dev)) 1565 if (!check_device(dev))
1249 return; 1566 return;
1250 1567
@@ -1253,6 +1570,9 @@ static void free_coherent(struct device *dev, size_t size,
1253 if (!iommu || !domain) 1570 if (!iommu || !domain)
1254 goto free_mem; 1571 goto free_mem;
1255 1572
1573 if (!dma_ops_domain(domain))
1574 goto free_mem;
1575
1256 spin_lock_irqsave(&domain->lock, flags); 1576 spin_lock_irqsave(&domain->lock, flags);
1257 1577
1258 __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL); 1578 __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL);
@@ -1305,7 +1625,7 @@ static void prealloc_protection_domains(void)
1305 u16 devid; 1625 u16 devid;
1306 1626
1307 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 1627 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
1308 devid = (dev->bus->number << 8) | dev->devfn; 1628 devid = calc_devid(dev->bus->number, dev->devfn);
1309 if (devid > amd_iommu_last_bdf) 1629 if (devid > amd_iommu_last_bdf)
1310 continue; 1630 continue;
1311 devid = amd_iommu_alias_table[devid]; 1631 devid = amd_iommu_alias_table[devid];
@@ -1352,6 +1672,7 @@ int __init amd_iommu_init_dma_ops(void)
1352 iommu->default_dom = dma_ops_domain_alloc(iommu, order); 1672 iommu->default_dom = dma_ops_domain_alloc(iommu, order);
1353 if (iommu->default_dom == NULL) 1673 if (iommu->default_dom == NULL)
1354 return -ENOMEM; 1674 return -ENOMEM;
1675 iommu->default_dom->domain.flags |= PD_DEFAULT_MASK;
1355 ret = iommu_init_unity_mappings(iommu); 1676 ret = iommu_init_unity_mappings(iommu);
1356 if (ret) 1677 if (ret)
1357 goto free_domains; 1678 goto free_domains;
@@ -1375,6 +1696,12 @@ int __init amd_iommu_init_dma_ops(void)
1375 /* Make the driver finally visible to the drivers */ 1696 /* Make the driver finally visible to the drivers */
1376 dma_ops = &amd_iommu_dma_ops; 1697 dma_ops = &amd_iommu_dma_ops;
1377 1698
1699 register_iommu(&amd_iommu_ops);
1700
1701 bus_register_notifier(&pci_bus_type, &device_nb);
1702
1703 amd_iommu_stats_init();
1704
1378 return 0; 1705 return 0;
1379 1706
1380free_domains: 1707free_domains:
@@ -1386,3 +1713,224 @@ free_domains:
1386 1713
1387 return ret; 1714 return ret;
1388} 1715}
1716
1717/*****************************************************************************
1718 *
1719 * The following functions belong to the exported interface of AMD IOMMU
1720 *
1721 * This interface allows access to lower level functions of the IOMMU
1722 * like protection domain handling and assignement of devices to domains
1723 * which is not possible with the dma_ops interface.
1724 *
1725 *****************************************************************************/
1726
1727static void cleanup_domain(struct protection_domain *domain)
1728{
1729 unsigned long flags;
1730 u16 devid;
1731
1732 write_lock_irqsave(&amd_iommu_devtable_lock, flags);
1733
1734 for (devid = 0; devid <= amd_iommu_last_bdf; ++devid)
1735 if (amd_iommu_pd_table[devid] == domain)
1736 __detach_device(domain, devid);
1737
1738 write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
1739}
1740
1741static int amd_iommu_domain_init(struct iommu_domain *dom)
1742{
1743 struct protection_domain *domain;
1744
1745 domain = kzalloc(sizeof(*domain), GFP_KERNEL);
1746 if (!domain)
1747 return -ENOMEM;
1748
1749 spin_lock_init(&domain->lock);
1750 domain->mode = PAGE_MODE_3_LEVEL;
1751 domain->id = domain_id_alloc();
1752 if (!domain->id)
1753 goto out_free;
1754 domain->pt_root = (void *)get_zeroed_page(GFP_KERNEL);
1755 if (!domain->pt_root)
1756 goto out_free;
1757
1758 dom->priv = domain;
1759
1760 return 0;
1761
1762out_free:
1763 kfree(domain);
1764
1765 return -ENOMEM;
1766}
1767
1768static void amd_iommu_domain_destroy(struct iommu_domain *dom)
1769{
1770 struct protection_domain *domain = dom->priv;
1771
1772 if (!domain)
1773 return;
1774
1775 if (domain->dev_cnt > 0)
1776 cleanup_domain(domain);
1777
1778 BUG_ON(domain->dev_cnt != 0);
1779
1780 free_pagetable(domain);
1781
1782 domain_id_free(domain->id);
1783
1784 kfree(domain);
1785
1786 dom->priv = NULL;
1787}
1788
1789static void amd_iommu_detach_device(struct iommu_domain *dom,
1790 struct device *dev)
1791{
1792 struct protection_domain *domain = dom->priv;
1793 struct amd_iommu *iommu;
1794 struct pci_dev *pdev;
1795 u16 devid;
1796
1797 if (dev->bus != &pci_bus_type)
1798 return;
1799
1800 pdev = to_pci_dev(dev);
1801
1802 devid = calc_devid(pdev->bus->number, pdev->devfn);
1803
1804 if (devid > 0)
1805 detach_device(domain, devid);
1806
1807 iommu = amd_iommu_rlookup_table[devid];
1808 if (!iommu)
1809 return;
1810
1811 iommu_queue_inv_dev_entry(iommu, devid);
1812 iommu_completion_wait(iommu);
1813}
1814
1815static int amd_iommu_attach_device(struct iommu_domain *dom,
1816 struct device *dev)
1817{
1818 struct protection_domain *domain = dom->priv;
1819 struct protection_domain *old_domain;
1820 struct amd_iommu *iommu;
1821 struct pci_dev *pdev;
1822 u16 devid;
1823
1824 if (dev->bus != &pci_bus_type)
1825 return -EINVAL;
1826
1827 pdev = to_pci_dev(dev);
1828
1829 devid = calc_devid(pdev->bus->number, pdev->devfn);
1830
1831 if (devid >= amd_iommu_last_bdf ||
1832 devid != amd_iommu_alias_table[devid])
1833 return -EINVAL;
1834
1835 iommu = amd_iommu_rlookup_table[devid];
1836 if (!iommu)
1837 return -EINVAL;
1838
1839 old_domain = domain_for_device(devid);
1840 if (old_domain)
1841 return -EBUSY;
1842
1843 attach_device(iommu, domain, devid);
1844
1845 iommu_completion_wait(iommu);
1846
1847 return 0;
1848}
1849
1850static int amd_iommu_map_range(struct iommu_domain *dom,
1851 unsigned long iova, phys_addr_t paddr,
1852 size_t size, int iommu_prot)
1853{
1854 struct protection_domain *domain = dom->priv;
1855 unsigned long i, npages = iommu_num_pages(paddr, size, PAGE_SIZE);
1856 int prot = 0;
1857 int ret;
1858
1859 if (iommu_prot & IOMMU_READ)
1860 prot |= IOMMU_PROT_IR;
1861 if (iommu_prot & IOMMU_WRITE)
1862 prot |= IOMMU_PROT_IW;
1863
1864 iova &= PAGE_MASK;
1865 paddr &= PAGE_MASK;
1866
1867 for (i = 0; i < npages; ++i) {
1868 ret = iommu_map_page(domain, iova, paddr, prot);
1869 if (ret)
1870 return ret;
1871
1872 iova += PAGE_SIZE;
1873 paddr += PAGE_SIZE;
1874 }
1875
1876 return 0;
1877}
1878
1879static void amd_iommu_unmap_range(struct iommu_domain *dom,
1880 unsigned long iova, size_t size)
1881{
1882
1883 struct protection_domain *domain = dom->priv;
1884 unsigned long i, npages = iommu_num_pages(iova, size, PAGE_SIZE);
1885
1886 iova &= PAGE_MASK;
1887
1888 for (i = 0; i < npages; ++i) {
1889 iommu_unmap_page(domain, iova);
1890 iova += PAGE_SIZE;
1891 }
1892
1893 iommu_flush_domain(domain->id);
1894}
1895
1896static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom,
1897 unsigned long iova)
1898{
1899 struct protection_domain *domain = dom->priv;
1900 unsigned long offset = iova & ~PAGE_MASK;
1901 phys_addr_t paddr;
1902 u64 *pte;
1903
1904 pte = &domain->pt_root[IOMMU_PTE_L2_INDEX(iova)];
1905
1906 if (!IOMMU_PTE_PRESENT(*pte))
1907 return 0;
1908
1909 pte = IOMMU_PTE_PAGE(*pte);
1910 pte = &pte[IOMMU_PTE_L1_INDEX(iova)];
1911
1912 if (!IOMMU_PTE_PRESENT(*pte))
1913 return 0;
1914
1915 pte = IOMMU_PTE_PAGE(*pte);
1916 pte = &pte[IOMMU_PTE_L0_INDEX(iova)];
1917
1918 if (!IOMMU_PTE_PRESENT(*pte))
1919 return 0;
1920
1921 paddr = *pte & IOMMU_PAGE_MASK;
1922 paddr |= offset;
1923
1924 return paddr;
1925}
1926
1927static struct iommu_ops amd_iommu_ops = {
1928 .domain_init = amd_iommu_domain_init,
1929 .domain_destroy = amd_iommu_domain_destroy,
1930 .attach_dev = amd_iommu_attach_device,
1931 .detach_dev = amd_iommu_detach_device,
1932 .map = amd_iommu_map_range,
1933 .unmap = amd_iommu_unmap_range,
1934 .iova_to_phys = amd_iommu_iova_to_phys,
1935};
1936
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index fb85e8d466cc..42c33cebf00f 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -122,7 +122,8 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
122LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings 122LIST_HEAD(amd_iommu_unity_map); /* a list of required unity mappings
123 we find in ACPI */ 123 we find in ACPI */
124unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */ 124unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
125int amd_iommu_isolate = 1; /* if 1, device isolation is enabled */ 125bool amd_iommu_isolate = true; /* if true, device isolation is
126 enabled */
126bool amd_iommu_unmap_flush; /* if true, flush on every unmap */ 127bool amd_iommu_unmap_flush; /* if true, flush on every unmap */
127 128
128LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the 129LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
@@ -245,12 +246,8 @@ static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit)
245/* Function to enable the hardware */ 246/* Function to enable the hardware */
246static void __init iommu_enable(struct amd_iommu *iommu) 247static void __init iommu_enable(struct amd_iommu *iommu)
247{ 248{
248 printk(KERN_INFO "AMD IOMMU: Enabling IOMMU " 249 printk(KERN_INFO "AMD IOMMU: Enabling IOMMU at %s cap 0x%hx\n",
249 "at %02x:%02x.%x cap 0x%hx\n", 250 dev_name(&iommu->dev->dev), iommu->cap_ptr);
250 iommu->dev->bus->number,
251 PCI_SLOT(iommu->dev->devfn),
252 PCI_FUNC(iommu->dev->devfn),
253 iommu->cap_ptr);
254 251
255 iommu_feature_enable(iommu, CONTROL_IOMMU_EN); 252 iommu_feature_enable(iommu, CONTROL_IOMMU_EN);
256} 253}
@@ -1218,9 +1215,9 @@ static int __init parse_amd_iommu_options(char *str)
1218{ 1215{
1219 for (; *str; ++str) { 1216 for (; *str; ++str) {
1220 if (strncmp(str, "isolate", 7) == 0) 1217 if (strncmp(str, "isolate", 7) == 0)
1221 amd_iommu_isolate = 1; 1218 amd_iommu_isolate = true;
1222 if (strncmp(str, "share", 5) == 0) 1219 if (strncmp(str, "share", 5) == 0)
1223 amd_iommu_isolate = 0; 1220 amd_iommu_isolate = false;
1224 if (strncmp(str, "fullflush", 9) == 0) 1221 if (strncmp(str, "fullflush", 9) == 0)
1225 amd_iommu_unmap_flush = true; 1222 amd_iommu_unmap_flush = true;
1226 } 1223 }
diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c
index d652515e2855..566a08466b19 100644
--- a/arch/x86/kernel/apic.c
+++ b/arch/x86/kernel/apic.c
@@ -31,9 +31,11 @@
31#include <linux/dmi.h> 31#include <linux/dmi.h>
32#include <linux/dmar.h> 32#include <linux/dmar.h>
33#include <linux/ftrace.h> 33#include <linux/ftrace.h>
34#include <linux/smp.h>
35#include <linux/nmi.h>
36#include <linux/timex.h>
34 37
35#include <asm/atomic.h> 38#include <asm/atomic.h>
36#include <asm/smp.h>
37#include <asm/mtrr.h> 39#include <asm/mtrr.h>
38#include <asm/mpspec.h> 40#include <asm/mpspec.h>
39#include <asm/desc.h> 41#include <asm/desc.h>
@@ -41,10 +43,8 @@
41#include <asm/hpet.h> 43#include <asm/hpet.h>
42#include <asm/pgalloc.h> 44#include <asm/pgalloc.h>
43#include <asm/i8253.h> 45#include <asm/i8253.h>
44#include <asm/nmi.h>
45#include <asm/idle.h> 46#include <asm/idle.h>
46#include <asm/proto.h> 47#include <asm/proto.h>
47#include <asm/timex.h>
48#include <asm/apic.h> 48#include <asm/apic.h>
49#include <asm/i8259.h> 49#include <asm/i8259.h>
50 50
@@ -140,7 +140,7 @@ static int lapic_next_event(unsigned long delta,
140 struct clock_event_device *evt); 140 struct clock_event_device *evt);
141static void lapic_timer_setup(enum clock_event_mode mode, 141static void lapic_timer_setup(enum clock_event_mode mode,
142 struct clock_event_device *evt); 142 struct clock_event_device *evt);
143static void lapic_timer_broadcast(const cpumask_t *mask); 143static void lapic_timer_broadcast(const struct cpumask *mask);
144static void apic_pm_activate(void); 144static void apic_pm_activate(void);
145 145
146/* 146/*
@@ -453,7 +453,7 @@ static void lapic_timer_setup(enum clock_event_mode mode,
453/* 453/*
454 * Local APIC timer broadcast function 454 * Local APIC timer broadcast function
455 */ 455 */
456static void lapic_timer_broadcast(const cpumask_t *mask) 456static void lapic_timer_broadcast(const struct cpumask *mask)
457{ 457{
458#ifdef CONFIG_SMP 458#ifdef CONFIG_SMP
459 send_IPI_mask(mask, LOCAL_TIMER_VECTOR); 459 send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
@@ -687,7 +687,7 @@ static int __init calibrate_APIC_clock(void)
687 local_irq_enable(); 687 local_irq_enable();
688 688
689 if (levt->features & CLOCK_EVT_FEAT_DUMMY) { 689 if (levt->features & CLOCK_EVT_FEAT_DUMMY) {
690 pr_warning("APIC timer disabled due to verification failure.\n"); 690 pr_warning("APIC timer disabled due to verification failure\n");
691 return -1; 691 return -1;
692 } 692 }
693 693
@@ -2087,14 +2087,12 @@ __cpuinit int apic_is_clustered_box(void)
2087 /* are we being called early in kernel startup? */ 2087 /* are we being called early in kernel startup? */
2088 if (bios_cpu_apicid) { 2088 if (bios_cpu_apicid) {
2089 id = bios_cpu_apicid[i]; 2089 id = bios_cpu_apicid[i];
2090 } 2090 } else if (i < nr_cpu_ids) {
2091 else if (i < nr_cpu_ids) {
2092 if (cpu_present(i)) 2091 if (cpu_present(i))
2093 id = per_cpu(x86_bios_cpu_apicid, i); 2092 id = per_cpu(x86_bios_cpu_apicid, i);
2094 else 2093 else
2095 continue; 2094 continue;
2096 } 2095 } else
2097 else
2098 break; 2096 break;
2099 2097
2100 if (id != BAD_APICID) 2098 if (id != BAD_APICID)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 42e0853030cb..3f95a40f718a 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -355,7 +355,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
355 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n"); 355 printk(KERN_INFO "CPU: Hyper-Threading is disabled\n");
356 } else if (smp_num_siblings > 1) { 356 } else if (smp_num_siblings > 1) {
357 357
358 if (smp_num_siblings > NR_CPUS) { 358 if (smp_num_siblings > nr_cpu_ids) {
359 printk(KERN_WARNING "CPU: Unsupported number of siblings %d", 359 printk(KERN_WARNING "CPU: Unsupported number of siblings %d",
360 smp_num_siblings); 360 smp_num_siblings);
361 smp_num_siblings = 1; 361 smp_num_siblings = 1;
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index 88ea02dcb622..28102ad1a363 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -517,6 +517,17 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
517 } 517 }
518} 518}
519 519
520static void free_acpi_perf_data(void)
521{
522 unsigned int i;
523
524 /* Freeing a NULL pointer is OK, and alloc_percpu zeroes. */
525 for_each_possible_cpu(i)
526 free_cpumask_var(per_cpu_ptr(acpi_perf_data, i)
527 ->shared_cpu_map);
528 free_percpu(acpi_perf_data);
529}
530
520/* 531/*
521 * acpi_cpufreq_early_init - initialize ACPI P-States library 532 * acpi_cpufreq_early_init - initialize ACPI P-States library
522 * 533 *
@@ -527,6 +538,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
527 */ 538 */
528static int __init acpi_cpufreq_early_init(void) 539static int __init acpi_cpufreq_early_init(void)
529{ 540{
541 unsigned int i;
530 dprintk("acpi_cpufreq_early_init\n"); 542 dprintk("acpi_cpufreq_early_init\n");
531 543
532 acpi_perf_data = alloc_percpu(struct acpi_processor_performance); 544 acpi_perf_data = alloc_percpu(struct acpi_processor_performance);
@@ -534,6 +546,16 @@ static int __init acpi_cpufreq_early_init(void)
534 dprintk("Memory allocation error for acpi_perf_data.\n"); 546 dprintk("Memory allocation error for acpi_perf_data.\n");
535 return -ENOMEM; 547 return -ENOMEM;
536 } 548 }
549 for_each_possible_cpu(i) {
550 if (!alloc_cpumask_var_node(
551 &per_cpu_ptr(acpi_perf_data, i)->shared_cpu_map,
552 GFP_KERNEL, cpu_to_node(i))) {
553
554 /* Freeing a NULL pointer is OK: alloc_percpu zeroes. */
555 free_acpi_perf_data();
556 return -ENOMEM;
557 }
558 }
537 559
538 /* Do initialization in ACPI core */ 560 /* Do initialization in ACPI core */
539 acpi_processor_preregister_performance(acpi_perf_data); 561 acpi_processor_preregister_performance(acpi_perf_data);
@@ -604,9 +626,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
604 */ 626 */
605 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || 627 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
606 policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { 628 policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
607 policy->cpus = perf->shared_cpu_map; 629 cpumask_copy(&policy->cpus, perf->shared_cpu_map);
608 } 630 }
609 policy->related_cpus = perf->shared_cpu_map; 631 cpumask_copy(&policy->related_cpus, perf->shared_cpu_map);
610 632
611#ifdef CONFIG_SMP 633#ifdef CONFIG_SMP
612 dmi_check_system(sw_any_bug_dmi_table); 634 dmi_check_system(sw_any_bug_dmi_table);
@@ -795,7 +817,7 @@ static int __init acpi_cpufreq_init(void)
795 817
796 ret = cpufreq_register_driver(&acpi_cpufreq_driver); 818 ret = cpufreq_register_driver(&acpi_cpufreq_driver);
797 if (ret) 819 if (ret)
798 free_percpu(acpi_perf_data); 820 free_acpi_perf_data();
799 821
800 return ret; 822 return ret;
801} 823}
diff --git a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
index b8e05ee4f736..beea4466b063 100644
--- a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
+++ b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
@@ -160,6 +160,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
160 switch (c->x86_model) { 160 switch (c->x86_model) {
161 case 0x0E: /* Core */ 161 case 0x0E: /* Core */
162 case 0x0F: /* Core Duo */ 162 case 0x0F: /* Core Duo */
163 case 0x16: /* Celeron Core */
163 p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS; 164 p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
164 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PCORE); 165 return speedstep_get_processor_frequency(SPEEDSTEP_PROCESSOR_PCORE);
165 case 0x0D: /* Pentium M (Dothan) */ 166 case 0x0D: /* Pentium M (Dothan) */
@@ -171,7 +172,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
171 } 172 }
172 173
173 if (c->x86 != 0xF) { 174 if (c->x86 != 0xF) {
174 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. Please send an e-mail to <cpufreq@vger.kernel.org>\n"); 175 if (!cpu_has(c, X86_FEATURE_EST))
176 printk(KERN_WARNING PFX "Unknown p4-clockmod-capable CPU. "
177 "Please send an e-mail to <cpufreq@vger.kernel.org>\n");
175 return 0; 178 return 0;
176 } 179 }
177 180
@@ -274,6 +277,7 @@ static struct cpufreq_driver p4clockmod_driver = {
274 .name = "p4-clockmod", 277 .name = "p4-clockmod",
275 .owner = THIS_MODULE, 278 .owner = THIS_MODULE,
276 .attr = p4clockmod_attr, 279 .attr = p4clockmod_attr,
280 .hide_interface = 1,
277}; 281};
278 282
279 283
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k7.c b/arch/x86/kernel/cpu/cpufreq/powernow-k7.c
index 7c7d56b43136..1b446d79a8fd 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k7.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k7.c
@@ -310,6 +310,12 @@ static int powernow_acpi_init(void)
310 goto err0; 310 goto err0;
311 } 311 }
312 312
313 if (!alloc_cpumask_var(&acpi_processor_perf->shared_cpu_map,
314 GFP_KERNEL)) {
315 retval = -ENOMEM;
316 goto err05;
317 }
318
313 if (acpi_processor_register_performance(acpi_processor_perf, 0)) { 319 if (acpi_processor_register_performance(acpi_processor_perf, 0)) {
314 retval = -EIO; 320 retval = -EIO;
315 goto err1; 321 goto err1;
@@ -412,6 +418,8 @@ static int powernow_acpi_init(void)
412err2: 418err2:
413 acpi_processor_unregister_performance(acpi_processor_perf, 0); 419 acpi_processor_unregister_performance(acpi_processor_perf, 0);
414err1: 420err1:
421 free_cpumask_var(acpi_processor_perf->shared_cpu_map);
422err05:
415 kfree(acpi_processor_perf); 423 kfree(acpi_processor_perf);
416err0: 424err0:
417 printk(KERN_WARNING PFX "ACPI perflib can not be used in this platform\n"); 425 printk(KERN_WARNING PFX "ACPI perflib can not be used in this platform\n");
@@ -652,6 +660,7 @@ static int powernow_cpu_exit (struct cpufreq_policy *policy) {
652#ifdef CONFIG_X86_POWERNOW_K7_ACPI 660#ifdef CONFIG_X86_POWERNOW_K7_ACPI
653 if (acpi_processor_perf) { 661 if (acpi_processor_perf) {
654 acpi_processor_unregister_performance(acpi_processor_perf, 0); 662 acpi_processor_unregister_performance(acpi_processor_perf, 0);
663 free_cpumask_var(acpi_processor_perf->shared_cpu_map);
655 kfree(acpi_processor_perf); 664 kfree(acpi_processor_perf);
656 } 665 }
657#endif 666#endif
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 7f05f44b97e9..c3c9adbaa26f 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -766,7 +766,7 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned
766static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) 766static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
767{ 767{
768 struct cpufreq_frequency_table *powernow_table; 768 struct cpufreq_frequency_table *powernow_table;
769 int ret_val; 769 int ret_val = -ENODEV;
770 770
771 if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { 771 if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) {
772 dprintk("register performance failed: bad ACPI data\n"); 772 dprintk("register performance failed: bad ACPI data\n");
@@ -815,6 +815,13 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
815 /* notify BIOS that we exist */ 815 /* notify BIOS that we exist */
816 acpi_processor_notify_smm(THIS_MODULE); 816 acpi_processor_notify_smm(THIS_MODULE);
817 817
818 if (!alloc_cpumask_var(&data->acpi_data.shared_cpu_map, GFP_KERNEL)) {
819 printk(KERN_ERR PFX
820 "unable to alloc powernow_k8_data cpumask\n");
821 ret_val = -ENOMEM;
822 goto err_out_mem;
823 }
824
818 return 0; 825 return 0;
819 826
820err_out_mem: 827err_out_mem:
@@ -826,7 +833,7 @@ err_out:
826 /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */ 833 /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */
827 data->acpi_data.state_count = 0; 834 data->acpi_data.state_count = 0;
828 835
829 return -ENODEV; 836 return ret_val;
830} 837}
831 838
832static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table) 839static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table)
@@ -929,6 +936,7 @@ static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data)
929{ 936{
930 if (data->acpi_data.state_count) 937 if (data->acpi_data.state_count)
931 acpi_processor_unregister_performance(&data->acpi_data, data->cpu); 938 acpi_processor_unregister_performance(&data->acpi_data, data->cpu);
939 free_cpumask_var(data->acpi_data.shared_cpu_map);
932} 940}
933 941
934#else 942#else
@@ -1134,7 +1142,8 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1134 data->cpu = pol->cpu; 1142 data->cpu = pol->cpu;
1135 data->currpstate = HW_PSTATE_INVALID; 1143 data->currpstate = HW_PSTATE_INVALID;
1136 1144
1137 if (powernow_k8_cpu_init_acpi(data)) { 1145 rc = powernow_k8_cpu_init_acpi(data);
1146 if (rc) {
1138 /* 1147 /*
1139 * Use the PSB BIOS structure. This is only availabe on 1148 * Use the PSB BIOS structure. This is only availabe on
1140 * an UP version, and is deprecated by AMD. 1149 * an UP version, and is deprecated by AMD.
@@ -1152,20 +1161,17 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1152 "ACPI maintainers and complain to your BIOS " 1161 "ACPI maintainers and complain to your BIOS "
1153 "vendor.\n"); 1162 "vendor.\n");
1154#endif 1163#endif
1155 kfree(data); 1164 goto err_out;
1156 return -ENODEV;
1157 } 1165 }
1158 if (pol->cpu != 0) { 1166 if (pol->cpu != 0) {
1159 printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for " 1167 printk(KERN_ERR FW_BUG PFX "No ACPI _PSS objects for "
1160 "CPU other than CPU0. Complain to your BIOS " 1168 "CPU other than CPU0. Complain to your BIOS "
1161 "vendor.\n"); 1169 "vendor.\n");
1162 kfree(data); 1170 goto err_out;
1163 return -ENODEV;
1164 } 1171 }
1165 rc = find_psb_table(data); 1172 rc = find_psb_table(data);
1166 if (rc) { 1173 if (rc) {
1167 kfree(data); 1174 goto err_out;
1168 return -ENODEV;
1169 } 1175 }
1170 } 1176 }
1171 1177
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
index 3b5f06423e77..f0ea6fa2f53c 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -459,9 +459,7 @@ static int centrino_verify (struct cpufreq_policy *policy)
459 * Sets a new CPUFreq policy. 459 * Sets a new CPUFreq policy.
460 */ 460 */
461struct allmasks { 461struct allmasks {
462 cpumask_t online_policy_cpus;
463 cpumask_t saved_mask; 462 cpumask_t saved_mask;
464 cpumask_t set_mask;
465 cpumask_t covered_cpus; 463 cpumask_t covered_cpus;
466}; 464};
467 465
@@ -475,9 +473,7 @@ static int centrino_target (struct cpufreq_policy *policy,
475 int retval = 0; 473 int retval = 0;
476 unsigned int j, k, first_cpu, tmp; 474 unsigned int j, k, first_cpu, tmp;
477 CPUMASK_ALLOC(allmasks); 475 CPUMASK_ALLOC(allmasks);
478 CPUMASK_PTR(online_policy_cpus, allmasks);
479 CPUMASK_PTR(saved_mask, allmasks); 476 CPUMASK_PTR(saved_mask, allmasks);
480 CPUMASK_PTR(set_mask, allmasks);
481 CPUMASK_PTR(covered_cpus, allmasks); 477 CPUMASK_PTR(covered_cpus, allmasks);
482 478
483 if (unlikely(allmasks == NULL)) 479 if (unlikely(allmasks == NULL))
@@ -497,30 +493,28 @@ static int centrino_target (struct cpufreq_policy *policy,
497 goto out; 493 goto out;
498 } 494 }
499 495
500#ifdef CONFIG_HOTPLUG_CPU
501 /* cpufreq holds the hotplug lock, so we are safe from here on */
502 cpus_and(*online_policy_cpus, cpu_online_map, policy->cpus);
503#else
504 *online_policy_cpus = policy->cpus;
505#endif
506
507 *saved_mask = current->cpus_allowed; 496 *saved_mask = current->cpus_allowed;
508 first_cpu = 1; 497 first_cpu = 1;
509 cpus_clear(*covered_cpus); 498 cpus_clear(*covered_cpus);
510 for_each_cpu_mask_nr(j, *online_policy_cpus) { 499 for_each_cpu_mask_nr(j, policy->cpus) {
500 const cpumask_t *mask;
501
502 /* cpufreq holds the hotplug lock, so we are safe here */
503 if (!cpu_online(j))
504 continue;
505
511 /* 506 /*
512 * Support for SMP systems. 507 * Support for SMP systems.
513 * Make sure we are running on CPU that wants to change freq 508 * Make sure we are running on CPU that wants to change freq
514 */ 509 */
515 cpus_clear(*set_mask);
516 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) 510 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
517 cpus_or(*set_mask, *set_mask, *online_policy_cpus); 511 mask = &policy->cpus;
518 else 512 else
519 cpu_set(j, *set_mask); 513 mask = &cpumask_of_cpu(j);
520 514
521 set_cpus_allowed_ptr(current, set_mask); 515 set_cpus_allowed_ptr(current, mask);
522 preempt_disable(); 516 preempt_disable();
523 if (unlikely(!cpu_isset(smp_processor_id(), *set_mask))) { 517 if (unlikely(!cpu_isset(smp_processor_id(), *mask))) {
524 dprintk("couldn't limit to CPUs in this domain\n"); 518 dprintk("couldn't limit to CPUs in this domain\n");
525 retval = -EAGAIN; 519 retval = -EAGAIN;
526 if (first_cpu) { 520 if (first_cpu) {
@@ -548,7 +542,9 @@ static int centrino_target (struct cpufreq_policy *policy,
548 dprintk("target=%dkHz old=%d new=%d msr=%04x\n", 542 dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
549 target_freq, freqs.old, freqs.new, msr); 543 target_freq, freqs.old, freqs.new, msr);
550 544
551 for_each_cpu_mask_nr(k, *online_policy_cpus) { 545 for_each_cpu_mask_nr(k, policy->cpus) {
546 if (!cpu_online(k))
547 continue;
552 freqs.cpu = k; 548 freqs.cpu = k;
553 cpufreq_notify_transition(&freqs, 549 cpufreq_notify_transition(&freqs,
554 CPUFREQ_PRECHANGE); 550 CPUFREQ_PRECHANGE);
@@ -571,7 +567,9 @@ static int centrino_target (struct cpufreq_policy *policy,
571 preempt_enable(); 567 preempt_enable();
572 } 568 }
573 569
574 for_each_cpu_mask_nr(k, *online_policy_cpus) { 570 for_each_cpu_mask_nr(k, policy->cpus) {
571 if (!cpu_online(k))
572 continue;
575 freqs.cpu = k; 573 freqs.cpu = k;
576 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 574 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
577 } 575 }
@@ -584,18 +582,17 @@ static int centrino_target (struct cpufreq_policy *policy,
584 * Best effort undo.. 582 * Best effort undo..
585 */ 583 */
586 584
587 if (!cpus_empty(*covered_cpus)) 585 for_each_cpu_mask_nr(j, *covered_cpus) {
588 for_each_cpu_mask_nr(j, *covered_cpus) { 586 set_cpus_allowed_ptr(current, &cpumask_of_cpu(j));
589 set_cpus_allowed_ptr(current, 587 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
590 &cpumask_of_cpu(j)); 588 }
591 wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
592 }
593 589
594 tmp = freqs.new; 590 tmp = freqs.new;
595 freqs.new = freqs.old; 591 freqs.new = freqs.old;
596 freqs.old = tmp; 592 freqs.old = tmp;
597 for_each_cpu_mask_nr(j, *online_policy_cpus) { 593 for_each_cpu_mask_nr(j, policy->cpus) {
598 freqs.cpu = j; 594 if (!cpu_online(j))
595 continue;
599 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 596 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
600 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 597 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
601 } 598 }
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-lib.c b/arch/x86/kernel/cpu/cpufreq/speedstep-lib.c
index 98d4fdb7dc04..cdac7d62369b 100644
--- a/arch/x86/kernel/cpu/cpufreq/speedstep-lib.c
+++ b/arch/x86/kernel/cpu/cpufreq/speedstep-lib.c
@@ -139,6 +139,15 @@ static unsigned int pentium_core_get_frequency(void)
139 case 3: 139 case 3:
140 fsb = 166667; 140 fsb = 166667;
141 break; 141 break;
142 case 2:
143 fsb = 200000;
144 break;
145 case 0:
146 fsb = 266667;
147 break;
148 case 4:
149 fsb = 333333;
150 break;
142 default: 151 default:
143 printk(KERN_ERR "PCORE - MSR_FSB_FREQ undefined value"); 152 printk(KERN_ERR "PCORE - MSR_FSB_FREQ undefined value");
144 } 153 }
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index c6ecda64f5f1..48533d77be78 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -534,7 +534,7 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)
534 per_cpu(cpuid4_info, cpu) = NULL; 534 per_cpu(cpuid4_info, cpu) = NULL;
535} 535}
536 536
537static void get_cpu_leaves(void *_retval) 537static void __cpuinit get_cpu_leaves(void *_retval)
538{ 538{
539 int j, *retval = _retval, cpu = smp_processor_id(); 539 int j, *retval = _retval, cpu = smp_processor_id();
540 540
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 85d28d53f5d3..2ac1f0c2beb3 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -121,7 +121,7 @@ static int cpuid_open(struct inode *inode, struct file *file)
121 lock_kernel(); 121 lock_kernel();
122 122
123 cpu = iminor(file->f_path.dentry->d_inode); 123 cpu = iminor(file->f_path.dentry->d_inode);
124 if (cpu >= NR_CPUS || !cpu_online(cpu)) { 124 if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
125 ret = -ENXIO; /* No such CPU */ 125 ret = -ENXIO; /* No such CPU */
126 goto out; 126 goto out;
127 } 127 }
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
index 4b8a53d841f7..11d5093eb281 100644
--- a/arch/x86/kernel/i8259.c
+++ b/arch/x86/kernel/i8259.c
@@ -11,15 +11,15 @@
11#include <linux/kernel_stat.h> 11#include <linux/kernel_stat.h>
12#include <linux/sysdev.h> 12#include <linux/sysdev.h>
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/acpi.h>
15#include <linux/io.h>
16#include <linux/delay.h>
14 17
15#include <asm/acpi.h>
16#include <asm/atomic.h> 18#include <asm/atomic.h>
17#include <asm/system.h> 19#include <asm/system.h>
18#include <asm/io.h>
19#include <asm/timer.h> 20#include <asm/timer.h>
20#include <asm/hw_irq.h> 21#include <asm/hw_irq.h>
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
22#include <asm/delay.h>
23#include <asm/desc.h> 23#include <asm/desc.h>
24#include <asm/apic.h> 24#include <asm/apic.h>
25#include <asm/arch_hooks.h> 25#include <asm/arch_hooks.h>
@@ -323,7 +323,7 @@ void init_8259A(int auto_eoi)
323 outb_pic(0x11, PIC_MASTER_CMD); /* ICW1: select 8259A-1 init */ 323 outb_pic(0x11, PIC_MASTER_CMD); /* ICW1: select 8259A-1 init */
324 324
325 /* ICW2: 8259A-1 IR0-7 mapped to 0x30-0x37 on x86-64, 325 /* ICW2: 8259A-1 IR0-7 mapped to 0x30-0x37 on x86-64,
326 to 0x20-0x27 on i386 */ 326 to 0x20-0x27 on i386 */
327 outb_pic(IRQ0_VECTOR, PIC_MASTER_IMR); 327 outb_pic(IRQ0_VECTOR, PIC_MASTER_IMR);
328 328
329 /* 8259A-1 (the master) has a slave on IR2 */ 329 /* 8259A-1 (the master) has a slave on IR2 */
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 45073520407f..1c4a1302536c 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -213,11 +213,11 @@ static struct irq_cfg *get_one_free_irq_cfg(int cpu)
213 213
214 cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node); 214 cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node);
215 if (cfg) { 215 if (cfg) {
216 /* FIXME: needs alloc_cpumask_var_node() */ 216 if (!alloc_cpumask_var_node(&cfg->domain, GFP_ATOMIC, node)) {
217 if (!alloc_cpumask_var(&cfg->domain, GFP_ATOMIC)) {
218 kfree(cfg); 217 kfree(cfg);
219 cfg = NULL; 218 cfg = NULL;
220 } else if (!alloc_cpumask_var(&cfg->old_domain, GFP_ATOMIC)) { 219 } else if (!alloc_cpumask_var_node(&cfg->old_domain,
220 GFP_ATOMIC, node)) {
221 free_cpumask_var(cfg->domain); 221 free_cpumask_var(cfg->domain);
222 kfree(cfg); 222 kfree(cfg);
223 cfg = NULL; 223 cfg = NULL;
diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index 191914302744..b12208f4dfee 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -35,8 +35,8 @@ static void set_bitmap(unsigned long *bitmap, unsigned int base,
35 */ 35 */
36asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) 36asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
37{ 37{
38 struct thread_struct * t = &current->thread; 38 struct thread_struct *t = &current->thread;
39 struct tss_struct * tss; 39 struct tss_struct *tss;
40 unsigned int i, max_long, bytes, bytes_updated; 40 unsigned int i, max_long, bytes, bytes_updated;
41 41
42 if ((from + num <= from) || (from + num > IO_BITMAP_BITS)) 42 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index bce53e1352a0..3973e2df7f87 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -5,10 +5,10 @@
5#include <linux/interrupt.h> 5#include <linux/interrupt.h>
6#include <linux/kernel_stat.h> 6#include <linux/kernel_stat.h>
7#include <linux/seq_file.h> 7#include <linux/seq_file.h>
8#include <linux/smp.h>
8 9
9#include <asm/apic.h> 10#include <asm/apic.h>
10#include <asm/io_apic.h> 11#include <asm/io_apic.h>
11#include <asm/smp.h>
12#include <asm/irq.h> 12#include <asm/irq.h>
13 13
14atomic_t irq_err_count; 14atomic_t irq_err_count;
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 9dc5588f336a..74b9ff7341e9 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -15,9 +15,9 @@
15#include <linux/notifier.h> 15#include <linux/notifier.h>
16#include <linux/cpu.h> 16#include <linux/cpu.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/uaccess.h>
18 19
19#include <asm/apic.h> 20#include <asm/apic.h>
20#include <asm/uaccess.h>
21 21
22DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); 22DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
23EXPORT_PER_CPU_SYMBOL(irq_stat); 23EXPORT_PER_CPU_SYMBOL(irq_stat);
@@ -93,7 +93,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
93 return 0; 93 return 0;
94 94
95 /* build the stack frame on the IRQ stack */ 95 /* build the stack frame on the IRQ stack */
96 isp = (u32 *) ((char*)irqctx + sizeof(*irqctx)); 96 isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
97 irqctx->tinfo.task = curctx->tinfo.task; 97 irqctx->tinfo.task = curctx->tinfo.task;
98 irqctx->tinfo.previous_esp = current_stack_pointer; 98 irqctx->tinfo.previous_esp = current_stack_pointer;
99 99
@@ -137,7 +137,7 @@ void __cpuinit irq_ctx_init(int cpu)
137 137
138 hardirq_ctx[cpu] = irqctx; 138 hardirq_ctx[cpu] = irqctx;
139 139
140 irqctx = (union irq_ctx*) &softirq_stack[cpu*THREAD_SIZE]; 140 irqctx = (union irq_ctx *) &softirq_stack[cpu*THREAD_SIZE];
141 irqctx->tinfo.task = NULL; 141 irqctx->tinfo.task = NULL;
142 irqctx->tinfo.exec_domain = NULL; 142 irqctx->tinfo.exec_domain = NULL;
143 irqctx->tinfo.cpu = cpu; 143 irqctx->tinfo.cpu = cpu;
@@ -147,7 +147,7 @@ void __cpuinit irq_ctx_init(int cpu)
147 softirq_ctx[cpu] = irqctx; 147 softirq_ctx[cpu] = irqctx;
148 148
149 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n", 149 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
150 cpu,hardirq_ctx[cpu],softirq_ctx[cpu]); 150 cpu, hardirq_ctx[cpu], softirq_ctx[cpu]);
151} 151}
152 152
153void irq_ctx_exit(int cpu) 153void irq_ctx_exit(int cpu)
@@ -174,7 +174,7 @@ asmlinkage void do_softirq(void)
174 irqctx->tinfo.previous_esp = current_stack_pointer; 174 irqctx->tinfo.previous_esp = current_stack_pointer;
175 175
176 /* build the stack frame on the softirq stack */ 176 /* build the stack frame on the softirq stack */
177 isp = (u32*) ((char*)irqctx + sizeof(*irqctx)); 177 isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
178 178
179 call_on_stack(__do_softirq, isp); 179 call_on_stack(__do_softirq, isp);
180 /* 180 /*
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index 6383d50f82ea..63c88e6ec025 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -14,10 +14,10 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/ftrace.h> 16#include <linux/ftrace.h>
17#include <asm/uaccess.h> 17#include <linux/uaccess.h>
18#include <linux/smp.h>
18#include <asm/io_apic.h> 19#include <asm/io_apic.h>
19#include <asm/idle.h> 20#include <asm/idle.h>
20#include <asm/smp.h>
21 21
22/* 22/*
23 * Probabilistic stack overflow check: 23 * Probabilistic stack overflow check:
@@ -142,18 +142,18 @@ extern void call_softirq(void);
142 142
143asmlinkage void do_softirq(void) 143asmlinkage void do_softirq(void)
144{ 144{
145 __u32 pending; 145 __u32 pending;
146 unsigned long flags; 146 unsigned long flags;
147 147
148 if (in_interrupt()) 148 if (in_interrupt())
149 return; 149 return;
150 150
151 local_irq_save(flags); 151 local_irq_save(flags);
152 pending = local_softirq_pending(); 152 pending = local_softirq_pending();
153 /* Switch to interrupt stack */ 153 /* Switch to interrupt stack */
154 if (pending) { 154 if (pending) {
155 call_softirq(); 155 call_softirq();
156 WARN_ON_ONCE(softirq_count()); 156 WARN_ON_ONCE(softirq_count());
157 } 157 }
158 local_irq_restore(flags); 158 local_irq_restore(flags);
159} 159}
diff --git a/arch/x86/kernel/irqinit_32.c b/arch/x86/kernel/irqinit_32.c
index 84723295f88a..1507ad4e674d 100644
--- a/arch/x86/kernel/irqinit_32.c
+++ b/arch/x86/kernel/irqinit_32.c
@@ -9,18 +9,18 @@
9#include <linux/kernel_stat.h> 9#include <linux/kernel_stat.h>
10#include <linux/sysdev.h> 10#include <linux/sysdev.h>
11#include <linux/bitops.h> 11#include <linux/bitops.h>
12#include <linux/io.h>
13#include <linux/delay.h>
12 14
13#include <asm/atomic.h> 15#include <asm/atomic.h>
14#include <asm/system.h> 16#include <asm/system.h>
15#include <asm/io.h>
16#include <asm/timer.h> 17#include <asm/timer.h>
17#include <asm/pgtable.h> 18#include <asm/pgtable.h>
18#include <asm/delay.h>
19#include <asm/desc.h> 19#include <asm/desc.h>
20#include <asm/apic.h> 20#include <asm/apic.h>
21#include <asm/arch_hooks.h> 21#include <asm/arch_hooks.h>
22#include <asm/i8259.h> 22#include <asm/i8259.h>
23 23#include <asm/traps.h>
24 24
25 25
26/* 26/*
@@ -34,12 +34,10 @@
34 * leads to races. IBM designers who came up with it should 34 * leads to races. IBM designers who came up with it should
35 * be shot. 35 * be shot.
36 */ 36 */
37
38 37
39static irqreturn_t math_error_irq(int cpl, void *dev_id) 38static irqreturn_t math_error_irq(int cpl, void *dev_id)
40{ 39{
41 extern void math_error(void __user *); 40 outb(0, 0xF0);
42 outb(0,0xF0);
43 if (ignore_fpu_irq || !boot_cpu_data.hard_math) 41 if (ignore_fpu_irq || !boot_cpu_data.hard_math)
44 return IRQ_NONE; 42 return IRQ_NONE;
45 math_error((void __user *)get_irq_regs()->ip); 43 math_error((void __user *)get_irq_regs()->ip);
@@ -56,7 +54,7 @@ static struct irqaction fpu_irq = {
56 .name = "fpu", 54 .name = "fpu",
57}; 55};
58 56
59void __init init_ISA_irqs (void) 57void __init init_ISA_irqs(void)
60{ 58{
61 int i; 59 int i;
62 60
diff --git a/arch/x86/kernel/irqinit_64.c b/arch/x86/kernel/irqinit_64.c
index 31ebfe38e96c..da481a1e3f30 100644
--- a/arch/x86/kernel/irqinit_64.c
+++ b/arch/x86/kernel/irqinit_64.c
@@ -11,14 +11,14 @@
11#include <linux/kernel_stat.h> 11#include <linux/kernel_stat.h>
12#include <linux/sysdev.h> 12#include <linux/sysdev.h>
13#include <linux/bitops.h> 13#include <linux/bitops.h>
14#include <linux/acpi.h>
15#include <linux/io.h>
16#include <linux/delay.h>
14 17
15#include <asm/acpi.h>
16#include <asm/atomic.h> 18#include <asm/atomic.h>
17#include <asm/system.h> 19#include <asm/system.h>
18#include <asm/io.h>
19#include <asm/hw_irq.h> 20#include <asm/hw_irq.h>
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
21#include <asm/delay.h>
22#include <asm/desc.h> 22#include <asm/desc.h>
23#include <asm/apic.h> 23#include <asm/apic.h>
24#include <asm/i8259.h> 24#include <asm/i8259.h>
@@ -81,7 +81,7 @@ int vector_used_by_percpu_irq(unsigned int vector)
81 return 0; 81 return 0;
82} 82}
83 83
84void __init init_ISA_irqs(void) 84static void __init init_ISA_irqs(void)
85{ 85{
86 int i; 86 int i;
87 87
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index cead7e27585d..c0601c2848a1 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -17,7 +17,6 @@
17#include <linux/acpi.h> 17#include <linux/acpi.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/acpi.h>
21 20
22#include <asm/mtrr.h> 21#include <asm/mtrr.h>
23#include <asm/mpspec.h> 22#include <asm/mpspec.h>
@@ -49,12 +48,12 @@ static int __init mpf_checksum(unsigned char *mp, int len)
49 return sum & 0xFF; 48 return sum & 0xFF;
50} 49}
51 50
52static void __init MP_processor_info(struct mpc_config_processor *m) 51static void __init MP_processor_info(struct mpc_cpu *m)
53{ 52{
54 int apicid; 53 int apicid;
55 char *bootup_cpu = ""; 54 char *bootup_cpu = "";
56 55
57 if (!(m->mpc_cpuflag & CPU_ENABLED)) { 56 if (!(m->cpuflag & CPU_ENABLED)) {
58 disabled_cpus++; 57 disabled_cpus++;
59 return; 58 return;
60 } 59 }
@@ -62,54 +61,54 @@ static void __init MP_processor_info(struct mpc_config_processor *m)
62 if (x86_quirks->mpc_apic_id) 61 if (x86_quirks->mpc_apic_id)
63 apicid = x86_quirks->mpc_apic_id(m); 62 apicid = x86_quirks->mpc_apic_id(m);
64 else 63 else
65 apicid = m->mpc_apicid; 64 apicid = m->apicid;
66 65
67 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { 66 if (m->cpuflag & CPU_BOOTPROCESSOR) {
68 bootup_cpu = " (Bootup-CPU)"; 67 bootup_cpu = " (Bootup-CPU)";
69 boot_cpu_physical_apicid = m->mpc_apicid; 68 boot_cpu_physical_apicid = m->apicid;
70 } 69 }
71 70
72 printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu); 71 printk(KERN_INFO "Processor #%d%s\n", m->apicid, bootup_cpu);
73 generic_processor_info(apicid, m->mpc_apicver); 72 generic_processor_info(apicid, m->apicver);
74} 73}
75 74
76#ifdef CONFIG_X86_IO_APIC 75#ifdef CONFIG_X86_IO_APIC
77static void __init MP_bus_info(struct mpc_config_bus *m) 76static void __init MP_bus_info(struct mpc_bus *m)
78{ 77{
79 char str[7]; 78 char str[7];
80 memcpy(str, m->mpc_bustype, 6); 79 memcpy(str, m->bustype, 6);
81 str[6] = 0; 80 str[6] = 0;
82 81
83 if (x86_quirks->mpc_oem_bus_info) 82 if (x86_quirks->mpc_oem_bus_info)
84 x86_quirks->mpc_oem_bus_info(m, str); 83 x86_quirks->mpc_oem_bus_info(m, str);
85 else 84 else
86 apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->mpc_busid, str); 85 apic_printk(APIC_VERBOSE, "Bus #%d is %s\n", m->busid, str);
87 86
88#if MAX_MP_BUSSES < 256 87#if MAX_MP_BUSSES < 256
89 if (m->mpc_busid >= MAX_MP_BUSSES) { 88 if (m->busid >= MAX_MP_BUSSES) {
90 printk(KERN_WARNING "MP table busid value (%d) for bustype %s " 89 printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
91 " is too large, max. supported is %d\n", 90 " is too large, max. supported is %d\n",
92 m->mpc_busid, str, MAX_MP_BUSSES - 1); 91 m->busid, str, MAX_MP_BUSSES - 1);
93 return; 92 return;
94 } 93 }
95#endif 94#endif
96 95
97 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) { 96 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA) - 1) == 0) {
98 set_bit(m->mpc_busid, mp_bus_not_pci); 97 set_bit(m->busid, mp_bus_not_pci);
99#if defined(CONFIG_EISA) || defined(CONFIG_MCA) 98#if defined(CONFIG_EISA) || defined(CONFIG_MCA)
100 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA; 99 mp_bus_id_to_type[m->busid] = MP_BUS_ISA;
101#endif 100#endif
102 } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) { 101 } else if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI) - 1) == 0) {
103 if (x86_quirks->mpc_oem_pci_bus) 102 if (x86_quirks->mpc_oem_pci_bus)
104 x86_quirks->mpc_oem_pci_bus(m); 103 x86_quirks->mpc_oem_pci_bus(m);
105 104
106 clear_bit(m->mpc_busid, mp_bus_not_pci); 105 clear_bit(m->busid, mp_bus_not_pci);
107#if defined(CONFIG_EISA) || defined(CONFIG_MCA) 106#if defined(CONFIG_EISA) || defined(CONFIG_MCA)
108 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI; 107 mp_bus_id_to_type[m->busid] = MP_BUS_PCI;
109 } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) { 108 } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA) - 1) == 0) {
110 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA; 109 mp_bus_id_to_type[m->busid] = MP_BUS_EISA;
111 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) { 110 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA) - 1) == 0) {
112 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA; 111 mp_bus_id_to_type[m->busid] = MP_BUS_MCA;
113#endif 112#endif
114 } else 113 } else
115 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str); 114 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
@@ -133,32 +132,31 @@ static int bad_ioapic(unsigned long address)
133 return 0; 132 return 0;
134} 133}
135 134
136static void __init MP_ioapic_info(struct mpc_config_ioapic *m) 135static void __init MP_ioapic_info(struct mpc_ioapic *m)
137{ 136{
138 if (!(m->mpc_flags & MPC_APIC_USABLE)) 137 if (!(m->flags & MPC_APIC_USABLE))
139 return; 138 return;
140 139
141 printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n", 140 printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
142 m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr); 141 m->apicid, m->apicver, m->apicaddr);
143 142
144 if (bad_ioapic(m->mpc_apicaddr)) 143 if (bad_ioapic(m->apicaddr))
145 return; 144 return;
146 145
147 mp_ioapics[nr_ioapics].mp_apicaddr = m->mpc_apicaddr; 146 mp_ioapics[nr_ioapics].mp_apicaddr = m->apicaddr;
148 mp_ioapics[nr_ioapics].mp_apicid = m->mpc_apicid; 147 mp_ioapics[nr_ioapics].mp_apicid = m->apicid;
149 mp_ioapics[nr_ioapics].mp_type = m->mpc_type; 148 mp_ioapics[nr_ioapics].mp_type = m->type;
150 mp_ioapics[nr_ioapics].mp_apicver = m->mpc_apicver; 149 mp_ioapics[nr_ioapics].mp_apicver = m->apicver;
151 mp_ioapics[nr_ioapics].mp_flags = m->mpc_flags; 150 mp_ioapics[nr_ioapics].mp_flags = m->flags;
152 nr_ioapics++; 151 nr_ioapics++;
153} 152}
154 153
155static void print_MP_intsrc_info(struct mpc_config_intsrc *m) 154static void print_MP_intsrc_info(struct mpc_intsrc *m)
156{ 155{
157 apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x," 156 apic_printk(APIC_VERBOSE, "Int: type %d, pol %d, trig %d, bus %02x,"
158 " IRQ %02x, APIC ID %x, APIC INT %02x\n", 157 " IRQ %02x, APIC ID %x, APIC INT %02x\n",
159 m->mpc_irqtype, m->mpc_irqflag & 3, 158 m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbus,
160 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus, 159 m->srcbusirq, m->dstapic, m->dstirq);
161 m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
162} 160}
163 161
164static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq) 162static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq)
@@ -170,52 +168,52 @@ static void __init print_mp_irq_info(struct mp_config_intsrc *mp_irq)
170 mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq); 168 mp_irq->mp_srcbusirq, mp_irq->mp_dstapic, mp_irq->mp_dstirq);
171} 169}
172 170
173static void __init assign_to_mp_irq(struct mpc_config_intsrc *m, 171static void __init assign_to_mp_irq(struct mpc_intsrc *m,
174 struct mp_config_intsrc *mp_irq) 172 struct mp_config_intsrc *mp_irq)
175{ 173{
176 mp_irq->mp_dstapic = m->mpc_dstapic; 174 mp_irq->mp_dstapic = m->dstapic;
177 mp_irq->mp_type = m->mpc_type; 175 mp_irq->mp_type = m->type;
178 mp_irq->mp_irqtype = m->mpc_irqtype; 176 mp_irq->mp_irqtype = m->irqtype;
179 mp_irq->mp_irqflag = m->mpc_irqflag; 177 mp_irq->mp_irqflag = m->irqflag;
180 mp_irq->mp_srcbus = m->mpc_srcbus; 178 mp_irq->mp_srcbus = m->srcbus;
181 mp_irq->mp_srcbusirq = m->mpc_srcbusirq; 179 mp_irq->mp_srcbusirq = m->srcbusirq;
182 mp_irq->mp_dstirq = m->mpc_dstirq; 180 mp_irq->mp_dstirq = m->dstirq;
183} 181}
184 182
185static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq, 183static void __init assign_to_mpc_intsrc(struct mp_config_intsrc *mp_irq,
186 struct mpc_config_intsrc *m) 184 struct mpc_intsrc *m)
187{ 185{
188 m->mpc_dstapic = mp_irq->mp_dstapic; 186 m->dstapic = mp_irq->mp_dstapic;
189 m->mpc_type = mp_irq->mp_type; 187 m->type = mp_irq->mp_type;
190 m->mpc_irqtype = mp_irq->mp_irqtype; 188 m->irqtype = mp_irq->mp_irqtype;
191 m->mpc_irqflag = mp_irq->mp_irqflag; 189 m->irqflag = mp_irq->mp_irqflag;
192 m->mpc_srcbus = mp_irq->mp_srcbus; 190 m->srcbus = mp_irq->mp_srcbus;
193 m->mpc_srcbusirq = mp_irq->mp_srcbusirq; 191 m->srcbusirq = mp_irq->mp_srcbusirq;
194 m->mpc_dstirq = mp_irq->mp_dstirq; 192 m->dstirq = mp_irq->mp_dstirq;
195} 193}
196 194
197static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq, 195static int __init mp_irq_mpc_intsrc_cmp(struct mp_config_intsrc *mp_irq,
198 struct mpc_config_intsrc *m) 196 struct mpc_intsrc *m)
199{ 197{
200 if (mp_irq->mp_dstapic != m->mpc_dstapic) 198 if (mp_irq->mp_dstapic != m->dstapic)
201 return 1; 199 return 1;
202 if (mp_irq->mp_type != m->mpc_type) 200 if (mp_irq->mp_type != m->type)
203 return 2; 201 return 2;
204 if (mp_irq->mp_irqtype != m->mpc_irqtype) 202 if (mp_irq->mp_irqtype != m->irqtype)
205 return 3; 203 return 3;
206 if (mp_irq->mp_irqflag != m->mpc_irqflag) 204 if (mp_irq->mp_irqflag != m->irqflag)
207 return 4; 205 return 4;
208 if (mp_irq->mp_srcbus != m->mpc_srcbus) 206 if (mp_irq->mp_srcbus != m->srcbus)
209 return 5; 207 return 5;
210 if (mp_irq->mp_srcbusirq != m->mpc_srcbusirq) 208 if (mp_irq->mp_srcbusirq != m->srcbusirq)
211 return 6; 209 return 6;
212 if (mp_irq->mp_dstirq != m->mpc_dstirq) 210 if (mp_irq->mp_dstirq != m->dstirq)
213 return 7; 211 return 7;
214 212
215 return 0; 213 return 0;
216} 214}
217 215
218static void __init MP_intsrc_info(struct mpc_config_intsrc *m) 216static void __init MP_intsrc_info(struct mpc_intsrc *m)
219{ 217{
220 int i; 218 int i;
221 219
@@ -233,57 +231,55 @@ static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
233 231
234#endif 232#endif
235 233
236static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m) 234static void __init MP_lintsrc_info(struct mpc_lintsrc *m)
237{ 235{
238 apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x," 236 apic_printk(APIC_VERBOSE, "Lint: type %d, pol %d, trig %d, bus %02x,"
239 " IRQ %02x, APIC ID %x, APIC LINT %02x\n", 237 " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
240 m->mpc_irqtype, m->mpc_irqflag & 3, 238 m->irqtype, m->irqflag & 3, (m->irqflag >> 2) & 3, m->srcbusid,
241 (m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid, 239 m->srcbusirq, m->destapic, m->destapiclint);
242 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
243} 240}
244 241
245/* 242/*
246 * Read/parse the MPC 243 * Read/parse the MPC
247 */ 244 */
248 245
249static int __init smp_check_mpc(struct mp_config_table *mpc, char *oem, 246static int __init smp_check_mpc(struct mpc_table *mpc, char *oem, char *str)
250 char *str)
251{ 247{
252 248
253 if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) { 249 if (memcmp(mpc->signature, MPC_SIGNATURE, 4)) {
254 printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n", 250 printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n",
255 mpc->mpc_signature[0], mpc->mpc_signature[1], 251 mpc->signature[0], mpc->signature[1],
256 mpc->mpc_signature[2], mpc->mpc_signature[3]); 252 mpc->signature[2], mpc->signature[3]);
257 return 0; 253 return 0;
258 } 254 }
259 if (mpf_checksum((unsigned char *)mpc, mpc->mpc_length)) { 255 if (mpf_checksum((unsigned char *)mpc, mpc->length)) {
260 printk(KERN_ERR "MPTABLE: checksum error!\n"); 256 printk(KERN_ERR "MPTABLE: checksum error!\n");
261 return 0; 257 return 0;
262 } 258 }
263 if (mpc->mpc_spec != 0x01 && mpc->mpc_spec != 0x04) { 259 if (mpc->spec != 0x01 && mpc->spec != 0x04) {
264 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n", 260 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
265 mpc->mpc_spec); 261 mpc->spec);
266 return 0; 262 return 0;
267 } 263 }
268 if (!mpc->mpc_lapic) { 264 if (!mpc->lapic) {
269 printk(KERN_ERR "MPTABLE: null local APIC address!\n"); 265 printk(KERN_ERR "MPTABLE: null local APIC address!\n");
270 return 0; 266 return 0;
271 } 267 }
272 memcpy(oem, mpc->mpc_oem, 8); 268 memcpy(oem, mpc->oem, 8);
273 oem[8] = 0; 269 oem[8] = 0;
274 printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem); 270 printk(KERN_INFO "MPTABLE: OEM ID: %s\n", oem);
275 271
276 memcpy(str, mpc->mpc_productid, 12); 272 memcpy(str, mpc->productid, 12);
277 str[12] = 0; 273 str[12] = 0;
278 274
279 printk(KERN_INFO "MPTABLE: Product ID: %s\n", str); 275 printk(KERN_INFO "MPTABLE: Product ID: %s\n", str);
280 276
281 printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic); 277 printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->lapic);
282 278
283 return 1; 279 return 1;
284} 280}
285 281
286static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early) 282static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)
287{ 283{
288 char str[16]; 284 char str[16];
289 char oem[10]; 285 char oem[10];
@@ -308,14 +304,14 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
308#endif 304#endif
309 /* save the local APIC address, it might be non-default */ 305 /* save the local APIC address, it might be non-default */
310 if (!acpi_lapic) 306 if (!acpi_lapic)
311 mp_lapic_addr = mpc->mpc_lapic; 307 mp_lapic_addr = mpc->lapic;
312 308
313 if (early) 309 if (early)
314 return 1; 310 return 1;
315 311
316 if (mpc->mpc_oemptr && x86_quirks->smp_read_mpc_oem) { 312 if (mpc->oemptr && x86_quirks->smp_read_mpc_oem) {
317 struct mp_config_oemtable *oem_table = (struct mp_config_oemtable *)(unsigned long)mpc->mpc_oemptr; 313 struct mpc_oemtable *oem_table = (void *)(long)mpc->oemptr;
318 x86_quirks->smp_read_mpc_oem(oem_table, mpc->mpc_oemsize); 314 x86_quirks->smp_read_mpc_oem(oem_table, mpc->oemsize);
319 } 315 }
320 316
321 /* 317 /*
@@ -324,12 +320,11 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
324 if (x86_quirks->mpc_record) 320 if (x86_quirks->mpc_record)
325 *x86_quirks->mpc_record = 0; 321 *x86_quirks->mpc_record = 0;
326 322
327 while (count < mpc->mpc_length) { 323 while (count < mpc->length) {
328 switch (*mpt) { 324 switch (*mpt) {
329 case MP_PROCESSOR: 325 case MP_PROCESSOR:
330 { 326 {
331 struct mpc_config_processor *m = 327 struct mpc_cpu *m = (struct mpc_cpu *)mpt;
332 (struct mpc_config_processor *)mpt;
333 /* ACPI may have already provided this data */ 328 /* ACPI may have already provided this data */
334 if (!acpi_lapic) 329 if (!acpi_lapic)
335 MP_processor_info(m); 330 MP_processor_info(m);
@@ -339,8 +334,7 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
339 } 334 }
340 case MP_BUS: 335 case MP_BUS:
341 { 336 {
342 struct mpc_config_bus *m = 337 struct mpc_bus *m = (struct mpc_bus *)mpt;
343 (struct mpc_config_bus *)mpt;
344#ifdef CONFIG_X86_IO_APIC 338#ifdef CONFIG_X86_IO_APIC
345 MP_bus_info(m); 339 MP_bus_info(m);
346#endif 340#endif
@@ -351,30 +345,28 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
351 case MP_IOAPIC: 345 case MP_IOAPIC:
352 { 346 {
353#ifdef CONFIG_X86_IO_APIC 347#ifdef CONFIG_X86_IO_APIC
354 struct mpc_config_ioapic *m = 348 struct mpc_ioapic *m = (struct mpc_ioapic *)mpt;
355 (struct mpc_config_ioapic *)mpt;
356 MP_ioapic_info(m); 349 MP_ioapic_info(m);
357#endif 350#endif
358 mpt += sizeof(struct mpc_config_ioapic); 351 mpt += sizeof(struct mpc_ioapic);
359 count += sizeof(struct mpc_config_ioapic); 352 count += sizeof(struct mpc_ioapic);
360 break; 353 break;
361 } 354 }
362 case MP_INTSRC: 355 case MP_INTSRC:
363 { 356 {
364#ifdef CONFIG_X86_IO_APIC 357#ifdef CONFIG_X86_IO_APIC
365 struct mpc_config_intsrc *m = 358 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
366 (struct mpc_config_intsrc *)mpt;
367 359
368 MP_intsrc_info(m); 360 MP_intsrc_info(m);
369#endif 361#endif
370 mpt += sizeof(struct mpc_config_intsrc); 362 mpt += sizeof(struct mpc_intsrc);
371 count += sizeof(struct mpc_config_intsrc); 363 count += sizeof(struct mpc_intsrc);
372 break; 364 break;
373 } 365 }
374 case MP_LINTSRC: 366 case MP_LINTSRC:
375 { 367 {
376 struct mpc_config_lintsrc *m = 368 struct mpc_lintsrc *m =
377 (struct mpc_config_lintsrc *)mpt; 369 (struct mpc_lintsrc *)mpt;
378 MP_lintsrc_info(m); 370 MP_lintsrc_info(m);
379 mpt += sizeof(*m); 371 mpt += sizeof(*m);
380 count += sizeof(*m); 372 count += sizeof(*m);
@@ -385,8 +377,8 @@ static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
385 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); 377 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
386 printk(KERN_ERR "type %x\n", *mpt); 378 printk(KERN_ERR "type %x\n", *mpt);
387 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, 379 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
388 1, mpc, mpc->mpc_length, 1); 380 1, mpc, mpc->length, 1);
389 count = mpc->mpc_length; 381 count = mpc->length;
390 break; 382 break;
391 } 383 }
392 if (x86_quirks->mpc_record) 384 if (x86_quirks->mpc_record)
@@ -417,16 +409,16 @@ static int __init ELCR_trigger(unsigned int irq)
417 409
418static void __init construct_default_ioirq_mptable(int mpc_default_type) 410static void __init construct_default_ioirq_mptable(int mpc_default_type)
419{ 411{
420 struct mpc_config_intsrc intsrc; 412 struct mpc_intsrc intsrc;
421 int i; 413 int i;
422 int ELCR_fallback = 0; 414 int ELCR_fallback = 0;
423 415
424 intsrc.mpc_type = MP_INTSRC; 416 intsrc.type = MP_INTSRC;
425 intsrc.mpc_irqflag = 0; /* conforming */ 417 intsrc.irqflag = 0; /* conforming */
426 intsrc.mpc_srcbus = 0; 418 intsrc.srcbus = 0;
427 intsrc.mpc_dstapic = mp_ioapics[0].mp_apicid; 419 intsrc.dstapic = mp_ioapics[0].mp_apicid;
428 420
429 intsrc.mpc_irqtype = mp_INT; 421 intsrc.irqtype = mp_INT;
430 422
431 /* 423 /*
432 * If true, we have an ISA/PCI system with no IRQ entries 424 * If true, we have an ISA/PCI system with no IRQ entries
@@ -469,30 +461,30 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
469 * irqflag field (level sensitive, active high polarity). 461 * irqflag field (level sensitive, active high polarity).
470 */ 462 */
471 if (ELCR_trigger(i)) 463 if (ELCR_trigger(i))
472 intsrc.mpc_irqflag = 13; 464 intsrc.irqflag = 13;
473 else 465 else
474 intsrc.mpc_irqflag = 0; 466 intsrc.irqflag = 0;
475 } 467 }
476 468
477 intsrc.mpc_srcbusirq = i; 469 intsrc.srcbusirq = i;
478 intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */ 470 intsrc.dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
479 MP_intsrc_info(&intsrc); 471 MP_intsrc_info(&intsrc);
480 } 472 }
481 473
482 intsrc.mpc_irqtype = mp_ExtINT; 474 intsrc.irqtype = mp_ExtINT;
483 intsrc.mpc_srcbusirq = 0; 475 intsrc.srcbusirq = 0;
484 intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */ 476 intsrc.dstirq = 0; /* 8259A to INTIN0 */
485 MP_intsrc_info(&intsrc); 477 MP_intsrc_info(&intsrc);
486} 478}
487 479
488 480
489static void __init construct_ioapic_table(int mpc_default_type) 481static void __init construct_ioapic_table(int mpc_default_type)
490{ 482{
491 struct mpc_config_ioapic ioapic; 483 struct mpc_ioapic ioapic;
492 struct mpc_config_bus bus; 484 struct mpc_bus bus;
493 485
494 bus.mpc_type = MP_BUS; 486 bus.type = MP_BUS;
495 bus.mpc_busid = 0; 487 bus.busid = 0;
496 switch (mpc_default_type) { 488 switch (mpc_default_type) {
497 default: 489 default:
498 printk(KERN_ERR "???\nUnknown standard configuration %d\n", 490 printk(KERN_ERR "???\nUnknown standard configuration %d\n",
@@ -500,29 +492,29 @@ static void __init construct_ioapic_table(int mpc_default_type)
500 /* fall through */ 492 /* fall through */
501 case 1: 493 case 1:
502 case 5: 494 case 5:
503 memcpy(bus.mpc_bustype, "ISA ", 6); 495 memcpy(bus.bustype, "ISA ", 6);
504 break; 496 break;
505 case 2: 497 case 2:
506 case 6: 498 case 6:
507 case 3: 499 case 3:
508 memcpy(bus.mpc_bustype, "EISA ", 6); 500 memcpy(bus.bustype, "EISA ", 6);
509 break; 501 break;
510 case 4: 502 case 4:
511 case 7: 503 case 7:
512 memcpy(bus.mpc_bustype, "MCA ", 6); 504 memcpy(bus.bustype, "MCA ", 6);
513 } 505 }
514 MP_bus_info(&bus); 506 MP_bus_info(&bus);
515 if (mpc_default_type > 4) { 507 if (mpc_default_type > 4) {
516 bus.mpc_busid = 1; 508 bus.busid = 1;
517 memcpy(bus.mpc_bustype, "PCI ", 6); 509 memcpy(bus.bustype, "PCI ", 6);
518 MP_bus_info(&bus); 510 MP_bus_info(&bus);
519 } 511 }
520 512
521 ioapic.mpc_type = MP_IOAPIC; 513 ioapic.type = MP_IOAPIC;
522 ioapic.mpc_apicid = 2; 514 ioapic.apicid = 2;
523 ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; 515 ioapic.apicver = mpc_default_type > 4 ? 0x10 : 0x01;
524 ioapic.mpc_flags = MPC_APIC_USABLE; 516 ioapic.flags = MPC_APIC_USABLE;
525 ioapic.mpc_apicaddr = 0xFEC00000; 517 ioapic.apicaddr = 0xFEC00000;
526 MP_ioapic_info(&ioapic); 518 MP_ioapic_info(&ioapic);
527 519
528 /* 520 /*
@@ -536,8 +528,8 @@ static inline void __init construct_ioapic_table(int mpc_default_type) { }
536 528
537static inline void __init construct_default_ISA_mptable(int mpc_default_type) 529static inline void __init construct_default_ISA_mptable(int mpc_default_type)
538{ 530{
539 struct mpc_config_processor processor; 531 struct mpc_cpu processor;
540 struct mpc_config_lintsrc lintsrc; 532 struct mpc_lintsrc lintsrc;
541 int linttypes[2] = { mp_ExtINT, mp_NMI }; 533 int linttypes[2] = { mp_ExtINT, mp_NMI };
542 int i; 534 int i;
543 535
@@ -549,30 +541,30 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
549 /* 541 /*
550 * 2 CPUs, numbered 0 & 1. 542 * 2 CPUs, numbered 0 & 1.
551 */ 543 */
552 processor.mpc_type = MP_PROCESSOR; 544 processor.type = MP_PROCESSOR;
553 /* Either an integrated APIC or a discrete 82489DX. */ 545 /* Either an integrated APIC or a discrete 82489DX. */
554 processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; 546 processor.apicver = mpc_default_type > 4 ? 0x10 : 0x01;
555 processor.mpc_cpuflag = CPU_ENABLED; 547 processor.cpuflag = CPU_ENABLED;
556 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 548 processor.cpufeature = (boot_cpu_data.x86 << 8) |
557 (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; 549 (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
558 processor.mpc_featureflag = boot_cpu_data.x86_capability[0]; 550 processor.featureflag = boot_cpu_data.x86_capability[0];
559 processor.mpc_reserved[0] = 0; 551 processor.reserved[0] = 0;
560 processor.mpc_reserved[1] = 0; 552 processor.reserved[1] = 0;
561 for (i = 0; i < 2; i++) { 553 for (i = 0; i < 2; i++) {
562 processor.mpc_apicid = i; 554 processor.apicid = i;
563 MP_processor_info(&processor); 555 MP_processor_info(&processor);
564 } 556 }
565 557
566 construct_ioapic_table(mpc_default_type); 558 construct_ioapic_table(mpc_default_type);
567 559
568 lintsrc.mpc_type = MP_LINTSRC; 560 lintsrc.type = MP_LINTSRC;
569 lintsrc.mpc_irqflag = 0; /* conforming */ 561 lintsrc.irqflag = 0; /* conforming */
570 lintsrc.mpc_srcbusid = 0; 562 lintsrc.srcbusid = 0;
571 lintsrc.mpc_srcbusirq = 0; 563 lintsrc.srcbusirq = 0;
572 lintsrc.mpc_destapic = MP_APIC_ALL; 564 lintsrc.destapic = MP_APIC_ALL;
573 for (i = 0; i < 2; i++) { 565 for (i = 0; i < 2; i++) {
574 lintsrc.mpc_irqtype = linttypes[i]; 566 lintsrc.irqtype = linttypes[i];
575 lintsrc.mpc_destapiclint = i; 567 lintsrc.destapiclint = i;
576 MP_lintsrc_info(&lintsrc); 568 MP_lintsrc_info(&lintsrc);
577 } 569 }
578} 570}
@@ -657,15 +649,15 @@ static void __init __get_smp_config(unsigned int early)
657 * ISA defaults and hope it will work. 649 * ISA defaults and hope it will work.
658 */ 650 */
659 if (!mp_irq_entries) { 651 if (!mp_irq_entries) {
660 struct mpc_config_bus bus; 652 struct mpc_bus bus;
661 653
662 printk(KERN_ERR "BIOS bug, no explicit IRQ entries, " 654 printk(KERN_ERR "BIOS bug, no explicit IRQ entries, "
663 "using default mptable. " 655 "using default mptable. "
664 "(tell your hw vendor)\n"); 656 "(tell your hw vendor)\n");
665 657
666 bus.mpc_type = MP_BUS; 658 bus.type = MP_BUS;
667 bus.mpc_busid = 0; 659 bus.busid = 0;
668 memcpy(bus.mpc_bustype, "ISA ", 6); 660 memcpy(bus.bustype, "ISA ", 6);
669 MP_bus_info(&bus); 661 MP_bus_info(&bus);
670 662
671 construct_default_ioirq_mptable(0); 663 construct_default_ioirq_mptable(0);
@@ -803,14 +795,14 @@ void __init find_smp_config(void)
803#ifdef CONFIG_X86_IO_APIC 795#ifdef CONFIG_X86_IO_APIC
804static u8 __initdata irq_used[MAX_IRQ_SOURCES]; 796static u8 __initdata irq_used[MAX_IRQ_SOURCES];
805 797
806static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m) 798static int __init get_MP_intsrc_index(struct mpc_intsrc *m)
807{ 799{
808 int i; 800 int i;
809 801
810 if (m->mpc_irqtype != mp_INT) 802 if (m->irqtype != mp_INT)
811 return 0; 803 return 0;
812 804
813 if (m->mpc_irqflag != 0x0f) 805 if (m->irqflag != 0x0f)
814 return 0; 806 return 0;
815 807
816 /* not legacy */ 808 /* not legacy */
@@ -822,9 +814,9 @@ static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m)
822 if (mp_irqs[i].mp_irqflag != 0x0f) 814 if (mp_irqs[i].mp_irqflag != 0x0f)
823 continue; 815 continue;
824 816
825 if (mp_irqs[i].mp_srcbus != m->mpc_srcbus) 817 if (mp_irqs[i].mp_srcbus != m->srcbus)
826 continue; 818 continue;
827 if (mp_irqs[i].mp_srcbusirq != m->mpc_srcbusirq) 819 if (mp_irqs[i].mp_srcbusirq != m->srcbusirq)
828 continue; 820 continue;
829 if (irq_used[i]) { 821 if (irq_used[i]) {
830 /* already claimed */ 822 /* already claimed */
@@ -840,10 +832,10 @@ static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m)
840 832
841#define SPARE_SLOT_NUM 20 833#define SPARE_SLOT_NUM 20
842 834
843static struct mpc_config_intsrc __initdata *m_spare[SPARE_SLOT_NUM]; 835static struct mpc_intsrc __initdata *m_spare[SPARE_SLOT_NUM];
844#endif 836#endif
845 837
846static int __init replace_intsrc_all(struct mp_config_table *mpc, 838static int __init replace_intsrc_all(struct mpc_table *mpc,
847 unsigned long mpc_new_phys, 839 unsigned long mpc_new_phys,
848 unsigned long mpc_new_length) 840 unsigned long mpc_new_length)
849{ 841{
@@ -855,36 +847,33 @@ static int __init replace_intsrc_all(struct mp_config_table *mpc,
855 int count = sizeof(*mpc); 847 int count = sizeof(*mpc);
856 unsigned char *mpt = ((unsigned char *)mpc) + count; 848 unsigned char *mpt = ((unsigned char *)mpc) + count;
857 849
858 printk(KERN_INFO "mpc_length %x\n", mpc->mpc_length); 850 printk(KERN_INFO "mpc_length %x\n", mpc->length);
859 while (count < mpc->mpc_length) { 851 while (count < mpc->length) {
860 switch (*mpt) { 852 switch (*mpt) {
861 case MP_PROCESSOR: 853 case MP_PROCESSOR:
862 { 854 {
863 struct mpc_config_processor *m = 855 struct mpc_cpu *m = (struct mpc_cpu *)mpt;
864 (struct mpc_config_processor *)mpt;
865 mpt += sizeof(*m); 856 mpt += sizeof(*m);
866 count += sizeof(*m); 857 count += sizeof(*m);
867 break; 858 break;
868 } 859 }
869 case MP_BUS: 860 case MP_BUS:
870 { 861 {
871 struct mpc_config_bus *m = 862 struct mpc_bus *m = (struct mpc_bus *)mpt;
872 (struct mpc_config_bus *)mpt;
873 mpt += sizeof(*m); 863 mpt += sizeof(*m);
874 count += sizeof(*m); 864 count += sizeof(*m);
875 break; 865 break;
876 } 866 }
877 case MP_IOAPIC: 867 case MP_IOAPIC:
878 { 868 {
879 mpt += sizeof(struct mpc_config_ioapic); 869 mpt += sizeof(struct mpc_ioapic);
880 count += sizeof(struct mpc_config_ioapic); 870 count += sizeof(struct mpc_ioapic);
881 break; 871 break;
882 } 872 }
883 case MP_INTSRC: 873 case MP_INTSRC:
884 { 874 {
885#ifdef CONFIG_X86_IO_APIC 875#ifdef CONFIG_X86_IO_APIC
886 struct mpc_config_intsrc *m = 876 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
887 (struct mpc_config_intsrc *)mpt;
888 877
889 printk(KERN_INFO "OLD "); 878 printk(KERN_INFO "OLD ");
890 print_MP_intsrc_info(m); 879 print_MP_intsrc_info(m);
@@ -905,14 +894,14 @@ static int __init replace_intsrc_all(struct mp_config_table *mpc,
905 nr_m_spare++; 894 nr_m_spare++;
906 } 895 }
907#endif 896#endif
908 mpt += sizeof(struct mpc_config_intsrc); 897 mpt += sizeof(struct mpc_intsrc);
909 count += sizeof(struct mpc_config_intsrc); 898 count += sizeof(struct mpc_intsrc);
910 break; 899 break;
911 } 900 }
912 case MP_LINTSRC: 901 case MP_LINTSRC:
913 { 902 {
914 struct mpc_config_lintsrc *m = 903 struct mpc_lintsrc *m =
915 (struct mpc_config_lintsrc *)mpt; 904 (struct mpc_lintsrc *)mpt;
916 mpt += sizeof(*m); 905 mpt += sizeof(*m);
917 count += sizeof(*m); 906 count += sizeof(*m);
918 break; 907 break;
@@ -922,7 +911,7 @@ static int __init replace_intsrc_all(struct mp_config_table *mpc,
922 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n"); 911 printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
923 printk(KERN_ERR "type %x\n", *mpt); 912 printk(KERN_ERR "type %x\n", *mpt);
924 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16, 913 print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
925 1, mpc, mpc->mpc_length, 1); 914 1, mpc, mpc->length, 1);
926 goto out; 915 goto out;
927 } 916 }
928 } 917 }
@@ -944,9 +933,8 @@ static int __init replace_intsrc_all(struct mp_config_table *mpc,
944 assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]); 933 assign_to_mpc_intsrc(&mp_irqs[i], m_spare[nr_m_spare]);
945 m_spare[nr_m_spare] = NULL; 934 m_spare[nr_m_spare] = NULL;
946 } else { 935 } else {
947 struct mpc_config_intsrc *m = 936 struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
948 (struct mpc_config_intsrc *)mpt; 937 count += sizeof(struct mpc_intsrc);
949 count += sizeof(struct mpc_config_intsrc);
950 if (!mpc_new_phys) { 938 if (!mpc_new_phys) {
951 printk(KERN_INFO "No spare slots, try to append...take your risk, new mpc_length %x\n", count); 939 printk(KERN_INFO "No spare slots, try to append...take your risk, new mpc_length %x\n", count);
952 } else { 940 } else {
@@ -958,17 +946,16 @@ static int __init replace_intsrc_all(struct mp_config_table *mpc,
958 } 946 }
959 } 947 }
960 assign_to_mpc_intsrc(&mp_irqs[i], m); 948 assign_to_mpc_intsrc(&mp_irqs[i], m);
961 mpc->mpc_length = count; 949 mpc->length = count;
962 mpt += sizeof(struct mpc_config_intsrc); 950 mpt += sizeof(struct mpc_intsrc);
963 } 951 }
964 print_mp_irq_info(&mp_irqs[i]); 952 print_mp_irq_info(&mp_irqs[i]);
965 } 953 }
966#endif 954#endif
967out: 955out:
968 /* update checksum */ 956 /* update checksum */
969 mpc->mpc_checksum = 0; 957 mpc->checksum = 0;
970 mpc->mpc_checksum -= mpf_checksum((unsigned char *)mpc, 958 mpc->checksum -= mpf_checksum((unsigned char *)mpc, mpc->length);
971 mpc->mpc_length);
972 959
973 return 0; 960 return 0;
974} 961}
@@ -1014,8 +1001,7 @@ static int __init update_mp_table(void)
1014 char str[16]; 1001 char str[16];
1015 char oem[10]; 1002 char oem[10];
1016 struct intel_mp_floating *mpf; 1003 struct intel_mp_floating *mpf;
1017 struct mp_config_table *mpc; 1004 struct mpc_table *mpc, *mpc_new;
1018 struct mp_config_table *mpc_new;
1019 1005
1020 if (!enable_update_mptable) 1006 if (!enable_update_mptable)
1021 return 0; 1007 return 0;
@@ -1041,7 +1027,7 @@ static int __init update_mp_table(void)
1041 printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); 1027 printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf));
1042 printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr); 1028 printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr);
1043 1029
1044 if (mpc_new_phys && mpc->mpc_length > mpc_new_length) { 1030 if (mpc_new_phys && mpc->length > mpc_new_length) {
1045 mpc_new_phys = 0; 1031 mpc_new_phys = 0;
1046 printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n", 1032 printk(KERN_INFO "mpc_new_length is %ld, please use alloc_mptable=8k\n",
1047 mpc_new_length); 1033 mpc_new_length);
@@ -1050,10 +1036,10 @@ static int __init update_mp_table(void)
1050 if (!mpc_new_phys) { 1036 if (!mpc_new_phys) {
1051 unsigned char old, new; 1037 unsigned char old, new;
1052 /* check if we can change the postion */ 1038 /* check if we can change the postion */
1053 mpc->mpc_checksum = 0; 1039 mpc->checksum = 0;
1054 old = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); 1040 old = mpf_checksum((unsigned char *)mpc, mpc->length);
1055 mpc->mpc_checksum = 0xff; 1041 mpc->checksum = 0xff;
1056 new = mpf_checksum((unsigned char *)mpc, mpc->mpc_length); 1042 new = mpf_checksum((unsigned char *)mpc, mpc->length);
1057 if (old == new) { 1043 if (old == new) {
1058 printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n"); 1044 printk(KERN_INFO "mpc is readonly, please try alloc_mptable instead\n");
1059 return 0; 1045 return 0;
@@ -1062,7 +1048,7 @@ static int __init update_mp_table(void)
1062 } else { 1048 } else {
1063 mpf->mpf_physptr = mpc_new_phys; 1049 mpf->mpf_physptr = mpc_new_phys;
1064 mpc_new = phys_to_virt(mpc_new_phys); 1050 mpc_new = phys_to_virt(mpc_new_phys);
1065 memcpy(mpc_new, mpc, mpc->mpc_length); 1051 memcpy(mpc_new, mpc, mpc->length);
1066 mpc = mpc_new; 1052 mpc = mpc_new;
1067 /* check if we can modify that */ 1053 /* check if we can modify that */
1068 if (mpc_new_phys - mpf->mpf_physptr) { 1054 if (mpc_new_phys - mpf->mpf_physptr) {
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 82a7c7ed6d45..726266695b2c 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -136,7 +136,7 @@ static int msr_open(struct inode *inode, struct file *file)
136 lock_kernel(); 136 lock_kernel();
137 cpu = iminor(file->f_path.dentry->d_inode); 137 cpu = iminor(file->f_path.dentry->d_inode);
138 138
139 if (cpu >= NR_CPUS || !cpu_online(cpu)) { 139 if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
140 ret = -ENXIO; /* No such CPU */ 140 ret = -ENXIO; /* No such CPU */
141 goto out; 141 goto out;
142 } 142 }
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 45a09ccdc214..7228979f1e7f 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -26,7 +26,6 @@
26#include <linux/kernel_stat.h> 26#include <linux/kernel_stat.h>
27#include <linux/kdebug.h> 27#include <linux/kdebug.h>
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/nmi.h>
30 29
31#include <asm/i8259.h> 30#include <asm/i8259.h>
32#include <asm/io_apic.h> 31#include <asm/io_apic.h>
diff --git a/arch/x86/kernel/numaq_32.c b/arch/x86/kernel/numaq_32.c
index 0deea37a53cf..f2191d4f2717 100644
--- a/arch/x86/kernel/numaq_32.c
+++ b/arch/x86/kernel/numaq_32.c
@@ -117,16 +117,15 @@ static inline int generate_logical_apicid(int quad, int phys_apicid)
117} 117}
118 118
119/* x86_quirks member */ 119/* x86_quirks member */
120static int mpc_apic_id(struct mpc_config_processor *m) 120static int mpc_apic_id(struct mpc_cpu *m)
121{ 121{
122 int quad = translation_table[mpc_record]->trans_quad; 122 int quad = translation_table[mpc_record]->trans_quad;
123 int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid); 123 int logical_apicid = generate_logical_apicid(quad, m->apicid);
124 124
125 printk(KERN_DEBUG "Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n", 125 printk(KERN_DEBUG "Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n",
126 m->mpc_apicid, 126 m->apicid, (m->cpufeature & CPU_FAMILY_MASK) >> 8,
127 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 127 (m->cpufeature & CPU_MODEL_MASK) >> 4,
128 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 128 m->apicver, quad, logical_apicid);
129 m->mpc_apicver, quad, logical_apicid);
130 return logical_apicid; 129 return logical_apicid;
131} 130}
132 131
@@ -135,26 +134,26 @@ int mp_bus_id_to_node[MAX_MP_BUSSES];
135int mp_bus_id_to_local[MAX_MP_BUSSES]; 134int mp_bus_id_to_local[MAX_MP_BUSSES];
136 135
137/* x86_quirks member */ 136/* x86_quirks member */
138static void mpc_oem_bus_info(struct mpc_config_bus *m, char *name) 137static void mpc_oem_bus_info(struct mpc_bus *m, char *name)
139{ 138{
140 int quad = translation_table[mpc_record]->trans_quad; 139 int quad = translation_table[mpc_record]->trans_quad;
141 int local = translation_table[mpc_record]->trans_local; 140 int local = translation_table[mpc_record]->trans_local;
142 141
143 mp_bus_id_to_node[m->mpc_busid] = quad; 142 mp_bus_id_to_node[m->busid] = quad;
144 mp_bus_id_to_local[m->mpc_busid] = local; 143 mp_bus_id_to_local[m->busid] = local;
145 printk(KERN_INFO "Bus #%d is %s (node %d)\n", 144 printk(KERN_INFO "Bus #%d is %s (node %d)\n",
146 m->mpc_busid, name, quad); 145 m->busid, name, quad);
147} 146}
148 147
149int quad_local_to_mp_bus_id [NR_CPUS/4][4]; 148int quad_local_to_mp_bus_id [NR_CPUS/4][4];
150 149
151/* x86_quirks member */ 150/* x86_quirks member */
152static void mpc_oem_pci_bus(struct mpc_config_bus *m) 151static void mpc_oem_pci_bus(struct mpc_bus *m)
153{ 152{
154 int quad = translation_table[mpc_record]->trans_quad; 153 int quad = translation_table[mpc_record]->trans_quad;
155 int local = translation_table[mpc_record]->trans_local; 154 int local = translation_table[mpc_record]->trans_local;
156 155
157 quad_local_to_mp_bus_id[quad][local] = m->mpc_busid; 156 quad_local_to_mp_bus_id[quad][local] = m->busid;
158} 157}
159 158
160static void __init MP_translation_info(struct mpc_config_translation *m) 159static void __init MP_translation_info(struct mpc_config_translation *m)
@@ -186,7 +185,7 @@ static int __init mpf_checksum(unsigned char *mp, int len)
186 * Read/parse the MPC oem tables 185 * Read/parse the MPC oem tables
187 */ 186 */
188 187
189static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, 188static void __init smp_read_mpc_oem(struct mpc_oemtable *oemtable,
190 unsigned short oemsize) 189 unsigned short oemsize)
191{ 190{
192 int count = sizeof(*oemtable); /* the header size */ 191 int count = sizeof(*oemtable); /* the header size */
@@ -195,18 +194,18 @@ static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable,
195 mpc_record = 0; 194 mpc_record = 0;
196 printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n", 195 printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n",
197 oemtable); 196 oemtable);
198 if (memcmp(oemtable->oem_signature, MPC_OEM_SIGNATURE, 4)) { 197 if (memcmp(oemtable->signature, MPC_OEM_SIGNATURE, 4)) {
199 printk(KERN_WARNING 198 printk(KERN_WARNING
200 "SMP mpc oemtable: bad signature [%c%c%c%c]!\n", 199 "SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
201 oemtable->oem_signature[0], oemtable->oem_signature[1], 200 oemtable->signature[0], oemtable->signature[1],
202 oemtable->oem_signature[2], oemtable->oem_signature[3]); 201 oemtable->signature[2], oemtable->signature[3]);
203 return; 202 return;
204 } 203 }
205 if (mpf_checksum((unsigned char *)oemtable, oemtable->oem_length)) { 204 if (mpf_checksum((unsigned char *)oemtable, oemtable->length)) {
206 printk(KERN_WARNING "SMP oem mptable: checksum error!\n"); 205 printk(KERN_WARNING "SMP oem mptable: checksum error!\n");
207 return; 206 return;
208 } 207 }
209 while (count < oemtable->oem_length) { 208 while (count < oemtable->length) {
210 switch (*oemptr) { 209 switch (*oemptr) {
211 case MP_TRANSLATION: 210 case MP_TRANSLATION:
212 { 211 {
@@ -260,8 +259,7 @@ static struct x86_quirks numaq_x86_quirks __initdata = {
260 .update_genapic = numaq_update_genapic, 259 .update_genapic = numaq_update_genapic,
261}; 260};
262 261
263void numaq_mps_oem_check(struct mp_config_table *mpc, char *oem, 262void numaq_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
264 char *productid)
265{ 263{
266 if (strncmp(oem, "IBM NUMA", 8)) 264 if (strncmp(oem, "IBM NUMA", 8))
267 printk("Warning! Not a NUMA-Q system!\n"); 265 printk("Warning! Not a NUMA-Q system!\n");
diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index 242c3440687f..8cba3749a511 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -13,7 +13,7 @@
13 13
14int swiotlb __read_mostly; 14int swiotlb __read_mostly;
15 15
16void *swiotlb_alloc_boot(size_t size, unsigned long nslabs) 16void * __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
17{ 17{
18 return alloc_bootmem_low_pages(size); 18 return alloc_bootmem_low_pages(size);
19} 19}
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 3ba155d24884..a546f55c77b4 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -39,11 +39,12 @@
39#include <linux/prctl.h> 39#include <linux/prctl.h>
40#include <linux/dmi.h> 40#include <linux/dmi.h>
41#include <linux/ftrace.h> 41#include <linux/ftrace.h>
42#include <linux/uaccess.h>
43#include <linux/io.h>
44#include <linux/kdebug.h>
42 45
43#include <asm/uaccess.h>
44#include <asm/pgtable.h> 46#include <asm/pgtable.h>
45#include <asm/system.h> 47#include <asm/system.h>
46#include <asm/io.h>
47#include <asm/ldt.h> 48#include <asm/ldt.h>
48#include <asm/processor.h> 49#include <asm/processor.h>
49#include <asm/i387.h> 50#include <asm/i387.h>
@@ -56,10 +57,8 @@
56 57
57#include <asm/tlbflush.h> 58#include <asm/tlbflush.h>
58#include <asm/cpu.h> 59#include <asm/cpu.h>
59#include <asm/kdebug.h>
60#include <asm/idle.h> 60#include <asm/idle.h>
61#include <asm/syscalls.h> 61#include <asm/syscalls.h>
62#include <asm/smp.h>
63#include <asm/ds.h> 62#include <asm/ds.h>
64 63
65asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 64asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
@@ -205,7 +204,7 @@ extern void kernel_thread_helper(void);
205/* 204/*
206 * Create a kernel thread 205 * Create a kernel thread
207 */ 206 */
208int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) 207int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
209{ 208{
210 struct pt_regs regs; 209 struct pt_regs regs;
211 210
@@ -266,7 +265,7 @@ void flush_thread(void)
266 tsk->thread.debugreg3 = 0; 265 tsk->thread.debugreg3 = 0;
267 tsk->thread.debugreg6 = 0; 266 tsk->thread.debugreg6 = 0;
268 tsk->thread.debugreg7 = 0; 267 tsk->thread.debugreg7 = 0;
269 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array)); 268 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
270 clear_tsk_thread_flag(tsk, TIF_DEBUG); 269 clear_tsk_thread_flag(tsk, TIF_DEBUG);
271 /* 270 /*
272 * Forget coprocessor state.. 271 * Forget coprocessor state..
@@ -293,9 +292,9 @@ void prepare_to_copy(struct task_struct *tsk)
293 292
294int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, 293int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
295 unsigned long unused, 294 unsigned long unused,
296 struct task_struct * p, struct pt_regs * regs) 295 struct task_struct *p, struct pt_regs *regs)
297{ 296{
298 struct pt_regs * childregs; 297 struct pt_regs *childregs;
299 struct task_struct *tsk; 298 struct task_struct *tsk;
300 int err; 299 int err;
301 300
@@ -347,7 +346,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
347void 346void
348start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp) 347start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
349{ 348{
350 __asm__("movl %0, %%gs" :: "r"(0)); 349 __asm__("movl %0, %%gs" : : "r"(0));
351 regs->fs = 0; 350 regs->fs = 0;
352 set_fs(USER_DS); 351 set_fs(USER_DS);
353 regs->ds = __USER_DS; 352 regs->ds = __USER_DS;
@@ -638,7 +637,7 @@ asmlinkage int sys_vfork(struct pt_regs regs)
638asmlinkage int sys_execve(struct pt_regs regs) 637asmlinkage int sys_execve(struct pt_regs regs)
639{ 638{
640 int error; 639 int error;
641 char * filename; 640 char *filename;
642 641
643 filename = getname((char __user *) regs.bx); 642 filename = getname((char __user *) regs.bx);
644 error = PTR_ERR(filename); 643 error = PTR_ERR(filename);
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index bf088c61fa40..2b46eb41643b 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -501,7 +501,7 @@ void native_machine_shutdown(void)
501 501
502#ifdef CONFIG_X86_32 502#ifdef CONFIG_X86_32
503 /* See if there has been given a command line override */ 503 /* See if there has been given a command line override */
504 if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) && 504 if ((reboot_cpu != -1) && (reboot_cpu < nr_cpu_ids) &&
505 cpu_online(reboot_cpu)) 505 cpu_online(reboot_cpu))
506 reboot_cpu_id = reboot_cpu; 506 reboot_cpu_id = reboot_cpu;
507#endif 507#endif
@@ -511,7 +511,7 @@ void native_machine_shutdown(void)
511 reboot_cpu_id = smp_processor_id(); 511 reboot_cpu_id = smp_processor_id();
512 512
513 /* Make certain I only run on the appropriate processor */ 513 /* Make certain I only run on the appropriate processor */
514 set_cpus_allowed_ptr(current, &cpumask_of_cpu(reboot_cpu_id)); 514 set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));
515 515
516 /* O.K Now that I'm on the appropriate processor, 516 /* O.K Now that I'm on the appropriate processor,
517 * stop all of the others. 517 * stop all of the others.
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 0b63b08e7530..e4433bf44209 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -5,12 +5,11 @@
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/kexec.h> 6#include <linux/kexec.h>
7#include <linux/crash_dump.h> 7#include <linux/crash_dump.h>
8#include <asm/smp.h> 8#include <linux/smp.h>
9#include <asm/percpu.h> 9#include <linux/topology.h>
10#include <asm/sections.h> 10#include <asm/sections.h>
11#include <asm/processor.h> 11#include <asm/processor.h>
12#include <asm/setup.h> 12#include <asm/setup.h>
13#include <asm/topology.h>
14#include <asm/mpspec.h> 13#include <asm/mpspec.h>
15#include <asm/apicdef.h> 14#include <asm/apicdef.h>
16#include <asm/highmem.h> 15#include <asm/highmem.h>
@@ -20,8 +19,8 @@ unsigned int num_processors;
20unsigned disabled_cpus __cpuinitdata; 19unsigned disabled_cpus __cpuinitdata;
21/* Processor that is doing the boot up */ 20/* Processor that is doing the boot up */
22unsigned int boot_cpu_physical_apicid = -1U; 21unsigned int boot_cpu_physical_apicid = -1U;
23unsigned int max_physical_apicid;
24EXPORT_SYMBOL(boot_cpu_physical_apicid); 22EXPORT_SYMBOL(boot_cpu_physical_apicid);
23unsigned int max_physical_apicid;
25 24
26/* Bitmask of physically existing CPUs */ 25/* Bitmask of physically existing CPUs */
27physid_mask_t phys_cpu_present_map; 26physid_mask_t phys_cpu_present_map;
@@ -153,12 +152,10 @@ void __init setup_per_cpu_areas(void)
153 align = max_t(unsigned long, PAGE_SIZE, align); 152 align = max_t(unsigned long, PAGE_SIZE, align);
154 size = roundup(old_size, align); 153 size = roundup(old_size, align);
155 154
156 printk(KERN_INFO 155 pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n",
157 "NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n",
158 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); 156 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
159 157
160 printk(KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n", 158 pr_info("PERCPU: Allocating %zd bytes of per cpu data\n", size);
161 size);
162 159
163 for_each_possible_cpu(cpu) { 160 for_each_possible_cpu(cpu) {
164#ifndef CONFIG_NEED_MULTIPLE_NODES 161#ifndef CONFIG_NEED_MULTIPLE_NODES
@@ -169,22 +166,15 @@ void __init setup_per_cpu_areas(void)
169 if (!node_online(node) || !NODE_DATA(node)) { 166 if (!node_online(node) || !NODE_DATA(node)) {
170 ptr = __alloc_bootmem(size, align, 167 ptr = __alloc_bootmem(size, align,
171 __pa(MAX_DMA_ADDRESS)); 168 __pa(MAX_DMA_ADDRESS));
172 printk(KERN_INFO 169 pr_info("cpu %d has no node %d or node-local memory\n",
173 "cpu %d has no node %d or node-local memory\n",
174 cpu, node); 170 cpu, node);
175 if (ptr) 171 pr_debug("per cpu data for cpu%d at %016lx\n",
176 printk(KERN_DEBUG 172 cpu, __pa(ptr));
177 "per cpu data for cpu%d at %016lx\n", 173 } else {
178 cpu, __pa(ptr));
179 }
180 else {
181 ptr = __alloc_bootmem_node(NODE_DATA(node), size, align, 174 ptr = __alloc_bootmem_node(NODE_DATA(node), size, align,
182 __pa(MAX_DMA_ADDRESS)); 175 __pa(MAX_DMA_ADDRESS));
183 if (ptr) 176 pr_debug("per cpu data for cpu%d on node%d at %016lx\n",
184 printk(KERN_DEBUG 177 cpu, node, __pa(ptr));
185 "per cpu data for cpu%d on node%d "
186 "at %016lx\n",
187 cpu, node, __pa(ptr));
188 } 178 }
189#endif 179#endif
190 per_cpu_offset(cpu) = ptr - __per_cpu_start; 180 per_cpu_offset(cpu) = ptr - __per_cpu_start;
@@ -289,8 +279,8 @@ static void __cpuinit numa_set_cpumask(int cpu, int enable)
289 279
290 cpulist_scnprintf(buf, sizeof(buf), mask); 280 cpulist_scnprintf(buf, sizeof(buf), mask);
291 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n", 281 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",
292 enable? "numa_add_cpu":"numa_remove_cpu", cpu, node, buf); 282 enable ? "numa_add_cpu" : "numa_remove_cpu", cpu, node, buf);
293 } 283}
294 284
295void __cpuinit numa_add_cpu(int cpu) 285void __cpuinit numa_add_cpu(int cpu)
296{ 286{
@@ -339,25 +329,25 @@ static const cpumask_t cpu_mask_none;
339/* 329/*
340 * Returns a pointer to the bitmask of CPUs on Node 'node'. 330 * Returns a pointer to the bitmask of CPUs on Node 'node'.
341 */ 331 */
342const cpumask_t *_node_to_cpumask_ptr(int node) 332const cpumask_t *cpumask_of_node(int node)
343{ 333{
344 if (node_to_cpumask_map == NULL) { 334 if (node_to_cpumask_map == NULL) {
345 printk(KERN_WARNING 335 printk(KERN_WARNING
346 "_node_to_cpumask_ptr(%d): no node_to_cpumask_map!\n", 336 "cpumask_of_node(%d): no node_to_cpumask_map!\n",
347 node); 337 node);
348 dump_stack(); 338 dump_stack();
349 return (const cpumask_t *)&cpu_online_map; 339 return (const cpumask_t *)&cpu_online_map;
350 } 340 }
351 if (node >= nr_node_ids) { 341 if (node >= nr_node_ids) {
352 printk(KERN_WARNING 342 printk(KERN_WARNING
353 "_node_to_cpumask_ptr(%d): node > nr_node_ids(%d)\n", 343 "cpumask_of_node(%d): node > nr_node_ids(%d)\n",
354 node, nr_node_ids); 344 node, nr_node_ids);
355 dump_stack(); 345 dump_stack();
356 return &cpu_mask_none; 346 return &cpu_mask_none;
357 } 347 }
358 return &node_to_cpumask_map[node]; 348 return &node_to_cpumask_map[node];
359} 349}
360EXPORT_SYMBOL(_node_to_cpumask_ptr); 350EXPORT_SYMBOL(cpumask_of_node);
361 351
362/* 352/*
363 * Returns a bitmask of CPUs on Node 'node'. 353 * Returns a bitmask of CPUs on Node 'node'.
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index c628f9178cd8..07576bee03ef 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -496,7 +496,7 @@ void __cpuinit set_cpu_sibling_map(int cpu)
496} 496}
497 497
498/* maps the cpu to the sched domain representing multi-core */ 498/* maps the cpu to the sched domain representing multi-core */
499cpumask_t cpu_coregroup_map(int cpu) 499const struct cpumask *cpu_coregroup_mask(int cpu)
500{ 500{
501 struct cpuinfo_x86 *c = &cpu_data(cpu); 501 struct cpuinfo_x86 *c = &cpu_data(cpu);
502 /* 502 /*
@@ -504,9 +504,14 @@ cpumask_t cpu_coregroup_map(int cpu)
504 * And for power savings, we return cpu_core_map 504 * And for power savings, we return cpu_core_map
505 */ 505 */
506 if (sched_mc_power_savings || sched_smt_power_savings) 506 if (sched_mc_power_savings || sched_smt_power_savings)
507 return per_cpu(cpu_core_map, cpu); 507 return &per_cpu(cpu_core_map, cpu);
508 else 508 else
509 return c->llc_shared_map; 509 return &c->llc_shared_map;
510}
511
512cpumask_t cpu_coregroup_map(int cpu)
513{
514 return *cpu_coregroup_mask(cpu);
510} 515}
511 516
512static void impress_friends(void) 517static void impress_friends(void)
@@ -1149,7 +1154,7 @@ static void __init smp_cpu_index_default(void)
1149 for_each_possible_cpu(i) { 1154 for_each_possible_cpu(i) {
1150 c = &cpu_data(i); 1155 c = &cpu_data(i);
1151 /* mark all to hotplug */ 1156 /* mark all to hotplug */
1152 c->cpu_index = NR_CPUS; 1157 c->cpu_index = nr_cpu_ids;
1153 } 1158 }
1154} 1159}
1155 1160
@@ -1293,6 +1298,8 @@ __init void prefill_possible_map(void)
1293 else 1298 else
1294 possible = setup_possible_cpus; 1299 possible = setup_possible_cpus;
1295 1300
1301 total_cpus = max_t(int, possible, num_processors + disabled_cpus);
1302
1296 if (possible > CONFIG_NR_CPUS) { 1303 if (possible > CONFIG_NR_CPUS) {
1297 printk(KERN_WARNING 1304 printk(KERN_WARNING
1298 "%d Processors exceeds NR_CPUS limit of %d\n", 1305 "%d Processors exceeds NR_CPUS limit of %d\n",
diff --git a/arch/x86/kernel/time_32.c b/arch/x86/kernel/time_32.c
index 65309e4cb1c0..3985cac0ed47 100644
--- a/arch/x86/kernel/time_32.c
+++ b/arch/x86/kernel/time_32.c
@@ -105,8 +105,8 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
105 high bit of the PPI port B (0x61). Note that some PS/2s, 105 high bit of the PPI port B (0x61). Note that some PS/2s,
106 notably the 55SX, work fine if this is removed. */ 106 notably the 55SX, work fine if this is removed. */
107 107
108 u8 irq_v = inb_p( 0x61 ); /* read the current state */ 108 u8 irq_v = inb_p(0x61); /* read the current state */
109 outb_p( irq_v|0x80, 0x61 ); /* reset the IRQ */ 109 outb_p(irq_v | 0x80, 0x61); /* reset the IRQ */
110 } 110 }
111#endif 111#endif
112 112
diff --git a/arch/x86/kernel/time_64.c b/arch/x86/kernel/time_64.c
index 891e7a7c4334..e6e695acd725 100644
--- a/arch/x86/kernel/time_64.c
+++ b/arch/x86/kernel/time_64.c
@@ -17,10 +17,10 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/time.h> 18#include <linux/time.h>
19#include <linux/mca.h> 19#include <linux/mca.h>
20#include <linux/nmi.h>
20 21
21#include <asm/i8253.h> 22#include <asm/i8253.h>
22#include <asm/hpet.h> 23#include <asm/hpet.h>
23#include <asm/nmi.h>
24#include <asm/vgtod.h> 24#include <asm/vgtod.h>
25#include <asm/time.h> 25#include <asm/time.h>
26#include <asm/timer.h> 26#include <asm/timer.h>
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index ce6650eb64e9..25d5c3073582 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -65,9 +65,6 @@
65#else 65#else
66#include <asm/processor-flags.h> 66#include <asm/processor-flags.h>
67#include <asm/arch_hooks.h> 67#include <asm/arch_hooks.h>
68#include <asm/nmi.h>
69#include <asm/smp.h>
70#include <asm/io.h>
71#include <asm/traps.h> 68#include <asm/traps.h>
72 69
73#include "cpu/mcheck/mce.h" 70#include "cpu/mcheck/mce.h"
diff --git a/arch/x86/kernel/visws_quirks.c b/arch/x86/kernel/visws_quirks.c
index 0c9667f0752a..d801d06af068 100644
--- a/arch/x86/kernel/visws_quirks.c
+++ b/arch/x86/kernel/visws_quirks.c
@@ -176,33 +176,31 @@ static int __init visws_get_smp_config(unsigned int early)
176 * No problem for Linux. 176 * No problem for Linux.
177 */ 177 */
178 178
179static void __init MP_processor_info(struct mpc_config_processor *m) 179static void __init MP_processor_info(struct mpc_cpu *m)
180{ 180{
181 int ver, logical_apicid; 181 int ver, logical_apicid;
182 physid_mask_t apic_cpus; 182 physid_mask_t apic_cpus;
183 183
184 if (!(m->mpc_cpuflag & CPU_ENABLED)) 184 if (!(m->cpuflag & CPU_ENABLED))
185 return; 185 return;
186 186
187 logical_apicid = m->mpc_apicid; 187 logical_apicid = m->apicid;
188 printk(KERN_INFO "%sCPU #%d %u:%u APIC version %d\n", 188 printk(KERN_INFO "%sCPU #%d %u:%u APIC version %d\n",
189 m->mpc_cpuflag & CPU_BOOTPROCESSOR ? "Bootup " : "", 189 m->cpuflag & CPU_BOOTPROCESSOR ? "Bootup " : "",
190 m->mpc_apicid, 190 m->apicid, (m->cpufeature & CPU_FAMILY_MASK) >> 8,
191 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 191 (m->cpufeature & CPU_MODEL_MASK) >> 4, m->apicver);
192 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
193 m->mpc_apicver);
194 192
195 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) 193 if (m->cpuflag & CPU_BOOTPROCESSOR)
196 boot_cpu_physical_apicid = m->mpc_apicid; 194 boot_cpu_physical_apicid = m->apicid;
197 195
198 ver = m->mpc_apicver; 196 ver = m->apicver;
199 if ((ver >= 0x14 && m->mpc_apicid >= 0xff) || m->mpc_apicid >= 0xf) { 197 if ((ver >= 0x14 && m->apicid >= 0xff) || m->apicid >= 0xf) {
200 printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n", 198 printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n",
201 m->mpc_apicid, MAX_APICS); 199 m->apicid, MAX_APICS);
202 return; 200 return;
203 } 201 }
204 202
205 apic_cpus = apicid_to_cpu_present(m->mpc_apicid); 203 apic_cpus = apicid_to_cpu_present(m->apicid);
206 physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus); 204 physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus);
207 /* 205 /*
208 * Validate version 206 * Validate version
@@ -210,15 +208,15 @@ static void __init MP_processor_info(struct mpc_config_processor *m)
210 if (ver == 0x0) { 208 if (ver == 0x0) {
211 printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! " 209 printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! "
212 "fixing up to 0x10. (tell your hw vendor)\n", 210 "fixing up to 0x10. (tell your hw vendor)\n",
213 m->mpc_apicid); 211 m->apicid);
214 ver = 0x10; 212 ver = 0x10;
215 } 213 }
216 apic_version[m->mpc_apicid] = ver; 214 apic_version[m->apicid] = ver;
217} 215}
218 216
219static int __init visws_find_smp_config(unsigned int reserve) 217static int __init visws_find_smp_config(unsigned int reserve)
220{ 218{
221 struct mpc_config_processor *mp = phys_to_virt(CO_CPU_TAB_PHYS); 219 struct mpc_cpu *mp = phys_to_virt(CO_CPU_TAB_PHYS);
222 unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS)); 220 unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS));
223 221
224 if (ncpus > CO_CPU_MAX) { 222 if (ncpus > CO_CPU_MAX) {
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index c02343594b4d..d3ec292f00f2 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -7,8 +7,8 @@ common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
7ifeq ($(CONFIG_KVM_TRACE),y) 7ifeq ($(CONFIG_KVM_TRACE),y)
8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) 8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o)
9endif 9endif
10ifeq ($(CONFIG_DMAR),y) 10ifeq ($(CONFIG_IOMMU_API),y)
11common-objs += $(addprefix ../../../virt/kvm/, vtd.o) 11common-objs += $(addprefix ../../../virt/kvm/, iommu.o)
12endif 12endif
13 13
14EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm 14EXTRA_CFLAGS += -Ivirt/kvm -Iarch/x86/kvm
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0e6aa8141dcd..cc17546a2406 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/mman.h> 35#include <linux/mman.h>
36#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include <linux/iommu.h>
37#include <linux/intel-iommu.h> 38#include <linux/intel-iommu.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
@@ -989,7 +990,7 @@ int kvm_dev_ioctl_check_extension(long ext)
989 r = !tdp_enabled; 990 r = !tdp_enabled;
990 break; 991 break;
991 case KVM_CAP_IOMMU: 992 case KVM_CAP_IOMMU:
992 r = intel_iommu_found(); 993 r = iommu_found();
993 break; 994 break;
994 default: 995 default:
995 r = 0; 996 r = 0;
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c
index 4ba5ccaa1584..c2ded1448024 100644
--- a/arch/x86/mach-generic/es7000.c
+++ b/arch/x86/mach-generic/es7000.c
@@ -43,12 +43,12 @@ static void __init enable_apic_mode(void)
43 return; 43 return;
44} 44}
45 45
46static __init int mps_oem_check(struct mp_config_table *mpc, char *oem, 46static __init int
47 char *productid) 47mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
48{ 48{
49 if (mpc->mpc_oemptr) { 49 if (mpc->oemptr) {
50 struct mp_config_oemtable *oem_table = 50 struct mpc_oemtable *oem_table =
51 (struct mp_config_oemtable *)mpc->mpc_oemptr; 51 (struct mpc_oemtable *)mpc->oemptr;
52 if (!strncmp(oem, "UNISYS", 6)) 52 if (!strncmp(oem, "UNISYS", 6))
53 return parse_unisys_oem((char *)oem_table); 53 return parse_unisys_oem((char *)oem_table);
54 } 54 }
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c
index 511d7941364f..3679e2255645 100644
--- a/arch/x86/mach-generic/numaq.c
+++ b/arch/x86/mach-generic/numaq.c
@@ -19,8 +19,7 @@
19#include <asm/numaq/wakecpu.h> 19#include <asm/numaq/wakecpu.h>
20#include <asm/numaq.h> 20#include <asm/numaq.h>
21 21
22static int mps_oem_check(struct mp_config_table *mpc, char *oem, 22static int mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
23 char *productid)
24{ 23{
25 numaq_mps_oem_check(mpc, oem, productid); 24 numaq_mps_oem_check(mpc, oem, productid);
26 return found_numaq; 25 return found_numaq;
diff --git a/arch/x86/mach-generic/probe.c b/arch/x86/mach-generic/probe.c
index c346d9d0226f..15a38daef1a8 100644
--- a/arch/x86/mach-generic/probe.c
+++ b/arch/x86/mach-generic/probe.c
@@ -110,8 +110,7 @@ void __init generic_apic_probe(void)
110 110
111/* These functions can switch the APIC even after the initial ->probe() */ 111/* These functions can switch the APIC even after the initial ->probe() */
112 112
113int __init mps_oem_check(struct mp_config_table *mpc, char *oem, 113int __init mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
114 char *productid)
115{ 114{
116 int i; 115 int i;
117 for (i = 0; apic_probe[i]; ++i) { 116 for (i = 0; apic_probe[i]; ++i) {
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index a5bc05492b1e..9840b7ec749a 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -357,9 +357,8 @@ void __init find_smp_config(void)
357 printk("VOYAGER SMP: Boot cpu is %d\n", boot_cpu_id); 357 printk("VOYAGER SMP: Boot cpu is %d\n", boot_cpu_id);
358 358
359 /* initialize the CPU structures (moved from smp_boot_cpus) */ 359 /* initialize the CPU structures (moved from smp_boot_cpus) */
360 for (i = 0; i < NR_CPUS; i++) { 360 for (i = 0; i < nr_cpu_ids; i++)
361 cpu_irq_affinity[i] = ~0; 361 cpu_irq_affinity[i] = ~0;
362 }
363 cpu_online_map = cpumask_of_cpu(boot_cpu_id); 362 cpu_online_map = cpumask_of_cpu(boot_cpu_id);
364 363
365 /* The boot CPU must be extended */ 364 /* The boot CPU must be extended */
@@ -1227,7 +1226,7 @@ int setup_profiling_timer(unsigned int multiplier)
1227 * new values until the next timer interrupt in which they do process 1226 * new values until the next timer interrupt in which they do process
1228 * accounting. 1227 * accounting.
1229 */ 1228 */
1230 for (i = 0; i < NR_CPUS; ++i) 1229 for (i = 0; i < nr_cpu_ids; ++i)
1231 per_cpu(prof_multiplier, i) = multiplier; 1230 per_cpu(prof_multiplier, i) = multiplier;
1232 1231
1233 return 0; 1232 return 0;
@@ -1257,7 +1256,7 @@ void __init voyager_smp_intr_init(void)
1257 int i; 1256 int i;
1258 1257
1259 /* initialize the per cpu irq mask to all disabled */ 1258 /* initialize the per cpu irq mask to all disabled */
1260 for (i = 0; i < NR_CPUS; i++) 1259 for (i = 0; i < nr_cpu_ids; i++)
1261 vic_irq_mask[i] = 0xFFFF; 1260 vic_irq_mask[i] = 0xFFFF;
1262 1261
1263 VIC_SET_GATE(VIC_CPI_LEVEL0, vic_cpi_interrupt); 1262 VIC_SET_GATE(VIC_CPI_LEVEL0, vic_cpi_interrupt);
diff --git a/arch/x86/mm/k8topology_64.c b/arch/x86/mm/k8topology_64.c
index 41f1b5c00a1d..268f8255280f 100644
--- a/arch/x86/mm/k8topology_64.c
+++ b/arch/x86/mm/k8topology_64.c
@@ -81,7 +81,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
81 unsigned numnodes, cores, bits, apicid_base; 81 unsigned numnodes, cores, bits, apicid_base;
82 unsigned long prevbase; 82 unsigned long prevbase;
83 struct bootnode nodes[8]; 83 struct bootnode nodes[8];
84 unsigned char nodeids[8];
85 int i, j, nb, found = 0; 84 int i, j, nb, found = 0;
86 u32 nodeid, reg; 85 u32 nodeid, reg;
87 86
@@ -110,7 +109,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
110 limit = read_pci_config(0, nb, 1, 0x44 + i*8); 109 limit = read_pci_config(0, nb, 1, 0x44 + i*8);
111 110
112 nodeid = limit & 7; 111 nodeid = limit & 7;
113 nodeids[i] = nodeid;
114 if ((base & 3) == 0) { 112 if ((base & 3) == 0) {
115 if (i < numnodes) 113 if (i < numnodes)
116 printk("Skipping disabled node %d\n", i); 114 printk("Skipping disabled node %d\n", i);
@@ -179,9 +177,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
179 177
180 nodes[nodeid].start = base; 178 nodes[nodeid].start = base;
181 nodes[nodeid].end = limit; 179 nodes[nodeid].end = limit;
182 e820_register_active_regions(nodeid,
183 nodes[nodeid].start >> PAGE_SHIFT,
184 nodes[nodeid].end >> PAGE_SHIFT);
185 180
186 prevbase = base; 181 prevbase = base;
187 182
@@ -211,12 +206,15 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
211 } 206 }
212 207
213 for (i = 0; i < 8; i++) { 208 for (i = 0; i < 8; i++) {
214 if (nodes[i].start != nodes[i].end) { 209 if (nodes[i].start == nodes[i].end)
215 nodeid = nodeids[i]; 210 continue;
216 for (j = apicid_base; j < cores + apicid_base; j++) 211
217 apicid_to_node[(nodeid << bits) + j] = i; 212 e820_register_active_regions(i,
218 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 213 nodes[i].start >> PAGE_SHIFT,
219 } 214 nodes[i].end >> PAGE_SHIFT);
215 for (j = apicid_base; j < cores + apicid_base; j++)
216 apicid_to_node[(i << bits) + j] = i;
217 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
220 } 218 }
221 219
222 numa_init_array(); 220 numa_init_array();
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 65d75a6be0ba..14f240623497 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -132,8 +132,7 @@ static void do_stolen_accounting(void)
132 *snap = state; 132 *snap = state;
133 133
134 /* Add the appropriate number of ticks of stolen time, 134 /* Add the appropriate number of ticks of stolen time,
135 including any left-overs from last time. Passing NULL to 135 including any left-overs from last time. */
136 account_steal_time accounts the time as stolen. */
137 stolen = runnable + offline + __get_cpu_var(residual_stolen); 136 stolen = runnable + offline + __get_cpu_var(residual_stolen);
138 137
139 if (stolen < 0) 138 if (stolen < 0)
@@ -141,11 +140,10 @@ static void do_stolen_accounting(void)
141 140
142 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen); 141 ticks = iter_div_u64_rem(stolen, NS_PER_TICK, &stolen);
143 __get_cpu_var(residual_stolen) = stolen; 142 __get_cpu_var(residual_stolen) = stolen;
144 account_steal_time(NULL, ticks); 143 account_steal_ticks(ticks);
145 144
146 /* Add the appropriate number of ticks of blocked time, 145 /* Add the appropriate number of ticks of blocked time,
147 including any left-overs from last time. Passing idle to 146 including any left-overs from last time. */
148 account_steal_time accounts the time as idle/wait. */
149 blocked += __get_cpu_var(residual_blocked); 147 blocked += __get_cpu_var(residual_blocked);
150 148
151 if (blocked < 0) 149 if (blocked < 0)
@@ -153,7 +151,7 @@ static void do_stolen_accounting(void)
153 151
154 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked); 152 ticks = iter_div_u64_rem(blocked, NS_PER_TICK, &blocked);
155 __get_cpu_var(residual_blocked) = blocked; 153 __get_cpu_var(residual_blocked) = blocked;
156 account_steal_time(idle_task(smp_processor_id()), ticks); 154 account_idle_ticks(ticks);
157} 155}
158 156
159/* 157/*
diff --git a/block/blk.h b/block/blk.h
index d2e49af90db5..6e1ed40534e9 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -99,8 +99,8 @@ static inline int queue_congestion_off_threshold(struct request_queue *q)
99static inline int blk_cpu_to_group(int cpu) 99static inline int blk_cpu_to_group(int cpu)
100{ 100{
101#ifdef CONFIG_SCHED_MC 101#ifdef CONFIG_SCHED_MC
102 cpumask_t mask = cpu_coregroup_map(cpu); 102 const struct cpumask *mask = cpu_coregroup_mask(cpu);
103 return first_cpu(mask); 103 return cpumask_first(mask);
104#elif defined(CONFIG_SCHED_SMT) 104#elif defined(CONFIG_SCHED_SMT)
105 return first_cpu(per_cpu(cpu_sibling_map, cpu)); 105 return first_cpu(per_cpu(cpu_sibling_map, cpu));
106#else 106#else
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 34948362f41d..0cc2fd31e376 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -826,6 +826,11 @@ static int acpi_processor_add(struct acpi_device *device)
826 if (!pr) 826 if (!pr)
827 return -ENOMEM; 827 return -ENOMEM;
828 828
829 if (!alloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
830 kfree(pr);
831 return -ENOMEM;
832 }
833
829 pr->handle = device->handle; 834 pr->handle = device->handle;
830 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); 835 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
831 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); 836 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
@@ -845,10 +850,8 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
845 850
846 pr = acpi_driver_data(device); 851 pr = acpi_driver_data(device);
847 852
848 if (pr->id >= nr_cpu_ids) { 853 if (pr->id >= nr_cpu_ids)
849 kfree(pr); 854 goto free;
850 return 0;
851 }
852 855
853 if (type == ACPI_BUS_REMOVAL_EJECT) { 856 if (type == ACPI_BUS_REMOVAL_EJECT) {
854 if (acpi_processor_handle_eject(pr)) 857 if (acpi_processor_handle_eject(pr))
@@ -873,6 +876,9 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
873 876
874 per_cpu(processors, pr->id) = NULL; 877 per_cpu(processors, pr->id) = NULL;
875 per_cpu(processor_device_array, pr->id) = NULL; 878 per_cpu(processor_device_array, pr->id) = NULL;
879
880free:
881 free_cpumask_var(pr->throttling.shared_cpu_map);
876 kfree(pr); 882 kfree(pr);
877 883
878 return 0; 884 return 0;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 0d7b772bef50..846e227592d4 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -588,12 +588,15 @@ int acpi_processor_preregister_performance(
588 int count, count_target; 588 int count, count_target;
589 int retval = 0; 589 int retval = 0;
590 unsigned int i, j; 590 unsigned int i, j;
591 cpumask_t covered_cpus; 591 cpumask_var_t covered_cpus;
592 struct acpi_processor *pr; 592 struct acpi_processor *pr;
593 struct acpi_psd_package *pdomain; 593 struct acpi_psd_package *pdomain;
594 struct acpi_processor *match_pr; 594 struct acpi_processor *match_pr;
595 struct acpi_psd_package *match_pdomain; 595 struct acpi_psd_package *match_pdomain;
596 596
597 if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))
598 return -ENOMEM;
599
597 mutex_lock(&performance_mutex); 600 mutex_lock(&performance_mutex);
598 601
599 retval = 0; 602 retval = 0;
@@ -617,7 +620,7 @@ int acpi_processor_preregister_performance(
617 } 620 }
618 621
619 pr->performance = percpu_ptr(performance, i); 622 pr->performance = percpu_ptr(performance, i);
620 cpu_set(i, pr->performance->shared_cpu_map); 623 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
621 if (acpi_processor_get_psd(pr)) { 624 if (acpi_processor_get_psd(pr)) {
622 retval = -EINVAL; 625 retval = -EINVAL;
623 continue; 626 continue;
@@ -650,18 +653,18 @@ int acpi_processor_preregister_performance(
650 } 653 }
651 } 654 }
652 655
653 cpus_clear(covered_cpus); 656 cpumask_clear(covered_cpus);
654 for_each_possible_cpu(i) { 657 for_each_possible_cpu(i) {
655 pr = per_cpu(processors, i); 658 pr = per_cpu(processors, i);
656 if (!pr) 659 if (!pr)
657 continue; 660 continue;
658 661
659 if (cpu_isset(i, covered_cpus)) 662 if (cpumask_test_cpu(i, covered_cpus))
660 continue; 663 continue;
661 664
662 pdomain = &(pr->performance->domain_info); 665 pdomain = &(pr->performance->domain_info);
663 cpu_set(i, pr->performance->shared_cpu_map); 666 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
664 cpu_set(i, covered_cpus); 667 cpumask_set_cpu(i, covered_cpus);
665 if (pdomain->num_processors <= 1) 668 if (pdomain->num_processors <= 1)
666 continue; 669 continue;
667 670
@@ -699,8 +702,8 @@ int acpi_processor_preregister_performance(
699 goto err_ret; 702 goto err_ret;
700 } 703 }
701 704
702 cpu_set(j, covered_cpus); 705 cpumask_set_cpu(j, covered_cpus);
703 cpu_set(j, pr->performance->shared_cpu_map); 706 cpumask_set_cpu(j, pr->performance->shared_cpu_map);
704 count++; 707 count++;
705 } 708 }
706 709
@@ -718,8 +721,8 @@ int acpi_processor_preregister_performance(
718 721
719 match_pr->performance->shared_type = 722 match_pr->performance->shared_type =
720 pr->performance->shared_type; 723 pr->performance->shared_type;
721 match_pr->performance->shared_cpu_map = 724 cpumask_copy(match_pr->performance->shared_cpu_map,
722 pr->performance->shared_cpu_map; 725 pr->performance->shared_cpu_map);
723 } 726 }
724 } 727 }
725 728
@@ -731,14 +734,15 @@ err_ret:
731 734
732 /* Assume no coordination on any error parsing domain info */ 735 /* Assume no coordination on any error parsing domain info */
733 if (retval) { 736 if (retval) {
734 cpus_clear(pr->performance->shared_cpu_map); 737 cpumask_clear(pr->performance->shared_cpu_map);
735 cpu_set(i, pr->performance->shared_cpu_map); 738 cpumask_set_cpu(i, pr->performance->shared_cpu_map);
736 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; 739 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
737 } 740 }
738 pr->performance = NULL; /* Will be set for real in register */ 741 pr->performance = NULL; /* Will be set for real in register */
739 } 742 }
740 743
741 mutex_unlock(&performance_mutex); 744 mutex_unlock(&performance_mutex);
745 free_cpumask_var(covered_cpus);
742 return retval; 746 return retval;
743} 747}
744EXPORT_SYMBOL(acpi_processor_preregister_performance); 748EXPORT_SYMBOL(acpi_processor_preregister_performance);
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index a0c38c94a8a0..d27838171f4a 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -61,11 +61,14 @@ static int acpi_processor_update_tsd_coord(void)
61 int count, count_target; 61 int count, count_target;
62 int retval = 0; 62 int retval = 0;
63 unsigned int i, j; 63 unsigned int i, j;
64 cpumask_t covered_cpus; 64 cpumask_var_t covered_cpus;
65 struct acpi_processor *pr, *match_pr; 65 struct acpi_processor *pr, *match_pr;
66 struct acpi_tsd_package *pdomain, *match_pdomain; 66 struct acpi_tsd_package *pdomain, *match_pdomain;
67 struct acpi_processor_throttling *pthrottling, *match_pthrottling; 67 struct acpi_processor_throttling *pthrottling, *match_pthrottling;
68 68
69 if (!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))
70 return -ENOMEM;
71
69 /* 72 /*
70 * Now that we have _TSD data from all CPUs, lets setup T-state 73 * Now that we have _TSD data from all CPUs, lets setup T-state
71 * coordination between all CPUs. 74 * coordination between all CPUs.
@@ -91,19 +94,19 @@ static int acpi_processor_update_tsd_coord(void)
91 if (retval) 94 if (retval)
92 goto err_ret; 95 goto err_ret;
93 96
94 cpus_clear(covered_cpus); 97 cpumask_clear(covered_cpus);
95 for_each_possible_cpu(i) { 98 for_each_possible_cpu(i) {
96 pr = per_cpu(processors, i); 99 pr = per_cpu(processors, i);
97 if (!pr) 100 if (!pr)
98 continue; 101 continue;
99 102
100 if (cpu_isset(i, covered_cpus)) 103 if (cpumask_test_cpu(i, covered_cpus))
101 continue; 104 continue;
102 pthrottling = &pr->throttling; 105 pthrottling = &pr->throttling;
103 106
104 pdomain = &(pthrottling->domain_info); 107 pdomain = &(pthrottling->domain_info);
105 cpu_set(i, pthrottling->shared_cpu_map); 108 cpumask_set_cpu(i, pthrottling->shared_cpu_map);
106 cpu_set(i, covered_cpus); 109 cpumask_set_cpu(i, covered_cpus);
107 /* 110 /*
108 * If the number of processor in the TSD domain is 1, it is 111 * If the number of processor in the TSD domain is 1, it is
109 * unnecessary to parse the coordination for this CPU. 112 * unnecessary to parse the coordination for this CPU.
@@ -144,8 +147,8 @@ static int acpi_processor_update_tsd_coord(void)
144 goto err_ret; 147 goto err_ret;
145 } 148 }
146 149
147 cpu_set(j, covered_cpus); 150 cpumask_set_cpu(j, covered_cpus);
148 cpu_set(j, pthrottling->shared_cpu_map); 151 cpumask_set_cpu(j, pthrottling->shared_cpu_map);
149 count++; 152 count++;
150 } 153 }
151 for_each_possible_cpu(j) { 154 for_each_possible_cpu(j) {
@@ -165,12 +168,14 @@ static int acpi_processor_update_tsd_coord(void)
165 * If some CPUS have the same domain, they 168 * If some CPUS have the same domain, they
166 * will have the same shared_cpu_map. 169 * will have the same shared_cpu_map.
167 */ 170 */
168 match_pthrottling->shared_cpu_map = 171 cpumask_copy(match_pthrottling->shared_cpu_map,
169 pthrottling->shared_cpu_map; 172 pthrottling->shared_cpu_map);
170 } 173 }
171 } 174 }
172 175
173err_ret: 176err_ret:
177 free_cpumask_var(covered_cpus);
178
174 for_each_possible_cpu(i) { 179 for_each_possible_cpu(i) {
175 pr = per_cpu(processors, i); 180 pr = per_cpu(processors, i);
176 if (!pr) 181 if (!pr)
@@ -182,8 +187,8 @@ err_ret:
182 */ 187 */
183 if (retval) { 188 if (retval) {
184 pthrottling = &(pr->throttling); 189 pthrottling = &(pr->throttling);
185 cpus_clear(pthrottling->shared_cpu_map); 190 cpumask_clear(pthrottling->shared_cpu_map);
186 cpu_set(i, pthrottling->shared_cpu_map); 191 cpumask_set_cpu(i, pthrottling->shared_cpu_map);
187 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; 192 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
188 } 193 }
189 } 194 }
@@ -567,7 +572,7 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
567 pthrottling = &pr->throttling; 572 pthrottling = &pr->throttling;
568 pthrottling->tsd_valid_flag = 1; 573 pthrottling->tsd_valid_flag = 1;
569 pthrottling->shared_type = pdomain->coord_type; 574 pthrottling->shared_type = pdomain->coord_type;
570 cpu_set(pr->id, pthrottling->shared_cpu_map); 575 cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map);
571 /* 576 /*
572 * If the coordination type is not defined in ACPI spec, 577 * If the coordination type is not defined in ACPI spec,
573 * the tsd_valid_flag will be clear and coordination type 578 * the tsd_valid_flag will be clear and coordination type
@@ -826,7 +831,7 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
826 831
827static int acpi_processor_get_throttling(struct acpi_processor *pr) 832static int acpi_processor_get_throttling(struct acpi_processor *pr)
828{ 833{
829 cpumask_t saved_mask; 834 cpumask_var_t saved_mask;
830 int ret; 835 int ret;
831 836
832 if (!pr) 837 if (!pr)
@@ -834,14 +839,20 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
834 839
835 if (!pr->flags.throttling) 840 if (!pr->flags.throttling)
836 return -ENODEV; 841 return -ENODEV;
842
843 if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
844 return -ENOMEM;
845
837 /* 846 /*
838 * Migrate task to the cpu pointed by pr. 847 * Migrate task to the cpu pointed by pr.
839 */ 848 */
840 saved_mask = current->cpus_allowed; 849 cpumask_copy(saved_mask, &current->cpus_allowed);
841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 850 /* FIXME: use work_on_cpu() */
851 set_cpus_allowed_ptr(current, cpumask_of(pr->id));
842 ret = pr->throttling.acpi_processor_get_throttling(pr); 852 ret = pr->throttling.acpi_processor_get_throttling(pr);
843 /* restore the previous state */ 853 /* restore the previous state */
844 set_cpus_allowed_ptr(current, &saved_mask); 854 set_cpus_allowed_ptr(current, saved_mask);
855 free_cpumask_var(saved_mask);
845 856
846 return ret; 857 return ret;
847} 858}
@@ -986,13 +997,13 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
986 997
987int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 998int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
988{ 999{
989 cpumask_t saved_mask; 1000 cpumask_var_t saved_mask;
990 int ret = 0; 1001 int ret = 0;
991 unsigned int i; 1002 unsigned int i;
992 struct acpi_processor *match_pr; 1003 struct acpi_processor *match_pr;
993 struct acpi_processor_throttling *p_throttling; 1004 struct acpi_processor_throttling *p_throttling;
994 struct throttling_tstate t_state; 1005 struct throttling_tstate t_state;
995 cpumask_t online_throttling_cpus; 1006 cpumask_var_t online_throttling_cpus;
996 1007
997 if (!pr) 1008 if (!pr)
998 return -EINVAL; 1009 return -EINVAL;
@@ -1003,17 +1014,25 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1003 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 1014 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
1004 return -EINVAL; 1015 return -EINVAL;
1005 1016
1006 saved_mask = current->cpus_allowed; 1017 if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
1018 return -ENOMEM;
1019
1020 if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) {
1021 free_cpumask_var(saved_mask);
1022 return -ENOMEM;
1023 }
1024
1025 cpumask_copy(saved_mask, &current->cpus_allowed);
1007 t_state.target_state = state; 1026 t_state.target_state = state;
1008 p_throttling = &(pr->throttling); 1027 p_throttling = &(pr->throttling);
1009 cpus_and(online_throttling_cpus, cpu_online_map, 1028 cpumask_and(online_throttling_cpus, cpu_online_mask,
1010 p_throttling->shared_cpu_map); 1029 p_throttling->shared_cpu_map);
1011 /* 1030 /*
1012 * The throttling notifier will be called for every 1031 * The throttling notifier will be called for every
1013 * affected cpu in order to get one proper T-state. 1032 * affected cpu in order to get one proper T-state.
1014 * The notifier event is THROTTLING_PRECHANGE. 1033 * The notifier event is THROTTLING_PRECHANGE.
1015 */ 1034 */
1016 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1035 for_each_cpu(i, online_throttling_cpus) {
1017 t_state.cpu = i; 1036 t_state.cpu = i;
1018 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, 1037 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE,
1019 &t_state); 1038 &t_state);
@@ -1025,7 +1044,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1025 * it can be called only for the cpu pointed by pr. 1044 * it can be called only for the cpu pointed by pr.
1026 */ 1045 */
1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1046 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id)); 1047 /* FIXME: use work_on_cpu() */
1048 set_cpus_allowed_ptr(current, cpumask_of(pr->id));
1029 ret = p_throttling->acpi_processor_set_throttling(pr, 1049 ret = p_throttling->acpi_processor_set_throttling(pr,
1030 t_state.target_state); 1050 t_state.target_state);
1031 } else { 1051 } else {
@@ -1034,7 +1054,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1034 * it is necessary to set T-state for every affected 1054 * it is necessary to set T-state for every affected
1035 * cpus. 1055 * cpus.
1036 */ 1056 */
1037 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1057 for_each_cpu(i, online_throttling_cpus) {
1038 match_pr = per_cpu(processors, i); 1058 match_pr = per_cpu(processors, i);
1039 /* 1059 /*
1040 * If the pointer is invalid, we will report the 1060 * If the pointer is invalid, we will report the
@@ -1056,7 +1076,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1056 continue; 1076 continue;
1057 } 1077 }
1058 t_state.cpu = i; 1078 t_state.cpu = i;
1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); 1079 /* FIXME: use work_on_cpu() */
1080 set_cpus_allowed_ptr(current, cpumask_of(i));
1060 ret = match_pr->throttling. 1081 ret = match_pr->throttling.
1061 acpi_processor_set_throttling( 1082 acpi_processor_set_throttling(
1062 match_pr, t_state.target_state); 1083 match_pr, t_state.target_state);
@@ -1068,13 +1089,16 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1068 * affected cpu to update the T-states. 1089 * affected cpu to update the T-states.
1069 * The notifier event is THROTTLING_POSTCHANGE 1090 * The notifier event is THROTTLING_POSTCHANGE
1070 */ 1091 */
1071 for_each_cpu_mask_nr(i, online_throttling_cpus) { 1092 for_each_cpu(i, online_throttling_cpus) {
1072 t_state.cpu = i; 1093 t_state.cpu = i;
1073 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, 1094 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE,
1074 &t_state); 1095 &t_state);
1075 } 1096 }
1076 /* restore the previous state */ 1097 /* restore the previous state */
1077 set_cpus_allowed_ptr(current, &saved_mask); 1098 /* FIXME: use work_on_cpu() */
1099 set_cpus_allowed_ptr(current, saved_mask);
1100 free_cpumask_var(online_throttling_cpus);
1101 free_cpumask_var(saved_mask);
1078 return ret; 1102 return ret;
1079} 1103}
1080 1104
@@ -1120,7 +1144,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
1120 if (acpi_processor_get_tsd(pr)) { 1144 if (acpi_processor_get_tsd(pr)) {
1121 pthrottling = &pr->throttling; 1145 pthrottling = &pr->throttling;
1122 pthrottling->tsd_valid_flag = 0; 1146 pthrottling->tsd_valid_flag = 0;
1123 cpu_set(pr->id, pthrottling->shared_cpu_map); 1147 cpumask_set_cpu(pr->id, pthrottling->shared_cpu_map);
1124 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL; 1148 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
1125 } 1149 }
1126 1150
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index c66637392bbc..b5b8ba512b28 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_FW_LOADER) += firmware_class.o
11obj-$(CONFIG_NUMA) += node.o 11obj-$(CONFIG_NUMA) += node.o
12obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o 12obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o
13obj-$(CONFIG_SMP) += topology.o 13obj-$(CONFIG_SMP) += topology.o
14obj-$(CONFIG_IOMMU_API) += iommu.o
14ifeq ($(CONFIG_SYSFS),y) 15ifeq ($(CONFIG_SYSFS),y)
15obj-$(CONFIG_MODULES) += module.o 16obj-$(CONFIG_MODULES) += module.o
16endif 17endif
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4259072f5bd0..719ee5c1c8d9 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -128,10 +128,54 @@ print_cpus_func(online);
128print_cpus_func(possible); 128print_cpus_func(possible);
129print_cpus_func(present); 129print_cpus_func(present);
130 130
131/*
132 * Print values for NR_CPUS and offlined cpus
133 */
134static ssize_t print_cpus_kernel_max(struct sysdev_class *class, char *buf)
135{
136 int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1);
137 return n;
138}
139static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
140
141/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
142unsigned int total_cpus;
143
144static ssize_t print_cpus_offline(struct sysdev_class *class, char *buf)
145{
146 int n = 0, len = PAGE_SIZE-2;
147 cpumask_var_t offline;
148
149 /* display offline cpus < nr_cpu_ids */
150 if (!alloc_cpumask_var(&offline, GFP_KERNEL))
151 return -ENOMEM;
152 cpumask_complement(offline, cpu_online_mask);
153 n = cpulist_scnprintf(buf, len, offline);
154 free_cpumask_var(offline);
155
156 /* display offline cpus >= nr_cpu_ids */
157 if (total_cpus && nr_cpu_ids < total_cpus) {
158 if (n && n < len)
159 buf[n++] = ',';
160
161 if (nr_cpu_ids == total_cpus-1)
162 n += snprintf(&buf[n], len - n, "%d", nr_cpu_ids);
163 else
164 n += snprintf(&buf[n], len - n, "%d-%d",
165 nr_cpu_ids, total_cpus-1);
166 }
167
168 n += snprintf(&buf[n], len - n, "\n");
169 return n;
170}
171static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
172
131static struct sysdev_class_attribute *cpu_state_attr[] = { 173static struct sysdev_class_attribute *cpu_state_attr[] = {
132 &attr_online_map, 174 &attr_online_map,
133 &attr_possible_map, 175 &attr_possible_map,
134 &attr_present_map, 176 &attr_present_map,
177 &attr_kernel_max,
178 &attr_offline,
135}; 179};
136 180
137static int cpu_states_init(void) 181static int cpu_states_init(void)
diff --git a/drivers/base/iommu.c b/drivers/base/iommu.c
new file mode 100644
index 000000000000..5e039d4f877c
--- /dev/null
+++ b/drivers/base/iommu.c
@@ -0,0 +1,100 @@
1/*
2 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * 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 License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include <linux/bug.h>
20#include <linux/types.h>
21#include <linux/errno.h>
22#include <linux/iommu.h>
23
24static struct iommu_ops *iommu_ops;
25
26void register_iommu(struct iommu_ops *ops)
27{
28 if (iommu_ops)
29 BUG();
30
31 iommu_ops = ops;
32}
33
34bool iommu_found()
35{
36 return iommu_ops != NULL;
37}
38EXPORT_SYMBOL_GPL(iommu_found);
39
40struct iommu_domain *iommu_domain_alloc(void)
41{
42 struct iommu_domain *domain;
43 int ret;
44
45 domain = kmalloc(sizeof(*domain), GFP_KERNEL);
46 if (!domain)
47 return NULL;
48
49 ret = iommu_ops->domain_init(domain);
50 if (ret)
51 goto out_free;
52
53 return domain;
54
55out_free:
56 kfree(domain);
57
58 return NULL;
59}
60EXPORT_SYMBOL_GPL(iommu_domain_alloc);
61
62void iommu_domain_free(struct iommu_domain *domain)
63{
64 iommu_ops->domain_destroy(domain);
65 kfree(domain);
66}
67EXPORT_SYMBOL_GPL(iommu_domain_free);
68
69int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
70{
71 return iommu_ops->attach_dev(domain, dev);
72}
73EXPORT_SYMBOL_GPL(iommu_attach_device);
74
75void iommu_detach_device(struct iommu_domain *domain, struct device *dev)
76{
77 iommu_ops->detach_dev(domain, dev);
78}
79EXPORT_SYMBOL_GPL(iommu_detach_device);
80
81int iommu_map_range(struct iommu_domain *domain, unsigned long iova,
82 phys_addr_t paddr, size_t size, int prot)
83{
84 return iommu_ops->map(domain, iova, paddr, size, prot);
85}
86EXPORT_SYMBOL_GPL(iommu_map_range);
87
88void iommu_unmap_range(struct iommu_domain *domain, unsigned long iova,
89 size_t size)
90{
91 iommu_ops->unmap(domain, iova, size);
92}
93EXPORT_SYMBOL_GPL(iommu_unmap_range);
94
95phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
96 unsigned long iova)
97{
98 return iommu_ops->iova_to_phys(domain, iova);
99}
100EXPORT_SYMBOL_GPL(iommu_iova_to_phys);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d26891bfcd41..c7afc068c28d 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -559,7 +559,40 @@ struct timer_rand_state {
559}; 559};
560 560
561#ifndef CONFIG_SPARSE_IRQ 561#ifndef CONFIG_SPARSE_IRQ
562struct timer_rand_state *irq_timer_state[NR_IRQS]; 562
563static struct timer_rand_state *irq_timer_state[NR_IRQS];
564
565static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
566{
567 return irq_timer_state[irq];
568}
569
570static void set_timer_rand_state(unsigned int irq,
571 struct timer_rand_state *state)
572{
573 irq_timer_state[irq] = state;
574}
575
576#else
577
578static struct timer_rand_state *get_timer_rand_state(unsigned int irq)
579{
580 struct irq_desc *desc;
581
582 desc = irq_to_desc(irq);
583
584 return desc->timer_rand_state;
585}
586
587static void set_timer_rand_state(unsigned int irq,
588 struct timer_rand_state *state)
589{
590 struct irq_desc *desc;
591
592 desc = irq_to_desc(irq);
593
594 desc->timer_rand_state = state;
595}
563#endif 596#endif
564 597
565static struct timer_rand_state input_timer_state; 598static struct timer_rand_state input_timer_state;
@@ -919,11 +952,6 @@ void rand_initialize_irq(int irq)
919{ 952{
920 struct timer_rand_state *state; 953 struct timer_rand_state *state;
921 954
922#ifndef CONFIG_SPARSE_IRQ
923 if (irq >= nr_irqs)
924 return;
925#endif
926
927 state = get_timer_rand_state(irq); 955 state = get_timer_rand_state(irq);
928 956
929 if (state) 957 if (state)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 31d6f535a79d..01dde80597f7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -754,6 +754,11 @@ static struct kobj_type ktype_cpufreq = {
754 .release = cpufreq_sysfs_release, 754 .release = cpufreq_sysfs_release,
755}; 755};
756 756
757static struct kobj_type ktype_empty_cpufreq = {
758 .sysfs_ops = &sysfs_ops,
759 .release = cpufreq_sysfs_release,
760};
761
757 762
758/** 763/**
759 * cpufreq_add_dev - add a CPU device 764 * cpufreq_add_dev - add a CPU device
@@ -822,8 +827,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
822 dprintk("initialization failed\n"); 827 dprintk("initialization failed\n");
823 goto err_out; 828 goto err_out;
824 } 829 }
825 policy->user_policy.min = policy->cpuinfo.min_freq; 830 policy->user_policy.min = policy->min;
826 policy->user_policy.max = policy->cpuinfo.max_freq; 831 policy->user_policy.max = policy->max;
827 832
828 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 833 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
829 CPUFREQ_START, policy); 834 CPUFREQ_START, policy);
@@ -876,26 +881,36 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
876 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy)); 881 memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
877 882
878 /* prepare interface data */ 883 /* prepare interface data */
879 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &sys_dev->kobj, 884 if (!cpufreq_driver->hide_interface) {
880 "cpufreq"); 885 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
881 if (ret) 886 &sys_dev->kobj, "cpufreq");
882 goto err_out_driver_exit;
883
884 /* set up files for this cpu device */
885 drv_attr = cpufreq_driver->attr;
886 while ((drv_attr) && (*drv_attr)) {
887 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
888 if (ret) 887 if (ret)
889 goto err_out_driver_exit; 888 goto err_out_driver_exit;
890 drv_attr++; 889
891 } 890 /* set up files for this cpu device */
892 if (cpufreq_driver->get) { 891 drv_attr = cpufreq_driver->attr;
893 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 892 while ((drv_attr) && (*drv_attr)) {
894 if (ret) 893 ret = sysfs_create_file(&policy->kobj,
895 goto err_out_driver_exit; 894 &((*drv_attr)->attr));
896 } 895 if (ret)
897 if (cpufreq_driver->target) { 896 goto err_out_driver_exit;
898 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); 897 drv_attr++;
898 }
899 if (cpufreq_driver->get) {
900 ret = sysfs_create_file(&policy->kobj,
901 &cpuinfo_cur_freq.attr);
902 if (ret)
903 goto err_out_driver_exit;
904 }
905 if (cpufreq_driver->target) {
906 ret = sysfs_create_file(&policy->kobj,
907 &scaling_cur_freq.attr);
908 if (ret)
909 goto err_out_driver_exit;
910 }
911 } else {
912 ret = kobject_init_and_add(&policy->kobj, &ktype_empty_cpufreq,
913 &sys_dev->kobj, "cpufreq");
899 if (ret) 914 if (ret)
900 goto err_out_driver_exit; 915 goto err_out_driver_exit;
901 } 916 }
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b4fd8ca701a4..e85c8fe9ffcf 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -85,14 +85,14 @@ config HID_COMPAT
85config HID_A4TECH 85config HID_A4TECH
86 tristate "A4 tech" if EMBEDDED 86 tristate "A4 tech" if EMBEDDED
87 depends on USB_HID 87 depends on USB_HID
88 default y 88 default !EMBEDDED
89 ---help--- 89 ---help---
90 Support for A4 tech X5 and WOP-35 / Trust 450L mice. 90 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
91 91
92config HID_APPLE 92config HID_APPLE
93 tristate "Apple" if EMBEDDED 93 tristate "Apple" if EMBEDDED
94 depends on (USB_HID || BT_HIDP) 94 depends on (USB_HID || BT_HIDP)
95 default y 95 default !EMBEDDED
96 ---help--- 96 ---help---
97 Support for some Apple devices which less or more break 97 Support for some Apple devices which less or more break
98 HID specification. 98 HID specification.
@@ -103,64 +103,49 @@ config HID_APPLE
103config HID_BELKIN 103config HID_BELKIN
104 tristate "Belkin" if EMBEDDED 104 tristate "Belkin" if EMBEDDED
105 depends on USB_HID 105 depends on USB_HID
106 default y 106 default !EMBEDDED
107 ---help--- 107 ---help---
108 Support for Belkin Flip KVM and Wireless keyboard. 108 Support for Belkin Flip KVM and Wireless keyboard.
109 109
110config HID_BRIGHT
111 tristate "Bright" if EMBEDDED
112 depends on USB_HID
113 default y
114 ---help---
115 Support for Bright ABNT-2 keyboard.
116
117config HID_CHERRY 110config HID_CHERRY
118 tristate "Cherry" if EMBEDDED 111 tristate "Cherry" if EMBEDDED
119 depends on USB_HID 112 depends on USB_HID
120 default y 113 default !EMBEDDED
121 ---help--- 114 ---help---
122 Support for Cherry Cymotion keyboard. 115 Support for Cherry Cymotion keyboard.
123 116
124config HID_CHICONY 117config HID_CHICONY
125 tristate "Chicony" if EMBEDDED 118 tristate "Chicony" if EMBEDDED
126 depends on USB_HID 119 depends on USB_HID
127 default y 120 default !EMBEDDED
128 ---help--- 121 ---help---
129 Support for Chicony Tactical pad. 122 Support for Chicony Tactical pad.
130 123
131config HID_CYPRESS 124config HID_CYPRESS
132 tristate "Cypress" if EMBEDDED 125 tristate "Cypress" if EMBEDDED
133 depends on USB_HID 126 depends on USB_HID
134 default y 127 default !EMBEDDED
135 ---help--- 128 ---help---
136 Support for cypress mouse and barcode readers. 129 Support for cypress mouse and barcode readers.
137 130
138config HID_DELL
139 tristate "Dell" if EMBEDDED
140 depends on USB_HID
141 default y
142 ---help---
143 Support for quirky Dell HID hardware that require
144 special LED handling (W7658 and SK8115 models)
145
146config HID_EZKEY 131config HID_EZKEY
147 tristate "Ezkey" if EMBEDDED 132 tristate "Ezkey" if EMBEDDED
148 depends on USB_HID 133 depends on USB_HID
149 default y 134 default !EMBEDDED
150 ---help--- 135 ---help---
151 Support for Ezkey BTC 8193 keyboard. 136 Support for Ezkey BTC 8193 keyboard.
152 137
153config HID_GYRATION 138config HID_GYRATION
154 tristate "Gyration" if EMBEDDED 139 tristate "Gyration" if EMBEDDED
155 depends on USB_HID 140 depends on USB_HID
156 default y 141 default !EMBEDDED
157 ---help--- 142 ---help---
158 Support for Gyration remote control. 143 Support for Gyration remote control.
159 144
160config HID_LOGITECH 145config HID_LOGITECH
161 tristate "Logitech" if EMBEDDED 146 tristate "Logitech" if EMBEDDED
162 depends on USB_HID 147 depends on USB_HID
163 default y 148 default !EMBEDDED
164 ---help--- 149 ---help---
165 Support for Logitech devices that are not fully compliant with HID standard. 150 Support for Logitech devices that are not fully compliant with HID standard.
166 151
@@ -191,21 +176,28 @@ config LOGIRUMBLEPAD2_FF
191config HID_MICROSOFT 176config HID_MICROSOFT
192 tristate "Microsoft" if EMBEDDED 177 tristate "Microsoft" if EMBEDDED
193 depends on USB_HID 178 depends on USB_HID
194 default y 179 default !EMBEDDED
195 ---help--- 180 ---help---
196 Support for Microsoft devices that are not fully compliant with HID standard. 181 Support for Microsoft devices that are not fully compliant with HID standard.
197 182
198config HID_MONTEREY 183config HID_MONTEREY
199 tristate "Monterey" if EMBEDDED 184 tristate "Monterey" if EMBEDDED
200 depends on USB_HID 185 depends on USB_HID
201 default y 186 default !EMBEDDED
202 ---help--- 187 ---help---
203 Support for Monterey Genius KB29E. 188 Support for Monterey Genius KB29E.
204 189
190config HID_NTRIG
191 tristate "NTrig" if EMBEDDED
192 depends on USB_HID
193 default !EMBEDDED
194 ---help---
195 Support for N-Trig touch screen.
196
205config HID_PANTHERLORD 197config HID_PANTHERLORD
206 tristate "Pantherlord devices support" if EMBEDDED 198 tristate "Pantherlord devices support" if EMBEDDED
207 depends on USB_HID 199 depends on USB_HID
208 default y 200 default !EMBEDDED
209 ---help--- 201 ---help---
210 Support for PantherLord/GreenAsia based device support. 202 Support for PantherLord/GreenAsia based device support.
211 203
@@ -220,31 +212,47 @@ config PANTHERLORD_FF
220config HID_PETALYNX 212config HID_PETALYNX
221 tristate "Petalynx" if EMBEDDED 213 tristate "Petalynx" if EMBEDDED
222 depends on USB_HID 214 depends on USB_HID
223 default y 215 default !EMBEDDED
224 ---help--- 216 ---help---
225 Support for Petalynx Maxter remote control. 217 Support for Petalynx Maxter remote control.
226 218
227config HID_SAMSUNG 219config HID_SAMSUNG
228 tristate "Samsung" if EMBEDDED 220 tristate "Samsung" if EMBEDDED
229 depends on USB_HID 221 depends on USB_HID
230 default y 222 default !EMBEDDED
231 ---help--- 223 ---help---
232 Support for Samsung InfraRed remote control. 224 Support for Samsung InfraRed remote control.
233 225
234config HID_SONY 226config HID_SONY
235 tristate "Sony" if EMBEDDED 227 tristate "Sony" if EMBEDDED
236 depends on USB_HID 228 depends on USB_HID
237 default y 229 default !EMBEDDED
238 ---help--- 230 ---help---
239 Support for Sony PS3 controller. 231 Support for Sony PS3 controller.
240 232
241config HID_SUNPLUS 233config HID_SUNPLUS
242 tristate "Sunplus" if EMBEDDED 234 tristate "Sunplus" if EMBEDDED
243 depends on USB_HID 235 depends on USB_HID
244 default y 236 default !EMBEDDED
245 ---help--- 237 ---help---
246 Support for Sunplus wireless desktop. 238 Support for Sunplus wireless desktop.
247 239
240config GREENASIA_FF
241 tristate "GreenAsia (Product ID 0x12) force feedback support"
242 depends on USB_HID
243 select INPUT_FF_MEMLESS
244 ---help---
245 Say Y here if you have a GreenAsia (Product ID 0x12) based game controller
246 (like MANTA Warior MM816 and SpeedLink Strike2 SL-6635) or adapter
247 and want to enable force feedback support for it.
248
249config HID_TOPSEED
250 tristate "TopSeed Cyberlink remote control support" if EMBEDDED
251 depends on USB_HID
252 default !EMBEDDED
253 ---help---
254 Say Y if you have a TopSeed Cyberlink remote control.
255
248config THRUSTMASTER_FF 256config THRUSTMASTER_FF
249 tristate "ThrustMaster devices support" 257 tristate "ThrustMaster devices support"
250 depends on USB_HID 258 depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index b09e43e7413e..fbd021f153f1 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -23,22 +23,23 @@ endif
23obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o 23obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
24obj-$(CONFIG_HID_APPLE) += hid-apple.o 24obj-$(CONFIG_HID_APPLE) += hid-apple.o
25obj-$(CONFIG_HID_BELKIN) += hid-belkin.o 25obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
26obj-$(CONFIG_HID_BRIGHT) += hid-bright.o
27obj-$(CONFIG_HID_CHERRY) += hid-cherry.o 26obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
28obj-$(CONFIG_HID_CHICONY) += hid-chicony.o 27obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
29obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 28obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
30obj-$(CONFIG_HID_DELL) += hid-dell.o
31obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 29obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
32obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 30obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
33obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 31obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
34obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 32obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
35obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o 33obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
34obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
36obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o 35obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
37obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 36obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
38obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 37obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
39obj-$(CONFIG_HID_SONY) += hid-sony.o 38obj-$(CONFIG_HID_SONY) += hid-sony.o
40obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 39obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
40obj-$(CONFIG_GREENASIA_FF) += hid-gaff.o
41obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o 41obj-$(CONFIG_THRUSTMASTER_FF) += hid-tmff.o
42obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o
42obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o 43obj-$(CONFIG_ZEROPLUS_FF) += hid-zpff.o
43 44
44obj-$(CONFIG_USB_HID) += usbhid/ 45obj-$(CONFIG_USB_HID) += usbhid/
diff --git a/drivers/hid/hid-bright.c b/drivers/hid/hid-bright.c
deleted file mode 100644
index 38517a117dfd..000000000000
--- a/drivers/hid/hid-bright.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * HID driver for some bright "special" devices
3 *
4 * Copyright (c) 2008 Mauro Carvalho Chehab <mchehab@redhat.com>
5 *
6 * Based on hid-dell driver
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16#include <linux/device.h>
17#include <linux/hid.h>
18#include <linux/module.h>
19
20#include "hid-ids.h"
21
22static int bright_probe(struct hid_device *hdev, const struct hid_device_id *id)
23{
24 int ret;
25
26 ret = hid_parse(hdev);
27 if (ret) {
28 dev_err(&hdev->dev, "parse failed\n");
29 goto err_free;
30 }
31
32 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
33 if (ret) {
34 dev_err(&hdev->dev, "hw start failed\n");
35 goto err_free;
36 }
37
38 usbhid_set_leds(hdev);
39
40 return 0;
41err_free:
42 return ret;
43}
44
45static const struct hid_device_id bright_devices[] = {
46 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
47 { }
48};
49MODULE_DEVICE_TABLE(hid, bright_devices);
50
51static struct hid_driver bright_driver = {
52 .name = "bright",
53 .id_table = bright_devices,
54 .probe = bright_probe,
55};
56
57static int bright_init(void)
58{
59 return hid_register_driver(&bright_driver);
60}
61
62static void bright_exit(void)
63{
64 hid_unregister_driver(&bright_driver);
65}
66
67module_init(bright_init);
68module_exit(bright_exit);
69MODULE_LICENSE("GPL");
70
71HID_COMPAT_LOAD_DRIVER(bright);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 40df3e1b4bd1..5d7640e49dc5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1256,19 +1256,16 @@ static const struct hid_device_id hid_blacklist[] = {
1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1256 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1257 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1258 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, 1258 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
1259 { HID_USB_DEVICE(USB_VENDOR_ID_BRIGHT, USB_DEVICE_ID_BRIGHT_ABNT2) },
1260 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, 1259 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
1261 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 1260 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
1262 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, 1261 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
1263 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, 1262 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
1264 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1263 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1265 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
1266 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
1267 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1264 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
1269 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1265 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1270 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 1266 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
1271 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) }, 1267 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
1268 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
1272 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) }, 1269 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
1273 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, 1270 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) },
1274 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1271 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
@@ -1279,7 +1276,6 @@ static const struct hid_device_id hid_blacklist[] = {
1279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 1276 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) },
1280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 1277 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) },
1281 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, 1278 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) },
1282 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) },
1283 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, 1279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) },
1284 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, 1280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
1285 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, 1281 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
@@ -1297,23 +1293,105 @@ static const struct hid_device_id hid_blacklist[] = {
1297 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1293 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
1298 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1294 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1299 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1295 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1296 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
1300 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1297 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1301 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1298 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1299 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1300 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1301 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1302 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
1305 1303
1306 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, 1304 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
1307 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, 1305 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) },
1308 { } 1306 { }
1309}; 1307};
1310 1308
1309struct hid_dynid {
1310 struct list_head list;
1311 struct hid_device_id id;
1312};
1313
1314/**
1315 * store_new_id - add a new HID device ID to this driver and re-probe devices
1316 * @driver: target device driver
1317 * @buf: buffer for scanning device ID data
1318 * @count: input size
1319 *
1320 * Adds a new dynamic hid device ID to this driver,
1321 * and causes the driver to probe for all devices again.
1322 */
1323static ssize_t store_new_id(struct device_driver *drv, const char *buf,
1324 size_t count)
1325{
1326 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1327 struct hid_dynid *dynid;
1328 __u32 bus, vendor, product;
1329 unsigned long driver_data = 0;
1330 int ret;
1331
1332 ret = sscanf(buf, "%x %x %x %lx",
1333 &bus, &vendor, &product, &driver_data);
1334 if (ret < 3)
1335 return -EINVAL;
1336
1337 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
1338 if (!dynid)
1339 return -ENOMEM;
1340
1341 dynid->id.bus = bus;
1342 dynid->id.vendor = vendor;
1343 dynid->id.product = product;
1344 dynid->id.driver_data = driver_data;
1345
1346 spin_lock(&hdrv->dyn_lock);
1347 list_add_tail(&dynid->list, &hdrv->dyn_list);
1348 spin_unlock(&hdrv->dyn_lock);
1349
1350 ret = 0;
1351 if (get_driver(&hdrv->driver)) {
1352 ret = driver_attach(&hdrv->driver);
1353 put_driver(&hdrv->driver);
1354 }
1355
1356 return ret ? : count;
1357}
1358static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
1359
1360static void hid_free_dynids(struct hid_driver *hdrv)
1361{
1362 struct hid_dynid *dynid, *n;
1363
1364 spin_lock(&hdrv->dyn_lock);
1365 list_for_each_entry_safe(dynid, n, &hdrv->dyn_list, list) {
1366 list_del(&dynid->list);
1367 kfree(dynid);
1368 }
1369 spin_unlock(&hdrv->dyn_lock);
1370}
1371
1372static const struct hid_device_id *hid_match_device(struct hid_device *hdev,
1373 struct hid_driver *hdrv)
1374{
1375 struct hid_dynid *dynid;
1376
1377 spin_lock(&hdrv->dyn_lock);
1378 list_for_each_entry(dynid, &hdrv->dyn_list, list) {
1379 if (hid_match_one_id(hdev, &dynid->id)) {
1380 spin_unlock(&hdrv->dyn_lock);
1381 return &dynid->id;
1382 }
1383 }
1384 spin_unlock(&hdrv->dyn_lock);
1385
1386 return hid_match_id(hdev, hdrv->id_table);
1387}
1388
1311static int hid_bus_match(struct device *dev, struct device_driver *drv) 1389static int hid_bus_match(struct device *dev, struct device_driver *drv)
1312{ 1390{
1313 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); 1391 struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver);
1314 struct hid_device *hdev = container_of(dev, struct hid_device, dev); 1392 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
1315 1393
1316 if (!hid_match_id(hdev, hdrv->id_table)) 1394 if (!hid_match_device(hdev, hdrv))
1317 return 0; 1395 return 0;
1318 1396
1319 /* generic wants all non-blacklisted */ 1397 /* generic wants all non-blacklisted */
@@ -1332,7 +1410,7 @@ static int hid_device_probe(struct device *dev)
1332 int ret = 0; 1410 int ret = 0;
1333 1411
1334 if (!hdev->driver) { 1412 if (!hdev->driver) {
1335 id = hid_match_id(hdev, hdrv->id_table); 1413 id = hid_match_device(hdev, hdrv);
1336 if (id == NULL) 1414 if (id == NULL)
1337 return -ENODEV; 1415 return -ENODEV;
1338 1416
@@ -1420,6 +1498,7 @@ static const struct hid_device_id hid_ignore_list[] = {
1420 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, 1498 { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) },
1421 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, 1499 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) },
1422 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, 1500 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) },
1501 { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) },
1423 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, 1502 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) },
1424 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, 1503 { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) },
1425 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, 1504 { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) },
@@ -1577,6 +1656,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
1577 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, 1656 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) },
1578 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, 1657 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) },
1579 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, 1658 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
1659 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) },
1660 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) },
1661 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) },
1580 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1662 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1581 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1663 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1582 { } 1664 { }
@@ -1618,9 +1700,10 @@ int hid_add_device(struct hid_device *hdev)
1618 if (hid_ignore(hdev)) 1700 if (hid_ignore(hdev))
1619 return -ENODEV; 1701 return -ENODEV;
1620 1702
1621 /* XXX hack, any other cleaner solution < 20 bus_id bytes? */ 1703 /* XXX hack, any other cleaner solution after the driver core
1622 sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus, 1704 * is converted to allow more than 20 bytes as the device name? */
1623 hdev->vendor, hdev->product, atomic_inc_return(&id)); 1705 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
1706 hdev->vendor, hdev->product, atomic_inc_return(&id));
1624 1707
1625 ret = device_add(&hdev->dev); 1708 ret = device_add(&hdev->dev);
1626 if (!ret) 1709 if (!ret)
@@ -1695,18 +1778,33 @@ EXPORT_SYMBOL_GPL(hid_destroy_device);
1695int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, 1778int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
1696 const char *mod_name) 1779 const char *mod_name)
1697{ 1780{
1781 int ret;
1782
1698 hdrv->driver.name = hdrv->name; 1783 hdrv->driver.name = hdrv->name;
1699 hdrv->driver.bus = &hid_bus_type; 1784 hdrv->driver.bus = &hid_bus_type;
1700 hdrv->driver.owner = owner; 1785 hdrv->driver.owner = owner;
1701 hdrv->driver.mod_name = mod_name; 1786 hdrv->driver.mod_name = mod_name;
1702 1787
1703 return driver_register(&hdrv->driver); 1788 INIT_LIST_HEAD(&hdrv->dyn_list);
1789 spin_lock_init(&hdrv->dyn_lock);
1790
1791 ret = driver_register(&hdrv->driver);
1792 if (ret)
1793 return ret;
1794
1795 ret = driver_create_file(&hdrv->driver, &driver_attr_new_id);
1796 if (ret)
1797 driver_unregister(&hdrv->driver);
1798
1799 return ret;
1704} 1800}
1705EXPORT_SYMBOL_GPL(__hid_register_driver); 1801EXPORT_SYMBOL_GPL(__hid_register_driver);
1706 1802
1707void hid_unregister_driver(struct hid_driver *hdrv) 1803void hid_unregister_driver(struct hid_driver *hdrv)
1708{ 1804{
1805 driver_remove_file(&hdrv->driver, &driver_attr_new_id);
1709 driver_unregister(&hdrv->driver); 1806 driver_unregister(&hdrv->driver);
1807 hid_free_dynids(hdrv);
1710} 1808}
1711EXPORT_SYMBOL_GPL(hid_unregister_driver); 1809EXPORT_SYMBOL_GPL(hid_unregister_driver);
1712 1810
diff --git a/drivers/hid/hid-dell.c b/drivers/hid/hid-dell.c
deleted file mode 100644
index f5474300b83a..000000000000
--- a/drivers/hid/hid-dell.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * HID driver for some dell "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 */
11
12/*
13 * 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 Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19#include <linux/device.h>
20#include <linux/hid.h>
21#include <linux/module.h>
22
23#include "hid-ids.h"
24
25static int dell_probe(struct hid_device *hdev, const struct hid_device_id *id)
26{
27 int ret;
28
29 ret = hid_parse(hdev);
30 if (ret) {
31 dev_err(&hdev->dev, "parse failed\n");
32 goto err_free;
33 }
34
35 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
36 if (ret) {
37 dev_err(&hdev->dev, "hw start failed\n");
38 goto err_free;
39 }
40
41 usbhid_set_leds(hdev);
42
43 return 0;
44err_free:
45 return ret;
46}
47
48static const struct hid_device_id dell_devices[] = {
49 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658) },
50 { HID_USB_DEVICE(USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_SK8115) },
51 { HID_USB_DEVICE(USB_VENDOR_ID_GENERIC_13BA, USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE) },
52 { }
53};
54MODULE_DEVICE_TABLE(hid, dell_devices);
55
56static struct hid_driver dell_driver = {
57 .name = "dell",
58 .id_table = dell_devices,
59 .probe = dell_probe,
60};
61
62static int dell_init(void)
63{
64 return hid_register_driver(&dell_driver);
65}
66
67static void dell_exit(void)
68{
69 hid_unregister_driver(&dell_driver);
70}
71
72module_init(dell_init);
73module_exit(dell_exit);
74MODULE_LICENSE("GPL");
75
76HID_COMPAT_LOAD_DRIVER(dell);
diff --git a/drivers/hid/hid-dummy.c b/drivers/hid/hid-dummy.c
index e148f86fb58e..b4cc0f743d63 100644
--- a/drivers/hid/hid-dummy.c
+++ b/drivers/hid/hid-dummy.c
@@ -43,6 +43,9 @@ static int __init hid_dummy_init(void)
43#ifdef CONFIG_HID_MONTEREY_MODULE 43#ifdef CONFIG_HID_MONTEREY_MODULE
44 HID_COMPAT_CALL_DRIVER(monterey); 44 HID_COMPAT_CALL_DRIVER(monterey);
45#endif 45#endif
46#ifdef CONFIG_HID_NTRIG_MODULE
47 HID_COMPAT_CALL_DRIVER(ntrig);
48#endif
46#ifdef CONFIG_HID_PANTHERLORD_MODULE 49#ifdef CONFIG_HID_PANTHERLORD_MODULE
47 HID_COMPAT_CALL_DRIVER(pantherlord); 50 HID_COMPAT_CALL_DRIVER(pantherlord);
48#endif 51#endif
@@ -58,6 +61,9 @@ static int __init hid_dummy_init(void)
58#ifdef CONFIG_HID_SUNPLUS_MODULE 61#ifdef CONFIG_HID_SUNPLUS_MODULE
59 HID_COMPAT_CALL_DRIVER(sunplus); 62 HID_COMPAT_CALL_DRIVER(sunplus);
60#endif 63#endif
64#ifdef CONFIG_GREENASIA_FF_MODULE
65 HID_COMPAT_CALL_DRIVER(greenasia);
66#endif
61#ifdef CONFIG_THRUSTMASTER_FF_MODULE 67#ifdef CONFIG_THRUSTMASTER_FF_MODULE
62 HID_COMPAT_CALL_DRIVER(thrustmaster); 68 HID_COMPAT_CALL_DRIVER(thrustmaster);
63#endif 69#endif
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
new file mode 100644
index 000000000000..71211f6a4f02
--- /dev/null
+++ b/drivers/hid/hid-gaff.c
@@ -0,0 +1,185 @@
1/*
2 * Force feedback support for GreenAsia (Product ID 0x12) based devices
3 *
4 * The devices are distributed under various names and the same USB device ID
5 * can be used in many game controllers.
6 *
7 *
8 * 0e8f:0012 "GreenAsia Inc. USB Joystick "
9 * - tested with MANTA Warior MM816 and SpeedLink Strike2 SL-6635.
10 *
11 * Copyright (c) 2008 Lukasz Lubojanski <lukasz@lubojanski.info>
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30#include <linux/input.h>
31#include <linux/usb.h>
32#include <linux/hid.h>
33#include "hid-ids.h"
34#include "usbhid/usbhid.h"
35
36struct gaff_device {
37 struct hid_report *report;
38};
39
40static int hid_gaff_play(struct input_dev *dev, void *data,
41 struct ff_effect *effect)
42{
43 struct hid_device *hid = input_get_drvdata(dev);
44 struct gaff_device *gaff = data;
45 int left, right;
46
47 left = effect->u.rumble.strong_magnitude;
48 right = effect->u.rumble.weak_magnitude;
49
50 dbg_hid("called with 0x%04x 0x%04x", left, right);
51
52 left = left * 0xfe / 0xffff;
53 right = right * 0xfe / 0xffff;
54
55 gaff->report->field[0]->value[0] = 0x51;
56 gaff->report->field[0]->value[1] = 0x0;
57 gaff->report->field[0]->value[2] = right;
58 gaff->report->field[0]->value[3] = 0;
59 gaff->report->field[0]->value[4] = left;
60 gaff->report->field[0]->value[5] = 0;
61 dbg_hid("running with 0x%02x 0x%02x", left, right);
62 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
63
64 gaff->report->field[0]->value[0] = 0xfa;
65 gaff->report->field[0]->value[1] = 0xfe;
66 gaff->report->field[0]->value[2] = 0x0;
67 gaff->report->field[0]->value[4] = 0x0;
68
69 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
70
71 return 0;
72}
73
74static int gaff_init(struct hid_device *hid)
75{
76 struct gaff_device *gaff;
77 struct hid_report *report;
78 struct hid_input *hidinput = list_entry(hid->inputs.next,
79 struct hid_input, list);
80 struct list_head *report_list =
81 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
82 struct list_head *report_ptr = report_list;
83 struct input_dev *dev = hidinput->input;
84 int error;
85
86 if (list_empty(report_list)) {
87 dev_err(&hid->dev, "no output reports found\n");
88 return -ENODEV;
89 }
90
91 report_ptr = report_ptr->next;
92
93 report = list_entry(report_ptr, struct hid_report, list);
94 if (report->maxfield < 1) {
95 dev_err(&hid->dev, "no fields in the report\n");
96 return -ENODEV;
97 }
98
99 if (report->field[0]->report_count < 6) {
100 dev_err(&hid->dev, "not enough values in the field\n");
101 return -ENODEV;
102 }
103
104 gaff = kzalloc(sizeof(struct gaff_device), GFP_KERNEL);
105 if (!gaff)
106 return -ENOMEM;
107
108 set_bit(FF_RUMBLE, dev->ffbit);
109
110 error = input_ff_create_memless(dev, gaff, hid_gaff_play);
111 if (error) {
112 kfree(gaff);
113 return error;
114 }
115
116 gaff->report = report;
117 gaff->report->field[0]->value[0] = 0x51;
118 gaff->report->field[0]->value[1] = 0x00;
119 gaff->report->field[0]->value[2] = 0x00;
120 gaff->report->field[0]->value[3] = 0x00;
121 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
122
123 gaff->report->field[0]->value[0] = 0xfa;
124 gaff->report->field[0]->value[1] = 0xfe;
125
126 usbhid_submit_report(hid, gaff->report, USB_DIR_OUT);
127
128 dev_info(&hid->dev, "Force Feedback for GreenAsia 0x12"
129 " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n");
130
131 return 0;
132}
133
134static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id)
135{
136 int ret;
137
138 dev_dbg(&hdev->dev, "Greenasia HID hardware probe...");
139
140 ret = hid_parse(hdev);
141 if (ret) {
142 dev_err(&hdev->dev, "parse failed\n");
143 goto err;
144 }
145
146 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
147 if (ret) {
148 dev_err(&hdev->dev, "hw start failed\n");
149 goto err;
150 }
151
152 gaff_init(hdev);
153
154 return 0;
155err:
156 return ret;
157}
158
159static const struct hid_device_id ga_devices[] = {
160 { HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012), },
161 { }
162};
163MODULE_DEVICE_TABLE(hid, ga_devices);
164
165static struct hid_driver ga_driver = {
166 .name = "greenasia",
167 .id_table = ga_devices,
168 .probe = ga_probe,
169};
170
171static int __init ga_init(void)
172{
173 return hid_register_driver(&ga_driver);
174}
175
176static void __exit ga_exit(void)
177{
178 hid_unregister_driver(&ga_driver);
179}
180
181module_init(ga_init);
182module_exit(ga_exit);
183MODULE_LICENSE("GPL");
184
185HID_COMPAT_LOAD_DRIVER(greenasia);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 39289699c32f..acc1abc834a4 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -107,9 +107,6 @@
107#define USB_VENDOR_ID_BELKIN 0x050d 107#define USB_VENDOR_ID_BELKIN 0x050d
108#define USB_DEVICE_ID_FLIP_KVM 0x3201 108#define USB_DEVICE_ID_FLIP_KVM 0x3201
109 109
110#define USB_VENDOR_ID_BRIGHT 0x1241
111#define USB_DEVICE_ID_BRIGHT_ABNT2 0x1503
112
113#define USB_VENDOR_ID_BERKSHIRE 0x0c98 110#define USB_VENDOR_ID_BERKSHIRE 0x0c98
114#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 111#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
115 112
@@ -141,9 +138,8 @@
141#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 138#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
142#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 139#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
143 140
144#define USB_VENDOR_ID_DELL 0x413c 141#define USB_VENDOR_ID_DEALEXTREAME 0x10c5
145#define USB_DEVICE_ID_DELL_W7658 0x2005 142#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a
146#define USB_DEVICE_ID_DELL_SK8115 0x2105
147 143
148#define USB_VENDOR_ID_DELORME 0x1163 144#define USB_VENDOR_ID_DELORME 0x1163
149#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 145#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100
@@ -167,9 +163,6 @@
167 163
168#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc 164#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc
169 165
170#define USB_VENDOR_ID_GENERIC_13BA 0x13ba
171#define USB_DEVICE_ID_GENERIC_13BA_KBD_MOUSE 0x0017
172
173#define USB_VENDOR_ID_GLAB 0x06c2 166#define USB_VENDOR_ID_GLAB 0x06c2
174#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 167#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
175#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 168#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
@@ -292,7 +285,6 @@
292#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 285#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
293#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 286#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295
294#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a 287#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a
295#define USB_DEVICE_ID_LOGITECH_KBD 0xc311
296#define USB_DEVICE_ID_S510_RECEIVER 0xc50c 288#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
297#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 289#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
298#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512 290#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512
@@ -339,6 +331,9 @@
339#define USB_VENDOR_ID_NEC 0x073e 331#define USB_VENDOR_ID_NEC 0x073e
340#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 332#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
341 333
334#define USB_VENDOR_ID_NTRIG 0x1b96
335#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001
336
342#define USB_VENDOR_ID_ONTRAK 0x0a07 337#define USB_VENDOR_ID_ONTRAK 0x0a07
343#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 338#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
344 339
@@ -383,9 +378,15 @@
383#define USB_VENDOR_ID_TOPMAX 0x0663 378#define USB_VENDOR_ID_TOPMAX 0x0663
384#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 379#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103
385 380
381#define USB_VENDOR_ID_TOPSEED 0x0766
382#define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204
383
386#define USB_VENDOR_ID_TURBOX 0x062a 384#define USB_VENDOR_ID_TURBOX 0x062a
387#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 385#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
388 386
387#define USB_VENDOR_ID_UCLOGIC 0x5543
388#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042
389
389#define USB_VENDOR_ID_VERNIER 0x08f7 390#define USB_VENDOR_ID_VERNIER 0x08f7
390#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 391#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
391#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 392#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
index 2bae340eafe2..83e07c9f4144 100644
--- a/drivers/hid/hid-lg.c
+++ b/drivers/hid/hid-lg.c
@@ -26,7 +26,6 @@
26#define LG_RDESC 0x001 26#define LG_RDESC 0x001
27#define LG_BAD_RELATIVE_KEYS 0x002 27#define LG_BAD_RELATIVE_KEYS 0x002
28#define LG_DUPLICATE_USAGES 0x004 28#define LG_DUPLICATE_USAGES 0x004
29#define LG_RESET_LEDS 0x008
30#define LG_EXPANDED_KEYMAP 0x010 29#define LG_EXPANDED_KEYMAP 0x010
31#define LG_IGNORE_DOUBLED_WHEEL 0x020 30#define LG_IGNORE_DOUBLED_WHEEL 0x020
32#define LG_WIRELESS 0x040 31#define LG_WIRELESS 0x040
@@ -248,9 +247,6 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
248 goto err_free; 247 goto err_free;
249 } 248 }
250 249
251 if (quirks & LG_RESET_LEDS)
252 usbhid_set_leds(hdev);
253
254 if (quirks & LG_FF) 250 if (quirks & LG_FF)
255 lgff_init(hdev); 251 lgff_init(hdev);
256 if (quirks & LG_FF2) 252 if (quirks & LG_FF2)
@@ -279,9 +275,6 @@ static const struct hid_device_id lg_devices[] = {
279 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI), 275 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI),
280 .driver_data = LG_DUPLICATE_USAGES }, 276 .driver_data = LG_DUPLICATE_USAGES },
281 277
282 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD),
283 .driver_data = LG_RESET_LEDS },
284
285 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD), 278 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD),
286 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP }, 279 .driver_data = LG_IGNORE_DOUBLED_WHEEL | LG_EXPANDED_KEYMAP },
287 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500), 280 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500),
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
new file mode 100644
index 000000000000..db44fbd7bdf6
--- /dev/null
+++ b/drivers/hid/hid-ntrig.c
@@ -0,0 +1,82 @@
1/*
2 * HID driver for some ntrig "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2008 Rafi Rubin
11 *
12 */
13
14/*
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
18 * any later version.
19 */
20
21#include <linux/device.h>
22#include <linux/hid.h>
23#include <linux/module.h>
24
25#include "hid-ids.h"
26
27#define NTRIG_DUPLICATE_USAGES 0x001
28
29#define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
30 EV_KEY, (c))
31
32static int ntrig_input_mapping(struct hid_device *hdev, struct hid_input *hi,
33 struct hid_field *field, struct hid_usage *usage,
34 unsigned long **bit, int *max)
35{
36 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER &&
37 (usage->hid & 0xff) == 0x47) {
38 nt_map_key_clear(BTN_TOOL_DOUBLETAP);
39 return 1;
40 }
41 return 0;
42}
43
44static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi,
45 struct hid_field *field, struct hid_usage *usage,
46 unsigned long **bit, int *max)
47{
48 if (usage->type == EV_KEY || usage->type == EV_REL
49 || usage->type == EV_ABS)
50 clear_bit(usage->code, *bit);
51
52 return 0;
53}
54static const struct hid_device_id ntrig_devices[] = {
55 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN),
56 .driver_data = NTRIG_DUPLICATE_USAGES },
57 { }
58};
59MODULE_DEVICE_TABLE(hid, ntrig_devices);
60
61static struct hid_driver ntrig_driver = {
62 .name = "ntrig",
63 .id_table = ntrig_devices,
64 .input_mapping = ntrig_input_mapping,
65 .input_mapped = ntrig_input_mapped,
66};
67
68static int ntrig_init(void)
69{
70 return hid_register_driver(&ntrig_driver);
71}
72
73static void ntrig_exit(void)
74{
75 hid_unregister_driver(&ntrig_driver);
76}
77
78module_init(ntrig_init);
79module_exit(ntrig_exit);
80MODULE_LICENSE("GPL");
81
82HID_COMPAT_LOAD_DRIVER(ntrig);
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 86e563b8d644..dd5a3979a4de 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -102,7 +102,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
102 } 102 }
103 103
104 ret = sony_set_operational(hdev); 104 ret = sony_set_operational(hdev);
105 if (ret) 105 if (ret < 0)
106 goto err_stop; 106 goto err_stop;
107 107
108 return 0; 108 return 0;
diff --git a/drivers/hid/hid-topseed.c b/drivers/hid/hid-topseed.c
new file mode 100644
index 000000000000..cca64a0564a9
--- /dev/null
+++ b/drivers/hid/hid-topseed.c
@@ -0,0 +1,77 @@
1/*
2 * HID driver for TopSeed Cyberlink remote
3 *
4 * Copyright (c) 2008 Lev Babiev
5 * based on hid-cherry driver
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18
19#include "hid-ids.h"
20
21#define ts_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
22 EV_KEY, (c))
23static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
24 struct hid_field *field, struct hid_usage *usage,
25 unsigned long **bit, int *max)
26{
27 if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000)
28 return 0;
29
30 switch (usage->hid & HID_USAGE) {
31 case 0x00d: ts_map_key_clear(KEY_HOME); break;
32 case 0x024: ts_map_key_clear(KEY_MENU); break;
33 case 0x025: ts_map_key_clear(KEY_TV); break;
34 case 0x048: ts_map_key_clear(KEY_RED); break;
35 case 0x047: ts_map_key_clear(KEY_GREEN); break;
36 case 0x049: ts_map_key_clear(KEY_YELLOW); break;
37 case 0x04a: ts_map_key_clear(KEY_BLUE); break;
38 case 0x04b: ts_map_key_clear(KEY_ANGLE); break;
39 case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break;
40 case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break;
41 case 0x031: ts_map_key_clear(KEY_AUDIO); break;
42 case 0x032: ts_map_key_clear(KEY_TEXT); break;
43 case 0x033: ts_map_key_clear(KEY_CHANNEL); break;
44 default:
45 return 0;
46 }
47
48 return 1;
49}
50
51static const struct hid_device_id ts_devices[] = {
52 { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
53 { }
54};
55MODULE_DEVICE_TABLE(hid, ts_devices);
56
57static struct hid_driver ts_driver = {
58 .name = "topseed",
59 .id_table = ts_devices,
60 .input_mapping = ts_input_mapping,
61};
62
63static int ts_init(void)
64{
65 return hid_register_driver(&ts_driver);
66}
67
68static void ts_exit(void)
69{
70 hid_unregister_driver(&ts_driver);
71}
72
73module_init(ts_init);
74module_exit(ts_exit);
75MODULE_LICENSE("GPL");
76
77HID_COMPAT_LOAD_DRIVER(topseed);
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 7685ae6808c4..732449628971 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -208,7 +208,7 @@ static int hidraw_release(struct inode * inode, struct file * file)
208 208
209 list_del(&list->node); 209 list_del(&list->node);
210 dev = hidraw_table[minor]; 210 dev = hidraw_table[minor];
211 if (!dev->open--) { 211 if (!--dev->open) {
212 if (list->hidraw->exist) 212 if (list->hidraw->exist)
213 dev->hid->ll_driver->close(dev->hid); 213 dev->hid->ll_driver->close(dev->hid);
214 else 214 else
@@ -265,6 +265,34 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
265 break; 265 break;
266 } 266 }
267 default: 267 default:
268 {
269 struct hid_device *hid = dev->hid;
270 if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ)
271 return -EINVAL;
272
273 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) {
274 int len;
275 if (!hid->name)
276 return 0;
277 len = strlen(hid->name) + 1;
278 if (len > _IOC_SIZE(cmd))
279 len = _IOC_SIZE(cmd);
280 return copy_to_user(user_arg, hid->name, len) ?
281 -EFAULT : len;
282 }
283
284 if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) {
285 int len;
286 if (!hid->phys)
287 return 0;
288 len = strlen(hid->phys) + 1;
289 if (len > _IOC_SIZE(cmd))
290 len = _IOC_SIZE(cmd);
291 return copy_to_user(user_arg, hid->phys, len) ?
292 -EFAULT : len;
293 }
294 }
295
268 ret = -ENOTTY; 296 ret = -ENOTTY;
269 } 297 }
270 unlock_kernel(); 298 unlock_kernel();
@@ -329,7 +357,7 @@ int hidraw_connect(struct hid_device *hid)
329 goto out; 357 goto out;
330 } 358 }
331 359
332 dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), 360 dev->dev = device_create(hidraw_class, &hid->dev, MKDEV(hidraw_major, minor),
333 NULL, "%s%d", "hidraw", minor); 361 NULL, "%s%d", "hidraw", minor);
334 362
335 if (IS_ERR(dev->dev)) { 363 if (IS_ERR(dev->dev)) {
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 5d9aa95fc3ef..4edb3bef94a6 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -45,7 +45,7 @@ config USB_HIDDEV
45 If unsure, say Y. 45 If unsure, say Y.
46 46
47menu "USB HID Boot Protocol drivers" 47menu "USB HID Boot Protocol drivers"
48 depends on USB!=n && USB_HID!=y 48 depends on USB!=n && USB_HID!=y && EMBEDDED
49 49
50config USB_KBD 50config USB_KBD
51 tristate "USB HIDBP Keyboard (simple Boot) support" 51 tristate "USB HIDBP Keyboard (simple Boot) support"
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 606369ea24ca..03cb494af1c5 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -4,7 +4,7 @@
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2008 Jiri Kosina
8 */ 8 */
9 9
10/* 10/*
@@ -641,9 +641,7 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type,
641 unsigned int size; 641 unsigned int size;
642 642
643 list_for_each_entry(report, &hid->report_enum[type].report_list, list) { 643 list_for_each_entry(report, &hid->report_enum[type].report_list, list) {
644 size = ((report->size - 1) >> 3) + 1; 644 size = ((report->size - 1) >> 3) + 1 + hid->report_enum[type].numbered;
645 if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered)
646 size++;
647 if (*max < size) 645 if (*max < size)
648 *max = size; 646 *max = size;
649 } 647 }
@@ -653,13 +651,16 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
653{ 651{
654 struct usbhid_device *usbhid = hid->driver_data; 652 struct usbhid_device *usbhid = hid->driver_data;
655 653
656 if (!(usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->inbuf_dma))) 654 usbhid->inbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
657 return -1; 655 &usbhid->inbuf_dma);
658 if (!(usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->outbuf_dma))) 656 usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
659 return -1; 657 &usbhid->outbuf_dma);
660 if (!(usbhid->cr = usb_buffer_alloc(dev, sizeof(*(usbhid->cr)), GFP_ATOMIC, &usbhid->cr_dma))) 658 usbhid->cr = usb_buffer_alloc(dev, sizeof(*usbhid->cr), GFP_KERNEL,
661 return -1; 659 &usbhid->cr_dma);
662 if (!(usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_ATOMIC, &usbhid->ctrlbuf_dma))) 660 usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
661 &usbhid->ctrlbuf_dma);
662 if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr ||
663 !usbhid->ctrlbuf)
663 return -1; 664 return -1;
664 665
665 return 0; 666 return 0;
@@ -807,7 +808,7 @@ static int usbhid_start(struct hid_device *hid)
807 int interval; 808 int interval;
808 809
809 endpoint = &interface->endpoint[n].desc; 810 endpoint = &interface->endpoint[n].desc;
810 if ((endpoint->bmAttributes & 3) != 3) /* Not an interrupt endpoint */ 811 if (!usb_endpoint_xfer_int(endpoint))
811 continue; 812 continue;
812 813
813 interval = endpoint->bInterval; 814 interval = endpoint->bInterval;
@@ -876,6 +877,15 @@ static int usbhid_start(struct hid_device *hid)
876 877
877 set_bit(HID_STARTED, &usbhid->iofl); 878 set_bit(HID_STARTED, &usbhid->iofl);
878 879
880 /* Some keyboards don't work until their LEDs have been set.
881 * Since BIOSes do set the LEDs, it must be safe for any device
882 * that supports the keyboard boot protocol.
883 */
884 if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT &&
885 interface->desc.bInterfaceProtocol ==
886 USB_INTERFACE_PROTOCOL_KEYBOARD)
887 usbhid_set_leds(hid);
888
879 return 0; 889 return 0;
880 890
881fail: 891fail:
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 47ebe045f9b5..4391717d2519 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -54,6 +54,7 @@ static const struct hid_blacklist {
54 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 54 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 55 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
56 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 56 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
57 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
57 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, 58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
58 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 59 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
59 60
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 83e851a5ed30..6a98f9f572b0 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -49,6 +49,7 @@
49struct hiddev { 49struct hiddev {
50 int exist; 50 int exist;
51 int open; 51 int open;
52 struct mutex existancelock;
52 wait_queue_head_t wait; 53 wait_queue_head_t wait;
53 struct hid_device *hid; 54 struct hid_device *hid;
54 struct list_head list; 55 struct list_head list;
@@ -63,6 +64,7 @@ struct hiddev_list {
63 struct fasync_struct *fasync; 64 struct fasync_struct *fasync;
64 struct hiddev *hiddev; 65 struct hiddev *hiddev;
65 struct list_head node; 66 struct list_head node;
67 struct mutex thread_lock;
66}; 68};
67 69
68static struct hiddev *hiddev_table[HIDDEV_MINORS]; 70static struct hiddev *hiddev_table[HIDDEV_MINORS];
@@ -264,29 +266,48 @@ static int hiddev_release(struct inode * inode, struct file * file)
264static int hiddev_open(struct inode *inode, struct file *file) 266static int hiddev_open(struct inode *inode, struct file *file)
265{ 267{
266 struct hiddev_list *list; 268 struct hiddev_list *list;
267 unsigned long flags; 269 int res;
268 270
269 int i = iminor(inode) - HIDDEV_MINOR_BASE; 271 int i = iminor(inode) - HIDDEV_MINOR_BASE;
270 272
271 if (i >= HIDDEV_MINORS || !hiddev_table[i]) 273 if (i >= HIDDEV_MINORS || i < 0 || !hiddev_table[i])
272 return -ENODEV; 274 return -ENODEV;
273 275
274 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) 276 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL)))
275 return -ENOMEM; 277 return -ENOMEM;
278 mutex_init(&list->thread_lock);
276 279
277 list->hiddev = hiddev_table[i]; 280 list->hiddev = hiddev_table[i];
278 281
279 spin_lock_irqsave(&list->hiddev->list_lock, flags);
280 list_add_tail(&list->node, &hiddev_table[i]->list);
281 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
282 282
283 file->private_data = list; 283 file->private_data = list;
284 284
285 if (!list->hiddev->open++) 285 /*
286 if (list->hiddev->exist) 286 * no need for locking because the USB major number
287 usbhid_open(hiddev_table[i]->hid); 287 * is shared which usbcore guards against disconnect
288 */
289 if (list->hiddev->exist) {
290 if (!list->hiddev->open++) {
291 res = usbhid_open(hiddev_table[i]->hid);
292 if (res < 0) {
293 res = -EIO;
294 goto bail;
295 }
296 }
297 } else {
298 res = -ENODEV;
299 goto bail;
300 }
301
302 spin_lock_irq(&list->hiddev->list_lock);
303 list_add_tail(&list->node, &hiddev_table[i]->list);
304 spin_unlock_irq(&list->hiddev->list_lock);
288 305
289 return 0; 306 return 0;
307bail:
308 file->private_data = NULL;
309 kfree(list->hiddev);
310 return res;
290} 311}
291 312
292/* 313/*
@@ -305,7 +326,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
305 DECLARE_WAITQUEUE(wait, current); 326 DECLARE_WAITQUEUE(wait, current);
306 struct hiddev_list *list = file->private_data; 327 struct hiddev_list *list = file->private_data;
307 int event_size; 328 int event_size;
308 int retval = 0; 329 int retval;
309 330
310 event_size = ((list->flags & HIDDEV_FLAG_UREF) != 0) ? 331 event_size = ((list->flags & HIDDEV_FLAG_UREF) != 0) ?
311 sizeof(struct hiddev_usage_ref) : sizeof(struct hiddev_event); 332 sizeof(struct hiddev_usage_ref) : sizeof(struct hiddev_event);
@@ -313,10 +334,14 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
313 if (count < event_size) 334 if (count < event_size)
314 return 0; 335 return 0;
315 336
337 /* lock against other threads */
338 retval = mutex_lock_interruptible(&list->thread_lock);
339 if (retval)
340 return -ERESTARTSYS;
341
316 while (retval == 0) { 342 while (retval == 0) {
317 if (list->head == list->tail) { 343 if (list->head == list->tail) {
318 add_wait_queue(&list->hiddev->wait, &wait); 344 prepare_to_wait(&list->hiddev->wait, &wait, TASK_INTERRUPTIBLE);
319 set_current_state(TASK_INTERRUPTIBLE);
320 345
321 while (list->head == list->tail) { 346 while (list->head == list->tail) {
322 if (file->f_flags & O_NONBLOCK) { 347 if (file->f_flags & O_NONBLOCK) {
@@ -332,35 +357,45 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
332 break; 357 break;
333 } 358 }
334 359
360 /* let O_NONBLOCK tasks run */
361 mutex_unlock(&list->thread_lock);
335 schedule(); 362 schedule();
363 if (mutex_lock_interruptible(&list->thread_lock))
364 return -EINTR;
336 set_current_state(TASK_INTERRUPTIBLE); 365 set_current_state(TASK_INTERRUPTIBLE);
337 } 366 }
367 finish_wait(&list->hiddev->wait, &wait);
338 368
339 set_current_state(TASK_RUNNING);
340 remove_wait_queue(&list->hiddev->wait, &wait);
341 } 369 }
342 370
343 if (retval) 371 if (retval) {
372 mutex_unlock(&list->thread_lock);
344 return retval; 373 return retval;
374 }
345 375
346 376
347 while (list->head != list->tail && 377 while (list->head != list->tail &&
348 retval + event_size <= count) { 378 retval + event_size <= count) {
349 if ((list->flags & HIDDEV_FLAG_UREF) == 0) { 379 if ((list->flags & HIDDEV_FLAG_UREF) == 0) {
350 if (list->buffer[list->tail].field_index != 380 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE) {
351 HID_FIELD_INDEX_NONE) {
352 struct hiddev_event event; 381 struct hiddev_event event;
382
353 event.hid = list->buffer[list->tail].usage_code; 383 event.hid = list->buffer[list->tail].usage_code;
354 event.value = list->buffer[list->tail].value; 384 event.value = list->buffer[list->tail].value;
355 if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event))) 385 if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event))) {
386 mutex_unlock(&list->thread_lock);
356 return -EFAULT; 387 return -EFAULT;
388 }
357 retval += sizeof(struct hiddev_event); 389 retval += sizeof(struct hiddev_event);
358 } 390 }
359 } else { 391 } else {
360 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE || 392 if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE ||
361 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 393 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
362 if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref))) 394
395 if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref))) {
396 mutex_unlock(&list->thread_lock);
363 return -EFAULT; 397 return -EFAULT;
398 }
364 retval += sizeof(struct hiddev_usage_ref); 399 retval += sizeof(struct hiddev_usage_ref);
365 } 400 }
366 } 401 }
@@ -368,6 +403,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
368 } 403 }
369 404
370 } 405 }
406 mutex_unlock(&list->thread_lock);
371 407
372 return retval; 408 return retval;
373} 409}
@@ -555,7 +591,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
555 struct hid_field *field; 591 struct hid_field *field;
556 struct usbhid_device *usbhid = hid->driver_data; 592 struct usbhid_device *usbhid = hid->driver_data;
557 void __user *user_arg = (void __user *)arg; 593 void __user *user_arg = (void __user *)arg;
558 int i; 594 int i, r;
559 595
560 /* Called without BKL by compat methods so no BKL taken */ 596 /* Called without BKL by compat methods so no BKL taken */
561 597
@@ -619,10 +655,22 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
619 } 655 }
620 656
621 case HIDIOCGSTRING: 657 case HIDIOCGSTRING:
622 return hiddev_ioctl_string(hiddev, cmd, user_arg); 658 mutex_lock(&hiddev->existancelock);
659 if (!hiddev->exist)
660 r = hiddev_ioctl_string(hiddev, cmd, user_arg);
661 else
662 r = -ENODEV;
663 mutex_unlock(&hiddev->existancelock);
664 return r;
623 665
624 case HIDIOCINITREPORT: 666 case HIDIOCINITREPORT:
667 mutex_lock(&hiddev->existancelock);
668 if (!hiddev->exist) {
669 mutex_unlock(&hiddev->existancelock);
670 return -ENODEV;
671 }
625 usbhid_init_reports(hid); 672 usbhid_init_reports(hid);
673 mutex_unlock(&hiddev->existancelock);
626 674
627 return 0; 675 return 0;
628 676
@@ -636,8 +684,12 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
636 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 684 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
637 return -EINVAL; 685 return -EINVAL;
638 686
639 usbhid_submit_report(hid, report, USB_DIR_IN); 687 mutex_lock(&hiddev->existancelock);
640 usbhid_wait_io(hid); 688 if (hiddev->exist) {
689 usbhid_submit_report(hid, report, USB_DIR_IN);
690 usbhid_wait_io(hid);
691 }
692 mutex_unlock(&hiddev->existancelock);
641 693
642 return 0; 694 return 0;
643 695
@@ -651,8 +703,12 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
651 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) 703 if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL)
652 return -EINVAL; 704 return -EINVAL;
653 705
654 usbhid_submit_report(hid, report, USB_DIR_OUT); 706 mutex_lock(&hiddev->existancelock);
655 usbhid_wait_io(hid); 707 if (hiddev->exist) {
708 usbhid_submit_report(hid, report, USB_DIR_OUT);
709 usbhid_wait_io(hid);
710 }
711 mutex_unlock(&hiddev->existancelock);
656 712
657 return 0; 713 return 0;
658 714
@@ -710,7 +766,13 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
710 case HIDIOCGUSAGES: 766 case HIDIOCGUSAGES:
711 case HIDIOCSUSAGES: 767 case HIDIOCSUSAGES:
712 case HIDIOCGCOLLECTIONINDEX: 768 case HIDIOCGCOLLECTIONINDEX:
713 return hiddev_ioctl_usage(hiddev, cmd, user_arg); 769 mutex_lock(&hiddev->existancelock);
770 if (hiddev->exist)
771 r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
772 else
773 r = -ENODEV;
774 mutex_unlock(&hiddev->existancelock);
775 return r;
714 776
715 case HIDIOCGCOLLECTIONINFO: 777 case HIDIOCGCOLLECTIONINFO:
716 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) 778 if (copy_from_user(&cinfo, user_arg, sizeof(cinfo)))
@@ -808,23 +870,22 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
808 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL))) 870 if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
809 return -1; 871 return -1;
810 872
811 retval = usb_register_dev(usbhid->intf, &hiddev_class);
812 if (retval) {
813 err_hid("Not able to get a minor for this device.");
814 kfree(hiddev);
815 return -1;
816 }
817
818 init_waitqueue_head(&hiddev->wait); 873 init_waitqueue_head(&hiddev->wait);
819 INIT_LIST_HEAD(&hiddev->list); 874 INIT_LIST_HEAD(&hiddev->list);
820 spin_lock_init(&hiddev->list_lock); 875 spin_lock_init(&hiddev->list_lock);
876 mutex_init(&hiddev->existancelock);
821 hiddev->hid = hid; 877 hiddev->hid = hid;
822 hiddev->exist = 1; 878 hiddev->exist = 1;
823 879
824 hid->minor = usbhid->intf->minor; 880 retval = usb_register_dev(usbhid->intf, &hiddev_class);
825 hid->hiddev = hiddev; 881 if (retval) {
826 882 err_hid("Not able to get a minor for this device.");
827 hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev; 883 kfree(hiddev);
884 return -1;
885 } else {
886 hid->minor = usbhid->intf->minor;
887 hiddev_table[usbhid->intf->minor - HIDDEV_MINOR_BASE] = hiddev;
888 }
828 889
829 return 0; 890 return 0;
830} 891}
@@ -839,7 +900,9 @@ void hiddev_disconnect(struct hid_device *hid)
839 struct hiddev *hiddev = hid->hiddev; 900 struct hiddev *hiddev = hid->hiddev;
840 struct usbhid_device *usbhid = hid->driver_data; 901 struct usbhid_device *usbhid = hid->driver_data;
841 902
903 mutex_lock(&hiddev->existancelock);
842 hiddev->exist = 0; 904 hiddev->exist = 0;
905 mutex_unlock(&hiddev->existancelock);
843 906
844 hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL; 907 hiddev_table[hiddev->hid->minor - HIDDEV_MINOR_BASE] = NULL;
845 usb_deregister_dev(usbhid->intf, &hiddev_class); 908 usb_deregister_dev(usbhid->intf, &hiddev_class);
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h
index 332abcdf9956..9eb30564be9c 100644
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -40,6 +40,16 @@ int usbhid_open(struct hid_device *hid);
40void usbhid_init_reports(struct hid_device *hid); 40void usbhid_init_reports(struct hid_device *hid);
41void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir); 41void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir);
42 42
43/* iofl flags */
44#define HID_CTRL_RUNNING 1
45#define HID_OUT_RUNNING 2
46#define HID_IN_RUNNING 3
47#define HID_RESET_PENDING 4
48#define HID_SUSPENDED 5
49#define HID_CLEAR_HALT 6
50#define HID_DISCONNECTED 7
51#define HID_STARTED 8
52
43/* 53/*
44 * USB-specific HID struct, to be pointed to 54 * USB-specific HID struct, to be pointed to
45 * from struct hid_device->driver_data 55 * from struct hid_device->driver_data
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 608038d64f81..be8ee2cac8bb 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -2,13 +2,16 @@
2 * TI OMAP I2C master mode driver 2 * TI OMAP I2C master mode driver
3 * 3 *
4 * Copyright (C) 2003 MontaVista Software, Inc. 4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Copyright (C) 2004 Texas Instruments.
6 *
7 * Updated to work with multiple I2C interfaces on 24xx by
8 * Tony Lindgren <tony@atomide.com> and Imre Deak <imre.deak@nokia.com>
9 * Copyright (C) 2005 Nokia Corporation 5 * Copyright (C) 2005 Nokia Corporation
6 * Copyright (C) 2004 - 2007 Texas Instruments.
10 * 7 *
11 * Cleaned up by Juha Yrjölä <juha.yrjola@nokia.com> 8 * Originally written by MontaVista Software, Inc.
9 * Additional contributions by:
10 * Tony Lindgren <tony@atomide.com>
11 * Imre Deak <imre.deak@nokia.com>
12 * Juha Yrjölä <juha.yrjola@solidboot.com>
13 * Syed Khasim <x0khasim@ti.com>
14 * Nishant Menon <nm@ti.com>
12 * 15 *
13 * 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
14 * 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
@@ -33,8 +36,14 @@
33#include <linux/completion.h> 36#include <linux/completion.h>
34#include <linux/platform_device.h> 37#include <linux/platform_device.h>
35#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/io.h>
40
41/* I2C controller revisions */
42#define OMAP_I2C_REV_2 0x20
36 43
37#include <asm/io.h> 44/* I2C controller revisions present on specific hardware */
45#define OMAP_I2C_REV_ON_2430 0x36
46#define OMAP_I2C_REV_ON_3430 0x3C
38 47
39/* timeout waiting for the controller to respond */ 48/* timeout waiting for the controller to respond */
40#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) 49#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
@@ -43,6 +52,8 @@
43#define OMAP_I2C_IE_REG 0x04 52#define OMAP_I2C_IE_REG 0x04
44#define OMAP_I2C_STAT_REG 0x08 53#define OMAP_I2C_STAT_REG 0x08
45#define OMAP_I2C_IV_REG 0x0c 54#define OMAP_I2C_IV_REG 0x0c
55/* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
56#define OMAP_I2C_WE_REG 0x0c
46#define OMAP_I2C_SYSS_REG 0x10 57#define OMAP_I2C_SYSS_REG 0x10
47#define OMAP_I2C_BUF_REG 0x14 58#define OMAP_I2C_BUF_REG 0x14
48#define OMAP_I2C_CNT_REG 0x18 59#define OMAP_I2C_CNT_REG 0x18
@@ -55,8 +66,11 @@
55#define OMAP_I2C_SCLL_REG 0x34 66#define OMAP_I2C_SCLL_REG 0x34
56#define OMAP_I2C_SCLH_REG 0x38 67#define OMAP_I2C_SCLH_REG 0x38
57#define OMAP_I2C_SYSTEST_REG 0x3c 68#define OMAP_I2C_SYSTEST_REG 0x3c
69#define OMAP_I2C_BUFSTAT_REG 0x40
58 70
59/* I2C Interrupt Enable Register (OMAP_I2C_IE): */ 71/* I2C Interrupt Enable Register (OMAP_I2C_IE): */
72#define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */
73#define OMAP_I2C_IE_RDR (1 << 13) /* RX Buffer drain int enable */
60#define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */ 74#define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */
61#define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */ 75#define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */
62#define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */ 76#define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */
@@ -64,7 +78,8 @@
64#define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */ 78#define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */
65 79
66/* I2C Status Register (OMAP_I2C_STAT): */ 80/* I2C Status Register (OMAP_I2C_STAT): */
67#define OMAP_I2C_STAT_SBD (1 << 15) /* Single byte data */ 81#define OMAP_I2C_STAT_XDR (1 << 14) /* TX Buffer draining */
82#define OMAP_I2C_STAT_RDR (1 << 13) /* RX Buffer draining */
68#define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */ 83#define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */
69#define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */ 84#define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */
70#define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */ 85#define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
@@ -76,13 +91,34 @@
76#define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */ 91#define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */
77#define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */ 92#define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */
78 93
94/* I2C WE wakeup enable register */
95#define OMAP_I2C_WE_XDR_WE (1 << 14) /* TX drain wakup */
96#define OMAP_I2C_WE_RDR_WE (1 << 13) /* RX drain wakeup */
97#define OMAP_I2C_WE_AAS_WE (1 << 9) /* Address as slave wakeup*/
98#define OMAP_I2C_WE_BF_WE (1 << 8) /* Bus free wakeup */
99#define OMAP_I2C_WE_STC_WE (1 << 6) /* Start condition wakeup */
100#define OMAP_I2C_WE_GC_WE (1 << 5) /* General call wakeup */
101#define OMAP_I2C_WE_DRDY_WE (1 << 3) /* TX/RX data ready wakeup */
102#define OMAP_I2C_WE_ARDY_WE (1 << 2) /* Reg access ready wakeup */
103#define OMAP_I2C_WE_NACK_WE (1 << 1) /* No acknowledgment wakeup */
104#define OMAP_I2C_WE_AL_WE (1 << 0) /* Arbitration lost wakeup */
105
106#define OMAP_I2C_WE_ALL (OMAP_I2C_WE_XDR_WE | OMAP_I2C_WE_RDR_WE | \
107 OMAP_I2C_WE_AAS_WE | OMAP_I2C_WE_BF_WE | \
108 OMAP_I2C_WE_STC_WE | OMAP_I2C_WE_GC_WE | \
109 OMAP_I2C_WE_DRDY_WE | OMAP_I2C_WE_ARDY_WE | \
110 OMAP_I2C_WE_NACK_WE | OMAP_I2C_WE_AL_WE)
111
79/* I2C Buffer Configuration Register (OMAP_I2C_BUF): */ 112/* I2C Buffer Configuration Register (OMAP_I2C_BUF): */
80#define OMAP_I2C_BUF_RDMA_EN (1 << 15) /* RX DMA channel enable */ 113#define OMAP_I2C_BUF_RDMA_EN (1 << 15) /* RX DMA channel enable */
114#define OMAP_I2C_BUF_RXFIF_CLR (1 << 14) /* RX FIFO Clear */
81#define OMAP_I2C_BUF_XDMA_EN (1 << 7) /* TX DMA channel enable */ 115#define OMAP_I2C_BUF_XDMA_EN (1 << 7) /* TX DMA channel enable */
116#define OMAP_I2C_BUF_TXFIF_CLR (1 << 6) /* TX FIFO Clear */
82 117
83/* I2C Configuration Register (OMAP_I2C_CON): */ 118/* I2C Configuration Register (OMAP_I2C_CON): */
84#define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */ 119#define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */
85#define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */ 120#define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */
121#define OMAP_I2C_CON_OPMODE_HS (1 << 12) /* High Speed support */
86#define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */ 122#define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */
87#define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */ 123#define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */
88#define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */ 124#define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */
@@ -91,6 +127,10 @@
91#define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */ 127#define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */
92#define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */ 128#define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */
93 129
130/* I2C SCL time value when Master */
131#define OMAP_I2C_SCLL_HSSCLL 8
132#define OMAP_I2C_SCLH_HSSCLH 8
133
94/* I2C System Test Register (OMAP_I2C_SYSTEST): */ 134/* I2C System Test Register (OMAP_I2C_SYSTEST): */
95#ifdef DEBUG 135#ifdef DEBUG
96#define OMAP_I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */ 136#define OMAP_I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
@@ -103,17 +143,19 @@
103#define OMAP_I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive out */ 143#define OMAP_I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive out */
104#endif 144#endif
105 145
106/* I2C System Status register (OMAP_I2C_SYSS): */ 146/* OCP_SYSSTATUS bit definitions */
107#define OMAP_I2C_SYSS_RDONE (1 << 0) /* Reset Done */ 147#define SYSS_RESETDONE_MASK (1 << 0)
148
149/* OCP_SYSCONFIG bit definitions */
150#define SYSC_CLOCKACTIVITY_MASK (0x3 << 8)
151#define SYSC_SIDLEMODE_MASK (0x3 << 3)
152#define SYSC_ENAWAKEUP_MASK (1 << 2)
153#define SYSC_SOFTRESET_MASK (1 << 1)
154#define SYSC_AUTOIDLE_MASK (1 << 0)
108 155
109/* I2C System Configuration Register (OMAP_I2C_SYSC): */ 156#define SYSC_IDLEMODE_SMART 0x2
110#define OMAP_I2C_SYSC_SRST (1 << 1) /* Soft Reset */ 157#define SYSC_CLOCKACTIVITY_FCLK 0x2
111 158
112/* REVISIT: Use platform_data instead of module parameters */
113/* Fast Mode = 400 kHz, Standard = 100 kHz */
114static int clock = 100; /* Default: 100 kHz */
115module_param(clock, int, 0);
116MODULE_PARM_DESC(clock, "Set I2C clock in kHz: 400=fast mode (default == 100)");
117 159
118struct omap_i2c_dev { 160struct omap_i2c_dev {
119 struct device *dev; 161 struct device *dev;
@@ -123,11 +165,17 @@ struct omap_i2c_dev {
123 struct clk *fclk; /* Functional clock */ 165 struct clk *fclk; /* Functional clock */
124 struct completion cmd_complete; 166 struct completion cmd_complete;
125 struct resource *ioarea; 167 struct resource *ioarea;
168 u32 speed; /* Speed of bus in Khz */
126 u16 cmd_err; 169 u16 cmd_err;
127 u8 *buf; 170 u8 *buf;
128 size_t buf_len; 171 size_t buf_len;
129 struct i2c_adapter adapter; 172 struct i2c_adapter adapter;
130 unsigned rev1:1; 173 u8 fifo_size; /* use as flag and value
174 * fifo_size==0 implies no fifo
175 * if set, should be trsh+1
176 */
177 u8 rev;
178 unsigned b_hw:1; /* bad h/w fixes */
131 unsigned idle:1; 179 unsigned idle:1;
132 u16 iestate; /* Saved interrupt register */ 180 u16 iestate; /* Saved interrupt register */
133}; 181};
@@ -143,9 +191,9 @@ static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
143 return __raw_readw(i2c_dev->base + reg); 191 return __raw_readw(i2c_dev->base + reg);
144} 192}
145 193
146static int omap_i2c_get_clocks(struct omap_i2c_dev *dev) 194static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev)
147{ 195{
148 if (cpu_is_omap16xx() || cpu_is_omap24xx()) { 196 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
149 dev->iclk = clk_get(dev->dev, "i2c_ick"); 197 dev->iclk = clk_get(dev->dev, "i2c_ick");
150 if (IS_ERR(dev->iclk)) { 198 if (IS_ERR(dev->iclk)) {
151 dev->iclk = NULL; 199 dev->iclk = NULL;
@@ -178,25 +226,33 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
178 226
179static void omap_i2c_unidle(struct omap_i2c_dev *dev) 227static void omap_i2c_unidle(struct omap_i2c_dev *dev)
180{ 228{
229 WARN_ON(!dev->idle);
230
181 if (dev->iclk != NULL) 231 if (dev->iclk != NULL)
182 clk_enable(dev->iclk); 232 clk_enable(dev->iclk);
183 clk_enable(dev->fclk); 233 clk_enable(dev->fclk);
234 dev->idle = 0;
184 if (dev->iestate) 235 if (dev->iestate)
185 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); 236 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
186 dev->idle = 0;
187} 237}
188 238
189static void omap_i2c_idle(struct omap_i2c_dev *dev) 239static void omap_i2c_idle(struct omap_i2c_dev *dev)
190{ 240{
191 u16 iv; 241 u16 iv;
192 242
193 dev->idle = 1; 243 WARN_ON(dev->idle);
244
194 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 245 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
195 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0); 246 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
196 if (dev->rev1) 247 if (dev->rev < OMAP_I2C_REV_2) {
197 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */ 248 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
198 else 249 } else {
199 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate); 250 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
251
252 /* Flush posted write before the dev->idle store occurs */
253 omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
254 }
255 dev->idle = 1;
200 clk_disable(dev->fclk); 256 clk_disable(dev->fclk);
201 if (dev->iclk != NULL) 257 if (dev->iclk != NULL)
202 clk_disable(dev->iclk); 258 clk_disable(dev->iclk);
@@ -204,18 +260,20 @@ static void omap_i2c_idle(struct omap_i2c_dev *dev)
204 260
205static int omap_i2c_init(struct omap_i2c_dev *dev) 261static int omap_i2c_init(struct omap_i2c_dev *dev)
206{ 262{
207 u16 psc = 0; 263 u16 psc = 0, scll = 0, sclh = 0;
264 u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
208 unsigned long fclk_rate = 12000000; 265 unsigned long fclk_rate = 12000000;
209 unsigned long timeout; 266 unsigned long timeout;
267 unsigned long internal_clk = 0;
210 268
211 if (!dev->rev1) { 269 if (dev->rev >= OMAP_I2C_REV_2) {
212 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, OMAP_I2C_SYSC_SRST); 270 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
213 /* For some reason we need to set the EN bit before the 271 /* For some reason we need to set the EN bit before the
214 * reset done bit gets set. */ 272 * reset done bit gets set. */
215 timeout = jiffies + OMAP_I2C_TIMEOUT; 273 timeout = jiffies + OMAP_I2C_TIMEOUT;
216 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 274 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
217 while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) & 275 while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
218 OMAP_I2C_SYSS_RDONE)) { 276 SYSS_RESETDONE_MASK)) {
219 if (time_after(jiffies, timeout)) { 277 if (time_after(jiffies, timeout)) {
220 dev_warn(dev->dev, "timeout waiting " 278 dev_warn(dev->dev, "timeout waiting "
221 "for controller reset\n"); 279 "for controller reset\n");
@@ -223,6 +281,33 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
223 } 281 }
224 msleep(1); 282 msleep(1);
225 } 283 }
284
285 /* SYSC register is cleared by the reset; rewrite it */
286 if (dev->rev == OMAP_I2C_REV_ON_2430) {
287
288 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
289 SYSC_AUTOIDLE_MASK);
290
291 } else if (dev->rev >= OMAP_I2C_REV_ON_3430) {
292 u32 v;
293
294 v = SYSC_AUTOIDLE_MASK;
295 v |= SYSC_ENAWAKEUP_MASK;
296 v |= (SYSC_IDLEMODE_SMART <<
297 __ffs(SYSC_SIDLEMODE_MASK));
298 v |= (SYSC_CLOCKACTIVITY_FCLK <<
299 __ffs(SYSC_CLOCKACTIVITY_MASK));
300
301 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, v);
302 /*
303 * Enabling all wakup sources to stop I2C freezing on
304 * WFI instruction.
305 * REVISIT: Some wkup sources might not be needed.
306 */
307 omap_i2c_write_reg(dev, OMAP_I2C_WE_REG,
308 OMAP_I2C_WE_ALL);
309
310 }
226 } 311 }
227 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 312 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
228 313
@@ -249,27 +334,65 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
249 psc = fclk_rate / 12000000; 334 psc = fclk_rate / 12000000;
250 } 335 }
251 336
337 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
338
339 /* HSI2C controller internal clk rate should be 19.2 Mhz */
340 internal_clk = 19200;
341 fclk_rate = clk_get_rate(dev->fclk) / 1000;
342
343 /* Compute prescaler divisor */
344 psc = fclk_rate / internal_clk;
345 psc = psc - 1;
346
347 /* If configured for High Speed */
348 if (dev->speed > 400) {
349 /* For first phase of HS mode */
350 fsscll = internal_clk / (400 * 2) - 6;
351 fssclh = internal_clk / (400 * 2) - 6;
352
353 /* For second phase of HS mode */
354 hsscll = fclk_rate / (dev->speed * 2) - 6;
355 hssclh = fclk_rate / (dev->speed * 2) - 6;
356 } else {
357 /* To handle F/S modes */
358 fsscll = internal_clk / (dev->speed * 2) - 6;
359 fssclh = internal_clk / (dev->speed * 2) - 6;
360 }
361 scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
362 sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
363 } else {
364 /* Program desired operating rate */
365 fclk_rate /= (psc + 1) * 1000;
366 if (psc > 2)
367 psc = 2;
368 scll = fclk_rate / (dev->speed * 2) - 7 + psc;
369 sclh = fclk_rate / (dev->speed * 2) - 7 + psc;
370 }
371
252 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ 372 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */
253 omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc); 373 omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc);
254 374
255 /* Program desired operating rate */ 375 /* SCL low and high time values */
256 fclk_rate /= (psc + 1) * 1000; 376 omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, scll);
257 if (psc > 2) 377 omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, sclh);
258 psc = 2;
259 378
260 omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, 379 if (dev->fifo_size)
261 fclk_rate / (clock * 2) - 7 + psc); 380 /* Note: setup required fifo size - 1 */
262 omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, 381 omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG,
263 fclk_rate / (clock * 2) - 7 + psc); 382 (dev->fifo_size - 1) << 8 | /* RTRSH */
383 OMAP_I2C_BUF_RXFIF_CLR |
384 (dev->fifo_size - 1) | /* XTRSH */
385 OMAP_I2C_BUF_TXFIF_CLR);
264 386
265 /* Take the I2C module out of reset: */ 387 /* Take the I2C module out of reset: */
266 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 388 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
267 389
268 /* Enable interrupts */ 390 /* Enable interrupts */
269 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 391 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG,
270 (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | 392 (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY |
271 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | 393 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK |
272 OMAP_I2C_IE_AL)); 394 OMAP_I2C_IE_AL) | ((dev->fifo_size) ?
395 (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0));
273 return 0; 396 return 0;
274} 397}
275 398
@@ -316,20 +439,59 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
316 439
317 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); 440 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len);
318 441
442 /* Clear the FIFO Buffers */
443 w = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG);
444 w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR;
445 omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w);
446
319 init_completion(&dev->cmd_complete); 447 init_completion(&dev->cmd_complete);
320 dev->cmd_err = 0; 448 dev->cmd_err = 0;
321 449
322 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; 450 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT;
451
452 /* High speed configuration */
453 if (dev->speed > 400)
454 w |= OMAP_I2C_CON_OPMODE_HS;
455
323 if (msg->flags & I2C_M_TEN) 456 if (msg->flags & I2C_M_TEN)
324 w |= OMAP_I2C_CON_XA; 457 w |= OMAP_I2C_CON_XA;
325 if (!(msg->flags & I2C_M_RD)) 458 if (!(msg->flags & I2C_M_RD))
326 w |= OMAP_I2C_CON_TRX; 459 w |= OMAP_I2C_CON_TRX;
327 if (stop) 460
461 if (!dev->b_hw && stop)
328 w |= OMAP_I2C_CON_STP; 462 w |= OMAP_I2C_CON_STP;
463
329 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); 464 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
330 465
331 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 466 /*
332 OMAP_I2C_TIMEOUT); 467 * Don't write stt and stp together on some hardware.
468 */
469 if (dev->b_hw && stop) {
470 unsigned long delay = jiffies + OMAP_I2C_TIMEOUT;
471 u16 con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
472 while (con & OMAP_I2C_CON_STT) {
473 con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
474
475 /* Let the user know if i2c is in a bad state */
476 if (time_after(jiffies, delay)) {
477 dev_err(dev->dev, "controller timed out "
478 "waiting for start condition to finish\n");
479 return -ETIMEDOUT;
480 }
481 cpu_relax();
482 }
483
484 w |= OMAP_I2C_CON_STP;
485 w &= ~OMAP_I2C_CON_STT;
486 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
487 }
488
489 /*
490 * REVISIT: We should abort the transfer on signals, but the bus goes
491 * into arbitration and we're currently unable to recover from it.
492 */
493 r = wait_for_completion_timeout(&dev->cmd_complete,
494 OMAP_I2C_TIMEOUT);
333 dev->buf_len = 0; 495 dev->buf_len = 0;
334 if (r < 0) 496 if (r < 0)
335 return r; 497 return r;
@@ -376,7 +538,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
376 538
377 omap_i2c_unidle(dev); 539 omap_i2c_unidle(dev);
378 540
379 if ((r = omap_i2c_wait_for_bb(dev)) < 0) 541 r = omap_i2c_wait_for_bb(dev);
542 if (r < 0)
380 goto out; 543 goto out;
381 544
382 for (i = 0; i < num; i++) { 545 for (i = 0; i < num; i++) {
@@ -411,6 +574,9 @@ omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat)
411 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 574 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
412} 575}
413 576
577/* rev1 devices are apparently only on some 15xx */
578#ifdef CONFIG_ARCH_OMAP15XX
579
414static irqreturn_t 580static irqreturn_t
415omap_i2c_rev1_isr(int this_irq, void *dev_id) 581omap_i2c_rev1_isr(int this_irq, void *dev_id)
416{ 582{
@@ -465,6 +631,9 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
465 631
466 return IRQ_HANDLED; 632 return IRQ_HANDLED;
467} 633}
634#else
635#define omap_i2c_rev1_isr NULL
636#endif
468 637
469static irqreturn_t 638static irqreturn_t
470omap_i2c_isr(int this_irq, void *dev_id) 639omap_i2c_isr(int this_irq, void *dev_id)
@@ -472,7 +641,7 @@ omap_i2c_isr(int this_irq, void *dev_id)
472 struct omap_i2c_dev *dev = dev_id; 641 struct omap_i2c_dev *dev = dev_id;
473 u16 bits; 642 u16 bits;
474 u16 stat, w; 643 u16 stat, w;
475 int count = 0; 644 int err, count = 0;
476 645
477 if (dev->idle) 646 if (dev->idle)
478 return IRQ_NONE; 647 return IRQ_NONE;
@@ -487,39 +656,96 @@ omap_i2c_isr(int this_irq, void *dev_id)
487 656
488 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 657 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
489 658
490 if (stat & OMAP_I2C_STAT_ARDY) { 659 err = 0;
491 omap_i2c_complete_cmd(dev, 0); 660 if (stat & OMAP_I2C_STAT_NACK) {
492 continue; 661 err |= OMAP_I2C_STAT_NACK;
662 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
663 OMAP_I2C_CON_STP);
493 } 664 }
494 if (stat & OMAP_I2C_STAT_RRDY) { 665 if (stat & OMAP_I2C_STAT_AL) {
495 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); 666 dev_err(dev->dev, "Arbitration lost\n");
496 if (dev->buf_len) { 667 err |= OMAP_I2C_STAT_AL;
497 *dev->buf++ = w; 668 }
498 dev->buf_len--; 669 if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
670 OMAP_I2C_STAT_AL))
671 omap_i2c_complete_cmd(dev, err);
672 if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
673 u8 num_bytes = 1;
674 if (dev->fifo_size) {
675 if (stat & OMAP_I2C_STAT_RRDY)
676 num_bytes = dev->fifo_size;
677 else
678 num_bytes = omap_i2c_read_reg(dev,
679 OMAP_I2C_BUFSTAT_REG);
680 }
681 while (num_bytes) {
682 num_bytes--;
683 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
499 if (dev->buf_len) { 684 if (dev->buf_len) {
500 *dev->buf++ = w >> 8; 685 *dev->buf++ = w;
501 dev->buf_len--; 686 dev->buf_len--;
687 /* Data reg from 2430 is 8 bit wide */
688 if (!cpu_is_omap2430() &&
689 !cpu_is_omap34xx()) {
690 if (dev->buf_len) {
691 *dev->buf++ = w >> 8;
692 dev->buf_len--;
693 }
694 }
695 } else {
696 if (stat & OMAP_I2C_STAT_RRDY)
697 dev_err(dev->dev,
698 "RRDY IRQ while no data"
699 " requested\n");
700 if (stat & OMAP_I2C_STAT_RDR)
701 dev_err(dev->dev,
702 "RDR IRQ while no data"
703 " requested\n");
704 break;
502 } 705 }
503 } else 706 }
504 dev_err(dev->dev, "RRDY IRQ while no data " 707 omap_i2c_ack_stat(dev,
505 "requested\n"); 708 stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR));
506 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY);
507 continue; 709 continue;
508 } 710 }
509 if (stat & OMAP_I2C_STAT_XRDY) { 711 if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
510 w = 0; 712 u8 num_bytes = 1;
511 if (dev->buf_len) { 713 if (dev->fifo_size) {
512 w = *dev->buf++; 714 if (stat & OMAP_I2C_STAT_XRDY)
513 dev->buf_len--; 715 num_bytes = dev->fifo_size;
716 else
717 num_bytes = omap_i2c_read_reg(dev,
718 OMAP_I2C_BUFSTAT_REG);
719 }
720 while (num_bytes) {
721 num_bytes--;
722 w = 0;
514 if (dev->buf_len) { 723 if (dev->buf_len) {
515 w |= *dev->buf++ << 8; 724 w = *dev->buf++;
516 dev->buf_len--; 725 dev->buf_len--;
726 /* Data reg from 2430 is 8 bit wide */
727 if (!cpu_is_omap2430() &&
728 !cpu_is_omap34xx()) {
729 if (dev->buf_len) {
730 w |= *dev->buf++ << 8;
731 dev->buf_len--;
732 }
733 }
734 } else {
735 if (stat & OMAP_I2C_STAT_XRDY)
736 dev_err(dev->dev,
737 "XRDY IRQ while no "
738 "data to send\n");
739 if (stat & OMAP_I2C_STAT_XDR)
740 dev_err(dev->dev,
741 "XDR IRQ while no "
742 "data to send\n");
743 break;
517 } 744 }
518 } else 745 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
519 dev_err(dev->dev, "XRDY IRQ while no " 746 }
520 "data to send\n"); 747 omap_i2c_ack_stat(dev,
521 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); 748 stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
522 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY);
523 continue; 749 continue;
524 } 750 }
525 if (stat & OMAP_I2C_STAT_ROVR) { 751 if (stat & OMAP_I2C_STAT_ROVR) {
@@ -527,18 +753,9 @@ omap_i2c_isr(int this_irq, void *dev_id)
527 dev->cmd_err |= OMAP_I2C_STAT_ROVR; 753 dev->cmd_err |= OMAP_I2C_STAT_ROVR;
528 } 754 }
529 if (stat & OMAP_I2C_STAT_XUDF) { 755 if (stat & OMAP_I2C_STAT_XUDF) {
530 dev_err(dev->dev, "Transmit overflow\n"); 756 dev_err(dev->dev, "Transmit underflow\n");
531 dev->cmd_err |= OMAP_I2C_STAT_XUDF; 757 dev->cmd_err |= OMAP_I2C_STAT_XUDF;
532 } 758 }
533 if (stat & OMAP_I2C_STAT_NACK) {
534 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_NACK);
535 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
536 OMAP_I2C_CON_STP);
537 }
538 if (stat & OMAP_I2C_STAT_AL) {
539 dev_err(dev->dev, "Arbitration lost\n");
540 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_AL);
541 }
542 } 759 }
543 760
544 return count ? IRQ_HANDLED : IRQ_NONE; 761 return count ? IRQ_HANDLED : IRQ_NONE;
@@ -549,13 +766,15 @@ static const struct i2c_algorithm omap_i2c_algo = {
549 .functionality = omap_i2c_func, 766 .functionality = omap_i2c_func,
550}; 767};
551 768
552static int 769static int __init
553omap_i2c_probe(struct platform_device *pdev) 770omap_i2c_probe(struct platform_device *pdev)
554{ 771{
555 struct omap_i2c_dev *dev; 772 struct omap_i2c_dev *dev;
556 struct i2c_adapter *adap; 773 struct i2c_adapter *adap;
557 struct resource *mem, *irq, *ioarea; 774 struct resource *mem, *irq, *ioarea;
775 irq_handler_t isr;
558 int r; 776 int r;
777 u32 speed = 0;
559 778
560 /* NOTE: driver uses the static register mapping */ 779 /* NOTE: driver uses the static register mapping */
561 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 780 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -576,17 +795,19 @@ omap_i2c_probe(struct platform_device *pdev)
576 return -EBUSY; 795 return -EBUSY;
577 } 796 }
578 797
579 if (clock > 200)
580 clock = 400; /* Fast mode */
581 else
582 clock = 100; /* Standard mode */
583
584 dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL); 798 dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
585 if (!dev) { 799 if (!dev) {
586 r = -ENOMEM; 800 r = -ENOMEM;
587 goto err_release_region; 801 goto err_release_region;
588 } 802 }
589 803
804 if (pdev->dev.platform_data != NULL)
805 speed = *(u32 *)pdev->dev.platform_data;
806 else
807 speed = 100; /* Defualt speed */
808
809 dev->speed = speed;
810 dev->idle = 1;
590 dev->dev = &pdev->dev; 811 dev->dev = &pdev->dev;
591 dev->irq = irq->start; 812 dev->irq = irq->start;
592 dev->base = ioremap(mem->start, mem->end - mem->start + 1); 813 dev->base = ioremap(mem->start, mem->end - mem->start + 1);
@@ -602,22 +823,39 @@ omap_i2c_probe(struct platform_device *pdev)
602 823
603 omap_i2c_unidle(dev); 824 omap_i2c_unidle(dev);
604 825
605 if (cpu_is_omap15xx()) 826 dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff;
606 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20; 827
828 if (cpu_is_omap2430() || cpu_is_omap34xx()) {
829 u16 s;
830
831 /* Set up the fifo size - Get total size */
832 s = (omap_i2c_read_reg(dev, OMAP_I2C_BUFSTAT_REG) >> 14) & 0x3;
833 dev->fifo_size = 0x8 << s;
834
835 /*
836 * Set up notification threshold as half the total available
837 * size. This is to ensure that we can handle the status on int
838 * call back latencies.
839 */
840 dev->fifo_size = (dev->fifo_size / 2);
841 dev->b_hw = 1; /* Enable hardware fixes */
842 }
607 843
608 /* reset ASAP, clearing any IRQs */ 844 /* reset ASAP, clearing any IRQs */
609 omap_i2c_init(dev); 845 omap_i2c_init(dev);
610 846
611 r = request_irq(dev->irq, dev->rev1 ? omap_i2c_rev1_isr : omap_i2c_isr, 847 isr = (dev->rev < OMAP_I2C_REV_2) ? omap_i2c_rev1_isr : omap_i2c_isr;
612 0, pdev->name, dev); 848 r = request_irq(dev->irq, isr, 0, pdev->name, dev);
613 849
614 if (r) { 850 if (r) {
615 dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); 851 dev_err(dev->dev, "failure requesting irq %i\n", dev->irq);
616 goto err_unuse_clocks; 852 goto err_unuse_clocks;
617 } 853 }
618 r = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff; 854
619 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", 855 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n",
620 pdev->id, r >> 4, r & 0xf, clock); 856 pdev->id, dev->rev >> 4, dev->rev & 0xf, dev->speed);
857
858 omap_i2c_idle(dev);
621 859
622 adap = &dev->adapter; 860 adap = &dev->adapter;
623 i2c_set_adapdata(adap, dev); 861 i2c_set_adapdata(adap, dev);
@@ -635,8 +873,6 @@ omap_i2c_probe(struct platform_device *pdev)
635 goto err_free_irq; 873 goto err_free_irq;
636 } 874 }
637 875
638 omap_i2c_idle(dev);
639
640 return 0; 876 return 0;
641 877
642err_free_irq: 878err_free_irq:
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index c39079f9c73f..f69f91ffb469 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -35,11 +35,9 @@
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/cpufreq.h> 36#include <linux/cpufreq.h>
37 37
38#include <mach/hardware.h>
39#include <asm/irq.h> 38#include <asm/irq.h>
40#include <asm/io.h> 39#include <asm/io.h>
41 40
42#include <mach/regs-gpio.h>
43#include <plat/regs-iic.h> 41#include <plat/regs-iic.h>
44#include <plat/iic.h> 42#include <plat/iic.h>
45 43
@@ -64,6 +62,7 @@ struct s3c24xx_i2c {
64 unsigned int msg_ptr; 62 unsigned int msg_ptr;
65 63
66 unsigned int tx_setup; 64 unsigned int tx_setup;
65 unsigned int irq;
67 66
68 enum s3c24xx_i2c_state state; 67 enum s3c24xx_i2c_state state;
69 unsigned long clkrate; 68 unsigned long clkrate;
@@ -71,7 +70,6 @@ struct s3c24xx_i2c {
71 void __iomem *regs; 70 void __iomem *regs;
72 struct clk *clk; 71 struct clk *clk;
73 struct device *dev; 72 struct device *dev;
74 struct resource *irq;
75 struct resource *ioarea; 73 struct resource *ioarea;
76 struct i2c_adapter adap; 74 struct i2c_adapter adap;
77 75
@@ -80,16 +78,7 @@ struct s3c24xx_i2c {
80#endif 78#endif
81}; 79};
82 80
83/* default platform data to use if not supplied in the platform_device 81/* default platform data removed, dev should always carry data. */
84*/
85
86static struct s3c2410_platform_i2c s3c24xx_i2c_default_platform = {
87 .flags = 0,
88 .slave_addr = 0x10,
89 .bus_freq = 100*1000,
90 .max_freq = 400*1000,
91 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
92};
93 82
94/* s3c24xx_i2c_is2440() 83/* s3c24xx_i2c_is2440()
95 * 84 *
@@ -103,21 +92,6 @@ static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
103 return !strcmp(pdev->name, "s3c2440-i2c"); 92 return !strcmp(pdev->name, "s3c2440-i2c");
104} 93}
105 94
106
107/* s3c24xx_i2c_get_platformdata
108 *
109 * get the platform data associated with the given device, or return
110 * the default if there is none
111*/
112
113static inline struct s3c2410_platform_i2c *s3c24xx_i2c_get_platformdata(struct device *dev)
114{
115 if (dev->platform_data != NULL)
116 return (struct s3c2410_platform_i2c *)dev->platform_data;
117
118 return &s3c24xx_i2c_default_platform;
119}
120
121/* s3c24xx_i2c_master_complete 95/* s3c24xx_i2c_master_complete
122 * 96 *
123 * complete the message and wake up the caller, using the given return code, 97 * complete the message and wake up the caller, using the given return code,
@@ -130,7 +104,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
130 104
131 i2c->msg_ptr = 0; 105 i2c->msg_ptr = 0;
132 i2c->msg = NULL; 106 i2c->msg = NULL;
133 i2c->msg_idx ++; 107 i2c->msg_idx++;
134 i2c->msg_num = 0; 108 i2c->msg_num = 0;
135 if (ret) 109 if (ret)
136 i2c->msg_idx = ret; 110 i2c->msg_idx = ret;
@@ -141,19 +115,17 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
141static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) 115static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c)
142{ 116{
143 unsigned long tmp; 117 unsigned long tmp;
144 118
145 tmp = readl(i2c->regs + S3C2410_IICCON); 119 tmp = readl(i2c->regs + S3C2410_IICCON);
146 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 120 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
147
148} 121}
149 122
150static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c) 123static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
151{ 124{
152 unsigned long tmp; 125 unsigned long tmp;
153 126
154 tmp = readl(i2c->regs + S3C2410_IICCON); 127 tmp = readl(i2c->regs + S3C2410_IICCON);
155 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); 128 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON);
156
157} 129}
158 130
159/* irq enable/disable functions */ 131/* irq enable/disable functions */
@@ -161,7 +133,7 @@ static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c)
161static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c) 133static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
162{ 134{
163 unsigned long tmp; 135 unsigned long tmp;
164 136
165 tmp = readl(i2c->regs + S3C2410_IICCON); 137 tmp = readl(i2c->regs + S3C2410_IICCON);
166 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 138 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
167} 139}
@@ -169,7 +141,7 @@ static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c)
169static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) 141static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
170{ 142{
171 unsigned long tmp; 143 unsigned long tmp;
172 144
173 tmp = readl(i2c->regs + S3C2410_IICCON); 145 tmp = readl(i2c->regs + S3C2410_IICCON);
174 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); 146 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
175} 147}
@@ -177,10 +149,10 @@ static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c)
177 149
178/* s3c24xx_i2c_message_start 150/* s3c24xx_i2c_message_start
179 * 151 *
180 * put the start of a message onto the bus 152 * put the start of a message onto the bus
181*/ 153*/
182 154
183static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, 155static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
184 struct i2c_msg *msg) 156 struct i2c_msg *msg)
185{ 157{
186 unsigned int addr = (msg->addr & 0x7f) << 1; 158 unsigned int addr = (msg->addr & 0x7f) << 1;
@@ -199,15 +171,15 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
199 if (msg->flags & I2C_M_REV_DIR_ADDR) 171 if (msg->flags & I2C_M_REV_DIR_ADDR)
200 addr ^= 1; 172 addr ^= 1;
201 173
202 // todo - check for wether ack wanted or not 174 /* todo - check for wether ack wanted or not */
203 s3c24xx_i2c_enable_ack(i2c); 175 s3c24xx_i2c_enable_ack(i2c);
204 176
205 iiccon = readl(i2c->regs + S3C2410_IICCON); 177 iiccon = readl(i2c->regs + S3C2410_IICCON);
206 writel(stat, i2c->regs + S3C2410_IICSTAT); 178 writel(stat, i2c->regs + S3C2410_IICSTAT);
207 179
208 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); 180 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
209 writeb(addr, i2c->regs + S3C2410_IICDS); 181 writeb(addr, i2c->regs + S3C2410_IICDS);
210 182
211 /* delay here to ensure the data byte has gotten onto the bus 183 /* delay here to ensure the data byte has gotten onto the bus
212 * before the transaction is started */ 184 * before the transaction is started */
213 185
@@ -215,8 +187,8 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
215 187
216 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); 188 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
217 writel(iiccon, i2c->regs + S3C2410_IICCON); 189 writel(iiccon, i2c->regs + S3C2410_IICCON);
218 190
219 stat |= S3C2410_IICSTAT_START; 191 stat |= S3C2410_IICSTAT_START;
220 writel(stat, i2c->regs + S3C2410_IICSTAT); 192 writel(stat, i2c->regs + S3C2410_IICSTAT);
221} 193}
222 194
@@ -227,11 +199,11 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
227 dev_dbg(i2c->dev, "STOP\n"); 199 dev_dbg(i2c->dev, "STOP\n");
228 200
229 /* stop the transfer */ 201 /* stop the transfer */
230 iicstat &= ~ S3C2410_IICSTAT_START; 202 iicstat &= ~S3C2410_IICSTAT_START;
231 writel(iicstat, i2c->regs + S3C2410_IICSTAT); 203 writel(iicstat, i2c->regs + S3C2410_IICSTAT);
232 204
233 i2c->state = STATE_STOP; 205 i2c->state = STATE_STOP;
234 206
235 s3c24xx_i2c_master_complete(i2c, ret); 207 s3c24xx_i2c_master_complete(i2c, ret);
236 s3c24xx_i2c_disable_irq(i2c); 208 s3c24xx_i2c_disable_irq(i2c);
237} 209}
@@ -241,7 +213,7 @@ static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret)
241 213
242/* is_lastmsg() 214/* is_lastmsg()
243 * 215 *
244 * returns TRUE if the current message is the last in the set 216 * returns TRUE if the current message is the last in the set
245*/ 217*/
246 218
247static inline int is_lastmsg(struct s3c24xx_i2c *i2c) 219static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
@@ -289,14 +261,14 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
289 261
290 case STATE_STOP: 262 case STATE_STOP:
291 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); 263 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
292 s3c24xx_i2c_disable_irq(i2c); 264 s3c24xx_i2c_disable_irq(i2c);
293 goto out_ack; 265 goto out_ack;
294 266
295 case STATE_START: 267 case STATE_START:
296 /* last thing we did was send a start condition on the 268 /* last thing we did was send a start condition on the
297 * bus, or started a new i2c message 269 * bus, or started a new i2c message
298 */ 270 */
299 271
300 if (iicstat & S3C2410_IICSTAT_LASTBIT && 272 if (iicstat & S3C2410_IICSTAT_LASTBIT &&
301 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { 273 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
302 /* ack was not received... */ 274 /* ack was not received... */
@@ -322,7 +294,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
322 if (i2c->state == STATE_READ) 294 if (i2c->state == STATE_READ)
323 goto prepare_read; 295 goto prepare_read;
324 296
325 /* fall through to the write state, as we will need to 297 /* fall through to the write state, as we will need to
326 * send a byte as well */ 298 * send a byte as well */
327 299
328 case STATE_WRITE: 300 case STATE_WRITE:
@@ -339,7 +311,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
339 } 311 }
340 } 312 }
341 313
342 retry_write: 314 retry_write:
343 315
344 if (!is_msgend(i2c)) { 316 if (!is_msgend(i2c)) {
345 byte = i2c->msg->buf[i2c->msg_ptr++]; 317 byte = i2c->msg->buf[i2c->msg_ptr++];
@@ -359,9 +331,9 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
359 dev_dbg(i2c->dev, "WRITE: Next Message\n"); 331 dev_dbg(i2c->dev, "WRITE: Next Message\n");
360 332
361 i2c->msg_ptr = 0; 333 i2c->msg_ptr = 0;
362 i2c->msg_idx ++; 334 i2c->msg_idx++;
363 i2c->msg++; 335 i2c->msg++;
364 336
365 /* check to see if we need to do another message */ 337 /* check to see if we need to do another message */
366 if (i2c->msg->flags & I2C_M_NOSTART) { 338 if (i2c->msg->flags & I2C_M_NOSTART) {
367 339
@@ -375,7 +347,6 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
375 347
376 goto retry_write; 348 goto retry_write;
377 } else { 349 } else {
378
379 /* send the new start */ 350 /* send the new start */
380 s3c24xx_i2c_message_start(i2c, i2c->msg); 351 s3c24xx_i2c_message_start(i2c, i2c->msg);
381 i2c->state = STATE_START; 352 i2c->state = STATE_START;
@@ -389,7 +360,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
389 break; 360 break;
390 361
391 case STATE_READ: 362 case STATE_READ:
392 /* we have a byte of data in the data register, do 363 /* we have a byte of data in the data register, do
393 * something with it, and then work out wether we are 364 * something with it, and then work out wether we are
394 * going to do any more read/write 365 * going to do any more read/write
395 */ 366 */
@@ -397,13 +368,13 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
397 byte = readb(i2c->regs + S3C2410_IICDS); 368 byte = readb(i2c->regs + S3C2410_IICDS);
398 i2c->msg->buf[i2c->msg_ptr++] = byte; 369 i2c->msg->buf[i2c->msg_ptr++] = byte;
399 370
400 prepare_read: 371 prepare_read:
401 if (is_msglast(i2c)) { 372 if (is_msglast(i2c)) {
402 /* last byte of buffer */ 373 /* last byte of buffer */
403 374
404 if (is_lastmsg(i2c)) 375 if (is_lastmsg(i2c))
405 s3c24xx_i2c_disable_ack(i2c); 376 s3c24xx_i2c_disable_ack(i2c);
406 377
407 } else if (is_msgend(i2c)) { 378 } else if (is_msgend(i2c)) {
408 /* ok, we've read the entire buffer, see if there 379 /* ok, we've read the entire buffer, see if there
409 * is anything else we need to do */ 380 * is anything else we need to do */
@@ -429,7 +400,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
429 /* acknowlegde the IRQ and get back on with the work */ 400 /* acknowlegde the IRQ and get back on with the work */
430 401
431 out_ack: 402 out_ack:
432 tmp = readl(i2c->regs + S3C2410_IICCON); 403 tmp = readl(i2c->regs + S3C2410_IICCON);
433 tmp &= ~S3C2410_IICCON_IRQPEND; 404 tmp &= ~S3C2410_IICCON_IRQPEND;
434 writel(tmp, i2c->regs + S3C2410_IICCON); 405 writel(tmp, i2c->regs + S3C2410_IICCON);
435 out: 406 out:
@@ -450,19 +421,19 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id)
450 status = readl(i2c->regs + S3C2410_IICSTAT); 421 status = readl(i2c->regs + S3C2410_IICSTAT);
451 422
452 if (status & S3C2410_IICSTAT_ARBITR) { 423 if (status & S3C2410_IICSTAT_ARBITR) {
453 // deal with arbitration loss 424 /* deal with arbitration loss */
454 dev_err(i2c->dev, "deal with arbitration loss\n"); 425 dev_err(i2c->dev, "deal with arbitration loss\n");
455 } 426 }
456 427
457 if (i2c->state == STATE_IDLE) { 428 if (i2c->state == STATE_IDLE) {
458 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n"); 429 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
459 430
460 tmp = readl(i2c->regs + S3C2410_IICCON); 431 tmp = readl(i2c->regs + S3C2410_IICCON);
461 tmp &= ~S3C2410_IICCON_IRQPEND; 432 tmp &= ~S3C2410_IICCON_IRQPEND;
462 writel(tmp, i2c->regs + S3C2410_IICCON); 433 writel(tmp, i2c->regs + S3C2410_IICCON);
463 goto out; 434 goto out;
464 } 435 }
465 436
466 /* pretty much this leaves us with the fact that we've 437 /* pretty much this leaves us with the fact that we've
467 * transmitted or received whatever byte we last sent */ 438 * transmitted or received whatever byte we last sent */
468 439
@@ -485,16 +456,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
485 456
486 while (timeout-- > 0) { 457 while (timeout-- > 0) {
487 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 458 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
488 459
489 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY)) 460 if (!(iicstat & S3C2410_IICSTAT_BUSBUSY))
490 return 0; 461 return 0;
491 462
492 msleep(1); 463 msleep(1);
493 } 464 }
494 465
495 dev_dbg(i2c->dev, "timeout: GPEDAT is %08x\n",
496 __raw_readl(S3C2410_GPEDAT));
497
498 return -ETIMEDOUT; 466 return -ETIMEDOUT;
499} 467}
500 468
@@ -503,7 +471,8 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
503 * this starts an i2c transfer 471 * this starts an i2c transfer
504*/ 472*/
505 473
506static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num) 474static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
475 struct i2c_msg *msgs, int num)
507{ 476{
508 unsigned long timeout; 477 unsigned long timeout;
509 int ret; 478 int ret;
@@ -529,12 +498,12 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
529 s3c24xx_i2c_enable_irq(i2c); 498 s3c24xx_i2c_enable_irq(i2c);
530 s3c24xx_i2c_message_start(i2c, msgs); 499 s3c24xx_i2c_message_start(i2c, msgs);
531 spin_unlock_irq(&i2c->lock); 500 spin_unlock_irq(&i2c->lock);
532 501
533 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); 502 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
534 503
535 ret = i2c->msg_idx; 504 ret = i2c->msg_idx;
536 505
537 /* having these next two as dev_err() makes life very 506 /* having these next two as dev_err() makes life very
538 * noisy when doing an i2cdetect */ 507 * noisy when doing an i2cdetect */
539 508
540 if (timeout == 0) 509 if (timeout == 0)
@@ -591,19 +560,6 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
591 .functionality = s3c24xx_i2c_func, 560 .functionality = s3c24xx_i2c_func,
592}; 561};
593 562
594static struct s3c24xx_i2c s3c24xx_i2c = {
595 .lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
596 .wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
597 .tx_setup = 50,
598 .adap = {
599 .name = "s3c2410-i2c",
600 .owner = THIS_MODULE,
601 .algo = &s3c24xx_i2c_algorithm,
602 .retries = 2,
603 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
604 },
605};
606
607/* s3c24xx_i2c_calcdivisor 563/* s3c24xx_i2c_calcdivisor
608 * 564 *
609 * return the divisor settings for a given frequency 565 * return the divisor settings for a given frequency
@@ -643,7 +599,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
643{ 599{
644 int diff = freq - wanted; 600 int diff = freq - wanted;
645 601
646 return (diff >= -2 && diff <= 2); 602 return diff >= -2 && diff <= 2;
647} 603}
648 604
649/* s3c24xx_i2c_clockrate 605/* s3c24xx_i2c_clockrate
@@ -655,7 +611,7 @@ static inline int freq_acceptable(unsigned int freq, unsigned int wanted)
655 611
656static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) 612static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
657{ 613{
658 struct s3c2410_platform_i2c *pdata; 614 struct s3c2410_platform_i2c *pdata = i2c->dev->platform_data;
659 unsigned long clkin = clk_get_rate(i2c->clk); 615 unsigned long clkin = clk_get_rate(i2c->clk);
660 unsigned int divs, div1; 616 unsigned int divs, div1;
661 u32 iiccon; 617 u32 iiccon;
@@ -663,10 +619,8 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
663 int start, end; 619 int start, end;
664 620
665 i2c->clkrate = clkin; 621 i2c->clkrate = clkin;
666
667 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
668 clkin /= 1000; /* clkin now in KHz */ 622 clkin /= 1000; /* clkin now in KHz */
669 623
670 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n", 624 dev_dbg(i2c->dev, "pdata %p, freq %lu %lu..%lu\n",
671 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq); 625 pdata, pdata->bus_freq, pdata->min_freq, pdata->max_freq);
672 626
@@ -774,7 +728,7 @@ static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c)
774 728
775/* s3c24xx_i2c_init 729/* s3c24xx_i2c_init
776 * 730 *
777 * initialise the controller, set the IO lines and frequency 731 * initialise the controller, set the IO lines and frequency
778*/ 732*/
779 733
780static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) 734static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
@@ -785,15 +739,15 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
785 739
786 /* get the plafrom data */ 740 /* get the plafrom data */
787 741
788 pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent); 742 pdata = i2c->dev->platform_data;
789 743
790 /* inititalise the gpio */ 744 /* inititalise the gpio */
791 745
792 s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA); 746 if (pdata->cfg_gpio)
793 s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL); 747 pdata->cfg_gpio(to_platform_device(i2c->dev));
794 748
795 /* write slave address */ 749 /* write slave address */
796 750
797 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD); 751 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD);
798 752
799 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); 753 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
@@ -831,12 +785,32 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
831 785
832static int s3c24xx_i2c_probe(struct platform_device *pdev) 786static int s3c24xx_i2c_probe(struct platform_device *pdev)
833{ 787{
834 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 788 struct s3c24xx_i2c *i2c;
835 struct s3c2410_platform_i2c *pdata; 789 struct s3c2410_platform_i2c *pdata;
836 struct resource *res; 790 struct resource *res;
837 int ret; 791 int ret;
838 792
839 pdata = s3c24xx_i2c_get_platformdata(&pdev->dev); 793 pdata = pdev->dev.platform_data;
794 if (!pdata) {
795 dev_err(&pdev->dev, "no platform data\n");
796 return -EINVAL;
797 }
798
799 i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
800 if (!i2c) {
801 dev_err(&pdev->dev, "no memory for state\n");
802 return -ENOMEM;
803 }
804
805 strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
806 i2c->adap.owner = THIS_MODULE;
807 i2c->adap.algo = &s3c24xx_i2c_algorithm;
808 i2c->adap.retries = 2;
809 i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
810 i2c->tx_setup = 50;
811
812 spin_lock_init(&i2c->lock);
813 init_waitqueue_head(&i2c->wait);
840 814
841 /* find the clock and enable it */ 815 /* find the clock and enable it */
842 816
@@ -878,7 +852,8 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
878 goto err_ioarea; 852 goto err_ioarea;
879 } 853 }
880 854
881 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 855 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
856 i2c->regs, i2c->ioarea, res);
882 857
883 /* setup info block for the i2c core */ 858 /* setup info block for the i2c core */
884 859
@@ -892,29 +867,23 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
892 goto err_iomap; 867 goto err_iomap;
893 868
894 /* find the IRQ for this unit (note, this relies on the init call to 869 /* find the IRQ for this unit (note, this relies on the init call to
895 * ensure no current IRQs pending 870 * ensure no current IRQs pending
896 */ 871 */
897 872
898 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 873 i2c->irq = ret = platform_get_irq(pdev, 0);
899 if (res == NULL) { 874 if (ret <= 0) {
900 dev_err(&pdev->dev, "cannot find IRQ\n"); 875 dev_err(&pdev->dev, "cannot find IRQ\n");
901 ret = -ENOENT;
902 goto err_iomap; 876 goto err_iomap;
903 } 877 }
904 878
905 ret = request_irq(res->start, s3c24xx_i2c_irq, IRQF_DISABLED, 879 ret = request_irq(i2c->irq, s3c24xx_i2c_irq, IRQF_DISABLED,
906 pdev->name, i2c); 880 dev_name(&pdev->dev), i2c);
907 881
908 if (ret != 0) { 882 if (ret != 0) {
909 dev_err(&pdev->dev, "cannot claim IRQ\n"); 883 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
910 goto err_iomap; 884 goto err_iomap;
911 } 885 }
912 886
913 i2c->irq = res;
914
915 dev_dbg(&pdev->dev, "irq resource %p (%lu)\n", res,
916 (unsigned long)res->start);
917
918 ret = s3c24xx_i2c_register_cpufreq(i2c); 887 ret = s3c24xx_i2c_register_cpufreq(i2c);
919 if (ret < 0) { 888 if (ret < 0) {
920 dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); 889 dev_err(&pdev->dev, "failed to register cpufreq notifier\n");
@@ -944,7 +913,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
944 s3c24xx_i2c_deregister_cpufreq(i2c); 913 s3c24xx_i2c_deregister_cpufreq(i2c);
945 914
946 err_irq: 915 err_irq:
947 free_irq(i2c->irq->start, i2c); 916 free_irq(i2c->irq, i2c);
948 917
949 err_iomap: 918 err_iomap:
950 iounmap(i2c->regs); 919 iounmap(i2c->regs);
@@ -958,6 +927,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
958 clk_put(i2c->clk); 927 clk_put(i2c->clk);
959 928
960 err_noclk: 929 err_noclk:
930 kfree(i2c);
961 return ret; 931 return ret;
962} 932}
963 933
@@ -973,7 +943,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
973 s3c24xx_i2c_deregister_cpufreq(i2c); 943 s3c24xx_i2c_deregister_cpufreq(i2c);
974 944
975 i2c_del_adapter(&i2c->adap); 945 i2c_del_adapter(&i2c->adap);
976 free_irq(i2c->irq->start, i2c); 946 free_irq(i2c->irq, i2c);
977 947
978 clk_disable(i2c->clk); 948 clk_disable(i2c->clk);
979 clk_put(i2c->clk); 949 clk_put(i2c->clk);
@@ -982,6 +952,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
982 952
983 release_resource(i2c->ioarea); 953 release_resource(i2c->ioarea);
984 kfree(i2c->ioarea); 954 kfree(i2c->ioarea);
955 kfree(i2c);
985 956
986 return 0; 957 return 0;
987} 958}
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 4c35702830ce..864ac561fdbb 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -126,19 +126,6 @@ config ISP1301_OMAP
126 This driver can also be built as a module. If so, the module 126 This driver can also be built as a module. If so, the module
127 will be called isp1301_omap. 127 will be called isp1301_omap.
128 128
129config TPS65010
130 tristate "TPS6501x Power Management chips"
131 depends on GPIOLIB
132 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
133 help
134 If you say yes here you get support for the TPS6501x series of
135 Power Management chips. These include voltage regulators,
136 lithium ion/polymer battery charging, and other features that
137 are often used in portable devices like cell phones and cameras.
138
139 This driver can also be built as a module. If so, the module
140 will be called tps65010.
141
142config SENSORS_MAX6875 129config SENSORS_MAX6875
143 tristate "Maxim MAX6875 Power supply supervisor" 130 tristate "Maxim MAX6875 Power supply supervisor"
144 depends on EXPERIMENTAL 131 depends on EXPERIMENTAL
@@ -164,16 +151,6 @@ config SENSORS_TSL2550
164 This driver can also be built as a module. If so, the module 151 This driver can also be built as a module. If so, the module
165 will be called tsl2550. 152 will be called tsl2550.
166 153
167config MENELAUS
168 bool "TWL92330/Menelaus PM chip"
169 depends on I2C=y && ARCH_OMAP24XX
170 help
171 If you say yes here you get support for the Texas Instruments
172 TWL92330/Menelaus Power Management chip. This include voltage
173 regulators, Dual slot memory card tranceivers, real-time clock
174 and other features that are often used in portable devices like
175 cell phones and PDAs.
176
177config MCU_MPC8349EMITX 154config MCU_MPC8349EMITX
178 tristate "MPC8349E-mITX MCU driver" 155 tristate "MPC8349E-mITX MCU driver"
179 depends on I2C && PPC_83xx 156 depends on I2C && PPC_83xx
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 23d2a31b0a64..8b95f41a5001 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -19,8 +19,6 @@ obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
19obj-$(CONFIG_PCF8575) += pcf8575.o 19obj-$(CONFIG_PCF8575) += pcf8575.o
20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
21obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 21obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
22obj-$(CONFIG_TPS65010) += tps65010.o
23obj-$(CONFIG_MENELAUS) += menelaus.o
24obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o 22obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
25obj-$(CONFIG_MCU_MPC8349EMITX) += mcu_mpc8349emitx.o 23obj-$(CONFIG_MCU_MPC8349EMITX) += mcu_mpc8349emitx.o
26 24
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 757035ea246f..3128a5090dbd 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -659,12 +659,12 @@ static inline int find_next_online_cpu(struct ehca_comp_pool *pool)
659 659
660 WARN_ON_ONCE(!in_interrupt()); 660 WARN_ON_ONCE(!in_interrupt());
661 if (ehca_debug_level >= 3) 661 if (ehca_debug_level >= 3)
662 ehca_dmp(&cpu_online_map, sizeof(cpumask_t), ""); 662 ehca_dmp(cpu_online_mask, cpumask_size(), "");
663 663
664 spin_lock_irqsave(&pool->last_cpu_lock, flags); 664 spin_lock_irqsave(&pool->last_cpu_lock, flags);
665 cpu = next_cpu_nr(pool->last_cpu, cpu_online_map); 665 cpu = cpumask_next(pool->last_cpu, cpu_online_mask);
666 if (cpu >= nr_cpu_ids) 666 if (cpu >= nr_cpu_ids)
667 cpu = first_cpu(cpu_online_map); 667 cpu = cpumask_first(cpu_online_mask);
668 pool->last_cpu = cpu; 668 pool->last_cpu = cpu;
669 spin_unlock_irqrestore(&pool->last_cpu_lock, flags); 669 spin_unlock_irqrestore(&pool->last_cpu_lock, flags);
670 670
@@ -855,7 +855,7 @@ static int __cpuinit comp_pool_callback(struct notifier_block *nfb,
855 case CPU_UP_CANCELED_FROZEN: 855 case CPU_UP_CANCELED_FROZEN:
856 ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu); 856 ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
857 cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu); 857 cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
858 kthread_bind(cct->task, any_online_cpu(cpu_online_map)); 858 kthread_bind(cct->task, cpumask_any(cpu_online_mask));
859 destroy_comp_task(pool, cpu); 859 destroy_comp_task(pool, cpu);
860 break; 860 break;
861 case CPU_ONLINE: 861 case CPU_ONLINE:
@@ -902,7 +902,7 @@ int ehca_create_comp_pool(void)
902 return -ENOMEM; 902 return -ENOMEM;
903 903
904 spin_lock_init(&pool->last_cpu_lock); 904 spin_lock_init(&pool->last_cpu_lock);
905 pool->last_cpu = any_online_cpu(cpu_online_map); 905 pool->last_cpu = cpumask_any(cpu_online_mask);
906 906
907 pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task); 907 pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task);
908 if (pool->cpu_comp_tasks == NULL) { 908 if (pool->cpu_comp_tasks == NULL) {
@@ -934,10 +934,9 @@ void ehca_destroy_comp_pool(void)
934 934
935 unregister_hotcpu_notifier(&comp_pool_callback_nb); 935 unregister_hotcpu_notifier(&comp_pool_callback_nb);
936 936
937 for (i = 0; i < NR_CPUS; i++) { 937 for_each_online_cpu(i)
938 if (cpu_online(i)) 938 destroy_comp_task(pool, i);
939 destroy_comp_task(pool, i); 939
940 }
941 free_percpu(pool->cpu_comp_tasks); 940 free_percpu(pool->cpu_comp_tasks);
942 kfree(pool); 941 kfree(pool);
943} 942}
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 239d4e8068ac..23173982b32c 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -1679,7 +1679,7 @@ static int find_best_unit(struct file *fp,
1679 * InfiniPath chip to that processor (we assume reasonable connectivity, 1679 * InfiniPath chip to that processor (we assume reasonable connectivity,
1680 * for now). This code assumes that if affinity has been set 1680 * for now). This code assumes that if affinity has been set
1681 * before this point, that at most one cpu is set; for now this 1681 * before this point, that at most one cpu is set; for now this
1682 * is reasonable. I check for both cpus_empty() and cpus_full(), 1682 * is reasonable. I check for both cpumask_empty() and cpumask_full(),
1683 * in case some kernel variant sets none of the bits when no 1683 * in case some kernel variant sets none of the bits when no
1684 * affinity is set. 2.6.11 and 12 kernels have all present 1684 * affinity is set. 2.6.11 and 12 kernels have all present
1685 * cpus set. Some day we'll have to fix it up further to handle 1685 * cpus set. Some day we'll have to fix it up further to handle
@@ -1688,11 +1688,11 @@ static int find_best_unit(struct file *fp,
1688 * information. There may be some issues with dual core numbering 1688 * information. There may be some issues with dual core numbering
1689 * as well. This needs more work prior to release. 1689 * as well. This needs more work prior to release.
1690 */ 1690 */
1691 if (!cpus_empty(current->cpus_allowed) && 1691 if (!cpumask_empty(&current->cpus_allowed) &&
1692 !cpus_full(current->cpus_allowed)) { 1692 !cpumask_full(&current->cpus_allowed)) {
1693 int ncpus = num_online_cpus(), curcpu = -1, nset = 0; 1693 int ncpus = num_online_cpus(), curcpu = -1, nset = 0;
1694 for (i = 0; i < ncpus; i++) 1694 for (i = 0; i < ncpus; i++)
1695 if (cpu_isset(i, current->cpus_allowed)) { 1695 if (cpumask_test_cpu(i, &current->cpus_allowed)) {
1696 ipath_cdbg(PROC, "%s[%u] affinity set for " 1696 ipath_cdbg(PROC, "%s[%u] affinity set for "
1697 "cpu %d/%d\n", current->comm, 1697 "cpu %d/%d\n", current->comm,
1698 current->pid, i, ncpus); 1698 current->pid, i, ncpus);
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index 53912c327bfe..8dc2bb781605 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -57,9 +57,6 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
57 } 57 }
58 58
59 inode->i_mode = mode; 59 inode->i_mode = mode;
60 inode->i_uid = 0;
61 inode->i_gid = 0;
62 inode->i_blocks = 0;
63 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 60 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
64 inode->i_private = data; 61 inode->i_private = data;
65 if ((mode & S_IFMT) == S_IFDIR) { 62 if ((mode & S_IFMT) == S_IFDIR) {
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index d5b4cc357a3c..650120261abf 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -1519,7 +1519,7 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)
1519 int digit2 = 0; 1519 int digit2 = 0;
1520 if (!isdigit(*s)) return -3; 1520 if (!isdigit(*s)) return -3;
1521 while (isdigit(*s)) { digit1 = digit1*10 + (*s - '0'); s++; } 1521 while (isdigit(*s)) { digit1 = digit1*10 + (*s - '0'); s++; }
1522 if (digit1 <= 0 && digit1 > 30) return -4; 1522 if (digit1 <= 0 || digit1 > 30) return -4;
1523 if (*s == 0 || *s == ',' || *s == ' ') { 1523 if (*s == 0 || *s == ',' || *s == ' ') {
1524 bmask |= (1 << digit1); 1524 bmask |= (1 << digit1);
1525 digit1 = 0; 1525 digit1 = 0;
@@ -1530,7 +1530,7 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)
1530 s++; 1530 s++;
1531 if (!isdigit(*s)) return -3; 1531 if (!isdigit(*s)) return -3;
1532 while (isdigit(*s)) { digit2 = digit2*10 + (*s - '0'); s++; } 1532 while (isdigit(*s)) { digit2 = digit2*10 + (*s - '0'); s++; }
1533 if (digit2 <= 0 && digit2 > 30) return -4; 1533 if (digit2 <= 0 || digit2 > 30) return -4;
1534 if (*s == 0 || *s == ',' || *s == ' ') { 1534 if (*s == 0 || *s == ',' || *s == ' ') {
1535 if (digit1 > digit2) 1535 if (digit1 > digit2)
1536 for (i = digit2; i <= digit1 ; i++) 1536 for (i = digit2; i <= digit1 ; i++)
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index 0aa66ec4cbdd..b129409925af 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -111,8 +111,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
111 goto fail; 111 goto fail;
112 inode->i_ino = 1; 112 inode->i_ino = 1;
113 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 113 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
114 inode->i_blocks = 0;
115 inode->i_uid = inode->i_gid = 0;
116 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 114 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
117 inode->i_op = &simple_dir_inode_operations; 115 inode->i_op = &simple_dir_inode_operations;
118 inode->i_fop = &simple_dir_operations; 116 inode->i_fop = &simple_dir_operations;
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 1c615804ea76..72880b7e28d9 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -3,9 +3,10 @@
3# 3#
4 4
5dm-mod-objs := dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \ 5dm-mod-objs := dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \
6 dm-ioctl.o dm-io.o dm-kcopyd.o 6 dm-ioctl.o dm-io.o dm-kcopyd.o dm-sysfs.o
7dm-multipath-objs := dm-path-selector.o dm-mpath.o 7dm-multipath-objs := dm-path-selector.o dm-mpath.o
8dm-snapshot-objs := dm-snap.o dm-exception-store.o 8dm-snapshot-objs := dm-snap.o dm-exception-store.o dm-snap-transient.o \
9 dm-snap-persistent.o
9dm-mirror-objs := dm-raid1.o 10dm-mirror-objs := dm-raid1.o
10md-mod-objs := md.o bitmap.o 11md-mod-objs := md.o bitmap.o
11raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \ 12raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 3326750ec02c..35bda49796fb 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1322,11 +1322,7 @@ static int __init dm_crypt_init(void)
1322 1322
1323static void __exit dm_crypt_exit(void) 1323static void __exit dm_crypt_exit(void)
1324{ 1324{
1325 int r = dm_unregister_target(&crypt_target); 1325 dm_unregister_target(&crypt_target);
1326
1327 if (r < 0)
1328 DMERR("unregister failed %d", r);
1329
1330 kmem_cache_destroy(_crypt_io_pool); 1326 kmem_cache_destroy(_crypt_io_pool);
1331} 1327}
1332 1328
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 848b381f1173..59ee1b015d2d 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -364,11 +364,7 @@ bad_queue:
364 364
365static void __exit dm_delay_exit(void) 365static void __exit dm_delay_exit(void)
366{ 366{
367 int r = dm_unregister_target(&delay_target); 367 dm_unregister_target(&delay_target);
368
369 if (r < 0)
370 DMERR("unregister failed %d", r);
371
372 kmem_cache_destroy(delayed_cache); 368 kmem_cache_destroy(delayed_cache);
373 destroy_workqueue(kdelayd_wq); 369 destroy_workqueue(kdelayd_wq);
374} 370}
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 01590f3e0009..dccbfb0e010f 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -1,756 +1,45 @@
1/* 1/*
2 * dm-exception-store.c
3 *
4 * Copyright (C) 2001-2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
5 * Copyright (C) 2006 Red Hat GmbH 3 * Copyright (C) 2006-2008 Red Hat GmbH
6 * 4 *
7 * This file is released under the GPL. 5 * This file is released under the GPL.
8 */ 6 */
9 7
10#include "dm-snap.h" 8#include "dm-exception-store.h"
11 9
12#include <linux/mm.h> 10#include <linux/mm.h>
13#include <linux/pagemap.h> 11#include <linux/pagemap.h>
14#include <linux/vmalloc.h> 12#include <linux/vmalloc.h>
15#include <linux/slab.h> 13#include <linux/slab.h>
16#include <linux/dm-io.h>
17#include <linux/dm-kcopyd.h>
18
19#define DM_MSG_PREFIX "snapshots"
20#define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */
21
22/*-----------------------------------------------------------------
23 * Persistent snapshots, by persistent we mean that the snapshot
24 * will survive a reboot.
25 *---------------------------------------------------------------*/
26
27/*
28 * We need to store a record of which parts of the origin have
29 * been copied to the snapshot device. The snapshot code
30 * requires that we copy exception chunks to chunk aligned areas
31 * of the COW store. It makes sense therefore, to store the
32 * metadata in chunk size blocks.
33 *
34 * There is no backward or forward compatibility implemented,
35 * snapshots with different disk versions than the kernel will
36 * not be usable. It is expected that "lvcreate" will blank out
37 * the start of a fresh COW device before calling the snapshot
38 * constructor.
39 *
40 * The first chunk of the COW device just contains the header.
41 * After this there is a chunk filled with exception metadata,
42 * followed by as many exception chunks as can fit in the
43 * metadata areas.
44 *
45 * All on disk structures are in little-endian format. The end
46 * of the exceptions info is indicated by an exception with a
47 * new_chunk of 0, which is invalid since it would point to the
48 * header chunk.
49 */
50
51/*
52 * Magic for persistent snapshots: "SnAp" - Feeble isn't it.
53 */
54#define SNAP_MAGIC 0x70416e53
55
56/*
57 * The on-disk version of the metadata.
58 */
59#define SNAPSHOT_DISK_VERSION 1
60
61struct disk_header {
62 uint32_t magic;
63
64 /*
65 * Is this snapshot valid. There is no way of recovering
66 * an invalid snapshot.
67 */
68 uint32_t valid;
69
70 /*
71 * Simple, incrementing version. no backward
72 * compatibility.
73 */
74 uint32_t version;
75
76 /* In sectors */
77 uint32_t chunk_size;
78};
79
80struct disk_exception {
81 uint64_t old_chunk;
82 uint64_t new_chunk;
83};
84
85struct commit_callback {
86 void (*callback)(void *, int success);
87 void *context;
88};
89
90/*
91 * The top level structure for a persistent exception store.
92 */
93struct pstore {
94 struct dm_snapshot *snap; /* up pointer to my snapshot */
95 int version;
96 int valid;
97 uint32_t exceptions_per_area;
98
99 /*
100 * Now that we have an asynchronous kcopyd there is no
101 * need for large chunk sizes, so it wont hurt to have a
102 * whole chunks worth of metadata in memory at once.
103 */
104 void *area;
105
106 /*
107 * An area of zeros used to clear the next area.
108 */
109 void *zero_area;
110
111 /*
112 * Used to keep track of which metadata area the data in
113 * 'chunk' refers to.
114 */
115 chunk_t current_area;
116
117 /*
118 * The next free chunk for an exception.
119 */
120 chunk_t next_free;
121
122 /*
123 * The index of next free exception in the current
124 * metadata area.
125 */
126 uint32_t current_committed;
127
128 atomic_t pending_count;
129 uint32_t callback_count;
130 struct commit_callback *callbacks;
131 struct dm_io_client *io_client;
132
133 struct workqueue_struct *metadata_wq;
134};
135
136static unsigned sectors_to_pages(unsigned sectors)
137{
138 return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
139}
140
141static int alloc_area(struct pstore *ps)
142{
143 int r = -ENOMEM;
144 size_t len;
145
146 len = ps->snap->chunk_size << SECTOR_SHIFT;
147
148 /*
149 * Allocate the chunk_size block of memory that will hold
150 * a single metadata area.
151 */
152 ps->area = vmalloc(len);
153 if (!ps->area)
154 return r;
155
156 ps->zero_area = vmalloc(len);
157 if (!ps->zero_area) {
158 vfree(ps->area);
159 return r;
160 }
161 memset(ps->zero_area, 0, len);
162
163 return 0;
164}
165
166static void free_area(struct pstore *ps)
167{
168 vfree(ps->area);
169 ps->area = NULL;
170 vfree(ps->zero_area);
171 ps->zero_area = NULL;
172}
173
174struct mdata_req {
175 struct dm_io_region *where;
176 struct dm_io_request *io_req;
177 struct work_struct work;
178 int result;
179};
180
181static void do_metadata(struct work_struct *work)
182{
183 struct mdata_req *req = container_of(work, struct mdata_req, work);
184
185 req->result = dm_io(req->io_req, 1, req->where, NULL);
186}
187
188/*
189 * Read or write a chunk aligned and sized block of data from a device.
190 */
191static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata)
192{
193 struct dm_io_region where = {
194 .bdev = ps->snap->cow->bdev,
195 .sector = ps->snap->chunk_size * chunk,
196 .count = ps->snap->chunk_size,
197 };
198 struct dm_io_request io_req = {
199 .bi_rw = rw,
200 .mem.type = DM_IO_VMA,
201 .mem.ptr.vma = ps->area,
202 .client = ps->io_client,
203 .notify.fn = NULL,
204 };
205 struct mdata_req req;
206
207 if (!metadata)
208 return dm_io(&io_req, 1, &where, NULL);
209
210 req.where = &where;
211 req.io_req = &io_req;
212
213 /*
214 * Issue the synchronous I/O from a different thread
215 * to avoid generic_make_request recursion.
216 */
217 INIT_WORK(&req.work, do_metadata);
218 queue_work(ps->metadata_wq, &req.work);
219 flush_workqueue(ps->metadata_wq);
220
221 return req.result;
222}
223
224/*
225 * Convert a metadata area index to a chunk index.
226 */
227static chunk_t area_location(struct pstore *ps, chunk_t area)
228{
229 return 1 + ((ps->exceptions_per_area + 1) * area);
230}
231
232/*
233 * Read or write a metadata area. Remembering to skip the first
234 * chunk which holds the header.
235 */
236static int area_io(struct pstore *ps, int rw)
237{
238 int r;
239 chunk_t chunk;
240
241 chunk = area_location(ps, ps->current_area);
242
243 r = chunk_io(ps, chunk, rw, 0);
244 if (r)
245 return r;
246
247 return 0;
248}
249
250static void zero_memory_area(struct pstore *ps)
251{
252 memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
253}
254
255static int zero_disk_area(struct pstore *ps, chunk_t area)
256{
257 struct dm_io_region where = {
258 .bdev = ps->snap->cow->bdev,
259 .sector = ps->snap->chunk_size * area_location(ps, area),
260 .count = ps->snap->chunk_size,
261 };
262 struct dm_io_request io_req = {
263 .bi_rw = WRITE,
264 .mem.type = DM_IO_VMA,
265 .mem.ptr.vma = ps->zero_area,
266 .client = ps->io_client,
267 .notify.fn = NULL,
268 };
269
270 return dm_io(&io_req, 1, &where, NULL);
271}
272
273static int read_header(struct pstore *ps, int *new_snapshot)
274{
275 int r;
276 struct disk_header *dh;
277 chunk_t chunk_size;
278 int chunk_size_supplied = 1;
279
280 /*
281 * Use default chunk size (or hardsect_size, if larger) if none supplied
282 */
283 if (!ps->snap->chunk_size) {
284 ps->snap->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS,
285 bdev_hardsect_size(ps->snap->cow->bdev) >> 9);
286 ps->snap->chunk_mask = ps->snap->chunk_size - 1;
287 ps->snap->chunk_shift = ffs(ps->snap->chunk_size) - 1;
288 chunk_size_supplied = 0;
289 }
290
291 ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap->
292 chunk_size));
293 if (IS_ERR(ps->io_client))
294 return PTR_ERR(ps->io_client);
295
296 r = alloc_area(ps);
297 if (r)
298 return r;
299
300 r = chunk_io(ps, 0, READ, 1);
301 if (r)
302 goto bad;
303
304 dh = (struct disk_header *) ps->area;
305
306 if (le32_to_cpu(dh->magic) == 0) {
307 *new_snapshot = 1;
308 return 0;
309 }
310
311 if (le32_to_cpu(dh->magic) != SNAP_MAGIC) {
312 DMWARN("Invalid or corrupt snapshot");
313 r = -ENXIO;
314 goto bad;
315 }
316
317 *new_snapshot = 0;
318 ps->valid = le32_to_cpu(dh->valid);
319 ps->version = le32_to_cpu(dh->version);
320 chunk_size = le32_to_cpu(dh->chunk_size);
321
322 if (!chunk_size_supplied || ps->snap->chunk_size == chunk_size)
323 return 0;
324
325 DMWARN("chunk size %llu in device metadata overrides "
326 "table chunk size of %llu.",
327 (unsigned long long)chunk_size,
328 (unsigned long long)ps->snap->chunk_size);
329
330 /* We had a bogus chunk_size. Fix stuff up. */
331 free_area(ps);
332
333 ps->snap->chunk_size = chunk_size;
334 ps->snap->chunk_mask = chunk_size - 1;
335 ps->snap->chunk_shift = ffs(chunk_size) - 1;
336
337 r = dm_io_client_resize(sectors_to_pages(ps->snap->chunk_size),
338 ps->io_client);
339 if (r)
340 return r;
341
342 r = alloc_area(ps);
343 return r;
344
345bad:
346 free_area(ps);
347 return r;
348}
349
350static int write_header(struct pstore *ps)
351{
352 struct disk_header *dh;
353
354 memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
355
356 dh = (struct disk_header *) ps->area;
357 dh->magic = cpu_to_le32(SNAP_MAGIC);
358 dh->valid = cpu_to_le32(ps->valid);
359 dh->version = cpu_to_le32(ps->version);
360 dh->chunk_size = cpu_to_le32(ps->snap->chunk_size);
361
362 return chunk_io(ps, 0, WRITE, 1);
363}
364
365/*
366 * Access functions for the disk exceptions, these do the endian conversions.
367 */
368static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
369{
370 BUG_ON(index >= ps->exceptions_per_area);
371
372 return ((struct disk_exception *) ps->area) + index;
373}
374 14
375static void read_exception(struct pstore *ps, 15#define DM_MSG_PREFIX "snapshot exception stores"
376 uint32_t index, struct disk_exception *result)
377{
378 struct disk_exception *e = get_exception(ps, index);
379
380 /* copy it */
381 result->old_chunk = le64_to_cpu(e->old_chunk);
382 result->new_chunk = le64_to_cpu(e->new_chunk);
383}
384
385static void write_exception(struct pstore *ps,
386 uint32_t index, struct disk_exception *de)
387{
388 struct disk_exception *e = get_exception(ps, index);
389
390 /* copy it */
391 e->old_chunk = cpu_to_le64(de->old_chunk);
392 e->new_chunk = cpu_to_le64(de->new_chunk);
393}
394 16
395/* 17int dm_exception_store_init(void)
396 * Registers the exceptions that are present in the current area.
397 * 'full' is filled in to indicate if the area has been
398 * filled.
399 */
400static int insert_exceptions(struct pstore *ps, int *full)
401{ 18{
402 int r; 19 int r;
403 unsigned int i;
404 struct disk_exception de;
405
406 /* presume the area is full */
407 *full = 1;
408
409 for (i = 0; i < ps->exceptions_per_area; i++) {
410 read_exception(ps, i, &de);
411
412 /*
413 * If the new_chunk is pointing at the start of
414 * the COW device, where the first metadata area
415 * is we know that we've hit the end of the
416 * exceptions. Therefore the area is not full.
417 */
418 if (de.new_chunk == 0LL) {
419 ps->current_committed = i;
420 *full = 0;
421 break;
422 }
423
424 /*
425 * Keep track of the start of the free chunks.
426 */
427 if (ps->next_free <= de.new_chunk)
428 ps->next_free = de.new_chunk + 1;
429
430 /*
431 * Otherwise we add the exception to the snapshot.
432 */
433 r = dm_add_exception(ps->snap, de.old_chunk, de.new_chunk);
434 if (r)
435 return r;
436 }
437
438 return 0;
439}
440
441static int read_exceptions(struct pstore *ps)
442{
443 int r, full = 1;
444
445 /*
446 * Keeping reading chunks and inserting exceptions until
447 * we find a partially full area.
448 */
449 for (ps->current_area = 0; full; ps->current_area++) {
450 r = area_io(ps, READ);
451 if (r)
452 return r;
453 20
454 r = insert_exceptions(ps, &full); 21 r = dm_transient_snapshot_init();
455 if (r) 22 if (r) {
456 return r; 23 DMERR("Unable to register transient exception store type.");
24 goto transient_fail;
457 } 25 }
458 26
459 ps->current_area--; 27 r = dm_persistent_snapshot_init();
460 28 if (r) {
461 return 0; 29 DMERR("Unable to register persistent exception store type");
462} 30 goto persistent_fail;
463
464static struct pstore *get_info(struct exception_store *store)
465{
466 return (struct pstore *) store->context;
467}
468
469static void persistent_fraction_full(struct exception_store *store,
470 sector_t *numerator, sector_t *denominator)
471{
472 *numerator = get_info(store)->next_free * store->snap->chunk_size;
473 *denominator = get_dev_size(store->snap->cow->bdev);
474}
475
476static void persistent_destroy(struct exception_store *store)
477{
478 struct pstore *ps = get_info(store);
479
480 destroy_workqueue(ps->metadata_wq);
481 dm_io_client_destroy(ps->io_client);
482 vfree(ps->callbacks);
483 free_area(ps);
484 kfree(ps);
485}
486
487static int persistent_read_metadata(struct exception_store *store)
488{
489 int r, uninitialized_var(new_snapshot);
490 struct pstore *ps = get_info(store);
491
492 /*
493 * Read the snapshot header.
494 */
495 r = read_header(ps, &new_snapshot);
496 if (r)
497 return r;
498
499 /*
500 * Now we know correct chunk_size, complete the initialisation.
501 */
502 ps->exceptions_per_area = (ps->snap->chunk_size << SECTOR_SHIFT) /
503 sizeof(struct disk_exception);
504 ps->callbacks = dm_vcalloc(ps->exceptions_per_area,
505 sizeof(*ps->callbacks));
506 if (!ps->callbacks)
507 return -ENOMEM;
508
509 /*
510 * Do we need to setup a new snapshot ?
511 */
512 if (new_snapshot) {
513 r = write_header(ps);
514 if (r) {
515 DMWARN("write_header failed");
516 return r;
517 }
518
519 ps->current_area = 0;
520 zero_memory_area(ps);
521 r = zero_disk_area(ps, 0);
522 if (r) {
523 DMWARN("zero_disk_area(0) failed");
524 return r;
525 }
526 } else {
527 /*
528 * Sanity checks.
529 */
530 if (ps->version != SNAPSHOT_DISK_VERSION) {
531 DMWARN("unable to handle snapshot disk version %d",
532 ps->version);
533 return -EINVAL;
534 }
535
536 /*
537 * Metadata are valid, but snapshot is invalidated
538 */
539 if (!ps->valid)
540 return 1;
541
542 /*
543 * Read the metadata.
544 */
545 r = read_exceptions(ps);
546 if (r)
547 return r;
548 } 31 }
549 32
550 return 0; 33 return 0;
551}
552
553static int persistent_prepare(struct exception_store *store,
554 struct dm_snap_exception *e)
555{
556 struct pstore *ps = get_info(store);
557 uint32_t stride;
558 chunk_t next_free;
559 sector_t size = get_dev_size(store->snap->cow->bdev);
560
561 /* Is there enough room ? */
562 if (size < ((ps->next_free + 1) * store->snap->chunk_size))
563 return -ENOSPC;
564 34
565 e->new_chunk = ps->next_free; 35persistent_fail:
566 36 dm_persistent_snapshot_exit();
567 /* 37transient_fail:
568 * Move onto the next free pending, making sure to take 38 return r;
569 * into account the location of the metadata chunks.
570 */
571 stride = (ps->exceptions_per_area + 1);
572 next_free = ++ps->next_free;
573 if (sector_div(next_free, stride) == 1)
574 ps->next_free++;
575
576 atomic_inc(&ps->pending_count);
577 return 0;
578}
579
580static void persistent_commit(struct exception_store *store,
581 struct dm_snap_exception *e,
582 void (*callback) (void *, int success),
583 void *callback_context)
584{
585 unsigned int i;
586 struct pstore *ps = get_info(store);
587 struct disk_exception de;
588 struct commit_callback *cb;
589
590 de.old_chunk = e->old_chunk;
591 de.new_chunk = e->new_chunk;
592 write_exception(ps, ps->current_committed++, &de);
593
594 /*
595 * Add the callback to the back of the array. This code
596 * is the only place where the callback array is
597 * manipulated, and we know that it will never be called
598 * multiple times concurrently.
599 */
600 cb = ps->callbacks + ps->callback_count++;
601 cb->callback = callback;
602 cb->context = callback_context;
603
604 /*
605 * If there are exceptions in flight and we have not yet
606 * filled this metadata area there's nothing more to do.
607 */
608 if (!atomic_dec_and_test(&ps->pending_count) &&
609 (ps->current_committed != ps->exceptions_per_area))
610 return;
611
612 /*
613 * If we completely filled the current area, then wipe the next one.
614 */
615 if ((ps->current_committed == ps->exceptions_per_area) &&
616 zero_disk_area(ps, ps->current_area + 1))
617 ps->valid = 0;
618
619 /*
620 * Commit exceptions to disk.
621 */
622 if (ps->valid && area_io(ps, WRITE))
623 ps->valid = 0;
624
625 /*
626 * Advance to the next area if this one is full.
627 */
628 if (ps->current_committed == ps->exceptions_per_area) {
629 ps->current_committed = 0;
630 ps->current_area++;
631 zero_memory_area(ps);
632 }
633
634 for (i = 0; i < ps->callback_count; i++) {
635 cb = ps->callbacks + i;
636 cb->callback(cb->context, ps->valid);
637 }
638
639 ps->callback_count = 0;
640}
641
642static void persistent_drop(struct exception_store *store)
643{
644 struct pstore *ps = get_info(store);
645
646 ps->valid = 0;
647 if (write_header(ps))
648 DMWARN("write header failed");
649}
650
651int dm_create_persistent(struct exception_store *store)
652{
653 struct pstore *ps;
654
655 /* allocate the pstore */
656 ps = kmalloc(sizeof(*ps), GFP_KERNEL);
657 if (!ps)
658 return -ENOMEM;
659
660 ps->snap = store->snap;
661 ps->valid = 1;
662 ps->version = SNAPSHOT_DISK_VERSION;
663 ps->area = NULL;
664 ps->next_free = 2; /* skipping the header and first area */
665 ps->current_committed = 0;
666
667 ps->callback_count = 0;
668 atomic_set(&ps->pending_count, 0);
669 ps->callbacks = NULL;
670
671 ps->metadata_wq = create_singlethread_workqueue("ksnaphd");
672 if (!ps->metadata_wq) {
673 kfree(ps);
674 DMERR("couldn't start header metadata update thread");
675 return -ENOMEM;
676 }
677
678 store->destroy = persistent_destroy;
679 store->read_metadata = persistent_read_metadata;
680 store->prepare_exception = persistent_prepare;
681 store->commit_exception = persistent_commit;
682 store->drop_snapshot = persistent_drop;
683 store->fraction_full = persistent_fraction_full;
684 store->context = ps;
685
686 return 0;
687}
688
689/*-----------------------------------------------------------------
690 * Implementation of the store for non-persistent snapshots.
691 *---------------------------------------------------------------*/
692struct transient_c {
693 sector_t next_free;
694};
695
696static void transient_destroy(struct exception_store *store)
697{
698 kfree(store->context);
699}
700
701static int transient_read_metadata(struct exception_store *store)
702{
703 return 0;
704}
705
706static int transient_prepare(struct exception_store *store,
707 struct dm_snap_exception *e)
708{
709 struct transient_c *tc = (struct transient_c *) store->context;
710 sector_t size = get_dev_size(store->snap->cow->bdev);
711
712 if (size < (tc->next_free + store->snap->chunk_size))
713 return -1;
714
715 e->new_chunk = sector_to_chunk(store->snap, tc->next_free);
716 tc->next_free += store->snap->chunk_size;
717
718 return 0;
719}
720
721static void transient_commit(struct exception_store *store,
722 struct dm_snap_exception *e,
723 void (*callback) (void *, int success),
724 void *callback_context)
725{
726 /* Just succeed */
727 callback(callback_context, 1);
728}
729
730static void transient_fraction_full(struct exception_store *store,
731 sector_t *numerator, sector_t *denominator)
732{
733 *numerator = ((struct transient_c *) store->context)->next_free;
734 *denominator = get_dev_size(store->snap->cow->bdev);
735} 39}
736 40
737int dm_create_transient(struct exception_store *store) 41void dm_exception_store_exit(void)
738{ 42{
739 struct transient_c *tc; 43 dm_persistent_snapshot_exit();
740 44 dm_transient_snapshot_exit();
741 store->destroy = transient_destroy;
742 store->read_metadata = transient_read_metadata;
743 store->prepare_exception = transient_prepare;
744 store->commit_exception = transient_commit;
745 store->drop_snapshot = NULL;
746 store->fraction_full = transient_fraction_full;
747
748 tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL);
749 if (!tc)
750 return -ENOMEM;
751
752 tc->next_free = 0;
753 store->context = tc;
754
755 return 0;
756} 45}
diff --git a/drivers/md/dm-exception-store.h b/drivers/md/dm-exception-store.h
new file mode 100644
index 000000000000..bb9f33d5daa2
--- /dev/null
+++ b/drivers/md/dm-exception-store.h
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-mapper snapshot exception store.
6 *
7 * This file is released under the GPL.
8 */
9
10#ifndef _LINUX_DM_EXCEPTION_STORE
11#define _LINUX_DM_EXCEPTION_STORE
12
13#include <linux/blkdev.h>
14#include <linux/device-mapper.h>
15
16/*
17 * The snapshot code deals with largish chunks of the disk at a
18 * time. Typically 32k - 512k.
19 */
20typedef sector_t chunk_t;
21
22/*
23 * An exception is used where an old chunk of data has been
24 * replaced by a new one.
25 * If chunk_t is 64 bits in size, the top 8 bits of new_chunk hold the number
26 * of chunks that follow contiguously. Remaining bits hold the number of the
27 * chunk within the device.
28 */
29struct dm_snap_exception {
30 struct list_head hash_list;
31
32 chunk_t old_chunk;
33 chunk_t new_chunk;
34};
35
36/*
37 * Abstraction to handle the meta/layout of exception stores (the
38 * COW device).
39 */
40struct dm_exception_store {
41 /*
42 * Destroys this object when you've finished with it.
43 */
44 void (*destroy) (struct dm_exception_store *store);
45
46 /*
47 * The target shouldn't read the COW device until this is
48 * called. As exceptions are read from the COW, they are
49 * reported back via the callback.
50 */
51 int (*read_metadata) (struct dm_exception_store *store,
52 int (*callback)(void *callback_context,
53 chunk_t old, chunk_t new),
54 void *callback_context);
55
56 /*
57 * Find somewhere to store the next exception.
58 */
59 int (*prepare_exception) (struct dm_exception_store *store,
60 struct dm_snap_exception *e);
61
62 /*
63 * Update the metadata with this exception.
64 */
65 void (*commit_exception) (struct dm_exception_store *store,
66 struct dm_snap_exception *e,
67 void (*callback) (void *, int success),
68 void *callback_context);
69
70 /*
71 * The snapshot is invalid, note this in the metadata.
72 */
73 void (*drop_snapshot) (struct dm_exception_store *store);
74
75 int (*status) (struct dm_exception_store *store, status_type_t status,
76 char *result, unsigned int maxlen);
77
78 /*
79 * Return how full the snapshot is.
80 */
81 void (*fraction_full) (struct dm_exception_store *store,
82 sector_t *numerator,
83 sector_t *denominator);
84
85 struct dm_snapshot *snap;
86 void *context;
87};
88
89/*
90 * Funtions to manipulate consecutive chunks
91 */
92# if defined(CONFIG_LBD) || (BITS_PER_LONG == 64)
93# define DM_CHUNK_CONSECUTIVE_BITS 8
94# define DM_CHUNK_NUMBER_BITS 56
95
96static inline chunk_t dm_chunk_number(chunk_t chunk)
97{
98 return chunk & (chunk_t)((1ULL << DM_CHUNK_NUMBER_BITS) - 1ULL);
99}
100
101static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
102{
103 return e->new_chunk >> DM_CHUNK_NUMBER_BITS;
104}
105
106static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
107{
108 e->new_chunk += (1ULL << DM_CHUNK_NUMBER_BITS);
109
110 BUG_ON(!dm_consecutive_chunk_count(e));
111}
112
113# else
114# define DM_CHUNK_CONSECUTIVE_BITS 0
115
116static inline chunk_t dm_chunk_number(chunk_t chunk)
117{
118 return chunk;
119}
120
121static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
122{
123 return 0;
124}
125
126static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
127{
128}
129
130# endif
131
132int dm_exception_store_init(void);
133void dm_exception_store_exit(void);
134
135/*
136 * Two exception store implementations.
137 */
138int dm_persistent_snapshot_init(void);
139void dm_persistent_snapshot_exit(void);
140
141int dm_transient_snapshot_init(void);
142void dm_transient_snapshot_exit(void);
143
144int dm_create_persistent(struct dm_exception_store *store);
145
146int dm_create_transient(struct dm_exception_store *store);
147
148#endif /* _LINUX_DM_EXCEPTION_STORE */
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 777c948180f9..54d0588fc1f6 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -233,7 +233,7 @@ static void __hash_remove(struct hash_cell *hc)
233 } 233 }
234 234
235 if (hc->new_map) 235 if (hc->new_map)
236 dm_table_put(hc->new_map); 236 dm_table_destroy(hc->new_map);
237 dm_put(hc->md); 237 dm_put(hc->md);
238 free_cell(hc); 238 free_cell(hc);
239} 239}
@@ -827,8 +827,8 @@ static int do_resume(struct dm_ioctl *param)
827 827
828 r = dm_swap_table(md, new_map); 828 r = dm_swap_table(md, new_map);
829 if (r) { 829 if (r) {
830 dm_table_destroy(new_map);
830 dm_put(md); 831 dm_put(md);
831 dm_table_put(new_map);
832 return r; 832 return r;
833 } 833 }
834 834
@@ -836,8 +836,6 @@ static int do_resume(struct dm_ioctl *param)
836 set_disk_ro(dm_disk(md), 0); 836 set_disk_ro(dm_disk(md), 0);
837 else 837 else
838 set_disk_ro(dm_disk(md), 1); 838 set_disk_ro(dm_disk(md), 1);
839
840 dm_table_put(new_map);
841 } 839 }
842 840
843 if (dm_suspended(md)) 841 if (dm_suspended(md))
@@ -1080,7 +1078,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
1080 } 1078 }
1081 1079
1082 if (hc->new_map) 1080 if (hc->new_map)
1083 dm_table_put(hc->new_map); 1081 dm_table_destroy(hc->new_map);
1084 hc->new_map = t; 1082 hc->new_map = t;
1085 up_write(&_hash_lock); 1083 up_write(&_hash_lock);
1086 1084
@@ -1109,7 +1107,7 @@ static int table_clear(struct dm_ioctl *param, size_t param_size)
1109 } 1107 }
1110 1108
1111 if (hc->new_map) { 1109 if (hc->new_map) {
1112 dm_table_put(hc->new_map); 1110 dm_table_destroy(hc->new_map);
1113 hc->new_map = NULL; 1111 hc->new_map = NULL;
1114 } 1112 }
1115 1113
@@ -1550,8 +1548,10 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
1550 goto out; 1548 goto out;
1551 } 1549 }
1552 1550
1553 strcpy(name, hc->name); 1551 if (name)
1554 strcpy(uuid, hc->uuid ? : ""); 1552 strcpy(name, hc->name);
1553 if (uuid)
1554 strcpy(uuid, hc->uuid ? : "");
1555 1555
1556out: 1556out:
1557 up_read(&_hash_lock); 1557 up_read(&_hash_lock);
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 44042becad8a..bfa107f59d96 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -142,6 +142,7 @@ static struct target_type linear_target = {
142 .status = linear_status, 142 .status = linear_status,
143 .ioctl = linear_ioctl, 143 .ioctl = linear_ioctl,
144 .merge = linear_merge, 144 .merge = linear_merge,
145 .features = DM_TARGET_SUPPORTS_BARRIERS,
145}; 146};
146 147
147int __init dm_linear_init(void) 148int __init dm_linear_init(void)
@@ -156,8 +157,5 @@ int __init dm_linear_init(void)
156 157
157void dm_linear_exit(void) 158void dm_linear_exit(void)
158{ 159{
159 int r = dm_unregister_target(&linear_target); 160 dm_unregister_target(&linear_target);
160
161 if (r < 0)
162 DMERR("unregister failed %d", r);
163} 161}
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index a8c0fc79ca78..737961f275c1 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -326,8 +326,6 @@ static void header_from_disk(struct log_header *core, struct log_header *disk)
326static int rw_header(struct log_c *lc, int rw) 326static int rw_header(struct log_c *lc, int rw)
327{ 327{
328 lc->io_req.bi_rw = rw; 328 lc->io_req.bi_rw = rw;
329 lc->io_req.mem.ptr.vma = lc->disk_header;
330 lc->io_req.notify.fn = NULL;
331 329
332 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); 330 return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
333} 331}
@@ -362,10 +360,15 @@ static int read_header(struct log_c *log)
362 return 0; 360 return 0;
363} 361}
364 362
365static inline int write_header(struct log_c *log) 363static int _check_region_size(struct dm_target *ti, uint32_t region_size)
366{ 364{
367 header_to_disk(&log->header, log->disk_header); 365 if (region_size < 2 || region_size > ti->len)
368 return rw_header(log, WRITE); 366 return 0;
367
368 if (!is_power_of_2(region_size))
369 return 0;
370
371 return 1;
369} 372}
370 373
371/*---------------------------------------------------------------- 374/*----------------------------------------------------------------
@@ -403,8 +406,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
403 } 406 }
404 } 407 }
405 408
406 if (sscanf(argv[0], "%u", &region_size) != 1) { 409 if (sscanf(argv[0], "%u", &region_size) != 1 ||
407 DMWARN("invalid region size string"); 410 !_check_region_size(ti, region_size)) {
411 DMWARN("invalid region size %s", argv[0]);
408 return -EINVAL; 412 return -EINVAL;
409 } 413 }
410 414
@@ -453,8 +457,18 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
453 */ 457 */
454 buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + 458 buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
455 bitset_size, ti->limits.hardsect_size); 459 bitset_size, ti->limits.hardsect_size);
460
461 if (buf_size > dev->bdev->bd_inode->i_size) {
462 DMWARN("log device %s too small: need %llu bytes",
463 dev->name, (unsigned long long)buf_size);
464 kfree(lc);
465 return -EINVAL;
466 }
467
456 lc->header_location.count = buf_size >> SECTOR_SHIFT; 468 lc->header_location.count = buf_size >> SECTOR_SHIFT;
469
457 lc->io_req.mem.type = DM_IO_VMA; 470 lc->io_req.mem.type = DM_IO_VMA;
471 lc->io_req.notify.fn = NULL;
458 lc->io_req.client = dm_io_client_create(dm_div_up(buf_size, 472 lc->io_req.client = dm_io_client_create(dm_div_up(buf_size,
459 PAGE_SIZE)); 473 PAGE_SIZE));
460 if (IS_ERR(lc->io_req.client)) { 474 if (IS_ERR(lc->io_req.client)) {
@@ -467,10 +481,12 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
467 lc->disk_header = vmalloc(buf_size); 481 lc->disk_header = vmalloc(buf_size);
468 if (!lc->disk_header) { 482 if (!lc->disk_header) {
469 DMWARN("couldn't allocate disk log buffer"); 483 DMWARN("couldn't allocate disk log buffer");
484 dm_io_client_destroy(lc->io_req.client);
470 kfree(lc); 485 kfree(lc);
471 return -ENOMEM; 486 return -ENOMEM;
472 } 487 }
473 488
489 lc->io_req.mem.ptr.vma = lc->disk_header;
474 lc->clean_bits = (void *)lc->disk_header + 490 lc->clean_bits = (void *)lc->disk_header +
475 (LOG_OFFSET << SECTOR_SHIFT); 491 (LOG_OFFSET << SECTOR_SHIFT);
476 } 492 }
@@ -482,6 +498,8 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
482 DMWARN("couldn't allocate sync bitset"); 498 DMWARN("couldn't allocate sync bitset");
483 if (!dev) 499 if (!dev)
484 vfree(lc->clean_bits); 500 vfree(lc->clean_bits);
501 else
502 dm_io_client_destroy(lc->io_req.client);
485 vfree(lc->disk_header); 503 vfree(lc->disk_header);
486 kfree(lc); 504 kfree(lc);
487 return -ENOMEM; 505 return -ENOMEM;
@@ -495,6 +513,8 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
495 vfree(lc->sync_bits); 513 vfree(lc->sync_bits);
496 if (!dev) 514 if (!dev)
497 vfree(lc->clean_bits); 515 vfree(lc->clean_bits);
516 else
517 dm_io_client_destroy(lc->io_req.client);
498 vfree(lc->disk_header); 518 vfree(lc->disk_header);
499 kfree(lc); 519 kfree(lc);
500 return -ENOMEM; 520 return -ENOMEM;
@@ -631,8 +651,10 @@ static int disk_resume(struct dm_dirty_log *log)
631 /* set the correct number of regions in the header */ 651 /* set the correct number of regions in the header */
632 lc->header.nr_regions = lc->region_count; 652 lc->header.nr_regions = lc->region_count;
633 653
654 header_to_disk(&lc->header, lc->disk_header);
655
634 /* write the new header */ 656 /* write the new header */
635 r = write_header(lc); 657 r = rw_header(lc, WRITE);
636 if (r) { 658 if (r) {
637 DMWARN("%s: Failed to write header on dirty region log device", 659 DMWARN("%s: Failed to write header on dirty region log device",
638 lc->log_dev->name); 660 lc->log_dev->name);
@@ -682,7 +704,7 @@ static int disk_flush(struct dm_dirty_log *log)
682 if (!lc->touched) 704 if (!lc->touched)
683 return 0; 705 return 0;
684 706
685 r = write_header(lc); 707 r = rw_header(lc, WRITE);
686 if (r) 708 if (r)
687 fail_log_device(lc); 709 fail_log_device(lc);
688 else 710 else
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 3d7f4923cd13..095f77bf9681 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -889,7 +889,7 @@ static int fail_path(struct pgpath *pgpath)
889 dm_path_uevent(DM_UEVENT_PATH_FAILED, m->ti, 889 dm_path_uevent(DM_UEVENT_PATH_FAILED, m->ti,
890 pgpath->path.dev->name, m->nr_valid_paths); 890 pgpath->path.dev->name, m->nr_valid_paths);
891 891
892 queue_work(kmultipathd, &m->trigger_event); 892 schedule_work(&m->trigger_event);
893 queue_work(kmultipathd, &pgpath->deactivate_path); 893 queue_work(kmultipathd, &pgpath->deactivate_path);
894 894
895out: 895out:
@@ -932,7 +932,7 @@ static int reinstate_path(struct pgpath *pgpath)
932 dm_path_uevent(DM_UEVENT_PATH_REINSTATED, m->ti, 932 dm_path_uevent(DM_UEVENT_PATH_REINSTATED, m->ti,
933 pgpath->path.dev->name, m->nr_valid_paths); 933 pgpath->path.dev->name, m->nr_valid_paths);
934 934
935 queue_work(kmultipathd, &m->trigger_event); 935 schedule_work(&m->trigger_event);
936 936
937out: 937out:
938 spin_unlock_irqrestore(&m->lock, flags); 938 spin_unlock_irqrestore(&m->lock, flags);
@@ -976,7 +976,7 @@ static void bypass_pg(struct multipath *m, struct priority_group *pg,
976 976
977 spin_unlock_irqrestore(&m->lock, flags); 977 spin_unlock_irqrestore(&m->lock, flags);
978 978
979 queue_work(kmultipathd, &m->trigger_event); 979 schedule_work(&m->trigger_event);
980} 980}
981 981
982/* 982/*
@@ -1006,7 +1006,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
1006 } 1006 }
1007 spin_unlock_irqrestore(&m->lock, flags); 1007 spin_unlock_irqrestore(&m->lock, flags);
1008 1008
1009 queue_work(kmultipathd, &m->trigger_event); 1009 schedule_work(&m->trigger_event);
1010 return 0; 1010 return 0;
1011} 1011}
1012 1012
@@ -1495,14 +1495,10 @@ static int __init dm_multipath_init(void)
1495 1495
1496static void __exit dm_multipath_exit(void) 1496static void __exit dm_multipath_exit(void)
1497{ 1497{
1498 int r;
1499
1500 destroy_workqueue(kmpath_handlerd); 1498 destroy_workqueue(kmpath_handlerd);
1501 destroy_workqueue(kmultipathd); 1499 destroy_workqueue(kmultipathd);
1502 1500
1503 r = dm_unregister_target(&multipath_target); 1501 dm_unregister_target(&multipath_target);
1504 if (r < 0)
1505 DMERR("target unregister failed %d", r);
1506 kmem_cache_destroy(_mpio_cache); 1502 kmem_cache_destroy(_mpio_cache);
1507} 1503}
1508 1504
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index ec43f9fa4b2a..4d6bc101962e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -197,9 +197,6 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
197 struct mirror_set *ms = m->ms; 197 struct mirror_set *ms = m->ms;
198 struct mirror *new; 198 struct mirror *new;
199 199
200 if (!errors_handled(ms))
201 return;
202
203 /* 200 /*
204 * error_count is used for nothing more than a 201 * error_count is used for nothing more than a
205 * simple way to tell if a device has encountered 202 * simple way to tell if a device has encountered
@@ -210,6 +207,9 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
210 if (test_and_set_bit(error_type, &m->error_type)) 207 if (test_and_set_bit(error_type, &m->error_type))
211 return; 208 return;
212 209
210 if (!errors_handled(ms))
211 return;
212
213 if (m != get_default_mirror(ms)) 213 if (m != get_default_mirror(ms))
214 goto out; 214 goto out;
215 215
@@ -808,12 +808,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti,
808 kfree(ms); 808 kfree(ms);
809} 809}
810 810
811static inline int _check_region_size(struct dm_target *ti, uint32_t size)
812{
813 return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) ||
814 size > ti->len);
815}
816
817static int get_mirror(struct mirror_set *ms, struct dm_target *ti, 811static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
818 unsigned int mirror, char **argv) 812 unsigned int mirror, char **argv)
819{ 813{
@@ -872,12 +866,6 @@ static struct dm_dirty_log *create_dirty_log(struct dm_target *ti,
872 return NULL; 866 return NULL;
873 } 867 }
874 868
875 if (!_check_region_size(ti, dl->type->get_region_size(dl))) {
876 ti->error = "Invalid region size";
877 dm_dirty_log_destroy(dl);
878 return NULL;
879 }
880
881 return dl; 869 return dl;
882} 870}
883 871
@@ -1300,11 +1288,7 @@ static int __init dm_mirror_init(void)
1300 1288
1301static void __exit dm_mirror_exit(void) 1289static void __exit dm_mirror_exit(void)
1302{ 1290{
1303 int r; 1291 dm_unregister_target(&mirror_target);
1304
1305 r = dm_unregister_target(&mirror_target);
1306 if (r < 0)
1307 DMERR("unregister failed %d", r);
1308} 1292}
1309 1293
1310/* Module hooks */ 1294/* Module hooks */
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
new file mode 100644
index 000000000000..936b34e0959f
--- /dev/null
+++ b/drivers/md/dm-snap-persistent.c
@@ -0,0 +1,704 @@
1/*
2 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2006-2008 Red Hat GmbH
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm-exception-store.h"
9#include "dm-snap.h"
10
11#include <linux/mm.h>
12#include <linux/pagemap.h>
13#include <linux/vmalloc.h>
14#include <linux/slab.h>
15#include <linux/dm-io.h>
16
17#define DM_MSG_PREFIX "persistent snapshot"
18#define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */
19
20/*-----------------------------------------------------------------
21 * Persistent snapshots, by persistent we mean that the snapshot
22 * will survive a reboot.
23 *---------------------------------------------------------------*/
24
25/*
26 * We need to store a record of which parts of the origin have
27 * been copied to the snapshot device. The snapshot code
28 * requires that we copy exception chunks to chunk aligned areas
29 * of the COW store. It makes sense therefore, to store the
30 * metadata in chunk size blocks.
31 *
32 * There is no backward or forward compatibility implemented,
33 * snapshots with different disk versions than the kernel will
34 * not be usable. It is expected that "lvcreate" will blank out
35 * the start of a fresh COW device before calling the snapshot
36 * constructor.
37 *
38 * The first chunk of the COW device just contains the header.
39 * After this there is a chunk filled with exception metadata,
40 * followed by as many exception chunks as can fit in the
41 * metadata areas.
42 *
43 * All on disk structures are in little-endian format. The end
44 * of the exceptions info is indicated by an exception with a
45 * new_chunk of 0, which is invalid since it would point to the
46 * header chunk.
47 */
48
49/*
50 * Magic for persistent snapshots: "SnAp" - Feeble isn't it.
51 */
52#define SNAP_MAGIC 0x70416e53
53
54/*
55 * The on-disk version of the metadata.
56 */
57#define SNAPSHOT_DISK_VERSION 1
58
59struct disk_header {
60 uint32_t magic;
61
62 /*
63 * Is this snapshot valid. There is no way of recovering
64 * an invalid snapshot.
65 */
66 uint32_t valid;
67
68 /*
69 * Simple, incrementing version. no backward
70 * compatibility.
71 */
72 uint32_t version;
73
74 /* In sectors */
75 uint32_t chunk_size;
76};
77
78struct disk_exception {
79 uint64_t old_chunk;
80 uint64_t new_chunk;
81};
82
83struct commit_callback {
84 void (*callback)(void *, int success);
85 void *context;
86};
87
88/*
89 * The top level structure for a persistent exception store.
90 */
91struct pstore {
92 struct dm_snapshot *snap; /* up pointer to my snapshot */
93 int version;
94 int valid;
95 uint32_t exceptions_per_area;
96
97 /*
98 * Now that we have an asynchronous kcopyd there is no
99 * need for large chunk sizes, so it wont hurt to have a
100 * whole chunks worth of metadata in memory at once.
101 */
102 void *area;
103
104 /*
105 * An area of zeros used to clear the next area.
106 */
107 void *zero_area;
108
109 /*
110 * Used to keep track of which metadata area the data in
111 * 'chunk' refers to.
112 */
113 chunk_t current_area;
114
115 /*
116 * The next free chunk for an exception.
117 */
118 chunk_t next_free;
119
120 /*
121 * The index of next free exception in the current
122 * metadata area.
123 */
124 uint32_t current_committed;
125
126 atomic_t pending_count;
127 uint32_t callback_count;
128 struct commit_callback *callbacks;
129 struct dm_io_client *io_client;
130
131 struct workqueue_struct *metadata_wq;
132};
133
134static unsigned sectors_to_pages(unsigned sectors)
135{
136 return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
137}
138
139static int alloc_area(struct pstore *ps)
140{
141 int r = -ENOMEM;
142 size_t len;
143
144 len = ps->snap->chunk_size << SECTOR_SHIFT;
145
146 /*
147 * Allocate the chunk_size block of memory that will hold
148 * a single metadata area.
149 */
150 ps->area = vmalloc(len);
151 if (!ps->area)
152 return r;
153
154 ps->zero_area = vmalloc(len);
155 if (!ps->zero_area) {
156 vfree(ps->area);
157 return r;
158 }
159 memset(ps->zero_area, 0, len);
160
161 return 0;
162}
163
164static void free_area(struct pstore *ps)
165{
166 vfree(ps->area);
167 ps->area = NULL;
168 vfree(ps->zero_area);
169 ps->zero_area = NULL;
170}
171
172struct mdata_req {
173 struct dm_io_region *where;
174 struct dm_io_request *io_req;
175 struct work_struct work;
176 int result;
177};
178
179static void do_metadata(struct work_struct *work)
180{
181 struct mdata_req *req = container_of(work, struct mdata_req, work);
182
183 req->result = dm_io(req->io_req, 1, req->where, NULL);
184}
185
186/*
187 * Read or write a chunk aligned and sized block of data from a device.
188 */
189static int chunk_io(struct pstore *ps, chunk_t chunk, int rw, int metadata)
190{
191 struct dm_io_region where = {
192 .bdev = ps->snap->cow->bdev,
193 .sector = ps->snap->chunk_size * chunk,
194 .count = ps->snap->chunk_size,
195 };
196 struct dm_io_request io_req = {
197 .bi_rw = rw,
198 .mem.type = DM_IO_VMA,
199 .mem.ptr.vma = ps->area,
200 .client = ps->io_client,
201 .notify.fn = NULL,
202 };
203 struct mdata_req req;
204
205 if (!metadata)
206 return dm_io(&io_req, 1, &where, NULL);
207
208 req.where = &where;
209 req.io_req = &io_req;
210
211 /*
212 * Issue the synchronous I/O from a different thread
213 * to avoid generic_make_request recursion.
214 */
215 INIT_WORK(&req.work, do_metadata);
216 queue_work(ps->metadata_wq, &req.work);
217 flush_workqueue(ps->metadata_wq);
218
219 return req.result;
220}
221
222/*
223 * Convert a metadata area index to a chunk index.
224 */
225static chunk_t area_location(struct pstore *ps, chunk_t area)
226{
227 return 1 + ((ps->exceptions_per_area + 1) * area);
228}
229
230/*
231 * Read or write a metadata area. Remembering to skip the first
232 * chunk which holds the header.
233 */
234static int area_io(struct pstore *ps, int rw)
235{
236 int r;
237 chunk_t chunk;
238
239 chunk = area_location(ps, ps->current_area);
240
241 r = chunk_io(ps, chunk, rw, 0);
242 if (r)
243 return r;
244
245 return 0;
246}
247
248static void zero_memory_area(struct pstore *ps)
249{
250 memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
251}
252
253static int zero_disk_area(struct pstore *ps, chunk_t area)
254{
255 struct dm_io_region where = {
256 .bdev = ps->snap->cow->bdev,
257 .sector = ps->snap->chunk_size * area_location(ps, area),
258 .count = ps->snap->chunk_size,
259 };
260 struct dm_io_request io_req = {
261 .bi_rw = WRITE,
262 .mem.type = DM_IO_VMA,
263 .mem.ptr.vma = ps->zero_area,
264 .client = ps->io_client,
265 .notify.fn = NULL,
266 };
267
268 return dm_io(&io_req, 1, &where, NULL);
269}
270
271static int read_header(struct pstore *ps, int *new_snapshot)
272{
273 int r;
274 struct disk_header *dh;
275 chunk_t chunk_size;
276 int chunk_size_supplied = 1;
277
278 /*
279 * Use default chunk size (or hardsect_size, if larger) if none supplied
280 */
281 if (!ps->snap->chunk_size) {
282 ps->snap->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS,
283 bdev_hardsect_size(ps->snap->cow->bdev) >> 9);
284 ps->snap->chunk_mask = ps->snap->chunk_size - 1;
285 ps->snap->chunk_shift = ffs(ps->snap->chunk_size) - 1;
286 chunk_size_supplied = 0;
287 }
288
289 ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap->
290 chunk_size));
291 if (IS_ERR(ps->io_client))
292 return PTR_ERR(ps->io_client);
293
294 r = alloc_area(ps);
295 if (r)
296 return r;
297
298 r = chunk_io(ps, 0, READ, 1);
299 if (r)
300 goto bad;
301
302 dh = (struct disk_header *) ps->area;
303
304 if (le32_to_cpu(dh->magic) == 0) {
305 *new_snapshot = 1;
306 return 0;
307 }
308
309 if (le32_to_cpu(dh->magic) != SNAP_MAGIC) {
310 DMWARN("Invalid or corrupt snapshot");
311 r = -ENXIO;
312 goto bad;
313 }
314
315 *new_snapshot = 0;
316 ps->valid = le32_to_cpu(dh->valid);
317 ps->version = le32_to_cpu(dh->version);
318 chunk_size = le32_to_cpu(dh->chunk_size);
319
320 if (!chunk_size_supplied || ps->snap->chunk_size == chunk_size)
321 return 0;
322
323 DMWARN("chunk size %llu in device metadata overrides "
324 "table chunk size of %llu.",
325 (unsigned long long)chunk_size,
326 (unsigned long long)ps->snap->chunk_size);
327
328 /* We had a bogus chunk_size. Fix stuff up. */
329 free_area(ps);
330
331 ps->snap->chunk_size = chunk_size;
332 ps->snap->chunk_mask = chunk_size - 1;
333 ps->snap->chunk_shift = ffs(chunk_size) - 1;
334
335 r = dm_io_client_resize(sectors_to_pages(ps->snap->chunk_size),
336 ps->io_client);
337 if (r)
338 return r;
339
340 r = alloc_area(ps);
341 return r;
342
343bad:
344 free_area(ps);
345 return r;
346}
347
348static int write_header(struct pstore *ps)
349{
350 struct disk_header *dh;
351
352 memset(ps->area, 0, ps->snap->chunk_size << SECTOR_SHIFT);
353
354 dh = (struct disk_header *) ps->area;
355 dh->magic = cpu_to_le32(SNAP_MAGIC);
356 dh->valid = cpu_to_le32(ps->valid);
357 dh->version = cpu_to_le32(ps->version);
358 dh->chunk_size = cpu_to_le32(ps->snap->chunk_size);
359
360 return chunk_io(ps, 0, WRITE, 1);
361}
362
363/*
364 * Access functions for the disk exceptions, these do the endian conversions.
365 */
366static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
367{
368 BUG_ON(index >= ps->exceptions_per_area);
369
370 return ((struct disk_exception *) ps->area) + index;
371}
372
373static void read_exception(struct pstore *ps,
374 uint32_t index, struct disk_exception *result)
375{
376 struct disk_exception *e = get_exception(ps, index);
377
378 /* copy it */
379 result->old_chunk = le64_to_cpu(e->old_chunk);
380 result->new_chunk = le64_to_cpu(e->new_chunk);
381}
382
383static void write_exception(struct pstore *ps,
384 uint32_t index, struct disk_exception *de)
385{
386 struct disk_exception *e = get_exception(ps, index);
387
388 /* copy it */
389 e->old_chunk = cpu_to_le64(de->old_chunk);
390 e->new_chunk = cpu_to_le64(de->new_chunk);
391}
392
393/*
394 * Registers the exceptions that are present in the current area.
395 * 'full' is filled in to indicate if the area has been
396 * filled.
397 */
398static int insert_exceptions(struct pstore *ps,
399 int (*callback)(void *callback_context,
400 chunk_t old, chunk_t new),
401 void *callback_context,
402 int *full)
403{
404 int r;
405 unsigned int i;
406 struct disk_exception de;
407
408 /* presume the area is full */
409 *full = 1;
410
411 for (i = 0; i < ps->exceptions_per_area; i++) {
412 read_exception(ps, i, &de);
413
414 /*
415 * If the new_chunk is pointing at the start of
416 * the COW device, where the first metadata area
417 * is we know that we've hit the end of the
418 * exceptions. Therefore the area is not full.
419 */
420 if (de.new_chunk == 0LL) {
421 ps->current_committed = i;
422 *full = 0;
423 break;
424 }
425
426 /*
427 * Keep track of the start of the free chunks.
428 */
429 if (ps->next_free <= de.new_chunk)
430 ps->next_free = de.new_chunk + 1;
431
432 /*
433 * Otherwise we add the exception to the snapshot.
434 */
435 r = callback(callback_context, de.old_chunk, de.new_chunk);
436 if (r)
437 return r;
438 }
439
440 return 0;
441}
442
443static int read_exceptions(struct pstore *ps,
444 int (*callback)(void *callback_context, chunk_t old,
445 chunk_t new),
446 void *callback_context)
447{
448 int r, full = 1;
449
450 /*
451 * Keeping reading chunks and inserting exceptions until
452 * we find a partially full area.
453 */
454 for (ps->current_area = 0; full; ps->current_area++) {
455 r = area_io(ps, READ);
456 if (r)
457 return r;
458
459 r = insert_exceptions(ps, callback, callback_context, &full);
460 if (r)
461 return r;
462 }
463
464 ps->current_area--;
465
466 return 0;
467}
468
469static struct pstore *get_info(struct dm_exception_store *store)
470{
471 return (struct pstore *) store->context;
472}
473
474static void persistent_fraction_full(struct dm_exception_store *store,
475 sector_t *numerator, sector_t *denominator)
476{
477 *numerator = get_info(store)->next_free * store->snap->chunk_size;
478 *denominator = get_dev_size(store->snap->cow->bdev);
479}
480
481static void persistent_destroy(struct dm_exception_store *store)
482{
483 struct pstore *ps = get_info(store);
484
485 destroy_workqueue(ps->metadata_wq);
486 dm_io_client_destroy(ps->io_client);
487 vfree(ps->callbacks);
488 free_area(ps);
489 kfree(ps);
490}
491
492static int persistent_read_metadata(struct dm_exception_store *store,
493 int (*callback)(void *callback_context,
494 chunk_t old, chunk_t new),
495 void *callback_context)
496{
497 int r, uninitialized_var(new_snapshot);
498 struct pstore *ps = get_info(store);
499
500 /*
501 * Read the snapshot header.
502 */
503 r = read_header(ps, &new_snapshot);
504 if (r)
505 return r;
506
507 /*
508 * Now we know correct chunk_size, complete the initialisation.
509 */
510 ps->exceptions_per_area = (ps->snap->chunk_size << SECTOR_SHIFT) /
511 sizeof(struct disk_exception);
512 ps->callbacks = dm_vcalloc(ps->exceptions_per_area,
513 sizeof(*ps->callbacks));
514 if (!ps->callbacks)
515 return -ENOMEM;
516
517 /*
518 * Do we need to setup a new snapshot ?
519 */
520 if (new_snapshot) {
521 r = write_header(ps);
522 if (r) {
523 DMWARN("write_header failed");
524 return r;
525 }
526
527 ps->current_area = 0;
528 zero_memory_area(ps);
529 r = zero_disk_area(ps, 0);
530 if (r) {
531 DMWARN("zero_disk_area(0) failed");
532 return r;
533 }
534 } else {
535 /*
536 * Sanity checks.
537 */
538 if (ps->version != SNAPSHOT_DISK_VERSION) {
539 DMWARN("unable to handle snapshot disk version %d",
540 ps->version);
541 return -EINVAL;
542 }
543
544 /*
545 * Metadata are valid, but snapshot is invalidated
546 */
547 if (!ps->valid)
548 return 1;
549
550 /*
551 * Read the metadata.
552 */
553 r = read_exceptions(ps, callback, callback_context);
554 if (r)
555 return r;
556 }
557
558 return 0;
559}
560
561static int persistent_prepare_exception(struct dm_exception_store *store,
562 struct dm_snap_exception *e)
563{
564 struct pstore *ps = get_info(store);
565 uint32_t stride;
566 chunk_t next_free;
567 sector_t size = get_dev_size(store->snap->cow->bdev);
568
569 /* Is there enough room ? */
570 if (size < ((ps->next_free + 1) * store->snap->chunk_size))
571 return -ENOSPC;
572
573 e->new_chunk = ps->next_free;
574
575 /*
576 * Move onto the next free pending, making sure to take
577 * into account the location of the metadata chunks.
578 */
579 stride = (ps->exceptions_per_area + 1);
580 next_free = ++ps->next_free;
581 if (sector_div(next_free, stride) == 1)
582 ps->next_free++;
583
584 atomic_inc(&ps->pending_count);
585 return 0;
586}
587
588static void persistent_commit_exception(struct dm_exception_store *store,
589 struct dm_snap_exception *e,
590 void (*callback) (void *, int success),
591 void *callback_context)
592{
593 unsigned int i;
594 struct pstore *ps = get_info(store);
595 struct disk_exception de;
596 struct commit_callback *cb;
597
598 de.old_chunk = e->old_chunk;
599 de.new_chunk = e->new_chunk;
600 write_exception(ps, ps->current_committed++, &de);
601
602 /*
603 * Add the callback to the back of the array. This code
604 * is the only place where the callback array is
605 * manipulated, and we know that it will never be called
606 * multiple times concurrently.
607 */
608 cb = ps->callbacks + ps->callback_count++;
609 cb->callback = callback;
610 cb->context = callback_context;
611
612 /*
613 * If there are exceptions in flight and we have not yet
614 * filled this metadata area there's nothing more to do.
615 */
616 if (!atomic_dec_and_test(&ps->pending_count) &&
617 (ps->current_committed != ps->exceptions_per_area))
618 return;
619
620 /*
621 * If we completely filled the current area, then wipe the next one.
622 */
623 if ((ps->current_committed == ps->exceptions_per_area) &&
624 zero_disk_area(ps, ps->current_area + 1))
625 ps->valid = 0;
626
627 /*
628 * Commit exceptions to disk.
629 */
630 if (ps->valid && area_io(ps, WRITE))
631 ps->valid = 0;
632
633 /*
634 * Advance to the next area if this one is full.
635 */
636 if (ps->current_committed == ps->exceptions_per_area) {
637 ps->current_committed = 0;
638 ps->current_area++;
639 zero_memory_area(ps);
640 }
641
642 for (i = 0; i < ps->callback_count; i++) {
643 cb = ps->callbacks + i;
644 cb->callback(cb->context, ps->valid);
645 }
646
647 ps->callback_count = 0;
648}
649
650static void persistent_drop_snapshot(struct dm_exception_store *store)
651{
652 struct pstore *ps = get_info(store);
653
654 ps->valid = 0;
655 if (write_header(ps))
656 DMWARN("write header failed");
657}
658
659int dm_create_persistent(struct dm_exception_store *store)
660{
661 struct pstore *ps;
662
663 /* allocate the pstore */
664 ps = kmalloc(sizeof(*ps), GFP_KERNEL);
665 if (!ps)
666 return -ENOMEM;
667
668 ps->snap = store->snap;
669 ps->valid = 1;
670 ps->version = SNAPSHOT_DISK_VERSION;
671 ps->area = NULL;
672 ps->next_free = 2; /* skipping the header and first area */
673 ps->current_committed = 0;
674
675 ps->callback_count = 0;
676 atomic_set(&ps->pending_count, 0);
677 ps->callbacks = NULL;
678
679 ps->metadata_wq = create_singlethread_workqueue("ksnaphd");
680 if (!ps->metadata_wq) {
681 kfree(ps);
682 DMERR("couldn't start header metadata update thread");
683 return -ENOMEM;
684 }
685
686 store->destroy = persistent_destroy;
687 store->read_metadata = persistent_read_metadata;
688 store->prepare_exception = persistent_prepare_exception;
689 store->commit_exception = persistent_commit_exception;
690 store->drop_snapshot = persistent_drop_snapshot;
691 store->fraction_full = persistent_fraction_full;
692 store->context = ps;
693
694 return 0;
695}
696
697int dm_persistent_snapshot_init(void)
698{
699 return 0;
700}
701
702void dm_persistent_snapshot_exit(void)
703{
704}
diff --git a/drivers/md/dm-snap-transient.c b/drivers/md/dm-snap-transient.c
new file mode 100644
index 000000000000..7f6e2e6dcb0d
--- /dev/null
+++ b/drivers/md/dm-snap-transient.c
@@ -0,0 +1,98 @@
1/*
2 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2006-2008 Red Hat GmbH
4 *
5 * This file is released under the GPL.
6 */
7
8#include "dm-exception-store.h"
9#include "dm-snap.h"
10
11#include <linux/mm.h>
12#include <linux/pagemap.h>
13#include <linux/vmalloc.h>
14#include <linux/slab.h>
15#include <linux/dm-io.h>
16
17#define DM_MSG_PREFIX "transient snapshot"
18
19/*-----------------------------------------------------------------
20 * Implementation of the store for non-persistent snapshots.
21 *---------------------------------------------------------------*/
22struct transient_c {
23 sector_t next_free;
24};
25
26static void transient_destroy(struct dm_exception_store *store)
27{
28 kfree(store->context);
29}
30
31static int transient_read_metadata(struct dm_exception_store *store,
32 int (*callback)(void *callback_context,
33 chunk_t old, chunk_t new),
34 void *callback_context)
35{
36 return 0;
37}
38
39static int transient_prepare_exception(struct dm_exception_store *store,
40 struct dm_snap_exception *e)
41{
42 struct transient_c *tc = (struct transient_c *) store->context;
43 sector_t size = get_dev_size(store->snap->cow->bdev);
44
45 if (size < (tc->next_free + store->snap->chunk_size))
46 return -1;
47
48 e->new_chunk = sector_to_chunk(store->snap, tc->next_free);
49 tc->next_free += store->snap->chunk_size;
50
51 return 0;
52}
53
54static void transient_commit_exception(struct dm_exception_store *store,
55 struct dm_snap_exception *e,
56 void (*callback) (void *, int success),
57 void *callback_context)
58{
59 /* Just succeed */
60 callback(callback_context, 1);
61}
62
63static void transient_fraction_full(struct dm_exception_store *store,
64 sector_t *numerator, sector_t *denominator)
65{
66 *numerator = ((struct transient_c *) store->context)->next_free;
67 *denominator = get_dev_size(store->snap->cow->bdev);
68}
69
70int dm_create_transient(struct dm_exception_store *store)
71{
72 struct transient_c *tc;
73
74 store->destroy = transient_destroy;
75 store->read_metadata = transient_read_metadata;
76 store->prepare_exception = transient_prepare_exception;
77 store->commit_exception = transient_commit_exception;
78 store->drop_snapshot = NULL;
79 store->fraction_full = transient_fraction_full;
80
81 tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL);
82 if (!tc)
83 return -ENOMEM;
84
85 tc->next_free = 0;
86 store->context = tc;
87
88 return 0;
89}
90
91int dm_transient_snapshot_init(void)
92{
93 return 0;
94}
95
96void dm_transient_snapshot_exit(void)
97{
98}
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 6c96db26b87c..65ff82ff124e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -9,6 +9,7 @@
9#include <linux/blkdev.h> 9#include <linux/blkdev.h>
10#include <linux/ctype.h> 10#include <linux/ctype.h>
11#include <linux/device-mapper.h> 11#include <linux/device-mapper.h>
12#include <linux/delay.h>
12#include <linux/fs.h> 13#include <linux/fs.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/kdev_t.h> 15#include <linux/kdev_t.h>
@@ -20,6 +21,7 @@
20#include <linux/log2.h> 21#include <linux/log2.h>
21#include <linux/dm-kcopyd.h> 22#include <linux/dm-kcopyd.h>
22 23
24#include "dm-exception-store.h"
23#include "dm-snap.h" 25#include "dm-snap.h"
24#include "dm-bio-list.h" 26#include "dm-bio-list.h"
25 27
@@ -428,8 +430,13 @@ out:
428 list_add(&new_e->hash_list, e ? &e->hash_list : l); 430 list_add(&new_e->hash_list, e ? &e->hash_list : l);
429} 431}
430 432
431int dm_add_exception(struct dm_snapshot *s, chunk_t old, chunk_t new) 433/*
434 * Callback used by the exception stores to load exceptions when
435 * initialising.
436 */
437static int dm_add_exception(void *context, chunk_t old, chunk_t new)
432{ 438{
439 struct dm_snapshot *s = context;
433 struct dm_snap_exception *e; 440 struct dm_snap_exception *e;
434 441
435 e = alloc_exception(); 442 e = alloc_exception();
@@ -658,7 +665,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
658 spin_lock_init(&s->tracked_chunk_lock); 665 spin_lock_init(&s->tracked_chunk_lock);
659 666
660 /* Metadata must only be loaded into one table at once */ 667 /* Metadata must only be loaded into one table at once */
661 r = s->store.read_metadata(&s->store); 668 r = s->store.read_metadata(&s->store, dm_add_exception, (void *)s);
662 if (r < 0) { 669 if (r < 0) {
663 ti->error = "Failed to read snapshot metadata"; 670 ti->error = "Failed to read snapshot metadata";
664 goto bad_load_and_register; 671 goto bad_load_and_register;
@@ -735,7 +742,7 @@ static void snapshot_dtr(struct dm_target *ti)
735 unregister_snapshot(s); 742 unregister_snapshot(s);
736 743
737 while (atomic_read(&s->pending_exceptions_count)) 744 while (atomic_read(&s->pending_exceptions_count))
738 yield(); 745 msleep(1);
739 /* 746 /*
740 * Ensure instructions in mempool_destroy aren't reordered 747 * Ensure instructions in mempool_destroy aren't reordered
741 * before atomic_read. 748 * before atomic_read.
@@ -888,10 +895,10 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
888 895
889 /* 896 /*
890 * Check for conflicting reads. This is extremely improbable, 897 * Check for conflicting reads. This is extremely improbable,
891 * so yield() is sufficient and there is no need for a wait queue. 898 * so msleep(1) is sufficient and there is no need for a wait queue.
892 */ 899 */
893 while (__chunk_is_tracked(s, pe->e.old_chunk)) 900 while (__chunk_is_tracked(s, pe->e.old_chunk))
894 yield(); 901 msleep(1);
895 902
896 /* 903 /*
897 * Add a proper exception, and remove the 904 * Add a proper exception, and remove the
@@ -1404,6 +1411,12 @@ static int __init dm_snapshot_init(void)
1404{ 1411{
1405 int r; 1412 int r;
1406 1413
1414 r = dm_exception_store_init();
1415 if (r) {
1416 DMERR("Failed to initialize exception stores");
1417 return r;
1418 }
1419
1407 r = dm_register_target(&snapshot_target); 1420 r = dm_register_target(&snapshot_target);
1408 if (r) { 1421 if (r) {
1409 DMERR("snapshot target register failed %d", r); 1422 DMERR("snapshot target register failed %d", r);
@@ -1452,39 +1465,34 @@ static int __init dm_snapshot_init(void)
1452 1465
1453 return 0; 1466 return 0;
1454 1467
1455 bad_pending_pool: 1468bad_pending_pool:
1456 kmem_cache_destroy(tracked_chunk_cache); 1469 kmem_cache_destroy(tracked_chunk_cache);
1457 bad5: 1470bad5:
1458 kmem_cache_destroy(pending_cache); 1471 kmem_cache_destroy(pending_cache);
1459 bad4: 1472bad4:
1460 kmem_cache_destroy(exception_cache); 1473 kmem_cache_destroy(exception_cache);
1461 bad3: 1474bad3:
1462 exit_origin_hash(); 1475 exit_origin_hash();
1463 bad2: 1476bad2:
1464 dm_unregister_target(&origin_target); 1477 dm_unregister_target(&origin_target);
1465 bad1: 1478bad1:
1466 dm_unregister_target(&snapshot_target); 1479 dm_unregister_target(&snapshot_target);
1467 return r; 1480 return r;
1468} 1481}
1469 1482
1470static void __exit dm_snapshot_exit(void) 1483static void __exit dm_snapshot_exit(void)
1471{ 1484{
1472 int r;
1473
1474 destroy_workqueue(ksnapd); 1485 destroy_workqueue(ksnapd);
1475 1486
1476 r = dm_unregister_target(&snapshot_target); 1487 dm_unregister_target(&snapshot_target);
1477 if (r) 1488 dm_unregister_target(&origin_target);
1478 DMERR("snapshot unregister failed %d", r);
1479
1480 r = dm_unregister_target(&origin_target);
1481 if (r)
1482 DMERR("origin unregister failed %d", r);
1483 1489
1484 exit_origin_hash(); 1490 exit_origin_hash();
1485 kmem_cache_destroy(pending_cache); 1491 kmem_cache_destroy(pending_cache);
1486 kmem_cache_destroy(exception_cache); 1492 kmem_cache_destroy(exception_cache);
1487 kmem_cache_destroy(tracked_chunk_cache); 1493 kmem_cache_destroy(tracked_chunk_cache);
1494
1495 dm_exception_store_exit();
1488} 1496}
1489 1497
1490/* Module hooks */ 1498/* Module hooks */
diff --git a/drivers/md/dm-snap.h b/drivers/md/dm-snap.h
index 99c0106ede2d..d9e62b43cf85 100644
--- a/drivers/md/dm-snap.h
+++ b/drivers/md/dm-snap.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * dm-snapshot.c
3 *
4 * Copyright (C) 2001-2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
5 * 3 *
6 * This file is released under the GPL. 4 * This file is released under the GPL.
@@ -10,6 +8,7 @@
10#define DM_SNAPSHOT_H 8#define DM_SNAPSHOT_H
11 9
12#include <linux/device-mapper.h> 10#include <linux/device-mapper.h>
11#include "dm-exception-store.h"
13#include "dm-bio-list.h" 12#include "dm-bio-list.h"
14#include <linux/blkdev.h> 13#include <linux/blkdev.h>
15#include <linux/workqueue.h> 14#include <linux/workqueue.h>
@@ -20,116 +19,6 @@ struct exception_table {
20 struct list_head *table; 19 struct list_head *table;
21}; 20};
22 21
23/*
24 * The snapshot code deals with largish chunks of the disk at a
25 * time. Typically 32k - 512k.
26 */
27typedef sector_t chunk_t;
28
29/*
30 * An exception is used where an old chunk of data has been
31 * replaced by a new one.
32 * If chunk_t is 64 bits in size, the top 8 bits of new_chunk hold the number
33 * of chunks that follow contiguously. Remaining bits hold the number of the
34 * chunk within the device.
35 */
36struct dm_snap_exception {
37 struct list_head hash_list;
38
39 chunk_t old_chunk;
40 chunk_t new_chunk;
41};
42
43/*
44 * Funtions to manipulate consecutive chunks
45 */
46# if defined(CONFIG_LBD) || (BITS_PER_LONG == 64)
47# define DM_CHUNK_CONSECUTIVE_BITS 8
48# define DM_CHUNK_NUMBER_BITS 56
49
50static inline chunk_t dm_chunk_number(chunk_t chunk)
51{
52 return chunk & (chunk_t)((1ULL << DM_CHUNK_NUMBER_BITS) - 1ULL);
53}
54
55static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
56{
57 return e->new_chunk >> DM_CHUNK_NUMBER_BITS;
58}
59
60static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
61{
62 e->new_chunk += (1ULL << DM_CHUNK_NUMBER_BITS);
63
64 BUG_ON(!dm_consecutive_chunk_count(e));
65}
66
67# else
68# define DM_CHUNK_CONSECUTIVE_BITS 0
69
70static inline chunk_t dm_chunk_number(chunk_t chunk)
71{
72 return chunk;
73}
74
75static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
76{
77 return 0;
78}
79
80static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
81{
82}
83
84# endif
85
86/*
87 * Abstraction to handle the meta/layout of exception stores (the
88 * COW device).
89 */
90struct exception_store {
91
92 /*
93 * Destroys this object when you've finished with it.
94 */
95 void (*destroy) (struct exception_store *store);
96
97 /*
98 * The target shouldn't read the COW device until this is
99 * called.
100 */
101 int (*read_metadata) (struct exception_store *store);
102
103 /*
104 * Find somewhere to store the next exception.
105 */
106 int (*prepare_exception) (struct exception_store *store,
107 struct dm_snap_exception *e);
108
109 /*
110 * Update the metadata with this exception.
111 */
112 void (*commit_exception) (struct exception_store *store,
113 struct dm_snap_exception *e,
114 void (*callback) (void *, int success),
115 void *callback_context);
116
117 /*
118 * The snapshot is invalid, note this in the metadata.
119 */
120 void (*drop_snapshot) (struct exception_store *store);
121
122 /*
123 * Return how full the snapshot is.
124 */
125 void (*fraction_full) (struct exception_store *store,
126 sector_t *numerator,
127 sector_t *denominator);
128
129 struct dm_snapshot *snap;
130 void *context;
131};
132
133#define DM_TRACKED_CHUNK_HASH_SIZE 16 22#define DM_TRACKED_CHUNK_HASH_SIZE 16
134#define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \ 23#define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \
135 (DM_TRACKED_CHUNK_HASH_SIZE - 1)) 24 (DM_TRACKED_CHUNK_HASH_SIZE - 1))
@@ -172,7 +61,7 @@ struct dm_snapshot {
172 spinlock_t pe_lock; 61 spinlock_t pe_lock;
173 62
174 /* The on disk metadata handler */ 63 /* The on disk metadata handler */
175 struct exception_store store; 64 struct dm_exception_store store;
176 65
177 struct dm_kcopyd_client *kcopyd_client; 66 struct dm_kcopyd_client *kcopyd_client;
178 67
@@ -187,20 +76,6 @@ struct dm_snapshot {
187}; 76};
188 77
189/* 78/*
190 * Used by the exception stores to load exceptions hen
191 * initialising.
192 */
193int dm_add_exception(struct dm_snapshot *s, chunk_t old, chunk_t new);
194
195/*
196 * Constructor and destructor for the default persistent
197 * store.
198 */
199int dm_create_persistent(struct exception_store *store);
200
201int dm_create_transient(struct exception_store *store);
202
203/*
204 * Return the number of sectors in the device. 79 * Return the number of sectors in the device.
205 */ 80 */
206static inline sector_t get_dev_size(struct block_device *bdev) 81static inline sector_t get_dev_size(struct block_device *bdev)
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 9e4ef88d421e..41569bc60abc 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -337,9 +337,7 @@ int __init dm_stripe_init(void)
337 337
338void dm_stripe_exit(void) 338void dm_stripe_exit(void)
339{ 339{
340 if (dm_unregister_target(&stripe_target)) 340 dm_unregister_target(&stripe_target);
341 DMWARN("target unregistration failed");
342
343 destroy_workqueue(kstriped); 341 destroy_workqueue(kstriped);
344 342
345 return; 343 return;
diff --git a/drivers/md/dm-sysfs.c b/drivers/md/dm-sysfs.c
new file mode 100644
index 000000000000..a2a45e6c7c8b
--- /dev/null
+++ b/drivers/md/dm-sysfs.c
@@ -0,0 +1,99 @@
1/*
2 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3 *
4 * This file is released under the GPL.
5 */
6
7#include <linux/sysfs.h>
8#include <linux/dm-ioctl.h>
9#include "dm.h"
10
11struct dm_sysfs_attr {
12 struct attribute attr;
13 ssize_t (*show)(struct mapped_device *, char *);
14 ssize_t (*store)(struct mapped_device *, char *);
15};
16
17#define DM_ATTR_RO(_name) \
18struct dm_sysfs_attr dm_attr_##_name = \
19 __ATTR(_name, S_IRUGO, dm_attr_##_name##_show, NULL)
20
21static ssize_t dm_attr_show(struct kobject *kobj, struct attribute *attr,
22 char *page)
23{
24 struct dm_sysfs_attr *dm_attr;
25 struct mapped_device *md;
26 ssize_t ret;
27
28 dm_attr = container_of(attr, struct dm_sysfs_attr, attr);
29 if (!dm_attr->show)
30 return -EIO;
31
32 md = dm_get_from_kobject(kobj);
33 if (!md)
34 return -EINVAL;
35
36 ret = dm_attr->show(md, page);
37 dm_put(md);
38
39 return ret;
40}
41
42static ssize_t dm_attr_name_show(struct mapped_device *md, char *buf)
43{
44 if (dm_copy_name_and_uuid(md, buf, NULL))
45 return -EIO;
46
47 strcat(buf, "\n");
48 return strlen(buf);
49}
50
51static ssize_t dm_attr_uuid_show(struct mapped_device *md, char *buf)
52{
53 if (dm_copy_name_and_uuid(md, NULL, buf))
54 return -EIO;
55
56 strcat(buf, "\n");
57 return strlen(buf);
58}
59
60static DM_ATTR_RO(name);
61static DM_ATTR_RO(uuid);
62
63static struct attribute *dm_attrs[] = {
64 &dm_attr_name.attr,
65 &dm_attr_uuid.attr,
66 NULL,
67};
68
69static struct sysfs_ops dm_sysfs_ops = {
70 .show = dm_attr_show,
71};
72
73/*
74 * dm kobject is embedded in mapped_device structure
75 * no need to define release function here
76 */
77static struct kobj_type dm_ktype = {
78 .sysfs_ops = &dm_sysfs_ops,
79 .default_attrs = dm_attrs,
80};
81
82/*
83 * Initialize kobj
84 * because nobody using md yet, no need to call explicit dm_get/put
85 */
86int dm_sysfs_init(struct mapped_device *md)
87{
88 return kobject_init_and_add(dm_kobject(md), &dm_ktype,
89 &disk_to_dev(dm_disk(md))->kobj,
90 "%s", "dm");
91}
92
93/*
94 * Remove kobj, called after all references removed
95 */
96void dm_sysfs_exit(struct mapped_device *md)
97{
98 kobject_put(dm_kobject(md));
99}
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 04e5fd742c2c..2fd66c30f7f8 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001 Sistina Software (UK) Limited. 2 * Copyright (C) 2001 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
@@ -15,6 +15,7 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/delay.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19 20
20#define DM_MSG_PREFIX "table" 21#define DM_MSG_PREFIX "table"
@@ -24,6 +25,19 @@
24#define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t)) 25#define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t))
25#define CHILDREN_PER_NODE (KEYS_PER_NODE + 1) 26#define CHILDREN_PER_NODE (KEYS_PER_NODE + 1)
26 27
28/*
29 * The table has always exactly one reference from either mapped_device->map
30 * or hash_cell->new_map. This reference is not counted in table->holders.
31 * A pair of dm_create_table/dm_destroy_table functions is used for table
32 * creation/destruction.
33 *
34 * Temporary references from the other code increase table->holders. A pair
35 * of dm_table_get/dm_table_put functions is used to manipulate it.
36 *
37 * When the table is about to be destroyed, we wait for table->holders to
38 * drop to zero.
39 */
40
27struct dm_table { 41struct dm_table {
28 struct mapped_device *md; 42 struct mapped_device *md;
29 atomic_t holders; 43 atomic_t holders;
@@ -38,6 +52,8 @@ struct dm_table {
38 sector_t *highs; 52 sector_t *highs;
39 struct dm_target *targets; 53 struct dm_target *targets;
40 54
55 unsigned barriers_supported:1;
56
41 /* 57 /*
42 * Indicates the rw permissions for the new logical 58 * Indicates the rw permissions for the new logical
43 * device. This should be a combination of FMODE_READ 59 * device. This should be a combination of FMODE_READ
@@ -226,7 +242,8 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
226 return -ENOMEM; 242 return -ENOMEM;
227 243
228 INIT_LIST_HEAD(&t->devices); 244 INIT_LIST_HEAD(&t->devices);
229 atomic_set(&t->holders, 1); 245 atomic_set(&t->holders, 0);
246 t->barriers_supported = 1;
230 247
231 if (!num_targets) 248 if (!num_targets)
232 num_targets = KEYS_PER_NODE; 249 num_targets = KEYS_PER_NODE;
@@ -256,10 +273,14 @@ static void free_devices(struct list_head *devices)
256 } 273 }
257} 274}
258 275
259static void table_destroy(struct dm_table *t) 276void dm_table_destroy(struct dm_table *t)
260{ 277{
261 unsigned int i; 278 unsigned int i;
262 279
280 while (atomic_read(&t->holders))
281 msleep(1);
282 smp_mb();
283
263 /* free the indexes (see dm_table_complete) */ 284 /* free the indexes (see dm_table_complete) */
264 if (t->depth >= 2) 285 if (t->depth >= 2)
265 vfree(t->index[t->depth - 2]); 286 vfree(t->index[t->depth - 2]);
@@ -297,8 +318,8 @@ void dm_table_put(struct dm_table *t)
297 if (!t) 318 if (!t)
298 return; 319 return;
299 320
300 if (atomic_dec_and_test(&t->holders)) 321 smp_mb__before_atomic_dec();
301 table_destroy(t); 322 atomic_dec(&t->holders);
302} 323}
303 324
304/* 325/*
@@ -728,6 +749,10 @@ int dm_table_add_target(struct dm_table *t, const char *type,
728 /* FIXME: the plan is to combine high here and then have 749 /* FIXME: the plan is to combine high here and then have
729 * the merge fn apply the target level restrictions. */ 750 * the merge fn apply the target level restrictions. */
730 combine_restrictions_low(&t->limits, &tgt->limits); 751 combine_restrictions_low(&t->limits, &tgt->limits);
752
753 if (!(tgt->type->features & DM_TARGET_SUPPORTS_BARRIERS))
754 t->barriers_supported = 0;
755
731 return 0; 756 return 0;
732 757
733 bad: 758 bad:
@@ -772,6 +797,12 @@ int dm_table_complete(struct dm_table *t)
772 797
773 check_for_valid_limits(&t->limits); 798 check_for_valid_limits(&t->limits);
774 799
800 /*
801 * We only support barriers if there is exactly one underlying device.
802 */
803 if (!list_is_singular(&t->devices))
804 t->barriers_supported = 0;
805
775 /* how many indexes will the btree have ? */ 806 /* how many indexes will the btree have ? */
776 leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); 807 leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
777 t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); 808 t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
@@ -986,6 +1017,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
986 return t->md; 1017 return t->md;
987} 1018}
988 1019
1020int dm_table_barrier_ok(struct dm_table *t)
1021{
1022 return t->barriers_supported;
1023}
1024EXPORT_SYMBOL(dm_table_barrier_ok);
1025
989EXPORT_SYMBOL(dm_vcalloc); 1026EXPORT_SYMBOL(dm_vcalloc);
990EXPORT_SYMBOL(dm_get_device); 1027EXPORT_SYMBOL(dm_get_device);
991EXPORT_SYMBOL(dm_put_device); 1028EXPORT_SYMBOL(dm_put_device);
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 835cf95b857f..7decf10006e4 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -130,26 +130,26 @@ int dm_register_target(struct target_type *t)
130 return rv; 130 return rv;
131} 131}
132 132
133int dm_unregister_target(struct target_type *t) 133void dm_unregister_target(struct target_type *t)
134{ 134{
135 struct tt_internal *ti; 135 struct tt_internal *ti;
136 136
137 down_write(&_lock); 137 down_write(&_lock);
138 if (!(ti = __find_target_type(t->name))) { 138 if (!(ti = __find_target_type(t->name))) {
139 up_write(&_lock); 139 DMCRIT("Unregistering unrecognised target: %s", t->name);
140 return -EINVAL; 140 BUG();
141 } 141 }
142 142
143 if (ti->use) { 143 if (ti->use) {
144 up_write(&_lock); 144 DMCRIT("Attempt to unregister target still in use: %s",
145 return -ETXTBSY; 145 t->name);
146 BUG();
146 } 147 }
147 148
148 list_del(&ti->list); 149 list_del(&ti->list);
149 kfree(ti); 150 kfree(ti);
150 151
151 up_write(&_lock); 152 up_write(&_lock);
152 return 0;
153} 153}
154 154
155/* 155/*
@@ -187,8 +187,7 @@ int __init dm_target_init(void)
187 187
188void dm_target_exit(void) 188void dm_target_exit(void)
189{ 189{
190 if (dm_unregister_target(&error_target)) 190 dm_unregister_target(&error_target);
191 DMWARN("error target unregistration failed");
192} 191}
193 192
194EXPORT_SYMBOL(dm_register_target); 193EXPORT_SYMBOL(dm_register_target);
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c
index cdbf126ec106..bbc97030c0c2 100644
--- a/drivers/md/dm-zero.c
+++ b/drivers/md/dm-zero.c
@@ -69,10 +69,7 @@ static int __init dm_zero_init(void)
69 69
70static void __exit dm_zero_exit(void) 70static void __exit dm_zero_exit(void)
71{ 71{
72 int r = dm_unregister_target(&zero_target); 72 dm_unregister_target(&zero_target);
73
74 if (r < 0)
75 DMERR("unregister failed %d", r);
76} 73}
77 74
78module_init(dm_zero_init) 75module_init(dm_zero_init)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 421c9f02d8ca..51ba1db4b3e7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
@@ -32,6 +32,7 @@ static unsigned int _major = 0;
32 32
33static DEFINE_SPINLOCK(_minor_lock); 33static DEFINE_SPINLOCK(_minor_lock);
34/* 34/*
35 * For bio-based dm.
35 * One of these is allocated per bio. 36 * One of these is allocated per bio.
36 */ 37 */
37struct dm_io { 38struct dm_io {
@@ -43,6 +44,7 @@ struct dm_io {
43}; 44};
44 45
45/* 46/*
47 * For bio-based dm.
46 * One of these is allocated per target within a bio. Hopefully 48 * One of these is allocated per target within a bio. Hopefully
47 * this will be simplified out one day. 49 * this will be simplified out one day.
48 */ 50 */
@@ -54,6 +56,27 @@ struct dm_target_io {
54 56
55DEFINE_TRACE(block_bio_complete); 57DEFINE_TRACE(block_bio_complete);
56 58
59/*
60 * For request-based dm.
61 * One of these is allocated per request.
62 */
63struct dm_rq_target_io {
64 struct mapped_device *md;
65 struct dm_target *ti;
66 struct request *orig, clone;
67 int error;
68 union map_info info;
69};
70
71/*
72 * For request-based dm.
73 * One of these is allocated per bio.
74 */
75struct dm_rq_clone_bio_info {
76 struct bio *orig;
77 struct request *rq;
78};
79
57union map_info *dm_get_mapinfo(struct bio *bio) 80union map_info *dm_get_mapinfo(struct bio *bio)
58{ 81{
59 if (bio && bio->bi_private) 82 if (bio && bio->bi_private)
@@ -144,11 +167,16 @@ struct mapped_device {
144 167
145 /* forced geometry settings */ 168 /* forced geometry settings */
146 struct hd_geometry geometry; 169 struct hd_geometry geometry;
170
171 /* sysfs handle */
172 struct kobject kobj;
147}; 173};
148 174
149#define MIN_IOS 256 175#define MIN_IOS 256
150static struct kmem_cache *_io_cache; 176static struct kmem_cache *_io_cache;
151static struct kmem_cache *_tio_cache; 177static struct kmem_cache *_tio_cache;
178static struct kmem_cache *_rq_tio_cache;
179static struct kmem_cache *_rq_bio_info_cache;
152 180
153static int __init local_init(void) 181static int __init local_init(void)
154{ 182{
@@ -164,9 +192,17 @@ static int __init local_init(void)
164 if (!_tio_cache) 192 if (!_tio_cache)
165 goto out_free_io_cache; 193 goto out_free_io_cache;
166 194
195 _rq_tio_cache = KMEM_CACHE(dm_rq_target_io, 0);
196 if (!_rq_tio_cache)
197 goto out_free_tio_cache;
198
199 _rq_bio_info_cache = KMEM_CACHE(dm_rq_clone_bio_info, 0);
200 if (!_rq_bio_info_cache)
201 goto out_free_rq_tio_cache;
202
167 r = dm_uevent_init(); 203 r = dm_uevent_init();
168 if (r) 204 if (r)
169 goto out_free_tio_cache; 205 goto out_free_rq_bio_info_cache;
170 206
171 _major = major; 207 _major = major;
172 r = register_blkdev(_major, _name); 208 r = register_blkdev(_major, _name);
@@ -180,6 +216,10 @@ static int __init local_init(void)
180 216
181out_uevent_exit: 217out_uevent_exit:
182 dm_uevent_exit(); 218 dm_uevent_exit();
219out_free_rq_bio_info_cache:
220 kmem_cache_destroy(_rq_bio_info_cache);
221out_free_rq_tio_cache:
222 kmem_cache_destroy(_rq_tio_cache);
183out_free_tio_cache: 223out_free_tio_cache:
184 kmem_cache_destroy(_tio_cache); 224 kmem_cache_destroy(_tio_cache);
185out_free_io_cache: 225out_free_io_cache:
@@ -190,6 +230,8 @@ out_free_io_cache:
190 230
191static void local_exit(void) 231static void local_exit(void)
192{ 232{
233 kmem_cache_destroy(_rq_bio_info_cache);
234 kmem_cache_destroy(_rq_tio_cache);
193 kmem_cache_destroy(_tio_cache); 235 kmem_cache_destroy(_tio_cache);
194 kmem_cache_destroy(_io_cache); 236 kmem_cache_destroy(_io_cache);
195 unregister_blkdev(_major, _name); 237 unregister_blkdev(_major, _name);
@@ -796,7 +838,11 @@ static int __split_bio(struct mapped_device *md, struct bio *bio)
796 ci.map = dm_get_table(md); 838 ci.map = dm_get_table(md);
797 if (unlikely(!ci.map)) 839 if (unlikely(!ci.map))
798 return -EIO; 840 return -EIO;
799 841 if (unlikely(bio_barrier(bio) && !dm_table_barrier_ok(ci.map))) {
842 dm_table_put(ci.map);
843 bio_endio(bio, -EOPNOTSUPP);
844 return 0;
845 }
800 ci.md = md; 846 ci.md = md;
801 ci.bio = bio; 847 ci.bio = bio;
802 ci.io = alloc_io(md); 848 ci.io = alloc_io(md);
@@ -880,15 +926,6 @@ static int dm_request(struct request_queue *q, struct bio *bio)
880 struct mapped_device *md = q->queuedata; 926 struct mapped_device *md = q->queuedata;
881 int cpu; 927 int cpu;
882 928
883 /*
884 * There is no use in forwarding any barrier request since we can't
885 * guarantee it is (or can be) handled by the targets correctly.
886 */
887 if (unlikely(bio_barrier(bio))) {
888 bio_endio(bio, -EOPNOTSUPP);
889 return 0;
890 }
891
892 down_read(&md->io_lock); 929 down_read(&md->io_lock);
893 930
894 cpu = part_stat_lock(); 931 cpu = part_stat_lock();
@@ -943,8 +980,6 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
943 struct mapped_device *md = congested_data; 980 struct mapped_device *md = congested_data;
944 struct dm_table *map; 981 struct dm_table *map;
945 982
946 atomic_inc(&md->pending);
947
948 if (!test_bit(DMF_BLOCK_IO, &md->flags)) { 983 if (!test_bit(DMF_BLOCK_IO, &md->flags)) {
949 map = dm_get_table(md); 984 map = dm_get_table(md);
950 if (map) { 985 if (map) {
@@ -953,10 +988,6 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
953 } 988 }
954 } 989 }
955 990
956 if (!atomic_dec_return(&md->pending))
957 /* nudge anyone waiting on suspend queue */
958 wake_up(&md->wait);
959
960 return r; 991 return r;
961} 992}
962 993
@@ -1216,10 +1247,12 @@ static int __bind(struct mapped_device *md, struct dm_table *t)
1216 1247
1217 if (md->suspended_bdev) 1248 if (md->suspended_bdev)
1218 __set_size(md, size); 1249 __set_size(md, size);
1219 if (size == 0) 1250
1251 if (!size) {
1252 dm_table_destroy(t);
1220 return 0; 1253 return 0;
1254 }
1221 1255
1222 dm_table_get(t);
1223 dm_table_event_callback(t, event_callback, md); 1256 dm_table_event_callback(t, event_callback, md);
1224 1257
1225 write_lock(&md->map_lock); 1258 write_lock(&md->map_lock);
@@ -1241,7 +1274,7 @@ static void __unbind(struct mapped_device *md)
1241 write_lock(&md->map_lock); 1274 write_lock(&md->map_lock);
1242 md->map = NULL; 1275 md->map = NULL;
1243 write_unlock(&md->map_lock); 1276 write_unlock(&md->map_lock);
1244 dm_table_put(map); 1277 dm_table_destroy(map);
1245} 1278}
1246 1279
1247/* 1280/*
@@ -1255,6 +1288,8 @@ int dm_create(int minor, struct mapped_device **result)
1255 if (!md) 1288 if (!md)
1256 return -ENXIO; 1289 return -ENXIO;
1257 1290
1291 dm_sysfs_init(md);
1292
1258 *result = md; 1293 *result = md;
1259 return 0; 1294 return 0;
1260} 1295}
@@ -1330,8 +1365,9 @@ void dm_put(struct mapped_device *md)
1330 dm_table_presuspend_targets(map); 1365 dm_table_presuspend_targets(map);
1331 dm_table_postsuspend_targets(map); 1366 dm_table_postsuspend_targets(map);
1332 } 1367 }
1333 __unbind(md); 1368 dm_sysfs_exit(md);
1334 dm_table_put(map); 1369 dm_table_put(map);
1370 __unbind(md);
1335 free_dev(md); 1371 free_dev(md);
1336 } 1372 }
1337} 1373}
@@ -1669,6 +1705,27 @@ struct gendisk *dm_disk(struct mapped_device *md)
1669 return md->disk; 1705 return md->disk;
1670} 1706}
1671 1707
1708struct kobject *dm_kobject(struct mapped_device *md)
1709{
1710 return &md->kobj;
1711}
1712
1713/*
1714 * struct mapped_device should not be exported outside of dm.c
1715 * so use this check to verify that kobj is part of md structure
1716 */
1717struct mapped_device *dm_get_from_kobject(struct kobject *kobj)
1718{
1719 struct mapped_device *md;
1720
1721 md = container_of(kobj, struct mapped_device, kobj);
1722 if (&md->kobj != kobj)
1723 return NULL;
1724
1725 dm_get(md);
1726 return md;
1727}
1728
1672int dm_suspended(struct mapped_device *md) 1729int dm_suspended(struct mapped_device *md)
1673{ 1730{
1674 return test_bit(DMF_SUSPENDED, &md->flags); 1731 return test_bit(DMF_SUSPENDED, &md->flags);
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 0ade60cdef42..20194e000c5a 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -36,6 +36,7 @@ struct dm_table;
36/*----------------------------------------------------------------- 36/*-----------------------------------------------------------------
37 * Internal table functions. 37 * Internal table functions.
38 *---------------------------------------------------------------*/ 38 *---------------------------------------------------------------*/
39void dm_table_destroy(struct dm_table *t);
39void dm_table_event_callback(struct dm_table *t, 40void dm_table_event_callback(struct dm_table *t,
40 void (*fn)(void *), void *context); 41 void (*fn)(void *), void *context);
41struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index); 42struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index);
@@ -51,6 +52,7 @@ int dm_table_any_congested(struct dm_table *t, int bdi_bits);
51 * To check the return value from dm_table_find_target(). 52 * To check the return value from dm_table_find_target().
52 */ 53 */
53#define dm_target_is_valid(t) ((t)->table) 54#define dm_target_is_valid(t) ((t)->table)
55int dm_table_barrier_ok(struct dm_table *t);
54 56
55/*----------------------------------------------------------------- 57/*-----------------------------------------------------------------
56 * A registry of target types. 58 * A registry of target types.
@@ -72,6 +74,14 @@ int dm_interface_init(void);
72void dm_interface_exit(void); 74void dm_interface_exit(void);
73 75
74/* 76/*
77 * sysfs interface
78 */
79int dm_sysfs_init(struct mapped_device *md);
80void dm_sysfs_exit(struct mapped_device *md);
81struct kobject *dm_kobject(struct mapped_device *md);
82struct mapped_device *dm_get_from_kobject(struct kobject *kobj);
83
84/*
75 * Targets for linear and striped mappings 85 * Targets for linear and striped mappings
76 */ 86 */
77int dm_linear_init(void); 87int dm_linear_init(void);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 7d844af88384..cf06f4d10ad4 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -192,9 +192,9 @@ void saa7146_buffer_timeout(unsigned long data)
192/********************************************************************************/ 192/********************************************************************************/
193/* file operations */ 193/* file operations */
194 194
195static int fops_open(struct inode *inode, struct file *file) 195static int fops_open(struct file *file)
196{ 196{
197 unsigned int minor = iminor(inode); 197 unsigned int minor = video_devdata(file)->minor;
198 struct saa7146_dev *h = NULL, *dev = NULL; 198 struct saa7146_dev *h = NULL, *dev = NULL;
199 struct list_head *list; 199 struct list_head *list;
200 struct saa7146_fh *fh = NULL; 200 struct saa7146_fh *fh = NULL;
@@ -202,7 +202,7 @@ static int fops_open(struct inode *inode, struct file *file)
202 202
203 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 203 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
204 204
205 DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor)); 205 DEB_EE(("file:%p, minor:%d\n", file, minor));
206 206
207 if (mutex_lock_interruptible(&saa7146_devices_lock)) 207 if (mutex_lock_interruptible(&saa7146_devices_lock))
208 return -ERESTARTSYS; 208 return -ERESTARTSYS;
@@ -255,7 +255,7 @@ static int fops_open(struct inode *inode, struct file *file)
255 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 255 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
256 result = saa7146_vbi_uops.open(dev,file); 256 result = saa7146_vbi_uops.open(dev,file);
257 if (dev->ext_vv_data->vbi_fops.open) 257 if (dev->ext_vv_data->vbi_fops.open)
258 dev->ext_vv_data->vbi_fops.open(inode, file); 258 dev->ext_vv_data->vbi_fops.open(file);
259 } else { 259 } else {
260 DEB_S(("initializing video...\n")); 260 DEB_S(("initializing video...\n"));
261 result = saa7146_video_uops.open(dev,file); 261 result = saa7146_video_uops.open(dev,file);
@@ -280,12 +280,12 @@ out:
280 return result; 280 return result;
281} 281}
282 282
283static int fops_release(struct inode *inode, struct file *file) 283static int fops_release(struct file *file)
284{ 284{
285 struct saa7146_fh *fh = file->private_data; 285 struct saa7146_fh *fh = file->private_data;
286 struct saa7146_dev *dev = fh->dev; 286 struct saa7146_dev *dev = fh->dev;
287 287
288 DEB_EE(("inode:%p, file:%p\n",inode,file)); 288 DEB_EE(("file:%p\n", file));
289 289
290 if (mutex_lock_interruptible(&saa7146_devices_lock)) 290 if (mutex_lock_interruptible(&saa7146_devices_lock))
291 return -ERESTARTSYS; 291 return -ERESTARTSYS;
@@ -294,7 +294,7 @@ static int fops_release(struct inode *inode, struct file *file)
294 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) 294 if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
295 saa7146_vbi_uops.release(dev,file); 295 saa7146_vbi_uops.release(dev,file);
296 if (dev->ext_vv_data->vbi_fops.release) 296 if (dev->ext_vv_data->vbi_fops.release)
297 dev->ext_vv_data->vbi_fops.release(inode, file); 297 dev->ext_vv_data->vbi_fops.release(file);
298 } else { 298 } else {
299 saa7146_video_uops.release(dev,file); 299 saa7146_video_uops.release(dev,file);
300 } 300 }
@@ -308,10 +308,10 @@ static int fops_release(struct inode *inode, struct file *file)
308 return 0; 308 return 0;
309} 309}
310 310
311static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 311static long fops_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
312{ 312{
313/* 313/*
314 DEB_EE(("inode:%p, file:%p, cmd:%d, arg:%li\n",inode, file, cmd, arg)); 314 DEB_EE(("file:%p, cmd:%d, arg:%li\n", file, cmd, arg));
315*/ 315*/
316 return video_usercopy(file, cmd, arg, saa7146_video_do_ioctl); 316 return video_usercopy(file, cmd, arg, saa7146_video_do_ioctl);
317} 317}
@@ -416,7 +416,7 @@ static ssize_t fops_write(struct file *file, const char __user *data, size_t cou
416 } 416 }
417} 417}
418 418
419static const struct file_operations video_fops = 419static const struct v4l2_file_operations video_fops =
420{ 420{
421 .owner = THIS_MODULE, 421 .owner = THIS_MODULE,
422 .open = fops_open, 422 .open = fops_open,
@@ -426,7 +426,6 @@ static const struct file_operations video_fops =
426 .poll = fops_poll, 426 .poll = fops_poll,
427 .mmap = fops_mmap, 427 .mmap = fops_mmap,
428 .ioctl = fops_ioctl, 428 .ioctl = fops_ioctl,
429 .llseek = no_llseek,
430}; 429};
431 430
432static void vv_callback(struct saa7146_dev *dev, unsigned long status) 431static void vv_callback(struct saa7146_dev *dev, unsigned long status)
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 101b01dbb8ea..6098b626811f 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -834,13 +834,14 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
834 * copying is done already, arg is a kernel pointer. 834 * copying is done already, arg is a kernel pointer.
835 */ 835 */
836 836
837int saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) 837long saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
838{ 838{
839 struct saa7146_fh *fh = file->private_data; 839 struct saa7146_fh *fh = file->private_data;
840 struct saa7146_dev *dev = fh->dev; 840 struct saa7146_dev *dev = fh->dev;
841 struct saa7146_vv *vv = dev->vv_data; 841 struct saa7146_vv *vv = dev->vv_data;
842 842
843 int err = 0, result = 0, ee = 0; 843 long err = 0;
844 int result = 0, ee = 0;
844 845
845 struct saa7146_use_ops *ops; 846 struct saa7146_use_ops *ops;
846 struct videobuf_queue *q; 847 struct videobuf_queue *q;
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index fb3f3b3adaba..de7adaf5fa5b 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -820,6 +820,15 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
820 int ret; 820 int ret;
821 unsigned frequency = params->frequency / 62500; 821 unsigned frequency = params->frequency / 62500;
822 822
823 if (!tun->stepsize) {
824 /* tuner-core was loaded before the digital tuner was
825 * configured and somehow picked the wrong tuner type */
826 tuner_err("attempt to treat tuner %d (%s) as digital tuner "
827 "without stepsize defined.\n",
828 priv->type, priv->tun->name);
829 return 0; /* failure */
830 }
831
823 t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); 832 t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL);
824 ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); 833 ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb);
825 if (ret < 0) 834 if (ret < 0)
@@ -1059,7 +1068,12 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
1059 memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, 1068 memcpy(&fe->ops.tuner_ops, &simple_tuner_ops,
1060 sizeof(struct dvb_tuner_ops)); 1069 sizeof(struct dvb_tuner_ops));
1061 1070
1062 tuner_info("type set to %d (%s)\n", type, priv->tun->name); 1071 if (type != priv->type)
1072 tuner_warn("couldn't set type to %d. Using %d (%s) instead\n",
1073 type, priv->type, priv->tun->name);
1074 else
1075 tuner_info("type set to %d (%s)\n",
1076 priv->type, priv->tun->name);
1063 1077
1064 if ((debug) || ((atv_input[priv->nr] > 0) || 1078 if ((debug) || ((atv_input[priv->nr] > 0) ||
1065 (dtv_input[priv->nr] > 0))) { 1079 (dtv_input[priv->nr] > 0))) {
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 6c571d9f011c..65d69665f1fc 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -436,8 +436,9 @@ static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env)
436{ 436{
437 struct dvb_device *dvbdev = dev_get_drvdata(dev); 437 struct dvb_device *dvbdev = dev_get_drvdata(dev);
438 438
439 add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id);
440 add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num); 439 add_uevent_var(env, "DVB_ADAPTER_NUM=%d", dvbdev->adapter->num);
440 add_uevent_var(env, "DVB_DEVICE_TYPE=%s", dnames[dvbdev->type]);
441 add_uevent_var(env, "DVB_DEVICE_NUM=%d", dvbdev->id);
441 return 0; 442 return 0;
442} 443}
443 444
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index c1da962cc886..3dd6843864ed 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk.c
@@ -187,7 +187,7 @@ int gp8psk_bcm4500_reload(struct dvb_usb_device *d)
187 /* load BCM4500 firmware */ 187 /* load BCM4500 firmware */
188 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) 188 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM)
189 if (gp8psk_load_bcm4500fw(d)) 189 if (gp8psk_load_bcm4500fw(d))
190 return EINVAL; 190 return -EINVAL;
191 return 0; 191 return 0;
192} 192}
193 193
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c
index 9b6c89e93f16..4f514d39b98f 100644
--- a/drivers/media/dvb/frontends/cx24116.c
+++ b/drivers/media/dvb/frontends/cx24116.c
@@ -1463,6 +1463,7 @@ static struct dvb_frontend_ops cx24116_ops = {
1463 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 1463 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
1464 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 1464 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
1465 FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 1465 FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
1466 FE_CAN_2G_MODULATION |
1466 FE_CAN_QPSK | FE_CAN_RECOVER 1467 FE_CAN_QPSK | FE_CAN_RECOVER
1467 }, 1468 },
1468 1469
diff --git a/drivers/media/dvb/frontends/cx24116.h b/drivers/media/dvb/frontends/cx24116.h
index 4cb3ddd6c626..b1b76b47a14c 100644
--- a/drivers/media/dvb/frontends/cx24116.h
+++ b/drivers/media/dvb/frontends/cx24116.h
@@ -37,7 +37,8 @@ struct cx24116_config {
37 u8 mpg_clk_pos_pol:0x02; 37 u8 mpg_clk_pos_pol:0x02;
38}; 38};
39 39
40#if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) 40#if defined(CONFIG_DVB_CX24116) || \
41 (defined(CONFIG_DVB_CX24116_MODULE) && defined(MODULE))
41extern struct dvb_frontend *cx24116_attach( 42extern struct dvb_frontend *cx24116_attach(
42 const struct cx24116_config *config, 43 const struct cx24116_config *config,
43 struct i2c_adapter *i2c); 44 struct i2c_adapter *i2c);
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c
index 528820170228..bee28f77b93f 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -1618,6 +1618,7 @@ static struct dvb_frontend_ops stb0899_ops = {
1618 1618
1619 .caps = FE_CAN_INVERSION_AUTO | 1619 .caps = FE_CAN_INVERSION_AUTO |
1620 FE_CAN_FEC_AUTO | 1620 FE_CAN_FEC_AUTO |
1621 FE_CAN_2G_MODULATION |
1621 FE_CAN_QPSK 1622 FE_CAN_QPSK
1622 }, 1623 },
1623 1624
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 5506f80e180e..170720b02815 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -587,8 +587,15 @@ static int zl10353_init(struct dvb_frontend *fe)
587 587
588static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) 588static int zl10353_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
589{ 589{
590 struct zl10353_state *state = fe->demodulator_priv;
590 u8 val = 0x0a; 591 u8 val = 0x0a;
591 592
593 if (state->config.no_tuner) {
594 /* No tuner attached to the internal I2C bus */
595 /* If set enable I2C bridge, the main I2C bus stopped hardly */
596 return 0;
597 }
598
592 if (enable) 599 if (enable)
593 val |= 0x10; 600 val |= 0x10;
594 601
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c
index fd62e0b85621..4307e4e8aa34 100644
--- a/drivers/media/dvb/siano/sms-cards.c
+++ b/drivers/media/dvb/siano/sms-cards.c
@@ -120,7 +120,7 @@ static struct sms_board sms_boards[] = {
120 .name = "Hauppauge WinTV MiniCard", 120 .name = "Hauppauge WinTV MiniCard",
121 .type = SMS_NOVA_B0, 121 .type = SMS_NOVA_B0,
122 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw", 122 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
123 .lna_ctrl = 1, 123 .lna_ctrl = -1,
124 }, 124 },
125}; 125};
126 126
@@ -131,9 +131,10 @@ struct sms_board *sms_get_board(int id)
131 return &sms_boards[id]; 131 return &sms_boards[id];
132} 132}
133 133
134static int sms_set_gpio(struct smscore_device_t *coredev, u32 pin, int enable) 134static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
135{ 135{
136 int ret; 136 int lvl, ret;
137 u32 gpio;
137 struct smscore_gpio_config gpioconfig = { 138 struct smscore_gpio_config gpioconfig = {
138 .direction = SMS_GPIO_DIRECTION_OUTPUT, 139 .direction = SMS_GPIO_DIRECTION_OUTPUT,
139 .pullupdown = SMS_GPIO_PULLUPDOWN_NONE, 140 .pullupdown = SMS_GPIO_PULLUPDOWN_NONE,
@@ -145,12 +146,20 @@ static int sms_set_gpio(struct smscore_device_t *coredev, u32 pin, int enable)
145 if (pin == 0) 146 if (pin == 0)
146 return -EINVAL; 147 return -EINVAL;
147 148
148 ret = smscore_configure_gpio(coredev, pin, &gpioconfig); 149 if (pin < 0) {
150 /* inverted gpio */
151 gpio = pin * -1;
152 lvl = enable ? 0 : 1;
153 } else {
154 gpio = pin;
155 lvl = enable ? 1 : 0;
156 }
149 157
158 ret = smscore_configure_gpio(coredev, gpio, &gpioconfig);
150 if (ret < 0) 159 if (ret < 0)
151 return ret; 160 return ret;
152 161
153 return smscore_set_gpio(coredev, pin, enable); 162 return smscore_set_gpio(coredev, gpio, lvl);
154} 163}
155 164
156int sms_board_setup(struct smscore_device_t *coredev) 165int sms_board_setup(struct smscore_device_t *coredev)
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index b4a0cc5dc935..c5b9c70563dc 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -316,7 +316,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
316 return 0; 316 return 0;
317} 317}
318 318
319static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) 319static long av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
320{ 320{
321 struct saa7146_dev *dev = fh->dev; 321 struct saa7146_dev *dev = fh->dev;
322 struct av7110 *av7110 = (struct av7110*) dev->ext_priv; 322 struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
@@ -567,7 +567,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
567 return 0; 567 return 0;
568} 568}
569 569
570static int av7110_vbi_reset(struct inode *inode, struct file *file) 570static int av7110_vbi_reset(struct file *file)
571{ 571{
572 struct saa7146_fh *fh = file->private_data; 572 struct saa7146_fh *fh = file->private_data;
573 struct saa7146_dev *dev = fh->dev; 573 struct saa7146_dev *dev = fh->dev;
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index f996cef79ec1..4182121d7e5d 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1493,7 +1493,7 @@ static struct saa7146_extension_ioctls ioctls[] = {
1493 {0, 0} 1493 {0, 0}
1494}; 1494};
1495 1495
1496static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) 1496static long av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
1497{ 1497{
1498 struct saa7146_dev *dev = fh->dev; 1498 struct saa7146_dev *dev = fh->dev;
1499 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv; 1499 struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
diff --git a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig
index f546bccdb997..2663ae39b886 100644
--- a/drivers/media/dvb/ttusb-budget/Kconfig
+++ b/drivers/media/dvb/ttusb-budget/Kconfig
@@ -1,6 +1,6 @@
1config DVB_TTUSB_BUDGET 1config DVB_TTUSB_BUDGET
2 tristate "Technotrend/Hauppauge Nova-USB devices" 2 tristate "Technotrend/Hauppauge Nova-USB devices"
3 depends on DVB_CORE && USB && I2C 3 depends on DVB_CORE && USB && I2C && PCI
4 select DVB_CX22700 if !DVB_FE_CUSTOMISE 4 select DVB_CX22700 if !DVB_FE_CUSTOMISE
5 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 5 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
6 select DVB_VES1820 if !DVB_FE_CUSTOMISE 6 select DVB_VES1820 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
index d5f48a3102bd..290254ab06db 100644
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ b/drivers/media/dvb/ttusb-dec/Kconfig
@@ -1,6 +1,6 @@
1config DVB_TTUSB_DEC 1config DVB_TTUSB_DEC
2 tristate "Technotrend/Hauppauge USB DEC devices" 2 tristate "Technotrend/Hauppauge USB DEC devices"
3 depends on DVB_CORE && USB && INPUT 3 depends on DVB_CORE && USB && INPUT && PCI
4 select CRC32 4 select CRC32
5 help 5 help
6 Support for external USB adapters designed by Technotrend and 6 Support for external USB adapters designed by Technotrend and
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 5189c4eb439f..3315cac875e5 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -387,4 +387,23 @@ config USB_MR800
387 To compile this driver as a module, choose M here: the 387 To compile this driver as a module, choose M here: the
388 module will be called radio-mr800. 388 module will be called radio-mr800.
389 389
390config RADIO_TEA5764
391 tristate "TEA5764 I2C FM radio support"
392 depends on I2C && VIDEO_V4L2
393 ---help---
394 Say Y here if you want to use the TEA5764 FM chip found in
395 EZX phones. This FM chip is present in EZX phones from Motorola,
396 connected to internal pxa I2C bus.
397
398 To compile this driver as a module, choose M here: the
399 module will be called radio-tea5764.
400
401config RADIO_TEA5764_XTAL
402 bool "TEA5764 crystal reference"
403 depends on RADIO_TEA5764=y
404 default y
405 help
406 Say Y here if TEA5764 have a 32768 Hz crystal in circuit, say N
407 here if TEA5764 reference frequency is connected in FREQIN.
408
390endif # RADIO_ADAPTERS 409endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 240ec63cdafc..0f2b35b3e560 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -19,5 +19,6 @@ obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o
19obj-$(CONFIG_USB_DSBR) += dsbr100.o 19obj-$(CONFIG_USB_DSBR) += dsbr100.o
20obj-$(CONFIG_USB_SI470X) += radio-si470x.o 20obj-$(CONFIG_USB_SI470X) += radio-si470x.o
21obj-$(CONFIG_USB_MR800) += radio-mr800.o 21obj-$(CONFIG_USB_MR800) += radio-mr800.o
22obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
22 23
23EXTRA_CFLAGS += -Isound 24EXTRA_CFLAGS += -Isound
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 5474a22c1b22..2014ebc4e984 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -154,8 +154,8 @@ devices, that would be 76 and 91. */
154static int usb_dsbr100_probe(struct usb_interface *intf, 154static int usb_dsbr100_probe(struct usb_interface *intf,
155 const struct usb_device_id *id); 155 const struct usb_device_id *id);
156static void usb_dsbr100_disconnect(struct usb_interface *intf); 156static void usb_dsbr100_disconnect(struct usb_interface *intf);
157static int usb_dsbr100_open(struct inode *inode, struct file *file); 157static int usb_dsbr100_open(struct file *file);
158static int usb_dsbr100_close(struct inode *inode, struct file *file); 158static int usb_dsbr100_close(struct file *file);
159static int usb_dsbr100_suspend(struct usb_interface *intf, 159static int usb_dsbr100_suspend(struct usb_interface *intf,
160 pm_message_t message); 160 pm_message_t message);
161static int usb_dsbr100_resume(struct usb_interface *intf); 161static int usb_dsbr100_resume(struct usb_interface *intf);
@@ -566,7 +566,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
566 return 0; 566 return 0;
567} 567}
568 568
569static int usb_dsbr100_open(struct inode *inode, struct file *file) 569static int usb_dsbr100_open(struct file *file)
570{ 570{
571 struct dsbr100_device *radio = video_drvdata(file); 571 struct dsbr100_device *radio = video_drvdata(file);
572 int retval; 572 int retval;
@@ -593,7 +593,7 @@ static int usb_dsbr100_open(struct inode *inode, struct file *file)
593 return 0; 593 return 0;
594} 594}
595 595
596static int usb_dsbr100_close(struct inode *inode, struct file *file) 596static int usb_dsbr100_close(struct file *file)
597{ 597{
598 struct dsbr100_device *radio = video_drvdata(file); 598 struct dsbr100_device *radio = video_drvdata(file);
599 int retval; 599 int retval;
@@ -653,15 +653,11 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev)
653} 653}
654 654
655/* File system interface */ 655/* File system interface */
656static const struct file_operations usb_dsbr100_fops = { 656static const struct v4l2_file_operations usb_dsbr100_fops = {
657 .owner = THIS_MODULE, 657 .owner = THIS_MODULE,
658 .open = usb_dsbr100_open, 658 .open = usb_dsbr100_open,
659 .release = usb_dsbr100_close, 659 .release = usb_dsbr100_close,
660 .ioctl = video_ioctl2, 660 .ioctl = video_ioctl2,
661#ifdef CONFIG_COMPAT
662 .compat_ioctl = v4l_compat_ioctl32,
663#endif
664 .llseek = no_llseek,
665}; 661};
666 662
667static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { 663static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = {
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index dd6d3dfcd7d2..bfa13b8b3043 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -374,26 +374,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
374 374
375static struct rt_device rtrack_unit; 375static struct rt_device rtrack_unit;
376 376
377static int rtrack_exclusive_open(struct inode *inode, struct file *file) 377static int rtrack_exclusive_open(struct file *file)
378{ 378{
379 return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0; 379 return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0;
380} 380}
381 381
382static int rtrack_exclusive_release(struct inode *inode, struct file *file) 382static int rtrack_exclusive_release(struct file *file)
383{ 383{
384 clear_bit(0, &rtrack_unit.in_use); 384 clear_bit(0, &rtrack_unit.in_use);
385 return 0; 385 return 0;
386} 386}
387 387
388static const struct file_operations rtrack_fops = { 388static const struct v4l2_file_operations rtrack_fops = {
389 .owner = THIS_MODULE, 389 .owner = THIS_MODULE,
390 .open = rtrack_exclusive_open, 390 .open = rtrack_exclusive_open,
391 .release = rtrack_exclusive_release, 391 .release = rtrack_exclusive_release,
392 .ioctl = video_ioctl2, 392 .ioctl = video_ioctl2,
393#ifdef CONFIG_COMPAT
394 .compat_ioctl = v4l_compat_ioctl32,
395#endif
396 .llseek = no_llseek,
397}; 393};
398 394
399static const struct v4l2_ioctl_ops rtrack_ioctl_ops = { 395static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index d78489573230..5604e881e96c 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -338,26 +338,22 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
338 338
339static struct az_device aztech_unit; 339static struct az_device aztech_unit;
340 340
341static int aztech_exclusive_open(struct inode *inode, struct file *file) 341static int aztech_exclusive_open(struct file *file)
342{ 342{
343 return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0; 343 return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0;
344} 344}
345 345
346static int aztech_exclusive_release(struct inode *inode, struct file *file) 346static int aztech_exclusive_release(struct file *file)
347{ 347{
348 clear_bit(0, &aztech_unit.in_use); 348 clear_bit(0, &aztech_unit.in_use);
349 return 0; 349 return 0;
350} 350}
351 351
352static const struct file_operations aztech_fops = { 352static const struct v4l2_file_operations aztech_fops = {
353 .owner = THIS_MODULE, 353 .owner = THIS_MODULE,
354 .open = aztech_exclusive_open, 354 .open = aztech_exclusive_open,
355 .release = aztech_exclusive_release, 355 .release = aztech_exclusive_release,
356 .ioctl = video_ioctl2, 356 .ioctl = video_ioctl2,
357#ifdef CONFIG_COMPAT
358 .compat_ioctl = v4l_compat_ioctl32,
359#endif
360 .llseek = no_llseek,
361}; 357};
362 358
363static const struct v4l2_ioctl_ops aztech_ioctl_ops = { 359static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index bfd37f38b9ab..cb3075ac104c 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -529,7 +529,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
529} 529}
530 530
531static int 531static int
532cadet_open(struct inode *inode, struct file *file) 532cadet_open(struct file *file)
533{ 533{
534 users++; 534 users++;
535 if (1 == users) init_waitqueue_head(&read_queue); 535 if (1 == users) init_waitqueue_head(&read_queue);
@@ -537,7 +537,7 @@ cadet_open(struct inode *inode, struct file *file)
537} 537}
538 538
539static int 539static int
540cadet_release(struct inode *inode, struct file *file) 540cadet_release(struct file *file)
541{ 541{
542 users--; 542 users--;
543 if (0 == users){ 543 if (0 == users){
@@ -557,17 +557,13 @@ cadet_poll(struct file *file, struct poll_table_struct *wait)
557} 557}
558 558
559 559
560static const struct file_operations cadet_fops = { 560static const struct v4l2_file_operations cadet_fops = {
561 .owner = THIS_MODULE, 561 .owner = THIS_MODULE,
562 .open = cadet_open, 562 .open = cadet_open,
563 .release = cadet_release, 563 .release = cadet_release,
564 .read = cadet_read, 564 .read = cadet_read,
565 .ioctl = video_ioctl2, 565 .ioctl = video_ioctl2,
566 .poll = cadet_poll, 566 .poll = cadet_poll,
567#ifdef CONFIG_COMPAT
568 .compat_ioctl = v4l_compat_ioctl32,
569#endif
570 .llseek = no_llseek,
571}; 567};
572 568
573static const struct v4l2_ioctl_ops cadet_ioctl_ops = { 569static const struct v4l2_ioctl_ops cadet_ioctl_ops = {
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index e15bee6d7cfc..0c96bf8525b0 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -358,26 +358,22 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id );
358 358
359static int mx = 1; 359static int mx = 1;
360 360
361static int gemtek_pci_exclusive_open(struct inode *inode, struct file *file) 361static int gemtek_pci_exclusive_open(struct file *file)
362{ 362{
363 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 363 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
364} 364}
365 365
366static int gemtek_pci_exclusive_release(struct inode *inode, struct file *file) 366static int gemtek_pci_exclusive_release(struct file *file)
367{ 367{
368 clear_bit(0, &in_use); 368 clear_bit(0, &in_use);
369 return 0; 369 return 0;
370} 370}
371 371
372static const struct file_operations gemtek_pci_fops = { 372static const struct v4l2_file_operations gemtek_pci_fops = {
373 .owner = THIS_MODULE, 373 .owner = THIS_MODULE,
374 .open = gemtek_pci_exclusive_open, 374 .open = gemtek_pci_exclusive_open,
375 .release = gemtek_pci_exclusive_release, 375 .release = gemtek_pci_exclusive_release,
376 .ioctl = video_ioctl2, 376 .ioctl = video_ioctl2,
377#ifdef CONFIG_COMPAT
378 .compat_ioctl = v4l_compat_ioctl32,
379#endif
380 .llseek = no_llseek,
381}; 377};
382 378
383static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { 379static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index e13118da307b..2b68be773f13 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -394,26 +394,22 @@ static struct v4l2_queryctrl radio_qctrl[] = {
394 } 394 }
395}; 395};
396 396
397static int gemtek_exclusive_open(struct inode *inode, struct file *file) 397static int gemtek_exclusive_open(struct file *file)
398{ 398{
399 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 399 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
400} 400}
401 401
402static int gemtek_exclusive_release(struct inode *inode, struct file *file) 402static int gemtek_exclusive_release(struct file *file)
403{ 403{
404 clear_bit(0, &in_use); 404 clear_bit(0, &in_use);
405 return 0; 405 return 0;
406} 406}
407 407
408static const struct file_operations gemtek_fops = { 408static const struct v4l2_file_operations gemtek_fops = {
409 .owner = THIS_MODULE, 409 .owner = THIS_MODULE,
410 .open = gemtek_exclusive_open, 410 .open = gemtek_exclusive_open,
411 .release = gemtek_exclusive_release, 411 .release = gemtek_exclusive_release,
412 .ioctl = video_ioctl2, 412 .ioctl = video_ioctl2,
413#ifdef CONFIG_COMPAT
414 .compat_ioctl = v4l_compat_ioctl32,
415#endif
416 .llseek = no_llseek
417}; 413};
418 414
419static int vidioc_querycap(struct file *file, void *priv, 415static int vidioc_querycap(struct file *file, void *priv,
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 4bf4d007bcfa..ba3a13a90013 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -79,12 +79,12 @@ static unsigned long in_use;
79 79
80static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 80static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
81 81
82static int maestro_exclusive_open(struct inode *inode, struct file *file) 82static int maestro_exclusive_open(struct file *file)
83{ 83{
84 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 84 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
85} 85}
86 86
87static int maestro_exclusive_release(struct inode *inode, struct file *file) 87static int maestro_exclusive_release(struct file *file)
88{ 88{
89 clear_bit(0, &in_use); 89 clear_bit(0, &in_use);
90 return 0; 90 return 0;
@@ -110,15 +110,11 @@ static struct pci_driver maestro_r_driver = {
110 .remove = __devexit_p(maestro_remove), 110 .remove = __devexit_p(maestro_remove),
111}; 111};
112 112
113static const struct file_operations maestro_fops = { 113static const struct v4l2_file_operations maestro_fops = {
114 .owner = THIS_MODULE, 114 .owner = THIS_MODULE,
115 .open = maestro_exclusive_open, 115 .open = maestro_exclusive_open,
116 .release = maestro_exclusive_release, 116 .release = maestro_exclusive_release,
117 .ioctl = video_ioctl2, 117 .ioctl = video_ioctl2,
118#ifdef CONFIG_COMPAT
119 .compat_ioctl = v4l_compat_ioctl32,
120#endif
121 .llseek = no_llseek,
122}; 118};
123 119
124struct radio_device { 120struct radio_device {
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index c777a17b00bc..c5dc00aa9c9f 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -100,26 +100,22 @@ static unsigned long in_use;
100#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) 100#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)
101 101
102 102
103static int maxiradio_exclusive_open(struct inode *inode, struct file *file) 103static int maxiradio_exclusive_open(struct file *file)
104{ 104{
105 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 105 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
106} 106}
107 107
108static int maxiradio_exclusive_release(struct inode *inode, struct file *file) 108static int maxiradio_exclusive_release(struct file *file)
109{ 109{
110 clear_bit(0, &in_use); 110 clear_bit(0, &in_use);
111 return 0; 111 return 0;
112} 112}
113 113
114static const struct file_operations maxiradio_fops = { 114static const struct v4l2_file_operations maxiradio_fops = {
115 .owner = THIS_MODULE, 115 .owner = THIS_MODULE,
116 .open = maxiradio_exclusive_open, 116 .open = maxiradio_exclusive_open,
117 .release = maxiradio_exclusive_release, 117 .release = maxiradio_exclusive_release,
118 .ioctl = video_ioctl2, 118 .ioctl = video_ioctl2,
119#ifdef CONFIG_COMPAT
120 .compat_ioctl = v4l_compat_ioctl32,
121#endif
122 .llseek = no_llseek,
123}; 119};
124 120
125static struct radio_device 121static struct radio_device
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index e730eddb2bb5..0747dc8862b0 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -127,8 +127,8 @@ static struct v4l2_queryctrl radio_qctrl[] = {
127static int usb_amradio_probe(struct usb_interface *intf, 127static int usb_amradio_probe(struct usb_interface *intf,
128 const struct usb_device_id *id); 128 const struct usb_device_id *id);
129static void usb_amradio_disconnect(struct usb_interface *intf); 129static void usb_amradio_disconnect(struct usb_interface *intf);
130static int usb_amradio_open(struct inode *inode, struct file *file); 130static int usb_amradio_open(struct file *file);
131static int usb_amradio_close(struct inode *inode, struct file *file); 131static int usb_amradio_close(struct file *file);
132static int usb_amradio_suspend(struct usb_interface *intf, 132static int usb_amradio_suspend(struct usb_interface *intf,
133 pm_message_t message); 133 pm_message_t message);
134static int usb_amradio_resume(struct usb_interface *intf); 134static int usb_amradio_resume(struct usb_interface *intf);
@@ -500,7 +500,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
500} 500}
501 501
502/* open device - amradio_start() and amradio_setfreq() */ 502/* open device - amradio_start() and amradio_setfreq() */
503static int usb_amradio_open(struct inode *inode, struct file *file) 503static int usb_amradio_open(struct file *file)
504{ 504{
505 struct amradio_device *radio = video_get_drvdata(video_devdata(file)); 505 struct amradio_device *radio = video_get_drvdata(video_devdata(file));
506 506
@@ -525,7 +525,7 @@ static int usb_amradio_open(struct inode *inode, struct file *file)
525} 525}
526 526
527/*close device */ 527/*close device */
528static int usb_amradio_close(struct inode *inode, struct file *file) 528static int usb_amradio_close(struct file *file)
529{ 529{
530 struct amradio_device *radio = video_get_drvdata(video_devdata(file)); 530 struct amradio_device *radio = video_get_drvdata(video_devdata(file));
531 int retval; 531 int retval;
@@ -572,15 +572,11 @@ static int usb_amradio_resume(struct usb_interface *intf)
572} 572}
573 573
574/* File system interface */ 574/* File system interface */
575static const struct file_operations usb_amradio_fops = { 575static const struct v4l2_file_operations usb_amradio_fops = {
576 .owner = THIS_MODULE, 576 .owner = THIS_MODULE,
577 .open = usb_amradio_open, 577 .open = usb_amradio_open,
578 .release = usb_amradio_close, 578 .release = usb_amradio_close,
579 .ioctl = video_ioctl2, 579 .ioctl = video_ioctl2,
580#ifdef CONFIG_COMPAT
581 .compat_ioctl = v4l_compat_ioctl32,
582#endif
583 .llseek = no_llseek,
584}; 580};
585 581
586static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { 582static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = {
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 7704f243b6f0..2587227214bf 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -280,26 +280,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
280 280
281static struct rt_device rtrack2_unit; 281static struct rt_device rtrack2_unit;
282 282
283static int rtrack2_exclusive_open(struct inode *inode, struct file *file) 283static int rtrack2_exclusive_open(struct file *file)
284{ 284{
285 return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0; 285 return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0;
286} 286}
287 287
288static int rtrack2_exclusive_release(struct inode *inode, struct file *file) 288static int rtrack2_exclusive_release(struct file *file)
289{ 289{
290 clear_bit(0, &rtrack2_unit.in_use); 290 clear_bit(0, &rtrack2_unit.in_use);
291 return 0; 291 return 0;
292} 292}
293 293
294static const struct file_operations rtrack2_fops = { 294static const struct v4l2_file_operations rtrack2_fops = {
295 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
296 .open = rtrack2_exclusive_open, 296 .open = rtrack2_exclusive_open,
297 .release = rtrack2_exclusive_release, 297 .release = rtrack2_exclusive_release,
298 .ioctl = video_ioctl2, 298 .ioctl = video_ioctl2,
299#ifdef CONFIG_COMPAT
300 .compat_ioctl = v4l_compat_ioctl32,
301#endif
302 .llseek = no_llseek,
303}; 299};
304 300
305static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = { 301static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 834d43651c70..d358e48c2422 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -280,26 +280,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
280 280
281static struct fmi_device fmi_unit; 281static struct fmi_device fmi_unit;
282 282
283static int fmi_exclusive_open(struct inode *inode, struct file *file) 283static int fmi_exclusive_open(struct file *file)
284{ 284{
285 return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0; 285 return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0;
286} 286}
287 287
288static int fmi_exclusive_release(struct inode *inode, struct file *file) 288static int fmi_exclusive_release(struct file *file)
289{ 289{
290 clear_bit(0, &fmi_unit.in_use); 290 clear_bit(0, &fmi_unit.in_use);
291 return 0; 291 return 0;
292} 292}
293 293
294static const struct file_operations fmi_fops = { 294static const struct v4l2_file_operations fmi_fops = {
295 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
296 .open = fmi_exclusive_open, 296 .open = fmi_exclusive_open,
297 .release = fmi_exclusive_release, 297 .release = fmi_exclusive_release,
298 .ioctl = video_ioctl2, 298 .ioctl = video_ioctl2,
299#ifdef CONFIG_COMPAT
300 .compat_ioctl = v4l_compat_ioctl32,
301#endif
302 .llseek = no_llseek,
303}; 299};
304 300
305static const struct v4l2_ioctl_ops fmi_ioctl_ops = { 301static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index b1f47c322e02..92f17a347fa7 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -396,26 +396,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
396 396
397static struct fmr2_device fmr2_unit; 397static struct fmr2_device fmr2_unit;
398 398
399static int fmr2_exclusive_open(struct inode *inode, struct file *file) 399static int fmr2_exclusive_open(struct file *file)
400{ 400{
401 return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0; 401 return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0;
402} 402}
403 403
404static int fmr2_exclusive_release(struct inode *inode, struct file *file) 404static int fmr2_exclusive_release(struct file *file)
405{ 405{
406 clear_bit(0, &fmr2_unit.in_use); 406 clear_bit(0, &fmr2_unit.in_use);
407 return 0; 407 return 0;
408} 408}
409 409
410static const struct file_operations fmr2_fops = { 410static const struct v4l2_file_operations fmr2_fops = {
411 .owner = THIS_MODULE, 411 .owner = THIS_MODULE,
412 .open = fmr2_exclusive_open, 412 .open = fmr2_exclusive_open,
413 .release = fmr2_exclusive_release, 413 .release = fmr2_exclusive_release,
414 .ioctl = video_ioctl2, 414 .ioctl = video_ioctl2,
415#ifdef CONFIG_COMPAT
416 .compat_ioctl = v4l_compat_ioctl32,
417#endif
418 .llseek = no_llseek,
419}; 415};
420 416
421static const struct v4l2_ioctl_ops fmr2_ioctl_ops = { 417static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
index 3e1830293de5..67cbce82cb91 100644
--- a/drivers/media/radio/radio-si470x.c
+++ b/drivers/media/radio/radio-si470x.c
@@ -96,6 +96,8 @@
96 * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com> 96 * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com>
97 * - add support for KWorld USB FM Radio FM700 97 * - add support for KWorld USB FM Radio FM700
98 * - blacklisted KWorld radio in hid-core.c and hid-ids.h 98 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
99 * 2008-12-03 Mark Lord <mlord@pobox.com>
100 * - add support for DealExtreme USB Radio
99 * 101 *
100 * ToDo: 102 * ToDo:
101 * - add firmware download/update support 103 * - add firmware download/update support
@@ -138,6 +140,8 @@ static struct usb_device_id si470x_usb_driver_id_table[] = {
138 { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) }, 140 { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) },
139 /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */ 141 /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */
140 { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) }, 142 { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) },
143 /* DealExtreme USB Radio */
144 { USB_DEVICE_AND_INTERFACE_INFO(0x10c5, 0x819a, USB_CLASS_HID, 0, 0) },
141 /* Terminating entry */ 145 /* Terminating entry */
142 { } 146 { }
143}; 147};
@@ -1075,7 +1079,7 @@ static unsigned int si470x_fops_poll(struct file *file,
1075/* 1079/*
1076 * si470x_fops_open - file open 1080 * si470x_fops_open - file open
1077 */ 1081 */
1078static int si470x_fops_open(struct inode *inode, struct file *file) 1082static int si470x_fops_open(struct file *file)
1079{ 1083{
1080 struct si470x_device *radio = video_drvdata(file); 1084 struct si470x_device *radio = video_drvdata(file);
1081 int retval; 1085 int retval;
@@ -1105,7 +1109,7 @@ done:
1105/* 1109/*
1106 * si470x_fops_release - file release 1110 * si470x_fops_release - file release
1107 */ 1111 */
1108static int si470x_fops_release(struct inode *inode, struct file *file) 1112static int si470x_fops_release(struct file *file)
1109{ 1113{
1110 struct si470x_device *radio = video_drvdata(file); 1114 struct si470x_device *radio = video_drvdata(file);
1111 int retval = 0; 1115 int retval = 0;
@@ -1147,15 +1151,11 @@ done:
1147/* 1151/*
1148 * si470x_fops - file operations interface 1152 * si470x_fops - file operations interface
1149 */ 1153 */
1150static const struct file_operations si470x_fops = { 1154static const struct v4l2_file_operations si470x_fops = {
1151 .owner = THIS_MODULE, 1155 .owner = THIS_MODULE,
1152 .llseek = no_llseek,
1153 .read = si470x_fops_read, 1156 .read = si470x_fops_read,
1154 .poll = si470x_fops_poll, 1157 .poll = si470x_fops_poll,
1155 .ioctl = video_ioctl2, 1158 .ioctl = video_ioctl2,
1156#ifdef CONFIG_COMPAT
1157 .compat_ioctl = v4l_compat_ioctl32,
1158#endif
1159 .open = si470x_fops_open, 1159 .open = si470x_fops_open,
1160 .release = si470x_fops_release, 1160 .release = si470x_fops_release,
1161}; 1161};
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
new file mode 100644
index 000000000000..4d35308fc1ff
--- /dev/null
+++ b/drivers/media/radio/radio-tea5764.c
@@ -0,0 +1,634 @@
1/*
2 * driver/media/radio/radio-tea5764.c
3 *
4 * Driver for TEA5764 radio chip for linux 2.6.
5 * This driver is for TEA5764 chip from NXP, used in EZX phones from Motorola.
6 * The I2C protocol is used for communicate with chip.
7 *
8 * Based in radio-tea5761.c Copyright (C) 2005 Nokia Corporation
9 *
10 * Copyright (c) 2008 Fabio Belavenuto <belavenuto@gmail.com>
11 *
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
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * History:
27 * 2008-12-06 Fabio Belavenuto <belavenuto@gmail.com>
28 * initial code
29 *
30 * TODO:
31 * add platform_data support for IRQs platform dependencies
32 * add RDS support
33 */
34#include <linux/kernel.h>
35#include <linux/module.h>
36#include <linux/init.h> /* Initdata */
37#include <linux/videodev2.h> /* kernel radio structs */
38#include <linux/i2c.h> /* I2C */
39#include <media/v4l2-common.h>
40#include <media/v4l2-ioctl.h>
41#include <linux/version.h> /* for KERNEL_VERSION MACRO */
42
43#define DRIVER_VERSION "v0.01"
44#define RADIO_VERSION KERNEL_VERSION(0, 0, 1)
45
46#define DRIVER_AUTHOR "Fabio Belavenuto <belavenuto@gmail.com>"
47#define DRIVER_DESC "A driver for the TEA5764 radio chip for EZX Phones."
48
49#define PINFO(format, ...)\
50 printk(KERN_INFO KBUILD_MODNAME ": "\
51 DRIVER_VERSION ": " format "\n", ## __VA_ARGS__)
52#define PWARN(format, ...)\
53 printk(KERN_WARNING KBUILD_MODNAME ": "\
54 DRIVER_VERSION ": " format "\n", ## __VA_ARGS__)
55# define PDEBUG(format, ...)\
56 printk(KERN_DEBUG KBUILD_MODNAME ": "\
57 DRIVER_VERSION ": " format "\n", ## __VA_ARGS__)
58
59/* Frequency limits in MHz -- these are European values. For Japanese
60devices, that would be 76000 and 91000. */
61#define FREQ_MIN 87500
62#define FREQ_MAX 108000
63#define FREQ_MUL 16
64
65/* TEA5764 registers */
66#define TEA5764_MANID 0x002b
67#define TEA5764_CHIPID 0x5764
68
69#define TEA5764_INTREG_BLMSK 0x0001
70#define TEA5764_INTREG_FRRMSK 0x0002
71#define TEA5764_INTREG_LEVMSK 0x0008
72#define TEA5764_INTREG_IFMSK 0x0010
73#define TEA5764_INTREG_BLMFLAG 0x0100
74#define TEA5764_INTREG_FRRFLAG 0x0200
75#define TEA5764_INTREG_LEVFLAG 0x0800
76#define TEA5764_INTREG_IFFLAG 0x1000
77
78#define TEA5764_FRQSET_SUD 0x8000
79#define TEA5764_FRQSET_SM 0x4000
80
81#define TEA5764_TNCTRL_PUPD1 0x8000
82#define TEA5764_TNCTRL_PUPD0 0x4000
83#define TEA5764_TNCTRL_BLIM 0x2000
84#define TEA5764_TNCTRL_SWPM 0x1000
85#define TEA5764_TNCTRL_IFCTC 0x0800
86#define TEA5764_TNCTRL_AFM 0x0400
87#define TEA5764_TNCTRL_SMUTE 0x0200
88#define TEA5764_TNCTRL_SNC 0x0100
89#define TEA5764_TNCTRL_MU 0x0080
90#define TEA5764_TNCTRL_SSL1 0x0040
91#define TEA5764_TNCTRL_SSL0 0x0020
92#define TEA5764_TNCTRL_HLSI 0x0010
93#define TEA5764_TNCTRL_MST 0x0008
94#define TEA5764_TNCTRL_SWP 0x0004
95#define TEA5764_TNCTRL_DTC 0x0002
96#define TEA5764_TNCTRL_AHLSI 0x0001
97
98#define TEA5764_TUNCHK_LEVEL(x) (((x) & 0x00F0) >> 4)
99#define TEA5764_TUNCHK_IFCNT(x) (((x) & 0xFE00) >> 9)
100#define TEA5764_TUNCHK_TUNTO 0x0100
101#define TEA5764_TUNCHK_LD 0x0008
102#define TEA5764_TUNCHK_STEREO 0x0004
103
104#define TEA5764_TESTREG_TRIGFR 0x0800
105
106struct tea5764_regs {
107 u16 intreg; /* INTFLAG & INTMSK */
108 u16 frqset; /* FRQSETMSB & FRQSETLSB */
109 u16 tnctrl; /* TNCTRL1 & TNCTRL2 */
110 u16 frqchk; /* FRQCHKMSB & FRQCHKLSB */
111 u16 tunchk; /* IFCHK & LEVCHK */
112 u16 testreg; /* TESTBITS & TESTMODE */
113 u16 rdsstat; /* RDSSTAT1 & RDSSTAT2 */
114 u16 rdslb; /* RDSLBMSB & RDSLBLSB */
115 u16 rdspb; /* RDSPBMSB & RDSPBLSB */
116 u16 rdsbc; /* RDSBBC & RDSGBC */
117 u16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */
118 u16 rdsbbl; /* PAUSEDET & RDSBBL */
119 u16 manid; /* MANID1 & MANID2 */
120 u16 chipid; /* CHIPID1 & CHIPID2 */
121} __attribute__ ((packed));
122
123struct tea5764_write_regs {
124 u8 intreg; /* INTMSK */
125 u16 frqset; /* FRQSETMSB & FRQSETLSB */
126 u16 tnctrl; /* TNCTRL1 & TNCTRL2 */
127 u16 testreg; /* TESTBITS & TESTMODE */
128 u16 rdsctrl; /* RDSCTRL1 & RDSCTRL2 */
129 u16 rdsbbl; /* PAUSEDET & RDSBBL */
130} __attribute__ ((packed));
131
132#ifndef RADIO_TEA5764_XTAL
133#define RADIO_TEA5764_XTAL 1
134#endif
135
136static int radio_nr = -1;
137static int use_xtal = RADIO_TEA5764_XTAL;
138
139struct tea5764_device {
140 struct i2c_client *i2c_client;
141 struct video_device *videodev;
142 struct tea5764_regs regs;
143 struct mutex mutex;
144 int users;
145};
146
147/* I2C code related */
148int tea5764_i2c_read(struct tea5764_device *radio)
149{
150 int i;
151 u16 *p = (u16 *) &radio->regs;
152
153 struct i2c_msg msgs[1] = {
154 { radio->i2c_client->addr, I2C_M_RD, sizeof(radio->regs),
155 (void *)&radio->regs },
156 };
157 if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1)
158 return -EIO;
159 for (i = 0; i < sizeof(struct tea5764_regs) / sizeof(u16); i++)
160 p[i] = __be16_to_cpu(p[i]);
161
162 return 0;
163}
164
165int tea5764_i2c_write(struct tea5764_device *radio)
166{
167 struct tea5764_write_regs wr;
168 struct tea5764_regs *r = &radio->regs;
169 struct i2c_msg msgs[1] = {
170 { radio->i2c_client->addr, 0, sizeof(wr), (void *) &wr },
171 };
172 wr.intreg = r->intreg & 0xff;
173 wr.frqset = __cpu_to_be16(r->frqset);
174 wr.tnctrl = __cpu_to_be16(r->tnctrl);
175 wr.testreg = __cpu_to_be16(r->testreg);
176 wr.rdsctrl = __cpu_to_be16(r->rdsctrl);
177 wr.rdsbbl = __cpu_to_be16(r->rdsbbl);
178 if (i2c_transfer(radio->i2c_client->adapter, msgs, 1) != 1)
179 return -EIO;
180 return 0;
181}
182
183/* V4L2 code related */
184static struct v4l2_queryctrl radio_qctrl[] = {
185 {
186 .id = V4L2_CID_AUDIO_MUTE,
187 .name = "Mute",
188 .minimum = 0,
189 .maximum = 1,
190 .default_value = 1,
191 .type = V4L2_CTRL_TYPE_BOOLEAN,
192 }
193};
194
195static void tea5764_power_up(struct tea5764_device *radio)
196{
197 struct tea5764_regs *r = &radio->regs;
198
199 if (!(r->tnctrl & TEA5764_TNCTRL_PUPD0)) {
200 r->tnctrl &= ~(TEA5764_TNCTRL_AFM | TEA5764_TNCTRL_MU |
201 TEA5764_TNCTRL_HLSI);
202 if (!use_xtal)
203 r->testreg |= TEA5764_TESTREG_TRIGFR;
204 else
205 r->testreg &= ~TEA5764_TESTREG_TRIGFR;
206
207 r->tnctrl |= TEA5764_TNCTRL_PUPD0;
208 tea5764_i2c_write(radio);
209 }
210}
211
212static void tea5764_power_down(struct tea5764_device *radio)
213{
214 struct tea5764_regs *r = &radio->regs;
215
216 if (r->tnctrl & TEA5764_TNCTRL_PUPD0) {
217 r->tnctrl &= ~TEA5764_TNCTRL_PUPD0;
218 tea5764_i2c_write(radio);
219 }
220}
221
222static void tea5764_set_freq(struct tea5764_device *radio, int freq)
223{
224 struct tea5764_regs *r = &radio->regs;
225
226 /* formula: (freq [+ or -] 225000) / 8192 */
227 if (r->tnctrl & TEA5764_TNCTRL_HLSI)
228 r->frqset = (freq + 225000) / 8192;
229 else
230 r->frqset = (freq - 225000) / 8192;
231}
232
233static int tea5764_get_freq(struct tea5764_device *radio)
234{
235 struct tea5764_regs *r = &radio->regs;
236
237 if (r->tnctrl & TEA5764_TNCTRL_HLSI)
238 return (r->frqchk * 8192) - 225000;
239 else
240 return (r->frqchk * 8192) + 225000;
241}
242
243/* tune an frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */
244static void tea5764_tune(struct tea5764_device *radio, int freq)
245{
246 tea5764_set_freq(radio, freq);
247 if (tea5764_i2c_write(radio))
248 PWARN("Could not set frequency!");
249}
250
251static void tea5764_set_audout_mode(struct tea5764_device *radio, int audmode)
252{
253 struct tea5764_regs *r = &radio->regs;
254 int tnctrl = r->tnctrl;
255
256 if (audmode == V4L2_TUNER_MODE_MONO)
257 r->tnctrl |= TEA5764_TNCTRL_MST;
258 else
259 r->tnctrl &= ~TEA5764_TNCTRL_MST;
260 if (tnctrl != r->tnctrl)
261 tea5764_i2c_write(radio);
262}
263
264static int tea5764_get_audout_mode(struct tea5764_device *radio)
265{
266 struct tea5764_regs *r = &radio->regs;
267
268 if (r->tnctrl & TEA5764_TNCTRL_MST)
269 return V4L2_TUNER_MODE_MONO;
270 else
271 return V4L2_TUNER_MODE_STEREO;
272}
273
274static void tea5764_mute(struct tea5764_device *radio, int on)
275{
276 struct tea5764_regs *r = &radio->regs;
277 int tnctrl = r->tnctrl;
278
279 if (on)
280 r->tnctrl |= TEA5764_TNCTRL_MU;
281 else
282 r->tnctrl &= ~TEA5764_TNCTRL_MU;
283 if (tnctrl != r->tnctrl)
284 tea5764_i2c_write(radio);
285}
286
287static int tea5764_is_muted(struct tea5764_device *radio)
288{
289 return radio->regs.tnctrl & TEA5764_TNCTRL_MU;
290}
291
292/* V4L2 vidioc */
293static int vidioc_querycap(struct file *file, void *priv,
294 struct v4l2_capability *v)
295{
296 struct tea5764_device *radio = video_drvdata(file);
297 struct video_device *dev = radio->videodev;
298
299 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver));
300 strlcpy(v->card, dev->name, sizeof(v->card));
301 snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev->dev.bus_id);
302 v->version = RADIO_VERSION;
303 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
304 return 0;
305}
306
307static int vidioc_g_tuner(struct file *file, void *priv,
308 struct v4l2_tuner *v)
309{
310 struct tea5764_device *radio = video_drvdata(file);
311 struct tea5764_regs *r = &radio->regs;
312
313 if (v->index > 0)
314 return -EINVAL;
315
316 memset(v, 0, sizeof(v));
317 strcpy(v->name, "FM");
318 v->type = V4L2_TUNER_RADIO;
319 tea5764_i2c_read(radio);
320 v->rangelow = FREQ_MIN * FREQ_MUL;
321 v->rangehigh = FREQ_MAX * FREQ_MUL;
322 v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
323 if (r->tunchk & TEA5764_TUNCHK_STEREO)
324 v->rxsubchans = V4L2_TUNER_SUB_STEREO;
325 v->audmode = tea5764_get_audout_mode(radio);
326 v->signal = TEA5764_TUNCHK_LEVEL(r->tunchk) * 0xffff / 0xf;
327 v->afc = TEA5764_TUNCHK_IFCNT(r->tunchk);
328
329 return 0;
330}
331
332static int vidioc_s_tuner(struct file *file, void *priv,
333 struct v4l2_tuner *v)
334{
335 struct tea5764_device *radio = video_drvdata(file);
336
337 if (v->index > 0)
338 return -EINVAL;
339
340 tea5764_set_audout_mode(radio, v->audmode);
341 return 0;
342}
343
344static int vidioc_s_frequency(struct file *file, void *priv,
345 struct v4l2_frequency *f)
346{
347 struct tea5764_device *radio = video_drvdata(file);
348
349 if (f->tuner != 0)
350 return -EINVAL;
351 if (f->frequency == 0) {
352 /* We special case this as a power down control. */
353 tea5764_power_down(radio);
354 }
355 if (f->frequency < (FREQ_MIN * FREQ_MUL))
356 return -EINVAL;
357 if (f->frequency > (FREQ_MAX * FREQ_MUL))
358 return -EINVAL;
359 tea5764_power_up(radio);
360 tea5764_tune(radio, (f->frequency * 125) / 2);
361 return 0;
362}
363
364static int vidioc_g_frequency(struct file *file, void *priv,
365 struct v4l2_frequency *f)
366{
367 struct tea5764_device *radio = video_drvdata(file);
368 struct tea5764_regs *r = &radio->regs;
369
370 tea5764_i2c_read(radio);
371 memset(f, 0, sizeof(f));
372 f->type = V4L2_TUNER_RADIO;
373 if (r->tnctrl & TEA5764_TNCTRL_PUPD0)
374 f->frequency = (tea5764_get_freq(radio) * 2) / 125;
375 else
376 f->frequency = 0;
377
378 return 0;
379}
380
381static int vidioc_queryctrl(struct file *file, void *priv,
382 struct v4l2_queryctrl *qc)
383{
384 int i;
385
386 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
387 if (qc->id && qc->id == radio_qctrl[i].id) {
388 memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
389 return 0;
390 }
391 }
392 return -EINVAL;
393}
394
395static int vidioc_g_ctrl(struct file *file, void *priv,
396 struct v4l2_control *ctrl)
397{
398 struct tea5764_device *radio = video_drvdata(file);
399
400 switch (ctrl->id) {
401 case V4L2_CID_AUDIO_MUTE:
402 tea5764_i2c_read(radio);
403 ctrl->value = tea5764_is_muted(radio) ? 1 : 0;
404 return 0;
405 }
406 return -EINVAL;
407}
408
409static int vidioc_s_ctrl(struct file *file, void *priv,
410 struct v4l2_control *ctrl)
411{
412 struct tea5764_device *radio = video_drvdata(file);
413
414 switch (ctrl->id) {
415 case V4L2_CID_AUDIO_MUTE:
416 tea5764_mute(radio, ctrl->value);
417 return 0;
418 }
419 return -EINVAL;
420}
421
422static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
423{
424 *i = 0;
425 return 0;
426}
427
428static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
429{
430 if (i != 0)
431 return -EINVAL;
432 return 0;
433}
434
435static int vidioc_g_audio(struct file *file, void *priv,
436 struct v4l2_audio *a)
437{
438 if (a->index > 1)
439 return -EINVAL;
440
441 strcpy(a->name, "Radio");
442 a->capability = V4L2_AUDCAP_STEREO;
443 return 0;
444}
445
446static int vidioc_s_audio(struct file *file, void *priv,
447 struct v4l2_audio *a)
448{
449 if (a->index != 0)
450 return -EINVAL;
451
452 return 0;
453}
454
455static int tea5764_open(struct file *file)
456{
457 /* Currently we support only one device */
458 int minor = video_devdata(file)->minor;
459 struct tea5764_device *radio = video_drvdata(file);
460
461 if (radio->videodev->minor != minor)
462 return -ENODEV;
463
464 mutex_lock(&radio->mutex);
465 /* Only exclusive access */
466 if (radio->users) {
467 mutex_unlock(&radio->mutex);
468 return -EBUSY;
469 }
470 radio->users++;
471 mutex_unlock(&radio->mutex);
472 file->private_data = radio;
473 return 0;
474}
475
476static int tea5764_close(struct file *file)
477{
478 struct tea5764_device *radio = video_drvdata(file);
479
480 if (!radio)
481 return -ENODEV;
482 mutex_lock(&radio->mutex);
483 radio->users--;
484 mutex_unlock(&radio->mutex);
485 return 0;
486}
487
488/* File system interface */
489static const struct v4l2_file_operations tea5764_fops = {
490 .owner = THIS_MODULE,
491 .open = tea5764_open,
492 .release = tea5764_close,
493 .ioctl = video_ioctl2,
494};
495
496static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
497 .vidioc_querycap = vidioc_querycap,
498 .vidioc_g_tuner = vidioc_g_tuner,
499 .vidioc_s_tuner = vidioc_s_tuner,
500 .vidioc_g_audio = vidioc_g_audio,
501 .vidioc_s_audio = vidioc_s_audio,
502 .vidioc_g_input = vidioc_g_input,
503 .vidioc_s_input = vidioc_s_input,
504 .vidioc_g_frequency = vidioc_g_frequency,
505 .vidioc_s_frequency = vidioc_s_frequency,
506 .vidioc_queryctrl = vidioc_queryctrl,
507 .vidioc_g_ctrl = vidioc_g_ctrl,
508 .vidioc_s_ctrl = vidioc_s_ctrl,
509};
510
511/* V4L2 interface */
512static struct video_device tea5764_radio_template = {
513 .name = "TEA5764 FM-Radio",
514 .fops = &tea5764_fops,
515 .ioctl_ops = &tea5764_ioctl_ops,
516 .release = video_device_release,
517};
518
519/* I2C probe: check if the device exists and register with v4l if it is */
520static int __devinit tea5764_i2c_probe(struct i2c_client *client,
521 const struct i2c_device_id *id)
522{
523 struct tea5764_device *radio;
524 struct tea5764_regs *r;
525 int ret;
526
527 PDEBUG("probe");
528 radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL);
529 if (!radio)
530 return -ENOMEM;
531
532 mutex_init(&radio->mutex);
533 radio->i2c_client = client;
534 ret = tea5764_i2c_read(radio);
535 if (ret)
536 goto errfr;
537 r = &radio->regs;
538 PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid);
539 if (r->chipid != TEA5764_CHIPID ||
540 (r->manid & 0x0fff) != TEA5764_MANID) {
541 PWARN("This chip is not a TEA5764!");
542 ret = -EINVAL;
543 goto errfr;
544 }
545
546 radio->videodev = video_device_alloc();
547 if (!(radio->videodev)) {
548 ret = -ENOMEM;
549 goto errfr;
550 }
551 memcpy(radio->videodev, &tea5764_radio_template,
552 sizeof(tea5764_radio_template));
553
554 i2c_set_clientdata(client, radio);
555 video_set_drvdata(radio->videodev, radio);
556
557 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
558 if (ret < 0) {
559 PWARN("Could not register video device!");
560 goto errrel;
561 }
562
563 /* initialize and power off the chip */
564 tea5764_i2c_read(radio);
565 tea5764_set_audout_mode(radio, V4L2_TUNER_MODE_STEREO);
566 tea5764_mute(radio, 1);
567 tea5764_power_down(radio);
568
569 PINFO("registered.");
570 return 0;
571errrel:
572 video_device_release(radio->videodev);
573errfr:
574 kfree(radio);
575 return ret;
576}
577
578static int __devexit tea5764_i2c_remove(struct i2c_client *client)
579{
580 struct tea5764_device *radio = i2c_get_clientdata(client);
581
582 PDEBUG("remove");
583 if (radio) {
584 tea5764_power_down(radio);
585 video_unregister_device(radio->videodev);
586 kfree(radio);
587 }
588 return 0;
589}
590
591/* I2C subsystem interface */
592static const struct i2c_device_id tea5764_id[] = {
593 { "radio-tea5764", 0 },
594 { } /* Terminating entry */
595};
596MODULE_DEVICE_TABLE(i2c, tea5764_id);
597
598static struct i2c_driver tea5764_i2c_driver = {
599 .driver = {
600 .name = "radio-tea5764",
601 .owner = THIS_MODULE,
602 },
603 .probe = tea5764_i2c_probe,
604 .remove = __devexit_p(tea5764_i2c_remove),
605 .id_table = tea5764_id,
606};
607
608/* init the driver */
609static int __init tea5764_init(void)
610{
611 int ret = i2c_add_driver(&tea5764_i2c_driver);
612
613 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ": "
614 DRIVER_DESC "\n");
615 return ret;
616}
617
618/* cleanup the driver */
619static void __exit tea5764_exit(void)
620{
621 i2c_del_driver(&tea5764_i2c_driver);
622}
623
624MODULE_AUTHOR(DRIVER_AUTHOR);
625MODULE_DESCRIPTION(DRIVER_DESC);
626MODULE_LICENSE("GPL");
627
628module_param(use_xtal, int, 1);
629MODULE_PARM_DESC(use_xtal, "Chip have a xtal connected in board");
630module_param(radio_nr, int, 0);
631MODULE_PARM_DESC(radio_nr, "video4linux device number to use");
632
633module_init(tea5764_init);
634module_exit(tea5764_exit);
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index 0abb186a9473..0798d71abd00 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -352,26 +352,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
352 352
353static struct tt_device terratec_unit; 353static struct tt_device terratec_unit;
354 354
355static int terratec_exclusive_open(struct inode *inode, struct file *file) 355static int terratec_exclusive_open(struct file *file)
356{ 356{
357 return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0; 357 return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0;
358} 358}
359 359
360static int terratec_exclusive_release(struct inode *inode, struct file *file) 360static int terratec_exclusive_release(struct file *file)
361{ 361{
362 clear_bit(0, &terratec_unit.in_use); 362 clear_bit(0, &terratec_unit.in_use);
363 return 0; 363 return 0;
364} 364}
365 365
366static const struct file_operations terratec_fops = { 366static const struct v4l2_file_operations terratec_fops = {
367 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
368 .open = terratec_exclusive_open, 368 .open = terratec_exclusive_open,
369 .release = terratec_exclusive_release, 369 .release = terratec_exclusive_release,
370 .ioctl = video_ioctl2, 370 .ioctl = video_ioctl2,
371#ifdef CONFIG_COMPAT
372 .compat_ioctl = v4l_compat_ioctl32,
373#endif
374 .llseek = no_llseek,
375}; 371};
376 372
377static const struct v4l2_ioctl_ops terratec_ioctl_ops = { 373static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index e7b111fcd105..bdf9cb6a75f4 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -337,26 +337,22 @@ static int vidioc_s_audio(struct file *file, void *priv,
337 return 0; 337 return 0;
338} 338}
339 339
340static int trust_exclusive_open(struct inode *inode, struct file *file) 340static int trust_exclusive_open(struct file *file)
341{ 341{
342 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 342 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
343} 343}
344 344
345static int trust_exclusive_release(struct inode *inode, struct file *file) 345static int trust_exclusive_release(struct file *file)
346{ 346{
347 clear_bit(0, &in_use); 347 clear_bit(0, &in_use);
348 return 0; 348 return 0;
349} 349}
350 350
351static const struct file_operations trust_fops = { 351static const struct v4l2_file_operations trust_fops = {
352 .owner = THIS_MODULE, 352 .owner = THIS_MODULE,
353 .open = trust_exclusive_open, 353 .open = trust_exclusive_open,
354 .release = trust_exclusive_release, 354 .release = trust_exclusive_release,
355 .ioctl = video_ioctl2, 355 .ioctl = video_ioctl2,
356#ifdef CONFIG_COMPAT
357 .compat_ioctl = v4l_compat_ioctl32,
358#endif
359 .llseek = no_llseek,
360}; 356};
361 357
362static const struct v4l2_ioctl_ops trust_ioctl_ops = { 358static const struct v4l2_ioctl_ops trust_ioctl_ops = {
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 952ec35a8415..5c3b319dab37 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -330,26 +330,22 @@ static struct typhoon_device typhoon_unit =
330 .mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ, 330 .mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ,
331}; 331};
332 332
333static int typhoon_exclusive_open(struct inode *inode, struct file *file) 333static int typhoon_exclusive_open(struct file *file)
334{ 334{
335 return test_and_set_bit(0, &typhoon_unit.in_use) ? -EBUSY : 0; 335 return test_and_set_bit(0, &typhoon_unit.in_use) ? -EBUSY : 0;
336} 336}
337 337
338static int typhoon_exclusive_release(struct inode *inode, struct file *file) 338static int typhoon_exclusive_release(struct file *file)
339{ 339{
340 clear_bit(0, &typhoon_unit.in_use); 340 clear_bit(0, &typhoon_unit.in_use);
341 return 0; 341 return 0;
342} 342}
343 343
344static const struct file_operations typhoon_fops = { 344static const struct v4l2_file_operations typhoon_fops = {
345 .owner = THIS_MODULE, 345 .owner = THIS_MODULE,
346 .open = typhoon_exclusive_open, 346 .open = typhoon_exclusive_open,
347 .release = typhoon_exclusive_release, 347 .release = typhoon_exclusive_release,
348 .ioctl = video_ioctl2, 348 .ioctl = video_ioctl2,
349#ifdef CONFIG_COMPAT
350 .compat_ioctl = v4l_compat_ioctl32,
351#endif
352 .llseek = no_llseek,
353}; 349};
354 350
355static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { 351static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 15b10bad6796..d2ac17eeec5f 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -401,27 +401,23 @@ static int vidioc_s_audio(struct file *file, void *priv,
401 401
402static struct zol_device zoltrix_unit; 402static struct zol_device zoltrix_unit;
403 403
404static int zoltrix_exclusive_open(struct inode *inode, struct file *file) 404static int zoltrix_exclusive_open(struct file *file)
405{ 405{
406 return test_and_set_bit(0, &zoltrix_unit.in_use) ? -EBUSY : 0; 406 return test_and_set_bit(0, &zoltrix_unit.in_use) ? -EBUSY : 0;
407} 407}
408 408
409static int zoltrix_exclusive_release(struct inode *inode, struct file *file) 409static int zoltrix_exclusive_release(struct file *file)
410{ 410{
411 clear_bit(0, &zoltrix_unit.in_use); 411 clear_bit(0, &zoltrix_unit.in_use);
412 return 0; 412 return 0;
413} 413}
414 414
415static const struct file_operations zoltrix_fops = 415static const struct v4l2_file_operations zoltrix_fops =
416{ 416{
417 .owner = THIS_MODULE, 417 .owner = THIS_MODULE,
418 .open = zoltrix_exclusive_open, 418 .open = zoltrix_exclusive_open,
419 .release = zoltrix_exclusive_release, 419 .release = zoltrix_exclusive_release,
420 .ioctl = video_ioctl2, 420 .ioctl = video_ioctl2,
421#ifdef CONFIG_COMPAT
422 .compat_ioctl = v4l_compat_ioctl32,
423#endif
424 .llseek = no_llseek,
425}; 421};
426 422
427static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = { 423static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = {
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 1611c33b1aee..72f6d03d2d8f 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -12,7 +12,10 @@ omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o
12 12
13videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o 13videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o
14 14
15obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-compat-ioctl32.o v4l2-int-device.o 15obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
16ifeq ($(CONFIG_COMPAT),y)
17 obj-$(CONFIG_VIDEO_DEV) += v4l2-compat-ioctl32.o
18endif
16 19
17obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o 20obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o
18 21
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index 2ba6abd92b6f..d137bac84511 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -396,7 +396,7 @@ out_up:
396 return ret; 396 return ret;
397} 397}
398 398
399static int ar_do_ioctl(struct file *file, unsigned int cmd, void *arg) 399static long ar_do_ioctl(struct file *file, unsigned int cmd, void *arg)
400{ 400{
401 struct video_device *dev = video_devdata(file); 401 struct video_device *dev = video_devdata(file);
402 struct ar_device *ar = video_get_drvdata(dev); 402 struct ar_device *ar = video_get_drvdata(dev);
@@ -539,7 +539,7 @@ static int ar_do_ioctl(struct file *file, unsigned int cmd, void *arg)
539 return 0; 539 return 0;
540} 540}
541 541
542static int ar_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 542static long ar_ioctl(struct file *file, unsigned int cmd,
543 unsigned long arg) 543 unsigned long arg)
544{ 544{
545 return video_usercopy(file, cmd, arg, ar_do_ioctl); 545 return video_usercopy(file, cmd, arg, ar_do_ioctl);
@@ -744,27 +744,23 @@ void ar_release(struct video_device *vfd)
744 ****************************************************************************/ 744 ****************************************************************************/
745static struct ar_device ardev; 745static struct ar_device ardev;
746 746
747static int ar_exclusive_open(struct inode *inode, struct file *file) 747static int ar_exclusive_open(struct file *file)
748{ 748{
749 return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0; 749 return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0;
750} 750}
751 751
752static int ar_exclusive_release(struct inode *inode, struct file *file) 752static int ar_exclusive_release(struct file *file)
753{ 753{
754 clear_bit(0, &ardev.in_use); 754 clear_bit(0, &ardev.in_use);
755 return 0; 755 return 0;
756} 756}
757 757
758static const struct file_operations ar_fops = { 758static const struct v4l2_file_operations ar_fops = {
759 .owner = THIS_MODULE, 759 .owner = THIS_MODULE,
760 .open = ar_exclusive_open, 760 .open = ar_exclusive_open,
761 .release = ar_exclusive_release, 761 .release = ar_exclusive_release,
762 .read = ar_read, 762 .read = ar_read,
763 .ioctl = ar_ioctl, 763 .ioctl = ar_ioctl,
764#ifdef CONFIG_COMPAT
765 .compat_ioctl = v4l_compat_ioctl32,
766#endif
767 .llseek = no_llseek,
768}; 764};
769 765
770static struct video_device ar_template = { 766static struct video_device ar_template = {
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 9ec4cec2e52d..c71f394fc0ea 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2039,7 +2039,7 @@ static int bttv_log_status(struct file *file, void *f)
2039 2039
2040#ifdef CONFIG_VIDEO_ADV_DEBUG 2040#ifdef CONFIG_VIDEO_ADV_DEBUG
2041static int bttv_g_register(struct file *file, void *f, 2041static int bttv_g_register(struct file *file, void *f,
2042 struct v4l2_register *reg) 2042 struct v4l2_dbg_register *reg)
2043{ 2043{
2044 struct bttv_fh *fh = f; 2044 struct bttv_fh *fh = f;
2045 struct bttv *btv = fh->btv; 2045 struct bttv *btv = fh->btv;
@@ -2047,18 +2047,19 @@ static int bttv_g_register(struct file *file, void *f,
2047 if (!capable(CAP_SYS_ADMIN)) 2047 if (!capable(CAP_SYS_ADMIN))
2048 return -EPERM; 2048 return -EPERM;
2049 2049
2050 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 2050 if (!v4l2_chip_match_host(&reg->match))
2051 return -EINVAL; 2051 return -EINVAL;
2052 2052
2053 /* bt848 has a 12-bit register space */ 2053 /* bt848 has a 12-bit register space */
2054 reg->reg &= 0xfff; 2054 reg->reg &= 0xfff;
2055 reg->val = btread(reg->reg); 2055 reg->val = btread(reg->reg);
2056 reg->size = 1;
2056 2057
2057 return 0; 2058 return 0;
2058} 2059}
2059 2060
2060static int bttv_s_register(struct file *file, void *f, 2061static int bttv_s_register(struct file *file, void *f,
2061 struct v4l2_register *reg) 2062 struct v4l2_dbg_register *reg)
2062{ 2063{
2063 struct bttv_fh *fh = f; 2064 struct bttv_fh *fh = f;
2064 struct bttv *btv = fh->btv; 2065 struct bttv *btv = fh->btv;
@@ -2066,7 +2067,7 @@ static int bttv_s_register(struct file *file, void *f,
2066 if (!capable(CAP_SYS_ADMIN)) 2067 if (!capable(CAP_SYS_ADMIN))
2067 return -EPERM; 2068 return -EPERM;
2068 2069
2069 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 2070 if (!v4l2_chip_match_host(&reg->match))
2070 return -EINVAL; 2071 return -EINVAL;
2071 2072
2072 /* bt848 has a 12-bit register space */ 2073 /* bt848 has a 12-bit register space */
@@ -3208,9 +3209,9 @@ err:
3208 return POLLERR; 3209 return POLLERR;
3209} 3210}
3210 3211
3211static int bttv_open(struct inode *inode, struct file *file) 3212static int bttv_open(struct file *file)
3212{ 3213{
3213 int minor = iminor(inode); 3214 int minor = video_devdata(file)->minor;
3214 struct bttv *btv = NULL; 3215 struct bttv *btv = NULL;
3215 struct bttv_fh *fh; 3216 struct bttv_fh *fh;
3216 enum v4l2_buf_type type = 0; 3217 enum v4l2_buf_type type = 0;
@@ -3291,7 +3292,7 @@ static int bttv_open(struct inode *inode, struct file *file)
3291 return 0; 3292 return 0;
3292} 3293}
3293 3294
3294static int bttv_release(struct inode *inode, struct file *file) 3295static int bttv_release(struct file *file)
3295{ 3296{
3296 struct bttv_fh *fh = file->private_data; 3297 struct bttv_fh *fh = file->private_data;
3297 struct bttv *btv = fh->btv; 3298 struct bttv *btv = fh->btv;
@@ -3346,14 +3347,12 @@ bttv_mmap(struct file *file, struct vm_area_struct *vma)
3346 return videobuf_mmap_mapper(bttv_queue(fh),vma); 3347 return videobuf_mmap_mapper(bttv_queue(fh),vma);
3347} 3348}
3348 3349
3349static const struct file_operations bttv_fops = 3350static const struct v4l2_file_operations bttv_fops =
3350{ 3351{
3351 .owner = THIS_MODULE, 3352 .owner = THIS_MODULE,
3352 .open = bttv_open, 3353 .open = bttv_open,
3353 .release = bttv_release, 3354 .release = bttv_release,
3354 .ioctl = video_ioctl2, 3355 .ioctl = video_ioctl2,
3355 .compat_ioctl = v4l_compat_ioctl32,
3356 .llseek = no_llseek,
3357 .read = bttv_read, 3356 .read = bttv_read,
3358 .mmap = bttv_mmap, 3357 .mmap = bttv_mmap,
3359 .poll = bttv_poll, 3358 .poll = bttv_poll,
@@ -3422,9 +3421,9 @@ static struct video_device bttv_video_template = {
3422/* ----------------------------------------------------------------------- */ 3421/* ----------------------------------------------------------------------- */
3423/* radio interface */ 3422/* radio interface */
3424 3423
3425static int radio_open(struct inode *inode, struct file *file) 3424static int radio_open(struct file *file)
3426{ 3425{
3427 int minor = iminor(inode); 3426 int minor = video_devdata(file)->minor;
3428 struct bttv *btv = NULL; 3427 struct bttv *btv = NULL;
3429 struct bttv_fh *fh; 3428 struct bttv_fh *fh;
3430 unsigned int i; 3429 unsigned int i;
@@ -3467,12 +3466,13 @@ static int radio_open(struct inode *inode, struct file *file)
3467 return 0; 3466 return 0;
3468} 3467}
3469 3468
3470static int radio_release(struct inode *inode, struct file *file) 3469static int radio_release(struct file *file)
3471{ 3470{
3472 struct bttv_fh *fh = file->private_data; 3471 struct bttv_fh *fh = file->private_data;
3473 struct bttv *btv = fh->btv; 3472 struct bttv *btv = fh->btv;
3474 struct rds_command cmd; 3473 struct rds_command cmd;
3475 3474
3475 v4l2_prio_close(&btv->prio,&fh->prio);
3476 file->private_data = NULL; 3476 file->private_data = NULL;
3477 kfree(fh); 3477 kfree(fh);
3478 3478
@@ -3633,15 +3633,13 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)
3633 return cmd.result; 3633 return cmd.result;
3634} 3634}
3635 3635
3636static const struct file_operations radio_fops = 3636static const struct v4l2_file_operations radio_fops =
3637{ 3637{
3638 .owner = THIS_MODULE, 3638 .owner = THIS_MODULE,
3639 .open = radio_open, 3639 .open = radio_open,
3640 .read = radio_read, 3640 .read = radio_read,
3641 .release = radio_release, 3641 .release = radio_release,
3642 .compat_ioctl = v4l_compat_ioctl32,
3643 .ioctl = video_ioctl2, 3642 .ioctl = video_ioctl2,
3644 .llseek = no_llseek,
3645 .poll = radio_poll, 3643 .poll = radio_poll,
3646}; 3644};
3647 3645
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 17f80d03f38e..10dbd4a11b30 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -706,7 +706,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
706 * Video4linux interfacing 706 * Video4linux interfacing
707 */ 707 */
708 708
709static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) 709static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
710{ 710{
711 struct video_device *dev = video_devdata(file); 711 struct video_device *dev = video_devdata(file);
712 struct qcam_device *qcam=(struct qcam_device *)dev; 712 struct qcam_device *qcam=(struct qcam_device *)dev;
@@ -863,7 +863,7 @@ static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
863 return 0; 863 return 0;
864} 864}
865 865
866static int qcam_ioctl(struct inode *inode, struct file *file, 866static long qcam_ioctl(struct file *file,
867 unsigned int cmd, unsigned long arg) 867 unsigned int cmd, unsigned long arg)
868{ 868{
869 return video_usercopy(file, cmd, arg, qcam_do_ioctl); 869 return video_usercopy(file, cmd, arg, qcam_do_ioctl);
@@ -893,7 +893,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
893 return len; 893 return len;
894} 894}
895 895
896static int qcam_exclusive_open(struct inode *inode, struct file *file) 896static int qcam_exclusive_open(struct file *file)
897{ 897{
898 struct video_device *dev = video_devdata(file); 898 struct video_device *dev = video_devdata(file);
899 struct qcam_device *qcam = (struct qcam_device *)dev; 899 struct qcam_device *qcam = (struct qcam_device *)dev;
@@ -901,7 +901,7 @@ static int qcam_exclusive_open(struct inode *inode, struct file *file)
901 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; 901 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0;
902} 902}
903 903
904static int qcam_exclusive_release(struct inode *inode, struct file *file) 904static int qcam_exclusive_release(struct file *file)
905{ 905{
906 struct video_device *dev = video_devdata(file); 906 struct video_device *dev = video_devdata(file);
907 struct qcam_device *qcam = (struct qcam_device *)dev; 907 struct qcam_device *qcam = (struct qcam_device *)dev;
@@ -910,16 +910,12 @@ static int qcam_exclusive_release(struct inode *inode, struct file *file)
910 return 0; 910 return 0;
911} 911}
912 912
913static const struct file_operations qcam_fops = { 913static const struct v4l2_file_operations qcam_fops = {
914 .owner = THIS_MODULE, 914 .owner = THIS_MODULE,
915 .open = qcam_exclusive_open, 915 .open = qcam_exclusive_open,
916 .release = qcam_exclusive_release, 916 .release = qcam_exclusive_release,
917 .ioctl = qcam_ioctl, 917 .ioctl = qcam_ioctl,
918#ifdef CONFIG_COMPAT
919 .compat_ioctl = v4l_compat_ioctl32,
920#endif
921 .read = qcam_read, 918 .read = qcam_read,
922 .llseek = no_llseek,
923}; 919};
924static struct video_device qcam_template= 920static struct video_device qcam_template=
925{ 921{
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 21c71eb085db..85cf1778827a 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -500,7 +500,7 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
500 * Video4linux interfacing 500 * Video4linux interfacing
501 */ 501 */
502 502
503static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg) 503static long qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
504{ 504{
505 struct video_device *dev = video_devdata(file); 505 struct video_device *dev = video_devdata(file);
506 struct qcam_device *qcam=(struct qcam_device *)dev; 506 struct qcam_device *qcam=(struct qcam_device *)dev;
@@ -665,7 +665,7 @@ static int qcam_do_ioctl(struct file *file, unsigned int cmd, void *arg)
665 return 0; 665 return 0;
666} 666}
667 667
668static int qcam_ioctl(struct inode *inode, struct file *file, 668static long qcam_ioctl(struct file *file,
669 unsigned int cmd, unsigned long arg) 669 unsigned int cmd, unsigned long arg)
670{ 670{
671 return video_usercopy(file, cmd, arg, qcam_do_ioctl); 671 return video_usercopy(file, cmd, arg, qcam_do_ioctl);
@@ -687,7 +687,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
687 return len; 687 return len;
688} 688}
689 689
690static int qcam_exclusive_open(struct inode *inode, struct file *file) 690static int qcam_exclusive_open(struct file *file)
691{ 691{
692 struct video_device *dev = video_devdata(file); 692 struct video_device *dev = video_devdata(file);
693 struct qcam_device *qcam = (struct qcam_device *)dev; 693 struct qcam_device *qcam = (struct qcam_device *)dev;
@@ -695,7 +695,7 @@ static int qcam_exclusive_open(struct inode *inode, struct file *file)
695 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0; 695 return test_and_set_bit(0, &qcam->in_use) ? -EBUSY : 0;
696} 696}
697 697
698static int qcam_exclusive_release(struct inode *inode, struct file *file) 698static int qcam_exclusive_release(struct file *file)
699{ 699{
700 struct video_device *dev = video_devdata(file); 700 struct video_device *dev = video_devdata(file);
701 struct qcam_device *qcam = (struct qcam_device *)dev; 701 struct qcam_device *qcam = (struct qcam_device *)dev;
@@ -705,16 +705,12 @@ static int qcam_exclusive_release(struct inode *inode, struct file *file)
705} 705}
706 706
707/* video device template */ 707/* video device template */
708static const struct file_operations qcam_fops = { 708static const struct v4l2_file_operations qcam_fops = {
709 .owner = THIS_MODULE, 709 .owner = THIS_MODULE,
710 .open = qcam_exclusive_open, 710 .open = qcam_exclusive_open,
711 .release = qcam_exclusive_release, 711 .release = qcam_exclusive_release,
712 .ioctl = qcam_ioctl, 712 .ioctl = qcam_ioctl,
713#ifdef CONFIG_COMPAT
714 .compat_ioctl = v4l_compat_ioctl32,
715#endif
716 .read = qcam_read, 713 .read = qcam_read,
717 .llseek = no_llseek,
718}; 714};
719 715
720static struct video_device qcam_template= 716static struct video_device qcam_template=
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 1740b9ebdcef..34a39d2e4703 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -859,7 +859,7 @@ static int __cafe_cam_reset(struct cafe_camera *cam)
859 */ 859 */
860static int cafe_cam_init(struct cafe_camera *cam) 860static int cafe_cam_init(struct cafe_camera *cam)
861{ 861{
862 struct v4l2_chip_ident chip = { V4L2_CHIP_MATCH_I2C_ADDR, 0, 0, 0 }; 862 struct v4l2_dbg_chip_ident chip;
863 int ret; 863 int ret;
864 864
865 mutex_lock(&cam->s_mutex); 865 mutex_lock(&cam->s_mutex);
@@ -869,8 +869,9 @@ static int cafe_cam_init(struct cafe_camera *cam)
869 ret = __cafe_cam_reset(cam); 869 ret = __cafe_cam_reset(cam);
870 if (ret) 870 if (ret)
871 goto out; 871 goto out;
872 chip.match_chip = cam->sensor->addr; 872 chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR;
873 ret = __cafe_cam_cmd(cam, VIDIOC_G_CHIP_IDENT, &chip); 873 chip.match.addr = cam->sensor->addr;
874 ret = __cafe_cam_cmd(cam, VIDIOC_DBG_G_CHIP_IDENT, &chip);
874 if (ret) 875 if (ret)
875 goto out; 876 goto out;
876 cam->sensor_type = chip.ident; 877 cam->sensor_type = chip.ident;
@@ -1472,11 +1473,11 @@ static int cafe_v4l_mmap(struct file *filp, struct vm_area_struct *vma)
1472 1473
1473 1474
1474 1475
1475static int cafe_v4l_open(struct inode *inode, struct file *filp) 1476static int cafe_v4l_open(struct file *filp)
1476{ 1477{
1477 struct cafe_camera *cam; 1478 struct cafe_camera *cam;
1478 1479
1479 cam = cafe_find_dev(iminor(inode)); 1480 cam = cafe_find_dev(video_devdata(filp)->minor);
1480 if (cam == NULL) 1481 if (cam == NULL)
1481 return -ENODEV; 1482 return -ENODEV;
1482 filp->private_data = cam; 1483 filp->private_data = cam;
@@ -1494,7 +1495,7 @@ static int cafe_v4l_open(struct inode *inode, struct file *filp)
1494} 1495}
1495 1496
1496 1497
1497static int cafe_v4l_release(struct inode *inode, struct file *filp) 1498static int cafe_v4l_release(struct file *filp)
1498{ 1499{
1499 struct cafe_camera *cam = filp->private_data; 1500 struct cafe_camera *cam = filp->private_data;
1500 1501
@@ -1759,7 +1760,7 @@ static void cafe_v4l_dev_release(struct video_device *vd)
1759 * clone it for specific real devices. 1760 * clone it for specific real devices.
1760 */ 1761 */
1761 1762
1762static const struct file_operations cafe_v4l_fops = { 1763static const struct v4l2_file_operations cafe_v4l_fops = {
1763 .owner = THIS_MODULE, 1764 .owner = THIS_MODULE,
1764 .open = cafe_v4l_open, 1765 .open = cafe_v4l_open,
1765 .release = cafe_v4l_release, 1766 .release = cafe_v4l_release,
@@ -1767,7 +1768,6 @@ static const struct file_operations cafe_v4l_fops = {
1767 .poll = cafe_v4l_poll, 1768 .poll = cafe_v4l_poll,
1768 .mmap = cafe_v4l_mmap, 1769 .mmap = cafe_v4l_mmap,
1769 .ioctl = video_ioctl2, 1770 .ioctl = video_ioctl2,
1770 .llseek = no_llseek,
1771}; 1771};
1772 1772
1773static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = { 1773static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index 028a400d2453..c3b0c8c63c76 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -3148,7 +3148,7 @@ static void put_cam(struct cpia_camera_ops* ops)
3148} 3148}
3149 3149
3150/* ------------------------- V4L interface --------------------- */ 3150/* ------------------------- V4L interface --------------------- */
3151static int cpia_open(struct inode *inode, struct file *file) 3151static int cpia_open(struct file *file)
3152{ 3152{
3153 struct video_device *dev = video_devdata(file); 3153 struct video_device *dev = video_devdata(file);
3154 struct cam_data *cam = video_get_drvdata(dev); 3154 struct cam_data *cam = video_get_drvdata(dev);
@@ -3225,7 +3225,7 @@ static int cpia_open(struct inode *inode, struct file *file)
3225 return err; 3225 return err;
3226} 3226}
3227 3227
3228static int cpia_close(struct inode *inode, struct file *file) 3228static int cpia_close(struct file *file)
3229{ 3229{
3230 struct video_device *dev = file->private_data; 3230 struct video_device *dev = file->private_data;
3231 struct cam_data *cam = video_get_drvdata(dev); 3231 struct cam_data *cam = video_get_drvdata(dev);
@@ -3333,7 +3333,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
3333 return cam->decompressed_frame.count; 3333 return cam->decompressed_frame.count;
3334} 3334}
3335 3335
3336static int cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg) 3336static long cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg)
3337{ 3337{
3338 struct video_device *dev = file->private_data; 3338 struct video_device *dev = file->private_data;
3339 struct cam_data *cam = video_get_drvdata(dev); 3339 struct cam_data *cam = video_get_drvdata(dev);
@@ -3720,7 +3720,7 @@ static int cpia_do_ioctl(struct file *file, unsigned int cmd, void *arg)
3720 return retval; 3720 return retval;
3721} 3721}
3722 3722
3723static int cpia_ioctl(struct inode *inode, struct file *file, 3723static long cpia_ioctl(struct file *file,
3724 unsigned int cmd, unsigned long arg) 3724 unsigned int cmd, unsigned long arg)
3725{ 3725{
3726 return video_usercopy(file, cmd, arg, cpia_do_ioctl); 3726 return video_usercopy(file, cmd, arg, cpia_do_ioctl);
@@ -3780,17 +3780,13 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
3780 return 0; 3780 return 0;
3781} 3781}
3782 3782
3783static const struct file_operations cpia_fops = { 3783static const struct v4l2_file_operations cpia_fops = {
3784 .owner = THIS_MODULE, 3784 .owner = THIS_MODULE,
3785 .open = cpia_open, 3785 .open = cpia_open,
3786 .release = cpia_close, 3786 .release = cpia_close,
3787 .read = cpia_read, 3787 .read = cpia_read,
3788 .mmap = cpia_mmap, 3788 .mmap = cpia_mmap,
3789 .ioctl = cpia_ioctl, 3789 .ioctl = cpia_ioctl,
3790#ifdef CONFIG_COMPAT
3791 .compat_ioctl = v4l_compat_ioctl32,
3792#endif
3793 .llseek = no_llseek,
3794}; 3790};
3795 3791
3796static struct video_device cpia_template = { 3792static struct video_device cpia_template = {
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 3c2d7eac1197..9c25894fdd8e 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -239,7 +239,7 @@ static struct v4l2_queryctrl controls[] = {
239 * cpia2_open 239 * cpia2_open
240 * 240 *
241 *****************************************************************************/ 241 *****************************************************************************/
242static int cpia2_open(struct inode *inode, struct file *file) 242static int cpia2_open(struct file *file)
243{ 243{
244 struct camera_data *cam = video_drvdata(file); 244 struct camera_data *cam = video_drvdata(file);
245 int retval = 0; 245 int retval = 0;
@@ -302,7 +302,7 @@ err_return:
302 * cpia2_close 302 * cpia2_close
303 * 303 *
304 *****************************************************************************/ 304 *****************************************************************************/
305static int cpia2_close(struct inode *inode, struct file *file) 305static int cpia2_close(struct file *file)
306{ 306{
307 struct video_device *dev = video_devdata(file); 307 struct video_device *dev = video_devdata(file);
308 struct camera_data *cam = video_get_drvdata(dev); 308 struct camera_data *cam = video_get_drvdata(dev);
@@ -1572,10 +1572,10 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file)
1572 * cpia2_ioctl 1572 * cpia2_ioctl
1573 * 1573 *
1574 *****************************************************************************/ 1574 *****************************************************************************/
1575static int cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) 1575static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1576{ 1576{
1577 struct camera_data *cam = video_drvdata(file); 1577 struct camera_data *cam = video_drvdata(file);
1578 int retval = 0; 1578 long retval = 0;
1579 1579
1580 if (!cam) 1580 if (!cam)
1581 return -ENOTTY; 1581 return -ENOTTY;
@@ -1841,7 +1841,7 @@ static int cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1841 return retval; 1841 return retval;
1842} 1842}
1843 1843
1844static int cpia2_ioctl(struct inode *inode, struct file *file, 1844static long cpia2_ioctl(struct file *file,
1845 unsigned int cmd, unsigned long arg) 1845 unsigned int cmd, unsigned long arg)
1846{ 1846{
1847 return video_usercopy(file, cmd, arg, cpia2_do_ioctl); 1847 return video_usercopy(file, cmd, arg, cpia2_do_ioctl);
@@ -1912,17 +1912,13 @@ static void reset_camera_struct_v4l(struct camera_data *cam)
1912/*** 1912/***
1913 * The v4l video device structure initialized for this device 1913 * The v4l video device structure initialized for this device
1914 ***/ 1914 ***/
1915static const struct file_operations fops_template = { 1915static const struct v4l2_file_operations fops_template = {
1916 .owner = THIS_MODULE, 1916 .owner = THIS_MODULE,
1917 .open = cpia2_open, 1917 .open = cpia2_open,
1918 .release = cpia2_close, 1918 .release = cpia2_close,
1919 .read = cpia2_v4l_read, 1919 .read = cpia2_v4l_read,
1920 .poll = cpia2_v4l_poll, 1920 .poll = cpia2_v4l_poll,
1921 .ioctl = cpia2_ioctl, 1921 .ioctl = cpia2_ioctl,
1922 .llseek = no_llseek,
1923#ifdef CONFIG_COMPAT
1924 .compat_ioctl = v4l_compat_ioctl32,
1925#endif
1926 .mmap = cpia2_mmap, 1922 .mmap = cpia2_mmap,
1927}; 1923};
1928 1924
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 70fcd0d5de13..14bebf8a116f 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -95,25 +95,24 @@ static int cs5345_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
95} 95}
96 96
97#ifdef CONFIG_VIDEO_ADV_DEBUG 97#ifdef CONFIG_VIDEO_ADV_DEBUG
98static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 98static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
99{ 99{
100 struct i2c_client *client = v4l2_get_subdevdata(sd); 100 struct i2c_client *client = v4l2_get_subdevdata(sd);
101 101
102 if (!v4l2_chip_match_i2c_client(client, 102 if (!v4l2_chip_match_i2c_client(client, &reg->match))
103 reg->match_type, reg->match_chip))
104 return -EINVAL; 103 return -EINVAL;
105 if (!capable(CAP_SYS_ADMIN)) 104 if (!capable(CAP_SYS_ADMIN))
106 return -EPERM; 105 return -EPERM;
106 reg->size = 1;
107 reg->val = cs5345_read(sd, reg->reg & 0x1f); 107 reg->val = cs5345_read(sd, reg->reg & 0x1f);
108 return 0; 108 return 0;
109} 109}
110 110
111static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 111static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
112{ 112{
113 struct i2c_client *client = v4l2_get_subdevdata(sd); 113 struct i2c_client *client = v4l2_get_subdevdata(sd);
114 114
115 if (!v4l2_chip_match_i2c_client(client, 115 if (!v4l2_chip_match_i2c_client(client, &reg->match))
116 reg->match_type, reg->match_chip))
117 return -EINVAL; 116 return -EINVAL;
118 if (!capable(CAP_SYS_ADMIN)) 117 if (!capable(CAP_SYS_ADMIN))
119 return -EPERM; 118 return -EPERM;
@@ -122,7 +121,7 @@ static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
122} 121}
123#endif 122#endif
124 123
125static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 124static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
126{ 125{
127 struct i2c_client *client = v4l2_get_subdevdata(sd); 126 struct i2c_client *client = v4l2_get_subdevdata(sd);
128 127
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index cb65d519cf78..7292a6316e63 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -102,7 +102,7 @@ static int cs53l32a_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
102 return 0; 102 return 0;
103} 103}
104 104
105static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 105static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
106{ 106{
107 struct i2c_client *client = v4l2_get_subdevdata(sd); 107 struct i2c_client *client = v4l2_get_subdevdata(sd);
108 108
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 425271a29517..055f6e004b2d 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -552,7 +552,7 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end)
552 } 552 }
553} 553}
554 554
555int cx18_v4l2_close(struct inode *inode, struct file *filp) 555int cx18_v4l2_close(struct file *filp)
556{ 556{
557 struct cx18_open_id *id = filp->private_data; 557 struct cx18_open_id *id = filp->private_data;
558 struct cx18 *cx = id->cx; 558 struct cx18 *cx = id->cx;
@@ -650,12 +650,12 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
650 return 0; 650 return 0;
651} 651}
652 652
653int cx18_v4l2_open(struct inode *inode, struct file *filp) 653int cx18_v4l2_open(struct file *filp)
654{ 654{
655 int res, x, y = 0; 655 int res, x, y = 0;
656 struct cx18 *cx = NULL; 656 struct cx18 *cx = NULL;
657 struct cx18_stream *s = NULL; 657 struct cx18_stream *s = NULL;
658 int minor = iminor(inode); 658 int minor = video_devdata(filp)->minor;
659 659
660 /* Find which card this open was on */ 660 /* Find which card this open was on */
661 spin_lock(&cx18_cards_lock); 661 spin_lock(&cx18_cards_lock);
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h
index 46da0282fc7d..92e2d5dab936 100644
--- a/drivers/media/video/cx18/cx18-fileops.h
+++ b/drivers/media/video/cx18/cx18-fileops.h
@@ -22,12 +22,12 @@
22 */ 22 */
23 23
24/* Testing/Debugging */ 24/* Testing/Debugging */
25int cx18_v4l2_open(struct inode *inode, struct file *filp); 25int cx18_v4l2_open(struct file *filp);
26ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, 26ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count,
27 loff_t *pos); 27 loff_t *pos);
28ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count, 28ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count,
29 loff_t *pos); 29 loff_t *pos);
30int cx18_v4l2_close(struct inode *inode, struct file *filp); 30int cx18_v4l2_close(struct file *filp);
31unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait); 31unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait);
32int cx18_start_capture(struct cx18_open_id *id); 32int cx18_start_capture(struct cx18_open_id *id);
33void cx18_stop_capture(struct cx18_open_id *id, int gop_end); 33void cx18_stop_capture(struct cx18_open_id *id, int gop_end);
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 8941f58bed7f..83e1c6333126 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -242,7 +242,7 @@ int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg)
242 return retval; 242 return retval;
243 } 243 }
244 } 244 }
245 if (cmd != VIDIOC_G_CHIP_IDENT) 245 if (cmd != VIDIOC_DBG_G_CHIP_IDENT)
246 CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n", 246 CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n",
247 addr, cmd); 247 addr, cmd);
248 return -ENODEV; 248 return -ENODEV;
@@ -268,17 +268,6 @@ static int cx18_i2c_id_addr(struct cx18 *cx, u32 id)
268 return retval; 268 return retval;
269} 269}
270 270
271/* Find the i2c device name matching the DRIVERID */
272static const char *cx18_i2c_id_name(u32 id)
273{
274 int i;
275
276 for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
277 if (hw_driverids[i] == id)
278 return hw_devicenames[i];
279 return "unknown device";
280}
281
282/* Find the i2c device name matching the CX18_HW_ flag */ 271/* Find the i2c device name matching the CX18_HW_ flag */
283static const char *cx18_i2c_hw_name(u32 hw) 272static const char *cx18_i2c_hw_name(u32 hw)
284{ 273{
@@ -326,21 +315,6 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg)
326 return cx18_call_i2c_client(cx, addr, cmd, arg); 315 return cx18_call_i2c_client(cx, addr, cmd, arg);
327} 316}
328 317
329/* Calls i2c device based on I2C driver ID. */
330int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg)
331{
332 int addr;
333
334 addr = cx18_i2c_id_addr(cx, id);
335 if (addr < 0) {
336 if (cmd != VIDIOC_G_CHIP_IDENT)
337 CX18_ERR("i2c ID 0x%08x (%s) not found for cmd 0x%x!\n",
338 id, cx18_i2c_id_name(id), cmd);
339 return addr;
340 }
341 return cx18_call_i2c_client(cx, addr, cmd, arg);
342}
343
344/* broadcast cmd for all I2C clients and for the gpio subsystem */ 318/* broadcast cmd for all I2C clients and for the gpio subsystem */
345void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) 319void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg)
346{ 320{
diff --git a/drivers/media/video/cx18/cx18-i2c.h b/drivers/media/video/cx18/cx18-i2c.h
index 113c3f9a2cc0..4869739013bd 100644
--- a/drivers/media/video/cx18/cx18-i2c.h
+++ b/drivers/media/video/cx18/cx18-i2c.h
@@ -23,7 +23,6 @@
23 23
24int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw); 24int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw);
25int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg); 25int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg);
26int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg);
27int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg); 26int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg);
28void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg); 27void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg);
29int cx18_i2c_register(struct cx18 *cx, unsigned idx); 28int cx18_i2c_register(struct cx18 *cx, unsigned idx);
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index e6087486f889..7086aaba77d6 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -254,30 +254,24 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
254} 254}
255 255
256static int cx18_g_chip_ident(struct file *file, void *fh, 256static int cx18_g_chip_ident(struct file *file, void *fh,
257 struct v4l2_chip_ident *chip) 257 struct v4l2_dbg_chip_ident *chip)
258{ 258{
259 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 259 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
260 260
261 chip->ident = V4L2_IDENT_NONE; 261 chip->ident = V4L2_IDENT_NONE;
262 chip->revision = 0; 262 chip->revision = 0;
263 if (chip->match_type == V4L2_CHIP_MATCH_HOST) { 263 if (v4l2_chip_match_host(&chip->match)) {
264 if (v4l2_chip_match_host(chip->match_type, chip->match_chip)) 264 chip->ident = V4L2_IDENT_CX23418;
265 chip->ident = V4L2_IDENT_CX23418;
266 return 0; 265 return 0;
267 } 266 }
268 if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 267 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_CHIP_IDENT, chip);
269 return cx18_i2c_id(cx, chip->match_chip, VIDIOC_G_CHIP_IDENT, 268 return 0;
270 chip);
271 if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR)
272 return cx18_call_i2c_client(cx, chip->match_chip,
273 VIDIOC_G_CHIP_IDENT, chip);
274 return -EINVAL;
275} 269}
276 270
277#ifdef CONFIG_VIDEO_ADV_DEBUG 271#ifdef CONFIG_VIDEO_ADV_DEBUG
278static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) 272static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
279{ 273{
280 struct v4l2_register *regs = arg; 274 struct v4l2_dbg_register *regs = arg;
281 unsigned long flags; 275 unsigned long flags;
282 276
283 if (!capable(CAP_SYS_ADMIN)) 277 if (!capable(CAP_SYS_ADMIN))
@@ -286,6 +280,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
286 return -EINVAL; 280 return -EINVAL;
287 281
288 spin_lock_irqsave(&cx18_cards_lock, flags); 282 spin_lock_irqsave(&cx18_cards_lock, flags);
283 regs->size = 4;
289 if (cmd == VIDIOC_DBG_G_REGISTER) 284 if (cmd == VIDIOC_DBG_G_REGISTER)
290 regs->val = cx18_read_enc(cx, regs->reg); 285 regs->val = cx18_read_enc(cx, regs->reg);
291 else 286 else
@@ -295,31 +290,25 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
295} 290}
296 291
297static int cx18_g_register(struct file *file, void *fh, 292static int cx18_g_register(struct file *file, void *fh,
298 struct v4l2_register *reg) 293 struct v4l2_dbg_register *reg)
299{ 294{
300 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 295 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
301 296
302 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 297 if (v4l2_chip_match_host(&reg->match))
303 return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg); 298 return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
304 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 299 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_REGISTER, reg);
305 return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER, 300 return 0;
306 reg);
307 return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER,
308 reg);
309} 301}
310 302
311static int cx18_s_register(struct file *file, void *fh, 303static int cx18_s_register(struct file *file, void *fh,
312 struct v4l2_register *reg) 304 struct v4l2_dbg_register *reg)
313{ 305{
314 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 306 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
315 307
316 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 308 if (v4l2_chip_match_host(&reg->match))
317 return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg); 309 return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
318 if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) 310 cx18_call_i2c_clients(cx, VIDIOC_DBG_S_REGISTER, reg);
319 return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER, 311 return 0;
320 reg);
321 return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER,
322 reg);
323} 312}
324#endif 313#endif
325 314
@@ -755,7 +744,7 @@ static int cx18_log_status(struct file *file, void *fh)
755 return 0; 744 return 0;
756} 745}
757 746
758static int cx18_default(struct file *file, void *fh, int cmd, void *arg) 747static long cx18_default(struct file *file, void *fh, int cmd, void *arg)
759{ 748{
760 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; 749 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
761 750
@@ -783,19 +772,19 @@ static int cx18_default(struct file *file, void *fh, int cmd, void *arg)
783 return 0; 772 return 0;
784} 773}
785 774
786int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 775long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
787 unsigned long arg) 776 unsigned long arg)
788{ 777{
789 struct video_device *vfd = video_devdata(filp); 778 struct video_device *vfd = video_devdata(filp);
790 struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; 779 struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data;
791 struct cx18 *cx = id->cx; 780 struct cx18 *cx = id->cx;
792 int res; 781 long res;
793 782
794 mutex_lock(&cx->serialize_lock); 783 mutex_lock(&cx->serialize_lock);
795 784
796 if (cx18_debug & CX18_DBGFLG_IOCTL) 785 if (cx18_debug & CX18_DBGFLG_IOCTL)
797 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; 786 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
798 res = video_ioctl2(inode, filp, cmd, arg); 787 res = video_ioctl2(filp, cmd, arg);
799 vfd->debug = 0; 788 vfd->debug = 0;
800 mutex_unlock(&cx->serialize_lock); 789 mutex_unlock(&cx->serialize_lock);
801 return res; 790 return res;
diff --git a/drivers/media/video/cx18/cx18-ioctl.h b/drivers/media/video/cx18/cx18-ioctl.h
index 08fe24e9510e..e2ca0d152116 100644
--- a/drivers/media/video/cx18/cx18-ioctl.h
+++ b/drivers/media/video/cx18/cx18-ioctl.h
@@ -29,5 +29,5 @@ void cx18_set_funcs(struct video_device *vdev);
29int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); 29int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std);
30int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); 30int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
31int cx18_s_input(struct file *file, void *fh, unsigned int inp); 31int cx18_s_input(struct file *file, void *fh, unsigned int inp);
32int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 32long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
33 unsigned long arg); 33 unsigned long arg);
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 63c336c95ff5..89c1ec94f335 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -37,13 +37,12 @@
37 37
38#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 38#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
39 39
40static struct file_operations cx18_v4l2_enc_fops = { 40static struct v4l2_file_operations cx18_v4l2_enc_fops = {
41 .owner = THIS_MODULE, 41 .owner = THIS_MODULE,
42 .read = cx18_v4l2_read, 42 .read = cx18_v4l2_read,
43 .open = cx18_v4l2_open, 43 .open = cx18_v4l2_open,
44 /* FIXME change to video_ioctl2 if serialization lock can be removed */ 44 /* FIXME change to video_ioctl2 if serialization lock can be removed */
45 .ioctl = cx18_v4l2_ioctl, 45 .ioctl = cx18_v4l2_ioctl,
46 .compat_ioctl = v4l_compat_ioctl32,
47 .release = cx18_v4l2_close, 46 .release = cx18_v4l2_close,
48 .poll = cx18_v4l2_enc_poll, 47 .poll = cx18_v4l2_enc_poll,
49}; 48};
@@ -61,49 +60,41 @@ static struct {
61 int num_offset; 60 int num_offset;
62 int dma; 61 int dma;
63 enum v4l2_buf_type buf_type; 62 enum v4l2_buf_type buf_type;
64 struct file_operations *fops;
65} cx18_stream_info[] = { 63} cx18_stream_info[] = {
66 { /* CX18_ENC_STREAM_TYPE_MPG */ 64 { /* CX18_ENC_STREAM_TYPE_MPG */
67 "encoder MPEG", 65 "encoder MPEG",
68 VFL_TYPE_GRABBER, 0, 66 VFL_TYPE_GRABBER, 0,
69 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 67 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
70 &cx18_v4l2_enc_fops
71 }, 68 },
72 { /* CX18_ENC_STREAM_TYPE_TS */ 69 { /* CX18_ENC_STREAM_TYPE_TS */
73 "TS", 70 "TS",
74 VFL_TYPE_GRABBER, -1, 71 VFL_TYPE_GRABBER, -1,
75 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 72 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
76 &cx18_v4l2_enc_fops
77 }, 73 },
78 { /* CX18_ENC_STREAM_TYPE_YUV */ 74 { /* CX18_ENC_STREAM_TYPE_YUV */
79 "encoder YUV", 75 "encoder YUV",
80 VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, 76 VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET,
81 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 77 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
82 &cx18_v4l2_enc_fops
83 }, 78 },
84 { /* CX18_ENC_STREAM_TYPE_VBI */ 79 { /* CX18_ENC_STREAM_TYPE_VBI */
85 "encoder VBI", 80 "encoder VBI",
86 VFL_TYPE_VBI, 0, 81 VFL_TYPE_VBI, 0,
87 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE, 82 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE,
88 &cx18_v4l2_enc_fops
89 }, 83 },
90 { /* CX18_ENC_STREAM_TYPE_PCM */ 84 { /* CX18_ENC_STREAM_TYPE_PCM */
91 "encoder PCM audio", 85 "encoder PCM audio",
92 VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET, 86 VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET,
93 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE, 87 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE,
94 &cx18_v4l2_enc_fops
95 }, 88 },
96 { /* CX18_ENC_STREAM_TYPE_IDX */ 89 { /* CX18_ENC_STREAM_TYPE_IDX */
97 "encoder IDX", 90 "encoder IDX",
98 VFL_TYPE_GRABBER, -1, 91 VFL_TYPE_GRABBER, -1,
99 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, 92 PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE,
100 &cx18_v4l2_enc_fops
101 }, 93 },
102 { /* CX18_ENC_STREAM_TYPE_RAD */ 94 { /* CX18_ENC_STREAM_TYPE_RAD */
103 "encoder radio", 95 "encoder radio",
104 VFL_TYPE_RADIO, 0, 96 VFL_TYPE_RADIO, 0,
105 PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE, 97 PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE,
106 &cx18_v4l2_enc_fops
107 }, 98 },
108}; 99};
109 100
@@ -184,7 +175,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
184 175
185 s->v4l2dev->num = num; 176 s->v4l2dev->num = num;
186 s->v4l2dev->parent = &cx->dev->dev; 177 s->v4l2dev->parent = &cx->dev->dev;
187 s->v4l2dev->fops = cx18_stream_info[type].fops; 178 s->v4l2dev->fops = &cx18_v4l2_enc_fops;
188 s->v4l2dev->release = video_device_release; 179 s->v4l2dev->release = video_device_release;
189 s->v4l2dev->tvnorms = V4L2_STD_ALL; 180 s->v4l2dev->tvnorms = V4L2_STD_ALL;
190 cx18_set_funcs(s->v4l2dev); 181 cx18_set_funcs(s->v4l2dev);
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 798d24024353..8f1db57bd1dd 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1027,12 +1027,13 @@ static int cx23885_initialize_codec(struct cx23885_dev *dev)
1027 printk(KERN_ERR "%s() f/w load failed\n", __func__); 1027 printk(KERN_ERR "%s() f/w load failed\n", __func__);
1028 return retval; 1028 return retval;
1029 } 1029 }
1030 dev->cx23417_mailbox = cx23885_find_mailbox(dev); 1030 retval = cx23885_find_mailbox(dev);
1031 if (dev->cx23417_mailbox < 0) { 1031 if (retval < 0) {
1032 printk(KERN_ERR "%s() mailbox < 0, error\n", 1032 printk(KERN_ERR "%s() mailbox < 0, error\n",
1033 __func__); 1033 __func__);
1034 return -1; 1034 return -1;
1035 } 1035 }
1036 dev->cx23417_mailbox = retval;
1036 retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); 1037 retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0);
1037 if (retval < 0) { 1038 if (retval < 0) {
1038 printk(KERN_ERR 1039 printk(KERN_ERR
@@ -1573,9 +1574,9 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1573 return cx23885_queryctrl(dev, c); 1574 return cx23885_queryctrl(dev, c);
1574} 1575}
1575 1576
1576static int mpeg_open(struct inode *inode, struct file *file) 1577static int mpeg_open(struct file *file)
1577{ 1578{
1578 int minor = iminor(inode); 1579 int minor = video_devdata(file)->minor;
1579 struct cx23885_dev *h, *dev = NULL; 1580 struct cx23885_dev *h, *dev = NULL;
1580 struct list_head *list; 1581 struct list_head *list;
1581 struct cx23885_fh *fh; 1582 struct cx23885_fh *fh;
@@ -1617,7 +1618,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
1617 return 0; 1618 return 0;
1618} 1619}
1619 1620
1620static int mpeg_release(struct inode *inode, struct file *file) 1621static int mpeg_release(struct file *file)
1621{ 1622{
1622 struct cx23885_fh *fh = file->private_data; 1623 struct cx23885_fh *fh = file->private_data;
1623 struct cx23885_dev *dev = fh->dev; 1624 struct cx23885_dev *dev = fh->dev;
@@ -1694,15 +1695,13 @@ static int mpeg_mmap(struct file *file, struct vm_area_struct *vma)
1694 return videobuf_mmap_mapper(&fh->mpegq, vma); 1695 return videobuf_mmap_mapper(&fh->mpegq, vma);
1695} 1696}
1696 1697
1697static struct file_operations mpeg_fops = { 1698static struct v4l2_file_operations mpeg_fops = {
1698 .owner = THIS_MODULE, 1699 .owner = THIS_MODULE,
1699 .open = mpeg_open, 1700 .open = mpeg_open,
1700 .release = mpeg_release, 1701 .release = mpeg_release,
1701 .read = mpeg_read, 1702 .read = mpeg_read,
1702 .poll = mpeg_poll, 1703 .poll = mpeg_poll,
1703 .mmap = mpeg_mmap, 1704 .mmap = mpeg_mmap,
1704 .ioctl = video_ioctl2,
1705 .llseek = no_llseek,
1706}; 1705};
1707 1706
1708static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { 1707static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index c742a10be5cb..2d81c4d04340 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -718,9 +718,9 @@ static int get_resource(struct cx23885_fh *fh)
718 } 718 }
719} 719}
720 720
721static int video_open(struct inode *inode, struct file *file) 721static int video_open(struct file *file)
722{ 722{
723 int minor = iminor(inode); 723 int minor = video_devdata(file)->minor;
724 struct cx23885_dev *h, *dev = NULL; 724 struct cx23885_dev *h, *dev = NULL;
725 struct cx23885_fh *fh; 725 struct cx23885_fh *fh;
726 struct list_head *list; 726 struct list_head *list;
@@ -834,7 +834,7 @@ static unsigned int video_poll(struct file *file,
834 return 0; 834 return 0;
835} 835}
836 836
837static int video_release(struct inode *inode, struct file *file) 837static int video_release(struct file *file)
838{ 838{
839 struct cx23885_fh *fh = file->private_data; 839 struct cx23885_fh *fh = file->private_data;
840 struct cx23885_dev *dev = fh->dev; 840 struct cx23885_dev *dev = fh->dev;
@@ -1326,11 +1326,11 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1326 1326
1327#ifdef CONFIG_VIDEO_ADV_DEBUG 1327#ifdef CONFIG_VIDEO_ADV_DEBUG
1328static int vidioc_g_register(struct file *file, void *fh, 1328static int vidioc_g_register(struct file *file, void *fh,
1329 struct v4l2_register *reg) 1329 struct v4l2_dbg_register *reg)
1330{ 1330{
1331 struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; 1331 struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;
1332 1332
1333 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1333 if (!v4l2_chip_match_host(&reg->match))
1334 return -EINVAL; 1334 return -EINVAL;
1335 1335
1336 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg); 1336 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg);
@@ -1339,11 +1339,11 @@ static int vidioc_g_register(struct file *file, void *fh,
1339} 1339}
1340 1340
1341static int vidioc_s_register(struct file *file, void *fh, 1341static int vidioc_s_register(struct file *file, void *fh,
1342 struct v4l2_register *reg) 1342 struct v4l2_dbg_register *reg)
1343{ 1343{
1344 struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev; 1344 struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;
1345 1345
1346 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1346 if (!v4l2_chip_match_host(&reg->match))
1347 return -EINVAL; 1347 return -EINVAL;
1348 1348
1349 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg); 1349 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg);
@@ -1422,7 +1422,7 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status)
1422/* ----------------------------------------------------------- */ 1422/* ----------------------------------------------------------- */
1423/* exported stuff */ 1423/* exported stuff */
1424 1424
1425static const struct file_operations video_fops = { 1425static const struct v4l2_file_operations video_fops = {
1426 .owner = THIS_MODULE, 1426 .owner = THIS_MODULE,
1427 .open = video_open, 1427 .open = video_open,
1428 .release = video_release, 1428 .release = video_release,
@@ -1430,8 +1430,6 @@ static const struct file_operations video_fops = {
1430 .poll = video_poll, 1430 .poll = video_poll,
1431 .mmap = video_mmap, 1431 .mmap = video_mmap,
1432 .ioctl = video_ioctl2, 1432 .ioctl = video_ioctl2,
1433 .compat_ioctl = v4l_compat_ioctl32,
1434 .llseek = no_llseek,
1435}; 1433};
1436 1434
1437static const struct v4l2_ioctl_ops video_ioctl_ops = { 1435static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -1479,13 +1477,11 @@ static struct video_device cx23885_video_template = {
1479 .current_norm = V4L2_STD_NTSC_M, 1477 .current_norm = V4L2_STD_NTSC_M,
1480}; 1478};
1481 1479
1482static const struct file_operations radio_fops = { 1480static const struct v4l2_file_operations radio_fops = {
1483 .owner = THIS_MODULE, 1481 .owner = THIS_MODULE,
1484 .open = video_open, 1482 .open = video_open,
1485 .release = video_release, 1483 .release = video_release,
1486 .ioctl = video_ioctl2, 1484 .ioctl = video_ioctl2,
1487 .compat_ioctl = v4l_compat_ioctl32,
1488 .llseek = no_llseek,
1489}; 1485};
1490 1486
1491 1487
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 2ad277189da8..88f2fd32bfe3 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1120,25 +1120,24 @@ static int cx25840_init(struct v4l2_subdev *sd, u32 val)
1120} 1120}
1121 1121
1122#ifdef CONFIG_VIDEO_ADV_DEBUG 1122#ifdef CONFIG_VIDEO_ADV_DEBUG
1123static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1123static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1124{ 1124{
1125 struct i2c_client *client = v4l2_get_subdevdata(sd); 1125 struct i2c_client *client = v4l2_get_subdevdata(sd);
1126 1126
1127 if (!v4l2_chip_match_i2c_client(client, 1127 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1128 reg->match_type, reg->match_chip))
1129 return -EINVAL; 1128 return -EINVAL;
1130 if (!capable(CAP_SYS_ADMIN)) 1129 if (!capable(CAP_SYS_ADMIN))
1131 return -EPERM; 1130 return -EPERM;
1131 reg->size = 1;
1132 reg->val = cx25840_read(client, reg->reg & 0x0fff); 1132 reg->val = cx25840_read(client, reg->reg & 0x0fff);
1133 return 0; 1133 return 0;
1134} 1134}
1135 1135
1136static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1136static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1137{ 1137{
1138 struct i2c_client *client = v4l2_get_subdevdata(sd); 1138 struct i2c_client *client = v4l2_get_subdevdata(sd);
1139 1139
1140 if (!v4l2_chip_match_i2c_client(client, 1140 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1141 reg->match_type, reg->match_chip))
1142 return -EINVAL; 1141 return -EINVAL;
1143 if (!capable(CAP_SYS_ADMIN)) 1142 if (!capable(CAP_SYS_ADMIN))
1144 return -EPERM; 1143 return -EPERM;
@@ -1362,7 +1361,7 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val)
1362 return 0; 1361 return 0;
1363} 1362}
1364 1363
1365static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 1364static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
1366{ 1365{
1367 struct cx25840_state *state = to_state(sd); 1366 struct cx25840_state *state = to_state(sd);
1368 struct i2c_client *client = v4l2_get_subdevdata(sd); 1367 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index e162a70748c5..7f5b8bfd08ac 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1049,16 +1049,16 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
1049 1049
1050/* FIXME: cx88_ioctl_hook not implemented */ 1050/* FIXME: cx88_ioctl_hook not implemented */
1051 1051
1052static int mpeg_open(struct inode *inode, struct file *file) 1052static int mpeg_open(struct file *file)
1053{ 1053{
1054 int minor = iminor(inode); 1054 int minor = video_devdata(file)->minor;
1055 struct cx8802_dev *dev = NULL; 1055 struct cx8802_dev *dev = NULL;
1056 struct cx8802_fh *fh; 1056 struct cx8802_fh *fh;
1057 struct cx8802_driver *drv = NULL; 1057 struct cx8802_driver *drv = NULL;
1058 int err; 1058 int err;
1059 1059
1060 lock_kernel(); 1060 lock_kernel();
1061 dev = cx8802_get_device(inode); 1061 dev = cx8802_get_device(minor);
1062 1062
1063 dprintk( 1, "%s\n", __func__); 1063 dprintk( 1, "%s\n", __func__);
1064 1064
@@ -1114,7 +1114,7 @@ static int mpeg_open(struct inode *inode, struct file *file)
1114 return 0; 1114 return 0;
1115} 1115}
1116 1116
1117static int mpeg_release(struct inode *inode, struct file *file) 1117static int mpeg_release(struct file *file)
1118{ 1118{
1119 struct cx8802_fh *fh = file->private_data; 1119 struct cx8802_fh *fh = file->private_data;
1120 struct cx8802_dev *dev = fh->dev; 1120 struct cx8802_dev *dev = fh->dev;
@@ -1132,7 +1132,7 @@ static int mpeg_release(struct inode *inode, struct file *file)
1132 kfree(fh); 1132 kfree(fh);
1133 1133
1134 /* Make sure we release the hardware */ 1134 /* Make sure we release the hardware */
1135 dev = cx8802_get_device(inode); 1135 dev = cx8802_get_device(video_devdata(file)->minor);
1136 if (dev == NULL) 1136 if (dev == NULL)
1137 return -ENODEV; 1137 return -ENODEV;
1138 1138
@@ -1178,7 +1178,7 @@ mpeg_mmap(struct file *file, struct vm_area_struct * vma)
1178 return videobuf_mmap_mapper(&fh->mpegq, vma); 1178 return videobuf_mmap_mapper(&fh->mpegq, vma);
1179} 1179}
1180 1180
1181static const struct file_operations mpeg_fops = 1181static const struct v4l2_file_operations mpeg_fops =
1182{ 1182{
1183 .owner = THIS_MODULE, 1183 .owner = THIS_MODULE,
1184 .open = mpeg_open, 1184 .open = mpeg_open,
@@ -1187,7 +1187,6 @@ static const struct file_operations mpeg_fops =
1187 .poll = mpeg_poll, 1187 .poll = mpeg_poll,
1188 .mmap = mpeg_mmap, 1188 .mmap = mpeg_mmap,
1189 .ioctl = video_ioctl2, 1189 .ioctl = video_ioctl2,
1190 .llseek = no_llseek,
1191}; 1190};
1192 1191
1193static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { 1192static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index a04fee235db6..59164fc94f5f 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -578,9 +578,8 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
578 578
579#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ 579#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
580 defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) 580 defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
581struct cx8802_dev * cx8802_get_device(struct inode *inode) 581struct cx8802_dev *cx8802_get_device(int minor)
582{ 582{
583 int minor = iminor(inode);
584 struct cx8802_dev *dev; 583 struct cx8802_dev *dev;
585 584
586 list_for_each_entry(dev, &cx8802_devlist, devlist) 585 list_for_each_entry(dev, &cx8802_devlist, devlist)
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index b96ce991d968..791e69d804f9 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -757,9 +757,9 @@ static int get_ressource(struct cx8800_fh *fh)
757 } 757 }
758} 758}
759 759
760static int video_open(struct inode *inode, struct file *file) 760static int video_open(struct file *file)
761{ 761{
762 int minor = iminor(inode); 762 int minor = video_devdata(file)->minor;
763 struct cx8800_dev *h,*dev = NULL; 763 struct cx8800_dev *h,*dev = NULL;
764 struct cx88_core *core; 764 struct cx88_core *core;
765 struct cx8800_fh *fh; 765 struct cx8800_fh *fh;
@@ -904,7 +904,7 @@ video_poll(struct file *file, struct poll_table_struct *wait)
904 return 0; 904 return 0;
905} 905}
906 906
907static int video_release(struct inode *inode, struct file *file) 907static int video_release(struct file *file)
908{ 908{
909 struct cx8800_fh *fh = file->private_data; 909 struct cx8800_fh *fh = file->private_data;
910 struct cx8800_dev *dev = fh->dev; 910 struct cx8800_dev *dev = fh->dev;
@@ -1447,25 +1447,26 @@ static int vidioc_s_frequency (struct file *file, void *priv,
1447 1447
1448#ifdef CONFIG_VIDEO_ADV_DEBUG 1448#ifdef CONFIG_VIDEO_ADV_DEBUG
1449static int vidioc_g_register (struct file *file, void *fh, 1449static int vidioc_g_register (struct file *file, void *fh,
1450 struct v4l2_register *reg) 1450 struct v4l2_dbg_register *reg)
1451{ 1451{
1452 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; 1452 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;
1453 1453
1454 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1454 if (!v4l2_chip_match_host(&reg->match))
1455 return -EINVAL; 1455 return -EINVAL;
1456 /* cx2388x has a 24-bit register space */ 1456 /* cx2388x has a 24-bit register space */
1457 reg->val = cx_read(reg->reg&0xffffff); 1457 reg->val = cx_read(reg->reg & 0xffffff);
1458 reg->size = 4;
1458 return 0; 1459 return 0;
1459} 1460}
1460 1461
1461static int vidioc_s_register (struct file *file, void *fh, 1462static int vidioc_s_register (struct file *file, void *fh,
1462 struct v4l2_register *reg) 1463 struct v4l2_dbg_register *reg)
1463{ 1464{
1464 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core; 1465 struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;
1465 1466
1466 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1467 if (!v4l2_chip_match_host(&reg->match))
1467 return -EINVAL; 1468 return -EINVAL;
1468 cx_write(reg->reg&0xffffff, reg->val); 1469 cx_write(reg->reg & 0xffffff, reg->val);
1469 return 0; 1470 return 0;
1470} 1471}
1471#endif 1472#endif
@@ -1693,7 +1694,7 @@ static irqreturn_t cx8800_irq(int irq, void *dev_id)
1693/* ----------------------------------------------------------- */ 1694/* ----------------------------------------------------------- */
1694/* exported stuff */ 1695/* exported stuff */
1695 1696
1696static const struct file_operations video_fops = 1697static const struct v4l2_file_operations video_fops =
1697{ 1698{
1698 .owner = THIS_MODULE, 1699 .owner = THIS_MODULE,
1699 .open = video_open, 1700 .open = video_open,
@@ -1702,8 +1703,6 @@ static const struct file_operations video_fops =
1702 .poll = video_poll, 1703 .poll = video_poll,
1703 .mmap = video_mmap, 1704 .mmap = video_mmap,
1704 .ioctl = video_ioctl2, 1705 .ioctl = video_ioctl2,
1705 .compat_ioctl = v4l_compat_ioctl32,
1706 .llseek = no_llseek,
1707}; 1706};
1708 1707
1709static const struct v4l2_ioctl_ops video_ioctl_ops = { 1708static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -1752,14 +1751,12 @@ static struct video_device cx8800_video_template = {
1752 .current_norm = V4L2_STD_NTSC_M, 1751 .current_norm = V4L2_STD_NTSC_M,
1753}; 1752};
1754 1753
1755static const struct file_operations radio_fops = 1754static const struct v4l2_file_operations radio_fops =
1756{ 1755{
1757 .owner = THIS_MODULE, 1756 .owner = THIS_MODULE,
1758 .open = video_open, 1757 .open = video_open,
1759 .release = video_release, 1758 .release = video_release,
1760 .ioctl = video_ioctl2, 1759 .ioctl = video_ioctl2,
1761 .compat_ioctl = v4l_compat_ioctl32,
1762 .llseek = no_llseek,
1763}; 1760};
1764 1761
1765static const struct v4l2_ioctl_ops radio_ioctl_ops = { 1762static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 20649b25f7ba..eb9ce30dc5e6 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -643,7 +643,7 @@ int cx88_audio_thread(void *data);
643 643
644int cx8802_register_driver(struct cx8802_driver *drv); 644int cx8802_register_driver(struct cx8802_driver *drv);
645int cx8802_unregister_driver(struct cx8802_driver *drv); 645int cx8802_unregister_driver(struct cx8802_driver *drv);
646struct cx8802_dev * cx8802_get_device(struct inode *inode); 646struct cx8802_dev *cx8802_get_device(int minor);
647struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype); 647struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
648 648
649/* ----------------------------------------------------------- */ 649/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 15c03f0e69ad..94378ccb7505 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -62,9 +62,9 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev)
62 62
63 dprintk("Stopping isoc\n"); 63 dprintk("Stopping isoc\n");
64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { 64 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
65 usb_unlink_urb(dev->adev->urb[i]); 65 usb_unlink_urb(dev->adev.urb[i]);
66 usb_free_urb(dev->adev->urb[i]); 66 usb_free_urb(dev->adev.urb[i]);
67 dev->adev->urb[i] = NULL; 67 dev->adev.urb[i] = NULL;
68 } 68 }
69 69
70 return 0; 70 return 0;
@@ -81,8 +81,8 @@ static void em28xx_audio_isocirq(struct urb *urb)
81 unsigned int stride; 81 unsigned int stride;
82 struct snd_pcm_substream *substream; 82 struct snd_pcm_substream *substream;
83 struct snd_pcm_runtime *runtime; 83 struct snd_pcm_runtime *runtime;
84 if (dev->adev->capture_pcm_substream) { 84 if (dev->adev.capture_pcm_substream) {
85 substream = dev->adev->capture_pcm_substream; 85 substream = dev->adev.capture_pcm_substream;
86 runtime = substream->runtime; 86 runtime = substream->runtime;
87 stride = runtime->frame_bits >> 3; 87 stride = runtime->frame_bits >> 3;
88 88
@@ -95,7 +95,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
95 if (!length) 95 if (!length)
96 continue; 96 continue;
97 97
98 oldptr = dev->adev->hwptr_done_capture; 98 oldptr = dev->adev.hwptr_done_capture;
99 if (oldptr + length >= runtime->buffer_size) { 99 if (oldptr + length >= runtime->buffer_size) {
100 unsigned int cnt = 100 unsigned int cnt =
101 runtime->buffer_size - oldptr; 101 runtime->buffer_size - oldptr;
@@ -110,16 +110,16 @@ static void em28xx_audio_isocirq(struct urb *urb)
110 110
111 snd_pcm_stream_lock(substream); 111 snd_pcm_stream_lock(substream);
112 112
113 dev->adev->hwptr_done_capture += length; 113 dev->adev.hwptr_done_capture += length;
114 if (dev->adev->hwptr_done_capture >= 114 if (dev->adev.hwptr_done_capture >=
115 runtime->buffer_size) 115 runtime->buffer_size)
116 dev->adev->hwptr_done_capture -= 116 dev->adev.hwptr_done_capture -=
117 runtime->buffer_size; 117 runtime->buffer_size;
118 118
119 dev->adev->capture_transfer_done += length; 119 dev->adev.capture_transfer_done += length;
120 if (dev->adev->capture_transfer_done >= 120 if (dev->adev.capture_transfer_done >=
121 runtime->period_size) { 121 runtime->period_size) {
122 dev->adev->capture_transfer_done -= 122 dev->adev.capture_transfer_done -=
123 runtime->period_size; 123 runtime->period_size;
124 period_elapsed = 1; 124 period_elapsed = 1;
125 } 125 }
@@ -131,7 +131,7 @@ static void em28xx_audio_isocirq(struct urb *urb)
131 } 131 }
132 urb->status = 0; 132 urb->status = 0;
133 133
134 if (dev->adev->shutdown) 134 if (dev->adev.shutdown)
135 return; 135 return;
136 136
137 status = usb_submit_urb(urb, GFP_ATOMIC); 137 status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -154,17 +154,17 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
154 struct urb *urb; 154 struct urb *urb;
155 int j, k; 155 int j, k;
156 156
157 dev->adev->transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); 157 dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC);
158 if (!dev->adev->transfer_buffer[i]) 158 if (!dev->adev.transfer_buffer[i])
159 return -ENOMEM; 159 return -ENOMEM;
160 160
161 memset(dev->adev->transfer_buffer[i], 0x80, sb_size); 161 memset(dev->adev.transfer_buffer[i], 0x80, sb_size);
162 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); 162 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
163 if (!urb) { 163 if (!urb) {
164 em28xx_errdev("usb_alloc_urb failed!\n"); 164 em28xx_errdev("usb_alloc_urb failed!\n");
165 for (j = 0; j < i; j++) { 165 for (j = 0; j < i; j++) {
166 usb_free_urb(dev->adev->urb[j]); 166 usb_free_urb(dev->adev.urb[j]);
167 kfree(dev->adev->transfer_buffer[j]); 167 kfree(dev->adev.transfer_buffer[j]);
168 } 168 }
169 return -ENOMEM; 169 return -ENOMEM;
170 } 170 }
@@ -173,7 +173,7 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
173 urb->context = dev; 173 urb->context = dev;
174 urb->pipe = usb_rcvisocpipe(dev->udev, 0x83); 174 urb->pipe = usb_rcvisocpipe(dev->udev, 0x83);
175 urb->transfer_flags = URB_ISO_ASAP; 175 urb->transfer_flags = URB_ISO_ASAP;
176 urb->transfer_buffer = dev->adev->transfer_buffer[i]; 176 urb->transfer_buffer = dev->adev.transfer_buffer[i];
177 urb->interval = 1; 177 urb->interval = 1;
178 urb->complete = em28xx_audio_isocirq; 178 urb->complete = em28xx_audio_isocirq;
179 urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS; 179 urb->number_of_packets = EM28XX_NUM_AUDIO_PACKETS;
@@ -185,11 +185,11 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
185 urb->iso_frame_desc[j].length = 185 urb->iso_frame_desc[j].length =
186 EM28XX_AUDIO_MAX_PACKET_SIZE; 186 EM28XX_AUDIO_MAX_PACKET_SIZE;
187 } 187 }
188 dev->adev->urb[i] = urb; 188 dev->adev.urb[i] = urb;
189 } 189 }
190 190
191 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { 191 for (i = 0; i < EM28XX_AUDIO_BUFS; i++) {
192 errCode = usb_submit_urb(dev->adev->urb[i], GFP_ATOMIC); 192 errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC);
193 if (errCode) { 193 if (errCode) {
194 em28xx_isoc_audio_deinit(dev); 194 em28xx_isoc_audio_deinit(dev);
195 195
@@ -202,16 +202,16 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
202 202
203static int em28xx_cmd(struct em28xx *dev, int cmd, int arg) 203static int em28xx_cmd(struct em28xx *dev, int cmd, int arg)
204{ 204{
205 dprintk("%s transfer\n", (dev->adev->capture_stream == STREAM_ON)? 205 dprintk("%s transfer\n", (dev->adev.capture_stream == STREAM_ON) ?
206 "stop" : "start"); 206 "stop" : "start");
207 207
208 switch (cmd) { 208 switch (cmd) {
209 case EM28XX_CAPTURE_STREAM_EN: 209 case EM28XX_CAPTURE_STREAM_EN:
210 if (dev->adev->capture_stream == STREAM_OFF && arg == 1) { 210 if (dev->adev.capture_stream == STREAM_OFF && arg == 1) {
211 dev->adev->capture_stream = STREAM_ON; 211 dev->adev.capture_stream = STREAM_ON;
212 em28xx_init_audio_isoc(dev); 212 em28xx_init_audio_isoc(dev);
213 } else if (dev->adev->capture_stream == STREAM_ON && arg == 0) { 213 } else if (dev->adev.capture_stream == STREAM_ON && arg == 0) {
214 dev->adev->capture_stream = STREAM_OFF; 214 dev->adev.capture_stream = STREAM_OFF;
215 em28xx_isoc_audio_deinit(dev); 215 em28xx_isoc_audio_deinit(dev);
216 } else { 216 } else {
217 printk(KERN_ERR "An underrun very likely occurred. " 217 printk(KERN_ERR "An underrun very likely occurred. "
@@ -289,17 +289,17 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
289 goto err; 289 goto err;
290 290
291 runtime->hw = snd_em28xx_hw_capture; 291 runtime->hw = snd_em28xx_hw_capture;
292 if (dev->alt == 0 && dev->adev->users == 0) { 292 if (dev->alt == 0 && dev->adev.users == 0) {
293 int errCode; 293 int errCode;
294 dev->alt = 7; 294 dev->alt = 7;
295 errCode = usb_set_interface(dev->udev, 0, 7); 295 errCode = usb_set_interface(dev->udev, 0, 7);
296 dprintk("changing alternate number to 7\n"); 296 dprintk("changing alternate number to 7\n");
297 } 297 }
298 298
299 dev->adev->users++; 299 dev->adev.users++;
300 300
301 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 301 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
302 dev->adev->capture_pcm_substream = substream; 302 dev->adev.capture_pcm_substream = substream;
303 runtime->private_data = dev; 303 runtime->private_data = dev;
304 304
305 return 0; 305 return 0;
@@ -311,7 +311,7 @@ err:
311static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream) 311static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
312{ 312{
313 struct em28xx *dev = snd_pcm_substream_chip(substream); 313 struct em28xx *dev = snd_pcm_substream_chip(substream);
314 dev->adev->users--; 314 dev->adev.users--;
315 315
316 dprintk("closing device\n"); 316 dprintk("closing device\n");
317 317
@@ -320,10 +320,10 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
320 em28xx_audio_analog_set(dev); 320 em28xx_audio_analog_set(dev);
321 mutex_unlock(&dev->lock); 321 mutex_unlock(&dev->lock);
322 322
323 if (dev->adev->users == 0 && dev->adev->shutdown == 1) { 323 if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
324 dprintk("audio users: %d\n", dev->adev->users); 324 dprintk("audio users: %d\n", dev->adev.users);
325 dprintk("disabling audio stream!\n"); 325 dprintk("disabling audio stream!\n");
326 dev->adev->shutdown = 0; 326 dev->adev.shutdown = 0;
327 dprintk("released lock\n"); 327 dprintk("released lock\n");
328 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); 328 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0);
329 } 329 }
@@ -356,7 +356,7 @@ static int snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream)
356 356
357 dprintk("Stop capture, if needed\n"); 357 dprintk("Stop capture, if needed\n");
358 358
359 if (dev->adev->capture_stream == STREAM_ON) 359 if (dev->adev.capture_stream == STREAM_ON)
360 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0); 360 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 0);
361 361
362 return 0; 362 return 0;
@@ -379,7 +379,7 @@ static int snd_em28xx_capture_trigger(struct snd_pcm_substream *substream,
379 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1); 379 em28xx_cmd(dev, EM28XX_CAPTURE_STREAM_EN, 1);
380 return 0; 380 return 0;
381 case SNDRV_PCM_TRIGGER_STOP: 381 case SNDRV_PCM_TRIGGER_STOP:
382 dev->adev->shutdown = 1; 382 dev->adev.shutdown = 1;
383 return 0; 383 return 0;
384 default: 384 default:
385 return -EINVAL; 385 return -EINVAL;
@@ -393,7 +393,7 @@ static snd_pcm_uframes_t snd_em28xx_capture_pointer(struct snd_pcm_substream
393 393
394 snd_pcm_uframes_t hwptr_done; 394 snd_pcm_uframes_t hwptr_done;
395 dev = snd_pcm_substream_chip(substream); 395 dev = snd_pcm_substream_chip(substream);
396 hwptr_done = dev->adev->hwptr_done_capture; 396 hwptr_done = dev->adev.hwptr_done_capture;
397 397
398 return hwptr_done; 398 return hwptr_done;
399} 399}
@@ -420,7 +420,7 @@ static struct snd_pcm_ops snd_em28xx_pcm_capture = {
420 420
421static int em28xx_audio_init(struct em28xx *dev) 421static int em28xx_audio_init(struct em28xx *dev)
422{ 422{
423 struct em28xx_audio *adev; 423 struct em28xx_audio *adev = &dev->adev;
424 struct snd_pcm *pcm; 424 struct snd_pcm *pcm;
425 struct snd_card *card; 425 struct snd_card *card;
426 static int devnr; 426 static int devnr;
@@ -438,16 +438,9 @@ static int em28xx_audio_init(struct em28xx *dev)
438 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " 438 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
439 "Rechberger\n"); 439 "Rechberger\n");
440 440
441 adev = kzalloc(sizeof(*adev), GFP_KERNEL);
442 if (!adev) {
443 printk(KERN_ERR "em28xx-audio.c: out of memory\n");
444 return -1;
445 }
446 card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0); 441 card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0);
447 if (card == NULL) { 442 if (card == NULL)
448 kfree(adev);
449 return -ENOMEM; 443 return -ENOMEM;
450 }
451 444
452 spin_lock_init(&adev->slock); 445 spin_lock_init(&adev->slock);
453 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm); 446 err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
@@ -471,7 +464,6 @@ static int em28xx_audio_init(struct em28xx *dev)
471 } 464 }
472 adev->sndcard = card; 465 adev->sndcard = card;
473 adev->udev = dev->udev; 466 adev->udev = dev->udev;
474 dev->adev = adev;
475 467
476 return 0; 468 return 0;
477} 469}
@@ -488,10 +480,9 @@ static int em28xx_audio_fini(struct em28xx *dev)
488 return 0; 480 return 0;
489 } 481 }
490 482
491 if (dev->adev) { 483 if (dev->adev.sndcard) {
492 snd_card_free(dev->adev->sndcard); 484 snd_card_free(dev->adev.sndcard);
493 kfree(dev->adev); 485 dev->adev.sndcard = NULL;
494 dev->adev = NULL;
495 } 486 }
496 487
497 return 0; 488 return 0;
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index f8504518586a..819cceaa6ef4 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -1000,12 +1000,11 @@ void em28xx_wake_i2c(struct em28xx *dev)
1000static LIST_HEAD(em28xx_devlist); 1000static LIST_HEAD(em28xx_devlist);
1001static DEFINE_MUTEX(em28xx_devlist_mutex); 1001static DEFINE_MUTEX(em28xx_devlist_mutex);
1002 1002
1003struct em28xx *em28xx_get_device(struct inode *inode, 1003struct em28xx *em28xx_get_device(int minor,
1004 enum v4l2_buf_type *fh_type, 1004 enum v4l2_buf_type *fh_type,
1005 int *has_radio) 1005 int *has_radio)
1006{ 1006{
1007 struct em28xx *h, *dev = NULL; 1007 struct em28xx *h, *dev = NULL;
1008 int minor = iminor(inode);
1009 1008
1010 *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1009 *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1011 *has_radio = 0; 1010 *has_radio = 0;
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h
index 65dcb91bdcc2..24e39c56811e 100644
--- a/drivers/media/video/em28xx/em28xx-reg.h
+++ b/drivers/media/video/em28xx/em28xx-reg.h
@@ -160,7 +160,7 @@
160 160
161/* FIXME: Need to be populated with the other chip ID's */ 161/* FIXME: Need to be populated with the other chip ID's */
162enum em28xx_chip_id { 162enum em28xx_chip_id {
163 CHIP_ID_EM2820 = 18, 163 CHIP_ID_EM2820 = 18, /* Also used by em2710 */
164 CHIP_ID_EM2840 = 20, 164 CHIP_ID_EM2840 = 20,
165 CHIP_ID_EM2750 = 33, 165 CHIP_ID_EM2750 = 33,
166 CHIP_ID_EM2860 = 34, 166 CHIP_ID_EM2860 = 34,
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 53527536481e..416b691c33c1 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1154,7 +1154,7 @@ static int em28xx_reg_len(int reg)
1154} 1154}
1155 1155
1156static int vidioc_g_chip_ident(struct file *file, void *priv, 1156static int vidioc_g_chip_ident(struct file *file, void *priv,
1157 struct v4l2_chip_ident *chip) 1157 struct v4l2_dbg_chip_ident *chip)
1158{ 1158{
1159 struct em28xx_fh *fh = priv; 1159 struct em28xx_fh *fh = priv;
1160 struct em28xx *dev = fh->dev; 1160 struct em28xx *dev = fh->dev;
@@ -1162,20 +1162,20 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
1162 chip->ident = V4L2_IDENT_NONE; 1162 chip->ident = V4L2_IDENT_NONE;
1163 chip->revision = 0; 1163 chip->revision = 0;
1164 1164
1165 em28xx_i2c_call_clients(dev, VIDIOC_G_CHIP_IDENT, chip); 1165 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_CHIP_IDENT, chip);
1166 1166
1167 return 0; 1167 return 0;
1168} 1168}
1169 1169
1170 1170
1171static int vidioc_g_register(struct file *file, void *priv, 1171static int vidioc_g_register(struct file *file, void *priv,
1172 struct v4l2_register *reg) 1172 struct v4l2_dbg_register *reg)
1173{ 1173{
1174 struct em28xx_fh *fh = priv; 1174 struct em28xx_fh *fh = priv;
1175 struct em28xx *dev = fh->dev; 1175 struct em28xx *dev = fh->dev;
1176 int ret; 1176 int ret;
1177 1177
1178 switch (reg->match_type) { 1178 switch (reg->match.type) {
1179 case V4L2_CHIP_MATCH_AC97: 1179 case V4L2_CHIP_MATCH_AC97:
1180 mutex_lock(&dev->lock); 1180 mutex_lock(&dev->lock);
1181 ret = em28xx_read_ac97(dev, reg->reg); 1181 ret = em28xx_read_ac97(dev, reg->reg);
@@ -1184,6 +1184,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1184 return ret; 1184 return ret;
1185 1185
1186 reg->val = ret; 1186 reg->val = ret;
1187 reg->size = 1;
1187 return 0; 1188 return 0;
1188 case V4L2_CHIP_MATCH_I2C_DRIVER: 1189 case V4L2_CHIP_MATCH_I2C_DRIVER:
1189 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg); 1190 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg);
@@ -1192,12 +1193,13 @@ static int vidioc_g_register(struct file *file, void *priv,
1192 /* Not supported yet */ 1193 /* Not supported yet */
1193 return -EINVAL; 1194 return -EINVAL;
1194 default: 1195 default:
1195 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1196 if (!v4l2_chip_match_host(&reg->match))
1196 return -EINVAL; 1197 return -EINVAL;
1197 } 1198 }
1198 1199
1199 /* Match host */ 1200 /* Match host */
1200 if (em28xx_reg_len(reg->reg) == 1) { 1201 reg->size = em28xx_reg_len(reg->reg);
1202 if (reg->size == 1) {
1201 mutex_lock(&dev->lock); 1203 mutex_lock(&dev->lock);
1202 ret = em28xx_read_reg(dev, reg->reg); 1204 ret = em28xx_read_reg(dev, reg->reg);
1203 mutex_unlock(&dev->lock); 1205 mutex_unlock(&dev->lock);
@@ -1207,7 +1209,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1207 1209
1208 reg->val = ret; 1210 reg->val = ret;
1209 } else { 1211 } else {
1210 __le64 val = 0; 1212 __le16 val = 0;
1211 mutex_lock(&dev->lock); 1213 mutex_lock(&dev->lock);
1212 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, 1214 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
1213 reg->reg, (char *)&val, 2); 1215 reg->reg, (char *)&val, 2);
@@ -1215,21 +1217,21 @@ static int vidioc_g_register(struct file *file, void *priv,
1215 if (ret < 0) 1217 if (ret < 0)
1216 return ret; 1218 return ret;
1217 1219
1218 reg->val = le64_to_cpu(val); 1220 reg->val = le16_to_cpu(val);
1219 } 1221 }
1220 1222
1221 return 0; 1223 return 0;
1222} 1224}
1223 1225
1224static int vidioc_s_register(struct file *file, void *priv, 1226static int vidioc_s_register(struct file *file, void *priv,
1225 struct v4l2_register *reg) 1227 struct v4l2_dbg_register *reg)
1226{ 1228{
1227 struct em28xx_fh *fh = priv; 1229 struct em28xx_fh *fh = priv;
1228 struct em28xx *dev = fh->dev; 1230 struct em28xx *dev = fh->dev;
1229 __le64 buf; 1231 __le16 buf;
1230 int rc; 1232 int rc;
1231 1233
1232 switch (reg->match_type) { 1234 switch (reg->match.type) {
1233 case V4L2_CHIP_MATCH_AC97: 1235 case V4L2_CHIP_MATCH_AC97:
1234 mutex_lock(&dev->lock); 1236 mutex_lock(&dev->lock);
1235 rc = em28xx_write_ac97(dev, reg->reg, reg->val); 1237 rc = em28xx_write_ac97(dev, reg->reg, reg->val);
@@ -1243,12 +1245,12 @@ static int vidioc_s_register(struct file *file, void *priv,
1243 /* Not supported yet */ 1245 /* Not supported yet */
1244 return -EINVAL; 1246 return -EINVAL;
1245 default: 1247 default:
1246 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1248 if (!v4l2_chip_match_host(&reg->match))
1247 return -EINVAL; 1249 return -EINVAL;
1248 } 1250 }
1249 1251
1250 /* Match host */ 1252 /* Match host */
1251 buf = cpu_to_le64(reg->val); 1253 buf = cpu_to_le16(reg->val);
1252 1254
1253 mutex_lock(&dev->lock); 1255 mutex_lock(&dev->lock);
1254 rc = em28xx_write_regs(dev, reg->reg, (char *)&buf, 1256 rc = em28xx_write_regs(dev, reg->reg, (char *)&buf,
@@ -1582,15 +1584,15 @@ static int radio_queryctrl(struct file *file, void *priv,
1582 * em28xx_v4l2_open() 1584 * em28xx_v4l2_open()
1583 * inits the device and starts isoc transfer 1585 * inits the device and starts isoc transfer
1584 */ 1586 */
1585static int em28xx_v4l2_open(struct inode *inode, struct file *filp) 1587static int em28xx_v4l2_open(struct file *filp)
1586{ 1588{
1587 int minor = iminor(inode); 1589 int minor = video_devdata(filp)->minor;
1588 int errCode = 0, radio; 1590 int errCode = 0, radio;
1589 struct em28xx *dev; 1591 struct em28xx *dev;
1590 enum v4l2_buf_type fh_type; 1592 enum v4l2_buf_type fh_type;
1591 struct em28xx_fh *fh; 1593 struct em28xx_fh *fh;
1592 1594
1593 dev = em28xx_get_device(inode, &fh_type, &radio); 1595 dev = em28xx_get_device(minor, &fh_type, &radio);
1594 1596
1595 if (NULL == dev) 1597 if (NULL == dev)
1596 return -ENODEV; 1598 return -ENODEV;
@@ -1686,7 +1688,7 @@ void em28xx_release_analog_resources(struct em28xx *dev)
1686 * stops streaming and deallocates all resources allocated by the v4l2 1688 * stops streaming and deallocates all resources allocated by the v4l2
1687 * calls and ioctls 1689 * calls and ioctls
1688 */ 1690 */
1689static int em28xx_v4l2_close(struct inode *inode, struct file *filp) 1691static int em28xx_v4l2_close(struct file *filp)
1690{ 1692{
1691 struct em28xx_fh *fh = filp->private_data; 1693 struct em28xx_fh *fh = filp->private_data;
1692 struct em28xx *dev = fh->dev; 1694 struct em28xx *dev = fh->dev;
@@ -1826,7 +1828,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
1826 return rc; 1828 return rc;
1827} 1829}
1828 1830
1829static const struct file_operations em28xx_v4l_fops = { 1831static const struct v4l2_file_operations em28xx_v4l_fops = {
1830 .owner = THIS_MODULE, 1832 .owner = THIS_MODULE,
1831 .open = em28xx_v4l2_open, 1833 .open = em28xx_v4l2_open,
1832 .release = em28xx_v4l2_close, 1834 .release = em28xx_v4l2_close,
@@ -1834,8 +1836,6 @@ static const struct file_operations em28xx_v4l_fops = {
1834 .poll = em28xx_v4l2_poll, 1836 .poll = em28xx_v4l2_poll,
1835 .mmap = em28xx_v4l2_mmap, 1837 .mmap = em28xx_v4l2_mmap,
1836 .ioctl = video_ioctl2, 1838 .ioctl = video_ioctl2,
1837 .llseek = no_llseek,
1838 .compat_ioctl = v4l_compat_ioctl32,
1839}; 1839};
1840 1840
1841static const struct v4l2_ioctl_ops video_ioctl_ops = { 1841static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -1890,13 +1890,11 @@ static const struct video_device em28xx_video_template = {
1890 .current_norm = V4L2_STD_PAL, 1890 .current_norm = V4L2_STD_PAL,
1891}; 1891};
1892 1892
1893static const struct file_operations radio_fops = { 1893static const struct v4l2_file_operations radio_fops = {
1894 .owner = THIS_MODULE, 1894 .owner = THIS_MODULE,
1895 .open = em28xx_v4l2_open, 1895 .open = em28xx_v4l2_open,
1896 .release = em28xx_v4l2_close, 1896 .release = em28xx_v4l2_close,
1897 .ioctl = video_ioctl2, 1897 .ioctl = video_ioctl2,
1898 .compat_ioctl = v4l_compat_ioctl32,
1899 .llseek = no_llseek,
1900}; 1898};
1901 1899
1902static const struct v4l2_ioctl_ops radio_ioctl_ops = { 1900static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index b5eddc26388e..6c6b94aa05b2 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -473,7 +473,7 @@ struct em28xx {
473 unsigned long i2c_hash; /* i2c devicelist hash - 473 unsigned long i2c_hash; /* i2c devicelist hash -
474 for boards with generic ID */ 474 for boards with generic ID */
475 475
476 struct em28xx_audio *adev; 476 struct em28xx_audio adev;
477 477
478 /* states */ 478 /* states */
479 enum em28xx_dev_state state; 479 enum em28xx_dev_state state;
@@ -583,7 +583,7 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);
583void em28xx_wake_i2c(struct em28xx *dev); 583void em28xx_wake_i2c(struct em28xx *dev);
584void em28xx_remove_from_devlist(struct em28xx *dev); 584void em28xx_remove_from_devlist(struct em28xx *dev);
585void em28xx_add_into_devlist(struct em28xx *dev); 585void em28xx_add_into_devlist(struct em28xx *dev);
586struct em28xx *em28xx_get_device(struct inode *inode, 586struct em28xx *em28xx_get_device(int minor,
587 enum v4l2_buf_type *fh_type, 587 enum v4l2_buf_type *fh_type,
588 int *has_radio); 588 int *has_radio);
589int em28xx_register_extension(struct em28xx_ops *dev); 589int em28xx_register_extension(struct em28xx_ops *dev);
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 83c07112c59d..d1c1e457f0b9 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -1206,7 +1206,7 @@ static void et61x251_release_resources(struct kref *kref)
1206} 1206}
1207 1207
1208 1208
1209static int et61x251_open(struct inode* inode, struct file* filp) 1209static int et61x251_open(struct file *filp)
1210{ 1210{
1211 struct et61x251_device* cam; 1211 struct et61x251_device* cam;
1212 int err = 0; 1212 int err = 0;
@@ -1291,7 +1291,7 @@ out:
1291} 1291}
1292 1292
1293 1293
1294static int et61x251_release(struct inode* inode, struct file* filp) 1294static int et61x251_release(struct file *filp)
1295{ 1295{
1296 struct et61x251_device* cam; 1296 struct et61x251_device* cam;
1297 1297
@@ -2392,8 +2392,8 @@ et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg)
2392} 2392}
2393 2393
2394 2394
2395static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp, 2395static long et61x251_ioctl_v4l2(struct file *filp,
2396 unsigned int cmd, void __user * arg) 2396 unsigned int cmd, void __user *arg)
2397{ 2397{
2398 struct et61x251_device *cam = video_drvdata(filp); 2398 struct et61x251_device *cam = video_drvdata(filp);
2399 2399
@@ -2487,11 +2487,11 @@ static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
2487} 2487}
2488 2488
2489 2489
2490static int et61x251_ioctl(struct inode* inode, struct file* filp, 2490static long et61x251_ioctl(struct file *filp,
2491 unsigned int cmd, unsigned long arg) 2491 unsigned int cmd, unsigned long arg)
2492{ 2492{
2493 struct et61x251_device *cam = video_drvdata(filp); 2493 struct et61x251_device *cam = video_drvdata(filp);
2494 int err = 0; 2494 long err = 0;
2495 2495
2496 if (mutex_lock_interruptible(&cam->fileop_mutex)) 2496 if (mutex_lock_interruptible(&cam->fileop_mutex))
2497 return -ERESTARTSYS; 2497 return -ERESTARTSYS;
@@ -2511,7 +2511,7 @@ static int et61x251_ioctl(struct inode* inode, struct file* filp,
2511 2511
2512 V4LDBG(3, "et61x251", cmd); 2512 V4LDBG(3, "et61x251", cmd);
2513 2513
2514 err = et61x251_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); 2514 err = et61x251_ioctl_v4l2(filp, cmd, (void __user *)arg);
2515 2515
2516 mutex_unlock(&cam->fileop_mutex); 2516 mutex_unlock(&cam->fileop_mutex);
2517 2517
@@ -2519,18 +2519,14 @@ static int et61x251_ioctl(struct inode* inode, struct file* filp,
2519} 2519}
2520 2520
2521 2521
2522static const struct file_operations et61x251_fops = { 2522static const struct v4l2_file_operations et61x251_fops = {
2523 .owner = THIS_MODULE, 2523 .owner = THIS_MODULE,
2524 .open = et61x251_open, 2524 .open = et61x251_open,
2525 .release = et61x251_release, 2525 .release = et61x251_release,
2526 .ioctl = et61x251_ioctl, 2526 .ioctl = et61x251_ioctl,
2527#ifdef CONFIG_COMPAT
2528 .compat_ioctl = v4l_compat_ioctl32,
2529#endif
2530 .read = et61x251_read, 2527 .read = et61x251_read,
2531 .poll = et61x251_poll, 2528 .poll = et61x251_poll,
2532 .mmap = et61x251_mmap, 2529 .mmap = et61x251_mmap,
2533 .llseek = no_llseek,
2534}; 2530};
2535 2531
2536/*****************************************************************************/ 2532/*****************************************************************************/
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 8b9f3bde5740..5e36b9a4ae3e 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -875,7 +875,7 @@ static void gspca_release(struct video_device *vfd)
875 kfree(gspca_dev); 875 kfree(gspca_dev);
876} 876}
877 877
878static int dev_open(struct inode *inode, struct file *file) 878static int dev_open(struct file *file)
879{ 879{
880 struct gspca_dev *gspca_dev; 880 struct gspca_dev *gspca_dev;
881 int ret; 881 int ret;
@@ -922,7 +922,7 @@ out:
922 return ret; 922 return ret;
923} 923}
924 924
925static int dev_close(struct inode *inode, struct file *file) 925static int dev_close(struct file *file)
926{ 926{
927 struct gspca_dev *gspca_dev = file->private_data; 927 struct gspca_dev *gspca_dev = file->private_data;
928 928
@@ -1802,17 +1802,13 @@ out:
1802 return ret; 1802 return ret;
1803} 1803}
1804 1804
1805static struct file_operations dev_fops = { 1805static struct v4l2_file_operations dev_fops = {
1806 .owner = THIS_MODULE, 1806 .owner = THIS_MODULE,
1807 .open = dev_open, 1807 .open = dev_open,
1808 .release = dev_close, 1808 .release = dev_close,
1809 .read = dev_read, 1809 .read = dev_read,
1810 .mmap = dev_mmap, 1810 .mmap = dev_mmap,
1811 .unlocked_ioctl = __video_ioctl2, 1811 .unlocked_ioctl = video_ioctl2,
1812#ifdef CONFIG_COMPAT
1813 .compat_ioctl = v4l_compat_ioctl32,
1814#endif
1815 .llseek = no_llseek,
1816 .poll = dev_poll, 1812 .poll = dev_poll,
1817}; 1813};
1818 1814
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c
index 352f84d440fb..79393d1772e4 100644
--- a/drivers/media/video/hexium_gemini.c
+++ b/drivers/media/video/hexium_gemini.c
@@ -306,7 +306,7 @@ static int hexium_detach(struct saa7146_dev *dev)
306 return 0; 306 return 0;
307} 307}
308 308
309static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) 309static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
310{ 310{
311 struct saa7146_dev *dev = fh->dev; 311 struct saa7146_dev *dev = fh->dev;
312 struct hexium *hexium = (struct hexium *) dev->ext_priv; 312 struct hexium *hexium = (struct hexium *) dev->ext_priv;
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index 8d3c1482e7ea..074bec711fe0 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -370,7 +370,7 @@ static int hexium_detach(struct saa7146_dev *dev)
370 return 0; 370 return 0;
371} 371}
372 372
373static int hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) 373static long hexium_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
374{ 374{
375 struct saa7146_dev *dev = fh->dev; 375 struct saa7146_dev *dev = fh->dev;
376 struct hexium *hexium = (struct hexium *) dev->ext_priv; 376 struct hexium *hexium = (struct hexium *) dev->ext_priv;
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 08b762951759..e8e5921cdc34 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -902,18 +902,19 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
902 } 902 }
903 903
904 if (hw & IVTV_HW_SAA711X) { 904 if (hw & IVTV_HW_SAA711X) {
905 struct v4l2_chip_ident v = { V4L2_CHIP_MATCH_I2C_DRIVER, I2C_DRIVERID_SAA711X }; 905 struct v4l2_dbg_chip_ident v;
906 906
907 /* determine the exact saa711x model */ 907 /* determine the exact saa711x model */
908 itv->hw_flags &= ~IVTV_HW_SAA711X; 908 itv->hw_flags &= ~IVTV_HW_SAA711X;
909 909
910 v.match.type = V4L2_CHIP_MATCH_I2C_DRIVER;
911 strlcpy(v.match.name, "saa7115", sizeof(v.match.name));
910 ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v); 912 ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v);
911 if (v.ident == V4L2_IDENT_SAA7114) { 913 if (v.ident == V4L2_IDENT_SAA7114) {
912 itv->hw_flags |= IVTV_HW_SAA7114; 914 itv->hw_flags |= IVTV_HW_SAA7114;
913 /* VBI is not yet supported by the saa7114 driver. */ 915 /* VBI is not yet supported by the saa7114 driver. */
914 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE); 916 itv->v4l2_cap &= ~(V4L2_CAP_SLICED_VBI_CAPTURE|V4L2_CAP_VBI_CAPTURE);
915 } 917 } else {
916 else {
917 itv->hw_flags |= IVTV_HW_SAA7115; 918 itv->hw_flags |= IVTV_HW_SAA7115;
918 } 919 }
919 itv->vbi.raw_decoder_line_size = 1443; 920 itv->vbi.raw_decoder_line_size = 1443;
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 5eb587592e9d..d594bc29f07f 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -831,7 +831,7 @@ static void ivtv_stop_decoding(struct ivtv_open_id *id, int flags, u64 pts)
831 ivtv_release_stream(s); 831 ivtv_release_stream(s);
832} 832}
833 833
834int ivtv_v4l2_close(struct inode *inode, struct file *filp) 834int ivtv_v4l2_close(struct file *filp)
835{ 835{
836 struct ivtv_open_id *id = filp->private_data; 836 struct ivtv_open_id *id = filp->private_data;
837 struct ivtv *itv = id->itv; 837 struct ivtv *itv = id->itv;
@@ -978,7 +978,7 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp)
978 return 0; 978 return 0;
979} 979}
980 980
981int ivtv_v4l2_open(struct inode *inode, struct file *filp) 981int ivtv_v4l2_open(struct file *filp)
982{ 982{
983 int res; 983 int res;
984 struct ivtv *itv = NULL; 984 struct ivtv *itv = NULL;
diff --git a/drivers/media/video/ivtv/ivtv-fileops.h b/drivers/media/video/ivtv/ivtv-fileops.h
index df81e790147f..049a2923965d 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.h
+++ b/drivers/media/video/ivtv/ivtv-fileops.h
@@ -22,12 +22,12 @@
22#define IVTV_FILEOPS_H 22#define IVTV_FILEOPS_H
23 23
24/* Testing/Debugging */ 24/* Testing/Debugging */
25int ivtv_v4l2_open(struct inode *inode, struct file *filp); 25int ivtv_v4l2_open(struct file *filp);
26ssize_t ivtv_v4l2_read(struct file *filp, char __user *buf, size_t count, 26ssize_t ivtv_v4l2_read(struct file *filp, char __user *buf, size_t count,
27 loff_t * pos); 27 loff_t * pos);
28ssize_t ivtv_v4l2_write(struct file *filp, const char __user *buf, size_t count, 28ssize_t ivtv_v4l2_write(struct file *filp, const char __user *buf, size_t count,
29 loff_t * pos); 29 loff_t * pos);
30int ivtv_v4l2_close(struct inode *inode, struct file *filp); 30int ivtv_v4l2_close(struct file *filp);
31unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait); 31unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait);
32unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table * wait); 32unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table * wait);
33int ivtv_start_capture(struct ivtv_open_id *id); 33int ivtv_start_capture(struct ivtv_open_id *id);
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index cd990a4b81a9..f6b3ef6e691b 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -674,19 +674,19 @@ static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_f
674 return ret; 674 return ret;
675} 675}
676 676
677static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident *chip) 677static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_dbg_chip_ident *chip)
678{ 678{
679 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 679 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
680 680
681 chip->ident = V4L2_IDENT_NONE; 681 chip->ident = V4L2_IDENT_NONE;
682 chip->revision = 0; 682 chip->revision = 0;
683 if (chip->match_type == V4L2_CHIP_MATCH_HOST) { 683 if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
684 if (v4l2_chip_match_host(chip->match_type, chip->match_chip)) 684 if (v4l2_chip_match_host(&chip->match))
685 chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416; 685 chip->ident = itv->has_cx23415 ? V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416;
686 return 0; 686 return 0;
687 } 687 }
688 if (chip->match_type != V4L2_CHIP_MATCH_I2C_DRIVER && 688 if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
689 chip->match_type != V4L2_CHIP_MATCH_I2C_ADDR) 689 chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
690 return -EINVAL; 690 return -EINVAL;
691 /* TODO: is this correct? */ 691 /* TODO: is this correct? */
692 return ivtv_call_all_err(itv, core, g_chip_ident, chip); 692 return ivtv_call_all_err(itv, core, g_chip_ident, chip);
@@ -695,7 +695,7 @@ static int ivtv_g_chip_ident(struct file *file, void *fh, struct v4l2_chip_ident
695#ifdef CONFIG_VIDEO_ADV_DEBUG 695#ifdef CONFIG_VIDEO_ADV_DEBUG
696static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg) 696static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
697{ 697{
698 struct v4l2_register *regs = arg; 698 struct v4l2_dbg_register *regs = arg;
699 volatile u8 __iomem *reg_start; 699 volatile u8 __iomem *reg_start;
700 700
701 if (!capable(CAP_SYS_ADMIN)) 701 if (!capable(CAP_SYS_ADMIN))
@@ -710,6 +710,7 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
710 else 710 else
711 return -EINVAL; 711 return -EINVAL;
712 712
713 regs->size = 4;
713 if (cmd == VIDIOC_DBG_G_REGISTER) 714 if (cmd == VIDIOC_DBG_G_REGISTER)
714 regs->val = readl(regs->reg + reg_start); 715 regs->val = readl(regs->reg + reg_start);
715 else 716 else
@@ -717,11 +718,11 @@ static int ivtv_itvc(struct ivtv *itv, unsigned int cmd, void *arg)
717 return 0; 718 return 0;
718} 719}
719 720
720static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *reg) 721static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
721{ 722{
722 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 723 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
723 724
724 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 725 if (v4l2_chip_match_host(&reg->match))
725 return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg); 726 return ivtv_itvc(itv, VIDIOC_DBG_G_REGISTER, reg);
726 /* TODO: subdev errors should not be ignored, this should become a 727 /* TODO: subdev errors should not be ignored, this should become a
727 subdev helper function. */ 728 subdev helper function. */
@@ -729,11 +730,11 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_register *re
729 return 0; 730 return 0;
730} 731}
731 732
732static int ivtv_s_register(struct file *file, void *fh, struct v4l2_register *reg) 733static int ivtv_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
733{ 734{
734 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 735 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
735 736
736 if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) 737 if (v4l2_chip_match_host(&reg->match))
737 return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg); 738 return ivtv_itvc(itv, VIDIOC_DBG_S_REGISTER, reg);
738 /* TODO: subdev errors should not be ignored, this should become a 739 /* TODO: subdev errors should not be ignored, this should become a
739 subdev helper function. */ 740 subdev helper function. */
@@ -1725,7 +1726,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1725 return 0; 1726 return 0;
1726} 1727}
1727 1728
1728static int ivtv_default(struct file *file, void *fh, int cmd, void *arg) 1729static long ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1729{ 1730{
1730 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 1731 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1731 1732
@@ -1827,7 +1828,7 @@ static long ivtv_serialized_ioctl(struct ivtv *itv, struct file *filp,
1827 1828
1828 if (ivtv_debug & IVTV_DBGFLG_IOCTL) 1829 if (ivtv_debug & IVTV_DBGFLG_IOCTL)
1829 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; 1830 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
1830 ret = __video_ioctl2(filp, cmd, arg); 1831 ret = video_ioctl2(filp, cmd, arg);
1831 vfd->debug = 0; 1832 vfd->debug = 0;
1832 return ret; 1833 return ret;
1833} 1834}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index f77d764707b2..854a950af78c 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -43,24 +43,22 @@
43#include "ivtv-cards.h" 43#include "ivtv-cards.h"
44#include "ivtv-streams.h" 44#include "ivtv-streams.h"
45 45
46static const struct file_operations ivtv_v4l2_enc_fops = { 46static const struct v4l2_file_operations ivtv_v4l2_enc_fops = {
47 .owner = THIS_MODULE, 47 .owner = THIS_MODULE,
48 .read = ivtv_v4l2_read, 48 .read = ivtv_v4l2_read,
49 .write = ivtv_v4l2_write, 49 .write = ivtv_v4l2_write,
50 .open = ivtv_v4l2_open, 50 .open = ivtv_v4l2_open,
51 .unlocked_ioctl = ivtv_v4l2_ioctl, 51 .unlocked_ioctl = ivtv_v4l2_ioctl,
52 .compat_ioctl = v4l_compat_ioctl32,
53 .release = ivtv_v4l2_close, 52 .release = ivtv_v4l2_close,
54 .poll = ivtv_v4l2_enc_poll, 53 .poll = ivtv_v4l2_enc_poll,
55}; 54};
56 55
57static const struct file_operations ivtv_v4l2_dec_fops = { 56static const struct v4l2_file_operations ivtv_v4l2_dec_fops = {
58 .owner = THIS_MODULE, 57 .owner = THIS_MODULE,
59 .read = ivtv_v4l2_read, 58 .read = ivtv_v4l2_read,
60 .write = ivtv_v4l2_write, 59 .write = ivtv_v4l2_write,
61 .open = ivtv_v4l2_open, 60 .open = ivtv_v4l2_open,
62 .unlocked_ioctl = ivtv_v4l2_ioctl, 61 .unlocked_ioctl = ivtv_v4l2_ioctl,
63 .compat_ioctl = v4l_compat_ioctl32,
64 .release = ivtv_v4l2_close, 62 .release = ivtv_v4l2_close,
65 .poll = ivtv_v4l2_dec_poll, 63 .poll = ivtv_v4l2_dec_poll,
66}; 64};
@@ -78,7 +76,7 @@ static struct {
78 int num_offset; 76 int num_offset;
79 int dma, pio; 77 int dma, pio;
80 enum v4l2_buf_type buf_type; 78 enum v4l2_buf_type buf_type;
81 const struct file_operations *fops; 79 const struct v4l2_file_operations *fops;
82} ivtv_stream_info[] = { 80} ivtv_stream_info[] = {
83 { /* IVTV_ENC_STREAM_TYPE_MPG */ 81 { /* IVTV_ENC_STREAM_TYPE_MPG */
84 "encoder MPG", 82 "encoder MPG",
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index 07be14a9fe7b..de397ef57b44 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -80,29 +80,28 @@ static int m52790_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
80} 80}
81 81
82#ifdef CONFIG_VIDEO_ADV_DEBUG 82#ifdef CONFIG_VIDEO_ADV_DEBUG
83static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 83static int m52790_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
84{ 84{
85 struct m52790_state *state = to_state(sd); 85 struct m52790_state *state = to_state(sd);
86 struct i2c_client *client = v4l2_get_subdevdata(sd); 86 struct i2c_client *client = v4l2_get_subdevdata(sd);
87 87
88 if (!v4l2_chip_match_i2c_client(client, 88 if (!v4l2_chip_match_i2c_client(client, &reg->match))
89 reg->match_type, reg->match_chip))
90 return -EINVAL; 89 return -EINVAL;
91 if (!capable(CAP_SYS_ADMIN)) 90 if (!capable(CAP_SYS_ADMIN))
92 return -EPERM; 91 return -EPERM;
93 if (reg->reg != 0) 92 if (reg->reg != 0)
94 return -EINVAL; 93 return -EINVAL;
94 reg->size = 1;
95 reg->val = state->input | state->output; 95 reg->val = state->input | state->output;
96 return 0; 96 return 0;
97} 97}
98 98
99static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 99static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
100{ 100{
101 struct m52790_state *state = to_state(sd); 101 struct m52790_state *state = to_state(sd);
102 struct i2c_client *client = v4l2_get_subdevdata(sd); 102 struct i2c_client *client = v4l2_get_subdevdata(sd);
103 103
104 if (!v4l2_chip_match_i2c_client(client, 104 if (!v4l2_chip_match_i2c_client(client, &reg->match))
105 reg->match_type, reg->match_chip))
106 return -EINVAL; 105 return -EINVAL;
107 if (!capable(CAP_SYS_ADMIN)) 106 if (!capable(CAP_SYS_ADMIN))
108 return -EPERM; 107 return -EPERM;
@@ -115,7 +114,7 @@ static int m52790_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
115} 114}
116#endif 115#endif
117 116
118static int m52790_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 117static int m52790_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
119{ 118{
120 struct i2c_client *client = v4l2_get_subdevdata(sd); 119 struct i2c_client *client = v4l2_get_subdevdata(sd);
121 120
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 6418f4a78f2a..b76e33d5c867 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -841,7 +841,7 @@ again:
841/* video4linux integration */ 841/* video4linux integration */
842/****************************************************************************/ 842/****************************************************************************/
843 843
844static int meye_open(struct inode *inode, struct file *file) 844static int meye_open(struct file *file)
845{ 845{
846 int i; 846 int i;
847 847
@@ -863,7 +863,7 @@ static int meye_open(struct inode *inode, struct file *file)
863 return 0; 863 return 0;
864} 864}
865 865
866static int meye_release(struct inode *inode, struct file *file) 866static int meye_release(struct file *file)
867{ 867{
868 mchip_hic_stop(); 868 mchip_hic_stop();
869 mchip_dma_free(); 869 mchip_dma_free();
@@ -1577,7 +1577,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
1577 return 0; 1577 return 0;
1578} 1578}
1579 1579
1580static int vidioc_default(struct file *file, void *fh, int cmd, void *arg) 1580static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
1581{ 1581{
1582 switch (cmd) { 1582 switch (cmd) {
1583 case MEYEIOC_G_PARAMS: 1583 case MEYEIOC_G_PARAMS:
@@ -1684,17 +1684,13 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
1684 return 0; 1684 return 0;
1685} 1685}
1686 1686
1687static const struct file_operations meye_fops = { 1687static const struct v4l2_file_operations meye_fops = {
1688 .owner = THIS_MODULE, 1688 .owner = THIS_MODULE,
1689 .open = meye_open, 1689 .open = meye_open,
1690 .release = meye_release, 1690 .release = meye_release,
1691 .mmap = meye_mmap, 1691 .mmap = meye_mmap,
1692 .ioctl = video_ioctl2, 1692 .ioctl = video_ioctl2,
1693#ifdef CONFIG_COMPAT
1694 .compat_ioctl = v4l_compat_ioctl32,
1695#endif
1696 .poll = meye_poll, 1693 .poll = meye_poll,
1697 .llseek = no_llseek,
1698}; 1694};
1699 1695
1700static const struct v4l2_ioctl_ops meye_ioctl_ops = { 1696static const struct v4l2_ioctl_ops meye_ioctl_ops = {
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index a622dbb72ed8..4d7a91852117 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -483,7 +483,7 @@ static int msp_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
483} 483}
484 484
485#ifdef CONFIG_VIDEO_ALLOW_V4L1 485#ifdef CONFIG_VIDEO_ALLOW_V4L1
486static int msp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) 486static long msp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
487{ 487{
488 struct msp_state *state = to_state(sd); 488 struct msp_state *state = to_state(sd);
489 struct i2c_client *client = v4l2_get_subdevdata(sd); 489 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -733,7 +733,7 @@ static int msp_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
733 return 0; 733 return 0;
734} 734}
735 735
736static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 736static int msp_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
737{ 737{
738 struct msp_state *state = to_state(sd); 738 struct msp_state *state = to_state(sd);
739 struct i2c_client *client = v4l2_get_subdevdata(sd); 739 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 1a1a12453672..c1bf75ef2741 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -343,14 +343,14 @@ static int mt9m001_try_fmt(struct soc_camera_device *icd,
343} 343}
344 344
345static int mt9m001_get_chip_id(struct soc_camera_device *icd, 345static int mt9m001_get_chip_id(struct soc_camera_device *icd,
346 struct v4l2_chip_ident *id) 346 struct v4l2_dbg_chip_ident *id)
347{ 347{
348 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); 348 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
349 349
350 if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) 350 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
351 return -EINVAL; 351 return -EINVAL;
352 352
353 if (id->match_chip != mt9m001->client->addr) 353 if (id->match.addr != mt9m001->client->addr)
354 return -ENODEV; 354 return -ENODEV;
355 355
356 id->ident = mt9m001->model; 356 id->ident = mt9m001->model;
@@ -361,16 +361,17 @@ static int mt9m001_get_chip_id(struct soc_camera_device *icd,
361 361
362#ifdef CONFIG_VIDEO_ADV_DEBUG 362#ifdef CONFIG_VIDEO_ADV_DEBUG
363static int mt9m001_get_register(struct soc_camera_device *icd, 363static int mt9m001_get_register(struct soc_camera_device *icd,
364 struct v4l2_register *reg) 364 struct v4l2_dbg_register *reg)
365{ 365{
366 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); 366 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
367 367
368 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 368 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
369 return -EINVAL; 369 return -EINVAL;
370 370
371 if (reg->match_chip != mt9m001->client->addr) 371 if (reg->match.addr != mt9m001->client->addr)
372 return -ENODEV; 372 return -ENODEV;
373 373
374 reg->size = 2;
374 reg->val = reg_read(icd, reg->reg); 375 reg->val = reg_read(icd, reg->reg);
375 376
376 if (reg->val > 0xffff) 377 if (reg->val > 0xffff)
@@ -380,14 +381,14 @@ static int mt9m001_get_register(struct soc_camera_device *icd,
380} 381}
381 382
382static int mt9m001_set_register(struct soc_camera_device *icd, 383static int mt9m001_set_register(struct soc_camera_device *icd,
383 struct v4l2_register *reg) 384 struct v4l2_dbg_register *reg)
384{ 385{
385 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); 386 struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
386 387
387 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 388 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
388 return -EINVAL; 389 return -EINVAL;
389 390
390 if (reg->match_chip != mt9m001->client->addr) 391 if (reg->match.addr != mt9m001->client->addr)
391 return -ENODEV; 392 return -ENODEV;
392 393
393 if (reg_write(icd, reg->reg, reg->val) < 0) 394 if (reg_write(icd, reg->reg, reg->val) < 0)
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index c89ea41fe259..5b8e20979cce 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -514,14 +514,14 @@ static int mt9m111_try_fmt(struct soc_camera_device *icd,
514} 514}
515 515
516static int mt9m111_get_chip_id(struct soc_camera_device *icd, 516static int mt9m111_get_chip_id(struct soc_camera_device *icd,
517 struct v4l2_chip_ident *id) 517 struct v4l2_dbg_chip_ident *id)
518{ 518{
519 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 519 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
520 520
521 if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) 521 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
522 return -EINVAL; 522 return -EINVAL;
523 523
524 if (id->match_chip != mt9m111->client->addr) 524 if (id->match.addr != mt9m111->client->addr)
525 return -ENODEV; 525 return -ENODEV;
526 526
527 id->ident = mt9m111->model; 527 id->ident = mt9m111->model;
@@ -532,18 +532,19 @@ static int mt9m111_get_chip_id(struct soc_camera_device *icd,
532 532
533#ifdef CONFIG_VIDEO_ADV_DEBUG 533#ifdef CONFIG_VIDEO_ADV_DEBUG
534static int mt9m111_get_register(struct soc_camera_device *icd, 534static int mt9m111_get_register(struct soc_camera_device *icd,
535 struct v4l2_register *reg) 535 struct v4l2_dbg_register *reg)
536{ 536{
537 int val; 537 int val;
538 538
539 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 539 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
540 540
541 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) 541 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
542 return -EINVAL; 542 return -EINVAL;
543 if (reg->match_chip != mt9m111->client->addr) 543 if (reg->match.addr != mt9m111->client->addr)
544 return -ENODEV; 544 return -ENODEV;
545 545
546 val = mt9m111_reg_read(icd, reg->reg); 546 val = mt9m111_reg_read(icd, reg->reg);
547 reg->size = 2;
547 reg->val = (u64)val; 548 reg->val = (u64)val;
548 549
549 if (reg->val > 0xffff) 550 if (reg->val > 0xffff)
@@ -553,14 +554,14 @@ static int mt9m111_get_register(struct soc_camera_device *icd,
553} 554}
554 555
555static int mt9m111_set_register(struct soc_camera_device *icd, 556static int mt9m111_set_register(struct soc_camera_device *icd,
556 struct v4l2_register *reg) 557 struct v4l2_dbg_register *reg)
557{ 558{
558 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 559 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
559 560
560 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff) 561 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0x2ff)
561 return -EINVAL; 562 return -EINVAL;
562 563
563 if (reg->match_chip != mt9m111->client->addr) 564 if (reg->match.addr != mt9m111->client->addr)
564 return -ENODEV; 565 return -ENODEV;
565 566
566 if (mt9m111_reg_write(icd, reg->reg, reg->val) < 0) 567 if (mt9m111_reg_write(icd, reg->reg, reg->val) < 0)
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
index 1a9d53966d06..349d8e365530 100644
--- a/drivers/media/video/mt9t031.c
+++ b/drivers/media/video/mt9t031.c
@@ -326,14 +326,14 @@ static int mt9t031_try_fmt(struct soc_camera_device *icd,
326} 326}
327 327
328static int mt9t031_get_chip_id(struct soc_camera_device *icd, 328static int mt9t031_get_chip_id(struct soc_camera_device *icd,
329 struct v4l2_chip_ident *id) 329 struct v4l2_dbg_chip_ident *id)
330{ 330{
331 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); 331 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
332 332
333 if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) 333 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
334 return -EINVAL; 334 return -EINVAL;
335 335
336 if (id->match_chip != mt9t031->client->addr) 336 if (id->match.addr != mt9t031->client->addr)
337 return -ENODEV; 337 return -ENODEV;
338 338
339 id->ident = mt9t031->model; 339 id->ident = mt9t031->model;
@@ -344,14 +344,14 @@ static int mt9t031_get_chip_id(struct soc_camera_device *icd,
344 344
345#ifdef CONFIG_VIDEO_ADV_DEBUG 345#ifdef CONFIG_VIDEO_ADV_DEBUG
346static int mt9t031_get_register(struct soc_camera_device *icd, 346static int mt9t031_get_register(struct soc_camera_device *icd,
347 struct v4l2_register *reg) 347 struct v4l2_dbg_register *reg)
348{ 348{
349 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); 349 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
350 350
351 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 351 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
352 return -EINVAL; 352 return -EINVAL;
353 353
354 if (reg->match_chip != mt9t031->client->addr) 354 if (reg->match.addr != mt9t031->client->addr)
355 return -ENODEV; 355 return -ENODEV;
356 356
357 reg->val = reg_read(icd, reg->reg); 357 reg->val = reg_read(icd, reg->reg);
@@ -363,14 +363,14 @@ static int mt9t031_get_register(struct soc_camera_device *icd,
363} 363}
364 364
365static int mt9t031_set_register(struct soc_camera_device *icd, 365static int mt9t031_set_register(struct soc_camera_device *icd,
366 struct v4l2_register *reg) 366 struct v4l2_dbg_register *reg)
367{ 367{
368 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); 368 struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd);
369 369
370 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 370 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
371 return -EINVAL; 371 return -EINVAL;
372 372
373 if (reg->match_chip != mt9t031->client->addr) 373 if (reg->match.addr != mt9t031->client->addr)
374 return -ENODEV; 374 return -ENODEV;
375 375
376 if (reg_write(icd, reg->reg, reg->val) < 0) 376 if (reg_write(icd, reg->reg, reg->val) < 0)
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index 14a5f9c21ffa..b04c8cb1644d 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -422,14 +422,14 @@ static int mt9v022_try_fmt(struct soc_camera_device *icd,
422} 422}
423 423
424static int mt9v022_get_chip_id(struct soc_camera_device *icd, 424static int mt9v022_get_chip_id(struct soc_camera_device *icd,
425 struct v4l2_chip_ident *id) 425 struct v4l2_dbg_chip_ident *id)
426{ 426{
427 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 427 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
428 428
429 if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) 429 if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
430 return -EINVAL; 430 return -EINVAL;
431 431
432 if (id->match_chip != mt9v022->client->addr) 432 if (id->match.addr != mt9v022->client->addr)
433 return -ENODEV; 433 return -ENODEV;
434 434
435 id->ident = mt9v022->model; 435 id->ident = mt9v022->model;
@@ -440,16 +440,17 @@ static int mt9v022_get_chip_id(struct soc_camera_device *icd,
440 440
441#ifdef CONFIG_VIDEO_ADV_DEBUG 441#ifdef CONFIG_VIDEO_ADV_DEBUG
442static int mt9v022_get_register(struct soc_camera_device *icd, 442static int mt9v022_get_register(struct soc_camera_device *icd,
443 struct v4l2_register *reg) 443 struct v4l2_dbg_register *reg)
444{ 444{
445 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 445 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
446 446
447 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 447 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
448 return -EINVAL; 448 return -EINVAL;
449 449
450 if (reg->match_chip != mt9v022->client->addr) 450 if (reg->match.addr != mt9v022->client->addr)
451 return -ENODEV; 451 return -ENODEV;
452 452
453 reg->size = 2;
453 reg->val = reg_read(icd, reg->reg); 454 reg->val = reg_read(icd, reg->reg);
454 455
455 if (reg->val > 0xffff) 456 if (reg->val > 0xffff)
@@ -459,14 +460,14 @@ static int mt9v022_get_register(struct soc_camera_device *icd,
459} 460}
460 461
461static int mt9v022_set_register(struct soc_camera_device *icd, 462static int mt9v022_set_register(struct soc_camera_device *icd,
462 struct v4l2_register *reg) 463 struct v4l2_dbg_register *reg)
463{ 464{
464 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); 465 struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
465 466
466 if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) 467 if (reg->match.type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff)
467 return -EINVAL; 468 return -EINVAL;
468 469
469 if (reg->match_chip != mt9v022->client->addr) 470 if (reg->match.addr != mt9v022->client->addr)
470 return -ENODEV; 471 return -ENODEV;
471 472
472 if (reg_write(icd, reg->reg, reg->val) < 0) 473 if (reg_write(icd, reg->reg, reg->val) < 0)
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 7f130284b5c7..e3cbe14c349a 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -489,7 +489,7 @@ static int mxb_detach(struct saa7146_dev *dev)
489 return 0; 489 return 0;
490} 490}
491 491
492static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) 492static long mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
493{ 493{
494 struct saa7146_dev *dev = fh->dev; 494 struct saa7146_dev *dev = fh->dev;
495 struct mxb *mxb = (struct mxb *)dev->ext_priv; 495 struct mxb *mxb = (struct mxb *)dev->ext_priv;
diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 85c3c7c92af1..73eb656acfe3 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -1454,9 +1454,9 @@ static int omap24xxcam_mmap(struct file *file, struct vm_area_struct *vma)
1454 return rval; 1454 return rval;
1455} 1455}
1456 1456
1457static int omap24xxcam_open(struct inode *inode, struct file *file) 1457static int omap24xxcam_open(struct file *file)
1458{ 1458{
1459 int minor = iminor(inode); 1459 int minor = video_devdata(file)->minor;
1460 struct omap24xxcam_device *cam = omap24xxcam.priv; 1460 struct omap24xxcam_device *cam = omap24xxcam.priv;
1461 struct omap24xxcam_fh *fh; 1461 struct omap24xxcam_fh *fh;
1462 struct v4l2_format format; 1462 struct v4l2_format format;
@@ -1511,7 +1511,7 @@ out_try_module_get:
1511 return -ENODEV; 1511 return -ENODEV;
1512} 1512}
1513 1513
1514static int omap24xxcam_release(struct inode *inode, struct file *file) 1514static int omap24xxcam_release(struct file *file)
1515{ 1515{
1516 struct omap24xxcam_fh *fh = file->private_data; 1516 struct omap24xxcam_fh *fh = file->private_data;
1517 struct omap24xxcam_device *cam = fh->cam; 1517 struct omap24xxcam_device *cam = fh->cam;
@@ -1559,8 +1559,7 @@ static int omap24xxcam_release(struct inode *inode, struct file *file)
1559 return 0; 1559 return 0;
1560} 1560}
1561 1561
1562static struct file_operations omap24xxcam_fops = { 1562static struct v4l2_file_operations omap24xxcam_fops = {
1563 .llseek = no_llseek,
1564 .ioctl = video_ioctl2, 1563 .ioctl = video_ioctl2,
1565 .poll = omap24xxcam_poll, 1564 .poll = omap24xxcam_poll,
1566 .mmap = omap24xxcam_mmap, 1565 .mmap = omap24xxcam_mmap,
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index 6ee9b69cc4a9..9af5532db142 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -3915,7 +3915,7 @@ ov51x_dealloc(struct usb_ov511 *ov)
3915 ***************************************************************************/ 3915 ***************************************************************************/
3916 3916
3917static int 3917static int
3918ov51x_v4l1_open(struct inode *inode, struct file *file) 3918ov51x_v4l1_open(struct file *file)
3919{ 3919{
3920 struct video_device *vdev = video_devdata(file); 3920 struct video_device *vdev = video_devdata(file);
3921 struct usb_ov511 *ov = video_get_drvdata(vdev); 3921 struct usb_ov511 *ov = video_get_drvdata(vdev);
@@ -3972,7 +3972,7 @@ out:
3972} 3972}
3973 3973
3974static int 3974static int
3975ov51x_v4l1_close(struct inode *inode, struct file *file) 3975ov51x_v4l1_close(struct file *file)
3976{ 3976{
3977 struct video_device *vdev = file->private_data; 3977 struct video_device *vdev = file->private_data;
3978 struct usb_ov511 *ov = video_get_drvdata(vdev); 3978 struct usb_ov511 *ov = video_get_drvdata(vdev);
@@ -4010,7 +4010,7 @@ ov51x_v4l1_close(struct inode *inode, struct file *file)
4010} 4010}
4011 4011
4012/* Do not call this function directly! */ 4012/* Do not call this function directly! */
4013static int 4013static long
4014ov51x_v4l1_ioctl_internal(struct file *file, unsigned int cmd, void *arg) 4014ov51x_v4l1_ioctl_internal(struct file *file, unsigned int cmd, void *arg)
4015{ 4015{
4016 struct video_device *vdev = file->private_data; 4016 struct video_device *vdev = file->private_data;
@@ -4449,8 +4449,8 @@ redo:
4449 return 0; 4449 return 0;
4450} 4450}
4451 4451
4452static int 4452static long
4453ov51x_v4l1_ioctl(struct inode *inode, struct file *file, 4453ov51x_v4l1_ioctl(struct file *file,
4454 unsigned int cmd, unsigned long arg) 4454 unsigned int cmd, unsigned long arg)
4455{ 4455{
4456 struct video_device *vdev = file->private_data; 4456 struct video_device *vdev = file->private_data;
@@ -4661,17 +4661,13 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
4661 return 0; 4661 return 0;
4662} 4662}
4663 4663
4664static const struct file_operations ov511_fops = { 4664static const struct v4l2_file_operations ov511_fops = {
4665 .owner = THIS_MODULE, 4665 .owner = THIS_MODULE,
4666 .open = ov51x_v4l1_open, 4666 .open = ov51x_v4l1_open,
4667 .release = ov51x_v4l1_close, 4667 .release = ov51x_v4l1_close,
4668 .read = ov51x_v4l1_read, 4668 .read = ov51x_v4l1_read,
4669 .mmap = ov51x_v4l1_mmap, 4669 .mmap = ov51x_v4l1_mmap,
4670 .ioctl = ov51x_v4l1_ioctl, 4670 .ioctl = ov51x_v4l1_ioctl,
4671#ifdef CONFIG_COMPAT
4672 .compat_ioctl = v4l_compat_ioctl32,
4673#endif
4674 .llseek = no_llseek,
4675}; 4671};
4676 4672
4677static struct video_device vdev_template = { 4673static struct video_device vdev_template = {
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index ea032f5f2f41..ca26b0c50cf2 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -1310,7 +1310,7 @@ static int ov7670_command(struct i2c_client *client, unsigned int cmd,
1310 void *arg) 1310 void *arg)
1311{ 1311{
1312 switch (cmd) { 1312 switch (cmd) {
1313 case VIDIOC_G_CHIP_IDENT: 1313 case VIDIOC_DBG_G_CHIP_IDENT:
1314 return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0); 1314 return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0);
1315 1315
1316 case VIDIOC_INT_RESET: 1316 case VIDIOC_INT_RESET:
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index 54b736fcc07a..3c9e0ba974e9 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -724,7 +724,7 @@ static unsigned long ov772x_query_bus_param(struct soc_camera_device *icd)
724} 724}
725 725
726static int ov772x_get_chip_id(struct soc_camera_device *icd, 726static int ov772x_get_chip_id(struct soc_camera_device *icd,
727 struct v4l2_chip_ident *id) 727 struct v4l2_dbg_chip_ident *id)
728{ 728{
729 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); 729 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
730 730
@@ -736,11 +736,12 @@ static int ov772x_get_chip_id(struct soc_camera_device *icd,
736 736
737#ifdef CONFIG_VIDEO_ADV_DEBUG 737#ifdef CONFIG_VIDEO_ADV_DEBUG
738static int ov772x_get_register(struct soc_camera_device *icd, 738static int ov772x_get_register(struct soc_camera_device *icd,
739 struct v4l2_register *reg) 739 struct v4l2_dbg_register *reg)
740{ 740{
741 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); 741 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
742 int ret; 742 int ret;
743 743
744 reg->size = 1;
744 if (reg->reg > 0xff) 745 if (reg->reg > 0xff)
745 return -EINVAL; 746 return -EINVAL;
746 747
@@ -754,7 +755,7 @@ static int ov772x_get_register(struct soc_camera_device *icd,
754} 755}
755 756
756static int ov772x_set_register(struct soc_camera_device *icd, 757static int ov772x_set_register(struct soc_camera_device *icd,
757 struct v4l2_register *reg) 758 struct v4l2_dbg_register *reg)
758{ 759{
759 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); 760 struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
760 761
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 45730fac1570..a1ad38fc49c1 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -680,7 +680,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
680 * Video4linux interfacing 680 * Video4linux interfacing
681 */ 681 */
682 682
683static int pms_do_ioctl(struct file *file, unsigned int cmd, void *arg) 683static long pms_do_ioctl(struct file *file, unsigned int cmd, void *arg)
684{ 684{
685 struct video_device *dev = video_devdata(file); 685 struct video_device *dev = video_devdata(file);
686 struct pms_device *pd=(struct pms_device *)dev; 686 struct pms_device *pd=(struct pms_device *)dev;
@@ -862,7 +862,7 @@ static int pms_do_ioctl(struct file *file, unsigned int cmd, void *arg)
862 return 0; 862 return 0;
863} 863}
864 864
865static int pms_ioctl(struct inode *inode, struct file *file, 865static long pms_ioctl(struct file *file,
866 unsigned int cmd, unsigned long arg) 866 unsigned int cmd, unsigned long arg)
867{ 867{
868 return video_usercopy(file, cmd, arg, pms_do_ioctl); 868 return video_usercopy(file, cmd, arg, pms_do_ioctl);
@@ -881,7 +881,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
881 return len; 881 return len;
882} 882}
883 883
884static int pms_exclusive_open(struct inode *inode, struct file *file) 884static int pms_exclusive_open(struct file *file)
885{ 885{
886 struct video_device *v = video_devdata(file); 886 struct video_device *v = video_devdata(file);
887 struct pms_device *pd = (struct pms_device *)v; 887 struct pms_device *pd = (struct pms_device *)v;
@@ -889,7 +889,7 @@ static int pms_exclusive_open(struct inode *inode, struct file *file)
889 return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0; 889 return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0;
890} 890}
891 891
892static int pms_exclusive_release(struct inode *inode, struct file *file) 892static int pms_exclusive_release(struct file *file)
893{ 893{
894 struct video_device *v = video_devdata(file); 894 struct video_device *v = video_devdata(file);
895 struct pms_device *pd = (struct pms_device *)v; 895 struct pms_device *pd = (struct pms_device *)v;
@@ -898,16 +898,12 @@ static int pms_exclusive_release(struct inode *inode, struct file *file)
898 return 0; 898 return 0;
899} 899}
900 900
901static const struct file_operations pms_fops = { 901static const struct v4l2_file_operations pms_fops = {
902 .owner = THIS_MODULE, 902 .owner = THIS_MODULE,
903 .open = pms_exclusive_open, 903 .open = pms_exclusive_open,
904 .release = pms_exclusive_release, 904 .release = pms_exclusive_release,
905 .ioctl = pms_ioctl, 905 .ioctl = pms_ioctl,
906#ifdef CONFIG_COMPAT
907 .compat_ioctl = v4l_compat_ioctl32,
908#endif
909 .read = pms_read, 906 .read = pms_read,
910 .llseek = no_llseek,
911}; 907};
912 908
913static struct video_device pms_template= 909static struct video_device pms_template=
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 4358079f1966..8fb92ac78c7b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -4732,26 +4732,25 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
4732 4732
4733 4733
4734int pvr2_hdw_register_access(struct pvr2_hdw *hdw, 4734int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
4735 u32 match_type, u32 match_chip, u64 reg_id, 4735 struct v4l2_dbg_match *match, u64 reg_id,
4736 int setFl,u64 *val_ptr) 4736 int setFl, u64 *val_ptr)
4737{ 4737{
4738#ifdef CONFIG_VIDEO_ADV_DEBUG 4738#ifdef CONFIG_VIDEO_ADV_DEBUG
4739 struct pvr2_i2c_client *cp; 4739 struct pvr2_i2c_client *cp;
4740 struct v4l2_register req; 4740 struct v4l2_dbg_register req;
4741 int stat = 0; 4741 int stat = 0;
4742 int okFl = 0; 4742 int okFl = 0;
4743 4743
4744 if (!capable(CAP_SYS_ADMIN)) return -EPERM; 4744 if (!capable(CAP_SYS_ADMIN)) return -EPERM;
4745 4745
4746 req.match_type = match_type; 4746 req.match = *match;
4747 req.match_chip = match_chip;
4748 req.reg = reg_id; 4747 req.reg = reg_id;
4749 if (setFl) req.val = *val_ptr; 4748 if (setFl) req.val = *val_ptr;
4750 mutex_lock(&hdw->i2c_list_lock); do { 4749 mutex_lock(&hdw->i2c_list_lock); do {
4751 list_for_each_entry(cp, &hdw->i2c_clients, list) { 4750 list_for_each_entry(cp, &hdw->i2c_clients, list) {
4752 if (!v4l2_chip_match_i2c_client( 4751 if (!v4l2_chip_match_i2c_client(
4753 cp->client, 4752 cp->client,
4754 req.match_type, req.match_chip)) { 4753 &req.match)) {
4755 continue; 4754 continue;
4756 } 4755 }
4757 stat = pvr2_i2c_client_cmd( 4756 stat = pvr2_i2c_client_cmd(
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 49482d1f2b28..1b4fec337c6b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -242,8 +242,8 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
242 setFl - true to set the register, false to read it 242 setFl - true to set the register, false to read it
243 val_ptr - storage location for source / result. */ 243 val_ptr - storage location for source / result. */
244int pvr2_hdw_register_access(struct pvr2_hdw *, 244int pvr2_hdw_register_access(struct pvr2_hdw *,
245 u32 match_type, u32 match_chip,u64 reg_id, 245 struct v4l2_dbg_match *match, u64 reg_id,
246 int setFl,u64 *val_ptr); 246 int setFl, u64 *val_ptr);
247 247
248/* The following entry points are all lower level things you normally don't 248/* The following entry points are all lower level things you normally don't
249 want to worry about. */ 249 want to worry about. */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 52af1c435965..878fd52a73b3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -168,13 +168,13 @@ static const char *get_v4l_name(int v4l_type)
168 * This is part of Video 4 Linux API. The procedure handles ioctl() calls. 168 * This is part of Video 4 Linux API. The procedure handles ioctl() calls.
169 * 169 *
170 */ 170 */
171static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) 171static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
172{ 172{
173 struct pvr2_v4l2_fh *fh = file->private_data; 173 struct pvr2_v4l2_fh *fh = file->private_data;
174 struct pvr2_v4l2 *vp = fh->vhead; 174 struct pvr2_v4l2 *vp = fh->vhead;
175 struct pvr2_v4l2_dev *dev_info = fh->dev_info; 175 struct pvr2_v4l2_dev *dev_info = fh->dev_info;
176 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 176 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
177 int ret = -EINVAL; 177 long ret = -EINVAL;
178 178
179 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { 179 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
180 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd); 180 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd);
@@ -851,11 +851,11 @@ static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
851 case VIDIOC_DBG_G_REGISTER: 851 case VIDIOC_DBG_G_REGISTER:
852 { 852 {
853 u64 val; 853 u64 val;
854 struct v4l2_register *req = (struct v4l2_register *)arg; 854 struct v4l2_dbg_register *req = (struct v4l2_dbg_register *)arg;
855 if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val; 855 if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val;
856 ret = pvr2_hdw_register_access( 856 ret = pvr2_hdw_register_access(
857 hdw,req->match_type,req->match_chip,req->reg, 857 hdw, &req->match, req->reg,
858 cmd == VIDIOC_DBG_S_REGISTER,&val); 858 cmd == VIDIOC_DBG_S_REGISTER, &val);
859 if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val; 859 if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val;
860 break; 860 break;
861 } 861 }
@@ -871,20 +871,20 @@ static int pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
871 if (ret < 0) { 871 if (ret < 0) {
872 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { 872 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
873 pvr2_trace(PVR2_TRACE_V4LIOCTL, 873 pvr2_trace(PVR2_TRACE_V4LIOCTL,
874 "pvr2_v4l2_do_ioctl failure, ret=%d",ret); 874 "pvr2_v4l2_do_ioctl failure, ret=%ld", ret);
875 } else { 875 } else {
876 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { 876 if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
877 pvr2_trace(PVR2_TRACE_V4LIOCTL, 877 pvr2_trace(PVR2_TRACE_V4LIOCTL,
878 "pvr2_v4l2_do_ioctl failure, ret=%d" 878 "pvr2_v4l2_do_ioctl failure, ret=%ld"
879 " command was:",ret); 879 " command was:", ret);
880 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), 880 v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),
881 cmd); 881 cmd);
882 } 882 }
883 } 883 }
884 } else { 884 } else {
885 pvr2_trace(PVR2_TRACE_V4LIOCTL, 885 pvr2_trace(PVR2_TRACE_V4LIOCTL,
886 "pvr2_v4l2_do_ioctl complete, ret=%d (0x%x)", 886 "pvr2_v4l2_do_ioctl complete, ret=%ld (0x%lx)",
887 ret,ret); 887 ret, ret);
888 } 888 }
889 return ret; 889 return ret;
890} 890}
@@ -948,7 +948,7 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
948} 948}
949 949
950 950
951static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file, 951static long pvr2_v4l2_ioctl(struct file *file,
952 unsigned int cmd, unsigned long arg) 952 unsigned int cmd, unsigned long arg)
953{ 953{
954 954
@@ -960,7 +960,7 @@ static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
960} 960}
961 961
962 962
963static int pvr2_v4l2_release(struct inode *inode, struct file *file) 963static int pvr2_v4l2_release(struct file *file)
964{ 964{
965 struct pvr2_v4l2_fh *fhp = file->private_data; 965 struct pvr2_v4l2_fh *fhp = file->private_data;
966 struct pvr2_v4l2 *vp = fhp->vhead; 966 struct pvr2_v4l2 *vp = fhp->vhead;
@@ -1008,7 +1008,7 @@ static int pvr2_v4l2_release(struct inode *inode, struct file *file)
1008} 1008}
1009 1009
1010 1010
1011static int pvr2_v4l2_open(struct inode *inode, struct file *file) 1011static int pvr2_v4l2_open(struct file *file)
1012{ 1012{
1013 struct pvr2_v4l2_dev *dip; /* Our own context pointer */ 1013 struct pvr2_v4l2_dev *dip; /* Our own context pointer */
1014 struct pvr2_v4l2_fh *fhp; 1014 struct pvr2_v4l2_fh *fhp;
@@ -1235,13 +1235,12 @@ static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait)
1235} 1235}
1236 1236
1237 1237
1238static const struct file_operations vdev_fops = { 1238static const struct v4l2_file_operations vdev_fops = {
1239 .owner = THIS_MODULE, 1239 .owner = THIS_MODULE,
1240 .open = pvr2_v4l2_open, 1240 .open = pvr2_v4l2_open,
1241 .release = pvr2_v4l2_release, 1241 .release = pvr2_v4l2_release,
1242 .read = pvr2_v4l2_read, 1242 .read = pvr2_v4l2_read,
1243 .ioctl = pvr2_v4l2_ioctl, 1243 .ioctl = pvr2_v4l2_ioctl,
1244 .llseek = no_llseek,
1245 .poll = pvr2_v4l2_poll, 1244 .poll = pvr2_v4l2_poll,
1246}; 1245};
1247 1246
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c
index c66530210192..f9fbe02e0f69 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -1266,9 +1266,9 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
1266/* copy local variable to arg */ 1266/* copy local variable to arg */
1267#define ARG_OUT(ARG_name) /* nothing */ 1267#define ARG_OUT(ARG_name) /* nothing */
1268 1268
1269int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) 1269long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1270{ 1270{
1271 int ret = 0; 1271 long ret = 0;
1272 1272
1273 switch(cmd) { 1273 switch(cmd) {
1274 case VIDIOCPWCRUSER: 1274 case VIDIOCPWCRUSER:
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 1ce9da167b7e..39fbc970f43d 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -142,16 +142,16 @@ static struct {
142 142
143/***/ 143/***/
144 144
145static int pwc_video_open(struct inode *inode, struct file *file); 145static int pwc_video_open(struct file *file);
146static int pwc_video_close(struct inode *inode, struct file *file); 146static int pwc_video_close(struct file *file);
147static ssize_t pwc_video_read(struct file *file, char __user *buf, 147static ssize_t pwc_video_read(struct file *file, char __user *buf,
148 size_t count, loff_t *ppos); 148 size_t count, loff_t *ppos);
149static unsigned int pwc_video_poll(struct file *file, poll_table *wait); 149static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
150static int pwc_video_ioctl(struct inode *inode, struct file *file, 150static long pwc_video_ioctl(struct file *file,
151 unsigned int ioctlnr, unsigned long arg); 151 unsigned int ioctlnr, unsigned long arg);
152static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); 152static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma);
153 153
154static const struct file_operations pwc_fops = { 154static const struct v4l2_file_operations pwc_fops = {
155 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
156 .open = pwc_video_open, 156 .open = pwc_video_open,
157 .release = pwc_video_close, 157 .release = pwc_video_close,
@@ -159,10 +159,6 @@ static const struct file_operations pwc_fops = {
159 .poll = pwc_video_poll, 159 .poll = pwc_video_poll,
160 .mmap = pwc_video_mmap, 160 .mmap = pwc_video_mmap,
161 .ioctl = pwc_video_ioctl, 161 .ioctl = pwc_video_ioctl,
162#ifdef CONFIG_COMPAT
163 .compat_ioctl = v4l_compat_ioctl32,
164#endif
165 .llseek = no_llseek,
166}; 162};
167static struct video_device pwc_template = { 163static struct video_device pwc_template = {
168 .name = "Philips Webcam", /* Filled in later */ 164 .name = "Philips Webcam", /* Filled in later */
@@ -1104,7 +1100,7 @@ static const char *pwc_sensor_type_to_string(unsigned int sensor_type)
1104/***************************************************************************/ 1100/***************************************************************************/
1105/* Video4Linux functions */ 1101/* Video4Linux functions */
1106 1102
1107static int pwc_video_open(struct inode *inode, struct file *file) 1103static int pwc_video_open(struct file *file)
1108{ 1104{
1109 int i, ret; 1105 int i, ret;
1110 struct video_device *vdev = video_devdata(file); 1106 struct video_device *vdev = video_devdata(file);
@@ -1224,7 +1220,7 @@ static void pwc_cleanup(struct pwc_device *pdev)
1224} 1220}
1225 1221
1226/* Note that all cleanup is done in the reverse order as in _open */ 1222/* Note that all cleanup is done in the reverse order as in _open */
1227static int pwc_video_close(struct inode *inode, struct file *file) 1223static int pwc_video_close(struct file *file)
1228{ 1224{
1229 struct video_device *vdev = file->private_data; 1225 struct video_device *vdev = file->private_data;
1230 struct pwc_device *pdev; 1226 struct pwc_device *pdev;
@@ -1399,12 +1395,12 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
1399 return 0; 1395 return 0;
1400} 1396}
1401 1397
1402static int pwc_video_ioctl(struct inode *inode, struct file *file, 1398static long pwc_video_ioctl(struct file *file,
1403 unsigned int cmd, unsigned long arg) 1399 unsigned int cmd, unsigned long arg)
1404{ 1400{
1405 struct video_device *vdev = file->private_data; 1401 struct video_device *vdev = file->private_data;
1406 struct pwc_device *pdev; 1402 struct pwc_device *pdev;
1407 int r = -ENODEV; 1403 long r = -ENODEV;
1408 1404
1409 if (!vdev) 1405 if (!vdev)
1410 goto out; 1406 goto out;
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index d7c147328e35..bc0a464295c5 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -337,7 +337,7 @@ static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f)
337 337
338} 338}
339 339
340int pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg) 340long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
341{ 341{
342 struct video_device *vdev = video_devdata(file); 342 struct video_device *vdev = video_devdata(file);
343 struct pwc_device *pdev; 343 struct pwc_device *pdev;
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index c046a2535668..01411fb2337a 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -337,10 +337,10 @@ extern int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise);
337extern int pwc_camera_power(struct pwc_device *pdev, int power); 337extern int pwc_camera_power(struct pwc_device *pdev, int power);
338 338
339/* Private ioctl()s; see pwc-ioctl.h */ 339/* Private ioctl()s; see pwc-ioctl.h */
340extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg); 340extern long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
341 341
342/** Functions in pwc-v4l.c */ 342/** Functions in pwc-v4l.c */
343extern int pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg); 343extern long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg);
344 344
345/** pwc-uncompress.c */ 345/** pwc-uncompress.c */
346/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */ 346/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 3c3f8cf73108..13f85ad363cd 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -1502,9 +1502,9 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
1502 dprintk(2, "setting jpeg quality %d\n", jc->quality); 1502 dprintk(2, "setting jpeg quality %d\n", jc->quality);
1503 return 0; 1503 return 0;
1504} 1504}
1505static int s2255_open(struct inode *inode, struct file *file) 1505static int s2255_open(struct file *file)
1506{ 1506{
1507 int minor = iminor(inode); 1507 int minor = video_devdata(file)->minor;
1508 struct s2255_dev *h, *dev = NULL; 1508 struct s2255_dev *h, *dev = NULL;
1509 struct s2255_fh *fh; 1509 struct s2255_fh *fh;
1510 struct list_head *list; 1510 struct list_head *list;
@@ -1711,11 +1711,11 @@ static void s2255_destroy(struct kref *kref)
1711 mutex_unlock(&dev->open_lock); 1711 mutex_unlock(&dev->open_lock);
1712} 1712}
1713 1713
1714static int s2255_close(struct inode *inode, struct file *file) 1714static int s2255_close(struct file *file)
1715{ 1715{
1716 struct s2255_fh *fh = file->private_data; 1716 struct s2255_fh *fh = file->private_data;
1717 struct s2255_dev *dev = fh->dev; 1717 struct s2255_dev *dev = fh->dev;
1718 int minor = iminor(inode); 1718 int minor = video_devdata(file)->minor;
1719 if (!dev) 1719 if (!dev)
1720 return -ENODEV; 1720 return -ENODEV;
1721 1721
@@ -1759,15 +1759,13 @@ static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma)
1759 return ret; 1759 return ret;
1760} 1760}
1761 1761
1762static const struct file_operations s2255_fops_v4l = { 1762static const struct v4l2_file_operations s2255_fops_v4l = {
1763 .owner = THIS_MODULE, 1763 .owner = THIS_MODULE,
1764 .open = s2255_open, 1764 .open = s2255_open,
1765 .release = s2255_close, 1765 .release = s2255_close,
1766 .poll = s2255_poll, 1766 .poll = s2255_poll,
1767 .ioctl = video_ioctl2, /* V4L2 ioctl handler */ 1767 .ioctl = video_ioctl2, /* V4L2 ioctl handler */
1768 .compat_ioctl = v4l_compat_ioctl32,
1769 .mmap = s2255_mmap_v4l, 1768 .mmap = s2255_mmap_v4l,
1770 .llseek = no_llseek,
1771}; 1769};
1772 1770
1773static const struct v4l2_ioctl_ops s2255_ioctl_ops = { 1771static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index f159441e9375..e637e440b6d5 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -804,7 +804,7 @@ static inline int saa5246a_stop_dau(struct saa5246a_device *t,
804 * 804 *
805 * Returns 0 if successful 805 * Returns 0 if successful
806 */ 806 */
807static int do_saa5246a_ioctl(struct file *file, unsigned int cmd, void *arg) 807static long do_saa5246a_ioctl(struct file *file, unsigned int cmd, void *arg)
808{ 808{
809 struct saa5246a_device *t = video_drvdata(file); 809 struct saa5246a_device *t = video_drvdata(file);
810 810
@@ -944,11 +944,11 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
944/* 944/*
945 * Handle the locking 945 * Handle the locking
946 */ 946 */
947static int saa5246a_ioctl(struct inode *inode, struct file *file, 947static long saa5246a_ioctl(struct file *file,
948 unsigned int cmd, unsigned long arg) 948 unsigned int cmd, unsigned long arg)
949{ 949{
950 struct saa5246a_device *t = video_drvdata(file); 950 struct saa5246a_device *t = video_drvdata(file);
951 int err; 951 long err;
952 952
953 cmd = vtx_fix_command(cmd); 953 cmd = vtx_fix_command(cmd);
954 mutex_lock(&t->lock); 954 mutex_lock(&t->lock);
@@ -957,7 +957,7 @@ static int saa5246a_ioctl(struct inode *inode, struct file *file,
957 return err; 957 return err;
958} 958}
959 959
960static int saa5246a_open(struct inode *inode, struct file *file) 960static int saa5246a_open(struct file *file)
961{ 961{
962 struct saa5246a_device *t = video_drvdata(file); 962 struct saa5246a_device *t = video_drvdata(file);
963 963
@@ -999,7 +999,7 @@ static int saa5246a_open(struct inode *inode, struct file *file)
999 return 0; 999 return 0;
1000} 1000}
1001 1001
1002static int saa5246a_release(struct inode *inode, struct file *file) 1002static int saa5246a_release(struct file *file)
1003{ 1003{
1004 struct saa5246a_device *t = video_drvdata(file); 1004 struct saa5246a_device *t = video_drvdata(file);
1005 1005
@@ -1018,12 +1018,11 @@ static int saa5246a_release(struct inode *inode, struct file *file)
1018 return 0; 1018 return 0;
1019} 1019}
1020 1020
1021static const struct file_operations saa_fops = { 1021static const struct v4l2_file_operations saa_fops = {
1022 .owner = THIS_MODULE, 1022 .owner = THIS_MODULE,
1023 .open = saa5246a_open, 1023 .open = saa5246a_open,
1024 .release = saa5246a_release, 1024 .release = saa5246a_release,
1025 .ioctl = saa5246a_ioctl, 1025 .ioctl = saa5246a_ioctl,
1026 .llseek = no_llseek,
1027}; 1026};
1028 1027
1029static struct video_device saa_template = 1028static struct video_device saa_template =
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 6ef3affb97f1..e29765192469 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -190,7 +190,7 @@ static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
190 * Standard character-device-driver functions 190 * Standard character-device-driver functions
191 */ 191 */
192 192
193static int do_saa5249_ioctl(struct file *file, unsigned int cmd, void *arg) 193static long do_saa5249_ioctl(struct file *file, unsigned int cmd, void *arg)
194{ 194{
195 static int virtual_mode = false; 195 static int virtual_mode = false;
196 struct saa5249_device *t = video_drvdata(file); 196 struct saa5249_device *t = video_drvdata(file);
@@ -479,11 +479,11 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
479 * Handle the locking 479 * Handle the locking
480 */ 480 */
481 481
482static int saa5249_ioctl(struct inode *inode, struct file *file, 482static long saa5249_ioctl(struct file *file,
483 unsigned int cmd, unsigned long arg) 483 unsigned int cmd, unsigned long arg)
484{ 484{
485 struct saa5249_device *t = video_drvdata(file); 485 struct saa5249_device *t = video_drvdata(file);
486 int err; 486 long err;
487 487
488 cmd = vtx_fix_command(cmd); 488 cmd = vtx_fix_command(cmd);
489 mutex_lock(&t->lock); 489 mutex_lock(&t->lock);
@@ -492,7 +492,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
492 return err; 492 return err;
493} 493}
494 494
495static int saa5249_open(struct inode *inode, struct file *file) 495static int saa5249_open(struct file *file)
496{ 496{
497 struct saa5249_device *t = video_drvdata(file); 497 struct saa5249_device *t = video_drvdata(file);
498 int pgbuf; 498 int pgbuf;
@@ -529,7 +529,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
529 529
530 530
531 531
532static int saa5249_release(struct inode *inode, struct file *file) 532static int saa5249_release(struct file *file)
533{ 533{
534 struct saa5249_device *t = video_drvdata(file); 534 struct saa5249_device *t = video_drvdata(file);
535 535
@@ -539,15 +539,11 @@ static int saa5249_release(struct inode *inode, struct file *file)
539 return 0; 539 return 0;
540} 540}
541 541
542static const struct file_operations saa_fops = { 542static const struct v4l2_file_operations saa_fops = {
543 .owner = THIS_MODULE, 543 .owner = THIS_MODULE,
544 .open = saa5249_open, 544 .open = saa5249_open,
545 .release = saa5249_release, 545 .release = saa5249_release,
546 .ioctl = saa5249_ioctl, 546 .ioctl = saa5249_ioctl,
547#ifdef CONFIG_COMPAT
548 .compat_ioctl = v4l_compat_ioctl32,
549#endif
550 .llseek = no_llseek,
551}; 547};
552 548
553static struct video_device saa_template = 549static struct video_device saa_template =
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 22708ecdf1bb..46c796c3fec8 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1371,25 +1371,24 @@ static int saa711x_g_vbi_data(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_dat
1371} 1371}
1372 1372
1373#ifdef CONFIG_VIDEO_ADV_DEBUG 1373#ifdef CONFIG_VIDEO_ADV_DEBUG
1374static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1374static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1375{ 1375{
1376 struct i2c_client *client = v4l2_get_subdevdata(sd); 1376 struct i2c_client *client = v4l2_get_subdevdata(sd);
1377 1377
1378 if (!v4l2_chip_match_i2c_client(client, 1378 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1379 reg->match_type, reg->match_chip))
1380 return -EINVAL; 1379 return -EINVAL;
1381 if (!capable(CAP_SYS_ADMIN)) 1380 if (!capable(CAP_SYS_ADMIN))
1382 return -EPERM; 1381 return -EPERM;
1383 reg->val = saa711x_read(sd, reg->reg & 0xff); 1382 reg->val = saa711x_read(sd, reg->reg & 0xff);
1383 reg->size = 1;
1384 return 0; 1384 return 0;
1385} 1385}
1386 1386
1387static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1387static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1388{ 1388{
1389 struct i2c_client *client = v4l2_get_subdevdata(sd); 1389 struct i2c_client *client = v4l2_get_subdevdata(sd);
1390 1390
1391 if (!v4l2_chip_match_i2c_client(client, 1391 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1392 reg->match_type, reg->match_chip))
1393 return -EINVAL; 1392 return -EINVAL;
1394 if (!capable(CAP_SYS_ADMIN)) 1393 if (!capable(CAP_SYS_ADMIN))
1395 return -EPERM; 1394 return -EPERM;
@@ -1398,7 +1397,7 @@ static int saa711x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
1398} 1397}
1399#endif 1398#endif
1400 1399
1401static int saa711x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 1400static int saa711x_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
1402{ 1401{
1403 struct saa711x_state *state = to_state(sd); 1402 struct saa711x_state *state = to_state(sd);
1404 struct i2c_client *client = v4l2_get_subdevdata(sd); 1403 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index bfc85654795e..d6848f7a503b 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -623,25 +623,24 @@ static int saa7127_s_vbi_data(struct v4l2_subdev *sd, const struct v4l2_sliced_v
623} 623}
624 624
625#ifdef CONFIG_VIDEO_ADV_DEBUG 625#ifdef CONFIG_VIDEO_ADV_DEBUG
626static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 626static int saa7127_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
627{ 627{
628 struct i2c_client *client = v4l2_get_subdevdata(sd); 628 struct i2c_client *client = v4l2_get_subdevdata(sd);
629 629
630 if (!v4l2_chip_match_i2c_client(client, 630 if (!v4l2_chip_match_i2c_client(client, &reg->match))
631 reg->match_type, reg->match_chip))
632 return -EINVAL; 631 return -EINVAL;
633 if (!capable(CAP_SYS_ADMIN)) 632 if (!capable(CAP_SYS_ADMIN))
634 return -EPERM; 633 return -EPERM;
635 reg->val = saa7127_read(sd, reg->reg & 0xff); 634 reg->val = saa7127_read(sd, reg->reg & 0xff);
635 reg->size = 1;
636 return 0; 636 return 0;
637} 637}
638 638
639static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 639static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
640{ 640{
641 struct i2c_client *client = v4l2_get_subdevdata(sd); 641 struct i2c_client *client = v4l2_get_subdevdata(sd);
642 642
643 if (!v4l2_chip_match_i2c_client(client, 643 if (!v4l2_chip_match_i2c_client(client, &reg->match))
644 reg->match_type, reg->match_chip))
645 return -EINVAL; 644 return -EINVAL;
646 if (!capable(CAP_SYS_ADMIN)) 645 if (!capable(CAP_SYS_ADMIN))
647 return -EPERM; 646 return -EPERM;
@@ -650,7 +649,7 @@ static int saa7127_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
650} 649}
651#endif 650#endif
652 651
653static int saa7127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 652static int saa7127_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
654{ 653{
655 struct saa7127_state *state = to_state(sd); 654 struct saa7127_state *state = to_state(sd);
656 struct i2c_client *client = v4l2_get_subdevdata(sd); 655 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 1fb6eccdade3..1fee6e84a512 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -838,7 +838,7 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
838 h->standard = *((v4l2_std_id *) arg); 838 h->standard = *((v4l2_std_id *) arg);
839 break; 839 break;
840 840
841 case VIDIOC_G_CHIP_IDENT: 841 case VIDIOC_DBG_G_CHIP_IDENT:
842 return v4l2_chip_ident_i2c_client(client, 842 return v4l2_chip_ident_i2c_client(client,
843 arg, h->chip, h->revision); 843 arg, h->chip, h->revision);
844 844
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index a2e3f6729c5b..e2febcd6e529 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -4462,6 +4462,7 @@ struct saa7134_board saa7134_boards[] = {
4462 .tuner_addr = ADDR_UNSET, 4462 .tuner_addr = ADDR_UNSET,
4463 .radio_addr = ADDR_UNSET, 4463 .radio_addr = ADDR_UNSET,
4464 .tda9887_conf = TDA9887_PRESENT, 4464 .tda9887_conf = TDA9887_PRESENT,
4465 .mpeg = SAA7134_MPEG_DVB,
4465 .inputs = {{ 4466 .inputs = {{
4466 .name = name_tv, 4467 .name = name_tv,
4467 .vmux = 3, 4468 .vmux = 3,
@@ -4480,8 +4481,6 @@ struct saa7134_board saa7134_boards[] = {
4480 .name = name_radio, 4481 .name = name_radio,
4481 .amux = LINE2, 4482 .amux = LINE2,
4482 }, 4483 },
4483 /* no DVB support for now */
4484 /* .mpeg = SAA7134_MPEG_DVB, */
4485 }, 4484 },
4486 [SAA7134_BOARD_ASUSTeK_TIGER_3IN1] = { 4485 [SAA7134_BOARD_ASUSTeK_TIGER_3IN1] = {
4487 .name = "Asus Tiger 3in1", 4486 .name = "Asus Tiger 3in1",
@@ -4643,6 +4642,38 @@ struct saa7134_board saa7134_boards[] = {
4643 .amux = 2, 4642 .amux = 2,
4644 }, 4643 },
4645 }, 4644 },
4645 [SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS] = {
4646 .name = "Avermedia AVerTV GO 007 FM Plus",
4647 .audio_clock = 0x00187de7,
4648 .tuner_type = TUNER_PHILIPS_TDA8290,
4649 .radio_type = UNSET,
4650 .tuner_addr = ADDR_UNSET,
4651 .radio_addr = ADDR_UNSET,
4652 .gpiomask = 0x00300003,
4653 /* .gpiomask = 0x8c240003, */
4654 .inputs = { {
4655 .name = name_tv,
4656 .vmux = 1,
4657 .amux = TV,
4658 .tv = 1,
4659 .gpio = 0x01,
4660 }, {
4661 .name = name_svideo,
4662 .vmux = 6,
4663 .amux = LINE1,
4664 .gpio = 0x02,
4665 } },
4666 .radio = {
4667 .name = name_radio,
4668 .amux = TV,
4669 .gpio = 0x00300001,
4670 },
4671 .mute = {
4672 .name = name_mute,
4673 .amux = TV,
4674 .gpio = 0x01,
4675 },
4676 },
4646}; 4677};
4647 4678
4648const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 4679const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -5702,6 +5733,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
5702 .subdevice = 0x7128, 5733 .subdevice = 0x7128,
5703 .driver_data = SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG, 5734 .driver_data = SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG,
5704 }, { 5735 }, {
5736 .vendor = PCI_VENDOR_ID_PHILIPS,
5737 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5738 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5739 .subdevice = 0xf31d,
5740 .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS,
5741
5742 }, {
5705 /* --- boards without eeprom + subsystem ID --- */ 5743 /* --- boards without eeprom + subsystem ID --- */
5706 .vendor = PCI_VENDOR_ID_PHILIPS, 5744 .vendor = PCI_VENDOR_ID_PHILIPS,
5707 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 5745 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -5930,6 +5968,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
5930 case SAA7134_BOARD_GENIUS_TVGO_A11MCE: 5968 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
5931 case SAA7134_BOARD_REAL_ANGEL_220: 5969 case SAA7134_BOARD_REAL_ANGEL_220:
5932 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: 5970 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
5971 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
5933 dev->has_remote = SAA7134_REMOTE_GPIO; 5972 dev->has_remote = SAA7134_REMOTE_GPIO;
5934 break; 5973 break;
5935 case SAA7134_BOARD_FLYDVBS_LR300: 5974 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -6025,6 +6064,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6025 case SAA7134_BOARD_BEHOLD_M6: 6064 case SAA7134_BOARD_BEHOLD_M6:
6026 case SAA7134_BOARD_BEHOLD_M63: 6065 case SAA7134_BOARD_BEHOLD_M63:
6027 case SAA7134_BOARD_BEHOLD_M6_EXTRA: 6066 case SAA7134_BOARD_BEHOLD_M6_EXTRA:
6067 case SAA7134_BOARD_BEHOLD_H6:
6028 dev->has_remote = SAA7134_REMOTE_I2C; 6068 dev->has_remote = SAA7134_REMOTE_I2C;
6029 break; 6069 break;
6030 case SAA7134_BOARD_AVERMEDIA_A169_B: 6070 case SAA7134_BOARD_AVERMEDIA_A169_B:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index d9a5652595b5..0776ecf56d27 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -49,6 +49,8 @@
49#include "lnbp21.h" 49#include "lnbp21.h"
50#include "tuner-simple.h" 50#include "tuner-simple.h"
51 51
52#include "zl10353.h"
53
52MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 54MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53MODULE_LICENSE("GPL"); 55MODULE_LICENSE("GPL");
54 56
@@ -854,6 +856,12 @@ static struct tda1004x_config ads_tech_duo_config = {
854 .request_firmware = philips_tda1004x_request_firmware 856 .request_firmware = philips_tda1004x_request_firmware
855}; 857};
856 858
859static struct zl10353_config behold_h6_config = {
860 .demod_address = 0x1e>>1,
861 .no_tuner = 1,
862 .parallel_ts = 1,
863};
864
857/* ================================================================== 865/* ==================================================================
858 * tda10086 based DVB-S cards, helper functions 866 * tda10086 based DVB-S cards, helper functions
859 */ 867 */
@@ -1357,6 +1365,16 @@ static int dvb_init(struct saa7134_dev *dev)
1357 &tda827x_cfg_0) < 0) 1365 &tda827x_cfg_0) < 0)
1358 goto dettach_frontend; 1366 goto dettach_frontend;
1359 break; 1367 break;
1368 case SAA7134_BOARD_BEHOLD_H6:
1369 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1370 &behold_h6_config,
1371 &dev->i2c_adap);
1372 if (fe0->dvb.frontend) {
1373 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1374 &dev->i2c_adap, 0x61,
1375 TUNER_PHILIPS_FMD1216ME_MK3);
1376 }
1377 break;
1360 default: 1378 default:
1361 wprintk("Huh? unknown DVB card?\n"); 1379 wprintk("Huh? unknown DVB card?\n");
1362 break; 1380 break;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 7f40511bcc04..c9d8beb87a60 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -83,9 +83,9 @@ static int ts_init_encoder(struct saa7134_dev* dev)
83 83
84/* ------------------------------------------------------------------ */ 84/* ------------------------------------------------------------------ */
85 85
86static int ts_open(struct inode *inode, struct file *file) 86static int ts_open(struct file *file)
87{ 87{
88 int minor = iminor(inode); 88 int minor = video_devdata(file)->minor;
89 struct saa7134_dev *dev; 89 struct saa7134_dev *dev;
90 int err; 90 int err;
91 91
@@ -119,7 +119,7 @@ done:
119 return err; 119 return err;
120} 120}
121 121
122static int ts_release(struct inode *inode, struct file *file) 122static int ts_release(struct file *file)
123{ 123{
124 struct saa7134_dev *dev = file->private_data; 124 struct saa7134_dev *dev = file->private_data;
125 125
@@ -405,7 +405,7 @@ static int empress_querymenu(struct file *file, void *priv,
405} 405}
406 406
407static int empress_g_chip_ident(struct file *file, void *fh, 407static int empress_g_chip_ident(struct file *file, void *fh,
408 struct v4l2_chip_ident *chip) 408 struct v4l2_dbg_chip_ident *chip)
409{ 409{
410 struct saa7134_dev *dev = file->private_data; 410 struct saa7134_dev *dev = file->private_data;
411 411
@@ -413,12 +413,12 @@ static int empress_g_chip_ident(struct file *file, void *fh,
413 chip->revision = 0; 413 chip->revision = 0;
414 if (dev->mpeg_i2c_client == NULL) 414 if (dev->mpeg_i2c_client == NULL)
415 return -EINVAL; 415 return -EINVAL;
416 if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER && 416 if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER &&
417 chip->match_chip == I2C_DRIVERID_SAA6752HS) 417 !strcmp(chip->match.name, "saa6752hs"))
418 return saa7134_i2c_call_saa6752(dev, VIDIOC_G_CHIP_IDENT, chip); 418 return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip);
419 if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR && 419 if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR &&
420 chip->match_chip == dev->mpeg_i2c_client->addr) 420 chip->match.addr == dev->mpeg_i2c_client->addr)
421 return saa7134_i2c_call_saa6752(dev, VIDIOC_G_CHIP_IDENT, chip); 421 return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip);
422 return -EINVAL; 422 return -EINVAL;
423} 423}
424 424
@@ -437,7 +437,7 @@ static int empress_g_std(struct file *file, void *priv, v4l2_std_id *id)
437 return 0; 437 return 0;
438} 438}
439 439
440static const struct file_operations ts_fops = 440static const struct v4l2_file_operations ts_fops =
441{ 441{
442 .owner = THIS_MODULE, 442 .owner = THIS_MODULE,
443 .open = ts_open, 443 .open = ts_open,
@@ -446,7 +446,6 @@ static const struct file_operations ts_fops =
446 .poll = ts_poll, 446 .poll = ts_poll,
447 .mmap = ts_mmap, 447 .mmap = ts_mmap,
448 .ioctl = video_ioctl2, 448 .ioctl = video_ioctl2,
449 .llseek = no_llseek,
450}; 449};
451 450
452static const struct v4l2_ioctl_ops ts_ioctl_ops = { 451static const struct v4l2_ioctl_ops ts_ioctl_ops = {
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index d2124f64e4e2..8a106d36e723 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -449,6 +449,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
449 case SAA7134_BOARD_AVERMEDIA_STUDIO_507: 449 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
450 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 450 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
451 case SAA7134_BOARD_AVERMEDIA_M102: 451 case SAA7134_BOARD_AVERMEDIA_M102:
452 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
452 ir_codes = ir_codes_avermedia; 453 ir_codes = ir_codes_avermedia;
453 mask_keycode = 0x0007C8; 454 mask_keycode = 0x0007C8;
454 mask_keydown = 0x000010; 455 mask_keydown = 0x000010;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 02bb6747a39c..a1f7e351f572 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1326,9 +1326,9 @@ static int saa7134_resource(struct saa7134_fh *fh)
1326 return 0; 1326 return 0;
1327} 1327}
1328 1328
1329static int video_open(struct inode *inode, struct file *file) 1329static int video_open(struct file *file)
1330{ 1330{
1331 int minor = iminor(inode); 1331 int minor = video_devdata(file)->minor;
1332 struct saa7134_dev *dev; 1332 struct saa7134_dev *dev;
1333 struct saa7134_fh *fh; 1333 struct saa7134_fh *fh;
1334 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1334 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -1462,7 +1462,7 @@ err:
1462 return POLLERR; 1462 return POLLERR;
1463} 1463}
1464 1464
1465static int video_release(struct inode *inode, struct file *file) 1465static int video_release(struct file *file)
1466{ 1466{
1467 struct saa7134_fh *fh = file->private_data; 1467 struct saa7134_fh *fh = file->private_data;
1468 struct saa7134_dev *dev = fh->dev; 1468 struct saa7134_dev *dev = fh->dev;
@@ -2247,24 +2247,25 @@ static int saa7134_g_parm(struct file *file, void *fh,
2247 2247
2248#ifdef CONFIG_VIDEO_ADV_DEBUG 2248#ifdef CONFIG_VIDEO_ADV_DEBUG
2249static int vidioc_g_register (struct file *file, void *priv, 2249static int vidioc_g_register (struct file *file, void *priv,
2250 struct v4l2_register *reg) 2250 struct v4l2_dbg_register *reg)
2251{ 2251{
2252 struct saa7134_fh *fh = priv; 2252 struct saa7134_fh *fh = priv;
2253 struct saa7134_dev *dev = fh->dev; 2253 struct saa7134_dev *dev = fh->dev;
2254 2254
2255 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 2255 if (!v4l2_chip_match_host(&reg->match))
2256 return -EINVAL; 2256 return -EINVAL;
2257 reg->val = saa_readb(reg->reg); 2257 reg->val = saa_readb(reg->reg);
2258 reg->size = 1;
2258 return 0; 2259 return 0;
2259} 2260}
2260 2261
2261static int vidioc_s_register (struct file *file, void *priv, 2262static int vidioc_s_register (struct file *file, void *priv,
2262 struct v4l2_register *reg) 2263 struct v4l2_dbg_register *reg)
2263{ 2264{
2264 struct saa7134_fh *fh = priv; 2265 struct saa7134_fh *fh = priv;
2265 struct saa7134_dev *dev = fh->dev; 2266 struct saa7134_dev *dev = fh->dev;
2266 2267
2267 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 2268 if (!v4l2_chip_match_host(&reg->match))
2268 return -EINVAL; 2269 return -EINVAL;
2269 saa_writeb(reg->reg&0xffffff, reg->val); 2270 saa_writeb(reg->reg&0xffffff, reg->val);
2270 return 0; 2271 return 0;
@@ -2377,7 +2378,7 @@ static int radio_queryctrl(struct file *file, void *priv,
2377 return 0; 2378 return 0;
2378} 2379}
2379 2380
2380static const struct file_operations video_fops = 2381static const struct v4l2_file_operations video_fops =
2381{ 2382{
2382 .owner = THIS_MODULE, 2383 .owner = THIS_MODULE,
2383 .open = video_open, 2384 .open = video_open,
@@ -2386,8 +2387,6 @@ static const struct file_operations video_fops =
2386 .poll = video_poll, 2387 .poll = video_poll,
2387 .mmap = video_mmap, 2388 .mmap = video_mmap,
2388 .ioctl = video_ioctl2, 2389 .ioctl = video_ioctl2,
2389 .compat_ioctl = v4l_compat_ioctl32,
2390 .llseek = no_llseek,
2391}; 2390};
2392 2391
2393static const struct v4l2_ioctl_ops video_ioctl_ops = { 2392static const struct v4l2_ioctl_ops video_ioctl_ops = {
@@ -2441,13 +2440,11 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
2441#endif 2440#endif
2442}; 2441};
2443 2442
2444static const struct file_operations radio_fops = { 2443static const struct v4l2_file_operations radio_fops = {
2445 .owner = THIS_MODULE, 2444 .owner = THIS_MODULE,
2446 .open = video_open, 2445 .open = video_open,
2447 .release = video_release, 2446 .release = video_release,
2448 .ioctl = video_ioctl2, 2447 .ioctl = video_ioctl2,
2449 .compat_ioctl = v4l_compat_ioctl32,
2450 .llseek = no_llseek,
2451}; 2448};
2452 2449
2453static const struct v4l2_ioctl_ops radio_ioctl_ops = { 2450static const struct v4l2_ioctl_ops radio_ioctl_ops = {
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index f6c1fcc72070..14ee265f3374 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -276,6 +276,7 @@ struct saa7134_format {
276#define SAA7134_BOARD_ADS_INSTANT_HDTV_PCI 151 276#define SAA7134_BOARD_ADS_INSTANT_HDTV_PCI 151
277#define SAA7134_BOARD_ASUSTeK_TIGER 152 277#define SAA7134_BOARD_ASUSTeK_TIGER 152
278#define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153 278#define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153
279#define SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS 154
279 280
280#define SAA7134_MAXBOARDS 32 281#define SAA7134_MAXBOARDS 32
281#define SAA7134_INPUT_MAX 8 282#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 9befca65905e..454ad1dd7507 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -1171,25 +1171,26 @@ static int saa717x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1171} 1171}
1172 1172
1173#ifdef CONFIG_VIDEO_ADV_DEBUG 1173#ifdef CONFIG_VIDEO_ADV_DEBUG
1174static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1174static int saa717x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1175{ 1175{
1176 struct i2c_client *client = v4l2_get_subdevdata(sd); 1176 struct i2c_client *client = v4l2_get_subdevdata(sd);
1177 1177
1178 if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 1178 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1179 return -EINVAL; 1179 return -EINVAL;
1180 if (!capable(CAP_SYS_ADMIN)) 1180 if (!capable(CAP_SYS_ADMIN))
1181 return -EPERM; 1181 return -EPERM;
1182 reg->val = saa717x_read(sd, reg->reg); 1182 reg->val = saa717x_read(sd, reg->reg);
1183 reg->size = 1;
1183 return 0; 1184 return 0;
1184} 1185}
1185 1186
1186static int saa717x_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 1187static int saa717x_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1187{ 1188{
1188 struct i2c_client *client = v4l2_get_subdevdata(sd); 1189 struct i2c_client *client = v4l2_get_subdevdata(sd);
1189 u16 addr = reg->reg & 0xffff; 1190 u16 addr = reg->reg & 0xffff;
1190 u8 val = reg->val & 0xff; 1191 u8 val = reg->val & 0xff;
1191 1192
1192 if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) 1193 if (!v4l2_chip_match_i2c_client(client, &reg->match))
1193 return -EINVAL; 1194 return -EINVAL;
1194 if (!capable(CAP_SYS_ADMIN)) 1195 if (!capable(CAP_SYS_ADMIN))
1195 return -EPERM; 1196 return -EPERM;
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c
index d652f25eef0e..5990ab38a124 100644
--- a/drivers/media/video/se401.c
+++ b/drivers/media/video/se401.c
@@ -932,7 +932,7 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
932 ***************************************************************************/ 932 ***************************************************************************/
933 933
934 934
935static int se401_open(struct inode *inode, struct file *file) 935static int se401_open(struct file *file)
936{ 936{
937 struct video_device *dev = video_devdata(file); 937 struct video_device *dev = video_devdata(file);
938 struct usb_se401 *se401 = (struct usb_se401 *)dev; 938 struct usb_se401 *se401 = (struct usb_se401 *)dev;
@@ -954,7 +954,7 @@ static int se401_open(struct inode *inode, struct file *file)
954 return err; 954 return err;
955} 955}
956 956
957static int se401_close(struct inode *inode, struct file *file) 957static int se401_close(struct file *file)
958{ 958{
959 struct video_device *dev = file->private_data; 959 struct video_device *dev = file->private_data;
960 struct usb_se401 *se401 = (struct usb_se401 *)dev; 960 struct usb_se401 *se401 = (struct usb_se401 *)dev;
@@ -975,7 +975,7 @@ static int se401_close(struct inode *inode, struct file *file)
975 return 0; 975 return 0;
976} 976}
977 977
978static int se401_do_ioctl(struct file *file, unsigned int cmd, void *arg) 978static long se401_do_ioctl(struct file *file, unsigned int cmd, void *arg)
979{ 979{
980 struct video_device *vdev = file->private_data; 980 struct video_device *vdev = file->private_data;
981 struct usb_se401 *se401 = (struct usb_se401 *)vdev; 981 struct usb_se401 *se401 = (struct usb_se401 *)vdev;
@@ -1138,7 +1138,7 @@ static int se401_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1138 return 0; 1138 return 0;
1139} 1139}
1140 1140
1141static int se401_ioctl(struct inode *inode, struct file *file, 1141static long se401_ioctl(struct file *file,
1142 unsigned int cmd, unsigned long arg) 1142 unsigned int cmd, unsigned long arg)
1143{ 1143{
1144 return video_usercopy(file, cmd, arg, se401_do_ioctl); 1144 return video_usercopy(file, cmd, arg, se401_do_ioctl);
@@ -1222,17 +1222,13 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
1222 return 0; 1222 return 0;
1223} 1223}
1224 1224
1225static const struct file_operations se401_fops = { 1225static const struct v4l2_file_operations se401_fops = {
1226 .owner = THIS_MODULE, 1226 .owner = THIS_MODULE,
1227 .open = se401_open, 1227 .open = se401_open,
1228 .release = se401_close, 1228 .release = se401_close,
1229 .read = se401_read, 1229 .read = se401_read,
1230 .mmap = se401_mmap, 1230 .mmap = se401_mmap,
1231 .ioctl = se401_ioctl, 1231 .ioctl = se401_ioctl,
1232#ifdef CONFIG_COMPAT
1233 .compat_ioctl = v4l_compat_ioctl32,
1234#endif
1235 .llseek = no_llseek,
1236}; 1232};
1237static struct video_device se401_template = { 1233static struct video_device se401_template = {
1238 .name = "se401 USB camera", 1234 .name = "se401 USB camera",
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 01a8efb8deb1..23edfdc4d4bc 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1746,7 +1746,7 @@ static void sn9c102_release_resources(struct kref *kref)
1746} 1746}
1747 1747
1748 1748
1749static int sn9c102_open(struct inode* inode, struct file* filp) 1749static int sn9c102_open(struct file *filp)
1750{ 1750{
1751 struct sn9c102_device* cam; 1751 struct sn9c102_device* cam;
1752 int err = 0; 1752 int err = 0;
@@ -1857,7 +1857,7 @@ out:
1857} 1857}
1858 1858
1859 1859
1860static int sn9c102_release(struct inode* inode, struct file* filp) 1860static int sn9c102_release(struct file *filp)
1861{ 1861{
1862 struct sn9c102_device* cam; 1862 struct sn9c102_device* cam;
1863 1863
@@ -3092,8 +3092,8 @@ sn9c102_vidioc_s_audio(struct sn9c102_device* cam, void __user * arg)
3092} 3092}
3093 3093
3094 3094
3095static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, 3095static long sn9c102_ioctl_v4l2(struct file *filp,
3096 unsigned int cmd, void __user * arg) 3096 unsigned int cmd, void __user *arg)
3097{ 3097{
3098 struct sn9c102_device *cam = video_drvdata(filp); 3098 struct sn9c102_device *cam = video_drvdata(filp);
3099 3099
@@ -3196,7 +3196,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
3196} 3196}
3197 3197
3198 3198
3199static int sn9c102_ioctl(struct inode* inode, struct file* filp, 3199static long sn9c102_ioctl(struct file *filp,
3200 unsigned int cmd, unsigned long arg) 3200 unsigned int cmd, unsigned long arg)
3201{ 3201{
3202 struct sn9c102_device *cam = video_drvdata(filp); 3202 struct sn9c102_device *cam = video_drvdata(filp);
@@ -3220,7 +3220,7 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
3220 3220
3221 V4LDBG(3, "sn9c102", cmd); 3221 V4LDBG(3, "sn9c102", cmd);
3222 3222
3223 err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); 3223 err = sn9c102_ioctl_v4l2(filp, cmd, (void __user *)arg);
3224 3224
3225 mutex_unlock(&cam->fileop_mutex); 3225 mutex_unlock(&cam->fileop_mutex);
3226 3226
@@ -3229,18 +3229,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
3229 3229
3230/*****************************************************************************/ 3230/*****************************************************************************/
3231 3231
3232static const struct file_operations sn9c102_fops = { 3232static const struct v4l2_file_operations sn9c102_fops = {
3233 .owner = THIS_MODULE, 3233 .owner = THIS_MODULE,
3234 .open = sn9c102_open, 3234 .open = sn9c102_open,
3235 .release = sn9c102_release, 3235 .release = sn9c102_release,
3236 .ioctl = sn9c102_ioctl, 3236 .ioctl = sn9c102_ioctl,
3237#ifdef CONFIG_COMPAT
3238 .compat_ioctl = v4l_compat_ioctl32,
3239#endif
3240 .read = sn9c102_read, 3237 .read = sn9c102_read,
3241 .poll = sn9c102_poll, 3238 .poll = sn9c102_poll,
3242 .mmap = sn9c102_mmap, 3239 .mmap = sn9c102_mmap,
3243 .llseek = no_llseek,
3244}; 3240};
3245 3241
3246/*****************************************************************************/ 3242/*****************************************************************************/
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 90077cb4fe66..fcb05f06de8f 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -256,7 +256,7 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd)
256 vfree(icd->user_formats); 256 vfree(icd->user_formats);
257} 257}
258 258
259static int soc_camera_open(struct inode *inode, struct file *file) 259static int soc_camera_open(struct file *file)
260{ 260{
261 struct video_device *vdev; 261 struct video_device *vdev;
262 struct soc_camera_device *icd; 262 struct soc_camera_device *icd;
@@ -330,7 +330,7 @@ emgd:
330 return ret; 330 return ret;
331} 331}
332 332
333static int soc_camera_close(struct inode *inode, struct file *file) 333static int soc_camera_close(struct file *file)
334{ 334{
335 struct soc_camera_file *icf = file->private_data; 335 struct soc_camera_file *icf = file->private_data;
336 struct soc_camera_device *icd = icf->icd; 336 struct soc_camera_device *icd = icf->icd;
@@ -400,7 +400,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
400 return ici->ops->poll(file, pt); 400 return ici->ops->poll(file, pt);
401} 401}
402 402
403static struct file_operations soc_camera_fops = { 403static struct v4l2_file_operations soc_camera_fops = {
404 .owner = THIS_MODULE, 404 .owner = THIS_MODULE,
405 .open = soc_camera_open, 405 .open = soc_camera_open,
406 .release = soc_camera_close, 406 .release = soc_camera_close,
@@ -408,7 +408,6 @@ static struct file_operations soc_camera_fops = {
408 .read = soc_camera_read, 408 .read = soc_camera_read,
409 .mmap = soc_camera_mmap, 409 .mmap = soc_camera_mmap,
410 .poll = soc_camera_poll, 410 .poll = soc_camera_poll,
411 .llseek = no_llseek,
412}; 411};
413 412
414static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, 413static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv,
@@ -700,7 +699,7 @@ static int soc_camera_s_crop(struct file *file, void *fh,
700} 699}
701 700
702static int soc_camera_g_chip_ident(struct file *file, void *fh, 701static int soc_camera_g_chip_ident(struct file *file, void *fh,
703 struct v4l2_chip_ident *id) 702 struct v4l2_dbg_chip_ident *id)
704{ 703{
705 struct soc_camera_file *icf = file->private_data; 704 struct soc_camera_file *icf = file->private_data;
706 struct soc_camera_device *icd = icf->icd; 705 struct soc_camera_device *icd = icf->icd;
@@ -713,7 +712,7 @@ static int soc_camera_g_chip_ident(struct file *file, void *fh,
713 712
714#ifdef CONFIG_VIDEO_ADV_DEBUG 713#ifdef CONFIG_VIDEO_ADV_DEBUG
715static int soc_camera_g_register(struct file *file, void *fh, 714static int soc_camera_g_register(struct file *file, void *fh,
716 struct v4l2_register *reg) 715 struct v4l2_dbg_register *reg)
717{ 716{
718 struct soc_camera_file *icf = file->private_data; 717 struct soc_camera_file *icf = file->private_data;
719 struct soc_camera_device *icd = icf->icd; 718 struct soc_camera_device *icd = icf->icd;
@@ -725,7 +724,7 @@ static int soc_camera_g_register(struct file *file, void *fh,
725} 724}
726 725
727static int soc_camera_s_register(struct file *file, void *fh, 726static int soc_camera_s_register(struct file *file, void *fh,
728 struct v4l2_register *reg) 727 struct v4l2_dbg_register *reg)
729{ 728{
730 struct soc_camera_file *icf = file->private_data; 729 struct soc_camera_file *icf = file->private_data;
731 struct soc_camera_device *icd = icf->icd; 730 struct soc_camera_device *icd = icf->icd;
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index f9516d0f3c11..26378cf390fc 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -664,7 +664,7 @@ static void stk_free_buffers(struct stk_camera *dev)
664 664
665/* v4l file operations */ 665/* v4l file operations */
666 666
667static int v4l_stk_open(struct inode *inode, struct file *fp) 667static int v4l_stk_open(struct file *fp)
668{ 668{
669 struct stk_camera *dev; 669 struct stk_camera *dev;
670 struct video_device *vdev; 670 struct video_device *vdev;
@@ -684,7 +684,7 @@ static int v4l_stk_open(struct inode *inode, struct file *fp)
684 return 0; 684 return 0;
685} 685}
686 686
687static int v4l_stk_release(struct inode *inode, struct file *fp) 687static int v4l_stk_release(struct file *fp)
688{ 688{
689 struct stk_camera *dev = fp->private_data; 689 struct stk_camera *dev = fp->private_data;
690 690
@@ -1281,7 +1281,7 @@ static int stk_vidioc_enum_framesizes(struct file *filp,
1281 } 1281 }
1282} 1282}
1283 1283
1284static struct file_operations v4l_stk_fops = { 1284static struct v4l2_file_operations v4l_stk_fops = {
1285 .owner = THIS_MODULE, 1285 .owner = THIS_MODULE,
1286 .open = v4l_stk_open, 1286 .open = v4l_stk_open,
1287 .release = v4l_stk_release, 1287 .release = v4l_stk_release,
@@ -1289,10 +1289,6 @@ static struct file_operations v4l_stk_fops = {
1289 .poll = v4l_stk_poll, 1289 .poll = v4l_stk_poll,
1290 .mmap = v4l_stk_mmap, 1290 .mmap = v4l_stk_mmap,
1291 .ioctl = video_ioctl2, 1291 .ioctl = video_ioctl2,
1292#ifdef CONFIG_COMPAT
1293 .compat_ioctl = v4l_compat_ioctl32,
1294#endif
1295 .llseek = no_llseek
1296}; 1292};
1297 1293
1298static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = { 1294static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index bbad54f85c83..0eb313082c97 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1275,7 +1275,7 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
1275 clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y); 1275 clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y);
1276} 1276}
1277 1277
1278static int saa_ioctl(struct inode *inode, struct file *file, 1278static long saa_ioctl(struct file *file,
1279 unsigned int cmd, unsigned long argl) 1279 unsigned int cmd, unsigned long argl)
1280{ 1280{
1281 struct saa7146 *saa = file->private_data; 1281 struct saa7146 *saa = file->private_data;
@@ -1877,7 +1877,7 @@ static ssize_t saa_write(struct file *file, const char __user * buf,
1877 return count; 1877 return count;
1878} 1878}
1879 1879
1880static int saa_open(struct inode *inode, struct file *file) 1880static int saa_open(struct file *file)
1881{ 1881{
1882 struct video_device *vdev = video_devdata(file); 1882 struct video_device *vdev = video_devdata(file);
1883 struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev); 1883 struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
@@ -1895,7 +1895,7 @@ static int saa_open(struct inode *inode, struct file *file)
1895 return 0; 1895 return 0;
1896} 1896}
1897 1897
1898static int saa_release(struct inode *inode, struct file *file) 1898static int saa_release(struct file *file)
1899{ 1899{
1900 struct saa7146 *saa = file->private_data; 1900 struct saa7146 *saa = file->private_data;
1901 saa->user--; 1901 saa->user--;
@@ -1906,16 +1906,12 @@ static int saa_release(struct inode *inode, struct file *file)
1906 return 0; 1906 return 0;
1907} 1907}
1908 1908
1909static const struct file_operations saa_fops = { 1909static const struct v4l2_file_operations saa_fops = {
1910 .owner = THIS_MODULE, 1910 .owner = THIS_MODULE,
1911 .open = saa_open, 1911 .open = saa_open,
1912 .release = saa_release, 1912 .release = saa_release,
1913 .ioctl = saa_ioctl, 1913 .ioctl = saa_ioctl,
1914#ifdef CONFIG_COMPAT
1915 .compat_ioctl = v4l_compat_ioctl32,
1916#endif
1917 .read = saa_read, 1914 .read = saa_read,
1918 .llseek = no_llseek,
1919 .write = saa_write, 1915 .write = saa_write,
1920 .mmap = saa_mmap, 1916 .mmap = saa_mmap,
1921}; 1917};
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 42acc92c182d..75f286f7a2e9 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1080,7 +1080,7 @@ static int stv680_newframe (struct usb_stv *stv680, int framenr)
1080 * Video4Linux 1080 * Video4Linux
1081 *********************************************************************/ 1081 *********************************************************************/
1082 1082
1083static int stv_open (struct inode *inode, struct file *file) 1083static int stv_open(struct file *file)
1084{ 1084{
1085 struct video_device *dev = video_devdata(file); 1085 struct video_device *dev = video_devdata(file);
1086 struct usb_stv *stv680 = video_get_drvdata(dev); 1086 struct usb_stv *stv680 = video_get_drvdata(dev);
@@ -1106,7 +1106,7 @@ static int stv_open (struct inode *inode, struct file *file)
1106 return err; 1106 return err;
1107} 1107}
1108 1108
1109static int stv_close (struct inode *inode, struct file *file) 1109static int stv_close(struct file *file)
1110{ 1110{
1111 struct video_device *dev = file->private_data; 1111 struct video_device *dev = file->private_data;
1112 struct usb_stv *stv680 = video_get_drvdata(dev); 1112 struct usb_stv *stv680 = video_get_drvdata(dev);
@@ -1132,7 +1132,7 @@ static int stv_close (struct inode *inode, struct file *file)
1132 return 0; 1132 return 0;
1133} 1133}
1134 1134
1135static int stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg) 1135static long stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1136{ 1136{
1137 struct video_device *vdev = file->private_data; 1137 struct video_device *vdev = file->private_data;
1138 struct usb_stv *stv680 = video_get_drvdata(vdev); 1138 struct usb_stv *stv680 = video_get_drvdata(vdev);
@@ -1299,7 +1299,7 @@ static int stv680_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1299 return 0; 1299 return 0;
1300} 1300}
1301 1301
1302static int stv680_ioctl(struct inode *inode, struct file *file, 1302static long stv680_ioctl(struct file *file,
1303 unsigned int cmd, unsigned long arg) 1303 unsigned int cmd, unsigned long arg)
1304{ 1304{
1305 return video_usercopy(file, cmd, arg, stv680_do_ioctl); 1305 return video_usercopy(file, cmd, arg, stv680_do_ioctl);
@@ -1391,17 +1391,13 @@ static ssize_t stv680_read (struct file *file, char __user *buf,
1391 return realcount; 1391 return realcount;
1392} /* stv680_read */ 1392} /* stv680_read */
1393 1393
1394static const struct file_operations stv680_fops = { 1394static const struct v4l2_file_operations stv680_fops = {
1395 .owner = THIS_MODULE, 1395 .owner = THIS_MODULE,
1396 .open = stv_open, 1396 .open = stv_open,
1397 .release = stv_close, 1397 .release = stv_close,
1398 .read = stv680_read, 1398 .read = stv680_read,
1399 .mmap = stv680_mmap, 1399 .mmap = stv680_mmap,
1400 .ioctl = stv680_ioctl, 1400 .ioctl = stv680_ioctl,
1401#ifdef CONFIG_COMPAT
1402 .compat_ioctl = v4l_compat_ioctl32,
1403#endif
1404 .llseek = no_llseek,
1405}; 1401};
1406static struct video_device stv680_template = { 1402static struct video_device stv680_template = {
1407 .name = "STV0680 USB camera", 1403 .name = "STV0680 USB camera",
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 2644e0dc9251..6afb7059502d 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -137,7 +137,7 @@ static int tda9840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *t)
137 return 0; 137 return 0;
138} 138}
139 139
140static int tda9840_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) 140static long tda9840_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg)
141{ 141{
142 int byte; 142 int byte;
143 143
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 31dde86f2df4..7519fd1f57ef 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -122,7 +122,7 @@ static int switch_matrix(struct i2c_client *client, int i, int o)
122 return ret; 122 return ret;
123} 123}
124 124
125static int tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) 125static long tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg)
126{ 126{
127 if (cmd == TEA6415C_SWITCH) { 127 if (cmd == TEA6415C_SWITCH) {
128 struct i2c_client *client = v4l2_get_subdevdata(sd); 128 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 38e519f04bde..081e74fa3b2e 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -90,7 +90,7 @@ static int tea6420_switch(struct i2c_client *client, int i, int o, int g)
90 return 0; 90 return 0;
91} 91}
92 92
93static int tea6420_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) 93static long tea6420_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg)
94{ 94{
95 if (cmd == TEA6420_SWITCH) { 95 if (cmd == TEA6420_SWITCH) {
96 struct i2c_client *client = v4l2_get_subdevdata(sd); 96 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 97d7509d212f..30640fbfd0f9 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -800,7 +800,7 @@ static int tuner_s_standby(struct v4l2_subdev *sd, u32 standby)
800} 800}
801 801
802#ifdef CONFIG_VIDEO_ALLOW_V4L1 802#ifdef CONFIG_VIDEO_ALLOW_V4L1
803static int tuner_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) 803static long tuner_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
804{ 804{
805 struct tuner *t = to_tuner(sd); 805 struct tuner *t = to_tuner(sd);
806 struct i2c_client *client = v4l2_get_subdevdata(sd); 806 struct i2c_client *client = v4l2_get_subdevdata(sd);
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index d0c794da735b..5aeccb301cea 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1762,7 +1762,7 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr
1762 return 0; 1762 return 0;
1763} 1763}
1764 1764
1765static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 1765static int tvaudio_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
1766{ 1766{
1767 struct i2c_client *client = v4l2_get_subdevdata(sd); 1767 struct i2c_client *client = v4l2_get_subdevdata(sd);
1768 1768
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index a388a9f0cb18..2cd64ef27b95 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -963,7 +963,7 @@ static int tvp5150_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
963 963
964 964
965static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, 965static int tvp5150_g_chip_ident(struct v4l2_subdev *sd,
966 struct v4l2_chip_ident *chip) 966 struct v4l2_dbg_chip_ident *chip)
967{ 967{
968 int rev; 968 int rev;
969 struct i2c_client *client = v4l2_get_subdevdata(sd); 969 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -977,25 +977,24 @@ static int tvp5150_g_chip_ident(struct v4l2_subdev *sd,
977 977
978 978
979#ifdef CONFIG_VIDEO_ADV_DEBUG 979#ifdef CONFIG_VIDEO_ADV_DEBUG
980static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 980static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
981{ 981{
982 struct i2c_client *client = v4l2_get_subdevdata(sd); 982 struct i2c_client *client = v4l2_get_subdevdata(sd);
983 983
984 if (!v4l2_chip_match_i2c_client(client, 984 if (!v4l2_chip_match_i2c_client(client, &reg->match))
985 reg->match_type, reg->match_chip))
986 return -EINVAL; 985 return -EINVAL;
987 if (!capable(CAP_SYS_ADMIN)) 986 if (!capable(CAP_SYS_ADMIN))
988 return -EPERM; 987 return -EPERM;
989 reg->val = tvp5150_read(sd, reg->reg & 0xff); 988 reg->val = tvp5150_read(sd, reg->reg & 0xff);
989 reg->size = 1;
990 return 0; 990 return 0;
991} 991}
992 992
993static int tvp5150_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 993static int tvp5150_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
994{ 994{
995 struct i2c_client *client = v4l2_get_subdevdata(sd); 995 struct i2c_client *client = v4l2_get_subdevdata(sd);
996 996
997 if (!v4l2_chip_match_i2c_client(client, 997 if (!v4l2_chip_match_i2c_client(client, &reg->match))
998 reg->match_type, reg->match_chip))
999 return -EINVAL; 998 return -EINVAL;
1000 if (!capable(CAP_SYS_ADMIN)) 999 if (!capable(CAP_SYS_ADMIN))
1001 return -EPERM; 1000 return -EPERM;
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c
index d5cdc4be1a35..52c0357faa5d 100644
--- a/drivers/media/video/tw9910.c
+++ b/drivers/media/video/tw9910.c
@@ -575,7 +575,7 @@ static unsigned long tw9910_query_bus_param(struct soc_camera_device *icd)
575} 575}
576 576
577static int tw9910_get_chip_id(struct soc_camera_device *icd, 577static int tw9910_get_chip_id(struct soc_camera_device *icd,
578 struct v4l2_chip_ident *id) 578 struct v4l2_dbg_chip_ident *id)
579{ 579{
580 id->ident = V4L2_IDENT_TW9910; 580 id->ident = V4L2_IDENT_TW9910;
581 id->revision = 0; 581 id->revision = 0;
@@ -606,7 +606,7 @@ static int tw9910_enum_input(struct soc_camera_device *icd,
606 606
607#ifdef CONFIG_VIDEO_ADV_DEBUG 607#ifdef CONFIG_VIDEO_ADV_DEBUG
608static int tw9910_get_register(struct soc_camera_device *icd, 608static int tw9910_get_register(struct soc_camera_device *icd,
609 struct v4l2_register *reg) 609 struct v4l2_dbg_register *reg)
610{ 610{
611 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); 611 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd);
612 int ret; 612 int ret;
@@ -627,7 +627,7 @@ static int tw9910_get_register(struct soc_camera_device *icd,
627} 627}
628 628
629static int tw9910_set_register(struct soc_camera_device *icd, 629static int tw9910_set_register(struct soc_camera_device *icd,
630 struct v4l2_register *reg) 630 struct v4l2_dbg_register *reg)
631{ 631{
632 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd); 632 struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd);
633 633
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index 7a609a3a6dbe..4f16effb530f 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -147,7 +147,7 @@ static int upd64031a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing
147 return upd64031a_s_frequency(sd, NULL); 147 return upd64031a_s_frequency(sd, NULL);
148} 148}
149 149
150static int upd64031a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 150static int upd64031a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
151{ 151{
152 struct i2c_client *client = v4l2_get_subdevdata(sd); 152 struct i2c_client *client = v4l2_get_subdevdata(sd);
153 153
@@ -162,25 +162,24 @@ static int upd64031a_log_status(struct v4l2_subdev *sd)
162} 162}
163 163
164#ifdef CONFIG_VIDEO_ADV_DEBUG 164#ifdef CONFIG_VIDEO_ADV_DEBUG
165static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 165static int upd64031a_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
166{ 166{
167 struct i2c_client *client = v4l2_get_subdevdata(sd); 167 struct i2c_client *client = v4l2_get_subdevdata(sd);
168 168
169 if (!v4l2_chip_match_i2c_client(client, 169 if (!v4l2_chip_match_i2c_client(client, &reg->match))
170 reg->match_type, reg->match_chip))
171 return -EINVAL; 170 return -EINVAL;
172 if (!capable(CAP_SYS_ADMIN)) 171 if (!capable(CAP_SYS_ADMIN))
173 return -EPERM; 172 return -EPERM;
174 reg->val = upd64031a_read(sd, reg->reg & 0xff); 173 reg->val = upd64031a_read(sd, reg->reg & 0xff);
174 reg->size = 1;
175 return 0; 175 return 0;
176} 176}
177 177
178static int upd64031a_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 178static int upd64031a_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
179{ 179{
180 struct i2c_client *client = v4l2_get_subdevdata(sd); 180 struct i2c_client *client = v4l2_get_subdevdata(sd);
181 181
182 if (!v4l2_chip_match_i2c_client(client, 182 if (!v4l2_chip_match_i2c_client(client, &reg->match))
183 reg->match_type, reg->match_chip))
184 return -EINVAL; 183 return -EINVAL;
185 if (!capable(CAP_SYS_ADMIN)) 184 if (!capable(CAP_SYS_ADMIN))
186 return -EPERM; 185 return -EPERM;
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 58412cb9c01a..4b712f69d1b7 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -120,25 +120,24 @@ static int upd64083_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing
120} 120}
121 121
122#ifdef CONFIG_VIDEO_ADV_DEBUG 122#ifdef CONFIG_VIDEO_ADV_DEBUG
123static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 123static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
124{ 124{
125 struct i2c_client *client = v4l2_get_subdevdata(sd); 125 struct i2c_client *client = v4l2_get_subdevdata(sd);
126 126
127 if (!v4l2_chip_match_i2c_client(client, 127 if (!v4l2_chip_match_i2c_client(client, &reg->match))
128 reg->match_type, reg->match_chip))
129 return -EINVAL; 128 return -EINVAL;
130 if (!capable(CAP_SYS_ADMIN)) 129 if (!capable(CAP_SYS_ADMIN))
131 return -EPERM; 130 return -EPERM;
132 reg->val = upd64083_read(sd, reg->reg & 0xff); 131 reg->val = upd64083_read(sd, reg->reg & 0xff);
132 reg->size = 1;
133 return 0; 133 return 0;
134} 134}
135 135
136static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg) 136static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
137{ 137{
138 struct i2c_client *client = v4l2_get_subdevdata(sd); 138 struct i2c_client *client = v4l2_get_subdevdata(sd);
139 139
140 if (!v4l2_chip_match_i2c_client(client, 140 if (!v4l2_chip_match_i2c_client(client, &reg->match))
141 reg->match_type, reg->match_chip))
142 return -EINVAL; 141 return -EINVAL;
143 if (!capable(CAP_SYS_ADMIN)) 142 if (!capable(CAP_SYS_ADMIN))
144 return -EPERM; 143 return -EPERM;
@@ -147,7 +146,7 @@ static int upd64083_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg
147} 146}
148#endif 147#endif
149 148
150static int upd64083_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 149static int upd64083_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
151{ 150{
152 struct i2c_client *client = v4l2_get_subdevdata(sd); 151 struct i2c_client *client = v4l2_get_subdevdata(sd);
153 152
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 148a1f98c70f..dea8b321fb4a 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -41,13 +41,13 @@ module_param(video_nr, int, 0);
41static void usbvideo_Disconnect(struct usb_interface *intf); 41static void usbvideo_Disconnect(struct usb_interface *intf);
42static void usbvideo_CameraRelease(struct uvd *uvd); 42static void usbvideo_CameraRelease(struct uvd *uvd);
43 43
44static int usbvideo_v4l_ioctl(struct inode *inode, struct file *file, 44static long usbvideo_v4l_ioctl(struct file *file,
45 unsigned int cmd, unsigned long arg); 45 unsigned int cmd, unsigned long arg);
46static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma); 46static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma);
47static int usbvideo_v4l_open(struct inode *inode, struct file *file); 47static int usbvideo_v4l_open(struct file *file);
48static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, 48static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf,
49 size_t count, loff_t *ppos); 49 size_t count, loff_t *ppos);
50static int usbvideo_v4l_close(struct inode *inode, struct file *file); 50static int usbvideo_v4l_close(struct file *file);
51 51
52static int usbvideo_StartDataPump(struct uvd *uvd); 52static int usbvideo_StartDataPump(struct uvd *uvd);
53static void usbvideo_StopDataPump(struct uvd *uvd); 53static void usbvideo_StopDataPump(struct uvd *uvd);
@@ -942,17 +942,13 @@ static int usbvideo_find_struct(struct usbvideo *cams)
942 return rv; 942 return rv;
943} 943}
944 944
945static const struct file_operations usbvideo_fops = { 945static const struct v4l2_file_operations usbvideo_fops = {
946 .owner = THIS_MODULE, 946 .owner = THIS_MODULE,
947 .open = usbvideo_v4l_open, 947 .open = usbvideo_v4l_open,
948 .release =usbvideo_v4l_close, 948 .release =usbvideo_v4l_close,
949 .read = usbvideo_v4l_read, 949 .read = usbvideo_v4l_read,
950 .mmap = usbvideo_v4l_mmap, 950 .mmap = usbvideo_v4l_mmap,
951 .ioctl = usbvideo_v4l_ioctl, 951 .ioctl = usbvideo_v4l_ioctl,
952#ifdef CONFIG_COMPAT
953 .compat_ioctl = v4l_compat_ioctl32,
954#endif
955 .llseek = no_llseek,
956}; 952};
957static const struct video_device usbvideo_template = { 953static const struct video_device usbvideo_template = {
958 .fops = &usbvideo_fops, 954 .fops = &usbvideo_fops,
@@ -1113,7 +1109,7 @@ static int usbvideo_v4l_mmap(struct file *file, struct vm_area_struct *vma)
1113 * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. 1109 * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers.
1114 * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT). 1110 * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT).
1115 */ 1111 */
1116static int usbvideo_v4l_open(struct inode *inode, struct file *file) 1112static int usbvideo_v4l_open(struct file *file)
1117{ 1113{
1118 struct video_device *dev = video_devdata(file); 1114 struct video_device *dev = video_devdata(file);
1119 struct uvd *uvd = (struct uvd *) dev; 1115 struct uvd *uvd = (struct uvd *) dev;
@@ -1233,7 +1229,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file)
1233 * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers. 1229 * 27-Jan-2000 Used USBVIDEO_NUMSBUF as number of URB buffers.
1234 * 24-May-2000 Moved MOD_DEC_USE_COUNT outside of code that can sleep. 1230 * 24-May-2000 Moved MOD_DEC_USE_COUNT outside of code that can sleep.
1235 */ 1231 */
1236static int usbvideo_v4l_close(struct inode *inode, struct file *file) 1232static int usbvideo_v4l_close(struct file *file)
1237{ 1233{
1238 struct video_device *dev = file->private_data; 1234 struct video_device *dev = file->private_data;
1239 struct uvd *uvd = (struct uvd *) dev; 1235 struct uvd *uvd = (struct uvd *) dev;
@@ -1281,7 +1277,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file)
1281 * History: 1277 * History:
1282 * 22-Jan-2000 Corrected VIDIOCSPICT to reject unsupported settings. 1278 * 22-Jan-2000 Corrected VIDIOCSPICT to reject unsupported settings.
1283 */ 1279 */
1284static int usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) 1280static long usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1285{ 1281{
1286 struct uvd *uvd = file->private_data; 1282 struct uvd *uvd = file->private_data;
1287 1283
@@ -1501,7 +1497,7 @@ static int usbvideo_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1501 return 0; 1497 return 0;
1502} 1498}
1503 1499
1504static int usbvideo_v4l_ioctl(struct inode *inode, struct file *file, 1500static long usbvideo_v4l_ioctl(struct file *file,
1505 unsigned int cmd, unsigned long arg) 1501 unsigned int cmd, unsigned long arg)
1506{ 1502{
1507 return video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl); 1503 return video_usercopy(file, cmd, arg, usbvideo_v4l_do_ioctl);
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 4602597ed8d1..2f1106338c08 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -229,12 +229,12 @@ set_camera_power(struct vicam_camera *cam, int state)
229 return 0; 229 return 0;
230} 230}
231 231
232static int 232static long
233vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsigned long arg) 233vicam_ioctl(struct file *file, unsigned int ioctlnr, unsigned long arg)
234{ 234{
235 void __user *user_arg = (void __user *)arg; 235 void __user *user_arg = (void __user *)arg;
236 struct vicam_camera *cam = file->private_data; 236 struct vicam_camera *cam = file->private_data;
237 int retval = 0; 237 long retval = 0;
238 238
239 if (!cam) 239 if (!cam)
240 return -ENODEV; 240 return -ENODEV;
@@ -470,7 +470,7 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
470} 470}
471 471
472static int 472static int
473vicam_open(struct inode *inode, struct file *file) 473vicam_open(struct file *file)
474{ 474{
475 struct vicam_camera *cam = video_drvdata(file); 475 struct vicam_camera *cam = video_drvdata(file);
476 476
@@ -536,7 +536,7 @@ vicam_open(struct inode *inode, struct file *file)
536} 536}
537 537
538static int 538static int
539vicam_close(struct inode *inode, struct file *file) 539vicam_close(struct file *file)
540{ 540{
541 struct vicam_camera *cam = file->private_data; 541 struct vicam_camera *cam = file->private_data;
542 int open_count; 542 int open_count;
@@ -783,17 +783,13 @@ vicam_mmap(struct file *file, struct vm_area_struct *vma)
783 return 0; 783 return 0;
784} 784}
785 785
786static const struct file_operations vicam_fops = { 786static const struct v4l2_file_operations vicam_fops = {
787 .owner = THIS_MODULE, 787 .owner = THIS_MODULE,
788 .open = vicam_open, 788 .open = vicam_open,
789 .release = vicam_close, 789 .release = vicam_close,
790 .read = vicam_read, 790 .read = vicam_read,
791 .mmap = vicam_mmap, 791 .mmap = vicam_mmap,
792 .ioctl = vicam_ioctl, 792 .ioctl = vicam_ioctl,
793#ifdef CONFIG_COMPAT
794 .compat_ioctl = v4l_compat_ioctl32,
795#endif
796 .llseek = no_llseek,
797}; 793};
798 794
799static struct video_device vicam_template = { 795static struct video_device vicam_template = {
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 85661b1848fe..2be5e47ed081 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -355,7 +355,7 @@ static void usbvision_remove_sysfs(struct video_device *vdev)
355 * then allocates buffers needed for video processing. 355 * then allocates buffers needed for video processing.
356 * 356 *
357 */ 357 */
358static int usbvision_v4l2_open(struct inode *inode, struct file *file) 358static int usbvision_v4l2_open(struct file *file)
359{ 359{
360 struct usb_usbvision *usbvision = video_drvdata(file); 360 struct usb_usbvision *usbvision = video_drvdata(file);
361 int errCode = 0; 361 int errCode = 0;
@@ -432,7 +432,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
432 * allocated in usbvision_v4l2_open(). 432 * allocated in usbvision_v4l2_open().
433 * 433 *
434 */ 434 */
435static int usbvision_v4l2_close(struct inode *inode, struct file *file) 435static int usbvision_v4l2_close(struct file *file)
436{ 436{
437 struct usb_usbvision *usbvision = video_drvdata(file); 437 struct usb_usbvision *usbvision = video_drvdata(file);
438 438
@@ -477,12 +477,12 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
477 */ 477 */
478#ifdef CONFIG_VIDEO_ADV_DEBUG 478#ifdef CONFIG_VIDEO_ADV_DEBUG
479static int vidioc_g_register (struct file *file, void *priv, 479static int vidioc_g_register (struct file *file, void *priv,
480 struct v4l2_register *reg) 480 struct v4l2_dbg_register *reg)
481{ 481{
482 struct usb_usbvision *usbvision = video_drvdata(file); 482 struct usb_usbvision *usbvision = video_drvdata(file);
483 int errCode; 483 int errCode;
484 484
485 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 485 if (!v4l2_chip_match_host(&reg->match))
486 return -EINVAL; 486 return -EINVAL;
487 /* NT100x has a 8-bit register space */ 487 /* NT100x has a 8-bit register space */
488 errCode = usbvision_read_reg(usbvision, reg->reg&0xff); 488 errCode = usbvision_read_reg(usbvision, reg->reg&0xff);
@@ -492,16 +492,17 @@ static int vidioc_g_register (struct file *file, void *priv,
492 return errCode; 492 return errCode;
493 } 493 }
494 reg->val = errCode; 494 reg->val = errCode;
495 reg->size = 1;
495 return 0; 496 return 0;
496} 497}
497 498
498static int vidioc_s_register (struct file *file, void *priv, 499static int vidioc_s_register (struct file *file, void *priv,
499 struct v4l2_register *reg) 500 struct v4l2_dbg_register *reg)
500{ 501{
501 struct usb_usbvision *usbvision = video_drvdata(file); 502 struct usb_usbvision *usbvision = video_drvdata(file);
502 int errCode; 503 int errCode;
503 504
504 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 505 if (!v4l2_chip_match_host(&reg->match))
505 return -EINVAL; 506 return -EINVAL;
506 /* NT100x has a 8-bit register space */ 507 /* NT100x has a 8-bit register space */
507 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); 508 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val);
@@ -1178,7 +1179,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1178 * Here comes the stuff for radio on usbvision based devices 1179 * Here comes the stuff for radio on usbvision based devices
1179 * 1180 *
1180 */ 1181 */
1181static int usbvision_radio_open(struct inode *inode, struct file *file) 1182static int usbvision_radio_open(struct file *file)
1182{ 1183{
1183 struct usb_usbvision *usbvision = video_drvdata(file); 1184 struct usb_usbvision *usbvision = video_drvdata(file);
1184 int errCode = 0; 1185 int errCode = 0;
@@ -1228,7 +1229,7 @@ out:
1228} 1229}
1229 1230
1230 1231
1231static int usbvision_radio_close(struct inode *inode, struct file *file) 1232static int usbvision_radio_close(struct file *file)
1232{ 1233{
1233 struct usb_usbvision *usbvision = video_drvdata(file); 1234 struct usb_usbvision *usbvision = video_drvdata(file);
1234 int errCode = 0; 1235 int errCode = 0;
@@ -1266,26 +1267,26 @@ static int usbvision_radio_close(struct inode *inode, struct file *file)
1266 * Here comes the stuff for vbi on usbvision based devices 1267 * Here comes the stuff for vbi on usbvision based devices
1267 * 1268 *
1268 */ 1269 */
1269static int usbvision_vbi_open(struct inode *inode, struct file *file) 1270static int usbvision_vbi_open(struct file *file)
1270{ 1271{
1271 /* TODO */ 1272 /* TODO */
1272 return -ENODEV; 1273 return -ENODEV;
1273} 1274}
1274 1275
1275static int usbvision_vbi_close(struct inode *inode, struct file *file) 1276static int usbvision_vbi_close(struct file *file)
1276{ 1277{
1277 /* TODO */ 1278 /* TODO */
1278 return -ENODEV; 1279 return -ENODEV;
1279} 1280}
1280 1281
1281static int usbvision_do_vbi_ioctl(struct file *file, 1282static long usbvision_do_vbi_ioctl(struct file *file,
1282 unsigned int cmd, void *arg) 1283 unsigned int cmd, void *arg)
1283{ 1284{
1284 /* TODO */ 1285 /* TODO */
1285 return -ENOIOCTLCMD; 1286 return -ENOIOCTLCMD;
1286} 1287}
1287 1288
1288static int usbvision_vbi_ioctl(struct inode *inode, struct file *file, 1289static long usbvision_vbi_ioctl(struct file *file,
1289 unsigned int cmd, unsigned long arg) 1290 unsigned int cmd, unsigned long arg)
1290{ 1291{
1291 return video_usercopy(file, cmd, arg, usbvision_do_vbi_ioctl); 1292 return video_usercopy(file, cmd, arg, usbvision_do_vbi_ioctl);
@@ -1297,16 +1298,14 @@ static int usbvision_vbi_ioctl(struct inode *inode, struct file *file,
1297// 1298//
1298 1299
1299// Video template 1300// Video template
1300static const struct file_operations usbvision_fops = { 1301static const struct v4l2_file_operations usbvision_fops = {
1301 .owner = THIS_MODULE, 1302 .owner = THIS_MODULE,
1302 .open = usbvision_v4l2_open, 1303 .open = usbvision_v4l2_open,
1303 .release = usbvision_v4l2_close, 1304 .release = usbvision_v4l2_close,
1304 .read = usbvision_v4l2_read, 1305 .read = usbvision_v4l2_read,
1305 .mmap = usbvision_v4l2_mmap, 1306 .mmap = usbvision_v4l2_mmap,
1306 .ioctl = video_ioctl2, 1307 .ioctl = video_ioctl2,
1307 .llseek = no_llseek,
1308/* .poll = video_poll, */ 1308/* .poll = video_poll, */
1309 .compat_ioctl = v4l_compat_ioctl32,
1310}; 1309};
1311 1310
1312static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { 1311static const struct v4l2_ioctl_ops usbvision_ioctl_ops = {
@@ -1355,13 +1354,11 @@ static struct video_device usbvision_video_template = {
1355 1354
1356 1355
1357// Radio template 1356// Radio template
1358static const struct file_operations usbvision_radio_fops = { 1357static const struct v4l2_file_operations usbvision_radio_fops = {
1359 .owner = THIS_MODULE, 1358 .owner = THIS_MODULE,
1360 .open = usbvision_radio_open, 1359 .open = usbvision_radio_open,
1361 .release = usbvision_radio_close, 1360 .release = usbvision_radio_close,
1362 .ioctl = video_ioctl2, 1361 .ioctl = video_ioctl2,
1363 .llseek = no_llseek,
1364 .compat_ioctl = v4l_compat_ioctl32,
1365}; 1362};
1366 1363
1367static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { 1364static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = {
@@ -1392,13 +1389,11 @@ static struct video_device usbvision_radio_template = {
1392}; 1389};
1393 1390
1394// vbi template 1391// vbi template
1395static const struct file_operations usbvision_vbi_fops = { 1392static const struct v4l2_file_operations usbvision_vbi_fops = {
1396 .owner = THIS_MODULE, 1393 .owner = THIS_MODULE,
1397 .open = usbvision_vbi_open, 1394 .open = usbvision_vbi_open,
1398 .release = usbvision_vbi_close, 1395 .release = usbvision_vbi_close,
1399 .ioctl = usbvision_vbi_ioctl, 1396 .ioctl = usbvision_vbi_ioctl,
1400 .llseek = no_llseek,
1401 .compat_ioctl = v4l_compat_ioctl32,
1402}; 1397};
1403 1398
1404static struct video_device usbvision_vbi_template= 1399static struct video_device usbvision_vbi_template=
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index afcc6934559e..fa150fff2c10 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -406,7 +406,7 @@ static int uvc_has_privileges(struct uvc_fh *handle)
406 * V4L2 file operations 406 * V4L2 file operations
407 */ 407 */
408 408
409static int uvc_v4l2_open(struct inode *inode, struct file *file) 409static int uvc_v4l2_open(struct file *file)
410{ 410{
411 struct uvc_video_device *video; 411 struct uvc_video_device *video;
412 struct uvc_fh *handle; 412 struct uvc_fh *handle;
@@ -444,7 +444,7 @@ done:
444 return ret; 444 return ret;
445} 445}
446 446
447static int uvc_v4l2_release(struct inode *inode, struct file *file) 447static int uvc_v4l2_release(struct file *file)
448{ 448{
449 struct uvc_video_device *video = video_drvdata(file); 449 struct uvc_video_device *video = video_drvdata(file);
450 struct uvc_fh *handle = (struct uvc_fh *)file->private_data; 450 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
@@ -472,12 +472,12 @@ static int uvc_v4l2_release(struct inode *inode, struct file *file)
472 return 0; 472 return 0;
473} 473}
474 474
475static int uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) 475static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
476{ 476{
477 struct video_device *vdev = video_devdata(file); 477 struct video_device *vdev = video_devdata(file);
478 struct uvc_video_device *video = video_get_drvdata(vdev); 478 struct uvc_video_device *video = video_get_drvdata(vdev);
479 struct uvc_fh *handle = (struct uvc_fh *)file->private_data; 479 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
480 int ret = 0; 480 long ret = 0;
481 481
482 switch (cmd) { 482 switch (cmd) {
483 /* Query capabilities */ 483 /* Query capabilities */
@@ -996,7 +996,7 @@ static int uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
996 return ret; 996 return ret;
997} 997}
998 998
999static int uvc_v4l2_ioctl(struct inode *inode, struct file *file, 999static long uvc_v4l2_ioctl(struct file *file,
1000 unsigned int cmd, unsigned long arg) 1000 unsigned int cmd, unsigned long arg)
1001{ 1001{
1002 if (uvc_trace_param & UVC_TRACE_IOCTL) { 1002 if (uvc_trace_param & UVC_TRACE_IOCTL) {
@@ -1097,13 +1097,11 @@ static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)
1097 return uvc_queue_poll(&video->queue, file, wait); 1097 return uvc_queue_poll(&video->queue, file, wait);
1098} 1098}
1099 1099
1100struct file_operations uvc_fops = { 1100const struct v4l2_file_operations uvc_fops = {
1101 .owner = THIS_MODULE, 1101 .owner = THIS_MODULE,
1102 .open = uvc_v4l2_open, 1102 .open = uvc_v4l2_open,
1103 .release = uvc_v4l2_release, 1103 .release = uvc_v4l2_release,
1104 .ioctl = uvc_v4l2_ioctl, 1104 .ioctl = uvc_v4l2_ioctl,
1105 .compat_ioctl = v4l_compat_ioctl32,
1106 .llseek = no_llseek,
1107 .read = uvc_v4l2_read, 1105 .read = uvc_v4l2_read,
1108 .mmap = uvc_v4l2_mmap, 1106 .mmap = uvc_v4l2_mmap,
1109 .poll = uvc_v4l2_poll, 1107 .poll = uvc_v4l2_poll,
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index 896b791ece15..bcf4361dc1bc 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -753,7 +753,7 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
753} 753}
754 754
755/* V4L2 interface */ 755/* V4L2 interface */
756extern struct file_operations uvc_fops; 756extern const struct v4l2_file_operations uvc_fops;
757 757
758/* Video */ 758/* Video */
759extern int uvc_video_init(struct uvc_video_device *video); 759extern int uvc_video_init(struct uvc_video_device *video);
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index f13c0a9d684f..d450cab20be4 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -267,12 +267,12 @@ done:
267 267
268/* ----------------------------------------------------------------- */ 268/* ----------------------------------------------------------------- */
269 269
270static noinline int v4l1_compat_get_capabilities( 270static noinline long v4l1_compat_get_capabilities(
271 struct video_capability *cap, 271 struct video_capability *cap,
272 struct file *file, 272 struct file *file,
273 v4l2_kioctl drv) 273 v4l2_kioctl drv)
274{ 274{
275 int err; 275 long err;
276 struct v4l2_framebuffer fbuf; 276 struct v4l2_framebuffer fbuf;
277 struct v4l2_capability *cap2; 277 struct v4l2_capability *cap2;
278 278
@@ -286,13 +286,13 @@ static noinline int v4l1_compat_get_capabilities(
286 286
287 err = drv(file, VIDIOC_QUERYCAP, cap2); 287 err = drv(file, VIDIOC_QUERYCAP, cap2);
288 if (err < 0) { 288 if (err < 0) {
289 dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err); 289 dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %ld\n", err);
290 goto done; 290 goto done;
291 } 291 }
292 if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { 292 if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) {
293 err = drv(file, VIDIOC_G_FBUF, &fbuf); 293 err = drv(file, VIDIOC_G_FBUF, &fbuf);
294 if (err < 0) { 294 if (err < 0) {
295 dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err); 295 dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %ld\n", err);
296 memset(&fbuf, 0, sizeof(fbuf)); 296 memset(&fbuf, 0, sizeof(fbuf));
297 } 297 }
298 err = 0; 298 err = 0;
@@ -324,12 +324,12 @@ done:
324 return err; 324 return err;
325} 325}
326 326
327static noinline int v4l1_compat_get_frame_buffer( 327static noinline long v4l1_compat_get_frame_buffer(
328 struct video_buffer *buffer, 328 struct video_buffer *buffer,
329 struct file *file, 329 struct file *file,
330 v4l2_kioctl drv) 330 v4l2_kioctl drv)
331{ 331{
332 int err; 332 long err;
333 struct v4l2_framebuffer fbuf; 333 struct v4l2_framebuffer fbuf;
334 334
335 memset(buffer, 0, sizeof(*buffer)); 335 memset(buffer, 0, sizeof(*buffer));
@@ -337,7 +337,7 @@ static noinline int v4l1_compat_get_frame_buffer(
337 337
338 err = drv(file, VIDIOC_G_FBUF, &fbuf); 338 err = drv(file, VIDIOC_G_FBUF, &fbuf);
339 if (err < 0) { 339 if (err < 0) {
340 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); 340 dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %ld\n", err);
341 goto done; 341 goto done;
342 } 342 }
343 buffer->base = fbuf.base; 343 buffer->base = fbuf.base;
@@ -378,12 +378,12 @@ done:
378 return err; 378 return err;
379} 379}
380 380
381static noinline int v4l1_compat_set_frame_buffer( 381static noinline long v4l1_compat_set_frame_buffer(
382 struct video_buffer *buffer, 382 struct video_buffer *buffer,
383 struct file *file, 383 struct file *file,
384 v4l2_kioctl drv) 384 v4l2_kioctl drv)
385{ 385{
386 int err; 386 long err;
387 struct v4l2_framebuffer fbuf; 387 struct v4l2_framebuffer fbuf;
388 388
389 memset(&fbuf, 0, sizeof(fbuf)); 389 memset(&fbuf, 0, sizeof(fbuf));
@@ -410,16 +410,16 @@ static noinline int v4l1_compat_set_frame_buffer(
410 fbuf.fmt.bytesperline = buffer->bytesperline; 410 fbuf.fmt.bytesperline = buffer->bytesperline;
411 err = drv(file, VIDIOC_S_FBUF, &fbuf); 411 err = drv(file, VIDIOC_S_FBUF, &fbuf);
412 if (err < 0) 412 if (err < 0)
413 dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err); 413 dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %ld\n", err);
414 return err; 414 return err;
415} 415}
416 416
417static noinline int v4l1_compat_get_win_cap_dimensions( 417static noinline long v4l1_compat_get_win_cap_dimensions(
418 struct video_window *win, 418 struct video_window *win,
419 struct file *file, 419 struct file *file,
420 v4l2_kioctl drv) 420 v4l2_kioctl drv)
421{ 421{
422 int err; 422 long err;
423 struct v4l2_format *fmt; 423 struct v4l2_format *fmt;
424 424
425 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 425 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
@@ -432,7 +432,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions(
432 fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 432 fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
433 err = drv(file, VIDIOC_G_FMT, fmt); 433 err = drv(file, VIDIOC_G_FMT, fmt);
434 if (err < 0) 434 if (err < 0)
435 dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err); 435 dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %ld\n", err);
436 if (err == 0) { 436 if (err == 0) {
437 win->x = fmt->fmt.win.w.left; 437 win->x = fmt->fmt.win.w.left;
438 win->y = fmt->fmt.win.w.top; 438 win->y = fmt->fmt.win.w.top;
@@ -447,7 +447,7 @@ static noinline int v4l1_compat_get_win_cap_dimensions(
447 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 447 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
448 err = drv(file, VIDIOC_G_FMT, fmt); 448 err = drv(file, VIDIOC_G_FMT, fmt);
449 if (err < 0) { 449 if (err < 0) {
450 dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err); 450 dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %ld\n", err);
451 goto done; 451 goto done;
452 } 452 }
453 win->x = 0; 453 win->x = 0;
@@ -462,12 +462,12 @@ done:
462 return err; 462 return err;
463} 463}
464 464
465static noinline int v4l1_compat_set_win_cap_dimensions( 465static noinline long v4l1_compat_set_win_cap_dimensions(
466 struct video_window *win, 466 struct video_window *win,
467 struct file *file, 467 struct file *file,
468 v4l2_kioctl drv) 468 v4l2_kioctl drv)
469{ 469{
470 int err, err1, err2; 470 long err, err1, err2;
471 struct v4l2_format *fmt; 471 struct v4l2_format *fmt;
472 472
473 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 473 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
@@ -479,7 +479,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
479 drv(file, VIDIOC_STREAMOFF, &fmt->type); 479 drv(file, VIDIOC_STREAMOFF, &fmt->type);
480 err1 = drv(file, VIDIOC_G_FMT, fmt); 480 err1 = drv(file, VIDIOC_G_FMT, fmt);
481 if (err1 < 0) 481 if (err1 < 0)
482 dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1); 482 dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %ld\n", err1);
483 if (err1 == 0) { 483 if (err1 == 0) {
484 fmt->fmt.pix.width = win->width; 484 fmt->fmt.pix.width = win->width;
485 fmt->fmt.pix.height = win->height; 485 fmt->fmt.pix.height = win->height;
@@ -487,7 +487,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
487 fmt->fmt.pix.bytesperline = 0; 487 fmt->fmt.pix.bytesperline = 0;
488 err = drv(file, VIDIOC_S_FMT, fmt); 488 err = drv(file, VIDIOC_S_FMT, fmt);
489 if (err < 0) 489 if (err < 0)
490 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", 490 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %ld\n",
491 err); 491 err);
492 win->width = fmt->fmt.pix.width; 492 win->width = fmt->fmt.pix.width;
493 win->height = fmt->fmt.pix.height; 493 win->height = fmt->fmt.pix.height;
@@ -504,7 +504,7 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
504 fmt->fmt.win.clipcount = win->clipcount; 504 fmt->fmt.win.clipcount = win->clipcount;
505 err2 = drv(file, VIDIOC_S_FMT, fmt); 505 err2 = drv(file, VIDIOC_S_FMT, fmt);
506 if (err2 < 0) 506 if (err2 < 0)
507 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2); 507 dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %ld\n", err2);
508 508
509 if (err1 != 0 && err2 != 0) 509 if (err1 != 0 && err2 != 0)
510 err = err1; 510 err = err1;
@@ -514,12 +514,12 @@ static noinline int v4l1_compat_set_win_cap_dimensions(
514 return err; 514 return err;
515} 515}
516 516
517static noinline int v4l1_compat_turn_preview_on_off( 517static noinline long v4l1_compat_turn_preview_on_off(
518 int *on, 518 int *on,
519 struct file *file, 519 struct file *file,
520 v4l2_kioctl drv) 520 v4l2_kioctl drv)
521{ 521{
522 int err; 522 long err;
523 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 523 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
524 524
525 if (0 == *on) { 525 if (0 == *on) {
@@ -530,16 +530,16 @@ static noinline int v4l1_compat_turn_preview_on_off(
530 } 530 }
531 err = drv(file, VIDIOC_OVERLAY, on); 531 err = drv(file, VIDIOC_OVERLAY, on);
532 if (err < 0) 532 if (err < 0)
533 dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err); 533 dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %ld\n", err);
534 return err; 534 return err;
535} 535}
536 536
537static noinline int v4l1_compat_get_input_info( 537static noinline long v4l1_compat_get_input_info(
538 struct video_channel *chan, 538 struct video_channel *chan,
539 struct file *file, 539 struct file *file,
540 v4l2_kioctl drv) 540 v4l2_kioctl drv)
541{ 541{
542 int err; 542 long err;
543 struct v4l2_input input2; 543 struct v4l2_input input2;
544 v4l2_std_id sid; 544 v4l2_std_id sid;
545 545
@@ -548,7 +548,7 @@ static noinline int v4l1_compat_get_input_info(
548 err = drv(file, VIDIOC_ENUMINPUT, &input2); 548 err = drv(file, VIDIOC_ENUMINPUT, &input2);
549 if (err < 0) { 549 if (err < 0) {
550 dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " 550 dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: "
551 "channel=%d err=%d\n", chan->channel, err); 551 "channel=%d err=%ld\n", chan->channel, err);
552 goto done; 552 goto done;
553 } 553 }
554 chan->channel = input2.index; 554 chan->channel = input2.index;
@@ -569,7 +569,7 @@ static noinline int v4l1_compat_get_input_info(
569 chan->norm = 0; 569 chan->norm = 0;
570 err = drv(file, VIDIOC_G_STD, &sid); 570 err = drv(file, VIDIOC_G_STD, &sid);
571 if (err < 0) 571 if (err < 0)
572 dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n", err); 572 dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %ld\n", err);
573 if (err == 0) { 573 if (err == 0) {
574 if (sid & V4L2_STD_PAL) 574 if (sid & V4L2_STD_PAL)
575 chan->norm = VIDEO_MODE_PAL; 575 chan->norm = VIDEO_MODE_PAL;
@@ -582,17 +582,17 @@ done:
582 return err; 582 return err;
583} 583}
584 584
585static noinline int v4l1_compat_set_input( 585static noinline long v4l1_compat_set_input(
586 struct video_channel *chan, 586 struct video_channel *chan,
587 struct file *file, 587 struct file *file,
588 v4l2_kioctl drv) 588 v4l2_kioctl drv)
589{ 589{
590 int err; 590 long err;
591 v4l2_std_id sid = 0; 591 v4l2_std_id sid = 0;
592 592
593 err = drv(file, VIDIOC_S_INPUT, &chan->channel); 593 err = drv(file, VIDIOC_S_INPUT, &chan->channel);
594 if (err < 0) 594 if (err < 0)
595 dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err); 595 dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %ld\n", err);
596 switch (chan->norm) { 596 switch (chan->norm) {
597 case VIDEO_MODE_PAL: 597 case VIDEO_MODE_PAL:
598 sid = V4L2_STD_PAL; 598 sid = V4L2_STD_PAL;
@@ -607,17 +607,17 @@ static noinline int v4l1_compat_set_input(
607 if (0 != sid) { 607 if (0 != sid) {
608 err = drv(file, VIDIOC_S_STD, &sid); 608 err = drv(file, VIDIOC_S_STD, &sid);
609 if (err < 0) 609 if (err < 0)
610 dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err); 610 dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %ld\n", err);
611 } 611 }
612 return err; 612 return err;
613} 613}
614 614
615static noinline int v4l1_compat_get_picture( 615static noinline long v4l1_compat_get_picture(
616 struct video_picture *pict, 616 struct video_picture *pict,
617 struct file *file, 617 struct file *file,
618 v4l2_kioctl drv) 618 v4l2_kioctl drv)
619{ 619{
620 int err; 620 long err;
621 struct v4l2_format *fmt; 621 struct v4l2_format *fmt;
622 622
623 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); 623 fmt = kzalloc(sizeof(*fmt), GFP_KERNEL);
@@ -640,7 +640,7 @@ static noinline int v4l1_compat_get_picture(
640 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 640 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
641 err = drv(file, VIDIOC_G_FMT, fmt); 641 err = drv(file, VIDIOC_G_FMT, fmt);
642 if (err < 0) { 642 if (err < 0) {
643 dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err); 643 dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %ld\n", err);
644 goto done; 644 goto done;
645 } 645 }
646 646
@@ -654,12 +654,12 @@ done:
654 return err; 654 return err;
655} 655}
656 656
657static noinline int v4l1_compat_set_picture( 657static noinline long v4l1_compat_set_picture(
658 struct video_picture *pict, 658 struct video_picture *pict,
659 struct file *file, 659 struct file *file,
660 v4l2_kioctl drv) 660 v4l2_kioctl drv)
661{ 661{
662 int err; 662 long err;
663 struct v4l2_framebuffer fbuf; 663 struct v4l2_framebuffer fbuf;
664 int mem_err = 0, ovl_err = 0; 664 int mem_err = 0, ovl_err = 0;
665 struct v4l2_format *fmt; 665 struct v4l2_format *fmt;
@@ -694,7 +694,7 @@ static noinline int v4l1_compat_set_picture(
694 support memory capture. Trying to set the memory capture 694 support memory capture. Trying to set the memory capture
695 parameters would be pointless. */ 695 parameters would be pointless. */
696 if (err < 0) { 696 if (err < 0) {
697 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n", err); 697 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %ld\n", err);
698 mem_err = -1000; /* didn't even try */ 698 mem_err = -1000; /* didn't even try */
699 } else if (fmt->fmt.pix.pixelformat != 699 } else if (fmt->fmt.pix.pixelformat !=
700 palette_to_pixelformat(pict->palette)) { 700 palette_to_pixelformat(pict->palette)) {
@@ -711,7 +711,7 @@ static noinline int v4l1_compat_set_picture(
711 support overlay. Trying to set the overlay parameters 711 support overlay. Trying to set the overlay parameters
712 would be quite pointless. */ 712 would be quite pointless. */
713 if (err < 0) { 713 if (err < 0) {
714 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n", err); 714 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %ld\n", err);
715 ovl_err = -1000; /* didn't even try */ 715 ovl_err = -1000; /* didn't even try */
716 } else if (fbuf.fmt.pixelformat != 716 } else if (fbuf.fmt.pixelformat !=
717 palette_to_pixelformat(pict->palette)) { 717 palette_to_pixelformat(pict->palette)) {
@@ -736,12 +736,13 @@ static noinline int v4l1_compat_set_picture(
736 return err; 736 return err;
737} 737}
738 738
739static noinline int v4l1_compat_get_tuner( 739static noinline long v4l1_compat_get_tuner(
740 struct video_tuner *tun, 740 struct video_tuner *tun,
741 struct file *file, 741 struct file *file,
742 v4l2_kioctl drv) 742 v4l2_kioctl drv)
743{ 743{
744 int err, i; 744 long err;
745 int i;
745 struct v4l2_tuner tun2; 746 struct v4l2_tuner tun2;
746 struct v4l2_standard std2; 747 struct v4l2_standard std2;
747 v4l2_std_id sid; 748 v4l2_std_id sid;
@@ -749,7 +750,7 @@ static noinline int v4l1_compat_get_tuner(
749 memset(&tun2, 0, sizeof(tun2)); 750 memset(&tun2, 0, sizeof(tun2));
750 err = drv(file, VIDIOC_G_TUNER, &tun2); 751 err = drv(file, VIDIOC_G_TUNER, &tun2);
751 if (err < 0) { 752 if (err < 0) {
752 dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err); 753 dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %ld\n", err);
753 goto done; 754 goto done;
754 } 755 }
755 memcpy(tun->name, tun2.name, 756 memcpy(tun->name, tun2.name,
@@ -775,7 +776,7 @@ static noinline int v4l1_compat_get_tuner(
775 776
776 err = drv(file, VIDIOC_G_STD, &sid); 777 err = drv(file, VIDIOC_G_STD, &sid);
777 if (err < 0) 778 if (err < 0)
778 dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n", err); 779 dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %ld\n", err);
779 if (err == 0) { 780 if (err == 0) {
780 if (sid & V4L2_STD_PAL) 781 if (sid & V4L2_STD_PAL)
781 tun->mode = VIDEO_MODE_PAL; 782 tun->mode = VIDEO_MODE_PAL;
@@ -794,12 +795,12 @@ done:
794 return err; 795 return err;
795} 796}
796 797
797static noinline int v4l1_compat_select_tuner( 798static noinline long v4l1_compat_select_tuner(
798 struct video_tuner *tun, 799 struct video_tuner *tun,
799 struct file *file, 800 struct file *file,
800 v4l2_kioctl drv) 801 v4l2_kioctl drv)
801{ 802{
802 int err; 803 long err;
803 struct v4l2_tuner t;/*84 bytes on x86_64*/ 804 struct v4l2_tuner t;/*84 bytes on x86_64*/
804 memset(&t, 0, sizeof(t)); 805 memset(&t, 0, sizeof(t));
805 806
@@ -807,34 +808,34 @@ static noinline int v4l1_compat_select_tuner(
807 808
808 err = drv(file, VIDIOC_S_INPUT, &t); 809 err = drv(file, VIDIOC_S_INPUT, &t);
809 if (err < 0) 810 if (err < 0)
810 dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err); 811 dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %ld\n", err);
811 return err; 812 return err;
812} 813}
813 814
814static noinline int v4l1_compat_get_frequency( 815static noinline long v4l1_compat_get_frequency(
815 unsigned long *freq, 816 unsigned long *freq,
816 struct file *file, 817 struct file *file,
817 v4l2_kioctl drv) 818 v4l2_kioctl drv)
818{ 819{
819 int err; 820 long err;
820 struct v4l2_frequency freq2; 821 struct v4l2_frequency freq2;
821 memset(&freq2, 0, sizeof(freq2)); 822 memset(&freq2, 0, sizeof(freq2));
822 823
823 freq2.tuner = 0; 824 freq2.tuner = 0;
824 err = drv(file, VIDIOC_G_FREQUENCY, &freq2); 825 err = drv(file, VIDIOC_G_FREQUENCY, &freq2);
825 if (err < 0) 826 if (err < 0)
826 dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err); 827 dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %ld\n", err);
827 if (0 == err) 828 if (0 == err)
828 *freq = freq2.frequency; 829 *freq = freq2.frequency;
829 return err; 830 return err;
830} 831}
831 832
832static noinline int v4l1_compat_set_frequency( 833static noinline long v4l1_compat_set_frequency(
833 unsigned long *freq, 834 unsigned long *freq,
834 struct file *file, 835 struct file *file,
835 v4l2_kioctl drv) 836 v4l2_kioctl drv)
836{ 837{
837 int err; 838 long err;
838 struct v4l2_frequency freq2; 839 struct v4l2_frequency freq2;
839 memset(&freq2, 0, sizeof(freq2)); 840 memset(&freq2, 0, sizeof(freq2));
840 841
@@ -842,16 +843,17 @@ static noinline int v4l1_compat_set_frequency(
842 freq2.frequency = *freq; 843 freq2.frequency = *freq;
843 err = drv(file, VIDIOC_S_FREQUENCY, &freq2); 844 err = drv(file, VIDIOC_S_FREQUENCY, &freq2);
844 if (err < 0) 845 if (err < 0)
845 dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err); 846 dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %ld\n", err);
846 return err; 847 return err;
847} 848}
848 849
849static noinline int v4l1_compat_get_audio( 850static noinline long v4l1_compat_get_audio(
850 struct video_audio *aud, 851 struct video_audio *aud,
851 struct file *file, 852 struct file *file,
852 v4l2_kioctl drv) 853 v4l2_kioctl drv)
853{ 854{
854 int err, i; 855 long err;
856 int i;
855 struct v4l2_queryctrl qctrl2; 857 struct v4l2_queryctrl qctrl2;
856 struct v4l2_audio aud2; 858 struct v4l2_audio aud2;
857 struct v4l2_tuner tun2; 859 struct v4l2_tuner tun2;
@@ -859,7 +861,7 @@ static noinline int v4l1_compat_get_audio(
859 861
860 err = drv(file, VIDIOC_G_AUDIO, &aud2); 862 err = drv(file, VIDIOC_G_AUDIO, &aud2);
861 if (err < 0) { 863 if (err < 0) {
862 dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err); 864 dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %ld\n", err);
863 goto done; 865 goto done;
864 } 866 }
865 memcpy(aud->name, aud2.name, 867 memcpy(aud->name, aud2.name,
@@ -903,7 +905,7 @@ static noinline int v4l1_compat_get_audio(
903 memset(&tun2, 0, sizeof(tun2)); 905 memset(&tun2, 0, sizeof(tun2));
904 err = drv(file, VIDIOC_G_TUNER, &tun2); 906 err = drv(file, VIDIOC_G_TUNER, &tun2);
905 if (err < 0) { 907 if (err < 0) {
906 dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err); 908 dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %ld\n", err);
907 err = 0; 909 err = 0;
908 goto done; 910 goto done;
909 } 911 }
@@ -918,12 +920,12 @@ done:
918 return err; 920 return err;
919} 921}
920 922
921static noinline int v4l1_compat_set_audio( 923static noinline long v4l1_compat_set_audio(
922 struct video_audio *aud, 924 struct video_audio *aud,
923 struct file *file, 925 struct file *file,
924 v4l2_kioctl drv) 926 v4l2_kioctl drv)
925{ 927{
926 int err; 928 long err;
927 struct v4l2_audio aud2; 929 struct v4l2_audio aud2;
928 struct v4l2_tuner tun2; 930 struct v4l2_tuner tun2;
929 931
@@ -933,7 +935,7 @@ static noinline int v4l1_compat_set_audio(
933 aud2.index = aud->audio; 935 aud2.index = aud->audio;
934 err = drv(file, VIDIOC_S_AUDIO, &aud2); 936 err = drv(file, VIDIOC_S_AUDIO, &aud2);
935 if (err < 0) { 937 if (err < 0) {
936 dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err); 938 dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %ld\n", err);
937 goto done; 939 goto done;
938 } 940 }
939 941
@@ -950,7 +952,7 @@ static noinline int v4l1_compat_set_audio(
950 952
951 err = drv(file, VIDIOC_G_TUNER, &tun2); 953 err = drv(file, VIDIOC_G_TUNER, &tun2);
952 if (err < 0) 954 if (err < 0)
953 dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n", err); 955 dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %ld\n", err);
954 if (err == 0) { 956 if (err == 0) {
955 switch (aud->mode) { 957 switch (aud->mode) {
956 default: 958 default:
@@ -967,19 +969,19 @@ static noinline int v4l1_compat_set_audio(
967 } 969 }
968 err = drv(file, VIDIOC_S_TUNER, &tun2); 970 err = drv(file, VIDIOC_S_TUNER, &tun2);
969 if (err < 0) 971 if (err < 0)
970 dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err); 972 dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %ld\n", err);
971 } 973 }
972 err = 0; 974 err = 0;
973done: 975done:
974 return err; 976 return err;
975} 977}
976 978
977static noinline int v4l1_compat_capture_frame( 979static noinline long v4l1_compat_capture_frame(
978 struct video_mmap *mm, 980 struct video_mmap *mm,
979 struct file *file, 981 struct file *file,
980 v4l2_kioctl drv) 982 v4l2_kioctl drv)
981{ 983{
982 int err; 984 long err;
983 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 985 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
984 struct v4l2_buffer buf; 986 struct v4l2_buffer buf;
985 struct v4l2_format *fmt; 987 struct v4l2_format *fmt;
@@ -994,7 +996,7 @@ static noinline int v4l1_compat_capture_frame(
994 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 996 fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
995 err = drv(file, VIDIOC_G_FMT, fmt); 997 err = drv(file, VIDIOC_G_FMT, fmt);
996 if (err < 0) { 998 if (err < 0) {
997 dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err); 999 dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %ld\n", err);
998 goto done; 1000 goto done;
999 } 1001 }
1000 if (mm->width != fmt->fmt.pix.width || 1002 if (mm->width != fmt->fmt.pix.width ||
@@ -1010,7 +1012,7 @@ static noinline int v4l1_compat_capture_frame(
1010 fmt->fmt.pix.bytesperline = 0; 1012 fmt->fmt.pix.bytesperline = 0;
1011 err = drv(file, VIDIOC_S_FMT, fmt); 1013 err = drv(file, VIDIOC_S_FMT, fmt);
1012 if (err < 0) { 1014 if (err < 0) {
1013 dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err); 1015 dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %ld\n", err);
1014 goto done; 1016 goto done;
1015 } 1017 }
1016 } 1018 }
@@ -1018,28 +1020,28 @@ static noinline int v4l1_compat_capture_frame(
1018 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1020 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1019 err = drv(file, VIDIOC_QUERYBUF, &buf); 1021 err = drv(file, VIDIOC_QUERYBUF, &buf);
1020 if (err < 0) { 1022 if (err < 0) {
1021 dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err); 1023 dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %ld\n", err);
1022 goto done; 1024 goto done;
1023 } 1025 }
1024 err = drv(file, VIDIOC_QBUF, &buf); 1026 err = drv(file, VIDIOC_QBUF, &buf);
1025 if (err < 0) { 1027 if (err < 0) {
1026 dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err); 1028 dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %ld\n", err);
1027 goto done; 1029 goto done;
1028 } 1030 }
1029 err = drv(file, VIDIOC_STREAMON, &captype); 1031 err = drv(file, VIDIOC_STREAMON, &captype);
1030 if (err < 0) 1032 if (err < 0)
1031 dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err); 1033 dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %ld\n", err);
1032done: 1034done:
1033 kfree(fmt); 1035 kfree(fmt);
1034 return err; 1036 return err;
1035} 1037}
1036 1038
1037static noinline int v4l1_compat_sync( 1039static noinline long v4l1_compat_sync(
1038 int *i, 1040 int *i,
1039 struct file *file, 1041 struct file *file,
1040 v4l2_kioctl drv) 1042 v4l2_kioctl drv)
1041{ 1043{
1042 int err; 1044 long err;
1043 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1045 enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1044 struct v4l2_buffer buf; 1046 struct v4l2_buffer buf;
1045 struct poll_wqueues *pwq; 1047 struct poll_wqueues *pwq;
@@ -1050,7 +1052,7 @@ static noinline int v4l1_compat_sync(
1050 err = drv(file, VIDIOC_QUERYBUF, &buf); 1052 err = drv(file, VIDIOC_QUERYBUF, &buf);
1051 if (err < 0) { 1053 if (err < 0) {
1052 /* No such buffer */ 1054 /* No such buffer */
1053 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); 1055 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err);
1054 goto done; 1056 goto done;
1055 } 1057 }
1056 if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) { 1058 if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) {
@@ -1062,7 +1064,7 @@ static noinline int v4l1_compat_sync(
1062 /* make sure capture actually runs so we don't block forever */ 1064 /* make sure capture actually runs so we don't block forever */
1063 err = drv(file, VIDIOC_STREAMON, &captype); 1065 err = drv(file, VIDIOC_STREAMON, &captype);
1064 if (err < 0) { 1066 if (err < 0) {
1065 dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err); 1067 dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %ld\n", err);
1066 goto done; 1068 goto done;
1067 } 1069 }
1068 1070
@@ -1076,7 +1078,7 @@ static noinline int v4l1_compat_sync(
1076 break; 1078 break;
1077 err = drv(file, VIDIOC_QUERYBUF, &buf); 1079 err = drv(file, VIDIOC_QUERYBUF, &buf);
1078 if (err < 0) 1080 if (err < 0)
1079 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); 1081 dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %ld\n", err);
1080 } 1082 }
1081 kfree(pwq); 1083 kfree(pwq);
1082 if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ 1084 if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */
@@ -1084,18 +1086,18 @@ static noinline int v4l1_compat_sync(
1084 do { 1086 do {
1085 err = drv(file, VIDIOC_DQBUF, &buf); 1087 err = drv(file, VIDIOC_DQBUF, &buf);
1086 if (err < 0) 1088 if (err < 0)
1087 dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err); 1089 dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %ld\n", err);
1088 } while (err == 0 && buf.index != *i); 1090 } while (err == 0 && buf.index != *i);
1089done: 1091done:
1090 return err; 1092 return err;
1091} 1093}
1092 1094
1093static noinline int v4l1_compat_get_vbi_format( 1095static noinline long v4l1_compat_get_vbi_format(
1094 struct vbi_format *fmt, 1096 struct vbi_format *fmt,
1095 struct file *file, 1097 struct file *file,
1096 v4l2_kioctl drv) 1098 v4l2_kioctl drv)
1097{ 1099{
1098 int err; 1100 long err;
1099 struct v4l2_format *fmt2; 1101 struct v4l2_format *fmt2;
1100 1102
1101 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); 1103 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
@@ -1107,7 +1109,7 @@ static noinline int v4l1_compat_get_vbi_format(
1107 1109
1108 err = drv(file, VIDIOC_G_FMT, fmt2); 1110 err = drv(file, VIDIOC_G_FMT, fmt2);
1109 if (err < 0) { 1111 if (err < 0) {
1110 dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); 1112 dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %ld\n", err);
1111 goto done; 1113 goto done;
1112 } 1114 }
1113 if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { 1115 if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) {
@@ -1128,12 +1130,12 @@ done:
1128 return err; 1130 return err;
1129} 1131}
1130 1132
1131static noinline int v4l1_compat_set_vbi_format( 1133static noinline long v4l1_compat_set_vbi_format(
1132 struct vbi_format *fmt, 1134 struct vbi_format *fmt,
1133 struct file *file, 1135 struct file *file,
1134 v4l2_kioctl drv) 1136 v4l2_kioctl drv)
1135{ 1137{
1136 int err; 1138 long err;
1137 struct v4l2_format *fmt2 = NULL; 1139 struct v4l2_format *fmt2 = NULL;
1138 1140
1139 if (VIDEO_PALETTE_RAW != fmt->sample_format) { 1141 if (VIDEO_PALETTE_RAW != fmt->sample_format) {
@@ -1157,7 +1159,7 @@ static noinline int v4l1_compat_set_vbi_format(
1157 fmt2->fmt.vbi.flags = fmt->flags; 1159 fmt2->fmt.vbi.flags = fmt->flags;
1158 err = drv(file, VIDIOC_TRY_FMT, fmt2); 1160 err = drv(file, VIDIOC_TRY_FMT, fmt2);
1159 if (err < 0) { 1161 if (err < 0) {
1160 dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); 1162 dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %ld\n", err);
1161 goto done; 1163 goto done;
1162 } 1164 }
1163 1165
@@ -1174,7 +1176,7 @@ static noinline int v4l1_compat_set_vbi_format(
1174 } 1176 }
1175 err = drv(file, VIDIOC_S_FMT, fmt2); 1177 err = drv(file, VIDIOC_S_FMT, fmt2);
1176 if (err < 0) 1178 if (err < 0)
1177 dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); 1179 dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %ld\n", err);
1178done: 1180done:
1179 kfree(fmt2); 1181 kfree(fmt2);
1180 return err; 1182 return err;
@@ -1183,13 +1185,13 @@ done:
1183/* 1185/*
1184 * This function is exported. 1186 * This function is exported.
1185 */ 1187 */
1186int 1188long
1187v4l_compat_translate_ioctl(struct file *file, 1189v4l_compat_translate_ioctl(struct file *file,
1188 int cmd, 1190 int cmd,
1189 void *arg, 1191 void *arg,
1190 v4l2_kioctl drv) 1192 v4l2_kioctl drv)
1191{ 1193{
1192 int err; 1194 long err;
1193 1195
1194 switch (cmd) { 1196 switch (cmd) {
1195 case VIDIOCGCAP: /* capability */ 1197 case VIDIOCGCAP: /* capability */
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index c676b0b0f708..b8f2be8d5c0e 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -797,11 +797,11 @@ u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
797} 797}
798EXPORT_SYMBOL(v4l2_ctrl_next); 798EXPORT_SYMBOL(v4l2_ctrl_next);
799 799
800int v4l2_chip_match_host(u32 match_type, u32 match_chip) 800int v4l2_chip_match_host(const struct v4l2_dbg_match *match)
801{ 801{
802 switch (match_type) { 802 switch (match->type) {
803 case V4L2_CHIP_MATCH_HOST: 803 case V4L2_CHIP_MATCH_HOST:
804 return match_chip == 0; 804 return match->addr == 0;
805 default: 805 default:
806 return 0; 806 return 0;
807 } 807 }
@@ -809,23 +809,34 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip)
809EXPORT_SYMBOL(v4l2_chip_match_host); 809EXPORT_SYMBOL(v4l2_chip_match_host);
810 810
811#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) 811#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
812int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 match_type, u32 match_chip) 812int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match)
813{ 813{
814 switch (match_type) { 814 int len;
815
816 if (c == NULL || match == NULL)
817 return 0;
818
819 switch (match->type) {
815 case V4L2_CHIP_MATCH_I2C_DRIVER: 820 case V4L2_CHIP_MATCH_I2C_DRIVER:
816 return (c != NULL && c->driver != NULL && c->driver->id == match_chip); 821 if (c->driver == NULL || c->driver->driver.name == NULL)
822 return 0;
823 len = strlen(c->driver->driver.name);
824 /* legacy drivers have a ' suffix, don't try to match that */
825 if (len && c->driver->driver.name[len - 1] == '\'')
826 len--;
827 return len && !strncmp(c->driver->driver.name, match->name, len);
817 case V4L2_CHIP_MATCH_I2C_ADDR: 828 case V4L2_CHIP_MATCH_I2C_ADDR:
818 return (c != NULL && c->addr == match_chip); 829 return c->addr == match->addr;
819 default: 830 default:
820 return 0; 831 return 0;
821 } 832 }
822} 833}
823EXPORT_SYMBOL(v4l2_chip_match_i2c_client); 834EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
824 835
825int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, 836int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip,
826 u32 ident, u32 revision) 837 u32 ident, u32 revision)
827{ 838{
828 if (!v4l2_chip_match_i2c_client(c, chip->match_type, chip->match_chip)) 839 if (!v4l2_chip_match_i2c_client(c, &chip->match))
829 return 0; 840 return 0;
830 if (chip->ident == V4L2_IDENT_NONE) { 841 if (chip->ident == V4L2_IDENT_NONE) {
831 chip->ident = ident; 842 chip->ident = ident;
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index d0e1bd3ace6a..110376be5d2b 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -222,9 +222,9 @@ static int get_microcode32(struct video_code *kp, struct video_code32 __user *up
222 222
223#endif 223#endif
224 224
225static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 225static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
226{ 226{
227 int ret = -ENOIOCTLCMD; 227 long ret = -ENOIOCTLCMD;
228 228
229 if (file->f_op->unlocked_ioctl) 229 if (file->f_op->unlocked_ioctl)
230 ret = file->f_op->unlocked_ioctl(file, cmd, arg); 230 ret = file->f_op->unlocked_ioctl(file, cmd, arg);
@@ -705,7 +705,7 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
705#define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32) 705#define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32)
706#define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32) 706#define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32)
707 707
708static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 708static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
709{ 709{
710 union { 710 union {
711#ifdef CONFIG_VIDEO_V4L1_COMPAT 711#ifdef CONFIG_VIDEO_V4L1_COMPAT
@@ -726,7 +726,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
726 } karg; 726 } karg;
727 void __user *up = compat_ptr(arg); 727 void __user *up = compat_ptr(arg);
728 int compatible_arg = 1; 728 int compatible_arg = 1;
729 int err = 0; 729 long err = 0;
730 730
731 /* First, convert the command. */ 731 /* First, convert the command. */
732 switch (cmd) { 732 switch (cmd) {
@@ -937,9 +937,9 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
937 return err; 937 return err;
938} 938}
939 939
940long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) 940long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
941{ 941{
942 int ret = -ENOIOCTLCMD; 942 long ret = -ENOIOCTLCMD;
943 943
944 if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl) 944 if (!file->f_op->ioctl && !file->f_op->unlocked_ioctl)
945 return ret; 945 return ret;
@@ -1046,7 +1046,8 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1046 case VIDIOC_TRY_ENCODER_CMD: 1046 case VIDIOC_TRY_ENCODER_CMD:
1047 case VIDIOC_DBG_S_REGISTER: 1047 case VIDIOC_DBG_S_REGISTER:
1048 case VIDIOC_DBG_G_REGISTER: 1048 case VIDIOC_DBG_G_REGISTER:
1049 case VIDIOC_G_CHIP_IDENT: 1049 case VIDIOC_DBG_G_CHIP_IDENT:
1050 case VIDIOC_G_CHIP_IDENT_OLD:
1050 case VIDIOC_S_HW_FREQ_SEEK: 1051 case VIDIOC_S_HW_FREQ_SEEK:
1051 ret = do_video_ioctl(file, cmd, arg); 1052 ret = do_video_ioctl(file, cmd, arg);
1052 break; 1053 break;
@@ -1065,18 +1066,14 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1065 break; 1066 break;
1066#endif 1067#endif
1067 default: 1068 default:
1068 v4l_print_ioctl("compat_ioctl32", cmd); 1069 printk(KERN_WARNING "compat_ioctl32: "
1069 printk(KERN_CONT "\n"); 1070 "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
1071 _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
1070 break; 1072 break;
1071 } 1073 }
1072 return ret; 1074 return ret;
1073} 1075}
1074#else 1076EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32);
1075long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1076{
1077 return -ENOIOCTLCMD;
1078}
1079#endif 1077#endif
1080EXPORT_SYMBOL_GPL(v4l_compat_ioctl32);
1081 1078
1082MODULE_LICENSE("GPL"); 1079MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 7ad6711ee327..13f87c22e78d 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -31,6 +31,7 @@
31 31
32#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
33#include <media/v4l2-device.h> 33#include <media/v4l2-device.h>
34#include <media/v4l2-ioctl.h>
34 35
35#define VIDEO_NUM_DEVICES 256 36#define VIDEO_NUM_DEVICES 256
36#define VIDEO_NAME "video4linux" 37#define VIDEO_NAME "video4linux"
@@ -182,7 +183,7 @@ static int v4l2_ioctl(struct inode *inode, struct file *filp,
182 return -ENOTTY; 183 return -ENOTTY;
183 /* Allow ioctl to continue even if the device was unregistered. 184 /* Allow ioctl to continue even if the device was unregistered.
184 Things like dequeueing buffers might still be useful. */ 185 Things like dequeueing buffers might still be useful. */
185 return vdev->fops->ioctl(inode, filp, cmd, arg); 186 return vdev->fops->ioctl(filp, cmd, arg);
186} 187}
187 188
188static long v4l2_unlocked_ioctl(struct file *filp, 189static long v4l2_unlocked_ioctl(struct file *filp,
@@ -197,20 +198,6 @@ static long v4l2_unlocked_ioctl(struct file *filp,
197 return vdev->fops->unlocked_ioctl(filp, cmd, arg); 198 return vdev->fops->unlocked_ioctl(filp, cmd, arg);
198} 199}
199 200
200#ifdef CONFIG_COMPAT
201static long v4l2_compat_ioctl(struct file *filp,
202 unsigned int cmd, unsigned long arg)
203{
204 struct video_device *vdev = video_devdata(filp);
205
206 if (!vdev->fops->compat_ioctl)
207 return -ENOIOCTLCMD;
208 /* Allow ioctl to continue even if the device was unregistered.
209 Things like dequeueing buffers might still be useful. */
210 return vdev->fops->compat_ioctl(filp, cmd, arg);
211}
212#endif
213
214static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) 201static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
215{ 202{
216 struct video_device *vdev = video_devdata(filp); 203 struct video_device *vdev = video_devdata(filp);
@@ -239,7 +226,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
239 /* and increase the device refcount */ 226 /* and increase the device refcount */
240 video_get(vdev); 227 video_get(vdev);
241 mutex_unlock(&videodev_lock); 228 mutex_unlock(&videodev_lock);
242 ret = vdev->fops->open(inode, filp); 229 ret = vdev->fops->open(filp);
243 /* decrease the refcount in case of an error */ 230 /* decrease the refcount in case of an error */
244 if (ret) 231 if (ret)
245 video_put(vdev); 232 video_put(vdev);
@@ -250,7 +237,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
250static int v4l2_release(struct inode *inode, struct file *filp) 237static int v4l2_release(struct inode *inode, struct file *filp)
251{ 238{
252 struct video_device *vdev = video_devdata(filp); 239 struct video_device *vdev = video_devdata(filp);
253 int ret = vdev->fops->release(inode, filp); 240 int ret = vdev->fops->release(filp);
254 241
255 /* decrease the refcount unconditionally since the release() 242 /* decrease the refcount unconditionally since the release()
256 return value is ignored. */ 243 return value is ignored. */
@@ -266,7 +253,7 @@ static const struct file_operations v4l2_unlocked_fops = {
266 .mmap = v4l2_mmap, 253 .mmap = v4l2_mmap,
267 .unlocked_ioctl = v4l2_unlocked_ioctl, 254 .unlocked_ioctl = v4l2_unlocked_ioctl,
268#ifdef CONFIG_COMPAT 255#ifdef CONFIG_COMPAT
269 .compat_ioctl = v4l2_compat_ioctl, 256 .compat_ioctl = v4l2_compat_ioctl32,
270#endif 257#endif
271 .release = v4l2_release, 258 .release = v4l2_release,
272 .poll = v4l2_poll, 259 .poll = v4l2_poll,
@@ -281,7 +268,7 @@ static const struct file_operations v4l2_fops = {
281 .mmap = v4l2_mmap, 268 .mmap = v4l2_mmap,
282 .ioctl = v4l2_ioctl, 269 .ioctl = v4l2_ioctl,
283#ifdef CONFIG_COMPAT 270#ifdef CONFIG_COMPAT
284 .compat_ioctl = v4l2_compat_ioctl, 271 .compat_ioctl = v4l2_compat_ioctl32,
285#endif 272#endif
286 .release = v4l2_release, 273 .release = v4l2_release,
287 .poll = v4l2_poll, 274 .poll = v4l2_poll,
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index b063381f4b3b..52d687b165e0 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -266,7 +266,7 @@ static const char *v4l2_ioctls[] = {
266 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", 266 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
267 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", 267 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
268 268
269 [_IOC_NR(VIDIOC_G_CHIP_IDENT)] = "VIDIOC_G_CHIP_IDENT", 269 [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT",
270 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK", 270 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK",
271#endif 271#endif
272}; 272};
@@ -392,14 +392,14 @@ video_fix_command(unsigned int cmd)
392/* 392/*
393 * Obsolete usercopy function - Should be removed soon 393 * Obsolete usercopy function - Should be removed soon
394 */ 394 */
395int 395long
396video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, 396video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
397 v4l2_kioctl func) 397 v4l2_kioctl func)
398{ 398{
399 char sbuf[128]; 399 char sbuf[128];
400 void *mbuf = NULL; 400 void *mbuf = NULL;
401 void *parg = NULL; 401 void *parg = NULL;
402 int err = -EINVAL; 402 long err = -EINVAL;
403 int is_ext_ctrl; 403 int is_ext_ctrl;
404 size_t ctrls_size = 0; 404 size_t ctrls_size = 0;
405 void __user *user_ptr = NULL; 405 void __user *user_ptr = NULL;
@@ -623,13 +623,13 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type)
623 return -EINVAL; 623 return -EINVAL;
624} 624}
625 625
626static int __video_do_ioctl(struct file *file, 626static long __video_do_ioctl(struct file *file,
627 unsigned int cmd, void *arg) 627 unsigned int cmd, void *arg)
628{ 628{
629 struct video_device *vfd = video_devdata(file); 629 struct video_device *vfd = video_devdata(file);
630 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; 630 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
631 void *fh = file->private_data; 631 void *fh = file->private_data;
632 int ret = -EINVAL; 632 long ret = -EINVAL;
633 633
634 if ((vfd->debug & V4L2_DEBUG_IOCTL) && 634 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
635 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { 635 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
@@ -1720,7 +1720,7 @@ static int __video_do_ioctl(struct file *file,
1720#ifdef CONFIG_VIDEO_ADV_DEBUG 1720#ifdef CONFIG_VIDEO_ADV_DEBUG
1721 case VIDIOC_DBG_G_REGISTER: 1721 case VIDIOC_DBG_G_REGISTER:
1722 { 1722 {
1723 struct v4l2_register *p = arg; 1723 struct v4l2_dbg_register *p = arg;
1724 1724
1725 if (!capable(CAP_SYS_ADMIN)) 1725 if (!capable(CAP_SYS_ADMIN))
1726 ret = -EPERM; 1726 ret = -EPERM;
@@ -1730,7 +1730,7 @@ static int __video_do_ioctl(struct file *file,
1730 } 1730 }
1731 case VIDIOC_DBG_S_REGISTER: 1731 case VIDIOC_DBG_S_REGISTER:
1732 { 1732 {
1733 struct v4l2_register *p = arg; 1733 struct v4l2_dbg_register *p = arg;
1734 1734
1735 if (!capable(CAP_SYS_ADMIN)) 1735 if (!capable(CAP_SYS_ADMIN))
1736 ret = -EPERM; 1736 ret = -EPERM;
@@ -1739,9 +1739,9 @@ static int __video_do_ioctl(struct file *file,
1739 break; 1739 break;
1740 } 1740 }
1741#endif 1741#endif
1742 case VIDIOC_G_CHIP_IDENT: 1742 case VIDIOC_DBG_G_CHIP_IDENT:
1743 { 1743 {
1744 struct v4l2_chip_ident *p = arg; 1744 struct v4l2_dbg_chip_ident *p = arg;
1745 1745
1746 if (!ops->vidioc_g_chip_ident) 1746 if (!ops->vidioc_g_chip_ident)
1747 break; 1747 break;
@@ -1750,6 +1750,11 @@ static int __video_do_ioctl(struct file *file,
1750 dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); 1750 dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
1751 break; 1751 break;
1752 } 1752 }
1753 case VIDIOC_G_CHIP_IDENT_OLD:
1754 printk(KERN_ERR "VIDIOC_G_CHIP_IDENT has been deprecated and will disappear in 2.6.30.\n");
1755 printk(KERN_ERR "It is a debugging ioctl and must not be used in applications!\n");
1756 return -EINVAL;
1757
1753 case VIDIOC_S_HW_FREQ_SEEK: 1758 case VIDIOC_S_HW_FREQ_SEEK:
1754 { 1759 {
1755 struct v4l2_hw_freq_seek *p = arg; 1760 struct v4l2_hw_freq_seek *p = arg;
@@ -1845,20 +1850,20 @@ static int __video_do_ioctl(struct file *file,
1845 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { 1850 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
1846 if (ret < 0) { 1851 if (ret < 0) {
1847 v4l_print_ioctl(vfd->name, cmd); 1852 v4l_print_ioctl(vfd->name, cmd);
1848 printk(KERN_CONT " error %d\n", ret); 1853 printk(KERN_CONT " error %ld\n", ret);
1849 } 1854 }
1850 } 1855 }
1851 1856
1852 return ret; 1857 return ret;
1853} 1858}
1854 1859
1855long __video_ioctl2(struct file *file, 1860long video_ioctl2(struct file *file,
1856 unsigned int cmd, unsigned long arg) 1861 unsigned int cmd, unsigned long arg)
1857{ 1862{
1858 char sbuf[128]; 1863 char sbuf[128];
1859 void *mbuf = NULL; 1864 void *mbuf = NULL;
1860 void *parg = NULL; 1865 void *parg = NULL;
1861 int err = -EINVAL; 1866 long err = -EINVAL;
1862 int is_ext_ctrl; 1867 int is_ext_ctrl;
1863 size_t ctrls_size = 0; 1868 size_t ctrls_size = 0;
1864 void __user *user_ptr = NULL; 1869 void __user *user_ptr = NULL;
@@ -1944,11 +1949,4 @@ out:
1944 kfree(mbuf); 1949 kfree(mbuf);
1945 return err; 1950 return err;
1946} 1951}
1947EXPORT_SYMBOL(__video_ioctl2);
1948
1949int video_ioctl2(struct inode *inode, struct file *file,
1950 unsigned int cmd, unsigned long arg)
1951{
1952 return __video_ioctl2(file, cmd, arg);
1953}
1954EXPORT_SYMBOL(video_ioctl2); 1952EXPORT_SYMBOL(video_ioctl2);
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c
index e3612f29d0df..fbe9cc0d433a 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -37,7 +37,7 @@ int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg)
37 return v4l2_subdev_call(sd, core, queryctrl, arg); 37 return v4l2_subdev_call(sd, core, queryctrl, arg);
38 case VIDIOC_LOG_STATUS: 38 case VIDIOC_LOG_STATUS:
39 return v4l2_subdev_call(sd, core, log_status); 39 return v4l2_subdev_call(sd, core, log_status);
40 case VIDIOC_G_CHIP_IDENT: 40 case VIDIOC_DBG_G_CHIP_IDENT:
41 return v4l2_subdev_call(sd, core, g_chip_ident, arg); 41 return v4l2_subdev_call(sd, core, g_chip_ident, arg);
42 case VIDIOC_INT_S_STANDBY: 42 case VIDIOC_INT_S_STANDBY:
43 return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0); 43 return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0);
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index a72a361daade..88bf845a3d56 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -4019,7 +4019,7 @@ out:
4019 4019
4020/* File operations */ 4020/* File operations */
4021 4021
4022static int vino_open(struct inode *inode, struct file *file) 4022static int vino_open(struct file *file)
4023{ 4023{
4024 struct vino_channel_settings *vcs = video_drvdata(file); 4024 struct vino_channel_settings *vcs = video_drvdata(file);
4025 int ret = 0; 4025 int ret = 0;
@@ -4050,7 +4050,7 @@ static int vino_open(struct inode *inode, struct file *file)
4050 return ret; 4050 return ret;
4051} 4051}
4052 4052
4053static int vino_close(struct inode *inode, struct file *file) 4053static int vino_close(struct file *file)
4054{ 4054{
4055 struct vino_channel_settings *vcs = video_drvdata(file); 4055 struct vino_channel_settings *vcs = video_drvdata(file);
4056 dprintk("close():\n"); 4056 dprintk("close():\n");
@@ -4237,7 +4237,7 @@ error:
4237 return ret; 4237 return ret;
4238} 4238}
4239 4239
4240static int vino_do_ioctl(struct file *file, unsigned int cmd, void *arg) 4240static long vino_do_ioctl(struct file *file, unsigned int cmd, void *arg)
4241{ 4241{
4242 struct vino_channel_settings *vcs = video_drvdata(file); 4242 struct vino_channel_settings *vcs = video_drvdata(file);
4243 4243
@@ -4343,11 +4343,11 @@ static int vino_do_ioctl(struct file *file, unsigned int cmd, void *arg)
4343 return 0; 4343 return 0;
4344} 4344}
4345 4345
4346static int vino_ioctl(struct inode *inode, struct file *file, 4346static long vino_ioctl(struct file *file,
4347 unsigned int cmd, unsigned long arg) 4347 unsigned int cmd, unsigned long arg)
4348{ 4348{
4349 struct vino_channel_settings *vcs = video_drvdata(file); 4349 struct vino_channel_settings *vcs = video_drvdata(file);
4350 int ret; 4350 long ret;
4351 4351
4352 if (mutex_lock_interruptible(&vcs->mutex)) 4352 if (mutex_lock_interruptible(&vcs->mutex))
4353 return -EINTR; 4353 return -EINTR;
@@ -4364,14 +4364,13 @@ static int vino_ioctl(struct inode *inode, struct file *file,
4364/* __initdata */ 4364/* __initdata */
4365static int vino_init_stage; 4365static int vino_init_stage;
4366 4366
4367static const struct file_operations vino_fops = { 4367static const struct v4l2_file_operations vino_fops = {
4368 .owner = THIS_MODULE, 4368 .owner = THIS_MODULE,
4369 .open = vino_open, 4369 .open = vino_open,
4370 .release = vino_close, 4370 .release = vino_close,
4371 .ioctl = vino_ioctl, 4371 .ioctl = vino_ioctl,
4372 .mmap = vino_mmap, 4372 .mmap = vino_mmap,
4373 .poll = vino_poll, 4373 .poll = vino_poll,
4374 .llseek = no_llseek,
4375}; 4374};
4376 4375
4377static struct video_device v4l_device_template = { 4376static struct video_device v4l_device_template = {
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index e15e48f04be7..81d5aa5cf331 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -1024,9 +1024,9 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1024 File operations for the device 1024 File operations for the device
1025 ------------------------------------------------------------------*/ 1025 ------------------------------------------------------------------*/
1026 1026
1027static int vivi_open(struct inode *inode, struct file *file) 1027static int vivi_open(struct file *file)
1028{ 1028{
1029 int minor = iminor(inode); 1029 int minor = video_devdata(file)->minor;
1030 struct vivi_dev *dev; 1030 struct vivi_dev *dev;
1031 struct vivi_fh *fh = NULL; 1031 struct vivi_fh *fh = NULL;
1032 int i; 1032 int i;
@@ -1127,13 +1127,13 @@ vivi_poll(struct file *file, struct poll_table_struct *wait)
1127 return videobuf_poll_stream(file, q, wait); 1127 return videobuf_poll_stream(file, q, wait);
1128} 1128}
1129 1129
1130static int vivi_close(struct inode *inode, struct file *file) 1130static int vivi_close(struct file *file)
1131{ 1131{
1132 struct vivi_fh *fh = file->private_data; 1132 struct vivi_fh *fh = file->private_data;
1133 struct vivi_dev *dev = fh->dev; 1133 struct vivi_dev *dev = fh->dev;
1134 struct vivi_dmaqueue *vidq = &dev->vidq; 1134 struct vivi_dmaqueue *vidq = &dev->vidq;
1135 1135
1136 int minor = iminor(inode); 1136 int minor = video_devdata(file)->minor;
1137 1137
1138 vivi_stop_thread(vidq); 1138 vivi_stop_thread(vidq);
1139 videobuf_stop(&fh->vb_vidq); 1139 videobuf_stop(&fh->vb_vidq);
@@ -1195,16 +1195,14 @@ static int vivi_mmap(struct file *file, struct vm_area_struct *vma)
1195 return ret; 1195 return ret;
1196} 1196}
1197 1197
1198static const struct file_operations vivi_fops = { 1198static const struct v4l2_file_operations vivi_fops = {
1199 .owner = THIS_MODULE, 1199 .owner = THIS_MODULE,
1200 .open = vivi_open, 1200 .open = vivi_open,
1201 .release = vivi_close, 1201 .release = vivi_close,
1202 .read = vivi_read, 1202 .read = vivi_read,
1203 .poll = vivi_poll, 1203 .poll = vivi_poll,
1204 .ioctl = video_ioctl2, /* V4L2 ioctl handler */ 1204 .ioctl = video_ioctl2, /* V4L2 ioctl handler */
1205 .compat_ioctl = v4l_compat_ioctl32,
1206 .mmap = vivi_mmap, 1205 .mmap = vivi_mmap,
1207 .llseek = no_llseek,
1208}; 1206};
1209 1207
1210static const struct v4l2_ioctl_ops vivi_ioctl_ops = { 1208static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c
index f72b859486ad..5d73f66d9f55 100644
--- a/drivers/media/video/vp27smpx.c
+++ b/drivers/media/video/vp27smpx.c
@@ -113,7 +113,7 @@ static int vp27smpx_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
113 return 0; 113 return 0;
114} 114}
115 115
116static int vp27smpx_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 116static int vp27smpx_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
117{ 117{
118 struct i2c_client *client = v4l2_get_subdevdata(sd); 118 struct i2c_client *client = v4l2_get_subdevdata(sd);
119 119
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 56c570c267ea..038ff32b01b8 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -180,19 +180,19 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data);
180static int w9966_i2c_rbyte(struct w9966_dev* cam); 180static int w9966_i2c_rbyte(struct w9966_dev* cam);
181#endif 181#endif
182 182
183static int w9966_v4l_ioctl(struct inode *inode, struct file *file, 183static long w9966_v4l_ioctl(struct file *file,
184 unsigned int cmd, unsigned long arg); 184 unsigned int cmd, unsigned long arg);
185static ssize_t w9966_v4l_read(struct file *file, char __user *buf, 185static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
186 size_t count, loff_t *ppos); 186 size_t count, loff_t *ppos);
187 187
188static int w9966_exclusive_open(struct inode *inode, struct file *file) 188static int w9966_exclusive_open(struct file *file)
189{ 189{
190 struct w9966_dev *cam = video_drvdata(file); 190 struct w9966_dev *cam = video_drvdata(file);
191 191
192 return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0; 192 return test_and_set_bit(0, &cam->in_use) ? -EBUSY : 0;
193} 193}
194 194
195static int w9966_exclusive_release(struct inode *inode, struct file *file) 195static int w9966_exclusive_release(struct file *file)
196{ 196{
197 struct w9966_dev *cam = video_drvdata(file); 197 struct w9966_dev *cam = video_drvdata(file);
198 198
@@ -200,16 +200,12 @@ static int w9966_exclusive_release(struct inode *inode, struct file *file)
200 return 0; 200 return 0;
201} 201}
202 202
203static const struct file_operations w9966_fops = { 203static const struct v4l2_file_operations w9966_fops = {
204 .owner = THIS_MODULE, 204 .owner = THIS_MODULE,
205 .open = w9966_exclusive_open, 205 .open = w9966_exclusive_open,
206 .release = w9966_exclusive_release, 206 .release = w9966_exclusive_release,
207 .ioctl = w9966_v4l_ioctl, 207 .ioctl = w9966_v4l_ioctl,
208#ifdef CONFIG_COMPAT
209 .compat_ioctl = v4l_compat_ioctl32,
210#endif
211 .read = w9966_v4l_read, 208 .read = w9966_v4l_read,
212 .llseek = no_llseek,
213}; 209};
214static struct video_device w9966_template = { 210static struct video_device w9966_template = {
215 .name = W9966_DRIVERNAME, 211 .name = W9966_DRIVERNAME,
@@ -727,7 +723,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
727 * Video4linux interfacing 723 * Video4linux interfacing
728 */ 724 */
729 725
730static int w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg) 726static long w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg)
731{ 727{
732 struct w9966_dev *cam = video_drvdata(file); 728 struct w9966_dev *cam = video_drvdata(file);
733 729
@@ -877,7 +873,7 @@ static int w9966_v4l_do_ioctl(struct file *file, unsigned int cmd, void *arg)
877 return 0; 873 return 0;
878} 874}
879 875
880static int w9966_v4l_ioctl(struct inode *inode, struct file *file, 876static long w9966_v4l_ioctl(struct file *file,
881 unsigned int cmd, unsigned long arg) 877 unsigned int cmd, unsigned long arg)
882{ 878{
883 return video_usercopy(file, cmd, arg, w9966_v4l_do_ioctl); 879 return video_usercopy(file, cmd, arg, w9966_v4l_do_ioctl);
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 4dfb43bd1846..a3997b7d4366 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -399,13 +399,13 @@ MODULE_PARM_DESC(specific_debug,
399 ****************************************************************************/ 399 ****************************************************************************/
400 400
401/* Video4linux interface */ 401/* Video4linux interface */
402static const struct file_operations w9968cf_fops; 402static const struct v4l2_file_operations w9968cf_fops;
403static int w9968cf_open(struct inode*, struct file*); 403static int w9968cf_open(struct file *);
404static int w9968cf_release(struct inode*, struct file*); 404static int w9968cf_release(struct file *);
405static int w9968cf_mmap(struct file*, struct vm_area_struct*); 405static int w9968cf_mmap(struct file *, struct vm_area_struct *);
406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long); 406static long w9968cf_ioctl(struct file *, unsigned, unsigned long);
407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*); 407static ssize_t w9968cf_read(struct file *, char __user *, size_t, loff_t *);
408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int, 408static long w9968cf_v4l_ioctl(struct file *, unsigned int,
409 void __user *); 409 void __user *);
410 410
411/* USB-specific */ 411/* USB-specific */
@@ -2662,7 +2662,7 @@ static void w9968cf_release_resources(struct w9968cf_device* cam)
2662 * Video4Linux interface * 2662 * Video4Linux interface *
2663 ****************************************************************************/ 2663 ****************************************************************************/
2664 2664
2665static int w9968cf_open(struct inode* inode, struct file* filp) 2665static int w9968cf_open(struct file *filp)
2666{ 2666{
2667 struct w9968cf_device* cam; 2667 struct w9968cf_device* cam;
2668 int err; 2668 int err;
@@ -2748,7 +2748,7 @@ deallocate_memory:
2748} 2748}
2749 2749
2750 2750
2751static int w9968cf_release(struct inode* inode, struct file* filp) 2751static int w9968cf_release(struct file *filp)
2752{ 2752{
2753 struct w9968cf_device* cam; 2753 struct w9968cf_device* cam;
2754 2754
@@ -2885,12 +2885,12 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2885} 2885}
2886 2886
2887 2887
2888static int 2888static long
2889w9968cf_ioctl(struct inode* inode, struct file* filp, 2889w9968cf_ioctl(struct file *filp,
2890 unsigned int cmd, unsigned long arg) 2890 unsigned int cmd, unsigned long arg)
2891{ 2891{
2892 struct w9968cf_device* cam; 2892 struct w9968cf_device* cam;
2893 int err; 2893 long err;
2894 2894
2895 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); 2895 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
2896 2896
@@ -2909,15 +2909,15 @@ w9968cf_ioctl(struct inode* inode, struct file* filp,
2909 return -EIO; 2909 return -EIO;
2910 } 2910 }
2911 2911
2912 err = w9968cf_v4l_ioctl(inode, filp, cmd, (void __user *)arg); 2912 err = w9968cf_v4l_ioctl(filp, cmd, (void __user *)arg);
2913 2913
2914 mutex_unlock(&cam->fileop_mutex); 2914 mutex_unlock(&cam->fileop_mutex);
2915 return err; 2915 return err;
2916} 2916}
2917 2917
2918 2918
2919static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, 2919static long w9968cf_v4l_ioctl(struct file *filp,
2920 unsigned int cmd, void __user * arg) 2920 unsigned int cmd, void __user *arg)
2921{ 2921{
2922 struct w9968cf_device* cam; 2922 struct w9968cf_device* cam;
2923 const char* v4l1_ioctls[] = { 2923 const char* v4l1_ioctls[] = {
@@ -3456,17 +3456,13 @@ ioctl_fail:
3456} 3456}
3457 3457
3458 3458
3459static const struct file_operations w9968cf_fops = { 3459static const struct v4l2_file_operations w9968cf_fops = {
3460 .owner = THIS_MODULE, 3460 .owner = THIS_MODULE,
3461 .open = w9968cf_open, 3461 .open = w9968cf_open,
3462 .release = w9968cf_release, 3462 .release = w9968cf_release,
3463 .read = w9968cf_read, 3463 .read = w9968cf_read,
3464 .ioctl = w9968cf_ioctl, 3464 .ioctl = w9968cf_ioctl,
3465#ifdef CONFIG_COMPAT
3466 .compat_ioctl = v4l_compat_ioctl32,
3467#endif
3468 .mmap = w9968cf_mmap, 3465 .mmap = w9968cf_mmap,
3469 .llseek = no_llseek,
3470}; 3466};
3471 3467
3472 3468
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 12a31e7a5f6d..f2864d5cd180 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -233,7 +233,7 @@ static int wm8739_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
233 return -EINVAL; 233 return -EINVAL;
234} 234}
235 235
236static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 236static int wm8739_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
237{ 237{
238 struct i2c_client *client = v4l2_get_subdevdata(sd); 238 struct i2c_client *client = v4l2_get_subdevdata(sd);
239 239
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index d0220b0ec0bc..53fcd42843e0 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -130,7 +130,7 @@ static int wm8775_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
130 return 0; 130 return 0;
131} 131}
132 132
133static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip) 133static int wm8775_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
134{ 134{
135 struct i2c_client *client = v4l2_get_subdevdata(sd); 135 struct i2c_client *client = v4l2_get_subdevdata(sd);
136 136
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 9d00e6056491..96971044fc78 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -649,7 +649,7 @@ static void zc0301_release_resources(struct kref *kref)
649} 649}
650 650
651 651
652static int zc0301_open(struct inode* inode, struct file* filp) 652static int zc0301_open(struct file *filp)
653{ 653{
654 struct zc0301_device* cam; 654 struct zc0301_device* cam;
655 int err = 0; 655 int err = 0;
@@ -733,7 +733,7 @@ out:
733} 733}
734 734
735 735
736static int zc0301_release(struct inode* inode, struct file* filp) 736static int zc0301_release(struct file *filp)
737{ 737{
738 struct zc0301_device* cam; 738 struct zc0301_device* cam;
739 739
@@ -1793,8 +1793,8 @@ zc0301_vidioc_s_parm(struct zc0301_device* cam, void __user * arg)
1793} 1793}
1794 1794
1795 1795
1796static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp, 1796static long zc0301_ioctl_v4l2(struct file *filp,
1797 unsigned int cmd, void __user * arg) 1797 unsigned int cmd, void __user *arg)
1798{ 1798{
1799 struct zc0301_device *cam = video_drvdata(filp); 1799 struct zc0301_device *cam = video_drvdata(filp);
1800 1800
@@ -1888,7 +1888,7 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
1888} 1888}
1889 1889
1890 1890
1891static int zc0301_ioctl(struct inode* inode, struct file* filp, 1891static long zc0301_ioctl(struct file *filp,
1892 unsigned int cmd, unsigned long arg) 1892 unsigned int cmd, unsigned long arg)
1893{ 1893{
1894 struct zc0301_device *cam = video_drvdata(filp); 1894 struct zc0301_device *cam = video_drvdata(filp);
@@ -1912,7 +1912,7 @@ static int zc0301_ioctl(struct inode* inode, struct file* filp,
1912 1912
1913 V4LDBG(3, "zc0301", cmd); 1913 V4LDBG(3, "zc0301", cmd);
1914 1914
1915 err = zc0301_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); 1915 err = zc0301_ioctl_v4l2(filp, cmd, (void __user *)arg);
1916 1916
1917 mutex_unlock(&cam->fileop_mutex); 1917 mutex_unlock(&cam->fileop_mutex);
1918 1918
@@ -1920,18 +1920,14 @@ static int zc0301_ioctl(struct inode* inode, struct file* filp,
1920} 1920}
1921 1921
1922 1922
1923static const struct file_operations zc0301_fops = { 1923static const struct v4l2_file_operations zc0301_fops = {
1924 .owner = THIS_MODULE, 1924 .owner = THIS_MODULE,
1925 .open = zc0301_open, 1925 .open = zc0301_open,
1926 .release = zc0301_release, 1926 .release = zc0301_release,
1927 .ioctl = zc0301_ioctl, 1927 .ioctl = zc0301_ioctl,
1928#ifdef CONFIG_COMPAT
1929 .compat_ioctl = v4l_compat_ioctl32,
1930#endif
1931 .read = zc0301_read, 1928 .read = zc0301_read,
1932 .poll = zc0301_poll, 1929 .poll = zc0301_poll,
1933 .mmap = zc0301_mmap, 1930 .mmap = zc0301_mmap,
1934 .llseek = no_llseek,
1935}; 1931};
1936 1932
1937/*****************************************************************************/ 1933/*****************************************************************************/
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index 00b97d97aeaa..b58b9dda715c 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -1197,10 +1197,9 @@ zoran_close_end_session (struct file *file)
1197 */ 1197 */
1198 1198
1199static int 1199static int
1200zoran_open (struct inode *inode, 1200zoran_open(struct file *file)
1201 struct file *file)
1202{ 1201{
1203 unsigned int minor = iminor(inode); 1202 unsigned int minor = video_devdata(file)->minor;
1204 struct zoran *zr = NULL; 1203 struct zoran *zr = NULL;
1205 struct zoran_fh *fh; 1204 struct zoran_fh *fh;
1206 int i, res, first_open = 0, have_module_locks = 0; 1205 int i, res, first_open = 0, have_module_locks = 0;
@@ -1340,8 +1339,7 @@ open_unlock_and_return:
1340} 1339}
1341 1340
1342static int 1341static int
1343zoran_close (struct inode *inode, 1342zoran_close(struct file *file)
1344 struct file *file)
1345{ 1343{
1346 struct zoran_fh *fh = file->private_data; 1344 struct zoran_fh *fh = file->private_data;
1347 struct zoran *zr = fh->zr; 1345 struct zoran *zr = fh->zr;
@@ -1940,7 +1938,7 @@ zoran_set_input (struct zoran *zr,
1940 * ioctl routine 1938 * ioctl routine
1941 */ 1939 */
1942 1940
1943static int zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg) 1941static long zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1944{ 1942{
1945 struct zoran_fh *fh = file->private_data; 1943 struct zoran_fh *fh = file->private_data;
1946 struct zoran *zr = fh->zr; 1944 struct zoran *zr = fh->zr;
@@ -4191,11 +4189,10 @@ static int zoran_do_ioctl(struct file *file, unsigned int cmd, void *arg)
4191} 4189}
4192 4190
4193 4191
4194static int 4192static long
4195zoran_ioctl (struct inode *inode, 4193zoran_ioctl(struct file *file,
4196 struct file *file, 4194 unsigned int cmd,
4197 unsigned int cmd, 4195 unsigned long arg)
4198 unsigned long arg)
4199{ 4196{
4200 return video_usercopy(file, cmd, arg, zoran_do_ioctl); 4197 return video_usercopy(file, cmd, arg, zoran_do_ioctl);
4201} 4198}
@@ -4620,15 +4617,11 @@ zoran_mmap (struct file *file,
4620 return 0; 4617 return 0;
4621} 4618}
4622 4619
4623static const struct file_operations zoran_fops = { 4620static const struct v4l2_file_operations zoran_fops = {
4624 .owner = THIS_MODULE, 4621 .owner = THIS_MODULE,
4625 .open = zoran_open, 4622 .open = zoran_open,
4626 .release = zoran_close, 4623 .release = zoran_close,
4627 .ioctl = zoran_ioctl, 4624 .ioctl = zoran_ioctl,
4628#ifdef CONFIG_COMPAT
4629 .compat_ioctl = v4l_compat_ioctl32,
4630#endif
4631 .llseek = no_llseek,
4632 .read = zoran_read, 4625 .read = zoran_read,
4633 .write = zoran_write, 4626 .write = zoran_write,
4634 .mmap = zoran_mmap, 4627 .mmap = zoran_mmap,
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index a1d81ed44c7c..93023560f324 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -634,7 +634,7 @@ static int zr364xx_vidioc_streamoff(struct file *file, void *priv,
634 634
635 635
636/* open the camera */ 636/* open the camera */
637static int zr364xx_open(struct inode *inode, struct file *file) 637static int zr364xx_open(struct file *file)
638{ 638{
639 struct video_device *vdev = video_devdata(file); 639 struct video_device *vdev = video_devdata(file);
640 struct zr364xx_camera *cam = video_get_drvdata(vdev); 640 struct zr364xx_camera *cam = video_get_drvdata(vdev);
@@ -688,7 +688,7 @@ out:
688 688
689 689
690/* release the camera */ 690/* release the camera */
691static int zr364xx_release(struct inode *inode, struct file *file) 691static int zr364xx_release(struct file *file)
692{ 692{
693 struct video_device *vdev = video_devdata(file); 693 struct video_device *vdev = video_devdata(file);
694 struct zr364xx_camera *cam; 694 struct zr364xx_camera *cam;
@@ -761,14 +761,13 @@ static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma)
761} 761}
762 762
763 763
764static const struct file_operations zr364xx_fops = { 764static const struct v4l2_file_operations zr364xx_fops = {
765 .owner = THIS_MODULE, 765 .owner = THIS_MODULE,
766 .open = zr364xx_open, 766 .open = zr364xx_open,
767 .release = zr364xx_release, 767 .release = zr364xx_release,
768 .read = zr364xx_read, 768 .read = zr364xx_read,
769 .mmap = zr364xx_mmap, 769 .mmap = zr364xx_mmap,
770 .ioctl = video_ioctl2, 770 .ioctl = video_ioctl2,
771 .llseek = no_llseek,
772}; 771};
773 772
774static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = { 773static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
@@ -894,7 +893,6 @@ static void zr364xx_disconnect(struct usb_interface *intf)
894{ 893{
895 struct zr364xx_camera *cam = usb_get_intfdata(intf); 894 struct zr364xx_camera *cam = usb_get_intfdata(intf);
896 usb_set_intfdata(intf, NULL); 895 usb_set_intfdata(intf, NULL);
897 dev_set_drvdata(&intf->dev, NULL);
898 dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); 896 dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n");
899 if (cam->vdev) 897 if (cam->vdev)
900 video_unregister_device(cam->vdev); 898 video_unregister_device(cam->vdev);
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 56faef1a1d55..06c655c55587 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index f3384c32b9a1..efba7021948a 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -19,7 +19,7 @@
19 * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel() 19 * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel()
20 * Deepak Saxena (11/18/1999): 20 * Deepak Saxena (11/18/1999):
21 * Added event managmenet support 21 * Added event managmenet support
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * 2.4 rewrite ported to 2.5 23 * 2.4 rewrite ported to 2.5
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Added pass-thru support for Adaptec's raidutils 25 * Added pass-thru support for Adaptec's raidutils
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 6e53a30bfd38..35c67d1f255e 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 610ef1204e68..25d6f2341983 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -19,7 +19,7 @@
19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> 19 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
20 * Deepak Saxena <deepak@plexity.net> 20 * Deepak Saxena <deepak@plexity.net>
21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> 21 * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
22 * Alan Cox <alan@redhat.com>: 22 * Alan Cox <alan@lxorguk.ukuu.org.uk>:
23 * Ported to Linux 2.5. 23 * Ported to Linux 2.5.
24 * Markus Lidel <Markus.Lidel@shadowconnect.com>: 24 * Markus Lidel <Markus.Lidel@shadowconnect.com>:
25 * Minor fixes for 2.6. 25 * Minor fixes for 2.6.
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 257277394f8c..416f9e7286ba 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -34,6 +34,14 @@ config MFD_ASIC3
34 This driver supports the ASIC3 multifunction chip found on many 34 This driver supports the ASIC3 multifunction chip found on many
35 PDAs (mainly iPAQ and HTC based ones) 35 PDAs (mainly iPAQ and HTC based ones)
36 36
37config MFD_DM355EVM_MSP
38 bool "DaVinci DM355 EVM microcontroller"
39 depends on I2C && MACH_DAVINCI_DM355_EVM
40 help
41 This driver supports the MSP430 microcontroller used on these
42 boards. MSP430 firmware manages resets and power sequencing,
43 inputs from buttons and the IR remote, LEDs, an RTC, and more.
44
37config HTC_EGPIO 45config HTC_EGPIO
38 bool "HTC EGPIO support" 46 bool "HTC EGPIO support"
39 depends on GENERIC_HARDIRQS && GPIOLIB && ARM 47 depends on GENERIC_HARDIRQS && GPIOLIB && ARM
@@ -61,9 +69,32 @@ config UCB1400_CORE
61 To compile this driver as a module, choose M here: the 69 To compile this driver as a module, choose M here: the
62 module will be called ucb1400_core. 70 module will be called ucb1400_core.
63 71
72config TPS65010
73 tristate "TPS6501x Power Management chips"
74 depends on I2C && GPIOLIB
75 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
76 help
77 If you say yes here you get support for the TPS6501x series of
78 Power Management chips. These include voltage regulators,
79 lithium ion/polymer battery charging, and other features that
80 are often used in portable devices like cell phones and cameras.
81
82 This driver can also be built as a module. If so, the module
83 will be called tps65010.
84
85config MENELAUS
86 bool "Texas Instruments TWL92330/Menelaus PM chip"
87 depends on I2C=y && ARCH_OMAP24XX
88 help
89 If you say yes here you get support for the Texas Instruments
90 TWL92330/Menelaus Power Management chip. This include voltage
91 regulators, Dual slot memory card tranceivers, real-time clock
92 and other features that are often used in portable devices like
93 cell phones and PDAs.
94
64config TWL4030_CORE 95config TWL4030_CORE
65 bool "Texas Instruments TWL4030/TPS659x0 Support" 96 bool "Texas Instruments TWL4030/TPS659x0 Support"
66 depends on I2C=y && GENERIC_HARDIRQS && (ARCH_OMAP2 || ARCH_OMAP3) 97 depends on I2C=y && GENERIC_HARDIRQS
67 help 98 help
68 Say yes here if you have TWL4030 family chip on your board. 99 Say yes here if you have TWL4030 family chip on your board.
69 This core driver provides register access and IRQ handling 100 This core driver provides register access and IRQ handling
@@ -116,6 +147,7 @@ config PMIC_DA903X
116 147
117config MFD_WM8400 148config MFD_WM8400
118 tristate "Support Wolfson Microelectronics WM8400" 149 tristate "Support Wolfson Microelectronics WM8400"
150 select MFD_CORE
119 depends on I2C 151 depends on I2C
120 help 152 help
121 Support for the Wolfson Microelecronics WM8400 PMIC and audio 153 Support for the Wolfson Microelecronics WM8400 PMIC and audio
@@ -142,6 +174,38 @@ config MFD_WM8350_CONFIG_MODE_3
142 bool 174 bool
143 depends on MFD_WM8350 175 depends on MFD_WM8350
144 176
177config MFD_WM8351_CONFIG_MODE_0
178 bool
179 depends on MFD_WM8350
180
181config MFD_WM8351_CONFIG_MODE_1
182 bool
183 depends on MFD_WM8350
184
185config MFD_WM8351_CONFIG_MODE_2
186 bool
187 depends on MFD_WM8350
188
189config MFD_WM8351_CONFIG_MODE_3
190 bool
191 depends on MFD_WM8350
192
193config MFD_WM8352_CONFIG_MODE_0
194 bool
195 depends on MFD_WM8350
196
197config MFD_WM8352_CONFIG_MODE_1
198 bool
199 depends on MFD_WM8350
200
201config MFD_WM8352_CONFIG_MODE_2
202 bool
203 depends on MFD_WM8350
204
205config MFD_WM8352_CONFIG_MODE_3
206 bool
207 depends on MFD_WM8350
208
145config MFD_WM8350_I2C 209config MFD_WM8350_I2C
146 tristate "Support Wolfson Microelectronics WM8350 with I2C" 210 tristate "Support Wolfson Microelectronics WM8350 with I2C"
147 select MFD_WM8350 211 select MFD_WM8350
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 9a5ad8af9116..0c9418b36c26 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -8,6 +8,8 @@ obj-$(CONFIG_MFD_ASIC3) += asic3.o
8obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o 8obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o
9obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o 9obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o
10 10
11obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o
12
11obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o 13obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o
12obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o 14obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o
13obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o 15obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o
@@ -17,6 +19,9 @@ wm8350-objs := wm8350-core.o wm8350-regmap.o wm8350-gpio.o
17obj-$(CONFIG_MFD_WM8350) += wm8350.o 19obj-$(CONFIG_MFD_WM8350) += wm8350.o
18obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o 20obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
19 21
22obj-$(CONFIG_TPS65010) += tps65010.o
23obj-$(CONFIG_MENELAUS) += menelaus.o
24
20obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o 25obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o
21 26
22obj-$(CONFIG_MFD_CORE) += mfd-core.o 27obj-$(CONFIG_MFD_CORE) += mfd-core.o
@@ -31,4 +36,4 @@ obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o
31endif 36endif
32obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o 37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
33 38
34obj-$(CONFIG_PMIC_DA903X) += da903x.o \ No newline at end of file 39obj-$(CONFIG_PMIC_DA903X) += da903x.o
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index 0b5bd85dfcec..99f8dcfe3d98 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -151,12 +151,24 @@ int da903x_write(struct device *dev, int reg, uint8_t val)
151} 151}
152EXPORT_SYMBOL_GPL(da903x_write); 152EXPORT_SYMBOL_GPL(da903x_write);
153 153
154int da903x_writes(struct device *dev, int reg, int len, uint8_t *val)
155{
156 return __da903x_writes(to_i2c_client(dev), reg, len, val);
157}
158EXPORT_SYMBOL_GPL(da903x_writes);
159
154int da903x_read(struct device *dev, int reg, uint8_t *val) 160int da903x_read(struct device *dev, int reg, uint8_t *val)
155{ 161{
156 return __da903x_read(to_i2c_client(dev), reg, val); 162 return __da903x_read(to_i2c_client(dev), reg, val);
157} 163}
158EXPORT_SYMBOL_GPL(da903x_read); 164EXPORT_SYMBOL_GPL(da903x_read);
159 165
166int da903x_reads(struct device *dev, int reg, int len, uint8_t *val)
167{
168 return __da903x_reads(to_i2c_client(dev), reg, len, val);
169}
170EXPORT_SYMBOL_GPL(da903x_reads);
171
160int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask) 172int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask)
161{ 173{
162 struct da903x_chip *chip = dev_get_drvdata(dev); 174 struct da903x_chip *chip = dev_get_drvdata(dev);
@@ -435,13 +447,13 @@ static const struct i2c_device_id da903x_id_table[] = {
435}; 447};
436MODULE_DEVICE_TABLE(i2c, da903x_id_table); 448MODULE_DEVICE_TABLE(i2c, da903x_id_table);
437 449
438static int __devexit __remove_subdev(struct device *dev, void *unused) 450static int __remove_subdev(struct device *dev, void *unused)
439{ 451{
440 platform_device_unregister(to_platform_device(dev)); 452 platform_device_unregister(to_platform_device(dev));
441 return 0; 453 return 0;
442} 454}
443 455
444static int __devexit da903x_remove_subdevs(struct da903x_chip *chip) 456static int da903x_remove_subdevs(struct da903x_chip *chip)
445{ 457{
446 return device_for_each_child(chip->dev, NULL, __remove_subdev); 458 return device_for_each_child(chip->dev, NULL, __remove_subdev);
447} 459}
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
new file mode 100644
index 000000000000..4214b3f72426
--- /dev/null
+++ b/drivers/mfd/dm355evm_msp.c
@@ -0,0 +1,420 @@
1/*
2 * dm355evm_msp.c - driver for MSP430 firmware on DM355EVM board
3 *
4 * Copyright (C) 2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/init.h>
13#include <linux/mutex.h>
14#include <linux/platform_device.h>
15#include <linux/clk.h>
16#include <linux/err.h>
17#include <linux/gpio.h>
18#include <linux/leds.h>
19#include <linux/i2c.h>
20#include <linux/i2c/dm355evm_msp.h>
21
22
23/*
24 * The DM355 is a DaVinci chip with video support but no C64+ DSP. Its
25 * EVM board has an MSP430 programmed with firmware for various board
26 * support functions. This driver exposes some of them directly, and
27 * supports other drivers (e.g. RTC, input) for more complex access.
28 *
29 * Because this firmware is entirely board-specific, this file embeds
30 * knowledge that would be passed as platform_data in a generic driver.
31 *
32 * This driver was tested with firmware revision A4.
33 */
34
35#if defined(CONFIG_KEYBOARD_DM355EVM) \
36 || defined(CONFIG_KEYBOARD_DM355EVM_MODULE)
37#define msp_has_keyboard() true
38#else
39#define msp_has_keyboard() false
40#endif
41
42#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
43#define msp_has_leds() true
44#else
45#define msp_has_leds() false
46#endif
47
48#if defined(CONFIG_RTC_DRV_DM355EVM) || defined(CONFIG_RTC_DRV_DM355EVM_MODULE)
49#define msp_has_rtc() true
50#else
51#define msp_has_rtc() false
52#endif
53
54#if defined(CONFIG_VIDEO_TVP514X) || defined(CONFIG_VIDEO_TVP514X_MODULE)
55#define msp_has_tvp() true
56#else
57#define msp_has_tvp() false
58#endif
59
60
61/*----------------------------------------------------------------------*/
62
63/* REVISIT for paranoia's sake, retry reads/writes on error */
64
65static struct i2c_client *msp430;
66
67/**
68 * dm355evm_msp_write - Writes a register in dm355evm_msp
69 * @value: the value to be written
70 * @reg: register address
71 *
72 * Returns result of operation - 0 is success, else negative errno
73 */
74int dm355evm_msp_write(u8 value, u8 reg)
75{
76 return i2c_smbus_write_byte_data(msp430, reg, value);
77}
78EXPORT_SYMBOL(dm355evm_msp_write);
79
80/**
81 * dm355evm_msp_read - Reads a register from dm355evm_msp
82 * @reg: register address
83 *
84 * Returns result of operation - value, or negative errno
85 */
86int dm355evm_msp_read(u8 reg)
87{
88 return i2c_smbus_read_byte_data(msp430, reg);
89}
90EXPORT_SYMBOL(dm355evm_msp_read);
91
92/*----------------------------------------------------------------------*/
93
94/*
95 * Many of the msp430 pins are just used as fixed-direction GPIOs.
96 * We could export a few more of them this way, if we wanted.
97 */
98#define MSP_GPIO(bit,reg) ((DM355EVM_MSP_ ## reg) << 3 | (bit))
99
100static const u8 msp_gpios[] = {
101 /* eight leds */
102 MSP_GPIO(0, LED), MSP_GPIO(1, LED),
103 MSP_GPIO(2, LED), MSP_GPIO(3, LED),
104 MSP_GPIO(4, LED), MSP_GPIO(5, LED),
105 MSP_GPIO(6, LED), MSP_GPIO(7, LED),
106 /* SW6 and the NTSC/nPAL jumper */
107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1),
108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1),
109 MSP_GPIO(4, SWITCH1),
110};
111
112#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
113#define MSP_GPIO_MASK(offset) BIT(msp_gpios[(offset)] & 0x07)
114
115static int msp_gpio_in(struct gpio_chip *chip, unsigned offset)
116{
117 switch (MSP_GPIO_REG(offset)) {
118 case DM355EVM_MSP_SWITCH1:
119 case DM355EVM_MSP_SWITCH2:
120 case DM355EVM_MSP_SDMMC:
121 return 0;
122 default:
123 return -EINVAL;
124 }
125}
126
127static u8 msp_led_cache;
128
129static int msp_gpio_get(struct gpio_chip *chip, unsigned offset)
130{
131 int reg, status;
132
133 reg = MSP_GPIO_REG(offset);
134 status = dm355evm_msp_read(reg);
135 if (status < 0)
136 return status;
137 if (reg == DM355EVM_MSP_LED)
138 msp_led_cache = status;
139 return status & MSP_GPIO_MASK(offset);
140}
141
142static int msp_gpio_out(struct gpio_chip *chip, unsigned offset, int value)
143{
144 int mask, bits;
145
146 /* NOTE: there are some other signals that could be
147 * packaged as output GPIOs, but they aren't as useful
148 * as the LEDs ... so for now we don't.
149 */
150 if (MSP_GPIO_REG(offset) != DM355EVM_MSP_LED)
151 return -EINVAL;
152
153 mask = MSP_GPIO_MASK(offset);
154 bits = msp_led_cache;
155
156 bits &= ~mask;
157 if (value)
158 bits |= mask;
159 msp_led_cache = bits;
160
161 return dm355evm_msp_write(bits, DM355EVM_MSP_LED);
162}
163
164static void msp_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
165{
166 msp_gpio_out(chip, offset, value);
167}
168
169static struct gpio_chip dm355evm_msp_gpio = {
170 .label = "dm355evm_msp",
171 .owner = THIS_MODULE,
172 .direction_input = msp_gpio_in,
173 .get = msp_gpio_get,
174 .direction_output = msp_gpio_out,
175 .set = msp_gpio_set,
176 .base = -EINVAL, /* dynamic assignment */
177 .ngpio = ARRAY_SIZE(msp_gpios),
178 .can_sleep = true,
179};
180
181/*----------------------------------------------------------------------*/
182
183static struct device *add_child(struct i2c_client *client, const char *name,
184 void *pdata, unsigned pdata_len,
185 bool can_wakeup, int irq)
186{
187 struct platform_device *pdev;
188 int status;
189
190 pdev = platform_device_alloc(name, -1);
191 if (!pdev) {
192 dev_dbg(&client->dev, "can't alloc dev\n");
193 status = -ENOMEM;
194 goto err;
195 }
196
197 device_init_wakeup(&pdev->dev, can_wakeup);
198 pdev->dev.parent = &client->dev;
199
200 if (pdata) {
201 status = platform_device_add_data(pdev, pdata, pdata_len);
202 if (status < 0) {
203 dev_dbg(&pdev->dev, "can't add platform_data\n");
204 goto err;
205 }
206 }
207
208 if (irq) {
209 struct resource r = {
210 .start = irq,
211 .flags = IORESOURCE_IRQ,
212 };
213
214 status = platform_device_add_resources(pdev, &r, 1);
215 if (status < 0) {
216 dev_dbg(&pdev->dev, "can't add irq\n");
217 goto err;
218 }
219 }
220
221 status = platform_device_add(pdev);
222
223err:
224 if (status < 0) {
225 platform_device_put(pdev);
226 dev_err(&client->dev, "can't add %s dev\n", name);
227 return ERR_PTR(status);
228 }
229 return &pdev->dev;
230}
231
232static int add_children(struct i2c_client *client)
233{
234 static const struct {
235 int offset;
236 char *label;
237 } config_inputs[] = {
238 /* 8 == right after the LEDs */
239 { 8 + 0, "sw6_1", },
240 { 8 + 1, "sw6_2", },
241 { 8 + 2, "sw6_3", },
242 { 8 + 3, "sw6_4", },
243 { 8 + 4, "NTSC/nPAL", },
244 };
245
246 struct device *child;
247 int status;
248 int i;
249
250 /* GPIO-ish stuff */
251 dm355evm_msp_gpio.dev = &client->dev;
252 status = gpiochip_add(&dm355evm_msp_gpio);
253 if (status < 0)
254 return status;
255
256 /* LED output */
257 if (msp_has_leds()) {
258#define GPIO_LED(l) .name = l, .active_low = true
259 static struct gpio_led evm_leds[] = {
260 { GPIO_LED("dm355evm::ds14"),
261 .default_trigger = "heartbeat", },
262 { GPIO_LED("dm355evm::ds15"),
263 .default_trigger = "mmc0", },
264 { GPIO_LED("dm355evm::ds16"),
265 /* could also be a CE-ATA drive */
266 .default_trigger = "mmc1", },
267 { GPIO_LED("dm355evm::ds17"),
268 .default_trigger = "nand-disk", },
269 { GPIO_LED("dm355evm::ds18"), },
270 { GPIO_LED("dm355evm::ds19"), },
271 { GPIO_LED("dm355evm::ds20"), },
272 { GPIO_LED("dm355evm::ds21"), },
273 };
274#undef GPIO_LED
275
276 struct gpio_led_platform_data evm_led_data = {
277 .num_leds = ARRAY_SIZE(evm_leds),
278 .leds = evm_leds,
279 };
280
281 for (i = 0; i < ARRAY_SIZE(evm_leds); i++)
282 evm_leds[i].gpio = i + dm355evm_msp_gpio.base;
283
284 /* NOTE: these are the only fully programmable LEDs
285 * on the board, since GPIO-61/ds22 (and many signals
286 * going to DC7) must be used for AEMIF address lines
287 * unless the top 1 GB of NAND is unused...
288 */
289 child = add_child(client, "leds-gpio",
290 &evm_led_data, sizeof(evm_led_data),
291 false, 0);
292 if (IS_ERR(child))
293 return PTR_ERR(child);
294 }
295
296 /* configuration inputs */
297 for (i = 0; i < ARRAY_SIZE(config_inputs); i++) {
298 int gpio = dm355evm_msp_gpio.base + config_inputs[i].offset;
299
300 gpio_request(gpio, config_inputs[i].label);
301 gpio_direction_input(gpio);
302
303 /* make it easy for userspace to see these */
304 gpio_export(gpio, false);
305 }
306
307 /* RTC is a 32 bit counter, no alarm */
308 if (msp_has_rtc()) {
309 child = add_child(client, "rtc-dm355evm",
310 NULL, 0, false, 0);
311 if (IS_ERR(child))
312 return PTR_ERR(child);
313 }
314
315 /* input from buttons and IR remote (uses the IRQ) */
316 if (msp_has_keyboard()) {
317 child = add_child(client, "dm355evm_keys",
318 NULL, 0, true, client->irq);
319 if (IS_ERR(child))
320 return PTR_ERR(child);
321 }
322
323 return 0;
324}
325
326/*----------------------------------------------------------------------*/
327
328static void dm355evm_command(unsigned command)
329{
330 int status;
331
332 status = dm355evm_msp_write(command, DM355EVM_MSP_COMMAND);
333 if (status < 0)
334 dev_err(&msp430->dev, "command %d failure %d\n",
335 command, status);
336}
337
338static void dm355evm_power_off(void)
339{
340 dm355evm_command(MSP_COMMAND_POWEROFF);
341}
342
343static int dm355evm_msp_remove(struct i2c_client *client)
344{
345 pm_power_off = NULL;
346 msp430 = NULL;
347 return 0;
348}
349
350static int
351dm355evm_msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
352{
353 int status;
354 const char *video = msp_has_tvp() ? "TVP5146" : "imager";
355
356 if (msp430)
357 return -EBUSY;
358 msp430 = client;
359
360 /* display revision status; doubles as sanity check */
361 status = dm355evm_msp_read(DM355EVM_MSP_FIRMREV);
362 if (status < 0)
363 goto fail;
364 dev_info(&client->dev, "firmware v.%02X, %s as video-in\n",
365 status, video);
366
367 /* mux video input: either tvp5146 or some external imager */
368 status = dm355evm_msp_write(msp_has_tvp() ? 0 : MSP_VIDEO_IMAGER,
369 DM355EVM_MSP_VIDEO_IN);
370 if (status < 0)
371 dev_warn(&client->dev, "error %d muxing %s as video-in\n",
372 status, video);
373
374 /* init LED cache, and turn off the LEDs */
375 msp_led_cache = 0xff;
376 dm355evm_msp_write(msp_led_cache, DM355EVM_MSP_LED);
377
378 /* export capabilities we support */
379 status = add_children(client);
380 if (status < 0)
381 goto fail;
382
383 /* PM hookup */
384 pm_power_off = dm355evm_power_off;
385
386 return 0;
387
388fail:
389 /* FIXME remove children ... */
390 dm355evm_msp_remove(client);
391 return status;
392}
393
394static const struct i2c_device_id dm355evm_msp_ids[] = {
395 { "dm355evm_msp", 0 },
396 { /* end of list */ },
397};
398MODULE_DEVICE_TABLE(i2c, dm355evm_msp_ids);
399
400static struct i2c_driver dm355evm_msp_driver = {
401 .driver.name = "dm355evm_msp",
402 .id_table = dm355evm_msp_ids,
403 .probe = dm355evm_msp_probe,
404 .remove = dm355evm_msp_remove,
405};
406
407static int __init dm355evm_msp_init(void)
408{
409 return i2c_add_driver(&dm355evm_msp_driver);
410}
411subsys_initcall(dm355evm_msp_init);
412
413static void __exit dm355evm_msp_exit(void)
414{
415 i2c_del_driver(&dm355evm_msp_driver);
416}
417module_exit(dm355evm_msp_exit);
418
419MODULE_DESCRIPTION("Interface to MSP430 firmware on DM355EVM");
420MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/mfd/menelaus.c
index 4b364bae6b3e..4b364bae6b3e 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/mfd/menelaus.c
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 6c0d1bec4b76..54ddf3772e0c 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -34,6 +34,7 @@ static int mfd_add_device(struct device *parent, int id,
34 goto fail_device; 34 goto fail_device;
35 35
36 pdev->dev.parent = parent; 36 pdev->dev.parent = parent;
37 platform_set_drvdata(pdev, cell->driver_data);
37 38
38 ret = platform_device_add_data(pdev, 39 ret = platform_device_add_data(pdev,
39 cell->platform_data, cell->data_size); 40 cell->platform_data, cell->data_size);
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/mfd/tps65010.c
index acf8b9d5f575..acf8b9d5f575 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/mfd/tps65010.c
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index dd843c4fbcc7..b59c385cbc12 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -33,6 +33,8 @@
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/err.h> 34#include <linux/err.h>
35 35
36#include <linux/regulator/machine.h>
37
36#include <linux/i2c.h> 38#include <linux/i2c.h>
37#include <linux/i2c/twl4030.h> 39#include <linux/i2c/twl4030.h>
38 40
@@ -71,6 +73,13 @@
71#define twl_has_gpio() false 73#define twl_has_gpio() false
72#endif 74#endif
73 75
76#if defined(CONFIG_REGULATOR_TWL4030) \
77 || defined(CONFIG_REGULATOR_TWL4030_MODULE)
78#define twl_has_regulator() true
79#else
80#define twl_has_regulator() false
81#endif
82
74#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE) 83#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
75#define twl_has_madc() true 84#define twl_has_madc() true
76#else 85#else
@@ -149,6 +158,10 @@
149#define HIGH_PERF_SQ (1 << 3) 158#define HIGH_PERF_SQ (1 << 3)
150 159
151 160
161/* chip-specific feature flags, for i2c_device_id.driver_data */
162#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */
163#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */
164
152/*----------------------------------------------------------------------*/ 165/*----------------------------------------------------------------------*/
153 166
154/* is driver active, bound to a chip? */ 167/* is driver active, bound to a chip? */
@@ -225,7 +238,7 @@ static struct twl4030mapping twl4030_map[TWL4030_MODULE_LAST + 1] = {
225 * 238 *
226 * Returns the result of operation - 0 is success 239 * Returns the result of operation - 0 is success
227 */ 240 */
228int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes) 241int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
229{ 242{
230 int ret; 243 int ret;
231 int sid; 244 int sid;
@@ -274,7 +287,7 @@ EXPORT_SYMBOL(twl4030_i2c_write);
274 * 287 *
275 * Returns result of operation - num_bytes is success else failure. 288 * Returns result of operation - num_bytes is success else failure.
276 */ 289 */
277int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes) 290int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
278{ 291{
279 int ret; 292 int ret;
280 u8 val; 293 u8 val;
@@ -352,258 +365,258 @@ EXPORT_SYMBOL(twl4030_i2c_read_u8);
352 365
353/*----------------------------------------------------------------------*/ 366/*----------------------------------------------------------------------*/
354 367
355/* 368static struct device *
356 * NOTE: We know the first 8 IRQs after pdata->base_irq are 369add_numbered_child(unsigned chip, const char *name, int num,
357 * for the PIH, and the next are for the PWR_INT SIH, since 370 void *pdata, unsigned pdata_len,
358 * that's how twl_init_irq() sets things up. 371 bool can_wakeup, int irq0, int irq1)
359 */
360
361static int add_children(struct twl4030_platform_data *pdata)
362{ 372{
363 struct platform_device *pdev = NULL; 373 struct platform_device *pdev;
364 struct twl4030_client *twl = NULL; 374 struct twl4030_client *twl = &twl4030_modules[chip];
365 int status = 0; 375 int status;
376
377 pdev = platform_device_alloc(name, num);
378 if (!pdev) {
379 dev_dbg(&twl->client->dev, "can't alloc dev\n");
380 status = -ENOMEM;
381 goto err;
382 }
366 383
367 if (twl_has_bci() && pdata->bci) { 384 device_init_wakeup(&pdev->dev, can_wakeup);
368 twl = &twl4030_modules[3]; 385 pdev->dev.parent = &twl->client->dev;
369 386
370 pdev = platform_device_alloc("twl4030_bci", -1); 387 if (pdata) {
371 if (!pdev) { 388 status = platform_device_add_data(pdev, pdata, pdata_len);
372 pr_debug("%s: can't alloc bci dev\n", DRIVER_NAME); 389 if (status < 0) {
373 status = -ENOMEM; 390 dev_dbg(&pdev->dev, "can't add platform_data\n");
374 goto err; 391 goto err;
375 } 392 }
393 }
376 394
377 if (status == 0) { 395 if (irq0) {
378 pdev->dev.parent = &twl->client->dev; 396 struct resource r[2] = {
379 status = platform_device_add_data(pdev, pdata->bci, 397 { .start = irq0, .flags = IORESOURCE_IRQ, },
380 sizeof(*pdata->bci)); 398 { .start = irq1, .flags = IORESOURCE_IRQ, },
381 if (status < 0) { 399 };
382 dev_dbg(&twl->client->dev,
383 "can't add bci data, %d\n",
384 status);
385 goto err;
386 }
387 }
388
389 if (status == 0) {
390 struct resource r = {
391 .start = pdata->irq_base + 8 + 1,
392 .flags = IORESOURCE_IRQ,
393 };
394
395 status = platform_device_add_resources(pdev, &r, 1);
396 }
397
398 if (status == 0)
399 status = platform_device_add(pdev);
400 400
401 status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
401 if (status < 0) { 402 if (status < 0) {
402 platform_device_put(pdev); 403 dev_dbg(&pdev->dev, "can't add irqs\n");
403 dev_dbg(&twl->client->dev,
404 "can't create bci dev, %d\n",
405 status);
406 goto err; 404 goto err;
407 } 405 }
408 } 406 }
409 407
410 if (twl_has_gpio() && pdata->gpio) { 408 status = platform_device_add(pdev);
411 twl = &twl4030_modules[1];
412 409
413 pdev = platform_device_alloc("twl4030_gpio", -1); 410err:
414 if (!pdev) { 411 if (status < 0) {
415 pr_debug("%s: can't alloc gpio dev\n", DRIVER_NAME); 412 platform_device_put(pdev);
416 status = -ENOMEM; 413 dev_err(&twl->client->dev, "can't add %s dev\n", name);
417 goto err; 414 return ERR_PTR(status);
418 } 415 }
416 return &pdev->dev;
417}
419 418
420 /* more driver model init */ 419static inline struct device *add_child(unsigned chip, const char *name,
421 if (status == 0) { 420 void *pdata, unsigned pdata_len,
422 pdev->dev.parent = &twl->client->dev; 421 bool can_wakeup, int irq0, int irq1)
423 /* device_init_wakeup(&pdev->dev, 1); */ 422{
424 423 return add_numbered_child(chip, name, -1, pdata, pdata_len,
425 status = platform_device_add_data(pdev, pdata->gpio, 424 can_wakeup, irq0, irq1);
426 sizeof(*pdata->gpio)); 425}
427 if (status < 0) {
428 dev_dbg(&twl->client->dev,
429 "can't add gpio data, %d\n",
430 status);
431 goto err;
432 }
433 }
434 426
435 /* GPIO module IRQ */ 427static struct device *
436 if (status == 0) { 428add_regulator_linked(int num, struct regulator_init_data *pdata,
437 struct resource r = { 429 struct regulator_consumer_supply *consumers,
438 .start = pdata->irq_base + 0, 430 unsigned num_consumers)
439 .flags = IORESOURCE_IRQ, 431{
440 }; 432 /* regulator framework demands init_data ... */
433 if (!pdata)
434 return NULL;
441 435
442 status = platform_device_add_resources(pdev, &r, 1); 436 if (consumers) {
443 } 437 pdata->consumer_supplies = consumers;
438 pdata->num_consumer_supplies = num_consumers;
439 }
444 440
445 if (status == 0) 441 /* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */
446 status = platform_device_add(pdev); 442 return add_numbered_child(3, "twl4030_reg", num,
443 pdata, sizeof(*pdata), false, 0, 0);
444}
447 445
448 if (status < 0) { 446static struct device *
449 platform_device_put(pdev); 447add_regulator(int num, struct regulator_init_data *pdata)
450 dev_dbg(&twl->client->dev, 448{
451 "can't create gpio dev, %d\n", 449 return add_regulator_linked(num, pdata, NULL, 0);
452 status); 450}
453 goto err; 451
454 } 452/*
453 * NOTE: We know the first 8 IRQs after pdata->base_irq are
454 * for the PIH, and the next are for the PWR_INT SIH, since
455 * that's how twl_init_irq() sets things up.
456 */
457
458static int
459add_children(struct twl4030_platform_data *pdata, unsigned long features)
460{
461 struct device *child;
462 struct device *usb_transceiver = NULL;
463
464 if (twl_has_bci() && pdata->bci && !(features & TPS_SUBSET)) {
465 child = add_child(3, "twl4030_bci",
466 pdata->bci, sizeof(*pdata->bci),
467 false,
468 /* irq0 = CHG_PRES, irq1 = BCI */
469 pdata->irq_base + 8 + 1, pdata->irq_base + 2);
470 if (IS_ERR(child))
471 return PTR_ERR(child);
472 }
473
474 if (twl_has_gpio() && pdata->gpio) {
475 child = add_child(1, "twl4030_gpio",
476 pdata->gpio, sizeof(*pdata->gpio),
477 false, pdata->irq_base + 0, 0);
478 if (IS_ERR(child))
479 return PTR_ERR(child);
455 } 480 }
456 481
457 if (twl_has_keypad() && pdata->keypad) { 482 if (twl_has_keypad() && pdata->keypad) {
458 pdev = platform_device_alloc("twl4030_keypad", -1); 483 child = add_child(2, "twl4030_keypad",
459 if (pdev) { 484 pdata->keypad, sizeof(*pdata->keypad),
460 twl = &twl4030_modules[2]; 485 true, pdata->irq_base + 1, 0);
461 pdev->dev.parent = &twl->client->dev; 486 if (IS_ERR(child))
462 device_init_wakeup(&pdev->dev, 1); 487 return PTR_ERR(child);
463 status = platform_device_add_data(pdev, pdata->keypad,
464 sizeof(*pdata->keypad));
465 if (status < 0) {
466 dev_dbg(&twl->client->dev,
467 "can't add keypad data, %d\n",
468 status);
469 platform_device_put(pdev);
470 goto err;
471 }
472 status = platform_device_add(pdev);
473 if (status < 0) {
474 platform_device_put(pdev);
475 dev_dbg(&twl->client->dev,
476 "can't create keypad dev, %d\n",
477 status);
478 goto err;
479 }
480 } else {
481 pr_debug("%s: can't alloc keypad dev\n", DRIVER_NAME);
482 status = -ENOMEM;
483 goto err;
484 }
485 } 488 }
486 489
487 if (twl_has_madc() && pdata->madc) { 490 if (twl_has_madc() && pdata->madc) {
488 pdev = platform_device_alloc("twl4030_madc", -1); 491 child = add_child(2, "twl4030_madc",
489 if (pdev) { 492 pdata->madc, sizeof(*pdata->madc),
490 twl = &twl4030_modules[2]; 493 true, pdata->irq_base + 3, 0);
491 pdev->dev.parent = &twl->client->dev; 494 if (IS_ERR(child))
492 device_init_wakeup(&pdev->dev, 1); 495 return PTR_ERR(child);
493 status = platform_device_add_data(pdev, pdata->madc,
494 sizeof(*pdata->madc));
495 if (status < 0) {
496 platform_device_put(pdev);
497 dev_dbg(&twl->client->dev,
498 "can't add madc data, %d\n",
499 status);
500 goto err;
501 }
502 status = platform_device_add(pdev);
503 if (status < 0) {
504 platform_device_put(pdev);
505 dev_dbg(&twl->client->dev,
506 "can't create madc dev, %d\n",
507 status);
508 goto err;
509 }
510 } else {
511 pr_debug("%s: can't alloc madc dev\n", DRIVER_NAME);
512 status = -ENOMEM;
513 goto err;
514 }
515 } 496 }
516 497
517 if (twl_has_rtc()) { 498 if (twl_has_rtc()) {
518 twl = &twl4030_modules[3];
519
520 pdev = platform_device_alloc("twl4030_rtc", -1);
521 if (!pdev) {
522 pr_debug("%s: can't alloc rtc dev\n", DRIVER_NAME);
523 status = -ENOMEM;
524 } else {
525 pdev->dev.parent = &twl->client->dev;
526 device_init_wakeup(&pdev->dev, 1);
527 }
528
529 /* 499 /*
530 * REVISIT platform_data here currently might use of 500 * REVISIT platform_data here currently might expose the
531 * "msecure" line ... but for now we just expect board 501 * "msecure" line ... but for now we just expect board
532 * setup to tell the chip "we are secure" at all times. 502 * setup to tell the chip "it's always ok to SET_TIME".
533 * Eventually, Linux might become more aware of such 503 * Eventually, Linux might become more aware of such
534 * HW security concerns, and "least privilege". 504 * HW security concerns, and "least privilege".
535 */ 505 */
536 506 child = add_child(3, "twl4030_rtc",
537 /* RTC module IRQ */ 507 NULL, 0,
538 if (status == 0) { 508 true, pdata->irq_base + 8 + 3, 0);
539 struct resource r = { 509 if (IS_ERR(child))
540 .start = pdata->irq_base + 8 + 3, 510 return PTR_ERR(child);
541 .flags = IORESOURCE_IRQ,
542 };
543
544 status = platform_device_add_resources(pdev, &r, 1);
545 }
546
547 if (status == 0)
548 status = platform_device_add(pdev);
549
550 if (status < 0) {
551 platform_device_put(pdev);
552 dev_dbg(&twl->client->dev,
553 "can't create rtc dev, %d\n",
554 status);
555 goto err;
556 }
557 } 511 }
558 512
559 if (twl_has_usb() && pdata->usb) { 513 if (twl_has_usb() && pdata->usb) {
560 twl = &twl4030_modules[0]; 514 child = add_child(0, "twl4030_usb",
561 515 pdata->usb, sizeof(*pdata->usb),
562 pdev = platform_device_alloc("twl4030_usb", -1); 516 true,
563 if (!pdev) { 517 /* irq0 = USB_PRES, irq1 = USB */
564 pr_debug("%s: can't alloc usb dev\n", DRIVER_NAME); 518 pdata->irq_base + 8 + 2, pdata->irq_base + 4);
565 status = -ENOMEM; 519 if (IS_ERR(child))
566 goto err; 520 return PTR_ERR(child);
567 } 521
568 522 /* we need to connect regulators to this transceiver */
569 if (status == 0) { 523 usb_transceiver = child;
570 pdev->dev.parent = &twl->client->dev; 524 }
571 device_init_wakeup(&pdev->dev, 1);
572 status = platform_device_add_data(pdev, pdata->usb,
573 sizeof(*pdata->usb));
574 if (status < 0) {
575 platform_device_put(pdev);
576 dev_dbg(&twl->client->dev,
577 "can't add usb data, %d\n",
578 status);
579 goto err;
580 }
581 }
582
583 if (status == 0) {
584 struct resource r = {
585 .start = pdata->irq_base + 8 + 2,
586 .flags = IORESOURCE_IRQ,
587 };
588 525
589 status = platform_device_add_resources(pdev, &r, 1); 526 if (twl_has_regulator()) {
590 } 527 /*
528 child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
529 if (IS_ERR(child))
530 return PTR_ERR(child);
531 */
532
533 child = add_regulator(TWL4030_REG_VMMC1, pdata->vmmc1);
534 if (IS_ERR(child))
535 return PTR_ERR(child);
536
537 child = add_regulator(TWL4030_REG_VDAC, pdata->vdac);
538 if (IS_ERR(child))
539 return PTR_ERR(child);
540
541 child = add_regulator((features & TWL4030_VAUX2)
542 ? TWL4030_REG_VAUX2_4030
543 : TWL4030_REG_VAUX2,
544 pdata->vaux2);
545 if (IS_ERR(child))
546 return PTR_ERR(child);
547 }
591 548
592 if (status == 0) 549 if (twl_has_regulator() && usb_transceiver) {
593 status = platform_device_add(pdev); 550 static struct regulator_consumer_supply usb1v5 = {
551 .supply = "usb1v5",
552 };
553 static struct regulator_consumer_supply usb1v8 = {
554 .supply = "usb1v8",
555 };
556 static struct regulator_consumer_supply usb3v1 = {
557 .supply = "usb3v1",
558 };
559
560 /* this is a template that gets copied */
561 struct regulator_init_data usb_fixed = {
562 .constraints.valid_modes_mask =
563 REGULATOR_MODE_NORMAL
564 | REGULATOR_MODE_STANDBY,
565 .constraints.valid_ops_mask =
566 REGULATOR_CHANGE_MODE
567 | REGULATOR_CHANGE_STATUS,
568 };
569
570 usb1v5.dev = usb_transceiver;
571 usb1v8.dev = usb_transceiver;
572 usb3v1.dev = usb_transceiver;
573
574 child = add_regulator_linked(TWL4030_REG_VUSB1V5, &usb_fixed,
575 &usb1v5, 1);
576 if (IS_ERR(child))
577 return PTR_ERR(child);
578
579 child = add_regulator_linked(TWL4030_REG_VUSB1V8, &usb_fixed,
580 &usb1v8, 1);
581 if (IS_ERR(child))
582 return PTR_ERR(child);
583
584 child = add_regulator_linked(TWL4030_REG_VUSB3V1, &usb_fixed,
585 &usb3v1, 1);
586 if (IS_ERR(child))
587 return PTR_ERR(child);
588 }
594 589
595 if (status < 0) { 590 /* maybe add LDOs that are omitted on cost-reduced parts */
596 platform_device_put(pdev); 591 if (twl_has_regulator() && !(features & TPS_SUBSET)) {
597 dev_dbg(&twl->client->dev, 592 /*
598 "can't create usb dev, %d\n", 593 child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2);
599 status); 594 if (IS_ERR(child))
600 } 595 return PTR_ERR(child);
596 */
597
598 child = add_regulator(TWL4030_REG_VMMC2, pdata->vmmc2);
599 if (IS_ERR(child))
600 return PTR_ERR(child);
601
602 child = add_regulator(TWL4030_REG_VSIM, pdata->vsim);
603 if (IS_ERR(child))
604 return PTR_ERR(child);
605
606 child = add_regulator(TWL4030_REG_VAUX1, pdata->vaux1);
607 if (IS_ERR(child))
608 return PTR_ERR(child);
609
610 child = add_regulator(TWL4030_REG_VAUX3, pdata->vaux3);
611 if (IS_ERR(child))
612 return PTR_ERR(child);
613
614 child = add_regulator(TWL4030_REG_VAUX4, pdata->vaux4);
615 if (IS_ERR(child))
616 return PTR_ERR(child);
601 } 617 }
602 618
603err: 619 return 0;
604 if (status)
605 pr_err("failed to add twl4030's children (status %d)\n", status);
606 return status;
607} 620}
608 621
609/*----------------------------------------------------------------------*/ 622/*----------------------------------------------------------------------*/
@@ -645,12 +658,7 @@ static void __init clocks_init(void)
645 osc = clk_get(NULL, "osc_ck"); 658 osc = clk_get(NULL, "osc_ck");
646 else 659 else
647 osc = clk_get(NULL, "osc_sys_ck"); 660 osc = clk_get(NULL, "osc_sys_ck");
648#else 661
649 /* REVISIT for non-OMAP systems, pass the clock rate from
650 * board init code, using platform_data.
651 */
652 osc = ERR_PTR(-EIO);
653#endif
654 if (IS_ERR(osc)) { 662 if (IS_ERR(osc)) {
655 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 663 printk(KERN_WARNING "Skipping twl4030 internal clock init and "
656 "using bootloader value (unknown osc rate)\n"); 664 "using bootloader value (unknown osc rate)\n");
@@ -660,6 +668,18 @@ static void __init clocks_init(void)
660 rate = clk_get_rate(osc); 668 rate = clk_get_rate(osc);
661 clk_put(osc); 669 clk_put(osc);
662 670
671#else
672 /* REVISIT for non-OMAP systems, pass the clock rate from
673 * board init code, using platform_data.
674 */
675 osc = ERR_PTR(-EIO);
676
677 printk(KERN_WARNING "Skipping twl4030 internal clock init and "
678 "using bootloader value (unknown osc rate)\n");
679
680 return;
681#endif
682
663 switch (rate) { 683 switch (rate) {
664 case 19200000: 684 case 19200000:
665 ctrl = HFCLK_FREQ_19p2_MHZ; 685 ctrl = HFCLK_FREQ_19p2_MHZ;
@@ -764,7 +784,7 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
764 goto fail; 784 goto fail;
765 } 785 }
766 786
767 status = add_children(pdata); 787 status = add_children(pdata, id->driver_data);
768fail: 788fail:
769 if (status < 0) 789 if (status < 0)
770 twl4030_remove(client); 790 twl4030_remove(client);
@@ -772,11 +792,11 @@ fail:
772} 792}
773 793
774static const struct i2c_device_id twl4030_ids[] = { 794static const struct i2c_device_id twl4030_ids[] = {
775 { "twl4030", 0 }, /* "Triton 2" */ 795 { "twl4030", TWL4030_VAUX2 }, /* "Triton 2" */
776 { "tps65950", 0 }, /* catalog version of twl4030 */ 796 { "twl5030", 0 }, /* T2 updated */
777 { "tps65930", 0 }, /* fewer LDOs and DACs; no charger */ 797 { "tps65950", 0 }, /* catalog version of twl5030 */
778 { "tps65920", 0 }, /* fewer LDOs; no codec or charger */ 798 { "tps65930", TPS_SUBSET }, /* fewer LDOs and DACs; no charger */
779 { "twl5030", 0 }, /* T2 updated */ 799 { "tps65920", TPS_SUBSET }, /* fewer LDOs; no codec or charger */
780 { /* end of list */ }, 800 { /* end of list */ },
781}; 801};
782MODULE_DEVICE_TABLE(i2c, twl4030_ids); 802MODULE_DEVICE_TABLE(i2c, twl4030_ids);
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index fae868a8d499..b10876036983 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -180,10 +180,15 @@ static struct completion irq_event;
180static int twl4030_irq_thread(void *data) 180static int twl4030_irq_thread(void *data)
181{ 181{
182 long irq = (long)data; 182 long irq = (long)data;
183 irq_desc_t *desc = irq_desc + irq; 183 struct irq_desc *desc = irq_to_desc(irq);
184 static unsigned i2c_errors; 184 static unsigned i2c_errors;
185 const static unsigned max_i2c_errors = 100; 185 const static unsigned max_i2c_errors = 100;
186 186
187 if (!desc) {
188 pr_err("twl4030: Invalid IRQ: %ld\n", irq);
189 return -EINVAL;
190 }
191
187 current->flags |= PF_NOFREEZE; 192 current->flags |= PF_NOFREEZE;
188 193
189 while (!kthread_should_stop()) { 194 while (!kthread_should_stop()) {
@@ -215,7 +220,13 @@ static int twl4030_irq_thread(void *data)
215 pih_isr; 220 pih_isr;
216 pih_isr >>= 1, module_irq++) { 221 pih_isr >>= 1, module_irq++) {
217 if (pih_isr & 0x1) { 222 if (pih_isr & 0x1) {
218 irq_desc_t *d = irq_desc + module_irq; 223 struct irq_desc *d = irq_to_desc(module_irq);
224
225 if (!d) {
226 pr_err("twl4030: Invalid SIH IRQ: %d\n",
227 module_irq);
228 return -EINVAL;
229 }
219 230
220 /* These can't be masked ... always warn 231 /* These can't be masked ... always warn
221 * if we get any surprises. 232 * if we get any surprises.
@@ -452,10 +463,16 @@ static void twl4030_sih_do_edge(struct work_struct *work)
452 /* Modify only the bits we know must change */ 463 /* Modify only the bits we know must change */
453 while (edge_change) { 464 while (edge_change) {
454 int i = fls(edge_change) - 1; 465 int i = fls(edge_change) - 1;
455 struct irq_desc *d = irq_desc + i + agent->irq_base; 466 struct irq_desc *d = irq_to_desc(i + agent->irq_base);
456 int byte = 1 + (i >> 2); 467 int byte = 1 + (i >> 2);
457 int off = (i & 0x3) * 2; 468 int off = (i & 0x3) * 2;
458 469
470 if (!d) {
471 pr_err("twl4030: Invalid IRQ: %d\n",
472 i + agent->irq_base);
473 return;
474 }
475
459 bytes[byte] &= ~(0x03 << off); 476 bytes[byte] &= ~(0x03 << off);
460 477
461 spin_lock_irq(&d->lock); 478 spin_lock_irq(&d->lock);
@@ -512,9 +529,14 @@ static void twl4030_sih_unmask(unsigned irq)
512static int twl4030_sih_set_type(unsigned irq, unsigned trigger) 529static int twl4030_sih_set_type(unsigned irq, unsigned trigger)
513{ 530{
514 struct sih_agent *sih = get_irq_chip_data(irq); 531 struct sih_agent *sih = get_irq_chip_data(irq);
515 struct irq_desc *desc = irq_desc + irq; 532 struct irq_desc *desc = irq_to_desc(irq);
516 unsigned long flags; 533 unsigned long flags;
517 534
535 if (!desc) {
536 pr_err("twl4030: Invalid IRQ: %d\n", irq);
537 return -EINVAL;
538 }
539
518 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) 540 if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
519 return -EINVAL; 541 return -EINVAL;
520 542
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 0d47fb9e4b3b..3a273ccef3f2 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -63,7 +63,6 @@
63 */ 63 */
64static DEFINE_MUTEX(io_mutex); 64static DEFINE_MUTEX(io_mutex);
65static DEFINE_MUTEX(reg_lock_mutex); 65static DEFINE_MUTEX(reg_lock_mutex);
66static DEFINE_MUTEX(auxadc_mutex);
67 66
68/* Perform a physical read from the device. 67/* Perform a physical read from the device.
69 */ 68 */
@@ -299,6 +298,13 @@ int wm8350_block_write(struct wm8350 *wm8350, int start_reg, int regs,
299} 298}
300EXPORT_SYMBOL_GPL(wm8350_block_write); 299EXPORT_SYMBOL_GPL(wm8350_block_write);
301 300
301/**
302 * wm8350_reg_lock()
303 *
304 * The WM8350 has a hardware lock which can be used to prevent writes to
305 * some registers (generally those which can cause particularly serious
306 * problems if misused). This function enables that lock.
307 */
302int wm8350_reg_lock(struct wm8350 *wm8350) 308int wm8350_reg_lock(struct wm8350 *wm8350)
303{ 309{
304 u16 key = WM8350_LOCK_KEY; 310 u16 key = WM8350_LOCK_KEY;
@@ -314,6 +320,15 @@ int wm8350_reg_lock(struct wm8350 *wm8350)
314} 320}
315EXPORT_SYMBOL_GPL(wm8350_reg_lock); 321EXPORT_SYMBOL_GPL(wm8350_reg_lock);
316 322
323/**
324 * wm8350_reg_unlock()
325 *
326 * The WM8350 has a hardware lock which can be used to prevent writes to
327 * some registers (generally those which can cause particularly serious
328 * problems if misused). This function disables that lock so updates
329 * can be performed. For maximum safety this should be done only when
330 * required.
331 */
317int wm8350_reg_unlock(struct wm8350 *wm8350) 332int wm8350_reg_unlock(struct wm8350 *wm8350)
318{ 333{
319 u16 key = WM8350_UNLOCK_KEY; 334 u16 key = WM8350_UNLOCK_KEY;
@@ -1066,38 +1081,158 @@ int wm8350_unmask_irq(struct wm8350 *wm8350, int irq)
1066} 1081}
1067EXPORT_SYMBOL_GPL(wm8350_unmask_irq); 1082EXPORT_SYMBOL_GPL(wm8350_unmask_irq);
1068 1083
1084int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref)
1085{
1086 u16 reg, result = 0;
1087 int tries = 5;
1088
1089 if (channel < WM8350_AUXADC_AUX1 || channel > WM8350_AUXADC_TEMP)
1090 return -EINVAL;
1091 if (channel >= WM8350_AUXADC_USB && channel <= WM8350_AUXADC_TEMP
1092 && (scale != 0 || vref != 0))
1093 return -EINVAL;
1094
1095 mutex_lock(&wm8350->auxadc_mutex);
1096
1097 /* Turn on the ADC */
1098 reg = wm8350_reg_read(wm8350, WM8350_POWER_MGMT_5);
1099 wm8350_reg_write(wm8350, WM8350_POWER_MGMT_5, reg | WM8350_AUXADC_ENA);
1100
1101 if (scale || vref) {
1102 reg = scale << 13;
1103 reg |= vref << 12;
1104 wm8350_reg_write(wm8350, WM8350_AUX1_READBACK + channel, reg);
1105 }
1106
1107 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1);
1108 reg |= 1 << channel | WM8350_AUXADC_POLL;
1109 wm8350_reg_write(wm8350, WM8350_DIGITISER_CONTROL_1, reg);
1110
1111 do {
1112 schedule_timeout_interruptible(1);
1113 reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1);
1114 } while (tries-- && (reg & WM8350_AUXADC_POLL));
1115
1116 if (!tries)
1117 dev_err(wm8350->dev, "adc chn %d read timeout\n", channel);
1118 else
1119 result = wm8350_reg_read(wm8350,
1120 WM8350_AUX1_READBACK + channel);
1121
1122 /* Turn off the ADC */
1123 reg = wm8350_reg_read(wm8350, WM8350_POWER_MGMT_5);
1124 wm8350_reg_write(wm8350, WM8350_POWER_MGMT_5,
1125 reg & ~WM8350_AUXADC_ENA);
1126
1127 mutex_unlock(&wm8350->auxadc_mutex);
1128
1129 return result & WM8350_AUXADC_DATA1_MASK;
1130}
1131EXPORT_SYMBOL_GPL(wm8350_read_auxadc);
1132
1069/* 1133/*
1070 * Cache is always host endian. 1134 * Cache is always host endian.
1071 */ 1135 */
1072static int wm8350_create_cache(struct wm8350 *wm8350, int mode) 1136static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode)
1073{ 1137{
1074 int i, ret = 0; 1138 int i, ret = 0;
1075 u16 value; 1139 u16 value;
1076 const u16 *reg_map; 1140 const u16 *reg_map;
1077 1141
1078 switch (mode) { 1142 switch (type) {
1079#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
1080 case 0: 1143 case 0:
1081 reg_map = wm8350_mode0_defaults; 1144 switch (mode) {
1082 break; 1145#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
1146 case 0:
1147 reg_map = wm8350_mode0_defaults;
1148 break;
1083#endif 1149#endif
1084#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1 1150#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1
1085 case 1: 1151 case 1:
1086 reg_map = wm8350_mode1_defaults; 1152 reg_map = wm8350_mode1_defaults;
1087 break; 1153 break;
1088#endif 1154#endif
1089#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2 1155#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2
1090 case 2: 1156 case 2:
1091 reg_map = wm8350_mode2_defaults; 1157 reg_map = wm8350_mode2_defaults;
1092 break; 1158 break;
1093#endif 1159#endif
1094#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3 1160#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3
1095 case 3: 1161 case 3:
1096 reg_map = wm8350_mode3_defaults; 1162 reg_map = wm8350_mode3_defaults;
1163 break;
1164#endif
1165 default:
1166 dev_err(wm8350->dev,
1167 "WM8350 configuration mode %d not supported\n",
1168 mode);
1169 return -EINVAL;
1170 }
1171 break;
1172
1173 case 1:
1174 switch (mode) {
1175#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_0
1176 case 0:
1177 reg_map = wm8351_mode0_defaults;
1178 break;
1179#endif
1180#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_1
1181 case 1:
1182 reg_map = wm8351_mode1_defaults;
1183 break;
1184#endif
1185#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_2
1186 case 2:
1187 reg_map = wm8351_mode2_defaults;
1188 break;
1189#endif
1190#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_3
1191 case 3:
1192 reg_map = wm8351_mode3_defaults;
1193 break;
1194#endif
1195 default:
1196 dev_err(wm8350->dev,
1197 "WM8351 configuration mode %d not supported\n",
1198 mode);
1199 return -EINVAL;
1200 }
1097 break; 1201 break;
1202
1203 case 2:
1204 switch (mode) {
1205#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_0
1206 case 0:
1207 reg_map = wm8352_mode0_defaults;
1208 break;
1209#endif
1210#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_1
1211 case 1:
1212 reg_map = wm8352_mode1_defaults;
1213 break;
1098#endif 1214#endif
1215#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_2
1216 case 2:
1217 reg_map = wm8352_mode2_defaults;
1218 break;
1219#endif
1220#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_3
1221 case 3:
1222 reg_map = wm8352_mode3_defaults;
1223 break;
1224#endif
1225 default:
1226 dev_err(wm8350->dev,
1227 "WM8352 configuration mode %d not supported\n",
1228 mode);
1229 return -EINVAL;
1230 }
1231 break;
1232
1099 default: 1233 default:
1100 dev_err(wm8350->dev, "Configuration mode %d not supported\n", 1234 dev_err(wm8350->dev,
1235 "WM835x configuration mode %d not supported\n",
1101 mode); 1236 mode);
1102 return -EINVAL; 1237 return -EINVAL;
1103 } 1238 }
@@ -1163,53 +1298,113 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1163 struct wm8350_platform_data *pdata) 1298 struct wm8350_platform_data *pdata)
1164{ 1299{
1165 int ret = -EINVAL; 1300 int ret = -EINVAL;
1166 u16 id1, id2, mask, mode; 1301 u16 id1, id2, mask_rev;
1302 u16 cust_id, mode, chip_rev;
1167 1303
1168 /* get WM8350 revision and config mode */ 1304 /* get WM8350 revision and config mode */
1169 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); 1305 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1);
1170 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2); 1306 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2);
1307 wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev), &mask_rev);
1171 1308
1172 id1 = be16_to_cpu(id1); 1309 id1 = be16_to_cpu(id1);
1173 id2 = be16_to_cpu(id2); 1310 id2 = be16_to_cpu(id2);
1311 mask_rev = be16_to_cpu(mask_rev);
1174 1312
1175 if (id1 == 0x6143) { 1313 if (id1 != 0x6143) {
1176 switch ((id2 & WM8350_CHIP_REV_MASK) >> 12) { 1314 dev_err(wm8350->dev,
1315 "Device with ID %x is not a WM8350\n", id1);
1316 ret = -ENODEV;
1317 goto err;
1318 }
1319
1320 mode = id2 & WM8350_CONF_STS_MASK >> 10;
1321 cust_id = id2 & WM8350_CUST_ID_MASK;
1322 chip_rev = (id2 & WM8350_CHIP_REV_MASK) >> 12;
1323 dev_info(wm8350->dev,
1324 "CONF_STS %d, CUST_ID %d, MASK_REV %d, CHIP_REV %d\n",
1325 mode, cust_id, mask_rev, chip_rev);
1326
1327 if (cust_id != 0) {
1328 dev_err(wm8350->dev, "Unsupported CUST_ID\n");
1329 ret = -ENODEV;
1330 goto err;
1331 }
1332
1333 switch (mask_rev) {
1334 case 0:
1335 wm8350->pmic.max_dcdc = WM8350_DCDC_6;
1336 wm8350->pmic.max_isink = WM8350_ISINK_B;
1337
1338 switch (chip_rev) {
1177 case WM8350_REV_E: 1339 case WM8350_REV_E:
1178 dev_info(wm8350->dev, "Found Rev E device\n"); 1340 dev_info(wm8350->dev, "WM8350 Rev E\n");
1179 wm8350->rev = WM8350_REV_E;
1180 break; 1341 break;
1181 case WM8350_REV_F: 1342 case WM8350_REV_F:
1182 dev_info(wm8350->dev, "Found Rev F device\n"); 1343 dev_info(wm8350->dev, "WM8350 Rev F\n");
1183 wm8350->rev = WM8350_REV_F;
1184 break; 1344 break;
1185 case WM8350_REV_G: 1345 case WM8350_REV_G:
1186 dev_info(wm8350->dev, "Found Rev G device\n"); 1346 dev_info(wm8350->dev, "WM8350 Rev G\n");
1187 wm8350->rev = WM8350_REV_G; 1347 wm8350->power.rev_g_coeff = 1;
1348 break;
1349 case WM8350_REV_H:
1350 dev_info(wm8350->dev, "WM8350 Rev H\n");
1351 wm8350->power.rev_g_coeff = 1;
1188 break; 1352 break;
1189 default: 1353 default:
1190 /* For safety we refuse to run on unknown hardware */ 1354 /* For safety we refuse to run on unknown hardware */
1191 dev_info(wm8350->dev, "Found unknown rev\n"); 1355 dev_err(wm8350->dev, "Unknown WM8350 CHIP_REV\n");
1192 ret = -ENODEV; 1356 ret = -ENODEV;
1193 goto err; 1357 goto err;
1194 } 1358 }
1195 } else { 1359 break;
1196 dev_info(wm8350->dev, "Device with ID %x is not a WM8350\n", 1360
1197 id1); 1361 case 1:
1362 wm8350->pmic.max_dcdc = WM8350_DCDC_4;
1363 wm8350->pmic.max_isink = WM8350_ISINK_A;
1364
1365 switch (chip_rev) {
1366 case 0:
1367 dev_info(wm8350->dev, "WM8351 Rev A\n");
1368 wm8350->power.rev_g_coeff = 1;
1369 break;
1370
1371 default:
1372 dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n");
1373 ret = -ENODEV;
1374 goto err;
1375 }
1376 break;
1377
1378 case 2:
1379 wm8350->pmic.max_dcdc = WM8350_DCDC_6;
1380 wm8350->pmic.max_isink = WM8350_ISINK_B;
1381
1382 switch (chip_rev) {
1383 case 0:
1384 dev_info(wm8350->dev, "WM8352 Rev A\n");
1385 wm8350->power.rev_g_coeff = 1;
1386 break;
1387
1388 default:
1389 dev_err(wm8350->dev, "Unknown WM8352 CHIP_REV\n");
1390 ret = -ENODEV;
1391 goto err;
1392 }
1393 break;
1394
1395 default:
1396 dev_err(wm8350->dev, "Unknown MASK_REV\n");
1198 ret = -ENODEV; 1397 ret = -ENODEV;
1199 goto err; 1398 goto err;
1200 } 1399 }
1201 1400
1202 mode = id2 & WM8350_CONF_STS_MASK >> 10; 1401 ret = wm8350_create_cache(wm8350, mask_rev, mode);
1203 mask = id2 & WM8350_CUST_ID_MASK;
1204 dev_info(wm8350->dev, "Config mode %d, ROM mask %d\n", mode, mask);
1205
1206 ret = wm8350_create_cache(wm8350, mode);
1207 if (ret < 0) { 1402 if (ret < 0) {
1208 printk(KERN_ERR "wm8350: failed to create register cache\n"); 1403 dev_err(wm8350->dev, "Failed to create register cache\n");
1209 return ret; 1404 return ret;
1210 } 1405 }
1211 1406
1212 if (pdata->init) { 1407 if (pdata && pdata->init) {
1213 ret = pdata->init(wm8350); 1408 ret = pdata->init(wm8350);
1214 if (ret != 0) { 1409 if (ret != 0) {
1215 dev_err(wm8350->dev, "Platform init() failed: %d\n", 1410 dev_err(wm8350->dev, "Platform init() failed: %d\n",
@@ -1218,6 +1413,7 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1218 } 1413 }
1219 } 1414 }
1220 1415
1416 mutex_init(&wm8350->auxadc_mutex);
1221 mutex_init(&wm8350->irq_mutex); 1417 mutex_init(&wm8350->irq_mutex);
1222 INIT_WORK(&wm8350->irq_work, wm8350_irq_worker); 1418 INIT_WORK(&wm8350->irq_work, wm8350_irq_worker);
1223 if (irq) { 1419 if (irq) {
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 3e0ce0e50ea2..8d8c93217572 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC 2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
3 * 3 *
4 * This driver defines and configures the WM8350 for the Freescale i.MX32ADS.
5 *
6 * Copyright 2007, 2008 Wolfson Microelectronics PLC. 4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
7 * 5 *
8 * Author: Liam Girdwood 6 * Author: Liam Girdwood
@@ -99,6 +97,8 @@ static int wm8350_i2c_remove(struct i2c_client *i2c)
99 97
100static const struct i2c_device_id wm8350_i2c_id[] = { 98static const struct i2c_device_id wm8350_i2c_id[] = {
101 { "wm8350", 0 }, 99 { "wm8350", 0 },
100 { "wm8351", 0 },
101 { "wm8352", 0 },
102 { } 102 { }
103}; 103};
104MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id); 104MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index 974678db22cd..68887b817d17 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -1074,6 +1074,2102 @@ const u16 wm8350_mode3_defaults[] = {
1074}; 1074};
1075#endif 1075#endif
1076 1076
1077#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_0
1078
1079#undef WM8350_HAVE_CONFIG_MODE
1080#define WM8350_HAVE_CONFIG_MODE
1081
1082const u16 wm8351_mode0_defaults[] = {
1083 0x6143, /* R0 - Reset/ID */
1084 0x0000, /* R1 - ID */
1085 0x0001, /* R2 - Revision */
1086 0x1C02, /* R3 - System Control 1 */
1087 0x0004, /* R4 - System Control 2 */
1088 0x0000, /* R5 - System Hibernate */
1089 0x8A00, /* R6 - Interface Control */
1090 0x0000, /* R7 */
1091 0x8000, /* R8 - Power mgmt (1) */
1092 0x0000, /* R9 - Power mgmt (2) */
1093 0x0000, /* R10 - Power mgmt (3) */
1094 0x2000, /* R11 - Power mgmt (4) */
1095 0x0E00, /* R12 - Power mgmt (5) */
1096 0x0000, /* R13 - Power mgmt (6) */
1097 0x0000, /* R14 - Power mgmt (7) */
1098 0x0000, /* R15 */
1099 0x0000, /* R16 - RTC Seconds/Minutes */
1100 0x0100, /* R17 - RTC Hours/Day */
1101 0x0101, /* R18 - RTC Date/Month */
1102 0x1400, /* R19 - RTC Year */
1103 0x0000, /* R20 - Alarm Seconds/Minutes */
1104 0x0000, /* R21 - Alarm Hours/Day */
1105 0x0000, /* R22 - Alarm Date/Month */
1106 0x0320, /* R23 - RTC Time Control */
1107 0x0000, /* R24 - System Interrupts */
1108 0x0000, /* R25 - Interrupt Status 1 */
1109 0x0000, /* R26 - Interrupt Status 2 */
1110 0x0000, /* R27 */
1111 0x0000, /* R28 - Under Voltage Interrupt status */
1112 0x0000, /* R29 - Over Current Interrupt status */
1113 0x0000, /* R30 - GPIO Interrupt Status */
1114 0x0000, /* R31 - Comparator Interrupt Status */
1115 0x3FFF, /* R32 - System Interrupts Mask */
1116 0x0000, /* R33 - Interrupt Status 1 Mask */
1117 0x0000, /* R34 - Interrupt Status 2 Mask */
1118 0x0000, /* R35 */
1119 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1120 0x0000, /* R37 - Over Current Interrupt status Mask */
1121 0x0000, /* R38 - GPIO Interrupt Status Mask */
1122 0x0000, /* R39 - Comparator Interrupt Status Mask */
1123 0x0040, /* R40 - Clock Control 1 */
1124 0x0000, /* R41 - Clock Control 2 */
1125 0x3A00, /* R42 - FLL Control 1 */
1126 0x7086, /* R43 - FLL Control 2 */
1127 0xC226, /* R44 - FLL Control 3 */
1128 0x0000, /* R45 - FLL Control 4 */
1129 0x0000, /* R46 */
1130 0x0000, /* R47 */
1131 0x0000, /* R48 - DAC Control */
1132 0x0000, /* R49 */
1133 0x00C0, /* R50 - DAC Digital Volume L */
1134 0x00C0, /* R51 - DAC Digital Volume R */
1135 0x0000, /* R52 */
1136 0x0040, /* R53 - DAC LR Rate */
1137 0x0000, /* R54 - DAC Clock Control */
1138 0x0000, /* R55 */
1139 0x0000, /* R56 */
1140 0x0000, /* R57 */
1141 0x4000, /* R58 - DAC Mute */
1142 0x0000, /* R59 - DAC Mute Volume */
1143 0x0000, /* R60 - DAC Side */
1144 0x0000, /* R61 */
1145 0x0000, /* R62 */
1146 0x0000, /* R63 */
1147 0x8000, /* R64 - ADC Control */
1148 0x0000, /* R65 */
1149 0x00C0, /* R66 - ADC Digital Volume L */
1150 0x00C0, /* R67 - ADC Digital Volume R */
1151 0x0000, /* R68 - ADC Divider */
1152 0x0000, /* R69 */
1153 0x0040, /* R70 - ADC LR Rate */
1154 0x0000, /* R71 */
1155 0x0303, /* R72 - Input Control */
1156 0x0000, /* R73 - IN3 Input Control */
1157 0x0000, /* R74 - Mic Bias Control */
1158 0x0000, /* R75 */
1159 0x0000, /* R76 - Output Control */
1160 0x0000, /* R77 - Jack Detect */
1161 0x0000, /* R78 - Anti Pop Control */
1162 0x0000, /* R79 */
1163 0x0040, /* R80 - Left Input Volume */
1164 0x0040, /* R81 - Right Input Volume */
1165 0x0000, /* R82 */
1166 0x0000, /* R83 */
1167 0x0000, /* R84 */
1168 0x0000, /* R85 */
1169 0x0000, /* R86 */
1170 0x0000, /* R87 */
1171 0x0800, /* R88 - Left Mixer Control */
1172 0x1000, /* R89 - Right Mixer Control */
1173 0x0000, /* R90 */
1174 0x0000, /* R91 */
1175 0x0000, /* R92 - OUT3 Mixer Control */
1176 0x0000, /* R93 - OUT4 Mixer Control */
1177 0x0000, /* R94 */
1178 0x0000, /* R95 */
1179 0x0000, /* R96 - Output Left Mixer Volume */
1180 0x0000, /* R97 - Output Right Mixer Volume */
1181 0x0000, /* R98 - Input Mixer Volume L */
1182 0x0000, /* R99 - Input Mixer Volume R */
1183 0x0000, /* R100 - Input Mixer Volume */
1184 0x0000, /* R101 */
1185 0x0000, /* R102 */
1186 0x0000, /* R103 */
1187 0x00E4, /* R104 - OUT1L Volume */
1188 0x00E4, /* R105 - OUT1R Volume */
1189 0x00E4, /* R106 - OUT2L Volume */
1190 0x02E4, /* R107 - OUT2R Volume */
1191 0x0000, /* R108 */
1192 0x0000, /* R109 */
1193 0x0000, /* R110 */
1194 0x0000, /* R111 - BEEP Volume */
1195 0x0A00, /* R112 - AI Formating */
1196 0x0000, /* R113 - ADC DAC COMP */
1197 0x0020, /* R114 - AI ADC Control */
1198 0x0020, /* R115 - AI DAC Control */
1199 0x0000, /* R116 */
1200 0x0000, /* R117 */
1201 0x0000, /* R118 */
1202 0x0000, /* R119 */
1203 0x0000, /* R120 */
1204 0x0000, /* R121 */
1205 0x0000, /* R122 */
1206 0x0000, /* R123 */
1207 0x0000, /* R124 */
1208 0x0000, /* R125 */
1209 0x0000, /* R126 */
1210 0x0000, /* R127 */
1211 0x1FFF, /* R128 - GPIO Debounce */
1212 0x0000, /* R129 - GPIO Pin pull up Control */
1213 0x0000, /* R130 - GPIO Pull down Control */
1214 0x0000, /* R131 - GPIO Interrupt Mode */
1215 0x0000, /* R132 */
1216 0x0000, /* R133 - GPIO Control */
1217 0x0FFC, /* R134 - GPIO Configuration (i/o) */
1218 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
1219 0x0000, /* R136 */
1220 0x0000, /* R137 */
1221 0x0000, /* R138 */
1222 0x0000, /* R139 */
1223 0x0013, /* R140 - GPIO Function Select 1 */
1224 0x0000, /* R141 - GPIO Function Select 2 */
1225 0x0000, /* R142 - GPIO Function Select 3 */
1226 0x0003, /* R143 - GPIO Function Select 4 */
1227 0x0000, /* R144 - Digitiser Control (1) */
1228 0x0002, /* R145 - Digitiser Control (2) */
1229 0x0000, /* R146 */
1230 0x0000, /* R147 */
1231 0x0000, /* R148 */
1232 0x0000, /* R149 */
1233 0x0000, /* R150 */
1234 0x0000, /* R151 */
1235 0x7000, /* R152 - AUX1 Readback */
1236 0x7000, /* R153 - AUX2 Readback */
1237 0x7000, /* R154 - AUX3 Readback */
1238 0x7000, /* R155 - AUX4 Readback */
1239 0x0000, /* R156 - USB Voltage Readback */
1240 0x0000, /* R157 - LINE Voltage Readback */
1241 0x0000, /* R158 - BATT Voltage Readback */
1242 0x0000, /* R159 - Chip Temp Readback */
1243 0x0000, /* R160 */
1244 0x0000, /* R161 */
1245 0x0000, /* R162 */
1246 0x0000, /* R163 - Generic Comparator Control */
1247 0x0000, /* R164 - Generic comparator 1 */
1248 0x0000, /* R165 - Generic comparator 2 */
1249 0x0000, /* R166 - Generic comparator 3 */
1250 0x0000, /* R167 - Generic comparator 4 */
1251 0xA00F, /* R168 - Battery Charger Control 1 */
1252 0x0B06, /* R169 - Battery Charger Control 2 */
1253 0x0000, /* R170 - Battery Charger Control 3 */
1254 0x0000, /* R171 */
1255 0x0000, /* R172 - Current Sink Driver A */
1256 0x0000, /* R173 - CSA Flash control */
1257 0x0000, /* R174 */
1258 0x0000, /* R175 */
1259 0x0000, /* R176 - DCDC/LDO requested */
1260 0x032D, /* R177 - DCDC Active options */
1261 0x0000, /* R178 - DCDC Sleep options */
1262 0x0025, /* R179 - Power-check comparator */
1263 0x000E, /* R180 - DCDC1 Control */
1264 0x0000, /* R181 - DCDC1 Timeouts */
1265 0x1006, /* R182 - DCDC1 Low Power */
1266 0x0018, /* R183 - DCDC2 Control */
1267 0x0000, /* R184 - DCDC2 Timeouts */
1268 0x0000, /* R185 */
1269 0x0000, /* R186 - DCDC3 Control */
1270 0x0000, /* R187 - DCDC3 Timeouts */
1271 0x0006, /* R188 - DCDC3 Low Power */
1272 0x0000, /* R189 - DCDC4 Control */
1273 0x0000, /* R190 - DCDC4 Timeouts */
1274 0x0006, /* R191 - DCDC4 Low Power */
1275 0x0008, /* R192 */
1276 0x0000, /* R193 */
1277 0x0000, /* R194 */
1278 0x0000, /* R195 */
1279 0x0000, /* R196 */
1280 0x0006, /* R197 */
1281 0x0000, /* R198 */
1282 0x0003, /* R199 - Limit Switch Control */
1283 0x001C, /* R200 - LDO1 Control */
1284 0x0000, /* R201 - LDO1 Timeouts */
1285 0x001C, /* R202 - LDO1 Low Power */
1286 0x001B, /* R203 - LDO2 Control */
1287 0x0000, /* R204 - LDO2 Timeouts */
1288 0x001C, /* R205 - LDO2 Low Power */
1289 0x001B, /* R206 - LDO3 Control */
1290 0x0000, /* R207 - LDO3 Timeouts */
1291 0x001C, /* R208 - LDO3 Low Power */
1292 0x001B, /* R209 - LDO4 Control */
1293 0x0000, /* R210 - LDO4 Timeouts */
1294 0x001C, /* R211 - LDO4 Low Power */
1295 0x0000, /* R212 */
1296 0x0000, /* R213 */
1297 0x0000, /* R214 */
1298 0x0000, /* R215 - VCC_FAULT Masks */
1299 0x001F, /* R216 - Main Bandgap Control */
1300 0x0000, /* R217 - OSC Control */
1301 0x9000, /* R218 - RTC Tick Control */
1302 0x0000, /* R219 - Security1 */
1303 0x4000, /* R220 */
1304 0x0000, /* R221 */
1305 0x0000, /* R222 */
1306 0x0000, /* R223 */
1307 0x0000, /* R224 - Signal overrides */
1308 0x0000, /* R225 - DCDC/LDO status */
1309 0x0000, /* R226 - Charger Overides/status */
1310 0x0000, /* R227 - misc overrides */
1311 0x0000, /* R228 - Supply overrides/status 1 */
1312 0x0000, /* R229 - Supply overrides/status 2 */
1313 0xE000, /* R230 - GPIO Pin Status */
1314 0x0000, /* R231 - comparotor overrides */
1315 0x0000, /* R232 */
1316 0x0000, /* R233 - State Machine status */
1317 0x1200, /* R234 - FLL Test 1 */
1318 0x0000, /* R235 */
1319 0x8000, /* R236 */
1320 0x0000, /* R237 */
1321 0x0000, /* R238 */
1322 0x0000, /* R239 */
1323 0x0003, /* R240 */
1324 0x0000, /* R241 */
1325 0x0000, /* R242 */
1326 0x0004, /* R243 */
1327 0x0300, /* R244 */
1328 0x0000, /* R245 */
1329 0x0200, /* R246 */
1330 0x0000, /* R247 */
1331 0x1000, /* R248 - DCDC1 Test Controls */
1332 0x1000, /* R249 */
1333 0x1000, /* R250 - DCDC3 Test Controls */
1334 0x1000, /* R251 - DCDC4 Test Controls */
1335};
1336#endif
1337
1338#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_1
1339
1340#undef WM8350_HAVE_CONFIG_MODE
1341#define WM8350_HAVE_CONFIG_MODE
1342
1343const u16 wm8351_mode1_defaults[] = {
1344 0x6143, /* R0 - Reset/ID */
1345 0x0000, /* R1 - ID */
1346 0x0001, /* R2 - Revision */
1347 0x1C02, /* R3 - System Control 1 */
1348 0x0204, /* R4 - System Control 2 */
1349 0x0000, /* R5 - System Hibernate */
1350 0x8A00, /* R6 - Interface Control */
1351 0x0000, /* R7 */
1352 0x8000, /* R8 - Power mgmt (1) */
1353 0x0000, /* R9 - Power mgmt (2) */
1354 0x0000, /* R10 - Power mgmt (3) */
1355 0x2000, /* R11 - Power mgmt (4) */
1356 0x0E00, /* R12 - Power mgmt (5) */
1357 0x0000, /* R13 - Power mgmt (6) */
1358 0x0000, /* R14 - Power mgmt (7) */
1359 0x0000, /* R15 */
1360 0x0000, /* R16 - RTC Seconds/Minutes */
1361 0x0100, /* R17 - RTC Hours/Day */
1362 0x0101, /* R18 - RTC Date/Month */
1363 0x1400, /* R19 - RTC Year */
1364 0x0000, /* R20 - Alarm Seconds/Minutes */
1365 0x0000, /* R21 - Alarm Hours/Day */
1366 0x0000, /* R22 - Alarm Date/Month */
1367 0x0320, /* R23 - RTC Time Control */
1368 0x0000, /* R24 - System Interrupts */
1369 0x0000, /* R25 - Interrupt Status 1 */
1370 0x0000, /* R26 - Interrupt Status 2 */
1371 0x0000, /* R27 */
1372 0x0000, /* R28 - Under Voltage Interrupt status */
1373 0x0000, /* R29 - Over Current Interrupt status */
1374 0x0000, /* R30 - GPIO Interrupt Status */
1375 0x0000, /* R31 - Comparator Interrupt Status */
1376 0x3FFF, /* R32 - System Interrupts Mask */
1377 0x0000, /* R33 - Interrupt Status 1 Mask */
1378 0x0000, /* R34 - Interrupt Status 2 Mask */
1379 0x0000, /* R35 */
1380 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1381 0x0000, /* R37 - Over Current Interrupt status Mask */
1382 0x0000, /* R38 - GPIO Interrupt Status Mask */
1383 0x0000, /* R39 - Comparator Interrupt Status Mask */
1384 0x0040, /* R40 - Clock Control 1 */
1385 0x0000, /* R41 - Clock Control 2 */
1386 0x3A00, /* R42 - FLL Control 1 */
1387 0x7086, /* R43 - FLL Control 2 */
1388 0xC226, /* R44 - FLL Control 3 */
1389 0x0000, /* R45 - FLL Control 4 */
1390 0x0000, /* R46 */
1391 0x0000, /* R47 */
1392 0x0000, /* R48 - DAC Control */
1393 0x0000, /* R49 */
1394 0x00C0, /* R50 - DAC Digital Volume L */
1395 0x00C0, /* R51 - DAC Digital Volume R */
1396 0x0000, /* R52 */
1397 0x0040, /* R53 - DAC LR Rate */
1398 0x0000, /* R54 - DAC Clock Control */
1399 0x0000, /* R55 */
1400 0x0000, /* R56 */
1401 0x0000, /* R57 */
1402 0x4000, /* R58 - DAC Mute */
1403 0x0000, /* R59 - DAC Mute Volume */
1404 0x0000, /* R60 - DAC Side */
1405 0x0000, /* R61 */
1406 0x0000, /* R62 */
1407 0x0000, /* R63 */
1408 0x8000, /* R64 - ADC Control */
1409 0x0000, /* R65 */
1410 0x00C0, /* R66 - ADC Digital Volume L */
1411 0x00C0, /* R67 - ADC Digital Volume R */
1412 0x0000, /* R68 - ADC Divider */
1413 0x0000, /* R69 */
1414 0x0040, /* R70 - ADC LR Rate */
1415 0x0000, /* R71 */
1416 0x0303, /* R72 - Input Control */
1417 0x0000, /* R73 - IN3 Input Control */
1418 0x0000, /* R74 - Mic Bias Control */
1419 0x0000, /* R75 */
1420 0x0000, /* R76 - Output Control */
1421 0x0000, /* R77 - Jack Detect */
1422 0x0000, /* R78 - Anti Pop Control */
1423 0x0000, /* R79 */
1424 0x0040, /* R80 - Left Input Volume */
1425 0x0040, /* R81 - Right Input Volume */
1426 0x0000, /* R82 */
1427 0x0000, /* R83 */
1428 0x0000, /* R84 */
1429 0x0000, /* R85 */
1430 0x0000, /* R86 */
1431 0x0000, /* R87 */
1432 0x0800, /* R88 - Left Mixer Control */
1433 0x1000, /* R89 - Right Mixer Control */
1434 0x0000, /* R90 */
1435 0x0000, /* R91 */
1436 0x0000, /* R92 - OUT3 Mixer Control */
1437 0x0000, /* R93 - OUT4 Mixer Control */
1438 0x0000, /* R94 */
1439 0x0000, /* R95 */
1440 0x0000, /* R96 - Output Left Mixer Volume */
1441 0x0000, /* R97 - Output Right Mixer Volume */
1442 0x0000, /* R98 - Input Mixer Volume L */
1443 0x0000, /* R99 - Input Mixer Volume R */
1444 0x0000, /* R100 - Input Mixer Volume */
1445 0x0000, /* R101 */
1446 0x0000, /* R102 */
1447 0x0000, /* R103 */
1448 0x00E4, /* R104 - OUT1L Volume */
1449 0x00E4, /* R105 - OUT1R Volume */
1450 0x00E4, /* R106 - OUT2L Volume */
1451 0x02E4, /* R107 - OUT2R Volume */
1452 0x0000, /* R108 */
1453 0x0000, /* R109 */
1454 0x0000, /* R110 */
1455 0x0000, /* R111 - BEEP Volume */
1456 0x0A00, /* R112 - AI Formating */
1457 0x0000, /* R113 - ADC DAC COMP */
1458 0x0020, /* R114 - AI ADC Control */
1459 0x0020, /* R115 - AI DAC Control */
1460 0x0000, /* R116 */
1461 0x0000, /* R117 */
1462 0x0000, /* R118 */
1463 0x0000, /* R119 */
1464 0x0000, /* R120 */
1465 0x0000, /* R121 */
1466 0x0000, /* R122 */
1467 0x0000, /* R123 */
1468 0x0000, /* R124 */
1469 0x0000, /* R125 */
1470 0x0000, /* R126 */
1471 0x0000, /* R127 */
1472 0x1FFF, /* R128 - GPIO Debounce */
1473 0x0000, /* R129 - GPIO Pin pull up Control */
1474 0x0000, /* R130 - GPIO Pull down Control */
1475 0x0000, /* R131 - GPIO Interrupt Mode */
1476 0x0000, /* R132 */
1477 0x0000, /* R133 - GPIO Control */
1478 0x0CFB, /* R134 - GPIO Configuration (i/o) */
1479 0x0C1F, /* R135 - GPIO Pin Polarity / Type */
1480 0x0000, /* R136 */
1481 0x0000, /* R137 */
1482 0x0000, /* R138 */
1483 0x0000, /* R139 */
1484 0x0300, /* R140 - GPIO Function Select 1 */
1485 0x1110, /* R141 - GPIO Function Select 2 */
1486 0x0013, /* R142 - GPIO Function Select 3 */
1487 0x0003, /* R143 - GPIO Function Select 4 */
1488 0x0000, /* R144 - Digitiser Control (1) */
1489 0x0002, /* R145 - Digitiser Control (2) */
1490 0x0000, /* R146 */
1491 0x0000, /* R147 */
1492 0x0000, /* R148 */
1493 0x0000, /* R149 */
1494 0x0000, /* R150 */
1495 0x0000, /* R151 */
1496 0x7000, /* R152 - AUX1 Readback */
1497 0x7000, /* R153 - AUX2 Readback */
1498 0x7000, /* R154 - AUX3 Readback */
1499 0x7000, /* R155 - AUX4 Readback */
1500 0x0000, /* R156 - USB Voltage Readback */
1501 0x0000, /* R157 - LINE Voltage Readback */
1502 0x0000, /* R158 - BATT Voltage Readback */
1503 0x0000, /* R159 - Chip Temp Readback */
1504 0x0000, /* R160 */
1505 0x0000, /* R161 */
1506 0x0000, /* R162 */
1507 0x0000, /* R163 - Generic Comparator Control */
1508 0x0000, /* R164 - Generic comparator 1 */
1509 0x0000, /* R165 - Generic comparator 2 */
1510 0x0000, /* R166 - Generic comparator 3 */
1511 0x0000, /* R167 - Generic comparator 4 */
1512 0xA00F, /* R168 - Battery Charger Control 1 */
1513 0x0B06, /* R169 - Battery Charger Control 2 */
1514 0x0000, /* R170 - Battery Charger Control 3 */
1515 0x0000, /* R171 */
1516 0x0000, /* R172 - Current Sink Driver A */
1517 0x0000, /* R173 - CSA Flash control */
1518 0x0000, /* R174 */
1519 0x0000, /* R175 */
1520 0x0000, /* R176 - DCDC/LDO requested */
1521 0x032D, /* R177 - DCDC Active options */
1522 0x0000, /* R178 - DCDC Sleep options */
1523 0x0025, /* R179 - Power-check comparator */
1524 0x000E, /* R180 - DCDC1 Control */
1525 0x0C00, /* R181 - DCDC1 Timeouts */
1526 0x1006, /* R182 - DCDC1 Low Power */
1527 0x0018, /* R183 - DCDC2 Control */
1528 0x0000, /* R184 - DCDC2 Timeouts */
1529 0x0000, /* R185 */
1530 0x0026, /* R186 - DCDC3 Control */
1531 0x0400, /* R187 - DCDC3 Timeouts */
1532 0x0006, /* R188 - DCDC3 Low Power */
1533 0x0062, /* R189 - DCDC4 Control */
1534 0x0800, /* R190 - DCDC4 Timeouts */
1535 0x0006, /* R191 - DCDC4 Low Power */
1536 0x0008, /* R192 */
1537 0x0000, /* R193 */
1538 0x0000, /* R194 */
1539 0x000A, /* R195 */
1540 0x1000, /* R196 */
1541 0x0006, /* R197 */
1542 0x0000, /* R198 */
1543 0x0003, /* R199 - Limit Switch Control */
1544 0x0006, /* R200 - LDO1 Control */
1545 0x0000, /* R201 - LDO1 Timeouts */
1546 0x001C, /* R202 - LDO1 Low Power */
1547 0x0010, /* R203 - LDO2 Control */
1548 0x0C00, /* R204 - LDO2 Timeouts */
1549 0x001C, /* R205 - LDO2 Low Power */
1550 0x001F, /* R206 - LDO3 Control */
1551 0x0800, /* R207 - LDO3 Timeouts */
1552 0x001C, /* R208 - LDO3 Low Power */
1553 0x000A, /* R209 - LDO4 Control */
1554 0x0800, /* R210 - LDO4 Timeouts */
1555 0x001C, /* R211 - LDO4 Low Power */
1556 0x0000, /* R212 */
1557 0x0000, /* R213 */
1558 0x0000, /* R214 */
1559 0x0000, /* R215 - VCC_FAULT Masks */
1560 0x001F, /* R216 - Main Bandgap Control */
1561 0x0000, /* R217 - OSC Control */
1562 0x9000, /* R218 - RTC Tick Control */
1563 0x0000, /* R219 - Security1 */
1564 0x4000, /* R220 */
1565 0x0000, /* R221 */
1566 0x0000, /* R222 */
1567 0x0000, /* R223 */
1568 0x0000, /* R224 - Signal overrides */
1569 0x0000, /* R225 - DCDC/LDO status */
1570 0x0000, /* R226 - Charger Overides/status */
1571 0x0000, /* R227 - misc overrides */
1572 0x0000, /* R228 - Supply overrides/status 1 */
1573 0x0000, /* R229 - Supply overrides/status 2 */
1574 0xE000, /* R230 - GPIO Pin Status */
1575 0x0000, /* R231 - comparotor overrides */
1576 0x0000, /* R232 */
1577 0x0000, /* R233 - State Machine status */
1578 0x1200, /* R234 - FLL Test 1 */
1579 0x0000, /* R235 */
1580 0x8000, /* R236 */
1581 0x0000, /* R237 */
1582 0x0000, /* R238 */
1583 0x0000, /* R239 */
1584 0x0003, /* R240 */
1585 0x0000, /* R241 */
1586 0x0000, /* R242 */
1587 0x0004, /* R243 */
1588 0x0300, /* R244 */
1589 0x0000, /* R245 */
1590 0x0200, /* R246 */
1591 0x1000, /* R247 */
1592 0x1000, /* R248 - DCDC1 Test Controls */
1593 0x1000, /* R249 */
1594 0x1000, /* R250 - DCDC3 Test Controls */
1595 0x1000, /* R251 - DCDC4 Test Controls */
1596};
1597#endif
1598
1599#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_2
1600
1601#undef WM8350_HAVE_CONFIG_MODE
1602#define WM8350_HAVE_CONFIG_MODE
1603
1604const u16 wm8351_mode2_defaults[] = {
1605 0x6143, /* R0 - Reset/ID */
1606 0x0000, /* R1 - ID */
1607 0x0001, /* R2 - Revision */
1608 0x1C02, /* R3 - System Control 1 */
1609 0x0214, /* R4 - System Control 2 */
1610 0x0000, /* R5 - System Hibernate */
1611 0x8A00, /* R6 - Interface Control */
1612 0x0000, /* R7 */
1613 0x8000, /* R8 - Power mgmt (1) */
1614 0x0000, /* R9 - Power mgmt (2) */
1615 0x0000, /* R10 - Power mgmt (3) */
1616 0x2000, /* R11 - Power mgmt (4) */
1617 0x0E00, /* R12 - Power mgmt (5) */
1618 0x0000, /* R13 - Power mgmt (6) */
1619 0x0000, /* R14 - Power mgmt (7) */
1620 0x0000, /* R15 */
1621 0x0000, /* R16 - RTC Seconds/Minutes */
1622 0x0100, /* R17 - RTC Hours/Day */
1623 0x0101, /* R18 - RTC Date/Month */
1624 0x1400, /* R19 - RTC Year */
1625 0x0000, /* R20 - Alarm Seconds/Minutes */
1626 0x0000, /* R21 - Alarm Hours/Day */
1627 0x0000, /* R22 - Alarm Date/Month */
1628 0x0320, /* R23 - RTC Time Control */
1629 0x0000, /* R24 - System Interrupts */
1630 0x0000, /* R25 - Interrupt Status 1 */
1631 0x0000, /* R26 - Interrupt Status 2 */
1632 0x0000, /* R27 */
1633 0x0000, /* R28 - Under Voltage Interrupt status */
1634 0x0000, /* R29 - Over Current Interrupt status */
1635 0x0000, /* R30 - GPIO Interrupt Status */
1636 0x0000, /* R31 - Comparator Interrupt Status */
1637 0x3FFF, /* R32 - System Interrupts Mask */
1638 0x0000, /* R33 - Interrupt Status 1 Mask */
1639 0x0000, /* R34 - Interrupt Status 2 Mask */
1640 0x0000, /* R35 */
1641 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1642 0x0000, /* R37 - Over Current Interrupt status Mask */
1643 0x0000, /* R38 - GPIO Interrupt Status Mask */
1644 0x0000, /* R39 - Comparator Interrupt Status Mask */
1645 0x0040, /* R40 - Clock Control 1 */
1646 0x0000, /* R41 - Clock Control 2 */
1647 0x3A00, /* R42 - FLL Control 1 */
1648 0x7086, /* R43 - FLL Control 2 */
1649 0xC226, /* R44 - FLL Control 3 */
1650 0x0000, /* R45 - FLL Control 4 */
1651 0x0000, /* R46 */
1652 0x0000, /* R47 */
1653 0x0000, /* R48 - DAC Control */
1654 0x0000, /* R49 */
1655 0x00C0, /* R50 - DAC Digital Volume L */
1656 0x00C0, /* R51 - DAC Digital Volume R */
1657 0x0000, /* R52 */
1658 0x0040, /* R53 - DAC LR Rate */
1659 0x0000, /* R54 - DAC Clock Control */
1660 0x0000, /* R55 */
1661 0x0000, /* R56 */
1662 0x0000, /* R57 */
1663 0x4000, /* R58 - DAC Mute */
1664 0x0000, /* R59 - DAC Mute Volume */
1665 0x0000, /* R60 - DAC Side */
1666 0x0000, /* R61 */
1667 0x0000, /* R62 */
1668 0x0000, /* R63 */
1669 0x8000, /* R64 - ADC Control */
1670 0x0000, /* R65 */
1671 0x00C0, /* R66 - ADC Digital Volume L */
1672 0x00C0, /* R67 - ADC Digital Volume R */
1673 0x0000, /* R68 - ADC Divider */
1674 0x0000, /* R69 */
1675 0x0040, /* R70 - ADC LR Rate */
1676 0x0000, /* R71 */
1677 0x0303, /* R72 - Input Control */
1678 0x0000, /* R73 - IN3 Input Control */
1679 0x0000, /* R74 - Mic Bias Control */
1680 0x0000, /* R75 */
1681 0x0000, /* R76 - Output Control */
1682 0x0000, /* R77 - Jack Detect */
1683 0x0000, /* R78 - Anti Pop Control */
1684 0x0000, /* R79 */
1685 0x0040, /* R80 - Left Input Volume */
1686 0x0040, /* R81 - Right Input Volume */
1687 0x0000, /* R82 */
1688 0x0000, /* R83 */
1689 0x0000, /* R84 */
1690 0x0000, /* R85 */
1691 0x0000, /* R86 */
1692 0x0000, /* R87 */
1693 0x0800, /* R88 - Left Mixer Control */
1694 0x1000, /* R89 - Right Mixer Control */
1695 0x0000, /* R90 */
1696 0x0000, /* R91 */
1697 0x0000, /* R92 - OUT3 Mixer Control */
1698 0x0000, /* R93 - OUT4 Mixer Control */
1699 0x0000, /* R94 */
1700 0x0000, /* R95 */
1701 0x0000, /* R96 - Output Left Mixer Volume */
1702 0x0000, /* R97 - Output Right Mixer Volume */
1703 0x0000, /* R98 - Input Mixer Volume L */
1704 0x0000, /* R99 - Input Mixer Volume R */
1705 0x0000, /* R100 - Input Mixer Volume */
1706 0x0000, /* R101 */
1707 0x0000, /* R102 */
1708 0x0000, /* R103 */
1709 0x00E4, /* R104 - OUT1L Volume */
1710 0x00E4, /* R105 - OUT1R Volume */
1711 0x00E4, /* R106 - OUT2L Volume */
1712 0x02E4, /* R107 - OUT2R Volume */
1713 0x0000, /* R108 */
1714 0x0000, /* R109 */
1715 0x0000, /* R110 */
1716 0x0000, /* R111 - BEEP Volume */
1717 0x0A00, /* R112 - AI Formating */
1718 0x0000, /* R113 - ADC DAC COMP */
1719 0x0020, /* R114 - AI ADC Control */
1720 0x0020, /* R115 - AI DAC Control */
1721 0x0000, /* R116 */
1722 0x0000, /* R117 */
1723 0x0000, /* R118 */
1724 0x0000, /* R119 */
1725 0x0000, /* R120 */
1726 0x0000, /* R121 */
1727 0x0000, /* R122 */
1728 0x0000, /* R123 */
1729 0x0000, /* R124 */
1730 0x0000, /* R125 */
1731 0x0000, /* R126 */
1732 0x0000, /* R127 */
1733 0x1FFF, /* R128 - GPIO Debounce */
1734 0x0000, /* R129 - GPIO Pin pull up Control */
1735 0x0110, /* R130 - GPIO Pull down Control */
1736 0x0000, /* R131 - GPIO Interrupt Mode */
1737 0x0000, /* R132 */
1738 0x0000, /* R133 - GPIO Control */
1739 0x09FA, /* R134 - GPIO Configuration (i/o) */
1740 0x0DF6, /* R135 - GPIO Pin Polarity / Type */
1741 0x0000, /* R136 */
1742 0x0000, /* R137 */
1743 0x0000, /* R138 */
1744 0x0000, /* R139 */
1745 0x1310, /* R140 - GPIO Function Select 1 */
1746 0x0003, /* R141 - GPIO Function Select 2 */
1747 0x2000, /* R142 - GPIO Function Select 3 */
1748 0x0000, /* R143 - GPIO Function Select 4 */
1749 0x0000, /* R144 - Digitiser Control (1) */
1750 0x0002, /* R145 - Digitiser Control (2) */
1751 0x0000, /* R146 */
1752 0x0000, /* R147 */
1753 0x0000, /* R148 */
1754 0x0000, /* R149 */
1755 0x0000, /* R150 */
1756 0x0000, /* R151 */
1757 0x7000, /* R152 - AUX1 Readback */
1758 0x7000, /* R153 - AUX2 Readback */
1759 0x7000, /* R154 - AUX3 Readback */
1760 0x7000, /* R155 - AUX4 Readback */
1761 0x0000, /* R156 - USB Voltage Readback */
1762 0x0000, /* R157 - LINE Voltage Readback */
1763 0x0000, /* R158 - BATT Voltage Readback */
1764 0x0000, /* R159 - Chip Temp Readback */
1765 0x0000, /* R160 */
1766 0x0000, /* R161 */
1767 0x0000, /* R162 */
1768 0x0000, /* R163 - Generic Comparator Control */
1769 0x0000, /* R164 - Generic comparator 1 */
1770 0x0000, /* R165 - Generic comparator 2 */
1771 0x0000, /* R166 - Generic comparator 3 */
1772 0x0000, /* R167 - Generic comparator 4 */
1773 0xA00F, /* R168 - Battery Charger Control 1 */
1774 0x0B06, /* R169 - Battery Charger Control 2 */
1775 0x0000, /* R170 - Battery Charger Control 3 */
1776 0x0000, /* R171 */
1777 0x0000, /* R172 - Current Sink Driver A */
1778 0x0000, /* R173 - CSA Flash control */
1779 0x0000, /* R174 */
1780 0x0000, /* R175 */
1781 0x0000, /* R176 - DCDC/LDO requested */
1782 0x032D, /* R177 - DCDC Active options */
1783 0x0000, /* R178 - DCDC Sleep options */
1784 0x0025, /* R179 - Power-check comparator */
1785 0x001A, /* R180 - DCDC1 Control */
1786 0x0800, /* R181 - DCDC1 Timeouts */
1787 0x1006, /* R182 - DCDC1 Low Power */
1788 0x0018, /* R183 - DCDC2 Control */
1789 0x0000, /* R184 - DCDC2 Timeouts */
1790 0x0000, /* R185 */
1791 0x0056, /* R186 - DCDC3 Control */
1792 0x0400, /* R187 - DCDC3 Timeouts */
1793 0x0006, /* R188 - DCDC3 Low Power */
1794 0x0026, /* R189 - DCDC4 Control */
1795 0x0C00, /* R190 - DCDC4 Timeouts */
1796 0x0006, /* R191 - DCDC4 Low Power */
1797 0x0008, /* R192 */
1798 0x0000, /* R193 */
1799 0x0000, /* R194 */
1800 0x0026, /* R195 */
1801 0x0C00, /* R196 */
1802 0x0006, /* R197 */
1803 0x0000, /* R198 */
1804 0x0003, /* R199 - Limit Switch Control */
1805 0x001C, /* R200 - LDO1 Control */
1806 0x0400, /* R201 - LDO1 Timeouts */
1807 0x001C, /* R202 - LDO1 Low Power */
1808 0x0010, /* R203 - LDO2 Control */
1809 0x0C00, /* R204 - LDO2 Timeouts */
1810 0x001C, /* R205 - LDO2 Low Power */
1811 0x0015, /* R206 - LDO3 Control */
1812 0x0000, /* R207 - LDO3 Timeouts */
1813 0x001C, /* R208 - LDO3 Low Power */
1814 0x001A, /* R209 - LDO4 Control */
1815 0x0000, /* R210 - LDO4 Timeouts */
1816 0x001C, /* R211 - LDO4 Low Power */
1817 0x0000, /* R212 */
1818 0x0000, /* R213 */
1819 0x0000, /* R214 */
1820 0x0000, /* R215 - VCC_FAULT Masks */
1821 0x001F, /* R216 - Main Bandgap Control */
1822 0x0000, /* R217 - OSC Control */
1823 0x9000, /* R218 - RTC Tick Control */
1824 0x0000, /* R219 - Security1 */
1825 0x4000, /* R220 */
1826 0x0000, /* R221 */
1827 0x0000, /* R222 */
1828 0x0000, /* R223 */
1829 0x0000, /* R224 - Signal overrides */
1830 0x0000, /* R225 - DCDC/LDO status */
1831 0x0000, /* R226 - Charger Overides/status */
1832 0x0000, /* R227 - misc overrides */
1833 0x0000, /* R228 - Supply overrides/status 1 */
1834 0x0000, /* R229 - Supply overrides/status 2 */
1835 0xE000, /* R230 - GPIO Pin Status */
1836 0x0000, /* R231 - comparotor overrides */
1837 0x0000, /* R232 */
1838 0x0000, /* R233 - State Machine status */
1839 0x1200, /* R234 - FLL Test 1 */
1840 0x0000, /* R235 */
1841 0x8000, /* R236 */
1842 0x0000, /* R237 */
1843 0x0000, /* R238 */
1844 0x0000, /* R239 */
1845 0x0003, /* R240 */
1846 0x0000, /* R241 */
1847 0x0000, /* R242 */
1848 0x0004, /* R243 */
1849 0x0300, /* R244 */
1850 0x0000, /* R245 */
1851 0x0200, /* R246 */
1852 0x0000, /* R247 */
1853 0x1000, /* R248 - DCDC1 Test Controls */
1854 0x1000, /* R249 */
1855 0x1000, /* R250 - DCDC3 Test Controls */
1856 0x1000, /* R251 - DCDC4 Test Controls */
1857};
1858#endif
1859
1860#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_3
1861
1862#undef WM8350_HAVE_CONFIG_MODE
1863#define WM8350_HAVE_CONFIG_MODE
1864
1865const u16 wm8351_mode3_defaults[] = {
1866 0x6143, /* R0 - Reset/ID */
1867 0x0000, /* R1 - ID */
1868 0x0001, /* R2 - Revision */
1869 0x1C02, /* R3 - System Control 1 */
1870 0x0204, /* R4 - System Control 2 */
1871 0x0000, /* R5 - System Hibernate */
1872 0x8A00, /* R6 - Interface Control */
1873 0x0000, /* R7 */
1874 0x8000, /* R8 - Power mgmt (1) */
1875 0x0000, /* R9 - Power mgmt (2) */
1876 0x0000, /* R10 - Power mgmt (3) */
1877 0x2000, /* R11 - Power mgmt (4) */
1878 0x0E00, /* R12 - Power mgmt (5) */
1879 0x0000, /* R13 - Power mgmt (6) */
1880 0x0000, /* R14 - Power mgmt (7) */
1881 0x0000, /* R15 */
1882 0x0000, /* R16 - RTC Seconds/Minutes */
1883 0x0100, /* R17 - RTC Hours/Day */
1884 0x0101, /* R18 - RTC Date/Month */
1885 0x1400, /* R19 - RTC Year */
1886 0x0000, /* R20 - Alarm Seconds/Minutes */
1887 0x0000, /* R21 - Alarm Hours/Day */
1888 0x0000, /* R22 - Alarm Date/Month */
1889 0x0320, /* R23 - RTC Time Control */
1890 0x0000, /* R24 - System Interrupts */
1891 0x0000, /* R25 - Interrupt Status 1 */
1892 0x0000, /* R26 - Interrupt Status 2 */
1893 0x0000, /* R27 */
1894 0x0000, /* R28 - Under Voltage Interrupt status */
1895 0x0000, /* R29 - Over Current Interrupt status */
1896 0x0000, /* R30 - GPIO Interrupt Status */
1897 0x0000, /* R31 - Comparator Interrupt Status */
1898 0x3FFF, /* R32 - System Interrupts Mask */
1899 0x0000, /* R33 - Interrupt Status 1 Mask */
1900 0x0000, /* R34 - Interrupt Status 2 Mask */
1901 0x0000, /* R35 */
1902 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1903 0x0000, /* R37 - Over Current Interrupt status Mask */
1904 0x0000, /* R38 - GPIO Interrupt Status Mask */
1905 0x0000, /* R39 - Comparator Interrupt Status Mask */
1906 0x0040, /* R40 - Clock Control 1 */
1907 0x0000, /* R41 - Clock Control 2 */
1908 0x3A00, /* R42 - FLL Control 1 */
1909 0x7086, /* R43 - FLL Control 2 */
1910 0xC226, /* R44 - FLL Control 3 */
1911 0x0000, /* R45 - FLL Control 4 */
1912 0x0000, /* R46 */
1913 0x0000, /* R47 */
1914 0x0000, /* R48 - DAC Control */
1915 0x0000, /* R49 */
1916 0x00C0, /* R50 - DAC Digital Volume L */
1917 0x00C0, /* R51 - DAC Digital Volume R */
1918 0x0000, /* R52 */
1919 0x0040, /* R53 - DAC LR Rate */
1920 0x0000, /* R54 - DAC Clock Control */
1921 0x0000, /* R55 */
1922 0x0000, /* R56 */
1923 0x0000, /* R57 */
1924 0x4000, /* R58 - DAC Mute */
1925 0x0000, /* R59 - DAC Mute Volume */
1926 0x0000, /* R60 - DAC Side */
1927 0x0000, /* R61 */
1928 0x0000, /* R62 */
1929 0x0000, /* R63 */
1930 0x8000, /* R64 - ADC Control */
1931 0x0000, /* R65 */
1932 0x00C0, /* R66 - ADC Digital Volume L */
1933 0x00C0, /* R67 - ADC Digital Volume R */
1934 0x0000, /* R68 - ADC Divider */
1935 0x0000, /* R69 */
1936 0x0040, /* R70 - ADC LR Rate */
1937 0x0000, /* R71 */
1938 0x0303, /* R72 - Input Control */
1939 0x0000, /* R73 - IN3 Input Control */
1940 0x0000, /* R74 - Mic Bias Control */
1941 0x0000, /* R75 */
1942 0x0000, /* R76 - Output Control */
1943 0x0000, /* R77 - Jack Detect */
1944 0x0000, /* R78 - Anti Pop Control */
1945 0x0000, /* R79 */
1946 0x0040, /* R80 - Left Input Volume */
1947 0x0040, /* R81 - Right Input Volume */
1948 0x0000, /* R82 */
1949 0x0000, /* R83 */
1950 0x0000, /* R84 */
1951 0x0000, /* R85 */
1952 0x0000, /* R86 */
1953 0x0000, /* R87 */
1954 0x0800, /* R88 - Left Mixer Control */
1955 0x1000, /* R89 - Right Mixer Control */
1956 0x0000, /* R90 */
1957 0x0000, /* R91 */
1958 0x0000, /* R92 - OUT3 Mixer Control */
1959 0x0000, /* R93 - OUT4 Mixer Control */
1960 0x0000, /* R94 */
1961 0x0000, /* R95 */
1962 0x0000, /* R96 - Output Left Mixer Volume */
1963 0x0000, /* R97 - Output Right Mixer Volume */
1964 0x0000, /* R98 - Input Mixer Volume L */
1965 0x0000, /* R99 - Input Mixer Volume R */
1966 0x0000, /* R100 - Input Mixer Volume */
1967 0x0000, /* R101 */
1968 0x0000, /* R102 */
1969 0x0000, /* R103 */
1970 0x00E4, /* R104 - OUT1L Volume */
1971 0x00E4, /* R105 - OUT1R Volume */
1972 0x00E4, /* R106 - OUT2L Volume */
1973 0x02E4, /* R107 - OUT2R Volume */
1974 0x0000, /* R108 */
1975 0x0000, /* R109 */
1976 0x0000, /* R110 */
1977 0x0000, /* R111 - BEEP Volume */
1978 0x0A00, /* R112 - AI Formating */
1979 0x0000, /* R113 - ADC DAC COMP */
1980 0x0020, /* R114 - AI ADC Control */
1981 0x0020, /* R115 - AI DAC Control */
1982 0x0000, /* R116 */
1983 0x0000, /* R117 */
1984 0x0000, /* R118 */
1985 0x0000, /* R119 */
1986 0x0000, /* R120 */
1987 0x0000, /* R121 */
1988 0x0000, /* R122 */
1989 0x0000, /* R123 */
1990 0x0000, /* R124 */
1991 0x0000, /* R125 */
1992 0x0000, /* R126 */
1993 0x0000, /* R127 */
1994 0x1FFF, /* R128 - GPIO Debounce */
1995 0x0010, /* R129 - GPIO Pin pull up Control */
1996 0x0000, /* R130 - GPIO Pull down Control */
1997 0x0000, /* R131 - GPIO Interrupt Mode */
1998 0x0000, /* R132 */
1999 0x0000, /* R133 - GPIO Control */
2000 0x0BFB, /* R134 - GPIO Configuration (i/o) */
2001 0x0FFD, /* R135 - GPIO Pin Polarity / Type */
2002 0x0000, /* R136 */
2003 0x0000, /* R137 */
2004 0x0000, /* R138 */
2005 0x0000, /* R139 */
2006 0x0310, /* R140 - GPIO Function Select 1 */
2007 0x0001, /* R141 - GPIO Function Select 2 */
2008 0x2300, /* R142 - GPIO Function Select 3 */
2009 0x0003, /* R143 - GPIO Function Select 4 */
2010 0x0000, /* R144 - Digitiser Control (1) */
2011 0x0002, /* R145 - Digitiser Control (2) */
2012 0x0000, /* R146 */
2013 0x0000, /* R147 */
2014 0x0000, /* R148 */
2015 0x0000, /* R149 */
2016 0x0000, /* R150 */
2017 0x0000, /* R151 */
2018 0x7000, /* R152 - AUX1 Readback */
2019 0x7000, /* R153 - AUX2 Readback */
2020 0x7000, /* R154 - AUX3 Readback */
2021 0x7000, /* R155 - AUX4 Readback */
2022 0x0000, /* R156 - USB Voltage Readback */
2023 0x0000, /* R157 - LINE Voltage Readback */
2024 0x0000, /* R158 - BATT Voltage Readback */
2025 0x0000, /* R159 - Chip Temp Readback */
2026 0x0000, /* R160 */
2027 0x0000, /* R161 */
2028 0x0000, /* R162 */
2029 0x0000, /* R163 - Generic Comparator Control */
2030 0x0000, /* R164 - Generic comparator 1 */
2031 0x0000, /* R165 - Generic comparator 2 */
2032 0x0000, /* R166 - Generic comparator 3 */
2033 0x0000, /* R167 - Generic comparator 4 */
2034 0xA00F, /* R168 - Battery Charger Control 1 */
2035 0x0B06, /* R169 - Battery Charger Control 2 */
2036 0x0000, /* R170 - Battery Charger Control 3 */
2037 0x0000, /* R171 */
2038 0x0000, /* R172 - Current Sink Driver A */
2039 0x0000, /* R173 - CSA Flash control */
2040 0x0000, /* R174 */
2041 0x0000, /* R175 */
2042 0x0000, /* R176 - DCDC/LDO requested */
2043 0x032D, /* R177 - DCDC Active options */
2044 0x0000, /* R178 - DCDC Sleep options */
2045 0x0025, /* R179 - Power-check comparator */
2046 0x000E, /* R180 - DCDC1 Control */
2047 0x0400, /* R181 - DCDC1 Timeouts */
2048 0x1006, /* R182 - DCDC1 Low Power */
2049 0x0018, /* R183 - DCDC2 Control */
2050 0x0000, /* R184 - DCDC2 Timeouts */
2051 0x0000, /* R185 */
2052 0x0026, /* R186 - DCDC3 Control */
2053 0x0800, /* R187 - DCDC3 Timeouts */
2054 0x0006, /* R188 - DCDC3 Low Power */
2055 0x0062, /* R189 - DCDC4 Control */
2056 0x1400, /* R190 - DCDC4 Timeouts */
2057 0x0006, /* R191 - DCDC4 Low Power */
2058 0x0008, /* R192 */
2059 0x0000, /* R193 */
2060 0x0000, /* R194 */
2061 0x0026, /* R195 */
2062 0x0400, /* R196 */
2063 0x0006, /* R197 */
2064 0x0000, /* R198 */
2065 0x0003, /* R199 - Limit Switch Control */
2066 0x0006, /* R200 - LDO1 Control */
2067 0x0C00, /* R201 - LDO1 Timeouts */
2068 0x001C, /* R202 - LDO1 Low Power */
2069 0x0016, /* R203 - LDO2 Control */
2070 0x0000, /* R204 - LDO2 Timeouts */
2071 0x001C, /* R205 - LDO2 Low Power */
2072 0x0019, /* R206 - LDO3 Control */
2073 0x0000, /* R207 - LDO3 Timeouts */
2074 0x001C, /* R208 - LDO3 Low Power */
2075 0x001A, /* R209 - LDO4 Control */
2076 0x1000, /* R210 - LDO4 Timeouts */
2077 0x001C, /* R211 - LDO4 Low Power */
2078 0x0000, /* R212 */
2079 0x0000, /* R213 */
2080 0x0000, /* R214 */
2081 0x0000, /* R215 - VCC_FAULT Masks */
2082 0x001F, /* R216 - Main Bandgap Control */
2083 0x0000, /* R217 - OSC Control */
2084 0x9000, /* R218 - RTC Tick Control */
2085 0x0000, /* R219 - Security1 */
2086 0x4000, /* R220 */
2087 0x0000, /* R221 */
2088 0x0000, /* R222 */
2089 0x0000, /* R223 */
2090 0x0000, /* R224 - Signal overrides */
2091 0x0000, /* R225 - DCDC/LDO status */
2092 0x0000, /* R226 - Charger Overides/status */
2093 0x0000, /* R227 - misc overrides */
2094 0x0000, /* R228 - Supply overrides/status 1 */
2095 0x0000, /* R229 - Supply overrides/status 2 */
2096 0xE000, /* R230 - GPIO Pin Status */
2097 0x0000, /* R231 - comparotor overrides */
2098 0x0000, /* R232 */
2099 0x0000, /* R233 - State Machine status */
2100 0x1200, /* R234 - FLL Test 1 */
2101 0x0000, /* R235 */
2102 0x8000, /* R236 */
2103 0x0000, /* R237 */
2104 0x0000, /* R238 */
2105 0x0000, /* R239 */
2106 0x0003, /* R240 */
2107 0x0000, /* R241 */
2108 0x0000, /* R242 */
2109 0x0004, /* R243 */
2110 0x0300, /* R244 */
2111 0x0000, /* R245 */
2112 0x0200, /* R246 */
2113 0x0000, /* R247 */
2114 0x1000, /* R248 - DCDC1 Test Controls */
2115 0x1000, /* R249 */
2116 0x1000, /* R250 - DCDC3 Test Controls */
2117 0x1000, /* R251 - DCDC4 Test Controls */
2118};
2119#endif
2120
2121#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_0
2122
2123#undef WM8350_HAVE_CONFIG_MODE
2124#define WM8350_HAVE_CONFIG_MODE
2125
2126const u16 wm8352_mode0_defaults[] = {
2127 0x6143, /* R0 - Reset/ID */
2128 0x0000, /* R1 - ID */
2129 0x0002, /* R2 - Revision */
2130 0x1C02, /* R3 - System Control 1 */
2131 0x0004, /* R4 - System Control 2 */
2132 0x0000, /* R5 - System Hibernate */
2133 0x8A00, /* R6 - Interface Control */
2134 0x0000, /* R7 */
2135 0x8000, /* R8 - Power mgmt (1) */
2136 0x0000, /* R9 - Power mgmt (2) */
2137 0x0000, /* R10 - Power mgmt (3) */
2138 0x2000, /* R11 - Power mgmt (4) */
2139 0x0E00, /* R12 - Power mgmt (5) */
2140 0x0000, /* R13 - Power mgmt (6) */
2141 0x0000, /* R14 - Power mgmt (7) */
2142 0x0000, /* R15 */
2143 0x0000, /* R16 - RTC Seconds/Minutes */
2144 0x0100, /* R17 - RTC Hours/Day */
2145 0x0101, /* R18 - RTC Date/Month */
2146 0x1400, /* R19 - RTC Year */
2147 0x0000, /* R20 - Alarm Seconds/Minutes */
2148 0x0000, /* R21 - Alarm Hours/Day */
2149 0x0000, /* R22 - Alarm Date/Month */
2150 0x0320, /* R23 - RTC Time Control */
2151 0x0000, /* R24 - System Interrupts */
2152 0x0000, /* R25 - Interrupt Status 1 */
2153 0x0000, /* R26 - Interrupt Status 2 */
2154 0x0000, /* R27 */
2155 0x0000, /* R28 - Under Voltage Interrupt status */
2156 0x0000, /* R29 - Over Current Interrupt status */
2157 0x0000, /* R30 - GPIO Interrupt Status */
2158 0x0000, /* R31 - Comparator Interrupt Status */
2159 0x3FFF, /* R32 - System Interrupts Mask */
2160 0x0000, /* R33 - Interrupt Status 1 Mask */
2161 0x0000, /* R34 - Interrupt Status 2 Mask */
2162 0x0000, /* R35 */
2163 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2164 0x0000, /* R37 - Over Current Interrupt status Mask */
2165 0x0000, /* R38 - GPIO Interrupt Status Mask */
2166 0x0000, /* R39 - Comparator Interrupt Status Mask */
2167 0x0040, /* R40 - Clock Control 1 */
2168 0x0000, /* R41 - Clock Control 2 */
2169 0x3A00, /* R42 - FLL Control 1 */
2170 0x7086, /* R43 - FLL Control 2 */
2171 0xC226, /* R44 - FLL Control 3 */
2172 0x0000, /* R45 - FLL Control 4 */
2173 0x0000, /* R46 */
2174 0x0000, /* R47 */
2175 0x0000, /* R48 - DAC Control */
2176 0x0000, /* R49 */
2177 0x00C0, /* R50 - DAC Digital Volume L */
2178 0x00C0, /* R51 - DAC Digital Volume R */
2179 0x0000, /* R52 */
2180 0x0040, /* R53 - DAC LR Rate */
2181 0x0000, /* R54 - DAC Clock Control */
2182 0x0000, /* R55 */
2183 0x0000, /* R56 */
2184 0x0000, /* R57 */
2185 0x4000, /* R58 - DAC Mute */
2186 0x0000, /* R59 - DAC Mute Volume */
2187 0x0000, /* R60 - DAC Side */
2188 0x0000, /* R61 */
2189 0x0000, /* R62 */
2190 0x0000, /* R63 */
2191 0x8000, /* R64 - ADC Control */
2192 0x0000, /* R65 */
2193 0x00C0, /* R66 - ADC Digital Volume L */
2194 0x00C0, /* R67 - ADC Digital Volume R */
2195 0x0000, /* R68 - ADC Divider */
2196 0x0000, /* R69 */
2197 0x0040, /* R70 - ADC LR Rate */
2198 0x0000, /* R71 */
2199 0x0303, /* R72 - Input Control */
2200 0x0000, /* R73 - IN3 Input Control */
2201 0x0000, /* R74 - Mic Bias Control */
2202 0x0000, /* R75 */
2203 0x0000, /* R76 - Output Control */
2204 0x0000, /* R77 - Jack Detect */
2205 0x0000, /* R78 - Anti Pop Control */
2206 0x0000, /* R79 */
2207 0x0040, /* R80 - Left Input Volume */
2208 0x0040, /* R81 - Right Input Volume */
2209 0x0000, /* R82 */
2210 0x0000, /* R83 */
2211 0x0000, /* R84 */
2212 0x0000, /* R85 */
2213 0x0000, /* R86 */
2214 0x0000, /* R87 */
2215 0x0800, /* R88 - Left Mixer Control */
2216 0x1000, /* R89 - Right Mixer Control */
2217 0x0000, /* R90 */
2218 0x0000, /* R91 */
2219 0x0000, /* R92 - OUT3 Mixer Control */
2220 0x0000, /* R93 - OUT4 Mixer Control */
2221 0x0000, /* R94 */
2222 0x0000, /* R95 */
2223 0x0000, /* R96 - Output Left Mixer Volume */
2224 0x0000, /* R97 - Output Right Mixer Volume */
2225 0x0000, /* R98 - Input Mixer Volume L */
2226 0x0000, /* R99 - Input Mixer Volume R */
2227 0x0000, /* R100 - Input Mixer Volume */
2228 0x0000, /* R101 */
2229 0x0000, /* R102 */
2230 0x0000, /* R103 */
2231 0x00E4, /* R104 - OUT1L Volume */
2232 0x00E4, /* R105 - OUT1R Volume */
2233 0x00E4, /* R106 - OUT2L Volume */
2234 0x02E4, /* R107 - OUT2R Volume */
2235 0x0000, /* R108 */
2236 0x0000, /* R109 */
2237 0x0000, /* R110 */
2238 0x0000, /* R111 - BEEP Volume */
2239 0x0A00, /* R112 - AI Formating */
2240 0x0000, /* R113 - ADC DAC COMP */
2241 0x0020, /* R114 - AI ADC Control */
2242 0x0020, /* R115 - AI DAC Control */
2243 0x0000, /* R116 */
2244 0x0000, /* R117 */
2245 0x0000, /* R118 */
2246 0x0000, /* R119 */
2247 0x0000, /* R120 */
2248 0x0000, /* R121 */
2249 0x0000, /* R122 */
2250 0x0000, /* R123 */
2251 0x0000, /* R124 */
2252 0x0000, /* R125 */
2253 0x0000, /* R126 */
2254 0x0000, /* R127 */
2255 0x1FFF, /* R128 - GPIO Debounce */
2256 0x0000, /* R129 - GPIO Pin pull up Control */
2257 0x0000, /* R130 - GPIO Pull down Control */
2258 0x0000, /* R131 - GPIO Interrupt Mode */
2259 0x0000, /* R132 */
2260 0x0000, /* R133 - GPIO Control */
2261 0x0FFC, /* R134 - GPIO Configuration (i/o) */
2262 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
2263 0x0000, /* R136 */
2264 0x0000, /* R137 */
2265 0x0000, /* R138 */
2266 0x0000, /* R139 */
2267 0x0013, /* R140 - GPIO Function Select 1 */
2268 0x0000, /* R141 - GPIO Function Select 2 */
2269 0x0000, /* R142 - GPIO Function Select 3 */
2270 0x0003, /* R143 - GPIO Function Select 4 */
2271 0x0000, /* R144 - Digitiser Control (1) */
2272 0x0002, /* R145 - Digitiser Control (2) */
2273 0x0000, /* R146 */
2274 0x0000, /* R147 */
2275 0x0000, /* R148 */
2276 0x0000, /* R149 */
2277 0x0000, /* R150 */
2278 0x0000, /* R151 */
2279 0x7000, /* R152 - AUX1 Readback */
2280 0x7000, /* R153 - AUX2 Readback */
2281 0x7000, /* R154 - AUX3 Readback */
2282 0x7000, /* R155 - AUX4 Readback */
2283 0x0000, /* R156 - USB Voltage Readback */
2284 0x0000, /* R157 - LINE Voltage Readback */
2285 0x0000, /* R158 - BATT Voltage Readback */
2286 0x0000, /* R159 - Chip Temp Readback */
2287 0x0000, /* R160 */
2288 0x0000, /* R161 */
2289 0x0000, /* R162 */
2290 0x0000, /* R163 - Generic Comparator Control */
2291 0x0000, /* R164 - Generic comparator 1 */
2292 0x0000, /* R165 - Generic comparator 2 */
2293 0x0000, /* R166 - Generic comparator 3 */
2294 0x0000, /* R167 - Generic comparator 4 */
2295 0xA00F, /* R168 - Battery Charger Control 1 */
2296 0x0B06, /* R169 - Battery Charger Control 2 */
2297 0x0000, /* R170 - Battery Charger Control 3 */
2298 0x0000, /* R171 */
2299 0x0000, /* R172 - Current Sink Driver A */
2300 0x0000, /* R173 - CSA Flash control */
2301 0x0000, /* R174 - Current Sink Driver B */
2302 0x0000, /* R175 - CSB Flash control */
2303 0x0000, /* R176 - DCDC/LDO requested */
2304 0x032D, /* R177 - DCDC Active options */
2305 0x0000, /* R178 - DCDC Sleep options */
2306 0x0025, /* R179 - Power-check comparator */
2307 0x000E, /* R180 - DCDC1 Control */
2308 0x0000, /* R181 - DCDC1 Timeouts */
2309 0x1006, /* R182 - DCDC1 Low Power */
2310 0x0018, /* R183 - DCDC2 Control */
2311 0x0000, /* R184 - DCDC2 Timeouts */
2312 0x0000, /* R185 */
2313 0x0000, /* R186 - DCDC3 Control */
2314 0x0000, /* R187 - DCDC3 Timeouts */
2315 0x0006, /* R188 - DCDC3 Low Power */
2316 0x0000, /* R189 - DCDC4 Control */
2317 0x0000, /* R190 - DCDC4 Timeouts */
2318 0x0006, /* R191 - DCDC4 Low Power */
2319 0x0008, /* R192 - DCDC5 Control */
2320 0x0000, /* R193 - DCDC5 Timeouts */
2321 0x0000, /* R194 */
2322 0x0000, /* R195 - DCDC6 Control */
2323 0x0000, /* R196 - DCDC6 Timeouts */
2324 0x0006, /* R197 - DCDC6 Low Power */
2325 0x0000, /* R198 */
2326 0x0003, /* R199 - Limit Switch Control */
2327 0x001C, /* R200 - LDO1 Control */
2328 0x0000, /* R201 - LDO1 Timeouts */
2329 0x001C, /* R202 - LDO1 Low Power */
2330 0x001B, /* R203 - LDO2 Control */
2331 0x0000, /* R204 - LDO2 Timeouts */
2332 0x001C, /* R205 - LDO2 Low Power */
2333 0x001B, /* R206 - LDO3 Control */
2334 0x0000, /* R207 - LDO3 Timeouts */
2335 0x001C, /* R208 - LDO3 Low Power */
2336 0x001B, /* R209 - LDO4 Control */
2337 0x0000, /* R210 - LDO4 Timeouts */
2338 0x001C, /* R211 - LDO4 Low Power */
2339 0x0000, /* R212 */
2340 0x0000, /* R213 */
2341 0x0000, /* R214 */
2342 0x0000, /* R215 - VCC_FAULT Masks */
2343 0x001F, /* R216 - Main Bandgap Control */
2344 0x0000, /* R217 - OSC Control */
2345 0x9000, /* R218 - RTC Tick Control */
2346 0x0000, /* R219 - Security1 */
2347 0x4000, /* R220 */
2348 0x0000, /* R221 */
2349 0x0000, /* R222 */
2350 0x0000, /* R223 */
2351 0x0000, /* R224 - Signal overrides */
2352 0x0000, /* R225 - DCDC/LDO status */
2353 0x0000, /* R226 - Charger Overides/status */
2354 0x0000, /* R227 - misc overrides */
2355 0x0000, /* R228 - Supply overrides/status 1 */
2356 0x0000, /* R229 - Supply overrides/status 2 */
2357 0xE000, /* R230 - GPIO Pin Status */
2358 0x0000, /* R231 - comparotor overrides */
2359 0x0000, /* R232 */
2360 0x0000, /* R233 - State Machine status */
2361 0x1200, /* R234 */
2362 0x0000, /* R235 */
2363 0x8000, /* R236 */
2364 0x0000, /* R237 */
2365 0x0000, /* R238 */
2366 0x0000, /* R239 */
2367 0x0003, /* R240 */
2368 0x0000, /* R241 */
2369 0x0000, /* R242 */
2370 0x0004, /* R243 */
2371 0x0300, /* R244 */
2372 0x0000, /* R245 */
2373 0x0200, /* R246 */
2374 0x0000, /* R247 */
2375 0x1000, /* R248 - DCDC1 Test Controls */
2376 0x5000, /* R249 */
2377 0x1000, /* R250 - DCDC3 Test Controls */
2378 0x1000, /* R251 - DCDC4 Test Controls */
2379 0x5100, /* R252 */
2380 0x1000, /* R253 - DCDC6 Test Controls */
2381};
2382#endif
2383
2384#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_1
2385
2386#undef WM8350_HAVE_CONFIG_MODE
2387#define WM8350_HAVE_CONFIG_MODE
2388
2389const u16 wm8352_mode1_defaults[] = {
2390 0x6143, /* R0 - Reset/ID */
2391 0x0000, /* R1 - ID */
2392 0x0002, /* R2 - Revision */
2393 0x1C02, /* R3 - System Control 1 */
2394 0x0204, /* R4 - System Control 2 */
2395 0x0000, /* R5 - System Hibernate */
2396 0x8A00, /* R6 - Interface Control */
2397 0x0000, /* R7 */
2398 0x8000, /* R8 - Power mgmt (1) */
2399 0x0000, /* R9 - Power mgmt (2) */
2400 0x0000, /* R10 - Power mgmt (3) */
2401 0x2000, /* R11 - Power mgmt (4) */
2402 0x0E00, /* R12 - Power mgmt (5) */
2403 0x0000, /* R13 - Power mgmt (6) */
2404 0x0000, /* R14 - Power mgmt (7) */
2405 0x0000, /* R15 */
2406 0x0000, /* R16 - RTC Seconds/Minutes */
2407 0x0100, /* R17 - RTC Hours/Day */
2408 0x0101, /* R18 - RTC Date/Month */
2409 0x1400, /* R19 - RTC Year */
2410 0x0000, /* R20 - Alarm Seconds/Minutes */
2411 0x0000, /* R21 - Alarm Hours/Day */
2412 0x0000, /* R22 - Alarm Date/Month */
2413 0x0320, /* R23 - RTC Time Control */
2414 0x0000, /* R24 - System Interrupts */
2415 0x0000, /* R25 - Interrupt Status 1 */
2416 0x0000, /* R26 - Interrupt Status 2 */
2417 0x0000, /* R27 */
2418 0x0000, /* R28 - Under Voltage Interrupt status */
2419 0x0000, /* R29 - Over Current Interrupt status */
2420 0x0000, /* R30 - GPIO Interrupt Status */
2421 0x0000, /* R31 - Comparator Interrupt Status */
2422 0x3FFF, /* R32 - System Interrupts Mask */
2423 0x0000, /* R33 - Interrupt Status 1 Mask */
2424 0x0000, /* R34 - Interrupt Status 2 Mask */
2425 0x0000, /* R35 */
2426 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2427 0x0000, /* R37 - Over Current Interrupt status Mask */
2428 0x0000, /* R38 - GPIO Interrupt Status Mask */
2429 0x0000, /* R39 - Comparator Interrupt Status Mask */
2430 0x0040, /* R40 - Clock Control 1 */
2431 0x0000, /* R41 - Clock Control 2 */
2432 0x3A00, /* R42 - FLL Control 1 */
2433 0x7086, /* R43 - FLL Control 2 */
2434 0xC226, /* R44 - FLL Control 3 */
2435 0x0000, /* R45 - FLL Control 4 */
2436 0x0000, /* R46 */
2437 0x0000, /* R47 */
2438 0x0000, /* R48 - DAC Control */
2439 0x0000, /* R49 */
2440 0x00C0, /* R50 - DAC Digital Volume L */
2441 0x00C0, /* R51 - DAC Digital Volume R */
2442 0x0000, /* R52 */
2443 0x0040, /* R53 - DAC LR Rate */
2444 0x0000, /* R54 - DAC Clock Control */
2445 0x0000, /* R55 */
2446 0x0000, /* R56 */
2447 0x0000, /* R57 */
2448 0x4000, /* R58 - DAC Mute */
2449 0x0000, /* R59 - DAC Mute Volume */
2450 0x0000, /* R60 - DAC Side */
2451 0x0000, /* R61 */
2452 0x0000, /* R62 */
2453 0x0000, /* R63 */
2454 0x8000, /* R64 - ADC Control */
2455 0x0000, /* R65 */
2456 0x00C0, /* R66 - ADC Digital Volume L */
2457 0x00C0, /* R67 - ADC Digital Volume R */
2458 0x0000, /* R68 - ADC Divider */
2459 0x0000, /* R69 */
2460 0x0040, /* R70 - ADC LR Rate */
2461 0x0000, /* R71 */
2462 0x0303, /* R72 - Input Control */
2463 0x0000, /* R73 - IN3 Input Control */
2464 0x0000, /* R74 - Mic Bias Control */
2465 0x0000, /* R75 */
2466 0x0000, /* R76 - Output Control */
2467 0x0000, /* R77 - Jack Detect */
2468 0x0000, /* R78 - Anti Pop Control */
2469 0x0000, /* R79 */
2470 0x0040, /* R80 - Left Input Volume */
2471 0x0040, /* R81 - Right Input Volume */
2472 0x0000, /* R82 */
2473 0x0000, /* R83 */
2474 0x0000, /* R84 */
2475 0x0000, /* R85 */
2476 0x0000, /* R86 */
2477 0x0000, /* R87 */
2478 0x0800, /* R88 - Left Mixer Control */
2479 0x1000, /* R89 - Right Mixer Control */
2480 0x0000, /* R90 */
2481 0x0000, /* R91 */
2482 0x0000, /* R92 - OUT3 Mixer Control */
2483 0x0000, /* R93 - OUT4 Mixer Control */
2484 0x0000, /* R94 */
2485 0x0000, /* R95 */
2486 0x0000, /* R96 - Output Left Mixer Volume */
2487 0x0000, /* R97 - Output Right Mixer Volume */
2488 0x0000, /* R98 - Input Mixer Volume L */
2489 0x0000, /* R99 - Input Mixer Volume R */
2490 0x0000, /* R100 - Input Mixer Volume */
2491 0x0000, /* R101 */
2492 0x0000, /* R102 */
2493 0x0000, /* R103 */
2494 0x00E4, /* R104 - OUT1L Volume */
2495 0x00E4, /* R105 - OUT1R Volume */
2496 0x00E4, /* R106 - OUT2L Volume */
2497 0x02E4, /* R107 - OUT2R Volume */
2498 0x0000, /* R108 */
2499 0x0000, /* R109 */
2500 0x0000, /* R110 */
2501 0x0000, /* R111 - BEEP Volume */
2502 0x0A00, /* R112 - AI Formating */
2503 0x0000, /* R113 - ADC DAC COMP */
2504 0x0020, /* R114 - AI ADC Control */
2505 0x0020, /* R115 - AI DAC Control */
2506 0x0000, /* R116 */
2507 0x0000, /* R117 */
2508 0x0000, /* R118 */
2509 0x0000, /* R119 */
2510 0x0000, /* R120 */
2511 0x0000, /* R121 */
2512 0x0000, /* R122 */
2513 0x0000, /* R123 */
2514 0x0000, /* R124 */
2515 0x0000, /* R125 */
2516 0x0000, /* R126 */
2517 0x0000, /* R127 */
2518 0x1FFF, /* R128 - GPIO Debounce */
2519 0x0000, /* R129 - GPIO Pin pull up Control */
2520 0x0000, /* R130 - GPIO Pull down Control */
2521 0x0000, /* R131 - GPIO Interrupt Mode */
2522 0x0000, /* R132 */
2523 0x0000, /* R133 - GPIO Control */
2524 0x0BFB, /* R134 - GPIO Configuration (i/o) */
2525 0x0FFF, /* R135 - GPIO Pin Polarity / Type */
2526 0x0000, /* R136 */
2527 0x0000, /* R137 */
2528 0x0000, /* R138 */
2529 0x0000, /* R139 */
2530 0x0300, /* R140 - GPIO Function Select 1 */
2531 0x0000, /* R141 - GPIO Function Select 2 */
2532 0x2300, /* R142 - GPIO Function Select 3 */
2533 0x0003, /* R143 - GPIO Function Select 4 */
2534 0x0000, /* R144 - Digitiser Control (1) */
2535 0x0002, /* R145 - Digitiser Control (2) */
2536 0x0000, /* R146 */
2537 0x0000, /* R147 */
2538 0x0000, /* R148 */
2539 0x0000, /* R149 */
2540 0x0000, /* R150 */
2541 0x0000, /* R151 */
2542 0x7000, /* R152 - AUX1 Readback */
2543 0x7000, /* R153 - AUX2 Readback */
2544 0x7000, /* R154 - AUX3 Readback */
2545 0x7000, /* R155 - AUX4 Readback */
2546 0x0000, /* R156 - USB Voltage Readback */
2547 0x0000, /* R157 - LINE Voltage Readback */
2548 0x0000, /* R158 - BATT Voltage Readback */
2549 0x0000, /* R159 - Chip Temp Readback */
2550 0x0000, /* R160 */
2551 0x0000, /* R161 */
2552 0x0000, /* R162 */
2553 0x0000, /* R163 - Generic Comparator Control */
2554 0x0000, /* R164 - Generic comparator 1 */
2555 0x0000, /* R165 - Generic comparator 2 */
2556 0x0000, /* R166 - Generic comparator 3 */
2557 0x0000, /* R167 - Generic comparator 4 */
2558 0xA00F, /* R168 - Battery Charger Control 1 */
2559 0x0B06, /* R169 - Battery Charger Control 2 */
2560 0x0000, /* R170 - Battery Charger Control 3 */
2561 0x0000, /* R171 */
2562 0x0000, /* R172 - Current Sink Driver A */
2563 0x0000, /* R173 - CSA Flash control */
2564 0x0000, /* R174 - Current Sink Driver B */
2565 0x0000, /* R175 - CSB Flash control */
2566 0x0000, /* R176 - DCDC/LDO requested */
2567 0x032D, /* R177 - DCDC Active options */
2568 0x0000, /* R178 - DCDC Sleep options */
2569 0x0025, /* R179 - Power-check comparator */
2570 0x0062, /* R180 - DCDC1 Control */
2571 0x0400, /* R181 - DCDC1 Timeouts */
2572 0x1006, /* R182 - DCDC1 Low Power */
2573 0x0018, /* R183 - DCDC2 Control */
2574 0x0000, /* R184 - DCDC2 Timeouts */
2575 0x0000, /* R185 */
2576 0x0006, /* R186 - DCDC3 Control */
2577 0x0800, /* R187 - DCDC3 Timeouts */
2578 0x0006, /* R188 - DCDC3 Low Power */
2579 0x0006, /* R189 - DCDC4 Control */
2580 0x0C00, /* R190 - DCDC4 Timeouts */
2581 0x0006, /* R191 - DCDC4 Low Power */
2582 0x0008, /* R192 - DCDC5 Control */
2583 0x0000, /* R193 - DCDC5 Timeouts */
2584 0x0000, /* R194 */
2585 0x0026, /* R195 - DCDC6 Control */
2586 0x1000, /* R196 - DCDC6 Timeouts */
2587 0x0006, /* R197 - DCDC6 Low Power */
2588 0x0000, /* R198 */
2589 0x0003, /* R199 - Limit Switch Control */
2590 0x0002, /* R200 - LDO1 Control */
2591 0x0000, /* R201 - LDO1 Timeouts */
2592 0x001C, /* R202 - LDO1 Low Power */
2593 0x001A, /* R203 - LDO2 Control */
2594 0x0000, /* R204 - LDO2 Timeouts */
2595 0x001C, /* R205 - LDO2 Low Power */
2596 0x001F, /* R206 - LDO3 Control */
2597 0x0000, /* R207 - LDO3 Timeouts */
2598 0x001C, /* R208 - LDO3 Low Power */
2599 0x001F, /* R209 - LDO4 Control */
2600 0x0000, /* R210 - LDO4 Timeouts */
2601 0x001C, /* R211 - LDO4 Low Power */
2602 0x0000, /* R212 */
2603 0x0000, /* R213 */
2604 0x0000, /* R214 */
2605 0x0000, /* R215 - VCC_FAULT Masks */
2606 0x001F, /* R216 - Main Bandgap Control */
2607 0x0000, /* R217 - OSC Control */
2608 0x9000, /* R218 - RTC Tick Control */
2609 0x0000, /* R219 - Security1 */
2610 0x4000, /* R220 */
2611 0x0000, /* R221 */
2612 0x0000, /* R222 */
2613 0x0000, /* R223 */
2614 0x0000, /* R224 - Signal overrides */
2615 0x0000, /* R225 - DCDC/LDO status */
2616 0x0000, /* R226 - Charger Overides/status */
2617 0x0000, /* R227 - misc overrides */
2618 0x0000, /* R228 - Supply overrides/status 1 */
2619 0x0000, /* R229 - Supply overrides/status 2 */
2620 0xE000, /* R230 - GPIO Pin Status */
2621 0x0000, /* R231 - comparotor overrides */
2622 0x0000, /* R232 */
2623 0x0000, /* R233 - State Machine status */
2624 0x1200, /* R234 */
2625 0x0000, /* R235 */
2626 0x8000, /* R236 */
2627 0x0000, /* R237 */
2628 0x0000, /* R238 */
2629 0x0000, /* R239 */
2630 0x0003, /* R240 */
2631 0x0000, /* R241 */
2632 0x0000, /* R242 */
2633 0x0004, /* R243 */
2634 0x0300, /* R244 */
2635 0x0000, /* R245 */
2636 0x0200, /* R246 */
2637 0x0000, /* R247 */
2638 0x1000, /* R248 - DCDC1 Test Controls */
2639 0x5000, /* R249 */
2640 0x1000, /* R250 - DCDC3 Test Controls */
2641 0x1000, /* R251 - DCDC4 Test Controls */
2642 0x5100, /* R252 */
2643 0x1000, /* R253 - DCDC6 Test Controls */
2644};
2645#endif
2646
2647#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_2
2648
2649#undef WM8350_HAVE_CONFIG_MODE
2650#define WM8350_HAVE_CONFIG_MODE
2651
2652const u16 wm8352_mode2_defaults[] = {
2653 0x6143, /* R0 - Reset/ID */
2654 0x0000, /* R1 - ID */
2655 0x0002, /* R2 - Revision */
2656 0x1C02, /* R3 - System Control 1 */
2657 0x0204, /* R4 - System Control 2 */
2658 0x0000, /* R5 - System Hibernate */
2659 0x8A00, /* R6 - Interface Control */
2660 0x0000, /* R7 */
2661 0x8000, /* R8 - Power mgmt (1) */
2662 0x0000, /* R9 - Power mgmt (2) */
2663 0x0000, /* R10 - Power mgmt (3) */
2664 0x2000, /* R11 - Power mgmt (4) */
2665 0x0E00, /* R12 - Power mgmt (5) */
2666 0x0000, /* R13 - Power mgmt (6) */
2667 0x0000, /* R14 - Power mgmt (7) */
2668 0x0000, /* R15 */
2669 0x0000, /* R16 - RTC Seconds/Minutes */
2670 0x0100, /* R17 - RTC Hours/Day */
2671 0x0101, /* R18 - RTC Date/Month */
2672 0x1400, /* R19 - RTC Year */
2673 0x0000, /* R20 - Alarm Seconds/Minutes */
2674 0x0000, /* R21 - Alarm Hours/Day */
2675 0x0000, /* R22 - Alarm Date/Month */
2676 0x0320, /* R23 - RTC Time Control */
2677 0x0000, /* R24 - System Interrupts */
2678 0x0000, /* R25 - Interrupt Status 1 */
2679 0x0000, /* R26 - Interrupt Status 2 */
2680 0x0000, /* R27 */
2681 0x0000, /* R28 - Under Voltage Interrupt status */
2682 0x0000, /* R29 - Over Current Interrupt status */
2683 0x0000, /* R30 - GPIO Interrupt Status */
2684 0x0000, /* R31 - Comparator Interrupt Status */
2685 0x3FFF, /* R32 - System Interrupts Mask */
2686 0x0000, /* R33 - Interrupt Status 1 Mask */
2687 0x0000, /* R34 - Interrupt Status 2 Mask */
2688 0x0000, /* R35 */
2689 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2690 0x0000, /* R37 - Over Current Interrupt status Mask */
2691 0x0000, /* R38 - GPIO Interrupt Status Mask */
2692 0x0000, /* R39 - Comparator Interrupt Status Mask */
2693 0x0040, /* R40 - Clock Control 1 */
2694 0x0000, /* R41 - Clock Control 2 */
2695 0x3A00, /* R42 - FLL Control 1 */
2696 0x7086, /* R43 - FLL Control 2 */
2697 0xC226, /* R44 - FLL Control 3 */
2698 0x0000, /* R45 - FLL Control 4 */
2699 0x0000, /* R46 */
2700 0x0000, /* R47 */
2701 0x0000, /* R48 - DAC Control */
2702 0x0000, /* R49 */
2703 0x00C0, /* R50 - DAC Digital Volume L */
2704 0x00C0, /* R51 - DAC Digital Volume R */
2705 0x0000, /* R52 */
2706 0x0040, /* R53 - DAC LR Rate */
2707 0x0000, /* R54 - DAC Clock Control */
2708 0x0000, /* R55 */
2709 0x0000, /* R56 */
2710 0x0000, /* R57 */
2711 0x4000, /* R58 - DAC Mute */
2712 0x0000, /* R59 - DAC Mute Volume */
2713 0x0000, /* R60 - DAC Side */
2714 0x0000, /* R61 */
2715 0x0000, /* R62 */
2716 0x0000, /* R63 */
2717 0x8000, /* R64 - ADC Control */
2718 0x0000, /* R65 */
2719 0x00C0, /* R66 - ADC Digital Volume L */
2720 0x00C0, /* R67 - ADC Digital Volume R */
2721 0x0000, /* R68 - ADC Divider */
2722 0x0000, /* R69 */
2723 0x0040, /* R70 - ADC LR Rate */
2724 0x0000, /* R71 */
2725 0x0303, /* R72 - Input Control */
2726 0x0000, /* R73 - IN3 Input Control */
2727 0x0000, /* R74 - Mic Bias Control */
2728 0x0000, /* R75 */
2729 0x0000, /* R76 - Output Control */
2730 0x0000, /* R77 - Jack Detect */
2731 0x0000, /* R78 - Anti Pop Control */
2732 0x0000, /* R79 */
2733 0x0040, /* R80 - Left Input Volume */
2734 0x0040, /* R81 - Right Input Volume */
2735 0x0000, /* R82 */
2736 0x0000, /* R83 */
2737 0x0000, /* R84 */
2738 0x0000, /* R85 */
2739 0x0000, /* R86 */
2740 0x0000, /* R87 */
2741 0x0800, /* R88 - Left Mixer Control */
2742 0x1000, /* R89 - Right Mixer Control */
2743 0x0000, /* R90 */
2744 0x0000, /* R91 */
2745 0x0000, /* R92 - OUT3 Mixer Control */
2746 0x0000, /* R93 - OUT4 Mixer Control */
2747 0x0000, /* R94 */
2748 0x0000, /* R95 */
2749 0x0000, /* R96 - Output Left Mixer Volume */
2750 0x0000, /* R97 - Output Right Mixer Volume */
2751 0x0000, /* R98 - Input Mixer Volume L */
2752 0x0000, /* R99 - Input Mixer Volume R */
2753 0x0000, /* R100 - Input Mixer Volume */
2754 0x0000, /* R101 */
2755 0x0000, /* R102 */
2756 0x0000, /* R103 */
2757 0x00E4, /* R104 - OUT1L Volume */
2758 0x00E4, /* R105 - OUT1R Volume */
2759 0x00E4, /* R106 - OUT2L Volume */
2760 0x02E4, /* R107 - OUT2R Volume */
2761 0x0000, /* R108 */
2762 0x0000, /* R109 */
2763 0x0000, /* R110 */
2764 0x0000, /* R111 - BEEP Volume */
2765 0x0A00, /* R112 - AI Formating */
2766 0x0000, /* R113 - ADC DAC COMP */
2767 0x0020, /* R114 - AI ADC Control */
2768 0x0020, /* R115 - AI DAC Control */
2769 0x0000, /* R116 */
2770 0x0000, /* R117 */
2771 0x0000, /* R118 */
2772 0x0000, /* R119 */
2773 0x0000, /* R120 */
2774 0x0000, /* R121 */
2775 0x0000, /* R122 */
2776 0x0000, /* R123 */
2777 0x0000, /* R124 */
2778 0x0000, /* R125 */
2779 0x0000, /* R126 */
2780 0x0000, /* R127 */
2781 0x1FFF, /* R128 - GPIO Debounce */
2782 0x0000, /* R129 - GPIO Pin pull up Control */
2783 0x0110, /* R130 - GPIO Pull down Control */
2784 0x0000, /* R131 - GPIO Interrupt Mode */
2785 0x0000, /* R132 */
2786 0x0000, /* R133 - GPIO Control */
2787 0x09DA, /* R134 - GPIO Configuration (i/o) */
2788 0x0DD6, /* R135 - GPIO Pin Polarity / Type */
2789 0x0000, /* R136 */
2790 0x0000, /* R137 */
2791 0x0000, /* R138 */
2792 0x0000, /* R139 */
2793 0x1310, /* R140 - GPIO Function Select 1 */
2794 0x0033, /* R141 - GPIO Function Select 2 */
2795 0x2000, /* R142 - GPIO Function Select 3 */
2796 0x0000, /* R143 - GPIO Function Select 4 */
2797 0x0000, /* R144 - Digitiser Control (1) */
2798 0x0002, /* R145 - Digitiser Control (2) */
2799 0x0000, /* R146 */
2800 0x0000, /* R147 */
2801 0x0000, /* R148 */
2802 0x0000, /* R149 */
2803 0x0000, /* R150 */
2804 0x0000, /* R151 */
2805 0x7000, /* R152 - AUX1 Readback */
2806 0x7000, /* R153 - AUX2 Readback */
2807 0x7000, /* R154 - AUX3 Readback */
2808 0x7000, /* R155 - AUX4 Readback */
2809 0x0000, /* R156 - USB Voltage Readback */
2810 0x0000, /* R157 - LINE Voltage Readback */
2811 0x0000, /* R158 - BATT Voltage Readback */
2812 0x0000, /* R159 - Chip Temp Readback */
2813 0x0000, /* R160 */
2814 0x0000, /* R161 */
2815 0x0000, /* R162 */
2816 0x0000, /* R163 - Generic Comparator Control */
2817 0x0000, /* R164 - Generic comparator 1 */
2818 0x0000, /* R165 - Generic comparator 2 */
2819 0x0000, /* R166 - Generic comparator 3 */
2820 0x0000, /* R167 - Generic comparator 4 */
2821 0xA00F, /* R168 - Battery Charger Control 1 */
2822 0x0B06, /* R169 - Battery Charger Control 2 */
2823 0x0000, /* R170 - Battery Charger Control 3 */
2824 0x0000, /* R171 */
2825 0x0000, /* R172 - Current Sink Driver A */
2826 0x0000, /* R173 - CSA Flash control */
2827 0x0000, /* R174 - Current Sink Driver B */
2828 0x0000, /* R175 - CSB Flash control */
2829 0x0000, /* R176 - DCDC/LDO requested */
2830 0x032D, /* R177 - DCDC Active options */
2831 0x0000, /* R178 - DCDC Sleep options */
2832 0x0025, /* R179 - Power-check comparator */
2833 0x000E, /* R180 - DCDC1 Control */
2834 0x0800, /* R181 - DCDC1 Timeouts */
2835 0x1006, /* R182 - DCDC1 Low Power */
2836 0x0018, /* R183 - DCDC2 Control */
2837 0x0000, /* R184 - DCDC2 Timeouts */
2838 0x0000, /* R185 */
2839 0x0056, /* R186 - DCDC3 Control */
2840 0x1800, /* R187 - DCDC3 Timeouts */
2841 0x0006, /* R188 - DCDC3 Low Power */
2842 0x000E, /* R189 - DCDC4 Control */
2843 0x1000, /* R190 - DCDC4 Timeouts */
2844 0x0006, /* R191 - DCDC4 Low Power */
2845 0x0008, /* R192 - DCDC5 Control */
2846 0x0000, /* R193 - DCDC5 Timeouts */
2847 0x0000, /* R194 */
2848 0x0026, /* R195 - DCDC6 Control */
2849 0x0C00, /* R196 - DCDC6 Timeouts */
2850 0x0006, /* R197 - DCDC6 Low Power */
2851 0x0000, /* R198 */
2852 0x0003, /* R199 - Limit Switch Control */
2853 0x001C, /* R200 - LDO1 Control */
2854 0x0000, /* R201 - LDO1 Timeouts */
2855 0x001C, /* R202 - LDO1 Low Power */
2856 0x0006, /* R203 - LDO2 Control */
2857 0x0400, /* R204 - LDO2 Timeouts */
2858 0x001C, /* R205 - LDO2 Low Power */
2859 0x001C, /* R206 - LDO3 Control */
2860 0x1400, /* R207 - LDO3 Timeouts */
2861 0x001C, /* R208 - LDO3 Low Power */
2862 0x001A, /* R209 - LDO4 Control */
2863 0x0000, /* R210 - LDO4 Timeouts */
2864 0x001C, /* R211 - LDO4 Low Power */
2865 0x0000, /* R212 */
2866 0x0000, /* R213 */
2867 0x0000, /* R214 */
2868 0x0000, /* R215 - VCC_FAULT Masks */
2869 0x001F, /* R216 - Main Bandgap Control */
2870 0x0000, /* R217 - OSC Control */
2871 0x9000, /* R218 - RTC Tick Control */
2872 0x0000, /* R219 - Security1 */
2873 0x4000, /* R220 */
2874 0x0000, /* R221 */
2875 0x0000, /* R222 */
2876 0x0000, /* R223 */
2877 0x0000, /* R224 - Signal overrides */
2878 0x0000, /* R225 - DCDC/LDO status */
2879 0x0000, /* R226 - Charger Overides/status */
2880 0x0000, /* R227 - misc overrides */
2881 0x0000, /* R228 - Supply overrides/status 1 */
2882 0x0000, /* R229 - Supply overrides/status 2 */
2883 0xE000, /* R230 - GPIO Pin Status */
2884 0x0000, /* R231 - comparotor overrides */
2885 0x0000, /* R232 */
2886 0x0000, /* R233 - State Machine status */
2887 0x1200, /* R234 */
2888 0x0000, /* R235 */
2889 0x8000, /* R236 */
2890 0x0000, /* R237 */
2891 0x0000, /* R238 */
2892 0x0000, /* R239 */
2893 0x0003, /* R240 */
2894 0x0000, /* R241 */
2895 0x0000, /* R242 */
2896 0x0004, /* R243 */
2897 0x0300, /* R244 */
2898 0x0000, /* R245 */
2899 0x0200, /* R246 */
2900 0x0000, /* R247 */
2901 0x1000, /* R248 - DCDC1 Test Controls */
2902 0x5000, /* R249 */
2903 0x1000, /* R250 - DCDC3 Test Controls */
2904 0x1000, /* R251 - DCDC4 Test Controls */
2905 0x5100, /* R252 */
2906 0x1000, /* R253 - DCDC6 Test Controls */
2907};
2908#endif
2909
2910#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_3
2911
2912#undef WM8350_HAVE_CONFIG_MODE
2913#define WM8350_HAVE_CONFIG_MODE
2914
2915const u16 wm8352_mode3_defaults[] = {
2916 0x6143, /* R0 - Reset/ID */
2917 0x0000, /* R1 - ID */
2918 0x0002, /* R2 - Revision */
2919 0x1C02, /* R3 - System Control 1 */
2920 0x0204, /* R4 - System Control 2 */
2921 0x0000, /* R5 - System Hibernate */
2922 0x8A00, /* R6 - Interface Control */
2923 0x0000, /* R7 */
2924 0x8000, /* R8 - Power mgmt (1) */
2925 0x0000, /* R9 - Power mgmt (2) */
2926 0x0000, /* R10 - Power mgmt (3) */
2927 0x2000, /* R11 - Power mgmt (4) */
2928 0x0E00, /* R12 - Power mgmt (5) */
2929 0x0000, /* R13 - Power mgmt (6) */
2930 0x0000, /* R14 - Power mgmt (7) */
2931 0x0000, /* R15 */
2932 0x0000, /* R16 - RTC Seconds/Minutes */
2933 0x0100, /* R17 - RTC Hours/Day */
2934 0x0101, /* R18 - RTC Date/Month */
2935 0x1400, /* R19 - RTC Year */
2936 0x0000, /* R20 - Alarm Seconds/Minutes */
2937 0x0000, /* R21 - Alarm Hours/Day */
2938 0x0000, /* R22 - Alarm Date/Month */
2939 0x0320, /* R23 - RTC Time Control */
2940 0x0000, /* R24 - System Interrupts */
2941 0x0000, /* R25 - Interrupt Status 1 */
2942 0x0000, /* R26 - Interrupt Status 2 */
2943 0x0000, /* R27 */
2944 0x0000, /* R28 - Under Voltage Interrupt status */
2945 0x0000, /* R29 - Over Current Interrupt status */
2946 0x0000, /* R30 - GPIO Interrupt Status */
2947 0x0000, /* R31 - Comparator Interrupt Status */
2948 0x3FFF, /* R32 - System Interrupts Mask */
2949 0x0000, /* R33 - Interrupt Status 1 Mask */
2950 0x0000, /* R34 - Interrupt Status 2 Mask */
2951 0x0000, /* R35 */
2952 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2953 0x0000, /* R37 - Over Current Interrupt status Mask */
2954 0x0000, /* R38 - GPIO Interrupt Status Mask */
2955 0x0000, /* R39 - Comparator Interrupt Status Mask */
2956 0x0040, /* R40 - Clock Control 1 */
2957 0x0000, /* R41 - Clock Control 2 */
2958 0x3A00, /* R42 - FLL Control 1 */
2959 0x7086, /* R43 - FLL Control 2 */
2960 0xC226, /* R44 - FLL Control 3 */
2961 0x0000, /* R45 - FLL Control 4 */
2962 0x0000, /* R46 */
2963 0x0000, /* R47 */
2964 0x0000, /* R48 - DAC Control */
2965 0x0000, /* R49 */
2966 0x00C0, /* R50 - DAC Digital Volume L */
2967 0x00C0, /* R51 - DAC Digital Volume R */
2968 0x0000, /* R52 */
2969 0x0040, /* R53 - DAC LR Rate */
2970 0x0000, /* R54 - DAC Clock Control */
2971 0x0000, /* R55 */
2972 0x0000, /* R56 */
2973 0x0000, /* R57 */
2974 0x4000, /* R58 - DAC Mute */
2975 0x0000, /* R59 - DAC Mute Volume */
2976 0x0000, /* R60 - DAC Side */
2977 0x0000, /* R61 */
2978 0x0000, /* R62 */
2979 0x0000, /* R63 */
2980 0x8000, /* R64 - ADC Control */
2981 0x0000, /* R65 */
2982 0x00C0, /* R66 - ADC Digital Volume L */
2983 0x00C0, /* R67 - ADC Digital Volume R */
2984 0x0000, /* R68 - ADC Divider */
2985 0x0000, /* R69 */
2986 0x0040, /* R70 - ADC LR Rate */
2987 0x0000, /* R71 */
2988 0x0303, /* R72 - Input Control */
2989 0x0000, /* R73 - IN3 Input Control */
2990 0x0000, /* R74 - Mic Bias Control */
2991 0x0000, /* R75 */
2992 0x0000, /* R76 - Output Control */
2993 0x0000, /* R77 - Jack Detect */
2994 0x0000, /* R78 - Anti Pop Control */
2995 0x0000, /* R79 */
2996 0x0040, /* R80 - Left Input Volume */
2997 0x0040, /* R81 - Right Input Volume */
2998 0x0000, /* R82 */
2999 0x0000, /* R83 */
3000 0x0000, /* R84 */
3001 0x0000, /* R85 */
3002 0x0000, /* R86 */
3003 0x0000, /* R87 */
3004 0x0800, /* R88 - Left Mixer Control */
3005 0x1000, /* R89 - Right Mixer Control */
3006 0x0000, /* R90 */
3007 0x0000, /* R91 */
3008 0x0000, /* R92 - OUT3 Mixer Control */
3009 0x0000, /* R93 - OUT4 Mixer Control */
3010 0x0000, /* R94 */
3011 0x0000, /* R95 */
3012 0x0000, /* R96 - Output Left Mixer Volume */
3013 0x0000, /* R97 - Output Right Mixer Volume */
3014 0x0000, /* R98 - Input Mixer Volume L */
3015 0x0000, /* R99 - Input Mixer Volume R */
3016 0x0000, /* R100 - Input Mixer Volume */
3017 0x0000, /* R101 */
3018 0x0000, /* R102 */
3019 0x0000, /* R103 */
3020 0x00E4, /* R104 - OUT1L Volume */
3021 0x00E4, /* R105 - OUT1R Volume */
3022 0x00E4, /* R106 - OUT2L Volume */
3023 0x02E4, /* R107 - OUT2R Volume */
3024 0x0000, /* R108 */
3025 0x0000, /* R109 */
3026 0x0000, /* R110 */
3027 0x0000, /* R111 - BEEP Volume */
3028 0x0A00, /* R112 - AI Formating */
3029 0x0000, /* R113 - ADC DAC COMP */
3030 0x0020, /* R114 - AI ADC Control */
3031 0x0020, /* R115 - AI DAC Control */
3032 0x0000, /* R116 */
3033 0x0000, /* R117 */
3034 0x0000, /* R118 */
3035 0x0000, /* R119 */
3036 0x0000, /* R120 */
3037 0x0000, /* R121 */
3038 0x0000, /* R122 */
3039 0x0000, /* R123 */
3040 0x0000, /* R124 */
3041 0x0000, /* R125 */
3042 0x0000, /* R126 */
3043 0x0000, /* R127 */
3044 0x1FFF, /* R128 - GPIO Debounce */
3045 0x0010, /* R129 - GPIO Pin pull up Control */
3046 0x0000, /* R130 - GPIO Pull down Control */
3047 0x0000, /* R131 - GPIO Interrupt Mode */
3048 0x0000, /* R132 */
3049 0x0000, /* R133 - GPIO Control */
3050 0x0BFB, /* R134 - GPIO Configuration (i/o) */
3051 0x0FFD, /* R135 - GPIO Pin Polarity / Type */
3052 0x0000, /* R136 */
3053 0x0000, /* R137 */
3054 0x0000, /* R138 */
3055 0x0000, /* R139 */
3056 0x0310, /* R140 - GPIO Function Select 1 */
3057 0x0001, /* R141 - GPIO Function Select 2 */
3058 0x2300, /* R142 - GPIO Function Select 3 */
3059 0x0003, /* R143 - GPIO Function Select 4 */
3060 0x0000, /* R144 - Digitiser Control (1) */
3061 0x0002, /* R145 - Digitiser Control (2) */
3062 0x0000, /* R146 */
3063 0x0000, /* R147 */
3064 0x0000, /* R148 */
3065 0x0000, /* R149 */
3066 0x0000, /* R150 */
3067 0x0000, /* R151 */
3068 0x7000, /* R152 - AUX1 Readback */
3069 0x7000, /* R153 - AUX2 Readback */
3070 0x7000, /* R154 - AUX3 Readback */
3071 0x7000, /* R155 - AUX4 Readback */
3072 0x0000, /* R156 - USB Voltage Readback */
3073 0x0000, /* R157 - LINE Voltage Readback */
3074 0x0000, /* R158 - BATT Voltage Readback */
3075 0x0000, /* R159 - Chip Temp Readback */
3076 0x0000, /* R160 */
3077 0x0000, /* R161 */
3078 0x0000, /* R162 */
3079 0x0000, /* R163 - Generic Comparator Control */
3080 0x0000, /* R164 - Generic comparator 1 */
3081 0x0000, /* R165 - Generic comparator 2 */
3082 0x0000, /* R166 - Generic comparator 3 */
3083 0x0000, /* R167 - Generic comparator 4 */
3084 0xA00F, /* R168 - Battery Charger Control 1 */
3085 0x0B06, /* R169 - Battery Charger Control 2 */
3086 0x0000, /* R170 - Battery Charger Control 3 */
3087 0x0000, /* R171 */
3088 0x0000, /* R172 - Current Sink Driver A */
3089 0x0000, /* R173 - CSA Flash control */
3090 0x0000, /* R174 - Current Sink Driver B */
3091 0x0000, /* R175 - CSB Flash control */
3092 0x0000, /* R176 - DCDC/LDO requested */
3093 0x032D, /* R177 - DCDC Active options */
3094 0x0000, /* R178 - DCDC Sleep options */
3095 0x0025, /* R179 - Power-check comparator */
3096 0x0006, /* R180 - DCDC1 Control */
3097 0x0400, /* R181 - DCDC1 Timeouts */
3098 0x1006, /* R182 - DCDC1 Low Power */
3099 0x0018, /* R183 - DCDC2 Control */
3100 0x0000, /* R184 - DCDC2 Timeouts */
3101 0x0000, /* R185 */
3102 0x0050, /* R186 - DCDC3 Control */
3103 0x0C00, /* R187 - DCDC3 Timeouts */
3104 0x0006, /* R188 - DCDC3 Low Power */
3105 0x000E, /* R189 - DCDC4 Control */
3106 0x0400, /* R190 - DCDC4 Timeouts */
3107 0x0006, /* R191 - DCDC4 Low Power */
3108 0x0008, /* R192 - DCDC5 Control */
3109 0x0000, /* R193 - DCDC5 Timeouts */
3110 0x0000, /* R194 */
3111 0x0029, /* R195 - DCDC6 Control */
3112 0x0800, /* R196 - DCDC6 Timeouts */
3113 0x0006, /* R197 - DCDC6 Low Power */
3114 0x0000, /* R198 */
3115 0x0003, /* R199 - Limit Switch Control */
3116 0x001D, /* R200 - LDO1 Control */
3117 0x1000, /* R201 - LDO1 Timeouts */
3118 0x001C, /* R202 - LDO1 Low Power */
3119 0x0017, /* R203 - LDO2 Control */
3120 0x1000, /* R204 - LDO2 Timeouts */
3121 0x001C, /* R205 - LDO2 Low Power */
3122 0x0006, /* R206 - LDO3 Control */
3123 0x1000, /* R207 - LDO3 Timeouts */
3124 0x001C, /* R208 - LDO3 Low Power */
3125 0x0010, /* R209 - LDO4 Control */
3126 0x1000, /* R210 - LDO4 Timeouts */
3127 0x001C, /* R211 - LDO4 Low Power */
3128 0x0000, /* R212 */
3129 0x0000, /* R213 */
3130 0x0000, /* R214 */
3131 0x0000, /* R215 - VCC_FAULT Masks */
3132 0x001F, /* R216 - Main Bandgap Control */
3133 0x0000, /* R217 - OSC Control */
3134 0x9000, /* R218 - RTC Tick Control */
3135 0x0000, /* R219 - Security1 */
3136 0x4000, /* R220 */
3137 0x0000, /* R221 */
3138 0x0000, /* R222 */
3139 0x0000, /* R223 */
3140 0x0000, /* R224 - Signal overrides */
3141 0x0000, /* R225 - DCDC/LDO status */
3142 0x0000, /* R226 - Charger Overides/status */
3143 0x0000, /* R227 - misc overrides */
3144 0x0000, /* R228 - Supply overrides/status 1 */
3145 0x0000, /* R229 - Supply overrides/status 2 */
3146 0xE000, /* R230 - GPIO Pin Status */
3147 0x0000, /* R231 - comparotor overrides */
3148 0x0000, /* R232 */
3149 0x0000, /* R233 - State Machine status */
3150 0x1200, /* R234 */
3151 0x0000, /* R235 */
3152 0x8000, /* R236 */
3153 0x0000, /* R237 */
3154 0x0000, /* R238 */
3155 0x0000, /* R239 */
3156 0x0003, /* R240 */
3157 0x0000, /* R241 */
3158 0x0000, /* R242 */
3159 0x0004, /* R243 */
3160 0x0300, /* R244 */
3161 0x0000, /* R245 */
3162 0x0200, /* R246 */
3163 0x0000, /* R247 */
3164 0x1000, /* R248 - DCDC1 Test Controls */
3165 0x5000, /* R249 */
3166 0x1000, /* R250 - DCDC3 Test Controls */
3167 0x1000, /* R251 - DCDC4 Test Controls */
3168 0x5100, /* R252 */
3169 0x1000, /* R253 - DCDC6 Test Controls */
3170};
3171#endif
3172
1077/* The register defaults for the config mode used must be compiled in but 3173/* The register defaults for the config mode used must be compiled in but
1078 * due to the impact on kernel size it is possible to disable 3174 * due to the impact on kernel size it is possible to disable
1079 */ 3175 */
@@ -1307,14 +3403,14 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
1307 { 0xFF3F, 0xE03F, 0x0000 }, /* R216 - Main Bandgap Control */ 3403 { 0xFF3F, 0xE03F, 0x0000 }, /* R216 - Main Bandgap Control */
1308 { 0xEF2F, 0xE02F, 0x0000 }, /* R217 - OSC Control */ 3404 { 0xEF2F, 0xE02F, 0x0000 }, /* R217 - OSC Control */
1309 { 0xF3FF, 0xB3FF, 0xc000 }, /* R218 - RTC Tick Control */ 3405 { 0xF3FF, 0xB3FF, 0xc000 }, /* R218 - RTC Tick Control */
1310 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R219 */ 3406 { 0xFFFF, 0xFFFF, 0x0000 }, /* R219 - Security */
1311 { 0x09FF, 0x01FF, 0x0000 }, /* R220 - RAM BIST 1 */ 3407 { 0x09FF, 0x01FF, 0x0000 }, /* R220 - RAM BIST 1 */
1312 { 0x0000, 0x0000, 0x0000 }, /* R221 */ 3408 { 0x0000, 0x0000, 0x0000 }, /* R221 */
1313 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R222 */ 3409 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R222 */
1314 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R223 */ 3410 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R223 */
1315 { 0x0000, 0x0000, 0x0000 }, /* R224 */ 3411 { 0x0000, 0x0000, 0x0000 }, /* R224 */
1316 { 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */ 3412 { 0x8F3F, 0x0000, 0xFFFF }, /* R225 - DCDC/LDO status */
1317 { 0x0000, 0x0000, 0x0000 }, /* R226 */ 3413 { 0x0000, 0x0000, 0xFFFF }, /* R226 - Charger status */
1318 { 0x0000, 0x0000, 0xFFFF }, /* R227 */ 3414 { 0x0000, 0x0000, 0xFFFF }, /* R227 */
1319 { 0x0000, 0x0000, 0x0000 }, /* R228 */ 3415 { 0x0000, 0x0000, 0x0000 }, /* R228 */
1320 { 0x0000, 0x0000, 0x0000 }, /* R229 */ 3416 { 0x0000, 0x0000, 0x0000 }, /* R229 */
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 6a0cedb5bb8a..cf30d06a0104 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -15,6 +15,7 @@
15#include <linux/bug.h> 15#include <linux/bug.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/mfd/core.h>
18#include <linux/mfd/wm8400-private.h> 19#include <linux/mfd/wm8400-private.h>
19#include <linux/mfd/wm8400-audio.h> 20#include <linux/mfd/wm8400-audio.h>
20 21
@@ -239,6 +240,16 @@ void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400)
239} 240}
240EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache); 241EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache);
241 242
243static int wm8400_register_codec(struct wm8400 *wm8400)
244{
245 struct mfd_cell cell = {
246 .name = "wm8400-codec",
247 .driver_data = wm8400,
248 };
249
250 return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0);
251}
252
242/* 253/*
243 * wm8400_init - Generic initialisation 254 * wm8400_init - Generic initialisation
244 * 255 *
@@ -296,24 +307,32 @@ static int wm8400_init(struct wm8400 *wm8400,
296 reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT; 307 reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT;
297 dev_info(wm8400->dev, "WM8400 revision %x\n", reg); 308 dev_info(wm8400->dev, "WM8400 revision %x\n", reg);
298 309
310 ret = wm8400_register_codec(wm8400);
311 if (ret != 0) {
312 dev_err(wm8400->dev, "Failed to register codec\n");
313 goto err_children;
314 }
315
299 if (pdata && pdata->platform_init) { 316 if (pdata && pdata->platform_init) {
300 ret = pdata->platform_init(wm8400->dev); 317 ret = pdata->platform_init(wm8400->dev);
301 if (ret != 0) 318 if (ret != 0) {
302 dev_err(wm8400->dev, "Platform init failed: %d\n", 319 dev_err(wm8400->dev, "Platform init failed: %d\n",
303 ret); 320 ret);
321 goto err_children;
322 }
304 } else 323 } else
305 dev_warn(wm8400->dev, "No platform initialisation supplied\n"); 324 dev_warn(wm8400->dev, "No platform initialisation supplied\n");
306 325
326 return 0;
327
328err_children:
329 mfd_remove_devices(wm8400->dev);
307 return ret; 330 return ret;
308} 331}
309 332
310static void wm8400_release(struct wm8400 *wm8400) 333static void wm8400_release(struct wm8400 *wm8400)
311{ 334{
312 int i; 335 mfd_remove_devices(wm8400->dev);
313
314 for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++)
315 if (wm8400->regulators[i].name)
316 platform_device_unregister(&wm8400->regulators[i]);
317} 336}
318 337
319#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 338#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 22a7e8ba211d..de966a6fb7e6 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -146,8 +146,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
146 146
147 if (ret) { 147 if (ret) {
148 ret->i_mode = mode; 148 ret->i_mode = mode;
149 ret->i_uid = ret->i_gid = 0;
150 ret->i_blocks = 0;
151 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 149 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
152 } 150 }
153 return ret; 151 return ret;
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 3d067c35185d..45b1f430685f 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -145,7 +145,7 @@ struct mmc_blk_request {
145static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) 145static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
146{ 146{
147 int err; 147 int err;
148 u32 blocks; 148 __be32 blocks;
149 149
150 struct mmc_request mrq; 150 struct mmc_request mrq;
151 struct mmc_command cmd; 151 struct mmc_command cmd;
@@ -204,9 +204,24 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
204 if (cmd.error || data.error) 204 if (cmd.error || data.error)
205 return (u32)-1; 205 return (u32)-1;
206 206
207 blocks = ntohl(blocks); 207 return ntohl(blocks);
208}
209
210static u32 get_card_status(struct mmc_card *card, struct request *req)
211{
212 struct mmc_command cmd;
213 int err;
208 214
209 return blocks; 215 memset(&cmd, 0, sizeof(struct mmc_command));
216 cmd.opcode = MMC_SEND_STATUS;
217 if (!mmc_host_is_spi(card->host))
218 cmd.arg = card->rca << 16;
219 cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
220 err = mmc_wait_for_cmd(card->host, &cmd, 0);
221 if (err)
222 printk(KERN_ERR "%s: error %d sending status comand",
223 req->rq_disk->disk_name, err);
224 return cmd.resp[0];
210} 225}
211 226
212static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) 227static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
@@ -214,13 +229,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
214 struct mmc_blk_data *md = mq->data; 229 struct mmc_blk_data *md = mq->data;
215 struct mmc_card *card = md->queue.card; 230 struct mmc_card *card = md->queue.card;
216 struct mmc_blk_request brq; 231 struct mmc_blk_request brq;
217 int ret = 1; 232 int ret = 1, disable_multi = 0;
218 233
219 mmc_claim_host(card->host); 234 mmc_claim_host(card->host);
220 235
221 do { 236 do {
222 struct mmc_command cmd; 237 struct mmc_command cmd;
223 u32 readcmd, writecmd; 238 u32 readcmd, writecmd, status = 0;
224 239
225 memset(&brq, 0, sizeof(struct mmc_blk_request)); 240 memset(&brq, 0, sizeof(struct mmc_blk_request));
226 brq.mrq.cmd = &brq.cmd; 241 brq.mrq.cmd = &brq.cmd;
@@ -236,6 +251,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
236 brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; 251 brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
237 brq.data.blocks = req->nr_sectors; 252 brq.data.blocks = req->nr_sectors;
238 253
254 /*
255 * After a read error, we redo the request one sector at a time
256 * in order to accurately determine which sectors can be read
257 * successfully.
258 */
259 if (disable_multi && brq.data.blocks > 1)
260 brq.data.blocks = 1;
261
239 if (brq.data.blocks > 1) { 262 if (brq.data.blocks > 1) {
240 /* SPI multiblock writes terminate using a special 263 /* SPI multiblock writes terminate using a special
241 * token, not a STOP_TRANSMISSION request. 264 * token, not a STOP_TRANSMISSION request.
@@ -264,6 +287,25 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
264 brq.data.sg = mq->sg; 287 brq.data.sg = mq->sg;
265 brq.data.sg_len = mmc_queue_map_sg(mq); 288 brq.data.sg_len = mmc_queue_map_sg(mq);
266 289
290 /*
291 * Adjust the sg list so it is the same size as the
292 * request.
293 */
294 if (brq.data.blocks != req->nr_sectors) {
295 int i, data_size = brq.data.blocks << 9;
296 struct scatterlist *sg;
297
298 for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) {
299 data_size -= sg->length;
300 if (data_size <= 0) {
301 sg->length += data_size;
302 i++;
303 break;
304 }
305 }
306 brq.data.sg_len = i;
307 }
308
267 mmc_queue_bounce_pre(mq); 309 mmc_queue_bounce_pre(mq);
268 310
269 mmc_wait_for_req(card->host, &brq.mrq); 311 mmc_wait_for_req(card->host, &brq.mrq);
@@ -275,19 +317,40 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
275 * until later as we need to wait for the card to leave 317 * until later as we need to wait for the card to leave
276 * programming mode even when things go wrong. 318 * programming mode even when things go wrong.
277 */ 319 */
320 if (brq.cmd.error || brq.data.error || brq.stop.error) {
321 if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
322 /* Redo read one sector at a time */
323 printk(KERN_WARNING "%s: retrying using single "
324 "block read\n", req->rq_disk->disk_name);
325 disable_multi = 1;
326 continue;
327 }
328 status = get_card_status(card, req);
329 }
330
278 if (brq.cmd.error) { 331 if (brq.cmd.error) {
279 printk(KERN_ERR "%s: error %d sending read/write command\n", 332 printk(KERN_ERR "%s: error %d sending read/write "
280 req->rq_disk->disk_name, brq.cmd.error); 333 "command, response %#x, card status %#x\n",
334 req->rq_disk->disk_name, brq.cmd.error,
335 brq.cmd.resp[0], status);
281 } 336 }
282 337
283 if (brq.data.error) { 338 if (brq.data.error) {
284 printk(KERN_ERR "%s: error %d transferring data\n", 339 if (brq.data.error == -ETIMEDOUT && brq.mrq.stop)
285 req->rq_disk->disk_name, brq.data.error); 340 /* 'Stop' response contains card status */
341 status = brq.mrq.stop->resp[0];
342 printk(KERN_ERR "%s: error %d transferring data,"
343 " sector %u, nr %u, card status %#x\n",
344 req->rq_disk->disk_name, brq.data.error,
345 (unsigned)req->sector,
346 (unsigned)req->nr_sectors, status);
286 } 347 }
287 348
288 if (brq.stop.error) { 349 if (brq.stop.error) {
289 printk(KERN_ERR "%s: error %d sending stop command\n", 350 printk(KERN_ERR "%s: error %d sending stop command, "
290 req->rq_disk->disk_name, brq.stop.error); 351 "response %#x, card status %#x\n",
352 req->rq_disk->disk_name, brq.stop.error,
353 brq.stop.resp[0], status);
291 } 354 }
292 355
293 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { 356 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) {
@@ -320,8 +383,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
320#endif 383#endif
321 } 384 }
322 385
323 if (brq.cmd.error || brq.data.error || brq.stop.error) 386 if (brq.cmd.error || brq.stop.error || brq.data.error) {
387 if (rq_data_dir(req) == READ) {
388 /*
389 * After an error, we redo I/O one sector at a
390 * time, so we only reach here after trying to
391 * read a single sector.
392 */
393 spin_lock_irq(&md->lock);
394 ret = __blk_end_request(req, -EIO, brq.data.blksz);
395 spin_unlock_irq(&md->lock);
396 continue;
397 }
324 goto cmd_err; 398 goto cmd_err;
399 }
325 400
326 /* 401 /*
327 * A block was successfully transferred. 402 * A block was successfully transferred.
@@ -343,25 +418,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
343 * If the card is not SD, we can still ok written sectors 418 * If the card is not SD, we can still ok written sectors
344 * as reported by the controller (which might be less than 419 * as reported by the controller (which might be less than
345 * the real number of written sectors, but never more). 420 * the real number of written sectors, but never more).
346 *
347 * For reads we just fail the entire chunk as that should
348 * be safe in all cases.
349 */ 421 */
350 if (rq_data_dir(req) != READ) { 422 if (mmc_card_sd(card)) {
351 if (mmc_card_sd(card)) { 423 u32 blocks;
352 u32 blocks;
353 424
354 blocks = mmc_sd_num_wr_blocks(card); 425 blocks = mmc_sd_num_wr_blocks(card);
355 if (blocks != (u32)-1) { 426 if (blocks != (u32)-1) {
356 spin_lock_irq(&md->lock);
357 ret = __blk_end_request(req, 0, blocks << 9);
358 spin_unlock_irq(&md->lock);
359 }
360 } else {
361 spin_lock_irq(&md->lock); 427 spin_lock_irq(&md->lock);
362 ret = __blk_end_request(req, 0, brq.data.bytes_xfered); 428 ret = __blk_end_request(req, 0, blocks << 9);
363 spin_unlock_irq(&md->lock); 429 spin_unlock_irq(&md->lock);
364 } 430 }
431 } else {
432 spin_lock_irq(&md->lock);
433 ret = __blk_end_request(req, 0, brq.data.bytes_xfered);
434 spin_unlock_irq(&md->lock);
365 } 435 }
366 436
367 mmc_release_host(card->host); 437 mmc_release_host(card->host);
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index f7284b905eb3..df6ce4a06cf3 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -20,6 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/leds.h> 21#include <linux/leds.h>
22#include <linux/scatterlist.h> 22#include <linux/scatterlist.h>
23#include <linux/log2.h>
23 24
24#include <linux/mmc/card.h> 25#include <linux/mmc/card.h>
25#include <linux/mmc/host.h> 26#include <linux/mmc/host.h>
@@ -448,6 +449,80 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width)
448 mmc_set_ios(host); 449 mmc_set_ios(host);
449} 450}
450 451
452/**
453 * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number
454 * @vdd: voltage (mV)
455 * @low_bits: prefer low bits in boundary cases
456 *
457 * This function returns the OCR bit number according to the provided @vdd
458 * value. If conversion is not possible a negative errno value returned.
459 *
460 * Depending on the @low_bits flag the function prefers low or high OCR bits
461 * on boundary voltages. For example,
462 * with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33);
463 * with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34);
464 *
465 * Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21).
466 */
467static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits)
468{
469 const int max_bit = ilog2(MMC_VDD_35_36);
470 int bit;
471
472 if (vdd < 1650 || vdd > 3600)
473 return -EINVAL;
474
475 if (vdd >= 1650 && vdd <= 1950)
476 return ilog2(MMC_VDD_165_195);
477
478 if (low_bits)
479 vdd -= 1;
480
481 /* Base 2000 mV, step 100 mV, bit's base 8. */
482 bit = (vdd - 2000) / 100 + 8;
483 if (bit > max_bit)
484 return max_bit;
485 return bit;
486}
487
488/**
489 * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask
490 * @vdd_min: minimum voltage value (mV)
491 * @vdd_max: maximum voltage value (mV)
492 *
493 * This function returns the OCR mask bits according to the provided @vdd_min
494 * and @vdd_max values. If conversion is not possible the function returns 0.
495 *
496 * Notes wrt boundary cases:
497 * This function sets the OCR bits for all boundary voltages, for example
498 * [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 |
499 * MMC_VDD_34_35 mask.
500 */
501u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
502{
503 u32 mask = 0;
504
505 if (vdd_max < vdd_min)
506 return 0;
507
508 /* Prefer high bits for the boundary vdd_max values. */
509 vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false);
510 if (vdd_max < 0)
511 return 0;
512
513 /* Prefer low bits for the boundary vdd_min values. */
514 vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true);
515 if (vdd_min < 0)
516 return 0;
517
518 /* Fill the mask, from max bit to min bit. */
519 while (vdd_max >= vdd_min)
520 mask |= 1 << vdd_max--;
521
522 return mask;
523}
524EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);
525
451/* 526/*
452 * Mask off any voltages we don't support and select 527 * Mask off any voltages we don't support and select
453 * the lowest voltage 528 * the lowest voltage
@@ -467,6 +542,8 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
467 host->ios.vdd = bit; 542 host->ios.vdd = bit;
468 mmc_set_ios(host); 543 mmc_set_ios(host);
469 } else { 544 } else {
545 pr_warning("%s: host doesn't support card's voltages\n",
546 mmc_hostname(host));
470 ocr = 0; 547 ocr = 0;
471 } 548 }
472 549
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index fdd7c760be8c..c232d11a7ed4 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -434,13 +434,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
434 * Activate wide bus (if supported). 434 * Activate wide bus (if supported).
435 */ 435 */
436 if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) && 436 if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
437 (host->caps & MMC_CAP_4_BIT_DATA)) { 437 (host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) {
438 unsigned ext_csd_bit, bus_width;
439
440 if (host->caps & MMC_CAP_8_BIT_DATA) {
441 ext_csd_bit = EXT_CSD_BUS_WIDTH_8;
442 bus_width = MMC_BUS_WIDTH_8;
443 } else {
444 ext_csd_bit = EXT_CSD_BUS_WIDTH_4;
445 bus_width = MMC_BUS_WIDTH_4;
446 }
447
438 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 448 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
439 EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4); 449 EXT_CSD_BUS_WIDTH, ext_csd_bit);
450
440 if (err) 451 if (err)
441 goto free_card; 452 goto free_card;
442 453
443 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); 454 mmc_set_bus_width(card->host, bus_width);
444 } 455 }
445 456
446 if (!oldcard) 457 if (!oldcard)
@@ -624,4 +635,3 @@ err:
624 635
625 return err; 636 return err;
626} 637}
627
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index c794cc5ce442..f4853288bbb1 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -19,6 +19,9 @@ obj-$(CONFIG_MMC_AT91) += at91_mci.o
19obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o 19obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o
20obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o 20obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o
21obj-$(CONFIG_MMC_SPI) += mmc_spi.o 21obj-$(CONFIG_MMC_SPI) += mmc_spi.o
22ifeq ($(CONFIG_OF),y)
23obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o
24endif
22obj-$(CONFIG_MMC_S3C) += s3cmci.o 25obj-$(CONFIG_MMC_S3C) += s3cmci.o
23obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o 26obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o
24obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o 27obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 1f8b5b36222c..e556d42cc45a 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -1088,6 +1088,8 @@ static int __init at91_mci_probe(struct platform_device *pdev)
1088 goto fail0; 1088 goto fail0;
1089 } 1089 }
1090 1090
1091 setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host);
1092
1091 platform_set_drvdata(pdev, mmc); 1093 platform_set_drvdata(pdev, mmc);
1092 1094
1093 /* 1095 /*
@@ -1101,8 +1103,6 @@ static int __init at91_mci_probe(struct platform_device *pdev)
1101 1103
1102 mmc_add_host(mmc); 1104 mmc_add_host(mmc);
1103 1105
1104 setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host);
1105
1106 /* 1106 /*
1107 * monitor card insertion/removal if we can 1107 * monitor card insertion/removal if we can
1108 */ 1108 */
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index ad00e1632317..87e211df68ac 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1285,7 +1285,7 @@ static int mmc_spi_probe(struct spi_device *spi)
1285 /* Platform data is used to hook up things like card sensing 1285 /* Platform data is used to hook up things like card sensing
1286 * and power switching gpios. 1286 * and power switching gpios.
1287 */ 1287 */
1288 host->pdata = spi->dev.platform_data; 1288 host->pdata = mmc_spi_get_pdata(spi);
1289 if (host->pdata) 1289 if (host->pdata)
1290 mmc->ocr_avail = host->pdata->ocr_mask; 1290 mmc->ocr_avail = host->pdata->ocr_mask;
1291 if (!mmc->ocr_avail) { 1291 if (!mmc->ocr_avail) {
@@ -1368,6 +1368,7 @@ fail_glue_init:
1368 1368
1369fail_nobuf1: 1369fail_nobuf1:
1370 mmc_free_host(mmc); 1370 mmc_free_host(mmc);
1371 mmc_spi_put_pdata(spi);
1371 dev_set_drvdata(&spi->dev, NULL); 1372 dev_set_drvdata(&spi->dev, NULL);
1372 1373
1373nomem: 1374nomem:
@@ -1402,6 +1403,7 @@ static int __devexit mmc_spi_remove(struct spi_device *spi)
1402 1403
1403 spi->max_speed_hz = mmc->f_max; 1404 spi->max_speed_hz = mmc->f_max;
1404 mmc_free_host(mmc); 1405 mmc_free_host(mmc);
1406 mmc_spi_put_pdata(spi);
1405 dev_set_drvdata(&spi->dev, NULL); 1407 dev_set_drvdata(&spi->dev, NULL);
1406 } 1408 }
1407 return 0; 1409 return 0;
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
new file mode 100644
index 000000000000..fb2921f8099d
--- /dev/null
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -0,0 +1,149 @@
1/*
2 * OpenFirmware bindings for the MMC-over-SPI driver
3 *
4 * Copyright (c) MontaVista Software, Inc. 2008.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/device.h>
17#include <linux/gpio.h>
18#include <linux/of.h>
19#include <linux/of_gpio.h>
20#include <linux/spi/spi.h>
21#include <linux/spi/mmc_spi.h>
22#include <linux/mmc/core.h>
23#include <linux/mmc/host.h>
24
25enum {
26 CD_GPIO = 0,
27 WP_GPIO,
28 NUM_GPIOS,
29};
30
31struct of_mmc_spi {
32 int gpios[NUM_GPIOS];
33 bool alow_gpios[NUM_GPIOS];
34 struct mmc_spi_platform_data pdata;
35};
36
37static struct of_mmc_spi *to_of_mmc_spi(struct device *dev)
38{
39 return container_of(dev->platform_data, struct of_mmc_spi, pdata);
40}
41
42static int of_mmc_spi_read_gpio(struct device *dev, int gpio_num)
43{
44 struct of_mmc_spi *oms = to_of_mmc_spi(dev);
45 bool active_low = oms->alow_gpios[gpio_num];
46 bool value = gpio_get_value(oms->gpios[gpio_num]);
47
48 return active_low ^ value;
49}
50
51static int of_mmc_spi_get_cd(struct device *dev)
52{
53 return of_mmc_spi_read_gpio(dev, CD_GPIO);
54}
55
56static int of_mmc_spi_get_ro(struct device *dev)
57{
58 return of_mmc_spi_read_gpio(dev, WP_GPIO);
59}
60
61struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
62{
63 struct device *dev = &spi->dev;
64 struct device_node *np = dev_archdata_get_node(&dev->archdata);
65 struct of_mmc_spi *oms;
66 const u32 *voltage_ranges;
67 int num_ranges;
68 int i;
69 int ret = -EINVAL;
70
71 if (dev->platform_data || !np)
72 return dev->platform_data;
73
74 oms = kzalloc(sizeof(*oms), GFP_KERNEL);
75 if (!oms)
76 return NULL;
77
78 voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
79 num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
80 if (!voltage_ranges || !num_ranges) {
81 dev_err(dev, "OF: voltage-ranges unspecified\n");
82 goto err_ocr;
83 }
84
85 for (i = 0; i < num_ranges; i++) {
86 const int j = i * 2;
87 u32 mask;
88
89 mask = mmc_vddrange_to_ocrmask(voltage_ranges[j],
90 voltage_ranges[j + 1]);
91 if (!mask) {
92 ret = -EINVAL;
93 dev_err(dev, "OF: voltage-range #%d is invalid\n", i);
94 goto err_ocr;
95 }
96 oms->pdata.ocr_mask |= mask;
97 }
98
99 for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
100 enum of_gpio_flags gpio_flags;
101
102 oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags);
103 if (!gpio_is_valid(oms->gpios[i]))
104 continue;
105
106 ret = gpio_request(oms->gpios[i], dev->bus_id);
107 if (ret < 0) {
108 oms->gpios[i] = -EINVAL;
109 continue;
110 }
111
112 if (gpio_flags & OF_GPIO_ACTIVE_LOW)
113 oms->alow_gpios[i] = true;
114 }
115
116 if (gpio_is_valid(oms->gpios[CD_GPIO]))
117 oms->pdata.get_cd = of_mmc_spi_get_cd;
118 if (gpio_is_valid(oms->gpios[WP_GPIO]))
119 oms->pdata.get_ro = of_mmc_spi_get_ro;
120
121 /* We don't support interrupts yet, let's poll. */
122 oms->pdata.caps |= MMC_CAP_NEEDS_POLL;
123
124 dev->platform_data = &oms->pdata;
125 return dev->platform_data;
126err_ocr:
127 kfree(oms);
128 return NULL;
129}
130EXPORT_SYMBOL(mmc_spi_get_pdata);
131
132void mmc_spi_put_pdata(struct spi_device *spi)
133{
134 struct device *dev = &spi->dev;
135 struct device_node *np = dev_archdata_get_node(&dev->archdata);
136 struct of_mmc_spi *oms = to_of_mmc_spi(dev);
137 int i;
138
139 if (!dev->platform_data || !np)
140 return;
141
142 for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
143 if (gpio_is_valid(oms->gpios[i]))
144 gpio_free(oms->gpios[i]);
145 }
146 kfree(oms);
147 dev->platform_data = NULL;
148}
149EXPORT_SYMBOL(mmc_spi_put_pdata);
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index f88cc7406354..3c5483b75da4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -283,7 +283,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat)
283 return 0; 283 return 0;
284 284
285 DCSR(host->dma) = 0; 285 DCSR(host->dma) = 0;
286 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len, 286 dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
287 host->dma_dir); 287 host->dma_dir);
288 288
289 if (stat & STAT_READ_TIME_OUT) 289 if (stat & STAT_READ_TIME_OUT)
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c
index a16d7609e4ee..be9e7b32b34e 100644
--- a/drivers/mmc/host/ricoh_mmc.c
+++ b/drivers/mmc/host/ricoh_mmc.c
@@ -11,9 +11,10 @@
11 11
12/* 12/*
13 * This is a conceptually ridiculous driver, but it is required by the way 13 * This is a conceptually ridiculous driver, but it is required by the way
14 * the Ricoh multi-function R5C832 works. This chip implements firewire 14 * the Ricoh multi-function chips (R5CXXX) work. These chips implement
15 * and four different memory card controllers. Two of those controllers are 15 * the four main memory card controllers (SD, MMC, MS, xD) and one or both
16 * an SDHCI controller and a proprietary MMC controller. The linux SDHCI 16 * of cardbus or firewire. It happens that they implement SD and MMC
17 * support as separate controllers (and PCI functions). The linux SDHCI
17 * driver supports MMC cards but the chip detects MMC cards in hardware 18 * driver supports MMC cards but the chip detects MMC cards in hardware
18 * and directs them to the MMC controller - so the SDHCI driver never sees 19 * and directs them to the MMC controller - so the SDHCI driver never sees
19 * them. To get around this, we must disable the useless MMC controller. 20 * them. To get around this, we must disable the useless MMC controller.
@@ -21,8 +22,10 @@
21 * a detection event occurs immediately, even if the MMC card is already 22 * a detection event occurs immediately, even if the MMC card is already
22 * in the reader. 23 * in the reader.
23 * 24 *
24 * The relevant registers live on the firewire function, so this is unavoidably 25 * It seems to be the case that the relevant PCI registers to deactivate the
25 * ugly. Such is life. 26 * MMC controller live on PCI function 0, which might be the cardbus controller
27 * or the firewire controller, depending on the particular chip in question. As
28 * such, it makes what this driver has to do unavoidably ugly. Such is life.
26 */ 29 */
27 30
28#include <linux/pci.h> 31#include <linux/pci.h>
@@ -143,6 +146,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
143 pci_get_device(PCI_VENDOR_ID_RICOH, 146 pci_get_device(PCI_VENDOR_ID_RICOH,
144 PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { 147 PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) {
145 if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && 148 if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
149 PCI_FUNC(fw_dev->devfn) == 0 &&
146 pdev->bus == fw_dev->bus) { 150 pdev->bus == fw_dev->bus) {
147 if (ricoh_mmc_disable(fw_dev) != 0) 151 if (ricoh_mmc_disable(fw_dev) != 0)
148 return -ENODEV; 152 return -ENODEV;
@@ -160,6 +164,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
160 (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, 164 (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH,
161 PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { 165 PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) {
162 if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && 166 if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) &&
167 PCI_FUNC(fw_dev->devfn) == 0 &&
163 pdev->bus == fw_dev->bus) { 168 pdev->bus == fw_dev->bus) {
164 if (ricoh_mmc_disable(fw_dev) != 0) 169 if (ricoh_mmc_disable(fw_dev) != 0)
165 return -ENODEV; 170 return -ENODEV;
@@ -172,7 +177,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev,
172 177
173 if (!ctrlfound) { 178 if (!ctrlfound) {
174 printk(KERN_WARNING DRIVER_NAME 179 printk(KERN_WARNING DRIVER_NAME
175 ": Main firewire function not found. Cannot disable controller.\n"); 180 ": Main Ricoh function not found. Cannot disable controller.\n");
176 return -ENODEV; 181 return -ENODEV;
177 } 182 }
178 183
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 9bd7026b0021..f07255cb17ee 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -545,7 +545,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
545 } 545 }
546 546
547 addr = pci_resource_start(pdev, bar); 547 addr = pci_resource_start(pdev, bar);
548 host->ioaddr = ioremap_nocache(addr, pci_resource_len(pdev, bar)); 548 host->ioaddr = pci_ioremap_bar(pdev, bar);
549 if (!host->ioaddr) { 549 if (!host->ioaddr) {
550 dev_err(&pdev->dev, "failed to remap registers\n"); 550 dev_err(&pdev->dev, "failed to remap registers\n");
551 goto release; 551 goto release;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 4d010a984bed..6b2d1f99af67 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -30,6 +30,11 @@
30#define DBG(f, x...) \ 30#define DBG(f, x...) \
31 pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) 31 pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
32 32
33#if defined(CONFIG_LEDS_CLASS) || (defined(CONFIG_LEDS_CLASS_MODULE) && \
34 defined(CONFIG_MMC_SDHCI_MODULE))
35#define SDHCI_USE_LEDS_CLASS
36#endif
37
33static unsigned int debug_quirks = 0; 38static unsigned int debug_quirks = 0;
34 39
35static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *); 40static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
@@ -149,7 +154,7 @@ static void sdhci_deactivate_led(struct sdhci_host *host)
149 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); 154 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
150} 155}
151 156
152#ifdef CONFIG_LEDS_CLASS 157#ifdef SDHCI_USE_LEDS_CLASS
153static void sdhci_led_control(struct led_classdev *led, 158static void sdhci_led_control(struct led_classdev *led,
154 enum led_brightness brightness) 159 enum led_brightness brightness)
155{ 160{
@@ -994,7 +999,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
994 999
995 WARN_ON(host->mrq != NULL); 1000 WARN_ON(host->mrq != NULL);
996 1001
997#ifndef CONFIG_LEDS_CLASS 1002#ifndef SDHCI_USE_LEDS_CLASS
998 sdhci_activate_led(host); 1003 sdhci_activate_led(host);
999#endif 1004#endif
1000 1005
@@ -1201,7 +1206,7 @@ static void sdhci_tasklet_finish(unsigned long param)
1201 host->cmd = NULL; 1206 host->cmd = NULL;
1202 host->data = NULL; 1207 host->data = NULL;
1203 1208
1204#ifndef CONFIG_LEDS_CLASS 1209#ifndef SDHCI_USE_LEDS_CLASS
1205 sdhci_deactivate_led(host); 1210 sdhci_deactivate_led(host);
1206#endif 1211#endif
1207 1212
@@ -1717,7 +1722,7 @@ int sdhci_add_host(struct sdhci_host *host)
1717 sdhci_dumpregs(host); 1722 sdhci_dumpregs(host);
1718#endif 1723#endif
1719 1724
1720#ifdef CONFIG_LEDS_CLASS 1725#ifdef SDHCI_USE_LEDS_CLASS
1721 host->led.name = mmc_hostname(mmc); 1726 host->led.name = mmc_hostname(mmc);
1722 host->led.brightness = LED_OFF; 1727 host->led.brightness = LED_OFF;
1723 host->led.default_trigger = mmc_hostname(mmc); 1728 host->led.default_trigger = mmc_hostname(mmc);
@@ -1739,7 +1744,7 @@ int sdhci_add_host(struct sdhci_host *host)
1739 1744
1740 return 0; 1745 return 0;
1741 1746
1742#ifdef CONFIG_LEDS_CLASS 1747#ifdef SDHCI_USE_LEDS_CLASS
1743reset: 1748reset:
1744 sdhci_reset(host, SDHCI_RESET_ALL); 1749 sdhci_reset(host, SDHCI_RESET_ALL);
1745 free_irq(host->irq, host); 1750 free_irq(host->irq, host);
@@ -1775,7 +1780,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
1775 1780
1776 mmc_remove_host(host->mmc); 1781 mmc_remove_host(host->mmc);
1777 1782
1778#ifdef CONFIG_LEDS_CLASS 1783#ifdef SDHCI_USE_LEDS_CLASS
1779 led_classdev_unregister(&host->led); 1784 led_classdev_unregister(&host->led);
1780#endif 1785#endif
1781 1786
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 31f4b1528e76..3efba2363941 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -220,7 +220,7 @@ struct sdhci_host {
220 struct mmc_host *mmc; /* MMC structure */ 220 struct mmc_host *mmc; /* MMC structure */
221 u64 dma_mask; /* custom DMA mask */ 221 u64 dma_mask; /* custom DMA mask */
222 222
223#ifdef CONFIG_LEDS_CLASS 223#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
224 struct led_classdev led; /* LED control */ 224 struct led_classdev led; /* LED control */
225#endif 225#endif
226 226
diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index 1df44d966bdb..cb41e9c3ac07 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -82,6 +82,8 @@ static struct pcmcia_device_id pcmcia_ids[] = {
82 /* vendor and device strings followed by their crc32 hashes */ 82 /* vendor and device strings followed by their crc32 hashes */
83 PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed, 83 PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed,
84 0xc3901202), 84 0xc3901202),
85 PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay Controller", 0xd9f522ed,
86 0xace80909),
85 PCMCIA_DEVICE_NULL, 87 PCMCIA_DEVICE_NULL,
86}; 88};
87 89
@@ -463,7 +465,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
463 465
464err: 466err:
465 if (iobase) 467 if (iobase)
466 iounmap(iobase); 468 pci_iounmap(pci_dev, iobase);
467 if (mmc) 469 if (mmc)
468 mmc_free_host(mmc); 470 mmc_free_host(mmc);
469 471
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index 95430b81ec11..6a7a61904833 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -224,7 +224,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
224{ 224{
225 void __iomem *ctl = host->ctl; 225 void __iomem *ctl = host->ctl;
226 struct mmc_data *data = host->data; 226 struct mmc_data *data = host->data;
227 struct mmc_command *stop = data->stop; 227 struct mmc_command *stop;
228 228
229 host->data = NULL; 229 host->data = NULL;
230 230
@@ -232,6 +232,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host)
232 pr_debug("Spurious data end IRQ\n"); 232 pr_debug("Spurious data end IRQ\n");
233 return; 233 return;
234 } 234 }
235 stop = data->stop;
235 236
236 /* FIXME - return correct transfer count on errors */ 237 /* FIXME - return correct transfer count on errors */
237 if (!data->error) 238 if (!data->error)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index c7630a228310..ba0bd3d5775b 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -815,19 +815,20 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
815 if (err) 815 if (err)
816 goto out_free; 816 goto out_free;
817 817
818 err = -ENOMEM;
818 ubi->peb_buf1 = vmalloc(ubi->peb_size); 819 ubi->peb_buf1 = vmalloc(ubi->peb_size);
819 if (!ubi->peb_buf1) 820 if (!ubi->peb_buf1)
820 goto out_free; 821 goto out_free;
821 822
822 ubi->peb_buf2 = vmalloc(ubi->peb_size); 823 ubi->peb_buf2 = vmalloc(ubi->peb_size);
823 if (!ubi->peb_buf2) 824 if (!ubi->peb_buf2)
824 goto out_free; 825 goto out_free;
825 826
826#ifdef CONFIG_MTD_UBI_DEBUG 827#ifdef CONFIG_MTD_UBI_DEBUG
827 mutex_init(&ubi->dbg_buf_mutex); 828 mutex_init(&ubi->dbg_buf_mutex);
828 ubi->dbg_peb_buf = vmalloc(ubi->peb_size); 829 ubi->dbg_peb_buf = vmalloc(ubi->peb_size);
829 if (!ubi->dbg_peb_buf) 830 if (!ubi->dbg_peb_buf)
830 goto out_free; 831 goto out_free;
831#endif 832#endif
832 833
833 err = attach_by_scanning(ubi); 834 err = attach_by_scanning(ubi);
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index b30a0b83d7f1..98cf31ed0814 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -721,7 +721,8 @@ static int rename_volumes(struct ubi_device *ubi,
721 * It seems we need to remove volume with name @re->new_name, 721 * It seems we need to remove volume with name @re->new_name,
722 * if it exists. 722 * if it exists.
723 */ 723 */
724 desc = ubi_open_volume_nm(ubi->ubi_num, re->new_name, UBI_EXCLUSIVE); 724 desc = ubi_open_volume_nm(ubi->ubi_num, re->new_name,
725 UBI_EXCLUSIVE);
725 if (IS_ERR(desc)) { 726 if (IS_ERR(desc)) {
726 err = PTR_ERR(desc); 727 err = PTR_ERR(desc);
727 if (err == -ENODEV) 728 if (err == -ENODEV)
diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
index 78e914d23ece..13777e5beac9 100644
--- a/drivers/mtd/ubi/debug.h
+++ b/drivers/mtd/ubi/debug.h
@@ -27,11 +27,11 @@
27#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__) 27#define dbg_err(fmt, ...) ubi_err(fmt, ##__VA_ARGS__)
28 28
29#define ubi_assert(expr) do { \ 29#define ubi_assert(expr) do { \
30 if (unlikely(!(expr))) { \ 30 if (unlikely(!(expr))) { \
31 printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \ 31 printk(KERN_CRIT "UBI assert failed in %s at %u (pid %d)\n", \
32 __func__, __LINE__, current->pid); \ 32 __func__, __LINE__, current->pid); \
33 ubi_dbg_dump_stack(); \ 33 ubi_dbg_dump_stack(); \
34 } \ 34 } \
35} while (0) 35} while (0)
36 36
37#define dbg_msg(fmt, ...) \ 37#define dbg_msg(fmt, ...) \
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index d8966bae0e0b..048a606cebde 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -504,12 +504,9 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
504 if (!vid_hdr) 504 if (!vid_hdr)
505 return -ENOMEM; 505 return -ENOMEM;
506 506
507 mutex_lock(&ubi->buf_mutex);
508
509retry: 507retry:
510 new_pnum = ubi_wl_get_peb(ubi, UBI_UNKNOWN); 508 new_pnum = ubi_wl_get_peb(ubi, UBI_UNKNOWN);
511 if (new_pnum < 0) { 509 if (new_pnum < 0) {
512 mutex_unlock(&ubi->buf_mutex);
513 ubi_free_vid_hdr(ubi, vid_hdr); 510 ubi_free_vid_hdr(ubi, vid_hdr);
514 return new_pnum; 511 return new_pnum;
515 } 512 }
@@ -529,20 +526,23 @@ retry:
529 goto write_error; 526 goto write_error;
530 527
531 data_size = offset + len; 528 data_size = offset + len;
529 mutex_lock(&ubi->buf_mutex);
532 memset(ubi->peb_buf1 + offset, 0xFF, len); 530 memset(ubi->peb_buf1 + offset, 0xFF, len);
533 531
534 /* Read everything before the area where the write failure happened */ 532 /* Read everything before the area where the write failure happened */
535 if (offset > 0) { 533 if (offset > 0) {
536 err = ubi_io_read_data(ubi, ubi->peb_buf1, pnum, 0, offset); 534 err = ubi_io_read_data(ubi, ubi->peb_buf1, pnum, 0, offset);
537 if (err && err != UBI_IO_BITFLIPS) 535 if (err && err != UBI_IO_BITFLIPS)
538 goto out_put; 536 goto out_unlock;
539 } 537 }
540 538
541 memcpy(ubi->peb_buf1 + offset, buf, len); 539 memcpy(ubi->peb_buf1 + offset, buf, len);
542 540
543 err = ubi_io_write_data(ubi, ubi->peb_buf1, new_pnum, 0, data_size); 541 err = ubi_io_write_data(ubi, ubi->peb_buf1, new_pnum, 0, data_size);
544 if (err) 542 if (err) {
543 mutex_unlock(&ubi->buf_mutex);
545 goto write_error; 544 goto write_error;
545 }
546 546
547 mutex_unlock(&ubi->buf_mutex); 547 mutex_unlock(&ubi->buf_mutex);
548 ubi_free_vid_hdr(ubi, vid_hdr); 548 ubi_free_vid_hdr(ubi, vid_hdr);
@@ -553,8 +553,9 @@ retry:
553 ubi_msg("data was successfully recovered"); 553 ubi_msg("data was successfully recovered");
554 return 0; 554 return 0;
555 555
556out_put: 556out_unlock:
557 mutex_unlock(&ubi->buf_mutex); 557 mutex_unlock(&ubi->buf_mutex);
558out_put:
558 ubi_wl_put_peb(ubi, new_pnum, 1); 559 ubi_wl_put_peb(ubi, new_pnum, 1);
559 ubi_free_vid_hdr(ubi, vid_hdr); 560 ubi_free_vid_hdr(ubi, vid_hdr);
560 return err; 561 return err;
@@ -567,7 +568,6 @@ write_error:
567 ubi_warn("failed to write to PEB %d", new_pnum); 568 ubi_warn("failed to write to PEB %d", new_pnum);
568 ubi_wl_put_peb(ubi, new_pnum, 1); 569 ubi_wl_put_peb(ubi, new_pnum, 1);
569 if (++tries > UBI_IO_RETRIES) { 570 if (++tries > UBI_IO_RETRIES) {
570 mutex_unlock(&ubi->buf_mutex);
571 ubi_free_vid_hdr(ubi, vid_hdr); 571 ubi_free_vid_hdr(ubi, vid_hdr);
572 return err; 572 return err;
573 } 573 }
@@ -949,10 +949,14 @@ write_error:
949 * This function copies logical eraseblock from physical eraseblock @from to 949 * This function copies logical eraseblock from physical eraseblock @from to
950 * physical eraseblock @to. The @vid_hdr buffer may be changed by this 950 * physical eraseblock @to. The @vid_hdr buffer may be changed by this
951 * function. Returns: 951 * function. Returns:
952 * o %0 in case of success; 952 * o %0 in case of success;
953 * o %1 if the operation was canceled and should be tried later (e.g., 953 * o %1 if the operation was canceled because the volume is being deleted
954 * because a bit-flip was detected at the target PEB); 954 * or because the PEB was put meanwhile;
955 * o %2 if the volume is being deleted and this LEB should not be moved. 955 * o %2 if the operation was canceled because there was a write error to the
956 * target PEB;
957 * o %-EAGAIN if the operation was canceled because a bit-flip was detected
958 * in the target PEB;
959 * o a negative error code in case of failure.
956 */ 960 */
957int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, 961int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
958 struct ubi_vid_hdr *vid_hdr) 962 struct ubi_vid_hdr *vid_hdr)
@@ -978,7 +982,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
978 /* 982 /*
979 * Note, we may race with volume deletion, which means that the volume 983 * Note, we may race with volume deletion, which means that the volume
980 * this logical eraseblock belongs to might be being deleted. Since the 984 * this logical eraseblock belongs to might be being deleted. Since the
981 * volume deletion unmaps all the volume's logical eraseblocks, it will 985 * volume deletion un-maps all the volume's logical eraseblocks, it will
982 * be locked in 'ubi_wl_put_peb()' and wait for the WL worker to finish. 986 * be locked in 'ubi_wl_put_peb()' and wait for the WL worker to finish.
983 */ 987 */
984 vol = ubi->volumes[idx]; 988 vol = ubi->volumes[idx];
@@ -986,7 +990,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
986 /* No need to do further work, cancel */ 990 /* No need to do further work, cancel */
987 dbg_eba("volume %d is being removed, cancel", vol_id); 991 dbg_eba("volume %d is being removed, cancel", vol_id);
988 spin_unlock(&ubi->volumes_lock); 992 spin_unlock(&ubi->volumes_lock);
989 return 2; 993 return 1;
990 } 994 }
991 spin_unlock(&ubi->volumes_lock); 995 spin_unlock(&ubi->volumes_lock);
992 996
@@ -1023,7 +1027,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1023 1027
1024 /* 1028 /*
1025 * OK, now the LEB is locked and we can safely start moving it. Since 1029 * OK, now the LEB is locked and we can safely start moving it. Since
1026 * this function utilizes thie @ubi->peb1_buf buffer which is shared 1030 * this function utilizes the @ubi->peb1_buf buffer which is shared
1027 * with some other functions, so lock the buffer by taking the 1031 * with some other functions, so lock the buffer by taking the
1028 * @ubi->buf_mutex. 1032 * @ubi->buf_mutex.
1029 */ 1033 */
@@ -1068,8 +1072,11 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1068 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi)); 1072 vid_hdr->sqnum = cpu_to_be64(next_sqnum(ubi));
1069 1073
1070 err = ubi_io_write_vid_hdr(ubi, to, vid_hdr); 1074 err = ubi_io_write_vid_hdr(ubi, to, vid_hdr);
1071 if (err) 1075 if (err) {
1076 if (err == -EIO)
1077 err = 2;
1072 goto out_unlock_buf; 1078 goto out_unlock_buf;
1079 }
1073 1080
1074 cond_resched(); 1081 cond_resched();
1075 1082
@@ -1079,14 +1086,17 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1079 if (err != UBI_IO_BITFLIPS) 1086 if (err != UBI_IO_BITFLIPS)
1080 ubi_warn("cannot read VID header back from PEB %d", to); 1087 ubi_warn("cannot read VID header back from PEB %d", to);
1081 else 1088 else
1082 err = 1; 1089 err = -EAGAIN;
1083 goto out_unlock_buf; 1090 goto out_unlock_buf;
1084 } 1091 }
1085 1092
1086 if (data_size > 0) { 1093 if (data_size > 0) {
1087 err = ubi_io_write_data(ubi, ubi->peb_buf1, to, 0, aldata_size); 1094 err = ubi_io_write_data(ubi, ubi->peb_buf1, to, 0, aldata_size);
1088 if (err) 1095 if (err) {
1096 if (err == -EIO)
1097 err = 2;
1089 goto out_unlock_buf; 1098 goto out_unlock_buf;
1099 }
1090 1100
1091 cond_resched(); 1101 cond_resched();
1092 1102
@@ -1101,15 +1111,16 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1101 ubi_warn("cannot read data back from PEB %d", 1111 ubi_warn("cannot read data back from PEB %d",
1102 to); 1112 to);
1103 else 1113 else
1104 err = 1; 1114 err = -EAGAIN;
1105 goto out_unlock_buf; 1115 goto out_unlock_buf;
1106 } 1116 }
1107 1117
1108 cond_resched(); 1118 cond_resched();
1109 1119
1110 if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) { 1120 if (memcmp(ubi->peb_buf1, ubi->peb_buf2, aldata_size)) {
1111 ubi_warn("read data back from PEB %d - it is different", 1121 ubi_warn("read data back from PEB %d and it is "
1112 to); 1122 "different", to);
1123 err = -EINVAL;
1113 goto out_unlock_buf; 1124 goto out_unlock_buf;
1114 } 1125 }
1115 } 1126 }
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 2fb64be44f1b..a74118c05745 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -637,8 +637,6 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
637 637
638 dbg_io("read EC header from PEB %d", pnum); 638 dbg_io("read EC header from PEB %d", pnum);
639 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); 639 ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
640 if (UBI_IO_DEBUG)
641 verbose = 1;
642 640
643 err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); 641 err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE);
644 if (err) { 642 if (err) {
@@ -685,6 +683,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
685 if (verbose) 683 if (verbose)
686 ubi_warn("no EC header found at PEB %d, " 684 ubi_warn("no EC header found at PEB %d, "
687 "only 0xFF bytes", pnum); 685 "only 0xFF bytes", pnum);
686 else if (UBI_IO_DEBUG)
687 dbg_msg("no EC header found at PEB %d, "
688 "only 0xFF bytes", pnum);
688 return UBI_IO_PEB_EMPTY; 689 return UBI_IO_PEB_EMPTY;
689 } 690 }
690 691
@@ -696,7 +697,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
696 ubi_warn("bad magic number at PEB %d: %08x instead of " 697 ubi_warn("bad magic number at PEB %d: %08x instead of "
697 "%08x", pnum, magic, UBI_EC_HDR_MAGIC); 698 "%08x", pnum, magic, UBI_EC_HDR_MAGIC);
698 ubi_dbg_dump_ec_hdr(ec_hdr); 699 ubi_dbg_dump_ec_hdr(ec_hdr);
699 } 700 } else if (UBI_IO_DEBUG)
701 dbg_msg("bad magic number at PEB %d: %08x instead of "
702 "%08x", pnum, magic, UBI_EC_HDR_MAGIC);
700 return UBI_IO_BAD_EC_HDR; 703 return UBI_IO_BAD_EC_HDR;
701 } 704 }
702 705
@@ -708,7 +711,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
708 ubi_warn("bad EC header CRC at PEB %d, calculated " 711 ubi_warn("bad EC header CRC at PEB %d, calculated "
709 "%#08x, read %#08x", pnum, crc, hdr_crc); 712 "%#08x, read %#08x", pnum, crc, hdr_crc);
710 ubi_dbg_dump_ec_hdr(ec_hdr); 713 ubi_dbg_dump_ec_hdr(ec_hdr);
711 } 714 } else if (UBI_IO_DEBUG)
715 dbg_msg("bad EC header CRC at PEB %d, calculated "
716 "%#08x, read %#08x", pnum, crc, hdr_crc);
712 return UBI_IO_BAD_EC_HDR; 717 return UBI_IO_BAD_EC_HDR;
713 } 718 }
714 719
@@ -912,8 +917,6 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
912 917
913 dbg_io("read VID header from PEB %d", pnum); 918 dbg_io("read VID header from PEB %d", pnum);
914 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); 919 ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
915 if (UBI_IO_DEBUG)
916 verbose = 1;
917 920
918 p = (char *)vid_hdr - ubi->vid_hdr_shift; 921 p = (char *)vid_hdr - ubi->vid_hdr_shift;
919 err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, 922 err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
@@ -960,6 +963,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
960 if (verbose) 963 if (verbose)
961 ubi_warn("no VID header found at PEB %d, " 964 ubi_warn("no VID header found at PEB %d, "
962 "only 0xFF bytes", pnum); 965 "only 0xFF bytes", pnum);
966 else if (UBI_IO_DEBUG)
967 dbg_msg("no VID header found at PEB %d, "
968 "only 0xFF bytes", pnum);
963 return UBI_IO_PEB_FREE; 969 return UBI_IO_PEB_FREE;
964 } 970 }
965 971
@@ -971,7 +977,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
971 ubi_warn("bad magic number at PEB %d: %08x instead of " 977 ubi_warn("bad magic number at PEB %d: %08x instead of "
972 "%08x", pnum, magic, UBI_VID_HDR_MAGIC); 978 "%08x", pnum, magic, UBI_VID_HDR_MAGIC);
973 ubi_dbg_dump_vid_hdr(vid_hdr); 979 ubi_dbg_dump_vid_hdr(vid_hdr);
974 } 980 } else if (UBI_IO_DEBUG)
981 dbg_msg("bad magic number at PEB %d: %08x instead of "
982 "%08x", pnum, magic, UBI_VID_HDR_MAGIC);
975 return UBI_IO_BAD_VID_HDR; 983 return UBI_IO_BAD_VID_HDR;
976 } 984 }
977 985
@@ -983,7 +991,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
983 ubi_warn("bad CRC at PEB %d, calculated %#08x, " 991 ubi_warn("bad CRC at PEB %d, calculated %#08x, "
984 "read %#08x", pnum, crc, hdr_crc); 992 "read %#08x", pnum, crc, hdr_crc);
985 ubi_dbg_dump_vid_hdr(vid_hdr); 993 ubi_dbg_dump_vid_hdr(vid_hdr);
986 } 994 } else if (UBI_IO_DEBUG)
995 dbg_msg("bad CRC at PEB %d, calculated %#08x, "
996 "read %#08x", pnum, crc, hdr_crc);
987 return UBI_IO_BAD_VID_HDR; 997 return UBI_IO_BAD_VID_HDR;
988 } 998 }
989 999
@@ -1024,7 +1034,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
1024 1034
1025 err = paranoid_check_peb_ec_hdr(ubi, pnum); 1035 err = paranoid_check_peb_ec_hdr(ubi, pnum);
1026 if (err) 1036 if (err)
1027 return err > 0 ? -EINVAL: err; 1037 return err > 0 ? -EINVAL : err;
1028 1038
1029 vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC); 1039 vid_hdr->magic = cpu_to_be32(UBI_VID_HDR_MAGIC);
1030 vid_hdr->version = UBI_VERSION; 1040 vid_hdr->version = UBI_VERSION;
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 1c3fa18c26a7..4a8ec485c91d 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -74,6 +74,13 @@
74#define UBI_IO_RETRIES 3 74#define UBI_IO_RETRIES 3
75 75
76/* 76/*
77 * Length of the protection queue. The length is effectively equivalent to the
78 * number of (global) erase cycles PEBs are protected from the wear-leveling
79 * worker.
80 */
81#define UBI_PROT_QUEUE_LEN 10
82
83/*
77 * Error codes returned by the I/O sub-system. 84 * Error codes returned by the I/O sub-system.
78 * 85 *
79 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only 86 * UBI_IO_PEB_EMPTY: the physical eraseblock is empty, i.e. it contains only
@@ -95,7 +102,8 @@ enum {
95 102
96/** 103/**
97 * struct ubi_wl_entry - wear-leveling entry. 104 * struct ubi_wl_entry - wear-leveling entry.
98 * @rb: link in the corresponding RB-tree 105 * @u.rb: link in the corresponding (free/used) RB-tree
106 * @u.list: link in the protection queue
99 * @ec: erase counter 107 * @ec: erase counter
100 * @pnum: physical eraseblock number 108 * @pnum: physical eraseblock number
101 * 109 *
@@ -104,7 +112,10 @@ enum {
104 * RB-trees. See WL sub-system for details. 112 * RB-trees. See WL sub-system for details.
105 */ 113 */
106struct ubi_wl_entry { 114struct ubi_wl_entry {
107 struct rb_node rb; 115 union {
116 struct rb_node rb;
117 struct list_head list;
118 } u;
108 int ec; 119 int ec;
109 int pnum; 120 int pnum;
110}; 121};
@@ -288,7 +299,7 @@ struct ubi_wl_entry;
288 * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling 299 * @beb_rsvd_level: normal level of PEBs reserved for bad PEB handling
289 * 300 *
290 * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end 301 * @autoresize_vol_id: ID of the volume which has to be auto-resized at the end
291 * of UBI ititializetion 302 * of UBI initialization
292 * @vtbl_slots: how many slots are available in the volume table 303 * @vtbl_slots: how many slots are available in the volume table
293 * @vtbl_size: size of the volume table in bytes 304 * @vtbl_size: size of the volume table in bytes
294 * @vtbl: in-RAM volume table copy 305 * @vtbl: in-RAM volume table copy
@@ -306,18 +317,17 @@ struct ubi_wl_entry;
306 * @used: RB-tree of used physical eraseblocks 317 * @used: RB-tree of used physical eraseblocks
307 * @free: RB-tree of free physical eraseblocks 318 * @free: RB-tree of free physical eraseblocks
308 * @scrub: RB-tree of physical eraseblocks which need scrubbing 319 * @scrub: RB-tree of physical eraseblocks which need scrubbing
309 * @prot: protection trees 320 * @pq: protection queue (contain physical eraseblocks which are temporarily
310 * @prot.pnum: protection tree indexed by physical eraseblock numbers 321 * protected from the wear-leveling worker)
311 * @prot.aec: protection tree indexed by absolute erase counter value 322 * @pq_head: protection queue head
312 * @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, 323 * @wl_lock: protects the @used, @free, @pq, @pq_head, @lookuptbl, @move_from,
313 * @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works 324 * @move_to, @move_to_put @erase_pending, @wl_scheduled and @works
314 * fields 325 * fields
315 * @move_mutex: serializes eraseblock moves 326 * @move_mutex: serializes eraseblock moves
316 * @work_sem: sycnhronizes the WL worker with use tasks 327 * @work_sem: synchronizes the WL worker with use tasks
317 * @wl_scheduled: non-zero if the wear-leveling was scheduled 328 * @wl_scheduled: non-zero if the wear-leveling was scheduled
318 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any 329 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any
319 * physical eraseblock 330 * physical eraseblock
320 * @abs_ec: absolute erase counter
321 * @move_from: physical eraseblock from where the data is being moved 331 * @move_from: physical eraseblock from where the data is being moved
322 * @move_to: physical eraseblock where the data is being moved to 332 * @move_to: physical eraseblock where the data is being moved to
323 * @move_to_put: if the "to" PEB was put 333 * @move_to_put: if the "to" PEB was put
@@ -351,11 +361,11 @@ struct ubi_wl_entry;
351 * 361 *
352 * @peb_buf1: a buffer of PEB size used for different purposes 362 * @peb_buf1: a buffer of PEB size used for different purposes
353 * @peb_buf2: another buffer of PEB size used for different purposes 363 * @peb_buf2: another buffer of PEB size used for different purposes
354 * @buf_mutex: proptects @peb_buf1 and @peb_buf2 364 * @buf_mutex: protects @peb_buf1 and @peb_buf2
355 * @ckvol_mutex: serializes static volume checking when opening 365 * @ckvol_mutex: serializes static volume checking when opening
356 * @mult_mutex: serializes operations on multiple volumes, like re-nameing 366 * @mult_mutex: serializes operations on multiple volumes, like re-naming
357 * @dbg_peb_buf: buffer of PEB size used for debugging 367 * @dbg_peb_buf: buffer of PEB size used for debugging
358 * @dbg_buf_mutex: proptects @dbg_peb_buf 368 * @dbg_buf_mutex: protects @dbg_peb_buf
359 */ 369 */
360struct ubi_device { 370struct ubi_device {
361 struct cdev cdev; 371 struct cdev cdev;
@@ -392,16 +402,13 @@ struct ubi_device {
392 struct rb_root used; 402 struct rb_root used;
393 struct rb_root free; 403 struct rb_root free;
394 struct rb_root scrub; 404 struct rb_root scrub;
395 struct { 405 struct list_head pq[UBI_PROT_QUEUE_LEN];
396 struct rb_root pnum; 406 int pq_head;
397 struct rb_root aec;
398 } prot;
399 spinlock_t wl_lock; 407 spinlock_t wl_lock;
400 struct mutex move_mutex; 408 struct mutex move_mutex;
401 struct rw_semaphore work_sem; 409 struct rw_semaphore work_sem;
402 int wl_scheduled; 410 int wl_scheduled;
403 struct ubi_wl_entry **lookuptbl; 411 struct ubi_wl_entry **lookuptbl;
404 unsigned long long abs_ec;
405 struct ubi_wl_entry *move_from; 412 struct ubi_wl_entry *move_from;
406 struct ubi_wl_entry *move_to; 413 struct ubi_wl_entry *move_to;
407 int move_to_put; 414 int move_to_put;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index dcb6dac1dc54..14901cb82c18 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -22,7 +22,7 @@
22 * UBI wear-leveling sub-system. 22 * UBI wear-leveling sub-system.
23 * 23 *
24 * This sub-system is responsible for wear-leveling. It works in terms of 24 * This sub-system is responsible for wear-leveling. It works in terms of
25 * physical* eraseblocks and erase counters and knows nothing about logical 25 * physical eraseblocks and erase counters and knows nothing about logical
26 * eraseblocks, volumes, etc. From this sub-system's perspective all physical 26 * eraseblocks, volumes, etc. From this sub-system's perspective all physical
27 * eraseblocks are of two types - used and free. Used physical eraseblocks are 27 * eraseblocks are of two types - used and free. Used physical eraseblocks are
28 * those that were "get" by the 'ubi_wl_get_peb()' function, and free physical 28 * those that were "get" by the 'ubi_wl_get_peb()' function, and free physical
@@ -55,8 +55,39 @@
55 * 55 *
56 * As it was said, for the UBI sub-system all physical eraseblocks are either 56 * As it was said, for the UBI sub-system all physical eraseblocks are either
57 * "free" or "used". Free eraseblock are kept in the @wl->free RB-tree, while 57 * "free" or "used". Free eraseblock are kept in the @wl->free RB-tree, while
58 * used eraseblocks are kept in a set of different RB-trees: @wl->used, 58 * used eraseblocks are kept in @wl->used or @wl->scrub RB-trees, or
59 * @wl->prot.pnum, @wl->prot.aec, and @wl->scrub. 59 * (temporarily) in the @wl->pq queue.
60 *
61 * When the WL sub-system returns a physical eraseblock, the physical
62 * eraseblock is protected from being moved for some "time". For this reason,
63 * the physical eraseblock is not directly moved from the @wl->free tree to the
64 * @wl->used tree. There is a protection queue in between where this
65 * physical eraseblock is temporarily stored (@wl->pq).
66 *
67 * All this protection stuff is needed because:
68 * o we don't want to move physical eraseblocks just after we have given them
69 * to the user; instead, we first want to let users fill them up with data;
70 *
71 * o there is a chance that the user will put the physical eraseblock very
72 * soon, so it makes sense not to move it for some time, but wait; this is
73 * especially important in case of "short term" physical eraseblocks.
74 *
75 * Physical eraseblocks stay protected only for limited time. But the "time" is
76 * measured in erase cycles in this case. This is implemented with help of the
77 * protection queue. Eraseblocks are put to the tail of this queue when they
78 * are returned by the 'ubi_wl_get_peb()', and eraseblocks are removed from the
79 * head of the queue on each erase operation (for any eraseblock). So the
80 * length of the queue defines how may (global) erase cycles PEBs are protected.
81 *
82 * To put it differently, each physical eraseblock has 2 main states: free and
83 * used. The former state corresponds to the @wl->free tree. The latter state
84 * is split up on several sub-states:
85 * o the WL movement is allowed (@wl->used tree);
86 * o the WL movement is temporarily prohibited (@wl->pq queue);
87 * o scrubbing is needed (@wl->scrub tree).
88 *
89 * Depending on the sub-state, wear-leveling entries of the used physical
90 * eraseblocks may be kept in one of those structures.
60 * 91 *
61 * Note, in this implementation, we keep a small in-RAM object for each physical 92 * Note, in this implementation, we keep a small in-RAM object for each physical
62 * eraseblock. This is surely not a scalable solution. But it appears to be good 93 * eraseblock. This is surely not a scalable solution. But it appears to be good
@@ -70,9 +101,6 @@
70 * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we 101 * target PEB, we pick a PEB with the highest EC if our PEB is "old" and we
71 * pick target PEB with an average EC if our PEB is not very "old". This is a 102 * pick target PEB with an average EC if our PEB is not very "old". This is a
72 * room for future re-works of the WL sub-system. 103 * room for future re-works of the WL sub-system.
73 *
74 * Note: the stuff with protection trees looks too complex and is difficult to
75 * understand. Should be fixed.
76 */ 104 */
77 105
78#include <linux/slab.h> 106#include <linux/slab.h>
@@ -85,14 +113,6 @@
85#define WL_RESERVED_PEBS 1 113#define WL_RESERVED_PEBS 1
86 114
87/* 115/*
88 * How many erase cycles are short term, unknown, and long term physical
89 * eraseblocks protected.
90 */
91#define ST_PROTECTION 16
92#define U_PROTECTION 10
93#define LT_PROTECTION 4
94
95/*
96 * Maximum difference between two erase counters. If this threshold is 116 * Maximum difference between two erase counters. If this threshold is
97 * exceeded, the WL sub-system starts moving data from used physical 117 * exceeded, the WL sub-system starts moving data from used physical
98 * eraseblocks with low erase counter to free physical eraseblocks with high 118 * eraseblocks with low erase counter to free physical eraseblocks with high
@@ -120,64 +140,9 @@
120#define WL_MAX_FAILURES 32 140#define WL_MAX_FAILURES 32
121 141
122/** 142/**
123 * struct ubi_wl_prot_entry - PEB protection entry.
124 * @rb_pnum: link in the @wl->prot.pnum RB-tree
125 * @rb_aec: link in the @wl->prot.aec RB-tree
126 * @abs_ec: the absolute erase counter value when the protection ends
127 * @e: the wear-leveling entry of the physical eraseblock under protection
128 *
129 * When the WL sub-system returns a physical eraseblock, the physical
130 * eraseblock is protected from being moved for some "time". For this reason,
131 * the physical eraseblock is not directly moved from the @wl->free tree to the
132 * @wl->used tree. There is one more tree in between where this physical
133 * eraseblock is temporarily stored (@wl->prot).
134 *
135 * All this protection stuff is needed because:
136 * o we don't want to move physical eraseblocks just after we have given them
137 * to the user; instead, we first want to let users fill them up with data;
138 *
139 * o there is a chance that the user will put the physical eraseblock very
140 * soon, so it makes sense not to move it for some time, but wait; this is
141 * especially important in case of "short term" physical eraseblocks.
142 *
143 * Physical eraseblocks stay protected only for limited time. But the "time" is
144 * measured in erase cycles in this case. This is implemented with help of the
145 * absolute erase counter (@wl->abs_ec). When it reaches certain value, the
146 * physical eraseblocks are moved from the protection trees (@wl->prot.*) to
147 * the @wl->used tree.
148 *
149 * Protected physical eraseblocks are searched by physical eraseblock number
150 * (when they are put) and by the absolute erase counter (to check if it is
151 * time to move them to the @wl->used tree). So there are actually 2 RB-trees
152 * storing the protected physical eraseblocks: @wl->prot.pnum and
153 * @wl->prot.aec. They are referred to as the "protection" trees. The
154 * first one is indexed by the physical eraseblock number. The second one is
155 * indexed by the absolute erase counter. Both trees store
156 * &struct ubi_wl_prot_entry objects.
157 *
158 * Each physical eraseblock has 2 main states: free and used. The former state
159 * corresponds to the @wl->free tree. The latter state is split up on several
160 * sub-states:
161 * o the WL movement is allowed (@wl->used tree);
162 * o the WL movement is temporarily prohibited (@wl->prot.pnum and
163 * @wl->prot.aec trees);
164 * o scrubbing is needed (@wl->scrub tree).
165 *
166 * Depending on the sub-state, wear-leveling entries of the used physical
167 * eraseblocks may be kept in one of those trees.
168 */
169struct ubi_wl_prot_entry {
170 struct rb_node rb_pnum;
171 struct rb_node rb_aec;
172 unsigned long long abs_ec;
173 struct ubi_wl_entry *e;
174};
175
176/**
177 * struct ubi_work - UBI work description data structure. 143 * struct ubi_work - UBI work description data structure.
178 * @list: a link in the list of pending works 144 * @list: a link in the list of pending works
179 * @func: worker function 145 * @func: worker function
180 * @priv: private data of the worker function
181 * @e: physical eraseblock to erase 146 * @e: physical eraseblock to erase
182 * @torture: if the physical eraseblock has to be tortured 147 * @torture: if the physical eraseblock has to be tortured
183 * 148 *
@@ -198,9 +163,11 @@ struct ubi_work {
198static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec); 163static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec);
199static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e, 164static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
200 struct rb_root *root); 165 struct rb_root *root);
166static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e);
201#else 167#else
202#define paranoid_check_ec(ubi, pnum, ec) 0 168#define paranoid_check_ec(ubi, pnum, ec) 0
203#define paranoid_check_in_wl_tree(e, root) 169#define paranoid_check_in_wl_tree(e, root)
170#define paranoid_check_in_pq(ubi, e) 0
204#endif 171#endif
205 172
206/** 173/**
@@ -220,7 +187,7 @@ static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
220 struct ubi_wl_entry *e1; 187 struct ubi_wl_entry *e1;
221 188
222 parent = *p; 189 parent = *p;
223 e1 = rb_entry(parent, struct ubi_wl_entry, rb); 190 e1 = rb_entry(parent, struct ubi_wl_entry, u.rb);
224 191
225 if (e->ec < e1->ec) 192 if (e->ec < e1->ec)
226 p = &(*p)->rb_left; 193 p = &(*p)->rb_left;
@@ -235,8 +202,8 @@ static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
235 } 202 }
236 } 203 }
237 204
238 rb_link_node(&e->rb, parent, p); 205 rb_link_node(&e->u.rb, parent, p);
239 rb_insert_color(&e->rb, root); 206 rb_insert_color(&e->u.rb, root);
240} 207}
241 208
242/** 209/**
@@ -331,7 +298,7 @@ static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root)
331 while (p) { 298 while (p) {
332 struct ubi_wl_entry *e1; 299 struct ubi_wl_entry *e1;
333 300
334 e1 = rb_entry(p, struct ubi_wl_entry, rb); 301 e1 = rb_entry(p, struct ubi_wl_entry, u.rb);
335 302
336 if (e->pnum == e1->pnum) { 303 if (e->pnum == e1->pnum) {
337 ubi_assert(e == e1); 304 ubi_assert(e == e1);
@@ -355,50 +322,24 @@ static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root)
355} 322}
356 323
357/** 324/**
358 * prot_tree_add - add physical eraseblock to protection trees. 325 * prot_queue_add - add physical eraseblock to the protection queue.
359 * @ubi: UBI device description object 326 * @ubi: UBI device description object
360 * @e: the physical eraseblock to add 327 * @e: the physical eraseblock to add
361 * @pe: protection entry object to use
362 * @abs_ec: absolute erase counter value when this physical eraseblock has
363 * to be removed from the protection trees.
364 * 328 *
365 * @wl->lock has to be locked. 329 * This function adds @e to the tail of the protection queue @ubi->pq, where
330 * @e will stay for %UBI_PROT_QUEUE_LEN erase operations and will be
331 * temporarily protected from the wear-leveling worker. Note, @wl->lock has to
332 * be locked.
366 */ 333 */
367static void prot_tree_add(struct ubi_device *ubi, struct ubi_wl_entry *e, 334static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e)
368 struct ubi_wl_prot_entry *pe, int abs_ec)
369{ 335{
370 struct rb_node **p, *parent = NULL; 336 int pq_tail = ubi->pq_head - 1;
371 struct ubi_wl_prot_entry *pe1;
372
373 pe->e = e;
374 pe->abs_ec = ubi->abs_ec + abs_ec;
375
376 p = &ubi->prot.pnum.rb_node;
377 while (*p) {
378 parent = *p;
379 pe1 = rb_entry(parent, struct ubi_wl_prot_entry, rb_pnum);
380
381 if (e->pnum < pe1->e->pnum)
382 p = &(*p)->rb_left;
383 else
384 p = &(*p)->rb_right;
385 }
386 rb_link_node(&pe->rb_pnum, parent, p);
387 rb_insert_color(&pe->rb_pnum, &ubi->prot.pnum);
388
389 p = &ubi->prot.aec.rb_node;
390 parent = NULL;
391 while (*p) {
392 parent = *p;
393 pe1 = rb_entry(parent, struct ubi_wl_prot_entry, rb_aec);
394 337
395 if (pe->abs_ec < pe1->abs_ec) 338 if (pq_tail < 0)
396 p = &(*p)->rb_left; 339 pq_tail = UBI_PROT_QUEUE_LEN - 1;
397 else 340 ubi_assert(pq_tail >= 0 && pq_tail < UBI_PROT_QUEUE_LEN);
398 p = &(*p)->rb_right; 341 list_add_tail(&e->u.list, &ubi->pq[pq_tail]);
399 } 342 dbg_wl("added PEB %d EC %d to the protection queue", e->pnum, e->ec);
400 rb_link_node(&pe->rb_aec, parent, p);
401 rb_insert_color(&pe->rb_aec, &ubi->prot.aec);
402} 343}
403 344
404/** 345/**
@@ -414,14 +355,14 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max)
414 struct rb_node *p; 355 struct rb_node *p;
415 struct ubi_wl_entry *e; 356 struct ubi_wl_entry *e;
416 357
417 e = rb_entry(rb_first(root), struct ubi_wl_entry, rb); 358 e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb);
418 max += e->ec; 359 max += e->ec;
419 360
420 p = root->rb_node; 361 p = root->rb_node;
421 while (p) { 362 while (p) {
422 struct ubi_wl_entry *e1; 363 struct ubi_wl_entry *e1;
423 364
424 e1 = rb_entry(p, struct ubi_wl_entry, rb); 365 e1 = rb_entry(p, struct ubi_wl_entry, u.rb);
425 if (e1->ec >= max) 366 if (e1->ec >= max)
426 p = p->rb_left; 367 p = p->rb_left;
427 else { 368 else {
@@ -443,17 +384,12 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max)
443 */ 384 */
444int ubi_wl_get_peb(struct ubi_device *ubi, int dtype) 385int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
445{ 386{
446 int err, protect, medium_ec; 387 int err, medium_ec;
447 struct ubi_wl_entry *e, *first, *last; 388 struct ubi_wl_entry *e, *first, *last;
448 struct ubi_wl_prot_entry *pe;
449 389
450 ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM || 390 ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM ||
451 dtype == UBI_UNKNOWN); 391 dtype == UBI_UNKNOWN);
452 392
453 pe = kmalloc(sizeof(struct ubi_wl_prot_entry), GFP_NOFS);
454 if (!pe)
455 return -ENOMEM;
456
457retry: 393retry:
458 spin_lock(&ubi->wl_lock); 394 spin_lock(&ubi->wl_lock);
459 if (!ubi->free.rb_node) { 395 if (!ubi->free.rb_node) {
@@ -461,16 +397,13 @@ retry:
461 ubi_assert(list_empty(&ubi->works)); 397 ubi_assert(list_empty(&ubi->works));
462 ubi_err("no free eraseblocks"); 398 ubi_err("no free eraseblocks");
463 spin_unlock(&ubi->wl_lock); 399 spin_unlock(&ubi->wl_lock);
464 kfree(pe);
465 return -ENOSPC; 400 return -ENOSPC;
466 } 401 }
467 spin_unlock(&ubi->wl_lock); 402 spin_unlock(&ubi->wl_lock);
468 403
469 err = produce_free_peb(ubi); 404 err = produce_free_peb(ubi);
470 if (err < 0) { 405 if (err < 0)
471 kfree(pe);
472 return err; 406 return err;
473 }
474 goto retry; 407 goto retry;
475 } 408 }
476 409
@@ -483,7 +416,6 @@ retry:
483 * %WL_FREE_MAX_DIFF. 416 * %WL_FREE_MAX_DIFF.
484 */ 417 */
485 e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); 418 e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
486 protect = LT_PROTECTION;
487 break; 419 break;
488 case UBI_UNKNOWN: 420 case UBI_UNKNOWN:
489 /* 421 /*
@@ -492,81 +424,63 @@ retry:
492 * eraseblock with erase counter greater or equivalent than the 424 * eraseblock with erase counter greater or equivalent than the
493 * lowest erase counter plus %WL_FREE_MAX_DIFF. 425 * lowest erase counter plus %WL_FREE_MAX_DIFF.
494 */ 426 */
495 first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb); 427 first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry,
496 last = rb_entry(rb_last(&ubi->free), struct ubi_wl_entry, rb); 428 u.rb);
429 last = rb_entry(rb_last(&ubi->free), struct ubi_wl_entry, u.rb);
497 430
498 if (last->ec - first->ec < WL_FREE_MAX_DIFF) 431 if (last->ec - first->ec < WL_FREE_MAX_DIFF)
499 e = rb_entry(ubi->free.rb_node, 432 e = rb_entry(ubi->free.rb_node,
500 struct ubi_wl_entry, rb); 433 struct ubi_wl_entry, u.rb);
501 else { 434 else {
502 medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2; 435 medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2;
503 e = find_wl_entry(&ubi->free, medium_ec); 436 e = find_wl_entry(&ubi->free, medium_ec);
504 } 437 }
505 protect = U_PROTECTION;
506 break; 438 break;
507 case UBI_SHORTTERM: 439 case UBI_SHORTTERM:
508 /* 440 /*
509 * For short term data we pick a physical eraseblock with the 441 * For short term data we pick a physical eraseblock with the
510 * lowest erase counter as we expect it will be erased soon. 442 * lowest erase counter as we expect it will be erased soon.
511 */ 443 */
512 e = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb); 444 e = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, u.rb);
513 protect = ST_PROTECTION;
514 break; 445 break;
515 default: 446 default:
516 protect = 0;
517 e = NULL;
518 BUG(); 447 BUG();
519 } 448 }
520 449
450 paranoid_check_in_wl_tree(e, &ubi->free);
451
521 /* 452 /*
522 * Move the physical eraseblock to the protection trees where it will 453 * Move the physical eraseblock to the protection queue where it will
523 * be protected from being moved for some time. 454 * be protected from being moved for some time.
524 */ 455 */
525 paranoid_check_in_wl_tree(e, &ubi->free); 456 rb_erase(&e->u.rb, &ubi->free);
526 rb_erase(&e->rb, &ubi->free); 457 dbg_wl("PEB %d EC %d", e->pnum, e->ec);
527 prot_tree_add(ubi, e, pe, protect); 458 prot_queue_add(ubi, e);
528
529 dbg_wl("PEB %d EC %d, protection %d", e->pnum, e->ec, protect);
530 spin_unlock(&ubi->wl_lock); 459 spin_unlock(&ubi->wl_lock);
531
532 return e->pnum; 460 return e->pnum;
533} 461}
534 462
535/** 463/**
536 * prot_tree_del - remove a physical eraseblock from the protection trees 464 * prot_queue_del - remove a physical eraseblock from the protection queue.
537 * @ubi: UBI device description object 465 * @ubi: UBI device description object
538 * @pnum: the physical eraseblock to remove 466 * @pnum: the physical eraseblock to remove
539 * 467 *
540 * This function returns PEB @pnum from the protection trees and returns zero 468 * This function deletes PEB @pnum from the protection queue and returns zero
541 * in case of success and %-ENODEV if the PEB was not found in the protection 469 * in case of success and %-ENODEV if the PEB was not found.
542 * trees.
543 */ 470 */
544static int prot_tree_del(struct ubi_device *ubi, int pnum) 471static int prot_queue_del(struct ubi_device *ubi, int pnum)
545{ 472{
546 struct rb_node *p; 473 struct ubi_wl_entry *e;
547 struct ubi_wl_prot_entry *pe = NULL;
548
549 p = ubi->prot.pnum.rb_node;
550 while (p) {
551
552 pe = rb_entry(p, struct ubi_wl_prot_entry, rb_pnum);
553
554 if (pnum == pe->e->pnum)
555 goto found;
556 474
557 if (pnum < pe->e->pnum) 475 e = ubi->lookuptbl[pnum];
558 p = p->rb_left; 476 if (!e)
559 else 477 return -ENODEV;
560 p = p->rb_right;
561 }
562 478
563 return -ENODEV; 479 if (paranoid_check_in_pq(ubi, e))
480 return -ENODEV;
564 481
565found: 482 list_del(&e->u.list);
566 ubi_assert(pe->e->pnum == pnum); 483 dbg_wl("deleted PEB %d from the protection queue", e->pnum);
567 rb_erase(&pe->rb_aec, &ubi->prot.aec);
568 rb_erase(&pe->rb_pnum, &ubi->prot.pnum);
569 kfree(pe);
570 return 0; 484 return 0;
571} 485}
572 486
@@ -632,47 +546,47 @@ out_free:
632} 546}
633 547
634/** 548/**
635 * check_protection_over - check if it is time to stop protecting some PEBs. 549 * serve_prot_queue - check if it is time to stop protecting PEBs.
636 * @ubi: UBI device description object 550 * @ubi: UBI device description object
637 * 551 *
638 * This function is called after each erase operation, when the absolute erase 552 * This function is called after each erase operation and removes PEBs from the
639 * counter is incremented, to check if some physical eraseblock have not to be 553 * tail of the protection queue. These PEBs have been protected for long enough
640 * protected any longer. These physical eraseblocks are moved from the 554 * and should be moved to the used tree.
641 * protection trees to the used tree.
642 */ 555 */
643static void check_protection_over(struct ubi_device *ubi) 556static void serve_prot_queue(struct ubi_device *ubi)
644{ 557{
645 struct ubi_wl_prot_entry *pe; 558 struct ubi_wl_entry *e, *tmp;
559 int count;
646 560
647 /* 561 /*
648 * There may be several protected physical eraseblock to remove, 562 * There may be several protected physical eraseblock to remove,
649 * process them all. 563 * process them all.
650 */ 564 */
651 while (1) { 565repeat:
652 spin_lock(&ubi->wl_lock); 566 count = 0;
653 if (!ubi->prot.aec.rb_node) { 567 spin_lock(&ubi->wl_lock);
654 spin_unlock(&ubi->wl_lock); 568 list_for_each_entry_safe(e, tmp, &ubi->pq[ubi->pq_head], u.list) {
655 break; 569 dbg_wl("PEB %d EC %d protection over, move to used tree",
656 } 570 e->pnum, e->ec);
657
658 pe = rb_entry(rb_first(&ubi->prot.aec),
659 struct ubi_wl_prot_entry, rb_aec);
660 571
661 if (pe->abs_ec > ubi->abs_ec) { 572 list_del(&e->u.list);
573 wl_tree_add(e, &ubi->used);
574 if (count++ > 32) {
575 /*
576 * Let's be nice and avoid holding the spinlock for
577 * too long.
578 */
662 spin_unlock(&ubi->wl_lock); 579 spin_unlock(&ubi->wl_lock);
663 break; 580 cond_resched();
581 goto repeat;
664 } 582 }
665
666 dbg_wl("PEB %d protection over, abs_ec %llu, PEB abs_ec %llu",
667 pe->e->pnum, ubi->abs_ec, pe->abs_ec);
668 rb_erase(&pe->rb_aec, &ubi->prot.aec);
669 rb_erase(&pe->rb_pnum, &ubi->prot.pnum);
670 wl_tree_add(pe->e, &ubi->used);
671 spin_unlock(&ubi->wl_lock);
672
673 kfree(pe);
674 cond_resched();
675 } 583 }
584
585 ubi->pq_head += 1;
586 if (ubi->pq_head == UBI_PROT_QUEUE_LEN)
587 ubi->pq_head = 0;
588 ubi_assert(ubi->pq_head >= 0 && ubi->pq_head < UBI_PROT_QUEUE_LEN);
589 spin_unlock(&ubi->wl_lock);
676} 590}
677 591
678/** 592/**
@@ -680,8 +594,8 @@ static void check_protection_over(struct ubi_device *ubi)
680 * @ubi: UBI device description object 594 * @ubi: UBI device description object
681 * @wrk: the work to schedule 595 * @wrk: the work to schedule
682 * 596 *
683 * This function enqueues a work defined by @wrk to the tail of the pending 597 * This function adds a work defined by @wrk to the tail of the pending works
684 * works list. 598 * list.
685 */ 599 */
686static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk) 600static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
687{ 601{
@@ -739,13 +653,11 @@ static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
739static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, 653static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
740 int cancel) 654 int cancel)
741{ 655{
742 int err, put = 0, scrubbing = 0, protect = 0; 656 int err, scrubbing = 0, torture = 0;
743 struct ubi_wl_prot_entry *uninitialized_var(pe);
744 struct ubi_wl_entry *e1, *e2; 657 struct ubi_wl_entry *e1, *e2;
745 struct ubi_vid_hdr *vid_hdr; 658 struct ubi_vid_hdr *vid_hdr;
746 659
747 kfree(wrk); 660 kfree(wrk);
748
749 if (cancel) 661 if (cancel)
750 return 0; 662 return 0;
751 663
@@ -781,7 +693,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
781 * highly worn-out free physical eraseblock. If the erase 693 * highly worn-out free physical eraseblock. If the erase
782 * counters differ much enough, start wear-leveling. 694 * counters differ much enough, start wear-leveling.
783 */ 695 */
784 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, rb); 696 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb);
785 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); 697 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
786 698
787 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) { 699 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) {
@@ -790,21 +702,21 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
790 goto out_cancel; 702 goto out_cancel;
791 } 703 }
792 paranoid_check_in_wl_tree(e1, &ubi->used); 704 paranoid_check_in_wl_tree(e1, &ubi->used);
793 rb_erase(&e1->rb, &ubi->used); 705 rb_erase(&e1->u.rb, &ubi->used);
794 dbg_wl("move PEB %d EC %d to PEB %d EC %d", 706 dbg_wl("move PEB %d EC %d to PEB %d EC %d",
795 e1->pnum, e1->ec, e2->pnum, e2->ec); 707 e1->pnum, e1->ec, e2->pnum, e2->ec);
796 } else { 708 } else {
797 /* Perform scrubbing */ 709 /* Perform scrubbing */
798 scrubbing = 1; 710 scrubbing = 1;
799 e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, rb); 711 e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, u.rb);
800 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); 712 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
801 paranoid_check_in_wl_tree(e1, &ubi->scrub); 713 paranoid_check_in_wl_tree(e1, &ubi->scrub);
802 rb_erase(&e1->rb, &ubi->scrub); 714 rb_erase(&e1->u.rb, &ubi->scrub);
803 dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum); 715 dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum);
804 } 716 }
805 717
806 paranoid_check_in_wl_tree(e2, &ubi->free); 718 paranoid_check_in_wl_tree(e2, &ubi->free);
807 rb_erase(&e2->rb, &ubi->free); 719 rb_erase(&e2->u.rb, &ubi->free);
808 ubi->move_from = e1; 720 ubi->move_from = e1;
809 ubi->move_to = e2; 721 ubi->move_to = e2;
810 spin_unlock(&ubi->wl_lock); 722 spin_unlock(&ubi->wl_lock);
@@ -844,46 +756,67 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
844 756
845 err = ubi_eba_copy_leb(ubi, e1->pnum, e2->pnum, vid_hdr); 757 err = ubi_eba_copy_leb(ubi, e1->pnum, e2->pnum, vid_hdr);
846 if (err) { 758 if (err) {
847 759 if (err == -EAGAIN)
760 goto out_not_moved;
848 if (err < 0) 761 if (err < 0)
849 goto out_error; 762 goto out_error;
850 if (err == 1) 763 if (err == 2) {
764 /* Target PEB write error, torture it */
765 torture = 1;
851 goto out_not_moved; 766 goto out_not_moved;
767 }
852 768
853 /* 769 /*
854 * For some reason the LEB was not moved - it might be because 770 * The LEB has not been moved because the volume is being
855 * the volume is being deleted. We should prevent this PEB from 771 * deleted or the PEB has been put meanwhile. We should prevent
856 * being selected for wear-levelling movement for some "time", 772 * this PEB from being selected for wear-leveling movement
857 * so put it to the protection tree. 773 * again, so put it to the protection queue.
858 */ 774 */
859 775
860 dbg_wl("cancelled moving PEB %d", e1->pnum); 776 dbg_wl("canceled moving PEB %d", e1->pnum);
861 pe = kmalloc(sizeof(struct ubi_wl_prot_entry), GFP_NOFS); 777 ubi_assert(err == 1);
862 if (!pe) { 778
863 err = -ENOMEM; 779 ubi_free_vid_hdr(ubi, vid_hdr);
864 goto out_error; 780 vid_hdr = NULL;
865 } 781
782 spin_lock(&ubi->wl_lock);
783 prot_queue_add(ubi, e1);
784 ubi_assert(!ubi->move_to_put);
785 ubi->move_from = ubi->move_to = NULL;
786 ubi->wl_scheduled = 0;
787 spin_unlock(&ubi->wl_lock);
866 788
867 protect = 1; 789 e1 = NULL;
790 err = schedule_erase(ubi, e2, 0);
791 if (err)
792 goto out_error;
793 mutex_unlock(&ubi->move_mutex);
794 return 0;
868 } 795 }
869 796
797 /* The PEB has been successfully moved */
870 ubi_free_vid_hdr(ubi, vid_hdr); 798 ubi_free_vid_hdr(ubi, vid_hdr);
871 if (scrubbing && !protect) 799 vid_hdr = NULL;
800 if (scrubbing)
872 ubi_msg("scrubbed PEB %d, data moved to PEB %d", 801 ubi_msg("scrubbed PEB %d, data moved to PEB %d",
873 e1->pnum, e2->pnum); 802 e1->pnum, e2->pnum);
874 803
875 spin_lock(&ubi->wl_lock); 804 spin_lock(&ubi->wl_lock);
876 if (protect) 805 if (!ubi->move_to_put) {
877 prot_tree_add(ubi, e1, pe, protect);
878 if (!ubi->move_to_put)
879 wl_tree_add(e2, &ubi->used); 806 wl_tree_add(e2, &ubi->used);
880 else 807 e2 = NULL;
881 put = 1; 808 }
882 ubi->move_from = ubi->move_to = NULL; 809 ubi->move_from = ubi->move_to = NULL;
883 ubi->move_to_put = ubi->wl_scheduled = 0; 810 ubi->move_to_put = ubi->wl_scheduled = 0;
884 spin_unlock(&ubi->wl_lock); 811 spin_unlock(&ubi->wl_lock);
885 812
886 if (put) { 813 err = schedule_erase(ubi, e1, 0);
814 if (err) {
815 e1 = NULL;
816 goto out_error;
817 }
818
819 if (e2) {
887 /* 820 /*
888 * Well, the target PEB was put meanwhile, schedule it for 821 * Well, the target PEB was put meanwhile, schedule it for
889 * erasure. 822 * erasure.
@@ -894,13 +827,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
894 goto out_error; 827 goto out_error;
895 } 828 }
896 829
897 if (!protect) {
898 err = schedule_erase(ubi, e1, 0);
899 if (err)
900 goto out_error;
901 }
902
903
904 dbg_wl("done"); 830 dbg_wl("done");
905 mutex_unlock(&ubi->move_mutex); 831 mutex_unlock(&ubi->move_mutex);
906 return 0; 832 return 0;
@@ -908,20 +834,24 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
908 /* 834 /*
909 * For some reasons the LEB was not moved, might be an error, might be 835 * For some reasons the LEB was not moved, might be an error, might be
910 * something else. @e1 was not changed, so return it back. @e2 might 836 * something else. @e1 was not changed, so return it back. @e2 might
911 * be changed, schedule it for erasure. 837 * have been changed, schedule it for erasure.
912 */ 838 */
913out_not_moved: 839out_not_moved:
840 dbg_wl("canceled moving PEB %d", e1->pnum);
914 ubi_free_vid_hdr(ubi, vid_hdr); 841 ubi_free_vid_hdr(ubi, vid_hdr);
842 vid_hdr = NULL;
915 spin_lock(&ubi->wl_lock); 843 spin_lock(&ubi->wl_lock);
916 if (scrubbing) 844 if (scrubbing)
917 wl_tree_add(e1, &ubi->scrub); 845 wl_tree_add(e1, &ubi->scrub);
918 else 846 else
919 wl_tree_add(e1, &ubi->used); 847 wl_tree_add(e1, &ubi->used);
848 ubi_assert(!ubi->move_to_put);
920 ubi->move_from = ubi->move_to = NULL; 849 ubi->move_from = ubi->move_to = NULL;
921 ubi->move_to_put = ubi->wl_scheduled = 0; 850 ubi->wl_scheduled = 0;
922 spin_unlock(&ubi->wl_lock); 851 spin_unlock(&ubi->wl_lock);
923 852
924 err = schedule_erase(ubi, e2, 0); 853 e1 = NULL;
854 err = schedule_erase(ubi, e2, torture);
925 if (err) 855 if (err)
926 goto out_error; 856 goto out_error;
927 857
@@ -938,8 +868,10 @@ out_error:
938 ubi->move_to_put = ubi->wl_scheduled = 0; 868 ubi->move_to_put = ubi->wl_scheduled = 0;
939 spin_unlock(&ubi->wl_lock); 869 spin_unlock(&ubi->wl_lock);
940 870
941 kmem_cache_free(ubi_wl_entry_slab, e1); 871 if (e1)
942 kmem_cache_free(ubi_wl_entry_slab, e2); 872 kmem_cache_free(ubi_wl_entry_slab, e1);
873 if (e2)
874 kmem_cache_free(ubi_wl_entry_slab, e2);
943 ubi_ro_mode(ubi); 875 ubi_ro_mode(ubi);
944 876
945 mutex_unlock(&ubi->move_mutex); 877 mutex_unlock(&ubi->move_mutex);
@@ -988,7 +920,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi)
988 * erase counter of free physical eraseblocks is greater then 920 * erase counter of free physical eraseblocks is greater then
989 * %UBI_WL_THRESHOLD. 921 * %UBI_WL_THRESHOLD.
990 */ 922 */
991 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, rb); 923 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb);
992 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); 924 e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
993 925
994 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD)) 926 if (!(e2->ec - e1->ec >= UBI_WL_THRESHOLD))
@@ -1050,7 +982,6 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1050 kfree(wl_wrk); 982 kfree(wl_wrk);
1051 983
1052 spin_lock(&ubi->wl_lock); 984 spin_lock(&ubi->wl_lock);
1053 ubi->abs_ec += 1;
1054 wl_tree_add(e, &ubi->free); 985 wl_tree_add(e, &ubi->free);
1055 spin_unlock(&ubi->wl_lock); 986 spin_unlock(&ubi->wl_lock);
1056 987
@@ -1058,7 +989,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1058 * One more erase operation has happened, take care about 989 * One more erase operation has happened, take care about
1059 * protected physical eraseblocks. 990 * protected physical eraseblocks.
1060 */ 991 */
1061 check_protection_over(ubi); 992 serve_prot_queue(ubi);
1062 993
1063 /* And take care about wear-leveling */ 994 /* And take care about wear-leveling */
1064 err = ensure_wear_leveling(ubi); 995 err = ensure_wear_leveling(ubi);
@@ -1190,12 +1121,12 @@ retry:
1190 } else { 1121 } else {
1191 if (in_wl_tree(e, &ubi->used)) { 1122 if (in_wl_tree(e, &ubi->used)) {
1192 paranoid_check_in_wl_tree(e, &ubi->used); 1123 paranoid_check_in_wl_tree(e, &ubi->used);
1193 rb_erase(&e->rb, &ubi->used); 1124 rb_erase(&e->u.rb, &ubi->used);
1194 } else if (in_wl_tree(e, &ubi->scrub)) { 1125 } else if (in_wl_tree(e, &ubi->scrub)) {
1195 paranoid_check_in_wl_tree(e, &ubi->scrub); 1126 paranoid_check_in_wl_tree(e, &ubi->scrub);
1196 rb_erase(&e->rb, &ubi->scrub); 1127 rb_erase(&e->u.rb, &ubi->scrub);
1197 } else { 1128 } else {
1198 err = prot_tree_del(ubi, e->pnum); 1129 err = prot_queue_del(ubi, e->pnum);
1199 if (err) { 1130 if (err) {
1200 ubi_err("PEB %d not found", pnum); 1131 ubi_err("PEB %d not found", pnum);
1201 ubi_ro_mode(ubi); 1132 ubi_ro_mode(ubi);
@@ -1255,11 +1186,11 @@ retry:
1255 1186
1256 if (in_wl_tree(e, &ubi->used)) { 1187 if (in_wl_tree(e, &ubi->used)) {
1257 paranoid_check_in_wl_tree(e, &ubi->used); 1188 paranoid_check_in_wl_tree(e, &ubi->used);
1258 rb_erase(&e->rb, &ubi->used); 1189 rb_erase(&e->u.rb, &ubi->used);
1259 } else { 1190 } else {
1260 int err; 1191 int err;
1261 1192
1262 err = prot_tree_del(ubi, e->pnum); 1193 err = prot_queue_del(ubi, e->pnum);
1263 if (err) { 1194 if (err) {
1264 ubi_err("PEB %d not found", pnum); 1195 ubi_err("PEB %d not found", pnum);
1265 ubi_ro_mode(ubi); 1196 ubi_ro_mode(ubi);
@@ -1290,7 +1221,7 @@ int ubi_wl_flush(struct ubi_device *ubi)
1290 int err; 1221 int err;
1291 1222
1292 /* 1223 /*
1293 * Erase while the pending works queue is not empty, but not more then 1224 * Erase while the pending works queue is not empty, but not more than
1294 * the number of currently pending works. 1225 * the number of currently pending works.
1295 */ 1226 */
1296 dbg_wl("flush (%d pending works)", ubi->works_count); 1227 dbg_wl("flush (%d pending works)", ubi->works_count);
@@ -1308,7 +1239,7 @@ int ubi_wl_flush(struct ubi_device *ubi)
1308 up_write(&ubi->work_sem); 1239 up_write(&ubi->work_sem);
1309 1240
1310 /* 1241 /*
1311 * And in case last was the WL worker and it cancelled the LEB 1242 * And in case last was the WL worker and it canceled the LEB
1312 * movement, flush again. 1243 * movement, flush again.
1313 */ 1244 */
1314 while (ubi->works_count) { 1245 while (ubi->works_count) {
@@ -1337,11 +1268,11 @@ static void tree_destroy(struct rb_root *root)
1337 else if (rb->rb_right) 1268 else if (rb->rb_right)
1338 rb = rb->rb_right; 1269 rb = rb->rb_right;
1339 else { 1270 else {
1340 e = rb_entry(rb, struct ubi_wl_entry, rb); 1271 e = rb_entry(rb, struct ubi_wl_entry, u.rb);
1341 1272
1342 rb = rb_parent(rb); 1273 rb = rb_parent(rb);
1343 if (rb) { 1274 if (rb) {
1344 if (rb->rb_left == &e->rb) 1275 if (rb->rb_left == &e->u.rb)
1345 rb->rb_left = NULL; 1276 rb->rb_left = NULL;
1346 else 1277 else
1347 rb->rb_right = NULL; 1278 rb->rb_right = NULL;
@@ -1436,15 +1367,13 @@ static void cancel_pending(struct ubi_device *ubi)
1436 */ 1367 */
1437int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si) 1368int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
1438{ 1369{
1439 int err; 1370 int err, i;
1440 struct rb_node *rb1, *rb2; 1371 struct rb_node *rb1, *rb2;
1441 struct ubi_scan_volume *sv; 1372 struct ubi_scan_volume *sv;
1442 struct ubi_scan_leb *seb, *tmp; 1373 struct ubi_scan_leb *seb, *tmp;
1443 struct ubi_wl_entry *e; 1374 struct ubi_wl_entry *e;
1444 1375
1445
1446 ubi->used = ubi->free = ubi->scrub = RB_ROOT; 1376 ubi->used = ubi->free = ubi->scrub = RB_ROOT;
1447 ubi->prot.pnum = ubi->prot.aec = RB_ROOT;
1448 spin_lock_init(&ubi->wl_lock); 1377 spin_lock_init(&ubi->wl_lock);
1449 mutex_init(&ubi->move_mutex); 1378 mutex_init(&ubi->move_mutex);
1450 init_rwsem(&ubi->work_sem); 1379 init_rwsem(&ubi->work_sem);
@@ -1458,6 +1387,10 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
1458 if (!ubi->lookuptbl) 1387 if (!ubi->lookuptbl)
1459 return err; 1388 return err;
1460 1389
1390 for (i = 0; i < UBI_PROT_QUEUE_LEN; i++)
1391 INIT_LIST_HEAD(&ubi->pq[i]);
1392 ubi->pq_head = 0;
1393
1461 list_for_each_entry_safe(seb, tmp, &si->erase, u.list) { 1394 list_for_each_entry_safe(seb, tmp, &si->erase, u.list) {
1462 cond_resched(); 1395 cond_resched();
1463 1396
@@ -1552,33 +1485,18 @@ out_free:
1552} 1485}
1553 1486
1554/** 1487/**
1555 * protection_trees_destroy - destroy the protection RB-trees. 1488 * protection_queue_destroy - destroy the protection queue.
1556 * @ubi: UBI device description object 1489 * @ubi: UBI device description object
1557 */ 1490 */
1558static void protection_trees_destroy(struct ubi_device *ubi) 1491static void protection_queue_destroy(struct ubi_device *ubi)
1559{ 1492{
1560 struct rb_node *rb; 1493 int i;
1561 struct ubi_wl_prot_entry *pe; 1494 struct ubi_wl_entry *e, *tmp;
1562
1563 rb = ubi->prot.aec.rb_node;
1564 while (rb) {
1565 if (rb->rb_left)
1566 rb = rb->rb_left;
1567 else if (rb->rb_right)
1568 rb = rb->rb_right;
1569 else {
1570 pe = rb_entry(rb, struct ubi_wl_prot_entry, rb_aec);
1571
1572 rb = rb_parent(rb);
1573 if (rb) {
1574 if (rb->rb_left == &pe->rb_aec)
1575 rb->rb_left = NULL;
1576 else
1577 rb->rb_right = NULL;
1578 }
1579 1495
1580 kmem_cache_free(ubi_wl_entry_slab, pe->e); 1496 for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i) {
1581 kfree(pe); 1497 list_for_each_entry_safe(e, tmp, &ubi->pq[i], u.list) {
1498 list_del(&e->u.list);
1499 kmem_cache_free(ubi_wl_entry_slab, e);
1582 } 1500 }
1583 } 1501 }
1584} 1502}
@@ -1591,7 +1509,7 @@ void ubi_wl_close(struct ubi_device *ubi)
1591{ 1509{
1592 dbg_wl("close the WL sub-system"); 1510 dbg_wl("close the WL sub-system");
1593 cancel_pending(ubi); 1511 cancel_pending(ubi);
1594 protection_trees_destroy(ubi); 1512 protection_queue_destroy(ubi);
1595 tree_destroy(&ubi->used); 1513 tree_destroy(&ubi->used);
1596 tree_destroy(&ubi->free); 1514 tree_destroy(&ubi->free);
1597 tree_destroy(&ubi->scrub); 1515 tree_destroy(&ubi->scrub);
@@ -1661,4 +1579,27 @@ static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
1661 return 1; 1579 return 1;
1662} 1580}
1663 1581
1582/**
1583 * paranoid_check_in_pq - check if wear-leveling entry is in the protection
1584 * queue.
1585 * @ubi: UBI device description object
1586 * @e: the wear-leveling entry to check
1587 *
1588 * This function returns zero if @e is in @ubi->pq and %1 if it is not.
1589 */
1590static int paranoid_check_in_pq(struct ubi_device *ubi, struct ubi_wl_entry *e)
1591{
1592 struct ubi_wl_entry *p;
1593 int i;
1594
1595 for (i = 0; i < UBI_PROT_QUEUE_LEN; ++i)
1596 list_for_each_entry(p, &ubi->pq[i], u.list)
1597 if (p == e)
1598 return 0;
1599
1600 ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue",
1601 e->pnum, e->ec);
1602 ubi_dbg_dump_stack();
1603 return 1;
1604}
1664#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ 1605#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 517fce48d94a..5b396ff6c83f 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -66,6 +66,7 @@
66#include <linux/mm.h> 66#include <linux/mm.h>
67#include <linux/highmem.h> 67#include <linux/highmem.h>
68#include <linux/sockios.h> 68#include <linux/sockios.h>
69#include <linux/firmware.h>
69 70
70#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 71#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
71#include <linux/if_vlan.h> 72#include <linux/if_vlan.h>
@@ -186,8 +187,6 @@ MODULE_DEVICE_TABLE(pci, acenic_pci_tbl);
186#define MAX_RODATA_LEN 8*1024 187#define MAX_RODATA_LEN 8*1024
187#define MAX_DATA_LEN 2*1024 188#define MAX_DATA_LEN 2*1024
188 189
189#include "acenic_firmware.h"
190
191#ifndef tigon2FwReleaseLocal 190#ifndef tigon2FwReleaseLocal
192#define tigon2FwReleaseLocal 0 191#define tigon2FwReleaseLocal 0
193#endif 192#endif
@@ -417,6 +416,10 @@ static int dis_pci_mem_inval[ACE_MAX_MOD_PARMS] = {1, 1, 1, 1, 1, 1, 1, 1};
417MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>"); 416MODULE_AUTHOR("Jes Sorensen <jes@trained-monkey.org>");
418MODULE_LICENSE("GPL"); 417MODULE_LICENSE("GPL");
419MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver"); 418MODULE_DESCRIPTION("AceNIC/3C985/GA620 Gigabit Ethernet driver");
419#ifndef CONFIG_ACENIC_OMIT_TIGON_I
420MODULE_FIRMWARE("acenic/tg1.bin");
421#endif
422MODULE_FIRMWARE("acenic/tg2.bin");
420 423
421module_param_array_named(link, link_state, int, NULL, 0); 424module_param_array_named(link, link_state, int, NULL, 0);
422module_param_array(trace, int, NULL, 0); 425module_param_array(trace, int, NULL, 0);
@@ -943,8 +946,8 @@ static int __devinit ace_init(struct net_device *dev)
943 case 4: 946 case 4:
944 case 5: 947 case 5:
945 printk(KERN_INFO " Tigon I (Rev. %i), Firmware: %i.%i.%i, ", 948 printk(KERN_INFO " Tigon I (Rev. %i), Firmware: %i.%i.%i, ",
946 tig_ver, tigonFwReleaseMajor, tigonFwReleaseMinor, 949 tig_ver, ap->firmware_major, ap->firmware_minor,
947 tigonFwReleaseFix); 950 ap->firmware_fix);
948 writel(0, &regs->LocalCtrl); 951 writel(0, &regs->LocalCtrl);
949 ap->version = 1; 952 ap->version = 1;
950 ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES; 953 ap->tx_ring_entries = TIGON_I_TX_RING_ENTRIES;
@@ -952,8 +955,8 @@ static int __devinit ace_init(struct net_device *dev)
952#endif 955#endif
953 case 6: 956 case 6:
954 printk(KERN_INFO " Tigon II (Rev. %i), Firmware: %i.%i.%i, ", 957 printk(KERN_INFO " Tigon II (Rev. %i), Firmware: %i.%i.%i, ",
955 tig_ver, tigon2FwReleaseMajor, tigon2FwReleaseMinor, 958 tig_ver, ap->firmware_major, ap->firmware_minor,
956 tigon2FwReleaseFix); 959 ap->firmware_fix);
957 writel(readl(&regs->CpuBCtrl) | CPU_HALT, &regs->CpuBCtrl); 960 writel(readl(&regs->CpuBCtrl) | CPU_HALT, &regs->CpuBCtrl);
958 readl(&regs->CpuBCtrl); /* PCI write posting */ 961 readl(&regs->CpuBCtrl); /* PCI write posting */
959 /* 962 /*
@@ -1205,7 +1208,9 @@ static int __devinit ace_init(struct net_device *dev)
1205 memset(ap->info, 0, sizeof(struct ace_info)); 1208 memset(ap->info, 0, sizeof(struct ace_info));
1206 memset(ap->skb, 0, sizeof(struct ace_skb)); 1209 memset(ap->skb, 0, sizeof(struct ace_skb));
1207 1210
1208 ace_load_firmware(dev); 1211 if (ace_load_firmware(dev))
1212 goto init_error;
1213
1209 ap->fw_running = 0; 1214 ap->fw_running = 0;
1210 1215
1211 tmp_ptr = ap->info_dma; 1216 tmp_ptr = ap->info_dma;
@@ -1441,10 +1446,7 @@ static int __devinit ace_init(struct net_device *dev)
1441 if (ap->version >= 2) 1446 if (ap->version >= 2)
1442 writel(tmp, &regs->TuneFastLink); 1447 writel(tmp, &regs->TuneFastLink);
1443 1448
1444 if (ACE_IS_TIGON_I(ap)) 1449 writel(ap->firmware_start, &regs->Pc);
1445 writel(tigonFwStartAddr, &regs->Pc);
1446 if (ap->version == 2)
1447 writel(tigon2FwStartAddr, &regs->Pc);
1448 1450
1449 writel(0, &regs->Mb0Lo); 1451 writel(0, &regs->Mb0Lo);
1450 1452
@@ -2761,8 +2763,8 @@ static void ace_get_drvinfo(struct net_device *dev,
2761 2763
2762 strlcpy(info->driver, "acenic", sizeof(info->driver)); 2764 strlcpy(info->driver, "acenic", sizeof(info->driver));
2763 snprintf(info->version, sizeof(info->version), "%i.%i.%i", 2765 snprintf(info->version, sizeof(info->version), "%i.%i.%i",
2764 tigonFwReleaseMajor, tigonFwReleaseMinor, 2766 ap->firmware_major, ap->firmware_minor,
2765 tigonFwReleaseFix); 2767 ap->firmware_fix);
2766 2768
2767 if (ap->pdev) 2769 if (ap->pdev)
2768 strlcpy(info->bus_info, pci_name(ap->pdev), 2770 strlcpy(info->bus_info, pci_name(ap->pdev),
@@ -2869,11 +2871,10 @@ static struct net_device_stats *ace_get_stats(struct net_device *dev)
2869} 2871}
2870 2872
2871 2873
2872static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src, 2874static void __devinit ace_copy(struct ace_regs __iomem *regs, const __be32 *src,
2873 u32 dest, int size) 2875 u32 dest, int size)
2874{ 2876{
2875 void __iomem *tdest; 2877 void __iomem *tdest;
2876 u32 *wsrc;
2877 short tsize, i; 2878 short tsize, i;
2878 2879
2879 if (size <= 0) 2880 if (size <= 0)
@@ -2885,20 +2886,15 @@ static void __devinit ace_copy(struct ace_regs __iomem *regs, void *src,
2885 tdest = (void __iomem *) &regs->Window + 2886 tdest = (void __iomem *) &regs->Window +
2886 (dest & (ACE_WINDOW_SIZE - 1)); 2887 (dest & (ACE_WINDOW_SIZE - 1));
2887 writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase); 2888 writel(dest & ~(ACE_WINDOW_SIZE - 1), &regs->WinBase);
2888 /*
2889 * This requires byte swapping on big endian, however
2890 * writel does that for us
2891 */
2892 wsrc = src;
2893 for (i = 0; i < (tsize / 4); i++) { 2889 for (i = 0; i < (tsize / 4); i++) {
2894 writel(wsrc[i], tdest + i*4); 2890 /* Firmware is big-endian */
2891 writel(be32_to_cpup(src), tdest);
2892 src++;
2893 tdest += 4;
2894 dest += 4;
2895 size -= 4;
2895 } 2896 }
2896 dest += tsize;
2897 src += tsize;
2898 size -= tsize;
2899 } 2897 }
2900
2901 return;
2902} 2898}
2903 2899
2904 2900
@@ -2937,8 +2933,13 @@ static void __devinit ace_clear(struct ace_regs __iomem *regs, u32 dest, int siz
2937 */ 2933 */
2938static int __devinit ace_load_firmware(struct net_device *dev) 2934static int __devinit ace_load_firmware(struct net_device *dev)
2939{ 2935{
2936 const struct firmware *fw;
2937 const char *fw_name = "acenic/tg2.bin";
2940 struct ace_private *ap = netdev_priv(dev); 2938 struct ace_private *ap = netdev_priv(dev);
2941 struct ace_regs __iomem *regs = ap->regs; 2939 struct ace_regs __iomem *regs = ap->regs;
2940 const __be32 *fw_data;
2941 u32 load_addr;
2942 int ret;
2942 2943
2943 if (!(readl(&regs->CpuCtrl) & CPU_HALTED)) { 2944 if (!(readl(&regs->CpuCtrl) & CPU_HALTED)) {
2944 printk(KERN_ERR "%s: trying to download firmware while the " 2945 printk(KERN_ERR "%s: trying to download firmware while the "
@@ -2946,28 +2947,52 @@ static int __devinit ace_load_firmware(struct net_device *dev)
2946 return -EFAULT; 2947 return -EFAULT;
2947 } 2948 }
2948 2949
2950 if (ACE_IS_TIGON_I(ap))
2951 fw_name = "acenic/tg1.bin";
2952
2953 ret = request_firmware(&fw, fw_name, &ap->pdev->dev);
2954 if (ret) {
2955 printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n",
2956 ap->name, fw_name);
2957 return ret;
2958 }
2959
2960 fw_data = (void *)fw->data;
2961
2962 /* Firmware blob starts with version numbers, followed by
2963 load and start address. Remainder is the blob to be loaded
2964 contiguously from load address. We don't bother to represent
2965 the BSS/SBSS sections any more, since we were clearing the
2966 whole thing anyway. */
2967 ap->firmware_major = fw->data[0];
2968 ap->firmware_minor = fw->data[1];
2969 ap->firmware_fix = fw->data[2];
2970
2971 ap->firmware_start = be32_to_cpu(fw_data[1]);
2972 if (ap->firmware_start < 0x4000 || ap->firmware_start >= 0x80000) {
2973 printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
2974 ap->name, ap->firmware_start, fw_name);
2975 ret = -EINVAL;
2976 goto out;
2977 }
2978
2979 load_addr = be32_to_cpu(fw_data[2]);
2980 if (load_addr < 0x4000 || load_addr >= 0x80000) {
2981 printk(KERN_ERR "%s: bogus load address %08x in \"%s\"\n",
2982 ap->name, load_addr, fw_name);
2983 ret = -EINVAL;
2984 goto out;
2985 }
2986
2949 /* 2987 /*
2950 * Do not try to clear more than 512KB or we end up seeing 2988 * Do not try to clear more than 512KiB or we end up seeing
2951 * funny things on NICs with only 512KB SRAM 2989 * funny things on NICs with only 512KiB SRAM
2952 */ 2990 */
2953 ace_clear(regs, 0x2000, 0x80000-0x2000); 2991 ace_clear(regs, 0x2000, 0x80000-0x2000);
2954 if (ACE_IS_TIGON_I(ap)) { 2992 ace_copy(regs, &fw_data[3], load_addr, fw->size-12);
2955 ace_copy(regs, tigonFwText, tigonFwTextAddr, tigonFwTextLen); 2993 out:
2956 ace_copy(regs, tigonFwData, tigonFwDataAddr, tigonFwDataLen); 2994 release_firmware(fw);
2957 ace_copy(regs, tigonFwRodata, tigonFwRodataAddr, 2995 return ret;
2958 tigonFwRodataLen);
2959 ace_clear(regs, tigonFwBssAddr, tigonFwBssLen);
2960 ace_clear(regs, tigonFwSbssAddr, tigonFwSbssLen);
2961 }else if (ap->version == 2) {
2962 ace_clear(regs, tigon2FwBssAddr, tigon2FwBssLen);
2963 ace_clear(regs, tigon2FwSbssAddr, tigon2FwSbssLen);
2964 ace_copy(regs, tigon2FwText, tigon2FwTextAddr,tigon2FwTextLen);
2965 ace_copy(regs, tigon2FwRodata, tigon2FwRodataAddr,
2966 tigon2FwRodataLen);
2967 ace_copy(regs, tigon2FwData, tigon2FwDataAddr,tigon2FwDataLen);
2968 }
2969
2970 return 0;
2971} 2996}
2972 2997
2973 2998
diff --git a/drivers/net/acenic.h b/drivers/net/acenic.h
index 4487f32759a4..c987c9b5a137 100644
--- a/drivers/net/acenic.h
+++ b/drivers/net/acenic.h
@@ -694,6 +694,10 @@ struct ace_private
694 u32 last_tx, last_std_rx, last_mini_rx; 694 u32 last_tx, last_std_rx, last_mini_rx;
695#endif 695#endif
696 int pci_using_dac; 696 int pci_using_dac;
697 u8 firmware_major;
698 u8 firmware_minor;
699 u8 firmware_fix;
700 u32 firmware_start;
697}; 701};
698 702
699 703
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 9f38b16ccbbd..134b2d60b479 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -658,12 +658,12 @@ static int e100_self_test(struct nic *nic)
658 e100_disable_irq(nic); 658 e100_disable_irq(nic);
659 659
660 /* Check results of self-test */ 660 /* Check results of self-test */
661 if(nic->mem->selftest.result != 0) { 661 if (nic->mem->selftest.result != 0) {
662 DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n", 662 DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n",
663 nic->mem->selftest.result); 663 nic->mem->selftest.result);
664 return -ETIMEDOUT; 664 return -ETIMEDOUT;
665 } 665 }
666 if(nic->mem->selftest.signature == 0) { 666 if (nic->mem->selftest.signature == 0) {
667 DPRINTK(HW, ERR, "Self-test failed: timed out\n"); 667 DPRINTK(HW, ERR, "Self-test failed: timed out\n");
668 return -ETIMEDOUT; 668 return -ETIMEDOUT;
669 } 669 }
@@ -684,13 +684,13 @@ static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 da
684 cmd_addr_data[2] = op_ewds << (addr_len - 2); 684 cmd_addr_data[2] = op_ewds << (addr_len - 2);
685 685
686 /* Bit-bang cmds to write word to eeprom */ 686 /* Bit-bang cmds to write word to eeprom */
687 for(j = 0; j < 3; j++) { 687 for (j = 0; j < 3; j++) {
688 688
689 /* Chip select */ 689 /* Chip select */
690 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo); 690 iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo);
691 e100_write_flush(nic); udelay(4); 691 e100_write_flush(nic); udelay(4);
692 692
693 for(i = 31; i >= 0; i--) { 693 for (i = 31; i >= 0; i--) {
694 ctrl = (cmd_addr_data[j] & (1 << i)) ? 694 ctrl = (cmd_addr_data[j] & (1 << i)) ?
695 eecs | eedi : eecs; 695 eecs | eedi : eecs;
696 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); 696 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
@@ -723,7 +723,7 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
723 e100_write_flush(nic); udelay(4); 723 e100_write_flush(nic); udelay(4);
724 724
725 /* Bit-bang to read word from eeprom */ 725 /* Bit-bang to read word from eeprom */
726 for(i = 31; i >= 0; i--) { 726 for (i = 31; i >= 0; i--) {
727 ctrl = (cmd_addr_data & (1 << i)) ? eecs | eedi : eecs; 727 ctrl = (cmd_addr_data & (1 << i)) ? eecs | eedi : eecs;
728 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo); 728 iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
729 e100_write_flush(nic); udelay(4); 729 e100_write_flush(nic); udelay(4);
@@ -734,7 +734,7 @@ static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
734 /* Eeprom drives a dummy zero to EEDO after receiving 734 /* Eeprom drives a dummy zero to EEDO after receiving
735 * complete address. Use this to adjust addr_len. */ 735 * complete address. Use this to adjust addr_len. */
736 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo); 736 ctrl = ioread8(&nic->csr->eeprom_ctrl_lo);
737 if(!(ctrl & eedo) && i > 16) { 737 if (!(ctrl & eedo) && i > 16) {
738 *addr_len -= (i - 16); 738 *addr_len -= (i - 16);
739 i = 17; 739 i = 17;
740 } 740 }
@@ -758,9 +758,9 @@ static int e100_eeprom_load(struct nic *nic)
758 e100_eeprom_read(nic, &addr_len, 0); 758 e100_eeprom_read(nic, &addr_len, 0);
759 nic->eeprom_wc = 1 << addr_len; 759 nic->eeprom_wc = 1 << addr_len;
760 760
761 for(addr = 0; addr < nic->eeprom_wc; addr++) { 761 for (addr = 0; addr < nic->eeprom_wc; addr++) {
762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr); 762 nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
763 if(addr < nic->eeprom_wc - 1) 763 if (addr < nic->eeprom_wc - 1)
764 checksum += le16_to_cpu(nic->eeprom[addr]); 764 checksum += le16_to_cpu(nic->eeprom[addr]);
765 } 765 }
766 766
@@ -784,15 +784,15 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
784 e100_eeprom_read(nic, &addr_len, 0); 784 e100_eeprom_read(nic, &addr_len, 0);
785 nic->eeprom_wc = 1 << addr_len; 785 nic->eeprom_wc = 1 << addr_len;
786 786
787 if(start + count >= nic->eeprom_wc) 787 if (start + count >= nic->eeprom_wc)
788 return -EINVAL; 788 return -EINVAL;
789 789
790 for(addr = start; addr < start + count; addr++) 790 for (addr = start; addr < start + count; addr++)
791 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]); 791 e100_eeprom_write(nic, addr_len, addr, nic->eeprom[addr]);
792 792
793 /* The checksum, stored in the last word, is calculated such that 793 /* The checksum, stored in the last word, is calculated such that
794 * the sum of words should be 0xBABA */ 794 * the sum of words should be 0xBABA */
795 for(addr = 0; addr < nic->eeprom_wc - 1; addr++) 795 for (addr = 0; addr < nic->eeprom_wc - 1; addr++)
796 checksum += le16_to_cpu(nic->eeprom[addr]); 796 checksum += le16_to_cpu(nic->eeprom[addr]);
797 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum); 797 nic->eeprom[nic->eeprom_wc - 1] = cpu_to_le16(0xBABA - checksum);
798 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, 798 e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1,
@@ -812,19 +812,19 @@ static int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr)
812 spin_lock_irqsave(&nic->cmd_lock, flags); 812 spin_lock_irqsave(&nic->cmd_lock, flags);
813 813
814 /* Previous command is accepted when SCB clears */ 814 /* Previous command is accepted when SCB clears */
815 for(i = 0; i < E100_WAIT_SCB_TIMEOUT; i++) { 815 for (i = 0; i < E100_WAIT_SCB_TIMEOUT; i++) {
816 if(likely(!ioread8(&nic->csr->scb.cmd_lo))) 816 if (likely(!ioread8(&nic->csr->scb.cmd_lo)))
817 break; 817 break;
818 cpu_relax(); 818 cpu_relax();
819 if(unlikely(i > E100_WAIT_SCB_FAST)) 819 if (unlikely(i > E100_WAIT_SCB_FAST))
820 udelay(5); 820 udelay(5);
821 } 821 }
822 if(unlikely(i == E100_WAIT_SCB_TIMEOUT)) { 822 if (unlikely(i == E100_WAIT_SCB_TIMEOUT)) {
823 err = -EAGAIN; 823 err = -EAGAIN;
824 goto err_unlock; 824 goto err_unlock;
825 } 825 }
826 826
827 if(unlikely(cmd != cuc_resume)) 827 if (unlikely(cmd != cuc_resume))
828 iowrite32(dma_addr, &nic->csr->scb.gen_ptr); 828 iowrite32(dma_addr, &nic->csr->scb.gen_ptr);
829 iowrite8(cmd, &nic->csr->scb.cmd_lo); 829 iowrite8(cmd, &nic->csr->scb.cmd_lo);
830 830
@@ -843,7 +843,7 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
843 843
844 spin_lock_irqsave(&nic->cb_lock, flags); 844 spin_lock_irqsave(&nic->cb_lock, flags);
845 845
846 if(unlikely(!nic->cbs_avail)) { 846 if (unlikely(!nic->cbs_avail)) {
847 err = -ENOMEM; 847 err = -ENOMEM;
848 goto err_unlock; 848 goto err_unlock;
849 } 849 }
@@ -853,7 +853,7 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
853 nic->cbs_avail--; 853 nic->cbs_avail--;
854 cb->skb = skb; 854 cb->skb = skb;
855 855
856 if(unlikely(!nic->cbs_avail)) 856 if (unlikely(!nic->cbs_avail))
857 err = -ENOSPC; 857 err = -ENOSPC;
858 858
859 cb_prepare(nic, cb, skb); 859 cb_prepare(nic, cb, skb);
@@ -864,15 +864,15 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
864 wmb(); 864 wmb();
865 cb->prev->command &= cpu_to_le16(~cb_s); 865 cb->prev->command &= cpu_to_le16(~cb_s);
866 866
867 while(nic->cb_to_send != nic->cb_to_use) { 867 while (nic->cb_to_send != nic->cb_to_use) {
868 if(unlikely(e100_exec_cmd(nic, nic->cuc_cmd, 868 if (unlikely(e100_exec_cmd(nic, nic->cuc_cmd,
869 nic->cb_to_send->dma_addr))) { 869 nic->cb_to_send->dma_addr))) {
870 /* Ok, here's where things get sticky. It's 870 /* Ok, here's where things get sticky. It's
871 * possible that we can't schedule the command 871 * possible that we can't schedule the command
872 * because the controller is too busy, so 872 * because the controller is too busy, so
873 * let's just queue the command and try again 873 * let's just queue the command and try again
874 * when another command is scheduled. */ 874 * when another command is scheduled. */
875 if(err == -ENOSPC) { 875 if (err == -ENOSPC) {
876 //request a reset 876 //request a reset
877 schedule_work(&nic->tx_timeout_task); 877 schedule_work(&nic->tx_timeout_task);
878 } 878 }
@@ -945,7 +945,7 @@ static void e100_get_defaults(struct nic *nic)
945 945
946 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */ 946 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */
947 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision; 947 nic->mac = (nic->flags & ich) ? mac_82559_D101M : nic->pdev->revision;
948 if(nic->mac == mac_unknown) 948 if (nic->mac == mac_unknown)
949 nic->mac = mac_82557_D100_A; 949 nic->mac = mac_82557_D100_A;
950 950
951 nic->params.rfds = rfds; 951 nic->params.rfds = rfds;
@@ -1008,23 +1008,23 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1008 config->adaptive_ifs = nic->adaptive_ifs; 1008 config->adaptive_ifs = nic->adaptive_ifs;
1009 config->loopback = nic->loopback; 1009 config->loopback = nic->loopback;
1010 1010
1011 if(nic->mii.force_media && nic->mii.full_duplex) 1011 if (nic->mii.force_media && nic->mii.full_duplex)
1012 config->full_duplex_force = 0x1; /* 1=force, 0=auto */ 1012 config->full_duplex_force = 0x1; /* 1=force, 0=auto */
1013 1013
1014 if(nic->flags & promiscuous || nic->loopback) { 1014 if (nic->flags & promiscuous || nic->loopback) {
1015 config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */ 1015 config->rx_save_bad_frames = 0x1; /* 1=save, 0=discard */
1016 config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */ 1016 config->rx_discard_short_frames = 0x0; /* 1=discard, 0=save */
1017 config->promiscuous_mode = 0x1; /* 1=on, 0=off */ 1017 config->promiscuous_mode = 0x1; /* 1=on, 0=off */
1018 } 1018 }
1019 1019
1020 if(nic->flags & multicast_all) 1020 if (nic->flags & multicast_all)
1021 config->multicast_all = 0x1; /* 1=accept, 0=no */ 1021 config->multicast_all = 0x1; /* 1=accept, 0=no */
1022 1022
1023 /* disable WoL when up */ 1023 /* disable WoL when up */
1024 if(netif_running(nic->netdev) || !(nic->flags & wol_magic)) 1024 if (netif_running(nic->netdev) || !(nic->flags & wol_magic))
1025 config->magic_packet_disable = 0x1; /* 1=off, 0=on */ 1025 config->magic_packet_disable = 0x1; /* 1=off, 0=on */
1026 1026
1027 if(nic->mac >= mac_82558_D101_A4) { 1027 if (nic->mac >= mac_82558_D101_A4) {
1028 config->fc_disable = 0x1; /* 1=Tx fc off, 0=Tx fc on */ 1028 config->fc_disable = 0x1; /* 1=Tx fc off, 0=Tx fc on */
1029 config->mwi_enable = 0x1; /* 1=enable, 0=disable */ 1029 config->mwi_enable = 0x1; /* 1=enable, 0=disable */
1030 config->standard_tcb = 0x0; /* 1=standard, 0=extended */ 1030 config->standard_tcb = 0x0; /* 1=standard, 0=extended */
@@ -1369,21 +1369,21 @@ static int e100_phy_init(struct nic *nic)
1369 u16 bmcr, stat, id_lo, id_hi, cong; 1369 u16 bmcr, stat, id_lo, id_hi, cong;
1370 1370
1371 /* Discover phy addr by searching addrs in order {1,0,2,..., 31} */ 1371 /* Discover phy addr by searching addrs in order {1,0,2,..., 31} */
1372 for(addr = 0; addr < 32; addr++) { 1372 for (addr = 0; addr < 32; addr++) {
1373 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr; 1373 nic->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr;
1374 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR); 1374 bmcr = mdio_read(netdev, nic->mii.phy_id, MII_BMCR);
1375 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); 1375 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR);
1376 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR); 1376 stat = mdio_read(netdev, nic->mii.phy_id, MII_BMSR);
1377 if(!((bmcr == 0xFFFF) || ((stat == 0) && (bmcr == 0)))) 1377 if (!((bmcr == 0xFFFF) || ((stat == 0) && (bmcr == 0))))
1378 break; 1378 break;
1379 } 1379 }
1380 DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id); 1380 DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id);
1381 if(addr == 32) 1381 if (addr == 32)
1382 return -EAGAIN; 1382 return -EAGAIN;
1383 1383
1384 /* Selected the phy and isolate the rest */ 1384 /* Selected the phy and isolate the rest */
1385 for(addr = 0; addr < 32; addr++) { 1385 for (addr = 0; addr < 32; addr++) {
1386 if(addr != nic->mii.phy_id) { 1386 if (addr != nic->mii.phy_id) {
1387 mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE); 1387 mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE);
1388 } else { 1388 } else {
1389 bmcr = mdio_read(netdev, addr, MII_BMCR); 1389 bmcr = mdio_read(netdev, addr, MII_BMCR);
@@ -1400,7 +1400,7 @@ static int e100_phy_init(struct nic *nic)
1400 1400
1401 /* Handle National tx phys */ 1401 /* Handle National tx phys */
1402#define NCS_PHY_MODEL_MASK 0xFFF0FFFF 1402#define NCS_PHY_MODEL_MASK 0xFFF0FFFF
1403 if((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) { 1403 if ((nic->phy & NCS_PHY_MODEL_MASK) == phy_nsc_tx) {
1404 /* Disable congestion control */ 1404 /* Disable congestion control */
1405 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG); 1405 cong = mdio_read(netdev, nic->mii.phy_id, MII_NSC_CONG);
1406 cong |= NSC_CONG_TXREADY; 1406 cong |= NSC_CONG_TXREADY;
@@ -1408,7 +1408,7 @@ static int e100_phy_init(struct nic *nic)
1408 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong); 1408 mdio_write(netdev, nic->mii.phy_id, MII_NSC_CONG, cong);
1409 } 1409 }
1410 1410
1411 if((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && 1411 if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
1412 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && 1412 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) &&
1413 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) { 1413 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) {
1414 /* enable/disable MDI/MDI-X auto-switching. */ 1414 /* enable/disable MDI/MDI-X auto-switching. */
@@ -1426,25 +1426,25 @@ static int e100_hw_init(struct nic *nic)
1426 e100_hw_reset(nic); 1426 e100_hw_reset(nic);
1427 1427
1428 DPRINTK(HW, ERR, "e100_hw_init\n"); 1428 DPRINTK(HW, ERR, "e100_hw_init\n");
1429 if(!in_interrupt() && (err = e100_self_test(nic))) 1429 if (!in_interrupt() && (err = e100_self_test(nic)))
1430 return err; 1430 return err;
1431 1431
1432 if((err = e100_phy_init(nic))) 1432 if ((err = e100_phy_init(nic)))
1433 return err; 1433 return err;
1434 if((err = e100_exec_cmd(nic, cuc_load_base, 0))) 1434 if ((err = e100_exec_cmd(nic, cuc_load_base, 0)))
1435 return err; 1435 return err;
1436 if((err = e100_exec_cmd(nic, ruc_load_base, 0))) 1436 if ((err = e100_exec_cmd(nic, ruc_load_base, 0)))
1437 return err; 1437 return err;
1438 if ((err = e100_exec_cb_wait(nic, NULL, e100_setup_ucode))) 1438 if ((err = e100_exec_cb_wait(nic, NULL, e100_setup_ucode)))
1439 return err; 1439 return err;
1440 if((err = e100_exec_cb(nic, NULL, e100_configure))) 1440 if ((err = e100_exec_cb(nic, NULL, e100_configure)))
1441 return err; 1441 return err;
1442 if((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr))) 1442 if ((err = e100_exec_cb(nic, NULL, e100_setup_iaaddr)))
1443 return err; 1443 return err;
1444 if((err = e100_exec_cmd(nic, cuc_dump_addr, 1444 if ((err = e100_exec_cmd(nic, cuc_dump_addr,
1445 nic->dma_addr + offsetof(struct mem, stats)))) 1445 nic->dma_addr + offsetof(struct mem, stats))))
1446 return err; 1446 return err;
1447 if((err = e100_exec_cmd(nic, cuc_dump_reset, 0))) 1447 if ((err = e100_exec_cmd(nic, cuc_dump_reset, 0)))
1448 return err; 1448 return err;
1449 1449
1450 e100_disable_irq(nic); 1450 e100_disable_irq(nic);
@@ -1460,7 +1460,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1460 1460
1461 cb->command = cpu_to_le16(cb_multi); 1461 cb->command = cpu_to_le16(cb_multi);
1462 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN); 1462 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN);
1463 for(i = 0; list && i < count; i++, list = list->next) 1463 for (i = 0; list && i < count; i++, list = list->next)
1464 memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr, 1464 memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr,
1465 ETH_ALEN); 1465 ETH_ALEN);
1466} 1466}
@@ -1472,12 +1472,12 @@ static void e100_set_multicast_list(struct net_device *netdev)
1472 DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n", 1472 DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n",
1473 netdev->mc_count, netdev->flags); 1473 netdev->mc_count, netdev->flags);
1474 1474
1475 if(netdev->flags & IFF_PROMISC) 1475 if (netdev->flags & IFF_PROMISC)
1476 nic->flags |= promiscuous; 1476 nic->flags |= promiscuous;
1477 else 1477 else
1478 nic->flags &= ~promiscuous; 1478 nic->flags &= ~promiscuous;
1479 1479
1480 if(netdev->flags & IFF_ALLMULTI || 1480 if (netdev->flags & IFF_ALLMULTI ||
1481 netdev->mc_count > E100_MAX_MULTICAST_ADDRS) 1481 netdev->mc_count > E100_MAX_MULTICAST_ADDRS)
1482 nic->flags |= multicast_all; 1482 nic->flags |= multicast_all;
1483 else 1483 else
@@ -1500,7 +1500,7 @@ static void e100_update_stats(struct nic *nic)
1500 * complete, so we're always waiting for results of the 1500 * complete, so we're always waiting for results of the
1501 * previous command. */ 1501 * previous command. */
1502 1502
1503 if(*complete == cpu_to_le32(cuc_dump_reset_complete)) { 1503 if (*complete == cpu_to_le32(cuc_dump_reset_complete)) {
1504 *complete = 0; 1504 *complete = 0;
1505 nic->tx_frames = le32_to_cpu(s->tx_good_frames); 1505 nic->tx_frames = le32_to_cpu(s->tx_good_frames);
1506 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions); 1506 nic->tx_collisions = le32_to_cpu(s->tx_total_collisions);
@@ -1527,12 +1527,12 @@ static void e100_update_stats(struct nic *nic)
1527 le32_to_cpu(s->tx_single_collisions); 1527 le32_to_cpu(s->tx_single_collisions);
1528 nic->tx_multiple_collisions += 1528 nic->tx_multiple_collisions +=
1529 le32_to_cpu(s->tx_multiple_collisions); 1529 le32_to_cpu(s->tx_multiple_collisions);
1530 if(nic->mac >= mac_82558_D101_A4) { 1530 if (nic->mac >= mac_82558_D101_A4) {
1531 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause); 1531 nic->tx_fc_pause += le32_to_cpu(s->fc_xmt_pause);
1532 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause); 1532 nic->rx_fc_pause += le32_to_cpu(s->fc_rcv_pause);
1533 nic->rx_fc_unsupported += 1533 nic->rx_fc_unsupported +=
1534 le32_to_cpu(s->fc_rcv_unsupported); 1534 le32_to_cpu(s->fc_rcv_unsupported);
1535 if(nic->mac >= mac_82559_D101M) { 1535 if (nic->mac >= mac_82559_D101M) {
1536 nic->tx_tco_frames += 1536 nic->tx_tco_frames +=
1537 le16_to_cpu(s->xmt_tco_frames); 1537 le16_to_cpu(s->xmt_tco_frames);
1538 nic->rx_tco_frames += 1538 nic->rx_tco_frames +=
@@ -1542,7 +1542,7 @@ static void e100_update_stats(struct nic *nic)
1542 } 1542 }
1543 1543
1544 1544
1545 if(e100_exec_cmd(nic, cuc_dump_reset, 0)) 1545 if (e100_exec_cmd(nic, cuc_dump_reset, 0))
1546 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n"); 1546 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n");
1547} 1547}
1548 1548
@@ -1551,19 +1551,19 @@ static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
1551 /* Adjust inter-frame-spacing (IFS) between two transmits if 1551 /* Adjust inter-frame-spacing (IFS) between two transmits if
1552 * we're getting collisions on a half-duplex connection. */ 1552 * we're getting collisions on a half-duplex connection. */
1553 1553
1554 if(duplex == DUPLEX_HALF) { 1554 if (duplex == DUPLEX_HALF) {
1555 u32 prev = nic->adaptive_ifs; 1555 u32 prev = nic->adaptive_ifs;
1556 u32 min_frames = (speed == SPEED_100) ? 1000 : 100; 1556 u32 min_frames = (speed == SPEED_100) ? 1000 : 100;
1557 1557
1558 if((nic->tx_frames / 32 < nic->tx_collisions) && 1558 if ((nic->tx_frames / 32 < nic->tx_collisions) &&
1559 (nic->tx_frames > min_frames)) { 1559 (nic->tx_frames > min_frames)) {
1560 if(nic->adaptive_ifs < 60) 1560 if (nic->adaptive_ifs < 60)
1561 nic->adaptive_ifs += 5; 1561 nic->adaptive_ifs += 5;
1562 } else if (nic->tx_frames < min_frames) { 1562 } else if (nic->tx_frames < min_frames) {
1563 if(nic->adaptive_ifs >= 5) 1563 if (nic->adaptive_ifs >= 5)
1564 nic->adaptive_ifs -= 5; 1564 nic->adaptive_ifs -= 5;
1565 } 1565 }
1566 if(nic->adaptive_ifs != prev) 1566 if (nic->adaptive_ifs != prev)
1567 e100_exec_cb(nic, NULL, e100_configure); 1567 e100_exec_cb(nic, NULL, e100_configure);
1568 } 1568 }
1569} 1569}
@@ -1579,12 +1579,12 @@ static void e100_watchdog(unsigned long data)
1579 1579
1580 mii_ethtool_gset(&nic->mii, &cmd); 1580 mii_ethtool_gset(&nic->mii, &cmd);
1581 1581
1582 if(mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { 1582 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) {
1583 printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n", 1583 printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n",
1584 nic->netdev->name, 1584 nic->netdev->name,
1585 cmd.speed == SPEED_100 ? "100" : "10", 1585 cmd.speed == SPEED_100 ? "100" : "10",
1586 cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); 1586 cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
1587 } else if(!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { 1587 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
1588 printk(KERN_INFO "e100: %s NIC Link is Down\n", 1588 printk(KERN_INFO "e100: %s NIC Link is Down\n",
1589 nic->netdev->name); 1589 nic->netdev->name);
1590 } 1590 }
@@ -1604,11 +1604,11 @@ static void e100_watchdog(unsigned long data)
1604 e100_update_stats(nic); 1604 e100_update_stats(nic);
1605 e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex); 1605 e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex);
1606 1606
1607 if(nic->mac <= mac_82557_D100_C) 1607 if (nic->mac <= mac_82557_D100_C)
1608 /* Issue a multicast command to workaround a 557 lock up */ 1608 /* Issue a multicast command to workaround a 557 lock up */
1609 e100_set_multicast_list(nic->netdev); 1609 e100_set_multicast_list(nic->netdev);
1610 1610
1611 if(nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF) 1611 if (nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF)
1612 /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */ 1612 /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */
1613 nic->flags |= ich_10h_workaround; 1613 nic->flags |= ich_10h_workaround;
1614 else 1614 else
@@ -1623,7 +1623,7 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
1623{ 1623{
1624 cb->command = nic->tx_command; 1624 cb->command = nic->tx_command;
1625 /* interrupt every 16 packets regardless of delay */ 1625 /* interrupt every 16 packets regardless of delay */
1626 if((nic->cbs_avail & ~15) == nic->cbs_avail) 1626 if ((nic->cbs_avail & ~15) == nic->cbs_avail)
1627 cb->command |= cpu_to_le16(cb_i); 1627 cb->command |= cpu_to_le16(cb_i);
1628 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd); 1628 cb->u.tcb.tbd_array = cb->dma_addr + offsetof(struct cb, u.tcb.tbd);
1629 cb->u.tcb.tcb_byte_count = 0; 1629 cb->u.tcb.tcb_byte_count = 0;
@@ -1640,18 +1640,18 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1640 struct nic *nic = netdev_priv(netdev); 1640 struct nic *nic = netdev_priv(netdev);
1641 int err; 1641 int err;
1642 1642
1643 if(nic->flags & ich_10h_workaround) { 1643 if (nic->flags & ich_10h_workaround) {
1644 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang. 1644 /* SW workaround for ICH[x] 10Mbps/half duplex Tx hang.
1645 Issue a NOP command followed by a 1us delay before 1645 Issue a NOP command followed by a 1us delay before
1646 issuing the Tx command. */ 1646 issuing the Tx command. */
1647 if(e100_exec_cmd(nic, cuc_nop, 0)) 1647 if (e100_exec_cmd(nic, cuc_nop, 0))
1648 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n"); 1648 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n");
1649 udelay(1); 1649 udelay(1);
1650 } 1650 }
1651 1651
1652 err = e100_exec_cb(nic, skb, e100_xmit_prepare); 1652 err = e100_exec_cb(nic, skb, e100_xmit_prepare);
1653 1653
1654 switch(err) { 1654 switch (err) {
1655 case -ENOSPC: 1655 case -ENOSPC:
1656 /* We queued the skb, but now we're out of space. */ 1656 /* We queued the skb, but now we're out of space. */
1657 DPRINTK(TX_ERR, DEBUG, "No space for CB\n"); 1657 DPRINTK(TX_ERR, DEBUG, "No space for CB\n");
@@ -1677,14 +1677,14 @@ static int e100_tx_clean(struct nic *nic)
1677 spin_lock(&nic->cb_lock); 1677 spin_lock(&nic->cb_lock);
1678 1678
1679 /* Clean CBs marked complete */ 1679 /* Clean CBs marked complete */
1680 for(cb = nic->cb_to_clean; 1680 for (cb = nic->cb_to_clean;
1681 cb->status & cpu_to_le16(cb_complete); 1681 cb->status & cpu_to_le16(cb_complete);
1682 cb = nic->cb_to_clean = cb->next) { 1682 cb = nic->cb_to_clean = cb->next) {
1683 DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n", 1683 DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n",
1684 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), 1684 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
1685 cb->status); 1685 cb->status);
1686 1686
1687 if(likely(cb->skb != NULL)) { 1687 if (likely(cb->skb != NULL)) {
1688 dev->stats.tx_packets++; 1688 dev->stats.tx_packets++;
1689 dev->stats.tx_bytes += cb->skb->len; 1689 dev->stats.tx_bytes += cb->skb->len;
1690 1690
@@ -1703,7 +1703,7 @@ static int e100_tx_clean(struct nic *nic)
1703 spin_unlock(&nic->cb_lock); 1703 spin_unlock(&nic->cb_lock);
1704 1704
1705 /* Recover from running out of Tx resources in xmit_frame */ 1705 /* Recover from running out of Tx resources in xmit_frame */
1706 if(unlikely(tx_cleaned && netif_queue_stopped(nic->netdev))) 1706 if (unlikely(tx_cleaned && netif_queue_stopped(nic->netdev)))
1707 netif_wake_queue(nic->netdev); 1707 netif_wake_queue(nic->netdev);
1708 1708
1709 return tx_cleaned; 1709 return tx_cleaned;
@@ -1711,10 +1711,10 @@ static int e100_tx_clean(struct nic *nic)
1711 1711
1712static void e100_clean_cbs(struct nic *nic) 1712static void e100_clean_cbs(struct nic *nic)
1713{ 1713{
1714 if(nic->cbs) { 1714 if (nic->cbs) {
1715 while(nic->cbs_avail != nic->params.cbs.count) { 1715 while (nic->cbs_avail != nic->params.cbs.count) {
1716 struct cb *cb = nic->cb_to_clean; 1716 struct cb *cb = nic->cb_to_clean;
1717 if(cb->skb) { 1717 if (cb->skb) {
1718 pci_unmap_single(nic->pdev, 1718 pci_unmap_single(nic->pdev,
1719 le32_to_cpu(cb->u.tcb.tbd.buf_addr), 1719 le32_to_cpu(cb->u.tcb.tbd.buf_addr),
1720 le16_to_cpu(cb->u.tcb.tbd.size), 1720 le16_to_cpu(cb->u.tcb.tbd.size),
@@ -1746,10 +1746,10 @@ static int e100_alloc_cbs(struct nic *nic)
1746 1746
1747 nic->cbs = pci_alloc_consistent(nic->pdev, 1747 nic->cbs = pci_alloc_consistent(nic->pdev,
1748 sizeof(struct cb) * count, &nic->cbs_dma_addr); 1748 sizeof(struct cb) * count, &nic->cbs_dma_addr);
1749 if(!nic->cbs) 1749 if (!nic->cbs)
1750 return -ENOMEM; 1750 return -ENOMEM;
1751 1751
1752 for(cb = nic->cbs, i = 0; i < count; cb++, i++) { 1752 for (cb = nic->cbs, i = 0; i < count; cb++, i++) {
1753 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; 1753 cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
1754 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1; 1754 cb->prev = (i == 0) ? nic->cbs + count - 1 : cb - 1;
1755 1755
@@ -1767,14 +1767,14 @@ static int e100_alloc_cbs(struct nic *nic)
1767 1767
1768static inline void e100_start_receiver(struct nic *nic, struct rx *rx) 1768static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
1769{ 1769{
1770 if(!nic->rxs) return; 1770 if (!nic->rxs) return;
1771 if(RU_SUSPENDED != nic->ru_running) return; 1771 if (RU_SUSPENDED != nic->ru_running) return;
1772 1772
1773 /* handle init time starts */ 1773 /* handle init time starts */
1774 if(!rx) rx = nic->rxs; 1774 if (!rx) rx = nic->rxs;
1775 1775
1776 /* (Re)start RU if suspended or idle and RFA is non-NULL */ 1776 /* (Re)start RU if suspended or idle and RFA is non-NULL */
1777 if(rx->skb) { 1777 if (rx->skb) {
1778 e100_exec_cmd(nic, ruc_start, rx->dma_addr); 1778 e100_exec_cmd(nic, ruc_start, rx->dma_addr);
1779 nic->ru_running = RU_RUNNING; 1779 nic->ru_running = RU_RUNNING;
1780 } 1780 }
@@ -1783,7 +1783,7 @@ static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
1783#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN) 1783#define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN)
1784static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) 1784static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
1785{ 1785{
1786 if(!(rx->skb = netdev_alloc_skb(nic->netdev, RFD_BUF_LEN + NET_IP_ALIGN))) 1786 if (!(rx->skb = netdev_alloc_skb(nic->netdev, RFD_BUF_LEN + NET_IP_ALIGN)))
1787 return -ENOMEM; 1787 return -ENOMEM;
1788 1788
1789 /* Align, init, and map the RFD. */ 1789 /* Align, init, and map the RFD. */
@@ -1820,7 +1820,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1820 struct rfd *rfd = (struct rfd *)skb->data; 1820 struct rfd *rfd = (struct rfd *)skb->data;
1821 u16 rfd_status, actual_size; 1821 u16 rfd_status, actual_size;
1822 1822
1823 if(unlikely(work_done && *work_done >= work_to_do)) 1823 if (unlikely(work_done && *work_done >= work_to_do))
1824 return -EAGAIN; 1824 return -EAGAIN;
1825 1825
1826 /* Need to sync before taking a peek at cb_complete bit */ 1826 /* Need to sync before taking a peek at cb_complete bit */
@@ -1847,7 +1847,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1847 1847
1848 /* Get actual data size */ 1848 /* Get actual data size */
1849 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF; 1849 actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
1850 if(unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd))) 1850 if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
1851 actual_size = RFD_BUF_LEN - sizeof(struct rfd); 1851 actual_size = RFD_BUF_LEN - sizeof(struct rfd);
1852 1852
1853 /* Get data */ 1853 /* Get data */
@@ -1872,10 +1872,10 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1872 skb_put(skb, actual_size); 1872 skb_put(skb, actual_size);
1873 skb->protocol = eth_type_trans(skb, nic->netdev); 1873 skb->protocol = eth_type_trans(skb, nic->netdev);
1874 1874
1875 if(unlikely(!(rfd_status & cb_ok))) { 1875 if (unlikely(!(rfd_status & cb_ok))) {
1876 /* Don't indicate if hardware indicates errors */ 1876 /* Don't indicate if hardware indicates errors */
1877 dev_kfree_skb_any(skb); 1877 dev_kfree_skb_any(skb);
1878 } else if(actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) { 1878 } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) {
1879 /* Don't indicate oversized frames */ 1879 /* Don't indicate oversized frames */
1880 nic->rx_over_length_errors++; 1880 nic->rx_over_length_errors++;
1881 dev_kfree_skb_any(skb); 1881 dev_kfree_skb_any(skb);
@@ -1883,7 +1883,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1883 dev->stats.rx_packets++; 1883 dev->stats.rx_packets++;
1884 dev->stats.rx_bytes += actual_size; 1884 dev->stats.rx_bytes += actual_size;
1885 netif_receive_skb(skb); 1885 netif_receive_skb(skb);
1886 if(work_done) 1886 if (work_done)
1887 (*work_done)++; 1887 (*work_done)++;
1888 } 1888 }
1889 1889
@@ -1901,7 +1901,7 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1901 struct rfd *old_before_last_rfd, *new_before_last_rfd; 1901 struct rfd *old_before_last_rfd, *new_before_last_rfd;
1902 1902
1903 /* Indicate newly arrived packets */ 1903 /* Indicate newly arrived packets */
1904 for(rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) { 1904 for (rx = nic->rx_to_clean; rx->skb; rx = nic->rx_to_clean = rx->next) {
1905 err = e100_rx_indicate(nic, rx, work_done, work_to_do); 1905 err = e100_rx_indicate(nic, rx, work_done, work_to_do);
1906 /* Hit quota or no more to clean */ 1906 /* Hit quota or no more to clean */
1907 if (-EAGAIN == err || -ENODATA == err) 1907 if (-EAGAIN == err || -ENODATA == err)
@@ -1922,8 +1922,8 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1922 old_before_last_rfd = (struct rfd *)old_before_last_rx->skb->data; 1922 old_before_last_rfd = (struct rfd *)old_before_last_rx->skb->data;
1923 1923
1924 /* Alloc new skbs to refill list */ 1924 /* Alloc new skbs to refill list */
1925 for(rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) { 1925 for (rx = nic->rx_to_use; !rx->skb; rx = nic->rx_to_use = rx->next) {
1926 if(unlikely(e100_rx_alloc_skb(nic, rx))) 1926 if (unlikely(e100_rx_alloc_skb(nic, rx)))
1927 break; /* Better luck next time (see watchdog) */ 1927 break; /* Better luck next time (see watchdog) */
1928 } 1928 }
1929 1929
@@ -1959,11 +1959,11 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
1959 PCI_DMA_BIDIRECTIONAL); 1959 PCI_DMA_BIDIRECTIONAL);
1960 } 1960 }
1961 1961
1962 if(restart_required) { 1962 if (restart_required) {
1963 // ack the rnr? 1963 // ack the rnr?
1964 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack); 1964 iowrite8(stat_ack_rnr, &nic->csr->scb.stat_ack);
1965 e100_start_receiver(nic, nic->rx_to_clean); 1965 e100_start_receiver(nic, nic->rx_to_clean);
1966 if(work_done) 1966 if (work_done)
1967 (*work_done)++; 1967 (*work_done)++;
1968 } 1968 }
1969} 1969}
@@ -1975,9 +1975,9 @@ static void e100_rx_clean_list(struct nic *nic)
1975 1975
1976 nic->ru_running = RU_UNINITIALIZED; 1976 nic->ru_running = RU_UNINITIALIZED;
1977 1977
1978 if(nic->rxs) { 1978 if (nic->rxs) {
1979 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 1979 for (rx = nic->rxs, i = 0; i < count; rx++, i++) {
1980 if(rx->skb) { 1980 if (rx->skb) {
1981 pci_unmap_single(nic->pdev, rx->dma_addr, 1981 pci_unmap_single(nic->pdev, rx->dma_addr,
1982 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 1982 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
1983 dev_kfree_skb(rx->skb); 1983 dev_kfree_skb(rx->skb);
@@ -1999,13 +1999,13 @@ static int e100_rx_alloc_list(struct nic *nic)
1999 nic->rx_to_use = nic->rx_to_clean = NULL; 1999 nic->rx_to_use = nic->rx_to_clean = NULL;
2000 nic->ru_running = RU_UNINITIALIZED; 2000 nic->ru_running = RU_UNINITIALIZED;
2001 2001
2002 if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC))) 2002 if (!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC)))
2003 return -ENOMEM; 2003 return -ENOMEM;
2004 2004
2005 for(rx = nic->rxs, i = 0; i < count; rx++, i++) { 2005 for (rx = nic->rxs, i = 0; i < count; rx++, i++) {
2006 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; 2006 rx->next = (i + 1 < count) ? rx + 1 : nic->rxs;
2007 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1; 2007 rx->prev = (i == 0) ? nic->rxs + count - 1 : rx - 1;
2008 if(e100_rx_alloc_skb(nic, rx)) { 2008 if (e100_rx_alloc_skb(nic, rx)) {
2009 e100_rx_clean_list(nic); 2009 e100_rx_clean_list(nic);
2010 return -ENOMEM; 2010 return -ENOMEM;
2011 } 2011 }
@@ -2038,7 +2038,7 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
2038 2038
2039 DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack); 2039 DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack);
2040 2040
2041 if(stat_ack == stat_ack_not_ours || /* Not our interrupt */ 2041 if (stat_ack == stat_ack_not_ours || /* Not our interrupt */
2042 stat_ack == stat_ack_not_present) /* Hardware is ejected */ 2042 stat_ack == stat_ack_not_present) /* Hardware is ejected */
2043 return IRQ_NONE; 2043 return IRQ_NONE;
2044 2044
@@ -2046,10 +2046,10 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
2046 iowrite8(stat_ack, &nic->csr->scb.stat_ack); 2046 iowrite8(stat_ack, &nic->csr->scb.stat_ack);
2047 2047
2048 /* We hit Receive No Resource (RNR); restart RU after cleaning */ 2048 /* We hit Receive No Resource (RNR); restart RU after cleaning */
2049 if(stat_ack & stat_ack_rnr) 2049 if (stat_ack & stat_ack_rnr)
2050 nic->ru_running = RU_SUSPENDED; 2050 nic->ru_running = RU_SUSPENDED;
2051 2051
2052 if(likely(netif_rx_schedule_prep(&nic->napi))) { 2052 if (likely(netif_rx_schedule_prep(&nic->napi))) {
2053 e100_disable_irq(nic); 2053 e100_disable_irq(nic);
2054 __netif_rx_schedule(&nic->napi); 2054 __netif_rx_schedule(&nic->napi);
2055 } 2055 }
@@ -2102,7 +2102,7 @@ static int e100_set_mac_address(struct net_device *netdev, void *p)
2102 2102
2103static int e100_change_mtu(struct net_device *netdev, int new_mtu) 2103static int e100_change_mtu(struct net_device *netdev, int new_mtu)
2104{ 2104{
2105 if(new_mtu < ETH_ZLEN || new_mtu > ETH_DATA_LEN) 2105 if (new_mtu < ETH_ZLEN || new_mtu > ETH_DATA_LEN)
2106 return -EINVAL; 2106 return -EINVAL;
2107 netdev->mtu = new_mtu; 2107 netdev->mtu = new_mtu;
2108 return 0; 2108 return 0;
@@ -2121,16 +2121,16 @@ static int e100_up(struct nic *nic)
2121{ 2121{
2122 int err; 2122 int err;
2123 2123
2124 if((err = e100_rx_alloc_list(nic))) 2124 if ((err = e100_rx_alloc_list(nic)))
2125 return err; 2125 return err;
2126 if((err = e100_alloc_cbs(nic))) 2126 if ((err = e100_alloc_cbs(nic)))
2127 goto err_rx_clean_list; 2127 goto err_rx_clean_list;
2128 if((err = e100_hw_init(nic))) 2128 if ((err = e100_hw_init(nic)))
2129 goto err_clean_cbs; 2129 goto err_clean_cbs;
2130 e100_set_multicast_list(nic->netdev); 2130 e100_set_multicast_list(nic->netdev);
2131 e100_start_receiver(nic, NULL); 2131 e100_start_receiver(nic, NULL);
2132 mod_timer(&nic->watchdog, jiffies); 2132 mod_timer(&nic->watchdog, jiffies);
2133 if((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED, 2133 if ((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED,
2134 nic->netdev->name, nic->netdev))) 2134 nic->netdev->name, nic->netdev)))
2135 goto err_no_irq; 2135 goto err_no_irq;
2136 netif_wake_queue(nic->netdev); 2136 netif_wake_queue(nic->netdev);
@@ -2192,26 +2192,26 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
2192 * in loopback mode, and the test passes if the received 2192 * in loopback mode, and the test passes if the received
2193 * packet compares byte-for-byte to the transmitted packet. */ 2193 * packet compares byte-for-byte to the transmitted packet. */
2194 2194
2195 if((err = e100_rx_alloc_list(nic))) 2195 if ((err = e100_rx_alloc_list(nic)))
2196 return err; 2196 return err;
2197 if((err = e100_alloc_cbs(nic))) 2197 if ((err = e100_alloc_cbs(nic)))
2198 goto err_clean_rx; 2198 goto err_clean_rx;
2199 2199
2200 /* ICH PHY loopback is broken so do MAC loopback instead */ 2200 /* ICH PHY loopback is broken so do MAC loopback instead */
2201 if(nic->flags & ich && loopback_mode == lb_phy) 2201 if (nic->flags & ich && loopback_mode == lb_phy)
2202 loopback_mode = lb_mac; 2202 loopback_mode = lb_mac;
2203 2203
2204 nic->loopback = loopback_mode; 2204 nic->loopback = loopback_mode;
2205 if((err = e100_hw_init(nic))) 2205 if ((err = e100_hw_init(nic)))
2206 goto err_loopback_none; 2206 goto err_loopback_none;
2207 2207
2208 if(loopback_mode == lb_phy) 2208 if (loopback_mode == lb_phy)
2209 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR, 2209 mdio_write(nic->netdev, nic->mii.phy_id, MII_BMCR,
2210 BMCR_LOOPBACK); 2210 BMCR_LOOPBACK);
2211 2211
2212 e100_start_receiver(nic, NULL); 2212 e100_start_receiver(nic, NULL);
2213 2213
2214 if(!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) { 2214 if (!(skb = netdev_alloc_skb(nic->netdev, ETH_DATA_LEN))) {
2215 err = -ENOMEM; 2215 err = -ENOMEM;
2216 goto err_loopback_none; 2216 goto err_loopback_none;
2217 } 2217 }
@@ -2224,7 +2224,7 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr, 2224 pci_dma_sync_single_for_cpu(nic->pdev, nic->rx_to_clean->dma_addr,
2225 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL); 2225 RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
2226 2226
2227 if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), 2227 if (memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd),
2228 skb->data, ETH_DATA_LEN)) 2228 skb->data, ETH_DATA_LEN))
2229 err = -EAGAIN; 2229 err = -EAGAIN;
2230 2230
@@ -2301,7 +2301,7 @@ static void e100_get_regs(struct net_device *netdev,
2301 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 | 2301 buff[0] = ioread8(&nic->csr->scb.cmd_hi) << 24 |
2302 ioread8(&nic->csr->scb.cmd_lo) << 16 | 2302 ioread8(&nic->csr->scb.cmd_lo) << 16 |
2303 ioread16(&nic->csr->scb.status); 2303 ioread16(&nic->csr->scb.status);
2304 for(i = E100_PHY_REGS; i >= 0; i--) 2304 for (i = E100_PHY_REGS; i >= 0; i--)
2305 buff[1 + E100_PHY_REGS - i] = 2305 buff[1 + E100_PHY_REGS - i] =
2306 mdio_read(netdev, nic->mii.phy_id, i); 2306 mdio_read(netdev, nic->mii.phy_id, i);
2307 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); 2307 memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf));
@@ -2326,7 +2326,7 @@ static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
2326 !device_can_wakeup(&nic->pdev->dev)) 2326 !device_can_wakeup(&nic->pdev->dev))
2327 return -EOPNOTSUPP; 2327 return -EOPNOTSUPP;
2328 2328
2329 if(wol->wolopts) 2329 if (wol->wolopts)
2330 nic->flags |= wol_magic; 2330 nic->flags |= wol_magic;
2331 else 2331 else
2332 nic->flags &= ~wol_magic; 2332 nic->flags &= ~wol_magic;
@@ -2385,7 +2385,7 @@ static int e100_set_eeprom(struct net_device *netdev,
2385{ 2385{
2386 struct nic *nic = netdev_priv(netdev); 2386 struct nic *nic = netdev_priv(netdev);
2387 2387
2388 if(eeprom->magic != E100_EEPROM_MAGIC) 2388 if (eeprom->magic != E100_EEPROM_MAGIC)
2389 return -EINVAL; 2389 return -EINVAL;
2390 2390
2391 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len); 2391 memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
@@ -2421,7 +2421,7 @@ static int e100_set_ringparam(struct net_device *netdev,
2421 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 2421 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
2422 return -EINVAL; 2422 return -EINVAL;
2423 2423
2424 if(netif_running(netdev)) 2424 if (netif_running(netdev))
2425 e100_down(nic); 2425 e100_down(nic);
2426 rfds->count = max(ring->rx_pending, rfds->min); 2426 rfds->count = max(ring->rx_pending, rfds->min);
2427 rfds->count = min(rfds->count, rfds->max); 2427 rfds->count = min(rfds->count, rfds->max);
@@ -2429,7 +2429,7 @@ static int e100_set_ringparam(struct net_device *netdev,
2429 cbs->count = min(cbs->count, cbs->max); 2429 cbs->count = min(cbs->count, cbs->max);
2430 DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n", 2430 DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n",
2431 rfds->count, cbs->count); 2431 rfds->count, cbs->count);
2432 if(netif_running(netdev)) 2432 if (netif_running(netdev))
2433 e100_up(nic); 2433 e100_up(nic);
2434 2434
2435 return 0; 2435 return 0;
@@ -2454,12 +2454,12 @@ static void e100_diag_test(struct net_device *netdev,
2454 memset(data, 0, E100_TEST_LEN * sizeof(u64)); 2454 memset(data, 0, E100_TEST_LEN * sizeof(u64));
2455 data[0] = !mii_link_ok(&nic->mii); 2455 data[0] = !mii_link_ok(&nic->mii);
2456 data[1] = e100_eeprom_load(nic); 2456 data[1] = e100_eeprom_load(nic);
2457 if(test->flags & ETH_TEST_FL_OFFLINE) { 2457 if (test->flags & ETH_TEST_FL_OFFLINE) {
2458 2458
2459 /* save speed, duplex & autoneg settings */ 2459 /* save speed, duplex & autoneg settings */
2460 err = mii_ethtool_gset(&nic->mii, &cmd); 2460 err = mii_ethtool_gset(&nic->mii, &cmd);
2461 2461
2462 if(netif_running(netdev)) 2462 if (netif_running(netdev))
2463 e100_down(nic); 2463 e100_down(nic);
2464 data[2] = e100_self_test(nic); 2464 data[2] = e100_self_test(nic);
2465 data[3] = e100_loopback_test(nic, lb_mac); 2465 data[3] = e100_loopback_test(nic, lb_mac);
@@ -2468,10 +2468,10 @@ static void e100_diag_test(struct net_device *netdev,
2468 /* restore speed, duplex & autoneg settings */ 2468 /* restore speed, duplex & autoneg settings */
2469 err = mii_ethtool_sset(&nic->mii, &cmd); 2469 err = mii_ethtool_sset(&nic->mii, &cmd);
2470 2470
2471 if(netif_running(netdev)) 2471 if (netif_running(netdev))
2472 e100_up(nic); 2472 e100_up(nic);
2473 } 2473 }
2474 for(i = 0; i < E100_TEST_LEN; i++) 2474 for (i = 0; i < E100_TEST_LEN; i++)
2475 test->flags |= data[i] ? ETH_TEST_FL_FAILED : 0; 2475 test->flags |= data[i] ? ETH_TEST_FL_FAILED : 0;
2476 2476
2477 msleep_interruptible(4 * 1000); 2477 msleep_interruptible(4 * 1000);
@@ -2481,7 +2481,7 @@ static int e100_phys_id(struct net_device *netdev, u32 data)
2481{ 2481{
2482 struct nic *nic = netdev_priv(netdev); 2482 struct nic *nic = netdev_priv(netdev);
2483 2483
2484 if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) 2484 if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
2485 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); 2485 data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
2486 mod_timer(&nic->blink_timer, jiffies); 2486 mod_timer(&nic->blink_timer, jiffies);
2487 msleep_interruptible(data * 1000); 2487 msleep_interruptible(data * 1000);
@@ -2524,7 +2524,7 @@ static void e100_get_ethtool_stats(struct net_device *netdev,
2524 struct nic *nic = netdev_priv(netdev); 2524 struct nic *nic = netdev_priv(netdev);
2525 int i; 2525 int i;
2526 2526
2527 for(i = 0; i < E100_NET_STATS_LEN; i++) 2527 for (i = 0; i < E100_NET_STATS_LEN; i++)
2528 data[i] = ((unsigned long *)&netdev->stats)[i]; 2528 data[i] = ((unsigned long *)&netdev->stats)[i];
2529 2529
2530 data[i++] = nic->tx_deferred; 2530 data[i++] = nic->tx_deferred;
@@ -2539,7 +2539,7 @@ static void e100_get_ethtool_stats(struct net_device *netdev,
2539 2539
2540static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data) 2540static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
2541{ 2541{
2542 switch(stringset) { 2542 switch (stringset) {
2543 case ETH_SS_TEST: 2543 case ETH_SS_TEST:
2544 memcpy(data, *e100_gstrings_test, sizeof(e100_gstrings_test)); 2544 memcpy(data, *e100_gstrings_test, sizeof(e100_gstrings_test));
2545 break; 2545 break;
@@ -2589,7 +2589,7 @@ static int e100_alloc(struct nic *nic)
2589 2589
2590static void e100_free(struct nic *nic) 2590static void e100_free(struct nic *nic)
2591{ 2591{
2592 if(nic->mem) { 2592 if (nic->mem) {
2593 pci_free_consistent(nic->pdev, sizeof(struct mem), 2593 pci_free_consistent(nic->pdev, sizeof(struct mem),
2594 nic->mem, nic->dma_addr); 2594 nic->mem, nic->dma_addr);
2595 nic->mem = NULL; 2595 nic->mem = NULL;
@@ -2602,7 +2602,7 @@ static int e100_open(struct net_device *netdev)
2602 int err = 0; 2602 int err = 0;
2603 2603
2604 netif_carrier_off(netdev); 2604 netif_carrier_off(netdev);
2605 if((err = e100_up(nic))) 2605 if ((err = e100_up(nic)))
2606 DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n"); 2606 DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n");
2607 return err; 2607 return err;
2608} 2608}
@@ -2635,8 +2635,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2635 struct nic *nic; 2635 struct nic *nic;
2636 int err; 2636 int err;
2637 2637
2638 if(!(netdev = alloc_etherdev(sizeof(struct nic)))) { 2638 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) {
2639 if(((1 << debug) - 1) & NETIF_MSG_PROBE) 2639 if (((1 << debug) - 1) & NETIF_MSG_PROBE)
2640 printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n"); 2640 printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n");
2641 return -ENOMEM; 2641 return -ENOMEM;
2642 } 2642 }
@@ -2653,24 +2653,24 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2653 nic->msg_enable = (1 << debug) - 1; 2653 nic->msg_enable = (1 << debug) - 1;
2654 pci_set_drvdata(pdev, netdev); 2654 pci_set_drvdata(pdev, netdev);
2655 2655
2656 if((err = pci_enable_device(pdev))) { 2656 if ((err = pci_enable_device(pdev))) {
2657 DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n"); 2657 DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n");
2658 goto err_out_free_dev; 2658 goto err_out_free_dev;
2659 } 2659 }
2660 2660
2661 if(!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 2661 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
2662 DPRINTK(PROBE, ERR, "Cannot find proper PCI device " 2662 DPRINTK(PROBE, ERR, "Cannot find proper PCI device "
2663 "base address, aborting.\n"); 2663 "base address, aborting.\n");
2664 err = -ENODEV; 2664 err = -ENODEV;
2665 goto err_out_disable_pdev; 2665 goto err_out_disable_pdev;
2666 } 2666 }
2667 2667
2668 if((err = pci_request_regions(pdev, DRV_NAME))) { 2668 if ((err = pci_request_regions(pdev, DRV_NAME))) {
2669 DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n"); 2669 DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n");
2670 goto err_out_disable_pdev; 2670 goto err_out_disable_pdev;
2671 } 2671 }
2672 2672
2673 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) { 2673 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
2674 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n"); 2674 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n");
2675 goto err_out_free_res; 2675 goto err_out_free_res;
2676 } 2676 }
@@ -2681,13 +2681,13 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2681 DPRINTK(PROBE, INFO, "using i/o access mode\n"); 2681 DPRINTK(PROBE, INFO, "using i/o access mode\n");
2682 2682
2683 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr)); 2683 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr));
2684 if(!nic->csr) { 2684 if (!nic->csr) {
2685 DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n"); 2685 DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n");
2686 err = -ENOMEM; 2686 err = -ENOMEM;
2687 goto err_out_free_res; 2687 goto err_out_free_res;
2688 } 2688 }
2689 2689
2690 if(ent->driver_data) 2690 if (ent->driver_data)
2691 nic->flags |= ich; 2691 nic->flags |= ich;
2692 else 2692 else
2693 nic->flags &= ~ich; 2693 nic->flags &= ~ich;
@@ -2715,12 +2715,12 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2715 2715
2716 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); 2716 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2717 2717
2718 if((err = e100_alloc(nic))) { 2718 if ((err = e100_alloc(nic))) {
2719 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2719 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
2720 goto err_out_iounmap; 2720 goto err_out_iounmap;
2721 } 2721 }
2722 2722
2723 if((err = e100_eeprom_load(nic))) 2723 if ((err = e100_eeprom_load(nic)))
2724 goto err_out_free; 2724 goto err_out_free;
2725 2725
2726 e100_phy_init(nic); 2726 e100_phy_init(nic);
@@ -2740,7 +2740,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2740 } 2740 }
2741 2741
2742 /* Wol magic packet can be enabled from eeprom */ 2742 /* Wol magic packet can be enabled from eeprom */
2743 if((nic->mac >= mac_82558_D101_A4) && 2743 if ((nic->mac >= mac_82558_D101_A4) &&
2744 (nic->eeprom[eeprom_id] & eeprom_id_wol)) { 2744 (nic->eeprom[eeprom_id] & eeprom_id_wol)) {
2745 nic->flags |= wol_magic; 2745 nic->flags |= wol_magic;
2746 device_set_wakeup_enable(&pdev->dev, true); 2746 device_set_wakeup_enable(&pdev->dev, true);
@@ -2750,7 +2750,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2750 pci_pme_active(pdev, false); 2750 pci_pme_active(pdev, false);
2751 2751
2752 strcpy(netdev->name, "eth%d"); 2752 strcpy(netdev->name, "eth%d");
2753 if((err = register_netdev(netdev))) { 2753 if ((err = register_netdev(netdev))) {
2754 DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n"); 2754 DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
2755 goto err_out_free; 2755 goto err_out_free;
2756 } 2756 }
@@ -2779,7 +2779,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
2779{ 2779{
2780 struct net_device *netdev = pci_get_drvdata(pdev); 2780 struct net_device *netdev = pci_get_drvdata(pdev);
2781 2781
2782 if(netdev) { 2782 if (netdev) {
2783 struct nic *nic = netdev_priv(netdev); 2783 struct nic *nic = netdev_priv(netdev);
2784 unregister_netdev(netdev); 2784 unregister_netdev(netdev);
2785 e100_free(nic); 2785 e100_free(nic);
@@ -2932,7 +2932,7 @@ static struct pci_driver e100_driver = {
2932 2932
2933static int __init e100_init_module(void) 2933static int __init e100_init_module(void)
2934{ 2934{
2935 if(((1 << debug) - 1) & NETIF_MSG_DRV) { 2935 if (((1 << debug) - 1) & NETIF_MSG_DRV) {
2936 printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 2936 printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
2937 printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT); 2937 printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT);
2938 } 2938 }
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 9930d5f8b9e1..6271b9411ccf 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -478,7 +478,7 @@ struct ehea_port {
478 int num_add_tx_qps; 478 int num_add_tx_qps;
479 int num_mcs; 479 int num_mcs;
480 int resets; 480 int resets;
481 u64 flags; 481 unsigned long flags;
482 u64 mac_addr; 482 u64 mac_addr;
483 u32 logical_port_id; 483 u32 logical_port_id;
484 u32 port_speed; 484 u32 port_speed;
@@ -510,7 +510,6 @@ void ehea_set_ethtool_ops(struct net_device *netdev);
510int ehea_sense_port_attr(struct ehea_port *port); 510int ehea_sense_port_attr(struct ehea_port *port);
511int ehea_set_portspeed(struct ehea_port *port, u32 port_speed); 511int ehea_set_portspeed(struct ehea_port *port, u32 port_speed);
512 512
513extern u64 ehea_driver_flags;
514extern struct work_struct ehea_rereg_mr_task; 513extern struct work_struct ehea_rereg_mr_task;
515 514
516#endif /* __EHEA_H__ */ 515#endif /* __EHEA_H__ */
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index a2f1905a23df..e3131ea629cd 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -99,7 +99,7 @@ MODULE_PARM_DESC(use_lro, " Large Receive Offload, 1: enable, 0: disable, "
99 99
100static int port_name_cnt; 100static int port_name_cnt;
101static LIST_HEAD(adapter_list); 101static LIST_HEAD(adapter_list);
102u64 ehea_driver_flags; 102static unsigned long ehea_driver_flags;
103struct work_struct ehea_rereg_mr_task; 103struct work_struct ehea_rereg_mr_task;
104static DEFINE_MUTEX(dlpar_mem_lock); 104static DEFINE_MUTEX(dlpar_mem_lock);
105struct ehea_fw_handle_array ehea_fw_handles; 105struct ehea_fw_handle_array ehea_fw_handles;
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index b0ef46c51a9d..cefe1d98f93e 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -944,7 +944,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)
944 if (netif_msg_rx_status(priv)) 944 if (netif_msg_rx_status(priv))
945 enc28j60_dump_rsv(priv, __func__, next_packet, len, rxstat); 945 enc28j60_dump_rsv(priv, __func__, next_packet, len, rxstat);
946 946
947 if (!RSV_GETBIT(rxstat, RSV_RXOK)) { 947 if (!RSV_GETBIT(rxstat, RSV_RXOK) || len > MAX_FRAMELEN) {
948 if (netif_msg_rx_err(priv)) 948 if (netif_msg_rx_err(priv))
949 dev_err(&ndev->dev, "Rx Error (%04x)\n", rxstat); 949 dev_err(&ndev->dev, "Rx Error (%04x)\n", rxstat);
950 ndev->stats.rx_errors++; 950 ndev->stats.rx_errors++;
@@ -952,6 +952,8 @@ static void enc28j60_hw_rx(struct net_device *ndev)
952 ndev->stats.rx_crc_errors++; 952 ndev->stats.rx_crc_errors++;
953 if (RSV_GETBIT(rxstat, RSV_LENCHECKERR)) 953 if (RSV_GETBIT(rxstat, RSV_LENCHECKERR))
954 ndev->stats.rx_frame_errors++; 954 ndev->stats.rx_frame_errors++;
955 if (len > MAX_FRAMELEN)
956 ndev->stats.rx_over_errors++;
955 } else { 957 } else {
956 skb = dev_alloc_skb(len + NET_IP_ALIGN); 958 skb = dev_alloc_skb(len + NET_IP_ALIGN);
957 if (!skb) { 959 if (!skb) {
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 022794e579c7..b82b0fb2056c 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1457,8 +1457,8 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
1457 1457
1458 /* Number of supported queues. */ 1458 /* Number of supported queues. */
1459 /* Having more queues than CPUs doesn't make sense. */ 1459 /* Having more queues than CPUs doesn't make sense. */
1460 adapter->num_rx_queues = min((u32)IGB_MAX_RX_QUEUES, (u32)num_online_cpus()); 1460 adapter->num_rx_queues = min_t(u32, IGB_MAX_RX_QUEUES, num_online_cpus());
1461 adapter->num_tx_queues = min(IGB_MAX_TX_QUEUES, num_online_cpus()); 1461 adapter->num_tx_queues = min_t(u32, IGB_MAX_TX_QUEUES, num_online_cpus());
1462 1462
1463 /* This call may decrease the number of queues depending on 1463 /* This call may decrease the number of queues depending on
1464 * interrupt mode. */ 1464 * interrupt mode. */
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 5e70180bf569..6bb71b687f7b 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -75,7 +75,7 @@
75#include "myri10ge_mcp.h" 75#include "myri10ge_mcp.h"
76#include "myri10ge_mcp_gen_header.h" 76#include "myri10ge_mcp_gen_header.h"
77 77
78#define MYRI10GE_VERSION_STR "1.4.4-1.395" 78#define MYRI10GE_VERSION_STR "1.4.4-1.398"
79 79
80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 80MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
81MODULE_AUTHOR("Maintainer: help@myri.com"); 81MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -3929,6 +3929,10 @@ abort_with_firmware:
3929 myri10ge_dummy_rdma(mgp, 0); 3929 myri10ge_dummy_rdma(mgp, 0);
3930 3930
3931abort_with_ioremap: 3931abort_with_ioremap:
3932 if (mgp->mac_addr_string != NULL)
3933 dev_err(&pdev->dev,
3934 "myri10ge_probe() failed: MAC=%s, SN=%ld\n",
3935 mgp->mac_addr_string, mgp->serial_number);
3932 iounmap(mgp->sram); 3936 iounmap(mgp->sram);
3933 3937
3934abort_with_mtrr: 3938abort_with_mtrr:
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index ba2e1c5b6bcf..459663a4023d 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -818,15 +818,6 @@ struct tx_doorbell_context {
818}; 818};
819 819
820/* DATA STRUCTURES SHARED WITH HARDWARE. */ 820/* DATA STRUCTURES SHARED WITH HARDWARE. */
821
822struct bq_element {
823 u32 addr_lo;
824#define BQ_END 0x00000001
825#define BQ_CONT 0x00000002
826#define BQ_MASK 0x00000003
827 u32 addr_hi;
828} __attribute((packed));
829
830struct tx_buf_desc { 821struct tx_buf_desc {
831 __le64 addr; 822 __le64 addr;
832 __le32 len; 823 __le32 len;
@@ -860,8 +851,8 @@ struct ob_mac_iocb_req {
860 __le16 frame_len; 851 __le16 frame_len;
861#define OB_MAC_IOCB_LEN_MASK 0x3ffff 852#define OB_MAC_IOCB_LEN_MASK 0x3ffff
862 __le16 reserved2; 853 __le16 reserved2;
863 __le32 tid; 854 u32 tid;
864 __le32 txq_idx; 855 u32 txq_idx;
865 __le32 reserved3; 856 __le32 reserved3;
866 __le16 vlan_tci; 857 __le16 vlan_tci;
867 __le16 reserved4; 858 __le16 reserved4;
@@ -880,8 +871,8 @@ struct ob_mac_iocb_rsp {
880 u8 flags2; /* */ 871 u8 flags2; /* */
881 u8 flags3; /* */ 872 u8 flags3; /* */
882#define OB_MAC_IOCB_RSP_B 0x80 /* */ 873#define OB_MAC_IOCB_RSP_B 0x80 /* */
883 __le32 tid; 874 u32 tid;
884 __le32 txq_idx; 875 u32 txq_idx;
885 __le32 reserved[13]; 876 __le32 reserved[13];
886} __attribute((packed)); 877} __attribute((packed));
887 878
@@ -903,8 +894,8 @@ struct ob_mac_tso_iocb_req {
903#define OB_MAC_TSO_IOCB_V 0x04 894#define OB_MAC_TSO_IOCB_V 0x04
904 __le32 reserved1[2]; 895 __le32 reserved1[2];
905 __le32 frame_len; 896 __le32 frame_len;
906 __le32 tid; 897 u32 tid;
907 __le32 txq_idx; 898 u32 txq_idx;
908 __le16 total_hdrs_len; 899 __le16 total_hdrs_len;
909 __le16 net_trans_offset; 900 __le16 net_trans_offset;
910#define OB_MAC_TRANSPORT_HDR_SHIFT 6 901#define OB_MAC_TRANSPORT_HDR_SHIFT 6
@@ -925,8 +916,8 @@ struct ob_mac_tso_iocb_rsp {
925 u8 flags2; /* */ 916 u8 flags2; /* */
926 u8 flags3; /* */ 917 u8 flags3; /* */
927#define OB_MAC_TSO_IOCB_RSP_B 0x8000 918#define OB_MAC_TSO_IOCB_RSP_B 0x8000
928 __le32 tid; 919 u32 tid;
929 __le32 txq_idx; 920 u32 txq_idx;
930 __le32 reserved2[13]; 921 __le32 reserved2[13];
931} __attribute((packed)); 922} __attribute((packed));
932 923
@@ -979,10 +970,11 @@ struct ib_mac_iocb_rsp {
979 970
980 __le16 reserved1; 971 __le16 reserved1;
981 __le32 reserved2[6]; 972 __le32 reserved2[6];
982 __le32 flags4; 973 u8 reserved3[3];
983#define IB_MAC_IOCB_RSP_HV 0x20000000 /* */ 974 u8 flags4;
984#define IB_MAC_IOCB_RSP_HS 0x40000000 /* */ 975#define IB_MAC_IOCB_RSP_HV 0x20
985#define IB_MAC_IOCB_RSP_HL 0x80000000 /* */ 976#define IB_MAC_IOCB_RSP_HS 0x40
977#define IB_MAC_IOCB_RSP_HL 0x80
986 __le32 hdr_len; /* */ 978 __le32 hdr_len; /* */
987 __le32 hdr_addr_lo; /* */ 979 __le32 hdr_addr_lo; /* */
988 __le32 hdr_addr_hi; /* */ 980 __le32 hdr_addr_hi; /* */
@@ -1126,7 +1118,7 @@ struct map_list {
1126struct tx_ring_desc { 1118struct tx_ring_desc {
1127 struct sk_buff *skb; 1119 struct sk_buff *skb;
1128 struct ob_mac_iocb_req *queue_entry; 1120 struct ob_mac_iocb_req *queue_entry;
1129 int index; 1121 u32 index;
1130 struct oal oal; 1122 struct oal oal;
1131 struct map_list map[MAX_SKB_FRAGS + 1]; 1123 struct map_list map[MAX_SKB_FRAGS + 1];
1132 int map_cnt; 1124 int map_cnt;
@@ -1138,8 +1130,8 @@ struct bq_desc {
1138 struct page *lbq_page; 1130 struct page *lbq_page;
1139 struct sk_buff *skb; 1131 struct sk_buff *skb;
1140 } p; 1132 } p;
1141 struct bq_element *bq; 1133 __le64 *addr;
1142 int index; 1134 u32 index;
1143 DECLARE_PCI_UNMAP_ADDR(mapaddr); 1135 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1144 DECLARE_PCI_UNMAP_LEN(maplen); 1136 DECLARE_PCI_UNMAP_LEN(maplen);
1145}; 1137};
@@ -1189,7 +1181,7 @@ struct rx_ring {
1189 u32 cq_size; 1181 u32 cq_size;
1190 u32 cq_len; 1182 u32 cq_len;
1191 u16 cq_id; 1183 u16 cq_id;
1192 u32 *prod_idx_sh_reg; /* Shadowed producer register. */ 1184 volatile __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
1193 dma_addr_t prod_idx_sh_reg_dma; 1185 dma_addr_t prod_idx_sh_reg_dma;
1194 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */ 1186 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1195 u32 cnsmr_idx; /* current sw idx */ 1187 u32 cnsmr_idx; /* current sw idx */
@@ -1467,21 +1459,6 @@ static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1467 mmiowb(); 1459 mmiowb();
1468} 1460}
1469 1461
1470/*
1471 * Shadow Registers:
1472 * Outbound queues have a consumer index that is maintained by the chip.
1473 * Inbound queues have a producer index that is maintained by the chip.
1474 * For lower overhead, these registers are "shadowed" to host memory
1475 * which allows the device driver to track the queue progress without
1476 * PCI reads. When an entry is placed on an inbound queue, the chip will
1477 * update the relevant index register and then copy the value to the
1478 * shadow register in host memory.
1479 */
1480static inline unsigned int ql_read_sh_reg(const volatile void *addr)
1481{
1482 return *(volatile unsigned int __force *)addr;
1483}
1484
1485extern char qlge_driver_name[]; 1462extern char qlge_driver_name[];
1486extern const char qlge_driver_version[]; 1463extern const char qlge_driver_version[];
1487extern const struct ethtool_ops qlge_ethtool_ops; 1464extern const struct ethtool_ops qlge_ethtool_ops;
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index 47df304a02c8..3f5e02d2e4a9 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -821,14 +821,11 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
821 le16_to_cpu(ib_mac_rsp->vlan_id)); 821 le16_to_cpu(ib_mac_rsp->vlan_id));
822 822
823 printk(KERN_ERR PFX "flags4 = %s%s%s.\n", 823 printk(KERN_ERR PFX "flags4 = %s%s%s.\n",
824 le32_to_cpu(ib_mac_rsp-> 824 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "",
825 flags4) & IB_MAC_IOCB_RSP_HV ? "HV " : "", 825 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "",
826 le32_to_cpu(ib_mac_rsp-> 826 ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : "");
827 flags4) & IB_MAC_IOCB_RSP_HS ? "HS " : "", 827
828 le32_to_cpu(ib_mac_rsp-> 828 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
829 flags4) & IB_MAC_IOCB_RSP_HL ? "HL " : "");
830
831 if (le32_to_cpu(ib_mac_rsp->flags4) & IB_MAC_IOCB_RSP_HV) {
832 printk(KERN_ERR PFX "hdr length = %d.\n", 829 printk(KERN_ERR PFX "hdr length = %d.\n",
833 le32_to_cpu(ib_mac_rsp->hdr_len)); 830 le32_to_cpu(ib_mac_rsp->hdr_len));
834 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n", 831 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n",
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index eefb81b13758..9d922e2ff226 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -56,9 +56,9 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
56 for (i = 1; i < qdev->rss_ring_first_cq_id; i++, rx_ring++) { 56 for (i = 1; i < qdev->rss_ring_first_cq_id; i++, rx_ring++) {
57 rx_ring = &qdev->rx_ring[i]; 57 rx_ring = &qdev->rx_ring[i];
58 cqicb = (struct cqicb *)rx_ring; 58 cqicb = (struct cqicb *)rx_ring;
59 cqicb->irq_delay = le16_to_cpu(qdev->tx_coalesce_usecs); 59 cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs);
60 cqicb->pkt_delay = 60 cqicb->pkt_delay =
61 le16_to_cpu(qdev->tx_max_coalesced_frames); 61 cpu_to_le16(qdev->tx_max_coalesced_frames);
62 cqicb->flags = FLAGS_LI; 62 cqicb->flags = FLAGS_LI;
63 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 63 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb),
64 CFG_LCQ, rx_ring->cq_id); 64 CFG_LCQ, rx_ring->cq_id);
@@ -79,9 +79,9 @@ static int ql_update_ring_coalescing(struct ql_adapter *qdev)
79 i++) { 79 i++) {
80 rx_ring = &qdev->rx_ring[i]; 80 rx_ring = &qdev->rx_ring[i];
81 cqicb = (struct cqicb *)rx_ring; 81 cqicb = (struct cqicb *)rx_ring;
82 cqicb->irq_delay = le16_to_cpu(qdev->rx_coalesce_usecs); 82 cqicb->irq_delay = cpu_to_le16(qdev->rx_coalesce_usecs);
83 cqicb->pkt_delay = 83 cqicb->pkt_delay =
84 le16_to_cpu(qdev->rx_max_coalesced_frames); 84 cpu_to_le16(qdev->rx_max_coalesced_frames);
85 cqicb->flags = FLAGS_LI; 85 cqicb->flags = FLAGS_LI;
86 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb), 86 status = ql_write_cfg(qdev, cqicb, sizeof(cqicb),
87 CFG_LCQ, rx_ring->cq_id); 87 CFG_LCQ, rx_ring->cq_id);
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 718a7bd0cd1a..f4c016012f18 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -257,7 +257,7 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
257 { 257 {
258 status = 258 status =
259 ql_wait_reg_rdy(qdev, 259 ql_wait_reg_rdy(qdev,
260 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 260 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
261 if (status) 261 if (status)
262 goto exit; 262 goto exit;
263 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 263 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -265,13 +265,13 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
265 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 265 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
266 status = 266 status =
267 ql_wait_reg_rdy(qdev, 267 ql_wait_reg_rdy(qdev,
268 MAC_ADDR_IDX, MAC_ADDR_MR, MAC_ADDR_E); 268 MAC_ADDR_IDX, MAC_ADDR_MR, 0);
269 if (status) 269 if (status)
270 goto exit; 270 goto exit;
271 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 271 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
272 status = 272 status =
273 ql_wait_reg_rdy(qdev, 273 ql_wait_reg_rdy(qdev,
274 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 274 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
275 if (status) 275 if (status)
276 goto exit; 276 goto exit;
277 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 277 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -279,14 +279,14 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
279 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 279 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
280 status = 280 status =
281 ql_wait_reg_rdy(qdev, 281 ql_wait_reg_rdy(qdev,
282 MAC_ADDR_IDX, MAC_ADDR_MR, MAC_ADDR_E); 282 MAC_ADDR_IDX, MAC_ADDR_MR, 0);
283 if (status) 283 if (status)
284 goto exit; 284 goto exit;
285 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 285 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
286 if (type == MAC_ADDR_TYPE_CAM_MAC) { 286 if (type == MAC_ADDR_TYPE_CAM_MAC) {
287 status = 287 status =
288 ql_wait_reg_rdy(qdev, 288 ql_wait_reg_rdy(qdev,
289 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 289 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
290 if (status) 290 if (status)
291 goto exit; 291 goto exit;
292 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 292 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -294,7 +294,7 @@ int ql_get_mac_addr_reg(struct ql_adapter *qdev, u32 type, u16 index,
294 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */ 294 MAC_ADDR_ADR | MAC_ADDR_RS | type); /* type */
295 status = 295 status =
296 ql_wait_reg_rdy(qdev, MAC_ADDR_IDX, 296 ql_wait_reg_rdy(qdev, MAC_ADDR_IDX,
297 MAC_ADDR_MR, MAC_ADDR_E); 297 MAC_ADDR_MR, 0);
298 if (status) 298 if (status)
299 goto exit; 299 goto exit;
300 *value++ = ql_read32(qdev, MAC_ADDR_DATA); 300 *value++ = ql_read32(qdev, MAC_ADDR_DATA);
@@ -344,7 +344,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
344 344
345 status = 345 status =
346 ql_wait_reg_rdy(qdev, 346 ql_wait_reg_rdy(qdev,
347 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 347 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
348 if (status) 348 if (status)
349 goto exit; 349 goto exit;
350 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 350 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -353,7 +353,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
353 ql_write32(qdev, MAC_ADDR_DATA, lower); 353 ql_write32(qdev, MAC_ADDR_DATA, lower);
354 status = 354 status =
355 ql_wait_reg_rdy(qdev, 355 ql_wait_reg_rdy(qdev,
356 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 356 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
357 if (status) 357 if (status)
358 goto exit; 358 goto exit;
359 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */ 359 ql_write32(qdev, MAC_ADDR_IDX, (offset++) | /* offset */
@@ -362,7 +362,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
362 ql_write32(qdev, MAC_ADDR_DATA, upper); 362 ql_write32(qdev, MAC_ADDR_DATA, upper);
363 status = 363 status =
364 ql_wait_reg_rdy(qdev, 364 ql_wait_reg_rdy(qdev,
365 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 365 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
366 if (status) 366 if (status)
367 goto exit; 367 goto exit;
368 ql_write32(qdev, MAC_ADDR_IDX, (offset) | /* offset */ 368 ql_write32(qdev, MAC_ADDR_IDX, (offset) | /* offset */
@@ -400,7 +400,7 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
400 400
401 status = 401 status =
402 ql_wait_reg_rdy(qdev, 402 ql_wait_reg_rdy(qdev,
403 MAC_ADDR_IDX, MAC_ADDR_MW, MAC_ADDR_E); 403 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
404 if (status) 404 if (status)
405 goto exit; 405 goto exit;
406 ql_write32(qdev, MAC_ADDR_IDX, offset | /* offset */ 406 ql_write32(qdev, MAC_ADDR_IDX, offset | /* offset */
@@ -431,13 +431,13 @@ int ql_get_routing_reg(struct ql_adapter *qdev, u32 index, u32 *value)
431 if (status) 431 if (status)
432 goto exit; 432 goto exit;
433 433
434 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MW, RT_IDX_E); 434 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MW, 0);
435 if (status) 435 if (status)
436 goto exit; 436 goto exit;
437 437
438 ql_write32(qdev, RT_IDX, 438 ql_write32(qdev, RT_IDX,
439 RT_IDX_TYPE_NICQ | RT_IDX_RS | (index << RT_IDX_IDX_SHIFT)); 439 RT_IDX_TYPE_NICQ | RT_IDX_RS | (index << RT_IDX_IDX_SHIFT));
440 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MR, RT_IDX_E); 440 status = ql_wait_reg_rdy(qdev, RT_IDX, RT_IDX_MR, 0);
441 if (status) 441 if (status)
442 goto exit; 442 goto exit;
443 *value = ql_read32(qdev, RT_DATA); 443 *value = ql_read32(qdev, RT_DATA);
@@ -874,7 +874,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
874{ 874{
875 int clean_idx = rx_ring->lbq_clean_idx; 875 int clean_idx = rx_ring->lbq_clean_idx;
876 struct bq_desc *lbq_desc; 876 struct bq_desc *lbq_desc;
877 struct bq_element *bq;
878 u64 map; 877 u64 map;
879 int i; 878 int i;
880 879
@@ -884,7 +883,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
884 "lbq: try cleaning clean_idx = %d.\n", 883 "lbq: try cleaning clean_idx = %d.\n",
885 clean_idx); 884 clean_idx);
886 lbq_desc = &rx_ring->lbq[clean_idx]; 885 lbq_desc = &rx_ring->lbq[clean_idx];
887 bq = lbq_desc->bq;
888 if (lbq_desc->p.lbq_page == NULL) { 886 if (lbq_desc->p.lbq_page == NULL) {
889 QPRINTK(qdev, RX_STATUS, DEBUG, 887 QPRINTK(qdev, RX_STATUS, DEBUG,
890 "lbq: getting new page for index %d.\n", 888 "lbq: getting new page for index %d.\n",
@@ -906,10 +904,7 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
906 } 904 }
907 pci_unmap_addr_set(lbq_desc, mapaddr, map); 905 pci_unmap_addr_set(lbq_desc, mapaddr, map);
908 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE); 906 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE);
909 bq->addr_lo = /*lbq_desc->addr_lo = */ 907 *lbq_desc->addr = cpu_to_le64(map);
910 cpu_to_le32(map);
911 bq->addr_hi = /*lbq_desc->addr_hi = */
912 cpu_to_le32(map >> 32);
913 } 908 }
914 clean_idx++; 909 clean_idx++;
915 if (clean_idx == rx_ring->lbq_len) 910 if (clean_idx == rx_ring->lbq_len)
@@ -934,7 +929,6 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
934{ 929{
935 int clean_idx = rx_ring->sbq_clean_idx; 930 int clean_idx = rx_ring->sbq_clean_idx;
936 struct bq_desc *sbq_desc; 931 struct bq_desc *sbq_desc;
937 struct bq_element *bq;
938 u64 map; 932 u64 map;
939 int i; 933 int i;
940 934
@@ -944,7 +938,6 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
944 QPRINTK(qdev, RX_STATUS, DEBUG, 938 QPRINTK(qdev, RX_STATUS, DEBUG,
945 "sbq: try cleaning clean_idx = %d.\n", 939 "sbq: try cleaning clean_idx = %d.\n",
946 clean_idx); 940 clean_idx);
947 bq = sbq_desc->bq;
948 if (sbq_desc->p.skb == NULL) { 941 if (sbq_desc->p.skb == NULL) {
949 QPRINTK(qdev, RX_STATUS, DEBUG, 942 QPRINTK(qdev, RX_STATUS, DEBUG,
950 "sbq: getting new skb for index %d.\n", 943 "sbq: getting new skb for index %d.\n",
@@ -963,11 +956,15 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
963 sbq_desc->p.skb->data, 956 sbq_desc->p.skb->data,
964 rx_ring->sbq_buf_size / 957 rx_ring->sbq_buf_size /
965 2, PCI_DMA_FROMDEVICE); 958 2, PCI_DMA_FROMDEVICE);
959 if (pci_dma_mapping_error(qdev->pdev, map)) {
960 QPRINTK(qdev, IFUP, ERR, "PCI mapping failed.\n");
961 rx_ring->sbq_clean_idx = clean_idx;
962 return;
963 }
966 pci_unmap_addr_set(sbq_desc, mapaddr, map); 964 pci_unmap_addr_set(sbq_desc, mapaddr, map);
967 pci_unmap_len_set(sbq_desc, maplen, 965 pci_unmap_len_set(sbq_desc, maplen,
968 rx_ring->sbq_buf_size / 2); 966 rx_ring->sbq_buf_size / 2);
969 bq->addr_lo = cpu_to_le32(map); 967 *sbq_desc->addr = cpu_to_le64(map);
970 bq->addr_hi = cpu_to_le32(map >> 32);
971 } 968 }
972 969
973 clean_idx++; 970 clean_idx++;
@@ -1303,6 +1300,11 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1303 "No skb available, drop the packet.\n"); 1300 "No skb available, drop the packet.\n");
1304 return NULL; 1301 return NULL;
1305 } 1302 }
1303 pci_unmap_page(qdev->pdev,
1304 pci_unmap_addr(lbq_desc,
1305 mapaddr),
1306 pci_unmap_len(lbq_desc, maplen),
1307 PCI_DMA_FROMDEVICE);
1306 skb_reserve(skb, NET_IP_ALIGN); 1308 skb_reserve(skb, NET_IP_ALIGN);
1307 QPRINTK(qdev, RX_STATUS, DEBUG, 1309 QPRINTK(qdev, RX_STATUS, DEBUG,
1308 "%d bytes of headers and data in large. Chain page to new skb and pull tail.\n", length); 1310 "%d bytes of headers and data in large. Chain page to new skb and pull tail.\n", length);
@@ -1330,7 +1332,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1330 * eventually be in trouble. 1332 * eventually be in trouble.
1331 */ 1333 */
1332 int size, offset, i = 0; 1334 int size, offset, i = 0;
1333 struct bq_element *bq, bq_array[8]; 1335 __le64 *bq, bq_array[8];
1334 sbq_desc = ql_get_curr_sbuf(rx_ring); 1336 sbq_desc = ql_get_curr_sbuf(rx_ring);
1335 pci_unmap_single(qdev->pdev, 1337 pci_unmap_single(qdev->pdev,
1336 pci_unmap_addr(sbq_desc, mapaddr), 1338 pci_unmap_addr(sbq_desc, mapaddr),
@@ -1356,16 +1358,10 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev,
1356 } else { 1358 } else {
1357 QPRINTK(qdev, RX_STATUS, DEBUG, 1359 QPRINTK(qdev, RX_STATUS, DEBUG,
1358 "Headers in small, %d bytes of data in chain of large.\n", length); 1360 "Headers in small, %d bytes of data in chain of large.\n", length);
1359 bq = (struct bq_element *)sbq_desc->p.skb->data; 1361 bq = (__le64 *)sbq_desc->p.skb->data;
1360 } 1362 }
1361 while (length > 0) { 1363 while (length > 0) {
1362 lbq_desc = ql_get_curr_lbuf(rx_ring); 1364 lbq_desc = ql_get_curr_lbuf(rx_ring);
1363 if ((bq->addr_lo & ~BQ_MASK) != lbq_desc->bq->addr_lo) {
1364 QPRINTK(qdev, RX_STATUS, ERR,
1365 "Panic!!! bad large buffer address, expected 0x%.08x, got 0x%.08x.\n",
1366 lbq_desc->bq->addr_lo, bq->addr_lo);
1367 return NULL;
1368 }
1369 pci_unmap_page(qdev->pdev, 1365 pci_unmap_page(qdev->pdev,
1370 pci_unmap_addr(lbq_desc, 1366 pci_unmap_addr(lbq_desc,
1371 mapaddr), 1367 mapaddr),
@@ -1549,7 +1545,7 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev,
1549static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) 1545static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1550{ 1546{
1551 struct ql_adapter *qdev = rx_ring->qdev; 1547 struct ql_adapter *qdev = rx_ring->qdev;
1552 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1548 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1553 struct ob_mac_iocb_rsp *net_rsp = NULL; 1549 struct ob_mac_iocb_rsp *net_rsp = NULL;
1554 int count = 0; 1550 int count = 0;
1555 1551
@@ -1575,7 +1571,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1575 } 1571 }
1576 count++; 1572 count++;
1577 ql_update_cq(rx_ring); 1573 ql_update_cq(rx_ring);
1578 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1574 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1579 } 1575 }
1580 ql_write_cq_idx(rx_ring); 1576 ql_write_cq_idx(rx_ring);
1581 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) { 1577 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) {
@@ -1595,7 +1591,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1595static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) 1591static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1596{ 1592{
1597 struct ql_adapter *qdev = rx_ring->qdev; 1593 struct ql_adapter *qdev = rx_ring->qdev;
1598 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1594 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1599 struct ql_net_rsp_iocb *net_rsp; 1595 struct ql_net_rsp_iocb *net_rsp;
1600 int count = 0; 1596 int count = 0;
1601 1597
@@ -1628,7 +1624,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1628 } 1624 }
1629 count++; 1625 count++;
1630 ql_update_cq(rx_ring); 1626 ql_update_cq(rx_ring);
1631 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg); 1627 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg);
1632 if (count == budget) 1628 if (count == budget)
1633 break; 1629 break;
1634 } 1630 }
@@ -1791,7 +1787,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1791 * Check the default queue and wake handler if active. 1787 * Check the default queue and wake handler if active.
1792 */ 1788 */
1793 rx_ring = &qdev->rx_ring[0]; 1789 rx_ring = &qdev->rx_ring[0];
1794 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) { 1790 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) {
1795 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n"); 1791 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n");
1796 ql_disable_completion_interrupt(qdev, intr_context->intr); 1792 ql_disable_completion_interrupt(qdev, intr_context->intr);
1797 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue, 1793 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue,
@@ -1805,7 +1801,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1805 */ 1801 */
1806 for (i = 1; i < qdev->rx_ring_count; i++) { 1802 for (i = 1; i < qdev->rx_ring_count; i++) {
1807 rx_ring = &qdev->rx_ring[i]; 1803 rx_ring = &qdev->rx_ring[i];
1808 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != 1804 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) !=
1809 rx_ring->cnsmr_idx) { 1805 rx_ring->cnsmr_idx) {
1810 QPRINTK(qdev, INTR, INFO, 1806 QPRINTK(qdev, INTR, INFO,
1811 "Waking handler for rx_ring[%d].\n", i); 1807 "Waking handler for rx_ring[%d].\n", i);
@@ -1874,7 +1870,7 @@ static void ql_hw_csum_setup(struct sk_buff *skb,
1874{ 1870{
1875 int len; 1871 int len;
1876 struct iphdr *iph = ip_hdr(skb); 1872 struct iphdr *iph = ip_hdr(skb);
1877 u16 *check; 1873 __sum16 *check;
1878 mac_iocb_ptr->opcode = OPCODE_OB_MAC_TSO_IOCB; 1874 mac_iocb_ptr->opcode = OPCODE_OB_MAC_TSO_IOCB;
1879 mac_iocb_ptr->frame_len = cpu_to_le32((u32) skb->len); 1875 mac_iocb_ptr->frame_len = cpu_to_le32((u32) skb->len);
1880 mac_iocb_ptr->net_trans_offset = 1876 mac_iocb_ptr->net_trans_offset =
@@ -2083,8 +2079,6 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring
2083 put_page(lbq_desc->p.lbq_page); 2079 put_page(lbq_desc->p.lbq_page);
2084 lbq_desc->p.lbq_page = NULL; 2080 lbq_desc->p.lbq_page = NULL;
2085 } 2081 }
2086 lbq_desc->bq->addr_lo = 0;
2087 lbq_desc->bq->addr_hi = 0;
2088 } 2082 }
2089} 2083}
2090 2084
@@ -2097,12 +2091,12 @@ static int ql_alloc_lbq_buffers(struct ql_adapter *qdev,
2097 int i; 2091 int i;
2098 struct bq_desc *lbq_desc; 2092 struct bq_desc *lbq_desc;
2099 u64 map; 2093 u64 map;
2100 struct bq_element *bq = rx_ring->lbq_base; 2094 __le64 *bq = rx_ring->lbq_base;
2101 2095
2102 for (i = 0; i < rx_ring->lbq_len; i++) { 2096 for (i = 0; i < rx_ring->lbq_len; i++) {
2103 lbq_desc = &rx_ring->lbq[i]; 2097 lbq_desc = &rx_ring->lbq[i];
2104 memset(lbq_desc, 0, sizeof(lbq_desc)); 2098 memset(lbq_desc, 0, sizeof(lbq_desc));
2105 lbq_desc->bq = bq; 2099 lbq_desc->addr = bq;
2106 lbq_desc->index = i; 2100 lbq_desc->index = i;
2107 lbq_desc->p.lbq_page = alloc_page(GFP_ATOMIC); 2101 lbq_desc->p.lbq_page = alloc_page(GFP_ATOMIC);
2108 if (unlikely(!lbq_desc->p.lbq_page)) { 2102 if (unlikely(!lbq_desc->p.lbq_page)) {
@@ -2119,8 +2113,7 @@ static int ql_alloc_lbq_buffers(struct ql_adapter *qdev,
2119 } 2113 }
2120 pci_unmap_addr_set(lbq_desc, mapaddr, map); 2114 pci_unmap_addr_set(lbq_desc, mapaddr, map);
2121 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE); 2115 pci_unmap_len_set(lbq_desc, maplen, PAGE_SIZE);
2122 bq->addr_lo = cpu_to_le32(map); 2116 *lbq_desc->addr = cpu_to_le64(map);
2123 bq->addr_hi = cpu_to_le32(map >> 32);
2124 } 2117 }
2125 bq++; 2118 bq++;
2126 } 2119 }
@@ -2149,13 +2142,6 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring
2149 dev_kfree_skb(sbq_desc->p.skb); 2142 dev_kfree_skb(sbq_desc->p.skb);
2150 sbq_desc->p.skb = NULL; 2143 sbq_desc->p.skb = NULL;
2151 } 2144 }
2152 if (sbq_desc->bq == NULL) {
2153 QPRINTK(qdev, IFUP, ERR, "sbq_desc->bq %d is NULL.\n",
2154 i);
2155 return;
2156 }
2157 sbq_desc->bq->addr_lo = 0;
2158 sbq_desc->bq->addr_hi = 0;
2159 } 2145 }
2160} 2146}
2161 2147
@@ -2167,13 +2153,13 @@ static int ql_alloc_sbq_buffers(struct ql_adapter *qdev,
2167 struct bq_desc *sbq_desc; 2153 struct bq_desc *sbq_desc;
2168 struct sk_buff *skb; 2154 struct sk_buff *skb;
2169 u64 map; 2155 u64 map;
2170 struct bq_element *bq = rx_ring->sbq_base; 2156 __le64 *bq = rx_ring->sbq_base;
2171 2157
2172 for (i = 0; i < rx_ring->sbq_len; i++) { 2158 for (i = 0; i < rx_ring->sbq_len; i++) {
2173 sbq_desc = &rx_ring->sbq[i]; 2159 sbq_desc = &rx_ring->sbq[i];
2174 memset(sbq_desc, 0, sizeof(sbq_desc)); 2160 memset(sbq_desc, 0, sizeof(sbq_desc));
2175 sbq_desc->index = i; 2161 sbq_desc->index = i;
2176 sbq_desc->bq = bq; 2162 sbq_desc->addr = bq;
2177 skb = netdev_alloc_skb(qdev->ndev, rx_ring->sbq_buf_size); 2163 skb = netdev_alloc_skb(qdev->ndev, rx_ring->sbq_buf_size);
2178 if (unlikely(!skb)) { 2164 if (unlikely(!skb)) {
2179 /* Better luck next round */ 2165 /* Better luck next round */
@@ -2199,10 +2185,7 @@ static int ql_alloc_sbq_buffers(struct ql_adapter *qdev,
2199 } 2185 }
2200 pci_unmap_addr_set(sbq_desc, mapaddr, map); 2186 pci_unmap_addr_set(sbq_desc, mapaddr, map);
2201 pci_unmap_len_set(sbq_desc, maplen, rx_ring->sbq_buf_size / 2); 2187 pci_unmap_len_set(sbq_desc, maplen, rx_ring->sbq_buf_size / 2);
2202 bq->addr_lo = /*sbq_desc->addr_lo = */ 2188 *sbq_desc->addr = cpu_to_le64(map);
2203 cpu_to_le32(map);
2204 bq->addr_hi = /*sbq_desc->addr_hi = */
2205 cpu_to_le32(map >> 32);
2206 bq++; 2189 bq++;
2207 } 2190 }
2208 return 0; 2191 return 0;
@@ -2481,7 +2464,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2481 memset((void *)cqicb, 0, sizeof(struct cqicb)); 2464 memset((void *)cqicb, 0, sizeof(struct cqicb));
2482 cqicb->msix_vect = rx_ring->irq; 2465 cqicb->msix_vect = rx_ring->irq;
2483 2466
2484 cqicb->len = cpu_to_le16(rx_ring->cq_len | LEN_V | LEN_CPP_CONT); 2467 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
2468 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
2485 2469
2486 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma); 2470 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma);
2487 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32); 2471 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32);
@@ -2503,8 +2487,11 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2503 cpu_to_le32(rx_ring->lbq_base_indirect_dma); 2487 cpu_to_le32(rx_ring->lbq_base_indirect_dma);
2504 cqicb->lbq_addr_hi = 2488 cqicb->lbq_addr_hi =
2505 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32); 2489 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32);
2506 cqicb->lbq_buf_size = cpu_to_le32(rx_ring->lbq_buf_size); 2490 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 :
2507 bq_len = (u16) rx_ring->lbq_len; 2491 (u16) rx_ring->lbq_buf_size;
2492 cqicb->lbq_buf_size = cpu_to_le16(bq_len);
2493 bq_len = (rx_ring->lbq_len == 65536) ? 0 :
2494 (u16) rx_ring->lbq_len;
2508 cqicb->lbq_len = cpu_to_le16(bq_len); 2495 cqicb->lbq_len = cpu_to_le16(bq_len);
2509 rx_ring->lbq_prod_idx = rx_ring->lbq_len - 16; 2496 rx_ring->lbq_prod_idx = rx_ring->lbq_len - 16;
2510 rx_ring->lbq_curr_idx = 0; 2497 rx_ring->lbq_curr_idx = 0;
@@ -2520,7 +2507,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2520 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32); 2507 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32);
2521 cqicb->sbq_buf_size = 2508 cqicb->sbq_buf_size =
2522 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8); 2509 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8);
2523 bq_len = (u16) rx_ring->sbq_len; 2510 bq_len = (rx_ring->sbq_len == 65536) ? 0 :
2511 (u16) rx_ring->sbq_len;
2524 cqicb->sbq_len = cpu_to_le16(bq_len); 2512 cqicb->sbq_len = cpu_to_le16(bq_len);
2525 rx_ring->sbq_prod_idx = rx_ring->sbq_len - 16; 2513 rx_ring->sbq_prod_idx = rx_ring->sbq_len - 16;
2526 rx_ring->sbq_curr_idx = 0; 2514 rx_ring->sbq_curr_idx = 0;
@@ -3341,11 +3329,11 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3341 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); 3329 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb);
3342 rx_ring->lbq_len = NUM_LARGE_BUFFERS; 3330 rx_ring->lbq_len = NUM_LARGE_BUFFERS;
3343 rx_ring->lbq_size = 3331 rx_ring->lbq_size =
3344 rx_ring->lbq_len * sizeof(struct bq_element); 3332 rx_ring->lbq_len * sizeof(__le64);
3345 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE; 3333 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE;
3346 rx_ring->sbq_len = NUM_SMALL_BUFFERS; 3334 rx_ring->sbq_len = NUM_SMALL_BUFFERS;
3347 rx_ring->sbq_size = 3335 rx_ring->sbq_size =
3348 rx_ring->sbq_len * sizeof(struct bq_element); 3336 rx_ring->sbq_len * sizeof(__le64);
3349 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2; 3337 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2;
3350 rx_ring->type = DEFAULT_Q; 3338 rx_ring->type = DEFAULT_Q;
3351 } else if (i < qdev->rss_ring_first_cq_id) { 3339 } else if (i < qdev->rss_ring_first_cq_id) {
@@ -3372,11 +3360,11 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3372 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); 3360 rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb);
3373 rx_ring->lbq_len = NUM_LARGE_BUFFERS; 3361 rx_ring->lbq_len = NUM_LARGE_BUFFERS;
3374 rx_ring->lbq_size = 3362 rx_ring->lbq_size =
3375 rx_ring->lbq_len * sizeof(struct bq_element); 3363 rx_ring->lbq_len * sizeof(__le64);
3376 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE; 3364 rx_ring->lbq_buf_size = LARGE_BUFFER_SIZE;
3377 rx_ring->sbq_len = NUM_SMALL_BUFFERS; 3365 rx_ring->sbq_len = NUM_SMALL_BUFFERS;
3378 rx_ring->sbq_size = 3366 rx_ring->sbq_size =
3379 rx_ring->sbq_len * sizeof(struct bq_element); 3367 rx_ring->sbq_len * sizeof(__le64);
3380 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2; 3368 rx_ring->sbq_buf_size = SMALL_BUFFER_SIZE * 2;
3381 rx_ring->type = RX_Q; 3369 rx_ring->type = RX_Q;
3382 } 3370 }
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index f54ac2389da2..57fb1f71c47b 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -42,11 +42,11 @@
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/if_vlan.h> 43#include <linux/if_vlan.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/firmware.h>
45#include <asm/processor.h> /* Processor type for cache alignment. */ 46#include <asm/processor.h> /* Processor type for cache alignment. */
46#include <asm/uaccess.h> 47#include <asm/uaccess.h>
47#include <asm/io.h> 48#include <asm/io.h>
48 49
49#include "starfire_firmware.h"
50/* 50/*
51 * The current frame processor firmware fails to checksum a fragment 51 * The current frame processor firmware fails to checksum a fragment
52 * of length 1. If and when this is fixed, the #define below can be removed. 52 * of length 1. If and when this is fixed, the #define below can be removed.
@@ -173,6 +173,10 @@ static int full_duplex[MAX_UNITS] = {0, };
173#define skb_first_frag_len(skb) skb_headlen(skb) 173#define skb_first_frag_len(skb) skb_headlen(skb)
174#define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1) 174#define skb_num_frags(skb) (skb_shinfo(skb)->nr_frags + 1)
175 175
176/* Firmware names */
177#define FIRMWARE_RX "adaptec/starfire_rx.bin"
178#define FIRMWARE_TX "adaptec/starfire_tx.bin"
179
176/* These identify the driver base version and may not be removed. */ 180/* These identify the driver base version and may not be removed. */
177static char version[] = 181static char version[] =
178KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n" 182KERN_INFO "starfire.c:v1.03 7/26/2000 Written by Donald Becker <becker@scyld.com>\n"
@@ -182,6 +186,8 @@ MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
182MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver"); 186MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver");
183MODULE_LICENSE("GPL"); 187MODULE_LICENSE("GPL");
184MODULE_VERSION(DRV_VERSION); 188MODULE_VERSION(DRV_VERSION);
189MODULE_FIRMWARE(FIRMWARE_RX);
190MODULE_FIRMWARE(FIRMWARE_TX);
185 191
186module_param(max_interrupt_work, int, 0); 192module_param(max_interrupt_work, int, 0);
187module_param(mtu, int, 0); 193module_param(mtu, int, 0);
@@ -902,9 +908,12 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
902 908
903static int netdev_open(struct net_device *dev) 909static int netdev_open(struct net_device *dev)
904{ 910{
911 const struct firmware *fw_rx, *fw_tx;
912 const __be32 *fw_rx_data, *fw_tx_data;
905 struct netdev_private *np = netdev_priv(dev); 913 struct netdev_private *np = netdev_priv(dev);
906 void __iomem *ioaddr = np->base; 914 void __iomem *ioaddr = np->base;
907 int i, retval; 915 int i, retval;
916 size_t tx_size, rx_size;
908 size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size; 917 size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
909 918
910 /* Do we ever need to reset the chip??? */ 919 /* Do we ever need to reset the chip??? */
@@ -1040,11 +1049,40 @@ static int netdev_open(struct net_device *dev)
1040 writel(ETH_P_8021Q, ioaddr + VlanType); 1049 writel(ETH_P_8021Q, ioaddr + VlanType);
1041#endif /* VLAN_SUPPORT */ 1050#endif /* VLAN_SUPPORT */
1042 1051
1052 retval = request_firmware(&fw_rx, FIRMWARE_RX, &np->pci_dev->dev);
1053 if (retval) {
1054 printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
1055 FIRMWARE_RX);
1056 return retval;
1057 }
1058 if (fw_rx->size % 4) {
1059 printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
1060 fw_rx->size, FIRMWARE_RX);
1061 retval = -EINVAL;
1062 goto out_rx;
1063 }
1064 retval = request_firmware(&fw_tx, FIRMWARE_TX, &np->pci_dev->dev);
1065 if (retval) {
1066 printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
1067 FIRMWARE_TX);
1068 goto out_rx;
1069 }
1070 if (fw_tx->size % 4) {
1071 printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
1072 fw_tx->size, FIRMWARE_TX);
1073 retval = -EINVAL;
1074 goto out_tx;
1075 }
1076 fw_rx_data = (const __be32 *)&fw_rx->data[0];
1077 fw_tx_data = (const __be32 *)&fw_tx->data[0];
1078 rx_size = fw_rx->size / 4;
1079 tx_size = fw_tx->size / 4;
1080
1043 /* Load Rx/Tx firmware into the frame processors */ 1081 /* Load Rx/Tx firmware into the frame processors */
1044 for (i = 0; i < FIRMWARE_RX_SIZE * 2; i++) 1082 for (i = 0; i < rx_size; i++)
1045 writel(firmware_rx[i], ioaddr + RxGfpMem + i * 4); 1083 writel(be32_to_cpup(&fw_rx_data[i]), ioaddr + RxGfpMem + i * 4);
1046 for (i = 0; i < FIRMWARE_TX_SIZE * 2; i++) 1084 for (i = 0; i < tx_size; i++)
1047 writel(firmware_tx[i], ioaddr + TxGfpMem + i * 4); 1085 writel(be32_to_cpup(&fw_tx_data[i]), ioaddr + TxGfpMem + i * 4);
1048 if (enable_hw_cksum) 1086 if (enable_hw_cksum)
1049 /* Enable the Rx and Tx units, and the Rx/Tx frame processors. */ 1087 /* Enable the Rx and Tx units, and the Rx/Tx frame processors. */
1050 writel(TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl); 1088 writel(TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl);
@@ -1056,7 +1094,11 @@ static int netdev_open(struct net_device *dev)
1056 printk(KERN_DEBUG "%s: Done netdev_open().\n", 1094 printk(KERN_DEBUG "%s: Done netdev_open().\n",
1057 dev->name); 1095 dev->name);
1058 1096
1059 return 0; 1097out_tx:
1098 release_firmware(fw_tx);
1099out_rx:
1100 release_firmware(fw_rx);
1101 return retval;
1060} 1102}
1061 1103
1062 1104
diff --git a/drivers/net/starfire_firmware.h b/drivers/net/starfire_firmware.h
deleted file mode 100644
index 0a668528955d..000000000000
--- a/drivers/net/starfire_firmware.h
+++ /dev/null
@@ -1,346 +0,0 @@
1/*
2 * Copyright 2003 Adaptec, Inc.
3 *
4 * Please read the following license before using the Adaptec Software
5 * ("Program"). If you do not agree to the license terms, do not use the
6 * Program:
7 *
8 * You agree to be bound by version 2 of the General Public License ("GPL")
9 * dated June 1991, which can be found at http://www.fsf.org/licenses/gpl.html.
10 * If the link is broken, write to Free Software Foundation, 59 Temple Place,
11 * Boston, Massachusetts 02111-1307.
12 *
13 * BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE IT IS LICENSED "AS IS" AND
14 * THERE IS NO WARRANTY FOR THE PROGRAM, INCLUDING BUT NOT LIMITED TO THE
15 * IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * (TO THE EXTENT PERMITTED BY APPLICABLE LAW). USE OF THE PROGRAM IS AT YOUR
17 * OWN RISK. IN NO EVENT WILL ADAPTEC OR ITS LICENSORS BE LIABLE TO YOU FOR
18 * DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
19 * ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM.
20 *
21 */
22
23static const u32 firmware_rx[] = {
24 0x010003dc, 0x00000000,
25 0x04000421, 0x00000086,
26 0x80000015, 0x0000180e,
27 0x81000015, 0x00006664,
28 0x1a0040ab, 0x00000b06,
29 0x14200011, 0x00000000,
30 0x14204022, 0x0000aaaa,
31 0x14204022, 0x00000300,
32 0x14204022, 0x00000000,
33 0x1a0040ab, 0x00000b14,
34 0x14200011, 0x00000000,
35 0x83000015, 0x00000002,
36 0x04000021, 0x00000000,
37 0x00000010, 0x00000000,
38 0x04000421, 0x00000087,
39 0x00000010, 0x00000000,
40 0x00000010, 0x00000000,
41 0x00008015, 0x00000000,
42 0x0000003e, 0x00000000,
43 0x00000010, 0x00000000,
44 0x82000015, 0x00004000,
45 0x009e8050, 0x00000000,
46 0x03008015, 0x00000000,
47 0x86008015, 0x00000000,
48 0x82000015, 0x00008000,
49 0x0100001c, 0x00000000,
50 0x000050a0, 0x0000010c,
51 0x4e20d011, 0x00006008,
52 0x1420d012, 0x00004008,
53 0x0000f090, 0x00007000,
54 0x0000c8b0, 0x00003000,
55 0x00004040, 0x00000000,
56 0x00108015, 0x00000000,
57 0x00a2c150, 0x00004000,
58 0x00a400b0, 0x00000014,
59 0x00000020, 0x00000000,
60 0x2500400d, 0x00002525,
61 0x00047220, 0x00003100,
62 0x00934070, 0x00000000,
63 0x00000020, 0x00000000,
64 0x00924460, 0x00000184,
65 0x2b20c011, 0x00000000,
66 0x0000c420, 0x00000540,
67 0x36014018, 0x0000422d,
68 0x14200011, 0x00000000,
69 0x00924460, 0x00000183,
70 0x3200001f, 0x00000034,
71 0x02ac0015, 0x00000002,
72 0x00a60110, 0x00000008,
73 0x42200011, 0x00000000,
74 0x00924060, 0x00000103,
75 0x0000001e, 0x00000000,
76 0x00000020, 0x00000100,
77 0x0000001e, 0x00000000,
78 0x00924460, 0x00000086,
79 0x00004080, 0x00000000,
80 0x0092c070, 0x00000000,
81 0x00924060, 0x00000100,
82 0x0000c890, 0x00005000,
83 0x00a6c110, 0x00000000,
84 0x00b0c090, 0x00000012,
85 0x021c0015, 0x00000000,
86 0x3200001f, 0x00000034,
87 0x00924460, 0x00000510,
88 0x44210011, 0x00000000,
89 0x42000011, 0x00000000,
90 0x83000015, 0x00000040,
91 0x00924460, 0x00000508,
92 0x45014018, 0x00004545,
93 0x00808050, 0x00000000,
94 0x62208012, 0x00000000,
95 0x82000015, 0x00000800,
96 0x15200011, 0x00000000,
97 0x00000010, 0x00000000,
98 0x00000010, 0x00000000,
99 0x00000010, 0x00000000,
100 0x00000010, 0x00000000,
101 0x00000010, 0x00000000,
102 0x80000015, 0x0000eea4,
103 0x81000015, 0x0000005f,
104 0x00000060, 0x00000000,
105 0x00004120, 0x00000000,
106 0x00004a00, 0x00004000,
107 0x00924460, 0x00000190,
108 0x5601401a, 0x00005956,
109 0x14000011, 0x00000000,
110 0x00934050, 0x00000018,
111 0x00930050, 0x00000018,
112 0x3601403a, 0x0000002d,
113 0x000643a9, 0x00000000,
114 0x0000c420, 0x00000140,
115 0x5601401a, 0x00005956,
116 0x14000011, 0x00000000,
117 0x00000010, 0x00000000,
118 0x00000010, 0x00000000,
119 0x000642a9, 0x00000000,
120 0x00024420, 0x00000183,
121 0x5601401a, 0x00005956,
122 0x82000015, 0x00002000,
123 0x15200011, 0x00000000,
124 0x82000015, 0x00000010,
125 0x15200011, 0x00000000,
126 0x82000015, 0x00000010,
127 0x15200011, 0x00000000,
128}; /* 104 Rx instructions */
129#define FIRMWARE_RX_SIZE 104
130
131static const u32 firmware_tx[] = {
132 0x010003dc, 0x00000000,
133 0x04000421, 0x00000086,
134 0x80000015, 0x0000180e,
135 0x81000015, 0x00006664,
136 0x1a0040ab, 0x00000b06,
137 0x14200011, 0x00000000,
138 0x14204022, 0x0000aaaa,
139 0x14204022, 0x00000300,
140 0x14204022, 0x00000000,
141 0x1a0040ab, 0x00000b14,
142 0x14200011, 0x00000000,
143 0x83000015, 0x00000002,
144 0x04000021, 0x00000000,
145 0x00000010, 0x00000000,
146 0x04000421, 0x00000087,
147 0x00000010, 0x00000000,
148 0x00000010, 0x00000000,
149 0x00008015, 0x00000000,
150 0x0000003e, 0x00000000,
151 0x00000010, 0x00000000,
152 0x82000015, 0x00004000,
153 0x009e8050, 0x00000000,
154 0x03008015, 0x00000000,
155 0x86008015, 0x00000000,
156 0x82000015, 0x00008000,
157 0x0100001c, 0x00000000,
158 0x000050a0, 0x0000010c,
159 0x4e20d011, 0x00006008,
160 0x1420d012, 0x00004008,
161 0x0000f090, 0x00007000,
162 0x0000c8b0, 0x00003000,
163 0x00004040, 0x00000000,
164 0x00108015, 0x00000000,
165 0x00a2c150, 0x00004000,
166 0x00a400b0, 0x00000014,
167 0x00000020, 0x00000000,
168 0x2500400d, 0x00002525,
169 0x00047220, 0x00003100,
170 0x00934070, 0x00000000,
171 0x00000020, 0x00000000,
172 0x00924460, 0x00000184,
173 0x2b20c011, 0x00000000,
174 0x0000c420, 0x00000540,
175 0x36014018, 0x0000422d,
176 0x14200011, 0x00000000,
177 0x00924460, 0x00000183,
178 0x3200001f, 0x00000034,
179 0x02ac0015, 0x00000002,
180 0x00a60110, 0x00000008,
181 0x42200011, 0x00000000,
182 0x00924060, 0x00000103,
183 0x0000001e, 0x00000000,
184 0x00000020, 0x00000100,
185 0x0000001e, 0x00000000,
186 0x00924460, 0x00000086,
187 0x00004080, 0x00000000,
188 0x0092c070, 0x00000000,
189 0x00924060, 0x00000100,
190 0x0000c890, 0x00005000,
191 0x00a6c110, 0x00000000,
192 0x00b0c090, 0x00000012,
193 0x021c0015, 0x00000000,
194 0x3200001f, 0x00000034,
195 0x00924460, 0x00000510,
196 0x44210011, 0x00000000,
197 0x42000011, 0x00000000,
198 0x83000015, 0x00000040,
199 0x00924460, 0x00000508,
200 0x45014018, 0x00004545,
201 0x00808050, 0x00000000,
202 0x62208012, 0x00000000,
203 0x82000015, 0x00000800,
204 0x15200011, 0x00000000,
205 0x00000010, 0x00000000,
206 0x00000010, 0x00000000,
207 0x00000010, 0x00000000,
208 0x00000010, 0x00000000,
209 0x00000010, 0x00000000,
210 0x80000015, 0x0000eea4,
211 0x81000015, 0x0000005f,
212 0x00000060, 0x00000000,
213 0x00004120, 0x00000000,
214 0x00004a00, 0x00004000,
215 0x00924460, 0x00000190,
216 0x5601401a, 0x00005956,
217 0x14000011, 0x00000000,
218 0x00934050, 0x00000018,
219 0x00930050, 0x00000018,
220 0x3601403a, 0x0000002d,
221 0x000643a9, 0x00000000,
222 0x0000c420, 0x00000140,
223 0x5601401a, 0x00005956,
224 0x14000011, 0x00000000,
225 0x00000010, 0x00000000,
226 0x00000010, 0x00000000,
227 0x000642a9, 0x00000000,
228 0x00024420, 0x00000183,
229 0x5601401a, 0x00005956,
230 0x82000015, 0x00002000,
231 0x15200011, 0x00000000,
232 0x82000015, 0x00000010,
233 0x15200011, 0x00000000,
234 0x82000015, 0x00000010,
235 0x15200011, 0x00000000,
236}; /* 104 Tx instructions */
237#define FIRMWARE_TX_SIZE 104
238#if 0
239static const u32 firmware_wol[] = {
240 0x010003dc, 0x00000000,
241 0x19000421, 0x00000087,
242 0x80000015, 0x00001a1a,
243 0x81000015, 0x00001a1a,
244 0x1a0040ab, 0x00000b06,
245 0x15200011, 0x00000000,
246 0x15204022, 0x0000aaaa,
247 0x15204022, 0x00000300,
248 0x15204022, 0x00000000,
249 0x1a0040ab, 0x00000b15,
250 0x15200011, 0x00000000,
251 0x83000015, 0x00000002,
252 0x04000021, 0x00000000,
253 0x00000010, 0x00000000,
254 0x04000421, 0x00000087,
255 0x00000010, 0x00000000,
256 0x00000010, 0x00000000,
257 0x00008015, 0x00000000,
258 0x0000003e, 0x00000000,
259 0x00000010, 0x00000000,
260 0x00000010, 0x00000000,
261 0x82000015, 0x00004000,
262 0x82000015, 0x00008000,
263 0x0000000c, 0x00000000,
264 0x00000010, 0x00000000,
265 0x00004080, 0x00000100,
266 0x1f20c011, 0x00001122,
267 0x2720f011, 0x00003011,
268 0x19200071, 0x00000000,
269 0x1a200051, 0x00000000,
270 0x00000010, 0x00000000,
271 0x00000010, 0x00000000,
272 0x1d2040a4, 0x00003344,
273 0x1d2040a2, 0x00005566,
274 0x000040a0, 0x00000100,
275 0x00108050, 0x00000001,
276 0x1a208012, 0x00000006,
277 0x82000015, 0x00008080,
278 0x010003dc, 0x00000000,
279 0x1d2040a4, 0x00002233,
280 0x1d2040a4, 0x00004455,
281 0x2d208011, 0x00000005,
282 0x1d2040a4, 0x00006611,
283 0x00108050, 0x00000001,
284 0x27200011, 0x00000000,
285 0x1d2050a4, 0x00006600,
286 0x82000015, 0x00008080,
287 0x010003dc, 0x00000000,
288 0x00000050, 0x00000000,
289 0x1b200031, 0x00000000,
290 0x0000001e, 0x00000000,
291 0x0000001e, 0x00000000,
292 0x0000001e, 0x00000000,
293 0x0000001e, 0x00000000,
294 0x00924460, 0x00000086,
295 0x00004080, 0x00000000,
296 0x0092c070, 0x00000000,
297 0x00924060, 0x00000100,
298 0x0000c890, 0x00005000,
299 0x00a6c110, 0x00000000,
300 0x00b0c090, 0x00000012,
301 0x021c0015, 0x00000000,
302 0x3200001f, 0x00000034,
303 0x00924460, 0x00000510,
304 0x44210011, 0x00000000,
305 0x42000011, 0x00000000,
306 0x83000015, 0x00000040,
307 0x00924460, 0x00000508,
308 0x476a0012, 0x00000100,
309 0x83000015, 0x00000008,
310 0x16200011, 0x00000000,
311 0x001e8050, 0x00000000,
312 0x001e8050, 0x00000000,
313 0x00808050, 0x00000000,
314 0x03008015, 0x00000000,
315 0x62208012, 0x00000000,
316 0x82000015, 0x00000800,
317 0x16200011, 0x00000000,
318 0x80000015, 0x0000eea4,
319 0x81000015, 0x0000005f,
320 0x00000020, 0x00000000,
321 0x00004120, 0x00000000,
322 0x00004a00, 0x00004000,
323 0x00924460, 0x00000190,
324 0x5c01401a, 0x0000595c,
325 0x15000011, 0x00000000,
326 0x00934050, 0x00000018,
327 0x00930050, 0x00000018,
328 0x3601403a, 0x0000002d,
329 0x00064029, 0x00000000,
330 0x0000c420, 0x00000140,
331 0x5c01401a, 0x0000595c,
332 0x15000011, 0x00000000,
333 0x00000010, 0x00000000,
334 0x00000010, 0x00000000,
335 0x00064029, 0x00000000,
336 0x00024420, 0x00000183,
337 0x5c01401a, 0x0000595c,
338 0x82000015, 0x00002000,
339 0x16200011, 0x00000000,
340 0x82000015, 0x00000010,
341 0x16200011, 0x00000000,
342 0x82000015, 0x00000010,
343 0x16200011, 0x00000000,
344}; /* 104 WoL instructions */
345#define FIRMWARE_WOL_SIZE 104
346#endif
diff --git a/drivers/net/starfire_firmware.pl b/drivers/net/starfire_firmware.pl
deleted file mode 100644
index 0c82b80e1074..000000000000
--- a/drivers/net/starfire_firmware.pl
+++ /dev/null
@@ -1,31 +0,0 @@
1#!/usr/bin/perl
2
3# This script can be used to generate a new starfire_firmware.h
4# from GFP_RX.DAT and GFP_TX.DAT, files included with the DDK
5# and also with the Novell drivers.
6
7open FW, "GFP_RX.DAT" || die;
8open FWH, ">starfire_firmware.h" || die;
9
10printf(FWH "static u32 firmware_rx[] = {\n");
11$counter = 0;
12while ($foo = <FW>) {
13 chomp;
14 printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4));
15 $counter++;
16}
17
18close FW;
19open FW, "GFP_TX.DAT" || die;
20
21printf(FWH "};\t/* %d Rx instructions */\n#define FIRMWARE_RX_SIZE %d\n\nstatic u32 firmware_tx[] = {\n", $counter, $counter);
22$counter = 0;
23while ($foo = <FW>) {
24 chomp;
25 printf(FWH " 0x%s, 0x0000%s,\n", substr($foo, 4, 8), substr($foo, 0, 4));
26 $counter++;
27}
28
29close FW;
30printf(FWH "};\t/* %d Tx instructions */\n#define FIRMWARE_TX_SIZE %d\n", $counter, $counter);
31close(FWH);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 04ae1e86aeaa..5e2dbaee125b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -40,6 +40,7 @@
40#include <linux/workqueue.h> 40#include <linux/workqueue.h>
41#include <linux/prefetch.h> 41#include <linux/prefetch.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/firmware.h>
43 44
44#include <net/checksum.h> 45#include <net/checksum.h>
45#include <net/ip.h> 46#include <net/ip.h>
@@ -137,6 +138,10 @@
137 138
138#define TG3_NUM_TEST 6 139#define TG3_NUM_TEST 6
139 140
141#define FIRMWARE_TG3 "tigon/tg3.bin"
142#define FIRMWARE_TG3TSO "tigon/tg3_tso.bin"
143#define FIRMWARE_TG3TSO5 "tigon/tg3_tso5.bin"
144
140static char version[] __devinitdata = 145static char version[] __devinitdata =
141 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 146 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
142 147
@@ -144,6 +149,10 @@ MODULE_AUTHOR("David S. Miller (davem@redhat.com) and Jeff Garzik (jgarzik@pobox
144MODULE_DESCRIPTION("Broadcom Tigon3 ethernet driver"); 149MODULE_DESCRIPTION("Broadcom Tigon3 ethernet driver");
145MODULE_LICENSE("GPL"); 150MODULE_LICENSE("GPL");
146MODULE_VERSION(DRV_MODULE_VERSION); 151MODULE_VERSION(DRV_MODULE_VERSION);
152MODULE_FIRMWARE(FIRMWARE_TG3);
153MODULE_FIRMWARE(FIRMWARE_TG3TSO);
154MODULE_FIRMWARE(FIRMWARE_TG3TSO5);
155
147 156
148static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */ 157static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */
149module_param(tg3_debug, int, 0); 158module_param(tg3_debug, int, 0);
@@ -6205,130 +6214,6 @@ static int tg3_halt(struct tg3 *tp, int kind, int silent)
6205 return 0; 6214 return 0;
6206} 6215}
6207 6216
6208#define TG3_FW_RELEASE_MAJOR 0x0
6209#define TG3_FW_RELASE_MINOR 0x0
6210#define TG3_FW_RELEASE_FIX 0x0
6211#define TG3_FW_START_ADDR 0x08000000
6212#define TG3_FW_TEXT_ADDR 0x08000000
6213#define TG3_FW_TEXT_LEN 0x9c0
6214#define TG3_FW_RODATA_ADDR 0x080009c0
6215#define TG3_FW_RODATA_LEN 0x60
6216#define TG3_FW_DATA_ADDR 0x08000a40
6217#define TG3_FW_DATA_LEN 0x20
6218#define TG3_FW_SBSS_ADDR 0x08000a60
6219#define TG3_FW_SBSS_LEN 0xc
6220#define TG3_FW_BSS_ADDR 0x08000a70
6221#define TG3_FW_BSS_LEN 0x10
6222
6223static const u32 tg3FwText[(TG3_FW_TEXT_LEN / sizeof(u32)) + 1] = {
6224 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c1d0800,
6225 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100000, 0x0e000018, 0x00000000,
6226 0x0000000d, 0x3c1d0800, 0x37bd3ffc, 0x03a0f021, 0x3c100800, 0x26100034,
6227 0x0e00021c, 0x00000000, 0x0000000d, 0x00000000, 0x00000000, 0x00000000,
6228 0x27bdffe0, 0x3c1cc000, 0xafbf0018, 0xaf80680c, 0x0e00004c, 0x241b2105,
6229 0x97850000, 0x97870002, 0x9782002c, 0x9783002e, 0x3c040800, 0x248409c0,
6230 0xafa00014, 0x00021400, 0x00621825, 0x00052c00, 0xafa30010, 0x8f860010,
6231 0x00e52825, 0x0e000060, 0x24070102, 0x3c02ac00, 0x34420100, 0x3c03ac01,
6232 0x34630100, 0xaf820490, 0x3c02ffff, 0xaf820494, 0xaf830498, 0xaf82049c,
6233 0x24020001, 0xaf825ce0, 0x0e00003f, 0xaf825d00, 0x0e000140, 0x00000000,
6234 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x2402ffff, 0xaf825404, 0x8f835400,
6235 0x34630400, 0xaf835400, 0xaf825404, 0x3c020800, 0x24420034, 0xaf82541c,
6236 0x03e00008, 0xaf805400, 0x00000000, 0x00000000, 0x3c020800, 0x34423000,
6237 0x3c030800, 0x34633000, 0x3c040800, 0x348437ff, 0x3c010800, 0xac220a64,
6238 0x24020040, 0x3c010800, 0xac220a68, 0x3c010800, 0xac200a60, 0xac600000,
6239 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
6240 0x00804821, 0x8faa0010, 0x3c020800, 0x8c420a60, 0x3c040800, 0x8c840a68,
6241 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010800, 0xac230a60, 0x14400003,
6242 0x00004021, 0x3c010800, 0xac200a60, 0x3c020800, 0x8c420a60, 0x3c030800,
6243 0x8c630a64, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
6244 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020800, 0x8c420a60,
6245 0x3c030800, 0x8c630a64, 0x8f84680c, 0x00021140, 0x00431021, 0xac440008,
6246 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
6247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6248 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6249 0, 0, 0, 0, 0, 0,
6250 0x02000008, 0x00000000, 0x0a0001e3, 0x3c0a0001, 0x0a0001e3, 0x3c0a0002,
6251 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6252 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6253 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6254 0x0a0001e3, 0x3c0a0007, 0x0a0001e3, 0x3c0a0008, 0x0a0001e3, 0x3c0a0009,
6255 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a000b,
6256 0x0a0001e3, 0x3c0a000c, 0x0a0001e3, 0x3c0a000d, 0x0a0001e3, 0x00000000,
6257 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a000e, 0x0a0001e3, 0x00000000,
6258 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6259 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x00000000,
6260 0x0a0001e3, 0x00000000, 0x0a0001e3, 0x3c0a0013, 0x0a0001e3, 0x3c0a0014,
6261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6264 0x27bdffe0, 0x00001821, 0x00001021, 0xafbf0018, 0xafb10014, 0xafb00010,
6265 0x3c010800, 0x00220821, 0xac200a70, 0x3c010800, 0x00220821, 0xac200a74,
6266 0x3c010800, 0x00220821, 0xac200a78, 0x24630001, 0x1860fff5, 0x2442000c,
6267 0x24110001, 0x8f906810, 0x32020004, 0x14400005, 0x24040001, 0x3c020800,
6268 0x8c420a78, 0x18400003, 0x00002021, 0x0e000182, 0x00000000, 0x32020001,
6269 0x10400003, 0x00000000, 0x0e000169, 0x00000000, 0x0a000153, 0xaf915028,
6270 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c050800,
6271 0x8ca50a70, 0x3c060800, 0x8cc60a80, 0x3c070800, 0x8ce70a78, 0x27bdffe0,
6272 0x3c040800, 0x248409d0, 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014,
6273 0x0e00017b, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x24020001,
6274 0x8f836810, 0x00821004, 0x00021027, 0x00621824, 0x03e00008, 0xaf836810,
6275 0x27bdffd8, 0xafbf0024, 0x1080002e, 0xafb00020, 0x8f825cec, 0xafa20018,
6276 0x8f825cec, 0x3c100800, 0x26100a78, 0xafa2001c, 0x34028000, 0xaf825cec,
6277 0x8e020000, 0x18400016, 0x00000000, 0x3c020800, 0x94420a74, 0x8fa3001c,
6278 0x000221c0, 0xac830004, 0x8fa2001c, 0x3c010800, 0x0e000201, 0xac220a74,
6279 0x10400005, 0x00000000, 0x8e020000, 0x24420001, 0x0a0001df, 0xae020000,
6280 0x3c020800, 0x8c420a70, 0x00021c02, 0x000321c0, 0x0a0001c5, 0xafa2001c,
6281 0x0e000201, 0x00000000, 0x1040001f, 0x00000000, 0x8e020000, 0x8fa3001c,
6282 0x24420001, 0x3c010800, 0xac230a70, 0x3c010800, 0xac230a74, 0x0a0001df,
6283 0xae020000, 0x3c100800, 0x26100a78, 0x8e020000, 0x18400028, 0x00000000,
6284 0x0e000201, 0x00000000, 0x14400024, 0x00000000, 0x8e020000, 0x3c030800,
6285 0x8c630a70, 0x2442ffff, 0xafa3001c, 0x18400006, 0xae020000, 0x00031402,
6286 0x000221c0, 0x8c820004, 0x3c010800, 0xac220a70, 0x97a2001e, 0x2442ff00,
6287 0x2c420300, 0x1440000b, 0x24024000, 0x3c040800, 0x248409dc, 0xafa00010,
6288 0xafa00014, 0x8fa6001c, 0x24050008, 0x0e000060, 0x00003821, 0x0a0001df,
6289 0x00000000, 0xaf825cf8, 0x3c020800, 0x8c420a40, 0x8fa3001c, 0x24420001,
6290 0xaf835cf8, 0x3c010800, 0xac220a40, 0x8fbf0024, 0x8fb00020, 0x03e00008,
6291 0x27bd0028, 0x27bdffe0, 0x3c040800, 0x248409e8, 0x00002821, 0x00003021,
6292 0x00003821, 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014, 0x8fbf0018,
6293 0x03e00008, 0x27bd0020, 0x8f82680c, 0x8f85680c, 0x00021827, 0x0003182b,
6294 0x00031823, 0x00431024, 0x00441021, 0x00a2282b, 0x10a00006, 0x00000000,
6295 0x00401821, 0x8f82680c, 0x0043102b, 0x1440fffd, 0x00000000, 0x03e00008,
6296 0x00000000, 0x3c040800, 0x8c840000, 0x3c030800, 0x8c630a40, 0x0064102b,
6297 0x54400002, 0x00831023, 0x00641023, 0x2c420008, 0x03e00008, 0x38420001,
6298 0x27bdffe0, 0x00802821, 0x3c040800, 0x24840a00, 0x00003021, 0x00003821,
6299 0xafbf0018, 0xafa00010, 0x0e000060, 0xafa00014, 0x0a000216, 0x00000000,
6300 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000, 0x27bdffe0, 0x3c1cc000,
6301 0xafbf0018, 0x0e00004c, 0xaf80680c, 0x3c040800, 0x24840a10, 0x03802821,
6302 0x00003021, 0x00003821, 0xafa00010, 0x0e000060, 0xafa00014, 0x2402ffff,
6303 0xaf825404, 0x3c0200aa, 0x0e000234, 0xaf825434, 0x8fbf0018, 0x03e00008,
6304 0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe8, 0xafb00010,
6305 0x24100001, 0xafbf0014, 0x3c01c003, 0xac200000, 0x8f826810, 0x30422000,
6306 0x10400003, 0x00000000, 0x0e000246, 0x00000000, 0x0a00023a, 0xaf905428,
6307 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdfff8, 0x8f845d0c,
6308 0x3c0200ff, 0x3c030800, 0x8c630a50, 0x3442fff8, 0x00821024, 0x1043001e,
6309 0x3c0500ff, 0x34a5fff8, 0x3c06c003, 0x3c074000, 0x00851824, 0x8c620010,
6310 0x3c010800, 0xac230a50, 0x30420008, 0x10400005, 0x00871025, 0x8cc20000,
6311 0x24420001, 0xacc20000, 0x00871025, 0xaf825d0c, 0x8fa20000, 0x24420001,
6312 0xafa20000, 0x8fa20000, 0x8fa20000, 0x24420001, 0xafa20000, 0x8fa20000,
6313 0x8f845d0c, 0x3c030800, 0x8c630a50, 0x00851024, 0x1443ffe8, 0x00851824,
6314 0x27bd0008, 0x03e00008, 0x00000000, 0x00000000, 0x00000000
6315};
6316
6317static const u32 tg3FwRodata[(TG3_FW_RODATA_LEN / sizeof(u32)) + 1] = {
6318 0x35373031, 0x726c7341, 0x00000000, 0x00000000, 0x53774576, 0x656e7430,
6319 0x00000000, 0x726c7045, 0x76656e74, 0x31000000, 0x556e6b6e, 0x45766e74,
6320 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
6321 0x00000000, 0x00000000, 0x4d61696e, 0x43707542, 0x00000000, 0x00000000,
6322 0x00000000
6323};
6324
6325#if 0 /* All zeros, don't eat up space with it. */
6326u32 tg3FwData[(TG3_FW_DATA_LEN / sizeof(u32)) + 1] = {
6327 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
6328 0x00000000, 0x00000000, 0x00000000, 0x00000000
6329};
6330#endif
6331
6332#define RX_CPU_SCRATCH_BASE 0x30000 6217#define RX_CPU_SCRATCH_BASE 0x30000
6333#define RX_CPU_SCRATCH_SIZE 0x04000 6218#define RX_CPU_SCRATCH_SIZE 0x04000
6334#define TX_CPU_SCRATCH_BASE 0x34000 6219#define TX_CPU_SCRATCH_BASE 0x34000
@@ -6383,15 +6268,9 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
6383} 6268}
6384 6269
6385struct fw_info { 6270struct fw_info {
6386 unsigned int text_base; 6271 unsigned int fw_base;
6387 unsigned int text_len; 6272 unsigned int fw_len;
6388 const u32 *text_data; 6273 const __be32 *fw_data;
6389 unsigned int rodata_base;
6390 unsigned int rodata_len;
6391 const u32 *rodata_data;
6392 unsigned int data_base;
6393 unsigned int data_len;
6394 const u32 *data_data;
6395}; 6274};
6396 6275
6397/* tp->lock is held. */ 6276/* tp->lock is held. */
@@ -6428,24 +6307,11 @@ static int tg3_load_firmware_cpu(struct tg3 *tp, u32 cpu_base, u32 cpu_scratch_b
6428 write_op(tp, cpu_scratch_base + i, 0); 6307 write_op(tp, cpu_scratch_base + i, 0);
6429 tw32(cpu_base + CPU_STATE, 0xffffffff); 6308 tw32(cpu_base + CPU_STATE, 0xffffffff);
6430 tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT); 6309 tw32(cpu_base + CPU_MODE, tr32(cpu_base+CPU_MODE)|CPU_MODE_HALT);
6431 for (i = 0; i < (info->text_len / sizeof(u32)); i++) 6310 for (i = 0; i < (info->fw_len / sizeof(u32)); i++)
6432 write_op(tp, (cpu_scratch_base +
6433 (info->text_base & 0xffff) +
6434 (i * sizeof(u32))),
6435 (info->text_data ?
6436 info->text_data[i] : 0));
6437 for (i = 0; i < (info->rodata_len / sizeof(u32)); i++)
6438 write_op(tp, (cpu_scratch_base +
6439 (info->rodata_base & 0xffff) +
6440 (i * sizeof(u32))),
6441 (info->rodata_data ?
6442 info->rodata_data[i] : 0));
6443 for (i = 0; i < (info->data_len / sizeof(u32)); i++)
6444 write_op(tp, (cpu_scratch_base + 6311 write_op(tp, (cpu_scratch_base +
6445 (info->data_base & 0xffff) + 6312 (info->fw_base & 0xffff) +
6446 (i * sizeof(u32))), 6313 (i * sizeof(u32))),
6447 (info->data_data ? 6314 be32_to_cpu(info->fw_data[i]));
6448 info->data_data[i] : 0));
6449 6315
6450 err = 0; 6316 err = 0;
6451 6317
@@ -6457,17 +6323,20 @@ out:
6457static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp) 6323static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6458{ 6324{
6459 struct fw_info info; 6325 struct fw_info info;
6326 const __be32 *fw_data;
6460 int err, i; 6327 int err, i;
6461 6328
6462 info.text_base = TG3_FW_TEXT_ADDR; 6329 fw_data = (void *)tp->fw->data;
6463 info.text_len = TG3_FW_TEXT_LEN; 6330
6464 info.text_data = &tg3FwText[0]; 6331 /* Firmware blob starts with version numbers, followed by
6465 info.rodata_base = TG3_FW_RODATA_ADDR; 6332 start address and length. We are setting complete length.
6466 info.rodata_len = TG3_FW_RODATA_LEN; 6333 length = end_address_of_bss - start_address_of_text.
6467 info.rodata_data = &tg3FwRodata[0]; 6334 Remainder is the blob to be loaded contiguously
6468 info.data_base = TG3_FW_DATA_ADDR; 6335 from start address. */
6469 info.data_len = TG3_FW_DATA_LEN; 6336
6470 info.data_data = NULL; 6337 info.fw_base = be32_to_cpu(fw_data[1]);
6338 info.fw_len = tp->fw->size - 12;
6339 info.fw_data = &fw_data[3];
6471 6340
6472 err = tg3_load_firmware_cpu(tp, RX_CPU_BASE, 6341 err = tg3_load_firmware_cpu(tp, RX_CPU_BASE,
6473 RX_CPU_SCRATCH_BASE, RX_CPU_SCRATCH_SIZE, 6342 RX_CPU_SCRATCH_BASE, RX_CPU_SCRATCH_SIZE,
@@ -6483,21 +6352,21 @@ static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6483 6352
6484 /* Now startup only the RX cpu. */ 6353 /* Now startup only the RX cpu. */
6485 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6354 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
6486 tw32_f(RX_CPU_BASE + CPU_PC, TG3_FW_TEXT_ADDR); 6355 tw32_f(RX_CPU_BASE + CPU_PC, info.fw_base);
6487 6356
6488 for (i = 0; i < 5; i++) { 6357 for (i = 0; i < 5; i++) {
6489 if (tr32(RX_CPU_BASE + CPU_PC) == TG3_FW_TEXT_ADDR) 6358 if (tr32(RX_CPU_BASE + CPU_PC) == info.fw_base)
6490 break; 6359 break;
6491 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6360 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
6492 tw32(RX_CPU_BASE + CPU_MODE, CPU_MODE_HALT); 6361 tw32(RX_CPU_BASE + CPU_MODE, CPU_MODE_HALT);
6493 tw32_f(RX_CPU_BASE + CPU_PC, TG3_FW_TEXT_ADDR); 6362 tw32_f(RX_CPU_BASE + CPU_PC, info.fw_base);
6494 udelay(1000); 6363 udelay(1000);
6495 } 6364 }
6496 if (i >= 5) { 6365 if (i >= 5) {
6497 printk(KERN_ERR PFX "tg3_load_firmware fails for %s " 6366 printk(KERN_ERR PFX "tg3_load_firmware fails for %s "
6498 "to set RX CPU PC, is %08x should be %08x\n", 6367 "to set RX CPU PC, is %08x should be %08x\n",
6499 tp->dev->name, tr32(RX_CPU_BASE + CPU_PC), 6368 tp->dev->name, tr32(RX_CPU_BASE + CPU_PC),
6500 TG3_FW_TEXT_ADDR); 6369 info.fw_base);
6501 return -ENODEV; 6370 return -ENODEV;
6502 } 6371 }
6503 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff); 6372 tw32(RX_CPU_BASE + CPU_STATE, 0xffffffff);
@@ -6506,547 +6375,36 @@ static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
6506 return 0; 6375 return 0;
6507} 6376}
6508 6377
6509
6510#define TG3_TSO_FW_RELEASE_MAJOR 0x1
6511#define TG3_TSO_FW_RELASE_MINOR 0x6
6512#define TG3_TSO_FW_RELEASE_FIX 0x0
6513#define TG3_TSO_FW_START_ADDR 0x08000000
6514#define TG3_TSO_FW_TEXT_ADDR 0x08000000
6515#define TG3_TSO_FW_TEXT_LEN 0x1aa0
6516#define TG3_TSO_FW_RODATA_ADDR 0x08001aa0
6517#define TG3_TSO_FW_RODATA_LEN 0x60
6518#define TG3_TSO_FW_DATA_ADDR 0x08001b20
6519#define TG3_TSO_FW_DATA_LEN 0x30
6520#define TG3_TSO_FW_SBSS_ADDR 0x08001b50
6521#define TG3_TSO_FW_SBSS_LEN 0x2c
6522#define TG3_TSO_FW_BSS_ADDR 0x08001b80
6523#define TG3_TSO_FW_BSS_LEN 0x894
6524
6525static const u32 tg3TsoFwText[(TG3_TSO_FW_TEXT_LEN / 4) + 1] = {
6526 0x0e000003, 0x00000000, 0x08001b24, 0x00000000, 0x10000003, 0x00000000,
6527 0x0000000d, 0x0000000d, 0x3c1d0800, 0x37bd4000, 0x03a0f021, 0x3c100800,
6528 0x26100000, 0x0e000010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
6529 0xafbf0018, 0x0e0005d8, 0x34840002, 0x0e000668, 0x00000000, 0x3c030800,
6530 0x90631b68, 0x24020002, 0x3c040800, 0x24841aac, 0x14620003, 0x24050001,
6531 0x3c040800, 0x24841aa0, 0x24060006, 0x00003821, 0xafa00010, 0x0e00067c,
6532 0xafa00014, 0x8f625c50, 0x34420001, 0xaf625c50, 0x8f625c90, 0x34420001,
6533 0xaf625c90, 0x2402ffff, 0x0e000034, 0xaf625404, 0x8fbf0018, 0x03e00008,
6534 0x27bd0020, 0x00000000, 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c,
6535 0xafb20018, 0xafb10014, 0x0e00005b, 0xafb00010, 0x24120002, 0x24110001,
6536 0x8f706820, 0x32020100, 0x10400003, 0x00000000, 0x0e0000bb, 0x00000000,
6537 0x8f706820, 0x32022000, 0x10400004, 0x32020001, 0x0e0001f0, 0x24040001,
6538 0x32020001, 0x10400003, 0x00000000, 0x0e0000a3, 0x00000000, 0x3c020800,
6539 0x90421b98, 0x14520003, 0x00000000, 0x0e0004c0, 0x00000000, 0x0a00003c,
6540 0xaf715028, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008,
6541 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841ac0, 0x00002821, 0x00003021,
6542 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014, 0x3c040800,
6543 0x248423d8, 0xa4800000, 0x3c010800, 0xa0201b98, 0x3c010800, 0xac201b9c,
6544 0x3c010800, 0xac201ba0, 0x3c010800, 0xac201ba4, 0x3c010800, 0xac201bac,
6545 0x3c010800, 0xac201bb8, 0x3c010800, 0xac201bbc, 0x8f624434, 0x3c010800,
6546 0xac221b88, 0x8f624438, 0x3c010800, 0xac221b8c, 0x8f624410, 0xac80f7a8,
6547 0x3c010800, 0xac201b84, 0x3c010800, 0xac2023e0, 0x3c010800, 0xac2023c8,
6548 0x3c010800, 0xac2023cc, 0x3c010800, 0xac202400, 0x3c010800, 0xac221b90,
6549 0x8f620068, 0x24030007, 0x00021702, 0x10430005, 0x00000000, 0x8f620068,
6550 0x00021702, 0x14400004, 0x24020001, 0x3c010800, 0x0a000097, 0xac20240c,
6551 0xac820034, 0x3c040800, 0x24841acc, 0x3c050800, 0x8ca5240c, 0x00003021,
6552 0x00003821, 0xafa00010, 0x0e00067c, 0xafa00014, 0x8fbf0018, 0x03e00008,
6553 0x27bd0020, 0x27bdffe0, 0x3c040800, 0x24841ad8, 0x00002821, 0x00003021,
6554 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014, 0x0e00005b,
6555 0x00000000, 0x0e0000b4, 0x00002021, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6556 0x24020001, 0x8f636820, 0x00821004, 0x00021027, 0x00621824, 0x03e00008,
6557 0xaf636820, 0x27bdffd0, 0xafbf002c, 0xafb60028, 0xafb50024, 0xafb40020,
6558 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x8f675c5c, 0x3c030800,
6559 0x24631bbc, 0x8c620000, 0x14470005, 0x3c0200ff, 0x3c020800, 0x90421b98,
6560 0x14400119, 0x3c0200ff, 0x3442fff8, 0x00e28824, 0xac670000, 0x00111902,
6561 0x306300ff, 0x30e20003, 0x000211c0, 0x00622825, 0x00a04021, 0x00071602,
6562 0x3c030800, 0x90631b98, 0x3044000f, 0x14600036, 0x00804821, 0x24020001,
6563 0x3c010800, 0xa0221b98, 0x00051100, 0x00821025, 0x3c010800, 0xac201b9c,
6564 0x3c010800, 0xac201ba0, 0x3c010800, 0xac201ba4, 0x3c010800, 0xac201bac,
6565 0x3c010800, 0xac201bb8, 0x3c010800, 0xac201bb0, 0x3c010800, 0xac201bb4,
6566 0x3c010800, 0xa42223d8, 0x9622000c, 0x30437fff, 0x3c010800, 0xa4222410,
6567 0x30428000, 0x3c010800, 0xa4231bc6, 0x10400005, 0x24020001, 0x3c010800,
6568 0xac2223f4, 0x0a000102, 0x2406003e, 0x24060036, 0x3c010800, 0xac2023f4,
6569 0x9622000a, 0x3c030800, 0x94631bc6, 0x3c010800, 0xac2023f0, 0x3c010800,
6570 0xac2023f8, 0x00021302, 0x00021080, 0x00c21021, 0x00621821, 0x3c010800,
6571 0xa42223d0, 0x3c010800, 0x0a000115, 0xa4231b96, 0x9622000c, 0x3c010800,
6572 0xa42223ec, 0x3c040800, 0x24841b9c, 0x8c820000, 0x00021100, 0x3c010800,
6573 0x00220821, 0xac311bc8, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821,
6574 0xac271bcc, 0x8c820000, 0x25030001, 0x306601ff, 0x00021100, 0x3c010800,
6575 0x00220821, 0xac261bd0, 0x8c820000, 0x00021100, 0x3c010800, 0x00220821,
6576 0xac291bd4, 0x96230008, 0x3c020800, 0x8c421bac, 0x00432821, 0x3c010800,
6577 0xac251bac, 0x9622000a, 0x30420004, 0x14400018, 0x00061100, 0x8f630c14,
6578 0x3063000f, 0x2c620002, 0x1440000b, 0x3c02c000, 0x8f630c14, 0x3c020800,
6579 0x8c421b40, 0x3063000f, 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002,
6580 0x1040fff7, 0x3c02c000, 0x00e21825, 0xaf635c5c, 0x8f625c50, 0x30420002,
6581 0x10400014, 0x00000000, 0x0a000147, 0x00000000, 0x3c030800, 0x8c631b80,
6582 0x3c040800, 0x94841b94, 0x01221025, 0x3c010800, 0xa42223da, 0x24020001,
6583 0x3c010800, 0xac221bb8, 0x24630001, 0x0085202a, 0x3c010800, 0x10800003,
6584 0xac231b80, 0x3c010800, 0xa4251b94, 0x3c060800, 0x24c61b9c, 0x8cc20000,
6585 0x24420001, 0xacc20000, 0x28420080, 0x14400005, 0x00000000, 0x0e000656,
6586 0x24040002, 0x0a0001e6, 0x00000000, 0x3c020800, 0x8c421bb8, 0x10400078,
6587 0x24020001, 0x3c050800, 0x90a51b98, 0x14a20072, 0x00000000, 0x3c150800,
6588 0x96b51b96, 0x3c040800, 0x8c841bac, 0x32a3ffff, 0x0083102a, 0x1440006c,
6589 0x00000000, 0x14830003, 0x00000000, 0x3c010800, 0xac2523f0, 0x1060005c,
6590 0x00009021, 0x24d60004, 0x0060a021, 0x24d30014, 0x8ec20000, 0x00028100,
6591 0x3c110800, 0x02308821, 0x0e000625, 0x8e311bc8, 0x00402821, 0x10a00054,
6592 0x00000000, 0x9628000a, 0x31020040, 0x10400005, 0x2407180c, 0x8e22000c,
6593 0x2407188c, 0x00021400, 0xaca20018, 0x3c030800, 0x00701821, 0x8c631bd0,
6594 0x3c020800, 0x00501021, 0x8c421bd4, 0x00031d00, 0x00021400, 0x00621825,
6595 0xaca30014, 0x8ec30004, 0x96220008, 0x00432023, 0x3242ffff, 0x3083ffff,
6596 0x00431021, 0x0282102a, 0x14400002, 0x02b23023, 0x00803021, 0x8e620000,
6597 0x30c4ffff, 0x00441021, 0xae620000, 0x8e220000, 0xaca20000, 0x8e220004,
6598 0x8e63fff4, 0x00431021, 0xaca20004, 0xa4a6000e, 0x8e62fff4, 0x00441021,
6599 0xae62fff4, 0x96230008, 0x0043102a, 0x14400005, 0x02469021, 0x8e62fff0,
6600 0xae60fff4, 0x24420001, 0xae62fff0, 0xaca00008, 0x3242ffff, 0x14540008,
6601 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x24020905, 0xa4a2000c,
6602 0x0a0001cb, 0x34e70020, 0xa4a2000c, 0x3c020800, 0x8c4223f0, 0x10400003,
6603 0x3c024b65, 0x0a0001d3, 0x34427654, 0x3c02b49a, 0x344289ab, 0xaca2001c,
6604 0x30e2ffff, 0xaca20010, 0x0e0005a2, 0x00a02021, 0x3242ffff, 0x0054102b,
6605 0x1440ffa9, 0x00000000, 0x24020002, 0x3c010800, 0x0a0001e6, 0xa0221b98,
6606 0x8ec2083c, 0x24420001, 0x0a0001e6, 0xaec2083c, 0x0e0004c0, 0x00000000,
6607 0x8fbf002c, 0x8fb60028, 0x8fb50024, 0x8fb40020, 0x8fb3001c, 0x8fb20018,
6608 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0030, 0x27bdffd0, 0xafbf0028,
6609 0xafb30024, 0xafb20020, 0xafb1001c, 0xafb00018, 0x8f725c9c, 0x3c0200ff,
6610 0x3442fff8, 0x3c070800, 0x24e71bb4, 0x02428824, 0x9623000e, 0x8ce20000,
6611 0x00431021, 0xace20000, 0x8e220010, 0x30420020, 0x14400011, 0x00809821,
6612 0x0e00063b, 0x02202021, 0x3c02c000, 0x02421825, 0xaf635c9c, 0x8f625c90,
6613 0x30420002, 0x1040011e, 0x00000000, 0xaf635c9c, 0x8f625c90, 0x30420002,
6614 0x10400119, 0x00000000, 0x0a00020d, 0x00000000, 0x8e240008, 0x8e230014,
6615 0x00041402, 0x000231c0, 0x00031502, 0x304201ff, 0x2442ffff, 0x3042007f,
6616 0x00031942, 0x30637800, 0x00021100, 0x24424000, 0x00624821, 0x9522000a,
6617 0x3084ffff, 0x30420008, 0x104000b0, 0x000429c0, 0x3c020800, 0x8c422400,
6618 0x14400024, 0x24c50008, 0x94c20014, 0x3c010800, 0xa42223d0, 0x8cc40010,
6619 0x00041402, 0x3c010800, 0xa42223d2, 0x3c010800, 0xa42423d4, 0x94c2000e,
6620 0x3083ffff, 0x00431023, 0x3c010800, 0xac222408, 0x94c2001a, 0x3c010800,
6621 0xac262400, 0x3c010800, 0xac322404, 0x3c010800, 0xac2223fc, 0x3c02c000,
6622 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000e5, 0x00000000,
6623 0xaf635c9c, 0x8f625c90, 0x30420002, 0x104000e0, 0x00000000, 0x0a000246,
6624 0x00000000, 0x94c2000e, 0x3c030800, 0x946323d4, 0x00434023, 0x3103ffff,
6625 0x2c620008, 0x1040001c, 0x00000000, 0x94c20014, 0x24420028, 0x00a22821,
6626 0x00031042, 0x1840000b, 0x00002021, 0x24e60848, 0x00403821, 0x94a30000,
6627 0x8cc20000, 0x24840001, 0x00431021, 0xacc20000, 0x0087102a, 0x1440fff9,
6628 0x24a50002, 0x31020001, 0x1040001f, 0x3c024000, 0x3c040800, 0x248423fc,
6629 0xa0a00001, 0x94a30000, 0x8c820000, 0x00431021, 0x0a000285, 0xac820000,
6630 0x8f626800, 0x3c030010, 0x00431024, 0x10400009, 0x00000000, 0x94c2001a,
6631 0x3c030800, 0x8c6323fc, 0x00431021, 0x3c010800, 0xac2223fc, 0x0a000286,
6632 0x3c024000, 0x94c2001a, 0x94c4001c, 0x3c030800, 0x8c6323fc, 0x00441023,
6633 0x00621821, 0x3c010800, 0xac2323fc, 0x3c024000, 0x02421825, 0xaf635c9c,
6634 0x8f625c90, 0x30420002, 0x1440fffc, 0x00000000, 0x9522000a, 0x30420010,
6635 0x1040009b, 0x00000000, 0x3c030800, 0x946323d4, 0x3c070800, 0x24e72400,
6636 0x8ce40000, 0x8f626800, 0x24630030, 0x00832821, 0x3c030010, 0x00431024,
6637 0x1440000a, 0x00000000, 0x94a20004, 0x3c040800, 0x8c842408, 0x3c030800,
6638 0x8c6323fc, 0x00441023, 0x00621821, 0x3c010800, 0xac2323fc, 0x3c040800,
6639 0x8c8423fc, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402, 0x00822021,
6640 0x00041027, 0xa4a20006, 0x3c030800, 0x8c632404, 0x3c0200ff, 0x3442fff8,
6641 0x00628824, 0x96220008, 0x24050001, 0x24034000, 0x000231c0, 0x00801021,
6642 0xa4c2001a, 0xa4c0001c, 0xace00000, 0x3c010800, 0xac251b60, 0xaf635cb8,
6643 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000, 0x3c010800, 0xac201b60,
6644 0x8e220008, 0xaf625cb8, 0x8f625cb0, 0x30420002, 0x10400003, 0x00000000,
6645 0x3c010800, 0xac201b60, 0x3c020800, 0x8c421b60, 0x1040ffec, 0x00000000,
6646 0x3c040800, 0x0e00063b, 0x8c842404, 0x0a00032a, 0x00000000, 0x3c030800,
6647 0x90631b98, 0x24020002, 0x14620003, 0x3c034b65, 0x0a0002e1, 0x00008021,
6648 0x8e22001c, 0x34637654, 0x10430002, 0x24100002, 0x24100001, 0x00c02021,
6649 0x0e000350, 0x02003021, 0x24020003, 0x3c010800, 0xa0221b98, 0x24020002,
6650 0x1202000a, 0x24020001, 0x3c030800, 0x8c6323f0, 0x10620006, 0x00000000,
6651 0x3c020800, 0x944223d8, 0x00021400, 0x0a00031f, 0xae220014, 0x3c040800,
6652 0x248423da, 0x94820000, 0x00021400, 0xae220014, 0x3c020800, 0x8c421bbc,
6653 0x3c03c000, 0x3c010800, 0xa0201b98, 0x00431025, 0xaf625c5c, 0x8f625c50,
6654 0x30420002, 0x10400009, 0x00000000, 0x2484f7e2, 0x8c820000, 0x00431025,
6655 0xaf625c5c, 0x8f625c50, 0x30420002, 0x1440fffa, 0x00000000, 0x3c020800,
6656 0x24421b84, 0x8c430000, 0x24630001, 0xac430000, 0x8f630c14, 0x3063000f,
6657 0x2c620002, 0x1440000c, 0x3c024000, 0x8f630c14, 0x3c020800, 0x8c421b40,
6658 0x3063000f, 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002, 0x1040fff7,
6659 0x00000000, 0x3c024000, 0x02421825, 0xaf635c9c, 0x8f625c90, 0x30420002,
6660 0x1440fffc, 0x00000000, 0x12600003, 0x00000000, 0x0e0004c0, 0x00000000,
6661 0x8fbf0028, 0x8fb30024, 0x8fb20020, 0x8fb1001c, 0x8fb00018, 0x03e00008,
6662 0x27bd0030, 0x8f634450, 0x3c040800, 0x24841b88, 0x8c820000, 0x00031c02,
6663 0x0043102b, 0x14400007, 0x3c038000, 0x8c840004, 0x8f624450, 0x00021c02,
6664 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024,
6665 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3c024000,
6666 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00000000,
6667 0x03e00008, 0x00000000, 0x27bdffe0, 0x00805821, 0x14c00011, 0x256e0008,
6668 0x3c020800, 0x8c4223f4, 0x10400007, 0x24020016, 0x3c010800, 0xa42223d2,
6669 0x2402002a, 0x3c010800, 0x0a000364, 0xa42223d4, 0x8d670010, 0x00071402,
6670 0x3c010800, 0xa42223d2, 0x3c010800, 0xa42723d4, 0x3c040800, 0x948423d4,
6671 0x3c030800, 0x946323d2, 0x95cf0006, 0x3c020800, 0x944223d0, 0x00832023,
6672 0x01e2c023, 0x3065ffff, 0x24a20028, 0x01c24821, 0x3082ffff, 0x14c0001a,
6673 0x01226021, 0x9582000c, 0x3042003f, 0x3c010800, 0xa42223d6, 0x95820004,
6674 0x95830006, 0x3c010800, 0xac2023e4, 0x3c010800, 0xac2023e8, 0x00021400,
6675 0x00431025, 0x3c010800, 0xac221bc0, 0x95220004, 0x3c010800, 0xa4221bc4,
6676 0x95230002, 0x01e51023, 0x0043102a, 0x10400010, 0x24020001, 0x3c010800,
6677 0x0a000398, 0xac2223f8, 0x3c030800, 0x8c6323e8, 0x3c020800, 0x94421bc4,
6678 0x00431021, 0xa5220004, 0x3c020800, 0x94421bc0, 0xa5820004, 0x3c020800,
6679 0x8c421bc0, 0xa5820006, 0x3c020800, 0x8c4223f0, 0x3c0d0800, 0x8dad23e4,
6680 0x3c0a0800, 0x144000e5, 0x8d4a23e8, 0x3c020800, 0x94421bc4, 0x004a1821,
6681 0x3063ffff, 0x0062182b, 0x24020002, 0x10c2000d, 0x01435023, 0x3c020800,
6682 0x944223d6, 0x30420009, 0x10400008, 0x00000000, 0x9582000c, 0x3042fff6,
6683 0xa582000c, 0x3c020800, 0x944223d6, 0x30420009, 0x01a26823, 0x3c020800,
6684 0x8c4223f8, 0x1040004a, 0x01203821, 0x3c020800, 0x944223d2, 0x00004021,
6685 0xa520000a, 0x01e21023, 0xa5220002, 0x3082ffff, 0x00021042, 0x18400008,
6686 0x00003021, 0x00401821, 0x94e20000, 0x25080001, 0x00c23021, 0x0103102a,
6687 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff, 0x00623021, 0x00061402,
6688 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a, 0x00003021, 0x2527000c,
6689 0x00004021, 0x94e20000, 0x25080001, 0x00c23021, 0x2d020004, 0x1440fffb,
6690 0x24e70002, 0x95220002, 0x00004021, 0x91230009, 0x00442023, 0x01803821,
6691 0x3082ffff, 0xa4e00010, 0x00621821, 0x00021042, 0x18400010, 0x00c33021,
6692 0x00404821, 0x94e20000, 0x24e70002, 0x00c23021, 0x30e2007f, 0x14400006,
6693 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80, 0x00625824, 0x25670008,
6694 0x0109102a, 0x1440fff3, 0x00000000, 0x30820001, 0x10400005, 0x00061c02,
6695 0xa0e00001, 0x94e20000, 0x00c23021, 0x00061c02, 0x30c2ffff, 0x00623021,
6696 0x00061402, 0x00c23021, 0x0a00047d, 0x30c6ffff, 0x24020002, 0x14c20081,
6697 0x00000000, 0x3c020800, 0x8c42240c, 0x14400007, 0x00000000, 0x3c020800,
6698 0x944223d2, 0x95230002, 0x01e21023, 0x10620077, 0x00000000, 0x3c020800,
6699 0x944223d2, 0x01e21023, 0xa5220002, 0x3c020800, 0x8c42240c, 0x1040001a,
6700 0x31e3ffff, 0x8dc70010, 0x3c020800, 0x94421b96, 0x00e04021, 0x00072c02,
6701 0x00aa2021, 0x00431023, 0x00823823, 0x00072402, 0x30e2ffff, 0x00823821,
6702 0x00071027, 0xa522000a, 0x3102ffff, 0x3c040800, 0x948423d4, 0x00453023,
6703 0x00e02821, 0x00641823, 0x006d1821, 0x00c33021, 0x00061c02, 0x30c2ffff,
6704 0x0a00047d, 0x00623021, 0x01203821, 0x00004021, 0x3082ffff, 0x00021042,
6705 0x18400008, 0x00003021, 0x00401821, 0x94e20000, 0x25080001, 0x00c23021,
6706 0x0103102a, 0x1440fffb, 0x24e70002, 0x00061c02, 0x30c2ffff, 0x00623021,
6707 0x00061402, 0x00c23021, 0x00c02821, 0x00061027, 0xa522000a, 0x00003021,
6708 0x2527000c, 0x00004021, 0x94e20000, 0x25080001, 0x00c23021, 0x2d020004,
6709 0x1440fffb, 0x24e70002, 0x95220002, 0x00004021, 0x91230009, 0x00442023,
6710 0x01803821, 0x3082ffff, 0xa4e00010, 0x3c040800, 0x948423d4, 0x00621821,
6711 0x00c33021, 0x00061c02, 0x30c2ffff, 0x00623021, 0x00061c02, 0x3c020800,
6712 0x944223d0, 0x00c34821, 0x00441023, 0x00021fc2, 0x00431021, 0x00021043,
6713 0x18400010, 0x00003021, 0x00402021, 0x94e20000, 0x24e70002, 0x00c23021,
6714 0x30e2007f, 0x14400006, 0x25080001, 0x8d630000, 0x3c02007f, 0x3442ff80,
6715 0x00625824, 0x25670008, 0x0104102a, 0x1440fff3, 0x00000000, 0x3c020800,
6716 0x944223ec, 0x00c23021, 0x3122ffff, 0x00c23021, 0x00061c02, 0x30c2ffff,
6717 0x00623021, 0x00061402, 0x00c23021, 0x00c04021, 0x00061027, 0xa5820010,
6718 0xadc00014, 0x0a00049d, 0xadc00000, 0x8dc70010, 0x00e04021, 0x11400007,
6719 0x00072c02, 0x00aa3021, 0x00061402, 0x30c3ffff, 0x00433021, 0x00061402,
6720 0x00c22821, 0x00051027, 0xa522000a, 0x3c030800, 0x946323d4, 0x3102ffff,
6721 0x01e21021, 0x00433023, 0x00cd3021, 0x00061c02, 0x30c2ffff, 0x00623021,
6722 0x00061402, 0x00c23021, 0x00c04021, 0x00061027, 0xa5820010, 0x3102ffff,
6723 0x00051c00, 0x00431025, 0xadc20010, 0x3c020800, 0x8c4223f4, 0x10400005,
6724 0x2de205eb, 0x14400002, 0x25e2fff2, 0x34028870, 0xa5c20034, 0x3c030800,
6725 0x246323e8, 0x8c620000, 0x24420001, 0xac620000, 0x3c040800, 0x8c8423e4,
6726 0x3c020800, 0x8c421bc0, 0x3303ffff, 0x00832021, 0x00431821, 0x0062102b,
6727 0x3c010800, 0xac2423e4, 0x10400003, 0x2482ffff, 0x3c010800, 0xac2223e4,
6728 0x3c010800, 0xac231bc0, 0x03e00008, 0x27bd0020, 0x27bdffb8, 0x3c050800,
6729 0x24a51b96, 0xafbf0044, 0xafbe0040, 0xafb7003c, 0xafb60038, 0xafb50034,
6730 0xafb40030, 0xafb3002c, 0xafb20028, 0xafb10024, 0xafb00020, 0x94a90000,
6731 0x3c020800, 0x944223d0, 0x3c030800, 0x8c631bb0, 0x3c040800, 0x8c841bac,
6732 0x01221023, 0x0064182a, 0xa7a9001e, 0x106000be, 0xa7a20016, 0x24be0022,
6733 0x97b6001e, 0x24b3001a, 0x24b70016, 0x8fc20000, 0x14400008, 0x00000000,
6734 0x8fc2fff8, 0x97a30016, 0x8fc4fff4, 0x00431021, 0x0082202a, 0x148000b0,
6735 0x00000000, 0x97d50818, 0x32a2ffff, 0x104000a3, 0x00009021, 0x0040a021,
6736 0x00008821, 0x0e000625, 0x00000000, 0x00403021, 0x14c00007, 0x00000000,
6737 0x3c020800, 0x8c4223dc, 0x24420001, 0x3c010800, 0x0a000596, 0xac2223dc,
6738 0x3c100800, 0x02118021, 0x8e101bc8, 0x9608000a, 0x31020040, 0x10400005,
6739 0x2407180c, 0x8e02000c, 0x2407188c, 0x00021400, 0xacc20018, 0x31020080,
6740 0x54400001, 0x34e70010, 0x3c020800, 0x00511021, 0x8c421bd0, 0x3c030800,
6741 0x00711821, 0x8c631bd4, 0x00021500, 0x00031c00, 0x00431025, 0xacc20014,
6742 0x96040008, 0x3242ffff, 0x00821021, 0x0282102a, 0x14400002, 0x02b22823,
6743 0x00802821, 0x8e020000, 0x02459021, 0xacc20000, 0x8e020004, 0x00c02021,
6744 0x26310010, 0xac820004, 0x30e2ffff, 0xac800008, 0xa485000e, 0xac820010,
6745 0x24020305, 0x0e0005a2, 0xa482000c, 0x3242ffff, 0x0054102b, 0x1440ffc5,
6746 0x3242ffff, 0x0a00058e, 0x00000000, 0x8e620000, 0x8e63fffc, 0x0043102a,
6747 0x10400067, 0x00000000, 0x8e62fff0, 0x00028900, 0x3c100800, 0x02118021,
6748 0x0e000625, 0x8e101bc8, 0x00403021, 0x14c00005, 0x00000000, 0x8e62082c,
6749 0x24420001, 0x0a000596, 0xae62082c, 0x9608000a, 0x31020040, 0x10400005,
6750 0x2407180c, 0x8e02000c, 0x2407188c, 0x00021400, 0xacc20018, 0x3c020800,
6751 0x00511021, 0x8c421bd0, 0x3c030800, 0x00711821, 0x8c631bd4, 0x00021500,
6752 0x00031c00, 0x00431025, 0xacc20014, 0x8e63fff4, 0x96020008, 0x00432023,
6753 0x3242ffff, 0x3083ffff, 0x00431021, 0x02c2102a, 0x10400003, 0x00802821,
6754 0x97a9001e, 0x01322823, 0x8e620000, 0x30a4ffff, 0x00441021, 0xae620000,
6755 0xa4c5000e, 0x8e020000, 0xacc20000, 0x8e020004, 0x8e63fff4, 0x00431021,
6756 0xacc20004, 0x8e63fff4, 0x96020008, 0x00641821, 0x0062102a, 0x14400006,
6757 0x02459021, 0x8e62fff0, 0xae60fff4, 0x24420001, 0x0a000571, 0xae62fff0,
6758 0xae63fff4, 0xacc00008, 0x3242ffff, 0x10560003, 0x31020004, 0x10400006,
6759 0x24020305, 0x31020080, 0x54400001, 0x34e70010, 0x34e70020, 0x24020905,
6760 0xa4c2000c, 0x8ee30000, 0x8ee20004, 0x14620007, 0x3c02b49a, 0x8ee20860,
6761 0x54400001, 0x34e70400, 0x3c024b65, 0x0a000588, 0x34427654, 0x344289ab,
6762 0xacc2001c, 0x30e2ffff, 0xacc20010, 0x0e0005a2, 0x00c02021, 0x3242ffff,
6763 0x0056102b, 0x1440ff9b, 0x00000000, 0x8e620000, 0x8e63fffc, 0x0043102a,
6764 0x1440ff48, 0x00000000, 0x8fbf0044, 0x8fbe0040, 0x8fb7003c, 0x8fb60038,
6765 0x8fb50034, 0x8fb40030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020,
6766 0x03e00008, 0x27bd0048, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f624450,
6767 0x8f634410, 0x0a0005b1, 0x00808021, 0x8f626820, 0x30422000, 0x10400003,
6768 0x00000000, 0x0e0001f0, 0x00002021, 0x8f624450, 0x8f634410, 0x3042ffff,
6769 0x0043102b, 0x1440fff5, 0x00000000, 0x8f630c14, 0x3063000f, 0x2c620002,
6770 0x1440000b, 0x00000000, 0x8f630c14, 0x3c020800, 0x8c421b40, 0x3063000f,
6771 0x24420001, 0x3c010800, 0xac221b40, 0x2c620002, 0x1040fff7, 0x00000000,
6772 0xaf705c18, 0x8f625c10, 0x30420002, 0x10400009, 0x00000000, 0x8f626820,
6773 0x30422000, 0x1040fff8, 0x00000000, 0x0e0001f0, 0x00002021, 0x0a0005c4,
6774 0x00000000, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000,
6775 0x00000000, 0x00000000, 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010,
6776 0xaf60680c, 0x8f626804, 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50,
6777 0x3c010800, 0xac221b54, 0x24020b78, 0x3c010800, 0xac221b64, 0x34630002,
6778 0xaf634000, 0x0e000605, 0x00808021, 0x3c010800, 0xa0221b68, 0x304200ff,
6779 0x24030002, 0x14430005, 0x00000000, 0x3c020800, 0x8c421b54, 0x0a0005f8,
6780 0xac5000c0, 0x3c020800, 0x8c421b54, 0xac5000bc, 0x8f624434, 0x8f634438,
6781 0x8f644410, 0x3c010800, 0xac221b5c, 0x3c010800, 0xac231b6c, 0x3c010800,
6782 0xac241b58, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c040800,
6783 0x8c870000, 0x3c03aa55, 0x3463aa55, 0x3c06c003, 0xac830000, 0x8cc20000,
6784 0x14430007, 0x24050002, 0x3c0355aa, 0x346355aa, 0xac830000, 0x8cc20000,
6785 0x50430001, 0x24050001, 0x3c020800, 0xac470000, 0x03e00008, 0x00a01021,
6786 0x27bdfff8, 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c, 0x1043fffe,
6787 0x00000000, 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000, 0x03e00008,
6788 0x27bd0008, 0x8f634450, 0x3c020800, 0x8c421b5c, 0x00031c02, 0x0043102b,
6789 0x14400008, 0x3c038000, 0x3c040800, 0x8c841b6c, 0x8f624450, 0x00021c02,
6790 0x0083102b, 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024,
6791 0x1440fffd, 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3082ffff,
6792 0x2442e000, 0x2c422001, 0x14400003, 0x3c024000, 0x0a000648, 0x2402ffff,
6793 0x00822025, 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00001021,
6794 0x03e00008, 0x00000000, 0x8f624450, 0x3c030800, 0x8c631b58, 0x0a000651,
6795 0x3042ffff, 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc, 0x00000000,
6796 0x03e00008, 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040800, 0x24841af0,
6797 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010, 0x0e00067c, 0xafa00014,
6798 0x0a000660, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x00000000,
6799 0x00000000, 0x00000000, 0x3c020800, 0x34423000, 0x3c030800, 0x34633000,
6800 0x3c040800, 0x348437ff, 0x3c010800, 0xac221b74, 0x24020040, 0x3c010800,
6801 0xac221b78, 0x3c010800, 0xac201b70, 0xac600000, 0x24630004, 0x0083102b,
6802 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000, 0x00804821, 0x8faa0010,
6803 0x3c020800, 0x8c421b70, 0x3c040800, 0x8c841b78, 0x8fab0014, 0x24430001,
6804 0x0044102b, 0x3c010800, 0xac231b70, 0x14400003, 0x00004021, 0x3c010800,
6805 0xac201b70, 0x3c020800, 0x8c421b70, 0x3c030800, 0x8c631b74, 0x91240000,
6806 0x00021140, 0x00431021, 0x00481021, 0x25080001, 0xa0440000, 0x29020008,
6807 0x1440fff4, 0x25290001, 0x3c020800, 0x8c421b70, 0x3c030800, 0x8c631b74,
6808 0x8f64680c, 0x00021140, 0x00431021, 0xac440008, 0xac45000c, 0xac460010,
6809 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c, 0x00000000, 0x00000000,
6810};
6811
6812static const u32 tg3TsoFwRodata[] = {
6813 0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
6814 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x496e0000, 0x73746b6f,
6815 0x66662a2a, 0x00000000, 0x53774576, 0x656e7430, 0x00000000, 0x00000000,
6816 0x00000000, 0x00000000, 0x66617461, 0x6c457272, 0x00000000, 0x00000000,
6817 0x00000000,
6818};
6819
6820static const u32 tg3TsoFwData[] = {
6821 0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x362e3000, 0x00000000,
6822 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
6823 0x00000000,
6824};
6825
6826/* 5705 needs a special version of the TSO firmware. */ 6378/* 5705 needs a special version of the TSO firmware. */
6827#define TG3_TSO5_FW_RELEASE_MAJOR 0x1
6828#define TG3_TSO5_FW_RELASE_MINOR 0x2
6829#define TG3_TSO5_FW_RELEASE_FIX 0x0
6830#define TG3_TSO5_FW_START_ADDR 0x00010000
6831#define TG3_TSO5_FW_TEXT_ADDR 0x00010000
6832#define TG3_TSO5_FW_TEXT_LEN 0xe90
6833#define TG3_TSO5_FW_RODATA_ADDR 0x00010e90
6834#define TG3_TSO5_FW_RODATA_LEN 0x50
6835#define TG3_TSO5_FW_DATA_ADDR 0x00010f00
6836#define TG3_TSO5_FW_DATA_LEN 0x20
6837#define TG3_TSO5_FW_SBSS_ADDR 0x00010f20
6838#define TG3_TSO5_FW_SBSS_LEN 0x28
6839#define TG3_TSO5_FW_BSS_ADDR 0x00010f50
6840#define TG3_TSO5_FW_BSS_LEN 0x88
6841
6842static const u32 tg3Tso5FwText[(TG3_TSO5_FW_TEXT_LEN / 4) + 1] = {
6843 0x0c004003, 0x00000000, 0x00010f04, 0x00000000, 0x10000003, 0x00000000,
6844 0x0000000d, 0x0000000d, 0x3c1d0001, 0x37bde000, 0x03a0f021, 0x3c100001,
6845 0x26100000, 0x0c004010, 0x00000000, 0x0000000d, 0x27bdffe0, 0x3c04fefe,
6846 0xafbf0018, 0x0c0042e8, 0x34840002, 0x0c004364, 0x00000000, 0x3c030001,
6847 0x90630f34, 0x24020002, 0x3c040001, 0x24840e9c, 0x14620003, 0x24050001,
6848 0x3c040001, 0x24840e90, 0x24060002, 0x00003821, 0xafa00010, 0x0c004378,
6849 0xafa00014, 0x0c00402c, 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6850 0x00000000, 0x00000000, 0x27bdffe0, 0xafbf001c, 0xafb20018, 0xafb10014,
6851 0x0c0042d4, 0xafb00010, 0x3c128000, 0x24110001, 0x8f706810, 0x32020400,
6852 0x10400007, 0x00000000, 0x8f641008, 0x00921024, 0x14400003, 0x00000000,
6853 0x0c004064, 0x00000000, 0x3c020001, 0x90420f56, 0x10510003, 0x32020200,
6854 0x1040fff1, 0x00000000, 0x0c0041b4, 0x00000000, 0x08004034, 0x00000000,
6855 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
6856 0x27bdffe0, 0x3c040001, 0x24840eb0, 0x00002821, 0x00003021, 0x00003821,
6857 0xafbf0018, 0xafa00010, 0x0c004378, 0xafa00014, 0x0000d021, 0x24020130,
6858 0xaf625000, 0x3c010001, 0xa4200f50, 0x3c010001, 0xa0200f57, 0x8fbf0018,
6859 0x03e00008, 0x27bd0020, 0x00000000, 0x00000000, 0x3c030001, 0x24630f60,
6860 0x90620000, 0x27bdfff0, 0x14400003, 0x0080c021, 0x08004073, 0x00004821,
6861 0x3c022000, 0x03021024, 0x10400003, 0x24090002, 0x08004073, 0xa0600000,
6862 0x24090001, 0x00181040, 0x30431f80, 0x346f8008, 0x1520004b, 0x25eb0028,
6863 0x3c040001, 0x00832021, 0x8c848010, 0x3c050001, 0x24a50f7a, 0x00041402,
6864 0xa0a20000, 0x3c010001, 0xa0240f7b, 0x3c020001, 0x00431021, 0x94428014,
6865 0x3c010001, 0xa0220f7c, 0x3c0c0001, 0x01836021, 0x8d8c8018, 0x304200ff,
6866 0x24420008, 0x000220c3, 0x24020001, 0x3c010001, 0xa0220f60, 0x0124102b,
6867 0x1040000c, 0x00003821, 0x24a6000e, 0x01602821, 0x8ca20000, 0x8ca30004,
6868 0x24a50008, 0x24e70001, 0xacc20000, 0xacc30004, 0x00e4102b, 0x1440fff8,
6869 0x24c60008, 0x00003821, 0x3c080001, 0x25080f7b, 0x91060000, 0x3c020001,
6870 0x90420f7c, 0x2503000d, 0x00c32821, 0x00461023, 0x00021fc2, 0x00431021,
6871 0x00021043, 0x1840000c, 0x00002021, 0x91020001, 0x00461023, 0x00021fc2,
6872 0x00431021, 0x00021843, 0x94a20000, 0x24e70001, 0x00822021, 0x00e3102a,
6873 0x1440fffb, 0x24a50002, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
6874 0x00822021, 0x3c02ffff, 0x01821024, 0x3083ffff, 0x00431025, 0x3c010001,
6875 0x080040fa, 0xac220f80, 0x3c050001, 0x24a50f7c, 0x90a20000, 0x3c0c0001,
6876 0x01836021, 0x8d8c8018, 0x000220c2, 0x1080000e, 0x00003821, 0x01603021,
6877 0x24a5000c, 0x8ca20000, 0x8ca30004, 0x24a50008, 0x24e70001, 0xacc20000,
6878 0xacc30004, 0x00e4102b, 0x1440fff8, 0x24c60008, 0x3c050001, 0x24a50f7c,
6879 0x90a20000, 0x30430007, 0x24020004, 0x10620011, 0x28620005, 0x10400005,
6880 0x24020002, 0x10620008, 0x000710c0, 0x080040fa, 0x00000000, 0x24020006,
6881 0x1062000e, 0x000710c0, 0x080040fa, 0x00000000, 0x00a21821, 0x9463000c,
6882 0x004b1021, 0x080040fa, 0xa4430000, 0x000710c0, 0x00a21821, 0x8c63000c,
6883 0x004b1021, 0x080040fa, 0xac430000, 0x00a21821, 0x8c63000c, 0x004b2021,
6884 0x00a21021, 0xac830000, 0x94420010, 0xa4820004, 0x95e70006, 0x3c020001,
6885 0x90420f7c, 0x3c030001, 0x90630f7a, 0x00e2c823, 0x3c020001, 0x90420f7b,
6886 0x24630028, 0x01e34021, 0x24420028, 0x15200012, 0x01e23021, 0x94c2000c,
6887 0x3c010001, 0xa4220f78, 0x94c20004, 0x94c30006, 0x3c010001, 0xa4200f76,
6888 0x3c010001, 0xa4200f72, 0x00021400, 0x00431025, 0x3c010001, 0xac220f6c,
6889 0x95020004, 0x3c010001, 0x08004124, 0xa4220f70, 0x3c020001, 0x94420f70,
6890 0x3c030001, 0x94630f72, 0x00431021, 0xa5020004, 0x3c020001, 0x94420f6c,
6891 0xa4c20004, 0x3c020001, 0x8c420f6c, 0xa4c20006, 0x3c040001, 0x94840f72,
6892 0x3c020001, 0x94420f70, 0x3c0a0001, 0x954a0f76, 0x00441821, 0x3063ffff,
6893 0x0062182a, 0x24020002, 0x1122000b, 0x00832023, 0x3c030001, 0x94630f78,
6894 0x30620009, 0x10400006, 0x3062fff6, 0xa4c2000c, 0x3c020001, 0x94420f78,
6895 0x30420009, 0x01425023, 0x24020001, 0x1122001b, 0x29220002, 0x50400005,
6896 0x24020002, 0x11200007, 0x31a2ffff, 0x08004197, 0x00000000, 0x1122001d,
6897 0x24020016, 0x08004197, 0x31a2ffff, 0x3c0e0001, 0x95ce0f80, 0x10800005,
6898 0x01806821, 0x01c42021, 0x00041c02, 0x3082ffff, 0x00627021, 0x000e1027,
6899 0xa502000a, 0x3c030001, 0x90630f7b, 0x31a2ffff, 0x00e21021, 0x0800418d,
6900 0x00432023, 0x3c020001, 0x94420f80, 0x00442021, 0x00041c02, 0x3082ffff,
6901 0x00622021, 0x00807021, 0x00041027, 0x08004185, 0xa502000a, 0x3c050001,
6902 0x24a50f7a, 0x90a30000, 0x14620002, 0x24e2fff2, 0xa5e20034, 0x90a20000,
6903 0x00e21023, 0xa5020002, 0x3c030001, 0x94630f80, 0x3c020001, 0x94420f5a,
6904 0x30e5ffff, 0x00641821, 0x00451023, 0x00622023, 0x00041c02, 0x3082ffff,
6905 0x00622021, 0x00041027, 0xa502000a, 0x3c030001, 0x90630f7c, 0x24620001,
6906 0x14a20005, 0x00807021, 0x01631021, 0x90420000, 0x08004185, 0x00026200,
6907 0x24620002, 0x14a20003, 0x306200fe, 0x004b1021, 0x944c0000, 0x3c020001,
6908 0x94420f82, 0x3183ffff, 0x3c040001, 0x90840f7b, 0x00431021, 0x00e21021,
6909 0x00442023, 0x008a2021, 0x00041c02, 0x3082ffff, 0x00622021, 0x00041402,
6910 0x00822021, 0x00806821, 0x00041027, 0xa4c20010, 0x31a2ffff, 0x000e1c00,
6911 0x00431025, 0x3c040001, 0x24840f72, 0xade20010, 0x94820000, 0x3c050001,
6912 0x94a50f76, 0x3c030001, 0x8c630f6c, 0x24420001, 0x00b92821, 0xa4820000,
6913 0x3322ffff, 0x00622021, 0x0083182b, 0x3c010001, 0xa4250f76, 0x10600003,
6914 0x24a2ffff, 0x3c010001, 0xa4220f76, 0x3c024000, 0x03021025, 0x3c010001,
6915 0xac240f6c, 0xaf621008, 0x03e00008, 0x27bd0010, 0x3c030001, 0x90630f56,
6916 0x27bdffe8, 0x24020001, 0xafbf0014, 0x10620026, 0xafb00010, 0x8f620cf4,
6917 0x2442ffff, 0x3042007f, 0x00021100, 0x8c434000, 0x3c010001, 0xac230f64,
6918 0x8c434008, 0x24444000, 0x8c5c4004, 0x30620040, 0x14400002, 0x24020088,
6919 0x24020008, 0x3c010001, 0xa4220f68, 0x30620004, 0x10400005, 0x24020001,
6920 0x3c010001, 0xa0220f57, 0x080041d5, 0x00031402, 0x3c010001, 0xa0200f57,
6921 0x00031402, 0x3c010001, 0xa4220f54, 0x9483000c, 0x24020001, 0x3c010001,
6922 0xa4200f50, 0x3c010001, 0xa0220f56, 0x3c010001, 0xa4230f62, 0x24020001,
6923 0x1342001e, 0x00000000, 0x13400005, 0x24020003, 0x13420067, 0x00000000,
6924 0x080042cf, 0x00000000, 0x3c020001, 0x94420f62, 0x241a0001, 0x3c010001,
6925 0xa4200f5e, 0x3c010001, 0xa4200f52, 0x304407ff, 0x00021bc2, 0x00031823,
6926 0x3063003e, 0x34630036, 0x00021242, 0x3042003c, 0x00621821, 0x3c010001,
6927 0xa4240f58, 0x00832021, 0x24630030, 0x3c010001, 0xa4240f5a, 0x3c010001,
6928 0xa4230f5c, 0x3c060001, 0x24c60f52, 0x94c50000, 0x94c30002, 0x3c040001,
6929 0x94840f5a, 0x00651021, 0x0044102a, 0x10400013, 0x3c108000, 0x00a31021,
6930 0xa4c20000, 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f56, 0x8f641008,
6931 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4,
6932 0x00501024, 0x104000b7, 0x00000000, 0x0800420f, 0x00000000, 0x3c030001,
6933 0x94630f50, 0x00851023, 0xa4c40000, 0x00621821, 0x3042ffff, 0x3c010001,
6934 0xa4230f50, 0xaf620ce8, 0x3c020001, 0x94420f68, 0x34420024, 0xaf620cec,
6935 0x94c30002, 0x3c020001, 0x94420f50, 0x14620012, 0x3c028000, 0x3c108000,
6936 0x3c02a000, 0xaf620cf4, 0x3c010001, 0xa0200f56, 0x8f641008, 0x00901024,
6937 0x14400003, 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024,
6938 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003, 0xaf620cf4, 0x3c108000,
6939 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064, 0x00000000,
6940 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x080042cf, 0x241a0003,
6941 0x3c070001, 0x24e70f50, 0x94e20000, 0x03821021, 0xaf620ce0, 0x3c020001,
6942 0x8c420f64, 0xaf620ce4, 0x3c050001, 0x94a50f54, 0x94e30000, 0x3c040001,
6943 0x94840f58, 0x3c020001, 0x94420f5e, 0x00a32823, 0x00822023, 0x30a6ffff,
6944 0x3083ffff, 0x00c3102b, 0x14400043, 0x00000000, 0x3c020001, 0x94420f5c,
6945 0x00021400, 0x00621025, 0xaf620ce8, 0x94e20000, 0x3c030001, 0x94630f54,
6946 0x00441021, 0xa4e20000, 0x3042ffff, 0x14430021, 0x3c020008, 0x3c020001,
6947 0x90420f57, 0x10400006, 0x3c03000c, 0x3c020001, 0x94420f68, 0x34630624,
6948 0x0800427c, 0x0000d021, 0x3c020001, 0x94420f68, 0x3c030008, 0x34630624,
6949 0x00431025, 0xaf620cec, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
6950 0xa0200f56, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
6951 0x00000000, 0x8f620cf4, 0x00501024, 0x10400015, 0x00000000, 0x08004283,
6952 0x00000000, 0x3c030001, 0x94630f68, 0x34420624, 0x3c108000, 0x00621825,
6953 0x3c028000, 0xaf630cec, 0xaf620cf4, 0x8f641008, 0x00901024, 0x14400003,
6954 0x00000000, 0x0c004064, 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7,
6955 0x00000000, 0x3c010001, 0x080042cf, 0xa4200f5e, 0x3c020001, 0x94420f5c,
6956 0x00021400, 0x00c21025, 0xaf620ce8, 0x3c020001, 0x90420f57, 0x10400009,
6957 0x3c03000c, 0x3c020001, 0x94420f68, 0x34630624, 0x0000d021, 0x00431025,
6958 0xaf620cec, 0x080042c1, 0x3c108000, 0x3c020001, 0x94420f68, 0x3c030008,
6959 0x34630604, 0x00431025, 0xaf620cec, 0x3c020001, 0x94420f5e, 0x00451021,
6960 0x3c010001, 0xa4220f5e, 0x3c108000, 0x3c02a000, 0xaf620cf4, 0x3c010001,
6961 0xa0200f56, 0x8f641008, 0x00901024, 0x14400003, 0x00000000, 0x0c004064,
6962 0x00000000, 0x8f620cf4, 0x00501024, 0x1440fff7, 0x00000000, 0x8fbf0014,
6963 0x8fb00010, 0x03e00008, 0x27bd0018, 0x00000000, 0x27bdffe0, 0x3c040001,
6964 0x24840ec0, 0x00002821, 0x00003021, 0x00003821, 0xafbf0018, 0xafa00010,
6965 0x0c004378, 0xafa00014, 0x0000d021, 0x24020130, 0xaf625000, 0x3c010001,
6966 0xa4200f50, 0x3c010001, 0xa0200f57, 0x8fbf0018, 0x03e00008, 0x27bd0020,
6967 0x27bdffe8, 0x3c1bc000, 0xafbf0014, 0xafb00010, 0xaf60680c, 0x8f626804,
6968 0x34420082, 0xaf626804, 0x8f634000, 0x24020b50, 0x3c010001, 0xac220f20,
6969 0x24020b78, 0x3c010001, 0xac220f30, 0x34630002, 0xaf634000, 0x0c004315,
6970 0x00808021, 0x3c010001, 0xa0220f34, 0x304200ff, 0x24030002, 0x14430005,
6971 0x00000000, 0x3c020001, 0x8c420f20, 0x08004308, 0xac5000c0, 0x3c020001,
6972 0x8c420f20, 0xac5000bc, 0x8f624434, 0x8f634438, 0x8f644410, 0x3c010001,
6973 0xac220f28, 0x3c010001, 0xac230f38, 0x3c010001, 0xac240f24, 0x8fbf0014,
6974 0x8fb00010, 0x03e00008, 0x27bd0018, 0x03e00008, 0x24020001, 0x27bdfff8,
6975 0x18800009, 0x00002821, 0x8f63680c, 0x8f62680c, 0x1043fffe, 0x00000000,
6976 0x24a50001, 0x00a4102a, 0x1440fff9, 0x00000000, 0x03e00008, 0x27bd0008,
6977 0x8f634450, 0x3c020001, 0x8c420f28, 0x00031c02, 0x0043102b, 0x14400008,
6978 0x3c038000, 0x3c040001, 0x8c840f38, 0x8f624450, 0x00021c02, 0x0083102b,
6979 0x1040fffc, 0x3c038000, 0xaf634444, 0x8f624444, 0x00431024, 0x1440fffd,
6980 0x00000000, 0x8f624448, 0x03e00008, 0x3042ffff, 0x3082ffff, 0x2442e000,
6981 0x2c422001, 0x14400003, 0x3c024000, 0x08004347, 0x2402ffff, 0x00822025,
6982 0xaf645c38, 0x8f625c30, 0x30420002, 0x1440fffc, 0x00001021, 0x03e00008,
6983 0x00000000, 0x8f624450, 0x3c030001, 0x8c630f24, 0x08004350, 0x3042ffff,
6984 0x8f624450, 0x3042ffff, 0x0043102b, 0x1440fffc, 0x00000000, 0x03e00008,
6985 0x00000000, 0x27bdffe0, 0x00802821, 0x3c040001, 0x24840ed0, 0x00003021,
6986 0x00003821, 0xafbf0018, 0xafa00010, 0x0c004378, 0xafa00014, 0x0800435f,
6987 0x00000000, 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x3c020001, 0x3442d600,
6988 0x3c030001, 0x3463d600, 0x3c040001, 0x3484ddff, 0x3c010001, 0xac220f40,
6989 0x24020040, 0x3c010001, 0xac220f44, 0x3c010001, 0xac200f3c, 0xac600000,
6990 0x24630004, 0x0083102b, 0x5040fffd, 0xac600000, 0x03e00008, 0x00000000,
6991 0x00804821, 0x8faa0010, 0x3c020001, 0x8c420f3c, 0x3c040001, 0x8c840f44,
6992 0x8fab0014, 0x24430001, 0x0044102b, 0x3c010001, 0xac230f3c, 0x14400003,
6993 0x00004021, 0x3c010001, 0xac200f3c, 0x3c020001, 0x8c420f3c, 0x3c030001,
6994 0x8c630f40, 0x91240000, 0x00021140, 0x00431021, 0x00481021, 0x25080001,
6995 0xa0440000, 0x29020008, 0x1440fff4, 0x25290001, 0x3c020001, 0x8c420f3c,
6996 0x3c030001, 0x8c630f40, 0x8f64680c, 0x00021140, 0x00431021, 0xac440008,
6997 0xac45000c, 0xac460010, 0xac470014, 0xac4a0018, 0x03e00008, 0xac4b001c,
6998 0x00000000, 0x00000000, 0x00000000,
6999};
7000
7001static const u32 tg3Tso5FwRodata[(TG3_TSO5_FW_RODATA_LEN / 4) + 1] = {
7002 0x4d61696e, 0x43707542, 0x00000000, 0x4d61696e, 0x43707541, 0x00000000,
7003 0x00000000, 0x00000000, 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000,
7004 0x73746b6f, 0x66666c64, 0x00000000, 0x00000000, 0x66617461, 0x6c457272,
7005 0x00000000, 0x00000000, 0x00000000,
7006};
7007
7008static const u32 tg3Tso5FwData[(TG3_TSO5_FW_DATA_LEN / 4) + 1] = {
7009 0x00000000, 0x73746b6f, 0x66666c64, 0x5f76312e, 0x322e3000, 0x00000000,
7010 0x00000000, 0x00000000, 0x00000000,
7011};
7012 6379
7013/* tp->lock is held. */ 6380/* tp->lock is held. */
7014static int tg3_load_tso_firmware(struct tg3 *tp) 6381static int tg3_load_tso_firmware(struct tg3 *tp)
7015{ 6382{
7016 struct fw_info info; 6383 struct fw_info info;
6384 const __be32 *fw_data;
7017 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size; 6385 unsigned long cpu_base, cpu_scratch_base, cpu_scratch_size;
7018 int err, i; 6386 int err, i;
7019 6387
7020 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 6388 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
7021 return 0; 6389 return 0;
7022 6390
6391 fw_data = (void *)tp->fw->data;
6392
6393 /* Firmware blob starts with version numbers, followed by
6394 start address and length. We are setting complete length.
6395 length = end_address_of_bss - start_address_of_text.
6396 Remainder is the blob to be loaded contiguously
6397 from start address. */
6398
6399 info.fw_base = be32_to_cpu(fw_data[1]);
6400 cpu_scratch_size = tp->fw_len;
6401 info.fw_len = tp->fw->size - 12;
6402 info.fw_data = &fw_data[3];
6403
7023 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) { 6404 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
7024 info.text_base = TG3_TSO5_FW_TEXT_ADDR;
7025 info.text_len = TG3_TSO5_FW_TEXT_LEN;
7026 info.text_data = &tg3Tso5FwText[0];
7027 info.rodata_base = TG3_TSO5_FW_RODATA_ADDR;
7028 info.rodata_len = TG3_TSO5_FW_RODATA_LEN;
7029 info.rodata_data = &tg3Tso5FwRodata[0];
7030 info.data_base = TG3_TSO5_FW_DATA_ADDR;
7031 info.data_len = TG3_TSO5_FW_DATA_LEN;
7032 info.data_data = &tg3Tso5FwData[0];
7033 cpu_base = RX_CPU_BASE; 6405 cpu_base = RX_CPU_BASE;
7034 cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705; 6406 cpu_scratch_base = NIC_SRAM_MBUF_POOL_BASE5705;
7035 cpu_scratch_size = (info.text_len +
7036 info.rodata_len +
7037 info.data_len +
7038 TG3_TSO5_FW_SBSS_LEN +
7039 TG3_TSO5_FW_BSS_LEN);
7040 } else { 6407 } else {
7041 info.text_base = TG3_TSO_FW_TEXT_ADDR;
7042 info.text_len = TG3_TSO_FW_TEXT_LEN;
7043 info.text_data = &tg3TsoFwText[0];
7044 info.rodata_base = TG3_TSO_FW_RODATA_ADDR;
7045 info.rodata_len = TG3_TSO_FW_RODATA_LEN;
7046 info.rodata_data = &tg3TsoFwRodata[0];
7047 info.data_base = TG3_TSO_FW_DATA_ADDR;
7048 info.data_len = TG3_TSO_FW_DATA_LEN;
7049 info.data_data = &tg3TsoFwData[0];
7050 cpu_base = TX_CPU_BASE; 6408 cpu_base = TX_CPU_BASE;
7051 cpu_scratch_base = TX_CPU_SCRATCH_BASE; 6409 cpu_scratch_base = TX_CPU_SCRATCH_BASE;
7052 cpu_scratch_size = TX_CPU_SCRATCH_SIZE; 6410 cpu_scratch_size = TX_CPU_SCRATCH_SIZE;
@@ -7060,21 +6418,21 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
7060 6418
7061 /* Now startup the cpu. */ 6419 /* Now startup the cpu. */
7062 tw32(cpu_base + CPU_STATE, 0xffffffff); 6420 tw32(cpu_base + CPU_STATE, 0xffffffff);
7063 tw32_f(cpu_base + CPU_PC, info.text_base); 6421 tw32_f(cpu_base + CPU_PC, info.fw_base);
7064 6422
7065 for (i = 0; i < 5; i++) { 6423 for (i = 0; i < 5; i++) {
7066 if (tr32(cpu_base + CPU_PC) == info.text_base) 6424 if (tr32(cpu_base + CPU_PC) == info.fw_base)
7067 break; 6425 break;
7068 tw32(cpu_base + CPU_STATE, 0xffffffff); 6426 tw32(cpu_base + CPU_STATE, 0xffffffff);
7069 tw32(cpu_base + CPU_MODE, CPU_MODE_HALT); 6427 tw32(cpu_base + CPU_MODE, CPU_MODE_HALT);
7070 tw32_f(cpu_base + CPU_PC, info.text_base); 6428 tw32_f(cpu_base + CPU_PC, info.fw_base);
7071 udelay(1000); 6429 udelay(1000);
7072 } 6430 }
7073 if (i >= 5) { 6431 if (i >= 5) {
7074 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s " 6432 printk(KERN_ERR PFX "tg3_load_tso_firmware fails for %s "
7075 "to set CPU PC, is %08x should be %08x\n", 6433 "to set CPU PC, is %08x should be %08x\n",
7076 tp->dev->name, tr32(cpu_base + CPU_PC), 6434 tp->dev->name, tr32(cpu_base + CPU_PC),
7077 info.text_base); 6435 info.fw_base);
7078 return -ENODEV; 6436 return -ENODEV;
7079 } 6437 }
7080 tw32(cpu_base + CPU_STATE, 0xffffffff); 6438 tw32(cpu_base + CPU_STATE, 0xffffffff);
@@ -7299,11 +6657,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7299 else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) { 6657 else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
7300 int fw_len; 6658 int fw_len;
7301 6659
7302 fw_len = (TG3_TSO5_FW_TEXT_LEN + 6660 fw_len = tp->fw_len;
7303 TG3_TSO5_FW_RODATA_LEN +
7304 TG3_TSO5_FW_DATA_LEN +
7305 TG3_TSO5_FW_SBSS_LEN +
7306 TG3_TSO5_FW_BSS_LEN);
7307 fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1); 6661 fw_len = (fw_len + (0x80 - 1)) & ~(0x80 - 1);
7308 tw32(BUFMGR_MB_POOL_ADDR, 6662 tw32(BUFMGR_MB_POOL_ADDR,
7309 NIC_SRAM_MBUF_POOL_BASE5705 + fw_len); 6663 NIC_SRAM_MBUF_POOL_BASE5705 + fw_len);
@@ -13580,6 +12934,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13580 struct net_device *dev; 12934 struct net_device *dev;
13581 struct tg3 *tp; 12935 struct tg3 *tp;
13582 int err, pm_cap; 12936 int err, pm_cap;
12937 const char *fw_name = NULL;
13583 char str[40]; 12938 char str[40];
13584 u64 dma_mask, persist_dma_mask; 12939 u64 dma_mask, persist_dma_mask;
13585 12940
@@ -13735,6 +13090,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13735 13090
13736 tg3_init_bufmgr_config(tp); 13091 tg3_init_bufmgr_config(tp);
13737 13092
13093 if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0)
13094 fw_name = FIRMWARE_TG3;
13095
13738 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 13096 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
13739 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; 13097 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
13740 } 13098 }
@@ -13747,6 +13105,37 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13747 } else { 13105 } else {
13748 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE | TG3_FLG2_TSO_BUG; 13106 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE | TG3_FLG2_TSO_BUG;
13749 } 13107 }
13108 if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
13109 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
13110 fw_name = FIRMWARE_TG3TSO5;
13111 else
13112 fw_name = FIRMWARE_TG3TSO;
13113 }
13114
13115 if (fw_name) {
13116 const __be32 *fw_data;
13117
13118 err = request_firmware(&tp->fw, fw_name, &tp->pdev->dev);
13119 if (err) {
13120 printk(KERN_ERR "tg3: Failed to load firmware \"%s\"\n",
13121 fw_name);
13122 goto err_out_iounmap;
13123 }
13124
13125 fw_data = (void *)tp->fw->data;
13126
13127 /* Firmware blob starts with version numbers, followed by
13128 start address and _full_ length including BSS sections
13129 (which must be longer than the actual data, of course */
13130
13131 tp->fw_len = be32_to_cpu(fw_data[2]); /* includes bss */
13132 if (tp->fw_len < (tp->fw->size - 12)) {
13133 printk(KERN_ERR "tg3: bogus length %d in \"%s\"\n",
13134 tp->fw_len, fw_name);
13135 err = -EINVAL;
13136 goto err_out_fw;
13137 }
13138 }
13750 13139
13751 /* TSO is on by default on chips that support hardware TSO. 13140 /* TSO is on by default on chips that support hardware TSO.
13752 * Firmware TSO on older chips gives lower performance, so it 13141 * Firmware TSO on older chips gives lower performance, so it
@@ -13778,7 +13167,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13778 if (err) { 13167 if (err) {
13779 printk(KERN_ERR PFX "Could not obtain valid ethernet address, " 13168 printk(KERN_ERR PFX "Could not obtain valid ethernet address, "
13780 "aborting.\n"); 13169 "aborting.\n");
13781 goto err_out_iounmap; 13170 goto err_out_fw;
13782 } 13171 }
13783 13172
13784 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 13173 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
@@ -13787,7 +13176,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
13787 printk(KERN_ERR PFX "Cannot map APE registers, " 13176 printk(KERN_ERR PFX "Cannot map APE registers, "
13788 "aborting.\n"); 13177 "aborting.\n");
13789 err = -ENOMEM; 13178 err = -ENOMEM;
13790 goto err_out_iounmap; 13179 goto err_out_fw;
13791 } 13180 }
13792 13181
13793 tg3_ape_lock_init(tp); 13182 tg3_ape_lock_init(tp);
@@ -13867,6 +13256,10 @@ err_out_apeunmap:
13867 tp->aperegs = NULL; 13256 tp->aperegs = NULL;
13868 } 13257 }
13869 13258
13259err_out_fw:
13260 if (tp->fw)
13261 release_firmware(tp->fw);
13262
13870err_out_iounmap: 13263err_out_iounmap:
13871 if (tp->regs) { 13264 if (tp->regs) {
13872 iounmap(tp->regs); 13265 iounmap(tp->regs);
@@ -13892,6 +13285,9 @@ static void __devexit tg3_remove_one(struct pci_dev *pdev)
13892 if (dev) { 13285 if (dev) {
13893 struct tg3 *tp = netdev_priv(dev); 13286 struct tg3 *tp = netdev_priv(dev);
13894 13287
13288 if (tp->fw)
13289 release_firmware(tp->fw);
13290
13895 flush_scheduled_work(); 13291 flush_scheduled_work();
13896 13292
13897 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) { 13293 if (tp->tg3_flags3 & TG3_FLG3_USE_PHYLIB) {
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 8936edfb0438..ae5da603c6af 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2762,6 +2762,10 @@ struct tg3 {
2762#define SST_25VF0X0_PAGE_SIZE 4098 2762#define SST_25VF0X0_PAGE_SIZE 4098
2763 2763
2764 struct ethtool_coalesce coal; 2764 struct ethtool_coalesce coal;
2765
2766 /* firmware info */
2767 const struct firmware *fw;
2768 u32 fw_len; /* includes BSS */
2765}; 2769};
2766 2770
2767#endif /* !(_T3_H) */ 2771#endif /* !(_T3_H) */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 69f9a0ec764d..d7b81e4fdd56 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -213,7 +213,7 @@ static int check_filter(struct tap_filter *filter, const struct sk_buff *skb)
213 213
214/* Network device part of the driver */ 214/* Network device part of the driver */
215 215
216static unsigned int tun_net_id; 216static int tun_net_id;
217struct tun_net { 217struct tun_net {
218 struct list_head dev_list; 218 struct list_head dev_list;
219}; 219};
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index ddc4c59f02dc..b7e4cee24269 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -29,9 +29,6 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
29 29
30 if (inode) { 30 if (inode) {
31 inode->i_mode = mode; 31 inode->i_mode = mode;
32 inode->i_uid = 0;
33 inode->i_gid = 0;
34 inode->i_blocks = 0;
35 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 32 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
36 } 33 }
37 return inode; 34 return inode;
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 691b3adeb870..f5a662a50acb 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -191,26 +191,17 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header)
191static int __init dmar_parse_dev(struct dmar_drhd_unit *dmaru) 191static int __init dmar_parse_dev(struct dmar_drhd_unit *dmaru)
192{ 192{
193 struct acpi_dmar_hardware_unit *drhd; 193 struct acpi_dmar_hardware_unit *drhd;
194 static int include_all;
195 int ret = 0; 194 int ret = 0;
196 195
197 drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr; 196 drhd = (struct acpi_dmar_hardware_unit *) dmaru->hdr;
198 197
199 if (!dmaru->include_all) 198 if (dmaru->include_all)
200 ret = dmar_parse_dev_scope((void *)(drhd + 1), 199 return 0;
200
201 ret = dmar_parse_dev_scope((void *)(drhd + 1),
201 ((void *)drhd) + drhd->header.length, 202 ((void *)drhd) + drhd->header.length,
202 &dmaru->devices_cnt, &dmaru->devices, 203 &dmaru->devices_cnt, &dmaru->devices,
203 drhd->segment); 204 drhd->segment);
204 else {
205 /* Only allow one INCLUDE_ALL */
206 if (include_all) {
207 printk(KERN_WARNING PREFIX "Only one INCLUDE_ALL "
208 "device scope is allowed\n");
209 ret = -EINVAL;
210 }
211 include_all = 1;
212 }
213
214 if (ret) { 205 if (ret) {
215 list_del(&dmaru->list); 206 list_del(&dmaru->list);
216 kfree(dmaru); 207 kfree(dmaru);
@@ -384,12 +375,21 @@ int dmar_pci_device_match(struct pci_dev *devices[], int cnt,
384struct dmar_drhd_unit * 375struct dmar_drhd_unit *
385dmar_find_matched_drhd_unit(struct pci_dev *dev) 376dmar_find_matched_drhd_unit(struct pci_dev *dev)
386{ 377{
387 struct dmar_drhd_unit *drhd = NULL; 378 struct dmar_drhd_unit *dmaru = NULL;
379 struct acpi_dmar_hardware_unit *drhd;
388 380
389 list_for_each_entry(drhd, &dmar_drhd_units, list) { 381 list_for_each_entry(dmaru, &dmar_drhd_units, list) {
390 if (drhd->include_all || dmar_pci_device_match(drhd->devices, 382 drhd = container_of(dmaru->hdr,
391 drhd->devices_cnt, dev)) 383 struct acpi_dmar_hardware_unit,
392 return drhd; 384 header);
385
386 if (dmaru->include_all &&
387 drhd->segment == pci_domain_nr(dev->bus))
388 return dmaru;
389
390 if (dmar_pci_device_match(dmaru->devices,
391 dmaru->devices_cnt, dev))
392 return dmaru;
393 } 393 }
394 394
395 return NULL; 395 return NULL;
@@ -491,6 +491,7 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
491 int map_size; 491 int map_size;
492 u32 ver; 492 u32 ver;
493 static int iommu_allocated = 0; 493 static int iommu_allocated = 0;
494 int agaw;
494 495
495 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); 496 iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
496 if (!iommu) 497 if (!iommu)
@@ -506,6 +507,15 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
506 iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); 507 iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG);
507 iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); 508 iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG);
508 509
510 agaw = iommu_calculate_agaw(iommu);
511 if (agaw < 0) {
512 printk(KERN_ERR
513 "Cannot get a valid agaw for iommu (seq_id = %d)\n",
514 iommu->seq_id);
515 goto error;
516 }
517 iommu->agaw = agaw;
518
509 /* the registers might be more than one page */ 519 /* the registers might be more than one page */
510 map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), 520 map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
511 cap_max_fault_reg_offset(iommu->cap)); 521 cap_max_fault_reg_offset(iommu->cap));
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 5c8baa43ac9c..235fb7a5a8a5 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -27,7 +27,6 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/irq.h> 28#include <linux/irq.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/sysdev.h>
31#include <linux/spinlock.h> 30#include <linux/spinlock.h>
32#include <linux/pci.h> 31#include <linux/pci.h>
33#include <linux/dmar.h> 32#include <linux/dmar.h>
@@ -35,6 +34,7 @@
35#include <linux/mempool.h> 34#include <linux/mempool.h>
36#include <linux/timer.h> 35#include <linux/timer.h>
37#include <linux/iova.h> 36#include <linux/iova.h>
37#include <linux/iommu.h>
38#include <linux/intel-iommu.h> 38#include <linux/intel-iommu.h>
39#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
40#include <asm/iommu.h> 40#include <asm/iommu.h>
@@ -54,6 +54,195 @@
54 54
55#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) 55#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
56 56
57#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
58#define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK)
59#define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK)
60
61/* global iommu list, set NULL for ignored DMAR units */
62static struct intel_iommu **g_iommus;
63
64/*
65 * 0: Present
66 * 1-11: Reserved
67 * 12-63: Context Ptr (12 - (haw-1))
68 * 64-127: Reserved
69 */
70struct root_entry {
71 u64 val;
72 u64 rsvd1;
73};
74#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
75static inline bool root_present(struct root_entry *root)
76{
77 return (root->val & 1);
78}
79static inline void set_root_present(struct root_entry *root)
80{
81 root->val |= 1;
82}
83static inline void set_root_value(struct root_entry *root, unsigned long value)
84{
85 root->val |= value & VTD_PAGE_MASK;
86}
87
88static inline struct context_entry *
89get_context_addr_from_root(struct root_entry *root)
90{
91 return (struct context_entry *)
92 (root_present(root)?phys_to_virt(
93 root->val & VTD_PAGE_MASK) :
94 NULL);
95}
96
97/*
98 * low 64 bits:
99 * 0: present
100 * 1: fault processing disable
101 * 2-3: translation type
102 * 12-63: address space root
103 * high 64 bits:
104 * 0-2: address width
105 * 3-6: aval
106 * 8-23: domain id
107 */
108struct context_entry {
109 u64 lo;
110 u64 hi;
111};
112
113static inline bool context_present(struct context_entry *context)
114{
115 return (context->lo & 1);
116}
117static inline void context_set_present(struct context_entry *context)
118{
119 context->lo |= 1;
120}
121
122static inline void context_set_fault_enable(struct context_entry *context)
123{
124 context->lo &= (((u64)-1) << 2) | 1;
125}
126
127#define CONTEXT_TT_MULTI_LEVEL 0
128
129static inline void context_set_translation_type(struct context_entry *context,
130 unsigned long value)
131{
132 context->lo &= (((u64)-1) << 4) | 3;
133 context->lo |= (value & 3) << 2;
134}
135
136static inline void context_set_address_root(struct context_entry *context,
137 unsigned long value)
138{
139 context->lo |= value & VTD_PAGE_MASK;
140}
141
142static inline void context_set_address_width(struct context_entry *context,
143 unsigned long value)
144{
145 context->hi |= value & 7;
146}
147
148static inline void context_set_domain_id(struct context_entry *context,
149 unsigned long value)
150{
151 context->hi |= (value & ((1 << 16) - 1)) << 8;
152}
153
154static inline void context_clear_entry(struct context_entry *context)
155{
156 context->lo = 0;
157 context->hi = 0;
158}
159
160/*
161 * 0: readable
162 * 1: writable
163 * 2-6: reserved
164 * 7: super page
165 * 8-11: available
166 * 12-63: Host physcial address
167 */
168struct dma_pte {
169 u64 val;
170};
171
172static inline void dma_clear_pte(struct dma_pte *pte)
173{
174 pte->val = 0;
175}
176
177static inline void dma_set_pte_readable(struct dma_pte *pte)
178{
179 pte->val |= DMA_PTE_READ;
180}
181
182static inline void dma_set_pte_writable(struct dma_pte *pte)
183{
184 pte->val |= DMA_PTE_WRITE;
185}
186
187static inline void dma_set_pte_prot(struct dma_pte *pte, unsigned long prot)
188{
189 pte->val = (pte->val & ~3) | (prot & 3);
190}
191
192static inline u64 dma_pte_addr(struct dma_pte *pte)
193{
194 return (pte->val & VTD_PAGE_MASK);
195}
196
197static inline void dma_set_pte_addr(struct dma_pte *pte, u64 addr)
198{
199 pte->val |= (addr & VTD_PAGE_MASK);
200}
201
202static inline bool dma_pte_present(struct dma_pte *pte)
203{
204 return (pte->val & 3) != 0;
205}
206
207/* devices under the same p2p bridge are owned in one domain */
208#define DOMAIN_FLAG_P2P_MULTIPLE_DEVICES (1 << 0)
209
210/* domain represents a virtual machine, more than one devices
211 * across iommus may be owned in one domain, e.g. kvm guest.
212 */
213#define DOMAIN_FLAG_VIRTUAL_MACHINE (1 << 1)
214
215struct dmar_domain {
216 int id; /* domain id */
217 unsigned long iommu_bmp; /* bitmap of iommus this domain uses*/
218
219 struct list_head devices; /* all devices' list */
220 struct iova_domain iovad; /* iova's that belong to this domain */
221
222 struct dma_pte *pgd; /* virtual address */
223 spinlock_t mapping_lock; /* page table lock */
224 int gaw; /* max guest address width */
225
226 /* adjusted guest address width, 0 is level 2 30-bit */
227 int agaw;
228
229 int flags; /* flags to find out type of domain */
230
231 int iommu_coherency;/* indicate coherency of iommu access */
232 int iommu_count; /* reference count of iommu */
233 spinlock_t iommu_lock; /* protect iommu set in domain */
234 u64 max_addr; /* maximum mapped address */
235};
236
237/* PCI domain-device relationship */
238struct device_domain_info {
239 struct list_head link; /* link to domain siblings */
240 struct list_head global; /* link to global list */
241 u8 bus; /* PCI bus numer */
242 u8 devfn; /* PCI devfn number */
243 struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */
244 struct dmar_domain *domain; /* pointer to domain */
245};
57 246
58static void flush_unmaps_timeout(unsigned long data); 247static void flush_unmaps_timeout(unsigned long data);
59 248
@@ -88,6 +277,8 @@ static int intel_iommu_strict;
88static DEFINE_SPINLOCK(device_domain_lock); 277static DEFINE_SPINLOCK(device_domain_lock);
89static LIST_HEAD(device_domain_list); 278static LIST_HEAD(device_domain_list);
90 279
280static struct iommu_ops intel_iommu_ops;
281
91static int __init intel_iommu_setup(char *str) 282static int __init intel_iommu_setup(char *str)
92{ 283{
93 if (!str) 284 if (!str)
@@ -184,6 +375,87 @@ void free_iova_mem(struct iova *iova)
184 kmem_cache_free(iommu_iova_cache, iova); 375 kmem_cache_free(iommu_iova_cache, iova);
185} 376}
186 377
378
379static inline int width_to_agaw(int width);
380
381/* calculate agaw for each iommu.
382 * "SAGAW" may be different across iommus, use a default agaw, and
383 * get a supported less agaw for iommus that don't support the default agaw.
384 */
385int iommu_calculate_agaw(struct intel_iommu *iommu)
386{
387 unsigned long sagaw;
388 int agaw = -1;
389
390 sagaw = cap_sagaw(iommu->cap);
391 for (agaw = width_to_agaw(DEFAULT_DOMAIN_ADDRESS_WIDTH);
392 agaw >= 0; agaw--) {
393 if (test_bit(agaw, &sagaw))
394 break;
395 }
396
397 return agaw;
398}
399
400/* in native case, each domain is related to only one iommu */
401static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain)
402{
403 int iommu_id;
404
405 BUG_ON(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE);
406
407 iommu_id = find_first_bit(&domain->iommu_bmp, g_num_of_iommus);
408 if (iommu_id < 0 || iommu_id >= g_num_of_iommus)
409 return NULL;
410
411 return g_iommus[iommu_id];
412}
413
414/* "Coherency" capability may be different across iommus */
415static void domain_update_iommu_coherency(struct dmar_domain *domain)
416{
417 int i;
418
419 domain->iommu_coherency = 1;
420
421 i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus);
422 for (; i < g_num_of_iommus; ) {
423 if (!ecap_coherent(g_iommus[i]->ecap)) {
424 domain->iommu_coherency = 0;
425 break;
426 }
427 i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1);
428 }
429}
430
431static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn)
432{
433 struct dmar_drhd_unit *drhd = NULL;
434 int i;
435
436 for_each_drhd_unit(drhd) {
437 if (drhd->ignored)
438 continue;
439
440 for (i = 0; i < drhd->devices_cnt; i++)
441 if (drhd->devices[i]->bus->number == bus &&
442 drhd->devices[i]->devfn == devfn)
443 return drhd->iommu;
444
445 if (drhd->include_all)
446 return drhd->iommu;
447 }
448
449 return NULL;
450}
451
452static void domain_flush_cache(struct dmar_domain *domain,
453 void *addr, int size)
454{
455 if (!domain->iommu_coherency)
456 clflush_cache_range(addr, size);
457}
458
187/* Gets context entry for a given bus and devfn */ 459/* Gets context entry for a given bus and devfn */
188static struct context_entry * device_to_context_entry(struct intel_iommu *iommu, 460static struct context_entry * device_to_context_entry(struct intel_iommu *iommu,
189 u8 bus, u8 devfn) 461 u8 bus, u8 devfn)
@@ -226,7 +498,7 @@ static int device_context_mapped(struct intel_iommu *iommu, u8 bus, u8 devfn)
226 ret = 0; 498 ret = 0;
227 goto out; 499 goto out;
228 } 500 }
229 ret = context_present(context[devfn]); 501 ret = context_present(&context[devfn]);
230out: 502out:
231 spin_unlock_irqrestore(&iommu->lock, flags); 503 spin_unlock_irqrestore(&iommu->lock, flags);
232 return ret; 504 return ret;
@@ -242,7 +514,7 @@ static void clear_context_table(struct intel_iommu *iommu, u8 bus, u8 devfn)
242 root = &iommu->root_entry[bus]; 514 root = &iommu->root_entry[bus];
243 context = get_context_addr_from_root(root); 515 context = get_context_addr_from_root(root);
244 if (context) { 516 if (context) {
245 context_clear_entry(context[devfn]); 517 context_clear_entry(&context[devfn]);
246 __iommu_flush_cache(iommu, &context[devfn], \ 518 __iommu_flush_cache(iommu, &context[devfn], \
247 sizeof(*context)); 519 sizeof(*context));
248 } 520 }
@@ -339,7 +611,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
339 if (level == 1) 611 if (level == 1)
340 break; 612 break;
341 613
342 if (!dma_pte_present(*pte)) { 614 if (!dma_pte_present(pte)) {
343 tmp_page = alloc_pgtable_page(); 615 tmp_page = alloc_pgtable_page();
344 616
345 if (!tmp_page) { 617 if (!tmp_page) {
@@ -347,18 +619,17 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
347 flags); 619 flags);
348 return NULL; 620 return NULL;
349 } 621 }
350 __iommu_flush_cache(domain->iommu, tmp_page, 622 domain_flush_cache(domain, tmp_page, PAGE_SIZE);
351 PAGE_SIZE); 623 dma_set_pte_addr(pte, virt_to_phys(tmp_page));
352 dma_set_pte_addr(*pte, virt_to_phys(tmp_page));
353 /* 624 /*
354 * high level table always sets r/w, last level page 625 * high level table always sets r/w, last level page
355 * table control read/write 626 * table control read/write
356 */ 627 */
357 dma_set_pte_readable(*pte); 628 dma_set_pte_readable(pte);
358 dma_set_pte_writable(*pte); 629 dma_set_pte_writable(pte);
359 __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); 630 domain_flush_cache(domain, pte, sizeof(*pte));
360 } 631 }
361 parent = phys_to_virt(dma_pte_addr(*pte)); 632 parent = phys_to_virt(dma_pte_addr(pte));
362 level--; 633 level--;
363 } 634 }
364 635
@@ -381,9 +652,9 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr,
381 if (level == total) 652 if (level == total)
382 return pte; 653 return pte;
383 654
384 if (!dma_pte_present(*pte)) 655 if (!dma_pte_present(pte))
385 break; 656 break;
386 parent = phys_to_virt(dma_pte_addr(*pte)); 657 parent = phys_to_virt(dma_pte_addr(pte));
387 total--; 658 total--;
388 } 659 }
389 return NULL; 660 return NULL;
@@ -398,8 +669,8 @@ static void dma_pte_clear_one(struct dmar_domain *domain, u64 addr)
398 pte = dma_addr_level_pte(domain, addr, 1); 669 pte = dma_addr_level_pte(domain, addr, 1);
399 670
400 if (pte) { 671 if (pte) {
401 dma_clear_pte(*pte); 672 dma_clear_pte(pte);
402 __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); 673 domain_flush_cache(domain, pte, sizeof(*pte));
403 } 674 }
404} 675}
405 676
@@ -445,10 +716,9 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
445 pte = dma_addr_level_pte(domain, tmp, level); 716 pte = dma_addr_level_pte(domain, tmp, level);
446 if (pte) { 717 if (pte) {
447 free_pgtable_page( 718 free_pgtable_page(
448 phys_to_virt(dma_pte_addr(*pte))); 719 phys_to_virt(dma_pte_addr(pte)));
449 dma_clear_pte(*pte); 720 dma_clear_pte(pte);
450 __iommu_flush_cache(domain->iommu, 721 domain_flush_cache(domain, pte, sizeof(*pte));
451 pte, sizeof(*pte));
452 } 722 }
453 tmp += level_size(level); 723 tmp += level_size(level);
454 } 724 }
@@ -950,17 +1220,28 @@ static int iommu_init_domains(struct intel_iommu *iommu)
950 1220
951 1221
952static void domain_exit(struct dmar_domain *domain); 1222static void domain_exit(struct dmar_domain *domain);
1223static void vm_domain_exit(struct dmar_domain *domain);
953 1224
954void free_dmar_iommu(struct intel_iommu *iommu) 1225void free_dmar_iommu(struct intel_iommu *iommu)
955{ 1226{
956 struct dmar_domain *domain; 1227 struct dmar_domain *domain;
957 int i; 1228 int i;
1229 unsigned long flags;
958 1230
959 i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap)); 1231 i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap));
960 for (; i < cap_ndoms(iommu->cap); ) { 1232 for (; i < cap_ndoms(iommu->cap); ) {
961 domain = iommu->domains[i]; 1233 domain = iommu->domains[i];
962 clear_bit(i, iommu->domain_ids); 1234 clear_bit(i, iommu->domain_ids);
963 domain_exit(domain); 1235
1236 spin_lock_irqsave(&domain->iommu_lock, flags);
1237 if (--domain->iommu_count == 0) {
1238 if (domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE)
1239 vm_domain_exit(domain);
1240 else
1241 domain_exit(domain);
1242 }
1243 spin_unlock_irqrestore(&domain->iommu_lock, flags);
1244
964 i = find_next_bit(iommu->domain_ids, 1245 i = find_next_bit(iommu->domain_ids,
965 cap_ndoms(iommu->cap), i+1); 1246 cap_ndoms(iommu->cap), i+1);
966 } 1247 }
@@ -978,6 +1259,17 @@ void free_dmar_iommu(struct intel_iommu *iommu)
978 kfree(iommu->domains); 1259 kfree(iommu->domains);
979 kfree(iommu->domain_ids); 1260 kfree(iommu->domain_ids);
980 1261
1262 g_iommus[iommu->seq_id] = NULL;
1263
1264 /* if all iommus are freed, free g_iommus */
1265 for (i = 0; i < g_num_of_iommus; i++) {
1266 if (g_iommus[i])
1267 break;
1268 }
1269
1270 if (i == g_num_of_iommus)
1271 kfree(g_iommus);
1272
981 /* free context mapping */ 1273 /* free context mapping */
982 free_context_table(iommu); 1274 free_context_table(iommu);
983} 1275}
@@ -1006,7 +1298,9 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu)
1006 1298
1007 set_bit(num, iommu->domain_ids); 1299 set_bit(num, iommu->domain_ids);
1008 domain->id = num; 1300 domain->id = num;
1009 domain->iommu = iommu; 1301 memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
1302 set_bit(iommu->seq_id, &domain->iommu_bmp);
1303 domain->flags = 0;
1010 iommu->domains[num] = domain; 1304 iommu->domains[num] = domain;
1011 spin_unlock_irqrestore(&iommu->lock, flags); 1305 spin_unlock_irqrestore(&iommu->lock, flags);
1012 1306
@@ -1016,10 +1310,13 @@ static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu)
1016static void iommu_free_domain(struct dmar_domain *domain) 1310static void iommu_free_domain(struct dmar_domain *domain)
1017{ 1311{
1018 unsigned long flags; 1312 unsigned long flags;
1313 struct intel_iommu *iommu;
1314
1315 iommu = domain_get_iommu(domain);
1019 1316
1020 spin_lock_irqsave(&domain->iommu->lock, flags); 1317 spin_lock_irqsave(&iommu->lock, flags);
1021 clear_bit(domain->id, domain->iommu->domain_ids); 1318 clear_bit(domain->id, iommu->domain_ids);
1022 spin_unlock_irqrestore(&domain->iommu->lock, flags); 1319 spin_unlock_irqrestore(&iommu->lock, flags);
1023} 1320}
1024 1321
1025static struct iova_domain reserved_iova_list; 1322static struct iova_domain reserved_iova_list;
@@ -1094,11 +1391,12 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1094 1391
1095 init_iova_domain(&domain->iovad, DMA_32BIT_PFN); 1392 init_iova_domain(&domain->iovad, DMA_32BIT_PFN);
1096 spin_lock_init(&domain->mapping_lock); 1393 spin_lock_init(&domain->mapping_lock);
1394 spin_lock_init(&domain->iommu_lock);
1097 1395
1098 domain_reserve_special_ranges(domain); 1396 domain_reserve_special_ranges(domain);
1099 1397
1100 /* calculate AGAW */ 1398 /* calculate AGAW */
1101 iommu = domain->iommu; 1399 iommu = domain_get_iommu(domain);
1102 if (guest_width > cap_mgaw(iommu->cap)) 1400 if (guest_width > cap_mgaw(iommu->cap))
1103 guest_width = cap_mgaw(iommu->cap); 1401 guest_width = cap_mgaw(iommu->cap);
1104 domain->gaw = guest_width; 1402 domain->gaw = guest_width;
@@ -1115,6 +1413,13 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1115 domain->agaw = agaw; 1413 domain->agaw = agaw;
1116 INIT_LIST_HEAD(&domain->devices); 1414 INIT_LIST_HEAD(&domain->devices);
1117 1415
1416 if (ecap_coherent(iommu->ecap))
1417 domain->iommu_coherency = 1;
1418 else
1419 domain->iommu_coherency = 0;
1420
1421 domain->iommu_count = 1;
1422
1118 /* always allocate the top pgd */ 1423 /* always allocate the top pgd */
1119 domain->pgd = (struct dma_pte *)alloc_pgtable_page(); 1424 domain->pgd = (struct dma_pte *)alloc_pgtable_page();
1120 if (!domain->pgd) 1425 if (!domain->pgd)
@@ -1151,28 +1456,82 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
1151 u8 bus, u8 devfn) 1456 u8 bus, u8 devfn)
1152{ 1457{
1153 struct context_entry *context; 1458 struct context_entry *context;
1154 struct intel_iommu *iommu = domain->iommu;
1155 unsigned long flags; 1459 unsigned long flags;
1460 struct intel_iommu *iommu;
1461 struct dma_pte *pgd;
1462 unsigned long num;
1463 unsigned long ndomains;
1464 int id;
1465 int agaw;
1156 1466
1157 pr_debug("Set context mapping for %02x:%02x.%d\n", 1467 pr_debug("Set context mapping for %02x:%02x.%d\n",
1158 bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 1468 bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
1159 BUG_ON(!domain->pgd); 1469 BUG_ON(!domain->pgd);
1470
1471 iommu = device_to_iommu(bus, devfn);
1472 if (!iommu)
1473 return -ENODEV;
1474
1160 context = device_to_context_entry(iommu, bus, devfn); 1475 context = device_to_context_entry(iommu, bus, devfn);
1161 if (!context) 1476 if (!context)
1162 return -ENOMEM; 1477 return -ENOMEM;
1163 spin_lock_irqsave(&iommu->lock, flags); 1478 spin_lock_irqsave(&iommu->lock, flags);
1164 if (context_present(*context)) { 1479 if (context_present(context)) {
1165 spin_unlock_irqrestore(&iommu->lock, flags); 1480 spin_unlock_irqrestore(&iommu->lock, flags);
1166 return 0; 1481 return 0;
1167 } 1482 }
1168 1483
1169 context_set_domain_id(*context, domain->id); 1484 id = domain->id;
1170 context_set_address_width(*context, domain->agaw); 1485 pgd = domain->pgd;
1171 context_set_address_root(*context, virt_to_phys(domain->pgd)); 1486
1172 context_set_translation_type(*context, CONTEXT_TT_MULTI_LEVEL); 1487 if (domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) {
1173 context_set_fault_enable(*context); 1488 int found = 0;
1174 context_set_present(*context); 1489
1175 __iommu_flush_cache(iommu, context, sizeof(*context)); 1490 /* find an available domain id for this device in iommu */
1491 ndomains = cap_ndoms(iommu->cap);
1492 num = find_first_bit(iommu->domain_ids, ndomains);
1493 for (; num < ndomains; ) {
1494 if (iommu->domains[num] == domain) {
1495 id = num;
1496 found = 1;
1497 break;
1498 }
1499 num = find_next_bit(iommu->domain_ids,
1500 cap_ndoms(iommu->cap), num+1);
1501 }
1502
1503 if (found == 0) {
1504 num = find_first_zero_bit(iommu->domain_ids, ndomains);
1505 if (num >= ndomains) {
1506 spin_unlock_irqrestore(&iommu->lock, flags);
1507 printk(KERN_ERR "IOMMU: no free domain ids\n");
1508 return -EFAULT;
1509 }
1510
1511 set_bit(num, iommu->domain_ids);
1512 iommu->domains[num] = domain;
1513 id = num;
1514 }
1515
1516 /* Skip top levels of page tables for
1517 * iommu which has less agaw than default.
1518 */
1519 for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
1520 pgd = phys_to_virt(dma_pte_addr(pgd));
1521 if (!dma_pte_present(pgd)) {
1522 spin_unlock_irqrestore(&iommu->lock, flags);
1523 return -ENOMEM;
1524 }
1525 }
1526 }
1527
1528 context_set_domain_id(context, id);
1529 context_set_address_width(context, iommu->agaw);
1530 context_set_address_root(context, virt_to_phys(pgd));
1531 context_set_translation_type(context, CONTEXT_TT_MULTI_LEVEL);
1532 context_set_fault_enable(context);
1533 context_set_present(context);
1534 domain_flush_cache(domain, context, sizeof(*context));
1176 1535
1177 /* it's a non-present to present mapping */ 1536 /* it's a non-present to present mapping */
1178 if (iommu->flush.flush_context(iommu, domain->id, 1537 if (iommu->flush.flush_context(iommu, domain->id,
@@ -1183,6 +1542,13 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
1183 iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0); 1542 iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_DSI_FLUSH, 0);
1184 1543
1185 spin_unlock_irqrestore(&iommu->lock, flags); 1544 spin_unlock_irqrestore(&iommu->lock, flags);
1545
1546 spin_lock_irqsave(&domain->iommu_lock, flags);
1547 if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) {
1548 domain->iommu_count++;
1549 domain_update_iommu_coherency(domain);
1550 }
1551 spin_unlock_irqrestore(&domain->iommu_lock, flags);
1186 return 0; 1552 return 0;
1187} 1553}
1188 1554
@@ -1218,13 +1584,17 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev)
1218 tmp->bus->number, tmp->devfn); 1584 tmp->bus->number, tmp->devfn);
1219} 1585}
1220 1586
1221static int domain_context_mapped(struct dmar_domain *domain, 1587static int domain_context_mapped(struct pci_dev *pdev)
1222 struct pci_dev *pdev)
1223{ 1588{
1224 int ret; 1589 int ret;
1225 struct pci_dev *tmp, *parent; 1590 struct pci_dev *tmp, *parent;
1591 struct intel_iommu *iommu;
1592
1593 iommu = device_to_iommu(pdev->bus->number, pdev->devfn);
1594 if (!iommu)
1595 return -ENODEV;
1226 1596
1227 ret = device_context_mapped(domain->iommu, 1597 ret = device_context_mapped(iommu,
1228 pdev->bus->number, pdev->devfn); 1598 pdev->bus->number, pdev->devfn);
1229 if (!ret) 1599 if (!ret)
1230 return ret; 1600 return ret;
@@ -1235,17 +1605,17 @@ static int domain_context_mapped(struct dmar_domain *domain,
1235 /* Secondary interface's bus number and devfn 0 */ 1605 /* Secondary interface's bus number and devfn 0 */
1236 parent = pdev->bus->self; 1606 parent = pdev->bus->self;
1237 while (parent != tmp) { 1607 while (parent != tmp) {
1238 ret = device_context_mapped(domain->iommu, parent->bus->number, 1608 ret = device_context_mapped(iommu, parent->bus->number,
1239 parent->devfn); 1609 parent->devfn);
1240 if (!ret) 1610 if (!ret)
1241 return ret; 1611 return ret;
1242 parent = parent->bus->self; 1612 parent = parent->bus->self;
1243 } 1613 }
1244 if (tmp->is_pcie) 1614 if (tmp->is_pcie)
1245 return device_context_mapped(domain->iommu, 1615 return device_context_mapped(iommu,
1246 tmp->subordinate->number, 0); 1616 tmp->subordinate->number, 0);
1247 else 1617 else
1248 return device_context_mapped(domain->iommu, 1618 return device_context_mapped(iommu,
1249 tmp->bus->number, tmp->devfn); 1619 tmp->bus->number, tmp->devfn);
1250} 1620}
1251 1621
@@ -1273,22 +1643,25 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
1273 /* We don't need lock here, nobody else 1643 /* We don't need lock here, nobody else
1274 * touches the iova range 1644 * touches the iova range
1275 */ 1645 */
1276 BUG_ON(dma_pte_addr(*pte)); 1646 BUG_ON(dma_pte_addr(pte));
1277 dma_set_pte_addr(*pte, start_pfn << VTD_PAGE_SHIFT); 1647 dma_set_pte_addr(pte, start_pfn << VTD_PAGE_SHIFT);
1278 dma_set_pte_prot(*pte, prot); 1648 dma_set_pte_prot(pte, prot);
1279 __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); 1649 domain_flush_cache(domain, pte, sizeof(*pte));
1280 start_pfn++; 1650 start_pfn++;
1281 index++; 1651 index++;
1282 } 1652 }
1283 return 0; 1653 return 0;
1284} 1654}
1285 1655
1286static void detach_domain_for_dev(struct dmar_domain *domain, u8 bus, u8 devfn) 1656static void iommu_detach_dev(struct intel_iommu *iommu, u8 bus, u8 devfn)
1287{ 1657{
1288 clear_context_table(domain->iommu, bus, devfn); 1658 if (!iommu)
1289 domain->iommu->flush.flush_context(domain->iommu, 0, 0, 0, 1659 return;
1660
1661 clear_context_table(iommu, bus, devfn);
1662 iommu->flush.flush_context(iommu, 0, 0, 0,
1290 DMA_CCMD_GLOBAL_INVL, 0); 1663 DMA_CCMD_GLOBAL_INVL, 0);
1291 domain->iommu->flush.flush_iotlb(domain->iommu, 0, 0, 0, 1664 iommu->flush.flush_iotlb(iommu, 0, 0, 0,
1292 DMA_TLB_GLOBAL_FLUSH, 0); 1665 DMA_TLB_GLOBAL_FLUSH, 0);
1293} 1666}
1294 1667
@@ -1296,6 +1669,7 @@ static void domain_remove_dev_info(struct dmar_domain *domain)
1296{ 1669{
1297 struct device_domain_info *info; 1670 struct device_domain_info *info;
1298 unsigned long flags; 1671 unsigned long flags;
1672 struct intel_iommu *iommu;
1299 1673
1300 spin_lock_irqsave(&device_domain_lock, flags); 1674 spin_lock_irqsave(&device_domain_lock, flags);
1301 while (!list_empty(&domain->devices)) { 1675 while (!list_empty(&domain->devices)) {
@@ -1307,7 +1681,8 @@ static void domain_remove_dev_info(struct dmar_domain *domain)
1307 info->dev->dev.archdata.iommu = NULL; 1681 info->dev->dev.archdata.iommu = NULL;
1308 spin_unlock_irqrestore(&device_domain_lock, flags); 1682 spin_unlock_irqrestore(&device_domain_lock, flags);
1309 1683
1310 detach_domain_for_dev(info->domain, info->bus, info->devfn); 1684 iommu = device_to_iommu(info->bus, info->devfn);
1685 iommu_detach_dev(iommu, info->bus, info->devfn);
1311 free_devinfo_mem(info); 1686 free_devinfo_mem(info);
1312 1687
1313 spin_lock_irqsave(&device_domain_lock, flags); 1688 spin_lock_irqsave(&device_domain_lock, flags);
@@ -1400,7 +1775,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
1400 info->dev = NULL; 1775 info->dev = NULL;
1401 info->domain = domain; 1776 info->domain = domain;
1402 /* This domain is shared by devices under p2p bridge */ 1777 /* This domain is shared by devices under p2p bridge */
1403 domain->flags |= DOMAIN_FLAG_MULTIPLE_DEVICES; 1778 domain->flags |= DOMAIN_FLAG_P2P_MULTIPLE_DEVICES;
1404 1779
1405 /* pcie-to-pci bridge already has a domain, uses it */ 1780 /* pcie-to-pci bridge already has a domain, uses it */
1406 found = NULL; 1781 found = NULL;
@@ -1563,6 +1938,11 @@ static void __init iommu_prepare_gfx_mapping(void)
1563 printk(KERN_ERR "IOMMU: mapping reserved region failed\n"); 1938 printk(KERN_ERR "IOMMU: mapping reserved region failed\n");
1564 } 1939 }
1565} 1940}
1941#else /* !CONFIG_DMAR_GFX_WA */
1942static inline void iommu_prepare_gfx_mapping(void)
1943{
1944 return;
1945}
1566#endif 1946#endif
1567 1947
1568#ifdef CONFIG_DMAR_FLOPPY_WA 1948#ifdef CONFIG_DMAR_FLOPPY_WA
@@ -1590,7 +1970,7 @@ static inline void iommu_prepare_isa(void)
1590} 1970}
1591#endif /* !CONFIG_DMAR_FLPY_WA */ 1971#endif /* !CONFIG_DMAR_FLPY_WA */
1592 1972
1593int __init init_dmars(void) 1973static int __init init_dmars(void)
1594{ 1974{
1595 struct dmar_drhd_unit *drhd; 1975 struct dmar_drhd_unit *drhd;
1596 struct dmar_rmrr_unit *rmrr; 1976 struct dmar_rmrr_unit *rmrr;
@@ -1613,9 +1993,18 @@ int __init init_dmars(void)
1613 */ 1993 */
1614 } 1994 }
1615 1995
1996 g_iommus = kcalloc(g_num_of_iommus, sizeof(struct intel_iommu *),
1997 GFP_KERNEL);
1998 if (!g_iommus) {
1999 printk(KERN_ERR "Allocating global iommu array failed\n");
2000 ret = -ENOMEM;
2001 goto error;
2002 }
2003
1616 deferred_flush = kzalloc(g_num_of_iommus * 2004 deferred_flush = kzalloc(g_num_of_iommus *
1617 sizeof(struct deferred_flush_tables), GFP_KERNEL); 2005 sizeof(struct deferred_flush_tables), GFP_KERNEL);
1618 if (!deferred_flush) { 2006 if (!deferred_flush) {
2007 kfree(g_iommus);
1619 ret = -ENOMEM; 2008 ret = -ENOMEM;
1620 goto error; 2009 goto error;
1621 } 2010 }
@@ -1625,6 +2014,7 @@ int __init init_dmars(void)
1625 continue; 2014 continue;
1626 2015
1627 iommu = drhd->iommu; 2016 iommu = drhd->iommu;
2017 g_iommus[iommu->seq_id] = iommu;
1628 2018
1629 ret = iommu_init_domains(iommu); 2019 ret = iommu_init_domains(iommu);
1630 if (ret) 2020 if (ret)
@@ -1737,6 +2127,7 @@ error:
1737 iommu = drhd->iommu; 2127 iommu = drhd->iommu;
1738 free_iommu(iommu); 2128 free_iommu(iommu);
1739 } 2129 }
2130 kfree(g_iommus);
1740 return ret; 2131 return ret;
1741} 2132}
1742 2133
@@ -1805,7 +2196,7 @@ get_valid_domain_for_dev(struct pci_dev *pdev)
1805 } 2196 }
1806 2197
1807 /* make sure context mapping is ok */ 2198 /* make sure context mapping is ok */
1808 if (unlikely(!domain_context_mapped(domain, pdev))) { 2199 if (unlikely(!domain_context_mapped(pdev))) {
1809 ret = domain_context_mapping(domain, pdev); 2200 ret = domain_context_mapping(domain, pdev);
1810 if (ret) { 2201 if (ret) {
1811 printk(KERN_ERR 2202 printk(KERN_ERR
@@ -1827,6 +2218,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
1827 struct iova *iova; 2218 struct iova *iova;
1828 int prot = 0; 2219 int prot = 0;
1829 int ret; 2220 int ret;
2221 struct intel_iommu *iommu;
1830 2222
1831 BUG_ON(dir == DMA_NONE); 2223 BUG_ON(dir == DMA_NONE);
1832 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2224 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
@@ -1836,6 +2228,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
1836 if (!domain) 2228 if (!domain)
1837 return 0; 2229 return 0;
1838 2230
2231 iommu = domain_get_iommu(domain);
1839 size = aligned_size((u64)paddr, size); 2232 size = aligned_size((u64)paddr, size);
1840 2233
1841 iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask); 2234 iova = __intel_alloc_iova(hwdev, domain, size, pdev->dma_mask);
@@ -1849,7 +2242,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
1849 * mappings.. 2242 * mappings..
1850 */ 2243 */
1851 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ 2244 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \
1852 !cap_zlr(domain->iommu->cap)) 2245 !cap_zlr(iommu->cap))
1853 prot |= DMA_PTE_READ; 2246 prot |= DMA_PTE_READ;
1854 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) 2247 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
1855 prot |= DMA_PTE_WRITE; 2248 prot |= DMA_PTE_WRITE;
@@ -1865,10 +2258,10 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
1865 goto error; 2258 goto error;
1866 2259
1867 /* it's a non-present to present mapping */ 2260 /* it's a non-present to present mapping */
1868 ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, 2261 ret = iommu_flush_iotlb_psi(iommu, domain->id,
1869 start_paddr, size >> VTD_PAGE_SHIFT, 1); 2262 start_paddr, size >> VTD_PAGE_SHIFT, 1);
1870 if (ret) 2263 if (ret)
1871 iommu_flush_write_buffer(domain->iommu); 2264 iommu_flush_write_buffer(iommu);
1872 2265
1873 return start_paddr + ((u64)paddr & (~PAGE_MASK)); 2266 return start_paddr + ((u64)paddr & (~PAGE_MASK));
1874 2267
@@ -1895,10 +2288,11 @@ static void flush_unmaps(void)
1895 2288
1896 /* just flush them all */ 2289 /* just flush them all */
1897 for (i = 0; i < g_num_of_iommus; i++) { 2290 for (i = 0; i < g_num_of_iommus; i++) {
1898 if (deferred_flush[i].next) { 2291 struct intel_iommu *iommu = g_iommus[i];
1899 struct intel_iommu *iommu = 2292 if (!iommu)
1900 deferred_flush[i].domain[0]->iommu; 2293 continue;
1901 2294
2295 if (deferred_flush[i].next) {
1902 iommu->flush.flush_iotlb(iommu, 0, 0, 0, 2296 iommu->flush.flush_iotlb(iommu, 0, 0, 0,
1903 DMA_TLB_GLOBAL_FLUSH, 0); 2297 DMA_TLB_GLOBAL_FLUSH, 0);
1904 for (j = 0; j < deferred_flush[i].next; j++) { 2298 for (j = 0; j < deferred_flush[i].next; j++) {
@@ -1925,12 +2319,14 @@ static void add_unmap(struct dmar_domain *dom, struct iova *iova)
1925{ 2319{
1926 unsigned long flags; 2320 unsigned long flags;
1927 int next, iommu_id; 2321 int next, iommu_id;
2322 struct intel_iommu *iommu;
1928 2323
1929 spin_lock_irqsave(&async_umap_flush_lock, flags); 2324 spin_lock_irqsave(&async_umap_flush_lock, flags);
1930 if (list_size == HIGH_WATER_MARK) 2325 if (list_size == HIGH_WATER_MARK)
1931 flush_unmaps(); 2326 flush_unmaps();
1932 2327
1933 iommu_id = dom->iommu->seq_id; 2328 iommu = domain_get_iommu(dom);
2329 iommu_id = iommu->seq_id;
1934 2330
1935 next = deferred_flush[iommu_id].next; 2331 next = deferred_flush[iommu_id].next;
1936 deferred_flush[iommu_id].domain[next] = dom; 2332 deferred_flush[iommu_id].domain[next] = dom;
@@ -1952,12 +2348,15 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size,
1952 struct dmar_domain *domain; 2348 struct dmar_domain *domain;
1953 unsigned long start_addr; 2349 unsigned long start_addr;
1954 struct iova *iova; 2350 struct iova *iova;
2351 struct intel_iommu *iommu;
1955 2352
1956 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2353 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
1957 return; 2354 return;
1958 domain = find_domain(pdev); 2355 domain = find_domain(pdev);
1959 BUG_ON(!domain); 2356 BUG_ON(!domain);
1960 2357
2358 iommu = domain_get_iommu(domain);
2359
1961 iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr)); 2360 iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr));
1962 if (!iova) 2361 if (!iova)
1963 return; 2362 return;
@@ -1973,9 +2372,9 @@ void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, size_t size,
1973 /* free page tables */ 2372 /* free page tables */
1974 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2373 dma_pte_free_pagetable(domain, start_addr, start_addr + size);
1975 if (intel_iommu_strict) { 2374 if (intel_iommu_strict) {
1976 if (iommu_flush_iotlb_psi(domain->iommu, 2375 if (iommu_flush_iotlb_psi(iommu,
1977 domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0)) 2376 domain->id, start_addr, size >> VTD_PAGE_SHIFT, 0))
1978 iommu_flush_write_buffer(domain->iommu); 2377 iommu_flush_write_buffer(iommu);
1979 /* free iova */ 2378 /* free iova */
1980 __free_iova(&domain->iovad, iova); 2379 __free_iova(&domain->iovad, iova);
1981 } else { 2380 } else {
@@ -2036,11 +2435,15 @@ void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
2036 size_t size = 0; 2435 size_t size = 0;
2037 void *addr; 2436 void *addr;
2038 struct scatterlist *sg; 2437 struct scatterlist *sg;
2438 struct intel_iommu *iommu;
2039 2439
2040 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2440 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
2041 return; 2441 return;
2042 2442
2043 domain = find_domain(pdev); 2443 domain = find_domain(pdev);
2444 BUG_ON(!domain);
2445
2446 iommu = domain_get_iommu(domain);
2044 2447
2045 iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address)); 2448 iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address));
2046 if (!iova) 2449 if (!iova)
@@ -2057,9 +2460,9 @@ void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
2057 /* free page tables */ 2460 /* free page tables */
2058 dma_pte_free_pagetable(domain, start_addr, start_addr + size); 2461 dma_pte_free_pagetable(domain, start_addr, start_addr + size);
2059 2462
2060 if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, 2463 if (iommu_flush_iotlb_psi(iommu, domain->id, start_addr,
2061 size >> VTD_PAGE_SHIFT, 0)) 2464 size >> VTD_PAGE_SHIFT, 0))
2062 iommu_flush_write_buffer(domain->iommu); 2465 iommu_flush_write_buffer(iommu);
2063 2466
2064 /* free iova */ 2467 /* free iova */
2065 __free_iova(&domain->iovad, iova); 2468 __free_iova(&domain->iovad, iova);
@@ -2093,6 +2496,7 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems,
2093 int ret; 2496 int ret;
2094 struct scatterlist *sg; 2497 struct scatterlist *sg;
2095 unsigned long start_addr; 2498 unsigned long start_addr;
2499 struct intel_iommu *iommu;
2096 2500
2097 BUG_ON(dir == DMA_NONE); 2501 BUG_ON(dir == DMA_NONE);
2098 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2502 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
@@ -2102,6 +2506,8 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems,
2102 if (!domain) 2506 if (!domain)
2103 return 0; 2507 return 0;
2104 2508
2509 iommu = domain_get_iommu(domain);
2510
2105 for_each_sg(sglist, sg, nelems, i) { 2511 for_each_sg(sglist, sg, nelems, i) {
2106 addr = SG_ENT_VIRT_ADDRESS(sg); 2512 addr = SG_ENT_VIRT_ADDRESS(sg);
2107 addr = (void *)virt_to_phys(addr); 2513 addr = (void *)virt_to_phys(addr);
@@ -2119,7 +2525,7 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems,
2119 * mappings.. 2525 * mappings..
2120 */ 2526 */
2121 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ 2527 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \
2122 !cap_zlr(domain->iommu->cap)) 2528 !cap_zlr(iommu->cap))
2123 prot |= DMA_PTE_READ; 2529 prot |= DMA_PTE_READ;
2124 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) 2530 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
2125 prot |= DMA_PTE_WRITE; 2531 prot |= DMA_PTE_WRITE;
@@ -2151,9 +2557,9 @@ int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int nelems,
2151 } 2557 }
2152 2558
2153 /* it's a non-present to present mapping */ 2559 /* it's a non-present to present mapping */
2154 if (iommu_flush_iotlb_psi(domain->iommu, domain->id, 2560 if (iommu_flush_iotlb_psi(iommu, domain->id,
2155 start_addr, offset >> VTD_PAGE_SHIFT, 1)) 2561 start_addr, offset >> VTD_PAGE_SHIFT, 1))
2156 iommu_flush_write_buffer(domain->iommu); 2562 iommu_flush_write_buffer(iommu);
2157 return nelems; 2563 return nelems;
2158} 2564}
2159 2565
@@ -2325,10 +2731,220 @@ int __init intel_iommu_init(void)
2325 init_timer(&unmap_timer); 2731 init_timer(&unmap_timer);
2326 force_iommu = 1; 2732 force_iommu = 1;
2327 dma_ops = &intel_dma_ops; 2733 dma_ops = &intel_dma_ops;
2734
2735 register_iommu(&intel_iommu_ops);
2736
2737 return 0;
2738}
2739
2740static int vm_domain_add_dev_info(struct dmar_domain *domain,
2741 struct pci_dev *pdev)
2742{
2743 struct device_domain_info *info;
2744 unsigned long flags;
2745
2746 info = alloc_devinfo_mem();
2747 if (!info)
2748 return -ENOMEM;
2749
2750 info->bus = pdev->bus->number;
2751 info->devfn = pdev->devfn;
2752 info->dev = pdev;
2753 info->domain = domain;
2754
2755 spin_lock_irqsave(&device_domain_lock, flags);
2756 list_add(&info->link, &domain->devices);
2757 list_add(&info->global, &device_domain_list);
2758 pdev->dev.archdata.iommu = info;
2759 spin_unlock_irqrestore(&device_domain_lock, flags);
2760
2761 return 0;
2762}
2763
2764static void vm_domain_remove_one_dev_info(struct dmar_domain *domain,
2765 struct pci_dev *pdev)
2766{
2767 struct device_domain_info *info;
2768 struct intel_iommu *iommu;
2769 unsigned long flags;
2770 int found = 0;
2771 struct list_head *entry, *tmp;
2772
2773 iommu = device_to_iommu(pdev->bus->number, pdev->devfn);
2774 if (!iommu)
2775 return;
2776
2777 spin_lock_irqsave(&device_domain_lock, flags);
2778 list_for_each_safe(entry, tmp, &domain->devices) {
2779 info = list_entry(entry, struct device_domain_info, link);
2780 if (info->bus == pdev->bus->number &&
2781 info->devfn == pdev->devfn) {
2782 list_del(&info->link);
2783 list_del(&info->global);
2784 if (info->dev)
2785 info->dev->dev.archdata.iommu = NULL;
2786 spin_unlock_irqrestore(&device_domain_lock, flags);
2787
2788 iommu_detach_dev(iommu, info->bus, info->devfn);
2789 free_devinfo_mem(info);
2790
2791 spin_lock_irqsave(&device_domain_lock, flags);
2792
2793 if (found)
2794 break;
2795 else
2796 continue;
2797 }
2798
2799 /* if there is no other devices under the same iommu
2800 * owned by this domain, clear this iommu in iommu_bmp
2801 * update iommu count and coherency
2802 */
2803 if (device_to_iommu(info->bus, info->devfn) == iommu)
2804 found = 1;
2805 }
2806
2807 if (found == 0) {
2808 unsigned long tmp_flags;
2809 spin_lock_irqsave(&domain->iommu_lock, tmp_flags);
2810 clear_bit(iommu->seq_id, &domain->iommu_bmp);
2811 domain->iommu_count--;
2812 domain_update_iommu_coherency(domain);
2813 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags);
2814 }
2815
2816 spin_unlock_irqrestore(&device_domain_lock, flags);
2817}
2818
2819static void vm_domain_remove_all_dev_info(struct dmar_domain *domain)
2820{
2821 struct device_domain_info *info;
2822 struct intel_iommu *iommu;
2823 unsigned long flags1, flags2;
2824
2825 spin_lock_irqsave(&device_domain_lock, flags1);
2826 while (!list_empty(&domain->devices)) {
2827 info = list_entry(domain->devices.next,
2828 struct device_domain_info, link);
2829 list_del(&info->link);
2830 list_del(&info->global);
2831 if (info->dev)
2832 info->dev->dev.archdata.iommu = NULL;
2833
2834 spin_unlock_irqrestore(&device_domain_lock, flags1);
2835
2836 iommu = device_to_iommu(info->bus, info->devfn);
2837 iommu_detach_dev(iommu, info->bus, info->devfn);
2838
2839 /* clear this iommu in iommu_bmp, update iommu count
2840 * and coherency
2841 */
2842 spin_lock_irqsave(&domain->iommu_lock, flags2);
2843 if (test_and_clear_bit(iommu->seq_id,
2844 &domain->iommu_bmp)) {
2845 domain->iommu_count--;
2846 domain_update_iommu_coherency(domain);
2847 }
2848 spin_unlock_irqrestore(&domain->iommu_lock, flags2);
2849
2850 free_devinfo_mem(info);
2851 spin_lock_irqsave(&device_domain_lock, flags1);
2852 }
2853 spin_unlock_irqrestore(&device_domain_lock, flags1);
2854}
2855
2856/* domain id for virtual machine, it won't be set in context */
2857static unsigned long vm_domid;
2858
2859static int vm_domain_min_agaw(struct dmar_domain *domain)
2860{
2861 int i;
2862 int min_agaw = domain->agaw;
2863
2864 i = find_first_bit(&domain->iommu_bmp, g_num_of_iommus);
2865 for (; i < g_num_of_iommus; ) {
2866 if (min_agaw > g_iommus[i]->agaw)
2867 min_agaw = g_iommus[i]->agaw;
2868
2869 i = find_next_bit(&domain->iommu_bmp, g_num_of_iommus, i+1);
2870 }
2871
2872 return min_agaw;
2873}
2874
2875static struct dmar_domain *iommu_alloc_vm_domain(void)
2876{
2877 struct dmar_domain *domain;
2878
2879 domain = alloc_domain_mem();
2880 if (!domain)
2881 return NULL;
2882
2883 domain->id = vm_domid++;
2884 memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
2885 domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE;
2886
2887 return domain;
2888}
2889
2890static int vm_domain_init(struct dmar_domain *domain, int guest_width)
2891{
2892 int adjust_width;
2893
2894 init_iova_domain(&domain->iovad, DMA_32BIT_PFN);
2895 spin_lock_init(&domain->mapping_lock);
2896 spin_lock_init(&domain->iommu_lock);
2897
2898 domain_reserve_special_ranges(domain);
2899
2900 /* calculate AGAW */
2901 domain->gaw = guest_width;
2902 adjust_width = guestwidth_to_adjustwidth(guest_width);
2903 domain->agaw = width_to_agaw(adjust_width);
2904
2905 INIT_LIST_HEAD(&domain->devices);
2906
2907 domain->iommu_count = 0;
2908 domain->iommu_coherency = 0;
2909 domain->max_addr = 0;
2910
2911 /* always allocate the top pgd */
2912 domain->pgd = (struct dma_pte *)alloc_pgtable_page();
2913 if (!domain->pgd)
2914 return -ENOMEM;
2915 domain_flush_cache(domain, domain->pgd, PAGE_SIZE);
2328 return 0; 2916 return 0;
2329} 2917}
2330 2918
2331void intel_iommu_domain_exit(struct dmar_domain *domain) 2919static void iommu_free_vm_domain(struct dmar_domain *domain)
2920{
2921 unsigned long flags;
2922 struct dmar_drhd_unit *drhd;
2923 struct intel_iommu *iommu;
2924 unsigned long i;
2925 unsigned long ndomains;
2926
2927 for_each_drhd_unit(drhd) {
2928 if (drhd->ignored)
2929 continue;
2930 iommu = drhd->iommu;
2931
2932 ndomains = cap_ndoms(iommu->cap);
2933 i = find_first_bit(iommu->domain_ids, ndomains);
2934 for (; i < ndomains; ) {
2935 if (iommu->domains[i] == domain) {
2936 spin_lock_irqsave(&iommu->lock, flags);
2937 clear_bit(i, iommu->domain_ids);
2938 iommu->domains[i] = NULL;
2939 spin_unlock_irqrestore(&iommu->lock, flags);
2940 break;
2941 }
2942 i = find_next_bit(iommu->domain_ids, ndomains, i+1);
2943 }
2944 }
2945}
2946
2947static void vm_domain_exit(struct dmar_domain *domain)
2332{ 2948{
2333 u64 end; 2949 u64 end;
2334 2950
@@ -2336,6 +2952,9 @@ void intel_iommu_domain_exit(struct dmar_domain *domain)
2336 if (!domain) 2952 if (!domain)
2337 return; 2953 return;
2338 2954
2955 vm_domain_remove_all_dev_info(domain);
2956 /* destroy iovas */
2957 put_iova_domain(&domain->iovad);
2339 end = DOMAIN_MAX_ADDR(domain->gaw); 2958 end = DOMAIN_MAX_ADDR(domain->gaw);
2340 end = end & (~VTD_PAGE_MASK); 2959 end = end & (~VTD_PAGE_MASK);
2341 2960
@@ -2345,94 +2964,167 @@ void intel_iommu_domain_exit(struct dmar_domain *domain)
2345 /* free page tables */ 2964 /* free page tables */
2346 dma_pte_free_pagetable(domain, 0, end); 2965 dma_pte_free_pagetable(domain, 0, end);
2347 2966
2348 iommu_free_domain(domain); 2967 iommu_free_vm_domain(domain);
2349 free_domain_mem(domain); 2968 free_domain_mem(domain);
2350} 2969}
2351EXPORT_SYMBOL_GPL(intel_iommu_domain_exit);
2352 2970
2353struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev) 2971static int intel_iommu_domain_init(struct iommu_domain *domain)
2354{ 2972{
2355 struct dmar_drhd_unit *drhd; 2973 struct dmar_domain *dmar_domain;
2356 struct dmar_domain *domain;
2357 struct intel_iommu *iommu;
2358
2359 drhd = dmar_find_matched_drhd_unit(pdev);
2360 if (!drhd) {
2361 printk(KERN_ERR "intel_iommu_domain_alloc: drhd == NULL\n");
2362 return NULL;
2363 }
2364 2974
2365 iommu = drhd->iommu; 2975 dmar_domain = iommu_alloc_vm_domain();
2366 if (!iommu) { 2976 if (!dmar_domain) {
2367 printk(KERN_ERR
2368 "intel_iommu_domain_alloc: iommu == NULL\n");
2369 return NULL;
2370 }
2371 domain = iommu_alloc_domain(iommu);
2372 if (!domain) {
2373 printk(KERN_ERR 2977 printk(KERN_ERR
2374 "intel_iommu_domain_alloc: domain == NULL\n"); 2978 "intel_iommu_domain_init: dmar_domain == NULL\n");
2375 return NULL; 2979 return -ENOMEM;
2376 } 2980 }
2377 if (domain_init(domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) { 2981 if (vm_domain_init(dmar_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) {
2378 printk(KERN_ERR 2982 printk(KERN_ERR
2379 "intel_iommu_domain_alloc: domain_init() failed\n"); 2983 "intel_iommu_domain_init() failed\n");
2380 intel_iommu_domain_exit(domain); 2984 vm_domain_exit(dmar_domain);
2381 return NULL; 2985 return -ENOMEM;
2382 } 2986 }
2383 return domain; 2987 domain->priv = dmar_domain;
2988
2989 return 0;
2384} 2990}
2385EXPORT_SYMBOL_GPL(intel_iommu_domain_alloc);
2386 2991
2387int intel_iommu_context_mapping( 2992static void intel_iommu_domain_destroy(struct iommu_domain *domain)
2388 struct dmar_domain *domain, struct pci_dev *pdev)
2389{ 2993{
2390 int rc; 2994 struct dmar_domain *dmar_domain = domain->priv;
2391 rc = domain_context_mapping(domain, pdev); 2995
2392 return rc; 2996 domain->priv = NULL;
2997 vm_domain_exit(dmar_domain);
2393} 2998}
2394EXPORT_SYMBOL_GPL(intel_iommu_context_mapping);
2395 2999
2396int intel_iommu_page_mapping( 3000static int intel_iommu_attach_device(struct iommu_domain *domain,
2397 struct dmar_domain *domain, dma_addr_t iova, 3001 struct device *dev)
2398 u64 hpa, size_t size, int prot)
2399{ 3002{
2400 int rc; 3003 struct dmar_domain *dmar_domain = domain->priv;
2401 rc = domain_page_mapping(domain, iova, hpa, size, prot); 3004 struct pci_dev *pdev = to_pci_dev(dev);
2402 return rc; 3005 struct intel_iommu *iommu;
3006 int addr_width;
3007 u64 end;
3008 int ret;
3009
3010 /* normally pdev is not mapped */
3011 if (unlikely(domain_context_mapped(pdev))) {
3012 struct dmar_domain *old_domain;
3013
3014 old_domain = find_domain(pdev);
3015 if (old_domain) {
3016 if (dmar_domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE)
3017 vm_domain_remove_one_dev_info(old_domain, pdev);
3018 else
3019 domain_remove_dev_info(old_domain);
3020 }
3021 }
3022
3023 iommu = device_to_iommu(pdev->bus->number, pdev->devfn);
3024 if (!iommu)
3025 return -ENODEV;
3026
3027 /* check if this iommu agaw is sufficient for max mapped address */
3028 addr_width = agaw_to_width(iommu->agaw);
3029 end = DOMAIN_MAX_ADDR(addr_width);
3030 end = end & VTD_PAGE_MASK;
3031 if (end < dmar_domain->max_addr) {
3032 printk(KERN_ERR "%s: iommu agaw (%d) is not "
3033 "sufficient for the mapped address (%llx)\n",
3034 __func__, iommu->agaw, dmar_domain->max_addr);
3035 return -EFAULT;
3036 }
3037
3038 ret = domain_context_mapping(dmar_domain, pdev);
3039 if (ret)
3040 return ret;
3041
3042 ret = vm_domain_add_dev_info(dmar_domain, pdev);
3043 return ret;
2403} 3044}
2404EXPORT_SYMBOL_GPL(intel_iommu_page_mapping);
2405 3045
2406void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn) 3046static void intel_iommu_detach_device(struct iommu_domain *domain,
3047 struct device *dev)
2407{ 3048{
2408 detach_domain_for_dev(domain, bus, devfn); 3049 struct dmar_domain *dmar_domain = domain->priv;
3050 struct pci_dev *pdev = to_pci_dev(dev);
3051
3052 vm_domain_remove_one_dev_info(dmar_domain, pdev);
2409} 3053}
2410EXPORT_SYMBOL_GPL(intel_iommu_detach_dev);
2411 3054
2412struct dmar_domain * 3055static int intel_iommu_map_range(struct iommu_domain *domain,
2413intel_iommu_find_domain(struct pci_dev *pdev) 3056 unsigned long iova, phys_addr_t hpa,
3057 size_t size, int iommu_prot)
2414{ 3058{
2415 return find_domain(pdev); 3059 struct dmar_domain *dmar_domain = domain->priv;
3060 u64 max_addr;
3061 int addr_width;
3062 int prot = 0;
3063 int ret;
3064
3065 if (iommu_prot & IOMMU_READ)
3066 prot |= DMA_PTE_READ;
3067 if (iommu_prot & IOMMU_WRITE)
3068 prot |= DMA_PTE_WRITE;
3069
3070 max_addr = (iova & VTD_PAGE_MASK) + VTD_PAGE_ALIGN(size);
3071 if (dmar_domain->max_addr < max_addr) {
3072 int min_agaw;
3073 u64 end;
3074
3075 /* check if minimum agaw is sufficient for mapped address */
3076 min_agaw = vm_domain_min_agaw(dmar_domain);
3077 addr_width = agaw_to_width(min_agaw);
3078 end = DOMAIN_MAX_ADDR(addr_width);
3079 end = end & VTD_PAGE_MASK;
3080 if (end < max_addr) {
3081 printk(KERN_ERR "%s: iommu agaw (%d) is not "
3082 "sufficient for the mapped address (%llx)\n",
3083 __func__, min_agaw, max_addr);
3084 return -EFAULT;
3085 }
3086 dmar_domain->max_addr = max_addr;
3087 }
3088
3089 ret = domain_page_mapping(dmar_domain, iova, hpa, size, prot);
3090 return ret;
2416} 3091}
2417EXPORT_SYMBOL_GPL(intel_iommu_find_domain);
2418 3092
2419int intel_iommu_found(void) 3093static void intel_iommu_unmap_range(struct iommu_domain *domain,
3094 unsigned long iova, size_t size)
2420{ 3095{
2421 return g_num_of_iommus; 3096 struct dmar_domain *dmar_domain = domain->priv;
3097 dma_addr_t base;
3098
3099 /* The address might not be aligned */
3100 base = iova & VTD_PAGE_MASK;
3101 size = VTD_PAGE_ALIGN(size);
3102 dma_pte_clear_range(dmar_domain, base, base + size);
3103
3104 if (dmar_domain->max_addr == base + size)
3105 dmar_domain->max_addr = base;
2422} 3106}
2423EXPORT_SYMBOL_GPL(intel_iommu_found);
2424 3107
2425u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova) 3108static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
3109 unsigned long iova)
2426{ 3110{
3111 struct dmar_domain *dmar_domain = domain->priv;
2427 struct dma_pte *pte; 3112 struct dma_pte *pte;
2428 u64 pfn; 3113 u64 phys = 0;
2429
2430 pfn = 0;
2431 pte = addr_to_dma_pte(domain, iova);
2432 3114
3115 pte = addr_to_dma_pte(dmar_domain, iova);
2433 if (pte) 3116 if (pte)
2434 pfn = dma_pte_addr(*pte); 3117 phys = dma_pte_addr(pte);
2435 3118
2436 return pfn >> VTD_PAGE_SHIFT; 3119 return phys;
2437} 3120}
2438EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn); 3121
3122static struct iommu_ops intel_iommu_ops = {
3123 .domain_init = intel_iommu_domain_init,
3124 .domain_destroy = intel_iommu_domain_destroy,
3125 .attach_dev = intel_iommu_attach_device,
3126 .detach_dev = intel_iommu_detach_device,
3127 .map = intel_iommu_map_range,
3128 .unmap = intel_iommu_unmap_range,
3129 .iova_to_phys = intel_iommu_iova_to_phys,
3130};
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 7ff824496b39..7e6b5a3b3281 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -481,7 +481,7 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
481 481
482 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); 482 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
483 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); 483 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
484 for (i = 0; i < NR_CPUS; i++) { 484 for_each_possible_cpu(i) {
485 struct desc_struct *gdt = get_cpu_gdt_table(i); 485 struct desc_struct *gdt = get_cpu_gdt_table(i);
486 if (!gdt) 486 if (!gdt)
487 continue; 487 continue;
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 8e0c2b47803c..668472405a57 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -29,6 +29,13 @@ config APM_POWER
29 Say Y here to enable support APM status emulation using 29 Say Y here to enable support APM status emulation using
30 battery class devices. 30 battery class devices.
31 31
32config WM8350_POWER
33 tristate "WM8350 PMU support"
34 depends on MFD_WM8350
35 help
36 Say Y here to enable support for the power management unit
37 provided by the Wolfson Microelectronics WM8350 PMIC.
38
32config BATTERY_DS2760 39config BATTERY_DS2760
33 tristate "DS2760 battery driver (HP iPAQ & others)" 40 tristate "DS2760 battery driver (HP iPAQ & others)"
34 select W1 41 select W1
@@ -68,4 +75,11 @@ config BATTERY_BQ27x00
68 help 75 help
69 Say Y here to enable support for batteries with BQ27200(I2C) chip. 76 Say Y here to enable support for batteries with BQ27200(I2C) chip.
70 77
78config BATTERY_DA9030
79 tristate "DA9030 battery driver"
80 depends on PMIC_DA903X
81 help
82 Say Y here to enable support for batteries charger integrated into
83 DA9030 PMIC.
84
71endif # POWER_SUPPLY 85endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index e8f1ecec5d8f..eebb15505a40 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_POWER_SUPPLY) += power_supply.o
16 16
17obj-$(CONFIG_PDA_POWER) += pda_power.o 17obj-$(CONFIG_PDA_POWER) += pda_power.o
18obj-$(CONFIG_APM_POWER) += apm_power.o 18obj-$(CONFIG_APM_POWER) += apm_power.o
19obj-$(CONFIG_WM8350_POWER) += wm8350_power.o
19 20
20obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o 21obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
21obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o 22obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
@@ -23,3 +24,4 @@ obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o
23obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o 24obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
24obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o 25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
25obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o 26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
diff --git a/drivers/power/da9030_battery.c b/drivers/power/da9030_battery.c
new file mode 100644
index 000000000000..1662bb0f23a5
--- /dev/null
+++ b/drivers/power/da9030_battery.c
@@ -0,0 +1,600 @@
1/*
2 * Battery charger driver for Dialog Semiconductor DA9030
3 *
4 * Copyright (C) 2008 Compulab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/device.h>
16#include <linux/workqueue.h>
17#include <linux/module.h>
18#include <linux/platform_device.h>
19#include <linux/power_supply.h>
20#include <linux/mfd/da903x.h>
21
22#include <linux/debugfs.h>
23#include <linux/seq_file.h>
24
25#define DA9030_STATUS_CHDET (1 << 3)
26
27#define DA9030_FAULT_LOG 0x0a
28#define DA9030_FAULT_LOG_OVER_TEMP (1 << 7)
29#define DA9030_FAULT_LOG_VBAT_OVER (1 << 4)
30
31#define DA9030_CHARGE_CONTROL 0x28
32#define DA9030_CHRG_CHARGER_ENABLE (1 << 7)
33
34#define DA9030_ADC_MAN_CONTROL 0x30
35#define DA9030_ADC_TBATREF_ENABLE (1 << 5)
36#define DA9030_ADC_LDO_INT_ENABLE (1 << 4)
37
38#define DA9030_ADC_AUTO_CONTROL 0x31
39#define DA9030_ADC_TBAT_ENABLE (1 << 5)
40#define DA9030_ADC_VBAT_IN_TXON (1 << 4)
41#define DA9030_ADC_VCH_ENABLE (1 << 3)
42#define DA9030_ADC_ICH_ENABLE (1 << 2)
43#define DA9030_ADC_VBAT_ENABLE (1 << 1)
44#define DA9030_ADC_AUTO_SLEEP_ENABLE (1 << 0)
45
46#define DA9030_VBATMON 0x32
47#define DA9030_VBATMONTXON 0x33
48#define DA9030_TBATHIGHP 0x34
49#define DA9030_TBATHIGHN 0x35
50#define DA9030_TBATLOW 0x36
51
52#define DA9030_VBAT_RES 0x41
53#define DA9030_VBATMIN_RES 0x42
54#define DA9030_VBATMINTXON_RES 0x43
55#define DA9030_ICHMAX_RES 0x44
56#define DA9030_ICHMIN_RES 0x45
57#define DA9030_ICHAVERAGE_RES 0x46
58#define DA9030_VCHMAX_RES 0x47
59#define DA9030_VCHMIN_RES 0x48
60#define DA9030_TBAT_RES 0x49
61
62struct da9030_adc_res {
63 uint8_t vbat_res;
64 uint8_t vbatmin_res;
65 uint8_t vbatmintxon;
66 uint8_t ichmax_res;
67 uint8_t ichmin_res;
68 uint8_t ichaverage_res;
69 uint8_t vchmax_res;
70 uint8_t vchmin_res;
71 uint8_t tbat_res;
72 uint8_t adc_in4_res;
73 uint8_t adc_in5_res;
74};
75
76struct da9030_battery_thresholds {
77 int tbat_low;
78 int tbat_high;
79 int tbat_restart;
80
81 int vbat_low;
82 int vbat_crit;
83 int vbat_charge_start;
84 int vbat_charge_stop;
85 int vbat_charge_restart;
86
87 int vcharge_min;
88 int vcharge_max;
89};
90
91struct da9030_charger {
92 struct power_supply psy;
93
94 struct device *master;
95
96 struct da9030_adc_res adc;
97 struct delayed_work work;
98 unsigned int interval;
99
100 struct power_supply_info *battery_info;
101
102 struct da9030_battery_thresholds thresholds;
103
104 unsigned int charge_milliamp;
105 unsigned int charge_millivolt;
106
107 /* charger status */
108 bool chdet;
109 uint8_t fault;
110 int mA;
111 int mV;
112 bool is_on;
113
114 struct notifier_block nb;
115
116 /* platform callbacks for battery low and critical events */
117 void (*battery_low)(void);
118 void (*battery_critical)(void);
119
120 struct dentry *debug_file;
121};
122
123static inline int da9030_reg_to_mV(int reg)
124{
125 return ((reg * 2650) >> 8) + 2650;
126}
127
128static inline int da9030_millivolt_to_reg(int mV)
129{
130 return ((mV - 2650) << 8) / 2650;
131}
132
133static inline int da9030_reg_to_mA(int reg)
134{
135 return ((reg * 24000) >> 8) / 15;
136}
137
138#ifdef CONFIG_DEBUG_FS
139static int bat_debug_show(struct seq_file *s, void *data)
140{
141 struct da9030_charger *charger = s->private;
142
143 seq_printf(s, "charger is %s\n", charger->is_on ? "on" : "off");
144 if (charger->chdet) {
145 seq_printf(s, "iset = %dmA, vset = %dmV\n",
146 charger->mA, charger->mV);
147 }
148
149 seq_printf(s, "vbat_res = %d (%dmV)\n",
150 charger->adc.vbat_res,
151 da9030_reg_to_mV(charger->adc.vbat_res));
152 seq_printf(s, "vbatmin_res = %d (%dmV)\n",
153 charger->adc.vbatmin_res,
154 da9030_reg_to_mV(charger->adc.vbatmin_res));
155 seq_printf(s, "vbatmintxon = %d (%dmV)\n",
156 charger->adc.vbatmintxon,
157 da9030_reg_to_mV(charger->adc.vbatmintxon));
158 seq_printf(s, "ichmax_res = %d (%dmA)\n",
159 charger->adc.ichmax_res,
160 da9030_reg_to_mV(charger->adc.ichmax_res));
161 seq_printf(s, "ichmin_res = %d (%dmA)\n",
162 charger->adc.ichmin_res,
163 da9030_reg_to_mA(charger->adc.ichmin_res));
164 seq_printf(s, "ichaverage_res = %d (%dmA)\n",
165 charger->adc.ichaverage_res,
166 da9030_reg_to_mA(charger->adc.ichaverage_res));
167 seq_printf(s, "vchmax_res = %d (%dmV)\n",
168 charger->adc.vchmax_res,
169 da9030_reg_to_mA(charger->adc.vchmax_res));
170 seq_printf(s, "vchmin_res = %d (%dmV)\n",
171 charger->adc.vchmin_res,
172 da9030_reg_to_mV(charger->adc.vchmin_res));
173
174 return 0;
175}
176
177static int debug_open(struct inode *inode, struct file *file)
178{
179 return single_open(file, bat_debug_show, inode->i_private);
180}
181
182static const struct file_operations bat_debug_fops = {
183 .open = debug_open,
184 .read = seq_read,
185 .llseek = seq_lseek,
186 .release = single_release,
187};
188
189static struct dentry *da9030_bat_create_debugfs(struct da9030_charger *charger)
190{
191 charger->debug_file = debugfs_create_file("charger", 0666, 0, charger,
192 &bat_debug_fops);
193 return charger->debug_file;
194}
195
196static void da9030_bat_remove_debugfs(struct da9030_charger *charger)
197{
198 debugfs_remove(charger->debug_file);
199}
200#else
201static inline struct dentry *da9030_bat_create_debugfs(struct da9030_charger *charger)
202{
203 return NULL;
204}
205static inline void da9030_bat_remove_debugfs(struct da9030_charger *charger)
206{
207}
208#endif
209
210static inline void da9030_read_adc(struct da9030_charger *charger,
211 struct da9030_adc_res *adc)
212{
213 da903x_reads(charger->master, DA9030_VBAT_RES,
214 sizeof(*adc), (uint8_t *)adc);
215}
216
217static void da9030_charger_update_state(struct da9030_charger *charger)
218{
219 uint8_t val;
220
221 da903x_read(charger->master, DA9030_CHARGE_CONTROL, &val);
222 charger->is_on = (val & DA9030_CHRG_CHARGER_ENABLE) ? 1 : 0;
223 charger->mA = ((val >> 3) & 0xf) * 100;
224 charger->mV = (val & 0x7) * 50 + 4000;
225
226 da9030_read_adc(charger, &charger->adc);
227 da903x_read(charger->master, DA9030_FAULT_LOG, &charger->fault);
228 charger->chdet = da903x_query_status(charger->master,
229 DA9030_STATUS_CHDET);
230}
231
232static void da9030_set_charge(struct da9030_charger *charger, int on)
233{
234 uint8_t val;
235
236 if (on) {
237 val = DA9030_CHRG_CHARGER_ENABLE;
238 val |= (charger->charge_milliamp / 100) << 3;
239 val |= (charger->charge_millivolt - 4000) / 50;
240 charger->is_on = 1;
241 } else {
242 val = 0;
243 charger->is_on = 0;
244 }
245
246 da903x_write(charger->master, DA9030_CHARGE_CONTROL, val);
247}
248
249static void da9030_charger_check_state(struct da9030_charger *charger)
250{
251 da9030_charger_update_state(charger);
252
253 /* we wake or boot with external power on */
254 if (!charger->is_on) {
255 if ((charger->chdet) &&
256 (charger->adc.vbat_res <
257 charger->thresholds.vbat_charge_start)) {
258 da9030_set_charge(charger, 1);
259 }
260 } else {
261 if (charger->adc.vbat_res >=
262 charger->thresholds.vbat_charge_stop) {
263 da9030_set_charge(charger, 0);
264 da903x_write(charger->master, DA9030_VBATMON,
265 charger->thresholds.vbat_charge_restart);
266 } else if (charger->adc.vbat_res >
267 charger->thresholds.vbat_low) {
268 /* we are charging and passed LOW_THRESH,
269 so upate DA9030 VBAT threshold
270 */
271 da903x_write(charger->master, DA9030_VBATMON,
272 charger->thresholds.vbat_low);
273 }
274 if (charger->adc.vchmax_res > charger->thresholds.vcharge_max ||
275 charger->adc.vchmin_res < charger->thresholds.vcharge_min ||
276 /* Tempreture readings are negative */
277 charger->adc.tbat_res < charger->thresholds.tbat_high ||
278 charger->adc.tbat_res > charger->thresholds.tbat_low) {
279 /* disable charger */
280 da9030_set_charge(charger, 0);
281 }
282 }
283}
284
285static void da9030_charging_monitor(struct work_struct *work)
286{
287 struct da9030_charger *charger;
288
289 charger = container_of(work, struct da9030_charger, work.work);
290
291 da9030_charger_check_state(charger);
292
293 /* reschedule for the next time */
294 schedule_delayed_work(&charger->work, charger->interval);
295}
296
297static enum power_supply_property da9030_battery_props[] = {
298 POWER_SUPPLY_PROP_MODEL_NAME,
299 POWER_SUPPLY_PROP_STATUS,
300 POWER_SUPPLY_PROP_HEALTH,
301 POWER_SUPPLY_PROP_TECHNOLOGY,
302 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
303 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
304 POWER_SUPPLY_PROP_VOLTAGE_NOW,
305 POWER_SUPPLY_PROP_CURRENT_AVG,
306};
307
308static void da9030_battery_check_status(struct da9030_charger *charger,
309 union power_supply_propval *val)
310{
311 if (charger->chdet) {
312 if (charger->is_on)
313 val->intval = POWER_SUPPLY_STATUS_CHARGING;
314 else
315 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
316 } else {
317 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
318 }
319}
320
321static void da9030_battery_check_health(struct da9030_charger *charger,
322 union power_supply_propval *val)
323{
324 if (charger->fault & DA9030_FAULT_LOG_OVER_TEMP)
325 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
326 else if (charger->fault & DA9030_FAULT_LOG_VBAT_OVER)
327 val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
328 else
329 val->intval = POWER_SUPPLY_HEALTH_GOOD;
330}
331
332static int da9030_battery_get_property(struct power_supply *psy,
333 enum power_supply_property psp,
334 union power_supply_propval *val)
335{
336 struct da9030_charger *charger;
337 charger = container_of(psy, struct da9030_charger, psy);
338
339 switch (psp) {
340 case POWER_SUPPLY_PROP_STATUS:
341 da9030_battery_check_status(charger, val);
342 break;
343 case POWER_SUPPLY_PROP_HEALTH:
344 da9030_battery_check_health(charger, val);
345 break;
346 case POWER_SUPPLY_PROP_TECHNOLOGY:
347 val->intval = charger->battery_info->technology;
348 break;
349 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
350 val->intval = charger->battery_info->voltage_max_design;
351 break;
352 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
353 val->intval = charger->battery_info->voltage_min_design;
354 break;
355 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
356 val->intval = da9030_reg_to_mV(charger->adc.vbat_res) * 1000;
357 break;
358 case POWER_SUPPLY_PROP_CURRENT_AVG:
359 val->intval =
360 da9030_reg_to_mA(charger->adc.ichaverage_res) * 1000;
361 break;
362 case POWER_SUPPLY_PROP_MODEL_NAME:
363 val->strval = charger->battery_info->name;
364 break;
365 default:
366 break;
367 }
368
369 return 0;
370}
371
372static void da9030_battery_vbat_event(struct da9030_charger *charger)
373{
374 da9030_read_adc(charger, &charger->adc);
375
376 if (charger->is_on)
377 return;
378
379 if (charger->adc.vbat_res < charger->thresholds.vbat_low) {
380 /* set VBAT threshold for critical */
381 da903x_write(charger->master, DA9030_VBATMON,
382 charger->thresholds.vbat_crit);
383 if (charger->battery_low)
384 charger->battery_low();
385 } else if (charger->adc.vbat_res <
386 charger->thresholds.vbat_crit) {
387 /* notify the system of battery critical */
388 if (charger->battery_critical)
389 charger->battery_critical();
390 }
391}
392
393static int da9030_battery_event(struct notifier_block *nb, unsigned long event,
394 void *data)
395{
396 struct da9030_charger *charger =
397 container_of(nb, struct da9030_charger, nb);
398 int status;
399
400 switch (event) {
401 case DA9030_EVENT_CHDET:
402 status = da903x_query_status(charger->master,
403 DA9030_STATUS_CHDET);
404 da9030_set_charge(charger, status);
405 break;
406 case DA9030_EVENT_VBATMON:
407 da9030_battery_vbat_event(charger);
408 break;
409 case DA9030_EVENT_CHIOVER:
410 case DA9030_EVENT_TBAT:
411 da9030_set_charge(charger, 0);
412 break;
413 }
414
415 return 0;
416}
417
418static void da9030_battery_convert_thresholds(struct da9030_charger *charger,
419 struct da9030_battery_info *pdata)
420{
421 charger->thresholds.tbat_low = pdata->tbat_low;
422 charger->thresholds.tbat_high = pdata->tbat_high;
423 charger->thresholds.tbat_restart = pdata->tbat_restart;
424
425 charger->thresholds.vbat_low =
426 da9030_millivolt_to_reg(pdata->vbat_low);
427 charger->thresholds.vbat_crit =
428 da9030_millivolt_to_reg(pdata->vbat_crit);
429 charger->thresholds.vbat_charge_start =
430 da9030_millivolt_to_reg(pdata->vbat_charge_start);
431 charger->thresholds.vbat_charge_stop =
432 da9030_millivolt_to_reg(pdata->vbat_charge_stop);
433 charger->thresholds.vbat_charge_restart =
434 da9030_millivolt_to_reg(pdata->vbat_charge_restart);
435
436 charger->thresholds.vcharge_min =
437 da9030_millivolt_to_reg(pdata->vcharge_min);
438 charger->thresholds.vcharge_max =
439 da9030_millivolt_to_reg(pdata->vcharge_max);
440}
441
442static void da9030_battery_setup_psy(struct da9030_charger *charger)
443{
444 struct power_supply *psy = &charger->psy;
445 struct power_supply_info *info = charger->battery_info;
446
447 psy->name = info->name;
448 psy->use_for_apm = info->use_for_apm;
449 psy->type = POWER_SUPPLY_TYPE_BATTERY;
450 psy->get_property = da9030_battery_get_property;
451
452 psy->properties = da9030_battery_props;
453 psy->num_properties = ARRAY_SIZE(da9030_battery_props);
454};
455
456static int da9030_battery_charger_init(struct da9030_charger *charger)
457{
458 char v[5];
459 int ret;
460
461 v[0] = v[1] = charger->thresholds.vbat_low;
462 v[2] = charger->thresholds.tbat_high;
463 v[3] = charger->thresholds.tbat_restart;
464 v[4] = charger->thresholds.tbat_low;
465
466 ret = da903x_writes(charger->master, DA9030_VBATMON, 5, v);
467 if (ret)
468 return ret;
469
470 /*
471 * Enable reference voltage supply for ADC from the LDO_INTERNAL
472 * regulator. Must be set before ADC measurements can be made.
473 */
474 ret = da903x_write(charger->master, DA9030_ADC_MAN_CONTROL,
475 DA9030_ADC_LDO_INT_ENABLE |
476 DA9030_ADC_TBATREF_ENABLE);
477 if (ret)
478 return ret;
479
480 /* enable auto ADC measuremnts */
481 return da903x_write(charger->master, DA9030_ADC_AUTO_CONTROL,
482 DA9030_ADC_TBAT_ENABLE | DA9030_ADC_VBAT_IN_TXON |
483 DA9030_ADC_VCH_ENABLE | DA9030_ADC_ICH_ENABLE |
484 DA9030_ADC_VBAT_ENABLE |
485 DA9030_ADC_AUTO_SLEEP_ENABLE);
486}
487
488static int da9030_battery_probe(struct platform_device *pdev)
489{
490 struct da9030_charger *charger;
491 struct da9030_battery_info *pdata = pdev->dev.platform_data;
492 int ret;
493
494 if (pdata == NULL)
495 return -EINVAL;
496
497 if (pdata->charge_milliamp >= 1500 ||
498 pdata->charge_millivolt < 4000 ||
499 pdata->charge_millivolt > 4350)
500 return -EINVAL;
501
502 charger = kzalloc(sizeof(*charger), GFP_KERNEL);
503 if (charger == NULL)
504 return -ENOMEM;
505
506 charger->master = pdev->dev.parent;
507
508 /* 10 seconds between monotor runs unless platfrom defines other
509 interval */
510 charger->interval = msecs_to_jiffies(
511 (pdata->batmon_interval ? : 10) * 1000);
512
513 charger->charge_milliamp = pdata->charge_milliamp;
514 charger->charge_millivolt = pdata->charge_millivolt;
515 charger->battery_info = pdata->battery_info;
516 charger->battery_low = pdata->battery_low;
517 charger->battery_critical = pdata->battery_critical;
518
519 da9030_battery_convert_thresholds(charger, pdata);
520
521 ret = da9030_battery_charger_init(charger);
522 if (ret)
523 goto err_charger_init;
524
525 INIT_DELAYED_WORK(&charger->work, da9030_charging_monitor);
526 schedule_delayed_work(&charger->work, charger->interval);
527
528 charger->nb.notifier_call = da9030_battery_event;
529 ret = da903x_register_notifier(charger->master, &charger->nb,
530 DA9030_EVENT_CHDET |
531 DA9030_EVENT_VBATMON |
532 DA9030_EVENT_CHIOVER |
533 DA9030_EVENT_TBAT);
534 if (ret)
535 goto err_notifier;
536
537 da9030_battery_setup_psy(charger);
538 ret = power_supply_register(&pdev->dev, &charger->psy);
539 if (ret)
540 goto err_ps_register;
541
542 charger->debug_file = da9030_bat_create_debugfs(charger);
543 platform_set_drvdata(pdev, charger);
544 return 0;
545
546err_ps_register:
547 da903x_unregister_notifier(charger->master, &charger->nb,
548 DA9030_EVENT_CHDET | DA9030_EVENT_VBATMON |
549 DA9030_EVENT_CHIOVER | DA9030_EVENT_TBAT);
550err_notifier:
551 cancel_delayed_work(&charger->work);
552
553err_charger_init:
554 kfree(charger);
555
556 return ret;
557}
558
559static int da9030_battery_remove(struct platform_device *dev)
560{
561 struct da9030_charger *charger = platform_get_drvdata(dev);
562
563 da9030_bat_remove_debugfs(charger);
564
565 da903x_unregister_notifier(charger->master, &charger->nb,
566 DA9030_EVENT_CHDET | DA9030_EVENT_VBATMON |
567 DA9030_EVENT_CHIOVER | DA9030_EVENT_TBAT);
568 cancel_delayed_work(&charger->work);
569 power_supply_unregister(&charger->psy);
570
571 kfree(charger);
572
573 return 0;
574}
575
576static struct platform_driver da903x_battery_driver = {
577 .driver = {
578 .name = "da903x-battery",
579 .owner = THIS_MODULE,
580 },
581 .probe = da9030_battery_probe,
582 .remove = da9030_battery_remove,
583};
584
585static int da903x_battery_init(void)
586{
587 return platform_driver_register(&da903x_battery_driver);
588}
589
590static void da903x_battery_exit(void)
591{
592 platform_driver_unregister(&da903x_battery_driver);
593}
594
595module_init(da903x_battery_init);
596module_exit(da903x_battery_exit);
597
598MODULE_DESCRIPTION("DA9030 battery charger driver");
599MODULE_AUTHOR("Mike Rapoport, CompuLab");
600MODULE_LICENSE("GPL");
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 23ae8460f5c1..ac01e06817fb 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -45,7 +45,7 @@ static ssize_t power_supply_show_property(struct device *dev,
45 }; 45 };
46 static char *health_text[] = { 46 static char *health_text[] = {
47 "Unknown", "Good", "Overheat", "Dead", "Over voltage", 47 "Unknown", "Good", "Overheat", "Dead", "Over voltage",
48 "Unspecified failure" 48 "Unspecified failure", "Cold",
49 }; 49 };
50 static char *technology_text[] = { 50 static char *technology_text[] = {
51 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd", 51 "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe", "NiCd",
diff --git a/drivers/power/wm8350_power.c b/drivers/power/wm8350_power.c
new file mode 100644
index 000000000000..1b16bf343f2f
--- /dev/null
+++ b/drivers/power/wm8350_power.c
@@ -0,0 +1,532 @@
1/*
2 * Battery driver for wm8350 PMIC
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Based on OLPC Battery Driver
7 *
8 * Copyright 2006 David Woodhouse <dwmw2@infradead.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/err.h>
17#include <linux/platform_device.h>
18#include <linux/power_supply.h>
19#include <linux/mfd/wm8350/supply.h>
20#include <linux/mfd/wm8350/core.h>
21#include <linux/mfd/wm8350/comparator.h>
22
23static int wm8350_read_battery_uvolts(struct wm8350 *wm8350)
24{
25 return wm8350_read_auxadc(wm8350, WM8350_AUXADC_BATT, 0, 0)
26 * WM8350_AUX_COEFF;
27}
28
29static int wm8350_read_line_uvolts(struct wm8350 *wm8350)
30{
31 return wm8350_read_auxadc(wm8350, WM8350_AUXADC_LINE, 0, 0)
32 * WM8350_AUX_COEFF;
33}
34
35static int wm8350_read_usb_uvolts(struct wm8350 *wm8350)
36{
37 return wm8350_read_auxadc(wm8350, WM8350_AUXADC_USB, 0, 0)
38 * WM8350_AUX_COEFF;
39}
40
41#define WM8350_BATT_SUPPLY 1
42#define WM8350_USB_SUPPLY 2
43#define WM8350_LINE_SUPPLY 4
44
45static inline int wm8350_charge_time_min(struct wm8350 *wm8350, int min)
46{
47 if (!wm8350->power.rev_g_coeff)
48 return (((min - 30) / 15) & 0xf) << 8;
49 else
50 return (((min - 30) / 30) & 0xf) << 8;
51}
52
53static int wm8350_get_supplies(struct wm8350 *wm8350)
54{
55 u16 sm, ov, co, chrg;
56 int supplies = 0;
57
58 sm = wm8350_reg_read(wm8350, WM8350_STATE_MACHINE_STATUS);
59 ov = wm8350_reg_read(wm8350, WM8350_MISC_OVERRIDES);
60 co = wm8350_reg_read(wm8350, WM8350_COMPARATOR_OVERRIDES);
61 chrg = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2);
62
63 /* USB_SM */
64 sm = (sm & WM8350_USB_SM_MASK) >> WM8350_USB_SM_SHIFT;
65
66 /* CHG_ISEL */
67 chrg &= WM8350_CHG_ISEL_MASK;
68
69 /* If the USB state machine is active then we're using that with or
70 * without battery, otherwise check for wall supply */
71 if (((sm == WM8350_USB_SM_100_SLV) ||
72 (sm == WM8350_USB_SM_500_SLV) ||
73 (sm == WM8350_USB_SM_STDBY_SLV))
74 && !(ov & WM8350_USB_LIMIT_OVRDE))
75 supplies = WM8350_USB_SUPPLY;
76 else if (((sm == WM8350_USB_SM_100_SLV) ||
77 (sm == WM8350_USB_SM_500_SLV) ||
78 (sm == WM8350_USB_SM_STDBY_SLV))
79 && (ov & WM8350_USB_LIMIT_OVRDE) && (chrg == 0))
80 supplies = WM8350_USB_SUPPLY | WM8350_BATT_SUPPLY;
81 else if (co & WM8350_WALL_FB_OVRDE)
82 supplies = WM8350_LINE_SUPPLY;
83 else
84 supplies = WM8350_BATT_SUPPLY;
85
86 return supplies;
87}
88
89static int wm8350_charger_config(struct wm8350 *wm8350,
90 struct wm8350_charger_policy *policy)
91{
92 u16 reg, eoc_mA, fast_limit_mA;
93
94 if (!policy) {
95 dev_warn(wm8350->dev,
96 "No charger policy, charger not configured.\n");
97 return -EINVAL;
98 }
99
100 /* make sure USB fast charge current is not > 500mA */
101 if (policy->fast_limit_USB_mA > 500) {
102 dev_err(wm8350->dev, "USB fast charge > 500mA\n");
103 return -EINVAL;
104 }
105
106 eoc_mA = WM8350_CHG_EOC_mA(policy->eoc_mA);
107
108 wm8350_reg_unlock(wm8350);
109
110 reg = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_1)
111 & WM8350_CHG_ENA_R168;
112 wm8350_reg_write(wm8350, WM8350_BATTERY_CHARGER_CONTROL_1,
113 reg | eoc_mA | policy->trickle_start_mV |
114 WM8350_CHG_TRICKLE_TEMP_CHOKE |
115 WM8350_CHG_TRICKLE_USB_CHOKE |
116 WM8350_CHG_FAST_USB_THROTTLE);
117
118 if (wm8350_get_supplies(wm8350) & WM8350_USB_SUPPLY) {
119 fast_limit_mA =
120 WM8350_CHG_FAST_LIMIT_mA(policy->fast_limit_USB_mA);
121 wm8350_reg_write(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2,
122 policy->charge_mV | policy->trickle_charge_USB_mA |
123 fast_limit_mA | wm8350_charge_time_min(wm8350,
124 policy->charge_timeout));
125
126 } else {
127 fast_limit_mA =
128 WM8350_CHG_FAST_LIMIT_mA(policy->fast_limit_mA);
129 wm8350_reg_write(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2,
130 policy->charge_mV | policy->trickle_charge_mA |
131 fast_limit_mA | wm8350_charge_time_min(wm8350,
132 policy->charge_timeout));
133 }
134
135 wm8350_reg_lock(wm8350);
136 return 0;
137}
138
139static int wm8350_batt_status(struct wm8350 *wm8350)
140{
141 u16 state;
142
143 state = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2);
144 state &= WM8350_CHG_STS_MASK;
145
146 switch (state) {
147 case WM8350_CHG_STS_OFF:
148 return POWER_SUPPLY_STATUS_DISCHARGING;
149
150 case WM8350_CHG_STS_TRICKLE:
151 case WM8350_CHG_STS_FAST:
152 return POWER_SUPPLY_STATUS_CHARGING;
153
154 default:
155 return POWER_SUPPLY_STATUS_UNKNOWN;
156 }
157}
158
159static ssize_t charger_state_show(struct device *dev,
160 struct device_attribute *attr, char *buf)
161{
162 struct wm8350 *wm8350 = dev_get_drvdata(dev);
163 char *charge;
164 int state;
165
166 state = wm8350_reg_read(wm8350, WM8350_BATTERY_CHARGER_CONTROL_2) &
167 WM8350_CHG_STS_MASK;
168 switch (state) {
169 case WM8350_CHG_STS_OFF:
170 charge = "Charger Off";
171 break;
172 case WM8350_CHG_STS_TRICKLE:
173 charge = "Trickle Charging";
174 break;
175 case WM8350_CHG_STS_FAST:
176 charge = "Fast Charging";
177 break;
178 default:
179 return 0;
180 }
181
182 return sprintf(buf, "%s\n", charge);
183}
184
185static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL);
186
187static void wm8350_charger_handler(struct wm8350 *wm8350, int irq, void *data)
188{
189 struct wm8350_power *power = &wm8350->power;
190 struct wm8350_charger_policy *policy = power->policy;
191
192 switch (irq) {
193 case WM8350_IRQ_CHG_BAT_FAIL:
194 dev_err(wm8350->dev, "battery failed\n");
195 break;
196 case WM8350_IRQ_CHG_TO:
197 dev_err(wm8350->dev, "charger timeout\n");
198 power_supply_changed(&power->battery);
199 break;
200
201 case WM8350_IRQ_CHG_BAT_HOT:
202 case WM8350_IRQ_CHG_BAT_COLD:
203 case WM8350_IRQ_CHG_START:
204 case WM8350_IRQ_CHG_END:
205 power_supply_changed(&power->battery);
206 break;
207
208 case WM8350_IRQ_CHG_FAST_RDY:
209 dev_dbg(wm8350->dev, "fast charger ready\n");
210 wm8350_charger_config(wm8350, policy);
211 wm8350_reg_unlock(wm8350);
212 wm8350_set_bits(wm8350, WM8350_BATTERY_CHARGER_CONTROL_1,
213 WM8350_CHG_FAST);
214 wm8350_reg_lock(wm8350);
215 break;
216
217 case WM8350_IRQ_CHG_VBATT_LT_3P9:
218 dev_warn(wm8350->dev, "battery < 3.9V\n");
219 break;
220 case WM8350_IRQ_CHG_VBATT_LT_3P1:
221 dev_warn(wm8350->dev, "battery < 3.1V\n");
222 break;
223 case WM8350_IRQ_CHG_VBATT_LT_2P85:
224 dev_warn(wm8350->dev, "battery < 2.85V\n");
225 break;
226
227 /* Supply change. We will overnotify but it should do
228 * no harm. */
229 case WM8350_IRQ_EXT_USB_FB:
230 case WM8350_IRQ_EXT_WALL_FB:
231 wm8350_charger_config(wm8350, policy);
232 case WM8350_IRQ_EXT_BAT_FB: /* Fall through */
233 power_supply_changed(&power->battery);
234 power_supply_changed(&power->usb);
235 power_supply_changed(&power->ac);
236 break;
237
238 default:
239 dev_err(wm8350->dev, "Unknown interrupt %d\n", irq);
240 }
241}
242
243/*********************************************************************
244 * AC Power
245 *********************************************************************/
246static int wm8350_ac_get_prop(struct power_supply *psy,
247 enum power_supply_property psp,
248 union power_supply_propval *val)
249{
250 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev->parent);
251 int ret = 0;
252
253 switch (psp) {
254 case POWER_SUPPLY_PROP_ONLINE:
255 val->intval = !!(wm8350_get_supplies(wm8350) &
256 WM8350_LINE_SUPPLY);
257 break;
258 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
259 val->intval = wm8350_read_line_uvolts(wm8350);
260 break;
261 default:
262 ret = -EINVAL;
263 break;
264 }
265 return ret;
266}
267
268static enum power_supply_property wm8350_ac_props[] = {
269 POWER_SUPPLY_PROP_ONLINE,
270 POWER_SUPPLY_PROP_VOLTAGE_NOW,
271};
272
273/*********************************************************************
274 * USB Power
275 *********************************************************************/
276static int wm8350_usb_get_prop(struct power_supply *psy,
277 enum power_supply_property psp,
278 union power_supply_propval *val)
279{
280 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev->parent);
281 int ret = 0;
282
283 switch (psp) {
284 case POWER_SUPPLY_PROP_ONLINE:
285 val->intval = !!(wm8350_get_supplies(wm8350) &
286 WM8350_USB_SUPPLY);
287 break;
288 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
289 val->intval = wm8350_read_usb_uvolts(wm8350);
290 break;
291 default:
292 ret = -EINVAL;
293 break;
294 }
295 return ret;
296}
297
298static enum power_supply_property wm8350_usb_props[] = {
299 POWER_SUPPLY_PROP_ONLINE,
300 POWER_SUPPLY_PROP_VOLTAGE_NOW,
301};
302
303/*********************************************************************
304 * Battery properties
305 *********************************************************************/
306
307static int wm8350_bat_check_health(struct wm8350 *wm8350)
308{
309 u16 reg;
310
311 if (wm8350_read_battery_uvolts(wm8350) < 2850000)
312 return POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
313
314 reg = wm8350_reg_read(wm8350, WM8350_CHARGER_OVERRIDES);
315 if (reg & WM8350_CHG_BATT_HOT_OVRDE)
316 return POWER_SUPPLY_HEALTH_OVERHEAT;
317
318 if (reg & WM8350_CHG_BATT_COLD_OVRDE)
319 return POWER_SUPPLY_HEALTH_COLD;
320
321 return POWER_SUPPLY_HEALTH_GOOD;
322}
323
324static int wm8350_bat_get_property(struct power_supply *psy,
325 enum power_supply_property psp,
326 union power_supply_propval *val)
327{
328 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev->parent);
329 int ret = 0;
330
331 switch (psp) {
332 case POWER_SUPPLY_PROP_STATUS:
333 val->intval = wm8350_batt_status(wm8350);
334 break;
335 case POWER_SUPPLY_PROP_ONLINE:
336 val->intval = !!(wm8350_get_supplies(wm8350) &
337 WM8350_BATT_SUPPLY);
338 break;
339 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
340 val->intval = wm8350_read_battery_uvolts(wm8350);
341 break;
342 case POWER_SUPPLY_PROP_HEALTH:
343 val->intval = wm8350_bat_check_health(wm8350);
344 break;
345 default:
346 ret = -EINVAL;
347 break;
348 }
349
350 return ret;
351}
352
353static enum power_supply_property wm8350_bat_props[] = {
354 POWER_SUPPLY_PROP_STATUS,
355 POWER_SUPPLY_PROP_ONLINE,
356 POWER_SUPPLY_PROP_VOLTAGE_NOW,
357 POWER_SUPPLY_PROP_HEALTH,
358};
359
360/*********************************************************************
361 * Initialisation
362 *********************************************************************/
363
364static void wm8350_init_charger(struct wm8350 *wm8350)
365{
366 /* register our interest in charger events */
367 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT,
368 wm8350_charger_handler, NULL);
369 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
370 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD,
371 wm8350_charger_handler, NULL);
372 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
373 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL,
374 wm8350_charger_handler, NULL);
375 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
376 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_TO,
377 wm8350_charger_handler, NULL);
378 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_TO);
379 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_END,
380 wm8350_charger_handler, NULL);
381 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_END);
382 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_START,
383 wm8350_charger_handler, NULL);
384 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_START);
385 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY,
386 wm8350_charger_handler, NULL);
387 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY);
388 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9,
389 wm8350_charger_handler, NULL);
390 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9);
391 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1,
392 wm8350_charger_handler, NULL);
393 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1);
394 wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85,
395 wm8350_charger_handler, NULL);
396 wm8350_unmask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85);
397
398 /* and supply change events */
399 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_USB_FB,
400 wm8350_charger_handler, NULL);
401 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
402 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_WALL_FB,
403 wm8350_charger_handler, NULL);
404 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
405 wm8350_register_irq(wm8350, WM8350_IRQ_EXT_BAT_FB,
406 wm8350_charger_handler, NULL);
407 wm8350_unmask_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
408}
409
410static void free_charger_irq(struct wm8350 *wm8350)
411{
412 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
413 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT);
414 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
415 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD);
416 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
417 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL);
418 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_TO);
419 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_TO);
420 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_END);
421 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_END);
422 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_START);
423 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_START);
424 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9);
425 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9);
426 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1);
427 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1);
428 wm8350_mask_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85);
429 wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85);
430 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
431 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_USB_FB);
432 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
433 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_WALL_FB);
434 wm8350_mask_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
435 wm8350_free_irq(wm8350, WM8350_IRQ_EXT_BAT_FB);
436}
437
438static __devinit int wm8350_power_probe(struct platform_device *pdev)
439{
440 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
441 struct wm8350_power *power = &wm8350->power;
442 struct wm8350_charger_policy *policy = power->policy;
443 struct power_supply *usb = &power->usb;
444 struct power_supply *battery = &power->battery;
445 struct power_supply *ac = &power->ac;
446 int ret;
447
448 ac->name = "wm8350-ac";
449 ac->type = POWER_SUPPLY_TYPE_MAINS;
450 ac->properties = wm8350_ac_props;
451 ac->num_properties = ARRAY_SIZE(wm8350_ac_props);
452 ac->get_property = wm8350_ac_get_prop;
453 ret = power_supply_register(&pdev->dev, ac);
454 if (ret)
455 return ret;
456
457 battery->name = "wm8350-battery";
458 battery->properties = wm8350_bat_props;
459 battery->num_properties = ARRAY_SIZE(wm8350_bat_props);
460 battery->get_property = wm8350_bat_get_property;
461 battery->use_for_apm = 1;
462 ret = power_supply_register(&pdev->dev, battery);
463 if (ret)
464 goto battery_failed;
465
466 usb->name = "wm8350-usb",
467 usb->type = POWER_SUPPLY_TYPE_USB;
468 usb->properties = wm8350_usb_props;
469 usb->num_properties = ARRAY_SIZE(wm8350_usb_props);
470 usb->get_property = wm8350_usb_get_prop;
471 ret = power_supply_register(&pdev->dev, usb);
472 if (ret)
473 goto usb_failed;
474
475 ret = device_create_file(&pdev->dev, &dev_attr_charger_state);
476 if (ret < 0)
477 dev_warn(wm8350->dev, "failed to add charge sysfs: %d\n", ret);
478 ret = 0;
479
480 wm8350_init_charger(wm8350);
481 if (wm8350_charger_config(wm8350, policy) == 0) {
482 wm8350_reg_unlock(wm8350);
483 wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CHG_ENA);
484 wm8350_reg_lock(wm8350);
485 }
486
487 return ret;
488
489usb_failed:
490 power_supply_unregister(battery);
491battery_failed:
492 power_supply_unregister(ac);
493
494 return ret;
495}
496
497static __devexit int wm8350_power_remove(struct platform_device *pdev)
498{
499 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
500 struct wm8350_power *power = &wm8350->power;
501
502 free_charger_irq(wm8350);
503 device_remove_file(&pdev->dev, &dev_attr_charger_state);
504 power_supply_unregister(&power->battery);
505 power_supply_unregister(&power->ac);
506 power_supply_unregister(&power->usb);
507 return 0;
508}
509
510static struct platform_driver wm8350_power_driver = {
511 .probe = wm8350_power_probe,
512 .remove = __devexit_p(wm8350_power_remove),
513 .driver = {
514 .name = "wm8350-power",
515 },
516};
517
518static int __init wm8350_power_init(void)
519{
520 return platform_driver_register(&wm8350_power_driver);
521}
522module_init(wm8350_power_init);
523
524static void __exit wm8350_power_exit(void)
525{
526 platform_driver_unregister(&wm8350_power_driver);
527}
528module_exit(wm8350_power_exit);
529
530MODULE_LICENSE("GPL");
531MODULE_DESCRIPTION("Power supply driver for WM8350");
532MODULE_ALIAS("platform:wm8350-power");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 1f44b17e23b1..c68c496b2c49 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1380,6 +1380,13 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
1380 if (wm8350->pmic.pdev[reg]) 1380 if (wm8350->pmic.pdev[reg])
1381 return -EBUSY; 1381 return -EBUSY;
1382 1382
1383 if (reg >= WM8350_DCDC_1 && reg <= WM8350_DCDC_6 &&
1384 reg > wm8350->pmic.max_dcdc)
1385 return -ENODEV;
1386 if (reg >= WM8350_ISINK_A && reg <= WM8350_ISINK_B &&
1387 reg > wm8350->pmic.max_isink)
1388 return -ENODEV;
1389
1383 pdev = platform_device_alloc("wm8350-regulator", reg); 1390 pdev = platform_device_alloc("wm8350-regulator", reg);
1384 if (!pdev) 1391 if (!pdev)
1385 return -ENOMEM; 1392 return -ENOMEM;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 123092d8a984..165a81843357 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -102,9 +102,13 @@ config RTC_INTF_DEV_UIE_EMUL
102 depends on RTC_INTF_DEV 102 depends on RTC_INTF_DEV
103 help 103 help
104 Provides an emulation for RTC_UIE if the underlying rtc chip 104 Provides an emulation for RTC_UIE if the underlying rtc chip
105 driver does not expose RTC_UIE ioctls. Those requests generate 105 driver does not expose RTC_UIE ioctls. Those requests generate
106 once-per-second update interrupts, used for synchronization. 106 once-per-second update interrupts, used for synchronization.
107 107
108 The emulation code will read the time from the hardware
109 clock several times per second, please enable this option
110 only if you know that you really need it.
111
108config RTC_DRV_TEST 112config RTC_DRV_TEST
109 tristate "Test driver/device" 113 tristate "Test driver/device"
110 help 114 help
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a04c1b6b1575..fd2c652504ff 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -307,6 +307,60 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
307} 307}
308EXPORT_SYMBOL_GPL(rtc_set_alarm); 308EXPORT_SYMBOL_GPL(rtc_set_alarm);
309 309
310int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
311{
312 int err = mutex_lock_interruptible(&rtc->ops_lock);
313 if (err)
314 return err;
315
316 if (!rtc->ops)
317 err = -ENODEV;
318 else if (!rtc->ops->alarm_irq_enable)
319 err = -EINVAL;
320 else
321 err = rtc->ops->alarm_irq_enable(rtc->dev.parent, enabled);
322
323 mutex_unlock(&rtc->ops_lock);
324 return err;
325}
326EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
327
328int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
329{
330 int err = mutex_lock_interruptible(&rtc->ops_lock);
331 if (err)
332 return err;
333
334#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
335 if (enabled == 0 && rtc->uie_irq_active) {
336 mutex_unlock(&rtc->ops_lock);
337 return rtc_dev_update_irq_enable_emul(rtc, enabled);
338 }
339#endif
340
341 if (!rtc->ops)
342 err = -ENODEV;
343 else if (!rtc->ops->update_irq_enable)
344 err = -EINVAL;
345 else
346 err = rtc->ops->update_irq_enable(rtc->dev.parent, enabled);
347
348 mutex_unlock(&rtc->ops_lock);
349
350#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
351 /*
352 * Enable emulation if the driver did not provide
353 * the update_irq_enable function pointer or if returned
354 * -EINVAL to signal that it has been configured without
355 * interrupts or that are not available at the moment.
356 */
357 if (err == -EINVAL)
358 err = rtc_dev_update_irq_enable_emul(rtc, enabled);
359#endif
360 return err;
361}
362EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
363
310/** 364/**
311 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs 365 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
312 * @rtc: the rtc device 366 * @rtc: the rtc device
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ecdea44ae4e5..45152f4952d6 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -92,10 +92,10 @@ static void rtc_uie_timer(unsigned long data)
92 spin_unlock_irqrestore(&rtc->irq_lock, flags); 92 spin_unlock_irqrestore(&rtc->irq_lock, flags);
93} 93}
94 94
95static void clear_uie(struct rtc_device *rtc) 95static int clear_uie(struct rtc_device *rtc)
96{ 96{
97 spin_lock_irq(&rtc->irq_lock); 97 spin_lock_irq(&rtc->irq_lock);
98 if (rtc->irq_active) { 98 if (rtc->uie_irq_active) {
99 rtc->stop_uie_polling = 1; 99 rtc->stop_uie_polling = 1;
100 if (rtc->uie_timer_active) { 100 if (rtc->uie_timer_active) {
101 spin_unlock_irq(&rtc->irq_lock); 101 spin_unlock_irq(&rtc->irq_lock);
@@ -108,9 +108,10 @@ static void clear_uie(struct rtc_device *rtc)
108 flush_scheduled_work(); 108 flush_scheduled_work();
109 spin_lock_irq(&rtc->irq_lock); 109 spin_lock_irq(&rtc->irq_lock);
110 } 110 }
111 rtc->irq_active = 0; 111 rtc->uie_irq_active = 0;
112 } 112 }
113 spin_unlock_irq(&rtc->irq_lock); 113 spin_unlock_irq(&rtc->irq_lock);
114 return 0;
114} 115}
115 116
116static int set_uie(struct rtc_device *rtc) 117static int set_uie(struct rtc_device *rtc)
@@ -122,8 +123,8 @@ static int set_uie(struct rtc_device *rtc)
122 if (err) 123 if (err)
123 return err; 124 return err;
124 spin_lock_irq(&rtc->irq_lock); 125 spin_lock_irq(&rtc->irq_lock);
125 if (!rtc->irq_active) { 126 if (!rtc->uie_irq_active) {
126 rtc->irq_active = 1; 127 rtc->uie_irq_active = 1;
127 rtc->stop_uie_polling = 0; 128 rtc->stop_uie_polling = 0;
128 rtc->oldsecs = tm.tm_sec; 129 rtc->oldsecs = tm.tm_sec;
129 rtc->uie_task_active = 1; 130 rtc->uie_task_active = 1;
@@ -134,6 +135,16 @@ static int set_uie(struct rtc_device *rtc)
134 spin_unlock_irq(&rtc->irq_lock); 135 spin_unlock_irq(&rtc->irq_lock);
135 return 0; 136 return 0;
136} 137}
138
139int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc, unsigned int enabled)
140{
141 if (enabled)
142 return set_uie(rtc);
143 else
144 return clear_uie(rtc);
145}
146EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul);
147
137#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */ 148#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */
138 149
139static ssize_t 150static ssize_t
@@ -357,6 +368,22 @@ static long rtc_dev_ioctl(struct file *file,
357 err = rtc_irq_set_state(rtc, NULL, 0); 368 err = rtc_irq_set_state(rtc, NULL, 0);
358 break; 369 break;
359 370
371 case RTC_AIE_ON:
372 mutex_unlock(&rtc->ops_lock);
373 return rtc_alarm_irq_enable(rtc, 1);
374
375 case RTC_AIE_OFF:
376 mutex_unlock(&rtc->ops_lock);
377 return rtc_alarm_irq_enable(rtc, 0);
378
379 case RTC_UIE_ON:
380 mutex_unlock(&rtc->ops_lock);
381 return rtc_update_irq_enable(rtc, 1);
382
383 case RTC_UIE_OFF:
384 mutex_unlock(&rtc->ops_lock);
385 return rtc_update_irq_enable(rtc, 0);
386
360 case RTC_IRQP_SET: 387 case RTC_IRQP_SET:
361 err = rtc_irq_set_freq(rtc, NULL, arg); 388 err = rtc_irq_set_freq(rtc, NULL, arg);
362 break; 389 break;
@@ -401,17 +428,6 @@ static long rtc_dev_ioctl(struct file *file,
401 err = -EFAULT; 428 err = -EFAULT;
402 return err; 429 return err;
403 430
404#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
405 case RTC_UIE_OFF:
406 mutex_unlock(&rtc->ops_lock);
407 clear_uie(rtc);
408 return 0;
409
410 case RTC_UIE_ON:
411 mutex_unlock(&rtc->ops_lock);
412 err = set_uie(rtc);
413 return err;
414#endif
415 default: 431 default:
416 err = -ENOTTY; 432 err = -ENOTTY;
417 break; 433 break;
@@ -440,7 +456,10 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
440 * Leave the alarm alone; it may be set to trigger a system wakeup 456 * Leave the alarm alone; it may be set to trigger a system wakeup
441 * later, or be used by kernel code, and is a one-shot event anyway. 457 * later, or be used by kernel code, and is a one-shot event anyway.
442 */ 458 */
459
460 /* Keep ioctl until all drivers are converted */
443 rtc_dev_ioctl(file, RTC_UIE_OFF, 0); 461 rtc_dev_ioctl(file, RTC_UIE_OFF, 0);
462 rtc_update_irq_enable(rtc, 0);
444 rtc_irq_set_state(rtc, NULL, 0); 463 rtc_irq_set_state(rtc, NULL, 0);
445 464
446 if (rtc->ops->release) 465 if (rtc->ops->release)
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 8a8df7552969..06b71823f399 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -632,8 +632,8 @@ do_IRQ (struct pt_regs *regs)
632 struct pt_regs *old_regs; 632 struct pt_regs *old_regs;
633 633
634 old_regs = set_irq_regs(regs); 634 old_regs = set_irq_regs(regs);
635 irq_enter();
636 s390_idle_check(); 635 s390_idle_check();
636 irq_enter();
637 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator) 637 if (S390_lowcore.int_clock >= S390_lowcore.clock_comparator)
638 /* Serve timer interrupts first. */ 638 /* Serve timer interrupts first. */
639 clock_comparator_work(); 639 clock_comparator_work();
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index d5ccce1643e4..e0c45574b0c8 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -643,7 +643,6 @@ struct qeth_card_options {
643 int macaddr_mode; 643 int macaddr_mode;
644 int fake_broadcast; 644 int fake_broadcast;
645 int add_hhlen; 645 int add_hhlen;
646 int fake_ll;
647 int layer2; 646 int layer2;
648 enum qeth_large_send_types large_send; 647 enum qeth_large_send_types large_send;
649 int performance_stats; 648 int performance_stats;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index e783644a2105..6811dd529f48 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -287,8 +287,15 @@ int qeth_set_large_send(struct qeth_card *card,
287 card->options.large_send = type; 287 card->options.large_send = type;
288 switch (card->options.large_send) { 288 switch (card->options.large_send) {
289 case QETH_LARGE_SEND_EDDP: 289 case QETH_LARGE_SEND_EDDP:
290 card->dev->features |= NETIF_F_TSO | NETIF_F_SG | 290 if (card->info.type != QETH_CARD_TYPE_IQD) {
291 card->dev->features |= NETIF_F_TSO | NETIF_F_SG |
291 NETIF_F_HW_CSUM; 292 NETIF_F_HW_CSUM;
293 } else {
294 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
295 NETIF_F_HW_CSUM);
296 card->options.large_send = QETH_LARGE_SEND_NO;
297 rc = -EOPNOTSUPP;
298 }
292 break; 299 break;
293 case QETH_LARGE_SEND_TSO: 300 case QETH_LARGE_SEND_TSO:
294 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { 301 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
@@ -572,6 +579,10 @@ static void qeth_send_control_data_cb(struct qeth_channel *channel,
572 card = CARD_FROM_CDEV(channel->ccwdev); 579 card = CARD_FROM_CDEV(channel->ccwdev);
573 if (qeth_check_idx_response(iob->data)) { 580 if (qeth_check_idx_response(iob->data)) {
574 qeth_clear_ipacmd_list(card); 581 qeth_clear_ipacmd_list(card);
582 if (((iob->data[2] & 0xc0) == 0xc0) && iob->data[4] == 0xf6)
583 dev_err(&card->gdev->dev,
584 "The qeth device is not configured "
585 "for the OSI layer required by z/VM\n");
575 qeth_schedule_recovery(card); 586 qeth_schedule_recovery(card);
576 goto out; 587 goto out;
577 } 588 }
@@ -1072,7 +1083,6 @@ static void qeth_set_intial_options(struct qeth_card *card)
1072 card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL; 1083 card->options.macaddr_mode = QETH_TR_MACADDR_NONCANONICAL;
1073 card->options.fake_broadcast = 0; 1084 card->options.fake_broadcast = 0;
1074 card->options.add_hhlen = DEFAULT_ADD_HHLEN; 1085 card->options.add_hhlen = DEFAULT_ADD_HHLEN;
1075 card->options.fake_ll = 0;
1076 card->options.performance_stats = 0; 1086 card->options.performance_stats = 0;
1077 card->options.rx_sg_cb = QETH_RX_SG_CB; 1087 card->options.rx_sg_cb = QETH_RX_SG_CB;
1078} 1088}
@@ -1682,6 +1692,7 @@ int qeth_send_control_data(struct qeth_card *card, int len,
1682 unsigned long flags; 1692 unsigned long flags;
1683 struct qeth_reply *reply = NULL; 1693 struct qeth_reply *reply = NULL;
1684 unsigned long timeout; 1694 unsigned long timeout;
1695 struct qeth_ipa_cmd *cmd;
1685 1696
1686 QETH_DBF_TEXT(TRACE, 2, "sendctl"); 1697 QETH_DBF_TEXT(TRACE, 2, "sendctl");
1687 1698
@@ -1728,17 +1739,34 @@ int qeth_send_control_data(struct qeth_card *card, int len,
1728 wake_up(&card->wait_q); 1739 wake_up(&card->wait_q);
1729 return rc; 1740 return rc;
1730 } 1741 }
1731 while (!atomic_read(&reply->received)) { 1742
1732 if (time_after(jiffies, timeout)) { 1743 /* we have only one long running ipassist, since we can ensure
1733 spin_lock_irqsave(&reply->card->lock, flags); 1744 process context of this command we can sleep */
1734 list_del_init(&reply->list); 1745 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
1735 spin_unlock_irqrestore(&reply->card->lock, flags); 1746 if ((cmd->hdr.command == IPA_CMD_SETIP) &&
1736 reply->rc = -ETIME; 1747 (cmd->hdr.prot_version == QETH_PROT_IPV4)) {
1737 atomic_inc(&reply->received); 1748 if (!wait_event_timeout(reply->wait_q,
1738 wake_up(&reply->wait_q); 1749 atomic_read(&reply->received), timeout))
1739 } 1750 goto time_err;
1740 cpu_relax(); 1751 } else {
1741 }; 1752 while (!atomic_read(&reply->received)) {
1753 if (time_after(jiffies, timeout))
1754 goto time_err;
1755 cpu_relax();
1756 };
1757 }
1758
1759 rc = reply->rc;
1760 qeth_put_reply(reply);
1761 return rc;
1762
1763time_err:
1764 spin_lock_irqsave(&reply->card->lock, flags);
1765 list_del_init(&reply->list);
1766 spin_unlock_irqrestore(&reply->card->lock, flags);
1767 reply->rc = -ETIME;
1768 atomic_inc(&reply->received);
1769 wake_up(&reply->wait_q);
1742 rc = reply->rc; 1770 rc = reply->rc;
1743 qeth_put_reply(reply); 1771 qeth_put_reply(reply);
1744 return rc; 1772 return rc;
@@ -2250,7 +2278,8 @@ void qeth_print_status_message(struct qeth_card *card)
2250 } 2278 }
2251 /* fallthrough */ 2279 /* fallthrough */
2252 case QETH_CARD_TYPE_IQD: 2280 case QETH_CARD_TYPE_IQD:
2253 if (card->info.guestlan) { 2281 if ((card->info.guestlan) ||
2282 (card->info.mcl_level[0] & 0x80)) {
2254 card->info.mcl_level[0] = (char) _ebcasc[(__u8) 2283 card->info.mcl_level[0] = (char) _ebcasc[(__u8)
2255 card->info.mcl_level[0]]; 2284 card->info.mcl_level[0]];
2256 card->info.mcl_level[1] = (char) _ebcasc[(__u8) 2285 card->info.mcl_level[1] = (char) _ebcasc[(__u8)
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 2c48591ced44..21627ba3093b 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1126,9 +1126,11 @@ static int qeth_l2_recover(void *ptr)
1126 dev_info(&card->gdev->dev, 1126 dev_info(&card->gdev->dev,
1127 "Device successfully recovered!\n"); 1127 "Device successfully recovered!\n");
1128 else { 1128 else {
1129 rtnl_lock(); 1129 if (card->dev) {
1130 dev_close(card->dev); 1130 rtnl_lock();
1131 rtnl_unlock(); 1131 dev_close(card->dev);
1132 rtnl_unlock();
1133 }
1132 dev_warn(&card->gdev->dev, "The qeth device driver " 1134 dev_warn(&card->gdev->dev, "The qeth device driver "
1133 "failed to recover an error on the device\n"); 1135 "failed to recover an error on the device\n");
1134 } 1136 }
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index c0b30b25a5f1..cfda1ecffdf2 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1047,7 +1047,7 @@ static int qeth_l3_setadapter_parms(struct qeth_card *card)
1047 rc = qeth_setadpparms_change_macaddr(card); 1047 rc = qeth_setadpparms_change_macaddr(card);
1048 if (rc) 1048 if (rc)
1049 dev_warn(&card->gdev->dev, "Reading the adapter MAC" 1049 dev_warn(&card->gdev->dev, "Reading the adapter MAC"
1050 " address failed\n", rc); 1050 " address failed\n");
1051 } 1051 }
1052 1052
1053 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) || 1053 if ((card->info.link_type == QETH_LINK_TYPE_HSTR) ||
@@ -1207,12 +1207,9 @@ static int qeth_l3_start_ipa_source_mac(struct qeth_card *card)
1207 1207
1208 QETH_DBF_TEXT(TRACE, 3, "stsrcmac"); 1208 QETH_DBF_TEXT(TRACE, 3, "stsrcmac");
1209 1209
1210 if (!card->options.fake_ll)
1211 return -EOPNOTSUPP;
1212
1213 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { 1210 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) {
1214 dev_info(&card->gdev->dev, 1211 dev_info(&card->gdev->dev,
1215 "Inbound source address not supported on %s\n", 1212 "Inbound source MAC-address not supported on %s\n",
1216 QETH_CARD_IFNAME(card)); 1213 QETH_CARD_IFNAME(card));
1217 return -EOPNOTSUPP; 1214 return -EOPNOTSUPP;
1218 } 1215 }
@@ -1221,7 +1218,7 @@ static int qeth_l3_start_ipa_source_mac(struct qeth_card *card)
1221 IPA_CMD_ASS_START, 0); 1218 IPA_CMD_ASS_START, 0);
1222 if (rc) 1219 if (rc)
1223 dev_warn(&card->gdev->dev, 1220 dev_warn(&card->gdev->dev,
1224 "Starting proxy ARP support for %s failed\n", 1221 "Starting source MAC-address support for %s failed\n",
1225 QETH_CARD_IFNAME(card)); 1222 QETH_CARD_IFNAME(card));
1226 return rc; 1223 return rc;
1227} 1224}
@@ -1921,8 +1918,13 @@ static inline __u16 qeth_l3_rebuild_skb(struct qeth_card *card,
1921 memcpy(tg_addr, card->dev->dev_addr, 1918 memcpy(tg_addr, card->dev->dev_addr,
1922 card->dev->addr_len); 1919 card->dev->addr_len);
1923 } 1920 }
1924 card->dev->header_ops->create(skb, card->dev, prot, tg_addr, 1921 if (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_SRC_MAC_ADDR)
1925 "FAKELL", card->dev->addr_len); 1922 card->dev->header_ops->create(skb, card->dev, prot,
1923 tg_addr, &hdr->hdr.l3.dest_addr[2],
1924 card->dev->addr_len);
1925 else
1926 card->dev->header_ops->create(skb, card->dev, prot,
1927 tg_addr, "FAKELL", card->dev->addr_len);
1926 } 1928 }
1927 1929
1928#ifdef CONFIG_TR 1930#ifdef CONFIG_TR
@@ -2080,9 +2082,11 @@ static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
2080 if (recovery_mode) 2082 if (recovery_mode)
2081 qeth_l3_stop(card->dev); 2083 qeth_l3_stop(card->dev);
2082 else { 2084 else {
2083 rtnl_lock(); 2085 if (card->dev) {
2084 dev_close(card->dev); 2086 rtnl_lock();
2085 rtnl_unlock(); 2087 dev_close(card->dev);
2088 rtnl_unlock();
2089 }
2086 } 2090 }
2087 if (!card->use_hard_stop) { 2091 if (!card->use_hard_stop) {
2088 rc = qeth_send_stoplan(card); 2092 rc = qeth_send_stoplan(card);
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c
index 834e9ee7e934..92b0417f8e12 100644
--- a/drivers/s390/s390mach.c
+++ b/drivers/s390/s390mach.c
@@ -18,6 +18,7 @@
18#include <asm/etr.h> 18#include <asm/etr.h>
19#include <asm/lowcore.h> 19#include <asm/lowcore.h>
20#include <asm/cio.h> 20#include <asm/cio.h>
21#include <asm/cpu.h>
21#include "s390mach.h" 22#include "s390mach.h"
22 23
23static struct semaphore m_sem; 24static struct semaphore m_sem;
@@ -369,6 +370,8 @@ s390_do_machine_check(struct pt_regs *regs)
369 370
370 lockdep_off(); 371 lockdep_off();
371 372
373 s390_idle_check();
374
372 mci = (struct mci *) &S390_lowcore.mcck_interruption_code; 375 mci = (struct mci *) &S390_lowcore.mcck_interruption_code;
373 mcck = &__get_cpu_var(cpu_mcck); 376 mcck = &__get_cpu_var(cpu_mcck);
374 umode = user_mode(regs); 377 umode = user_mode(regs);
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 185be760833e..2a129cb7bb56 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -279,7 +279,6 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
279 inode->i_mode = mode; 279 inode->i_mode = mode;
280 inode->i_uid = current_fsuid(); 280 inode->i_uid = current_fsuid();
281 inode->i_gid = current_fsgid(); 281 inode->i_gid = current_fsgid();
282 inode->i_blocks = 0;
283 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 282 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
284 switch (mode & S_IFMT) { 283 switch (mode & S_IFMT) {
285 default: 284 default:
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index c4e62a6297d7..2e71368f45b4 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1863,26 +1863,10 @@ static int do_write(struct fsg_dev *fsg)
1863static int fsync_sub(struct lun *curlun) 1863static int fsync_sub(struct lun *curlun)
1864{ 1864{
1865 struct file *filp = curlun->filp; 1865 struct file *filp = curlun->filp;
1866 struct inode *inode;
1867 int rc, err;
1868 1866
1869 if (curlun->ro || !filp) 1867 if (curlun->ro || !filp)
1870 return 0; 1868 return 0;
1871 if (!filp->f_op->fsync) 1869 return vfs_fsync(filp, filp->f_path.dentry, 1);
1872 return -EINVAL;
1873
1874 inode = filp->f_path.dentry->d_inode;
1875 mutex_lock(&inode->i_mutex);
1876 rc = filemap_fdatawrite(inode->i_mapping);
1877 err = filp->f_op->fsync(filp, filp->f_path.dentry, 1);
1878 if (!rc)
1879 rc = err;
1880 err = filemap_fdatawait(inode->i_mapping);
1881 if (!rc)
1882 rc = err;
1883 mutex_unlock(&inode->i_mutex);
1884 VLDBG(curlun, "fdatasync -> %d\n", rc);
1885 return rc;
1886} 1870}
1887 1871
1888static void fsync_all(struct fsg_dev *fsg) 1872static void fsync_all(struct fsg_dev *fsg)
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index eeb26c0f88e5..317b48fdbf01 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -2001,7 +2001,6 @@ gadgetfs_make_inode (struct super_block *sb,
2001 inode->i_mode = mode; 2001 inode->i_mode = mode;
2002 inode->i_uid = default_uid; 2002 inode->i_uid = default_uid;
2003 inode->i_gid = default_gid; 2003 inode->i_gid = default_gid;
2004 inode->i_blocks = 0;
2005 inode->i_atime = inode->i_mtime = inode->i_ctime 2004 inode->i_atime = inode->i_mtime = inode->i_ctime
2006 = CURRENT_TIME; 2005 = CURRENT_TIME;
2007 inode->i_private = data; 2006 inode->i_private = data;
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 73ac754ad801..e21fe5b6f9ff 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -546,23 +546,25 @@ static int viafb_blank(int blank_mode, struct fb_info *info)
546 546
547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 547static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
548{ 548{
549 struct viafb_ioctl_mode viamode; 549 union {
550 struct viafb_ioctl_samm viasamm; 550 struct viafb_ioctl_mode viamode;
551 struct viafb_driver_version driver_version; 551 struct viafb_ioctl_samm viasamm;
552 struct fb_var_screeninfo sec_var; 552 struct viafb_driver_version driver_version;
553 struct _panel_size_pos_info panel_pos_size_para; 553 struct fb_var_screeninfo sec_var;
554 struct _panel_size_pos_info panel_pos_size_para;
555 struct viafb_ioctl_setting viafb_setting;
556 struct device_t active_dev;
557 } u;
554 u32 state_info = 0; 558 u32 state_info = 0;
555 u32 viainfo_size = sizeof(struct viafb_ioctl_info);
556 u32 *viafb_gamma_table; 559 u32 *viafb_gamma_table;
557 char driver_name[] = "viafb"; 560 char driver_name[] = "viafb";
558 561
559 u32 __user *argp = (u32 __user *) arg; 562 u32 __user *argp = (u32 __user *) arg;
560 u32 gpu32; 563 u32 gpu32;
561 u32 video_dev_info = 0; 564 u32 video_dev_info = 0;
562 struct viafb_ioctl_setting viafb_setting = {};
563 struct device_t active_dev = {};
564 565
565 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd); 566 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
567 memset(&u, 0, sizeof(u));
566 568
567 switch (cmd) { 569 switch (cmd) {
568 case VIAFB_GET_CHIP_INFO: 570 case VIAFB_GET_CHIP_INFO:
@@ -571,7 +573,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
571 return -EFAULT; 573 return -EFAULT;
572 break; 574 break;
573 case VIAFB_GET_INFO_SIZE: 575 case VIAFB_GET_INFO_SIZE:
574 return put_user(viainfo_size, argp); 576 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
575 case VIAFB_GET_INFO: 577 case VIAFB_GET_INFO:
576 return viafb_ioctl_get_viafb_info(arg); 578 return viafb_ioctl_get_viafb_info(arg);
577 case VIAFB_HOTPLUG: 579 case VIAFB_HOTPLUG:
@@ -584,60 +586,60 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
584 viafb_hotplug = (gpu32) ? 1 : 0; 586 viafb_hotplug = (gpu32) ? 1 : 0;
585 break; 587 break;
586 case VIAFB_GET_RESOLUTION: 588 case VIAFB_GET_RESOLUTION:
587 viamode.xres = (u32) viafb_hotplug_Xres; 589 u.viamode.xres = (u32) viafb_hotplug_Xres;
588 viamode.yres = (u32) viafb_hotplug_Yres; 590 u.viamode.yres = (u32) viafb_hotplug_Yres;
589 viamode.refresh = (u32) viafb_hotplug_refresh; 591 u.viamode.refresh = (u32) viafb_hotplug_refresh;
590 viamode.bpp = (u32) viafb_hotplug_bpp; 592 u.viamode.bpp = (u32) viafb_hotplug_bpp;
591 if (viafb_SAMM_ON == 1) { 593 if (viafb_SAMM_ON == 1) {
592 viamode.xres_sec = viafb_second_xres; 594 u.viamode.xres_sec = viafb_second_xres;
593 viamode.yres_sec = viafb_second_yres; 595 u.viamode.yres_sec = viafb_second_yres;
594 viamode.virtual_xres_sec = viafb_second_virtual_xres; 596 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
595 viamode.virtual_yres_sec = viafb_second_virtual_yres; 597 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
596 viamode.refresh_sec = viafb_refresh1; 598 u.viamode.refresh_sec = viafb_refresh1;
597 viamode.bpp_sec = viafb_bpp1; 599 u.viamode.bpp_sec = viafb_bpp1;
598 } else { 600 } else {
599 viamode.xres_sec = 0; 601 u.viamode.xres_sec = 0;
600 viamode.yres_sec = 0; 602 u.viamode.yres_sec = 0;
601 viamode.virtual_xres_sec = 0; 603 u.viamode.virtual_xres_sec = 0;
602 viamode.virtual_yres_sec = 0; 604 u.viamode.virtual_yres_sec = 0;
603 viamode.refresh_sec = 0; 605 u.viamode.refresh_sec = 0;
604 viamode.bpp_sec = 0; 606 u.viamode.bpp_sec = 0;
605 } 607 }
606 if (copy_to_user(argp, &viamode, sizeof(viamode))) 608 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
607 return -EFAULT; 609 return -EFAULT;
608 break; 610 break;
609 case VIAFB_GET_SAMM_INFO: 611 case VIAFB_GET_SAMM_INFO:
610 viasamm.samm_status = viafb_SAMM_ON; 612 u.viasamm.samm_status = viafb_SAMM_ON;
611 613
612 if (viafb_SAMM_ON == 1) { 614 if (viafb_SAMM_ON == 1) {
613 if (viafb_dual_fb) { 615 if (viafb_dual_fb) {
614 viasamm.size_prim = viaparinfo->fbmem_free; 616 u.viasamm.size_prim = viaparinfo->fbmem_free;
615 viasamm.size_sec = viaparinfo1->fbmem_free; 617 u.viasamm.size_sec = viaparinfo1->fbmem_free;
616 } else { 618 } else {
617 if (viafb_second_size) { 619 if (viafb_second_size) {
618 viasamm.size_prim = 620 u.viasamm.size_prim =
619 viaparinfo->fbmem_free - 621 viaparinfo->fbmem_free -
620 viafb_second_size * 1024 * 1024; 622 viafb_second_size * 1024 * 1024;
621 viasamm.size_sec = 623 u.viasamm.size_sec =
622 viafb_second_size * 1024 * 1024; 624 viafb_second_size * 1024 * 1024;
623 } else { 625 } else {
624 viasamm.size_prim = 626 u.viasamm.size_prim =
625 viaparinfo->fbmem_free >> 1; 627 viaparinfo->fbmem_free >> 1;
626 viasamm.size_sec = 628 u.viasamm.size_sec =
627 (viaparinfo->fbmem_free >> 1); 629 (viaparinfo->fbmem_free >> 1);
628 } 630 }
629 } 631 }
630 viasamm.mem_base = viaparinfo->fbmem; 632 u.viasamm.mem_base = viaparinfo->fbmem;
631 viasamm.offset_sec = viafb_second_offset; 633 u.viasamm.offset_sec = viafb_second_offset;
632 } else { 634 } else {
633 viasamm.size_prim = 635 u.viasamm.size_prim =
634 viaparinfo->memsize - viaparinfo->fbmem_used; 636 viaparinfo->memsize - viaparinfo->fbmem_used;
635 viasamm.size_sec = 0; 637 u.viasamm.size_sec = 0;
636 viasamm.mem_base = viaparinfo->fbmem; 638 u.viasamm.mem_base = viaparinfo->fbmem;
637 viasamm.offset_sec = 0; 639 u.viasamm.offset_sec = 0;
638 } 640 }
639 641
640 if (copy_to_user(argp, &viasamm, sizeof(viasamm))) 642 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
641 return -EFAULT; 643 return -EFAULT;
642 644
643 break; 645 break;
@@ -662,74 +664,75 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
662 viafb_lcd_disable(); 664 viafb_lcd_disable();
663 break; 665 break;
664 case VIAFB_SET_DEVICE: 666 case VIAFB_SET_DEVICE:
665 if (copy_from_user(&active_dev, (void *)argp, 667 if (copy_from_user(&u.active_dev, (void *)argp,
666 sizeof(active_dev))) 668 sizeof(u.active_dev)))
667 return -EFAULT; 669 return -EFAULT;
668 viafb_set_device(active_dev); 670 viafb_set_device(u.active_dev);
669 viafb_set_par(info); 671 viafb_set_par(info);
670 break; 672 break;
671 case VIAFB_GET_DEVICE: 673 case VIAFB_GET_DEVICE:
672 active_dev.crt = viafb_CRT_ON; 674 u.active_dev.crt = viafb_CRT_ON;
673 active_dev.dvi = viafb_DVI_ON; 675 u.active_dev.dvi = viafb_DVI_ON;
674 active_dev.lcd = viafb_LCD_ON; 676 u.active_dev.lcd = viafb_LCD_ON;
675 active_dev.samm = viafb_SAMM_ON; 677 u.active_dev.samm = viafb_SAMM_ON;
676 active_dev.primary_dev = viafb_primary_dev; 678 u.active_dev.primary_dev = viafb_primary_dev;
677 679
678 active_dev.lcd_dsp_cent = viafb_lcd_dsp_method; 680 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
679 active_dev.lcd_panel_id = viafb_lcd_panel_id; 681 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
680 active_dev.lcd_mode = viafb_lcd_mode; 682 u.active_dev.lcd_mode = viafb_lcd_mode;
681 683
682 active_dev.xres = viafb_hotplug_Xres; 684 u.active_dev.xres = viafb_hotplug_Xres;
683 active_dev.yres = viafb_hotplug_Yres; 685 u.active_dev.yres = viafb_hotplug_Yres;
684 686
685 active_dev.xres1 = viafb_second_xres; 687 u.active_dev.xres1 = viafb_second_xres;
686 active_dev.yres1 = viafb_second_yres; 688 u.active_dev.yres1 = viafb_second_yres;
687 689
688 active_dev.bpp = viafb_bpp; 690 u.active_dev.bpp = viafb_bpp;
689 active_dev.bpp1 = viafb_bpp1; 691 u.active_dev.bpp1 = viafb_bpp1;
690 active_dev.refresh = viafb_refresh; 692 u.active_dev.refresh = viafb_refresh;
691 active_dev.refresh1 = viafb_refresh1; 693 u.active_dev.refresh1 = viafb_refresh1;
692 694
693 active_dev.epia_dvi = viafb_platform_epia_dvi; 695 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
694 active_dev.lcd_dual_edge = viafb_device_lcd_dualedge; 696 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
695 active_dev.bus_width = viafb_bus_width; 697 u.active_dev.bus_width = viafb_bus_width;
696 698
697 if (copy_to_user(argp, &active_dev, sizeof(active_dev))) 699 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
698 return -EFAULT; 700 return -EFAULT;
699 break; 701 break;
700 702
701 case VIAFB_GET_DRIVER_VERSION: 703 case VIAFB_GET_DRIVER_VERSION:
702 driver_version.iMajorNum = VERSION_MAJOR; 704 u.driver_version.iMajorNum = VERSION_MAJOR;
703 driver_version.iKernelNum = VERSION_KERNEL; 705 u.driver_version.iKernelNum = VERSION_KERNEL;
704 driver_version.iOSNum = VERSION_OS; 706 u.driver_version.iOSNum = VERSION_OS;
705 driver_version.iMinorNum = VERSION_MINOR; 707 u.driver_version.iMinorNum = VERSION_MINOR;
706 708
707 if (copy_to_user(argp, &driver_version, 709 if (copy_to_user(argp, &u.driver_version,
708 sizeof(driver_version))) 710 sizeof(u.driver_version)))
709 return -EFAULT; 711 return -EFAULT;
710 712
711 break; 713 break;
712 714
713 case VIAFB_SET_DEVICE_INFO: 715 case VIAFB_SET_DEVICE_INFO:
714 if (copy_from_user(&viafb_setting, 716 if (copy_from_user(&u.viafb_setting,
715 argp, sizeof(viafb_setting))) 717 argp, sizeof(u.viafb_setting)))
716 return -EFAULT; 718 return -EFAULT;
717 if (apply_device_setting(viafb_setting, info) < 0) 719 if (apply_device_setting(u.viafb_setting, info) < 0)
718 return -EINVAL; 720 return -EINVAL;
719 721
720 break; 722 break;
721 723
722 case VIAFB_SET_SECOND_MODE: 724 case VIAFB_SET_SECOND_MODE:
723 if (copy_from_user(&sec_var, argp, sizeof(sec_var))) 725 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
724 return -EFAULT; 726 return -EFAULT;
725 apply_second_mode_setting(&sec_var); 727 apply_second_mode_setting(&u.sec_var);
726 break; 728 break;
727 729
728 case VIAFB_GET_DEVICE_INFO: 730 case VIAFB_GET_DEVICE_INFO:
729 731
730 retrieve_device_setting(&viafb_setting); 732 retrieve_device_setting(&u.viafb_setting);
731 733
732 if (copy_to_user(argp, &viafb_setting, sizeof(viafb_setting))) 734 if (copy_to_user(argp, &u.viafb_setting,
735 sizeof(u.viafb_setting)))
733 return -EFAULT; 736 return -EFAULT;
734 737
735 break; 738 break;
@@ -806,51 +809,51 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
806 break; 809 break;
807 810
808 case VIAFB_GET_PANEL_MAX_SIZE: 811 case VIAFB_GET_PANEL_MAX_SIZE:
809 if (copy_from_user 812 if (copy_from_user(&u.panel_pos_size_para, argp,
810 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 813 sizeof(u.panel_pos_size_para)))
811 return -EFAULT; 814 return -EFAULT;
812 panel_pos_size_para.x = panel_pos_size_para.y = 0; 815 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
813 if (copy_to_user(argp, &panel_pos_size_para, 816 if (copy_to_user(argp, &u.panel_pos_size_para,
814 sizeof(panel_pos_size_para))) 817 sizeof(u.panel_pos_size_para)))
815 return -EFAULT; 818 return -EFAULT;
816 break; 819 break;
817 case VIAFB_GET_PANEL_MAX_POSITION: 820 case VIAFB_GET_PANEL_MAX_POSITION:
818 if (copy_from_user 821 if (copy_from_user(&u.panel_pos_size_para, argp,
819 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 822 sizeof(u.panel_pos_size_para)))
820 return -EFAULT; 823 return -EFAULT;
821 panel_pos_size_para.x = panel_pos_size_para.y = 0; 824 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
822 if (copy_to_user(argp, &panel_pos_size_para, 825 if (copy_to_user(argp, &u.panel_pos_size_para,
823 sizeof(panel_pos_size_para))) 826 sizeof(u.panel_pos_size_para)))
824 return -EFAULT; 827 return -EFAULT;
825 break; 828 break;
826 829
827 case VIAFB_GET_PANEL_POSITION: 830 case VIAFB_GET_PANEL_POSITION:
828 if (copy_from_user 831 if (copy_from_user(&u.panel_pos_size_para, argp,
829 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 832 sizeof(u.panel_pos_size_para)))
830 return -EFAULT; 833 return -EFAULT;
831 panel_pos_size_para.x = panel_pos_size_para.y = 0; 834 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
832 if (copy_to_user(argp, &panel_pos_size_para, 835 if (copy_to_user(argp, &u.panel_pos_size_para,
833 sizeof(panel_pos_size_para))) 836 sizeof(u.panel_pos_size_para)))
834 return -EFAULT; 837 return -EFAULT;
835 break; 838 break;
836 case VIAFB_GET_PANEL_SIZE: 839 case VIAFB_GET_PANEL_SIZE:
837 if (copy_from_user 840 if (copy_from_user(&u.panel_pos_size_para, argp,
838 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 841 sizeof(u.panel_pos_size_para)))
839 return -EFAULT; 842 return -EFAULT;
840 panel_pos_size_para.x = panel_pos_size_para.y = 0; 843 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
841 if (copy_to_user(argp, &panel_pos_size_para, 844 if (copy_to_user(argp, &u.panel_pos_size_para,
842 sizeof(panel_pos_size_para))) 845 sizeof(u.panel_pos_size_para)))
843 return -EFAULT; 846 return -EFAULT;
844 break; 847 break;
845 848
846 case VIAFB_SET_PANEL_POSITION: 849 case VIAFB_SET_PANEL_POSITION:
847 if (copy_from_user 850 if (copy_from_user(&u.panel_pos_size_para, argp,
848 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 851 sizeof(u.panel_pos_size_para)))
849 return -EFAULT; 852 return -EFAULT;
850 break; 853 break;
851 case VIAFB_SET_PANEL_SIZE: 854 case VIAFB_SET_PANEL_SIZE:
852 if (copy_from_user 855 if (copy_from_user(&u.panel_pos_size_para, argp,
853 (&panel_pos_size_para, argp, sizeof(panel_pos_size_para))) 856 sizeof(u.panel_pos_size_para)))
854 return -EFAULT; 857 return -EFAULT;
855 break; 858 break;
856 859
@@ -1052,10 +1055,8 @@ static void viafb_imageblit(struct fb_info *info,
1052 1055
1053static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1056static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1054{ 1057{
1055 u8 data[CURSOR_SIZE / 8];
1056 u32 data_bak[CURSOR_SIZE / 32];
1057 u32 temp, xx, yy, bg_col = 0, fg_col = 0; 1058 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
1058 int size, i, j = 0; 1059 int i, j = 0;
1059 static int hw_cursor; 1060 static int hw_cursor;
1060 struct viafb_par *p_viafb_par; 1061 struct viafb_par *p_viafb_par;
1061 1062
@@ -1178,22 +1179,29 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1178 } 1179 }
1179 1180
1180 if (cursor->set & FB_CUR_SETSHAPE) { 1181 if (cursor->set & FB_CUR_SETSHAPE) {
1181 size = 1182 struct {
1183 u8 data[CURSOR_SIZE / 8];
1184 u32 bak[CURSOR_SIZE / 32];
1185 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
1186 int size =
1182 ((viacursor.image.width + 7) >> 3) * 1187 ((viacursor.image.width + 7) >> 3) *
1183 viacursor.image.height; 1188 viacursor.image.height;
1184 1189
1190 if (cr_data == NULL)
1191 goto out;
1192
1185 if (MAX_CURS == 32) { 1193 if (MAX_CURS == 32) {
1186 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1194 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1187 data_bak[i] = 0x0; 1195 cr_data->bak[i] = 0x0;
1188 data_bak[i + 1] = 0xFFFFFFFF; 1196 cr_data->bak[i + 1] = 0xFFFFFFFF;
1189 i += 1; 1197 i += 1;
1190 } 1198 }
1191 } else if (MAX_CURS == 64) { 1199 } else if (MAX_CURS == 64) {
1192 for (i = 0; i < (CURSOR_SIZE / 32); i++) { 1200 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1193 data_bak[i] = 0x0; 1201 cr_data->bak[i] = 0x0;
1194 data_bak[i + 1] = 0x0; 1202 cr_data->bak[i + 1] = 0x0;
1195 data_bak[i + 2] = 0xFFFFFFFF; 1203 cr_data->bak[i + 2] = 0xFFFFFFFF;
1196 data_bak[i + 3] = 0xFFFFFFFF; 1204 cr_data->bak[i + 3] = 0xFFFFFFFF;
1197 i += 3; 1205 i += 3;
1198 } 1206 }
1199 } 1207 }
@@ -1201,12 +1209,12 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1201 switch (viacursor.rop) { 1209 switch (viacursor.rop) {
1202 case ROP_XOR: 1210 case ROP_XOR:
1203 for (i = 0; i < size; i++) 1211 for (i = 0; i < size; i++)
1204 data[i] = viacursor.mask[i]; 1212 cr_data->data[i] = viacursor.mask[i];
1205 break; 1213 break;
1206 case ROP_COPY: 1214 case ROP_COPY:
1207 1215
1208 for (i = 0; i < size; i++) 1216 for (i = 0; i < size; i++)
1209 data[i] = viacursor.mask[i]; 1217 cr_data->data[i] = viacursor.mask[i];
1210 break; 1218 break;
1211 default: 1219 default:
1212 break; 1220 break;
@@ -1214,23 +1222,25 @@ static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1214 1222
1215 if (MAX_CURS == 32) { 1223 if (MAX_CURS == 32) {
1216 for (i = 0; i < size; i++) { 1224 for (i = 0; i < size; i++) {
1217 data_bak[j] = (u32) data[i]; 1225 cr_data->bak[j] = (u32) cr_data->data[i];
1218 data_bak[j + 1] = ~data_bak[j]; 1226 cr_data->bak[j + 1] = ~cr_data->bak[j];
1219 j += 2; 1227 j += 2;
1220 } 1228 }
1221 } else if (MAX_CURS == 64) { 1229 } else if (MAX_CURS == 64) {
1222 for (i = 0; i < size; i++) { 1230 for (i = 0; i < size; i++) {
1223 data_bak[j] = (u32) data[i]; 1231 cr_data->bak[j] = (u32) cr_data->data[i];
1224 data_bak[j + 1] = 0x0; 1232 cr_data->bak[j + 1] = 0x0;
1225 data_bak[j + 2] = ~data_bak[j]; 1233 cr_data->bak[j + 2] = ~cr_data->bak[j];
1226 data_bak[j + 3] = ~data_bak[j + 1]; 1234 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
1227 j += 4; 1235 j += 4;
1228 } 1236 }
1229 } 1237 }
1230 1238
1231 memcpy(((struct viafb_par *)(info->par))->fbmem_virt + 1239 memcpy(((struct viafb_par *)(info->par))->fbmem_virt +
1232 ((struct viafb_par *)(info->par))->cursor_start, 1240 ((struct viafb_par *)(info->par))->cursor_start,
1233 data_bak, CURSOR_SIZE); 1241 cr_data->bak, CURSOR_SIZE);
1242out:
1243 kfree(cr_data);
1234 } 1244 }
1235 1245
1236 if (viacursor.enable) 1246 if (viacursor.enable)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 4fd3fa5546b1..ec68c741b564 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -55,6 +55,13 @@ config SOFT_WATCHDOG
55 To compile this driver as a module, choose M here: the 55 To compile this driver as a module, choose M here: the
56 module will be called softdog. 56 module will be called softdog.
57 57
58config WM8350_WATCHDOG
59 tristate "WM8350 watchdog"
60 depends on MFD_WM8350
61 help
62 Support for the watchdog in the WM8350 AudioPlus PMIC. When
63 the watchdog triggers the system will be reset.
64
58# ALPHA Architecture 65# ALPHA Architecture
59 66
60# ARM Architecture 67# ARM Architecture
@@ -551,6 +558,18 @@ config CPU5_WDT
551 To compile this driver as a module, choose M here: the 558 To compile this driver as a module, choose M here: the
552 module will be called cpu5wdt. 559 module will be called cpu5wdt.
553 560
561config SMSC_SCH311X_WDT
562 tristate "SMSC SCH311X Watchdog Timer"
563 depends on X86
564 ---help---
565 This is the driver for the hardware watchdog timer on the
566 SMSC SCH3112, SCH3114 and SCH3116 Super IO chipset
567 (LPC IO with 8042 KBC, Reset Generation, HWM and multiple
568 serial ports).
569
570 To compile this driver as a module, choose M here: the
571 module will be called sch311x_wdt.
572
554config SMSC37B787_WDT 573config SMSC37B787_WDT
555 tristate "Winbond SMsC37B787 Watchdog Timer" 574 tristate "Winbond SMsC37B787 Watchdog Timer"
556 depends on X86 575 depends on X86
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index e352bbb7630b..c19b866f5ed1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -83,6 +83,7 @@ obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
83obj-$(CONFIG_SBC8360_WDT) += sbc8360.o 83obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
84obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o 84obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o
85obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 85obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
86obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o
86obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o 87obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
87obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o 88obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
88obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o 89obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
@@ -133,4 +134,5 @@ obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o
133# XTENSA Architecture 134# XTENSA Architecture
134 135
135# Architecture Independant 136# Architecture Independant
137obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
136obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o 138obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c
index 317ef2b16cff..4bef3ddff4a5 100644
--- a/drivers/watchdog/ib700wdt.c
+++ b/drivers/watchdog/ib700wdt.c
@@ -91,32 +91,16 @@ static char expect_close;
91 * 91 *
92 */ 92 */
93 93
94static int wd_times[] = {
95 30, /* 0x0 */
96 28, /* 0x1 */
97 26, /* 0x2 */
98 24, /* 0x3 */
99 22, /* 0x4 */
100 20, /* 0x5 */
101 18, /* 0x6 */
102 16, /* 0x7 */
103 14, /* 0x8 */
104 12, /* 0x9 */
105 10, /* 0xA */
106 8, /* 0xB */
107 6, /* 0xC */
108 4, /* 0xD */
109 2, /* 0xE */
110 0, /* 0xF */
111};
112
113#define WDT_STOP 0x441 94#define WDT_STOP 0x441
114#define WDT_START 0x443 95#define WDT_START 0x443
115 96
116/* Default timeout */ 97/* Default timeout */
117#define WD_TIMO 0 /* 30 seconds +/- 20%, from table */ 98#define WATCHDOG_TIMEOUT 30 /* 30 seconds +/- 20% */
118 99static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
119static int wd_margin = WD_TIMO; 100module_param(timeout, int, 0);
101MODULE_PARM_DESC(timeout,
102 "Watchdog timeout in seconds. 0<= timeout <=30, default="
103 __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
120 104
121static int nowayout = WATCHDOG_NOWAYOUT; 105static int nowayout = WATCHDOG_NOWAYOUT;
122module_param(nowayout, int, 0); 106module_param(nowayout, int, 0);
@@ -131,6 +115,8 @@ MODULE_PARM_DESC(nowayout,
131 115
132static void ibwdt_ping(void) 116static void ibwdt_ping(void)
133{ 117{
118 int wd_margin = 15 - ((timeout + 1) / 2);
119
134 spin_lock(&ibwdt_lock); 120 spin_lock(&ibwdt_lock);
135 121
136 /* Write a watchdog value */ 122 /* Write a watchdog value */
@@ -148,15 +134,10 @@ static void ibwdt_disable(void)
148 134
149static int ibwdt_set_heartbeat(int t) 135static int ibwdt_set_heartbeat(int t)
150{ 136{
151 int i; 137 if (t < 0 || t > 30)
152
153 if ((t < 0) || (t > 30))
154 return -EINVAL; 138 return -EINVAL;
155 139
156 for (i = 0x0F; i > -1; i--) 140 timeout = t;
157 if (wd_times[i] >= t)
158 break;
159 wd_margin = i;
160 return 0; 141 return 0;
161} 142}
162 143
@@ -240,7 +221,7 @@ static long ibwdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
240 /* Fall */ 221 /* Fall */
241 222
242 case WDIOC_GETTIMEOUT: 223 case WDIOC_GETTIMEOUT:
243 return put_user(wd_times[wd_margin], p); 224 return put_user(timeout, p);
244 225
245 default: 226 default:
246 return -ENOTTY; 227 return -ENOTTY;
@@ -317,6 +298,14 @@ static int __devinit ibwdt_probe(struct platform_device *dev)
317 goto out_nostartreg; 298 goto out_nostartreg;
318 } 299 }
319 300
301 /* Check that the heartbeat value is within it's range ;
302 * if not reset to the default */
303 if (ibwdt_set_heartbeat(timeout)) {
304 ibwdt_set_heartbeat(WATCHDOG_TIMEOUT);
305 printk(KERN_INFO PFX
306 "timeout value must be 0<=x<=30, using %d\n", timeout);
307 }
308
320 res = misc_register(&ibwdt_miscdev); 309 res = misc_register(&ibwdt_miscdev);
321 if (res) { 310 if (res) {
322 printk(KERN_ERR PFX "failed to register misc device\n"); 311 printk(KERN_ERR PFX "failed to register misc device\n");
diff --git a/drivers/watchdog/sch311x_wdt.c b/drivers/watchdog/sch311x_wdt.c
new file mode 100644
index 000000000000..569eb295a7a8
--- /dev/null
+++ b/drivers/watchdog/sch311x_wdt.c
@@ -0,0 +1,578 @@
1/*
2 * sch311x_wdt.c - Driver for the SCH311x Super-I/O chips
3 * integrated watchdog.
4 *
5 * (c) Copyright 2008 Wim Van Sebroeck <wim@iguana.be>.
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 * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
13 * provide warranty for any of this software. This material is
14 * provided "AS-IS" and at no charge.
15 */
16
17/*
18 * Includes, defines, variables, module parameters, ...
19 */
20
21/* Includes */
22#include <linux/module.h> /* For module specific items */
23#include <linux/moduleparam.h> /* For new moduleparam's */
24#include <linux/types.h> /* For standard types (like size_t) */
25#include <linux/errno.h> /* For the -ENODEV/... values */
26#include <linux/kernel.h> /* For printk/... */
27#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV
28 (WATCHDOG_MINOR) */
29#include <linux/watchdog.h> /* For the watchdog specific items */
30#include <linux/init.h> /* For __init/__exit/... */
31#include <linux/fs.h> /* For file operations */
32#include <linux/platform_device.h> /* For platform_driver framework */
33#include <linux/ioport.h> /* For io-port access */
34#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
35#include <linux/uaccess.h> /* For copy_to_user/put_user/... */
36#include <linux/io.h> /* For inb/outb/... */
37
38/* Module and version information */
39#define DRV_NAME "sch311x_wdt"
40#define PFX DRV_NAME ": "
41
42/* Runtime registers */
43#define RESGEN 0x1d
44#define GP60 0x47
45#define WDT_TIME_OUT 0x65
46#define WDT_VAL 0x66
47#define WDT_CFG 0x67
48#define WDT_CTRL 0x68
49
50/* internal variables */
51static unsigned long sch311x_wdt_is_open;
52static char sch311x_wdt_expect_close;
53static struct platform_device *sch311x_wdt_pdev;
54
55static int sch311x_ioports[] = { 0x2e, 0x4e, 0x162e, 0x164e, 0x00 };
56
57static struct { /* The devices private data */
58 /* the Runtime Register base address */
59 unsigned short runtime_reg;
60 /* The card's boot status */
61 int boot_status;
62 /* the lock for io operations */
63 spinlock_t io_lock;
64} sch311x_wdt_data;
65
66/* Module load parameters */
67static unsigned short force_id;
68module_param(force_id, ushort, 0);
69MODULE_PARM_DESC(force_id, "Override the detected device ID");
70
71static unsigned short therm_trip;
72module_param(therm_trip, ushort, 0);
73MODULE_PARM_DESC(therm_trip, "Should a ThermTrip trigger the reset generator");
74
75#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
76static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
77module_param(timeout, int, 0);
78MODULE_PARM_DESC(timeout,
79 "Watchdog timeout in seconds. 1<= timeout <=15300, default="
80 __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
81
82static int nowayout = WATCHDOG_NOWAYOUT;
83module_param(nowayout, int, 0);
84MODULE_PARM_DESC(nowayout,
85 "Watchdog cannot be stopped once started (default="
86 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
87
88/*
89 * Super-IO functions
90 */
91
92static inline void sch311x_sio_enter(int sio_config_port)
93{
94 outb(0x55, sio_config_port);
95}
96
97static inline void sch311x_sio_exit(int sio_config_port)
98{
99 outb(0xaa, sio_config_port);
100}
101
102static inline int sch311x_sio_inb(int sio_config_port, int reg)
103{
104 outb(reg, sio_config_port);
105 return inb(sio_config_port + 1);
106}
107
108static inline void sch311x_sio_outb(int sio_config_port, int reg, int val)
109{
110 outb(reg, sio_config_port);
111 outb(val, sio_config_port + 1);
112}
113
114/*
115 * Watchdog Operations
116 */
117
118static void sch311x_wdt_set_timeout(int t)
119{
120 unsigned char timeout_unit = 0x80;
121
122 /* When new timeout is bigger then 255 seconds, we will use minutes */
123 if (t > 255) {
124 timeout_unit = 0;
125 t /= 60;
126 }
127
128 /* -- Watchdog Timeout --
129 * Bit 0-6 (Reserved)
130 * Bit 7 WDT Time-out Value Units Select
131 * (0 = Minutes, 1 = Seconds)
132 */
133 outb(timeout_unit, sch311x_wdt_data.runtime_reg + WDT_TIME_OUT);
134
135 /* -- Watchdog Timer Time-out Value --
136 * Bit 0-7 Binary coded units (0=Disabled, 1..255)
137 */
138 outb(t, sch311x_wdt_data.runtime_reg + WDT_VAL);
139}
140
141static void sch311x_wdt_start(void)
142{
143 spin_lock(&sch311x_wdt_data.io_lock);
144
145 /* set watchdog's timeout */
146 sch311x_wdt_set_timeout(timeout);
147 /* enable the watchdog */
148 /* -- General Purpose I/O Bit 6.0 --
149 * Bit 0, In/Out: 0 = Output, 1 = Input
150 * Bit 1, Polarity: 0 = No Invert, 1 = Invert
151 * Bit 2-3, Function select: 00 = GPI/O, 01 = LED1, 11 = WDT,
152 * 10 = Either Edge Triggered Intr.4
153 * Bit 4-6 (Reserved)
154 * Bit 7, Output Type: 0 = Push Pull Bit, 1 = Open Drain
155 */
156 outb(0x0e, sch311x_wdt_data.runtime_reg + GP60);
157
158 spin_unlock(&sch311x_wdt_data.io_lock);
159
160}
161
162static void sch311x_wdt_stop(void)
163{
164 spin_lock(&sch311x_wdt_data.io_lock);
165
166 /* stop the watchdog */
167 outb(0x01, sch311x_wdt_data.runtime_reg + GP60);
168 /* disable timeout by setting it to 0 */
169 sch311x_wdt_set_timeout(0);
170
171 spin_unlock(&sch311x_wdt_data.io_lock);
172}
173
174static void sch311x_wdt_keepalive(void)
175{
176 spin_lock(&sch311x_wdt_data.io_lock);
177 sch311x_wdt_set_timeout(timeout);
178 spin_unlock(&sch311x_wdt_data.io_lock);
179}
180
181static int sch311x_wdt_set_heartbeat(int t)
182{
183 if (t < 1 || t > (255*60))
184 return -EINVAL;
185
186 /* When new timeout is bigger then 255 seconds,
187 * we will round up to minutes (with a max of 255) */
188 if (t > 255)
189 t = (((t - 1) / 60) + 1) * 60;
190
191 timeout = t;
192 return 0;
193}
194
195static void sch311x_wdt_get_status(int *status)
196{
197 unsigned char new_status;
198
199 *status = 0;
200
201 spin_lock(&sch311x_wdt_data.io_lock);
202
203 /* -- Watchdog timer control --
204 * Bit 0 Status Bit: 0 = Timer counting, 1 = Timeout occured
205 * Bit 1 Reserved
206 * Bit 2 Force Timeout: 1 = Forces WD timeout event (self-cleaning)
207 * Bit 3 P20 Force Timeout enabled:
208 * 0 = P20 activity does not generate the WD timeout event
209 * 1 = P20 Allows rising edge of P20, from the keyboard
210 * controller, to force the WD timeout event.
211 * Bit 4-7 Reserved
212 */
213 new_status = inb(sch311x_wdt_data.runtime_reg + WDT_CTRL);
214 if (new_status & 0x01)
215 *status |= WDIOF_CARDRESET;
216
217 spin_unlock(&sch311x_wdt_data.io_lock);
218}
219
220/*
221 * /dev/watchdog handling
222 */
223
224static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf,
225 size_t count, loff_t *ppos)
226{
227 if (count) {
228 if (!nowayout) {
229 size_t i;
230
231 sch311x_wdt_expect_close = 0;
232
233 for (i = 0; i != count; i++) {
234 char c;
235 if (get_user(c, buf + i))
236 return -EFAULT;
237 if (c == 'V')
238 sch311x_wdt_expect_close = 42;
239 }
240 }
241 sch311x_wdt_keepalive();
242 }
243 return count;
244}
245
246static long sch311x_wdt_ioctl(struct file *file, unsigned int cmd,
247 unsigned long arg)
248{
249 int status;
250 int new_timeout;
251 void __user *argp = (void __user *)arg;
252 int __user *p = argp;
253 static struct watchdog_info ident = {
254 .options = WDIOF_KEEPALIVEPING |
255 WDIOF_SETTIMEOUT |
256 WDIOF_MAGICCLOSE,
257 .firmware_version = 1,
258 .identity = DRV_NAME,
259 };
260
261 switch (cmd) {
262 case WDIOC_GETSUPPORT:
263 if (copy_to_user(argp, &ident, sizeof(ident)))
264 return -EFAULT;
265 break;
266
267 case WDIOC_GETSTATUS:
268 {
269 sch311x_wdt_get_status(&status);
270 return put_user(status, p);
271 }
272 case WDIOC_GETBOOTSTATUS:
273 return put_user(sch311x_wdt_data.boot_status, p);
274
275 case WDIOC_SETOPTIONS:
276 {
277 int options, retval = -EINVAL;
278
279 if (get_user(options, p))
280 return -EFAULT;
281 if (options & WDIOS_DISABLECARD) {
282 sch311x_wdt_stop();
283 retval = 0;
284 }
285 if (options & WDIOS_ENABLECARD) {
286 sch311x_wdt_start();
287 retval = 0;
288 }
289 return retval;
290 }
291 case WDIOC_KEEPALIVE:
292 sch311x_wdt_keepalive();
293 break;
294
295 case WDIOC_SETTIMEOUT:
296 if (get_user(new_timeout, p))
297 return -EFAULT;
298 if (sch311x_wdt_set_heartbeat(new_timeout))
299 return -EINVAL;
300 sch311x_wdt_keepalive();
301 /* Fall */
302 case WDIOC_GETTIMEOUT:
303 return put_user(timeout, p);
304 default:
305 return -ENOTTY;
306 }
307 return 0;
308}
309
310static int sch311x_wdt_open(struct inode *inode, struct file *file)
311{
312 if (test_and_set_bit(0, &sch311x_wdt_is_open))
313 return -EBUSY;
314 /*
315 * Activate
316 */
317 sch311x_wdt_start();
318 return nonseekable_open(inode, file);
319}
320
321static int sch311x_wdt_close(struct inode *inode, struct file *file)
322{
323 if (sch311x_wdt_expect_close == 42) {
324 sch311x_wdt_stop();
325 } else {
326 printk(KERN_CRIT PFX
327 "Unexpected close, not stopping watchdog!\n");
328 sch311x_wdt_keepalive();
329 }
330 clear_bit(0, &sch311x_wdt_is_open);
331 sch311x_wdt_expect_close = 0;
332 return 0;
333}
334
335/*
336 * Kernel Interfaces
337 */
338
339static const struct file_operations sch311x_wdt_fops = {
340 .owner = THIS_MODULE,
341 .llseek = no_llseek,
342 .write = sch311x_wdt_write,
343 .unlocked_ioctl = sch311x_wdt_ioctl,
344 .open = sch311x_wdt_open,
345 .release = sch311x_wdt_close,
346};
347
348static struct miscdevice sch311x_wdt_miscdev = {
349 .minor = WATCHDOG_MINOR,
350 .name = "watchdog",
351 .fops = &sch311x_wdt_fops,
352};
353
354/*
355 * Init & exit routines
356 */
357
358static int __devinit sch311x_wdt_probe(struct platform_device *pdev)
359{
360 struct device *dev = &pdev->dev;
361 unsigned char val;
362 int err;
363
364 spin_lock_init(&sch311x_wdt_data.io_lock);
365
366 if (!request_region(sch311x_wdt_data.runtime_reg + RESGEN, 1,
367 DRV_NAME)) {
368 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
369 sch311x_wdt_data.runtime_reg + RESGEN,
370 sch311x_wdt_data.runtime_reg + RESGEN);
371 err = -EBUSY;
372 goto exit;
373 }
374
375 if (!request_region(sch311x_wdt_data.runtime_reg + GP60, 1, DRV_NAME)) {
376 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
377 sch311x_wdt_data.runtime_reg + GP60,
378 sch311x_wdt_data.runtime_reg + GP60);
379 err = -EBUSY;
380 goto exit_release_region;
381 }
382
383 if (!request_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4,
384 DRV_NAME)) {
385 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
386 sch311x_wdt_data.runtime_reg + WDT_TIME_OUT,
387 sch311x_wdt_data.runtime_reg + WDT_CTRL);
388 err = -EBUSY;
389 goto exit_release_region2;
390 }
391
392 /* Make sure that the watchdog is not running */
393 sch311x_wdt_stop();
394
395 /* Disable keyboard and mouse interaction and interrupt */
396 /* -- Watchdog timer configuration --
397 * Bit 0 Reserved
398 * Bit 1 Keyboard enable: 0* = No Reset, 1 = Reset WDT upon KBD Intr.
399 * Bit 2 Mouse enable: 0* = No Reset, 1 = Reset WDT upon Mouse Intr
400 * Bit 3 Reserved
401 * Bit 4-7 WDT Interrupt Mapping: (0000* = Disabled,
402 * 0001=IRQ1, 0010=(Invalid), 0011=IRQ3 to 1111=IRQ15)
403 */
404 outb(0, sch311x_wdt_data.runtime_reg + WDT_CFG);
405
406 /* Check that the heartbeat value is within it's range ;
407 * if not reset to the default */
408 if (sch311x_wdt_set_heartbeat(timeout)) {
409 sch311x_wdt_set_heartbeat(WATCHDOG_TIMEOUT);
410 dev_info(dev, "timeout value must be 1<=x<=15300, using %d\n",
411 timeout);
412 }
413
414 /* Get status at boot */
415 sch311x_wdt_get_status(&sch311x_wdt_data.boot_status);
416
417 /* enable watchdog */
418 /* -- Reset Generator --
419 * Bit 0 Enable Watchdog Timer Generation: 0* = Enabled, 1 = Disabled
420 * Bit 1 Thermtrip Source Select: O* = No Source, 1 = Source
421 * Bit 2 WDT2_CTL: WDT input bit
422 * Bit 3-7 Reserved
423 */
424 outb(0, sch311x_wdt_data.runtime_reg + RESGEN);
425 val = therm_trip ? 0x06 : 0x04;
426 outb(val, sch311x_wdt_data.runtime_reg + RESGEN);
427
428 err = misc_register(&sch311x_wdt_miscdev);
429 if (err != 0) {
430 dev_err(dev, "cannot register miscdev on minor=%d (err=%d)\n",
431 WATCHDOG_MINOR, err);
432 goto exit_release_region3;
433 }
434
435 sch311x_wdt_miscdev.parent = dev;
436
437 dev_info(dev,
438 "SMSC SCH311x WDT initialized. timeout=%d sec (nowayout=%d)\n",
439 timeout, nowayout);
440
441 return 0;
442
443exit_release_region3:
444 release_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4);
445exit_release_region2:
446 release_region(sch311x_wdt_data.runtime_reg + GP60, 1);
447exit_release_region:
448 release_region(sch311x_wdt_data.runtime_reg + RESGEN, 1);
449 sch311x_wdt_data.runtime_reg = 0;
450exit:
451 return err;
452}
453
454static int __devexit sch311x_wdt_remove(struct platform_device *pdev)
455{
456 /* Stop the timer before we leave */
457 if (!nowayout)
458 sch311x_wdt_stop();
459
460 /* Deregister */
461 misc_deregister(&sch311x_wdt_miscdev);
462 release_region(sch311x_wdt_data.runtime_reg + WDT_TIME_OUT, 4);
463 release_region(sch311x_wdt_data.runtime_reg + GP60, 1);
464 release_region(sch311x_wdt_data.runtime_reg + RESGEN, 1);
465 sch311x_wdt_data.runtime_reg = 0;
466 return 0;
467}
468
469static void sch311x_wdt_shutdown(struct platform_device *dev)
470{
471 /* Turn the WDT off if we have a soft shutdown */
472 sch311x_wdt_stop();
473}
474
475#define sch311x_wdt_suspend NULL
476#define sch311x_wdt_resume NULL
477
478static struct platform_driver sch311x_wdt_driver = {
479 .probe = sch311x_wdt_probe,
480 .remove = __devexit_p(sch311x_wdt_remove),
481 .shutdown = sch311x_wdt_shutdown,
482 .suspend = sch311x_wdt_suspend,
483 .resume = sch311x_wdt_resume,
484 .driver = {
485 .owner = THIS_MODULE,
486 .name = DRV_NAME,
487 },
488};
489
490static int __init sch311x_detect(int sio_config_port, unsigned short *addr)
491{
492 int err = 0, reg;
493 unsigned short base_addr;
494 unsigned char dev_id;
495
496 sch311x_sio_enter(sio_config_port);
497
498 /* Check device ID. We currently know about:
499 * SCH3112 (0x7c), SCH3114 (0x7d), and SCH3116 (0x7f). */
500 reg = force_id ? force_id : sch311x_sio_inb(sio_config_port, 0x20);
501 if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) {
502 err = -ENODEV;
503 goto exit;
504 }
505 dev_id = reg == 0x7c ? 2 : reg == 0x7d ? 4 : 6;
506
507 /* Select logical device A (runtime registers) */
508 sch311x_sio_outb(sio_config_port, 0x07, 0x0a);
509
510 /* Check if Logical Device Register is currently active */
511 if (sch311x_sio_inb(sio_config_port, 0x30) && 0x01 == 0)
512 printk(KERN_INFO PFX "Seems that LDN 0x0a is not active...\n");
513
514 /* Get the base address of the runtime registers */
515 base_addr = (sch311x_sio_inb(sio_config_port, 0x60) << 8) |
516 sch311x_sio_inb(sio_config_port, 0x61);
517 if (!base_addr) {
518 printk(KERN_ERR PFX "Base address not set.\n");
519 err = -ENODEV;
520 goto exit;
521 }
522 *addr = base_addr;
523
524 printk(KERN_INFO PFX "Found an SMSC SCH311%d chip at 0x%04x\n",
525 dev_id, base_addr);
526
527exit:
528 sch311x_sio_exit(sio_config_port);
529 return err;
530}
531
532static int __init sch311x_wdt_init(void)
533{
534 int err, i, found = 0;
535 unsigned short addr = 0;
536
537 for (i = 0; !found && sch311x_ioports[i]; i++)
538 if (sch311x_detect(sch311x_ioports[i], &addr) == 0)
539 found++;
540
541 if (!found)
542 return -ENODEV;
543
544 sch311x_wdt_data.runtime_reg = addr;
545
546 err = platform_driver_register(&sch311x_wdt_driver);
547 if (err)
548 return err;
549
550 sch311x_wdt_pdev = platform_device_register_simple(DRV_NAME, addr,
551 NULL, 0);
552
553 if (IS_ERR(sch311x_wdt_pdev)) {
554 err = PTR_ERR(sch311x_wdt_pdev);
555 goto unreg_platform_driver;
556 }
557
558 return 0;
559
560unreg_platform_driver:
561 platform_driver_unregister(&sch311x_wdt_driver);
562 return err;
563}
564
565static void __exit sch311x_wdt_exit(void)
566{
567 platform_device_unregister(sch311x_wdt_pdev);
568 platform_driver_unregister(&sch311x_wdt_driver);
569}
570
571module_init(sch311x_wdt_init);
572module_exit(sch311x_wdt_exit);
573
574MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
575MODULE_DESCRIPTION("SMSC SCH311x WatchDog Timer Driver");
576MODULE_LICENSE("GPL");
577MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
578
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
new file mode 100644
index 000000000000..2bc0d4d4b415
--- /dev/null
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -0,0 +1,329 @@
1/*
2 * Watchdog driver for the wm8350
3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics <linux@wolfsonmicro.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation
9 */
10
11#include <linux/module.h>
12#include <linux/moduleparam.h>
13#include <linux/types.h>
14#include <linux/kernel.h>
15#include <linux/fs.h>
16#include <linux/miscdevice.h>
17#include <linux/platform_device.h>
18#include <linux/watchdog.h>
19#include <linux/uaccess.h>
20#include <linux/mfd/wm8350/core.h>
21
22static int nowayout = WATCHDOG_NOWAYOUT;
23module_param(nowayout, int, 0);
24MODULE_PARM_DESC(nowayout,
25 "Watchdog cannot be stopped once started (default="
26 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
27
28static unsigned long wm8350_wdt_users;
29static struct miscdevice wm8350_wdt_miscdev;
30static int wm8350_wdt_expect_close;
31static DEFINE_MUTEX(wdt_mutex);
32
33static struct {
34 int time; /* Seconds */
35 u16 val; /* To be set in WM8350_SYSTEM_CONTROL_2 */
36} wm8350_wdt_cfgs[] = {
37 { 1, 0x02 },
38 { 2, 0x04 },
39 { 4, 0x05 },
40};
41
42static struct wm8350 *get_wm8350(void)
43{
44 return dev_get_drvdata(wm8350_wdt_miscdev.parent);
45}
46
47static int wm8350_wdt_set_timeout(struct wm8350 *wm8350, u16 value)
48{
49 int ret;
50 u16 reg;
51
52 mutex_lock(&wdt_mutex);
53 wm8350_reg_unlock(wm8350);
54
55 reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2);
56 reg &= ~WM8350_WDOG_TO_MASK;
57 reg |= value;
58 ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg);
59
60 wm8350_reg_lock(wm8350);
61 mutex_unlock(&wdt_mutex);
62
63 return ret;
64}
65
66static int wm8350_wdt_start(struct wm8350 *wm8350)
67{
68 int ret;
69 u16 reg;
70
71 mutex_lock(&wdt_mutex);
72 wm8350_reg_unlock(wm8350);
73
74 reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2);
75 reg &= ~WM8350_WDOG_MODE_MASK;
76 reg |= 0x20;
77 ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg);
78
79 wm8350_reg_lock(wm8350);
80 mutex_unlock(&wdt_mutex);
81
82 return ret;
83}
84
85static int wm8350_wdt_stop(struct wm8350 *wm8350)
86{
87 int ret;
88 u16 reg;
89
90 mutex_lock(&wdt_mutex);
91 wm8350_reg_unlock(wm8350);
92
93 reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2);
94 reg &= ~WM8350_WDOG_MODE_MASK;
95 ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg);
96
97 wm8350_reg_lock(wm8350);
98 mutex_unlock(&wdt_mutex);
99
100 return ret;
101}
102
103static int wm8350_wdt_kick(struct wm8350 *wm8350)
104{
105 int ret;
106 u16 reg;
107
108 mutex_lock(&wdt_mutex);
109
110 reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2);
111 ret = wm8350_reg_write(wm8350, WM8350_SYSTEM_CONTROL_2, reg);
112
113 mutex_unlock(&wdt_mutex);
114
115 return ret;
116}
117
118static int wm8350_wdt_open(struct inode *inode, struct file *file)
119{
120 struct wm8350 *wm8350 = get_wm8350();
121 int ret;
122
123 if (!wm8350)
124 return -ENODEV;
125
126 if (test_and_set_bit(0, &wm8350_wdt_users))
127 return -EBUSY;
128
129 ret = wm8350_wdt_start(wm8350);
130 if (ret != 0)
131 return ret;
132
133 return nonseekable_open(inode, file);
134}
135
136static int wm8350_wdt_release(struct inode *inode, struct file *file)
137{
138 struct wm8350 *wm8350 = get_wm8350();
139
140 if (wm8350_wdt_expect_close)
141 wm8350_wdt_stop(wm8350);
142 else {
143 dev_warn(wm8350->dev, "Watchdog device closed uncleanly\n");
144 wm8350_wdt_kick(wm8350);
145 }
146
147 clear_bit(0, &wm8350_wdt_users);
148
149 return 0;
150}
151
152static ssize_t wm8350_wdt_write(struct file *file,
153 const char __user *data, size_t count,
154 loff_t *ppos)
155{
156 struct wm8350 *wm8350 = get_wm8350();
157 size_t i;
158
159 if (count) {
160 wm8350_wdt_kick(wm8350);
161
162 if (!nowayout) {
163 /* In case it was set long ago */
164 wm8350_wdt_expect_close = 0;
165
166 /* scan to see whether or not we got the magic
167 character */
168 for (i = 0; i != count; i++) {
169 char c;
170 if (get_user(c, data + i))
171 return -EFAULT;
172 if (c == 'V')
173 wm8350_wdt_expect_close = 42;
174 }
175 }
176 }
177 return count;
178}
179
180static struct watchdog_info ident = {
181 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
182 .identity = "WM8350 Watchdog",
183};
184
185static long wm8350_wdt_ioctl(struct file *file, unsigned int cmd,
186 unsigned long arg)
187{
188 struct wm8350 *wm8350 = get_wm8350();
189 int ret = -ENOTTY, time, i;
190 void __user *argp = (void __user *)arg;
191 int __user *p = argp;
192 u16 reg;
193
194 switch (cmd) {
195 case WDIOC_GETSUPPORT:
196 ret = copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
197 break;
198
199 case WDIOC_GETSTATUS:
200 case WDIOC_GETBOOTSTATUS:
201 ret = put_user(0, p);
202 break;
203
204 case WDIOC_SETOPTIONS:
205 {
206 int options;
207
208 if (get_user(options, p))
209 return -EFAULT;
210
211 ret = -EINVAL;
212
213 /* Setting both simultaneously means at least one must fail */
214 if (options == WDIOS_DISABLECARD)
215 ret = wm8350_wdt_start(wm8350);
216
217 if (options == WDIOS_ENABLECARD)
218 ret = wm8350_wdt_stop(wm8350);
219 break;
220 }
221
222 case WDIOC_KEEPALIVE:
223 ret = wm8350_wdt_kick(wm8350);
224 break;
225
226 case WDIOC_SETTIMEOUT:
227 ret = get_user(time, p);
228 if (ret)
229 break;
230
231 if (time == 0) {
232 if (nowayout)
233 ret = -EINVAL;
234 else
235 wm8350_wdt_stop(wm8350);
236 break;
237 }
238
239 for (i = 0; i < ARRAY_SIZE(wm8350_wdt_cfgs); i++)
240 if (wm8350_wdt_cfgs[i].time == time)
241 break;
242 if (i == ARRAY_SIZE(wm8350_wdt_cfgs))
243 ret = -EINVAL;
244 else
245 ret = wm8350_wdt_set_timeout(wm8350,
246 wm8350_wdt_cfgs[i].val);
247 break;
248
249 case WDIOC_GETTIMEOUT:
250 reg = wm8350_reg_read(wm8350, WM8350_SYSTEM_CONTROL_2);
251 reg &= WM8350_WDOG_TO_MASK;
252 for (i = 0; i < ARRAY_SIZE(wm8350_wdt_cfgs); i++)
253 if (wm8350_wdt_cfgs[i].val == reg)
254 break;
255 if (i == ARRAY_SIZE(wm8350_wdt_cfgs)) {
256 dev_warn(wm8350->dev,
257 "Unknown watchdog configuration: %x\n", reg);
258 ret = -EINVAL;
259 } else
260 ret = put_user(wm8350_wdt_cfgs[i].time, p);
261
262 }
263
264 return ret;
265}
266
267static const struct file_operations wm8350_wdt_fops = {
268 .owner = THIS_MODULE,
269 .llseek = no_llseek,
270 .write = wm8350_wdt_write,
271 .unlocked_ioctl = wm8350_wdt_ioctl,
272 .open = wm8350_wdt_open,
273 .release = wm8350_wdt_release,
274};
275
276static struct miscdevice wm8350_wdt_miscdev = {
277 .minor = WATCHDOG_MINOR,
278 .name = "watchdog",
279 .fops = &wm8350_wdt_fops,
280};
281
282static int wm8350_wdt_probe(struct platform_device *pdev)
283{
284 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
285
286 if (!wm8350) {
287 dev_err(wm8350->dev, "No driver data supplied\n");
288 return -ENODEV;
289 }
290
291 /* Default to 4s timeout */
292 wm8350_wdt_set_timeout(wm8350, 0x05);
293
294 wm8350_wdt_miscdev.parent = &pdev->dev;
295
296 return misc_register(&wm8350_wdt_miscdev);
297}
298
299static int __exit wm8350_wdt_remove(struct platform_device *pdev)
300{
301 misc_deregister(&wm8350_wdt_miscdev);
302
303 return 0;
304}
305
306static struct platform_driver wm8350_wdt_driver = {
307 .probe = wm8350_wdt_probe,
308 .remove = wm8350_wdt_remove,
309 .driver = {
310 .name = "wm8350-wdt",
311 },
312};
313
314static int __init wm8350_wdt_init(void)
315{
316 return platform_driver_register(&wm8350_wdt_driver);
317}
318module_init(wm8350_wdt_init);
319
320static void __exit wm8350_wdt_exit(void)
321{
322 platform_driver_unregister(&wm8350_wdt_driver);
323}
324module_exit(wm8350_wdt_exit);
325
326MODULE_AUTHOR("Mark Brown");
327MODULE_DESCRIPTION("WM8350 Watchdog");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS("platform:wm8350-wdt");
diff --git a/firmware/Makefile b/firmware/Makefile
index 6968388818be..d872b7942a30 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -20,6 +20,15 @@ fw-external-y := $(subst ",,$(CONFIG_EXTRA_FIRMWARE))
20# accurate. In the latter case it doesn't matter -- it'll use $(fw-shipped-all). 20# accurate. In the latter case it doesn't matter -- it'll use $(fw-shipped-all).
21# But be aware that the config file might not be included at all. 21# But be aware that the config file might not be included at all.
22 22
23ifdef CONFIG_ACENIC_OMIT_TIGON_I
24acenic-objs := acenic/tg2.bin
25fw-shipped- += acenic/tg1.bin
26else
27acenic-objs := acenic/tg1.bin acenic/tg2.bin
28endif
29fw-shipped-$(CONFIG_ACENIC) += $(acenic-objs)
30fw-shipped-$(CONFIG_ADAPTEC_STARFIRE) += adaptec/starfire_rx.bin \
31 adaptec/starfire_tx.bin
23fw-shipped-$(CONFIG_ATARI_DSP56K) += dsp56k/bootstrap.bin 32fw-shipped-$(CONFIG_ATARI_DSP56K) += dsp56k/bootstrap.bin
24fw-shipped-$(CONFIG_ATM_AMBASSADOR) += atmsar11.fw 33fw-shipped-$(CONFIG_ATM_AMBASSADOR) += atmsar11.fw
25fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin 34fw-shipped-$(CONFIG_CASSINI) += sun/cassini.bin
@@ -38,6 +47,8 @@ fw-shipped-$(CONFIG_SND_SB16_CSP) += sb16/mulaw_main.csp sb16/alaw_main.csp \
38 sb16/ima_adpcm_capture.csp 47 sb16/ima_adpcm_capture.csp
39fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \ 48fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \
40 yamaha/ds1e_ctrl.fw 49 yamaha/ds1e_ctrl.fw
50fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \
51 tigon/tg3_tso5.bin
41fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin 52fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
42fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \ 53fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
43 emi26/bitstream.fw 54 emi26/bitstream.fw
diff --git a/firmware/WHENCE b/firmware/WHENCE
index 8f06639ba3e7..1bb2cf4b1735 100644
--- a/firmware/WHENCE
+++ b/firmware/WHENCE
@@ -360,3 +360,52 @@ License: GPLv2 or OpenIB.org BSD license, no source visible
360 360
361-------------------------------------------------------------------------- 361--------------------------------------------------------------------------
362 362
363Driver: acenic -- Alteon AceNIC Gigabit Ethernet card
364
365File: acenic/tg1.bin
366File: acenic/tg2.bin
367
368Licence: Unknown
369
370Found in hex form in kernel source, but source allegedly available at
371http://alteon.shareable.org/
372
373--------------------------------------------------------------------------
374
375Driver: tigon3 -- Broadcom Tigon3 based gigabit Ethernet cards
376
377File: tigon/tg3.bin
378File: tigon/tg3_tso.bin
379File: tigon/tg3_tso5.bin
380
381Licence:
382 * Firmware is:
383 * Derived from proprietary unpublished source code,
384 * Copyright (C) 2000-2003 Broadcom Corporation.
385 *
386 * Permission is hereby granted for the distribution of this firmware
387 * data in hexadecimal or equivalent format, provided this copyright
388 * notice is accompanying it.
389
390Found in hex form in kernel source.
391
392--------------------------------------------------------------------------
393
394Driver: ADAPTEC_STARFIRE - Adaptec Starfire/DuraLAN support
395
396File: adaptec/starfire_rx.bin
397File: adaptec/starfire_tx.bin
398
399Licence: Allegedly GPLv2, but no source visible.
400
401Found in hex form in kernel source, with the following notice:
402
403 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE IT IS LICENSED "AS IS" AND
404 THERE IS NO WARRANTY FOR THE PROGRAM, INCLUDING BUT NOT LIMITED TO THE
405 IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE
406 (TO THE EXTENT PERMITTED BY APPLICABLE LAW). USE OF THE PROGRAM IS AT YOUR
407 OWN RISK. IN NO EVENT WILL ADAPTEC OR ITS LICENSORS BE LIABLE TO YOU FOR
408 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
409 ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM.
410
411--------------------------------------------------------------------------
diff --git a/firmware/acenic/tg1.bin.ihex b/firmware/acenic/tg1.bin.ihex
new file mode 100644
index 000000000000..bef2659d3645
--- /dev/null
+++ b/firmware/acenic/tg1.bin.ihex
@@ -0,0 +1,4573 @@
1:100000000C040B0000004000000040001000000342
2:10001000000000000000000D0000000D3C1D00016C
3:100020008FBD5C5403A0F0213C100000261040005E
4:100030000C00100C000000000000000D27BDFFD8D0
5:100040003C1CC0003C1B0013377BD8000000D021B3
6:100050003C17001336F7541802E02021340583E8DA
7:10006000AFBF00240C002488AFB000200C0023E8B0
8:10007000000000003C040001248451A42405000178
9:1000800002E03021000038213C10000126107E5093
10:10009000AFB000100C002403AFBB00143C02000FF3
11:1000A0003442FFFF020210240362102B10400009AB
12:1000B000240500033C040001248451B002003021D7
13:1000C000036038213C020010AFA200100C00240392
14:1000D000AFA00014000020213405C0003C01000145
15:1000E00000370821A02083B03C010001003708211F
16:1000F000A02083B23C01000100370821A02083B377
17:100100003C01000100370821AC2083B4A2E004D8F0
18:10011000000418C02484000100771021AC40727CD8
19:1001200000771021AC40728002E31021A445727C5C
20:100130002C8200201440FFF7000418C0000020218A
21:100140003405C000000418C0248400010077102189
22:10015000AC40737C00771021AC40738002E3102127
23:10016000A445737C2C8200805440FFF7000418C023
24:10017000AF800054AF80011C8F82004434420040A5
25:10018000AF8200448F82004434420020AF8200449A
26:100190008F420218304200021040000900000000A7
27:1001A0008F4202203C030002346300040043102508
28:1001B000AEE204C48F42021C0800107434420004F2
29:1001C0008F4202203C0300023463000600431025E6
30:1001D000AEE204C48F42021C34420006AEE204CCFC
31:1001E0008F420218304200101040000A0000000048
32:1001F0008F42021C34420004AEE204C88F42022047
33:100200003C03000A34630004004310250800108AF0
34:10021000AEE204C08F4202203C03000A34630006B1
35:1002200000431025AEE204C08F42021C3442000697
36:10023000AEE204C88F4202183042020010400003B0
37:100240002402000108001091A2E27248A2E0724864
38:1002500024020001AF8200A0AF8200B08F8300545F
39:100260008F82005408001099246300648F82005428
40:10027000006210232C4200651440FFFC00000000C7
41:10028000AF8000448F4202088F43020CAEE20010A0
42:10029000AEE300148EE400108EE5001426E2003078
43:1002A000AEE2002824020490AEE20018AF84009071
44:1002B000AF8500948EE20028AF8200B496E2001A67
45:1002C000AF82009C8F8200B08EE304CC00431025E7
46:1002D000AF8200B08F8200B0304200041440FFFDB6
47:1002E000000000008EE204508EE30454AEE304FCF0
48:1002F0008EE204FC2442E0002C4220011440000D58
49:1003000026E400308EE204508EE304543C040001E5
50:10031000248451BC3C050001AFA00010AFA0001424
51:100320008EE704FC34A5F0000C00240300603021AB
52:1003300026E400300C0024882405040027440080B3
53:100340000C0024882405008026E4777C0C00248897
54:10035000240504008F42025C26E40094AEE20060B3
55:100360008F4202602745020024060008AEE20068C2
56:10037000240200060C00249AAEE200643C023B9A80
57:100380003442CA000000202124030002AEE30074BE
58:10039000AEE30070AEE2006C240203E8AEE20104BA
59:1003A00024020001AEE30100AEE2010C3C030001B7
60:1003B0000064182190635C2002E410212484000171
61:1003C000A043009C2C82000F1440FFF800000000A6
62:1003D0008F82004002E418212484000100021702E9
63:1003E00024420030A062009C02E41021A040009C46
64:1003F00096E2046A30420003144000090000000045
65:1004000096E2047A30420003504001313C03080078
66:1004100096E2046A304200031040002A3C020700C2
67:1004200096E2047A30420003104000263C020700A6
68:1004300096E3047A96E2046A146200223C02070002
69:100440008EE204C024030001A2E34E2034420E00D9
70:10045000AEE204C08F420218304201001040000595
71:10046000000000003C0200012442E1680800111D68
72:10047000000211003C0200012442D35C0002110082
73:10048000000211823C030800004310253C010001DA
74:10049000AC2212383C0200012442F6800002110016
75:1004A000000211823C030800004310253C010001BA
76:1004B000AC2212788EE2000034424000080012386C
77:1004C000AEE2000034423000AFA200188EE206080F
78:1004D0008F43022824420001304900FF512300E2EB
79:1004E000AFA000108EE20608000210C000571021D5
80:1004F0008FA300188FA4001CAC43060CAC4406105C
81:100500008F8701202762380024E800200102102B89
82:1005100050400001276830008F820128110200043A
83:10052000000000008F820124150200070000102146
84:100530008EE201A40000302124420001AEE201A4B9
85:10054000080011A08EE201A48EE40608000420C079
86:10055000008018218EE404308EE5043400A32821A5
87:1005600000A3302B0082202100862021ACE4000073
88:10057000ACE500048EE3060824020008A4E2000EA5
89:100580002402000DACE20018ACE9001C000318C006
90:100590002463060C02E31021ACE200088EE204C4DE
91:1005A000ACE20010AF88012092E24E2014400037E8
92:1005B000240600018EE24E30000210C02442503862
93:1005C00002E220218C830000240200071462001F35
94:1005D000000000008EE34E308EE24E341062001BAD
95:1005E000240300408C82000424420001AC820004F9
96:1005F0008EE24E348EE54E30244200011043000757
97:10060000000000008EE24E342442000110A20005DA
98:10061000000000000800118A0000000014A000057E
99:10062000000000008F82012824420020AF820128B0
100:100630008F8201288C8200042C420011504000134C
101:10064000AC800000080011A0000000008EE24E30D7
102:100650002403004024420001504300030000102105
103:100660008EE24E3024420001AEE24E308EE24E3039
104:10067000000210C02442503802E220212402000768
105:10068000AC82000024020001AC82000454C0000CC3
106:10069000AEE906083C040001248451C8AFA0001054
107:1006A000AFA000148EE606088F4702283C0500091B
108:1006B0000C00240334A5F000080012230000000001
109:1006C0008F830120276238002466002000C2102B8F
110:1006D00050400001276630008F82012810C20004BC
111:1006E000000000008F82012414C2000700000000F7
112:1006F0008EE201A40000302124420001AEE201A4F8
113:10070000080012078EE201A48EE20608AC62001C0B
114:100710008EE404A08EE504A42462001CAC620008F0
115:1007200024020008A462000E24020011AC6200182A
116:10073000AC640000AC6500048EE204C4AC6200103E
117:10074000AF86012092E24E201440003724060001BB
118:100750008EE24E30000210C02442503802E22021C6
119:100760008C830000240200121462001F00000000AD
120:100770008EE34E308EE24E341062001B24030040A4
121:100780008C82000424420001AC8200048EE24E34CC
122:100790008EE54E30244200011043000700000000A7
123:1007A0008EE24E342442000110A200050000000039
124:1007B000080011F10000000014A000050000000076
125:1007C0008F82012824420020AF8201288F820128D5
126:1007D0008C8200042C42001150400013AC800000B9
127:1007E00008001207000000008EE24E302403004093
128:1007F0002442000150430003000010218EE24E30DD
129:1008000024420001AEE24E308EE24E30000210C0B3
130:100810002442503802E2202124020012AC8200005F
131:1008200024020001AC82000414C0001B0000000080
132:100830003C040001248451D0AFA00010AFA00014EC
133:100840008EE606088F4702283C0500090C002403A9
134:1008500034A5F0018EE201B024420001AEE201B005
135:10086000080012238EE201B03C040001248451DC14
136:10087000AFA000148EE606088F4702283C05000949
137:100880000C00240334A5F0058EE201AC24420001E3
138:10089000AEE201AC8EE201AC8EE201603C040001EC
139:1008A000248451E83405F00124420001AEE20160E5
140:1008B0008EE201600000302100003821AFA000105E
141:1008C0000C002403AFA00014080012380000000040
142:1008D0003C0200012442F5A800021100000211822E
143:1008E000004310253C010001AC22127896E2045A24
144:1008F00030420003104000253C050FFF8EE204C883
145:1009000034A5FFFF34420A00AEE204C88EE304C8F7
146:100910003C040001248451F424020001A2E204EC0E
147:10092000A2E204ED3C020002006218253C02000134
148:100930002442A3900045102400021082AEE304C8B4
149:100940003C030800004310253C010001AC221220AA
150:100950003C0200012442ADD4004510240002108264
151:10096000004310253C010001AC22128096E6045A97
152:100970000000382124050011AFA000100C00240352
153:10098000AFA0001408001268000000003C02000143
154:100990002442A9D400021100000211823C03080085
155:1009A000004310253C010001AC22128096E2046A4B
156:1009B00030420010144000090000000096E2047A62
157:1009C00030420010104001120000000096E2046A5C
158:1009D00030420010104000053C02070096E2047A05
159:1009E00030420010144001023C0207003442300043
160:1009F000AFA200188EE206088F43022824420001AD
161:100A0000304900FF512300E2AFA000108EE206083B
162:100A1000000210C0005710218FA300188FA4001CE3
163:100A2000AC43060CAC4406108F87012027623800C7
164:100A300024E800200102102B5040000127683000FC
165:100A40008F82012811020004000000008F8201241F
166:100A500015020007000010218EE201A400003021E1
167:100A600024420001AEE201A4080012EA8EE201A4D1
168:100A70008EE40608000420C0008018218EE40430B3
169:100A80008EE5043400A3282100A3302B008220210E
170:100A900000862021ACE40000ACE500048EE30608EB
171:100AA00024020008A4E2000E2402000DACE20018AB
172:100AB000ACE9001C000318C02463060C02E31021FB
173:100AC000ACE200088EE204C4ACE20010AF88012062
174:100AD00092E24E2014400037240600018EE24E3090
175:100AE000000210C02442503802E220218C83000012
176:100AF000240200071462001F000000008EE34E3045
177:100B00008EE24E341062001B240300408C820004ED
178:100B100024420001AC8200048EE24E348EE54E3059
179:100B20002442000110430007000000008EE24E3412
180:100B30002442000110A2000500000000080012D4A9
181:100B40000000000014A00005000000008F820128B2
182:100B500024420020AF8201288F8201288C82000469
183:100B60002C42001150400013AC800000080012EA33
184:100B7000000000008EE24E302403004024420001B9
185:100B800050430003000010218EE24E302442000149
186:100B9000AEE24E308EE24E30000210C02442503899
187:100BA00002E2202124020007AC820000240200019E
188:100BB000AC82000454C0000CAEE906083C040001FD
189:100BC000248451C8AFA00010AFA000148EE6060820
190:100BD0008F4702283C0500090C00240334A5F000CF
191:100BE0000800136D000000008F8301202762380089
192:100BF0002466002000C2102B504000012766300000
193:100C00008F82012810C20004000000008F8201249E
194:100C100014C20007000000008EE201A40000302191
195:100C200024420001AEE201A4080013518EE201A4A7
196:100C30008EE20608AC62001C8EE404A08EE504A4DB
197:100C40002462001CAC62000824020008A462000EAA
198:100C500024020011AC620018AC640000AC65000412
199:100C60008EE204C4AC620010AF86012092E24E20F6
200:100C700014400037240600018EE24E30000210C0FE
201:100C80002442503802E220218C830000240200120A
202:100C90001462001F000000008EE34E308EE24E34DE
203:100CA0001062001B240300408C82000424420001D7
204:100CB000AC8200048EE24E348EE54E3024420001B8
205:100CC00010430007000000008EE24E342442000171
206:100CD00010A20005000000000800133B0000000007
207:100CE00014A00005000000008F820128244200208B
208:100CF000AF8201288F8201288C8200042C420011CF
209:100D000050400013AC8000000800135100000000A8
210:100D10008EE24E3024030040244200015043000381
211:100D2000000010218EE24E3024420001AEE24E302F
212:100D30008EE24E30000210C02442503802E22021E0
213:100D400024020012AC82000024020001AC820004E4
214:100D500014C0001B000000003C040001248451D09A
215:100D6000AFA00010AFA000148EE606088F4702283F
216:100D70003C0500090C00240334A5F0018EE201B00B
217:100D800024420001AEE201B00800136D8EE201B012
218:100D90003C040001248451DCAFA000148EE6060858
219:100DA0008F4702283C0500090C00240334A5F005F8
220:100DB0008EE201AC24420001AEE201AC8EE201AC55
221:100DC0008EE201603C040001248451E83405F00205
222:100DD00024420001AEE201608EE201600000302199
223:100DE00000003821AFA000100C002403AFA00014B5
224:100DF00096E6047A96E7046A3C04000124845200D3
225:100E000024050012AFA000100C002403AFA00014B2
226:100E10000C004500000000000C002318000000003A
227:100E20003C06000134C63800AEE00608AF40022898
228:100E3000AF40022C96E304588EE400003C0512D823
229:100E400034A5C35827623800AEE2725827623800D2
230:100E5000AEE2726027623800AEE27264036610216F
231:100E6000AEE272702402FFFFAEE004D4AEE004E014
232:100E7000AEE004E4AEE004F0A2E004F4AEE00E0C58
233:100E8000AEE00E18AEE00E10AEE00E14AEE00E1C9A
234:100E9000AEE0724CAEE05244AEE05240AEE0523CA6
235:100EA000AEE07250AEE07254AEE0725CAEE07268DA
236:100EB000AEE004D02463FFFF00852025AEE304F8F4
237:100EC000AEE40000AF800060AF8200643C0201002D
238:100ED000AFA200188EE206088F43022824420001C8
239:100EE000304900FF512300E2AFA000108EE2060857
240:100EF000000210C0005710218FA300188FA4001CFF
241:100F0000AC43060CAC4406108F87012027623800E2
242:100F100024E800200102102B504000012768300017
243:100F20008F82012811020004000000008F8201243A
244:100F300015020007000010218EE201A400003021FC
245:100F400024420001AEE201A4080014228EE201A4B2
246:100F50008EE40608000420C0008018218EE40430CE
247:100F60008EE5043400A3282100A3302B0082202129
248:100F700000862021ACE40000ACE500048EE3060806
249:100F800024020008A4E2000E2402000DACE20018C6
250:100F9000ACE9001C000318C02463060C02E3102116
251:100FA000ACE200088EE204C4ACE20010AF8801207D
252:100FB00092E24E2014400037240600018EE24E30AB
253:100FC000000210C02442503802E220218C8300002D
254:100FD000240200071462001F000000008EE34E3060
255:100FE0008EE24E341062001B240300408C82000409
256:100FF00024420001AC8200048EE24E348EE54E3075
257:101000002442000110430007000000008EE24E342D
258:101010002442000110A20005000000000800140C8A
259:101020000000000014A00005000000008F820128CD
260:1010300024420020AF8201288F8201288C82000484
261:101040002C42001150400013AC8000000800142214
262:10105000000000008EE24E302403004024420001D4
263:1010600050430003000010218EE24E302442000164
264:10107000AEE24E308EE24E30000210C024425038B4
265:1010800002E2202124020007AC82000024020001B9
266:10109000AC82000454C0000CAEE906083C04000118
267:1010A000248451C8AFA00010AFA000148EE606083B
268:1010B0008F4702283C0500090C00240334A5F000EA
269:1010C000080014A5000000008F830120276238006B
270:1010D0002466002000C2102B50400001276630001B
271:1010E0008F82012810C20004000000008F820124BA
272:1010F00014C20007000000008EE201A400003021AD
273:1011000024420001AEE201A4080014898EE201A489
274:101110008EE20608AC62001C8EE404A08EE504A4F6
275:101120002462001CAC62000824020008A462000EC5
276:1011300024020011AC620018AC640000AC6500042D
277:101140008EE204C4AC620010AF86012092E24E2011
278:1011500014400037240600018EE24E30000210C019
279:101160002442503802E220218C8300002402001225
280:101170001462001F000000008EE34E308EE24E34F9
281:101180001062001B240300408C82000424420001F2
282:10119000AC8200048EE24E348EE54E3024420001D3
283:1011A00010430007000000008EE24E34244200018C
284:1011B00010A20005000000000800147300000000E9
285:1011C00014A00005000000008F82012824420020A6
286:1011D000AF8201288F8201288C8200042C420011EA
287:1011E00050400013AC80000008001489000000008B
288:1011F0008EE24E302403004024420001504300039D
289:10120000000010218EE24E3024420001AEE24E304A
290:101210008EE24E30000210C02442503802E22021FB
291:1012200024020012AC82000024020001AC820004FF
292:1012300014C0001B000000003C040001248451D0B5
293:10124000AFA00010AFA000148EE606088F4702285A
294:101250003C0500090C00240334A5F0018EE201B026
295:1012600024420001AEE201B0080014A58EE201B0F4
296:101270003C040001248451DCAFA000148EE6060873
297:101280008F4702283C0500090C00240334A5F00513
298:101290008EE201AC24420001AEE201AC8EE201AC70
299:1012A0008EE2015424420001AEE201540C0014DC31
300:1012B0008EE201548F8200A0304200041440FFFDF2
301:1012C000000000008F8200403042000114400008FE
302:1012D000000000008F43010424020001106200049A
303:1012E000000000008F420264104000060000000071
304:1012F0008EE2017C24420001AEE2017C080014C5AC
305:101300008EE2017C8F82004434420004AF820044AC
306:101310008EE2017824420001AEE201788EE201788B
307:101320008F8200D88F8300D400431023AEE2726C0A
308:101330008EE2726C1C4000033C030001004310214C
309:10134000AEE2726C0C004064000000000C004440EF
310:10135000AF8002288FBF00248FB0002003E0000878
311:1013600027BD002803E000080000000003E000089B
312:101370000000000000000000000000002402002C1B
313:10138000AF820050AEE072748F420238AEE27278E3
314:101390008F82005424420067AF820058AEE07B8801
315:1013A000AEE07B8CAEE07B843C010001003708217D
316:1013B000AC2083BC3C0100010037082103E0000899
317:1013C000A02083B927BDFFD8AFBF0024AFB0002055
318:1013D0008F8200543C0300018C635CD82442006778
319:1013E0001060000DAF8200583C0200010057102130
320:1013F000904283B8104000053C0302003C0100010C
321:101400000037082108001503A02083B88EE20000F1
322:1014100000431025AEE200008F4202183042010066
323:10142000104000C6000000008F8200B0304200046F
324:10143000104000C2000000003C03000100771821AA
325:101440008C6383D08F820104146200B4000000001A
326:101450003C030001007718218C6383D48F8200B491
327:10146000146200AE000000008F8200B03C030080D8
328:10147000004310241040000D000000008F82011C6A
329:1014800034420002AF82011C8F8200B02403FFFBB4
330:1014900000431024AF8200B08F82011C2403FFFDA3
331:1014A00000431024080015CCAF82011C3C0300014E
332:1014B000007718218C6383D08F820104146200822C
333:1014C000000000003C030001007718218C6383D4E6
334:1014D0008F8200B41462007C000000003C07000111
335:1014E00000F738218CE783D08F8200B03C040001E4
336:1014F00024845270AFA00014AFA200108F8600B0F9
337:101500003C0500050C00240334A509008F82011C52
338:1015100034420002AF82011C8F8301048F8200B02D
339:1015200034420001AF8200B0AF8301048F830120F9
340:10153000276238002466002000C2102B50400001B2
341:10154000276630008F82012810C2000400000000CE
342:101550008F82012414C20006000000008EE201A464
343:1015600024420001AEE201A4080015A08EE201A40D
344:101570008F4402088F45020C26E20030AC6200085E
345:1015800024020400A462000E2402000FAC620018C2
346:10159000AC60001CAC640000AC6500048EE204C4C6
347:1015A000AC620010AF86012092E24E20144000375A
348:1015B000000000008EE24E30000210C0244250387D
349:1015C00002E220218C830000240200071462001F25
350:1015D000000000008EE34E308EE24E341062001B9D
351:1015E000240300408C82000424420001AC820004E9
352:1015F0008EE24E348EE54E30244200011043000747
353:10160000000000008EE24E342442000110A20005CA
354:10161000000000000800158A0000000014A000056A
355:10162000000000008F82012824420020AF820128A0
356:101630008F8201288C8200042C420011504000133C
357:10164000AC800000080015A0000000008EE24E30C3
358:1016500024030040244200015043000300001021F5
359:101660008EE24E3024420001AEE24E308EE24E3029
360:10167000000210C02442503802E220212402000758
361:10168000AC82000024020001AC8200048F82011CA5
362:101690002403FFFD00431024AF82011C8EE201E40D
363:1016A0003C07000100F738218CE783D02442000179
364:1016B000AEE201E48EE201E43C0400012484527CA9
365:1016C000080015BDAFA000108F8201043C0100018D
366:1016D00000370821AC2283D08F8200B43C07000180
367:1016E00000F738218CE783D03C0400012484528425
368:1016F0003C01000100370821AC2283D4AFA00010C8
369:10170000AFA000148F8600B03C0500050C00240338
370:1017100034A50900080015CC000000008F820104E8
371:101720003C01000100370821AC2283D08F8200B435
372:101730003C01000100370821AC2283D48EE2727490
373:1017400092E304F42442006714600006AEE272746F
374:101750008EE272748F4302340043102B1440007BDE
375:10176000000000008EE304E48EE204F8146200043A
376:101770000000000092E204F450400074A2E004F47F
377:101780008F830120276238002466002000C2102BBE
378:1017900050400001276630008F82012810C20004EB
379:1017A000000000008F82012414C200070000000026
380:1017B0008EE201A40000802124420001AEE201A4D7
381:1017C000080016378EE201A48EE204E4AC62001C2D
382:1017D0008EE404B08EE504B42462001CAC62000800
383:1017E00024020008A462000E24020011AC6200185A
384:1017F000AC640000AC6500048EE204C4AC6200106E
385:10180000AF86012092E24E201440003724100001E0
386:101810008EE24E30000210C02442503802E22021F5
387:101820008C830000240200121462001F00000000DC
388:101830008EE34E308EE24E341062001B24030040D3
389:101840008C82000424420001AC8200048EE24E34FB
390:101850008EE54E30244200011043000700000000D6
391:101860008EE24E342442000110A200050000000068
392:10187000080016210000000014A000050000000070
393:101880008F82012824420020AF8201288F82012804
394:101890008C8200042C42001150400013AC800000E8
395:1018A00008001637000000008EE24E30240300408E
396:1018B0002442000150430003000010218EE24E300C
397:1018C00024420001AEE24E308EE24E30000210C0E3
398:1018D0002442503802E2202124020012AC8200008F
399:1018E00024020001AC8200045600000B2410000109
400:1018F0008EE204E43C0400012484528CAFA0001466
401:10190000AFA200108EE606088F4702283C050009AA
402:101910000C00240334A5F006160000032402000185
403:1019200008001650A2E204F48EE201702442000185
404:10193000AEE201708EE201708EE204E4A2E004F4F3
405:10194000AEE004F0AEE07274AEE204F88EE20E1C7B
406:101950001040006D000000008F83012027623800D6
407:101960002466002000C2102B504000012766300082
408:101970008F82012810C20004000000008F82012421
409:1019800014C20007000000008EE201A400008021C4
410:1019900024420001AEE201A4080016AD8EE201A4CB
411:1019A0008EE2724CAC62001C8EE404A88EE504AC9E
412:1019B0002462001CAC62000824020008A462000E2D
413:1019C00024020011AC620018AC640000AC65000495
414:1019D0008EE204C4AC620010AF86012092E24E2079
415:1019E00014400037241000018EE24E30000210C077
416:1019F0002442503802E220218C830000240200128D
417:101A00001462001F000000008EE34E308EE24E3460
418:101A10001062001B240300408C8200042442000159
419:101A2000AC8200048EE24E348EE54E30244200013A
420:101A300010430007000000008EE24E3424420001F3
421:101A400010A200050000000008001697000000002A
422:101A500014A00005000000008F820128244200200D
423:101A6000AF8201288F8201288C8200042C42001151
424:101A700050400013AC800000080016AD00000000CC
425:101A80008EE24E3024030040244200015043000304
426:101A9000000010218EE24E3024420001AEE24E30B2
427:101AA0008EE24E30000210C02442503802E2202163
428:101AB00024020012AC82000024020001AC82000467
429:101AC0005600000B241000018EE2724C3C04000111
430:101AD00024845298AFA00014AFA200108EE6724C7E
431:101AE0008F4702803C0500090C00240334A5F00850
432:101AF00056000001AEE00E1C8EE20174244200018B
433:101B0000AEE201748EE201748EE24E2410400019A0
434:101B100000000000AEE04E248F8200403042000101
435:101B200014400008000000008F430104240200015B
436:101B300010620004000000008F42026410400006A2
437:101B4000000000008EE2017C24420001AEE2017C34
438:101B5000080016DA8EE2017C8F82004434420004D1
439:101B6000AF8200448EE2017824420001AEE20178A7
440:101B70008EE201788EE272782442FF99AEE27278AA
441:101B80008EE272781C4002AD000000008F420238E5
442:101B9000104002AA000000003C0200010057102182
443:101BA000904283E0144002A5000000008F420080B4
444:101BB000AEE2004C8F4200C0AEE200488F4200848B
445:101BC000AEE200388F420084AEE202448F420088C9
446:101BD000AEE202488F42008CAEE2024C8F4200908F
447:101BE000AEE202508F420094AEE202548F4200985F
448:101BF000AEE202588F42009CAEE2025C8F4200A02F
449:101C0000AEE202608F4200A4AEE202648F4200A8FE
450:101C1000AEE202688F4200ACAEE2026C8F4200B0CE
451:101C2000AEE202708F4200B4AEE202748F4200B89E
452:101C3000AEE202788F4200BC24040001AEE2027CD6
453:101C4000AEE0003C00041080005710218EE3003C01
454:101C50008C42024424840001006218212C82000F6F
455:101C6000AEE3003C1440FFF8000410808F4200CC2B
456:101C7000AEE200508F4200D0AEE200548F830120CC
457:101C8000276238002466002000C2102B504000015B
458:101C9000276630008F82012810C200040000000077
459:101CA0008F82012414C20007000000008EE201A40C
460:101CB0000000802124420001AEE201A40800177553
461:101CC0008EE201A48F4402088F45020C26E2003008
462:101CD000AC62000824020400A462000E2402000F7B
463:101CE000AC620018AC60001CAC640000AC65000481
464:101CF0008EE204C4AC620010AF86012092E24E2056
465:101D000014400037241000018EE24E30000210C053
466:101D10002442503802E220218C8300002402000774
467:101D20001462001F000000008EE34E308EE24E343D
468:101D30001062001B240300408C8200042442000136
469:101D4000AC8200048EE24E348EE54E302442000117
470:101D500010430007000000008EE24E3424420001D0
471:101D600010A20005000000000800175F000000003E
472:101D700014A00005000000008F82012824420020EA
473:101D8000AF8201288F8201288C8200042C4200112E
474:101D900050400013AC8000000800177500000000E0
475:101DA0008EE24E30240300402442000150430003E1
476:101DB000000010218EE24E3024420001AEE24E308F
477:101DC0008EE24E30000210C02442503802E2202140
478:101DD00024020007AC82000024020001AC8200044F
479:101DE000120002123C020400AFA200183C020001E3
480:101DF00000571021904283B01040010B00000000FA
481:101E00008EE206088F43022824420001304A00FF78
482:101E1000514300FDAFA000108EE20608000210C082
483:101E2000005710218FA300188FA4001CAC43060C90
484:101E3000AC4406108F8300548F8200542469003212
485:101E4000012210232C4200331040006A0000582168
486:101E500024180008240F000D240D0007240C004056
487:101E6000240E00018F8701202762380024E800201B
488:101E70000102102B50400001276830008F8201289A
489:101E800011020004000000008F82012415020007E7
490:101E9000000010218EE201A40000802124420001F4
491:101EA000AEE201A4080017F38EE201A48EE4060856
492:101EB000000420C0008018218EE404308EE5043434
493:101EC00000A3282100A3302B00822021008620219E
494:101ED000ACE40000ACE500048EE20608A4F8000EB5
495:101EE000ACEF0018ACEA001C000210C02442060C43
496:101EF00002E21021ACE200088EE204C4ACE2001061
497:101F0000AF88012092E24E201440003324100001DB
498:101F10008EE24E30000210C02442503802E22021EE
499:101F20008C820000144D001F000000008EE34E3034
500:101F30008EE24E341062001B000000008C82000410
501:101F400024420001AC8200048EE24E348EE34E3017
502:101F500024420001104C0007000000008EE24E34C5
503:101F6000244200011062000500000000080017E094
504:101F70000000000014600005000000008F820128AE
505:101F800024420020AF8201288F8201288C82000425
506:101F90002C42001150400010AC800000080017F3E4
507:101FA000000000008EE24E3024420001504C00033D
508:101FB000000010218EE24E3024420001AEE24E308D
509:101FC0008EE24E30000210C02442503802E220213E
510:101FD000AC8D0000AC8E000456000006240B0001FE
511:101FE0008F820054012210232C4200331440FF9DA5
512:101FF00000000000316300FF24020001146200773A
513:102000003C050009AEEA06088F8300548F82005415
514:1020100024690032012210232C4200331040006159
515:1020200000005821240D0008240C0011240800127F
516:1020300024070040240A00018F8301202762380012
517:102040002466002000C2102B50400001276630009B
518:102050008F82012810C20004000000008F8201243A
519:1020600014C20007000000008EE201A400008021DD
520:1020700024420001AEE201A40800185F8EE201A430
521:102080008EE20608AC62001C8EE404A08EE504A477
522:102090002462001CAC620008A46D000EAC6C001839
523:1020A000AC640000AC6500048EE204C4AC620010B5
524:1020B000AF86012092E24E2014400033241000012C
525:1020C0008EE24E30000210C02442503802E220213D
526:1020D0008C8200001448001F000000008EE34E3088
527:1020E0008EE24E341062001B000000008C8200045F
528:1020F00024420001AC8200048EE24E348EE34E3066
529:102100002442000110470007000000008EE24E3418
530:102110002442000110620005000000000800184C75
531:102120000000000014600005000000008F820128FC
532:1021300024420020AF8201288F8201288C82000473
533:102140002C42001150400010AC8000000800185FC5
534:10215000000000008EE24E30244200015047000390
535:10216000000010218EE24E3024420001AEE24E30DB
536:102170008EE24E30000210C02442503802E220218C
537:10218000AC880000AC8A000456000006240B000155
538:102190008F820054012210232C4200331440FFA6EA
539:1021A00000000000316300FF2402000114620003FC
540:1021B0003C0500090800197C241000013C040001C2
541:1021C000248452A4AFA00010AFA000148F86012079
542:1021D0008F8701240800187B34A5F0113C0400010E
543:1021E000248452B0AFA00010AFA000148F8601204D
544:1021F0008F87012434A5F0100C00240300008021F7
545:102200000800197C000000003C040001248452BC3A
546:10221000AFA000148EE606088F4702283C0500098F
547:102220000800197534A5F00F8EE206088F430228C6
548:1022300024420001304900FF512300E2AFA000100A
549:102240008EE20608000210C0005710218FA300186C
550:102250008FA4001CAC43060CAC4406108F870120F1
551:102260002762380024E800200102102B50400001B2
552:10227000276830008F82012811020004000000004E
553:102280008F82012415020007000010218EE201A4B4
554:102290000000802124420001AEE201A4080018F7EA
555:1022A0008EE201A48EE40608000420C000801821FC
556:1022B0008EE404308EE5043400A3282100A3302BE3
557:1022C0000082202100862021ACE40000ACE500045F
558:1022D0008EE3060824020008A4E2000E2402000D8A
559:1022E000ACE20018ACE9001C000318C02463060C23
560:1022F00002E31021ACE200088EE204C4ACE200105C
561:10230000AF88012092E24E201440003724100001D3
562:102310008EE24E30000210C02442503802E22021EA
563:102320008C830000240200071462001F00000000DC
564:102330008EE34E308EE24E341062001B24030040C8
565:102340008C82000424420001AC8200048EE24E34F0
566:102350008EE54E30244200011043000700000000CB
567:102360008EE24E342442000110A20005000000005D
568:10237000080018E10000000014A0000500000000A3
569:102380008F82012824420020AF8201288F820128F9
570:102390008C8200042C42001150400013AC800000DD
571:1023A000080018F7000000008EE24E3024030040C1
572:1023B0002442000150430003000010218EE24E3001
573:1023C00024420001AEE24E308EE24E30000210C0D8
574:1023D0002442503802E2202124020007AC8200008F
575:1023E00024020001AC8200045600000CAEE906088D
576:1023F0003C040001248452C8AFA00010AFA0001418
577:102400008EE606088F4702283C0500090C002403CD
578:1024100034A5F0000800197C000000008F83012023
579:10242000276238002466002000C2102B50400001B3
580:10243000276630008F82012810C2000400000000CF
581:102440008F82012414C20007000000008EE201A464
582:102450000000802124420001AEE201A40800195EC0
583:102460008EE201A48EE20608AC62001C8EE404A099
584:102470008EE504A42462001CAC620008240200085B
585:10248000A462000E24020011AC620018AC640000CB
586:10249000AC6500048EE204C4AC620010AF8601207B
587:1024A00092E24E2014400037241000018EE24E309C
588:1024B000000210C02442503802E220218C83000028
589:1024C000240200121462001F000000008EE34E3050
590:1024D0008EE24E341062001B240300408C82000404
591:1024E00024420001AC8200048EE24E348EE54E3070
592:1024F0002442000110430007000000008EE24E3429
593:102500002442000110A20005000000000800194844
594:102510000000000014A00005000000008F820128C8
595:1025200024420020AF8201288F8201288C8200047F
596:102530002C42001150400013AC8000000800195ECE
597:10254000000000008EE24E302403004024420001CF
598:1025500050430003000010218EE24E30244200015F
599:10256000AEE24E308EE24E30000210C024425038AF
600:1025700002E2202124020012AC82000024020001A9
601:10258000AC8200045600001D241000013C04000130
602:10259000248452D0AFA00010AFA000148EE606082D
603:1025A0008F4702283C0500090C00240334A5F001E4
604:1025B0008EE201B024420001AEE201B00800197CB5
605:1025C0008EE201B03C040001248452DCAFA0001470
606:1025D0008EE606088F4702283C05000934A5F00561
607:1025E0000C002403000000008EE201AC00008021FA
608:1025F00024420001AEE201AC8EE201AC1200000CFC
609:10260000240200013C01000100370821A02083B012
610:102610008F4202388EE3015824630001AEE3015873
611:102620008EE301580800198CAEE272782402000192
612:102630003C01000100370821A02283B03C020001C8
613:102640008C425CD810400187000000008EE27B8441
614:1026500024430001284200C9144001A4AEE37B8456
615:102660008EE204D43042000214400119AEE07B84B3
616:102670008EE204D43C0306003463100034420002AE
617:10268000AEE204D4AFA300188EE206088F430228FE
618:1026900024420001304A00FF514300FDAFA000106A
619:1026A0008EE20608000210C0005710218FA3001808
620:1026B0008FA4001CAC43060CAC4406108F8300545E
621:1026C0008F82005424690032012210232C420033EF
622:1026D0001040006A0000582124180008240F000D43
623:1026E000240D0007240C0040240E00018F870120D8
624:1026F0002762380024E800200102102B504000011E
625:10270000276830008F8201281102000400000000B9
626:102710008F82012415020007000010218EE201A41F
627:102720000000802124420001AEE201A408001A1535
628:102730008EE201A48EE40608000420C00080182167
629:102740008EE404308EE5043400A3282100A3302B4E
630:102750000082202100862021ACE40000ACE50004CA
631:102760008EE20608A4F8000EACEF0018ACEA001CDC
632:10277000000210C02442060C02E21021ACE2000864
633:102780008EE204C4ACE20010AF88012092E24E2039
634:1027900014400033241000018EE24E30000210C0BD
635:1027A0002442503802E220218C820000144D001F88
636:1027B000000000008EE34E308EE24E341062001BAB
637:1027C000000000008C82000424420001AC8200045E
638:1027D0008EE24E348EE34E3024420001104C00074E
639:1027E000000000008EE24E34244200011062000519
640:1027F0000000000008001A0200000000146000053C
641:10280000000000008F82012824420020AF820128AE
642:102810008F8201288C8200042C420011504000104D
643:10282000AC80000008001A15000000008EE24E3057
644:1028300024420001504C0003000010218EE24E3073
645:1028400024420001AEE24E308EE24E30000210C053
646:102850002442503802E22021AC8D0000AC8E0004EE
647:1028600056000006240B00018F8200540122102321
648:102870002C4200331440FF9D00000000316300FF34
649:102880002402000154620078AFA00010AEEA0608EE
650:102890008F8300548F820054246900320122102358
651:1028A0002C4200331040006100005821240D000824
652:1028B000240C00112408001224070040240A0001FF
653:1028C0008F830120276238002466002000C2102B6D
654:1028D00050400001276630008F82012810C200049A
655:1028E000000000008F82012414C2000700000000D5
656:1028F0008EE201A40000802124420001AEE201A486
657:1029000008001A818EE201A48EE20608AC62001C67
658:102910008EE404A08EE504A42462001CAC620008CE
659:10292000A46D000EAC6C0018AC640000AC65000433
660:102930008EE204C4AC620010AF86012092E24E2009
661:1029400014400033241000018EE24E30000210C00B
662:102950002442503802E220218C8200001448001FDB
663:10296000000000008EE34E308EE24E341062001BF9
664:10297000000000008C82000424420001AC820004AC
665:102980008EE24E348EE34E302442000110470007A1
666:10299000000000008EE24E34244200011062000567
667:1029A0000000000008001A6E00000000146000051E
668:1029B000000000008F82012824420020AF820128FD
669:1029C0008F8201288C8200042C420011504000109C
670:1029D000AC80000008001A81000000008EE24E303A
671:1029E0002442000150470003000010218EE24E30C7
672:1029F00024420001AEE24E308EE24E30000210C0A2
673:102A00002442503802E22021AC880000AC8A000445
674:102A100056000006240B00018F820054012210236F
675:102A20002C4200331440FFA600000000316300FF79
676:102A30002402000110620022000000003C0400019A
677:102A4000248452A4AFA00010AFA000148F860120F0
678:102A50008F8701243C0500090C00240334A5F011E4
679:102A600008001AAD000000003C040001248452B0AC
680:102A7000AFA000148F8601208F8701243C05000938
681:102A80000C00240334A5F01008001AAD000000006B
682:102A90003C040001248452BCAFA000148EE606085A
683:102AA0008F4702283C0500090C00240334A5F00FD1
684:102AB0008EE201AC24420001AEE201AC8EE201AC38
685:102AC0008EE2015C24420001AEE2015C8EE2015C18
686:102AD0008EE204D430420001104000550000000096
687:102AE0008F42021830420080104000290000000090
688:102AF0008F82004434420040AF8200448EE27B7CEF
689:102B0000004028218EE200C08EE300C424060000AD
690:102B10002407FFFF00002021004610241444000D6C
691:102B2000006718241465000B000000008EE27B8013
692:102B3000004028218EE200E08EE300E40000202126
693:102B40000046102414440003006718241065000B8D
694:102B5000000000008EE200C08EE300C48EE400E0BE
695:102B60008EE500E4AEE37B7CAEE57B808F820044A3
696:102B70003842002008001B38AF8200448F82004496
697:102B80002403FFDF0043102408001B38AF820044F9
698:102B90008F8200442403FFDF00431024AF820044EF
699:102BA0008EE27B7C004028218EE200C08EE300C4D0
700:102BB000240600002407FFFF000020210046102407
701:102BC0001444000D006718241465000B0000000079
702:102BD0008EE27B80004028218EE200E08EE300E45C
703:102BE000000020210046102414440003006718242C
704:102BF0001065000B000000008EE200C08EE300C4F0
705:102C00008EE400E08EE500E4AEE37B7CAEE57B8005
706:102C10008F8200443842004008001B38AF820044D5
707:102C20008F8200443442004008001B38AF820044C9
708:102C30008F82004434420040AF8200448EE27B8C9D
709:102C4000244300012842001514400028AEE37B8C89
710:102C50008F82004438420020AF82004408001B38B5
711:102C6000AEE07B8C8EE204D43042000110400011B3
712:102C7000000000008F42021830420080104000091E
713:102C8000000000008F82004434420020AF820044E4
714:102C90008F8200442403FFBF0043102408001B362A
715:102CA000AF8200448F8200443442006008001B362B
716:102CB000AF8200448F82004434420040AF8200441F
717:102CC0008EE27B88244300012842138914400005CA
718:102CD000AEE37B888F82004438420020AF820044FC
719:102CE000AEE07B880C004603000000008FBF00248C
720:102CF0008FB0002003E0000827BD002827BDFFB8E3
721:102D0000AFBF0044AFB60040AFB5003CAFB4003831
722:102D1000AFB30034AFB20030AFB1002CAFB0002879
723:102D20008F96006432C200041040000C240200049C
724:102D3000AF8200648F420114AEE204E08F82006033
725:102D400034420008AF8200608EE2016C2442000130
726:102D5000AEE2016C080022F48EE2016C32C2000186
727:102D60001040000424020001AF820064080022F435
728:102D70000000000032C200021440000C3C050003B9
729:102D80003C0400012484535434A5000102C03021C6
730:102D900000003821AFA000100C002403AFA00014E5
731:102DA0002402FFF8080022F4AF8200648F43022C53
732:102DB0008F42010C5062000CAFA000108F42022C19
733:102DC00000021080005A10218C420300AFA20020A4
734:102DD0008F42022C24070001244200013042003FB0
735:102DE00008001B80AF42022C3C0400012484536085
736:102DF000AFA000148F46022C8F47010C3C05000346
737:102E00000C00240334A5F01F0000382114E0000357
738:102E100000000000080022EDAF96006493A200209D
739:102E20002443FFFF2C62001110400658000310805D
740:102E30003C010001002208218C22541800400008A7
741:102E4000000000008FA2002030420FFFAEE20E0C07
742:102E50008F82006034420200AF8200608EE201186F
743:102E600024420001AEE20118080022E88EE20118B7
744:102E70008FA20020240300013C010001003708213B
745:102E8000A02383B130420FFFAEE252388F82006040
746:102E900034420100AF8200608EE20144244200010E
747:102EA000AEE20144080022E88EE201448FA2002035
748:102EB0000002120000022502240200011082000517
749:102EC00024020002108200092402FFFE08001BC930
750:102ED000AFA000108EE204D4AEE40070AEE4007443
751:102EE0003442000108001BBDAEE204D48EE304D4DA
752:102EF000AEE40070AEE4007400621824AEE304D4C3
753:102F00008F8400540004144200041C8200431021EA
754:102F100000041CC20043102300041D0200431021C2
755:102F200000041D420043102308001BD0AEE20078CD
756:102F30003C0400012484536CAFA000148FA6002031
757:102F40003C0500030C00240334A500048EE20110AC
758:102F500024420001AEE20110080022E88EE20110D6
759:102F6000274402120C0022FE240500063049001FEF
760:102F7000000920C002E410219442727C30424000DB
761:102F80001040000A0097102197430212A443727E5A
762:102F90008F43021400971021AC43728002E4182181
763:102FA0003402800008001C79A462727C9443727E13
764:102FB000974202121462000602E4102100971021C9
765:102FC0008C4372808F4202141062009F02E4102131
766:102FD0009442727C304280001040002A2406FFFF99
767:102FE00000002021000410C002E210219442737CF2
768:102FF000304240005440000500803021248400010C
769:103000002C8200801440FFF8000410C004C100109E
770:10301000000618C0000610C0005718218C63737C8E
771:1030200000571021AFA300108C4273803C040001B4
772:1030300024845378AFA200148F4702143C05000388
773:103040000C00240334A5001308001C903C02080067
774:103050009744021200771021A444737E8F44021417
775:103060000077102102E31821AC4473803402800001
776:10307000A462737C000910C002E2102108001C79D0
777:10308000A446727C02E410219445727C08001C2E38
778:10309000000510C09443737E97420212146200062A
779:1030A000000510C0009710218C4373808F420214DA
780:1030B00010620065000510C002E210219445737C87
781:1030C000000510C002E210219442737C304280005F
782:1030D0001040FFF000971021000520C0009710213C
783:1030E0009443737E97420212146200062406FFFF87
784:1030F000009710218C4373808F420214106200539A
785:103100003C02080000002021000410C002E210214F
786:103110009442737C304240005440000500803021CE
787:10312000248400012C8200801440FFF8000410C0A9
788:1031300004C10023000618C0000910C00057182160
789:103140008C63727C00571021AFA300108C427280F8
790:103150003C04000124845384AFA200148F4702145E
791:103160003C0500030C00240334A5F01708001C9054
792:103170003C0208008F43021000B71021AC43777C5B
793:103180008F43021400B71021AC4377803C0200014A
794:10319000005710218C4283B4244200013C010001FD
795:1031A00000370821AC2283B43C03000100771821CA
796:1031B0008C6383B402E5102108001C82A443777C51
797:1031C0009744021200771021A444737E8F440214A6
798:1031D0000077102102E31821AC4473803402800090
799:1031E000A462737C000510C002E21021A446737C27
800:1031F00000002021000428C002E510219442777CC1
801:103200001040FFDC248400012C8200805440FFFA2F
802:10321000000428C092E204D81040000624020001F5
803:103220008EE304DC012210040062182508001C8FC4
804:10323000AEE304DC8F830228240200010122100483
805:1032400000621825AF8302283C02080034421000B7
806:10325000AFA200188EE206088F4302282442000124
807:10326000304A00FF514300FDAFA000108EE2060877
808:10327000000210C0005710218FA300188FA4001C5B
809:10328000AC43060CAC4406108F8300548F8200546C
810:1032900024690032012210232C4200331040006ABE
811:1032A0000000582124100008240F000D240D0007F1
812:1032B000240C0040240E00018F8701202762380073
813:1032C00024E800200102102B504000012768300044
814:1032D0008F82012811020004000000008F82012467
815:1032E00015020007000010218EE201A40000382121
816:1032F00024420001AEE201A408001D088EE201A4F0
817:103300008EE40608000420C0008018218EE40430FA
818:103310008EE5043400A3282100A3302B0082202155
819:1033200000862021ACE40000ACE500048EE2060833
820:10333000A4F0000EACEF0018ACEA001C000210C0B4
821:103340002442060C02E21021ACE200088EE204C422
822:10335000ACE20010AF88012092E24E20144000330E
823:10336000240700018EE24E30000210C02442503883
824:1033700002E220218C820000144D001F000000009A
825:103380008EE34E308EE24E341062001B00000000CF
826:103390008C82000424420001AC8200048EE24E3490
827:1033A0008EE34E3024420001104C00070000000064
828:1033B0008EE24E342442000110620005000000003D
829:1033C00008001CF50000000014600005000000006B
830:1033D0008F82012824420020AF8201288F82012899
831:1033E0008C8200042C42001150400010AC80000080
832:1033F00008001D08000000008EE24E30244200014B
833:10340000504C0003000010218EE24E302442000197
834:10341000AEE24E308EE24E30000210C024425038F0
835:1034200002E22021AC8D0000AC8E000454E00006C6
836:10343000240B00018F820054012210232C42003300
837:103440001440FF9D00000000316300FF24020001D2
838:1034500054620078AFA00010AEEA06088F830054D3
839:103460008F82005424690032012210232C42003341
840:103470001040006100005821240E0008240D0011A6
841:10348000240A001224080040240C00018F8301202C
842:10349000276238002466002000C2102B5040000133
843:1034A000276630008F82012810C20004000000004F
844:1034B0008F82012414C20007000000008EE201A4E4
845:1034C0000000382124420001AEE201A408001D746E
846:1034D0008EE201A48EE20608AC62001C8EE404A019
847:1034E0008EE504A42462001CAC620008A46E000EE9
848:1034F000AC6D0018AC640000AC6500048EE204C43E
849:10350000AC620010AF86012092E24E2014400033DE
850:10351000240700018EE24E30000210C024425038D1
851:1035200002E220218C820000144A001F00000000EB
852:103530008EE34E308EE24E341062001B000000001D
853:103540008C82000424420001AC8200048EE24E34DE
854:103550008EE34E30244200011048000700000000B6
855:103560008EE24E342442000110620005000000008B
856:1035700008001D610000000014600005000000004C
857:103580008F82012824420020AF8201288F820128E7
858:103590008C8200042C42001150400010AC800000CE
859:1035A00008001D74000000008EE24E30244200012D
860:1035B00050480003000010218EE24E3024420001EA
861:1035C000AEE24E308EE24E30000210C0244250383F
862:1035D00002E22021AC8A0000AC8C000454E000061A
863:1035E000240B00018F820054012210232C4200334F
864:1035F0001440FFA600000000316300FF2402000118
865:1036000010620022000000003C040001248453905A
866:10361000AFA00010AFA000148F8601208F87012477
867:103620003C0500090C00240334A5F01108001DA07E
868:10363000000000003C0400012484539CAFA000144F
869:103640008F8601208F8701243C0500090C0024038C
870:1036500034A5F01008001DA0000000003C0400018B
871:10366000248453A8AFA000148EE606088F470228D2
872:103670003C0500090C00240334A5F00F8EE201ACD8
873:1036800024420001AEE201AC8EE201AC8EE20124E4
874:1036900024420001AEE2012408001F978EE20124BB
875:1036A000274402120C0022FE240500063049001FA8
876:1036B000000928C002E510219442727C304280004B
877:1036C0001040002F02E510219442727C30424000ED
878:1036D0001440001C00B710219443727E97420212DE
879:1036E0001462001800B710218C4372808F420214BC
880:1036F00054620016AFA2001092E204D810400007F6
881:10370000240200018EE304DC0122100400021027D1
882:103710000062182408001DC9AEE304DC8F83022870
883:10372000012210040002102700621824AF8302282F
884:10373000000910C002E218213402C00008001E4E29
885:10374000A462727C8F420214AFA20010000910C064
886:10375000005710218C42727C3C040001248453B435
887:103760003C050003AFA200148F47021034A5F01CE3
888:103770000C0024030120302108001E833C020800B5
889:1037800000B710219443727E97420212146200190E
890:10379000000918C000B710218C4372808F420214B8
891:1037A00014620014000918C002E510219447727CCD
892:1037B000000720C0009710219443737E00B71021AA
893:1037C000A443727E009710218C43738000B71021B0
894:1037D000AC43728002E410219443737C02E5102113
895:1037E000A443727C02E418213402C00008001E4E7B
896:1037F000A462737C02E310219447727C00003021A4
897:10380000000720C002E410219442737C0000402194
898:10381000304280001440002500E028210060502143
899:10382000340BC000009710219443737E974202121C
900:103830005462001500E02821009710218C4373800A
901:103840008F4202145462001000E02821110000068B
902:1038500002E410219443737C000510C002E21021A1
903:1038600008001E1AA443737C9443737C02EA10215F
904:10387000A443727C000710C002E21021A44B737CA9
905:1038800008001E2824060001000510C002E21021D5
906:103890009447737C000720C002E410219442737C9B
907:1038A000304280001040FFDF2508000130C200FFD9
908:1038B0001440002500002021000720C0009710219F
909:1038C0009443737E974202121462000F000910C0E5
910:1038D000009710218C4373808F4202141462000AF7
911:1038E000000910C002E418213402C00015000015C0
912:1038F000A462737C000910C002E218213402800027
913:1039000008001E4EA462727C005710218C42727C0B
914:103910003C040001248453C03C050003AFA2001006
915:10392000000710C0005710218C42737C34A5001E84
916:10393000012030210C002403AFA2001408001E83D4
917:103940003C02080000002021000428C000B710211C
918:103950009443777E974202125462002B2484000124
919:1039600000B710218C4377808F42021454620026E6
920:10397000248400013C020001005710218C4283B4D2
921:103980002442FFFF3C01000100370821AC2283B430
922:103990003C020001005710218C4283B4008090212A
923:1039A0000242102B1040000E24B1777C24B07784A3
924:1039B00002F0202102F128210C00249024060008A6
925:1039C000263100083C020001005710218C4283B4CC
926:1039D000265200010242102B1440FFF52610000869
927:1039E0003C040001009720218C8483B42405000846
928:1039F000000420C02484777C0C00248802E4202169
929:103A000008001E833C0208002C8200801440FFCF77
930:103A1000000428C03C02080034422000AFA2001875
931:103A20008EE206088F43022824420001304A00FF3C
932:103A3000514300FDAFA000108EE20608000210C046
933:103A4000005710218FA300188FA4001CAC43060C54
934:103A5000AC4406108F8300548F82005424690032D6
935:103A6000012210232C4200331040006A000058212C
936:103A700024100008240F000D240D0007240C004022
937:103A8000240E00018F8701202762380024E80020DF
938:103A90000102102B50400001276830008F8201285E
939:103AA00011020004000000008F82012415020007AB
940:103AB000000010218EE201A4000038212442000100
941:103AC000AEE201A408001EFB8EE201A48EE406080B
942:103AD000000420C0008018218EE404308EE50434F8
943:103AE00000A3282100A3302B008220210086202162
944:103AF000ACE40000ACE500048EE20608A4F0000E81
945:103B0000ACEF0018ACEA001C000210C02442060C06
946:103B100002E21021ACE200088EE204C4ACE2001024
947:103B2000AF88012092E24E201440003324070001A8
948:103B30008EE24E30000210C02442503802E22021B2
949:103B40008C820000144D001F000000008EE34E30F8
950:103B50008EE24E341062001B000000008C820004D4
951:103B600024420001AC8200048EE24E348EE34E30DB
952:103B700024420001104C0007000000008EE24E3489
953:103B800024420001106200050000000008001EE849
954:103B90000000000014600005000000008F82012872
955:103BA00024420020AF8201288F8201288C820004E9
956:103BB0002C42001150400010AC80000008001EFB99
957:103BC000000000008EE24E3024420001504C000301
958:103BD000000010218EE24E3024420001AEE24E3051
959:103BE0008EE24E30000210C02442503802E2202102
960:103BF000AC8D0000AC8E000454E00006240B0001E4
961:103C00008F820054012210232C4200331440FF9D68
962:103C100000000000316300FF2402000154620078BC
963:103C2000AFA00010AEEA06088F8300548F820054C4
964:103C300024690032012210232C420033104000611D
965:103C400000005821240E0008240D0011240A00123F
966:103C500024080040240C00018F83012027623800D3
967:103C60002466002000C2102B50400001276630005F
968:103C70008F82012810C20004000000008F820124FE
969:103C800014C20007000000008EE201A400003821E9
970:103C900024420001AEE201A408001F678EE201A4E5
971:103CA0008EE20608AC62001C8EE404A08EE504A43B
972:103CB0002462001CAC620008A46E000EAC6D0018FB
973:103CC000AC640000AC6500048EE204C4AC62001079
974:103CD000AF86012092E24E201440003324070001F9
975:103CE0008EE24E30000210C02442503802E2202101
976:103CF0008C820000144A001F000000008EE34E304A
977:103D00008EE24E341062001B000000008C82000422
978:103D100024420001AC8200048EE24E348EE34E3029
979:103D20002442000110480007000000008EE24E34DB
980:103D300024420001106200050000000008001F542A
981:103D40000000000014600005000000008F820128C0
982:103D500024420020AF8201288F8201288C82000437
983:103D60002C42001150400010AC80000008001F677A
984:103D7000000000008EE24E30244200015048000353
985:103D8000000010218EE24E3024420001AEE24E309F
986:103D90008EE24E30000210C02442503802E2202150
987:103DA000AC8A0000AC8C000454E00006240B000137
988:103DB0008F820054012210232C4200331440FFA6AE
989:103DC00000000000316300FF2402000110620022A5
990:103DD000000000003C04000124845390AFA00010B8
991:103DE000AFA000148F8601208F8701243C050009B5
992:103DF0000C00240334A5F01108001F9300000000FC
993:103E00003C0400012484539CAFA000148F86012041
994:103E10008F8701243C0500090C00240334A5F01011
995:103E200008001F93000000003C040001248453A8F4
996:103E3000AFA000148EE606088F4702283C05000953
997:103E40000C00240334A5F00F8EE201AC24420001E3
998:103E5000AEE201AC8EE201AC8EE201282442000108
999:103E6000AEE201288EE201288EE2016424420001C4
1000:103E7000AEE20164080022E88EE201648FA2002015
1001:103E80000002120000021D0224020001106200055F
1002:103E9000240200021062000D0000000008001FB79D
1003:103EA000AFA0001092E204D81440000624020001E2
1004:103EB0008F820228AEE204DC2402FFFFAF820228D8
1005:103EC0002402000108001FBEA2E204D892E204D836
1006:103ED0005040000CA2E004D88EE204DCAF8202283D
1007:103EE00008001FBEA2E004D83C040001248453C88B
1008:103EF000AFA000148FA600203C0500030C00240393
1009:103F000034A5F0098EE2013C24420001AEE2013CFE
1010:103F1000080022E88EE2013C8FA20020000212007D
1011:103F20000002250224020001108200052402000282
1012:103F30001082000F0000000008001FE3AFA0001077
1013:103F40008F8202203C0308FF3463FFFF00431024EC
1014:103F500034420008AF820220240200013C0100012B
1015:103F600000370821A02283B208001FEAAEE401084E
1016:103F70008F8202203C0308FF3463FFF700431024C4
1017:103F8000AF8202203C01000100370821A02083B24B
1018:103F900008001FEAAEE401083C040001248453D465
1019:103FA000AFA000148FA600203C0500030C002403E2
1020:103FB00034A5F00A8EE2012C24420001AEE2012C6D
1021:103FC000080022E88EE2012C8FA2002000021200DD
1022:103FD00000021D02240200011062000524020002FA
1023:103FE0001062000E0000000008002011AFA00010B9
1024:103FF0008F8202203C0308FF3463FFFF004310243C
1025:1040000034420008AF820220240200013C0100017A
1026:104010000037082108002018A02283B33C020001C9
1027:1040200000571021904283B23C0100010037082163
1028:104030001440000EA02083B38F8202203C0308FFAF
1029:104040003463FFF70043102408002018AF820220D9
1030:104050003C040001248453E0AFA000148FA600208C
1031:104060003C0500030C00240334A5F00B8EE2011480
1032:1040700024420001AEE20114080022E88EE201149D
1033:1040800027840208274502000C00249A2406000811
1034:1040900026E40094274502000C00249A2406000818
1035:1040A0008EE2013424420001AEE20134080022E82D
1036:1040B0008EE201348F460248000020210C00510896
1037:1040C000240500048EE2013024420001AEE20130FA
1038:1040D000080022E88EE201308EF301CC8EF401D08C
1039:1040E0008EF501D88EE2014026E400302442000122
1040:1040F000AEE201408EF001408EF100748EF200704D
1041:104100000C00248824050400AEF301CCAEF401D0E9
1042:10411000AEF501D8AEF00140AEF10074AEF2007021
1043:104120008F42025C26E40094AEE200608F4202609F
1044:104130002745020024060008AEE2006824020006BB
1045:104140000C00249AAEE200643C023B9A3442CA005E
1046:10415000AEE2006C240203E8240400022403000100
1047:10416000AEE20104AEE40100AEE3010C8F82022056
1048:10417000304200081040000400000000AEE30108D7
1049:104180000800206100002021AEE401080000202189
1050:104190003C0300010064182190635C3002E41021AC
1051:1041A00024840001A043009C2C82000F1440FFF8DF
1052:1041B000000000008F82004002E4182124840001E6
1053:1041C0000002170224420030A062009C02E4102189
1054:1041D000080022E8A040009C240200013C010001EC
1055:1041E00000370821A02283E0240B040024080014D7
1056:1041F000240A0040240900018F8301002762300057
1057:104200002466002000C2102B5040000127662800C1
1058:104210008F82010810C20004000000008F82010498
1059:1042200014C2000726E200308EE201A80000382107
1060:1042300024420001AEE201A8080020A88EE201A8F5
1061:104240008EE404B88EE504BCAC620008A46B000EDA
1062:10425000AC680018AC60001CAC640000AC650004E5
1063:104260008EE204CCAC620010AF86010092E204EC56
1064:104270001440000E240700018EE24E282442000163
1065:10428000504A0003000010218EE24E282442000113
1066:10429000AEE24E288EE24E28000210C024424E3874
1067:1042A00002E21021AC480000AC49000410E0FFD24B
1068:1042B00000000000080022E8000000003C020900A5
1069:1042C000AEE05238AEE0523CAEE05240AEE0524476
1070:1042D000AEE001D03C01000100370821A02083B1ED
1071:1042E000AFA200188EE206088F4302282442000184
1072:1042F000304A00FF514300FDAFA000108EE20608D7
1073:10430000000210C0005710218FA300188FA4001CBA
1074:10431000AC43060CAC4406108F8300548F820054CB
1075:1043200024690032012210232C4200331040006A1D
1076:104330000000582124100008240F000D240D000750
1077:10434000240C0040240E00018F87012027623800D2
1078:1043500024E800200102102B5040000127683000A3
1079:104360008F82012811020004000000008F820124C6
1080:1043700015020007000010218EE201A40000382180
1081:1043800024420001AEE201A40800212C8EE201A427
1082:104390008EE40608000420C0008018218EE404305A
1083:1043A0008EE5043400A3282100A3302B00822021B5
1084:1043B00000862021ACE40000ACE500048EE2060893
1085:1043C000A4F0000EACEF0018ACEA001C000210C014
1086:1043D0002442060C02E21021ACE200088EE204C482
1087:1043E000ACE20010AF88012092E24E20144000336E
1088:1043F000240700018EE24E30000210C024425038E3
1089:1044000002E220218C820000144D001F00000000F9
1090:104410008EE34E308EE24E341062001B000000002E
1091:104420008C82000424420001AC8200048EE24E34EF
1092:104430008EE34E3024420001104C000700000000C3
1093:104440008EE24E342442000110620005000000009C
1094:1044500008002119000000001460000500000000A1
1095:104460008F82012824420020AF8201288F820128F8
1096:104470008C8200042C42001150400010AC800000DF
1097:104480000800212C000000008EE24E302442000182
1098:10449000504C0003000010218EE24E3024420001F7
1099:1044A000AEE24E308EE24E30000210C02442503850
1100:1044B00002E22021AC8D0000AC8E000454E0000626
1101:1044C000240B00018F820054012210232C42003360
1102:1044D0001440FF9D00000000316300FF2402000132
1103:1044E00054620078AFA00010AEEA06088F83005433
1104:1044F0008F82005424690032012210232C420033A1
1105:104500001040006100005821240E0008240D001105
1106:10451000240A001224080040240C00018F8301208B
1107:10452000276238002466002000C2102B5040000192
1108:10453000276630008F82012810C2000400000000AE
1109:104540008F82012414C20007000000008EE201A443
1110:104550000000382124420001AEE201A408002198A5
1111:104560008EE201A48EE20608AC62001C8EE404A078
1112:104570008EE504A42462001CAC620008A46E000E48
1113:10458000AC6D0018AC640000AC6500048EE204C49D
1114:10459000AC620010AF86012092E24E20144000333E
1115:1045A000240700018EE24E30000210C02442503831
1116:1045B00002E220218C820000144A001F000000004B
1117:1045C0008EE34E308EE24E341062001B000000007D
1118:1045D0008C82000424420001AC8200048EE24E343E
1119:1045E0008EE34E3024420001104800070000000016
1120:1045F0008EE24E34244200011062000500000000EB
1121:104600000800218500000000146000050000000083
1122:104610008F82012824420020AF8201288F82012846
1123:104620008C8200042C42001150400010AC8000002D
1124:1046300008002198000000008EE24E302442000164
1125:1046400050480003000010218EE24E302442000149
1126:10465000AEE24E308EE24E30000210C0244250389E
1127:1046600002E22021AC8A0000AC8C000454E0000679
1128:10467000240B00018F820054012210232C420033AE
1129:104680001440FFA600000000316300FF2402000177
1130:1046900010620022000000003C04000124845390BA
1131:1046A000AFA00010AFA000148F8601208F870124D7
1132:1046B0003C0500090C00240334A5F011080021C4B6
1133:1046C000000000003C0400012484539CAFA00014AF
1134:1046D0008F8601208F8701243C0500090C002403EC
1135:1046E00034A5F010080021C4000000003C040001C3
1136:1046F000248453A8AFA000148EE606088F47022832
1137:104700003C0500090C00240334A5F00F8EE201AC37
1138:1047100024420001AEE201AC8EE201AC8EE2012047
1139:1047200024420001AEE201208EE201208EE2016807
1140:1047300024420001AEE20168080022E88EE201682E
1141:104740008F42025C26E40094AEE200608F42026079
1142:1047500027450200240600080C00249AAEE20068F7
1143:104760008F8202203042000814400002240200011F
1144:1047700024020002AEE201088EE2011C2442000184
1145:10478000AEE2011C080022E88EE2011C3C0400019C
1146:10479000248453ECAFA00010AFA000148FA600201B
1147:1047A0003C0500030C00240334A5F00F93A2002065
1148:1047B0003C0307003463100000431025AFA200182B
1149:1047C0008EE206088F43022824420001304900FF90
1150:1047D000512300E2AFA000108EE20608000210C0D4
1151:1047E000005710218FA300188FA4001CAC43060CA7
1152:1047F000AC4406108F8701202762380024E800208F
1153:104800000102102B50400001276830008F820128E0
1154:1048100011020004000000008F820124150200072D
1155:10482000000010218EE201A4000038212442000182
1156:10483000AEE201A40800225D8EE201A48EE4060827
1157:10484000000420C0008018218EE404308EE504347A
1158:1048500000A3282100A3302B0082202100862021E4
1159:10486000ACE40000ACE500048EE306082402000876
1160:10487000A4E2000E2402000DACE20018ACE9001C1A
1161:10488000000318C02463060C02E31021ACE2000808
1162:104890008EE204C4ACE20010AF88012092E24E2008
1163:1048A00014400037240700018EE24E30000210C091
1164:1048B0002442503802E220218C83000024020007A9
1165:1048C0001462001F000000008EE34E308EE24E3472
1166:1048D0001062001B240300408C820004244200016B
1167:1048E000AC8200048EE24E348EE54E30244200014C
1168:1048F00010430007000000008EE24E342442000105
1169:1049000010A200050000000008002247000000007F
1170:1049100014A00005000000008F820128244200201E
1171:10492000AF8201288F8201288C8200042C42001162
1172:1049300050400013AC8000000800225D0000000021
1173:104940008EE24E3024030040244200015043000315
1174:10495000000010218EE24E3024420001AEE24E30C3
1175:104960008EE24E30000210C02442503802E2202174
1176:1049700024020007AC82000024020001AC82000483
1177:1049800054E0000CAEE906083C040001248453F412
1178:10499000AFA00010AFA000148EE606088F470228D3
1179:1049A0003C0500090C00240334A5F000080022E0B7
1180:1049B000000000008F830120276238002466002059
1181:1049C00000C2102B50400001276630008F82012862
1182:1049D00010C20004000000008F82012414C20007EE
1183:1049E000000000008EE201A40000382124420001F2
1184:1049F000AEE201A4080022C48EE201A48EE2060801
1185:104A0000AC62001C8EE404A08EE504A42462001CA9
1186:104A1000AC62000824020008A462000E2402001107
1187:104A2000AC620018AC640000AC6500048EE204C403
1188:104A3000AC620010AF86012092E24E201440003795
1189:104A4000240700018EE24E30000210C0244250388C
1190:104A500002E220218C830000240200121462001F55
1191:104A6000000000008EE34E308EE24E341062001BD8
1192:104A7000240300408C82000424420001AC82000424
1193:104A80008EE24E348EE54E30244200011043000782
1194:104A9000000000008EE24E342442000110A2000506
1195:104AA00000000000080022AE0000000014A0000575
1196:104AB000000000008F82012824420020AF820128DC
1197:104AC0008F8201288C8200042C4200115040001378
1198:104AD000AC800000080022C4000000008EE24E30CE
1199:104AE0002403004024420001504300030000102131
1200:104AF0008EE24E3024420001AEE24E308EE24E3065
1201:104B0000000210C02442503802E220212402001288
1202:104B1000AC82000024020001AC82000414E0001BFF
1203:104B2000000000003C040001248453FCAFA00010EE
1204:104B3000AFA000148EE606088F4702283C05000946
1205:104B40000C00240334A5F0018EE201B024420001E0
1206:104B5000AEE201B0080022E08EE201B03C040001A8
1207:104B600024845408AFA000148EE606088F4702285C
1208:104B70003C0500090C00240334A5F0058EE201ACCD
1209:104B800024420001AEE201AC8EE201AC8EE20150A3
1210:104B900024420001AEE201508EE201508EE201603B
1211:104BA00024420001AEE201608EE201608F43022CDC
1212:104BB0008F42010C1462000924020002AF820064DB
1213:104BC0008F82006414400005000000008F43022C17
1214:104BD0008F42010C1462F875000000008FBF004482
1215:104BE0008FB600408FB5003C8FB400388FB30034CF
1216:104BF0008FB200308FB1002C8FB0002803E0000886
1217:104C000027BD004827BDFFF82408FFFF10A00014AF
1218:104C1000000048213C0AEDB8354A83209087000007
1219:104C200024840001000030210107102630420001D9
1220:104C30001040000200081842006A18260060402157
1221:104C400024C600012CC200081440FFF700073842B8
1222:104C5000252900010125102B1440FFF00000000061
1223:104C60000100102103E0000827BD000827BDFFE870
1224:104C700027642800AFBF00100C0024882405100012
1225:104C800024020021AF800100AF800104AF80010841
1226:104C9000AF800110AF800114AF800118AF800120F8
1227:104CA000AF800124AF800128AF800130AF80013494
1228:104CB000AF800138AEE04E28AEE04E2CAEE04E3074
1229:104CC000AEE04E34AF82011C8F42021830420040E9
1230:104CD00010400004000000008F82011C34420004D8
1231:104CE000AF82011C8FBF001003E0000827BD001831
1232:104CF00027BDFFE0AFBF00188F820104AFA20010F4
1233:104D00008F8201003C050002AFA200148F8600B024
1234:104D10008F87011C3C040001248454C00C00240330
1235:104D200034A5F0008F8300B03C027F00006218249D
1236:104D30003C020400106200290043102B14400008BC
1237:104D40003C0220003C020100106200243C020200F0
1238:104D50001062001100000000080023740000000031
1239:104D6000106200083C0240001462001C00000000B9
1240:104D70008EE2019024420001AEE20190080023740B
1241:104D80008EE201908EE2018C24420001AEE2018CA1
1242:104D9000080023748EE2018C8F82011C34420002D1
1243:104DA000AF82011C8F8301048F8200B03442000166
1244:104DB000AF8200B0AF8301048F82011C2403FFFD8A
1245:104DC00000431024AF82011C8EE201A024420001A6
1246:104DD000AEE201A0080023778EE201A08F8200B02E
1247:104DE00034420001AF8200B08FBF001803E000081A
1248:104DF00027BD002027BDFFE0AFBF001CAFB00018EB
1249:104E00008F820120AFA200108F8201243C05000197
1250:104E1000AFA200148F8600A08F87011C3C04000104
1251:104E2000248454CC0C00240334A5F0008F8300A00C
1252:104E30003C027F00006218243C0204001062005310
1253:104E4000000080210043102B144000083C04200087
1254:104E50003C0201001062004D3C0202001062003A68
1255:104E600000000000080023E00000000010640003C0
1256:104E70003C02400014620045000000008F8200A048
1257:104E80000044102410400006000000008EE201944F
1258:104E900024420001AEE20194080023A98EE20194AD
1259:104EA0008EE2019824420001AEE201988EE2019860
1260:104EB0008F82011C34420002AF82011C8F82011CD0
1261:104EC000304202001040001B000000008F8300A051
1262:104ED0008F8401248F8200AC14400007240200015B
1263:104EE0003C0200013442F0000062102450400001F6
1264:104EF00024100001240200011200000DAF8200A066
1265:104F00008F8201242442FFE0AF8201248F8201249A
1266:104F10008F820124276330000043102B10400005CE
1267:104F2000276237E0AF820124080023CA0000000096
1268:104F3000AF8401248F82011C2403FFFD0043102451
1269:104F4000080023E3AF82011C8F82011C344200025F
1270:104F5000AF82011C8F8301248F8200A034420001A4
1271:104F6000AF8200A0AF8301248F82011C2403FFFDC8
1272:104F700000431024AF82011C8EE2019C24420001F8
1273:104F8000AEE2019C080023E38EE2019C8F8200A028
1274:104F900034420001AF8200A08FBF001C8FB0001808
1275:104FA00003E0000827BD0020000000003C020001D3
1276:104FB0008C425C5827BDFFE8AFBF001414400012BC
1277:104FC000AFB000103C10000126105DD0020020217F
1278:104FD0000C0024882405200026021FE03C0100016B
1279:104FE000AC225D943C010001AC225D90AF420250C6
1280:104FF00024022000AF500254AF42025824020001A4
1281:105000003C010001AC225C588FBF00148FB000102F
1282:1050100003E0000827BD00183C0300018C635D9489
1283:105020008C8200008FA800108FA90014AC620000D1
1284:105030003C0200018C425D948C830004AC4300046C
1285:10504000AC4500088F8400542443FFE0AC460010B8
1286:10505000AC470014AC480018AC49001C3C010001EE
1287:10506000AC235D94AC44000C3C02000124425DD0B2
1288:105070000062182B10600005000000003C020001D7
1289:105080008C425D903C010001AC225D943C03000128
1290:105090008C635D943C0200018C425C40AC62000079
1291:1050A0003C0300018C635D943C0200018C425C4037
1292:1050B000AC62000403E00008AF4302503C0300016F
1293:1050C0008C635D943C0200018C425C4027BDFFD0A4
1294:1050D000AFB400208FB40040AFB00010008080213A
1295:1050E000AFB500248FB500448FA40048AFB10014C1
1296:1050F00000A08821AFBF0028AFB3001CAFB20018DA
1297:10510000AC6200003C0500018CA55D943C020001EE
1298:105110008C425C4000C0902100E098211080000685
1299:10512000ACA2000424A500080C002490240600185A
1300:105130000800244E0000000024A400080C0024886D
1301:10514000240500183C0200018C425D943C050001DE
1302:1051500024A55DD02442FFE03C010001AC225D9417
1303:105160000045102B10400005000000003C0200012B
1304:105170008C425D903C010001AC225D943C03000137
1305:105180008C635D948E020000AC6200003C03000161
1306:105190008C635D948E020004AC620004AC71000864
1307:1051A0008F8400542462FFE03C010001AC225D9436
1308:1051B0000045102BAC720010AC730014AC740018D6
1309:1051C000AC75001C10400005AC64000C3C020001F2
1310:1051D0008C425D903C010001AC225D943C030001D7
1311:1051E0008C635D943C0200018C425C40AC62000028
1312:1051F0003C0300018C635D943C0200018C425C40E6
1313:10520000AC620004AF4302508FBF00288FB500246A
1314:105210008FB400208FB3001C8FB200188FB1001420
1315:105220008FB0001003E0000827BD003010A000057B
1316:1052300000000000AC80000024A5FFFC14A0FFFDCE
1317:105240002484000403E000080000000010C00007F0
1318:10525000000000008C8200002484000424C6FFFCAF
1319:10526000ACA2000014C0FFFB24A5000403E000086A
1320:105270000000000010C00007000000008CA2000029
1321:1052800024A5000424C6FFFCAC82000014C0FFFB70
1322:105290002484000403E000080000000003E000088C
1323:1052A0000000000027BDFFD8AFBF00208EE304E45C
1324:1052B0008EE204E010620436000000008EE204E496
1325:1052C0008EE304FC00021100006260219587000853
1326:1052D0008D8A00008D8B0004958D000A8EE2725C31
1327:1052E0008EE3726C30E4FFFF004410210062182B43
1328:1052F0001060001531A200048F8200D88EE372582E
1329:1053000000431023AEE2726C8EE2726C1C4000030C
1330:105310003C03000100431021AEE2726C8EE2725C2D
1331:105320008EE3726C004410210062182B106000069E
1332:1053300031A200048EE201B824420001AEE201B8BD
1333:10534000080028E18EE201B81040024031A20200BC
1334:105350001040014D0000482196E2045A30420010EE
1335:1053600010400149000000008F84010027623000D6
1336:105370002485002000A2102B504000012765280042
1337:105380008F82010810A20004000000008F82010437
1338:1053900014A200062402000C8EE201A8244200019F
1339:1053A000AEE201A80800252C8EE201A8AC8A00001C
1340:1053B000AC8B00048EE3726424060005A482000E08
1341:1053C000AC860018AC8300088EE204E4AC82001CBA
1342:1053D0008EE204C8AC820010AF85010092E204ECBA
1343:1053E00014400036240900018EE24E28000210C04D
1344:1053F00024424E3802E220218C8200001446001F15
1345:10540000000000008EE34E288EE24E2C1062001B3E
1346:10541000240300408C82000424420001AC8200047A
1347:105420008EE24E2C8EE54E282442000110430007E8
1348:10543000000000008EE24E2C2442000110A2000564
1349:1054400000000000080025160000000014A0000560
1350:10545000000000008F82010824420020AF82010872
1351:105460008F8201088C8200042C42001150400013EE
1352:10547000AC8000000800252C000000008EE24E28C1
1353:105480002403004024420001504300030000102187
1354:105490008EE24E2824420001AEE24E288EE24E28D3
1355:1054A000000210C024424E3802E2202124020005EE
1356:1054B000AC82000024020001AC8200041520000A26
1357:1054C0003C040001AFAB00108EE272643C040001AA
1358:1054D000248457303C050004AFA200148EE604E497
1359:1054E000080028BE34A5F1148EE2726434843800BA
1360:1054F00003641821244200100043102B1440007351
1361:10550000000000008EE27264244800100364102141
1362:105510000102102B144000023C02FFFF0102402157
1363:105520008F8501002762300024A6002000C2102BC6
1364:1055300050400001276628008F82010810C2000435
1365:10554000000000008F82010414C200072563000CD4
1366:105550008EE201A80000482124420001AEE201A829
1367:10556000080025A08EE201A82C64000C0144102143
1368:10557000ACA20000ACA3000424E2FFF4A4A2000E3D
1369:1055800024020006ACA80008ACA200188EE204E4D5
1370:10559000ACA2001C8EE204C83C03000200431025AC
1371:1055A000ACA20010AF86010092E204EC1440003778
1372:1055B000240900018EE24E28000210C024424E3819
1373:1055C00002E220218C830000240200051462001FE7
1374:1055D000000000008EE34E288EE24E2C1062001B6D
1375:1055E000240300408C82000424420001AC820004A9
1376:1055F0008EE24E2C8EE54E28244200011043000717
1377:10560000000000008EE24E2C2442000110A2000592
1378:10561000000000000800258A0000000014A000051A
1379:10562000000000008F82010824420020AF820108A0
1380:105630008F8201088C8200042C420011504000131C
1381:10564000AC800000080025A0000000008EE24E287B
1382:1056500024030040244200015043000300001021B5
1383:105660008EE24E2824420001AEE24E288EE24E2801
1384:10567000000210C024424E3802E22021240200051C
1385:10568000AC82000024020001AC8200041520000A54
1386:105690002508FFFCAFAB00108EE272643C040001F1
1387:1056A000248457303C050004AFA200148EE604E4C5
1388:1056B000080028BE34A5F12534028100A5020000AF
1389:1056C0009582000E0800261DA50200028F850100AC
1390:1056D0002762300024A6002000C2102B5040000199
1391:1056E000276628008F82010810C200040000000015
1392:1056F0008F82010414C200072563000C8EE201A80A
1393:105700000000482124420001AEE201A80800260D55
1394:105710008EE201A82C64000C01441021ACA2000010
1395:10572000ACA300048EE3726424E2FFF4A4A2000E92
1396:1057300024020006ACA2001824630010ACA30008E9
1397:105740008EE204E4ACA2001C8EE204C83C0300021A
1398:1057500000431025ACA20010AF86010092E204ECD9
1399:1057600014400037240900018EE24E28000210C0C8
1400:1057700024424E3802E220218C83000024020005DE
1401:105780001462001F000000008EE34E288EE24E2CB3
1402:105790001062001B240300408C820004244200019C
1403:1057A000AC8200048EE24E2C8EE54E28244200018D
1404:1057B00010430007000000008EE24E2C244200013E
1405:1057C00010A2000500000000080025F700000000FE
1406:1057D00014A00005000000008F8201082442002070
1407:1057E000AF8201088F8201088C8200042C420011D4
1408:1057F00050400013AC8000000800260D000000009F
1409:105800008EE24E282403004024420001504300034E
1410:10581000000010218EE24E2824420001AEE24E2804
1411:105820008EE24E28000210C024424E3802E22021AF
1412:1058300024020005AC82000024020001AC820004B6
1413:105840001520000A34028100AFAB00108EE27264B2
1414:105850003C040001248457303C050004AFA200142E
1415:105860008EE604E4080028BE34A5F0158EE37264C9
1416:10587000A462000C8EE372649582000EA462000E96
1417:105880000800268124E700048F840100276230008D
1418:105890002485002000A2102B50400001276528001D
1419:1058A0008F82010810A20004000000008F82010412
1420:1058B00014A20007240200068EE201A8000048217D
1421:1058C00024420001AEE201A8080026778EE201A87A
1422:1058D000AC8A0000AC8B00048EE37264A487000ED7
1423:1058E000AC820018AC8300088EE204E4AC82001C99
1424:1058F0008EE204C83C03000200431025AC82001075
1425:10590000AF85010092E204EC144000372409000145
1426:105910008EE24E28000210C024424E3802E22021BE
1427:105920008C830000240200051462001F00000000A8
1428:105930008EE34E288EE24E2C1062001B24030040A2
1429:105940008C82000424420001AC8200048EE24E2CC2
1430:105950008EE54E282442000110430007000000009D
1431:105960008EE24E2C2442000110A20005000000002F
1432:10597000080026610000000014A0000500000000DF
1433:105980008F82010824420020AF8201088F82010823
1434:105990008C8200042C42001150400013AC800000A7
1435:1059A00008002677000000008EE24E282403004005
1436:1059B0002442000150430003000010218EE24E28D3
1437:1059C00024420001AEE24E288EE24E28000210C0B2
1438:1059D00024424E3802E2202124020005AC8200005D
1439:1059E00024020001AC820004152000093C050004DB
1440:1059F000AFAB00108EE272643C0400012484573087
1441:105A0000AFA200148EE604E4080028BE34A5F0041A
1442:105A10008EE2725C30E7FFFF00471021AEE2725C5D
1443:105A20008EE204E48EE304FC8EE47258000211005E
1444:105A300000431021AC44000C8EE27258AFA2001853
1445:105A40008EE3725CAFA3001C8EE2725C2C42003CC1
1446:105A500010400004246200012403FFFE00431024D0
1447:105A6000AFA2001C8EE272643C06000134C638000E
1448:105A70008EE3725C2405FFF80047102124420007E2
1449:105A80000045102424630007AEE272588EE2726C67
1450:105A90008EE472580065182400431023AEE2726C45
1451:105AA000036610210082202B148000043C03FFFFBA
1452:105AB0008EE2725800431021AEE272588EE27258A4
1453:105AC000AEE272648F8200F024470008276218005B
1454:105AD00000E2102B50400001276710008F8200F475
1455:105AE00014E20007000000008EE201B4000048212B
1456:105AF00024420001AEE201B4080026C48EE201B4E3
1457:105B00008F8200F0240900018FA300188FA4001CCD
1458:105B1000AC430000AC440004AF8700F01520001235
1459:105B2000000D11428F8200F0AFA200108F8200F4AE
1460:105B30003C0400012484573CAFA200148FA6001837
1461:105B40008FA7001C3C0500040C00240334A5F005BD
1462:105B50008EE2008824420001AEE200888EE20088D6
1463:105B6000080028D3AEE0725C304300032402000238
1464:105B70001062001628620003104000052402000194
1465:105B80001062000800000000080027030000000069
1466:105B90002402000310620017000000000800270321
1467:105BA000000000008EE200E88EE300EC24630001B8
1468:105BB0002C64000100441021AEE200E8AEE300ECEA
1469:105BC0008EE200E8080027038EE300EC8EE200F08E
1470:105BD0008EE300F4246300012C64000100441021D2
1471:105BE000AEE200F0AEE300F48EE200F0080027031E
1472:105BF0008EE300F48EE200F88EE300FC24630001E3
1473:105C00002C64000100441021AEE200F8AEE300FC79
1474:105C10008EE200F88EE300FC8EE2725C8EE400E01F
1475:105C20008EE500E4004018210000102100A3282187
1476:105C300000A3302B0082202100862021AEE400E06A
1477:105C4000AEE500E4080028D3AEE0725C30E2FFFF6E
1478:105C5000104001C131A202001040014D0000482156
1479:105C600096E2045A30420010104001490000000042
1480:105C70008F840100276230002485002000A2102BB1
1481:105C800050400001276528008F82010810A20004FF
1482:105C9000000000008F82010414A200062402000C00
1483:105CA0008EE201A824420001AEE201A80800276E9E
1484:105CB0008EE201A8AC8A0000AC8B00048EE3726413
1485:105CC00024060005A482000EAC860018AC830008F0
1486:105CD0008EE204E4AC82001C8EE204C8AC820010A8
1487:105CE000AF85010092E204EC144000362409000163
1488:105CF0008EE24E28000210C024424E3802E22021DB
1489:105D00008C8200001446001F000000008EE34E2825
1490:105D10008EE24E2C1062001B240300408C82000493
1491:105D200024420001AC8200048EE24E2C8EE54E2807
1492:105D30002442000110430007000000008EE24E2CB8
1493:105D40002442000110A200050000000008002758AE
1494:105D50000000000014A00005000000008F82010870
1495:105D600024420020AF8201088F8201088C82000447
1496:105D70002C42001150400013AC8000000800276E38
1497:105D8000000000008EE24E2824030040244200015F
1498:105D900050430003000010218EE24E2824420001EF
1499:105DA000AEE24E288EE24E28000210C024424E3849
1500:105DB00002E2202124020005AC820000240200013E
1501:105DC000AC8200041520000A3C040001AFAB0010B7
1502:105DD0008EE272643C040001248457303C050004C8
1503:105DE000AFA200148EE604E4080028BE34A5F01427
1504:105DF0008EE2726434843800036418212442001057
1505:105E00000043102B14400073000000008EE2726407
1506:105E100024480010036410210102102B14400002DA
1507:105E20003C02FFFF010240218F8501002762300004
1508:105E300024A6002000C2102B504000012766280035
1509:105E40008F82010810C20004000000008F8201044C
1510:105E500014C200072563000C8EE201A8000048214F
1511:105E600024420001AEE201A8080027E28EE201A868
1512:105E70002C64000C01441021ACA20000ACA300046F
1513:105E800024E2FFF4A4A2000E24020006ACA800083D
1514:105E9000ACA200188EE204E4ACA2001C8EE204C89E
1515:105EA0003C03000200431025ACA20010AF860100A5
1516:105EB00092E204EC14400037240900018EE24E28DF
1517:105EC000000210C024424E3802E220218C830000E0
1518:105ED000240200051462001F000000008EE34E281B
1519:105EE0008EE24E2C1062001B240300408C820004C2
1520:105EF00024420001AC8200048EE24E2C8EE54E2836
1521:105F00002442000110430007000000008EE24E2CE6
1522:105F10002442000110A2000500000000080027CC68
1523:105F20000000000014A00005000000008F8201089E
1524:105F300024420020AF8201088F8201088C82000475
1525:105F40002C42001150400013AC800000080027E2F2
1526:105F5000000000008EE24E2824030040244200018D
1527:105F600050430003000010218EE24E28244200011D
1528:105F7000AEE24E288EE24E28000210C024424E3877
1529:105F800002E2202124020005AC820000240200016C
1530:105F9000AC8200041520000A2508FFFCAFAB0010FE
1531:105FA0008EE272643C040001248457303C050004F6
1532:105FB000AFA200148EE604E4080028BE34A5F01554
1533:105FC00034028100A50200009582000E0800285FBF
1534:105FD000A50200028F8501002762300024A6002060
1535:105FE00000C2102B50400001276628008F82010854
1536:105FF00010C20004000000008F82010414C20007D8
1537:106000002563000C8EE201A8000048212442000113
1538:10601000AEE201A80800284F8EE201A82C64000C13
1539:1060200001441021ACA20000ACA300048EE3726412
1540:1060300024E2FFF4A4A2000E24020006ACA2001881
1541:1060400024630010ACA300088EE204E4ACA2001CA0
1542:106050008EE204C83C03000200431025ACA20010ED
1543:10606000AF86010092E204EC1440003724090001DD
1544:106070008EE24E28000210C024424E3802E2202157
1545:106080008C830000240200051462001F0000000041
1546:106090008EE34E288EE24E2C1062001B240300403B
1547:1060A0008C82000424420001AC8200048EE24E2C5B
1548:1060B0008EE54E2824420001104300070000000036
1549:1060C0008EE24E2C2442000110A2000500000000C8
1550:1060D000080028390000000014A00005000000009E
1551:1060E0008F82010824420020AF8201088F820108BC
1552:1060F0008C8200042C42001150400013AC80000040
1553:106100000800284F000000008EE24E2824030040C3
1554:106110002442000150430003000010218EE24E286B
1555:1061200024420001AEE24E288EE24E28000210C04A
1556:1061300024424E3802E2202124020005AC820000F5
1557:1061400024020001AC8200041520000A3402810000
1558:10615000AFAB00108EE272643C040001248457301F
1559:106160003C050004AFA200148EE604E4080028BE3B
1560:1061700034A5F0168EE37264A462000C8EE37264A0
1561:106180009582000EA462000E080028C224E70004D5
1562:106190008F83010027623000246400200082102BCE
1563:1061A00050400001276428008F82010810820004FB
1564:1061B000000000008F8201041482000724050005FE
1565:1061C0008EE201A80000482124420001AEE201A8AD
1566:1061D000080028B68EE201A8AC6A0000AC6B00048F
1567:1061E0008EE27264A467000EAC650018AC62000811
1568:1061F0008EE204E4AC62001C8EE204C8AC620010C3
1569:10620000AF84010092E204EC14400036240900013E
1570:106210008EE24E28000210C024424E3802E22021B5
1571:106220008C8200001445001F000000008EE34E2801
1572:106230008EE24E2C1062001B240300408C8200046E
1573:1062400024420001AC8200048EE24E2C8EE54E28E2
1574:106250002442000110430007000000008EE24E2C93
1575:106260002442000110A2000500000000080028A040
1576:106270000000000014A00005000000008F8201084B
1577:1062800024420020AF8201088F8201088C82000422
1578:106290002C42001150400013AC800000080028B6CA
1579:1062A000000000008EE24E2824030040244200013A
1580:1062B00050430003000010218EE24E2824420001CA
1581:1062C000AEE24E288EE24E28000210C024424E3824
1582:1062D00002E2202124020005AC8200002402000119
1583:1062E000AC8200041520000B3C0500043C040001B6
1584:1062F00024845748AFAB0010AFA000148EE604E42E
1585:1063000034A5F0170C00240330E7FFFF080028E154
1586:10631000000000008EE272643C05000130E4FFFFE3
1587:1063200000441021AEE272648EE2725C8EE372640D
1588:1063300034A5380000441021AEE2725C03651021E0
1589:106340000062182B146000043C03FFFF8EE27264AD
1590:1063500000431021AEE272648EE304E496E2045836
1591:10636000246300012442FFFF00621824AEE304E42A
1592:106370008EE304E48EE204E01462000500000000F5
1593:106380008F8200602403FFF700431024AF82006077
1594:106390008FBF002003E0000827BD002827BDFFE0D5
1595:1063A000AFBF00188EE304E88EE204E010620189BA
1596:1063B000000000008EE204E88EE304FC00021100FD
1597:1063C000006218219467000892E204ED8C680000D6
1598:1063D0008C69000410400023946A000A8EE204C80D
1599:1063E00034460400314202001040001F000000004B
1600:1063F00096E2045A304200101040001B3C0280001C
1601:106400003C01000100370821AC2283D88EE272647F
1602:106410009464000E3C05000134A5380024420004B9
1603:10642000AEE272648EE372640004240003651021FE
1604:106430003C01000100370821AC2483DC0062182BEA
1605:106440001460000524E700048EE272643C03FFFF41
1606:1064500000431021AEE272648EE2726408002917D4
1607:10646000AEE272588EE604C88EE2726C30E4FFFF32
1608:106470000044102A10400015000000008F8200D850
1609:106480008EE3725800431023AEE2726C8EE2726C9F
1610:106490001C4000070044102A8EE2726C3C0300018D
1611:1064A00000431021AEE2726C8EE2726C0044102A3E
1612:1064B00010400006000000008EE201B824420001F6
1613:1064C000AEE201B808002A728EE201B83C02000177
1614:1064D000005710218C4283D85440000124E7FFFC70
1615:1064E00031420004104000B930E2FFFF3C020001DD
1616:1064F000005710218C4283D81040002F00005021FB
1617:106500008F840100276230002485002000A2102B18
1618:1065100050400001276528008F82010810A2003238
1619:10652000000000008F82010410A2002F2402001539
1620:10653000AC880000AC8900048EE37264A487000E6E
1621:10654000AC820018AC8300088EE204E83C03000132
1622:10655000007718218C6383DCAC8600100043102583
1623:10656000AC82001CAF85010092E204EC144000668E
1624:10657000240A00018EE24E28240300402442000138
1625:1065800050430003000010218EE24E2824420001F7
1626:10659000AEE24E288EE24E28000210C024424E3851
1627:1065A00002E2182124020015AC620000240200015E
1628:1065B000080029BFAC6200048F840100276230000C
1629:1065C0002485002000A2102B5040000127652800E0
1630:1065D0008F82010810A20004000000008F820104D5
1631:1065E00014A20006240200068EE201A82442000143
1632:1065F000AEE201A8080029BF8EE201A8AC88000025
1633:10660000AC8900048EE37264A487000EAC8200188B
1634:10661000AC8300088EE204E8AC860010AC82001C5B
1635:10662000AF85010092E204EC14400037240A000117
1636:106630008EE24E28000210C024424E3802E2202191
1637:106640008C830000240200051462001F000000007B
1638:106650008EE34E288EE24E2C1062001B2403004075
1639:106660008C82000424420001AC8200048EE24E2C95
1640:106670008EE54E2824420001104300070000000070
1641:106680008EE24E2C2442000110A200050000000002
1642:10669000080029A90000000014A000050000000067
1643:1066A0008F82010824420020AF8201088F820108F6
1644:1066B0008C8200042C42001150400013AC8000007A
1645:1066C000080029BF000000008EE24E28240300408D
1646:1066D0002442000150430003000010218EE24E28A6
1647:1066E00024420001AEE24E288EE24E28000210C085
1648:1066F00024424E3802E2202124020005AC82000030
1649:1067000024020001AC8200041540000A24020001AA
1650:10671000AFA900108EE272643C040001248457305B
1651:106720003C050004AFA200148EE604E408002A4FE2
1652:1067300034A5F204A2E204ED8EE204E88EE304FC48
1653:106740008EE472583C06000134C638003C0100015A
1654:1067500000370821AC2083D83C0100010037082114
1655:10676000AC2083DC0002110000431021AC44000C7B
1656:106770008EE272642405FFF830E3FFFF004310212E
1657:10678000244200070045102424630007AEE272583B
1658:106790008EE2726C8EE47258006518240043102358
1659:1067A000AEE2726C036610210082202B148000047C
1660:1067B0003C03FFFF8EE2725800431021AEE2725894
1661:1067C0008EE2725808002A64AEE2726410400073D0
1662:1067D000000000008F830100276230002464002045
1663:1067E0000082102B14400002000050212764280072
1664:1067F0008F82010810820004000000008F820104D3
1665:1068000014820006240500058EE201A8244200013E
1666:10681000AEE201A808002A468EE201A8AC6800009A
1667:10682000AC6900048EE27264A467000EAC650018C7
1668:10683000AC6200088EE204E8AC660010AC62001C9A
1669:10684000AF84010092E204EC14400036240A0001F7
1670:106850008EE24E28000210C024424E3802E220216F
1671:106860008C8200001445001F000000008EE34E28BB
1672:106870008EE24E2C1062001B240300408C82000428
1673:1068800024420001AC8200048EE24E2C8EE54E289C
1674:106890002442000110430007000000008EE24E2C4D
1675:1068A0002442000110A200050000000008002A3068
1676:1068B0000000000014A00005000000008F82010805
1677:1068C00024420020AF8201088F8201088C820004DC
1678:1068D0002C42001150400013AC80000008002A46F2
1679:1068E000000000008EE24E282403004024420001F4
1680:1068F00050430003000010218EE24E282442000184
1681:10690000AEE24E288EE24E28000210C024424E38DD
1682:1069100002E2202124020005AC82000024020001D2
1683:10692000AC8200041540000C30E5FFFF3C04000180
1684:10693000248457483C050004AFA90010AFA0001400
1685:106940008EE604E434A5F2370C00240330E7FFFFA1
1686:1069500008002A72000000008EE2726400451021D7
1687:10696000AEE272648EE2726C8EE372643C040001EB
1688:1069700034843800A2E004ED00451023AEE2726CCE
1689:10698000036410210062182B146000043C03FFFF15
1690:106990008EE2726400431021AEE272648EE304E87A
1691:1069A00096E20458246300012442FFFF0062182489
1692:1069B000AEE304E88EE304E88EE204E0146200052E
1693:1069C000000000008F8200602403FFF700431024C2
1694:1069D000AF8200608FBF001803E0000827BD0020D1
1695:1069E00027BDFFE0AFBF001CAFB000188F820100D1
1696:1069F0008EE34E2C8F8201048F8501082402004013
1697:106A00002463000150620003000010218EE24E2C2E
1698:106A100024420001AEE24E2C8EE24E2C8EE34E2C30
1699:106A2000000210C024424E3802E220218EE24E289D
1700:106A30008C8700041462000700A030218F820108B7
1701:106A400024420020AF8201088F82010808002AA298
1702:106A5000AC8000008EE24E2C240300402442000152
1703:106A600050430003000010218EE24E2C244200010E
1704:106A7000000210C024424E3802E220218C82000421
1705:106A80008F8301080002114000621821AF830108C2
1706:106A9000AC8000008CC200182443FFFE2C6200135F
1707:106AA000104000C1000310803C01000100220821B9
1708:106AB0008C22577000400008000000008EE204F0B5
1709:106AC00000471021AEE204F08EE204F08F43023C56
1710:106AD0000043102B144000BE000000008EE304E4CD
1711:106AE0008EE204F8506200BAA2E004F48F83012021
1712:106AF000276238002466002000C2102B504000019D
1713:106B0000276630008F82012810C2000400000000B8
1714:106B10008F82012414C20007000000008EE201A44D
1715:106B20000000802124420001AEE201A408002B12E3
1716:106B30008EE201A48EE204E4AC62001C8EE404B098
1717:106B40008EE504B42462001CAC6200082402000834
1718:106B5000A462000E24020011AC620018AC640000B4
1719:106B6000AC6500048EE204C4AC620010AF86012064
1720:106B700092E24E2014400037241000018EE24E3085
1721:106B8000000210C02442503802E220218C83000011
1722:106B9000240200121462001F000000008EE34E3039
1723:106BA0008EE24E341062001B240300408C820004ED
1724:106BB00024420001AC8200048EE24E348EE54E3059
1725:106BC0002442000110430007000000008EE24E3412
1726:106BD0002442000110A200050000000008002AFC69
1727:106BE0000000000014A00005000000008F820128B2
1728:106BF00024420020AF8201288F8201288C82000469
1729:106C00002C42001150400013AC80000008002B12F1
1730:106C1000000000008EE24E302403004024420001B8
1731:106C200050430003000010218EE24E302442000148
1732:106C3000AEE24E308EE24E30000210C02442503898
1733:106C400002E2202124020012AC8200002402000192
1734:106C5000AC8200045600000B241000018EE204E414
1735:106C60003C04000124845754AFA00014AFA20010CC
1736:106C70008EE606088F4702283C0500090C00240315
1737:106C800034A5F006160000032402000108002B7151
1738:106C9000A2E204F48EE2017024420001AEE201702F
1739:106CA0008EE201708EE204E4A2E004F4AEE004F0AF
1740:106CB000AEE204F88F42023C50400045AEE07274F0
1741:106CC0008EE2018424420001AEE201848EE201845E
1742:106CD00008002B71AEE072748EE2050424030040BC
1743:106CE0002442000150430003000010218EE20504FD
1744:106CF00024420001AEE205048EE205048CC30018B4
1745:106D000000021080005710218C4405082402000363
1746:106D10001462000F000000003C0200010057102127
1747:106D2000904283B110400014000000008EE201D0B8
1748:106D30008EE3524000441021AEE201D08EE201D831
1749:106D400000641821306300FF08002B59AEE3524065
1750:106D50008EE201CC8EE30E1000441021AEE201CC95
1751:106D60008EE201D800641821306301FFAEE30E10FB
1752:106D700000441021AEE201D88EE20000344200400F
1753:106D800008002B71AEE200008EE2014C3C010001D4
1754:106D900000370821A02083E024420001AEE2014C2C
1755:106DA00008002B718EE2014C94C7000E8CC2001CAF
1756:106DB0003C04000124845760AFA60014AFA2001069
1757:106DC0008CC600183C0500080C00240334A50910EB
1758:106DD0008FBF001C8FB0001803E0000827BD002003
1759:106DE00027BDFF98AFBF0060AFBE005CAFB60058D4
1760:106DF000AFB50054AFB40050AFB3004CAFB20048D1
1761:106E0000AFB10044AFB000408F8301088F8201040E
1762:106E1000AFA00024106203E7AFA0002C3C1E0001CD
1763:106E200037DE38003C0BFFFF8F9301088E6200189D
1764:106E30008F8301042443FFFE2C620014104003CF13
1765:106E4000000310803C010001002208218C2257C061
1766:106E500000400008000000009663000E8EE2725CA5
1767:106E60008EE404F000431021AEE2725C8E63001CDD
1768:106E700096E2045824840001AEE404F02463000187
1769:106E80002442FFFF00621824AEE304E48F42023C78
1770:106E90000082202B148003B9000000008F830120A2
1771:106EA000276238002466002000C2102B50400001E9
1772:106EB000276630008F82012810C200040000000005
1773:106EC0008F82012414C20007000000008EE201A49A
1774:106ED0000000802124420001AEE201A408002BFE44
1775:106EE0008EE201A48EE204E4AC62001C8EE404B0E5
1776:106EF0008EE504B42462001CAC6200082402000881
1777:106F0000A462000E24020011AC620018AC64000000
1778:106F1000AC6500048EE204C4AC620010AF860120B0
1779:106F200092E24E2014400037241000018EE24E30D1
1780:106F3000000210C02442503802E220218C8300005D
1781:106F4000240200121462001F000000008EE34E3085
1782:106F50008EE24E341062001B240C00408C82000430
1783:106F600024420001AC8200048EE24E348EE34E30A7
1784:106F700024420001104C0007000000008EE24E3455
1785:106F800024420001106200050000000008002BE808
1786:106F90000000000014600005000000008F8201283E
1787:106FA00024420020AF8201288F8201288C820004B5
1788:106FB0002C42001150400013AC80000008002BFE52
1789:106FC000000000008EE24E30240C004024420001FC
1790:106FD000504C0003000010218EE24E30244200018C
1791:106FE000AEE24E308EE24E30000210C024425038E5
1792:106FF00002E2202124020012240C0001AC820000D5
1793:10700000AC8C00045600000D241000018EE204E454
1794:107010003C04000124845754AFA00014AFA2001018
1795:107020008EE606088F4702283C05000934A5F006C5
1796:107030000C002403AFAB00388FAB00381200030AFA
1797:10704000240C000108002F1900000000966C001CA1
1798:10705000AFAC002C9662001E3C0C8000AFAC00244C
1799:10706000AE62001C8E75001C8EE204FC8EE404FCF3
1800:1070700000151900006210218C52000C92E27B98DE
1801:10708000006418219476000A1440000332C2000202
1802:10709000AEF27BA4AEF57B9C1040004B000080213B
1803:1070A00096E2045A304200021040004700000000FF
1804:1070B0008E63001C8EE204FC00032100008210217C
1805:1070C0008C42000C037E1821244200220043102B26
1806:1070D0001440000A240500148EE204FC00821021F2
1807:1070E0008C44000CAFAB00380C002F752484000ECC
1808:1070F0008FAB003808002C523050FFFF8EE204FCAA
1809:10710000008210218C42000C9450000E9443001019
1810:10711000944400129445001402038021020480214B
1811:107120000205802194430016944400189445001AE7
1812:107130000203802102048021020580219443001C67
1813:107140009444001E94420020020380210204802106
1814:107150000202802100101C023202FFFF0062802127
1815:107160008E63001C8EE204FC001024020003290040
1816:1071700000A210218C43000C3202FFFF008280210C
1817:10718000037E1021246300180062182B146000098C
1818:10719000000000008EE204FC00A210218C43000CD1
1819:1071A000001010273C01FFFF0023082108002C6F6E
1820:1071B000A42200188EE204FC00A210218C43000CD3
1821:1071C00000101027A462001896E2045A00008821DB
1822:1071D00030420008144000630000A0218E63001CB0
1823:1071E0008EE204FC0003310000C210218C42000C2E
1824:1071F000037E1821244200220043102B1440003546
1825:10720000000000008EE204FC00C210218C42000C41
1826:1072100024470010037E102100E2102B5040000193
1827:1072200000EB38218EE204FC94F1000000C2102132
1828:107230008C42000C24470016037E102100E2102B24
1829:10724000144000022634FFEC00EB38218EE204FCEF
1830:1072500090E3000100C210218C42000C2447001A68
1831:10726000037E102100E2102B1440000202838821CB
1832:1072700000EB382194E2000024E70002022288217A
1833:10728000037E102100E2102B5040000100EB38215A
1834:1072900094E2000024E7000202228821037E1021EC
1835:1072A00000E2102B5040000100EB382194E2000076
1836:1072B00024E7000202228821037E102100E2102B25
1837:1072C0005040000100EB382194E2000008002CD06F
1838:1072D000022288218EE204FC00C210218C43000CA3
1839:1072E0008EE204FC947100108EE304FC00C21021B5
1840:1072F0008C44000C00C318218C62000C2634FFEC77
1841:10730000908400178EE304FC9442001A02848821C2
1842:1073100000C318218C65000C8EE304FC0222882136
1843:107320008EE204FC00C3182100C210218C44000C22
1844:107330008C62000C94A3001C9484001E94420020D4
1845:1073400002238821022488210222882100111C02A4
1846:107350003222FFFF0062882100111C023222FFFF4F
1847:107360000062882132C20001104000B2000000001B
1848:1073700096E2045A30420001104000AE32C2008052
1849:10738000104000080000000092E27B9814400005C5
1850:1073900000000000240C0001A2EC7B98AEF57B9C61
1851:1073A000AEF27BA48EE304FC001511000043102113
1852:1073B0008C47000C037E182124E2000E0043102BA2
1853:1073C0001440000800E020212405000E0C002F7559
1854:1073D000AFAB00383042FFFF8FAB003808002D09FB
1855:1073E0000202802194E6000024E7000294E50000F8
1856:1073F00024E7000294E3000024E7000294E2000086
1857:1074000024E7000294E4000024E700020206802141
1858:1074100002058021020380210202802194E2000003
1859:1074200094E30002020480210202802102038021F1
1860:1074300000101C023202FFFF0062802100101C02BB
1861:107440003202FFFF8EE47B9C0062802114950004D1
1862:107450003205FFFF9662001608002D17005120210B
1863:107460009662001600542021000414023083FFFFAE
1864:1074700000432021008520230004140200822021E3
1865:107480003084FFFF508000013404FFFF8EE27BA4B4
1866:1074900024430017037E10210062102B504000018E
1867:1074A000006B182190630000240200111462003167
1868:1074B000240200068EE27BA4037E182124420028C9
1869:1074C0000043102B14400018000000008EE27B9C4B
1870:1074D00012A2000A32C201008EE27BA43C01FFFF2F
1871:1074E00000220821942200280082202100041C028E
1872:1074F0003082FFFF0062202132C2010014400004EC
1873:107500000004102792E27B98144000020004102728
1874:107510003044FFFF8EE27BA43C01FFFF00220821E4
1875:1075200008002D8AA42400288EE27B9C12A2000869
1876:1075300032C201008EE27BA4944200280082202106
1877:1075400000041C023082FFFF0062202132C20100D1
1878:10755000144000040004102792E27B9814400002BB
1879:10756000000410273044FFFF8EE27BA408002D8A20
1880:10757000A44400281462002F037E18218EE27BA40D
1881:10758000244200320043102B144000180000000079
1882:107590008EE27B9C12A2000A32C201008EE27BA422
1883:1075A0003C01FFFF002208219422003200822021AA
1884:1075B00000041C023082FFFF0062202132C2010061
1885:1075C000144000040004102792E27B98144000024B
1886:1075D000000410273044FFFF8EE27BA43C01FFFF34
1887:1075E0000022082108002D8AA42400328EE27B9C10
1888:1075F00012A2000832C201008EE27BA49442003243
1889:107600000082202100041C023082FFFF0062202142
1890:1076100032C20100144000040004102792E27B985B
1891:1076200014400002000410273044FFFF8EE27BA4C8
1892:10763000A44400328FAC00241180002C037E18215A
1893:107640008E420000AE42FFFC2642000A0043102B8F
1894:107650001440001B3403810026430004037E1021E4
1895:107660000062102B1440000300602021006B1821E1
1896:10767000006020218C62000024630004AE42000000
1897:10768000037E10210062102B50400001006B182176
1898:107690008C620000AC82000034028100A462000011
1899:1076A00024630002037E10210062102B5040000171
1900:1076B000006B182197AC002E08002DB4A46C0000BC
1901:1076C0008E4200048E440008A643000897AC002EAA
1902:1076D000A64C000AAE420000AE4400049662000EC2
1903:1076E0002652FFFC24420004A662000E9662000EA1
1904:1076F0008EE3725C00621821AEE3725CAFB20018D8
1905:107700008EE3725CAFA3001C8EE2725C2C42003CE4
1906:1077100010400004246200012403FFFE00431024F3
1907:10772000AFA2001C32C200801040000C32C2010027
1908:107730008EE27BA824430001000210C000571021F4
1909:10774000AEE37BA88FA300188FA4001CAC437BACD6
1910:10775000AC447BB008002EA0AEE0725C104000721A
1911:10776000000000008EE27BA824430001000210C04C
1912:1077700000571021AEE37BA88FA300188FA4001C34
1913:10778000AC437BACAC447BB08EE27BA81040006382
1914:1077900000004821000050218F8200F0244800089A
1915:1077A000276218000102102B5040000127681000CA
1916:1077B0008F8200F415020007000000008EE201B481
1917:1077C0000000802124420001AEE201B408002DFA3D
1918:1077D0008EE201B48F8300F02410000101571021C4
1919:1077E0008C447BAC8C457BB0AC640000AC65000481
1920:1077F000AF8800F01600000602EA10218EE2008831
1921:1078000024420001AEE2008808002E3F8EE200888C
1922:107810008C427BB08EE400E08EE500E48EE67B9C3B
1923:10782000004018210000102100A3282100A3382BBC
1924:1078300000822021008720218EE204FC00C9302133
1925:1078400000063100AEE400E0AEE500E400C2302105
1926:1078500094C2000A240C00020002114230430003CB
1927:10786000106C00162862000310400005240C000173
1928:10787000106C00080000000008002E3F000000000F
1929:10788000240C0003106C00170000000008002E3FBD
1930:10789000000000008EE200E88EE300EC24630001AB
1931:1078A0002C64000100441021AEE200E8AEE300ECDD
1932:1078B0008EE200E808002E3F8EE300EC8EE200F03E
1933:1078C0008EE300F4246300012C64000100441021C5
1934:1078D000AEE200F0AEE300F48EE200F008002E3FCE
1935:1078E0008EE300F48EE200F88EE300FC24630001D6
1936:1078F0002C64000100441021AEE200F8AEE300FC6D
1937:107900008EE200F88EE300FC8EE27BA825290001C0
1938:107910000122102B1440FFA0254A0008A2E07B980A
1939:1079200008002E9FAEE07BA88F8200F0244700085D
1940:107930002762180000E2102B50400001276710005A
1941:107940008F8200F414E20007000000008EE201B410
1942:107950000000802124420001AEE201B408002E5D47
1943:107960008EE201B48F8200F0241000018FA3001872
1944:107970008FA4001CAC430000AC440004AF8700F0AF
1945:1079800016000007000000008EE20088244200017B
1946:10799000AEE200888EE2008808002EA0AEE0725CA5
1947:1079A0008EE2725C8EE400E08EE500E4240C0002BE
1948:1079B000004018210000102100A3282100A3302B33
1949:1079C000008220210086202100161142304300034E
1950:1079D000AEE400E0AEE500E4106C00172C6200039A
1951:1079E00010400005240C0001106C0008000000008D
1952:1079F00008002EA0AEE0725C240C0003106C00198D
1953:107A00000000000008002EA0AEE0725C8EE200E8EC
1954:107A10008EE300EC246300012C640001004410217B
1955:107A2000AEE200E8AEE300EC8EE200E88EE300ECAC
1956:107A300008002EA0AEE0725C8EE200F08EE300F44F
1957:107A4000246300012C64000100441021AEE200F028
1958:107A5000AEE300F48EE200F08EE300F408002EA006
1959:107A6000AEE0725C8EE200F88EE300FC246300015D
1960:107A70002C64000100441021AEE200F8AEE300FCEB
1961:107A80008EE200F88EE300FCAEE0725C8E62001CB9
1962:107A900096E304588EE404F0244200012463FFFFBF
1963:107AA0000043102424840001AEE204E4AEE404F0B8
1964:107AB0008F42023C0082202B148000B000000000A6
1965:107AC0008F830120276238002466002000C2102B1B
1966:107AD00050400001276630008F82012810C2000448
1967:107AE000000000008F82012414C200070000000083
1968:107AF0008EE201A40000802124420001AEE201A434
1969:107B000008002F078EE201A48EE204E4AC62001CA0
1970:107B10008EE404B08EE504B42462001CAC6200085C
1971:107B200024020008A462000E24020011AC620018B6
1972:107B3000AC640000AC6500048EE204C4AC620010CA
1973:107B4000AF86012092E24E2014400037241000013D
1974:107B50008EE24E30000210C02442503802E2202152
1975:107B60008C830000240200121462001F0000000039
1976:107B70008EE34E308EE24E341062001B240C004027
1977:107B80008C82000424420001AC8200048EE24E3458
1978:107B90008EE34E3024420001104C0007000000002C
1979:107BA0008EE24E3424420001106200050000000005
1980:107BB00008002EF100000000146000050000000025
1981:107BC0008F82012824420020AF8201288F82012861
1982:107BD0008C8200042C42001150400013AC80000045
1983:107BE00008002F07000000008EE24E30240C0040F9
1984:107BF00024420001504C0003000010218EE24E3060
1985:107C000024420001AEE24E308EE24E30000210C03F
1986:107C10002442503802E2202124020012240C0001E8
1987:107C2000AC820000AC8C00045600000D2410000152
1988:107C30008EE204E43C04000124845754AFA00014F5
1989:107C4000AFA200108EE606088F4702283C05000907
1990:107C500034A5F0060C002403AFAB00388FAB00381E
1991:107C600016000003240C000108002F5CA2EC04F4B1
1992:107C70008EE2017024420001AEE201708EE20170DA
1993:107C80008EE204E4A2E004F4AEE004F0AEE072742C
1994:107C9000AEE204F88F42023C1040003800000000C1
1995:107CA0008EE2018424420001AEE2018408002F5CD0
1996:107CB0008EE201848EE20504240C0040244200017F
1997:107CC000504C0003000010218EE205042442000104
1998:107CD000AEE205048EE205048E630018240C000356
1999:107CE0000002108000571021146C000F8C4405080E
2000:107CF0003C02000100571021904283B11040001453
2001:107D0000000000008EE201D08EE3524000441021BA
2002:107D1000AEE201D08EE201D800641821306300FF8A
2003:107D200008002F4FAEE352408EE201CC8EE30E10DE
2004:107D300000441021AEE201CC8EE201D8006418218B
2005:107D4000306301FFAEE30E1000441021AEE201D813
2006:107D50008EE200003442004008002F5CAEE20000DA
2007:107D60008EE2014C3C01000100370821A02083E095
2008:107D700024420001AEE2014C8EE2014C8F820108E8
2009:107D800024420020AF8201088F8201088F820108FF
2010:107D9000276330000043102B1440000227622800A4
2011:107DA000AF8201088F8301088F8201041462FC1ED8
2012:107DB000000000008FBF00608FBE005C8FB60058CF
2013:107DC0008FB500548FB400508FB3004C8FB2004871
2014:107DD0008FB100448FB0004003E0000827BD006869
2015:107DE0000005284310A0000D000030213C030001D5
2016:107DF000346338003C07FFFF036310210082102B1F
2017:107E00005040000100872021948200002484000259
2018:107E100024A5FFFF14A0FFF800C2302100061C02B9
2019:107E200030C2FFFF0062302100061C0230C2FFFF9B
2020:107E30000062302103E0000830C2FFFF27BDFF8849
2021:107E4000240F0001AFBF0070AFBE006CAFB600687A
2022:107E5000AFB50064AFB40060AFB3005CAFB2005820
2023:107E6000AFB10054AFB00050A3A00027AFAF002CBB
2024:107E70008EE204D400008021304200011440002A28
2025:107E8000A3A000378F8700E08F8800C48F8200E8AE
2026:107E900000E220232C8210005040000124841000B6
2027:107EA000000420C2008018218EE400C88EE500CCBA
2028:107EB0000000102100A3282100A3302B00822021E4
2029:107EC00000862021AEE400C8AEE500CC8F8300C858
2030:107ED0003C02000A3442EFFF010320230044102B30
2031:107EE000104000033C02000A3442F00000822021CE
2032:107EF000008018218EE400C08EE500C4000010212F
2033:107F000000A3282100A3302B0082202100862021FD
2034:107F1000AEE400C0AEE500C4AF8800C8AF8700E49F
2035:107F2000080034CCAF8700E83C0200010057102164
2036:107F3000904283C01040000B000000003C14000180
2037:107F40000297A0218E9483C43C13000102779821EC
2038:107F50008E7383C83C1200010257902108003193B0
2039:107F60008E5283CC8F8300E08F8200E410430007A1
2040:107F7000000088218F8200E4241100018C4300005E
2041:107F80008C440004AFA30018AFA4001C1620000E00
2042:107F90003C02FFFF8F8200C4AFA200108F8200C896
2043:107FA0003C04000124845870AFA200148F8600E0C6
2044:107FB0008F8700E43C0500060C00240334A5F00084
2045:107FC000080034CC000000008FA3001C8FB2001802
2046:107FD0003074FFFF2694FFFC00621024104000580C
2047:107FE000024098213C020080006210241040000AE8
2048:107FF0003C0400408EE2007C24420001AEE2007CA2
2049:108000008EE2007C8EE201FC24420001AEE201FC23
2050:10801000080034C68EE201FC3C0600043C0B000163
2051:108020003C0A00023C0500103C0900088EE200807A
2052:108030003C0800203407800024420001AEE20080AA
2053:108040008EE200808FA2001C0044182410660021DC
2054:1080500000C3102B1440000700000000106B00113B
2055:1080600000000000106A0015000000000800304900
2056:10807000000420421065002300A3102B14400005CB
2057:1080800000000000106900190000000008003049DD
2058:108090000004204210680021000000000800304960
2059:1080A000000420428EE2003424420001AEE200349B
2060:1080B0008EE2003408003049000420428EE201ECD8
2061:1080C00024420001AEE201EC8EE201EC08003049EE
2062:1080D000000420428EE201F024420001AEE201F0F1
2063:1080E0008EE201F008003049000420428EE201F4E3
2064:1080F00024420001AEE201F48EE201F408003049AE
2065:10810000000420428EE2003024420001AEE2003042
2066:108110008EE2003008003049000420428EE201F86F
2067:1081200024420001AEE201F88EE201F80004204290
2068:108130001087047C000000000800300E00000000E2
2069:108140003C02000100571021904283B21440008489
2070:10815000240200013C03000100771821906383B3DF
2071:108160001462007F3C0201008E4300000062102474
2072:108170001040006F2402FFFF14620005241000016C
2073:10818000964300043402FFFF1062007500000000F7
2074:1081900092E204D814400072000000003C0200018A
2075:1081A000005710218C4283B4284200051040002063
2076:1081B000000038213C020001005710218C4283B49A
2077:1081C000184000160000282196660000000520C017
2078:1081D000009710219442777E1446000900971021E1
2079:1081E0009443778096620002146200050097102184
2080:1081F00094437782966200045062000824070001CD
2081:108200003C020001005710218C4283B424A50001D8
2082:1082100000A2102A5440FFEE000520C030E200FF0B
2083:108220001040044000000000080030D500000000AD
2084:10823000024020210C0022FE240500063044001FCD
2085:10824000000428C002E510219442727C30424000B4
2086:108250001440043400B710219443727E96620000EB
2087:108260001462000B000418C000B710219443728000
2088:108270009662000214620006000418C000B71021C4
2089:10828000944372829662000410620035000418C0A4
2090:1082900002E310219442727C304280001440042199
2091:1082A00002E31021944B727C96670000000B28C0FB
2092:1082B00000B710219442737E080030B700003021CF
2093:1082C000000420C002E410219443737C02E41021D6
2094:1082D000944B737C3063800014600010000B28C046
2095:1082E00000B710219442737E1447FFF501602021EE
2096:1082F00000B7102194437380966200025462FFF12C
2097:10830000000420C000B710219443738296620004D9
2098:108310005462FFEC000420C02406000130C200FFBC
2099:108320001040040000000000080030D500000000EC
2100:108330009743020296420000146203FA0000000014
2101:108340009743020496420002146203F60000000004
2102:108350009743020696420004146203F200000000F4
2103:10836000924200003A030001304200010043102411
2104:10837000104000742402FFFF8E63000014620004AA
2105:108380003402FFFF966300041062006F240F0002A6
2106:108390003C02000100571021904283B21440006A51
2107:1083A000240F000392E204D854400068AFAF002CC1
2108:1083B0003C020001005710218C4283B42842000582
2109:1083C00010400020000038213C020001005710211D
2110:1083D0008C4283B4184000160000282196660000E5
2111:1083E000000520C0009710219442777E14460009B2
2112:1083F0000097102194437780966200021462000572
2113:10840000009710219443778296620004506200081E
2114:10841000240700013C020001005710218C4283B464
2115:1084200024A5000100A2102A5440FFEE000520C040
2116:1084300030E200FF14400044240F0003080034C65B
2117:1084400000000000024020210C0022FE240500064E
2118:108450003044001F000428C002E510219442727CC1
2119:1084600030424000144003AF00B710219443727EA5
2120:10847000966200001462000B000418C000B71021BF
2121:10848000944372809662000214620006000418C0D1
2122:1084900000B7102194437282966200041062002794
2123:1084A000000418C002E310219442727C3042800024
2124:1084B0001440039C02E31021944B727C96670000E9
2125:1084C000000B28C000B710219442737E0800313C95
2126:1084D00000003021000420C002E410219443737C8A
2127:1084E00002E41021944B737C306380001460001010
2128:1084F000000B28C000B710219442737E1447FFF58B
2129:108500000160202100B7102194437380966200021D
2130:108510005462FFF1000420C000B71021944373821D
2131:10852000966200045462FFEC000420C0240600019F
2132:1085300030C200FF1040037B000000000800314FF4
2133:10854000240F0003240F0001AFAF002C8F42026004
2134:108550000054102B1040003A000000008F8300E40C
2135:108560008F8200E01062000324630008AF8300E400
2136:10857000AF8300E88EE400C08EE500C402801821BD
2137:108580000000102100A3282100A3302B008220210D
2138:1085900000862021AEE400C0AEE500C48EE20058A3
2139:1085A00024420001AEE200588EE200588EE2007CC8
2140:1085B00024420001AEE2007C8EE2007C8F8200E06B
2141:1085C000AFA200108F8200E43C040001248458789C
2142:1085D000AFA200148FA600188FA7001C3C05000650
2143:1085E0000C00240334A5F003080034CC0000000084
2144:1085F0008EE25240AFA200108EE252443C040001D1
2145:1086000024845884AFA200148EE60E108EE70E1854
2146:108610003C0500060C00240334A5F0028EE201C0E4
2147:1086200024420001AEE201C08EE200008EE301C0F0
2148:108630002403FFBF0043102408003470AEE20000A2
2149:1086400096E204680054102B104000030000000064
2150:10865000240F0001A3AF0027128003012416000796
2151:1086600024150040241E0001240E00128EE2724CDC
2152:108670008F43028024420001304207FF106202D380
2153:108680000000000093A2002710400014000000002A
2154:108690008EE352408EE252441062000926ED5244AD
2155:1086A0008EE652448EE35244000211402442524866
2156:1086B00002E2802124630001080031BF306B00FF1B
2157:1086C00092E272481440FFCA000000008EE201E00E
2158:1086D00024420001AEE201E08EE201E08EE30E10E2
2159:1086E0008EE20E181062FFC226ED0E188EE60E18EE
2160:1086F0008EE30E180002114024420E2002E2802177
2161:1087000024630001306B01FF96E2046A30420010DE
2162:1087100010400019000000009642000C340F810048
2163:10872000144F0015000000003C020001005710210A
2164:10873000904283C014400010000000009642000EDA
2165:10874000A60200168E4200088E4300048E440000EC
2166:108750002694FFFCAE42000CAE430008AE44000479
2167:108760009602000E26730004240F0001A3AF003709
2168:1087700034420200A602000E8E0200008E030004A6
2169:108780003C04000134843800306A0007026A9823F0
2170:10879000036410210262102B10400005028AA02100
2171:1087A00002641023036218233C0200200043982334
2172:1087B000268200072404FFF89603000A0044602480
2173:1087C000006A1821006C102B104000020180382133
2174:1087D00000603821AE1300188F88012024E20007C2
2175:1087E0000044382427623800250900200122102B7C
2176:1087F00050400001276930008F82012811220004B7
2177:10880000000000008F82012415220007014018217A
2178:108810008EE201A40000882124420001AEE201A4FE
2179:108820000800324C8EE201A48E0400008E05000484
2180:1088300000001021AD130008A507000EAD160018AA
2181:10884000AD06001C00A3302B00A3282300822023A8
2182:1088500000862023AD040000AD0500048EE204C0B4
2183:10886000AD020010AF89012092E24E201440003387
2184:10887000241100018EE24E30000210C02442503814
2185:1088800002E220218C8200001456001F000000002C
2186:108890008EE34E308EE24E341062001B000000006A
2187:1088A0008C82000424420001AC8200048EE24E342B
2188:1088B0008EE34E30244200011055000700000000F6
2189:1088C0008EE24E34244200011062000500000000D8
2190:1088D00008003239000000001460000500000000AC
2191:1088E0008F82012824420020AF8201288F82012834
2192:1088F0008C8200042C42001150400010AC8000001B
2193:108900000800324C000000008EE24E30244200018C
2194:1089100050550003000010218EE24E302442000129
2195:10892000AEE24E308EE24E30000210C0244250388B
2196:1089300002E22021AC960000AC9E00041620001834
2197:108940003C0500068E0200183C0400012484589067
2198:10895000AFA200108E0200008E03000434A5F009BF
2199:10896000020030210C002403AFA3001493A20037AF
2200:1089700010400216340F81008E4200048E4300081E
2201:108980008E44000CA64F000CAE420000AE43000423
2202:10899000AE4400089602001608003470A642000E8D
2203:1089A00014EC0168028A1823960C000A9603000E44
2204:1089B000028A1023A602000A34620004A602000EF6
2205:1089C0008F88012027623800250900200122102B02
2206:1089D00014400002306AFFFF276930008F820128AF
2207:1089E00011220004000000008F82012415220007DC
2208:1089F000240400208EE201A400008821244200010A
2209:108A0000AEE201A4080032CA8EE201A48EE5724CE7
2210:108A10008EE604908EE70494A504000E240400045E
2211:108A2000AD100008AD0400180005294000A0182171
2212:108A30000000102100E3382100E3202B00C2302188
2213:108A400000C43021AD060000AD0700048EE2724C78
2214:108A5000AD02001C8EE204C4AD020010AF890120FB
2215:108A600092E24E2014400033241100018EE24E3079
2216:108A7000000210C02442503802E220218C82000003
2217:108A80001456001F000000008EE34E308EE24E347C
2218:108A90001062001B000000008C82000424420001D0
2219:108AA000AC8200048EE24E348EE34E30244200014C
2220:108AB00010550007000000008EE24E3424420001F1
2221:108AC0001062000500000000080032B7000000003E
2222:108AD00014600005000000008F820128244200205D
2223:108AE000AF8201288F8201288C8200042C42001161
2224:108AF00050400010AC800000080032CA00000000A6
2225:108B00008EE24E3024420001505500030000102137
2226:108B10008EE24E3024420001AEE24E308EE24E3004
2227:108B2000000210C02442503802E22021AC9600001E
2228:108B3000AC9E00041620000D00000000A60C000AE8
2229:108B4000A60A000E8F820100AFA200108F820104DE
2230:108B50003C0400012484589C3C050006AFA200148C
2231:108B60008EE6724C0800343B34A5F00B3C0100014A
2232:108B700000370821A02083C0ADAB00008EE201D8F1
2233:108B80008EE3724C2442FFFFAEE201D88EE201D8A0
2234:108B900024630001306307FF26E2524415A2000659
2235:108BA000AEE3724C8EE201D02442FFFFAEE201D070
2236:108BB000080032EF8EE201D08EE201CC2442FFFFAA
2237:108BC000AEE201CC8EE201CC8F4202401040007335
2238:108BD000000000008EE20E1C24420001AEE20E1CDA
2239:108BE0008F4302400043102B144001760000A02167
2240:108BF0008F830120276238002466002000C2102BDA
2241:108C000050400001276630008F82012810C2000406
2242:108C1000000000008F82012414C200070000000041
2243:108C20008EE201A40000882124420001AEE201A4EA
2244:108C30000800334F8EE201A48EE2724CAC62001C3D
2245:108C40008EE404A88EE504AC2462001CAC6200082B
2246:108C500024020008A462000E24020011AC62001875
2247:108C6000AC640000AC6500048EE204C4AC62001089
2248:108C7000AF86012092E24E201440003324110001FF
2249:108C80008EE24E30000210C02442503802E2202111
2250:108C90008C820000144E001F000000008EE34E3056
2251:108CA0008EE24E341062001B000000008C82000433
2252:108CB00024420001AC8200048EE24E348EE34E303A
2253:108CC0002442000110550007000000008EE24E34DF
2254:108CD0002442000110620005000000000800333C3F
2255:108CE0000000000014600005000000008F820128D1
2256:108CF00024420020AF8201288F8201288C82000448
2257:108D00002C42001150400010AC8000000800334F8E
2258:108D1000000000008EE24E30244200015055000356
2259:108D2000000010218EE24E3024420001AEE24E30AF
2260:108D30008EE24E30000210C02442503802E2202160
2261:108D4000AC8E0000AC9E00045620000D24110001E2
2262:108D50008EE2724C3C040001248458A8AFA0001499
2263:108D6000AFA200108EE6724C8F4702803C050009CE
2264:108D700034A5F0080C002403AFAE00488FAE0048C5
2265:108D800056200001AEE00E1C8EE201882442000154
2266:108D9000AEE20188080033C88EE201888F8301208B
2267:108DA000276238002466002000C2102B50400001CA
2268:108DB000276630008F82012810C2000400000000E6
2269:108DC0008F82012414C20007000000008EE201A47B
2270:108DD0000000882124420001AEE201A4080033BA59
2271:108DE0008EE201A48EE2724CAC62001C8EE404A8F8
2272:108DF0008EE504AC2462001CAC620008240200086A
2273:108E0000A462000E24020011AC620018AC640000E1
2274:108E1000AC6500048EE204C4AC620010AF86012091
2275:108E200092E24E2014400033241100018EE24E30B5
2276:108E3000000210C02442503802E220218C8200003F
2277:108E4000144E001F000000008EE34E308EE24E34C0
2278:108E50001062001B000000008C820004244200010C
2279:108E6000AC8200048EE24E348EE34E302442000188
2280:108E700010550007000000008EE24E34244200012D
2281:108E80001062000500000000080033A70000000089
2282:108E900014600005000000008F8201282442002099
2283:108EA000AF8201288F8201288C8200042C4200119D
2284:108EB00050400010AC800000080033BA00000000F1
2285:108EC0008EE24E3024420001505500030000102174
2286:108ED0008EE24E3024420001AEE24E308EE24E3041
2287:108EE000000210C02442503802E22021AC8E000063
2288:108EF000AC9E00041620000D000000008EE2724CB3
2289:108F00003C040001248458A8AFA00014AFA20010B4
2290:108F10008EE6724C8F4702803C05000934A5F008AC
2291:108F20000C002403AFAE00488FAE00488EE20174FF
2292:108F300024420001AEE201748EE201740800346E36
2293:108F40000000A021960C000A0183102B5440000160
2294:108F500001801821A603000A8F88012027623800AB
2295:108F6000250900200122102B504000012769300004
2296:108F70008F82012811220004000000008F8201244A
2297:108F800015220007240400208EE201A4000088219D
2298:108F900024420001AEE201A40800342F8EE201A4B5
2299:108FA0008EE5724C8EE604908EE70494A504000EC4
2300:108FB00024040004AD100008AD0400180005294089
2301:108FC00000A018210000102100E3382100E3202B2D
2302:108FD00000C2302100C43021AD060000AD070004FE
2303:108FE0008EE2724CAD02001C8EE204C4AD02001091
2304:108FF000AF89012092E24E20144000332411000179
2305:109000008EE24E30000210C02442503802E220218D
2306:109010008C8200001456001F000000008EE34E30CA
2307:109020008EE24E341062001B000000008C820004AF
2308:1090300024420001AC8200048EE24E348EE34E30B6
2309:109040002442000110550007000000008EE24E345B
2310:109050002442000110620005000000000800341CDA
2311:109060000000000014600005000000008F8201284D
2312:1090700024420020AF8201288F8201288C820004C4
2313:109080002C42001150400010AC8000000800342F2A
2314:10909000000000008EE24E302442000150550003D3
2315:1090A000000010218EE24E3024420001AEE24E302C
2316:1090B0008EE24E30000210C02442503802E22021DD
2317:1090C000AC960000AC9E00041620001D00000000BD
2318:1090D000A60C000A8F820100AFA200108F8201044B
2319:1090E0003C0400012484589C3C050006AFA20014F7
2320:1090F0008EE6724C34A5F00D0C00240302003821DA
2321:1091000093A2003710400031340F81008E420004DA
2322:109110008E4300088E44000CA64F000CAE420000A7
2323:10912000AE430004AE44000896020016A642000EAC
2324:109130009602000E3042FDFF08003470A602000EB9
2325:109140008EE201D82442FFFFAEE201D88EE201D8C0
2326:109150008EE201CC3C04001F3C01000100370821D5
2327:10916000A03E83C02442FFFFAEE201CC9603000A7A
2328:109170003484FFFF8EE201CC006A1821026398213B
2329:109180000093202B108000033C02FFF534421000B6
2330:1091900002629821ADAB00008EE2724C24420001C5
2331:1091A000304207FFAEE2724C8F4202401040000492
2332:1091B0000283A0238EE20E1C24420001AEE20E1CAC
2333:1091C000A3A000271680FD290000000012800024C3
2334:1091D000000000003C01000100370821AC3483C4CA
2335:1091E0003C01000100370821AC3383C83C01000179
2336:1091F00000370821AC3283CC93A20037104000081E
2337:10920000000000003C020001005710218C4283CC7A
2338:10921000244200043C01000100370821AC2283CC29
2339:109220008EE2724C8F43028024420001304207FFDD
2340:1092300014620006000000008EE201C42442000116
2341:10924000AEE201C4080034CC8EE201C48EE201BC5F
2342:1092500024420001AEE201BC080034CC8EE201BC25
2343:1092600097A4001E2484FFFC008018218EE400C017
2344:109270008EE500C40000102100A3282100A3302B9C
2345:109280000082202100862021AEE400C0AEE500C4AB
2346:109290008FAF002C2402000211E2000F29E200032C
2347:1092A000144000172402000315E20015000000001E
2348:1092B0008EE200D08EE300D4246300012C64000110
2349:1092C00000441021AEE200D0AEE300D48EE200D024
2350:1092D000080034C68EE300D48EE200D88EE300DCB2
2351:1092E000246300012C64000100441021AEE200D888
2352:1092F000AEE300DC8EE200D8080034C68EE300DC6A
2353:109300008EE200C88EE300CC246300012C640001CF
2354:1093100000441021AEE200C8AEE300CC8EE200C8EB
2355:109320008EE300CC8F8300E48F8200E010620003A4
2356:1093300024630008AF8300E4AF8300E88FBF0070B0
2357:109340008FBE006C8FB600688FB500648FB400606C
2358:109350008FB3005C8FB200588FB100548FB00050B3
2359:1093600003E0000827BD007827BDFFB0AFB500447B
2360:109370000000A821AFB0003000008021AFBF004C3A
2361:10938000AFB60048AFB40040AFB3003CAFB2003856
2362:10939000AFB100348EE204D4241400013042000145
2363:1093A0001440002A0000B0218F8700E08F8800C49D
2364:1093B0008F8200E800E220232C8210005040000140
2365:1093C00024841000000420C2008018218EE400C80C
2366:1093D0008EE500CC0000102100A3282100A3302B33
2367:1093E0000082202100862021AEE400C8AEE500CC3A
2368:1093F0008F8300C83C02000A3442EFFF01032023A0
2369:109400000044102B104000033C02000A3442F000DC
2370:1094100000822021008018218EE400C08EE500C467
2371:109420000000102100A3282100A3302B008220215E
2372:1094300000862021AEE400C0AEE500C4AF8800C8BD
2373:10944000AF8700E408003850AF8700E83C02000115
2374:1094500000571021904283C01040000B0000000014
2375:109460003C130001027798218E7383C43C110001E4
2376:10947000023788218E3183C83C12000102579021A7
2377:10948000080036E88E5283CC8F8300E08F8200E4A0
2378:1094900010430007000048218F8200E424090001E6
2379:1094A0008C4300008C440004AFA30018AFA4001C40
2380:1094B0001520000E3C02FFFF8F8200C4AFA20010F7
2381:1094C0008F8200C83C04000124845870AFA20014AD
2382:1094D0008F8600E08F8700E43C0500060C00240323
2383:1094E00034A5F00008003850000000008FA3001CD5
2384:1094F0008FB200183073FFFF2673FFFC0062102448
2385:1095000010400058024088213C0200800062102474
2386:109510001040000A3C0400408EE2007C244200011E
2387:10952000AEE2007C8EE2007C8EE201FC244200016F
2388:10953000AEE201FC0800384A8EE201FC3C06000461
2389:109540003C0B00013C0A00023C0500103C090008ED
2390:109550008EE200803C080020340780002442000195
2391:10956000AEE200808EE200808FA2001C004418242E
2392:109570001066002100C3102B1440000700000000FB
2393:10958000106B001100000000106A001500000000C0
2394:1095900008003592000420421065002300A3102B20
2395:1095A00014400005000000001069001900000000D0
2396:1095B00008003592000420421068002100000000DD
2397:1095C00008003592000420428EE20034244200015B
2398:1095D000AEE200348EE200340800359200042042EE
2399:1095E0008EE201EC24420001AEE201EC8EE201ECDD
2400:1095F00008003592000420428EE201F0244200016E
2401:10960000AEE201F08EE201F0080035920004204243
2402:109610008EE201F424420001AEE201F48EE201F494
2403:1096200008003592000420428EE2003024420001FE
2404:10963000AEE200308EE20030080035920004204295
2405:109640008EE201F824420001AEE201F88EE201F858
2406:1096500000042042108702B70000000008003557C0
2407:10966000000000003C02000100571021904283B22C
2408:1096700014400084240200013C03000100771821FB
2409:10968000906383B31462007F3C0201008E430000AC
2410:10969000006210241040006F2402FFFF14620005D6
2411:1096A00024100001964300043402FFFF106200758D
2412:1096B0000000000092E204D8144000720000000094
2413:1096C0003C020001005710218C4283B4284200055F
2414:1096D00010400020000038213C02000100571021FA
2415:1096E0008C4283B418400016000028219626000002
2416:1096F000000520C0009710219442777E144600098F
2417:10970000009710219443778096220002146200058E
2418:10971000009710219443778296220004506200083B
2419:10972000240700013C020001005710218C4283B441
2420:1097300024A5000100A2102A5440FFEE000520C01D
2421:1097400030E200FF1040027B000000000800361EDF
2422:1097500000000000024020210C0022FE240500062B
2423:109760003044001F000428C002E510219442727C9E
2424:10977000304240001440026F00B710219443727EC3
2425:10978000962200001462000B000418C000B71021DC
2426:10979000944372809622000214620006000418C0EE
2427:1097A00000B71021944372829622000410620035A3
2428:1097B000000418C002E310219442727C3042800001
2429:1097C0001440025C02E310219448727C962700004A
2430:1097D000000828C000B710219442737E08003600AC
2431:1097E00000003021000420C002E410219443737C67
2432:1097F00002E410219448737C3063800014600010F0
2433:10980000000828C000B710219442737E1447FFF56A
2434:109810000100202100B7102194437380962200029A
2435:109820005462FFF1000420C000B7102194437382FA
2436:10983000962200045462FFEC000420C024060001BC
2437:1098400030C200FF1040023B000000000800361E3E
2438:1098500000000000974302029642000014620235A5
2439:109860000000000097430204964200021462023195
2440:109870000000000097430206964200041462022D85
2441:1098800000000000924200003A0300013042000153
2442:1098900000431024104000742402FFFF8E230000B8
2443:1098A000146200043402FFFF962300041062006F6C
2444:1098B000241400023C02000100571021904283B2A0
2445:1098C0001440006A2414000392E204D81440006794
2446:1098D000000000003C020001005710218C4283B4BC
2447:1098E0002842000510400020000038213C02000101
2448:1098F000005710218C4283B4184000160000282124
2449:1099000096260000000520C0009710219442777E23
2450:109910001446000900971021944377809622000294
2451:109920001462000500971021944377829622000468
2452:1099300050620008240700013C020001005710217A
2453:109940008C4283B424A5000100A2102A5440FFEEEB
2454:10995000000520C030E200FF14400044241400033E
2455:109960000800384A00000000024020210C0022FEBE
2456:10997000240500063044001F000428C002E5102121
2457:109980009442727C30424000144001EA00B710213A
2458:109990009443727E962200001462000B000418C0EB
2459:1099A00000B71021944372809622000214620006D0
2460:1099B000000418C000B7102194437282962200045C
2461:1099C00010620027000418C002E310219442727C48
2462:1099D00030428000144001D702E310219448727C89
2463:1099E00096270000000828C000B710219442737E1B
2464:1099F0000800368500003021000420C002E4102158
2465:109A00009443737C02E410219448737C306380009B
2466:109A100014600010000828C000B710219442737E23
2467:109A20001447FFF50100202100B7102194437380F3
2468:109A3000962200025462FFF1000420C000B71021FA
2469:109A400094437382962200045462FFEC000420C009
2470:109A50002406000130C200FF104001B600000000E3
2471:109A60000800369824140003241400018F42026079
2472:109A70000053102B10400049000000008F8300E4C9
2473:109A80008F8200E01062000324630008AF8300E4CB
2474:109A9000AF8300E88EE400C08EE500C402601821A8
2475:109AA0000000102100A3282100A3302B00822021D8
2476:109AB00000862021AEE400C0AEE500C48EE200586E
2477:109AC00024420001AEE200588EE200588EE2007C93
2478:109AD00024420001AEE2007C8EE2007C8F8200E036
2479:109AE000AFA200108F8200E43C0400012484587867
2480:109AF000AFA200148FA600188FA7001C3C0500061B
2481:109B00000C00240334A5F0030800385000000000C6
2482:109B10008EE25240AFA200108EE252443C0400019B
2483:109B200024845884AFA200148EE60E108EE70E181F
2484:109B30000C00240334A5F0028EE201C0244200018F
2485:109B4000AEE201C08EE200008EE301C02403FFBF3D
2486:109B500000431024080037F8AEE200008EE25240C5
2487:109B6000AFA200108EE252443C04000124845884C9
2488:109B7000AFA200148EE60E108EE70E183C0500060C
2489:109B80000C00240334A5F0028EE201C0244200013F
2490:109B9000AEE201C0080037F88EE201C096E2046828
2491:109BA0000053102B544000013C158000126001311D
2492:109BB0003C0C001F358CFFFF8EE2724C8F430280FD
2493:109BC00024420001304207FF10620108000000003B
2494:109BD00012A00014000000008EE352408EE25244B6
2495:109BE0001062000926EE52448EEB52448EE352443A
2496:109BF000000211402442524802E280212463000105
2497:109C000008003712306800FF92E272481440FFC02B
2498:109C10003C0500068EE201E024420001AEE201E0D4
2499:109C20008EE201E08EE30E108EE20E181062FFCB82
2500:109C300026EE0E188EEB0E180000A8218EE30E18EB
2501:109C40000002114024420E2002E280212463000120
2502:109C5000306801FF96E2046A30420010104000179D
2503:109C6000340281009643000C1462001400000000CE
2504:109C70003C02000100571021904283C01440000FA5
2505:109C8000000000009642000EA60200168E42000858
2506:109C90008E4300048E4400002673FFFCAE42000C8D
2507:109CA000AE430008AE4400049602000E26310004C4
2508:109CB0002416000134420200A602000E9603000A98
2509:109CC000026050210073102B1040000202606821D6
2510:109CD000006050212D42003D1040002A0000382134
2511:109CE0009623000C2402080054620027AE110018CD
2512:109CF0003C02000100571021904283C054400022D2
2513:109D0000AE110018262200170182102B10400013FC
2514:109D1000000000003C02FFF5005110219042101796
2515:109D2000384300062C630001384200112C42000128
2516:109D30000062182510600013262200100182102BEB
2517:109D40001040000E000000003C07FFF500F1382134
2518:109D500094E710100800375E24E7000E92220017E7
2519:109D6000384300062C630001384200112C420001E8
2520:109D70000062182550600004AE11001896270010EC
2521:109D800024E7000EAE1100183C020001005710211C
2522:109D9000904283C00002102B14E0000200024EC06B
2523:109DA000014038218F83012027623800246600207B
2524:109DB00000C2102B50400001276630008F8201281E
2525:109DC00010C20004000000008F82012414C20007AA
2526:109DD0002402000B8EE201A400004821244200016D
2527:109DE000AEE201A4080037BF8EE201A48E04000099
2528:109DF0008E050004AC62001801751025004910257D
2529:109E0000AC710008A467000EAC62001CAC640000DA
2530:109E1000AC6500048EE204C0AC620010AF86012085
2531:109E200092E24E2014400038240900018EE24E30A8
2532:109E3000000210C02442503802E220218C8300002E
2533:109E40002402000714620020000000008EE34E3060
2534:109E50008EE24E341062001C000000008C82000470
2535:109E600024420001AC8200048EE34E348EE54E3075
2536:109E7000240200402463000110620007000000007B
2537:109E80008EE24E342442000110A2000500000000C2
2538:109E9000080037A90000000014A000050000000021
2539:109EA0008F82012824420020AF8201288F8201285E
2540:109EB0008C8200042C42001150400013AC80000042
2541:109EC000080037BF000000008EE24E30240300403F
2542:109ED0002442000150430003000010218EE24E3066
2543:109EE00024420001AEE24E308EE24E30000210C03D
2544:109EF0002442503802E2202124020007AC820000F4
2545:109F000024020001AC820004152000183C05000664
2546:109F10008E0200183C04000124845890AFA2001067
2547:109F20008E0200008E03000434A5F00902003021E7
2548:109F30000C002403AFA3001432C200FF1040002B1A
2549:109F4000340281008E4300048E4400088E45000CCC
2550:109F5000A642000CAE430000AE440004AE4500082B
2551:109F600096020016080037F8A642000E154D000AAA
2552:109F7000000000009602000EA613000A34420004FE
2553:109F8000A602000E3C01000100370821A02083C07A
2554:109F9000080037F6000098219604000A0093102B61
2555:109FA00010400002026018210080182124020001E4
2556:109FB000A603000A3C01000100370821A02283C04B
2557:109FC0009604000A022488210191102B10400003FE
2558:109FD0003C02FFF5344210000222882102649823DB
2559:109FE0000000A8211660FEF4ADC800001260002138
2560:109FF00032C200FF3C01000100370821AC3383C4AA
2561:10A000003C01000100370821AC3183C83C0100014C
2562:10A010000037082110400008AC3283CC3C0200011C
2563:10A02000005710218C4283CC244200043C010001E3
2564:10A0300000370821AC2283CC8EE2724C8F43028021
2565:10A040002442000114620006000000008EE201C4F8
2566:10A0500024420001AEE201C4080038508EE201C47F
2567:10A060008EE201BC24420001AEE201BC080038507F
2568:10A070008EE201BC97A4001E2484FFFC00801821FE
2569:10A080008EE400C08EE500C40000102100A328214A
2570:10A0900000A3302B00822021008620212402000210
2571:10A0A000AEE400C0AEE500C41282000F2A820003B5
2572:10A0B000144000172402000316820015000000005F
2573:10A0C0008EE200D08EE300D4246300012C640001F2
2574:10A0D00000441021AEE200D0AEE300D48EE200D006
2575:10A0E0000800384A8EE300D48EE200D88EE300DC0C
2576:10A0F000246300012C64000100441021AEE200D86A
2577:10A10000AEE300DC8EE200D80800384A8EE300DCC3
2578:10A110008EE200C88EE300CC246300012C640001B1
2579:10A1200000441021AEE200C8AEE300CC8EE200C8CD
2580:10A130008EE300CC8F8300E48F8200E01062000386
2581:10A1400024630008AF8300E4AF8300E88FBF004CB6
2582:10A150008FB600488FB500448FB400408FB3003CE9
2583:10A160008FB200388FB100348FB0003003E00008A8
2584:10A1700027BD005027BDFF90AFB600600000B021A2
2585:10A18000AFBF0068AFBE0064AFB5005CAFB40058AD
2586:10A19000AFB30054AFB20050AFB1004CAFB0004805
2587:10A1A0008EE204D400008821241500013042000111
2588:10A1B0001440002AA3A0002F8F8700E08F8800C4DE
2589:10A1C0008F8200E800E220232C8210005040000122
2590:10A1D00024841000000420C2008018218EE400C8EE
2591:10A1E0008EE500CC0000102100A3282100A3302B15
2592:10A1F0000082202100862021AEE400C8AEE500CC1C
2593:10A200008F8300C83C02000A3442EFFF0103202381
2594:10A210000044102B104000033C02000A3442F000BE
2595:10A2200000822021008018218EE400C08EE500C449
2596:10A230000000102100A3282100A3302B0082202140
2597:10A2400000862021AEE400C0AEE500C4AF8800C89F
2598:10A25000AF8700E408003C5BAF8700E83C020001E8
2599:10A2600000571021904283C01040000B00000000F6
2600:10A270003C130001027798218E7383C43C100001C7
2601:10A28000021780218E1083C83C12000102579021D2
2602:10A2900008003A598E5283CC8F8300E08F8200E40D
2603:10A2A00010430007000038218F8200E424070001DA
2604:10A2B0008C4300008C440004AFA30018AFA4001C22
2605:10A2C00014E0000E3C02FFFF8F8200C4AFA200101A
2606:10A2D0008F8200C83C040001248458B4AFA200144B
2607:10A2E0008F8600E08F8700E43C0500060C00240305
2608:10A2F00034A5F20008003C5B000000008FA3001CA6
2609:10A300008FB200183073FFFF2673FFFC0062102429
2610:10A3100010400058024080213C020080006210245E
2611:10A320001040000A3C0400408EE2007C2442000100
2612:10A33000AEE2007C8EE2007C8EE201FC2442000151
2613:10A34000AEE201FC08003C558EE201FC3C06000434
2614:10A350003C0B00013C0A00023C0500103C090008CF
2615:10A360008EE200803C080020340780002442000177
2616:10A37000AEE200808EE200808FA2001C0044182410
2617:10A380001066002100C3102B1440000700000000DD
2618:10A39000106B001100000000106A001500000000A2
2619:10A3A00008003916000420421065002300A3102B7A
2620:10A3B00014400005000000001069001900000000B2
2621:10A3C0000800391600042042106800210000000037
2622:10A3D00008003916000420428EE2003424420001B5
2623:10A3E000AEE200348EE20034080039160004204248
2624:10A3F0008EE201EC24420001AEE201EC8EE201ECBF
2625:10A4000008003916000420428EE201F024420001C7
2626:10A41000AEE201F08EE201F008003916000420429D
2627:10A420008EE201F424420001AEE201F48EE201F476
2628:10A4300008003916000420428EE200302442000158
2629:10A44000AEE200308EE200300800391600042042EF
2630:10A450008EE201F824420001AEE201F88EE201F83A
2631:10A46000000420421087033E00000000080038DB93
2632:10A47000000000003C02000100571021904283B20E
2633:10A4800014400084240200013C03000100771821DD
2634:10A49000906383B31462007F3C0201008E4300008E
2635:10A4A000006210241040006F2402FFFF14620005B8
2636:10A4B00024110001964300043402FFFF106200756E
2637:10A4C0000000000092E204D8144000720000000076
2638:10A4D0003C020001005710218C4283B42842000541
2639:10A4E00010400020000038213C02000100571021DC
2640:10A4F0008C4283B418400016000028219606000004
2641:10A50000000520C0009710219442777E1446000970
2642:10A510000097102194437780960200021462000590
2643:10A52000009710219443778296020004506200083D
2644:10A53000240700013C020001005710218C4283B423
2645:10A5400024A5000100A2102A5440FFEE000520C0FF
2646:10A5500030E200FF1040030200000000080039A2B2
2647:10A5600000000000024020210C0022FE240500060D
2648:10A570003044001F000428C002E510219442727C80
2649:10A5800030424000144002F600B710219443727E1E
2650:10A59000960200001462000B000418C000B71021DE
2651:10A5A000944372809602000214620006000418C0F0
2652:10A5B00000B71021944372829602000410620035A5
2653:10A5C000000418C002E310219442727C30428000E3
2654:10A5D000144002E302E31021944D727C96070000C0
2655:10A5E000000D28C000B710219442737E0800398402
2656:10A5F00000003021000420C002E410219443737C49
2657:10A6000002E41021944D737C3063800014600010CC
2658:10A61000000D28C000B710219442737E1447FFF547
2659:10A6200001A0202100B710219443738096020002FC
2660:10A630005462FFF1000420C000B7102194437382DC
2661:10A64000960200045462FFEC000420C024060001BE
2662:10A6500030C200FF104002C200000000080039A212
2663:10A66000000000009743020296420000146202BC00
2664:10A67000000000009743020496420002146202B8F0
2665:10A68000000000009743020696420004146202B4E0
2666:10A6900000000000924200003A2300013042000115
2667:10A6A00000431024104000742402FFFF8E030000BA
2668:10A6B000146200043402FFFF960300041062006F6E
2669:10A6C000241500023C02000100571021904283B281
2670:10A6D0001440006A2415000392E204D81440006775
2671:10A6E000000000003C020001005710218C4283B49E
2672:10A6F0002842000510400020000038213C020001E3
2673:10A70000005710218C4283B4184000160000282105
2674:10A7100096060000000520C0009710219442777E25
2675:10A720001446000900971021944377809602000296
2676:10A73000146200050097102194437782960200046A
2677:10A7400050620008240700013C020001005710215C
2678:10A750008C4283B424A5000100A2102A5440FFEECD
2679:10A76000000520C030E200FF14400044241500031F
2680:10A7700008003C5500000000024020210C0022FE91
2681:10A78000240500063044001F000428C002E5102103
2682:10A790009442727C304240001440027100B7102194
2683:10A7A0009443727E960200001462000B000418C0ED
2684:10A7B00000B71021944372809602000214620006D2
2685:10A7C000000418C000B7102194437282960200045E
2686:10A7D00010620027000418C002E310219442727C2A
2687:10A7E000304280001440025E02E31021944D727CDE
2688:10A7F00096070000000D28C000B710219442737E18
2689:10A8000008003A0900003021000420C002E41021B1
2690:10A810009443737C02E41021944D737C3063800078
2691:10A8200014600010000D28C000B710219442737E00
2692:10A830001447FFF501A0202100B710219443738035
2693:10A84000960200025462FFF1000420C000B71021FC
2694:10A8500094437382960200045462FFEC000420C00B
2695:10A860002406000130C200FF1040023D000000003D
2696:10A8700008003A1C24150003241500018F420260D1
2697:10A880000053102B10400036000000008F8300E4BE
2698:10A890008F8200E01062000324630008AF8300E4AD
2699:10A8A000AF8300E88EE400C08EE500C4026018218A
2700:10A8B0000000102100A3282100A3302B00822021BA
2701:10A8C00000862021AEE400C0AEE500C48EE2005850
2702:10A8D00024420001AEE200588EE200588EE2007C75
2703:10A8E00024420001AEE2007C8EE2007C8F8200E018
2704:10A8F000AFA200108F8200E43C040001248458C001
2705:10A90000AFA200148FA600188FA7001C3C050006FC
2706:10A910000C00240334A5F20308003C5B0000000097
2707:10A920008EE25240AFA200108EE252443C0400017D
2708:10A93000248458CCAFA200148EE60E108EE70E18B9
2709:10A940003C0500060C00240334A5F2028EE201C08F
2710:10A9500024420001AEE201C008003C028EE201C0C8
2711:10A9600096E204680053102B544000013C1680000E
2712:10A97000126001CB3C0E001F35CEFFFF3C0FFFF5F0
2713:10A9800035EF1000241E00408EE2724C8F4302808F
2714:10A9900024420001304207FF1062019E00000000C7
2715:10A9A00012C00012000000008EE352408EE25244BA
2716:10A9B0001062000A26F852448EF45244AFB80024C4
2717:10A9C0008EE35244000211402442524802E28821A0
2718:10A9D0002463000108003A85306D00FF8EE201E03B
2719:10A9E00024420001AEE201E08EE201E08EE30E10AF
2720:10A9F0008EE20E181062FFCA26F80E188EF40E189A
2721:10AA00000000B021AFB800248EE30E180002114000
2722:10AA100024420E2002E2882124630001306D01FFF0
2723:10AA200096E2046A3042001010400018340281009F
2724:10AA30009643000C14620015000000003C02000167
2725:10AA400000571021904283C0144000100000000005
2726:10AA50009642000EA62200168E4200088E43000485
2727:10AA60008E4400002673FFFCAE42000CAE4300088B
2728:10AA7000AE4400049622000E2610000424180001A3
2729:10AA8000A3B8002F34420200A622000E8E2200003E
2730:10AA90008E2300043C04000134843800020030217D
2731:10AAA000306A0007020A8023036410210202102B7F
2732:10AAB00010400005026A9821020410230362182343
2733:10AAC0003C02002000438023266200079623000AF0
2734:10AAD0002418FFF80058C824006A18210079102BA8
2735:10AAE00010400002032060210060602101801821D5
2736:10AAF000246200072418FFF800586024026C102B11
2737:10AB000014400004019328230183282308003AC33A
2738:10AB100000C3102100D31021004A202301C4102BB0
2739:10AB200054400001008F202125420040004C102B92
2740:10AB3000144000350000582194C3000C2402080082
2741:10AB400054620032AE2600183C020001005710216A
2742:10AB5000904283C05440002DAE26001824C2001736
2743:10AB600001C2102B10400013000000003C02FFF552
2744:10AB70000046102190421017384300062C63000154
2745:10AB8000384200112C4200010062182510600014A8
2746:10AB900024C2001001C2102B1040000E0000000063
2747:10ABA0003C0BFFF501665821956B101008003AF434
2748:10ABB0002562000E90C20017384300062C63000186
2749:10ABC000384200112C420001006218251060000577
2750:10ABD0000160182194CB00102562000E004A582114
2751:10ABE00001601821246200072418FFF80058582437
2752:10ABF00000C31021004A202301C4102B1040000282
2753:10AC000001632823008F2021AE2600183C0200019A
2754:10AC100000571021904283C00002102B000216C082
2755:10AC200015600002AFA2004401805821308200016B
2756:10AC3000104000070000402190880000248400019B
2757:10AC400001C4102B1040000224A5FFFF008F20211B
2758:10AC500050A0001200081C022CA20002544000095F
2759:10AC600024A5FFFF948200002484000201024021F9
2760:10AC700001C4102B1040000624A5FFFE08003B2154
2761:10AC8000008F20219082000000021200010240216A
2762:10AC900014A0FFF22CA2000200081C023102FFFFE8
2763:10ACA000006240213108FFFF0140282111400011BE
2764:10ACB000020020212CA200025440000924A5FFFF1D
2765:10ACC00094820000248400020102402101C4102B60
2766:10ACD0001040000624A5FFFE08003B38008F20210D
2767:10ACE00090820000000212000102402114A0FFF235
2768:10ACF0002CA2000200081C023102FFFF006240216A
2769:10AD000000081C023102FFFF8F89012000624021F0
2770:10AD100027623800252300200062102B1440000217
2771:10AD20003108FFFF276330008F8201281062000482
2772:10AD3000000000008F8201241462000701402821D6
2773:10AD40008EE201A40000382124420001AEE201A4F9
2774:10AD500008003BC98EE201A48E2600008E27000465
2775:10AD6000000814003448000BAD300008A52B000E7D
2776:10AD7000AD2800188FB8004400002021029610254D
2777:10AD800000581025AD22001C00E5102B00E53823EB
2778:10AD900000C4302300C23023AD260000AD270004DC
2779:10ADA0008EE204C0AD220010AF83012092E24E205B
2780:10ADB0001440005F240700012502FFEE2C42000230
2781:10ADC00014400003240200111502002400000000BA
2782:10ADD0008EE24E30000210C02442503802E22021A0
2783:10ADE0008C830000240200121462000F0000000097
2784:10ADF0008EE34E308EE24E341062000B00000000F5
2785:10AE00008C82000424420001AC8200048EE24E34A5
2786:10AE10008EE34E3024420001105E002A0000000044
2787:10AE200008003BA8000000008EE24E3024420001E2
2788:10AE3000505E0003000010218EE24E3024420001DB
2789:10AE4000AEE24E308EE24E30000210C02442503846
2790:10AE500002E2202108003BC6240200128EE24E309E
2791:10AE6000000210C02442503802E220218C830000EE
2792:10AE7000240200071462001F000000008EE34E3021
2793:10AE80008EE24E341062001B000000008C82000431
2794:10AE900024420001AC8200048EE24E348EE34E3038
2795:10AEA00024420001105E0007000000008EE24E34D4
2796:10AEB00024420001106200050000000008003BB4BD
2797:10AEC0000000000014600005000000008F820128CF
2798:10AED00024420020AF8201288F8201288C82000446
2799:10AEE0002C42001150400012AC80000008003BC909
2800:10AEF000000000008EE24E3024420001505E00034C
2801:10AF0000000010218EE24E3024420001AEE24E30AD
2802:10AF10008EE24E30000210C02442503802E220215E
2803:10AF200024020007AC82000024020001AC8200046D
2804:10AF300014E000193C0500063C04000124845890EC
2805:10AF40008E22001834A5F209AFA200108E22000054
2806:10AF50008E23000402203021016038210C002403DC
2807:10AF6000AFA3001493A2002F1040002A34028100E6
2808:10AF70008E4300048E4400088E45000CA642000C4F
2809:10AF8000AE430000AE440004AE4500089622001611
2810:10AF900008003C02A642000E1599000A026A182316
2811:10AFA0009622000EA623000A34420004A622000EB8
2812:10AFB0003C01000100370821A02083C008003BFFAE
2813:10AFC000000098219624000A0083102B54400001B1
2814:10AFD0000080182124020001A623000A3C01000180
2815:10AFE00000370821A02283C09622000A004A1821B7
2816:10AFF0000203802101D0102B54400001020F802158
2817:10B00000026398230000B0218FB800241660FE5E12
2818:10B01000AF0D000012600022000000003C010001A2
2819:10B0200000370821AC3383C43C01000100370821FC
2820:10B03000AC3083C83C01000100370821AC3283CC1E
2821:10B0400093A2002F10400008000000003C02000105
2822:10B05000005710218C4283CC244200043C010001A3
2823:10B0600000370821AC2283CC8F4302808EE2724CE1
2824:10B0700014620006000000008EE201C424420001B8
2825:10B08000AEE201C408003C5B8EE201C48EE201BC6A
2826:10B0900024420001AEE201BC08003C5B8EE201BC30
2827:10B0A00097A4001E2484FFFC008018218EE400C0B9
2828:10B0B0008EE500C40000102100A3282100A3302B3E
2829:10B0C000008220210086202124020002AEE400C07C
2830:10B0D000AEE500C412A2000F2AA20003144000171C
2831:10B0E0002402000316A20015000000008EE200D02A
2832:10B0F0008EE300D4246300012C640001004410217D
2833:10B10000AEE200D0AEE300D48EE200D008003C55A1
2834:10B110008EE300D48EE200D88EE300DC24630001CD
2835:10B120002C64000100441021AEE200D8AEE300DC44
2836:10B130008EE200D808003C558EE300DC8EE200C8A9
2837:10B140008EE300CC246300012C6400010044102134
2838:10B15000AEE200C8AEE300CC8EE200C88EE300CCC5
2839:10B160008F8300E48F8200E01062000324630008F4
2840:10B17000AF8300E4AF8300E88FBF00688FBE006438
2841:10B180008FB600608FB5005C8FB400588FB3005449
2842:10B190008FB200508FB1004C8FB0004803E0000820
2843:10B1A00027BD007027BDFFE0AFBF00188EE30E146F
2844:10B1B0008EE20E0C10620074000000008EE30E0C94
2845:10B1C0008EE20E1400622023048200012484020017
2846:10B1D0008EE30E188EE20E140043102B1440000470
2847:10B1E000240202008EE30E1408003C7D0043182365
2848:10B1F0008EE20E188EE30E14004310232443FFFF4B
2849:10B20000008048210069102A544000010060482154
2850:10B210008F8701002762300024E800200102102BF4
2851:10B2200050400001276828008F82010811020004A5
2852:10B23000000000008F8201041502000700001021A9
2853:10B240008EE201A80000202124420001AEE201A804
2854:10B2500008003CBF8EE201A88EE40E1400042140D9
2855:10B26000008018218EE404608EE5046400A3282188
2856:10B2700000A3302B0082202100862021ACE40000B6
2857:10B28000ACE500048EE30E1400091140A4E2000EA8
2858:10B2900024020002ACE200180003194024630E20CF
2859:10B2A00002E31021ACE200088EE20E14ACE2001CB6
2860:10B2B0008EE204CCACE20010AF88010092E204EC14
2861:10B2C00014400011240400018EE24E2824030040A3
2862:10B2D0002442000150430003000010218EE24E285A
2863:10B2E00024420001AEE24E288EE24E28000210C039
2864:10B2F00024424E3802E2182124020002AC6200000F
2865:10B3000024020001AC6200041480000E24030040FB
2866:10B310008EE20E14AFA200108EE20E183C0500075C
2867:10B32000AFA200148EE60E0C8EE70E103C04000156
2868:10B33000248458D40C00240334A5F00108003CDD1B
2869:10B34000000000008EE2050024420001504300038B
2870:10B35000000010218EE2050024420001AEE205004B
2871:10B360008EE205000002108000571021AC4905084C
2872:10B370008EE20E1400491021304201FFAEE20E149D
2873:10B380008EE30E148EE20E0C146200050000000025
2874:10B390008F8200602403FDFF00431024AF82006011
2875:10B3A0008FBF001803E0000827BD002027BDFFE085
2876:10B3B000AFBF00188EE3523C8EE252381062007428
2877:10B3C000000000008EE352388EE2523C00622023DF
2878:10B3D00004820001248401008EE352448EE2523C38
2879:10B3E0000043102B14400004240201008EE3523C61
2880:10B3F00008003CFF004318238EE252448EE3523C87
2881:10B40000004310232443FFFF008048210069102AD5
2882:10B4100054400001006048218F87010027623000FE
2883:10B4200024E800200102102B50400001276828006A
2884:10B430008F82010811020004000000008F820104C5
2885:10B4400015020007000010218EE201A80000202153
2886:10B4500024420001AEE201A808003D418EE201A8AD
2887:10B460008EE4523C00042140008018218EE40470D8
2888:10B470008EE5047400A3282100A3302B0082202134
2889:10B4800000862021ACE40000ACE500048EE3523CD1
2890:10B4900000091140A4E2000E24020003ACE20018EF
2891:10B4A000000319402463524802E31021ACE2000873
2892:10B4B0008EE2523CACE2001C8EE204CCACE2001006
2893:10B4C000AF88010092E204EC144000112404000152
2894:10B4D0008EE24E2824030040244200015043000322
2895:10B4E000000010218EE24E2824420001AEE24E28D8
2896:10B4F0008EE24E28000210C024424E3802E218218B
2897:10B5000024020003AC62000024020001AC620004CB
2898:10B510001480000E240300408EE2523CAFA20010C3
2899:10B520008EE252443C050007AFA200148EE652386A
2900:10B530008EE752403C040001248458E00C002403B0
2901:10B5400034A5F01008003D5F000000008EE2050009
2902:10B550002442000150430003000010218EE2050048
2903:10B5600024420001AEE205008EE2050000021080D8
2904:10B5700000571021AC4905088EE2523C00491021C9
2905:10B58000304200FFAEE2523C8EE3523C8EE2523833
2906:10B5900014620005000000008F8200602403FEFF9B
2907:10B5A00000431024AF8200608FBF001803E0000842
2908:10B5B00027BD00208F8201208EE34E348F8201242C
2909:10B5C0008F8601282402004024630001506200039A
2910:10B5D000000010218EE24E3424420001AEE24E34CF
2911:10B5E0008EE24E348EE44E348EE34E30000210C0B4
2912:10B5F000244250381483000702E228218F82012858
2913:10B6000024420020AF8201288F82012808003D9249
2914:10B61000ACA000008EE24E3424030040244200011E
2915:10B6200050430003000010218EE24E3424420001FA
2916:10B63000000210C02442503802E228218CA20004EB
2917:10B640008F8301280002114000621821AF83012876
2918:10B65000ACA000008CC200182443FFFE2C62001234
2919:10B6600010400008000310803C0100010022082166
2920:10B670008C2258F000400008000000002402000165
2921:10B68000AEE24E2403E000080000000027BDFFC822
2922:10B69000AFBF0030AFB5002CAFB40028AFB300246B
2923:10B6A000AFB20020AFB1001CAFB000188F830128EB
2924:10B6B0008F820124106202B0000098213C11001F0B
2925:10B6C0003631FFFF3C12FFF53652100024150012F0
2926:10B6D000241400408F8C01288F82012824420020EE
2927:10B6E000AF8201289182001B8F8301282443FFFE33
2928:10B6F0002C6200121040029C000310803C010001EB
2929:10B70000002208218C225948004000080000000057
2930:10B710008F42021830420100104000070000000074
2931:10B720009583001695820018006218230003140206
2932:10B7300000431021A58200168D82001C3C0380006E
2933:10B740003044FFFF004368243C03080000431824F2
2934:10B7500011A00004AD84001C0004114008003DD875
2935:10B76000244252480004114024420E2002E2582193
2936:10B770009562000E3042FFFC10600004A562000ECE
2937:10B780009584001608003EC0000000008D69001876
2938:10B7900000004021952A000025290002952700007D
2939:10B7A0002529000295260000252900029525000084
2940:10B7B0002529000295240000252900029523000078
2941:10B7C0002529000295220000252900020147502169
2942:10B7D000014650210145502101445021014350218F
2943:10B7E00001425021000A1C023142FFFF0062502139
2944:10B7F000000A1C023142FFFF0062502196E2046AF7
2945:10B80000314EFFFF30420002104000440000502142
2946:10B81000252200140222102B1040001401201821B0
2947:10B820002405000A000020210223102B54400001AF
2948:10B8300000721821946200002463000224A5FFFF17
2949:10B8400014A0FFF90082202100041C023082FFFFB7
2950:10B8500000622021000414023083FFFF0043102106
2951:10B860003042FFFF08003E3301425021952A00007C
2952:10B8700025290002952800002529000295270000AF
2953:10B8800025290002952600002529000295250000A3
2954:10B890002529000295230000252900029522000099
2955:10B8A0002529000295240000252900020148502185
2956:10B8B00001475021014650210145502101435021AB
2957:10B8C000014250219522000095230002014450219D
2958:10B8D0000142502101435021000A1C023142FFFF66
2959:10B8E00000625021000A1C023142FFFF0062502119
2960:10B8F0003148FFFF510000013408FFFF8D6200183E
2961:10B900009443000C2402080054620005A56800104E
2962:10B910009562000E34420002A562000EA568001078
2963:10B9200096E2046A000028213042000814400056C4
2964:10B93000000030218D630018246200240222102BA5
2965:10B9400010400034246900100229102B54400001DB
2966:10B950000132482195250000246900140229102B8A
2967:10B960001040000224A5FFEC01324821952200007E
2968:10B9700030420FFF144000032529000208003E60FA
2969:10B98000241300010000982100A030210229102B6F
2970:10B990005440000101324821912200012529000272
2971:10B9A00000A228210229102B544000010132482115
2972:10B9B000252900020229102B5440000101324821A0
2973:10B9C000952200002529000200A228210229102B1F
2974:10B9D000544000010132482195220000252900022F
2975:10B9E00000A228210229102B5440000101324821D5
2976:10B9F000952200002529000200A228210229102BEF
2977:10BA000054400001013248219522000008003E996F
2978:10BA100000A2282194650010946200142469001685
2979:10BA200030420FFF1440000324A5FFEC08003E8CB9
2980:10BA3000241300010000982100A03021912300016F
2981:10BA400025290004952200002529000295240000E4
2982:10BA50002529000200A3282100A228219522000008
2983:10BA60009523000200A4282100A2282100A3282158
2984:10BA700000051C0230A2FFFF0062282100051C0205
2985:10BA800030A2FFFF0062282196E2046A30420001E2
2986:10BA90001040001E0000202195820016004E202339
2987:10BAA0000004140200822021326200FF5040000294
2988:10BAB000008620210085202100041402008220211C
2989:10BAC0003084FFFF508000013404FFFF8D620018B6
2990:10BAD000244300170223102B544000010072182148
2991:10BAE00090620000384300112C63000138420006C8
2992:10BAF0002C420001006218251060000400000000C4
2993:10BB00009562000E34420001A562000E9562000E9F
2994:10BB1000240A00023042000410400002A564001212
2995:10BB2000240A00048F88012027623800250900209C
2996:10BB30000122102B50400001276930008F8201281C
2997:10BB400011220004000000008F820124152200074A
2998:10BB5000240400208EE201A4000080212442000180
2999:10BB6000AEE201A408003F4F8EE201A48EE5724CC4
3000:10BB70008EE604908EE70494AD0B0008A504000E39
3001:10BB8000AD0A00180005294000A01821000010216E
3002:10BB900000E3382100E3202B00C2302100C4302113
3003:10BBA000AD060000AD0700048EE2724C004D10257A
3004:10BBB000AD02001C8EE204C4AD020010AF8901206A
3005:10BBC00092E24E2014400060241000012543FFEE55
3006:10BBD0002C630002394200112C420001006218253A
3007:10BBE00010600024000000008EE24E30000210C001
3008:10BBF0002442503802E220218C8200001455000FAC
3009:10BC0000000000008EE34E308EE24E341062000BD6
3010:10BC1000000000008C82000424420001AC82000479
3011:10BC20008EE24E348EE34E30244200011054002B3D
3012:10BC30000000000008003F2E000000008EE24E30A1
3013:10BC40002442000150540003000010218EE24E30C7
3014:10BC500024420001AEE24E308EE24E30000210C0AF
3015:10BC60002442503802E220212402000108003F4E05
3016:10BC7000AC9500008EE24E30000210C024425038D5
3017:10BC800002E220218C830000240200071462001FBE
3018:10BC9000000000008EE34E308EE24E341062001B36
3019:10BCA000000000008C82000424420001AC820004E9
3020:10BCB0008EE24E348EE34E302442000110540007D1
3021:10BCC000000000008EE24E342442000110620005A4
3022:10BCD0000000000008003F3A00000000146000056A
3023:10BCE000000000008F82012824420020AF8201283A
3024:10BCF0008F8201288C8200042C42001150400012D7
3025:10BD0000AC80000008003F4F000000008EE24E3083
3026:10BD10002442000150540003000010218EE24E30F6
3027:10BD200024420001AEE24E308EE24E30000210C0DE
3028:10BD30002442503802E2202124020007AC82000095
3029:10BD400024020001AC8200041600000D0000000077
3030:10BD50008F8201203C04000124845938AFA00014D4
3031:10BD6000AFA200108D86001C8F8701243C050008BF
3032:10BD70000C00240334A50001080040570000000017
3033:10BD80008EE2724C24420001304207FF11A00006EF
3034:10BD9000AEE2724C8EE201D02442FFFFAEE201D04F
3035:10BDA00008003F6B8EE201D08EE201CC2442FFFFFF
3036:10BDB000AEE201CC8EE201CC8EE201D82442FFFF3C
3037:10BDC000AEE201D8080040578EE201D88F4202400F
3038:10BDD000104000E5000000008EE20E1C244200012D
3039:10BDE00008004057AEE20E1C9582001EAD82001C7A
3040:10BDF0008F42024010400072000000008EE20E1CD4
3041:10BE000024420001AEE20E1C8F4302400043102B7F
3042:10BE1000144000D5000000008F8301202762380005
3043:10BE20002466002000C2102B50400001276630001D
3044:10BE30008F82012810C20004000000008F820124BC
3045:10BE400014C20007000000008EE201A4000080215F
3046:10BE500024420001AEE201A408003FDA8EE201A410
3047:10BE60008EE2724CAC62001C8EE404A88EE504AC39
3048:10BE70002462001CAC62000824020008A462000EC8
3049:10BE800024020011AC620018AC640000AC65000430
3050:10BE90008EE204C4AC620010AF86012092E24E2014
3051:10BEA00014400034241000018EE24E30000210C015
3052:10BEB0002442503802E220218C8200001455001FD9
3053:10BEC000000000008EE34E308EE24E341062001B04
3054:10BED000000000008C82000424420001AC820004B7
3055:10BEE0008EE24E348EE34E3024420001105400079F
3056:10BEF000000000008EE24E34244200011062000572
3057:10BF00000000000008003FC60000000014600005AB
3058:10BF1000000000008F82012824420020AF82012807
3059:10BF20008F8201288C8200042C42001150400011A5
3060:10BF3000AC80000008003FDA000000008EE24E30C6
3061:10BF40002442000150540003000010218EE24E30C4
3062:10BF500024420001AEE24E308EE24E30000210C0AC
3063:10BF60002442503802E2202124020001AC95000056
3064:10BF7000AC8200045600000B241000018EE2724CCB
3065:10BF80003C040001248458A8AFA00014AFA2001004
3066:10BF90008EE6724C8F4702803C0500090C0024039A
3067:10BFA00034A5F00856000001AEE00E1C8EE20188B8
3068:10BFB00024420001AEE20188080040508EE2018870
3069:10BFC0008F830120276238002466002000C2102BD6
3070:10BFD00050400001276630008F82012810C2000403
3071:10BFE000000000008F82012414C20007000000003E
3072:10BFF0008EE201A40000802124420001AEE201A4EF
3073:10C00000080040448EE201A48EE2724CAC62001C37
3074:10C010008EE404A88EE504AC2462001CAC62000827
3075:10C0200024020008A462000E24020011AC62001871
3076:10C03000AC640000AC6500048EE204C4AC62001085
3077:10C04000AF86012092E24E201440003424100001FB
3078:10C050008EE24E30000210C02442503802E220210D
3079:10C060008C8200001455001F000000008EE34E304B
3080:10C070008EE24E341062001B000000008C8200042F
3081:10C0800024420001AC8200048EE24E348EE34E3036
3082:10C090002442000110540007000000008EE24E34DC
3083:10C0A000244200011062000500000000080040303A
3084:10C0B0000000000014600005000000008F820128CD
3085:10C0C00024420020AF8201288F8201288C82000444
3086:10C0D0002C42001150400011AC8000000800404488
3087:10C0E000000000008EE24E30244200015054000354
3088:10C0F000000010218EE24E3024420001AEE24E30AC
3089:10C100008EE24E30000210C02442503802E220215C
3090:10C1100024020001AC950000AC8200041600000B64
3091:10C12000000000008EE2724C3C040001248458A8F8
3092:10C13000AFA00014AFA200108EE6724C8F470280B1
3093:10C140003C0500090C00240334A5F0088EE20174BC
3094:10C1500024420001AEE20174080040578EE20174EF
3095:10C1600024020001AEE24E248F8301288F82012435
3096:10C170001462FD58000000008FBF00308FB5002C06
3097:10C180008FB400288FB300248FB200208FB1001C21
3098:10C190008FB0001803E0000827BD003827BDFFE876
3099:10C1A000278402082745020024060008AFBF0014B8
3100:10C1B0000C00249AAFB000100000202124100001D0
3101:10C1C0002402241FAF900210AF900200AF8002043F
3102:10C1D000AF8202148F460248240300043C02004050
3103:10C1E0003C010001AC235CC43C010001AC235CC8F1
3104:10C1F0003C010001AC205D9C3C010001AC225CC014
3105:10C200003C010001AC235CC80C005108240500046B
3106:10C210000C004822000000008EE200003C03FEFFFC
3107:10C220003463FFFD00431024AEE200003C023C00FA
3108:10C23000AF82021C3C01000100370821AC3083AC06
3109:10C240008FBF00148FB0001003E0000827BD001856
3110:10C2500027BDFFE03C05000834A50400AFBF00186F
3111:10C26000AFA00010AFA000148F8602003C040001B4
3112:10C27000248459F00C002403000038218EE202804F
3113:10C2800024420001AEE202808EE202808F8302002F
3114:10C290003C023F00006218248FBF00183C020400DB
3115:10C2A00003E0000827BD002027BDFFD8AFBF002056
3116:10C2B000AFB1001CAFB000188F9002208EE20214C4
3117:10C2C0000000382124420001AEE202148EE2021482
3118:10C2D0003C02030002021024104000273C1104001D
3119:10C2E0000C00429B000000003C02010002021024EE
3120:10C2F00010400007000000008EE2021824420001F6
3121:10C30000AEE202188EE20218080040C63C03FDFFB0
3122:10C310008EE2021C24420001AEE2021C8EE2021CEC
3123:10C320003C03FDFF3463FFFF3C0808FF3508FFFFB7
3124:10C330008EE200003C040001248459FC3C05000806
3125:10C340000200302100431024AEE200008F82022060
3126:10C35000000038213C03030000481024004310254E
3127:10C36000AF820220AFA000100C002403AFA0001485
3128:10C370000800429600000000021110241040001F27
3129:10C380003C0240008F830224240214021462000B3A
3130:10C390003C03FDFF3C04000124845A083C050008CE
3131:10C3A000AFA00010AFA000148F86022434A5FFFFB9
3132:10C3B0000C002403000038213C03FDFF8EE2000046
3133:10C3C0003463FFFF02002021004310240C004E5470
3134:10C3D000AEE200008EE2022024420001AEE2022022
3135:10C3E0008EE202208F8202203C0308FF3463FFFFAD
3136:10C3F0000043102408004295005110250202102429
3137:10C4000010400142000000008EE2022C2442000194
3138:10C41000AEE2022C8EE2022C8F8202203C0308FF47
3139:10C420003463FFFF0043102434420004AF82022033
3140:10C430008F8300548F8200540800410E2463000251
3141:10C440008F820054006210232C4200031440FFFC32
3142:10C45000000000008F8600E08F8400E430C20007F7
3143:10C4600010400012000000008F8300E42402FFF857
3144:10C4700000C210241043000D000000008F82005401
3145:10C480008F8300E014C30009244400508F820054BD
3146:10C49000008210232C4200511040000400000000D4
3147:10C4A0008F8200E010C2FFF9000000008F8202209E
3148:10C4B0003C0308FF3463FFFD00431024AF820220D9
3149:10C4C0008F8600E030C20007104000032402FFF80E
3150:10C4D00000C23024AF8600E08F8300C43C02001FFE
3151:10C4E0003442FFFF246800080048102B104000036E
3152:10C4F0003C02FFF534421000010240218F8B00C83E
3153:10C500008F8501208F8401240800414500006021AF
3154:10C51000276238000082102B504000012764300051
3155:10C5200010A40010318200FF8C82001838430007ED
3156:10C530002C6300013842000B2C42000100621825D8
3157:10C540005060FFF3248400208EE20240240C00019E
3158:10C5500024420001AEE202408EE202408C8B0008D1
3159:10C56000318200FF14400065000000003C02000121
3160:10C5700000571021904283C014400060000000006A
3161:10C580008F8400E400C41023000218C30462000179
3162:10C59000246302008F8900C410600005240200019A
3163:10C5A0001062000900000000080041870000000040
3164:10C5B0008EE202300120582124420001AEE2023016
3165:10C5C000080041BC8EE202308EE202343C05000AD3
3166:10C5D00024420001AEE202348C8B000034A5F0004E
3167:10C5E0008EE20234012B182300A3102B54400001CB
3168:10C5F000006518212C62233F144000400000000019
3169:10C600008F8200E824420008AF8200E88F8200E8B1
3170:10C610008F8200E40120582124420008AF8200E408
3171:10C62000080041BC8F8200E48EE202383C03000A1D
3172:10C6300024420001AEE202388C8400003463F00032
3173:10C640008EE20238008838230067102B5440000126
3174:10C6500000E338213C02000334420D400047102B18
3175:10C660001040000300000000080041BC0080582179
3176:10C670008F8200E424440008AF8400E48F8400E447
3177:10C68000108600183C05000A34A5F0003C0A00039F
3178:10C69000354A0D408EE2007C24420001AEE2007C6F
3179:10C6A0008C8300008EE2007C0068382300A7102BEA
3180:10C6B0005440000100E538210147102B5440000789
3181:10C6C000006058218F8200E424440008AF8400E415
3182:10C6D0008F8400E41486FFEF00000000148600053C
3183:10C6E0000000000001205821AF8600E4080041BC92
3184:10C6F000AF8600E8AF8400E4AF8400E88F8200C812
3185:10C700003C03000A3463F000004838230067102B14
3186:10C710005440000100E338213C02000334420D3F45
3187:10C720000047102B544000070000602101683823A7
3188:10C730000067102B5440000300E33821080041CF6C
3189:10C740003C0200033C02000334420D3F0047102B23
3190:10C7500014400016318200FF144000060000000063
3191:10C760003C02000100571021904283C01040000F8E
3192:10C77000000000008EE2023C3C04FDFF8EE300005E
3193:10C780003484FFFF24420001AEE2023C8EE2023C10
3194:10C7900024020001006418243C0100010037082134
3195:10C7A000A02283B80800422CAEE30000AF8B00C883
3196:10C7B0008F8300C88F8200C43C04000A3484F000D8
3197:10C7C000006238230087102B5440000100E4382118
3198:10C7D0003C02000334420D400047102B2CE30001C3
3199:10C7E0000043102510400008000000008F82022046
3200:10C7F0003C0308FF3463FFFF004310243C03400068
3201:10C8000000431025AF8202208F8600E08F8400E471
3202:10C8100010C4002A000000008EE2007C24420001C7
3203:10C82000AEE2007C8EE2007C24C2FFF8AF8200E022
3204:10C830003C0200018C427E303C0300088F8600E001
3205:10C84000004310241040001D0000000010C4001B15
3206:10C85000240DFFF83C0A000A354AF0003C0C008029
3207:10C86000248500082762280050A2000127651800CF
3208:10C870008C8800048C8200008CA900003103FFFF2B
3209:10C8800000431021004D102424430010006B102B96
3210:10C8900054400001006A1821012B102B5440000164
3211:10C8A000012A482110690002010C1025AC82000405
3212:10C8B00000A0202114C4FFEB248500088F820220F1
3213:10C8C0003C0308FF3463FFFF00431024344200029E
3214:10C8D000AF8202208F8300548F82005408004237B9
3215:10C8E000246300018F820054006210232C42000256
3216:10C8F0001440FFFC000000008F8202203C0308FF70
3217:10C900003463FFFB00431024AF8202200601005570
3218:10C91000000000008EE2022824420001AEE202285C
3219:10C920008EE202288F8202203C0308FF3463FFFF5F
3220:10C930000043102434420004AF8202208F8300544D
3221:10C940008F82005408004251246300028F820054F9
3222:10C95000006210232C4200031440FFFC0000000082
3223:10C960008F8600E030C20007104000120000000077
3224:10C970008F8300E42402FFF800C210241043000D4E
3225:10C98000000000008F8200548F8300E014C3000970
3226:10C99000244400328F820054008210232C42003342
3227:10C9A00010400004000000008F8200E010C2FFF978
3228:10C9B000000000008F8202203C0308FF3463FFFD6B
3229:10C9C00000431024AF8202208F8600E030C20007AF
3230:10C9D000104000032402FFF800C23024AF8600E0BC
3231:10C9E000240301F58F8200E800673823000718C090
3232:10C9F00000431021AF8200E88F8200E8AF8200E49C
3233:10CA00008EE2007C3C0408FF3484FFFF00471021C5
3234:10CA1000AEE2007C8F8202203C038000346300027F
3235:10CA20000044102400431025AF8202208F8300545D
3236:10CA30008F8200540800428D246300018F820054CD
3237:10CA4000006210232C4200021440FFFC0000000092
3238:10CA50008F8202203C0308FF3463FFFB0043102455
3239:10CA6000AF8202208FBF00208FB1001C8FB0001852
3240:10CA700003E0000827BD00283C0200018C425CD87E
3241:10CA800027BDFFD810400012AFBF00203C040001BA
3242:10CA900024845A143C050008240200013C010001D2
3243:10CAA00000370821AC2283ACAFA00010AFA0001467
3244:10CAB0008F86022034A504983C010001AC205CD88C
3245:10CAC0003C010001AC225CCC0C00240300003821A6
3246:10CAD0008F4202683C037FFF3463FFFF0043102452
3247:10CAE000AF4202688EE204D08EE404D42403FFFE39
3248:10CAF00000431024308400021080011EAEE204D0F6
3249:10CB00008EE204D42403FFFD00431024AEE204D4DB
3250:10CB10008F8200443C03060034632000344200202E
3251:10CB2000AF820044AFA300188EE206088F430228AC
3252:10CB300024420001304A00FF514300FEAFA0001024
3253:10CB40008EE20608000210C0005710218FA30018C3
3254:10CB50008FA4001CAC43060CAC4406108F83005419
3255:10CB60008F82005424690032012210232C420033AA
3256:10CB70001040006A0000582124180008240F000DFE
3257:10CB8000240D0007240C0040240E00018F87012093
3258:10CB90002762380024E800200102102B50400001D9
3259:10CBA000276830008F820128110200040000000075
3260:10CBB0008F82012415020007000010218EE201A4DB
3261:10CBC0000000282124420001AEE201A40800433DF8
3262:10CBD0008EE201A48EE40608000420C00080182123
3263:10CBE0008EE404308EE5043400A3282100A3302B0A
3264:10CBF0000082202100862021ACE40000ACE5000486
3265:10CC00008EE20608A4F8000EACEF0018ACEA001C97
3266:10CC1000000210C02442060C02E21021ACE200081F
3267:10CC20008EE204C4ACE20010AF88012092E24E20F4
3268:10CC300014400033240500018EE24E30000210C083
3269:10CC40002442503802E220218C820000144D001F43
3270:10CC5000000000008EE34E308EE24E341062001B66
3271:10CC6000000000008C82000424420001AC82000419
3272:10CC70008EE24E348EE34E3024420001104C000709
3273:10CC8000000000008EE24E342442000110620005D4
3274:10CC9000000000000800432A0000000014600005A6
3275:10CCA000000000008F82012824420020AF8201286A
3276:10CCB0008F8201288C8200042C4200115040001009
3277:10CCC000AC8000000800433D000000008EE24E30C2
3278:10CCD00024420001504C0003000010218EE24E302F
3279:10CCE00024420001AEE24E308EE24E30000210C00F
3280:10CCF0002442503802E22021AC8D0000AC8E0004AA
3281:10CD000054A00006240B00018F820054012210233E
3282:10CD10002C4200331440FF9D00000000316300FFEF
3283:10CD20002402000154620079AFA00010AEEA0608A8
3284:10CD30008F8300548F820054246900320122102313
3285:10CD40002C4200331040006100005821240D0008DF
3286:10CD5000240C00112408001224070040240A0001BA
3287:10CD60008F830120276238002466002000C2102B28
3288:10CD700050400001276630008F82012810C2000455
3289:10CD8000000000008F82012414C200070000000090
3290:10CD90008EE201A40000282124420001AEE201A499
3291:10CDA000080043A98EE201A48EE20608AC62001CD2
3292:10CDB0008EE404A08EE504A42462001CAC6200088A
3293:10CDC000A46D000EAC6C0018AC640000AC650004EF
3294:10CDD0008EE204C4AC620010AF86012092E24E20C5
3295:10CDE00014400033240500018EE24E30000210C0D2
3296:10CDF0002442503802E220218C8200001448001F97
3297:10CE0000000000008EE34E308EE24E341062001BB4
3298:10CE1000000000008C82000424420001AC82000467
3299:10CE20008EE24E348EE34E3024420001104700075C
3300:10CE3000000000008EE24E34244200011062000522
3301:10CE40000000000008004396000000001460000588
3302:10CE5000000000008F82012824420020AF820128B8
3303:10CE60008F8201288C8200042C4200115040001057
3304:10CE7000AC800000080043A9000000008EE24E30A4
3305:10CE80002442000150470003000010218EE24E3082
3306:10CE900024420001AEE24E308EE24E30000210C05D
3307:10CEA0002442503802E22021AC880000AC8A000401
3308:10CEB00054A00006240B00018F820054012210238D
3309:10CEC0002C4200331440FFA600000000316300FF35
3310:10CED0002402000154620003AFA00010080043D6F2
3311:10CEE000000000003C04000124845A20AFA000147C
3312:10CEF0008F8601208F8701243C0500090C00240344
3313:10CF000034A5F011080043D6000000003C040001E5
3314:10CF100024845A2CAFA000148F8601208F8701240F
3315:10CF20003C0500090C00240334A5F010080043D68A
3316:10CF3000000000003C04000124845A38AFA0001413
3317:10CF40008EE606088F4702283C0500090C002403E2
3318:10CF500034A5F00F8EE201AC24420001AEE201AC38
3319:10CF60008EE201AC8EE2015C24420001AEE2015C83
3320:10CF70008EE2015C8FBF002003E0000827BD00287F
3321:10CF80003C0200018C425CD827BDFFE01440000D3C
3322:10CF9000AFBF00183C04000124845A443C0500083B
3323:10CFA000AFA00010AFA000148F86022034A5049912
3324:10CFB000240200013C010001AC225CD80C002403D7
3325:10CFC000000038218EE204D03C03000100771821D4
3326:10CFD000946383B23442000110600007AEE204D0D3
3327:10CFE0008F8202203C0308FF3463FFFF00431024BC
3328:10CFF00034420008AF820220000020210C0052A21F
3329:10D0000024050004AF4202688FBF001803E0000847
3330:10D0100027BD00200000000000000000000000000C
3331:10D020000000000000000000000000000000000000
3332:10D0300000000000000000000000000000000000F0
3333:10D0400000000000000000000000000000000000E0
3334:10D0500000000000000000000000000000000000D0
3335:10D0600000000000000000000000000000000000C0
3336:10D0700000000000000000000000000000000000B0
3337:10D0800000000000000000000000000000000000A0
3338:10D090000000000000000000000000000000000090
3339:10D0A0000000000000000000000000000000000080
3340:10D0B0000000000000000000000000000000000070
3341:10D0C0000000000000000000000000000000000060
3342:10D0D0000000000000000000000000000000000050
3343:10D0E0000000000000000000000000000000000040
3344:10D0F0000000000000000000000000000000000030
3345:10D100000000000000000000000000003C120001D0
3346:10D11000265212003C1400018E945C503C10000119
3347:10D12000261011203C15C00036B500608E8A000024
3348:10D130008EB30000026A400B0248000A0200F82188
3349:10D14000000000000000000D0000000000000000D2
3350:10D1500000000000000000000000000000000000CF
3351:10D1600000000000000000000000000000000000BF
3352:10D1700000000000000000000000000000000000AF
3353:10D18000000000000000000000000000000000009F
3354:10D19000000000000000000000000000000000008F
3355:10D1A000000000000000000000000000000000007F
3356:10D1B000000000000000000000000000000000006F
3357:10D1C000000000000000000000000000000000005F
3358:10D1D000000000000000000000000000000000004F
3359:10D1E000000000000000000000000000000000003F
3360:10D1F000000000000000000000000000000000002F
3361:10D20000000000000000000000000000080014D62C
3362:10D2100000000000080014D83C0A0001080014D8DF
3363:10D220003C0A0002080014D800000000080024A6F0
3364:10D2300000000000080014D83C0A0003080014D8BD
3365:10D240003C0A000408002F8C00000000080014D8DD
3366:10D250003C0A000508003CE80000000008003C66AD
3367:10D2600000000000080014D83C0A0006080014D88A
3368:10D270003C0A0007080014D800000000080014D879
3369:10D2800000000000080014D80000000008002A7503
3370:10D2900000000000080014D83C0A000B080014D855
3371:10D2A0003C0A000C080014D83C0A000D0800237A40
3372:10D2B000000000000800233900000000080014D816
3373:10D2C0003C0A000E08001B3C00000000080024A4DB
3374:10D2D00000000000080014D83C0A000F080040A716
3375:10D2E000000000000800409100000000080014D871
3376:10D2F0003C0A0010080014EE00000000080014D8DA
3377:10D300003C0A0011080014D83C0A0012080014D886
3378:10D310003C0A0013000000000000000000000000B4
3379:10D3200000000000000000000000000000000000FD
3380:10D3300000000000000000000000000000000000ED
3381:10D3400000000000000000000000000000000000DD
3382:10D3500000000000000000000000000000000000CD
3383:10D3600000000000000000000000000000000000BD
3384:10D3700000000000000000000000000000000000AD
3385:10D38000000000000000000000000000000000009D
3386:10D39000000000000000000000000000000000008D
3387:10D3A000000000000000000000000000000000007D
3388:10D3B000000000000000000000000000000000006D
3389:10D3C000000000000000000000000000000000005D
3390:10D3D000000000000000000000000000000000004D
3391:10D3E000000000000000000000000000000000003D
3392:10D3F000000000000000000000000000000000002D
3393:10D400000000000000000000000000003C030001DC
3394:10D4100034633800240500802404001F2406FFFF25
3395:10D4200024020001AF80021CAF820200AF82022002
3396:10D4300003631021AF8200C003631021AF8200C4D8
3397:10D4400003631021AF8200C827623800AF8200D08A
3398:10D4500027623800AF8200D427623800AF8200D83C
3399:10D4600027621800AF8200E027621800AF8200E454
3400:10D4700027621800AF8200E827621000AF8200F038
3401:10D4800027621000AF8200F427621000AF8200F81C
3402:10D49000ACA000002484FFFF1486FFFD24A5000437
3403:10D4A0008F8300403C02F000006218243C025000D0
3404:10D4B0001062000C0043102B144000063C02600078
3405:10D4C0003C024000106200082402080008004539B0
3406:10D4D0000000000010620004240208000800453922
3407:10D4E00000000000240207003C010001AC225CDCCB
3408:10D4F00003E000080000000027BDFFD8AFBF0024F4
3409:10D50000AFB000208F8300548F8200543C01000193
3410:10D51000AC205CC408004545246300648F8200543D
3411:10D52000006210232C4200651440FFFC0000000044
3412:10D530000C004D71000000002404000100002821AF
3413:10D5400027A60018340280000C00498EA7A20018FC
3414:10D550008F8300548F820054080045562463006472
3415:10D560008F820054006210232C4200651440FFFC9F
3416:10D5700024040001240500010C00494C27A60018D2
3417:10D580008F8300548F820054080045622463006436
3418:10D590008F820054006210232C4200651440FFFC6F
3419:10D5A00024040001240500010C00494C27A60018A2
3420:10D5B0008F8300548F8200540800456E24630064FA
3421:10D5C0008F820054006210232C4200651440FFFC3F
3422:10D5D000240400013C06000124C65DA00C00494C57
3423:10D5E000240500028F8300548F8200540800457B7D
3424:10D5F000246300648F820054006210232C42006573
3425:10D600001440FFFC24040001240500033C10000129
3426:10D6100026105DA20C00494C0200302197A600188C
3427:10D620003C07000194E75DA03C04000124845AB04B
3428:10D63000AFA00014960200003C05000D34A50100C7
3429:10D640000C002403AFA2001097A200181040004C59
3430:10D6500024036040960200003042FFF01443000AA9
3431:10D66000240200203C03000194635DA05462000981
3432:10D6700024027830240200033C010001AC225CC487
3433:10D68000080045AC240200053C03000194635DA042
3434:10D69000240278301462000F240300103C020001C1
3435:10D6A00094425DA23042FFF01443000A24020003BA
3436:10D6B0003C010001AC225CC4240200063C010001D4
3437:10D6C000AC225DB03C010001AC225DBC080045E627
3438:10D6D0003C09FFF03C0200018C425CC43C030001A9
3439:10D6E00094635DA0344200013C010001AC225CC4A3
3440:10D6F000240200151462000F000000003C0200012B
3441:10D7000094425DA23042FFF03843F4202C630001C4
3442:10D710003842F4302C4200010062182510600005E8
3443:10D72000240200033C010001AC225DBC080045E678
3444:10D730003C09FFF03C03000194635DA024027810D3
3445:10D740001462000B240200023C02000194425DA21C
3446:10D750003042FFF0144000062402000224020004BC
3447:10D760003C010001AC225DBC080045E63C09FFF02D
3448:10D770003C010001AC225DBC080045E63C09FFF01D
3449:10D780003C0200018C425CC4240300013C01000106
3450:10D79000AC235DBC344200043C010001AC225CC4FB
3451:10D7A0003C09FFF03529BDC03C0600018CC65CC4B5
3452:10D7B0003C04000124845AB0240200013C01000111
3453:10D7C000AC225CCC8F8200543C0700018CE75DBC2E
3454:10D7D0003C03000194635DA03C08000195085DA234
3455:10D7E0003C05000D34A501003C010001AC205CC8E3
3456:10D7F000004910213C010001AC225DACAFA3001038
3457:10D800000C002403AFA800148FBF00248FB00020A9
3458:10D8100003E0000827BD002827BDFFE83C05000104
3459:10D820008CA55CC8240600042402000114A2001484
3460:10D83000AFBF00103C0200018C427E3C30428000B1
3461:10D84000104000053C04000F3C0300018C635DBCEC
3462:10D8500008004617348442403C0400043C030001A5
3463:10D860008C635DBC348493E02402000514620016CE
3464:10D87000000000003C04003D0800462F34840900ED
3465:10D880003C0200018C427E3830428000104000058E
3466:10D890003C04001E3C0300018C635DBC0800462A6A
3467:10D8A000348484803C04000F3C0300018C635DBC25
3468:10D8B000348442402402000514620003000000008A
3469:10D8C0003C04007A348412003C0200018C425DACBE
3470:10D8D0008F83005400441021004310230044102B78
3471:10D8E00014400037000000003C0200018C425CD074
3472:10D8F00014400033000000003C01000110C000256E
3473:10D90000AC205CE03C0900018D295CC424070001C7
3474:10D910003C0440003C08000125087E3C250AFFFC31
3475:10D920000005284214A0000224C6FFFF24050008B9
3476:10D9300000A91024104000100000000014A70008E7
3477:10D94000000000008D020000004410241040000A76
3478:10D95000000000003C0100010800465BAC255CE0D3
3479:10D960008D4200000044102410400003000000001D
3480:10D970003C010001AC275CE03C0200018C425CE011
3481:10D980000006182B2C420001004310245440FFE5F0
3482:10D99000000528428F8200543C0300018C635CE048
3483:10D9A0003C010001AC225DAC1060002A24020001A1
3484:10D9B0003C010001AC255CC83C010001AC225CCC00
3485:10D9C0003C0200018C425CE010400022000000009C
3486:10D9D0003C0200018C425CCC1040000A2402000191
3487:10D9E0003C010001AC205CCC3C0100010037082167
3488:10D9F000AC2283AC3C010001AC205D4C3C01000139
3489:10DA0000AC225D043C030001007718218C6383ACD9
3490:10DA10002402000810620005240200010C00469553
3491:10DA20000000000008004692000000003C030001D6
3492:10DA30008C635CC8106200072402000E3C030001E6
3493:10DA40008C637DD010620003000000000C004E5477
3494:10DA50008F8402208FBF001003E0000827BD00184C
3495:10DA600027BDFFE03C02FDFFAFBF00188EE30000C2
3496:10DA70003C0500018CA55CC83C0400018C845CF072
3497:10DA80003442FFFF0062182414A40008AEE3000033
3498:10DA90003C030001007718218C6383AC3C02000139
3499:10DAA0008C425CF410620008000000003C0200019F
3500:10DAB000005710218C4283AC3C010001AC255CF086
3501:10DAC0003C010001AC225CF43C0300018C635CC8A7
3502:10DAD00024020002106201692C620003104000055C
3503:10DAE0002402000110620008000000000800481C29
3504:10DAF0000000000024020004106200B124020001B2
3505:10DB00000800481D000000003C02000100571021E1
3506:10DB10008C4283AC2443FFFF2C6200081040015A62
3507:10DB2000000310803C010001002208218C225AC809
3508:10DB300000400008000000003C0300018C635DBC55
3509:10DB40002402000514620014000000003C020001E1
3510:10DB50008C425CD41040000A240200030C004822CE
3511:10DB600000000000240200023C01000100370821EF
3512:10DB7000AC2283AC3C010001080046E0AC205CD440
3513:10DB80003C01000100370821AC2283AC3C010001BC
3514:10DB90000800481FAC205C600C0048220000000018
3515:10DBA0003C0200018C425CD43C010001AC205C6072
3516:10DBB000104000DD240200023C0100010037082172
3517:10DBC000AC2283AC3C0100010800481FAC205CD4AF
3518:10DBD0003C0300018C635DBC240200051462000359
3519:10DBE000240200013C010001AC225D000C0049CF81
3520:10DBF000000000003C0300018C635D000800478EBC
3521:10DC0000240200113C0500018CA55CC83C06000103
3522:10DC10008CC67E3C0C005108000020212402000527
3523:10DC20003C010001AC205CD43C010001003708211C
3524:10DC30000800481FAC2283AC3C04000124845ABC79
3525:10DC40003C05000F34A50100000030210000382100
3526:10DC5000AFA000100C002403AFA000140800481F60
3527:10DC6000000000008F8202203C03F70000431025D3
3528:10DC7000080047B7AF8202208F8202203C030004D5
3529:10DC800000431024144000A9240200078F8300548D
3530:10DC90003C0200018C425DA42463D8F000431023B1
3531:10DCA0002C422710144000F8240200010800481DEF
3532:10DCB000000000003C0500018CA55CC80C0052A2CD
3533:10DCC000000020210C005386000020213C030001AD
3534:10DCD0008C637E34046100EA240200013C020008E7
3535:10DCE0000062102410400006000000008F82021421
3536:10DCF0003C03FFFF00431024080047413442251F26
3537:10DD00008F8202143C03FFFF004310243442241F7F
3538:10DD1000AF8202148EE200003C0302000043102593
3539:10DD2000AEE200008F8202202403FFFB0043102498
3540:10DD3000AF8202208F82022034420002AF82022092
3541:10DD4000240200083C01000100370821AC2283AC0A
3542:10DD50008F8202203C03000400431024144000057D
3543:10DD6000000000008F8202203C03F70000431025D2
3544:10DD7000AF8202203C0300018C635DBC24020005DD
3545:10DD80001462000A000000003C02000194425DA2FF
3546:10DD900024429FBC2C4200041040000424040018BC
3547:10DDA000240500020C004D93240600200C0043DDE6
3548:10DDB000000000003C0100010800481FAC205D503D
3549:10DDC0003C020001005710218C4283AC2443FFFF2A
3550:10DDD0002C620008104000AC000310803C010001E0
3551:10DDE000002208218C225AE80040000800000000B0
3552:10DDF0000C00429B000000003C010001AC205CCC08
3553:10DE0000AF8002043C0100010C004822AC207E20BF
3554:10DE1000240200013C010001AC225CE42402000267
3555:10DE20003C010001003708210800481FAC2283ACE8
3556:10DE30000C00489F000000003C0300018C635CE480
3557:10DE40002402000914620090240200033C01000136
3558:10DE5000003708210800481FAC2283AC3C020001B7
3559:10DE60008C427E3830424000104000050000000027
3560:10DE70008F8200443C03FFFF0800479F34637FFF0D
3561:10DE80008F8200442403FF7F00431024AF820044AC
3562:10DE90008F830054080047B9240200048F83005484
3563:10DEA0003C0200018C425DA42463D8F0004310239F
3564:10DEB0002C42271014400074240200053C0100018C
3565:10DEC000003708210800481FAC2283AC8F82022053
3566:10DED0003C03F70000431025AF820220AF8002040C
3567:10DEE0003C010001AC207E208F83005424020006F8
3568:10DEF0003C01000100370821AC2283AC3C01000149
3569:10DF00000800481FAC235DA48F8300543C0200012D
3570:10DF10008C425DA42463FFF6004310232C42000AC8
3571:10DF20001440005900000000240200073C010001D9
3572:10DF3000003708210800481FAC2283AC8F820220E2
3573:10DF40003C04F70000441025AF8202208F8202209B
3574:10DF50003C03030000431024144000050000182176
3575:10DF60008F8202202403000100441025AF8202208A
3576:10DF700010600043240200018F8202143C03FFFF63
3577:10DF80003C0400018C845D98004310243442251F1A
3578:10DF9000AF820214240200083C010001003708216E
3579:10DFA0001080000BAC2283AC3C0200018C425D74FB
3580:10DFB00014400007240200013C010001AC227DD086
3581:10DFC0000C004E548F8402200800480C0000000012
3582:10DFD0008F8202203C0300080043102414400017E5
3583:10DFE0002402000E3C010001AC227DD08EE2000034
3584:10DFF000000020213C030200004310250C00538642
3585:10E00000AEE200008F8202202403FFFB00431024B5
3586:10E01000AF8202208F820220344200020C0043DDD6
3587:10E02000AF8202203C0500018CA55CC80C0052A206
3588:10E03000000020210800481F000000003C020001F1
3589:10E040008C425D7410400010000000003C02000192
3590:10E050008C425D702442FFFF3C010001AC225D70E8
3591:10E0600014400009240200023C010001AC205D7450
3592:10E070003C0100010800481FAC225D702402000131
3593:10E080003C010001AC225CCC8FBF001803E000080B
3594:10E0900027BD00208F8202008F8202208F82022003
3595:10E0A00034420004AF8202208F8202003C0600014D
3596:10E0B0008CC65CC834420004AF8202002402000215
3597:10E0C00010C2003A2CC200031040000524020001D7
3598:10E0D00010C20008000000000800486800000000AE
3599:10E0E0002402000410C20013240200010800486842
3600:10E0F000000000003C0300018C635CB83C0200019E
3601:10E100008C425CC03C0400018C845CDC3C0500015A
3602:10E110008CA55CBCAF860200AF860220346300226F
3603:10E1200000441025004510253442000208004867CD
3604:10E13000AF8302003C0300018C635D98AF82020054
3605:10E1400010600009AF8202203C0200018C425D7425
3606:10E15000144000053C033F003C0200018C425CB0CF
3607:10E160000800485B346300E03C0200018C425CB074
3608:10E170003C033F00346300E200431025AF820200FD
3609:10E180003C0300018C635CB43C04F7003C020001DA
3610:10E190008C425CC03C0500018CA55CDC0064182549
3611:10E1A0000043102500451025AF82022003E000083F
3612:10E1B000000000008F8202203C0300018C635CC8D9
3613:10E1C00034420004AF820220240200011062000FDA
3614:10E1D000000000008F8300548F82005424630002EB
3615:10E1E000006210232C4200031040001100000000C8
3616:10E1F0008F820054006210232C4200031040000C58
3617:10E200000000000008004879000000008F830054DF
3618:10E210008F82005408004885246300078F820054D1
3619:10E22000006210232C4200081440FFFC0000000094
3620:10E230008F8400E0308200071040000D00000000D5
3621:10E240008F8200548F8300E014830009244500323C
3622:10E250008F82005400A210232C420033104000048F
3623:10E26000000000008F8200E01082FFF90000000033
3624:10E270008F8202202403FFFD00431024AF8202207E
3625:10E2800003E00008000000003C0300018C635CE434
3626:10E290003C0200018C425CE8506200042463FFFFF2
3627:10E2A0003C010001AC235CE82463FFFF2C62000901
3628:10E2B0001040009D000310803C0100010022082155
3629:10E2C0008C225B0800400008000000008F820044A0
3630:10E2D00034428080AF8200448F8300540800493864
3631:10E2E000240200028F8300543C0200018C425DA88E
3632:10E2F0002463D8F0004310232C4227101440008AD6
3633:10E300002402000308004945000000008F820044F9
3634:10E310003C03FFFF34637FFF00431024AF820044BF
3635:10E320008F83005408004938240200048F8300546E
3636:10E330003C0200018C425DA82463FFF600431023D9
3637:10E340002C42000A144000782402000508004945C8
3638:10E35000000000008F8202203C03F70000431025DC
3639:10E36000AF8202208F8202202403FFFB004310248F
3640:10E37000AF8202208F82022034420002AF8202204C
3641:10E380003C023F00344200E0AF8202008F82020074
3642:10E390002403FFFD00431024AF8202002404000187
3643:10E3A0003405FFFFAF8402048F8300548F82005432
3644:10E3B000080048EC246300018F820054006210239F
3645:10E3C0002C4200021440FFFC000000008F82022457
3646:10E3D0000004204000A4102B1040FFF200000000B9
3647:10E3E0008F8202203C03F70000431025AF820220F9
3648:10E3F0008F8202143C03FFFF004310243442251F88
3649:10E40000AF8202148F8202202403FFFB00431024FA
3650:10E41000AF8202208F8202203C04F700348400087F
3651:10E4200034420002AF8202208F8202203C033F0070
3652:10E43000346300E200441025AF820220AF83020063
3653:10E440008F8400F0276217F81482000224850008E8
3654:10E45000276510008F8200F410A200073C038000A3
3655:10E46000346300403C02000124425C70AC82000036
3656:10E47000AC830004AF8500F08F8300540800493856
3657:10E48000240200068F8300543C0200018C425DA8E8
3658:10E490002463FFF6004310232C42000A144000229C
3659:10E4A0002402000708004945000000008F8200E0B8
3660:10E4B000AF8200E48F8200E0AF8200E88F8202200A
3661:10E4C00034420004AF8202208F8202202403FFF72F
3662:10E4D00000431024AF8202208F82004434428080A7
3663:10E4E000AF8200448F830054240200083C010001E5
3664:10E4F000AC225CE43C01000108004947AC235DA864
3665:10E500008F8300543C0200018C425DA82463D8F044
3666:10E51000004310232C42271014400003240200095A
3667:10E520003C010001AC225CE403E0000800000000B4
3668:10E5300000000000000000000000000027BDFFD820
3669:10E54000AFB2001800809021AFB3001C00A098214A
3670:10E55000AFB1001400C08821AFB0001000008021CE
3671:10E56000AFBF0020A62000000C004D4B240400018A
3672:10E57000261000012E0200201440FFFB00000000C6
3673:10E580000C004D4B000020210C004D4B24040001D9
3674:10E590000C004D4B240400010C004D4B00002021C9
3675:10E5A000241000100250102410400002000020210E
3676:10E5B000240400010C004D4B001080421600FFFAAD
3677:10E5C0000250102424100010027010241040000289
3678:10E5D00000002021240400010C004D4B001080425B
3679:10E5E0001600FFFA027010240C004D7134108000E8
3680:10E5F0000C004D71000000000C004D2B00000000CD
3681:10E600005040000500108042962200000050102566
3682:10E61000A6220000001080421600FFF70000000054
3683:10E620000C004D71000000008FBF00208FB3001C54
3684:10E630008FB200188FB100148FB0001003E00008F3
3685:10E6400027BD002827BDFFD8AFB100140080882166
3686:10E65000AFB2001800A09021AFB3001C00C09821F9
3687:10E66000AFB0001000008021AFBF00200C004D4B68
3688:10E6700024040001261000012E0200201440FFFB9C
3689:10E68000000000000C004D4B000020210C004D4B01
3690:10E69000240400010C004D4B000020210C004D4BC8
3691:10E6A0002404000124100010023010241040000245
3692:10E6B00000002021240400010C004D4B001080427A
3693:10E6C0001600FFFA0230102424100010025010240B
3694:10E6D0001040000200002021240400010C004D4BDA
3695:10E6E000001080421600FFFA025010240C004D4B1F
3696:10E6F000240400010C004D4B000020213410800048
3697:10E7000096620000005010241040000200002021FA
3698:10E71000240400010C004D4B001080421600FFF84D
3699:10E72000000000000C004D71000000008FBF0020B1
3700:10E730008FB3001C8FB200188FB100148FB000107F
3701:10E7400003E0000827BD00283C0300018C635D0046
3702:10E750003C0200018C425D4827BDFFD8AFBF0020BE
3703:10E76000AFB1001C10620003AFB000183C01000103
3704:10E77000AC235D482463FFFF2C6200131040034963
3705:10E78000000310803C010001002208218C225B3034
3706:10E7900000400008000000000C004D7100008021C6
3707:10E7A00034028000A7A2001027B100100C004D4BCE
3708:10E7B00024040001261000012E0200201440FFFB5B
3709:10E7C000000000000C004D4B000020210C004D4BC0
3710:10E7D000240400010C004D4B000020210C004D4B87
3711:10E7E0002404000124100010320200011040000235
3712:10E7F00000002021240400010C004D4B0010804239
3713:10E800001600FFFA32020001241000100C004D4BDC
3714:10E8100000002021001080421600FFFC00000000D4
3715:10E820000C004D4B240400010C004D4B0000202136
3716:10E830003410800096220000005010241040000286
3717:10E8400000002021240400010C004D4B00108042E8
3718:10E850001600FFF8000000000C004D7100000000E1
3719:10E8600008004D242402000227B10010A7A00010C8
3720:10E87000000080210C004D4B2404000126100001F3
3721:10E880002E0200201440FFFB000000000C004D4B46
3722:10E89000000020210C004D4B240400010C004D4BC6
3723:10E8A000240400010C004D4B000020212410001016
3724:10E8B0003202000110400002000020212404000167
3725:10E8C0000C004D4B001080421600FFFA320200018E
3726:10E8D000241000100C004D4B00002021001080423D
3727:10E8E0001600FFFC000000000C004D713410800089
3728:10E8F0000C004D71000000000C004D2B00000000CA
3729:10E900005040000500108042962200000050102563
3730:10E91000A6220000001080421600FFF70000000051
3731:10E920000C004D710000000097A2001030428000E2
3732:10E93000144002DC2402000308004D240000000003
3733:10E9400024021200A7A2001027B1001000008021AD
3734:10E950000C004D4B24040001261000012E02002063
3735:10E960001440FFFB000000000C004D4B0000202174
3736:10E970000C004D4B240400010C004D4B00002021E5
3737:10E980000C004D4B24040001241000103202000141
3738:10E990001040000200002021240400010C004D4B17
3739:10E9A000001080421600FFFA32020001241000100D
3740:10E9B0000C004D4B00002021001080421600FFFC8F
3741:10E9C000000000000C004D4B240400010C004D4BD6
3742:10E9D00000002021341080009622000000501024F6
3743:10E9E0001040000200002021240400010C004D4BC7
3744:10E9F000001080421600FFF8000000000C004D716E
3745:10EA0000000000008F83005408004D16240200040B
3746:10EA10008F8300543C0200018C425DB82463FF9C4C
3747:10EA2000004310232C4200641440029E2402000282
3748:10EA30003C0300018C635DBC106202972C620003F2
3749:10EA40001440029624020011240200031062000503
3750:10EA500024020004106202912402000F08004D24D9
3751:10EA60002402001108004D24240200052402001491
3752:10EA7000A7A2001027B10010000080210C004D4B10
3753:10EA800024040001261000012E0200201440FFFB88
3754:10EA9000000000000C004D4B000020210C004D4BED
3755:10EAA000240400010C004D4B000020210C004D4BB4
3756:10EAB0002404000124100010320200011040000262
3757:10EAC00000002021240400010C004D4B0010804266
3758:10EAD0001600FFFA32020001241000103202001268
3759:10EAE0001040000200002021240400010C004D4BC6
3760:10EAF000001080421600FFFA320200120C004D4B4B
3761:10EB0000240400010C004D4B000020213410800033
3762:10EB10009622000000501024104000020000202126
3763:10EB2000240400010C004D4B001080421600FFF839
3764:10EB3000000000000C004D71000000008F830054A5
3765:10EB400008004D16240200068F8300543C02000189
3766:10EB50008C425DB82463FF9C004310232C42006468
3767:10EB6000144002502402000708004D240000000059
3768:10EB700024020006A7A2001027B100100000802187
3769:10EB80000C004D4B24040001261000012E02002031
3770:10EB90001440FFFB000000000C004D4B0000202142
3771:10EBA0000C004D4B240400010C004D4B00002021B3
3772:10EBB0000C004D4B2404000124100010320200010F
3773:10EBC0001040000200002021240400010C004D4BE5
3774:10EBD000001080421600FFFA3202000124100010DB
3775:10EBE0003202001310400002000020212404000122
3776:10EBF0000C004D4B001080421600FFFA3202001349
3777:10EC00000C004D4B240400010C004D4B0000202152
3778:10EC100034108000962200000050102410400002A2
3779:10EC200000002021240400010C004D4B0010804204
3780:10EC30001600FFF8000000000C004D7100000000FD
3781:10EC40008F83005408004D16240200088F8300545F
3782:10EC50003C0200018C425DB82463FF9C00431023FA
3783:10EC60002C4200641440020F2402000908004D24C5
3784:10EC70000000000027B10010A7A0001000008021B4
3785:10EC80000C004D4B24040001261000012E02002030
3786:10EC90001440FFFB000000000C004D4B0000202141
3787:10ECA0000C004D4B240400010C004D4B24040001CA
3788:10ECB0000C004D4B000020212410001032020001F6
3789:10ECC0001040000200002021240400010C004D4BE4
3790:10ECD000001080421600FFFA3202000124100010DA
3791:10ECE000320200181040000200002021240400011C
3792:10ECF0000C004D4B001080421600FFFA3202001843
3793:10ED00000C004D71341080000C004D7100000000AB
3794:10ED10000C004D2B00000000504000050010804208
3795:10ED20009622000000501025A6220000001080420C
3796:10ED30001600FFF7000000000C004D71000080215C
3797:10ED400097A2001027B1001034420001A7A20010C2
3798:10ED50000C004D4B24040001261000012E0200205F
3799:10ED60001440FFFB000000000C004D4B0000202170
3800:10ED70000C004D4B240400010C004D4B00002021E1
3801:10ED80000C004D4B2404000124100010320200013D
3802:10ED90001040000200002021240400010C004D4B13
3803:10EDA000001080421600FFFA320200012410001009
3804:10EDB000320200181040000200002021240400014B
3805:10EDC0000C004D4B001080421600FFFA3202001872
3806:10EDD0000C004D4B240400010C004D4B0000202181
3807:10EDE00034108000962200000050102410400002D1
3808:10EDF00000002021240400010C004D4B0010804233
3809:10EE00001600FFF8000000000C004D71000000002B
3810:10EE10008F83005408004D162402000A8F8300548B
3811:10EE20003C0200018C425DB82463FF9C0043102328
3812:10EE30002C4200641440019B2402000B08004D2466
3813:10EE40000000000027B10010A7A0001000008021E2
3814:10EE50000C004D4B24040001261000012E0200205E
3815:10EE60001440FFFB000000000C004D4B000020216F
3816:10EE70000C004D4B240400010C004D4B24040001F8
3817:10EE80000C004D4B00002021241000103202000124
3818:10EE90001040000200002021240400010C004D4B12
3819:10EEA000001080421600FFFA320200012410001008
3820:10EEB000320200171040000200002021240400014B
3821:10EEC0000C004D4B001080421600FFFA3202001772
3822:10EED0000C004D71341080000C004D7100000000DA
3823:10EEE0000C004D2B00000000504000050010804237
3824:10EEF0009622000000501025A6220000001080423B
3825:10EF00001600FFF7000000000C004D71000080218A
3826:10EF100097A2001027B1001034420700A7A20010EA
3827:10EF20000C004D4B24040001261000012E0200208D
3828:10EF30001440FFFB000000000C004D4B000020219E
3829:10EF40000C004D4B240400010C004D4B000020210F
3830:10EF50000C004D4B2404000124100010320200016B
3831:10EF60001040000200002021240400010C004D4B41
3832:10EF7000001080421600FFFA320200012410001037
3833:10EF8000320200171040000200002021240400017A
3834:10EF90000C004D4B001080421600FFFA32020017A1
3835:10EFA0000C004D4B240400010C004D4B00002021AF
3836:10EFB00034108000962200000050102410400002FF
3837:10EFC00000002021240400010C004D4B0010804261
3838:10EFD0001600FFF8000000000C004D71000000005A
3839:10EFE0008F83005408004D162402000C8F830054B8
3840:10EFF0003C0200018C425DB82463FF9C0043102357
3841:10F000002C420064144001272402001208004D2401
3842:10F010000000000027B10010A7A000100000802110
3843:10F020000C004D4B24040001261000012E0200208C
3844:10F030001440FFFB000000000C004D4B000020219D
3845:10F040000C004D4B240400010C004D4B2404000126
3846:10F050000C004D4B00002021241000103202000152
3847:10F060001040000200002021240400010C004D4B40
3848:10F07000001080421600FFFA320200012410001036
3849:10F08000320200141040000200002021240400017C
3850:10F090000C004D4B001080421600FFFA32020014A3
3851:10F0A0000C004D71341080000C004D710000000008
3852:10F0B0000C004D2B00000000504000050010804265
3853:10F0C0009622000000501025A62200000010804269
3854:10F0D0001600FFF7000000000C004D7100008021B9
3855:10F0E00097A2001027B1001034420010A7A2001010
3856:10F0F0000C004D4B24040001261000012E020020BC
3857:10F100001440FFFB000000000C004D4B00002021CC
3858:10F110000C004D4B240400010C004D4B000020213D
3859:10F120000C004D4B24040001241000103202000199
3860:10F130001040000200002021240400010C004D4B6F
3861:10F14000001080421600FFFA320200012410001065
3862:10F1500032020014104000020000202124040001AB
3863:10F160000C004D4B001080421600FFFA32020014D2
3864:10F170000C004D4B240400010C004D4B00002021DD
3865:10F18000341080009622000000501024104000022D
3866:10F1900000002021240400010C004D4B001080428F
3867:10F1A0001600FFF8000000000C004D710000000088
3868:10F1B0008F83005408004D16240200138F830054DF
3869:10F1C0003C0200018C425DB82463FF9C0043102385
3870:10F1D0002C420064144000B32402000D08004D24AA
3871:10F1E0000000000027B10010A7A00010000080213F
3872:10F1F0000C004D4B24040001261000012E020020BB
3873:10F200001440FFFB000000000C004D4B00002021CB
3874:10F210000C004D4B240400010C004D4B2404000154
3875:10F220000C004D4B00002021241000103202000180
3876:10F230001040000200002021240400010C004D4B6E
3877:10F24000001080421600FFFA320200012410001064
3878:10F2500032020018104000020000202124040001A6
3879:10F260000C004D4B001080421600FFFA32020018CD
3880:10F270000C004D71341080000C004D710000000036
3881:10F280000C004D2B00000000504000050010804293
3882:10F290009622000000501025A62200000010804297
3883:10F2A0001600FFF7000000000C004D7100008021E7
3884:10F2B00097A2001027B100103042FFFEA7A2001055
3885:10F2C0000C004D4B24040001261000012E020020EA
3886:10F2D0001440FFFB000000000C004D4B00002021FB
3887:10F2E0000C004D4B240400010C004D4B000020216C
3888:10F2F0000C004D4B240400012410001032020001C8
3889:10F300001040000200002021240400010C004D4B9D
3890:10F31000001080421600FFFA320200012410001093
3891:10F3200032020018104000020000202124040001D5
3892:10F330000C004D4B001080421600FFFA32020018FC
3893:10F340000C004D4B240400010C004D4B000020210B
3894:10F35000341080009622000000501024104000025B
3895:10F3600000002021240400010C004D4B00108042BD
3896:10F370001600FFF8000000000C004D7100000000B6
3897:10F380008F83005408004D162402000E240208400A
3898:10F39000A7A2001027B10010000080210C004D4BE7
3899:10F3A00024040001261000012E0200201440FFFB5F
3900:10F3B000000000000C004D4B000020210C004D4BC4
3901:10F3C000240400010C004D4B000020210C004D4B8B
3902:10F3D0002404000124100010320200011040000239
3903:10F3E00000002021240400010C004D4B001080423D
3904:10F3F0001600FFFA3202000124100010320200133E
3905:10F400001040000200002021240400010C004D4B9C
3906:10F41000001080421600FFFA320200130C004D4B20
3907:10F42000240400010C004D4B00002021341080000A
3908:10F4300096220000005010241040000200002021FD
3909:10F44000240400010C004D4B001080421600FFF810
3910:10F45000000000000C004D71000000008F8300547C
3911:10F46000240200103C010001AC225D003C010001BF
3912:10F4700008004D26AC235DB88F8300543C02000188
3913:10F480008C425DB82463FF9C004310232C4200642F
3914:10F490001440000400000000240200113C0100019F
3915:10F4A000AC225D008FBF00208FB1001C8FB0001810
3916:10F4B00003E0000827BD00288F8500448F820044A8
3917:10F4C0003C030001004310253C030008AF820044C8
3918:10F4D0008F8400548F82005400A3282408004D37E5
3919:10F4E000248400018F820054008210232C420002E9
3920:10F4F0001440FFFC000000008F8200443C03FFFE2C
3921:10F500003463FFFF00431024AF8200448F83005414
3922:10F510008F82005408004D45246300018F820054FF
3923:10F52000006210232C4200021440FFFC0000000087
3924:10F5300003E0000800A010218F8300443C02FFF08C
3925:10F540003442FFFF00042480006218243C020002C1
3926:10F550000082202500641825AF8300448F82004478
3927:10F560003C03FFFE3463FFFF00431024AF820044DE
3928:10F570008F8300548F82005408004D5E2463000185
3929:10F580008F820054006210232C4200021440FFFCC2
3930:10F59000000000008F8200443C030001004310255E
3931:10F5A000AF8200448F8300548F82005408004D6B5B
3932:10F5B000246300018F820054006210232C42000259
3933:10F5C0001440FFFC0000000003E000080000000001
3934:10F5D0008F8200443C03FFF03463FFFF004310249C
3935:10F5E000AF8200448F8200443C0300010043102599
3936:10F5F000AF8200448F8300548F82005408004D7FF7
3937:10F60000246300018F820054006210232C42000208
3938:10F610001440FFFC000000008F8200443C03FFFE0A
3939:10F620003463FFFF00431024AF8200448F830054F3
3940:10F630008F82005408004D8D246300018F82005496
3941:10F64000006210232C4200021440FFFC0000000066
3942:10F6500003E000080000000027BDFFC8AFB300248E
3943:10F6600000809821AFB5002C00A0A821AFB20020E7
3944:10F6700000C0902132A2FFFFAFBF0030AFB400281E
3945:10F68000AFB1001CAFB0001814400034A7B2001096
3946:10F690003271FFFF27B20010000080210C004D4B9B
3947:10F6A00024040001261000012E0200201440FFFB5C
3948:10F6B000000000000C004D4B000020210C004D4BC1
3949:10F6C000240400010C004D4B000020210C004D4B88
3950:10F6D0002404000124100010320200011040000236
3951:10F6E00000002021240400010C004D4B001080423A
3952:10F6F0001600FFFA3202000124100010023010241C
3953:10F700001040000200002021240400010C004D4B99
3954:10F71000001080421600FFFA023010240C004D4BFE
3955:10F72000240400010C004D4B000020213410800007
3956:10F7300096420000005010241040000200002021DA
3957:10F74000240400010C004D4B001080421200007593
3958:10F750000000000008004DC9000000003274FFFFE7
3959:10F7600027B10010A7A00010000080210C004D4B15
3960:10F7700024040001261000012E0200201440FFFB8B
3961:10F78000000000000C004D4B000020210C004D4BF0
3962:10F79000240400010C004D4B240400010C004D4BCF
3963:10F7A000000020212410001032020001104000024D
3964:10F7B00000002021240400010C004D4B0010804269
3965:10F7C0001600FFFA320200012410001002901024EB
3966:10F7D0001040000200002021240400010C004D4BC9
3967:10F7E000001080421600FFFA029010240C004D71A8
3968:10F7F000341080000C004D71000000000C004D2BF7
3969:10F8000000000000504000050010804296220000D9
3970:10F8100000501025A6220000001080421600FFF7BD
3971:10F82000000000000C004D710000000032A5FFFF39
3972:10F830002402000154A200042402000297A2001036
3973:10F8400008004E140052102514A200063271FFFF6A
3974:10F8500097A200100012182700431024A7A200103E
3975:10F860003271FFFF27B20010000080210C004D4BC9
3976:10F8700024040001261000012E0200201440FFFB8A
3977:10F88000000000000C004D4B000020210C004D4BEF
3978:10F89000240400010C004D4B000020210C004D4BB6
3979:10F8A0002404000124100010320200011040000264
3980:10F8B00000002021240400010C004D4B0010804268
3981:10F8C0001600FFFA3202000124100010023010244A
3982:10F8D0001040000200002021240400010C004D4BC8
3983:10F8E000001080421600FFFA023010240C004D4B2D
3984:10F8F000240400010C004D4B000020213410800036
3985:10F900009642000000501024104000020000202108
3986:10F91000240400010C004D4B001080421600FFF83B
3987:10F92000000000000C004D71000000008FBF00308F
3988:10F930008FB5002C8FB400288FB300248FB2002025
3989:10F940008FB1001C8FB0001803E0000827BD0038FD
3990:10F9500000000000000000000000000027BDFFE8DC
3991:10F96000AFBF00103C030001007718218C6383AC0B
3992:10F97000240200081462022C008030213C020001A5
3993:10F980008C425D9814400033000000008F850224F3
3994:10F9900038A300202C63000138A200102C42000183
3995:10F9A000006218251460000D38A300302C6300019C
3996:10F9B00038A204002C4200010062182514600007E0
3997:10F9C00038A304022C63000138A204042C42000175
3998:10F9D0000062182510600005000000000C00429B2A
3999:10F9E0000000000008004E8D2402000E0C0043DDD4
4000:10F9F000000000003C0500018CA55CC80C0052A270
4001:10FA0000000020213C0300018C635CC82402000438
4002:10FA1000146200052403FFFB3C0200018C425CC41D
4003:10FA200008004E892403FFF73C0200018C425CC4AD
4004:10FA3000004310243C010001AC225CC42402000EEF
4005:10FA40003C0100010C00429BAC227DD00800508795
4006:10FA5000000000008F8202203C03040000431024B9
4007:10FA6000104000272403FFBF8F8502243C020001C1
4008:10FA70008C427DDC00A32024004310241482000C5F
4009:10FA8000000000003C0200018C427DE024420001A5
4010:10FA90003C010001AC227DE02C4200021440000831
4011:10FAA000240200013C01000108004EADAC227E00A2
4012:10FAB0003C010001AC207DE03C010001AC207E0057
4013:10FAC0003C0200018C427E001040000630A2004043
4014:10FAD00010400004240200013C01000108004EB85F
4015:10FAE000AC227E043C010001AC207E043C010001FC
4016:10FAF000AC257DDC3C01000108004EC8AC207E1026
4017:10FB0000240200013C010001AC227E103C010001F6
4018:10FB1000AC207E003C010001AC207DE03C010001F6
4019:10FB2000AC207E043C010001AC207DDC3C030001E4
4020:10FB30008C637DD03C0200018C427DD410620003B6
4021:10FB40003C0202003C010001AC237DD400C2102421
4022:10FB5000104000072463FFFF8F820220240300016E
4023:10FB60003C010001AC235CCC080050853C03F7004D
4024:10FB70002C62000E104001A8000310803C0100011F
4025:10FB8000002208218C225B80004000080000000059
4026:10FB90003C010001AC207E003C010001AC207DE076
4027:10FBA0003C010001AC207DDC3C010001AC207E0466
4028:10FBB0003C010001AC207DF83C010001AC207DF04F
4029:10FBC0000C00486AAF800224240200023C010001BC
4030:10FBD000AC227DD03C0200018C427E1014400056C5
4031:10FBE0003C03FDFF8EE200003463FFFF004310245E
4032:10FBF0000C00429BAEE20000AF8002048F82020044
4033:10FC00002403FFFD00431024AF8202003C010001E9
4034:10FC1000AC207E208F8300543C0200018C427DF892
4035:10FC2000240400013C010001AC247E0C24420001AC
4036:10FC30003C010001AC227DF82C4200043C01000193
4037:10FC4000AC237DF414400006240200033C010001B3
4038:10FC5000AC245CCC3C01000108005083AC207DF852
4039:10FC60003C01000108005083AC227DD08F830054FA
4040:10FC70003C0200018C427DF42463D8F00043102341
4041:10FC80002C42271014400003240200043C01000110
4042:10FC9000AC227DD03C0200018C427E101440002634
4043:10FCA0003C03FDFF8EE200003463FFFF004310249D
4044:10FCB00008005083AEE200003C0400018C845D9C8F
4045:10FCC0003C0100010C00508AAC207DE83C020001A0
4046:10FCD0008C427E1CAF8202043C0200018C427E10EA
4047:10FCE000144000153C03FDFF8EE200003463FFFF6B
4048:10FCF00000431024AEE200008F8202043042003044
4049:10FD00001440013C240200023C0300018C637E1C71
4050:10FD1000240200053C010001AC227DD03C01000121
4051:10FD200008005083AC237E203C0200018C427E10F0
4052:10FD3000104000103C03FDFF3C0200018C425D6C52
4053:10FD4000244200013C010001AC225D6C2C42000207
4054:10FD500014400131240200013C010001AC225D7419
4055:10FD60003C010001AC205D6C3C01000108005083A7
4056:10FD7000AC225CCC8EE200003463FFFF0043102411
4057:10FD8000AEE200003C0200018C427E0010400122E5
4058:10FD9000000000003C0200018C427DDC1040011E8E
4059:10FDA000000000003C010001AC227E082402000398
4060:10FDB0003C010001AC227DE0080050242402000632
4061:10FDC0003C010001AC207DE88F82020434420040F7
4062:10FDD000AF8202043C0200018C427E202403000713
4063:10FDE0003C010001AC237DD0344200403C010001C5
4064:10FDF000AC227E203C0200018C427E0010400005B7
4065:10FE0000000000003C0200018C427DDC104000F943
4066:10FE1000240200023C05000124A57DE08CA2000024
4067:10FE20002C424E21104000F3240200023C0200014B
4068:10FE30008C427E04104000F82404FFBF3C02000105
4069:10FE40008C427DDC3C0300018C637E08004410245E
4070:10FE50000064182410430004240200013C01000146
4071:10FE600008005083AC227DD024020003ACA2000025
4072:10FE7000240200083C010001AC227DD03C020001BC
4073:10FE80008C427E0C1040000C240200013C04000156
4074:10FE90000C0050978C847DDC3C0200018C427E2853
4075:10FEA00014400005240200013C0200018C427E2423
4076:10FEB00010400006240200013C010001AC225CCC91
4077:10FEC0003C01000108005083AC207DF83C02000199
4078:10FED0008C427DF03C0300018C637DDC2C420001F0
4079:10FEE000000210C0306300083C010001AC227DF02C
4080:10FEF0003C010001AC237DEC8F83005424020009F7
4081:10FF00003C010001AC227DD03C010001080050837F
4082:10FF1000AC237DF48F8300543C0200018C427DF4BD
4083:10FF20002463D8F0004310232C422710144000A86B
4084:10FF3000000000003C0200018C427E0010400005E1
4085:10FF4000000000003C0200018C427DDC104000A952
4086:10FF5000240200023C03000124637DE08C62000067
4087:10FF60002C424E21104000A3240200023C0200015A
4088:10FF70008C427E0C1040000E000000003C0200018C
4089:10FF80008C427DDC3C010001AC207E0C30420080C4
4090:10FF90001040002F2402000C8F82020430420080A7
4091:10FFA0001440000C24020003080050112402000C2D
4092:10FFB0003C0200018C427DDC304200801440000590
4093:10FFC000240200038F820204304200801040001F90
4094:10FFD00024020003AC6200002402000A3C0100017C
4095:10FFE000AC227DD03C04000124847E188C82000069
4096:10FFF0003C0300018C637DF000431025AF820204B6
4097:020000021000EC
4098:100000008C8300003C0400018C847DF02402000BF2
4099:100010003C010001AC227DD0006418253C010001A8
4100:10002000AC237E203C05000124A57DE08CA20000CD
4101:100030002C424E211040006F240200023C020001BD
4102:100040008C427E1010400005000000002402000CCD
4103:100050003C01000108005083AC227DD03C0200012D
4104:100060008C427E001040006C000000003C04000147
4105:100070008C847DDC1080005E308200083C0300012F
4106:100080008C637DEC10620064240200033C010001DB
4107:10009000AC247E08ACA20000240200063C01000152
4108:1000A00008005083AC227DD08F82020034420002CF
4109:1000B000AF8202008F8300542402000D3C01000136
4110:1000C000AC227DD03C010001AC237DF48F83005431
4111:1000D0003C0200018C427DF42463D8F000431023DD
4112:1000E0002C4227101440003A000000003C0200019E
4113:1000F0008C427E10104000292402000E3C030001B7
4114:100100008C637E243C01000114600015AC227DD07C
4115:100110000C0043DD000000003C0500018CA55CC81C
4116:100120000C0052A2000020213C0300018C635CC83B
4117:1001300024020004146200052403FFFB3C020001BA
4118:100140008C425CC4080050522403FFF73C020001BB
4119:100150008C425CC4004310243C010001AC225CC40E
4120:100160008EE200003C03020000431025AEE20000D6
4121:100170008F8202243C010001AC227E2C8F8202205F
4122:100180002403FFFB00431024AF8202208F82022051
4123:100190003442000208005083AF8202203C0200017A
4124:1001A0008C427E0010400005000000003C0200016F
4125:1001B0008C427DDC1040000F240200023C02000152
4126:1001C0008C427DE02C424E211040000A24020002A5
4127:1001D0003C0200018C427E001040000F0000000035
4128:1001E0003C0200018C427DDC1440000B000000004A
4129:1001F000240200023C01000108005083AC227DD0A3
4130:100200003C0200018C427E00104000030000000010
4131:100210000C00429B000000008F8202203C03F7008C
4132:1002200000431025AF8202208FBF001003E00008BA
4133:1002300027BD00183C03000124637E288C62000067
4134:1002400010400005344220003C010001AC227E1C1D
4135:1002500008005095AC6000003C010001AC247E1CFD
4136:1002600003E000080000000027BDFFE030820030FE
4137:10027000AFBF00183C010001AC227E24144000678F
4138:100280003C02FFFF34421F0E008210241440006124
4139:1002900024020030308220001040005D3083800056
4140:1002A00000031A0230820001000212003C04000127
4141:1002B0008C845D9C00621825000331C23C03000160
4142:1002C00024635D78308280000002120230840001D5
4143:1002D0000004220000441025000239C200061080EC
4144:1002E0000043102100471021904300002402000128
4145:1002F00010620025000000001060000724020002C8
4146:1003000010620013240200031062002C3C05000F51
4147:10031000080050F9000000008F8202002403FEFF55
4148:1003200000431024AF8202008F8202203C03FFFEB4
4149:100330003463FFFF00431024AF8202203C01000120
4150:10034000AC207E443C01000108005104AC207E4CEE
4151:100350008F82020034420100AF8202008F820220AD
4152:100360003C03FFFE3463FFFF00431024AF820220F2
4153:10037000240201003C010001AC227E443C0100014A
4154:1003800008005104AC207E4C8F8202002403FEFF43
4155:1003900000431024AF8202008F8202203C03000140
4156:1003A00000431025AF8202203C010001AC207E44B6
4157:1003B0003C01000108005104AC237E4C8F820200F6
4158:1003C00034420100AF8202008F8202203C03000110
4159:1003D00000431025AF820220240201003C010001ED
4160:1003E000AC227E443C01000108005104AC237E4C49
4161:1003F00034A5FFFF3C04000124845BB8AFA30010C8
4162:100400000C002403AFA000140800510400000000F9
4163:10041000240200303C010001AC227E288FBF00186E
4164:1004200003E0000827BD00200000000027BDFFC832
4165:10043000AFB2002800809021AFB3002C00A098211B
4166:10044000AFB0002000C080213C04000124845BD0B8
4167:100450003C0500093C0200018C425CC834A59001B7
4168:100460000240302102603821AFBF0030AFB100241C
4169:10047000A7A0001AAFB000140C002403AFA2001014
4170:1004800024020002126200832E6200031040000565
4171:10049000240200011262000A000000000800529BC2
4172:1004A0000000000024020004126200FA2402000886
4173:1004B000126200F93C02FFEC0800529B00000000B1
4174:1004C0003C0200018C425CC4304200021440000433
4175:1004D000001289403C02FFFB3442FFFF02028024ED
4176:1004E0003C01000100310821AC307E3C3C02400060
4177:1004F000020210241040004E001023C2308400304D
4178:10050000001013823042001C3C03000124635D088C
4179:1005100000431021008238213C02002002021024F6
4180:1005200010400006240201003C01000100310821B6
4181:10053000AC227E40080051503C0200803C0100018A
4182:1005400000310821AC207E403C02008002021024D1
4183:1005500010400006001219403C0200013C0100015D
4184:10056000002308210800515CAC227E480012114093
4185:100570003C01000100220821AC207E4894E40000E8
4186:100580003C0300018C635DBC240200051062001076
4187:10059000A7A400183202400010400002348240003C
4188:1005A000A7A200182404000194E20002240500041C
4189:1005B00024E60002344200010C00498EA4E200024D
4190:1005C00024040001000028210C00498E27A60018F1
4191:1005D0003C0200018C425CC8241100013C01000176
4192:1005E000AC315CD414530004320280000C00429BF6
4193:1005F00000000000320280001040011F00000000D7
4194:100600000C00429B000000003C0300018C635DBCB9
4195:100610002402000510620118240200023C010001BE
4196:10062000AC315CCC3C0100010800529BAC225CC8A0
4197:10063000240400012405000427B0001A0C00498E90
4198:100640000200302124040001000028210C00498E02
4199:10065000020030213C020001005110218C427E3406
4200:100660003C0400018C845CC83C03BFFF3463FFFF83
4201:100670003C010001AC335CD4004310243C01000178
4202:1006800000310821109300FAAC227E340800529BFE
4203:10069000000000003C02200002021024104000056F
4204:1006A000240200013C010001AC225D98080051AD1C
4205:1006B000001289403C010001AC205D980012894085
4206:1006C0003C01000100310821AC307E383C02400082
4207:1006D0000202102414400016000000003C02000139
4208:1006E0008C425D9810400008240400042405000199
4209:1006F0000C004D9324062000240200013C0100015F
4210:1007000000370821AC2283AC3C02000100511021CB
4211:100710008C427E303C03BFFF3463FFFF0043102454
4212:100720003C0100010031082108005299AC227E30C2
4213:100730003C0200018C425D98104000283C0300A060
4214:10074000020310245443000D3C0200203C0200012F
4215:100750008C425D9C240301003C0100010031082112
4216:10076000AC237E443C0300013C0100010031082120
4217:10077000AC237E4C080051F03442040002021024E5
4218:1007800010400008240301003C0200018C425D9CE3
4219:100790003C01000100310821AC237E44080051F0E7
4220:1007A000344208003C020080020210241040002E57
4221:1007B0003C0300013C0200018C425D9C3C010001B5
4222:1007C00000310821AC237E4C34420C003C01000176
4223:1007D000AC225D9C08005218240400013C02002059
4224:1007E0000202102410400006240201003C01000116
4225:1007F00000310821AC227E44080052013C020080F6
4226:100800003C01000100310821AC207E443C02008004
4227:100810000202102410400007001219403C0200019F
4228:100820003C01000100230821AC227E4C0800520F3D
4229:1008300024040001001211403C01000100220821A3
4230:10084000AC207E4C240400010000282127B0001EAB
4231:100850000C00494C02003021240400010000282132
4232:100860000C00494C02003021240400012405000141
4233:1008700027B0001C0C00494C020030212404000168
4234:10088000240500010C00494C020030210800529957
4235:10089000000000003C02FFEC3442FFFF0202802413
4236:1008A0003C02000802028025001211403C010001B8
4237:1008B00000220821AC307E383C02200002021024C5
4238:1008C00010400009000000003C0200018C425D74F1
4239:1008D00014400005240200013C010001AC225D9897
4240:1008E0000800523A3C0240003C010001AC205D98F7
4241:1008F0003C024000020210241440001E00000000D0
4242:100900003C0200018C425D983C010001AC205CE09F
4243:1009100010400007240220203C010001AC225D9C15
4244:10092000240200013C01000100370821AC2283AC05
4245:100930003C04BFFF001219403C020001004310219B
4246:100940008C427E303C0500018CA55CC83484FFFFDE
4247:10095000004410243C01000100230821AC227E3019
4248:100960002402000110A20044000000000800529977
4249:10097000000000003C0200018C425D981040001C09
4250:10098000240220003C010001AC225D9C3C0300A03D
4251:100990000203102414430005001211403402A00089
4252:1009A0003C01000108005294AC225D9C3C03000114
4253:1009B000006218218C637E383C0200200062102403
4254:1009C00010400004240220013C0100010800529460
4255:1009D000AC225D9C3C020080006210241040001F8D
4256:1009E0003402A0013C01000108005294AC225D9C3D
4257:1009F0003C0200200202102410400007001219409F
4258:100A0000240201003C01000100230821AC227E44A5
4259:100A1000080052883C020080001211403C01000195
4260:100A200000220821AC207E443C02008002021024F7
4261:100A300010400006001219403C0200013C01000178
4262:100A40000023082108005294AC227E4C0012114071
4263:100A50003C01000100220821AC207E4C3C03000137
4264:100A60008C635CC8240200011062000300000000D7
4265:100A70000C00429B000000008FBF00308FB3002CA1
4266:100A80008FB200288FB100248FB0002003E000084F
4267:100A900027BD003827BDFFD8AFB2002000809021CD
4268:100AA000AFB1001C0000882124020002AFBF002467
4269:100AB000AFB00018A7A0001210A200D3A7A000108A
4270:100AC0002CA20003104000052402000110A2000A1D
4271:100AD00000128140080053800220102124020004EB
4272:100AE00010A2007D2402000810A2007C0012294000
4273:100AF00008005380022010213C03000100701821DF
4274:100B00008C637E3C3C0240000062102414400009CB
4275:100B1000240400013C027FFF3442FFFF006288246E
4276:100B20003C01000100300821AC317E3408005380C4
4277:100B300002201021240500010C00494C27A60010BA
4278:100B400024040001240500010C00494C27A60010D4
4279:100B500097A2001030420004104000343C114000C5
4280:100B60003C0200018C425DBC2443FFFF2C62000666
4281:100B700010400034000310803C01000100220821D5
4282:100B80008C225BE00040000800000000240400010B
4283:100B90002405001127B000120C00494C020030213E
4284:100BA00024040001240500110C00494C02003021EE
4285:100BB00097A5001230A24000104000023C04001033
4286:100BC0003C0400083C0300010800530130A28000EF
4287:100BD000240400012405001427B000120C00494C25
4288:100BE0000200302124040001240500140C00494CAB
4289:100BF0000200302197A5001230A210001040000220
4290:100C00003C0400103C0400083C03000130A2080032
4291:100C1000544000013C0300023C02800002221025E7
4292:100C2000006418250800530E004388253C1100017C
4293:100C3000023088218E317E3C3C027FFF3442FFFF30
4294:100C4000022288243C0200018C425CD81040001D26
4295:100C5000001211403C0200018C425D9810400002DD
4296:100C60003C02200002228825001211403C010001B4
4297:100C7000002208218C227E40104000033C0200200C
4298:100C800008005322022288253C02FFDF3442FFFF86
4299:100C900002228824001211403C0100010022082198
4300:100CA0008C227E48104000033C0200800800532D37
4301:100CB000022288253C02FF7F3442FFFF0222882463
4302:100CC000001211403C01000100220821AC317E34A9
4303:100CD0000800538002201021001229403C0300012B
4304:100CE000006518218C637E383C02400000621024AD
4305:100CF000144000083C027FFF3442FFFF006288245A
4306:100D00003C01000100250821AC317E3008005380F1
4307:100D1000022010213C0200018C425CD810400033BC
4308:100D20003C11C00C3C0200018C425D743C04C00CC0
4309:100D3000348420003C0300018C635D980002102B7A
4310:100D40000002102300441024106000030051882585
4311:100D50003C022000022288253C02000100451021AF
4312:100D60008C427E44104000033C0200200800535D8A
4313:100D7000022288253C02FFDF3442FFFF0222882442
4314:100D8000001211403C010001002208218C227E4CFF
4315:100D9000104000033C0200800800536802228825AE
4316:100DA0003C02FF7F3442FFFF022288243C02000104
4317:100DB0008C425D60104000023C020800022288253F
4318:100DC0003C0200018C425D64104000023C020400C1
4319:100DD000022288253C0200018C425D68104000061A
4320:100DE0003C0201000800537B022288253C027FFF61
4321:100DF0003442FFFF00628824001211403C010001D0
4322:100E000000220821AC317E30022010218FBF002447
4323:100E10008FB200208FB1001C8FB0001803E00008D3
4324:100E200027BD002827BDFFD8AFB400200080A02137
4325:100E3000AFBF0024AFB3001CAFB20018AFB10014B5
4326:100E4000AFB000108F9002003C0300018C635CC8BF
4327:100E50008F93022024020002106200632C620003C0
4328:100E600010400005240200011062000A001419401D
4329:100E70000800544800000000240200041062005AD8
4330:100E800024020008106200590014914008005448E0
4331:100E9000000000003C040001008320218C847E3C83
4332:100EA0003C110001022388218E317E343C02400037
4333:100EB000008210241040003E3C0200080222102450
4334:100EC00010400020361000023C02000100431021B7
4335:100ED0008C427E4010400005361000203610010084
4336:100EE0003C020020080053BD022288252402FEFF98
4337:100EF000020280243C02FFDF3442FFFF02228824EA
4338:100F0000001411403C010001002208218C227E487F
4339:100F1000104000053C020001026298253C0200805E
4340:100F2000080053DC022288253C02FFFE3442FFFF0A
4341:100F3000026298243C02FF7F3442FFFF080053DC2A
4342:100F4000022288242402FEDF020280243C02FFFEEB
4343:100F50003442FFFF026298243C02FF5F3442FFFFED
4344:100F6000022288243C01000100230821AC207E409D
4345:100F70003C01000100230821AC207E480C00486A97
4346:100F800000000000AF900200AF9302208F82022089
4347:100F90002403FFFB00431024AF8202208F82022033
4348:100FA00034420002AF820220080053F300141140C3
4349:100FB0008F8202002403FFFD004310240C00486AC6
4350:100FC000AF8202003C02BFFF3442FFFF0C00429B95
4351:100FD00002228824001411403C0100010022082153
4352:100FE00008005448AC317E34001491403C040001A8
4353:100FF000009220218C847E383C110001023288212D
4354:101000008E317E303C0240000082102414400011DA
4355:10101000000000003C0200018C425D981440000674
4356:101020003C02BFFF8F820200344200020C00486A7B
4357:10103000AF8202003C02BFFF3442FFFF0C00429B24
4358:10104000022288243C010001003208210800544893
4359:10105000AC317E303C0200018C425D9810400005AE
4360:101060003C0200203C0200018C425D741040002BC9
4361:101070003C0200200082102410400007361000209F
4362:10108000240201003C01000100320821AC227E4410
4363:1010900008005428361001003C01000100320821EC
4364:1010A000AC207E442402FEFF020280243C02008029
4365:1010B0000082102410400007001419403C02000177
4366:1010C0003C01000100230821AC227E4C0800543969
4367:1010D00002629825001411403C0100010022082101
4368:1010E000AC207E4C3C02FFFE3442FFFF026298249B
4369:1010F0000C00486A00000000AF900200AF9302208D
4370:101100008F8202202403FFFB00431024AF820220C1
4371:101110008F82022034420002AF820220001411406C
4372:101120003C01000100220821AC317E308FBF002439
4373:101130008FB400208FB3001C8FB200188FB1001441
4374:101140008FB0001003E0000827BD00282448656127
4375:101150006465723A202F70726F6A656374732F72C0
4376:1011600063732F73772F67652F2E2F6E69632F663A
4377:10117000772F636F6D6D6F6E2F66776D61696E2E61
4378:10118000632C7620312E312E322E313120313939F7
4379:10119000382F30342F32372032323A31333A34322A
4380:1011A00020736875616E6720457870202400000008
4381:1011B0007468655F4441574E00000000535441433A
4382:1011C0004B5F312000000000426164536E64526E38
4383:1011D000670000003F456E71457674003F6E6F51A9
4384:1011E00064457650000000006576526E6746756C67
4385:1011F0006C000000496C6C436F6E66527800000012
4386:1012000053656E64436B53756D00000052656376E1
4387:10121000566C616E0000000000000000244865610B
4388:101220006465723A202F70726F6A656374732F72EF
4389:1012300063732F73772F67652F2E2F6E69632F6669
4390:10124000772F636F6D6D6F6E2F74696D65722E638E
4391:101250002C7620312E312E322E3820313939382F4C
4392:1012600030372F33312031373A35383A343520731F
4393:101270006875616E6720457870202400542D446D98
4394:101280006152643100000000542D446D61424200FF
4395:10129000542D446D613200003F6E6F5164547845A7
4396:1012A000000000003F6E6F5164527845000000005E
4397:1012B000656E714D4576504661696C00656E714D85
4398:1012C00045764661696C00006661696C456E454D06
4399:1012D000000000003F456E71457674003F6E6F510F
4400:1012E00064457650000000006576526E6746756C66
4401:1012F0006C00000000000000000000002448656150
4402:101300006465723A202F70726F6A656374732F720E
4403:1013100063732F73772F67652F2E2F6E69632F6688
4404:10132000772F636F6D6D6F6E2F636F6D6D616E6480
4405:101330002E632C7620312E312E322E313020313951
4406:1013400039382F31312F31382031373A31313A3174
4407:101350003820736875616E6720457870202400001E
4408:101360003F4D626F78457674000000004E4F636F0A
4409:101370006D616E6400000000687374655F455252D1
4410:1013800000000000412D45727242756300000000AC
4411:101390004552524F522D416464000000656E714DFC
4412:1013A0004576504661696C00656E714D45764661C3
4413:1013B000696C00006661696C456E454D0000000077
4414:1013C000442D4572724C617374000000442D4572C7
4415:1013D000723200006D4373744D6445525200000038
4416:1013E00070726F6D4D6445525200000046696C7416
4417:1013F0004D64455252000000636D645F45525200D7
4418:101400003F456E71457674003F6E6F51644576506E
4419:10141000000000006576526E6746756C6C00000037
4420:101420000000000000006EA000007FBC00006E38CD
4421:1014300000008734000082B00000878000008780B1
4422:1014400000006F540000769400007F0C000080A81C
4423:10145000000080740000878000007E70000080CC57
4424:1014600000006E64000081CC00000000244865612B
4425:101470006465723A202F70726F6A656374732F729D
4426:1014800063732F73772F67652F2E2F6E69632F6617
4427:10149000772F636F6D6D6F6E2F646D612E632C7689
4428:1014A00020312E312E322E3320313939382F30343D
4429:1014B0002F32372032323A31333A34312073687563
4430:1014C000616E67204578702024000000646D6172B1
4431:1014D0006441544E00000000646D61777241544EC7
4432:1014E00000000000000000000000000024486561CA
4433:1014F0006465723A202F70726F6A656374732F721D
4434:1015000063732F73772F67652F2E2F6E69632F6696
4435:10151000772F636F6D6D6F6E2F74726163652E63CD
4436:101520002C7620312E312E322E3220313939382F7F
4437:1015300030342F32372032323A31333A353020735B
4438:101540006875616E672045787020240024486561C5
4439:101550006465723A202F70726F6A656374732F72BC
4440:1015600063732F73772F67652F2E2F6E69632F6636
4441:10157000772F636F6D6D6F6E2F646174612E632CB6
4442:101580007620312E312E322E3220313939382F301B
4443:10159000342F32372032323A31333A3430207368C4
4444:1015A00075616E67204578702024000046575F56AD
4445:1015B000455253494F4E3A2023312046726920410B
4446:1015C000707220372031373A35353A34382050445C
4447:1015D000542032303030000046575F434F4D504961
4448:1015E0004C455F54494D453A2031373A35353A3408
4449:1015F0003800000046575F434F4D50494C455F420D
4450:10160000593A2064657672637300000046575F4361
4451:101610004F4D50494C455F484F53543A20636F6DCE
4452:10162000707574650000000046575F434F4D504988
4453:101630004C455F444F4D41494E3A20656E672E61DF
4454:101640006374656F6E2E636F6D00000046575F43D5
4455:101650004F4D50494C45523A20676363207665727E
4456:1016600073696F6E20322E372E32000000000000AA
4457:101670000000000000000000000000002448656138
4458:101680006465723A202F70726F6A656374732F728B
4459:1016900063732F73772F67652F2E2F6E69632F6605
4460:1016A000772F636F6D6D6F6E2F6D656D2E632C766A
4461:1016B00020312E312E322E3220313939382F30342C
4462:1016C0002F32372032323A31333A3434207368754E
4463:1016D000616E672045787020240000002448656111
4464:1016E0006465723A202F70726F6A656374732F722B
4465:1016F00063732F73772F67652F2E2F6E69632F66A5
4466:10170000772F636F6D6D6F6E2F73656E642E632C14
4467:101710007620312E312E322E313120313939382F89
4468:1017200031322F32322031373A31373A3535207362
4469:101730006875616E6720457870202400736E64645C
4470:10174000654E6F51200000006E6F454E515F54583A
4471:1017500000000000736E6464744E6F51200000003E
4472:101760003F6E6F516454784500000000756E6B72D7
4473:101770006474797065000000000000000000ACCCCB
4474:101780000000ACCC0000AD9C0000AAB00000AAB0E4
4475:101790000000AD9C0000AD9C0000AD9C0000AD9C25
4476:1017A0000000AD9C0000AD9C0000AD9C0000AD9C15
4477:1017B0000000AD9C0000AD9C0000AD9C0000AD9C05
4478:1017C0000000AD9C0000AD7C000000000000BCA843
4479:1017D0000000BCA80000BD700000AE4C0000B05876
4480:1017E0000000BD700000BD700000BD700000BD7045
4481:1017F0000000BD700000BD700000BD700000BD7035
4482:101800000000BD700000BD700000BD700000BD7024
4483:101810000000BD700000BD540000B0402448656168
4484:101820006465723A202F70726F6A656374732F72E9
4485:1018300063732F73772F67652F2E2F6E69632F6663
4486:10184000772F636F6D6D6F6E2F726563762E632CCD
4487:101850007620312E312E322E313920313939382F40
4488:1018600030372F32342032313A33303A303520732A
4489:101870006875616E6720457870202400706B52781F
4490:101880004552520066726D324C617267650000000D
4491:1018900072784E6F527842640000000072785144B2
4492:1018A0006D61444600000000727851446D6142460B
4493:1018B000000000003F6E6F51645278450000000048
4494:1018C000706B5278455252730000000066726D32A0
4495:1018D0004C7267530000000072784E6F42645300F0
4496:1018E0003F724264446D6146000000003F724A420C
4497:1018F00064446D4600000000000000000000F6781F
4498:101900000000F6780000F6780000F6780000F6781F
4499:101910000000F6780000F6780000F6780000F6780F
4500:101920000000F6780000F6780000F6780000F678FF
4501:101930000000F6780000F6780000F6700000F670FF
4502:101940000000F670572D444D41456E4600000000E2
4503:10195000000000000000FDC00001015C0000FDDC93
4504:101960000001015C0001015C0001015C0001015CFF
4505:101970000001015C0001015C0000F7040001015C52
4506:101980000001015C0001015C0001015C0001015CDF
4507:101990000001015400010154000101542448656113
4508:1019A0006465723A202F70726F6A656374732F7268
4509:1019B00063732F73772F67652F2E2F6E69632F66E2
4510:1019C000772F636F6D6D6F6E2F6D61632E632C7655
4511:1019D00020312E312E322E313220313939382F300C
4512:1019E000342F32372032323A31333A34322073686E
4513:1019F00075616E6720457870202400006D61637406
4514:101A00007841544E000000004E7453796E264C6BA2
4515:101A10000000000072656D61737372740000000055
4516:101A20006C696E6B444F574E00000000656E714D3F
4517:101A30004576504661696C00656E714D457646612C
4518:101A4000696C00006661696C456E454D00000000E0
4519:101A50006C696E6B55500000000000002448656101
4520:101A60006465723A202F70726F6A656374732F72A7
4521:101A700063732F73772F67652F2E2F6E69632F6621
4522:101A8000772F636F6D6D6F6E2F636B73756D2E6344
4523:101A90002C7620312E312E322E3220313939382F0A
4524:101AA00030342F32372032323A31333A33392073DF
4525:101AB0006875616E672045787020240050726F62EF
4526:101AC00065506879000000006C6E6B4153535254AE
4527:101AD0000000000000011B2C00011BC400011BF8CA
4528:101AE00000011C2C00011C5800011C6C00011CA8EA
4529:101AF0000001207C00011DE400011E2400011E5095
4530:101B000000011E9000011EC000011EFC00011F30DC
4531:101B10000001207C000122C0000122D80001230026
4532:101B2000000123200001234800012478000124A0A3
4533:101B3000000124F40001251C000000000001278C96
4534:101B40000001285C0001293400012A0400012A60F8
4535:101B500000012B3C00012B6400012C4000012C688B
4536:101B600000012E1000012E3800012FE0000131D8B5
4537:101B70000001346C000133800001346C00013498A2
4538:101B800000013008000131B00000000000013B847A
4539:101B900000013BC800013C6000013CAC00013D1C61
4540:101BA00000013DB400013DE800013E7000013F0826
4541:101BB00000013FD8000140180001409C000140C0D6
4542:101BC000000141F4646F42617365506700000000DA
4543:101BD00000000000000000000000000073746D6150
4544:101BE000634C4E4B000000000000000000014C3828
4545:101BF00000014C3800014B8000014BC400014C38FF
4546:101C000000014C380000000000000000000000004F
4547:101C100000000000000000000000000000000000C4
4548:101C2000000000000000000000000000416C74652E
4549:101C30006F6E204163654E4943205600416C7465C8
4550:101C40006F6E204163654E49432056004242424236
4551:101C50000000000000000000000000000013541805
4552:101C60000013E7FC0000000000000000000000007E
4553:101C70000000000000000000000000000060CF0035
4554:101C800000000060CF000000000000000000000025
4555:101C90000000000000000000000000000000000044
4556:101CA0000000000000000000000000000000000034
4557:101CB0000000000000000000000000000000000024
4558:101CC0000000000000000000000000000000000014
4559:101CD0000000000000000000000000030000000001
4560:101CE00000000001000000000000000000000000F3
4561:101CF00000000001000000000000000100000000E2
4562:101D000000000000000000000000000000000001D2
4563:101D100000000001000000000000000000000000C2
4564:101D20000000000000000000010000002100000091
4565:101D30001200014000000000000000002000000030
4566:101D4000120000A0000000001200006012000180DC
4567:101D5000120001E000000000000000000000000090
4568:101D60000000000100000000000000000000000072
4569:101D70000000000000000000000000000000000261
4570:101D8000000000000000000000030001000000014E
4571:0C1D900000030201000000000000000041
4572:00000001FF
4573/* tg1 firmware v12.4.11 */
diff --git a/firmware/acenic/tg2.bin.ihex b/firmware/acenic/tg2.bin.ihex
new file mode 100644
index 000000000000..a9ff4f431f22
--- /dev/null
+++ b/firmware/acenic/tg2.bin.ihex
@@ -0,0 +1,4844 @@
1:100000000C040B0000004000000040000000000055
2:1000100010000003000000000000000D0000000DB3
3:100020003C1D00018FBD6D2003A0F0213C1000009D
4:10003000261040000C0010C0000000000000000D61
5:100040003C1D00018FBD6D2403A0F0213C10000079
6:10005000261040000C0017E0000000000000000D1A
7:100060000000000000000000000000000000000090
8:100070000000000000000000000000000000000080
9:100080000000000000000000000000000000000070
10:100090000000000000000000000000000000000060
11:1000A0000000000000000000000000000000000050
12:1000B0000000000000000000000000000000000040
13:1000C0000000000000000000000000000000000030
14:1000D0000000000000000000000000000000000020
15:1000E0000000000000000000000000000000000010
16:1000F0000000000000000000000000000000000000
17:1001000000000000000000000000000002000008E5
18:10011000000000000800172F3C0A00010800172FFC
19:100120003C0A00020800172F0000000008002CAC59
20:100130000000000008002C4F000000000800172FEE
21:100140003C0A00040800328A0000000008001A522D
22:10015000000000000800394D00000000080038F4DD
23:10016000000000000800172F3C0A0006080039BBF9
24:100170003C0A00070800172F3C0A00080800172F48
25:100180003C0A000908003A130000000008002EA6EF
26:10019000000000000800172F3C0A000B0800172F72
27:1001A0003C0A000C0800172F3C0A000D080028FB31
28:1001B0000000000008002890000000000800172F31
29:1001C0003C0A000E0800208C0000000008001964A2
30:1001D0000000000008001A040000000008003CA60F
31:1001E0000000000008003C94000000000800172FE9
32:1001F000000000000800191A000000000800172F76
33:10020000000000000800172F3C0A00130800172FF9
34:100210003C0A001400000000000000000000000084
35:1002200000000000000000000000000000000000CE
36:1002300000000000000000000000000000000000BE
37:1002400000000000000000000000000000000000AE
38:10025000000000000000000000000000000000009E
39:10026000000000000000000000000000000000008E
40:10027000000000000000000000000000000000007E
41:10028000000000000000000000000000000000006E
42:10029000000000000000000000000000000000005E
43:1002A000000000000000000000000000000000004E
44:1002B000000000000000000000000000000000003E
45:1002C000000000000000000000000000000000002E
46:1002D000000000000000000000000000000000001E
47:1002E000000000000000000000000000000000000E
48:1002F00000000000000000000000000000000000FE
49:1003000000000000000000000000000027BDFFE02A
50:100310003C1CC000AFBF001CAFB000188F82014072
51:1003200024030003AF8300EC344200040C002B20B4
52:10033000AF8201403C0100C00C001763AC203FFCC1
53:10034000004018213C0200103C010001AC236E9CCF
54:10035000106200110043102B144000023C020020E8
55:100360003C0200081062000C240501003C0600015C
56:100370008CC66E9C3C04000124845C74000038210F
57:10038000AFA000100C002B3BAFA000143C020020DB
58:100390003C010001AC226E9C240200083C010001DB
59:1003A000AC226EB42402001F3C010001AC226EC4DA
60:1003B000240200163C010001AC226E983C05FFFEB1
61:1003C00034A56F083C0200018C426E9C3C03000285
62:1003D000246390103C0400018C846CC400431023FF
63:1003E00014800002004580212610FA382402F00013
64:1003F000020280240C00178502002021020228231B
65:100400003C0400200082182300651823247BB000E0
66:100410003C03FFFE3463BF080363B8213C0600BF02
67:1004200034C6F0003C0700018CE76CC03C0300BF01
68:100430003463E000008520233C010001AC246EA859
69:10044000008220233C010001AC256E90000528426B
70:100450003C010001AC226E8427620FFC3C010001CC
71:10046000AC226D2027621FFC00DB3023007B1823A9
72:100470003C010001AC246E883C010001AC256EAC4F
73:100480003C010001AC226D24AF86015010E0001148
74:10049000AF8302503C1D00018FBD6CCC03A0F02146
75:1004A0000C001749000000003C0200018C426CD097
76:1004B0003C0300018C636CD42442FE0024630200E0
77:1004C0003C010001AC226CD03C0100011000000492
78:1004D000AC236CD43C1D00018FBD6D2003A0F02126
79:1004E0003C0200018C426CC41040000D26FAFA3820
80:1004F0003C0200018C426CD03C0300018C636CD444
81:100500003C1A00018F5A6CD42442FA38246305C87F
82:100510003C010001AC226CD03C010001AC236CD446
83:100520003C0200018C426CC8144000030000000033
84:100530003C010001AC206CD00C0011510000000007
85:100540008FBF001C8FB0001803E0000827BD0020FB
86:100550003C0200018C426CD03C0300018C636CD4E3
87:1005600027BDFF98AFB000483C1000018E1066B860
88:10057000AFB200503C12000026524100AFBF0060F5
89:10058000AFBE005CAFB50058AFB30054AFB1004C84
90:10059000AFA20034AFA30030AFA00010AFA0001492
91:1005A0008F8600403C04000124845C802405020006
92:1005B0003C010001AC326E800C002B3B0200382164
93:1005C0008F8300403C02F000006218243C0260006F
94:1005D0001062000BA3A0003F240E00013C040001A8
95:1005E00024845C88A3AE003FAFA00010AFA000142D
96:1005F0008F860040240503000C002B3B02003821AD
97:100600008F8202403C03000100431025AF8202406C
98:10061000AF8000488F8200481440000500000000B1
99:10062000AF8000488F8200481040000400000000A6
100:10063000AF8000481000000302E02021AF80004C92
101:1006400002E020213C0500010C002BA834A540F855
102:10065000034020210C002BA8240505C83C02000102
103:100660008C426EA83C0D00018DAD6E883C030001EC
104:100670008C636E843C0800018D086E903C0900017B
105:100680008D296EAC3C0A00018D4A6EB43C0B000112
106:100690008D6B6EC43C0C00018D8C6E983C04000187
107:1006A00024845C9424050400AF42013C8F42013C49
108:1006B0002406000124070001AF400000AF4D0138BF
109:1006C000AF430144AF480148AF49014CAF4A015024
110:1006D000AF4B0154AF4C01582442FF80AF42014060
111:1006E00024020001AFA200100C002B3BAFA00014AD
112:1006F0008F420138AFA200108F42013CAFA200141C
113:100700008F4601448F4701483C04000124845CA0CB
114:100710000C002B3B24050500AFB70010AFBA001446
115:100720008F46014C8F4701503C04000124845CAC8F
116:100730000C002B3B240506003C0200018C426E9C01
117:10074000036038213C06000224C690102448FFFFB5
118:100750000106182400E810240043102B1040000666
119:10076000240509003C04000124845CB8AFA80010F3
120:100770000C002B3BAFA000148F82000CAFA2001026
121:100780008F82003CAFA200148F8600008F87000488
122:100790003C04000124845CC40C002B3B24051000A5
123:1007A0008C0202208C0302248C0602188C07021C87
124:1007B0003C04000124845CCC24051100AFA200108D
125:1007C0000C002B3BAFA30014AF800054AF80011C82
126:1007D0008C020218304200021040000900000000A4
127:1007E0008C0202203C030002346300040043102505
128:1007F000AF42000C8C02021C1000000834420004BE
129:100800008C0202203C0300023463000600431025E2
130:10081000AF42000C8C02021C34420006AF420014AE
131:100820008C020218304200101040000A0000000044
132:100830008C02021C34420004AF4200108C020220E1
133:100840003C03000A34630004004310251000000933
134:10085000AF4200088C0202203C03000A3463000609
135:1008600000431025AF4200088C02021C34420006EF
136:10087000AF42001024020001AF8200A0AF8200B09E
137:100880008F8300548F820054AF8000D0AF8000C0AF
138:1008900010000002246300648F8200540062102361
139:1008A0002C4200651440FFFC000000008C0402088C
140:1008B0008C05020C26E20028AEE2002024020490FF
141:1008C000AEE20010AEE40008AEE5000C26E400083D
142:1008D0008C8200008C830004AF820090AF83009470
143:1008E0008C820018AF8200B49482000AAF82009C10
144:1008F0008F420014AF8200B08F8200B030420004FB
145:100900001440FFFD000000008F8200B03C03EF00A8
146:100910000043102410400021000000008F8200B42A
147:10092000AFA200108F8200908F8300943C040001DE
148:1009300024845CD4AFA300148F8600B08F87009C02
149:100940003C0500010C002B3B34A5200D3C040001AC
150:1009500024845CE0240203C0AFA20010AFA0001406
151:100960008F8601443C07000124E75CE80C002B3B28
152:100970003405DEAD8F82011C34420002AF82011CBF
153:100980008F82022034420004AF8202208F82014015
154:100990003C03000100431025AF82014096E204723F
155:1009A00096E6045296E70462AFA2001096E2048233
156:1009B0003C04000124845D14240512000C002B3B30
157:1009C000AFA2001496F0045232020001104000025F
158:1009D0000000B02124160001320200025440000140
159:1009E00036D60002320200085440000136D6000418
160:1009F000320200105440000136D6000832020020B6
161:100A00005440000136D6001032020040544000012C
162:100A100036D60020320200805440000136D6004015
163:100A200096E6048230C202005440000136D64000EF
164:100A300096E304723062020010400003306201004D
165:100A40001000000336D620005440000136D61000B6
166:100A500096F0046232C24000144000043207009B4A
167:100A600030C2009B14E20007240E000132C22000B5
168:100A70001440000D320200013062009B10E20009B8
169:100A8000240E00013C04000124845D202405130091
170:100A900002003821A3AE003FAFA300100C002B3B97
171:100AA000AFA00014320200015440000136D600808D
172:100AB000320200025440000136D601003202000822
173:100AC0005440000136D602003202001054400001AA
174:100AD00036D60400320200805440000136D60800A9
175:100AE0008C02021830420200104000023C02000852
176:100AF00002C2B0258C0202183042080010400002E9
177:100B00003C02008002C2B0258C0202183042040070
178:100B1000104000023C02010002C2B0258C02021803
179:100B200030420100104000023C02020002C2B02527
180:100B30008C02021830420080104000023C02040087
181:100B400002C2B0258C020218304220001040000280
182:100B50003C02001002C2B0258C0202183042400054
183:100B6000104000023C02002002C2B0258C02021894
184:100B700030421000104000023C02004002C2B0258A
185:100B80008EE204988EE3049CAF420160AF4301649F
186:100B90008EE204A08EE304A4AF420168AF43016C6F
187:100BA0008EE204A88EE304ACAF420170AF4301743F
188:100BB0008EE204288EE3042CAF420178AF43017C1F
189:100BC0008EE204488EE3044CAF420180AF430184BF
190:100BD0008EE204588EE3045CAF420188AF43018C7F
191:100BE0008EE204688EE3046CAF420190AF4301943F
192:100BF0008EE204788EE3047CAF420198AF43019CFF
193:100C00008EE204888EE3048CAF4201A0AF4301A4BE
194:100C10008EE204B08EE304B424040080AF4201A845
195:100C2000AF4301AC0C002BA8240500808C02025CB1
196:100C300027440224AF4201F08C0202602405020026
197:100C4000240600080C002BBFAF4201F83C043B9A7D
198:100C50003484CA0000003821240200062403000264
199:100C6000AF4201F4240203E8AF430204AF430200A1
200:100C7000AF4401FCAF42029424020001AF43029052
201:100C8000AF42029C3C0300010067182190636CD8BE
202:100C90000347102124E70001A043022C2CE2000F9F
203:100CA0001440FFF80347182124E700013C08000125
204:100CB000350840F88F8200403C04000124845D2CFC
205:100CC000240514000002170224420030A062022C06
206:100CD00003471021A040022C8C07021802C03021CB
207:100CE000240205C8AFA200100C002B3BAFA80014D3
208:100CF0003C04000124845D383C05000024A55C8090
209:100D00002406001027B100300220382127B3003418
210:100D10000C0017A3AFB300103C0300018C636CC838
211:100D20001060000A004080218FA300302405FF00DE
212:100D30008FA20034246400FF008520240083182340
213:100D400000431023AFA20034AFA400303C040001E4
214:100D500024845D443C05000024A5410024060108CC
215:100D6000022038210C0017A3AFB3001000409021DF
216:100D700032C200033C010001AC326E8010400045DD
217:100D8000022038218F8200503C03001000431024C1
218:100D900010400016000000008C0202183042004093
219:100DA0001040000F240200018F8200508C030218B3
220:100DB000240E00013C04000124845D50A3AE003FDA
221:100DC000AFA20010AFA300148F87004024051500C8
222:100DD0000C002B3B02C0302110000004000000007A
223:100DE0003C01000100370821A02240F43C0400012E
224:100DF00024845D5C3C05000124A55B403C060001A9
225:100E000024C65BAC00C530238F42001027B30030EE
226:100E10000260382127B1003434420A00AF4200108A
227:100E20000C0017A3AFB100103C04000124845D70D6
228:100E30003C05000124A5B7143C06000124C6BA9065
229:100E400000C5302302603821AF4201080C0017A30F
230:100E5000AFB100103C04000124845D8C3C0500010E
231:100E600024A5BE583C06000124C6C90000C5302395
232:100E7000026038213C010001AC226EF40C0017A383
233:100E8000AFB100103C04000124845DA410000024D4
234:100E9000240516003C04000124845DAC3C050001DF
235:100EA00024A5A10C3C06000124C6A23800C53023AD
236:100EB0000C0017A3AFB300103C04000124845DBCF8
237:100EC0003C05000124A5B2B03C06000124C6B70CC5
238:100ED00000C5302302203821AF4201080C0017A3BF
239:100EE000AFB300103C04000124845DD03C05000138
240:100EF00024A5BA983C06000124C6BE5000C5302384
241:100F0000022038213C010001AC226EF40C0017A332
242:100F1000AFB300103C04000124845DE424051650A6
243:100F200002C03021000038213C010001AC226EF8E3
244:100F3000AFA000100C002B3BAFA0001432C2002069
245:100F40001040002127A700303C04000124845DF0FC
246:100F50003C05000124A5B13C3C06000124C6B2A812
247:100F600000C5302324022000AF42001C27A2003419
248:100F70000C0017A3AFA20010000219000003198291
249:100F80003C04080000641825AE4300282403001028
250:100F9000AF43003C96E30450AF4300408F43004012
251:100FA0003C04000124845E04AFA00014AFA3001031
252:100FB0008F47001C240516603C010001AC226EF036
253:100FC0001000002532C600208EE204488EE3044C57
254:100FD000AF43001C8F42001C2442E0002C42200141
255:100FE0001440000A240E00013C04000124845E1019
256:100FF000A3AE003FAFA00010AFA000148F46001CAE
257:10100000240517000C002B3B000038213C02000097
258:1010100024425CBC00021100000211823C03080063
259:1010200000431025AE42002824020008AF42003CD5
260:1010300096E20450AF4200408F4200403C04000161
261:1010400024845E1CAFA00014AFA200108F47001CC8
262:101050002405180032C600200C002B3B00000000C5
263:101060003C050FFF3C0300018C636EF434A5FFFFC9
264:10107000024030213C0200018C426EF83C04080022
265:101080000065182400031882006418250045102408
266:101090000002108200441025ACC2008032C20180E0
267:1010A00010400056ACC300208F82005C3C030080DF
268:1010B000004310241040000D000000008F820050FB
269:1010C000AFA200108F82005C240E00013C040001DE
270:1010D00024845E28A3AE003FAFA200148F87004097
271:1010E000240519000C002B3B02C030218F820050D8
272:1010F0003C030010004310241040001600000000C4
273:101100008C020218304200401040000F24020001FF
274:101110008F8200508C030218240E00013C04000151
275:1011200024845D50A3AE003FAFA20010AFA3001413
276:101130008F870040240520000C002B3B02C030218B
277:1011400010000004000000003C01000100370821ED
278:10115000A02240F43C04000124845E343C050001DC
279:1011600024A55AC03C06000124C65B3800C53023C4
280:101170008F42000827B300300260382127B10034C5
281:1011800034420E00AF4200080C0017A3AFB10010AC
282:101190003C04000124845E4C3C05000124A5D8B425
283:1011A0003C06000124C6E3C800C530230260382194
284:1011B000AF42010C0C0017A3AFB100103C040001BA
285:1011C00024845E643C05000124A5E9AC3C060001D2
286:1011D00024C6F0F000C53023026038213C01000134
287:1011E000AC226F040C0017A3AFB100103C04000147
288:1011F00024845E7C10000027240521003C040001AB
289:1012000024845E843C05000124A59FC83C0600019F
290:1012100024C6A10400C5302327B1003002203821A4
291:1012200027B300340C0017A3AFB300103C04000137
292:1012300024845E943C05000124A5CAD43C06000128
293:1012400024C6D8AC00C5302302203821AF42010C9F
294:101250000C0017A3AFB300103C04000124845EA46B
295:101260003C05000124A5E84C3C06000124C6E9A485
296:1012700000C53023022038213C010001AC226F045C
297:101280000C0017A3AFB300103C04000124845EB827
298:101290002405215002C03021000038213C0100010A
299:1012A000AC226F10AFA000100C002B3BAFA00014BD
300:1012B0003C110FFF3C0300018C636F043631FFFFCC
301:1012C000024098213C0200018C426F103C0E080045
302:1012D0000071182400031882006E18250051102494
303:1012E00000021082004E1025AE630038AE62007816
304:1012F0008C02021830420040144000042402000115
305:101300003C01000100370821A02240F43C04000108
306:1013100024845EC43C05000124A5E3D03C06000102
307:1013200024C6E52C00C5302327BE003003C0382179
308:1013300027B500340C0017A3AFB500103C01000125
309:10134000AC226EFC00511024000210823C0E0800FA
310:10135000004E1025AE62005032C220001040000640
311:1013600003C038213C02000024425CBC022210244D
312:101370001000000F000210823C04000124845ED89B
313:101380003C05000124A5E5343C06000124C6E6E442
314:1013900000C530230C0017A3AFB500103C010001BD
315:1013A000AC226F1400511024000210823C0E080081
316:1013B000004E1025AE62004832C2400010400005C9
317:1013C00027A700303C02000024425CBC1000000E45
318:1013D000000211003C04000124845EF03C05000181
319:1013E00024A5E6EC3C06000124C6E84400C53023F1
320:1013F00027A200340C0017A3AFA200103C0100018B
321:10140000AC226F0800021100000211823C030800A8
322:1014100000431025AE4200603C04000124845F08B4
323:101420003C05000124A582303C06000124C68650FC
324:1014300000C5302327B100300220382127B3003403
325:101440000C0017A3AFB300103C0E0FFF35CEFFFF0B
326:101450003C04000124845F143C05000024A564685A
327:101460003C06000024C6658800C5302302203821D0
328:101470000240F0213C010001AC226EDC004E102441
329:10148000000210823C15080000551025AFAE004444
330:10149000AFC200B80C0017A3AFB300103C040001AA
331:1014A00024845F203C05000024A565903C060000D4
332:1014B00024C668088FAE004400C5302302203821BE
333:1014C0003C010001AC226ED0004E102400021082BC
334:1014D00000551025AFC200E80C0017A3AFB30010F1
335:1014E0003C04000124845F383C05000024A56810FA
336:1014F0003C06000024C669408FAE004400C530237E
337:10150000022038213C010001AC226EC8004E10249C
338:101510000002108200551025AFC200C00C0017A3B6
339:10152000AFB300103C04000124845F503C0500016F
340:1015300024A5FAD03C06000124C6FBA88FAE0044C7
341:1015400000C53023022038213C010001AC226ED4BA
342:10155000004E10240002108200551025AFC200C8B2
343:101560000C0017A3AFB300103C04000124845F5C9F
344:101570003C05000124A5C93C3C06000124C6CA2044
345:1015800000C5302302203821AF4201100C0017A300
346:10159000AFB300103C04000124845F6C3C050001E3
347:1015A00024A5C9103C06000124C6C93400C5302357
348:1015B00002203821AF4201240C0017A3AFB3001062
349:1015C0003C04000124845F7C3C05000124A55A8072
350:1015D0003C06000124C65AAC00C530230220382145
351:1015E000AF420120AF4201140C0017A3AFB30010AB
352:1015F0003C04000124845F883C05000124A5F29886
353:101600003C06000124C6F6B400C530230220382170
354:10161000AF4201180C0017A3AFB300108FAE004407
355:101620003C010001AC226F18004E10240002108211
356:10163000005510250C003FC3AFC200D00C003C4049
357:10164000000000000C0027A800000000AC000228E9
358:10165000AC00022C96E204502442FFFFAF42003857
359:1016600096E20460AF42008032C2400014400003A2
360:101670000000000096E20480AF42008496E70490E8
361:1016800050E000012407080024E2FFFFAF42008879
362:10169000AF42007C2402080010E2000F32C240007A
363:1016A000104000032402040010E2000B00000000C0
364:1016B000240E00013C04000124845F98A3AE003F87
365:1016C00096E604902405217002C03821AFA00010D6
366:1016D0000C002B3BAFA000148F4301388F4401381E
367:1016E00024020001A34205C2AF430094AF44009816
368:1016F000AFA00010AFA000148F4600808F47008479
369:101700003C04000124845FA40C002B3B2405220030
370:101710000C0024A43C1108003C1433D83694CB5858
371:101720003C020800344200803C04000124845FB085
372:101730003C05000024A55D003C06000024C65D1C9D
373:1017400000C5302327A70030AF8200602402FFFFCE
374:10175000AF82006427A200340C0017A3AFA20010D0
375:101760003C010001AC226EB800021100000211829F
376:10177000005110250C0018FCAE4200008F82024080
377:101780003C03000100431025AF8202403C020000F0
378:1017900024424034AF820244AF8002408F82006016
379:1017A00000511024144000053C0308008F820060A3
380:1017B000004310241040FFFD000000000C003C4DD1
381:1017C000000088213C020100AFA200208F530018C6
382:1017D000240200FF56620001267100018C020228DB
383:1017E0001622000E001330C08F42033C2442000139
384:1017F000AF42033C8F42033C8C0202283C040001B0
385:1018000024845C243C050009AFA00014AFA20010A2
386:101810008FA600201000003F34A5010000D7102142
387:101820008FA300208FA40024AC4304C0AC4404C4A4
388:1018300000C018218F4401788F45017C00001021E1
389:1018400024070004AFA70010AFB100148F48000CAC
390:1018500024C604C002E63021AFA800188F48010C4E
391:101860002407000800A3282100A3482B0082202180
392:101870000100F809008920211440000B240700080A
393:101880008F820120AFA200108F8201243C0400014E
394:1018900024845C2C3C050009AFA200148FA6002014
395:1018A0001000001C34A502008F4401608F450164C4
396:1018B0008F43000CAF5100188F86012024020010C6
397:1018C000AFA20010AFB10014AFA300188F42010CFB
398:1018D0000040F80924C6001C14400010000000005D
399:1018E0008F42034024420001AF4203408F42034035
400:1018F0008F820120AFA200108F8201243C040001DE
401:1019000024845C343C050009AFA200148FA600209B
402:1019100034A503000C002B3B026038218F4202E407
403:1019200024420001AF4202E48F4202E493A2003F4E
404:10193000104000693C02070034423000AFA200288A
405:101940008F530018240200FF126200020000882159
406:10195000267100018C0202281622000E001330C0EE
407:101960008F42033C24420001AF42033C8F42033CC0
408:101970008C0202283C04000124845C243C050009FC
409:10198000AFA00014AFA200108FA600281000003FE7
410:1019900034A5010000D710218FA300288FA4002CAC
411:1019A000AC4304C0AC4404C400C018218F44017887
412:1019B0008F45017C0000102124070004AFA7001010
413:1019C000AFB100148F48000C24C604C002E63021D9
414:1019D000AFA800188F48010C2407000800A3282195
415:1019E00000A3482B008220210100F8090089202152
416:1019F0001440000B240700088F820120AFA20010C2
417:101A00008F8201243C04000124845C2C3C050009E5
418:101A1000AFA200148FA600281000001C34A50200FD
419:101A20008F4401608F4501648F43000CAF51001853
420:101A30008F86012024020010AFA20010AFB1001465
421:101A4000AFA300188F42010C0040F80924C6001C07
422:101A500014400010000000008F42034024420001A7
423:101A6000AF4203408F4203408F820120AFA200109B
424:101A70008F8201243C04000124845C343C0500096D
425:101A8000AFA200148FA6002834A503000C002B3B46
426:101A9000026038218F4202F024420001AF4202F07E
427:101AA0008F4202F03C04000124845FC0AFA000100C
428:101AB000AFA000148FA60028240523000C002B3BA8
429:101AC0000000382110000004000000008C020264B5
430:101AD00010400005000000008F8200A0304200048A
431:101AE0001440FFFA000000008F82004434420004DA
432:101AF000AF8200448F42030824420001AF42030832
433:101B00008F4203088F8200D88F8300D400431023B4
434:101B10002442FF80AF4200908F4200902842FF8114
435:101B200010400006240200018F4200908F430144C0
436:101B300000431021AF42009024020001AF42008C0C
437:101B400032C2000810400006000000008F8202141C
438:101B50003C0381003042FFFF00431025AF82021496
439:101B60003C0300018C636D94306200021040000958
440:101B7000306200013C04000124845FCC3C0500007D
441:101B800024A56D503C06000024C671C81000001248
442:101B900000C5302310400009000000003C04000193
443:101BA00024845FDC3C05000024A571D03C060000C5
444:101BB00024C676781000000800C530233C040001DC
445:101BC00024845FEC3C05000024A569483C06000025
446:101BD00024C66D4800C5302327A7003027A2003453
447:101BE0000C0017A3AFA200103C010001AC226ECC88
448:101BF0003C0200018C426ECC3C0308000002110044
449:101C00000002118200431025AE4200408F8200A0E6
450:101C1000AFA200108F8200B0AFA200148F86005CCC
451:101C20008F87011C3C04000124845FFC3C010001FF
452:101C3000AC366EA43C010001AC206E943C01000166
453:101C4000AC3C6E8C3C010001AC3B6EBC3C01000125
454:101C5000AC376EC03C010001AC3A6EA00C002B3BCF
455:101C6000240524008F820200AFA200108F82022080
456:101C7000AFA200148F8600448F8700503C040001FF
457:101C8000248460080C002B3B240525008F83006012
458:101C90000074100B0242000A0200F821000000004C
459:101CA0000000000D8FBF00608FBE005C8FB5005834
460:101CB0008FB300548FB200508FB1004C8FB00048EA
461:101CC00003E0000827BD006827BDFFE03C040001D9
462:101CD00024846014240526000000302100003821EF
463:101CE000AFBF0018AFA000100C002B3BAFA000143A
464:101CF0008FBF001803E0000827BD002003E00008A4
465:101D00000000000003E000080000000000000000E8
466:101D100000000000000000000000000000000000C3
467:101D200003E000080000000003E0000800000000DD
468:101D300027BDFDE027A500183C04DEAD3484BEEFCE
469:101D4000AFBF02188F8201503C03001F3463FFFFB6
470:101D5000AFA4001800A2282300A328248CA200000E
471:101D60001044000A00000000AFA500108CA2000083
472:101D7000AFA200148F8601508F8702503C040001EF
473:101D80002484601C0C002B3B240527008FBF021805
474:101D900003E0000827BD022027BDFFE03C06ABBAE8
475:101DA00034C6BABEAFB000183C1000043C07007F38
476:101DB00034E7FFFFAFBF001C001028408E04000076
477:101DC0008CA30000ACA00000AE0600008CA20000B6
478:101DD000ACA3000010460005AE04000000A0802166
479:101DE00000F0102B1040FFF5001028403C040001CB
480:101DF00024846028240528000200302100003821B6
481:101E0000AFA000100C002B3BAFA00014020010216B
482:101E10008FBF001C8FB0001803E0000827BD002012
483:101E20008C0202243047003F10E000100080302177
484:101E3000000028212403002000E3102410400002A9
485:101E40000006304200A62821000318421460FFFB60
486:101E500000E310242402F00000A228243402FFFF33
487:101E60000045102B144000033C0200011000000844
488:101E70003C0200013442FFFF008518230043102B71
489:101E80001440000300A010213C02FFFE008210213C
490:101E900003E000080000000027BDFFD0AFB5002818
491:101EA0008FB50040AFB2002000A09021AFB1001C60
492:101EB00024C60003AFBF002CAFB30024AFB000189E
493:101EC0008EA200002403FFFC00C380240050102BCE
494:101ED0001440001B00E088218E330000AFB00010DA
495:101EE0008EA20000AFA200148E270000240530004F
496:101EF0000C002B3B024030218E230000007020217B
497:101F00000064102B10400007024028218CA2000022
498:101F1000AC620000246300040064102B1440FFFB3B
499:101F200024A500048EA2000000501023AEA20000E1
500:101F30008E220000005010211000000BAE22000085
501:101F40002402002DA0820000AFB000108EA200007D
502:101F500002409821AFA200148E2700002405310012
503:101F60000C002B3B02603021026010218FBF002C3F
504:101F70008FB500288FB300248FB200208FB1001CD2
505:101F80008FB0001803E0000827BD003027BDFFE830
506:101F90003C1CC0003C05FFFE3C0300018C636E84CA
507:101FA0003C0400018C846E9034A5BF0824021FFC01
508:101FB0003C010001AC226CD03C0200C03C0100019D
509:101FC000AC226CD43C020020AFBF00103C0100C02A
510:101FD000AC201FFC0043102300441023245BB000FE
511:101FE0000365B8213C1D00018FBD6CCC03A0F0211E
512:101FF0003C0400C0348402003C1A00C03C0300C012
513:10200000346307C824021DFC3C010001AC226CD0E3
514:10201000240218343C010001AC246CD43C010001C2
515:10202000AC226CD03C010001AC236CD40C00180D28
516:10203000375A02008FBF001003E0000827BD0018C8
517:1020400027BDFFC83C04000124846034240532000D
518:102050003C0200018C426CD03C0300018C636CD4C8
519:102060000000302103603821AFBF0030AFB3002C37
520:10207000AFB20028AFB10024AFB00020AFA2001C67
521:10208000AFA30018AFB700100C002B3BAFBA001481
522:102090000C001916000000008F8202403442000438
523:1020A000AF82024024020001AF4200003C02000166
524:1020B00000571021904240F4104000922403FFFC8E
525:1020C0003C1000012610AC733C1200012652A84CB3
526:1020D00002121023004380248FA3001C3C04000143
527:1020E000248460400070102B1440001A27B300189D
528:1020F0008FB100182405300002403021AFB000102D
529:10210000AFA300140C002B3B022038218FA3001832
530:10211000007020210064102B104000070240302185
531:102120008CC20000AC620000246300040064102B29
532:102130001440FFFB24C600048FA2001C0050102393
533:10214000AFA2001C8E620000005010211000000A97
534:10215000AE6200000240882124053100AFB00010BB
535:10216000AFA300148FA70018022030212402002DF5
536:102170000C002B3BA0820000240700208FA3001C32
537:102180003C0400012484605C241200203C01000116
538:10219000AC316EB02C6200201440001D27B1001835
539:1021A0008FB00018240530003C06000124C66F5093
540:1021B000AFA70010AFA300140C002B3B0200382186
541:1021C0008FA300183C04000124846F502465002074
542:1021D0000065102B10400007000000008C820000FA
543:1021E000AC620000246300040065102B1440FFFB68
544:1021F000248400048FA2001C00521023AFA2001CF4
545:102200008E220000005210211000000BAE220000B0
546:102210003C10000126106F5024053100AFA70010BC
547:10222000AFA300148FA70018020030212402002D54
548:102230000C002B3BA0820000240700203C0400017E
549:10224000248460708FA3001C241200203C01000134
550:10225000AC306EE42C6200201440001D27B1001841
551:102260008FB00018240530003C06000124C66F70B2
552:10227000AFA70010AFA300140C002B3B02003821C5
553:102280008FA300183C04000124846F702465002093
554:102290000065102B10400007000000008C82000039
555:1022A000AC620000246300040065102B1440FFFBA7
556:1022B000248400048FA2001C00521023AFA2001C33
557:1022C0008E220000005210211000000BAE220000F0
558:1022D0003C10000126106F7024053100AFA70010DC
559:1022E000AFA300148FA70018020030212402002D94
560:1022F0000C002B3BA08200003C01000110000031CB
561:10230000AC306EE03C1000012610821F3C12000130
562:102310002652809C02121023004380248FA3001CAD
563:102320003C040001248460840070102B1440001AC7
564:1023300027B300188FB10018240530000240302167
565:10234000AFB00010AFA300140C002B3B02203821CB
566:102350008FA30018007020210064102B104000078C
567:10236000024030218CC20000AC62000024630004F3
568:102370000064102B1440FFFB24C600048FA2001C35
569:1023800000501023AFA2001C8E62000000501021EC
570:102390001000000AAE6200000240882124053100CE
571:1023A000AFB00010AFA300148FA700180220302197
572:1023B0002402002D0C002B3BA08200003C010001F8
573:1023C000AC316EB03C0300018C636EB0240204009B
574:1023D0000060F809AF8200708FBF00308FB3002C0F
575:1023E0008FB200288FB100248FB0002003E00008D6
576:1023F00027BD003800000000000000008F82004070
577:102400003C03F000004310243C036000144300062A
578:10241000000000008F8200502403FF80004310243E
579:1024200034420055AF8200508F820054244203E8AA
580:10243000AF820058240201F4AF4200E024020004FD
581:10244000AF4200E824020002AF4001B0AF4000E418
582:10245000AF4200DCAF4000D8AF4000D403E000083A
583:10246000AF4000D08F8200542442000503E00008F2
584:10247000AF82007827BDFFE8AFBF00108F82005405
585:10248000244203E8AF8200583C02080002C2102434
586:10249000104000043C02F7FF3442FFFF02C2B024A8
587:1024A000369400403C0200018C426DA81040001799
588:1024B0003C0202003C0300018C636F1C106000169C
589:1024C0000282A0253C0200018C426E44144000129E
590:1024D0003C0202003C0200018C426D943042000339
591:1024E0001440000D3C0202008F8302243C020002D3
592:1024F0008C428FEC106200083C0202000C003DAFE1
593:1025000000000000100000043C0202000C00419694
594:10251000000000003C02020002C210241040000330
595:10252000000000000C001F4B000000008F4200D88C
596:102530008F4300DC24420001AF4200D80043102B3F
597:102540001440000300000000AF4000D83694008023
598:102550008C0302381060000C000000008F4201B0B4
599:10256000244203E8AF4201B00043102B14400006A0
600:1025700000000000934205C5144000030000000065
601:102580000C001DA0000000008FBF001003E0000839
602:1025900027BD001803E000080000000027BDFFD899
603:1025A000AFBF00208F43002C8F42003810620059CB
604:1025B000000000003C02000100571021904240F052
605:1025C00010400026240700088F4401708F450174D5
606:1025D0008F48000C8F86012024020020AFA200103B
607:1025E000AFA30014AFA800188F42010C0040F809F7
608:1025F00024C6001C14400011240200013C0100010B
609:1026000000370821A02240F08F820124AFA20010E1
610:102610008F8201283C04000124846128AFA20014A9
611:102620008F46002C8F8701203C0500090C002B3BB6
612:1026300034A509001000005C000000008F42030078
613:1026400024420001AF4203008F4203008F42002C5E
614:10265000A34005C110000027AF4200388F4401702D
615:102660008F4501748F43002C8F48000C8F8601200A
616:1026700024020080AFA20010AFA30014AFA800187E
617:102680008F42010C0040F80924C6001C14400011C0
618:10269000240200013C01000100370821A02240F182
619:1026A0008F820124AFA200108F8201283C04000118
620:1026B00024846134AFA200148F46002C8F87012040
621:1026C0003C0500090C002B3B34A51100100000361E
622:1026D000000000008F4203008F43002C24420001C1
623:1026E000AF4203008F42030024020001A34205C150
624:1026F000AF4300383C01000100370821A02040F121
625:102700003C01000100370821A02040F01000002605
626:10271000AF400034934205C11040001D000000008E
627:10272000A34005C18F8200403042000114400008E0
628:10273000000020218C0301042402000150620005E6
629:10274000240400018C020264104000030080102168
630:102750002404000100801021104000060000000049
631:102760008F42030C24420001AF42030C100000080A
632:102770008F42030C8F82004434420004AF82004435
633:102780008F42030824420001AF4203088F4203082E
634:102790003C01000100370821A02040F03C0100016D
635:1027A00000370821A02040F18F42000010400007B0
636:1027B00000000000AF80004C8F82004C1040FFFDF5
637:1027C000000000001000000500000000AF8000487D
638:1027D0008F8200481040FFFD000000008F820060E3
639:1027E0003C03FF7F3463FFFF00431024AF8200608F
640:1027F0008F420000104000030000000010000002A3
641:10280000AF80004CAF8000488FBF002003E000087D
642:1028100027BD002803E000080000000027BDFFD806
643:10282000AFBF00208F4300448F42007C106200291C
644:10283000240700088F4401688F45016C8F48000C05
645:102840008F86012024020040AFA20010AFA3001425
646:10285000AFA800188F42010C0040F80924C6001CE4
647:1028600014400011240200013C010001003708213E
648:10287000A02240F28F820124AFA200108F82012893
649:102880003C0400012484613CAFA200148F46004444
650:102890008F8701203C0500090C002B3B34A5130059
651:1028A0001000000F000000008F42030424420001CA
652:1028B000AF4203048F4203048F420044AF42007CC6
653:1028C0003C01000100370821A02040F21000000464
654:1028D000AF4000783C01000100370821A02040F201
655:1028E0008F4200001040000700000000AF80004C45
656:1028F0008F82004C1040FFFD00000000100000051A
657:1029000000000000AF8000488F8200481040FFFDAB
658:10291000000000008F8200603C03FEFF3463FFFF75
659:1029200000431024AF8200608F420000104000037B
660:102930000000000010000002AF80004CAF80004893
661:102940008FBF002003E0000827BD002803E0000837
662:10295000000000003C0200018C426DA827BDFFA8CA
663:10296000AFBF0050AFBE004CAFB50048AFB300449E
664:10297000AFB20040AFB1003CAFB00038104000D55E
665:102980008F9000448F4200D0244300012842000B66
666:10299000144000E4AF4300D08F42000430420002F4
667:1029A0001440009CAF4000D08F4200043C03000163
668:1029B0008C636D9834420002AF420004240200018F
669:1029C000146200033C020600100000023442300092
670:1029D00034421000AFA200208F4A0018AFAA003482
671:1029E00027AA0020AFAA002C8FAA0034240200FFDF
672:1029F0001142000200001821254300018C02022828
673:102A0000006098211662000E3C0500098F42033CCD
674:102A100024420001AF42033C8F42033C8C02022857
675:102A20008FA700343C0400012484610CAFA0001483
676:102A3000AFA200108FA600201000007034A5050082
677:102A40008FAA0034000A38C000F710218FA300209D
678:102A50008FA40024AC4304C0AC4404C48F8300544E
679:102A60008F820054247103E8022210232C4203E9D0
680:102A70001040001B0000A82100E09021265E04C049
681:102A80008F4401788F45017C02401821240A0004FC
682:102A9000AFAA0010AFB300148F48000C0000102143
683:102AA00002FE3021AFA800188F48010C240700084F
684:102AB00000A3282100A3482B008220210100F8094F
685:102AC0000089202154400006241500018F82005403
686:102AD000022210232C4203E91440FFE90000000009
687:102AE00032A200FF54400018AF5300188F42037801
688:102AF00024420001AF4203788F4203788F82012085
689:102B00008FAA002C8FA70034AFA200108F8201245F
690:102B10003C04000124846118AFA200148D4600001B
691:102B20003C0500091000003534A506008F4203085B
692:102B30002415000124420001AF4203088F4203081C
693:102B40001000001E32A200FF8F8300548F820054B9
694:102B5000247103E8022210232C4203E910400016DE
695:102B60000000A8213C1E0020241200108F42000CFF
696:102B70008F4401608F4501648F860120AFB2001041
697:102B8000AFB30014005E1025AFA200188F42010CF5
698:102B9000240700080040F80924C6001C1440FFE385
699:102BA000000000008F820054022210232C4203E90F
700:102BB0001440FFEE0000000032A200FF144000119C
701:102BC0003C0500098F42037824420001AF4203789C
702:102BD0008F4203788F8201208FAA002C8FA70034A8
703:102BE000AFA200108F8201243C04000124846120E4
704:102BF000AFA200148D46000034A507000C002B3B4B
705:102C0000000000008F4202EC24420001AF4202ECBF
706:102C10008F4202EC8F4200043042000150400029F4
707:102C2000361000403C02040002C210241040001381
708:102C30002404FFDF8F4202508F4302548F4401B4BB
709:102C400014640006361000408F4202708F430274F5
710:102C50008F4401B8106400072402FFDF8F42025046
711:102C60008F4302548F4402708F450274100000128B
712:102C70003A1000201000002B020280248F420250E4
713:102C80008F4302548F4501B414650006020480246A
714:102C90008F4202708F4302748F4401B85064002148
715:102CA000361000408F4202508F4302548F4402700E
716:102CB0008F4502743A100040AF4301B41000001970
717:102CC000AF4501B88F4200D4244300011000001129
718:102CD000284200338F4200043042000110400009B6
719:102CE0003C02040002C21024104000042402FFDF52
720:102CF000020280241000000B361000401000000972
721:102D0000361000608F4200D436100040244300018A
722:102D1000284201F514400003AF4300D4AF4000D473
723:102D20003A100020AF9000442402FF7F0282A024CA
724:102D30008FBF00508FBE004C8FB500488FB300444A
725:102D40008FB200408FB1003C8FB0003803E0000824
726:102D500027BD005803E00008000000003C0200010D
727:102D60008C426DA827BDFFB0AFBF0048AFBE004486
728:102D7000AFB50040AFB3003CAFB20038AFB10034E4
729:102D8000104000C7AFB000308F4200D02443000194
730:102D90002842000B144000DAAF4300D08F420004F9
731:102DA0003042000214400097AF4000D08F42000430
732:102DB0003C0300018C636D9834420002AF42000472
733:102DC00024020001146200033C020600100000020D
734:102DD0003442300034421000AFA20020000018211D
735:102DE0008F5E001827AA0020240200FF13C20002F1
736:102DF000AFAA002C27C300018C020228006090219A
737:102E00001642000E001E38C08F42033C24420001CF
738:102E1000AF42033C8F42033C8C0202283C04000179
739:102E20002484610C3C050009AFA00014AFA200107F
740:102E30008FA600201000006D34A5050000F71021BA
741:102E40008FA300208FA40024AC4304C0AC4404C46E
742:102E50008F8300548F820054247003E802021023F1
743:102E60002C4203E91040001B0000982100E088215B
744:102E7000263504C08F4401788F45017C022018213B
745:102E8000240A0004AFAA0010AFB200148F48000C4F
746:102E90000000102102F53021AFA800188F48010C66
747:102EA0002407000800A3282100A3482B008220212A
748:102EB0000100F80900892021544000062413000174
749:102EC0008F820054020210232C4203E91440FFE9D0
750:102ED00000000000326200FF54400017AF5200189B
751:102EE0008F42037824420001AF4203788F42037877
752:102EF0008F8201208FAA002CAFA200108F820124A4
753:102F00003C040001248461183C050009AFA20014B0
754:102F10008D4600001000003534A506008F420308DE
755:102F20002413000124420001AF4203088F4203082A
756:102F30001000001E326200FF8F8300548F82005405
757:102F4000247003E8020210232C4203E9104000160B
758:102F5000000098213C150020241100108F42000C25
759:102F60008F4401608F4501648F860120AFB100104E
760:102F7000AFB2001400551025AFA200188F42010C0B
761:102F8000240700080040F80924C6001C1440FFE391
762:102F9000000000008F820054020210232C4203E93B
763:102FA0001440FFEE00000000326200FF14400011E8
764:102FB000000000008F42037824420001AF420378F2
765:102FC0008F4203788F8201208FAA002CAFA20010BD
766:102FD0008F8201243C040001248461203C05000907
767:102FE000AFA200148D46000034A507000C002B3B57
768:102FF00003C038218F4202EC24420001AF4202ECB0
769:103000008F4202EC8F420004304200011040001851
770:10301000240400018F4202508F4302548F4501B4B3
771:103020003C01000114650006A0246CF18F4202707F
772:103030008F4302748F4401B8106400210000000027
773:103040008F4202508F4302543C04000190846CF084
774:103050008F4602708F47027438840001AF4301B479
775:10306000AF4701B83C01000110000025A0246CF01E
776:103070008F4200D43C010001A0206CF024430001E9
777:10308000284200331440001EAF4300D43C0200012C
778:1030900090426CF1AF4000D410000017384200019C
779:1030A0008F42000430420001104000080000000080
780:1030B0000C00565A000020213C010001A0206CF1B8
781:1030C0003C0100011000000EA0206CF08F4200D4E3
782:1030D0003C010001A0206CF024430001284201F5CE
783:1030E00014400007AF4300D43C02000190426CF151
784:1030F000AF4000D4004210263C010001A0226CF138
785:103100003C0300018C636D98240200021462000CE1
786:103110003C0300023C03000190636CF124020001B7
787:103120005462001F000020213C02000190426CF01C
788:103130001443001B24040005100000192404000699
789:103140003C0200028C428FF4004310241040000B1C
790:10315000240200013C03000190636CF154620010F2
791:10316000000020213C02000190426CF01443000C4E
792:10317000240400031000000A240400043C0300019E
793:1031800090636CF114620006000020213C020001F3
794:1031900090426CF024040001504400012404000219
795:1031A0000C00565A000000002402FF7F0282A02477
796:1031B0008FBF00488FBE00448FB500408FB3003CE6
797:1031C0008FB200388FB100348FB0003003E00008B8
798:1031D00027BD005003E00008000000003C02000191
799:1031E0008C426DA827BDFFB0AFBF0048AFBE004402
800:1031F000AFB50040AFB3003CAFB20038AFB1003460
801:10320000104000DEAFB000308F4200D03C0400011F
802:103210008C846D98244300012842000BAF4400E8E1
803:10322000144000FEAF4300D08F4200043042000241
804:1032300014400095AF4000D08F4200043442000299
805:10324000AF42000424020001148200033C02060085
806:10325000100000023442300034421000AFA20020BF
807:10326000000018218F5E001827AA0020240200FF0A
808:1032700013C20002AFAA002C27C300018C0202284F
809:10328000006090211642000E001E38C08F42033CA1
810:1032900024420001AF42033C8F42033C8C020228CF
811:1032A0003C0400012484610C3C050009AFA000141B
812:1032B000AFA200108FA600201000006D34A50500FD
813:1032C00000F710218FA300208FA40024AC4304C07A
814:1032D000AC4404C48F8300548F820054247003E8EC
815:1032E000020210232C4203E91040001B0000982129
816:1032F00000E08821263504C08F4401788F45017C89
817:1033000002201821240A0004AFAA0010AFB2001452
818:103310008F48000C0000102102F53021AFA80018E2
819:103320008F48010C2407000800A3282100A3482B84
820:10333000008220210100F809008920215440000664
821:10334000241300018F820054020210232C4203E94F
822:103350001440FFE900000000326200FF54400017F3
823:10336000AF5200188F42037824420001AF42037825
824:103370008F4203788F8201208FAA002CAFA2001009
825:103380008F8201243C040001248461183C0500095B
826:10339000AFA200148D4600001000003534A50600D1
827:1033A0008F4203082413000124420001AF420308A6
828:1033B0008F4203081000001E326200FF8F8300540A
829:1033C0008F820054247003E8020210232C4203E988
830:1033D00010400016000098213C1500202411001018
831:1033E0008F42000C8F4401608F4501648F8601205D
832:1033F000AFB10010AFB2001400551025AFA20018F5
833:103400008F42010C240700080040F80924C6001C64
834:103410001440FFE3000000008F82005402021023DA
835:103420002C4203E91440FFEE00000000326200FF6E
836:1034300014400011000000008F4203782442000174
837:10344000AF4203788F4203788F8201208FAA002C2D
838:10345000AFA200108F8201243C040001248461206B
839:103460003C050009AFA200148D46000034A50700FA
840:103470000C002B3B03C038218F4202EC2442000198
841:10348000AF4202EC8F4202EC8F4200043042000156
842:10349000104000333C02040002C210241040001708
843:1034A00000000000934205C08F4402508F45025433
844:1034B0008F4301B43442002014A30006A34205C088
845:1034C0008F4202708F4302748F4401B81064000869
846:1034D000000000008F4202508F430254934405C005
847:1034E0008F4602708F470274100000163884004027
848:1034F000934205C010000048304200BF934205C00F
849:103500008F4402508F4502548F4301B4304200BFB4
850:1035100014A30006A34205C08F4202708F430274B9
851:103520008F4401B81064000B000000008F4202506D
852:103530008F430254934405C08F4602708F47027434
853:1035400038840020AF4301B4AF4701B81000003306
854:10355000A34405C0934205C01000002F3442002050
855:10356000934205C08F4300D434420020A34205C0DB
856:103570002462000110000023286300338F4200E41E
857:103580008F4300E024420001AF4200E40043102AD0
858:1035900014400006240300018F4200E81443000297
859:1035A000AF4000E424030004AF4300E88F4200046E
860:1035B000304200011040000D3C02040002C2102401
861:1035C0001040000700000000934205C03442004054
862:1035D000A34205C0934205C01000000F304200DF37
863:1035E000934205C01000000C34420060934205C0B5
864:1035F0008F4300D434420020A34205C0246200015E
865:10360000286300FB14600005AF4200D4934205C05C
866:10361000AF4000D438420040A34205C0934205C0E9
867:103620008F4300E83042007FA34205C0240200011E
868:103630001462000500000000934405C0000421024C
869:1036400010000003348400F0934405C03484000F5C
870:103650000C005640000000002402FF7F0282A024DC
871:103660008FBF00488FBE00448FB500408FB3003C31
872:103670008FB200388FB100348FB0003003E0000803
873:1036800027BD005003E000080000000027BDFFB088
874:10369000274401C026E30028246504000065102BA0
875:1036A000AFBF0048AFBE0044AFB50040AFB3003C71
876:1036B000AFB20038AFB1003410400007AFB00030F7
877:1036C0008C820000AC620000246300040065102BB3
878:1036D0001440FFFB248400048C020080AEE200440E
879:1036E0008C0200C0AEE200408C020084AEE20030EA
880:1036F0008C020084AEE2023C8C020088AEE2024002
881:103700008C02008CAEE202448C020090AEE20248D1
882:103710008C020094AEE2024C8C020098AEE20250A1
883:103720008C02009CAEE202548C0200A0AEE2025871
884:103730008C0200A4AEE2025C8C0200A8AEE2026041
885:103740008C0200ACAEE202648C0200B0AEE2026811
886:103750008C0200B4AEE2026C8C0200B8AEE20270E1
887:103760008C0200BC24040001AEE20274AEE000341E
888:1037700000041080005710218EE300348C42023C7C
889:1037800024840001006218212C82000FAEE3003473
890:103790001440FFF8000410808C0200CCAEE2004818
891:1037A0008C0200D0AEE2004C8C0200E0AEE201F8E8
892:1037B0008C0200E4AEE201FC8C0200E8AEE2020002
893:1037C0008C0200ECAEE202048C0200F0AEE20208D1
894:1037D0008EE400C08EE500C48C0200FC0045102B76
895:1037E0001040000B000000008EE200C08EE300C419
896:1037F0002404000124050000006518210065302B19
897:103800000044102100461021AEE200C0AEE300C427
898:103810008C0200FC8EE400C08EE500C42408FFFF8B
899:1038200024090000004018210000102100882024F5
900:1038300000A928240082202500A32825AEE400C08A
901:10384000AEE500C48EE400D08EE500D48C0200F416
902:103850000045102B1040000B000000008EE200D04D
903:103860008EE300D424040001240500000065182123
904:103870000065302B0044102100461021AEE200D03C
905:10388000AEE300D48C0200F48EE400D08EE500D4C8
906:1038900000401821000010210088202400A92824BD
907:1038A0000082202500A32825AEE400D0AEE500D498
908:1038B0008EE400C88EE500CC8C0200F80045102B89
909:1038C0001040000B000000008EE200C88EE300CC28
910:1038D0002404000124050000006518210065302B38
911:1038E0000044102100461021AEE200C8AEE300CC37
912:1038F0008C0200F88EE400C88EE500CC0040182150
913:10390000000010210088202400A9282400822025FE
914:1039100000A3282524020008AEE400C8AEE500CCD0
915:10392000AFA20010AFA000148F42000C8C0402085C
916:103930008C05020CAFA200188F42010C26E600286D
917:103940000040F80924070400104000F03C02040085
918:10395000AFA20020934205C6104000890000182144
919:103960008F5E001827AA0020240200FF13C2000265
920:10397000AFAA002C27C300018C020228006090210E
921:103980001642000E001E38C08F42033C2442000144
922:10399000AF42033C8F42033C8C0202283C040001EE
923:1039A0002484610C3C050009AFA00014AFA20010F4
924:1039B0008FA600201000006B34A5050000F7102131
925:1039C0008FA300208FA40024AC4304C0AC4404C4E3
926:1039D0008F8300548F820054247003E80202102366
927:1039E0002C4203E91040001B0000982100E08821D0
928:1039F000263504C08F4401788F45017C02201821B0
929:103A0000240A0004AFAA0010AFB200148F48000CC3
930:103A10000000102102F53021AFA800188F48010CDA
931:103A20002407000800A3282100A3482B008220219E
932:103A30000100F809008920215440000624130001E8
933:103A40008F820054020210232C4203E91440FFE944
934:103A500000000000326200FF54400017AF5200180F
935:103A60008F42037824420001AF4203788F420378EB
936:103A70008F8201208FAA002CAFA200108F82012418
937:103A80003C040001248461183C050009AFA2001425
938:103A90008D4600001000003334A506008F42030855
939:103AA0002413000124420001AF4203088F4203089F
940:103AB0001000001C326200FF8F8300548F8200547C
941:103AC000247003E8020210232C4203E91040001482
942:103AD00000009821241100108F42000C8F440160D7
943:103AE0008F4501648F860120AFB10010AFB2001482
944:103AF000AFA200188F42010C240700080040F8090B
945:103B000024C6001C1440FFE5000000008F82005412
946:103B1000020210232C4203E91440FFEF00000000D2
947:103B2000326200FF54400012240200018F420378E9
948:103B300024420001AF4203788F4203788F82012034
949:103B40008FAA002CAFA200108F8201243C04000138
950:103B5000248461203C050009AFA200148D460000BA
951:103B600034A507000C002B3B03C0382100001021B6
952:103B70001440005B240200011000006500000000FA
953:103B80008F510018240200FF122200020000802141
954:103B9000263000018C0202281602000E001130C0EF
955:103BA0008F42033C24420001AF42033C8F42033C5E
956:103BB0008C0202283C040001248460F43C050009C6
957:103BC000AFA00014AFA200108FA600201000003F8D
958:103BD00034A5010000D710218FA300208FA400245A
959:103BE000AC4304C0AC4404C400C018218F44017825
960:103BF0008F45017C0000102124070004AFA70010AE
961:103C0000AFB000148F48000C24C604C002E6302177
962:103C1000AFA800188F48010C2407000800A3282132
963:103C200000A3482B008220210100F80900892021EF
964:103C30001440000B240700088F820120AFA200105F
965:103C40008F8201243C040001248460FC3C050009AF
966:103C5000AFA200148FA600201000001C34A50200A3
967:103C60008F4401608F4501648F43000CAF500018F2
968:103C70008F86012024020010AFA20010AFB0001404
969:103C8000AFA300188F42010C0040F80924C6001CA5
970:103C900054400011240200018F42034024420001DD
971:103CA000AF4203408F4203408F820120AFA2001039
972:103CB0008F8201243C040001248461043C05000936
973:103CC000AFA200148FA6002034A503000C002B3BEC
974:103CD00002203821000010211040000D24020001B4
975:103CE0008F4202E8A34005C6AF4001B02442000164
976:103CF000AF4202E88F4202E88EE201502442000106
977:103D0000AEE20150100000038EE2015024020001D7
978:103D1000A34205C68FBF00488FBE00448FB5004048
979:103D20008FB3003C8FB200388FB100348FB00030B9
980:103D300003E0000827BD005027BDFFD8AFBF00201B
981:103D40008F8200B030420004104000680000000084
982:103D50008F4301288F8201041462000500000000D7
983:103D60008F4301308F8200B4106200060000000013
984:103D70008F820104AF4201288F8200B41000005BE3
985:103D8000AF4201308F8200B03C030080004310241A
986:103D90001040000D000000008F82011C3442000220
987:103DA000AF82011C8F8200B02403FFFB004310246C
988:103DB000AF8200B08F82011C2403FFFD004310245A
989:103DC0001000004AAF82011C8F4301288F8201043A
990:103DD00014620005000000008F4301308F8200B4A0
991:103DE00010620010000000008F820104AF42012821
992:103DF0008F8200B48F430128AF420130AFA300107F
993:103E00008F4201303C04000124846144AFA20014BD
994:103E10008F86011C8F8700B03C0500051000003123
995:103E200034A509008F420128AFA200108F42013053
996:103E30003C04000124846150AFA200148F86011C51
997:103E40008F8700B03C0500050C002B3B34A510000B
998:103E50008F82011C34420002AF82011C8F83010457
999:103E60008F8200B034420001AF8200B0240200080B
1000:103E7000AF830104AFA20010AFA000148F42000C6A
1001:103E80008C0402088C05020CAFA200188F42010CB2
1002:103E900026E600280040F809240704008F82011C50
1003:103EA0002403FFFD00431024AF82011C8EE201DCDD
1004:103EB00024420001AEE201DC8EE201DC8F420128E7
1005:103EC000AFA200108F4201303C0400012484615CE9
1006:103ED000AFA200148F86011C8F8700B03C0500053F
1007:103EE00034A511000C002B3B000000008F8200A0C5
1008:103EF0003042000410400069000000008F43012C94
1009:103F00008F82012414620005000000008F430134F9
1010:103F10008F8200A410620006000000008F8201243E
1011:103F2000AF42012C8F8200A41000005CAF4201342C
1012:103F30008F8200A03C030080004310241040000D3D
1013:103F4000000000008F82011C34420002AF82011C7D
1014:103F50008F8200A02403FFFB00431024AF8200A047
1015:103F60008F82011C2403FFFD004310241000004B2E
1016:103F7000AF82011C8F43012C8F8201241462000543
1017:103F8000000000008F4301348F8200A410620010F3
1018:103F9000000000008F820124AF42012C8F8200A418
1019:103FA0008F43012CAF420134AFA300108F42013484
1020:103FB0003C04000124846168AFA200148F86011CB8
1021:103FC0008F8700A03C0500051000003234A51200C8
1022:103FD0008F42012CAFA200108F4201343C0400013B
1023:103FE00024846174AFA200148F86011C8F8700A007
1024:103FF0003C0500050C002B3B34A513008F82011CEF
1025:1040000034420002AF82011C8F8301248F8200A002
1026:1040100034420001AF8200A024020080AF8301245B
1027:10402000AFA20010AFA000148F4200148C0402084D
1028:104030008C05020CAFA200188F4201083C0600015B
1029:1040400024C66ED80040F809240700048F82011CA2
1030:104050002403FFFD00431024AF82011C8EE201DC2B
1031:1040600024420001AEE201DC8EE201DC8F42012C31
1032:10407000AFA200108F4201343C040001248461800F
1033:10408000AFA200148F86011C8F8700A03C0500059D
1034:1040900034A514000C002B3B000000008FBF002053
1035:1040A00003E0000827BD00283C0810002407000199
1036:1040B0003C0600803C0501008F82007000481024FF
1037:1040C0001040FFFD000000008F82005424420005D4
1038:1040D000AF8200788C040234108000160000182192
1039:1040E0003C020001005710218C4240E824420005A8
1040:1040F0003C01000100370821AC2240E83C020001ED
1041:10410000005710218C4240E80044102B1440000955
1042:10411000000000003C0300803C0100010037082142
1043:10412000AC2040E83C010001003708211000000BE2
1044:10413000A02740F03C02000100571021904240F0BF
1045:1041400054400006006618253C020001005710216B
1046:10415000904240F154400001006618258C04023062
1047:1041600010800013000000003C02000100571021E5
1048:104170008C4240EC244200053C010001003708213C
1049:10418000AC2240EC3C020001005710218C4240EC74
1050:104190000044102B14400006000000003C01000108
1051:1041A00000370821AC2040EC1000000600651825FF
1052:1041B0003C02000100571021904240F2544000019F
1053:1041C000006518251060FFBC000000008F42000051
1054:1041D0001040000700000000AF80004C8F82004CB0
1055:1041E0001040FFFD0000000010000005000000006E
1056:1041F000AF8000488F8200481040FFFD00000000A3
1057:104200008F82006000431025AF8200608F42000063
1058:1042100010400003000000001000FFA7AF80004C1A
1059:104220001000FFA5AF80004803E000080000000078
1060:1042300000000000000000000000000027BDFFE0BB
1061:10424000AFBF00188F86006430C200041040002504
1062:10425000240400048C020114AF420020AF840064E7
1063:104260008F4202FC24420001AF4202FC8F4202FC5A
1064:104270008F820064304200041440000500000000FA
1065:104280008C0301148F4200201462FFF20000000032
1066:104290008F420000104000078F43003CAF80004C6D
1067:1042A0008F82004C1040FFFD000000001000000550
1068:1042B00000000000AF8000488F8200481040FFFDE2
1069:1042C000000000008F82006000431025AF82006074
1070:1042D0008F42000010400073000000001000006FCB
1071:1042E0000000000030C20008104000202404000834
1072:1042F0008C02011CAF420048AF8400648F4202A8C8
1073:1043000024420001AF4202A88F4202A88F820064BB
1074:104310003042000814400005000000008C03011C1E
1075:104320008F4200481462FFF2000000008F4200003C
1076:104330001040000700000000AF80004C8F82004C4E
1077:104340001040FFFD0000000010000005000000000C
1078:10435000AF8000488F8200481040FFFD0000000041
1079:104360008F8200601000FFD93442020030C200206A
1080:1043700010400023240400208C02012CAF4200686E
1081:10438000AF8400648F4202D824420001AF4202D8B9
1082:104390008F4202D88F820064304200201440000512
1083:1043A00032C240008C03012C8F4200681462FFF27D
1084:1043B00032C24000144000023C02000102C2B0259B
1085:1043C0008F4200001040000700000000AF80004C4A
1086:1043D0008F82004C1040FFFD00000000100000051F
1087:1043E00000000000AF8000488F8200481040FFFDB1
1088:1043F000000000008F8200601000FFB4344208000B
1089:1044000030C2001010400029240400108C02012446
1090:10441000AF420058AF8400648F4202D424420001AE
1091:10442000AF4202D48F4202D48F8200643042001027
1092:104430001440000532C220008C0301248F42005832
1093:104440001462FFF232C220005040000136D68000D4
1094:104450008F4200001040000700000000AF80004CB9
1095:104460008F82004C1040FFFD00000000100000058E
1096:1044700000000000AF8000488F8200481040FFFD20
1097:10448000000000008F82006034420100AF820060B3
1098:104490008F42000010400003000000001000006C7C
1099:1044A000AF80004C1000006AAF80004830C20001AD
1100:1044B0001040000424020001AF8200641000006478
1101:1044C0000000000030C200021440000B3C05000355
1102:1044D0003C0400012484624434A505000000382116
1103:1044E000AFA000100C002B3BAFA000142402FFC0B3
1104:1044F00010000057AF8200648C05022C8C02010C66
1105:1045000010A20048000510808C46030024A2000180
1106:104510003045003F24020003AC05022C00061E02B9
1107:1045200010620005240200101062001D30C20FFF4F
1108:1045300010000039000000008F4302A88F440000E3
1109:1045400030C20FFFAF42004824630001AF4302A80E
1110:10455000108000078F4202A8AF80004C8F82004C71
1111:104560001040FFFD000000001000000500000000EA
1112:10457000AF8000488F8200481040FFFD000000001F
1113:104580008F82006034420200AF8200608F420000E0
1114:104590001040001F000000001000001B0000000081
1115:1045A000AF42005832C220005040000136D6800091
1116:1045B0008F4202D48F43000024420001AF4202D454
1117:1045C000106000078F4202D4AF80004C8F82004CF5
1118:1045D0001040FFFD0000000010000005000000007A
1119:1045E000AF8000488F8200481040FFFD00000000AF
1120:1045F0008F82006034420100AF8200608F42000071
1121:10460000104000030000000010000006AF80004CC6
1122:1046100010000004AF8000480C00219600C020214B
1123:10462000004028218C02010C14A200022402000286
1124:10463000AF8200648F8200643042000214400004A4
1125:10464000000000008C02010C14A2FFAC000000006E
1126:104650008FBF001803E0000827BD002003E000081A
1127:104660000000000027BDFFA0AFB000400080802107
1128:10467000001016022442FFFF304300FF2C6200139B
1129:10468000AFBF0058AFBE0054AFB50050AFB3004C41
1130:10469000AFB20048AFB10044104001F3AFA5003401
1131:1046A000000310803C010001002208218C22628856
1132:1046B00000400008000000000010130230440FFF0B
1133:1046C0002402000110820005240200021082000C66
1134:1046D0002402FFFE100000243C0500038F43000469
1135:1046E0003C0200018C426F04AF440200AF4402045C
1136:1046F0003C0400018C846E801000000934630001CA
1137:104700008F430004AF440200AF4402043C040001A4
1138:104710008C846E80006218243C0200012442CA2866
1139:104720000002110000021182AF4300043C030800A4
1140:1047300000431025AC8200388F84005400041442DA
1141:1047400000041C820043102100041CC200431023FB
1142:1047500000041D020043102100041D4200431023E9
1143:1047600010000009AF4202083C040001248462509A
1144:1047700034A510000200302100003821AFA0001045
1145:104780000C002B3BAFA000148F4202A0244200017A
1146:10479000AF4202A01000021F8F4202A027B00028E3
1147:1047A00002002021240502100C002BBF2406000863
1148:1047B0000C00251802002021100002160000000045
1149:1047C0008FAA003427A40028000A1880254200017F
1150:1047D0003042003FAFA200348C6503008FAA003442
1151:1047E000000210808C430300254200013042003F4C
1152:1047F000AFA20034AC02022CAFA500280C00251893
1153:10480000AFA3002C100002030000000027B0002816
1154:1048100002002021240502100C002BBF24060008F2
1155:104820000C00265702002021100001FA00000000B1
1156:104830008FAA003427A40028000A1880254200010E
1157:104840003042003FAFA200348C6503008FAA0034D1
1158:10485000000210808C430300254200013042003FDB
1159:10486000AFA20034AC02022CAFA500280C002657E2
1160:10487000AFA3002C100001E700000000001013029D
1161:1048800030430FFF240200011062000524020002E1
1162:104890001062001E3C020002100000333C050003C1
1163:1048A0003C03000202C310245440003702C3B02569
1164:1048B0008F8202283C01000100370821AC2238D841
1165:1048C0008F82022C3C01000100370821AC2238DC29
1166:1048D0008F8202303C01000100370821AC2238E011
1167:1048E0008F8202343C01000100370821AC2238E4F9
1168:1048F0002402FFFFAF820228AF82022CAF82023077
1169:10490000AF8202341000002002C3B02502C210247E
1170:10491000104000123C02FFFD3C0200010057102134
1171:104920008C4238D8AF8202283C0200010057102187
1172:104930008C4238DCAF82022C3C020001005710216F
1173:104940008C4238E0AF8202303C0200010057102157
1174:104950008C4238E4AF8202343C02FFFD3442FFFF58
1175:104960001000000902C2B0243C0400012484625CEF
1176:1049700034A511000200302100003821AFA0001042
1177:104980000C002B3BAFA000148F4202CC244200014C
1178:10499000AF4202CC1000019F8F4202CC00101302E4
1179:1049A00030450FFF2402000110A20005240200027E
1180:1049B00010A2000D3C0408FF100000143C05000389
1181:1049C0003C0208FF3442FFFF8F8302203C040004B6
1182:1049D00002C4B0250062182434630008AF830220AB
1183:1049E00010000012AF4502983484FFF73C03FFFB30
1184:1049F0008F8202203463FFFF02C3B02400441024DE
1185:104A0000AF82022010000009AF4502983C0400016B
1186:104A10002484626834A5120002003021000038218D
1187:104A2000AFA000100C002B3BAFA000148F4202BCC3
1188:104A300024420001AF4202BC100001768F4202BC4A
1189:104A400027840208240502000C002BBF240600085E
1190:104A500027440224240502000C002BBF2406000872
1191:104A60008F4202C424420001AF4202C41000016917
1192:104A70008F4202C40010130230430FFF24020001D2
1193:104A8000106200112862000250400005240200025A
1194:104A90001060000700000000100000170000000078
1195:104AA0001062000F00000000100000130000000062
1196:104AB0008C060248000020210C005104240500044B
1197:104AC00010000007000000008C06024800002021B2
1198:104AD0000C00510424050004100000100000000028
1199:104AE0008C06024C000020210C005104240500011A
1200:104AF0001000000A000000003C04000124846274DD
1201:104B00003C05000334A513000200302100003821C9
1202:104B1000AFA000100C002B3BAFA000148F4202C0CE
1203:104B200024420001AF4202C01000013A8F4202C08D
1204:104B30000C002426000000001000013600000000D8
1205:104B400024020001A34205C5241001008F4401A8DE
1206:104B50008F4501ACAFB00010AFA000148F4200141D
1207:104B6000AFA200188F42010826E600280040F8098D
1208:104B7000240704001040FFF500000000100001258C
1209:104B8000000000003C03FFFF34637FFF8F42036897
1210:104B90008F44036002C3B02400001821AF400058C6
1211:104BA000AF40005CAF400060AF40006400441023A1
1212:104BB000AF4203683C020900AF400360AFA200208F
1213:104BC0008F5E001827AA0020240200FF13C20002F3
1214:104BD000AFAA003C27C300018C020228006090218C
1215:104BE0001642000E001E38C08F42033C24420001D2
1216:104BF000AF42033C8F42033C8C0202283C0400017C
1217:104C00002484620C3C050009AFA00014AFA2001080
1218:104C10008FA600201000006B34A5050000F71021BE
1219:104C20008FA300208FA40024AC4304C0AC4404C470
1220:104C30008F8300548F820054247003E802021023F3
1221:104C40002C4203E91040001B0000982100E088215D
1222:104C5000263504C08F4401788F45017C022018213D
1223:104C6000240A0004AFAA0010AFB200148F48000C51
1224:104C70000000102102F53021AFA800188F48010C68
1225:104C80002407000800A3282100A3482B008220212C
1226:104C90000100F80900892021544000062413000176
1227:104CA0008F820054020210232C4203E91440FFE9D2
1228:104CB00000000000326200FF54400017AF5200189D
1229:104CC0008F42037824420001AF4203788F42037879
1230:104CD0008F8201208FAA003CAFA200108F82012496
1231:104CE0003C040001248462183C050009AFA20014B2
1232:104CF0008D4600001000003334A506008F420308E3
1233:104D00002413000124420001AF4203088F4203082C
1234:104D10001000001C326200FF8F8300548F82005409
1235:104D2000247003E8020210232C4203E9104000140F
1236:104D300000009821241100108F42000C8F44016064
1237:104D40008F4501648F860120AFB10010AFB200140F
1238:104D5000AFA200188F42010C240700080040F80998
1239:104D600024C6001C1440FFE5000000008F820054A0
1240:104D7000020210232C4203E91440FFEF0000000060
1241:104D8000326200FF14400011000000008F420378DF
1242:104D900024420001AF4203788F4203788F820120C2
1243:104DA0008FAA003CAFA200108F8201243C040001B6
1244:104DB000248462203C050009AFA200148D46000047
1245:104DC00034A507000C002B3B03C038218F4202B0F2
1246:104DD00024420001AF4202B08F4202B08F4202F87B
1247:104DE00024420001AF4202F81000008A8F4202F80C
1248:104DF0008C02025C27440224AF4201F08C02026064
1249:104E000024050200240600080C002BBFAF4201F865
1250:104E10008F82022030420008144000022402000168
1251:104E200024020002AF4202988F4202AC24420001E9
1252:104E3000AF4202AC100000778F4202AC3C0200FF90
1253:104E40003442FFFF0202182432C2018014400006DF
1254:104E50003402FFFB0043102B14400003000000004D
1255:104E60001000006CAF4300BC3C040001248462804D
1256:104E70003C05000334A51500020030210000382154
1257:104E8000AFA000100C002B3BAFA000143C020700A9
1258:104E90003442100000101E0200621825AFA300204B
1259:104EA0008F510018240200FF12220002000080210E
1260:104EB000263000018C0202281602000E001130C0BC
1261:104EC0008F42033C24420001AF42033C8F42033C2B
1262:104ED0008C0202283C040001248461F43C05000992
1263:104EE000AFA00014AFA200108FA600201000003F5A
1264:104EF00034A5010000D710218FA300208FA4002427
1265:104F0000AC4304C0AC4404C400C018218F440178F1
1266:104F10008F45017C0000102124070004AFA700107A
1267:104F2000AFB000148F48000C24C604C002E6302144
1268:104F3000AFA800188F48010C2407000800A32821FF
1269:104F400000A3482B008220210100F80900892021BC
1270:104F50001440000B240700088F820120AFA200102C
1271:104F60008F8201243C040001248461FC3C0500097B
1272:104F7000AFA200148FA600201000001C34A5020070
1273:104F80008F4401608F4501648F43000CAF500018BF
1274:104F90008F86012024020010AFA20010AFB00014D1
1275:104FA000AFA300188F42010C0040F80924C6001C72
1276:104FB00014400010000000008F4203402442000112
1277:104FC000AF4203408F4203408F820120AFA2001006
1278:104FD0008F8201243C040001248462043C05000902
1279:104FE000AFA200148FA6002034A503000C002B3BB9
1280:104FF000022038218F4202E024420001AF4202E049
1281:105000008F4202E08F4202F024420001AF4202F0E0
1282:105010008F4202F08FA200348FBF00588FBE005421
1283:105020008FB500508FB3004C8FB200488FB1004451
1284:105030008FB0004003E0000827BD006027BDFFF8E7
1285:105040002408FFFF10A00014000048213C0AEDB81E
1286:10505000354A83209087000024840001000030211D
1287:1050600001071026304200011040000200081842DB
1288:10507000006A18260060402124C600012CC20008E6
1289:105080001440FFF700073842252900010125102BA5
1290:105090001440FFF0000000000100102103E00008B0
1291:1050A00027BD000827BDFFB0AFBF0048AFBE00441A
1292:1050B000AFB50040AFB3003CAFB20038AFB1003481
1293:1050C000AFB000308F870220AFA700248F87020087
1294:1050D000AFA7002C8F8202203C0308FF3463FFFF40
1295:1050E0000043102434420004AF8202208F82020069
1296:1050F0003C03C0FF3463FFFF00431024344200042C
1297:10510000AF8202008F5303588F55035C8F5E03609C
1298:105110008F470364AFA700148F470368AFA7001C35
1299:105120008F4202D0274401C024420001AF4202D086
1300:105130008F5002D08F5102048F5202000C002BA816
1301:1051400024050400AF530358AF55035CAF5E036002
1302:105150008FA70014AF4703648FA7001CAF470368F5
1303:10516000AF5002D0AF510204AF5202008C02025C79
1304:1051700027440224AF4201F08C02026024050200A1
1305:1051800024060008AF4201F8240200060C002BBFE1
1306:10519000AF4201F43C023B9A3442CA00AF4201FCE8
1307:1051A000240203E82404000224030001AF42029415
1308:1051B000AF440290AF43029C8F820220304200082D
1309:1051C0001040000400000000AF43029810000003EC
1310:1051D00000003021AF440298000030213C03000160
1311:1051E0000066182190636D000346102124C600015B
1312:1051F000A043022C2CC2000F1440FFF803461821D4
1313:1052000024C600018F820040240400802405008011
1314:105210000002170224420030A062022C0346102133
1315:105220000C002BA8A040022C8FA7002430E2000421
1316:1052300014400006000000008F8202203C0308FF9B
1317:105240003463FFFB00431024AF8202208FA7002CA1
1318:1052500030E2000414400006000000008F820200CB
1319:105260003C03C0FF3463FFFB00431024AF82020005
1320:105270008FBF00488FBE00448FB500408FB3003C05
1321:105280008FB200388FB100348FB0003003E00008D7
1322:1052900027BD00500000000000000000AF400104E6
1323:1052A00024040001000410C002E21821248200013D
1324:1052B0003C01000100230821A42234D00040202119
1325:1052C0002C8200801440FFF8000410C0240200016A
1326:1052D0003C01000100370821A42038D0AF42010072
1327:1052E000AF800228AF80022CAF800230AF80023442
1328:1052F00003E000080000000027BDFFE8AFBF001476
1329:10530000AFB000108F420104284200051040002673
1330:10531000008080213C0200018F430104344230D0E0
1331:1053200002E22021000318C00062182102E31821C4
1332:105330000083102B1040001500001021960700007C
1333:1053400024840006246600069482FFFC14470009AA
1334:10535000000028219483FFFE9602000214620006DA
1335:1053600000A0102194820000960300040043102640
1336:105370002C45000100A010211440000924840008DD
1337:105380000086102B1440FFF000001021304200FF77
1338:1053900014400030240200011000002E00001021F3
1339:1053A0001000FFFA24020001020020210C00240C4E
1340:1053B000240500063042007F000218C002E31021DD
1341:1053C0003C01000100220821942230D01040FFF25D
1342:1053D00002E310213C06000100C2302194C630D007
1343:1053E00010C0FFED3C080001350834D296070000DC
1344:1053F000000610C000572021008820219482000060
1345:10540000144700090000282194830002960200023C
1346:105410001462000600A01021948200049603000488
1347:10542000004310262C45000100A010211440000765
1348:10543000000610C002E210213C06000100C230212B
1349:1054400094C634D014C0FFEB000610C010C0FFD2C9
1350:10545000240200018FBF00148FB0001003E0000889
1351:1054600027BD001803E000080000000027BDFFB0C2
1352:1054700000801021AFB00030245000020200202133
1353:1054800024050006AFB1003400408821AFBF0048BA
1354:10549000AFBE0044AFB50040AFB3003C0C00240CDD
1355:1054A000AFB200383047007F000710C002E2102181
1356:1054B0003C05000100A2282194A530D050A0001C7A
1357:1054C00000A030213C090001352934D29628000281
1358:1054D000000510C00057202100892021948200007F
1359:1054E0001448000900003021948300029602000253
1360:1054F0001462000600C01021948200049603000488
1361:10550000004310262C46000100C010211440000763
1362:10551000000510C002E210213C05000100A2282174
1363:1055200094A534D014A0FFEB000510C000A03021DA
1364:1055300010C00014000610C0005718213C010001E3
1365:10554000002308218C2334D000571021AFA3001072
1366:105550003C010001002208218C2234D43C040001CB
1367:1055600024846394AFA200148E2600008E270004CA
1368:105570003C0500040C002B3B34A504001000006324
1369:105580003C0208008F45010010A00006000510C075
1370:1055900002E210213C01000100220821942234D0B3
1371:1055A000AF42010000A0302114C00011000628C045
1372:1055B000000710C002E21021AFA700103C0100015B
1373:1055C00000220821942230D03C040001248463A0EE
1374:1055D000AFA200148E2600008E2700043C050004B4
1375:1055E0000C002B3B34A50500100000483C020800CD
1376:1055F00000B718213C02000196040000344234D266
1377:1056000000621821A46400008E020002000720C07E
1378:10561000AC62000202E410213C0300010062182188
1379:10562000946330D002E510213C01000100220821E2
1380:10563000A42334D002E410213C01000100220821FF
1381:10564000A42630D08F420104244200012842008069
1382:105650001040000F3C0200028F4201043C04000194
1383:10566000348430D296030000000210C0005710218D
1384:1056700000441021A44300008E030002AC4300024A
1385:105680008F42010424420001AF4201043C020002A7
1386:1056900002C2102410400011000721423C03000107
1387:1056A000346338D824020003004410230002108021
1388:1056B0000057202100832021005710210043102192
1389:1056C00030E5001F8C4300002402000100A21004FA
1390:1056D000006218251000000CAC83000024020003B7
1391:1056E0000044102300021080005C2821005C10217F
1392:1056F00030E4001F8C4302282402000100821004C1
1393:1057000000621825ACA302283C02080034421000B5
1394:1057100000001821AFA200208F5E001827AA0020E9
1395:10572000240200FF13C20002AFAA002C27C300010D
1396:105730008C020228006090211642000E001E38C024
1397:105740008F42033C24420001AF42033C8F42033CA2
1398:105750008C0202283C0400012484635C3C0500099F
1399:10576000AFA00014AFA200108FA600201000006BA5
1400:1057700034A5050000F710218FA300208FA400247A
1401:10578000AC4304C0AC4404C48F8300548F820054E3
1402:10579000247003E8020210232C4203E91040001B8E
1403:1057A0000000982100E08821263504C08F4401784C
1404:1057B0008F45017C02201821240A0004AFAA0010A2
1405:1057C000AFB200148F48000C0000102102F5302108
1406:1057D000AFA800188F48010C2407000800A3282157
1407:1057E00000A3482B008220210100F8090089202114
1408:1057F00054400006241300018F820054020210233B
1409:105800002C4203E91440FFE900000000326200FF6F
1410:1058100054400017AF5200188F4203782442000111
1411:10582000AF4203788F4203788F8201208FAA002C29
1412:10583000AFA200108F8201243C040001248463681D
1413:105840003C050009AFA200148D4600001000003393
1414:1058500034A506008F4203082413000124420001EE
1415:10586000AF4203088F4203081000001C326200FFA1
1416:105870008F8300548F820054247003E802021023A7
1417:105880002C4203E91040001400009821241100105C
1418:105890008F42000C8F4401608F4501648F86012088
1419:1058A000AFB10010AFB20014AFA200188F42010CCC
1420:1058B000240700080040F80924C6001C1440FFE536
1421:1058C000000000008F820054020210232C4203E9E2
1422:1058D0001440FFEF00000000326200FF144000118E
1423:1058E000000000008F42037824420001AF42037899
1424:1058F0008F4203788F8201208FAA002CAFA2001064
1425:105900008F8201243C040001248463703C0500095B
1426:10591000AFA200148D46000034A507000C002B3BFD
1427:1059200003C038218F4202B424420001AF4202B4C6
1428:105930008F4202B48F4202F424420001AF4202F4CB
1429:105940008F4202F48FBF00488FBE00448FB50040E5
1430:105950008FB3003C8FB200388FB100348FB000306D
1431:1059600003E0000827BD005027BDFFA000801021E4
1432:10597000AFB00040245000020200202124050006A0
1433:10598000AFB1004400408821AFBF0058AFBE005403
1434:10599000AFB50050AFB3004C0C00240CAFB20048C0
1435:1059A0003048007F000810C002E210213C060001D0
1436:1059B00000C2302194C630D010C0001C0000382135
1437:1059C0003C0A0001354A34D296290002000610C074
1438:1059D00000572021008A20219482000014490009E8
1439:1059E000000028219483000296020002146200063F
1440:1059F00000A01021948200049603000400431026A6
1441:105A00002C45000100A0102114400008000610C021
1442:105A100000C0382102E210213C06000100C2302102
1443:105A200094C634D014C0FFEA000610C014C00011A0
1444:105A3000AFA70028000810C002E21021AFA8001094
1445:105A40003C01000100220821942230D03C040001D6
1446:105A5000248463ACAFA200148E2600008E270004BD
1447:105A60003C0500040C002B3B34A509001000007518
1448:105A70003C02080010E0000C000610C002E21021F9
1449:105A80003C03000100621821946334D0000710C069
1450:105A900002E210213C01000100220821A42334D09D
1451:105AA0001000000B3C04000102E210213C03000145
1452:105AB00000621821946334D0000810C002E2102163
1453:105AC0003C01000100220821A42330D03C04000145
1454:105AD000348430D08F430100000610C002E2102150
1455:105AE0003C01000100220821A42334D08F4201048C
1456:105AF00002E438210000282118400029AF460100A7
1457:105B000024E6000694C3FFFC96020000146200091C
1458:105B10000000202194C3FFFE9602000214620006DA
1459:105B20000080102194C20000960300040043102658
1460:105B30002C440001008010215040001424A50001D5
1461:105B40008F4201042442FFFF00A2102A1040000BE4
1462:105B500024E40004948200068C830008A482FFFEE3
1463:105B6000AC8300008F42010424A500012442FFFF02
1464:105B700000A2102A1440FFF7248400088F42010479
1465:105B80002442FFFF10000006AF4201048F420104CF
1466:105B900024C6000800A2102A1440FFDA24E70008F7
1467:105BA000000810C002E210213C010001002208217F
1468:105BB000942230D0144000233C0208003C02000232
1469:105BC00002C2102410400012000821423C030001D0
1470:105BD000346338D8240200030044102300021080EC
1471:105BE000005720210083202100571021004310215D
1472:105BF0003105001F240300018C42000000A318049B
1473:105C000000031827004310241000000DAC82000090
1474:105C1000240200030044102300021080005C2821AD
1475:105C2000005C10213104001F240300018C42022873
1476:105C3000008318040003182700431024ACA2022894
1477:105C40003C0208003442200000001821AFA20020CE
1478:105C50008F5E001827AB0020240200FF13C2000251
1479:105C6000AFAB003427C300018C02022800609021F2
1480:105C70001642000E001E38C08F42033C2442000131
1481:105C8000AF42033C8F42033C8C0202283C040001DB
1482:105C90002484635C3C050009AFA00014AFA200108F
1483:105CA0008FA600201000006B34A5050000F710211E
1484:105CB0008FA300208FA40024AC4304C0AC4404C4D0
1485:105CC0008F8300548F820054247003E80202102353
1486:105CD0002C4203E91040001B0000982100E08821BD
1487:105CE000263504C08F4401788F45017C022018219D
1488:105CF000240B0004AFAB0010AFB200148F48000CAF
1489:105D00000000102102F53021AFA800188F48010CC7
1490:105D10002407000800A3282100A3482B008220218B
1491:105D20000100F809008920215440000624130001D5
1492:105D30008F820054020210232C4203E91440FFE931
1493:105D400000000000326200FF54400017AF520018FC
1494:105D50008F42037824420001AF4203788F420378D8
1495:105D60008F8201208FAB0034AFA200108F820124FC
1496:105D70003C040001248463683C050009AFA20014C0
1497:105D80008D6600001000003334A506008F42030822
1498:105D90002413000124420001AF4203088F4203088C
1499:105DA0001000001C326200FF8F8300548F82005469
1500:105DB000247003E8020210232C4203E9104000146F
1501:105DC00000009821241100108F42000C8F440160C4
1502:105DD0008F4501648F860120AFB10010AFB200146F
1503:105DE000AFA200188F42010C240700080040F809F8
1504:105DF00024C6001C1440FFE5000000008F82005400
1505:105E0000020210232C4203E91440FFEF00000000BF
1506:105E1000326200FF14400011000000008F4203783E
1507:105E200024420001AF4203788F4203788F82012021
1508:105E30008FAB0034AFA200108F8201243C0400011C
1509:105E4000248463703C050009AFA200148D66000035
1510:105E500034A507000C002B3B03C038218F4202B849
1511:105E600024420001AF4202B88F4202B88F4202F4CE
1512:105E700024420001AF4202F48F4202F48FBF005867
1513:105E80008FBE00548FB500508FB3004C8FB20048C6
1514:105E90008FB100448FB0004003E0000827BD0060D0
1515:105EA00000000000000000000000000027BDFFE02F
1516:105EB00027644000AFBF00180C002BA82405100079
1517:105EC0003C03000134632CC03C04000134842EC820
1518:105ED00024020020AF82011C02E31021AF800100E8
1519:105EE000AF800104AF800108AF800110AF800114C2
1520:105EF000AF800118AF800120AF800124AF8001285E
1521:105F0000AF800130AF800134AF800138AF4200EC88
1522:105F100002E31021AF4200F002E41021AF4200F48E
1523:105F200002E41021AF4200F83C02000100571021AA
1524:105F3000904240F41440001C3C0500018F82011C7B
1525:105F40003C040001248464703C05000134420001DB
1526:105F5000AF82011CAFA00010AFA000148F86011CFF
1527:105F600034A501000C002B3B000038218C020218E4
1528:105F70003042004010400014000000008F82011CDD
1529:105F80003C0400012484647C3C050001344200048C
1530:105F9000AF82011CAFA00010AFA000148F86011CBF
1531:105FA0001000000734A502003C040001248464842E
1532:105FB000AFA00010AFA000148F86011C34A5030011
1533:105FC0000C002B3B000038218FBF001803E00008B5
1534:105FD00027BD00208FA900108F83012C8FAA0014E9
1535:105FE0008FAB00181060000A27624FE014620002B5
1536:105FF00024680020276848008F82012811020004CD
1537:10600000000000008F82012415020007000000003C
1538:106010008F4303340000102124630001AF43033495
1539:10602000100000398F430334AC640000AC650004F9
1540:10603000AC660008A467000EAC690018AC6A001CCE
1541:10604000AC6B0010AC620014AF8801208F4200FCE2
1542:106050008F4400F42442FFFFAF4200FC8C8200001A
1543:10606000104900053042FF8F104000193122FF8F88
1544:10607000104000183C0200018C8300042C620010C8
1545:10608000104000133C02000124630001AC830004B3
1546:106090008F4300F8344230C802E2102154620004F9
1547:1060A000246200083C02000134422EC802E21021A2
1548:1060B00014440015240200018F820128244200208C
1549:1060C000AF8201288F8201281000000F24020001F6
1550:1060D0003C020001344230C802E210215482000424
1551:1060E000248200083C02000134422EC802E2102142
1552:1060F0000040202124020001AF4400F4AC890000DC
1553:10610000AC8200042402000103E00008000000004B
1554:1061100003E00008000000008FA900108F83010C2D
1555:106120008FAA00148FAB00181060000A276247E0A6
1556:106130001462000224680020276840008F82010852
1557:1061400011020004000000008F8201041502000704
1558:10615000000000008F430338000010212463000179
1559:10616000AF430338100000358F430338AC640000A0
1560:10617000AC650004AC660008A467000EAC690018AA
1561:10618000AC6A001CAC6B0010AC620014AF8801005C
1562:106190008F4400EC8C820000304200061040001951
1563:1061A00031220006104000183C0200018C830004DC
1564:1061B0002C620010104000133C0200012463000117
1565:1061C000AC8300048F4300F034422EC002E2102161
1566:1061D00054620004246200083C02000134422CC0D6
1567:1061E00002E2102114440015240200018F820108EC
1568:1061F00024420020AF8201088F8201081000000FA6
1569:10620000240200013C02000134422EC002E21021AF
1570:1062100054820004248200083C02000134422CC055
1571:1062200002E210210040202124020001AF4400ECD2
1572:10623000AC890000AC8200042402000103E00008E5
1573:106240000000000003E000080000000027BDFFD8A8
1574:106250003C0400012484648C3C050001AFBF002491
1575:10626000AFB20020AFB1001CAFB000188F90010496
1576:106270008F9100B08F92011C34A525008F82010000
1577:106280000240302102203821AFA200100C002B3B2D
1578:10629000AFB000148E020008AFA200108E02000CF6
1579:1062A0003C04000124846498AFA200148E06000010
1580:1062B0008E0700043C0500010C002B3B34A5251083
1581:1062C0008E020018AFA200108E02001C3C040001D8
1582:1062D000248464A4AFA200148E0600108E0700145C
1583:1062E0003C0500010C002B3B34A525203C027F001F
1584:1062F000022210243C030800544300163C03020011
1585:106300008F82009C3042FFFF144000123C030200C9
1586:106310003C040001248464B03C05000234A5F03044
1587:10632000000030210000382136420002AF82011CFB
1588:1063300036220001AF8200B0AF900104AF92011C81
1589:10634000AFA000100C002B3BAFA0001410000024E5
1590:106350000000000002C310241040000D022310248E
1591:106360001040000B36420002AF82011C36220001B1
1592:10637000AF8200B0AF900104AF92011C8F42033096
1593:1063800024420001AF420330100000158F42033059
1594:106390003C040001248464B8240202A9AFA20010C6
1595:1063A000AFA000148F8601443C07000124E764C0BD
1596:1063B0000C002B3B3405DEAD8F82011C3442000201
1597:1063C000AF82011C8F82022034420004AF8202207F
1598:1063D0008F8201403C03000100431025AF82014041
1599:1063E0008FBF00248FB200208FB1001C8FB0001827
1600:1063F00003E0000827BD002827BDFFD83C040001AA
1601:10640000248464E83C050001AFBF0024AFB2002043
1602:10641000AFB1001CAFB000188F9001248F9100A085
1603:106420008F92011C34A526008F820120024030216A
1604:1064300002203821AFA200100C002B3BAFB000149B
1605:106440008E020008AFA200108E02000C3C04000176
1606:10645000248464F4AFA200148E0600008E070004AA
1607:106460003C0500010C002B3B34A526108E020018C1
1608:10647000AFA200108E02001C3C04000124846500C1
1609:10648000AFA200148E0600108E0700143C05000118
1610:106490000C002B3B34A526203C027F000222102456
1611:1064A0003C030800544300163C0302008F8200ACFA
1612:1064B0003042FFFF144000123C0302003C04000184
1613:1064C0002484650C3C05000134A5F0300000302127
1614:1064D0000000382136420002AF82011C3622000142
1615:1064E000AF8200A0AF900124AF92011CAFA00010BA
1616:1064F0000C002B3BAFA00014100000240000000093
1617:1065000002C310241040000D022310241040000B81
1618:1065100036420002AF82011C36220001AF8200A089
1619:10652000AF900124AF92011C8F42032C2442000142
1620:10653000AF42032C100000158F42032C3C040001D5
1621:10654000248464B8240202E2AFA20010AFA00014B9
1622:106550008F8601443C07000124E764C00C002B3BFC
1623:106560003405DEAD8F82011C34420002AF82011C73
1624:106570008F82022034420004AF8202208F820140C9
1625:106580003C03000100431025AF8201408FBF00246F
1626:106590008FB200208FB1001C8FB0001803E00008FC
1627:1065A00027BD00280000602100005021000030219C
1628:1065B0000000282100006821000048210000782107
1629:1065C000000070218F8801248F8701041580002E20
1630:1065D0008F8B011C11A00014316208008F820120F2
1631:1065E00010460029000000003C0400018C846EE489
1632:1065F0008CC200008CC30004AC820000AC83000499
1633:106600008CC20008AC82000894C2000EA482000E66
1634:106610008CC20010240C0001AC8200108CC200144B
1635:106620001000001224C600201040001700000000D7
1636:106630003C0400018C846EE48D0200008D03000494
1637:10664000AC820000AC8300048D020008AC8200081C
1638:106650009502000EA482000E8D0200102506002077
1639:10666000AC8200108D020014240C000100C018211F
1640:10667000AC82001427624FE00043102B544000010D
1641:1066800027634800006030211540002F316201006F
1642:1066900011200014316280008F8201001045002A11
1643:1066A000316201003C0400018C846EE08CA2000089
1644:1066B0008CA30004AC820000AC8300048CA2000810
1645:1066C000AC82000894A2000EA482000E8CA20010DE
1646:1066D000240A0001AC8200108CA2001410000012E9
1647:1066E00024A5002010400018316201003C04000184
1648:1066F0008C846EE08CE200008CE30004AC8200002D
1649:10670000AC8300048CE20008AC82000894E2000E26
1650:10671000A482000E8CE2001024E50020AC82001060
1651:106720008CE20014240A000100A01821AC8200149D
1652:10673000276247E00043102B5440000127634000CC
1653:1067400000602821316201005440001D31621000B8
1654:1067500011A0000931A20800104000042502002009
1655:106760008F8200A8A5E2000025020020AF8201244C
1656:106770008F8801240000682111800011316210000F
1657:106780003C0400018C846EE48C8200008C83000445
1658:10679000AF820080AF8300848C820008AF8200A4A7
1659:1067A0009482000EAF8200AC8C8200100000602149
1660:1067B000AF8200A08C8D00108C8F0014316210000D
1661:1067C0001440FF82000000001120000F3122080059
1662:1067D000104000043C0200028F8200B8A5C20000F5
1663:1067E0003C020002012210241040000424E2002098
1664:1067F0008F8200B4AF8200D424E20020AF82010473
1665:106800008F870104000048211140FF700000000044
1666:106810003C0400018C846EE08C8200008C830004B8
1667:10682000AF820090AF8300948C820008AF8200B4E6
1668:106830009482000EAF82009C8C82001000005021D8
1669:10684000AF8200B08C8900101000FF608C8E0014A5
1670:1068500003E0000800000000000060210000582153
1671:106860000000302100002821000068210000502194
1672:1068700000007821000070218F8801248F87010497
1673:106880003C1801001580002E8F89011C11A00014F6
1674:10689000312208008F8201201046002900000000EC
1675:1068A0003C0400018C846EE48CC200008CC30004A4
1676:1068B000AC820000AC8300048CC20008AC820008EB
1677:1068C00094C2000EA482000E8CC20010240C0001A1
1678:1068D000AC8200108CC200141000001224C60020EC
1679:1068E00010400017000000003C0400018C846EE49E
1680:1068F0008D0200008D030004AC820000AC83000414
1681:106900008D020008AC8200089502000EA482000EE1
1682:106910008D02001025060020AC8200108D020014AC
1683:10692000240C000100C01821AC82001427624FE043
1684:106930000043102B544000012763480000603021C1
1685:106940001560002F31220100114000143122800017
1686:106950008F8201001045002A312201003C04000111
1687:106960008C846EE08CA200008CA30004AC8200003A
1688:10697000AC8300048CA20008AC82000894A2000E34
1689:10698000A482000E8CA20010240B0001AC82001027
1690:106990008CA200141000001224A500201040001842
1691:1069A000312201003C0400018C846EE08CE2000086
1692:1069B0008CE30004AC820000AC8300048CE200088D
1693:1069C000AC82000894E2000EA482000E8CE200105B
1694:1069D00024E50020AC8200108CE20014240B00019E
1695:1069E00000A01821AC820014276247E00043102B5E
1696:1069F000544000012763400000602821312201003B
1697:106A00005440001D3122100011A0000931A20800DD
1698:106A100010400004250200208F8200A8A5E200009B
1699:106A200025020020AF8201248F8801240000682104
1700:106A300011800011312210003C0400018C846EE4AE
1701:106A40008C8200008C830004AF820080AF830084BE
1702:106A50008C820008AF8200A49482000EAF8200AC4A
1703:106A60008C82001000006021AF8200A08C8D00108D
1704:106A70008C8F00143122100014400022000000000E
1705:106A80001140000F31420800104000043C02000297
1706:106A90008F8200B8A5C200003C020002014210240F
1707:106AA0001040000424E200208F8200B4AF8200D4A2
1708:106AB00024E20020AF8201048F87010400005021EE
1709:106AC00011600010000000003C0400018C846EE0A6
1710:106AD0008C8200008C830004AF820090AF8300940E
1711:106AE0008C820008AF8200B49482000EAF82009CBA
1712:106AF0008C82001000005821AF8200B08C8A0010F8
1713:106B00008C8E00148F8200703C0310000043102410
1714:106B10001040FF5C000000008F82005424420005FA
1715:106B2000AF8200788C040234108000160000182117
1716:106B30003C020001005710218C4240E8244200052D
1717:106B40003C01000100370821AC2240E83C02000172
1718:106B5000005710218C4240E80044102B14400009DB
1719:106B6000240200013C0300803C01000100370821A1
1720:106B7000AC2040E83C010001003708211000000C67
1721:106B8000A02240F03C02000100571021904240F04A
1722:106B9000144000063C0200803C0200010057102116
1723:106BA000904240F1104000023C0200800062182533
1724:106BB0008C04023010800013000000003C02000131
1725:106BC000005710218C4240EC244200053C0100019A
1726:106BD00000370821AC2240EC3C0200010057102194
1727:106BE0008C4240EC0044102B1440000600000000D2
1728:106BF0003C01000100370821AC2040EC10000006E9
1729:106C0000007818253C02000100571021904240F204
1730:106C100054400001007818251060FF1A00000000A1
1731:106C20008F4200001040000700000000AF80004CC1
1732:106C30008F82004C1040FFFD000000001000000596
1733:106C400000000000AF8000488F8200481040FFFD28
1734:106C5000000000008F82006000431025AF820060BA
1735:106C60008F42000010400003000000001000FF05EC
1736:106C7000AF80004C1000FF03AF80004803E0000825
1737:106C80000000000000000000000000003C020001C5
1738:106C90008C426D2827BDFFE8AFBF001414400012DE
1739:106CA000AFB000103C10000126106F9002002021B0
1740:106CB0000C002BA82405200026021FE03C01000147
1741:106CC000AC226EEC3C010001AC226EE8AC0202503A
1742:106CD00024022000AC100254AC020258240200012D
1743:106CE0003C010001AC226D288FBF00148FB0001052
1744:106CF00003E0000827BD00183C0900018D296EEC57
1745:106D00008C8200008FA300108FA80014AD22000019
1746:106D10008C820004AD250008AD2200048F8200544F
1747:106D2000AD260010AD270014AD230018AD28001CBF
1748:106D3000AD22000C2529FFE03C02000124426F90A7
1749:106D40000122102B10400003000000003C0900014C
1750:106D50008D296EE83C0200018C426D10AD220000CE
1751:106D60003C0200018C426D103C010001AC296EEC2C
1752:106D7000AD220004AC09025003E00008000000004E
1753:106D800027BDFFD0AFB000103C1000018E106EEC9C
1754:106D90003C0200018C426D10AFB1001400808821CC
1755:106DA000AFBE00248FBE00408FA40048AFB20018D1
1756:106DB00000A09021AFBF0028AFB50020AFB3001CEA
1757:106DC000AE0200003C0200018C426D1000C0982110
1758:106DD00000E0A82110800006AE020004260500088D
1759:106DE0000C002BB324060018100000052610FFE04D
1760:106DF000260400080C002BA8240500182610FFE02C
1761:106E00003C03000124636F900203102B1040000329
1762:106E1000000000003C1000018E106EE88E22000081
1763:106E2000AE0200008E220004AE120008AE02000482
1764:106E30008F820054AE130010AE150014AE1E001861
1765:106E40008FA80044AE08001CAE02000C2610FFE024
1766:106E50000203102B10400003000000003C10000152
1767:106E60008E106EE83C0200018C426D10AE020000F4
1768:106E70003C0200018C426D103C010001AC306EEC14
1769:106E8000AE020004AC1002508FBF00288FBE002459
1770:106E90008FB500208FB3001C8FB200188FB1001483
1771:106EA0008FB0001003E0000827BD003000851821D6
1772:106EB0000083102B1040000600000000AC80000092
1773:106EC000248400040083102B5440FFFDAC8000009C
1774:106ED00003E000080000000000A6182100A3102B0A
1775:106EE00010400007000000008C820000ACA20000EF
1776:106EF00024A5000400A3102B1440FFFB24840004ED
1777:106F000003E0000800000000008618210083102B19
1778:106F100010400007000000008CA20000AC820000BE
1779:106F2000248400040083102B1440FFFB24A50004DC
1780:106F300003E00008000000000006308000861821F1
1781:106F40000083102B1040000600000000AC850000FC
1782:106F5000248400040083102B5440FFFDAC85000006
1783:106F600003E00008000000000000000026E5002803
1784:106F700000A03021274301C08F4D03588F47035C89
1785:106F80008F4803608F4903648F4A03688F4B020464
1786:106F90008F4C0200246404000064102B1040000891
1787:106FA0003C0208FF8CC20000AC62000024630004B5
1788:106FB0000064102B1440FFFB24C600043C0208FFB1
1789:106FC0003442FFFF3C03C0FFAF4D0358AF47035CA3
1790:106FD000AF480360AF490364AF4A0368AF4B020494
1791:106FE000AF4C02008F8402203463FFFF8F860200C3
1792:106FF000008210243442000400C3182434630004C7
1793:10700000AF820220AF8302008CA20214AC02008483
1794:107010008CA20218AC0200888CA2021CAC02008C6C
1795:107020008CA20220AC0200908CA20224AC0200943C
1796:107030008CA20228AC0200988CA2022CAC02009C0C
1797:107040008CA20230AC0200A08CA20234AC0200A4DC
1798:107050008CA20238AC0200A88CA2023CAC0200ACAC
1799:107060008CA20240AC0200B08CA20244AC0200B47C
1800:107070008CA20248AC0200B88CA2024CAC0200BC4C
1801:107080008CA2001CAC0200808CA20018AC0200C0D4
1802:107090008CA20020AC0200CC8CA20024AC0200D058
1803:1070A0008CA201D0AC0200E08CA201D4AC0200E4BE
1804:1070B0008CA201D8AC0200E88CA201DCAC0200EC8E
1805:1070C0008CA201E0AC0200F08CA200988CA3009C82
1806:1070D000AC0300FC8CA200A88CA300ACAC0300F4B1
1807:1070E0008CA200A08CA300A430840004AC0300F8A0
1808:1070F0001480000730C200048F8202203C0308FF86
1809:107100003463FFFB00431024AF82022030C200042E
1810:1071100014400006000000008F8202003C03C0FF04
1811:107120003463FFFB00431024AF8202008F4202DC75
1812:10713000A34005C524420001AF4202DC8F4202DCBD
1813:1071400003E000080000000027BDFFD8AFBF002407
1814:10715000AFB000208F4300248F420020106200381F
1815:10716000000000008F4300208F4200240062202393
1816:1071700004810003000000008F42004000822021B3
1817:107180008F4300308F4200240043102B1440000531
1818:10719000000000008F4300408F42002410000005D3
1819:1071A000006210238F4200308F43002400431023DD
1820:1071B0002442FFFF00406021008C102A544000014F
1821:1071C000008060218F4A00248F4900408F480024AE
1822:1071D0008F4401808F4501848F4600248F4B001C13
1823:1071E00024070001AFA7001000084100010018218A
1824:1071F000014C50212529FFFF01498024AFB0001424
1825:107200008F4700140000102100063100AFA70018BE
1826:1072100000A3282100A3382B0082202100872021F1
1827:107220008F420108016630210040F809000C390046
1828:1072300054400001AF5000248F4300248F420020AF
1829:1072400014620018000000008F4200001040000788
1830:1072500000000000AF80004C8F82004C1040FFFD0A
1831:10726000000000001000000500000000AF80004892
1832:107270008F8200481040FFFD000000008F820060F8
1833:107280002403FFEF00431024AF8200608F42000010
1834:10729000104000030000000010000002AF80004C0E
1835:1072A000AF8000488FBF00248FB0002003E00008AB
1836:1072B00027BD002803E000080000000027BDFFC034
1837:1072C00032C20020AFBF0038AFB30034AFB20030DD
1838:1072D000AFB1002C10400004AFB000288F5300283D
1839:1072E00010000002000000008F5300208F42003089
1840:1072F000105300EB000211008F43001C006280213C
1841:107300008E0400008E050004961200088F42009043
1842:107310009611000A3246FFFF0046102A104000175F
1843:10732000000000008F8200D88F4300980043102394
1844:107330002442DCBEAF4200908F4200902842DCBF66
1845:1073400010400005000000008F4200908F43014470
1846:1073500000431021AF4200908F4200900046102A57
1847:1073600010400006000000008F4203482442000144
1848:10737000AF420348100000E18F4203488F8200FCB7
1849:1073800014400006000000008F4203442442000124
1850:10739000AF420344100000D98F420344934205C218
1851:1073A0001040000B32C200081040000832220200D8
1852:1073B000104000063C0340009602000EAF4300ACB4
1853:1073C0000002140010000002AF4200B0AF4000AC59
1854:1073D000322200041040007F3222080010400003D7
1855:1073E0003247FFFF100000022402002024020004A4
1856:1073F000AFA200108F420030AFA200148F420010E5
1857:107400003C03000200431025AFA200188F460098ED
1858:107410008F4201080040F80900000000104000B74A
1859:10742000000000008F42009C8F4300940242102114
1860:10743000AF42009CAE03000C8F4200AC104000082D
1861:107440003C0340008F42009400431025AFA200206F
1862:107450008F42009C8F4300B01000000400431025B1
1863:107460008F420094AFA200208F42009CAFA2002464
1864:107470008F8200FC8FA300208FA40024AC43000067
1865:10748000AC44000424420008AF8200F08F42009C0C
1866:107490008F4402708F4502740040182100001021B3
1867:1074A00000A3282100A3302B008220210086202168
1868:1074B0003223006024020040AF440270AF450274E2
1869:1074C000106200172C6200411040000524020020C9
1870:1074D00010620008240200011000002600000000D5
1871:1074E0002402006010620019240200011000002133
1872:1074F000000000008F4202788F43027C2463000169
1873:107500002C64000100441021AF420278AF43027C9A
1874:107510008F4202788F43027C100000162402000183
1875:107520008F4202808F430284246300012C64000197
1876:1075300000441021AF420280AF4302848F42028098
1877:107540008F4302841000000B240200018F42028846
1878:107550008F43028C246300012C640001004410213D
1879:10756000AF420288AF43028C8F4202888F43028C65
1880:1075700024020001A34205C28F4200983244FFFF5B
1881:107580002406FFF88F45013C0044102124420007E7
1882:107590000046102424840007AF4200948F420090DC
1883:1075A0008F43009400862024004410230065182B8C
1884:1075B00014600005AF4200908F4200948F43014455
1885:1075C00000431023AF4200948F4200941000002328
1886:1075D000AF40009C3247FFFF50E0002232C2002043
1887:1075E000144000022402001024020002AFA2001086
1888:1075F0008F420030AFA200148F420010AFA20018DB
1889:107600008F4600988F4201080040F80900000000F2
1890:107610001040003A3245FFFF8F4200988F430090A0
1891:107620008F46013C00451021AF4200988F42009CDC
1892:107630008F440098A34005C200651823AF43009013
1893:10764000004510210086202B14800005AF42009CCD
1894:107650008F4200988F43014400431023AF420098AB
1895:1076600032C2002010400005000000008F42035885
1896:107670002442FFFFAF4203588F4203588F4200302D
1897:107680008F430040244200012463FFFF0043102485
1898:10769000AF4200308F420030145300180000000049
1899:1076A0008F4200001040000700000000AF80004C37
1900:1076B0008F82004C1040FFFD00000000100000050C
1901:1076C00000000000AF8000488F8200481040FFFD9E
1902:1076D000000000008F8200602403FFF700431024A5
1903:1076E000AF8200608F4200001040000300000000E5
1904:1076F00010000002AF80004CAF8000488FBF003800
1905:107700008FB300348FB200308FB1002C8FB00028BF
1906:1077100003E0000827BD004003E00008000000006F
1907:1077200027BDFFD032C20020AFBF002CAFB200286F
1908:10773000AFB1002410400004AFB000208F520028E9
1909:1077400010000002000000008F5200208F42003025
1910:10775000105200B5000211008F43001C006280210E
1911:107760008E0400008E050004961100088F420090E0
1912:107770009607000A3226FFFF0046102A1040001725
1913:10778000000000008F8200D88F4300980043102330
1914:107790002442DC46AF4200908F4200902842DC47F2
1915:1077A00010400005000000008F4200908F4301440C
1916:1077B00000431021AF4200908F4200900046102AF3
1917:1077C00010400006000000008F42034824420001E0
1918:1077D000AF420348100000AB8F4203488F8600FC85
1919:1077E00010C0000C000000008F8200F42403FFF89A
1920:1077F0000043102400461023000218C35860000103
1921:10780000246301008F42008C0043102B14400006BB
1922:10781000000712C28F42034424420001AF420344D6
1923:10782000100000988F420344934305C21060000F7C
1924:10783000304600018F4200103448040032C2000874
1925:107840001040000830E20200104000063C034000F7
1926:107850009602000EAF4300AC0002140010000004BA
1927:10786000AF4200B010000002AF4000AC8F480010E3
1928:1078700030E20004104000453227FFFF8F4900AC82
1929:107880001120000530C200FF144000062402004011
1930:10789000100000042402000814400002240200200A
1931:1078A00024020004AFA200108F4300301120000416
1932:1078B000AFA300148F4200B000621025AFA20014E5
1933:1078C0003C02000201021025AFA200188F4600986A
1934:1078D0008F4201080040F8090000000010400069D4
1935:1078E0003224FFFF8F42008C8F430094244200011A
1936:1078F000AF42008C24020001AE03000CA34205C27B
1937:107900008F4200982406FFF88F45013C0044102167
1938:10791000244200070046102424840007AF4200944C
1939:107920008F4200908F43009400862024004410234F
1940:107930000065182B14600005AF4200908F42009440
1941:107940008F43014400431023AF4200948F430094BF
1942:107950008F4201400043102B10400009000000003E
1943:107960008F43013C8F4400948F4200908F45013833
1944:107970000064182300431023AF420090AF450094E9
1945:107980008F4200941000001FAF42009810E0001DCD
1946:1079900030C200FF14400002240200102402000242
1947:1079A000AFA200108F420030AFA80018AFA20014A1
1948:1079B0008F4600988F4201080040F809000000003F
1949:1079C000104000303225FFFF8F4200988F44013C69
1950:1079D00000451021AF4200988F4200908F430098DD
1951:1079E000A34005C2004510230064182B1460000555
1952:1079F000AF4200908F4200988F4301440043102310
1953:107A0000AF4200988F4200308F4300402442000173
1954:107A10002463FFFF00431024AF4200308F42003048
1955:107A200014520018000000008F42000010400007B0
1956:107A300000000000AF80004C8F82004C1040FFFD22
1957:107A4000000000001000000500000000AF800048AA
1958:107A50008F8200481040FFFD000000008F82006010
1959:107A60002403FFF700431024AF8200608F42000020
1960:107A7000104000030000000010000002AF80004C26
1961:107A8000AF8000488FBF002C8FB200288FB1002438
1962:107A90008FB0002003E0000827BD003003E000089D
1963:107AA0000000000027BDFFD83C02000134422EC078
1964:107AB000AFBF00208F4300F08F84010802E2102145
1965:107AC00054620004246200083C02000134422CC0CD
1966:107AD00002E2102100401821AF4300F0AC6000002A
1967:107AE0008F4200EC8C660004146200043C0200012A
1968:107AF000248200201000000FAF8201088F4300F0A5
1969:107B000034422EC002E210215462000424620008B4
1970:107B10003C02000134422CC002E210210040182136
1971:107B20008C6200040002114000821021AF82010823
1972:107B3000AC6000008C85001830A200361040006C4C
1973:107B400030A200018C82001C8F4300408F4400341F
1974:107B5000244200012463FFFF0043102400862021FB
1975:107B6000AF42002C30A2003014400006AF44003475
1976:107B70008F4200348C03023C0043102B144000B4AD
1977:107B80000000000032C20010104000282407000846
1978:107B90008F4401708F4501748F43002C8F48000C77
1979:107BA0008F86012024020080AFA20010AFA3001432
1980:107BB000AFA800188F42010C0040F80924C6001C31
1981:107BC00014400011240200013C010001003708218B
1982:107BD000A02240F18F820124AFA200108F820128E1
1983:107BE0003C040001248467C4AFA200148F46002C1B
1984:107BF0008F8701203C0500090C002B3B34A51100A8
1985:107C000010000036000000008F4203008F43002C5C
1986:107C100024420001AF4203008F420300240200010E
1987:107C2000A34205C110000026AF4300388F44017005
1988:107C30008F4501748F43002C8F48000C8F860120E4
1989:107C400024020020AFA20010AFA30014AFA80018B8
1990:107C50008F42010C0040F80924C6001C144000119A
1991:107C6000240200013C01000100370821A02240F05D
1992:107C70008F820124AFA200108F8201283C040001F2
1993:107C8000248467B8AFA200148F46002C8F87012090
1994:107C90003C0500090C002B3B34A509001000000F27
1995:107CA000000000008F42030024420001AF420300A5
1996:107CB0008F4203008F42002CA34005C1AF42003821
1997:107CC0003C01000100370821A02040F13C010001E7
1998:107CD00000370821A02040F0AF4000348F42031449
1999:107CE00024420001AF420314100000598F420314D4
2000:107CF0001040002230A270008C85001C8F420028AA
2001:107D000000A2202304810003000000008F420040F5
2002:107D1000008220218F4203588F430000AF45002886
2003:107D20000044102110600007AF420358AF80004CA0
2004:107D30008F82004C1040FFFD000000001000000585
2005:107D400000000000AF8000488F8200481040FFFD17
2006:107D5000000000008F82006034420008AF820060A3
2007:107D60008F420000104000030000000010000038A7
2008:107D7000AF80004C10000036AF8000481040002F4C
2009:107D800030A210001040000C30A240008C83001C78
2010:107D90008F420050006220230482000124840200EC
2011:107DA0008F42035C00441021AF42035C8F420368A2
2012:107DB0001000001AAF4300501040000C32C2800087
2013:107DC0008C83001C8F42007000622023048200011B
2014:107DD000248404008F42036400441021AF420364F2
2015:107DE0008F4203681000000DAF4300701040000E7A
2016:107DF0003C0208008C83001C8F420060006220233C
2017:107E000004820001248401008F4203600044102199
2018:107E1000AF4203608F420368AF430060004410210B
2019:107E2000AF4203683C02080002C210245040000820
2020:107E300036940040100000060000000030A201004F
2021:107E400010400003000000000C002BD800000000D0
2022:107E50008FBF002003E0000827BD002803E00008D2
2023:107E60000000000027BDFFA8AFBF0050AFBE004C10
2024:107E7000AFB50048AFB30044AFB20040AFB1003C73
2025:107E8000AFB000388F91010826220020AF82010890
2026:107E90008E3200180000A82132420024104001BA9E
2027:107EA0000000F0218E26001C8F43001C00061100EC
2028:107EB000006218218C70000C9604000C962D0016A0
2029:107EC0009473000A2C8305DD388288702C420001EF
2030:107ED00000621825106000150000282132C2004001
2031:107EE00010400015240208009603001414620012CA
2032:107EF0003402AAAA9603000E146200070000202193
2033:107F00009603001024020300146200040080102174
2034:107F1000960200122C4400010080102154400006FB
2035:107F200024050016100000040000000024020800D0
2036:107F3000508200012405000E934205C3144000083E
2037:107F400000005821240B000132620180AF4500A8D7
2038:107F5000AF5000A010400002AF4600A4A34B05C3E1
2039:107F600010A0008502054021910200000000382188
2040:107F70003042000F0002508032C200021040001256
2041:107F8000010A1821326200021040001032C20001C2
2042:107F900001002021948200002484000200E23821A4
2043:107FA0000083102B1440FFFB30E2FFFF00071C0290
2044:107FB0000062382100071C0230E2FFFF0062382116
2045:107FC00000071027A502000A32C200011040006A13
2046:107FD0003262000110400068000000008F4200A8DB
2047:107FE00010400065000000008F4200A08F4300A8F1
2048:107FF00000431021904C0009318900FF392300060D
2049:108000000003182B392200110002102B00621824E3
2050:108010001060000C3C0500068F4200A43C040001E7
2051:10802000248467D4AFA200108F4200A034A546007C
2052:10803000012038210C002B3BAFA200141000004E91
2053:108040000000000032C20004144000130000282188
2054:10805000316200FF1440000400000000950200029D
2055:108060001000000D004A28239505000C9502000E13
2056:108070009503001000A2282100A3282195030012D7
2057:10808000910400099502000200A3282100A42821E0
2058:10809000004A102300A2282102002021948200001F
2059:1080A0002484000200E238210088102B1440FFFBDA
2060:1080B00000071C0230E2FFFF0062382100071C02AB
2061:1080C00030E2FFFF0062382101A5282100051C02D3
2062:1080D00030A2FFFF0062282100051C0230A2FFFF32
2063:1080E0000062282100A728230005140200A22821ED
2064:1080F00030A5FFFF50A000013405FFFF316200FFF3
2065:1081000014400008318300FF8F4300A08F4200A875
2066:1081100000624021910200003042000F00025080B6
2067:10812000318300FF2402000614620003010A1021BB
2068:10813000100000022444001024440006316200FFB5
2069:1081400014400006000000009482000000A22821D4
2070:1081500000051C0230A2FFFF00622821934205C3E4
2071:10816000104000033262010050400003A48500006B
2072:1081700000052827A48500009622000E8F43009C4E
2073:108180000062182132A200FF10400007AF43009C9C
2074:108190003C02400002021025AFA200208F42009C4A
2075:1081A00010000003005E1025AFB000208F42009C3D
2076:1081B000AFA2002432620080104000103262010041
2077:1081C0008F4200B424430001000210C00057102168
2078:1081D000AF4300B48FA300208FA400243C01000112
2079:1081E00000220821AC2338E83C01000100220821CC
2080:1081F000AC2438EC100000A532C20020104000640E
2081:10820000000000008F4200B424430001000210C0AF
2082:1082100000571021AF4300B48FA300208FA4002487
2083:108220003C01000100220821AC2338E83C01000198
2084:1082300000220821AC2438EC8F4200B410400051D9
2085:10824000000038213C090001352938E83C08001FAE
2086:108250003508FFFF240BFFFF340AFFFF000710C0A3
2087:1082600000571021004910218C4300008C44000469
2088:10827000AFA30028AFA4002C8F8200FC8FA300289E
2089:108280008FA4002CAC430000AC440004244200083E
2090:10829000AF8200F08F42008C2442FFFFAF42008C7F
2091:1082A00097A2002E8F4402708F450274004018215F
2092:1082B0000000102100A3282100A3302B00822021E0
2093:1082C00000862021AF440270AF4502748FA20028BF
2094:1082D0000048102490430000306300011460000B3C
2095:1082E000004020218F4202788F43027C24630001EA
2096:1082F0002C64000100441021AF420278AF43027C9D
2097:108300008F4202781000001A8F43027C8C8200009A
2098:10831000144B000E0000000094820004144A000B6D
2099:10832000000000008F4202888F43028C246300010A
2100:108330002C64000100441021AF420288AF43028C3C
2101:108340008F4202881000000A8F43028C8F42028005
2102:108350008F430284246300012C6400010044102137
2103:10836000AF420280AF4302848F4202808F43028477
2104:108370008F4200B424E7000100E2102B1440FFB844
2105:10838000000710C0A34005C31000003FAF4000B479
2106:108390008F8200FC8FA300208FA40024AC43000038
2107:1083A000AC44000424420008AF8200F08F42009CDD
2108:1083B0008F46008C8F4402708F4502740040182154
2109:1083C0000000102124C6FFFFAF46008C00A3282127
2110:1083D00000A3302B0082202100862021AF440270B0
2111:1083E000AF45027492020000304200011440000CBC
2112:1083F0002402FFFF8F4202788F43027C2463000136
2113:108400002C64000100441021AF420278AF43027C8B
2114:108410008F4202788F43027C1000001C32C2002081
2115:108420008E0300001462000F3402FFFF9603000465
2116:108430001462000C000000008F4202888F43028CFF
2117:10844000246300012C64000100441021AF42028823
2118:10845000AF43028C8F4202888F43028C1000000BC6
2119:1084600032C200208F4202808F43028424630001C5
2120:108470002C64000100441021AF420280AF4302840B
2121:108480008F4202808F43028432C2002010400005D8
2122:10849000AF40009C8F4203582442FFFFAF42035875
2123:1084A0008F4203588E22001C8F430040244200015B
2124:1084B0002463FFFF00431024AF42002C32420060CF
2125:1084C0001440000832C200108F42003424420001E0
2126:1084D000AF4200348C03023C0043102B14400102D5
2127:1084E00032C2001010400018240700088F440170A9
2128:1084F0008F4501748F43002C8F48000C8F8601201C
2129:1085000024020080AFA20010AFA30014AFA800188F
2130:108510008F42010C0040F80924C6001C104000479F
2131:10852000240200018F4203008F43002C24420001EB
2132:10853000AF4203008F42030024020001A34205C1A1
2133:108540001000007CAF4300388F4401708F450174E8
2134:108550008F43002C8F48000C8F86012024020020BE
2135:10856000AFA20010AFA30014AFA800188F42010CF7
2136:108570000040F80924C6001C1040005724020001E6
2137:10858000100000650000000032420012104000752B
2138:10859000324200019622000E8F43009C0062182197
2139:1085A00032C2002010400005AF43009C8F420358A8
2140:1085B0002442FFFFAF4203588F4203588E22001C13
2141:1085C0008F430040244200012463FFFF0043102436
2142:1085D000AF42002C324200101440000832C200109A
2143:1085E0008F42003424420001AF4200348C03023C2D
2144:1085F0000043102B144000BC32C200101040002871
2145:10860000240700088F4401708F4501748F43002CAC
2146:108610008F48000C8F86012024020080AFA200103A
2147:10862000AFA30014AFA800188F42010C0040F80956
2148:1086300024C6001C14400011240200013C0100016A
2149:1086400000370821A02240F18F820124AFA2001040
2150:108650008F8201283C040001248467C4AFA2001467
2151:108660008F46002C8F8701203C0500090C002B3B16
2152:1086700034A5110010000036000000008F420300F6
2153:108680008F43002C24420001AF4203008F420300BD
2154:1086900024020001A34205C110000026AF430038A8
2155:1086A0008F4401708F4501748F43002C8F48000C5C
2156:1086B0008F86012024020020AFA20010AFA3001477
2157:1086C000AFA800188F42010C0040F80924C6001C16
2158:1086D00014400011240200013C0100010037082170
2159:1086E000A02240F08F820124AFA200108F820128C7
2160:1086F0003C040001248467B8AFA200148F46002C0C
2161:108700008F8701203C0500090C002B3B34A5090094
2162:108710001000000F000000008F42030024420001FF
2163:10872000AF4203008F4203008F42002CA34005C1DB
2164:10873000AF4200383C01000100370821A02040F181
2165:108740003C01000100370821A02040F0AF40003478
2166:108750008F42031424420001AF4203141000006250
2167:108760008F42031410400022324270008E25001CFC
2168:108770008F42002800A22023048100030000000093
2169:108780008F420040008220218F4203588F43000017
2170:10879000AF4500280044102110600007AF42035885
2171:1087A000AF80004C8F82004C1040FFFD00000000A5
2172:1087B0001000000500000000AF8000488F820048D4
2173:1087C0001040FFFD000000008F820060344200086E
2174:1087D000AF8200608F4200001040000300000000E4
2175:1087E00010000041AF80004C1000003FAF800048F7
2176:1087F0001040002F324210001040000C3242400066
2177:108800008E23001C8F42005000622023048200014E
2178:10881000248402008F42035C00441021AF42035CB9
2179:108820008F4203681000001AAF4300501040000C44
2180:1088300032C280008E23001C8F4200700062202311
2181:1088400004820001248404008F4203640044102148
2182:10885000AF4203648F4203681000000DAF43007005
2183:108860001040000E3C0208008E23001C8F42006066
2184:108870000062202304820001248401008F420360EF
2185:1088800000441021AF4203608F420368AF43006091
2186:1088900000441021AF4203683C02080002C21024C9
2187:1088A00050400011369400401000000F00000000FE
2188:1088B0003242004810400007241500018E22001C9F
2189:1088C0003C03FFFF0043F0243042FFFF1000FD7522
2190:1088D000AE22001C324201001040000300000000E4
2191:1088E0000C002BD8000000008FBF00508FBE004C42
2192:1088F0008FB500488FB300448FB200408FB1003C69
2193:108900008FB0003803E0000827BD005803E00008DE
2194:108910000000000000000000000000008F8300E461
2195:108920008F8200E02404FFF8004410240062102627
2196:108930000002102B0002102303E000080062102444
2197:1089400003E000080000000027BDFFE0AFBF001CEF
2198:10895000AFB000188F8600C48F8400E08F8500E4DC
2199:108960002402FFF80082182410A3000927623FF8B0
2200:1089700014A2000224A200082762300000408021D7
2201:1089800016030005308200041040000400C02021BE
2202:1089900010000022000010218E0400008F42011CF4
2203:1089A00014A20003000000008F420120AF42011416
2204:1089B0008CA300008F420148008318230043102B32
2205:1089C00010400003000000008F420148006218219F
2206:1089D00094A20006244200500062102B1440000FA5
2207:1089E00000A01021AFA40010AFA300148CA60000BB
2208:1089F0008CA700043C0400010C002B3B24846894E9
2209:108A00008F42020C24420001AF42020C8F42020C42
2210:108A100000001021AF9000E8AF9000E48FBF001C71
2211:108A20008FB0001803E0000827BD002003E0000815
2212:108A3000000000008F8400E08F8800C48F8300E86E
2213:108A40002402FFF80082382400E320232C82100047
2214:108A50005040000124841000000420C2008018212E
2215:108A60008F4402588F45025C0000102100A328218A
2216:108A700000A3302B0082202100862021AF44025821
2217:108A8000AF45025C8F8300C88F4201480103202359
2218:108A90000082102B14400004008018218F420148EE
2219:108AA00000822021008018218F4402508F450254FB
2220:108AB0000000102100A3282100A3302B00822021D8
2221:108AC00000862021AF440250AF450254AF8800C851
2222:108AD000AF8700E4AF8700E803E000080000000073
2223:108AE00027BDFF30240A0001AFBF00C8AFBE00C4DD
2224:108AF000AFB500C0AFB300BCAFB200B8AFB100B407
2225:108B0000AFB000B0A3A00097AFA00044AFAA005C34
2226:108B1000934205C4A7A0008E1040000AA7A00086BB
2227:108B20008F4B00C4AFAB00648F4A00C0AFAA006C8B
2228:108B30008F4B00CCAFAB00748F4A00C810000129E6
2229:108B4000AFAA007C8F4201140040F8090000000029
2230:108B50000040302110C0034F000000008CC2000014
2231:108B60008CC30004AFA20020AFA300248FAB00246D
2232:108B70008FAA00203162FFFF2442FFFCAFA2006CED
2233:108B80003C02000602C21024AFAB007C144000156A
2234:108B9000AFAA006491420000304200011040001171
2235:108BA0002402FFFF8D430000146200043402FFFF23
2236:108BB000954300041062000B000000000C0024BB71
2237:108BC0008FA40064304200FF144000060000000043
2238:108BD0008F4201180040F809000000001000032D2A
2239:108BE000000000008FA200243C03FFBF3463FFFF9E
2240:108BF000004310243C03FFFF0043182414600003CB
2241:108C0000AFA2002410000040000018213C020080A8
2242:108C10000062102410400007000000008F42038C07
2243:108C200024420001AF42038C8F42038C10000036B7
2244:108C3000240300018F42021024420001AF420210BF
2245:108C40008F4202103C020001006210241040000616
2246:108C50003C0200028F4201C424420001AF4201C421
2247:108C60008F4201C43C020002006210241040000642
2248:108C70003C0200048F42037C24420001AF42037C8B
2249:108C80008F42037C3C020004006210241040000666
2250:108C90003C0200088F42038024420001AF4203805F
2251:108CA0008F4203803C02000800621024104000063E
2252:108CB0003C0200108F42038424420001AF4203842F
2253:108CC0008F4203843C020010006210241040000612
2254:108CD0003C0200208F4201C024420001AF4201C08B
2255:108CE0008F4201C03C0200200062102410400006A8
2256:108CF000240300018F42038824420001AF4203880D
2257:108D00008F420388240300018C0202608FAB006C49
2258:108D1000004B102B10400014307000FF8F4201E810
2259:108D200024420001AF4201E88F4201E88FAA007C93
2260:108D30008F8200E0354A0100AFAA007CAFA200108C
2261:108D40008F8200E4241000013C040001248468A008
2262:108D5000AFA200148FA600208FA700243C050007B7
2263:108D60000C002B3B34A50800120000103C020080D0
2264:108D700002C210241440000E32C204008FAB007CEB
2265:108D80003C020080344201000162102410400005C2
2266:108D9000000000008F42020C24420001AF42020C8E
2267:108DA0008F42020C100002B08FA3006C32C204008C
2268:108DB00010400015340281008FAA00649543000C16
2269:108DC000146200123C020100240B0200A7AB008ECB
2270:108DD0009542000E8D4300088D4400048D4500002F
2271:108DE0008FAA006C8FAB0064254AFFFCAFAA006C11
2272:108DF000A7A20086AD63000CAD640008AD65000459
2273:108E0000256B0004AFAB00643C02010002C21024D9
2274:108E100010400004000000008FAA006C254A0004E6
2275:108E2000AFAA006C8F4200BC5040000AAFA0007493
2276:108E30008FAB006C004B102B50400006AFA00074AD
2277:108E40008F4200BC01621023AFA200748F4A00BCA5
2278:108E5000AFAA006C8F4200808FAB006C004B102BD0
2279:108E60001040005632C280001040005E240A000309
2280:108E700032C210001040005BAFAA005C1000005826
2281:108E8000240B00048F4203502403FFBF0283A0245D
2282:108E900024420001AF4203501000024F8F420350A2
2283:108EA00002C2B0252402FFBF0282A0248F830128C2
2284:108EB0003C040001248468D026620001AFA20014A3
2285:108EC000AFA300108F8601208F8701243C05000787
2286:108ED0000C002B3B34A522501000023F0000000084
2287:108EE00002C2B0252402FFBF0282A0248F83012882
2288:108EF0003C040001248468D024020002AFA20014C4
2289:108F0000AFA300108F8601208F8701243C05000746
2290:108F10000C002B3B34A524501000022F0000000051
2291:108F20008EA200008EA300043C040001248468E8A3
2292:108F3000AFB00010AFBE00148EA7001834A52800F3
2293:108F40000C002B3B006030211000022300000000C9
2294:108F5000A6B1000A8F8201243C040001248468F039
2295:108F6000AFBE0014AFA200108F4600448F870120CF
2296:108F70003C0500070C002B3B34A530001000021606
2297:108F800000000000A6B1000AA6B2000E8F820124E4
2298:108F90003C040001248468FCAFBE0014AFA20010A2
2299:108FA0008F4600448F8701203C0500070C002B3BB7
2300:108FB00034A5320010000208000000008F42008437
2301:108FC0008FAA006C004A102B144000073C020001DD
2302:108FD00002C210241040000400000000240B000214
2303:108FE000AFAB005C8FAA006C1140021B27AB0020C6
2304:108FF000AFAB00A43C0A001F354AFFFFAFAA009C9C
2305:109000008FAB005C240A0001556A0021240A00028B
2306:109010008F4300548F4200501062000B274B0054C6
2307:109020008F5E00543403ECC0AFAB004C27C200018C
2308:10903000304201FFAFA20054001E11400043102136
2309:109040001000006B02E2A8218F4200448FAA006C3E
2310:109050003C040001248468ACAFAA0014AFA2001045
2311:109060008F4600548F4700503C0500070C002B3BF7
2312:1090700034A513008F4303502402FFBF0282A024B3
2313:1090800024630001AF430350100001D38F4203500B
2314:10909000156A001D000000008F4300748F420070AD
2315:1090A0001062000A274B00748F5E0074AFAB004C57
2316:1090B00027C20001304203FFAFA20054001E11403E
2317:1090C00024426CC01000004A02E2A8218F420044F2
2318:1090D0008FAA006C3C040001248468B83C0500079A
2319:1090E000AFAA0014AFA200108F4600748F47007023
2320:1090F00034A51500240B00010C002B3BAFAB005C2A
2321:109100001000FFC3000000008F4300648F42006026
2322:109110001062001A274A00648F5E00648FAB005C07
2323:10912000AFAA004C27C20001304200FFAFA200549A
2324:10913000240200041562000E001E1140001E118062
2325:1091400024420CC002E21021AFA200449442002A43
2326:109150008FAA00448FAB006C004B102B10400024F2
2327:1091600025550020240A000110000021A3AA009721
2328:1091700024424CC01000001E02E2A8218F4200448D
2329:109180008FAB006C3C040001248468C4AFAB0014B6
2330:10919000AFA200108F4600648F4700603C050007B7
2331:1091A0000C002B3B34A518003C02000802C210241E
2332:1091B0001440FF34000000008F420370240A0001B5
2333:1091C000AFAA005C24420001AF4203701000FF9080
2334:1091D0008F42037027A3003600131040006218214D
2335:1091E000946200000044102110000020A4620000DE
2336:1091F0008FAB0064AEAB001893A2009710400072D2
2337:10920000000098218FAA00448FA4006C8FA300A4B3
2338:1092100025420020AFA2002825420008AFA200305E
2339:1092200025420010AFAA002CAFA200349542002ABC
2340:10923000A7A2003895420018A7A2003A9542001A4A
2341:10924000A7A2003C9542001CA7A2003E9462001811
2342:1092500024630002008220231880FFDE26730001B1
2343:109260002E6200041440FFF9000000008F4200FC51
2344:109270002665000100A2102A1440002B24030001DF
2345:109280008F83012C10600023000000008F820124D6
2346:109290000043102300022143588000012484004031
2347:1092A0008F820128004310230002194358600001F7
2348:1092B000246300400064102A544000010060202113
2349:1092C000AF4400FC8F4200FC00A2102A10400011A5
2350:1092D0002403000110000015306200FF8FAB006412
2351:1092E00096070018AFAB00108E2200083C04000166
2352:1092F000248468DC8C4300048C42000034A52400E4
2353:10930000024030210C002B3BAFA300141000002BB7
2354:10931000000000008F4203340000182124420001A5
2355:10932000AF4203348F420334306200FF5040FEDC12
2356:109330003C02080012600021000090218FB100A4BF
2357:10934000022080218E220008960700188FA6006454
2358:109350008C4400008C450004240A0001AFAA0010D0
2359:10936000AFBE00148F420008AFA200188F42010C5C
2360:109370000040F809000000001040FFD83C0500073D
2361:10938000960200188FAB00648FAA009C01625821DE
2362:10939000014B102B10400004AFAB00648F4201481A
2363:1093A00001625823AFAB0064261000022652000170
2364:1093B0000253102B1440FFE3263100048FB0006CE1
2365:1093C0001000003697B100388F4200FC24050002DF
2366:1093D00000A2102A1440001B240300018F83012CDB
2367:1093E00010600013000000008F820124004310234E
2368:1093F0000002214358800001248400408F8201280C
2369:109400000043102300021943586000012463004008
2370:109410000064102A5440000100602021AF4400FC89
2371:109420008F4200FC00A2102A144000062403000111
2372:109430008F4203340000182124420001AF4203345C
2373:109440008F420334306200FF1040FEA53C0208004A
2374:1094500096B1000A8FB0006C3223FFFF0070102B12
2375:1094600054400001006080218EA400008EA50004FD
2376:10947000240B0001AFAB0010AFBE00148F420008F8
2377:109480008FA60064AFA200188F42010C0040F809BB
2378:10949000020038211040FEA23C05000796A3000EF2
2379:1094A00097AA008E1140000700609021934205C4E6
2380:1094B000144000040000000097AB0086006A1825E5
2381:1094C000A6AB00168FAA007C3C02FFFF01421024CD
2382:1094D00010400003000A140234630400A6A2001422
2383:1094E0008FAB006C560B0072A6A3000E3462000412
2384:1094F000A6A2000E8FAA0074016A1021A6A2000A7B
2385:109500008F4300448F4401A08F4501A434028000A2
2386:10951000AFA200108F42004402A030212407002097
2387:10952000AFA200148F42000C0003194000604821D4
2388:10953000AFA200188F42010C0000402100A9282191
2389:1095400000A9182B008820210040F8090083202161
2390:109550005040FE7FA6B2000E8F420368AFA0006CA1
2391:10956000A34005C42442FFFFAF4203688FAB005CF9
2392:10957000240A00018F420368156A0006240A0002CB
2393:109580008F42035C2442FFFFAF42035C1000000CDB
2394:109590008F42035C156A0006000000008F420364DE
2395:1095A0002442FFFFAF420364100000058F420364B2
2396:1095B0008F4203602442FFFFAF4203608F4203608B
2397:1095C0008FAA00548FAB004CAD6A00008F4200445C
2398:1095D0008F4400888F430078244200010044102407
2399:1095E00024630001AF420044AF4300788C02024084
2400:1095F0000062182B14600075240700088F4401686E
2401:109600008F45016C8F4300448F48000C8F860120EA
2402:1096100024020040AFA20010AFA30014AFA80018AE
2403:109620008F42010C0040F80924C6001C14400011B0
2404:10963000240B00013C01000100370821A02B40F25F
2405:109640008F820124AFA200108F8201283C04000108
2406:109650002484688CAFA200148F4600448F870120B9
2407:109660003C0500090C002B3B34A513001000000B37
2408:10967000000000008F42030424420001AF420304B3
2409:109680008F4203048F420044AF42007C3C01000142
2410:1096900000370821A02040F2AF4000788F42031825
2411:1096A00024420001AF420318100000488F42031803
2412:1096B000A6B0000A8F4300448F4401A08F4501A447
2413:1096C00034028000AFA200108F42004402A030217B
2414:1096D00024070020AFA200148F42000C00031940A1
2415:1096E00000604821AFA200188F42010C0000402109
2416:1096F00000A9282100A9182B008820210040F80982
2417:10970000008320211040FE1F240A0001A34A05C443
2418:109710008FAB006C8FAA006401705823AFAB006C54
2419:109720008FAB009C01505021016A102B10400004A7
2420:10973000AFAA00648F42014801425023AFAA0064DF
2421:109740008F4203682442FFFFAF4203688FAA005C88
2422:10975000240B00018F420368154B0006240B000206
2423:109760008F42035C2442FFFFAF42035C1000000CF9
2424:109770008F42035C114B0006000000008F42036023
2425:109780002442FFFFAF420360100000058F420360D8
2426:109790008F4203642442FFFFAF4203648F4203649D
2427:1097A0008FAB00548FAA004CAD4B00008F42004499
2428:1097B0008F4400888F430078244200010044102425
2429:1097C00024630001AF420044AF4300788FAA006CCD
2430:1097D0001540FE0B000000008FAB006C1160001EF6
2431:1097E00000000000934205C4104000090000000082
2432:1097F0008FAA0064AF4A00C4AF4B00C08FAB007C9F
2433:10980000AF4B00C88FAA00741000000EAF4A00CC06
2434:1098100097AB008E1160000B340381008FA20020F3
2435:109820008C46000CA443000C97AA00868C440004CC
2436:109830008C450008A44A000EAC440000AC4500046E
2437:10984000AC4600088F42034C24420001AF42034C57
2438:10985000100000108F42034C8FAB007C3164FFFF7F
2439:109860002484FFFC008018218F4402508F4502544D
2440:109870008F4601180000102100A3282100A3382BD7
2441:109880000082202100872021AF44025000C0F80947
2442:10989000AF4502548FBF00C88FBE00C48FB500C053
2443:1098A0008FB300BC8FB200B88FB100B48FB000B0DE
2444:1098B00003E0000827BD00D003E00008000000001E
2445:1098C00027BDFF38240B0001AFBF00C0AFBE00BCF6
2446:1098D000AFB500B8AFB300B4AFB200B0AFB100AC39
2447:1098E000AFB000A8A3A00087AFA00044AFAB005C5E
2448:1098F000934205C4A7A0007610400007A7A0007EF1
2449:109900008F4C00C0AFAC00648F4B00C88F5E00C4AA
2450:1099100010000130AFAB006C8F4201140040F80919
2451:10992000000000000040302110C002A10000000033
2452:109930008CC200008CC30004AFA20020AFA300249F
2453:109940008FAC00248FBE00203182FFFF2442FFFC39
2454:10995000AFA200643C02000602C2102414400015AD
2455:10996000AFAC006C93C20000304200011040001107
2456:109970002402FFFF8FC30000146200043402FFFFC3
2457:1099800097C300041062000B000000000C0024BB11
2458:1099900003C02021304200FF1440000600000000F8
2459:1099A0008F4201180040F8090000000010000280FA
2460:1099B000000000008FA200243C03FFBF3463FFFFC0
2461:1099C000004310243C03FFFF0043182414600003ED
2462:1099D000AFA2002410000040000080213C02008063
2463:1099E0000062102410400007000000008F42038C2A
2464:1099F00024420001AF42038C8F42038C10000036DA
2465:109A0000241000018F42021024420001AF420210D4
2466:109A10008F4202103C020001006210241040000638
2467:109A20003C0200028F4201C424420001AF4201C443
2468:109A30008F4201C43C020002006210241040000664
2469:109A40003C0200048F42037C24420001AF42037CAD
2470:109A50008F42037C3C020004006210241040000688
2471:109A60003C0200088F42038024420001AF42038081
2472:109A70008F4203803C020008006210241040000660
2473:109A80003C0200108F42038424420001AF42038451
2474:109A90008F4203843C020010006210241040000634
2475:109AA0003C0200208F4201C024420001AF4201C0AD
2476:109AB0008F4201C03C0200200062102410400006CA
2477:109AC000241000018F42038824420001AF42038822
2478:109AD0008F420388241000018C0202608FAB006467
2479:109AE000004B102B10400015320200FF8F4201E89E
2480:109AF00024420001AF4201E88F4201E88FAC006CC4
2481:109B00008F8200E0358C0100AFAC006CAFA200107A
2482:109B10008F8200E4241000013C040001248468A02A
2483:109B2000AFA200148FA600208FA700243C050007D9
2484:109B30000C002B3B34A53600320200FF1040001011
2485:109B40003C02008002C210241440000E32C2040005
2486:109B50008FAB006C3C020080344201000162102493
2487:109B600010400005000000008F42020C244200015A
2488:109B7000AF42020C8F42020C100002028FA300645D
2489:109B800032C20400104000123402810097C3000C5E
2490:109B90001462000F00000000240C0200A7AC007645
2491:109BA00097C2000E8FC300088FC400048FAB0064FF
2492:109BB0008FC50000256BFFFCAFAB0064A7A2007E41
2493:109BC000AFC3000CAFC40008AFC5000427DE00041B
2494:109BD0008FA70064320200FF144000343C020100F1
2495:109BE00097C4000C2C8305DD388288702C4200015C
2496:109BF00000621825106000150000282132C20800FC
2497:109C0000104000152402080097C3001414620012CB
2498:109C10003402AAAA97C3000E146200070000202194
2499:109C200097C3001024020300146200040080102176
2500:109C300097C200122C4400010080102154400006FD
2501:109C40002405001610000004000000002402080093
2502:109C5000508200012405000E10A0001303C520212E
2503:109C6000248300093C02001F3442FFFF0043102BF5
2504:109C700010400003000000008F42014800621823DA
2505:109C800090620000384300062C6300013842001146
2506:109C90002C42000100621825106000043C02010003
2507:109CA00094820002004538213C02010002C21024C7
2508:109CB0005040000EAFA700648FAC006410EC0008A9
2509:109CC0003C0500073C040001248469088FA6006459
2510:109CD00034A54000AFA000100C002B3BAFA0001437
2511:109CE0008FAB0064256B0004AFAB00648F42008033
2512:109CF0008FAC0064004C102B1040002C32C280004E
2513:109D000010400034240B000332C210001040003118
2514:109D1000AFAB005C1000002E240C00048F420350F7
2515:109D20002403FFBF0283A02424420001AF4203505A
2516:109D3000100001738F4203503C02080002C2B0259C
2517:109D40002402FFBF0282A0248F8301283C0400016B
2518:109D5000248468D026620001AFA20014AFA30010D3
2519:109D60008F8601208F8701243C0500070C002B3BC8
2520:109D700034A5530010000162000000008EA2000014
2521:109D80008EA300043C040001248468E8AFB00010F6
2522:109D9000AFB100148EA7001834A559000C002B3B5E
2523:109DA0000060302110000156000000008F42008446
2524:109DB0008FAB0064004B102B144000073C020001E5
2525:109DC00002C210241040000400000000240C000215
2526:109DD000AFAC005C8FAB00641160016627AC002063
2527:109DE000AFAC008C8FAB005C240C0001556C0021E3
2528:109DF000240C00028F4300548F4200501062000B6D
2529:109E0000274B00548F5100543403ECC0AFAB004CCF
2530:109E100026220001304201FFAFA200540011114080
2531:109E2000004310211000006B02E2A8218F42004481
2532:109E30008FAC00643C040001248468ACAFAC001417
2533:109E4000AFA200108F4600548F4700503C0500071A
2534:109E50000C002B3B34A543008F4303502402FFBF6B
2535:109E60000282A02424630001AF43035010000124A8
2536:109E70008F420350156C001D000000008F430074DA
2537:109E80008F4200701062000A274B00748F510074DB
2538:109E9000AFAB004C26220001304203FFAFA20054BA
2539:109EA0000011114024426CC01000004A02E2A821B7
2540:109EB0008F4200448FAC00643C040001248468B8E5
2541:109EC0003C050007AFAC0014AFA200108F46007431
2542:109ED0008F47007034A54500240B00010C002B3B7C
2543:109EE000AFAB005C1000FFC3000000008F430064B4
2544:109EF0008F4200601062001A274C00648F5100648A
2545:109F00008FAB005CAFAC004C26220001304200FF5A
2546:109F1000AFA20054240200041562000E001111408B
2547:109F20000011118024420CC002E21021AFA20044B3
2548:109F30009442002A8FAC00448FAB0064004B102B7E
2549:109F40001040002425950020240C00011000002161
2550:109F5000A3AC008724424CC01000001E02E2A821DE
2551:109F60008F4200448FAB00643C040001248468C429
2552:109F7000AFAB0014AFA200108F4600648F470060A3
2553:109F80003C0500070C002B3B34A548003C020008B0
2554:109F900002C210241440FF61000000008F420370D1
2555:109FA000240C0001AFAC005C24420001AF420370FE
2556:109FB0001000FF908F42037027A30036001310405B
2557:109FC0000062182194620000004410211000001F5C
2558:109FD000A4620000AEBE001893A200871040008467
2559:109FE000000098218FAB00448FA400648FA3008CE5
2560:109FF00025620020AFA2002825620008AFA2003031
2561:10A0000025620010AFAB002CAFA200349562002A8D
2562:10A01000A7A2003895620018A7A2003A9562001A1C
2563:10A02000A7A2003C9562001CA7A2003E9462001803
2564:10A0300024630002008220231880FFDF26730001C2
2565:10A040002E6200041440FFF9000000008F4200FC63
2566:10A050000262102A14400030240300018F83012C77
2567:10A0600010600028000000008F82012400431023AC
2568:10A070000002214358800001248400408F8201287F
2569:10A08000004310230002194358600001246300407C
2570:10A090000064102A5440000100602021AF4400FCFD
2571:10A0A0008F4200FC0262102A1040001624030001B7
2572:10A0B0001000001A306200FF8FAC008C00101040BE
2573:10A0C000004C10219447001800101080004C102103
2574:10A0D000AFBE00108C4200083C040001248468DC00
2575:10A0E0003C0500078C4300048C42000034A5550059
2576:10A0F000020030210C002B3BAFA3001410000039EC
2577:10A10000000000008F4203340000182124420001A7
2578:10A11000AF4203348F420334306200FF1040FF0629
2579:10A12000000080218F4300082402FBFF1260002DF5
2580:10A13000006250243C0B4000022B40258FB1008C64
2581:10A140002669FFFF022090218E4200089627001802
2582:10A150008C4400008C45000456090004240B0001C7
2583:10A16000240C000210000002AFAC0010AFAB0010D6
2584:10A1700016000004AFA800148F420008100000026F
2585:10A18000AFA20018AFAA00188F42010C03C0302103
2586:10A19000AFA80098AFA9009C0040F809AFAA00A0A2
2587:10A1A0008FA800988FA9009C8FAA00A01040FFC222
2588:10A1B0003C02001F962300183442FFFF03C3F02126
2589:10A1C000005E102B10400003263100028F42014830
2590:10A1D00003C2F023261000010213102B1440FFDAF3
2591:10A1E000265200048FB000641000001A0000000026
2592:10A1F00096A3000A8FB000640070102B5440000139
2593:10A20000006080218EA400008EA500048FAB005C4E
2594:10A21000240C0002AFAC0010934305C4000B1700E0
2595:10A2200010600003022230253C02080000C23025E5
2596:10A23000AFA600148F420008AFA200188F42010C95
2597:10A2400003C030210040F809020038211040FECB45
2598:10A250003C05000797AC00761180000796A3000E1E
2599:10A26000934205C4144000040000000097AB007E38
2600:10A27000006C1825A6AB00168FAC006C3C02FFFFEB
2601:10A280000182102410400003000C14023463040007
2602:10A29000A6A20014A6B0000A8FAB0064560B0006FD
2603:10A2A00003D0F02134620004AFA00064A6A2000E27
2604:10A2B0001000000DA34005C48FAC00643C02001FD9
2605:10A2C0003442FFFF005E102B01906023AFAC0064AE
2606:10A2D000A6A3000E240B000110400003A34B05C4ED
2607:10A2E0008F42014803C2F0238FAB00548FAC004C67
2608:10A2F000AD8B00008FAC00641580FEBA000000003A
2609:10A300008FAB00641160001B00000000934205C485
2610:10A310001040000600000000AF5E00C4AF4B00C05C
2611:10A320008FAC006C1000000EAF4C00C897AB0076ED
2612:10A330001160000B340381008FA200208C46000CBA
2613:10A34000A443000C97AC007E8C4400048C450008AC
2614:10A35000A44C000EAC440000AC450004AC46000820
2615:10A360008F42034C24420001AF42034C1000001006
2616:10A370008F42034C8FAB006C3164FFFF2484FFFCE1
2617:10A38000008018218F4402508F4502548F460118D7
2618:10A390000000102100A3282100A3382B00822021D7
2619:10A3A00000872021AF44025000C0F809AF45025495
2620:10A3B0008FBF00C08FBE00BC8FB500B88FB300B494
2621:10A3C0008FB200B08FB100AC8FB000A803E00008DE
2622:10A3D00027BD00C803E000080000000027BDFFD82B
2623:10A3E000AFBF0024AFB000208F43004C8F42004825
2624:10A3F00010620034000000008F4300488F42004C80
2625:10A400000062202304820001248402008F43005450
2626:10A410008F42004C0043102B144000042402020021
2627:10A420008F43004C10000005004310238F4200545E
2628:10A430008F43004C004310232442FFFF0040502173
2629:10A44000008A102A54400001008050218F49004C9E
2630:10A450008F48004C8F4401888F45018C8F46004CFB
2631:10A4600024071000AFA70010000841400100182188
2632:10A47000012A4821313001FFAFB000148F4700148A
2633:10A480000000102100063140AFA7001800A32821CA
2634:10A4900000A3382B00822021008720213402ECC049
2635:10A4A00000C230218F42010802E630210040F80945
2636:10A4B000000A394054400001AF50004C8F43004C1B
2637:10A4C0008F42004814620018000000008F42000014
2638:10A4D0001040000700000000AF80004C8F82004C4D
2639:10A4E0001040FFFD0000000010000005000000000B
2640:10A4F000AF8000488F8200481040FFFD0000000040
2641:10A500008F8200602403FDFF00431024AF820060AF
2642:10A510008F42000010400003000000001000000205
2643:10A52000AF80004CAF8000488FBF00248FB0002068
2644:10A5300003E0000827BD002803E000080000000039
2645:10A5400027BDFFD8AFBF0024AFB000208F43005C11
2646:10A550008F42005810620049000000008F430058ED
2647:10A560008F42005C006220230482000124840100E9
2648:10A570008F4300648F42005C0043102B14400004A2
2649:10A58000240201008F43005C1000000500431023EB
2650:10A590008F4200648F43005C004310232442FFFF7E
2651:10A5A000004038210087102A5440000100803821E3
2652:10A5B0008F42005C00471021305000FF32C2100073
2653:10A5C00010400015240820008F49005C8F44019042
2654:10A5D0008F4501948F46005C00073980AFA80010BA
2655:10A5E000AFB000148F4800140009498001201821E1
2656:10A5F0000000102100A3282100A3482B0082202165
2657:10A600000089202100063180AFA800188F42010880
2658:10A610001000001424C60CC08F49005C8F440190C8
2659:10A620008F4501948F46005C00073940AFA80010A9
2660:10A63000AFB000148F4800140009494001201821D0
2661:10A640000000102100A3282100A3482B0082202114
2662:10A650000089202100063140AFA800188F42010870
2663:10A6600024C64CC00040F80902E6302154400001E5
2664:10A67000AF50005C8F43005C8F420058146200189A
2665:10A68000000000008F4200001040000700000000A2
2666:10A69000AF80004C8F82004C1040FFFD0000000096
2667:10A6A0001000000500000000AF8000488F820048C5
2668:10A6B0001040FFFD000000008F8200602403FEFFB9
2669:10A6C00000431024AF8200608F420000104000035E
2670:10A6D0000000000010000002AF80004CAF80004876
2671:10A6E0008FBF00248FB0002003E0000827BD0028A2
2672:10A6F00003E000080000000027BDFFD8AFBF002422
2673:10A70000AFB000208F43006C8F42006810620033AE
2674:10A71000000000008F4300688F42006C006220231D
2675:10A7200004820001248404008F4300748F42006C73
2676:10A730000043102B14400004240204008F43006CDB
2677:10A7400010000005004310238F4200748F43006CFB
2678:10A75000004310232442FFFF00405021008A102AAA
2679:10A7600054400001008050218F49006C8F48006CDC
2680:10A770008F4401988F45019C8F46006C2407400050
2681:10A78000AFA700100008414001001821012A48210C
2682:10A79000313003FFAFB000148F47001400001021C8
2683:10A7A0000006314024C66CC0AFA7001800A32821C2
2684:10A7B00000A3382B00822021008720218F4201082E
2685:10A7C00002E630210040F809000A394054400001F7
2686:10A7D000AF50006C8F43006C8F4200681462001809
2687:10A7E000000000008F420000104000070000000041
2688:10A7F000AF80004C8F82004C1040FFFD0000000035
2689:10A800001000000500000000AF8000488F82004863
2690:10A810001040FFFD000000008F8200602403F7FF5E
2691:10A8200000431024AF8200608F42000010400003FC
2692:10A830000000000010000002AF80004CAF80004814
2693:10A840008FBF00248FB0002003E0000827BD002840
2694:10A8500003E00008000000008F4200FC3C03000100
2695:10A860008F4400F8346330C824420001AF4200FC3A
2696:10A870008F85012802E310215482000424820008FD
2697:10A880003C02000134422EC802E21021004018218F
2698:10A89000AF4300F8AC6000008F4200F41462000483
2699:10A8A0003C02000124A200201000000FAF8201280A
2700:10A8B0008F4300F8344230C802E210215462000491
2701:10A8C000246200083C02000134422EC802E210213A
2702:10A8D000004018218C6200040002114000A21021E7
2703:10A8E000AF820128AC6000008CA3001830620070B9
2704:10A8F0001040002D30620020104000043C02001087
2705:10A9000002C210241040000D000000003062004020
2706:10A91000104000043C02002002C210241040000736
2707:10A9200000000000306200101040001F3C02004098
2708:10A9300002C210241440001C000000008F8200405E
2709:10A940003042000114400008000020218C03010463
2710:10A950002402000150620005240400018C020264FC
2711:10A960001040000300801021240400010080102109
2712:10A9700010400006000000008F42030C244200013A
2713:10A98000AF42030C100000088F42030C8F8200447A
2714:10A9900034420004AF8200448F4203082442000185
2715:10A9A000AF4203088F42030803E0000800000000E4
2716:10A9B00003E000080000000027BDFF98AFBF006063
2717:10A9C000AFBE005CAFB50058AFB30054AFB200509B
2718:10A9D000AFB1004CAFB000488F4200FC24420001F0
2719:10A9E000AF4200FC8F88012825020020AF82012899
2720:10A9F0008D030018306200701040002E306200207D
2721:10AA0000104000043C02001002C210241040000D4F
2722:10AA10000000000030620040104000043C020020B2
2723:10AA200002C2102410400007000000003062001035
2724:10AA3000104001A93C02004002C21024144001A6AB
2725:10AA4000000000008F8200403042000114400008E6
2726:10AA5000000020218C030104240200015062000543
2727:10AA6000240400018C0202641040000300801021C5
2728:10AA700024040001008010211040000600000000A6
2729:10AA80008F42030C24420001AF42030C10000192DC
2730:10AA90008F42030C8F82004434420004AF82004492
2731:10AAA0008F42030824420001AF4203081000018ACC
2732:10AAB0008F420308306200021040014B3C02080044
2733:10AAC0008D1E001C001E5702AFAA0034950A001606
2734:10AAD00003C22024AFAA00248FAA0034240200015C
2735:10AAE0001542000633DEFFFF001E11403403ECC0A8
2736:10AAF000004310211000001002E2A82124020002ED
2737:10AB00001542000524020003001E114024426CC0BF
2738:10AB10001000000902E2A82115420005001E118064
2739:10AB2000001E114024424CC01000000302E2A82184
2740:10AB30000057102124550CE096A2000E304AFFFC6D
2741:10AB40003042040010400003AFAA002C100000E1C6
2742:10AB500000008821108000040000882197B10026A1
2743:10AB6000100000DDA6B100128EB30018966A000C2A
2744:10AB7000A7AA003E97A5003E2CA305DD38A2887049
2745:10AB80002C420001006218251060001500002021F1
2746:10AB900032C2080010400015240208009663001419
2747:10ABA000146200123402AAAA9663000E146200070F
2748:10ABB00000002821966300102402030014620004A0
2749:10ABC00000A01021966200122C45000100A0102167
2750:10ABD0005440000624040016100000040000000089
2751:10ABE0002402080050A200012404000E108000B9C5
2752:10ABF00002649021924200003042000F00028080E7
2753:10AC000032C2010010400020025018213C020020F6
2754:10AC10000043102B1440000E024020210000282188
2755:10AC2000948200002484000200A228210083102BBB
2756:10AC30001440FFFB30A2FFFF00051C020062282128
2757:10AC400000051C0230A2FFFF10000009006228214D
2758:10AC50008F4701488F420110001028423C06002017
2759:10AC60000040F809AFA800403045FFFF8FA8004022
2760:10AC700050A000013405FFFF8FAA002C354A0002C6
2761:10AC800010000002AFAA002C0000282132C2008070
2762:10AC900010400090A6A50010264300093C02001FAA
2763:10ACA0003442FFFF0043102B10400003000000005F
2764:10ACB0008F420148006218239066000030C200FFF6
2765:10ACC000384300062C630001384200112C42000179
2766:10ACD000006218251060007F24020800000088210F
2767:10ACE00097A3003E1462000F0260202196710000BD
2768:10ACF0009662000296630004966400060222882190
2769:10AD00000223882102248821966200089663000AA3
2770:10AD10009664000C0222882102238821100000077B
2771:10AD200002248821948200002484000202228821C7
2772:10AD30000092102B1440FFFB0000000000111C02C9
2773:10AD40003222FFFF0062882100111C023222FFFF25
2774:10AD50000062882132C2020010400003264400062F
2775:10AD60001000003E000080213C05001F34A5FFFFBD
2776:10AD700000A4102B10400003000000008F42014887
2777:10AD8000008220239482000030421FFF1040000404
2778:10AD90002644000C96420002100000300050802330
2779:10ADA0009642000226430014005080233C020020FB
2780:10ADB0000043102B1440000A00D080219642000C62
2781:10ADC000020280219642000E964300109644001223
2782:10ADD0000202802102038021100000200204802151
2783:10ADE00000A4102B10400003000000008F42014817
2784:10ADF0000082202394820000248400020202802129
2785:10AE000000A4102B10400003000000008F420148F6
2786:10AE10000082202394820000248400020202802108
2787:10AE200000A4102B10400003000000008F420148D6
2788:10AE300000822023948200002484000202028021E8
2789:10AE400000A4102B10400003000000008F420148B6
2790:10AE50000082202394820000020280213C02010033
2791:10AE600002C210241040000E000000008FAA002C27
2792:10AE7000314200041040000A000000009504000E5A
2793:10AE8000026420210C003EEC2484FFFC3042FFFFD2
2794:10AE90000222882100111C023222FFFF0062882159
2795:10AEA0008FAA002401518823001114020222882154
2796:10AEB0000230882100111402022288213231FFFF62
2797:10AEC000522000013411FFFF8FAA002C354A0001E7
2798:10AED000AFAA002CA6B1001297AA002EA6AA000EB7
2799:10AEE0008FAA002C314200041040000224091000F7
2800:10AEF000340980008F4800448F4401A08F4501A48D
2801:10AF0000AFA900108F4900440008414001001821FA
2802:10AF1000AFA900148F48000C02A0302124070020A4
2803:10AF2000AFA800188F48010C0000102100A32821B1
2804:10AF300000A3482B008220210100F809008920216C
2805:10AF40001440000B000000008F8201283C04000127
2806:10AF500024846914AFBE0014AFA200108F860124B0
2807:10AF60008F8701203C0500070C002B3B34A599205E
2808:10AF70008F4203682442FFFFAF4203688F420044C0
2809:10AF80008F4300882442000100431024AF42004454
2810:10AF90008FAA00348F440368240200011542000682
2811:10AFA000240200028F42035C2442FFFFAF42035C95
2812:10AFB000100000498F42035C1542000600000000AB
2813:10AFC0008F4203642442FFFFAF420364100000423B
2814:10AFD0008F4203648F4203602442FFFFAF4203604D
2815:10AFE0001000003D8F4203603062100010400005E9
2816:10AFF000306280008F420078244200011000003649
2817:10B00000AF42007810400034000000008F4200780A
2818:10B0100024420001AF4200788C0302400043102B11
2819:10B020001440002D240700088F4401688F45016CEF
2820:10B030008F4300448F48000C8F860120240200407B
2821:10B04000AFA20010AFA30014AFA800188F42010CEC
2822:10B050000040F80924C6001C14400011240200011D
2823:10B060003C01000100370821A02240F28F82012418
2824:10B07000AFA200108F8201283C0400012484688C58
2825:10B08000AFA200148F4600448F8701203C050009C1
2826:10B090000C002B3B34A513001000000B0000000037
2827:10B0A0008F42030424420001AF4203048F42030491
2828:10B0B0008F420044AF42007C3C0100010037082170
2829:10B0C000A02040F2AF4000788F42031824420001D4
2830:10B0D000AF4203188F4203188FBF00608FBE005C21
2831:10B0E0008FB500588FB300548FB200508FB1004C11
2832:10B0F0008FB0004803E0000827BD006803E00008A7
2833:10B100000000000000000000000000008F42013C31
2834:10B11000AF8200C08F42013CAF8200C48F42013C2D
2835:10B12000AF8200C88F420138AF8200D08F42013811
2836:10B13000AF8200D48F42013803E00008AF8200D80C
2837:10B1400027BDFFE02784020824050200AFBF0018D6
2838:10B150000C002BBF240600088C0202040C004012D5
2839:10B16000AF8202103C0200018C426D94304200021A
2840:10B170001040000E000020218C060248240200022C
2841:10B180003C010001AC226D980C0051042405000222
2842:10B19000000020218C060248240200013C0100012D
2843:10B1A000AC226D9810000011240500018C060248A5
2844:10B1B000240200043C010001AC226D980C005104F3
2845:10B1C000240500043C0200018C426D9430420001D1
2846:10B1D00010400008240200013C010001AC226D98DF
2847:10B1E00000002021240500013C06601B0C005104D6
2848:10B1F000000000003C040001248469D08F4201500B
2849:10B200008F4301543C0500088F4601580002164048
2850:10B21000000319403463040300431025000633C0C3
2851:10B2200000461025AF82021CAFA00010AFA0001492
2852:10B230008F86021C34A502000C002B3B0000382135
2853:10B240003C010001AC206D903C010001AC206DA8D8
2854:10B250008FBF001803E0000827BD002027BDFFE0D6
2855:10B260003C05000834A50300AFBF0018AFA00010D4
2856:10B27000AFA000148F8602003C040001248469DC26
2857:10B280000C002B3B000038218F42041024420001A7
2858:10B29000AF4204108F4204108FBF001803E0000873
2859:10B2A00027BD002027BDFFD8AFBF0020AFB1001CD5
2860:10B2B000AFB000188F4203A424420001AF4203A4A0
2861:10B2C0008F4203A48F9002208F8200E0AFA2001073
2862:10B2D0008F8200E4AFA200148F8600C48F8700C85D
2863:10B2E0003C040001248469E80C002B3B0200282167
2864:10B2F0003C04400002041024504000B43C0401000F
2865:10B300008F4203BC24420001AF4203BC8F4203BC06
2866:10B310008F8700C48F8300C88F42014800671823BD
2867:10B320000043102B10400003000000008F42014832
2868:10B330000062182110600005000000008F42014CDF
2869:10B340000043102B1040000B000000008F8200E033
2870:10B350008F430124AF42011CAF4301148F820220AE
2871:10B360003C0308FF3463FFFB00431024100000CEB1
2872:10B37000004410258F8202203C0308FF3463FFFF46
2873:10B380000043102434420004AF8202208F8200E088
2874:10B390008F430124AF42011CAF4301148F8600C8C4
2875:10B3A0008F8401208F8301241000000500002821D4
2876:10B3B0001462000224620020276248000040182125
2877:10B3C0001064000C30A200FF8C62001830420003B1
2878:10B3D0001040FFF727624FE08F4203D024050001A1
2879:10B3E00024420001AF4203D08F4203D08C66000894
2880:10B3F00030A200FF1440005800000000934205C432
2881:10B4000014400055000000008F8700C48F8800E0C2
2882:10B410008F8400E42402FFF8010240240104102379
2883:10B42000000218C3046200012463020010600005DA
2884:10B430002402000110620009000000001000001F3B
2885:10B44000000000008F4203C000E0302124420001D0
2886:10B45000AF4203C0100000408F4203C08F4203C4BC
2887:10B4600024420001AF4203C48C8600008F42014891
2888:10B470008F4303C400E618230043102B1040000440
2889:10B480002C62233F8F420148006218212C62233F27
2890:10B4900014400031000000008F42020C24420001E1
2891:10B4A000AF42020C8F42020C00E0302124820008DF
2892:10B4B000AF8200E410000028AF8200E88F4203C88A
2893:10B4C00024420001AF4203C88F4203C88C850000AC
2894:10B4D0008F42014800A718230043102B104000039F
2895:10B4E000000000008F420148006218218F42014C89
2896:10B4F0000043102B5440000A00A030218F42020C60
2897:10B5000024420001AF42020C8F42020C2482000848
2898:10B51000AF8200E48F8400E41488FFECAF8400E87D
2899:10B520001488000D27623000148200022482FFF884
2900:10B5300027623FF8944300063C02001F3442FFFF9D
2901:10B5400000C330210046102B104000030000000013
2902:10B550008F42014800C23023AF8600C88F8300C4E9
2903:10B560008F42014800C318230043102B10400003F2
2904:10B57000000000008F4201480062182110600005A1
2905:10B58000000000008F42014C0043102B5040000887
2906:10B590003C02FDFF8F8202203C0308FF3463FFFB67
2907:10B5A000004310243C0340001000003F00431025DE
2908:10B5B0008F4303CC3442FFFF0282A02424630001A6
2909:10B5C000AF4303CC100000398F4203CC0204102497
2910:10B5D0001040000E3C1102008F4203A824420001DB
2911:10B5E000AF4203A88F4203A88F8202203C0308FFCA
2912:10B5F0003463FFFF00431024004410250C003DAFCE
2913:10B60000AF82022010000029000000000211102467
2914:10B61000504000083C1104008F4203AC244200015A
2915:10B62000AF4203AC0C003DAF8F4203AC10000019D9
2916:10B6300000000000021110241040001C0000000057
2917:10B640008F83022424021402146200093C050008BE
2918:10B650003C040001248469F4AFA00010AFA00014E2
2919:10B660008F86022434A505000C002B3B00003821F6
2920:10B670008F4203B024420001AF4203B08F4203B0B7
2921:10B680008F82022002002021344200020C004E9CD6
2922:10B69000AF8202208F8202203C0308FF3463FFFF49
2923:10B6A0000043102400511025AF8202208FBF0020DC
2924:10B6B0008FB1001C8FB0001803E0000827BD0028E0
2925:10B6C00003E00008000000003C0200018C426DA86D
2926:10B6D00027BDFFB0AFBF0048AFBE0044AFB50040CC
2927:10B6E000AFB3003CAFB20038AFB100341040000F30
2928:10B6F000AFB000303C04000124846A003C0500081F
2929:10B70000AFA00010AFA000148F86022034A5060061
2930:10B71000240200013C010001AC206DA83C010001A5
2931:10B72000AC226D9C0C002B3B000038213C037FFFBA
2932:10B730008C0202683463FFFF3C04FDFF00431024C9
2933:10B74000AC0202688F4200043484FFFF30420002E2
2934:10B75000104000920284A0243C040600348420009F
2935:10B760008F420004000028212403FFFD0043102421
2936:10B77000AF420004AFA400208F5E001827AA00206B
2937:10B78000240200FF13C20002AFAA002C27C500014B
2938:10B790008C02022800A090211642000E001E38C024
2939:10B7A0008F42033C24420001AF42033C8F42033CE2
2940:10B7B0008C0202283C040001248469983C0500099D
2941:10B7C000AFA00014AFA200108FA600201000006DE3
2942:10B7D00034A5050000F710218FA300208FA40024BA
2943:10B7E000AC4304C0AC4404C48F8300548F82005423
2944:10B7F000247003E8020210232C4203E91040001BCE
2945:10B800000000982100E08821263504C08F4401788B
2946:10B810008F45017C02201821240A0004AFAA0010E1
2947:10B82000AFB200148F48000C0000102102F5302147
2948:10B83000AFA800188F48010C2407000800A3282196
2949:10B8400000A3482B008220210100F8090089202153
2950:10B8500054400006241300018F820054020210237A
2951:10B860002C4203E91440FFE900000000326200FFAF
2952:10B8700054400017AF5200188F4203782442000151
2953:10B88000AF4203788F4203788F8201208FAA002C69
2954:10B89000AFA200108F8201243C040001248469A41B
2955:10B8A0003C050009AFA200148D46000010000035D1
2956:10B8B00034A506008F42030824130001244200012E
2957:10B8C000AF4203088F4203081000001E326200FFDF
2958:10B8D0008F8300548F820054247003E802021023E7
2959:10B8E0002C4203E910400016000098213C1500206E
2960:10B8F000241100108F42000C8F4401608F450164B9
2961:10B900008F860120AFB10010AFB200140055102592
2962:10B91000AFA200188F42010C240700080040F8096C
2963:10B9200024C6001C1440FFE3000000008F82005476
2964:10B93000020210232C4203E91440FFEE0000000035
2965:10B94000326200FF14400011000000008F420378B3
2966:10B9500024420001AF4203788F4203788F82012096
2967:10B960008FAA002CAFA200108F8201243C0400019A
2968:10B97000248469AC3C050009AFA200148D46000088
2969:10B9800034A507000C002B3B03C038218F4202EC8A
2970:10B9900024420001AF4202EC8F4202EC8FBF00480C
2971:10B9A0008FBE00448FB500408FB3003C8FB200388B
2972:10B9B0008FB100348FB0003003E0000827BD005085
2973:10B9C0003C0200018C426DA827BDFFE01440000D31
2974:10B9D000AFBF00183C04000124846A0C3C05000839
2975:10B9E000AFA00010AFA000148F86022034A507007E
2976:10B9F000240200013C010001AC226DA80C002B3B8D
2977:10BA0000000038213C02000402C21024104000074C
2978:10BA1000000000008F8202203C0308FF3463FFFF18
2979:10BA20000043102434420008AF8202203C0500018C
2980:10BA30008CA56D982402000114A2000700002021AB
2981:10BA40000C00529B24050001AC02026C8C03026CBA
2982:10BA5000100000063C0200070C00529B0000202151
2983:10BA6000AC0202688C0302683C02000700621824E2
2984:10BA70003C0200025062000D3C0205F50043102B11
2985:10BA8000144000063C0200043C0200011062000960
2986:10BA90003C0200981000000B000000001462000936
2987:10BAA0003C023B9A100000043442CA00100000021D
2988:10BAB0003442E10034429680AF4201FC8F4201FCE7
2989:10BAC000AEE200648FBF001803E0000827BD00202D
2990:10BAD0000000000000000000000000000086102BA5
2991:10BAE000504000010087202300C410230002484377
2992:10BAF0000125102B1040001B00091040008240213E
2993:10BB00000088102B104000070000182194820000CC
2994:10BB100024840002006218210088102B1440FFFBCF
2995:10BB2000000000000060202100C7302300A910237E
2996:10BB30000002104000C2282100C5102B1040000751
2997:10BB40000000182194C2000024C6000200621821DF
2998:10BB500000C5102B1440FFFB000000001000000D7A
2999:10BB60000083202100051040008228210085102B31
3000:10BB70001040000700001821948200002484000275
3001:10BB8000006218210085102B1440FFFB000000000C
3002:10BB90000060202100041C023082FFFF006220218F
3003:10BBA00000041C023082FFFF0062202103E0000835
3004:10BBB0003082FFFF03E00008000000000080282121
3005:10BBC00030A200011040002B3C03001F3463FFFF34
3006:10BBD00024A200040062102B544000070065102BC3
3007:10BBE00090A2000190A4000390A3000090A5000281
3008:10BBF0001000002A00441021104000030000000043
3009:10BC00008F42014800A2282390A4000024A500012F
3010:10BC10000065102B10400003000000008F42014817
3011:10BC200000A2282390A2000024A500010002120017
3012:10BC3000008220210065102B10400003000000004E
3013:10BC40008F42014800A2282390A2000024A50001F1
3014:10BC5000008220210065102B10400003000000002E
3015:10BC60008F42014800A2282390A200001000002D5E
3016:10BC7000000212003463FFFF24A200040062102BB4
3017:10BC80005440000A0065102B90A2000090A400020E
3018:10BC900090A3000190A500030044102100021200AF
3019:10BCA00000651821100000200043202110400003EF
3020:10BCB000000000008F42014800A2282390A200004B
3021:10BCC00024A50001000222000065102B1040000393
3022:10BCD000000000008F42014800A2282390A200002B
3023:10BCE00024A50001008220210065102B10400003D4
3024:10BCF000000000008F42014800A2282390A200000B
3025:10BD000024A5000100021200008220210065102BF2
3026:10BD100010400003000000008F42014800A22823C9
3027:10BD200090A200000082202100041C023082FFFF4C
3028:10BD30000062202100041C023082FFFF00622021EB
3029:10BD400003E000083082FFFF000000008F82022025
3030:10BD500034420002AF8202203C0200028C428FF883
3031:10BD60003042400010400054240400018F82020041
3032:10BD700024067FFF8F830200304500022402FFFD6E
3033:10BD800000621824AF830200AF8402048F83005442
3034:10BD90008F82005410000002246300018F8200543F
3035:10BDA000006210232C4200021440FFFC000000003F
3036:10BDB0008F8202241444004D0004204000C4102B44
3037:10BDC0001040FFF1000000008F82020000451025A6
3038:10BDD000AF8202008F82022034428000AF820220B4
3039:10BDE0008F8300548F8200541000000224630001EE
3040:10BDF0008F820054006210232C4200021440FFFC8A
3041:10BE0000000000008F8202203C0300040043102445
3042:10BE10001440000F000000008F8202203C03FFFF4F
3043:10BE200034637FFF00431024AF8202208F830054CD
3044:10BE30008F82005410000002246300018F8200549E
3045:10BE4000006210232C4200021440FFFC000000009E
3046:10BE50008F8202203C030004004310241440000D94
3047:10BE6000000000008F82022034428000AF82022056
3048:10BE70008F8300548F82005410000002246300015D
3049:10BE80008F820054006210232C4200021440FFFCF9
3050:10BE9000000000008F8202203C03000400431024B5
3051:10BEA0001040001B000010218F830220240200019B
3052:10BEB000100000153C04F7008F8202203C04F700BC
3053:10BEC00000441025AF8202208F8202202403FFFD50
3054:10BED00000431024AF8202208F8202203C03030023
3055:10BEE000004310241440000300000000100000086C
3056:10BEF000000010218F82022034420002AF82022013
3057:10BF00008F8302202402000100641825AF830220E1
3058:10BF100003E0000800000000000020213C050100B3
3059:10BF200024020001AF80021CAF820200AF82022017
3060:10BF300027625000AF8200C027625000AF8200C469
3061:10BF400027625000AF8200C827625000AF8200D045
3062:10BF500027625000AF8200D427625000AF8200D821
3063:10BF600027623000AF8200E027623000AF8200E439
3064:10BF700027623000AF8200E827622800AF8200F01D
3065:10BF800027622800AF8200F427622800AF8200F801
3066:10BF9000000418C02484000103631021AC45300460
3067:10BFA00003631021AC403000288202001440FFF9E6
3068:10BFB000000418C000002021000418C024840001DF
3069:10BFC00003631021AC40280403631021AC40280017
3070:10BFD000288201001440FFF9000418C0AF80023C21
3071:10BFE0002403008024040100AC60000024630004EA
3072:10BFF0000064102B5440FFFDAC6000008F830040B4
3073:10C000003C02F000006218243C0250001062000C58
3074:10C010000043102B144000063C0260003C0240002C
3075:10C020001062000824020800100000080000000050
3076:10C030001062000424020800100000040000000048
3077:10C04000240207003C010001AC226DAC03E00008B3
3078:10C05000000000003C0200018C426DBC27BDFFD0F7
3079:10C06000AFBF002CAFB20028AFB10024AFB00020AA
3080:10C070003C01000110400005AC206D940C004D9E69
3081:10C08000000000003C010001AC206DBC8F83005417
3082:10C090008F82005410000002246300648F820054D9
3083:10C0A000006210232C4200651440FFFC00000000D9
3084:10C0B0000C004DB9000000002404000100002821FC
3085:10C0C00027A60018340280000C0045BEA7A2001865
3086:10C0D0008F8300548F820054100000022463006498
3087:10C0E0008F820054006210232C4200651440FFFC34
3088:10C0F00024040001240500010C00457C27A600183B
3089:10C100008F8300548F820054100000022463006467
3090:10C110008F820054006210232C4200651440FFFC03
3091:10C1200024040001240500010C00457C27A600180A
3092:10C130008F8300548F820054100000022463006437
3093:10C140008F820054006210232C4200651440FFFCD3
3094:10C15000240400013C06000124C66F240C00457C29
3095:10C16000240500028F8300548F82005410000002C7
3096:10C17000246300648F820054006210232C42006507
3097:10C180001440FFFC24040001240500033C100001BE
3098:10C1900026106F260C00457C0200302197A600185F
3099:10C1A0003C07000194E76F243C04000124846AE00A
3100:10C1B000AFA00014960200003C05000D34A501005C
3101:10C1C0000C002B3BAFA2001097A200181040004DAE
3102:10C1D00024036040960200003042FFF01443000C3C
3103:10C1E000240200203C03000194636F241462000BBE
3104:10C1F00024027830240200033C010001AC226D943B
3105:10C20000240200053C0100011000003FAC226F3405
3106:10C210003C03000194636F24240278301462000C04
3107:10C22000240300103C02000194426F263042FFF0CC
3108:10C2300014430007240200033C010001AC226D946A
3109:10C24000240200063C0100011000002FAC226F34D4
3110:10C250003C0200018C426D943C03000194636F2406
3111:10C26000344200013C010001AC226D94240200150F
3112:10C270001462000B000000003C02000194426F2693
3113:10C280003042FFF03843F4202C6300013842F43090
3114:10C290002C420001006218251460001B24020003D8
3115:10C2A0003C03000194636F2424027810146200168A
3116:10C2B000240200023C02000194426F263042FFF04B
3117:10C2C00014400011240200021000000F2402000498
3118:10C2D0003C0200018C426D94344200083C01000194
3119:10C2E000AC226D941000005E240200043C020001A8
3120:10C2F0008C426D94344200043C010001100000AFF8
3121:10C30000AC226D94240200013C010001AC226F407C
3122:10C310003C0200018C426D9430420002144000B295
3123:10C320003C09FFF024020E00AF8202388F840054D3
3124:10C330008F820054240300083C010001AC236D9857
3125:10C3400010000002248401F48F8200540082102324
3126:10C350002C4201F51440FFFC3C0200C8344201FBB2
3127:10C36000AF8202388F8300548F8200541000000285
3128:10C37000246301F48F820054006210232C4201F5E3
3129:10C380001440FFFC00008021241200012411000948
3130:10C390000C004482000000003C010001AC326DB48E
3131:10C3A0000C004547000000003C0200018C426DB4C7
3132:10C3B0001451FFFB3C0200C8344201F6AF82023840
3133:10C3C0008F8300548F820054100000022463000AFF
3134:10C3D0008F820054006210232C42000B1440FFFC9B
3135:10C3E000000000008F820220240400013442000279
3136:10C3F000AF8202208F83020024057FFF2402FFFD0D
3137:10C4000000621824AF830200AF8402048F830054BB
3138:10C410008F82005410000002246300018F820054B8
3139:10C42000006210232C4200021440FFFC00000000B8
3140:10C430008F8202241444000534028000000420404E
3141:10C4400000A4102B1040FFF0340280001082FFA0E7
3142:10C45000261000012E0200141440FFCD2402000417
3143:10C460003C010001AC226D980000802124120009DB
3144:10C470003C11FFFF36313F7F0C004482000000007A
3145:10C48000240200013C010001AC226DB40C004547C0
3146:10C49000000000003C0200018C426DB41452FFFB0E
3147:10C4A000000000008F82004400511024344250806C
3148:10C4B000AF8200448F8300548F820054100000022A
3149:10C4C0002463000A8F820054006210232C42000B68
3150:10C4D0001440FFFC000000008F8200440051102433
3151:10C4E0003442F080AF8200448F8300548F82005426
3152:10C4F000100000022463000A8F820054006210239F
3153:10C500002C42000B1440FFFC000000008F82022030
3154:10C510003C03F70000431025AF8202208F830054B4
3155:10C520008F82005410000002246300648F82005444
3156:10C53000006210232C4200651440FFFC0000000044
3157:10C540008F8202202404000134420002AF820220C4
3158:10C550008F83020024057FFF2402FFFD0062182460
3159:10C56000AF830200AF8402048F8300548F82005493
3160:10C5700010000002246300018F8200540062102327
3161:10C580002C4200021440FFFC000000008F820224B5
3162:10C5900014440005340280000004204000A4102B45
3163:10C5A0001040FFF0340280001082FF50261000017E
3164:10C5B0002E0200641440FFB0000000003C020001A5
3165:10C5C0008C426D9430420004144000073C09FFF097
3166:10C5D0008F8200443C03FFFF34633F7F00431024FD
3167:10C5E000AF8200443C09FFF03529BDC03C06000184
3168:10C5F0008CC66D943C04000124846AE0240200018E
3169:10C600003C010001AC226D9C8F8200543C0700016C
3170:10C610008CE76F403C03000194636F243C080001E9
3171:10C6200095086F263C05000D34A501003C01000172
3172:10C63000AC206D98004910213C010001AC226F3004
3173:10C64000AFA300100C002B3BAFA800148FBF002C31
3174:10C650008FB200288FB100248FB0002003E00008C3
3175:10C6600027BD003027BDFFE83C0500018CA56D9873
3176:10C67000240600042402000114A20014AFBF00101D
3177:10C680003C0200028C428FFC3042800010400005CA
3178:10C690003C04000F3C0300018C636F401000000558
3179:10C6A000348442403C0400043C0300018C636F402E
3180:10C6B000348493E024020005146200160000000098
3181:10C6C0003C04003D10000013348409003C020002C9
3182:10C6D0008C428FF830428000104000053C04001E60
3183:10C6E0003C0300018C636F4010000005348484809B
3184:10C6F0003C04000F3C0300018C636F4034844240D3
3185:10C700002402000514620003000000003C04007ACB
3186:10C71000348412003C0200018C426F308F8300543D
3187:10C7200000441021004310230044102B1440004CFF
3188:10C73000000000003C0200018C426DA01440004843
3189:10C74000000000003C01000110C00025AC206DB0CD
3190:10C750003C0900018D296D94240700013C04400030
3191:10C760003C08000225088FFC250AFFFC0005284232
3192:10C7700014A0000224C6FFFF2405000800A910240D
3193:10C78000104000100000000014A700080000000086
3194:10C790008D020000004410241040000A0000000038
3195:10C7A0003C01000110000007AC256DB08D42000077
3196:10C7B0000044102410400003000000003C01000170
3197:10C7C000AC276DB03C0200018C426DB00006182B06
3198:10C7D0002C420001004310245440FFE5000528428C
3199:10C7E0008F8200543C0300018C636DB03C0100015A
3200:10C7F000AC226F301060003B240200053C030001B6
3201:10C800008C636F403C010001AC256D9814620012EE
3202:10C81000240200013C0200028C428FF83C032000FD
3203:10C820003463500000431024144000062402000129
3204:10C830003C010001AC206F1C3C010001AC226D9852
3205:10C84000240200013C010001AC226E243C010001E5
3206:10C85000AC226DA4240200013C010001AC226D9CBD
3207:10C860003C0200018C426DB01040001E0000000030
3208:10C870003C0200018C426D9C104000082402000123
3209:10C880003C010001AC206D9CAEE204B83C0100010B
3210:10C89000AC206E1C3C010001AC226DD48EE304B8C8
3211:10C8A0002402000810620005240200010C00423935
3212:10C8B000000000001000000B000000003C0300011D
3213:10C8C0008C636D98106200072402000E3C03000286
3214:10C8D0008C638F9010620003000000000C004E9CDF
3215:10C8E0008F8402208FBF001003E0000827BD0018CE
3216:10C8F00027BDFFE03C03FDFF3C0400018C846D98E4
3217:10C900003C0200018C426DC03463FFFF0283A0240F
3218:10C9100014820006AFBF00188EE304B83C02000189
3219:10C920008C426DC410620006000000008EE204B864
3220:10C930003C010001AC246DC03C010001AC226DC47F
3221:10C940003C0300018C636D98240200021062019C7C
3222:10C950002C62000310400005240200011062000A4E
3223:10C960000000000010000226000000002402000465
3224:10C97000106200B6240200081062010A24020001BD
3225:10C980001000021F000000008EE204B82443FFFFE5
3226:10C990002C6200081040021C000310803C010001C2
3227:10C9A000002208218C226AF80040000800000000E4
3228:10C9B0003C0300018C636F402402000514620010E8
3229:10C9C000000000003C0200018C426DA410400008F1
3230:10C9D000240200030C004482000000002402000234
3231:10C9E000AEE204B83C01000110000002AC206DA4CE
3232:10C9F000AEE204B83C01000110000203AC206D302F
3233:10CA00000C004482000000003C0200018C426DA436
3234:10CA10003C010001AC206D301440017A2402000278
3235:10CA20001000019D240200073C0300018C636F404D
3236:10CA30002402000514620003240200013C010001ED
3237:10CA4000AC226DD00C0045FF000000003C0300014B
3238:10CA50008C636DD010000174240200113C050001AC
3239:10CA60008CA56D983C0600028CC68FFC0C0051040E
3240:10CA700000002021240200053C010001AC206DA42F
3241:10CA8000100001E1AEE204B83C04000124846AEC29
3242:10CA90003C05000F34A501000000302100003821C2
3243:10CAA000AFA000100C002B3BAFA00014100001D66B
3244:10CAB000000000008F8202203C0300040043102489
3245:10CAC00014400175240200078F8300543C020001CA
3246:10CAD0008C426F282463D8F0004310232C42271087
3247:10CAE00014400003240200013C010001AC226D9CB3
3248:10CAF0003C0200028C428FFC30425000104001C2C8
3249:10CB0000000000008F820220304280001040017D32
3250:10CB10000000000010000175000000003C0500014D
3251:10CB20008CA56D980C00529B000020210C00551B19
3252:10CB3000000020213C0300028C638FF4046101B0EB
3253:10CB4000240200013C02000800621024104000068C
3254:10CB5000000000008F8202143C03FFFF00431024FA
3255:10CB6000100000053442251F8F8202143C03FFFF92
3256:10CB7000004310243442241FAF8202148F8202200B
3257:10CB80003C03020034420002AF820220240200086B
3258:10CB9000AEE204B88F8202200283A0253C03000489
3259:10CBA0000043102414400016000000003C02000264
3260:10CBB0008C428FFC304250001040000D00000000FD
3261:10CBC0008F820220304280001040000600000000EA
3262:10CBD0008F8202203C03FFFF34637FFF10000003BD
3263:10CBE000004310248F82022034428000AF82022052
3264:10CBF0008F8202203C03F70000431025AF82022001
3265:10CC00003C0300018C636F40240200051462000A9B
3266:10CC1000000000003C02000194426F2624429FBCA9
3267:10CC20002C420004104000042404001824050002D3
3268:10CC30000C004DDB240600200C003E6D00000000BF
3269:10CC40003C01000110000170AC206E208EE204B89F
3270:10CC50002443FFFF2C6200081040016B000310808A
3271:10CC60003C010001002208218C226B1800400008C2
3272:10CC7000000000000C004547000000003C030001DC
3273:10CC80008C636DB4100000E8240200093C0200022D
3274:10CC90008C428FF830424000104000040000000039
3275:10CCA0008F820044100000063442F0808F820044DE
3276:10CCB0003C03FFFF34633F7F004310243442A080D5
3277:10CCC000AF8200448F830054100000EA2402000465
3278:10CCD0008F8300543C0200018C426F282463D8F0FB
3279:10CCE000004310232C422710144001472402000562
3280:10CCF000100000D8000000008F8202203C03F700E3
3281:10CD000000431025AF820220AF8002043C010002E4
3282:10CD1000100000D6AC208FE08F8300543C0200014D
3283:10CD20008C426F282463FFF6004310232C42000A34
3284:10CD30001440013524020007100000D70000000055
3285:10CD40000C003F50000000001040012D24020001A3
3286:10CD50008F8202143C03FFFF3C0400018C846F1C93
3287:10CD6000004310243442251FAF820214240200081D
3288:10CD700010800005AEE204B83C0200018C426E4413
3289:10CD800010400064240200018F8202203C0300084E
3290:10CD9000004310241040006A3C020200100000789A
3291:10CDA000000000008EE204B82443FFFF2C6200075D
3292:10CDB00010400115000310803C01000100220821F1
3293:10CDC0008C226B3800400008000000000C003DAFD2
3294:10CDD000000000003C010001AC206D9CAF8002040B
3295:10CDE0003C0100020C004482AC208FE024020001D0
3296:10CDF0003C010001AC226DB42402000210000102CB
3297:10CE0000AEE204B80C004547000000003C030001FE
3298:10CE10008C636DB410000084240200093C020002FF
3299:10CE20008C428FF830424000104000033C0200C8A2
3300:10CE300010000002344201F6344201FEAF82023893
3301:10CE40008F8300541000008B240200048F83005451
3302:10CE50003C0200018C426F282463D8F00043102369
3303:10CE60002C422710144000E824020005100000792D
3304:10CE7000000000008F8202203C03F70000431025D1
3305:10CE8000AF820220AF8002043C0100021000007754
3306:10CE9000AC208FE08F8300543C0200018C426F284D
3307:10CEA0002463FFF6004310232C42000A144000D6EE
3308:10CEB0002402000710000078000000000C003F5022
3309:10CEC00000000000104000CE240200018F820214F6
3310:10CED0003C03FFFF3C0400018C846F1C00431024C2
3311:10CEE0003442251FAF820214240200081080000F74
3312:10CEF000AEE204B83C0200018C426E441440000BC8
3313:10CF0000000000008F82022034420002AF82022023
3314:10CF1000240200013C010002AC228F900C004E9CC8
3315:10CF20008F84022010000016000000008F82022073
3316:10CF30003C03000800431024144000113C0202008E
3317:10CF40000282A0252402000E3C010002AC228F9038
3318:10CF50000C00551B000020218F8202203442000269
3319:10CF60000C003E6DAF8202203C0500018CA56D983F
3320:10CF70000C00529B00002021100000A300000000C4
3321:10CF80003C0200018C426E441040009F00000000F3
3322:10CF90003C0200018C426E402442FFFF3C01000134
3323:10CFA000AC226E4014400098240200023C010001B3
3324:10CFB000AC206E443C01000110000093AC226E4096
3325:10CFC0008EE204B82443FFFF2C6200071040008E5D
3326:10CFD000000310803C010001002208218C226B58C4
3327:10CFE00000400008000000003C0200018C426DA4DB
3328:10CFF00010400018240200050C00448200000000CC
3329:10D0000024020002AEE204B83C0100011000007EE0
3330:10D01000AC206DA40C004963000000003C0300013B
3331:10D020008C636DD42402000614620077240200038E
3332:10D0300010000075AEE204B83C0500018CA56D98A7
3333:10D040003C0600028CC68FF80C0051040000202121
3334:10D05000240200051000006CAEE204B88F820220AA
3335:10D060003C03F70000431025AF8202208F83005459
3336:10D0700024020006AEE204B83C0100011000006288
3337:10D08000AC236F288F8202203C030004004310244D
3338:10D0900010400003240200071000005BAEE204B859
3339:10D0A0008F8300543C0200018C426F282463D8F027
3340:10D0B000004310232C4227101440000324020001D7
3341:10D0C0003C010001AC226D9C3C0200028C428FF8B6
3342:10D0D000304250001040004C000000008F820220BF
3343:10D0E0003042800010400007000000008F820220C4
3344:10D0F0003C03FFFF34637FFF004310241000004215
3345:10D10000AF8202208F820220344280001000003E55
3346:10D11000AF8202203C0500018CA56D980C00529B4B
3347:10D12000000020210C00551B000020213C020002C1
3348:10D130008C428FF004410032240200018F820214DD
3349:10D140003C03FFFF004310243442251FAF8202142A
3350:10D1500024020008AEE204B88F82022034420002AA
3351:10D16000AF8202208F8202203C030004004310247F
3352:10D1700014400016000000003C0200028C428FF8B0
3353:10D18000304250001040000D000000008F8202204D
3354:10D190003042800010400006000000008F82022014
3355:10D1A0003C03FFFF34637FFF1000000300431024A3
3356:10D1B0008F82022034428000AF8202208F820220C0
3357:10D1C0003C03F70000431025AF8202203C0200011F
3358:10D1D00094426F2624429FBC2C420004104000045D
3359:10D1E00024040018240500020C004DDB2406002056
3360:10D1F0000C003E6D00000000100000030000000065
3361:10D200003C010001AC226D9C8FBF001803E00008B8
3362:10D2100027BD00208F8202008F8202208F82022091
3363:10D2200034420004AF8202208F8202003C050001DC
3364:10D230008CA56D9834420004AF82020024020002E3
3365:10D2400010A2004B2CA20003104000052402000194
3366:10D2500010A2000A00000000100000B10000000051
3367:10D260002402000410A200722402000810A200850B
3368:10D270003C02F0FF100000AA000000008F83005065
3369:10D280003C02F0FF3442FFFF3C0400018C846F40FD
3370:10D29000006218243C0207000062182524020E00D8
3371:10D2A0002484FFFB2C840002AF830050AF85020072
3372:10D2B000AF85022014800006AF8202388F820044BE
3373:10D2C0003C03FFFF34633F7F00431024AF820044E0
3374:10D2D0003C0300018C636F402402000514620004CB
3375:10D2E000000000008F82004434425000AF820044AE
3376:10D2F0003C0200018C426D883C0300018C636F404E
3377:10D30000344200222463FFFC2C6300021460000CF2
3378:10D31000AF8202003C0200018C426DAC3C03000174
3379:10D320008C636D903C0400018C846D8C34428000D1
3380:10D3300000621825006418251000000A34620002FB
3381:10D340003C0200018C426D903C0300018C636DAC8B
3382:10D350003C0400018C846D8C004310250044102592
3383:10D3600034420002AF8202201000002F240200018C
3384:10D3700024020E01AF8202388F8300503C02F0FF7E
3385:10D380003442FFFF3C0400018C846F1C00621824AF
3386:10D390003C020D000062182524020001AF830050FA
3387:10D3A000AF820200AF820220108000053C033F00E4
3388:10D3B0003C0200018C426D80100000043463007058
3389:10D3C0003C0200018C426D803463007200431025E2
3390:10D3D000AF8202003C0300018C636D843C02F700C5
3391:10D3E000006218253C0200018C426D903C04000153
3392:10D3F0008C846DAC3C0500018CA56F40004310256A
3393:10D4000000441025AF8202202402000514A2000669
3394:10D41000240200018F8200442403AFFF0043102444
3395:10D42000AF820044240200011000003DAF820238A8
3396:10D430008F8300503C02F0FF3442FFFF3C040001A8
3397:10D440008C846F1C006218243C020A0000621825BC
3398:10D4500024020001AF830050AF8202001080001E42
3399:10D46000AF8202203C0200018C426E441440001A3C
3400:10D470003C033F003C0200018C426D801000001A0A
3401:10D48000346300E08F8300503C0400018C846F1CE7
3402:10D490003442FFFF006218241080000FAF83005059
3403:10D4A0003C0200018C426E441440000B3C043F00DF
3404:10D4B0003C0300018C636D80348400E02402000191
3405:10D4C000AF820200AF82022000641825AF83020001
3406:10D4D000100000083C05F7003C0200018C426D8002
3407:10D4E0003C033F00346300E200431025AF8202009A
3408:10D4F0003C05F70034A580003C0300018C636D847B
3409:10D500003C0200018C426D903C0400018C846DACA7
3410:10D51000006518250043102500441025AF82022025
3411:10D5200003E00008000000003C0300018C636DB4C0
3412:10D530003C0200018C426DB810620003240200021C
3413:10D540003C010001AC236DB81062001D2C62000389
3414:10D55000104000252402000114620023240200046C
3415:10D560003C0300018C636D981062000624020008E1
3416:10D570001462000C3C0200C8344201FB1000000998
3417:10D58000AF82023824020E01AF8202388F8200443B
3418:10D590003C03FFFF34633F7F00431024344200808C
3419:10D5A000AF8200448F830054240200023C0100013A
3420:10D5B000AC226DB43C0100011000000BAC236F2CB9
3421:10D5C0008F8300543C0200018C426F2C2463D8F0FE
3422:10D5D000004310232C4227101440000324020009AA
3423:10D5E0003C010001AC226DB403E000080000000023
3424:10D5F00000000000000000000000000027BDFFD870
3425:10D60000AFB2001800809021AFB3001C00A0982199
3426:10D61000AFB1001400C08821AFB00010000080211D
3427:10D62000AFBF0020A62000000C004D7824040001AC
3428:10D63000261000012E0200201440FFFB0000000015
3429:10D640000C004D78000020210C004D7824040001CE
3430:10D650000C004D78240400010C004D7800002021BE
3431:10D66000241000100250102410400002000020215D
3432:10D67000240400010C004D78001080421600FFFACF
3433:10D6800002501024241000100270102410400002D8
3434:10D6900000002021240400010C004D78001080427D
3435:10D6A0001600FFFA027010240C004DB934108000EF
3436:10D6B0000C004DB9000000000C004D5800000000A7
3437:10D6C00050400005001080429622000000501025B6
3438:10D6D000A6220000001080421600FFF700000000A4
3439:10D6E0000C004DB9000000008FBF00208FB3001C5C
3440:10D6F0008FB200188FB100148FB0001003E0000843
3441:10D7000027BD002827BDFFD8AFB1001400808821B5
3442:10D71000AFB2001800A09021AFB3001C00C0982148
3443:10D72000AFB0001000008021AFBF00200C004D788A
3444:10D7300024040001261000012E0200201440FFFBEB
3445:10D74000000000000C004D78000020210C004D78F6
3446:10D75000240400010C004D78000020210C004D78BD
3447:10D760002404000124100010023010241040000294
3448:10D7700000002021240400010C004D78001080429C
3449:10D780001600FFFA0230102424100010025010245A
3450:10D790001040000200002021240400010C004D78FC
3451:10D7A000001080421600FFFA025010240C004D7841
3452:10D7B000240400010C004D7800002021341080006A
3453:10D7C000966200000050102410400002000020214A
3454:10D7D000240400010C004D78001080421600FFF870
3455:10D7E000000000000C004DB9000000008FBF0020B9
3456:10D7F0008FB3001C8FB200188FB100148FB00010CF
3457:10D8000003E0000827BD00283C0400018C846DD093
3458:10D810003C0200018C426E1827BDFFD8AFBF00202C
3459:10D82000AFB1001C10820003AFB000183C01000132
3460:10D83000AC246E183C0300018C636F402402000589
3461:10D84000146200052483FFFF0C0049630000000000
3462:10D850001000034C000000002C620013104003492C
3463:10D86000000310803C010001002208218C226B8003
3464:10D8700000400008000000000C004DB900008021AD
3465:10D8800034028000A7A2001027B100100C004D78D0
3466:10D8900024040001261000012E0200201440FFFB8A
3467:10D8A000000000000C004D78000020210C004D7895
3468:10D8B000240400010C004D78000020210C004D785C
3469:10D8C0002404000124100010320200011040000264
3470:10D8D00000002021240400010C004D78001080423B
3471:10D8E0001600FFFA32020001241000100C004D78DF
3472:10D8F00000002021001080421600FFFC0000000004
3473:10D900000C004D78240400010C004D78000020210B
3474:10D9100034108000962200000050102410400002B5
3475:10D9200000002021240400010C004D7800108042EA
3476:10D930001600FFF8000000000C004DB900000000C8
3477:10D940001000030E2402000227B10010A7A000104F
3478:10D95000000080210C004D782404000126100001F5
3479:10D960002E0200201440FFFB000000000C004D7848
3480:10D97000000020210C004D78240400010C004D789B
3481:10D98000240400010C004D78000020212410001018
3482:10D990003202000110400002000020212404000196
3483:10D9A0000C004D78001080421600FFFA3202000190
3484:10D9B000241000100C004D7800002021001080423F
3485:10D9C0001600FFFC000000000C004DB93410800070
3486:10D9D0000C004DB9000000000C004D580000000084
3487:10D9E0005040000500108042962200000050102593
3488:10D9F000A6220000001080421600FFF70000000081
3489:10DA00000C004DB90000000097A2001030428000C9
3490:10DA1000144002DC24020003100002D800000000C1
3491:10DA200024021200A7A2001027B1001000008021DC
3492:10DA30000C004D7824040001261000012E02002065
3493:10DA40001440FFFB000000000C004D780000202176
3494:10DA50000C004D78240400010C004D7800002021BA
3495:10DA60000C004D7824040001241000103202000143
3496:10DA70001040000200002021240400010C004D7819
3497:10DA8000001080421600FFFA32020001241000103C
3498:10DA90000C004D7800002021001080421600FFFC91
3499:10DAA000000000000C004D78240400010C004D78AB
3500:10DAB0000000202134108000962200000050102425
3501:10DAC0001040000200002021240400010C004D78C9
3502:10DAD000001080421600FFF8000000000C004DB955
3503:10DAE000000000008F8300541000029624020004FE
3504:10DAF0008F8300543C0200018C426F3C2463FF9CE6
3505:10DB0000004310232C4200641440029E24020002B1
3506:10DB10003C0300018C636F40106202972C6200038B
3507:10DB20001440029624020011240200031062000532
3508:10DB300024020004106202912402000F1000028FE0
3509:10DB4000240200111000028D24020005240200149A
3510:10DB5000A7A2001027B10010000080210C004D7812
3511:10DB600024040001261000012E0200201440FFFBB7
3512:10DB7000000000000C004D78000020210C004D78C2
3513:10DB8000240400010C004D78000020210C004D7889
3514:10DB90002404000124100010320200011040000291
3515:10DBA00000002021240400010C004D780010804268
3516:10DBB0001600FFFA32020001241000103202001297
3517:10DBC0001040000200002021240400010C004D78C8
3518:10DBD000001080421600FFFA320200120C004D784D
3519:10DBE000240400010C004D78000020213410800036
3520:10DBF0009622000000501024104000020000202156
3521:10DC0000240400010C004D78001080421600FFF83B
3522:10DC1000000000000C004DB9000000008F8300548C
3523:10DC200010000248240200068F8300543C020001C9
3524:10DC30008C426F3C2463FF9C004310232C42006401
3525:10DC400014400250240200071000024C00000000A3
3526:10DC500024020006A7A2001027B1001000008021B6
3527:10DC60000C004D7824040001261000012E02002033
3528:10DC70001440FFFB000000000C004D780000202144
3529:10DC80000C004D78240400010C004D780000202188
3530:10DC90000C004D7824040001241000103202000111
3531:10DCA0001040000200002021240400010C004D78E7
3532:10DCB000001080421600FFFA32020001241000100A
3533:10DCC0003202001310400002000020212404000151
3534:10DCD0000C004D78001080421600FFFA320200134B
3535:10DCE0000C004D78240400010C004D780000202128
3536:10DCF00034108000962200000050102410400002D2
3537:10DD000000002021240400010C004D780010804206
3538:10DD10001600FFF8000000000C004DB900000000E4
3539:10DD20008F83005410000207240200088F830054E0
3540:10DD30003C0200018C426F3C2463FF9C0043102393
3541:10DD40002C4200641440020F240200091000020B50
3542:10DD50000000000027B10010A7A0001000008021E3
3543:10DD60000C004D7824040001261000012E02002032
3544:10DD70001440FFFB000000000C004D780000202143
3545:10DD80000C004D78240400010C004D78240400019F
3546:10DD90000C004D78000020212410001032020001F8
3547:10DDA0001040000200002021240400010C004D78E6
3548:10DDB000001080421600FFFA320200012410001009
3549:10DDC000320200181040000200002021240400014B
3550:10DDD0000C004D78001080421600FFFA3202001845
3551:10DDE0000C004DB9341080000C004DB9000000004B
3552:10DDF0000C004D580000000050400005001080420B
3553:10DE00009622000000501025A6220000001080423B
3554:10DE10001600FFF7000000000C004DB90000802143
3555:10DE200097A2001027B1001034420001A7A20010F1
3556:10DE30000C004D7824040001261000012E02002061
3557:10DE40001440FFFB000000000C004D780000202172
3558:10DE50000C004D78240400010C004D7800002021B6
3559:10DE60000C004D782404000124100010320200013F
3560:10DE70001040000200002021240400010C004D7815
3561:10DE8000001080421600FFFA320200012410001038
3562:10DE9000320200181040000200002021240400017A
3563:10DEA0000C004D78001080421600FFFA3202001874
3564:10DEB0000C004D78240400010C004D780000202156
3565:10DEC0003410800096220000005010241040000200
3566:10DED00000002021240400010C004D780010804235
3567:10DEE0001600FFF8000000000C004DB90000000013
3568:10DEF0008F830054100001932402000A8F83005482
3569:10DF00003C0200018C426F3C2463FF9C00431023C1
3570:10DF10002C4200641440019B2402000B1000019766
3571:10DF20000000000027B10010A7A000100000802111
3572:10DF30000C004D7824040001261000012E02002060
3573:10DF40001440FFFB000000000C004D780000202171
3574:10DF50000C004D78240400010C004D7824040001CD
3575:10DF60000C004D7800002021241000103202000126
3576:10DF70001040000200002021240400010C004D7814
3577:10DF8000001080421600FFFA320200012410001037
3578:10DF9000320200171040000200002021240400017A
3579:10DFA0000C004D78001080421600FFFA3202001774
3580:10DFB0000C004DB9341080000C004DB90000000079
3581:10DFC0000C004D5800000000504000050010804239
3582:10DFD0009622000000501025A6220000001080426A
3583:10DFE0001600FFF7000000000C004DB90000802172
3584:10DFF00097A2001027B1001034420700A7A200101A
3585:10E000000C004D7824040001261000012E0200208F
3586:10E010001440FFFB000000000C004D7800002021A0
3587:10E020000C004D78240400010C004D7800002021E4
3588:10E030000C004D782404000124100010320200016D
3589:10E040001040000200002021240400010C004D7843
3590:10E05000001080421600FFFA320200012410001066
3591:10E0600032020017104000020000202124040001A9
3592:10E070000C004D78001080421600FFFA32020017A3
3593:10E080000C004D78240400010C004D780000202184
3594:10E09000341080009622000000501024104000022E
3595:10E0A00000002021240400010C004D780010804263
3596:10E0B0001600FFF8000000000C004DB90000000041
3597:10E0C0008F8300541000011F2402000C8F83005422
3598:10E0D0003C0200018C426F3C2463FF9C00431023F0
3599:10E0E0002C42006414400127240200121000012376
3600:10E0F0000000000027B10010A7A000100000802140
3601:10E100000C004D7824040001261000012E0200208E
3602:10E110001440FFFB000000000C004D78000020219F
3603:10E120000C004D78240400010C004D7824040001FB
3604:10E130000C004D7800002021241000103202000154
3605:10E140001040000200002021240400010C004D7842
3606:10E15000001080421600FFFA320200012410001065
3607:10E1600032020014104000020000202124040001AB
3608:10E170000C004D78001080421600FFFA32020014A5
3609:10E180000C004DB9341080000C004DB900000000A7
3610:10E190000C004D5800000000504000050010804267
3611:10E1A0009622000000501025A62200000010804298
3612:10E1B0001600FFF7000000000C004DB900008021A0
3613:10E1C00097A2001027B1001034420010A7A200103F
3614:10E1D0000C004D7824040001261000012E020020BE
3615:10E1E0001440FFFB000000000C004D7800002021CF
3616:10E1F0000C004D78240400010C004D780000202113
3617:10E200000C004D782404000124100010320200019B
3618:10E210001040000200002021240400010C004D7871
3619:10E22000001080421600FFFA320200012410001094
3620:10E2300032020014104000020000202124040001DA
3621:10E240000C004D78001080421600FFFA32020014D4
3622:10E250000C004D78240400010C004D7800002021B2
3623:10E26000341080009622000000501024104000025C
3624:10E2700000002021240400010C004D780010804291
3625:10E280001600FFF8000000000C004DB9000000006F
3626:10E290008F830054100000AB240200138F830054BE
3627:10E2A0003C0200018C426F3C2463FF9C004310231E
3628:10E2B0002C420064144000B32402000D100000AF93
3629:10E2C0000000000027B10010A7A00010000080216E
3630:10E2D0000C004D7824040001261000012E020020BD
3631:10E2E0001440FFFB000000000C004D7800002021CE
3632:10E2F0000C004D78240400010C004D78240400012A
3633:10E300000C004D7800002021241000103202000182
3634:10E310001040000200002021240400010C004D7870
3635:10E32000001080421600FFFA320200012410001093
3636:10E3300032020018104000020000202124040001D5
3637:10E340000C004D78001080421600FFFA32020018CF
3638:10E350000C004DB9341080000C004DB900000000D5
3639:10E360000C004D5800000000504000050010804295
3640:10E370009622000000501025A622000000108042C6
3641:10E380001600FFF7000000000C004DB900008021CE
3642:10E3900097A2001027B100103042FFFEA7A2001084
3643:10E3A0000C004D7824040001261000012E020020EC
3644:10E3B0001440FFFB000000000C004D7800002021FD
3645:10E3C0000C004D78240400010C004D780000202141
3646:10E3D0000C004D78240400012410001032020001CA
3647:10E3E0001040000200002021240400010C004D78A0
3648:10E3F000001080421600FFFA3202000124100010C3
3649:10E400003202001810400002000020212404000104
3650:10E410000C004D78001080421600FFFA32020018FE
3651:10E420000C004D78240400010C004D7800002021E0
3652:10E43000341080009622000000501024104000028A
3653:10E4400000002021240400010C004D7800108042BF
3654:10E450001600FFF8000000000C004DB9000000009D
3655:10E460008F830054100000372402000E240208405D
3656:10E47000A7A2001027B10010000080210C004D78E9
3657:10E4800024040001261000012E0200201440FFFB8E
3658:10E49000000000000C004D78000020210C004D7899
3659:10E4A000240400010C004D78000020210C004D7860
3660:10E4B0002404000124100010320200011040000268
3661:10E4C00000002021240400010C004D78001080423F
3662:10E4D0001600FFFA3202000124100010320200136D
3663:10E4E0001040000200002021240400010C004D789F
3664:10E4F000001080421600FFFA320200130C004D7823
3665:10E50000240400010C004D7800002021341080000C
3666:10E51000962200000050102410400002000020212C
3667:10E52000240400010C004D78001080421600FFF812
3668:10E53000000000000C004DB9000000008F83005463
3669:10E54000240200103C010001AC226DD03C0100010E
3670:10E550001000000CAC236F3C8F8300543C02000180
3671:10E560008C426F3C2463FF9C004310232C420064C8
3672:10E570001440000400000000240200113C010001CE
3673:10E58000AC226DD08FBF00208FB1001C8FB000185F
3674:10E5900003E0000827BD00283C0300018C636D9850
3675:10E5A00027BDFFC824020002AFBF0034AFB2003065
3676:10E5B000AFB1002C14620004AFB000283C1200027E
3677:10E5C000100000038E528FF83C1200028E528FFC16
3678:10E5D0003C0300018C636DD43C0200018C426E1C34
3679:10E5E000506200042463FFFF3C010001AC236E1C59
3680:10E5F0002463FFFF2C6200061040037700031080A5
3681:10E600003C010001002208218C226BD80040000848
3682:10E610000000000000002021000028210C004DDB3C
3683:10E6200034068000240400102405000224060002A1
3684:10E63000240200020C004DDBA7A2001824020002F5
3685:10E640003C01000110000364AC226DD427B1001816
3686:10E65000A7A00018000080210C004D7824040001C0
3687:10E66000261000012E0200201440FFFB00000000D5
3688:10E670000C004D78000020210C004D78240400018E
3689:10E680000C004D78240400010C004D78000020217E
3690:10E69000241000103202000110400002000020216E
3691:10E6A000240400010C004D78001080421600FFFA8F
3692:10E6B00032020001241000100C004D7800002021CF
3693:10E6C000001080421600FFFC000000000C004DB955
3694:10E6D000341080000C004DB9000000000C004D58B3
3695:10E6E000000000005040000500108042962200000B
3696:10E6F00000501025A6220000001080421600FFF7EF
3697:10E70000000000000C004DB90000000097A20018A6
3698:10E710003042800014400004240200033C01000148
3699:10E72000AC226DD4240200033C0100011000032A36
3700:10E73000AC226DD42404001024050002240600023B
3701:10E74000240200020C004DDBA7A200183C030001CC
3702:10E750008C636E2024020001146201E1000080211C
3703:10E7600027B10018A7A000180C004D782404000160
3704:10E77000261000012E0200201440FFFB00000000C4
3705:10E780000C004D78000020210C004D78240400017D
3706:10E790000C004D78240400010C004D78000020216D
3707:10E7A000241000103202000110400002000020215D
3708:10E7B000240400010C004D78001080421600FFFA7E
3709:10E7C0003202000124100010320200181040000232
3710:10E7D00000002021240400010C004D78001080422C
3711:10E7E0001600FFFA320200180C004DB934108000F8
3712:10E7F0000C004DB9000000000C004D580000000056
3713:10E800005040000500108042962200000050102564
3714:10E81000A6220000001080421600FFF70000000052
3715:10E820000C004DB90000802127B10018A7A00018E6
3716:10E830000C004D7824040001261000012E02002057
3717:10E840001440FFFB000000000C004D780000202168
3718:10E850000C004D78240400010C004D7824040001C4
3719:10E860000C004D780000202124100010320200011D
3720:10E870001040000200002021240400010C004D780B
3721:10E88000001080421600FFFA32020001241000102E
3722:10E890003202001810400002000020212404000170
3723:10E8A0000C004D78001080421600FFFA320200186A
3724:10E8B0000C004DB9341080000C004DB90000000070
3725:10E8C0000C004D5800000000504000050010804230
3726:10E8D0009622000000501025A62200000010804261
3727:10E8E0001600FFF7000000000C004DB90000802169
3728:10E8F00024040018000028210C004DDB2406040429
3729:10E90000A7A0001A0C004D78240400012610000175
3730:10E910002E0200201440FFFB000000000C004D7888
3731:10E92000000020210C004D78240400010C004D78DB
3732:10E93000240400010C004D78000020212410001058
3733:10E9400032020001104000020000202124040001D6
3734:10E950000C004D78001080421600FFFA32020001D0
3735:10E960002410001032020018104000020000202184
3736:10E97000240400010C004D78001080421600FFFABC
3737:10E98000320200180C004DB9341080000C004DB953
3738:10E99000000000000C004D58000000005040000531
3739:10E9A0000010804297A2001A00501025A7A2001A5A
3740:10E9B000001080421600FFF7000000000C004DB967
3741:10E9C00000008021A7A0001A0C004D78240400014B
3742:10E9D000261000012E0200201440FFFB0000000062
3743:10E9E0000C004D78000020210C004D78240400011B
3744:10E9F0000C004D78240400010C004D78000020210B
3745:10EA000024100010320200011040000200002021FA
3746:10EA1000240400010C004D78001080421600FFFA1B
3747:10EA200032020001241000103202001810400002CF
3748:10EA300000002021240400010C004D7800108042C9
3749:10EA40001600FFFA320200180C004DB93410800095
3750:10EA50000C004DB9000000000C004D5800000000F3
3751:10EA6000504000050010804297A2001A0050102567
3752:10EA7000A7A2001A001080421600FFF70000000055
3753:10EA80000C004DB900008021A7A0001C0C004D789F
3754:10EA900024040001261000012E0200201440FFFB78
3755:10EAA000000000000C004D78000020210C004D7883
3756:10EAB000240400010C004D78240400010C004D7862
3757:10EAC00000002021241000100C004D7800002021AF
3758:10EAD000001080421600FFFC00000000241000100F
3759:10EAE0003202001E10400002000020212404000118
3760:10EAF0000C004D78001080421600FFFA3202001E12
3761:10EB00000C004DB9341080000C004DB9000000001D
3762:10EB10000C004D58000000005040000500108042DD
3763:10EB200097A2001C00501025A7A2001C00108042D4
3764:10EB30001600FFF7000000000C004DB90000802116
3765:10EB4000A7A0001C0C004D78240400012610000131
3766:10EB50002E0200201440FFFB000000000C004D7846
3767:10EB6000000020210C004D78240400010C004D7899
3768:10EB7000240400010C004D78000020212410001016
3769:10EB80000C004D7800002021001080421600FFFC90
3770:10EB900000000000241000103202001E104000028D
3771:10EBA00000002021240400010C004D780010804258
3772:10EBB0001600FFFA3202001E0C004DB9341080001E
3773:10EBC0000C004DB9000000000C004D580000000082
3774:10EBD000504000050010804297A2001C00501025F4
3775:10EBE000A7A2001C001080421600FFF700000000E2
3776:10EBF0000C004DB90000802124020002A7A2001ED3
3777:10EC00000C004D7824040001261000012E02002083
3778:10EC10001440FFFB000000000C004D780000202194
3779:10EC20000C004D78240400010C004D7800002021D8
3780:10EC30000C004D7824040001241000100C004D78C5
3781:10EC400000002021001080421600FFFC00000000A0
3782:10EC5000241000103202001E10400002000020218B
3783:10EC6000240400010C004D78001080421600FFFAC9
3784:10EC70003202001E0C004D78240400010C004D7877
3785:10EC8000000020213410800097A2001E00501024A4
3786:10EC90001040000200002021240400010C004D78E7
3787:10ECA000001080421600FFF8000000000C004DB973
3788:10ECB00000008021A7A000200C004D782404000152
3789:10ECC000261000012E0200201440FFFB000000006F
3790:10ECD0000C004D78000020210C004D782404000128
3791:10ECE0000C004D78240400010C004D780000202118
3792:10ECF000241000100C004D780000202100108042EC
3793:10ED00001600FFFC00000000241000103202001E5C
3794:10ED10001040000200002021240400010C004D7866
3795:10ED2000001080421600FFFA3202001E0C004DB99E
3796:10ED3000341080000C004DB9000000000C004D584C
3797:10ED400000000000504000050010804297A2002003
3798:10ED500000501025A7A20020001080421600FFF7E7
3799:10ED6000000000000C004DB900008021A7A0002089
3800:10ED70000C004D7824040001261000012E02002012
3801:10ED80001440FFFB000000000C004D780000202123
3802:10ED90000C004D78240400010C004D78240400017F
3803:10EDA0000C004D7800002021241000100C004D783C
3804:10EDB00000002021001080421600FFFC000000002F
3805:10EDC000241000103202001E10400002000020211A
3806:10EDD000240400010C004D78001080421600FFFA58
3807:10EDE0003202001E0C004DB9341080000C004DB9E9
3808:10EDF000000000000C004D580000000050400005CD
3809:10EE00000010804297A2002000501025A7A20020E9
3810:10EE1000001080421600FFF7000000000C004DB902
3811:10EE200000008021A7A000220C004D7824040001DE
3812:10EE3000261000012E0200201440FFFB00000000FD
3813:10EE40000C004D78000020210C004D7824040001B6
3814:10EE50000C004D78000020210C004D7824040001A6
3815:10EE6000241000100C004D7800002021001080427A
3816:10EE70001600FFFC00000000241000100C004D786C
3817:10EE800000002021001080421600FFFC000000005E
3818:10EE90000C004D78240400010C004D780000202166
3819:10EEA0003410800097A2002200501024104000026D
3820:10EEB00000002021240400010C004D780010804245
3821:10EEC0001600FFF8000000000C004DB90000000023
3822:10EED00024040018240500020C004DDB2406000465
3823:10EEE0003C1000018E106E24240200011602011D48
3824:10EEF000000000003C02000194426F263C0100012A
3825:10EF0000AC206E2424429FBC2C4200041040000C14
3826:10EF100024040009240500010C004DDB2406040034
3827:10EF200024040018240500010C004DDB24060020F9
3828:10EF300024040018240500010C004DDB24062000E9
3829:10EF40003C02400002421024104001233C022000F9
3830:10EF50000242102410400004000000003C010001A7
3831:10EF600010000003AC306F1C3C010001AC206F1C92
3832:10EF70003C0300018C636F3424020005146200F925
3833:10EF8000000000003C0200018C426F1C1040006732
3834:10EF90003C0200040242102410400011A7A00018F7
3835:10EFA0003C02000802421024104000022402020029
3836:10EFB000A7A200183C0200100242102410400004D6
3837:10EFC0000000000097A2001834420100A7A2001818
3838:10EFD00097A600182404000910000004000028214E
3839:10EFE0002404000900002821000030210C004DDB22
3840:10EFF0000000000024020001A7A2001A3C02000841
3841:10F00000024210241040000C3C0200020242102474
3842:10F010001040000224020101A7A2001A3C020001D4
3843:10F0200002421024104000053C02001097A2001A72
3844:10F0300034420040A7A2001A3C02001002421024F1
3845:10F040001040000E3C020002024210241040000555
3846:10F050003C02000197A2001A34420080A7A2001AC5
3847:10F060003C02000102421024104000053C0300A0B5
3848:10F0700097A2001A34420020A7A2001A3C0300A065
3849:10F0800002431024544300043C02002097A2001ABB
3850:10F090001000000C344204000242102450400004CE
3851:10F0A0003C02008097A2001A1000000634420800BB
3852:10F0B00002421024104000040000000097A2001A31
3853:10F0C00034420C00A7A2001A97A6001A24040004D8
3854:10F0D0000C004DDB000028213C02000402421024F9
3855:10F0E00010400004A7A0001C32425000144000044D
3856:10F0F00000000000324240001040000500002021C6
3857:10F100000C004CF902402021100000960000000085
3858:10F1100097A6001C0000282134C612000C004DDB0D
3859:10F12000A7A6001C1000008F00000000024210245F
3860:10F1300010400004A7A00018324250001440000400
3861:10F140000000000032424000104000053C02001068
3862:10F150000C004CF90240202110000019A7A0001A51
3863:10F1600002421024104000040000000097A2001882
3864:10F1700010000004A7A2001897A200183442010052
3865:10F18000A7A200183C020001024210241040000413
3866:10F190000000000097A2001810000004A7A20018A9
3867:10F1A00097A2001834422000A7A2001897A60018C2
3868:10F1B000000020210C004DDB00002821A7A0001A30
3869:10F1C000000080210C004D7824040001261000016D
3870:10F1D0002E0200201440FFFB000000000C004D78C0
3871:10F1E000000020210C004D78240400010C004D7813
3872:10F1F000240400010C004D78000020212410001090
3873:10F20000320200011040000200002021240400010D
3874:10F210000C004D78001080421600FFFA3202000107
3875:10F22000241000100C004D780000202100108042B6
3876:10F230001600FFFC000000000C004DB934108000E7
3877:10F240000C004DB9000000000C004D5800000000FB
3878:10F25000504000050010804297A2001A005010256F
3879:10F26000A7A2001A001080421600FFF7000000005D
3880:10F270000C004DB900008021A7A0001A0C004D78A9
3881:10F2800024040001261000012E0200201440FFFB80
3882:10F29000000000000C004D78000020210C004D788B
3883:10F2A000240400010C004D78240400010C004D786A
3884:10F2B0000000202124100010320200011040000242
3885:10F2C00000002021240400010C004D780010804231
3886:10F2D0001600FFFA32020001241000100C004D78D5
3887:10F2E00000002021001080421600FFFC00000000FA
3888:10F2F0000C004DB9341080000C004DB90000000026
3889:10F300000C004D58000000005040000500108042E5
3890:10F3100097A2001A00501025A7A2001A00108042E0
3891:10F320001600FFF7000000000C004DB900000000BF
3892:10F330003C04000124846BCC97A6001897A7001A00
3893:10F340003C0200018C426D983C0300018C636F1CF1
3894:10F350003C05000D34A50205AFA200100C002B3BAC
3895:10F36000AFA300148F830054240200043C01000169
3896:10F37000AC226DD43C01000110000017AC236F38A3
3897:10F380008F8300543C0200018C426F382463FF9C41
3898:10F39000004310232C4200641440000F00000000C2
3899:10F3A0008F820220240300053C010001AC236DD4B0
3900:10F3B0003C03F7000043102510000007AF82022035
3901:10F3C000240200063C010001AC226DD4240200118D
3902:10F3D0003C010001AC226DD08FBF00348FB20030F1
3903:10F3E0008FB1002C8FB0002803E0000827BD003843
3904:10F3F00027BDFFD8AFB0001800808021AFB1001C3E
3905:10F40000000088213202400010400013AFBF0020EE
3906:10F410003C020010020210242C42000100021023C2
3907:10F42000304341003C020001020210241440000657
3908:10F43000347140003C020002020210241440000219
3909:10F440003471600034714040000020210000282108
3910:10F45000100000360220302132021000104000352A
3911:10F4600000002021000028210C004DDB2406004074
3912:10F4700024040018000028210C004DDB24060C0099
3913:10F4800024040017000028210C004DDB2406040092
3914:10F4900024040016000028210C004DDB2406000681
3915:10F4A00024040017000028210C004DDB2406250051
3916:10F4B00024040016000028210C004DDB2406000661
3917:10F4C00024040017000028210C004DDB2406460010
3918:10F4D00024040016000028210C004DDB2406000641
3919:10F4E00024040017000028210C004DDB24066700CF
3920:10F4F00024040016000028210C004DDB2406000621
3921:10F500002404001F000028210C004DDB24060010FD
3922:10F5100024040009000028210C004DDB24061500FE
3923:10F52000240400090000282124061D000C004DDBE6
3924:10F53000000000003C04000124846BF03C05000E38
3925:10F5400034A501000200302102203821AFA00010B4
3926:10F550000C002B3BAFA000148FBF00208FB1001C0C
3927:10F560008FB0001803E0000827BD00288F850044F5
3928:10F570008F8200443C030001004310253C03000837
3929:10F58000AF8200448F8400548F82005400A328244B
3930:10F5900010000002248400018F8200540082102396
3931:10F5A0002C4200021440FFFC000000008F82004447
3932:10F5B0003C03FFFE3463FFFF00431024AF8200448E
3933:10F5C0008F8300548F8200541000000224630001D6
3934:10F5D0008F820054006210232C4200021440FFFC72
3935:10F5E0000000000003E0000800A010218F83004409
3936:10F5F0003C02FFF03442FFFF000424800062182424
3937:10F600003C0200020082202500641825AF830044DC
3938:10F610008F8200443C03FFFE3463FFFF004310244D
3939:10F62000AF8200448F8300548F8200541000000288
3940:10F63000246300018F820054006210232C420002D8
3941:10F640001440FFFC000000008F8200443C030001D6
3942:10F6500000431025AF8200448F8300548F820054F2
3943:10F6600010000002246300018F8200540062102306
3944:10F670002C4200021440FFFC0000000003E00008E0
3945:10F68000000000008F8200442403FF7F0043102409
3946:10F69000AF8200448F8300548F8200541000000218
3947:10F6A000246300018F820054006210232C42000268
3948:10F6B0001440FFFC000000008F82004434420080B0
3949:10F6C000AF8200448F8300548F82005410000002E8
3950:10F6D000246300018F820054006210232C42000238
3951:10F6E0001440FFFC0000000003E0000800000000E0
3952:10F6F0008F8200443C03FFF03463FFFF004310247B
3953:10F70000AF8200448F8200443C0300010043102577
3954:10F71000AF8200448F8300548F8200541000000297
3955:10F72000246300018F820054006210232C420002E7
3956:10F730001440FFFC000000008F8200443C03FFFEE9
3957:10F740003463FFFF00431024AF8200448F830054D2
3958:10F750008F82005410000002246300018F82005445
3959:10F76000006210232C4200021440FFFC0000000045
3960:10F7700003E000080000000027BDFFC8AFB300246D
3961:10F7800000809821AFBE002C00A0F021AFB2002075
3962:10F7900000C0902133C2FFFFAFBF0030AFB50028DB
3963:10F7A000AFB1001CAFB0001814400034A7B2001075
3964:10F7B0003271FFFF27B20010000080210C004D784D
3965:10F7C00024040001261000012E0200201440FFFB3B
3966:10F7D000000000000C004D78000020210C004D7846
3967:10F7E000240400010C004D78000020210C004D780D
3968:10F7F0002404000124100010320200011040000215
3969:10F8000000002021240400010C004D7800108042EB
3970:10F810001600FFFA320200012410001002301024FA
3971:10F820001040000200002021240400010C004D784B
3972:10F83000001080421600FFFA023010240C004D78B0
3973:10F84000240400010C004D780000202134108000B9
3974:10F8500096420000005010241040000200002021B9
3975:10F86000240400010C004D78001080421200007545
3976:10F87000000000001000FFF6000000003275FFFFDE
3977:10F8800027B10010A7A00010000080210C004D78C7
3978:10F8900024040001261000012E0200201440FFFB6A
3979:10F8A000000000000C004D78000020210C004D7875
3980:10F8B000240400010C004D78240400010C004D7854
3981:10F8C000000020212410001032020001104000022C
3982:10F8D00000002021240400010C004D78001080421B
3983:10F8E0001600FFFA320200012410001002B01024AA
3984:10F8F0001040000200002021240400010C004D787B
3985:10F90000001080421600FFFA02B010240C004DB91E
3986:10F91000341080000C004DB9000000000C004D5860
3987:10F9200000000000504000050010804296220000B8
3988:10F9300000501025A6220000001080421600FFF79C
3989:10F94000000000000C004DB90000000033C5FFFFAF
3990:10F950002402000154A200042402000297A2001015
3991:10F96000100000060052102514A200063271FFFF9D
3992:10F9700097A200100012182700431024A7A200101D
3993:10F980003271FFFF27B20010000080210C004D787B
3994:10F9900024040001261000012E0200201440FFFB69
3995:10F9A000000000000C004D78000020210C004D7874
3996:10F9B000240400010C004D78000020210C004D783B
3997:10F9C0002404000124100010320200011040000243
3998:10F9D00000002021240400010C004D78001080421A
3999:10F9E0001600FFFA32020001241000100230102429
4000:10F9F0001040000200002021240400010C004D787A
4001:10FA0000001080421600FFFA023010240C004D78DE
4002:10FA1000240400010C004D780000202134108000E7
4003:10FA200096420000005010241040000200002021E7
4004:10FA3000240400010C004D78001080421600FFF8ED
4005:10FA4000000000000C004DB9000000008FBF003026
4006:10FA50008FBE002C8FB500288FB300248FB20020FA
4007:10FA60008FB1001C8FB0001803E0000827BD0038DC
4008:10FA700000000000000000000000000027BDFFE8BB
4009:10FA8000AFBF00108EE304B824020008146201E046
4010:10FA9000000000003C0200018C426F1C1440000575
4011:10FAA000000000000C003DAF8F840224100001D83C
4012:10FAB000000000008F8202203C0300080043102455
4013:10FAC00010400026240200018F8402248F8202202D
4014:10FAD0003C03040000431024104000060000000016
4015:10FAE0003C010002AC208FA03C0100021000000B82
4016:10FAF000AC208FC03C03000224638FA08C62000006
4017:10FB000024420001AC6200002C42000214400003B9
4018:10FB1000240200013C010002AC228FC03C02000222
4019:10FB20008C428FC01040000630820040104000041C
4020:10FB3000240200013C01000210000003AC228FC42B
4021:10FB40003C010002AC208FC43C010002AC248F9C1D
4022:10FB50003C0100021000000BAC208FD03C010002E1
4023:10FB6000AC228FD03C010002AC208FC03C010002CF
4024:10FB7000AC208FA03C010002AC208FC43C010002ED
4025:10FB8000AC208F9C3C0300028C638F903C020002EF
4026:10FB90008C428F94506200042463FFFF3C010002FA
4027:10FBA000AC238F942463FFFF2C62000E104001945D
4028:10FBB000000310803C010001002208218C226C000F
4029:10FBC0000040000800000000240200023C01000286
4030:10FBD000AC208FC03C010002AC208FA03C01000291
4031:10FBE000AC208F9C3C010002AC208FC43C01000281
4032:10FBF000AC208FB83C010002AC208FB0AF80022453
4033:10FC00003C010002AC228F903C0200028C428FD05B
4034:10FC10001440004F3C02FDFF3442FFFF0C003DAF9B
4035:10FC20000282A024AF8002048F8202002403FFFD21
4036:10FC300000431024AF8202003C010002AC208FE0A0
4037:10FC40008F8300543C0200028C428FB824040001D0
4038:10FC50003C010002AC248FCC244200013C01000294
4039:10FC6000AC228FB82C4200043C010002AC238FB4BC
4040:10FC700014400006240200033C010001AC246D9CEA
4041:10FC80003C0100021000015EAC208FB83C01000274
4042:10FC90001000015BAC228F908F8300543C02000265
4043:10FCA0008C428FB42463D8F0004310232C422710D9
4044:10FCB00014400003240200043C010002AC228F9097
4045:10FCC0003C0200028C428FD0144000213C02FDFF18
4046:10FCD0003442FFFF1000014A0282A0243C040001CC
4047:10FCE0008C846F203C0100020C005084AC208FA853
4048:10FCF0003C0200028C428FDCAF8202043C02000214
4049:10FD00008C428FD0144000123C03FDFF8F8202040E
4050:10FD10003463FFFF304200301440012F0283A024DF
4051:10FD20003C0300028C638FDC240200053C010002CE
4052:10FD3000AC228F903C01000210000131AC238FE017
4053:10FD40003C0200028C428FD0104000103C02FDFFAC
4054:10FD50003C0200018C426E3C244200013C01000147
4055:10FD6000AC226E3C2C42000214400125240200010A
4056:10FD70003C010001AC226E443C010001AC206E3C11
4057:10FD80003C0100011000011EAC226D9C3C030002EE
4058:10FD90008C638FC03442FFFF106001190282A024DF
4059:10FDA0003C0200028C428F9C1040011500000000B4
4060:10FDB0003C010002AC228FC8240200033C01000277
4061:10FDC000AC228FA0100000B8240200063C01000203
4062:10FDD000AC208FA88F82020434420040AF8202041C
4063:10FDE0003C0200028C428FE0240300073C01000229
4064:10FDF000AC238F90344200403C010002AC228FE0E3
4065:10FE00003C0200028C428FC0104000050000000040
4066:10FE10003C0200028C428F9C104000F02402000241
4067:10FE20003C05000224A58FA08CA200002C424E218C
4068:10FE3000104000EA240200023C0200028C428FC4FF
4069:10FE4000104000EF2404FFBF3C0200028C428F9C54
4070:10FE50003C0300028C638FC8004410240064182403
4071:10FE600010430004240200013C010002100000E4E1
4072:10FE7000AC228F9024020003ACA2000024020008F0
4073:10FE80003C010002AC228F903C0200028C428FCCDD
4074:10FE90001040000C240200013C0400020C005091B0
4075:10FEA0008C848F9C3C0200028C428FE81440000539
4076:10FEB000240200013C0200028C428FE41040000644
4077:10FEC000240200013C010001AC226D9C3C010002B7
4078:10FED000100000CBAC208FB83C0200028C428FB0E7
4079:10FEE0003C0300028C638F9C2C420001000210C076
4080:10FEF000306300083C010002AC228FB03C010002DC
4081:10FF0000AC238FAC8F830054240200093C01000213
4082:10FF1000AC228F903C010002100000B9AC238FB4DA
4083:10FF20008F8300543C0200028C428FB42463D8F0CB
4084:10FF3000004310232C4227101440009F00000000B3
4085:10FF40003C0200028C428FC01040000500000000FF
4086:10FF50003C0200028C428F9C104000A02402000250
4087:10FF60003C03000224638FA08C6200002C424E21CF
4088:10FF70001040009A240200023C0200028C428FCC06
4089:10FF80001040000E000000003C0200028C428F9CDA
4090:10FF90003C010002AC208FCC304200801040002F8A
4091:10FFA0002402000C8F820204304200801440000CB6
4092:10FFB00024020003100000292402000C3C0200026D
4093:10FFC0008C428F9C304200801440000524020003C4
4094:10FFD0008F820204304200801040001F2402000380
4095:10FFE000AC6200002402000A3C010002AC228F90A7
4096:10FFF0003C04000224848FD88C8200003C03000261
4097:020000021000EC
4098:100000008C638FB000431025AF8202048C83000004
4099:100010003C0400028C848FB02402000B3C010002DF
4100:10002000AC228F90006418253C010002AC238FE0C5
4101:100030003C05000224A58FA08CA200002C424E217A
4102:1000400010400066240200023C0200028C428FD065
4103:1000500010400005000000002402000C3C010002DA
4104:1000600010000067AC228F903C0200028C428FC0CF
4105:1000700010400063000000003C0400028C848F9C50
4106:1000800010800055308200083C0300028C638FAC66
4107:100090001062005B240200033C010002AC248FC804
4108:1000A000ACA20000240200063C0100021000005433
4109:1000B000AC228F908F82020034420002AF82020095
4110:1000C0008F8300542402000D3C010002AC228F906B
4111:1000D0003C010002AC238FB48F8300543C02000229
4112:1000E0008C428FB42463D8F0004310232C42271095
4113:1000F00014400031000000003C0200028C428FD00E
4114:10010000104000202402000E3C0300028C638FE4A8
4115:100110003C01000214600015AC228F900C003E6D73
4116:10012000000000003C0500018CA56D980C00529B5E
4117:10013000000020213C0300018C636D982402000420
4118:10014000146200052403FFFB3C0200018C426D9405
4119:10015000100000032403FFF73C0200018C426D9461
4120:10016000004310243C010001AC226D948F830224D3
4121:100170003C0202003C010002AC238FEC1000002086
4122:100180000282A0253C0200028C428FC01040000574
4123:10019000000000003C0200028C428F9C1040000FC7
4124:1001A000240200023C0200028C428FA02C424E210D
4125:1001B0001040000A240200023C0200028C428FC060
4126:1001C0001040000F000000003C0200028C428F9C97
4127:1001D0001440000B00000000240200023C01000259
4128:1001E00010000007AC228F903C0200028C428FC0AE
4129:1001F00010400003000000000C003DAF00000000B4
4130:100200008F8202203C03F70000431025AF820220BA
4131:100210008FBF001003E0000827BD00183C03000258
4132:1002200024638FE88C6200001040000534422000F7
4133:100230003C010002AC228FDC10000003AC60000027
4134:100240003C010002AC248FDC03E000080000000049
4135:1002500027BDFFE030820030AFBF00183C01000234
4136:10026000AC228FE4144000673C02FFFF34421F0EB3
4137:1002700000821024144000612402003030822000EB
4138:100280001040005D3083800000031A0230820001BC
4139:10029000000212003C0400018C846F2000621825CB
4140:1002A000000331C23C03000124636E4830828000A9
4141:1002B00000021202308400010004220000441025D4
4142:1002C000000239C2000610800043102100471021AF
4143:1002D000904300002402000110620025000000008D
4144:1002E00010600007240200021062001324020003C1
4145:1002F0001062002C3C05000F1000003700000000C9
4146:100300008F8202002403FEFF00431024AF8202000C
4147:100310008F8202203C03FFFE3463FFFF0043102462
4148:10032000AF8202203C010002AC2090043C0100029C
4149:1003300010000034AC20900C8F8202003442010087
4150:10034000AF8202008F8202203C03FFFE3463FFFF76
4151:1003500000431024AF820220240201003C0100026D
4152:10036000AC2290043C01000210000026AC20900C4E
4153:100370008F8202002403FEFF00431024AF8202009C
4154:100380008F8202203C03000100431025AF8202202F
4155:100390003C010002AC2090043C0100021000001956
4156:1003A000AC23900C8F82020034420100AF82020025
4157:1003B0008F8202203C03000100431025AF820220FF
4158:1003C000240201003C010002AC2290043C01000226
4159:1003D0001000000CAC23900C34A5FFFF3C0400017E
4160:1003E00024846C38AFA300100C002B3BAFA000148A
4161:1003F0001000000400000000240200303C01000254
4162:10040000AC228FE88FBF001803E0000827BD002052
4163:1004100000000000000000000000000027BDFFC831
4164:10042000AFB2002800809021AFB3002C00A098212B
4165:10043000AFB0002000C080213C04000124846C5037
4166:100440003C0500093C0200018C426D9834A59001E6
4167:100450000240302102603821AFBF0030AFB100242C
4168:10046000A7A0001AAFB000140C002B3BAFA20010E5
4169:1004700024020002126200832E6200031040000575
4170:10048000240200011262000A000000001000017343
4171:100490000000000024020004126200F82402000898
4172:1004A000126200F73C02FFEC1000016C000000003B
4173:1004B0003C0200018C426D94304200021440000462
4174:1004C000001289403C02FFFB3442FFFF02028024FD
4175:1004D0003C01000200310821AC308FFC3C0240009E
4176:1004E000020210241040004E001023C2308400305D
4177:1004F000001013823042001C3C03000124636DD8BD
4178:1005000000431021008238213C0200200202102406
4179:1005100010400006240201003C01000200310821C5
4180:10052000AC229000100000053C0200803C0100025B
4181:1005300000310821AC2090003C020080020210240F
4182:1005400010400006001219403C0200013C0100026C
4183:100550000023082110000005AC2290080012114071
4184:100560003C01000200220821AC20900894E4000025
4185:100570003C0300018C636F402402000510620010F0
4186:10058000A7A400183202400010400002348240004C
4187:10059000A7A200182404000194E20002240500042C
4188:1005A00024E60002344200010C0045BEA4E2000231
4189:1005B00024040001000028210C0045BE27A60018D5
4190:1005C0003C0200018C426D98241100013C010001A5
4191:1005D000AC316DA414530004320280000C003DAF16
4192:1005E00000000000320280001040011C00000000EA
4193:1005F0000C003DAF000000003C0300018C636F4025
4194:100600002402000510620115240200023C010001D1
4195:10061000AC316D9C3C01000110000110AC226D98C2
4196:10062000240400012405000427B0001A0C0045BE74
4197:100630000200302124040001000028210C0045BEE6
4198:10064000020030213C020002005110218C428FF444
4199:100650003C0400018C846D983C03BFFF3463FFFFB2
4200:100660003C010001AC336DA4004310243C010002A6
4201:1006700000310821109300F7AC228FF4100000F72E
4202:10068000000000003C02200002021024104000057F
4203:10069000240200013C010001AC226F1C1000000488
4204:1006A000001289403C010001AC206F1C00128940FF
4205:1006B0003C01000200310821AC308FF83C024000C0
4206:1006C0000202102414400014000000003C0200014B
4207:1006D0008C426F1C10400006240400042405000115
4208:1006E0000C004DDB2406200024020001AEE204B819
4209:1006F0003C020002005110218C428FF03C03BFFFEE
4210:100700003463FFFF004310243C0100020031082144
4211:10071000100000D0AC228FF03C0200018C426F1C14
4212:10072000104000283C0300A0020310245443000D95
4213:100730003C0200203C0200018C426F202403010097
4214:100740003C01000200310821AC2390043C0300016D
4215:100750003C01000200310821AC23900C1000001570
4216:100760003442040002021024104000082403010057
4217:100770003C0200018C426F203C0100020031082144
4218:10078000AC2390041000000B344208003C020080AF
4219:10079000020210241040002E3C0300013C02000124
4220:1007A0008C426F203C01000200310821AC23900CE8
4221:1007B00034420C003C010001AC226F2010000025E7
4222:1007C000240400013C020020020210241040000614
4223:1007D000240201003C01000200310821AC229004F7
4224:1007E000100000053C0200803C010002003108219D
4225:1007F000AC2090043C02008002021024104000074C
4226:10080000001219403C0200013C01000200230821B3
4227:10081000AC22900C100000062404000100121140CC
4228:100820003C01000200220821AC20900C24040001AD
4229:100830000000282127B0001E0C00457C020030215A
4230:1008400024040001000028210C00457C0200302116
4231:10085000240400012405000127B0001C0C00457C85
4232:100860000200302124040001240500010C00457C15
4233:100870000200302110000077000000003C02FFEC75
4234:100880003442FFFF020280243C020008020280255D
4235:10089000001211403C01000200220821AC308FF808
4236:1008A0003C02200002021024104000090000000059
4237:1008B0003C0200018C426E441440000524020001F9
4238:1008C0003C010001AC226F1C100000043C024000FF
4239:1008D0003C010001AC206F1C3C02400002021024CD
4240:1008E0001440001D24020E013C0300018C636F1CA8
4241:1008F000AF8202383C010001AC206DB010600005F1
4242:10090000240220203C010001AC226F2024020001BF
4243:10091000AEE204B83C04BFFF001219403C020002E2
4244:10092000004310218C428FF03C0500018CA56D988E
4245:100930003484FFFF004410243C01000200230821FE
4246:10094000AC228FF02402000110A20044000000003D
4247:1009500010000040000000003C0200018C426F1CAF
4248:100960001040001C240220003C010001AC226F203A
4249:100970003C0300A0020310241443000500121140A0
4250:100980003402A0003C0100011000002DAC226F20B9
4251:100990003C030002006218218C638FF83C020020A7
4252:1009A0000062102410400004240220013C010001D8
4253:1009B00010000023AC226F203C0200800062102453
4254:1009C0001040001F3402A0013C0100011000001C77
4255:1009D000AC226F203C0200200202102410400007CD
4256:1009E00000121940240201003C01000200230821EA
4257:1009F000AC229004100000063C020080001211405E
4258:100A00003C01000200220821AC2090043C0200803E
4259:100A10000202102410400006001219403C0200019E
4260:100A20003C0100020023082110000005AC22900CBC
4261:100A3000001211403C01000200220821AC20900C61
4262:100A40003C0300018C636D982402000110620003D6
4263:100A5000000000000C003DAF000000008FBF003020
4264:100A60008FB3002C8FB200288FB100248FB00020EC
4265:100A700003E0000827BD003827BDFFB0AFB3003C3E
4266:100A800000009821AFB500400000A821AFB10034AC
4267:100A90000000882124020002AFBF0048AFBE00441E
4268:100AA000AFB20038AFB00030AFA4002CA7A0001A3E
4269:100AB000A7A00018A7A00020A7A0001EA7A00022A2
4270:100AC00010A20130A7A0001C2CA2000310400005BA
4271:100AD0002402000110A2000A3C0240001000025D46
4272:100AE000022010212402000410A2020A240200089D
4273:100AF00010A202080220102110000256000000007F
4274:100B00008FA8002C000881403C03000200701821CF
4275:100B10008C638FFC0062102414400009240400013F
4276:100B20003C027FFF3442FFFF006288243C01000248
4277:100B300000300821AC318FF4100002460220102151
4278:100B4000240500010C00457C27A6001824040001A0
4279:100B5000240500010C00457C27A6001897A2001868
4280:100B600030420004104000D93C1140003C0200011A
4281:100B70008C426F402443FFFF2C620006104000D9D6
4282:100B8000000310803C010001002208218C226C68C7
4283:100B900000400008000000002404000124050011AA
4284:100BA00027B0001A0C00457C02003021240400010B
4285:100BB000240500110C00457C0200302197A3001A87
4286:100BC00030624000104000023C1500103C15000847
4287:100BD00030628000104000AA3C130001100000A801
4288:100BE0003C130002240400012405001427B0001A5D
4289:100BF0000C00457C0200302124040001240500146F
4290:100C00000C00457C0200302197A3001A30621000CE
4291:100C1000104000023C1500103C150008306208002E
4292:100C2000104000973C130001100000953C13000297
4293:100C3000240400012405001927B0001C0C00457C89
4294:100C40000200302124040001240500190C00457C19
4295:100C50000200302197A2001C304307002402040048
4296:100C600010620027286204011040000E24020200D6
4297:100C70001062001F286202011040000524020100DA
4298:100C80005062001E3C1300011000001E24040001ED
4299:100C900024020300506200193C13000210000019E6
4300:100CA00024040001240206001062000D28620601DF
4301:100CB00010400005240205005062000B3C130002A6
4302:100CC0001000001024040001240207001462000D2B
4303:100CD000240400013C1300041000000A3C15000825
4304:100CE000100000063C130004100000053C1500082D
4305:100CF0003C130001100000023C1500083C150010D8
4306:100D0000240400012405001827B0001E0C00457CB7
4307:100D10000200302124040001240500180C00457C49
4308:100D2000020030218FA8002C97A7001E0008114058
4309:100D30003C06000200C230218CC68FF497A200222C
4310:100D40003C10000126106C5C02002021AFA20010B4
4311:100D500097A2001C3C05000C34A503030C002B3BA0
4312:100D6000AFA200143C020004166200103C02000115
4313:100D70008F84005424030001240200023C0100017E
4314:100D8000AC236D9C3C010001AC226D983C0100013C
4315:100D9000AC236DA43C010001AC236E243C01000196
4316:100DA000AC246F301000004F02B388251662003962
4317:100DB0003C0280003C0200018C426E201440001E68
4318:100DC0002404001800002021000028210C004DDB25
4319:100DD000340680008F8300548F82005402B388252C
4320:100DE00010000002246300328F820054006210233E
4321:100DF0002C4200331440FFFC000000008F8300549D
4322:100E0000240200013C010001AC226E203C010001E3
4323:100E1000AC226D9C3C010001AC226D983C010001AC
4324:100E2000AC226DA43C010001AC226E243C01000107
4325:100E30001000002CAC236F30000028210C004DDB8B
4326:100E400024060404000020212405001E27A6001803
4327:100E5000240200020C0045BEA7A2001800002021B9
4328:100E60000000282127A600180C0045BEA7A00018E6
4329:100E700024040018240500020C004DDB24060004A5
4330:100E80003C0280000222102502B318251000001534
4331:100E90000043882502221025027518250043882565
4332:100EA0000200202197A6001C3C0700018CE76D98EA
4333:100EB0003C05000C34A50326AFB300100C002B3BFF
4334:100EC000AFB1001410000007000000003C11000248
4335:100ED000023088218E318FFC3C027FFF3442FFFFBD
4336:100EE000022288243C0200018C426DA81040001EA2
4337:100EF000000000003C0200018C426F1C1040000208
4338:100F00003C022000022288258FA8002C00081140F6
4339:100F10003C010002002208218C22900010400003B6
4340:100F20003C02002010000005022288253C02FFDF61
4341:100F30003442FFFF022288248FA8002C00081140B1
4342:100F40003C010002002208218C229008104000037E
4343:100F50003C02008010000004022288253C02FF7F32
4344:100F60003442FFFF022288248FA8002C0008114081
4345:100F70003C01000200220821AC318FF41000013541
4346:100F8000022010218FA8002C0008F1403C03000231
4347:100F9000007E18218C638FF83C0240000062102410
4348:100FA00014400009240400013C027FFF3442FFFF8B
4349:100FB000006288243C010002003E0821AC318FF021
4350:100FC0001000012402201021000028210C00457C83
4351:100FD00027A6001824040001000028210C00457CED
4352:100FE00027A60018240400012405000127B20020D0
4353:100FF0000C00457C0240302124040001240500013E
4354:101000000C00457C0240302124040001240500042A
4355:1010100027B1001E0C00457C022030212404000171
4356:10102000240500040C00457C02203021240400012A
4357:101030002405000527B000220C00457C0200302169
4358:1010400024040001240500050C00457C0200302129
4359:1010500024040001240500100C00457C27A600187C
4360:1010600024040001240500100C00457C27A600186C
4361:10107000240400012405000A0C00457C02403021B4
4362:10108000240400012405000A0C00457C02403021A4
4363:1010900024040001240500180C00457C02203021A6
4364:1010A00024040001240500180C00457C0220302196
4365:1010B00024040001240500010C00457C27A600182B
4366:1010C00024040001240500010C00457C27A600181B
4367:1010D00097A2001830420004104000663C11400006
4368:1010E0003C0300018C636F34240200051462006726
4369:1010F000240400012405001927B0001C0C00457CC5
4370:101100000200302124040001240500190C00457C54
4371:101110000200302197A2001C304307002402040083
4372:1011200010620027286204011040000E2402020011
4373:101130001062001F28620201104000052402010015
4374:101140005062001E3C1300011000001E3C0200040F
4375:1011500024020300506200193C1300021000001921
4376:101160003C020004240206001062000D2862060101
4377:1011700010400005240205005062000B3C130002E1
4378:10118000100000103C020004240207001462000D4D
4379:101190003C0200043C1300041000000A3C15000847
4380:1011A000100000063C130004100000053C15000868
4381:1011B0003C130001100000023C1500083C15001013
4382:1011C0003C020004126200173C0280008F8200542F
4383:1011D000241000013C010001AC306D9C3C01000179
4384:1011E000AC306D983C010001AC306DA43C010001B5
4385:1011F000AC306E243C010001AC226F303C02000197
4386:101200001662002202758825000020210000282196
4387:101210000C004DDB340680003C0100011000001B77
4388:10122000AC306E200222102502B318250043882519
4389:1012300097A6001C3C0200018C426F1C3C07000179
4390:101240008CE76D983C04000124846C5CAFA2001014
4391:1012500097A2001E3C05000C34A503233C010001AD
4392:10126000AC206E200C002B3BAFA200141000000736
4393:10127000000000003C110002023E88218E318FF0F8
4394:101280003C027FFF3442FFFF022288243C0200011F
4395:101290008C426DA810400069000000003C02000173
4396:1012A0008C426F1C104000023C0220000222882564
4397:1012B0008FA8002C000811403C01000200220821E8
4398:1012C0008C229004104000033C0200201000000516
4399:1012D000022288253C02FFDF3442FFFF02228824DD
4400:1012E0008FA8002C000811403C01000200220821B8
4401:1012F0008C22900C104000033C0200801000004F34
4402:10130000022288253C02FF7F3442FFFF1000004B81
4403:10131000022288248FA8002C000829403C030002E8
4404:10132000006518218C638FF83C0240000062102495
4405:10133000144000083C027FFF3442FFFF0062882413
4406:101340003C01000200250821AC318FF01000004163
4407:10135000022010213C0200018C426DA81040003494
4408:101360003C11C00C3C0200018C426E443C04C00C99
4409:10137000348420003C0300018C636F1C0002102B9E
4410:10138000000210230044102410600003005188253F
4411:101390003C022000022288253C0200020045102168
4412:1013A0008C429004104000033C0200201000000416
4413:1013B000022288253C02FFDF3442FFFF02228824FC
4414:1013C0008FA8002C000811403C01000200220821D7
4415:1013D0008C22900C104000033C020080100000049E
4416:1013E000022288253C02FF7F3442FFFF022288242C
4417:1013F0003C0200018C426E30104000023C020800AA
4418:10140000022288253C0200018C426E34104000020A
4419:101410003C020400022288253C0200018C426E3806
4420:10142000104000063C020100100000040222882542
4421:101430003C027FFF3442FFFF006288248FA8002C0B
4422:10144000000811403C01000200220821AC318FF05D
4423:10145000022010218FBF00488FBE00448FB500408E
4424:101460008FB3003C8FB200388FB100348FB00030A2
4425:1014700003E0000827BD005027BDFFD0AFB2002811
4426:1014800000809021AFBF002CAFB10024AFB000208E
4427:101490008F8402003C1000018E106D988F86022010
4428:1014A000240200021202005C2E020003104000051C
4429:1014B000240200011202000A001219401000010C5F
4430:1014C0000000000024020004120200BF24020008F1
4431:1014D000120200BE00128940100001050000000049
4432:1014E0003C05000200A328218CA58FFC3C100002C3
4433:1014F000020380218E108FF43C02400000A21024D1
4434:10150000104000383C020008020210241040002065
4435:10151000348400023C020002004310218C429000FF
4436:101520001040000534840020348401003C02002077
4437:1015300010000006020280252402FEFF0082202403
4438:101540003C02FFDF3442FFFF020280240012114000
4439:101550003C010002002208218C2290081040000566
4440:101560003C02000100C230253C0200801000001641
4441:10157000020280253C02FFFE3442FFFF00C23024FD
4442:101580003C02FF7F3442FFFF1000000F0202802464
4443:101590002402FEDF008220243C02FFFE3442FFFFD3
4444:1015A00000C230243C02FF5F3442FFFF020280246D
4445:1015B0003C01000200230821AC2090003C01000205
4446:1015C00000230821AC209008AF840200AF860220DF
4447:1015D0008F82022034420002AF8202201000000AF3
4448:1015E000001211403C02BFFF3442FFFF8F83020014
4449:1015F000020280242402FFFD006218240C003DAF8B
4450:10160000AF830200001211403C01000200220821B9
4451:10161000100000B7AC308FF43C0200018C426F1C0C
4452:101620001040006924050004240400010C00457CDE
4453:1016300027A6001824040001240500050C00457CA1
4454:1016400027A6001A97A3001897A2001A3C040001CD
4455:1016500024846E4830630C0000031A8230420C0070
4456:1016600000021282A7A2001A00021080004410217A
4457:1016700000431021A7A30018904800002402000195
4458:101680003103FFFF106200292862000210400005AC
4459:101690000000000010600009000000001000003D84
4460:1016A0000000000010700013240200031062002CE0
4461:1016B0000000000010000037000000008F820200D0
4462:1016C0002403FEFF00431024AF8202008F82022019
4463:1016D0003C03FFFE3463FFFF00431024AF8202206F
4464:1016E0003C010002AC2090043C01000210000032DA
4465:1016F000AC20900C8F82020034420100AF820200C5
4466:101700008F8202203C03FFFE3463FFFF004310245E
4467:10171000AF820220240201003C010002AC229004AE
4468:101720003C01000210000024AC20900C8F820200CB
4469:101730002403FEFF00431024AF8202008F820220A8
4470:101740003C03000100431025AF8202203C0100024F
4471:10175000AC2090043C01000210000017AC23900C58
4472:101760008F82020034420100AF8202008F82022089
4473:101770003C03000100431025AF8202202402010037
4474:101780003C010002AC2290043C0100021000000A5F
4475:10179000AC23900C3C04000124846C8097A6001AB2
4476:1017A00097A700183C05000134A5FFFFAFA8001063
4477:1017B0000C002B3BAFA000148F82020034420002C9
4478:1017C0001000004BAF820200001289403C0500026D
4479:1017D00000B128218CA58FF83C1000020211802155
4480:1017E0008E108FF03C02400000A210241440001024
4481:1017F000000000003C0200018C426F1C14400005F8
4482:101800003C02BFFF8F82020034420002AF8202001E
4483:101810003C02BFFF3442FFFF0C003DAF02028024B8
4484:101820003C0100020031082110000031AC308FF083
4485:101830003C0200018C426F1C104000053C0200205D
4486:101840003C0200018C426E44104000253C02002006
4487:1018500000A210241040000734840020240201005C
4488:101860003C01000200310821AC2290041000000667
4489:10187000348401003C01000200310821AC209004B6
4490:101880002402FEFF008220243C02008000A21024DB
4491:1018900010400007001219403C0200013C01000208
4492:1018A00000230821AC22900C1000000800C2302553
4493:1018B000001211403C01000200220821AC20900CD3
4494:1018C0003C02FFFE3442FFFF00C23024AF8402001E
4495:1018D000AF8602208F82022034420002AF820220B3
4496:1018E000001211403C01000200220821AC308FF0B0
4497:1018F0008FBF002C8FB200288FB100248FB0002042
4498:1019000003E0000827BD003000000000000018219F
4499:10191000308400FF2405FFDF2406FFBF00641007AA
4500:101920003042000110400004000000008F8200449B
4501:1019300010000003344200408F820044004610240F
4502:10194000AF8200448F82004434420020AF820044C2
4503:101950008F82004400451024AF82004424630001BC
4504:10196000286200085440FFEE0064100703E00008FE
4505:10197000000000002C8200081040001B0000000046
4506:101980002405FFDF2406FFBF000418803C0200018D
4507:1019900024426E60006218212464000490620000FA
4508:1019A00010400004000000008F820044100000037B
4509:1019B000344200408F82004400461024AF8200442D
4510:1019C0008F82004434420020AF8200448F82004462
4511:1019D00000451024AF820044246300010064102BF2
4512:1019E0001440FFEE0000000003E0000800000000CB
4513:1019F0000000000000000000000000008F8400C410
4514:101A00008F8600E08F8700E42402FFF800C22824BC
4515:101A100010E5001A27623FF814E2000224E80008EB
4516:101A200027683000550500048D0A000030C200040C
4517:101A300014400012008050218CE900008F42013CCC
4518:101A4000014948230049182B94EB0006106000025E
4519:101A500025630050004948210123182B5040000302
4520:101A60008F4201FC03E0000800E01021AF8800E88D
4521:101A700024420001AF4201FCAF8800E403E000080B
4522:101A80000000102103E00008000000008F8300E444
4523:101A900027623FF81062000424620008AF8200E869
4524:101AA00003E00008AF8200E427623000AF8200E864
4525:101AB00003E00008AF8200E403E00008000000003B
4526:101AC0000000000000000000000000008F880120DE
4527:101AD00027624FE08F8301281502000225090020AC
4528:101AE00027694800112300128FA20010AD040000E6
4529:101AF000AD050004AD060008A507000E8FA3001475
4530:101B0000AD0200188FA20018AD03001C25030016BB
4531:101B1000AD020010AD030014AF8901208F4300FC1B
4532:101B2000240200012463FFFF03E00008AF4300FC30
4533:101B30008F430324000010212463000103E0000808
4534:101B4000AF43032403E00008000000008F88010079
4535:101B5000276247E08F830108150200022509002053
4536:101B6000276940001123000F8FA20010AD04000070
4537:101B7000AD050004AD060008A507000E8FA30014F4
4538:101B8000AD0200188FA20018AD03001C250300163B
4539:101B9000AD020010AD030014AF89010003E000089E
4540:101BA000240200018F430328000010212463000158
4541:101BB00003E00008AF43032803E000080000000032
4542:101BC00000000000000000000000000024486561E3
4543:101BD0006465723A202F70726F6A656374732F7236
4544:101BE00063732F73772F67652F2E2F6E69632F66B0
4545:101BF00077322F636F6D6D6F6E2F66776D61696ED3
4546:101C00002E632C7620312E312E322E343520313970
4547:101C100039392F30312F32342030303A31303A35A3
4548:101C20003520736875616E67204578702024000048
4549:101C3000657674526E674600516576744600000002
4550:101C400051657674505F46004D657674526E6746F6
4551:101C5000000000004D516576744600004D516576D8
4552:101C6000505F46005173436F6E495F4600000000AD
4553:101C70005173436F6E734600517250726F64460029
4554:101C80006261644D656D537A0000000068775665A7
4555:101C900072000000626164487756657200000000BF
4556:101CA0002A2A4441574E5F41000000007478527860
4557:101CB0004266537A00000000626641746E4D726B9A
4558:101CC000000000007265645A6F6E6531000000000C
4559:101CD000706369436F6E660067656E436F6E660082
4560:101CE0002A646D615244666C000000002A50414E27
4561:101CF00049432A002E2E2F2E2E2F2E2E2F2E2E2F02
4562:101D00002E2E2F7372632F6E69632F6677322F63C7
4563:101D10006F6D6D6F6E2F66776D61696E2E6300005B
4564:101D2000726362466C616773000000006261645216
4565:101D30007852636200000000676C6F62466C6773E4
4566:101D4000000000002B5F646973705F6C6F6F700040
4567:101D50002B65765F68616E646C65720063616E749A
4568:101D600031446D61000000002B715F646D615F7430
4569:101D70006F5F6E69635F636B73756D002B685F7374
4570:101D8000656E645F646174615F72656164795F63ED
4571:101D90006B73756D000000002B685F646D615F728E
4572:101DA000645F6173736973745F636B73756D000057
4573:101DB00074436B736D4F6E002B715F646D615F7464
4574:101DC0006F5F6E69630000002B685F73656E645F10
4575:101DD000646174615F726561647900002B685F649F
4576:101DE0006D615F72645F61737369737400000000FA
4577:101DF00074436B736D4F6666000000002B685F7361
4578:101E0000656E645F62645F72656164790000000002
4579:101E10006873745352696E67000000006261645316
4580:101E200052696E67000000006E69635352696E6705
4581:101E30000000000077446D61416C6C4100000000BF
4582:101E40002B715F646D615F746F5F686F73745F6344
4583:101E50006B73756D000000002B685F6D61635F72CE
4584:101E6000785F636F6D705F636B73756D000000006A
4585:101E70002B685F646D615F77725F61737369737400
4586:101E80005F636B73756D000072436B736D4F6E0013
4587:101E90002B715F646D615F746F5F686F73740000B6
4588:101EA0002B685F6D61635F72785F636F6D700000B8
4589:101EB0002B685F646D615F77725F617373697374C0
4590:101EC0000000000072436B736D4F666600000000F7
4591:101ED0002B685F726563765F62645F7265616479C7
4592:101EE000000000002B685F726563765F6A756D6243
4593:101EF0006F5F62645F726561647900002B685F7276
4594:101F00006563765F6D696E695F62645F7265616467
4595:101F1000790000002B6D685F636F6D6D616E64000A
4596:101F20002B685F74696D6572000000002B685F6448
4597:101F30006F5F7570646174655F74785F636F6E73F3
4598:101F4000000000002B685F646F5F757064617465EA
4599:101F50005F72785F70726F64000000002B636B73B8
4600:101F6000756D3136000000002B7065656B5F6D612B
4601:101F7000635F72785F7761002B7065656B5F6D6181
4602:101F8000635F7278000000002B6465715F6D6163B0
4603:101F90005F7278002B685F6D61635F72785F617458
4604:101FA000746E0000626164526574537A0000000030
4605:101FB000727842644266537A000000002B6E756CA2
4606:101FC0006C5F68616E646C657200000066774F70CC
4607:101FD0004661696C000000002B685F757064617475
4608:101FE000655F6C65643400002B685F7570646174B4
4609:101FF000655F6C65643600002B685F7570646174A2
4610:10200000655F6C6564320000696E74537461746559
4611:10201000000000002A2A696E697443700000000005
4612:102020002373637265616D0069537461636B4572FC
4613:102030000000000070726F62654D656D0000000069
4614:102040002A2A4441574E5F42000000002B73775FFD
4615:10205000646D615F6173736973745F706C75735FD6
4616:1020600074696D65720000002B267072656C6F617B
4617:10207000645F77725F646573637200002B26707211
4618:10208000656C6F61645F72645F64657363720000A6
4619:102090002B685F68665F74696D65720024486561CE
4620:1020A0006465723A202F70726F6A656374732F7261
4621:1020B00063732F73772F67652F2E2F6E69632F66DB
4622:1020C00077322F636F6D6D6F6E2F74696D65722E31
4623:1020D000632C7620312E312E322E33352031393992
4624:1020E000392F30312F32372031393A30393A3530C3
4625:1020F0002068617965732045787020240000000015
4626:10210000657674526E67460051657674460000002D
4627:1021100051657674505F46004D657674526E674621
4628:10212000000000004D516576744600004D51657603
4629:10213000505F46005173436F6E495F4600000000D8
4630:102140005173436F6E734600517250726F64460054
4631:10215000542D446D6152643200000000542D446DD2
4632:102160006152643100000000542D446D615264429C
4633:1021700000000000542D446D6157723200000000D1
4634:10218000542D446D6157723100000000542D446D90
4635:1021900061577242000000000000000024486561A1
4636:1021A0006465723A202F70726F6A656374732F7260
4637:1021B00063732F73772F67652F2E2F6E69632F66DA
4638:1021C00077322F636F6D6D6F6E2F636F6D6D616E04
4639:1021D000642E632C7620312E312E322E323820316F
4640:1021E0003939392F30312F32302031393A34393AB8
4641:1021F000343920736875616E67204578702024003B
4642:10220000657674526E67460051657674460000002C
4643:1022100051657674505F46004D657674526E674620
4644:10222000000000004D516576744600004D51657602
4645:10223000505F46005173436F6E495F4600000000D7
4646:102240005173436F6E734600517250726F64460053
4647:102250003F48636D644D6278000000003F636D6429
4648:1022600048737453000000003F636D644D634D6418
4649:10227000000000003F636D6450726F6D000000004D
4650:102280003F636D644C696E6B000000003F636D64DA
4651:1022900045727200000086AC00008E5C00008E5C0F
4652:1022A00000008DE400008B7800008E3000008E5C12
4653:1022B00000008790000088000000899000008A6874
4654:1022C00000008A3400008E5C0000887000008B24BF
4655:1022D00000008E5C00008B34000087B4000088246E
4656:1022E00000000000000000000000000024486561BC
4657:1022F0006465723A202F70726F6A656374732F720F
4658:1023000063732F73772F67652F2E2F6E69632F6688
4659:1023100077322F636F6D6D6F6E2F6D636173742EE7
4660:10232000632C7620312E312E322E38203139393837
4661:102330002F31322F30382030323A33363A3336208C
4662:10234000736875616E672045787020240000000076
4663:10235000657674526E6746005165767446000000DB
4664:1023600051657674505F46004D657674526E6746CF
4665:10237000000000004D516576744600004D516576B1
4666:10238000505F46005173436F6E495F460000000086
4667:102390005173436F6E734600517250726F64460002
4668:1023A0006164644D63447570000000006164644DB5
4669:1023B0006346756C0000000064656C4D634E6F45AC
4670:1023C00000000000000000000000000024486561DB
4671:1023D0006465723A202F70726F6A656374732F722E
4672:1023E00063732F73772F67652F2E2F6E69632F66A8
4673:1023F00077322F636F6D6D6F6E2F646D612E632C5E
4674:102400007620312E312E322E323420313939382F88
4675:1024100031322F32312030303A33333A3039207371
4676:102420006875616E67204578702024006576745267
4677:102430006E674600516576744600000051657674FB
4678:10244000505F46004D657674526E6746000000008E
4679:102450004D516576744600004D516576505F4600DB
4680:102460005173436F6E495F46000000005173436F24
4681:102470006E734600517250726F6446007377446DFC
4682:10248000614F66660000000031446D614F6E0000D0
4683:102490007377446D614F6E002372446D6141544EF9
4684:1024A0000000000072446D6141544E300000000095
4685:1024B00072446D6141544E310000000072446D6100
4686:1024C000344762002A50414E49432A002E2E2F2EB7
4687:1024D0002E2F2E2E2F2E2E2F2E2E2F7372632F6E19
4688:1024E00069632F6677322F636F6D6D6F6E2F646D2A
4689:1024F000612E63002377446D6141544E000000005B
4690:1025000077446D6141544E300000000077446D61A6
4691:1025100041544E310000000077446D613447620041
4692:102520000000000000000000000000002448656179
4693:102530006465723A202F70726F6A656374732F72CC
4694:1025400063732F73772F67652F2E2F6E69632F6646
4695:1025500077322F636F6D6D6F6E2F74726163652EAE
4696:10256000632C7620312E312E322E352031393938F8
4697:102570002F30392F33302031383A35303A32382045
4698:10258000736875616E672045787020240000000034
4699:102590000000000000000000000000002448656109
4700:1025A0006465723A202F70726F6A656374732F725C
4701:1025B00063732F73772F67652F2E2F6E69632F66D6
4702:1025C00077322F636F6D6D6F6E2F646174612E6350
4703:1025D0002C7620312E312E322E31322031393939BC
4704:1025E0002F30312F32302031393A34393A353120D9
4705:1025F000736875616E6720457870202400000000C4
4706:1026000046575F56455253494F4E3A202331204694
4707:1026100072692041707220372031373A35373A35A8
4708:1026200032205044542032303030000046575F434F
4709:102630004F4D50494C455F54494D453A2031373A4A
4710:1026400035373A353200000046575F434F4D504909
4711:102650004C455F42593A206465767263730000000E
4712:1026600046575F434F4D50494C455F484F53543A8E
4713:1026700020636F6D707574650000000046575F43FE
4714:102680004F4D50494C455F444F4D41494E3A2065AE
4715:102690006E672E616374656F6E2E636F6D00000050
4716:1026A00046575F434F4D50494C45523A206763634C
4717:1026B0002076657273696F6E20322E372E320000DD
4718:1026C00000000000120411000000000024486561B1
4719:1026D0006465723A202F70726F6A656374732F722B
4720:1026E00063732F73772F67652F2E2F6E69632F66A5
4721:1026F00077322F636F6D6D6F6E2F6D656D2E632C4E
4722:102700007620312E312E322E3520313939382F3086
4723:10271000392F33302031383A35303A303820736829
4724:1027200075616E672045787020240000244865613B
4725:102730006465723A202F70726F6A656374732F72CA
4726:1027400063732F73772F67652F2E2F6E69632F6644
4727:1027500077322F636F6D6D6F6E2F73656E642E63AE
4728:102760002C7620312E312E322E3434203139393826
4729:102770002F31322F32312030303A33333A31382052
4730:10278000736875616E672045787020240000000032
4731:10279000657674526E674600516576744600000097
4732:1027A00051657674505F46004D657674526E67468B
4733:1027B000000000004D516576744600004D5165766D
4734:1027C000505F46005173436F6E495F460000000042
4735:1027D0005173436F6E734600517250726F644600BE
4736:1027E00069736E745463705500000000244865617D
4737:1027F0006465723A202F70726F6A656374732F720A
4738:1028000063732F73772F67652F2E2F6E69632F6683
4739:1028100077322F636F6D6D6F6E2F726563762E63E7
4740:102820002C7620312E312E322E3533203139393964
4741:102830002F30312F31362030323A35353A3433208B
4742:10284000736875616E672045787020240000000071
4743:10285000657674526E6746005165767446000000D6
4744:1028600051657674505F46004D657674526E6746CA
4745:10287000000000004D516576744600004D516576AC
4746:10288000505F46005173436F6E495F460000000081
4747:102890005173436F6E734600517250726F644600FD
4748:1028A000724D616343686B300000000072784672BD
4749:1028B0006D324C670000000072784E6F53744264B2
4750:1028C0000000000072784E6F4D6942640000000005
4751:1028D00072784E6F4A6D4264000000007278436B5C
4752:1028E000446D614600000000727851446D457846A1
4753:1028F00000000000727851446D61460072785144C6
4754:102900004C42644600000000727851446D426446B7
4755:1029100000000000727843726350616400000000A0
4756:1029200072536D51446D614600000000244865619A
4757:102930006465723A202F70726F6A656374732F72C8
4758:1029400063732F73772F67652F2E2F6E69632F6642
4759:1029500077322F636F6D6D6F6E2F6D61632E632CF9
4760:102960007620312E312E322E323220313939382F25
4761:1029700031322F30382030323A33363A3330207308
4762:102980006875616E67204578702024006576745202
4763:102990006E67460051657674460000005165767496
4764:1029A000505F46004D657674526E67460000000029
4765:1029B0004D516576744600004D516576505F460076
4766:1029C0005173436F6E495F46000000005173436FBF
4767:1029D0006E734600517250726F6446006D616354AD
4768:1029E000687265730000000023744D616341544EAA
4769:1029F0000000000023724D616341544E000000004E
4770:102A000072656D4173737274000000006C696E6BC7
4771:102A1000444F574E000000006C696E6B555000002B
4772:102A20000000000000000000000000002448656174
4773:102A30006465723A202F70726F6A656374732F72C7
4774:102A400063732F73772F67652F2E2F6E69632F6641
4775:102A500077322F636F6D6D6F6E2F636B73756D2E95
4776:102A6000632C7620312E312E322E392031393939EE
4777:102A70002F30312F31342030303A30333A3438204F
4778:102A8000736875616E67204578702024000000002F
4779:102A9000657674526E674600516576744600000094
4780:102AA00051657674505F46004D657674526E674688
4781:102AB000000000004D516576744600004D5165766A
4782:102AC000505F46005173436F6E495F46000000003F
4783:102AD0005173436F6E734600517250726F644600BB
4784:102AE00000000000000000000000000050726F6253
4785:102AF00065506879000000006C6E6B41535352546E
4786:102B000000000000000109A400010A1C00010A5095
4787:102B100000010A7C0001105000010AA800010B10FE
4788:102B2000000111FC00010DC000010C6800010C80C7
4789:102B300000010CC400010CEC00010D0C00010D346F
4790:102B4000000111FC00010DC000010DF800010E1084
4791:102B500000010E4000010E6800010E8800010EB059
4792:102B60000000000000010FDC000110080001102C23
4793:102B7000000111FC00011050000110780001110843
4794:102B80000000000000000000000000000001186CC0
4795:102B90000001193C00011A1400011AE400011B4055
4796:102BA00000011C1C00011C4400011D2000011D48E7
4797:102BB00000011EF000011F18000120C0000122B812
4798:102BC0000001254C000124600001254C00012578FE
4799:102BD000000120E8000122907273745F676D6969DB
4800:102BE00000000000000126080001264000012728FF
4801:102BF00000013374000133B4000133CC7365746C8D
4802:102C00006F6F7000000000000000000000013BBC7E
4803:102C100000013BFC00013C8C00013CD000013D3434
4804:102C200000013DC000013DF400013E7C00013F1465
4805:102C300000013FE400014024000140A8000140CC15
4806:102C4000000141DC646F4261736550670000000061
4807:102C500000000000000000000000000073746D61BF
4808:102C6000634C4E4B000000006765746D636C6E6BC7
4809:102C70000000000000014ED800014ED800014B8C2E
4810:102C800000014BD800014C2400014ED87365746DCF
4811:102C90006163616374000000000000000000000038
4812:102CA0000000000000000000000000000000000024
4813:102CB0000000000000000000000000000000000014
4814:102CC0000000000000000000000000000000000103
4815:102CD000000000010000000100C001FC00003FFCFA
4816:102CE00000C00000416C74656F6E204163654E4901
4817:102CF000432056000000000000000000000000001B
4818:102D0000000000000000000000000000416C74653D
4819:102D10006F6E204163654E49432056004242424255
4820:102D2000000000000000000000000000001FFFFC89
4821:102D3000001FFF7C000000000000000000000000F9
4822:102D40000000000000000000000000000060CF0054
4823:102D500000000060CF000000000000000000000044
4824:102D60000000000000000000000000000000000063
4825:102D70000000000000000000000000000000000053
4826:102D80000000000000000000000000000000000043
4827:102D90000000000000000000000000000000000033
4828:102DA0000000000000000000000000030000000020
4829:102DB0000000000100000000000000000000000012
4830:102DC0000000000100000000000000010000000001
4831:102DD00000000000000000000000000000000001F2
4832:102DE00000000001000000000000000000000000E2
4833:102DF00000000000000000000100000021000000B1
4834:102E0000120001400000000000000000200000004F
4835:102E1000120000A0000000001200006012000180FB
4836:102E2000120001E0000000000000000000000000AF
4837:102E30000000000100000000000000000000000091
4838:102E40000000000000000000000000000000000280
4839:102E5000000000000000000000030001000000016D
4840:102E60000003020100000000000000000101010158
4841:102E70000101010000010100010100010001000148
4842:0C2E800001000101000001010000000041
4843:00000001FF
4844/* tg2 firmware v12.4.11 */
diff --git a/firmware/adaptec/starfire_rx.bin.ihex b/firmware/adaptec/starfire_rx.bin.ihex
new file mode 100644
index 000000000000..6b1fae0d18eb
--- /dev/null
+++ b/firmware/adaptec/starfire_rx.bin.ihex
@@ -0,0 +1,53 @@
1:10000000010003DC00000000040004210000008661
2:10001000800000150000180E8100001500006664C5
3:100020001A0040AB00000B06142000110000000075
4:10003000142040220000AAAA14204022000003003D
5:1000400014204022000000001A0040AB00000B14F6
6:1000500014200011000000008300001500000002C1
7:10006000040000210000000000000010000000005B
8:1000700004000421000000870000001000000000C0
9:1000800000000010000000000000801500000000CB
10:100090000000003E00000000000000100000000012
11:1000A0008200001500004000009E8050000000000B
12:1000B000030080150000000086008015000000008D
13:1000C00082000015000080000100001C00000000FC
14:1000D000000050A00000010C4E20D011000060086C
15:1000E0001420D012000040080000F09000007000C2
16:1000F0000000C8B0000030000000404000000000D8
17:10010000001080150000000000A2C1500000400057
18:1001100000A400B000000014000000200000000057
19:100120002500400D0000252500047220000031004C
20:10013000009340700000000000000020000000005C
21:1001400000924460000001842B20C01100000000D8
22:100150000000C42000000540360140180000422D78
23:100160001420001100000000009244600000018390
24:100170003200001F0000003402AC00150000000235
25:1001800000A601100000000842200011000000003D
26:1001900000924060000001030000001E000000000B
27:1001A00000000020000001000000001E0000000010
28:1001B00000924460000000860000408000000000C3
29:1001C0000092C0700000000000924060000001003A
30:1001D0000000C8900000500000A6C1100000000000
31:1001E00000B0C09000000012021C001500000000CA
32:1001F0003200001F0000003400924460000005102F
33:100200004421001100000000420000110000000025
34:1002100083000015000000400092446000000508C3
35:100220004501401800004545008080500000000056
36:10023000622080120000000082000015000008000B
37:100240001520001100000000000000100000000058
38:10025000000000100000000000000010000000007E
39:10026000000000100000000000000010000000006E
40:10027000800000150000EEA4810000150000005F62
41:1002800000000060000000000000412000000000AD
42:1002900000004A000000400000924460000001900D
43:1002A0005601401A000059561400001100000000C9
44:1002B0000093405000000018009300500000001808
45:1002C0003601403A0000002D000643A9000000005E
46:1002D0000000C420000001405601401A0000595699
47:1002E00014000011000000000000001000000000D9
48:1002F0000000001000000000000642A900000000FD
49:1003000000024420000001835601401A00005956A3
50:1003100082000015000020001520001100000000E0
51:1003200082000015000000101520001100000000E0
52:1003300082000015000000101520001100000000D0
53:00000001FF
diff --git a/firmware/adaptec/starfire_tx.bin.ihex b/firmware/adaptec/starfire_tx.bin.ihex
new file mode 100644
index 000000000000..6b1fae0d18eb
--- /dev/null
+++ b/firmware/adaptec/starfire_tx.bin.ihex
@@ -0,0 +1,53 @@
1:10000000010003DC00000000040004210000008661
2:10001000800000150000180E8100001500006664C5
3:100020001A0040AB00000B06142000110000000075
4:10003000142040220000AAAA14204022000003003D
5:1000400014204022000000001A0040AB00000B14F6
6:1000500014200011000000008300001500000002C1
7:10006000040000210000000000000010000000005B
8:1000700004000421000000870000001000000000C0
9:1000800000000010000000000000801500000000CB
10:100090000000003E00000000000000100000000012
11:1000A0008200001500004000009E8050000000000B
12:1000B000030080150000000086008015000000008D
13:1000C00082000015000080000100001C00000000FC
14:1000D000000050A00000010C4E20D011000060086C
15:1000E0001420D012000040080000F09000007000C2
16:1000F0000000C8B0000030000000404000000000D8
17:10010000001080150000000000A2C1500000400057
18:1001100000A400B000000014000000200000000057
19:100120002500400D0000252500047220000031004C
20:10013000009340700000000000000020000000005C
21:1001400000924460000001842B20C01100000000D8
22:100150000000C42000000540360140180000422D78
23:100160001420001100000000009244600000018390
24:100170003200001F0000003402AC00150000000235
25:1001800000A601100000000842200011000000003D
26:1001900000924060000001030000001E000000000B
27:1001A00000000020000001000000001E0000000010
28:1001B00000924460000000860000408000000000C3
29:1001C0000092C0700000000000924060000001003A
30:1001D0000000C8900000500000A6C1100000000000
31:1001E00000B0C09000000012021C001500000000CA
32:1001F0003200001F0000003400924460000005102F
33:100200004421001100000000420000110000000025
34:1002100083000015000000400092446000000508C3
35:100220004501401800004545008080500000000056
36:10023000622080120000000082000015000008000B
37:100240001520001100000000000000100000000058
38:10025000000000100000000000000010000000007E
39:10026000000000100000000000000010000000006E
40:10027000800000150000EEA4810000150000005F62
41:1002800000000060000000000000412000000000AD
42:1002900000004A000000400000924460000001900D
43:1002A0005601401A000059561400001100000000C9
44:1002B0000093405000000018009300500000001808
45:1002C0003601403A0000002D000643A9000000005E
46:1002D0000000C420000001405601401A0000595699
47:1002E00014000011000000000000001000000000D9
48:1002F0000000001000000000000642A900000000FD
49:1003000000024420000001835601401A00005956A3
50:1003100082000015000020001520001100000000E0
51:1003200082000015000000101520001100000000E0
52:1003300082000015000000101520001100000000D0
53:00000001FF
diff --git a/firmware/tigon/tg3.bin.ihex b/firmware/tigon/tg3.bin.ihex
new file mode 100644
index 000000000000..d842d7cc91b5
--- /dev/null
+++ b/firmware/tigon/tg3.bin.ihex
@@ -0,0 +1,175 @@
1:10000000000000000800000000000A80000000005E
2:1000100010000003000000000000000D0000000DB3
3:100020003C1D080037BD3FFC03A0F0213C10080038
4:10003000261000000E000018000000000000000D57
5:100040003C1D080037BD3FFC03A0F0213C10080018
6:10005000261000340E00021C000000000000000DFD
7:1000600000000000000000000000000027BDFFE0CD
8:100070003C1CC000AFBF0018AF80680C0E00004CE5
9:10008000241B210597850000978700029782002C8A
10:100090009783002E3C040800248409C0AFA00014FC
11:1000A000000214000062182500052C00AFA3001008
12:1000B0008F86001000E528250E000060240701024D
13:1000C0003C02AC00344201003C03AC01346301004B
14:1000D000AF8204903C02FFFFAF820494AF83049888
15:1000E000AF82049C24020001AF825CE00E00003F5E
16:1000F000AF825D000E000140000000008FBF0018BD
17:1001000003E0000827BD00202402FFFFAF82540453
18:100110008F83540034630400AF835400AF825404CF
19:100120003C02080024420034AF82541C03E0000863
20:10013000AF80540000000000000000003C020800F6
21:10014000344230003C030800346330003C040800B3
22:10015000348437FF3C010800AC220A6424020040CA
23:100160003C010800AC220A683C010800AC200A608F
24:10017000AC600000246300040083102B5040FFFD9E
25:10018000AC60000003E0000800000000008048218F
26:100190008FAA00103C0208008C420A603C04080050
27:1001A0008C840A688FAB0014244300010044102B98
28:1001B0003C010800AC230A60144000030000402109
29:1001C0003C010800AC200A603C0208008C420A6036
30:1001D0003C0308008C630A64912400000002114073
31:1001E000004310210048102125080001A044000010
32:1001F000290200081440FFF4252900013C020800F0
33:100200008C420A603C0308008C630A648F84680C8B
34:100210000002114000431021AC440008AC45000C22
35:10022000AC460010AC470014AC4A001803E00008CC
36:10023000AC4B001C000000000000000000000000AB
37:1002400000000000000000000000000000000000AE
38:10025000000000000000000000000000000000009E
39:10026000000000000000000000000000000000008E
40:10027000000000000000000000000000000000007E
41:10028000000000000000000000000000000000006E
42:10029000000000000000000000000000000000005E
43:1002A000000000000000000000000000000000004E
44:1002B000000000000000000000000000000000003E
45:1002C000000000000000000000000000000000002E
46:1002D000000000000000000000000000000000001E
47:1002E000000000000000000000000000000000000E
48:1002F00000000000000000000000000000000000FE
49:1003000000000000000000000000000002000008E3
50:10031000000000000A0001E33C0A00010A0001E3BA
51:100320003C0A00020A0001E3000000000A0001E3A9
52:10033000000000000A0001E3000000000A0001E3E1
53:10034000000000000A0001E3000000000A0001E3D1
54:10035000000000000A0001E3000000000A0001E3C1
55:10036000000000000A0001E3000000000A0001E3B1
56:100370003C0A00070A0001E33C0A00080A0001E306
57:100380003C0A00090A0001E3000000000A0001E342
58:10039000000000000A0001E33C0A000B0A0001E330
59:1003A0003C0A000C0A0001E33C0A000D0A0001E3CC
60:1003B000000000000A0001E3000000000A0001E361
61:1003C0003C0A000E0A0001E3000000000A0001E3FD
62:1003D000000000000A0001E3000000000A0001E341
63:1003E000000000000A0001E3000000000A0001E331
64:1003F000000000000A0001E3000000000A0001E321
65:10040000000000000A0001E33C0A00130A0001E3B7
66:100410003C0A001400000000000000000000000082
67:1004200000000000000000000000000000000000CC
68:1004300000000000000000000000000000000000BC
69:1004400000000000000000000000000000000000AC
70:10045000000000000000000000000000000000009C
71:10046000000000000000000000000000000000008C
72:10047000000000000000000000000000000000007C
73:10048000000000000000000000000000000000006C
74:10049000000000000000000000000000000000005C
75:1004A000000000000000000000000000000000004C
76:1004B000000000000000000000000000000000003C
77:1004C000000000000000000000000000000000002C
78:1004D000000000000000000000000000000000001C
79:1004E000000000000000000000000000000000000C
80:1004F00000000000000000000000000000000000FC
81:1005000000000000000000000000000027BDFFE028
82:100510000000182100001021AFBF0018AFB1001477
83:10052000AFB000103C01080000220821AC200A7086
84:100530003C01080000220821AC200A743C0108009C
85:1005400000220821AC200A78246300011860FFF51E
86:100550002442000C241100018F9068103202000424
87:1005600014400005240400013C0208008C420A7873
88:1005700018400003000020210E000182000000004E
89:100580003202000110400003000000000E0001696B
90:10059000000000000A000153AF9150288FBF0018DF
91:1005A0008FB100148FB0001003E0000827BD0020B9
92:1005B0003C0508008CA50A703C0608008CC60A8021
93:1005C0003C0708008CE70A7827BDFFE03C040800E0
94:1005D000248409D0AFBF0018AFA000100E00006047
95:1005E000AFA000140E00017B000020218FBF001877
96:1005F00003E0000827BD0020240200018F8368105B
97:1006000000821004000210270062182403E0000892
98:10061000AF83681027BDFFD8AFBF00241080002E25
99:10062000AFB000208F825CECAFA200188F825CEC30
100:100630003C10080026100A78AFA2001C340280008B
101:10064000AF825CEC8E020000184000160000000033
102:100650003C02080094420A748FA3001C000221C0CF
103:10066000AC8300048FA2001C3C0108000E000201B4
104:10067000AC220A7410400005000000008E02000049
105:10068000244200010A0001DFAE0200003C02080023
106:100690008C420A7000021C02000321C00A0001C53E
107:1006A000AFA2001C0E000201000000001040001F5D
108:1006B000000000008E0200008FA3001C24420001F5
109:1006C0003C010800AC230A703C010800AC230A740A
110:1006D0000A0001DFAE0200003C10080026100A7874
111:1006E0008E02000018400028000000000E000201E9
112:1006F0000000000014400024000000008E020000F2
113:100700003C0308008C630A702442FFFFAFA3001C67
114:1007100018400006AE02000000031402000221C0CF
115:100720008C8200043C010800AC220A7097A2001ED3
116:100730002442FF002C4203001440000B240240001E
117:100740003C040800248409DCAFA00010AFA0001412
118:100750008FA6001C240500080E0000600000382150
119:100760000A0001DF00000000AF825CF83C020800D4
120:100770008C420A408FA3001C24420001AF835CF826
121:100780003C010800AC220A408FBF00248FB000203B
122:1007900003E0000827BD002827BDFFE03C04080057
123:1007A000248409E8000028210000302100003821BD
124:1007B000AFBF0018AFA000100E000060AFA0001483
125:1007C0008FBF001803E0000827BD00208F82680C4F
126:1007D0008F85680C000218270003182B00031823CC
127:1007E000004310240044102100A2282B10A0000672
128:1007F00000000000004018218F82680C0043102B7D
129:100800001440FFFD0000000003E0000800000000AD
130:100810003C0408008C8400003C0308008C630A4000
131:100820000064102B54400002008310230064102346
132:100830002C42000803E000083842000127BDFFE019
133:10084000008028213C04080024840A000000302194
134:1008500000003821AFBF0018AFA000100E000060EC
135:10086000AFA000140A000216000000008FBF00189D
136:1008700003E0000827BD00200000000027BDFFE0C6
137:100880003C1CC000AFBF00180E00004CAF80680CCD
138:100890003C04080024840A10038028210000302131
139:1008A00000003821AFA000100E000060AFA00014BF
140:1008B0002402FFFFAF8254043C0200AA0E0002345F
141:1008C000AF8254348FBF001803E0000827BD00201A
142:1008D00000000000000000000000000027BDFFE84D
143:1008E000AFB0001024100001AFBF00143C01C003E2
144:1008F000AC2000008F8268103042200010400003BE
145:10090000000000000E000246000000000A00023A4B
146:10091000AF9054288FBF00148FB0001003E0000880
147:1009200027BD001827BDFFF88F845D0C3C0200FF37
148:100930003C0308008C630A503442FFF80082102404
149:100940001043001E3C0500FF34A5FFF83C06C00321
150:100950003C074000008518248C6200103C01080010
151:10096000AC230A50304200081040000500871025D3
152:100970008CC2000024420001ACC200000087102598
153:10098000AF825D0C8FA2000024420001AFA20000E4
154:100990008FA200008FA2000024420001AFA200003D
155:1009A0008FA200008F845D0C3C0308008C630A500A
156:1009B000008510241443FFE80085182427BD000893
157:1009C00003E000080000000000000000353730316F
158:1009D000726C734100000000000000005377457600
159:1009E000656E743000000000726C704576656E7440
160:1009F00031000000556E6B6E45766E74000000008D
161:100A0000000000000000000000000000666174614A
162:100A10006C45727200000000000000004D61696EBC
163:100A2000437075420000000000000000000000005C
164:100A300000000000000000000000000000000000B6
165:100A400000000000000000000000000000000000A6
166:100A50000000000000000000000000000000000096
167:0C0A60000000000000000000000000008A
168:00000001FF
169 * Firmware is:
170 * Derived from proprietary unpublished source code,
171 * Copyright (C) 2000-2003 Broadcom Corporation.
172 *
173 * Permission is hereby granted for the distribution of this firmware
174 * data in hexadecimal or equivalent format, provided this copyright
175 * notice is accompanying it.
diff --git a/firmware/tigon/tg3_tso.bin.ihex b/firmware/tigon/tg3_tso.bin.ihex
new file mode 100644
index 000000000000..f10c4ef90513
--- /dev/null
+++ b/firmware/tigon/tg3_tso.bin.ihex
@@ -0,0 +1,446 @@
1:100000000106000008000000000024140E00000398
2:100010000000000008001B24000000001000000386
3:10002000000000000000000D0000000D3C1D080055
4:1000300037BD400003A0F0213C100800261000004E
5:100040000E000010000000000000000D27BDFFE0C2
6:100050003C04FEFEAFBF00180E0005D83484000239
7:100060000E000668000000003C03080090631B6857
8:10007000240200023C04080024841AAC1462000329
9:10008000240500013C04080024841AA0240600066C
10:1000900000003821AFA000100E00067CAFA00014B5
11:1000A0008F625C5034420001AF625C508F625C90A2
12:1000B00034420001AF625C902402FFFF0E00003466
13:1000C000AF6254048FBF001803E0000827BD002072
14:1000D00000000000000000000000000027BDFFE05D
15:1000E000AFBF001CAFB20018AFB100140E00005B30
16:1000F000AFB0001024120002241100018F7068209C
17:100100003202010010400003000000000E0000BB9E
18:10011000000000008F7068203202200010400004B0
19:10012000320200010E0001F024040001320200013D
20:1001300010400003000000000E0000A300000000BB
21:100140003C02080090421B9814520003000000007B
22:100150000E0004C0000000000A00003CAF715028EF
23:100160008FBF001C8FB200188FB100148FB0001029
24:1001700003E0000827BD002027BDFFE03C04080085
25:1001800024841AC0000028210000302100003821FA
26:10019000AFBF0018AFA000100E00067CAFA0001487
27:1001A0003C040800248423D8A48000003C010800FB
28:1001B000A0201B983C010800AC201B9C3C010800BF
29:1001C000AC201BA03C010800AC201BA43C01080093
30:1001D000AC201BAC3C010800AC201BB83C01080063
31:1001E000AC201BBC8F6244343C010800AC221B884D
32:1001F0008F6244383C010800AC221B8C8F62441093
33:10020000AC80F7A83C010800AC201B843C0108002E
34:10021000AC2023E03C010800AC2023C83C010800CE
35:10022000AC2023CC3C010800AC2024003C01080099
36:10023000AC221B908F6200682403000700021702A3
37:1002400010430005000000008F62006800021702E2
38:1002500014400004240200013C0108000A00009739
39:10026000AC20240CAC8200343C04080024841ACC5A
40:100270003C0508008CA5240C00003021000038212A
41:10028000AFA000100E00067CAFA000148FBF0018B6
42:1002900003E0000827BD002027BDFFE03C04080064
43:1002A00024841AD8000028210000302100003821C1
44:1002B000AFBF0018AFA000100E00067CAFA0001466
45:1002C0000E00005B000000000E0000B400002021C2
46:1002D0008FBF001803E0000827BD002024020001A2
47:1002E0008F63682000821004000210270062182427
48:1002F00003E00008AF63682027BDFFD0AFBF002C2C
49:10030000AFB60028AFB50024AFB40020AFB3001CD7
50:10031000AFB20018AFB10014AFB000108F675C5CD3
51:100320003C03080024631BBC8C62000014470005DA
52:100330003C0200FF3C02080090421B981440011947
53:100340003C0200FF3442FFF800E28824AC67000062
54:1003500000111902306300FF30E20003000211C0F7
55:100360000062282500A04021000716023C03080077
56:1003700090631B983044000F1460003600804821C1
57:10038000240200013C010800A0221B980005110076
58:10039000008210253C010800AC201B9C3C01080099
59:1003A000AC201BA03C010800AC201BA43C010800B1
60:1003B000AC201BAC3C010800AC201BB83C01080081
61:1003C000AC201BB03C010800AC201BB43C01080071
62:1003D000A42223D89622000C30437FFF3C01080062
63:1003E000A4222410304280003C010800A4231BC634
64:1003F00010400005240200013C010800AC2223F457
65:100400000A0001022406003E240600363C010800D2
66:10041000AC2023F49622000A3C03080094631BC618
67:100420003C010800AC2023F03C010800AC2023F87C
68:10043000000213020002108000C210210062182185
69:100440003C010800A42223D03C0108000A00011549
70:10045000A4231B969622000C3C010800A42223EC46
71:100460003C04080024841B9C8C82000000021100C4
72:100470003C01080000220821AC311BC88C8200001E
73:10048000000211003C01080000220821AC271BCC0F
74:100490008C82000025030001306601FF000211007C
75:1004A0003C01080000220821AC261BD08C820000F1
76:1004B000000211003C01080000220821AC291BD4D5
77:1004C000962300083C0208008C421BAC0043282104
78:1004D0003C010800AC251BAC9622000A3042000407
79:1004E00014400018000611008F630C143063000FD5
80:1004F0002C6200021440000B3C02C0008F630C14FD
81:100500003C0208008C421B403063000F2442000173
82:100510003C010800AC221B402C6200021040FFF797
83:100520003C02C00000E21825AF635C5C8F625C5047
84:100530003042000210400014000000000A00014791
85:10054000000000003C0308008C631B803C04080092
86:1005500094841B94012210253C010800A42223DA74
87:10056000240200013C010800AC221BB824630001F6
88:100570000085202A3C01080010800003AC231B806A
89:100580003C010800A4251B943C06080024C61B9CC3
90:100590008CC2000024420001ACC20000284200804E
91:1005A00014400005000000000E000656240400025E
92:1005B0000A0001E6000000003C0208008C421BB863
93:1005C00010400078240200013C05080090A51B980B
94:1005D00014A20072000000003C15080096B51B969E
95:1005E0003C0408008C841BAC32A3FFFF0083102A5C
96:1005F0001440006C000000001483000300000000A1
97:100600003C010800AC2523F01060005C0000902144
98:1006100024D600040060A02124D300148EC2000060
99:10062000000281003C110800023088210E000625DE
100:100630008E311BC80040282110A00054000000008B
101:100640009628000A31020040104000052407180CCB
102:100650008E22000C2407188C00021400ACA2001893
103:100660003C030800007018218C631BD03C0208007A
104:10067000005010218C421BD400031D000002140006
105:1006800000621825ACA300148EC300049622000853
106:10069000004320233242FFFF3083FFFF004310213D
107:1006A0000282102A1440000202B23023008030215E
108:1006B0008E62000030C4FFFF00441021AE620000D3
109:1006C0008E220000ACA200008E2200048E63FFF494
110:1006D00000431021ACA20004A4A6000E8E62FFF419
111:1006E00000441021AE62FFF4962300080043102A54
112:1006F00014400005024690218E62FFF0AE60FFF4C8
113:1007000024420001AE62FFF0ACA000083242FFFFBD
114:1007100014540008240203053102008054400001F3
115:1007200034E7001024020905A4A2000C0A0001CB42
116:1007300034E70020A4A2000C3C0208008C4223F005
117:10074000104000033C024B650A0001D3344276544A
118:100750003C02B49A344289ABACA2001C30E2FFFFE9
119:10076000ACA200100E0005A200A020213242FFFF23
120:100770000054102B1440FFA90000000024020002C6
121:100780003C0108000A0001E6A0221B988EC2083C2A
122:10079000244200010A0001E6AEC2083C0E0004C07B
123:1007A000000000008FBF002C8FB600288FB50024FA
124:1007B0008FB400208FB3001C8FB200188FB10014CB
125:1007C0008FB0001003E0000827BD003027BDFFD028
126:1007D000AFBF0028AFB30024AFB20020AFB1001C00
127:1007E000AFB000188F725C9C3C0200FF3442FFF8EF
128:1007F0003C07080024E71BB4024288249623000E1D
129:100800008CE2000000431021ACE200008E220010B8
130:100810003042002014400011008098210E00063B59
131:10082000022020213C02C00002421825AF635C9CDC
132:100830008F625C90304200021040011E00000000F8
133:10084000AF635C9C8F625C903042000210400119E3
134:10085000000000000A00020D000000008E240008C5
135:100860008E23001400041402000231C0000315029C
136:10087000304201FF2442FFFF3042007F0003194253
137:1008800030637800000211002442400000624821D9
138:100890009522000A3084FFFF30420008104000B06B
139:1008A000000429C03C0208008C42240014400024AB
140:1008B00024C5000894C200143C010800A42223D0DF
141:1008C0008CC40010000414023C010800A42223D2AE
142:1008D0003C010800A42423D494C2000E3083FFFFFF
143:1008E000004310233C010800AC22240894C2001AE3
144:1008F0003C010800AC2624003C010800AC32240472
145:100900003C010800AC2223FC3C02C0000242182536
146:10091000AF635C9C8F625C9030420002104000E547
147:1009200000000000AF635C9C8F625C90304200026C
148:10093000104000E0000000000A0002460000000035
149:1009400094C2000E3C030800946323D40043402368
150:100950003103FFFF2C6200081040001C0000000063
151:1009600094C200142442002800A22821000310424F
152:100970001840000B0000202124E6084800403821E0
153:1009800094A300008CC200002484000100431021C5
154:10099000ACC200000087102A1440FFF924A5000211
155:1009A000310200011040001F3C0240003C040800DE
156:1009B000248423FCA0A0000194A300008C820000EA
157:1009C000004310210A000285AC8200008F6268009B
158:1009D0003C030010004310241040000900000000F8
159:1009E00094C2001A3C0308008C6323FC00431021CE
160:1009F0003C010800AC2223FC0A0002863C024000B5
161:100A000094C2001A94C4001C3C0308008C6323FCAD
162:100A100000441023006218213C010800AC2323FC91
163:100A20003C02400002421825AF635C9C8F625C90E0
164:100A3000304200021440FFFC000000009522000A32
165:100A4000304200101040009B000000003C030800F2
166:100A5000946323D43C07080024E724008CE40000BE
167:100A60008F62680024630030008328213C0300105B
168:100A7000004310241440000A0000000094A2000467
169:100A80003C0408008C8424083C0308008C6323FC8D
170:100A900000441023006218213C010800AC2323FC11
171:100AA0003C0408008C8423FC00041C023082FFFFFD
172:100AB000006220210004140200822021000410277B
173:100AC000A4A200063C0308008C6324043C0200FF3F
174:100AD0003442FFF8006288249622000824050001B1
175:100AE00024034000000231C000801021A4C2001A7B
176:100AF000A4C0001CACE000003C010800AC251B6059
177:100B0000AF635CB88F625CB03042000210400003FB
178:100B1000000000003C010800AC201B608E22000891
179:100B2000AF625CB88F625CB03042000210400003DC
180:100B3000000000003C010800AC201B603C020800E3
181:100B40008C421B601040FFEC000000003C040800D9
182:100B50000E00063B8C8424040A00032A00000000D7
183:100B60003C03080090631B982402000214620003F7
184:100B70003C034B650A0002E1000080218E22001C2C
185:100B80003463765410430002241000022410000144
186:100B900000C020210E000350020030212402000377
187:100BA0003C010800A0221B98240200021202000A45
188:100BB000240200013C0308008C6323F0106200064D
189:100BC000000000003C020800944223D800021400F8
190:100BD0000A00031FAE2200143C040800248423DA18
191:100BE0009482000000021400AE2200143C020800AF
192:100BF0008C421BBC3C03C0003C010800A0201B9899
193:100C000000431025AF625C5C8F625C503042000292
194:100C100010400009000000002484F7E28C820000EC
195:100C200000431025AF625C5C8F625C503042000272
196:100C30001440FFFA000000003C02080024421B841C
197:100C40008C43000024630001AC4300008F630C144C
198:100C50003063000F2C6200021440000C3C02400084
199:100C60008F630C143C0208008C421B403063000F61
200:100C7000244200013C010800AC221B402C6200020F
201:100C80001040FFF7000000003C024000024218251F
202:100C9000AF635C9C8F625C90304200021440FFFCAA
203:100CA0000000000012600003000000000E0004C0FD
204:100CB000000000008FBF00288FB300248FB20020F7
205:100CC0008FB1001C8FB0001803E0000827BD003072
206:100CD0008F6344503C04080024841B888C820000ED
207:100CE00000031C020043102B144000073C0380004B
208:100CF0008C8400048F62445000021C020083102B7D
209:100D00001040FFFC3C038000AF6344448F624444C6
210:100D1000004310241440FFFD000000008F6244488F
211:100D200003E000083042FFFF3C0240000082202523
212:100D3000AF645C388F625C30304200021440FFFCCC
213:100D40000000000003E000080000000027BDFFE0F5
214:100D50000080582114C00011256E00083C020800D4
215:100D60008C4223F410400007240200163C010800C6
216:100D7000A42223D22402002A3C0108000A000364B2
217:100D8000A42223D48D670010000714023C01080040
218:100D9000A42223D23C010800A42723D43C04080049
219:100DA000948423D43C030800946323D295CF000697
220:100DB0003C020800944223D00083202301E2C02398
221:100DC0003065FFFF24A2002801C248213082FFFFC6
222:100DD00014C0001A012260219582000C3042003FAD
223:100DE0003C010800A42223D69582000495830006C6
224:100DF0003C010800AC2023E43C010800AC2023E8BF
225:100E000000021400004310253C010800AC221BC066
226:100E1000952200043C010800A4221BC49523000273
227:100E200001E510230043102A1040001024020001A5
228:100E30003C0108000A000398AC2223F83C03080098
229:100E40008C6323E83C02080094421BC40043102139
230:100E5000A52200043C02080094421BC0A5820004A5
231:100E60003C0208008C421BC0A58200063C02080020
232:100E70008C4223F03C0D08008DAD23E43C0A0800B1
233:100E8000144000E58D4A23E83C02080094421BC44C
234:100E9000004A18213063FFFF0062182B2402000271
235:100EA00010C2000D014350233C020800944223D697
236:100EB0003042000910400008000000009582000C3C
237:100EC0003042FFF6A582000C3C020800944223D673
238:100ED0003042000901A268233C0208008C4223F83A
239:100EE0001040004A012038213C020800944223D2DD
240:100EF00000004021A520000A01E21023A5220002E3
241:100F00003082FFFF0002104218400008000030212C
242:100F10000040182194E200002508000100C23021A1
243:100F20000103102A1440FFFB24E7000200061C0204
244:100F300030C2FFFF006230210006140200C23021DF
245:100F400000C0282100061027A522000A0000302139
246:100F50002527000C0000402194E200002508000134
247:100F600000C230212D0200041440FFFB24E70002E0
248:100F70009522000200004021912300090044202313
249:100F8000018038213082FFFFA4E0001000621821A8
250:100F9000000210421840001000C3302100404821D8
251:100FA00094E2000024E7000200C2302130E2007F1A
252:100FB00014400006250800018D6300003C02007FFC
253:100FC0003442FF8000625824256700080109102A76
254:100FD0001440FFF3000000003082000110400005C3
255:100FE00000061C02A0E0000194E2000000C23021D3
256:100FF00000061C0230C2FFFF00623021000614020E
257:1010000000C230210A00047D30C6FFFF2402000226
258:1010100014C20081000000003C0208008C42240C35
259:1010200014400007000000003C020800944223D254
260:101030009523000201E210231062007700000000F7
261:101040003C020800944223D201E21023A5220002B0
262:101050003C0208008C42240C1040001A31E3FFFFD0
263:101060008DC700103C02080094421B9600E040210E
264:1010700000072C0200AA20210043102300823823FD
265:101080000007240230E2FFFF00823821000710270A
266:10109000A522000A3102FFFF3C040800948423D4F7
267:1010A0000045302300E0282100641823006D18213A
268:1010B00000C3302100061C0230C2FFFF0A00047D7D
269:1010C0000062302101203821000040213082FFFFE2
270:1010D0000002104218400008000030210040182192
271:1010E00094E200002508000100C230210103102A0B
272:1010F0001440FFFB24E7000200061C0230C2FFFF81
273:10110000006230210006140200C2302100C02821F4
274:1011100000061027A522000A000030212527000C18
275:101120000000402194E200002508000100C23021A7
276:101130002D0200041440FFFB24E700029522000268
277:101140000000402191230009004420230180382120
278:101150003082FFFFA4E000103C040800948423D4F4
279:101160000062182100C3302100061C0230C2FFFFBC
280:101170000062302100061C023C020800944223D089
281:1011800000C348210044102300021FC20043102165
282:1011900000021043184000100000302100402021C0
283:1011A00094E2000024E7000200C2302130E2007F18
284:1011B00014400006250800018D6300003C02007FFA
285:1011C0003442FF8000625824256700080104102A79
286:1011D0001440FFF3000000003C020800944223EC9E
287:1011E00000C230213122FFFF00C2302100061C0264
288:1011F00030C2FFFF006230210006140200C230211D
289:1012000000C0402100061027A5820010ADC00014C8
290:101210000A00049DADC000008DC7001000E0402111
291:101220001140000700072C0200AA3021000614021A
292:1012300030C3FFFF004330210006140200C2282102
293:1012400000051027A522000A3C030800946323D45C
294:101250003102FFFF01E210210043302300CD302195
295:1012600000061C0230C2FFFF00623021000614029B
296:1012700000C2302100C0402100061027A5820010C6
297:101280003102FFFF00051C0000431025ADC2001015
298:101290003C0208008C4223F4104000052DE205EBCF
299:1012A0001440000225E2FFF234028870A5C2003427
300:1012B0003C030800246323E88C6200002442000100
301:1012C000AC6200003C0408008C8423E43C0208006B
302:1012D0008C421BC03303FFFF0083202100431821F1
303:1012E0000062102B3C010800AC2423E410400003F2
304:1012F0002482FFFF3C010800AC2223E43C010800EB
305:10130000AC231BC003E0000827BD002027BDFFB8A9
306:101310003C05080024A51B96AFBF0044AFBE0040AB
307:10132000AFB7003CAFB60038AFB50034AFB4003053
308:10133000AFB3002CAFB20028AFB10024AFB0002093
309:1013400094A900003C020800944223D03C0308000A
310:101350008C631BB03C0408008C841BAC012210235E
311:101360000064182AA7A9001E106000BEA7A20016DC
312:1013700024BE002297B6001E24B3001A24B700161C
313:101380008FC2000014400008000000008FC2FFF868
314:1013900097A300168FC4FFF4004310210082202A77
315:1013A000148000B00000000097D5081832A2FFFF9B
316:1013B000104000A3000090210040A02100008821DF
317:1013C0000E000625000000000040302114C0000778
318:1013D000000000003C0208008C4223DC2442000193
319:1013E0003C0108000A000596AC2223DC3C100800F2
320:1013F000021180218E101BC89608000A310200409D
321:10140000104000052407180C8E02000C2407188CCD
322:1014100000021400ACC200183102008054400001E8
323:1014200034E700103C020800005110218C421BD010
324:101430003C030800007118218C631BD400021500C6
325:1014400000031C0000431025ACC2001496040008E1
326:101450003242FFFF008210210282102A1440000253
327:1014600002B22823008028218E020000024590212C
328:10147000ACC200008E02000400C020212631001002
329:10148000AC82000430E2FFFFAC800008A485000EAF
330:10149000AC820010240203050E0005A2A482000CF9
331:1014A0003242FFFF0054102B1440FFC53242FFFFB1
332:1014B0000A00058E000000008E6200008E63FFFCB3
333:1014C0000043102A10400067000000008E62FFF009
334:1014D000000289003C100800021180210E00062540
335:1014E0008E101BC80040302114C000050000000011
336:1014F0008E62082C244200010A000596AE62082C78
337:101500009608000A31020040104000052407180C1C
338:101510008E02000C2407188C00021400ACC20018C4
339:101520003C020800005110218C421BD03C030800F3
340:10153000007118218C631BD40002150000031C00ED
341:1015400000431025ACC200148E63FFF4960200081D
342:10155000004320233242FFFF3083FFFF004310216E
343:1015600002C2102A104000030080282197A9001E03
344:10157000013228238E62000030A4FFFF00441021B6
345:10158000AE620000A4C5000E8E020000ACC20000D6
346:101590008E0200048E63FFF400431021ACC20004ED
347:1015A0008E63FFF496020008006418210062102A7E
348:1015B00014400006024590218E62FFF0AE60FFF4F9
349:1015C000244200010A000571AE62FFF0AE63FFF431
350:1015D000ACC000083242FFFF105600033102000485
351:1015E000104000062402030531020080544000012F
352:1015F00034E7001034E7002024020905A4C2000CDF
353:101600008EE300008EE20004146200073C02B49AEC
354:101610008EE208605440000134E704003C024B6550
355:101620000A00058834427654344289ABACC2001CAF
356:1016300030E2FFFFACC200100E0005A200C0202166
357:101640003242FFFF0056102B1440FF9B00000000A9
358:101650008E6200008E63FFFC0043102A1440FF4896
359:10166000000000008FBF00448FBE00408FB7003CD9
360:101670008FB600388FB500348FB400308FB3002C94
361:101680008FB200288FB100248FB0002003E0000843
362:1016900027BD004827BDFFE8AFBF0014AFB0001062
363:1016A0008F6244508F6344100A0005B1008080218E
364:1016B0008F626820304220001040000300000000CC
365:1016C0000E0001F0000020218F6244508F6344100F
366:1016D0003042FFFF0043102B1440FFF500000000D4
367:1016E0008F630C143063000F2C6200021440000B57
368:1016F000000000008F630C143C0208008C421B4069
369:101700003063000F244200013C010800AC221B4062
370:101710002C6200021040FFF700000000AF705C1860
371:101720008F625C103042000210400009000000008F
372:101730008F626820304220001040FFF80000000057
373:101740000E0001F0000020210A0005C40000000086
374:101750008FBF00148FB0001003E0000827BD0018F1
375:1017600000000000000000000000000027BDFFE8AE
376:101770003C1BC000AFBF0014AFB00010AF60680CDE
377:101780008F62680434420082AF6268048F63400055
378:1017900024020B503C010800AC221B5424020B789D
379:1017A0003C010800AC221B6434630002AF634000BC
380:1017B0000E000605008080213C010800A0221B6865
381:1017C000304200FF24030002144300050000000023
382:1017D0003C0208008C421B540A0005F8AC5000C0C3
383:1017E0003C0208008C421B54AC5000BC8F62443455
384:1017F0008F6344388F6444103C010800AC221B5CAA
385:101800003C010800AC231B6C3C010800AC241B58B5
386:101810008FBF00148FB0001003E0000827BD001830
387:101820003C0408008C8700003C03AA553463AA5589
388:101830003C06C003AC8300008CC2000014430007C8
389:10184000240500023C0355AA346355AAAC8300006A
390:101850008CC2000050430001240500013C02080036
391:10186000AC47000003E0000800A0102127BDFFF8EE
392:1018700018800009000028218F63680C8F62680CB3
393:101880001043FFFE0000000024A5000100A4102A60
394:101890001440FFF90000000003E0000827BD000825
395:1018A0008F6344503C0208008C421B5C00031C0206
396:1018B0000043102B144000083C0380003C04080047
397:1018C0008C841B6C8F62445000021C020083102B1E
398:1018D0001040FFFC3C038000AF6344448F624444EB
399:1018E000004310241440FFFD000000008F624448B4
400:1018F00003E000083042FFFF3082FFFF2442E00097
401:101900002C422001144000033C0240000A0006481B
402:101910002402FFFF00822025AF645C388F625C30B8
403:10192000304200021440FFFC0000102103E00008D8
404:10193000000000008F6244503C0308008C631B5879
405:101940000A0006513042FFFF8F6244503042FFFFD1
406:101950000043102B1440FFFC0000000003E00008CF
407:101960000000000027BDFFE0008028213C040800A3
408:1019700024841AF00000302100003821AFBF001885
409:10198000AFA000100E00067CAFA000140A00066095
410:10199000000000008FBF001803E0000827BD0020F2
411:1019A0000000000000000000000000003C020800F1
412:1019B000344230003C030800346330003C0408002B
413:1019C000348437FF3C010800AC221B742402004021
414:1019D0003C010800AC221B783C010800AC201B70C5
415:1019E000AC600000246300040083102B5040FFFD16
416:1019F000AC60000003E00008000000000080482107
417:101A00008FAA00103C0208008C421B703C040800A6
418:101A10008C841B788FAB0014244300010044102BEE
419:101A20003C010800AC231B7014400003000040215F
420:101A30003C010800AC201B703C0208008C421B706B
421:101A40003C0308008C631B749124000000021140C9
422:101A5000004310210048102125080001A044000087
423:101A6000290200081440FFF4252900013C02080067
424:101A70008C421B703C0308008C631B748F64680CE1
425:101A80000002114000431021AC440008AC45000C9A
426:101A9000AC460010AC470014AC4A001803E0000844
427:101AA000AC4B001C00000000000000004D61696E9E
428:101AB00043707542000000004D61696E43707541CE
429:101AC00000000000000000000000000073746B6F55
430:101AD00066666C64496E000073746B6F66662A2AD2
431:101AE0000000000053774576656E743000000000FA
432:101AF000000000000000000000000000666174614A
433:101B00006C45727200000000000000000000000040
434:101B100000000000000000000000000000000000C5
435:101B200000000000000000000000000000000000B5
436:101B300073746B6F66666C645F76312E362E300080
437:101B40000000000000000000000000000000000095
438:0C1B500000000000000000000000000089
439:00000001FF
440 * Firmware is:
441 * Derived from proprietary unpublished source code,
442 * Copyright (C) 2000-2003 Broadcom Corporation.
443 *
444 * Permission is hereby granted for the distribution of this firmware
445 * data in hexadecimal or equivalent format, provided this copyright
446 * notice is accompanying it.
diff --git a/firmware/tigon/tg3_tso5.bin.ihex b/firmware/tigon/tg3_tso5.bin.ihex
new file mode 100644
index 000000000000..33672514eab3
--- /dev/null
+++ b/firmware/tigon/tg3_tso5.bin.ihex
@@ -0,0 +1,252 @@
1:10000000010200000001000000000FD80C004003B6
2:100010000000000000010F040000000010000003B9
3:10002000000000000000000D0000000D3C1D00015C
4:1000300037BDE00003A0F0213C10000126100000B5
5:100040000C004010000000000000000D27BDFFE084
6:100050003C04FEFEAFBF00180C0042E834840002EE
7:100060000C004364000000003C03000190630F3467
8:10007000240200023C04000124840E9C146200034C
9:10008000240500013C04000124840E902406000293
10:1000900000003821AFA000100C004378AFA000147E
11:1000A0000C00402C000000008FBF001803E0000887
12:1000B00027BD0020000000000000000027BDFFE079
13:1000C000AFBF001CAFB20018AFB100140C0042D497
14:1000D000AFB000103C128000241100018F70681036
15:1000E0003202040010400007000000008F64100876
16:1000F0000092102414400003000000000C00406433
17:10010000000000003C02000190420F561051000315
18:10011000320202001040FFF1000000000C0041B468
19:100120000000000008004034000000008FBF001CE9
20:100130008FB200188FB100148FB0001003E00008D8
21:1001400027BD002027BDFFE03C04000124840EB041
22:10015000000028210000302100003821AFBF001826
23:10016000AFA000100C004378AFA000140000D02115
24:1001700024020130AF6250003C010001A4200F5066
25:100180003C010001A0200F578FBF001803E00008BA
26:1001900027BD002000000000000000003C0300011B
27:1001A00024630F609062000027BDFFF0144000033D
28:1001B0000080C02108004073000048213C0220005C
29:1001C00003021024104000032409000208004073B9
30:1001D000A0600000240900010018104030431F8077
31:1001E000346F80081520004B25EB00283C040001EB
32:1001F000008320218C8480103C05000124A50F7A07
33:1002000000041402A0A200003C010001A0240F7B06
34:100210003C02000100431021944280143C01000183
35:10022000A0220F7C3C0C0001018360218D8C801882
36:10023000304200FF24420008000220C324020001D3
37:100240003C010001A0220F600124102B1040000C83
38:100250000000382124A6000E016028218CA2000095
39:100260008CA3000424A5000824E70001ACC2000010
40:10027000ACC3000400E4102B1440FFF824C60008AF
41:10028000000038213C08000125080F7B9106000082
42:100290003C02000190420F7C2503000D00C3282181
43:1002A0000046102300021FC2004310210002104329
44:1002B0001840000C0000202191020001004610238C
45:1002C00000021FC2004310210002184394A2000044
46:1002D00024E700010082202100E3102A1440FFFBE4
47:1002E00024A5000200041C023082FFFF00622021CE
48:1002F00000041402008220213C02FFFF018210242E
49:100300003083FFFF004310253C010001080040FA44
50:10031000AC220F803C05000124A50F7C90A20000B8
51:100320003C0C0001018360218D8C8018000220C2EA
52:100330001080000E000038210160302124A5000C3F
53:100340008CA200008CA3000424A5000824E700016F
54:10035000ACC20000ACC3000400E4102B1440FFF852
55:1003600024C600083C05000124A50F7C90A20000D3
56:1003700030430007240200041062001128620005C7
57:10038000104000052402000210620008000710C09F
58:10039000080040FA00000000240200061062000E6F
59:1003A000000710C0080040FA0000000000A2182159
60:1003B0009463000C004B1021080040FAA443000095
61:1003C000000710C000A218218C63000C004B102104
62:1003D000080040FAAC43000000A218218C63000C16
63:1003E000004B202100A21021AC8300009442001099
64:1003F000A482000495E700063C02000190420F7CB5
65:100400003C03000190630F7A00E2C8233C02000124
66:1004100090420F7B2463002801E3402124420028FE
67:100420001520001201E2302194C2000C3C010001B1
68:10043000A4220F7894C2000494C300063C0100017A
69:10044000A4200F763C010001A4200F7200021400CA
70:10045000004310253C010001AC220F6C9502000402
71:100460003C01000108004124A4220F703C0200015D
72:1004700094420F703C03000194630F7200431021FB
73:10048000A50200043C02000194420F6CA4C20004C7
74:100490003C0200018C420F6CA4C200063C04000127
75:1004A00094840F723C02000194420F703C0A0001D8
76:1004B000954A0F76004418213063FFFF0062182A26
77:1004C000240200021122000B008320233C030001C0
78:1004D00094630F7830620009104000063062FFF626
79:1004E000A4C2000C3C02000194420F783042000983
80:1004F00001425023240200011122001B2922000284
81:1005000050400005240200021120000731A2FFFF25
82:1005100008004197000000001122001D240200166F
83:100520000800419731A2FFFF3C0E000195CE0F80DD
84:10053000108000050180682101C4202100041C02F4
85:100540003082FFFF00627021000E1027A502000A12
86:100550003C03000190630F7B31A2FFFF00E21021FA
87:100560000800418D004320233C02000194420F808B
88:100570000044202100041C023082FFFF0062202181
89:10058000008070210004102708004185A502000AA0
90:100590003C05000124A50F7A90A30000146200021C
91:1005A00024E2FFF2A5E2003490A2000000E2102352
92:1005B000A50200023C03000194630F803C0200018D
93:1005C00094420F5A30E5FFFF0064182100451023C4
94:1005D0000062202300041C023082FFFF0062202101
95:1005E00000041027A502000A3C03000190630F7C61
96:1005F0002462000114A20005008070210163102113
97:10060000904200000800418500026200246200025E
98:1006100014A20003306200FE004B1021944C000035
99:100620003C02000194420F823183FFFF3C04000131
100:1006300090840F7B0043102100E21021004420230E
101:10064000008A202100041C023082FFFF006220216A
102:100650000004140200822021008068210004102779
103:10066000A4C2001031A2FFFF000E1C0000431025A1
104:100670003C04000124840F72ADE20010948200005B
105:100680003C05000194A50F763C0300018C630F6CC0
106:100690002442000100B92821A48200003322FFFF78
107:1006A000006220210083182B3C010001A4250F7655
108:1006B0001060000324A2FFFF3C010001A4220F767A
109:1006C0003C024000030210253C010001AC240F6CE9
110:1006D000AF62100803E0000827BD00103C030001D2
111:1006E00090630F5627BDFFE824020001AFBF00143E
112:1006F00010620026AFB000108F620CF42442FFFF9E
113:100700003042007F000211008C4340003C01000198
114:10071000AC230F648C434008244440008C5C4004AC
115:1007200030620040144000022402008824020008C5
116:100730003C010001A4220F68306200041040000553
117:10074000240200013C010001A0220F57080041D5FE
118:10075000000314023C010001A0200F570003140203
119:100760003C010001A4220F549483000C24020001D8
120:100770003C010001A4200F503C010001A0220F56B3
121:100780003C010001A4230F62240200011342001E59
122:10079000000000001340000524020003134200671C
123:1007A00000000000080042CF000000003C020001F1
124:1007B00094420F62241A00013C010001A4200F5E44
125:1007C0003C010001A4200F52304407FF00021BC26D
126:1007D000000318233063003E3463003600021242E7
127:1007E0003042003C006218213C010001A4240F5853
128:1007F00000832021246300303C010001A4240F5A0F
129:100800003C010001A4230F5C3C06000124C60F52EA
130:1008100094C5000094C300023C04000194840F5A64
131:10082000006510210044102A104000133C10800085
132:1008300000A31021A4C200003C02A000AF620CF48F
133:100840003C010001A0200F568F6410080090102476
134:1008500014400003000000000C0040640000000091
135:100860008F620CF400501024104000B7000000000C
136:100870000800420F000000003C03000194630F5089
137:1008800000851023A4C40000006218213042FFFF3D
138:100890003C010001A4230F50AF620CE83C020001B0
139:1008A00094420F6834420024AF620CEC94C30002FF
140:1008B0003C02000194420F50146200123C0280007E
141:1008C0003C1080003C02A000AF620CF43C0100012F
142:1008D000A0200F568F6410080090102414400003CD
143:1008E000000000000C004064000000008F620CF467
144:1008F000005010241440FFF700000000080042CF11
145:10090000241A0003AF620CF43C1080008F641008BE
146:100910000090102414400003000000000C0040640C
147:10092000000000008F620CF4005010241440FFF708
148:1009300000000000080042CF241A00033C07000119
149:1009400024E70F5094E2000003821021AF620CE014
150:100950003C0200018C420F64AF620CE43C050001D4
151:1009600094A50F5494E300003C04000194840F58B4
152:100970003C02000194420F5E00A328230082202342
153:1009800030A6FFFF3083FFFF00C3102B144000434D
154:10099000000000003C02000194420F5C00021400C1
155:1009A00000621025AF620CE894E200003C030001F5
156:1009B00094630F5400441021A4E200003042FFFF72
157:1009C000144300213C0200083C02000190420F57F2
158:1009D000104000063C03000C3C02000194420F68EA
159:1009E000346306240800427C0000D0213C02000150
160:1009F00094420F683C03000834630624004310252A
161:100A0000AF620CEC3C1080003C02A000AF620CF422
162:100A10003C010001A0200F568F64100800901024A4
163:100A200014400003000000000C00406400000000BF
164:100A30008F620CF4005010241040001500000000DC
165:100A400008004283000000003C03000194630F682B
166:100A5000344206243C108000006218253C028000CD
167:100A6000AF630CECAF620CF48F641008009010249C
168:100A700014400003000000000C004064000000006F
169:100A80008F620CF4005010241440FFF700000000A7
170:100A90003C010001080042CFA4200F5E3C0200018F
171:100AA00094420F5C0002140000C21025AF620CE8F3
172:100AB0003C02000190420F57104000093C03000C1B
173:100AC0003C02000194420F68346306240000D021E8
174:100AD00000431025AF620CEC080042C13C108000BE
175:100AE0003C02000194420F683C0300083463060492
176:100AF00000431025AF620CEC3C02000194420F5EF3
177:100B0000004510213C010001A4220F5E3C10800032
178:100B10003C02A000AF620CF43C010001A0200F5683
179:100B20008F6410080090102414400003000000009F
180:100B30000C004064000000008F620CF40050102490
181:100B40001440FFF7000000008FBF00148FB00010AA
182:100B500003E0000827BD00180000000027BDFFE0EB
183:100B60003C04000124840EC0000028210000302134
184:100B700000003821AFBF0018AFA000100C00437870
185:100B8000AFA000140000D02124020130AF62500059
186:100B90003C010001A4200F503C010001A0200F5790
187:100BA0008FBF001803E0000827BD002027BDFFE825
188:100BB0003C1BC000AFBF0014AFB00010AF60680CAA
189:100BC0008F62680434420082AF6268048F63400021
190:100BD00024020B503C010001AC220F2024020B78B0
191:100BE0003C010001AC220F3034630002AF634000CF
192:100BF0000C004315008080213C010001A0220F342D
193:100C0000304200FF240300021443000500000000EE
194:100C10003C0200018C420F2008004308AC5000C089
195:100C20003C0200018C420F20AC5000BC8F62443467
196:100C30008F6344388F6444103C010001AC220F28BC
197:100C40003C010001AC230F383C010001AC240F240F
198:100C50008FBF00148FB0001003E0000827BD0018FC
199:100C600003E000082402000127BDFFF818800009F6
200:100C7000000028218F63680C8F62680C1043FFFE10
201:100C80000000000024A5000100A4102A1440FFF970
202:100C90000000000003E0000827BD00088F634450F7
203:100CA0003C0200018C420F2800031C020043102B61
204:100CB000144000083C0380003C0400018C840F3881
205:100CC0008F62445000021C020083102B1040FFFC76
206:100CD0003C038000AF6344448F62444400431024CB
207:100CE0001440FFFD000000008F62444803E000084C
208:100CF0003042FFFF3082FFFF2442E0002C422001FF
209:100D0000144000033C024000080043472402FFFF58
210:100D100000822025AF645C388F625C303042000274
211:100D20001440FFFC0000102103E000080000000058
212:100D30008F6244503C0300018C630F240800435031
213:100D40003042FFFF8F6244503042FFFF0043102BC0
214:100D50001440FFFC0000000003E000080000000059
215:100D600027BDFFE0008028213C04000124840ED030
216:100D70000000302100003821AFBF0018AFA00010E4
217:100D80000C004378AFA000140800435F000000008F
218:100D90008FBF001803E0000827BD00203C020001BF
219:100DA0003442D6003C0300013463D6003C04000109
220:100DB0003484DDFF3C010001AC220F4024020040DE
221:100DC0003C010001AC220F443C010001AC200F3C6F
222:100DD000AC600000246300040083102B5040FFFD32
223:100DE000AC60000003E00008000000000080482123
224:100DF0008FAA00103C0200018C420F3C3C04000111
225:100E00008C840F448FAB0014244300010044102B4A
226:100E10003C010001AC230F3C1440000300004021C2
227:100E20003C010001AC200F3C3C0200018C420F3C15
228:100E30003C0300018C630F4091240000000211402C
229:100E4000004310210048102125080001A0440000A3
230:100E5000290200081440FFF4252900013C0200018A
231:100E60008C420F3C3C0300018C630F408F64680C84
232:100E70000002114000431021AC440008AC45000CB6
233:100E8000AC460010AC470014AC4A001803E0000860
234:100E9000AC4B001C00000000000000004D61696EBA
235:100EA00043707542000000004D61696E43707541EA
236:100EB00000000000000000000000000073746B6F71
237:100EC00066666C64000000000000000073746B6FC5
238:100ED00066666C64000000000000000066617461DA
239:100EE0006C4572720000000000000000000000006D
240:100EF00000000000000000000000000000000000F2
241:100F000000000000000000000000000000000000E1
242:100F100073746B6F66666C645F76312E322E3000B0
243:0C0F2000000000000000000000000000C5
244:00000001FF
245 * Firmware is:
246 * Derived from proprietary unpublished source code,
247 * Copyright (C) 2000-2003 Broadcom Corporation.
248 *
249 * Permission is hereby granted for the distribution of this firmware
250 * data in hexadecimal or equivalent format, provided this copyright
251 * notice is accompanying it.
252/* 5705 needs a special version of the TSO firmware. */
diff --git a/fs/Kconfig b/fs/Kconfig
index ff0e81980207..f9b6e2979aaa 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -189,6 +189,8 @@ config OCFS2_FS
189 select CONFIGFS_FS 189 select CONFIGFS_FS
190 select JBD2 190 select JBD2
191 select CRC32 191 select CRC32
192 select QUOTA
193 select QUOTA_TREE
192 help 194 help
193 OCFS2 is a general purpose extent based shared disk cluster file 195 OCFS2 is a general purpose extent based shared disk cluster file
194 system with many similarities to ext3. It supports 64 bit inode 196 system with many similarities to ext3. It supports 64 bit inode
@@ -258,15 +260,14 @@ config OCFS2_DEBUG_FS
258 this option for debugging only as it is likely to decrease 260 this option for debugging only as it is likely to decrease
259 performance of the filesystem. 261 performance of the filesystem.
260 262
261config OCFS2_COMPAT_JBD 263config OCFS2_FS_POSIX_ACL
262 bool "Use JBD for compatibility" 264 bool "OCFS2 POSIX Access Control Lists"
263 depends on OCFS2_FS 265 depends on OCFS2_FS
266 select FS_POSIX_ACL
264 default n 267 default n
265 select JBD
266 help 268 help
267 The ocfs2 filesystem now uses JBD2 for its journalling. JBD2 269 Posix Access Control Lists (ACLs) support permissions for users and
268 is backwards compatible with JBD. It is safe to say N here. 270 groups beyond the owner/group/world scheme.
269 However, if you really want to use the original JBD, say Y here.
270 271
271endif # BLOCK 272endif # BLOCK
272 273
@@ -303,6 +304,10 @@ config PRINT_QUOTA_WARNING
303 Note that this behavior is currently deprecated and may go away in 304 Note that this behavior is currently deprecated and may go away in
304 future. Please use notification via netlink socket instead. 305 future. Please use notification via netlink socket instead.
305 306
307# Generic support for tree structured quota files. Seleted when needed.
308config QUOTA_TREE
309 tristate
310
306config QFMT_V1 311config QFMT_V1
307 tristate "Old quota format support" 312 tristate "Old quota format support"
308 depends on QUOTA 313 depends on QUOTA
@@ -314,6 +319,7 @@ config QFMT_V1
314config QFMT_V2 319config QFMT_V2
315 tristate "Quota format v2 support" 320 tristate "Quota format v2 support"
316 depends on QUOTA 321 depends on QUOTA
322 select QUOTA_TREE
317 help 323 help
318 This quota format allows using quotas with 32-bit UIDs/GIDs. If you 324 This quota format allows using quotas with 32-bit UIDs/GIDs. If you
319 need this functionality say Y here. 325 need this functionality say Y here.
diff --git a/fs/Makefile b/fs/Makefile
index e6f423d1d228..c830611550d3 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_GENERIC_ACL) += generic_acl.o
54obj-$(CONFIG_QUOTA) += dquot.o 54obj-$(CONFIG_QUOTA) += dquot.o
55obj-$(CONFIG_QFMT_V1) += quota_v1.o 55obj-$(CONFIG_QFMT_V1) += quota_v1.o
56obj-$(CONFIG_QFMT_V2) += quota_v2.o 56obj-$(CONFIG_QFMT_V2) += quota_v2.o
57obj-$(CONFIG_QUOTA_TREE) += quota_tree.o
57obj-$(CONFIG_QUOTACTL) += quota.o 58obj-$(CONFIG_QUOTACTL) += quota.o
58 59
59obj-$(CONFIG_PROC_FS) += proc/ 60obj-$(CONFIG_PROC_FS) += proc/
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 1377b1240b6e..9246cb4aa018 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -628,7 +628,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping
628 } 628 }
629 629
630 index = pos >> PAGE_CACHE_SHIFT; 630 index = pos >> PAGE_CACHE_SHIFT;
631 page = __grab_cache_page(mapping, index); 631 page = grab_cache_page_write_begin(mapping, index, flags);
632 if (!page) 632 if (!page)
633 return -ENOMEM; 633 return -ENOMEM;
634 *pagep = page; 634 *pagep = page;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 415d9c67ac16..3c4ec7d864c4 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -119,8 +119,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
119 goto bad_inode; 119 goto bad_inode;
120#else 120#else
121 inode->i_mode |= S_IFDIR; 121 inode->i_mode |= S_IFDIR;
122 inode->i_op = NULL; 122 /* ... and leave ->i_op and ->i_fop pointing to empty */
123 inode->i_fop = NULL;
124 break; 123 break;
125#endif 124#endif
126 case ST_LINKFILE: 125 case ST_LINKFILE:
diff --git a/fs/afs/write.c b/fs/afs/write.c
index d6b85dab35fc..3fb36d433621 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -144,7 +144,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
144 candidate->state = AFS_WBACK_PENDING; 144 candidate->state = AFS_WBACK_PENDING;
145 init_waitqueue_head(&candidate->waitq); 145 init_waitqueue_head(&candidate->waitq);
146 146
147 page = __grab_cache_page(mapping, index); 147 page = grab_cache_page_write_begin(mapping, index, flags);
148 if (!page) { 148 if (!page) {
149 kfree(candidate); 149 kfree(candidate);
150 return -ENOMEM; 150 return -ENOMEM;
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index c773680d5c60..e1734f2d6e26 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -251,13 +251,11 @@ struct inode *autofs_iget(struct super_block *sb, unsigned long ino)
251 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 251 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
252 inode->i_nlink = 2; 252 inode->i_nlink = 2;
253 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 253 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
254 inode->i_blocks = 0;
255 254
256 if (ino == AUTOFS_ROOT_INO) { 255 if (ino == AUTOFS_ROOT_INO) {
257 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 256 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
258 inode->i_op = &autofs_root_inode_operations; 257 inode->i_op = &autofs_root_inode_operations;
259 inode->i_fop = &autofs_root_operations; 258 inode->i_fop = &autofs_root_operations;
260 inode->i_uid = inode->i_gid = 0; /* Changed in read_super */
261 goto done; 259 goto done;
262 } 260 }
263 261
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 7b19802cfef4..cfc23e53b6f4 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -455,11 +455,7 @@ struct inode *autofs4_get_inode(struct super_block *sb,
455 if (sb->s_root) { 455 if (sb->s_root) {
456 inode->i_uid = sb->s_root->d_inode->i_uid; 456 inode->i_uid = sb->s_root->d_inode->i_uid;
457 inode->i_gid = sb->s_root->d_inode->i_gid; 457 inode->i_gid = sb->s_root->d_inode->i_gid;
458 } else {
459 inode->i_uid = 0;
460 inode->i_gid = 0;
461 } 458 }
462 inode->i_blocks = 0;
463 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 459 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
464 460
465 if (S_ISDIR(inf->mode)) { 461 if (S_ISDIR(inf->mode)) {
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index f1f3f4192a60..b639dcf7c778 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -95,92 +95,55 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u
95 int has_dumped = 0; 95 int has_dumped = 0;
96 unsigned long dump_start, dump_size; 96 unsigned long dump_start, dump_size;
97 struct user dump; 97 struct user dump;
98#if defined(__alpha__) 98#ifdef __alpha__
99# define START_DATA(u) (u.start_data) 99# define START_DATA(u) (u.start_data)
100#elif defined(__arm__) 100#else
101# define START_DATA(u) ((u.u_tsize << PAGE_SHIFT) + u.start_code) 101# define START_DATA(u) ((u.u_tsize << PAGE_SHIFT) + u.start_code)
102#elif defined(__sparc__)
103# define START_DATA(u) (u.u_tsize)
104#elif defined(__i386__) || defined(__mc68000__) || defined(__arch_um__)
105# define START_DATA(u) (u.u_tsize << PAGE_SHIFT)
106#endif 102#endif
107#ifdef __sparc__
108# define START_STACK(u) ((regs->u_regs[UREG_FP]) & ~(PAGE_SIZE - 1))
109#else
110# define START_STACK(u) (u.start_stack) 103# define START_STACK(u) (u.start_stack)
111#endif
112 104
113 fs = get_fs(); 105 fs = get_fs();
114 set_fs(KERNEL_DS); 106 set_fs(KERNEL_DS);
115 has_dumped = 1; 107 has_dumped = 1;
116 current->flags |= PF_DUMPCORE; 108 current->flags |= PF_DUMPCORE;
117 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); 109 strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
118#ifndef __sparc__
119 dump.u_ar0 = offsetof(struct user, regs); 110 dump.u_ar0 = offsetof(struct user, regs);
120#endif
121 dump.signal = signr; 111 dump.signal = signr;
122 aout_dump_thread(regs, &dump); 112 aout_dump_thread(regs, &dump);
123 113
124/* If the size of the dump file exceeds the rlimit, then see what would happen 114/* If the size of the dump file exceeds the rlimit, then see what would happen
125 if we wrote the stack, but not the data area. */ 115 if we wrote the stack, but not the data area. */
126#ifdef __sparc__
127 if ((dump.u_dsize + dump.u_ssize) > limit)
128 dump.u_dsize = 0;
129#else
130 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit) 116 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit)
131 dump.u_dsize = 0; 117 dump.u_dsize = 0;
132#endif
133 118
134/* Make sure we have enough room to write the stack and data areas. */ 119/* Make sure we have enough room to write the stack and data areas. */
135#ifdef __sparc__
136 if (dump.u_ssize > limit)
137 dump.u_ssize = 0;
138#else
139 if ((dump.u_ssize + 1) * PAGE_SIZE > limit) 120 if ((dump.u_ssize + 1) * PAGE_SIZE > limit)
140 dump.u_ssize = 0; 121 dump.u_ssize = 0;
141#endif
142 122
143/* make sure we actually have a data and stack area to dump */ 123/* make sure we actually have a data and stack area to dump */
144 set_fs(USER_DS); 124 set_fs(USER_DS);
145#ifdef __sparc__
146 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize))
147 dump.u_dsize = 0;
148 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize))
149 dump.u_ssize = 0;
150#else
151 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT)) 125 if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
152 dump.u_dsize = 0; 126 dump.u_dsize = 0;
153 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT)) 127 if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
154 dump.u_ssize = 0; 128 dump.u_ssize = 0;
155#endif
156 129
157 set_fs(KERNEL_DS); 130 set_fs(KERNEL_DS);
158/* struct user */ 131/* struct user */
159 DUMP_WRITE(&dump,sizeof(dump)); 132 DUMP_WRITE(&dump,sizeof(dump));
160/* Now dump all of the user data. Include malloced stuff as well */ 133/* Now dump all of the user data. Include malloced stuff as well */
161#ifndef __sparc__
162 DUMP_SEEK(PAGE_SIZE); 134 DUMP_SEEK(PAGE_SIZE);
163#endif
164/* now we start writing out the user space info */ 135/* now we start writing out the user space info */
165 set_fs(USER_DS); 136 set_fs(USER_DS);
166/* Dump the data area */ 137/* Dump the data area */
167 if (dump.u_dsize != 0) { 138 if (dump.u_dsize != 0) {
168 dump_start = START_DATA(dump); 139 dump_start = START_DATA(dump);
169#ifdef __sparc__
170 dump_size = dump.u_dsize;
171#else
172 dump_size = dump.u_dsize << PAGE_SHIFT; 140 dump_size = dump.u_dsize << PAGE_SHIFT;
173#endif
174 DUMP_WRITE(dump_start,dump_size); 141 DUMP_WRITE(dump_start,dump_size);
175 } 142 }
176/* Now prepare to dump the stack area */ 143/* Now prepare to dump the stack area */
177 if (dump.u_ssize != 0) { 144 if (dump.u_ssize != 0) {
178 dump_start = START_STACK(dump); 145 dump_start = START_STACK(dump);
179#ifdef __sparc__
180 dump_size = dump.u_ssize;
181#else
182 dump_size = dump.u_ssize << PAGE_SHIFT; 146 dump_size = dump.u_ssize << PAGE_SHIFT;
183#endif
184 DUMP_WRITE(dump_start,dump_size); 147 DUMP_WRITE(dump_start,dump_size);
185 } 148 }
186/* Finally dump the task struct. Not be used by gdb, but could be useful */ 149/* Finally dump the task struct. Not be used by gdb, but could be useful */
@@ -205,29 +168,24 @@ static unsigned long __user *create_aout_tables(char __user *p, struct linux_bin
205 int envc = bprm->envc; 168 int envc = bprm->envc;
206 169
207 sp = (void __user *)((-(unsigned long)sizeof(char *)) & (unsigned long) p); 170 sp = (void __user *)((-(unsigned long)sizeof(char *)) & (unsigned long) p);
208#ifdef __sparc__
209 /* This imposes the proper stack alignment for a new process. */
210 sp = (void __user *) (((unsigned long) sp) & ~7);
211 if ((envc+argc+3)&1) --sp;
212#endif
213#ifdef __alpha__ 171#ifdef __alpha__
214/* whee.. test-programs are so much fun. */ 172/* whee.. test-programs are so much fun. */
215 put_user(0, --sp); 173 put_user(0, --sp);
216 put_user(0, --sp); 174 put_user(0, --sp);
217 if (bprm->loader) { 175 if (bprm->loader) {
218 put_user(0, --sp); 176 put_user(0, --sp);
219 put_user(0x3eb, --sp); 177 put_user(1003, --sp);
220 put_user(bprm->loader, --sp); 178 put_user(bprm->loader, --sp);
221 put_user(0x3ea, --sp); 179 put_user(1002, --sp);
222 } 180 }
223 put_user(bprm->exec, --sp); 181 put_user(bprm->exec, --sp);
224 put_user(0x3e9, --sp); 182 put_user(1001, --sp);
225#endif 183#endif
226 sp -= envc+1; 184 sp -= envc+1;
227 envp = (char __user * __user *) sp; 185 envp = (char __user * __user *) sp;
228 sp -= argc+1; 186 sp -= argc+1;
229 argv = (char __user * __user *) sp; 187 argv = (char __user * __user *) sp;
230#if defined(__i386__) || defined(__mc68000__) || defined(__arm__) || defined(__arch_um__) 188#ifndef __alpha__
231 put_user((unsigned long) envp,--sp); 189 put_user((unsigned long) envp,--sp);
232 put_user((unsigned long) argv,--sp); 190 put_user((unsigned long) argv,--sp);
233#endif 191#endif
@@ -300,13 +258,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
300 return retval; 258 return retval;
301 259
302 /* OK, This is the point of no return */ 260 /* OK, This is the point of no return */
303#if defined(__alpha__) 261#ifdef __alpha__
304 SET_AOUT_PERSONALITY(bprm, ex); 262 SET_AOUT_PERSONALITY(bprm, ex);
305#elif defined(__sparc__)
306 set_personality(PER_SUNOS);
307#if !defined(__sparc_v9__)
308 memcpy(&current->thread.core_exec, &ex, sizeof(struct exec));
309#endif
310#else 263#else
311 set_personality(PER_LINUX); 264 set_personality(PER_LINUX);
312#endif 265#endif
@@ -322,24 +275,6 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
322 275
323 install_exec_creds(bprm); 276 install_exec_creds(bprm);
324 current->flags &= ~PF_FORKNOEXEC; 277 current->flags &= ~PF_FORKNOEXEC;
325#ifdef __sparc__
326 if (N_MAGIC(ex) == NMAGIC) {
327 loff_t pos = fd_offset;
328 /* Fuck me plenty... */
329 /* <AOL></AOL> */
330 down_write(&current->mm->mmap_sem);
331 error = do_brk(N_TXTADDR(ex), ex.a_text);
332 up_write(&current->mm->mmap_sem);
333 bprm->file->f_op->read(bprm->file, (char *) N_TXTADDR(ex),
334 ex.a_text, &pos);
335 down_write(&current->mm->mmap_sem);
336 error = do_brk(N_DATADDR(ex), ex.a_data);
337 up_write(&current->mm->mmap_sem);
338 bprm->file->f_op->read(bprm->file, (char *) N_DATADDR(ex),
339 ex.a_data, &pos);
340 goto beyond_if;
341 }
342#endif
343 278
344 if (N_MAGIC(ex) == OMAGIC) { 279 if (N_MAGIC(ex) == OMAGIC) {
345 unsigned long text_addr, map_size; 280 unsigned long text_addr, map_size;
@@ -347,7 +282,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
347 282
348 text_addr = N_TXTADDR(ex); 283 text_addr = N_TXTADDR(ex);
349 284
350#if defined(__alpha__) || defined(__sparc__) 285#ifdef __alpha__
351 pos = fd_offset; 286 pos = fd_offset;
352 map_size = ex.a_text+ex.a_data + PAGE_SIZE - 1; 287 map_size = ex.a_text+ex.a_data + PAGE_SIZE - 1;
353#else 288#else
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index f2744ab4e5b3..e1158cb4fbd6 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -496,9 +496,6 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
496 496
497 if (inode) { 497 if (inode) {
498 inode->i_mode = mode; 498 inode->i_mode = mode;
499 inode->i_uid = 0;
500 inode->i_gid = 0;
501 inode->i_blocks = 0;
502 inode->i_atime = inode->i_mtime = inode->i_ctime = 499 inode->i_atime = inode->i_mtime = inode->i_ctime =
503 current_fs_time(inode->i_sb); 500 current_fs_time(inode->i_sb);
504 } 501 }
diff --git a/fs/buffer.c b/fs/buffer.c
index 776ae091d3b0..a13f09b696f7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1996,7 +1996,7 @@ int block_write_begin(struct file *file, struct address_space *mapping,
1996 page = *pagep; 1996 page = *pagep;
1997 if (page == NULL) { 1997 if (page == NULL) {
1998 ownpage = 1; 1998 ownpage = 1;
1999 page = __grab_cache_page(mapping, index); 1999 page = grab_cache_page_write_begin(mapping, index, flags);
2000 if (!page) { 2000 if (!page) {
2001 status = -ENOMEM; 2001 status = -ENOMEM;
2002 goto out; 2002 goto out;
@@ -2502,7 +2502,7 @@ int nobh_write_begin(struct file *file, struct address_space *mapping,
2502 from = pos & (PAGE_CACHE_SIZE - 1); 2502 from = pos & (PAGE_CACHE_SIZE - 1);
2503 to = from + len; 2503 to = from + len;
2504 2504
2505 page = __grab_cache_page(mapping, index); 2505 page = grab_cache_page_write_begin(mapping, index, flags);
2506 if (!page) 2506 if (!page)
2507 return -ENOMEM; 2507 return -ENOMEM;
2508 *pagep = page; 2508 *pagep = page;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index b1e1fc6a6e6a..12bb656fbe75 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2074,7 +2074,7 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
2074 2074
2075 cFYI(1, ("write_begin from %lld len %d", (long long)pos, len)); 2075 cFYI(1, ("write_begin from %lld len %d", (long long)pos, len));
2076 2076
2077 page = __grab_cache_page(mapping, index); 2077 page = grab_cache_page_write_begin(mapping, index, flags);
2078 if (!page) { 2078 if (!page) {
2079 rc = -ENOMEM; 2079 rc = -ENOMEM;
2080 goto out; 2080 goto out;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index f247da9f4edc..5ab9896fdcb2 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1641,7 +1641,7 @@ do_expand:
1641 i_size_write(inode, offset); 1641 i_size_write(inode, offset);
1642 spin_unlock(&inode->i_lock); 1642 spin_unlock(&inode->i_lock);
1643out_truncate: 1643out_truncate:
1644 if (inode->i_op && inode->i_op->truncate) 1644 if (inode->i_op->truncate)
1645 inode->i_op->truncate(inode); 1645 inode->i_op->truncate(inode);
1646 return 0; 1646 return 0;
1647out_sig: 1647out_sig:
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 466303db2df6..6a347fbc998a 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -201,8 +201,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
201int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync) 201int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
202{ 202{
203 struct file *host_file; 203 struct file *host_file;
204 struct dentry *host_dentry; 204 struct inode *coda_inode = coda_dentry->d_inode;
205 struct inode *host_inode, *coda_inode = coda_dentry->d_inode;
206 struct coda_file_info *cfi; 205 struct coda_file_info *cfi;
207 int err = 0; 206 int err = 0;
208 207
@@ -214,14 +213,7 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
214 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 213 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
215 host_file = cfi->cfi_container; 214 host_file = cfi->cfi_container;
216 215
217 if (host_file->f_op && host_file->f_op->fsync) { 216 err = vfs_fsync(host_file, host_file->f_path.dentry, datasync);
218 host_dentry = host_file->f_path.dentry;
219 host_inode = host_dentry->d_inode;
220 mutex_lock(&host_inode->i_mutex);
221 err = host_file->f_op->fsync(host_file, host_dentry, datasync);
222 mutex_unlock(&host_inode->i_mutex);
223 }
224
225 if ( !err && !datasync ) { 217 if ( !err && !datasync ) {
226 lock_kernel(); 218 lock_kernel();
227 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); 219 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 4803ccc94480..5d349d38e056 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -117,8 +117,6 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
117static inline void set_default_inode_attr(struct inode * inode, mode_t mode) 117static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
118{ 118{
119 inode->i_mode = mode; 119 inode->i_mode = mode;
120 inode->i_uid = 0;
121 inode->i_gid = 0;
122 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 120 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
123} 121}
124 122
@@ -136,7 +134,6 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
136{ 134{
137 struct inode * inode = new_inode(configfs_sb); 135 struct inode * inode = new_inode(configfs_sb);
138 if (inode) { 136 if (inode) {
139 inode->i_blocks = 0;
140 inode->i_mapping->a_ops = &configfs_aops; 137 inode->i_mapping->a_ops = &configfs_aops;
141 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; 138 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
142 inode->i_op = &configfs_inode_operations; 139 inode->i_op = &configfs_inode_operations;
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index f40423eb1a14..a07338d2d140 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -83,8 +83,6 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
83 inode->i_op = &page_symlink_inode_operations; 83 inode->i_op = &page_symlink_inode_operations;
84 inode->i_data.a_ops = &cramfs_aops; 84 inode->i_data.a_ops = &cramfs_aops;
85 } else { 85 } else {
86 inode->i_size = 0;
87 inode->i_blocks = 0;
88 init_special_inode(inode, inode->i_mode, 86 init_special_inode(inode, inode->i_mode,
89 old_decode_dev(cramfs_inode->size)); 87 old_decode_dev(cramfs_inode->size));
90 } 88 }
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 3dbe2169cf36..81ae9ea3c6e1 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -37,9 +37,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
37 37
38 if (inode) { 38 if (inode) {
39 inode->i_mode = mode; 39 inode->i_mode = mode;
40 inode->i_uid = 0;
41 inode->i_gid = 0;
42 inode->i_blocks = 0;
43 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 40 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
44 switch (mode & S_IFMT) { 41 switch (mode & S_IFMT) {
45 default: 42 default:
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index fff96e152c0c..5f3231b9633f 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -189,8 +189,6 @@ static int mknod_ptmx(struct super_block *sb)
189 } 189 }
190 190
191 inode->i_ino = 2; 191 inode->i_ino = 2;
192 inode->i_uid = inode->i_gid = 0;
193 inode->i_blocks = 0;
194 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 192 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
195 193
196 mode = S_IFCHR|opts->ptmxmode; 194 mode = S_IFCHR|opts->ptmxmode;
@@ -300,8 +298,6 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
300 goto free_fsi; 298 goto free_fsi;
301 inode->i_ino = 1; 299 inode->i_ino = 1;
302 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 300 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
303 inode->i_blocks = 0;
304 inode->i_uid = inode->i_gid = 0;
305 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 301 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
306 inode->i_op = &simple_dir_inode_operations; 302 inode->i_op = &simple_dir_inode_operations;
307 inode->i_fop = &simple_dir_operations; 303 inode->i_fop = &simple_dir_operations;
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
index 8bf31e3fbf01..dc2ad6008b2d 100644
--- a/fs/dlm/ast.c
+++ b/fs/dlm/ast.c
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
6** 6**
7** This copyrighted material is made available to anyone wishing to use, 7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions 8** modify, copy, or redistribute it subject to the terms and conditions
@@ -33,10 +33,10 @@ void dlm_del_ast(struct dlm_lkb *lkb)
33 spin_unlock(&ast_queue_lock); 33 spin_unlock(&ast_queue_lock);
34} 34}
35 35
36void dlm_add_ast(struct dlm_lkb *lkb, int type) 36void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
37{ 37{
38 if (lkb->lkb_flags & DLM_IFL_USER) { 38 if (lkb->lkb_flags & DLM_IFL_USER) {
39 dlm_user_add_ast(lkb, type); 39 dlm_user_add_ast(lkb, type, bastmode);
40 return; 40 return;
41 } 41 }
42 42
@@ -46,6 +46,8 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type)
46 list_add_tail(&lkb->lkb_astqueue, &ast_queue); 46 list_add_tail(&lkb->lkb_astqueue, &ast_queue);
47 } 47 }
48 lkb->lkb_ast_type |= type; 48 lkb->lkb_ast_type |= type;
49 if (bastmode)
50 lkb->lkb_bastmode = bastmode;
49 spin_unlock(&ast_queue_lock); 51 spin_unlock(&ast_queue_lock);
50 52
51 set_bit(WAKE_ASTS, &astd_wakeflags); 53 set_bit(WAKE_ASTS, &astd_wakeflags);
@@ -59,50 +61,40 @@ static void process_asts(void)
59 struct dlm_lkb *lkb; 61 struct dlm_lkb *lkb;
60 void (*cast) (void *astparam); 62 void (*cast) (void *astparam);
61 void (*bast) (void *astparam, int mode); 63 void (*bast) (void *astparam, int mode);
62 int type = 0, found, bmode; 64 int type = 0, bastmode;
63 65
64 for (;;) { 66repeat:
65 found = 0; 67 spin_lock(&ast_queue_lock);
66 spin_lock(&ast_queue_lock); 68 list_for_each_entry(lkb, &ast_queue, lkb_astqueue) {
67 list_for_each_entry(lkb, &ast_queue, lkb_astqueue) { 69 r = lkb->lkb_resource;
68 r = lkb->lkb_resource; 70 ls = r->res_ls;
69 ls = r->res_ls; 71
70 72 if (dlm_locking_stopped(ls))
71 if (dlm_locking_stopped(ls)) 73 continue;
72 continue;
73
74 list_del(&lkb->lkb_astqueue);
75 type = lkb->lkb_ast_type;
76 lkb->lkb_ast_type = 0;
77 found = 1;
78 break;
79 }
80 spin_unlock(&ast_queue_lock);
81 74
82 if (!found) 75 list_del(&lkb->lkb_astqueue);
83 break; 76 type = lkb->lkb_ast_type;
77 lkb->lkb_ast_type = 0;
78 bastmode = lkb->lkb_bastmode;
84 79
80 spin_unlock(&ast_queue_lock);
85 cast = lkb->lkb_astfn; 81 cast = lkb->lkb_astfn;
86 bast = lkb->lkb_bastfn; 82 bast = lkb->lkb_bastfn;
87 bmode = lkb->lkb_bastmode;
88 83
89 if ((type & AST_COMP) && cast) 84 if ((type & AST_COMP) && cast)
90 cast(lkb->lkb_astparam); 85 cast(lkb->lkb_astparam);
91 86
92 /* FIXME: Is it safe to look at lkb_grmode here
93 without doing a lock_rsb() ?
94 Look at other checks in v1 to avoid basts. */
95
96 if ((type & AST_BAST) && bast) 87 if ((type & AST_BAST) && bast)
97 if (!dlm_modes_compat(lkb->lkb_grmode, bmode)) 88 bast(lkb->lkb_astparam, bastmode);
98 bast(lkb->lkb_astparam, bmode);
99 89
100 /* this removes the reference added by dlm_add_ast 90 /* this removes the reference added by dlm_add_ast
101 and may result in the lkb being freed */ 91 and may result in the lkb being freed */
102 dlm_put_lkb(lkb); 92 dlm_put_lkb(lkb);
103 93
104 schedule(); 94 cond_resched();
95 goto repeat;
105 } 96 }
97 spin_unlock(&ast_queue_lock);
106} 98}
107 99
108static inline int no_asts(void) 100static inline int no_asts(void)
diff --git a/fs/dlm/ast.h b/fs/dlm/ast.h
index 6ee276c74c52..1b5fc5f428fd 100644
--- a/fs/dlm/ast.h
+++ b/fs/dlm/ast.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
5** 5**
6** This copyrighted material is made available to anyone wishing to use, 6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions 7** modify, copy, or redistribute it subject to the terms and conditions
@@ -13,7 +13,7 @@
13#ifndef __ASTD_DOT_H__ 13#ifndef __ASTD_DOT_H__
14#define __ASTD_DOT_H__ 14#define __ASTD_DOT_H__
15 15
16void dlm_add_ast(struct dlm_lkb *lkb, int type); 16void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode);
17void dlm_del_ast(struct dlm_lkb *lkb); 17void dlm_del_ast(struct dlm_lkb *lkb);
18 18
19void dlm_astd_wake(void); 19void dlm_astd_wake(void);
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 8fc24f4507a3..2f107d1a6a45 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved.
5** 5**
6** This copyrighted material is made available to anyone wishing to use, 6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions 7** modify, copy, or redistribute it subject to the terms and conditions
@@ -27,7 +27,7 @@ static struct dentry *dlm_root;
27 27
28struct rsb_iter { 28struct rsb_iter {
29 int entry; 29 int entry;
30 int locks; 30 int format;
31 int header; 31 int header;
32 struct dlm_ls *ls; 32 struct dlm_ls *ls;
33 struct list_head *next; 33 struct list_head *next;
@@ -60,8 +60,8 @@ static char *print_lockmode(int mode)
60 } 60 }
61} 61}
62 62
63static void print_resource_lock(struct seq_file *s, struct dlm_lkb *lkb, 63static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
64 struct dlm_rsb *res) 64 struct dlm_rsb *res)
65{ 65{
66 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); 66 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode));
67 67
@@ -83,7 +83,7 @@ static void print_resource_lock(struct seq_file *s, struct dlm_lkb *lkb,
83 seq_printf(s, "\n"); 83 seq_printf(s, "\n");
84} 84}
85 85
86static int print_resource(struct dlm_rsb *res, struct seq_file *s) 86static int print_format1(struct dlm_rsb *res, struct seq_file *s)
87{ 87{
88 struct dlm_lkb *lkb; 88 struct dlm_lkb *lkb;
89 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; 89 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list;
@@ -134,15 +134,15 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
134 /* Print the locks attached to this resource */ 134 /* Print the locks attached to this resource */
135 seq_printf(s, "Granted Queue\n"); 135 seq_printf(s, "Granted Queue\n");
136 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) 136 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue)
137 print_resource_lock(s, lkb, res); 137 print_format1_lock(s, lkb, res);
138 138
139 seq_printf(s, "Conversion Queue\n"); 139 seq_printf(s, "Conversion Queue\n");
140 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) 140 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue)
141 print_resource_lock(s, lkb, res); 141 print_format1_lock(s, lkb, res);
142 142
143 seq_printf(s, "Waiting Queue\n"); 143 seq_printf(s, "Waiting Queue\n");
144 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) 144 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue)
145 print_resource_lock(s, lkb, res); 145 print_format1_lock(s, lkb, res);
146 146
147 if (list_empty(&res->res_lookup)) 147 if (list_empty(&res->res_lookup))
148 goto out; 148 goto out;
@@ -160,23 +160,24 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)
160 return 0; 160 return 0;
161} 161}
162 162
163static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) 163static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
164 struct dlm_rsb *r)
164{ 165{
165 unsigned int waiting = 0; 166 u64 xid = 0;
166 uint64_t xid = 0; 167 u64 us;
167 168
168 if (lkb->lkb_flags & DLM_IFL_USER) { 169 if (lkb->lkb_flags & DLM_IFL_USER) {
169 if (lkb->lkb_ua) 170 if (lkb->lkb_ua)
170 xid = lkb->lkb_ua->xid; 171 xid = lkb->lkb_ua->xid;
171 } 172 }
172 173
173 if (lkb->lkb_timestamp) 174 /* microseconds since lkb was added to current queue */
174 waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp); 175 us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp));
175 176
176 /* id nodeid remid pid xid exflags flags sts grmode rqmode time_ms 177 /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us
177 r_nodeid r_len r_name */ 178 r_nodeid r_len r_name */
178 179
179 seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %u %u %d \"%s\"\n", 180 seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
180 lkb->lkb_id, 181 lkb->lkb_id,
181 lkb->lkb_nodeid, 182 lkb->lkb_nodeid,
182 lkb->lkb_remid, 183 lkb->lkb_remid,
@@ -187,26 +188,114 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *
187 lkb->lkb_status, 188 lkb->lkb_status,
188 lkb->lkb_grmode, 189 lkb->lkb_grmode,
189 lkb->lkb_rqmode, 190 lkb->lkb_rqmode,
190 waiting, 191 (unsigned long long)us,
191 r->res_nodeid, 192 r->res_nodeid,
192 r->res_length, 193 r->res_length,
193 r->res_name); 194 r->res_name);
194} 195}
195 196
196static int print_locks(struct dlm_rsb *r, struct seq_file *s) 197static int print_format2(struct dlm_rsb *r, struct seq_file *s)
197{ 198{
198 struct dlm_lkb *lkb; 199 struct dlm_lkb *lkb;
199 200
200 lock_rsb(r); 201 lock_rsb(r);
201 202
202 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) 203 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue)
203 print_lock(s, lkb, r); 204 print_format2_lock(s, lkb, r);
204 205
205 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) 206 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue)
206 print_lock(s, lkb, r); 207 print_format2_lock(s, lkb, r);
207 208
208 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) 209 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue)
209 print_lock(s, lkb, r); 210 print_format2_lock(s, lkb, r);
211
212 unlock_rsb(r);
213 return 0;
214}
215
216static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
217 int rsb_lookup)
218{
219 u64 xid = 0;
220
221 if (lkb->lkb_flags & DLM_IFL_USER) {
222 if (lkb->lkb_ua)
223 xid = lkb->lkb_ua->xid;
224 }
225
226 seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
227 lkb->lkb_id,
228 lkb->lkb_nodeid,
229 lkb->lkb_remid,
230 lkb->lkb_ownpid,
231 (unsigned long long)xid,
232 lkb->lkb_exflags,
233 lkb->lkb_flags,
234 lkb->lkb_status,
235 lkb->lkb_grmode,
236 lkb->lkb_rqmode,
237 lkb->lkb_highbast,
238 rsb_lookup,
239 lkb->lkb_wait_type,
240 lkb->lkb_lvbseq,
241 (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
242 (unsigned long long)ktime_to_ns(lkb->lkb_time_bast));
243}
244
245static int print_format3(struct dlm_rsb *r, struct seq_file *s)
246{
247 struct dlm_lkb *lkb;
248 int i, lvblen = r->res_ls->ls_lvblen;
249 int print_name = 1;
250
251 lock_rsb(r);
252
253 seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
254 r,
255 r->res_nodeid,
256 r->res_first_lkid,
257 r->res_flags,
258 !list_empty(&r->res_root_list),
259 !list_empty(&r->res_recover_list),
260 r->res_recover_locks_count,
261 r->res_length);
262
263 for (i = 0; i < r->res_length; i++) {
264 if (!isascii(r->res_name[i]) || !isprint(r->res_name[i]))
265 print_name = 0;
266 }
267
268 seq_printf(s, "%s", print_name ? "str " : "hex");
269
270 for (i = 0; i < r->res_length; i++) {
271 if (print_name)
272 seq_printf(s, "%c", r->res_name[i]);
273 else
274 seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
275 }
276 seq_printf(s, "\n");
277
278 if (!r->res_lvbptr)
279 goto do_locks;
280
281 seq_printf(s, "lvb %u %d", r->res_lvbseq, lvblen);
282
283 for (i = 0; i < lvblen; i++)
284 seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]);
285 seq_printf(s, "\n");
286
287 do_locks:
288 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue)
289 print_format3_lock(s, lkb, 0);
290
291 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue)
292 print_format3_lock(s, lkb, 0);
293
294 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue)
295 print_format3_lock(s, lkb, 0);
296
297 list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup)
298 print_format3_lock(s, lkb, 1);
210 299
211 unlock_rsb(r); 300 unlock_rsb(r);
212 return 0; 301 return 0;
@@ -231,7 +320,7 @@ static int rsb_iter_next(struct rsb_iter *ri)
231 break; 320 break;
232 } 321 }
233 read_unlock(&ls->ls_rsbtbl[i].lock); 322 read_unlock(&ls->ls_rsbtbl[i].lock);
234 } 323 }
235 ri->entry = i; 324 ri->entry = i;
236 325
237 if (ri->entry >= ls->ls_rsbtbl_size) 326 if (ri->entry >= ls->ls_rsbtbl_size)
@@ -248,7 +337,7 @@ static int rsb_iter_next(struct rsb_iter *ri)
248 read_unlock(&ls->ls_rsbtbl[i].lock); 337 read_unlock(&ls->ls_rsbtbl[i].lock);
249 dlm_put_rsb(old); 338 dlm_put_rsb(old);
250 goto top; 339 goto top;
251 } 340 }
252 ri->rsb = list_entry(ri->next, struct dlm_rsb, res_hashchain); 341 ri->rsb = list_entry(ri->next, struct dlm_rsb, res_hashchain);
253 dlm_hold_rsb(ri->rsb); 342 dlm_hold_rsb(ri->rsb);
254 read_unlock(&ls->ls_rsbtbl[i].lock); 343 read_unlock(&ls->ls_rsbtbl[i].lock);
@@ -274,6 +363,7 @@ static struct rsb_iter *rsb_iter_init(struct dlm_ls *ls)
274 ri->ls = ls; 363 ri->ls = ls;
275 ri->entry = 0; 364 ri->entry = 0;
276 ri->next = NULL; 365 ri->next = NULL;
366 ri->format = 1;
277 367
278 if (rsb_iter_next(ri)) { 368 if (rsb_iter_next(ri)) {
279 rsb_iter_free(ri); 369 rsb_iter_free(ri);
@@ -325,16 +415,26 @@ static int rsb_seq_show(struct seq_file *file, void *iter_ptr)
325{ 415{
326 struct rsb_iter *ri = iter_ptr; 416 struct rsb_iter *ri = iter_ptr;
327 417
328 if (ri->locks) { 418 switch (ri->format) {
419 case 1:
420 print_format1(ri->rsb, file);
421 break;
422 case 2:
329 if (ri->header) { 423 if (ri->header) {
330 seq_printf(file, "id nodeid remid pid xid exflags flags " 424 seq_printf(file, "id nodeid remid pid xid exflags "
331 "sts grmode rqmode time_ms r_nodeid " 425 "flags sts grmode rqmode time_ms "
332 "r_len r_name\n"); 426 "r_nodeid r_len r_name\n");
333 ri->header = 0; 427 ri->header = 0;
334 } 428 }
335 print_locks(ri->rsb, file); 429 print_format2(ri->rsb, file);
336 } else { 430 break;
337 print_resource(ri->rsb, file); 431 case 3:
432 if (ri->header) {
433 seq_printf(file, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
434 ri->header = 0;
435 }
436 print_format3(ri->rsb, file);
437 break;
338 } 438 }
339 439
340 return 0; 440 return 0;
@@ -385,7 +485,7 @@ static struct rsb_iter *locks_iter_init(struct dlm_ls *ls, loff_t *pos)
385 ri->ls = ls; 485 ri->ls = ls;
386 ri->entry = 0; 486 ri->entry = 0;
387 ri->next = NULL; 487 ri->next = NULL;
388 ri->locks = 1; 488 ri->format = 2;
389 489
390 if (*pos == 0) 490 if (*pos == 0)
391 ri->header = 1; 491 ri->header = 1;
@@ -448,6 +548,84 @@ static const struct file_operations locks_fops = {
448}; 548};
449 549
450/* 550/*
551 * Dump all rsb/lvb/lkb state in compact listing, more complete than _locks
552 * This can replace both formats 1 and 2 eventually.
553 */
554
555static struct rsb_iter *all_iter_init(struct dlm_ls *ls, loff_t *pos)
556{
557 struct rsb_iter *ri;
558
559 ri = kzalloc(sizeof *ri, GFP_KERNEL);
560 if (!ri)
561 return NULL;
562
563 ri->ls = ls;
564 ri->entry = 0;
565 ri->next = NULL;
566 ri->format = 3;
567
568 if (*pos == 0)
569 ri->header = 1;
570
571 if (rsb_iter_next(ri)) {
572 rsb_iter_free(ri);
573 return NULL;
574 }
575
576 return ri;
577}
578
579static void *all_seq_start(struct seq_file *file, loff_t *pos)
580{
581 struct rsb_iter *ri;
582 loff_t n = *pos;
583
584 ri = all_iter_init(file->private, pos);
585 if (!ri)
586 return NULL;
587
588 while (n--) {
589 if (rsb_iter_next(ri)) {
590 rsb_iter_free(ri);
591 return NULL;
592 }
593 }
594
595 return ri;
596}
597
598static struct seq_operations all_seq_ops = {
599 .start = all_seq_start,
600 .next = rsb_seq_next,
601 .stop = rsb_seq_stop,
602 .show = rsb_seq_show,
603};
604
605static int all_open(struct inode *inode, struct file *file)
606{
607 struct seq_file *seq;
608 int ret;
609
610 ret = seq_open(file, &all_seq_ops);
611 if (ret)
612 return ret;
613
614 seq = file->private_data;
615 seq->private = inode->i_private;
616
617 return 0;
618}
619
620static const struct file_operations all_fops = {
621 .owner = THIS_MODULE,
622 .open = all_open,
623 .read = seq_read,
624 .llseek = seq_lseek,
625 .release = seq_release
626};
627
628/*
451 * dump lkb's on the ls_waiters list 629 * dump lkb's on the ls_waiters list
452 */ 630 */
453 631
@@ -489,30 +667,33 @@ static const struct file_operations waiters_fops = {
489 .read = waiters_read 667 .read = waiters_read
490}; 668};
491 669
670void dlm_delete_debug_file(struct dlm_ls *ls)
671{
672 if (ls->ls_debug_rsb_dentry)
673 debugfs_remove(ls->ls_debug_rsb_dentry);
674 if (ls->ls_debug_waiters_dentry)
675 debugfs_remove(ls->ls_debug_waiters_dentry);
676 if (ls->ls_debug_locks_dentry)
677 debugfs_remove(ls->ls_debug_locks_dentry);
678 if (ls->ls_debug_all_dentry)
679 debugfs_remove(ls->ls_debug_all_dentry);
680}
681
492int dlm_create_debug_file(struct dlm_ls *ls) 682int dlm_create_debug_file(struct dlm_ls *ls)
493{ 683{
494 char name[DLM_LOCKSPACE_LEN+8]; 684 char name[DLM_LOCKSPACE_LEN+8];
495 685
686 /* format 1 */
687
496 ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name, 688 ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name,
497 S_IFREG | S_IRUGO, 689 S_IFREG | S_IRUGO,
498 dlm_root, 690 dlm_root,
499 ls, 691 ls,
500 &rsb_fops); 692 &rsb_fops);
501 if (!ls->ls_debug_rsb_dentry) 693 if (!ls->ls_debug_rsb_dentry)
502 return -ENOMEM; 694 goto fail;
503 695
504 memset(name, 0, sizeof(name)); 696 /* format 2 */
505 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_waiters", ls->ls_name);
506
507 ls->ls_debug_waiters_dentry = debugfs_create_file(name,
508 S_IFREG | S_IRUGO,
509 dlm_root,
510 ls,
511 &waiters_fops);
512 if (!ls->ls_debug_waiters_dentry) {
513 debugfs_remove(ls->ls_debug_rsb_dentry);
514 return -ENOMEM;
515 }
516 697
517 memset(name, 0, sizeof(name)); 698 memset(name, 0, sizeof(name));
518 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_locks", ls->ls_name); 699 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_locks", ls->ls_name);
@@ -522,23 +703,38 @@ int dlm_create_debug_file(struct dlm_ls *ls)
522 dlm_root, 703 dlm_root,
523 ls, 704 ls,
524 &locks_fops); 705 &locks_fops);
525 if (!ls->ls_debug_locks_dentry) { 706 if (!ls->ls_debug_locks_dentry)
526 debugfs_remove(ls->ls_debug_waiters_dentry); 707 goto fail;
527 debugfs_remove(ls->ls_debug_rsb_dentry); 708
528 return -ENOMEM; 709 /* format 3 */
529 } 710
711 memset(name, 0, sizeof(name));
712 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_all", ls->ls_name);
713
714 ls->ls_debug_all_dentry = debugfs_create_file(name,
715 S_IFREG | S_IRUGO,
716 dlm_root,
717 ls,
718 &all_fops);
719 if (!ls->ls_debug_all_dentry)
720 goto fail;
721
722 memset(name, 0, sizeof(name));
723 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_waiters", ls->ls_name);
724
725 ls->ls_debug_waiters_dentry = debugfs_create_file(name,
726 S_IFREG | S_IRUGO,
727 dlm_root,
728 ls,
729 &waiters_fops);
730 if (!ls->ls_debug_waiters_dentry)
731 goto fail;
530 732
531 return 0; 733 return 0;
532}
533 734
534void dlm_delete_debug_file(struct dlm_ls *ls) 735 fail:
535{ 736 dlm_delete_debug_file(ls);
536 if (ls->ls_debug_rsb_dentry) 737 return -ENOMEM;
537 debugfs_remove(ls->ls_debug_rsb_dentry);
538 if (ls->ls_debug_waiters_dentry)
539 debugfs_remove(ls->ls_debug_waiters_dentry);
540 if (ls->ls_debug_locks_dentry)
541 debugfs_remove(ls->ls_debug_locks_dentry);
542} 738}
543 739
544int __init dlm_register_debugfs(void) 740int __init dlm_register_debugfs(void)
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index 85defeb64df4..92969f879a17 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -374,7 +374,7 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
374 struct list_head *list; 374 struct list_head *list;
375 struct dlm_rsb *r; 375 struct dlm_rsb *r;
376 int offset = 0, dir_nodeid; 376 int offset = 0, dir_nodeid;
377 uint16_t be_namelen; 377 __be16 be_namelen;
378 378
379 down_read(&ls->ls_root_sem); 379 down_read(&ls->ls_root_sem);
380 380
@@ -410,15 +410,15 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
410 410
411 if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) { 411 if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) {
412 /* Write end-of-block record */ 412 /* Write end-of-block record */
413 be_namelen = 0; 413 be_namelen = cpu_to_be16(0);
414 memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 414 memcpy(outbuf + offset, &be_namelen, sizeof(__be16));
415 offset += sizeof(uint16_t); 415 offset += sizeof(__be16);
416 goto out; 416 goto out;
417 } 417 }
418 418
419 be_namelen = cpu_to_be16(r->res_length); 419 be_namelen = cpu_to_be16(r->res_length);
420 memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 420 memcpy(outbuf + offset, &be_namelen, sizeof(__be16));
421 offset += sizeof(uint16_t); 421 offset += sizeof(__be16);
422 memcpy(outbuf + offset, r->res_name, r->res_length); 422 memcpy(outbuf + offset, r->res_name, r->res_length);
423 offset += r->res_length; 423 offset += r->res_length;
424 } 424 }
@@ -430,9 +430,9 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
430 430
431 if ((list == &ls->ls_root_list) && 431 if ((list == &ls->ls_root_list) &&
432 (offset + sizeof(uint16_t) <= outlen)) { 432 (offset + sizeof(uint16_t) <= outlen)) {
433 be_namelen = 0xFFFF; 433 be_namelen = cpu_to_be16(0xFFFF);
434 memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 434 memcpy(outbuf + offset, &be_namelen, sizeof(__be16));
435 offset += sizeof(uint16_t); 435 offset += sizeof(__be16);
436 } 436 }
437 437
438 out: 438 out:
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 868e4c9ef127..ef2f1e353966 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -245,7 +245,8 @@ struct dlm_lkb {
245 struct list_head lkb_astqueue; /* need ast to be sent */ 245 struct list_head lkb_astqueue; /* need ast to be sent */
246 struct list_head lkb_ownqueue; /* list of locks for a process */ 246 struct list_head lkb_ownqueue; /* list of locks for a process */
247 struct list_head lkb_time_list; 247 struct list_head lkb_time_list;
248 unsigned long lkb_timestamp; 248 ktime_t lkb_time_bast; /* for debugging */
249 ktime_t lkb_timestamp;
249 unsigned long lkb_timeout_cs; 250 unsigned long lkb_timeout_cs;
250 251
251 char *lkb_lvbptr; 252 char *lkb_lvbptr;
@@ -481,6 +482,7 @@ struct dlm_ls {
481 struct dentry *ls_debug_rsb_dentry; /* debugfs */ 482 struct dentry *ls_debug_rsb_dentry; /* debugfs */
482 struct dentry *ls_debug_waiters_dentry; /* debugfs */ 483 struct dentry *ls_debug_waiters_dentry; /* debugfs */
483 struct dentry *ls_debug_locks_dentry; /* debugfs */ 484 struct dentry *ls_debug_locks_dentry; /* debugfs */
485 struct dentry *ls_debug_all_dentry; /* debugfs */
484 486
485 wait_queue_head_t ls_uevent_wait; /* user part of join/leave */ 487 wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
486 int ls_uevent_result; 488 int ls_uevent_result;
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 724ddac91538..6cfe65bbf4a2 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -307,7 +307,7 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv)
307 lkb->lkb_lksb->sb_status = rv; 307 lkb->lkb_lksb->sb_status = rv;
308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; 308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags;
309 309
310 dlm_add_ast(lkb, AST_COMP); 310 dlm_add_ast(lkb, AST_COMP, 0);
311} 311}
312 312
313static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) 313static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb)
@@ -318,12 +318,12 @@ static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb)
318 318
319static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) 319static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode)
320{ 320{
321 lkb->lkb_time_bast = ktime_get();
322
321 if (is_master_copy(lkb)) 323 if (is_master_copy(lkb))
322 send_bast(r, lkb, rqmode); 324 send_bast(r, lkb, rqmode);
323 else { 325 else
324 lkb->lkb_bastmode = rqmode; 326 dlm_add_ast(lkb, AST_BAST, rqmode);
325 dlm_add_ast(lkb, AST_BAST);
326 }
327} 327}
328 328
329/* 329/*
@@ -744,6 +744,8 @@ static void add_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb, int status)
744 744
745 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); 745 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););
746 746
747 lkb->lkb_timestamp = ktime_get();
748
747 lkb->lkb_status = status; 749 lkb->lkb_status = status;
748 750
749 switch (status) { 751 switch (status) {
@@ -1013,10 +1015,8 @@ static void add_timeout(struct dlm_lkb *lkb)
1013{ 1015{
1014 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1016 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
1015 1017
1016 if (is_master_copy(lkb)) { 1018 if (is_master_copy(lkb))
1017 lkb->lkb_timestamp = jiffies;
1018 return; 1019 return;
1019 }
1020 1020
1021 if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && 1021 if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) &&
1022 !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { 1022 !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) {
@@ -1031,7 +1031,6 @@ static void add_timeout(struct dlm_lkb *lkb)
1031 DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); 1031 DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb););
1032 mutex_lock(&ls->ls_timeout_mutex); 1032 mutex_lock(&ls->ls_timeout_mutex);
1033 hold_lkb(lkb); 1033 hold_lkb(lkb);
1034 lkb->lkb_timestamp = jiffies;
1035 list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); 1034 list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout);
1036 mutex_unlock(&ls->ls_timeout_mutex); 1035 mutex_unlock(&ls->ls_timeout_mutex);
1037} 1036}
@@ -1059,6 +1058,7 @@ void dlm_scan_timeout(struct dlm_ls *ls)
1059 struct dlm_rsb *r; 1058 struct dlm_rsb *r;
1060 struct dlm_lkb *lkb; 1059 struct dlm_lkb *lkb;
1061 int do_cancel, do_warn; 1060 int do_cancel, do_warn;
1061 s64 wait_us;
1062 1062
1063 for (;;) { 1063 for (;;) {
1064 if (dlm_locking_stopped(ls)) 1064 if (dlm_locking_stopped(ls))
@@ -1069,14 +1069,15 @@ void dlm_scan_timeout(struct dlm_ls *ls)
1069 mutex_lock(&ls->ls_timeout_mutex); 1069 mutex_lock(&ls->ls_timeout_mutex);
1070 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { 1070 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) {
1071 1071
1072 wait_us = ktime_to_us(ktime_sub(ktime_get(),
1073 lkb->lkb_timestamp));
1074
1072 if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && 1075 if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) &&
1073 time_after_eq(jiffies, lkb->lkb_timestamp + 1076 wait_us >= (lkb->lkb_timeout_cs * 10000))
1074 lkb->lkb_timeout_cs * HZ/100))
1075 do_cancel = 1; 1077 do_cancel = 1;
1076 1078
1077 if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && 1079 if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) &&
1078 time_after_eq(jiffies, lkb->lkb_timestamp + 1080 wait_us >= dlm_config.ci_timewarn_cs * 10000)
1079 dlm_config.ci_timewarn_cs * HZ/100))
1080 do_warn = 1; 1081 do_warn = 1;
1081 1082
1082 if (!do_cancel && !do_warn) 1083 if (!do_cancel && !do_warn)
@@ -1122,12 +1123,12 @@ void dlm_scan_timeout(struct dlm_ls *ls)
1122void dlm_adjust_timeouts(struct dlm_ls *ls) 1123void dlm_adjust_timeouts(struct dlm_ls *ls)
1123{ 1124{
1124 struct dlm_lkb *lkb; 1125 struct dlm_lkb *lkb;
1125 long adj = jiffies - ls->ls_recover_begin; 1126 u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin);
1126 1127
1127 ls->ls_recover_begin = 0; 1128 ls->ls_recover_begin = 0;
1128 mutex_lock(&ls->ls_timeout_mutex); 1129 mutex_lock(&ls->ls_timeout_mutex);
1129 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) 1130 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list)
1130 lkb->lkb_timestamp += adj; 1131 lkb->lkb_timestamp = ktime_add_us(lkb->lkb_timestamp, adj_us);
1131 mutex_unlock(&ls->ls_timeout_mutex); 1132 mutex_unlock(&ls->ls_timeout_mutex);
1132} 1133}
1133 1134
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 3962262f991a..103a5ebd1371 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -295,6 +295,7 @@ static int add_sock(struct socket *sock, struct connection *con)
295 con->sock->sk->sk_write_space = lowcomms_write_space; 295 con->sock->sk->sk_write_space = lowcomms_write_space;
296 con->sock->sk->sk_state_change = lowcomms_state_change; 296 con->sock->sk->sk_state_change = lowcomms_state_change;
297 con->sock->sk->sk_user_data = con; 297 con->sock->sk->sk_user_data = con;
298 con->sock->sk->sk_allocation = GFP_NOFS;
298 return 0; 299 return 0;
299} 300}
300 301
@@ -823,7 +824,6 @@ static void sctp_init_assoc(struct connection *con)
823 len = e->len; 824 len = e->len;
824 offset = e->offset; 825 offset = e->offset;
825 spin_unlock(&con->writequeue_lock); 826 spin_unlock(&con->writequeue_lock);
826 kmap(e->page);
827 827
828 /* Send the first block off the write queue */ 828 /* Send the first block off the write queue */
829 iov[0].iov_base = page_address(e->page)+offset; 829 iov[0].iov_base = page_address(e->page)+offset;
@@ -854,7 +854,6 @@ static void sctp_init_assoc(struct connection *con)
854 854
855 if (e->len == 0 && e->users == 0) { 855 if (e->len == 0 && e->users == 0) {
856 list_del(&e->list); 856 list_del(&e->list);
857 kunmap(e->page);
858 free_entry(e); 857 free_entry(e);
859 } 858 }
860 spin_unlock(&con->writequeue_lock); 859 spin_unlock(&con->writequeue_lock);
@@ -1203,8 +1202,6 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
1203 1202
1204 if (e) { 1203 if (e) {
1205 got_one: 1204 got_one:
1206 if (users == 0)
1207 kmap(e->page);
1208 *ppc = page_address(e->page) + offset; 1205 *ppc = page_address(e->page) + offset;
1209 return e; 1206 return e;
1210 } 1207 }
@@ -1233,7 +1230,6 @@ void dlm_lowcomms_commit_buffer(void *mh)
1233 if (users) 1230 if (users)
1234 goto out; 1231 goto out;
1235 e->len = e->end - e->offset; 1232 e->len = e->end - e->offset;
1236 kunmap(e->page);
1237 spin_unlock(&con->writequeue_lock); 1233 spin_unlock(&con->writequeue_lock);
1238 1234
1239 if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) { 1235 if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) {
@@ -1272,7 +1268,6 @@ static void send_to_sock(struct connection *con)
1272 offset = e->offset; 1268 offset = e->offset;
1273 BUG_ON(len == 0 && e->users == 0); 1269 BUG_ON(len == 0 && e->users == 0);
1274 spin_unlock(&con->writequeue_lock); 1270 spin_unlock(&con->writequeue_lock);
1275 kmap(e->page);
1276 1271
1277 ret = 0; 1272 ret = 0;
1278 if (len) { 1273 if (len) {
@@ -1294,7 +1289,6 @@ static void send_to_sock(struct connection *con)
1294 1289
1295 if (e->len == 0 && e->users == 0) { 1290 if (e->len == 0 && e->users == 0) {
1296 list_del(&e->list); 1291 list_del(&e->list);
1297 kunmap(e->page);
1298 free_entry(e); 1292 free_entry(e);
1299 continue; 1293 continue;
1300 } 1294 }
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index 54c14c6d06cb..c1775b84ebab 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -39,7 +39,7 @@ char *dlm_allocate_lvb(struct dlm_ls *ls)
39{ 39{
40 char *p; 40 char *p;
41 41
42 p = kzalloc(ls->ls_lvblen, GFP_KERNEL); 42 p = kzalloc(ls->ls_lvblen, ls->ls_allocation);
43 return p; 43 return p;
44} 44}
45 45
@@ -57,7 +57,7 @@ struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen)
57 57
58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,); 58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,);
59 59
60 r = kzalloc(sizeof(*r) + namelen, GFP_KERNEL); 60 r = kzalloc(sizeof(*r) + namelen, ls->ls_allocation);
61 return r; 61 return r;
62} 62}
63 63
@@ -72,7 +72,7 @@ struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
72{ 72{
73 struct dlm_lkb *lkb; 73 struct dlm_lkb *lkb;
74 74
75 lkb = kmem_cache_zalloc(lkb_cache, GFP_KERNEL); 75 lkb = kmem_cache_zalloc(lkb_cache, ls->ls_allocation);
76 return lkb; 76 return lkb;
77} 77}
78 78
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 07ac709f3ed7..f3396c622aec 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -112,7 +112,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base,
112 ordinary messages). */ 112 ordinary messages). */
113 113
114 if (msglen > sizeof(__tmp) && p == &__tmp.p) { 114 if (msglen > sizeof(__tmp) && p == &__tmp.p) {
115 p = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); 115 p = kmalloc(dlm_config.ci_buffer_size, GFP_NOFS);
116 if (p == NULL) 116 if (p == NULL)
117 return ret; 117 return ret;
118 } 118 }
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index aa2a5775a027..ccc9d62c462d 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -115,7 +115,6 @@ static void fill_data(struct dlm_lock_data *data, struct dlm_lkb *lkb)
115 data->status = lkb->lkb_status; 115 data->status = lkb->lkb_status;
116 data->grmode = lkb->lkb_grmode; 116 data->grmode = lkb->lkb_grmode;
117 data->rqmode = lkb->lkb_rqmode; 117 data->rqmode = lkb->lkb_rqmode;
118 data->timestamp = lkb->lkb_timestamp;
119 if (lkb->lkb_ua) 118 if (lkb->lkb_ua)
120 data->xid = lkb->lkb_ua->xid; 119 data->xid = lkb->lkb_ua->xid;
121 if (r) { 120 if (r) {
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index b3832c67194a..065149e84f42 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -175,7 +175,7 @@ static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type)
175/* we could possibly check if the cancel of an orphan has resulted in the lkb 175/* we could possibly check if the cancel of an orphan has resulted in the lkb
176 being removed and then remove that lkb from the orphans list and free it */ 176 being removed and then remove that lkb from the orphans list and free it */
177 177
178void dlm_user_add_ast(struct dlm_lkb *lkb, int type) 178void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
179{ 179{
180 struct dlm_ls *ls; 180 struct dlm_ls *ls;
181 struct dlm_user_args *ua; 181 struct dlm_user_args *ua;
@@ -208,6 +208,8 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type)
208 208
209 ast_type = lkb->lkb_ast_type; 209 ast_type = lkb->lkb_ast_type;
210 lkb->lkb_ast_type |= type; 210 lkb->lkb_ast_type |= type;
211 if (bastmode)
212 lkb->lkb_bastmode = bastmode;
211 213
212 if (!ast_type) { 214 if (!ast_type) {
213 kref_get(&lkb->lkb_ref); 215 kref_get(&lkb->lkb_ref);
diff --git a/fs/dlm/user.h b/fs/dlm/user.h
index 35eb6a13d616..1c9686492286 100644
--- a/fs/dlm/user.h
+++ b/fs/dlm/user.h
@@ -9,7 +9,7 @@
9#ifndef __USER_DOT_H__ 9#ifndef __USER_DOT_H__
10#define __USER_DOT_H__ 10#define __USER_DOT_H__
11 11
12void dlm_user_add_ast(struct dlm_lkb *lkb, int type); 12void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode);
13int dlm_user_init(void); 13int dlm_user_init(void);
14void dlm_user_exit(void); 14void dlm_user_exit(void);
15int dlm_device_deregister(struct dlm_ls *ls); 15int dlm_device_deregister(struct dlm_ls *ls);
diff --git a/fs/dquot.c b/fs/dquot.c
index c237ccc8581c..61bfff64e5af 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -211,8 +211,6 @@ static struct hlist_head *dquot_hash;
211 211
212struct dqstats dqstats; 212struct dqstats dqstats;
213 213
214static void dqput(struct dquot *dquot);
215
216static inline unsigned int 214static inline unsigned int
217hashfn(const struct super_block *sb, unsigned int id, int type) 215hashfn(const struct super_block *sb, unsigned int id, int type)
218{ 216{
@@ -415,6 +413,17 @@ out_dqlock:
415 return ret; 413 return ret;
416} 414}
417 415
416void dquot_destroy(struct dquot *dquot)
417{
418 kmem_cache_free(dquot_cachep, dquot);
419}
420EXPORT_SYMBOL(dquot_destroy);
421
422static inline void do_destroy_dquot(struct dquot *dquot)
423{
424 dquot->dq_sb->dq_op->destroy_dquot(dquot);
425}
426
418/* Invalidate all dquots on the list. Note that this function is called after 427/* Invalidate all dquots on the list. Note that this function is called after
419 * quota is disabled and pointers from inodes removed so there cannot be new 428 * quota is disabled and pointers from inodes removed so there cannot be new
420 * quota users. There can still be some users of quotas due to inodes being 429 * quota users. There can still be some users of quotas due to inodes being
@@ -463,9 +472,44 @@ restart:
463 remove_dquot_hash(dquot); 472 remove_dquot_hash(dquot);
464 remove_free_dquot(dquot); 473 remove_free_dquot(dquot);
465 remove_inuse(dquot); 474 remove_inuse(dquot);
466 kmem_cache_free(dquot_cachep, dquot); 475 do_destroy_dquot(dquot);
476 }
477 spin_unlock(&dq_list_lock);
478}
479
480/* Call callback for every active dquot on given filesystem */
481int dquot_scan_active(struct super_block *sb,
482 int (*fn)(struct dquot *dquot, unsigned long priv),
483 unsigned long priv)
484{
485 struct dquot *dquot, *old_dquot = NULL;
486 int ret = 0;
487
488 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
489 spin_lock(&dq_list_lock);
490 list_for_each_entry(dquot, &inuse_list, dq_inuse) {
491 if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
492 continue;
493 if (dquot->dq_sb != sb)
494 continue;
495 /* Now we have active dquot so we can just increase use count */
496 atomic_inc(&dquot->dq_count);
497 dqstats.lookups++;
498 spin_unlock(&dq_list_lock);
499 dqput(old_dquot);
500 old_dquot = dquot;
501 ret = fn(dquot, priv);
502 if (ret < 0)
503 goto out;
504 spin_lock(&dq_list_lock);
505 /* We are safe to continue now because our dquot could not
506 * be moved out of the inuse list while we hold the reference */
467 } 507 }
468 spin_unlock(&dq_list_lock); 508 spin_unlock(&dq_list_lock);
509out:
510 dqput(old_dquot);
511 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
512 return ret;
469} 513}
470 514
471int vfs_quota_sync(struct super_block *sb, int type) 515int vfs_quota_sync(struct super_block *sb, int type)
@@ -479,7 +523,7 @@ int vfs_quota_sync(struct super_block *sb, int type)
479 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 523 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
480 if (type != -1 && cnt != type) 524 if (type != -1 && cnt != type)
481 continue; 525 continue;
482 if (!sb_has_quota_enabled(sb, cnt)) 526 if (!sb_has_quota_active(sb, cnt))
483 continue; 527 continue;
484 spin_lock(&dq_list_lock); 528 spin_lock(&dq_list_lock);
485 dirty = &dqopt->info[cnt].dqi_dirty_list; 529 dirty = &dqopt->info[cnt].dqi_dirty_list;
@@ -504,8 +548,8 @@ int vfs_quota_sync(struct super_block *sb, int type)
504 } 548 }
505 549
506 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 550 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
507 if ((cnt == type || type == -1) && sb_has_quota_enabled(sb, cnt) 551 if ((cnt == type || type == -1) && sb_has_quota_active(sb, cnt)
508 && info_dirty(&dqopt->info[cnt])) 552 && info_dirty(&dqopt->info[cnt]))
509 sb->dq_op->write_info(sb, cnt); 553 sb->dq_op->write_info(sb, cnt);
510 spin_lock(&dq_list_lock); 554 spin_lock(&dq_list_lock);
511 dqstats.syncs++; 555 dqstats.syncs++;
@@ -527,7 +571,7 @@ static void prune_dqcache(int count)
527 remove_dquot_hash(dquot); 571 remove_dquot_hash(dquot);
528 remove_free_dquot(dquot); 572 remove_free_dquot(dquot);
529 remove_inuse(dquot); 573 remove_inuse(dquot);
530 kmem_cache_free(dquot_cachep, dquot); 574 do_destroy_dquot(dquot);
531 count--; 575 count--;
532 head = free_dquots.prev; 576 head = free_dquots.prev;
533 } 577 }
@@ -558,7 +602,7 @@ static struct shrinker dqcache_shrinker = {
558 * NOTE: If you change this function please check whether dqput_blocks() works right... 602 * NOTE: If you change this function please check whether dqput_blocks() works right...
559 * MUST be called with either dqptr_sem or dqonoff_mutex held 603 * MUST be called with either dqptr_sem or dqonoff_mutex held
560 */ 604 */
561static void dqput(struct dquot *dquot) 605void dqput(struct dquot *dquot)
562{ 606{
563 int ret; 607 int ret;
564 608
@@ -584,7 +628,7 @@ we_slept:
584 /* We have more than one user... nothing to do */ 628 /* We have more than one user... nothing to do */
585 atomic_dec(&dquot->dq_count); 629 atomic_dec(&dquot->dq_count);
586 /* Releasing dquot during quotaoff phase? */ 630 /* Releasing dquot during quotaoff phase? */
587 if (!sb_has_quota_enabled(dquot->dq_sb, dquot->dq_type) && 631 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_type) &&
588 atomic_read(&dquot->dq_count) == 1) 632 atomic_read(&dquot->dq_count) == 1)
589 wake_up(&dquot->dq_wait_unused); 633 wake_up(&dquot->dq_wait_unused);
590 spin_unlock(&dq_list_lock); 634 spin_unlock(&dq_list_lock);
@@ -625,11 +669,17 @@ we_slept:
625 spin_unlock(&dq_list_lock); 669 spin_unlock(&dq_list_lock);
626} 670}
627 671
672struct dquot *dquot_alloc(struct super_block *sb, int type)
673{
674 return kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
675}
676EXPORT_SYMBOL(dquot_alloc);
677
628static struct dquot *get_empty_dquot(struct super_block *sb, int type) 678static struct dquot *get_empty_dquot(struct super_block *sb, int type)
629{ 679{
630 struct dquot *dquot; 680 struct dquot *dquot;
631 681
632 dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS); 682 dquot = sb->dq_op->alloc_dquot(sb, type);
633 if(!dquot) 683 if(!dquot)
634 return NODQUOT; 684 return NODQUOT;
635 685
@@ -647,15 +697,33 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
647} 697}
648 698
649/* 699/*
700 * Check whether dquot is in memory.
701 * MUST be called with either dqptr_sem or dqonoff_mutex held
702 */
703int dquot_is_cached(struct super_block *sb, unsigned int id, int type)
704{
705 unsigned int hashent = hashfn(sb, id, type);
706 int ret = 0;
707
708 if (!sb_has_quota_active(sb, type))
709 return 0;
710 spin_lock(&dq_list_lock);
711 if (find_dquot(hashent, sb, id, type) != NODQUOT)
712 ret = 1;
713 spin_unlock(&dq_list_lock);
714 return ret;
715}
716
717/*
650 * Get reference to dquot 718 * Get reference to dquot
651 * MUST be called with either dqptr_sem or dqonoff_mutex held 719 * MUST be called with either dqptr_sem or dqonoff_mutex held
652 */ 720 */
653static struct dquot *dqget(struct super_block *sb, unsigned int id, int type) 721struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
654{ 722{
655 unsigned int hashent = hashfn(sb, id, type); 723 unsigned int hashent = hashfn(sb, id, type);
656 struct dquot *dquot, *empty = NODQUOT; 724 struct dquot *dquot, *empty = NODQUOT;
657 725
658 if (!sb_has_quota_enabled(sb, type)) 726 if (!sb_has_quota_active(sb, type))
659 return NODQUOT; 727 return NODQUOT;
660we_slept: 728we_slept:
661 spin_lock(&dq_list_lock); 729 spin_lock(&dq_list_lock);
@@ -682,7 +750,7 @@ we_slept:
682 dqstats.lookups++; 750 dqstats.lookups++;
683 spin_unlock(&dq_list_lock); 751 spin_unlock(&dq_list_lock);
684 if (empty) 752 if (empty)
685 kmem_cache_free(dquot_cachep, empty); 753 do_destroy_dquot(empty);
686 } 754 }
687 /* Wait for dq_lock - after this we know that either dquot_release() is already 755 /* Wait for dq_lock - after this we know that either dquot_release() is already
688 * finished or it will be canceled due to dq_count > 1 test */ 756 * finished or it will be canceled due to dq_count > 1 test */
@@ -820,7 +888,7 @@ static void drop_dquot_ref(struct super_block *sb, int type)
820 } 888 }
821} 889}
822 890
823static inline void dquot_incr_inodes(struct dquot *dquot, unsigned long number) 891static inline void dquot_incr_inodes(struct dquot *dquot, qsize_t number)
824{ 892{
825 dquot->dq_dqb.dqb_curinodes += number; 893 dquot->dq_dqb.dqb_curinodes += number;
826} 894}
@@ -830,9 +898,10 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number)
830 dquot->dq_dqb.dqb_curspace += number; 898 dquot->dq_dqb.dqb_curspace += number;
831} 899}
832 900
833static inline void dquot_decr_inodes(struct dquot *dquot, unsigned long number) 901static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
834{ 902{
835 if (dquot->dq_dqb.dqb_curinodes > number) 903 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
904 dquot->dq_dqb.dqb_curinodes >= number)
836 dquot->dq_dqb.dqb_curinodes -= number; 905 dquot->dq_dqb.dqb_curinodes -= number;
837 else 906 else
838 dquot->dq_dqb.dqb_curinodes = 0; 907 dquot->dq_dqb.dqb_curinodes = 0;
@@ -843,11 +912,12 @@ static inline void dquot_decr_inodes(struct dquot *dquot, unsigned long number)
843 912
844static inline void dquot_decr_space(struct dquot *dquot, qsize_t number) 913static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
845{ 914{
846 if (dquot->dq_dqb.dqb_curspace > number) 915 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
916 dquot->dq_dqb.dqb_curspace >= number)
847 dquot->dq_dqb.dqb_curspace -= number; 917 dquot->dq_dqb.dqb_curspace -= number;
848 else 918 else
849 dquot->dq_dqb.dqb_curspace = 0; 919 dquot->dq_dqb.dqb_curspace = 0;
850 if (toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit) 920 if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
851 dquot->dq_dqb.dqb_btime = (time_t) 0; 921 dquot->dq_dqb.dqb_btime = (time_t) 0;
852 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 922 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
853} 923}
@@ -1023,10 +1093,11 @@ static inline char ignore_hardlimit(struct dquot *dquot)
1023} 1093}
1024 1094
1025/* needs dq_data_lock */ 1095/* needs dq_data_lock */
1026static int check_idq(struct dquot *dquot, ulong inodes, char *warntype) 1096static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
1027{ 1097{
1028 *warntype = QUOTA_NL_NOWARN; 1098 *warntype = QUOTA_NL_NOWARN;
1029 if (inodes <= 0 || test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1099 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) ||
1100 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1030 return QUOTA_OK; 1101 return QUOTA_OK;
1031 1102
1032 if (dquot->dq_dqb.dqb_ihardlimit && 1103 if (dquot->dq_dqb.dqb_ihardlimit &&
@@ -1058,11 +1129,12 @@ static int check_idq(struct dquot *dquot, ulong inodes, char *warntype)
1058static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype) 1129static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *warntype)
1059{ 1130{
1060 *warntype = QUOTA_NL_NOWARN; 1131 *warntype = QUOTA_NL_NOWARN;
1061 if (space <= 0 || test_bit(DQ_FAKE_B, &dquot->dq_flags)) 1132 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type) ||
1133 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1062 return QUOTA_OK; 1134 return QUOTA_OK;
1063 1135
1064 if (dquot->dq_dqb.dqb_bhardlimit && 1136 if (dquot->dq_dqb.dqb_bhardlimit &&
1065 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bhardlimit && 1137 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bhardlimit &&
1066 !ignore_hardlimit(dquot)) { 1138 !ignore_hardlimit(dquot)) {
1067 if (!prealloc) 1139 if (!prealloc)
1068 *warntype = QUOTA_NL_BHARDWARN; 1140 *warntype = QUOTA_NL_BHARDWARN;
@@ -1070,7 +1142,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1070 } 1142 }
1071 1143
1072 if (dquot->dq_dqb.dqb_bsoftlimit && 1144 if (dquot->dq_dqb.dqb_bsoftlimit &&
1073 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit && 1145 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
1074 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime && 1146 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime &&
1075 !ignore_hardlimit(dquot)) { 1147 !ignore_hardlimit(dquot)) {
1076 if (!prealloc) 1148 if (!prealloc)
@@ -1079,7 +1151,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1079 } 1151 }
1080 1152
1081 if (dquot->dq_dqb.dqb_bsoftlimit && 1153 if (dquot->dq_dqb.dqb_bsoftlimit &&
1082 toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit && 1154 dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
1083 dquot->dq_dqb.dqb_btime == 0) { 1155 dquot->dq_dqb.dqb_btime == 0) {
1084 if (!prealloc) { 1156 if (!prealloc) {
1085 *warntype = QUOTA_NL_BSOFTWARN; 1157 *warntype = QUOTA_NL_BSOFTWARN;
@@ -1096,10 +1168,11 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
1096 return QUOTA_OK; 1168 return QUOTA_OK;
1097} 1169}
1098 1170
1099static int info_idq_free(struct dquot *dquot, ulong inodes) 1171static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1100{ 1172{
1101 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1173 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1102 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit) 1174 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1175 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_type))
1103 return QUOTA_NL_NOWARN; 1176 return QUOTA_NL_NOWARN;
1104 1177
1105 if (dquot->dq_dqb.dqb_curinodes - inodes <= dquot->dq_dqb.dqb_isoftlimit) 1178 if (dquot->dq_dqb.dqb_curinodes - inodes <= dquot->dq_dqb.dqb_isoftlimit)
@@ -1113,15 +1186,13 @@ static int info_idq_free(struct dquot *dquot, ulong inodes)
1113static int info_bdq_free(struct dquot *dquot, qsize_t space) 1186static int info_bdq_free(struct dquot *dquot, qsize_t space)
1114{ 1187{
1115 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1188 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1116 toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit) 1189 dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
1117 return QUOTA_NL_NOWARN; 1190 return QUOTA_NL_NOWARN;
1118 1191
1119 if (toqb(dquot->dq_dqb.dqb_curspace - space) <= 1192 if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
1120 dquot->dq_dqb.dqb_bsoftlimit)
1121 return QUOTA_NL_BSOFTBELOW; 1193 return QUOTA_NL_BSOFTBELOW;
1122 if (toqb(dquot->dq_dqb.dqb_curspace) >= dquot->dq_dqb.dqb_bhardlimit && 1194 if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
1123 toqb(dquot->dq_dqb.dqb_curspace - space) < 1195 dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
1124 dquot->dq_dqb.dqb_bhardlimit)
1125 return QUOTA_NL_BHARDBELOW; 1196 return QUOTA_NL_BHARDBELOW;
1126 return QUOTA_NL_NOWARN; 1197 return QUOTA_NL_NOWARN;
1127} 1198}
@@ -1166,17 +1237,23 @@ out_err:
1166 * Release all quotas referenced by inode 1237 * Release all quotas referenced by inode
1167 * Transaction must be started at an entry 1238 * Transaction must be started at an entry
1168 */ 1239 */
1169int dquot_drop(struct inode *inode) 1240int dquot_drop_locked(struct inode *inode)
1170{ 1241{
1171 int cnt; 1242 int cnt;
1172 1243
1173 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1174 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1244 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1175 if (inode->i_dquot[cnt] != NODQUOT) { 1245 if (inode->i_dquot[cnt] != NODQUOT) {
1176 dqput(inode->i_dquot[cnt]); 1246 dqput(inode->i_dquot[cnt]);
1177 inode->i_dquot[cnt] = NODQUOT; 1247 inode->i_dquot[cnt] = NODQUOT;
1178 } 1248 }
1179 } 1249 }
1250 return 0;
1251}
1252
1253int dquot_drop(struct inode *inode)
1254{
1255 down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1256 dquot_drop_locked(inode);
1180 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); 1257 up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
1181 return 0; 1258 return 0;
1182} 1259}
@@ -1264,7 +1341,7 @@ warn_put_all:
1264/* 1341/*
1265 * This operation can block, but only after everything is updated 1342 * This operation can block, but only after everything is updated
1266 */ 1343 */
1267int dquot_alloc_inode(const struct inode *inode, unsigned long number) 1344int dquot_alloc_inode(const struct inode *inode, qsize_t number)
1268{ 1345{
1269 int cnt, ret = NO_QUOTA; 1346 int cnt, ret = NO_QUOTA;
1270 char warntype[MAXQUOTAS]; 1347 char warntype[MAXQUOTAS];
@@ -1349,7 +1426,7 @@ out_sub:
1349/* 1426/*
1350 * This operation can block, but only after everything is updated 1427 * This operation can block, but only after everything is updated
1351 */ 1428 */
1352int dquot_free_inode(const struct inode *inode, unsigned long number) 1429int dquot_free_inode(const struct inode *inode, qsize_t number)
1353{ 1430{
1354 unsigned int cnt; 1431 unsigned int cnt;
1355 char warntype[MAXQUOTAS]; 1432 char warntype[MAXQUOTAS];
@@ -1495,7 +1572,7 @@ warn_put_all:
1495/* Wrapper for transferring ownership of an inode */ 1572/* Wrapper for transferring ownership of an inode */
1496int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) 1573int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
1497{ 1574{
1498 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { 1575 if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
1499 vfs_dq_init(inode); 1576 vfs_dq_init(inode);
1500 if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA) 1577 if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA)
1501 return 1; 1578 return 1;
@@ -1533,54 +1610,27 @@ struct dquot_operations dquot_operations = {
1533 .acquire_dquot = dquot_acquire, 1610 .acquire_dquot = dquot_acquire,
1534 .release_dquot = dquot_release, 1611 .release_dquot = dquot_release,
1535 .mark_dirty = dquot_mark_dquot_dirty, 1612 .mark_dirty = dquot_mark_dquot_dirty,
1536 .write_info = dquot_commit_info 1613 .write_info = dquot_commit_info,
1614 .alloc_dquot = dquot_alloc,
1615 .destroy_dquot = dquot_destroy,
1537}; 1616};
1538 1617
1539static inline void set_enable_flags(struct quota_info *dqopt, int type)
1540{
1541 switch (type) {
1542 case USRQUOTA:
1543 dqopt->flags |= DQUOT_USR_ENABLED;
1544 dqopt->flags &= ~DQUOT_USR_SUSPENDED;
1545 break;
1546 case GRPQUOTA:
1547 dqopt->flags |= DQUOT_GRP_ENABLED;
1548 dqopt->flags &= ~DQUOT_GRP_SUSPENDED;
1549 break;
1550 }
1551}
1552
1553static inline void reset_enable_flags(struct quota_info *dqopt, int type,
1554 int remount)
1555{
1556 switch (type) {
1557 case USRQUOTA:
1558 dqopt->flags &= ~DQUOT_USR_ENABLED;
1559 if (remount)
1560 dqopt->flags |= DQUOT_USR_SUSPENDED;
1561 else
1562 dqopt->flags &= ~DQUOT_USR_SUSPENDED;
1563 break;
1564 case GRPQUOTA:
1565 dqopt->flags &= ~DQUOT_GRP_ENABLED;
1566 if (remount)
1567 dqopt->flags |= DQUOT_GRP_SUSPENDED;
1568 else
1569 dqopt->flags &= ~DQUOT_GRP_SUSPENDED;
1570 break;
1571 }
1572}
1573
1574
1575/* 1618/*
1576 * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount) 1619 * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
1577 */ 1620 */
1578int vfs_quota_off(struct super_block *sb, int type, int remount) 1621int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags)
1579{ 1622{
1580 int cnt, ret = 0; 1623 int cnt, ret = 0;
1581 struct quota_info *dqopt = sb_dqopt(sb); 1624 struct quota_info *dqopt = sb_dqopt(sb);
1582 struct inode *toputinode[MAXQUOTAS]; 1625 struct inode *toputinode[MAXQUOTAS];
1583 1626
1627 /* Cannot turn off usage accounting without turning off limits, or
1628 * suspend quotas and simultaneously turn quotas off. */
1629 if ((flags & DQUOT_USAGE_ENABLED && !(flags & DQUOT_LIMITS_ENABLED))
1630 || (flags & DQUOT_SUSPENDED && flags & (DQUOT_LIMITS_ENABLED |
1631 DQUOT_USAGE_ENABLED)))
1632 return -EINVAL;
1633
1584 /* We need to serialize quota_off() for device */ 1634 /* We need to serialize quota_off() for device */
1585 mutex_lock(&dqopt->dqonoff_mutex); 1635 mutex_lock(&dqopt->dqonoff_mutex);
1586 1636
@@ -1589,7 +1639,7 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1589 * sometimes we are called when fill_super() failed and calling 1639 * sometimes we are called when fill_super() failed and calling
1590 * sync_fs() in such cases does no good. 1640 * sync_fs() in such cases does no good.
1591 */ 1641 */
1592 if (!sb_any_quota_enabled(sb) && !sb_any_quota_suspended(sb)) { 1642 if (!sb_any_quota_loaded(sb)) {
1593 mutex_unlock(&dqopt->dqonoff_mutex); 1643 mutex_unlock(&dqopt->dqonoff_mutex);
1594 return 0; 1644 return 0;
1595 } 1645 }
@@ -1597,17 +1647,28 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1597 toputinode[cnt] = NULL; 1647 toputinode[cnt] = NULL;
1598 if (type != -1 && cnt != type) 1648 if (type != -1 && cnt != type)
1599 continue; 1649 continue;
1600 /* If we keep inodes of quota files after remount and quotaoff 1650 if (!sb_has_quota_loaded(sb, cnt))
1601 * is called, drop kept inodes. */
1602 if (!remount && sb_has_quota_suspended(sb, cnt)) {
1603 iput(dqopt->files[cnt]);
1604 dqopt->files[cnt] = NULL;
1605 reset_enable_flags(dqopt, cnt, 0);
1606 continue; 1651 continue;
1652
1653 if (flags & DQUOT_SUSPENDED) {
1654 dqopt->flags |=
1655 dquot_state_flag(DQUOT_SUSPENDED, cnt);
1656 } else {
1657 dqopt->flags &= ~dquot_state_flag(flags, cnt);
1658 /* Turning off suspended quotas? */
1659 if (!sb_has_quota_loaded(sb, cnt) &&
1660 sb_has_quota_suspended(sb, cnt)) {
1661 dqopt->flags &= ~dquot_state_flag(
1662 DQUOT_SUSPENDED, cnt);
1663 iput(dqopt->files[cnt]);
1664 dqopt->files[cnt] = NULL;
1665 continue;
1666 }
1607 } 1667 }
1608 if (!sb_has_quota_enabled(sb, cnt)) 1668
1669 /* We still have to keep quota loaded? */
1670 if (sb_has_quota_loaded(sb, cnt) && !(flags & DQUOT_SUSPENDED))
1609 continue; 1671 continue;
1610 reset_enable_flags(dqopt, cnt, remount);
1611 1672
1612 /* Note: these are blocking operations */ 1673 /* Note: these are blocking operations */
1613 drop_dquot_ref(sb, cnt); 1674 drop_dquot_ref(sb, cnt);
@@ -1623,7 +1684,7 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1623 put_quota_format(dqopt->info[cnt].dqi_format); 1684 put_quota_format(dqopt->info[cnt].dqi_format);
1624 1685
1625 toputinode[cnt] = dqopt->files[cnt]; 1686 toputinode[cnt] = dqopt->files[cnt];
1626 if (!remount) 1687 if (!sb_has_quota_loaded(sb, cnt))
1627 dqopt->files[cnt] = NULL; 1688 dqopt->files[cnt] = NULL;
1628 dqopt->info[cnt].dqi_flags = 0; 1689 dqopt->info[cnt].dqi_flags = 0;
1629 dqopt->info[cnt].dqi_igrace = 0; 1690 dqopt->info[cnt].dqi_igrace = 0;
@@ -1631,6 +1692,11 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1631 dqopt->ops[cnt] = NULL; 1692 dqopt->ops[cnt] = NULL;
1632 } 1693 }
1633 mutex_unlock(&dqopt->dqonoff_mutex); 1694 mutex_unlock(&dqopt->dqonoff_mutex);
1695
1696 /* Skip syncing and setting flags if quota files are hidden */
1697 if (dqopt->flags & DQUOT_QUOTA_SYS_FILE)
1698 goto put_inodes;
1699
1634 /* Sync the superblock so that buffers with quota data are written to 1700 /* Sync the superblock so that buffers with quota data are written to
1635 * disk (and so userspace sees correct data afterwards). */ 1701 * disk (and so userspace sees correct data afterwards). */
1636 if (sb->s_op->sync_fs) 1702 if (sb->s_op->sync_fs)
@@ -1646,7 +1712,7 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1646 mutex_lock(&dqopt->dqonoff_mutex); 1712 mutex_lock(&dqopt->dqonoff_mutex);
1647 /* If quota was reenabled in the meantime, we have 1713 /* If quota was reenabled in the meantime, we have
1648 * nothing to do */ 1714 * nothing to do */
1649 if (!sb_has_quota_enabled(sb, cnt)) { 1715 if (!sb_has_quota_loaded(sb, cnt)) {
1650 mutex_lock_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA); 1716 mutex_lock_nested(&toputinode[cnt]->i_mutex, I_MUTEX_QUOTA);
1651 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 1717 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
1652 S_NOATIME | S_NOQUOTA); 1718 S_NOATIME | S_NOQUOTA);
@@ -1655,26 +1721,43 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1655 mark_inode_dirty(toputinode[cnt]); 1721 mark_inode_dirty(toputinode[cnt]);
1656 } 1722 }
1657 mutex_unlock(&dqopt->dqonoff_mutex); 1723 mutex_unlock(&dqopt->dqonoff_mutex);
1724 }
1725 if (sb->s_bdev)
1726 invalidate_bdev(sb->s_bdev);
1727put_inodes:
1728 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
1729 if (toputinode[cnt]) {
1658 /* On remount RO, we keep the inode pointer so that we 1730 /* On remount RO, we keep the inode pointer so that we
1659 * can reenable quota on the subsequent remount RW. 1731 * can reenable quota on the subsequent remount RW. We
1660 * But we have better not keep inode pointer when there 1732 * have to check 'flags' variable and not use sb_has_
1661 * is pending delete on the quota file... */ 1733 * function because another quotaon / quotaoff could
1662 if (!remount) 1734 * change global state before we got here. We refuse
1735 * to suspend quotas when there is pending delete on
1736 * the quota file... */
1737 if (!(flags & DQUOT_SUSPENDED))
1663 iput(toputinode[cnt]); 1738 iput(toputinode[cnt]);
1664 else if (!toputinode[cnt]->i_nlink) 1739 else if (!toputinode[cnt]->i_nlink)
1665 ret = -EBUSY; 1740 ret = -EBUSY;
1666 } 1741 }
1667 if (sb->s_bdev)
1668 invalidate_bdev(sb->s_bdev);
1669 return ret; 1742 return ret;
1670} 1743}
1671 1744
1745int vfs_quota_off(struct super_block *sb, int type, int remount)
1746{
1747 return vfs_quota_disable(sb, type, remount ? DQUOT_SUSPENDED :
1748 (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED));
1749}
1750
1672/* 1751/*
1673 * Turn quotas on on a device 1752 * Turn quotas on on a device
1674 */ 1753 */
1675 1754
1676/* Helper function when we already have the inode */ 1755/*
1677static int vfs_quota_on_inode(struct inode *inode, int type, int format_id) 1756 * Helper function to turn quotas on when we already have the inode of
1757 * quota file and no quota information is loaded.
1758 */
1759static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
1760 unsigned int flags)
1678{ 1761{
1679 struct quota_format_type *fmt = find_quota_format(format_id); 1762 struct quota_format_type *fmt = find_quota_format(format_id);
1680 struct super_block *sb = inode->i_sb; 1763 struct super_block *sb = inode->i_sb;
@@ -1696,27 +1779,37 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1696 error = -EINVAL; 1779 error = -EINVAL;
1697 goto out_fmt; 1780 goto out_fmt;
1698 } 1781 }
1782 /* Usage always has to be set... */
1783 if (!(flags & DQUOT_USAGE_ENABLED)) {
1784 error = -EINVAL;
1785 goto out_fmt;
1786 }
1699 1787
1700 /* As we bypass the pagecache we must now flush the inode so that 1788 if (!(dqopt->flags & DQUOT_QUOTA_SYS_FILE)) {
1701 * we see all the changes from userspace... */ 1789 /* As we bypass the pagecache we must now flush the inode so
1702 write_inode_now(inode, 1); 1790 * that we see all the changes from userspace... */
1703 /* And now flush the block cache so that kernel sees the changes */ 1791 write_inode_now(inode, 1);
1704 invalidate_bdev(sb->s_bdev); 1792 /* And now flush the block cache so that kernel sees the
1793 * changes */
1794 invalidate_bdev(sb->s_bdev);
1795 }
1705 mutex_lock(&inode->i_mutex); 1796 mutex_lock(&inode->i_mutex);
1706 mutex_lock(&dqopt->dqonoff_mutex); 1797 mutex_lock(&dqopt->dqonoff_mutex);
1707 if (sb_has_quota_enabled(sb, type) || 1798 if (sb_has_quota_loaded(sb, type)) {
1708 sb_has_quota_suspended(sb, type)) {
1709 error = -EBUSY; 1799 error = -EBUSY;
1710 goto out_lock; 1800 goto out_lock;
1711 } 1801 }
1712 /* We don't want quota and atime on quota files (deadlocks possible) 1802
1713 * Also nobody should write to the file - we use special IO operations 1803 if (!(dqopt->flags & DQUOT_QUOTA_SYS_FILE)) {
1714 * which ignore the immutable bit. */ 1804 /* We don't want quota and atime on quota files (deadlocks
1715 down_write(&dqopt->dqptr_sem); 1805 * possible) Also nobody should write to the file - we use
1716 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | S_NOQUOTA); 1806 * special IO operations which ignore the immutable bit. */
1717 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE; 1807 down_write(&dqopt->dqptr_sem);
1718 up_write(&dqopt->dqptr_sem); 1808 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE | S_NOQUOTA);
1719 sb->dq_op->drop(inode); 1809 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
1810 up_write(&dqopt->dqptr_sem);
1811 sb->dq_op->drop(inode);
1812 }
1720 1813
1721 error = -EIO; 1814 error = -EIO;
1722 dqopt->files[type] = igrab(inode); 1815 dqopt->files[type] = igrab(inode);
@@ -1737,7 +1830,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1737 } 1830 }
1738 mutex_unlock(&dqopt->dqio_mutex); 1831 mutex_unlock(&dqopt->dqio_mutex);
1739 mutex_unlock(&inode->i_mutex); 1832 mutex_unlock(&inode->i_mutex);
1740 set_enable_flags(dqopt, type); 1833 dqopt->flags |= dquot_state_flag(flags, type);
1741 1834
1742 add_dquot_ref(sb, type); 1835 add_dquot_ref(sb, type);
1743 mutex_unlock(&dqopt->dqonoff_mutex); 1836 mutex_unlock(&dqopt->dqonoff_mutex);
@@ -1770,20 +1863,23 @@ static int vfs_quota_on_remount(struct super_block *sb, int type)
1770 struct quota_info *dqopt = sb_dqopt(sb); 1863 struct quota_info *dqopt = sb_dqopt(sb);
1771 struct inode *inode; 1864 struct inode *inode;
1772 int ret; 1865 int ret;
1866 unsigned int flags;
1773 1867
1774 mutex_lock(&dqopt->dqonoff_mutex); 1868 mutex_lock(&dqopt->dqonoff_mutex);
1775 if (!sb_has_quota_suspended(sb, type)) { 1869 if (!sb_has_quota_suspended(sb, type)) {
1776 mutex_unlock(&dqopt->dqonoff_mutex); 1870 mutex_unlock(&dqopt->dqonoff_mutex);
1777 return 0; 1871 return 0;
1778 } 1872 }
1779 BUG_ON(sb_has_quota_enabled(sb, type));
1780
1781 inode = dqopt->files[type]; 1873 inode = dqopt->files[type];
1782 dqopt->files[type] = NULL; 1874 dqopt->files[type] = NULL;
1783 reset_enable_flags(dqopt, type, 0); 1875 flags = dqopt->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
1876 DQUOT_LIMITS_ENABLED, type);
1877 dqopt->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, type);
1784 mutex_unlock(&dqopt->dqonoff_mutex); 1878 mutex_unlock(&dqopt->dqonoff_mutex);
1785 1879
1786 ret = vfs_quota_on_inode(inode, type, dqopt->info[type].dqi_fmt_id); 1880 flags = dquot_generic_flag(flags, type);
1881 ret = vfs_load_quota_inode(inode, type, dqopt->info[type].dqi_fmt_id,
1882 flags);
1787 iput(inode); 1883 iput(inode);
1788 1884
1789 return ret; 1885 return ret;
@@ -1799,12 +1895,12 @@ int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
1799 if (path->mnt->mnt_sb != sb) 1895 if (path->mnt->mnt_sb != sb)
1800 error = -EXDEV; 1896 error = -EXDEV;
1801 else 1897 else
1802 error = vfs_quota_on_inode(path->dentry->d_inode, type, 1898 error = vfs_load_quota_inode(path->dentry->d_inode, type,
1803 format_id); 1899 format_id, DQUOT_USAGE_ENABLED |
1900 DQUOT_LIMITS_ENABLED);
1804 return error; 1901 return error;
1805} 1902}
1806 1903
1807/* Actual function called from quotactl() */
1808int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name, 1904int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name,
1809 int remount) 1905 int remount)
1810{ 1906{
@@ -1823,6 +1919,50 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *name,
1823} 1919}
1824 1920
1825/* 1921/*
1922 * More powerful function for turning on quotas allowing setting
1923 * of individual quota flags
1924 */
1925int vfs_quota_enable(struct inode *inode, int type, int format_id,
1926 unsigned int flags)
1927{
1928 int ret = 0;
1929 struct super_block *sb = inode->i_sb;
1930 struct quota_info *dqopt = sb_dqopt(sb);
1931
1932 /* Just unsuspend quotas? */
1933 if (flags & DQUOT_SUSPENDED)
1934 return vfs_quota_on_remount(sb, type);
1935 if (!flags)
1936 return 0;
1937 /* Just updating flags needed? */
1938 if (sb_has_quota_loaded(sb, type)) {
1939 mutex_lock(&dqopt->dqonoff_mutex);
1940 /* Now do a reliable test... */
1941 if (!sb_has_quota_loaded(sb, type)) {
1942 mutex_unlock(&dqopt->dqonoff_mutex);
1943 goto load_quota;
1944 }
1945 if (flags & DQUOT_USAGE_ENABLED &&
1946 sb_has_quota_usage_enabled(sb, type)) {
1947 ret = -EBUSY;
1948 goto out_lock;
1949 }
1950 if (flags & DQUOT_LIMITS_ENABLED &&
1951 sb_has_quota_limits_enabled(sb, type)) {
1952 ret = -EBUSY;
1953 goto out_lock;
1954 }
1955 sb_dqopt(sb)->flags |= dquot_state_flag(flags, type);
1956out_lock:
1957 mutex_unlock(&dqopt->dqonoff_mutex);
1958 return ret;
1959 }
1960
1961load_quota:
1962 return vfs_load_quota_inode(inode, type, format_id, flags);
1963}
1964
1965/*
1826 * This function is used when filesystem needs to initialize quotas 1966 * This function is used when filesystem needs to initialize quotas
1827 * during mount time. 1967 * during mount time.
1828 */ 1968 */
@@ -1843,7 +1983,8 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
1843 1983
1844 error = security_quota_on(dentry); 1984 error = security_quota_on(dentry);
1845 if (!error) 1985 if (!error)
1846 error = vfs_quota_on_inode(dentry->d_inode, type, format_id); 1986 error = vfs_load_quota_inode(dentry->d_inode, type, format_id,
1987 DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
1847 1988
1848out: 1989out:
1849 dput(dentry); 1990 dput(dentry);
@@ -1866,14 +2007,24 @@ int vfs_dq_quota_on_remount(struct super_block *sb)
1866 return ret; 2007 return ret;
1867} 2008}
1868 2009
2010static inline qsize_t qbtos(qsize_t blocks)
2011{
2012 return blocks << QIF_DQBLKSIZE_BITS;
2013}
2014
2015static inline qsize_t stoqb(qsize_t space)
2016{
2017 return (space + QIF_DQBLKSIZE - 1) >> QIF_DQBLKSIZE_BITS;
2018}
2019
1869/* Generic routine for getting common part of quota structure */ 2020/* Generic routine for getting common part of quota structure */
1870static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di) 2021static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
1871{ 2022{
1872 struct mem_dqblk *dm = &dquot->dq_dqb; 2023 struct mem_dqblk *dm = &dquot->dq_dqb;
1873 2024
1874 spin_lock(&dq_data_lock); 2025 spin_lock(&dq_data_lock);
1875 di->dqb_bhardlimit = dm->dqb_bhardlimit; 2026 di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit);
1876 di->dqb_bsoftlimit = dm->dqb_bsoftlimit; 2027 di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit);
1877 di->dqb_curspace = dm->dqb_curspace; 2028 di->dqb_curspace = dm->dqb_curspace;
1878 di->dqb_ihardlimit = dm->dqb_ihardlimit; 2029 di->dqb_ihardlimit = dm->dqb_ihardlimit;
1879 di->dqb_isoftlimit = dm->dqb_isoftlimit; 2030 di->dqb_isoftlimit = dm->dqb_isoftlimit;
@@ -1918,28 +2069,36 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
1918 if (di->dqb_valid & QIF_SPACE) { 2069 if (di->dqb_valid & QIF_SPACE) {
1919 dm->dqb_curspace = di->dqb_curspace; 2070 dm->dqb_curspace = di->dqb_curspace;
1920 check_blim = 1; 2071 check_blim = 1;
2072 __set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
1921 } 2073 }
1922 if (di->dqb_valid & QIF_BLIMITS) { 2074 if (di->dqb_valid & QIF_BLIMITS) {
1923 dm->dqb_bsoftlimit = di->dqb_bsoftlimit; 2075 dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
1924 dm->dqb_bhardlimit = di->dqb_bhardlimit; 2076 dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
1925 check_blim = 1; 2077 check_blim = 1;
2078 __set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
1926 } 2079 }
1927 if (di->dqb_valid & QIF_INODES) { 2080 if (di->dqb_valid & QIF_INODES) {
1928 dm->dqb_curinodes = di->dqb_curinodes; 2081 dm->dqb_curinodes = di->dqb_curinodes;
1929 check_ilim = 1; 2082 check_ilim = 1;
2083 __set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
1930 } 2084 }
1931 if (di->dqb_valid & QIF_ILIMITS) { 2085 if (di->dqb_valid & QIF_ILIMITS) {
1932 dm->dqb_isoftlimit = di->dqb_isoftlimit; 2086 dm->dqb_isoftlimit = di->dqb_isoftlimit;
1933 dm->dqb_ihardlimit = di->dqb_ihardlimit; 2087 dm->dqb_ihardlimit = di->dqb_ihardlimit;
1934 check_ilim = 1; 2088 check_ilim = 1;
2089 __set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
1935 } 2090 }
1936 if (di->dqb_valid & QIF_BTIME) 2091 if (di->dqb_valid & QIF_BTIME) {
1937 dm->dqb_btime = di->dqb_btime; 2092 dm->dqb_btime = di->dqb_btime;
1938 if (di->dqb_valid & QIF_ITIME) 2093 __set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
2094 }
2095 if (di->dqb_valid & QIF_ITIME) {
1939 dm->dqb_itime = di->dqb_itime; 2096 dm->dqb_itime = di->dqb_itime;
2097 __set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
2098 }
1940 2099
1941 if (check_blim) { 2100 if (check_blim) {
1942 if (!dm->dqb_bsoftlimit || toqb(dm->dqb_curspace) < dm->dqb_bsoftlimit) { 2101 if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) {
1943 dm->dqb_btime = 0; 2102 dm->dqb_btime = 0;
1944 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 2103 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1945 } 2104 }
@@ -1970,12 +2129,14 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
1970 int rc; 2129 int rc;
1971 2130
1972 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 2131 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1973 if (!(dquot = dqget(sb, id, type))) { 2132 dquot = dqget(sb, id, type);
1974 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 2133 if (!dquot) {
1975 return -ESRCH; 2134 rc = -ESRCH;
2135 goto out;
1976 } 2136 }
1977 rc = do_set_dqblk(dquot, di); 2137 rc = do_set_dqblk(dquot, di);
1978 dqput(dquot); 2138 dqput(dquot);
2139out:
1979 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 2140 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1980 return rc; 2141 return rc;
1981} 2142}
@@ -1986,7 +2147,7 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
1986 struct mem_dqinfo *mi; 2147 struct mem_dqinfo *mi;
1987 2148
1988 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 2149 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
1989 if (!sb_has_quota_enabled(sb, type)) { 2150 if (!sb_has_quota_active(sb, type)) {
1990 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 2151 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
1991 return -ESRCH; 2152 return -ESRCH;
1992 } 2153 }
@@ -2005,11 +2166,12 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
2005int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii) 2166int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
2006{ 2167{
2007 struct mem_dqinfo *mi; 2168 struct mem_dqinfo *mi;
2169 int err = 0;
2008 2170
2009 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); 2171 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
2010 if (!sb_has_quota_enabled(sb, type)) { 2172 if (!sb_has_quota_active(sb, type)) {
2011 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 2173 err = -ESRCH;
2012 return -ESRCH; 2174 goto out;
2013 } 2175 }
2014 mi = sb_dqopt(sb)->info + type; 2176 mi = sb_dqopt(sb)->info + type;
2015 spin_lock(&dq_data_lock); 2177 spin_lock(&dq_data_lock);
@@ -2023,8 +2185,9 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
2023 mark_info_dirty(sb, type); 2185 mark_info_dirty(sb, type);
2024 /* Force write to disk */ 2186 /* Force write to disk */
2025 sb->dq_op->write_info(sb, type); 2187 sb->dq_op->write_info(sb, type);
2188out:
2026 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex); 2189 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
2027 return 0; 2190 return err;
2028} 2191}
2029 2192
2030struct quotactl_ops vfs_quotactl_ops = { 2193struct quotactl_ops vfs_quotactl_ops = {
@@ -2186,10 +2349,13 @@ EXPORT_SYMBOL(register_quota_format);
2186EXPORT_SYMBOL(unregister_quota_format); 2349EXPORT_SYMBOL(unregister_quota_format);
2187EXPORT_SYMBOL(dqstats); 2350EXPORT_SYMBOL(dqstats);
2188EXPORT_SYMBOL(dq_data_lock); 2351EXPORT_SYMBOL(dq_data_lock);
2352EXPORT_SYMBOL(vfs_quota_enable);
2189EXPORT_SYMBOL(vfs_quota_on); 2353EXPORT_SYMBOL(vfs_quota_on);
2190EXPORT_SYMBOL(vfs_quota_on_path); 2354EXPORT_SYMBOL(vfs_quota_on_path);
2191EXPORT_SYMBOL(vfs_quota_on_mount); 2355EXPORT_SYMBOL(vfs_quota_on_mount);
2356EXPORT_SYMBOL(vfs_quota_disable);
2192EXPORT_SYMBOL(vfs_quota_off); 2357EXPORT_SYMBOL(vfs_quota_off);
2358EXPORT_SYMBOL(dquot_scan_active);
2193EXPORT_SYMBOL(vfs_quota_sync); 2359EXPORT_SYMBOL(vfs_quota_sync);
2194EXPORT_SYMBOL(vfs_get_dqinfo); 2360EXPORT_SYMBOL(vfs_get_dqinfo);
2195EXPORT_SYMBOL(vfs_set_dqinfo); 2361EXPORT_SYMBOL(vfs_set_dqinfo);
@@ -2202,7 +2368,11 @@ EXPORT_SYMBOL(dquot_release);
2202EXPORT_SYMBOL(dquot_mark_dquot_dirty); 2368EXPORT_SYMBOL(dquot_mark_dquot_dirty);
2203EXPORT_SYMBOL(dquot_initialize); 2369EXPORT_SYMBOL(dquot_initialize);
2204EXPORT_SYMBOL(dquot_drop); 2370EXPORT_SYMBOL(dquot_drop);
2371EXPORT_SYMBOL(dquot_drop_locked);
2205EXPORT_SYMBOL(vfs_dq_drop); 2372EXPORT_SYMBOL(vfs_dq_drop);
2373EXPORT_SYMBOL(dqget);
2374EXPORT_SYMBOL(dqput);
2375EXPORT_SYMBOL(dquot_is_cached);
2206EXPORT_SYMBOL(dquot_alloc_space); 2376EXPORT_SYMBOL(dquot_alloc_space);
2207EXPORT_SYMBOL(dquot_alloc_inode); 2377EXPORT_SYMBOL(dquot_alloc_inode);
2208EXPORT_SYMBOL(dquot_free_space); 2378EXPORT_SYMBOL(dquot_free_space);
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index eb3dc4c7ac06..713834371229 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -275,18 +275,9 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
275static int 275static int
276ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync) 276ecryptfs_fsync(struct file *file, struct dentry *dentry, int datasync)
277{ 277{
278 struct file *lower_file = ecryptfs_file_to_lower(file); 278 return vfs_fsync(ecryptfs_file_to_lower(file),
279 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 279 ecryptfs_dentry_to_lower(dentry),
280 struct inode *lower_inode = lower_dentry->d_inode; 280 datasync);
281 int rc = -EINVAL;
282
283 if (lower_inode->i_fop->fsync) {
284 mutex_lock(&lower_inode->i_mutex);
285 rc = lower_inode->i_fop->fsync(lower_file, lower_dentry,
286 datasync);
287 mutex_unlock(&lower_inode->i_mutex);
288 }
289 return rc;
290} 281}
291 282
292static int ecryptfs_fasync(int fd, struct file *file, int flag) 283static int ecryptfs_fasync(int fd, struct file *file, int flag)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 5e78fc179886..0111906a8877 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -612,8 +612,7 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
612 struct ecryptfs_crypt_stat *crypt_stat; 612 struct ecryptfs_crypt_stat *crypt_stat;
613 613
614 lower_dentry = ecryptfs_dentry_to_lower(dentry); 614 lower_dentry = ecryptfs_dentry_to_lower(dentry);
615 if (!lower_dentry->d_inode->i_op || 615 if (!lower_dentry->d_inode->i_op->readlink) {
616 !lower_dentry->d_inode->i_op->readlink) {
617 rc = -EINVAL; 616 rc = -EINVAL;
618 goto out; 617 goto out;
619 } 618 }
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 04d7b3fa1ac6..46cec2b69796 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -288,7 +288,7 @@ static int ecryptfs_write_begin(struct file *file,
288 loff_t prev_page_end_size; 288 loff_t prev_page_end_size;
289 int rc = 0; 289 int rc = 0;
290 290
291 page = __grab_cache_page(mapping, index); 291 page = grab_cache_page_write_begin(mapping, index, flags);
292 if (!page) 292 if (!page)
293 return -ENOMEM; 293 return -ENOMEM;
294 *pagep = page; 294 *pagep = page;
diff --git a/fs/exec.c b/fs/exec.c
index dfbf7009fbe7..9c33f542dc77 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -51,17 +51,13 @@
51#include <linux/audit.h> 51#include <linux/audit.h>
52#include <linux/tracehook.h> 52#include <linux/tracehook.h>
53#include <linux/kmod.h> 53#include <linux/kmod.h>
54#include <linux/fsnotify.h>
54 55
55#include <asm/uaccess.h> 56#include <asm/uaccess.h>
56#include <asm/mmu_context.h> 57#include <asm/mmu_context.h>
57#include <asm/tlb.h> 58#include <asm/tlb.h>
58#include "internal.h" 59#include "internal.h"
59 60
60#ifdef __alpha__
61/* for /sbin/loader handling in search_binary_handler() */
62#include <linux/a.out.h>
63#endif
64
65int core_uses_pid; 61int core_uses_pid;
66char core_pattern[CORENAME_MAX_SIZE] = "core"; 62char core_pattern[CORENAME_MAX_SIZE] = "core";
67int suid_dumpable = 0; 63int suid_dumpable = 0;
@@ -137,6 +133,8 @@ asmlinkage long sys_uselib(const char __user * library)
137 if (IS_ERR(file)) 133 if (IS_ERR(file))
138 goto out; 134 goto out;
139 135
136 fsnotify_open(file->f_path.dentry);
137
140 error = -ENOEXEC; 138 error = -ENOEXEC;
141 if(file->f_op) { 139 if(file->f_op) {
142 struct linux_binfmt * fmt; 140 struct linux_binfmt * fmt;
@@ -689,6 +687,8 @@ struct file *open_exec(const char *name)
689 if (IS_ERR(file)) 687 if (IS_ERR(file))
690 return file; 688 return file;
691 689
690 fsnotify_open(file->f_path.dentry);
691
692 err = deny_write_access(file); 692 err = deny_write_access(file);
693 if (err) { 693 if (err) {
694 fput(file); 694 fput(file);
@@ -1172,41 +1172,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
1172 unsigned int depth = bprm->recursion_depth; 1172 unsigned int depth = bprm->recursion_depth;
1173 int try,retval; 1173 int try,retval;
1174 struct linux_binfmt *fmt; 1174 struct linux_binfmt *fmt;
1175#ifdef __alpha__
1176 /* handle /sbin/loader.. */
1177 {
1178 struct exec * eh = (struct exec *) bprm->buf;
1179
1180 if (!bprm->loader && eh->fh.f_magic == 0x183 &&
1181 (eh->fh.f_flags & 0x3000) == 0x3000)
1182 {
1183 struct file * file;
1184 unsigned long loader;
1185 1175
1186 allow_write_access(bprm->file);
1187 fput(bprm->file);
1188 bprm->file = NULL;
1189
1190 loader = bprm->vma->vm_end - sizeof(void *);
1191
1192 file = open_exec("/sbin/loader");
1193 retval = PTR_ERR(file);
1194 if (IS_ERR(file))
1195 return retval;
1196
1197 /* Remember if the application is TASO. */
1198 bprm->taso = eh->ah.entry < 0x100000000UL;
1199
1200 bprm->file = file;
1201 bprm->loader = loader;
1202 retval = prepare_binprm(bprm);
1203 if (retval<0)
1204 return retval;
1205 /* should call search_binary_handler recursively here,
1206 but it does not matter */
1207 }
1208 }
1209#endif
1210 retval = security_bprm_check(bprm); 1176 retval = security_bprm_check(bprm);
1211 if (retval) 1177 if (retval)
1212 return retval; 1178 return retval;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index c4bdccf976b5..5fa453b49a64 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1161,7 +1161,7 @@ static int ext3_write_begin(struct file *file, struct address_space *mapping,
1161 to = from + len; 1161 to = from + len;
1162 1162
1163retry: 1163retry:
1164 page = __grab_cache_page(mapping, index); 1164 page = grab_cache_page_write_begin(mapping, index, flags);
1165 if (!page) 1165 if (!page)
1166 return -ENOMEM; 1166 return -ENOMEM;
1167 *pagep = page; 1167 *pagep = page;
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 297ea8dfac7c..1dd2abe6313e 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -2175,8 +2175,7 @@ retry:
2175 * We have a transaction open. All is sweetness. It also sets 2175 * We have a transaction open. All is sweetness. It also sets
2176 * i_size in generic_commit_write(). 2176 * i_size in generic_commit_write().
2177 */ 2177 */
2178 err = __page_symlink(inode, symname, l, 2178 err = __page_symlink(inode, symname, l, 1);
2179 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2180 if (err) { 2179 if (err) {
2181 drop_nlink(inode); 2180 drop_nlink(inode);
2182 unlock_new_inode(inode); 2181 unlock_new_inode(inode);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index f6c94f232ec1..c22d01467bd1 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -713,7 +713,9 @@ static struct dquot_operations ext3_quota_operations = {
713 .acquire_dquot = ext3_acquire_dquot, 713 .acquire_dquot = ext3_acquire_dquot,
714 .release_dquot = ext3_release_dquot, 714 .release_dquot = ext3_release_dquot,
715 .mark_dirty = ext3_mark_dquot_dirty, 715 .mark_dirty = ext3_mark_dquot_dirty,
716 .write_info = ext3_write_info 716 .write_info = ext3_write_info,
717 .alloc_dquot = dquot_alloc,
718 .destroy_dquot = dquot_destroy,
717}; 719};
718 720
719static struct quotactl_ops ext3_qctl_operations = { 721static struct quotactl_ops ext3_qctl_operations = {
@@ -1035,8 +1037,7 @@ static int parse_options (char *options, struct super_block *sb,
1035 case Opt_grpjquota: 1037 case Opt_grpjquota:
1036 qtype = GRPQUOTA; 1038 qtype = GRPQUOTA;
1037set_qf_name: 1039set_qf_name:
1038 if ((sb_any_quota_enabled(sb) || 1040 if (sb_any_quota_loaded(sb) &&
1039 sb_any_quota_suspended(sb)) &&
1040 !sbi->s_qf_names[qtype]) { 1041 !sbi->s_qf_names[qtype]) {
1041 printk(KERN_ERR 1042 printk(KERN_ERR
1042 "EXT3-fs: Cannot change journaled " 1043 "EXT3-fs: Cannot change journaled "
@@ -1075,8 +1076,7 @@ set_qf_name:
1075 case Opt_offgrpjquota: 1076 case Opt_offgrpjquota:
1076 qtype = GRPQUOTA; 1077 qtype = GRPQUOTA;
1077clear_qf_name: 1078clear_qf_name:
1078 if ((sb_any_quota_enabled(sb) || 1079 if (sb_any_quota_loaded(sb) &&
1079 sb_any_quota_suspended(sb)) &&
1080 sbi->s_qf_names[qtype]) { 1080 sbi->s_qf_names[qtype]) {
1081 printk(KERN_ERR "EXT3-fs: Cannot change " 1081 printk(KERN_ERR "EXT3-fs: Cannot change "
1082 "journaled quota options when " 1082 "journaled quota options when "
@@ -1095,8 +1095,7 @@ clear_qf_name:
1095 case Opt_jqfmt_vfsv0: 1095 case Opt_jqfmt_vfsv0:
1096 qfmt = QFMT_VFS_V0; 1096 qfmt = QFMT_VFS_V0;
1097set_qf_format: 1097set_qf_format:
1098 if ((sb_any_quota_enabled(sb) || 1098 if (sb_any_quota_loaded(sb) &&
1099 sb_any_quota_suspended(sb)) &&
1100 sbi->s_jquota_fmt != qfmt) { 1099 sbi->s_jquota_fmt != qfmt) {
1101 printk(KERN_ERR "EXT3-fs: Cannot change " 1100 printk(KERN_ERR "EXT3-fs: Cannot change "
1102 "journaled quota options when " 1101 "journaled quota options when "
@@ -1115,8 +1114,7 @@ set_qf_format:
1115 set_opt(sbi->s_mount_opt, GRPQUOTA); 1114 set_opt(sbi->s_mount_opt, GRPQUOTA);
1116 break; 1115 break;
1117 case Opt_noquota: 1116 case Opt_noquota:
1118 if (sb_any_quota_enabled(sb) || 1117 if (sb_any_quota_loaded(sb)) {
1119 sb_any_quota_suspended(sb)) {
1120 printk(KERN_ERR "EXT3-fs: Cannot change quota " 1118 printk(KERN_ERR "EXT3-fs: Cannot change quota "
1121 "options when quota turned on.\n"); 1119 "options when quota turned on.\n");
1122 return 0; 1120 return 0;
diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h
index 445fde603df8..b21f16713db0 100644
--- a/fs/ext4/ext4_sb.h
+++ b/fs/ext4/ext4_sb.h
@@ -146,4 +146,10 @@ struct ext4_sb_info {
146 struct flex_groups *s_flex_groups; 146 struct flex_groups *s_flex_groups;
147}; 147};
148 148
149static inline spinlock_t *
150sb_bgl_lock(struct ext4_sb_info *sbi, unsigned int block_group)
151{
152 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
153}
154
149#endif /* _EXT4_SB */ 155#endif /* _EXT4_SB */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7c3325e0b005..6702a49992a6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1346,7 +1346,7 @@ retry:
1346 goto out; 1346 goto out;
1347 } 1347 }
1348 1348
1349 page = __grab_cache_page(mapping, index); 1349 page = grab_cache_page_write_begin(mapping, index, flags);
1350 if (!page) { 1350 if (!page) {
1351 ext4_journal_stop(handle); 1351 ext4_journal_stop(handle);
1352 ret = -ENOMEM; 1352 ret = -ENOMEM;
@@ -2550,7 +2550,7 @@ retry:
2550 goto out; 2550 goto out;
2551 } 2551 }
2552 2552
2553 page = __grab_cache_page(mapping, index); 2553 page = grab_cache_page_write_begin(mapping, index, flags);
2554 if (!page) { 2554 if (!page) {
2555 ext4_journal_stop(handle); 2555 ext4_journal_stop(handle);
2556 ret = -ENOMEM; 2556 ret = -ENOMEM;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index da98a9012fa5..9fd2a5e1be4d 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2212,8 +2212,7 @@ retry:
2212 * We have a transaction open. All is sweetness. It also sets 2212 * We have a transaction open. All is sweetness. It also sets
2213 * i_size in generic_commit_write(). 2213 * i_size in generic_commit_write().
2214 */ 2214 */
2215 err = __page_symlink(inode, symname, l, 2215 err = __page_symlink(inode, symname, l, 1);
2216 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2217 if (err) { 2216 if (err) {
2218 clear_nlink(inode); 2217 clear_nlink(inode);
2219 unlock_new_inode(inode); 2218 unlock_new_inode(inode);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 04158ad74dbb..9494bb249390 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -803,7 +803,9 @@ static struct dquot_operations ext4_quota_operations = {
803 .acquire_dquot = ext4_acquire_dquot, 803 .acquire_dquot = ext4_acquire_dquot,
804 .release_dquot = ext4_release_dquot, 804 .release_dquot = ext4_release_dquot,
805 .mark_dirty = ext4_mark_dquot_dirty, 805 .mark_dirty = ext4_mark_dquot_dirty,
806 .write_info = ext4_write_info 806 .write_info = ext4_write_info,
807 .alloc_dquot = dquot_alloc,
808 .destroy_dquot = dquot_destroy,
807}; 809};
808 810
809static struct quotactl_ops ext4_qctl_operations = { 811static struct quotactl_ops ext4_qctl_operations = {
@@ -1142,8 +1144,7 @@ static int parse_options(char *options, struct super_block *sb,
1142 case Opt_grpjquota: 1144 case Opt_grpjquota:
1143 qtype = GRPQUOTA; 1145 qtype = GRPQUOTA;
1144set_qf_name: 1146set_qf_name:
1145 if ((sb_any_quota_enabled(sb) || 1147 if (sb_any_quota_loaded(sb) &&
1146 sb_any_quota_suspended(sb)) &&
1147 !sbi->s_qf_names[qtype]) { 1148 !sbi->s_qf_names[qtype]) {
1148 printk(KERN_ERR 1149 printk(KERN_ERR
1149 "EXT4-fs: Cannot change journaled " 1150 "EXT4-fs: Cannot change journaled "
@@ -1182,8 +1183,7 @@ set_qf_name:
1182 case Opt_offgrpjquota: 1183 case Opt_offgrpjquota:
1183 qtype = GRPQUOTA; 1184 qtype = GRPQUOTA;
1184clear_qf_name: 1185clear_qf_name:
1185 if ((sb_any_quota_enabled(sb) || 1186 if (sb_any_quota_loaded(sb) &&
1186 sb_any_quota_suspended(sb)) &&
1187 sbi->s_qf_names[qtype]) { 1187 sbi->s_qf_names[qtype]) {
1188 printk(KERN_ERR "EXT4-fs: Cannot change " 1188 printk(KERN_ERR "EXT4-fs: Cannot change "
1189 "journaled quota options when " 1189 "journaled quota options when "
@@ -1202,8 +1202,7 @@ clear_qf_name:
1202 case Opt_jqfmt_vfsv0: 1202 case Opt_jqfmt_vfsv0:
1203 qfmt = QFMT_VFS_V0; 1203 qfmt = QFMT_VFS_V0;
1204set_qf_format: 1204set_qf_format:
1205 if ((sb_any_quota_enabled(sb) || 1205 if (sb_any_quota_loaded(sb) &&
1206 sb_any_quota_suspended(sb)) &&
1207 sbi->s_jquota_fmt != qfmt) { 1206 sbi->s_jquota_fmt != qfmt) {
1208 printk(KERN_ERR "EXT4-fs: Cannot change " 1207 printk(KERN_ERR "EXT4-fs: Cannot change "
1209 "journaled quota options when " 1208 "journaled quota options when "
@@ -1222,7 +1221,7 @@ set_qf_format:
1222 set_opt(sbi->s_mount_opt, GRPQUOTA); 1221 set_opt(sbi->s_mount_opt, GRPQUOTA);
1223 break; 1222 break;
1224 case Opt_noquota: 1223 case Opt_noquota:
1225 if (sb_any_quota_enabled(sb)) { 1224 if (sb_any_quota_loaded(sb)) {
1226 printk(KERN_ERR "EXT4-fs: Cannot change quota " 1225 printk(KERN_ERR "EXT4-fs: Cannot change quota "
1227 "options when quota turned on.\n"); 1226 "options when quota turned on.\n");
1228 return 0; 1227 return 0;
diff --git a/fs/filesystems.c b/fs/filesystems.c
index d0e20ced62dd..d488dcd7f2bb 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -253,24 +253,27 @@ static int __init proc_filesystems_init(void)
253module_init(proc_filesystems_init); 253module_init(proc_filesystems_init);
254#endif 254#endif
255 255
256struct file_system_type *get_fs_type(const char *name) 256static struct file_system_type *__get_fs_type(const char *name, int len)
257{ 257{
258 struct file_system_type *fs; 258 struct file_system_type *fs;
259 const char *dot = strchr(name, '.');
260 unsigned len = dot ? dot - name : strlen(name);
261 259
262 read_lock(&file_systems_lock); 260 read_lock(&file_systems_lock);
263 fs = *(find_filesystem(name, len)); 261 fs = *(find_filesystem(name, len));
264 if (fs && !try_module_get(fs->owner)) 262 if (fs && !try_module_get(fs->owner))
265 fs = NULL; 263 fs = NULL;
266 read_unlock(&file_systems_lock); 264 read_unlock(&file_systems_lock);
267 if (!fs && (request_module("%.*s", len, name) == 0)) { 265 return fs;
268 read_lock(&file_systems_lock); 266}
269 fs = *(find_filesystem(name, len)); 267
270 if (fs && !try_module_get(fs->owner)) 268struct file_system_type *get_fs_type(const char *name)
271 fs = NULL; 269{
272 read_unlock(&file_systems_lock); 270 struct file_system_type *fs;
273 } 271 const char *dot = strchr(name, '.');
272 int len = dot ? dot - name : strlen(name);
273
274 fs = __get_fs_type(name, len);
275 if (!fs && (request_module("%.*s", len, name) == 0))
276 fs = __get_fs_type(name, len);
274 277
275 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) { 278 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
276 put_filesystem(fs); 279 put_filesystem(fs);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 34930a964b82..4c9ee7011265 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -646,7 +646,7 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
646{ 646{
647 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 647 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
648 648
649 *pagep = __grab_cache_page(mapping, index); 649 *pagep = grab_cache_page_write_begin(mapping, index, flags);
650 if (!*pagep) 650 if (!*pagep)
651 return -ENOMEM; 651 return -ENOMEM;
652 return 0; 652 return 0;
@@ -779,7 +779,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
779 break; 779 break;
780 780
781 err = -ENOMEM; 781 err = -ENOMEM;
782 page = __grab_cache_page(mapping, index); 782 page = grab_cache_page_write_begin(mapping, index, 0);
783 if (!page) 783 if (!page)
784 break; 784 break;
785 785
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile
index ec65851ec80a..c1b4ec6a9650 100644
--- a/fs/gfs2/Makefile
+++ b/fs/gfs2/Makefile
@@ -1,5 +1,5 @@
1obj-$(CONFIG_GFS2_FS) += gfs2.o 1obj-$(CONFIG_GFS2_FS) += gfs2.o
2gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ 2gfs2-y := acl.o bmap.o dir.o eaops.o eattr.o glock.o \
3 glops.o inode.o log.o lops.o locking.o main.o meta_io.o \ 3 glops.o inode.o log.o lops.o locking.o main.o meta_io.o \
4 mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ 4 mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \
5 ops_fstype.o ops_inode.o ops_super.o quota.o \ 5 ops_fstype.o ops_inode.o ops_super.o quota.o \
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 3e9bd46f27e3..e335dceb6a4f 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -91,7 +91,7 @@ static int acl_get(struct gfs2_inode *ip, int access, struct posix_acl **acl,
91 struct gfs2_ea_location el_this; 91 struct gfs2_ea_location el_this;
92 int error; 92 int error;
93 93
94 if (!ip->i_di.di_eattr) 94 if (!ip->i_eattr)
95 return 0; 95 return 0;
96 96
97 memset(&er, 0, sizeof(struct gfs2_ea_request)); 97 memset(&er, 0, sizeof(struct gfs2_ea_request));
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index bec76b1c2bb0..11ffc56f1f81 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -75,9 +75,9 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
75 void *kaddr = kmap(page); 75 void *kaddr = kmap(page);
76 76
77 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), 77 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
78 ip->i_di.di_size); 78 ip->i_disksize);
79 memset(kaddr + ip->i_di.di_size, 0, 79 memset(kaddr + ip->i_disksize, 0,
80 PAGE_CACHE_SIZE - ip->i_di.di_size); 80 PAGE_CACHE_SIZE - ip->i_disksize);
81 kunmap(page); 81 kunmap(page);
82 82
83 SetPageUptodate(page); 83 SetPageUptodate(page);
@@ -132,7 +132,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
132 if (error) 132 if (error)
133 goto out; 133 goto out;
134 134
135 if (ip->i_di.di_size) { 135 if (ip->i_disksize) {
136 /* Get a free block, fill it with the stuffed data, 136 /* Get a free block, fill it with the stuffed data,
137 and write it out to disk */ 137 and write it out to disk */
138 138
@@ -159,7 +159,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
159 di = (struct gfs2_dinode *)dibh->b_data; 159 di = (struct gfs2_dinode *)dibh->b_data;
160 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 160 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
161 161
162 if (ip->i_di.di_size) { 162 if (ip->i_disksize) {
163 *(__be64 *)(di + 1) = cpu_to_be64(block); 163 *(__be64 *)(di + 1) = cpu_to_be64(block);
164 gfs2_add_inode_blocks(&ip->i_inode, 1); 164 gfs2_add_inode_blocks(&ip->i_inode, 1);
165 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); 165 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
@@ -926,7 +926,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
926 } 926 }
927 } 927 }
928 928
929 ip->i_di.di_size = size; 929 ip->i_disksize = size;
930 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 930 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
931 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 931 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
932 gfs2_dinode_out(ip, dibh->b_data); 932 gfs2_dinode_out(ip, dibh->b_data);
@@ -1033,7 +1033,7 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
1033 goto out; 1033 goto out;
1034 1034
1035 if (gfs2_is_stuffed(ip)) { 1035 if (gfs2_is_stuffed(ip)) {
1036 ip->i_di.di_size = size; 1036 ip->i_disksize = size;
1037 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1037 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1038 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1038 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1039 gfs2_dinode_out(ip, dibh->b_data); 1039 gfs2_dinode_out(ip, dibh->b_data);
@@ -1045,9 +1045,9 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
1045 error = gfs2_block_truncate_page(ip->i_inode.i_mapping); 1045 error = gfs2_block_truncate_page(ip->i_inode.i_mapping);
1046 1046
1047 if (!error) { 1047 if (!error) {
1048 ip->i_di.di_size = size; 1048 ip->i_disksize = size;
1049 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1049 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1050 ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG; 1050 ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG;
1051 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1051 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1052 gfs2_dinode_out(ip, dibh->b_data); 1052 gfs2_dinode_out(ip, dibh->b_data);
1053 } 1053 }
@@ -1114,13 +1114,13 @@ static int trunc_end(struct gfs2_inode *ip)
1114 if (error) 1114 if (error)
1115 goto out; 1115 goto out;
1116 1116
1117 if (!ip->i_di.di_size) { 1117 if (!ip->i_disksize) {
1118 ip->i_height = 0; 1118 ip->i_height = 0;
1119 ip->i_goal = ip->i_no_addr; 1119 ip->i_goal = ip->i_no_addr;
1120 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 1120 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
1121 } 1121 }
1122 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1122 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1123 ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG; 1123 ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG;
1124 1124
1125 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1125 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1126 gfs2_dinode_out(ip, dibh->b_data); 1126 gfs2_dinode_out(ip, dibh->b_data);
@@ -1205,9 +1205,9 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size)
1205 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode))) 1205 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode)))
1206 return -EINVAL; 1206 return -EINVAL;
1207 1207
1208 if (size > ip->i_di.di_size) 1208 if (size > ip->i_disksize)
1209 error = do_grow(ip, size); 1209 error = do_grow(ip, size);
1210 else if (size < ip->i_di.di_size) 1210 else if (size < ip->i_disksize)
1211 error = do_shrink(ip, size); 1211 error = do_shrink(ip, size);
1212 else 1212 else
1213 /* update time stamps */ 1213 /* update time stamps */
@@ -1219,7 +1219,7 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size)
1219int gfs2_truncatei_resume(struct gfs2_inode *ip) 1219int gfs2_truncatei_resume(struct gfs2_inode *ip)
1220{ 1220{
1221 int error; 1221 int error;
1222 error = trunc_dealloc(ip, ip->i_di.di_size); 1222 error = trunc_dealloc(ip, ip->i_disksize);
1223 if (!error) 1223 if (!error)
1224 error = trunc_end(ip); 1224 error = trunc_end(ip);
1225 return error; 1225 return error;
@@ -1231,35 +1231,6 @@ int gfs2_file_dealloc(struct gfs2_inode *ip)
1231} 1231}
1232 1232
1233/** 1233/**
1234 * gfs2_write_calc_reserv - calculate number of blocks needed to write to a file
1235 * @ip: the file
1236 * @len: the number of bytes to be written to the file
1237 * @data_blocks: returns the number of data blocks required
1238 * @ind_blocks: returns the number of indirect blocks required
1239 *
1240 */
1241
1242void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len,
1243 unsigned int *data_blocks, unsigned int *ind_blocks)
1244{
1245 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1246 unsigned int tmp;
1247
1248 if (gfs2_is_dir(ip)) {
1249 *data_blocks = DIV_ROUND_UP(len, sdp->sd_jbsize) + 2;
1250 *ind_blocks = 3 * (sdp->sd_max_jheight - 1);
1251 } else {
1252 *data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3;
1253 *ind_blocks = 3 * (sdp->sd_max_height - 1);
1254 }
1255
1256 for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) {
1257 tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
1258 *ind_blocks += tmp;
1259 }
1260}
1261
1262/**
1263 * gfs2_write_alloc_required - figure out if a write will require an allocation 1234 * gfs2_write_alloc_required - figure out if a write will require an allocation
1264 * @ip: the file being written to 1235 * @ip: the file being written to
1265 * @offset: the offset to write to 1236 * @offset: the offset to write to
@@ -1276,6 +1247,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
1276 struct buffer_head bh; 1247 struct buffer_head bh;
1277 unsigned int shift; 1248 unsigned int shift;
1278 u64 lblock, lblock_stop, size; 1249 u64 lblock, lblock_stop, size;
1250 u64 end_of_file;
1279 1251
1280 *alloc_required = 0; 1252 *alloc_required = 0;
1281 1253
@@ -1291,19 +1263,12 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
1291 1263
1292 *alloc_required = 1; 1264 *alloc_required = 1;
1293 shift = sdp->sd_sb.sb_bsize_shift; 1265 shift = sdp->sd_sb.sb_bsize_shift;
1294 if (gfs2_is_dir(ip)) { 1266 BUG_ON(gfs2_is_dir(ip));
1295 unsigned int bsize = sdp->sd_jbsize; 1267 end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize - 1) >> shift;
1296 lblock = offset; 1268 lblock = offset >> shift;
1297 do_div(lblock, bsize); 1269 lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
1298 lblock_stop = offset + len + bsize - 1; 1270 if (lblock_stop > end_of_file)
1299 do_div(lblock_stop, bsize); 1271 return 0;
1300 } else {
1301 u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift;
1302 lblock = offset >> shift;
1303 lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
1304 if (lblock_stop > end_of_file)
1305 return 0;
1306 }
1307 1272
1308 size = (lblock_stop - lblock) << shift; 1273 size = (lblock_stop - lblock) << shift;
1309 do { 1274 do {
diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h
index 4e6cde2943bd..c983177e05ac 100644
--- a/fs/gfs2/bmap.h
+++ b/fs/gfs2/bmap.h
@@ -10,10 +10,40 @@
10#ifndef __BMAP_DOT_H__ 10#ifndef __BMAP_DOT_H__
11#define __BMAP_DOT_H__ 11#define __BMAP_DOT_H__
12 12
13#include "inode.h"
14
13struct inode; 15struct inode;
14struct gfs2_inode; 16struct gfs2_inode;
15struct page; 17struct page;
16 18
19
20/**
21 * gfs2_write_calc_reserv - calculate number of blocks needed to write to a file
22 * @ip: the file
23 * @len: the number of bytes to be written to the file
24 * @data_blocks: returns the number of data blocks required
25 * @ind_blocks: returns the number of indirect blocks required
26 *
27 */
28
29static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip,
30 unsigned int len,
31 unsigned int *data_blocks,
32 unsigned int *ind_blocks)
33{
34 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
35 unsigned int tmp;
36
37 BUG_ON(gfs2_is_dir(ip));
38 *data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3;
39 *ind_blocks = 3 * (sdp->sd_max_height - 1);
40
41 for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) {
42 tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
43 *ind_blocks += tmp;
44 }
45}
46
17int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page); 47int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
18int gfs2_block_map(struct inode *inode, sector_t lblock, struct buffer_head *bh, int create); 48int gfs2_block_map(struct inode *inode, sector_t lblock, struct buffer_head *bh, int create);
19int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen); 49int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen);
@@ -21,10 +51,6 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi
21int gfs2_truncatei(struct gfs2_inode *ip, u64 size); 51int gfs2_truncatei(struct gfs2_inode *ip, u64 size);
22int gfs2_truncatei_resume(struct gfs2_inode *ip); 52int gfs2_truncatei_resume(struct gfs2_inode *ip);
23int gfs2_file_dealloc(struct gfs2_inode *ip); 53int gfs2_file_dealloc(struct gfs2_inode *ip);
24
25void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len,
26 unsigned int *data_blocks,
27 unsigned int *ind_blocks);
28int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, 54int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
29 unsigned int len, int *alloc_required); 55 unsigned int len, int *alloc_required);
30 56
diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c
deleted file mode 100644
index e51991947d2c..000000000000
--- a/fs/gfs2/daemon.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/buffer_head.h>
15#include <linux/kthread.h>
16#include <linux/delay.h>
17#include <linux/gfs2_ondisk.h>
18#include <linux/lm_interface.h>
19#include <linux/freezer.h>
20
21#include "gfs2.h"
22#include "incore.h"
23#include "daemon.h"
24#include "glock.h"
25#include "log.h"
26#include "quota.h"
27#include "recovery.h"
28#include "super.h"
29#include "util.h"
30
31/* This uses schedule_timeout() instead of msleep() because it's good for
32 the daemons to wake up more often than the timeout when unmounting so
33 the user's unmount doesn't sit there forever.
34
35 The kthread functions used to start these daemons block and flush signals. */
36
37/**
38 * gfs2_glockd - Reclaim unused glock structures
39 * @sdp: Pointer to GFS2 superblock
40 *
41 * One or more of these daemons run, reclaiming glocks on sd_reclaim_list.
42 * Number of daemons can be set by user, with num_glockd mount option.
43 */
44
45int gfs2_glockd(void *data)
46{
47 struct gfs2_sbd *sdp = data;
48
49 while (!kthread_should_stop()) {
50 while (atomic_read(&sdp->sd_reclaim_count))
51 gfs2_reclaim_glock(sdp);
52
53 wait_event_interruptible(sdp->sd_reclaim_wq,
54 (atomic_read(&sdp->sd_reclaim_count) ||
55 kthread_should_stop()));
56 if (freezing(current))
57 refrigerator();
58 }
59
60 return 0;
61}
62
63/**
64 * gfs2_recoverd - Recover dead machine's journals
65 * @sdp: Pointer to GFS2 superblock
66 *
67 */
68
69int gfs2_recoverd(void *data)
70{
71 struct gfs2_sbd *sdp = data;
72 unsigned long t;
73
74 while (!kthread_should_stop()) {
75 gfs2_check_journals(sdp);
76 t = gfs2_tune_get(sdp, gt_recoverd_secs) * HZ;
77 if (freezing(current))
78 refrigerator();
79 schedule_timeout_interruptible(t);
80 }
81
82 return 0;
83}
84
85/**
86 * gfs2_quotad - Write cached quota changes into the quota file
87 * @sdp: Pointer to GFS2 superblock
88 *
89 */
90
91int gfs2_quotad(void *data)
92{
93 struct gfs2_sbd *sdp = data;
94 unsigned long t;
95 int error;
96
97 while (!kthread_should_stop()) {
98 /* Update the master statfs file */
99
100 t = sdp->sd_statfs_sync_time +
101 gfs2_tune_get(sdp, gt_statfs_quantum) * HZ;
102
103 if (time_after_eq(jiffies, t)) {
104 error = gfs2_statfs_sync(sdp);
105 if (error &&
106 error != -EROFS &&
107 !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
108 fs_err(sdp, "quotad: (1) error=%d\n", error);
109 sdp->sd_statfs_sync_time = jiffies;
110 }
111
112 /* Update quota file */
113
114 t = sdp->sd_quota_sync_time +
115 gfs2_tune_get(sdp, gt_quota_quantum) * HZ;
116
117 if (time_after_eq(jiffies, t)) {
118 error = gfs2_quota_sync(sdp);
119 if (error &&
120 error != -EROFS &&
121 !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
122 fs_err(sdp, "quotad: (2) error=%d\n", error);
123 sdp->sd_quota_sync_time = jiffies;
124 }
125
126 gfs2_quota_scan(sdp);
127
128 t = gfs2_tune_get(sdp, gt_quotad_secs) * HZ;
129 if (freezing(current))
130 refrigerator();
131 schedule_timeout_interruptible(t);
132 }
133
134 return 0;
135}
136
diff --git a/fs/gfs2/daemon.h b/fs/gfs2/daemon.h
deleted file mode 100644
index 4be084fb6a62..000000000000
--- a/fs/gfs2/daemon.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#ifndef __DAEMON_DOT_H__
11#define __DAEMON_DOT_H__
12
13int gfs2_glockd(void *data);
14int gfs2_recoverd(void *data);
15int gfs2_quotad(void *data);
16
17#endif /* __DAEMON_DOT_H__ */
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index eed040d8ba3a..b7c8e5c70791 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -36,7 +36,7 @@
36 * the block. In leaves, they begin at offset sizeof(struct gfs2_leaf) from the 36 * the block. In leaves, they begin at offset sizeof(struct gfs2_leaf) from the
37 * beginning of the leaf block. The dirents reside in leaves when 37 * beginning of the leaf block. The dirents reside in leaves when
38 * 38 *
39 * dip->i_di.di_flags & GFS2_DIF_EXHASH is true 39 * dip->i_diskflags & GFS2_DIF_EXHASH is true
40 * 40 *
41 * Otherwise, the dirents are "linear", within a single stuffed dinode block. 41 * Otherwise, the dirents are "linear", within a single stuffed dinode block.
42 * 42 *
@@ -128,8 +128,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
128 128
129 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 129 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
130 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); 130 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
131 if (ip->i_di.di_size < offset + size) 131 if (ip->i_disksize < offset + size)
132 ip->i_di.di_size = offset + size; 132 ip->i_disksize = offset + size;
133 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 133 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
134 gfs2_dinode_out(ip, dibh->b_data); 134 gfs2_dinode_out(ip, dibh->b_data);
135 135
@@ -226,8 +226,8 @@ out:
226 if (error) 226 if (error)
227 return error; 227 return error;
228 228
229 if (ip->i_di.di_size < offset + copied) 229 if (ip->i_disksize < offset + copied)
230 ip->i_di.di_size = offset + copied; 230 ip->i_disksize = offset + copied;
231 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 231 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
232 232
233 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 233 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
@@ -277,11 +277,11 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
277 int copied = 0; 277 int copied = 0;
278 int error = 0; 278 int error = 0;
279 279
280 if (offset >= ip->i_di.di_size) 280 if (offset >= ip->i_disksize)
281 return 0; 281 return 0;
282 282
283 if (offset + size > ip->i_di.di_size) 283 if (offset + size > ip->i_disksize)
284 size = ip->i_di.di_size - offset; 284 size = ip->i_disksize - offset;
285 285
286 if (!size) 286 if (!size)
287 return 0; 287 return 0;
@@ -755,12 +755,12 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
755 struct gfs2_inode *ip = GFS2_I(inode); 755 struct gfs2_inode *ip = GFS2_I(inode);
756 int error; 756 int error;
757 757
758 if (ip->i_di.di_flags & GFS2_DIF_EXHASH) { 758 if (ip->i_diskflags & GFS2_DIF_EXHASH) {
759 struct gfs2_leaf *leaf; 759 struct gfs2_leaf *leaf;
760 unsigned hsize = 1 << ip->i_depth; 760 unsigned hsize = 1 << ip->i_depth;
761 unsigned index; 761 unsigned index;
762 u64 ln; 762 u64 ln;
763 if (hsize * sizeof(u64) != ip->i_di.di_size) { 763 if (hsize * sizeof(u64) != ip->i_disksize) {
764 gfs2_consist_inode(ip); 764 gfs2_consist_inode(ip);
765 return ERR_PTR(-EIO); 765 return ERR_PTR(-EIO);
766 } 766 }
@@ -858,8 +858,8 @@ static int dir_make_exhash(struct inode *inode)
858 return -ENOSPC; 858 return -ENOSPC;
859 bn = bh->b_blocknr; 859 bn = bh->b_blocknr;
860 860
861 gfs2_assert(sdp, dip->i_di.di_entries < (1 << 16)); 861 gfs2_assert(sdp, dip->i_entries < (1 << 16));
862 leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries); 862 leaf->lf_entries = cpu_to_be16(dip->i_entries);
863 863
864 /* Copy dirents */ 864 /* Copy dirents */
865 865
@@ -905,9 +905,9 @@ static int dir_make_exhash(struct inode *inode)
905 for (x = sdp->sd_hash_ptrs; x--; lp++) 905 for (x = sdp->sd_hash_ptrs; x--; lp++)
906 *lp = cpu_to_be64(bn); 906 *lp = cpu_to_be64(bn);
907 907
908 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2; 908 dip->i_disksize = sdp->sd_sb.sb_bsize / 2;
909 gfs2_add_inode_blocks(&dip->i_inode, 1); 909 gfs2_add_inode_blocks(&dip->i_inode, 1);
910 dip->i_di.di_flags |= GFS2_DIF_EXHASH; 910 dip->i_diskflags |= GFS2_DIF_EXHASH;
911 911
912 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ; 912 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
913 dip->i_depth = y; 913 dip->i_depth = y;
@@ -1082,7 +1082,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1082 int error = 0; 1082 int error = 0;
1083 1083
1084 hsize = 1 << dip->i_depth; 1084 hsize = 1 << dip->i_depth;
1085 if (hsize * sizeof(u64) != dip->i_di.di_size) { 1085 if (hsize * sizeof(u64) != dip->i_disksize) {
1086 gfs2_consist_inode(dip); 1086 gfs2_consist_inode(dip);
1087 return -EIO; 1087 return -EIO;
1088 } 1088 }
@@ -1091,7 +1091,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1091 1091
1092 buf = kcalloc(3, sdp->sd_hash_bsize, GFP_NOFS | __GFP_NOFAIL); 1092 buf = kcalloc(3, sdp->sd_hash_bsize, GFP_NOFS | __GFP_NOFAIL);
1093 1093
1094 for (block = dip->i_di.di_size >> sdp->sd_hash_bsize_shift; block--;) { 1094 for (block = dip->i_disksize >> sdp->sd_hash_bsize_shift; block--;) {
1095 error = gfs2_dir_read_data(dip, (char *)buf, 1095 error = gfs2_dir_read_data(dip, (char *)buf,
1096 block * sdp->sd_hash_bsize, 1096 block * sdp->sd_hash_bsize,
1097 sdp->sd_hash_bsize, 1); 1097 sdp->sd_hash_bsize, 1);
@@ -1370,7 +1370,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1370 unsigned depth = 0; 1370 unsigned depth = 0;
1371 1371
1372 hsize = 1 << dip->i_depth; 1372 hsize = 1 << dip->i_depth;
1373 if (hsize * sizeof(u64) != dip->i_di.di_size) { 1373 if (hsize * sizeof(u64) != dip->i_disksize) {
1374 gfs2_consist_inode(dip); 1374 gfs2_consist_inode(dip);
1375 return -EIO; 1375 return -EIO;
1376 } 1376 }
@@ -1426,10 +1426,10 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
1426 int copied = 0; 1426 int copied = 0;
1427 int error; 1427 int error;
1428 1428
1429 if (!dip->i_di.di_entries) 1429 if (!dip->i_entries)
1430 return 0; 1430 return 0;
1431 1431
1432 if (dip->i_di.di_flags & GFS2_DIF_EXHASH) 1432 if (dip->i_diskflags & GFS2_DIF_EXHASH)
1433 return dir_e_read(inode, offset, opaque, filldir); 1433 return dir_e_read(inode, offset, opaque, filldir);
1434 1434
1435 if (!gfs2_is_stuffed(dip)) { 1435 if (!gfs2_is_stuffed(dip)) {
@@ -1453,17 +1453,17 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
1453 error = PTR_ERR(dent); 1453 error = PTR_ERR(dent);
1454 goto out; 1454 goto out;
1455 } 1455 }
1456 if (dip->i_di.di_entries != g.offset) { 1456 if (dip->i_entries != g.offset) {
1457 fs_warn(sdp, "Number of entries corrupt in dir %llu, " 1457 fs_warn(sdp, "Number of entries corrupt in dir %llu, "
1458 "ip->i_di.di_entries (%u) != g.offset (%u)\n", 1458 "ip->i_entries (%u) != g.offset (%u)\n",
1459 (unsigned long long)dip->i_no_addr, 1459 (unsigned long long)dip->i_no_addr,
1460 dip->i_di.di_entries, 1460 dip->i_entries,
1461 g.offset); 1461 g.offset);
1462 error = -EIO; 1462 error = -EIO;
1463 goto out; 1463 goto out;
1464 } 1464 }
1465 error = do_filldir_main(dip, offset, opaque, filldir, darr, 1465 error = do_filldir_main(dip, offset, opaque, filldir, darr,
1466 dip->i_di.di_entries, &copied); 1466 dip->i_entries, &copied);
1467out: 1467out:
1468 kfree(darr); 1468 kfree(darr);
1469 } 1469 }
@@ -1612,7 +1612,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1612 dent = gfs2_init_dirent(inode, dent, name, bh); 1612 dent = gfs2_init_dirent(inode, dent, name, bh);
1613 gfs2_inum_out(nip, dent); 1613 gfs2_inum_out(nip, dent);
1614 dent->de_type = cpu_to_be16(type); 1614 dent->de_type = cpu_to_be16(type);
1615 if (ip->i_di.di_flags & GFS2_DIF_EXHASH) { 1615 if (ip->i_diskflags & GFS2_DIF_EXHASH) {
1616 leaf = (struct gfs2_leaf *)bh->b_data; 1616 leaf = (struct gfs2_leaf *)bh->b_data;
1617 be16_add_cpu(&leaf->lf_entries, 1); 1617 be16_add_cpu(&leaf->lf_entries, 1);
1618 } 1618 }
@@ -1621,14 +1621,14 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1621 if (error) 1621 if (error)
1622 break; 1622 break;
1623 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1623 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1624 ip->i_di.di_entries++; 1624 ip->i_entries++;
1625 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1625 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1626 gfs2_dinode_out(ip, bh->b_data); 1626 gfs2_dinode_out(ip, bh->b_data);
1627 brelse(bh); 1627 brelse(bh);
1628 error = 0; 1628 error = 0;
1629 break; 1629 break;
1630 } 1630 }
1631 if (!(ip->i_di.di_flags & GFS2_DIF_EXHASH)) { 1631 if (!(ip->i_diskflags & GFS2_DIF_EXHASH)) {
1632 error = dir_make_exhash(inode); 1632 error = dir_make_exhash(inode);
1633 if (error) 1633 if (error)
1634 break; 1634 break;
@@ -1691,7 +1691,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1691 } 1691 }
1692 1692
1693 dirent_del(dip, bh, prev, dent); 1693 dirent_del(dip, bh, prev, dent);
1694 if (dip->i_di.di_flags & GFS2_DIF_EXHASH) { 1694 if (dip->i_diskflags & GFS2_DIF_EXHASH) {
1695 struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data; 1695 struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
1696 u16 entries = be16_to_cpu(leaf->lf_entries); 1696 u16 entries = be16_to_cpu(leaf->lf_entries);
1697 if (!entries) 1697 if (!entries)
@@ -1704,10 +1704,10 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1704 if (error) 1704 if (error)
1705 return error; 1705 return error;
1706 1706
1707 if (!dip->i_di.di_entries) 1707 if (!dip->i_entries)
1708 gfs2_consist_inode(dip); 1708 gfs2_consist_inode(dip);
1709 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1709 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1710 dip->i_di.di_entries--; 1710 dip->i_entries--;
1711 dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME; 1711 dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME;
1712 gfs2_dinode_out(dip, bh->b_data); 1712 gfs2_dinode_out(dip, bh->b_data);
1713 brelse(bh); 1713 brelse(bh);
@@ -1748,7 +1748,7 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
1748 gfs2_inum_out(nip, dent); 1748 gfs2_inum_out(nip, dent);
1749 dent->de_type = cpu_to_be16(new_type); 1749 dent->de_type = cpu_to_be16(new_type);
1750 1750
1751 if (dip->i_di.di_flags & GFS2_DIF_EXHASH) { 1751 if (dip->i_diskflags & GFS2_DIF_EXHASH) {
1752 brelse(bh); 1752 brelse(bh);
1753 error = gfs2_meta_inode_buffer(dip, &bh); 1753 error = gfs2_meta_inode_buffer(dip, &bh);
1754 if (error) 1754 if (error)
@@ -1784,7 +1784,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1784 int error = 0; 1784 int error = 0;
1785 1785
1786 hsize = 1 << dip->i_depth; 1786 hsize = 1 << dip->i_depth;
1787 if (hsize * sizeof(u64) != dip->i_di.di_size) { 1787 if (hsize * sizeof(u64) != dip->i_disksize) {
1788 gfs2_consist_inode(dip); 1788 gfs2_consist_inode(dip);
1789 return -EIO; 1789 return -EIO;
1790 } 1790 }
diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h
index 8a468cac9328..4f919440c3be 100644
--- a/fs/gfs2/dir.h
+++ b/fs/gfs2/dir.h
@@ -11,6 +11,7 @@
11#define __DIR_DOT_H__ 11#define __DIR_DOT_H__
12 12
13#include <linux/dcache.h> 13#include <linux/dcache.h>
14#include <linux/crc32.h>
14 15
15struct inode; 16struct inode;
16struct gfs2_inode; 17struct gfs2_inode;
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c
index e3f76f451b0a..0d1c76d906ae 100644
--- a/fs/gfs2/eattr.c
+++ b/fs/gfs2/eattr.c
@@ -114,11 +114,11 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
114 __be64 *eablk, *end; 114 __be64 *eablk, *end;
115 int error; 115 int error;
116 116
117 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh); 117 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &bh);
118 if (error) 118 if (error)
119 return error; 119 return error;
120 120
121 if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT)) { 121 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) {
122 error = ea_foreach_i(ip, bh, ea_call, data); 122 error = ea_foreach_i(ip, bh, ea_call, data);
123 goto out; 123 goto out;
124 } 124 }
@@ -414,7 +414,7 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er)
414 if (error) 414 if (error)
415 return error; 415 return error;
416 416
417 if (ip->i_di.di_eattr) { 417 if (ip->i_eattr) {
418 struct ea_list ei = { .ei_er = er, .ei_size = 0 }; 418 struct ea_list ei = { .ei_er = er, .ei_size = 0 };
419 419
420 error = ea_foreach(ip, ea_list_i, &ei); 420 error = ea_foreach(ip, ea_list_i, &ei);
@@ -514,7 +514,7 @@ int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
514 struct gfs2_ea_location el; 514 struct gfs2_ea_location el;
515 int error; 515 int error;
516 516
517 if (!ip->i_di.di_eattr) 517 if (!ip->i_eattr)
518 return -ENODATA; 518 return -ENODATA;
519 519
520 error = gfs2_ea_find(ip, er, &el); 520 error = gfs2_ea_find(ip, er, &el);
@@ -741,7 +741,7 @@ static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
741 if (error) 741 if (error)
742 return error; 742 return error;
743 743
744 ip->i_di.di_eattr = bh->b_blocknr; 744 ip->i_eattr = bh->b_blocknr;
745 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er); 745 error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er);
746 746
747 brelse(bh); 747 brelse(bh);
@@ -935,10 +935,10 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
935 int error; 935 int error;
936 int mh_size = sizeof(struct gfs2_meta_header); 936 int mh_size = sizeof(struct gfs2_meta_header);
937 937
938 if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) { 938 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) {
939 __be64 *end; 939 __be64 *end;
940 940
941 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, 941 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT,
942 &indbh); 942 &indbh);
943 if (error) 943 if (error)
944 return error; 944 return error;
@@ -972,9 +972,9 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
972 gfs2_buffer_clear_tail(indbh, mh_size); 972 gfs2_buffer_clear_tail(indbh, mh_size);
973 973
974 eablk = (__be64 *)(indbh->b_data + mh_size); 974 eablk = (__be64 *)(indbh->b_data + mh_size);
975 *eablk = cpu_to_be64(ip->i_di.di_eattr); 975 *eablk = cpu_to_be64(ip->i_eattr);
976 ip->i_di.di_eattr = blk; 976 ip->i_eattr = blk;
977 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT; 977 ip->i_diskflags |= GFS2_DIF_EA_INDIRECT;
978 gfs2_add_inode_blocks(&ip->i_inode, 1); 978 gfs2_add_inode_blocks(&ip->i_inode, 1);
979 979
980 eablk++; 980 eablk++;
@@ -1015,7 +1015,7 @@ static int ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
1015 if (error) 1015 if (error)
1016 return error; 1016 return error;
1017 1017
1018 if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT)) 1018 if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT))
1019 blks++; 1019 blks++;
1020 if (GFS2_EAREQ_SIZE_STUFFED(er) > GFS2_SB(&ip->i_inode)->sd_jbsize) 1020 if (GFS2_EAREQ_SIZE_STUFFED(er) > GFS2_SB(&ip->i_inode)->sd_jbsize)
1021 blks += DIV_ROUND_UP(er->er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize); 1021 blks += DIV_ROUND_UP(er->er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize);
@@ -1040,7 +1040,7 @@ int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
1040 struct gfs2_ea_location el; 1040 struct gfs2_ea_location el;
1041 int error; 1041 int error;
1042 1042
1043 if (!ip->i_di.di_eattr) { 1043 if (!ip->i_eattr) {
1044 if (er->er_flags & XATTR_REPLACE) 1044 if (er->er_flags & XATTR_REPLACE)
1045 return -ENODATA; 1045 return -ENODATA;
1046 return ea_init(ip, er); 1046 return ea_init(ip, er);
@@ -1051,7 +1051,7 @@ int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
1051 return error; 1051 return error;
1052 1052
1053 if (el.el_ea) { 1053 if (el.el_ea) {
1054 if (ip->i_di.di_flags & GFS2_DIF_APPENDONLY) { 1054 if (ip->i_diskflags & GFS2_DIF_APPENDONLY) {
1055 brelse(el.el_bh); 1055 brelse(el.el_bh);
1056 return -EPERM; 1056 return -EPERM;
1057 } 1057 }
@@ -1145,7 +1145,7 @@ int gfs2_ea_remove_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
1145 struct gfs2_ea_location el; 1145 struct gfs2_ea_location el;
1146 int error; 1146 int error;
1147 1147
1148 if (!ip->i_di.di_eattr) 1148 if (!ip->i_eattr)
1149 return -ENODATA; 1149 return -ENODATA;
1150 1150
1151 error = gfs2_ea_find(ip, er, &el); 1151 error = gfs2_ea_find(ip, er, &el);
@@ -1309,7 +1309,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1309 1309
1310 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); 1310 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
1311 1311
1312 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &indbh); 1312 error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh);
1313 if (error) 1313 if (error)
1314 return error; 1314 return error;
1315 1315
@@ -1388,7 +1388,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1388 if (bstart) 1388 if (bstart)
1389 gfs2_free_meta(ip, bstart, blen); 1389 gfs2_free_meta(ip, bstart, blen);
1390 1390
1391 ip->i_di.di_flags &= ~GFS2_DIF_EA_INDIRECT; 1391 ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT;
1392 1392
1393 error = gfs2_meta_inode_buffer(ip, &dibh); 1393 error = gfs2_meta_inode_buffer(ip, &dibh);
1394 if (!error) { 1394 if (!error) {
@@ -1416,7 +1416,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1416 struct buffer_head *dibh; 1416 struct buffer_head *dibh;
1417 int error; 1417 int error;
1418 1418
1419 rgd = gfs2_blk2rgrpd(sdp, ip->i_di.di_eattr); 1419 rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr);
1420 if (!rgd) { 1420 if (!rgd) {
1421 gfs2_consist_inode(ip); 1421 gfs2_consist_inode(ip);
1422 return -EIO; 1422 return -EIO;
@@ -1432,9 +1432,9 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1432 if (error) 1432 if (error)
1433 goto out_gunlock; 1433 goto out_gunlock;
1434 1434
1435 gfs2_free_meta(ip, ip->i_di.di_eattr, 1); 1435 gfs2_free_meta(ip, ip->i_eattr, 1);
1436 1436
1437 ip->i_di.di_eattr = 0; 1437 ip->i_eattr = 0;
1438 gfs2_add_inode_blocks(&ip->i_inode, -1); 1438 gfs2_add_inode_blocks(&ip->i_inode, -1);
1439 1439
1440 error = gfs2_meta_inode_buffer(ip, &dibh); 1440 error = gfs2_meta_inode_buffer(ip, &dibh);
@@ -1479,7 +1479,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
1479 if (error) 1479 if (error)
1480 goto out_rindex; 1480 goto out_rindex;
1481 1481
1482 if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) { 1482 if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) {
1483 error = ea_dealloc_indirect(ip); 1483 error = ea_dealloc_indirect(ip);
1484 if (error) 1484 if (error)
1485 goto out_rindex; 1485 goto out_rindex;
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index c962283d4e7f..6b983aef785d 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -40,6 +40,7 @@
40#include "quota.h" 40#include "quota.h"
41#include "super.h" 41#include "super.h"
42#include "util.h" 42#include "util.h"
43#include "bmap.h"
43 44
44struct gfs2_gl_hash_bucket { 45struct gfs2_gl_hash_bucket {
45 struct hlist_head hb_list; 46 struct hlist_head hb_list;
@@ -61,9 +62,10 @@ static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int
61 62
62static DECLARE_RWSEM(gfs2_umount_flush_sem); 63static DECLARE_RWSEM(gfs2_umount_flush_sem);
63static struct dentry *gfs2_root; 64static struct dentry *gfs2_root;
64static struct task_struct *scand_process;
65static unsigned int scand_secs = 5;
66static struct workqueue_struct *glock_workqueue; 65static struct workqueue_struct *glock_workqueue;
66static LIST_HEAD(lru_list);
67static atomic_t lru_count = ATOMIC_INIT(0);
68static DEFINE_SPINLOCK(lru_lock);
67 69
68#define GFS2_GL_HASH_SHIFT 15 70#define GFS2_GL_HASH_SHIFT 15
69#define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT) 71#define GFS2_GL_HASH_SIZE (1 << GFS2_GL_HASH_SHIFT)
@@ -174,6 +176,22 @@ static void gfs2_glock_hold(struct gfs2_glock *gl)
174} 176}
175 177
176/** 178/**
179 * gfs2_glock_schedule_for_reclaim - Add a glock to the reclaim list
180 * @gl: the glock
181 *
182 */
183
184static void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl)
185{
186 spin_lock(&lru_lock);
187 if (list_empty(&gl->gl_lru) && gl->gl_state != LM_ST_UNLOCKED) {
188 list_add_tail(&gl->gl_lru, &lru_list);
189 atomic_inc(&lru_count);
190 }
191 spin_unlock(&lru_lock);
192}
193
194/**
177 * gfs2_glock_put() - Decrement reference count on glock 195 * gfs2_glock_put() - Decrement reference count on glock
178 * @gl: The glock to put 196 * @gl: The glock to put
179 * 197 *
@@ -187,14 +205,23 @@ int gfs2_glock_put(struct gfs2_glock *gl)
187 if (atomic_dec_and_test(&gl->gl_ref)) { 205 if (atomic_dec_and_test(&gl->gl_ref)) {
188 hlist_del(&gl->gl_list); 206 hlist_del(&gl->gl_list);
189 write_unlock(gl_lock_addr(gl->gl_hash)); 207 write_unlock(gl_lock_addr(gl->gl_hash));
208 spin_lock(&lru_lock);
209 if (!list_empty(&gl->gl_lru)) {
210 list_del_init(&gl->gl_lru);
211 atomic_dec(&lru_count);
212 }
213 spin_unlock(&lru_lock);
190 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_UNLOCKED); 214 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_UNLOCKED);
191 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_reclaim)); 215 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_lru));
192 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders)); 216 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
193 glock_free(gl); 217 glock_free(gl);
194 rv = 1; 218 rv = 1;
195 goto out; 219 goto out;
196 } 220 }
197 write_unlock(gl_lock_addr(gl->gl_hash)); 221 write_unlock(gl_lock_addr(gl->gl_hash));
222 /* 1 for being hashed, 1 for having state != LM_ST_UNLOCKED */
223 if (atomic_read(&gl->gl_ref) == 2)
224 gfs2_glock_schedule_for_reclaim(gl);
198out: 225out:
199 return rv; 226 return rv;
200} 227}
@@ -289,10 +316,13 @@ static void gfs2_holder_wake(struct gfs2_holder *gh)
289 * do_promote - promote as many requests as possible on the current queue 316 * do_promote - promote as many requests as possible on the current queue
290 * @gl: The glock 317 * @gl: The glock
291 * 318 *
292 * Returns: true if there is a blocked holder at the head of the list 319 * Returns: 1 if there is a blocked holder at the head of the list, or 2
320 * if a type specific operation is underway.
293 */ 321 */
294 322
295static int do_promote(struct gfs2_glock *gl) 323static int do_promote(struct gfs2_glock *gl)
324__releases(&gl->gl_spin)
325__acquires(&gl->gl_spin)
296{ 326{
297 const struct gfs2_glock_operations *glops = gl->gl_ops; 327 const struct gfs2_glock_operations *glops = gl->gl_ops;
298 struct gfs2_holder *gh, *tmp; 328 struct gfs2_holder *gh, *tmp;
@@ -310,6 +340,8 @@ restart:
310 ret = glops->go_lock(gh); 340 ret = glops->go_lock(gh);
311 spin_lock(&gl->gl_spin); 341 spin_lock(&gl->gl_spin);
312 if (ret) { 342 if (ret) {
343 if (ret == 1)
344 return 2;
313 gh->gh_error = ret; 345 gh->gh_error = ret;
314 list_del_init(&gh->gh_list); 346 list_del_init(&gh->gh_list);
315 gfs2_holder_wake(gh); 347 gfs2_holder_wake(gh);
@@ -414,6 +446,7 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
414 const struct gfs2_glock_operations *glops = gl->gl_ops; 446 const struct gfs2_glock_operations *glops = gl->gl_ops;
415 struct gfs2_holder *gh; 447 struct gfs2_holder *gh;
416 unsigned state = ret & LM_OUT_ST_MASK; 448 unsigned state = ret & LM_OUT_ST_MASK;
449 int rv;
417 450
418 spin_lock(&gl->gl_spin); 451 spin_lock(&gl->gl_spin);
419 state_change(gl, state); 452 state_change(gl, state);
@@ -468,7 +501,6 @@ retry:
468 gfs2_demote_wake(gl); 501 gfs2_demote_wake(gl);
469 if (state != LM_ST_UNLOCKED) { 502 if (state != LM_ST_UNLOCKED) {
470 if (glops->go_xmote_bh) { 503 if (glops->go_xmote_bh) {
471 int rv;
472 spin_unlock(&gl->gl_spin); 504 spin_unlock(&gl->gl_spin);
473 rv = glops->go_xmote_bh(gl, gh); 505 rv = glops->go_xmote_bh(gl, gh);
474 if (rv == -EAGAIN) 506 if (rv == -EAGAIN)
@@ -479,10 +511,13 @@ retry:
479 goto out; 511 goto out;
480 } 512 }
481 } 513 }
482 do_promote(gl); 514 rv = do_promote(gl);
515 if (rv == 2)
516 goto out_locked;
483 } 517 }
484out: 518out:
485 clear_bit(GLF_LOCK, &gl->gl_flags); 519 clear_bit(GLF_LOCK, &gl->gl_flags);
520out_locked:
486 spin_unlock(&gl->gl_spin); 521 spin_unlock(&gl->gl_spin);
487 gfs2_glock_put(gl); 522 gfs2_glock_put(gl);
488} 523}
@@ -511,6 +546,8 @@ static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock,
511 */ 546 */
512 547
513static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target) 548static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target)
549__releases(&gl->gl_spin)
550__acquires(&gl->gl_spin)
514{ 551{
515 const struct gfs2_glock_operations *glops = gl->gl_ops; 552 const struct gfs2_glock_operations *glops = gl->gl_ops;
516 struct gfs2_sbd *sdp = gl->gl_sbd; 553 struct gfs2_sbd *sdp = gl->gl_sbd;
@@ -576,8 +613,11 @@ static inline struct gfs2_holder *find_first_holder(const struct gfs2_glock *gl)
576 */ 613 */
577 614
578static void run_queue(struct gfs2_glock *gl, const int nonblock) 615static void run_queue(struct gfs2_glock *gl, const int nonblock)
616__releases(&gl->gl_spin)
617__acquires(&gl->gl_spin)
579{ 618{
580 struct gfs2_holder *gh = NULL; 619 struct gfs2_holder *gh = NULL;
620 int ret;
581 621
582 if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) 622 if (test_and_set_bit(GLF_LOCK, &gl->gl_flags))
583 return; 623 return;
@@ -596,8 +636,11 @@ static void run_queue(struct gfs2_glock *gl, const int nonblock)
596 } else { 636 } else {
597 if (test_bit(GLF_DEMOTE, &gl->gl_flags)) 637 if (test_bit(GLF_DEMOTE, &gl->gl_flags))
598 gfs2_demote_wake(gl); 638 gfs2_demote_wake(gl);
599 if (do_promote(gl) == 0) 639 ret = do_promote(gl);
640 if (ret == 0)
600 goto out; 641 goto out;
642 if (ret == 2)
643 return;
601 gh = find_first_waiter(gl); 644 gh = find_first_waiter(gl);
602 gl->gl_target = gh->gh_state; 645 gl->gl_target = gh->gh_state;
603 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) 646 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
@@ -820,7 +863,7 @@ static void wait_on_demote(struct gfs2_glock *gl)
820 */ 863 */
821 864
822static void handle_callback(struct gfs2_glock *gl, unsigned int state, 865static void handle_callback(struct gfs2_glock *gl, unsigned int state,
823 int remote, unsigned long delay) 866 unsigned long delay)
824{ 867{
825 int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE; 868 int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE;
826 869
@@ -828,9 +871,6 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state,
828 if (gl->gl_demote_state == LM_ST_EXCLUSIVE) { 871 if (gl->gl_demote_state == LM_ST_EXCLUSIVE) {
829 gl->gl_demote_state = state; 872 gl->gl_demote_state = state;
830 gl->gl_demote_time = jiffies; 873 gl->gl_demote_time = jiffies;
831 if (remote && gl->gl_ops->go_type == LM_TYPE_IOPEN &&
832 gl->gl_object)
833 gfs2_glock_schedule_for_reclaim(gl);
834 } else if (gl->gl_demote_state != LM_ST_UNLOCKED && 874 } else if (gl->gl_demote_state != LM_ST_UNLOCKED &&
835 gl->gl_demote_state != state) { 875 gl->gl_demote_state != state) {
836 gl->gl_demote_state = LM_ST_UNLOCKED; 876 gl->gl_demote_state = LM_ST_UNLOCKED;
@@ -877,6 +917,8 @@ void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...)
877 */ 917 */
878 918
879static inline void add_to_queue(struct gfs2_holder *gh) 919static inline void add_to_queue(struct gfs2_holder *gh)
920__releases(&gl->gl_spin)
921__acquires(&gl->gl_spin)
880{ 922{
881 struct gfs2_glock *gl = gh->gh_gl; 923 struct gfs2_glock *gl = gh->gh_gl;
882 struct gfs2_sbd *sdp = gl->gl_sbd; 924 struct gfs2_sbd *sdp = gl->gl_sbd;
@@ -998,7 +1040,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
998 1040
999 spin_lock(&gl->gl_spin); 1041 spin_lock(&gl->gl_spin);
1000 if (gh->gh_flags & GL_NOCACHE) 1042 if (gh->gh_flags & GL_NOCACHE)
1001 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1043 handle_callback(gl, LM_ST_UNLOCKED, 0);
1002 1044
1003 list_del_init(&gh->gh_list); 1045 list_del_init(&gh->gh_list);
1004 if (find_first_holder(gl) == NULL) { 1046 if (find_first_holder(gl) == NULL) {
@@ -1269,12 +1311,26 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name,
1269 delay = gl->gl_ops->go_min_hold_time; 1311 delay = gl->gl_ops->go_min_hold_time;
1270 1312
1271 spin_lock(&gl->gl_spin); 1313 spin_lock(&gl->gl_spin);
1272 handle_callback(gl, state, 1, delay); 1314 handle_callback(gl, state, delay);
1273 spin_unlock(&gl->gl_spin); 1315 spin_unlock(&gl->gl_spin);
1274 if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0) 1316 if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
1275 gfs2_glock_put(gl); 1317 gfs2_glock_put(gl);
1276} 1318}
1277 1319
1320static void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
1321{
1322 struct gfs2_jdesc *jd;
1323
1324 spin_lock(&sdp->sd_jindex_spin);
1325 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
1326 if (jd->jd_jid != jid)
1327 continue;
1328 jd->jd_dirty = 1;
1329 break;
1330 }
1331 spin_unlock(&sdp->sd_jindex_spin);
1332}
1333
1278/** 1334/**
1279 * gfs2_glock_cb - Callback used by locking module 1335 * gfs2_glock_cb - Callback used by locking module
1280 * @sdp: Pointer to the superblock 1336 * @sdp: Pointer to the superblock
@@ -1338,80 +1394,83 @@ void gfs2_glock_cb(void *cb_data, unsigned int type, void *data)
1338 * Returns: 1 if it's ok 1394 * Returns: 1 if it's ok
1339 */ 1395 */
1340 1396
1341static int demote_ok(struct gfs2_glock *gl) 1397static int demote_ok(const struct gfs2_glock *gl)
1342{ 1398{
1343 const struct gfs2_glock_operations *glops = gl->gl_ops; 1399 const struct gfs2_glock_operations *glops = gl->gl_ops;
1344 int demote = 1;
1345
1346 if (test_bit(GLF_STICKY, &gl->gl_flags))
1347 demote = 0;
1348 else if (glops->go_demote_ok)
1349 demote = glops->go_demote_ok(gl);
1350
1351 return demote;
1352}
1353
1354/**
1355 * gfs2_glock_schedule_for_reclaim - Add a glock to the reclaim list
1356 * @gl: the glock
1357 *
1358 */
1359
1360void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl)
1361{
1362 struct gfs2_sbd *sdp = gl->gl_sbd;
1363 1400
1364 spin_lock(&sdp->sd_reclaim_lock); 1401 if (gl->gl_state == LM_ST_UNLOCKED)
1365 if (list_empty(&gl->gl_reclaim)) { 1402 return 0;
1366 gfs2_glock_hold(gl); 1403 if (!list_empty(&gl->gl_holders))
1367 list_add(&gl->gl_reclaim, &sdp->sd_reclaim_list); 1404 return 0;
1368 atomic_inc(&sdp->sd_reclaim_count); 1405 if (glops->go_demote_ok)
1369 spin_unlock(&sdp->sd_reclaim_lock); 1406 return glops->go_demote_ok(gl);
1370 wake_up(&sdp->sd_reclaim_wq); 1407 return 1;
1371 } else
1372 spin_unlock(&sdp->sd_reclaim_lock);
1373} 1408}
1374 1409
1375/**
1376 * gfs2_reclaim_glock - process the next glock on the filesystem's reclaim list
1377 * @sdp: the filesystem
1378 *
1379 * Called from gfs2_glockd() glock reclaim daemon, or when promoting a
1380 * different glock and we notice that there are a lot of glocks in the
1381 * reclaim list.
1382 *
1383 */
1384 1410
1385void gfs2_reclaim_glock(struct gfs2_sbd *sdp) 1411static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask)
1386{ 1412{
1387 struct gfs2_glock *gl; 1413 struct gfs2_glock *gl;
1388 int done_callback = 0; 1414 int may_demote;
1415 int nr_skipped = 0;
1416 int got_ref = 0;
1417 LIST_HEAD(skipped);
1389 1418
1390 spin_lock(&sdp->sd_reclaim_lock); 1419 if (nr == 0)
1391 if (list_empty(&sdp->sd_reclaim_list)) { 1420 goto out;
1392 spin_unlock(&sdp->sd_reclaim_lock);
1393 return;
1394 }
1395 gl = list_entry(sdp->sd_reclaim_list.next,
1396 struct gfs2_glock, gl_reclaim);
1397 list_del_init(&gl->gl_reclaim);
1398 spin_unlock(&sdp->sd_reclaim_lock);
1399 1421
1400 atomic_dec(&sdp->sd_reclaim_count); 1422 if (!(gfp_mask & __GFP_FS))
1401 atomic_inc(&sdp->sd_reclaimed); 1423 return -1;
1402 1424
1403 spin_lock(&gl->gl_spin); 1425 spin_lock(&lru_lock);
1404 if (find_first_holder(gl) == NULL && 1426 while(nr && !list_empty(&lru_list)) {
1405 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) { 1427 gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru);
1406 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1428 list_del_init(&gl->gl_lru);
1407 done_callback = 1; 1429 atomic_dec(&lru_count);
1430
1431 /* Test for being demotable */
1432 if (!test_and_set_bit(GLF_LOCK, &gl->gl_flags)) {
1433 gfs2_glock_hold(gl);
1434 got_ref = 1;
1435 spin_unlock(&lru_lock);
1436 spin_lock(&gl->gl_spin);
1437 may_demote = demote_ok(gl);
1438 spin_unlock(&gl->gl_spin);
1439 clear_bit(GLF_LOCK, &gl->gl_flags);
1440 if (may_demote) {
1441 handle_callback(gl, LM_ST_UNLOCKED, 0);
1442 nr--;
1443 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1444 gfs2_glock_put(gl);
1445 }
1446 spin_lock(&lru_lock);
1447 if (may_demote)
1448 continue;
1449 }
1450 if (list_empty(&gl->gl_lru) &&
1451 (atomic_read(&gl->gl_ref) <= (2 + got_ref))) {
1452 nr_skipped++;
1453 list_add(&gl->gl_lru, &skipped);
1454 }
1455 if (got_ref) {
1456 spin_unlock(&lru_lock);
1457 gfs2_glock_put(gl);
1458 spin_lock(&lru_lock);
1459 got_ref = 0;
1460 }
1408 } 1461 }
1409 spin_unlock(&gl->gl_spin); 1462 list_splice(&skipped, &lru_list);
1410 if (!done_callback || 1463 atomic_add(nr_skipped, &lru_count);
1411 queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) 1464 spin_unlock(&lru_lock);
1412 gfs2_glock_put(gl); 1465out:
1466 return (atomic_read(&lru_count) / 100) * sysctl_vfs_cache_pressure;
1413} 1467}
1414 1468
1469static struct shrinker glock_shrinker = {
1470 .shrink = gfs2_shrink_glock_memory,
1471 .seeks = DEFAULT_SEEKS,
1472};
1473
1415/** 1474/**
1416 * examine_bucket - Call a function for glock in a hash bucket 1475 * examine_bucket - Call a function for glock in a hash bucket
1417 * @examiner: the function 1476 * @examiner: the function
@@ -1457,26 +1516,6 @@ out:
1457} 1516}
1458 1517
1459/** 1518/**
1460 * scan_glock - look at a glock and see if we can reclaim it
1461 * @gl: the glock to look at
1462 *
1463 */
1464
1465static void scan_glock(struct gfs2_glock *gl)
1466{
1467 if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object)
1468 return;
1469 if (test_bit(GLF_LOCK, &gl->gl_flags))
1470 return;
1471
1472 spin_lock(&gl->gl_spin);
1473 if (find_first_holder(gl) == NULL &&
1474 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl))
1475 gfs2_glock_schedule_for_reclaim(gl);
1476 spin_unlock(&gl->gl_spin);
1477}
1478
1479/**
1480 * clear_glock - look at a glock and see if we can free it from glock cache 1519 * clear_glock - look at a glock and see if we can free it from glock cache
1481 * @gl: the glock to look at 1520 * @gl: the glock to look at
1482 * 1521 *
@@ -1484,23 +1523,16 @@ static void scan_glock(struct gfs2_glock *gl)
1484 1523
1485static void clear_glock(struct gfs2_glock *gl) 1524static void clear_glock(struct gfs2_glock *gl)
1486{ 1525{
1487 struct gfs2_sbd *sdp = gl->gl_sbd; 1526 spin_lock(&lru_lock);
1488 int released; 1527 if (!list_empty(&gl->gl_lru)) {
1489 1528 list_del_init(&gl->gl_lru);
1490 spin_lock(&sdp->sd_reclaim_lock); 1529 atomic_dec(&lru_count);
1491 if (!list_empty(&gl->gl_reclaim)) {
1492 list_del_init(&gl->gl_reclaim);
1493 atomic_dec(&sdp->sd_reclaim_count);
1494 spin_unlock(&sdp->sd_reclaim_lock);
1495 released = gfs2_glock_put(gl);
1496 gfs2_assert(sdp, !released);
1497 } else {
1498 spin_unlock(&sdp->sd_reclaim_lock);
1499 } 1530 }
1531 spin_unlock(&lru_lock);
1500 1532
1501 spin_lock(&gl->gl_spin); 1533 spin_lock(&gl->gl_spin);
1502 if (find_first_holder(gl) == NULL && gl->gl_state != LM_ST_UNLOCKED) 1534 if (find_first_holder(gl) == NULL && gl->gl_state != LM_ST_UNLOCKED)
1503 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1535 handle_callback(gl, LM_ST_UNLOCKED, 0);
1504 spin_unlock(&gl->gl_spin); 1536 spin_unlock(&gl->gl_spin);
1505 gfs2_glock_hold(gl); 1537 gfs2_glock_hold(gl);
1506 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) 1538 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
@@ -1548,6 +1580,20 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
1548 } 1580 }
1549} 1581}
1550 1582
1583void gfs2_glock_finish_truncate(struct gfs2_inode *ip)
1584{
1585 struct gfs2_glock *gl = ip->i_gl;
1586 int ret;
1587
1588 ret = gfs2_truncatei_resume(ip);
1589 gfs2_assert_withdraw(gl->gl_sbd, ret == 0);
1590
1591 spin_lock(&gl->gl_spin);
1592 clear_bit(GLF_LOCK, &gl->gl_flags);
1593 run_queue(gl, 1);
1594 spin_unlock(&gl->gl_spin);
1595}
1596
1551static const char *state2str(unsigned state) 1597static const char *state2str(unsigned state)
1552{ 1598{
1553 switch(state) { 1599 switch(state) {
@@ -1623,8 +1669,6 @@ static const char *gflags2str(char *buf, const unsigned long *gflags)
1623 char *p = buf; 1669 char *p = buf;
1624 if (test_bit(GLF_LOCK, gflags)) 1670 if (test_bit(GLF_LOCK, gflags))
1625 *p++ = 'l'; 1671 *p++ = 'l';
1626 if (test_bit(GLF_STICKY, gflags))
1627 *p++ = 's';
1628 if (test_bit(GLF_DEMOTE, gflags)) 1672 if (test_bit(GLF_DEMOTE, gflags))
1629 *p++ = 'D'; 1673 *p++ = 'D';
1630 if (test_bit(GLF_PENDING_DEMOTE, gflags)) 1674 if (test_bit(GLF_PENDING_DEMOTE, gflags))
@@ -1743,34 +1787,6 @@ static int gfs2_dump_lockstate(struct gfs2_sbd *sdp)
1743 return error; 1787 return error;
1744} 1788}
1745 1789
1746/**
1747 * gfs2_scand - Look for cached glocks and inodes to toss from memory
1748 * @sdp: Pointer to GFS2 superblock
1749 *
1750 * One of these daemons runs, finding candidates to add to sd_reclaim_list.
1751 * See gfs2_glockd()
1752 */
1753
1754static int gfs2_scand(void *data)
1755{
1756 unsigned x;
1757 unsigned delay;
1758
1759 while (!kthread_should_stop()) {
1760 for (x = 0; x < GFS2_GL_HASH_SIZE; x++)
1761 examine_bucket(scan_glock, NULL, x);
1762 if (freezing(current))
1763 refrigerator();
1764 delay = scand_secs;
1765 if (delay < 1)
1766 delay = 1;
1767 schedule_timeout_interruptible(delay * HZ);
1768 }
1769
1770 return 0;
1771}
1772
1773
1774 1790
1775int __init gfs2_glock_init(void) 1791int __init gfs2_glock_init(void)
1776{ 1792{
@@ -1784,28 +1800,21 @@ int __init gfs2_glock_init(void)
1784 } 1800 }
1785#endif 1801#endif
1786 1802
1787 scand_process = kthread_run(gfs2_scand, NULL, "gfs2_scand");
1788 if (IS_ERR(scand_process))
1789 return PTR_ERR(scand_process);
1790
1791 glock_workqueue = create_workqueue("glock_workqueue"); 1803 glock_workqueue = create_workqueue("glock_workqueue");
1792 if (IS_ERR(glock_workqueue)) { 1804 if (IS_ERR(glock_workqueue))
1793 kthread_stop(scand_process);
1794 return PTR_ERR(glock_workqueue); 1805 return PTR_ERR(glock_workqueue);
1795 } 1806
1807 register_shrinker(&glock_shrinker);
1796 1808
1797 return 0; 1809 return 0;
1798} 1810}
1799 1811
1800void gfs2_glock_exit(void) 1812void gfs2_glock_exit(void)
1801{ 1813{
1814 unregister_shrinker(&glock_shrinker);
1802 destroy_workqueue(glock_workqueue); 1815 destroy_workqueue(glock_workqueue);
1803 kthread_stop(scand_process);
1804} 1816}
1805 1817
1806module_param(scand_secs, uint, S_IRUGO|S_IWUSR);
1807MODULE_PARM_DESC(scand_secs, "The number of seconds between scand runs");
1808
1809static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi) 1818static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
1810{ 1819{
1811 struct gfs2_glock *gl; 1820 struct gfs2_glock *gl;
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 695c6b193611..543ec7ecfbda 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -129,9 +129,9 @@ int gfs2_lvb_hold(struct gfs2_glock *gl);
129void gfs2_lvb_unhold(struct gfs2_glock *gl); 129void gfs2_lvb_unhold(struct gfs2_glock *gl);
130 130
131void gfs2_glock_cb(void *cb_data, unsigned int type, void *data); 131void gfs2_glock_cb(void *cb_data, unsigned int type, void *data);
132void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl);
133void gfs2_reclaim_glock(struct gfs2_sbd *sdp); 132void gfs2_reclaim_glock(struct gfs2_sbd *sdp);
134void gfs2_gl_hash_clear(struct gfs2_sbd *sdp); 133void gfs2_gl_hash_clear(struct gfs2_sbd *sdp);
134void gfs2_glock_finish_truncate(struct gfs2_inode *ip);
135 135
136int __init gfs2_glock_init(void); 136int __init gfs2_glock_init(void);
137void gfs2_glock_exit(void); 137void gfs2_glock_exit(void);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index c6c318c2a0f6..8522d3aa64fc 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -201,19 +201,12 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
201 * Returns: 1 if it's ok 201 * Returns: 1 if it's ok
202 */ 202 */
203 203
204static int inode_go_demote_ok(struct gfs2_glock *gl) 204static int inode_go_demote_ok(const struct gfs2_glock *gl)
205{ 205{
206 struct gfs2_sbd *sdp = gl->gl_sbd; 206 struct gfs2_sbd *sdp = gl->gl_sbd;
207 int demote = 0; 207 if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
208 208 return 0;
209 if (!gl->gl_object && !gl->gl_aspace->i_mapping->nrpages) 209 return 1;
210 demote = 1;
211 else if (!sdp->sd_args.ar_localcaching &&
212 time_after_eq(jiffies, gl->gl_stamp +
213 gfs2_tune_get(sdp, gt_demote_secs) * HZ))
214 demote = 1;
215
216 return demote;
217} 210}
218 211
219/** 212/**
@@ -227,6 +220,7 @@ static int inode_go_demote_ok(struct gfs2_glock *gl)
227static int inode_go_lock(struct gfs2_holder *gh) 220static int inode_go_lock(struct gfs2_holder *gh)
228{ 221{
229 struct gfs2_glock *gl = gh->gh_gl; 222 struct gfs2_glock *gl = gh->gh_gl;
223 struct gfs2_sbd *sdp = gl->gl_sbd;
230 struct gfs2_inode *ip = gl->gl_object; 224 struct gfs2_inode *ip = gl->gl_object;
231 int error = 0; 225 int error = 0;
232 226
@@ -239,10 +233,16 @@ static int inode_go_lock(struct gfs2_holder *gh)
239 return error; 233 return error;
240 } 234 }
241 235
242 if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) && 236 if ((ip->i_diskflags & GFS2_DIF_TRUNC_IN_PROG) &&
243 (gl->gl_state == LM_ST_EXCLUSIVE) && 237 (gl->gl_state == LM_ST_EXCLUSIVE) &&
244 (gh->gh_state == LM_ST_EXCLUSIVE)) 238 (gh->gh_state == LM_ST_EXCLUSIVE)) {
245 error = gfs2_truncatei_resume(ip); 239 spin_lock(&sdp->sd_trunc_lock);
240 if (list_empty(&ip->i_trunc_list))
241 list_add(&sdp->sd_trunc_list, &ip->i_trunc_list);
242 spin_unlock(&sdp->sd_trunc_lock);
243 wake_up(&sdp->sd_quota_wait);
244 return 1;
245 }
246 246
247 return error; 247 return error;
248} 248}
@@ -260,10 +260,13 @@ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
260 const struct gfs2_inode *ip = gl->gl_object; 260 const struct gfs2_inode *ip = gl->gl_object;
261 if (ip == NULL) 261 if (ip == NULL)
262 return 0; 262 return 0;
263 gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%08lx\n", 263 gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu/%llu\n",
264 (unsigned long long)ip->i_no_formal_ino, 264 (unsigned long long)ip->i_no_formal_ino,
265 (unsigned long long)ip->i_no_addr, 265 (unsigned long long)ip->i_no_addr,
266 IF2DT(ip->i_inode.i_mode), ip->i_flags); 266 IF2DT(ip->i_inode.i_mode), ip->i_flags,
267 (unsigned int)ip->i_diskflags,
268 (unsigned long long)ip->i_inode.i_size,
269 (unsigned long long)ip->i_disksize);
267 return 0; 270 return 0;
268} 271}
269 272
@@ -274,7 +277,7 @@ static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
274 * Returns: 1 if it's ok 277 * Returns: 1 if it's ok
275 */ 278 */
276 279
277static int rgrp_go_demote_ok(struct gfs2_glock *gl) 280static int rgrp_go_demote_ok(const struct gfs2_glock *gl)
278{ 281{
279 return !gl->gl_aspace->i_mapping->nrpages; 282 return !gl->gl_aspace->i_mapping->nrpages;
280} 283}
@@ -318,7 +321,9 @@ static int rgrp_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
318 const struct gfs2_rgrpd *rgd = gl->gl_object; 321 const struct gfs2_rgrpd *rgd = gl->gl_object;
319 if (rgd == NULL) 322 if (rgd == NULL)
320 return 0; 323 return 0;
321 gfs2_print_dbg(seq, " R: n:%llu\n", (unsigned long long)rgd->rd_addr); 324 gfs2_print_dbg(seq, " R: n:%llu f:%02x b:%u/%u i:%u\n",
325 (unsigned long long)rgd->rd_addr, rgd->rd_flags,
326 rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes);
322 return 0; 327 return 0;
323} 328}
324 329
@@ -374,13 +379,25 @@ static int trans_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
374} 379}
375 380
376/** 381/**
382 * trans_go_demote_ok
383 * @gl: the glock
384 *
385 * Always returns 0
386 */
387
388static int trans_go_demote_ok(const struct gfs2_glock *gl)
389{
390 return 0;
391}
392
393/**
377 * quota_go_demote_ok - Check to see if it's ok to unlock a quota glock 394 * quota_go_demote_ok - Check to see if it's ok to unlock a quota glock
378 * @gl: the glock 395 * @gl: the glock
379 * 396 *
380 * Returns: 1 if it's ok 397 * Returns: 1 if it's ok
381 */ 398 */
382 399
383static int quota_go_demote_ok(struct gfs2_glock *gl) 400static int quota_go_demote_ok(const struct gfs2_glock *gl)
384{ 401{
385 return !atomic_read(&gl->gl_lvb_count); 402 return !atomic_read(&gl->gl_lvb_count);
386} 403}
@@ -414,6 +431,7 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
414const struct gfs2_glock_operations gfs2_trans_glops = { 431const struct gfs2_glock_operations gfs2_trans_glops = {
415 .go_xmote_th = trans_go_sync, 432 .go_xmote_th = trans_go_sync,
416 .go_xmote_bh = trans_go_xmote_bh, 433 .go_xmote_bh = trans_go_xmote_bh,
434 .go_demote_ok = trans_go_demote_ok,
417 .go_type = LM_TYPE_NONDISK, 435 .go_type = LM_TYPE_NONDISK,
418}; 436};
419 437
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index f566ec1b4e8e..608849d00021 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -68,12 +68,6 @@ struct gfs2_bitmap {
68 u32 bi_len; 68 u32 bi_len;
69}; 69};
70 70
71struct gfs2_rgrp_host {
72 u32 rg_free;
73 u32 rg_dinodes;
74 u64 rg_igeneration;
75};
76
77struct gfs2_rgrpd { 71struct gfs2_rgrpd {
78 struct list_head rd_list; /* Link with superblock */ 72 struct list_head rd_list; /* Link with superblock */
79 struct list_head rd_list_mru; 73 struct list_head rd_list_mru;
@@ -83,14 +77,16 @@ struct gfs2_rgrpd {
83 u32 rd_length; /* length of rgrp header in fs blocks */ 77 u32 rd_length; /* length of rgrp header in fs blocks */
84 u32 rd_data; /* num of data blocks in rgrp */ 78 u32 rd_data; /* num of data blocks in rgrp */
85 u32 rd_bitbytes; /* number of bytes in data bitmaps */ 79 u32 rd_bitbytes; /* number of bytes in data bitmaps */
86 struct gfs2_rgrp_host rd_rg; 80 u32 rd_free;
81 u32 rd_free_clone;
82 u32 rd_dinodes;
83 u64 rd_igeneration;
87 struct gfs2_bitmap *rd_bits; 84 struct gfs2_bitmap *rd_bits;
88 unsigned int rd_bh_count;
89 struct mutex rd_mutex; 85 struct mutex rd_mutex;
90 u32 rd_free_clone;
91 struct gfs2_log_element rd_le; 86 struct gfs2_log_element rd_le;
92 u32 rd_last_alloc;
93 struct gfs2_sbd *rd_sbd; 87 struct gfs2_sbd *rd_sbd;
88 unsigned int rd_bh_count;
89 u32 rd_last_alloc;
94 unsigned char rd_flags; 90 unsigned char rd_flags;
95#define GFS2_RDF_CHECK 0x01 /* Need to check for unlinked inodes */ 91#define GFS2_RDF_CHECK 0x01 /* Need to check for unlinked inodes */
96#define GFS2_RDF_NOALLOC 0x02 /* rg prohibits allocation */ 92#define GFS2_RDF_NOALLOC 0x02 /* rg prohibits allocation */
@@ -129,7 +125,7 @@ struct gfs2_glock_operations {
129 void (*go_xmote_th) (struct gfs2_glock *gl); 125 void (*go_xmote_th) (struct gfs2_glock *gl);
130 int (*go_xmote_bh) (struct gfs2_glock *gl, struct gfs2_holder *gh); 126 int (*go_xmote_bh) (struct gfs2_glock *gl, struct gfs2_holder *gh);
131 void (*go_inval) (struct gfs2_glock *gl, int flags); 127 void (*go_inval) (struct gfs2_glock *gl, int flags);
132 int (*go_demote_ok) (struct gfs2_glock *gl); 128 int (*go_demote_ok) (const struct gfs2_glock *gl);
133 int (*go_lock) (struct gfs2_holder *gh); 129 int (*go_lock) (struct gfs2_holder *gh);
134 void (*go_unlock) (struct gfs2_holder *gh); 130 void (*go_unlock) (struct gfs2_holder *gh);
135 int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl); 131 int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
@@ -159,7 +155,6 @@ struct gfs2_holder {
159 155
160enum { 156enum {
161 GLF_LOCK = 1, 157 GLF_LOCK = 1,
162 GLF_STICKY = 2,
163 GLF_DEMOTE = 3, 158 GLF_DEMOTE = 3,
164 GLF_PENDING_DEMOTE = 4, 159 GLF_PENDING_DEMOTE = 4,
165 GLF_DEMOTE_IN_PROGRESS = 5, 160 GLF_DEMOTE_IN_PROGRESS = 5,
@@ -194,7 +189,7 @@ struct gfs2_glock {
194 unsigned long gl_tchange; 189 unsigned long gl_tchange;
195 void *gl_object; 190 void *gl_object;
196 191
197 struct list_head gl_reclaim; 192 struct list_head gl_lru;
198 193
199 struct gfs2_sbd *gl_sbd; 194 struct gfs2_sbd *gl_sbd;
200 195
@@ -233,29 +228,24 @@ enum {
233 GIF_USER = 4, /* user inode, not metadata addr space */ 228 GIF_USER = 4, /* user inode, not metadata addr space */
234}; 229};
235 230
236struct gfs2_dinode_host {
237 u64 di_size; /* number of bytes in file */
238 u64 di_generation; /* generation number for NFS */
239 u32 di_flags; /* GFS2_DIF_... */
240 /* These only apply to directories */
241 u32 di_entries; /* The number of entries in the directory */
242 u64 di_eattr; /* extended attribute block number */
243};
244 231
245struct gfs2_inode { 232struct gfs2_inode {
246 struct inode i_inode; 233 struct inode i_inode;
247 u64 i_no_addr; 234 u64 i_no_addr;
248 u64 i_no_formal_ino; 235 u64 i_no_formal_ino;
236 u64 i_generation;
237 u64 i_eattr;
238 loff_t i_disksize;
249 unsigned long i_flags; /* GIF_... */ 239 unsigned long i_flags; /* GIF_... */
250
251 struct gfs2_dinode_host i_di; /* To be replaced by ref to block */
252
253 struct gfs2_glock *i_gl; /* Move into i_gh? */ 240 struct gfs2_glock *i_gl; /* Move into i_gh? */
254 struct gfs2_holder i_iopen_gh; 241 struct gfs2_holder i_iopen_gh;
255 struct gfs2_holder i_gh; /* for prepare/commit_write only */ 242 struct gfs2_holder i_gh; /* for prepare/commit_write only */
256 struct gfs2_alloc *i_alloc; 243 struct gfs2_alloc *i_alloc;
257 u64 i_goal; /* goal block for allocations */ 244 u64 i_goal; /* goal block for allocations */
258 struct rw_semaphore i_rw_mutex; 245 struct rw_semaphore i_rw_mutex;
246 struct list_head i_trunc_list;
247 u32 i_entries;
248 u32 i_diskflags;
259 u8 i_height; 249 u8 i_height;
260 u8 i_depth; 250 u8 i_depth;
261}; 251};
@@ -406,13 +396,11 @@ struct gfs2_args {
406struct gfs2_tune { 396struct gfs2_tune {
407 spinlock_t gt_spin; 397 spinlock_t gt_spin;
408 398
409 unsigned int gt_demote_secs; /* Cache retention for unheld glock */
410 unsigned int gt_incore_log_blocks; 399 unsigned int gt_incore_log_blocks;
411 unsigned int gt_log_flush_secs; 400 unsigned int gt_log_flush_secs;
412 401
413 unsigned int gt_recoverd_secs; 402 unsigned int gt_recoverd_secs;
414 unsigned int gt_logd_secs; 403 unsigned int gt_logd_secs;
415 unsigned int gt_quotad_secs;
416 404
417 unsigned int gt_quota_simul_sync; /* Max quotavals to sync at once */ 405 unsigned int gt_quota_simul_sync; /* Max quotavals to sync at once */
418 unsigned int gt_quota_warn_period; /* Secs between quota warn msgs */ 406 unsigned int gt_quota_warn_period; /* Secs between quota warn msgs */
@@ -488,10 +476,6 @@ struct gfs2_sbd {
488 /* Lock Stuff */ 476 /* Lock Stuff */
489 477
490 struct lm_lockstruct sd_lockstruct; 478 struct lm_lockstruct sd_lockstruct;
491 struct list_head sd_reclaim_list;
492 spinlock_t sd_reclaim_lock;
493 wait_queue_head_t sd_reclaim_wq;
494 atomic_t sd_reclaim_count;
495 struct gfs2_holder sd_live_gh; 479 struct gfs2_holder sd_live_gh;
496 struct gfs2_glock *sd_rename_gl; 480 struct gfs2_glock *sd_rename_gl;
497 struct gfs2_glock *sd_trans_gl; 481 struct gfs2_glock *sd_trans_gl;
@@ -519,7 +503,6 @@ struct gfs2_sbd {
519 spinlock_t sd_statfs_spin; 503 spinlock_t sd_statfs_spin;
520 struct gfs2_statfs_change_host sd_statfs_master; 504 struct gfs2_statfs_change_host sd_statfs_master;
521 struct gfs2_statfs_change_host sd_statfs_local; 505 struct gfs2_statfs_change_host sd_statfs_local;
522 unsigned long sd_statfs_sync_time;
523 506
524 /* Resource group stuff */ 507 /* Resource group stuff */
525 508
@@ -552,8 +535,6 @@ struct gfs2_sbd {
552 struct task_struct *sd_recoverd_process; 535 struct task_struct *sd_recoverd_process;
553 struct task_struct *sd_logd_process; 536 struct task_struct *sd_logd_process;
554 struct task_struct *sd_quotad_process; 537 struct task_struct *sd_quotad_process;
555 struct task_struct *sd_glockd_process[GFS2_GLOCKD_MAX];
556 unsigned int sd_glockd_num;
557 538
558 /* Quota stuff */ 539 /* Quota stuff */
559 540
@@ -561,13 +542,15 @@ struct gfs2_sbd {
561 atomic_t sd_quota_count; 542 atomic_t sd_quota_count;
562 spinlock_t sd_quota_spin; 543 spinlock_t sd_quota_spin;
563 struct mutex sd_quota_mutex; 544 struct mutex sd_quota_mutex;
545 wait_queue_head_t sd_quota_wait;
546 struct list_head sd_trunc_list;
547 spinlock_t sd_trunc_lock;
564 548
565 unsigned int sd_quota_slots; 549 unsigned int sd_quota_slots;
566 unsigned int sd_quota_chunks; 550 unsigned int sd_quota_chunks;
567 unsigned char **sd_quota_bitmap; 551 unsigned char **sd_quota_bitmap;
568 552
569 u64 sd_quota_sync_gen; 553 u64 sd_quota_sync_gen;
570 unsigned long sd_quota_sync_time;
571 554
572 /* Log stuff */ 555 /* Log stuff */
573 556
@@ -624,10 +607,6 @@ struct gfs2_sbd {
624 struct mutex sd_freeze_lock; 607 struct mutex sd_freeze_lock;
625 unsigned int sd_freeze_count; 608 unsigned int sd_freeze_count;
626 609
627 /* Counters */
628
629 atomic_t sd_reclaimed;
630
631 char sd_fsname[GFS2_FSNAME_LEN]; 610 char sd_fsname[GFS2_FSNAME_LEN];
632 char sd_table_name[GFS2_FSNAME_LEN]; 611 char sd_table_name[GFS2_FSNAME_LEN];
633 char sd_proto_name[GFS2_FSNAME_LEN]; 612 char sd_proto_name[GFS2_FSNAME_LEN];
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index d57616840e89..3b87c188da41 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -32,7 +32,6 @@
32#include "log.h" 32#include "log.h"
33#include "meta_io.h" 33#include "meta_io.h"
34#include "ops_address.h" 34#include "ops_address.h"
35#include "ops_inode.h"
36#include "quota.h" 35#include "quota.h"
37#include "rgrp.h" 36#include "rgrp.h"
38#include "trans.h" 37#include "trans.h"
@@ -248,7 +247,6 @@ fail:
248 247
249static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) 248static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
250{ 249{
251 struct gfs2_dinode_host *di = &ip->i_di;
252 const struct gfs2_dinode *str = buf; 250 const struct gfs2_dinode *str = buf;
253 struct timespec atime; 251 struct timespec atime;
254 u16 height, depth; 252 u16 height, depth;
@@ -274,8 +272,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
274 * to do that. 272 * to do that.
275 */ 273 */
276 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink); 274 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
277 di->di_size = be64_to_cpu(str->di_size); 275 ip->i_disksize = be64_to_cpu(str->di_size);
278 i_size_write(&ip->i_inode, di->di_size); 276 i_size_write(&ip->i_inode, ip->i_disksize);
279 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); 277 gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
280 atime.tv_sec = be64_to_cpu(str->di_atime); 278 atime.tv_sec = be64_to_cpu(str->di_atime);
281 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); 279 atime.tv_nsec = be32_to_cpu(str->di_atime_nsec);
@@ -287,9 +285,9 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
287 ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); 285 ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
288 286
289 ip->i_goal = be64_to_cpu(str->di_goal_meta); 287 ip->i_goal = be64_to_cpu(str->di_goal_meta);
290 di->di_generation = be64_to_cpu(str->di_generation); 288 ip->i_generation = be64_to_cpu(str->di_generation);
291 289
292 di->di_flags = be32_to_cpu(str->di_flags); 290 ip->i_diskflags = be32_to_cpu(str->di_flags);
293 gfs2_set_inode_flags(&ip->i_inode); 291 gfs2_set_inode_flags(&ip->i_inode);
294 height = be16_to_cpu(str->di_height); 292 height = be16_to_cpu(str->di_height);
295 if (unlikely(height > GFS2_MAX_META_HEIGHT)) 293 if (unlikely(height > GFS2_MAX_META_HEIGHT))
@@ -300,9 +298,9 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
300 if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) 298 if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
301 goto corrupt; 299 goto corrupt;
302 ip->i_depth = (u8)depth; 300 ip->i_depth = (u8)depth;
303 di->di_entries = be32_to_cpu(str->di_entries); 301 ip->i_entries = be32_to_cpu(str->di_entries);
304 302
305 di->di_eattr = be64_to_cpu(str->di_eattr); 303 ip->i_eattr = be64_to_cpu(str->di_eattr);
306 if (S_ISREG(ip->i_inode.i_mode)) 304 if (S_ISREG(ip->i_inode.i_mode))
307 gfs2_set_aops(&ip->i_inode); 305 gfs2_set_aops(&ip->i_inode);
308 306
@@ -388,7 +386,6 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip)
388 gfs2_free_di(rgd, ip); 386 gfs2_free_di(rgd, ip);
389 387
390 gfs2_trans_end(sdp); 388 gfs2_trans_end(sdp);
391 clear_bit(GLF_STICKY, &ip->i_gl->gl_flags);
392 389
393out_rg_gunlock: 390out_rg_gunlock:
394 gfs2_glock_dq_uninit(&al->al_rgd_gh); 391 gfs2_glock_dq_uninit(&al->al_rgd_gh);
@@ -690,7 +687,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
690 return error; 687 return error;
691 } 688 }
692 689
693 if (dip->i_di.di_entries == (u32)-1) 690 if (dip->i_entries == (u32)-1)
694 return -EFBIG; 691 return -EFBIG;
695 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1) 692 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
696 return -EMLINK; 693 return -EMLINK;
@@ -790,11 +787,11 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
790 di->di_flags = 0; 787 di->di_flags = 0;
791 788
792 if (S_ISREG(mode)) { 789 if (S_ISREG(mode)) {
793 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) || 790 if ((dip->i_diskflags & GFS2_DIF_INHERIT_JDATA) ||
794 gfs2_tune_get(sdp, gt_new_files_jdata)) 791 gfs2_tune_get(sdp, gt_new_files_jdata))
795 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA); 792 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
796 } else if (S_ISDIR(mode)) { 793 } else if (S_ISDIR(mode)) {
797 di->di_flags |= cpu_to_be32(dip->i_di.di_flags & 794 di->di_flags |= cpu_to_be32(dip->i_diskflags &
798 GFS2_DIF_INHERIT_JDATA); 795 GFS2_DIF_INHERIT_JDATA);
799 } 796 }
800 797
@@ -1068,7 +1065,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
1068 struct qstr dotname; 1065 struct qstr dotname;
1069 int error; 1066 int error;
1070 1067
1071 if (ip->i_di.di_entries != 2) { 1068 if (ip->i_entries != 2) {
1072 if (gfs2_consist_inode(ip)) 1069 if (gfs2_consist_inode(ip))
1073 gfs2_dinode_print(ip); 1070 gfs2_dinode_print(ip);
1074 return -EIO; 1071 return -EIO;
@@ -1168,7 +1165,7 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
1168 return error; 1165 return error;
1169 } 1166 }
1170 1167
1171 if (!ip->i_di.di_size) { 1168 if (!ip->i_disksize) {
1172 gfs2_consist_inode(ip); 1169 gfs2_consist_inode(ip);
1173 error = -EIO; 1170 error = -EIO;
1174 goto out; 1171 goto out;
@@ -1178,7 +1175,7 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
1178 if (error) 1175 if (error)
1179 goto out; 1176 goto out;
1180 1177
1181 x = ip->i_di.di_size + 1; 1178 x = ip->i_disksize + 1;
1182 if (x > *len) { 1179 if (x > *len) {
1183 *buf = kmalloc(x, GFP_NOFS); 1180 *buf = kmalloc(x, GFP_NOFS);
1184 if (!*buf) { 1181 if (!*buf) {
@@ -1242,7 +1239,6 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1242 1239
1243void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) 1240void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1244{ 1241{
1245 const struct gfs2_dinode_host *di = &ip->i_di;
1246 struct gfs2_dinode *str = buf; 1242 struct gfs2_dinode *str = buf;
1247 1243
1248 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC); 1244 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
@@ -1256,7 +1252,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1256 str->di_uid = cpu_to_be32(ip->i_inode.i_uid); 1252 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
1257 str->di_gid = cpu_to_be32(ip->i_inode.i_gid); 1253 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
1258 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink); 1254 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
1259 str->di_size = cpu_to_be64(di->di_size); 1255 str->di_size = cpu_to_be64(ip->i_disksize);
1260 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); 1256 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
1261 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec); 1257 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1262 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec); 1258 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
@@ -1264,17 +1260,17 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1264 1260
1265 str->di_goal_meta = cpu_to_be64(ip->i_goal); 1261 str->di_goal_meta = cpu_to_be64(ip->i_goal);
1266 str->di_goal_data = cpu_to_be64(ip->i_goal); 1262 str->di_goal_data = cpu_to_be64(ip->i_goal);
1267 str->di_generation = cpu_to_be64(di->di_generation); 1263 str->di_generation = cpu_to_be64(ip->i_generation);
1268 1264
1269 str->di_flags = cpu_to_be32(di->di_flags); 1265 str->di_flags = cpu_to_be32(ip->i_diskflags);
1270 str->di_height = cpu_to_be16(ip->i_height); 1266 str->di_height = cpu_to_be16(ip->i_height);
1271 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && 1267 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
1272 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? 1268 !(ip->i_diskflags & GFS2_DIF_EXHASH) ?
1273 GFS2_FORMAT_DE : 0); 1269 GFS2_FORMAT_DE : 0);
1274 str->di_depth = cpu_to_be16(ip->i_depth); 1270 str->di_depth = cpu_to_be16(ip->i_depth);
1275 str->di_entries = cpu_to_be32(di->di_entries); 1271 str->di_entries = cpu_to_be32(ip->i_entries);
1276 1272
1277 str->di_eattr = cpu_to_be64(di->di_eattr); 1273 str->di_eattr = cpu_to_be64(ip->i_eattr);
1278 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); 1274 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
1279 str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec); 1275 str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec);
1280 str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec); 1276 str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec);
@@ -1282,22 +1278,21 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1282 1278
1283void gfs2_dinode_print(const struct gfs2_inode *ip) 1279void gfs2_dinode_print(const struct gfs2_inode *ip)
1284{ 1280{
1285 const struct gfs2_dinode_host *di = &ip->i_di;
1286
1287 printk(KERN_INFO " no_formal_ino = %llu\n", 1281 printk(KERN_INFO " no_formal_ino = %llu\n",
1288 (unsigned long long)ip->i_no_formal_ino); 1282 (unsigned long long)ip->i_no_formal_ino);
1289 printk(KERN_INFO " no_addr = %llu\n", 1283 printk(KERN_INFO " no_addr = %llu\n",
1290 (unsigned long long)ip->i_no_addr); 1284 (unsigned long long)ip->i_no_addr);
1291 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); 1285 printk(KERN_INFO " i_disksize = %llu\n",
1286 (unsigned long long)ip->i_disksize);
1292 printk(KERN_INFO " blocks = %llu\n", 1287 printk(KERN_INFO " blocks = %llu\n",
1293 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode)); 1288 (unsigned long long)gfs2_get_inode_blocks(&ip->i_inode));
1294 printk(KERN_INFO " i_goal = %llu\n", 1289 printk(KERN_INFO " i_goal = %llu\n",
1295 (unsigned long long)ip->i_goal); 1290 (unsigned long long)ip->i_goal);
1296 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags); 1291 printk(KERN_INFO " i_diskflags = 0x%.8X\n", ip->i_diskflags);
1297 printk(KERN_INFO " i_height = %u\n", ip->i_height); 1292 printk(KERN_INFO " i_height = %u\n", ip->i_height);
1298 printk(KERN_INFO " i_depth = %u\n", ip->i_depth); 1293 printk(KERN_INFO " i_depth = %u\n", ip->i_depth);
1299 printk(KERN_INFO " di_entries = %u\n", di->di_entries); 1294 printk(KERN_INFO " i_entries = %u\n", ip->i_entries);
1300 printk(KERN_INFO " di_eattr = %llu\n", 1295 printk(KERN_INFO " i_eattr = %llu\n",
1301 (unsigned long long)di->di_eattr); 1296 (unsigned long long)ip->i_eattr);
1302} 1297}
1303 1298
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 2d43f69610a0..d5329364cdff 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -10,6 +10,7 @@
10#ifndef __INODE_DOT_H__ 10#ifndef __INODE_DOT_H__
11#define __INODE_DOT_H__ 11#define __INODE_DOT_H__
12 12
13#include <linux/fs.h>
13#include "util.h" 14#include "util.h"
14 15
15static inline int gfs2_is_stuffed(const struct gfs2_inode *ip) 16static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
@@ -19,7 +20,7 @@ static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
19 20
20static inline int gfs2_is_jdata(const struct gfs2_inode *ip) 21static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
21{ 22{
22 return ip->i_di.di_flags & GFS2_DIF_JDATA; 23 return ip->i_diskflags & GFS2_DIF_JDATA;
23} 24}
24 25
25static inline int gfs2_is_writeback(const struct gfs2_inode *ip) 26static inline int gfs2_is_writeback(const struct gfs2_inode *ip)
@@ -97,5 +98,15 @@ struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
97void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf); 98void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
98void gfs2_dinode_print(const struct gfs2_inode *ip); 99void gfs2_dinode_print(const struct gfs2_inode *ip);
99 100
101extern const struct inode_operations gfs2_file_iops;
102extern const struct inode_operations gfs2_dir_iops;
103extern const struct inode_operations gfs2_symlink_iops;
104extern const struct file_operations gfs2_file_fops;
105extern const struct file_operations gfs2_dir_fops;
106extern const struct file_operations gfs2_file_fops_nolock;
107extern const struct file_operations gfs2_dir_fops_nolock;
108
109extern void gfs2_set_inode_flags(struct inode *inode);
110
100#endif /* __INODE_DOT_H__ */ 111#endif /* __INODE_DOT_H__ */
101 112
diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c
index 0c4cbe6c8285..1aa7eb6a0226 100644
--- a/fs/gfs2/locking/dlm/mount.c
+++ b/fs/gfs2/locking/dlm/mount.c
@@ -194,17 +194,25 @@ out:
194static void gdlm_recovery_done(void *lockspace, unsigned int jid, 194static void gdlm_recovery_done(void *lockspace, unsigned int jid,
195 unsigned int message) 195 unsigned int message)
196{ 196{
197 char env_jid[20];
198 char env_status[20];
199 char *envp[] = { env_jid, env_status, NULL };
197 struct gdlm_ls *ls = lockspace; 200 struct gdlm_ls *ls = lockspace;
198 ls->recover_jid_done = jid; 201 ls->recover_jid_done = jid;
199 ls->recover_jid_status = message; 202 ls->recover_jid_status = message;
200 kobject_uevent(&ls->kobj, KOBJ_CHANGE); 203 sprintf(env_jid, "JID=%d", jid);
204 sprintf(env_status, "RECOVERY=%s",
205 message == LM_RD_SUCCESS ? "Done" : "Failed");
206 kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp);
201} 207}
202 208
203static void gdlm_others_may_mount(void *lockspace) 209static void gdlm_others_may_mount(void *lockspace)
204{ 210{
211 char *message = "FIRSTMOUNT=Done";
212 char *envp[] = { message, NULL };
205 struct gdlm_ls *ls = lockspace; 213 struct gdlm_ls *ls = lockspace;
206 ls->first_done = 1; 214 ls->first_done = 1;
207 kobject_uevent(&ls->kobj, KOBJ_CHANGE); 215 kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp);
208} 216}
209 217
210/* Userspace gets the offline uevent, blocks new gfs locks on 218/* Userspace gets the offline uevent, blocks new gfs locks on
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 4ec571c3d8a9..9b7edcf7bd49 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -195,9 +195,23 @@ void gdlm_kobject_release(struct gdlm_ls *ls)
195 kobject_put(&ls->kobj); 195 kobject_put(&ls->kobj);
196} 196}
197 197
198static int gdlm_uevent(struct kset *kset, struct kobject *kobj,
199 struct kobj_uevent_env *env)
200{
201 struct gdlm_ls *ls = container_of(kobj, struct gdlm_ls, kobj);
202 add_uevent_var(env, "LOCKTABLE=%s:%s", ls->clustername, ls->fsname);
203 add_uevent_var(env, "LOCKPROTO=lock_dlm");
204 return 0;
205}
206
207static struct kset_uevent_ops gdlm_uevent_ops = {
208 .uevent = gdlm_uevent,
209};
210
211
198int gdlm_sysfs_init(void) 212int gdlm_sysfs_init(void)
199{ 213{
200 gdlm_kset = kset_create_and_add("lock_dlm", NULL, kernel_kobj); 214 gdlm_kset = kset_create_and_add("lock_dlm", &gdlm_uevent_ops, kernel_kobj);
201 if (!gdlm_kset) { 215 if (!gdlm_kset) {
202 printk(KERN_WARNING "%s: can not create kset\n", __func__); 216 printk(KERN_WARNING "%s: can not create kset\n", __func__);
203 return -ENOMEM; 217 return -ENOMEM;
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index bb2cc303ac29..7cacfde32194 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -19,7 +19,7 @@
19 19
20#include "gfs2.h" 20#include "gfs2.h"
21#include "incore.h" 21#include "incore.h"
22#include "ops_fstype.h" 22#include "super.h"
23#include "sys.h" 23#include "sys.h"
24#include "util.h" 24#include "util.h"
25#include "glock.h" 25#include "glock.h"
@@ -30,6 +30,7 @@ static void gfs2_init_inode_once(void *foo)
30 30
31 inode_init_once(&ip->i_inode); 31 inode_init_once(&ip->i_inode);
32 init_rwsem(&ip->i_rw_mutex); 32 init_rwsem(&ip->i_rw_mutex);
33 INIT_LIST_HEAD(&ip->i_trunc_list);
33 ip->i_alloc = NULL; 34 ip->i_alloc = NULL;
34} 35}
35 36
@@ -42,7 +43,7 @@ static void gfs2_init_glock_once(void *foo)
42 INIT_LIST_HEAD(&gl->gl_holders); 43 INIT_LIST_HEAD(&gl->gl_holders);
43 gl->gl_lvb = NULL; 44 gl->gl_lvb = NULL;
44 atomic_set(&gl->gl_lvb_count, 0); 45 atomic_set(&gl->gl_lvb_count, 0);
45 INIT_LIST_HEAD(&gl->gl_reclaim); 46 INIT_LIST_HEAD(&gl->gl_lru);
46 INIT_LIST_HEAD(&gl->gl_ail_list); 47 INIT_LIST_HEAD(&gl->gl_ail_list);
47 atomic_set(&gl->gl_ail_count, 0); 48 atomic_set(&gl->gl_ail_count, 0);
48} 49}
@@ -93,6 +94,12 @@ static int __init init_gfs2_fs(void)
93 if (!gfs2_rgrpd_cachep) 94 if (!gfs2_rgrpd_cachep)
94 goto fail; 95 goto fail;
95 96
97 gfs2_quotad_cachep = kmem_cache_create("gfs2_quotad",
98 sizeof(struct gfs2_quota_data),
99 0, 0, NULL);
100 if (!gfs2_quotad_cachep)
101 goto fail;
102
96 error = register_filesystem(&gfs2_fs_type); 103 error = register_filesystem(&gfs2_fs_type);
97 if (error) 104 if (error)
98 goto fail; 105 goto fail;
@@ -112,6 +119,9 @@ fail_unregister:
112fail: 119fail:
113 gfs2_glock_exit(); 120 gfs2_glock_exit();
114 121
122 if (gfs2_quotad_cachep)
123 kmem_cache_destroy(gfs2_quotad_cachep);
124
115 if (gfs2_rgrpd_cachep) 125 if (gfs2_rgrpd_cachep)
116 kmem_cache_destroy(gfs2_rgrpd_cachep); 126 kmem_cache_destroy(gfs2_rgrpd_cachep);
117 127
@@ -140,6 +150,7 @@ static void __exit exit_gfs2_fs(void)
140 unregister_filesystem(&gfs2_fs_type); 150 unregister_filesystem(&gfs2_fs_type);
141 unregister_filesystem(&gfs2meta_fs_type); 151 unregister_filesystem(&gfs2meta_fs_type);
142 152
153 kmem_cache_destroy(gfs2_quotad_cachep);
143 kmem_cache_destroy(gfs2_rgrpd_cachep); 154 kmem_cache_destroy(gfs2_rgrpd_cachep);
144 kmem_cache_destroy(gfs2_bufdata_cachep); 155 kmem_cache_destroy(gfs2_bufdata_cachep);
145 kmem_cache_destroy(gfs2_inode_cachep); 156 kmem_cache_destroy(gfs2_inode_cachep);
diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c
index f96eb90a2cfa..3cb0a44ba023 100644
--- a/fs/gfs2/mount.c
+++ b/fs/gfs2/mount.c
@@ -32,7 +32,6 @@ enum {
32 Opt_debug, 32 Opt_debug,
33 Opt_nodebug, 33 Opt_nodebug,
34 Opt_upgrade, 34 Opt_upgrade,
35 Opt_num_glockd,
36 Opt_acl, 35 Opt_acl,
37 Opt_noacl, 36 Opt_noacl,
38 Opt_quota_off, 37 Opt_quota_off,
@@ -57,7 +56,6 @@ static const match_table_t tokens = {
57 {Opt_debug, "debug"}, 56 {Opt_debug, "debug"},
58 {Opt_nodebug, "nodebug"}, 57 {Opt_nodebug, "nodebug"},
59 {Opt_upgrade, "upgrade"}, 58 {Opt_upgrade, "upgrade"},
60 {Opt_num_glockd, "num_glockd=%d"},
61 {Opt_acl, "acl"}, 59 {Opt_acl, "acl"},
62 {Opt_noacl, "noacl"}, 60 {Opt_noacl, "noacl"},
63 {Opt_quota_off, "quota=off"}, 61 {Opt_quota_off, "quota=off"},
@@ -87,16 +85,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
87 int error = 0; 85 int error = 0;
88 86
89 if (!remount) { 87 if (!remount) {
90 /* If someone preloaded options, use those instead */
91 spin_lock(&gfs2_sys_margs_lock);
92 if (gfs2_sys_margs) {
93 data = gfs2_sys_margs;
94 gfs2_sys_margs = NULL;
95 }
96 spin_unlock(&gfs2_sys_margs_lock);
97
98 /* Set some defaults */ 88 /* Set some defaults */
99 args->ar_num_glockd = GFS2_GLOCKD_DEFAULT;
100 args->ar_quota = GFS2_QUOTA_DEFAULT; 89 args->ar_quota = GFS2_QUOTA_DEFAULT;
101 args->ar_data = GFS2_DATA_DEFAULT; 90 args->ar_data = GFS2_DATA_DEFAULT;
102 } 91 }
@@ -105,7 +94,7 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
105 process them */ 94 process them */
106 95
107 for (options = data; (o = strsep(&options, ",")); ) { 96 for (options = data; (o = strsep(&options, ",")); ) {
108 int token, option; 97 int token;
109 substring_t tmp[MAX_OPT_ARGS]; 98 substring_t tmp[MAX_OPT_ARGS];
110 99
111 if (!*o) 100 if (!*o)
@@ -196,22 +185,6 @@ int gfs2_mount_args(struct gfs2_sbd *sdp, char *data_arg, int remount)
196 goto cant_remount; 185 goto cant_remount;
197 args->ar_upgrade = 1; 186 args->ar_upgrade = 1;
198 break; 187 break;
199 case Opt_num_glockd:
200 if ((error = match_int(&tmp[0], &option))) {
201 fs_info(sdp, "problem getting num_glockd\n");
202 goto out_error;
203 }
204
205 if (remount && option != args->ar_num_glockd)
206 goto cant_remount;
207 if (!option || option > GFS2_GLOCKD_MAX) {
208 fs_info(sdp, "0 < num_glockd <= %u (not %u)\n",
209 GFS2_GLOCKD_MAX, option);
210 error = -EINVAL;
211 goto out_error;
212 }
213 args->ar_num_glockd = option;
214 break;
215 case Opt_acl: 188 case Opt_acl:
216 args->ar_posix_acl = 1; 189 args->ar_posix_acl = 1;
217 sdp->sd_vfs->s_flags |= MS_POSIXACL; 190 sdp->sd_vfs->s_flags |= MS_POSIXACL;
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 27563816e1c5..6e4ea36c6605 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -210,25 +210,23 @@ static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc
210{ 210{
211 struct inode *inode = page->mapping->host; 211 struct inode *inode = page->mapping->host;
212 struct gfs2_sbd *sdp = GFS2_SB(inode); 212 struct gfs2_sbd *sdp = GFS2_SB(inode);
213 int error; 213 int ret;
214 int done_trans = 0; 214 int done_trans = 0;
215 215
216 error = gfs2_writepage_common(page, wbc);
217 if (error <= 0)
218 return error;
219
220 if (PageChecked(page)) { 216 if (PageChecked(page)) {
221 if (wbc->sync_mode != WB_SYNC_ALL) 217 if (wbc->sync_mode != WB_SYNC_ALL)
222 goto out_ignore; 218 goto out_ignore;
223 error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0); 219 ret = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
224 if (error) 220 if (ret)
225 goto out_ignore; 221 goto out_ignore;
226 done_trans = 1; 222 done_trans = 1;
227 } 223 }
228 error = __gfs2_jdata_writepage(page, wbc); 224 ret = gfs2_writepage_common(page, wbc);
225 if (ret > 0)
226 ret = __gfs2_jdata_writepage(page, wbc);
229 if (done_trans) 227 if (done_trans)
230 gfs2_trans_end(sdp); 228 gfs2_trans_end(sdp);
231 return error; 229 return ret;
232 230
233out_ignore: 231out_ignore:
234 redirty_page_for_writepage(wbc, page); 232 redirty_page_for_writepage(wbc, page);
@@ -453,8 +451,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
453 451
454 kaddr = kmap_atomic(page, KM_USER0); 452 kaddr = kmap_atomic(page, KM_USER0);
455 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), 453 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
456 ip->i_di.di_size); 454 ip->i_disksize);
457 memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size); 455 memset(kaddr + ip->i_disksize, 0, PAGE_CACHE_SIZE - ip->i_disksize);
458 kunmap_atomic(kaddr, KM_USER0); 456 kunmap_atomic(kaddr, KM_USER0);
459 flush_dcache_page(page); 457 flush_dcache_page(page);
460 brelse(dibh); 458 brelse(dibh);
@@ -627,7 +625,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
627{ 625{
628 struct gfs2_inode *ip = GFS2_I(mapping->host); 626 struct gfs2_inode *ip = GFS2_I(mapping->host);
629 struct gfs2_sbd *sdp = GFS2_SB(mapping->host); 627 struct gfs2_sbd *sdp = GFS2_SB(mapping->host);
630 unsigned int data_blocks, ind_blocks, rblocks; 628 unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
631 int alloc_required; 629 int alloc_required;
632 int error = 0; 630 int error = 0;
633 struct gfs2_alloc *al; 631 struct gfs2_alloc *al;
@@ -641,11 +639,13 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
641 if (unlikely(error)) 639 if (unlikely(error))
642 goto out_uninit; 640 goto out_uninit;
643 641
644 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
645 error = gfs2_write_alloc_required(ip, pos, len, &alloc_required); 642 error = gfs2_write_alloc_required(ip, pos, len, &alloc_required);
646 if (error) 643 if (error)
647 goto out_unlock; 644 goto out_unlock;
648 645
646 if (alloc_required || gfs2_is_jdata(ip))
647 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
648
649 if (alloc_required) { 649 if (alloc_required) {
650 al = gfs2_alloc_get(ip); 650 al = gfs2_alloc_get(ip);
651 if (!al) { 651 if (!al) {
@@ -675,7 +675,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
675 goto out_trans_fail; 675 goto out_trans_fail;
676 676
677 error = -ENOMEM; 677 error = -ENOMEM;
678 page = __grab_cache_page(mapping, index); 678 page = grab_cache_page_write_begin(mapping, index, flags);
679 *pagep = page; 679 *pagep = page;
680 if (unlikely(!page)) 680 if (unlikely(!page))
681 goto out_endtrans; 681 goto out_endtrans;
@@ -782,7 +782,7 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
782 782
783 if (inode->i_size < to) { 783 if (inode->i_size < to) {
784 i_size_write(inode, to); 784 i_size_write(inode, to);
785 ip->i_di.di_size = inode->i_size; 785 ip->i_disksize = inode->i_size;
786 di->di_size = cpu_to_be64(inode->i_size); 786 di->di_size = cpu_to_be64(inode->i_size);
787 mark_inode_dirty(inode); 787 mark_inode_dirty(inode);
788 } 788 }
@@ -847,9 +847,9 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
847 847
848 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); 848 ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
849 849
850 if (likely(ret >= 0) && (inode->i_size > ip->i_di.di_size)) { 850 if (likely(ret >= 0) && (inode->i_size > ip->i_disksize)) {
851 di = (struct gfs2_dinode *)dibh->b_data; 851 di = (struct gfs2_dinode *)dibh->b_data;
852 ip->i_di.di_size = inode->i_size; 852 ip->i_disksize = inode->i_size;
853 di->di_size = cpu_to_be64(inode->i_size); 853 di->di_size = cpu_to_be64(inode->i_size);
854 mark_inode_dirty(inode); 854 mark_inode_dirty(inode);
855 } 855 }
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c
index 4a5e676b4420..c2ad36330ca3 100644
--- a/fs/gfs2/ops_dentry.c
+++ b/fs/gfs2/ops_dentry.c
@@ -19,7 +19,7 @@
19#include "incore.h" 19#include "incore.h"
20#include "dir.h" 20#include "dir.h"
21#include "glock.h" 21#include "glock.h"
22#include "ops_dentry.h" 22#include "super.h"
23#include "util.h" 23#include "util.h"
24#include "inode.h" 24#include "inode.h"
25 25
diff --git a/fs/gfs2/ops_dentry.h b/fs/gfs2/ops_dentry.h
deleted file mode 100644
index 5caa3db4d3f5..000000000000
--- a/fs/gfs2/ops_dentry.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#ifndef __OPS_DENTRY_DOT_H__
11#define __OPS_DENTRY_DOT_H__
12
13#include <linux/dcache.h>
14
15extern struct dentry_operations gfs2_dops;
16
17#endif /* __OPS_DENTRY_DOT_H__ */
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index bbb8c36403a9..7fdeb14ddd1a 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -22,8 +22,7 @@
22#include "glock.h" 22#include "glock.h"
23#include "glops.h" 23#include "glops.h"
24#include "inode.h" 24#include "inode.h"
25#include "ops_dentry.h" 25#include "super.h"
26#include "ops_fstype.h"
27#include "rgrp.h" 26#include "rgrp.h"
28#include "util.h" 27#include "util.h"
29 28
@@ -214,7 +213,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,
214 } 213 }
215 214
216 error = -EIO; 215 error = -EIO;
217 if (GFS2_I(inode)->i_di.di_flags & GFS2_DIF_SYSTEM) { 216 if (GFS2_I(inode)->i_diskflags & GFS2_DIF_SYSTEM) {
218 iput(inode); 217 iput(inode);
219 goto fail; 218 goto fail;
220 } 219 }
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 3a747f8e2188..289c5f54ba53 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -39,7 +39,6 @@
39#include "util.h" 39#include "util.h"
40#include "eaops.h" 40#include "eaops.h"
41#include "ops_address.h" 41#include "ops_address.h"
42#include "ops_inode.h"
43 42
44/** 43/**
45 * gfs2_llseek - seek to a location in a file 44 * gfs2_llseek - seek to a location in a file
@@ -158,8 +157,8 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
158 if (error) 157 if (error)
159 return error; 158 return error;
160 159
161 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags); 160 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_diskflags);
162 if (!S_ISDIR(inode->i_mode) && ip->i_di.di_flags & GFS2_DIF_JDATA) 161 if (!S_ISDIR(inode->i_mode) && ip->i_diskflags & GFS2_DIF_JDATA)
163 fsflags |= FS_JOURNAL_DATA_FL; 162 fsflags |= FS_JOURNAL_DATA_FL;
164 if (put_user(fsflags, ptr)) 163 if (put_user(fsflags, ptr))
165 error = -EFAULT; 164 error = -EFAULT;
@@ -172,17 +171,16 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
172void gfs2_set_inode_flags(struct inode *inode) 171void gfs2_set_inode_flags(struct inode *inode)
173{ 172{
174 struct gfs2_inode *ip = GFS2_I(inode); 173 struct gfs2_inode *ip = GFS2_I(inode);
175 struct gfs2_dinode_host *di = &ip->i_di;
176 unsigned int flags = inode->i_flags; 174 unsigned int flags = inode->i_flags;
177 175
178 flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); 176 flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
179 if (di->di_flags & GFS2_DIF_IMMUTABLE) 177 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
180 flags |= S_IMMUTABLE; 178 flags |= S_IMMUTABLE;
181 if (di->di_flags & GFS2_DIF_APPENDONLY) 179 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
182 flags |= S_APPEND; 180 flags |= S_APPEND;
183 if (di->di_flags & GFS2_DIF_NOATIME) 181 if (ip->i_diskflags & GFS2_DIF_NOATIME)
184 flags |= S_NOATIME; 182 flags |= S_NOATIME;
185 if (di->di_flags & GFS2_DIF_SYNC) 183 if (ip->i_diskflags & GFS2_DIF_SYNC)
186 flags |= S_SYNC; 184 flags |= S_SYNC;
187 inode->i_flags = flags; 185 inode->i_flags = flags;
188} 186}
@@ -221,7 +219,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
221 if (error) 219 if (error)
222 goto out_drop_write; 220 goto out_drop_write;
223 221
224 flags = ip->i_di.di_flags; 222 flags = ip->i_diskflags;
225 new_flags = (flags & ~mask) | (reqflags & mask); 223 new_flags = (flags & ~mask) | (reqflags & mask);
226 if ((new_flags ^ flags) == 0) 224 if ((new_flags ^ flags) == 0)
227 goto out; 225 goto out;
@@ -260,7 +258,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
260 if (error) 258 if (error)
261 goto out_trans_end; 259 goto out_trans_end;
262 gfs2_trans_add_bh(ip->i_gl, bh, 1); 260 gfs2_trans_add_bh(ip->i_gl, bh, 1);
263 ip->i_di.di_flags = new_flags; 261 ip->i_diskflags = new_flags;
264 gfs2_dinode_out(ip, bh->b_data); 262 gfs2_dinode_out(ip, bh->b_data);
265 brelse(bh); 263 brelse(bh);
266 gfs2_set_inode_flags(inode); 264 gfs2_set_inode_flags(inode);
@@ -357,7 +355,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
357 goto out; 355 goto out;
358 356
359 set_bit(GIF_SW_PAGED, &ip->i_flags); 357 set_bit(GIF_SW_PAGED, &ip->i_flags);
360 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
361 ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required); 358 ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required);
362 if (ret || !alloc_required) 359 if (ret || !alloc_required)
363 goto out_unlock; 360 goto out_unlock;
@@ -369,6 +366,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
369 ret = gfs2_quota_lock_check(ip); 366 ret = gfs2_quota_lock_check(ip);
370 if (ret) 367 if (ret)
371 goto out_alloc_put; 368 goto out_alloc_put;
369 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
372 al->al_requested = data_blocks + ind_blocks; 370 al->al_requested = data_blocks + ind_blocks;
373 ret = gfs2_inplace_reserve(ip); 371 ret = gfs2_inplace_reserve(ip);
374 if (ret) 372 if (ret)
@@ -479,7 +477,7 @@ static int gfs2_open(struct inode *inode, struct file *file)
479 goto fail; 477 goto fail;
480 478
481 if (!(file->f_flags & O_LARGEFILE) && 479 if (!(file->f_flags & O_LARGEFILE) &&
482 ip->i_di.di_size > MAX_NON_LFS) { 480 ip->i_disksize > MAX_NON_LFS) {
483 error = -EOVERFLOW; 481 error = -EOVERFLOW;
484 goto fail_gunlock; 482 goto fail_gunlock;
485 } 483 }
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index b117fcf2c4f5..f91eebdde581 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -22,20 +22,18 @@
22#include "gfs2.h" 22#include "gfs2.h"
23#include "incore.h" 23#include "incore.h"
24#include "bmap.h" 24#include "bmap.h"
25#include "daemon.h"
26#include "glock.h" 25#include "glock.h"
27#include "glops.h" 26#include "glops.h"
28#include "inode.h" 27#include "inode.h"
29#include "mount.h" 28#include "mount.h"
30#include "ops_fstype.h"
31#include "ops_dentry.h"
32#include "ops_super.h"
33#include "recovery.h" 29#include "recovery.h"
34#include "rgrp.h" 30#include "rgrp.h"
35#include "super.h" 31#include "super.h"
36#include "sys.h" 32#include "sys.h"
37#include "util.h" 33#include "util.h"
38#include "log.h" 34#include "log.h"
35#include "quota.h"
36#include "dir.h"
39 37
40#define DO 0 38#define DO 0
41#define UNDO 1 39#define UNDO 1
@@ -58,12 +56,10 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
58{ 56{
59 spin_lock_init(&gt->gt_spin); 57 spin_lock_init(&gt->gt_spin);
60 58
61 gt->gt_demote_secs = 300;
62 gt->gt_incore_log_blocks = 1024; 59 gt->gt_incore_log_blocks = 1024;
63 gt->gt_log_flush_secs = 60; 60 gt->gt_log_flush_secs = 60;
64 gt->gt_recoverd_secs = 60; 61 gt->gt_recoverd_secs = 60;
65 gt->gt_logd_secs = 1; 62 gt->gt_logd_secs = 1;
66 gt->gt_quotad_secs = 5;
67 gt->gt_quota_simul_sync = 64; 63 gt->gt_quota_simul_sync = 64;
68 gt->gt_quota_warn_period = 10; 64 gt->gt_quota_warn_period = 10;
69 gt->gt_quota_scale_num = 1; 65 gt->gt_quota_scale_num = 1;
@@ -91,10 +87,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
91 87
92 gfs2_tune_init(&sdp->sd_tune); 88 gfs2_tune_init(&sdp->sd_tune);
93 89
94 INIT_LIST_HEAD(&sdp->sd_reclaim_list);
95 spin_lock_init(&sdp->sd_reclaim_lock);
96 init_waitqueue_head(&sdp->sd_reclaim_wq);
97
98 mutex_init(&sdp->sd_inum_mutex); 90 mutex_init(&sdp->sd_inum_mutex);
99 spin_lock_init(&sdp->sd_statfs_spin); 91 spin_lock_init(&sdp->sd_statfs_spin);
100 92
@@ -110,6 +102,9 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
110 INIT_LIST_HEAD(&sdp->sd_quota_list); 102 INIT_LIST_HEAD(&sdp->sd_quota_list);
111 spin_lock_init(&sdp->sd_quota_spin); 103 spin_lock_init(&sdp->sd_quota_spin);
112 mutex_init(&sdp->sd_quota_mutex); 104 mutex_init(&sdp->sd_quota_mutex);
105 init_waitqueue_head(&sdp->sd_quota_wait);
106 INIT_LIST_HEAD(&sdp->sd_trunc_list);
107 spin_lock_init(&sdp->sd_trunc_lock);
113 108
114 spin_lock_init(&sdp->sd_log_lock); 109 spin_lock_init(&sdp->sd_log_lock);
115 110
@@ -443,24 +438,11 @@ out:
443static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, 438static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
444 int undo) 439 int undo)
445{ 440{
446 struct task_struct *p;
447 int error = 0; 441 int error = 0;
448 442
449 if (undo) 443 if (undo)
450 goto fail_trans; 444 goto fail_trans;
451 445
452 for (sdp->sd_glockd_num = 0;
453 sdp->sd_glockd_num < sdp->sd_args.ar_num_glockd;
454 sdp->sd_glockd_num++) {
455 p = kthread_run(gfs2_glockd, sdp, "gfs2_glockd");
456 error = IS_ERR(p);
457 if (error) {
458 fs_err(sdp, "can't start glockd thread: %d\n", error);
459 goto fail;
460 }
461 sdp->sd_glockd_process[sdp->sd_glockd_num] = p;
462 }
463
464 error = gfs2_glock_nq_num(sdp, 446 error = gfs2_glock_nq_num(sdp,
465 GFS2_MOUNT_LOCK, &gfs2_nondisk_glops, 447 GFS2_MOUNT_LOCK, &gfs2_nondisk_glops,
466 LM_ST_EXCLUSIVE, LM_FLAG_NOEXP | GL_NOCACHE, 448 LM_ST_EXCLUSIVE, LM_FLAG_NOEXP | GL_NOCACHE,
@@ -493,7 +475,6 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
493 fs_err(sdp, "can't create transaction glock: %d\n", error); 475 fs_err(sdp, "can't create transaction glock: %d\n", error);
494 goto fail_rename; 476 goto fail_rename;
495 } 477 }
496 set_bit(GLF_STICKY, &sdp->sd_trans_gl->gl_flags);
497 478
498 return 0; 479 return 0;
499 480
@@ -506,9 +487,6 @@ fail_live:
506fail_mount: 487fail_mount:
507 gfs2_glock_dq_uninit(mount_gh); 488 gfs2_glock_dq_uninit(mount_gh);
508fail: 489fail:
509 while (sdp->sd_glockd_num--)
510 kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]);
511
512 return error; 490 return error;
513} 491}
514 492
@@ -620,7 +598,7 @@ static int map_journal_extents(struct gfs2_sbd *sdp)
620 598
621 prev_db = 0; 599 prev_db = 0;
622 600
623 for (lb = 0; lb < ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; lb++) { 601 for (lb = 0; lb < ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; lb++) {
624 bh.b_state = 0; 602 bh.b_state = 0;
625 bh.b_blocknr = 0; 603 bh.b_blocknr = 0;
626 bh.b_size = 1 << ip->i_inode.i_blkbits; 604 bh.b_size = 1 << ip->i_inode.i_blkbits;
@@ -661,6 +639,72 @@ static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)
661 sdp->sd_lockstruct.ls_lockspace); 639 sdp->sd_lockstruct.ls_lockspace);
662} 640}
663 641
642/**
643 * gfs2_jindex_hold - Grab a lock on the jindex
644 * @sdp: The GFS2 superblock
645 * @ji_gh: the holder for the jindex glock
646 *
647 * Returns: errno
648 */
649
650static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
651{
652 struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex);
653 struct qstr name;
654 char buf[20];
655 struct gfs2_jdesc *jd;
656 int error;
657
658 name.name = buf;
659
660 mutex_lock(&sdp->sd_jindex_mutex);
661
662 for (;;) {
663 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, ji_gh);
664 if (error)
665 break;
666
667 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
668 name.hash = gfs2_disk_hash(name.name, name.len);
669
670 error = gfs2_dir_check(sdp->sd_jindex, &name, NULL);
671 if (error == -ENOENT) {
672 error = 0;
673 break;
674 }
675
676 gfs2_glock_dq_uninit(ji_gh);
677
678 if (error)
679 break;
680
681 error = -ENOMEM;
682 jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
683 if (!jd)
684 break;
685
686 INIT_LIST_HEAD(&jd->extent_list);
687 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1);
688 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
689 if (!jd->jd_inode)
690 error = -ENOENT;
691 else
692 error = PTR_ERR(jd->jd_inode);
693 kfree(jd);
694 break;
695 }
696
697 spin_lock(&sdp->sd_jindex_spin);
698 jd->jd_jid = sdp->sd_journals++;
699 list_add_tail(&jd->jd_list, &sdp->sd_jindex_list);
700 spin_unlock(&sdp->sd_jindex_spin);
701 }
702
703 mutex_unlock(&sdp->sd_jindex_mutex);
704
705 return error;
706}
707
664static int init_journal(struct gfs2_sbd *sdp, int undo) 708static int init_journal(struct gfs2_sbd *sdp, int undo)
665{ 709{
666 struct inode *master = sdp->sd_master_dir->d_inode; 710 struct inode *master = sdp->sd_master_dir->d_inode;
@@ -681,7 +725,6 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
681 return PTR_ERR(sdp->sd_jindex); 725 return PTR_ERR(sdp->sd_jindex);
682 } 726 }
683 ip = GFS2_I(sdp->sd_jindex); 727 ip = GFS2_I(sdp->sd_jindex);
684 set_bit(GLF_STICKY, &ip->i_gl->gl_flags);
685 728
686 /* Load in the journal index special file */ 729 /* Load in the journal index special file */
687 730
@@ -832,7 +875,6 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
832 goto fail_statfs; 875 goto fail_statfs;
833 } 876 }
834 ip = GFS2_I(sdp->sd_rindex); 877 ip = GFS2_I(sdp->sd_rindex);
835 set_bit(GLF_STICKY, &ip->i_gl->gl_flags);
836 sdp->sd_rindex_uptodate = 0; 878 sdp->sd_rindex_uptodate = 0;
837 879
838 /* Read in the quota inode */ 880 /* Read in the quota inode */
@@ -973,9 +1015,6 @@ static int init_threads(struct gfs2_sbd *sdp, int undo)
973 } 1015 }
974 sdp->sd_logd_process = p; 1016 sdp->sd_logd_process = p;
975 1017
976 sdp->sd_statfs_sync_time = jiffies;
977 sdp->sd_quota_sync_time = jiffies;
978
979 p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad"); 1018 p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad");
980 error = IS_ERR(p); 1019 error = IS_ERR(p);
981 if (error) { 1020 if (error) {
@@ -1224,17 +1263,21 @@ static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags,
1224static void gfs2_kill_sb(struct super_block *sb) 1263static void gfs2_kill_sb(struct super_block *sb)
1225{ 1264{
1226 struct gfs2_sbd *sdp = sb->s_fs_info; 1265 struct gfs2_sbd *sdp = sb->s_fs_info;
1227 if (sdp) { 1266
1228 gfs2_meta_syncfs(sdp); 1267 if (sdp == NULL) {
1229 dput(sdp->sd_root_dir); 1268 kill_block_super(sb);
1230 dput(sdp->sd_master_dir); 1269 return;
1231 sdp->sd_root_dir = NULL;
1232 sdp->sd_master_dir = NULL;
1233 } 1270 }
1271
1272 gfs2_meta_syncfs(sdp);
1273 dput(sdp->sd_root_dir);
1274 dput(sdp->sd_master_dir);
1275 sdp->sd_root_dir = NULL;
1276 sdp->sd_master_dir = NULL;
1234 shrink_dcache_sb(sb); 1277 shrink_dcache_sb(sb);
1235 kill_block_super(sb); 1278 kill_block_super(sb);
1236 if (sdp) 1279 gfs2_delete_debugfs_file(sdp);
1237 gfs2_delete_debugfs_file(sdp); 1280 kfree(sdp);
1238} 1281}
1239 1282
1240struct file_system_type gfs2_fs_type = { 1283struct file_system_type gfs2_fs_type = {
diff --git a/fs/gfs2/ops_fstype.h b/fs/gfs2/ops_fstype.h
deleted file mode 100644
index da8490511836..000000000000
--- a/fs/gfs2/ops_fstype.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#ifndef __OPS_FSTYPE_DOT_H__
11#define __OPS_FSTYPE_DOT_H__
12
13#include <linux/fs.h>
14
15extern struct file_system_type gfs2_fs_type;
16extern struct file_system_type gfs2meta_fs_type;
17extern const struct export_operations gfs2_export_ops;
18
19#endif /* __OPS_FSTYPE_DOT_H__ */
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index d232991b9046..49877546beb9 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -19,6 +19,7 @@
19#include <linux/gfs2_ondisk.h> 19#include <linux/gfs2_ondisk.h>
20#include <linux/crc32.h> 20#include <linux/crc32.h>
21#include <linux/lm_interface.h> 21#include <linux/lm_interface.h>
22#include <linux/fiemap.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
24#include "gfs2.h" 25#include "gfs2.h"
@@ -31,12 +32,11 @@
31#include "glock.h" 32#include "glock.h"
32#include "inode.h" 33#include "inode.h"
33#include "meta_io.h" 34#include "meta_io.h"
34#include "ops_dentry.h"
35#include "ops_inode.h"
36#include "quota.h" 35#include "quota.h"
37#include "rgrp.h" 36#include "rgrp.h"
38#include "trans.h" 37#include "trans.h"
39#include "util.h" 38#include "util.h"
39#include "super.h"
40 40
41/** 41/**
42 * gfs2_create - Create a file 42 * gfs2_create - Create a file
@@ -185,7 +185,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
185 if (!dip->i_inode.i_nlink) 185 if (!dip->i_inode.i_nlink)
186 goto out_gunlock; 186 goto out_gunlock;
187 error = -EFBIG; 187 error = -EFBIG;
188 if (dip->i_di.di_entries == (u32)-1) 188 if (dip->i_entries == (u32)-1)
189 goto out_gunlock; 189 goto out_gunlock;
190 error = -EPERM; 190 error = -EPERM;
191 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 191 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -371,7 +371,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
371 371
372 ip = ghs[1].gh_gl->gl_object; 372 ip = ghs[1].gh_gl->gl_object;
373 373
374 ip->i_di.di_size = size; 374 ip->i_disksize = size;
375 375
376 error = gfs2_meta_inode_buffer(ip, &dibh); 376 error = gfs2_meta_inode_buffer(ip, &dibh);
377 377
@@ -425,9 +425,9 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
425 ip = ghs[1].gh_gl->gl_object; 425 ip = ghs[1].gh_gl->gl_object;
426 426
427 ip->i_inode.i_nlink = 2; 427 ip->i_inode.i_nlink = 2;
428 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); 428 ip->i_disksize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
429 ip->i_di.di_flags |= GFS2_DIF_JDATA; 429 ip->i_diskflags |= GFS2_DIF_JDATA;
430 ip->i_di.di_entries = 2; 430 ip->i_entries = 2;
431 431
432 error = gfs2_meta_inode_buffer(ip, &dibh); 432 error = gfs2_meta_inode_buffer(ip, &dibh);
433 433
@@ -517,13 +517,13 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
517 if (error) 517 if (error)
518 goto out_gunlock; 518 goto out_gunlock;
519 519
520 if (ip->i_di.di_entries < 2) { 520 if (ip->i_entries < 2) {
521 if (gfs2_consist_inode(ip)) 521 if (gfs2_consist_inode(ip))
522 gfs2_dinode_print(ip); 522 gfs2_dinode_print(ip);
523 error = -EIO; 523 error = -EIO;
524 goto out_gunlock; 524 goto out_gunlock;
525 } 525 }
526 if (ip->i_di.di_entries > 2) { 526 if (ip->i_entries > 2) {
527 error = -ENOTEMPTY; 527 error = -ENOTEMPTY;
528 goto out_gunlock; 528 goto out_gunlock;
529 } 529 }
@@ -726,13 +726,13 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
726 goto out_gunlock; 726 goto out_gunlock;
727 727
728 if (S_ISDIR(nip->i_inode.i_mode)) { 728 if (S_ISDIR(nip->i_inode.i_mode)) {
729 if (nip->i_di.di_entries < 2) { 729 if (nip->i_entries < 2) {
730 if (gfs2_consist_inode(nip)) 730 if (gfs2_consist_inode(nip))
731 gfs2_dinode_print(nip); 731 gfs2_dinode_print(nip);
732 error = -EIO; 732 error = -EIO;
733 goto out_gunlock; 733 goto out_gunlock;
734 } 734 }
735 if (nip->i_di.di_entries > 2) { 735 if (nip->i_entries > 2) {
736 error = -ENOTEMPTY; 736 error = -ENOTEMPTY;
737 goto out_gunlock; 737 goto out_gunlock;
738 } 738 }
@@ -758,7 +758,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
758 error = -EINVAL; 758 error = -EINVAL;
759 goto out_gunlock; 759 goto out_gunlock;
760 } 760 }
761 if (ndip->i_di.di_entries == (u32)-1) { 761 if (ndip->i_entries == (u32)-1) {
762 error = -EFBIG; 762 error = -EFBIG;
763 goto out_gunlock; 763 goto out_gunlock;
764 } 764 }
@@ -990,7 +990,7 @@ static int setattr_size(struct inode *inode, struct iattr *attr)
990 struct gfs2_sbd *sdp = GFS2_SB(inode); 990 struct gfs2_sbd *sdp = GFS2_SB(inode);
991 int error; 991 int error;
992 992
993 if (attr->ia_size != ip->i_di.di_size) { 993 if (attr->ia_size != ip->i_disksize) {
994 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); 994 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
995 if (error) 995 if (error)
996 return error; 996 return error;
@@ -1001,8 +1001,8 @@ static int setattr_size(struct inode *inode, struct iattr *attr)
1001 } 1001 }
1002 1002
1003 error = gfs2_truncatei(ip, attr->ia_size); 1003 error = gfs2_truncatei(ip, attr->ia_size);
1004 if (error && (inode->i_size != ip->i_di.di_size)) 1004 if (error && (inode->i_size != ip->i_disksize))
1005 i_size_write(inode, ip->i_di.di_size); 1005 i_size_write(inode, ip->i_disksize);
1006 1006
1007 return error; 1007 return error;
1008} 1008}
@@ -1212,6 +1212,48 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
1212 return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er); 1212 return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er);
1213} 1213}
1214 1214
1215static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
1216 u64 start, u64 len)
1217{
1218 struct gfs2_inode *ip = GFS2_I(inode);
1219 struct gfs2_holder gh;
1220 int ret;
1221
1222 ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
1223 if (ret)
1224 return ret;
1225
1226 mutex_lock(&inode->i_mutex);
1227
1228 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
1229 if (ret)
1230 goto out;
1231
1232 if (gfs2_is_stuffed(ip)) {
1233 u64 phys = ip->i_no_addr << inode->i_blkbits;
1234 u64 size = i_size_read(inode);
1235 u32 flags = FIEMAP_EXTENT_LAST|FIEMAP_EXTENT_NOT_ALIGNED|
1236 FIEMAP_EXTENT_DATA_INLINE;
1237 phys += sizeof(struct gfs2_dinode);
1238 phys += start;
1239 if (start + len > size)
1240 len = size - start;
1241 if (start < size)
1242 ret = fiemap_fill_next_extent(fieinfo, start, phys,
1243 len, flags);
1244 if (ret == 1)
1245 ret = 0;
1246 } else {
1247 ret = __generic_block_fiemap(inode, fieinfo, start, len,
1248 gfs2_block_map);
1249 }
1250
1251 gfs2_glock_dq_uninit(&gh);
1252out:
1253 mutex_unlock(&inode->i_mutex);
1254 return ret;
1255}
1256
1215const struct inode_operations gfs2_file_iops = { 1257const struct inode_operations gfs2_file_iops = {
1216 .permission = gfs2_permission, 1258 .permission = gfs2_permission,
1217 .setattr = gfs2_setattr, 1259 .setattr = gfs2_setattr,
@@ -1220,6 +1262,7 @@ const struct inode_operations gfs2_file_iops = {
1220 .getxattr = gfs2_getxattr, 1262 .getxattr = gfs2_getxattr,
1221 .listxattr = gfs2_listxattr, 1263 .listxattr = gfs2_listxattr,
1222 .removexattr = gfs2_removexattr, 1264 .removexattr = gfs2_removexattr,
1265 .fiemap = gfs2_fiemap,
1223}; 1266};
1224 1267
1225const struct inode_operations gfs2_dir_iops = { 1268const struct inode_operations gfs2_dir_iops = {
@@ -1239,6 +1282,7 @@ const struct inode_operations gfs2_dir_iops = {
1239 .getxattr = gfs2_getxattr, 1282 .getxattr = gfs2_getxattr,
1240 .listxattr = gfs2_listxattr, 1283 .listxattr = gfs2_listxattr,
1241 .removexattr = gfs2_removexattr, 1284 .removexattr = gfs2_removexattr,
1285 .fiemap = gfs2_fiemap,
1242}; 1286};
1243 1287
1244const struct inode_operations gfs2_symlink_iops = { 1288const struct inode_operations gfs2_symlink_iops = {
@@ -1251,5 +1295,6 @@ const struct inode_operations gfs2_symlink_iops = {
1251 .getxattr = gfs2_getxattr, 1295 .getxattr = gfs2_getxattr,
1252 .listxattr = gfs2_listxattr, 1296 .listxattr = gfs2_listxattr,
1253 .removexattr = gfs2_removexattr, 1297 .removexattr = gfs2_removexattr,
1298 .fiemap = gfs2_fiemap,
1254}; 1299};
1255 1300
diff --git a/fs/gfs2/ops_inode.h b/fs/gfs2/ops_inode.h
deleted file mode 100644
index 14b4b797622a..000000000000
--- a/fs/gfs2/ops_inode.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#ifndef __OPS_INODE_DOT_H__
11#define __OPS_INODE_DOT_H__
12
13#include <linux/fs.h>
14
15extern const struct inode_operations gfs2_file_iops;
16extern const struct inode_operations gfs2_dir_iops;
17extern const struct inode_operations gfs2_symlink_iops;
18extern const struct file_operations gfs2_file_fops;
19extern const struct file_operations gfs2_dir_fops;
20extern const struct file_operations gfs2_file_fops_nolock;
21extern const struct file_operations gfs2_dir_fops_nolock;
22
23extern void gfs2_set_inode_flags(struct inode *inode);
24
25#endif /* __OPS_INODE_DOT_H__ */
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index d5355d9b5926..777783deddcb 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -28,7 +28,6 @@
28#include "inode.h" 28#include "inode.h"
29#include "log.h" 29#include "log.h"
30#include "mount.h" 30#include "mount.h"
31#include "ops_super.h"
32#include "quota.h" 31#include "quota.h"
33#include "recovery.h" 32#include "recovery.h"
34#include "rgrp.h" 33#include "rgrp.h"
@@ -143,8 +142,6 @@ static void gfs2_put_super(struct super_block *sb)
143 kthread_stop(sdp->sd_quotad_process); 142 kthread_stop(sdp->sd_quotad_process);
144 kthread_stop(sdp->sd_logd_process); 143 kthread_stop(sdp->sd_logd_process);
145 kthread_stop(sdp->sd_recoverd_process); 144 kthread_stop(sdp->sd_recoverd_process);
146 while (sdp->sd_glockd_num--)
147 kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]);
148 145
149 if (!(sb->s_flags & MS_RDONLY)) { 146 if (!(sb->s_flags & MS_RDONLY)) {
150 error = gfs2_make_fs_ro(sdp); 147 error = gfs2_make_fs_ro(sdp);
@@ -185,7 +182,6 @@ static void gfs2_put_super(struct super_block *sb)
185 182
186 /* At this point, we're through participating in the lockspace */ 183 /* At this point, we're through participating in the lockspace */
187 gfs2_sys_fs_del(sdp); 184 gfs2_sys_fs_del(sdp);
188 kfree(sdp);
189} 185}
190 186
191/** 187/**
@@ -260,6 +256,137 @@ static void gfs2_unlockfs(struct super_block *sb)
260} 256}
261 257
262/** 258/**
259 * statfs_fill - fill in the sg for a given RG
260 * @rgd: the RG
261 * @sc: the sc structure
262 *
263 * Returns: 0 on success, -ESTALE if the LVB is invalid
264 */
265
266static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
267 struct gfs2_statfs_change_host *sc)
268{
269 gfs2_rgrp_verify(rgd);
270 sc->sc_total += rgd->rd_data;
271 sc->sc_free += rgd->rd_free;
272 sc->sc_dinodes += rgd->rd_dinodes;
273 return 0;
274}
275
276/**
277 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
278 * @sdp: the filesystem
279 * @sc: the sc info that will be returned
280 *
281 * Any error (other than a signal) will cause this routine to fall back
282 * to the synchronous version.
283 *
284 * FIXME: This really shouldn't busy wait like this.
285 *
286 * Returns: errno
287 */
288
289static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
290{
291 struct gfs2_holder ri_gh;
292 struct gfs2_rgrpd *rgd_next;
293 struct gfs2_holder *gha, *gh;
294 unsigned int slots = 64;
295 unsigned int x;
296 int done;
297 int error = 0, err;
298
299 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
300 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
301 if (!gha)
302 return -ENOMEM;
303
304 error = gfs2_rindex_hold(sdp, &ri_gh);
305 if (error)
306 goto out;
307
308 rgd_next = gfs2_rgrpd_get_first(sdp);
309
310 for (;;) {
311 done = 1;
312
313 for (x = 0; x < slots; x++) {
314 gh = gha + x;
315
316 if (gh->gh_gl && gfs2_glock_poll(gh)) {
317 err = gfs2_glock_wait(gh);
318 if (err) {
319 gfs2_holder_uninit(gh);
320 error = err;
321 } else {
322 if (!error)
323 error = statfs_slow_fill(
324 gh->gh_gl->gl_object, sc);
325 gfs2_glock_dq_uninit(gh);
326 }
327 }
328
329 if (gh->gh_gl)
330 done = 0;
331 else if (rgd_next && !error) {
332 error = gfs2_glock_nq_init(rgd_next->rd_gl,
333 LM_ST_SHARED,
334 GL_ASYNC,
335 gh);
336 rgd_next = gfs2_rgrpd_get_next(rgd_next);
337 done = 0;
338 }
339
340 if (signal_pending(current))
341 error = -ERESTARTSYS;
342 }
343
344 if (done)
345 break;
346
347 yield();
348 }
349
350 gfs2_glock_dq_uninit(&ri_gh);
351
352out:
353 kfree(gha);
354 return error;
355}
356
357/**
358 * gfs2_statfs_i - Do a statfs
359 * @sdp: the filesystem
360 * @sg: the sg structure
361 *
362 * Returns: errno
363 */
364
365static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
366{
367 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
368 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
369
370 spin_lock(&sdp->sd_statfs_spin);
371
372 *sc = *m_sc;
373 sc->sc_total += l_sc->sc_total;
374 sc->sc_free += l_sc->sc_free;
375 sc->sc_dinodes += l_sc->sc_dinodes;
376
377 spin_unlock(&sdp->sd_statfs_spin);
378
379 if (sc->sc_free < 0)
380 sc->sc_free = 0;
381 if (sc->sc_free > sc->sc_total)
382 sc->sc_free = sc->sc_total;
383 if (sc->sc_dinodes < 0)
384 sc->sc_dinodes = 0;
385
386 return 0;
387}
388
389/**
263 * gfs2_statfs - Gather and return stats about the filesystem 390 * gfs2_statfs - Gather and return stats about the filesystem
264 * @sb: The superblock 391 * @sb: The superblock
265 * @statfsbuf: The buffer 392 * @statfsbuf: The buffer
@@ -370,7 +497,6 @@ static void gfs2_clear_inode(struct inode *inode)
370 */ 497 */
371 if (test_bit(GIF_USER, &ip->i_flags)) { 498 if (test_bit(GIF_USER, &ip->i_flags)) {
372 ip->i_gl->gl_object = NULL; 499 ip->i_gl->gl_object = NULL;
373 gfs2_glock_schedule_for_reclaim(ip->i_gl);
374 gfs2_glock_put(ip->i_gl); 500 gfs2_glock_put(ip->i_gl);
375 ip->i_gl = NULL; 501 ip->i_gl = NULL;
376 if (ip->i_iopen_gh.gh_gl) { 502 if (ip->i_iopen_gh.gh_gl) {
@@ -423,8 +549,6 @@ static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
423 seq_printf(s, ",debug"); 549 seq_printf(s, ",debug");
424 if (args->ar_upgrade) 550 if (args->ar_upgrade)
425 seq_printf(s, ",upgrade"); 551 seq_printf(s, ",upgrade");
426 if (args->ar_num_glockd != GFS2_GLOCKD_DEFAULT)
427 seq_printf(s, ",num_glockd=%u", args->ar_num_glockd);
428 if (args->ar_posix_acl) 552 if (args->ar_posix_acl)
429 seq_printf(s, ",acl"); 553 seq_printf(s, ",acl");
430 if (args->ar_quota != GFS2_QUOTA_DEFAULT) { 554 if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
@@ -494,16 +618,16 @@ static void gfs2_delete_inode(struct inode *inode)
494 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); 618 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh);
495 error = gfs2_glock_nq(&ip->i_iopen_gh); 619 error = gfs2_glock_nq(&ip->i_iopen_gh);
496 if (error) 620 if (error)
497 goto out_uninit; 621 goto out_truncate;
498 622
499 if (S_ISDIR(inode->i_mode) && 623 if (S_ISDIR(inode->i_mode) &&
500 (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { 624 (ip->i_diskflags & GFS2_DIF_EXHASH)) {
501 error = gfs2_dir_exhash_dealloc(ip); 625 error = gfs2_dir_exhash_dealloc(ip);
502 if (error) 626 if (error)
503 goto out_unlock; 627 goto out_unlock;
504 } 628 }
505 629
506 if (ip->i_di.di_eattr) { 630 if (ip->i_eattr) {
507 error = gfs2_ea_dealloc(ip); 631 error = gfs2_ea_dealloc(ip);
508 if (error) 632 if (error)
509 goto out_unlock; 633 goto out_unlock;
@@ -519,6 +643,7 @@ static void gfs2_delete_inode(struct inode *inode)
519 if (error) 643 if (error)
520 goto out_unlock; 644 goto out_unlock;
521 645
646out_truncate:
522 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); 647 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
523 if (error) 648 if (error)
524 goto out_unlock; 649 goto out_unlock;
@@ -527,8 +652,8 @@ static void gfs2_delete_inode(struct inode *inode)
527 gfs2_trans_end(sdp); 652 gfs2_trans_end(sdp);
528 653
529out_unlock: 654out_unlock:
530 gfs2_glock_dq(&ip->i_iopen_gh); 655 if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags))
531out_uninit: 656 gfs2_glock_dq(&ip->i_iopen_gh);
532 gfs2_holder_uninit(&ip->i_iopen_gh); 657 gfs2_holder_uninit(&ip->i_iopen_gh);
533 gfs2_glock_dq_uninit(&gh); 658 gfs2_glock_dq_uninit(&gh);
534 if (error && error != GLR_TRYFAILED) 659 if (error && error != GLR_TRYFAILED)
diff --git a/fs/gfs2/ops_super.h b/fs/gfs2/ops_super.h
deleted file mode 100644
index 442a274c6272..000000000000
--- a/fs/gfs2/ops_super.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#ifndef __OPS_SUPER_DOT_H__
11#define __OPS_SUPER_DOT_H__
12
13#include <linux/fs.h>
14
15extern const struct super_operations gfs2_super_ops;
16
17#endif /* __OPS_SUPER_DOT_H__ */
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 3e073f5144fa..b08d09696b3e 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -46,6 +46,8 @@
46#include <linux/bio.h> 46#include <linux/bio.h>
47#include <linux/gfs2_ondisk.h> 47#include <linux/gfs2_ondisk.h>
48#include <linux/lm_interface.h> 48#include <linux/lm_interface.h>
49#include <linux/kthread.h>
50#include <linux/freezer.h>
49 51
50#include "gfs2.h" 52#include "gfs2.h"
51#include "incore.h" 53#include "incore.h"
@@ -94,7 +96,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id,
94 struct gfs2_quota_data *qd; 96 struct gfs2_quota_data *qd;
95 int error; 97 int error;
96 98
97 qd = kzalloc(sizeof(struct gfs2_quota_data), GFP_NOFS); 99 qd = kmem_cache_zalloc(gfs2_quotad_cachep, GFP_NOFS);
98 if (!qd) 100 if (!qd)
99 return -ENOMEM; 101 return -ENOMEM;
100 102
@@ -119,7 +121,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id,
119 return 0; 121 return 0;
120 122
121fail: 123fail:
122 kfree(qd); 124 kmem_cache_free(gfs2_quotad_cachep, qd);
123 return error; 125 return error;
124} 126}
125 127
@@ -158,7 +160,7 @@ static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, int create,
158 if (qd || !create) { 160 if (qd || !create) {
159 if (new_qd) { 161 if (new_qd) {
160 gfs2_lvb_unhold(new_qd->qd_gl); 162 gfs2_lvb_unhold(new_qd->qd_gl);
161 kfree(new_qd); 163 kmem_cache_free(gfs2_quotad_cachep, new_qd);
162 } 164 }
163 *qdp = qd; 165 *qdp = qd;
164 return 0; 166 return 0;
@@ -1013,7 +1015,7 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
1013 1015
1014 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), change)) 1016 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), change))
1015 return; 1017 return;
1016 if (ip->i_di.di_flags & GFS2_DIF_SYSTEM) 1018 if (ip->i_diskflags & GFS2_DIF_SYSTEM)
1017 return; 1019 return;
1018 1020
1019 for (x = 0; x < al->al_qd_num; x++) { 1021 for (x = 0; x < al->al_qd_num; x++) {
@@ -1100,15 +1102,15 @@ static void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *
1100int gfs2_quota_init(struct gfs2_sbd *sdp) 1102int gfs2_quota_init(struct gfs2_sbd *sdp)
1101{ 1103{
1102 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode); 1104 struct gfs2_inode *ip = GFS2_I(sdp->sd_qc_inode);
1103 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; 1105 unsigned int blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift;
1104 unsigned int x, slot = 0; 1106 unsigned int x, slot = 0;
1105 unsigned int found = 0; 1107 unsigned int found = 0;
1106 u64 dblock; 1108 u64 dblock;
1107 u32 extlen = 0; 1109 u32 extlen = 0;
1108 int error; 1110 int error;
1109 1111
1110 if (!ip->i_di.di_size || ip->i_di.di_size > (64 << 20) || 1112 if (!ip->i_disksize || ip->i_disksize > (64 << 20) ||
1111 ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1)) { 1113 ip->i_disksize & (sdp->sd_sb.sb_bsize - 1)) {
1112 gfs2_consist_inode(ip); 1114 gfs2_consist_inode(ip);
1113 return -EIO; 1115 return -EIO;
1114 } 1116 }
@@ -1195,7 +1197,7 @@ fail:
1195 return error; 1197 return error;
1196} 1198}
1197 1199
1198void gfs2_quota_scan(struct gfs2_sbd *sdp) 1200static void gfs2_quota_scan(struct gfs2_sbd *sdp)
1199{ 1201{
1200 struct gfs2_quota_data *qd, *safe; 1202 struct gfs2_quota_data *qd, *safe;
1201 LIST_HEAD(dead); 1203 LIST_HEAD(dead);
@@ -1222,7 +1224,7 @@ void gfs2_quota_scan(struct gfs2_sbd *sdp)
1222 gfs2_assert_warn(sdp, !qd->qd_bh_count); 1224 gfs2_assert_warn(sdp, !qd->qd_bh_count);
1223 1225
1224 gfs2_lvb_unhold(qd->qd_gl); 1226 gfs2_lvb_unhold(qd->qd_gl);
1225 kfree(qd); 1227 kmem_cache_free(gfs2_quotad_cachep, qd);
1226 } 1228 }
1227} 1229}
1228 1230
@@ -1257,7 +1259,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
1257 gfs2_assert_warn(sdp, !qd->qd_bh_count); 1259 gfs2_assert_warn(sdp, !qd->qd_bh_count);
1258 1260
1259 gfs2_lvb_unhold(qd->qd_gl); 1261 gfs2_lvb_unhold(qd->qd_gl);
1260 kfree(qd); 1262 kmem_cache_free(gfs2_quotad_cachep, qd);
1261 1263
1262 spin_lock(&sdp->sd_quota_spin); 1264 spin_lock(&sdp->sd_quota_spin);
1263 } 1265 }
@@ -1272,3 +1274,94 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
1272 } 1274 }
1273} 1275}
1274 1276
1277static void quotad_error(struct gfs2_sbd *sdp, const char *msg, int error)
1278{
1279 if (error == 0 || error == -EROFS)
1280 return;
1281 if (!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
1282 fs_err(sdp, "gfs2_quotad: %s error %d\n", msg, error);
1283}
1284
1285static void quotad_check_timeo(struct gfs2_sbd *sdp, const char *msg,
1286 int (*fxn)(struct gfs2_sbd *sdp),
1287 unsigned long t, unsigned long *timeo,
1288 unsigned int *new_timeo)
1289{
1290 if (t >= *timeo) {
1291 int error = fxn(sdp);
1292 quotad_error(sdp, msg, error);
1293 *timeo = gfs2_tune_get_i(&sdp->sd_tune, new_timeo) * HZ;
1294 } else {
1295 *timeo -= t;
1296 }
1297}
1298
1299static void quotad_check_trunc_list(struct gfs2_sbd *sdp)
1300{
1301 struct gfs2_inode *ip;
1302
1303 while(1) {
1304 ip = NULL;
1305 spin_lock(&sdp->sd_trunc_lock);
1306 if (!list_empty(&sdp->sd_trunc_list)) {
1307 ip = list_entry(sdp->sd_trunc_list.next,
1308 struct gfs2_inode, i_trunc_list);
1309 list_del_init(&ip->i_trunc_list);
1310 }
1311 spin_unlock(&sdp->sd_trunc_lock);
1312 if (ip == NULL)
1313 return;
1314 gfs2_glock_finish_truncate(ip);
1315 }
1316}
1317
1318/**
1319 * gfs2_quotad - Write cached quota changes into the quota file
1320 * @sdp: Pointer to GFS2 superblock
1321 *
1322 */
1323
1324int gfs2_quotad(void *data)
1325{
1326 struct gfs2_sbd *sdp = data;
1327 struct gfs2_tune *tune = &sdp->sd_tune;
1328 unsigned long statfs_timeo = 0;
1329 unsigned long quotad_timeo = 0;
1330 unsigned long t = 0;
1331 DEFINE_WAIT(wait);
1332 int empty;
1333
1334 while (!kthread_should_stop()) {
1335
1336 /* Update the master statfs file */
1337 quotad_check_timeo(sdp, "statfs", gfs2_statfs_sync, t,
1338 &statfs_timeo, &tune->gt_statfs_quantum);
1339
1340 /* Update quota file */
1341 quotad_check_timeo(sdp, "sync", gfs2_quota_sync, t,
1342 &quotad_timeo, &tune->gt_quota_quantum);
1343
1344 /* FIXME: This should be turned into a shrinker */
1345 gfs2_quota_scan(sdp);
1346
1347 /* Check for & recover partially truncated inodes */
1348 quotad_check_trunc_list(sdp);
1349
1350 if (freezing(current))
1351 refrigerator();
1352 t = min(quotad_timeo, statfs_timeo);
1353
1354 prepare_to_wait(&sdp->sd_quota_wait, &wait, TASK_UNINTERRUPTIBLE);
1355 spin_lock(&sdp->sd_trunc_lock);
1356 empty = list_empty(&sdp->sd_trunc_list);
1357 spin_unlock(&sdp->sd_trunc_lock);
1358 if (empty)
1359 t -= schedule_timeout(t);
1360 else
1361 t = 0;
1362 finish_wait(&sdp->sd_quota_wait, &wait);
1363 }
1364
1365 return 0;
1366}
1367
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
index 3b7f4b0e5dfe..cec9032be97d 100644
--- a/fs/gfs2/quota.h
+++ b/fs/gfs2/quota.h
@@ -15,22 +15,22 @@ struct gfs2_sbd;
15 15
16#define NO_QUOTA_CHANGE ((u32)-1) 16#define NO_QUOTA_CHANGE ((u32)-1)
17 17
18int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid); 18extern int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid);
19void gfs2_quota_unhold(struct gfs2_inode *ip); 19extern void gfs2_quota_unhold(struct gfs2_inode *ip);
20 20
21int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid); 21extern int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid);
22void gfs2_quota_unlock(struct gfs2_inode *ip); 22extern void gfs2_quota_unlock(struct gfs2_inode *ip);
23 23
24int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid); 24extern int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid);
25void gfs2_quota_change(struct gfs2_inode *ip, s64 change, 25extern void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
26 u32 uid, u32 gid); 26 u32 uid, u32 gid);
27 27
28int gfs2_quota_sync(struct gfs2_sbd *sdp); 28extern int gfs2_quota_sync(struct gfs2_sbd *sdp);
29int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id); 29extern int gfs2_quota_refresh(struct gfs2_sbd *sdp, int user, u32 id);
30 30
31int gfs2_quota_init(struct gfs2_sbd *sdp); 31extern int gfs2_quota_init(struct gfs2_sbd *sdp);
32void gfs2_quota_scan(struct gfs2_sbd *sdp); 32extern void gfs2_quota_cleanup(struct gfs2_sbd *sdp);
33void gfs2_quota_cleanup(struct gfs2_sbd *sdp); 33extern int gfs2_quotad(void *data);
34 34
35static inline int gfs2_quota_lock_check(struct gfs2_inode *ip) 35static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
36{ 36{
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index d5e91f4f6a0b..efd09c3d2b26 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -14,6 +14,8 @@
14#include <linux/gfs2_ondisk.h> 14#include <linux/gfs2_ondisk.h>
15#include <linux/crc32.h> 15#include <linux/crc32.h>
16#include <linux/lm_interface.h> 16#include <linux/lm_interface.h>
17#include <linux/kthread.h>
18#include <linux/freezer.h>
17 19
18#include "gfs2.h" 20#include "gfs2.h"
19#include "incore.h" 21#include "incore.h"
@@ -583,13 +585,35 @@ fail:
583 return error; 585 return error;
584} 586}
585 587
588static struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
589{
590 struct gfs2_jdesc *jd;
591 int found = 0;
592
593 spin_lock(&sdp->sd_jindex_spin);
594
595 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
596 if (jd->jd_dirty) {
597 jd->jd_dirty = 0;
598 found = 1;
599 break;
600 }
601 }
602 spin_unlock(&sdp->sd_jindex_spin);
603
604 if (!found)
605 jd = NULL;
606
607 return jd;
608}
609
586/** 610/**
587 * gfs2_check_journals - Recover any dirty journals 611 * gfs2_check_journals - Recover any dirty journals
588 * @sdp: the filesystem 612 * @sdp: the filesystem
589 * 613 *
590 */ 614 */
591 615
592void gfs2_check_journals(struct gfs2_sbd *sdp) 616static void gfs2_check_journals(struct gfs2_sbd *sdp)
593{ 617{
594 struct gfs2_jdesc *jd; 618 struct gfs2_jdesc *jd;
595 619
@@ -603,3 +627,25 @@ void gfs2_check_journals(struct gfs2_sbd *sdp)
603 } 627 }
604} 628}
605 629
630/**
631 * gfs2_recoverd - Recover dead machine's journals
632 * @sdp: Pointer to GFS2 superblock
633 *
634 */
635
636int gfs2_recoverd(void *data)
637{
638 struct gfs2_sbd *sdp = data;
639 unsigned long t;
640
641 while (!kthread_should_stop()) {
642 gfs2_check_journals(sdp);
643 t = gfs2_tune_get(sdp, gt_recoverd_secs) * HZ;
644 if (freezing(current))
645 refrigerator();
646 schedule_timeout_interruptible(t);
647 }
648
649 return 0;
650}
651
diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h
index f7235e61c723..a8218ea15b57 100644
--- a/fs/gfs2/recovery.h
+++ b/fs/gfs2/recovery.h
@@ -18,17 +18,17 @@ static inline void gfs2_replay_incr_blk(struct gfs2_sbd *sdp, unsigned int *blk)
18 *blk = 0; 18 *blk = 0;
19} 19}
20 20
21int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, 21extern int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
22 struct buffer_head **bh); 22 struct buffer_head **bh);
23 23
24int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); 24extern int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
25int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where); 25extern int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
26void gfs2_revoke_clean(struct gfs2_sbd *sdp); 26extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);
27 27
28int gfs2_find_jhead(struct gfs2_jdesc *jd, 28extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
29 struct gfs2_log_header_host *head); 29 struct gfs2_log_header_host *head);
30int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd); 30extern int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd);
31void gfs2_check_journals(struct gfs2_sbd *sdp); 31extern int gfs2_recoverd(void *data);
32 32
33#endif /* __RECOVERY_DOT_H__ */ 33#endif /* __RECOVERY_DOT_H__ */
34 34
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 2d90fb253505..8b01c635d925 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -269,16 +269,14 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)
269 bi->bi_len, x); 269 bi->bi_len, x);
270 } 270 }
271 271
272 if (count[0] != rgd->rd_rg.rg_free) { 272 if (count[0] != rgd->rd_free) {
273 if (gfs2_consist_rgrpd(rgd)) 273 if (gfs2_consist_rgrpd(rgd))
274 fs_err(sdp, "free data mismatch: %u != %u\n", 274 fs_err(sdp, "free data mismatch: %u != %u\n",
275 count[0], rgd->rd_rg.rg_free); 275 count[0], rgd->rd_free);
276 return; 276 return;
277 } 277 }
278 278
279 tmp = rgd->rd_data - 279 tmp = rgd->rd_data - rgd->rd_free - rgd->rd_dinodes;
280 rgd->rd_rg.rg_free -
281 rgd->rd_rg.rg_dinodes;
282 if (count[1] + count[2] != tmp) { 280 if (count[1] + count[2] != tmp) {
283 if (gfs2_consist_rgrpd(rgd)) 281 if (gfs2_consist_rgrpd(rgd))
284 fs_err(sdp, "used data mismatch: %u != %u\n", 282 fs_err(sdp, "used data mismatch: %u != %u\n",
@@ -286,10 +284,10 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)
286 return; 284 return;
287 } 285 }
288 286
289 if (count[3] != rgd->rd_rg.rg_dinodes) { 287 if (count[3] != rgd->rd_dinodes) {
290 if (gfs2_consist_rgrpd(rgd)) 288 if (gfs2_consist_rgrpd(rgd))
291 fs_err(sdp, "used metadata mismatch: %u != %u\n", 289 fs_err(sdp, "used metadata mismatch: %u != %u\n",
292 count[3], rgd->rd_rg.rg_dinodes); 290 count[3], rgd->rd_dinodes);
293 return; 291 return;
294 } 292 }
295 293
@@ -501,7 +499,7 @@ u64 gfs2_ri_total(struct gfs2_sbd *sdp)
501 for (rgrps = 0;; rgrps++) { 499 for (rgrps = 0;; rgrps++) {
502 loff_t pos = rgrps * sizeof(struct gfs2_rindex); 500 loff_t pos = rgrps * sizeof(struct gfs2_rindex);
503 501
504 if (pos + sizeof(struct gfs2_rindex) >= ip->i_di.di_size) 502 if (pos + sizeof(struct gfs2_rindex) >= ip->i_disksize)
505 break; 503 break;
506 error = gfs2_internal_read(ip, &ra_state, buf, &pos, 504 error = gfs2_internal_read(ip, &ra_state, buf, &pos,
507 sizeof(struct gfs2_rindex)); 505 sizeof(struct gfs2_rindex));
@@ -590,7 +588,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
590 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 588 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
591 struct inode *inode = &ip->i_inode; 589 struct inode *inode = &ip->i_inode;
592 struct file_ra_state ra_state; 590 struct file_ra_state ra_state;
593 u64 rgrp_count = ip->i_di.di_size; 591 u64 rgrp_count = ip->i_disksize;
594 int error; 592 int error;
595 593
596 if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) { 594 if (do_div(rgrp_count, sizeof(struct gfs2_rindex))) {
@@ -634,7 +632,7 @@ static int gfs2_ri_update_special(struct gfs2_inode *ip)
634 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { 632 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) {
635 /* Ignore partials */ 633 /* Ignore partials */
636 if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) > 634 if ((sdp->sd_rgrps + 1) * sizeof(struct gfs2_rindex) >
637 ip->i_di.di_size) 635 ip->i_disksize)
638 break; 636 break;
639 error = read_rindex_entry(ip, &ra_state); 637 error = read_rindex_entry(ip, &ra_state);
640 if (error) { 638 if (error) {
@@ -692,7 +690,6 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh)
692static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf) 690static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf)
693{ 691{
694 const struct gfs2_rgrp *str = buf; 692 const struct gfs2_rgrp *str = buf;
695 struct gfs2_rgrp_host *rg = &rgd->rd_rg;
696 u32 rg_flags; 693 u32 rg_flags;
697 694
698 rg_flags = be32_to_cpu(str->rg_flags); 695 rg_flags = be32_to_cpu(str->rg_flags);
@@ -700,24 +697,23 @@ static void gfs2_rgrp_in(struct gfs2_rgrpd *rgd, const void *buf)
700 rgd->rd_flags |= GFS2_RDF_NOALLOC; 697 rgd->rd_flags |= GFS2_RDF_NOALLOC;
701 else 698 else
702 rgd->rd_flags &= ~GFS2_RDF_NOALLOC; 699 rgd->rd_flags &= ~GFS2_RDF_NOALLOC;
703 rg->rg_free = be32_to_cpu(str->rg_free); 700 rgd->rd_free = be32_to_cpu(str->rg_free);
704 rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); 701 rgd->rd_dinodes = be32_to_cpu(str->rg_dinodes);
705 rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); 702 rgd->rd_igeneration = be64_to_cpu(str->rg_igeneration);
706} 703}
707 704
708static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf) 705static void gfs2_rgrp_out(struct gfs2_rgrpd *rgd, void *buf)
709{ 706{
710 struct gfs2_rgrp *str = buf; 707 struct gfs2_rgrp *str = buf;
711 struct gfs2_rgrp_host *rg = &rgd->rd_rg;
712 u32 rg_flags = 0; 708 u32 rg_flags = 0;
713 709
714 if (rgd->rd_flags & GFS2_RDF_NOALLOC) 710 if (rgd->rd_flags & GFS2_RDF_NOALLOC)
715 rg_flags |= GFS2_RGF_NOALLOC; 711 rg_flags |= GFS2_RGF_NOALLOC;
716 str->rg_flags = cpu_to_be32(rg_flags); 712 str->rg_flags = cpu_to_be32(rg_flags);
717 str->rg_free = cpu_to_be32(rg->rg_free); 713 str->rg_free = cpu_to_be32(rgd->rd_free);
718 str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); 714 str->rg_dinodes = cpu_to_be32(rgd->rd_dinodes);
719 str->__pad = cpu_to_be32(0); 715 str->__pad = cpu_to_be32(0);
720 str->rg_igeneration = cpu_to_be64(rg->rg_igeneration); 716 str->rg_igeneration = cpu_to_be64(rgd->rd_igeneration);
721 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); 717 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
722} 718}
723 719
@@ -776,7 +772,7 @@ int gfs2_rgrp_bh_get(struct gfs2_rgrpd *rgd)
776 } 772 }
777 773
778 spin_lock(&sdp->sd_rindex_spin); 774 spin_lock(&sdp->sd_rindex_spin);
779 rgd->rd_free_clone = rgd->rd_rg.rg_free; 775 rgd->rd_free_clone = rgd->rd_free;
780 rgd->rd_bh_count++; 776 rgd->rd_bh_count++;
781 spin_unlock(&sdp->sd_rindex_spin); 777 spin_unlock(&sdp->sd_rindex_spin);
782 778
@@ -850,7 +846,7 @@ void gfs2_rgrp_repolish_clones(struct gfs2_rgrpd *rgd)
850 } 846 }
851 847
852 spin_lock(&sdp->sd_rindex_spin); 848 spin_lock(&sdp->sd_rindex_spin);
853 rgd->rd_free_clone = rgd->rd_rg.rg_free; 849 rgd->rd_free_clone = rgd->rd_free;
854 spin_unlock(&sdp->sd_rindex_spin); 850 spin_unlock(&sdp->sd_rindex_spin);
855} 851}
856 852
@@ -1403,8 +1399,8 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n)
1403 block = rgd->rd_data0 + blk; 1399 block = rgd->rd_data0 + blk;
1404 ip->i_goal = block; 1400 ip->i_goal = block;
1405 1401
1406 gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free >= *n); 1402 gfs2_assert_withdraw(sdp, rgd->rd_free >= *n);
1407 rgd->rd_rg.rg_free -= *n; 1403 rgd->rd_free -= *n;
1408 1404
1409 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1405 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1410 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1406 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
@@ -1445,10 +1441,10 @@ u64 gfs2_alloc_di(struct gfs2_inode *dip, u64 *generation)
1445 1441
1446 block = rgd->rd_data0 + blk; 1442 block = rgd->rd_data0 + blk;
1447 1443
1448 gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free); 1444 gfs2_assert_withdraw(sdp, rgd->rd_free);
1449 rgd->rd_rg.rg_free--; 1445 rgd->rd_free--;
1450 rgd->rd_rg.rg_dinodes++; 1446 rgd->rd_dinodes++;
1451 *generation = rgd->rd_rg.rg_igeneration++; 1447 *generation = rgd->rd_igeneration++;
1452 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1448 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1453 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1449 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
1454 1450
@@ -1481,7 +1477,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
1481 if (!rgd) 1477 if (!rgd)
1482 return; 1478 return;
1483 1479
1484 rgd->rd_rg.rg_free += blen; 1480 rgd->rd_free += blen;
1485 1481
1486 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1482 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1487 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1483 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
@@ -1509,7 +1505,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
1509 if (!rgd) 1505 if (!rgd)
1510 return; 1506 return;
1511 1507
1512 rgd->rd_rg.rg_free += blen; 1508 rgd->rd_free += blen;
1513 1509
1514 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1510 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1515 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1511 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
@@ -1546,10 +1542,10 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
1546 return; 1542 return;
1547 gfs2_assert_withdraw(sdp, rgd == tmp_rgd); 1543 gfs2_assert_withdraw(sdp, rgd == tmp_rgd);
1548 1544
1549 if (!rgd->rd_rg.rg_dinodes) 1545 if (!rgd->rd_dinodes)
1550 gfs2_consist_rgrpd(rgd); 1546 gfs2_consist_rgrpd(rgd);
1551 rgd->rd_rg.rg_dinodes--; 1547 rgd->rd_dinodes--;
1552 rgd->rd_rg.rg_free++; 1548 rgd->rd_free++;
1553 1549
1554 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); 1550 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1555 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); 1551 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index c3ba3d9d0aac..141b781f2fcc 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -34,76 +34,6 @@
34#include "util.h" 34#include "util.h"
35 35
36/** 36/**
37 * gfs2_jindex_hold - Grab a lock on the jindex
38 * @sdp: The GFS2 superblock
39 * @ji_gh: the holder for the jindex glock
40 *
41 * This is very similar to the gfs2_rindex_hold() function, except that
42 * in general we hold the jindex lock for longer periods of time and
43 * we grab it far less frequently (in general) then the rgrp lock.
44 *
45 * Returns: errno
46 */
47
48int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
49{
50 struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex);
51 struct qstr name;
52 char buf[20];
53 struct gfs2_jdesc *jd;
54 int error;
55
56 name.name = buf;
57
58 mutex_lock(&sdp->sd_jindex_mutex);
59
60 for (;;) {
61 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, ji_gh);
62 if (error)
63 break;
64
65 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
66 name.hash = gfs2_disk_hash(name.name, name.len);
67
68 error = gfs2_dir_check(sdp->sd_jindex, &name, NULL);
69 if (error == -ENOENT) {
70 error = 0;
71 break;
72 }
73
74 gfs2_glock_dq_uninit(ji_gh);
75
76 if (error)
77 break;
78
79 error = -ENOMEM;
80 jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
81 if (!jd)
82 break;
83
84 INIT_LIST_HEAD(&jd->extent_list);
85 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1);
86 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
87 if (!jd->jd_inode)
88 error = -ENOENT;
89 else
90 error = PTR_ERR(jd->jd_inode);
91 kfree(jd);
92 break;
93 }
94
95 spin_lock(&sdp->sd_jindex_spin);
96 jd->jd_jid = sdp->sd_journals++;
97 list_add_tail(&jd->jd_list, &sdp->sd_jindex_list);
98 spin_unlock(&sdp->sd_jindex_spin);
99 }
100
101 mutex_unlock(&sdp->sd_jindex_mutex);
102
103 return error;
104}
105
106/**
107 * gfs2_jindex_free - Clear all the journal index information 37 * gfs2_jindex_free - Clear all the journal index information
108 * @sdp: The GFS2 superblock 38 * @sdp: The GFS2 superblock
109 * 39 *
@@ -166,39 +96,6 @@ struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid)
166 return jd; 96 return jd;
167} 97}
168 98
169void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
170{
171 struct gfs2_jdesc *jd;
172
173 spin_lock(&sdp->sd_jindex_spin);
174 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
175 if (jd)
176 jd->jd_dirty = 1;
177 spin_unlock(&sdp->sd_jindex_spin);
178}
179
180struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
181{
182 struct gfs2_jdesc *jd;
183 int found = 0;
184
185 spin_lock(&sdp->sd_jindex_spin);
186
187 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
188 if (jd->jd_dirty) {
189 jd->jd_dirty = 0;
190 found = 1;
191 break;
192 }
193 }
194 spin_unlock(&sdp->sd_jindex_spin);
195
196 if (!found)
197 jd = NULL;
198
199 return jd;
200}
201
202int gfs2_jdesc_check(struct gfs2_jdesc *jd) 99int gfs2_jdesc_check(struct gfs2_jdesc *jd)
203{ 100{
204 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 101 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
@@ -206,14 +103,14 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
206 int ar; 103 int ar;
207 int error; 104 int error;
208 105
209 if (ip->i_di.di_size < (8 << 20) || ip->i_di.di_size > (1 << 30) || 106 if (ip->i_disksize < (8 << 20) || ip->i_disksize > (1 << 30) ||
210 (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) { 107 (ip->i_disksize & (sdp->sd_sb.sb_bsize - 1))) {
211 gfs2_consist_inode(ip); 108 gfs2_consist_inode(ip);
212 return -EIO; 109 return -EIO;
213 } 110 }
214 jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; 111 jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift;
215 112
216 error = gfs2_write_alloc_required(ip, 0, ip->i_di.di_size, &ar); 113 error = gfs2_write_alloc_required(ip, 0, ip->i_disksize, &ar);
217 if (!error && ar) { 114 if (!error && ar) {
218 gfs2_consist_inode(ip); 115 gfs2_consist_inode(ip);
219 error = -EIO; 116 error = -EIO;
@@ -423,137 +320,6 @@ out:
423 return error; 320 return error;
424} 321}
425 322
426/**
427 * gfs2_statfs_i - Do a statfs
428 * @sdp: the filesystem
429 * @sg: the sg structure
430 *
431 * Returns: errno
432 */
433
434int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
435{
436 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
437 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
438
439 spin_lock(&sdp->sd_statfs_spin);
440
441 *sc = *m_sc;
442 sc->sc_total += l_sc->sc_total;
443 sc->sc_free += l_sc->sc_free;
444 sc->sc_dinodes += l_sc->sc_dinodes;
445
446 spin_unlock(&sdp->sd_statfs_spin);
447
448 if (sc->sc_free < 0)
449 sc->sc_free = 0;
450 if (sc->sc_free > sc->sc_total)
451 sc->sc_free = sc->sc_total;
452 if (sc->sc_dinodes < 0)
453 sc->sc_dinodes = 0;
454
455 return 0;
456}
457
458/**
459 * statfs_fill - fill in the sg for a given RG
460 * @rgd: the RG
461 * @sc: the sc structure
462 *
463 * Returns: 0 on success, -ESTALE if the LVB is invalid
464 */
465
466static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
467 struct gfs2_statfs_change_host *sc)
468{
469 gfs2_rgrp_verify(rgd);
470 sc->sc_total += rgd->rd_data;
471 sc->sc_free += rgd->rd_rg.rg_free;
472 sc->sc_dinodes += rgd->rd_rg.rg_dinodes;
473 return 0;
474}
475
476/**
477 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
478 * @sdp: the filesystem
479 * @sc: the sc info that will be returned
480 *
481 * Any error (other than a signal) will cause this routine to fall back
482 * to the synchronous version.
483 *
484 * FIXME: This really shouldn't busy wait like this.
485 *
486 * Returns: errno
487 */
488
489int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
490{
491 struct gfs2_holder ri_gh;
492 struct gfs2_rgrpd *rgd_next;
493 struct gfs2_holder *gha, *gh;
494 unsigned int slots = 64;
495 unsigned int x;
496 int done;
497 int error = 0, err;
498
499 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
500 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
501 if (!gha)
502 return -ENOMEM;
503
504 error = gfs2_rindex_hold(sdp, &ri_gh);
505 if (error)
506 goto out;
507
508 rgd_next = gfs2_rgrpd_get_first(sdp);
509
510 for (;;) {
511 done = 1;
512
513 for (x = 0; x < slots; x++) {
514 gh = gha + x;
515
516 if (gh->gh_gl && gfs2_glock_poll(gh)) {
517 err = gfs2_glock_wait(gh);
518 if (err) {
519 gfs2_holder_uninit(gh);
520 error = err;
521 } else {
522 if (!error)
523 error = statfs_slow_fill(
524 gh->gh_gl->gl_object, sc);
525 gfs2_glock_dq_uninit(gh);
526 }
527 }
528
529 if (gh->gh_gl)
530 done = 0;
531 else if (rgd_next && !error) {
532 error = gfs2_glock_nq_init(rgd_next->rd_gl,
533 LM_ST_SHARED,
534 GL_ASYNC,
535 gh);
536 rgd_next = gfs2_rgrpd_get_next(rgd_next);
537 done = 0;
538 }
539
540 if (signal_pending(current))
541 error = -ERESTARTSYS;
542 }
543
544 if (done)
545 break;
546
547 yield();
548 }
549
550 gfs2_glock_dq_uninit(&ri_gh);
551
552out:
553 kfree(gha);
554 return error;
555}
556
557struct lfcc { 323struct lfcc {
558 struct list_head list; 324 struct list_head list;
559 struct gfs2_holder gh; 325 struct gfs2_holder gh;
@@ -580,10 +346,6 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
580 struct gfs2_log_header_host lh; 346 struct gfs2_log_header_host lh;
581 int error; 347 int error;
582 348
583 error = gfs2_jindex_hold(sdp, &ji_gh);
584 if (error)
585 return error;
586
587 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { 349 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
588 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL); 350 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
589 if (!lfcc) { 351 if (!lfcc) {
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h
index 50a4c9b1215e..f6b8b00ad881 100644
--- a/fs/gfs2/super.h
+++ b/fs/gfs2/super.h
@@ -10,6 +10,8 @@
10#ifndef __SUPER_DOT_H__ 10#ifndef __SUPER_DOT_H__
11#define __SUPER_DOT_H__ 11#define __SUPER_DOT_H__
12 12
13#include <linux/fs.h>
14#include <linux/dcache.h>
13#include "incore.h" 15#include "incore.h"
14 16
15void gfs2_lm_unmount(struct gfs2_sbd *sdp); 17void gfs2_lm_unmount(struct gfs2_sbd *sdp);
@@ -23,12 +25,9 @@ static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp)
23 return x; 25 return x;
24} 26}
25 27
26int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh);
27void gfs2_jindex_free(struct gfs2_sbd *sdp); 28void gfs2_jindex_free(struct gfs2_sbd *sdp);
28 29
29struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid); 30struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid);
30void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid);
31struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp);
32int gfs2_jdesc_check(struct gfs2_jdesc *jd); 31int gfs2_jdesc_check(struct gfs2_jdesc *jd);
33 32
34int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename, 33int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
@@ -40,11 +39,15 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp);
40void gfs2_statfs_change(struct gfs2_sbd *sdp, 39void gfs2_statfs_change(struct gfs2_sbd *sdp,
41 s64 total, s64 free, s64 dinodes); 40 s64 total, s64 free, s64 dinodes);
42int gfs2_statfs_sync(struct gfs2_sbd *sdp); 41int gfs2_statfs_sync(struct gfs2_sbd *sdp);
43int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
44int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
45 42
46int gfs2_freeze_fs(struct gfs2_sbd *sdp); 43int gfs2_freeze_fs(struct gfs2_sbd *sdp);
47void gfs2_unfreeze_fs(struct gfs2_sbd *sdp); 44void gfs2_unfreeze_fs(struct gfs2_sbd *sdp);
48 45
46extern struct file_system_type gfs2_fs_type;
47extern struct file_system_type gfs2meta_fs_type;
48extern const struct export_operations gfs2_export_ops;
49extern const struct super_operations gfs2_super_ops;
50extern struct dentry_operations gfs2_dops;
51
49#endif /* __SUPER_DOT_H__ */ 52#endif /* __SUPER_DOT_H__ */
50 53
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 7e1879f1a02c..26c1fa777a95 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -26,9 +26,6 @@
26#include "quota.h" 26#include "quota.h"
27#include "util.h" 27#include "util.h"
28 28
29char *gfs2_sys_margs;
30spinlock_t gfs2_sys_margs_lock;
31
32static ssize_t id_show(struct gfs2_sbd *sdp, char *buf) 29static ssize_t id_show(struct gfs2_sbd *sdp, char *buf)
33{ 30{
34 return snprintf(buf, PAGE_SIZE, "%u:%u\n", 31 return snprintf(buf, PAGE_SIZE, "%u:%u\n",
@@ -263,7 +260,6 @@ ARGS_ATTR(localcaching, "%d\n");
263ARGS_ATTR(localflocks, "%d\n"); 260ARGS_ATTR(localflocks, "%d\n");
264ARGS_ATTR(debug, "%d\n"); 261ARGS_ATTR(debug, "%d\n");
265ARGS_ATTR(upgrade, "%d\n"); 262ARGS_ATTR(upgrade, "%d\n");
266ARGS_ATTR(num_glockd, "%u\n");
267ARGS_ATTR(posix_acl, "%d\n"); 263ARGS_ATTR(posix_acl, "%d\n");
268ARGS_ATTR(quota, "%u\n"); 264ARGS_ATTR(quota, "%u\n");
269ARGS_ATTR(suiddir, "%d\n"); 265ARGS_ATTR(suiddir, "%d\n");
@@ -279,7 +275,6 @@ static struct attribute *args_attrs[] = {
279 &args_attr_localflocks.attr, 275 &args_attr_localflocks.attr,
280 &args_attr_debug.attr, 276 &args_attr_debug.attr,
281 &args_attr_upgrade.attr, 277 &args_attr_upgrade.attr,
282 &args_attr_num_glockd.attr,
283 &args_attr_posix_acl.attr, 278 &args_attr_posix_acl.attr,
284 &args_attr_quota.attr, 279 &args_attr_quota.attr,
285 &args_attr_suiddir.attr, 280 &args_attr_suiddir.attr,
@@ -288,30 +283,6 @@ static struct attribute *args_attrs[] = {
288}; 283};
289 284
290/* 285/*
291 * display counters from superblock
292 */
293
294struct counters_attr {
295 struct attribute attr;
296 ssize_t (*show)(struct gfs2_sbd *, char *);
297};
298
299#define COUNTERS_ATTR(name, fmt) \
300static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
301{ \
302 return snprintf(buf, PAGE_SIZE, fmt, \
303 (unsigned int)atomic_read(&sdp->sd_##name)); \
304} \
305static struct counters_attr counters_attr_##name = __ATTR_RO(name)
306
307COUNTERS_ATTR(reclaimed, "%u\n");
308
309static struct attribute *counters_attrs[] = {
310 &counters_attr_reclaimed.attr,
311 NULL,
312};
313
314/*
315 * get and set struct gfs2_tune fields 286 * get and set struct gfs2_tune fields
316 */ 287 */
317 288
@@ -393,7 +364,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
393} \ 364} \
394TUNE_ATTR_2(name, name##_store) 365TUNE_ATTR_2(name, name##_store)
395 366
396TUNE_ATTR(demote_secs, 0);
397TUNE_ATTR(incore_log_blocks, 0); 367TUNE_ATTR(incore_log_blocks, 0);
398TUNE_ATTR(log_flush_secs, 0); 368TUNE_ATTR(log_flush_secs, 0);
399TUNE_ATTR(quota_warn_period, 0); 369TUNE_ATTR(quota_warn_period, 0);
@@ -408,11 +378,9 @@ TUNE_ATTR(stall_secs, 1);
408TUNE_ATTR(statfs_quantum, 1); 378TUNE_ATTR(statfs_quantum, 1);
409TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process); 379TUNE_ATTR_DAEMON(recoverd_secs, recoverd_process);
410TUNE_ATTR_DAEMON(logd_secs, logd_process); 380TUNE_ATTR_DAEMON(logd_secs, logd_process);
411TUNE_ATTR_DAEMON(quotad_secs, quotad_process);
412TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store); 381TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
413 382
414static struct attribute *tune_attrs[] = { 383static struct attribute *tune_attrs[] = {
415 &tune_attr_demote_secs.attr,
416 &tune_attr_incore_log_blocks.attr, 384 &tune_attr_incore_log_blocks.attr,
417 &tune_attr_log_flush_secs.attr, 385 &tune_attr_log_flush_secs.attr,
418 &tune_attr_quota_warn_period.attr, 386 &tune_attr_quota_warn_period.attr,
@@ -426,7 +394,6 @@ static struct attribute *tune_attrs[] = {
426 &tune_attr_statfs_quantum.attr, 394 &tune_attr_statfs_quantum.attr,
427 &tune_attr_recoverd_secs.attr, 395 &tune_attr_recoverd_secs.attr,
428 &tune_attr_logd_secs.attr, 396 &tune_attr_logd_secs.attr,
429 &tune_attr_quotad_secs.attr,
430 &tune_attr_quota_scale.attr, 397 &tune_attr_quota_scale.attr,
431 &tune_attr_new_files_jdata.attr, 398 &tune_attr_new_files_jdata.attr,
432 NULL, 399 NULL,
@@ -437,11 +404,6 @@ static struct attribute_group lockstruct_group = {
437 .attrs = lockstruct_attrs, 404 .attrs = lockstruct_attrs,
438}; 405};
439 406
440static struct attribute_group counters_group = {
441 .name = "counters",
442 .attrs = counters_attrs,
443};
444
445static struct attribute_group args_group = { 407static struct attribute_group args_group = {
446 .name = "args", 408 .name = "args",
447 .attrs = args_attrs, 409 .attrs = args_attrs,
@@ -466,13 +428,9 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
466 if (error) 428 if (error)
467 goto fail_reg; 429 goto fail_reg;
468 430
469 error = sysfs_create_group(&sdp->sd_kobj, &counters_group);
470 if (error)
471 goto fail_lockstruct;
472
473 error = sysfs_create_group(&sdp->sd_kobj, &args_group); 431 error = sysfs_create_group(&sdp->sd_kobj, &args_group);
474 if (error) 432 if (error)
475 goto fail_counters; 433 goto fail_lockstruct;
476 434
477 error = sysfs_create_group(&sdp->sd_kobj, &tune_group); 435 error = sysfs_create_group(&sdp->sd_kobj, &tune_group);
478 if (error) 436 if (error)
@@ -483,8 +441,6 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
483 441
484fail_args: 442fail_args:
485 sysfs_remove_group(&sdp->sd_kobj, &args_group); 443 sysfs_remove_group(&sdp->sd_kobj, &args_group);
486fail_counters:
487 sysfs_remove_group(&sdp->sd_kobj, &counters_group);
488fail_lockstruct: 444fail_lockstruct:
489 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); 445 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group);
490fail_reg: 446fail_reg:
@@ -498,16 +454,27 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp)
498{ 454{
499 sysfs_remove_group(&sdp->sd_kobj, &tune_group); 455 sysfs_remove_group(&sdp->sd_kobj, &tune_group);
500 sysfs_remove_group(&sdp->sd_kobj, &args_group); 456 sysfs_remove_group(&sdp->sd_kobj, &args_group);
501 sysfs_remove_group(&sdp->sd_kobj, &counters_group);
502 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); 457 sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group);
503 kobject_put(&sdp->sd_kobj); 458 kobject_put(&sdp->sd_kobj);
504} 459}
505 460
461static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
462 struct kobj_uevent_env *env)
463{
464 struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
465 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
466 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
467 return 0;
468}
469
470static struct kset_uevent_ops gfs2_uevent_ops = {
471 .uevent = gfs2_uevent,
472};
473
474
506int gfs2_sys_init(void) 475int gfs2_sys_init(void)
507{ 476{
508 gfs2_sys_margs = NULL; 477 gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj);
509 spin_lock_init(&gfs2_sys_margs_lock);
510 gfs2_kset = kset_create_and_add("gfs2", NULL, fs_kobj);
511 if (!gfs2_kset) 478 if (!gfs2_kset)
512 return -ENOMEM; 479 return -ENOMEM;
513 return 0; 480 return 0;
@@ -515,7 +482,6 @@ int gfs2_sys_init(void)
515 482
516void gfs2_sys_uninit(void) 483void gfs2_sys_uninit(void)
517{ 484{
518 kfree(gfs2_sys_margs);
519 kset_unregister(gfs2_kset); 485 kset_unregister(gfs2_kset);
520} 486}
521 487
diff --git a/fs/gfs2/sys.h b/fs/gfs2/sys.h
index 1ca8cdac5304..e94560e836d7 100644
--- a/fs/gfs2/sys.h
+++ b/fs/gfs2/sys.h
@@ -13,10 +13,6 @@
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14struct gfs2_sbd; 14struct gfs2_sbd;
15 15
16/* Allow args to be passed to GFS2 when using an initial ram disk */
17extern char *gfs2_sys_margs;
18extern spinlock_t gfs2_sys_margs_lock;
19
20int gfs2_sys_fs_add(struct gfs2_sbd *sdp); 16int gfs2_sys_fs_add(struct gfs2_sbd *sdp);
21void gfs2_sys_fs_del(struct gfs2_sbd *sdp); 17void gfs2_sys_fs_del(struct gfs2_sbd *sdp);
22 18
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index d31e355c61fb..374f50e95496 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -25,6 +25,7 @@ struct kmem_cache *gfs2_glock_cachep __read_mostly;
25struct kmem_cache *gfs2_inode_cachep __read_mostly; 25struct kmem_cache *gfs2_inode_cachep __read_mostly;
26struct kmem_cache *gfs2_bufdata_cachep __read_mostly; 26struct kmem_cache *gfs2_bufdata_cachep __read_mostly;
27struct kmem_cache *gfs2_rgrpd_cachep __read_mostly; 27struct kmem_cache *gfs2_rgrpd_cachep __read_mostly;
28struct kmem_cache *gfs2_quotad_cachep __read_mostly;
28 29
29void gfs2_assert_i(struct gfs2_sbd *sdp) 30void gfs2_assert_i(struct gfs2_sbd *sdp)
30{ 31{
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index 7f48576289c9..33e96b0ce9ab 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -148,6 +148,7 @@ extern struct kmem_cache *gfs2_glock_cachep;
148extern struct kmem_cache *gfs2_inode_cachep; 148extern struct kmem_cache *gfs2_inode_cachep;
149extern struct kmem_cache *gfs2_bufdata_cachep; 149extern struct kmem_cache *gfs2_bufdata_cachep;
150extern struct kmem_cache *gfs2_rgrpd_cachep; 150extern struct kmem_cache *gfs2_rgrpd_cachep;
151extern struct kmem_cache *gfs2_quotad_cachep;
151 152
152static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, 153static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
153 unsigned int *p) 154 unsigned int *p)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 3a31451ac170..5c538e0ec14b 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -501,7 +501,7 @@ int hostfs_write_begin(struct file *file, struct address_space *mapping,
501{ 501{
502 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 502 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
503 503
504 *pagep = __grab_cache_page(mapping, index); 504 *pagep = grab_cache_page_write_begin(mapping, index, flags);
505 if (!*pagep) 505 if (!*pagep)
506 return -ENOMEM; 506 return -ENOMEM;
507 return 0; 507 return 0;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7d479ce3aceb..0ab0c6f5f438 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -506,7 +506,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
506 inode->i_mode = mode; 506 inode->i_mode = mode;
507 inode->i_uid = uid; 507 inode->i_uid = uid;
508 inode->i_gid = gid; 508 inode->i_gid = gid;
509 inode->i_blocks = 0;
510 inode->i_mapping->a_ops = &hugetlbfs_aops; 509 inode->i_mapping->a_ops = &hugetlbfs_aops;
511 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 510 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
512 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 511 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
diff --git a/fs/inode.c b/fs/inode.c
index 7de1cda92489..bd48e5e6d3e8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -131,6 +131,8 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
131 inode->i_op = &empty_iops; 131 inode->i_op = &empty_iops;
132 inode->i_fop = &empty_fops; 132 inode->i_fop = &empty_fops;
133 inode->i_nlink = 1; 133 inode->i_nlink = 1;
134 inode->i_uid = 0;
135 inode->i_gid = 0;
134 atomic_set(&inode->i_writecount, 0); 136 atomic_set(&inode->i_writecount, 0);
135 inode->i_size = 0; 137 inode->i_size = 0;
136 inode->i_blocks = 0; 138 inode->i_blocks = 0;
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 43e8b2c0664b..cc3f1aa1cf7b 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -231,7 +231,8 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
231#define blk_to_logical(inode, blk) (blk << (inode)->i_blkbits) 231#define blk_to_logical(inode, blk) (blk << (inode)->i_blkbits)
232#define logical_to_blk(inode, offset) (offset >> (inode)->i_blkbits); 232#define logical_to_blk(inode, offset) (offset >> (inode)->i_blkbits);
233 233
234/* 234/**
235 * __generic_block_fiemap - FIEMAP for block based inodes (no locking)
235 * @inode - the inode to map 236 * @inode - the inode to map
236 * @arg - the pointer to userspace where we copy everything to 237 * @arg - the pointer to userspace where we copy everything to
237 * @get_block - the fs's get_block function 238 * @get_block - the fs's get_block function
@@ -242,11 +243,15 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
242 * 243 *
243 * If it is possible to have data blocks beyond a hole past @inode->i_size, then 244 * If it is possible to have data blocks beyond a hole past @inode->i_size, then
244 * please do not use this function, it will stop at the first unmapped block 245 * please do not use this function, it will stop at the first unmapped block
245 * beyond i_size 246 * beyond i_size.
247 *
248 * If you use this function directly, you need to do your own locking. Use
249 * generic_block_fiemap if you want the locking done for you.
246 */ 250 */
247int generic_block_fiemap(struct inode *inode, 251
248 struct fiemap_extent_info *fieinfo, u64 start, 252int __generic_block_fiemap(struct inode *inode,
249 u64 len, get_block_t *get_block) 253 struct fiemap_extent_info *fieinfo, u64 start,
254 u64 len, get_block_t *get_block)
250{ 255{
251 struct buffer_head tmp; 256 struct buffer_head tmp;
252 unsigned int start_blk; 257 unsigned int start_blk;
@@ -260,9 +265,6 @@ int generic_block_fiemap(struct inode *inode,
260 265
261 start_blk = logical_to_blk(inode, start); 266 start_blk = logical_to_blk(inode, start);
262 267
263 /* guard against change */
264 mutex_lock(&inode->i_mutex);
265
266 length = (long long)min_t(u64, len, i_size_read(inode)); 268 length = (long long)min_t(u64, len, i_size_read(inode));
267 map_len = length; 269 map_len = length;
268 270
@@ -334,14 +336,36 @@ int generic_block_fiemap(struct inode *inode,
334 cond_resched(); 336 cond_resched();
335 } while (1); 337 } while (1);
336 338
337 mutex_unlock(&inode->i_mutex);
338
339 /* if ret is 1 then we just hit the end of the extent array */ 339 /* if ret is 1 then we just hit the end of the extent array */
340 if (ret == 1) 340 if (ret == 1)
341 ret = 0; 341 ret = 0;
342 342
343 return ret; 343 return ret;
344} 344}
345EXPORT_SYMBOL(__generic_block_fiemap);
346
347/**
348 * generic_block_fiemap - FIEMAP for block based inodes
349 * @inode: The inode to map
350 * @fieinfo: The mapping information
351 * @start: The initial block to map
352 * @len: The length of the extect to attempt to map
353 * @get_block: The block mapping function for the fs
354 *
355 * Calls __generic_block_fiemap to map the inode, after taking
356 * the inode's mutex lock.
357 */
358
359int generic_block_fiemap(struct inode *inode,
360 struct fiemap_extent_info *fieinfo, u64 start,
361 u64 len, get_block_t *get_block)
362{
363 int ret;
364 mutex_lock(&inode->i_mutex);
365 ret = __generic_block_fiemap(inode, fieinfo, start, len, get_block);
366 mutex_unlock(&inode->i_mutex);
367 return ret;
368}
345EXPORT_SYMBOL(generic_block_fiemap); 369EXPORT_SYMBOL(generic_block_fiemap);
346 370
347#endif /* CONFIG_BLOCK */ 371#endif /* CONFIG_BLOCK */
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 3f8af0f1505b..6147ec3643a0 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -855,10 +855,6 @@ root_found:
855 } 855 }
856 sbi->s_joliet_level = joliet_level; 856 sbi->s_joliet_level = joliet_level;
857 857
858 /* check the root inode */
859 if (!inode->i_op)
860 goto out_bad_root;
861
862 /* Make sure the root inode is a directory */ 858 /* Make sure the root inode is a directory */
863 if (!S_ISDIR(inode->i_mode)) { 859 if (!S_ISDIR(inode->i_mode)) {
864 printk(KERN_WARNING 860 printk(KERN_WARNING
@@ -886,8 +882,6 @@ root_found:
886 /* 882 /*
887 * Display error messages and free resources. 883 * Display error messages and free resources.
888 */ 884 */
889out_bad_root:
890 printk(KERN_WARNING "%s: root inode not initialized\n", __func__);
891out_iput: 885out_iput:
892 iput(inode); 886 iput(inode);
893 goto out_no_inode; 887 goto out_no_inode;
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index ebc667bc54a8..c8a1bace685a 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -509,6 +509,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
509 if (is_journal_aborted(journal)) { 509 if (is_journal_aborted(journal)) {
510 clear_buffer_jbddirty(jh2bh(jh)); 510 clear_buffer_jbddirty(jh2bh(jh));
511 JBUFFER_TRACE(jh, "journal is aborting: refile"); 511 JBUFFER_TRACE(jh, "journal is aborting: refile");
512 jbd2_buffer_abort_trigger(jh,
513 jh->b_frozen_data ?
514 jh->b_frozen_triggers :
515 jh->b_triggers);
512 jbd2_journal_refile_buffer(journal, jh); 516 jbd2_journal_refile_buffer(journal, jh);
513 /* If that was the last one, we need to clean up 517 /* If that was the last one, we need to clean up
514 * any descriptor buffers which may have been 518 * any descriptor buffers which may have been
@@ -844,6 +848,9 @@ restart_loop:
844 * data. 848 * data.
845 * 849 *
846 * Otherwise, we can just throw away the frozen data now. 850 * Otherwise, we can just throw away the frozen data now.
851 *
852 * We also know that the frozen data has already fired
853 * its triggers if they exist, so we can clear that too.
847 */ 854 */
848 if (jh->b_committed_data) { 855 if (jh->b_committed_data) {
849 jbd2_free(jh->b_committed_data, bh->b_size); 856 jbd2_free(jh->b_committed_data, bh->b_size);
@@ -851,10 +858,12 @@ restart_loop:
851 if (jh->b_frozen_data) { 858 if (jh->b_frozen_data) {
852 jh->b_committed_data = jh->b_frozen_data; 859 jh->b_committed_data = jh->b_frozen_data;
853 jh->b_frozen_data = NULL; 860 jh->b_frozen_data = NULL;
861 jh->b_frozen_triggers = NULL;
854 } 862 }
855 } else if (jh->b_frozen_data) { 863 } else if (jh->b_frozen_data) {
856 jbd2_free(jh->b_frozen_data, bh->b_size); 864 jbd2_free(jh->b_frozen_data, bh->b_size);
857 jh->b_frozen_data = NULL; 865 jh->b_frozen_data = NULL;
866 jh->b_frozen_triggers = NULL;
858 } 867 }
859 868
860 spin_lock(&journal->j_list_lock); 869 spin_lock(&journal->j_list_lock);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index e70d657a19f8..f6bff9d6f8df 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -50,6 +50,7 @@ EXPORT_SYMBOL(jbd2_journal_unlock_updates);
50EXPORT_SYMBOL(jbd2_journal_get_write_access); 50EXPORT_SYMBOL(jbd2_journal_get_write_access);
51EXPORT_SYMBOL(jbd2_journal_get_create_access); 51EXPORT_SYMBOL(jbd2_journal_get_create_access);
52EXPORT_SYMBOL(jbd2_journal_get_undo_access); 52EXPORT_SYMBOL(jbd2_journal_get_undo_access);
53EXPORT_SYMBOL(jbd2_journal_set_triggers);
53EXPORT_SYMBOL(jbd2_journal_dirty_metadata); 54EXPORT_SYMBOL(jbd2_journal_dirty_metadata);
54EXPORT_SYMBOL(jbd2_journal_release_buffer); 55EXPORT_SYMBOL(jbd2_journal_release_buffer);
55EXPORT_SYMBOL(jbd2_journal_forget); 56EXPORT_SYMBOL(jbd2_journal_forget);
@@ -290,6 +291,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
290 struct page *new_page; 291 struct page *new_page;
291 unsigned int new_offset; 292 unsigned int new_offset;
292 struct buffer_head *bh_in = jh2bh(jh_in); 293 struct buffer_head *bh_in = jh2bh(jh_in);
294 struct jbd2_buffer_trigger_type *triggers;
293 295
294 /* 296 /*
295 * The buffer really shouldn't be locked: only the current committing 297 * The buffer really shouldn't be locked: only the current committing
@@ -314,13 +316,23 @@ repeat:
314 done_copy_out = 1; 316 done_copy_out = 1;
315 new_page = virt_to_page(jh_in->b_frozen_data); 317 new_page = virt_to_page(jh_in->b_frozen_data);
316 new_offset = offset_in_page(jh_in->b_frozen_data); 318 new_offset = offset_in_page(jh_in->b_frozen_data);
319 triggers = jh_in->b_frozen_triggers;
317 } else { 320 } else {
318 new_page = jh2bh(jh_in)->b_page; 321 new_page = jh2bh(jh_in)->b_page;
319 new_offset = offset_in_page(jh2bh(jh_in)->b_data); 322 new_offset = offset_in_page(jh2bh(jh_in)->b_data);
323 triggers = jh_in->b_triggers;
320 } 324 }
321 325
322 mapped_data = kmap_atomic(new_page, KM_USER0); 326 mapped_data = kmap_atomic(new_page, KM_USER0);
323 /* 327 /*
328 * Fire any commit trigger. Do this before checking for escaping,
329 * as the trigger may modify the magic offset. If a copy-out
330 * happens afterwards, it will have the correct data in the buffer.
331 */
332 jbd2_buffer_commit_trigger(jh_in, mapped_data + new_offset,
333 triggers);
334
335 /*
324 * Check for escaping 336 * Check for escaping
325 */ 337 */
326 if (*((__be32 *)(mapped_data + new_offset)) == 338 if (*((__be32 *)(mapped_data + new_offset)) ==
@@ -352,6 +364,13 @@ repeat:
352 new_page = virt_to_page(tmp); 364 new_page = virt_to_page(tmp);
353 new_offset = offset_in_page(tmp); 365 new_offset = offset_in_page(tmp);
354 done_copy_out = 1; 366 done_copy_out = 1;
367
368 /*
369 * This isn't strictly necessary, as we're using frozen
370 * data for the escaping, but it keeps consistency with
371 * b_frozen_data usage.
372 */
373 jh_in->b_frozen_triggers = jh_in->b_triggers;
355 } 374 }
356 375
357 /* 376 /*
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 39b7805a599a..4f925a4f3d05 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -741,6 +741,12 @@ done:
741 source = kmap_atomic(page, KM_USER0); 741 source = kmap_atomic(page, KM_USER0);
742 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size); 742 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size);
743 kunmap_atomic(source, KM_USER0); 743 kunmap_atomic(source, KM_USER0);
744
745 /*
746 * Now that the frozen data is saved off, we need to store
747 * any matching triggers.
748 */
749 jh->b_frozen_triggers = jh->b_triggers;
744 } 750 }
745 jbd_unlock_bh_state(bh); 751 jbd_unlock_bh_state(bh);
746 752
@@ -944,6 +950,47 @@ out:
944} 950}
945 951
946/** 952/**
953 * void jbd2_journal_set_triggers() - Add triggers for commit writeout
954 * @bh: buffer to trigger on
955 * @type: struct jbd2_buffer_trigger_type containing the trigger(s).
956 *
957 * Set any triggers on this journal_head. This is always safe, because
958 * triggers for a committing buffer will be saved off, and triggers for
959 * a running transaction will match the buffer in that transaction.
960 *
961 * Call with NULL to clear the triggers.
962 */
963void jbd2_journal_set_triggers(struct buffer_head *bh,
964 struct jbd2_buffer_trigger_type *type)
965{
966 struct journal_head *jh = bh2jh(bh);
967
968 jh->b_triggers = type;
969}
970
971void jbd2_buffer_commit_trigger(struct journal_head *jh, void *mapped_data,
972 struct jbd2_buffer_trigger_type *triggers)
973{
974 struct buffer_head *bh = jh2bh(jh);
975
976 if (!triggers || !triggers->t_commit)
977 return;
978
979 triggers->t_commit(triggers, bh, mapped_data, bh->b_size);
980}
981
982void jbd2_buffer_abort_trigger(struct journal_head *jh,
983 struct jbd2_buffer_trigger_type *triggers)
984{
985 if (!triggers || !triggers->t_abort)
986 return;
987
988 triggers->t_abort(triggers, jh2bh(jh));
989}
990
991
992
993/**
947 * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata 994 * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata
948 * @handle: transaction to add buffer to. 995 * @handle: transaction to add buffer to.
949 * @bh: buffer to mark 996 * @bh: buffer to mark
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 5a98aa87c853..5edc2bf20581 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -132,7 +132,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
132 uint32_t pageofs = index << PAGE_CACHE_SHIFT; 132 uint32_t pageofs = index << PAGE_CACHE_SHIFT;
133 int ret = 0; 133 int ret = 0;
134 134
135 pg = __grab_cache_page(mapping, index); 135 pg = grab_cache_page_write_begin(mapping, index, flags);
136 if (!pg) 136 if (!pg)
137 return -ENOMEM; 137 return -ENOMEM;
138 *pagep = pg; 138 *pagep = pg;
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index d6363d8309d0..0f94381ca6d0 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -58,9 +58,9 @@
58 58
59/* 59/*
60 * __mark_inode_dirty expects inodes to be hashed. Since we don't want 60 * __mark_inode_dirty expects inodes to be hashed. Since we don't want
61 * special inodes in the fileset inode space, we hash them to a dummy head 61 * special inodes in the fileset inode space, we make them appear hashed,
62 * but do not put on any lists.
62 */ 63 */
63static HLIST_HEAD(aggregate_hash);
64 64
65/* 65/*
66 * imap locks 66 * imap locks
@@ -496,7 +496,11 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
496 /* release the page */ 496 /* release the page */
497 release_metapage(mp); 497 release_metapage(mp);
498 498
499 hlist_add_head(&ip->i_hash, &aggregate_hash); 499 /*
500 * that will look hashed, but won't be on any list; hlist_del()
501 * will work fine and require no locking.
502 */
503 ip->i_hash.pprev = &ip->i_hash.next;
500 504
501 return (ip); 505 return (ip);
502} 506}
diff --git a/fs/libfs.c b/fs/libfs.c
index e960a8321902..49b44099dabb 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -231,7 +231,6 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
231 */ 231 */
232 root->i_ino = 1; 232 root->i_ino = 1;
233 root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR; 233 root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
234 root->i_uid = root->i_gid = 0;
235 root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME; 234 root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
236 dentry = d_alloc(NULL, &d_name); 235 dentry = d_alloc(NULL, &d_name);
237 if (!dentry) { 236 if (!dentry) {
@@ -360,7 +359,7 @@ int simple_write_begin(struct file *file, struct address_space *mapping,
360 index = pos >> PAGE_CACHE_SHIFT; 359 index = pos >> PAGE_CACHE_SHIFT;
361 from = pos & (PAGE_CACHE_SIZE - 1); 360 from = pos & (PAGE_CACHE_SIZE - 1);
362 361
363 page = __grab_cache_page(mapping, index); 362 page = grab_cache_page_write_begin(mapping, index, flags);
364 if (!page) 363 if (!page)
365 return -ENOMEM; 364 return -ENOMEM;
366 365
@@ -436,8 +435,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
436 */ 435 */
437 inode->i_ino = 1; 436 inode->i_ino = 1;
438 inode->i_mode = S_IFDIR | 0755; 437 inode->i_mode = S_IFDIR | 0755;
439 inode->i_uid = inode->i_gid = 0;
440 inode->i_blocks = 0;
441 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 438 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
442 inode->i_op = &simple_dir_inode_operations; 439 inode->i_op = &simple_dir_inode_operations;
443 inode->i_fop = &simple_dir_operations; 440 inode->i_fop = &simple_dir_operations;
@@ -464,8 +461,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
464 if (!inode) 461 if (!inode)
465 goto out; 462 goto out;
466 inode->i_mode = S_IFREG | files->mode; 463 inode->i_mode = S_IFREG | files->mode;
467 inode->i_uid = inode->i_gid = 0;
468 inode->i_blocks = 0;
469 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 464 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
470 inode->i_fop = files->ops; 465 inode->i_fop = files->ops;
471 inode->i_ino = i; 466 inode->i_ino = i;
diff --git a/fs/namei.c b/fs/namei.c
index dd5c9f0bf829..f05bed242422 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -257,7 +257,7 @@ int inode_permission(struct inode *inode, int mask)
257 return -EACCES; 257 return -EACCES;
258 } 258 }
259 259
260 if (inode->i_op && inode->i_op->permission) 260 if (inode->i_op->permission)
261 retval = inode->i_op->permission(inode, mask); 261 retval = inode->i_op->permission(inode, mask);
262 else 262 else
263 retval = generic_permission(inode, mask, NULL); 263 retval = generic_permission(inode, mask, NULL);
@@ -432,7 +432,7 @@ static int exec_permission_lite(struct inode *inode)
432{ 432{
433 umode_t mode = inode->i_mode; 433 umode_t mode = inode->i_mode;
434 434
435 if (inode->i_op && inode->i_op->permission) 435 if (inode->i_op->permission)
436 return -EAGAIN; 436 return -EAGAIN;
437 437
438 if (current_fsuid() == inode->i_uid) 438 if (current_fsuid() == inode->i_uid)
@@ -908,9 +908,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
908 inode = next.dentry->d_inode; 908 inode = next.dentry->d_inode;
909 if (!inode) 909 if (!inode)
910 goto out_dput; 910 goto out_dput;
911 err = -ENOTDIR;
912 if (!inode->i_op)
913 goto out_dput;
914 911
915 if (inode->i_op->follow_link) { 912 if (inode->i_op->follow_link) {
916 err = do_follow_link(&next, nd); 913 err = do_follow_link(&next, nd);
@@ -920,9 +917,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
920 inode = nd->path.dentry->d_inode; 917 inode = nd->path.dentry->d_inode;
921 if (!inode) 918 if (!inode)
922 break; 919 break;
923 err = -ENOTDIR;
924 if (!inode->i_op)
925 break;
926 } else 920 } else
927 path_to_nameidata(&next, nd); 921 path_to_nameidata(&next, nd);
928 err = -ENOTDIR; 922 err = -ENOTDIR;
@@ -961,7 +955,7 @@ last_component:
961 break; 955 break;
962 inode = next.dentry->d_inode; 956 inode = next.dentry->d_inode;
963 if ((lookup_flags & LOOKUP_FOLLOW) 957 if ((lookup_flags & LOOKUP_FOLLOW)
964 && inode && inode->i_op && inode->i_op->follow_link) { 958 && inode && inode->i_op->follow_link) {
965 err = do_follow_link(&next, nd); 959 err = do_follow_link(&next, nd);
966 if (err) 960 if (err)
967 goto return_err; 961 goto return_err;
@@ -973,7 +967,7 @@ last_component:
973 break; 967 break;
974 if (lookup_flags & LOOKUP_DIRECTORY) { 968 if (lookup_flags & LOOKUP_DIRECTORY) {
975 err = -ENOTDIR; 969 err = -ENOTDIR;
976 if (!inode->i_op || !inode->i_op->lookup) 970 if (!inode->i_op->lookup)
977 break; 971 break;
978 } 972 }
979 goto return_base; 973 goto return_base;
@@ -1469,7 +1463,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
1469 if (error) 1463 if (error)
1470 return error; 1464 return error;
1471 1465
1472 if (!dir->i_op || !dir->i_op->create) 1466 if (!dir->i_op->create)
1473 return -EACCES; /* shouldn't it be ENOSYS? */ 1467 return -EACCES; /* shouldn't it be ENOSYS? */
1474 mode &= S_IALLUGO; 1468 mode &= S_IALLUGO;
1475 mode |= S_IFREG; 1469 mode |= S_IFREG;
@@ -1752,7 +1746,7 @@ do_last:
1752 error = -ENOENT; 1746 error = -ENOENT;
1753 if (!path.dentry->d_inode) 1747 if (!path.dentry->d_inode)
1754 goto exit_dput; 1748 goto exit_dput;
1755 if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) 1749 if (path.dentry->d_inode->i_op->follow_link)
1756 goto do_link; 1750 goto do_link;
1757 1751
1758 path_to_nameidata(&path, &nd); 1752 path_to_nameidata(&path, &nd);
@@ -1933,7 +1927,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
1933 if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) 1927 if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
1934 return -EPERM; 1928 return -EPERM;
1935 1929
1936 if (!dir->i_op || !dir->i_op->mknod) 1930 if (!dir->i_op->mknod)
1937 return -EPERM; 1931 return -EPERM;
1938 1932
1939 error = devcgroup_inode_mknod(mode, dev); 1933 error = devcgroup_inode_mknod(mode, dev);
@@ -2035,7 +2029,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
2035 if (error) 2029 if (error)
2036 return error; 2030 return error;
2037 2031
2038 if (!dir->i_op || !dir->i_op->mkdir) 2032 if (!dir->i_op->mkdir)
2039 return -EPERM; 2033 return -EPERM;
2040 2034
2041 mode &= (S_IRWXUGO|S_ISVTX); 2035 mode &= (S_IRWXUGO|S_ISVTX);
@@ -2126,7 +2120,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
2126 if (error) 2120 if (error)
2127 return error; 2121 return error;
2128 2122
2129 if (!dir->i_op || !dir->i_op->rmdir) 2123 if (!dir->i_op->rmdir)
2130 return -EPERM; 2124 return -EPERM;
2131 2125
2132 DQUOT_INIT(dir); 2126 DQUOT_INIT(dir);
@@ -2213,7 +2207,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
2213 if (error) 2207 if (error)
2214 return error; 2208 return error;
2215 2209
2216 if (!dir->i_op || !dir->i_op->unlink) 2210 if (!dir->i_op->unlink)
2217 return -EPERM; 2211 return -EPERM;
2218 2212
2219 DQUOT_INIT(dir); 2213 DQUOT_INIT(dir);
@@ -2320,7 +2314,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
2320 if (error) 2314 if (error)
2321 return error; 2315 return error;
2322 2316
2323 if (!dir->i_op || !dir->i_op->symlink) 2317 if (!dir->i_op->symlink)
2324 return -EPERM; 2318 return -EPERM;
2325 2319
2326 error = security_inode_symlink(dir, dentry, oldname); 2320 error = security_inode_symlink(dir, dentry, oldname);
@@ -2401,7 +2395,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
2401 */ 2395 */
2402 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) 2396 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2403 return -EPERM; 2397 return -EPERM;
2404 if (!dir->i_op || !dir->i_op->link) 2398 if (!dir->i_op->link)
2405 return -EPERM; 2399 return -EPERM;
2406 if (S_ISDIR(inode->i_mode)) 2400 if (S_ISDIR(inode->i_mode))
2407 return -EPERM; 2401 return -EPERM;
@@ -2608,7 +2602,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2608 if (error) 2602 if (error)
2609 return error; 2603 return error;
2610 2604
2611 if (!old_dir->i_op || !old_dir->i_op->rename) 2605 if (!old_dir->i_op->rename)
2612 return -EPERM; 2606 return -EPERM;
2613 2607
2614 DQUOT_INIT(old_dir); 2608 DQUOT_INIT(old_dir);
@@ -2817,18 +2811,23 @@ void page_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
2817 } 2811 }
2818} 2812}
2819 2813
2820int __page_symlink(struct inode *inode, const char *symname, int len, 2814/*
2821 gfp_t gfp_mask) 2815 * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS
2816 */
2817int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
2822{ 2818{
2823 struct address_space *mapping = inode->i_mapping; 2819 struct address_space *mapping = inode->i_mapping;
2824 struct page *page; 2820 struct page *page;
2825 void *fsdata; 2821 void *fsdata;
2826 int err; 2822 int err;
2827 char *kaddr; 2823 char *kaddr;
2824 unsigned int flags = AOP_FLAG_UNINTERRUPTIBLE;
2825 if (nofs)
2826 flags |= AOP_FLAG_NOFS;
2828 2827
2829retry: 2828retry:
2830 err = pagecache_write_begin(NULL, mapping, 0, len-1, 2829 err = pagecache_write_begin(NULL, mapping, 0, len-1,
2831 AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata); 2830 flags, &page, &fsdata);
2832 if (err) 2831 if (err)
2833 goto fail; 2832 goto fail;
2834 2833
@@ -2852,7 +2851,7 @@ fail:
2852int page_symlink(struct inode *inode, const char *symname, int len) 2851int page_symlink(struct inode *inode, const char *symname, int len)
2853{ 2852{
2854 return __page_symlink(inode, symname, len, 2853 return __page_symlink(inode, symname, len,
2855 mapping_gfp_mask(inode->i_mapping)); 2854 !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS));
2856} 2855}
2857 2856
2858const struct inode_operations page_symlink_inode_operations = { 2857const struct inode_operations page_symlink_inode_operations = {
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index d319b49f8f06..90f292b520d2 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -354,7 +354,7 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
354 file->f_path.dentry->d_name.name, 354 file->f_path.dentry->d_name.name,
355 mapping->host->i_ino, len, (long long) pos); 355 mapping->host->i_ino, len, (long long) pos);
356 356
357 page = __grab_cache_page(mapping, index); 357 page = grab_cache_page_write_begin(mapping, index, flags);
358 if (!page) 358 if (!page)
359 return -ENOMEM; 359 return -ENOMEM;
360 *pagep = page; 360 *pagep = page;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index d1c5f787b365..44aa92aba891 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -744,45 +744,16 @@ nfsd_close(struct file *filp)
744 fput(filp); 744 fput(filp);
745} 745}
746 746
747/*
748 * Sync a file
749 * As this calls fsync (not fdatasync) there is no need for a write_inode
750 * after it.
751 */
752static inline int nfsd_dosync(struct file *filp, struct dentry *dp,
753 const struct file_operations *fop)
754{
755 struct inode *inode = dp->d_inode;
756 int (*fsync) (struct file *, struct dentry *, int);
757 int err;
758
759 err = filemap_fdatawrite(inode->i_mapping);
760 if (err == 0 && fop && (fsync = fop->fsync))
761 err = fsync(filp, dp, 0);
762 if (err == 0)
763 err = filemap_fdatawait(inode->i_mapping);
764
765 return err;
766}
767
768
769static int 747static int
770nfsd_sync(struct file *filp) 748nfsd_sync(struct file *filp)
771{ 749{
772 int err; 750 return vfs_fsync(filp, filp->f_path.dentry, 0);
773 struct inode *inode = filp->f_path.dentry->d_inode;
774 dprintk("nfsd: sync file %s\n", filp->f_path.dentry->d_name.name);
775 mutex_lock(&inode->i_mutex);
776 err=nfsd_dosync(filp, filp->f_path.dentry, filp->f_op);
777 mutex_unlock(&inode->i_mutex);
778
779 return err;
780} 751}
781 752
782int 753int
783nfsd_sync_dir(struct dentry *dp) 754nfsd_sync_dir(struct dentry *dentry)
784{ 755{
785 return nfsd_dosync(NULL, dp, dp->d_inode->i_fop); 756 return vfs_fsync(NULL, dentry, 0);
786} 757}
787 758
788/* 759/*
@@ -1211,7 +1182,7 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
1211 dirp = dentry->d_inode; 1182 dirp = dentry->d_inode;
1212 1183
1213 err = nfserr_notdir; 1184 err = nfserr_notdir;
1214 if(!dirp->i_op || !dirp->i_op->lookup) 1185 if (!dirp->i_op->lookup)
1215 goto out; 1186 goto out;
1216 /* 1187 /*
1217 * Check whether the response file handle has been verified yet. 1188 * Check whether the response file handle has been verified yet.
@@ -1347,7 +1318,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1347 /* Get all the sanity checks out of the way before 1318 /* Get all the sanity checks out of the way before
1348 * we lock the parent. */ 1319 * we lock the parent. */
1349 err = nfserr_notdir; 1320 err = nfserr_notdir;
1350 if(!dirp->i_op || !dirp->i_op->lookup) 1321 if (!dirp->i_op->lookup)
1351 goto out; 1322 goto out;
1352 fh_lock_nested(fhp, I_MUTEX_PARENT); 1323 fh_lock_nested(fhp, I_MUTEX_PARENT);
1353 1324
@@ -1482,7 +1453,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
1482 inode = dentry->d_inode; 1453 inode = dentry->d_inode;
1483 1454
1484 err = nfserr_inval; 1455 err = nfserr_inval;
1485 if (!inode->i_op || !inode->i_op->readlink) 1456 if (!inode->i_op->readlink)
1486 goto out; 1457 goto out;
1487 1458
1488 touch_atime(fhp->fh_export->ex_path.mnt, dentry); 1459 touch_atime(fhp->fh_export->ex_path.mnt, dentry);
@@ -2162,7 +2133,7 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
2162 size_t size; 2133 size_t size;
2163 int error; 2134 int error;
2164 2135
2165 if (!IS_POSIXACL(inode) || !inode->i_op || 2136 if (!IS_POSIXACL(inode) ||
2166 !inode->i_op->setxattr || !inode->i_op->removexattr) 2137 !inode->i_op->setxattr || !inode->i_op->removexattr)
2167 return -EOPNOTSUPP; 2138 return -EOPNOTSUPP;
2168 switch(type) { 2139 switch(type) {
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 400f8064a548..81b8644b0136 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -704,7 +704,7 @@ fput_and_out:
704 return ret; 704 return ret;
705} 705}
706 706
707asmlinkage long sys_inotify_rm_watch(int fd, u32 wd) 707asmlinkage long sys_inotify_rm_watch(int fd, __s32 wd)
708{ 708{
709 struct file *filp; 709 struct file *filp;
710 struct inotify_device *dev; 710 struct inotify_device *dev;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index e9da092e2772..86bef156cf0a 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1406,9 +1406,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1406 ni->allocated_size = sle64_to_cpu( 1406 ni->allocated_size = sle64_to_cpu(
1407 a->data.non_resident.allocated_size); 1407 a->data.non_resident.allocated_size);
1408 } 1408 }
1409 /* Setup the operations for this attribute inode. */
1410 vi->i_op = NULL;
1411 vi->i_fop = NULL;
1412 if (NInoMstProtected(ni)) 1409 if (NInoMstProtected(ni))
1413 vi->i_mapping->a_ops = &ntfs_mst_aops; 1410 vi->i_mapping->a_ops = &ntfs_mst_aops;
1414 else 1411 else
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index 589dcdfdfe3c..01596079dd63 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_OCFS2_FS_USERSPACE_CLUSTER) += ocfs2_stack_user.o
12ocfs2-objs := \ 12ocfs2-objs := \
13 alloc.o \ 13 alloc.o \
14 aops.o \ 14 aops.o \
15 blockcheck.o \
15 buffer_head_io.o \ 16 buffer_head_io.o \
16 dcache.o \ 17 dcache.o \
17 dir.o \ 18 dir.o \
@@ -35,8 +36,14 @@ ocfs2-objs := \
35 sysfile.o \ 36 sysfile.o \
36 uptodate.o \ 37 uptodate.o \
37 ver.o \ 38 ver.o \
39 quota_local.o \
40 quota_global.o \
38 xattr.o 41 xattr.o
39 42
43ifeq ($(CONFIG_OCFS2_FS_POSIX_ACL),y)
44ocfs2-objs += acl.o
45endif
46
40ocfs2_stackglue-objs := stackglue.o 47ocfs2_stackglue-objs := stackglue.o
41ocfs2_stack_o2cb-objs := stack_o2cb.o 48ocfs2_stack_o2cb-objs := stack_o2cb.o
42ocfs2_stack_user-objs := stack_user.o 49ocfs2_stack_user-objs := stack_user.o
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
new file mode 100644
index 000000000000..12dfb44c22e5
--- /dev/null
+++ b/fs/ocfs2/acl.c
@@ -0,0 +1,479 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * acl.c
5 *
6 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
7 *
8 * CREDITS:
9 * Lots of code in this file is copy from linux/fs/ext3/acl.c.
10 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public
14 * License version 2 as published by the Free Software Foundation.
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 GNU
19 * General Public License for more details.
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/string.h>
25
26#define MLOG_MASK_PREFIX ML_INODE
27#include <cluster/masklog.h>
28
29#include "ocfs2.h"
30#include "alloc.h"
31#include "dlmglue.h"
32#include "file.h"
33#include "ocfs2_fs.h"
34
35#include "xattr.h"
36#include "acl.h"
37
38/*
39 * Convert from xattr value to acl struct.
40 */
41static struct posix_acl *ocfs2_acl_from_xattr(const void *value, size_t size)
42{
43 int n, count;
44 struct posix_acl *acl;
45
46 if (!value)
47 return NULL;
48 if (size < sizeof(struct posix_acl_entry))
49 return ERR_PTR(-EINVAL);
50
51 count = size / sizeof(struct posix_acl_entry);
52 if (count < 0)
53 return ERR_PTR(-EINVAL);
54 if (count == 0)
55 return NULL;
56
57 acl = posix_acl_alloc(count, GFP_NOFS);
58 if (!acl)
59 return ERR_PTR(-ENOMEM);
60 for (n = 0; n < count; n++) {
61 struct ocfs2_acl_entry *entry =
62 (struct ocfs2_acl_entry *)value;
63
64 acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
65 acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
66 acl->a_entries[n].e_id = le32_to_cpu(entry->e_id);
67 value += sizeof(struct posix_acl_entry);
68
69 }
70 return acl;
71}
72
73/*
74 * Convert acl struct to xattr value.
75 */
76static void *ocfs2_acl_to_xattr(const struct posix_acl *acl, size_t *size)
77{
78 struct ocfs2_acl_entry *entry = NULL;
79 char *ocfs2_acl;
80 size_t n;
81
82 *size = acl->a_count * sizeof(struct posix_acl_entry);
83
84 ocfs2_acl = kmalloc(*size, GFP_NOFS);
85 if (!ocfs2_acl)
86 return ERR_PTR(-ENOMEM);
87
88 entry = (struct ocfs2_acl_entry *)ocfs2_acl;
89 for (n = 0; n < acl->a_count; n++, entry++) {
90 entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
91 entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
92 entry->e_id = cpu_to_le32(acl->a_entries[n].e_id);
93 }
94 return ocfs2_acl;
95}
96
97static struct posix_acl *ocfs2_get_acl_nolock(struct inode *inode,
98 int type,
99 struct buffer_head *di_bh)
100{
101 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
102 int name_index;
103 char *value = NULL;
104 struct posix_acl *acl;
105 int retval;
106
107 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
108 return NULL;
109
110 switch (type) {
111 case ACL_TYPE_ACCESS:
112 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
113 break;
114 case ACL_TYPE_DEFAULT:
115 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT;
116 break;
117 default:
118 return ERR_PTR(-EINVAL);
119 }
120
121 retval = ocfs2_xattr_get_nolock(inode, di_bh, name_index, "", NULL, 0);
122 if (retval > 0) {
123 value = kmalloc(retval, GFP_NOFS);
124 if (!value)
125 return ERR_PTR(-ENOMEM);
126 retval = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
127 "", value, retval);
128 }
129
130 if (retval > 0)
131 acl = ocfs2_acl_from_xattr(value, retval);
132 else if (retval == -ENODATA || retval == 0)
133 acl = NULL;
134 else
135 acl = ERR_PTR(retval);
136
137 kfree(value);
138
139 return acl;
140}
141
142
143/*
144 * Get posix acl.
145 */
146static struct posix_acl *ocfs2_get_acl(struct inode *inode, int type)
147{
148 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
149 struct buffer_head *di_bh = NULL;
150 struct posix_acl *acl;
151 int ret;
152
153 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
154 return NULL;
155
156 ret = ocfs2_inode_lock(inode, &di_bh, 0);
157 if (ret < 0) {
158 mlog_errno(ret);
159 acl = ERR_PTR(ret);
160 return acl;
161 }
162
163 acl = ocfs2_get_acl_nolock(inode, type, di_bh);
164
165 ocfs2_inode_unlock(inode, 0);
166
167 brelse(di_bh);
168
169 return acl;
170}
171
172/*
173 * Set the access or default ACL of an inode.
174 */
175static int ocfs2_set_acl(handle_t *handle,
176 struct inode *inode,
177 struct buffer_head *di_bh,
178 int type,
179 struct posix_acl *acl,
180 struct ocfs2_alloc_context *meta_ac,
181 struct ocfs2_alloc_context *data_ac)
182{
183 int name_index;
184 void *value = NULL;
185 size_t size = 0;
186 int ret;
187
188 if (S_ISLNK(inode->i_mode))
189 return -EOPNOTSUPP;
190
191 switch (type) {
192 case ACL_TYPE_ACCESS:
193 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
194 if (acl) {
195 mode_t mode = inode->i_mode;
196 ret = posix_acl_equiv_mode(acl, &mode);
197 if (ret < 0)
198 return ret;
199 else {
200 inode->i_mode = mode;
201 if (ret == 0)
202 acl = NULL;
203 }
204 }
205 break;
206 case ACL_TYPE_DEFAULT:
207 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT;
208 if (!S_ISDIR(inode->i_mode))
209 return acl ? -EACCES : 0;
210 break;
211 default:
212 return -EINVAL;
213 }
214
215 if (acl) {
216 value = ocfs2_acl_to_xattr(acl, &size);
217 if (IS_ERR(value))
218 return (int)PTR_ERR(value);
219 }
220
221 if (handle)
222 ret = ocfs2_xattr_set_handle(handle, inode, di_bh, name_index,
223 "", value, size, 0,
224 meta_ac, data_ac);
225 else
226 ret = ocfs2_xattr_set(inode, name_index, "", value, size, 0);
227
228 kfree(value);
229
230 return ret;
231}
232
233int ocfs2_check_acl(struct inode *inode, int mask)
234{
235 struct posix_acl *acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
236
237 if (IS_ERR(acl))
238 return PTR_ERR(acl);
239 if (acl) {
240 int ret = posix_acl_permission(inode, acl, mask);
241 posix_acl_release(acl);
242 return ret;
243 }
244
245 return -EAGAIN;
246}
247
248int ocfs2_acl_chmod(struct inode *inode)
249{
250 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
251 struct posix_acl *acl, *clone;
252 int ret;
253
254 if (S_ISLNK(inode->i_mode))
255 return -EOPNOTSUPP;
256
257 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
258 return 0;
259
260 acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
261 if (IS_ERR(acl) || !acl)
262 return PTR_ERR(acl);
263 clone = posix_acl_clone(acl, GFP_KERNEL);
264 posix_acl_release(acl);
265 if (!clone)
266 return -ENOMEM;
267 ret = posix_acl_chmod_masq(clone, inode->i_mode);
268 if (!ret)
269 ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
270 clone, NULL, NULL);
271 posix_acl_release(clone);
272 return ret;
273}
274
275/*
276 * Initialize the ACLs of a new inode. If parent directory has default ACL,
277 * then clone to new inode. Called from ocfs2_mknod.
278 */
279int ocfs2_init_acl(handle_t *handle,
280 struct inode *inode,
281 struct inode *dir,
282 struct buffer_head *di_bh,
283 struct buffer_head *dir_bh,
284 struct ocfs2_alloc_context *meta_ac,
285 struct ocfs2_alloc_context *data_ac)
286{
287 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
288 struct posix_acl *acl = NULL;
289 int ret = 0;
290
291 if (!S_ISLNK(inode->i_mode)) {
292 if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
293 acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT,
294 dir_bh);
295 if (IS_ERR(acl))
296 return PTR_ERR(acl);
297 }
298 if (!acl)
299 inode->i_mode &= ~current->fs->umask;
300 }
301 if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
302 struct posix_acl *clone;
303 mode_t mode;
304
305 if (S_ISDIR(inode->i_mode)) {
306 ret = ocfs2_set_acl(handle, inode, di_bh,
307 ACL_TYPE_DEFAULT, acl,
308 meta_ac, data_ac);
309 if (ret)
310 goto cleanup;
311 }
312 clone = posix_acl_clone(acl, GFP_NOFS);
313 ret = -ENOMEM;
314 if (!clone)
315 goto cleanup;
316
317 mode = inode->i_mode;
318 ret = posix_acl_create_masq(clone, &mode);
319 if (ret >= 0) {
320 inode->i_mode = mode;
321 if (ret > 0) {
322 ret = ocfs2_set_acl(handle, inode,
323 di_bh, ACL_TYPE_ACCESS,
324 clone, meta_ac, data_ac);
325 }
326 }
327 posix_acl_release(clone);
328 }
329cleanup:
330 posix_acl_release(acl);
331 return ret;
332}
333
334static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
335 char *list,
336 size_t list_len,
337 const char *name,
338 size_t name_len)
339{
340 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
341 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
342
343 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
344 return 0;
345
346 if (list && size <= list_len)
347 memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
348 return size;
349}
350
351static size_t ocfs2_xattr_list_acl_default(struct inode *inode,
352 char *list,
353 size_t list_len,
354 const char *name,
355 size_t name_len)
356{
357 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
358 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
359
360 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
361 return 0;
362
363 if (list && size <= list_len)
364 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
365 return size;
366}
367
368static int ocfs2_xattr_get_acl(struct inode *inode,
369 int type,
370 void *buffer,
371 size_t size)
372{
373 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
374 struct posix_acl *acl;
375 int ret;
376
377 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
378 return -EOPNOTSUPP;
379
380 acl = ocfs2_get_acl(inode, type);
381 if (IS_ERR(acl))
382 return PTR_ERR(acl);
383 if (acl == NULL)
384 return -ENODATA;
385 ret = posix_acl_to_xattr(acl, buffer, size);
386 posix_acl_release(acl);
387
388 return ret;
389}
390
391static int ocfs2_xattr_get_acl_access(struct inode *inode,
392 const char *name,
393 void *buffer,
394 size_t size)
395{
396 if (strcmp(name, "") != 0)
397 return -EINVAL;
398 return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
399}
400
401static int ocfs2_xattr_get_acl_default(struct inode *inode,
402 const char *name,
403 void *buffer,
404 size_t size)
405{
406 if (strcmp(name, "") != 0)
407 return -EINVAL;
408 return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
409}
410
411static int ocfs2_xattr_set_acl(struct inode *inode,
412 int type,
413 const void *value,
414 size_t size)
415{
416 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
417 struct posix_acl *acl;
418 int ret = 0;
419
420 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
421 return -EOPNOTSUPP;
422
423 if (!is_owner_or_cap(inode))
424 return -EPERM;
425
426 if (value) {
427 acl = posix_acl_from_xattr(value, size);
428 if (IS_ERR(acl))
429 return PTR_ERR(acl);
430 else if (acl) {
431 ret = posix_acl_valid(acl);
432 if (ret)
433 goto cleanup;
434 }
435 } else
436 acl = NULL;
437
438 ret = ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
439
440cleanup:
441 posix_acl_release(acl);
442 return ret;
443}
444
445static int ocfs2_xattr_set_acl_access(struct inode *inode,
446 const char *name,
447 const void *value,
448 size_t size,
449 int flags)
450{
451 if (strcmp(name, "") != 0)
452 return -EINVAL;
453 return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
454}
455
456static int ocfs2_xattr_set_acl_default(struct inode *inode,
457 const char *name,
458 const void *value,
459 size_t size,
460 int flags)
461{
462 if (strcmp(name, "") != 0)
463 return -EINVAL;
464 return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
465}
466
467struct xattr_handler ocfs2_xattr_acl_access_handler = {
468 .prefix = POSIX_ACL_XATTR_ACCESS,
469 .list = ocfs2_xattr_list_acl_access,
470 .get = ocfs2_xattr_get_acl_access,
471 .set = ocfs2_xattr_set_acl_access,
472};
473
474struct xattr_handler ocfs2_xattr_acl_default_handler = {
475 .prefix = POSIX_ACL_XATTR_DEFAULT,
476 .list = ocfs2_xattr_list_acl_default,
477 .get = ocfs2_xattr_get_acl_default,
478 .set = ocfs2_xattr_set_acl_default,
479};
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h
new file mode 100644
index 000000000000..8f6389ed4da5
--- /dev/null
+++ b/fs/ocfs2/acl.h
@@ -0,0 +1,58 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * acl.h
5 *
6 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef OCFS2_ACL_H
19#define OCFS2_ACL_H
20
21#include <linux/posix_acl_xattr.h>
22
23struct ocfs2_acl_entry {
24 __le16 e_tag;
25 __le16 e_perm;
26 __le32 e_id;
27};
28
29#ifdef CONFIG_OCFS2_FS_POSIX_ACL
30
31extern int ocfs2_check_acl(struct inode *, int);
32extern int ocfs2_acl_chmod(struct inode *);
33extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
34 struct buffer_head *, struct buffer_head *,
35 struct ocfs2_alloc_context *,
36 struct ocfs2_alloc_context *);
37
38#else /* CONFIG_OCFS2_FS_POSIX_ACL*/
39
40#define ocfs2_check_acl NULL
41static inline int ocfs2_acl_chmod(struct inode *inode)
42{
43 return 0;
44}
45static inline int ocfs2_init_acl(handle_t *handle,
46 struct inode *inode,
47 struct inode *dir,
48 struct buffer_head *di_bh,
49 struct buffer_head *dir_bh,
50 struct ocfs2_alloc_context *meta_ac,
51 struct ocfs2_alloc_context *data_ac)
52{
53 return 0;
54}
55
56#endif /* CONFIG_OCFS2_FS_POSIX_ACL*/
57
58#endif /* OCFS2_ACL_H */
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 0cc2deb9394c..54ff4c77aaa3 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/highmem.h> 29#include <linux/highmem.h>
30#include <linux/swap.h> 30#include <linux/swap.h>
31#include <linux/quotaops.h>
31 32
32#define MLOG_MASK_PREFIX ML_DISK_ALLOC 33#define MLOG_MASK_PREFIX ML_DISK_ALLOC
33#include <cluster/masklog.h> 34#include <cluster/masklog.h>
@@ -36,6 +37,7 @@
36 37
37#include "alloc.h" 38#include "alloc.h"
38#include "aops.h" 39#include "aops.h"
40#include "blockcheck.h"
39#include "dlmglue.h" 41#include "dlmglue.h"
40#include "extent_map.h" 42#include "extent_map.h"
41#include "inode.h" 43#include "inode.h"
@@ -46,6 +48,7 @@
46#include "file.h" 48#include "file.h"
47#include "super.h" 49#include "super.h"
48#include "uptodate.h" 50#include "uptodate.h"
51#include "xattr.h"
49 52
50#include "buffer_head_io.h" 53#include "buffer_head_io.h"
51 54
@@ -187,20 +190,12 @@ static int ocfs2_dinode_insert_check(struct inode *inode,
187static int ocfs2_dinode_sanity_check(struct inode *inode, 190static int ocfs2_dinode_sanity_check(struct inode *inode,
188 struct ocfs2_extent_tree *et) 191 struct ocfs2_extent_tree *et)
189{ 192{
190 int ret = 0; 193 struct ocfs2_dinode *di = et->et_object;
191 struct ocfs2_dinode *di;
192 194
193 BUG_ON(et->et_ops != &ocfs2_dinode_et_ops); 195 BUG_ON(et->et_ops != &ocfs2_dinode_et_ops);
196 BUG_ON(!OCFS2_IS_VALID_DINODE(di));
194 197
195 di = et->et_object; 198 return 0;
196 if (!OCFS2_IS_VALID_DINODE(di)) {
197 ret = -EIO;
198 ocfs2_error(inode->i_sb,
199 "Inode %llu has invalid path root",
200 (unsigned long long)OCFS2_I(inode)->ip_blkno);
201 }
202
203 return ret;
204} 199}
205 200
206static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et) 201static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et)
@@ -213,36 +208,33 @@ static void ocfs2_dinode_fill_root_el(struct ocfs2_extent_tree *et)
213 208
214static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et) 209static void ocfs2_xattr_value_fill_root_el(struct ocfs2_extent_tree *et)
215{ 210{
216 struct ocfs2_xattr_value_root *xv = et->et_object; 211 struct ocfs2_xattr_value_buf *vb = et->et_object;
217 212
218 et->et_root_el = &xv->xr_list; 213 et->et_root_el = &vb->vb_xv->xr_list;
219} 214}
220 215
221static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et, 216static void ocfs2_xattr_value_set_last_eb_blk(struct ocfs2_extent_tree *et,
222 u64 blkno) 217 u64 blkno)
223{ 218{
224 struct ocfs2_xattr_value_root *xv = 219 struct ocfs2_xattr_value_buf *vb = et->et_object;
225 (struct ocfs2_xattr_value_root *)et->et_object;
226 220
227 xv->xr_last_eb_blk = cpu_to_le64(blkno); 221 vb->vb_xv->xr_last_eb_blk = cpu_to_le64(blkno);
228} 222}
229 223
230static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et) 224static u64 ocfs2_xattr_value_get_last_eb_blk(struct ocfs2_extent_tree *et)
231{ 225{
232 struct ocfs2_xattr_value_root *xv = 226 struct ocfs2_xattr_value_buf *vb = et->et_object;
233 (struct ocfs2_xattr_value_root *) et->et_object;
234 227
235 return le64_to_cpu(xv->xr_last_eb_blk); 228 return le64_to_cpu(vb->vb_xv->xr_last_eb_blk);
236} 229}
237 230
238static void ocfs2_xattr_value_update_clusters(struct inode *inode, 231static void ocfs2_xattr_value_update_clusters(struct inode *inode,
239 struct ocfs2_extent_tree *et, 232 struct ocfs2_extent_tree *et,
240 u32 clusters) 233 u32 clusters)
241{ 234{
242 struct ocfs2_xattr_value_root *xv = 235 struct ocfs2_xattr_value_buf *vb = et->et_object;
243 (struct ocfs2_xattr_value_root *)et->et_object;
244 236
245 le32_add_cpu(&xv->xr_clusters, clusters); 237 le32_add_cpu(&vb->vb_xv->xr_clusters, clusters);
246} 238}
247 239
248static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = { 240static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = {
@@ -304,11 +296,13 @@ static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
304static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et, 296static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
305 struct inode *inode, 297 struct inode *inode,
306 struct buffer_head *bh, 298 struct buffer_head *bh,
299 ocfs2_journal_access_func access,
307 void *obj, 300 void *obj,
308 struct ocfs2_extent_tree_operations *ops) 301 struct ocfs2_extent_tree_operations *ops)
309{ 302{
310 et->et_ops = ops; 303 et->et_ops = ops;
311 et->et_root_bh = bh; 304 et->et_root_bh = bh;
305 et->et_root_journal_access = access;
312 if (!obj) 306 if (!obj)
313 obj = (void *)bh->b_data; 307 obj = (void *)bh->b_data;
314 et->et_object = obj; 308 et->et_object = obj;
@@ -324,23 +318,23 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
324 struct inode *inode, 318 struct inode *inode,
325 struct buffer_head *bh) 319 struct buffer_head *bh)
326{ 320{
327 __ocfs2_init_extent_tree(et, inode, bh, NULL, &ocfs2_dinode_et_ops); 321 __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_di,
322 NULL, &ocfs2_dinode_et_ops);
328} 323}
329 324
330void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, 325void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
331 struct inode *inode, 326 struct inode *inode,
332 struct buffer_head *bh) 327 struct buffer_head *bh)
333{ 328{
334 __ocfs2_init_extent_tree(et, inode, bh, NULL, 329 __ocfs2_init_extent_tree(et, inode, bh, ocfs2_journal_access_xb,
335 &ocfs2_xattr_tree_et_ops); 330 NULL, &ocfs2_xattr_tree_et_ops);
336} 331}
337 332
338void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, 333void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
339 struct inode *inode, 334 struct inode *inode,
340 struct buffer_head *bh, 335 struct ocfs2_xattr_value_buf *vb)
341 struct ocfs2_xattr_value_root *xv)
342{ 336{
343 __ocfs2_init_extent_tree(et, inode, bh, xv, 337 __ocfs2_init_extent_tree(et, inode, vb->vb_bh, vb->vb_access, vb,
344 &ocfs2_xattr_value_et_ops); 338 &ocfs2_xattr_value_et_ops);
345} 339}
346 340
@@ -362,6 +356,15 @@ static inline void ocfs2_et_update_clusters(struct inode *inode,
362 et->et_ops->eo_update_clusters(inode, et, clusters); 356 et->et_ops->eo_update_clusters(inode, et, clusters);
363} 357}
364 358
359static inline int ocfs2_et_root_journal_access(handle_t *handle,
360 struct inode *inode,
361 struct ocfs2_extent_tree *et,
362 int type)
363{
364 return et->et_root_journal_access(handle, inode, et->et_root_bh,
365 type);
366}
367
365static inline int ocfs2_et_insert_check(struct inode *inode, 368static inline int ocfs2_et_insert_check(struct inode *inode,
366 struct ocfs2_extent_tree *et, 369 struct ocfs2_extent_tree *et,
367 struct ocfs2_extent_rec *rec) 370 struct ocfs2_extent_rec *rec)
@@ -402,12 +405,14 @@ struct ocfs2_path_item {
402#define OCFS2_MAX_PATH_DEPTH 5 405#define OCFS2_MAX_PATH_DEPTH 5
403 406
404struct ocfs2_path { 407struct ocfs2_path {
405 int p_tree_depth; 408 int p_tree_depth;
406 struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH]; 409 ocfs2_journal_access_func p_root_access;
410 struct ocfs2_path_item p_node[OCFS2_MAX_PATH_DEPTH];
407}; 411};
408 412
409#define path_root_bh(_path) ((_path)->p_node[0].bh) 413#define path_root_bh(_path) ((_path)->p_node[0].bh)
410#define path_root_el(_path) ((_path)->p_node[0].el) 414#define path_root_el(_path) ((_path)->p_node[0].el)
415#define path_root_access(_path)((_path)->p_root_access)
411#define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh) 416#define path_leaf_bh(_path) ((_path)->p_node[(_path)->p_tree_depth].bh)
412#define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el) 417#define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el)
413#define path_num_items(_path) ((_path)->p_tree_depth + 1) 418#define path_num_items(_path) ((_path)->p_tree_depth + 1)
@@ -440,6 +445,8 @@ static void ocfs2_reinit_path(struct ocfs2_path *path, int keep_root)
440 */ 445 */
441 if (keep_root) 446 if (keep_root)
442 depth = le16_to_cpu(path_root_el(path)->l_tree_depth); 447 depth = le16_to_cpu(path_root_el(path)->l_tree_depth);
448 else
449 path_root_access(path) = NULL;
443 450
444 path->p_tree_depth = depth; 451 path->p_tree_depth = depth;
445} 452}
@@ -465,6 +472,7 @@ static void ocfs2_cp_path(struct ocfs2_path *dest, struct ocfs2_path *src)
465 472
466 BUG_ON(path_root_bh(dest) != path_root_bh(src)); 473 BUG_ON(path_root_bh(dest) != path_root_bh(src));
467 BUG_ON(path_root_el(dest) != path_root_el(src)); 474 BUG_ON(path_root_el(dest) != path_root_el(src));
475 BUG_ON(path_root_access(dest) != path_root_access(src));
468 476
469 ocfs2_reinit_path(dest, 1); 477 ocfs2_reinit_path(dest, 1);
470 478
@@ -486,6 +494,7 @@ static void ocfs2_mv_path(struct ocfs2_path *dest, struct ocfs2_path *src)
486 int i; 494 int i;
487 495
488 BUG_ON(path_root_bh(dest) != path_root_bh(src)); 496 BUG_ON(path_root_bh(dest) != path_root_bh(src));
497 BUG_ON(path_root_access(dest) != path_root_access(src));
489 498
490 for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) { 499 for(i = 1; i < OCFS2_MAX_PATH_DEPTH; i++) {
491 brelse(dest->p_node[i].bh); 500 brelse(dest->p_node[i].bh);
@@ -521,7 +530,8 @@ static inline void ocfs2_path_insert_eb(struct ocfs2_path *path, int index,
521} 530}
522 531
523static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, 532static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh,
524 struct ocfs2_extent_list *root_el) 533 struct ocfs2_extent_list *root_el,
534 ocfs2_journal_access_func access)
525{ 535{
526 struct ocfs2_path *path; 536 struct ocfs2_path *path;
527 537
@@ -533,11 +543,48 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh,
533 get_bh(root_bh); 543 get_bh(root_bh);
534 path_root_bh(path) = root_bh; 544 path_root_bh(path) = root_bh;
535 path_root_el(path) = root_el; 545 path_root_el(path) = root_el;
546 path_root_access(path) = access;
536 } 547 }
537 548
538 return path; 549 return path;
539} 550}
540 551
552static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path)
553{
554 return ocfs2_new_path(path_root_bh(path), path_root_el(path),
555 path_root_access(path));
556}
557
558static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et)
559{
560 return ocfs2_new_path(et->et_root_bh, et->et_root_el,
561 et->et_root_journal_access);
562}
563
564/*
565 * Journal the buffer at depth idx. All idx>0 are extent_blocks,
566 * otherwise it's the root_access function.
567 *
568 * I don't like the way this function's name looks next to
569 * ocfs2_journal_access_path(), but I don't have a better one.
570 */
571static int ocfs2_path_bh_journal_access(handle_t *handle,
572 struct inode *inode,
573 struct ocfs2_path *path,
574 int idx)
575{
576 ocfs2_journal_access_func access = path_root_access(path);
577
578 if (!access)
579 access = ocfs2_journal_access;
580
581 if (idx)
582 access = ocfs2_journal_access_eb;
583
584 return access(handle, inode, path->p_node[idx].bh,
585 OCFS2_JOURNAL_ACCESS_WRITE);
586}
587
541/* 588/*
542 * Convenience function to journal all components in a path. 589 * Convenience function to journal all components in a path.
543 */ 590 */
@@ -550,8 +597,7 @@ static int ocfs2_journal_access_path(struct inode *inode, handle_t *handle,
550 goto out; 597 goto out;
551 598
552 for(i = 0; i < path_num_items(path); i++) { 599 for(i = 0; i < path_num_items(path); i++) {
553 ret = ocfs2_journal_access(handle, inode, path->p_node[i].bh, 600 ret = ocfs2_path_bh_journal_access(handle, inode, path, i);
554 OCFS2_JOURNAL_ACCESS_WRITE);
555 if (ret < 0) { 601 if (ret < 0) {
556 mlog_errno(ret); 602 mlog_errno(ret);
557 goto out; 603 goto out;
@@ -686,6 +732,80 @@ struct ocfs2_merge_ctxt {
686 int c_split_covers_rec; 732 int c_split_covers_rec;
687}; 733};
688 734
735static int ocfs2_validate_extent_block(struct super_block *sb,
736 struct buffer_head *bh)
737{
738 int rc;
739 struct ocfs2_extent_block *eb =
740 (struct ocfs2_extent_block *)bh->b_data;
741
742 mlog(0, "Validating extent block %llu\n",
743 (unsigned long long)bh->b_blocknr);
744
745 BUG_ON(!buffer_uptodate(bh));
746
747 /*
748 * If the ecc fails, we return the error but otherwise
749 * leave the filesystem running. We know any error is
750 * local to this block.
751 */
752 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &eb->h_check);
753 if (rc) {
754 mlog(ML_ERROR, "Checksum failed for extent block %llu\n",
755 (unsigned long long)bh->b_blocknr);
756 return rc;
757 }
758
759 /*
760 * Errors after here are fatal.
761 */
762
763 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
764 ocfs2_error(sb,
765 "Extent block #%llu has bad signature %.*s",
766 (unsigned long long)bh->b_blocknr, 7,
767 eb->h_signature);
768 return -EINVAL;
769 }
770
771 if (le64_to_cpu(eb->h_blkno) != bh->b_blocknr) {
772 ocfs2_error(sb,
773 "Extent block #%llu has an invalid h_blkno "
774 "of %llu",
775 (unsigned long long)bh->b_blocknr,
776 (unsigned long long)le64_to_cpu(eb->h_blkno));
777 return -EINVAL;
778 }
779
780 if (le32_to_cpu(eb->h_fs_generation) != OCFS2_SB(sb)->fs_generation) {
781 ocfs2_error(sb,
782 "Extent block #%llu has an invalid "
783 "h_fs_generation of #%u",
784 (unsigned long long)bh->b_blocknr,
785 le32_to_cpu(eb->h_fs_generation));
786 return -EINVAL;
787 }
788
789 return 0;
790}
791
792int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno,
793 struct buffer_head **bh)
794{
795 int rc;
796 struct buffer_head *tmp = *bh;
797
798 rc = ocfs2_read_block(inode, eb_blkno, &tmp,
799 ocfs2_validate_extent_block);
800
801 /* If ocfs2_read_block() got us a new bh, pass it up. */
802 if (!rc && !*bh)
803 *bh = tmp;
804
805 return rc;
806}
807
808
689/* 809/*
690 * How many free extents have we got before we need more meta data? 810 * How many free extents have we got before we need more meta data?
691 */ 811 */
@@ -705,8 +825,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
705 last_eb_blk = ocfs2_et_get_last_eb_blk(et); 825 last_eb_blk = ocfs2_et_get_last_eb_blk(et);
706 826
707 if (last_eb_blk) { 827 if (last_eb_blk) {
708 retval = ocfs2_read_block(inode, last_eb_blk, 828 retval = ocfs2_read_extent_block(inode, last_eb_blk, &eb_bh);
709 &eb_bh);
710 if (retval < 0) { 829 if (retval < 0) {
711 mlog_errno(retval); 830 mlog_errno(retval);
712 goto bail; 831 goto bail;
@@ -768,8 +887,8 @@ static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
768 } 887 }
769 ocfs2_set_new_buffer_uptodate(inode, bhs[i]); 888 ocfs2_set_new_buffer_uptodate(inode, bhs[i]);
770 889
771 status = ocfs2_journal_access(handle, inode, bhs[i], 890 status = ocfs2_journal_access_eb(handle, inode, bhs[i],
772 OCFS2_JOURNAL_ACCESS_CREATE); 891 OCFS2_JOURNAL_ACCESS_CREATE);
773 if (status < 0) { 892 if (status < 0) {
774 mlog_errno(status); 893 mlog_errno(status);
775 goto bail; 894 goto bail;
@@ -908,15 +1027,12 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
908 for(i = 0; i < new_blocks; i++) { 1027 for(i = 0; i < new_blocks; i++) {
909 bh = new_eb_bhs[i]; 1028 bh = new_eb_bhs[i];
910 eb = (struct ocfs2_extent_block *) bh->b_data; 1029 eb = (struct ocfs2_extent_block *) bh->b_data;
911 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 1030 /* ocfs2_create_new_meta_bhs() should create it right! */
912 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); 1031 BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb));
913 status = -EIO;
914 goto bail;
915 }
916 eb_el = &eb->h_list; 1032 eb_el = &eb->h_list;
917 1033
918 status = ocfs2_journal_access(handle, inode, bh, 1034 status = ocfs2_journal_access_eb(handle, inode, bh,
919 OCFS2_JOURNAL_ACCESS_CREATE); 1035 OCFS2_JOURNAL_ACCESS_CREATE);
920 if (status < 0) { 1036 if (status < 0) {
921 mlog_errno(status); 1037 mlog_errno(status);
922 goto bail; 1038 goto bail;
@@ -955,21 +1071,21 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
955 * journal_dirty erroring as it won't unless we've aborted the 1071 * journal_dirty erroring as it won't unless we've aborted the
956 * handle (in which case we would never be here) so reserving 1072 * handle (in which case we would never be here) so reserving
957 * the write with journal_access is all we need to do. */ 1073 * the write with journal_access is all we need to do. */
958 status = ocfs2_journal_access(handle, inode, *last_eb_bh, 1074 status = ocfs2_journal_access_eb(handle, inode, *last_eb_bh,
959 OCFS2_JOURNAL_ACCESS_WRITE); 1075 OCFS2_JOURNAL_ACCESS_WRITE);
960 if (status < 0) { 1076 if (status < 0) {
961 mlog_errno(status); 1077 mlog_errno(status);
962 goto bail; 1078 goto bail;
963 } 1079 }
964 status = ocfs2_journal_access(handle, inode, et->et_root_bh, 1080 status = ocfs2_et_root_journal_access(handle, inode, et,
965 OCFS2_JOURNAL_ACCESS_WRITE); 1081 OCFS2_JOURNAL_ACCESS_WRITE);
966 if (status < 0) { 1082 if (status < 0) {
967 mlog_errno(status); 1083 mlog_errno(status);
968 goto bail; 1084 goto bail;
969 } 1085 }
970 if (eb_bh) { 1086 if (eb_bh) {
971 status = ocfs2_journal_access(handle, inode, eb_bh, 1087 status = ocfs2_journal_access_eb(handle, inode, eb_bh,
972 OCFS2_JOURNAL_ACCESS_WRITE); 1088 OCFS2_JOURNAL_ACCESS_WRITE);
973 if (status < 0) { 1089 if (status < 0) {
974 mlog_errno(status); 1090 mlog_errno(status);
975 goto bail; 1091 goto bail;
@@ -1052,17 +1168,14 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
1052 } 1168 }
1053 1169
1054 eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; 1170 eb = (struct ocfs2_extent_block *) new_eb_bh->b_data;
1055 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 1171 /* ocfs2_create_new_meta_bhs() should create it right! */
1056 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); 1172 BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb));
1057 status = -EIO;
1058 goto bail;
1059 }
1060 1173
1061 eb_el = &eb->h_list; 1174 eb_el = &eb->h_list;
1062 root_el = et->et_root_el; 1175 root_el = et->et_root_el;
1063 1176
1064 status = ocfs2_journal_access(handle, inode, new_eb_bh, 1177 status = ocfs2_journal_access_eb(handle, inode, new_eb_bh,
1065 OCFS2_JOURNAL_ACCESS_CREATE); 1178 OCFS2_JOURNAL_ACCESS_CREATE);
1066 if (status < 0) { 1179 if (status < 0) {
1067 mlog_errno(status); 1180 mlog_errno(status);
1068 goto bail; 1181 goto bail;
@@ -1080,8 +1193,8 @@ static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
1080 goto bail; 1193 goto bail;
1081 } 1194 }
1082 1195
1083 status = ocfs2_journal_access(handle, inode, et->et_root_bh, 1196 status = ocfs2_et_root_journal_access(handle, inode, et,
1084 OCFS2_JOURNAL_ACCESS_WRITE); 1197 OCFS2_JOURNAL_ACCESS_WRITE);
1085 if (status < 0) { 1198 if (status < 0) {
1086 mlog_errno(status); 1199 mlog_errno(status);
1087 goto bail; 1200 goto bail;
@@ -1176,18 +1289,13 @@ static int ocfs2_find_branch_target(struct ocfs2_super *osb,
1176 brelse(bh); 1289 brelse(bh);
1177 bh = NULL; 1290 bh = NULL;
1178 1291
1179 status = ocfs2_read_block(inode, blkno, &bh); 1292 status = ocfs2_read_extent_block(inode, blkno, &bh);
1180 if (status < 0) { 1293 if (status < 0) {
1181 mlog_errno(status); 1294 mlog_errno(status);
1182 goto bail; 1295 goto bail;
1183 } 1296 }
1184 1297
1185 eb = (struct ocfs2_extent_block *) bh->b_data; 1298 eb = (struct ocfs2_extent_block *) bh->b_data;
1186 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
1187 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb);
1188 status = -EIO;
1189 goto bail;
1190 }
1191 el = &eb->h_list; 1299 el = &eb->h_list;
1192 1300
1193 if (le16_to_cpu(el->l_next_free_rec) < 1301 if (le16_to_cpu(el->l_next_free_rec) <
@@ -1540,7 +1648,7 @@ static int __ocfs2_find_path(struct inode *inode,
1540 1648
1541 brelse(bh); 1649 brelse(bh);
1542 bh = NULL; 1650 bh = NULL;
1543 ret = ocfs2_read_block(inode, blkno, &bh); 1651 ret = ocfs2_read_extent_block(inode, blkno, &bh);
1544 if (ret) { 1652 if (ret) {
1545 mlog_errno(ret); 1653 mlog_errno(ret);
1546 goto out; 1654 goto out;
@@ -1548,11 +1656,6 @@ static int __ocfs2_find_path(struct inode *inode,
1548 1656
1549 eb = (struct ocfs2_extent_block *) bh->b_data; 1657 eb = (struct ocfs2_extent_block *) bh->b_data;
1550 el = &eb->h_list; 1658 el = &eb->h_list;
1551 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
1552 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb);
1553 ret = -EIO;
1554 goto out;
1555 }
1556 1659
1557 if (le16_to_cpu(el->l_next_free_rec) > 1660 if (le16_to_cpu(el->l_next_free_rec) >
1558 le16_to_cpu(el->l_count)) { 1661 le16_to_cpu(el->l_count)) {
@@ -1860,25 +1963,23 @@ static int ocfs2_rotate_subtree_right(struct inode *inode,
1860 root_bh = left_path->p_node[subtree_index].bh; 1963 root_bh = left_path->p_node[subtree_index].bh;
1861 BUG_ON(root_bh != right_path->p_node[subtree_index].bh); 1964 BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
1862 1965
1863 ret = ocfs2_journal_access(handle, inode, root_bh, 1966 ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
1864 OCFS2_JOURNAL_ACCESS_WRITE); 1967 subtree_index);
1865 if (ret) { 1968 if (ret) {
1866 mlog_errno(ret); 1969 mlog_errno(ret);
1867 goto out; 1970 goto out;
1868 } 1971 }
1869 1972
1870 for(i = subtree_index + 1; i < path_num_items(right_path); i++) { 1973 for(i = subtree_index + 1; i < path_num_items(right_path); i++) {
1871 ret = ocfs2_journal_access(handle, inode, 1974 ret = ocfs2_path_bh_journal_access(handle, inode,
1872 right_path->p_node[i].bh, 1975 right_path, i);
1873 OCFS2_JOURNAL_ACCESS_WRITE);
1874 if (ret) { 1976 if (ret) {
1875 mlog_errno(ret); 1977 mlog_errno(ret);
1876 goto out; 1978 goto out;
1877 } 1979 }
1878 1980
1879 ret = ocfs2_journal_access(handle, inode, 1981 ret = ocfs2_path_bh_journal_access(handle, inode,
1880 left_path->p_node[i].bh, 1982 left_path, i);
1881 OCFS2_JOURNAL_ACCESS_WRITE);
1882 if (ret) { 1983 if (ret) {
1883 mlog_errno(ret); 1984 mlog_errno(ret);
1884 goto out; 1985 goto out;
@@ -2102,8 +2203,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode,
2102 2203
2103 *ret_left_path = NULL; 2204 *ret_left_path = NULL;
2104 2205
2105 left_path = ocfs2_new_path(path_root_bh(right_path), 2206 left_path = ocfs2_new_path_from_path(right_path);
2106 path_root_el(right_path));
2107 if (!left_path) { 2207 if (!left_path) {
2108 ret = -ENOMEM; 2208 ret = -ENOMEM;
2109 mlog_errno(ret); 2209 mlog_errno(ret);
@@ -2398,9 +2498,9 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
2398 return -EAGAIN; 2498 return -EAGAIN;
2399 2499
2400 if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) { 2500 if (le16_to_cpu(right_leaf_el->l_next_free_rec) > 1) {
2401 ret = ocfs2_journal_access(handle, inode, 2501 ret = ocfs2_journal_access_eb(handle, inode,
2402 path_leaf_bh(right_path), 2502 path_leaf_bh(right_path),
2403 OCFS2_JOURNAL_ACCESS_WRITE); 2503 OCFS2_JOURNAL_ACCESS_WRITE);
2404 if (ret) { 2504 if (ret) {
2405 mlog_errno(ret); 2505 mlog_errno(ret);
2406 goto out; 2506 goto out;
@@ -2417,8 +2517,8 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
2417 * We have to update i_last_eb_blk during the meta 2517 * We have to update i_last_eb_blk during the meta
2418 * data delete. 2518 * data delete.
2419 */ 2519 */
2420 ret = ocfs2_journal_access(handle, inode, et_root_bh, 2520 ret = ocfs2_et_root_journal_access(handle, inode, et,
2421 OCFS2_JOURNAL_ACCESS_WRITE); 2521 OCFS2_JOURNAL_ACCESS_WRITE);
2422 if (ret) { 2522 if (ret) {
2423 mlog_errno(ret); 2523 mlog_errno(ret);
2424 goto out; 2524 goto out;
@@ -2433,25 +2533,23 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
2433 */ 2533 */
2434 BUG_ON(right_has_empty && !del_right_subtree); 2534 BUG_ON(right_has_empty && !del_right_subtree);
2435 2535
2436 ret = ocfs2_journal_access(handle, inode, root_bh, 2536 ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
2437 OCFS2_JOURNAL_ACCESS_WRITE); 2537 subtree_index);
2438 if (ret) { 2538 if (ret) {
2439 mlog_errno(ret); 2539 mlog_errno(ret);
2440 goto out; 2540 goto out;
2441 } 2541 }
2442 2542
2443 for(i = subtree_index + 1; i < path_num_items(right_path); i++) { 2543 for(i = subtree_index + 1; i < path_num_items(right_path); i++) {
2444 ret = ocfs2_journal_access(handle, inode, 2544 ret = ocfs2_path_bh_journal_access(handle, inode,
2445 right_path->p_node[i].bh, 2545 right_path, i);
2446 OCFS2_JOURNAL_ACCESS_WRITE);
2447 if (ret) { 2546 if (ret) {
2448 mlog_errno(ret); 2547 mlog_errno(ret);
2449 goto out; 2548 goto out;
2450 } 2549 }
2451 2550
2452 ret = ocfs2_journal_access(handle, inode, 2551 ret = ocfs2_path_bh_journal_access(handle, inode,
2453 left_path->p_node[i].bh, 2552 left_path, i);
2454 OCFS2_JOURNAL_ACCESS_WRITE);
2455 if (ret) { 2553 if (ret) {
2456 mlog_errno(ret); 2554 mlog_errno(ret);
2457 goto out; 2555 goto out;
@@ -2596,16 +2694,17 @@ out:
2596 2694
2597static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode, 2695static int ocfs2_rotate_rightmost_leaf_left(struct inode *inode,
2598 handle_t *handle, 2696 handle_t *handle,
2599 struct buffer_head *bh, 2697 struct ocfs2_path *path)
2600 struct ocfs2_extent_list *el)
2601{ 2698{
2602 int ret; 2699 int ret;
2700 struct buffer_head *bh = path_leaf_bh(path);
2701 struct ocfs2_extent_list *el = path_leaf_el(path);
2603 2702
2604 if (!ocfs2_is_empty_extent(&el->l_recs[0])) 2703 if (!ocfs2_is_empty_extent(&el->l_recs[0]))
2605 return 0; 2704 return 0;
2606 2705
2607 ret = ocfs2_journal_access(handle, inode, bh, 2706 ret = ocfs2_path_bh_journal_access(handle, inode, path,
2608 OCFS2_JOURNAL_ACCESS_WRITE); 2707 path_num_items(path) - 1);
2609 if (ret) { 2708 if (ret) {
2610 mlog_errno(ret); 2709 mlog_errno(ret);
2611 goto out; 2710 goto out;
@@ -2644,8 +2743,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
2644 goto out; 2743 goto out;
2645 } 2744 }
2646 2745
2647 left_path = ocfs2_new_path(path_root_bh(path), 2746 left_path = ocfs2_new_path_from_path(path);
2648 path_root_el(path));
2649 if (!left_path) { 2747 if (!left_path) {
2650 ret = -ENOMEM; 2748 ret = -ENOMEM;
2651 mlog_errno(ret); 2749 mlog_errno(ret);
@@ -2654,8 +2752,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
2654 2752
2655 ocfs2_cp_path(left_path, path); 2753 ocfs2_cp_path(left_path, path);
2656 2754
2657 right_path = ocfs2_new_path(path_root_bh(path), 2755 right_path = ocfs2_new_path_from_path(path);
2658 path_root_el(path));
2659 if (!right_path) { 2756 if (!right_path) {
2660 ret = -ENOMEM; 2757 ret = -ENOMEM;
2661 mlog_errno(ret); 2758 mlog_errno(ret);
@@ -2689,9 +2786,8 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
2689 * Caller might still want to make changes to the 2786 * Caller might still want to make changes to the
2690 * tree root, so re-add it to the journal here. 2787 * tree root, so re-add it to the journal here.
2691 */ 2788 */
2692 ret = ocfs2_journal_access(handle, inode, 2789 ret = ocfs2_path_bh_journal_access(handle, inode,
2693 path_root_bh(left_path), 2790 left_path, 0);
2694 OCFS2_JOURNAL_ACCESS_WRITE);
2695 if (ret) { 2791 if (ret) {
2696 mlog_errno(ret); 2792 mlog_errno(ret);
2697 goto out; 2793 goto out;
@@ -2785,8 +2881,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
2785 * We have a path to the left of this one - it needs 2881 * We have a path to the left of this one - it needs
2786 * an update too. 2882 * an update too.
2787 */ 2883 */
2788 left_path = ocfs2_new_path(path_root_bh(path), 2884 left_path = ocfs2_new_path_from_path(path);
2789 path_root_el(path));
2790 if (!left_path) { 2885 if (!left_path) {
2791 ret = -ENOMEM; 2886 ret = -ENOMEM;
2792 mlog_errno(ret); 2887 mlog_errno(ret);
@@ -2875,8 +2970,7 @@ rightmost_no_delete:
2875 * it up front. 2970 * it up front.
2876 */ 2971 */
2877 ret = ocfs2_rotate_rightmost_leaf_left(inode, handle, 2972 ret = ocfs2_rotate_rightmost_leaf_left(inode, handle,
2878 path_leaf_bh(path), 2973 path);
2879 path_leaf_el(path));
2880 if (ret) 2974 if (ret)
2881 mlog_errno(ret); 2975 mlog_errno(ret);
2882 goto out; 2976 goto out;
@@ -3027,8 +3121,7 @@ static int ocfs2_get_right_path(struct inode *inode,
3027 /* This function shouldn't be called for the rightmost leaf. */ 3121 /* This function shouldn't be called for the rightmost leaf. */
3028 BUG_ON(right_cpos == 0); 3122 BUG_ON(right_cpos == 0);
3029 3123
3030 right_path = ocfs2_new_path(path_root_bh(left_path), 3124 right_path = ocfs2_new_path_from_path(left_path);
3031 path_root_el(left_path));
3032 if (!right_path) { 3125 if (!right_path) {
3033 ret = -ENOMEM; 3126 ret = -ENOMEM;
3034 mlog_errno(ret); 3127 mlog_errno(ret);
@@ -3111,8 +3204,8 @@ static int ocfs2_merge_rec_right(struct inode *inode,
3111 root_bh = left_path->p_node[subtree_index].bh; 3204 root_bh = left_path->p_node[subtree_index].bh;
3112 BUG_ON(root_bh != right_path->p_node[subtree_index].bh); 3205 BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
3113 3206
3114 ret = ocfs2_journal_access(handle, inode, root_bh, 3207 ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
3115 OCFS2_JOURNAL_ACCESS_WRITE); 3208 subtree_index);
3116 if (ret) { 3209 if (ret) {
3117 mlog_errno(ret); 3210 mlog_errno(ret);
3118 goto out; 3211 goto out;
@@ -3120,17 +3213,15 @@ static int ocfs2_merge_rec_right(struct inode *inode,
3120 3213
3121 for (i = subtree_index + 1; 3214 for (i = subtree_index + 1;
3122 i < path_num_items(right_path); i++) { 3215 i < path_num_items(right_path); i++) {
3123 ret = ocfs2_journal_access(handle, inode, 3216 ret = ocfs2_path_bh_journal_access(handle, inode,
3124 right_path->p_node[i].bh, 3217 right_path, i);
3125 OCFS2_JOURNAL_ACCESS_WRITE);
3126 if (ret) { 3218 if (ret) {
3127 mlog_errno(ret); 3219 mlog_errno(ret);
3128 goto out; 3220 goto out;
3129 } 3221 }
3130 3222
3131 ret = ocfs2_journal_access(handle, inode, 3223 ret = ocfs2_path_bh_journal_access(handle, inode,
3132 left_path->p_node[i].bh, 3224 left_path, i);
3133 OCFS2_JOURNAL_ACCESS_WRITE);
3134 if (ret) { 3225 if (ret) {
3135 mlog_errno(ret); 3226 mlog_errno(ret);
3136 goto out; 3227 goto out;
@@ -3142,8 +3233,8 @@ static int ocfs2_merge_rec_right(struct inode *inode,
3142 right_rec = &el->l_recs[index + 1]; 3233 right_rec = &el->l_recs[index + 1];
3143 } 3234 }
3144 3235
3145 ret = ocfs2_journal_access(handle, inode, bh, 3236 ret = ocfs2_path_bh_journal_access(handle, inode, left_path,
3146 OCFS2_JOURNAL_ACCESS_WRITE); 3237 path_num_items(left_path) - 1);
3147 if (ret) { 3238 if (ret) {
3148 mlog_errno(ret); 3239 mlog_errno(ret);
3149 goto out; 3240 goto out;
@@ -3199,8 +3290,7 @@ static int ocfs2_get_left_path(struct inode *inode,
3199 /* This function shouldn't be called for the leftmost leaf. */ 3290 /* This function shouldn't be called for the leftmost leaf. */
3200 BUG_ON(left_cpos == 0); 3291 BUG_ON(left_cpos == 0);
3201 3292
3202 left_path = ocfs2_new_path(path_root_bh(right_path), 3293 left_path = ocfs2_new_path_from_path(right_path);
3203 path_root_el(right_path));
3204 if (!left_path) { 3294 if (!left_path) {
3205 ret = -ENOMEM; 3295 ret = -ENOMEM;
3206 mlog_errno(ret); 3296 mlog_errno(ret);
@@ -3283,8 +3373,8 @@ static int ocfs2_merge_rec_left(struct inode *inode,
3283 root_bh = left_path->p_node[subtree_index].bh; 3373 root_bh = left_path->p_node[subtree_index].bh;
3284 BUG_ON(root_bh != right_path->p_node[subtree_index].bh); 3374 BUG_ON(root_bh != right_path->p_node[subtree_index].bh);
3285 3375
3286 ret = ocfs2_journal_access(handle, inode, root_bh, 3376 ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
3287 OCFS2_JOURNAL_ACCESS_WRITE); 3377 subtree_index);
3288 if (ret) { 3378 if (ret) {
3289 mlog_errno(ret); 3379 mlog_errno(ret);
3290 goto out; 3380 goto out;
@@ -3292,17 +3382,15 @@ static int ocfs2_merge_rec_left(struct inode *inode,
3292 3382
3293 for (i = subtree_index + 1; 3383 for (i = subtree_index + 1;
3294 i < path_num_items(right_path); i++) { 3384 i < path_num_items(right_path); i++) {
3295 ret = ocfs2_journal_access(handle, inode, 3385 ret = ocfs2_path_bh_journal_access(handle, inode,
3296 right_path->p_node[i].bh, 3386 right_path, i);
3297 OCFS2_JOURNAL_ACCESS_WRITE);
3298 if (ret) { 3387 if (ret) {
3299 mlog_errno(ret); 3388 mlog_errno(ret);
3300 goto out; 3389 goto out;
3301 } 3390 }
3302 3391
3303 ret = ocfs2_journal_access(handle, inode, 3392 ret = ocfs2_path_bh_journal_access(handle, inode,
3304 left_path->p_node[i].bh, 3393 left_path, i);
3305 OCFS2_JOURNAL_ACCESS_WRITE);
3306 if (ret) { 3394 if (ret) {
3307 mlog_errno(ret); 3395 mlog_errno(ret);
3308 goto out; 3396 goto out;
@@ -3314,8 +3402,8 @@ static int ocfs2_merge_rec_left(struct inode *inode,
3314 has_empty_extent = 1; 3402 has_empty_extent = 1;
3315 } 3403 }
3316 3404
3317 ret = ocfs2_journal_access(handle, inode, bh, 3405 ret = ocfs2_path_bh_journal_access(handle, inode, right_path,
3318 OCFS2_JOURNAL_ACCESS_WRITE); 3406 path_num_items(right_path) - 1);
3319 if (ret) { 3407 if (ret) {
3320 mlog_errno(ret); 3408 mlog_errno(ret);
3321 goto out; 3409 goto out;
@@ -3732,8 +3820,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle,
3732 * leftmost leaf. 3820 * leftmost leaf.
3733 */ 3821 */
3734 if (left_cpos) { 3822 if (left_cpos) {
3735 left_path = ocfs2_new_path(path_root_bh(right_path), 3823 left_path = ocfs2_new_path_from_path(right_path);
3736 path_root_el(right_path));
3737 if (!left_path) { 3824 if (!left_path) {
3738 ret = -ENOMEM; 3825 ret = -ENOMEM;
3739 mlog_errno(ret); 3826 mlog_errno(ret);
@@ -3958,8 +4045,8 @@ static int ocfs2_do_insert_extent(struct inode *inode,
3958 4045
3959 el = et->et_root_el; 4046 el = et->et_root_el;
3960 4047
3961 ret = ocfs2_journal_access(handle, inode, et->et_root_bh, 4048 ret = ocfs2_et_root_journal_access(handle, inode, et,
3962 OCFS2_JOURNAL_ACCESS_WRITE); 4049 OCFS2_JOURNAL_ACCESS_WRITE);
3963 if (ret) { 4050 if (ret) {
3964 mlog_errno(ret); 4051 mlog_errno(ret);
3965 goto out; 4052 goto out;
@@ -3970,7 +4057,7 @@ static int ocfs2_do_insert_extent(struct inode *inode,
3970 goto out_update_clusters; 4057 goto out_update_clusters;
3971 } 4058 }
3972 4059
3973 right_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); 4060 right_path = ocfs2_new_path_from_et(et);
3974 if (!right_path) { 4061 if (!right_path) {
3975 ret = -ENOMEM; 4062 ret = -ENOMEM;
3976 mlog_errno(ret); 4063 mlog_errno(ret);
@@ -4020,8 +4107,8 @@ static int ocfs2_do_insert_extent(struct inode *inode,
4020 * ocfs2_rotate_tree_right() might have extended the 4107 * ocfs2_rotate_tree_right() might have extended the
4021 * transaction without re-journaling our tree root. 4108 * transaction without re-journaling our tree root.
4022 */ 4109 */
4023 ret = ocfs2_journal_access(handle, inode, et->et_root_bh, 4110 ret = ocfs2_et_root_journal_access(handle, inode, et,
4024 OCFS2_JOURNAL_ACCESS_WRITE); 4111 OCFS2_JOURNAL_ACCESS_WRITE);
4025 if (ret) { 4112 if (ret) {
4026 mlog_errno(ret); 4113 mlog_errno(ret);
4027 goto out; 4114 goto out;
@@ -4082,8 +4169,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
4082 goto out; 4169 goto out;
4083 4170
4084 if (left_cpos != 0) { 4171 if (left_cpos != 0) {
4085 left_path = ocfs2_new_path(path_root_bh(path), 4172 left_path = ocfs2_new_path_from_path(path);
4086 path_root_el(path));
4087 if (!left_path) 4173 if (!left_path)
4088 goto out; 4174 goto out;
4089 4175
@@ -4097,8 +4183,15 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
4097 le16_to_cpu(new_el->l_count)) { 4183 le16_to_cpu(new_el->l_count)) {
4098 bh = path_leaf_bh(left_path); 4184 bh = path_leaf_bh(left_path);
4099 eb = (struct ocfs2_extent_block *)bh->b_data; 4185 eb = (struct ocfs2_extent_block *)bh->b_data;
4100 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, 4186 ocfs2_error(inode->i_sb,
4101 eb); 4187 "Extent block #%llu has an "
4188 "invalid l_next_free_rec of "
4189 "%d. It should have "
4190 "matched the l_count of %d",
4191 (unsigned long long)le64_to_cpu(eb->h_blkno),
4192 le16_to_cpu(new_el->l_next_free_rec),
4193 le16_to_cpu(new_el->l_count));
4194 status = -EINVAL;
4102 goto out; 4195 goto out;
4103 } 4196 }
4104 rec = &new_el->l_recs[ 4197 rec = &new_el->l_recs[
@@ -4132,8 +4225,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
4132 if (right_cpos == 0) 4225 if (right_cpos == 0)
4133 goto out; 4226 goto out;
4134 4227
4135 right_path = ocfs2_new_path(path_root_bh(path), 4228 right_path = ocfs2_new_path_from_path(path);
4136 path_root_el(path));
4137 if (!right_path) 4229 if (!right_path)
4138 goto out; 4230 goto out;
4139 4231
@@ -4147,8 +4239,12 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
4147 if (le16_to_cpu(new_el->l_next_free_rec) <= 1) { 4239 if (le16_to_cpu(new_el->l_next_free_rec) <= 1) {
4148 bh = path_leaf_bh(right_path); 4240 bh = path_leaf_bh(right_path);
4149 eb = (struct ocfs2_extent_block *)bh->b_data; 4241 eb = (struct ocfs2_extent_block *)bh->b_data;
4150 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, 4242 ocfs2_error(inode->i_sb,
4151 eb); 4243 "Extent block #%llu has an "
4244 "invalid l_next_free_rec of %d",
4245 (unsigned long long)le64_to_cpu(eb->h_blkno),
4246 le16_to_cpu(new_el->l_next_free_rec));
4247 status = -EINVAL;
4152 goto out; 4248 goto out;
4153 } 4249 }
4154 rec = &new_el->l_recs[1]; 4250 rec = &new_el->l_recs[1];
@@ -4294,7 +4390,9 @@ static int ocfs2_figure_insert_type(struct inode *inode,
4294 * ocfs2_figure_insert_type() and ocfs2_add_branch() 4390 * ocfs2_figure_insert_type() and ocfs2_add_branch()
4295 * may want it later. 4391 * may want it later.
4296 */ 4392 */
4297 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), &bh); 4393 ret = ocfs2_read_extent_block(inode,
4394 ocfs2_et_get_last_eb_blk(et),
4395 &bh);
4298 if (ret) { 4396 if (ret) {
4299 mlog_exit(ret); 4397 mlog_exit(ret);
4300 goto out; 4398 goto out;
@@ -4320,7 +4418,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
4320 return 0; 4418 return 0;
4321 } 4419 }
4322 4420
4323 path = ocfs2_new_path(et->et_root_bh, et->et_root_el); 4421 path = ocfs2_new_path_from_et(et);
4324 if (!path) { 4422 if (!path) {
4325 ret = -ENOMEM; 4423 ret = -ENOMEM;
4326 mlog_errno(ret); 4424 mlog_errno(ret);
@@ -4531,9 +4629,9 @@ int ocfs2_add_clusters_in_btree(struct ocfs2_super *osb,
4531 4629
4532 BUG_ON(num_bits > clusters_to_add); 4630 BUG_ON(num_bits > clusters_to_add);
4533 4631
4534 /* reserve our write early -- insert_extent may update the inode */ 4632 /* reserve our write early -- insert_extent may update the tree root */
4535 status = ocfs2_journal_access(handle, inode, et->et_root_bh, 4633 status = ocfs2_et_root_journal_access(handle, inode, et,
4536 OCFS2_JOURNAL_ACCESS_WRITE); 4634 OCFS2_JOURNAL_ACCESS_WRITE);
4537 if (status < 0) { 4635 if (status < 0) {
4538 mlog_errno(status); 4636 mlog_errno(status);
4539 goto leave; 4637 goto leave;
@@ -4760,20 +4858,15 @@ static int __ocfs2_mark_extent_written(struct inode *inode,
4760 if (path->p_tree_depth) { 4858 if (path->p_tree_depth) {
4761 struct ocfs2_extent_block *eb; 4859 struct ocfs2_extent_block *eb;
4762 4860
4763 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), 4861 ret = ocfs2_read_extent_block(inode,
4764 &last_eb_bh); 4862 ocfs2_et_get_last_eb_blk(et),
4863 &last_eb_bh);
4765 if (ret) { 4864 if (ret) {
4766 mlog_exit(ret); 4865 mlog_exit(ret);
4767 goto out; 4866 goto out;
4768 } 4867 }
4769 4868
4770 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 4869 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data;
4771 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
4772 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb);
4773 ret = -EROFS;
4774 goto out;
4775 }
4776
4777 rightmost_el = &eb->h_list; 4870 rightmost_el = &eb->h_list;
4778 } else 4871 } else
4779 rightmost_el = path_root_el(path); 4872 rightmost_el = path_root_el(path);
@@ -4854,7 +4947,7 @@ int ocfs2_mark_extent_written(struct inode *inode,
4854 if (et->et_ops == &ocfs2_dinode_et_ops) 4947 if (et->et_ops == &ocfs2_dinode_et_ops)
4855 ocfs2_extent_map_trunc(inode, 0); 4948 ocfs2_extent_map_trunc(inode, 0);
4856 4949
4857 left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); 4950 left_path = ocfs2_new_path_from_et(et);
4858 if (!left_path) { 4951 if (!left_path) {
4859 ret = -ENOMEM; 4952 ret = -ENOMEM;
4860 mlog_errno(ret); 4953 mlog_errno(ret);
@@ -4918,8 +5011,9 @@ static int ocfs2_split_tree(struct inode *inode, struct ocfs2_extent_tree *et,
4918 5011
4919 depth = path->p_tree_depth; 5012 depth = path->p_tree_depth;
4920 if (depth > 0) { 5013 if (depth > 0) {
4921 ret = ocfs2_read_block(inode, ocfs2_et_get_last_eb_blk(et), 5014 ret = ocfs2_read_extent_block(inode,
4922 &last_eb_bh); 5015 ocfs2_et_get_last_eb_blk(et),
5016 &last_eb_bh);
4923 if (ret < 0) { 5017 if (ret < 0) {
4924 mlog_errno(ret); 5018 mlog_errno(ret);
4925 goto out; 5019 goto out;
@@ -5025,8 +5119,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle,
5025 } 5119 }
5026 5120
5027 if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) { 5121 if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) {
5028 left_path = ocfs2_new_path(path_root_bh(path), 5122 left_path = ocfs2_new_path_from_path(path);
5029 path_root_el(path));
5030 if (!left_path) { 5123 if (!left_path) {
5031 ret = -ENOMEM; 5124 ret = -ENOMEM;
5032 mlog_errno(ret); 5125 mlog_errno(ret);
@@ -5135,7 +5228,7 @@ int ocfs2_remove_extent(struct inode *inode,
5135 5228
5136 ocfs2_extent_map_trunc(inode, 0); 5229 ocfs2_extent_map_trunc(inode, 0);
5137 5230
5138 path = ocfs2_new_path(et->et_root_bh, et->et_root_el); 5231 path = ocfs2_new_path_from_et(et);
5139 if (!path) { 5232 if (!path) {
5140 ret = -ENOMEM; 5233 ret = -ENOMEM;
5141 mlog_errno(ret); 5234 mlog_errno(ret);
@@ -5255,6 +5348,78 @@ out:
5255 return ret; 5348 return ret;
5256} 5349}
5257 5350
5351int ocfs2_remove_btree_range(struct inode *inode,
5352 struct ocfs2_extent_tree *et,
5353 u32 cpos, u32 phys_cpos, u32 len,
5354 struct ocfs2_cached_dealloc_ctxt *dealloc)
5355{
5356 int ret;
5357 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
5358 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5359 struct inode *tl_inode = osb->osb_tl_inode;
5360 handle_t *handle;
5361 struct ocfs2_alloc_context *meta_ac = NULL;
5362
5363 ret = ocfs2_lock_allocators(inode, et, 0, 1, NULL, &meta_ac);
5364 if (ret) {
5365 mlog_errno(ret);
5366 return ret;
5367 }
5368
5369 mutex_lock(&tl_inode->i_mutex);
5370
5371 if (ocfs2_truncate_log_needs_flush(osb)) {
5372 ret = __ocfs2_flush_truncate_log(osb);
5373 if (ret < 0) {
5374 mlog_errno(ret);
5375 goto out;
5376 }
5377 }
5378
5379 handle = ocfs2_start_trans(osb, ocfs2_remove_extent_credits(osb->sb));
5380 if (IS_ERR(handle)) {
5381 ret = PTR_ERR(handle);
5382 mlog_errno(ret);
5383 goto out;
5384 }
5385
5386 ret = ocfs2_et_root_journal_access(handle, inode, et,
5387 OCFS2_JOURNAL_ACCESS_WRITE);
5388 if (ret) {
5389 mlog_errno(ret);
5390 goto out;
5391 }
5392
5393 ret = ocfs2_remove_extent(inode, et, cpos, len, handle, meta_ac,
5394 dealloc);
5395 if (ret) {
5396 mlog_errno(ret);
5397 goto out_commit;
5398 }
5399
5400 ocfs2_et_update_clusters(inode, et, -len);
5401
5402 ret = ocfs2_journal_dirty(handle, et->et_root_bh);
5403 if (ret) {
5404 mlog_errno(ret);
5405 goto out_commit;
5406 }
5407
5408 ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len);
5409 if (ret)
5410 mlog_errno(ret);
5411
5412out_commit:
5413 ocfs2_commit_trans(osb, handle);
5414out:
5415 mutex_unlock(&tl_inode->i_mutex);
5416
5417 if (meta_ac)
5418 ocfs2_free_alloc_context(meta_ac);
5419
5420 return ret;
5421}
5422
5258int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) 5423int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb)
5259{ 5424{
5260 struct buffer_head *tl_bh = osb->osb_tl_bh; 5425 struct buffer_head *tl_bh = osb->osb_tl_bh;
@@ -5308,13 +5473,13 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb,
5308 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); 5473 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk);
5309 5474
5310 di = (struct ocfs2_dinode *) tl_bh->b_data; 5475 di = (struct ocfs2_dinode *) tl_bh->b_data;
5311 tl = &di->id2.i_dealloc;
5312 if (!OCFS2_IS_VALID_DINODE(di)) {
5313 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di);
5314 status = -EIO;
5315 goto bail;
5316 }
5317 5476
5477 /* tl_bh is loaded from ocfs2_truncate_log_init(). It's validated
5478 * by the underlying call to ocfs2_read_inode_block(), so any
5479 * corruption is a code bug */
5480 BUG_ON(!OCFS2_IS_VALID_DINODE(di));
5481
5482 tl = &di->id2.i_dealloc;
5318 tl_count = le16_to_cpu(tl->tl_count); 5483 tl_count = le16_to_cpu(tl->tl_count);
5319 mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) || 5484 mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) ||
5320 tl_count == 0, 5485 tl_count == 0,
@@ -5332,8 +5497,8 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb,
5332 goto bail; 5497 goto bail;
5333 } 5498 }
5334 5499
5335 status = ocfs2_journal_access(handle, tl_inode, tl_bh, 5500 status = ocfs2_journal_access_di(handle, tl_inode, tl_bh,
5336 OCFS2_JOURNAL_ACCESS_WRITE); 5501 OCFS2_JOURNAL_ACCESS_WRITE);
5337 if (status < 0) { 5502 if (status < 0) {
5338 mlog_errno(status); 5503 mlog_errno(status);
5339 goto bail; 5504 goto bail;
@@ -5394,8 +5559,8 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
5394 while (i >= 0) { 5559 while (i >= 0) {
5395 /* Caller has given us at least enough credits to 5560 /* Caller has given us at least enough credits to
5396 * update the truncate log dinode */ 5561 * update the truncate log dinode */
5397 status = ocfs2_journal_access(handle, tl_inode, tl_bh, 5562 status = ocfs2_journal_access_di(handle, tl_inode, tl_bh,
5398 OCFS2_JOURNAL_ACCESS_WRITE); 5563 OCFS2_JOURNAL_ACCESS_WRITE);
5399 if (status < 0) { 5564 if (status < 0) {
5400 mlog_errno(status); 5565 mlog_errno(status);
5401 goto bail; 5566 goto bail;
@@ -5464,13 +5629,13 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
5464 BUG_ON(mutex_trylock(&tl_inode->i_mutex)); 5629 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
5465 5630
5466 di = (struct ocfs2_dinode *) tl_bh->b_data; 5631 di = (struct ocfs2_dinode *) tl_bh->b_data;
5467 tl = &di->id2.i_dealloc;
5468 if (!OCFS2_IS_VALID_DINODE(di)) {
5469 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di);
5470 status = -EIO;
5471 goto out;
5472 }
5473 5632
5633 /* tl_bh is loaded from ocfs2_truncate_log_init(). It's validated
5634 * by the underlying call to ocfs2_read_inode_block(), so any
5635 * corruption is a code bug */
5636 BUG_ON(!OCFS2_IS_VALID_DINODE(di));
5637
5638 tl = &di->id2.i_dealloc;
5474 num_to_flush = le16_to_cpu(tl->tl_used); 5639 num_to_flush = le16_to_cpu(tl->tl_used);
5475 mlog(0, "Flush %u records from truncate log #%llu\n", 5640 mlog(0, "Flush %u records from truncate log #%llu\n",
5476 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); 5641 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno);
@@ -5586,7 +5751,7 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb,
5586 goto bail; 5751 goto bail;
5587 } 5752 }
5588 5753
5589 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); 5754 status = ocfs2_read_inode_block(inode, &bh);
5590 if (status < 0) { 5755 if (status < 0) {
5591 iput(inode); 5756 iput(inode);
5592 mlog_errno(status); 5757 mlog_errno(status);
@@ -5625,13 +5790,13 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
5625 } 5790 }
5626 5791
5627 di = (struct ocfs2_dinode *) tl_bh->b_data; 5792 di = (struct ocfs2_dinode *) tl_bh->b_data;
5628 tl = &di->id2.i_dealloc;
5629 if (!OCFS2_IS_VALID_DINODE(di)) {
5630 OCFS2_RO_ON_INVALID_DINODE(tl_inode->i_sb, di);
5631 status = -EIO;
5632 goto bail;
5633 }
5634 5793
5794 /* tl_bh is loaded from ocfs2_get_truncate_log_info(). It's
5795 * validated by the underlying call to ocfs2_read_inode_block(),
5796 * so any corruption is a code bug */
5797 BUG_ON(!OCFS2_IS_VALID_DINODE(di));
5798
5799 tl = &di->id2.i_dealloc;
5635 if (le16_to_cpu(tl->tl_used)) { 5800 if (le16_to_cpu(tl->tl_used)) {
5636 mlog(0, "We'll have %u logs to recover\n", 5801 mlog(0, "We'll have %u logs to recover\n",
5637 le16_to_cpu(tl->tl_used)); 5802 le16_to_cpu(tl->tl_used));
@@ -5651,6 +5816,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb,
5651 * tl_used. */ 5816 * tl_used. */
5652 tl->tl_used = 0; 5817 tl->tl_used = 0;
5653 5818
5819 ocfs2_compute_meta_ecc(osb->sb, tl_bh->b_data, &di->i_check);
5654 status = ocfs2_write_block(osb, tl_bh, tl_inode); 5820 status = ocfs2_write_block(osb, tl_bh, tl_inode);
5655 if (status < 0) { 5821 if (status < 0) {
5656 mlog_errno(status); 5822 mlog_errno(status);
@@ -5800,7 +5966,10 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb)
5800 */ 5966 */
5801 5967
5802/* 5968/*
5803 * Describes a single block free from a suballocator 5969 * Describe a single bit freed from a suballocator. For the block
5970 * suballocators, it represents one block. For the global cluster
5971 * allocator, it represents some clusters and free_bit indicates
5972 * clusters number.
5804 */ 5973 */
5805struct ocfs2_cached_block_free { 5974struct ocfs2_cached_block_free {
5806 struct ocfs2_cached_block_free *free_next; 5975 struct ocfs2_cached_block_free *free_next;
@@ -5815,10 +5984,10 @@ struct ocfs2_per_slot_free_list {
5815 struct ocfs2_cached_block_free *f_first; 5984 struct ocfs2_cached_block_free *f_first;
5816}; 5985};
5817 5986
5818static int ocfs2_free_cached_items(struct ocfs2_super *osb, 5987static int ocfs2_free_cached_blocks(struct ocfs2_super *osb,
5819 int sysfile_type, 5988 int sysfile_type,
5820 int slot, 5989 int slot,
5821 struct ocfs2_cached_block_free *head) 5990 struct ocfs2_cached_block_free *head)
5822{ 5991{
5823 int ret; 5992 int ret;
5824 u64 bg_blkno; 5993 u64 bg_blkno;
@@ -5893,6 +6062,82 @@ out:
5893 return ret; 6062 return ret;
5894} 6063}
5895 6064
6065int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
6066 u64 blkno, unsigned int bit)
6067{
6068 int ret = 0;
6069 struct ocfs2_cached_block_free *item;
6070
6071 item = kmalloc(sizeof(*item), GFP_NOFS);
6072 if (item == NULL) {
6073 ret = -ENOMEM;
6074 mlog_errno(ret);
6075 return ret;
6076 }
6077
6078 mlog(0, "Insert clusters: (bit %u, blk %llu)\n",
6079 bit, (unsigned long long)blkno);
6080
6081 item->free_blk = blkno;
6082 item->free_bit = bit;
6083 item->free_next = ctxt->c_global_allocator;
6084
6085 ctxt->c_global_allocator = item;
6086 return ret;
6087}
6088
6089static int ocfs2_free_cached_clusters(struct ocfs2_super *osb,
6090 struct ocfs2_cached_block_free *head)
6091{
6092 struct ocfs2_cached_block_free *tmp;
6093 struct inode *tl_inode = osb->osb_tl_inode;
6094 handle_t *handle;
6095 int ret = 0;
6096
6097 mutex_lock(&tl_inode->i_mutex);
6098
6099 while (head) {
6100 if (ocfs2_truncate_log_needs_flush(osb)) {
6101 ret = __ocfs2_flush_truncate_log(osb);
6102 if (ret < 0) {
6103 mlog_errno(ret);
6104 break;
6105 }
6106 }
6107
6108 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
6109 if (IS_ERR(handle)) {
6110 ret = PTR_ERR(handle);
6111 mlog_errno(ret);
6112 break;
6113 }
6114
6115 ret = ocfs2_truncate_log_append(osb, handle, head->free_blk,
6116 head->free_bit);
6117
6118 ocfs2_commit_trans(osb, handle);
6119 tmp = head;
6120 head = head->free_next;
6121 kfree(tmp);
6122
6123 if (ret < 0) {
6124 mlog_errno(ret);
6125 break;
6126 }
6127 }
6128
6129 mutex_unlock(&tl_inode->i_mutex);
6130
6131 while (head) {
6132 /* Premature exit may have left some dangling items. */
6133 tmp = head;
6134 head = head->free_next;
6135 kfree(tmp);
6136 }
6137
6138 return ret;
6139}
6140
5896int ocfs2_run_deallocs(struct ocfs2_super *osb, 6141int ocfs2_run_deallocs(struct ocfs2_super *osb,
5897 struct ocfs2_cached_dealloc_ctxt *ctxt) 6142 struct ocfs2_cached_dealloc_ctxt *ctxt)
5898{ 6143{
@@ -5908,8 +6153,10 @@ int ocfs2_run_deallocs(struct ocfs2_super *osb,
5908 if (fl->f_first) { 6153 if (fl->f_first) {
5909 mlog(0, "Free items: (type %u, slot %d)\n", 6154 mlog(0, "Free items: (type %u, slot %d)\n",
5910 fl->f_inode_type, fl->f_slot); 6155 fl->f_inode_type, fl->f_slot);
5911 ret2 = ocfs2_free_cached_items(osb, fl->f_inode_type, 6156 ret2 = ocfs2_free_cached_blocks(osb,
5912 fl->f_slot, fl->f_first); 6157 fl->f_inode_type,
6158 fl->f_slot,
6159 fl->f_first);
5913 if (ret2) 6160 if (ret2)
5914 mlog_errno(ret2); 6161 mlog_errno(ret2);
5915 if (!ret) 6162 if (!ret)
@@ -5920,6 +6167,17 @@ int ocfs2_run_deallocs(struct ocfs2_super *osb,
5920 kfree(fl); 6167 kfree(fl);
5921 } 6168 }
5922 6169
6170 if (ctxt->c_global_allocator) {
6171 ret2 = ocfs2_free_cached_clusters(osb,
6172 ctxt->c_global_allocator);
6173 if (ret2)
6174 mlog_errno(ret2);
6175 if (!ret)
6176 ret = ret2;
6177
6178 ctxt->c_global_allocator = NULL;
6179 }
6180
5923 return ret; 6181 return ret;
5924} 6182}
5925 6183
@@ -6075,11 +6333,10 @@ static int ocfs2_find_new_last_ext_blk(struct inode *inode,
6075 6333
6076 eb = (struct ocfs2_extent_block *) bh->b_data; 6334 eb = (struct ocfs2_extent_block *) bh->b_data;
6077 el = &eb->h_list; 6335 el = &eb->h_list;
6078 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { 6336
6079 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); 6337 /* ocfs2_find_leaf() gets the eb from ocfs2_read_extent_block().
6080 ret = -EROFS; 6338 * Any corruption is a code bug. */
6081 goto out; 6339 BUG_ON(!OCFS2_IS_VALID_EXTENT_BLOCK(eb));
6082 }
6083 6340
6084 *new_last_eb = bh; 6341 *new_last_eb = bh;
6085 get_bh(*new_last_eb); 6342 get_bh(*new_last_eb);
@@ -6326,8 +6583,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
6326 } 6583 }
6327 6584
6328 if (last_eb_bh) { 6585 if (last_eb_bh) {
6329 status = ocfs2_journal_access(handle, inode, last_eb_bh, 6586 status = ocfs2_journal_access_eb(handle, inode, last_eb_bh,
6330 OCFS2_JOURNAL_ACCESS_WRITE); 6587 OCFS2_JOURNAL_ACCESS_WRITE);
6331 if (status < 0) { 6588 if (status < 0) {
6332 mlog_errno(status); 6589 mlog_errno(status);
6333 goto bail; 6590 goto bail;
@@ -6350,6 +6607,8 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
6350 goto bail; 6607 goto bail;
6351 } 6608 }
6352 6609
6610 vfs_dq_free_space_nodirty(inode,
6611 ocfs2_clusters_to_bytes(osb->sb, clusters_to_del));
6353 spin_lock(&OCFS2_I(inode)->ip_lock); 6612 spin_lock(&OCFS2_I(inode)->ip_lock);
6354 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - 6613 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) -
6355 clusters_to_del; 6614 clusters_to_del;
@@ -6436,11 +6695,6 @@ static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
6436 mlog_errno(ret); 6695 mlog_errno(ret);
6437 else if (ocfs2_should_order_data(inode)) { 6696 else if (ocfs2_should_order_data(inode)) {
6438 ret = ocfs2_jbd2_file_inode(handle, inode); 6697 ret = ocfs2_jbd2_file_inode(handle, inode);
6439#ifdef CONFIG_OCFS2_COMPAT_JBD
6440 ret = walk_page_buffers(handle, page_buffers(page),
6441 from, to, &partial,
6442 ocfs2_journal_dirty_data);
6443#endif
6444 if (ret < 0) 6698 if (ret < 0)
6445 mlog_errno(ret); 6699 mlog_errno(ret);
6446 } 6700 }
@@ -6663,6 +6917,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6663 struct page **pages = NULL; 6917 struct page **pages = NULL;
6664 loff_t end = osb->s_clustersize; 6918 loff_t end = osb->s_clustersize;
6665 struct ocfs2_extent_tree et; 6919 struct ocfs2_extent_tree et;
6920 int did_quota = 0;
6666 6921
6667 has_data = i_size_read(inode) ? 1 : 0; 6922 has_data = i_size_read(inode) ? 1 : 0;
6668 6923
@@ -6682,15 +6937,16 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6682 } 6937 }
6683 } 6938 }
6684 6939
6685 handle = ocfs2_start_trans(osb, OCFS2_INLINE_TO_EXTENTS_CREDITS); 6940 handle = ocfs2_start_trans(osb,
6941 ocfs2_inline_to_extents_credits(osb->sb));
6686 if (IS_ERR(handle)) { 6942 if (IS_ERR(handle)) {
6687 ret = PTR_ERR(handle); 6943 ret = PTR_ERR(handle);
6688 mlog_errno(ret); 6944 mlog_errno(ret);
6689 goto out_unlock; 6945 goto out_unlock;
6690 } 6946 }
6691 6947
6692 ret = ocfs2_journal_access(handle, inode, di_bh, 6948 ret = ocfs2_journal_access_di(handle, inode, di_bh,
6693 OCFS2_JOURNAL_ACCESS_WRITE); 6949 OCFS2_JOURNAL_ACCESS_WRITE);
6694 if (ret) { 6950 if (ret) {
6695 mlog_errno(ret); 6951 mlog_errno(ret);
6696 goto out_commit; 6952 goto out_commit;
@@ -6701,6 +6957,13 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6701 unsigned int page_end; 6957 unsigned int page_end;
6702 u64 phys; 6958 u64 phys;
6703 6959
6960 if (vfs_dq_alloc_space_nodirty(inode,
6961 ocfs2_clusters_to_bytes(osb->sb, 1))) {
6962 ret = -EDQUOT;
6963 goto out_commit;
6964 }
6965 did_quota = 1;
6966
6704 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, 6967 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
6705 &num); 6968 &num);
6706 if (ret) { 6969 if (ret) {
@@ -6774,6 +7037,10 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode,
6774 } 7037 }
6775 7038
6776out_commit: 7039out_commit:
7040 if (ret < 0 && did_quota)
7041 vfs_dq_free_space_nodirty(inode,
7042 ocfs2_clusters_to_bytes(osb->sb, 1));
7043
6777 ocfs2_commit_trans(osb, handle); 7044 ocfs2_commit_trans(osb, handle);
6778 7045
6779out_unlock: 7046out_unlock:
@@ -6813,7 +7080,8 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
6813 new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb, 7080 new_highest_cpos = ocfs2_clusters_for_bytes(osb->sb,
6814 i_size_read(inode)); 7081 i_size_read(inode));
6815 7082
6816 path = ocfs2_new_path(fe_bh, &di->id2.i_list); 7083 path = ocfs2_new_path(fe_bh, &di->id2.i_list,
7084 ocfs2_journal_access_di);
6817 if (!path) { 7085 if (!path) {
6818 status = -ENOMEM; 7086 status = -ENOMEM;
6819 mlog_errno(status); 7087 mlog_errno(status);
@@ -6984,20 +7252,14 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
6984 ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc); 7252 ocfs2_init_dealloc_ctxt(&(*tc)->tc_dealloc);
6985 7253
6986 if (fe->id2.i_list.l_tree_depth) { 7254 if (fe->id2.i_list.l_tree_depth) {
6987 status = ocfs2_read_block(inode, le64_to_cpu(fe->i_last_eb_blk), 7255 status = ocfs2_read_extent_block(inode,
6988 &last_eb_bh); 7256 le64_to_cpu(fe->i_last_eb_blk),
7257 &last_eb_bh);
6989 if (status < 0) { 7258 if (status < 0) {
6990 mlog_errno(status); 7259 mlog_errno(status);
6991 goto bail; 7260 goto bail;
6992 } 7261 }
6993 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; 7262 eb = (struct ocfs2_extent_block *) last_eb_bh->b_data;
6994 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
6995 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb);
6996
6997 brelse(last_eb_bh);
6998 status = -EIO;
6999 goto bail;
7000 }
7001 } 7263 }
7002 7264
7003 (*tc)->tc_last_eb_bh = last_eb_bh; 7265 (*tc)->tc_last_eb_bh = last_eb_bh;
@@ -7052,8 +7314,8 @@ int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
7052 goto out; 7314 goto out;
7053 } 7315 }
7054 7316
7055 ret = ocfs2_journal_access(handle, inode, di_bh, 7317 ret = ocfs2_journal_access_di(handle, inode, di_bh,
7056 OCFS2_JOURNAL_ACCESS_WRITE); 7318 OCFS2_JOURNAL_ACCESS_WRITE);
7057 if (ret) { 7319 if (ret) {
7058 mlog_errno(ret); 7320 mlog_errno(ret);
7059 goto out_commit; 7321 goto out_commit;
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
index 70257c84cfbe..cceff5c37f47 100644
--- a/fs/ocfs2/alloc.h
+++ b/fs/ocfs2/alloc.h
@@ -45,7 +45,9 @@
45 * 45 *
46 * ocfs2_extent_tree contains info for the root of the b-tree, it must have a 46 * ocfs2_extent_tree contains info for the root of the b-tree, it must have a
47 * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree 47 * root ocfs2_extent_list and a root_bh so that they can be used in the b-tree
48 * functions. 48 * functions. With metadata ecc, we now call different journal_access
49 * functions for each type of metadata, so it must have the
50 * root_journal_access function.
49 * ocfs2_extent_tree_operations abstract the normal operations we do for 51 * ocfs2_extent_tree_operations abstract the normal operations we do for
50 * the root of extent b-tree. 52 * the root of extent b-tree.
51 */ 53 */
@@ -54,6 +56,7 @@ struct ocfs2_extent_tree {
54 struct ocfs2_extent_tree_operations *et_ops; 56 struct ocfs2_extent_tree_operations *et_ops;
55 struct buffer_head *et_root_bh; 57 struct buffer_head *et_root_bh;
56 struct ocfs2_extent_list *et_root_el; 58 struct ocfs2_extent_list *et_root_el;
59 ocfs2_journal_access_func et_root_journal_access;
57 void *et_object; 60 void *et_object;
58 unsigned int et_max_leaf_clusters; 61 unsigned int et_max_leaf_clusters;
59}; 62};
@@ -68,10 +71,18 @@ void ocfs2_init_dinode_extent_tree(struct ocfs2_extent_tree *et,
68void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et, 71void ocfs2_init_xattr_tree_extent_tree(struct ocfs2_extent_tree *et,
69 struct inode *inode, 72 struct inode *inode,
70 struct buffer_head *bh); 73 struct buffer_head *bh);
74struct ocfs2_xattr_value_buf;
71void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et, 75void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
72 struct inode *inode, 76 struct inode *inode,
73 struct buffer_head *bh, 77 struct ocfs2_xattr_value_buf *vb);
74 struct ocfs2_xattr_value_root *xv); 78
79/*
80 * Read an extent block into *bh. If *bh is NULL, a bh will be
81 * allocated. This is a cached read. The extent block will be validated
82 * with ocfs2_validate_extent_block().
83 */
84int ocfs2_read_extent_block(struct inode *inode, u64 eb_blkno,
85 struct buffer_head **bh);
75 86
76struct ocfs2_alloc_context; 87struct ocfs2_alloc_context;
77int ocfs2_insert_extent(struct ocfs2_super *osb, 88int ocfs2_insert_extent(struct ocfs2_super *osb,
@@ -110,6 +121,11 @@ int ocfs2_remove_extent(struct inode *inode,
110 u32 cpos, u32 len, handle_t *handle, 121 u32 cpos, u32 len, handle_t *handle,
111 struct ocfs2_alloc_context *meta_ac, 122 struct ocfs2_alloc_context *meta_ac,
112 struct ocfs2_cached_dealloc_ctxt *dealloc); 123 struct ocfs2_cached_dealloc_ctxt *dealloc);
124int ocfs2_remove_btree_range(struct inode *inode,
125 struct ocfs2_extent_tree *et,
126 u32 cpos, u32 phys_cpos, u32 len,
127 struct ocfs2_cached_dealloc_ctxt *dealloc);
128
113int ocfs2_num_free_extents(struct ocfs2_super *osb, 129int ocfs2_num_free_extents(struct ocfs2_super *osb,
114 struct inode *inode, 130 struct inode *inode,
115 struct ocfs2_extent_tree *et); 131 struct ocfs2_extent_tree *et);
@@ -167,10 +183,18 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb);
167 */ 183 */
168struct ocfs2_cached_dealloc_ctxt { 184struct ocfs2_cached_dealloc_ctxt {
169 struct ocfs2_per_slot_free_list *c_first_suballocator; 185 struct ocfs2_per_slot_free_list *c_first_suballocator;
186 struct ocfs2_cached_block_free *c_global_allocator;
170}; 187};
171static inline void ocfs2_init_dealloc_ctxt(struct ocfs2_cached_dealloc_ctxt *c) 188static inline void ocfs2_init_dealloc_ctxt(struct ocfs2_cached_dealloc_ctxt *c)
172{ 189{
173 c->c_first_suballocator = NULL; 190 c->c_first_suballocator = NULL;
191 c->c_global_allocator = NULL;
192}
193int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
194 u64 blkno, unsigned int bit);
195static inline int ocfs2_dealloc_has_cluster(struct ocfs2_cached_dealloc_ctxt *c)
196{
197 return c->c_global_allocator != NULL;
174} 198}
175int ocfs2_run_deallocs(struct ocfs2_super *osb, 199int ocfs2_run_deallocs(struct ocfs2_super *osb,
176 struct ocfs2_cached_dealloc_ctxt *ctxt); 200 struct ocfs2_cached_dealloc_ctxt *ctxt);
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index c22543b33420..a067a6cffb01 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -27,6 +27,7 @@
27#include <linux/swap.h> 27#include <linux/swap.h>
28#include <linux/pipe_fs_i.h> 28#include <linux/pipe_fs_i.h>
29#include <linux/mpage.h> 29#include <linux/mpage.h>
30#include <linux/quotaops.h>
30 31
31#define MLOG_MASK_PREFIX ML_FILE_IO 32#define MLOG_MASK_PREFIX ML_FILE_IO
32#include <cluster/masklog.h> 33#include <cluster/masklog.h>
@@ -68,20 +69,13 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
68 goto bail; 69 goto bail;
69 } 70 }
70 71
71 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); 72 status = ocfs2_read_inode_block(inode, &bh);
72 if (status < 0) { 73 if (status < 0) {
73 mlog_errno(status); 74 mlog_errno(status);
74 goto bail; 75 goto bail;
75 } 76 }
76 fe = (struct ocfs2_dinode *) bh->b_data; 77 fe = (struct ocfs2_dinode *) bh->b_data;
77 78
78 if (!OCFS2_IS_VALID_DINODE(fe)) {
79 mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
80 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
81 fe->i_signature);
82 goto bail;
83 }
84
85 if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb, 79 if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb,
86 le32_to_cpu(fe->i_clusters))) { 80 le32_to_cpu(fe->i_clusters))) {
87 mlog(ML_ERROR, "block offset is outside the allocated size: " 81 mlog(ML_ERROR, "block offset is outside the allocated size: "
@@ -262,7 +256,7 @@ static int ocfs2_readpage_inline(struct inode *inode, struct page *page)
262 BUG_ON(!PageLocked(page)); 256 BUG_ON(!PageLocked(page));
263 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); 257 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL));
264 258
265 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); 259 ret = ocfs2_read_inode_block(inode, &di_bh);
266 if (ret) { 260 if (ret) {
267 mlog_errno(ret); 261 mlog_errno(ret);
268 goto out; 262 goto out;
@@ -481,12 +475,6 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
481 475
482 if (ocfs2_should_order_data(inode)) { 476 if (ocfs2_should_order_data(inode)) {
483 ret = ocfs2_jbd2_file_inode(handle, inode); 477 ret = ocfs2_jbd2_file_inode(handle, inode);
484#ifdef CONFIG_OCFS2_COMPAT_JBD
485 ret = walk_page_buffers(handle,
486 page_buffers(page),
487 from, to, NULL,
488 ocfs2_journal_dirty_data);
489#endif
490 if (ret < 0) 478 if (ret < 0)
491 mlog_errno(ret); 479 mlog_errno(ret);
492 } 480 }
@@ -1072,15 +1060,8 @@ static void ocfs2_write_failure(struct inode *inode,
1072 tmppage = wc->w_pages[i]; 1060 tmppage = wc->w_pages[i];
1073 1061
1074 if (page_has_buffers(tmppage)) { 1062 if (page_has_buffers(tmppage)) {
1075 if (ocfs2_should_order_data(inode)) { 1063 if (ocfs2_should_order_data(inode))
1076 ocfs2_jbd2_file_inode(wc->w_handle, inode); 1064 ocfs2_jbd2_file_inode(wc->w_handle, inode);
1077#ifdef CONFIG_OCFS2_COMPAT_JBD
1078 walk_page_buffers(wc->w_handle,
1079 page_buffers(tmppage),
1080 from, to, NULL,
1081 ocfs2_journal_dirty_data);
1082#endif
1083 }
1084 1065
1085 block_commit_write(tmppage, from, to); 1066 block_commit_write(tmppage, from, to);
1086 } 1067 }
@@ -1531,8 +1512,8 @@ static int ocfs2_write_begin_inline(struct address_space *mapping,
1531 goto out; 1512 goto out;
1532 } 1513 }
1533 1514
1534 ret = ocfs2_journal_access(handle, inode, wc->w_di_bh, 1515 ret = ocfs2_journal_access_di(handle, inode, wc->w_di_bh,
1535 OCFS2_JOURNAL_ACCESS_WRITE); 1516 OCFS2_JOURNAL_ACCESS_WRITE);
1536 if (ret) { 1517 if (ret) {
1537 ocfs2_commit_trans(osb, handle); 1518 ocfs2_commit_trans(osb, handle);
1538 1519
@@ -1750,15 +1731,20 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1750 1731
1751 wc->w_handle = handle; 1732 wc->w_handle = handle;
1752 1733
1734 if (clusters_to_alloc && vfs_dq_alloc_space_nodirty(inode,
1735 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc))) {
1736 ret = -EDQUOT;
1737 goto out_commit;
1738 }
1753 /* 1739 /*
1754 * We don't want this to fail in ocfs2_write_end(), so do it 1740 * We don't want this to fail in ocfs2_write_end(), so do it
1755 * here. 1741 * here.
1756 */ 1742 */
1757 ret = ocfs2_journal_access(handle, inode, wc->w_di_bh, 1743 ret = ocfs2_journal_access_di(handle, inode, wc->w_di_bh,
1758 OCFS2_JOURNAL_ACCESS_WRITE); 1744 OCFS2_JOURNAL_ACCESS_WRITE);
1759 if (ret) { 1745 if (ret) {
1760 mlog_errno(ret); 1746 mlog_errno(ret);
1761 goto out_commit; 1747 goto out_quota;
1762 } 1748 }
1763 1749
1764 /* 1750 /*
@@ -1771,14 +1757,14 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1771 mmap_page); 1757 mmap_page);
1772 if (ret) { 1758 if (ret) {
1773 mlog_errno(ret); 1759 mlog_errno(ret);
1774 goto out_commit; 1760 goto out_quota;
1775 } 1761 }
1776 1762
1777 ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, 1763 ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos,
1778 len); 1764 len);
1779 if (ret) { 1765 if (ret) {
1780 mlog_errno(ret); 1766 mlog_errno(ret);
1781 goto out_commit; 1767 goto out_quota;
1782 } 1768 }
1783 1769
1784 if (data_ac) 1770 if (data_ac)
@@ -1790,6 +1776,10 @@ success:
1790 *pagep = wc->w_target_page; 1776 *pagep = wc->w_target_page;
1791 *fsdata = wc; 1777 *fsdata = wc;
1792 return 0; 1778 return 0;
1779out_quota:
1780 if (clusters_to_alloc)
1781 vfs_dq_free_space(inode,
1782 ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc));
1793out_commit: 1783out_commit:
1794 ocfs2_commit_trans(osb, handle); 1784 ocfs2_commit_trans(osb, handle);
1795 1785
@@ -1919,15 +1909,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
1919 } 1909 }
1920 1910
1921 if (page_has_buffers(tmppage)) { 1911 if (page_has_buffers(tmppage)) {
1922 if (ocfs2_should_order_data(inode)) { 1912 if (ocfs2_should_order_data(inode))
1923 ocfs2_jbd2_file_inode(wc->w_handle, inode); 1913 ocfs2_jbd2_file_inode(wc->w_handle, inode);
1924#ifdef CONFIG_OCFS2_COMPAT_JBD
1925 walk_page_buffers(wc->w_handle,
1926 page_buffers(tmppage),
1927 from, to, NULL,
1928 ocfs2_journal_dirty_data);
1929#endif
1930 }
1931 block_commit_write(tmppage, from, to); 1914 block_commit_write(tmppage, from, to);
1932 } 1915 }
1933 } 1916 }
diff --git a/fs/ocfs2/blockcheck.c b/fs/ocfs2/blockcheck.c
new file mode 100644
index 000000000000..2a947c44e594
--- /dev/null
+++ b/fs/ocfs2/blockcheck.c
@@ -0,0 +1,477 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * blockcheck.c
5 *
6 * Checksum and ECC codes for the OCFS2 userspace library.
7 *
8 * Copyright (C) 2006, 2008 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License, version 2, 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
20#include <linux/kernel.h>
21#include <linux/types.h>
22#include <linux/crc32.h>
23#include <linux/buffer_head.h>
24#include <linux/bitops.h>
25#include <asm/byteorder.h>
26
27#include <cluster/masklog.h>
28
29#include "ocfs2.h"
30
31#include "blockcheck.h"
32
33
34/*
35 * We use the following conventions:
36 *
37 * d = # data bits
38 * p = # parity bits
39 * c = # total code bits (d + p)
40 */
41
42
43/*
44 * Calculate the bit offset in the hamming code buffer based on the bit's
45 * offset in the data buffer. Since the hamming code reserves all
46 * power-of-two bits for parity, the data bit number and the code bit
47 * number are offest by all the parity bits beforehand.
48 *
49 * Recall that bit numbers in hamming code are 1-based. This function
50 * takes the 0-based data bit from the caller.
51 *
52 * An example. Take bit 1 of the data buffer. 1 is a power of two (2^0),
53 * so it's a parity bit. 2 is a power of two (2^1), so it's a parity bit.
54 * 3 is not a power of two. So bit 1 of the data buffer ends up as bit 3
55 * in the code buffer.
56 *
57 * The caller can pass in *p if it wants to keep track of the most recent
58 * number of parity bits added. This allows the function to start the
59 * calculation at the last place.
60 */
61static unsigned int calc_code_bit(unsigned int i, unsigned int *p_cache)
62{
63 unsigned int b, p = 0;
64
65 /*
66 * Data bits are 0-based, but we're talking code bits, which
67 * are 1-based.
68 */
69 b = i + 1;
70
71 /* Use the cache if it is there */
72 if (p_cache)
73 p = *p_cache;
74 b += p;
75
76 /*
77 * For every power of two below our bit number, bump our bit.
78 *
79 * We compare with (b + 1) because we have to compare with what b
80 * would be _if_ it were bumped up by the parity bit. Capice?
81 *
82 * p is set above.
83 */
84 for (; (1 << p) < (b + 1); p++)
85 b++;
86
87 if (p_cache)
88 *p_cache = p;
89
90 return b;
91}
92
93/*
94 * This is the low level encoder function. It can be called across
95 * multiple hunks just like the crc32 code. 'd' is the number of bits
96 * _in_this_hunk_. nr is the bit offset of this hunk. So, if you had
97 * two 512B buffers, you would do it like so:
98 *
99 * parity = ocfs2_hamming_encode(0, buf1, 512 * 8, 0);
100 * parity = ocfs2_hamming_encode(parity, buf2, 512 * 8, 512 * 8);
101 *
102 * If you just have one buffer, use ocfs2_hamming_encode_block().
103 */
104u32 ocfs2_hamming_encode(u32 parity, void *data, unsigned int d, unsigned int nr)
105{
106 unsigned int i, b, p = 0;
107
108 BUG_ON(!d);
109
110 /*
111 * b is the hamming code bit number. Hamming code specifies a
112 * 1-based array, but C uses 0-based. So 'i' is for C, and 'b' is
113 * for the algorithm.
114 *
115 * The i++ in the for loop is so that the start offset passed
116 * to ocfs2_find_next_bit_set() is one greater than the previously
117 * found bit.
118 */
119 for (i = 0; (i = ocfs2_find_next_bit(data, d, i)) < d; i++)
120 {
121 /*
122 * i is the offset in this hunk, nr + i is the total bit
123 * offset.
124 */
125 b = calc_code_bit(nr + i, &p);
126
127 /*
128 * Data bits in the resultant code are checked by
129 * parity bits that are part of the bit number
130 * representation. Huh?
131 *
132 * <wikipedia href="http://en.wikipedia.org/wiki/Hamming_code">
133 * In other words, the parity bit at position 2^k
134 * checks bits in positions having bit k set in
135 * their binary representation. Conversely, for
136 * instance, bit 13, i.e. 1101(2), is checked by
137 * bits 1000(2) = 8, 0100(2)=4 and 0001(2) = 1.
138 * </wikipedia>
139 *
140 * Note that 'k' is the _code_ bit number. 'b' in
141 * our loop.
142 */
143 parity ^= b;
144 }
145
146 /* While the data buffer was treated as little endian, the
147 * return value is in host endian. */
148 return parity;
149}
150
151u32 ocfs2_hamming_encode_block(void *data, unsigned int blocksize)
152{
153 return ocfs2_hamming_encode(0, data, blocksize * 8, 0);
154}
155
156/*
157 * Like ocfs2_hamming_encode(), this can handle hunks. nr is the bit
158 * offset of the current hunk. If bit to be fixed is not part of the
159 * current hunk, this does nothing.
160 *
161 * If you only have one hunk, use ocfs2_hamming_fix_block().
162 */
163void ocfs2_hamming_fix(void *data, unsigned int d, unsigned int nr,
164 unsigned int fix)
165{
166 unsigned int i, b;
167
168 BUG_ON(!d);
169
170 /*
171 * If the bit to fix has an hweight of 1, it's a parity bit. One
172 * busted parity bit is its own error. Nothing to do here.
173 */
174 if (hweight32(fix) == 1)
175 return;
176
177 /*
178 * nr + d is the bit right past the data hunk we're looking at.
179 * If fix after that, nothing to do
180 */
181 if (fix >= calc_code_bit(nr + d, NULL))
182 return;
183
184 /*
185 * nr is the offset in the data hunk we're starting at. Let's
186 * start b at the offset in the code buffer. See hamming_encode()
187 * for a more detailed description of 'b'.
188 */
189 b = calc_code_bit(nr, NULL);
190 /* If the fix is before this hunk, nothing to do */
191 if (fix < b)
192 return;
193
194 for (i = 0; i < d; i++, b++)
195 {
196 /* Skip past parity bits */
197 while (hweight32(b) == 1)
198 b++;
199
200 /*
201 * i is the offset in this data hunk.
202 * nr + i is the offset in the total data buffer.
203 * b is the offset in the total code buffer.
204 *
205 * Thus, when b == fix, bit i in the current hunk needs
206 * fixing.
207 */
208 if (b == fix)
209 {
210 if (ocfs2_test_bit(i, data))
211 ocfs2_clear_bit(i, data);
212 else
213 ocfs2_set_bit(i, data);
214 break;
215 }
216 }
217}
218
219void ocfs2_hamming_fix_block(void *data, unsigned int blocksize,
220 unsigned int fix)
221{
222 ocfs2_hamming_fix(data, blocksize * 8, 0, fix);
223}
224
225/*
226 * This function generates check information for a block.
227 * data is the block to be checked. bc is a pointer to the
228 * ocfs2_block_check structure describing the crc32 and the ecc.
229 *
230 * bc should be a pointer inside data, as the function will
231 * take care of zeroing it before calculating the check information. If
232 * bc does not point inside data, the caller must make sure any inline
233 * ocfs2_block_check structures are zeroed.
234 *
235 * The data buffer must be in on-disk endian (little endian for ocfs2).
236 * bc will be filled with little-endian values and will be ready to go to
237 * disk.
238 */
239void ocfs2_block_check_compute(void *data, size_t blocksize,
240 struct ocfs2_block_check *bc)
241{
242 u32 crc;
243 u32 ecc;
244
245 memset(bc, 0, sizeof(struct ocfs2_block_check));
246
247 crc = crc32_le(~0, data, blocksize);
248 ecc = ocfs2_hamming_encode_block(data, blocksize);
249
250 /*
251 * No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
252 * larger than 16 bits.
253 */
254 BUG_ON(ecc > USHORT_MAX);
255
256 bc->bc_crc32e = cpu_to_le32(crc);
257 bc->bc_ecc = cpu_to_le16((u16)ecc);
258}
259
260/*
261 * This function validates existing check information. Like _compute,
262 * the function will take care of zeroing bc before calculating check codes.
263 * If bc is not a pointer inside data, the caller must have zeroed any
264 * inline ocfs2_block_check structures.
265 *
266 * Again, the data passed in should be the on-disk endian.
267 */
268int ocfs2_block_check_validate(void *data, size_t blocksize,
269 struct ocfs2_block_check *bc)
270{
271 int rc = 0;
272 struct ocfs2_block_check check;
273 u32 crc, ecc;
274
275 check.bc_crc32e = le32_to_cpu(bc->bc_crc32e);
276 check.bc_ecc = le16_to_cpu(bc->bc_ecc);
277
278 memset(bc, 0, sizeof(struct ocfs2_block_check));
279
280 /* Fast path - if the crc32 validates, we're good to go */
281 crc = crc32_le(~0, data, blocksize);
282 if (crc == check.bc_crc32e)
283 goto out;
284
285 mlog(ML_ERROR,
286 "CRC32 failed: stored: %u, computed %u. Applying ECC.\n",
287 (unsigned int)check.bc_crc32e, (unsigned int)crc);
288
289 /* Ok, try ECC fixups */
290 ecc = ocfs2_hamming_encode_block(data, blocksize);
291 ocfs2_hamming_fix_block(data, blocksize, ecc ^ check.bc_ecc);
292
293 /* And check the crc32 again */
294 crc = crc32_le(~0, data, blocksize);
295 if (crc == check.bc_crc32e)
296 goto out;
297
298 mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n",
299 (unsigned int)check.bc_crc32e, (unsigned int)crc);
300
301 rc = -EIO;
302
303out:
304 bc->bc_crc32e = cpu_to_le32(check.bc_crc32e);
305 bc->bc_ecc = cpu_to_le16(check.bc_ecc);
306
307 return rc;
308}
309
310/*
311 * This function generates check information for a list of buffer_heads.
312 * bhs is the blocks to be checked. bc is a pointer to the
313 * ocfs2_block_check structure describing the crc32 and the ecc.
314 *
315 * bc should be a pointer inside data, as the function will
316 * take care of zeroing it before calculating the check information. If
317 * bc does not point inside data, the caller must make sure any inline
318 * ocfs2_block_check structures are zeroed.
319 *
320 * The data buffer must be in on-disk endian (little endian for ocfs2).
321 * bc will be filled with little-endian values and will be ready to go to
322 * disk.
323 */
324void ocfs2_block_check_compute_bhs(struct buffer_head **bhs, int nr,
325 struct ocfs2_block_check *bc)
326{
327 int i;
328 u32 crc, ecc;
329
330 BUG_ON(nr < 0);
331
332 if (!nr)
333 return;
334
335 memset(bc, 0, sizeof(struct ocfs2_block_check));
336
337 for (i = 0, crc = ~0, ecc = 0; i < nr; i++) {
338 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size);
339 /*
340 * The number of bits in a buffer is obviously b_size*8.
341 * The offset of this buffer is b_size*i, so the bit offset
342 * of this buffer is b_size*8*i.
343 */
344 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data,
345 bhs[i]->b_size * 8,
346 bhs[i]->b_size * 8 * i);
347 }
348
349 /*
350 * No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
351 * larger than 16 bits.
352 */
353 BUG_ON(ecc > USHORT_MAX);
354
355 bc->bc_crc32e = cpu_to_le32(crc);
356 bc->bc_ecc = cpu_to_le16((u16)ecc);
357}
358
359/*
360 * This function validates existing check information on a list of
361 * buffer_heads. Like _compute_bhs, the function will take care of
362 * zeroing bc before calculating check codes. If bc is not a pointer
363 * inside data, the caller must have zeroed any inline
364 * ocfs2_block_check structures.
365 *
366 * Again, the data passed in should be the on-disk endian.
367 */
368int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
369 struct ocfs2_block_check *bc)
370{
371 int i, rc = 0;
372 struct ocfs2_block_check check;
373 u32 crc, ecc, fix;
374
375 BUG_ON(nr < 0);
376
377 if (!nr)
378 return 0;
379
380 check.bc_crc32e = le32_to_cpu(bc->bc_crc32e);
381 check.bc_ecc = le16_to_cpu(bc->bc_ecc);
382
383 memset(bc, 0, sizeof(struct ocfs2_block_check));
384
385 /* Fast path - if the crc32 validates, we're good to go */
386 for (i = 0, crc = ~0; i < nr; i++)
387 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size);
388 if (crc == check.bc_crc32e)
389 goto out;
390
391 mlog(ML_ERROR,
392 "CRC32 failed: stored: %u, computed %u. Applying ECC.\n",
393 (unsigned int)check.bc_crc32e, (unsigned int)crc);
394
395 /* Ok, try ECC fixups */
396 for (i = 0, ecc = 0; i < nr; i++) {
397 /*
398 * The number of bits in a buffer is obviously b_size*8.
399 * The offset of this buffer is b_size*i, so the bit offset
400 * of this buffer is b_size*8*i.
401 */
402 ecc = (u16)ocfs2_hamming_encode(ecc, bhs[i]->b_data,
403 bhs[i]->b_size * 8,
404 bhs[i]->b_size * 8 * i);
405 }
406 fix = ecc ^ check.bc_ecc;
407 for (i = 0; i < nr; i++) {
408 /*
409 * Try the fix against each buffer. It will only affect
410 * one of them.
411 */
412 ocfs2_hamming_fix(bhs[i]->b_data, bhs[i]->b_size * 8,
413 bhs[i]->b_size * 8 * i, fix);
414 }
415
416 /* And check the crc32 again */
417 for (i = 0, crc = ~0; i < nr; i++)
418 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size);
419 if (crc == check.bc_crc32e)
420 goto out;
421
422 mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n",
423 (unsigned int)check.bc_crc32e, (unsigned int)crc);
424
425 rc = -EIO;
426
427out:
428 bc->bc_crc32e = cpu_to_le32(check.bc_crc32e);
429 bc->bc_ecc = cpu_to_le16(check.bc_ecc);
430
431 return rc;
432}
433
434/*
435 * These are the main API. They check the superblock flag before
436 * calling the underlying operations.
437 *
438 * They expect the buffer(s) to be in disk format.
439 */
440void ocfs2_compute_meta_ecc(struct super_block *sb, void *data,
441 struct ocfs2_block_check *bc)
442{
443 if (ocfs2_meta_ecc(OCFS2_SB(sb)))
444 ocfs2_block_check_compute(data, sb->s_blocksize, bc);
445}
446
447int ocfs2_validate_meta_ecc(struct super_block *sb, void *data,
448 struct ocfs2_block_check *bc)
449{
450 int rc = 0;
451
452 if (ocfs2_meta_ecc(OCFS2_SB(sb)))
453 rc = ocfs2_block_check_validate(data, sb->s_blocksize, bc);
454
455 return rc;
456}
457
458void ocfs2_compute_meta_ecc_bhs(struct super_block *sb,
459 struct buffer_head **bhs, int nr,
460 struct ocfs2_block_check *bc)
461{
462 if (ocfs2_meta_ecc(OCFS2_SB(sb)))
463 ocfs2_block_check_compute_bhs(bhs, nr, bc);
464}
465
466int ocfs2_validate_meta_ecc_bhs(struct super_block *sb,
467 struct buffer_head **bhs, int nr,
468 struct ocfs2_block_check *bc)
469{
470 int rc = 0;
471
472 if (ocfs2_meta_ecc(OCFS2_SB(sb)))
473 rc = ocfs2_block_check_validate_bhs(bhs, nr, bc);
474
475 return rc;
476}
477
diff --git a/fs/ocfs2/blockcheck.h b/fs/ocfs2/blockcheck.h
new file mode 100644
index 000000000000..70ec3feda32f
--- /dev/null
+++ b/fs/ocfs2/blockcheck.h
@@ -0,0 +1,82 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * blockcheck.h
5 *
6 * Checksum and ECC codes for the OCFS2 userspace library.
7 *
8 * Copyright (C) 2004, 2008 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License, version 2, 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
20#ifndef OCFS2_BLOCKCHECK_H
21#define OCFS2_BLOCKCHECK_H
22
23
24/* High level block API */
25void ocfs2_compute_meta_ecc(struct super_block *sb, void *data,
26 struct ocfs2_block_check *bc);
27int ocfs2_validate_meta_ecc(struct super_block *sb, void *data,
28 struct ocfs2_block_check *bc);
29void ocfs2_compute_meta_ecc_bhs(struct super_block *sb,
30 struct buffer_head **bhs, int nr,
31 struct ocfs2_block_check *bc);
32int ocfs2_validate_meta_ecc_bhs(struct super_block *sb,
33 struct buffer_head **bhs, int nr,
34 struct ocfs2_block_check *bc);
35
36/* Lower level API */
37void ocfs2_block_check_compute(void *data, size_t blocksize,
38 struct ocfs2_block_check *bc);
39int ocfs2_block_check_validate(void *data, size_t blocksize,
40 struct ocfs2_block_check *bc);
41void ocfs2_block_check_compute_bhs(struct buffer_head **bhs, int nr,
42 struct ocfs2_block_check *bc);
43int ocfs2_block_check_validate_bhs(struct buffer_head **bhs, int nr,
44 struct ocfs2_block_check *bc);
45
46/*
47 * Hamming code functions
48 */
49
50/*
51 * Encoding hamming code parity bits for a buffer.
52 *
53 * This is the low level encoder function. It can be called across
54 * multiple hunks just like the crc32 code. 'd' is the number of bits
55 * _in_this_hunk_. nr is the bit offset of this hunk. So, if you had
56 * two 512B buffers, you would do it like so:
57 *
58 * parity = ocfs2_hamming_encode(0, buf1, 512 * 8, 0);
59 * parity = ocfs2_hamming_encode(parity, buf2, 512 * 8, 512 * 8);
60 *
61 * If you just have one buffer, use ocfs2_hamming_encode_block().
62 */
63u32 ocfs2_hamming_encode(u32 parity, void *data, unsigned int d,
64 unsigned int nr);
65/*
66 * Fix a buffer with a bit error. The 'fix' is the original parity
67 * xor'd with the parity calculated now.
68 *
69 * Like ocfs2_hamming_encode(), this can handle hunks. nr is the bit
70 * offset of the current hunk. If bit to be fixed is not part of the
71 * current hunk, this does nothing.
72 *
73 * If you only have one buffer, use ocfs2_hamming_fix_block().
74 */
75void ocfs2_hamming_fix(void *data, unsigned int d, unsigned int nr,
76 unsigned int fix);
77
78/* Convenience wrappers for a single buffer of data */
79extern u32 ocfs2_hamming_encode_block(void *data, unsigned int blocksize);
80extern void ocfs2_hamming_fix_block(void *data, unsigned int blocksize,
81 unsigned int fix);
82#endif
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index 3a178ec48d7c..15c8e6deee2e 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -39,6 +39,18 @@
39 39
40#include "buffer_head_io.h" 40#include "buffer_head_io.h"
41 41
42/*
43 * Bits on bh->b_state used by ocfs2.
44 *
45 * These MUST be after the JBD2 bits. Hence, we use BH_JBDPrivateStart.
46 */
47enum ocfs2_state_bits {
48 BH_NeedsValidate = BH_JBDPrivateStart,
49};
50
51/* Expand the magic b_state functions */
52BUFFER_FNS(NeedsValidate, needs_validate);
53
42int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, 54int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
43 struct inode *inode) 55 struct inode *inode)
44{ 56{
@@ -166,7 +178,9 @@ bail:
166} 178}
167 179
168int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, 180int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
169 struct buffer_head *bhs[], int flags) 181 struct buffer_head *bhs[], int flags,
182 int (*validate)(struct super_block *sb,
183 struct buffer_head *bh))
170{ 184{
171 int status = 0; 185 int status = 0;
172 int i, ignore_cache = 0; 186 int i, ignore_cache = 0;
@@ -298,6 +312,8 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
298 312
299 clear_buffer_uptodate(bh); 313 clear_buffer_uptodate(bh);
300 get_bh(bh); /* for end_buffer_read_sync() */ 314 get_bh(bh); /* for end_buffer_read_sync() */
315 if (validate)
316 set_buffer_needs_validate(bh);
301 bh->b_end_io = end_buffer_read_sync; 317 bh->b_end_io = end_buffer_read_sync;
302 submit_bh(READ, bh); 318 submit_bh(READ, bh);
303 continue; 319 continue;
@@ -328,6 +344,20 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
328 bhs[i] = NULL; 344 bhs[i] = NULL;
329 continue; 345 continue;
330 } 346 }
347
348 if (buffer_needs_validate(bh)) {
349 /* We never set NeedsValidate if the
350 * buffer was held by the journal, so
351 * that better not have changed */
352 BUG_ON(buffer_jbd(bh));
353 clear_buffer_needs_validate(bh);
354 status = validate(inode->i_sb, bh);
355 if (status) {
356 put_bh(bh);
357 bhs[i] = NULL;
358 continue;
359 }
360 }
331 } 361 }
332 362
333 /* Always set the buffer in the cache, even if it was 363 /* Always set the buffer in the cache, even if it was
diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h
index 75e1dcb1ade7..c75d682dadd8 100644
--- a/fs/ocfs2/buffer_head_io.h
+++ b/fs/ocfs2/buffer_head_io.h
@@ -31,21 +31,24 @@
31void ocfs2_end_buffer_io_sync(struct buffer_head *bh, 31void ocfs2_end_buffer_io_sync(struct buffer_head *bh,
32 int uptodate); 32 int uptodate);
33 33
34static inline int ocfs2_read_block(struct inode *inode,
35 u64 off,
36 struct buffer_head **bh);
37
38int ocfs2_write_block(struct ocfs2_super *osb, 34int ocfs2_write_block(struct ocfs2_super *osb,
39 struct buffer_head *bh, 35 struct buffer_head *bh,
40 struct inode *inode); 36 struct inode *inode);
41int ocfs2_read_blocks(struct inode *inode,
42 u64 block,
43 int nr,
44 struct buffer_head *bhs[],
45 int flags);
46int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, 37int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
47 unsigned int nr, struct buffer_head *bhs[]); 38 unsigned int nr, struct buffer_head *bhs[]);
48 39
40/*
41 * If not NULL, validate() will be called on a buffer that is freshly
42 * read from disk. It will not be called if the buffer was in cache.
43 * Note that if validate() is being used for this buffer, it needs to
44 * be set even for a READAHEAD call, as it marks the buffer for later
45 * validation.
46 */
47int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
48 struct buffer_head *bhs[], int flags,
49 int (*validate)(struct super_block *sb,
50 struct buffer_head *bh));
51
49int ocfs2_write_super_or_backup(struct ocfs2_super *osb, 52int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
50 struct buffer_head *bh); 53 struct buffer_head *bh);
51 54
@@ -53,7 +56,9 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
53#define OCFS2_BH_READAHEAD 8 56#define OCFS2_BH_READAHEAD 8
54 57
55static inline int ocfs2_read_block(struct inode *inode, u64 off, 58static inline int ocfs2_read_block(struct inode *inode, u64 off,
56 struct buffer_head **bh) 59 struct buffer_head **bh,
60 int (*validate)(struct super_block *sb,
61 struct buffer_head *bh))
57{ 62{
58 int status = 0; 63 int status = 0;
59 64
@@ -63,7 +68,7 @@ static inline int ocfs2_read_block(struct inode *inode, u64 off,
63 goto bail; 68 goto bail;
64 } 69 }
65 70
66 status = ocfs2_read_blocks(inode, off, 1, bh, 0); 71 status = ocfs2_read_blocks(inode, off, 1, bh, 0, validate);
67 72
68bail: 73bail:
69 return status; 74 return status;
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c
index d8a0cb92cef6..96df5416993e 100644
--- a/fs/ocfs2/cluster/masklog.c
+++ b/fs/ocfs2/cluster/masklog.c
@@ -110,6 +110,7 @@ static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = {
110 define_mask(QUORUM), 110 define_mask(QUORUM),
111 define_mask(EXPORT), 111 define_mask(EXPORT),
112 define_mask(XATTR), 112 define_mask(XATTR),
113 define_mask(QUOTA),
113 define_mask(ERROR), 114 define_mask(ERROR),
114 define_mask(NOTICE), 115 define_mask(NOTICE),
115 define_mask(KTHREAD), 116 define_mask(KTHREAD),
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index 57670c680471..7e72a81bc2d4 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -113,6 +113,7 @@
113#define ML_QUORUM 0x0000000008000000ULL /* net connection quorum */ 113#define ML_QUORUM 0x0000000008000000ULL /* net connection quorum */
114#define ML_EXPORT 0x0000000010000000ULL /* ocfs2 export operations */ 114#define ML_EXPORT 0x0000000010000000ULL /* ocfs2 export operations */
115#define ML_XATTR 0x0000000020000000ULL /* ocfs2 extended attributes */ 115#define ML_XATTR 0x0000000020000000ULL /* ocfs2 extended attributes */
116#define ML_QUOTA 0x0000000040000000ULL /* ocfs2 quota operations */
116/* bits that are infrequently given and frequently matched in the high word */ 117/* bits that are infrequently given and frequently matched in the high word */
117#define ML_ERROR 0x0000000100000000ULL /* sent to KERN_ERR */ 118#define ML_ERROR 0x0000000100000000ULL /* sent to KERN_ERR */
118#define ML_NOTICE 0x0000000200000000ULL /* setn to KERN_NOTICE */ 119#define ML_NOTICE 0x0000000200000000ULL /* setn to KERN_NOTICE */
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 026e6eb85187..f2c4098cf337 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -40,6 +40,7 @@
40#include <linux/types.h> 40#include <linux/types.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/quotaops.h>
43 44
44#define MLOG_MASK_PREFIX ML_NAMEI 45#define MLOG_MASK_PREFIX ML_NAMEI
45#include <cluster/masklog.h> 46#include <cluster/masklog.h>
@@ -47,6 +48,7 @@
47#include "ocfs2.h" 48#include "ocfs2.h"
48 49
49#include "alloc.h" 50#include "alloc.h"
51#include "blockcheck.h"
50#include "dir.h" 52#include "dir.h"
51#include "dlmglue.h" 53#include "dlmglue.h"
52#include "extent_map.h" 54#include "extent_map.h"
@@ -82,47 +84,72 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
82 struct ocfs2_alloc_context *meta_ac, 84 struct ocfs2_alloc_context *meta_ac,
83 struct buffer_head **new_bh); 85 struct buffer_head **new_bh);
84 86
85static struct buffer_head *ocfs2_bread(struct inode *inode, 87/*
86 int block, int *err, int reada) 88 * These are distinct checks because future versions of the file system will
89 * want to have a trailing dirent structure independent of indexing.
90 */
91static int ocfs2_dir_has_trailer(struct inode *dir)
87{ 92{
88 struct buffer_head *bh = NULL; 93 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
89 int tmperr; 94 return 0;
90 u64 p_blkno;
91 int readflags = 0;
92 95
93 if (reada) 96 return ocfs2_meta_ecc(OCFS2_SB(dir->i_sb));
94 readflags |= OCFS2_BH_READAHEAD; 97}
95 98
96 if (((u64)block << inode->i_sb->s_blocksize_bits) >= 99static int ocfs2_supports_dir_trailer(struct ocfs2_super *osb)
97 i_size_read(inode)) { 100{
98 BUG_ON(!reada); 101 return ocfs2_meta_ecc(osb);
99 return NULL; 102}
100 }
101 103
102 down_read(&OCFS2_I(inode)->ip_alloc_sem); 104static inline unsigned int ocfs2_dir_trailer_blk_off(struct super_block *sb)
103 tmperr = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL, 105{
104 NULL); 106 return sb->s_blocksize - sizeof(struct ocfs2_dir_block_trailer);
105 up_read(&OCFS2_I(inode)->ip_alloc_sem); 107}
106 if (tmperr < 0) {
107 mlog_errno(tmperr);
108 goto fail;
109 }
110 108
111 tmperr = ocfs2_read_blocks(inode, p_blkno, 1, &bh, readflags); 109#define ocfs2_trailer_from_bh(_bh, _sb) ((struct ocfs2_dir_block_trailer *) ((_bh)->b_data + ocfs2_dir_trailer_blk_off((_sb))))
112 if (tmperr < 0)
113 goto fail;
114 110
115 tmperr = 0; 111/* XXX ocfs2_block_dqtrailer() is similar but not quite - can we make
112 * them more consistent? */
113struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
114 void *data)
115{
116 char *p = data;
116 117
117 *err = 0; 118 p += blocksize - sizeof(struct ocfs2_dir_block_trailer);
118 return bh; 119 return (struct ocfs2_dir_block_trailer *)p;
120}
119 121
120fail: 122/*
121 brelse(bh); 123 * XXX: This is executed once on every dirent. We should consider optimizing
122 bh = NULL; 124 * it.
125 */
126static int ocfs2_skip_dir_trailer(struct inode *dir,
127 struct ocfs2_dir_entry *de,
128 unsigned long offset,
129 unsigned long blklen)
130{
131 unsigned long toff = blklen - sizeof(struct ocfs2_dir_block_trailer);
123 132
124 *err = -EIO; 133 if (!ocfs2_dir_has_trailer(dir))
125 return NULL; 134 return 0;
135
136 if (offset != toff)
137 return 0;
138
139 return 1;
140}
141
142static void ocfs2_init_dir_trailer(struct inode *inode,
143 struct buffer_head *bh)
144{
145 struct ocfs2_dir_block_trailer *trailer;
146
147 trailer = ocfs2_trailer_from_bh(bh, inode->i_sb);
148 strcpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE);
149 trailer->db_compat_rec_len =
150 cpu_to_le16(sizeof(struct ocfs2_dir_block_trailer));
151 trailer->db_parent_dinode = cpu_to_le64(OCFS2_I(inode)->ip_blkno);
152 trailer->db_blkno = cpu_to_le64(bh->b_blocknr);
126} 153}
127 154
128/* 155/*
@@ -231,7 +258,7 @@ static struct buffer_head *ocfs2_find_entry_id(const char *name,
231 struct ocfs2_dinode *di; 258 struct ocfs2_dinode *di;
232 struct ocfs2_inline_data *data; 259 struct ocfs2_inline_data *data;
233 260
234 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); 261 ret = ocfs2_read_inode_block(dir, &di_bh);
235 if (ret) { 262 if (ret) {
236 mlog_errno(ret); 263 mlog_errno(ret);
237 goto out; 264 goto out;
@@ -250,6 +277,108 @@ out:
250 return NULL; 277 return NULL;
251} 278}
252 279
280static int ocfs2_validate_dir_block(struct super_block *sb,
281 struct buffer_head *bh)
282{
283 int rc;
284 struct ocfs2_dir_block_trailer *trailer =
285 ocfs2_trailer_from_bh(bh, sb);
286
287
288 /*
289 * We don't validate dirents here, that's handled
290 * in-place when the code walks them.
291 */
292 mlog(0, "Validating dirblock %llu\n",
293 (unsigned long long)bh->b_blocknr);
294
295 BUG_ON(!buffer_uptodate(bh));
296
297 /*
298 * If the ecc fails, we return the error but otherwise
299 * leave the filesystem running. We know any error is
300 * local to this block.
301 *
302 * Note that we are safe to call this even if the directory
303 * doesn't have a trailer. Filesystems without metaecc will do
304 * nothing, and filesystems with it will have one.
305 */
306 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &trailer->db_check);
307 if (rc)
308 mlog(ML_ERROR, "Checksum failed for dinode %llu\n",
309 (unsigned long long)bh->b_blocknr);
310
311 return rc;
312}
313
314/*
315 * This function forces all errors to -EIO for consistency with its
316 * predecessor, ocfs2_bread(). We haven't audited what returning the
317 * real error codes would do to callers. We log the real codes with
318 * mlog_errno() before we squash them.
319 */
320static int ocfs2_read_dir_block(struct inode *inode, u64 v_block,
321 struct buffer_head **bh, int flags)
322{
323 int rc = 0;
324 struct buffer_head *tmp = *bh;
325 struct ocfs2_dir_block_trailer *trailer;
326
327 rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, flags,
328 ocfs2_validate_dir_block);
329 if (rc) {
330 mlog_errno(rc);
331 goto out;
332 }
333
334 /*
335 * We check the trailer here rather than in
336 * ocfs2_validate_dir_block() because that function doesn't have
337 * the inode to test.
338 */
339 if (!(flags & OCFS2_BH_READAHEAD) &&
340 ocfs2_dir_has_trailer(inode)) {
341 trailer = ocfs2_trailer_from_bh(tmp, inode->i_sb);
342 if (!OCFS2_IS_VALID_DIR_TRAILER(trailer)) {
343 rc = -EINVAL;
344 ocfs2_error(inode->i_sb,
345 "Invalid dirblock #%llu: "
346 "signature = %.*s\n",
347 (unsigned long long)tmp->b_blocknr, 7,
348 trailer->db_signature);
349 goto out;
350 }
351 if (le64_to_cpu(trailer->db_blkno) != tmp->b_blocknr) {
352 rc = -EINVAL;
353 ocfs2_error(inode->i_sb,
354 "Directory block #%llu has an invalid "
355 "db_blkno of %llu",
356 (unsigned long long)tmp->b_blocknr,
357 (unsigned long long)le64_to_cpu(trailer->db_blkno));
358 goto out;
359 }
360 if (le64_to_cpu(trailer->db_parent_dinode) !=
361 OCFS2_I(inode)->ip_blkno) {
362 rc = -EINVAL;
363 ocfs2_error(inode->i_sb,
364 "Directory block #%llu on dinode "
365 "#%llu has an invalid parent_dinode "
366 "of %llu",
367 (unsigned long long)tmp->b_blocknr,
368 (unsigned long long)OCFS2_I(inode)->ip_blkno,
369 (unsigned long long)le64_to_cpu(trailer->db_blkno));
370 goto out;
371 }
372 }
373
374 /* If ocfs2_read_virt_blocks() got us a new bh, pass it up. */
375 if (!*bh)
376 *bh = tmp;
377
378out:
379 return rc ? -EIO : 0;
380}
381
253static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen, 382static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen,
254 struct inode *dir, 383 struct inode *dir,
255 struct ocfs2_dir_entry **res_dir) 384 struct ocfs2_dir_entry **res_dir)
@@ -296,15 +425,17 @@ restart:
296 } 425 }
297 num++; 426 num++;
298 427
299 bh = ocfs2_bread(dir, b++, &err, 1); 428 bh = NULL;
429 err = ocfs2_read_dir_block(dir, b++, &bh,
430 OCFS2_BH_READAHEAD);
300 bh_use[ra_max] = bh; 431 bh_use[ra_max] = bh;
301 } 432 }
302 } 433 }
303 if ((bh = bh_use[ra_ptr++]) == NULL) 434 if ((bh = bh_use[ra_ptr++]) == NULL)
304 goto next; 435 goto next;
305 if (ocfs2_read_block(dir, block, &bh)) { 436 if (ocfs2_read_dir_block(dir, block, &bh, 0)) {
306 /* read error, skip block & hope for the best. 437 /* read error, skip block & hope for the best.
307 * ocfs2_read_block() has released the bh. */ 438 * ocfs2_read_dir_block() has released the bh. */
308 ocfs2_error(dir->i_sb, "reading directory %llu, " 439 ocfs2_error(dir->i_sb, "reading directory %llu, "
309 "offset %lu\n", 440 "offset %lu\n",
310 (unsigned long long)OCFS2_I(dir)->ip_blkno, 441 (unsigned long long)OCFS2_I(dir)->ip_blkno,
@@ -381,14 +512,18 @@ int ocfs2_update_entry(struct inode *dir, handle_t *handle,
381 struct inode *new_entry_inode) 512 struct inode *new_entry_inode)
382{ 513{
383 int ret; 514 int ret;
515 ocfs2_journal_access_func access = ocfs2_journal_access_db;
384 516
385 /* 517 /*
386 * The same code works fine for both inline-data and extent 518 * The same code works fine for both inline-data and extent
387 * based directories, so no need to split this up. 519 * based directories, so no need to split this up. The only
520 * difference is the journal_access function.
388 */ 521 */
389 522
390 ret = ocfs2_journal_access(handle, dir, de_bh, 523 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
391 OCFS2_JOURNAL_ACCESS_WRITE); 524 access = ocfs2_journal_access_di;
525
526 ret = access(handle, dir, de_bh, OCFS2_JOURNAL_ACCESS_WRITE);
392 if (ret) { 527 if (ret) {
393 mlog_errno(ret); 528 mlog_errno(ret);
394 goto out; 529 goto out;
@@ -410,9 +545,13 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
410{ 545{
411 struct ocfs2_dir_entry *de, *pde; 546 struct ocfs2_dir_entry *de, *pde;
412 int i, status = -ENOENT; 547 int i, status = -ENOENT;
548 ocfs2_journal_access_func access = ocfs2_journal_access_db;
413 549
414 mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh); 550 mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh);
415 551
552 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
553 access = ocfs2_journal_access_di;
554
416 i = 0; 555 i = 0;
417 pde = NULL; 556 pde = NULL;
418 de = (struct ocfs2_dir_entry *) first_de; 557 de = (struct ocfs2_dir_entry *) first_de;
@@ -423,8 +562,8 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
423 goto bail; 562 goto bail;
424 } 563 }
425 if (de == de_del) { 564 if (de == de_del) {
426 status = ocfs2_journal_access(handle, dir, bh, 565 status = access(handle, dir, bh,
427 OCFS2_JOURNAL_ACCESS_WRITE); 566 OCFS2_JOURNAL_ACCESS_WRITE);
428 if (status < 0) { 567 if (status < 0) {
429 status = -EIO; 568 status = -EIO;
430 mlog_errno(status); 569 mlog_errno(status);
@@ -458,7 +597,7 @@ static inline int ocfs2_delete_entry_id(handle_t *handle,
458 struct ocfs2_dinode *di; 597 struct ocfs2_dinode *di;
459 struct ocfs2_inline_data *data; 598 struct ocfs2_inline_data *data;
460 599
461 ret = ocfs2_read_block(dir, OCFS2_I(dir)->ip_blkno, &di_bh); 600 ret = ocfs2_read_inode_block(dir, &di_bh);
462 if (ret) { 601 if (ret) {
463 mlog_errno(ret); 602 mlog_errno(ret);
464 goto out; 603 goto out;
@@ -576,6 +715,16 @@ int __ocfs2_add_entry(handle_t *handle,
576 goto bail; 715 goto bail;
577 } 716 }
578 717
718 /* We're guaranteed that we should have space, so we
719 * can't possibly have hit the trailer...right? */
720 mlog_bug_on_msg(ocfs2_skip_dir_trailer(dir, de, offset, size),
721 "Hit dir trailer trying to insert %.*s "
722 "(namelen %d) into directory %llu. "
723 "offset is %lu, trailer offset is %d\n",
724 namelen, name, namelen,
725 (unsigned long long)parent_fe_bh->b_blocknr,
726 offset, ocfs2_dir_trailer_blk_off(dir->i_sb));
727
579 if (ocfs2_dirent_would_fit(de, rec_len)) { 728 if (ocfs2_dirent_would_fit(de, rec_len)) {
580 dir->i_mtime = dir->i_ctime = CURRENT_TIME; 729 dir->i_mtime = dir->i_ctime = CURRENT_TIME;
581 retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); 730 retval = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh);
@@ -584,8 +733,14 @@ int __ocfs2_add_entry(handle_t *handle,
584 goto bail; 733 goto bail;
585 } 734 }
586 735
587 status = ocfs2_journal_access(handle, dir, insert_bh, 736 if (insert_bh == parent_fe_bh)
588 OCFS2_JOURNAL_ACCESS_WRITE); 737 status = ocfs2_journal_access_di(handle, dir,
738 insert_bh,
739 OCFS2_JOURNAL_ACCESS_WRITE);
740 else
741 status = ocfs2_journal_access_db(handle, dir,
742 insert_bh,
743 OCFS2_JOURNAL_ACCESS_WRITE);
589 /* By now the buffer is marked for journaling */ 744 /* By now the buffer is marked for journaling */
590 offset += le16_to_cpu(de->rec_len); 745 offset += le16_to_cpu(de->rec_len);
591 if (le64_to_cpu(de->inode)) { 746 if (le64_to_cpu(de->inode)) {
@@ -611,6 +766,7 @@ int __ocfs2_add_entry(handle_t *handle,
611 retval = 0; 766 retval = 0;
612 goto bail; 767 goto bail;
613 } 768 }
769
614 offset += le16_to_cpu(de->rec_len); 770 offset += le16_to_cpu(de->rec_len);
615 de = (struct ocfs2_dir_entry *) ((char *) de + le16_to_cpu(de->rec_len)); 771 de = (struct ocfs2_dir_entry *) ((char *) de + le16_to_cpu(de->rec_len));
616 } 772 }
@@ -636,7 +792,7 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode,
636 struct ocfs2_inline_data *data; 792 struct ocfs2_inline_data *data;
637 struct ocfs2_dir_entry *de; 793 struct ocfs2_dir_entry *de;
638 794
639 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); 795 ret = ocfs2_read_inode_block(inode, &di_bh);
640 if (ret) { 796 if (ret) {
641 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n", 797 mlog(ML_ERROR, "Unable to read inode block for dir %llu\n",
642 (unsigned long long)OCFS2_I(inode)->ip_blkno); 798 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -724,7 +880,6 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
724 int i, stored; 880 int i, stored;
725 struct buffer_head * bh, * tmp; 881 struct buffer_head * bh, * tmp;
726 struct ocfs2_dir_entry * de; 882 struct ocfs2_dir_entry * de;
727 int err;
728 struct super_block * sb = inode->i_sb; 883 struct super_block * sb = inode->i_sb;
729 unsigned int ra_sectors = 16; 884 unsigned int ra_sectors = 16;
730 885
@@ -735,12 +890,8 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
735 890
736 while (!error && !stored && *f_pos < i_size_read(inode)) { 891 while (!error && !stored && *f_pos < i_size_read(inode)) {
737 blk = (*f_pos) >> sb->s_blocksize_bits; 892 blk = (*f_pos) >> sb->s_blocksize_bits;
738 bh = ocfs2_bread(inode, blk, &err, 0); 893 if (ocfs2_read_dir_block(inode, blk, &bh, 0)) {
739 if (!bh) { 894 /* Skip the corrupt dirblock and keep trying */
740 mlog(ML_ERROR,
741 "directory #%llu contains a hole at offset %lld\n",
742 (unsigned long long)OCFS2_I(inode)->ip_blkno,
743 *f_pos);
744 *f_pos += sb->s_blocksize - offset; 895 *f_pos += sb->s_blocksize - offset;
745 continue; 896 continue;
746 } 897 }
@@ -754,8 +905,10 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode,
754 || (((last_ra_blk - blk) << 9) <= (ra_sectors / 2))) { 905 || (((last_ra_blk - blk) << 9) <= (ra_sectors / 2))) {
755 for (i = ra_sectors >> (sb->s_blocksize_bits - 9); 906 for (i = ra_sectors >> (sb->s_blocksize_bits - 9);
756 i > 0; i--) { 907 i > 0; i--) {
757 tmp = ocfs2_bread(inode, ++blk, &err, 1); 908 tmp = NULL;
758 brelse(tmp); 909 if (!ocfs2_read_dir_block(inode, ++blk, &tmp,
910 OCFS2_BH_READAHEAD))
911 brelse(tmp);
759 } 912 }
760 last_ra_blk = blk; 913 last_ra_blk = blk;
761 ra_sectors = 8; 914 ra_sectors = 8;
@@ -828,6 +981,7 @@ revalidate:
828 } 981 }
829 offset = 0; 982 offset = 0;
830 brelse(bh); 983 brelse(bh);
984 bh = NULL;
831 } 985 }
832 986
833 stored = 0; 987 stored = 0;
@@ -1050,9 +1204,15 @@ int ocfs2_empty_dir(struct inode *inode)
1050 return !priv.seen_other; 1204 return !priv.seen_other;
1051} 1205}
1052 1206
1053static void ocfs2_fill_initial_dirents(struct inode *inode, 1207/*
1054 struct inode *parent, 1208 * Fills "." and ".." dirents in a new directory block. Returns dirent for
1055 char *start, unsigned int size) 1209 * "..", which might be used during creation of a directory with a trailing
1210 * header. It is otherwise safe to ignore the return code.
1211 */
1212static struct ocfs2_dir_entry *ocfs2_fill_initial_dirents(struct inode *inode,
1213 struct inode *parent,
1214 char *start,
1215 unsigned int size)
1056{ 1216{
1057 struct ocfs2_dir_entry *de = (struct ocfs2_dir_entry *)start; 1217 struct ocfs2_dir_entry *de = (struct ocfs2_dir_entry *)start;
1058 1218
@@ -1069,6 +1229,8 @@ static void ocfs2_fill_initial_dirents(struct inode *inode,
1069 de->name_len = 2; 1229 de->name_len = 2;
1070 strcpy(de->name, ".."); 1230 strcpy(de->name, "..");
1071 ocfs2_set_de_type(de, S_IFDIR); 1231 ocfs2_set_de_type(de, S_IFDIR);
1232
1233 return de;
1072} 1234}
1073 1235
1074/* 1236/*
@@ -1086,8 +1248,8 @@ static int ocfs2_fill_new_dir_id(struct ocfs2_super *osb,
1086 struct ocfs2_inline_data *data = &di->id2.i_data; 1248 struct ocfs2_inline_data *data = &di->id2.i_data;
1087 unsigned int size = le16_to_cpu(data->id_count); 1249 unsigned int size = le16_to_cpu(data->id_count);
1088 1250
1089 ret = ocfs2_journal_access(handle, inode, di_bh, 1251 ret = ocfs2_journal_access_di(handle, inode, di_bh,
1090 OCFS2_JOURNAL_ACCESS_WRITE); 1252 OCFS2_JOURNAL_ACCESS_WRITE);
1091 if (ret) { 1253 if (ret) {
1092 mlog_errno(ret); 1254 mlog_errno(ret);
1093 goto out; 1255 goto out;
@@ -1121,10 +1283,15 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
1121 struct ocfs2_alloc_context *data_ac) 1283 struct ocfs2_alloc_context *data_ac)
1122{ 1284{
1123 int status; 1285 int status;
1286 unsigned int size = osb->sb->s_blocksize;
1124 struct buffer_head *new_bh = NULL; 1287 struct buffer_head *new_bh = NULL;
1288 struct ocfs2_dir_entry *de;
1125 1289
1126 mlog_entry_void(); 1290 mlog_entry_void();
1127 1291
1292 if (ocfs2_supports_dir_trailer(osb))
1293 size = ocfs2_dir_trailer_blk_off(parent->i_sb);
1294
1128 status = ocfs2_do_extend_dir(osb->sb, handle, inode, fe_bh, 1295 status = ocfs2_do_extend_dir(osb->sb, handle, inode, fe_bh,
1129 data_ac, NULL, &new_bh); 1296 data_ac, NULL, &new_bh);
1130 if (status < 0) { 1297 if (status < 0) {
@@ -1134,16 +1301,17 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
1134 1301
1135 ocfs2_set_new_buffer_uptodate(inode, new_bh); 1302 ocfs2_set_new_buffer_uptodate(inode, new_bh);
1136 1303
1137 status = ocfs2_journal_access(handle, inode, new_bh, 1304 status = ocfs2_journal_access_db(handle, inode, new_bh,
1138 OCFS2_JOURNAL_ACCESS_CREATE); 1305 OCFS2_JOURNAL_ACCESS_CREATE);
1139 if (status < 0) { 1306 if (status < 0) {
1140 mlog_errno(status); 1307 mlog_errno(status);
1141 goto bail; 1308 goto bail;
1142 } 1309 }
1143 memset(new_bh->b_data, 0, osb->sb->s_blocksize); 1310 memset(new_bh->b_data, 0, osb->sb->s_blocksize);
1144 1311
1145 ocfs2_fill_initial_dirents(inode, parent, new_bh->b_data, 1312 de = ocfs2_fill_initial_dirents(inode, parent, new_bh->b_data, size);
1146 osb->sb->s_blocksize); 1313 if (ocfs2_supports_dir_trailer(osb))
1314 ocfs2_init_dir_trailer(inode, new_bh);
1147 1315
1148 status = ocfs2_journal_dirty(handle, new_bh); 1316 status = ocfs2_journal_dirty(handle, new_bh);
1149 if (status < 0) { 1317 if (status < 0) {
@@ -1184,13 +1352,27 @@ int ocfs2_fill_new_dir(struct ocfs2_super *osb,
1184 data_ac); 1352 data_ac);
1185} 1353}
1186 1354
1355/*
1356 * Expand rec_len of the rightmost dirent in a directory block so that it
1357 * contains the end of our valid space for dirents. We do this during
1358 * expansion from an inline directory to one with extents. The first dir block
1359 * in that case is taken from the inline data portion of the inode block.
1360 *
1361 * We add the dir trailer if this filesystem wants it.
1362 */
1187static void ocfs2_expand_last_dirent(char *start, unsigned int old_size, 1363static void ocfs2_expand_last_dirent(char *start, unsigned int old_size,
1188 unsigned int new_size) 1364 struct super_block *sb)
1189{ 1365{
1190 struct ocfs2_dir_entry *de; 1366 struct ocfs2_dir_entry *de;
1191 struct ocfs2_dir_entry *prev_de; 1367 struct ocfs2_dir_entry *prev_de;
1192 char *de_buf, *limit; 1368 char *de_buf, *limit;
1193 unsigned int bytes = new_size - old_size; 1369 unsigned int new_size = sb->s_blocksize;
1370 unsigned int bytes;
1371
1372 if (ocfs2_supports_dir_trailer(OCFS2_SB(sb)))
1373 new_size = ocfs2_dir_trailer_blk_off(sb);
1374
1375 bytes = new_size - old_size;
1194 1376
1195 limit = start + old_size; 1377 limit = start + old_size;
1196 de_buf = start; 1378 de_buf = start;
@@ -1216,9 +1398,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1216 unsigned int blocks_wanted, 1398 unsigned int blocks_wanted,
1217 struct buffer_head **first_block_bh) 1399 struct buffer_head **first_block_bh)
1218{ 1400{
1219 int ret, credits = OCFS2_INLINE_TO_EXTENTS_CREDITS;
1220 u32 alloc, bit_off, len; 1401 u32 alloc, bit_off, len;
1221 struct super_block *sb = dir->i_sb; 1402 struct super_block *sb = dir->i_sb;
1403 int ret, credits = ocfs2_inline_to_extents_credits(sb);
1222 u64 blkno, bytes = blocks_wanted << sb->s_blocksize_bits; 1404 u64 blkno, bytes = blocks_wanted << sb->s_blocksize_bits;
1223 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); 1405 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
1224 struct ocfs2_inode_info *oi = OCFS2_I(dir); 1406 struct ocfs2_inode_info *oi = OCFS2_I(dir);
@@ -1227,6 +1409,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1227 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 1409 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1228 handle_t *handle; 1410 handle_t *handle;
1229 struct ocfs2_extent_tree et; 1411 struct ocfs2_extent_tree et;
1412 int did_quota = 0;
1230 1413
1231 ocfs2_init_dinode_extent_tree(&et, dir, di_bh); 1414 ocfs2_init_dinode_extent_tree(&et, dir, di_bh);
1232 1415
@@ -1264,6 +1447,12 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1264 goto out_sem; 1447 goto out_sem;
1265 } 1448 }
1266 1449
1450 if (vfs_dq_alloc_space_nodirty(dir,
1451 ocfs2_clusters_to_bytes(osb->sb, alloc))) {
1452 ret = -EDQUOT;
1453 goto out_commit;
1454 }
1455 did_quota = 1;
1267 /* 1456 /*
1268 * Try to claim as many clusters as the bitmap can give though 1457 * Try to claim as many clusters as the bitmap can give though
1269 * if we only get one now, that's enough to continue. The rest 1458 * if we only get one now, that's enough to continue. The rest
@@ -1290,8 +1479,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1290 1479
1291 ocfs2_set_new_buffer_uptodate(dir, dirdata_bh); 1480 ocfs2_set_new_buffer_uptodate(dir, dirdata_bh);
1292 1481
1293 ret = ocfs2_journal_access(handle, dir, dirdata_bh, 1482 ret = ocfs2_journal_access_db(handle, dir, dirdata_bh,
1294 OCFS2_JOURNAL_ACCESS_CREATE); 1483 OCFS2_JOURNAL_ACCESS_CREATE);
1295 if (ret) { 1484 if (ret) {
1296 mlog_errno(ret); 1485 mlog_errno(ret);
1297 goto out_commit; 1486 goto out_commit;
@@ -1300,8 +1489,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1300 memcpy(dirdata_bh->b_data, di->id2.i_data.id_data, i_size_read(dir)); 1489 memcpy(dirdata_bh->b_data, di->id2.i_data.id_data, i_size_read(dir));
1301 memset(dirdata_bh->b_data + i_size_read(dir), 0, 1490 memset(dirdata_bh->b_data + i_size_read(dir), 0,
1302 sb->s_blocksize - i_size_read(dir)); 1491 sb->s_blocksize - i_size_read(dir));
1303 ocfs2_expand_last_dirent(dirdata_bh->b_data, i_size_read(dir), 1492 ocfs2_expand_last_dirent(dirdata_bh->b_data, i_size_read(dir), sb);
1304 sb->s_blocksize); 1493 if (ocfs2_supports_dir_trailer(osb))
1494 ocfs2_init_dir_trailer(dir, dirdata_bh);
1305 1495
1306 ret = ocfs2_journal_dirty(handle, dirdata_bh); 1496 ret = ocfs2_journal_dirty(handle, dirdata_bh);
1307 if (ret) { 1497 if (ret) {
@@ -1317,8 +1507,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1317 * We let the later dirent insert modify c/mtime - to the user 1507 * We let the later dirent insert modify c/mtime - to the user
1318 * the data hasn't changed. 1508 * the data hasn't changed.
1319 */ 1509 */
1320 ret = ocfs2_journal_access(handle, dir, di_bh, 1510 ret = ocfs2_journal_access_di(handle, dir, di_bh,
1321 OCFS2_JOURNAL_ACCESS_CREATE); 1511 OCFS2_JOURNAL_ACCESS_CREATE);
1322 if (ret) { 1512 if (ret) {
1323 mlog_errno(ret); 1513 mlog_errno(ret);
1324 goto out_commit; 1514 goto out_commit;
@@ -1386,6 +1576,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1386 dirdata_bh = NULL; 1576 dirdata_bh = NULL;
1387 1577
1388out_commit: 1578out_commit:
1579 if (ret < 0 && did_quota)
1580 vfs_dq_free_space_nodirty(dir,
1581 ocfs2_clusters_to_bytes(osb->sb, 2));
1389 ocfs2_commit_trans(osb, handle); 1582 ocfs2_commit_trans(osb, handle);
1390 1583
1391out_sem: 1584out_sem:
@@ -1410,7 +1603,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
1410 struct buffer_head **new_bh) 1603 struct buffer_head **new_bh)
1411{ 1604{
1412 int status; 1605 int status;
1413 int extend; 1606 int extend, did_quota = 0;
1414 u64 p_blkno, v_blkno; 1607 u64 p_blkno, v_blkno;
1415 1608
1416 spin_lock(&OCFS2_I(dir)->ip_lock); 1609 spin_lock(&OCFS2_I(dir)->ip_lock);
@@ -1420,6 +1613,13 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
1420 if (extend) { 1613 if (extend) {
1421 u32 offset = OCFS2_I(dir)->ip_clusters; 1614 u32 offset = OCFS2_I(dir)->ip_clusters;
1422 1615
1616 if (vfs_dq_alloc_space_nodirty(dir,
1617 ocfs2_clusters_to_bytes(sb, 1))) {
1618 status = -EDQUOT;
1619 goto bail;
1620 }
1621 did_quota = 1;
1622
1423 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset, 1623 status = ocfs2_add_inode_data(OCFS2_SB(sb), dir, &offset,
1424 1, 0, parent_fe_bh, handle, 1624 1, 0, parent_fe_bh, handle,
1425 data_ac, meta_ac, NULL); 1625 data_ac, meta_ac, NULL);
@@ -1445,6 +1645,8 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
1445 } 1645 }
1446 status = 0; 1646 status = 0;
1447bail: 1647bail:
1648 if (did_quota && status < 0)
1649 vfs_dq_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1));
1448 mlog_exit(status); 1650 mlog_exit(status);
1449 return status; 1651 return status;
1450} 1652}
@@ -1569,16 +1771,22 @@ do_extend:
1569 1771
1570 ocfs2_set_new_buffer_uptodate(dir, new_bh); 1772 ocfs2_set_new_buffer_uptodate(dir, new_bh);
1571 1773
1572 status = ocfs2_journal_access(handle, dir, new_bh, 1774 status = ocfs2_journal_access_db(handle, dir, new_bh,
1573 OCFS2_JOURNAL_ACCESS_CREATE); 1775 OCFS2_JOURNAL_ACCESS_CREATE);
1574 if (status < 0) { 1776 if (status < 0) {
1575 mlog_errno(status); 1777 mlog_errno(status);
1576 goto bail; 1778 goto bail;
1577 } 1779 }
1578 memset(new_bh->b_data, 0, sb->s_blocksize); 1780 memset(new_bh->b_data, 0, sb->s_blocksize);
1781
1579 de = (struct ocfs2_dir_entry *) new_bh->b_data; 1782 de = (struct ocfs2_dir_entry *) new_bh->b_data;
1580 de->inode = 0; 1783 de->inode = 0;
1581 de->rec_len = cpu_to_le16(sb->s_blocksize); 1784 if (ocfs2_dir_has_trailer(dir)) {
1785 de->rec_len = cpu_to_le16(ocfs2_dir_trailer_blk_off(sb));
1786 ocfs2_init_dir_trailer(dir, new_bh);
1787 } else {
1788 de->rec_len = cpu_to_le16(sb->s_blocksize);
1789 }
1582 status = ocfs2_journal_dirty(handle, new_bh); 1790 status = ocfs2_journal_dirty(handle, new_bh);
1583 if (status < 0) { 1791 if (status < 0) {
1584 mlog_errno(status); 1792 mlog_errno(status);
@@ -1620,11 +1828,21 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
1620 unsigned int *blocks_wanted) 1828 unsigned int *blocks_wanted)
1621{ 1829{
1622 int ret; 1830 int ret;
1831 struct super_block *sb = dir->i_sb;
1623 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 1832 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1624 struct ocfs2_dir_entry *de, *last_de = NULL; 1833 struct ocfs2_dir_entry *de, *last_de = NULL;
1625 char *de_buf, *limit; 1834 char *de_buf, *limit;
1626 unsigned long offset = 0; 1835 unsigned long offset = 0;
1627 unsigned int rec_len, new_rec_len; 1836 unsigned int rec_len, new_rec_len, free_space = dir->i_sb->s_blocksize;
1837
1838 /*
1839 * This calculates how many free bytes we'd have in block zero, should
1840 * this function force expansion to an extent tree.
1841 */
1842 if (ocfs2_supports_dir_trailer(OCFS2_SB(sb)))
1843 free_space = ocfs2_dir_trailer_blk_off(sb) - i_size_read(dir);
1844 else
1845 free_space = dir->i_sb->s_blocksize - i_size_read(dir);
1628 1846
1629 de_buf = di->id2.i_data.id_data; 1847 de_buf = di->id2.i_data.id_data;
1630 limit = de_buf + i_size_read(dir); 1848 limit = de_buf + i_size_read(dir);
@@ -1641,6 +1859,11 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
1641 ret = -EEXIST; 1859 ret = -EEXIST;
1642 goto out; 1860 goto out;
1643 } 1861 }
1862 /*
1863 * No need to check for a trailing dirent record here as
1864 * they're not used for inline dirs.
1865 */
1866
1644 if (ocfs2_dirent_would_fit(de, rec_len)) { 1867 if (ocfs2_dirent_would_fit(de, rec_len)) {
1645 /* Ok, we found a spot. Return this bh and let 1868 /* Ok, we found a spot. Return this bh and let
1646 * the caller actually fill it in. */ 1869 * the caller actually fill it in. */
@@ -1661,7 +1884,7 @@ static int ocfs2_find_dir_space_id(struct inode *dir, struct buffer_head *di_bh,
1661 * dirent can be found. 1884 * dirent can be found.
1662 */ 1885 */
1663 *blocks_wanted = 1; 1886 *blocks_wanted = 1;
1664 new_rec_len = le16_to_cpu(last_de->rec_len) + (dir->i_sb->s_blocksize - i_size_read(dir)); 1887 new_rec_len = le16_to_cpu(last_de->rec_len) + free_space;
1665 if (new_rec_len < (rec_len + OCFS2_DIR_REC_LEN(last_de->name_len))) 1888 if (new_rec_len < (rec_len + OCFS2_DIR_REC_LEN(last_de->name_len)))
1666 *blocks_wanted = 2; 1889 *blocks_wanted = 2;
1667 1890
@@ -1679,9 +1902,10 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
1679 struct ocfs2_dir_entry *de; 1902 struct ocfs2_dir_entry *de;
1680 struct super_block *sb = dir->i_sb; 1903 struct super_block *sb = dir->i_sb;
1681 int status; 1904 int status;
1905 int blocksize = dir->i_sb->s_blocksize;
1682 1906
1683 bh = ocfs2_bread(dir, 0, &status, 0); 1907 status = ocfs2_read_dir_block(dir, 0, &bh, 0);
1684 if (!bh) { 1908 if (status) {
1685 mlog_errno(status); 1909 mlog_errno(status);
1686 goto bail; 1910 goto bail;
1687 } 1911 }
@@ -1702,11 +1926,10 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
1702 status = -ENOSPC; 1926 status = -ENOSPC;
1703 goto bail; 1927 goto bail;
1704 } 1928 }
1705 bh = ocfs2_bread(dir, 1929 status = ocfs2_read_dir_block(dir,
1706 offset >> sb->s_blocksize_bits, 1930 offset >> sb->s_blocksize_bits,
1707 &status, 1931 &bh, 0);
1708 0); 1932 if (status) {
1709 if (!bh) {
1710 mlog_errno(status); 1933 mlog_errno(status);
1711 goto bail; 1934 goto bail;
1712 } 1935 }
@@ -1721,6 +1944,11 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
1721 status = -EEXIST; 1944 status = -EEXIST;
1722 goto bail; 1945 goto bail;
1723 } 1946 }
1947
1948 if (ocfs2_skip_dir_trailer(dir, de, offset % blocksize,
1949 blocksize))
1950 goto next;
1951
1724 if (ocfs2_dirent_would_fit(de, rec_len)) { 1952 if (ocfs2_dirent_would_fit(de, rec_len)) {
1725 /* Ok, we found a spot. Return this bh and let 1953 /* Ok, we found a spot. Return this bh and let
1726 * the caller actually fill it in. */ 1954 * the caller actually fill it in. */
@@ -1729,6 +1957,7 @@ static int ocfs2_find_dir_space_el(struct inode *dir, const char *name,
1729 status = 0; 1957 status = 0;
1730 goto bail; 1958 goto bail;
1731 } 1959 }
1960next:
1732 offset += le16_to_cpu(de->rec_len); 1961 offset += le16_to_cpu(de->rec_len);
1733 de = (struct ocfs2_dir_entry *)((char *) de + le16_to_cpu(de->rec_len)); 1962 de = (struct ocfs2_dir_entry *)((char *) de + le16_to_cpu(de->rec_len));
1734 } 1963 }
diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h
index ce48b9080d87..c511e2e18e9f 100644
--- a/fs/ocfs2/dir.h
+++ b/fs/ocfs2/dir.h
@@ -83,4 +83,6 @@ int ocfs2_fill_new_dir(struct ocfs2_super *osb,
83 struct buffer_head *fe_bh, 83 struct buffer_head *fe_bh,
84 struct ocfs2_alloc_context *data_ac); 84 struct ocfs2_alloc_context *data_ac);
85 85
86struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
87 void *data);
86#endif /* OCFS2_DIR_H */ 88#endif /* OCFS2_DIR_H */
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index 644bee55d8ba..d07ddbe4b283 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -275,6 +275,7 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
275 struct list_head *iter, *head=NULL; 275 struct list_head *iter, *head=NULL;
276 u64 cookie; 276 u64 cookie;
277 u32 flags; 277 u32 flags;
278 u8 node;
278 279
279 if (!dlm_grab(dlm)) { 280 if (!dlm_grab(dlm)) {
280 dlm_error(DLM_REJECTED); 281 dlm_error(DLM_REJECTED);
@@ -286,18 +287,21 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
286 287
287 name = past->name; 288 name = past->name;
288 locklen = past->namelen; 289 locklen = past->namelen;
289 cookie = be64_to_cpu(past->cookie); 290 cookie = past->cookie;
290 flags = be32_to_cpu(past->flags); 291 flags = be32_to_cpu(past->flags);
292 node = past->node_idx;
291 293
292 if (locklen > DLM_LOCKID_NAME_MAX) { 294 if (locklen > DLM_LOCKID_NAME_MAX) {
293 ret = DLM_IVBUFLEN; 295 ret = DLM_IVBUFLEN;
294 mlog(ML_ERROR, "Invalid name length in proxy ast handler!\n"); 296 mlog(ML_ERROR, "Invalid name length (%d) in proxy ast "
297 "handler!\n", locklen);
295 goto leave; 298 goto leave;
296 } 299 }
297 300
298 if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) == 301 if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) ==
299 (LKM_PUT_LVB|LKM_GET_LVB)) { 302 (LKM_PUT_LVB|LKM_GET_LVB)) {
300 mlog(ML_ERROR, "both PUT and GET lvb specified\n"); 303 mlog(ML_ERROR, "Both PUT and GET lvb specified, (0x%x)\n",
304 flags);
301 ret = DLM_BADARGS; 305 ret = DLM_BADARGS;
302 goto leave; 306 goto leave;
303 } 307 }
@@ -310,22 +314,21 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
310 if (past->type != DLM_AST && 314 if (past->type != DLM_AST &&
311 past->type != DLM_BAST) { 315 past->type != DLM_BAST) {
312 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu" 316 mlog(ML_ERROR, "Unknown ast type! %d, cookie=%u:%llu"
313 "name=%.*s\n", past->type, 317 "name=%.*s, node=%u\n", past->type,
314 dlm_get_lock_cookie_node(cookie), 318 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
315 dlm_get_lock_cookie_seq(cookie), 319 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
316 locklen, name); 320 locklen, name, node);
317 ret = DLM_IVLOCKID; 321 ret = DLM_IVLOCKID;
318 goto leave; 322 goto leave;
319 } 323 }
320 324
321 res = dlm_lookup_lockres(dlm, name, locklen); 325 res = dlm_lookup_lockres(dlm, name, locklen);
322 if (!res) { 326 if (!res) {
323 mlog(0, "got %sast for unknown lockres! " 327 mlog(0, "Got %sast for unknown lockres! cookie=%u:%llu, "
324 "cookie=%u:%llu, name=%.*s, namelen=%u\n", 328 "name=%.*s, node=%u\n", (past->type == DLM_AST ? "" : "b"),
325 past->type == DLM_AST ? "" : "b", 329 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
326 dlm_get_lock_cookie_node(cookie), 330 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
327 dlm_get_lock_cookie_seq(cookie), 331 locklen, name, node);
328 locklen, name, locklen);
329 ret = DLM_IVLOCKID; 332 ret = DLM_IVLOCKID;
330 goto leave; 333 goto leave;
331 } 334 }
@@ -337,12 +340,12 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
337 340
338 spin_lock(&res->spinlock); 341 spin_lock(&res->spinlock);
339 if (res->state & DLM_LOCK_RES_RECOVERING) { 342 if (res->state & DLM_LOCK_RES_RECOVERING) {
340 mlog(0, "responding with DLM_RECOVERING!\n"); 343 mlog(0, "Responding with DLM_RECOVERING!\n");
341 ret = DLM_RECOVERING; 344 ret = DLM_RECOVERING;
342 goto unlock_out; 345 goto unlock_out;
343 } 346 }
344 if (res->state & DLM_LOCK_RES_MIGRATING) { 347 if (res->state & DLM_LOCK_RES_MIGRATING) {
345 mlog(0, "responding with DLM_MIGRATING!\n"); 348 mlog(0, "Responding with DLM_MIGRATING!\n");
346 ret = DLM_MIGRATING; 349 ret = DLM_MIGRATING;
347 goto unlock_out; 350 goto unlock_out;
348 } 351 }
@@ -351,7 +354,7 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
351 lock = NULL; 354 lock = NULL;
352 list_for_each(iter, head) { 355 list_for_each(iter, head) {
353 lock = list_entry (iter, struct dlm_lock, list); 356 lock = list_entry (iter, struct dlm_lock, list);
354 if (be64_to_cpu(lock->ml.cookie) == cookie) 357 if (lock->ml.cookie == cookie)
355 goto do_ast; 358 goto do_ast;
356 } 359 }
357 360
@@ -363,15 +366,15 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data,
363 366
364 list_for_each(iter, head) { 367 list_for_each(iter, head) {
365 lock = list_entry (iter, struct dlm_lock, list); 368 lock = list_entry (iter, struct dlm_lock, list);
366 if (be64_to_cpu(lock->ml.cookie) == cookie) 369 if (lock->ml.cookie == cookie)
367 goto do_ast; 370 goto do_ast;
368 } 371 }
369 372
370 mlog(0, "got %sast for unknown lock! cookie=%u:%llu, " 373 mlog(0, "Got %sast for unknown lock! cookie=%u:%llu, name=%.*s, "
371 "name=%.*s, namelen=%u\n", past->type == DLM_AST ? "" : "b", 374 "node=%u\n", past->type == DLM_AST ? "" : "b",
372 dlm_get_lock_cookie_node(cookie), 375 dlm_get_lock_cookie_node(be64_to_cpu(cookie)),
373 dlm_get_lock_cookie_seq(cookie), 376 dlm_get_lock_cookie_seq(be64_to_cpu(cookie)),
374 locklen, name, locklen); 377 locklen, name, node);
375 378
376 ret = DLM_NORMAL; 379 ret = DLM_NORMAL;
377unlock_out: 380unlock_out:
@@ -383,8 +386,8 @@ do_ast:
383 if (past->type == DLM_AST) { 386 if (past->type == DLM_AST) {
384 /* do not alter lock refcount. switching lists. */ 387 /* do not alter lock refcount. switching lists. */
385 list_move_tail(&lock->list, &res->granted); 388 list_move_tail(&lock->list, &res->granted);
386 mlog(0, "ast: adding to granted list... type=%d, " 389 mlog(0, "ast: Adding to granted list... type=%d, "
387 "convert_type=%d\n", lock->ml.type, lock->ml.convert_type); 390 "convert_type=%d\n", lock->ml.type, lock->ml.convert_type);
388 if (lock->ml.convert_type != LKM_IVMODE) { 391 if (lock->ml.convert_type != LKM_IVMODE) {
389 lock->ml.type = lock->ml.convert_type; 392 lock->ml.type = lock->ml.convert_type;
390 lock->ml.convert_type = LKM_IVMODE; 393 lock->ml.convert_type = LKM_IVMODE;
@@ -408,7 +411,6 @@ do_ast:
408 dlm_do_local_bast(dlm, res, lock, past->blocked_type); 411 dlm_do_local_bast(dlm, res, lock, past->blocked_type);
409 412
410leave: 413leave:
411
412 if (res) 414 if (res)
413 dlm_lockres_put(res); 415 dlm_lockres_put(res);
414 416
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index d5a86fb81a49..bb53714813ab 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -140,6 +140,7 @@ struct dlm_ctxt
140 unsigned int purge_count; 140 unsigned int purge_count;
141 spinlock_t spinlock; 141 spinlock_t spinlock;
142 spinlock_t ast_lock; 142 spinlock_t ast_lock;
143 spinlock_t track_lock;
143 char *name; 144 char *name;
144 u8 node_num; 145 u8 node_num;
145 u32 key; 146 u32 key;
@@ -316,6 +317,8 @@ struct dlm_lock_resource
316 * put on a list for the dlm thread to run. */ 317 * put on a list for the dlm thread to run. */
317 unsigned long last_used; 318 unsigned long last_used;
318 319
320 struct dlm_ctxt *dlm;
321
319 unsigned migration_pending:1; 322 unsigned migration_pending:1;
320 atomic_t asts_reserved; 323 atomic_t asts_reserved;
321 spinlock_t spinlock; 324 spinlock_t spinlock;
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 1b81dcba175d..b32f60a5acfb 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -630,43 +630,38 @@ static void *lockres_seq_start(struct seq_file *m, loff_t *pos)
630{ 630{
631 struct debug_lockres *dl = m->private; 631 struct debug_lockres *dl = m->private;
632 struct dlm_ctxt *dlm = dl->dl_ctxt; 632 struct dlm_ctxt *dlm = dl->dl_ctxt;
633 struct dlm_lock_resource *oldres = dl->dl_res;
633 struct dlm_lock_resource *res = NULL; 634 struct dlm_lock_resource *res = NULL;
635 struct list_head *track_list;
634 636
635 spin_lock(&dlm->spinlock); 637 spin_lock(&dlm->track_lock);
638 if (oldres)
639 track_list = &oldres->tracking;
640 else
641 track_list = &dlm->tracking_list;
636 642
637 if (dl->dl_res) { 643 list_for_each_entry(res, track_list, tracking) {
638 list_for_each_entry(res, &dl->dl_res->tracking, tracking) { 644 if (&res->tracking == &dlm->tracking_list)
639 if (dl->dl_res) { 645 res = NULL;
640 dlm_lockres_put(dl->dl_res); 646 else
641 dl->dl_res = NULL;
642 }
643 if (&res->tracking == &dlm->tracking_list) {
644 mlog(0, "End of list found, %p\n", res);
645 dl = NULL;
646 break;
647 }
648 dlm_lockres_get(res); 647 dlm_lockres_get(res);
649 dl->dl_res = res; 648 break;
650 break;
651 }
652 } else {
653 if (!list_empty(&dlm->tracking_list)) {
654 list_for_each_entry(res, &dlm->tracking_list, tracking)
655 break;
656 dlm_lockres_get(res);
657 dl->dl_res = res;
658 } else
659 dl = NULL;
660 } 649 }
650 spin_unlock(&dlm->track_lock);
661 651
662 if (dl) { 652 if (oldres)
663 spin_lock(&dl->dl_res->spinlock); 653 dlm_lockres_put(oldres);
664 dump_lockres(dl->dl_res, dl->dl_buf, dl->dl_len - 1);
665 spin_unlock(&dl->dl_res->spinlock);
666 }
667 654
668 spin_unlock(&dlm->spinlock); 655 dl->dl_res = res;
656
657 if (res) {
658 spin_lock(&res->spinlock);
659 dump_lockres(res, dl->dl_buf, dl->dl_len - 1);
660 spin_unlock(&res->spinlock);
661 } else
662 dl = NULL;
669 663
664 /* passed to seq_show */
670 return dl; 665 return dl;
671} 666}
672 667
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 63f8125824e8..d8d578f45613 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -1550,6 +1550,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1550 spin_lock_init(&dlm->spinlock); 1550 spin_lock_init(&dlm->spinlock);
1551 spin_lock_init(&dlm->master_lock); 1551 spin_lock_init(&dlm->master_lock);
1552 spin_lock_init(&dlm->ast_lock); 1552 spin_lock_init(&dlm->ast_lock);
1553 spin_lock_init(&dlm->track_lock);
1553 INIT_LIST_HEAD(&dlm->list); 1554 INIT_LIST_HEAD(&dlm->list);
1554 INIT_LIST_HEAD(&dlm->dirty_list); 1555 INIT_LIST_HEAD(&dlm->dirty_list);
1555 INIT_LIST_HEAD(&dlm->reco.resources); 1556 INIT_LIST_HEAD(&dlm->reco.resources);
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 6f7a77d54020..1c9efb406a96 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -341,7 +341,6 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
341 inode->i_mode = mode; 341 inode->i_mode = mode;
342 inode->i_uid = current_fsuid(); 342 inode->i_uid = current_fsuid();
343 inode->i_gid = current_fsgid(); 343 inode->i_gid = current_fsgid();
344 inode->i_blocks = 0;
345 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 344 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
346 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 345 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
347 inc_nlink(inode); 346 inc_nlink(inode);
@@ -367,7 +366,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
367 inode->i_mode = mode; 366 inode->i_mode = mode;
368 inode->i_uid = current_fsuid(); 367 inode->i_uid = current_fsuid();
369 inode->i_gid = current_fsgid(); 368 inode->i_gid = current_fsgid();
370 inode->i_blocks = 0;
371 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 369 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
372 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 370 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
373 371
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 44f87caf3683..54e182a27caf 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -505,8 +505,10 @@ void dlm_change_lockres_owner(struct dlm_ctxt *dlm,
505static void dlm_lockres_release(struct kref *kref) 505static void dlm_lockres_release(struct kref *kref)
506{ 506{
507 struct dlm_lock_resource *res; 507 struct dlm_lock_resource *res;
508 struct dlm_ctxt *dlm;
508 509
509 res = container_of(kref, struct dlm_lock_resource, refs); 510 res = container_of(kref, struct dlm_lock_resource, refs);
511 dlm = res->dlm;
510 512
511 /* This should not happen -- all lockres' have a name 513 /* This should not happen -- all lockres' have a name
512 * associated with them at init time. */ 514 * associated with them at init time. */
@@ -515,6 +517,7 @@ static void dlm_lockres_release(struct kref *kref)
515 mlog(0, "destroying lockres %.*s\n", res->lockname.len, 517 mlog(0, "destroying lockres %.*s\n", res->lockname.len,
516 res->lockname.name); 518 res->lockname.name);
517 519
520 spin_lock(&dlm->track_lock);
518 if (!list_empty(&res->tracking)) 521 if (!list_empty(&res->tracking))
519 list_del_init(&res->tracking); 522 list_del_init(&res->tracking);
520 else { 523 else {
@@ -522,6 +525,9 @@ static void dlm_lockres_release(struct kref *kref)
522 res->lockname.len, res->lockname.name); 525 res->lockname.len, res->lockname.name);
523 dlm_print_one_lock_resource(res); 526 dlm_print_one_lock_resource(res);
524 } 527 }
528 spin_unlock(&dlm->track_lock);
529
530 dlm_put(dlm);
525 531
526 if (!hlist_unhashed(&res->hash_node) || 532 if (!hlist_unhashed(&res->hash_node) ||
527 !list_empty(&res->granted) || 533 !list_empty(&res->granted) ||
@@ -595,6 +601,10 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm,
595 res->migration_pending = 0; 601 res->migration_pending = 0;
596 res->inflight_locks = 0; 602 res->inflight_locks = 0;
597 603
604 /* put in dlm_lockres_release */
605 dlm_grab(dlm);
606 res->dlm = dlm;
607
598 kref_init(&res->refs); 608 kref_init(&res->refs);
599 609
600 /* just for consistency */ 610 /* just for consistency */
@@ -722,14 +732,21 @@ lookup:
722 if (tmpres) { 732 if (tmpres) {
723 int dropping_ref = 0; 733 int dropping_ref = 0;
724 734
735 spin_unlock(&dlm->spinlock);
736
725 spin_lock(&tmpres->spinlock); 737 spin_lock(&tmpres->spinlock);
738 /* We wait for the other thread that is mastering the resource */
739 if (tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN) {
740 __dlm_wait_on_lockres(tmpres);
741 BUG_ON(tmpres->owner == DLM_LOCK_RES_OWNER_UNKNOWN);
742 }
743
726 if (tmpres->owner == dlm->node_num) { 744 if (tmpres->owner == dlm->node_num) {
727 BUG_ON(tmpres->state & DLM_LOCK_RES_DROPPING_REF); 745 BUG_ON(tmpres->state & DLM_LOCK_RES_DROPPING_REF);
728 dlm_lockres_grab_inflight_ref(dlm, tmpres); 746 dlm_lockres_grab_inflight_ref(dlm, tmpres);
729 } else if (tmpres->state & DLM_LOCK_RES_DROPPING_REF) 747 } else if (tmpres->state & DLM_LOCK_RES_DROPPING_REF)
730 dropping_ref = 1; 748 dropping_ref = 1;
731 spin_unlock(&tmpres->spinlock); 749 spin_unlock(&tmpres->spinlock);
732 spin_unlock(&dlm->spinlock);
733 750
734 /* wait until done messaging the master, drop our ref to allow 751 /* wait until done messaging the master, drop our ref to allow
735 * the lockres to be purged, start over. */ 752 * the lockres to be purged, start over. */
@@ -2949,7 +2966,7 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm,
2949 struct dlm_node_iter *iter) 2966 struct dlm_node_iter *iter)
2950{ 2967{
2951 struct dlm_migrate_request migrate; 2968 struct dlm_migrate_request migrate;
2952 int ret, status = 0; 2969 int ret, skip, status = 0;
2953 int nodenum; 2970 int nodenum;
2954 2971
2955 memset(&migrate, 0, sizeof(migrate)); 2972 memset(&migrate, 0, sizeof(migrate));
@@ -2966,12 +2983,27 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm,
2966 nodenum == new_master) 2983 nodenum == new_master)
2967 continue; 2984 continue;
2968 2985
2986 /* We could race exit domain. If exited, skip. */
2987 spin_lock(&dlm->spinlock);
2988 skip = (!test_bit(nodenum, dlm->domain_map));
2989 spin_unlock(&dlm->spinlock);
2990 if (skip) {
2991 clear_bit(nodenum, iter->node_map);
2992 continue;
2993 }
2994
2969 ret = o2net_send_message(DLM_MIGRATE_REQUEST_MSG, dlm->key, 2995 ret = o2net_send_message(DLM_MIGRATE_REQUEST_MSG, dlm->key,
2970 &migrate, sizeof(migrate), nodenum, 2996 &migrate, sizeof(migrate), nodenum,
2971 &status); 2997 &status);
2972 if (ret < 0) 2998 if (ret < 0) {
2973 mlog_errno(ret); 2999 mlog(0, "migrate_request returned %d!\n", ret);
2974 else if (status < 0) { 3000 if (!dlm_is_host_down(ret)) {
3001 mlog(ML_ERROR, "unhandled error=%d!\n", ret);
3002 BUG();
3003 }
3004 clear_bit(nodenum, iter->node_map);
3005 ret = 0;
3006 } else if (status < 0) {
2975 mlog(0, "migrate request (node %u) returned %d!\n", 3007 mlog(0, "migrate request (node %u) returned %d!\n",
2976 nodenum, status); 3008 nodenum, status);
2977 ret = status; 3009 ret = status;
diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
index 4060bb328bc8..d1295203029f 100644
--- a/fs/ocfs2/dlm/dlmthread.c
+++ b/fs/ocfs2/dlm/dlmthread.c
@@ -181,7 +181,8 @@ static int dlm_purge_lockres(struct dlm_ctxt *dlm,
181 181
182 spin_lock(&res->spinlock); 182 spin_lock(&res->spinlock);
183 /* This ensures that clear refmap is sent after the set */ 183 /* This ensures that clear refmap is sent after the set */
184 __dlm_wait_on_lockres_flags(res, DLM_LOCK_RES_SETREF_INPROG); 184 __dlm_wait_on_lockres_flags(res, (DLM_LOCK_RES_SETREF_INPROG |
185 DLM_LOCK_RES_MIGRATING));
185 spin_unlock(&res->spinlock); 186 spin_unlock(&res->spinlock);
186 187
187 /* clear our bit from the master's refmap, ignore errors */ 188 /* clear our bit from the master's refmap, ignore errors */
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 6e6cc0a2e5f7..f731ab491795 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -32,6 +32,7 @@
32#include <linux/debugfs.h> 32#include <linux/debugfs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/time.h> 34#include <linux/time.h>
35#include <linux/quotaops.h>
35 36
36#define MLOG_MASK_PREFIX ML_DLM_GLUE 37#define MLOG_MASK_PREFIX ML_DLM_GLUE
37#include <cluster/masklog.h> 38#include <cluster/masklog.h>
@@ -51,6 +52,7 @@
51#include "slot_map.h" 52#include "slot_map.h"
52#include "super.h" 53#include "super.h"
53#include "uptodate.h" 54#include "uptodate.h"
55#include "quota.h"
54 56
55#include "buffer_head_io.h" 57#include "buffer_head_io.h"
56 58
@@ -68,6 +70,7 @@ struct ocfs2_mask_waiter {
68static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres); 70static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
69static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres); 71static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);
70static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres); 72static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres);
73static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres);
71 74
72/* 75/*
73 * Return value from ->downconvert_worker functions. 76 * Return value from ->downconvert_worker functions.
@@ -102,6 +105,7 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
102static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb, 105static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
103 struct ocfs2_lock_res *lockres); 106 struct ocfs2_lock_res *lockres);
104 107
108static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres);
105 109
106#define mlog_meta_lvb(__level, __lockres) ocfs2_dump_meta_lvb_info(__level, __PRETTY_FUNCTION__, __LINE__, __lockres) 110#define mlog_meta_lvb(__level, __lockres) ocfs2_dump_meta_lvb_info(__level, __PRETTY_FUNCTION__, __LINE__, __lockres)
107 111
@@ -111,8 +115,7 @@ static void ocfs2_dump_meta_lvb_info(u64 level,
111 unsigned int line, 115 unsigned int line,
112 struct ocfs2_lock_res *lockres) 116 struct ocfs2_lock_res *lockres)
113{ 117{
114 struct ocfs2_meta_lvb *lvb = 118 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
115 (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb);
116 119
117 mlog(level, "LVB information for %s (called from %s:%u):\n", 120 mlog(level, "LVB information for %s (called from %s:%u):\n",
118 lockres->l_name, function, line); 121 lockres->l_name, function, line);
@@ -258,6 +261,12 @@ static struct ocfs2_lock_res_ops ocfs2_flock_lops = {
258 .flags = 0, 261 .flags = 0,
259}; 262};
260 263
264static struct ocfs2_lock_res_ops ocfs2_qinfo_lops = {
265 .set_lvb = ocfs2_set_qinfo_lvb,
266 .get_osb = ocfs2_get_qinfo_osb,
267 .flags = LOCK_TYPE_REQUIRES_REFRESH | LOCK_TYPE_USES_LVB,
268};
269
261static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) 270static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres)
262{ 271{
263 return lockres->l_type == OCFS2_LOCK_TYPE_META || 272 return lockres->l_type == OCFS2_LOCK_TYPE_META ||
@@ -279,6 +288,13 @@ static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res
279 return (struct ocfs2_dentry_lock *)lockres->l_priv; 288 return (struct ocfs2_dentry_lock *)lockres->l_priv;
280} 289}
281 290
291static inline struct ocfs2_mem_dqinfo *ocfs2_lock_res_qinfo(struct ocfs2_lock_res *lockres)
292{
293 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_QINFO);
294
295 return (struct ocfs2_mem_dqinfo *)lockres->l_priv;
296}
297
282static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres) 298static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres)
283{ 299{
284 if (lockres->l_ops->get_osb) 300 if (lockres->l_ops->get_osb)
@@ -507,6 +523,13 @@ static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres)
507 return OCFS2_SB(inode->i_sb); 523 return OCFS2_SB(inode->i_sb);
508} 524}
509 525
526static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres)
527{
528 struct ocfs2_mem_dqinfo *info = lockres->l_priv;
529
530 return OCFS2_SB(info->dqi_gi.dqi_sb);
531}
532
510static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres) 533static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres)
511{ 534{
512 struct ocfs2_file_private *fp = lockres->l_priv; 535 struct ocfs2_file_private *fp = lockres->l_priv;
@@ -609,6 +632,17 @@ void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres,
609 lockres->l_flags |= OCFS2_LOCK_NOCACHE; 632 lockres->l_flags |= OCFS2_LOCK_NOCACHE;
610} 633}
611 634
635void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres,
636 struct ocfs2_mem_dqinfo *info)
637{
638 ocfs2_lock_res_init_once(lockres);
639 ocfs2_build_lock_name(OCFS2_LOCK_TYPE_QINFO, info->dqi_gi.dqi_type,
640 0, lockres->l_name);
641 ocfs2_lock_res_init_common(OCFS2_SB(info->dqi_gi.dqi_sb), lockres,
642 OCFS2_LOCK_TYPE_QINFO, &ocfs2_qinfo_lops,
643 info);
644}
645
612void ocfs2_lock_res_free(struct ocfs2_lock_res *res) 646void ocfs2_lock_res_free(struct ocfs2_lock_res *res)
613{ 647{
614 mlog_entry_void(); 648 mlog_entry_void();
@@ -1829,7 +1863,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
1829 1863
1830 mlog_entry_void(); 1864 mlog_entry_void();
1831 1865
1832 lvb = (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); 1866 lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
1833 1867
1834 /* 1868 /*
1835 * Invalidate the LVB of a deleted inode - this way other 1869 * Invalidate the LVB of a deleted inode - this way other
@@ -1881,7 +1915,7 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
1881 1915
1882 mlog_meta_lvb(0, lockres); 1916 mlog_meta_lvb(0, lockres);
1883 1917
1884 lvb = (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb); 1918 lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
1885 1919
1886 /* We're safe here without the lockres lock... */ 1920 /* We're safe here without the lockres lock... */
1887 spin_lock(&oi->ip_lock); 1921 spin_lock(&oi->ip_lock);
@@ -1916,8 +1950,7 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
1916static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode, 1950static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode,
1917 struct ocfs2_lock_res *lockres) 1951 struct ocfs2_lock_res *lockres)
1918{ 1952{
1919 struct ocfs2_meta_lvb *lvb = 1953 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
1920 (struct ocfs2_meta_lvb *)ocfs2_dlm_lvb(&lockres->l_lksb);
1921 1954
1922 if (lvb->lvb_version == OCFS2_LVB_VERSION 1955 if (lvb->lvb_version == OCFS2_LVB_VERSION
1923 && be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation) 1956 && be32_to_cpu(lvb->lvb_igeneration) == inode->i_generation)
@@ -2024,7 +2057,7 @@ static int ocfs2_inode_lock_update(struct inode *inode,
2024 } else { 2057 } else {
2025 /* Boo, we have to go to disk. */ 2058 /* Boo, we have to go to disk. */
2026 /* read bh, cast, ocfs2_refresh_inode */ 2059 /* read bh, cast, ocfs2_refresh_inode */
2027 status = ocfs2_read_block(inode, oi->ip_blkno, bh); 2060 status = ocfs2_read_inode_block(inode, bh);
2028 if (status < 0) { 2061 if (status < 0) {
2029 mlog_errno(status); 2062 mlog_errno(status);
2030 goto bail_refresh; 2063 goto bail_refresh;
@@ -2032,18 +2065,14 @@ static int ocfs2_inode_lock_update(struct inode *inode,
2032 fe = (struct ocfs2_dinode *) (*bh)->b_data; 2065 fe = (struct ocfs2_dinode *) (*bh)->b_data;
2033 2066
2034 /* This is a good chance to make sure we're not 2067 /* This is a good chance to make sure we're not
2035 * locking an invalid object. 2068 * locking an invalid object. ocfs2_read_inode_block()
2069 * already checked that the inode block is sane.
2036 * 2070 *
2037 * We bug on a stale inode here because we checked 2071 * We bug on a stale inode here because we checked
2038 * above whether it was wiped from disk. The wiping 2072 * above whether it was wiped from disk. The wiping
2039 * node provides a guarantee that we receive that 2073 * node provides a guarantee that we receive that
2040 * message and can mark the inode before dropping any 2074 * message and can mark the inode before dropping any
2041 * locks associated with it. */ 2075 * locks associated with it. */
2042 if (!OCFS2_IS_VALID_DINODE(fe)) {
2043 OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe);
2044 status = -EIO;
2045 goto bail_refresh;
2046 }
2047 mlog_bug_on_msg(inode->i_generation != 2076 mlog_bug_on_msg(inode->i_generation !=
2048 le32_to_cpu(fe->i_generation), 2077 le32_to_cpu(fe->i_generation),
2049 "Invalid dinode %llu disk generation: %u " 2078 "Invalid dinode %llu disk generation: %u "
@@ -2085,7 +2114,7 @@ static int ocfs2_assign_bh(struct inode *inode,
2085 return 0; 2114 return 0;
2086 } 2115 }
2087 2116
2088 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, ret_bh); 2117 status = ocfs2_read_inode_block(inode, ret_bh);
2089 if (status < 0) 2118 if (status < 0)
2090 mlog_errno(status); 2119 mlog_errno(status);
2091 2120
@@ -3449,6 +3478,117 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
3449 return UNBLOCK_CONTINUE_POST; 3478 return UNBLOCK_CONTINUE_POST;
3450} 3479}
3451 3480
3481static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres)
3482{
3483 struct ocfs2_qinfo_lvb *lvb;
3484 struct ocfs2_mem_dqinfo *oinfo = ocfs2_lock_res_qinfo(lockres);
3485 struct mem_dqinfo *info = sb_dqinfo(oinfo->dqi_gi.dqi_sb,
3486 oinfo->dqi_gi.dqi_type);
3487
3488 mlog_entry_void();
3489
3490 lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
3491 lvb->lvb_version = OCFS2_QINFO_LVB_VERSION;
3492 lvb->lvb_bgrace = cpu_to_be32(info->dqi_bgrace);
3493 lvb->lvb_igrace = cpu_to_be32(info->dqi_igrace);
3494 lvb->lvb_syncms = cpu_to_be32(oinfo->dqi_syncms);
3495 lvb->lvb_blocks = cpu_to_be32(oinfo->dqi_gi.dqi_blocks);
3496 lvb->lvb_free_blk = cpu_to_be32(oinfo->dqi_gi.dqi_free_blk);
3497 lvb->lvb_free_entry = cpu_to_be32(oinfo->dqi_gi.dqi_free_entry);
3498
3499 mlog_exit_void();
3500}
3501
3502void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex)
3503{
3504 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock;
3505 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
3506 int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
3507
3508 mlog_entry_void();
3509 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
3510 ocfs2_cluster_unlock(osb, lockres, level);
3511 mlog_exit_void();
3512}
3513
3514static int ocfs2_refresh_qinfo(struct ocfs2_mem_dqinfo *oinfo)
3515{
3516 struct mem_dqinfo *info = sb_dqinfo(oinfo->dqi_gi.dqi_sb,
3517 oinfo->dqi_gi.dqi_type);
3518 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock;
3519 struct ocfs2_qinfo_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
3520 struct buffer_head *bh = NULL;
3521 struct ocfs2_global_disk_dqinfo *gdinfo;
3522 int status = 0;
3523
3524 if (lvb->lvb_version == OCFS2_QINFO_LVB_VERSION) {
3525 info->dqi_bgrace = be32_to_cpu(lvb->lvb_bgrace);
3526 info->dqi_igrace = be32_to_cpu(lvb->lvb_igrace);
3527 oinfo->dqi_syncms = be32_to_cpu(lvb->lvb_syncms);
3528 oinfo->dqi_gi.dqi_blocks = be32_to_cpu(lvb->lvb_blocks);
3529 oinfo->dqi_gi.dqi_free_blk = be32_to_cpu(lvb->lvb_free_blk);
3530 oinfo->dqi_gi.dqi_free_entry =
3531 be32_to_cpu(lvb->lvb_free_entry);
3532 } else {
3533 status = ocfs2_read_quota_block(oinfo->dqi_gqinode, 0, &bh);
3534 if (status) {
3535 mlog_errno(status);
3536 goto bail;
3537 }
3538 gdinfo = (struct ocfs2_global_disk_dqinfo *)
3539 (bh->b_data + OCFS2_GLOBAL_INFO_OFF);
3540 info->dqi_bgrace = le32_to_cpu(gdinfo->dqi_bgrace);
3541 info->dqi_igrace = le32_to_cpu(gdinfo->dqi_igrace);
3542 oinfo->dqi_syncms = le32_to_cpu(gdinfo->dqi_syncms);
3543 oinfo->dqi_gi.dqi_blocks = le32_to_cpu(gdinfo->dqi_blocks);
3544 oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(gdinfo->dqi_free_blk);
3545 oinfo->dqi_gi.dqi_free_entry =
3546 le32_to_cpu(gdinfo->dqi_free_entry);
3547 brelse(bh);
3548 ocfs2_track_lock_refresh(lockres);
3549 }
3550
3551bail:
3552 return status;
3553}
3554
3555/* Lock quota info, this function expects at least shared lock on the quota file
3556 * so that we can safely refresh quota info from disk. */
3557int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex)
3558{
3559 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock;
3560 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
3561 int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
3562 int status = 0;
3563
3564 mlog_entry_void();
3565
3566 /* On RO devices, locking really isn't needed... */
3567 if (ocfs2_is_hard_readonly(osb)) {
3568 if (ex)
3569 status = -EROFS;
3570 goto bail;
3571 }
3572 if (ocfs2_mount_local(osb))
3573 goto bail;
3574
3575 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
3576 if (status < 0) {
3577 mlog_errno(status);
3578 goto bail;
3579 }
3580 if (!ocfs2_should_refresh_lock_res(lockres))
3581 goto bail;
3582 /* OK, we have the lock but we need to refresh the quota info */
3583 status = ocfs2_refresh_qinfo(oinfo);
3584 if (status)
3585 ocfs2_qinfo_unlock(oinfo, ex);
3586 ocfs2_complete_lock_res_refresh(lockres, status);
3587bail:
3588 mlog_exit(status);
3589 return status;
3590}
3591
3452/* 3592/*
3453 * This is the filesystem locking protocol. It provides the lock handling 3593 * This is the filesystem locking protocol. It provides the lock handling
3454 * hooks for the underlying DLM. It has a maximum version number. 3594 * hooks for the underlying DLM. It has a maximum version number.
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index 2bb01f09c1b1..3f8d9986b8e0 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -49,6 +49,19 @@ struct ocfs2_meta_lvb {
49 __be32 lvb_reserved2; 49 __be32 lvb_reserved2;
50}; 50};
51 51
52#define OCFS2_QINFO_LVB_VERSION 1
53
54struct ocfs2_qinfo_lvb {
55 __u8 lvb_version;
56 __u8 lvb_reserved[3];
57 __be32 lvb_bgrace;
58 __be32 lvb_igrace;
59 __be32 lvb_syncms;
60 __be32 lvb_blocks;
61 __be32 lvb_free_blk;
62 __be32 lvb_free_entry;
63};
64
52/* ocfs2_inode_lock_full() 'arg_flags' flags */ 65/* ocfs2_inode_lock_full() 'arg_flags' flags */
53/* don't wait on recovery. */ 66/* don't wait on recovery. */
54#define OCFS2_META_LOCK_RECOVERY (0x01) 67#define OCFS2_META_LOCK_RECOVERY (0x01)
@@ -69,6 +82,9 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,
69struct ocfs2_file_private; 82struct ocfs2_file_private;
70void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, 83void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres,
71 struct ocfs2_file_private *fp); 84 struct ocfs2_file_private *fp);
85struct ocfs2_mem_dqinfo;
86void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres,
87 struct ocfs2_mem_dqinfo *info);
72void ocfs2_lock_res_free(struct ocfs2_lock_res *res); 88void ocfs2_lock_res_free(struct ocfs2_lock_res *res);
73int ocfs2_create_new_inode_locks(struct inode *inode); 89int ocfs2_create_new_inode_locks(struct inode *inode);
74int ocfs2_drop_inode_locks(struct inode *inode); 90int ocfs2_drop_inode_locks(struct inode *inode);
@@ -103,6 +119,9 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex);
103void ocfs2_dentry_unlock(struct dentry *dentry, int ex); 119void ocfs2_dentry_unlock(struct dentry *dentry, int ex);
104int ocfs2_file_lock(struct file *file, int ex, int trylock); 120int ocfs2_file_lock(struct file *file, int ex, int trylock);
105void ocfs2_file_unlock(struct file *file); 121void ocfs2_file_unlock(struct file *file);
122int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex);
123void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex);
124
106 125
107void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres); 126void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres);
108void ocfs2_simple_drop_lockres(struct ocfs2_super *osb, 127void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index 2baedac58234..f2bb1a04d253 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -293,7 +293,7 @@ static int ocfs2_last_eb_is_empty(struct inode *inode,
293 struct ocfs2_extent_block *eb; 293 struct ocfs2_extent_block *eb;
294 struct ocfs2_extent_list *el; 294 struct ocfs2_extent_list *el;
295 295
296 ret = ocfs2_read_block(inode, last_eb_blk, &eb_bh); 296 ret = ocfs2_read_extent_block(inode, last_eb_blk, &eb_bh);
297 if (ret) { 297 if (ret) {
298 mlog_errno(ret); 298 mlog_errno(ret);
299 goto out; 299 goto out;
@@ -302,12 +302,6 @@ static int ocfs2_last_eb_is_empty(struct inode *inode,
302 eb = (struct ocfs2_extent_block *) eb_bh->b_data; 302 eb = (struct ocfs2_extent_block *) eb_bh->b_data;
303 el = &eb->h_list; 303 el = &eb->h_list;
304 304
305 if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) {
306 ret = -EROFS;
307 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb);
308 goto out;
309 }
310
311 if (el->l_tree_depth) { 305 if (el->l_tree_depth) {
312 ocfs2_error(inode->i_sb, 306 ocfs2_error(inode->i_sb,
313 "Inode %lu has non zero tree depth in " 307 "Inode %lu has non zero tree depth in "
@@ -381,23 +375,16 @@ static int ocfs2_figure_hole_clusters(struct inode *inode,
381 if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL) 375 if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL)
382 goto no_more_extents; 376 goto no_more_extents;
383 377
384 ret = ocfs2_read_block(inode, 378 ret = ocfs2_read_extent_block(inode,
385 le64_to_cpu(eb->h_next_leaf_blk), 379 le64_to_cpu(eb->h_next_leaf_blk),
386 &next_eb_bh); 380 &next_eb_bh);
387 if (ret) { 381 if (ret) {
388 mlog_errno(ret); 382 mlog_errno(ret);
389 goto out; 383 goto out;
390 } 384 }
391 next_eb = (struct ocfs2_extent_block *)next_eb_bh->b_data;
392
393 if (!OCFS2_IS_VALID_EXTENT_BLOCK(next_eb)) {
394 ret = -EROFS;
395 OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, next_eb);
396 goto out;
397 }
398 385
386 next_eb = (struct ocfs2_extent_block *)next_eb_bh->b_data;
399 el = &next_eb->h_list; 387 el = &next_eb->h_list;
400
401 i = ocfs2_search_for_hole_index(el, v_cluster); 388 i = ocfs2_search_for_hole_index(el, v_cluster);
402 } 389 }
403 390
@@ -630,7 +617,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
630 if (ret == 0) 617 if (ret == 0)
631 goto out; 618 goto out;
632 619
633 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &di_bh); 620 ret = ocfs2_read_inode_block(inode, &di_bh);
634 if (ret) { 621 if (ret) {
635 mlog_errno(ret); 622 mlog_errno(ret);
636 goto out; 623 goto out;
@@ -819,3 +806,74 @@ out:
819 806
820 return ret; 807 return ret;
821} 808}
809
810int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
811 struct buffer_head *bhs[], int flags,
812 int (*validate)(struct super_block *sb,
813 struct buffer_head *bh))
814{
815 int rc = 0;
816 u64 p_block, p_count;
817 int i, count, done = 0;
818
819 mlog_entry("(inode = %p, v_block = %llu, nr = %d, bhs = %p, "
820 "flags = %x, validate = %p)\n",
821 inode, (unsigned long long)v_block, nr, bhs, flags,
822 validate);
823
824 if (((v_block + nr - 1) << inode->i_sb->s_blocksize_bits) >=
825 i_size_read(inode)) {
826 BUG_ON(!(flags & OCFS2_BH_READAHEAD));
827 goto out;
828 }
829
830 while (done < nr) {
831 down_read(&OCFS2_I(inode)->ip_alloc_sem);
832 rc = ocfs2_extent_map_get_blocks(inode, v_block + done,
833 &p_block, &p_count, NULL);
834 up_read(&OCFS2_I(inode)->ip_alloc_sem);
835 if (rc) {
836 mlog_errno(rc);
837 break;
838 }
839
840 if (!p_block) {
841 rc = -EIO;
842 mlog(ML_ERROR,
843 "Inode #%llu contains a hole at offset %llu\n",
844 (unsigned long long)OCFS2_I(inode)->ip_blkno,
845 (unsigned long long)(v_block + done) <<
846 inode->i_sb->s_blocksize_bits);
847 break;
848 }
849
850 count = nr - done;
851 if (p_count < count)
852 count = p_count;
853
854 /*
855 * If the caller passed us bhs, they should have come
856 * from a previous readahead call to this function. Thus,
857 * they should have the right b_blocknr.
858 */
859 for (i = 0; i < count; i++) {
860 if (!bhs[done + i])
861 continue;
862 BUG_ON(bhs[done + i]->b_blocknr != (p_block + i));
863 }
864
865 rc = ocfs2_read_blocks(inode, p_block, count, bhs + done,
866 flags, validate);
867 if (rc) {
868 mlog_errno(rc);
869 break;
870 }
871 done += count;
872 }
873
874out:
875 mlog_exit(rc);
876 return rc;
877}
878
879
diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h
index 1c4aa8b06f34..b7dd9731b462 100644
--- a/fs/ocfs2/extent_map.h
+++ b/fs/ocfs2/extent_map.h
@@ -57,4 +57,28 @@ int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
57 u32 *p_cluster, u32 *num_clusters, 57 u32 *p_cluster, u32 *num_clusters,
58 struct ocfs2_extent_list *el); 58 struct ocfs2_extent_list *el);
59 59
60int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
61 struct buffer_head *bhs[], int flags,
62 int (*validate)(struct super_block *sb,
63 struct buffer_head *bh));
64static inline int ocfs2_read_virt_block(struct inode *inode, u64 v_block,
65 struct buffer_head **bh,
66 int (*validate)(struct super_block *sb,
67 struct buffer_head *bh))
68{
69 int status = 0;
70
71 if (bh == NULL) {
72 printk("ocfs2: bh == NULL\n");
73 status = -EINVAL;
74 goto bail;
75 }
76
77 status = ocfs2_read_virt_blocks(inode, v_block, 1, bh, 0, validate);
78
79bail:
80 return status;
81}
82
83
60#endif /* _EXTENT_MAP_H */ 84#endif /* _EXTENT_MAP_H */
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index e2570a3bc2b2..e8f795f978aa 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -35,6 +35,7 @@
35#include <linux/mount.h> 35#include <linux/mount.h>
36#include <linux/writeback.h> 36#include <linux/writeback.h>
37#include <linux/falloc.h> 37#include <linux/falloc.h>
38#include <linux/quotaops.h>
38 39
39#define MLOG_MASK_PREFIX ML_INODE 40#define MLOG_MASK_PREFIX ML_INODE
40#include <cluster/masklog.h> 41#include <cluster/masklog.h>
@@ -56,6 +57,8 @@
56#include "suballoc.h" 57#include "suballoc.h"
57#include "super.h" 58#include "super.h"
58#include "xattr.h" 59#include "xattr.h"
60#include "acl.h"
61#include "quota.h"
59 62
60#include "buffer_head_io.h" 63#include "buffer_head_io.h"
61 64
@@ -253,8 +256,8 @@ int ocfs2_update_inode_atime(struct inode *inode,
253 goto out; 256 goto out;
254 } 257 }
255 258
256 ret = ocfs2_journal_access(handle, inode, bh, 259 ret = ocfs2_journal_access_di(handle, inode, bh,
257 OCFS2_JOURNAL_ACCESS_WRITE); 260 OCFS2_JOURNAL_ACCESS_WRITE);
258 if (ret) { 261 if (ret) {
259 mlog_errno(ret); 262 mlog_errno(ret);
260 goto out_commit; 263 goto out_commit;
@@ -303,9 +306,9 @@ bail:
303 return status; 306 return status;
304} 307}
305 308
306static int ocfs2_simple_size_update(struct inode *inode, 309int ocfs2_simple_size_update(struct inode *inode,
307 struct buffer_head *di_bh, 310 struct buffer_head *di_bh,
308 u64 new_i_size) 311 u64 new_i_size)
309{ 312{
310 int ret; 313 int ret;
311 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 314 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
@@ -350,8 +353,8 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
350 goto out; 353 goto out;
351 } 354 }
352 355
353 status = ocfs2_journal_access(handle, inode, fe_bh, 356 status = ocfs2_journal_access_di(handle, inode, fe_bh,
354 OCFS2_JOURNAL_ACCESS_WRITE); 357 OCFS2_JOURNAL_ACCESS_WRITE);
355 if (status < 0) { 358 if (status < 0) {
356 mlog_errno(status); 359 mlog_errno(status);
357 goto out_commit; 360 goto out_commit;
@@ -401,12 +404,9 @@ static int ocfs2_truncate_file(struct inode *inode,
401 (unsigned long long)OCFS2_I(inode)->ip_blkno, 404 (unsigned long long)OCFS2_I(inode)->ip_blkno,
402 (unsigned long long)new_i_size); 405 (unsigned long long)new_i_size);
403 406
407 /* We trust di_bh because it comes from ocfs2_inode_lock(), which
408 * already validated it */
404 fe = (struct ocfs2_dinode *) di_bh->b_data; 409 fe = (struct ocfs2_dinode *) di_bh->b_data;
405 if (!OCFS2_IS_VALID_DINODE(fe)) {
406 OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe);
407 status = -EIO;
408 goto bail;
409 }
410 410
411 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), 411 mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode),
412 "Inode %llu, inode i_size = %lld != di " 412 "Inode %llu, inode i_size = %lld != di "
@@ -536,6 +536,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
536 enum ocfs2_alloc_restarted why; 536 enum ocfs2_alloc_restarted why;
537 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 537 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
538 struct ocfs2_extent_tree et; 538 struct ocfs2_extent_tree et;
539 int did_quota = 0;
539 540
540 mlog_entry("(clusters_to_add = %u)\n", clusters_to_add); 541 mlog_entry("(clusters_to_add = %u)\n", clusters_to_add);
541 542
@@ -545,18 +546,12 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
545 */ 546 */
546 BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb)); 547 BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb));
547 548
548 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, &bh); 549 status = ocfs2_read_inode_block(inode, &bh);
549 if (status < 0) { 550 if (status < 0) {
550 mlog_errno(status); 551 mlog_errno(status);
551 goto leave; 552 goto leave;
552 } 553 }
553
554 fe = (struct ocfs2_dinode *) bh->b_data; 554 fe = (struct ocfs2_dinode *) bh->b_data;
555 if (!OCFS2_IS_VALID_DINODE(fe)) {
556 OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe);
557 status = -EIO;
558 goto leave;
559 }
560 555
561restart_all: 556restart_all:
562 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); 557 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters);
@@ -585,11 +580,18 @@ restart_all:
585 } 580 }
586 581
587restarted_transaction: 582restarted_transaction:
583 if (vfs_dq_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb,
584 clusters_to_add))) {
585 status = -EDQUOT;
586 goto leave;
587 }
588 did_quota = 1;
589
588 /* reserve a write to the file entry early on - that we if we 590 /* reserve a write to the file entry early on - that we if we
589 * run out of credits in the allocation path, we can still 591 * run out of credits in the allocation path, we can still
590 * update i_size. */ 592 * update i_size. */
591 status = ocfs2_journal_access(handle, inode, bh, 593 status = ocfs2_journal_access_di(handle, inode, bh,
592 OCFS2_JOURNAL_ACCESS_WRITE); 594 OCFS2_JOURNAL_ACCESS_WRITE);
593 if (status < 0) { 595 if (status < 0) {
594 mlog_errno(status); 596 mlog_errno(status);
595 goto leave; 597 goto leave;
@@ -622,6 +624,10 @@ restarted_transaction:
622 spin_lock(&OCFS2_I(inode)->ip_lock); 624 spin_lock(&OCFS2_I(inode)->ip_lock);
623 clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); 625 clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters);
624 spin_unlock(&OCFS2_I(inode)->ip_lock); 626 spin_unlock(&OCFS2_I(inode)->ip_lock);
627 /* Release unused quota reservation */
628 vfs_dq_free_space(inode,
629 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
630 did_quota = 0;
625 631
626 if (why != RESTART_NONE && clusters_to_add) { 632 if (why != RESTART_NONE && clusters_to_add) {
627 if (why == RESTART_META) { 633 if (why == RESTART_META) {
@@ -654,6 +660,9 @@ restarted_transaction:
654 OCFS2_I(inode)->ip_clusters, (long long)i_size_read(inode)); 660 OCFS2_I(inode)->ip_clusters, (long long)i_size_read(inode));
655 661
656leave: 662leave:
663 if (status < 0 && did_quota)
664 vfs_dq_free_space(inode,
665 ocfs2_clusters_to_bytes(osb->sb, clusters_to_add));
657 if (handle) { 666 if (handle) {
658 ocfs2_commit_trans(osb, handle); 667 ocfs2_commit_trans(osb, handle);
659 handle = NULL; 668 handle = NULL;
@@ -885,6 +894,9 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
885 struct ocfs2_super *osb = OCFS2_SB(sb); 894 struct ocfs2_super *osb = OCFS2_SB(sb);
886 struct buffer_head *bh = NULL; 895 struct buffer_head *bh = NULL;
887 handle_t *handle = NULL; 896 handle_t *handle = NULL;
897 int locked[MAXQUOTAS] = {0, 0};
898 int credits, qtype;
899 struct ocfs2_mem_dqinfo *oinfo;
888 900
889 mlog_entry("(0x%p, '%.*s')\n", dentry, 901 mlog_entry("(0x%p, '%.*s')\n", dentry,
890 dentry->d_name.len, dentry->d_name.name); 902 dentry->d_name.len, dentry->d_name.name);
@@ -955,11 +967,47 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
955 } 967 }
956 } 968 }
957 969
958 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); 970 if ((attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
959 if (IS_ERR(handle)) { 971 (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
960 status = PTR_ERR(handle); 972 credits = OCFS2_INODE_UPDATE_CREDITS;
961 mlog_errno(status); 973 if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
962 goto bail_unlock; 974 && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
975 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
976 oinfo = sb_dqinfo(sb, USRQUOTA)->dqi_priv;
977 status = ocfs2_lock_global_qf(oinfo, 1);
978 if (status < 0)
979 goto bail_unlock;
980 credits += ocfs2_calc_qinit_credits(sb, USRQUOTA) +
981 ocfs2_calc_qdel_credits(sb, USRQUOTA);
982 locked[USRQUOTA] = 1;
983 }
984 if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid
985 && OCFS2_HAS_RO_COMPAT_FEATURE(sb,
986 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
987 oinfo = sb_dqinfo(sb, GRPQUOTA)->dqi_priv;
988 status = ocfs2_lock_global_qf(oinfo, 1);
989 if (status < 0)
990 goto bail_unlock;
991 credits += ocfs2_calc_qinit_credits(sb, GRPQUOTA) +
992 ocfs2_calc_qdel_credits(sb, GRPQUOTA);
993 locked[GRPQUOTA] = 1;
994 }
995 handle = ocfs2_start_trans(osb, credits);
996 if (IS_ERR(handle)) {
997 status = PTR_ERR(handle);
998 mlog_errno(status);
999 goto bail_unlock;
1000 }
1001 status = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
1002 if (status < 0)
1003 goto bail_commit;
1004 } else {
1005 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
1006 if (IS_ERR(handle)) {
1007 status = PTR_ERR(handle);
1008 mlog_errno(status);
1009 goto bail_unlock;
1010 }
963 } 1011 }
964 1012
965 /* 1013 /*
@@ -982,6 +1030,12 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
982bail_commit: 1030bail_commit:
983 ocfs2_commit_trans(osb, handle); 1031 ocfs2_commit_trans(osb, handle);
984bail_unlock: 1032bail_unlock:
1033 for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
1034 if (!locked[qtype])
1035 continue;
1036 oinfo = sb_dqinfo(sb, qtype)->dqi_priv;
1037 ocfs2_unlock_global_qf(oinfo, 1);
1038 }
985 ocfs2_inode_unlock(inode, 1); 1039 ocfs2_inode_unlock(inode, 1);
986bail_unlock_rw: 1040bail_unlock_rw:
987 if (size_change) 1041 if (size_change)
@@ -989,6 +1043,12 @@ bail_unlock_rw:
989bail: 1043bail:
990 brelse(bh); 1044 brelse(bh);
991 1045
1046 if (!status && attr->ia_valid & ATTR_MODE) {
1047 status = ocfs2_acl_chmod(inode);
1048 if (status < 0)
1049 mlog_errno(status);
1050 }
1051
992 mlog_exit(status); 1052 mlog_exit(status);
993 return status; 1053 return status;
994} 1054}
@@ -1035,7 +1095,7 @@ int ocfs2_permission(struct inode *inode, int mask)
1035 goto out; 1095 goto out;
1036 } 1096 }
1037 1097
1038 ret = generic_permission(inode, mask, NULL); 1098 ret = generic_permission(inode, mask, ocfs2_check_acl);
1039 1099
1040 ocfs2_inode_unlock(inode, 0); 1100 ocfs2_inode_unlock(inode, 0);
1041out: 1101out:
@@ -1061,8 +1121,8 @@ static int __ocfs2_write_remove_suid(struct inode *inode,
1061 goto out; 1121 goto out;
1062 } 1122 }
1063 1123
1064 ret = ocfs2_journal_access(handle, inode, bh, 1124 ret = ocfs2_journal_access_di(handle, inode, bh,
1065 OCFS2_JOURNAL_ACCESS_WRITE); 1125 OCFS2_JOURNAL_ACCESS_WRITE);
1066 if (ret < 0) { 1126 if (ret < 0) {
1067 mlog_errno(ret); 1127 mlog_errno(ret);
1068 goto out_trans; 1128 goto out_trans;
@@ -1128,9 +1188,8 @@ static int ocfs2_write_remove_suid(struct inode *inode)
1128{ 1188{
1129 int ret; 1189 int ret;
1130 struct buffer_head *bh = NULL; 1190 struct buffer_head *bh = NULL;
1131 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1132 1191
1133 ret = ocfs2_read_block(inode, oi->ip_blkno, &bh); 1192 ret = ocfs2_read_inode_block(inode, &bh);
1134 if (ret < 0) { 1193 if (ret < 0) {
1135 mlog_errno(ret); 1194 mlog_errno(ret);
1136 goto out; 1195 goto out;
@@ -1156,8 +1215,7 @@ static int ocfs2_allocate_unwritten_extents(struct inode *inode,
1156 struct buffer_head *di_bh = NULL; 1215 struct buffer_head *di_bh = NULL;
1157 1216
1158 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { 1217 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
1159 ret = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, 1218 ret = ocfs2_read_inode_block(inode, &di_bh);
1160 &di_bh);
1161 if (ret) { 1219 if (ret) {
1162 mlog_errno(ret); 1220 mlog_errno(ret);
1163 goto out; 1221 goto out;
@@ -1226,83 +1284,6 @@ out:
1226 return ret; 1284 return ret;
1227} 1285}
1228 1286
1229static int __ocfs2_remove_inode_range(struct inode *inode,
1230 struct buffer_head *di_bh,
1231 u32 cpos, u32 phys_cpos, u32 len,
1232 struct ocfs2_cached_dealloc_ctxt *dealloc)
1233{
1234 int ret;
1235 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
1236 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1237 struct inode *tl_inode = osb->osb_tl_inode;
1238 handle_t *handle;
1239 struct ocfs2_alloc_context *meta_ac = NULL;
1240 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1241 struct ocfs2_extent_tree et;
1242
1243 ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
1244
1245 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
1246 if (ret) {
1247 mlog_errno(ret);
1248 return ret;
1249 }
1250
1251 mutex_lock(&tl_inode->i_mutex);
1252
1253 if (ocfs2_truncate_log_needs_flush(osb)) {
1254 ret = __ocfs2_flush_truncate_log(osb);
1255 if (ret < 0) {
1256 mlog_errno(ret);
1257 goto out;
1258 }
1259 }
1260
1261 handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS);
1262 if (IS_ERR(handle)) {
1263 ret = PTR_ERR(handle);
1264 mlog_errno(ret);
1265 goto out;
1266 }
1267
1268 ret = ocfs2_journal_access(handle, inode, di_bh,
1269 OCFS2_JOURNAL_ACCESS_WRITE);
1270 if (ret) {
1271 mlog_errno(ret);
1272 goto out;
1273 }
1274
1275 ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac,
1276 dealloc);
1277 if (ret) {
1278 mlog_errno(ret);
1279 goto out_commit;
1280 }
1281
1282 OCFS2_I(inode)->ip_clusters -= len;
1283 di->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters);
1284
1285 ret = ocfs2_journal_dirty(handle, di_bh);
1286 if (ret) {
1287 mlog_errno(ret);
1288 goto out_commit;
1289 }
1290
1291 ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len);
1292 if (ret)
1293 mlog_errno(ret);
1294
1295out_commit:
1296 ocfs2_commit_trans(osb, handle);
1297out:
1298 mutex_unlock(&tl_inode->i_mutex);
1299
1300 if (meta_ac)
1301 ocfs2_free_alloc_context(meta_ac);
1302
1303 return ret;
1304}
1305
1306/* 1287/*
1307 * Truncate a byte range, avoiding pages within partial clusters. This 1288 * Truncate a byte range, avoiding pages within partial clusters. This
1308 * preserves those pages for the zeroing code to write to. 1289 * preserves those pages for the zeroing code to write to.
@@ -1402,7 +1383,9 @@ static int ocfs2_remove_inode_range(struct inode *inode,
1402 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1383 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1403 struct ocfs2_cached_dealloc_ctxt dealloc; 1384 struct ocfs2_cached_dealloc_ctxt dealloc;
1404 struct address_space *mapping = inode->i_mapping; 1385 struct address_space *mapping = inode->i_mapping;
1386 struct ocfs2_extent_tree et;
1405 1387
1388 ocfs2_init_dinode_extent_tree(&et, inode, di_bh);
1406 ocfs2_init_dealloc_ctxt(&dealloc); 1389 ocfs2_init_dealloc_ctxt(&dealloc);
1407 1390
1408 if (byte_len == 0) 1391 if (byte_len == 0)
@@ -1458,9 +1441,9 @@ static int ocfs2_remove_inode_range(struct inode *inode,
1458 1441
1459 /* Only do work for non-holes */ 1442 /* Only do work for non-holes */
1460 if (phys_cpos != 0) { 1443 if (phys_cpos != 0) {
1461 ret = __ocfs2_remove_inode_range(inode, di_bh, cpos, 1444 ret = ocfs2_remove_btree_range(inode, &et, cpos,
1462 phys_cpos, alloc_size, 1445 phys_cpos, alloc_size,
1463 &dealloc); 1446 &dealloc);
1464 if (ret) { 1447 if (ret) {
1465 mlog_errno(ret); 1448 mlog_errno(ret);
1466 goto out; 1449 goto out;
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index e92382cbca5f..172f9fbc9fc7 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -51,6 +51,9 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb,
51 struct ocfs2_alloc_context *data_ac, 51 struct ocfs2_alloc_context *data_ac,
52 struct ocfs2_alloc_context *meta_ac, 52 struct ocfs2_alloc_context *meta_ac,
53 enum ocfs2_alloc_restarted *reason_ret); 53 enum ocfs2_alloc_restarted *reason_ret);
54int ocfs2_simple_size_update(struct inode *inode,
55 struct buffer_head *di_bh,
56 u64 new_i_size);
54int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, 57int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size,
55 u64 zero_to); 58 u64 zero_to);
56int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); 59int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 7aa00d511874..229e707bc050 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/highmem.h> 29#include <linux/highmem.h>
30#include <linux/pagemap.h> 30#include <linux/pagemap.h>
31#include <linux/quotaops.h>
31 32
32#include <asm/byteorder.h> 33#include <asm/byteorder.h>
33 34
@@ -37,6 +38,7 @@
37#include "ocfs2.h" 38#include "ocfs2.h"
38 39
39#include "alloc.h" 40#include "alloc.h"
41#include "blockcheck.h"
40#include "dlmglue.h" 42#include "dlmglue.h"
41#include "extent_map.h" 43#include "extent_map.h"
42#include "file.h" 44#include "file.h"
@@ -214,12 +216,11 @@ static int ocfs2_init_locked_inode(struct inode *inode, void *opaque)
214 return 0; 216 return 0;
215} 217}
216 218
217int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, 219void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
218 int create_ino) 220 int create_ino)
219{ 221{
220 struct super_block *sb; 222 struct super_block *sb;
221 struct ocfs2_super *osb; 223 struct ocfs2_super *osb;
222 int status = -EINVAL;
223 int use_plocks = 1; 224 int use_plocks = 1;
224 225
225 mlog_entry("(0x%p, size:%llu)\n", inode, 226 mlog_entry("(0x%p, size:%llu)\n", inode,
@@ -232,25 +233,17 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
232 ocfs2_mount_local(osb) || !ocfs2_stack_supports_plocks()) 233 ocfs2_mount_local(osb) || !ocfs2_stack_supports_plocks())
233 use_plocks = 0; 234 use_plocks = 0;
234 235
235 /* this means that read_inode cannot create a superblock inode 236 /*
236 * today. change if needed. */ 237 * These have all been checked by ocfs2_read_inode_block() or set
237 if (!OCFS2_IS_VALID_DINODE(fe) || 238 * by ocfs2_mknod_locked(), so a failure is a code bug.
238 !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { 239 */
239 mlog(0, "Invalid dinode: i_ino=%lu, i_blkno=%llu, " 240 BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); /* This means that read_inode
240 "signature = %.*s, flags = 0x%x\n", 241 cannot create a superblock
241 inode->i_ino, 242 inode today. change if
242 (unsigned long long)le64_to_cpu(fe->i_blkno), 7, 243 that is needed. */
243 fe->i_signature, le32_to_cpu(fe->i_flags)); 244 BUG_ON(!(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL)));
244 goto bail; 245 BUG_ON(le32_to_cpu(fe->i_fs_generation) != osb->fs_generation);
245 }
246 246
247 if (le32_to_cpu(fe->i_fs_generation) != osb->fs_generation) {
248 mlog(ML_ERROR, "file entry generation does not match "
249 "superblock! osb->fs_generation=%x, "
250 "fe->i_fs_generation=%x\n",
251 osb->fs_generation, le32_to_cpu(fe->i_fs_generation));
252 goto bail;
253 }
254 247
255 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); 248 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
256 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr); 249 OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
@@ -284,14 +277,18 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
284 277
285 inode->i_nlink = le16_to_cpu(fe->i_links_count); 278 inode->i_nlink = le16_to_cpu(fe->i_links_count);
286 279
287 if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) 280 if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) {
288 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE; 281 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE;
282 inode->i_flags |= S_NOQUOTA;
283 }
289 284
290 if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) { 285 if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) {
291 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; 286 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
292 mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino); 287 mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino);
293 } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) { 288 } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) {
294 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; 289 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
290 } else if (fe->i_flags & cpu_to_le32(OCFS2_QUOTA_FL)) {
291 inode->i_flags |= S_NOQUOTA;
295 } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) { 292 } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) {
296 mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino); 293 mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino);
297 /* we can't actually hit this as read_inode can't 294 /* we can't actually hit this as read_inode can't
@@ -354,10 +351,7 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
354 351
355 ocfs2_set_inode_flags(inode); 352 ocfs2_set_inode_flags(inode);
356 353
357 status = 0; 354 mlog_exit_void();
358bail:
359 mlog_exit(status);
360 return status;
361} 355}
362 356
363static int ocfs2_read_locked_inode(struct inode *inode, 357static int ocfs2_read_locked_inode(struct inode *inode,
@@ -460,11 +454,14 @@ static int ocfs2_read_locked_inode(struct inode *inode,
460 } 454 }
461 } 455 }
462 456
463 if (can_lock) 457 if (can_lock) {
464 status = ocfs2_read_blocks(inode, args->fi_blkno, 1, &bh, 458 status = ocfs2_read_inode_block_full(inode, &bh,
465 OCFS2_BH_IGNORE_CACHE); 459 OCFS2_BH_IGNORE_CACHE);
466 else 460 } else {
467 status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh); 461 status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh);
462 if (!status)
463 status = ocfs2_validate_inode_block(osb->sb, bh);
464 }
468 if (status < 0) { 465 if (status < 0) {
469 mlog_errno(status); 466 mlog_errno(status);
470 goto bail; 467 goto bail;
@@ -472,12 +469,6 @@ static int ocfs2_read_locked_inode(struct inode *inode,
472 469
473 status = -EINVAL; 470 status = -EINVAL;
474 fe = (struct ocfs2_dinode *) bh->b_data; 471 fe = (struct ocfs2_dinode *) bh->b_data;
475 if (!OCFS2_IS_VALID_DINODE(fe)) {
476 mlog(0, "Invalid dinode #%llu: signature = %.*s\n",
477 (unsigned long long)args->fi_blkno, 7,
478 fe->i_signature);
479 goto bail;
480 }
481 472
482 /* 473 /*
483 * This is a code bug. Right now the caller needs to 474 * This is a code bug. Right now the caller needs to
@@ -491,10 +482,9 @@ static int ocfs2_read_locked_inode(struct inode *inode,
491 482
492 if (S_ISCHR(le16_to_cpu(fe->i_mode)) || 483 if (S_ISCHR(le16_to_cpu(fe->i_mode)) ||
493 S_ISBLK(le16_to_cpu(fe->i_mode))) 484 S_ISBLK(le16_to_cpu(fe->i_mode)))
494 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); 485 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
495 486
496 if (ocfs2_populate_inode(inode, fe, 0) < 0) 487 ocfs2_populate_inode(inode, fe, 0);
497 goto bail;
498 488
499 BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno)); 489 BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno));
500 490
@@ -547,8 +537,8 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
547 goto out; 537 goto out;
548 } 538 }
549 539
550 status = ocfs2_journal_access(handle, inode, fe_bh, 540 status = ocfs2_journal_access_di(handle, inode, fe_bh,
551 OCFS2_JOURNAL_ACCESS_WRITE); 541 OCFS2_JOURNAL_ACCESS_WRITE);
552 if (status < 0) { 542 if (status < 0) {
553 mlog_errno(status); 543 mlog_errno(status);
554 goto out; 544 goto out;
@@ -615,7 +605,8 @@ static int ocfs2_remove_inode(struct inode *inode,
615 goto bail; 605 goto bail;
616 } 606 }
617 607
618 handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS); 608 handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS +
609 ocfs2_quota_trans_credits(inode->i_sb));
619 if (IS_ERR(handle)) { 610 if (IS_ERR(handle)) {
620 status = PTR_ERR(handle); 611 status = PTR_ERR(handle);
621 mlog_errno(status); 612 mlog_errno(status);
@@ -630,8 +621,8 @@ static int ocfs2_remove_inode(struct inode *inode,
630 } 621 }
631 622
632 /* set the inodes dtime */ 623 /* set the inodes dtime */
633 status = ocfs2_journal_access(handle, inode, di_bh, 624 status = ocfs2_journal_access_di(handle, inode, di_bh,
634 OCFS2_JOURNAL_ACCESS_WRITE); 625 OCFS2_JOURNAL_ACCESS_WRITE);
635 if (status < 0) { 626 if (status < 0) {
636 mlog_errno(status); 627 mlog_errno(status);
637 goto bail_commit; 628 goto bail_commit;
@@ -647,6 +638,7 @@ static int ocfs2_remove_inode(struct inode *inode,
647 } 638 }
648 639
649 ocfs2_remove_from_cache(inode, di_bh); 640 ocfs2_remove_from_cache(inode, di_bh);
641 vfs_dq_free_inode(inode);
650 642
651 status = ocfs2_free_dinode(handle, inode_alloc_inode, 643 status = ocfs2_free_dinode(handle, inode_alloc_inode,
652 inode_alloc_bh, di); 644 inode_alloc_bh, di);
@@ -929,7 +921,10 @@ void ocfs2_delete_inode(struct inode *inode)
929 921
930 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 922 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
931 923
932 if (is_bad_inode(inode)) { 924 /* When we fail in read_inode() we mark inode as bad. The second test
925 * catches the case when inode allocation fails before allocating
926 * a block for inode. */
927 if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno) {
933 mlog(0, "Skipping delete of bad inode\n"); 928 mlog(0, "Skipping delete of bad inode\n");
934 goto bail; 929 goto bail;
935 } 930 }
@@ -1195,8 +1190,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
1195 mlog_entry("(inode %llu)\n", 1190 mlog_entry("(inode %llu)\n",
1196 (unsigned long long)OCFS2_I(inode)->ip_blkno); 1191 (unsigned long long)OCFS2_I(inode)->ip_blkno);
1197 1192
1198 status = ocfs2_journal_access(handle, inode, bh, 1193 status = ocfs2_journal_access_di(handle, inode, bh,
1199 OCFS2_JOURNAL_ACCESS_WRITE); 1194 OCFS2_JOURNAL_ACCESS_WRITE);
1200 if (status < 0) { 1195 if (status < 0) {
1201 mlog_errno(status); 1196 mlog_errno(status);
1202 goto leave; 1197 goto leave;
@@ -1264,3 +1259,89 @@ void ocfs2_refresh_inode(struct inode *inode,
1264 1259
1265 spin_unlock(&OCFS2_I(inode)->ip_lock); 1260 spin_unlock(&OCFS2_I(inode)->ip_lock);
1266} 1261}
1262
1263int ocfs2_validate_inode_block(struct super_block *sb,
1264 struct buffer_head *bh)
1265{
1266 int rc;
1267 struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
1268
1269 mlog(0, "Validating dinode %llu\n",
1270 (unsigned long long)bh->b_blocknr);
1271
1272 BUG_ON(!buffer_uptodate(bh));
1273
1274 /*
1275 * If the ecc fails, we return the error but otherwise
1276 * leave the filesystem running. We know any error is
1277 * local to this block.
1278 */
1279 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &di->i_check);
1280 if (rc) {
1281 mlog(ML_ERROR, "Checksum failed for dinode %llu\n",
1282 (unsigned long long)bh->b_blocknr);
1283 goto bail;
1284 }
1285
1286 /*
1287 * Errors after here are fatal.
1288 */
1289
1290 rc = -EINVAL;
1291
1292 if (!OCFS2_IS_VALID_DINODE(di)) {
1293 ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n",
1294 (unsigned long long)bh->b_blocknr, 7,
1295 di->i_signature);
1296 goto bail;
1297 }
1298
1299 if (le64_to_cpu(di->i_blkno) != bh->b_blocknr) {
1300 ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n",
1301 (unsigned long long)bh->b_blocknr,
1302 (unsigned long long)le64_to_cpu(di->i_blkno));
1303 goto bail;
1304 }
1305
1306 if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
1307 ocfs2_error(sb,
1308 "Invalid dinode #%llu: OCFS2_VALID_FL not set\n",
1309 (unsigned long long)bh->b_blocknr);
1310 goto bail;
1311 }
1312
1313 if (le32_to_cpu(di->i_fs_generation) !=
1314 OCFS2_SB(sb)->fs_generation) {
1315 ocfs2_error(sb,
1316 "Invalid dinode #%llu: fs_generation is %u\n",
1317 (unsigned long long)bh->b_blocknr,
1318 le32_to_cpu(di->i_fs_generation));
1319 goto bail;
1320 }
1321
1322 rc = 0;
1323
1324bail:
1325 return rc;
1326}
1327
1328int ocfs2_read_inode_block_full(struct inode *inode, struct buffer_head **bh,
1329 int flags)
1330{
1331 int rc;
1332 struct buffer_head *tmp = *bh;
1333
1334 rc = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, &tmp,
1335 flags, ocfs2_validate_inode_block);
1336
1337 /* If ocfs2_read_blocks() got us a new bh, pass it up. */
1338 if (!rc && !*bh)
1339 *bh = tmp;
1340
1341 return rc;
1342}
1343
1344int ocfs2_read_inode_block(struct inode *inode, struct buffer_head **bh)
1345{
1346 return ocfs2_read_inode_block_full(inode, bh, 0);
1347}
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 2f37af9bcc4a..eb3c302b38d3 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -128,8 +128,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 feoff, unsigned flags,
128 int sysfile_type); 128 int sysfile_type);
129int ocfs2_inode_init_private(struct inode *inode); 129int ocfs2_inode_init_private(struct inode *inode);
130int ocfs2_inode_revalidate(struct dentry *dentry); 130int ocfs2_inode_revalidate(struct dentry *dentry);
131int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, 131void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
132 int create_ino); 132 int create_ino);
133void ocfs2_read_inode(struct inode *inode); 133void ocfs2_read_inode(struct inode *inode);
134void ocfs2_read_inode2(struct inode *inode, void *opaque); 134void ocfs2_read_inode2(struct inode *inode, void *opaque);
135ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf, 135ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf,
@@ -142,6 +142,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
142 struct buffer_head *bh); 142 struct buffer_head *bh);
143int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb); 143int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb);
144int ocfs2_aio_write(struct file *file, struct kiocb *req, struct iocb *iocb); 144int ocfs2_aio_write(struct file *file, struct kiocb *req, struct iocb *iocb);
145struct buffer_head *ocfs2_bread(struct inode *inode,
146 int block, int *err, int reada);
145 147
146void ocfs2_set_inode_flags(struct inode *inode); 148void ocfs2_set_inode_flags(struct inode *inode);
147void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi); 149void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
@@ -153,4 +155,16 @@ static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
153 return (blkcnt_t)(OCFS2_I(inode)->ip_clusters << c_to_s_bits); 155 return (blkcnt_t)(OCFS2_I(inode)->ip_clusters << c_to_s_bits);
154} 156}
155 157
158/* Validate that a bh contains a valid inode */
159int ocfs2_validate_inode_block(struct super_block *sb,
160 struct buffer_head *bh);
161/*
162 * Read an inode block into *bh. If *bh is NULL, a bh will be allocated.
163 * This is a cached read. The inode will be validated with
164 * ocfs2_validate_inode_block().
165 */
166int ocfs2_read_inode_block(struct inode *inode, struct buffer_head **bh);
167/* The same, but can be passed OCFS2_BH_* flags */
168int ocfs2_read_inode_block_full(struct inode *inode, struct buffer_head **bh,
169 int flags);
156#endif /* OCFS2_INODE_H */ 170#endif /* OCFS2_INODE_H */
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 99fe9d584f3c..57d7d25a2b9a 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -35,6 +35,7 @@
35#include "ocfs2.h" 35#include "ocfs2.h"
36 36
37#include "alloc.h" 37#include "alloc.h"
38#include "blockcheck.h"
38#include "dir.h" 39#include "dir.h"
39#include "dlmglue.h" 40#include "dlmglue.h"
40#include "extent_map.h" 41#include "extent_map.h"
@@ -45,6 +46,7 @@
45#include "slot_map.h" 46#include "slot_map.h"
46#include "super.h" 47#include "super.h"
47#include "sysfile.h" 48#include "sysfile.h"
49#include "quota.h"
48 50
49#include "buffer_head_io.h" 51#include "buffer_head_io.h"
50 52
@@ -52,10 +54,10 @@ DEFINE_SPINLOCK(trans_inc_lock);
52 54
53static int ocfs2_force_read_journal(struct inode *inode); 55static int ocfs2_force_read_journal(struct inode *inode);
54static int ocfs2_recover_node(struct ocfs2_super *osb, 56static int ocfs2_recover_node(struct ocfs2_super *osb,
55 int node_num); 57 int node_num, int slot_num);
56static int __ocfs2_recovery_thread(void *arg); 58static int __ocfs2_recovery_thread(void *arg);
57static int ocfs2_commit_cache(struct ocfs2_super *osb); 59static int ocfs2_commit_cache(struct ocfs2_super *osb);
58static int ocfs2_wait_on_mount(struct ocfs2_super *osb); 60static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota);
59static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, 61static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
60 int dirty, int replayed); 62 int dirty, int replayed);
61static int ocfs2_trylock_journal(struct ocfs2_super *osb, 63static int ocfs2_trylock_journal(struct ocfs2_super *osb,
@@ -64,6 +66,17 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
64 int slot); 66 int slot);
65static int ocfs2_commit_thread(void *arg); 67static int ocfs2_commit_thread(void *arg);
66 68
69static inline int ocfs2_wait_on_mount(struct ocfs2_super *osb)
70{
71 return __ocfs2_wait_on_mount(osb, 0);
72}
73
74static inline int ocfs2_wait_on_quotas(struct ocfs2_super *osb)
75{
76 return __ocfs2_wait_on_mount(osb, 1);
77}
78
79
67 80
68/* 81/*
69 * The recovery_list is a simple linked list of node numbers to recover. 82 * The recovery_list is a simple linked list of node numbers to recover.
@@ -256,11 +269,9 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
256 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); 269 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
257 BUG_ON(max_buffs <= 0); 270 BUG_ON(max_buffs <= 0);
258 271
259 /* JBD might support this, but our journalling code doesn't yet. */ 272 /* Nested transaction? Just return the handle... */
260 if (journal_current_handle()) { 273 if (journal_current_handle())
261 mlog(ML_ERROR, "Recursive transaction attempted!\n"); 274 return jbd2_journal_start(journal, max_buffs);
262 BUG();
263 }
264 275
265 down_read(&osb->journal->j_trans_barrier); 276 down_read(&osb->journal->j_trans_barrier);
266 277
@@ -285,16 +296,18 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
285int ocfs2_commit_trans(struct ocfs2_super *osb, 296int ocfs2_commit_trans(struct ocfs2_super *osb,
286 handle_t *handle) 297 handle_t *handle)
287{ 298{
288 int ret; 299 int ret, nested;
289 struct ocfs2_journal *journal = osb->journal; 300 struct ocfs2_journal *journal = osb->journal;
290 301
291 BUG_ON(!handle); 302 BUG_ON(!handle);
292 303
304 nested = handle->h_ref > 1;
293 ret = jbd2_journal_stop(handle); 305 ret = jbd2_journal_stop(handle);
294 if (ret < 0) 306 if (ret < 0)
295 mlog_errno(ret); 307 mlog_errno(ret);
296 308
297 up_read(&journal->j_trans_barrier); 309 if (!nested)
310 up_read(&journal->j_trans_barrier);
298 311
299 return ret; 312 return ret;
300} 313}
@@ -357,10 +370,137 @@ bail:
357 return status; 370 return status;
358} 371}
359 372
360int ocfs2_journal_access(handle_t *handle, 373struct ocfs2_triggers {
361 struct inode *inode, 374 struct jbd2_buffer_trigger_type ot_triggers;
362 struct buffer_head *bh, 375 int ot_offset;
363 int type) 376};
377
378static inline struct ocfs2_triggers *to_ocfs2_trigger(struct jbd2_buffer_trigger_type *triggers)
379{
380 return container_of(triggers, struct ocfs2_triggers, ot_triggers);
381}
382
383static void ocfs2_commit_trigger(struct jbd2_buffer_trigger_type *triggers,
384 struct buffer_head *bh,
385 void *data, size_t size)
386{
387 struct ocfs2_triggers *ot = to_ocfs2_trigger(triggers);
388
389 /*
390 * We aren't guaranteed to have the superblock here, so we
391 * must unconditionally compute the ecc data.
392 * __ocfs2_journal_access() will only set the triggers if
393 * metaecc is enabled.
394 */
395 ocfs2_block_check_compute(data, size, data + ot->ot_offset);
396}
397
398/*
399 * Quota blocks have their own trigger because the struct ocfs2_block_check
400 * offset depends on the blocksize.
401 */
402static void ocfs2_dq_commit_trigger(struct jbd2_buffer_trigger_type *triggers,
403 struct buffer_head *bh,
404 void *data, size_t size)
405{
406 struct ocfs2_disk_dqtrailer *dqt =
407 ocfs2_block_dqtrailer(size, data);
408
409 /*
410 * We aren't guaranteed to have the superblock here, so we
411 * must unconditionally compute the ecc data.
412 * __ocfs2_journal_access() will only set the triggers if
413 * metaecc is enabled.
414 */
415 ocfs2_block_check_compute(data, size, &dqt->dq_check);
416}
417
418/*
419 * Directory blocks also have their own trigger because the
420 * struct ocfs2_block_check offset depends on the blocksize.
421 */
422static void ocfs2_db_commit_trigger(struct jbd2_buffer_trigger_type *triggers,
423 struct buffer_head *bh,
424 void *data, size_t size)
425{
426 struct ocfs2_dir_block_trailer *trailer =
427 ocfs2_dir_trailer_from_size(size, data);
428
429 /*
430 * We aren't guaranteed to have the superblock here, so we
431 * must unconditionally compute the ecc data.
432 * __ocfs2_journal_access() will only set the triggers if
433 * metaecc is enabled.
434 */
435 ocfs2_block_check_compute(data, size, &trailer->db_check);
436}
437
438static void ocfs2_abort_trigger(struct jbd2_buffer_trigger_type *triggers,
439 struct buffer_head *bh)
440{
441 mlog(ML_ERROR,
442 "ocfs2_abort_trigger called by JBD2. bh = 0x%lx, "
443 "bh->b_blocknr = %llu\n",
444 (unsigned long)bh,
445 (unsigned long long)bh->b_blocknr);
446
447 /* We aren't guaranteed to have the superblock here - but if we
448 * don't, it'll just crash. */
449 ocfs2_error(bh->b_assoc_map->host->i_sb,
450 "JBD2 has aborted our journal, ocfs2 cannot continue\n");
451}
452
453static struct ocfs2_triggers di_triggers = {
454 .ot_triggers = {
455 .t_commit = ocfs2_commit_trigger,
456 .t_abort = ocfs2_abort_trigger,
457 },
458 .ot_offset = offsetof(struct ocfs2_dinode, i_check),
459};
460
461static struct ocfs2_triggers eb_triggers = {
462 .ot_triggers = {
463 .t_commit = ocfs2_commit_trigger,
464 .t_abort = ocfs2_abort_trigger,
465 },
466 .ot_offset = offsetof(struct ocfs2_extent_block, h_check),
467};
468
469static struct ocfs2_triggers gd_triggers = {
470 .ot_triggers = {
471 .t_commit = ocfs2_commit_trigger,
472 .t_abort = ocfs2_abort_trigger,
473 },
474 .ot_offset = offsetof(struct ocfs2_group_desc, bg_check),
475};
476
477static struct ocfs2_triggers db_triggers = {
478 .ot_triggers = {
479 .t_commit = ocfs2_db_commit_trigger,
480 .t_abort = ocfs2_abort_trigger,
481 },
482};
483
484static struct ocfs2_triggers xb_triggers = {
485 .ot_triggers = {
486 .t_commit = ocfs2_commit_trigger,
487 .t_abort = ocfs2_abort_trigger,
488 },
489 .ot_offset = offsetof(struct ocfs2_xattr_block, xb_check),
490};
491
492static struct ocfs2_triggers dq_triggers = {
493 .ot_triggers = {
494 .t_commit = ocfs2_dq_commit_trigger,
495 .t_abort = ocfs2_abort_trigger,
496 },
497};
498
499static int __ocfs2_journal_access(handle_t *handle,
500 struct inode *inode,
501 struct buffer_head *bh,
502 struct ocfs2_triggers *triggers,
503 int type)
364{ 504{
365 int status; 505 int status;
366 506
@@ -406,6 +546,8 @@ int ocfs2_journal_access(handle_t *handle,
406 status = -EINVAL; 546 status = -EINVAL;
407 mlog(ML_ERROR, "Uknown access type!\n"); 547 mlog(ML_ERROR, "Uknown access type!\n");
408 } 548 }
549 if (!status && ocfs2_meta_ecc(OCFS2_SB(inode->i_sb)) && triggers)
550 jbd2_journal_set_triggers(bh, &triggers->ot_triggers);
409 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex); 551 mutex_unlock(&OCFS2_I(inode)->ip_io_mutex);
410 552
411 if (status < 0) 553 if (status < 0)
@@ -416,6 +558,54 @@ int ocfs2_journal_access(handle_t *handle,
416 return status; 558 return status;
417} 559}
418 560
561int ocfs2_journal_access_di(handle_t *handle, struct inode *inode,
562 struct buffer_head *bh, int type)
563{
564 return __ocfs2_journal_access(handle, inode, bh, &di_triggers,
565 type);
566}
567
568int ocfs2_journal_access_eb(handle_t *handle, struct inode *inode,
569 struct buffer_head *bh, int type)
570{
571 return __ocfs2_journal_access(handle, inode, bh, &eb_triggers,
572 type);
573}
574
575int ocfs2_journal_access_gd(handle_t *handle, struct inode *inode,
576 struct buffer_head *bh, int type)
577{
578 return __ocfs2_journal_access(handle, inode, bh, &gd_triggers,
579 type);
580}
581
582int ocfs2_journal_access_db(handle_t *handle, struct inode *inode,
583 struct buffer_head *bh, int type)
584{
585 return __ocfs2_journal_access(handle, inode, bh, &db_triggers,
586 type);
587}
588
589int ocfs2_journal_access_xb(handle_t *handle, struct inode *inode,
590 struct buffer_head *bh, int type)
591{
592 return __ocfs2_journal_access(handle, inode, bh, &xb_triggers,
593 type);
594}
595
596int ocfs2_journal_access_dq(handle_t *handle, struct inode *inode,
597 struct buffer_head *bh, int type)
598{
599 return __ocfs2_journal_access(handle, inode, bh, &dq_triggers,
600 type);
601}
602
603int ocfs2_journal_access(handle_t *handle, struct inode *inode,
604 struct buffer_head *bh, int type)
605{
606 return __ocfs2_journal_access(handle, inode, bh, NULL, type);
607}
608
419int ocfs2_journal_dirty(handle_t *handle, 609int ocfs2_journal_dirty(handle_t *handle,
420 struct buffer_head *bh) 610 struct buffer_head *bh)
421{ 611{
@@ -434,20 +624,6 @@ int ocfs2_journal_dirty(handle_t *handle,
434 return status; 624 return status;
435} 625}
436 626
437#ifdef CONFIG_OCFS2_COMPAT_JBD
438int ocfs2_journal_dirty_data(handle_t *handle,
439 struct buffer_head *bh)
440{
441 int err = journal_dirty_data(handle, bh);
442 if (err)
443 mlog_errno(err);
444 /* TODO: When we can handle it, abort the handle and go RO on
445 * error here. */
446
447 return err;
448}
449#endif
450
451#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE) 627#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE)
452 628
453void ocfs2_set_journal_params(struct ocfs2_super *osb) 629void ocfs2_set_journal_params(struct ocfs2_super *osb)
@@ -587,17 +763,11 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
587 mlog_entry_void(); 763 mlog_entry_void();
588 764
589 fe = (struct ocfs2_dinode *)bh->b_data; 765 fe = (struct ocfs2_dinode *)bh->b_data;
590 if (!OCFS2_IS_VALID_DINODE(fe)) { 766
591 /* This is called from startup/shutdown which will 767 /* The journal bh on the osb always comes from ocfs2_journal_init()
592 * handle the errors in a specific manner, so no need 768 * and was validated there inside ocfs2_inode_lock_full(). It's a
593 * to call ocfs2_error() here. */ 769 * code bug if we mess it up. */
594 mlog(ML_ERROR, "Journal dinode %llu has invalid " 770 BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
595 "signature: %.*s",
596 (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
597 fe->i_signature);
598 status = -EIO;
599 goto out;
600 }
601 771
602 flags = le32_to_cpu(fe->id1.journal1.ij_flags); 772 flags = le32_to_cpu(fe->id1.journal1.ij_flags);
603 if (dirty) 773 if (dirty)
@@ -609,11 +779,11 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
609 if (replayed) 779 if (replayed)
610 ocfs2_bump_recovery_generation(fe); 780 ocfs2_bump_recovery_generation(fe);
611 781
782 ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check);
612 status = ocfs2_write_block(osb, bh, journal->j_inode); 783 status = ocfs2_write_block(osb, bh, journal->j_inode);
613 if (status < 0) 784 if (status < 0)
614 mlog_errno(status); 785 mlog_errno(status);
615 786
616out:
617 mlog_exit(status); 787 mlog_exit(status);
618 return status; 788 return status;
619} 789}
@@ -878,6 +1048,7 @@ struct ocfs2_la_recovery_item {
878 int lri_slot; 1048 int lri_slot;
879 struct ocfs2_dinode *lri_la_dinode; 1049 struct ocfs2_dinode *lri_la_dinode;
880 struct ocfs2_dinode *lri_tl_dinode; 1050 struct ocfs2_dinode *lri_tl_dinode;
1051 struct ocfs2_quota_recovery *lri_qrec;
881}; 1052};
882 1053
883/* Does the second half of the recovery process. By this point, the 1054/* Does the second half of the recovery process. By this point, the
@@ -898,6 +1069,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
898 struct ocfs2_super *osb = journal->j_osb; 1069 struct ocfs2_super *osb = journal->j_osb;
899 struct ocfs2_dinode *la_dinode, *tl_dinode; 1070 struct ocfs2_dinode *la_dinode, *tl_dinode;
900 struct ocfs2_la_recovery_item *item, *n; 1071 struct ocfs2_la_recovery_item *item, *n;
1072 struct ocfs2_quota_recovery *qrec;
901 LIST_HEAD(tmp_la_list); 1073 LIST_HEAD(tmp_la_list);
902 1074
903 mlog_entry_void(); 1075 mlog_entry_void();
@@ -913,6 +1085,8 @@ void ocfs2_complete_recovery(struct work_struct *work)
913 1085
914 mlog(0, "Complete recovery for slot %d\n", item->lri_slot); 1086 mlog(0, "Complete recovery for slot %d\n", item->lri_slot);
915 1087
1088 ocfs2_wait_on_quotas(osb);
1089
916 la_dinode = item->lri_la_dinode; 1090 la_dinode = item->lri_la_dinode;
917 if (la_dinode) { 1091 if (la_dinode) {
918 mlog(0, "Clean up local alloc %llu\n", 1092 mlog(0, "Clean up local alloc %llu\n",
@@ -943,6 +1117,16 @@ void ocfs2_complete_recovery(struct work_struct *work)
943 if (ret < 0) 1117 if (ret < 0)
944 mlog_errno(ret); 1118 mlog_errno(ret);
945 1119
1120 qrec = item->lri_qrec;
1121 if (qrec) {
1122 mlog(0, "Recovering quota files");
1123 ret = ocfs2_finish_quota_recovery(osb, qrec,
1124 item->lri_slot);
1125 if (ret < 0)
1126 mlog_errno(ret);
1127 /* Recovery info is already freed now */
1128 }
1129
946 kfree(item); 1130 kfree(item);
947 } 1131 }
948 1132
@@ -956,7 +1140,8 @@ void ocfs2_complete_recovery(struct work_struct *work)
956static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal, 1140static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
957 int slot_num, 1141 int slot_num,
958 struct ocfs2_dinode *la_dinode, 1142 struct ocfs2_dinode *la_dinode,
959 struct ocfs2_dinode *tl_dinode) 1143 struct ocfs2_dinode *tl_dinode,
1144 struct ocfs2_quota_recovery *qrec)
960{ 1145{
961 struct ocfs2_la_recovery_item *item; 1146 struct ocfs2_la_recovery_item *item;
962 1147
@@ -971,6 +1156,9 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
971 if (tl_dinode) 1156 if (tl_dinode)
972 kfree(tl_dinode); 1157 kfree(tl_dinode);
973 1158
1159 if (qrec)
1160 ocfs2_free_quota_recovery(qrec);
1161
974 mlog_errno(-ENOMEM); 1162 mlog_errno(-ENOMEM);
975 return; 1163 return;
976 } 1164 }
@@ -979,6 +1167,7 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
979 item->lri_la_dinode = la_dinode; 1167 item->lri_la_dinode = la_dinode;
980 item->lri_slot = slot_num; 1168 item->lri_slot = slot_num;
981 item->lri_tl_dinode = tl_dinode; 1169 item->lri_tl_dinode = tl_dinode;
1170 item->lri_qrec = qrec;
982 1171
983 spin_lock(&journal->j_lock); 1172 spin_lock(&journal->j_lock);
984 list_add_tail(&item->lri_list, &journal->j_la_cleanups); 1173 list_add_tail(&item->lri_list, &journal->j_la_cleanups);
@@ -998,6 +1187,7 @@ void ocfs2_complete_mount_recovery(struct ocfs2_super *osb)
998 ocfs2_queue_recovery_completion(journal, 1187 ocfs2_queue_recovery_completion(journal,
999 osb->slot_num, 1188 osb->slot_num,
1000 osb->local_alloc_copy, 1189 osb->local_alloc_copy,
1190 NULL,
1001 NULL); 1191 NULL);
1002 ocfs2_schedule_truncate_log_flush(osb, 0); 1192 ocfs2_schedule_truncate_log_flush(osb, 0);
1003 1193
@@ -1006,11 +1196,26 @@ void ocfs2_complete_mount_recovery(struct ocfs2_super *osb)
1006 } 1196 }
1007} 1197}
1008 1198
1199void ocfs2_complete_quota_recovery(struct ocfs2_super *osb)
1200{
1201 if (osb->quota_rec) {
1202 ocfs2_queue_recovery_completion(osb->journal,
1203 osb->slot_num,
1204 NULL,
1205 NULL,
1206 osb->quota_rec);
1207 osb->quota_rec = NULL;
1208 }
1209}
1210
1009static int __ocfs2_recovery_thread(void *arg) 1211static int __ocfs2_recovery_thread(void *arg)
1010{ 1212{
1011 int status, node_num; 1213 int status, node_num, slot_num;
1012 struct ocfs2_super *osb = arg; 1214 struct ocfs2_super *osb = arg;
1013 struct ocfs2_recovery_map *rm = osb->recovery_map; 1215 struct ocfs2_recovery_map *rm = osb->recovery_map;
1216 int *rm_quota = NULL;
1217 int rm_quota_used = 0, i;
1218 struct ocfs2_quota_recovery *qrec;
1014 1219
1015 mlog_entry_void(); 1220 mlog_entry_void();
1016 1221
@@ -1019,6 +1224,11 @@ static int __ocfs2_recovery_thread(void *arg)
1019 goto bail; 1224 goto bail;
1020 } 1225 }
1021 1226
1227 rm_quota = kzalloc(osb->max_slots * sizeof(int), GFP_NOFS);
1228 if (!rm_quota) {
1229 status = -ENOMEM;
1230 goto bail;
1231 }
1022restart: 1232restart:
1023 status = ocfs2_super_lock(osb, 1); 1233 status = ocfs2_super_lock(osb, 1);
1024 if (status < 0) { 1234 if (status < 0) {
@@ -1032,8 +1242,28 @@ restart:
1032 * clear it until ocfs2_recover_node() has succeeded. */ 1242 * clear it until ocfs2_recover_node() has succeeded. */
1033 node_num = rm->rm_entries[0]; 1243 node_num = rm->rm_entries[0];
1034 spin_unlock(&osb->osb_lock); 1244 spin_unlock(&osb->osb_lock);
1035 1245 mlog(0, "checking node %d\n", node_num);
1036 status = ocfs2_recover_node(osb, node_num); 1246 slot_num = ocfs2_node_num_to_slot(osb, node_num);
1247 if (slot_num == -ENOENT) {
1248 status = 0;
1249 mlog(0, "no slot for this node, so no recovery"
1250 "required.\n");
1251 goto skip_recovery;
1252 }
1253 mlog(0, "node %d was using slot %d\n", node_num, slot_num);
1254
1255 /* It is a bit subtle with quota recovery. We cannot do it
1256 * immediately because we have to obtain cluster locks from
1257 * quota files and we also don't want to just skip it because
1258 * then quota usage would be out of sync until some node takes
1259 * the slot. So we remember which nodes need quota recovery
1260 * and when everything else is done, we recover quotas. */
1261 for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++);
1262 if (i == rm_quota_used)
1263 rm_quota[rm_quota_used++] = slot_num;
1264
1265 status = ocfs2_recover_node(osb, node_num, slot_num);
1266skip_recovery:
1037 if (!status) { 1267 if (!status) {
1038 ocfs2_recovery_map_clear(osb, node_num); 1268 ocfs2_recovery_map_clear(osb, node_num);
1039 } else { 1269 } else {
@@ -1055,13 +1285,27 @@ restart:
1055 if (status < 0) 1285 if (status < 0)
1056 mlog_errno(status); 1286 mlog_errno(status);
1057 1287
1288 /* Now it is right time to recover quotas... We have to do this under
1289 * superblock lock so that noone can start using the slot (and crash)
1290 * before we recover it */
1291 for (i = 0; i < rm_quota_used; i++) {
1292 qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
1293 if (IS_ERR(qrec)) {
1294 status = PTR_ERR(qrec);
1295 mlog_errno(status);
1296 continue;
1297 }
1298 ocfs2_queue_recovery_completion(osb->journal, rm_quota[i],
1299 NULL, NULL, qrec);
1300 }
1301
1058 ocfs2_super_unlock(osb, 1); 1302 ocfs2_super_unlock(osb, 1);
1059 1303
1060 /* We always run recovery on our own orphan dir - the dead 1304 /* We always run recovery on our own orphan dir - the dead
1061 * node(s) may have disallowd a previos inode delete. Re-processing 1305 * node(s) may have disallowd a previos inode delete. Re-processing
1062 * is therefore required. */ 1306 * is therefore required. */
1063 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL, 1307 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL,
1064 NULL); 1308 NULL, NULL);
1065 1309
1066bail: 1310bail:
1067 mutex_lock(&osb->recovery_lock); 1311 mutex_lock(&osb->recovery_lock);
@@ -1076,6 +1320,9 @@ bail:
1076 1320
1077 mutex_unlock(&osb->recovery_lock); 1321 mutex_unlock(&osb->recovery_lock);
1078 1322
1323 if (rm_quota)
1324 kfree(rm_quota);
1325
1079 mlog_exit(status); 1326 mlog_exit(status);
1080 /* no one is callint kthread_stop() for us so the kthread() api 1327 /* no one is callint kthread_stop() for us so the kthread() api
1081 * requires that we call do_exit(). And it isn't exported, but 1328 * requires that we call do_exit(). And it isn't exported, but
@@ -1135,8 +1382,7 @@ static int ocfs2_read_journal_inode(struct ocfs2_super *osb,
1135 } 1382 }
1136 SET_INODE_JOURNAL(inode); 1383 SET_INODE_JOURNAL(inode);
1137 1384
1138 status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, bh, 1385 status = ocfs2_read_inode_block_full(inode, bh, OCFS2_BH_IGNORE_CACHE);
1139 OCFS2_BH_IGNORE_CACHE);
1140 if (status < 0) { 1386 if (status < 0) {
1141 mlog_errno(status); 1387 mlog_errno(status);
1142 goto bail; 1388 goto bail;
@@ -1268,6 +1514,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1268 osb->slot_recovery_generations[slot_num] = 1514 osb->slot_recovery_generations[slot_num] =
1269 ocfs2_get_recovery_generation(fe); 1515 ocfs2_get_recovery_generation(fe);
1270 1516
1517 ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check);
1271 status = ocfs2_write_block(osb, bh, inode); 1518 status = ocfs2_write_block(osb, bh, inode);
1272 if (status < 0) 1519 if (status < 0)
1273 mlog_errno(status); 1520 mlog_errno(status);
@@ -1304,31 +1551,19 @@ done:
1304 * far less concerning. 1551 * far less concerning.
1305 */ 1552 */
1306static int ocfs2_recover_node(struct ocfs2_super *osb, 1553static int ocfs2_recover_node(struct ocfs2_super *osb,
1307 int node_num) 1554 int node_num, int slot_num)
1308{ 1555{
1309 int status = 0; 1556 int status = 0;
1310 int slot_num;
1311 struct ocfs2_dinode *la_copy = NULL; 1557 struct ocfs2_dinode *la_copy = NULL;
1312 struct ocfs2_dinode *tl_copy = NULL; 1558 struct ocfs2_dinode *tl_copy = NULL;
1313 1559
1314 mlog_entry("(node_num=%d, osb->node_num = %d)\n", 1560 mlog_entry("(node_num=%d, slot_num=%d, osb->node_num = %d)\n",
1315 node_num, osb->node_num); 1561 node_num, slot_num, osb->node_num);
1316
1317 mlog(0, "checking node %d\n", node_num);
1318 1562
1319 /* Should not ever be called to recover ourselves -- in that 1563 /* Should not ever be called to recover ourselves -- in that
1320 * case we should've called ocfs2_journal_load instead. */ 1564 * case we should've called ocfs2_journal_load instead. */
1321 BUG_ON(osb->node_num == node_num); 1565 BUG_ON(osb->node_num == node_num);
1322 1566
1323 slot_num = ocfs2_node_num_to_slot(osb, node_num);
1324 if (slot_num == -ENOENT) {
1325 status = 0;
1326 mlog(0, "no slot for this node, so no recovery required.\n");
1327 goto done;
1328 }
1329
1330 mlog(0, "node %d was using slot %d\n", node_num, slot_num);
1331
1332 status = ocfs2_replay_journal(osb, node_num, slot_num); 1567 status = ocfs2_replay_journal(osb, node_num, slot_num);
1333 if (status < 0) { 1568 if (status < 0) {
1334 if (status == -EBUSY) { 1569 if (status == -EBUSY) {
@@ -1364,7 +1599,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
1364 1599
1365 /* This will kfree the memory pointed to by la_copy and tl_copy */ 1600 /* This will kfree the memory pointed to by la_copy and tl_copy */
1366 ocfs2_queue_recovery_completion(osb->journal, slot_num, la_copy, 1601 ocfs2_queue_recovery_completion(osb->journal, slot_num, la_copy,
1367 tl_copy); 1602 tl_copy, NULL);
1368 1603
1369 status = 0; 1604 status = 0;
1370done: 1605done:
@@ -1659,13 +1894,14 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1659 return ret; 1894 return ret;
1660} 1895}
1661 1896
1662static int ocfs2_wait_on_mount(struct ocfs2_super *osb) 1897static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota)
1663{ 1898{
1664 /* This check is good because ocfs2 will wait on our recovery 1899 /* This check is good because ocfs2 will wait on our recovery
1665 * thread before changing it to something other than MOUNTED 1900 * thread before changing it to something other than MOUNTED
1666 * or DISABLED. */ 1901 * or DISABLED. */
1667 wait_event(osb->osb_mount_event, 1902 wait_event(osb->osb_mount_event,
1668 atomic_read(&osb->vol_state) == VOLUME_MOUNTED || 1903 (!quota && atomic_read(&osb->vol_state) == VOLUME_MOUNTED) ||
1904 atomic_read(&osb->vol_state) == VOLUME_MOUNTED_QUOTAS ||
1669 atomic_read(&osb->vol_state) == VOLUME_DISABLED); 1905 atomic_read(&osb->vol_state) == VOLUME_DISABLED);
1670 1906
1671 /* If there's an error on mount, then we may never get to the 1907 /* If there's an error on mount, then we may never get to the
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index d4d14e9a3cea..3c3532e1307c 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -27,12 +27,7 @@
27#define OCFS2_JOURNAL_H 27#define OCFS2_JOURNAL_H
28 28
29#include <linux/fs.h> 29#include <linux/fs.h>
30#ifndef CONFIG_OCFS2_COMPAT_JBD 30#include <linux/jbd2.h>
31# include <linux/jbd2.h>
32#else
33# include <linux/jbd.h>
34# include "ocfs2_jbd_compat.h"
35#endif
36 31
37enum ocfs2_journal_state { 32enum ocfs2_journal_state {
38 OCFS2_JOURNAL_FREE = 0, 33 OCFS2_JOURNAL_FREE = 0,
@@ -173,6 +168,7 @@ void ocfs2_recovery_thread(struct ocfs2_super *osb,
173 int node_num); 168 int node_num);
174int ocfs2_mark_dead_nodes(struct ocfs2_super *osb); 169int ocfs2_mark_dead_nodes(struct ocfs2_super *osb);
175void ocfs2_complete_mount_recovery(struct ocfs2_super *osb); 170void ocfs2_complete_mount_recovery(struct ocfs2_super *osb);
171void ocfs2_complete_quota_recovery(struct ocfs2_super *osb);
176 172
177static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb) 173static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb)
178{ 174{
@@ -216,9 +212,12 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
216 * ocfs2_extend_trans - Extend a handle by nblocks credits. This may 212 * ocfs2_extend_trans - Extend a handle by nblocks credits. This may
217 * commit the handle to disk in the process, but will 213 * commit the handle to disk in the process, but will
218 * not release any locks taken during the transaction. 214 * not release any locks taken during the transaction.
219 * ocfs2_journal_access - Notify the handle that we want to journal this 215 * ocfs2_journal_access* - Notify the handle that we want to journal this
220 * buffer. Will have to call ocfs2_journal_dirty once 216 * buffer. Will have to call ocfs2_journal_dirty once
221 * we've actually dirtied it. Type is one of . or . 217 * we've actually dirtied it. Type is one of . or .
218 * Always call the specific flavor of
219 * ocfs2_journal_access_*() unless you intend to
220 * manage the checksum by hand.
222 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. 221 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data.
223 * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before 222 * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before
224 * the current handle commits. 223 * the current handle commits.
@@ -248,10 +247,29 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks);
248#define OCFS2_JOURNAL_ACCESS_WRITE 1 247#define OCFS2_JOURNAL_ACCESS_WRITE 1
249#define OCFS2_JOURNAL_ACCESS_UNDO 2 248#define OCFS2_JOURNAL_ACCESS_UNDO 2
250 249
251int ocfs2_journal_access(handle_t *handle, 250
252 struct inode *inode, 251/* ocfs2_inode */
253 struct buffer_head *bh, 252int ocfs2_journal_access_di(handle_t *handle, struct inode *inode,
254 int type); 253 struct buffer_head *bh, int type);
254/* ocfs2_extent_block */
255int ocfs2_journal_access_eb(handle_t *handle, struct inode *inode,
256 struct buffer_head *bh, int type);
257/* ocfs2_group_desc */
258int ocfs2_journal_access_gd(handle_t *handle, struct inode *inode,
259 struct buffer_head *bh, int type);
260/* ocfs2_xattr_block */
261int ocfs2_journal_access_xb(handle_t *handle, struct inode *inode,
262 struct buffer_head *bh, int type);
263/* quota blocks */
264int ocfs2_journal_access_dq(handle_t *handle, struct inode *inode,
265 struct buffer_head *bh, int type);
266/* dirblock */
267int ocfs2_journal_access_db(handle_t *handle, struct inode *inode,
268 struct buffer_head *bh, int type);
269/* Anything that has no ecc */
270int ocfs2_journal_access(handle_t *handle, struct inode *inode,
271 struct buffer_head *bh, int type);
272
255/* 273/*
256 * A word about the journal_access/journal_dirty "dance". It is 274 * A word about the journal_access/journal_dirty "dance". It is
257 * entirely legal to journal_access a buffer more than once (as long 275 * entirely legal to journal_access a buffer more than once (as long
@@ -273,10 +291,6 @@ int ocfs2_journal_access(handle_t *handle,
273 */ 291 */
274int ocfs2_journal_dirty(handle_t *handle, 292int ocfs2_journal_dirty(handle_t *handle,
275 struct buffer_head *bh); 293 struct buffer_head *bh);
276#ifdef CONFIG_OCFS2_COMPAT_JBD
277int ocfs2_journal_dirty_data(handle_t *handle,
278 struct buffer_head *bh);
279#endif
280 294
281/* 295/*
282 * Credit Macros: 296 * Credit Macros:
@@ -293,6 +307,37 @@ int ocfs2_journal_dirty_data(handle_t *handle,
293/* extended attribute block update */ 307/* extended attribute block update */
294#define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 308#define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1
295 309
310/* global quotafile inode update, data block */
311#define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
312
313/*
314 * The two writes below can accidentally see global info dirty due
315 * to set_info() quotactl so make them prepared for the writes.
316 */
317/* quota data block, global info */
318/* Write to local quota file */
319#define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + 1)
320
321/* global quota data block, local quota data block, global quota inode,
322 * global quota info */
323#define OCFS2_QSYNC_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 3)
324
325static inline int ocfs2_quota_trans_credits(struct super_block *sb)
326{
327 int credits = 0;
328
329 if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA))
330 credits += OCFS2_QWRITE_CREDITS;
331 if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA))
332 credits += OCFS2_QWRITE_CREDITS;
333 return credits;
334}
335
336/* Number of credits needed for removing quota structure from file */
337int ocfs2_calc_qdel_credits(struct super_block *sb, int type);
338/* Number of credits needed for initialization of new quota structure */
339int ocfs2_calc_qinit_credits(struct super_block *sb, int type);
340
296/* group extend. inode update and last group update. */ 341/* group extend. inode update and last group update. */
297#define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) 342#define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
298 343
@@ -303,8 +348,11 @@ int ocfs2_journal_dirty_data(handle_t *handle,
303 * prev. group desc. if we relink. */ 348 * prev. group desc. if we relink. */
304#define OCFS2_SUBALLOC_ALLOC (3) 349#define OCFS2_SUBALLOC_ALLOC (3)
305 350
306#define OCFS2_INLINE_TO_EXTENTS_CREDITS (OCFS2_SUBALLOC_ALLOC \ 351static inline int ocfs2_inline_to_extents_credits(struct super_block *sb)
307 + OCFS2_INODE_UPDATE_CREDITS) 352{
353 return OCFS2_SUBALLOC_ALLOC + OCFS2_INODE_UPDATE_CREDITS +
354 ocfs2_quota_trans_credits(sb);
355}
308 356
309/* dinode + group descriptor update. We don't relink on free yet. */ 357/* dinode + group descriptor update. We don't relink on free yet. */
310#define OCFS2_SUBALLOC_FREE (2) 358#define OCFS2_SUBALLOC_FREE (2)
@@ -313,16 +361,23 @@ int ocfs2_journal_dirty_data(handle_t *handle,
313#define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ 361#define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \
314 + OCFS2_TRUNCATE_LOG_UPDATE) 362 + OCFS2_TRUNCATE_LOG_UPDATE)
315 363
316#define OCFS2_REMOVE_EXTENT_CREDITS (OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS) 364static inline int ocfs2_remove_extent_credits(struct super_block *sb)
365{
366 return OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS +
367 ocfs2_quota_trans_credits(sb);
368}
317 369
318/* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + 370/* data block for new dir/symlink, 2 for bitmap updates (bitmap fe +
319 * bitmap block for the new bit) */ 371 * bitmap block for the new bit) */
320#define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) 372#define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2)
321 373
322/* parent fe, parent block, new file entry, inode alloc fe, inode alloc 374/* parent fe, parent block, new file entry, inode alloc fe, inode alloc
323 * group descriptor + mkdir/symlink blocks */ 375 * group descriptor + mkdir/symlink blocks + quota update */
324#define OCFS2_MKNOD_CREDITS (3 + OCFS2_SUBALLOC_ALLOC \ 376static inline int ocfs2_mknod_credits(struct super_block *sb)
325 + OCFS2_DIR_LINK_ADDITIONAL_CREDITS) 377{
378 return 3 + OCFS2_SUBALLOC_ALLOC + OCFS2_DIR_LINK_ADDITIONAL_CREDITS +
379 ocfs2_quota_trans_credits(sb);
380}
326 381
327/* local alloc metadata change + main bitmap updates */ 382/* local alloc metadata change + main bitmap updates */
328#define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ 383#define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \
@@ -332,13 +387,21 @@ int ocfs2_journal_dirty_data(handle_t *handle,
332 * for the dinode, one for the new block. */ 387 * for the dinode, one for the new block. */
333#define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) 388#define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
334 389
335/* file update (nlink, etc) + directory mtime/ctime + dir entry block */ 390/* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota
336#define OCFS2_LINK_CREDITS (2*OCFS2_INODE_UPDATE_CREDITS + 1) 391 * update on dir */
392static inline int ocfs2_link_credits(struct super_block *sb)
393{
394 return 2*OCFS2_INODE_UPDATE_CREDITS + 1 +
395 ocfs2_quota_trans_credits(sb);
396}
337 397
338/* inode + dir inode (if we unlink a dir), + dir entry block + orphan 398/* inode + dir inode (if we unlink a dir), + dir entry block + orphan
339 * dir inode link */ 399 * dir inode link */
340#define OCFS2_UNLINK_CREDITS (2 * OCFS2_INODE_UPDATE_CREDITS + 1 \ 400static inline int ocfs2_unlink_credits(struct super_block *sb)
341 + OCFS2_LINK_CREDITS) 401{
402 /* The quota update from ocfs2_link_credits is unused here... */
403 return 2 * OCFS2_INODE_UPDATE_CREDITS + 1 + ocfs2_link_credits(sb);
404}
342 405
343/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + 406/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry +
344 * inode alloc group descriptor */ 407 * inode alloc group descriptor */
@@ -347,8 +410,10 @@ int ocfs2_journal_dirty_data(handle_t *handle,
347/* dinode update, old dir dinode update, new dir dinode update, old 410/* dinode update, old dir dinode update, new dir dinode update, old
348 * dir dir entry, new dir dir entry, dir entry update for renaming 411 * dir dir entry, new dir dir entry, dir entry update for renaming
349 * directory + target unlink */ 412 * directory + target unlink */
350#define OCFS2_RENAME_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3 \ 413static inline int ocfs2_rename_credits(struct super_block *sb)
351 + OCFS2_UNLINK_CREDITS) 414{
415 return 3 * OCFS2_INODE_UPDATE_CREDITS + 3 + ocfs2_unlink_credits(sb);
416}
352 417
353/* global bitmap dinode, group desc., relinked group, 418/* global bitmap dinode, group desc., relinked group,
354 * suballocator dinode, group desc., relinked group, 419 * suballocator dinode, group desc., relinked group,
@@ -386,18 +451,19 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb,
386 * credit for the dinode there. */ 451 * credit for the dinode there. */
387 extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); 452 extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth);
388 453
389 return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks; 454 return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks +
455 ocfs2_quota_trans_credits(sb);
390} 456}
391 457
392static inline int ocfs2_calc_symlink_credits(struct super_block *sb) 458static inline int ocfs2_calc_symlink_credits(struct super_block *sb)
393{ 459{
394 int blocks = OCFS2_MKNOD_CREDITS; 460 int blocks = ocfs2_mknod_credits(sb);
395 461
396 /* links can be longer than one block so we may update many 462 /* links can be longer than one block so we may update many
397 * within our single allocated extent. */ 463 * within our single allocated extent. */
398 blocks += ocfs2_clusters_to_blocks(sb, 1); 464 blocks += ocfs2_clusters_to_blocks(sb, 1);
399 465
400 return blocks; 466 return blocks + ocfs2_quota_trans_credits(sb);
401} 467}
402 468
403static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, 469static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb,
@@ -434,6 +500,8 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb,
434 /* update to the truncate log. */ 500 /* update to the truncate log. */
435 credits += OCFS2_TRUNCATE_LOG_UPDATE; 501 credits += OCFS2_TRUNCATE_LOG_UPDATE;
436 502
503 credits += ocfs2_quota_trans_credits(sb);
504
437 return credits; 505 return credits;
438} 506}
439 507
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 687b28713c32..ec70cdbe77fc 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -36,6 +36,7 @@
36#include "ocfs2.h" 36#include "ocfs2.h"
37 37
38#include "alloc.h" 38#include "alloc.h"
39#include "blockcheck.h"
39#include "dlmglue.h" 40#include "dlmglue.h"
40#include "inode.h" 41#include "inode.h"
41#include "journal.h" 42#include "journal.h"
@@ -248,8 +249,8 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
248 goto bail; 249 goto bail;
249 } 250 }
250 251
251 status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, 252 status = ocfs2_read_inode_block_full(inode, &alloc_bh,
252 &alloc_bh, OCFS2_BH_IGNORE_CACHE); 253 OCFS2_BH_IGNORE_CACHE);
253 if (status < 0) { 254 if (status < 0) {
254 mlog_errno(status); 255 mlog_errno(status);
255 goto bail; 256 goto bail;
@@ -382,8 +383,8 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
382 } 383 }
383 memcpy(alloc_copy, alloc, bh->b_size); 384 memcpy(alloc_copy, alloc, bh->b_size);
384 385
385 status = ocfs2_journal_access(handle, local_alloc_inode, bh, 386 status = ocfs2_journal_access_di(handle, local_alloc_inode, bh,
386 OCFS2_JOURNAL_ACCESS_WRITE); 387 OCFS2_JOURNAL_ACCESS_WRITE);
387 if (status < 0) { 388 if (status < 0) {
388 mlog_errno(status); 389 mlog_errno(status);
389 goto out_commit; 390 goto out_commit;
@@ -459,8 +460,8 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
459 460
460 mutex_lock(&inode->i_mutex); 461 mutex_lock(&inode->i_mutex);
461 462
462 status = ocfs2_read_blocks(inode, OCFS2_I(inode)->ip_blkno, 1, 463 status = ocfs2_read_inode_block_full(inode, &alloc_bh,
463 &alloc_bh, OCFS2_BH_IGNORE_CACHE); 464 OCFS2_BH_IGNORE_CACHE);
464 if (status < 0) { 465 if (status < 0) {
465 mlog_errno(status); 466 mlog_errno(status);
466 goto bail; 467 goto bail;
@@ -476,6 +477,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
476 alloc = (struct ocfs2_dinode *) alloc_bh->b_data; 477 alloc = (struct ocfs2_dinode *) alloc_bh->b_data;
477 ocfs2_clear_local_alloc(alloc); 478 ocfs2_clear_local_alloc(alloc);
478 479
480 ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check);
479 status = ocfs2_write_block(osb, alloc_bh, inode); 481 status = ocfs2_write_block(osb, alloc_bh, inode);
480 if (status < 0) 482 if (status < 0)
481 mlog_errno(status); 483 mlog_errno(status);
@@ -762,9 +764,9 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
762 * delete bits from it! */ 764 * delete bits from it! */
763 *num_bits = bits_wanted; 765 *num_bits = bits_wanted;
764 766
765 status = ocfs2_journal_access(handle, local_alloc_inode, 767 status = ocfs2_journal_access_di(handle, local_alloc_inode,
766 osb->local_alloc_bh, 768 osb->local_alloc_bh,
767 OCFS2_JOURNAL_ACCESS_WRITE); 769 OCFS2_JOURNAL_ACCESS_WRITE);
768 if (status < 0) { 770 if (status < 0) {
769 mlog_errno(status); 771 mlog_errno(status);
770 goto bail; 772 goto bail;
@@ -1240,9 +1242,9 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
1240 } 1242 }
1241 memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size); 1243 memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
1242 1244
1243 status = ocfs2_journal_access(handle, local_alloc_inode, 1245 status = ocfs2_journal_access_di(handle, local_alloc_inode,
1244 osb->local_alloc_bh, 1246 osb->local_alloc_bh,
1245 OCFS2_JOURNAL_ACCESS_WRITE); 1247 OCFS2_JOURNAL_ACCESS_WRITE);
1246 if (status < 0) { 1248 if (status < 0) {
1247 mlog_errno(status); 1249 mlog_errno(status);
1248 goto bail; 1250 goto bail;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 2545e7402efe..084aba86c3b2 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -40,6 +40,7 @@
40#include <linux/types.h> 40#include <linux/types.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/quotaops.h>
43 44
44#define MLOG_MASK_PREFIX ML_NAMEI 45#define MLOG_MASK_PREFIX ML_NAMEI
45#include <cluster/masklog.h> 46#include <cluster/masklog.h>
@@ -61,17 +62,18 @@
61#include "sysfile.h" 62#include "sysfile.h"
62#include "uptodate.h" 63#include "uptodate.h"
63#include "xattr.h" 64#include "xattr.h"
65#include "acl.h"
64 66
65#include "buffer_head_io.h" 67#include "buffer_head_io.h"
66 68
67static int ocfs2_mknod_locked(struct ocfs2_super *osb, 69static int ocfs2_mknod_locked(struct ocfs2_super *osb,
68 struct inode *dir, 70 struct inode *dir,
69 struct dentry *dentry, int mode, 71 struct inode *inode,
72 struct dentry *dentry,
70 dev_t dev, 73 dev_t dev,
71 struct buffer_head **new_fe_bh, 74 struct buffer_head **new_fe_bh,
72 struct buffer_head *parent_fe_bh, 75 struct buffer_head *parent_fe_bh,
73 handle_t *handle, 76 handle_t *handle,
74 struct inode **ret_inode,
75 struct ocfs2_alloc_context *inode_ac); 77 struct ocfs2_alloc_context *inode_ac);
76 78
77static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, 79static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
@@ -186,6 +188,35 @@ bail:
186 return ret; 188 return ret;
187} 189}
188 190
191static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
192{
193 struct inode *inode;
194
195 inode = new_inode(dir->i_sb);
196 if (!inode) {
197 mlog(ML_ERROR, "new_inode failed!\n");
198 return NULL;
199 }
200
201 /* populate as many fields early on as possible - many of
202 * these are used by the support functions here and in
203 * callers. */
204 if (S_ISDIR(mode))
205 inode->i_nlink = 2;
206 else
207 inode->i_nlink = 1;
208 inode->i_uid = current_fsuid();
209 if (dir->i_mode & S_ISGID) {
210 inode->i_gid = dir->i_gid;
211 if (S_ISDIR(mode))
212 mode |= S_ISGID;
213 } else
214 inode->i_gid = current_fsgid();
215 inode->i_mode = mode;
216 vfs_dq_init(inode);
217 return inode;
218}
219
189static int ocfs2_mknod(struct inode *dir, 220static int ocfs2_mknod(struct inode *dir,
190 struct dentry *dentry, 221 struct dentry *dentry,
191 int mode, 222 int mode,
@@ -201,6 +232,13 @@ static int ocfs2_mknod(struct inode *dir,
201 struct inode *inode = NULL; 232 struct inode *inode = NULL;
202 struct ocfs2_alloc_context *inode_ac = NULL; 233 struct ocfs2_alloc_context *inode_ac = NULL;
203 struct ocfs2_alloc_context *data_ac = NULL; 234 struct ocfs2_alloc_context *data_ac = NULL;
235 struct ocfs2_alloc_context *xattr_ac = NULL;
236 int want_clusters = 0;
237 int xattr_credits = 0;
238 struct ocfs2_security_xattr_info si = {
239 .enable = 1,
240 };
241 int did_quota_inode = 0;
204 242
205 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, 243 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode,
206 (unsigned long)dev, dentry->d_name.len, 244 (unsigned long)dev, dentry->d_name.len,
@@ -250,17 +288,46 @@ static int ocfs2_mknod(struct inode *dir,
250 goto leave; 288 goto leave;
251 } 289 }
252 290
253 /* Reserve a cluster if creating an extent based directory. */ 291 inode = ocfs2_get_init_inode(dir, mode);
254 if (S_ISDIR(mode) && !ocfs2_supports_inline_data(osb)) { 292 if (!inode) {
255 status = ocfs2_reserve_clusters(osb, 1, &data_ac); 293 status = -ENOMEM;
256 if (status < 0) { 294 mlog_errno(status);
257 if (status != -ENOSPC) 295 goto leave;
258 mlog_errno(status); 296 }
297
298 /* get security xattr */
299 status = ocfs2_init_security_get(inode, dir, &si);
300 if (status) {
301 if (status == -EOPNOTSUPP)
302 si.enable = 0;
303 else {
304 mlog_errno(status);
259 goto leave; 305 goto leave;
260 } 306 }
261 } 307 }
262 308
263 handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS); 309 /* calculate meta data/clusters for setting security and acl xattr */
310 status = ocfs2_calc_xattr_init(dir, parent_fe_bh, mode,
311 &si, &want_clusters,
312 &xattr_credits, &xattr_ac);
313 if (status < 0) {
314 mlog_errno(status);
315 goto leave;
316 }
317
318 /* Reserve a cluster if creating an extent based directory. */
319 if (S_ISDIR(mode) && !ocfs2_supports_inline_data(osb))
320 want_clusters += 1;
321
322 status = ocfs2_reserve_clusters(osb, want_clusters, &data_ac);
323 if (status < 0) {
324 if (status != -ENOSPC)
325 mlog_errno(status);
326 goto leave;
327 }
328
329 handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb) +
330 xattr_credits);
264 if (IS_ERR(handle)) { 331 if (IS_ERR(handle)) {
265 status = PTR_ERR(handle); 332 status = PTR_ERR(handle);
266 handle = NULL; 333 handle = NULL;
@@ -268,10 +335,19 @@ static int ocfs2_mknod(struct inode *dir,
268 goto leave; 335 goto leave;
269 } 336 }
270 337
338 /* We don't use standard VFS wrapper because we don't want vfs_dq_init
339 * to be called. */
340 if (sb_any_quota_active(osb->sb) &&
341 osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
342 status = -EDQUOT;
343 goto leave;
344 }
345 did_quota_inode = 1;
346
271 /* do the real work now. */ 347 /* do the real work now. */
272 status = ocfs2_mknod_locked(osb, dir, dentry, mode, dev, 348 status = ocfs2_mknod_locked(osb, dir, inode, dentry, dev,
273 &new_fe_bh, parent_fe_bh, handle, 349 &new_fe_bh, parent_fe_bh, handle,
274 &inode, inode_ac); 350 inode_ac);
275 if (status < 0) { 351 if (status < 0) {
276 mlog_errno(status); 352 mlog_errno(status);
277 goto leave; 353 goto leave;
@@ -285,8 +361,8 @@ static int ocfs2_mknod(struct inode *dir,
285 goto leave; 361 goto leave;
286 } 362 }
287 363
288 status = ocfs2_journal_access(handle, dir, parent_fe_bh, 364 status = ocfs2_journal_access_di(handle, dir, parent_fe_bh,
289 OCFS2_JOURNAL_ACCESS_WRITE); 365 OCFS2_JOURNAL_ACCESS_WRITE);
290 if (status < 0) { 366 if (status < 0) {
291 mlog_errno(status); 367 mlog_errno(status);
292 goto leave; 368 goto leave;
@@ -300,6 +376,22 @@ static int ocfs2_mknod(struct inode *dir,
300 inc_nlink(dir); 376 inc_nlink(dir);
301 } 377 }
302 378
379 status = ocfs2_init_acl(handle, inode, dir, new_fe_bh, parent_fe_bh,
380 xattr_ac, data_ac);
381 if (status < 0) {
382 mlog_errno(status);
383 goto leave;
384 }
385
386 if (si.enable) {
387 status = ocfs2_init_security_set(handle, inode, new_fe_bh, &si,
388 xattr_ac, data_ac);
389 if (status < 0) {
390 mlog_errno(status);
391 goto leave;
392 }
393 }
394
303 status = ocfs2_add_entry(handle, dentry, inode, 395 status = ocfs2_add_entry(handle, dentry, inode,
304 OCFS2_I(inode)->ip_blkno, parent_fe_bh, 396 OCFS2_I(inode)->ip_blkno, parent_fe_bh,
305 de_bh); 397 de_bh);
@@ -320,6 +412,8 @@ static int ocfs2_mknod(struct inode *dir,
320 d_instantiate(dentry, inode); 412 d_instantiate(dentry, inode);
321 status = 0; 413 status = 0;
322leave: 414leave:
415 if (status < 0 && did_quota_inode)
416 vfs_dq_free_inode(inode);
323 if (handle) 417 if (handle)
324 ocfs2_commit_trans(osb, handle); 418 ocfs2_commit_trans(osb, handle);
325 419
@@ -331,9 +425,13 @@ leave:
331 brelse(new_fe_bh); 425 brelse(new_fe_bh);
332 brelse(de_bh); 426 brelse(de_bh);
333 brelse(parent_fe_bh); 427 brelse(parent_fe_bh);
428 kfree(si.name);
429 kfree(si.value);
334 430
335 if ((status < 0) && inode) 431 if ((status < 0) && inode) {
432 clear_nlink(inode);
336 iput(inode); 433 iput(inode);
434 }
337 435
338 if (inode_ac) 436 if (inode_ac)
339 ocfs2_free_alloc_context(inode_ac); 437 ocfs2_free_alloc_context(inode_ac);
@@ -341,6 +439,9 @@ leave:
341 if (data_ac) 439 if (data_ac)
342 ocfs2_free_alloc_context(data_ac); 440 ocfs2_free_alloc_context(data_ac);
343 441
442 if (xattr_ac)
443 ocfs2_free_alloc_context(xattr_ac);
444
344 mlog_exit(status); 445 mlog_exit(status);
345 446
346 return status; 447 return status;
@@ -348,12 +449,12 @@ leave:
348 449
349static int ocfs2_mknod_locked(struct ocfs2_super *osb, 450static int ocfs2_mknod_locked(struct ocfs2_super *osb,
350 struct inode *dir, 451 struct inode *dir,
351 struct dentry *dentry, int mode, 452 struct inode *inode,
453 struct dentry *dentry,
352 dev_t dev, 454 dev_t dev,
353 struct buffer_head **new_fe_bh, 455 struct buffer_head **new_fe_bh,
354 struct buffer_head *parent_fe_bh, 456 struct buffer_head *parent_fe_bh,
355 handle_t *handle, 457 handle_t *handle,
356 struct inode **ret_inode,
357 struct ocfs2_alloc_context *inode_ac) 458 struct ocfs2_alloc_context *inode_ac)
358{ 459{
359 int status = 0; 460 int status = 0;
@@ -361,14 +462,12 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
361 struct ocfs2_extent_list *fel; 462 struct ocfs2_extent_list *fel;
362 u64 fe_blkno = 0; 463 u64 fe_blkno = 0;
363 u16 suballoc_bit; 464 u16 suballoc_bit;
364 struct inode *inode = NULL;
365 465
366 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, 466 mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry,
367 (unsigned long)dev, dentry->d_name.len, 467 inode->i_mode, (unsigned long)dev, dentry->d_name.len,
368 dentry->d_name.name); 468 dentry->d_name.name);
369 469
370 *new_fe_bh = NULL; 470 *new_fe_bh = NULL;
371 *ret_inode = NULL;
372 471
373 status = ocfs2_claim_new_inode(osb, handle, inode_ac, &suballoc_bit, 472 status = ocfs2_claim_new_inode(osb, handle, inode_ac, &suballoc_bit,
374 &fe_blkno); 473 &fe_blkno);
@@ -377,23 +476,11 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
377 goto leave; 476 goto leave;
378 } 477 }
379 478
380 inode = new_inode(dir->i_sb);
381 if (!inode) {
382 status = -ENOMEM;
383 mlog(ML_ERROR, "new_inode failed!\n");
384 goto leave;
385 }
386
387 /* populate as many fields early on as possible - many of 479 /* populate as many fields early on as possible - many of
388 * these are used by the support functions here and in 480 * these are used by the support functions here and in
389 * callers. */ 481 * callers. */
390 inode->i_ino = ino_from_blkno(osb->sb, fe_blkno); 482 inode->i_ino = ino_from_blkno(osb->sb, fe_blkno);
391 OCFS2_I(inode)->ip_blkno = fe_blkno; 483 OCFS2_I(inode)->ip_blkno = fe_blkno;
392 if (S_ISDIR(mode))
393 inode->i_nlink = 2;
394 else
395 inode->i_nlink = 1;
396 inode->i_mode = mode;
397 spin_lock(&osb->osb_lock); 484 spin_lock(&osb->osb_lock);
398 inode->i_generation = osb->s_next_generation++; 485 inode->i_generation = osb->s_next_generation++;
399 spin_unlock(&osb->osb_lock); 486 spin_unlock(&osb->osb_lock);
@@ -406,8 +493,8 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
406 } 493 }
407 ocfs2_set_new_buffer_uptodate(inode, *new_fe_bh); 494 ocfs2_set_new_buffer_uptodate(inode, *new_fe_bh);
408 495
409 status = ocfs2_journal_access(handle, inode, *new_fe_bh, 496 status = ocfs2_journal_access_di(handle, inode, *new_fe_bh,
410 OCFS2_JOURNAL_ACCESS_CREATE); 497 OCFS2_JOURNAL_ACCESS_CREATE);
411 if (status < 0) { 498 if (status < 0) {
412 mlog_errno(status); 499 mlog_errno(status);
413 goto leave; 500 goto leave;
@@ -421,17 +508,11 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
421 fe->i_blkno = cpu_to_le64(fe_blkno); 508 fe->i_blkno = cpu_to_le64(fe_blkno);
422 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); 509 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
423 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot); 510 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
424 fe->i_uid = cpu_to_le32(current_fsuid()); 511 fe->i_uid = cpu_to_le32(inode->i_uid);
425 if (dir->i_mode & S_ISGID) { 512 fe->i_gid = cpu_to_le32(inode->i_gid);
426 fe->i_gid = cpu_to_le32(dir->i_gid); 513 fe->i_mode = cpu_to_le16(inode->i_mode);
427 if (S_ISDIR(mode)) 514 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
428 mode |= S_ISGID;
429 } else
430 fe->i_gid = cpu_to_le32(current_fsgid());
431 fe->i_mode = cpu_to_le16(mode);
432 if (S_ISCHR(mode) || S_ISBLK(mode))
433 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev)); 515 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
434
435 fe->i_links_count = cpu_to_le16(inode->i_nlink); 516 fe->i_links_count = cpu_to_le16(inode->i_nlink);
436 517
437 fe->i_last_eb_blk = 0; 518 fe->i_last_eb_blk = 0;
@@ -446,7 +527,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
446 /* 527 /*
447 * If supported, directories start with inline data. 528 * If supported, directories start with inline data.
448 */ 529 */
449 if (S_ISDIR(mode) && ocfs2_supports_inline_data(osb)) { 530 if (S_ISDIR(inode->i_mode) && ocfs2_supports_inline_data(osb)) {
450 u16 feat = le16_to_cpu(fe->i_dyn_features); 531 u16 feat = le16_to_cpu(fe->i_dyn_features);
451 532
452 fe->i_dyn_features = cpu_to_le16(feat | OCFS2_INLINE_DATA_FL); 533 fe->i_dyn_features = cpu_to_le16(feat | OCFS2_INLINE_DATA_FL);
@@ -465,15 +546,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
465 goto leave; 546 goto leave;
466 } 547 }
467 548
468 if (ocfs2_populate_inode(inode, fe, 1) < 0) { 549 ocfs2_populate_inode(inode, fe, 1);
469 mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, "
470 "i_blkno=%llu, i_ino=%lu\n",
471 (unsigned long long)(*new_fe_bh)->b_blocknr,
472 (unsigned long long)le64_to_cpu(fe->i_blkno),
473 inode->i_ino);
474 BUG();
475 }
476
477 ocfs2_inode_set_new(osb, inode); 550 ocfs2_inode_set_new(osb, inode);
478 if (!ocfs2_mount_local(osb)) { 551 if (!ocfs2_mount_local(osb)) {
479 status = ocfs2_create_new_inode_locks(inode); 552 status = ocfs2_create_new_inode_locks(inode);
@@ -484,17 +557,12 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
484 status = 0; /* error in ocfs2_create_new_inode_locks is not 557 status = 0; /* error in ocfs2_create_new_inode_locks is not
485 * critical */ 558 * critical */
486 559
487 *ret_inode = inode;
488leave: 560leave:
489 if (status < 0) { 561 if (status < 0) {
490 if (*new_fe_bh) { 562 if (*new_fe_bh) {
491 brelse(*new_fe_bh); 563 brelse(*new_fe_bh);
492 *new_fe_bh = NULL; 564 *new_fe_bh = NULL;
493 } 565 }
494 if (inode) {
495 clear_nlink(inode);
496 iput(inode);
497 }
498 } 566 }
499 567
500 mlog_exit(status); 568 mlog_exit(status);
@@ -588,7 +656,7 @@ static int ocfs2_link(struct dentry *old_dentry,
588 goto out_unlock_inode; 656 goto out_unlock_inode;
589 } 657 }
590 658
591 handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS); 659 handle = ocfs2_start_trans(osb, ocfs2_link_credits(osb->sb));
592 if (IS_ERR(handle)) { 660 if (IS_ERR(handle)) {
593 err = PTR_ERR(handle); 661 err = PTR_ERR(handle);
594 handle = NULL; 662 handle = NULL;
@@ -596,8 +664,8 @@ static int ocfs2_link(struct dentry *old_dentry,
596 goto out_unlock_inode; 664 goto out_unlock_inode;
597 } 665 }
598 666
599 err = ocfs2_journal_access(handle, inode, fe_bh, 667 err = ocfs2_journal_access_di(handle, inode, fe_bh,
600 OCFS2_JOURNAL_ACCESS_WRITE); 668 OCFS2_JOURNAL_ACCESS_WRITE);
601 if (err < 0) { 669 if (err < 0) {
602 mlog_errno(err); 670 mlog_errno(err);
603 goto out_commit; 671 goto out_commit;
@@ -775,7 +843,7 @@ static int ocfs2_unlink(struct inode *dir,
775 } 843 }
776 } 844 }
777 845
778 handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS); 846 handle = ocfs2_start_trans(osb, ocfs2_unlink_credits(osb->sb));
779 if (IS_ERR(handle)) { 847 if (IS_ERR(handle)) {
780 status = PTR_ERR(handle); 848 status = PTR_ERR(handle);
781 handle = NULL; 849 handle = NULL;
@@ -783,8 +851,8 @@ static int ocfs2_unlink(struct inode *dir,
783 goto leave; 851 goto leave;
784 } 852 }
785 853
786 status = ocfs2_journal_access(handle, inode, fe_bh, 854 status = ocfs2_journal_access_di(handle, inode, fe_bh,
787 OCFS2_JOURNAL_ACCESS_WRITE); 855 OCFS2_JOURNAL_ACCESS_WRITE);
788 if (status < 0) { 856 if (status < 0) {
789 mlog_errno(status); 857 mlog_errno(status);
790 goto leave; 858 goto leave;
@@ -1181,7 +1249,7 @@ static int ocfs2_rename(struct inode *old_dir,
1181 } 1249 }
1182 } 1250 }
1183 1251
1184 handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS); 1252 handle = ocfs2_start_trans(osb, ocfs2_rename_credits(osb->sb));
1185 if (IS_ERR(handle)) { 1253 if (IS_ERR(handle)) {
1186 status = PTR_ERR(handle); 1254 status = PTR_ERR(handle);
1187 handle = NULL; 1255 handle = NULL;
@@ -1197,8 +1265,8 @@ static int ocfs2_rename(struct inode *old_dir,
1197 goto bail; 1265 goto bail;
1198 } 1266 }
1199 } 1267 }
1200 status = ocfs2_journal_access(handle, new_inode, newfe_bh, 1268 status = ocfs2_journal_access_di(handle, new_inode, newfe_bh,
1201 OCFS2_JOURNAL_ACCESS_WRITE); 1269 OCFS2_JOURNAL_ACCESS_WRITE);
1202 if (status < 0) { 1270 if (status < 0) {
1203 mlog_errno(status); 1271 mlog_errno(status);
1204 goto bail; 1272 goto bail;
@@ -1244,8 +1312,8 @@ static int ocfs2_rename(struct inode *old_dir,
1244 old_inode->i_ctime = CURRENT_TIME; 1312 old_inode->i_ctime = CURRENT_TIME;
1245 mark_inode_dirty(old_inode); 1313 mark_inode_dirty(old_inode);
1246 1314
1247 status = ocfs2_journal_access(handle, old_inode, old_inode_bh, 1315 status = ocfs2_journal_access_di(handle, old_inode, old_inode_bh,
1248 OCFS2_JOURNAL_ACCESS_WRITE); 1316 OCFS2_JOURNAL_ACCESS_WRITE);
1249 if (status >= 0) { 1317 if (status >= 0) {
1250 old_di = (struct ocfs2_dinode *) old_inode_bh->b_data; 1318 old_di = (struct ocfs2_dinode *) old_inode_bh->b_data;
1251 1319
@@ -1321,9 +1389,9 @@ static int ocfs2_rename(struct inode *old_dir,
1321 (int)old_dir_nlink, old_dir->i_nlink); 1389 (int)old_dir_nlink, old_dir->i_nlink);
1322 } else { 1390 } else {
1323 struct ocfs2_dinode *fe; 1391 struct ocfs2_dinode *fe;
1324 status = ocfs2_journal_access(handle, old_dir, 1392 status = ocfs2_journal_access_di(handle, old_dir,
1325 old_dir_bh, 1393 old_dir_bh,
1326 OCFS2_JOURNAL_ACCESS_WRITE); 1394 OCFS2_JOURNAL_ACCESS_WRITE);
1327 fe = (struct ocfs2_dinode *) old_dir_bh->b_data; 1395 fe = (struct ocfs2_dinode *) old_dir_bh->b_data;
1328 fe->i_links_count = cpu_to_le16(old_dir->i_nlink); 1396 fe->i_links_count = cpu_to_le16(old_dir->i_nlink);
1329 status = ocfs2_journal_dirty(handle, old_dir_bh); 1397 status = ocfs2_journal_dirty(handle, old_dir_bh);
@@ -1496,6 +1564,13 @@ static int ocfs2_symlink(struct inode *dir,
1496 handle_t *handle = NULL; 1564 handle_t *handle = NULL;
1497 struct ocfs2_alloc_context *inode_ac = NULL; 1565 struct ocfs2_alloc_context *inode_ac = NULL;
1498 struct ocfs2_alloc_context *data_ac = NULL; 1566 struct ocfs2_alloc_context *data_ac = NULL;
1567 struct ocfs2_alloc_context *xattr_ac = NULL;
1568 int want_clusters = 0;
1569 int xattr_credits = 0;
1570 struct ocfs2_security_xattr_info si = {
1571 .enable = 1,
1572 };
1573 int did_quota = 0, did_quota_inode = 0;
1499 1574
1500 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, 1575 mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir,
1501 dentry, symname, dentry->d_name.len, dentry->d_name.name); 1576 dentry, symname, dentry->d_name.len, dentry->d_name.name);
@@ -1542,17 +1617,46 @@ static int ocfs2_symlink(struct inode *dir,
1542 goto bail; 1617 goto bail;
1543 } 1618 }
1544 1619
1545 /* don't reserve bitmap space for fast symlinks. */ 1620 inode = ocfs2_get_init_inode(dir, S_IFLNK | S_IRWXUGO);
1546 if (l > ocfs2_fast_symlink_chars(sb)) { 1621 if (!inode) {
1547 status = ocfs2_reserve_clusters(osb, 1, &data_ac); 1622 status = -ENOMEM;
1623 mlog_errno(status);
1624 goto bail;
1625 }
1626
1627 /* get security xattr */
1628 status = ocfs2_init_security_get(inode, dir, &si);
1629 if (status) {
1630 if (status == -EOPNOTSUPP)
1631 si.enable = 0;
1632 else {
1633 mlog_errno(status);
1634 goto bail;
1635 }
1636 }
1637
1638 /* calculate meta data/clusters for setting security xattr */
1639 if (si.enable) {
1640 status = ocfs2_calc_security_init(dir, &si, &want_clusters,
1641 &xattr_credits, &xattr_ac);
1548 if (status < 0) { 1642 if (status < 0) {
1549 if (status != -ENOSPC) 1643 mlog_errno(status);
1550 mlog_errno(status);
1551 goto bail; 1644 goto bail;
1552 } 1645 }
1553 } 1646 }
1554 1647
1555 handle = ocfs2_start_trans(osb, credits); 1648 /* don't reserve bitmap space for fast symlinks. */
1649 if (l > ocfs2_fast_symlink_chars(sb))
1650 want_clusters += 1;
1651
1652 status = ocfs2_reserve_clusters(osb, want_clusters, &data_ac);
1653 if (status < 0) {
1654 if (status != -ENOSPC)
1655 mlog_errno(status);
1656 goto bail;
1657 }
1658
1659 handle = ocfs2_start_trans(osb, credits + xattr_credits);
1556 if (IS_ERR(handle)) { 1660 if (IS_ERR(handle)) {
1557 status = PTR_ERR(handle); 1661 status = PTR_ERR(handle);
1558 handle = NULL; 1662 handle = NULL;
@@ -1560,10 +1664,18 @@ static int ocfs2_symlink(struct inode *dir,
1560 goto bail; 1664 goto bail;
1561 } 1665 }
1562 1666
1563 status = ocfs2_mknod_locked(osb, dir, dentry, 1667 /* We don't use standard VFS wrapper because we don't want vfs_dq_init
1564 S_IFLNK | S_IRWXUGO, 0, 1668 * to be called. */
1565 &new_fe_bh, parent_fe_bh, handle, 1669 if (sb_any_quota_active(osb->sb) &&
1566 &inode, inode_ac); 1670 osb->sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) {
1671 status = -EDQUOT;
1672 goto bail;
1673 }
1674 did_quota_inode = 1;
1675
1676 status = ocfs2_mknod_locked(osb, dir, inode, dentry,
1677 0, &new_fe_bh, parent_fe_bh, handle,
1678 inode_ac);
1567 if (status < 0) { 1679 if (status < 0) {
1568 mlog_errno(status); 1680 mlog_errno(status);
1569 goto bail; 1681 goto bail;
@@ -1576,6 +1688,12 @@ static int ocfs2_symlink(struct inode *dir,
1576 u32 offset = 0; 1688 u32 offset = 0;
1577 1689
1578 inode->i_op = &ocfs2_symlink_inode_operations; 1690 inode->i_op = &ocfs2_symlink_inode_operations;
1691 if (vfs_dq_alloc_space_nodirty(inode,
1692 ocfs2_clusters_to_bytes(osb->sb, 1))) {
1693 status = -EDQUOT;
1694 goto bail;
1695 }
1696 did_quota = 1;
1579 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0, 1697 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0,
1580 new_fe_bh, 1698 new_fe_bh,
1581 handle, data_ac, NULL, 1699 handle, data_ac, NULL,
@@ -1614,6 +1732,15 @@ static int ocfs2_symlink(struct inode *dir,
1614 } 1732 }
1615 } 1733 }
1616 1734
1735 if (si.enable) {
1736 status = ocfs2_init_security_set(handle, inode, new_fe_bh, &si,
1737 xattr_ac, data_ac);
1738 if (status < 0) {
1739 mlog_errno(status);
1740 goto bail;
1741 }
1742 }
1743
1617 status = ocfs2_add_entry(handle, dentry, inode, 1744 status = ocfs2_add_entry(handle, dentry, inode,
1618 le64_to_cpu(fe->i_blkno), parent_fe_bh, 1745 le64_to_cpu(fe->i_blkno), parent_fe_bh,
1619 de_bh); 1746 de_bh);
@@ -1632,6 +1759,11 @@ static int ocfs2_symlink(struct inode *dir,
1632 dentry->d_op = &ocfs2_dentry_ops; 1759 dentry->d_op = &ocfs2_dentry_ops;
1633 d_instantiate(dentry, inode); 1760 d_instantiate(dentry, inode);
1634bail: 1761bail:
1762 if (status < 0 && did_quota)
1763 vfs_dq_free_space_nodirty(inode,
1764 ocfs2_clusters_to_bytes(osb->sb, 1));
1765 if (status < 0 && did_quota_inode)
1766 vfs_dq_free_inode(inode);
1635 if (handle) 1767 if (handle)
1636 ocfs2_commit_trans(osb, handle); 1768 ocfs2_commit_trans(osb, handle);
1637 1769
@@ -1640,12 +1772,18 @@ bail:
1640 brelse(new_fe_bh); 1772 brelse(new_fe_bh);
1641 brelse(parent_fe_bh); 1773 brelse(parent_fe_bh);
1642 brelse(de_bh); 1774 brelse(de_bh);
1775 kfree(si.name);
1776 kfree(si.value);
1643 if (inode_ac) 1777 if (inode_ac)
1644 ocfs2_free_alloc_context(inode_ac); 1778 ocfs2_free_alloc_context(inode_ac);
1645 if (data_ac) 1779 if (data_ac)
1646 ocfs2_free_alloc_context(data_ac); 1780 ocfs2_free_alloc_context(data_ac);
1647 if ((status < 0) && inode) 1781 if (xattr_ac)
1782 ocfs2_free_alloc_context(xattr_ac);
1783 if ((status < 0) && inode) {
1784 clear_nlink(inode);
1648 iput(inode); 1785 iput(inode);
1786 }
1649 1787
1650 mlog_exit(status); 1788 mlog_exit(status);
1651 1789
@@ -1754,16 +1892,14 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
1754 1892
1755 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 1893 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
1756 1894
1757 status = ocfs2_read_block(orphan_dir_inode, 1895 status = ocfs2_read_inode_block(orphan_dir_inode, &orphan_dir_bh);
1758 OCFS2_I(orphan_dir_inode)->ip_blkno,
1759 &orphan_dir_bh);
1760 if (status < 0) { 1896 if (status < 0) {
1761 mlog_errno(status); 1897 mlog_errno(status);
1762 goto leave; 1898 goto leave;
1763 } 1899 }
1764 1900
1765 status = ocfs2_journal_access(handle, orphan_dir_inode, orphan_dir_bh, 1901 status = ocfs2_journal_access_di(handle, orphan_dir_inode, orphan_dir_bh,
1766 OCFS2_JOURNAL_ACCESS_WRITE); 1902 OCFS2_JOURNAL_ACCESS_WRITE);
1767 if (status < 0) { 1903 if (status < 0) {
1768 mlog_errno(status); 1904 mlog_errno(status);
1769 goto leave; 1905 goto leave;
@@ -1850,8 +1986,8 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
1850 goto leave; 1986 goto leave;
1851 } 1987 }
1852 1988
1853 status = ocfs2_journal_access(handle,orphan_dir_inode, orphan_dir_bh, 1989 status = ocfs2_journal_access_di(handle,orphan_dir_inode, orphan_dir_bh,
1854 OCFS2_JOURNAL_ACCESS_WRITE); 1990 OCFS2_JOURNAL_ACCESS_WRITE);
1855 if (status < 0) { 1991 if (status < 0) {
1856 mlog_errno(status); 1992 mlog_errno(status);
1857 goto leave; 1993 goto leave;
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 3fed9e3d8992..ad5c24a29edd 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -161,6 +161,7 @@ enum ocfs2_vol_state
161{ 161{
162 VOLUME_INIT = 0, 162 VOLUME_INIT = 0,
163 VOLUME_MOUNTED, 163 VOLUME_MOUNTED,
164 VOLUME_MOUNTED_QUOTAS,
164 VOLUME_DISMOUNTED, 165 VOLUME_DISMOUNTED,
165 VOLUME_DISABLED 166 VOLUME_DISABLED
166}; 167};
@@ -195,6 +196,9 @@ enum ocfs2_mount_options
195 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */ 196 OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
196 OCFS2_MOUNT_NOUSERXATTR = 1 << 6, /* No user xattr */ 197 OCFS2_MOUNT_NOUSERXATTR = 1 << 6, /* No user xattr */
197 OCFS2_MOUNT_INODE64 = 1 << 7, /* Allow inode numbers > 2^32 */ 198 OCFS2_MOUNT_INODE64 = 1 << 7, /* Allow inode numbers > 2^32 */
199 OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
200 OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
201 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
198}; 202};
199 203
200#define OCFS2_OSB_SOFT_RO 0x0001 204#define OCFS2_OSB_SOFT_RO 0x0001
@@ -205,6 +209,7 @@ enum ocfs2_mount_options
205struct ocfs2_journal; 209struct ocfs2_journal;
206struct ocfs2_slot_info; 210struct ocfs2_slot_info;
207struct ocfs2_recovery_map; 211struct ocfs2_recovery_map;
212struct ocfs2_quota_recovery;
208struct ocfs2_super 213struct ocfs2_super
209{ 214{
210 struct task_struct *commit_task; 215 struct task_struct *commit_task;
@@ -286,10 +291,11 @@ struct ocfs2_super
286 char *local_alloc_debug_buf; 291 char *local_alloc_debug_buf;
287#endif 292#endif
288 293
289 /* Next two fields are for local node slot recovery during 294 /* Next three fields are for local node slot recovery during
290 * mount. */ 295 * mount. */
291 int dirty; 296 int dirty;
292 struct ocfs2_dinode *local_alloc_copy; 297 struct ocfs2_dinode *local_alloc_copy;
298 struct ocfs2_quota_recovery *quota_rec;
293 299
294 struct ocfs2_alloc_stats alloc_stats; 300 struct ocfs2_alloc_stats alloc_stats;
295 char dev_str[20]; /* "major,minor" of the device */ 301 char dev_str[20]; /* "major,minor" of the device */
@@ -333,6 +339,10 @@ struct ocfs2_super
333 339
334#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info) 340#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info)
335 341
342/* Useful typedef for passing around journal access functions */
343typedef int (*ocfs2_journal_access_func)(handle_t *handle, struct inode *inode,
344 struct buffer_head *bh, int type);
345
336static inline int ocfs2_should_order_data(struct inode *inode) 346static inline int ocfs2_should_order_data(struct inode *inode)
337{ 347{
338 if (!S_ISREG(inode->i_mode)) 348 if (!S_ISREG(inode->i_mode))
@@ -376,6 +386,13 @@ static inline int ocfs2_supports_xattr(struct ocfs2_super *osb)
376 return 0; 386 return 0;
377} 387}
378 388
389static inline int ocfs2_meta_ecc(struct ocfs2_super *osb)
390{
391 if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_META_ECC)
392 return 1;
393 return 0;
394}
395
379/* set / clear functions because cluster events can make these happen 396/* set / clear functions because cluster events can make these happen
380 * in parallel so we want the transitions to be atomic. this also 397 * in parallel so we want the transitions to be atomic. this also
381 * means that any future flags osb_flags must be protected by spinlock 398 * means that any future flags osb_flags must be protected by spinlock
@@ -443,39 +460,19 @@ static inline int ocfs2_uses_extended_slot_map(struct ocfs2_super *osb)
443#define OCFS2_IS_VALID_DINODE(ptr) \ 460#define OCFS2_IS_VALID_DINODE(ptr) \
444 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) 461 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))
445 462
446#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do { \
447 typeof(__di) ____di = (__di); \
448 ocfs2_error((__sb), \
449 "Dinode # %llu has bad signature %.*s", \
450 (unsigned long long)le64_to_cpu((____di)->i_blkno), 7, \
451 (____di)->i_signature); \
452} while (0)
453
454#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \ 463#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \
455 (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE)) 464 (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE))
456 465
457#define OCFS2_RO_ON_INVALID_EXTENT_BLOCK(__sb, __eb) do { \
458 typeof(__eb) ____eb = (__eb); \
459 ocfs2_error((__sb), \
460 "Extent Block # %llu has bad signature %.*s", \
461 (unsigned long long)le64_to_cpu((____eb)->h_blkno), 7, \
462 (____eb)->h_signature); \
463} while (0)
464
465#define OCFS2_IS_VALID_GROUP_DESC(ptr) \ 466#define OCFS2_IS_VALID_GROUP_DESC(ptr) \
466 (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE)) 467 (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE))
467 468
468#define OCFS2_RO_ON_INVALID_GROUP_DESC(__sb, __gd) do { \
469 typeof(__gd) ____gd = (__gd); \
470 ocfs2_error((__sb), \
471 "Group Descriptor # %llu has bad signature %.*s", \
472 (unsigned long long)le64_to_cpu((____gd)->bg_blkno), 7, \
473 (____gd)->bg_signature); \
474} while (0)
475 469
476#define OCFS2_IS_VALID_XATTR_BLOCK(ptr) \ 470#define OCFS2_IS_VALID_XATTR_BLOCK(ptr) \
477 (!strcmp((ptr)->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE)) 471 (!strcmp((ptr)->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE))
478 472
473#define OCFS2_IS_VALID_DIR_TRAILER(ptr) \
474 (!strcmp((ptr)->db_signature, OCFS2_DIR_TRAILER_SIGNATURE))
475
479static inline unsigned long ino_from_blkno(struct super_block *sb, 476static inline unsigned long ino_from_blkno(struct super_block *sb,
480 u64 blkno) 477 u64 blkno)
481{ 478{
@@ -632,5 +629,6 @@ static inline s16 ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
632#define ocfs2_clear_bit ext2_clear_bit 629#define ocfs2_clear_bit ext2_clear_bit
633#define ocfs2_test_bit ext2_test_bit 630#define ocfs2_test_bit ext2_test_bit
634#define ocfs2_find_next_zero_bit ext2_find_next_zero_bit 631#define ocfs2_find_next_zero_bit ext2_find_next_zero_bit
632#define ocfs2_find_next_bit ext2_find_next_bit
635#endif /* OCFS2_H */ 633#endif /* OCFS2_H */
636 634
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
index 5e0c0d0aef7d..c7ae45aaa36c 100644
--- a/fs/ocfs2/ocfs2_fs.h
+++ b/fs/ocfs2/ocfs2_fs.h
@@ -65,6 +65,7 @@
65#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01" 65#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
66#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01" 66#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01"
67#define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01" 67#define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
68#define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
68 69
69/* Compatibility flags */ 70/* Compatibility flags */
70#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ 71#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
@@ -93,8 +94,11 @@
93 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \ 94 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
94 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ 95 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
95 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \ 96 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
96 | OCFS2_FEATURE_INCOMPAT_XATTR) 97 | OCFS2_FEATURE_INCOMPAT_XATTR \
97#define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 98 | OCFS2_FEATURE_INCOMPAT_META_ECC)
99#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
100 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
101 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
98 102
99/* 103/*
100 * Heartbeat-only devices are missing journals and other files. The 104 * Heartbeat-only devices are missing journals and other files. The
@@ -147,6 +151,9 @@
147/* Support for extended attributes */ 151/* Support for extended attributes */
148#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200 152#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
149 153
154/* Metadata checksum and error correction */
155#define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
156
150/* 157/*
151 * backup superblock flag is used to indicate that this volume 158 * backup superblock flag is used to indicate that this volume
152 * has backup superblocks. 159 * has backup superblocks.
@@ -163,6 +170,12 @@
163 */ 170 */
164#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001 171#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
165 172
173/*
174 * Maintain quota information for this filesystem
175 */
176#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
177#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
178
166/* The byte offset of the first backup block will be 1G. 179/* The byte offset of the first backup block will be 1G.
167 * The following will be 4G, 16G, 64G, 256G and 1T. 180 * The following will be 4G, 16G, 64G, 256G and 1T.
168 */ 181 */
@@ -192,6 +205,7 @@
192#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */ 205#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
193#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */ 206#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
194#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */ 207#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
208#define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
195 209
196/* 210/*
197 * Flags on ocfs2_dinode.i_dyn_features 211 * Flags on ocfs2_dinode.i_dyn_features
@@ -329,13 +343,17 @@ enum {
329#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE 343#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
330 HEARTBEAT_SYSTEM_INODE, 344 HEARTBEAT_SYSTEM_INODE,
331 GLOBAL_BITMAP_SYSTEM_INODE, 345 GLOBAL_BITMAP_SYSTEM_INODE,
332#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE 346 USER_QUOTA_SYSTEM_INODE,
347 GROUP_QUOTA_SYSTEM_INODE,
348#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
333 ORPHAN_DIR_SYSTEM_INODE, 349 ORPHAN_DIR_SYSTEM_INODE,
334 EXTENT_ALLOC_SYSTEM_INODE, 350 EXTENT_ALLOC_SYSTEM_INODE,
335 INODE_ALLOC_SYSTEM_INODE, 351 INODE_ALLOC_SYSTEM_INODE,
336 JOURNAL_SYSTEM_INODE, 352 JOURNAL_SYSTEM_INODE,
337 LOCAL_ALLOC_SYSTEM_INODE, 353 LOCAL_ALLOC_SYSTEM_INODE,
338 TRUNCATE_LOG_SYSTEM_INODE, 354 TRUNCATE_LOG_SYSTEM_INODE,
355 LOCAL_USER_QUOTA_SYSTEM_INODE,
356 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
339 NUM_SYSTEM_INODES 357 NUM_SYSTEM_INODES
340}; 358};
341 359
@@ -349,6 +367,8 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
349 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 }, 367 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
350 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 }, 368 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
351 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 }, 369 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
370 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
371 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
352 372
353 /* Slot-specific system inodes (one copy per slot) */ 373 /* Slot-specific system inodes (one copy per slot) */
354 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 }, 374 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
@@ -356,7 +376,9 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
356 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, 376 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
357 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 }, 377 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
358 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }, 378 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
359 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 } 379 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
380 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
381 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
360}; 382};
361 383
362/* Parameter passed from mount.ocfs2 to module */ 384/* Parameter passed from mount.ocfs2 to module */
@@ -410,6 +432,22 @@ static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
410#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super)) 432#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
411 433
412/* 434/*
435 * Block checking structure. This is used in metadata to validate the
436 * contents. If OCFS2_FEATURE_INCOMPAT_META_ECC is not set, it is all
437 * zeros.
438 */
439struct ocfs2_block_check {
440/*00*/ __le32 bc_crc32e; /* 802.3 Ethernet II CRC32 */
441 __le16 bc_ecc; /* Single-error-correction parity vector.
442 This is a simple Hamming code dependant
443 on the blocksize. OCFS2's maximum
444 blocksize, 4K, requires 16 parity bits,
445 so we fit in __le16. */
446 __le16 bc_reserved1;
447/*08*/
448};
449
450/*
413 * On disk extent record for OCFS2 451 * On disk extent record for OCFS2
414 * It describes a range of clusters on disk. 452 * It describes a range of clusters on disk.
415 * 453 *
@@ -496,7 +534,7 @@ struct ocfs2_truncate_log {
496struct ocfs2_extent_block 534struct ocfs2_extent_block
497{ 535{
498/*00*/ __u8 h_signature[8]; /* Signature for verification */ 536/*00*/ __u8 h_signature[8]; /* Signature for verification */
499 __le64 h_reserved1; 537 struct ocfs2_block_check h_check; /* Error checking */
500/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this 538/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this
501 extent_header belongs to */ 539 extent_header belongs to */
502 __le16 h_suballoc_bit; /* Bit offset in suballocator 540 __le16 h_suballoc_bit; /* Bit offset in suballocator
@@ -666,7 +704,8 @@ struct ocfs2_dinode {
666 was set in i_flags */ 704 was set in i_flags */
667 __le16 i_dyn_features; 705 __le16 i_dyn_features;
668 __le64 i_xattr_loc; 706 __le64 i_xattr_loc;
669/*80*/ __le64 i_reserved2[7]; 707/*80*/ struct ocfs2_block_check i_check; /* Error checking */
708/*88*/ __le64 i_reserved2[6];
670/*B8*/ union { 709/*B8*/ union {
671 __le64 i_pad1; /* Generic way to refer to this 710 __le64 i_pad1; /* Generic way to refer to this
672 64bit union */ 711 64bit union */
@@ -715,6 +754,34 @@ struct ocfs2_dir_entry {
715} __attribute__ ((packed)); 754} __attribute__ ((packed));
716 755
717/* 756/*
757 * Per-block record for the unindexed directory btree. This is carefully
758 * crafted so that the rec_len and name_len records of an ocfs2_dir_entry are
759 * mirrored. That way, the directory manipulation code needs a minimal amount
760 * of update.
761 *
762 * NOTE: Keep this structure aligned to a multiple of 4 bytes.
763 */
764struct ocfs2_dir_block_trailer {
765/*00*/ __le64 db_compat_inode; /* Always zero. Was inode */
766
767 __le16 db_compat_rec_len; /* Backwards compatible with
768 * ocfs2_dir_entry. */
769 __u8 db_compat_name_len; /* Always zero. Was name_len */
770 __u8 db_reserved0;
771 __le16 db_reserved1;
772 __le16 db_free_rec_len; /* Size of largest empty hole
773 * in this block. (unused) */
774/*10*/ __u8 db_signature[8]; /* Signature for verification */
775 __le64 db_reserved2;
776 __le64 db_free_next; /* Next block in list (unused) */
777/*20*/ __le64 db_blkno; /* Offset on disk, in blocks */
778 __le64 db_parent_dinode; /* dinode which owns me, in
779 blocks */
780/*30*/ struct ocfs2_block_check db_check; /* Error checking */
781/*40*/
782};
783
784/*
718 * On disk allocator group structure for OCFS2 785 * On disk allocator group structure for OCFS2
719 */ 786 */
720struct ocfs2_group_desc 787struct ocfs2_group_desc
@@ -733,7 +800,8 @@ struct ocfs2_group_desc
733/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in 800/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in
734 blocks */ 801 blocks */
735 __le64 bg_blkno; /* Offset on disk, in blocks */ 802 __le64 bg_blkno; /* Offset on disk, in blocks */
736/*30*/ __le64 bg_reserved2[2]; 803/*30*/ struct ocfs2_block_check bg_check; /* Error checking */
804 __le64 bg_reserved2;
737/*40*/ __u8 bg_bitmap[0]; 805/*40*/ __u8 bg_bitmap[0];
738}; 806};
739 807
@@ -776,7 +844,12 @@ struct ocfs2_xattr_header {
776 in this extent record, 844 in this extent record,
777 only valid in the first 845 only valid in the first
778 bucket. */ 846 bucket. */
779 __le64 xh_csum; 847 struct ocfs2_block_check xh_check; /* Error checking
848 (Note, this is only
849 used for xattr
850 buckets. A block uses
851 xb_check and sets
852 this field to zero.) */
780 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */ 853 struct ocfs2_xattr_entry xh_entries[0]; /* xattr entry list. */
781}; 854};
782 855
@@ -827,7 +900,7 @@ struct ocfs2_xattr_block {
827 block group */ 900 block group */
828 __le32 xb_fs_generation; /* Must match super block */ 901 __le32 xb_fs_generation; /* Must match super block */
829/*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */ 902/*10*/ __le64 xb_blkno; /* Offset on disk, in blocks */
830 __le64 xb_csum; 903 struct ocfs2_block_check xb_check; /* Error checking */
831/*20*/ __le16 xb_flags; /* Indicates whether this block contains 904/*20*/ __le16 xb_flags; /* Indicates whether this block contains
832 real xattr or a xattr tree. */ 905 real xattr or a xattr tree. */
833 __le16 xb_reserved0; 906 __le16 xb_reserved0;
@@ -868,6 +941,128 @@ static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
868 return xe->xe_type & OCFS2_XATTR_TYPE_MASK; 941 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
869} 942}
870 943
944/*
945 * On disk structures for global quota file
946 */
947
948/* Magic numbers and known versions for global quota files */
949#define OCFS2_GLOBAL_QMAGICS {\
950 0x0cf52470, /* USRQUOTA */ \
951 0x0cf52471 /* GRPQUOTA */ \
952}
953
954#define OCFS2_GLOBAL_QVERSIONS {\
955 0, \
956 0, \
957}
958
959
960/* Each block of each quota file has a certain fixed number of bytes reserved
961 * for OCFS2 internal use at its end. OCFS2 can use it for things like
962 * checksums, etc. */
963#define OCFS2_QBLK_RESERVED_SPACE 8
964
965/* Generic header of all quota files */
966struct ocfs2_disk_dqheader {
967 __le32 dqh_magic; /* Magic number identifying file */
968 __le32 dqh_version; /* Quota format version */
969};
970
971#define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
972
973/* Information header of global quota file (immediately follows the generic
974 * header) */
975struct ocfs2_global_disk_dqinfo {
976/*00*/ __le32 dqi_bgrace; /* Grace time for space softlimit excess */
977 __le32 dqi_igrace; /* Grace time for inode softlimit excess */
978 __le32 dqi_syncms; /* Time after which we sync local changes to
979 * global quota file */
980 __le32 dqi_blocks; /* Number of blocks in quota file */
981/*10*/ __le32 dqi_free_blk; /* First free block in quota file */
982 __le32 dqi_free_entry; /* First block with free dquot entry in quota
983 * file */
984};
985
986/* Structure with global user / group information. We reserve some space
987 * for future use. */
988struct ocfs2_global_disk_dqblk {
989/*00*/ __le32 dqb_id; /* ID the structure belongs to */
990 __le32 dqb_use_count; /* Number of nodes having reference to this structure */
991 __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
992/*10*/ __le64 dqb_isoftlimit; /* preferred inode limit */
993 __le64 dqb_curinodes; /* current # allocated inodes */
994/*20*/ __le64 dqb_bhardlimit; /* absolute limit on disk space */
995 __le64 dqb_bsoftlimit; /* preferred limit on disk space */
996/*30*/ __le64 dqb_curspace; /* current space occupied */
997 __le64 dqb_btime; /* time limit for excessive disk use */
998/*40*/ __le64 dqb_itime; /* time limit for excessive inode use */
999 __le64 dqb_pad1;
1000/*50*/ __le64 dqb_pad2;
1001};
1002
1003/*
1004 * On-disk structures for local quota file
1005 */
1006
1007/* Magic numbers and known versions for local quota files */
1008#define OCFS2_LOCAL_QMAGICS {\
1009 0x0cf524c0, /* USRQUOTA */ \
1010 0x0cf524c1 /* GRPQUOTA */ \
1011}
1012
1013#define OCFS2_LOCAL_QVERSIONS {\
1014 0, \
1015 0, \
1016}
1017
1018/* Quota flags in dqinfo header */
1019#define OLQF_CLEAN 0x0001 /* Quota file is empty (this should be after\
1020 * quota has been cleanly turned off) */
1021
1022#define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1023
1024/* Information header of local quota file (immediately follows the generic
1025 * header) */
1026struct ocfs2_local_disk_dqinfo {
1027 __le32 dqi_flags; /* Flags for quota file */
1028 __le32 dqi_chunks; /* Number of chunks of quota structures
1029 * with a bitmap */
1030 __le32 dqi_blocks; /* Number of blocks allocated for quota file */
1031};
1032
1033/* Header of one chunk of a quota file */
1034struct ocfs2_local_disk_chunk {
1035 __le32 dqc_free; /* Number of free entries in the bitmap */
1036 u8 dqc_bitmap[0]; /* Bitmap of entries in the corresponding
1037 * chunk of quota file */
1038};
1039
1040/* One entry in local quota file */
1041struct ocfs2_local_disk_dqblk {
1042/*00*/ __le64 dqb_id; /* id this quota applies to */
1043 __le64 dqb_spacemod; /* Change in the amount of used space */
1044/*10*/ __le64 dqb_inodemod; /* Change in the amount of used inodes */
1045};
1046
1047
1048/*
1049 * The quota trailer lives at the end of each quota block.
1050 */
1051
1052struct ocfs2_disk_dqtrailer {
1053/*00*/ struct ocfs2_block_check dq_check; /* Error checking */
1054/*08*/ /* Cannot be larger than OCFS2_QBLK_RESERVED_SPACE */
1055};
1056
1057static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1058 void *buf)
1059{
1060 char *ptr = buf;
1061 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1062
1063 return (struct ocfs2_disk_dqtrailer *)ptr;
1064}
1065
871#ifdef __KERNEL__ 1066#ifdef __KERNEL__
872static inline int ocfs2_fast_symlink_chars(struct super_block *sb) 1067static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
873{ 1068{
diff --git a/fs/ocfs2/ocfs2_jbd_compat.h b/fs/ocfs2/ocfs2_jbd_compat.h
deleted file mode 100644
index b91c78f8f558..000000000000
--- a/fs/ocfs2/ocfs2_jbd_compat.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * ocfs2_jbd_compat.h
5 *
6 * Compatibility defines for JBD.
7 *
8 * Copyright (C) 2008 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License version 2 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
20#ifndef OCFS2_JBD_COMPAT_H
21#define OCFS2_JBD_COMPAT_H
22
23#ifndef CONFIG_OCFS2_COMPAT_JBD
24# error Should not have been included
25#endif
26
27struct jbd2_inode {
28 unsigned int dummy;
29};
30
31#define JBD2_BARRIER JFS_BARRIER
32#define JBD2_DEFAULT_MAX_COMMIT_AGE JBD_DEFAULT_MAX_COMMIT_AGE
33
34#define jbd2_journal_ack_err journal_ack_err
35#define jbd2_journal_clear_err journal_clear_err
36#define jbd2_journal_destroy journal_destroy
37#define jbd2_journal_dirty_metadata journal_dirty_metadata
38#define jbd2_journal_errno journal_errno
39#define jbd2_journal_extend journal_extend
40#define jbd2_journal_flush journal_flush
41#define jbd2_journal_force_commit journal_force_commit
42#define jbd2_journal_get_write_access journal_get_write_access
43#define jbd2_journal_get_undo_access journal_get_undo_access
44#define jbd2_journal_init_inode journal_init_inode
45#define jbd2_journal_invalidatepage journal_invalidatepage
46#define jbd2_journal_load journal_load
47#define jbd2_journal_lock_updates journal_lock_updates
48#define jbd2_journal_restart journal_restart
49#define jbd2_journal_start journal_start
50#define jbd2_journal_start_commit journal_start_commit
51#define jbd2_journal_stop journal_stop
52#define jbd2_journal_try_to_free_buffers journal_try_to_free_buffers
53#define jbd2_journal_unlock_updates journal_unlock_updates
54#define jbd2_journal_wipe journal_wipe
55#define jbd2_log_wait_commit log_wait_commit
56
57static inline int jbd2_journal_file_inode(handle_t *handle,
58 struct jbd2_inode *inode)
59{
60 return 0;
61}
62
63static inline int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode,
64 loff_t new_size)
65{
66 return 0;
67}
68
69static inline void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode,
70 struct inode *inode)
71{
72 return;
73}
74
75static inline void jbd2_journal_release_jbd_inode(journal_t *journal,
76 struct jbd2_inode *jinode)
77{
78 return;
79}
80
81
82#endif /* OCFS2_JBD_COMPAT_H */
diff --git a/fs/ocfs2/ocfs2_lockid.h b/fs/ocfs2/ocfs2_lockid.h
index 82c200f7a8f1..eb6f50c9ceca 100644
--- a/fs/ocfs2/ocfs2_lockid.h
+++ b/fs/ocfs2/ocfs2_lockid.h
@@ -46,6 +46,7 @@ enum ocfs2_lock_type {
46 OCFS2_LOCK_TYPE_DENTRY, 46 OCFS2_LOCK_TYPE_DENTRY,
47 OCFS2_LOCK_TYPE_OPEN, 47 OCFS2_LOCK_TYPE_OPEN,
48 OCFS2_LOCK_TYPE_FLOCK, 48 OCFS2_LOCK_TYPE_FLOCK,
49 OCFS2_LOCK_TYPE_QINFO,
49 OCFS2_NUM_LOCK_TYPES 50 OCFS2_NUM_LOCK_TYPES
50}; 51};
51 52
@@ -77,6 +78,9 @@ static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type)
77 case OCFS2_LOCK_TYPE_FLOCK: 78 case OCFS2_LOCK_TYPE_FLOCK:
78 c = 'F'; 79 c = 'F';
79 break; 80 break;
81 case OCFS2_LOCK_TYPE_QINFO:
82 c = 'Q';
83 break;
80 default: 84 default:
81 c = '\0'; 85 c = '\0';
82 } 86 }
@@ -95,6 +99,7 @@ static char *ocfs2_lock_type_strings[] = {
95 [OCFS2_LOCK_TYPE_DENTRY] = "Dentry", 99 [OCFS2_LOCK_TYPE_DENTRY] = "Dentry",
96 [OCFS2_LOCK_TYPE_OPEN] = "Open", 100 [OCFS2_LOCK_TYPE_OPEN] = "Open",
97 [OCFS2_LOCK_TYPE_FLOCK] = "Flock", 101 [OCFS2_LOCK_TYPE_FLOCK] = "Flock",
102 [OCFS2_LOCK_TYPE_QINFO] = "Quota",
98}; 103};
99 104
100static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type) 105static inline const char *ocfs2_lock_type_string(enum ocfs2_lock_type type)
diff --git a/fs/ocfs2/quota.h b/fs/ocfs2/quota.h
new file mode 100644
index 000000000000..7365e2e08706
--- /dev/null
+++ b/fs/ocfs2/quota.h
@@ -0,0 +1,119 @@
1/*
2 * quota.h for OCFS2
3 *
4 * On disk quota structures for local and global quota file, in-memory
5 * structures.
6 *
7 */
8
9#ifndef _OCFS2_QUOTA_H
10#define _OCFS2_QUOTA_H
11
12#include <linux/types.h>
13#include <linux/slab.h>
14#include <linux/quota.h>
15#include <linux/list.h>
16#include <linux/dqblk_qtree.h>
17
18#include "ocfs2.h"
19
20/* Common stuff */
21/* id number of quota format */
22#define QFMT_OCFS2 3
23
24/*
25 * In-memory structures
26 */
27struct ocfs2_dquot {
28 struct dquot dq_dquot; /* Generic VFS dquot */
29 loff_t dq_local_off; /* Offset in the local quota file */
30 struct ocfs2_quota_chunk *dq_chunk; /* Chunk dquot is in */
31 unsigned int dq_use_count; /* Number of nodes having reference to this entry in global quota file */
32 s64 dq_origspace; /* Last globally synced space usage */
33 s64 dq_originodes; /* Last globally synced inode usage */
34};
35
36/* Description of one chunk to recover in memory */
37struct ocfs2_recovery_chunk {
38 struct list_head rc_list; /* List of chunks */
39 int rc_chunk; /* Chunk number */
40 unsigned long *rc_bitmap; /* Bitmap of entries to recover */
41};
42
43struct ocfs2_quota_recovery {
44 struct list_head r_list[MAXQUOTAS]; /* List of chunks to recover */
45};
46
47/* In-memory structure with quota header information */
48struct ocfs2_mem_dqinfo {
49 unsigned int dqi_type; /* Quota type this structure describes */
50 unsigned int dqi_chunks; /* Number of chunks in local quota file */
51 unsigned int dqi_blocks; /* Number of blocks allocated for local quota file */
52 unsigned int dqi_syncms; /* How often should we sync with other nodes */
53 unsigned int dqi_syncjiff; /* Precomputed dqi_syncms in jiffies */
54 struct list_head dqi_chunk; /* List of chunks */
55 struct inode *dqi_gqinode; /* Global quota file inode */
56 struct ocfs2_lock_res dqi_gqlock; /* Lock protecting quota information structure */
57 struct buffer_head *dqi_gqi_bh; /* Buffer head with global quota file inode - set only if inode lock is obtained */
58 int dqi_gqi_count; /* Number of holders of dqi_gqi_bh */
59 struct buffer_head *dqi_lqi_bh; /* Buffer head with local quota file inode */
60 struct buffer_head *dqi_ibh; /* Buffer with information header */
61 struct qtree_mem_dqinfo dqi_gi; /* Info about global file */
62 struct delayed_work dqi_sync_work; /* Work for syncing dquots */
63 struct ocfs2_quota_recovery *dqi_rec; /* Pointer to recovery
64 * information, in case we
65 * enable quotas on file
66 * needing it */
67};
68
69static inline struct ocfs2_dquot *OCFS2_DQUOT(struct dquot *dquot)
70{
71 return container_of(dquot, struct ocfs2_dquot, dq_dquot);
72}
73
74struct ocfs2_quota_chunk {
75 struct list_head qc_chunk; /* List of quotafile chunks */
76 int qc_num; /* Number of quota chunk */
77 struct buffer_head *qc_headerbh; /* Buffer head with chunk header */
78};
79
80extern struct kmem_cache *ocfs2_dquot_cachep;
81extern struct kmem_cache *ocfs2_qf_chunk_cachep;
82
83extern struct qtree_fmt_operations ocfs2_global_ops;
84
85struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
86 struct ocfs2_super *osb, int slot_num);
87int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
88 struct ocfs2_quota_recovery *rec,
89 int slot_num);
90void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec);
91ssize_t ocfs2_quota_read(struct super_block *sb, int type, char *data,
92 size_t len, loff_t off);
93ssize_t ocfs2_quota_write(struct super_block *sb, int type,
94 const char *data, size_t len, loff_t off);
95int ocfs2_global_read_info(struct super_block *sb, int type);
96int ocfs2_global_write_info(struct super_block *sb, int type);
97int ocfs2_global_read_dquot(struct dquot *dquot);
98int __ocfs2_sync_dquot(struct dquot *dquot, int freeing);
99static inline int ocfs2_sync_dquot(struct dquot *dquot)
100{
101 return __ocfs2_sync_dquot(dquot, 0);
102}
103static inline int ocfs2_global_release_dquot(struct dquot *dquot)
104{
105 return __ocfs2_sync_dquot(dquot, 1);
106}
107
108int ocfs2_lock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex);
109void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex);
110int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
111 struct buffer_head **bh);
112
113extern struct dquot_operations ocfs2_quota_operations;
114extern struct quota_format_type ocfs2_quota_format;
115
116int ocfs2_quota_setup(void);
117void ocfs2_quota_shutdown(void);
118
119#endif /* _OCFS2_QUOTA_H */
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
new file mode 100644
index 000000000000..6aff8f2d3e49
--- /dev/null
+++ b/fs/ocfs2/quota_global.c
@@ -0,0 +1,1025 @@
1/*
2 * Implementation of operations over global quota file
3 */
4#include <linux/spinlock.h>
5#include <linux/fs.h>
6#include <linux/quota.h>
7#include <linux/quotaops.h>
8#include <linux/dqblk_qtree.h>
9#include <linux/jiffies.h>
10#include <linux/writeback.h>
11#include <linux/workqueue.h>
12
13#define MLOG_MASK_PREFIX ML_QUOTA
14#include <cluster/masklog.h>
15
16#include "ocfs2_fs.h"
17#include "ocfs2.h"
18#include "alloc.h"
19#include "blockcheck.h"
20#include "inode.h"
21#include "journal.h"
22#include "file.h"
23#include "sysfile.h"
24#include "dlmglue.h"
25#include "uptodate.h"
26#include "quota.h"
27
28static struct workqueue_struct *ocfs2_quota_wq = NULL;
29
30static void qsync_work_fn(struct work_struct *work);
31
32static void ocfs2_global_disk2memdqb(struct dquot *dquot, void *dp)
33{
34 struct ocfs2_global_disk_dqblk *d = dp;
35 struct mem_dqblk *m = &dquot->dq_dqb;
36
37 /* Update from disk only entries not set by the admin */
38 if (!test_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags)) {
39 m->dqb_ihardlimit = le64_to_cpu(d->dqb_ihardlimit);
40 m->dqb_isoftlimit = le64_to_cpu(d->dqb_isoftlimit);
41 }
42 if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags))
43 m->dqb_curinodes = le64_to_cpu(d->dqb_curinodes);
44 if (!test_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags)) {
45 m->dqb_bhardlimit = le64_to_cpu(d->dqb_bhardlimit);
46 m->dqb_bsoftlimit = le64_to_cpu(d->dqb_bsoftlimit);
47 }
48 if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags))
49 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
50 if (!test_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags))
51 m->dqb_btime = le64_to_cpu(d->dqb_btime);
52 if (!test_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags))
53 m->dqb_itime = le64_to_cpu(d->dqb_itime);
54 OCFS2_DQUOT(dquot)->dq_use_count = le32_to_cpu(d->dqb_use_count);
55}
56
57static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
58{
59 struct ocfs2_global_disk_dqblk *d = dp;
60 struct mem_dqblk *m = &dquot->dq_dqb;
61
62 d->dqb_id = cpu_to_le32(dquot->dq_id);
63 d->dqb_use_count = cpu_to_le32(OCFS2_DQUOT(dquot)->dq_use_count);
64 d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
65 d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
66 d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
67 d->dqb_bhardlimit = cpu_to_le64(m->dqb_bhardlimit);
68 d->dqb_bsoftlimit = cpu_to_le64(m->dqb_bsoftlimit);
69 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
70 d->dqb_btime = cpu_to_le64(m->dqb_btime);
71 d->dqb_itime = cpu_to_le64(m->dqb_itime);
72}
73
74static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
75{
76 struct ocfs2_global_disk_dqblk *d = dp;
77 struct ocfs2_mem_dqinfo *oinfo =
78 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
79
80 if (qtree_entry_unused(&oinfo->dqi_gi, dp))
81 return 0;
82 return le32_to_cpu(d->dqb_id) == dquot->dq_id;
83}
84
85struct qtree_fmt_operations ocfs2_global_ops = {
86 .mem2disk_dqblk = ocfs2_global_mem2diskdqb,
87 .disk2mem_dqblk = ocfs2_global_disk2memdqb,
88 .is_id = ocfs2_global_is_id,
89};
90
91static int ocfs2_validate_quota_block(struct super_block *sb,
92 struct buffer_head *bh)
93{
94 struct ocfs2_disk_dqtrailer *dqt =
95 ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data);
96
97 mlog(0, "Validating quota block %llu\n",
98 (unsigned long long)bh->b_blocknr);
99
100 BUG_ON(!buffer_uptodate(bh));
101
102 /*
103 * If the ecc fails, we return the error but otherwise
104 * leave the filesystem running. We know any error is
105 * local to this block.
106 */
107 return ocfs2_validate_meta_ecc(sb, bh->b_data, &dqt->dq_check);
108}
109
110int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
111 struct buffer_head **bh)
112{
113 int rc = 0;
114 struct buffer_head *tmp = *bh;
115
116 rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0,
117 ocfs2_validate_quota_block);
118 if (rc)
119 mlog_errno(rc);
120
121 /* If ocfs2_read_virt_blocks() got us a new bh, pass it up. */
122 if (!rc && !*bh)
123 *bh = tmp;
124
125 return rc;
126}
127
128static int ocfs2_get_quota_block(struct inode *inode, int block,
129 struct buffer_head **bh)
130{
131 u64 pblock, pcount;
132 int err;
133
134 down_read(&OCFS2_I(inode)->ip_alloc_sem);
135 err = ocfs2_extent_map_get_blocks(inode, block, &pblock, &pcount, NULL);
136 up_read(&OCFS2_I(inode)->ip_alloc_sem);
137 if (err) {
138 mlog_errno(err);
139 return err;
140 }
141 *bh = sb_getblk(inode->i_sb, pblock);
142 if (!*bh) {
143 err = -EIO;
144 mlog_errno(err);
145 }
146 return err;;
147}
148
149/* Read data from global quotafile - avoid pagecache and such because we cannot
150 * afford acquiring the locks... We use quota cluster lock to serialize
151 * operations. Caller is responsible for acquiring it. */
152ssize_t ocfs2_quota_read(struct super_block *sb, int type, char *data,
153 size_t len, loff_t off)
154{
155 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
156 struct inode *gqinode = oinfo->dqi_gqinode;
157 loff_t i_size = i_size_read(gqinode);
158 int offset = off & (sb->s_blocksize - 1);
159 sector_t blk = off >> sb->s_blocksize_bits;
160 int err = 0;
161 struct buffer_head *bh;
162 size_t toread, tocopy;
163
164 if (off > i_size)
165 return 0;
166 if (off + len > i_size)
167 len = i_size - off;
168 toread = len;
169 while (toread > 0) {
170 tocopy = min_t(size_t, (sb->s_blocksize - offset), toread);
171 bh = NULL;
172 err = ocfs2_read_quota_block(gqinode, blk, &bh);
173 if (err) {
174 mlog_errno(err);
175 return err;
176 }
177 memcpy(data, bh->b_data + offset, tocopy);
178 brelse(bh);
179 offset = 0;
180 toread -= tocopy;
181 data += tocopy;
182 blk++;
183 }
184 return len;
185}
186
187/* Write to quotafile (we know the transaction is already started and has
188 * enough credits) */
189ssize_t ocfs2_quota_write(struct super_block *sb, int type,
190 const char *data, size_t len, loff_t off)
191{
192 struct mem_dqinfo *info = sb_dqinfo(sb, type);
193 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
194 struct inode *gqinode = oinfo->dqi_gqinode;
195 int offset = off & (sb->s_blocksize - 1);
196 sector_t blk = off >> sb->s_blocksize_bits;
197 int err = 0, new = 0, ja_type;
198 struct buffer_head *bh = NULL;
199 handle_t *handle = journal_current_handle();
200
201 if (!handle) {
202 mlog(ML_ERROR, "Quota write (off=%llu, len=%llu) cancelled "
203 "because transaction was not started.\n",
204 (unsigned long long)off, (unsigned long long)len);
205 return -EIO;
206 }
207 if (len > sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE - offset) {
208 WARN_ON(1);
209 len = sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE - offset;
210 }
211
212 mutex_lock_nested(&gqinode->i_mutex, I_MUTEX_QUOTA);
213 if (gqinode->i_size < off + len) {
214 down_write(&OCFS2_I(gqinode)->ip_alloc_sem);
215 err = ocfs2_extend_no_holes(gqinode, off + len, off);
216 up_write(&OCFS2_I(gqinode)->ip_alloc_sem);
217 if (err < 0)
218 goto out;
219 err = ocfs2_simple_size_update(gqinode,
220 oinfo->dqi_gqi_bh,
221 off + len);
222 if (err < 0)
223 goto out;
224 new = 1;
225 }
226 /* Not rewriting whole block? */
227 if ((offset || len < sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE) &&
228 !new) {
229 err = ocfs2_read_quota_block(gqinode, blk, &bh);
230 ja_type = OCFS2_JOURNAL_ACCESS_WRITE;
231 } else {
232 err = ocfs2_get_quota_block(gqinode, blk, &bh);
233 ja_type = OCFS2_JOURNAL_ACCESS_CREATE;
234 }
235 if (err) {
236 mlog_errno(err);
237 return err;
238 }
239 lock_buffer(bh);
240 if (new)
241 memset(bh->b_data, 0, sb->s_blocksize);
242 memcpy(bh->b_data + offset, data, len);
243 flush_dcache_page(bh->b_page);
244 set_buffer_uptodate(bh);
245 unlock_buffer(bh);
246 ocfs2_set_buffer_uptodate(gqinode, bh);
247 err = ocfs2_journal_access_dq(handle, gqinode, bh, ja_type);
248 if (err < 0) {
249 brelse(bh);
250 goto out;
251 }
252 err = ocfs2_journal_dirty(handle, bh);
253 brelse(bh);
254 if (err < 0)
255 goto out;
256out:
257 if (err) {
258 mutex_unlock(&gqinode->i_mutex);
259 mlog_errno(err);
260 return err;
261 }
262 gqinode->i_version++;
263 ocfs2_mark_inode_dirty(handle, gqinode, oinfo->dqi_gqi_bh);
264 mutex_unlock(&gqinode->i_mutex);
265 return len;
266}
267
268int ocfs2_lock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
269{
270 int status;
271 struct buffer_head *bh = NULL;
272
273 status = ocfs2_inode_lock(oinfo->dqi_gqinode, &bh, ex);
274 if (status < 0)
275 return status;
276 spin_lock(&dq_data_lock);
277 if (!oinfo->dqi_gqi_count++)
278 oinfo->dqi_gqi_bh = bh;
279 else
280 WARN_ON(bh != oinfo->dqi_gqi_bh);
281 spin_unlock(&dq_data_lock);
282 return 0;
283}
284
285void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
286{
287 ocfs2_inode_unlock(oinfo->dqi_gqinode, ex);
288 brelse(oinfo->dqi_gqi_bh);
289 spin_lock(&dq_data_lock);
290 if (!--oinfo->dqi_gqi_count)
291 oinfo->dqi_gqi_bh = NULL;
292 spin_unlock(&dq_data_lock);
293}
294
295/* Read information header from global quota file */
296int ocfs2_global_read_info(struct super_block *sb, int type)
297{
298 struct inode *gqinode = NULL;
299 unsigned int ino[MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
300 GROUP_QUOTA_SYSTEM_INODE };
301 struct ocfs2_global_disk_dqinfo dinfo;
302 struct mem_dqinfo *info = sb_dqinfo(sb, type);
303 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
304 int status;
305
306 mlog_entry_void();
307
308 /* Read global header */
309 gqinode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type],
310 OCFS2_INVALID_SLOT);
311 if (!gqinode) {
312 mlog(ML_ERROR, "failed to get global quota inode (type=%d)\n",
313 type);
314 status = -EINVAL;
315 goto out_err;
316 }
317 oinfo->dqi_gi.dqi_sb = sb;
318 oinfo->dqi_gi.dqi_type = type;
319 ocfs2_qinfo_lock_res_init(&oinfo->dqi_gqlock, oinfo);
320 oinfo->dqi_gi.dqi_entry_size = sizeof(struct ocfs2_global_disk_dqblk);
321 oinfo->dqi_gi.dqi_ops = &ocfs2_global_ops;
322 oinfo->dqi_gqi_bh = NULL;
323 oinfo->dqi_gqi_count = 0;
324 oinfo->dqi_gqinode = gqinode;
325 status = ocfs2_lock_global_qf(oinfo, 0);
326 if (status < 0) {
327 mlog_errno(status);
328 goto out_err;
329 }
330 status = sb->s_op->quota_read(sb, type, (char *)&dinfo,
331 sizeof(struct ocfs2_global_disk_dqinfo),
332 OCFS2_GLOBAL_INFO_OFF);
333 ocfs2_unlock_global_qf(oinfo, 0);
334 if (status != sizeof(struct ocfs2_global_disk_dqinfo)) {
335 mlog(ML_ERROR, "Cannot read global quota info (%d).\n",
336 status);
337 if (status >= 0)
338 status = -EIO;
339 mlog_errno(status);
340 goto out_err;
341 }
342 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
343 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
344 oinfo->dqi_syncms = le32_to_cpu(dinfo.dqi_syncms);
345 oinfo->dqi_syncjiff = msecs_to_jiffies(oinfo->dqi_syncms);
346 oinfo->dqi_gi.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
347 oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
348 oinfo->dqi_gi.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
349 oinfo->dqi_gi.dqi_blocksize_bits = sb->s_blocksize_bits;
350 oinfo->dqi_gi.dqi_usable_bs = sb->s_blocksize -
351 OCFS2_QBLK_RESERVED_SPACE;
352 oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi);
353 INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn);
354 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
355 oinfo->dqi_syncjiff);
356
357out_err:
358 mlog_exit(status);
359 return status;
360}
361
362/* Write information to global quota file. Expects exlusive lock on quota
363 * file inode and quota info */
364static int __ocfs2_global_write_info(struct super_block *sb, int type)
365{
366 struct mem_dqinfo *info = sb_dqinfo(sb, type);
367 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
368 struct ocfs2_global_disk_dqinfo dinfo;
369 ssize_t size;
370
371 spin_lock(&dq_data_lock);
372 info->dqi_flags &= ~DQF_INFO_DIRTY;
373 dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace);
374 dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
375 spin_unlock(&dq_data_lock);
376 dinfo.dqi_syncms = cpu_to_le32(oinfo->dqi_syncms);
377 dinfo.dqi_blocks = cpu_to_le32(oinfo->dqi_gi.dqi_blocks);
378 dinfo.dqi_free_blk = cpu_to_le32(oinfo->dqi_gi.dqi_free_blk);
379 dinfo.dqi_free_entry = cpu_to_le32(oinfo->dqi_gi.dqi_free_entry);
380 size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
381 sizeof(struct ocfs2_global_disk_dqinfo),
382 OCFS2_GLOBAL_INFO_OFF);
383 if (size != sizeof(struct ocfs2_global_disk_dqinfo)) {
384 mlog(ML_ERROR, "Cannot write global quota info structure\n");
385 if (size >= 0)
386 size = -EIO;
387 return size;
388 }
389 return 0;
390}
391
392int ocfs2_global_write_info(struct super_block *sb, int type)
393{
394 int err;
395 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
396
397 err = ocfs2_qinfo_lock(info, 1);
398 if (err < 0)
399 return err;
400 err = __ocfs2_global_write_info(sb, type);
401 ocfs2_qinfo_unlock(info, 1);
402 return err;
403}
404
405/* Read in information from global quota file and acquire a reference to it.
406 * dquot_acquire() has already started the transaction and locked quota file */
407int ocfs2_global_read_dquot(struct dquot *dquot)
408{
409 int err, err2, ex = 0;
410 struct ocfs2_mem_dqinfo *info =
411 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
412
413 err = ocfs2_qinfo_lock(info, 0);
414 if (err < 0)
415 goto out;
416 err = qtree_read_dquot(&info->dqi_gi, dquot);
417 if (err < 0)
418 goto out_qlock;
419 OCFS2_DQUOT(dquot)->dq_use_count++;
420 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
421 OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
422 if (!dquot->dq_off) { /* No real quota entry? */
423 /* Upgrade to exclusive lock for allocation */
424 err = ocfs2_qinfo_lock(info, 1);
425 if (err < 0)
426 goto out_qlock;
427 ex = 1;
428 }
429 err = qtree_write_dquot(&info->dqi_gi, dquot);
430 if (ex && info_dirty(sb_dqinfo(dquot->dq_sb, dquot->dq_type))) {
431 err2 = __ocfs2_global_write_info(dquot->dq_sb, dquot->dq_type);
432 if (!err)
433 err = err2;
434 }
435out_qlock:
436 if (ex)
437 ocfs2_qinfo_unlock(info, 1);
438 ocfs2_qinfo_unlock(info, 0);
439out:
440 if (err < 0)
441 mlog_errno(err);
442 return err;
443}
444
445/* Sync local information about quota modifications with global quota file.
446 * Caller must have started the transaction and obtained exclusive lock for
447 * global quota file inode */
448int __ocfs2_sync_dquot(struct dquot *dquot, int freeing)
449{
450 int err, err2;
451 struct super_block *sb = dquot->dq_sb;
452 int type = dquot->dq_type;
453 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
454 struct ocfs2_global_disk_dqblk dqblk;
455 s64 spacechange, inodechange;
456 time_t olditime, oldbtime;
457
458 err = sb->s_op->quota_read(sb, type, (char *)&dqblk,
459 sizeof(struct ocfs2_global_disk_dqblk),
460 dquot->dq_off);
461 if (err != sizeof(struct ocfs2_global_disk_dqblk)) {
462 if (err >= 0) {
463 mlog(ML_ERROR, "Short read from global quota file "
464 "(%u read)\n", err);
465 err = -EIO;
466 }
467 goto out;
468 }
469
470 /* Update space and inode usage. Get also other information from
471 * global quota file so that we don't overwrite any changes there.
472 * We are */
473 spin_lock(&dq_data_lock);
474 spacechange = dquot->dq_dqb.dqb_curspace -
475 OCFS2_DQUOT(dquot)->dq_origspace;
476 inodechange = dquot->dq_dqb.dqb_curinodes -
477 OCFS2_DQUOT(dquot)->dq_originodes;
478 olditime = dquot->dq_dqb.dqb_itime;
479 oldbtime = dquot->dq_dqb.dqb_btime;
480 ocfs2_global_disk2memdqb(dquot, &dqblk);
481 mlog(0, "Syncing global dquot %u space %lld+%lld, inodes %lld+%lld\n",
482 dquot->dq_id, dquot->dq_dqb.dqb_curspace, (long long)spacechange,
483 dquot->dq_dqb.dqb_curinodes, (long long)inodechange);
484 if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags))
485 dquot->dq_dqb.dqb_curspace += spacechange;
486 if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags))
487 dquot->dq_dqb.dqb_curinodes += inodechange;
488 /* Set properly space grace time... */
489 if (dquot->dq_dqb.dqb_bsoftlimit &&
490 dquot->dq_dqb.dqb_curspace > dquot->dq_dqb.dqb_bsoftlimit) {
491 if (!test_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags) &&
492 oldbtime > 0) {
493 if (dquot->dq_dqb.dqb_btime > 0)
494 dquot->dq_dqb.dqb_btime =
495 min(dquot->dq_dqb.dqb_btime, oldbtime);
496 else
497 dquot->dq_dqb.dqb_btime = oldbtime;
498 }
499 } else {
500 dquot->dq_dqb.dqb_btime = 0;
501 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
502 }
503 /* Set properly inode grace time... */
504 if (dquot->dq_dqb.dqb_isoftlimit &&
505 dquot->dq_dqb.dqb_curinodes > dquot->dq_dqb.dqb_isoftlimit) {
506 if (!test_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags) &&
507 olditime > 0) {
508 if (dquot->dq_dqb.dqb_itime > 0)
509 dquot->dq_dqb.dqb_itime =
510 min(dquot->dq_dqb.dqb_itime, olditime);
511 else
512 dquot->dq_dqb.dqb_itime = olditime;
513 }
514 } else {
515 dquot->dq_dqb.dqb_itime = 0;
516 clear_bit(DQ_INODES_B, &dquot->dq_flags);
517 }
518 /* All information is properly updated, clear the flags */
519 __clear_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
520 __clear_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
521 __clear_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
522 __clear_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
523 __clear_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
524 __clear_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
525 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
526 OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
527 spin_unlock(&dq_data_lock);
528 err = ocfs2_qinfo_lock(info, freeing);
529 if (err < 0) {
530 mlog(ML_ERROR, "Failed to lock quota info, loosing quota write"
531 " (type=%d, id=%u)\n", dquot->dq_type,
532 (unsigned)dquot->dq_id);
533 goto out;
534 }
535 if (freeing)
536 OCFS2_DQUOT(dquot)->dq_use_count--;
537 err = qtree_write_dquot(&info->dqi_gi, dquot);
538 if (err < 0)
539 goto out_qlock;
540 if (freeing && !OCFS2_DQUOT(dquot)->dq_use_count) {
541 err = qtree_release_dquot(&info->dqi_gi, dquot);
542 if (info_dirty(sb_dqinfo(sb, type))) {
543 err2 = __ocfs2_global_write_info(sb, type);
544 if (!err)
545 err = err2;
546 }
547 }
548out_qlock:
549 ocfs2_qinfo_unlock(info, freeing);
550out:
551 if (err < 0)
552 mlog_errno(err);
553 return err;
554}
555
556/*
557 * Functions for periodic syncing of dquots with global file
558 */
559static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type)
560{
561 handle_t *handle;
562 struct super_block *sb = dquot->dq_sb;
563 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
564 struct ocfs2_super *osb = OCFS2_SB(sb);
565 int status = 0;
566
567 mlog_entry("id=%u qtype=%u type=%lu device=%s\n", dquot->dq_id,
568 dquot->dq_type, type, sb->s_id);
569 if (type != dquot->dq_type)
570 goto out;
571 status = ocfs2_lock_global_qf(oinfo, 1);
572 if (status < 0)
573 goto out;
574
575 handle = ocfs2_start_trans(osb, OCFS2_QSYNC_CREDITS);
576 if (IS_ERR(handle)) {
577 status = PTR_ERR(handle);
578 mlog_errno(status);
579 goto out_ilock;
580 }
581 mutex_lock(&sb_dqopt(sb)->dqio_mutex);
582 status = ocfs2_sync_dquot(dquot);
583 mutex_unlock(&sb_dqopt(sb)->dqio_mutex);
584 if (status < 0)
585 mlog_errno(status);
586 /* We have to write local structure as well... */
587 dquot_mark_dquot_dirty(dquot);
588 status = dquot_commit(dquot);
589 if (status < 0)
590 mlog_errno(status);
591 ocfs2_commit_trans(osb, handle);
592out_ilock:
593 ocfs2_unlock_global_qf(oinfo, 1);
594out:
595 mlog_exit(status);
596 return status;
597}
598
599static void qsync_work_fn(struct work_struct *work)
600{
601 struct ocfs2_mem_dqinfo *oinfo = container_of(work,
602 struct ocfs2_mem_dqinfo,
603 dqi_sync_work.work);
604 struct super_block *sb = oinfo->dqi_gqinode->i_sb;
605
606 dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type);
607 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
608 oinfo->dqi_syncjiff);
609}
610
611/*
612 * Wrappers for generic quota functions
613 */
614
615static int ocfs2_write_dquot(struct dquot *dquot)
616{
617 handle_t *handle;
618 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
619 int status = 0;
620
621 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
622
623 handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS);
624 if (IS_ERR(handle)) {
625 status = PTR_ERR(handle);
626 mlog_errno(status);
627 goto out;
628 }
629 status = dquot_commit(dquot);
630 ocfs2_commit_trans(osb, handle);
631out:
632 mlog_exit(status);
633 return status;
634}
635
636int ocfs2_calc_qdel_credits(struct super_block *sb, int type)
637{
638 struct ocfs2_mem_dqinfo *oinfo;
639 int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
640 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA };
641
642 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type]))
643 return 0;
644
645 oinfo = sb_dqinfo(sb, type)->dqi_priv;
646 /* We modify tree, leaf block, global info, local chunk header,
647 * global and local inode */
648 return oinfo->dqi_gi.dqi_qtree_depth + 2 + 1 +
649 2 * OCFS2_INODE_UPDATE_CREDITS;
650}
651
652static int ocfs2_release_dquot(struct dquot *dquot)
653{
654 handle_t *handle;
655 struct ocfs2_mem_dqinfo *oinfo =
656 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
657 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
658 int status = 0;
659
660 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
661
662 status = ocfs2_lock_global_qf(oinfo, 1);
663 if (status < 0)
664 goto out;
665 handle = ocfs2_start_trans(osb,
666 ocfs2_calc_qdel_credits(dquot->dq_sb, dquot->dq_type));
667 if (IS_ERR(handle)) {
668 status = PTR_ERR(handle);
669 mlog_errno(status);
670 goto out_ilock;
671 }
672 status = dquot_release(dquot);
673 ocfs2_commit_trans(osb, handle);
674out_ilock:
675 ocfs2_unlock_global_qf(oinfo, 1);
676out:
677 mlog_exit(status);
678 return status;
679}
680
681int ocfs2_calc_qinit_credits(struct super_block *sb, int type)
682{
683 struct ocfs2_mem_dqinfo *oinfo;
684 int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
685 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA };
686 struct ocfs2_dinode *lfe, *gfe;
687
688 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type]))
689 return 0;
690
691 oinfo = sb_dqinfo(sb, type)->dqi_priv;
692 gfe = (struct ocfs2_dinode *)oinfo->dqi_gqi_bh->b_data;
693 lfe = (struct ocfs2_dinode *)oinfo->dqi_lqi_bh->b_data;
694 /* We can extend local file + global file. In local file we
695 * can modify info, chunk header block and dquot block. In
696 * global file we can modify info, tree and leaf block */
697 return ocfs2_calc_extend_credits(sb, &lfe->id2.i_list, 0) +
698 ocfs2_calc_extend_credits(sb, &gfe->id2.i_list, 0) +
699 3 + oinfo->dqi_gi.dqi_qtree_depth + 2;
700}
701
702static int ocfs2_acquire_dquot(struct dquot *dquot)
703{
704 handle_t *handle;
705 struct ocfs2_mem_dqinfo *oinfo =
706 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
707 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
708 int status = 0;
709
710 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
711 /* We need an exclusive lock, because we're going to update use count
712 * and instantiate possibly new dquot structure */
713 status = ocfs2_lock_global_qf(oinfo, 1);
714 if (status < 0)
715 goto out;
716 handle = ocfs2_start_trans(osb,
717 ocfs2_calc_qinit_credits(dquot->dq_sb, dquot->dq_type));
718 if (IS_ERR(handle)) {
719 status = PTR_ERR(handle);
720 mlog_errno(status);
721 goto out_ilock;
722 }
723 status = dquot_acquire(dquot);
724 ocfs2_commit_trans(osb, handle);
725out_ilock:
726 ocfs2_unlock_global_qf(oinfo, 1);
727out:
728 mlog_exit(status);
729 return status;
730}
731
732static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
733{
734 unsigned long mask = (1 << (DQ_LASTSET_B + QIF_ILIMITS_B)) |
735 (1 << (DQ_LASTSET_B + QIF_BLIMITS_B)) |
736 (1 << (DQ_LASTSET_B + QIF_INODES_B)) |
737 (1 << (DQ_LASTSET_B + QIF_SPACE_B)) |
738 (1 << (DQ_LASTSET_B + QIF_BTIME_B)) |
739 (1 << (DQ_LASTSET_B + QIF_ITIME_B));
740 int sync = 0;
741 int status;
742 struct super_block *sb = dquot->dq_sb;
743 int type = dquot->dq_type;
744 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
745 handle_t *handle;
746 struct ocfs2_super *osb = OCFS2_SB(sb);
747
748 mlog_entry("id=%u, type=%d", dquot->dq_id, type);
749 dquot_mark_dquot_dirty(dquot);
750
751 /* In case user set some limits, sync dquot immediately to global
752 * quota file so that information propagates quicker */
753 spin_lock(&dq_data_lock);
754 if (dquot->dq_flags & mask)
755 sync = 1;
756 spin_unlock(&dq_data_lock);
757 if (!sync) {
758 status = ocfs2_write_dquot(dquot);
759 goto out;
760 }
761 status = ocfs2_lock_global_qf(oinfo, 1);
762 if (status < 0)
763 goto out;
764 handle = ocfs2_start_trans(osb, OCFS2_QSYNC_CREDITS);
765 if (IS_ERR(handle)) {
766 status = PTR_ERR(handle);
767 mlog_errno(status);
768 goto out_ilock;
769 }
770 status = ocfs2_sync_dquot(dquot);
771 if (status < 0) {
772 mlog_errno(status);
773 goto out_trans;
774 }
775 /* Now write updated local dquot structure */
776 status = dquot_commit(dquot);
777out_trans:
778 ocfs2_commit_trans(osb, handle);
779out_ilock:
780 ocfs2_unlock_global_qf(oinfo, 1);
781out:
782 mlog_exit(status);
783 return status;
784}
785
786/* This should happen only after set_dqinfo(). */
787static int ocfs2_write_info(struct super_block *sb, int type)
788{
789 handle_t *handle;
790 int status = 0;
791 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
792
793 mlog_entry_void();
794
795 status = ocfs2_lock_global_qf(oinfo, 1);
796 if (status < 0)
797 goto out;
798 handle = ocfs2_start_trans(OCFS2_SB(sb), OCFS2_QINFO_WRITE_CREDITS);
799 if (IS_ERR(handle)) {
800 status = PTR_ERR(handle);
801 mlog_errno(status);
802 goto out_ilock;
803 }
804 status = dquot_commit_info(sb, type);
805 ocfs2_commit_trans(OCFS2_SB(sb), handle);
806out_ilock:
807 ocfs2_unlock_global_qf(oinfo, 1);
808out:
809 mlog_exit(status);
810 return status;
811}
812
813/* This is difficult. We have to lock quota inode and start transaction
814 * in this function but we don't want to take the penalty of exlusive
815 * quota file lock when we are just going to use cached structures. So
816 * we just take read lock check whether we have dquot cached and if so,
817 * we don't have to take the write lock... */
818static int ocfs2_dquot_initialize(struct inode *inode, int type)
819{
820 handle_t *handle = NULL;
821 int status = 0;
822 struct super_block *sb = inode->i_sb;
823 struct ocfs2_mem_dqinfo *oinfo;
824 int exclusive = 0;
825 int cnt;
826 qid_t id;
827
828 mlog_entry_void();
829
830 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
831 if (type != -1 && cnt != type)
832 continue;
833 if (!sb_has_quota_active(sb, cnt))
834 continue;
835 oinfo = sb_dqinfo(sb, cnt)->dqi_priv;
836 status = ocfs2_lock_global_qf(oinfo, 0);
837 if (status < 0)
838 goto out;
839 /* This is just a performance optimization not a reliable test.
840 * Since we hold an inode lock, noone can actually release
841 * the structure until we are finished with initialization. */
842 if (inode->i_dquot[cnt] != NODQUOT) {
843 ocfs2_unlock_global_qf(oinfo, 0);
844 continue;
845 }
846 /* When we have inode lock, we know that no dquot_release() can
847 * run and thus we can safely check whether we need to
848 * read+modify global file to get quota information or whether
849 * our node already has it. */
850 if (cnt == USRQUOTA)
851 id = inode->i_uid;
852 else if (cnt == GRPQUOTA)
853 id = inode->i_gid;
854 else
855 BUG();
856 /* Obtain exclusion from quota off... */
857 down_write(&sb_dqopt(sb)->dqptr_sem);
858 exclusive = !dquot_is_cached(sb, id, cnt);
859 up_write(&sb_dqopt(sb)->dqptr_sem);
860 if (exclusive) {
861 status = ocfs2_lock_global_qf(oinfo, 1);
862 if (status < 0) {
863 exclusive = 0;
864 mlog_errno(status);
865 goto out_ilock;
866 }
867 handle = ocfs2_start_trans(OCFS2_SB(sb),
868 ocfs2_calc_qinit_credits(sb, cnt));
869 if (IS_ERR(handle)) {
870 status = PTR_ERR(handle);
871 mlog_errno(status);
872 goto out_ilock;
873 }
874 }
875 dquot_initialize(inode, cnt);
876 if (exclusive) {
877 ocfs2_commit_trans(OCFS2_SB(sb), handle);
878 ocfs2_unlock_global_qf(oinfo, 1);
879 }
880 ocfs2_unlock_global_qf(oinfo, 0);
881 }
882 mlog_exit(0);
883 return 0;
884out_ilock:
885 if (exclusive)
886 ocfs2_unlock_global_qf(oinfo, 1);
887 ocfs2_unlock_global_qf(oinfo, 0);
888out:
889 mlog_exit(status);
890 return status;
891}
892
893static int ocfs2_dquot_drop_slow(struct inode *inode)
894{
895 int status = 0;
896 int cnt;
897 int got_lock[MAXQUOTAS] = {0, 0};
898 handle_t *handle;
899 struct super_block *sb = inode->i_sb;
900 struct ocfs2_mem_dqinfo *oinfo;
901
902 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
903 if (!sb_has_quota_active(sb, cnt))
904 continue;
905 oinfo = sb_dqinfo(sb, cnt)->dqi_priv;
906 status = ocfs2_lock_global_qf(oinfo, 1);
907 if (status < 0)
908 goto out;
909 got_lock[cnt] = 1;
910 }
911 handle = ocfs2_start_trans(OCFS2_SB(sb),
912 ocfs2_calc_qinit_credits(sb, USRQUOTA) +
913 ocfs2_calc_qinit_credits(sb, GRPQUOTA));
914 if (IS_ERR(handle)) {
915 status = PTR_ERR(handle);
916 mlog_errno(status);
917 goto out;
918 }
919 dquot_drop(inode);
920 ocfs2_commit_trans(OCFS2_SB(sb), handle);
921out:
922 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
923 if (got_lock[cnt]) {
924 oinfo = sb_dqinfo(sb, cnt)->dqi_priv;
925 ocfs2_unlock_global_qf(oinfo, 1);
926 }
927 return status;
928}
929
930/* See the comment before ocfs2_dquot_initialize. */
931static int ocfs2_dquot_drop(struct inode *inode)
932{
933 int status = 0;
934 struct super_block *sb = inode->i_sb;
935 struct ocfs2_mem_dqinfo *oinfo;
936 int exclusive = 0;
937 int cnt;
938 int got_lock[MAXQUOTAS] = {0, 0};
939
940 mlog_entry_void();
941 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
942 if (!sb_has_quota_active(sb, cnt))
943 continue;
944 oinfo = sb_dqinfo(sb, cnt)->dqi_priv;
945 status = ocfs2_lock_global_qf(oinfo, 0);
946 if (status < 0)
947 goto out;
948 got_lock[cnt] = 1;
949 }
950 /* Lock against anyone releasing references so that when when we check
951 * we know we are not going to be last ones to release dquot */
952 down_write(&sb_dqopt(sb)->dqptr_sem);
953 /* Urgh, this is a terrible hack :( */
954 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
955 if (inode->i_dquot[cnt] != NODQUOT &&
956 atomic_read(&inode->i_dquot[cnt]->dq_count) > 1) {
957 exclusive = 1;
958 break;
959 }
960 }
961 if (!exclusive)
962 dquot_drop_locked(inode);
963 up_write(&sb_dqopt(sb)->dqptr_sem);
964out:
965 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
966 if (got_lock[cnt]) {
967 oinfo = sb_dqinfo(sb, cnt)->dqi_priv;
968 ocfs2_unlock_global_qf(oinfo, 0);
969 }
970 /* In case we bailed out because we had to do expensive locking
971 * do it now... */
972 if (exclusive)
973 status = ocfs2_dquot_drop_slow(inode);
974 mlog_exit(status);
975 return status;
976}
977
978static struct dquot *ocfs2_alloc_dquot(struct super_block *sb, int type)
979{
980 struct ocfs2_dquot *dquot =
981 kmem_cache_zalloc(ocfs2_dquot_cachep, GFP_NOFS);
982
983 if (!dquot)
984 return NULL;
985 return &dquot->dq_dquot;
986}
987
988static void ocfs2_destroy_dquot(struct dquot *dquot)
989{
990 kmem_cache_free(ocfs2_dquot_cachep, dquot);
991}
992
993struct dquot_operations ocfs2_quota_operations = {
994 .initialize = ocfs2_dquot_initialize,
995 .drop = ocfs2_dquot_drop,
996 .alloc_space = dquot_alloc_space,
997 .alloc_inode = dquot_alloc_inode,
998 .free_space = dquot_free_space,
999 .free_inode = dquot_free_inode,
1000 .transfer = dquot_transfer,
1001 .write_dquot = ocfs2_write_dquot,
1002 .acquire_dquot = ocfs2_acquire_dquot,
1003 .release_dquot = ocfs2_release_dquot,
1004 .mark_dirty = ocfs2_mark_dquot_dirty,
1005 .write_info = ocfs2_write_info,
1006 .alloc_dquot = ocfs2_alloc_dquot,
1007 .destroy_dquot = ocfs2_destroy_dquot,
1008};
1009
1010int ocfs2_quota_setup(void)
1011{
1012 ocfs2_quota_wq = create_workqueue("o2quot");
1013 if (!ocfs2_quota_wq)
1014 return -ENOMEM;
1015 return 0;
1016}
1017
1018void ocfs2_quota_shutdown(void)
1019{
1020 if (ocfs2_quota_wq) {
1021 flush_workqueue(ocfs2_quota_wq);
1022 destroy_workqueue(ocfs2_quota_wq);
1023 ocfs2_quota_wq = NULL;
1024 }
1025}
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
new file mode 100644
index 000000000000..07deec5e9721
--- /dev/null
+++ b/fs/ocfs2/quota_local.c
@@ -0,0 +1,1253 @@
1/*
2 * Implementation of operations over local quota file
3 */
4
5#include <linux/fs.h>
6#include <linux/quota.h>
7#include <linux/quotaops.h>
8#include <linux/module.h>
9
10#define MLOG_MASK_PREFIX ML_QUOTA
11#include <cluster/masklog.h>
12
13#include "ocfs2_fs.h"
14#include "ocfs2.h"
15#include "inode.h"
16#include "alloc.h"
17#include "file.h"
18#include "buffer_head_io.h"
19#include "journal.h"
20#include "sysfile.h"
21#include "dlmglue.h"
22#include "quota.h"
23
24/* Number of local quota structures per block */
25static inline unsigned int ol_quota_entries_per_block(struct super_block *sb)
26{
27 return ((sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE) /
28 sizeof(struct ocfs2_local_disk_dqblk));
29}
30
31/* Number of blocks with entries in one chunk */
32static inline unsigned int ol_chunk_blocks(struct super_block *sb)
33{
34 return ((sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) -
35 OCFS2_QBLK_RESERVED_SPACE) << 3) /
36 ol_quota_entries_per_block(sb);
37}
38
39/* Number of entries in a chunk bitmap */
40static unsigned int ol_chunk_entries(struct super_block *sb)
41{
42 return ol_chunk_blocks(sb) * ol_quota_entries_per_block(sb);
43}
44
45/* Offset of the chunk in quota file */
46static unsigned int ol_quota_chunk_block(struct super_block *sb, int c)
47{
48 /* 1 block for local quota file info, 1 block per chunk for chunk info */
49 return 1 + (ol_chunk_blocks(sb) + 1) * c;
50}
51
52static unsigned int ol_dqblk_block(struct super_block *sb, int c, int off)
53{
54 int epb = ol_quota_entries_per_block(sb);
55
56 return ol_quota_chunk_block(sb, c) + 1 + off / epb;
57}
58
59static unsigned int ol_dqblk_block_off(struct super_block *sb, int c, int off)
60{
61 int epb = ol_quota_entries_per_block(sb);
62
63 return (off % epb) * sizeof(struct ocfs2_local_disk_dqblk);
64}
65
66/* Offset of the dquot structure in the quota file */
67static loff_t ol_dqblk_off(struct super_block *sb, int c, int off)
68{
69 return (ol_dqblk_block(sb, c, off) << sb->s_blocksize_bits) +
70 ol_dqblk_block_off(sb, c, off);
71}
72
73/* Compute block number from given offset */
74static inline unsigned int ol_dqblk_file_block(struct super_block *sb, loff_t off)
75{
76 return off >> sb->s_blocksize_bits;
77}
78
79static inline unsigned int ol_dqblk_block_offset(struct super_block *sb, loff_t off)
80{
81 return off & ((1 << sb->s_blocksize_bits) - 1);
82}
83
84/* Compute offset in the chunk of a structure with the given offset */
85static int ol_dqblk_chunk_off(struct super_block *sb, int c, loff_t off)
86{
87 int epb = ol_quota_entries_per_block(sb);
88
89 return ((off >> sb->s_blocksize_bits) -
90 ol_quota_chunk_block(sb, c) - 1) * epb
91 + ((unsigned int)(off & ((1 << sb->s_blocksize_bits) - 1))) /
92 sizeof(struct ocfs2_local_disk_dqblk);
93}
94
95/* Write bufferhead into the fs */
96static int ocfs2_modify_bh(struct inode *inode, struct buffer_head *bh,
97 void (*modify)(struct buffer_head *, void *), void *private)
98{
99 struct super_block *sb = inode->i_sb;
100 handle_t *handle;
101 int status;
102
103 handle = ocfs2_start_trans(OCFS2_SB(sb), 1);
104 if (IS_ERR(handle)) {
105 status = PTR_ERR(handle);
106 mlog_errno(status);
107 return status;
108 }
109 status = ocfs2_journal_access_dq(handle, inode, bh,
110 OCFS2_JOURNAL_ACCESS_WRITE);
111 if (status < 0) {
112 mlog_errno(status);
113 ocfs2_commit_trans(OCFS2_SB(sb), handle);
114 return status;
115 }
116 lock_buffer(bh);
117 modify(bh, private);
118 unlock_buffer(bh);
119 status = ocfs2_journal_dirty(handle, bh);
120 if (status < 0) {
121 mlog_errno(status);
122 ocfs2_commit_trans(OCFS2_SB(sb), handle);
123 return status;
124 }
125 status = ocfs2_commit_trans(OCFS2_SB(sb), handle);
126 if (status < 0) {
127 mlog_errno(status);
128 return status;
129 }
130 return 0;
131}
132
133/* Check whether we understand format of quota files */
134static int ocfs2_local_check_quota_file(struct super_block *sb, int type)
135{
136 unsigned int lmagics[MAXQUOTAS] = OCFS2_LOCAL_QMAGICS;
137 unsigned int lversions[MAXQUOTAS] = OCFS2_LOCAL_QVERSIONS;
138 unsigned int gmagics[MAXQUOTAS] = OCFS2_GLOBAL_QMAGICS;
139 unsigned int gversions[MAXQUOTAS] = OCFS2_GLOBAL_QVERSIONS;
140 unsigned int ino[MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
141 GROUP_QUOTA_SYSTEM_INODE };
142 struct buffer_head *bh = NULL;
143 struct inode *linode = sb_dqopt(sb)->files[type];
144 struct inode *ginode = NULL;
145 struct ocfs2_disk_dqheader *dqhead;
146 int status, ret = 0;
147
148 /* First check whether we understand local quota file */
149 status = ocfs2_read_quota_block(linode, 0, &bh);
150 if (status) {
151 mlog_errno(status);
152 mlog(ML_ERROR, "failed to read quota file header (type=%d)\n",
153 type);
154 goto out_err;
155 }
156 dqhead = (struct ocfs2_disk_dqheader *)(bh->b_data);
157 if (le32_to_cpu(dqhead->dqh_magic) != lmagics[type]) {
158 mlog(ML_ERROR, "quota file magic does not match (%u != %u),"
159 " type=%d\n", le32_to_cpu(dqhead->dqh_magic),
160 lmagics[type], type);
161 goto out_err;
162 }
163 if (le32_to_cpu(dqhead->dqh_version) != lversions[type]) {
164 mlog(ML_ERROR, "quota file version does not match (%u != %u),"
165 " type=%d\n", le32_to_cpu(dqhead->dqh_version),
166 lversions[type], type);
167 goto out_err;
168 }
169 brelse(bh);
170 bh = NULL;
171
172 /* Next check whether we understand global quota file */
173 ginode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type],
174 OCFS2_INVALID_SLOT);
175 if (!ginode) {
176 mlog(ML_ERROR, "cannot get global quota file inode "
177 "(type=%d)\n", type);
178 goto out_err;
179 }
180 /* Since the header is read only, we don't care about locking */
181 status = ocfs2_read_quota_block(ginode, 0, &bh);
182 if (status) {
183 mlog_errno(status);
184 mlog(ML_ERROR, "failed to read global quota file header "
185 "(type=%d)\n", type);
186 goto out_err;
187 }
188 dqhead = (struct ocfs2_disk_dqheader *)(bh->b_data);
189 if (le32_to_cpu(dqhead->dqh_magic) != gmagics[type]) {
190 mlog(ML_ERROR, "global quota file magic does not match "
191 "(%u != %u), type=%d\n",
192 le32_to_cpu(dqhead->dqh_magic), gmagics[type], type);
193 goto out_err;
194 }
195 if (le32_to_cpu(dqhead->dqh_version) != gversions[type]) {
196 mlog(ML_ERROR, "global quota file version does not match "
197 "(%u != %u), type=%d\n",
198 le32_to_cpu(dqhead->dqh_version), gversions[type],
199 type);
200 goto out_err;
201 }
202
203 ret = 1;
204out_err:
205 brelse(bh);
206 iput(ginode);
207 return ret;
208}
209
210/* Release given list of quota file chunks */
211static void ocfs2_release_local_quota_bitmaps(struct list_head *head)
212{
213 struct ocfs2_quota_chunk *pos, *next;
214
215 list_for_each_entry_safe(pos, next, head, qc_chunk) {
216 list_del(&pos->qc_chunk);
217 brelse(pos->qc_headerbh);
218 kmem_cache_free(ocfs2_qf_chunk_cachep, pos);
219 }
220}
221
222/* Load quota bitmaps into memory */
223static int ocfs2_load_local_quota_bitmaps(struct inode *inode,
224 struct ocfs2_local_disk_dqinfo *ldinfo,
225 struct list_head *head)
226{
227 struct ocfs2_quota_chunk *newchunk;
228 int i, status;
229
230 INIT_LIST_HEAD(head);
231 for (i = 0; i < le32_to_cpu(ldinfo->dqi_chunks); i++) {
232 newchunk = kmem_cache_alloc(ocfs2_qf_chunk_cachep, GFP_NOFS);
233 if (!newchunk) {
234 ocfs2_release_local_quota_bitmaps(head);
235 return -ENOMEM;
236 }
237 newchunk->qc_num = i;
238 newchunk->qc_headerbh = NULL;
239 status = ocfs2_read_quota_block(inode,
240 ol_quota_chunk_block(inode->i_sb, i),
241 &newchunk->qc_headerbh);
242 if (status) {
243 mlog_errno(status);
244 kmem_cache_free(ocfs2_qf_chunk_cachep, newchunk);
245 ocfs2_release_local_quota_bitmaps(head);
246 return status;
247 }
248 list_add_tail(&newchunk->qc_chunk, head);
249 }
250 return 0;
251}
252
253static void olq_update_info(struct buffer_head *bh, void *private)
254{
255 struct mem_dqinfo *info = private;
256 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
257 struct ocfs2_local_disk_dqinfo *ldinfo;
258
259 ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
260 OCFS2_LOCAL_INFO_OFF);
261 spin_lock(&dq_data_lock);
262 ldinfo->dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK);
263 ldinfo->dqi_chunks = cpu_to_le32(oinfo->dqi_chunks);
264 ldinfo->dqi_blocks = cpu_to_le32(oinfo->dqi_blocks);
265 spin_unlock(&dq_data_lock);
266}
267
268static int ocfs2_add_recovery_chunk(struct super_block *sb,
269 struct ocfs2_local_disk_chunk *dchunk,
270 int chunk,
271 struct list_head *head)
272{
273 struct ocfs2_recovery_chunk *rc;
274
275 rc = kmalloc(sizeof(struct ocfs2_recovery_chunk), GFP_NOFS);
276 if (!rc)
277 return -ENOMEM;
278 rc->rc_chunk = chunk;
279 rc->rc_bitmap = kmalloc(sb->s_blocksize, GFP_NOFS);
280 if (!rc->rc_bitmap) {
281 kfree(rc);
282 return -ENOMEM;
283 }
284 memcpy(rc->rc_bitmap, dchunk->dqc_bitmap,
285 (ol_chunk_entries(sb) + 7) >> 3);
286 list_add_tail(&rc->rc_list, head);
287 return 0;
288}
289
290static void free_recovery_list(struct list_head *head)
291{
292 struct ocfs2_recovery_chunk *next;
293 struct ocfs2_recovery_chunk *rchunk;
294
295 list_for_each_entry_safe(rchunk, next, head, rc_list) {
296 list_del(&rchunk->rc_list);
297 kfree(rchunk->rc_bitmap);
298 kfree(rchunk);
299 }
300}
301
302void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec)
303{
304 int type;
305
306 for (type = 0; type < MAXQUOTAS; type++)
307 free_recovery_list(&(rec->r_list[type]));
308 kfree(rec);
309}
310
311/* Load entries in our quota file we have to recover*/
312static int ocfs2_recovery_load_quota(struct inode *lqinode,
313 struct ocfs2_local_disk_dqinfo *ldinfo,
314 int type,
315 struct list_head *head)
316{
317 struct super_block *sb = lqinode->i_sb;
318 struct buffer_head *hbh;
319 struct ocfs2_local_disk_chunk *dchunk;
320 int i, chunks = le32_to_cpu(ldinfo->dqi_chunks);
321 int status = 0;
322
323 for (i = 0; i < chunks; i++) {
324 hbh = NULL;
325 status = ocfs2_read_quota_block(lqinode,
326 ol_quota_chunk_block(sb, i),
327 &hbh);
328 if (status) {
329 mlog_errno(status);
330 break;
331 }
332 dchunk = (struct ocfs2_local_disk_chunk *)hbh->b_data;
333 if (le32_to_cpu(dchunk->dqc_free) < ol_chunk_entries(sb))
334 status = ocfs2_add_recovery_chunk(sb, dchunk, i, head);
335 brelse(hbh);
336 if (status < 0)
337 break;
338 }
339 if (status < 0)
340 free_recovery_list(head);
341 return status;
342}
343
344static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void)
345{
346 int type;
347 struct ocfs2_quota_recovery *rec;
348
349 rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS);
350 if (!rec)
351 return NULL;
352 for (type = 0; type < MAXQUOTAS; type++)
353 INIT_LIST_HEAD(&(rec->r_list[type]));
354 return rec;
355}
356
357/* Load information we need for quota recovery into memory */
358struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
359 struct ocfs2_super *osb,
360 int slot_num)
361{
362 unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
363 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
364 unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
365 LOCAL_GROUP_QUOTA_SYSTEM_INODE };
366 struct super_block *sb = osb->sb;
367 struct ocfs2_local_disk_dqinfo *ldinfo;
368 struct inode *lqinode;
369 struct buffer_head *bh;
370 int type;
371 int status = 0;
372 struct ocfs2_quota_recovery *rec;
373
374 mlog(ML_NOTICE, "Beginning quota recovery in slot %u\n", slot_num);
375 rec = ocfs2_alloc_quota_recovery();
376 if (!rec)
377 return ERR_PTR(-ENOMEM);
378 /* First init... */
379
380 for (type = 0; type < MAXQUOTAS; type++) {
381 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
382 continue;
383 /* At this point, journal of the slot is already replayed so
384 * we can trust metadata and data of the quota file */
385 lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num);
386 if (!lqinode) {
387 status = -ENOENT;
388 goto out;
389 }
390 status = ocfs2_inode_lock_full(lqinode, NULL, 1,
391 OCFS2_META_LOCK_RECOVERY);
392 if (status < 0) {
393 mlog_errno(status);
394 goto out_put;
395 }
396 /* Now read local header */
397 bh = NULL;
398 status = ocfs2_read_quota_block(lqinode, 0, &bh);
399 if (status) {
400 mlog_errno(status);
401 mlog(ML_ERROR, "failed to read quota file info header "
402 "(slot=%d type=%d)\n", slot_num, type);
403 goto out_lock;
404 }
405 ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
406 OCFS2_LOCAL_INFO_OFF);
407 status = ocfs2_recovery_load_quota(lqinode, ldinfo, type,
408 &rec->r_list[type]);
409 brelse(bh);
410out_lock:
411 ocfs2_inode_unlock(lqinode, 1);
412out_put:
413 iput(lqinode);
414 if (status < 0)
415 break;
416 }
417out:
418 if (status < 0) {
419 ocfs2_free_quota_recovery(rec);
420 rec = ERR_PTR(status);
421 }
422 return rec;
423}
424
425/* Sync changes in local quota file into global quota file and
426 * reinitialize local quota file.
427 * The function expects local quota file to be already locked and
428 * dqonoff_mutex locked. */
429static int ocfs2_recover_local_quota_file(struct inode *lqinode,
430 int type,
431 struct ocfs2_quota_recovery *rec)
432{
433 struct super_block *sb = lqinode->i_sb;
434 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
435 struct ocfs2_local_disk_chunk *dchunk;
436 struct ocfs2_local_disk_dqblk *dqblk;
437 struct dquot *dquot;
438 handle_t *handle;
439 struct buffer_head *hbh = NULL, *qbh = NULL;
440 int status = 0;
441 int bit, chunk;
442 struct ocfs2_recovery_chunk *rchunk, *next;
443 qsize_t spacechange, inodechange;
444
445 mlog_entry("ino=%lu type=%u", (unsigned long)lqinode->i_ino, type);
446
447 status = ocfs2_lock_global_qf(oinfo, 1);
448 if (status < 0)
449 goto out;
450
451 list_for_each_entry_safe(rchunk, next, &(rec->r_list[type]), rc_list) {
452 chunk = rchunk->rc_chunk;
453 hbh = NULL;
454 status = ocfs2_read_quota_block(lqinode,
455 ol_quota_chunk_block(sb, chunk),
456 &hbh);
457 if (status) {
458 mlog_errno(status);
459 break;
460 }
461 dchunk = (struct ocfs2_local_disk_chunk *)hbh->b_data;
462 for_each_bit(bit, rchunk->rc_bitmap, ol_chunk_entries(sb)) {
463 qbh = NULL;
464 status = ocfs2_read_quota_block(lqinode,
465 ol_dqblk_block(sb, chunk, bit),
466 &qbh);
467 if (status) {
468 mlog_errno(status);
469 break;
470 }
471 dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
472 ol_dqblk_block_off(sb, chunk, bit));
473 dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type);
474 if (!dquot) {
475 status = -EIO;
476 mlog(ML_ERROR, "Failed to get quota structure "
477 "for id %u, type %d. Cannot finish quota "
478 "file recovery.\n",
479 (unsigned)le64_to_cpu(dqblk->dqb_id),
480 type);
481 goto out_put_bh;
482 }
483 handle = ocfs2_start_trans(OCFS2_SB(sb),
484 OCFS2_QSYNC_CREDITS);
485 if (IS_ERR(handle)) {
486 status = PTR_ERR(handle);
487 mlog_errno(status);
488 goto out_put_dquot;
489 }
490 mutex_lock(&sb_dqopt(sb)->dqio_mutex);
491 spin_lock(&dq_data_lock);
492 /* Add usage from quota entry into quota changes
493 * of our node. Auxiliary variables are important
494 * due to signedness */
495 spacechange = le64_to_cpu(dqblk->dqb_spacemod);
496 inodechange = le64_to_cpu(dqblk->dqb_inodemod);
497 dquot->dq_dqb.dqb_curspace += spacechange;
498 dquot->dq_dqb.dqb_curinodes += inodechange;
499 spin_unlock(&dq_data_lock);
500 /* We want to drop reference held by the crashed
501 * node. Since we have our own reference we know
502 * global structure actually won't be freed. */
503 status = ocfs2_global_release_dquot(dquot);
504 if (status < 0) {
505 mlog_errno(status);
506 goto out_commit;
507 }
508 /* Release local quota file entry */
509 status = ocfs2_journal_access_dq(handle, lqinode,
510 qbh, OCFS2_JOURNAL_ACCESS_WRITE);
511 if (status < 0) {
512 mlog_errno(status);
513 goto out_commit;
514 }
515 lock_buffer(qbh);
516 WARN_ON(!ocfs2_test_bit(bit, dchunk->dqc_bitmap));
517 ocfs2_clear_bit(bit, dchunk->dqc_bitmap);
518 le32_add_cpu(&dchunk->dqc_free, 1);
519 unlock_buffer(qbh);
520 status = ocfs2_journal_dirty(handle, qbh);
521 if (status < 0)
522 mlog_errno(status);
523out_commit:
524 mutex_unlock(&sb_dqopt(sb)->dqio_mutex);
525 ocfs2_commit_trans(OCFS2_SB(sb), handle);
526out_put_dquot:
527 dqput(dquot);
528out_put_bh:
529 brelse(qbh);
530 if (status < 0)
531 break;
532 }
533 brelse(hbh);
534 list_del(&rchunk->rc_list);
535 kfree(rchunk->rc_bitmap);
536 kfree(rchunk);
537 if (status < 0)
538 break;
539 }
540 ocfs2_unlock_global_qf(oinfo, 1);
541out:
542 if (status < 0)
543 free_recovery_list(&(rec->r_list[type]));
544 mlog_exit(status);
545 return status;
546}
547
548/* Recover local quota files for given node different from us */
549int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
550 struct ocfs2_quota_recovery *rec,
551 int slot_num)
552{
553 unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
554 LOCAL_GROUP_QUOTA_SYSTEM_INODE };
555 struct super_block *sb = osb->sb;
556 struct ocfs2_local_disk_dqinfo *ldinfo;
557 struct buffer_head *bh;
558 handle_t *handle;
559 int type;
560 int status = 0;
561 struct inode *lqinode;
562 unsigned int flags;
563
564 mlog(ML_NOTICE, "Finishing quota recovery in slot %u\n", slot_num);
565 mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
566 for (type = 0; type < MAXQUOTAS; type++) {
567 if (list_empty(&(rec->r_list[type])))
568 continue;
569 mlog(0, "Recovering quota in slot %d\n", slot_num);
570 lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num);
571 if (!lqinode) {
572 status = -ENOENT;
573 goto out;
574 }
575 status = ocfs2_inode_lock_full(lqinode, NULL, 1,
576 OCFS2_META_LOCK_NOQUEUE);
577 /* Someone else is holding the lock? Then he must be
578 * doing the recovery. Just skip the file... */
579 if (status == -EAGAIN) {
580 mlog(ML_NOTICE, "skipping quota recovery for slot %d "
581 "because quota file is locked.\n", slot_num);
582 status = 0;
583 goto out_put;
584 } else if (status < 0) {
585 mlog_errno(status);
586 goto out_put;
587 }
588 /* Now read local header */
589 bh = NULL;
590 status = ocfs2_read_quota_block(lqinode, 0, &bh);
591 if (status) {
592 mlog_errno(status);
593 mlog(ML_ERROR, "failed to read quota file info header "
594 "(slot=%d type=%d)\n", slot_num, type);
595 goto out_lock;
596 }
597 ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
598 OCFS2_LOCAL_INFO_OFF);
599 /* Is recovery still needed? */
600 flags = le32_to_cpu(ldinfo->dqi_flags);
601 if (!(flags & OLQF_CLEAN))
602 status = ocfs2_recover_local_quota_file(lqinode,
603 type,
604 rec);
605 /* We don't want to mark file as clean when it is actually
606 * active */
607 if (slot_num == osb->slot_num)
608 goto out_bh;
609 /* Mark quota file as clean if we are recovering quota file of
610 * some other node. */
611 handle = ocfs2_start_trans(osb, 1);
612 if (IS_ERR(handle)) {
613 status = PTR_ERR(handle);
614 mlog_errno(status);
615 goto out_bh;
616 }
617 status = ocfs2_journal_access_dq(handle, lqinode, bh,
618 OCFS2_JOURNAL_ACCESS_WRITE);
619 if (status < 0) {
620 mlog_errno(status);
621 goto out_trans;
622 }
623 lock_buffer(bh);
624 ldinfo->dqi_flags = cpu_to_le32(flags | OLQF_CLEAN);
625 unlock_buffer(bh);
626 status = ocfs2_journal_dirty(handle, bh);
627 if (status < 0)
628 mlog_errno(status);
629out_trans:
630 ocfs2_commit_trans(osb, handle);
631out_bh:
632 brelse(bh);
633out_lock:
634 ocfs2_inode_unlock(lqinode, 1);
635out_put:
636 iput(lqinode);
637 if (status < 0)
638 break;
639 }
640out:
641 mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
642 kfree(rec);
643 return status;
644}
645
646/* Read information header from quota file */
647static int ocfs2_local_read_info(struct super_block *sb, int type)
648{
649 struct ocfs2_local_disk_dqinfo *ldinfo;
650 struct mem_dqinfo *info = sb_dqinfo(sb, type);
651 struct ocfs2_mem_dqinfo *oinfo;
652 struct inode *lqinode = sb_dqopt(sb)->files[type];
653 int status;
654 struct buffer_head *bh = NULL;
655 struct ocfs2_quota_recovery *rec;
656 int locked = 0;
657
658 info->dqi_maxblimit = 0x7fffffffffffffffLL;
659 info->dqi_maxilimit = 0x7fffffffffffffffLL;
660 oinfo = kmalloc(sizeof(struct ocfs2_mem_dqinfo), GFP_NOFS);
661 if (!oinfo) {
662 mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota"
663 " info.");
664 goto out_err;
665 }
666 info->dqi_priv = oinfo;
667 oinfo->dqi_type = type;
668 INIT_LIST_HEAD(&oinfo->dqi_chunk);
669 oinfo->dqi_rec = NULL;
670 oinfo->dqi_lqi_bh = NULL;
671 oinfo->dqi_ibh = NULL;
672
673 status = ocfs2_global_read_info(sb, type);
674 if (status < 0)
675 goto out_err;
676
677 status = ocfs2_inode_lock(lqinode, &oinfo->dqi_lqi_bh, 1);
678 if (status < 0) {
679 mlog_errno(status);
680 goto out_err;
681 }
682 locked = 1;
683
684 /* Now read local header */
685 status = ocfs2_read_quota_block(lqinode, 0, &bh);
686 if (status) {
687 mlog_errno(status);
688 mlog(ML_ERROR, "failed to read quota file info header "
689 "(type=%d)\n", type);
690 goto out_err;
691 }
692 ldinfo = (struct ocfs2_local_disk_dqinfo *)(bh->b_data +
693 OCFS2_LOCAL_INFO_OFF);
694 info->dqi_flags = le32_to_cpu(ldinfo->dqi_flags);
695 oinfo->dqi_chunks = le32_to_cpu(ldinfo->dqi_chunks);
696 oinfo->dqi_blocks = le32_to_cpu(ldinfo->dqi_blocks);
697 oinfo->dqi_ibh = bh;
698
699 /* We crashed when using local quota file? */
700 if (!(info->dqi_flags & OLQF_CLEAN)) {
701 rec = OCFS2_SB(sb)->quota_rec;
702 if (!rec) {
703 rec = ocfs2_alloc_quota_recovery();
704 if (!rec) {
705 status = -ENOMEM;
706 mlog_errno(status);
707 goto out_err;
708 }
709 OCFS2_SB(sb)->quota_rec = rec;
710 }
711
712 status = ocfs2_recovery_load_quota(lqinode, ldinfo, type,
713 &rec->r_list[type]);
714 if (status < 0) {
715 mlog_errno(status);
716 goto out_err;
717 }
718 }
719
720 status = ocfs2_load_local_quota_bitmaps(lqinode,
721 ldinfo,
722 &oinfo->dqi_chunk);
723 if (status < 0) {
724 mlog_errno(status);
725 goto out_err;
726 }
727
728 /* Now mark quota file as used */
729 info->dqi_flags &= ~OLQF_CLEAN;
730 status = ocfs2_modify_bh(lqinode, bh, olq_update_info, info);
731 if (status < 0) {
732 mlog_errno(status);
733 goto out_err;
734 }
735
736 return 0;
737out_err:
738 if (oinfo) {
739 iput(oinfo->dqi_gqinode);
740 ocfs2_simple_drop_lockres(OCFS2_SB(sb), &oinfo->dqi_gqlock);
741 ocfs2_lock_res_free(&oinfo->dqi_gqlock);
742 brelse(oinfo->dqi_lqi_bh);
743 if (locked)
744 ocfs2_inode_unlock(lqinode, 1);
745 ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
746 kfree(oinfo);
747 }
748 brelse(bh);
749 return -1;
750}
751
752/* Write local info to quota file */
753static int ocfs2_local_write_info(struct super_block *sb, int type)
754{
755 struct mem_dqinfo *info = sb_dqinfo(sb, type);
756 struct buffer_head *bh = ((struct ocfs2_mem_dqinfo *)info->dqi_priv)
757 ->dqi_ibh;
758 int status;
759
760 status = ocfs2_modify_bh(sb_dqopt(sb)->files[type], bh, olq_update_info,
761 info);
762 if (status < 0) {
763 mlog_errno(status);
764 return -1;
765 }
766
767 return 0;
768}
769
770/* Release info from memory */
771static int ocfs2_local_free_info(struct super_block *sb, int type)
772{
773 struct mem_dqinfo *info = sb_dqinfo(sb, type);
774 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
775 struct ocfs2_quota_chunk *chunk;
776 struct ocfs2_local_disk_chunk *dchunk;
777 int mark_clean = 1, len;
778 int status;
779
780 /* At this point we know there are no more dquots and thus
781 * even if there's some sync in the pdflush queue, it won't
782 * find any dquots and return without doing anything */
783 cancel_delayed_work_sync(&oinfo->dqi_sync_work);
784 iput(oinfo->dqi_gqinode);
785 ocfs2_simple_drop_lockres(OCFS2_SB(sb), &oinfo->dqi_gqlock);
786 ocfs2_lock_res_free(&oinfo->dqi_gqlock);
787 list_for_each_entry(chunk, &oinfo->dqi_chunk, qc_chunk) {
788 dchunk = (struct ocfs2_local_disk_chunk *)
789 (chunk->qc_headerbh->b_data);
790 if (chunk->qc_num < oinfo->dqi_chunks - 1) {
791 len = ol_chunk_entries(sb);
792 } else {
793 len = (oinfo->dqi_blocks -
794 ol_quota_chunk_block(sb, chunk->qc_num) - 1)
795 * ol_quota_entries_per_block(sb);
796 }
797 /* Not all entries free? Bug! */
798 if (le32_to_cpu(dchunk->dqc_free) != len) {
799 mlog(ML_ERROR, "releasing quota file with used "
800 "entries (type=%d)\n", type);
801 mark_clean = 0;
802 }
803 }
804 ocfs2_release_local_quota_bitmaps(&oinfo->dqi_chunk);
805
806 /* dqonoff_mutex protects us against racing with recovery thread... */
807 if (oinfo->dqi_rec) {
808 ocfs2_free_quota_recovery(oinfo->dqi_rec);
809 mark_clean = 0;
810 }
811
812 if (!mark_clean)
813 goto out;
814
815 /* Mark local file as clean */
816 info->dqi_flags |= OLQF_CLEAN;
817 status = ocfs2_modify_bh(sb_dqopt(sb)->files[type],
818 oinfo->dqi_ibh,
819 olq_update_info,
820 info);
821 if (status < 0) {
822 mlog_errno(status);
823 goto out;
824 }
825
826out:
827 ocfs2_inode_unlock(sb_dqopt(sb)->files[type], 1);
828 brelse(oinfo->dqi_ibh);
829 brelse(oinfo->dqi_lqi_bh);
830 kfree(oinfo);
831 return 0;
832}
833
834static void olq_set_dquot(struct buffer_head *bh, void *private)
835{
836 struct ocfs2_dquot *od = private;
837 struct ocfs2_local_disk_dqblk *dqblk;
838 struct super_block *sb = od->dq_dquot.dq_sb;
839
840 dqblk = (struct ocfs2_local_disk_dqblk *)(bh->b_data
841 + ol_dqblk_block_offset(sb, od->dq_local_off));
842
843 dqblk->dqb_id = cpu_to_le64(od->dq_dquot.dq_id);
844 spin_lock(&dq_data_lock);
845 dqblk->dqb_spacemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curspace -
846 od->dq_origspace);
847 dqblk->dqb_inodemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curinodes -
848 od->dq_originodes);
849 spin_unlock(&dq_data_lock);
850 mlog(0, "Writing local dquot %u space %lld inodes %lld\n",
851 od->dq_dquot.dq_id, (long long)le64_to_cpu(dqblk->dqb_spacemod),
852 (long long)le64_to_cpu(dqblk->dqb_inodemod));
853}
854
855/* Write dquot to local quota file */
856static int ocfs2_local_write_dquot(struct dquot *dquot)
857{
858 struct super_block *sb = dquot->dq_sb;
859 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
860 struct buffer_head *bh = NULL;
861 int status;
862
863 status = ocfs2_read_quota_block(sb_dqopt(sb)->files[dquot->dq_type],
864 ol_dqblk_file_block(sb, od->dq_local_off),
865 &bh);
866 if (status) {
867 mlog_errno(status);
868 goto out;
869 }
870 status = ocfs2_modify_bh(sb_dqopt(sb)->files[dquot->dq_type], bh,
871 olq_set_dquot, od);
872 if (status < 0) {
873 mlog_errno(status);
874 goto out;
875 }
876out:
877 brelse(bh);
878 return status;
879}
880
881/* Find free entry in local quota file */
882static struct ocfs2_quota_chunk *ocfs2_find_free_entry(struct super_block *sb,
883 int type,
884 int *offset)
885{
886 struct mem_dqinfo *info = sb_dqinfo(sb, type);
887 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
888 struct ocfs2_quota_chunk *chunk;
889 struct ocfs2_local_disk_chunk *dchunk;
890 int found = 0, len;
891
892 list_for_each_entry(chunk, &oinfo->dqi_chunk, qc_chunk) {
893 dchunk = (struct ocfs2_local_disk_chunk *)
894 chunk->qc_headerbh->b_data;
895 if (le32_to_cpu(dchunk->dqc_free) > 0) {
896 found = 1;
897 break;
898 }
899 }
900 if (!found)
901 return NULL;
902
903 if (chunk->qc_num < oinfo->dqi_chunks - 1) {
904 len = ol_chunk_entries(sb);
905 } else {
906 len = (oinfo->dqi_blocks -
907 ol_quota_chunk_block(sb, chunk->qc_num) - 1)
908 * ol_quota_entries_per_block(sb);
909 }
910
911 found = ocfs2_find_next_zero_bit(dchunk->dqc_bitmap, len, 0);
912 /* We failed? */
913 if (found == len) {
914 mlog(ML_ERROR, "Did not find empty entry in chunk %d with %u"
915 " entries free (type=%d)\n", chunk->qc_num,
916 le32_to_cpu(dchunk->dqc_free), type);
917 return ERR_PTR(-EIO);
918 }
919 *offset = found;
920 return chunk;
921}
922
923/* Add new chunk to the local quota file */
924static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
925 struct super_block *sb,
926 int type,
927 int *offset)
928{
929 struct mem_dqinfo *info = sb_dqinfo(sb, type);
930 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
931 struct inode *lqinode = sb_dqopt(sb)->files[type];
932 struct ocfs2_quota_chunk *chunk = NULL;
933 struct ocfs2_local_disk_chunk *dchunk;
934 int status;
935 handle_t *handle;
936 struct buffer_head *bh = NULL;
937 u64 p_blkno;
938
939 /* We are protected by dqio_sem so no locking needed */
940 status = ocfs2_extend_no_holes(lqinode,
941 lqinode->i_size + 2 * sb->s_blocksize,
942 lqinode->i_size);
943 if (status < 0) {
944 mlog_errno(status);
945 goto out;
946 }
947 status = ocfs2_simple_size_update(lqinode, oinfo->dqi_lqi_bh,
948 lqinode->i_size + 2 * sb->s_blocksize);
949 if (status < 0) {
950 mlog_errno(status);
951 goto out;
952 }
953
954 chunk = kmem_cache_alloc(ocfs2_qf_chunk_cachep, GFP_NOFS);
955 if (!chunk) {
956 status = -ENOMEM;
957 mlog_errno(status);
958 goto out;
959 }
960
961 down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
962 status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks,
963 &p_blkno, NULL, NULL);
964 up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
965 if (status < 0) {
966 mlog_errno(status);
967 goto out;
968 }
969 bh = sb_getblk(sb, p_blkno);
970 if (!bh) {
971 status = -ENOMEM;
972 mlog_errno(status);
973 goto out;
974 }
975 dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data;
976
977 handle = ocfs2_start_trans(OCFS2_SB(sb), 2);
978 if (IS_ERR(handle)) {
979 status = PTR_ERR(handle);
980 mlog_errno(status);
981 goto out;
982 }
983
984 status = ocfs2_journal_access_dq(handle, lqinode, bh,
985 OCFS2_JOURNAL_ACCESS_WRITE);
986 if (status < 0) {
987 mlog_errno(status);
988 goto out_trans;
989 }
990 lock_buffer(bh);
991 dchunk->dqc_free = cpu_to_le32(ol_quota_entries_per_block(sb));
992 memset(dchunk->dqc_bitmap, 0,
993 sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) -
994 OCFS2_QBLK_RESERVED_SPACE);
995 set_buffer_uptodate(bh);
996 unlock_buffer(bh);
997 status = ocfs2_journal_dirty(handle, bh);
998 if (status < 0) {
999 mlog_errno(status);
1000 goto out_trans;
1001 }
1002
1003 oinfo->dqi_blocks += 2;
1004 oinfo->dqi_chunks++;
1005 status = ocfs2_local_write_info(sb, type);
1006 if (status < 0) {
1007 mlog_errno(status);
1008 goto out_trans;
1009 }
1010 status = ocfs2_commit_trans(OCFS2_SB(sb), handle);
1011 if (status < 0) {
1012 mlog_errno(status);
1013 goto out;
1014 }
1015
1016 list_add_tail(&chunk->qc_chunk, &oinfo->dqi_chunk);
1017 chunk->qc_num = list_entry(chunk->qc_chunk.prev,
1018 struct ocfs2_quota_chunk,
1019 qc_chunk)->qc_num + 1;
1020 chunk->qc_headerbh = bh;
1021 *offset = 0;
1022 return chunk;
1023out_trans:
1024 ocfs2_commit_trans(OCFS2_SB(sb), handle);
1025out:
1026 brelse(bh);
1027 kmem_cache_free(ocfs2_qf_chunk_cachep, chunk);
1028 return ERR_PTR(status);
1029}
1030
1031/* Find free entry in local quota file */
1032static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
1033 struct super_block *sb,
1034 int type,
1035 int *offset)
1036{
1037 struct mem_dqinfo *info = sb_dqinfo(sb, type);
1038 struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
1039 struct ocfs2_quota_chunk *chunk;
1040 struct inode *lqinode = sb_dqopt(sb)->files[type];
1041 struct ocfs2_local_disk_chunk *dchunk;
1042 int epb = ol_quota_entries_per_block(sb);
1043 unsigned int chunk_blocks;
1044 int status;
1045 handle_t *handle;
1046
1047 if (list_empty(&oinfo->dqi_chunk))
1048 return ocfs2_local_quota_add_chunk(sb, type, offset);
1049 /* Is the last chunk full? */
1050 chunk = list_entry(oinfo->dqi_chunk.prev,
1051 struct ocfs2_quota_chunk, qc_chunk);
1052 chunk_blocks = oinfo->dqi_blocks -
1053 ol_quota_chunk_block(sb, chunk->qc_num) - 1;
1054 if (ol_chunk_blocks(sb) == chunk_blocks)
1055 return ocfs2_local_quota_add_chunk(sb, type, offset);
1056
1057 /* We are protected by dqio_sem so no locking needed */
1058 status = ocfs2_extend_no_holes(lqinode,
1059 lqinode->i_size + sb->s_blocksize,
1060 lqinode->i_size);
1061 if (status < 0) {
1062 mlog_errno(status);
1063 goto out;
1064 }
1065 status = ocfs2_simple_size_update(lqinode, oinfo->dqi_lqi_bh,
1066 lqinode->i_size + sb->s_blocksize);
1067 if (status < 0) {
1068 mlog_errno(status);
1069 goto out;
1070 }
1071 handle = ocfs2_start_trans(OCFS2_SB(sb), 2);
1072 if (IS_ERR(handle)) {
1073 status = PTR_ERR(handle);
1074 mlog_errno(status);
1075 goto out;
1076 }
1077 status = ocfs2_journal_access_dq(handle, lqinode, chunk->qc_headerbh,
1078 OCFS2_JOURNAL_ACCESS_WRITE);
1079 if (status < 0) {
1080 mlog_errno(status);
1081 goto out_trans;
1082 }
1083
1084 dchunk = (struct ocfs2_local_disk_chunk *)chunk->qc_headerbh->b_data;
1085 lock_buffer(chunk->qc_headerbh);
1086 le32_add_cpu(&dchunk->dqc_free, ol_quota_entries_per_block(sb));
1087 unlock_buffer(chunk->qc_headerbh);
1088 status = ocfs2_journal_dirty(handle, chunk->qc_headerbh);
1089 if (status < 0) {
1090 mlog_errno(status);
1091 goto out_trans;
1092 }
1093 oinfo->dqi_blocks++;
1094 status = ocfs2_local_write_info(sb, type);
1095 if (status < 0) {
1096 mlog_errno(status);
1097 goto out_trans;
1098 }
1099
1100 status = ocfs2_commit_trans(OCFS2_SB(sb), handle);
1101 if (status < 0) {
1102 mlog_errno(status);
1103 goto out;
1104 }
1105 *offset = chunk_blocks * epb;
1106 return chunk;
1107out_trans:
1108 ocfs2_commit_trans(OCFS2_SB(sb), handle);
1109out:
1110 return ERR_PTR(status);
1111}
1112
1113static void olq_alloc_dquot(struct buffer_head *bh, void *private)
1114{
1115 int *offset = private;
1116 struct ocfs2_local_disk_chunk *dchunk;
1117
1118 dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data;
1119 ocfs2_set_bit(*offset, dchunk->dqc_bitmap);
1120 le32_add_cpu(&dchunk->dqc_free, -1);
1121}
1122
1123/* Create dquot in the local file for given id */
1124static int ocfs2_create_local_dquot(struct dquot *dquot)
1125{
1126 struct super_block *sb = dquot->dq_sb;
1127 int type = dquot->dq_type;
1128 struct inode *lqinode = sb_dqopt(sb)->files[type];
1129 struct ocfs2_quota_chunk *chunk;
1130 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
1131 int offset;
1132 int status;
1133
1134 chunk = ocfs2_find_free_entry(sb, type, &offset);
1135 if (!chunk) {
1136 chunk = ocfs2_extend_local_quota_file(sb, type, &offset);
1137 if (IS_ERR(chunk))
1138 return PTR_ERR(chunk);
1139 } else if (IS_ERR(chunk)) {
1140 return PTR_ERR(chunk);
1141 }
1142 od->dq_local_off = ol_dqblk_off(sb, chunk->qc_num, offset);
1143 od->dq_chunk = chunk;
1144
1145 /* Initialize dquot structure on disk */
1146 status = ocfs2_local_write_dquot(dquot);
1147 if (status < 0) {
1148 mlog_errno(status);
1149 goto out;
1150 }
1151
1152 /* Mark structure as allocated */
1153 status = ocfs2_modify_bh(lqinode, chunk->qc_headerbh, olq_alloc_dquot,
1154 &offset);
1155 if (status < 0) {
1156 mlog_errno(status);
1157 goto out;
1158 }
1159out:
1160 return status;
1161}
1162
1163/* Create entry in local file for dquot, load data from the global file */
1164static int ocfs2_local_read_dquot(struct dquot *dquot)
1165{
1166 int status;
1167
1168 mlog_entry("id=%u, type=%d\n", dquot->dq_id, dquot->dq_type);
1169
1170 status = ocfs2_global_read_dquot(dquot);
1171 if (status < 0) {
1172 mlog_errno(status);
1173 goto out_err;
1174 }
1175
1176 /* Now create entry in the local quota file */
1177 status = ocfs2_create_local_dquot(dquot);
1178 if (status < 0) {
1179 mlog_errno(status);
1180 goto out_err;
1181 }
1182 mlog_exit(0);
1183 return 0;
1184out_err:
1185 mlog_exit(status);
1186 return status;
1187}
1188
1189/* Release dquot structure from local quota file. ocfs2_release_dquot() has
1190 * already started a transaction and obtained exclusive lock for global
1191 * quota file. */
1192static int ocfs2_local_release_dquot(struct dquot *dquot)
1193{
1194 int status;
1195 int type = dquot->dq_type;
1196 struct ocfs2_dquot *od = OCFS2_DQUOT(dquot);
1197 struct super_block *sb = dquot->dq_sb;
1198 struct ocfs2_local_disk_chunk *dchunk;
1199 int offset;
1200 handle_t *handle = journal_current_handle();
1201
1202 BUG_ON(!handle);
1203 /* First write all local changes to global file */
1204 status = ocfs2_global_release_dquot(dquot);
1205 if (status < 0) {
1206 mlog_errno(status);
1207 goto out;
1208 }
1209
1210 status = ocfs2_journal_access_dq(handle, sb_dqopt(sb)->files[type],
1211 od->dq_chunk->qc_headerbh, OCFS2_JOURNAL_ACCESS_WRITE);
1212 if (status < 0) {
1213 mlog_errno(status);
1214 goto out;
1215 }
1216 offset = ol_dqblk_chunk_off(sb, od->dq_chunk->qc_num,
1217 od->dq_local_off);
1218 dchunk = (struct ocfs2_local_disk_chunk *)
1219 (od->dq_chunk->qc_headerbh->b_data);
1220 /* Mark structure as freed */
1221 lock_buffer(od->dq_chunk->qc_headerbh);
1222 ocfs2_clear_bit(offset, dchunk->dqc_bitmap);
1223 le32_add_cpu(&dchunk->dqc_free, 1);
1224 unlock_buffer(od->dq_chunk->qc_headerbh);
1225 status = ocfs2_journal_dirty(handle, od->dq_chunk->qc_headerbh);
1226 if (status < 0) {
1227 mlog_errno(status);
1228 goto out;
1229 }
1230 status = 0;
1231out:
1232 /* Clear the read bit so that next time someone uses this
1233 * dquot he reads fresh info from disk and allocates local
1234 * dquot structure */
1235 clear_bit(DQ_READ_B, &dquot->dq_flags);
1236 return status;
1237}
1238
1239static struct quota_format_ops ocfs2_format_ops = {
1240 .check_quota_file = ocfs2_local_check_quota_file,
1241 .read_file_info = ocfs2_local_read_info,
1242 .write_file_info = ocfs2_global_write_info,
1243 .free_file_info = ocfs2_local_free_info,
1244 .read_dqblk = ocfs2_local_read_dquot,
1245 .commit_dqblk = ocfs2_local_write_dquot,
1246 .release_dqblk = ocfs2_local_release_dquot,
1247};
1248
1249struct quota_format_type ocfs2_quota_format = {
1250 .qf_fmt_id = QFMT_OCFS2,
1251 .qf_ops = &ocfs2_format_ops,
1252 .qf_owner = THIS_MODULE
1253};
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index ffd48db229a7..424adaa5f900 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -106,8 +106,8 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle,
106 mlog_entry("(new_clusters=%d, first_new_cluster = %u)\n", 106 mlog_entry("(new_clusters=%d, first_new_cluster = %u)\n",
107 new_clusters, first_new_cluster); 107 new_clusters, first_new_cluster);
108 108
109 ret = ocfs2_journal_access(handle, bm_inode, group_bh, 109 ret = ocfs2_journal_access_gd(handle, bm_inode, group_bh,
110 OCFS2_JOURNAL_ACCESS_WRITE); 110 OCFS2_JOURNAL_ACCESS_WRITE);
111 if (ret < 0) { 111 if (ret < 0) {
112 mlog_errno(ret); 112 mlog_errno(ret);
113 goto out; 113 goto out;
@@ -141,8 +141,8 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle,
141 } 141 }
142 142
143 /* update the inode accordingly. */ 143 /* update the inode accordingly. */
144 ret = ocfs2_journal_access(handle, bm_inode, bm_bh, 144 ret = ocfs2_journal_access_di(handle, bm_inode, bm_bh,
145 OCFS2_JOURNAL_ACCESS_WRITE); 145 OCFS2_JOURNAL_ACCESS_WRITE);
146 if (ret < 0) { 146 if (ret < 0) {
147 mlog_errno(ret); 147 mlog_errno(ret);
148 goto out_rollback; 148 goto out_rollback;
@@ -314,6 +314,10 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
314 314
315 fe = (struct ocfs2_dinode *)main_bm_bh->b_data; 315 fe = (struct ocfs2_dinode *)main_bm_bh->b_data;
316 316
317 /* main_bm_bh is validated by inode read inside ocfs2_inode_lock(),
318 * so any corruption is a code bug. */
319 BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
320
317 if (le16_to_cpu(fe->id2.i_chain.cl_cpg) != 321 if (le16_to_cpu(fe->id2.i_chain.cl_cpg) !=
318 ocfs2_group_bitmap_size(osb->sb) * 8) { 322 ocfs2_group_bitmap_size(osb->sb) * 8) {
319 mlog(ML_ERROR, "The disk is too old and small. " 323 mlog(ML_ERROR, "The disk is too old and small. "
@@ -322,30 +326,18 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
322 goto out_unlock; 326 goto out_unlock;
323 } 327 }
324 328
325 if (!OCFS2_IS_VALID_DINODE(fe)) {
326 OCFS2_RO_ON_INVALID_DINODE(main_bm_inode->i_sb, fe);
327 ret = -EIO;
328 goto out_unlock;
329 }
330
331 first_new_cluster = le32_to_cpu(fe->i_clusters); 329 first_new_cluster = le32_to_cpu(fe->i_clusters);
332 lgd_blkno = ocfs2_which_cluster_group(main_bm_inode, 330 lgd_blkno = ocfs2_which_cluster_group(main_bm_inode,
333 first_new_cluster - 1); 331 first_new_cluster - 1);
334 332
335 ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh); 333 ret = ocfs2_read_group_descriptor(main_bm_inode, fe, lgd_blkno,
334 &group_bh);
336 if (ret < 0) { 335 if (ret < 0) {
337 mlog_errno(ret); 336 mlog_errno(ret);
338 goto out_unlock; 337 goto out_unlock;
339 } 338 }
340
341 group = (struct ocfs2_group_desc *)group_bh->b_data; 339 group = (struct ocfs2_group_desc *)group_bh->b_data;
342 340
343 ret = ocfs2_check_group_descriptor(inode->i_sb, fe, group);
344 if (ret) {
345 mlog_errno(ret);
346 goto out_unlock;
347 }
348
349 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc); 341 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
350 if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters > 342 if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
351 le16_to_cpu(fe->id2.i_chain.cl_cpg)) { 343 le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
@@ -398,41 +390,16 @@ static int ocfs2_check_new_group(struct inode *inode,
398 struct buffer_head *group_bh) 390 struct buffer_head *group_bh)
399{ 391{
400 int ret; 392 int ret;
401 struct ocfs2_group_desc *gd; 393 struct ocfs2_group_desc *gd =
394 (struct ocfs2_group_desc *)group_bh->b_data;
402 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc); 395 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
403 unsigned int max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) *
404 le16_to_cpu(di->id2.i_chain.cl_bpc);
405
406 396
407 gd = (struct ocfs2_group_desc *)group_bh->b_data; 397 ret = ocfs2_check_group_descriptor(inode->i_sb, di, group_bh);
398 if (ret)
399 goto out;
408 400
409 ret = -EIO; 401 ret = -EINVAL;
410 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) 402 if (le16_to_cpu(gd->bg_chain) != input->chain)
411 mlog(ML_ERROR, "Group descriptor # %llu isn't valid.\n",
412 (unsigned long long)le64_to_cpu(gd->bg_blkno));
413 else if (di->i_blkno != gd->bg_parent_dinode)
414 mlog(ML_ERROR, "Group descriptor # %llu has bad parent "
415 "pointer (%llu, expected %llu)\n",
416 (unsigned long long)le64_to_cpu(gd->bg_blkno),
417 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
418 (unsigned long long)le64_to_cpu(di->i_blkno));
419 else if (le16_to_cpu(gd->bg_bits) > max_bits)
420 mlog(ML_ERROR, "Group descriptor # %llu has bit count of %u\n",
421 (unsigned long long)le64_to_cpu(gd->bg_blkno),
422 le16_to_cpu(gd->bg_bits));
423 else if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits))
424 mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
425 "claims that %u are free\n",
426 (unsigned long long)le64_to_cpu(gd->bg_blkno),
427 le16_to_cpu(gd->bg_bits),
428 le16_to_cpu(gd->bg_free_bits_count));
429 else if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size)))
430 mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
431 "max bitmap bits of %u\n",
432 (unsigned long long)le64_to_cpu(gd->bg_blkno),
433 le16_to_cpu(gd->bg_bits),
434 8 * le16_to_cpu(gd->bg_size));
435 else if (le16_to_cpu(gd->bg_chain) != input->chain)
436 mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u " 403 mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u "
437 "while input has %u set.\n", 404 "while input has %u set.\n",
438 (unsigned long long)le64_to_cpu(gd->bg_blkno), 405 (unsigned long long)le64_to_cpu(gd->bg_blkno),
@@ -451,6 +418,7 @@ static int ocfs2_check_new_group(struct inode *inode,
451 else 418 else
452 ret = 0; 419 ret = 0;
453 420
421out:
454 return ret; 422 return ret;
455} 423}
456 424
@@ -568,8 +536,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
568 cl = &fe->id2.i_chain; 536 cl = &fe->id2.i_chain;
569 cr = &cl->cl_recs[input->chain]; 537 cr = &cl->cl_recs[input->chain];
570 538
571 ret = ocfs2_journal_access(handle, main_bm_inode, group_bh, 539 ret = ocfs2_journal_access_gd(handle, main_bm_inode, group_bh,
572 OCFS2_JOURNAL_ACCESS_WRITE); 540 OCFS2_JOURNAL_ACCESS_WRITE);
573 if (ret < 0) { 541 if (ret < 0) {
574 mlog_errno(ret); 542 mlog_errno(ret);
575 goto out_commit; 543 goto out_commit;
@@ -584,8 +552,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
584 goto out_commit; 552 goto out_commit;
585 } 553 }
586 554
587 ret = ocfs2_journal_access(handle, main_bm_inode, main_bm_bh, 555 ret = ocfs2_journal_access_di(handle, main_bm_inode, main_bm_bh,
588 OCFS2_JOURNAL_ACCESS_WRITE); 556 OCFS2_JOURNAL_ACCESS_WRITE);
589 if (ret < 0) { 557 if (ret < 0) {
590 mlog_errno(ret); 558 mlog_errno(ret);
591 goto out_commit; 559 goto out_commit;
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index bdda2d8f8508..40661e7824e9 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -151,7 +151,7 @@ int ocfs2_refresh_slot_info(struct ocfs2_super *osb)
151 * this is not true, the read of -1 (UINT64_MAX) will fail. 151 * this is not true, the read of -1 (UINT64_MAX) will fail.
152 */ 152 */
153 ret = ocfs2_read_blocks(si->si_inode, -1, si->si_blocks, si->si_bh, 153 ret = ocfs2_read_blocks(si->si_inode, -1, si->si_blocks, si->si_bh,
154 OCFS2_BH_IGNORE_CACHE); 154 OCFS2_BH_IGNORE_CACHE, NULL);
155 if (ret == 0) { 155 if (ret == 0) {
156 spin_lock(&osb->osb_lock); 156 spin_lock(&osb->osb_lock);
157 ocfs2_update_slot_info(si); 157 ocfs2_update_slot_info(si);
@@ -405,7 +405,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb,
405 405
406 bh = NULL; /* Acquire a fresh bh */ 406 bh = NULL; /* Acquire a fresh bh */
407 status = ocfs2_read_blocks(si->si_inode, blkno, 1, &bh, 407 status = ocfs2_read_blocks(si->si_inode, blkno, 1, &bh,
408 OCFS2_BH_IGNORE_CACHE); 408 OCFS2_BH_IGNORE_CACHE, NULL);
409 if (status < 0) { 409 if (status < 0) {
410 mlog_errno(status); 410 mlog_errno(status);
411 goto bail; 411 goto bail;
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index c5ff18b46b57..a69628603e18 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -35,6 +35,7 @@
35#include "ocfs2.h" 35#include "ocfs2.h"
36 36
37#include "alloc.h" 37#include "alloc.h"
38#include "blockcheck.h"
38#include "dlmglue.h" 39#include "dlmglue.h"
39#include "inode.h" 40#include "inode.h"
40#include "journal.h" 41#include "journal.h"
@@ -145,62 +146,183 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
145 return (u32)le16_to_cpu(cl->cl_cpg) * (u32)le16_to_cpu(cl->cl_bpc); 146 return (u32)le16_to_cpu(cl->cl_cpg) * (u32)le16_to_cpu(cl->cl_bpc);
146} 147}
147 148
148/* somewhat more expensive than our other checks, so use sparingly. */ 149#define do_error(fmt, ...) \
149int ocfs2_check_group_descriptor(struct super_block *sb, 150 do{ \
150 struct ocfs2_dinode *di, 151 if (clean_error) \
151 struct ocfs2_group_desc *gd) 152 mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \
153 else \
154 ocfs2_error(sb, fmt, ##__VA_ARGS__); \
155 } while (0)
156
157static int ocfs2_validate_gd_self(struct super_block *sb,
158 struct buffer_head *bh,
159 int clean_error)
152{ 160{
153 unsigned int max_bits; 161 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
154 162
155 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) { 163 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
156 OCFS2_RO_ON_INVALID_GROUP_DESC(sb, gd); 164 do_error("Group descriptor #%llu has bad signature %.*s",
157 return -EIO; 165 (unsigned long long)bh->b_blocknr, 7,
166 gd->bg_signature);
167 return -EINVAL;
158 } 168 }
159 169
170 if (le64_to_cpu(gd->bg_blkno) != bh->b_blocknr) {
171 do_error("Group descriptor #%llu has an invalid bg_blkno "
172 "of %llu",
173 (unsigned long long)bh->b_blocknr,
174 (unsigned long long)le64_to_cpu(gd->bg_blkno));
175 return -EINVAL;
176 }
177
178 if (le32_to_cpu(gd->bg_generation) != OCFS2_SB(sb)->fs_generation) {
179 do_error("Group descriptor #%llu has an invalid "
180 "fs_generation of #%u",
181 (unsigned long long)bh->b_blocknr,
182 le32_to_cpu(gd->bg_generation));
183 return -EINVAL;
184 }
185
186 if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) {
187 do_error("Group descriptor #%llu has bit count %u but "
188 "claims that %u are free",
189 (unsigned long long)bh->b_blocknr,
190 le16_to_cpu(gd->bg_bits),
191 le16_to_cpu(gd->bg_free_bits_count));
192 return -EINVAL;
193 }
194
195 if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) {
196 do_error("Group descriptor #%llu has bit count %u but "
197 "max bitmap bits of %u",
198 (unsigned long long)bh->b_blocknr,
199 le16_to_cpu(gd->bg_bits),
200 8 * le16_to_cpu(gd->bg_size));
201 return -EINVAL;
202 }
203
204 return 0;
205}
206
207static int ocfs2_validate_gd_parent(struct super_block *sb,
208 struct ocfs2_dinode *di,
209 struct buffer_head *bh,
210 int clean_error)
211{
212 unsigned int max_bits;
213 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
214
160 if (di->i_blkno != gd->bg_parent_dinode) { 215 if (di->i_blkno != gd->bg_parent_dinode) {
161 ocfs2_error(sb, "Group descriptor # %llu has bad parent " 216 do_error("Group descriptor #%llu has bad parent "
162 "pointer (%llu, expected %llu)", 217 "pointer (%llu, expected %llu)",
163 (unsigned long long)le64_to_cpu(gd->bg_blkno), 218 (unsigned long long)bh->b_blocknr,
164 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode), 219 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
165 (unsigned long long)le64_to_cpu(di->i_blkno)); 220 (unsigned long long)le64_to_cpu(di->i_blkno));
166 return -EIO; 221 return -EINVAL;
167 } 222 }
168 223
169 max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc); 224 max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
170 if (le16_to_cpu(gd->bg_bits) > max_bits) { 225 if (le16_to_cpu(gd->bg_bits) > max_bits) {
171 ocfs2_error(sb, "Group descriptor # %llu has bit count of %u", 226 do_error("Group descriptor #%llu has bit count of %u",
172 (unsigned long long)le64_to_cpu(gd->bg_blkno), 227 (unsigned long long)bh->b_blocknr,
173 le16_to_cpu(gd->bg_bits)); 228 le16_to_cpu(gd->bg_bits));
174 return -EIO; 229 return -EINVAL;
175 } 230 }
176 231
177 if (le16_to_cpu(gd->bg_chain) >= 232 if (le16_to_cpu(gd->bg_chain) >=
178 le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) { 233 le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
179 ocfs2_error(sb, "Group descriptor # %llu has bad chain %u", 234 do_error("Group descriptor #%llu has bad chain %u",
180 (unsigned long long)le64_to_cpu(gd->bg_blkno), 235 (unsigned long long)bh->b_blocknr,
181 le16_to_cpu(gd->bg_chain)); 236 le16_to_cpu(gd->bg_chain));
182 return -EIO; 237 return -EINVAL;
183 } 238 }
184 239
185 if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) { 240 return 0;
186 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but " 241}
187 "claims that %u are free",
188 (unsigned long long)le64_to_cpu(gd->bg_blkno),
189 le16_to_cpu(gd->bg_bits),
190 le16_to_cpu(gd->bg_free_bits_count));
191 return -EIO;
192 }
193 242
194 if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) { 243#undef do_error
195 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but " 244
196 "max bitmap bits of %u", 245/*
197 (unsigned long long)le64_to_cpu(gd->bg_blkno), 246 * This version only prints errors. It does not fail the filesystem, and
198 le16_to_cpu(gd->bg_bits), 247 * exists only for resize.
199 8 * le16_to_cpu(gd->bg_size)); 248 */
200 return -EIO; 249int ocfs2_check_group_descriptor(struct super_block *sb,
250 struct ocfs2_dinode *di,
251 struct buffer_head *bh)
252{
253 int rc;
254 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
255
256 BUG_ON(!buffer_uptodate(bh));
257
258 /*
259 * If the ecc fails, we return the error but otherwise
260 * leave the filesystem running. We know any error is
261 * local to this block.
262 */
263 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check);
264 if (rc) {
265 mlog(ML_ERROR,
266 "Checksum failed for group descriptor %llu\n",
267 (unsigned long long)bh->b_blocknr);
268 } else
269 rc = ocfs2_validate_gd_self(sb, bh, 1);
270 if (!rc)
271 rc = ocfs2_validate_gd_parent(sb, di, bh, 1);
272
273 return rc;
274}
275
276static int ocfs2_validate_group_descriptor(struct super_block *sb,
277 struct buffer_head *bh)
278{
279 int rc;
280 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
281
282 mlog(0, "Validating group descriptor %llu\n",
283 (unsigned long long)bh->b_blocknr);
284
285 BUG_ON(!buffer_uptodate(bh));
286
287 /*
288 * If the ecc fails, we return the error but otherwise
289 * leave the filesystem running. We know any error is
290 * local to this block.
291 */
292 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check);
293 if (rc)
294 return rc;
295
296 /*
297 * Errors after here are fatal.
298 */
299
300 return ocfs2_validate_gd_self(sb, bh, 0);
301}
302
303int ocfs2_read_group_descriptor(struct inode *inode, struct ocfs2_dinode *di,
304 u64 gd_blkno, struct buffer_head **bh)
305{
306 int rc;
307 struct buffer_head *tmp = *bh;
308
309 rc = ocfs2_read_block(inode, gd_blkno, &tmp,
310 ocfs2_validate_group_descriptor);
311 if (rc)
312 goto out;
313
314 rc = ocfs2_validate_gd_parent(inode->i_sb, di, tmp, 0);
315 if (rc) {
316 brelse(tmp);
317 goto out;
201 } 318 }
202 319
203 return 0; 320 /* If ocfs2_read_block() got us a new bh, pass it up. */
321 if (!*bh)
322 *bh = tmp;
323
324out:
325 return rc;
204} 326}
205 327
206static int ocfs2_block_group_fill(handle_t *handle, 328static int ocfs2_block_group_fill(handle_t *handle,
@@ -225,10 +347,10 @@ static int ocfs2_block_group_fill(handle_t *handle,
225 goto bail; 347 goto bail;
226 } 348 }
227 349
228 status = ocfs2_journal_access(handle, 350 status = ocfs2_journal_access_gd(handle,
229 alloc_inode, 351 alloc_inode,
230 bg_bh, 352 bg_bh,
231 OCFS2_JOURNAL_ACCESS_CREATE); 353 OCFS2_JOURNAL_ACCESS_CREATE);
232 if (status < 0) { 354 if (status < 0) {
233 mlog_errno(status); 355 mlog_errno(status);
234 goto bail; 356 goto bail;
@@ -358,8 +480,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
358 480
359 bg = (struct ocfs2_group_desc *) bg_bh->b_data; 481 bg = (struct ocfs2_group_desc *) bg_bh->b_data;
360 482
361 status = ocfs2_journal_access(handle, alloc_inode, 483 status = ocfs2_journal_access_di(handle, alloc_inode,
362 bh, OCFS2_JOURNAL_ACCESS_WRITE); 484 bh, OCFS2_JOURNAL_ACCESS_WRITE);
363 if (status < 0) { 485 if (status < 0) {
364 mlog_errno(status); 486 mlog_errno(status);
365 goto bail; 487 goto bail;
@@ -441,11 +563,11 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
441 ac->ac_alloc_slot = slot; 563 ac->ac_alloc_slot = slot;
442 564
443 fe = (struct ocfs2_dinode *) bh->b_data; 565 fe = (struct ocfs2_dinode *) bh->b_data;
444 if (!OCFS2_IS_VALID_DINODE(fe)) { 566
445 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); 567 /* The bh was validated by the inode read inside
446 status = -EIO; 568 * ocfs2_inode_lock(). Any corruption is a code bug. */
447 goto bail; 569 BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
448 } 570
449 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) { 571 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) {
450 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu", 572 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu",
451 (unsigned long long)le64_to_cpu(fe->i_blkno)); 573 (unsigned long long)le64_to_cpu(fe->i_blkno));
@@ -790,10 +912,9 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
790 int offset, start, found, status = 0; 912 int offset, start, found, status = 0;
791 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; 913 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
792 914
793 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { 915 /* Callers got this descriptor from
794 OCFS2_RO_ON_INVALID_GROUP_DESC(osb->sb, bg); 916 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
795 return -EIO; 917 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg));
796 }
797 918
798 found = start = best_offset = best_size = 0; 919 found = start = best_offset = best_size = 0;
799 bitmap = bg->bg_bitmap; 920 bitmap = bg->bg_bitmap;
@@ -858,11 +979,9 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle,
858 979
859 mlog_entry_void(); 980 mlog_entry_void();
860 981
861 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { 982 /* All callers get the descriptor via
862 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); 983 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
863 status = -EIO; 984 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg));
864 goto bail;
865 }
866 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); 985 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits);
867 986
868 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, 987 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off,
@@ -871,10 +990,10 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle,
871 if (ocfs2_is_cluster_bitmap(alloc_inode)) 990 if (ocfs2_is_cluster_bitmap(alloc_inode))
872 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 991 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
873 992
874 status = ocfs2_journal_access(handle, 993 status = ocfs2_journal_access_gd(handle,
875 alloc_inode, 994 alloc_inode,
876 group_bh, 995 group_bh,
877 journal_type); 996 journal_type);
878 if (status < 0) { 997 if (status < 0) {
879 mlog_errno(status); 998 mlog_errno(status);
880 goto bail; 999 goto bail;
@@ -931,21 +1050,10 @@ static int ocfs2_relink_block_group(handle_t *handle,
931 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; 1050 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
932 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data; 1051 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data;
933 1052
934 if (!OCFS2_IS_VALID_DINODE(fe)) { 1053 /* The caller got these descriptors from
935 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); 1054 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
936 status = -EIO; 1055 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg));
937 goto out; 1056 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(prev_bg));
938 }
939 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
940 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
941 status = -EIO;
942 goto out;
943 }
944 if (!OCFS2_IS_VALID_GROUP_DESC(prev_bg)) {
945 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, prev_bg);
946 status = -EIO;
947 goto out;
948 }
949 1057
950 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n", 1058 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n",
951 (unsigned long long)le64_to_cpu(fe->i_blkno), chain, 1059 (unsigned long long)le64_to_cpu(fe->i_blkno), chain,
@@ -956,8 +1064,8 @@ static int ocfs2_relink_block_group(handle_t *handle,
956 bg_ptr = le64_to_cpu(bg->bg_next_group); 1064 bg_ptr = le64_to_cpu(bg->bg_next_group);
957 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); 1065 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group);
958 1066
959 status = ocfs2_journal_access(handle, alloc_inode, prev_bg_bh, 1067 status = ocfs2_journal_access_gd(handle, alloc_inode, prev_bg_bh,
960 OCFS2_JOURNAL_ACCESS_WRITE); 1068 OCFS2_JOURNAL_ACCESS_WRITE);
961 if (status < 0) { 1069 if (status < 0) {
962 mlog_errno(status); 1070 mlog_errno(status);
963 goto out_rollback; 1071 goto out_rollback;
@@ -971,8 +1079,8 @@ static int ocfs2_relink_block_group(handle_t *handle,
971 goto out_rollback; 1079 goto out_rollback;
972 } 1080 }
973 1081
974 status = ocfs2_journal_access(handle, alloc_inode, bg_bh, 1082 status = ocfs2_journal_access_gd(handle, alloc_inode, bg_bh,
975 OCFS2_JOURNAL_ACCESS_WRITE); 1083 OCFS2_JOURNAL_ACCESS_WRITE);
976 if (status < 0) { 1084 if (status < 0) {
977 mlog_errno(status); 1085 mlog_errno(status);
978 goto out_rollback; 1086 goto out_rollback;
@@ -986,8 +1094,8 @@ static int ocfs2_relink_block_group(handle_t *handle,
986 goto out_rollback; 1094 goto out_rollback;
987 } 1095 }
988 1096
989 status = ocfs2_journal_access(handle, alloc_inode, fe_bh, 1097 status = ocfs2_journal_access_di(handle, alloc_inode, fe_bh,
990 OCFS2_JOURNAL_ACCESS_WRITE); 1098 OCFS2_JOURNAL_ACCESS_WRITE);
991 if (status < 0) { 1099 if (status < 0) {
992 mlog_errno(status); 1100 mlog_errno(status);
993 goto out_rollback; 1101 goto out_rollback;
@@ -1008,7 +1116,7 @@ out_rollback:
1008 bg->bg_next_group = cpu_to_le64(bg_ptr); 1116 bg->bg_next_group = cpu_to_le64(bg_ptr);
1009 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); 1117 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
1010 } 1118 }
1011out: 1119
1012 mlog_exit(status); 1120 mlog_exit(status);
1013 return status; 1121 return status;
1014} 1122}
@@ -1138,8 +1246,8 @@ static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1138 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; 1246 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
1139 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain; 1247 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain;
1140 1248
1141 ret = ocfs2_journal_access(handle, inode, di_bh, 1249 ret = ocfs2_journal_access_di(handle, inode, di_bh,
1142 OCFS2_JOURNAL_ACCESS_WRITE); 1250 OCFS2_JOURNAL_ACCESS_WRITE);
1143 if (ret < 0) { 1251 if (ret < 0) {
1144 mlog_errno(ret); 1252 mlog_errno(ret);
1145 goto out; 1253 goto out;
@@ -1170,21 +1278,17 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1170 u16 found; 1278 u16 found;
1171 struct buffer_head *group_bh = NULL; 1279 struct buffer_head *group_bh = NULL;
1172 struct ocfs2_group_desc *gd; 1280 struct ocfs2_group_desc *gd;
1281 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data;
1173 struct inode *alloc_inode = ac->ac_inode; 1282 struct inode *alloc_inode = ac->ac_inode;
1174 1283
1175 ret = ocfs2_read_block(alloc_inode, gd_blkno, &group_bh); 1284 ret = ocfs2_read_group_descriptor(alloc_inode, di, gd_blkno,
1285 &group_bh);
1176 if (ret < 0) { 1286 if (ret < 0) {
1177 mlog_errno(ret); 1287 mlog_errno(ret);
1178 return ret; 1288 return ret;
1179 } 1289 }
1180 1290
1181 gd = (struct ocfs2_group_desc *) group_bh->b_data; 1291 gd = (struct ocfs2_group_desc *) group_bh->b_data;
1182 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
1183 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, gd);
1184 ret = -EIO;
1185 goto out;
1186 }
1187
1188 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, 1292 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits,
1189 ac->ac_max_block, bit_off, &found); 1293 ac->ac_max_block, bit_off, &found);
1190 if (ret < 0) { 1294 if (ret < 0) {
@@ -1241,19 +1345,14 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1241 bits_wanted, chain, 1345 bits_wanted, chain,
1242 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno); 1346 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno);
1243 1347
1244 status = ocfs2_read_block(alloc_inode, 1348 status = ocfs2_read_group_descriptor(alloc_inode, fe,
1245 le64_to_cpu(cl->cl_recs[chain].c_blkno), 1349 le64_to_cpu(cl->cl_recs[chain].c_blkno),
1246 &group_bh); 1350 &group_bh);
1247 if (status < 0) { 1351 if (status < 0) {
1248 mlog_errno(status); 1352 mlog_errno(status);
1249 goto bail; 1353 goto bail;
1250 } 1354 }
1251 bg = (struct ocfs2_group_desc *) group_bh->b_data; 1355 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1252 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1253 if (status) {
1254 mlog_errno(status);
1255 goto bail;
1256 }
1257 1356
1258 status = -ENOSPC; 1357 status = -ENOSPC;
1259 /* for now, the chain search is a bit simplistic. We just use 1358 /* for now, the chain search is a bit simplistic. We just use
@@ -1271,18 +1370,13 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1271 next_group = le64_to_cpu(bg->bg_next_group); 1370 next_group = le64_to_cpu(bg->bg_next_group);
1272 prev_group_bh = group_bh; 1371 prev_group_bh = group_bh;
1273 group_bh = NULL; 1372 group_bh = NULL;
1274 status = ocfs2_read_block(alloc_inode, 1373 status = ocfs2_read_group_descriptor(alloc_inode, fe,
1275 next_group, &group_bh); 1374 next_group, &group_bh);
1276 if (status < 0) { 1375 if (status < 0) {
1277 mlog_errno(status); 1376 mlog_errno(status);
1278 goto bail; 1377 goto bail;
1279 } 1378 }
1280 bg = (struct ocfs2_group_desc *) group_bh->b_data; 1379 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1281 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1282 if (status) {
1283 mlog_errno(status);
1284 goto bail;
1285 }
1286 } 1380 }
1287 if (status < 0) { 1381 if (status < 0) {
1288 if (status != -ENOSPC) 1382 if (status != -ENOSPC)
@@ -1324,10 +1418,10 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1324 1418
1325 /* Ok, claim our bits now: set the info on dinode, chainlist 1419 /* Ok, claim our bits now: set the info on dinode, chainlist
1326 * and then the group */ 1420 * and then the group */
1327 status = ocfs2_journal_access(handle, 1421 status = ocfs2_journal_access_di(handle,
1328 alloc_inode, 1422 alloc_inode,
1329 ac->ac_bh, 1423 ac->ac_bh,
1330 OCFS2_JOURNAL_ACCESS_WRITE); 1424 OCFS2_JOURNAL_ACCESS_WRITE);
1331 if (status < 0) { 1425 if (status < 0) {
1332 mlog_errno(status); 1426 mlog_errno(status);
1333 goto bail; 1427 goto bail;
@@ -1392,11 +1486,11 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1392 BUG_ON(!ac->ac_bh); 1486 BUG_ON(!ac->ac_bh);
1393 1487
1394 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; 1488 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data;
1395 if (!OCFS2_IS_VALID_DINODE(fe)) { 1489
1396 OCFS2_RO_ON_INVALID_DINODE(osb->sb, fe); 1490 /* The bh was validated by the inode read during
1397 status = -EIO; 1491 * ocfs2_reserve_suballoc_bits(). Any corruption is a code bug. */
1398 goto bail; 1492 BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
1399 } 1493
1400 if (le32_to_cpu(fe->id1.bitmap1.i_used) >= 1494 if (le32_to_cpu(fe->id1.bitmap1.i_used) >=
1401 le32_to_cpu(fe->id1.bitmap1.i_total)) { 1495 le32_to_cpu(fe->id1.bitmap1.i_total)) {
1402 ocfs2_error(osb->sb, "Chain allocator dinode %llu has %u used " 1496 ocfs2_error(osb->sb, "Chain allocator dinode %llu has %u used "
@@ -1725,19 +1819,17 @@ static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1725 1819
1726 mlog_entry_void(); 1820 mlog_entry_void();
1727 1821
1728 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { 1822 /* The caller got this descriptor from
1729 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); 1823 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
1730 status = -EIO; 1824 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg));
1731 goto bail;
1732 }
1733 1825
1734 mlog(0, "off = %u, num = %u\n", bit_off, num_bits); 1826 mlog(0, "off = %u, num = %u\n", bit_off, num_bits);
1735 1827
1736 if (ocfs2_is_cluster_bitmap(alloc_inode)) 1828 if (ocfs2_is_cluster_bitmap(alloc_inode))
1737 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 1829 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
1738 1830
1739 status = ocfs2_journal_access(handle, alloc_inode, group_bh, 1831 status = ocfs2_journal_access_gd(handle, alloc_inode, group_bh,
1740 journal_type); 1832 journal_type);
1741 if (status < 0) { 1833 if (status < 0) {
1742 mlog_errno(status); 1834 mlog_errno(status);
1743 goto bail; 1835 goto bail;
@@ -1782,29 +1874,26 @@ int ocfs2_free_suballoc_bits(handle_t *handle,
1782 1874
1783 mlog_entry_void(); 1875 mlog_entry_void();
1784 1876
1785 if (!OCFS2_IS_VALID_DINODE(fe)) { 1877 /* The alloc_bh comes from ocfs2_free_dinode() or
1786 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); 1878 * ocfs2_free_clusters(). The callers have all locked the
1787 status = -EIO; 1879 * allocator and gotten alloc_bh from the lock call. This
1788 goto bail; 1880 * validates the dinode buffer. Any corruption that has happended
1789 } 1881 * is a code bug. */
1882 BUG_ON(!OCFS2_IS_VALID_DINODE(fe));
1790 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); 1883 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl));
1791 1884
1792 mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n", 1885 mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n",
1793 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count, 1886 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count,
1794 (unsigned long long)bg_blkno, start_bit); 1887 (unsigned long long)bg_blkno, start_bit);
1795 1888
1796 status = ocfs2_read_block(alloc_inode, bg_blkno, &group_bh); 1889 status = ocfs2_read_group_descriptor(alloc_inode, fe, bg_blkno,
1890 &group_bh);
1797 if (status < 0) { 1891 if (status < 0) {
1798 mlog_errno(status); 1892 mlog_errno(status);
1799 goto bail; 1893 goto bail;
1800 } 1894 }
1801
1802 group = (struct ocfs2_group_desc *) group_bh->b_data; 1895 group = (struct ocfs2_group_desc *) group_bh->b_data;
1803 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, group); 1896
1804 if (status) {
1805 mlog_errno(status);
1806 goto bail;
1807 }
1808 BUG_ON((count + start_bit) > le16_to_cpu(group->bg_bits)); 1897 BUG_ON((count + start_bit) > le16_to_cpu(group->bg_bits));
1809 1898
1810 status = ocfs2_block_group_clear_bits(handle, alloc_inode, 1899 status = ocfs2_block_group_clear_bits(handle, alloc_inode,
@@ -1815,8 +1904,8 @@ int ocfs2_free_suballoc_bits(handle_t *handle,
1815 goto bail; 1904 goto bail;
1816 } 1905 }
1817 1906
1818 status = ocfs2_journal_access(handle, alloc_inode, alloc_bh, 1907 status = ocfs2_journal_access_di(handle, alloc_inode, alloc_bh,
1819 OCFS2_JOURNAL_ACCESS_WRITE); 1908 OCFS2_JOURNAL_ACCESS_WRITE);
1820 if (status < 0) { 1909 if (status < 0) {
1821 mlog_errno(status); 1910 mlog_errno(status);
1822 goto bail; 1911 goto bail;
diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h
index 4df159d8f450..e3c13c77f9e8 100644
--- a/fs/ocfs2/suballoc.h
+++ b/fs/ocfs2/suballoc.h
@@ -164,10 +164,24 @@ void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac);
164 * and return that block offset. */ 164 * and return that block offset. */
165u64 ocfs2_which_cluster_group(struct inode *inode, u32 cluster); 165u64 ocfs2_which_cluster_group(struct inode *inode, u32 cluster);
166 166
167/* somewhat more expensive than our other checks, so use sparingly. */ 167/*
168 * By default, ocfs2_read_group_descriptor() calls ocfs2_error() when it
169 * finds a problem. A caller that wants to check a group descriptor
170 * without going readonly should read the block with ocfs2_read_block[s]()
171 * and then checking it with this function. This is only resize, really.
172 * Everyone else should be using ocfs2_read_group_descriptor().
173 */
168int ocfs2_check_group_descriptor(struct super_block *sb, 174int ocfs2_check_group_descriptor(struct super_block *sb,
169 struct ocfs2_dinode *di, 175 struct ocfs2_dinode *di,
170 struct ocfs2_group_desc *gd); 176 struct buffer_head *bh);
177/*
178 * Read a group descriptor block into *bh. If *bh is NULL, a bh will be
179 * allocated. This is a cached read. The descriptor will be validated with
180 * ocfs2_validate_group_descriptor().
181 */
182int ocfs2_read_group_descriptor(struct inode *inode, struct ocfs2_dinode *di,
183 u64 gd_blkno, struct buffer_head **bh);
184
171int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_extent_tree *et, 185int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_extent_tree *et,
172 u32 clusters_to_add, u32 extents_to_split, 186 u32 clusters_to_add, u32 extents_to_split,
173 struct ocfs2_alloc_context **data_ac, 187 struct ocfs2_alloc_context **data_ac,
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 304b63ac78cf..43ed11345b59 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -41,6 +41,7 @@
41#include <linux/debugfs.h> 41#include <linux/debugfs.h>
42#include <linux/mount.h> 42#include <linux/mount.h>
43#include <linux/seq_file.h> 43#include <linux/seq_file.h>
44#include <linux/quotaops.h>
44 45
45#define MLOG_MASK_PREFIX ML_SUPER 46#define MLOG_MASK_PREFIX ML_SUPER
46#include <cluster/masklog.h> 47#include <cluster/masklog.h>
@@ -51,6 +52,7 @@
51#include "ocfs1_fs_compat.h" 52#include "ocfs1_fs_compat.h"
52 53
53#include "alloc.h" 54#include "alloc.h"
55#include "blockcheck.h"
54#include "dlmglue.h" 56#include "dlmglue.h"
55#include "export.h" 57#include "export.h"
56#include "extent_map.h" 58#include "extent_map.h"
@@ -65,10 +67,13 @@
65#include "uptodate.h" 67#include "uptodate.h"
66#include "ver.h" 68#include "ver.h"
67#include "xattr.h" 69#include "xattr.h"
70#include "quota.h"
68 71
69#include "buffer_head_io.h" 72#include "buffer_head_io.h"
70 73
71static struct kmem_cache *ocfs2_inode_cachep = NULL; 74static struct kmem_cache *ocfs2_inode_cachep = NULL;
75struct kmem_cache *ocfs2_dquot_cachep;
76struct kmem_cache *ocfs2_qf_chunk_cachep;
72 77
73/* OCFS2 needs to schedule several differnt types of work which 78/* OCFS2 needs to schedule several differnt types of work which
74 * require cluster locking, disk I/O, recovery waits, etc. Since these 79 * require cluster locking, disk I/O, recovery waits, etc. Since these
@@ -124,6 +129,9 @@ static int ocfs2_get_sector(struct super_block *sb,
124static void ocfs2_write_super(struct super_block *sb); 129static void ocfs2_write_super(struct super_block *sb);
125static struct inode *ocfs2_alloc_inode(struct super_block *sb); 130static struct inode *ocfs2_alloc_inode(struct super_block *sb);
126static void ocfs2_destroy_inode(struct inode *inode); 131static void ocfs2_destroy_inode(struct inode *inode);
132static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend);
133static int ocfs2_enable_quotas(struct ocfs2_super *osb);
134static void ocfs2_disable_quotas(struct ocfs2_super *osb);
127 135
128static const struct super_operations ocfs2_sops = { 136static const struct super_operations ocfs2_sops = {
129 .statfs = ocfs2_statfs, 137 .statfs = ocfs2_statfs,
@@ -137,6 +145,8 @@ static const struct super_operations ocfs2_sops = {
137 .put_super = ocfs2_put_super, 145 .put_super = ocfs2_put_super,
138 .remount_fs = ocfs2_remount, 146 .remount_fs = ocfs2_remount,
139 .show_options = ocfs2_show_options, 147 .show_options = ocfs2_show_options,
148 .quota_read = ocfs2_quota_read,
149 .quota_write = ocfs2_quota_write,
140}; 150};
141 151
142enum { 152enum {
@@ -158,6 +168,10 @@ enum {
158 Opt_user_xattr, 168 Opt_user_xattr,
159 Opt_nouser_xattr, 169 Opt_nouser_xattr,
160 Opt_inode64, 170 Opt_inode64,
171 Opt_acl,
172 Opt_noacl,
173 Opt_usrquota,
174 Opt_grpquota,
161 Opt_err, 175 Opt_err,
162}; 176};
163 177
@@ -180,6 +194,10 @@ static const match_table_t tokens = {
180 {Opt_user_xattr, "user_xattr"}, 194 {Opt_user_xattr, "user_xattr"},
181 {Opt_nouser_xattr, "nouser_xattr"}, 195 {Opt_nouser_xattr, "nouser_xattr"},
182 {Opt_inode64, "inode64"}, 196 {Opt_inode64, "inode64"},
197 {Opt_acl, "acl"},
198 {Opt_noacl, "noacl"},
199 {Opt_usrquota, "usrquota"},
200 {Opt_grpquota, "grpquota"},
183 {Opt_err, NULL} 201 {Opt_err, NULL}
184}; 202};
185 203
@@ -221,6 +239,19 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait)
221 return 0; 239 return 0;
222} 240}
223 241
242static int ocfs2_need_system_inode(struct ocfs2_super *osb, int ino)
243{
244 if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA)
245 && (ino == USER_QUOTA_SYSTEM_INODE
246 || ino == LOCAL_USER_QUOTA_SYSTEM_INODE))
247 return 0;
248 if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
249 && (ino == GROUP_QUOTA_SYSTEM_INODE
250 || ino == LOCAL_GROUP_QUOTA_SYSTEM_INODE))
251 return 0;
252 return 1;
253}
254
224static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) 255static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb)
225{ 256{
226 struct inode *new = NULL; 257 struct inode *new = NULL;
@@ -247,6 +278,8 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb)
247 278
248 for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE; 279 for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE;
249 i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) { 280 i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) {
281 if (!ocfs2_need_system_inode(osb, i))
282 continue;
250 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); 283 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
251 if (!new) { 284 if (!new) {
252 ocfs2_release_system_inodes(osb); 285 ocfs2_release_system_inodes(osb);
@@ -277,6 +310,8 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb)
277 for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; 310 for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1;
278 i < NUM_SYSTEM_INODES; 311 i < NUM_SYSTEM_INODES;
279 i++) { 312 i++) {
313 if (!ocfs2_need_system_inode(osb, i))
314 continue;
280 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); 315 new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
281 if (!new) { 316 if (!new) {
282 ocfs2_release_system_inodes(osb); 317 ocfs2_release_system_inodes(osb);
@@ -426,6 +461,12 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
426 461
427 /* We're going to/from readonly mode. */ 462 /* We're going to/from readonly mode. */
428 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { 463 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
464 /* Disable quota accounting before remounting RO */
465 if (*flags & MS_RDONLY) {
466 ret = ocfs2_susp_quotas(osb, 0);
467 if (ret < 0)
468 goto out;
469 }
429 /* Lock here so the check of HARD_RO and the potential 470 /* Lock here so the check of HARD_RO and the potential
430 * setting of SOFT_RO is atomic. */ 471 * setting of SOFT_RO is atomic. */
431 spin_lock(&osb->osb_lock); 472 spin_lock(&osb->osb_lock);
@@ -461,11 +502,28 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
461 } 502 }
462unlock_osb: 503unlock_osb:
463 spin_unlock(&osb->osb_lock); 504 spin_unlock(&osb->osb_lock);
505 /* Enable quota accounting after remounting RW */
506 if (!ret && !(*flags & MS_RDONLY)) {
507 if (sb_any_quota_suspended(sb))
508 ret = ocfs2_susp_quotas(osb, 1);
509 else
510 ret = ocfs2_enable_quotas(osb);
511 if (ret < 0) {
512 /* Return back changes... */
513 spin_lock(&osb->osb_lock);
514 sb->s_flags |= MS_RDONLY;
515 osb->osb_flags |= OCFS2_OSB_SOFT_RO;
516 spin_unlock(&osb->osb_lock);
517 goto out;
518 }
519 }
464 } 520 }
465 521
466 if (!ret) { 522 if (!ret) {
467 /* Only save off the new mount options in case of a successful 523 /* Only save off the new mount options in case of a successful
468 * remount. */ 524 * remount. */
525 if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR))
526 parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
469 osb->s_mount_opt = parsed_options.mount_opt; 527 osb->s_mount_opt = parsed_options.mount_opt;
470 osb->s_atime_quantum = parsed_options.atime_quantum; 528 osb->s_atime_quantum = parsed_options.atime_quantum;
471 osb->preferred_slot = parsed_options.slot; 529 osb->preferred_slot = parsed_options.slot;
@@ -619,6 +677,131 @@ static int ocfs2_verify_userspace_stack(struct ocfs2_super *osb,
619 return 0; 677 return 0;
620} 678}
621 679
680static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
681{
682 int type;
683 struct super_block *sb = osb->sb;
684 unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
685 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
686 int status = 0;
687
688 for (type = 0; type < MAXQUOTAS; type++) {
689 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
690 continue;
691 if (unsuspend)
692 status = vfs_quota_enable(
693 sb_dqopt(sb)->files[type],
694 type, QFMT_OCFS2,
695 DQUOT_SUSPENDED);
696 else
697 status = vfs_quota_disable(sb, type,
698 DQUOT_SUSPENDED);
699 if (status < 0)
700 break;
701 }
702 if (status < 0)
703 mlog(ML_ERROR, "Failed to suspend/unsuspend quotas on "
704 "remount (error = %d).\n", status);
705 return status;
706}
707
708static int ocfs2_enable_quotas(struct ocfs2_super *osb)
709{
710 struct inode *inode[MAXQUOTAS] = { NULL, NULL };
711 struct super_block *sb = osb->sb;
712 unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
713 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
714 unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
715 LOCAL_GROUP_QUOTA_SYSTEM_INODE };
716 int status;
717 int type;
718
719 sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NEGATIVE_USAGE;
720 for (type = 0; type < MAXQUOTAS; type++) {
721 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
722 continue;
723 inode[type] = ocfs2_get_system_file_inode(osb, ino[type],
724 osb->slot_num);
725 if (!inode[type]) {
726 status = -ENOENT;
727 goto out_quota_off;
728 }
729 status = vfs_quota_enable(inode[type], type, QFMT_OCFS2,
730 DQUOT_USAGE_ENABLED);
731 if (status < 0)
732 goto out_quota_off;
733 }
734
735 for (type = 0; type < MAXQUOTAS; type++)
736 iput(inode[type]);
737 return 0;
738out_quota_off:
739 ocfs2_disable_quotas(osb);
740 for (type = 0; type < MAXQUOTAS; type++)
741 iput(inode[type]);
742 mlog_errno(status);
743 return status;
744}
745
746static void ocfs2_disable_quotas(struct ocfs2_super *osb)
747{
748 int type;
749 struct inode *inode;
750 struct super_block *sb = osb->sb;
751
752 /* We mostly ignore errors in this function because there's not much
753 * we can do when we see them */
754 for (type = 0; type < MAXQUOTAS; type++) {
755 if (!sb_has_quota_loaded(sb, type))
756 continue;
757 inode = igrab(sb->s_dquot.files[type]);
758 /* Turn off quotas. This will remove all dquot structures from
759 * memory and so they will be automatically synced to global
760 * quota files */
761 vfs_quota_disable(sb, type, DQUOT_USAGE_ENABLED |
762 DQUOT_LIMITS_ENABLED);
763 if (!inode)
764 continue;
765 iput(inode);
766 }
767}
768
769/* Handle quota on quotactl */
770static int ocfs2_quota_on(struct super_block *sb, int type, int format_id,
771 char *path, int remount)
772{
773 unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
774 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
775
776 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
777 return -EINVAL;
778
779 if (remount)
780 return 0; /* Just ignore it has been handled in
781 * ocfs2_remount() */
782 return vfs_quota_enable(sb_dqopt(sb)->files[type], type,
783 format_id, DQUOT_LIMITS_ENABLED);
784}
785
786/* Handle quota off quotactl */
787static int ocfs2_quota_off(struct super_block *sb, int type, int remount)
788{
789 if (remount)
790 return 0; /* Ignore now and handle later in
791 * ocfs2_remount() */
792 return vfs_quota_disable(sb, type, DQUOT_LIMITS_ENABLED);
793}
794
795static struct quotactl_ops ocfs2_quotactl_ops = {
796 .quota_on = ocfs2_quota_on,
797 .quota_off = ocfs2_quota_off,
798 .quota_sync = vfs_quota_sync,
799 .get_info = vfs_get_dqinfo,
800 .set_info = vfs_set_dqinfo,
801 .get_dqblk = vfs_get_dqblk,
802 .set_dqblk = vfs_set_dqblk,
803};
804
622static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) 805static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
623{ 806{
624 struct dentry *root; 807 struct dentry *root;
@@ -651,12 +834,32 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
651 } 834 }
652 brelse(bh); 835 brelse(bh);
653 bh = NULL; 836 bh = NULL;
837
838 if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR))
839 parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
840
654 osb->s_mount_opt = parsed_options.mount_opt; 841 osb->s_mount_opt = parsed_options.mount_opt;
655 osb->s_atime_quantum = parsed_options.atime_quantum; 842 osb->s_atime_quantum = parsed_options.atime_quantum;
656 osb->preferred_slot = parsed_options.slot; 843 osb->preferred_slot = parsed_options.slot;
657 osb->osb_commit_interval = parsed_options.commit_interval; 844 osb->osb_commit_interval = parsed_options.commit_interval;
658 osb->local_alloc_default_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt); 845 osb->local_alloc_default_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt);
659 osb->local_alloc_bits = osb->local_alloc_default_bits; 846 osb->local_alloc_bits = osb->local_alloc_default_bits;
847 if (osb->s_mount_opt & OCFS2_MOUNT_USRQUOTA &&
848 !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
849 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
850 status = -EINVAL;
851 mlog(ML_ERROR, "User quotas were requested, but this "
852 "filesystem does not have the feature enabled.\n");
853 goto read_super_error;
854 }
855 if (osb->s_mount_opt & OCFS2_MOUNT_GRPQUOTA &&
856 !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
857 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
858 status = -EINVAL;
859 mlog(ML_ERROR, "Group quotas were requested, but this "
860 "filesystem does not have the feature enabled.\n");
861 goto read_super_error;
862 }
660 863
661 status = ocfs2_verify_userspace_stack(osb, &parsed_options); 864 status = ocfs2_verify_userspace_stack(osb, &parsed_options);
662 if (status) 865 if (status)
@@ -664,6 +867,9 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
664 867
665 sb->s_magic = OCFS2_SUPER_MAGIC; 868 sb->s_magic = OCFS2_SUPER_MAGIC;
666 869
870 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
871 ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
872
667 /* Hard readonly mode only if: bdev_read_only, MS_RDONLY, 873 /* Hard readonly mode only if: bdev_read_only, MS_RDONLY,
668 * heartbeat=none */ 874 * heartbeat=none */
669 if (bdev_read_only(sb->s_bdev)) { 875 if (bdev_read_only(sb->s_bdev)) {
@@ -758,6 +964,28 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
758 atomic_set(&osb->vol_state, VOLUME_MOUNTED); 964 atomic_set(&osb->vol_state, VOLUME_MOUNTED);
759 wake_up(&osb->osb_mount_event); 965 wake_up(&osb->osb_mount_event);
760 966
967 /* Now we can initialize quotas because we can afford to wait
968 * for cluster locks recovery now. That also means that truncation
969 * log recovery can happen but that waits for proper quota setup */
970 if (!(sb->s_flags & MS_RDONLY)) {
971 status = ocfs2_enable_quotas(osb);
972 if (status < 0) {
973 /* We have to err-out specially here because
974 * s_root is already set */
975 mlog_errno(status);
976 atomic_set(&osb->vol_state, VOLUME_DISABLED);
977 wake_up(&osb->osb_mount_event);
978 mlog_exit(status);
979 return status;
980 }
981 }
982
983 ocfs2_complete_quota_recovery(osb);
984
985 /* Now we wake up again for processes waiting for quotas */
986 atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS);
987 wake_up(&osb->osb_mount_event);
988
761 mlog_exit(status); 989 mlog_exit(status);
762 return status; 990 return status;
763 991
@@ -945,6 +1173,41 @@ static int ocfs2_parse_options(struct super_block *sb,
945 case Opt_inode64: 1173 case Opt_inode64:
946 mopt->mount_opt |= OCFS2_MOUNT_INODE64; 1174 mopt->mount_opt |= OCFS2_MOUNT_INODE64;
947 break; 1175 break;
1176 case Opt_usrquota:
1177 /* We check only on remount, otherwise features
1178 * aren't yet initialized. */
1179 if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
1180 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
1181 mlog(ML_ERROR, "User quota requested but "
1182 "filesystem feature is not set\n");
1183 status = 0;
1184 goto bail;
1185 }
1186 mopt->mount_opt |= OCFS2_MOUNT_USRQUOTA;
1187 break;
1188 case Opt_grpquota:
1189 if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
1190 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
1191 mlog(ML_ERROR, "Group quota requested but "
1192 "filesystem feature is not set\n");
1193 status = 0;
1194 goto bail;
1195 }
1196 mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA;
1197 break;
1198#ifdef CONFIG_OCFS2_FS_POSIX_ACL
1199 case Opt_acl:
1200 mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL;
1201 break;
1202 case Opt_noacl:
1203 mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
1204 break;
1205#else
1206 case Opt_acl:
1207 case Opt_noacl:
1208 printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
1209 break;
1210#endif
948 default: 1211 default:
949 mlog(ML_ERROR, 1212 mlog(ML_ERROR,
950 "Unrecognized mount option \"%s\" " 1213 "Unrecognized mount option \"%s\" "
@@ -1008,6 +1271,10 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
1008 if (osb->osb_cluster_stack[0]) 1271 if (osb->osb_cluster_stack[0])
1009 seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN, 1272 seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN,
1010 osb->osb_cluster_stack); 1273 osb->osb_cluster_stack);
1274 if (opts & OCFS2_MOUNT_USRQUOTA)
1275 seq_printf(s, ",usrquota");
1276 if (opts & OCFS2_MOUNT_GRPQUOTA)
1277 seq_printf(s, ",grpquota");
1011 1278
1012 if (opts & OCFS2_MOUNT_NOUSERXATTR) 1279 if (opts & OCFS2_MOUNT_NOUSERXATTR)
1013 seq_printf(s, ",nouser_xattr"); 1280 seq_printf(s, ",nouser_xattr");
@@ -1017,6 +1284,13 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
1017 if (opts & OCFS2_MOUNT_INODE64) 1284 if (opts & OCFS2_MOUNT_INODE64)
1018 seq_printf(s, ",inode64"); 1285 seq_printf(s, ",inode64");
1019 1286
1287#ifdef CONFIG_OCFS2_FS_POSIX_ACL
1288 if (opts & OCFS2_MOUNT_POSIX_ACL)
1289 seq_printf(s, ",acl");
1290 else
1291 seq_printf(s, ",noacl");
1292#endif
1293
1020 return 0; 1294 return 0;
1021} 1295}
1022 1296
@@ -1052,10 +1326,16 @@ static int __init ocfs2_init(void)
1052 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); 1326 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
1053 } 1327 }
1054 1328
1329 status = ocfs2_quota_setup();
1330 if (status)
1331 goto leave;
1332
1055 ocfs2_set_locking_protocol(); 1333 ocfs2_set_locking_protocol();
1056 1334
1335 status = register_quota_format(&ocfs2_quota_format);
1057leave: 1336leave:
1058 if (status < 0) { 1337 if (status < 0) {
1338 ocfs2_quota_shutdown();
1059 ocfs2_free_mem_caches(); 1339 ocfs2_free_mem_caches();
1060 exit_ocfs2_uptodate_cache(); 1340 exit_ocfs2_uptodate_cache();
1061 } 1341 }
@@ -1072,11 +1352,15 @@ static void __exit ocfs2_exit(void)
1072{ 1352{
1073 mlog_entry_void(); 1353 mlog_entry_void();
1074 1354
1355 ocfs2_quota_shutdown();
1356
1075 if (ocfs2_wq) { 1357 if (ocfs2_wq) {
1076 flush_workqueue(ocfs2_wq); 1358 flush_workqueue(ocfs2_wq);
1077 destroy_workqueue(ocfs2_wq); 1359 destroy_workqueue(ocfs2_wq);
1078 } 1360 }
1079 1361
1362 unregister_quota_format(&ocfs2_quota_format);
1363
1080 debugfs_remove(ocfs2_debugfs_root); 1364 debugfs_remove(ocfs2_debugfs_root);
1081 1365
1082 ocfs2_free_mem_caches(); 1366 ocfs2_free_mem_caches();
@@ -1192,8 +1476,27 @@ static int ocfs2_initialize_mem_caches(void)
1192 (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| 1476 (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
1193 SLAB_MEM_SPREAD), 1477 SLAB_MEM_SPREAD),
1194 ocfs2_inode_init_once); 1478 ocfs2_inode_init_once);
1195 if (!ocfs2_inode_cachep) 1479 ocfs2_dquot_cachep = kmem_cache_create("ocfs2_dquot_cache",
1480 sizeof(struct ocfs2_dquot),
1481 0,
1482 (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
1483 SLAB_MEM_SPREAD),
1484 NULL);
1485 ocfs2_qf_chunk_cachep = kmem_cache_create("ocfs2_qf_chunk_cache",
1486 sizeof(struct ocfs2_quota_chunk),
1487 0,
1488 (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD),
1489 NULL);
1490 if (!ocfs2_inode_cachep || !ocfs2_dquot_cachep ||
1491 !ocfs2_qf_chunk_cachep) {
1492 if (ocfs2_inode_cachep)
1493 kmem_cache_destroy(ocfs2_inode_cachep);
1494 if (ocfs2_dquot_cachep)
1495 kmem_cache_destroy(ocfs2_dquot_cachep);
1496 if (ocfs2_qf_chunk_cachep)
1497 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1196 return -ENOMEM; 1498 return -ENOMEM;
1499 }
1197 1500
1198 return 0; 1501 return 0;
1199} 1502}
@@ -1202,8 +1505,15 @@ static void ocfs2_free_mem_caches(void)
1202{ 1505{
1203 if (ocfs2_inode_cachep) 1506 if (ocfs2_inode_cachep)
1204 kmem_cache_destroy(ocfs2_inode_cachep); 1507 kmem_cache_destroy(ocfs2_inode_cachep);
1205
1206 ocfs2_inode_cachep = NULL; 1508 ocfs2_inode_cachep = NULL;
1509
1510 if (ocfs2_dquot_cachep)
1511 kmem_cache_destroy(ocfs2_dquot_cachep);
1512 ocfs2_dquot_cachep = NULL;
1513
1514 if (ocfs2_qf_chunk_cachep)
1515 kmem_cache_destroy(ocfs2_qf_chunk_cachep);
1516 ocfs2_qf_chunk_cachep = NULL;
1207} 1517}
1208 1518
1209static int ocfs2_get_sector(struct super_block *sb, 1519static int ocfs2_get_sector(struct super_block *sb,
@@ -1303,6 +1613,8 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1303 osb = OCFS2_SB(sb); 1613 osb = OCFS2_SB(sb);
1304 BUG_ON(!osb); 1614 BUG_ON(!osb);
1305 1615
1616 ocfs2_disable_quotas(osb);
1617
1306 ocfs2_shutdown_local_alloc(osb); 1618 ocfs2_shutdown_local_alloc(osb);
1307 1619
1308 ocfs2_truncate_log_shutdown(osb); 1620 ocfs2_truncate_log_shutdown(osb);
@@ -1413,6 +1725,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1413 sb->s_fs_info = osb; 1725 sb->s_fs_info = osb;
1414 sb->s_op = &ocfs2_sops; 1726 sb->s_op = &ocfs2_sops;
1415 sb->s_export_op = &ocfs2_export_ops; 1727 sb->s_export_op = &ocfs2_export_ops;
1728 sb->s_qcop = &ocfs2_quotactl_ops;
1729 sb->dq_op = &ocfs2_quota_operations;
1416 sb->s_xattr = ocfs2_xattr_handlers; 1730 sb->s_xattr = ocfs2_xattr_handlers;
1417 sb->s_time_gran = 1; 1731 sb->s_time_gran = 1;
1418 sb->s_flags |= MS_NOATIME; 1732 sb->s_flags |= MS_NOATIME;
@@ -1676,6 +1990,15 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
1676 1990
1677 if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE, 1991 if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
1678 strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) { 1992 strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
1993 /* We have to do a raw check of the feature here */
1994 if (le32_to_cpu(di->id2.i_super.s_feature_incompat) &
1995 OCFS2_FEATURE_INCOMPAT_META_ECC) {
1996 status = ocfs2_block_check_validate(bh->b_data,
1997 bh->b_size,
1998 &di->i_check);
1999 if (status)
2000 goto out;
2001 }
1679 status = -EINVAL; 2002 status = -EINVAL;
1680 if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != blksz) { 2003 if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != blksz) {
1681 mlog(ML_ERROR, "found superblock with incorrect block " 2004 mlog(ML_ERROR, "found superblock with incorrect block "
@@ -1717,6 +2040,7 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
1717 } 2040 }
1718 } 2041 }
1719 2042
2043out:
1720 mlog_exit(status); 2044 mlog_exit(status);
1721 return status; 2045 return status;
1722} 2046}
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index cbd03dfdc7b9..ed0a0cfd68d2 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -84,7 +84,7 @@ static char *ocfs2_fast_symlink_getlink(struct inode *inode,
84 84
85 mlog_entry_void(); 85 mlog_entry_void();
86 86
87 status = ocfs2_read_block(inode, OCFS2_I(inode)->ip_blkno, bh); 87 status = ocfs2_read_inode_block(inode, bh);
88 if (status < 0) { 88 if (status < 0) {
89 mlog_errno(status); 89 mlog_errno(status);
90 link = ERR_PTR(status); 90 link = ERR_PTR(status);
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 74d7367ade13..e1d638af6ac3 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -35,12 +35,14 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/security.h>
38 39
39#define MLOG_MASK_PREFIX ML_XATTR 40#define MLOG_MASK_PREFIX ML_XATTR
40#include <cluster/masklog.h> 41#include <cluster/masklog.h>
41 42
42#include "ocfs2.h" 43#include "ocfs2.h"
43#include "alloc.h" 44#include "alloc.h"
45#include "blockcheck.h"
44#include "dlmglue.h" 46#include "dlmglue.h"
45#include "file.h" 47#include "file.h"
46#include "symlink.h" 48#include "symlink.h"
@@ -61,12 +63,32 @@ struct ocfs2_xattr_def_value_root {
61}; 63};
62 64
63struct ocfs2_xattr_bucket { 65struct ocfs2_xattr_bucket {
64 struct buffer_head *bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET]; 66 /* The inode these xattrs are associated with */
65 struct ocfs2_xattr_header *xh; 67 struct inode *bu_inode;
68
69 /* The actual buffers that make up the bucket */
70 struct buffer_head *bu_bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET];
71
72 /* How many blocks make up one bucket for this filesystem */
73 int bu_blocks;
74};
75
76struct ocfs2_xattr_set_ctxt {
77 handle_t *handle;
78 struct ocfs2_alloc_context *meta_ac;
79 struct ocfs2_alloc_context *data_ac;
80 struct ocfs2_cached_dealloc_ctxt dealloc;
66}; 81};
67 82
68#define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) 83#define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
69#define OCFS2_XATTR_INLINE_SIZE 80 84#define OCFS2_XATTR_INLINE_SIZE 80
85#define OCFS2_XATTR_FREE_IN_IBODY (OCFS2_MIN_XATTR_INLINE_SIZE \
86 - sizeof(struct ocfs2_xattr_header) \
87 - sizeof(__u32))
88#define OCFS2_XATTR_FREE_IN_BLOCK(ptr) ((ptr)->i_sb->s_blocksize \
89 - sizeof(struct ocfs2_xattr_block) \
90 - sizeof(struct ocfs2_xattr_header) \
91 - sizeof(__u32))
70 92
71static struct ocfs2_xattr_def_value_root def_xv = { 93static struct ocfs2_xattr_def_value_root def_xv = {
72 .xv.xr_list.l_count = cpu_to_le16(1), 94 .xv.xr_list.l_count = cpu_to_le16(1),
@@ -74,13 +96,25 @@ static struct ocfs2_xattr_def_value_root def_xv = {
74 96
75struct xattr_handler *ocfs2_xattr_handlers[] = { 97struct xattr_handler *ocfs2_xattr_handlers[] = {
76 &ocfs2_xattr_user_handler, 98 &ocfs2_xattr_user_handler,
99#ifdef CONFIG_OCFS2_FS_POSIX_ACL
100 &ocfs2_xattr_acl_access_handler,
101 &ocfs2_xattr_acl_default_handler,
102#endif
77 &ocfs2_xattr_trusted_handler, 103 &ocfs2_xattr_trusted_handler,
104 &ocfs2_xattr_security_handler,
78 NULL 105 NULL
79}; 106};
80 107
81static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { 108static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
82 [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, 109 [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler,
110#ifdef CONFIG_OCFS2_FS_POSIX_ACL
111 [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS]
112 = &ocfs2_xattr_acl_access_handler,
113 [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT]
114 = &ocfs2_xattr_acl_default_handler,
115#endif
83 [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler, 116 [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler,
117 [OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler,
84}; 118};
85 119
86struct ocfs2_xattr_info { 120struct ocfs2_xattr_info {
@@ -98,7 +132,7 @@ struct ocfs2_xattr_search {
98 */ 132 */
99 struct buffer_head *xattr_bh; 133 struct buffer_head *xattr_bh;
100 struct ocfs2_xattr_header *header; 134 struct ocfs2_xattr_header *header;
101 struct ocfs2_xattr_bucket bucket; 135 struct ocfs2_xattr_bucket *bucket;
102 void *base; 136 void *base;
103 void *end; 137 void *end;
104 struct ocfs2_xattr_entry *here; 138 struct ocfs2_xattr_entry *here;
@@ -127,14 +161,20 @@ static int ocfs2_xattr_tree_list_index_block(struct inode *inode,
127 size_t buffer_size); 161 size_t buffer_size);
128 162
129static int ocfs2_xattr_create_index_block(struct inode *inode, 163static int ocfs2_xattr_create_index_block(struct inode *inode,
130 struct ocfs2_xattr_search *xs); 164 struct ocfs2_xattr_search *xs,
165 struct ocfs2_xattr_set_ctxt *ctxt);
131 166
132static int ocfs2_xattr_set_entry_index_block(struct inode *inode, 167static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
133 struct ocfs2_xattr_info *xi, 168 struct ocfs2_xattr_info *xi,
134 struct ocfs2_xattr_search *xs); 169 struct ocfs2_xattr_search *xs,
170 struct ocfs2_xattr_set_ctxt *ctxt);
135 171
136static int ocfs2_delete_xattr_index_block(struct inode *inode, 172static int ocfs2_delete_xattr_index_block(struct inode *inode,
137 struct buffer_head *xb_bh); 173 struct buffer_head *xb_bh);
174static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
175 u64 src_blk, u64 last_blk, u64 to_blk,
176 unsigned int start_bucket,
177 u32 *first_hash);
138 178
139static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) 179static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
140{ 180{
@@ -154,6 +194,216 @@ static inline u16 ocfs2_xattr_max_xe_in_bucket(struct super_block *sb)
154 return len / sizeof(struct ocfs2_xattr_entry); 194 return len / sizeof(struct ocfs2_xattr_entry);
155} 195}
156 196
197#define bucket_blkno(_b) ((_b)->bu_bhs[0]->b_blocknr)
198#define bucket_block(_b, _n) ((_b)->bu_bhs[(_n)]->b_data)
199#define bucket_xh(_b) ((struct ocfs2_xattr_header *)bucket_block((_b), 0))
200
201static struct ocfs2_xattr_bucket *ocfs2_xattr_bucket_new(struct inode *inode)
202{
203 struct ocfs2_xattr_bucket *bucket;
204 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
205
206 BUG_ON(blks > OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET);
207
208 bucket = kzalloc(sizeof(struct ocfs2_xattr_bucket), GFP_NOFS);
209 if (bucket) {
210 bucket->bu_inode = inode;
211 bucket->bu_blocks = blks;
212 }
213
214 return bucket;
215}
216
217static void ocfs2_xattr_bucket_relse(struct ocfs2_xattr_bucket *bucket)
218{
219 int i;
220
221 for (i = 0; i < bucket->bu_blocks; i++) {
222 brelse(bucket->bu_bhs[i]);
223 bucket->bu_bhs[i] = NULL;
224 }
225}
226
227static void ocfs2_xattr_bucket_free(struct ocfs2_xattr_bucket *bucket)
228{
229 if (bucket) {
230 ocfs2_xattr_bucket_relse(bucket);
231 bucket->bu_inode = NULL;
232 kfree(bucket);
233 }
234}
235
236/*
237 * A bucket that has never been written to disk doesn't need to be
238 * read. We just need the buffer_heads. Don't call this for
239 * buckets that are already on disk. ocfs2_read_xattr_bucket() initializes
240 * them fully.
241 */
242static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
243 u64 xb_blkno)
244{
245 int i, rc = 0;
246
247 for (i = 0; i < bucket->bu_blocks; i++) {
248 bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb,
249 xb_blkno + i);
250 if (!bucket->bu_bhs[i]) {
251 rc = -EIO;
252 mlog_errno(rc);
253 break;
254 }
255
256 if (!ocfs2_buffer_uptodate(bucket->bu_inode,
257 bucket->bu_bhs[i]))
258 ocfs2_set_new_buffer_uptodate(bucket->bu_inode,
259 bucket->bu_bhs[i]);
260 }
261
262 if (rc)
263 ocfs2_xattr_bucket_relse(bucket);
264 return rc;
265}
266
267/* Read the xattr bucket at xb_blkno */
268static int ocfs2_read_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
269 u64 xb_blkno)
270{
271 int rc;
272
273 rc = ocfs2_read_blocks(bucket->bu_inode, xb_blkno,
274 bucket->bu_blocks, bucket->bu_bhs, 0,
275 NULL);
276 if (!rc) {
277 rc = ocfs2_validate_meta_ecc_bhs(bucket->bu_inode->i_sb,
278 bucket->bu_bhs,
279 bucket->bu_blocks,
280 &bucket_xh(bucket)->xh_check);
281 if (rc)
282 mlog_errno(rc);
283 }
284
285 if (rc)
286 ocfs2_xattr_bucket_relse(bucket);
287 return rc;
288}
289
290static int ocfs2_xattr_bucket_journal_access(handle_t *handle,
291 struct ocfs2_xattr_bucket *bucket,
292 int type)
293{
294 int i, rc = 0;
295
296 for (i = 0; i < bucket->bu_blocks; i++) {
297 rc = ocfs2_journal_access(handle, bucket->bu_inode,
298 bucket->bu_bhs[i], type);
299 if (rc) {
300 mlog_errno(rc);
301 break;
302 }
303 }
304
305 return rc;
306}
307
308static void ocfs2_xattr_bucket_journal_dirty(handle_t *handle,
309 struct ocfs2_xattr_bucket *bucket)
310{
311 int i;
312
313 ocfs2_compute_meta_ecc_bhs(bucket->bu_inode->i_sb,
314 bucket->bu_bhs, bucket->bu_blocks,
315 &bucket_xh(bucket)->xh_check);
316
317 for (i = 0; i < bucket->bu_blocks; i++)
318 ocfs2_journal_dirty(handle, bucket->bu_bhs[i]);
319}
320
321static void ocfs2_xattr_bucket_copy_data(struct ocfs2_xattr_bucket *dest,
322 struct ocfs2_xattr_bucket *src)
323{
324 int i;
325 int blocksize = src->bu_inode->i_sb->s_blocksize;
326
327 BUG_ON(dest->bu_blocks != src->bu_blocks);
328 BUG_ON(dest->bu_inode != src->bu_inode);
329
330 for (i = 0; i < src->bu_blocks; i++) {
331 memcpy(bucket_block(dest, i), bucket_block(src, i),
332 blocksize);
333 }
334}
335
336static int ocfs2_validate_xattr_block(struct super_block *sb,
337 struct buffer_head *bh)
338{
339 int rc;
340 struct ocfs2_xattr_block *xb =
341 (struct ocfs2_xattr_block *)bh->b_data;
342
343 mlog(0, "Validating xattr block %llu\n",
344 (unsigned long long)bh->b_blocknr);
345
346 BUG_ON(!buffer_uptodate(bh));
347
348 /*
349 * If the ecc fails, we return the error but otherwise
350 * leave the filesystem running. We know any error is
351 * local to this block.
352 */
353 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &xb->xb_check);
354 if (rc)
355 return rc;
356
357 /*
358 * Errors after here are fatal
359 */
360
361 if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
362 ocfs2_error(sb,
363 "Extended attribute block #%llu has bad "
364 "signature %.*s",
365 (unsigned long long)bh->b_blocknr, 7,
366 xb->xb_signature);
367 return -EINVAL;
368 }
369
370 if (le64_to_cpu(xb->xb_blkno) != bh->b_blocknr) {
371 ocfs2_error(sb,
372 "Extended attribute block #%llu has an "
373 "invalid xb_blkno of %llu",
374 (unsigned long long)bh->b_blocknr,
375 (unsigned long long)le64_to_cpu(xb->xb_blkno));
376 return -EINVAL;
377 }
378
379 if (le32_to_cpu(xb->xb_fs_generation) != OCFS2_SB(sb)->fs_generation) {
380 ocfs2_error(sb,
381 "Extended attribute block #%llu has an invalid "
382 "xb_fs_generation of #%u",
383 (unsigned long long)bh->b_blocknr,
384 le32_to_cpu(xb->xb_fs_generation));
385 return -EINVAL;
386 }
387
388 return 0;
389}
390
391static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno,
392 struct buffer_head **bh)
393{
394 int rc;
395 struct buffer_head *tmp = *bh;
396
397 rc = ocfs2_read_block(inode, xb_blkno, &tmp,
398 ocfs2_validate_xattr_block);
399
400 /* If ocfs2_read_block() got us a new bh, pass it up. */
401 if (!rc && !*bh)
402 *bh = tmp;
403
404 return rc;
405}
406
157static inline const char *ocfs2_xattr_prefix(int name_index) 407static inline const char *ocfs2_xattr_prefix(int name_index)
158{ 408{
159 struct xattr_handler *handler = NULL; 409 struct xattr_handler *handler = NULL;
@@ -200,54 +450,163 @@ static void ocfs2_xattr_hash_entry(struct inode *inode,
200 return; 450 return;
201} 451}
202 452
453static int ocfs2_xattr_entry_real_size(int name_len, size_t value_len)
454{
455 int size = 0;
456
457 if (value_len <= OCFS2_XATTR_INLINE_SIZE)
458 size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_SIZE(value_len);
459 else
460 size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
461 size += sizeof(struct ocfs2_xattr_entry);
462
463 return size;
464}
465
466int ocfs2_calc_security_init(struct inode *dir,
467 struct ocfs2_security_xattr_info *si,
468 int *want_clusters,
469 int *xattr_credits,
470 struct ocfs2_alloc_context **xattr_ac)
471{
472 int ret = 0;
473 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
474 int s_size = ocfs2_xattr_entry_real_size(strlen(si->name),
475 si->value_len);
476
477 /*
478 * The max space of security xattr taken inline is
479 * 256(name) + 80(value) + 16(entry) = 352 bytes,
480 * So reserve one metadata block for it is ok.
481 */
482 if (dir->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE ||
483 s_size > OCFS2_XATTR_FREE_IN_IBODY) {
484 ret = ocfs2_reserve_new_metadata_blocks(osb, 1, xattr_ac);
485 if (ret) {
486 mlog_errno(ret);
487 return ret;
488 }
489 *xattr_credits += OCFS2_XATTR_BLOCK_CREATE_CREDITS;
490 }
491
492 /* reserve clusters for xattr value which will be set in B tree*/
493 if (si->value_len > OCFS2_XATTR_INLINE_SIZE) {
494 int new_clusters = ocfs2_clusters_for_bytes(dir->i_sb,
495 si->value_len);
496
497 *xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
498 new_clusters);
499 *want_clusters += new_clusters;
500 }
501 return ret;
502}
503
504int ocfs2_calc_xattr_init(struct inode *dir,
505 struct buffer_head *dir_bh,
506 int mode,
507 struct ocfs2_security_xattr_info *si,
508 int *want_clusters,
509 int *xattr_credits,
510 struct ocfs2_alloc_context **xattr_ac)
511{
512 int ret = 0;
513 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
514 int s_size = 0, a_size = 0, acl_len = 0, new_clusters;
515
516 if (si->enable)
517 s_size = ocfs2_xattr_entry_real_size(strlen(si->name),
518 si->value_len);
519
520 if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
521 acl_len = ocfs2_xattr_get_nolock(dir, dir_bh,
522 OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT,
523 "", NULL, 0);
524 if (acl_len > 0) {
525 a_size = ocfs2_xattr_entry_real_size(0, acl_len);
526 if (S_ISDIR(mode))
527 a_size <<= 1;
528 } else if (acl_len != 0 && acl_len != -ENODATA) {
529 mlog_errno(ret);
530 return ret;
531 }
532 }
533
534 if (!(s_size + a_size))
535 return ret;
536
537 /*
538 * The max space of security xattr taken inline is
539 * 256(name) + 80(value) + 16(entry) = 352 bytes,
540 * The max space of acl xattr taken inline is
541 * 80(value) + 16(entry) * 2(if directory) = 192 bytes,
542 * when blocksize = 512, may reserve one more cluser for
543 * xattr bucket, otherwise reserve one metadata block
544 * for them is ok.
545 */
546 if (dir->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE ||
547 (s_size + a_size) > OCFS2_XATTR_FREE_IN_IBODY) {
548 ret = ocfs2_reserve_new_metadata_blocks(osb, 1, xattr_ac);
549 if (ret) {
550 mlog_errno(ret);
551 return ret;
552 }
553 *xattr_credits += OCFS2_XATTR_BLOCK_CREATE_CREDITS;
554 }
555
556 if (dir->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE &&
557 (s_size + a_size) > OCFS2_XATTR_FREE_IN_BLOCK(dir)) {
558 *want_clusters += 1;
559 *xattr_credits += ocfs2_blocks_per_xattr_bucket(dir->i_sb);
560 }
561
562 /*
563 * reserve credits and clusters for xattrs which has large value
564 * and have to be set outside
565 */
566 if (si->enable && si->value_len > OCFS2_XATTR_INLINE_SIZE) {
567 new_clusters = ocfs2_clusters_for_bytes(dir->i_sb,
568 si->value_len);
569 *xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
570 new_clusters);
571 *want_clusters += new_clusters;
572 }
573 if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL &&
574 acl_len > OCFS2_XATTR_INLINE_SIZE) {
575 /* for directory, it has DEFAULT and ACCESS two types of acls */
576 new_clusters = (S_ISDIR(mode) ? 2 : 1) *
577 ocfs2_clusters_for_bytes(dir->i_sb, acl_len);
578 *xattr_credits += ocfs2_clusters_to_blocks(dir->i_sb,
579 new_clusters);
580 *want_clusters += new_clusters;
581 }
582
583 return ret;
584}
585
203static int ocfs2_xattr_extend_allocation(struct inode *inode, 586static int ocfs2_xattr_extend_allocation(struct inode *inode,
204 u32 clusters_to_add, 587 u32 clusters_to_add,
205 struct buffer_head *xattr_bh, 588 struct ocfs2_xattr_value_buf *vb,
206 struct ocfs2_xattr_value_root *xv) 589 struct ocfs2_xattr_set_ctxt *ctxt)
207{ 590{
208 int status = 0; 591 int status = 0;
209 int restart_func = 0; 592 handle_t *handle = ctxt->handle;
210 int credits = 0;
211 handle_t *handle = NULL;
212 struct ocfs2_alloc_context *data_ac = NULL;
213 struct ocfs2_alloc_context *meta_ac = NULL;
214 enum ocfs2_alloc_restarted why; 593 enum ocfs2_alloc_restarted why;
215 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 594 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
216 u32 prev_clusters, logical_start = le32_to_cpu(xv->xr_clusters); 595 u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters);
217 struct ocfs2_extent_tree et; 596 struct ocfs2_extent_tree et;
218 597
219 mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); 598 mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add);
220 599
221 ocfs2_init_xattr_value_extent_tree(&et, inode, xattr_bh, xv); 600 ocfs2_init_xattr_value_extent_tree(&et, inode, vb);
222
223restart_all:
224
225 status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0,
226 &data_ac, &meta_ac);
227 if (status) {
228 mlog_errno(status);
229 goto leave;
230 }
231
232 credits = ocfs2_calc_extend_credits(osb->sb, et.et_root_el,
233 clusters_to_add);
234 handle = ocfs2_start_trans(osb, credits);
235 if (IS_ERR(handle)) {
236 status = PTR_ERR(handle);
237 handle = NULL;
238 mlog_errno(status);
239 goto leave;
240 }
241 601
242restarted_transaction: 602 status = vb->vb_access(handle, inode, vb->vb_bh,
243 status = ocfs2_journal_access(handle, inode, xattr_bh, 603 OCFS2_JOURNAL_ACCESS_WRITE);
244 OCFS2_JOURNAL_ACCESS_WRITE);
245 if (status < 0) { 604 if (status < 0) {
246 mlog_errno(status); 605 mlog_errno(status);
247 goto leave; 606 goto leave;
248 } 607 }
249 608
250 prev_clusters = le32_to_cpu(xv->xr_clusters); 609 prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
251 status = ocfs2_add_clusters_in_btree(osb, 610 status = ocfs2_add_clusters_in_btree(osb,
252 inode, 611 inode,
253 &logical_start, 612 &logical_start,
@@ -255,157 +614,84 @@ restarted_transaction:
255 0, 614 0,
256 &et, 615 &et,
257 handle, 616 handle,
258 data_ac, 617 ctxt->data_ac,
259 meta_ac, 618 ctxt->meta_ac,
260 &why); 619 &why);
261 if ((status < 0) && (status != -EAGAIN)) { 620 if (status < 0) {
262 if (status != -ENOSPC) 621 mlog_errno(status);
263 mlog_errno(status);
264 goto leave; 622 goto leave;
265 } 623 }
266 624
267 status = ocfs2_journal_dirty(handle, xattr_bh); 625 status = ocfs2_journal_dirty(handle, vb->vb_bh);
268 if (status < 0) { 626 if (status < 0) {
269 mlog_errno(status); 627 mlog_errno(status);
270 goto leave; 628 goto leave;
271 } 629 }
272 630
273 clusters_to_add -= le32_to_cpu(xv->xr_clusters) - prev_clusters; 631 clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters;
274 632
275 if (why != RESTART_NONE && clusters_to_add) { 633 /*
276 if (why == RESTART_META) { 634 * We should have already allocated enough space before the transaction,
277 mlog(0, "restarting function.\n"); 635 * so no need to restart.
278 restart_func = 1; 636 */
279 } else { 637 BUG_ON(why != RESTART_NONE || clusters_to_add);
280 BUG_ON(why != RESTART_TRANS);
281
282 mlog(0, "restarting transaction.\n");
283 /* TODO: This can be more intelligent. */
284 credits = ocfs2_calc_extend_credits(osb->sb,
285 et.et_root_el,
286 clusters_to_add);
287 status = ocfs2_extend_trans(handle, credits);
288 if (status < 0) {
289 /* handle still has to be committed at
290 * this point. */
291 status = -ENOMEM;
292 mlog_errno(status);
293 goto leave;
294 }
295 goto restarted_transaction;
296 }
297 }
298 638
299leave: 639leave:
300 if (handle) {
301 ocfs2_commit_trans(osb, handle);
302 handle = NULL;
303 }
304 if (data_ac) {
305 ocfs2_free_alloc_context(data_ac);
306 data_ac = NULL;
307 }
308 if (meta_ac) {
309 ocfs2_free_alloc_context(meta_ac);
310 meta_ac = NULL;
311 }
312 if ((!status) && restart_func) {
313 restart_func = 0;
314 goto restart_all;
315 }
316 640
317 return status; 641 return status;
318} 642}
319 643
320static int __ocfs2_remove_xattr_range(struct inode *inode, 644static int __ocfs2_remove_xattr_range(struct inode *inode,
321 struct buffer_head *root_bh, 645 struct ocfs2_xattr_value_buf *vb,
322 struct ocfs2_xattr_value_root *xv,
323 u32 cpos, u32 phys_cpos, u32 len, 646 u32 cpos, u32 phys_cpos, u32 len,
324 struct ocfs2_cached_dealloc_ctxt *dealloc) 647 struct ocfs2_xattr_set_ctxt *ctxt)
325{ 648{
326 int ret; 649 int ret;
327 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); 650 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
328 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 651 handle_t *handle = ctxt->handle;
329 struct inode *tl_inode = osb->osb_tl_inode;
330 handle_t *handle;
331 struct ocfs2_alloc_context *meta_ac = NULL;
332 struct ocfs2_extent_tree et; 652 struct ocfs2_extent_tree et;
333 653
334 ocfs2_init_xattr_value_extent_tree(&et, inode, root_bh, xv); 654 ocfs2_init_xattr_value_extent_tree(&et, inode, vb);
335 655
336 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac); 656 ret = vb->vb_access(handle, inode, vb->vb_bh,
657 OCFS2_JOURNAL_ACCESS_WRITE);
337 if (ret) { 658 if (ret) {
338 mlog_errno(ret); 659 mlog_errno(ret);
339 return ret;
340 }
341
342 mutex_lock(&tl_inode->i_mutex);
343
344 if (ocfs2_truncate_log_needs_flush(osb)) {
345 ret = __ocfs2_flush_truncate_log(osb);
346 if (ret < 0) {
347 mlog_errno(ret);
348 goto out;
349 }
350 }
351
352 handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS);
353 if (IS_ERR(handle)) {
354 ret = PTR_ERR(handle);
355 mlog_errno(ret);
356 goto out; 660 goto out;
357 } 661 }
358 662
359 ret = ocfs2_journal_access(handle, inode, root_bh, 663 ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, ctxt->meta_ac,
360 OCFS2_JOURNAL_ACCESS_WRITE); 664 &ctxt->dealloc);
361 if (ret) {
362 mlog_errno(ret);
363 goto out_commit;
364 }
365
366 ret = ocfs2_remove_extent(inode, &et, cpos, len, handle, meta_ac,
367 dealloc);
368 if (ret) { 665 if (ret) {
369 mlog_errno(ret); 666 mlog_errno(ret);
370 goto out_commit; 667 goto out;
371 } 668 }
372 669
373 le32_add_cpu(&xv->xr_clusters, -len); 670 le32_add_cpu(&vb->vb_xv->xr_clusters, -len);
374 671
375 ret = ocfs2_journal_dirty(handle, root_bh); 672 ret = ocfs2_journal_dirty(handle, vb->vb_bh);
376 if (ret) { 673 if (ret) {
377 mlog_errno(ret); 674 mlog_errno(ret);
378 goto out_commit; 675 goto out;
379 } 676 }
380 677
381 ret = ocfs2_truncate_log_append(osb, handle, phys_blkno, len); 678 ret = ocfs2_cache_cluster_dealloc(&ctxt->dealloc, phys_blkno, len);
382 if (ret) 679 if (ret)
383 mlog_errno(ret); 680 mlog_errno(ret);
384 681
385out_commit:
386 ocfs2_commit_trans(osb, handle);
387out: 682out:
388 mutex_unlock(&tl_inode->i_mutex);
389
390 if (meta_ac)
391 ocfs2_free_alloc_context(meta_ac);
392
393 return ret; 683 return ret;
394} 684}
395 685
396static int ocfs2_xattr_shrink_size(struct inode *inode, 686static int ocfs2_xattr_shrink_size(struct inode *inode,
397 u32 old_clusters, 687 u32 old_clusters,
398 u32 new_clusters, 688 u32 new_clusters,
399 struct buffer_head *root_bh, 689 struct ocfs2_xattr_value_buf *vb,
400 struct ocfs2_xattr_value_root *xv) 690 struct ocfs2_xattr_set_ctxt *ctxt)
401{ 691{
402 int ret = 0; 692 int ret = 0;
403 u32 trunc_len, cpos, phys_cpos, alloc_size; 693 u32 trunc_len, cpos, phys_cpos, alloc_size;
404 u64 block; 694 u64 block;
405 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
406 struct ocfs2_cached_dealloc_ctxt dealloc;
407
408 ocfs2_init_dealloc_ctxt(&dealloc);
409 695
410 if (old_clusters <= new_clusters) 696 if (old_clusters <= new_clusters)
411 return 0; 697 return 0;
@@ -414,7 +700,8 @@ static int ocfs2_xattr_shrink_size(struct inode *inode,
414 trunc_len = old_clusters - new_clusters; 700 trunc_len = old_clusters - new_clusters;
415 while (trunc_len) { 701 while (trunc_len) {
416 ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos, 702 ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos,
417 &alloc_size, &xv->xr_list); 703 &alloc_size,
704 &vb->vb_xv->xr_list);
418 if (ret) { 705 if (ret) {
419 mlog_errno(ret); 706 mlog_errno(ret);
420 goto out; 707 goto out;
@@ -423,9 +710,9 @@ static int ocfs2_xattr_shrink_size(struct inode *inode,
423 if (alloc_size > trunc_len) 710 if (alloc_size > trunc_len)
424 alloc_size = trunc_len; 711 alloc_size = trunc_len;
425 712
426 ret = __ocfs2_remove_xattr_range(inode, root_bh, xv, cpos, 713 ret = __ocfs2_remove_xattr_range(inode, vb, cpos,
427 phys_cpos, alloc_size, 714 phys_cpos, alloc_size,
428 &dealloc); 715 ctxt);
429 if (ret) { 716 if (ret) {
430 mlog_errno(ret); 717 mlog_errno(ret);
431 goto out; 718 goto out;
@@ -439,20 +726,17 @@ static int ocfs2_xattr_shrink_size(struct inode *inode,
439 } 726 }
440 727
441out: 728out:
442 ocfs2_schedule_truncate_log_flush(osb, 1);
443 ocfs2_run_deallocs(osb, &dealloc);
444
445 return ret; 729 return ret;
446} 730}
447 731
448static int ocfs2_xattr_value_truncate(struct inode *inode, 732static int ocfs2_xattr_value_truncate(struct inode *inode,
449 struct buffer_head *root_bh, 733 struct ocfs2_xattr_value_buf *vb,
450 struct ocfs2_xattr_value_root *xv, 734 int len,
451 int len) 735 struct ocfs2_xattr_set_ctxt *ctxt)
452{ 736{
453 int ret; 737 int ret;
454 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len); 738 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len);
455 u32 old_clusters = le32_to_cpu(xv->xr_clusters); 739 u32 old_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
456 740
457 if (new_clusters == old_clusters) 741 if (new_clusters == old_clusters)
458 return 0; 742 return 0;
@@ -460,11 +744,11 @@ static int ocfs2_xattr_value_truncate(struct inode *inode,
460 if (new_clusters > old_clusters) 744 if (new_clusters > old_clusters)
461 ret = ocfs2_xattr_extend_allocation(inode, 745 ret = ocfs2_xattr_extend_allocation(inode,
462 new_clusters - old_clusters, 746 new_clusters - old_clusters,
463 root_bh, xv); 747 vb, ctxt);
464 else 748 else
465 ret = ocfs2_xattr_shrink_size(inode, 749 ret = ocfs2_xattr_shrink_size(inode,
466 old_clusters, new_clusters, 750 old_clusters, new_clusters,
467 root_bh, xv); 751 vb, ctxt);
468 752
469 return ret; 753 return ret;
470} 754}
@@ -554,18 +838,14 @@ static int ocfs2_xattr_block_list(struct inode *inode,
554 if (!di->i_xattr_loc) 838 if (!di->i_xattr_loc)
555 return ret; 839 return ret;
556 840
557 ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); 841 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
842 &blk_bh);
558 if (ret < 0) { 843 if (ret < 0) {
559 mlog_errno(ret); 844 mlog_errno(ret);
560 return ret; 845 return ret;
561 } 846 }
562 847
563 xb = (struct ocfs2_xattr_block *)blk_bh->b_data; 848 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
564 if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
565 ret = -EIO;
566 goto cleanup;
567 }
568
569 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { 849 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
570 struct ocfs2_xattr_header *header = &xb->xb_attrs.xb_header; 850 struct ocfs2_xattr_header *header = &xb->xb_attrs.xb_header;
571 ret = ocfs2_xattr_list_entries(inode, header, 851 ret = ocfs2_xattr_list_entries(inode, header,
@@ -575,7 +855,7 @@ static int ocfs2_xattr_block_list(struct inode *inode,
575 ret = ocfs2_xattr_tree_list_index_block(inode, xt, 855 ret = ocfs2_xattr_tree_list_index_block(inode, xt,
576 buffer, buffer_size); 856 buffer, buffer_size);
577 } 857 }
578cleanup: 858
579 brelse(blk_bh); 859 brelse(blk_bh);
580 860
581 return ret; 861 return ret;
@@ -685,7 +965,7 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode,
685 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); 965 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
686 /* Copy ocfs2_xattr_value */ 966 /* Copy ocfs2_xattr_value */
687 for (i = 0; i < num_clusters * bpc; i++, blkno++) { 967 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
688 ret = ocfs2_read_block(inode, blkno, &bh); 968 ret = ocfs2_read_block(inode, blkno, &bh, NULL);
689 if (ret) { 969 if (ret) {
690 mlog_errno(ret); 970 mlog_errno(ret);
691 goto out; 971 goto out;
@@ -769,7 +1049,12 @@ static int ocfs2_xattr_block_get(struct inode *inode,
769 size_t size; 1049 size_t size;
770 int ret = -ENODATA, name_offset, name_len, block_off, i; 1050 int ret = -ENODATA, name_offset, name_len, block_off, i;
771 1051
772 memset(&xs->bucket, 0, sizeof(xs->bucket)); 1052 xs->bucket = ocfs2_xattr_bucket_new(inode);
1053 if (!xs->bucket) {
1054 ret = -ENOMEM;
1055 mlog_errno(ret);
1056 goto cleanup;
1057 }
773 1058
774 ret = ocfs2_xattr_block_find(inode, name_index, name, xs); 1059 ret = ocfs2_xattr_block_find(inode, name_index, name, xs);
775 if (ret) { 1060 if (ret) {
@@ -795,11 +1080,11 @@ static int ocfs2_xattr_block_get(struct inode *inode,
795 1080
796 if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) { 1081 if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) {
797 ret = ocfs2_xattr_bucket_get_name_value(inode, 1082 ret = ocfs2_xattr_bucket_get_name_value(inode,
798 xs->bucket.xh, 1083 bucket_xh(xs->bucket),
799 i, 1084 i,
800 &block_off, 1085 &block_off,
801 &name_offset); 1086 &name_offset);
802 xs->base = xs->bucket.bhs[block_off]->b_data; 1087 xs->base = bucket_block(xs->bucket, block_off);
803 } 1088 }
804 if (ocfs2_xattr_is_local(xs->here)) { 1089 if (ocfs2_xattr_is_local(xs->here)) {
805 memcpy(buffer, (void *)xs->base + 1090 memcpy(buffer, (void *)xs->base +
@@ -817,21 +1102,15 @@ static int ocfs2_xattr_block_get(struct inode *inode,
817 } 1102 }
818 ret = size; 1103 ret = size;
819cleanup: 1104cleanup:
820 for (i = 0; i < OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET; i++) 1105 ocfs2_xattr_bucket_free(xs->bucket);
821 brelse(xs->bucket.bhs[i]);
822 memset(&xs->bucket, 0, sizeof(xs->bucket));
823 1106
824 brelse(xs->xattr_bh); 1107 brelse(xs->xattr_bh);
825 xs->xattr_bh = NULL; 1108 xs->xattr_bh = NULL;
826 return ret; 1109 return ret;
827} 1110}
828 1111
829/* ocfs2_xattr_get() 1112int ocfs2_xattr_get_nolock(struct inode *inode,
830 * 1113 struct buffer_head *di_bh,
831 * Copy an extended attribute into the buffer provided.
832 * Buffer is NULL to compute the size of buffer required.
833 */
834static int ocfs2_xattr_get(struct inode *inode,
835 int name_index, 1114 int name_index,
836 const char *name, 1115 const char *name,
837 void *buffer, 1116 void *buffer,
@@ -839,7 +1118,6 @@ static int ocfs2_xattr_get(struct inode *inode,
839{ 1118{
840 int ret; 1119 int ret;
841 struct ocfs2_dinode *di = NULL; 1120 struct ocfs2_dinode *di = NULL;
842 struct buffer_head *di_bh = NULL;
843 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1121 struct ocfs2_inode_info *oi = OCFS2_I(inode);
844 struct ocfs2_xattr_search xis = { 1122 struct ocfs2_xattr_search xis = {
845 .not_found = -ENODATA, 1123 .not_found = -ENODATA,
@@ -854,11 +1132,6 @@ static int ocfs2_xattr_get(struct inode *inode,
854 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) 1132 if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL))
855 ret = -ENODATA; 1133 ret = -ENODATA;
856 1134
857 ret = ocfs2_inode_lock(inode, &di_bh, 0);
858 if (ret < 0) {
859 mlog_errno(ret);
860 return ret;
861 }
862 xis.inode_bh = xbs.inode_bh = di_bh; 1135 xis.inode_bh = xbs.inode_bh = di_bh;
863 di = (struct ocfs2_dinode *)di_bh->b_data; 1136 di = (struct ocfs2_dinode *)di_bh->b_data;
864 1137
@@ -869,6 +1142,32 @@ static int ocfs2_xattr_get(struct inode *inode,
869 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer, 1142 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
870 buffer_size, &xbs); 1143 buffer_size, &xbs);
871 up_read(&oi->ip_xattr_sem); 1144 up_read(&oi->ip_xattr_sem);
1145
1146 return ret;
1147}
1148
1149/* ocfs2_xattr_get()
1150 *
1151 * Copy an extended attribute into the buffer provided.
1152 * Buffer is NULL to compute the size of buffer required.
1153 */
1154static int ocfs2_xattr_get(struct inode *inode,
1155 int name_index,
1156 const char *name,
1157 void *buffer,
1158 size_t buffer_size)
1159{
1160 int ret;
1161 struct buffer_head *di_bh = NULL;
1162
1163 ret = ocfs2_inode_lock(inode, &di_bh, 0);
1164 if (ret < 0) {
1165 mlog_errno(ret);
1166 return ret;
1167 }
1168 ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
1169 name, buffer, buffer_size);
1170
872 ocfs2_inode_unlock(inode, 0); 1171 ocfs2_inode_unlock(inode, 0);
873 1172
874 brelse(di_bh); 1173 brelse(di_bh);
@@ -877,44 +1176,36 @@ static int ocfs2_xattr_get(struct inode *inode,
877} 1176}
878 1177
879static int __ocfs2_xattr_set_value_outside(struct inode *inode, 1178static int __ocfs2_xattr_set_value_outside(struct inode *inode,
1179 handle_t *handle,
880 struct ocfs2_xattr_value_root *xv, 1180 struct ocfs2_xattr_value_root *xv,
881 const void *value, 1181 const void *value,
882 int value_len) 1182 int value_len)
883{ 1183{
884 int ret = 0, i, cp_len, credits; 1184 int ret = 0, i, cp_len;
885 u16 blocksize = inode->i_sb->s_blocksize; 1185 u16 blocksize = inode->i_sb->s_blocksize;
886 u32 p_cluster, num_clusters; 1186 u32 p_cluster, num_clusters;
887 u32 cpos = 0, bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); 1187 u32 cpos = 0, bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
888 u32 clusters = ocfs2_clusters_for_bytes(inode->i_sb, value_len); 1188 u32 clusters = ocfs2_clusters_for_bytes(inode->i_sb, value_len);
889 u64 blkno; 1189 u64 blkno;
890 struct buffer_head *bh = NULL; 1190 struct buffer_head *bh = NULL;
891 handle_t *handle;
892 1191
893 BUG_ON(clusters > le32_to_cpu(xv->xr_clusters)); 1192 BUG_ON(clusters > le32_to_cpu(xv->xr_clusters));
894 1193
895 credits = clusters * bpc;
896 handle = ocfs2_start_trans(OCFS2_SB(inode->i_sb), credits);
897 if (IS_ERR(handle)) {
898 ret = PTR_ERR(handle);
899 mlog_errno(ret);
900 goto out;
901 }
902
903 while (cpos < clusters) { 1194 while (cpos < clusters) {
904 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster, 1195 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
905 &num_clusters, &xv->xr_list); 1196 &num_clusters, &xv->xr_list);
906 if (ret) { 1197 if (ret) {
907 mlog_errno(ret); 1198 mlog_errno(ret);
908 goto out_commit; 1199 goto out;
909 } 1200 }
910 1201
911 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster); 1202 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
912 1203
913 for (i = 0; i < num_clusters * bpc; i++, blkno++) { 1204 for (i = 0; i < num_clusters * bpc; i++, blkno++) {
914 ret = ocfs2_read_block(inode, blkno, &bh); 1205 ret = ocfs2_read_block(inode, blkno, &bh, NULL);
915 if (ret) { 1206 if (ret) {
916 mlog_errno(ret); 1207 mlog_errno(ret);
917 goto out_commit; 1208 goto out;
918 } 1209 }
919 1210
920 ret = ocfs2_journal_access(handle, 1211 ret = ocfs2_journal_access(handle,
@@ -923,7 +1214,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
923 OCFS2_JOURNAL_ACCESS_WRITE); 1214 OCFS2_JOURNAL_ACCESS_WRITE);
924 if (ret < 0) { 1215 if (ret < 0) {
925 mlog_errno(ret); 1216 mlog_errno(ret);
926 goto out_commit; 1217 goto out;
927 } 1218 }
928 1219
929 cp_len = value_len > blocksize ? blocksize : value_len; 1220 cp_len = value_len > blocksize ? blocksize : value_len;
@@ -937,7 +1228,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
937 ret = ocfs2_journal_dirty(handle, bh); 1228 ret = ocfs2_journal_dirty(handle, bh);
938 if (ret < 0) { 1229 if (ret < 0) {
939 mlog_errno(ret); 1230 mlog_errno(ret);
940 goto out_commit; 1231 goto out;
941 } 1232 }
942 brelse(bh); 1233 brelse(bh);
943 bh = NULL; 1234 bh = NULL;
@@ -951,8 +1242,6 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
951 } 1242 }
952 cpos += num_clusters; 1243 cpos += num_clusters;
953 } 1244 }
954out_commit:
955 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
956out: 1245out:
957 brelse(bh); 1246 brelse(bh);
958 1247
@@ -960,28 +1249,22 @@ out:
960} 1249}
961 1250
962static int ocfs2_xattr_cleanup(struct inode *inode, 1251static int ocfs2_xattr_cleanup(struct inode *inode,
1252 handle_t *handle,
963 struct ocfs2_xattr_info *xi, 1253 struct ocfs2_xattr_info *xi,
964 struct ocfs2_xattr_search *xs, 1254 struct ocfs2_xattr_search *xs,
1255 struct ocfs2_xattr_value_buf *vb,
965 size_t offs) 1256 size_t offs)
966{ 1257{
967 handle_t *handle = NULL;
968 int ret = 0; 1258 int ret = 0;
969 size_t name_len = strlen(xi->name); 1259 size_t name_len = strlen(xi->name);
970 void *val = xs->base + offs; 1260 void *val = xs->base + offs;
971 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; 1261 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
972 1262
973 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), 1263 ret = vb->vb_access(handle, inode, vb->vb_bh,
974 OCFS2_XATTR_BLOCK_UPDATE_CREDITS); 1264 OCFS2_JOURNAL_ACCESS_WRITE);
975 if (IS_ERR(handle)) {
976 ret = PTR_ERR(handle);
977 mlog_errno(ret);
978 goto out;
979 }
980 ret = ocfs2_journal_access(handle, inode, xs->xattr_bh,
981 OCFS2_JOURNAL_ACCESS_WRITE);
982 if (ret) { 1265 if (ret) {
983 mlog_errno(ret); 1266 mlog_errno(ret);
984 goto out_commit; 1267 goto out;
985 } 1268 }
986 /* Decrease xattr count */ 1269 /* Decrease xattr count */
987 le16_add_cpu(&xs->header->xh_count, -1); 1270 le16_add_cpu(&xs->header->xh_count, -1);
@@ -989,35 +1272,27 @@ static int ocfs2_xattr_cleanup(struct inode *inode,
989 memset((void *)xs->here, 0, sizeof(struct ocfs2_xattr_entry)); 1272 memset((void *)xs->here, 0, sizeof(struct ocfs2_xattr_entry));
990 memset(val, 0, size); 1273 memset(val, 0, size);
991 1274
992 ret = ocfs2_journal_dirty(handle, xs->xattr_bh); 1275 ret = ocfs2_journal_dirty(handle, vb->vb_bh);
993 if (ret < 0) 1276 if (ret < 0)
994 mlog_errno(ret); 1277 mlog_errno(ret);
995out_commit:
996 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
997out: 1278out:
998 return ret; 1279 return ret;
999} 1280}
1000 1281
1001static int ocfs2_xattr_update_entry(struct inode *inode, 1282static int ocfs2_xattr_update_entry(struct inode *inode,
1283 handle_t *handle,
1002 struct ocfs2_xattr_info *xi, 1284 struct ocfs2_xattr_info *xi,
1003 struct ocfs2_xattr_search *xs, 1285 struct ocfs2_xattr_search *xs,
1286 struct ocfs2_xattr_value_buf *vb,
1004 size_t offs) 1287 size_t offs)
1005{ 1288{
1006 handle_t *handle = NULL; 1289 int ret;
1007 int ret = 0;
1008 1290
1009 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), 1291 ret = vb->vb_access(handle, inode, vb->vb_bh,
1010 OCFS2_XATTR_BLOCK_UPDATE_CREDITS); 1292 OCFS2_JOURNAL_ACCESS_WRITE);
1011 if (IS_ERR(handle)) {
1012 ret = PTR_ERR(handle);
1013 mlog_errno(ret);
1014 goto out;
1015 }
1016 ret = ocfs2_journal_access(handle, inode, xs->xattr_bh,
1017 OCFS2_JOURNAL_ACCESS_WRITE);
1018 if (ret) { 1293 if (ret) {
1019 mlog_errno(ret); 1294 mlog_errno(ret);
1020 goto out_commit; 1295 goto out;
1021 } 1296 }
1022 1297
1023 xs->here->xe_name_offset = cpu_to_le16(offs); 1298 xs->here->xe_name_offset = cpu_to_le16(offs);
@@ -1028,11 +1303,9 @@ static int ocfs2_xattr_update_entry(struct inode *inode,
1028 ocfs2_xattr_set_local(xs->here, 0); 1303 ocfs2_xattr_set_local(xs->here, 0);
1029 ocfs2_xattr_hash_entry(inode, xs->header, xs->here); 1304 ocfs2_xattr_hash_entry(inode, xs->header, xs->here);
1030 1305
1031 ret = ocfs2_journal_dirty(handle, xs->xattr_bh); 1306 ret = ocfs2_journal_dirty(handle, vb->vb_bh);
1032 if (ret < 0) 1307 if (ret < 0)
1033 mlog_errno(ret); 1308 mlog_errno(ret);
1034out_commit:
1035 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
1036out: 1309out:
1037 return ret; 1310 return ret;
1038} 1311}
@@ -1045,6 +1318,8 @@ out:
1045static int ocfs2_xattr_set_value_outside(struct inode *inode, 1318static int ocfs2_xattr_set_value_outside(struct inode *inode,
1046 struct ocfs2_xattr_info *xi, 1319 struct ocfs2_xattr_info *xi,
1047 struct ocfs2_xattr_search *xs, 1320 struct ocfs2_xattr_search *xs,
1321 struct ocfs2_xattr_set_ctxt *ctxt,
1322 struct ocfs2_xattr_value_buf *vb,
1048 size_t offs) 1323 size_t offs)
1049{ 1324{
1050 size_t name_len = strlen(xi->name); 1325 size_t name_len = strlen(xi->name);
@@ -1062,20 +1337,20 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1062 xv->xr_list.l_tree_depth = 0; 1337 xv->xr_list.l_tree_depth = 0;
1063 xv->xr_list.l_count = cpu_to_le16(1); 1338 xv->xr_list.l_count = cpu_to_le16(1);
1064 xv->xr_list.l_next_free_rec = 0; 1339 xv->xr_list.l_next_free_rec = 0;
1340 vb->vb_xv = xv;
1065 1341
1066 ret = ocfs2_xattr_value_truncate(inode, xs->xattr_bh, xv, 1342 ret = ocfs2_xattr_value_truncate(inode, vb, xi->value_len, ctxt);
1067 xi->value_len);
1068 if (ret < 0) { 1343 if (ret < 0) {
1069 mlog_errno(ret); 1344 mlog_errno(ret);
1070 return ret; 1345 return ret;
1071 } 1346 }
1072 ret = __ocfs2_xattr_set_value_outside(inode, xv, xi->value, 1347 ret = ocfs2_xattr_update_entry(inode, ctxt->handle, xi, xs, vb, offs);
1073 xi->value_len);
1074 if (ret < 0) { 1348 if (ret < 0) {
1075 mlog_errno(ret); 1349 mlog_errno(ret);
1076 return ret; 1350 return ret;
1077 } 1351 }
1078 ret = ocfs2_xattr_update_entry(inode, xi, xs, offs); 1352 ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb->vb_xv,
1353 xi->value, xi->value_len);
1079 if (ret < 0) 1354 if (ret < 0)
1080 mlog_errno(ret); 1355 mlog_errno(ret);
1081 1356
@@ -1195,6 +1470,7 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode,
1195static int ocfs2_xattr_set_entry(struct inode *inode, 1470static int ocfs2_xattr_set_entry(struct inode *inode,
1196 struct ocfs2_xattr_info *xi, 1471 struct ocfs2_xattr_info *xi,
1197 struct ocfs2_xattr_search *xs, 1472 struct ocfs2_xattr_search *xs,
1473 struct ocfs2_xattr_set_ctxt *ctxt,
1198 int flag) 1474 int flag)
1199{ 1475{
1200 struct ocfs2_xattr_entry *last; 1476 struct ocfs2_xattr_entry *last;
@@ -1202,7 +1478,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1202 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; 1478 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
1203 size_t min_offs = xs->end - xs->base, name_len = strlen(xi->name); 1479 size_t min_offs = xs->end - xs->base, name_len = strlen(xi->name);
1204 size_t size_l = 0; 1480 size_t size_l = 0;
1205 handle_t *handle = NULL; 1481 handle_t *handle = ctxt->handle;
1206 int free, i, ret; 1482 int free, i, ret;
1207 struct ocfs2_xattr_info xi_l = { 1483 struct ocfs2_xattr_info xi_l = {
1208 .name_index = xi->name_index, 1484 .name_index = xi->name_index,
@@ -1210,6 +1486,16 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1210 .value = xi->value, 1486 .value = xi->value,
1211 .value_len = xi->value_len, 1487 .value_len = xi->value_len,
1212 }; 1488 };
1489 struct ocfs2_xattr_value_buf vb = {
1490 .vb_bh = xs->xattr_bh,
1491 .vb_access = ocfs2_journal_access_di,
1492 };
1493
1494 if (!(flag & OCFS2_INLINE_XATTR_FL)) {
1495 BUG_ON(xs->xattr_bh == xs->inode_bh);
1496 vb.vb_access = ocfs2_journal_access_xb;
1497 } else
1498 BUG_ON(xs->xattr_bh != xs->inode_bh);
1213 1499
1214 /* Compute min_offs, last and free space. */ 1500 /* Compute min_offs, last and free space. */
1215 last = xs->header->xh_entries; 1501 last = xs->header->xh_entries;
@@ -1265,15 +1551,14 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1265 if (ocfs2_xattr_is_local(xs->here) && size == size_l) { 1551 if (ocfs2_xattr_is_local(xs->here) && size == size_l) {
1266 /* Replace existing local xattr with tree root */ 1552 /* Replace existing local xattr with tree root */
1267 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, 1553 ret = ocfs2_xattr_set_value_outside(inode, xi, xs,
1268 offs); 1554 ctxt, &vb, offs);
1269 if (ret < 0) 1555 if (ret < 0)
1270 mlog_errno(ret); 1556 mlog_errno(ret);
1271 goto out; 1557 goto out;
1272 } else if (!ocfs2_xattr_is_local(xs->here)) { 1558 } else if (!ocfs2_xattr_is_local(xs->here)) {
1273 /* For existing xattr which has value outside */ 1559 /* For existing xattr which has value outside */
1274 struct ocfs2_xattr_value_root *xv = NULL; 1560 vb.vb_xv = (struct ocfs2_xattr_value_root *)
1275 xv = (struct ocfs2_xattr_value_root *)(val + 1561 (val + OCFS2_XATTR_SIZE(name_len));
1276 OCFS2_XATTR_SIZE(name_len));
1277 1562
1278 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { 1563 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
1279 /* 1564 /*
@@ -1282,27 +1567,30 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1282 * then set new value with set_value_outside(). 1567 * then set new value with set_value_outside().
1283 */ 1568 */
1284 ret = ocfs2_xattr_value_truncate(inode, 1569 ret = ocfs2_xattr_value_truncate(inode,
1285 xs->xattr_bh, 1570 &vb,
1286 xv, 1571 xi->value_len,
1287 xi->value_len); 1572 ctxt);
1288 if (ret < 0) { 1573 if (ret < 0) {
1289 mlog_errno(ret); 1574 mlog_errno(ret);
1290 goto out; 1575 goto out;
1291 } 1576 }
1292 1577
1293 ret = __ocfs2_xattr_set_value_outside(inode, 1578 ret = ocfs2_xattr_update_entry(inode,
1294 xv, 1579 handle,
1295 xi->value, 1580 xi,
1296 xi->value_len); 1581 xs,
1582 &vb,
1583 offs);
1297 if (ret < 0) { 1584 if (ret < 0) {
1298 mlog_errno(ret); 1585 mlog_errno(ret);
1299 goto out; 1586 goto out;
1300 } 1587 }
1301 1588
1302 ret = ocfs2_xattr_update_entry(inode, 1589 ret = __ocfs2_xattr_set_value_outside(inode,
1303 xi, 1590 handle,
1304 xs, 1591 vb.vb_xv,
1305 offs); 1592 xi->value,
1593 xi->value_len);
1306 if (ret < 0) 1594 if (ret < 0)
1307 mlog_errno(ret); 1595 mlog_errno(ret);
1308 goto out; 1596 goto out;
@@ -1312,44 +1600,28 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1312 * just trucate old value to zero. 1600 * just trucate old value to zero.
1313 */ 1601 */
1314 ret = ocfs2_xattr_value_truncate(inode, 1602 ret = ocfs2_xattr_value_truncate(inode,
1315 xs->xattr_bh, 1603 &vb,
1316 xv, 1604 0,
1317 0); 1605 ctxt);
1318 if (ret < 0) 1606 if (ret < 0)
1319 mlog_errno(ret); 1607 mlog_errno(ret);
1320 } 1608 }
1321 } 1609 }
1322 } 1610 }
1323 1611
1324 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), 1612 ret = ocfs2_journal_access_di(handle, inode, xs->inode_bh,
1325 OCFS2_INODE_UPDATE_CREDITS); 1613 OCFS2_JOURNAL_ACCESS_WRITE);
1326 if (IS_ERR(handle)) {
1327 ret = PTR_ERR(handle);
1328 mlog_errno(ret);
1329 goto out;
1330 }
1331
1332 ret = ocfs2_journal_access(handle, inode, xs->inode_bh,
1333 OCFS2_JOURNAL_ACCESS_WRITE);
1334 if (ret) { 1614 if (ret) {
1335 mlog_errno(ret); 1615 mlog_errno(ret);
1336 goto out_commit; 1616 goto out;
1337 } 1617 }
1338 1618
1339 if (!(flag & OCFS2_INLINE_XATTR_FL)) { 1619 if (!(flag & OCFS2_INLINE_XATTR_FL)) {
1340 /* set extended attribute in external block. */ 1620 ret = vb.vb_access(handle, inode, vb.vb_bh,
1341 ret = ocfs2_extend_trans(handle, 1621 OCFS2_JOURNAL_ACCESS_WRITE);
1342 OCFS2_INODE_UPDATE_CREDITS +
1343 OCFS2_XATTR_BLOCK_UPDATE_CREDITS);
1344 if (ret) {
1345 mlog_errno(ret);
1346 goto out_commit;
1347 }
1348 ret = ocfs2_journal_access(handle, inode, xs->xattr_bh,
1349 OCFS2_JOURNAL_ACCESS_WRITE);
1350 if (ret) { 1622 if (ret) {
1351 mlog_errno(ret); 1623 mlog_errno(ret);
1352 goto out_commit; 1624 goto out;
1353 } 1625 }
1354 } 1626 }
1355 1627
@@ -1363,7 +1635,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1363 ret = ocfs2_journal_dirty(handle, xs->xattr_bh); 1635 ret = ocfs2_journal_dirty(handle, xs->xattr_bh);
1364 if (ret < 0) { 1636 if (ret < 0) {
1365 mlog_errno(ret); 1637 mlog_errno(ret);
1366 goto out_commit; 1638 goto out;
1367 } 1639 }
1368 } 1640 }
1369 1641
@@ -1391,25 +1663,19 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1391 oi->ip_dyn_features |= flag; 1663 oi->ip_dyn_features |= flag;
1392 di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features); 1664 di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features);
1393 spin_unlock(&oi->ip_lock); 1665 spin_unlock(&oi->ip_lock);
1394 /* Update inode ctime */
1395 inode->i_ctime = CURRENT_TIME;
1396 di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
1397 di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
1398 1666
1399 ret = ocfs2_journal_dirty(handle, xs->inode_bh); 1667 ret = ocfs2_journal_dirty(handle, xs->inode_bh);
1400 if (ret < 0) 1668 if (ret < 0)
1401 mlog_errno(ret); 1669 mlog_errno(ret);
1402 1670
1403out_commit:
1404 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
1405
1406 if (!ret && xi->value_len > OCFS2_XATTR_INLINE_SIZE) { 1671 if (!ret && xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
1407 /* 1672 /*
1408 * Set value outside in B tree. 1673 * Set value outside in B tree.
1409 * This is the second step for value size > INLINE_SIZE. 1674 * This is the second step for value size > INLINE_SIZE.
1410 */ 1675 */
1411 size_t offs = le16_to_cpu(xs->here->xe_name_offset); 1676 size_t offs = le16_to_cpu(xs->here->xe_name_offset);
1412 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, offs); 1677 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, ctxt,
1678 &vb, offs);
1413 if (ret < 0) { 1679 if (ret < 0) {
1414 int ret2; 1680 int ret2;
1415 1681
@@ -1418,41 +1684,56 @@ out_commit:
1418 * If set value outside failed, we have to clean 1684 * If set value outside failed, we have to clean
1419 * the junk tree root we have already set in local. 1685 * the junk tree root we have already set in local.
1420 */ 1686 */
1421 ret2 = ocfs2_xattr_cleanup(inode, xi, xs, offs); 1687 ret2 = ocfs2_xattr_cleanup(inode, ctxt->handle,
1688 xi, xs, &vb, offs);
1422 if (ret2 < 0) 1689 if (ret2 < 0)
1423 mlog_errno(ret2); 1690 mlog_errno(ret2);
1424 } 1691 }
1425 } 1692 }
1426out: 1693out:
1427 return ret; 1694 return ret;
1428
1429} 1695}
1430 1696
1431static int ocfs2_remove_value_outside(struct inode*inode, 1697static int ocfs2_remove_value_outside(struct inode*inode,
1432 struct buffer_head *bh, 1698 struct ocfs2_xattr_value_buf *vb,
1433 struct ocfs2_xattr_header *header) 1699 struct ocfs2_xattr_header *header)
1434{ 1700{
1435 int ret = 0, i; 1701 int ret = 0, i;
1702 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1703 struct ocfs2_xattr_set_ctxt ctxt = { NULL, NULL, };
1704
1705 ocfs2_init_dealloc_ctxt(&ctxt.dealloc);
1706
1707 ctxt.handle = ocfs2_start_trans(osb,
1708 ocfs2_remove_extent_credits(osb->sb));
1709 if (IS_ERR(ctxt.handle)) {
1710 ret = PTR_ERR(ctxt.handle);
1711 mlog_errno(ret);
1712 goto out;
1713 }
1436 1714
1437 for (i = 0; i < le16_to_cpu(header->xh_count); i++) { 1715 for (i = 0; i < le16_to_cpu(header->xh_count); i++) {
1438 struct ocfs2_xattr_entry *entry = &header->xh_entries[i]; 1716 struct ocfs2_xattr_entry *entry = &header->xh_entries[i];
1439 1717
1440 if (!ocfs2_xattr_is_local(entry)) { 1718 if (!ocfs2_xattr_is_local(entry)) {
1441 struct ocfs2_xattr_value_root *xv;
1442 void *val; 1719 void *val;
1443 1720
1444 val = (void *)header + 1721 val = (void *)header +
1445 le16_to_cpu(entry->xe_name_offset); 1722 le16_to_cpu(entry->xe_name_offset);
1446 xv = (struct ocfs2_xattr_value_root *) 1723 vb->vb_xv = (struct ocfs2_xattr_value_root *)
1447 (val + OCFS2_XATTR_SIZE(entry->xe_name_len)); 1724 (val + OCFS2_XATTR_SIZE(entry->xe_name_len));
1448 ret = ocfs2_xattr_value_truncate(inode, bh, xv, 0); 1725 ret = ocfs2_xattr_value_truncate(inode, vb, 0, &ctxt);
1449 if (ret < 0) { 1726 if (ret < 0) {
1450 mlog_errno(ret); 1727 mlog_errno(ret);
1451 return ret; 1728 break;
1452 } 1729 }
1453 } 1730 }
1454 } 1731 }
1455 1732
1733 ocfs2_commit_trans(osb, ctxt.handle);
1734 ocfs2_schedule_truncate_log_flush(osb, 1);
1735 ocfs2_run_deallocs(osb, &ctxt.dealloc);
1736out:
1456 return ret; 1737 return ret;
1457} 1738}
1458 1739
@@ -1463,12 +1744,16 @@ static int ocfs2_xattr_ibody_remove(struct inode *inode,
1463 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 1744 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1464 struct ocfs2_xattr_header *header; 1745 struct ocfs2_xattr_header *header;
1465 int ret; 1746 int ret;
1747 struct ocfs2_xattr_value_buf vb = {
1748 .vb_bh = di_bh,
1749 .vb_access = ocfs2_journal_access_di,
1750 };
1466 1751
1467 header = (struct ocfs2_xattr_header *) 1752 header = (struct ocfs2_xattr_header *)
1468 ((void *)di + inode->i_sb->s_blocksize - 1753 ((void *)di + inode->i_sb->s_blocksize -
1469 le16_to_cpu(di->i_xattr_inline_size)); 1754 le16_to_cpu(di->i_xattr_inline_size));
1470 1755
1471 ret = ocfs2_remove_value_outside(inode, di_bh, header); 1756 ret = ocfs2_remove_value_outside(inode, &vb, header);
1472 1757
1473 return ret; 1758 return ret;
1474} 1759}
@@ -1478,11 +1763,15 @@ static int ocfs2_xattr_block_remove(struct inode *inode,
1478{ 1763{
1479 struct ocfs2_xattr_block *xb; 1764 struct ocfs2_xattr_block *xb;
1480 int ret = 0; 1765 int ret = 0;
1766 struct ocfs2_xattr_value_buf vb = {
1767 .vb_bh = blk_bh,
1768 .vb_access = ocfs2_journal_access_xb,
1769 };
1481 1770
1482 xb = (struct ocfs2_xattr_block *)blk_bh->b_data; 1771 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
1483 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { 1772 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
1484 struct ocfs2_xattr_header *header = &(xb->xb_attrs.xb_header); 1773 struct ocfs2_xattr_header *header = &(xb->xb_attrs.xb_header);
1485 ret = ocfs2_remove_value_outside(inode, blk_bh, header); 1774 ret = ocfs2_remove_value_outside(inode, &vb, header);
1486 } else 1775 } else
1487 ret = ocfs2_delete_xattr_index_block(inode, blk_bh); 1776 ret = ocfs2_delete_xattr_index_block(inode, blk_bh);
1488 1777
@@ -1502,24 +1791,19 @@ static int ocfs2_xattr_free_block(struct inode *inode,
1502 u64 blk, bg_blkno; 1791 u64 blk, bg_blkno;
1503 u16 bit; 1792 u16 bit;
1504 1793
1505 ret = ocfs2_read_block(inode, block, &blk_bh); 1794 ret = ocfs2_read_xattr_block(inode, block, &blk_bh);
1506 if (ret < 0) { 1795 if (ret < 0) {
1507 mlog_errno(ret); 1796 mlog_errno(ret);
1508 goto out; 1797 goto out;
1509 } 1798 }
1510 1799
1511 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
1512 if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
1513 ret = -EIO;
1514 goto out;
1515 }
1516
1517 ret = ocfs2_xattr_block_remove(inode, blk_bh); 1800 ret = ocfs2_xattr_block_remove(inode, blk_bh);
1518 if (ret < 0) { 1801 if (ret < 0) {
1519 mlog_errno(ret); 1802 mlog_errno(ret);
1520 goto out; 1803 goto out;
1521 } 1804 }
1522 1805
1806 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
1523 blk = le64_to_cpu(xb->xb_blkno); 1807 blk = le64_to_cpu(xb->xb_blkno);
1524 bit = le16_to_cpu(xb->xb_suballoc_bit); 1808 bit = le16_to_cpu(xb->xb_suballoc_bit);
1525 bg_blkno = ocfs2_which_suballoc_group(blk, bit); 1809 bg_blkno = ocfs2_which_suballoc_group(blk, bit);
@@ -1606,8 +1890,8 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh)
1606 mlog_errno(ret); 1890 mlog_errno(ret);
1607 goto out; 1891 goto out;
1608 } 1892 }
1609 ret = ocfs2_journal_access(handle, inode, di_bh, 1893 ret = ocfs2_journal_access_di(handle, inode, di_bh,
1610 OCFS2_JOURNAL_ACCESS_WRITE); 1894 OCFS2_JOURNAL_ACCESS_WRITE);
1611 if (ret) { 1895 if (ret) {
1612 mlog_errno(ret); 1896 mlog_errno(ret);
1613 goto out_commit; 1897 goto out_commit;
@@ -1714,7 +1998,8 @@ static int ocfs2_xattr_ibody_find(struct inode *inode,
1714 */ 1998 */
1715static int ocfs2_xattr_ibody_set(struct inode *inode, 1999static int ocfs2_xattr_ibody_set(struct inode *inode,
1716 struct ocfs2_xattr_info *xi, 2000 struct ocfs2_xattr_info *xi,
1717 struct ocfs2_xattr_search *xs) 2001 struct ocfs2_xattr_search *xs,
2002 struct ocfs2_xattr_set_ctxt *ctxt)
1718{ 2003{
1719 struct ocfs2_inode_info *oi = OCFS2_I(inode); 2004 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1720 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; 2005 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
@@ -1731,7 +2016,7 @@ static int ocfs2_xattr_ibody_set(struct inode *inode,
1731 } 2016 }
1732 } 2017 }
1733 2018
1734 ret = ocfs2_xattr_set_entry(inode, xi, xs, 2019 ret = ocfs2_xattr_set_entry(inode, xi, xs, ctxt,
1735 (OCFS2_INLINE_XATTR_FL | OCFS2_HAS_XATTR_FL)); 2020 (OCFS2_INLINE_XATTR_FL | OCFS2_HAS_XATTR_FL));
1736out: 2021out:
1737 up_write(&oi->ip_alloc_sem); 2022 up_write(&oi->ip_alloc_sem);
@@ -1758,19 +2043,15 @@ static int ocfs2_xattr_block_find(struct inode *inode,
1758 if (!di->i_xattr_loc) 2043 if (!di->i_xattr_loc)
1759 return ret; 2044 return ret;
1760 2045
1761 ret = ocfs2_read_block(inode, le64_to_cpu(di->i_xattr_loc), &blk_bh); 2046 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
2047 &blk_bh);
1762 if (ret < 0) { 2048 if (ret < 0) {
1763 mlog_errno(ret); 2049 mlog_errno(ret);
1764 return ret; 2050 return ret;
1765 } 2051 }
1766 2052
1767 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
1768 if (!OCFS2_IS_VALID_XATTR_BLOCK(xb)) {
1769 ret = -EIO;
1770 goto cleanup;
1771 }
1772
1773 xs->xattr_bh = blk_bh; 2053 xs->xattr_bh = blk_bh;
2054 xb = (struct ocfs2_xattr_block *)blk_bh->b_data;
1774 2055
1775 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) { 2056 if (!(le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED)) {
1776 xs->header = &xb->xb_attrs.xb_header; 2057 xs->header = &xb->xb_attrs.xb_header;
@@ -1804,13 +2085,13 @@ cleanup:
1804 */ 2085 */
1805static int ocfs2_xattr_block_set(struct inode *inode, 2086static int ocfs2_xattr_block_set(struct inode *inode,
1806 struct ocfs2_xattr_info *xi, 2087 struct ocfs2_xattr_info *xi,
1807 struct ocfs2_xattr_search *xs) 2088 struct ocfs2_xattr_search *xs,
2089 struct ocfs2_xattr_set_ctxt *ctxt)
1808{ 2090{
1809 struct buffer_head *new_bh = NULL; 2091 struct buffer_head *new_bh = NULL;
1810 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 2092 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1811 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data; 2093 struct ocfs2_dinode *di = (struct ocfs2_dinode *)xs->inode_bh->b_data;
1812 struct ocfs2_alloc_context *meta_ac = NULL; 2094 handle_t *handle = ctxt->handle;
1813 handle_t *handle = NULL;
1814 struct ocfs2_xattr_block *xblk = NULL; 2095 struct ocfs2_xattr_block *xblk = NULL;
1815 u16 suballoc_bit_start; 2096 u16 suballoc_bit_start;
1816 u32 num_got; 2097 u32 num_got;
@@ -1818,45 +2099,29 @@ static int ocfs2_xattr_block_set(struct inode *inode,
1818 int ret; 2099 int ret;
1819 2100
1820 if (!xs->xattr_bh) { 2101 if (!xs->xattr_bh) {
1821 /* 2102 ret = ocfs2_journal_access_di(handle, inode, xs->inode_bh,
1822 * Alloc one external block for extended attribute 2103 OCFS2_JOURNAL_ACCESS_CREATE);
1823 * outside of inode.
1824 */
1825 ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &meta_ac);
1826 if (ret < 0) { 2104 if (ret < 0) {
1827 mlog_errno(ret); 2105 mlog_errno(ret);
1828 goto out; 2106 goto end;
1829 }
1830 handle = ocfs2_start_trans(osb,
1831 OCFS2_XATTR_BLOCK_CREATE_CREDITS);
1832 if (IS_ERR(handle)) {
1833 ret = PTR_ERR(handle);
1834 mlog_errno(ret);
1835 goto out;
1836 }
1837 ret = ocfs2_journal_access(handle, inode, xs->inode_bh,
1838 OCFS2_JOURNAL_ACCESS_CREATE);
1839 if (ret < 0) {
1840 mlog_errno(ret);
1841 goto out_commit;
1842 } 2107 }
1843 2108
1844 ret = ocfs2_claim_metadata(osb, handle, meta_ac, 1, 2109 ret = ocfs2_claim_metadata(osb, handle, ctxt->meta_ac, 1,
1845 &suballoc_bit_start, &num_got, 2110 &suballoc_bit_start, &num_got,
1846 &first_blkno); 2111 &first_blkno);
1847 if (ret < 0) { 2112 if (ret < 0) {
1848 mlog_errno(ret); 2113 mlog_errno(ret);
1849 goto out_commit; 2114 goto end;
1850 } 2115 }
1851 2116
1852 new_bh = sb_getblk(inode->i_sb, first_blkno); 2117 new_bh = sb_getblk(inode->i_sb, first_blkno);
1853 ocfs2_set_new_buffer_uptodate(inode, new_bh); 2118 ocfs2_set_new_buffer_uptodate(inode, new_bh);
1854 2119
1855 ret = ocfs2_journal_access(handle, inode, new_bh, 2120 ret = ocfs2_journal_access_xb(handle, inode, new_bh,
1856 OCFS2_JOURNAL_ACCESS_CREATE); 2121 OCFS2_JOURNAL_ACCESS_CREATE);
1857 if (ret < 0) { 2122 if (ret < 0) {
1858 mlog_errno(ret); 2123 mlog_errno(ret);
1859 goto out_commit; 2124 goto end;
1860 } 2125 }
1861 2126
1862 /* Initialize ocfs2_xattr_block */ 2127 /* Initialize ocfs2_xattr_block */
@@ -1874,44 +2139,555 @@ static int ocfs2_xattr_block_set(struct inode *inode,
1874 xs->end = (void *)xblk + inode->i_sb->s_blocksize; 2139 xs->end = (void *)xblk + inode->i_sb->s_blocksize;
1875 xs->here = xs->header->xh_entries; 2140 xs->here = xs->header->xh_entries;
1876 2141
1877
1878 ret = ocfs2_journal_dirty(handle, new_bh); 2142 ret = ocfs2_journal_dirty(handle, new_bh);
1879 if (ret < 0) { 2143 if (ret < 0) {
1880 mlog_errno(ret); 2144 mlog_errno(ret);
1881 goto out_commit; 2145 goto end;
1882 } 2146 }
1883 di->i_xattr_loc = cpu_to_le64(first_blkno); 2147 di->i_xattr_loc = cpu_to_le64(first_blkno);
1884 ret = ocfs2_journal_dirty(handle, xs->inode_bh); 2148 ocfs2_journal_dirty(handle, xs->inode_bh);
1885 if (ret < 0)
1886 mlog_errno(ret);
1887out_commit:
1888 ocfs2_commit_trans(osb, handle);
1889out:
1890 if (meta_ac)
1891 ocfs2_free_alloc_context(meta_ac);
1892 if (ret < 0)
1893 return ret;
1894 } else 2149 } else
1895 xblk = (struct ocfs2_xattr_block *)xs->xattr_bh->b_data; 2150 xblk = (struct ocfs2_xattr_block *)xs->xattr_bh->b_data;
1896 2151
1897 if (!(le16_to_cpu(xblk->xb_flags) & OCFS2_XATTR_INDEXED)) { 2152 if (!(le16_to_cpu(xblk->xb_flags) & OCFS2_XATTR_INDEXED)) {
1898 /* Set extended attribute into external block */ 2153 /* Set extended attribute into external block */
1899 ret = ocfs2_xattr_set_entry(inode, xi, xs, OCFS2_HAS_XATTR_FL); 2154 ret = ocfs2_xattr_set_entry(inode, xi, xs, ctxt,
2155 OCFS2_HAS_XATTR_FL);
1900 if (!ret || ret != -ENOSPC) 2156 if (!ret || ret != -ENOSPC)
1901 goto end; 2157 goto end;
1902 2158
1903 ret = ocfs2_xattr_create_index_block(inode, xs); 2159 ret = ocfs2_xattr_create_index_block(inode, xs, ctxt);
1904 if (ret) 2160 if (ret)
1905 goto end; 2161 goto end;
1906 } 2162 }
1907 2163
1908 ret = ocfs2_xattr_set_entry_index_block(inode, xi, xs); 2164 ret = ocfs2_xattr_set_entry_index_block(inode, xi, xs, ctxt);
1909 2165
1910end: 2166end:
1911 2167
1912 return ret; 2168 return ret;
1913} 2169}
1914 2170
2171/* Check whether the new xattr can be inserted into the inode. */
2172static int ocfs2_xattr_can_be_in_inode(struct inode *inode,
2173 struct ocfs2_xattr_info *xi,
2174 struct ocfs2_xattr_search *xs)
2175{
2176 u64 value_size;
2177 struct ocfs2_xattr_entry *last;
2178 int free, i;
2179 size_t min_offs = xs->end - xs->base;
2180
2181 if (!xs->header)
2182 return 0;
2183
2184 last = xs->header->xh_entries;
2185
2186 for (i = 0; i < le16_to_cpu(xs->header->xh_count); i++) {
2187 size_t offs = le16_to_cpu(last->xe_name_offset);
2188 if (offs < min_offs)
2189 min_offs = offs;
2190 last += 1;
2191 }
2192
2193 free = min_offs - ((void *)last - xs->base) - sizeof(__u32);
2194 if (free < 0)
2195 return 0;
2196
2197 BUG_ON(!xs->not_found);
2198
2199 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE)
2200 value_size = OCFS2_XATTR_ROOT_SIZE;
2201 else
2202 value_size = OCFS2_XATTR_SIZE(xi->value_len);
2203
2204 if (free >= sizeof(struct ocfs2_xattr_entry) +
2205 OCFS2_XATTR_SIZE(strlen(xi->name)) + value_size)
2206 return 1;
2207
2208 return 0;
2209}
2210
2211static int ocfs2_calc_xattr_set_need(struct inode *inode,
2212 struct ocfs2_dinode *di,
2213 struct ocfs2_xattr_info *xi,
2214 struct ocfs2_xattr_search *xis,
2215 struct ocfs2_xattr_search *xbs,
2216 int *clusters_need,
2217 int *meta_need,
2218 int *credits_need)
2219{
2220 int ret = 0, old_in_xb = 0;
2221 int clusters_add = 0, meta_add = 0, credits = 0;
2222 struct buffer_head *bh = NULL;
2223 struct ocfs2_xattr_block *xb = NULL;
2224 struct ocfs2_xattr_entry *xe = NULL;
2225 struct ocfs2_xattr_value_root *xv = NULL;
2226 char *base = NULL;
2227 int name_offset, name_len = 0;
2228 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
2229 xi->value_len);
2230 u64 value_size;
2231
2232 /*
2233 * Calculate the clusters we need to write.
2234 * No matter whether we replace an old one or add a new one,
2235 * we need this for writing.
2236 */
2237 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE)
2238 credits += new_clusters *
2239 ocfs2_clusters_to_blocks(inode->i_sb, 1);
2240
2241 if (xis->not_found && xbs->not_found) {
2242 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2243
2244 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
2245 clusters_add += new_clusters;
2246 credits += ocfs2_calc_extend_credits(inode->i_sb,
2247 &def_xv.xv.xr_list,
2248 new_clusters);
2249 }
2250
2251 goto meta_guess;
2252 }
2253
2254 if (!xis->not_found) {
2255 xe = xis->here;
2256 name_offset = le16_to_cpu(xe->xe_name_offset);
2257 name_len = OCFS2_XATTR_SIZE(xe->xe_name_len);
2258 base = xis->base;
2259 credits += OCFS2_INODE_UPDATE_CREDITS;
2260 } else {
2261 int i, block_off = 0;
2262 xb = (struct ocfs2_xattr_block *)xbs->xattr_bh->b_data;
2263 xe = xbs->here;
2264 name_offset = le16_to_cpu(xe->xe_name_offset);
2265 name_len = OCFS2_XATTR_SIZE(xe->xe_name_len);
2266 i = xbs->here - xbs->header->xh_entries;
2267 old_in_xb = 1;
2268
2269 if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) {
2270 ret = ocfs2_xattr_bucket_get_name_value(inode,
2271 bucket_xh(xbs->bucket),
2272 i, &block_off,
2273 &name_offset);
2274 base = bucket_block(xbs->bucket, block_off);
2275 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2276 } else {
2277 base = xbs->base;
2278 credits += OCFS2_XATTR_BLOCK_UPDATE_CREDITS;
2279 }
2280 }
2281
2282 /*
2283 * delete a xattr doesn't need metadata and cluster allocation.
2284 * so just calculate the credits and return.
2285 *
2286 * The credits for removing the value tree will be extended
2287 * by ocfs2_remove_extent itself.
2288 */
2289 if (!xi->value) {
2290 if (!ocfs2_xattr_is_local(xe))
2291 credits += ocfs2_remove_extent_credits(inode->i_sb);
2292
2293 goto out;
2294 }
2295
2296 /* do cluster allocation guess first. */
2297 value_size = le64_to_cpu(xe->xe_value_size);
2298
2299 if (old_in_xb) {
2300 /*
2301 * In xattr set, we always try to set the xe in inode first,
2302 * so if it can be inserted into inode successfully, the old
2303 * one will be removed from the xattr block, and this xattr
2304 * will be inserted into inode as a new xattr in inode.
2305 */
2306 if (ocfs2_xattr_can_be_in_inode(inode, xi, xis)) {
2307 clusters_add += new_clusters;
2308 credits += ocfs2_remove_extent_credits(inode->i_sb) +
2309 OCFS2_INODE_UPDATE_CREDITS;
2310 if (!ocfs2_xattr_is_local(xe))
2311 credits += ocfs2_calc_extend_credits(
2312 inode->i_sb,
2313 &def_xv.xv.xr_list,
2314 new_clusters);
2315 goto out;
2316 }
2317 }
2318
2319 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
2320 /* the new values will be stored outside. */
2321 u32 old_clusters = 0;
2322
2323 if (!ocfs2_xattr_is_local(xe)) {
2324 old_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
2325 value_size);
2326 xv = (struct ocfs2_xattr_value_root *)
2327 (base + name_offset + name_len);
2328 value_size = OCFS2_XATTR_ROOT_SIZE;
2329 } else
2330 xv = &def_xv.xv;
2331
2332 if (old_clusters >= new_clusters) {
2333 credits += ocfs2_remove_extent_credits(inode->i_sb);
2334 goto out;
2335 } else {
2336 meta_add += ocfs2_extend_meta_needed(&xv->xr_list);
2337 clusters_add += new_clusters - old_clusters;
2338 credits += ocfs2_calc_extend_credits(inode->i_sb,
2339 &xv->xr_list,
2340 new_clusters -
2341 old_clusters);
2342 if (value_size >= OCFS2_XATTR_ROOT_SIZE)
2343 goto out;
2344 }
2345 } else {
2346 /*
2347 * Now the new value will be stored inside. So if the new
2348 * value is smaller than the size of value root or the old
2349 * value, we don't need any allocation, otherwise we have
2350 * to guess metadata allocation.
2351 */
2352 if ((ocfs2_xattr_is_local(xe) && value_size >= xi->value_len) ||
2353 (!ocfs2_xattr_is_local(xe) &&
2354 OCFS2_XATTR_ROOT_SIZE >= xi->value_len))
2355 goto out;
2356 }
2357
2358meta_guess:
2359 /* calculate metadata allocation. */
2360 if (di->i_xattr_loc) {
2361 if (!xbs->xattr_bh) {
2362 ret = ocfs2_read_xattr_block(inode,
2363 le64_to_cpu(di->i_xattr_loc),
2364 &bh);
2365 if (ret) {
2366 mlog_errno(ret);
2367 goto out;
2368 }
2369
2370 xb = (struct ocfs2_xattr_block *)bh->b_data;
2371 } else
2372 xb = (struct ocfs2_xattr_block *)xbs->xattr_bh->b_data;
2373
2374 /*
2375 * If there is already an xattr tree, good, we can calculate
2376 * like other b-trees. Otherwise we may have the chance of
2377 * create a tree, the credit calculation is borrowed from
2378 * ocfs2_calc_extend_credits with root_el = NULL. And the
2379 * new tree will be cluster based, so no meta is needed.
2380 */
2381 if (le16_to_cpu(xb->xb_flags) & OCFS2_XATTR_INDEXED) {
2382 struct ocfs2_extent_list *el =
2383 &xb->xb_attrs.xb_root.xt_list;
2384 meta_add += ocfs2_extend_meta_needed(el);
2385 credits += ocfs2_calc_extend_credits(inode->i_sb,
2386 el, 1);
2387 } else
2388 credits += OCFS2_SUBALLOC_ALLOC + 1;
2389
2390 /*
2391 * This cluster will be used either for new bucket or for
2392 * new xattr block.
2393 * If the cluster size is the same as the bucket size, one
2394 * more is needed since we may need to extend the bucket
2395 * also.
2396 */
2397 clusters_add += 1;
2398 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2399 if (OCFS2_XATTR_BUCKET_SIZE ==
2400 OCFS2_SB(inode->i_sb)->s_clustersize) {
2401 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2402 clusters_add += 1;
2403 }
2404 } else {
2405 meta_add += 1;
2406 credits += OCFS2_XATTR_BLOCK_CREATE_CREDITS;
2407 }
2408out:
2409 if (clusters_need)
2410 *clusters_need = clusters_add;
2411 if (meta_need)
2412 *meta_need = meta_add;
2413 if (credits_need)
2414 *credits_need = credits;
2415 brelse(bh);
2416 return ret;
2417}
2418
2419static int ocfs2_init_xattr_set_ctxt(struct inode *inode,
2420 struct ocfs2_dinode *di,
2421 struct ocfs2_xattr_info *xi,
2422 struct ocfs2_xattr_search *xis,
2423 struct ocfs2_xattr_search *xbs,
2424 struct ocfs2_xattr_set_ctxt *ctxt,
2425 int *credits)
2426{
2427 int clusters_add, meta_add, ret;
2428 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2429
2430 memset(ctxt, 0, sizeof(struct ocfs2_xattr_set_ctxt));
2431
2432 ocfs2_init_dealloc_ctxt(&ctxt->dealloc);
2433
2434 ret = ocfs2_calc_xattr_set_need(inode, di, xi, xis, xbs,
2435 &clusters_add, &meta_add, credits);
2436 if (ret) {
2437 mlog_errno(ret);
2438 return ret;
2439 }
2440
2441 mlog(0, "Set xattr %s, reserve meta blocks = %d, clusters = %d, "
2442 "credits = %d\n", xi->name, meta_add, clusters_add, *credits);
2443
2444 if (meta_add) {
2445 ret = ocfs2_reserve_new_metadata_blocks(osb, meta_add,
2446 &ctxt->meta_ac);
2447 if (ret) {
2448 mlog_errno(ret);
2449 goto out;
2450 }
2451 }
2452
2453 if (clusters_add) {
2454 ret = ocfs2_reserve_clusters(osb, clusters_add, &ctxt->data_ac);
2455 if (ret)
2456 mlog_errno(ret);
2457 }
2458out:
2459 if (ret) {
2460 if (ctxt->meta_ac) {
2461 ocfs2_free_alloc_context(ctxt->meta_ac);
2462 ctxt->meta_ac = NULL;
2463 }
2464
2465 /*
2466 * We cannot have an error and a non null ctxt->data_ac.
2467 */
2468 }
2469
2470 return ret;
2471}
2472
2473static int __ocfs2_xattr_set_handle(struct inode *inode,
2474 struct ocfs2_dinode *di,
2475 struct ocfs2_xattr_info *xi,
2476 struct ocfs2_xattr_search *xis,
2477 struct ocfs2_xattr_search *xbs,
2478 struct ocfs2_xattr_set_ctxt *ctxt)
2479{
2480 int ret = 0, credits, old_found;
2481
2482 if (!xi->value) {
2483 /* Remove existing extended attribute */
2484 if (!xis->not_found)
2485 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
2486 else if (!xbs->not_found)
2487 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
2488 } else {
2489 /* We always try to set extended attribute into inode first*/
2490 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
2491 if (!ret && !xbs->not_found) {
2492 /*
2493 * If succeed and that extended attribute existing in
2494 * external block, then we will remove it.
2495 */
2496 xi->value = NULL;
2497 xi->value_len = 0;
2498
2499 old_found = xis->not_found;
2500 xis->not_found = -ENODATA;
2501 ret = ocfs2_calc_xattr_set_need(inode,
2502 di,
2503 xi,
2504 xis,
2505 xbs,
2506 NULL,
2507 NULL,
2508 &credits);
2509 xis->not_found = old_found;
2510 if (ret) {
2511 mlog_errno(ret);
2512 goto out;
2513 }
2514
2515 ret = ocfs2_extend_trans(ctxt->handle, credits +
2516 ctxt->handle->h_buffer_credits);
2517 if (ret) {
2518 mlog_errno(ret);
2519 goto out;
2520 }
2521 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
2522 } else if (ret == -ENOSPC) {
2523 if (di->i_xattr_loc && !xbs->xattr_bh) {
2524 ret = ocfs2_xattr_block_find(inode,
2525 xi->name_index,
2526 xi->name, xbs);
2527 if (ret)
2528 goto out;
2529
2530 old_found = xis->not_found;
2531 xis->not_found = -ENODATA;
2532 ret = ocfs2_calc_xattr_set_need(inode,
2533 di,
2534 xi,
2535 xis,
2536 xbs,
2537 NULL,
2538 NULL,
2539 &credits);
2540 xis->not_found = old_found;
2541 if (ret) {
2542 mlog_errno(ret);
2543 goto out;
2544 }
2545
2546 ret = ocfs2_extend_trans(ctxt->handle, credits +
2547 ctxt->handle->h_buffer_credits);
2548 if (ret) {
2549 mlog_errno(ret);
2550 goto out;
2551 }
2552 }
2553 /*
2554 * If no space in inode, we will set extended attribute
2555 * into external block.
2556 */
2557 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
2558 if (ret)
2559 goto out;
2560 if (!xis->not_found) {
2561 /*
2562 * If succeed and that extended attribute
2563 * existing in inode, we will remove it.
2564 */
2565 xi->value = NULL;
2566 xi->value_len = 0;
2567 xbs->not_found = -ENODATA;
2568 ret = ocfs2_calc_xattr_set_need(inode,
2569 di,
2570 xi,
2571 xis,
2572 xbs,
2573 NULL,
2574 NULL,
2575 &credits);
2576 if (ret) {
2577 mlog_errno(ret);
2578 goto out;
2579 }
2580
2581 ret = ocfs2_extend_trans(ctxt->handle, credits +
2582 ctxt->handle->h_buffer_credits);
2583 if (ret) {
2584 mlog_errno(ret);
2585 goto out;
2586 }
2587 ret = ocfs2_xattr_ibody_set(inode, xi,
2588 xis, ctxt);
2589 }
2590 }
2591 }
2592
2593 if (!ret) {
2594 /* Update inode ctime. */
2595 ret = ocfs2_journal_access(ctxt->handle, inode, xis->inode_bh,
2596 OCFS2_JOURNAL_ACCESS_WRITE);
2597 if (ret) {
2598 mlog_errno(ret);
2599 goto out;
2600 }
2601
2602 inode->i_ctime = CURRENT_TIME;
2603 di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
2604 di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
2605 ocfs2_journal_dirty(ctxt->handle, xis->inode_bh);
2606 }
2607out:
2608 return ret;
2609}
2610
2611/*
2612 * This function only called duing creating inode
2613 * for init security/acl xattrs of the new inode.
2614 * All transanction credits have been reserved in mknod.
2615 */
2616int ocfs2_xattr_set_handle(handle_t *handle,
2617 struct inode *inode,
2618 struct buffer_head *di_bh,
2619 int name_index,
2620 const char *name,
2621 const void *value,
2622 size_t value_len,
2623 int flags,
2624 struct ocfs2_alloc_context *meta_ac,
2625 struct ocfs2_alloc_context *data_ac)
2626{
2627 struct ocfs2_dinode *di;
2628 int ret;
2629
2630 struct ocfs2_xattr_info xi = {
2631 .name_index = name_index,
2632 .name = name,
2633 .value = value,
2634 .value_len = value_len,
2635 };
2636
2637 struct ocfs2_xattr_search xis = {
2638 .not_found = -ENODATA,
2639 };
2640
2641 struct ocfs2_xattr_search xbs = {
2642 .not_found = -ENODATA,
2643 };
2644
2645 struct ocfs2_xattr_set_ctxt ctxt = {
2646 .handle = handle,
2647 .meta_ac = meta_ac,
2648 .data_ac = data_ac,
2649 };
2650
2651 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
2652 return -EOPNOTSUPP;
2653
2654 /*
2655 * In extreme situation, may need xattr bucket when
2656 * block size is too small. And we have already reserved
2657 * the credits for bucket in mknod.
2658 */
2659 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE) {
2660 xbs.bucket = ocfs2_xattr_bucket_new(inode);
2661 if (!xbs.bucket) {
2662 mlog_errno(-ENOMEM);
2663 return -ENOMEM;
2664 }
2665 }
2666
2667 xis.inode_bh = xbs.inode_bh = di_bh;
2668 di = (struct ocfs2_dinode *)di_bh->b_data;
2669
2670 down_write(&OCFS2_I(inode)->ip_xattr_sem);
2671
2672 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
2673 if (ret)
2674 goto cleanup;
2675 if (xis.not_found) {
2676 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
2677 if (ret)
2678 goto cleanup;
2679 }
2680
2681 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
2682
2683cleanup:
2684 up_write(&OCFS2_I(inode)->ip_xattr_sem);
2685 brelse(xbs.xattr_bh);
2686 ocfs2_xattr_bucket_free(xbs.bucket);
2687
2688 return ret;
2689}
2690
1915/* 2691/*
1916 * ocfs2_xattr_set() 2692 * ocfs2_xattr_set()
1917 * 2693 *
@@ -1928,8 +2704,10 @@ int ocfs2_xattr_set(struct inode *inode,
1928{ 2704{
1929 struct buffer_head *di_bh = NULL; 2705 struct buffer_head *di_bh = NULL;
1930 struct ocfs2_dinode *di; 2706 struct ocfs2_dinode *di;
1931 int ret; 2707 int ret, credits;
1932 u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 2708 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2709 struct inode *tl_inode = osb->osb_tl_inode;
2710 struct ocfs2_xattr_set_ctxt ctxt = { NULL, NULL, };
1933 2711
1934 struct ocfs2_xattr_info xi = { 2712 struct ocfs2_xattr_info xi = {
1935 .name_index = name_index, 2713 .name_index = name_index,
@@ -1949,10 +2727,20 @@ int ocfs2_xattr_set(struct inode *inode,
1949 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb))) 2727 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
1950 return -EOPNOTSUPP; 2728 return -EOPNOTSUPP;
1951 2729
2730 /*
2731 * Only xbs will be used on indexed trees. xis doesn't need a
2732 * bucket.
2733 */
2734 xbs.bucket = ocfs2_xattr_bucket_new(inode);
2735 if (!xbs.bucket) {
2736 mlog_errno(-ENOMEM);
2737 return -ENOMEM;
2738 }
2739
1952 ret = ocfs2_inode_lock(inode, &di_bh, 1); 2740 ret = ocfs2_inode_lock(inode, &di_bh, 1);
1953 if (ret < 0) { 2741 if (ret < 0) {
1954 mlog_errno(ret); 2742 mlog_errno(ret);
1955 return ret; 2743 goto cleanup_nolock;
1956 } 2744 }
1957 xis.inode_bh = xbs.inode_bh = di_bh; 2745 xis.inode_bh = xbs.inode_bh = di_bh;
1958 di = (struct ocfs2_dinode *)di_bh->b_data; 2746 di = (struct ocfs2_dinode *)di_bh->b_data;
@@ -1984,55 +2772,53 @@ int ocfs2_xattr_set(struct inode *inode,
1984 goto cleanup; 2772 goto cleanup;
1985 } 2773 }
1986 2774
1987 if (!value) { 2775
1988 /* Remove existing extended attribute */ 2776 mutex_lock(&tl_inode->i_mutex);
1989 if (!xis.not_found) 2777
1990 ret = ocfs2_xattr_ibody_set(inode, &xi, &xis); 2778 if (ocfs2_truncate_log_needs_flush(osb)) {
1991 else if (!xbs.not_found) 2779 ret = __ocfs2_flush_truncate_log(osb);
1992 ret = ocfs2_xattr_block_set(inode, &xi, &xbs); 2780 if (ret < 0) {
1993 } else { 2781 mutex_unlock(&tl_inode->i_mutex);
1994 /* We always try to set extended attribute into inode first*/ 2782 mlog_errno(ret);
1995 ret = ocfs2_xattr_ibody_set(inode, &xi, &xis); 2783 goto cleanup;
1996 if (!ret && !xbs.not_found) {
1997 /*
1998 * If succeed and that extended attribute existing in
1999 * external block, then we will remove it.
2000 */
2001 xi.value = NULL;
2002 xi.value_len = 0;
2003 ret = ocfs2_xattr_block_set(inode, &xi, &xbs);
2004 } else if (ret == -ENOSPC) {
2005 if (di->i_xattr_loc && !xbs.xattr_bh) {
2006 ret = ocfs2_xattr_block_find(inode, name_index,
2007 name, &xbs);
2008 if (ret)
2009 goto cleanup;
2010 }
2011 /*
2012 * If no space in inode, we will set extended attribute
2013 * into external block.
2014 */
2015 ret = ocfs2_xattr_block_set(inode, &xi, &xbs);
2016 if (ret)
2017 goto cleanup;
2018 if (!xis.not_found) {
2019 /*
2020 * If succeed and that extended attribute
2021 * existing in inode, we will remove it.
2022 */
2023 xi.value = NULL;
2024 xi.value_len = 0;
2025 ret = ocfs2_xattr_ibody_set(inode, &xi, &xis);
2026 }
2027 } 2784 }
2028 } 2785 }
2786 mutex_unlock(&tl_inode->i_mutex);
2787
2788 ret = ocfs2_init_xattr_set_ctxt(inode, di, &xi, &xis,
2789 &xbs, &ctxt, &credits);
2790 if (ret) {
2791 mlog_errno(ret);
2792 goto cleanup;
2793 }
2794
2795 /* we need to update inode's ctime field, so add credit for it. */
2796 credits += OCFS2_INODE_UPDATE_CREDITS;
2797 ctxt.handle = ocfs2_start_trans(osb, credits);
2798 if (IS_ERR(ctxt.handle)) {
2799 ret = PTR_ERR(ctxt.handle);
2800 mlog_errno(ret);
2801 goto cleanup;
2802 }
2803
2804 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
2805
2806 ocfs2_commit_trans(osb, ctxt.handle);
2807
2808 if (ctxt.data_ac)
2809 ocfs2_free_alloc_context(ctxt.data_ac);
2810 if (ctxt.meta_ac)
2811 ocfs2_free_alloc_context(ctxt.meta_ac);
2812 if (ocfs2_dealloc_has_cluster(&ctxt.dealloc))
2813 ocfs2_schedule_truncate_log_flush(osb, 1);
2814 ocfs2_run_deallocs(osb, &ctxt.dealloc);
2029cleanup: 2815cleanup:
2030 up_write(&OCFS2_I(inode)->ip_xattr_sem); 2816 up_write(&OCFS2_I(inode)->ip_xattr_sem);
2031 ocfs2_inode_unlock(inode, 1); 2817 ocfs2_inode_unlock(inode, 1);
2818cleanup_nolock:
2032 brelse(di_bh); 2819 brelse(di_bh);
2033 brelse(xbs.xattr_bh); 2820 brelse(xbs.xattr_bh);
2034 for (i = 0; i < blk_per_bucket; i++) 2821 ocfs2_xattr_bucket_free(xbs.bucket);
2035 brelse(xbs.bucket.bhs[i]);
2036 2822
2037 return ret; 2823 return ret;
2038} 2824}
@@ -2107,7 +2893,7 @@ typedef int (xattr_bucket_func)(struct inode *inode,
2107 void *para); 2893 void *para);
2108 2894
2109static int ocfs2_find_xe_in_bucket(struct inode *inode, 2895static int ocfs2_find_xe_in_bucket(struct inode *inode,
2110 struct buffer_head *header_bh, 2896 struct ocfs2_xattr_bucket *bucket,
2111 int name_index, 2897 int name_index,
2112 const char *name, 2898 const char *name,
2113 u32 name_hash, 2899 u32 name_hash,
@@ -2115,11 +2901,9 @@ static int ocfs2_find_xe_in_bucket(struct inode *inode,
2115 int *found) 2901 int *found)
2116{ 2902{
2117 int i, ret = 0, cmp = 1, block_off, new_offset; 2903 int i, ret = 0, cmp = 1, block_off, new_offset;
2118 struct ocfs2_xattr_header *xh = 2904 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
2119 (struct ocfs2_xattr_header *)header_bh->b_data;
2120 size_t name_len = strlen(name); 2905 size_t name_len = strlen(name);
2121 struct ocfs2_xattr_entry *xe = NULL; 2906 struct ocfs2_xattr_entry *xe = NULL;
2122 struct buffer_head *name_bh = NULL;
2123 char *xe_name; 2907 char *xe_name;
2124 2908
2125 /* 2909 /*
@@ -2150,19 +2934,9 @@ static int ocfs2_find_xe_in_bucket(struct inode *inode,
2150 break; 2934 break;
2151 } 2935 }
2152 2936
2153 ret = ocfs2_read_block(inode, header_bh->b_blocknr + block_off,
2154 &name_bh);
2155 if (ret) {
2156 mlog_errno(ret);
2157 break;
2158 }
2159 xe_name = name_bh->b_data + new_offset;
2160 2937
2161 cmp = memcmp(name, xe_name, name_len); 2938 xe_name = bucket_block(bucket, block_off) + new_offset;
2162 brelse(name_bh); 2939 if (!memcmp(name, xe_name, name_len)) {
2163 name_bh = NULL;
2164
2165 if (cmp == 0) {
2166 *xe_index = i; 2940 *xe_index = i;
2167 *found = 1; 2941 *found = 1;
2168 ret = 0; 2942 ret = 0;
@@ -2192,39 +2966,42 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2192 struct ocfs2_xattr_search *xs) 2966 struct ocfs2_xattr_search *xs)
2193{ 2967{
2194 int ret, found = 0; 2968 int ret, found = 0;
2195 struct buffer_head *bh = NULL;
2196 struct buffer_head *lower_bh = NULL;
2197 struct ocfs2_xattr_header *xh = NULL; 2969 struct ocfs2_xattr_header *xh = NULL;
2198 struct ocfs2_xattr_entry *xe = NULL; 2970 struct ocfs2_xattr_entry *xe = NULL;
2199 u16 index = 0; 2971 u16 index = 0;
2200 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 2972 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2201 int low_bucket = 0, bucket, high_bucket; 2973 int low_bucket = 0, bucket, high_bucket;
2974 struct ocfs2_xattr_bucket *search;
2202 u32 last_hash; 2975 u32 last_hash;
2203 u64 blkno; 2976 u64 blkno, lower_blkno = 0;
2204 2977
2205 ret = ocfs2_read_block(inode, p_blkno, &bh); 2978 search = ocfs2_xattr_bucket_new(inode);
2979 if (!search) {
2980 ret = -ENOMEM;
2981 mlog_errno(ret);
2982 goto out;
2983 }
2984
2985 ret = ocfs2_read_xattr_bucket(search, p_blkno);
2206 if (ret) { 2986 if (ret) {
2207 mlog_errno(ret); 2987 mlog_errno(ret);
2208 goto out; 2988 goto out;
2209 } 2989 }
2210 2990
2211 xh = (struct ocfs2_xattr_header *)bh->b_data; 2991 xh = bucket_xh(search);
2212 high_bucket = le16_to_cpu(xh->xh_num_buckets) - 1; 2992 high_bucket = le16_to_cpu(xh->xh_num_buckets) - 1;
2213
2214 while (low_bucket <= high_bucket) { 2993 while (low_bucket <= high_bucket) {
2215 brelse(bh); 2994 ocfs2_xattr_bucket_relse(search);
2216 bh = NULL;
2217 bucket = (low_bucket + high_bucket) / 2;
2218 2995
2996 bucket = (low_bucket + high_bucket) / 2;
2219 blkno = p_blkno + bucket * blk_per_bucket; 2997 blkno = p_blkno + bucket * blk_per_bucket;
2220 2998 ret = ocfs2_read_xattr_bucket(search, blkno);
2221 ret = ocfs2_read_block(inode, blkno, &bh);
2222 if (ret) { 2999 if (ret) {
2223 mlog_errno(ret); 3000 mlog_errno(ret);
2224 goto out; 3001 goto out;
2225 } 3002 }
2226 3003
2227 xh = (struct ocfs2_xattr_header *)bh->b_data; 3004 xh = bucket_xh(search);
2228 xe = &xh->xh_entries[0]; 3005 xe = &xh->xh_entries[0];
2229 if (name_hash < le32_to_cpu(xe->xe_name_hash)) { 3006 if (name_hash < le32_to_cpu(xe->xe_name_hash)) {
2230 high_bucket = bucket - 1; 3007 high_bucket = bucket - 1;
@@ -2241,10 +3018,8 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2241 3018
2242 last_hash = le32_to_cpu(xe->xe_name_hash); 3019 last_hash = le32_to_cpu(xe->xe_name_hash);
2243 3020
2244 /* record lower_bh which may be the insert place. */ 3021 /* record lower_blkno which may be the insert place. */
2245 brelse(lower_bh); 3022 lower_blkno = blkno;
2246 lower_bh = bh;
2247 bh = NULL;
2248 3023
2249 if (name_hash > le32_to_cpu(xe->xe_name_hash)) { 3024 if (name_hash > le32_to_cpu(xe->xe_name_hash)) {
2250 low_bucket = bucket + 1; 3025 low_bucket = bucket + 1;
@@ -2252,7 +3027,7 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2252 } 3027 }
2253 3028
2254 /* the searched xattr should reside in this bucket if exists. */ 3029 /* the searched xattr should reside in this bucket if exists. */
2255 ret = ocfs2_find_xe_in_bucket(inode, lower_bh, 3030 ret = ocfs2_find_xe_in_bucket(inode, search,
2256 name_index, name, name_hash, 3031 name_index, name, name_hash,
2257 &index, &found); 3032 &index, &found);
2258 if (ret) { 3033 if (ret) {
@@ -2267,46 +3042,29 @@ static int ocfs2_xattr_bucket_find(struct inode *inode,
2267 * When the xattr's hash value is in the gap of 2 buckets, we will 3042 * When the xattr's hash value is in the gap of 2 buckets, we will
2268 * always set it to the previous bucket. 3043 * always set it to the previous bucket.
2269 */ 3044 */
2270 if (!lower_bh) { 3045 if (!lower_blkno)
2271 /* 3046 lower_blkno = p_blkno;
2272 * We can't find any bucket whose first name_hash is less 3047
2273 * than the find name_hash. 3048 /* This should be in cache - we just read it during the search */
2274 */ 3049 ret = ocfs2_read_xattr_bucket(xs->bucket, lower_blkno);
2275 BUG_ON(bh->b_blocknr != p_blkno); 3050 if (ret) {
2276 lower_bh = bh; 3051 mlog_errno(ret);
2277 bh = NULL; 3052 goto out;
2278 } 3053 }
2279 xs->bucket.bhs[0] = lower_bh;
2280 xs->bucket.xh = (struct ocfs2_xattr_header *)
2281 xs->bucket.bhs[0]->b_data;
2282 lower_bh = NULL;
2283 3054
2284 xs->header = xs->bucket.xh; 3055 xs->header = bucket_xh(xs->bucket);
2285 xs->base = xs->bucket.bhs[0]->b_data; 3056 xs->base = bucket_block(xs->bucket, 0);
2286 xs->end = xs->base + inode->i_sb->s_blocksize; 3057 xs->end = xs->base + inode->i_sb->s_blocksize;
2287 3058
2288 if (found) { 3059 if (found) {
2289 /*
2290 * If we have found the xattr enty, read all the blocks in
2291 * this bucket.
2292 */
2293 ret = ocfs2_read_blocks(inode, xs->bucket.bhs[0]->b_blocknr + 1,
2294 blk_per_bucket - 1, &xs->bucket.bhs[1],
2295 0);
2296 if (ret) {
2297 mlog_errno(ret);
2298 goto out;
2299 }
2300
2301 xs->here = &xs->header->xh_entries[index]; 3060 xs->here = &xs->header->xh_entries[index];
2302 mlog(0, "find xattr %s in bucket %llu, entry = %u\n", name, 3061 mlog(0, "find xattr %s in bucket %llu, entry = %u\n", name,
2303 (unsigned long long)xs->bucket.bhs[0]->b_blocknr, index); 3062 (unsigned long long)bucket_blkno(xs->bucket), index);
2304 } else 3063 } else
2305 ret = -ENODATA; 3064 ret = -ENODATA;
2306 3065
2307out: 3066out:
2308 brelse(bh); 3067 ocfs2_xattr_bucket_free(search);
2309 brelse(lower_bh);
2310 return ret; 3068 return ret;
2311} 3069}
2312 3070
@@ -2357,53 +3115,50 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode,
2357 xattr_bucket_func *func, 3115 xattr_bucket_func *func,
2358 void *para) 3116 void *para)
2359{ 3117{
2360 int i, j, ret = 0; 3118 int i, ret = 0;
2361 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2362 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)); 3119 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
2363 u32 num_buckets = clusters * bpc; 3120 u32 num_buckets = clusters * bpc;
2364 struct ocfs2_xattr_bucket bucket; 3121 struct ocfs2_xattr_bucket *bucket;
2365 3122
2366 memset(&bucket, 0, sizeof(bucket)); 3123 bucket = ocfs2_xattr_bucket_new(inode);
3124 if (!bucket) {
3125 mlog_errno(-ENOMEM);
3126 return -ENOMEM;
3127 }
2367 3128
2368 mlog(0, "iterating xattr buckets in %u clusters starting from %llu\n", 3129 mlog(0, "iterating xattr buckets in %u clusters starting from %llu\n",
2369 clusters, (unsigned long long)blkno); 3130 clusters, (unsigned long long)blkno);
2370 3131
2371 for (i = 0; i < num_buckets; i++, blkno += blk_per_bucket) { 3132 for (i = 0; i < num_buckets; i++, blkno += bucket->bu_blocks) {
2372 ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, 3133 ret = ocfs2_read_xattr_bucket(bucket, blkno);
2373 bucket.bhs, 0);
2374 if (ret) { 3134 if (ret) {
2375 mlog_errno(ret); 3135 mlog_errno(ret);
2376 goto out; 3136 break;
2377 } 3137 }
2378 3138
2379 bucket.xh = (struct ocfs2_xattr_header *)bucket.bhs[0]->b_data;
2380 /* 3139 /*
2381 * The real bucket num in this series of blocks is stored 3140 * The real bucket num in this series of blocks is stored
2382 * in the 1st bucket. 3141 * in the 1st bucket.
2383 */ 3142 */
2384 if (i == 0) 3143 if (i == 0)
2385 num_buckets = le16_to_cpu(bucket.xh->xh_num_buckets); 3144 num_buckets = le16_to_cpu(bucket_xh(bucket)->xh_num_buckets);
2386 3145
2387 mlog(0, "iterating xattr bucket %llu, first hash %u\n", 3146 mlog(0, "iterating xattr bucket %llu, first hash %u\n",
2388 (unsigned long long)blkno, 3147 (unsigned long long)blkno,
2389 le32_to_cpu(bucket.xh->xh_entries[0].xe_name_hash)); 3148 le32_to_cpu(bucket_xh(bucket)->xh_entries[0].xe_name_hash));
2390 if (func) { 3149 if (func) {
2391 ret = func(inode, &bucket, para); 3150 ret = func(inode, bucket, para);
2392 if (ret) { 3151 if (ret)
2393 mlog_errno(ret); 3152 mlog_errno(ret);
2394 break; 3153 /* Fall through to bucket_relse() */
2395 }
2396 } 3154 }
2397 3155
2398 for (j = 0; j < blk_per_bucket; j++) 3156 ocfs2_xattr_bucket_relse(bucket);
2399 brelse(bucket.bhs[j]); 3157 if (ret)
2400 memset(&bucket, 0, sizeof(bucket)); 3158 break;
2401 } 3159 }
2402 3160
2403out: 3161 ocfs2_xattr_bucket_free(bucket);
2404 for (j = 0; j < blk_per_bucket; j++)
2405 brelse(bucket.bhs[j]);
2406
2407 return ret; 3162 return ret;
2408} 3163}
2409 3164
@@ -2441,21 +3196,21 @@ static int ocfs2_list_xattr_bucket(struct inode *inode,
2441 int i, block_off, new_offset; 3196 int i, block_off, new_offset;
2442 const char *prefix, *name; 3197 const char *prefix, *name;
2443 3198
2444 for (i = 0 ; i < le16_to_cpu(bucket->xh->xh_count); i++) { 3199 for (i = 0 ; i < le16_to_cpu(bucket_xh(bucket)->xh_count); i++) {
2445 struct ocfs2_xattr_entry *entry = &bucket->xh->xh_entries[i]; 3200 struct ocfs2_xattr_entry *entry = &bucket_xh(bucket)->xh_entries[i];
2446 type = ocfs2_xattr_get_type(entry); 3201 type = ocfs2_xattr_get_type(entry);
2447 prefix = ocfs2_xattr_prefix(type); 3202 prefix = ocfs2_xattr_prefix(type);
2448 3203
2449 if (prefix) { 3204 if (prefix) {
2450 ret = ocfs2_xattr_bucket_get_name_value(inode, 3205 ret = ocfs2_xattr_bucket_get_name_value(inode,
2451 bucket->xh, 3206 bucket_xh(bucket),
2452 i, 3207 i,
2453 &block_off, 3208 &block_off,
2454 &new_offset); 3209 &new_offset);
2455 if (ret) 3210 if (ret)
2456 break; 3211 break;
2457 3212
2458 name = (const char *)bucket->bhs[block_off]->b_data + 3213 name = (const char *)bucket_block(bucket, block_off) +
2459 new_offset; 3214 new_offset;
2460 ret = ocfs2_xattr_list_entry(xl->buffer, 3215 ret = ocfs2_xattr_list_entry(xl->buffer,
2461 xl->buffer_size, 3216 xl->buffer_size,
@@ -2540,32 +3295,34 @@ static void swap_xe(void *a, void *b, int size)
2540/* 3295/*
2541 * When the ocfs2_xattr_block is filled up, new bucket will be created 3296 * When the ocfs2_xattr_block is filled up, new bucket will be created
2542 * and all the xattr entries will be moved to the new bucket. 3297 * and all the xattr entries will be moved to the new bucket.
3298 * The header goes at the start of the bucket, and the names+values are
3299 * filled from the end. This is why *target starts as the last buffer.
2543 * Note: we need to sort the entries since they are not saved in order 3300 * Note: we need to sort the entries since they are not saved in order
2544 * in the ocfs2_xattr_block. 3301 * in the ocfs2_xattr_block.
2545 */ 3302 */
2546static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode, 3303static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
2547 struct buffer_head *xb_bh, 3304 struct buffer_head *xb_bh,
2548 struct buffer_head *xh_bh, 3305 struct ocfs2_xattr_bucket *bucket)
2549 struct buffer_head *data_bh)
2550{ 3306{
2551 int i, blocksize = inode->i_sb->s_blocksize; 3307 int i, blocksize = inode->i_sb->s_blocksize;
3308 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2552 u16 offset, size, off_change; 3309 u16 offset, size, off_change;
2553 struct ocfs2_xattr_entry *xe; 3310 struct ocfs2_xattr_entry *xe;
2554 struct ocfs2_xattr_block *xb = 3311 struct ocfs2_xattr_block *xb =
2555 (struct ocfs2_xattr_block *)xb_bh->b_data; 3312 (struct ocfs2_xattr_block *)xb_bh->b_data;
2556 struct ocfs2_xattr_header *xb_xh = &xb->xb_attrs.xb_header; 3313 struct ocfs2_xattr_header *xb_xh = &xb->xb_attrs.xb_header;
2557 struct ocfs2_xattr_header *xh = 3314 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
2558 (struct ocfs2_xattr_header *)xh_bh->b_data;
2559 u16 count = le16_to_cpu(xb_xh->xh_count); 3315 u16 count = le16_to_cpu(xb_xh->xh_count);
2560 char *target = xh_bh->b_data, *src = xb_bh->b_data; 3316 char *src = xb_bh->b_data;
3317 char *target = bucket_block(bucket, blks - 1);
2561 3318
2562 mlog(0, "cp xattr from block %llu to bucket %llu\n", 3319 mlog(0, "cp xattr from block %llu to bucket %llu\n",
2563 (unsigned long long)xb_bh->b_blocknr, 3320 (unsigned long long)xb_bh->b_blocknr,
2564 (unsigned long long)xh_bh->b_blocknr); 3321 (unsigned long long)bucket_blkno(bucket));
3322
3323 for (i = 0; i < blks; i++)
3324 memset(bucket_block(bucket, i), 0, blocksize);
2565 3325
2566 memset(xh_bh->b_data, 0, blocksize);
2567 if (data_bh)
2568 memset(data_bh->b_data, 0, blocksize);
2569 /* 3326 /*
2570 * Since the xe_name_offset is based on ocfs2_xattr_header, 3327 * Since the xe_name_offset is based on ocfs2_xattr_header,
2571 * there is a offset change corresponding to the change of 3328 * there is a offset change corresponding to the change of
@@ -2577,8 +3334,6 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
2577 size = blocksize - offset; 3334 size = blocksize - offset;
2578 3335
2579 /* copy all the names and values. */ 3336 /* copy all the names and values. */
2580 if (data_bh)
2581 target = data_bh->b_data;
2582 memcpy(target + offset, src + offset, size); 3337 memcpy(target + offset, src + offset, size);
2583 3338
2584 /* Init new header now. */ 3339 /* Init new header now. */
@@ -2588,7 +3343,7 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
2588 xh->xh_free_start = cpu_to_le16(OCFS2_XATTR_BUCKET_SIZE - size); 3343 xh->xh_free_start = cpu_to_le16(OCFS2_XATTR_BUCKET_SIZE - size);
2589 3344
2590 /* copy all the entries. */ 3345 /* copy all the entries. */
2591 target = xh_bh->b_data; 3346 target = bucket_block(bucket, 0);
2592 offset = offsetof(struct ocfs2_xattr_header, xh_entries); 3347 offset = offsetof(struct ocfs2_xattr_header, xh_entries);
2593 size = count * sizeof(struct ocfs2_xattr_entry); 3348 size = count * sizeof(struct ocfs2_xattr_entry);
2594 memcpy(target + offset, (char *)xb_xh + offset, size); 3349 memcpy(target + offset, (char *)xb_xh + offset, size);
@@ -2614,73 +3369,47 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
2614 * While if the entry is in index b-tree, "bucket" indicates the 3369 * While if the entry is in index b-tree, "bucket" indicates the
2615 * real place of the xattr. 3370 * real place of the xattr.
2616 */ 3371 */
2617static int ocfs2_xattr_update_xattr_search(struct inode *inode, 3372static void ocfs2_xattr_update_xattr_search(struct inode *inode,
2618 struct ocfs2_xattr_search *xs, 3373 struct ocfs2_xattr_search *xs,
2619 struct buffer_head *old_bh, 3374 struct buffer_head *old_bh)
2620 struct buffer_head *new_bh)
2621{ 3375{
2622 int ret = 0;
2623 char *buf = old_bh->b_data; 3376 char *buf = old_bh->b_data;
2624 struct ocfs2_xattr_block *old_xb = (struct ocfs2_xattr_block *)buf; 3377 struct ocfs2_xattr_block *old_xb = (struct ocfs2_xattr_block *)buf;
2625 struct ocfs2_xattr_header *old_xh = &old_xb->xb_attrs.xb_header; 3378 struct ocfs2_xattr_header *old_xh = &old_xb->xb_attrs.xb_header;
2626 int i, blocksize = inode->i_sb->s_blocksize; 3379 int i;
2627 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2628
2629 xs->bucket.bhs[0] = new_bh;
2630 get_bh(new_bh);
2631 xs->bucket.xh = (struct ocfs2_xattr_header *)xs->bucket.bhs[0]->b_data;
2632 xs->header = xs->bucket.xh;
2633 3380
2634 xs->base = new_bh->b_data; 3381 xs->header = bucket_xh(xs->bucket);
3382 xs->base = bucket_block(xs->bucket, 0);
2635 xs->end = xs->base + inode->i_sb->s_blocksize; 3383 xs->end = xs->base + inode->i_sb->s_blocksize;
2636 3384
2637 if (!xs->not_found) { 3385 if (xs->not_found)
2638 if (OCFS2_XATTR_BUCKET_SIZE != blocksize) { 3386 return;
2639 ret = ocfs2_read_blocks(inode,
2640 xs->bucket.bhs[0]->b_blocknr + 1,
2641 blk_per_bucket - 1, &xs->bucket.bhs[1],
2642 0);
2643 if (ret) {
2644 mlog_errno(ret);
2645 return ret;
2646 }
2647
2648 }
2649 i = xs->here - old_xh->xh_entries;
2650 xs->here = &xs->header->xh_entries[i];
2651 }
2652 3387
2653 return ret; 3388 i = xs->here - old_xh->xh_entries;
3389 xs->here = &xs->header->xh_entries[i];
2654} 3390}
2655 3391
2656static int ocfs2_xattr_create_index_block(struct inode *inode, 3392static int ocfs2_xattr_create_index_block(struct inode *inode,
2657 struct ocfs2_xattr_search *xs) 3393 struct ocfs2_xattr_search *xs,
3394 struct ocfs2_xattr_set_ctxt *ctxt)
2658{ 3395{
2659 int ret, credits = OCFS2_SUBALLOC_ALLOC; 3396 int ret;
2660 u32 bit_off, len; 3397 u32 bit_off, len;
2661 u64 blkno; 3398 u64 blkno;
2662 handle_t *handle; 3399 handle_t *handle = ctxt->handle;
2663 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 3400 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2664 struct ocfs2_inode_info *oi = OCFS2_I(inode); 3401 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2665 struct ocfs2_alloc_context *data_ac;
2666 struct buffer_head *xh_bh = NULL, *data_bh = NULL;
2667 struct buffer_head *xb_bh = xs->xattr_bh; 3402 struct buffer_head *xb_bh = xs->xattr_bh;
2668 struct ocfs2_xattr_block *xb = 3403 struct ocfs2_xattr_block *xb =
2669 (struct ocfs2_xattr_block *)xb_bh->b_data; 3404 (struct ocfs2_xattr_block *)xb_bh->b_data;
2670 struct ocfs2_xattr_tree_root *xr; 3405 struct ocfs2_xattr_tree_root *xr;
2671 u16 xb_flags = le16_to_cpu(xb->xb_flags); 3406 u16 xb_flags = le16_to_cpu(xb->xb_flags);
2672 u16 bpb = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2673 3407
2674 mlog(0, "create xattr index block for %llu\n", 3408 mlog(0, "create xattr index block for %llu\n",
2675 (unsigned long long)xb_bh->b_blocknr); 3409 (unsigned long long)xb_bh->b_blocknr);
2676 3410
2677 BUG_ON(xb_flags & OCFS2_XATTR_INDEXED); 3411 BUG_ON(xb_flags & OCFS2_XATTR_INDEXED);
2678 3412 BUG_ON(!xs->bucket);
2679 ret = ocfs2_reserve_clusters(osb, 1, &data_ac);
2680 if (ret) {
2681 mlog_errno(ret);
2682 goto out;
2683 }
2684 3413
2685 /* 3414 /*
2686 * XXX: 3415 * XXX:
@@ -2689,29 +3418,18 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,
2689 */ 3418 */
2690 down_write(&oi->ip_alloc_sem); 3419 down_write(&oi->ip_alloc_sem);
2691 3420
2692 /* 3421 ret = ocfs2_journal_access_xb(handle, inode, xb_bh,
2693 * 3 more credits, one for xattr block update, one for the 1st block 3422 OCFS2_JOURNAL_ACCESS_WRITE);
2694 * of the new xattr bucket and one for the value/data.
2695 */
2696 credits += 3;
2697 handle = ocfs2_start_trans(osb, credits);
2698 if (IS_ERR(handle)) {
2699 ret = PTR_ERR(handle);
2700 mlog_errno(ret);
2701 goto out_sem;
2702 }
2703
2704 ret = ocfs2_journal_access(handle, inode, xb_bh,
2705 OCFS2_JOURNAL_ACCESS_WRITE);
2706 if (ret) { 3423 if (ret) {
2707 mlog_errno(ret); 3424 mlog_errno(ret);
2708 goto out_commit; 3425 goto out;
2709 } 3426 }
2710 3427
2711 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len); 3428 ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac,
3429 1, 1, &bit_off, &len);
2712 if (ret) { 3430 if (ret) {
2713 mlog_errno(ret); 3431 mlog_errno(ret);
2714 goto out_commit; 3432 goto out;
2715 } 3433 }
2716 3434
2717 /* 3435 /*
@@ -2724,51 +3442,23 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,
2724 mlog(0, "allocate 1 cluster from %llu to xattr block\n", 3442 mlog(0, "allocate 1 cluster from %llu to xattr block\n",
2725 (unsigned long long)blkno); 3443 (unsigned long long)blkno);
2726 3444
2727 xh_bh = sb_getblk(inode->i_sb, blkno); 3445 ret = ocfs2_init_xattr_bucket(xs->bucket, blkno);
2728 if (!xh_bh) { 3446 if (ret) {
2729 ret = -EIO;
2730 mlog_errno(ret); 3447 mlog_errno(ret);
2731 goto out_commit; 3448 goto out;
2732 } 3449 }
2733 3450
2734 ocfs2_set_new_buffer_uptodate(inode, xh_bh); 3451 ret = ocfs2_xattr_bucket_journal_access(handle, xs->bucket,
2735 3452 OCFS2_JOURNAL_ACCESS_CREATE);
2736 ret = ocfs2_journal_access(handle, inode, xh_bh,
2737 OCFS2_JOURNAL_ACCESS_CREATE);
2738 if (ret) { 3453 if (ret) {
2739 mlog_errno(ret); 3454 mlog_errno(ret);
2740 goto out_commit; 3455 goto out;
2741 }
2742
2743 if (bpb > 1) {
2744 data_bh = sb_getblk(inode->i_sb, blkno + bpb - 1);
2745 if (!data_bh) {
2746 ret = -EIO;
2747 mlog_errno(ret);
2748 goto out_commit;
2749 }
2750
2751 ocfs2_set_new_buffer_uptodate(inode, data_bh);
2752
2753 ret = ocfs2_journal_access(handle, inode, data_bh,
2754 OCFS2_JOURNAL_ACCESS_CREATE);
2755 if (ret) {
2756 mlog_errno(ret);
2757 goto out_commit;
2758 }
2759 } 3456 }
2760 3457
2761 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xh_bh, data_bh); 3458 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xs->bucket);
3459 ocfs2_xattr_bucket_journal_dirty(handle, xs->bucket);
2762 3460
2763 ocfs2_journal_dirty(handle, xh_bh); 3461 ocfs2_xattr_update_xattr_search(inode, xs, xb_bh);
2764 if (data_bh)
2765 ocfs2_journal_dirty(handle, data_bh);
2766
2767 ret = ocfs2_xattr_update_xattr_search(inode, xs, xb_bh, xh_bh);
2768 if (ret) {
2769 mlog_errno(ret);
2770 goto out_commit;
2771 }
2772 3462
2773 /* Change from ocfs2_xattr_header to ocfs2_xattr_tree_root */ 3463 /* Change from ocfs2_xattr_header to ocfs2_xattr_tree_root */
2774 memset(&xb->xb_attrs, 0, inode->i_sb->s_blocksize - 3464 memset(&xb->xb_attrs, 0, inode->i_sb->s_blocksize -
@@ -2787,24 +3477,10 @@ static int ocfs2_xattr_create_index_block(struct inode *inode,
2787 3477
2788 xb->xb_flags = cpu_to_le16(xb_flags | OCFS2_XATTR_INDEXED); 3478 xb->xb_flags = cpu_to_le16(xb_flags | OCFS2_XATTR_INDEXED);
2789 3479
2790 ret = ocfs2_journal_dirty(handle, xb_bh); 3480 ocfs2_journal_dirty(handle, xb_bh);
2791 if (ret) {
2792 mlog_errno(ret);
2793 goto out_commit;
2794 }
2795
2796out_commit:
2797 ocfs2_commit_trans(osb, handle);
2798
2799out_sem:
2800 up_write(&oi->ip_alloc_sem);
2801 3481
2802out: 3482out:
2803 if (data_ac) 3483 up_write(&oi->ip_alloc_sem);
2804 ocfs2_free_alloc_context(data_ac);
2805
2806 brelse(xh_bh);
2807 brelse(data_bh);
2808 3484
2809 return ret; 3485 return ret;
2810} 3486}
@@ -2829,29 +3505,18 @@ static int cmp_xe_offset(const void *a, const void *b)
2829 * so that we can spare some space for insertion. 3505 * so that we can spare some space for insertion.
2830 */ 3506 */
2831static int ocfs2_defrag_xattr_bucket(struct inode *inode, 3507static int ocfs2_defrag_xattr_bucket(struct inode *inode,
3508 handle_t *handle,
2832 struct ocfs2_xattr_bucket *bucket) 3509 struct ocfs2_xattr_bucket *bucket)
2833{ 3510{
2834 int ret, i; 3511 int ret, i;
2835 size_t end, offset, len, value_len; 3512 size_t end, offset, len, value_len;
2836 struct ocfs2_xattr_header *xh; 3513 struct ocfs2_xattr_header *xh;
2837 char *entries, *buf, *bucket_buf = NULL; 3514 char *entries, *buf, *bucket_buf = NULL;
2838 u64 blkno = bucket->bhs[0]->b_blocknr; 3515 u64 blkno = bucket_blkno(bucket);
2839 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
2840 u16 xh_free_start; 3516 u16 xh_free_start;
2841 size_t blocksize = inode->i_sb->s_blocksize; 3517 size_t blocksize = inode->i_sb->s_blocksize;
2842 handle_t *handle;
2843 struct buffer_head **bhs;
2844 struct ocfs2_xattr_entry *xe; 3518 struct ocfs2_xattr_entry *xe;
2845 3519
2846 bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket,
2847 GFP_NOFS);
2848 if (!bhs)
2849 return -ENOMEM;
2850
2851 ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, 0);
2852 if (ret)
2853 goto out;
2854
2855 /* 3520 /*
2856 * In order to make the operation more efficient and generic, 3521 * In order to make the operation more efficient and generic,
2857 * we copy all the blocks into a contiguous memory and do the 3522 * we copy all the blocks into a contiguous memory and do the
@@ -2865,26 +3530,16 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2865 } 3530 }
2866 3531
2867 buf = bucket_buf; 3532 buf = bucket_buf;
2868 for (i = 0; i < blk_per_bucket; i++, buf += blocksize) 3533 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
2869 memcpy(buf, bhs[i]->b_data, blocksize); 3534 memcpy(buf, bucket_block(bucket, i), blocksize);
2870 3535
2871 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), blk_per_bucket); 3536 ret = ocfs2_xattr_bucket_journal_access(handle, bucket,
2872 if (IS_ERR(handle)) { 3537 OCFS2_JOURNAL_ACCESS_WRITE);
2873 ret = PTR_ERR(handle); 3538 if (ret < 0) {
2874 handle = NULL;
2875 mlog_errno(ret); 3539 mlog_errno(ret);
2876 goto out; 3540 goto out;
2877 } 3541 }
2878 3542
2879 for (i = 0; i < blk_per_bucket; i++) {
2880 ret = ocfs2_journal_access(handle, inode, bhs[i],
2881 OCFS2_JOURNAL_ACCESS_WRITE);
2882 if (ret < 0) {
2883 mlog_errno(ret);
2884 goto commit;
2885 }
2886 }
2887
2888 xh = (struct ocfs2_xattr_header *)bucket_buf; 3543 xh = (struct ocfs2_xattr_header *)bucket_buf;
2889 entries = (char *)xh->xh_entries; 3544 entries = (char *)xh->xh_entries;
2890 xh_free_start = le16_to_cpu(xh->xh_free_start); 3545 xh_free_start = le16_to_cpu(xh->xh_free_start);
@@ -2940,7 +3595,7 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2940 "bucket %llu\n", (unsigned long long)blkno); 3595 "bucket %llu\n", (unsigned long long)blkno);
2941 3596
2942 if (xh_free_start == end) 3597 if (xh_free_start == end)
2943 goto commit; 3598 goto out;
2944 3599
2945 memset(bucket_buf + xh_free_start, 0, end - xh_free_start); 3600 memset(bucket_buf + xh_free_start, 0, end - xh_free_start);
2946 xh->xh_free_start = cpu_to_le16(end); 3601 xh->xh_free_start = cpu_to_le16(end);
@@ -2951,169 +3606,94 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
2951 cmp_xe, swap_xe); 3606 cmp_xe, swap_xe);
2952 3607
2953 buf = bucket_buf; 3608 buf = bucket_buf;
2954 for (i = 0; i < blk_per_bucket; i++, buf += blocksize) { 3609 for (i = 0; i < bucket->bu_blocks; i++, buf += blocksize)
2955 memcpy(bhs[i]->b_data, buf, blocksize); 3610 memcpy(bucket_block(bucket, i), buf, blocksize);
2956 ocfs2_journal_dirty(handle, bhs[i]); 3611 ocfs2_xattr_bucket_journal_dirty(handle, bucket);
2957 }
2958 3612
2959commit:
2960 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
2961out: 3613out:
2962
2963 if (bhs) {
2964 for (i = 0; i < blk_per_bucket; i++)
2965 brelse(bhs[i]);
2966 }
2967 kfree(bhs);
2968
2969 kfree(bucket_buf); 3614 kfree(bucket_buf);
2970 return ret; 3615 return ret;
2971} 3616}
2972 3617
2973/* 3618/*
2974 * Move half nums of the xattr bucket in the previous cluster to this new 3619 * prev_blkno points to the start of an existing extent. new_blkno
2975 * cluster. We only touch the last cluster of the previous extend record. 3620 * points to a newly allocated extent. Because we know each of our
3621 * clusters contains more than bucket, we can easily split one cluster
3622 * at a bucket boundary. So we take the last cluster of the existing
3623 * extent and split it down the middle. We move the last half of the
3624 * buckets in the last cluster of the existing extent over to the new
3625 * extent.
3626 *
3627 * first_bh is the buffer at prev_blkno so we can update the existing
3628 * extent's bucket count. header_bh is the bucket were we were hoping
3629 * to insert our xattr. If the bucket move places the target in the new
3630 * extent, we'll update first_bh and header_bh after modifying the old
3631 * extent.
2976 * 3632 *
2977 * first_bh is the first buffer_head of a series of bucket in the same 3633 * first_hash will be set as the 1st xe's name_hash in the new extent.
2978 * extent rec and header_bh is the header of one bucket in this cluster.
2979 * They will be updated if we move the data header_bh contains to the new
2980 * cluster. first_hash will be set as the 1st xe's name_hash of the new cluster.
2981 */ 3634 */
2982static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode, 3635static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode,
2983 handle_t *handle, 3636 handle_t *handle,
2984 struct buffer_head **first_bh, 3637 struct ocfs2_xattr_bucket *first,
2985 struct buffer_head **header_bh, 3638 struct ocfs2_xattr_bucket *target,
2986 u64 new_blkno, 3639 u64 new_blkno,
2987 u64 prev_blkno,
2988 u32 num_clusters, 3640 u32 num_clusters,
2989 u32 *first_hash) 3641 u32 *first_hash)
2990{ 3642{
2991 int i, ret, credits; 3643 int ret;
2992 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 3644 struct super_block *sb = inode->i_sb;
2993 int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); 3645 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(sb);
2994 int num_buckets = ocfs2_xattr_buckets_per_cluster(osb); 3646 int num_buckets = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(sb));
2995 int blocksize = inode->i_sb->s_blocksize; 3647 int to_move = num_buckets / 2;
2996 struct buffer_head *old_bh, *new_bh, *prev_bh, *new_first_bh = NULL; 3648 u64 src_blkno;
2997 struct ocfs2_xattr_header *new_xh; 3649 u64 last_cluster_blkno = bucket_blkno(first) +
2998 struct ocfs2_xattr_header *xh = 3650 ((num_clusters - 1) * ocfs2_clusters_to_blocks(sb, 1));
2999 (struct ocfs2_xattr_header *)((*first_bh)->b_data);
3000
3001 BUG_ON(le16_to_cpu(xh->xh_num_buckets) < num_buckets);
3002 BUG_ON(OCFS2_XATTR_BUCKET_SIZE == osb->s_clustersize);
3003
3004 prev_bh = *first_bh;
3005 get_bh(prev_bh);
3006 xh = (struct ocfs2_xattr_header *)prev_bh->b_data;
3007 3651
3008 prev_blkno += (num_clusters - 1) * bpc + bpc / 2; 3652 BUG_ON(le16_to_cpu(bucket_xh(first)->xh_num_buckets) < num_buckets);
3653 BUG_ON(OCFS2_XATTR_BUCKET_SIZE == OCFS2_SB(sb)->s_clustersize);
3009 3654
3010 mlog(0, "move half of xattrs in cluster %llu to %llu\n", 3655 mlog(0, "move half of xattrs in cluster %llu to %llu\n",
3011 (unsigned long long)prev_blkno, (unsigned long long)new_blkno); 3656 (unsigned long long)last_cluster_blkno, (unsigned long long)new_blkno);
3012 3657
3013 /* 3658 ret = ocfs2_mv_xattr_buckets(inode, handle, bucket_blkno(first),
3014 * We need to update the 1st half of the new cluster and 3659 last_cluster_blkno, new_blkno,
3015 * 1 more for the update of the 1st bucket of the previous 3660 to_move, first_hash);
3016 * extent record.
3017 */
3018 credits = bpc / 2 + 1;
3019 ret = ocfs2_extend_trans(handle, credits);
3020 if (ret) { 3661 if (ret) {
3021 mlog_errno(ret); 3662 mlog_errno(ret);
3022 goto out; 3663 goto out;
3023 } 3664 }
3024 3665
3025 ret = ocfs2_journal_access(handle, inode, prev_bh, 3666 /* This is the first bucket that got moved */
3026 OCFS2_JOURNAL_ACCESS_WRITE); 3667 src_blkno = last_cluster_blkno + (to_move * blks_per_bucket);
3027 if (ret) {
3028 mlog_errno(ret);
3029 goto out;
3030 }
3031 3668
3032 for (i = 0; i < bpc / 2; i++, prev_blkno++, new_blkno++) { 3669 /*
3033 old_bh = new_bh = NULL; 3670 * If the target bucket was part of the moved buckets, we need to
3034 new_bh = sb_getblk(inode->i_sb, new_blkno); 3671 * update first and target.
3035 if (!new_bh) { 3672 */
3036 ret = -EIO; 3673 if (bucket_blkno(target) >= src_blkno) {
3037 mlog_errno(ret); 3674 /* Find the block for the new target bucket */
3038 goto out; 3675 src_blkno = new_blkno +
3039 } 3676 (bucket_blkno(target) - src_blkno);
3040 3677
3041 ocfs2_set_new_buffer_uptodate(inode, new_bh); 3678 ocfs2_xattr_bucket_relse(first);
3679 ocfs2_xattr_bucket_relse(target);
3042 3680
3043 ret = ocfs2_journal_access(handle, inode, new_bh, 3681 /*
3044 OCFS2_JOURNAL_ACCESS_CREATE); 3682 * These shouldn't fail - the buffers are in the
3045 if (ret < 0) { 3683 * journal from ocfs2_cp_xattr_bucket().
3684 */
3685 ret = ocfs2_read_xattr_bucket(first, new_blkno);
3686 if (ret) {
3046 mlog_errno(ret); 3687 mlog_errno(ret);
3047 brelse(new_bh);
3048 goto out; 3688 goto out;
3049 } 3689 }
3050 3690 ret = ocfs2_read_xattr_bucket(target, src_blkno);
3051 ret = ocfs2_read_block(inode, prev_blkno, &old_bh); 3691 if (ret)
3052 if (ret < 0) {
3053 mlog_errno(ret); 3692 mlog_errno(ret);
3054 brelse(new_bh);
3055 goto out;
3056 }
3057 3693
3058 memcpy(new_bh->b_data, old_bh->b_data, blocksize);
3059
3060 if (i == 0) {
3061 new_xh = (struct ocfs2_xattr_header *)new_bh->b_data;
3062 new_xh->xh_num_buckets = cpu_to_le16(num_buckets / 2);
3063
3064 if (first_hash)
3065 *first_hash = le32_to_cpu(
3066 new_xh->xh_entries[0].xe_name_hash);
3067 new_first_bh = new_bh;
3068 get_bh(new_first_bh);
3069 }
3070
3071 ocfs2_journal_dirty(handle, new_bh);
3072
3073 if (*header_bh == old_bh) {
3074 brelse(*header_bh);
3075 *header_bh = new_bh;
3076 get_bh(*header_bh);
3077
3078 brelse(*first_bh);
3079 *first_bh = new_first_bh;
3080 get_bh(*first_bh);
3081 }
3082 brelse(new_bh);
3083 brelse(old_bh);
3084 } 3694 }
3085 3695
3086 le16_add_cpu(&xh->xh_num_buckets, -(num_buckets / 2));
3087
3088 ocfs2_journal_dirty(handle, prev_bh);
3089out: 3696out:
3090 brelse(prev_bh);
3091 brelse(new_first_bh);
3092 return ret;
3093}
3094
3095static int ocfs2_read_xattr_bucket(struct inode *inode,
3096 u64 blkno,
3097 struct buffer_head **bhs,
3098 int new)
3099{
3100 int ret = 0;
3101 u16 i, blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3102
3103 if (!new)
3104 return ocfs2_read_blocks(inode, blkno,
3105 blk_per_bucket, bhs, 0);
3106
3107 for (i = 0; i < blk_per_bucket; i++) {
3108 bhs[i] = sb_getblk(inode->i_sb, blkno + i);
3109 if (bhs[i] == NULL) {
3110 ret = -EIO;
3111 mlog_errno(ret);
3112 break;
3113 }
3114 ocfs2_set_new_buffer_uptodate(inode, bhs[i]);
3115 }
3116
3117 return ret; 3697 return ret;
3118} 3698}
3119 3699
@@ -3178,8 +3758,7 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
3178{ 3758{
3179 int ret, i; 3759 int ret, i;
3180 int count, start, len, name_value_len = 0, xe_len, name_offset = 0; 3760 int count, start, len, name_value_len = 0, xe_len, name_offset = 0;
3181 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 3761 struct ocfs2_xattr_bucket *s_bucket = NULL, *t_bucket = NULL;
3182 struct buffer_head **s_bhs, **t_bhs = NULL;
3183 struct ocfs2_xattr_header *xh; 3762 struct ocfs2_xattr_header *xh;
3184 struct ocfs2_xattr_entry *xe; 3763 struct ocfs2_xattr_entry *xe;
3185 int blocksize = inode->i_sb->s_blocksize; 3764 int blocksize = inode->i_sb->s_blocksize;
@@ -3187,47 +3766,52 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
3187 mlog(0, "move some of xattrs from bucket %llu to %llu\n", 3766 mlog(0, "move some of xattrs from bucket %llu to %llu\n",
3188 (unsigned long long)blk, (unsigned long long)new_blk); 3767 (unsigned long long)blk, (unsigned long long)new_blk);
3189 3768
3190 s_bhs = kcalloc(blk_per_bucket, sizeof(struct buffer_head *), GFP_NOFS); 3769 s_bucket = ocfs2_xattr_bucket_new(inode);
3191 if (!s_bhs) 3770 t_bucket = ocfs2_xattr_bucket_new(inode);
3192 return -ENOMEM; 3771 if (!s_bucket || !t_bucket) {
3193 3772 ret = -ENOMEM;
3194 ret = ocfs2_read_xattr_bucket(inode, blk, s_bhs, 0);
3195 if (ret) {
3196 mlog_errno(ret); 3773 mlog_errno(ret);
3197 goto out; 3774 goto out;
3198 } 3775 }
3199 3776
3200 ret = ocfs2_journal_access(handle, inode, s_bhs[0], 3777 ret = ocfs2_read_xattr_bucket(s_bucket, blk);
3201 OCFS2_JOURNAL_ACCESS_WRITE);
3202 if (ret) { 3778 if (ret) {
3203 mlog_errno(ret); 3779 mlog_errno(ret);
3204 goto out; 3780 goto out;
3205 } 3781 }
3206 3782
3207 t_bhs = kcalloc(blk_per_bucket, sizeof(struct buffer_head *), GFP_NOFS); 3783 ret = ocfs2_xattr_bucket_journal_access(handle, s_bucket,
3208 if (!t_bhs) { 3784 OCFS2_JOURNAL_ACCESS_WRITE);
3209 ret = -ENOMEM; 3785 if (ret) {
3786 mlog_errno(ret);
3210 goto out; 3787 goto out;
3211 } 3788 }
3212 3789
3213 ret = ocfs2_read_xattr_bucket(inode, new_blk, t_bhs, new_bucket_head); 3790 /*
3791 * Even if !new_bucket_head, we're overwriting t_bucket. Thus,
3792 * there's no need to read it.
3793 */
3794 ret = ocfs2_init_xattr_bucket(t_bucket, new_blk);
3214 if (ret) { 3795 if (ret) {
3215 mlog_errno(ret); 3796 mlog_errno(ret);
3216 goto out; 3797 goto out;
3217 } 3798 }
3218 3799
3219 for (i = 0; i < blk_per_bucket; i++) { 3800 /*
3220 ret = ocfs2_journal_access(handle, inode, t_bhs[i], 3801 * Hey, if we're overwriting t_bucket, what difference does
3221 new_bucket_head ? 3802 * ACCESS_CREATE vs ACCESS_WRITE make? See the comment in the
3222 OCFS2_JOURNAL_ACCESS_CREATE : 3803 * same part of ocfs2_cp_xattr_bucket().
3223 OCFS2_JOURNAL_ACCESS_WRITE); 3804 */
3224 if (ret) { 3805 ret = ocfs2_xattr_bucket_journal_access(handle, t_bucket,
3225 mlog_errno(ret); 3806 new_bucket_head ?
3226 goto out; 3807 OCFS2_JOURNAL_ACCESS_CREATE :
3227 } 3808 OCFS2_JOURNAL_ACCESS_WRITE);
3809 if (ret) {
3810 mlog_errno(ret);
3811 goto out;
3228 } 3812 }
3229 3813
3230 xh = (struct ocfs2_xattr_header *)s_bhs[0]->b_data; 3814 xh = bucket_xh(s_bucket);
3231 count = le16_to_cpu(xh->xh_count); 3815 count = le16_to_cpu(xh->xh_count);
3232 start = ocfs2_xattr_find_divide_pos(xh); 3816 start = ocfs2_xattr_find_divide_pos(xh);
3233 3817
@@ -3239,10 +3823,10 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
3239 * The hash value is set as one larger than 3823 * The hash value is set as one larger than
3240 * that of the last entry in the previous bucket. 3824 * that of the last entry in the previous bucket.
3241 */ 3825 */
3242 for (i = 0; i < blk_per_bucket; i++) 3826 for (i = 0; i < t_bucket->bu_blocks; i++)
3243 memset(t_bhs[i]->b_data, 0, blocksize); 3827 memset(bucket_block(t_bucket, i), 0, blocksize);
3244 3828
3245 xh = (struct ocfs2_xattr_header *)t_bhs[0]->b_data; 3829 xh = bucket_xh(t_bucket);
3246 xh->xh_free_start = cpu_to_le16(blocksize); 3830 xh->xh_free_start = cpu_to_le16(blocksize);
3247 xh->xh_entries[0].xe_name_hash = xe->xe_name_hash; 3831 xh->xh_entries[0].xe_name_hash = xe->xe_name_hash;
3248 le32_add_cpu(&xh->xh_entries[0].xe_name_hash, 1); 3832 le32_add_cpu(&xh->xh_entries[0].xe_name_hash, 1);
@@ -3251,11 +3835,10 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode,
3251 } 3835 }
3252 3836
3253 /* copy the whole bucket to the new first. */ 3837 /* copy the whole bucket to the new first. */
3254 for (i = 0; i < blk_per_bucket; i++) 3838 ocfs2_xattr_bucket_copy_data(t_bucket, s_bucket);
3255 memcpy(t_bhs[i]->b_data, s_bhs[i]->b_data, blocksize);
3256 3839
3257 /* update the new bucket. */ 3840 /* update the new bucket. */
3258 xh = (struct ocfs2_xattr_header *)t_bhs[0]->b_data; 3841 xh = bucket_xh(t_bucket);
3259 3842
3260 /* 3843 /*
3261 * Calculate the total name/value len and xh_free_start for 3844 * Calculate the total name/value len and xh_free_start for
@@ -3319,11 +3902,7 @@ set_num_buckets:
3319 else 3902 else
3320 xh->xh_num_buckets = 0; 3903 xh->xh_num_buckets = 0;
3321 3904
3322 for (i = 0; i < blk_per_bucket; i++) { 3905 ocfs2_xattr_bucket_journal_dirty(handle, t_bucket);
3323 ocfs2_journal_dirty(handle, t_bhs[i]);
3324 if (ret)
3325 mlog_errno(ret);
3326 }
3327 3906
3328 /* store the first_hash of the new bucket. */ 3907 /* store the first_hash of the new bucket. */
3329 if (first_hash) 3908 if (first_hash)
@@ -3337,29 +3916,18 @@ set_num_buckets:
3337 if (start == count) 3916 if (start == count)
3338 goto out; 3917 goto out;
3339 3918
3340 xh = (struct ocfs2_xattr_header *)s_bhs[0]->b_data; 3919 xh = bucket_xh(s_bucket);
3341 memset(&xh->xh_entries[start], 0, 3920 memset(&xh->xh_entries[start], 0,
3342 sizeof(struct ocfs2_xattr_entry) * (count - start)); 3921 sizeof(struct ocfs2_xattr_entry) * (count - start));
3343 xh->xh_count = cpu_to_le16(start); 3922 xh->xh_count = cpu_to_le16(start);
3344 xh->xh_free_start = cpu_to_le16(name_offset); 3923 xh->xh_free_start = cpu_to_le16(name_offset);
3345 xh->xh_name_value_len = cpu_to_le16(name_value_len); 3924 xh->xh_name_value_len = cpu_to_le16(name_value_len);
3346 3925
3347 ocfs2_journal_dirty(handle, s_bhs[0]); 3926 ocfs2_xattr_bucket_journal_dirty(handle, s_bucket);
3348 if (ret)
3349 mlog_errno(ret);
3350 3927
3351out: 3928out:
3352 if (s_bhs) { 3929 ocfs2_xattr_bucket_free(s_bucket);
3353 for (i = 0; i < blk_per_bucket; i++) 3930 ocfs2_xattr_bucket_free(t_bucket);
3354 brelse(s_bhs[i]);
3355 }
3356 kfree(s_bhs);
3357
3358 if (t_bhs) {
3359 for (i = 0; i < blk_per_bucket; i++)
3360 brelse(t_bhs[i]);
3361 }
3362 kfree(t_bhs);
3363 3931
3364 return ret; 3932 return ret;
3365} 3933}
@@ -3376,10 +3944,8 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
3376 u64 t_blkno, 3944 u64 t_blkno,
3377 int t_is_new) 3945 int t_is_new)
3378{ 3946{
3379 int ret, i; 3947 int ret;
3380 int blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 3948 struct ocfs2_xattr_bucket *s_bucket = NULL, *t_bucket = NULL;
3381 int blocksize = inode->i_sb->s_blocksize;
3382 struct buffer_head **s_bhs, **t_bhs = NULL;
3383 3949
3384 BUG_ON(s_blkno == t_blkno); 3950 BUG_ON(s_blkno == t_blkno);
3385 3951
@@ -3387,92 +3953,115 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode,
3387 (unsigned long long)s_blkno, (unsigned long long)t_blkno, 3953 (unsigned long long)s_blkno, (unsigned long long)t_blkno,
3388 t_is_new); 3954 t_is_new);
3389 3955
3390 s_bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket, 3956 s_bucket = ocfs2_xattr_bucket_new(inode);
3391 GFP_NOFS); 3957 t_bucket = ocfs2_xattr_bucket_new(inode);
3392 if (!s_bhs) 3958 if (!s_bucket || !t_bucket) {
3393 return -ENOMEM; 3959 ret = -ENOMEM;
3960 mlog_errno(ret);
3961 goto out;
3962 }
3394 3963
3395 ret = ocfs2_read_xattr_bucket(inode, s_blkno, s_bhs, 0); 3964 ret = ocfs2_read_xattr_bucket(s_bucket, s_blkno);
3396 if (ret) 3965 if (ret)
3397 goto out; 3966 goto out;
3398 3967
3399 t_bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket, 3968 /*
3400 GFP_NOFS); 3969 * Even if !t_is_new, we're overwriting t_bucket. Thus,
3401 if (!t_bhs) { 3970 * there's no need to read it.
3402 ret = -ENOMEM; 3971 */
3972 ret = ocfs2_init_xattr_bucket(t_bucket, t_blkno);
3973 if (ret)
3403 goto out; 3974 goto out;
3404 }
3405 3975
3406 ret = ocfs2_read_xattr_bucket(inode, t_blkno, t_bhs, t_is_new); 3976 /*
3977 * Hey, if we're overwriting t_bucket, what difference does
3978 * ACCESS_CREATE vs ACCESS_WRITE make? Well, if we allocated a new
3979 * cluster to fill, we came here from
3980 * ocfs2_mv_xattr_buckets(), and it is really new -
3981 * ACCESS_CREATE is required. But we also might have moved data
3982 * out of t_bucket before extending back into it.
3983 * ocfs2_add_new_xattr_bucket() can do this - its call to
3984 * ocfs2_add_new_xattr_cluster() may have created a new extent
3985 * and copied out the end of the old extent. Then it re-extends
3986 * the old extent back to create space for new xattrs. That's
3987 * how we get here, and the bucket isn't really new.
3988 */
3989 ret = ocfs2_xattr_bucket_journal_access(handle, t_bucket,
3990 t_is_new ?
3991 OCFS2_JOURNAL_ACCESS_CREATE :
3992 OCFS2_JOURNAL_ACCESS_WRITE);
3407 if (ret) 3993 if (ret)
3408 goto out; 3994 goto out;
3409 3995
3410 for (i = 0; i < blk_per_bucket; i++) { 3996 ocfs2_xattr_bucket_copy_data(t_bucket, s_bucket);
3411 ret = ocfs2_journal_access(handle, inode, t_bhs[i], 3997 ocfs2_xattr_bucket_journal_dirty(handle, t_bucket);
3412 t_is_new ?
3413 OCFS2_JOURNAL_ACCESS_CREATE :
3414 OCFS2_JOURNAL_ACCESS_WRITE);
3415 if (ret)
3416 goto out;
3417 }
3418
3419 for (i = 0; i < blk_per_bucket; i++) {
3420 memcpy(t_bhs[i]->b_data, s_bhs[i]->b_data, blocksize);
3421 ocfs2_journal_dirty(handle, t_bhs[i]);
3422 }
3423 3998
3424out: 3999out:
3425 if (s_bhs) { 4000 ocfs2_xattr_bucket_free(t_bucket);
3426 for (i = 0; i < blk_per_bucket; i++) 4001 ocfs2_xattr_bucket_free(s_bucket);
3427 brelse(s_bhs[i]);
3428 }
3429 kfree(s_bhs);
3430
3431 if (t_bhs) {
3432 for (i = 0; i < blk_per_bucket; i++)
3433 brelse(t_bhs[i]);
3434 }
3435 kfree(t_bhs);
3436 4002
3437 return ret; 4003 return ret;
3438} 4004}
3439 4005
3440/* 4006/*
3441 * Copy one xattr cluster from src_blk to to_blk. 4007 * src_blk points to the start of an existing extent. last_blk points to
3442 * The to_blk will become the first bucket header of the cluster, so its 4008 * last cluster in that extent. to_blk points to a newly allocated
3443 * xh_num_buckets will be initialized as the bucket num in the cluster. 4009 * extent. We copy the buckets from the cluster at last_blk to the new
4010 * extent. If start_bucket is non-zero, we skip that many buckets before
4011 * we start copying. The new extent's xh_num_buckets gets set to the
4012 * number of buckets we copied. The old extent's xh_num_buckets shrinks
4013 * by the same amount.
3444 */ 4014 */
3445static int ocfs2_cp_xattr_cluster(struct inode *inode, 4015static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
3446 handle_t *handle, 4016 u64 src_blk, u64 last_blk, u64 to_blk,
3447 struct buffer_head *first_bh, 4017 unsigned int start_bucket,
3448 u64 src_blk,
3449 u64 to_blk,
3450 u32 *first_hash) 4018 u32 *first_hash)
3451{ 4019{
3452 int i, ret, credits; 4020 int i, ret, credits;
3453 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 4021 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3454 int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); 4022 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3455 int num_buckets = ocfs2_xattr_buckets_per_cluster(osb); 4023 int num_buckets = ocfs2_xattr_buckets_per_cluster(osb);
3456 struct buffer_head *bh = NULL; 4024 struct ocfs2_xattr_bucket *old_first, *new_first;
3457 struct ocfs2_xattr_header *xh; 4025
3458 u64 to_blk_start = to_blk; 4026 mlog(0, "mv xattrs from cluster %llu to %llu\n",
4027 (unsigned long long)last_blk, (unsigned long long)to_blk);
4028
4029 BUG_ON(start_bucket >= num_buckets);
4030 if (start_bucket) {
4031 num_buckets -= start_bucket;
4032 last_blk += (start_bucket * blks_per_bucket);
4033 }
4034
4035 /* The first bucket of the original extent */
4036 old_first = ocfs2_xattr_bucket_new(inode);
4037 /* The first bucket of the new extent */
4038 new_first = ocfs2_xattr_bucket_new(inode);
4039 if (!old_first || !new_first) {
4040 ret = -ENOMEM;
4041 mlog_errno(ret);
4042 goto out;
4043 }
3459 4044
3460 mlog(0, "cp xattrs from cluster %llu to %llu\n", 4045 ret = ocfs2_read_xattr_bucket(old_first, src_blk);
3461 (unsigned long long)src_blk, (unsigned long long)to_blk); 4046 if (ret) {
4047 mlog_errno(ret);
4048 goto out;
4049 }
3462 4050
3463 /* 4051 /*
3464 * We need to update the new cluster and 1 more for the update of 4052 * We need to update the first bucket of the old extent and all
3465 * the 1st bucket of the previous extent rec. 4053 * the buckets going to the new extent.
3466 */ 4054 */
3467 credits = bpc + 1; 4055 credits = ((num_buckets + 1) * blks_per_bucket) +
4056 handle->h_buffer_credits;
3468 ret = ocfs2_extend_trans(handle, credits); 4057 ret = ocfs2_extend_trans(handle, credits);
3469 if (ret) { 4058 if (ret) {
3470 mlog_errno(ret); 4059 mlog_errno(ret);
3471 goto out; 4060 goto out;
3472 } 4061 }
3473 4062
3474 ret = ocfs2_journal_access(handle, inode, first_bh, 4063 ret = ocfs2_xattr_bucket_journal_access(handle, old_first,
3475 OCFS2_JOURNAL_ACCESS_WRITE); 4064 OCFS2_JOURNAL_ACCESS_WRITE);
3476 if (ret) { 4065 if (ret) {
3477 mlog_errno(ret); 4066 mlog_errno(ret);
3478 goto out; 4067 goto out;
@@ -3480,45 +4069,45 @@ static int ocfs2_cp_xattr_cluster(struct inode *inode,
3480 4069
3481 for (i = 0; i < num_buckets; i++) { 4070 for (i = 0; i < num_buckets; i++) {
3482 ret = ocfs2_cp_xattr_bucket(inode, handle, 4071 ret = ocfs2_cp_xattr_bucket(inode, handle,
3483 src_blk, to_blk, 1); 4072 last_blk + (i * blks_per_bucket),
4073 to_blk + (i * blks_per_bucket),
4074 1);
3484 if (ret) { 4075 if (ret) {
3485 mlog_errno(ret); 4076 mlog_errno(ret);
3486 goto out; 4077 goto out;
3487 } 4078 }
3488
3489 src_blk += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3490 to_blk += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3491 } 4079 }
3492 4080
3493 /* update the old bucket header. */ 4081 /*
3494 xh = (struct ocfs2_xattr_header *)first_bh->b_data; 4082 * Get the new bucket ready before we dirty anything
3495 le16_add_cpu(&xh->xh_num_buckets, -num_buckets); 4083 * (This actually shouldn't fail, because we already dirtied
3496 4084 * it once in ocfs2_cp_xattr_bucket()).
3497 ocfs2_journal_dirty(handle, first_bh); 4085 */
3498 4086 ret = ocfs2_read_xattr_bucket(new_first, to_blk);
3499 /* update the new bucket header. */ 4087 if (ret) {
3500 ret = ocfs2_read_block(inode, to_blk_start, &bh);
3501 if (ret < 0) {
3502 mlog_errno(ret); 4088 mlog_errno(ret);
3503 goto out; 4089 goto out;
3504 } 4090 }
3505 4091 ret = ocfs2_xattr_bucket_journal_access(handle, new_first,
3506 ret = ocfs2_journal_access(handle, inode, bh, 4092 OCFS2_JOURNAL_ACCESS_WRITE);
3507 OCFS2_JOURNAL_ACCESS_WRITE);
3508 if (ret) { 4093 if (ret) {
3509 mlog_errno(ret); 4094 mlog_errno(ret);
3510 goto out; 4095 goto out;
3511 } 4096 }
3512 4097
3513 xh = (struct ocfs2_xattr_header *)bh->b_data; 4098 /* Now update the headers */
3514 xh->xh_num_buckets = cpu_to_le16(num_buckets); 4099 le16_add_cpu(&bucket_xh(old_first)->xh_num_buckets, -num_buckets);
4100 ocfs2_xattr_bucket_journal_dirty(handle, old_first);
3515 4101
3516 ocfs2_journal_dirty(handle, bh); 4102 bucket_xh(new_first)->xh_num_buckets = cpu_to_le16(num_buckets);
4103 ocfs2_xattr_bucket_journal_dirty(handle, new_first);
3517 4104
3518 if (first_hash) 4105 if (first_hash)
3519 *first_hash = le32_to_cpu(xh->xh_entries[0].xe_name_hash); 4106 *first_hash = le32_to_cpu(bucket_xh(new_first)->xh_entries[0].xe_name_hash);
4107
3520out: 4108out:
3521 brelse(bh); 4109 ocfs2_xattr_bucket_free(new_first);
4110 ocfs2_xattr_bucket_free(old_first);
3522 return ret; 4111 return ret;
3523} 4112}
3524 4113
@@ -3534,7 +4123,7 @@ static int ocfs2_divide_xattr_cluster(struct inode *inode,
3534 u32 *first_hash) 4123 u32 *first_hash)
3535{ 4124{
3536 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 4125 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3537 int ret, credits = 2 * blk_per_bucket; 4126 int ret, credits = 2 * blk_per_bucket + handle->h_buffer_credits;
3538 4127
3539 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize); 4128 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize);
3540 4129
@@ -3577,43 +4166,49 @@ static int ocfs2_divide_xattr_cluster(struct inode *inode,
3577 */ 4166 */
3578static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode, 4167static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
3579 handle_t *handle, 4168 handle_t *handle,
3580 struct buffer_head **first_bh, 4169 struct ocfs2_xattr_bucket *first,
3581 struct buffer_head **header_bh, 4170 struct ocfs2_xattr_bucket *target,
3582 u64 new_blk, 4171 u64 new_blk,
3583 u64 prev_blk,
3584 u32 prev_clusters, 4172 u32 prev_clusters,
3585 u32 *v_start, 4173 u32 *v_start,
3586 int *extend) 4174 int *extend)
3587{ 4175{
3588 int ret = 0; 4176 int ret;
3589 int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
3590 4177
3591 mlog(0, "adjust xattrs from cluster %llu len %u to %llu\n", 4178 mlog(0, "adjust xattrs from cluster %llu len %u to %llu\n",
3592 (unsigned long long)prev_blk, prev_clusters, 4179 (unsigned long long)bucket_blkno(first), prev_clusters,
3593 (unsigned long long)new_blk); 4180 (unsigned long long)new_blk);
3594 4181
3595 if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) 4182 if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) {
3596 ret = ocfs2_mv_xattr_bucket_cross_cluster(inode, 4183 ret = ocfs2_mv_xattr_bucket_cross_cluster(inode,
3597 handle, 4184 handle,
3598 first_bh, 4185 first, target,
3599 header_bh,
3600 new_blk, 4186 new_blk,
3601 prev_blk,
3602 prev_clusters, 4187 prev_clusters,
3603 v_start); 4188 v_start);
3604 else { 4189 if (ret)
3605 u64 last_blk = prev_blk + bpc * (prev_clusters - 1); 4190 mlog_errno(ret);
3606 4191 } else {
3607 if (prev_clusters > 1 && (*header_bh)->b_blocknr != last_blk) 4192 /* The start of the last cluster in the first extent */
3608 ret = ocfs2_cp_xattr_cluster(inode, handle, *first_bh, 4193 u64 last_blk = bucket_blkno(first) +
3609 last_blk, new_blk, 4194 ((prev_clusters - 1) *
4195 ocfs2_clusters_to_blocks(inode->i_sb, 1));
4196
4197 if (prev_clusters > 1 && bucket_blkno(target) != last_blk) {
4198 ret = ocfs2_mv_xattr_buckets(inode, handle,
4199 bucket_blkno(first),
4200 last_blk, new_blk, 0,
3610 v_start); 4201 v_start);
3611 else { 4202 if (ret)
4203 mlog_errno(ret);
4204 } else {
3612 ret = ocfs2_divide_xattr_cluster(inode, handle, 4205 ret = ocfs2_divide_xattr_cluster(inode, handle,
3613 last_blk, new_blk, 4206 last_blk, new_blk,
3614 v_start); 4207 v_start);
4208 if (ret)
4209 mlog_errno(ret);
3615 4210
3616 if ((*header_bh)->b_blocknr == last_blk && extend) 4211 if ((bucket_blkno(target) == last_blk) && extend)
3617 *extend = 0; 4212 *extend = 0;
3618 } 4213 }
3619 } 4214 }
@@ -3639,56 +4234,37 @@ static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
3639 */ 4234 */
3640static int ocfs2_add_new_xattr_cluster(struct inode *inode, 4235static int ocfs2_add_new_xattr_cluster(struct inode *inode,
3641 struct buffer_head *root_bh, 4236 struct buffer_head *root_bh,
3642 struct buffer_head **first_bh, 4237 struct ocfs2_xattr_bucket *first,
3643 struct buffer_head **header_bh, 4238 struct ocfs2_xattr_bucket *target,
3644 u32 *num_clusters, 4239 u32 *num_clusters,
3645 u32 prev_cpos, 4240 u32 prev_cpos,
3646 u64 prev_blkno, 4241 int *extend,
3647 int *extend) 4242 struct ocfs2_xattr_set_ctxt *ctxt)
3648{ 4243{
3649 int ret, credits; 4244 int ret;
3650 u16 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); 4245 u16 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
3651 u32 prev_clusters = *num_clusters; 4246 u32 prev_clusters = *num_clusters;
3652 u32 clusters_to_add = 1, bit_off, num_bits, v_start = 0; 4247 u32 clusters_to_add = 1, bit_off, num_bits, v_start = 0;
3653 u64 block; 4248 u64 block;
3654 handle_t *handle = NULL; 4249 handle_t *handle = ctxt->handle;
3655 struct ocfs2_alloc_context *data_ac = NULL;
3656 struct ocfs2_alloc_context *meta_ac = NULL;
3657 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 4250 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3658 struct ocfs2_extent_tree et; 4251 struct ocfs2_extent_tree et;
3659 4252
3660 mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, " 4253 mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, "
3661 "previous xattr blkno = %llu\n", 4254 "previous xattr blkno = %llu\n",
3662 (unsigned long long)OCFS2_I(inode)->ip_blkno, 4255 (unsigned long long)OCFS2_I(inode)->ip_blkno,
3663 prev_cpos, (unsigned long long)prev_blkno); 4256 prev_cpos, (unsigned long long)bucket_blkno(first));
3664 4257
3665 ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh); 4258 ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
3666 4259
3667 ret = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, 4260 ret = ocfs2_journal_access_xb(handle, inode, root_bh,
3668 &data_ac, &meta_ac); 4261 OCFS2_JOURNAL_ACCESS_WRITE);
3669 if (ret) {
3670 mlog_errno(ret);
3671 goto leave;
3672 }
3673
3674 credits = ocfs2_calc_extend_credits(osb->sb, et.et_root_el,
3675 clusters_to_add);
3676 handle = ocfs2_start_trans(osb, credits);
3677 if (IS_ERR(handle)) {
3678 ret = PTR_ERR(handle);
3679 handle = NULL;
3680 mlog_errno(ret);
3681 goto leave;
3682 }
3683
3684 ret = ocfs2_journal_access(handle, inode, root_bh,
3685 OCFS2_JOURNAL_ACCESS_WRITE);
3686 if (ret < 0) { 4262 if (ret < 0) {
3687 mlog_errno(ret); 4263 mlog_errno(ret);
3688 goto leave; 4264 goto leave;
3689 } 4265 }
3690 4266
3691 ret = __ocfs2_claim_clusters(osb, handle, data_ac, 1, 4267 ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac, 1,
3692 clusters_to_add, &bit_off, &num_bits); 4268 clusters_to_add, &bit_off, &num_bits);
3693 if (ret < 0) { 4269 if (ret < 0) {
3694 if (ret != -ENOSPC) 4270 if (ret != -ENOSPC)
@@ -3702,7 +4278,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
3702 mlog(0, "Allocating %u clusters at block %u for xattr in inode %llu\n", 4278 mlog(0, "Allocating %u clusters at block %u for xattr in inode %llu\n",
3703 num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno); 4279 num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno);
3704 4280
3705 if (prev_blkno + prev_clusters * bpc == block && 4281 if (bucket_blkno(first) + (prev_clusters * bpc) == block &&
3706 (prev_clusters + num_bits) << osb->s_clustersize_bits <= 4282 (prev_clusters + num_bits) << osb->s_clustersize_bits <=
3707 OCFS2_MAX_XATTR_TREE_LEAF_SIZE) { 4283 OCFS2_MAX_XATTR_TREE_LEAF_SIZE) {
3708 /* 4284 /*
@@ -3721,10 +4297,9 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
3721 } else { 4297 } else {
3722 ret = ocfs2_adjust_xattr_cross_cluster(inode, 4298 ret = ocfs2_adjust_xattr_cross_cluster(inode,
3723 handle, 4299 handle,
3724 first_bh, 4300 first,
3725 header_bh, 4301 target,
3726 block, 4302 block,
3727 prev_blkno,
3728 prev_clusters, 4303 prev_clusters,
3729 &v_start, 4304 &v_start,
3730 extend); 4305 extend);
@@ -3734,149 +4309,137 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
3734 } 4309 }
3735 } 4310 }
3736 4311
3737 if (handle->h_buffer_credits < credits) {
3738 /*
3739 * The journal has been restarted before, and don't
3740 * have enough space for the insertion, so extend it
3741 * here.
3742 */
3743 ret = ocfs2_extend_trans(handle, credits);
3744 if (ret) {
3745 mlog_errno(ret);
3746 goto leave;
3747 }
3748 }
3749 mlog(0, "Insert %u clusters at block %llu for xattr at %u\n", 4312 mlog(0, "Insert %u clusters at block %llu for xattr at %u\n",
3750 num_bits, (unsigned long long)block, v_start); 4313 num_bits, (unsigned long long)block, v_start);
3751 ret = ocfs2_insert_extent(osb, handle, inode, &et, v_start, block, 4314 ret = ocfs2_insert_extent(osb, handle, inode, &et, v_start, block,
3752 num_bits, 0, meta_ac); 4315 num_bits, 0, ctxt->meta_ac);
3753 if (ret < 0) { 4316 if (ret < 0) {
3754 mlog_errno(ret); 4317 mlog_errno(ret);
3755 goto leave; 4318 goto leave;
3756 } 4319 }
3757 4320
3758 ret = ocfs2_journal_dirty(handle, root_bh); 4321 ret = ocfs2_journal_dirty(handle, root_bh);
3759 if (ret < 0) { 4322 if (ret < 0)
3760 mlog_errno(ret); 4323 mlog_errno(ret);
3761 goto leave;
3762 }
3763 4324
3764leave: 4325leave:
3765 if (handle)
3766 ocfs2_commit_trans(osb, handle);
3767 if (data_ac)
3768 ocfs2_free_alloc_context(data_ac);
3769 if (meta_ac)
3770 ocfs2_free_alloc_context(meta_ac);
3771
3772 return ret; 4326 return ret;
3773} 4327}
3774 4328
3775/* 4329/*
3776 * Extend a new xattr bucket and move xattrs to the end one by one until 4330 * We are given an extent. 'first' is the bucket at the very front of
3777 * We meet with start_bh. Only move half of the xattrs to the bucket after it. 4331 * the extent. The extent has space for an additional bucket past
4332 * bucket_xh(first)->xh_num_buckets. 'target_blkno' is the block number
4333 * of the target bucket. We wish to shift every bucket past the target
4334 * down one, filling in that additional space. When we get back to the
4335 * target, we split the target between itself and the now-empty bucket
4336 * at target+1 (aka, target_blkno + blks_per_bucket).
3778 */ 4337 */
3779static int ocfs2_extend_xattr_bucket(struct inode *inode, 4338static int ocfs2_extend_xattr_bucket(struct inode *inode,
3780 struct buffer_head *first_bh, 4339 handle_t *handle,
3781 struct buffer_head *start_bh, 4340 struct ocfs2_xattr_bucket *first,
4341 u64 target_blk,
3782 u32 num_clusters) 4342 u32 num_clusters)
3783{ 4343{
3784 int ret, credits; 4344 int ret, credits;
3785 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 4345 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3786 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 4346 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3787 u64 start_blk = start_bh->b_blocknr, end_blk; 4347 u64 end_blk;
3788 u32 num_buckets = num_clusters * ocfs2_xattr_buckets_per_cluster(osb); 4348 u16 new_bucket = le16_to_cpu(bucket_xh(first)->xh_num_buckets);
3789 handle_t *handle;
3790 struct ocfs2_xattr_header *first_xh =
3791 (struct ocfs2_xattr_header *)first_bh->b_data;
3792 u16 bucket = le16_to_cpu(first_xh->xh_num_buckets);
3793 4349
3794 mlog(0, "extend xattr bucket in %llu, xattr extend rec starting " 4350 mlog(0, "extend xattr bucket in %llu, xattr extend rec starting "
3795 "from %llu, len = %u\n", (unsigned long long)start_blk, 4351 "from %llu, len = %u\n", (unsigned long long)target_blk,
3796 (unsigned long long)first_bh->b_blocknr, num_clusters); 4352 (unsigned long long)bucket_blkno(first), num_clusters);
3797 4353
3798 BUG_ON(bucket >= num_buckets); 4354 /* The extent must have room for an additional bucket */
4355 BUG_ON(new_bucket >=
4356 (num_clusters * ocfs2_xattr_buckets_per_cluster(osb)));
3799 4357
3800 end_blk = first_bh->b_blocknr + (bucket - 1) * blk_per_bucket; 4358 /* end_blk points to the last existing bucket */
4359 end_blk = bucket_blkno(first) + ((new_bucket - 1) * blk_per_bucket);
3801 4360
3802 /* 4361 /*
3803 * We will touch all the buckets after the start_bh(include it). 4362 * end_blk is the start of the last existing bucket.
3804 * Add one more bucket and modify the first_bh. 4363 * Thus, (end_blk - target_blk) covers the target bucket and
4364 * every bucket after it up to, but not including, the last
4365 * existing bucket. Then we add the last existing bucket, the
4366 * new bucket, and the first bucket (3 * blk_per_bucket).
3805 */ 4367 */
3806 credits = end_blk - start_blk + 2 * blk_per_bucket + 1; 4368 credits = (end_blk - target_blk) + (3 * blk_per_bucket) +
3807 handle = ocfs2_start_trans(osb, credits); 4369 handle->h_buffer_credits;
3808 if (IS_ERR(handle)) { 4370 ret = ocfs2_extend_trans(handle, credits);
3809 ret = PTR_ERR(handle); 4371 if (ret) {
3810 handle = NULL;
3811 mlog_errno(ret); 4372 mlog_errno(ret);
3812 goto out; 4373 goto out;
3813 } 4374 }
3814 4375
3815 ret = ocfs2_journal_access(handle, inode, first_bh, 4376 ret = ocfs2_xattr_bucket_journal_access(handle, first,
3816 OCFS2_JOURNAL_ACCESS_WRITE); 4377 OCFS2_JOURNAL_ACCESS_WRITE);
3817 if (ret) { 4378 if (ret) {
3818 mlog_errno(ret); 4379 mlog_errno(ret);
3819 goto commit; 4380 goto out;
3820 } 4381 }
3821 4382
3822 while (end_blk != start_blk) { 4383 while (end_blk != target_blk) {
3823 ret = ocfs2_cp_xattr_bucket(inode, handle, end_blk, 4384 ret = ocfs2_cp_xattr_bucket(inode, handle, end_blk,
3824 end_blk + blk_per_bucket, 0); 4385 end_blk + blk_per_bucket, 0);
3825 if (ret) 4386 if (ret)
3826 goto commit; 4387 goto out;
3827 end_blk -= blk_per_bucket; 4388 end_blk -= blk_per_bucket;
3828 } 4389 }
3829 4390
3830 /* Move half of the xattr in start_blk to the next bucket. */ 4391 /* Move half of the xattr in target_blkno to the next bucket. */
3831 ret = ocfs2_divide_xattr_bucket(inode, handle, start_blk, 4392 ret = ocfs2_divide_xattr_bucket(inode, handle, target_blk,
3832 start_blk + blk_per_bucket, NULL, 0); 4393 target_blk + blk_per_bucket, NULL, 0);
3833 4394
3834 le16_add_cpu(&first_xh->xh_num_buckets, 1); 4395 le16_add_cpu(&bucket_xh(first)->xh_num_buckets, 1);
3835 ocfs2_journal_dirty(handle, first_bh); 4396 ocfs2_xattr_bucket_journal_dirty(handle, first);
3836 4397
3837commit:
3838 ocfs2_commit_trans(osb, handle);
3839out: 4398out:
3840 return ret; 4399 return ret;
3841} 4400}
3842 4401
3843/* 4402/*
3844 * Add new xattr bucket in an extent record and adjust the buckets accordingly. 4403 * Add new xattr bucket in an extent record and adjust the buckets
3845 * xb_bh is the ocfs2_xattr_block. 4404 * accordingly. xb_bh is the ocfs2_xattr_block, and target is the
3846 * We will move all the buckets starting from header_bh to the next place. As 4405 * bucket we want to insert into.
3847 * for this one, half num of its xattrs will be moved to the next one. 4406 *
4407 * In the easy case, we will move all the buckets after target down by
4408 * one. Half of target's xattrs will be moved to the next bucket.
3848 * 4409 *
3849 * We will allocate a new cluster if current cluster is full and adjust 4410 * If current cluster is full, we'll allocate a new one. This may not
3850 * header_bh and first_bh if the insert place is moved to the new cluster. 4411 * be contiguous. The underlying calls will make sure that there is
4412 * space for the insert, shifting buckets around if necessary.
4413 * 'target' may be moved by those calls.
3851 */ 4414 */
3852static int ocfs2_add_new_xattr_bucket(struct inode *inode, 4415static int ocfs2_add_new_xattr_bucket(struct inode *inode,
3853 struct buffer_head *xb_bh, 4416 struct buffer_head *xb_bh,
3854 struct buffer_head *header_bh) 4417 struct ocfs2_xattr_bucket *target,
4418 struct ocfs2_xattr_set_ctxt *ctxt)
3855{ 4419{
3856 struct ocfs2_xattr_header *first_xh = NULL;
3857 struct buffer_head *first_bh = NULL;
3858 struct ocfs2_xattr_block *xb = 4420 struct ocfs2_xattr_block *xb =
3859 (struct ocfs2_xattr_block *)xb_bh->b_data; 4421 (struct ocfs2_xattr_block *)xb_bh->b_data;
3860 struct ocfs2_xattr_tree_root *xb_root = &xb->xb_attrs.xb_root; 4422 struct ocfs2_xattr_tree_root *xb_root = &xb->xb_attrs.xb_root;
3861 struct ocfs2_extent_list *el = &xb_root->xt_list; 4423 struct ocfs2_extent_list *el = &xb_root->xt_list;
3862 struct ocfs2_xattr_header *xh = 4424 u32 name_hash =
3863 (struct ocfs2_xattr_header *)header_bh->b_data; 4425 le32_to_cpu(bucket_xh(target)->xh_entries[0].xe_name_hash);
3864 u32 name_hash = le32_to_cpu(xh->xh_entries[0].xe_name_hash); 4426 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3865 struct super_block *sb = inode->i_sb;
3866 struct ocfs2_super *osb = OCFS2_SB(sb);
3867 int ret, num_buckets, extend = 1; 4427 int ret, num_buckets, extend = 1;
3868 u64 p_blkno; 4428 u64 p_blkno;
3869 u32 e_cpos, num_clusters; 4429 u32 e_cpos, num_clusters;
4430 /* The bucket at the front of the extent */
4431 struct ocfs2_xattr_bucket *first;
3870 4432
3871 mlog(0, "Add new xattr bucket starting form %llu\n", 4433 mlog(0, "Add new xattr bucket starting from %llu\n",
3872 (unsigned long long)header_bh->b_blocknr); 4434 (unsigned long long)bucket_blkno(target));
3873 4435
3874 /* 4436 /* The first bucket of the original extent */
3875 * Add refrence for header_bh here because it may be 4437 first = ocfs2_xattr_bucket_new(inode);
3876 * changed in ocfs2_add_new_xattr_cluster and we need 4438 if (!first) {
3877 * to free it in the end. 4439 ret = -ENOMEM;
3878 */ 4440 mlog_errno(ret);
3879 get_bh(header_bh); 4441 goto out;
4442 }
3880 4443
3881 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &e_cpos, 4444 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &e_cpos,
3882 &num_clusters, el); 4445 &num_clusters, el);
@@ -3885,40 +4448,45 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode,
3885 goto out; 4448 goto out;
3886 } 4449 }
3887 4450
3888 ret = ocfs2_read_block(inode, p_blkno, &first_bh); 4451 ret = ocfs2_read_xattr_bucket(first, p_blkno);
3889 if (ret) { 4452 if (ret) {
3890 mlog_errno(ret); 4453 mlog_errno(ret);
3891 goto out; 4454 goto out;
3892 } 4455 }
3893 4456
3894 num_buckets = ocfs2_xattr_buckets_per_cluster(osb) * num_clusters; 4457 num_buckets = ocfs2_xattr_buckets_per_cluster(osb) * num_clusters;
3895 first_xh = (struct ocfs2_xattr_header *)first_bh->b_data; 4458 if (num_buckets == le16_to_cpu(bucket_xh(first)->xh_num_buckets)) {
3896 4459 /*
3897 if (num_buckets == le16_to_cpu(first_xh->xh_num_buckets)) { 4460 * This can move first+target if the target bucket moves
4461 * to the new extent.
4462 */
3898 ret = ocfs2_add_new_xattr_cluster(inode, 4463 ret = ocfs2_add_new_xattr_cluster(inode,
3899 xb_bh, 4464 xb_bh,
3900 &first_bh, 4465 first,
3901 &header_bh, 4466 target,
3902 &num_clusters, 4467 &num_clusters,
3903 e_cpos, 4468 e_cpos,
3904 p_blkno, 4469 &extend,
3905 &extend); 4470 ctxt);
3906 if (ret) { 4471 if (ret) {
3907 mlog_errno(ret); 4472 mlog_errno(ret);
3908 goto out; 4473 goto out;
3909 } 4474 }
3910 } 4475 }
3911 4476
3912 if (extend) 4477 if (extend) {
3913 ret = ocfs2_extend_xattr_bucket(inode, 4478 ret = ocfs2_extend_xattr_bucket(inode,
3914 first_bh, 4479 ctxt->handle,
3915 header_bh, 4480 first,
4481 bucket_blkno(target),
3916 num_clusters); 4482 num_clusters);
3917 if (ret) 4483 if (ret)
3918 mlog_errno(ret); 4484 mlog_errno(ret);
4485 }
4486
3919out: 4487out:
3920 brelse(first_bh); 4488 ocfs2_xattr_bucket_free(first);
3921 brelse(header_bh); 4489
3922 return ret; 4490 return ret;
3923} 4491}
3924 4492
@@ -3929,7 +4497,7 @@ static inline char *ocfs2_xattr_bucket_get_val(struct inode *inode,
3929 int block_off = offs >> inode->i_sb->s_blocksize_bits; 4497 int block_off = offs >> inode->i_sb->s_blocksize_bits;
3930 4498
3931 offs = offs % inode->i_sb->s_blocksize; 4499 offs = offs % inode->i_sb->s_blocksize;
3932 return bucket->bhs[block_off]->b_data + offs; 4500 return bucket_block(bucket, block_off) + offs;
3933} 4501}
3934 4502
3935/* 4503/*
@@ -3984,7 +4552,7 @@ static void ocfs2_xattr_set_entry_normal(struct inode *inode,
3984 xe->xe_value_size = 0; 4552 xe->xe_value_size = 0;
3985 4553
3986 val = ocfs2_xattr_bucket_get_val(inode, 4554 val = ocfs2_xattr_bucket_get_val(inode,
3987 &xs->bucket, offs); 4555 xs->bucket, offs);
3988 memset(val + OCFS2_XATTR_SIZE(name_len), 0, 4556 memset(val + OCFS2_XATTR_SIZE(name_len), 0,
3989 size - OCFS2_XATTR_SIZE(name_len)); 4557 size - OCFS2_XATTR_SIZE(name_len));
3990 if (OCFS2_XATTR_SIZE(xi->value_len) > 0) 4558 if (OCFS2_XATTR_SIZE(xi->value_len) > 0)
@@ -4062,8 +4630,7 @@ set_new_name_value:
4062 xh->xh_free_start = cpu_to_le16(offs); 4630 xh->xh_free_start = cpu_to_le16(offs);
4063 } 4631 }
4064 4632
4065 val = ocfs2_xattr_bucket_get_val(inode, 4633 val = ocfs2_xattr_bucket_get_val(inode, xs->bucket, offs - size);
4066 &xs->bucket, offs - size);
4067 xe->xe_name_offset = cpu_to_le16(offs - size); 4634 xe->xe_name_offset = cpu_to_le16(offs - size);
4068 4635
4069 memset(val, 0, size); 4636 memset(val, 0, size);
@@ -4079,125 +4646,45 @@ set_new_name_value:
4079 return; 4646 return;
4080} 4647}
4081 4648
4082static int ocfs2_xattr_bucket_handle_journal(struct inode *inode,
4083 handle_t *handle,
4084 struct ocfs2_xattr_search *xs,
4085 struct buffer_head **bhs,
4086 u16 bh_num)
4087{
4088 int ret = 0, off, block_off;
4089 struct ocfs2_xattr_entry *xe = xs->here;
4090
4091 /*
4092 * First calculate all the blocks we should journal_access
4093 * and journal_dirty. The first block should always be touched.
4094 */
4095 ret = ocfs2_journal_dirty(handle, bhs[0]);
4096 if (ret)
4097 mlog_errno(ret);
4098
4099 /* calc the data. */
4100 off = le16_to_cpu(xe->xe_name_offset);
4101 block_off = off >> inode->i_sb->s_blocksize_bits;
4102 ret = ocfs2_journal_dirty(handle, bhs[block_off]);
4103 if (ret)
4104 mlog_errno(ret);
4105
4106 return ret;
4107}
4108
4109/* 4649/*
4110 * Set the xattr entry in the specified bucket. 4650 * Set the xattr entry in the specified bucket.
4111 * The bucket is indicated by xs->bucket and it should have the enough 4651 * The bucket is indicated by xs->bucket and it should have the enough
4112 * space for the xattr insertion. 4652 * space for the xattr insertion.
4113 */ 4653 */
4114static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode, 4654static int ocfs2_xattr_set_entry_in_bucket(struct inode *inode,
4655 handle_t *handle,
4115 struct ocfs2_xattr_info *xi, 4656 struct ocfs2_xattr_info *xi,
4116 struct ocfs2_xattr_search *xs, 4657 struct ocfs2_xattr_search *xs,
4117 u32 name_hash, 4658 u32 name_hash,
4118 int local) 4659 int local)
4119{ 4660{
4120 int i, ret; 4661 int ret;
4121 handle_t *handle = NULL; 4662 u64 blkno;
4122 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4123 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
4124 4663
4125 mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n", 4664 mlog(0, "Set xattr entry len = %lu index = %d in bucket %llu\n",
4126 (unsigned long)xi->value_len, xi->name_index, 4665 (unsigned long)xi->value_len, xi->name_index,
4127 (unsigned long long)xs->bucket.bhs[0]->b_blocknr); 4666 (unsigned long long)bucket_blkno(xs->bucket));
4128 4667
4129 if (!xs->bucket.bhs[1]) { 4668 if (!xs->bucket->bu_bhs[1]) {
4130 ret = ocfs2_read_blocks(inode, 4669 blkno = bucket_blkno(xs->bucket);
4131 xs->bucket.bhs[0]->b_blocknr + 1, 4670 ocfs2_xattr_bucket_relse(xs->bucket);
4132 blk_per_bucket - 1, &xs->bucket.bhs[1], 4671 ret = ocfs2_read_xattr_bucket(xs->bucket, blkno);
4133 0);
4134 if (ret) { 4672 if (ret) {
4135 mlog_errno(ret); 4673 mlog_errno(ret);
4136 goto out; 4674 goto out;
4137 } 4675 }
4138 } 4676 }
4139 4677
4140 handle = ocfs2_start_trans(osb, blk_per_bucket); 4678 ret = ocfs2_xattr_bucket_journal_access(handle, xs->bucket,
4141 if (IS_ERR(handle)) { 4679 OCFS2_JOURNAL_ACCESS_WRITE);
4142 ret = PTR_ERR(handle); 4680 if (ret < 0) {
4143 handle = NULL;
4144 mlog_errno(ret); 4681 mlog_errno(ret);
4145 goto out; 4682 goto out;
4146 } 4683 }
4147 4684
4148 for (i = 0; i < blk_per_bucket; i++) {
4149 ret = ocfs2_journal_access(handle, inode, xs->bucket.bhs[i],
4150 OCFS2_JOURNAL_ACCESS_WRITE);
4151 if (ret < 0) {
4152 mlog_errno(ret);
4153 goto out;
4154 }
4155 }
4156
4157 ocfs2_xattr_set_entry_normal(inode, xi, xs, name_hash, local); 4685 ocfs2_xattr_set_entry_normal(inode, xi, xs, name_hash, local);
4686 ocfs2_xattr_bucket_journal_dirty(handle, xs->bucket);
4158 4687
4159 /*Only dirty the blocks we have touched in set xattr. */
4160 ret = ocfs2_xattr_bucket_handle_journal(inode, handle, xs,
4161 xs->bucket.bhs, blk_per_bucket);
4162 if (ret)
4163 mlog_errno(ret);
4164out:
4165 ocfs2_commit_trans(osb, handle);
4166
4167 return ret;
4168}
4169
4170static int ocfs2_xattr_value_update_size(struct inode *inode,
4171 struct buffer_head *xe_bh,
4172 struct ocfs2_xattr_entry *xe,
4173 u64 new_size)
4174{
4175 int ret;
4176 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
4177 handle_t *handle = NULL;
4178
4179 handle = ocfs2_start_trans(osb, 1);
4180 if (IS_ERR(handle)) {
4181 ret = -ENOMEM;
4182 mlog_errno(ret);
4183 goto out;
4184 }
4185
4186 ret = ocfs2_journal_access(handle, inode, xe_bh,
4187 OCFS2_JOURNAL_ACCESS_WRITE);
4188 if (ret < 0) {
4189 mlog_errno(ret);
4190 goto out_commit;
4191 }
4192
4193 xe->xe_value_size = cpu_to_le64(new_size);
4194
4195 ret = ocfs2_journal_dirty(handle, xe_bh);
4196 if (ret < 0)
4197 mlog_errno(ret);
4198
4199out_commit:
4200 ocfs2_commit_trans(osb, handle);
4201out: 4688out:
4202 return ret; 4689 return ret;
4203} 4690}
@@ -4210,18 +4697,19 @@ out:
4210 * Copy the new updated xe and xe_value_root to new_xe and new_xv if needed. 4697 * Copy the new updated xe and xe_value_root to new_xe and new_xv if needed.
4211 */ 4698 */
4212static int ocfs2_xattr_bucket_value_truncate(struct inode *inode, 4699static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4213 struct buffer_head *header_bh, 4700 struct ocfs2_xattr_bucket *bucket,
4214 int xe_off, 4701 int xe_off,
4215 int len) 4702 int len,
4703 struct ocfs2_xattr_set_ctxt *ctxt)
4216{ 4704{
4217 int ret, offset; 4705 int ret, offset;
4218 u64 value_blk; 4706 u64 value_blk;
4219 struct buffer_head *value_bh = NULL;
4220 struct ocfs2_xattr_value_root *xv;
4221 struct ocfs2_xattr_entry *xe; 4707 struct ocfs2_xattr_entry *xe;
4222 struct ocfs2_xattr_header *xh = 4708 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4223 (struct ocfs2_xattr_header *)header_bh->b_data;
4224 size_t blocksize = inode->i_sb->s_blocksize; 4709 size_t blocksize = inode->i_sb->s_blocksize;
4710 struct ocfs2_xattr_value_buf vb = {
4711 .vb_access = ocfs2_journal_access,
4712 };
4225 4713
4226 xe = &xh->xh_entries[xe_off]; 4714 xe = &xh->xh_entries[xe_off];
4227 4715
@@ -4234,49 +4722,58 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4234 4722
4235 /* We don't allow ocfs2_xattr_value to be stored in different block. */ 4723 /* We don't allow ocfs2_xattr_value to be stored in different block. */
4236 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize); 4724 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
4237 value_blk += header_bh->b_blocknr;
4238 4725
4239 ret = ocfs2_read_block(inode, value_blk, &value_bh); 4726 vb.vb_bh = bucket->bu_bhs[value_blk];
4240 if (ret) { 4727 BUG_ON(!vb.vb_bh);
4241 mlog_errno(ret);
4242 goto out;
4243 }
4244 4728
4245 xv = (struct ocfs2_xattr_value_root *) 4729 vb.vb_xv = (struct ocfs2_xattr_value_root *)
4246 (value_bh->b_data + offset % blocksize); 4730 (vb.vb_bh->b_data + offset % blocksize);
4247 4731
4248 mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n", 4732 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
4249 xe_off, (unsigned long long)header_bh->b_blocknr, len); 4733 OCFS2_JOURNAL_ACCESS_WRITE);
4250 ret = ocfs2_xattr_value_truncate(inode, value_bh, xv, len);
4251 if (ret) { 4734 if (ret) {
4252 mlog_errno(ret); 4735 mlog_errno(ret);
4253 goto out; 4736 goto out;
4254 } 4737 }
4255 4738
4256 ret = ocfs2_xattr_value_update_size(inode, header_bh, xe, len); 4739 /*
4740 * From here on out we have to dirty the bucket. The generic
4741 * value calls only modify one of the bucket's bhs, but we need
4742 * to send the bucket at once. So if they error, they *could* have
4743 * modified something. We have to assume they did, and dirty
4744 * the whole bucket. This leaves us in a consistent state.
4745 */
4746 mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n",
4747 xe_off, (unsigned long long)bucket_blkno(bucket), len);
4748 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
4257 if (ret) { 4749 if (ret) {
4258 mlog_errno(ret); 4750 mlog_errno(ret);
4259 goto out; 4751 goto out_dirty;
4260 } 4752 }
4261 4753
4754 xe->xe_value_size = cpu_to_le64(len);
4755
4756out_dirty:
4757 ocfs2_xattr_bucket_journal_dirty(ctxt->handle, bucket);
4758
4262out: 4759out:
4263 brelse(value_bh);
4264 return ret; 4760 return ret;
4265} 4761}
4266 4762
4267static int ocfs2_xattr_bucket_value_truncate_xs(struct inode *inode, 4763static int ocfs2_xattr_bucket_value_truncate_xs(struct inode *inode,
4268 struct ocfs2_xattr_search *xs, 4764 struct ocfs2_xattr_search *xs,
4269 int len) 4765 int len,
4766 struct ocfs2_xattr_set_ctxt *ctxt)
4270{ 4767{
4271 int ret, offset; 4768 int ret, offset;
4272 struct ocfs2_xattr_entry *xe = xs->here; 4769 struct ocfs2_xattr_entry *xe = xs->here;
4273 struct ocfs2_xattr_header *xh = (struct ocfs2_xattr_header *)xs->base; 4770 struct ocfs2_xattr_header *xh = (struct ocfs2_xattr_header *)xs->base;
4274 4771
4275 BUG_ON(!xs->bucket.bhs[0] || !xe || ocfs2_xattr_is_local(xe)); 4772 BUG_ON(!xs->bucket->bu_bhs[0] || !xe || ocfs2_xattr_is_local(xe));
4276 4773
4277 offset = xe - xh->xh_entries; 4774 offset = xe - xh->xh_entries;
4278 ret = ocfs2_xattr_bucket_value_truncate(inode, xs->bucket.bhs[0], 4775 ret = ocfs2_xattr_bucket_value_truncate(inode, xs->bucket,
4279 offset, len); 4776 offset, len, ctxt);
4280 if (ret) 4777 if (ret)
4281 mlog_errno(ret); 4778 mlog_errno(ret);
4282 4779
@@ -4284,6 +4781,7 @@ static int ocfs2_xattr_bucket_value_truncate_xs(struct inode *inode,
4284} 4781}
4285 4782
4286static int ocfs2_xattr_bucket_set_value_outside(struct inode *inode, 4783static int ocfs2_xattr_bucket_set_value_outside(struct inode *inode,
4784 handle_t *handle,
4287 struct ocfs2_xattr_search *xs, 4785 struct ocfs2_xattr_search *xs,
4288 char *val, 4786 char *val,
4289 int value_len) 4787 int value_len)
@@ -4299,7 +4797,8 @@ static int ocfs2_xattr_bucket_set_value_outside(struct inode *inode,
4299 4797
4300 xv = (struct ocfs2_xattr_value_root *)(xs->base + offset); 4798 xv = (struct ocfs2_xattr_value_root *)(xs->base + offset);
4301 4799
4302 return __ocfs2_xattr_set_value_outside(inode, xv, val, value_len); 4800 return __ocfs2_xattr_set_value_outside(inode, handle,
4801 xv, val, value_len);
4303} 4802}
4304 4803
4305static int ocfs2_rm_xattr_cluster(struct inode *inode, 4804static int ocfs2_rm_xattr_cluster(struct inode *inode,
@@ -4343,15 +4842,15 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
4343 } 4842 }
4344 } 4843 }
4345 4844
4346 handle = ocfs2_start_trans(osb, OCFS2_REMOVE_EXTENT_CREDITS); 4845 handle = ocfs2_start_trans(osb, ocfs2_remove_extent_credits(osb->sb));
4347 if (IS_ERR(handle)) { 4846 if (IS_ERR(handle)) {
4348 ret = -ENOMEM; 4847 ret = -ENOMEM;
4349 mlog_errno(ret); 4848 mlog_errno(ret);
4350 goto out; 4849 goto out;
4351 } 4850 }
4352 4851
4353 ret = ocfs2_journal_access(handle, inode, root_bh, 4852 ret = ocfs2_journal_access_xb(handle, inode, root_bh,
4354 OCFS2_JOURNAL_ACCESS_WRITE); 4853 OCFS2_JOURNAL_ACCESS_WRITE);
4355 if (ret) { 4854 if (ret) {
4356 mlog_errno(ret); 4855 mlog_errno(ret);
4357 goto out_commit; 4856 goto out_commit;
@@ -4392,26 +4891,19 @@ out:
4392} 4891}
4393 4892
4394static void ocfs2_xattr_bucket_remove_xs(struct inode *inode, 4893static void ocfs2_xattr_bucket_remove_xs(struct inode *inode,
4894 handle_t *handle,
4395 struct ocfs2_xattr_search *xs) 4895 struct ocfs2_xattr_search *xs)
4396{ 4896{
4397 handle_t *handle = NULL; 4897 struct ocfs2_xattr_header *xh = bucket_xh(xs->bucket);
4398 struct ocfs2_xattr_header *xh = xs->bucket.xh;
4399 struct ocfs2_xattr_entry *last = &xh->xh_entries[ 4898 struct ocfs2_xattr_entry *last = &xh->xh_entries[
4400 le16_to_cpu(xh->xh_count) - 1]; 4899 le16_to_cpu(xh->xh_count) - 1];
4401 int ret = 0; 4900 int ret = 0;
4402 4901
4403 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), 1); 4902 ret = ocfs2_xattr_bucket_journal_access(handle, xs->bucket,
4404 if (IS_ERR(handle)) { 4903 OCFS2_JOURNAL_ACCESS_WRITE);
4405 ret = PTR_ERR(handle);
4406 mlog_errno(ret);
4407 return;
4408 }
4409
4410 ret = ocfs2_journal_access(handle, inode, xs->bucket.bhs[0],
4411 OCFS2_JOURNAL_ACCESS_WRITE);
4412 if (ret) { 4904 if (ret) {
4413 mlog_errno(ret); 4905 mlog_errno(ret);
4414 goto out_commit; 4906 return;
4415 } 4907 }
4416 4908
4417 /* Remove the old entry. */ 4909 /* Remove the old entry. */
@@ -4420,11 +4912,7 @@ static void ocfs2_xattr_bucket_remove_xs(struct inode *inode,
4420 memset(last, 0, sizeof(struct ocfs2_xattr_entry)); 4912 memset(last, 0, sizeof(struct ocfs2_xattr_entry));
4421 le16_add_cpu(&xh->xh_count, -1); 4913 le16_add_cpu(&xh->xh_count, -1);
4422 4914
4423 ret = ocfs2_journal_dirty(handle, xs->bucket.bhs[0]); 4915 ocfs2_xattr_bucket_journal_dirty(handle, xs->bucket);
4424 if (ret < 0)
4425 mlog_errno(ret);
4426out_commit:
4427 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
4428} 4916}
4429 4917
4430/* 4918/*
@@ -4440,7 +4928,8 @@ out_commit:
4440 */ 4928 */
4441static int ocfs2_xattr_set_in_bucket(struct inode *inode, 4929static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4442 struct ocfs2_xattr_info *xi, 4930 struct ocfs2_xattr_info *xi,
4443 struct ocfs2_xattr_search *xs) 4931 struct ocfs2_xattr_search *xs,
4932 struct ocfs2_xattr_set_ctxt *ctxt)
4444{ 4933{
4445 int ret, local = 1; 4934 int ret, local = 1;
4446 size_t value_len; 4935 size_t value_len;
@@ -4468,7 +4957,8 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4468 value_len = 0; 4957 value_len = 0;
4469 4958
4470 ret = ocfs2_xattr_bucket_value_truncate_xs(inode, xs, 4959 ret = ocfs2_xattr_bucket_value_truncate_xs(inode, xs,
4471 value_len); 4960 value_len,
4961 ctxt);
4472 if (ret) 4962 if (ret)
4473 goto out; 4963 goto out;
4474 4964
@@ -4488,7 +4978,8 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4488 xi->value_len = OCFS2_XATTR_ROOT_SIZE; 4978 xi->value_len = OCFS2_XATTR_ROOT_SIZE;
4489 } 4979 }
4490 4980
4491 ret = ocfs2_xattr_set_entry_in_bucket(inode, xi, xs, name_hash, local); 4981 ret = ocfs2_xattr_set_entry_in_bucket(inode, ctxt->handle, xi, xs,
4982 name_hash, local);
4492 if (ret) { 4983 if (ret) {
4493 mlog_errno(ret); 4984 mlog_errno(ret);
4494 goto out; 4985 goto out;
@@ -4499,7 +4990,7 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4499 4990
4500 /* allocate the space now for the outside block storage. */ 4991 /* allocate the space now for the outside block storage. */
4501 ret = ocfs2_xattr_bucket_value_truncate_xs(inode, xs, 4992 ret = ocfs2_xattr_bucket_value_truncate_xs(inode, xs,
4502 value_len); 4993 value_len, ctxt);
4503 if (ret) { 4994 if (ret) {
4504 mlog_errno(ret); 4995 mlog_errno(ret);
4505 4996
@@ -4509,13 +5000,14 @@ static int ocfs2_xattr_set_in_bucket(struct inode *inode,
4509 * storage and we have allocated xattr already, 5000 * storage and we have allocated xattr already,
4510 * so need to remove it. 5001 * so need to remove it.
4511 */ 5002 */
4512 ocfs2_xattr_bucket_remove_xs(inode, xs); 5003 ocfs2_xattr_bucket_remove_xs(inode, ctxt->handle, xs);
4513 } 5004 }
4514 goto out; 5005 goto out;
4515 } 5006 }
4516 5007
4517set_value_outside: 5008set_value_outside:
4518 ret = ocfs2_xattr_bucket_set_value_outside(inode, xs, val, value_len); 5009 ret = ocfs2_xattr_bucket_set_value_outside(inode, ctxt->handle,
5010 xs, val, value_len);
4519out: 5011out:
4520 return ret; 5012 return ret;
4521} 5013}
@@ -4530,7 +5022,7 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
4530 struct ocfs2_xattr_bucket *bucket, 5022 struct ocfs2_xattr_bucket *bucket,
4531 const char *name) 5023 const char *name)
4532{ 5024{
4533 struct ocfs2_xattr_header *xh = bucket->xh; 5025 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4534 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name)); 5026 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
4535 5027
4536 if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash)) 5028 if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash))
@@ -4540,7 +5032,7 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
4540 xh->xh_entries[0].xe_name_hash) { 5032 xh->xh_entries[0].xe_name_hash) {
4541 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, " 5033 mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, "
4542 "hash = %u\n", 5034 "hash = %u\n",
4543 (unsigned long long)bucket->bhs[0]->b_blocknr, 5035 (unsigned long long)bucket_blkno(bucket),
4544 le32_to_cpu(xh->xh_entries[0].xe_name_hash)); 5036 le32_to_cpu(xh->xh_entries[0].xe_name_hash));
4545 return -ENOSPC; 5037 return -ENOSPC;
4546 } 5038 }
@@ -4550,16 +5042,16 @@ static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
4550 5042
4551static int ocfs2_xattr_set_entry_index_block(struct inode *inode, 5043static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
4552 struct ocfs2_xattr_info *xi, 5044 struct ocfs2_xattr_info *xi,
4553 struct ocfs2_xattr_search *xs) 5045 struct ocfs2_xattr_search *xs,
5046 struct ocfs2_xattr_set_ctxt *ctxt)
4554{ 5047{
4555 struct ocfs2_xattr_header *xh; 5048 struct ocfs2_xattr_header *xh;
4556 struct ocfs2_xattr_entry *xe; 5049 struct ocfs2_xattr_entry *xe;
4557 u16 count, header_size, xh_free_start; 5050 u16 count, header_size, xh_free_start;
4558 int i, free, max_free, need, old; 5051 int free, max_free, need, old;
4559 size_t value_size = 0, name_len = strlen(xi->name); 5052 size_t value_size = 0, name_len = strlen(xi->name);
4560 size_t blocksize = inode->i_sb->s_blocksize; 5053 size_t blocksize = inode->i_sb->s_blocksize;
4561 int ret, allocation = 0; 5054 int ret, allocation = 0;
4562 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4563 5055
4564 mlog_entry("Set xattr %s in xattr index block\n", xi->name); 5056 mlog_entry("Set xattr %s in xattr index block\n", xi->name);
4565 5057
@@ -4574,7 +5066,7 @@ try_again:
4574 5066
4575 mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size " 5067 mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size "
4576 "of %u which exceed block size\n", 5068 "of %u which exceed block size\n",
4577 (unsigned long long)xs->bucket.bhs[0]->b_blocknr, 5069 (unsigned long long)bucket_blkno(xs->bucket),
4578 header_size); 5070 header_size);
4579 5071
4580 if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE) 5072 if (xi->value && xi->value_len > OCFS2_XATTR_INLINE_SIZE)
@@ -4614,11 +5106,13 @@ try_again:
4614 mlog(0, "xs->not_found = %d, in xattr bucket %llu: free = %d, " 5106 mlog(0, "xs->not_found = %d, in xattr bucket %llu: free = %d, "
4615 "need = %d, max_free = %d, xh_free_start = %u, xh_name_value_len =" 5107 "need = %d, max_free = %d, xh_free_start = %u, xh_name_value_len ="
4616 " %u\n", xs->not_found, 5108 " %u\n", xs->not_found,
4617 (unsigned long long)xs->bucket.bhs[0]->b_blocknr, 5109 (unsigned long long)bucket_blkno(xs->bucket),
4618 free, need, max_free, le16_to_cpu(xh->xh_free_start), 5110 free, need, max_free, le16_to_cpu(xh->xh_free_start),
4619 le16_to_cpu(xh->xh_name_value_len)); 5111 le16_to_cpu(xh->xh_name_value_len));
4620 5112
4621 if (free < need || count == ocfs2_xattr_max_xe_in_bucket(inode->i_sb)) { 5113 if (free < need ||
5114 (xs->not_found &&
5115 count == ocfs2_xattr_max_xe_in_bucket(inode->i_sb))) {
4622 if (need <= max_free && 5116 if (need <= max_free &&
4623 count < ocfs2_xattr_max_xe_in_bucket(inode->i_sb)) { 5117 count < ocfs2_xattr_max_xe_in_bucket(inode->i_sb)) {
4624 /* 5118 /*
@@ -4626,7 +5120,8 @@ try_again:
4626 * name/value will be moved, the xe shouldn't be changed 5120 * name/value will be moved, the xe shouldn't be changed
4627 * in xs. 5121 * in xs.
4628 */ 5122 */
4629 ret = ocfs2_defrag_xattr_bucket(inode, &xs->bucket); 5123 ret = ocfs2_defrag_xattr_bucket(inode, ctxt->handle,
5124 xs->bucket);
4630 if (ret) { 5125 if (ret) {
4631 mlog_errno(ret); 5126 mlog_errno(ret);
4632 goto out; 5127 goto out;
@@ -4658,7 +5153,7 @@ try_again:
4658 * add a new bucket for the insert. 5153 * add a new bucket for the insert.
4659 */ 5154 */
4660 ret = ocfs2_check_xattr_bucket_collision(inode, 5155 ret = ocfs2_check_xattr_bucket_collision(inode,
4661 &xs->bucket, 5156 xs->bucket,
4662 xi->name); 5157 xi->name);
4663 if (ret) { 5158 if (ret) {
4664 mlog_errno(ret); 5159 mlog_errno(ret);
@@ -4667,17 +5162,21 @@ try_again:
4667 5162
4668 ret = ocfs2_add_new_xattr_bucket(inode, 5163 ret = ocfs2_add_new_xattr_bucket(inode,
4669 xs->xattr_bh, 5164 xs->xattr_bh,
4670 xs->bucket.bhs[0]); 5165 xs->bucket,
5166 ctxt);
4671 if (ret) { 5167 if (ret) {
4672 mlog_errno(ret); 5168 mlog_errno(ret);
4673 goto out; 5169 goto out;
4674 } 5170 }
4675 5171
4676 for (i = 0; i < blk_per_bucket; i++) 5172 /*
4677 brelse(xs->bucket.bhs[i]); 5173 * ocfs2_add_new_xattr_bucket() will have updated
4678 5174 * xs->bucket if it moved, but it will not have updated
4679 memset(&xs->bucket, 0, sizeof(xs->bucket)); 5175 * any of the other search fields. Thus, we drop it and
4680 5176 * re-search. Everything should be cached, so it'll be
5177 * quick.
5178 */
5179 ocfs2_xattr_bucket_relse(xs->bucket);
4681 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh, 5180 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,
4682 xi->name_index, 5181 xi->name_index,
4683 xi->name, xs); 5182 xi->name, xs);
@@ -4689,7 +5188,7 @@ try_again:
4689 } 5188 }
4690 5189
4691xattr_set: 5190xattr_set:
4692 ret = ocfs2_xattr_set_in_bucket(inode, xi, xs); 5191 ret = ocfs2_xattr_set_in_bucket(inode, xi, xs, ctxt);
4693out: 5192out:
4694 mlog_exit(ret); 5193 mlog_exit(ret);
4695 return ret; 5194 return ret;
@@ -4700,24 +5199,41 @@ static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
4700 void *para) 5199 void *para)
4701{ 5200{
4702 int ret = 0; 5201 int ret = 0;
4703 struct ocfs2_xattr_header *xh = bucket->xh; 5202 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4704 u16 i; 5203 u16 i;
4705 struct ocfs2_xattr_entry *xe; 5204 struct ocfs2_xattr_entry *xe;
5205 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5206 struct ocfs2_xattr_set_ctxt ctxt = {NULL, NULL,};
5207 int credits = ocfs2_remove_extent_credits(osb->sb) +
5208 ocfs2_blocks_per_xattr_bucket(inode->i_sb);
5209
5210
5211 ocfs2_init_dealloc_ctxt(&ctxt.dealloc);
4706 5212
4707 for (i = 0; i < le16_to_cpu(xh->xh_count); i++) { 5213 for (i = 0; i < le16_to_cpu(xh->xh_count); i++) {
4708 xe = &xh->xh_entries[i]; 5214 xe = &xh->xh_entries[i];
4709 if (ocfs2_xattr_is_local(xe)) 5215 if (ocfs2_xattr_is_local(xe))
4710 continue; 5216 continue;
4711 5217
4712 ret = ocfs2_xattr_bucket_value_truncate(inode, 5218 ctxt.handle = ocfs2_start_trans(osb, credits);
4713 bucket->bhs[0], 5219 if (IS_ERR(ctxt.handle)) {
4714 i, 0); 5220 ret = PTR_ERR(ctxt.handle);
5221 mlog_errno(ret);
5222 break;
5223 }
5224
5225 ret = ocfs2_xattr_bucket_value_truncate(inode, bucket,
5226 i, 0, &ctxt);
5227
5228 ocfs2_commit_trans(osb, ctxt.handle);
4715 if (ret) { 5229 if (ret) {
4716 mlog_errno(ret); 5230 mlog_errno(ret);
4717 break; 5231 break;
4718 } 5232 }
4719 } 5233 }
4720 5234
5235 ocfs2_schedule_truncate_log_flush(osb, 1);
5236 ocfs2_run_deallocs(osb, &ctxt.dealloc);
4721 return ret; 5237 return ret;
4722} 5238}
4723 5239
@@ -4768,6 +5284,74 @@ out:
4768} 5284}
4769 5285
4770/* 5286/*
5287 * 'security' attributes support
5288 */
5289static size_t ocfs2_xattr_security_list(struct inode *inode, char *list,
5290 size_t list_size, const char *name,
5291 size_t name_len)
5292{
5293 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
5294 const size_t total_len = prefix_len + name_len + 1;
5295
5296 if (list && total_len <= list_size) {
5297 memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
5298 memcpy(list + prefix_len, name, name_len);
5299 list[prefix_len + name_len] = '\0';
5300 }
5301 return total_len;
5302}
5303
5304static int ocfs2_xattr_security_get(struct inode *inode, const char *name,
5305 void *buffer, size_t size)
5306{
5307 if (strcmp(name, "") == 0)
5308 return -EINVAL;
5309 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name,
5310 buffer, size);
5311}
5312
5313static int ocfs2_xattr_security_set(struct inode *inode, const char *name,
5314 const void *value, size_t size, int flags)
5315{
5316 if (strcmp(name, "") == 0)
5317 return -EINVAL;
5318
5319 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value,
5320 size, flags);
5321}
5322
5323int ocfs2_init_security_get(struct inode *inode,
5324 struct inode *dir,
5325 struct ocfs2_security_xattr_info *si)
5326{
5327 /* check whether ocfs2 support feature xattr */
5328 if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb)))
5329 return -EOPNOTSUPP;
5330 return security_inode_init_security(inode, dir, &si->name, &si->value,
5331 &si->value_len);
5332}
5333
5334int ocfs2_init_security_set(handle_t *handle,
5335 struct inode *inode,
5336 struct buffer_head *di_bh,
5337 struct ocfs2_security_xattr_info *si,
5338 struct ocfs2_alloc_context *xattr_ac,
5339 struct ocfs2_alloc_context *data_ac)
5340{
5341 return ocfs2_xattr_set_handle(handle, inode, di_bh,
5342 OCFS2_XATTR_INDEX_SECURITY,
5343 si->name, si->value, si->value_len, 0,
5344 xattr_ac, data_ac);
5345}
5346
5347struct xattr_handler ocfs2_xattr_security_handler = {
5348 .prefix = XATTR_SECURITY_PREFIX,
5349 .list = ocfs2_xattr_security_list,
5350 .get = ocfs2_xattr_security_get,
5351 .set = ocfs2_xattr_security_set,
5352};
5353
5354/*
4771 * 'trusted' attributes support 5355 * 'trusted' attributes support
4772 */ 5356 */
4773static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, 5357static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
diff --git a/fs/ocfs2/xattr.h b/fs/ocfs2/xattr.h
index 1d8314c7656d..5a1ebc789f7e 100644
--- a/fs/ocfs2/xattr.h
+++ b/fs/ocfs2/xattr.h
@@ -30,13 +30,58 @@ enum ocfs2_xattr_type {
30 OCFS2_XATTR_MAX 30 OCFS2_XATTR_MAX
31}; 31};
32 32
33struct ocfs2_security_xattr_info {
34 int enable;
35 char *name;
36 void *value;
37 size_t value_len;
38};
39
33extern struct xattr_handler ocfs2_xattr_user_handler; 40extern struct xattr_handler ocfs2_xattr_user_handler;
34extern struct xattr_handler ocfs2_xattr_trusted_handler; 41extern struct xattr_handler ocfs2_xattr_trusted_handler;
42extern struct xattr_handler ocfs2_xattr_security_handler;
43#ifdef CONFIG_OCFS2_FS_POSIX_ACL
44extern struct xattr_handler ocfs2_xattr_acl_access_handler;
45extern struct xattr_handler ocfs2_xattr_acl_default_handler;
46#endif
35extern struct xattr_handler *ocfs2_xattr_handlers[]; 47extern struct xattr_handler *ocfs2_xattr_handlers[];
36 48
37ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); 49ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
50int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
51 const char *, void *, size_t);
38int ocfs2_xattr_set(struct inode *, int, const char *, const void *, 52int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
39 size_t, int); 53 size_t, int);
54int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
55 int, const char *, const void *, size_t, int,
56 struct ocfs2_alloc_context *,
57 struct ocfs2_alloc_context *);
40int ocfs2_xattr_remove(struct inode *, struct buffer_head *); 58int ocfs2_xattr_remove(struct inode *, struct buffer_head *);
59int ocfs2_init_security_get(struct inode *, struct inode *,
60 struct ocfs2_security_xattr_info *);
61int ocfs2_init_security_set(handle_t *, struct inode *,
62 struct buffer_head *,
63 struct ocfs2_security_xattr_info *,
64 struct ocfs2_alloc_context *,
65 struct ocfs2_alloc_context *);
66int ocfs2_calc_security_init(struct inode *,
67 struct ocfs2_security_xattr_info *,
68 int *, int *, struct ocfs2_alloc_context **);
69int ocfs2_calc_xattr_init(struct inode *, struct buffer_head *,
70 int, struct ocfs2_security_xattr_info *,
71 int *, int *, struct ocfs2_alloc_context **);
72
73/*
74 * xattrs can live inside an inode, as part of an external xattr block,
75 * or inside an xattr bucket, which is the leaf of a tree rooted in an
76 * xattr block. Some of the xattr calls, especially the value setting
77 * functions, want to treat each of these locations as equal. Let's wrap
78 * them in a structure that we can pass around instead of raw buffer_heads.
79 */
80struct ocfs2_xattr_value_buf {
81 struct buffer_head *vb_bh;
82 ocfs2_journal_access_func vb_access;
83 struct ocfs2_xattr_value_root *vb_xv;
84};
85
41 86
42#endif /* OCFS2_XATTR_H */ 87#endif /* OCFS2_XATTR_H */
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 6afe57c84f84..633e9dc972bb 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -39,7 +39,6 @@ struct inode *omfs_new_inode(struct inode *dir, int mode)
39 inode->i_mode = mode; 39 inode->i_mode = mode;
40 inode->i_uid = current_fsuid(); 40 inode->i_uid = current_fsuid();
41 inode->i_gid = current_fsgid(); 41 inode->i_gid = current_fsgid();
42 inode->i_blocks = 0;
43 inode->i_mapping->a_ops = &omfs_aops; 42 inode->i_mapping->a_ops = &omfs_aops;
44 43
45 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 44 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
diff --git a/fs/open.c b/fs/open.c
index 1cd7d40e9991..d882fd2351d6 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -412,7 +412,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len)
412 if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) 412 if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
413 goto out_fput; 413 goto out_fput;
414 414
415 if (inode->i_op && inode->i_op->fallocate) 415 if (inode->i_op->fallocate)
416 ret = inode->i_op->fallocate(inode, mode, offset, len); 416 ret = inode->i_op->fallocate(inode, mode, offset, len);
417 else 417 else
418 ret = -EOPNOTSUPP; 418 ret = -EOPNOTSUPP;
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index d41bdc784de4..ffcd04f0012c 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -256,9 +256,6 @@ found:
256 break; 256 break;
257 } 257 }
258 258
259 inode->i_gid = 0;
260 inode->i_uid = 0;
261
262 d_add(dentry, inode); 259 d_add(dentry, inode);
263 return NULL; 260 return NULL;
264} 261}
diff --git a/fs/pipe.c b/fs/pipe.c
index aaf797bd57b9..891697112f66 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1016,10 +1016,7 @@ int do_pipe_flags(int *fd, int flags)
1016 goto err_fdr; 1016 goto err_fdr;
1017 fdw = error; 1017 fdw = error;
1018 1018
1019 error = audit_fd_pair(fdr, fdw); 1019 audit_fd_pair(fdr, fdw);
1020 if (error < 0)
1021 goto err_fdw;
1022
1023 fd_install(fdr, fr); 1020 fd_install(fdr, fr);
1024 fd_install(fdw, fw); 1021 fd_install(fdw, fw);
1025 fd[0] = fdr; 1022 fd[0] = fdr;
@@ -1027,8 +1024,6 @@ int do_pipe_flags(int *fd, int flags)
1027 1024
1028 return 0; 1025 return 0;
1029 1026
1030 err_fdw:
1031 put_unused_fd(fdw);
1032 err_fdr: 1027 err_fdr:
1033 put_unused_fd(fdr); 1028 put_unused_fd(fdr);
1034 err_read_pipe: 1029 err_read_pipe:
diff --git a/fs/proc/base.c b/fs/proc/base.c
index cad92c1ac2b3..10fd5223d600 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1426,8 +1426,6 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
1426 if (!ei->pid) 1426 if (!ei->pid)
1427 goto out_unlock; 1427 goto out_unlock;
1428 1428
1429 inode->i_uid = 0;
1430 inode->i_gid = 0;
1431 if (task_dumpable(task)) { 1429 if (task_dumpable(task)) {
1432 rcu_read_lock(); 1430 rcu_read_lock();
1433 cred = __task_cred(task); 1431 cred = __task_cred(task);
@@ -2349,8 +2347,6 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
2349 if (!ei->pid) 2347 if (!ei->pid)
2350 goto out_iput; 2348 goto out_iput;
2351 2349
2352 inode->i_uid = 0;
2353 inode->i_gid = 0;
2354 inode->i_mode = p->mode; 2350 inode->i_mode = p->mode;
2355 if (S_ISDIR(inode->i_mode)) 2351 if (S_ISDIR(inode->i_mode))
2356 inode->i_nlink = 2; 2352 inode->i_nlink = 2;
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 06ed10b7da9e..94fcfff6863a 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -31,7 +31,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
31 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 31 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
32 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ 32 inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */
33 inode->i_mode = table->mode; 33 inode->i_mode = table->mode;
34 inode->i_uid = inode->i_gid = 0;
35 if (!table->child) { 34 if (!table->child) {
36 inode->i_mode |= S_IFREG; 35 inode->i_mode |= S_IFREG;
37 inode->i_op = &proc_sys_inode_operations; 36 inode->i_op = &proc_sys_inode_operations;
diff --git a/fs/quota.c b/fs/quota.c
index b7fe44e01618..4a8c94f05f76 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -73,7 +73,7 @@ static int generic_quotactl_valid(struct super_block *sb, int type, int cmd, qid
73 case Q_SETQUOTA: 73 case Q_SETQUOTA:
74 case Q_GETQUOTA: 74 case Q_GETQUOTA:
75 /* This is just informative test so we are satisfied without a lock */ 75 /* This is just informative test so we are satisfied without a lock */
76 if (!sb_has_quota_enabled(sb, type)) 76 if (!sb_has_quota_active(sb, type))
77 return -ESRCH; 77 return -ESRCH;
78 } 78 }
79 79
@@ -160,6 +160,9 @@ static void quota_sync_sb(struct super_block *sb, int type)
160 int cnt; 160 int cnt;
161 161
162 sb->s_qcop->quota_sync(sb, type); 162 sb->s_qcop->quota_sync(sb, type);
163
164 if (sb_dqopt(sb)->flags & DQUOT_QUOTA_SYS_FILE)
165 return;
163 /* This is not very clever (and fast) but currently I don't know about 166 /* This is not very clever (and fast) but currently I don't know about
164 * any other simple way of getting quota data to disk and we must get 167 * any other simple way of getting quota data to disk and we must get
165 * them there for userspace to be visible... */ 168 * them there for userspace to be visible... */
@@ -175,7 +178,7 @@ static void quota_sync_sb(struct super_block *sb, int type)
175 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 178 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
176 if (type != -1 && cnt != type) 179 if (type != -1 && cnt != type)
177 continue; 180 continue;
178 if (!sb_has_quota_enabled(sb, cnt)) 181 if (!sb_has_quota_active(sb, cnt))
179 continue; 182 continue;
180 mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, I_MUTEX_QUOTA); 183 mutex_lock_nested(&sb_dqopt(sb)->files[cnt]->i_mutex, I_MUTEX_QUOTA);
181 truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0); 184 truncate_inode_pages(&sb_dqopt(sb)->files[cnt]->i_data, 0);
@@ -201,7 +204,7 @@ restart:
201 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 204 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
202 if (type != -1 && type != cnt) 205 if (type != -1 && type != cnt)
203 continue; 206 continue;
204 if (!sb_has_quota_enabled(sb, cnt)) 207 if (!sb_has_quota_active(sb, cnt))
205 continue; 208 continue;
206 if (!info_dirty(&sb_dqopt(sb)->info[cnt]) && 209 if (!info_dirty(&sb_dqopt(sb)->info[cnt]) &&
207 list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list)) 210 list_empty(&sb_dqopt(sb)->info[cnt].dqi_dirty_list))
@@ -245,7 +248,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, void
245 __u32 fmt; 248 __u32 fmt;
246 249
247 down_read(&sb_dqopt(sb)->dqptr_sem); 250 down_read(&sb_dqopt(sb)->dqptr_sem);
248 if (!sb_has_quota_enabled(sb, type)) { 251 if (!sb_has_quota_active(sb, type)) {
249 up_read(&sb_dqopt(sb)->dqptr_sem); 252 up_read(&sb_dqopt(sb)->dqptr_sem);
250 return -ESRCH; 253 return -ESRCH;
251 } 254 }
diff --git a/fs/quota_tree.c b/fs/quota_tree.c
new file mode 100644
index 000000000000..953404c95b17
--- /dev/null
+++ b/fs/quota_tree.c
@@ -0,0 +1,645 @@
1/*
2 * vfsv0 quota IO operations on file
3 */
4
5#include <linux/errno.h>
6#include <linux/fs.h>
7#include <linux/mount.h>
8#include <linux/dqblk_v2.h>
9#include <linux/kernel.h>
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/slab.h>
13#include <linux/quotaops.h>
14
15#include <asm/byteorder.h>
16
17#include "quota_tree.h"
18
19MODULE_AUTHOR("Jan Kara");
20MODULE_DESCRIPTION("Quota trie support");
21MODULE_LICENSE("GPL");
22
23#define __QUOTA_QT_PARANOIA
24
25typedef char *dqbuf_t;
26
27static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth)
28{
29 unsigned int epb = info->dqi_usable_bs >> 2;
30
31 depth = info->dqi_qtree_depth - depth - 1;
32 while (depth--)
33 id /= epb;
34 return id % epb;
35}
36
37/* Number of entries in one blocks */
38static inline int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
39{
40 return (info->dqi_usable_bs - sizeof(struct qt_disk_dqdbheader))
41 / info->dqi_entry_size;
42}
43
44static dqbuf_t getdqbuf(size_t size)
45{
46 dqbuf_t buf = kmalloc(size, GFP_NOFS);
47 if (!buf)
48 printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n");
49 return buf;
50}
51
52static inline void freedqbuf(dqbuf_t buf)
53{
54 kfree(buf);
55}
56
57static inline ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf)
58{
59 struct super_block *sb = info->dqi_sb;
60
61 memset(buf, 0, info->dqi_usable_bs);
62 return sb->s_op->quota_read(sb, info->dqi_type, (char *)buf,
63 info->dqi_usable_bs, blk << info->dqi_blocksize_bits);
64}
65
66static inline ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, dqbuf_t buf)
67{
68 struct super_block *sb = info->dqi_sb;
69
70 return sb->s_op->quota_write(sb, info->dqi_type, (char *)buf,
71 info->dqi_usable_bs, blk << info->dqi_blocksize_bits);
72}
73
74/* Remove empty block from list and return it */
75static int get_free_dqblk(struct qtree_mem_dqinfo *info)
76{
77 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
78 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
79 int ret, blk;
80
81 if (!buf)
82 return -ENOMEM;
83 if (info->dqi_free_blk) {
84 blk = info->dqi_free_blk;
85 ret = read_blk(info, blk, buf);
86 if (ret < 0)
87 goto out_buf;
88 info->dqi_free_blk = le32_to_cpu(dh->dqdh_next_free);
89 }
90 else {
91 memset(buf, 0, info->dqi_usable_bs);
92 /* Assure block allocation... */
93 ret = write_blk(info, info->dqi_blocks, buf);
94 if (ret < 0)
95 goto out_buf;
96 blk = info->dqi_blocks++;
97 }
98 mark_info_dirty(info->dqi_sb, info->dqi_type);
99 ret = blk;
100out_buf:
101 freedqbuf(buf);
102 return ret;
103}
104
105/* Insert empty block to the list */
106static int put_free_dqblk(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk)
107{
108 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
109 int err;
110
111 dh->dqdh_next_free = cpu_to_le32(info->dqi_free_blk);
112 dh->dqdh_prev_free = cpu_to_le32(0);
113 dh->dqdh_entries = cpu_to_le16(0);
114 err = write_blk(info, blk, buf);
115 if (err < 0)
116 return err;
117 info->dqi_free_blk = blk;
118 mark_info_dirty(info->dqi_sb, info->dqi_type);
119 return 0;
120}
121
122/* Remove given block from the list of blocks with free entries */
123static int remove_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk)
124{
125 dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs);
126 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
127 uint nextblk = le32_to_cpu(dh->dqdh_next_free);
128 uint prevblk = le32_to_cpu(dh->dqdh_prev_free);
129 int err;
130
131 if (!tmpbuf)
132 return -ENOMEM;
133 if (nextblk) {
134 err = read_blk(info, nextblk, tmpbuf);
135 if (err < 0)
136 goto out_buf;
137 ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_prev_free =
138 dh->dqdh_prev_free;
139 err = write_blk(info, nextblk, tmpbuf);
140 if (err < 0)
141 goto out_buf;
142 }
143 if (prevblk) {
144 err = read_blk(info, prevblk, tmpbuf);
145 if (err < 0)
146 goto out_buf;
147 ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_next_free =
148 dh->dqdh_next_free;
149 err = write_blk(info, prevblk, tmpbuf);
150 if (err < 0)
151 goto out_buf;
152 } else {
153 info->dqi_free_entry = nextblk;
154 mark_info_dirty(info->dqi_sb, info->dqi_type);
155 }
156 freedqbuf(tmpbuf);
157 dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0);
158 /* No matter whether write succeeds block is out of list */
159 if (write_blk(info, blk, buf) < 0)
160 printk(KERN_ERR "VFS: Can't write block (%u) with free entries.\n", blk);
161 return 0;
162out_buf:
163 freedqbuf(tmpbuf);
164 return err;
165}
166
167/* Insert given block to the beginning of list with free entries */
168static int insert_free_dqentry(struct qtree_mem_dqinfo *info, dqbuf_t buf, uint blk)
169{
170 dqbuf_t tmpbuf = getdqbuf(info->dqi_usable_bs);
171 struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
172 int err;
173
174 if (!tmpbuf)
175 return -ENOMEM;
176 dh->dqdh_next_free = cpu_to_le32(info->dqi_free_entry);
177 dh->dqdh_prev_free = cpu_to_le32(0);
178 err = write_blk(info, blk, buf);
179 if (err < 0)
180 goto out_buf;
181 if (info->dqi_free_entry) {
182 err = read_blk(info, info->dqi_free_entry, tmpbuf);
183 if (err < 0)
184 goto out_buf;
185 ((struct qt_disk_dqdbheader *)tmpbuf)->dqdh_prev_free =
186 cpu_to_le32(blk);
187 err = write_blk(info, info->dqi_free_entry, tmpbuf);
188 if (err < 0)
189 goto out_buf;
190 }
191 freedqbuf(tmpbuf);
192 info->dqi_free_entry = blk;
193 mark_info_dirty(info->dqi_sb, info->dqi_type);
194 return 0;
195out_buf:
196 freedqbuf(tmpbuf);
197 return err;
198}
199
200/* Is the entry in the block free? */
201int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk)
202{
203 int i;
204
205 for (i = 0; i < info->dqi_entry_size; i++)
206 if (disk[i])
207 return 0;
208 return 1;
209}
210EXPORT_SYMBOL(qtree_entry_unused);
211
212/* Find space for dquot */
213static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
214 struct dquot *dquot, int *err)
215{
216 uint blk, i;
217 struct qt_disk_dqdbheader *dh;
218 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
219 char *ddquot;
220
221 *err = 0;
222 if (!buf) {
223 *err = -ENOMEM;
224 return 0;
225 }
226 dh = (struct qt_disk_dqdbheader *)buf;
227 if (info->dqi_free_entry) {
228 blk = info->dqi_free_entry;
229 *err = read_blk(info, blk, buf);
230 if (*err < 0)
231 goto out_buf;
232 } else {
233 blk = get_free_dqblk(info);
234 if ((int)blk < 0) {
235 *err = blk;
236 freedqbuf(buf);
237 return 0;
238 }
239 memset(buf, 0, info->dqi_usable_bs);
240 /* This is enough as block is already zeroed and entry list is empty... */
241 info->dqi_free_entry = blk;
242 mark_info_dirty(dquot->dq_sb, dquot->dq_type);
243 }
244 /* Block will be full? */
245 if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) {
246 *err = remove_free_dqentry(info, buf, blk);
247 if (*err < 0) {
248 printk(KERN_ERR "VFS: find_free_dqentry(): Can't "
249 "remove block (%u) from entry free list.\n",
250 blk);
251 goto out_buf;
252 }
253 }
254 le16_add_cpu(&dh->dqdh_entries, 1);
255 /* Find free structure in block */
256 for (i = 0, ddquot = ((char *)buf) + sizeof(struct qt_disk_dqdbheader);
257 i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot);
258 i++, ddquot += info->dqi_entry_size);
259#ifdef __QUOTA_QT_PARANOIA
260 if (i == qtree_dqstr_in_blk(info)) {
261 printk(KERN_ERR "VFS: find_free_dqentry(): Data block full "
262 "but it shouldn't.\n");
263 *err = -EIO;
264 goto out_buf;
265 }
266#endif
267 *err = write_blk(info, blk, buf);
268 if (*err < 0) {
269 printk(KERN_ERR "VFS: find_free_dqentry(): Can't write quota "
270 "data block %u.\n", blk);
271 goto out_buf;
272 }
273 dquot->dq_off = (blk << info->dqi_blocksize_bits) +
274 sizeof(struct qt_disk_dqdbheader) +
275 i * info->dqi_entry_size;
276 freedqbuf(buf);
277 return blk;
278out_buf:
279 freedqbuf(buf);
280 return 0;
281}
282
283/* Insert reference to structure into the trie */
284static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
285 uint *treeblk, int depth)
286{
287 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
288 int ret = 0, newson = 0, newact = 0;
289 __le32 *ref;
290 uint newblk;
291
292 if (!buf)
293 return -ENOMEM;
294 if (!*treeblk) {
295 ret = get_free_dqblk(info);
296 if (ret < 0)
297 goto out_buf;
298 *treeblk = ret;
299 memset(buf, 0, info->dqi_usable_bs);
300 newact = 1;
301 } else {
302 ret = read_blk(info, *treeblk, buf);
303 if (ret < 0) {
304 printk(KERN_ERR "VFS: Can't read tree quota block "
305 "%u.\n", *treeblk);
306 goto out_buf;
307 }
308 }
309 ref = (__le32 *)buf;
310 newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
311 if (!newblk)
312 newson = 1;
313 if (depth == info->dqi_qtree_depth - 1) {
314#ifdef __QUOTA_QT_PARANOIA
315 if (newblk) {
316 printk(KERN_ERR "VFS: Inserting already present quota "
317 "entry (block %u).\n",
318 le32_to_cpu(ref[get_index(info,
319 dquot->dq_id, depth)]));
320 ret = -EIO;
321 goto out_buf;
322 }
323#endif
324 newblk = find_free_dqentry(info, dquot, &ret);
325 } else {
326 ret = do_insert_tree(info, dquot, &newblk, depth+1);
327 }
328 if (newson && ret >= 0) {
329 ref[get_index(info, dquot->dq_id, depth)] =
330 cpu_to_le32(newblk);
331 ret = write_blk(info, *treeblk, buf);
332 } else if (newact && ret < 0) {
333 put_free_dqblk(info, buf, *treeblk);
334 }
335out_buf:
336 freedqbuf(buf);
337 return ret;
338}
339
340/* Wrapper for inserting quota structure into tree */
341static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
342 struct dquot *dquot)
343{
344 int tmp = QT_TREEOFF;
345 return do_insert_tree(info, dquot, &tmp, 0);
346}
347
348/*
349 * We don't have to be afraid of deadlocks as we never have quotas on quota files...
350 */
351int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
352{
353 int type = dquot->dq_type;
354 struct super_block *sb = dquot->dq_sb;
355 ssize_t ret;
356 dqbuf_t ddquot = getdqbuf(info->dqi_entry_size);
357
358 if (!ddquot)
359 return -ENOMEM;
360
361 /* dq_off is guarded by dqio_mutex */
362 if (!dquot->dq_off) {
363 ret = dq_insert_tree(info, dquot);
364 if (ret < 0) {
365 printk(KERN_ERR "VFS: Error %zd occurred while "
366 "creating quota.\n", ret);
367 freedqbuf(ddquot);
368 return ret;
369 }
370 }
371 spin_lock(&dq_data_lock);
372 info->dqi_ops->mem2disk_dqblk(ddquot, dquot);
373 spin_unlock(&dq_data_lock);
374 ret = sb->s_op->quota_write(sb, type, (char *)ddquot,
375 info->dqi_entry_size, dquot->dq_off);
376 if (ret != info->dqi_entry_size) {
377 printk(KERN_WARNING "VFS: dquota write failed on dev %s\n",
378 sb->s_id);
379 if (ret >= 0)
380 ret = -ENOSPC;
381 } else {
382 ret = 0;
383 }
384 dqstats.writes++;
385 freedqbuf(ddquot);
386
387 return ret;
388}
389EXPORT_SYMBOL(qtree_write_dquot);
390
391/* Free dquot entry in data block */
392static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
393 uint blk)
394{
395 struct qt_disk_dqdbheader *dh;
396 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
397 int ret = 0;
398
399 if (!buf)
400 return -ENOMEM;
401 if (dquot->dq_off >> info->dqi_blocksize_bits != blk) {
402 printk(KERN_ERR "VFS: Quota structure has offset to other "
403 "block (%u) than it should (%u).\n", blk,
404 (uint)(dquot->dq_off >> info->dqi_blocksize_bits));
405 goto out_buf;
406 }
407 ret = read_blk(info, blk, buf);
408 if (ret < 0) {
409 printk(KERN_ERR "VFS: Can't read quota data block %u\n", blk);
410 goto out_buf;
411 }
412 dh = (struct qt_disk_dqdbheader *)buf;
413 le16_add_cpu(&dh->dqdh_entries, -1);
414 if (!le16_to_cpu(dh->dqdh_entries)) { /* Block got free? */
415 ret = remove_free_dqentry(info, buf, blk);
416 if (ret >= 0)
417 ret = put_free_dqblk(info, buf, blk);
418 if (ret < 0) {
419 printk(KERN_ERR "VFS: Can't move quota data block (%u) "
420 "to free list.\n", blk);
421 goto out_buf;
422 }
423 } else {
424 memset(buf +
425 (dquot->dq_off & ((1 << info->dqi_blocksize_bits) - 1)),
426 0, info->dqi_entry_size);
427 if (le16_to_cpu(dh->dqdh_entries) ==
428 qtree_dqstr_in_blk(info) - 1) {
429 /* Insert will write block itself */
430 ret = insert_free_dqentry(info, buf, blk);
431 if (ret < 0) {
432 printk(KERN_ERR "VFS: Can't insert quota data "
433 "block (%u) to free entry list.\n", blk);
434 goto out_buf;
435 }
436 } else {
437 ret = write_blk(info, blk, buf);
438 if (ret < 0) {
439 printk(KERN_ERR "VFS: Can't write quota data "
440 "block %u\n", blk);
441 goto out_buf;
442 }
443 }
444 }
445 dquot->dq_off = 0; /* Quota is now unattached */
446out_buf:
447 freedqbuf(buf);
448 return ret;
449}
450
451/* Remove reference to dquot from tree */
452static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
453 uint *blk, int depth)
454{
455 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
456 int ret = 0;
457 uint newblk;
458 __le32 *ref = (__le32 *)buf;
459
460 if (!buf)
461 return -ENOMEM;
462 ret = read_blk(info, *blk, buf);
463 if (ret < 0) {
464 printk(KERN_ERR "VFS: Can't read quota data block %u\n", *blk);
465 goto out_buf;
466 }
467 newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
468 if (depth == info->dqi_qtree_depth - 1) {
469 ret = free_dqentry(info, dquot, newblk);
470 newblk = 0;
471 } else {
472 ret = remove_tree(info, dquot, &newblk, depth+1);
473 }
474 if (ret >= 0 && !newblk) {
475 int i;
476 ref[get_index(info, dquot->dq_id, depth)] = cpu_to_le32(0);
477 /* Block got empty? */
478 for (i = 0;
479 i < (info->dqi_usable_bs >> 2) && !ref[i];
480 i++);
481 /* Don't put the root block into the free block list */
482 if (i == (info->dqi_usable_bs >> 2)
483 && *blk != QT_TREEOFF) {
484 put_free_dqblk(info, buf, *blk);
485 *blk = 0;
486 } else {
487 ret = write_blk(info, *blk, buf);
488 if (ret < 0)
489 printk(KERN_ERR "VFS: Can't write quota tree "
490 "block %u.\n", *blk);
491 }
492 }
493out_buf:
494 freedqbuf(buf);
495 return ret;
496}
497
498/* Delete dquot from tree */
499int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
500{
501 uint tmp = QT_TREEOFF;
502
503 if (!dquot->dq_off) /* Even not allocated? */
504 return 0;
505 return remove_tree(info, dquot, &tmp, 0);
506}
507EXPORT_SYMBOL(qtree_delete_dquot);
508
509/* Find entry in block */
510static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
511 struct dquot *dquot, uint blk)
512{
513 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
514 loff_t ret = 0;
515 int i;
516 char *ddquot;
517
518 if (!buf)
519 return -ENOMEM;
520 ret = read_blk(info, blk, buf);
521 if (ret < 0) {
522 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
523 goto out_buf;
524 }
525 for (i = 0, ddquot = ((char *)buf) + sizeof(struct qt_disk_dqdbheader);
526 i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot);
527 i++, ddquot += info->dqi_entry_size);
528 if (i == qtree_dqstr_in_blk(info)) {
529 printk(KERN_ERR "VFS: Quota for id %u referenced "
530 "but not present.\n", dquot->dq_id);
531 ret = -EIO;
532 goto out_buf;
533 } else {
534 ret = (blk << info->dqi_blocksize_bits) + sizeof(struct
535 qt_disk_dqdbheader) + i * info->dqi_entry_size;
536 }
537out_buf:
538 freedqbuf(buf);
539 return ret;
540}
541
542/* Find entry for given id in the tree */
543static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
544 struct dquot *dquot, uint blk, int depth)
545{
546 dqbuf_t buf = getdqbuf(info->dqi_usable_bs);
547 loff_t ret = 0;
548 __le32 *ref = (__le32 *)buf;
549
550 if (!buf)
551 return -ENOMEM;
552 ret = read_blk(info, blk, buf);
553 if (ret < 0) {
554 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
555 goto out_buf;
556 }
557 ret = 0;
558 blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
559 if (!blk) /* No reference? */
560 goto out_buf;
561 if (depth < info->dqi_qtree_depth - 1)
562 ret = find_tree_dqentry(info, dquot, blk, depth+1);
563 else
564 ret = find_block_dqentry(info, dquot, blk);
565out_buf:
566 freedqbuf(buf);
567 return ret;
568}
569
570/* Find entry for given id in the tree - wrapper function */
571static inline loff_t find_dqentry(struct qtree_mem_dqinfo *info,
572 struct dquot *dquot)
573{
574 return find_tree_dqentry(info, dquot, QT_TREEOFF, 0);
575}
576
577int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
578{
579 int type = dquot->dq_type;
580 struct super_block *sb = dquot->dq_sb;
581 loff_t offset;
582 dqbuf_t ddquot;
583 int ret = 0;
584
585#ifdef __QUOTA_QT_PARANOIA
586 /* Invalidated quota? */
587 if (!sb_dqopt(dquot->dq_sb)->files[type]) {
588 printk(KERN_ERR "VFS: Quota invalidated while reading!\n");
589 return -EIO;
590 }
591#endif
592 /* Do we know offset of the dquot entry in the quota file? */
593 if (!dquot->dq_off) {
594 offset = find_dqentry(info, dquot);
595 if (offset <= 0) { /* Entry not present? */
596 if (offset < 0)
597 printk(KERN_ERR "VFS: Can't read quota "
598 "structure for id %u.\n", dquot->dq_id);
599 dquot->dq_off = 0;
600 set_bit(DQ_FAKE_B, &dquot->dq_flags);
601 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
602 ret = offset;
603 goto out;
604 }
605 dquot->dq_off = offset;
606 }
607 ddquot = getdqbuf(info->dqi_entry_size);
608 if (!ddquot)
609 return -ENOMEM;
610 ret = sb->s_op->quota_read(sb, type, (char *)ddquot,
611 info->dqi_entry_size, dquot->dq_off);
612 if (ret != info->dqi_entry_size) {
613 if (ret >= 0)
614 ret = -EIO;
615 printk(KERN_ERR "VFS: Error while reading quota "
616 "structure for id %u.\n", dquot->dq_id);
617 set_bit(DQ_FAKE_B, &dquot->dq_flags);
618 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
619 freedqbuf(ddquot);
620 goto out;
621 }
622 spin_lock(&dq_data_lock);
623 info->dqi_ops->disk2mem_dqblk(dquot, ddquot);
624 if (!dquot->dq_dqb.dqb_bhardlimit &&
625 !dquot->dq_dqb.dqb_bsoftlimit &&
626 !dquot->dq_dqb.dqb_ihardlimit &&
627 !dquot->dq_dqb.dqb_isoftlimit)
628 set_bit(DQ_FAKE_B, &dquot->dq_flags);
629 spin_unlock(&dq_data_lock);
630 freedqbuf(ddquot);
631out:
632 dqstats.reads++;
633 return ret;
634}
635EXPORT_SYMBOL(qtree_read_dquot);
636
637/* Check whether dquot should not be deleted. We know we are
638 * the only one operating on dquot (thanks to dq_lock) */
639int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
640{
641 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace))
642 return qtree_delete_dquot(info, dquot);
643 return 0;
644}
645EXPORT_SYMBOL(qtree_release_dquot);
diff --git a/fs/quota_tree.h b/fs/quota_tree.h
new file mode 100644
index 000000000000..a1ab8db81a51
--- /dev/null
+++ b/fs/quota_tree.h
@@ -0,0 +1,25 @@
1/*
2 * Definitions of structures for vfsv0 quota format
3 */
4
5#ifndef _LINUX_QUOTA_TREE_H
6#define _LINUX_QUOTA_TREE_H
7
8#include <linux/types.h>
9#include <linux/quota.h>
10
11/*
12 * Structure of header of block with quota structures. It is padded to 16 bytes so
13 * there will be space for exactly 21 quota-entries in a block
14 */
15struct qt_disk_dqdbheader {
16 __le32 dqdh_next_free; /* Number of next block with free entry */
17 __le32 dqdh_prev_free; /* Number of previous block with free entry */
18 __le16 dqdh_entries; /* Number of valid entries in block */
19 __le16 dqdh_pad1;
20 __le32 dqdh_pad2;
21};
22
23#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
24
25#endif /* _LINUX_QUOTAIO_TREE_H */
diff --git a/fs/quota_v1.c b/fs/quota_v1.c
index 5ae15b13eeb0..b4af1c69ad16 100644
--- a/fs/quota_v1.c
+++ b/fs/quota_v1.c
@@ -3,25 +3,39 @@
3#include <linux/quota.h> 3#include <linux/quota.h>
4#include <linux/quotaops.h> 4#include <linux/quotaops.h>
5#include <linux/dqblk_v1.h> 5#include <linux/dqblk_v1.h>
6#include <linux/quotaio_v1.h>
7#include <linux/kernel.h> 6#include <linux/kernel.h>
8#include <linux/init.h> 7#include <linux/init.h>
9#include <linux/module.h> 8#include <linux/module.h>
10 9
11#include <asm/byteorder.h> 10#include <asm/byteorder.h>
12 11
12#include "quotaio_v1.h"
13
13MODULE_AUTHOR("Jan Kara"); 14MODULE_AUTHOR("Jan Kara");
14MODULE_DESCRIPTION("Old quota format support"); 15MODULE_DESCRIPTION("Old quota format support");
15MODULE_LICENSE("GPL"); 16MODULE_LICENSE("GPL");
16 17
18#define QUOTABLOCK_BITS 10
19#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
20
21static inline qsize_t v1_stoqb(qsize_t space)
22{
23 return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
24}
25
26static inline qsize_t v1_qbtos(qsize_t blocks)
27{
28 return blocks << QUOTABLOCK_BITS;
29}
30
17static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d) 31static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d)
18{ 32{
19 m->dqb_ihardlimit = d->dqb_ihardlimit; 33 m->dqb_ihardlimit = d->dqb_ihardlimit;
20 m->dqb_isoftlimit = d->dqb_isoftlimit; 34 m->dqb_isoftlimit = d->dqb_isoftlimit;
21 m->dqb_curinodes = d->dqb_curinodes; 35 m->dqb_curinodes = d->dqb_curinodes;
22 m->dqb_bhardlimit = d->dqb_bhardlimit; 36 m->dqb_bhardlimit = v1_qbtos(d->dqb_bhardlimit);
23 m->dqb_bsoftlimit = d->dqb_bsoftlimit; 37 m->dqb_bsoftlimit = v1_qbtos(d->dqb_bsoftlimit);
24 m->dqb_curspace = ((qsize_t)d->dqb_curblocks) << QUOTABLOCK_BITS; 38 m->dqb_curspace = v1_qbtos(d->dqb_curblocks);
25 m->dqb_itime = d->dqb_itime; 39 m->dqb_itime = d->dqb_itime;
26 m->dqb_btime = d->dqb_btime; 40 m->dqb_btime = d->dqb_btime;
27} 41}
@@ -31,9 +45,9 @@ static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m)
31 d->dqb_ihardlimit = m->dqb_ihardlimit; 45 d->dqb_ihardlimit = m->dqb_ihardlimit;
32 d->dqb_isoftlimit = m->dqb_isoftlimit; 46 d->dqb_isoftlimit = m->dqb_isoftlimit;
33 d->dqb_curinodes = m->dqb_curinodes; 47 d->dqb_curinodes = m->dqb_curinodes;
34 d->dqb_bhardlimit = m->dqb_bhardlimit; 48 d->dqb_bhardlimit = v1_stoqb(m->dqb_bhardlimit);
35 d->dqb_bsoftlimit = m->dqb_bsoftlimit; 49 d->dqb_bsoftlimit = v1_stoqb(m->dqb_bsoftlimit);
36 d->dqb_curblocks = toqb(m->dqb_curspace); 50 d->dqb_curblocks = v1_stoqb(m->dqb_curspace);
37 d->dqb_itime = m->dqb_itime; 51 d->dqb_itime = m->dqb_itime;
38 d->dqb_btime = m->dqb_btime; 52 d->dqb_btime = m->dqb_btime;
39} 53}
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index b53827dc02d9..b618b563635c 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -6,7 +6,6 @@
6#include <linux/fs.h> 6#include <linux/fs.h>
7#include <linux/mount.h> 7#include <linux/mount.h>
8#include <linux/dqblk_v2.h> 8#include <linux/dqblk_v2.h>
9#include <linux/quotaio_v2.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/init.h> 10#include <linux/init.h>
12#include <linux/module.h> 11#include <linux/module.h>
@@ -15,16 +14,37 @@
15 14
16#include <asm/byteorder.h> 15#include <asm/byteorder.h>
17 16
17#include "quota_tree.h"
18#include "quotaio_v2.h"
19
18MODULE_AUTHOR("Jan Kara"); 20MODULE_AUTHOR("Jan Kara");
19MODULE_DESCRIPTION("Quota format v2 support"); 21MODULE_DESCRIPTION("Quota format v2 support");
20MODULE_LICENSE("GPL"); 22MODULE_LICENSE("GPL");
21 23
22#define __QUOTA_V2_PARANOIA 24#define __QUOTA_V2_PARANOIA
23 25
24typedef char *dqbuf_t; 26static void v2_mem2diskdqb(void *dp, struct dquot *dquot);
27static void v2_disk2memdqb(struct dquot *dquot, void *dp);
28static int v2_is_id(void *dp, struct dquot *dquot);
29
30static struct qtree_fmt_operations v2_qtree_ops = {
31 .mem2disk_dqblk = v2_mem2diskdqb,
32 .disk2mem_dqblk = v2_disk2memdqb,
33 .is_id = v2_is_id,
34};
35
36#define QUOTABLOCK_BITS 10
37#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
25 38
26#define GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff) 39static inline qsize_t v2_stoqb(qsize_t space)
27#define GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)buf)+sizeof(struct v2_disk_dqdbheader))) 40{
41 return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
42}
43
44static inline qsize_t v2_qbtos(qsize_t blocks)
45{
46 return blocks << QUOTABLOCK_BITS;
47}
28 48
29/* Check whether given file is really vfsv0 quotafile */ 49/* Check whether given file is really vfsv0 quotafile */
30static int v2_check_quota_file(struct super_block *sb, int type) 50static int v2_check_quota_file(struct super_block *sb, int type)
@@ -50,7 +70,8 @@ static int v2_check_quota_file(struct super_block *sb, int type)
50static int v2_read_file_info(struct super_block *sb, int type) 70static int v2_read_file_info(struct super_block *sb, int type)
51{ 71{
52 struct v2_disk_dqinfo dinfo; 72 struct v2_disk_dqinfo dinfo;
53 struct mem_dqinfo *info = sb_dqopt(sb)->info+type; 73 struct mem_dqinfo *info = sb_dqinfo(sb, type);
74 struct qtree_mem_dqinfo *qinfo;
54 ssize_t size; 75 ssize_t size;
55 76
56 size = sb->s_op->quota_read(sb, type, (char *)&dinfo, 77 size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
@@ -60,15 +81,29 @@ static int v2_read_file_info(struct super_block *sb, int type)
60 sb->s_id); 81 sb->s_id);
61 return -1; 82 return -1;
62 } 83 }
84 info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
85 if (!info->dqi_priv) {
86 printk(KERN_WARNING
87 "Not enough memory for quota information structure.\n");
88 return -1;
89 }
90 qinfo = info->dqi_priv;
63 /* limits are stored as unsigned 32-bit data */ 91 /* limits are stored as unsigned 32-bit data */
64 info->dqi_maxblimit = 0xffffffff; 92 info->dqi_maxblimit = 0xffffffff;
65 info->dqi_maxilimit = 0xffffffff; 93 info->dqi_maxilimit = 0xffffffff;
66 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); 94 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
67 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); 95 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
68 info->dqi_flags = le32_to_cpu(dinfo.dqi_flags); 96 info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
69 info->u.v2_i.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); 97 qinfo->dqi_sb = sb;
70 info->u.v2_i.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); 98 qinfo->dqi_type = type;
71 info->u.v2_i.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); 99 qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
100 qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
101 qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
102 qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
103 qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
104 qinfo->dqi_qtree_depth = qtree_depth(qinfo);
105 qinfo->dqi_entry_size = sizeof(struct v2_disk_dqblk);
106 qinfo->dqi_ops = &v2_qtree_ops;
72 return 0; 107 return 0;
73} 108}
74 109
@@ -76,7 +111,8 @@ static int v2_read_file_info(struct super_block *sb, int type)
76static int v2_write_file_info(struct super_block *sb, int type) 111static int v2_write_file_info(struct super_block *sb, int type)
77{ 112{
78 struct v2_disk_dqinfo dinfo; 113 struct v2_disk_dqinfo dinfo;
79 struct mem_dqinfo *info = sb_dqopt(sb)->info+type; 114 struct mem_dqinfo *info = sb_dqinfo(sb, type);
115 struct qtree_mem_dqinfo *qinfo = info->dqi_priv;
80 ssize_t size; 116 ssize_t size;
81 117
82 spin_lock(&dq_data_lock); 118 spin_lock(&dq_data_lock);
@@ -85,9 +121,9 @@ static int v2_write_file_info(struct super_block *sb, int type)
85 dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace); 121 dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace);
86 dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK); 122 dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK);
87 spin_unlock(&dq_data_lock); 123 spin_unlock(&dq_data_lock);
88 dinfo.dqi_blocks = cpu_to_le32(info->u.v2_i.dqi_blocks); 124 dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks);
89 dinfo.dqi_free_blk = cpu_to_le32(info->u.v2_i.dqi_free_blk); 125 dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk);
90 dinfo.dqi_free_entry = cpu_to_le32(info->u.v2_i.dqi_free_entry); 126 dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry);
91 size = sb->s_op->quota_write(sb, type, (char *)&dinfo, 127 size = sb->s_op->quota_write(sb, type, (char *)&dinfo,
92 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); 128 sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
93 if (size != sizeof(struct v2_disk_dqinfo)) { 129 if (size != sizeof(struct v2_disk_dqinfo)) {
@@ -98,574 +134,75 @@ static int v2_write_file_info(struct super_block *sb, int type)
98 return 0; 134 return 0;
99} 135}
100 136
101static void disk2memdqb(struct mem_dqblk *m, struct v2_disk_dqblk *d) 137static void v2_disk2memdqb(struct dquot *dquot, void *dp)
102{ 138{
139 struct v2_disk_dqblk *d = dp, empty;
140 struct mem_dqblk *m = &dquot->dq_dqb;
141
103 m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit); 142 m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit);
104 m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit); 143 m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit);
105 m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes); 144 m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes);
106 m->dqb_itime = le64_to_cpu(d->dqb_itime); 145 m->dqb_itime = le64_to_cpu(d->dqb_itime);
107 m->dqb_bhardlimit = le32_to_cpu(d->dqb_bhardlimit); 146 m->dqb_bhardlimit = v2_qbtos(le32_to_cpu(d->dqb_bhardlimit));
108 m->dqb_bsoftlimit = le32_to_cpu(d->dqb_bsoftlimit); 147 m->dqb_bsoftlimit = v2_qbtos(le32_to_cpu(d->dqb_bsoftlimit));
109 m->dqb_curspace = le64_to_cpu(d->dqb_curspace); 148 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
110 m->dqb_btime = le64_to_cpu(d->dqb_btime); 149 m->dqb_btime = le64_to_cpu(d->dqb_btime);
150 /* We need to escape back all-zero structure */
151 memset(&empty, 0, sizeof(struct v2_disk_dqblk));
152 empty.dqb_itime = cpu_to_le64(1);
153 if (!memcmp(&empty, dp, sizeof(struct v2_disk_dqblk)))
154 m->dqb_itime = 0;
111} 155}
112 156
113static void mem2diskdqb(struct v2_disk_dqblk *d, struct mem_dqblk *m, qid_t id) 157static void v2_mem2diskdqb(void *dp, struct dquot *dquot)
114{ 158{
159 struct v2_disk_dqblk *d = dp;
160 struct mem_dqblk *m = &dquot->dq_dqb;
161 struct qtree_mem_dqinfo *info =
162 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
163
115 d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit); 164 d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit);
116 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); 165 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit);
117 d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes); 166 d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes);
118 d->dqb_itime = cpu_to_le64(m->dqb_itime); 167 d->dqb_itime = cpu_to_le64(m->dqb_itime);
119 d->dqb_bhardlimit = cpu_to_le32(m->dqb_bhardlimit); 168 d->dqb_bhardlimit = cpu_to_le32(v2_stoqb(m->dqb_bhardlimit));
120 d->dqb_bsoftlimit = cpu_to_le32(m->dqb_bsoftlimit); 169 d->dqb_bsoftlimit = cpu_to_le32(v2_stoqb(m->dqb_bsoftlimit));
121 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 170 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
122 d->dqb_btime = cpu_to_le64(m->dqb_btime); 171 d->dqb_btime = cpu_to_le64(m->dqb_btime);
123 d->dqb_id = cpu_to_le32(id); 172 d->dqb_id = cpu_to_le32(dquot->dq_id);
124} 173 if (qtree_entry_unused(info, dp))
125 174 d->dqb_itime = cpu_to_le64(1);
126static dqbuf_t getdqbuf(void)
127{
128 dqbuf_t buf = kmalloc(V2_DQBLKSIZE, GFP_NOFS);
129 if (!buf)
130 printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n");
131 return buf;
132}
133
134static inline void freedqbuf(dqbuf_t buf)
135{
136 kfree(buf);
137}
138
139static inline ssize_t read_blk(struct super_block *sb, int type, uint blk, dqbuf_t buf)
140{
141 memset(buf, 0, V2_DQBLKSIZE);
142 return sb->s_op->quota_read(sb, type, (char *)buf,
143 V2_DQBLKSIZE, blk << V2_DQBLKSIZE_BITS);
144}
145
146static inline ssize_t write_blk(struct super_block *sb, int type, uint blk, dqbuf_t buf)
147{
148 return sb->s_op->quota_write(sb, type, (char *)buf,
149 V2_DQBLKSIZE, blk << V2_DQBLKSIZE_BITS);
150}
151
152/* Remove empty block from list and return it */
153static int get_free_dqblk(struct super_block *sb, int type)
154{
155 dqbuf_t buf = getdqbuf();
156 struct mem_dqinfo *info = sb_dqinfo(sb, type);
157 struct v2_disk_dqdbheader *dh = (struct v2_disk_dqdbheader *)buf;
158 int ret, blk;
159
160 if (!buf)
161 return -ENOMEM;
162 if (info->u.v2_i.dqi_free_blk) {
163 blk = info->u.v2_i.dqi_free_blk;
164 if ((ret = read_blk(sb, type, blk, buf)) < 0)
165 goto out_buf;
166 info->u.v2_i.dqi_free_blk = le32_to_cpu(dh->dqdh_next_free);
167 }
168 else {
169 memset(buf, 0, V2_DQBLKSIZE);
170 /* Assure block allocation... */
171 if ((ret = write_blk(sb, type, info->u.v2_i.dqi_blocks, buf)) < 0)
172 goto out_buf;
173 blk = info->u.v2_i.dqi_blocks++;
174 }
175 mark_info_dirty(sb, type);
176 ret = blk;
177out_buf:
178 freedqbuf(buf);
179 return ret;
180}
181
182/* Insert empty block to the list */
183static int put_free_dqblk(struct super_block *sb, int type, dqbuf_t buf, uint blk)
184{
185 struct mem_dqinfo *info = sb_dqinfo(sb, type);
186 struct v2_disk_dqdbheader *dh = (struct v2_disk_dqdbheader *)buf;
187 int err;
188
189 dh->dqdh_next_free = cpu_to_le32(info->u.v2_i.dqi_free_blk);
190 dh->dqdh_prev_free = cpu_to_le32(0);
191 dh->dqdh_entries = cpu_to_le16(0);
192 info->u.v2_i.dqi_free_blk = blk;
193 mark_info_dirty(sb, type);
194 /* Some strange block. We had better leave it... */
195 if ((err = write_blk(sb, type, blk, buf)) < 0)
196 return err;
197 return 0;
198} 175}
199 176
200/* Remove given block from the list of blocks with free entries */ 177static int v2_is_id(void *dp, struct dquot *dquot)
201static int remove_free_dqentry(struct super_block *sb, int type, dqbuf_t buf, uint blk)
202{ 178{
203 dqbuf_t tmpbuf = getdqbuf(); 179 struct v2_disk_dqblk *d = dp;
204 struct mem_dqinfo *info = sb_dqinfo(sb, type); 180 struct qtree_mem_dqinfo *info =
205 struct v2_disk_dqdbheader *dh = (struct v2_disk_dqdbheader *)buf; 181 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
206 uint nextblk = le32_to_cpu(dh->dqdh_next_free), prevblk = le32_to_cpu(dh->dqdh_prev_free);
207 int err;
208 182
209 if (!tmpbuf) 183 if (qtree_entry_unused(info, dp))
210 return -ENOMEM;
211 if (nextblk) {
212 if ((err = read_blk(sb, type, nextblk, tmpbuf)) < 0)
213 goto out_buf;
214 ((struct v2_disk_dqdbheader *)tmpbuf)->dqdh_prev_free = dh->dqdh_prev_free;
215 if ((err = write_blk(sb, type, nextblk, tmpbuf)) < 0)
216 goto out_buf;
217 }
218 if (prevblk) {
219 if ((err = read_blk(sb, type, prevblk, tmpbuf)) < 0)
220 goto out_buf;
221 ((struct v2_disk_dqdbheader *)tmpbuf)->dqdh_next_free = dh->dqdh_next_free;
222 if ((err = write_blk(sb, type, prevblk, tmpbuf)) < 0)
223 goto out_buf;
224 }
225 else {
226 info->u.v2_i.dqi_free_entry = nextblk;
227 mark_info_dirty(sb, type);
228 }
229 freedqbuf(tmpbuf);
230 dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0);
231 /* No matter whether write succeeds block is out of list */
232 if (write_blk(sb, type, blk, buf) < 0)
233 printk(KERN_ERR "VFS: Can't write block (%u) with free entries.\n", blk);
234 return 0;
235out_buf:
236 freedqbuf(tmpbuf);
237 return err;
238}
239
240/* Insert given block to the beginning of list with free entries */
241static int insert_free_dqentry(struct super_block *sb, int type, dqbuf_t buf, uint blk)
242{
243 dqbuf_t tmpbuf = getdqbuf();
244 struct mem_dqinfo *info = sb_dqinfo(sb, type);
245 struct v2_disk_dqdbheader *dh = (struct v2_disk_dqdbheader *)buf;
246 int err;
247
248 if (!tmpbuf)
249 return -ENOMEM;
250 dh->dqdh_next_free = cpu_to_le32(info->u.v2_i.dqi_free_entry);
251 dh->dqdh_prev_free = cpu_to_le32(0);
252 if ((err = write_blk(sb, type, blk, buf)) < 0)
253 goto out_buf;
254 if (info->u.v2_i.dqi_free_entry) {
255 if ((err = read_blk(sb, type, info->u.v2_i.dqi_free_entry, tmpbuf)) < 0)
256 goto out_buf;
257 ((struct v2_disk_dqdbheader *)tmpbuf)->dqdh_prev_free = cpu_to_le32(blk);
258 if ((err = write_blk(sb, type, info->u.v2_i.dqi_free_entry, tmpbuf)) < 0)
259 goto out_buf;
260 }
261 freedqbuf(tmpbuf);
262 info->u.v2_i.dqi_free_entry = blk;
263 mark_info_dirty(sb, type);
264 return 0;
265out_buf:
266 freedqbuf(tmpbuf);
267 return err;
268}
269
270/* Find space for dquot */
271static uint find_free_dqentry(struct dquot *dquot, int *err)
272{
273 struct super_block *sb = dquot->dq_sb;
274 struct mem_dqinfo *info = sb_dqopt(sb)->info+dquot->dq_type;
275 uint blk, i;
276 struct v2_disk_dqdbheader *dh;
277 struct v2_disk_dqblk *ddquot;
278 struct v2_disk_dqblk fakedquot;
279 dqbuf_t buf;
280
281 *err = 0;
282 if (!(buf = getdqbuf())) {
283 *err = -ENOMEM;
284 return 0; 184 return 0;
285 } 185 return le32_to_cpu(d->dqb_id) == dquot->dq_id;
286 dh = (struct v2_disk_dqdbheader *)buf;
287 ddquot = GETENTRIES(buf);
288 if (info->u.v2_i.dqi_free_entry) {
289 blk = info->u.v2_i.dqi_free_entry;
290 if ((*err = read_blk(sb, dquot->dq_type, blk, buf)) < 0)
291 goto out_buf;
292 }
293 else {
294 blk = get_free_dqblk(sb, dquot->dq_type);
295 if ((int)blk < 0) {
296 *err = blk;
297 freedqbuf(buf);
298 return 0;
299 }
300 memset(buf, 0, V2_DQBLKSIZE);
301 /* This is enough as block is already zeroed and entry list is empty... */
302 info->u.v2_i.dqi_free_entry = blk;
303 mark_info_dirty(sb, dquot->dq_type);
304 }
305 if (le16_to_cpu(dh->dqdh_entries)+1 >= V2_DQSTRINBLK) /* Block will be full? */
306 if ((*err = remove_free_dqentry(sb, dquot->dq_type, buf, blk)) < 0) {
307 printk(KERN_ERR "VFS: find_free_dqentry(): Can't remove block (%u) from entry free list.\n", blk);
308 goto out_buf;
309 }
310 le16_add_cpu(&dh->dqdh_entries, 1);
311 memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk));
312 /* Find free structure in block */
313 for (i = 0; i < V2_DQSTRINBLK && memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)); i++);
314#ifdef __QUOTA_V2_PARANOIA
315 if (i == V2_DQSTRINBLK) {
316 printk(KERN_ERR "VFS: find_free_dqentry(): Data block full but it shouldn't.\n");
317 *err = -EIO;
318 goto out_buf;
319 }
320#endif
321 if ((*err = write_blk(sb, dquot->dq_type, blk, buf)) < 0) {
322 printk(KERN_ERR "VFS: find_free_dqentry(): Can't write quota data block %u.\n", blk);
323 goto out_buf;
324 }
325 dquot->dq_off = (blk<<V2_DQBLKSIZE_BITS)+sizeof(struct v2_disk_dqdbheader)+i*sizeof(struct v2_disk_dqblk);
326 freedqbuf(buf);
327 return blk;
328out_buf:
329 freedqbuf(buf);
330 return 0;
331}
332
333/* Insert reference to structure into the trie */
334static int do_insert_tree(struct dquot *dquot, uint *treeblk, int depth)
335{
336 struct super_block *sb = dquot->dq_sb;
337 dqbuf_t buf;
338 int ret = 0, newson = 0, newact = 0;
339 __le32 *ref;
340 uint newblk;
341
342 if (!(buf = getdqbuf()))
343 return -ENOMEM;
344 if (!*treeblk) {
345 ret = get_free_dqblk(sb, dquot->dq_type);
346 if (ret < 0)
347 goto out_buf;
348 *treeblk = ret;
349 memset(buf, 0, V2_DQBLKSIZE);
350 newact = 1;
351 }
352 else {
353 if ((ret = read_blk(sb, dquot->dq_type, *treeblk, buf)) < 0) {
354 printk(KERN_ERR "VFS: Can't read tree quota block %u.\n", *treeblk);
355 goto out_buf;
356 }
357 }
358 ref = (__le32 *)buf;
359 newblk = le32_to_cpu(ref[GETIDINDEX(dquot->dq_id, depth)]);
360 if (!newblk)
361 newson = 1;
362 if (depth == V2_DQTREEDEPTH-1) {
363#ifdef __QUOTA_V2_PARANOIA
364 if (newblk) {
365 printk(KERN_ERR "VFS: Inserting already present quota entry (block %u).\n", le32_to_cpu(ref[GETIDINDEX(dquot->dq_id, depth)]));
366 ret = -EIO;
367 goto out_buf;
368 }
369#endif
370 newblk = find_free_dqentry(dquot, &ret);
371 }
372 else
373 ret = do_insert_tree(dquot, &newblk, depth+1);
374 if (newson && ret >= 0) {
375 ref[GETIDINDEX(dquot->dq_id, depth)] = cpu_to_le32(newblk);
376 ret = write_blk(sb, dquot->dq_type, *treeblk, buf);
377 }
378 else if (newact && ret < 0)
379 put_free_dqblk(sb, dquot->dq_type, buf, *treeblk);
380out_buf:
381 freedqbuf(buf);
382 return ret;
383} 186}
384 187
385/* Wrapper for inserting quota structure into tree */ 188static int v2_read_dquot(struct dquot *dquot)
386static inline int dq_insert_tree(struct dquot *dquot)
387{ 189{
388 int tmp = V2_DQTREEOFF; 190 return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
389 return do_insert_tree(dquot, &tmp, 0);
390} 191}
391 192
392/*
393 * We don't have to be afraid of deadlocks as we never have quotas on quota files...
394 */
395static int v2_write_dquot(struct dquot *dquot) 193static int v2_write_dquot(struct dquot *dquot)
396{ 194{
397 int type = dquot->dq_type; 195 return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
398 ssize_t ret;
399 struct v2_disk_dqblk ddquot, empty;
400
401 /* dq_off is guarded by dqio_mutex */
402 if (!dquot->dq_off)
403 if ((ret = dq_insert_tree(dquot)) < 0) {
404 printk(KERN_ERR "VFS: Error %zd occurred while creating quota.\n", ret);
405 return ret;
406 }
407 spin_lock(&dq_data_lock);
408 mem2diskdqb(&ddquot, &dquot->dq_dqb, dquot->dq_id);
409 /* Argh... We may need to write structure full of zeroes but that would be
410 * treated as an empty place by the rest of the code. Format change would
411 * be definitely cleaner but the problems probably are not worth it */
412 memset(&empty, 0, sizeof(struct v2_disk_dqblk));
413 if (!memcmp(&empty, &ddquot, sizeof(struct v2_disk_dqblk)))
414 ddquot.dqb_itime = cpu_to_le64(1);
415 spin_unlock(&dq_data_lock);
416 ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
417 (char *)&ddquot, sizeof(struct v2_disk_dqblk), dquot->dq_off);
418 if (ret != sizeof(struct v2_disk_dqblk)) {
419 printk(KERN_WARNING "VFS: dquota write failed on dev %s\n", dquot->dq_sb->s_id);
420 if (ret >= 0)
421 ret = -ENOSPC;
422 }
423 else
424 ret = 0;
425 dqstats.writes++;
426
427 return ret;
428} 196}
429 197
430/* Free dquot entry in data block */ 198static int v2_release_dquot(struct dquot *dquot)
431static int free_dqentry(struct dquot *dquot, uint blk)
432{
433 struct super_block *sb = dquot->dq_sb;
434 int type = dquot->dq_type;
435 struct v2_disk_dqdbheader *dh;
436 dqbuf_t buf = getdqbuf();
437 int ret = 0;
438
439 if (!buf)
440 return -ENOMEM;
441 if (dquot->dq_off >> V2_DQBLKSIZE_BITS != blk) {
442 printk(KERN_ERR "VFS: Quota structure has offset to other "
443 "block (%u) than it should (%u).\n", blk,
444 (uint)(dquot->dq_off >> V2_DQBLKSIZE_BITS));
445 goto out_buf;
446 }
447 if ((ret = read_blk(sb, type, blk, buf)) < 0) {
448 printk(KERN_ERR "VFS: Can't read quota data block %u\n", blk);
449 goto out_buf;
450 }
451 dh = (struct v2_disk_dqdbheader *)buf;
452 le16_add_cpu(&dh->dqdh_entries, -1);
453 if (!le16_to_cpu(dh->dqdh_entries)) { /* Block got free? */
454 if ((ret = remove_free_dqentry(sb, type, buf, blk)) < 0 ||
455 (ret = put_free_dqblk(sb, type, buf, blk)) < 0) {
456 printk(KERN_ERR "VFS: Can't move quota data block (%u) "
457 "to free list.\n", blk);
458 goto out_buf;
459 }
460 }
461 else {
462 memset(buf+(dquot->dq_off & ((1 << V2_DQBLKSIZE_BITS)-1)), 0,
463 sizeof(struct v2_disk_dqblk));
464 if (le16_to_cpu(dh->dqdh_entries) == V2_DQSTRINBLK-1) {
465 /* Insert will write block itself */
466 if ((ret = insert_free_dqentry(sb, type, buf, blk)) < 0) {
467 printk(KERN_ERR "VFS: Can't insert quota data block (%u) to free entry list.\n", blk);
468 goto out_buf;
469 }
470 }
471 else
472 if ((ret = write_blk(sb, type, blk, buf)) < 0) {
473 printk(KERN_ERR "VFS: Can't write quota data "
474 "block %u\n", blk);
475 goto out_buf;
476 }
477 }
478 dquot->dq_off = 0; /* Quota is now unattached */
479out_buf:
480 freedqbuf(buf);
481 return ret;
482}
483
484/* Remove reference to dquot from tree */
485static int remove_tree(struct dquot *dquot, uint *blk, int depth)
486{
487 struct super_block *sb = dquot->dq_sb;
488 int type = dquot->dq_type;
489 dqbuf_t buf = getdqbuf();
490 int ret = 0;
491 uint newblk;
492 __le32 *ref = (__le32 *)buf;
493
494 if (!buf)
495 return -ENOMEM;
496 if ((ret = read_blk(sb, type, *blk, buf)) < 0) {
497 printk(KERN_ERR "VFS: Can't read quota data block %u\n", *blk);
498 goto out_buf;
499 }
500 newblk = le32_to_cpu(ref[GETIDINDEX(dquot->dq_id, depth)]);
501 if (depth == V2_DQTREEDEPTH-1) {
502 ret = free_dqentry(dquot, newblk);
503 newblk = 0;
504 }
505 else
506 ret = remove_tree(dquot, &newblk, depth+1);
507 if (ret >= 0 && !newblk) {
508 int i;
509 ref[GETIDINDEX(dquot->dq_id, depth)] = cpu_to_le32(0);
510 for (i = 0; i < V2_DQBLKSIZE && !buf[i]; i++); /* Block got empty? */
511 /* Don't put the root block into the free block list */
512 if (i == V2_DQBLKSIZE && *blk != V2_DQTREEOFF) {
513 put_free_dqblk(sb, type, buf, *blk);
514 *blk = 0;
515 }
516 else
517 if ((ret = write_blk(sb, type, *blk, buf)) < 0)
518 printk(KERN_ERR "VFS: Can't write quota tree "
519 "block %u.\n", *blk);
520 }
521out_buf:
522 freedqbuf(buf);
523 return ret;
524}
525
526/* Delete dquot from tree */
527static int v2_delete_dquot(struct dquot *dquot)
528{
529 uint tmp = V2_DQTREEOFF;
530
531 if (!dquot->dq_off) /* Even not allocated? */
532 return 0;
533 return remove_tree(dquot, &tmp, 0);
534}
535
536/* Find entry in block */
537static loff_t find_block_dqentry(struct dquot *dquot, uint blk)
538{
539 dqbuf_t buf = getdqbuf();
540 loff_t ret = 0;
541 int i;
542 struct v2_disk_dqblk *ddquot = GETENTRIES(buf);
543
544 if (!buf)
545 return -ENOMEM;
546 if ((ret = read_blk(dquot->dq_sb, dquot->dq_type, blk, buf)) < 0) {
547 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
548 goto out_buf;
549 }
550 if (dquot->dq_id)
551 for (i = 0; i < V2_DQSTRINBLK &&
552 le32_to_cpu(ddquot[i].dqb_id) != dquot->dq_id; i++);
553 else { /* ID 0 as a bit more complicated searching... */
554 struct v2_disk_dqblk fakedquot;
555
556 memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk));
557 for (i = 0; i < V2_DQSTRINBLK; i++)
558 if (!le32_to_cpu(ddquot[i].dqb_id) &&
559 memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)))
560 break;
561 }
562 if (i == V2_DQSTRINBLK) {
563 printk(KERN_ERR "VFS: Quota for id %u referenced "
564 "but not present.\n", dquot->dq_id);
565 ret = -EIO;
566 goto out_buf;
567 }
568 else
569 ret = (blk << V2_DQBLKSIZE_BITS) + sizeof(struct
570 v2_disk_dqdbheader) + i * sizeof(struct v2_disk_dqblk);
571out_buf:
572 freedqbuf(buf);
573 return ret;
574}
575
576/* Find entry for given id in the tree */
577static loff_t find_tree_dqentry(struct dquot *dquot, uint blk, int depth)
578{
579 dqbuf_t buf = getdqbuf();
580 loff_t ret = 0;
581 __le32 *ref = (__le32 *)buf;
582
583 if (!buf)
584 return -ENOMEM;
585 if ((ret = read_blk(dquot->dq_sb, dquot->dq_type, blk, buf)) < 0) {
586 printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
587 goto out_buf;
588 }
589 ret = 0;
590 blk = le32_to_cpu(ref[GETIDINDEX(dquot->dq_id, depth)]);
591 if (!blk) /* No reference? */
592 goto out_buf;
593 if (depth < V2_DQTREEDEPTH-1)
594 ret = find_tree_dqentry(dquot, blk, depth+1);
595 else
596 ret = find_block_dqentry(dquot, blk);
597out_buf:
598 freedqbuf(buf);
599 return ret;
600}
601
602/* Find entry for given id in the tree - wrapper function */
603static inline loff_t find_dqentry(struct dquot *dquot)
604{
605 return find_tree_dqentry(dquot, V2_DQTREEOFF, 0);
606}
607
608static int v2_read_dquot(struct dquot *dquot)
609{ 199{
610 int type = dquot->dq_type; 200 return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot);
611 loff_t offset;
612 struct v2_disk_dqblk ddquot, empty;
613 int ret = 0;
614
615#ifdef __QUOTA_V2_PARANOIA
616 /* Invalidated quota? */
617 if (!dquot->dq_sb || !sb_dqopt(dquot->dq_sb)->files[type]) {
618 printk(KERN_ERR "VFS: Quota invalidated while reading!\n");
619 return -EIO;
620 }
621#endif
622 offset = find_dqentry(dquot);
623 if (offset <= 0) { /* Entry not present? */
624 if (offset < 0)
625 printk(KERN_ERR "VFS: Can't read quota "
626 "structure for id %u.\n", dquot->dq_id);
627 dquot->dq_off = 0;
628 set_bit(DQ_FAKE_B, &dquot->dq_flags);
629 memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
630 ret = offset;
631 }
632 else {
633 dquot->dq_off = offset;
634 if ((ret = dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type,
635 (char *)&ddquot, sizeof(struct v2_disk_dqblk), offset))
636 != sizeof(struct v2_disk_dqblk)) {
637 if (ret >= 0)
638 ret = -EIO;
639 printk(KERN_ERR "VFS: Error while reading quota "
640 "structure for id %u.\n", dquot->dq_id);
641 memset(&ddquot, 0, sizeof(struct v2_disk_dqblk));
642 }
643 else {
644 ret = 0;
645 /* We need to escape back all-zero structure */
646 memset(&empty, 0, sizeof(struct v2_disk_dqblk));
647 empty.dqb_itime = cpu_to_le64(1);
648 if (!memcmp(&empty, &ddquot, sizeof(struct v2_disk_dqblk)))
649 ddquot.dqb_itime = 0;
650 }
651 disk2memdqb(&dquot->dq_dqb, &ddquot);
652 if (!dquot->dq_dqb.dqb_bhardlimit &&
653 !dquot->dq_dqb.dqb_bsoftlimit &&
654 !dquot->dq_dqb.dqb_ihardlimit &&
655 !dquot->dq_dqb.dqb_isoftlimit)
656 set_bit(DQ_FAKE_B, &dquot->dq_flags);
657 }
658 dqstats.reads++;
659
660 return ret;
661} 201}
662 202
663/* Check whether dquot should not be deleted. We know we are 203static int v2_free_file_info(struct super_block *sb, int type)
664 * the only one operating on dquot (thanks to dq_lock) */
665static int v2_release_dquot(struct dquot *dquot)
666{ 204{
667 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace)) 205 kfree(sb_dqinfo(sb, type)->dqi_priv);
668 return v2_delete_dquot(dquot);
669 return 0; 206 return 0;
670} 207}
671 208
@@ -673,7 +210,7 @@ static struct quota_format_ops v2_format_ops = {
673 .check_quota_file = v2_check_quota_file, 210 .check_quota_file = v2_check_quota_file,
674 .read_file_info = v2_read_file_info, 211 .read_file_info = v2_read_file_info,
675 .write_file_info = v2_write_file_info, 212 .write_file_info = v2_write_file_info,
676 .free_file_info = NULL, 213 .free_file_info = v2_free_file_info,
677 .read_dqblk = v2_read_dquot, 214 .read_dqblk = v2_read_dquot,
678 .commit_dqblk = v2_write_dquot, 215 .commit_dqblk = v2_write_dquot,
679 .release_dqblk = v2_release_dquot, 216 .release_dqblk = v2_release_dquot,
diff --git a/include/linux/quotaio_v1.h b/fs/quotaio_v1.h
index 746654b5de70..746654b5de70 100644
--- a/include/linux/quotaio_v1.h
+++ b/fs/quotaio_v1.h
diff --git a/include/linux/quotaio_v2.h b/fs/quotaio_v2.h
index 303d7cbe30d4..530fe580685c 100644
--- a/include/linux/quotaio_v2.h
+++ b/fs/quotaio_v2.h
@@ -21,6 +21,12 @@
21 0 /* GRPQUOTA */\ 21 0 /* GRPQUOTA */\
22} 22}
23 23
24/* First generic header */
25struct v2_disk_dqheader {
26 __le32 dqh_magic; /* Magic number identifying file */
27 __le32 dqh_version; /* File version */
28};
29
24/* 30/*
25 * The following structure defines the format of the disk quota file 31 * The following structure defines the format of the disk quota file
26 * (as it appears on disk) - the file is a radix tree whose leaves point 32 * (as it appears on disk) - the file is a radix tree whose leaves point
@@ -38,15 +44,6 @@ struct v2_disk_dqblk {
38 __le64 dqb_itime; /* time limit for excessive inode use */ 44 __le64 dqb_itime; /* time limit for excessive inode use */
39}; 45};
40 46
41/*
42 * Here are header structures as written on disk and their in-memory copies
43 */
44/* First generic header */
45struct v2_disk_dqheader {
46 __le32 dqh_magic; /* Magic number identifying file */
47 __le32 dqh_version; /* File version */
48};
49
50/* Header with type and version specific information */ 47/* Header with type and version specific information */
51struct v2_disk_dqinfo { 48struct v2_disk_dqinfo {
52 __le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */ 49 __le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */
@@ -57,23 +54,7 @@ struct v2_disk_dqinfo {
57 __le32 dqi_free_entry; /* Number of block with at least one free entry */ 54 __le32 dqi_free_entry; /* Number of block with at least one free entry */
58}; 55};
59 56
60/*
61 * Structure of header of block with quota structures. It is padded to 16 bytes so
62 * there will be space for exactly 21 quota-entries in a block
63 */
64struct v2_disk_dqdbheader {
65 __le32 dqdh_next_free; /* Number of next block with free entry */
66 __le32 dqdh_prev_free; /* Number of previous block with free entry */
67 __le16 dqdh_entries; /* Number of valid entries in block */
68 __le16 dqdh_pad1;
69 __le32 dqdh_pad2;
70};
71
72#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader) /* Offset of info header in file */ 57#define V2_DQINFOOFF sizeof(struct v2_disk_dqheader) /* Offset of info header in file */
73#define V2_DQBLKSIZE_BITS 10 58#define V2_DQBLKSIZE_BITS 10 /* Size of leaf block in tree */
74#define V2_DQBLKSIZE (1 << V2_DQBLKSIZE_BITS) /* Size of block with quota structures */
75#define V2_DQTREEOFF 1 /* Offset of tree in file in blocks */
76#define V2_DQTREEDEPTH 4 /* Depth of quota tree */
77#define V2_DQSTRINBLK ((V2_DQBLKSIZE - sizeof(struct v2_disk_dqdbheader)) / sizeof(struct v2_disk_dqblk)) /* Number of entries in one blocks */
78 59
79#endif /* _LINUX_QUOTAIO_V2_H */ 60#endif /* _LINUX_QUOTAIO_V2_H */
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index a83a3518ae33..b7e6ac706b87 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -57,7 +57,6 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
57 inode->i_mode = mode; 57 inode->i_mode = mode;
58 inode->i_uid = current_fsuid(); 58 inode->i_uid = current_fsuid();
59 inode->i_gid = current_fsgid(); 59 inode->i_gid = current_fsgid();
60 inode->i_blocks = 0;
61 inode->i_mapping->a_ops = &ramfs_aops; 60 inode->i_mapping->a_ops = &ramfs_aops;
62 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; 61 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
63 mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); 62 mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER);
diff --git a/fs/read_write.c b/fs/read_write.c
index 969a6d9c020b..5cc6924eb158 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -50,6 +50,14 @@ generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
50 offset += inode->i_size; 50 offset += inode->i_size;
51 break; 51 break;
52 case SEEK_CUR: 52 case SEEK_CUR:
53 /*
54 * Here we special-case the lseek(fd, 0, SEEK_CUR)
55 * position-querying operation. Avoid rewriting the "same"
56 * f_pos value back to the file because a concurrent read(),
57 * write() or lseek() might have altered it
58 */
59 if (offset == 0)
60 return file->f_pos;
53 offset += file->f_pos; 61 offset += file->f_pos;
54 break; 62 break;
55 } 63 }
@@ -105,6 +113,10 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
105 offset += i_size_read(file->f_path.dentry->d_inode); 113 offset += i_size_read(file->f_path.dentry->d_inode);
106 break; 114 break;
107 case SEEK_CUR: 115 case SEEK_CUR:
116 if (offset == 0) {
117 retval = file->f_pos;
118 goto out;
119 }
108 offset += file->f_pos; 120 offset += file->f_pos;
109 } 121 }
110 retval = -EINVAL; 122 retval = -EINVAL;
@@ -115,6 +127,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
115 } 127 }
116 retval = offset; 128 retval = offset;
117 } 129 }
130out:
118 unlock_kernel(); 131 unlock_kernel();
119 return retval; 132 return retval;
120} 133}
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 145c2d3e5e01..55fce92cdf18 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1782,6 +1782,12 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1782 goto out_bad_inode; 1782 goto out_bad_inode;
1783 } 1783 }
1784 args.objectid = inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid); 1784 args.objectid = inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid);
1785 if (old_format_only(sb))
1786 make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
1787 TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
1788 else
1789 make_le_item_head(&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET,
1790 TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
1785 memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE); 1791 memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
1786 args.dirid = le32_to_cpu(ih.ih_key.k_dir_id); 1792 args.dirid = le32_to_cpu(ih.ih_key.k_dir_id);
1787 if (insert_inode_locked4(inode, args.objectid, 1793 if (insert_inode_locked4(inode, args.objectid,
@@ -1834,13 +1840,6 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1834 reiserfs_init_acl_default(inode); 1840 reiserfs_init_acl_default(inode);
1835 reiserfs_init_xattr_rwsem(inode); 1841 reiserfs_init_xattr_rwsem(inode);
1836 1842
1837 if (old_format_only(sb))
1838 make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
1839 TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
1840 else
1841 make_le_item_head(&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET,
1842 TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
1843
1844 /* key to search for correct place for new stat data */ 1843 /* key to search for correct place for new stat data */
1845 _make_cpu_key(&key, KEY_FORMAT_3_6, le32_to_cpu(ih.ih_key.k_dir_id), 1844 _make_cpu_key(&key, KEY_FORMAT_3_6, le32_to_cpu(ih.ih_key.k_dir_id),
1846 le32_to_cpu(ih.ih_key.k_objectid), SD_OFFSET, 1845 le32_to_cpu(ih.ih_key.k_objectid), SD_OFFSET,
@@ -2561,7 +2560,7 @@ static int reiserfs_write_begin(struct file *file,
2561 } 2560 }
2562 2561
2563 index = pos >> PAGE_CACHE_SHIFT; 2562 index = pos >> PAGE_CACHE_SHIFT;
2564 page = __grab_cache_page(mapping, index); 2563 page = grab_cache_page_write_begin(mapping, index, flags);
2565 if (!page) 2564 if (!page)
2566 return -ENOMEM; 2565 return -ENOMEM;
2567 *pagep = page; 2566 *pagep = page;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 663a91f5dce8..c55651f1407c 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -649,6 +649,8 @@ static struct dquot_operations reiserfs_quota_operations = {
649 .release_dquot = reiserfs_release_dquot, 649 .release_dquot = reiserfs_release_dquot,
650 .mark_dirty = reiserfs_mark_dquot_dirty, 650 .mark_dirty = reiserfs_mark_dquot_dirty,
651 .write_info = reiserfs_write_info, 651 .write_info = reiserfs_write_info,
652 .alloc_dquot = dquot_alloc,
653 .destroy_dquot = dquot_destroy,
652}; 654};
653 655
654static struct quotactl_ops reiserfs_qctl_operations = { 656static struct quotactl_ops reiserfs_qctl_operations = {
@@ -994,8 +996,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
994 if (c == 'u' || c == 'g') { 996 if (c == 'u' || c == 'g') {
995 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA; 997 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
996 998
997 if ((sb_any_quota_enabled(s) || 999 if (sb_any_quota_loaded(s) &&
998 sb_any_quota_suspended(s)) &&
999 (!*arg != !REISERFS_SB(s)->s_qf_names[qtype])) { 1000 (!*arg != !REISERFS_SB(s)->s_qf_names[qtype])) {
1000 reiserfs_warning(s, 1001 reiserfs_warning(s,
1001 "reiserfs_parse_options: cannot change journaled quota options when quota turned on."); 1002 "reiserfs_parse_options: cannot change journaled quota options when quota turned on.");
@@ -1041,8 +1042,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
1041 "reiserfs_parse_options: unknown quota format specified."); 1042 "reiserfs_parse_options: unknown quota format specified.");
1042 return 0; 1043 return 0;
1043 } 1044 }
1044 if ((sb_any_quota_enabled(s) || 1045 if (sb_any_quota_loaded(s) &&
1045 sb_any_quota_suspended(s)) &&
1046 *qfmt != REISERFS_SB(s)->s_jquota_fmt) { 1046 *qfmt != REISERFS_SB(s)->s_jquota_fmt) {
1047 reiserfs_warning(s, 1047 reiserfs_warning(s,
1048 "reiserfs_parse_options: cannot change journaled quota options when quota turned on."); 1048 "reiserfs_parse_options: cannot change journaled quota options when quota turned on.");
@@ -1067,7 +1067,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
1067 } 1067 }
1068 /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ 1068 /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
1069 if (!(*mount_options & (1 << REISERFS_QUOTA)) 1069 if (!(*mount_options & (1 << REISERFS_QUOTA))
1070 && sb_any_quota_enabled(s)) { 1070 && sb_any_quota_loaded(s)) {
1071 reiserfs_warning(s, 1071 reiserfs_warning(s,
1072 "reiserfs_parse_options: quota options must be present when quota is turned on."); 1072 "reiserfs_parse_options: quota options must be present when quota is turned on.");
1073 return 0; 1073 return 0;
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 60d2f822e87b..c97d4c931715 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -524,7 +524,6 @@ romfs_iget(struct super_block *sb, unsigned long ino)
524 i->i_size = be32_to_cpu(ri.size); 524 i->i_size = be32_to_cpu(ri.size);
525 i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0; 525 i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
526 i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0; 526 i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
527 i->i_uid = i->i_gid = 0;
528 527
529 /* Precalculate the data offset */ 528 /* Precalculate the data offset */
530 ino = romfs_strnlen(i, ino+ROMFH_SIZE, ROMFS_MAXFN); 529 ino = romfs_strnlen(i, ino+ROMFH_SIZE, ROMFS_MAXFN);
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 99d8b8cfc9b7..b569ff1c4dc8 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -468,7 +468,8 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, char *esc)
468 return -1; 468 return -1;
469} 469}
470 470
471int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits) 471int seq_bitmap(struct seq_file *m, const unsigned long *bits,
472 unsigned int nr_bits)
472{ 473{
473 if (m->count < m->size) { 474 if (m->count < m->size) {
474 int len = bitmap_scnprintf(m->buf + m->count, 475 int len = bitmap_scnprintf(m->buf + m->count,
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c
index e4f8d51a5553..92d5e8ffb639 100644
--- a/fs/smbfs/file.c
+++ b/fs/smbfs/file.c
@@ -297,7 +297,7 @@ static int smb_write_begin(struct file *file, struct address_space *mapping,
297 struct page **pagep, void **fsdata) 297 struct page **pagep, void **fsdata)
298{ 298{
299 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 299 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
300 *pagep = __grab_cache_page(mapping, index); 300 *pagep = grab_cache_page_write_begin(mapping, index, flags);
301 if (!*pagep) 301 if (!*pagep)
302 return -ENOMEM; 302 return -ENOMEM;
303 return 0; 303 return 0;
diff --git a/fs/stat.c b/fs/stat.c
index 7c46fbeb8b76..7e12a6f82795 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -305,7 +305,7 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *pathname,
305 struct inode *inode = path.dentry->d_inode; 305 struct inode *inode = path.dentry->d_inode;
306 306
307 error = -EINVAL; 307 error = -EINVAL;
308 if (inode->i_op && inode->i_op->readlink) { 308 if (inode->i_op->readlink) {
309 error = security_inode_readlink(path.dentry); 309 error = security_inode_readlink(path.dentry);
310 if (!error) { 310 if (!error) {
311 touch_atime(path.mnt, path.dentry); 311 touch_atime(path.mnt, path.dentry);
diff --git a/fs/sync.c b/fs/sync.c
index 2967562d416f..0921d6d4b5e6 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -75,14 +75,39 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
75 return ret; 75 return ret;
76} 76}
77 77
78long do_fsync(struct file *file, int datasync) 78/**
79 * vfs_fsync - perform a fsync or fdatasync on a file
80 * @file: file to sync
81 * @dentry: dentry of @file
82 * @data: only perform a fdatasync operation
83 *
84 * Write back data and metadata for @file to disk. If @datasync is
85 * set only metadata needed to access modified file data is written.
86 *
87 * In case this function is called from nfsd @file may be %NULL and
88 * only @dentry is set. This can only happen when the filesystem
89 * implements the export_operations API.
90 */
91int vfs_fsync(struct file *file, struct dentry *dentry, int datasync)
79{ 92{
80 int ret; 93 const struct file_operations *fop;
81 int err; 94 struct address_space *mapping;
82 struct address_space *mapping = file->f_mapping; 95 int err, ret;
96
97 /*
98 * Get mapping and operations from the file in case we have
99 * as file, or get the default values for them in case we
100 * don't have a struct file available. Damn nfsd..
101 */
102 if (file) {
103 mapping = file->f_mapping;
104 fop = file->f_op;
105 } else {
106 mapping = dentry->d_inode->i_mapping;
107 fop = dentry->d_inode->i_fop;
108 }
83 109
84 if (!file->f_op || !file->f_op->fsync) { 110 if (!fop || !fop->fsync) {
85 /* Why? We can still call filemap_fdatawrite */
86 ret = -EINVAL; 111 ret = -EINVAL;
87 goto out; 112 goto out;
88 } 113 }
@@ -94,7 +119,7 @@ long do_fsync(struct file *file, int datasync)
94 * livelocks in fsync_buffers_list(). 119 * livelocks in fsync_buffers_list().
95 */ 120 */
96 mutex_lock(&mapping->host->i_mutex); 121 mutex_lock(&mapping->host->i_mutex);
97 err = file->f_op->fsync(file, file->f_path.dentry, datasync); 122 err = fop->fsync(file, dentry, datasync);
98 if (!ret) 123 if (!ret)
99 ret = err; 124 ret = err;
100 mutex_unlock(&mapping->host->i_mutex); 125 mutex_unlock(&mapping->host->i_mutex);
@@ -104,15 +129,16 @@ long do_fsync(struct file *file, int datasync)
104out: 129out:
105 return ret; 130 return ret;
106} 131}
132EXPORT_SYMBOL(vfs_fsync);
107 133
108static long __do_fsync(unsigned int fd, int datasync) 134static int do_fsync(unsigned int fd, int datasync)
109{ 135{
110 struct file *file; 136 struct file *file;
111 int ret = -EBADF; 137 int ret = -EBADF;
112 138
113 file = fget(fd); 139 file = fget(fd);
114 if (file) { 140 if (file) {
115 ret = do_fsync(file, datasync); 141 ret = vfs_fsync(file, file->f_path.dentry, datasync);
116 fput(file); 142 fput(file);
117 } 143 }
118 return ret; 144 return ret;
@@ -120,12 +146,12 @@ static long __do_fsync(unsigned int fd, int datasync)
120 146
121asmlinkage long sys_fsync(unsigned int fd) 147asmlinkage long sys_fsync(unsigned int fd)
122{ 148{
123 return __do_fsync(fd, 0); 149 return do_fsync(fd, 0);
124} 150}
125 151
126asmlinkage long sys_fdatasync(unsigned int fd) 152asmlinkage long sys_fdatasync(unsigned int fd)
127{ 153{
128 return __do_fsync(fd, 1); 154 return do_fsync(fd, 1);
129} 155}
130 156
131/* 157/*
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index eb53c632f856..dfa3d94cfc74 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -107,8 +107,6 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
107static inline void set_default_inode_attr(struct inode * inode, mode_t mode) 107static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
108{ 108{
109 inode->i_mode = mode; 109 inode->i_mode = mode;
110 inode->i_uid = 0;
111 inode->i_gid = 0;
112 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 110 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
113} 111}
114 112
@@ -149,7 +147,6 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
149{ 147{
150 struct bin_attribute *bin_attr; 148 struct bin_attribute *bin_attr;
151 149
152 inode->i_blocks = 0;
153 inode->i_mapping->a_ops = &sysfs_aops; 150 inode->i_mapping->a_ops = &sysfs_aops;
154 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; 151 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
155 inode->i_op = &sysfs_inode_operations; 152 inode->i_op = &sysfs_inode_operations;
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index 4a18f084cc42..0e5e54d82924 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -32,18 +32,15 @@
32 32
33#include "ubifs.h" 33#include "ubifs.h"
34#include <linux/writeback.h> 34#include <linux/writeback.h>
35#include <asm/div64.h> 35#include <linux/math64.h>
36 36
37/* 37/*
38 * When pessimistic budget calculations say that there is no enough space, 38 * When pessimistic budget calculations say that there is no enough space,
39 * UBIFS starts writing back dirty inodes and pages, doing garbage collection, 39 * UBIFS starts writing back dirty inodes and pages, doing garbage collection,
40 * or committing. The below constants define maximum number of times UBIFS 40 * or committing. The below constant defines maximum number of times UBIFS
41 * repeats the operations. 41 * repeats the operations.
42 */ 42 */
43#define MAX_SHRINK_RETRIES 8 43#define MAX_MKSPC_RETRIES 3
44#define MAX_GC_RETRIES 4
45#define MAX_CMT_RETRIES 2
46#define MAX_NOSPC_RETRIES 1
47 44
48/* 45/*
49 * The below constant defines amount of dirty pages which should be written 46 * The below constant defines amount of dirty pages which should be written
@@ -52,30 +49,6 @@
52#define NR_TO_WRITE 16 49#define NR_TO_WRITE 16
53 50
54/** 51/**
55 * struct retries_info - information about re-tries while making free space.
56 * @prev_liability: previous liability
57 * @shrink_cnt: how many times the liability was shrinked
58 * @shrink_retries: count of liability shrink re-tries (increased when
59 * liability does not shrink)
60 * @try_gc: GC should be tried first
61 * @gc_retries: how many times GC was run
62 * @cmt_retries: how many times commit has been done
63 * @nospc_retries: how many times GC returned %-ENOSPC
64 *
65 * Since we consider budgeting to be the fast-path, and this structure has to
66 * be allocated on stack and zeroed out, we make it smaller using bit-fields.
67 */
68struct retries_info {
69 long long prev_liability;
70 unsigned int shrink_cnt;
71 unsigned int shrink_retries:5;
72 unsigned int try_gc:1;
73 unsigned int gc_retries:4;
74 unsigned int cmt_retries:3;
75 unsigned int nospc_retries:1;
76};
77
78/**
79 * shrink_liability - write-back some dirty pages/inodes. 52 * shrink_liability - write-back some dirty pages/inodes.
80 * @c: UBIFS file-system description object 53 * @c: UBIFS file-system description object
81 * @nr_to_write: how many dirty pages to write-back 54 * @nr_to_write: how many dirty pages to write-back
@@ -147,9 +120,25 @@ static int run_gc(struct ubifs_info *c)
147} 120}
148 121
149/** 122/**
123 * get_liability - calculate current liability.
124 * @c: UBIFS file-system description object
125 *
126 * This function calculates and returns current UBIFS liability, i.e. the
127 * amount of bytes UBIFS has "promised" to write to the media.
128 */
129static long long get_liability(struct ubifs_info *c)
130{
131 long long liab;
132
133 spin_lock(&c->space_lock);
134 liab = c->budg_idx_growth + c->budg_data_growth + c->budg_dd_growth;
135 spin_unlock(&c->space_lock);
136 return liab;
137}
138
139/**
150 * make_free_space - make more free space on the file-system. 140 * make_free_space - make more free space on the file-system.
151 * @c: UBIFS file-system description object 141 * @c: UBIFS file-system description object
152 * @ri: information about previous invocations of this function
153 * 142 *
154 * This function is called when an operation cannot be budgeted because there 143 * This function is called when an operation cannot be budgeted because there
155 * is supposedly no free space. But in most cases there is some free space: 144 * is supposedly no free space. But in most cases there is some free space:
@@ -165,87 +154,42 @@ static int run_gc(struct ubifs_info *c)
165 * Returns %-ENOSPC if it couldn't do more free space, and other negative error 154 * Returns %-ENOSPC if it couldn't do more free space, and other negative error
166 * codes on failures. 155 * codes on failures.
167 */ 156 */
168static int make_free_space(struct ubifs_info *c, struct retries_info *ri) 157static int make_free_space(struct ubifs_info *c)
169{ 158{
170 int err; 159 int err, retries = 0;
171 160 long long liab1, liab2;
172 /*
173 * If we have some dirty pages and inodes (liability), try to write
174 * them back unless this was tried too many times without effect
175 * already.
176 */
177 if (ri->shrink_retries < MAX_SHRINK_RETRIES && !ri->try_gc) {
178 long long liability;
179
180 spin_lock(&c->space_lock);
181 liability = c->budg_idx_growth + c->budg_data_growth +
182 c->budg_dd_growth;
183 spin_unlock(&c->space_lock);
184 161
185 if (ri->prev_liability >= liability) { 162 do {
186 /* Liability does not shrink, next time try GC then */ 163 liab1 = get_liability(c);
187 ri->shrink_retries += 1; 164 /*
188 if (ri->gc_retries < MAX_GC_RETRIES) 165 * We probably have some dirty pages or inodes (liability), try
189 ri->try_gc = 1; 166 * to write them back.
190 dbg_budg("liability did not shrink: retries %d of %d", 167 */
191 ri->shrink_retries, MAX_SHRINK_RETRIES); 168 dbg_budg("liability %lld, run write-back", liab1);
192 } 169 shrink_liability(c, NR_TO_WRITE);
193 170
194 dbg_budg("force write-back (count %d)", ri->shrink_cnt); 171 liab2 = get_liability(c);
195 shrink_liability(c, NR_TO_WRITE + ri->shrink_cnt); 172 if (liab2 < liab1)
173 return -EAGAIN;
196 174
197 ri->prev_liability = liability; 175 dbg_budg("new liability %lld (not shrinked)", liab2);
198 ri->shrink_cnt += 1;
199 return -EAGAIN;
200 }
201 176
202 /* 177 /* Liability did not shrink again, try GC */
203 * Try to run garbage collector unless it was already tried too many 178 dbg_budg("Run GC");
204 * times.
205 */
206 if (ri->gc_retries < MAX_GC_RETRIES) {
207 ri->gc_retries += 1;
208 dbg_budg("run GC, retries %d of %d",
209 ri->gc_retries, MAX_GC_RETRIES);
210
211 ri->try_gc = 0;
212 err = run_gc(c); 179 err = run_gc(c);
213 if (!err) 180 if (!err)
214 return -EAGAIN; 181 return -EAGAIN;
215 182
216 if (err == -EAGAIN) { 183 if (err != -EAGAIN && err != -ENOSPC)
217 dbg_budg("GC asked to commit"); 184 /* Some real error happened */
218 err = ubifs_run_commit(c);
219 if (err)
220 return err;
221 return -EAGAIN;
222 }
223
224 if (err != -ENOSPC)
225 return err;
226
227 /*
228 * GC could not make any progress. If this is the first time,
229 * then it makes sense to try to commit, because it might make
230 * some dirty space.
231 */
232 dbg_budg("GC returned -ENOSPC, retries %d",
233 ri->nospc_retries);
234 if (ri->nospc_retries >= MAX_NOSPC_RETRIES)
235 return err; 185 return err;
236 ri->nospc_retries += 1;
237 }
238 186
239 /* Neither GC nor write-back helped, try to commit */ 187 dbg_budg("Run commit (retries %d)", retries);
240 if (ri->cmt_retries < MAX_CMT_RETRIES) {
241 ri->cmt_retries += 1;
242 dbg_budg("run commit, retries %d of %d",
243 ri->cmt_retries, MAX_CMT_RETRIES);
244 err = ubifs_run_commit(c); 188 err = ubifs_run_commit(c);
245 if (err) 189 if (err)
246 return err; 190 return err;
247 return -EAGAIN; 191 } while (retries++ < MAX_MKSPC_RETRIES);
248 } 192
249 return -ENOSPC; 193 return -ENOSPC;
250} 194}
251 195
@@ -258,8 +202,8 @@ static int make_free_space(struct ubifs_info *c, struct retries_info *ri)
258 */ 202 */
259int ubifs_calc_min_idx_lebs(struct ubifs_info *c) 203int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
260{ 204{
261 int ret; 205 int idx_lebs, eff_leb_size = c->leb_size - c->max_idx_node_sz;
262 uint64_t idx_size; 206 long long idx_size;
263 207
264 idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; 208 idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx;
265 209
@@ -271,23 +215,16 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c)
271 * pair, nor similarly the two variables for the new index size, so we 215 * pair, nor similarly the two variables for the new index size, so we
272 * have to do this costly 64-bit division on fast-path. 216 * have to do this costly 64-bit division on fast-path.
273 */ 217 */
274 if (do_div(idx_size, c->leb_size - c->max_idx_node_sz)) 218 idx_size += eff_leb_size - 1;
275 ret = idx_size + 1; 219 idx_lebs = div_u64(idx_size, eff_leb_size);
276 else
277 ret = idx_size;
278 /* 220 /*
279 * The index head is not available for the in-the-gaps method, so add an 221 * The index head is not available for the in-the-gaps method, so add an
280 * extra LEB to compensate. 222 * extra LEB to compensate.
281 */ 223 */
282 ret += 1; 224 idx_lebs += 1;
283 /* 225 if (idx_lebs < MIN_INDEX_LEBS)
284 * At present the index needs at least 2 LEBs: one for the index head 226 idx_lebs = MIN_INDEX_LEBS;
285 * and one for in-the-gaps method (which currently does not cater for 227 return idx_lebs;
286 * the index head and so excludes it from consideration).
287 */
288 if (ret < 2)
289 ret = 2;
290 return ret;
291} 228}
292 229
293/** 230/**
@@ -530,8 +467,7 @@ static int calc_dd_growth(const struct ubifs_info *c,
530int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req) 467int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
531{ 468{
532 int uninitialized_var(cmt_retries), uninitialized_var(wb_retries); 469 int uninitialized_var(cmt_retries), uninitialized_var(wb_retries);
533 int err, idx_growth, data_growth, dd_growth; 470 int err, idx_growth, data_growth, dd_growth, retried = 0;
534 struct retries_info ri;
535 471
536 ubifs_assert(req->new_page <= 1); 472 ubifs_assert(req->new_page <= 1);
537 ubifs_assert(req->dirtied_page <= 1); 473 ubifs_assert(req->dirtied_page <= 1);
@@ -549,7 +485,6 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
549 if (!data_growth && !dd_growth) 485 if (!data_growth && !dd_growth)
550 return 0; 486 return 0;
551 idx_growth = calc_idx_growth(c, req); 487 idx_growth = calc_idx_growth(c, req);
552 memset(&ri, 0, sizeof(struct retries_info));
553 488
554again: 489again:
555 spin_lock(&c->space_lock); 490 spin_lock(&c->space_lock);
@@ -587,12 +522,17 @@ again:
587 return err; 522 return err;
588 } 523 }
589 524
590 err = make_free_space(c, &ri); 525 err = make_free_space(c);
526 cond_resched();
591 if (err == -EAGAIN) { 527 if (err == -EAGAIN) {
592 dbg_budg("try again"); 528 dbg_budg("try again");
593 cond_resched();
594 goto again; 529 goto again;
595 } else if (err == -ENOSPC) { 530 } else if (err == -ENOSPC) {
531 if (!retried) {
532 retried = 1;
533 dbg_budg("-ENOSPC, but anyway try once again");
534 goto again;
535 }
596 dbg_budg("FS is full, -ENOSPC"); 536 dbg_budg("FS is full, -ENOSPC");
597 c->nospace = 1; 537 c->nospace = 1;
598 if (can_use_rp(c) || c->rp_size == 0) 538 if (can_use_rp(c) || c->rp_size == 0)
@@ -712,9 +652,9 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
712 * user-space. User-space application tend to expect that if the file-system 652 * user-space. User-space application tend to expect that if the file-system
713 * (e.g., via the 'statfs()' call) reports that it has N bytes available, they 653 * (e.g., via the 'statfs()' call) reports that it has N bytes available, they
714 * are able to write a file of size N. UBIFS attaches node headers to each data 654 * are able to write a file of size N. UBIFS attaches node headers to each data
715 * node and it has to write indexind nodes as well. This introduces additional 655 * node and it has to write indexing nodes as well. This introduces additional
716 * overhead, and UBIFS it has to report sligtly less free space to meet the 656 * overhead, and UBIFS has to report slightly less free space to meet the above
717 * above expectetion. 657 * expectations.
718 * 658 *
719 * This function assumes free space is made up of uncompressed data nodes and 659 * This function assumes free space is made up of uncompressed data nodes and
720 * full index nodes (one per data node, tripled because we always allow enough 660 * full index nodes (one per data node, tripled because we always allow enough
@@ -723,7 +663,7 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
723 * Note, the calculation is pessimistic, which means that most of the time 663 * Note, the calculation is pessimistic, which means that most of the time
724 * UBIFS reports less space than it actually has. 664 * UBIFS reports less space than it actually has.
725 */ 665 */
726long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free) 666long long ubifs_reported_space(const struct ubifs_info *c, long long free)
727{ 667{
728 int divisor, factor, f; 668 int divisor, factor, f;
729 669
@@ -737,7 +677,7 @@ long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free)
737 * of data nodes, f - fanout. Because effective UBIFS fanout is twice 677 * of data nodes, f - fanout. Because effective UBIFS fanout is twice
738 * as less than maximum fanout, we assume that each data node 678 * as less than maximum fanout, we assume that each data node
739 * introduces 3 * @c->max_idx_node_sz / (@c->fanout/2 - 1) bytes. 679 * introduces 3 * @c->max_idx_node_sz / (@c->fanout/2 - 1) bytes.
740 * Note, the multiplier 3 is because UBIFS reseves thrice as more space 680 * Note, the multiplier 3 is because UBIFS reserves thrice as more space
741 * for the index. 681 * for the index.
742 */ 682 */
743 f = c->fanout > 3 ? c->fanout >> 1 : 2; 683 f = c->fanout > 3 ? c->fanout >> 1 : 2;
@@ -745,8 +685,7 @@ long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free)
745 divisor = UBIFS_MAX_DATA_NODE_SZ; 685 divisor = UBIFS_MAX_DATA_NODE_SZ;
746 divisor += (c->max_idx_node_sz * 3) / (f - 1); 686 divisor += (c->max_idx_node_sz * 3) / (f - 1);
747 free *= factor; 687 free *= factor;
748 do_div(free, divisor); 688 return div_u64(free, divisor);
749 return free;
750} 689}
751 690
752/** 691/**
@@ -756,10 +695,10 @@ long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free)
756 * This function calculates amount of free space to report to user-space. 695 * This function calculates amount of free space to report to user-space.
757 * 696 *
758 * Because UBIFS may introduce substantial overhead (the index, node headers, 697 * Because UBIFS may introduce substantial overhead (the index, node headers,
759 * alighment, wastage at the end of eraseblocks, etc), it cannot report real 698 * alignment, wastage at the end of eraseblocks, etc), it cannot report real
760 * amount of free flash space it has (well, because not all dirty space is 699 * amount of free flash space it has (well, because not all dirty space is
761 * reclamable, UBIFS does not actually know the real amount). If UBIFS did so, 700 * reclaimable, UBIFS does not actually know the real amount). If UBIFS did so,
762 * it would bread user expectetion about what free space is. Users seem to 701 * it would bread user expectations about what free space is. Users seem to
763 * accustomed to assume that if the file-system reports N bytes of free space, 702 * accustomed to assume that if the file-system reports N bytes of free space,
764 * they would be able to fit a file of N bytes to the FS. This almost works for 703 * they would be able to fit a file of N bytes to the FS. This almost works for
765 * traditional file-systems, because they have way less overhead than UBIFS. 704 * traditional file-systems, because they have way less overhead than UBIFS.
@@ -771,18 +710,9 @@ long long ubifs_get_free_space(struct ubifs_info *c)
771 long long available, outstanding, free; 710 long long available, outstanding, free;
772 711
773 spin_lock(&c->space_lock); 712 spin_lock(&c->space_lock);
774 min_idx_lebs = ubifs_calc_min_idx_lebs(c); 713 min_idx_lebs = c->min_idx_lebs;
714 ubifs_assert(min_idx_lebs == ubifs_calc_min_idx_lebs(c));
775 outstanding = c->budg_data_growth + c->budg_dd_growth; 715 outstanding = c->budg_data_growth + c->budg_dd_growth;
776
777 /*
778 * Force the amount available to the total size reported if the used
779 * space is zero.
780 */
781 if (c->lst.total_used <= UBIFS_INO_NODE_SZ && !outstanding) {
782 spin_unlock(&c->space_lock);
783 return (long long)c->block_cnt << UBIFS_BLOCK_SHIFT;
784 }
785
786 available = ubifs_calc_available(c, min_idx_lebs); 716 available = ubifs_calc_available(c, min_idx_lebs);
787 717
788 /* 718 /*
diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
index b49884c8c10e..f3a7945527fb 100644
--- a/fs/ubifs/commit.c
+++ b/fs/ubifs/commit.c
@@ -470,12 +470,12 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot)
470{ 470{
471 struct ubifs_idx_node *idx; 471 struct ubifs_idx_node *idx;
472 int lnum, offs, len, err = 0; 472 int lnum, offs, len, err = 0;
473 struct ubifs_debug_info *d = c->dbg;
473 474
474 c->old_zroot = *zroot; 475 d->old_zroot = *zroot;
475 476 lnum = d->old_zroot.lnum;
476 lnum = c->old_zroot.lnum; 477 offs = d->old_zroot.offs;
477 offs = c->old_zroot.offs; 478 len = d->old_zroot.len;
478 len = c->old_zroot.len;
479 479
480 idx = kmalloc(c->max_idx_node_sz, GFP_NOFS); 480 idx = kmalloc(c->max_idx_node_sz, GFP_NOFS);
481 if (!idx) 481 if (!idx)
@@ -485,8 +485,8 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot)
485 if (err) 485 if (err)
486 goto out; 486 goto out;
487 487
488 c->old_zroot_level = le16_to_cpu(idx->level); 488 d->old_zroot_level = le16_to_cpu(idx->level);
489 c->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum); 489 d->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum);
490out: 490out:
491 kfree(idx); 491 kfree(idx);
492 return err; 492 return err;
@@ -509,6 +509,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
509{ 509{
510 int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt; 510 int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt;
511 int first = 1, iip; 511 int first = 1, iip;
512 struct ubifs_debug_info *d = c->dbg;
512 union ubifs_key lower_key, upper_key, l_key, u_key; 513 union ubifs_key lower_key, upper_key, l_key, u_key;
513 unsigned long long uninitialized_var(last_sqnum); 514 unsigned long long uninitialized_var(last_sqnum);
514 struct ubifs_idx_node *idx; 515 struct ubifs_idx_node *idx;
@@ -525,9 +526,9 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
525 UBIFS_IDX_NODE_SZ; 526 UBIFS_IDX_NODE_SZ;
526 527
527 /* Start at the old zroot */ 528 /* Start at the old zroot */
528 lnum = c->old_zroot.lnum; 529 lnum = d->old_zroot.lnum;
529 offs = c->old_zroot.offs; 530 offs = d->old_zroot.offs;
530 len = c->old_zroot.len; 531 len = d->old_zroot.len;
531 iip = 0; 532 iip = 0;
532 533
533 /* 534 /*
@@ -560,11 +561,11 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
560 if (first) { 561 if (first) {
561 first = 0; 562 first = 0;
562 /* Check root level and sqnum */ 563 /* Check root level and sqnum */
563 if (le16_to_cpu(idx->level) != c->old_zroot_level) { 564 if (le16_to_cpu(idx->level) != d->old_zroot_level) {
564 err = 2; 565 err = 2;
565 goto out_dump; 566 goto out_dump;
566 } 567 }
567 if (le64_to_cpu(idx->ch.sqnum) != c->old_zroot_sqnum) { 568 if (le64_to_cpu(idx->ch.sqnum) != d->old_zroot_sqnum) {
568 err = 3; 569 err = 3;
569 goto out_dump; 570 goto out_dump;
570 } 571 }
diff --git a/fs/ubifs/compress.c b/fs/ubifs/compress.c
index a0ada596b17c..11e4132f314a 100644
--- a/fs/ubifs/compress.c
+++ b/fs/ubifs/compress.c
@@ -33,7 +33,7 @@
33/* Fake description object for the "none" compressor */ 33/* Fake description object for the "none" compressor */
34static struct ubifs_compressor none_compr = { 34static struct ubifs_compressor none_compr = {
35 .compr_type = UBIFS_COMPR_NONE, 35 .compr_type = UBIFS_COMPR_NONE,
36 .name = "no compression", 36 .name = "none",
37 .capi_name = "", 37 .capi_name = "",
38}; 38};
39 39
@@ -43,13 +43,13 @@ static DEFINE_MUTEX(lzo_mutex);
43static struct ubifs_compressor lzo_compr = { 43static struct ubifs_compressor lzo_compr = {
44 .compr_type = UBIFS_COMPR_LZO, 44 .compr_type = UBIFS_COMPR_LZO,
45 .comp_mutex = &lzo_mutex, 45 .comp_mutex = &lzo_mutex,
46 .name = "LZO", 46 .name = "lzo",
47 .capi_name = "lzo", 47 .capi_name = "lzo",
48}; 48};
49#else 49#else
50static struct ubifs_compressor lzo_compr = { 50static struct ubifs_compressor lzo_compr = {
51 .compr_type = UBIFS_COMPR_LZO, 51 .compr_type = UBIFS_COMPR_LZO,
52 .name = "LZO", 52 .name = "lzo",
53}; 53};
54#endif 54#endif
55 55
@@ -108,7 +108,7 @@ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len,
108 if (compr->comp_mutex) 108 if (compr->comp_mutex)
109 mutex_lock(compr->comp_mutex); 109 mutex_lock(compr->comp_mutex);
110 err = crypto_comp_compress(compr->cc, in_buf, in_len, out_buf, 110 err = crypto_comp_compress(compr->cc, in_buf, in_len, out_buf,
111 out_len); 111 (unsigned int *)out_len);
112 if (compr->comp_mutex) 112 if (compr->comp_mutex)
113 mutex_unlock(compr->comp_mutex); 113 mutex_unlock(compr->comp_mutex);
114 if (unlikely(err)) { 114 if (unlikely(err)) {
@@ -119,10 +119,10 @@ void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len,
119 } 119 }
120 120
121 /* 121 /*
122 * Presently, we just require that compression results in less data, 122 * If the data compressed only slightly, it is better to leave it
123 * rather than any defined minimum compression ratio or amount. 123 * uncompressed to improve read speed.
124 */ 124 */
125 if (ALIGN(*out_len, 8) >= ALIGN(in_len, 8)) 125 if (in_len - *out_len < UBIFS_MIN_COMPRESS_DIFF)
126 goto no_compr; 126 goto no_compr;
127 127
128 return; 128 return;
@@ -172,7 +172,7 @@ int ubifs_decompress(const void *in_buf, int in_len, void *out_buf,
172 if (compr->decomp_mutex) 172 if (compr->decomp_mutex)
173 mutex_lock(compr->decomp_mutex); 173 mutex_lock(compr->decomp_mutex);
174 err = crypto_comp_decompress(compr->cc, in_buf, in_len, out_buf, 174 err = crypto_comp_decompress(compr->cc, in_buf, in_len, out_buf,
175 out_len); 175 (unsigned int *)out_len);
176 if (compr->decomp_mutex) 176 if (compr->decomp_mutex)
177 mutex_unlock(compr->decomp_mutex); 177 mutex_unlock(compr->decomp_mutex);
178 if (err) 178 if (err)
@@ -244,7 +244,7 @@ out_lzo:
244/** 244/**
245 * ubifs_compressors_exit - de-initialize UBIFS compressors. 245 * ubifs_compressors_exit - de-initialize UBIFS compressors.
246 */ 246 */
247void __exit ubifs_compressors_exit(void) 247void ubifs_compressors_exit(void)
248{ 248{
249 compr_exit(&lzo_compr); 249 compr_exit(&lzo_compr);
250 compr_exit(&zlib_compr); 250 compr_exit(&zlib_compr);
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 510ffa0bbda4..792c5a16c182 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -32,6 +32,8 @@
32#include "ubifs.h" 32#include "ubifs.h"
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
35#include <linux/debugfs.h>
36#include <linux/math64.h>
35 37
36#ifdef CONFIG_UBIFS_FS_DEBUG 38#ifdef CONFIG_UBIFS_FS_DEBUG
37 39
@@ -596,7 +598,9 @@ void dbg_dump_budg(struct ubifs_info *c)
596 struct rb_node *rb; 598 struct rb_node *rb;
597 struct ubifs_bud *bud; 599 struct ubifs_bud *bud;
598 struct ubifs_gced_idx_leb *idx_gc; 600 struct ubifs_gced_idx_leb *idx_gc;
601 long long available, outstanding, free;
599 602
603 ubifs_assert(spin_is_locked(&c->space_lock));
600 spin_lock(&dbg_lock); 604 spin_lock(&dbg_lock);
601 printk(KERN_DEBUG "(pid %d) Budgeting info: budg_data_growth %lld, " 605 printk(KERN_DEBUG "(pid %d) Budgeting info: budg_data_growth %lld, "
602 "budg_dd_growth %lld, budg_idx_growth %lld\n", current->pid, 606 "budg_dd_growth %lld, budg_idx_growth %lld\n", current->pid,
@@ -629,6 +633,17 @@ void dbg_dump_budg(struct ubifs_info *c)
629 printk(KERN_DEBUG "\tGC'ed idx LEB %d unmap %d\n", 633 printk(KERN_DEBUG "\tGC'ed idx LEB %d unmap %d\n",
630 idx_gc->lnum, idx_gc->unmap); 634 idx_gc->lnum, idx_gc->unmap);
631 printk(KERN_DEBUG "\tcommit state %d\n", c->cmt_state); 635 printk(KERN_DEBUG "\tcommit state %d\n", c->cmt_state);
636
637 /* Print budgeting predictions */
638 available = ubifs_calc_available(c, c->min_idx_lebs);
639 outstanding = c->budg_data_growth + c->budg_dd_growth;
640 if (available > outstanding)
641 free = ubifs_reported_space(c, available - outstanding);
642 else
643 free = 0;
644 printk(KERN_DEBUG "Budgeting predictions:\n");
645 printk(KERN_DEBUG "\tavailable: %lld, outstanding %lld, free %lld\n",
646 available, outstanding, free);
632 spin_unlock(&dbg_lock); 647 spin_unlock(&dbg_lock);
633} 648}
634 649
@@ -645,7 +660,8 @@ void dbg_dump_lprops(struct ubifs_info *c)
645 struct ubifs_lprops lp; 660 struct ubifs_lprops lp;
646 struct ubifs_lp_stats lst; 661 struct ubifs_lp_stats lst;
647 662
648 printk(KERN_DEBUG "(pid %d) Dumping LEB properties\n", current->pid); 663 printk(KERN_DEBUG "(pid %d) start dumping LEB properties\n",
664 current->pid);
649 ubifs_get_lp_stats(c, &lst); 665 ubifs_get_lp_stats(c, &lst);
650 dbg_dump_lstats(&lst); 666 dbg_dump_lstats(&lst);
651 667
@@ -656,6 +672,8 @@ void dbg_dump_lprops(struct ubifs_info *c)
656 672
657 dbg_dump_lprop(c, &lp); 673 dbg_dump_lprop(c, &lp);
658 } 674 }
675 printk(KERN_DEBUG "(pid %d) finish dumping LEB properties\n",
676 current->pid);
659} 677}
660 678
661void dbg_dump_lpt_info(struct ubifs_info *c) 679void dbg_dump_lpt_info(struct ubifs_info *c)
@@ -663,6 +681,7 @@ void dbg_dump_lpt_info(struct ubifs_info *c)
663 int i; 681 int i;
664 682
665 spin_lock(&dbg_lock); 683 spin_lock(&dbg_lock);
684 printk(KERN_DEBUG "(pid %d) dumping LPT information\n", current->pid);
666 printk(KERN_DEBUG "\tlpt_sz: %lld\n", c->lpt_sz); 685 printk(KERN_DEBUG "\tlpt_sz: %lld\n", c->lpt_sz);
667 printk(KERN_DEBUG "\tpnode_sz: %d\n", c->pnode_sz); 686 printk(KERN_DEBUG "\tpnode_sz: %d\n", c->pnode_sz);
668 printk(KERN_DEBUG "\tnnode_sz: %d\n", c->nnode_sz); 687 printk(KERN_DEBUG "\tnnode_sz: %d\n", c->nnode_sz);
@@ -684,7 +703,8 @@ void dbg_dump_lpt_info(struct ubifs_info *c)
684 printk(KERN_DEBUG "\tLPT root is at %d:%d\n", c->lpt_lnum, c->lpt_offs); 703 printk(KERN_DEBUG "\tLPT root is at %d:%d\n", c->lpt_lnum, c->lpt_offs);
685 printk(KERN_DEBUG "\tLPT head is at %d:%d\n", 704 printk(KERN_DEBUG "\tLPT head is at %d:%d\n",
686 c->nhead_lnum, c->nhead_offs); 705 c->nhead_lnum, c->nhead_offs);
687 printk(KERN_DEBUG "\tLPT ltab is at %d:%d\n", c->ltab_lnum, c->ltab_offs); 706 printk(KERN_DEBUG "\tLPT ltab is at %d:%d\n",
707 c->ltab_lnum, c->ltab_offs);
688 if (c->big_lpt) 708 if (c->big_lpt)
689 printk(KERN_DEBUG "\tLPT lsave is at %d:%d\n", 709 printk(KERN_DEBUG "\tLPT lsave is at %d:%d\n",
690 c->lsave_lnum, c->lsave_offs); 710 c->lsave_lnum, c->lsave_offs);
@@ -703,9 +723,9 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
703 if (dbg_failure_mode) 723 if (dbg_failure_mode)
704 return; 724 return;
705 725
706 printk(KERN_DEBUG "(pid %d) Dumping LEB %d\n", current->pid, lnum); 726 printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n",
707 727 current->pid, lnum);
708 sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); 728 sleb = ubifs_scan(c, lnum, 0, c->dbg->buf);
709 if (IS_ERR(sleb)) { 729 if (IS_ERR(sleb)) {
710 ubifs_err("scan error %d", (int)PTR_ERR(sleb)); 730 ubifs_err("scan error %d", (int)PTR_ERR(sleb));
711 return; 731 return;
@@ -721,6 +741,8 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
721 dbg_dump_node(c, snod->node); 741 dbg_dump_node(c, snod->node);
722 } 742 }
723 743
744 printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n",
745 current->pid, lnum);
724 ubifs_scan_destroy(sleb); 746 ubifs_scan_destroy(sleb);
725 return; 747 return;
726} 748}
@@ -768,7 +790,7 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
768{ 790{
769 int i; 791 int i;
770 792
771 printk(KERN_DEBUG "(pid %d) Dumping heap cat %d (%d elements)\n", 793 printk(KERN_DEBUG "(pid %d) start dumping heap cat %d (%d elements)\n",
772 current->pid, cat, heap->cnt); 794 current->pid, cat, heap->cnt);
773 for (i = 0; i < heap->cnt; i++) { 795 for (i = 0; i < heap->cnt; i++) {
774 struct ubifs_lprops *lprops = heap->arr[i]; 796 struct ubifs_lprops *lprops = heap->arr[i];
@@ -777,6 +799,7 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
777 "flags %d\n", i, lprops->lnum, lprops->hpos, 799 "flags %d\n", i, lprops->lnum, lprops->hpos,
778 lprops->free, lprops->dirty, lprops->flags); 800 lprops->free, lprops->dirty, lprops->flags);
779 } 801 }
802 printk(KERN_DEBUG "(pid %d) finish dumping heap\n", current->pid);
780} 803}
781 804
782void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, 805void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
@@ -784,7 +807,7 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
784{ 807{
785 int i; 808 int i;
786 809
787 printk(KERN_DEBUG "(pid %d) Dumping pnode:\n", current->pid); 810 printk(KERN_DEBUG "(pid %d) dumping pnode:\n", current->pid);
788 printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n", 811 printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n",
789 (size_t)pnode, (size_t)parent, (size_t)pnode->cnext); 812 (size_t)pnode, (size_t)parent, (size_t)pnode->cnext);
790 printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n", 813 printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n",
@@ -803,7 +826,7 @@ void dbg_dump_tnc(struct ubifs_info *c)
803 int level; 826 int level;
804 827
805 printk(KERN_DEBUG "\n"); 828 printk(KERN_DEBUG "\n");
806 printk(KERN_DEBUG "(pid %d) Dumping the TNC tree\n", current->pid); 829 printk(KERN_DEBUG "(pid %d) start dumping TNC tree\n", current->pid);
807 znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL); 830 znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL);
808 level = znode->level; 831 level = znode->level;
809 printk(KERN_DEBUG "== Level %d ==\n", level); 832 printk(KERN_DEBUG "== Level %d ==\n", level);
@@ -815,8 +838,7 @@ void dbg_dump_tnc(struct ubifs_info *c)
815 dbg_dump_znode(c, znode); 838 dbg_dump_znode(c, znode);
816 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode); 839 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
817 } 840 }
818 841 printk(KERN_DEBUG "(pid %d) finish dumping TNC tree\n", current->pid);
819 printk(KERN_DEBUG "\n");
820} 842}
821 843
822static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode, 844static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
@@ -992,8 +1014,8 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
992 zbr1->offs, DBGKEY(&key)); 1014 zbr1->offs, DBGKEY(&key));
993 dbg_err("but it should have key %s according to tnc", 1015 dbg_err("but it should have key %s according to tnc",
994 DBGKEY(&zbr1->key)); 1016 DBGKEY(&zbr1->key));
995 dbg_dump_node(c, dent1); 1017 dbg_dump_node(c, dent1);
996 goto out_free; 1018 goto out_free;
997 } 1019 }
998 1020
999 key_read(c, &dent2->key, &key); 1021 key_read(c, &dent2->key, &key);
@@ -1002,8 +1024,8 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1002 zbr1->offs, DBGKEY(&key)); 1024 zbr1->offs, DBGKEY(&key));
1003 dbg_err("but it should have key %s according to tnc", 1025 dbg_err("but it should have key %s according to tnc",
1004 DBGKEY(&zbr2->key)); 1026 DBGKEY(&zbr2->key));
1005 dbg_dump_node(c, dent2); 1027 dbg_dump_node(c, dent2);
1006 goto out_free; 1028 goto out_free;
1007 } 1029 }
1008 1030
1009 nlen1 = le16_to_cpu(dent1->nlen); 1031 nlen1 = le16_to_cpu(dent1->nlen);
@@ -1020,9 +1042,9 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
1020 dbg_err("bad order of colliding key %s", 1042 dbg_err("bad order of colliding key %s",
1021 DBGKEY(&key)); 1043 DBGKEY(&key));
1022 1044
1023 dbg_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs); 1045 ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs);
1024 dbg_dump_node(c, dent1); 1046 dbg_dump_node(c, dent1);
1025 dbg_msg("second node at %d:%d\n", zbr2->lnum, zbr2->offs); 1047 ubifs_msg("second node at %d:%d\n", zbr2->lnum, zbr2->offs);
1026 dbg_dump_node(c, dent2); 1048 dbg_dump_node(c, dent2);
1027 1049
1028out_free: 1050out_free:
@@ -2097,13 +2119,13 @@ static int simple_rand(void)
2097 return (next >> 16) & 32767; 2119 return (next >> 16) & 32767;
2098} 2120}
2099 2121
2100void dbg_failure_mode_registration(struct ubifs_info *c) 2122static void failure_mode_init(struct ubifs_info *c)
2101{ 2123{
2102 struct failure_mode_info *fmi; 2124 struct failure_mode_info *fmi;
2103 2125
2104 fmi = kmalloc(sizeof(struct failure_mode_info), GFP_NOFS); 2126 fmi = kmalloc(sizeof(struct failure_mode_info), GFP_NOFS);
2105 if (!fmi) { 2127 if (!fmi) {
2106 dbg_err("Failed to register failure mode - no memory"); 2128 ubifs_err("Failed to register failure mode - no memory");
2107 return; 2129 return;
2108 } 2130 }
2109 fmi->c = c; 2131 fmi->c = c;
@@ -2112,7 +2134,7 @@ void dbg_failure_mode_registration(struct ubifs_info *c)
2112 spin_unlock(&fmi_lock); 2134 spin_unlock(&fmi_lock);
2113} 2135}
2114 2136
2115void dbg_failure_mode_deregistration(struct ubifs_info *c) 2137static void failure_mode_exit(struct ubifs_info *c)
2116{ 2138{
2117 struct failure_mode_info *fmi, *tmp; 2139 struct failure_mode_info *fmi, *tmp;
2118 2140
@@ -2146,42 +2168,44 @@ static int in_failure_mode(struct ubi_volume_desc *desc)
2146 struct ubifs_info *c = dbg_find_info(desc); 2168 struct ubifs_info *c = dbg_find_info(desc);
2147 2169
2148 if (c && dbg_failure_mode) 2170 if (c && dbg_failure_mode)
2149 return c->failure_mode; 2171 return c->dbg->failure_mode;
2150 return 0; 2172 return 0;
2151} 2173}
2152 2174
2153static int do_fail(struct ubi_volume_desc *desc, int lnum, int write) 2175static int do_fail(struct ubi_volume_desc *desc, int lnum, int write)
2154{ 2176{
2155 struct ubifs_info *c = dbg_find_info(desc); 2177 struct ubifs_info *c = dbg_find_info(desc);
2178 struct ubifs_debug_info *d;
2156 2179
2157 if (!c || !dbg_failure_mode) 2180 if (!c || !dbg_failure_mode)
2158 return 0; 2181 return 0;
2159 if (c->failure_mode) 2182 d = c->dbg;
2183 if (d->failure_mode)
2160 return 1; 2184 return 1;
2161 if (!c->fail_cnt) { 2185 if (!d->fail_cnt) {
2162 /* First call - decide delay to failure */ 2186 /* First call - decide delay to failure */
2163 if (chance(1, 2)) { 2187 if (chance(1, 2)) {
2164 unsigned int delay = 1 << (simple_rand() >> 11); 2188 unsigned int delay = 1 << (simple_rand() >> 11);
2165 2189
2166 if (chance(1, 2)) { 2190 if (chance(1, 2)) {
2167 c->fail_delay = 1; 2191 d->fail_delay = 1;
2168 c->fail_timeout = jiffies + 2192 d->fail_timeout = jiffies +
2169 msecs_to_jiffies(delay); 2193 msecs_to_jiffies(delay);
2170 dbg_rcvry("failing after %ums", delay); 2194 dbg_rcvry("failing after %ums", delay);
2171 } else { 2195 } else {
2172 c->fail_delay = 2; 2196 d->fail_delay = 2;
2173 c->fail_cnt_max = delay; 2197 d->fail_cnt_max = delay;
2174 dbg_rcvry("failing after %u calls", delay); 2198 dbg_rcvry("failing after %u calls", delay);
2175 } 2199 }
2176 } 2200 }
2177 c->fail_cnt += 1; 2201 d->fail_cnt += 1;
2178 } 2202 }
2179 /* Determine if failure delay has expired */ 2203 /* Determine if failure delay has expired */
2180 if (c->fail_delay == 1) { 2204 if (d->fail_delay == 1) {
2181 if (time_before(jiffies, c->fail_timeout)) 2205 if (time_before(jiffies, d->fail_timeout))
2182 return 0; 2206 return 0;
2183 } else if (c->fail_delay == 2) 2207 } else if (d->fail_delay == 2)
2184 if (c->fail_cnt++ < c->fail_cnt_max) 2208 if (d->fail_cnt++ < d->fail_cnt_max)
2185 return 0; 2209 return 0;
2186 if (lnum == UBIFS_SB_LNUM) { 2210 if (lnum == UBIFS_SB_LNUM) {
2187 if (write) { 2211 if (write) {
@@ -2239,7 +2263,7 @@ static int do_fail(struct ubi_volume_desc *desc, int lnum, int write)
2239 dbg_rcvry("failing in bud LEB %d commit not running", lnum); 2263 dbg_rcvry("failing in bud LEB %d commit not running", lnum);
2240 } 2264 }
2241 ubifs_err("*** SETTING FAILURE MODE ON (LEB %d) ***", lnum); 2265 ubifs_err("*** SETTING FAILURE MODE ON (LEB %d) ***", lnum);
2242 c->failure_mode = 1; 2266 d->failure_mode = 1;
2243 dump_stack(); 2267 dump_stack();
2244 return 1; 2268 return 1;
2245} 2269}
@@ -2344,4 +2368,181 @@ int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype)
2344 return 0; 2368 return 0;
2345} 2369}
2346 2370
2371/**
2372 * ubifs_debugging_init - initialize UBIFS debugging.
2373 * @c: UBIFS file-system description object
2374 *
2375 * This function initializes debugging-related data for the file system.
2376 * Returns zero in case of success and a negative error code in case of
2377 * failure.
2378 */
2379int ubifs_debugging_init(struct ubifs_info *c)
2380{
2381 c->dbg = kzalloc(sizeof(struct ubifs_debug_info), GFP_KERNEL);
2382 if (!c->dbg)
2383 return -ENOMEM;
2384
2385 c->dbg->buf = vmalloc(c->leb_size);
2386 if (!c->dbg->buf)
2387 goto out;
2388
2389 failure_mode_init(c);
2390 return 0;
2391
2392out:
2393 kfree(c->dbg);
2394 return -ENOMEM;
2395}
2396
2397/**
2398 * ubifs_debugging_exit - free debugging data.
2399 * @c: UBIFS file-system description object
2400 */
2401void ubifs_debugging_exit(struct ubifs_info *c)
2402{
2403 failure_mode_exit(c);
2404 vfree(c->dbg->buf);
2405 kfree(c->dbg);
2406}
2407
2408/*
2409 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which
2410 * contain the stuff specific to particular file-system mounts.
2411 */
2412static struct dentry *debugfs_rootdir;
2413
2414/**
2415 * dbg_debugfs_init - initialize debugfs file-system.
2416 *
2417 * UBIFS uses debugfs file-system to expose various debugging knobs to
2418 * user-space. This function creates "ubifs" directory in the debugfs
2419 * file-system. Returns zero in case of success and a negative error code in
2420 * case of failure.
2421 */
2422int dbg_debugfs_init(void)
2423{
2424 debugfs_rootdir = debugfs_create_dir("ubifs", NULL);
2425 if (IS_ERR(debugfs_rootdir)) {
2426 int err = PTR_ERR(debugfs_rootdir);
2427 ubifs_err("cannot create \"ubifs\" debugfs directory, "
2428 "error %d\n", err);
2429 return err;
2430 }
2431
2432 return 0;
2433}
2434
2435/**
2436 * dbg_debugfs_exit - remove the "ubifs" directory from debugfs file-system.
2437 */
2438void dbg_debugfs_exit(void)
2439{
2440 debugfs_remove(debugfs_rootdir);
2441}
2442
2443static int open_debugfs_file(struct inode *inode, struct file *file)
2444{
2445 file->private_data = inode->i_private;
2446 return 0;
2447}
2448
2449static ssize_t write_debugfs_file(struct file *file, const char __user *buf,
2450 size_t count, loff_t *ppos)
2451{
2452 struct ubifs_info *c = file->private_data;
2453 struct ubifs_debug_info *d = c->dbg;
2454
2455 if (file->f_path.dentry == d->dump_lprops)
2456 dbg_dump_lprops(c);
2457 else if (file->f_path.dentry == d->dump_budg) {
2458 spin_lock(&c->space_lock);
2459 dbg_dump_budg(c);
2460 spin_unlock(&c->space_lock);
2461 } else if (file->f_path.dentry == d->dump_tnc) {
2462 mutex_lock(&c->tnc_mutex);
2463 dbg_dump_tnc(c);
2464 mutex_unlock(&c->tnc_mutex);
2465 } else
2466 return -EINVAL;
2467
2468 *ppos += count;
2469 return count;
2470}
2471
2472static const struct file_operations debugfs_fops = {
2473 .open = open_debugfs_file,
2474 .write = write_debugfs_file,
2475 .owner = THIS_MODULE,
2476};
2477
2478/**
2479 * dbg_debugfs_init_fs - initialize debugfs for UBIFS instance.
2480 * @c: UBIFS file-system description object
2481 *
2482 * This function creates all debugfs files for this instance of UBIFS. Returns
2483 * zero in case of success and a negative error code in case of failure.
2484 *
2485 * Note, the only reason we have not merged this function with the
2486 * 'ubifs_debugging_init()' function is because it is better to initialize
2487 * debugfs interfaces at the very end of the mount process, and remove them at
2488 * the very beginning of the mount process.
2489 */
2490int dbg_debugfs_init_fs(struct ubifs_info *c)
2491{
2492 int err;
2493 const char *fname;
2494 struct dentry *dent;
2495 struct ubifs_debug_info *d = c->dbg;
2496
2497 sprintf(d->debugfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id);
2498 d->debugfs_dir = debugfs_create_dir(d->debugfs_dir_name,
2499 debugfs_rootdir);
2500 if (IS_ERR(d->debugfs_dir)) {
2501 err = PTR_ERR(d->debugfs_dir);
2502 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2503 d->debugfs_dir_name, err);
2504 goto out;
2505 }
2506
2507 fname = "dump_lprops";
2508 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c,
2509 &debugfs_fops);
2510 if (IS_ERR(dent))
2511 goto out_remove;
2512 d->dump_lprops = dent;
2513
2514 fname = "dump_budg";
2515 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c,
2516 &debugfs_fops);
2517 if (IS_ERR(dent))
2518 goto out_remove;
2519 d->dump_budg = dent;
2520
2521 fname = "dump_tnc";
2522 dent = debugfs_create_file(fname, S_IWUGO, d->debugfs_dir, c,
2523 &debugfs_fops);
2524 if (IS_ERR(dent))
2525 goto out_remove;
2526 d->dump_tnc = dent;
2527
2528 return 0;
2529
2530out_remove:
2531 err = PTR_ERR(dent);
2532 ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
2533 fname, err);
2534 debugfs_remove_recursive(d->debugfs_dir);
2535out:
2536 return err;
2537}
2538
2539/**
2540 * dbg_debugfs_exit_fs - remove all debugfs files.
2541 * @c: UBIFS file-system description object
2542 */
2543void dbg_debugfs_exit_fs(struct ubifs_info *c)
2544{
2545 debugfs_remove_recursive(c->dbg->debugfs_dir);
2546}
2547
2347#endif /* CONFIG_UBIFS_FS_DEBUG */ 2548#endif /* CONFIG_UBIFS_FS_DEBUG */
diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
index 33d6b95071e4..9820d6999f7e 100644
--- a/fs/ubifs/debug.h
+++ b/fs/ubifs/debug.h
@@ -25,7 +25,56 @@
25 25
26#ifdef CONFIG_UBIFS_FS_DEBUG 26#ifdef CONFIG_UBIFS_FS_DEBUG
27 27
28#define UBIFS_DBG(op) op 28/**
29 * ubifs_debug_info - per-FS debugging information.
30 * @buf: a buffer of LEB size, used for various purposes
31 * @old_zroot: old index root - used by 'dbg_check_old_index()'
32 * @old_zroot_level: old index root level - used by 'dbg_check_old_index()'
33 * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()'
34 * @failure_mode: failure mode for recovery testing
35 * @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls
36 * @fail_timeout: time in jiffies when delay of failure mode expires
37 * @fail_cnt: current number of calls to failure mode I/O functions
38 * @fail_cnt_max: number of calls by which to delay failure mode
39 * @chk_lpt_sz: used by LPT tree size checker
40 * @chk_lpt_sz2: used by LPT tree size checker
41 * @chk_lpt_wastage: used by LPT tree size checker
42 * @chk_lpt_lebs: used by LPT tree size checker
43 * @new_nhead_offs: used by LPT tree size checker
44 * @new_ihead_lnum: used by debugging to check ihead_lnum
45 * @new_ihead_offs: used by debugging to check ihead_offs
46 *
47 * debugfs_dir_name: name of debugfs directory containing this file-system's
48 * files
49 * debugfs_dir: direntry object of the file-system debugfs directory
50 * dump_lprops: "dump lprops" debugfs knob
51 * dump_budg: "dump budgeting information" debugfs knob
52 * dump_tnc: "dump TNC" debugfs knob
53 */
54struct ubifs_debug_info {
55 void *buf;
56 struct ubifs_zbranch old_zroot;
57 int old_zroot_level;
58 unsigned long long old_zroot_sqnum;
59 int failure_mode;
60 int fail_delay;
61 unsigned long fail_timeout;
62 unsigned int fail_cnt;
63 unsigned int fail_cnt_max;
64 long long chk_lpt_sz;
65 long long chk_lpt_sz2;
66 long long chk_lpt_wastage;
67 int chk_lpt_lebs;
68 int new_nhead_offs;
69 int new_ihead_lnum;
70 int new_ihead_offs;
71
72 char debugfs_dir_name[100];
73 struct dentry *debugfs_dir;
74 struct dentry *dump_lprops;
75 struct dentry *dump_budg;
76 struct dentry *dump_tnc;
77};
29 78
30#define ubifs_assert(expr) do { \ 79#define ubifs_assert(expr) do { \
31 if (unlikely(!(expr))) { \ 80 if (unlikely(!(expr))) { \
@@ -211,14 +260,18 @@ extern unsigned int ubifs_msg_flags;
211extern unsigned int ubifs_chk_flags; 260extern unsigned int ubifs_chk_flags;
212extern unsigned int ubifs_tst_flags; 261extern unsigned int ubifs_tst_flags;
213 262
214/* Dump functions */ 263int ubifs_debugging_init(struct ubifs_info *c);
264void ubifs_debugging_exit(struct ubifs_info *c);
215 265
266/* Dump functions */
216const char *dbg_ntype(int type); 267const char *dbg_ntype(int type);
217const char *dbg_cstate(int cmt_state); 268const char *dbg_cstate(int cmt_state);
218const char *dbg_get_key_dump(const struct ubifs_info *c, 269const char *dbg_get_key_dump(const struct ubifs_info *c,
219 const union ubifs_key *key); 270 const union ubifs_key *key);
220void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode); 271void dbg_dump_inode(const struct ubifs_info *c, const struct inode *inode);
221void dbg_dump_node(const struct ubifs_info *c, const void *node); 272void dbg_dump_node(const struct ubifs_info *c, const void *node);
273void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum,
274 int offs);
222void dbg_dump_budget_req(const struct ubifs_budget_req *req); 275void dbg_dump_budget_req(const struct ubifs_budget_req *req);
223void dbg_dump_lstats(const struct ubifs_lp_stats *lst); 276void dbg_dump_lstats(const struct ubifs_lp_stats *lst);
224void dbg_dump_budg(struct ubifs_info *c); 277void dbg_dump_budg(struct ubifs_info *c);
@@ -233,9 +286,9 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
233 struct ubifs_nnode *parent, int iip); 286 struct ubifs_nnode *parent, int iip);
234void dbg_dump_tnc(struct ubifs_info *c); 287void dbg_dump_tnc(struct ubifs_info *c);
235void dbg_dump_index(struct ubifs_info *c); 288void dbg_dump_index(struct ubifs_info *c);
289void dbg_dump_lpt_lebs(const struct ubifs_info *c);
236 290
237/* Checking helper functions */ 291/* Checking helper functions */
238
239typedef int (*dbg_leaf_callback)(struct ubifs_info *c, 292typedef int (*dbg_leaf_callback)(struct ubifs_info *c,
240 struct ubifs_zbranch *zbr, void *priv); 293 struct ubifs_zbranch *zbr, void *priv);
241typedef int (*dbg_znode_callback)(struct ubifs_info *c, 294typedef int (*dbg_znode_callback)(struct ubifs_info *c,
@@ -274,9 +327,6 @@ int dbg_force_in_the_gaps(void);
274 327
275#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY) 328#define dbg_failure_mode (ubifs_tst_flags & UBIFS_TST_RCVRY)
276 329
277void dbg_failure_mode_registration(struct ubifs_info *c);
278void dbg_failure_mode_deregistration(struct ubifs_info *c);
279
280#ifndef UBIFS_DBG_PRESERVE_UBI 330#ifndef UBIFS_DBG_PRESERVE_UBI
281 331
282#define ubi_leb_read dbg_leb_read 332#define ubi_leb_read dbg_leb_read
@@ -318,9 +368,13 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
318 return dbg_leb_change(desc, lnum, buf, len, UBI_UNKNOWN); 368 return dbg_leb_change(desc, lnum, buf, len, UBI_UNKNOWN);
319} 369}
320 370
321#else /* !CONFIG_UBIFS_FS_DEBUG */ 371/* Debugfs-related stuff */
372int dbg_debugfs_init(void);
373void dbg_debugfs_exit(void);
374int dbg_debugfs_init_fs(struct ubifs_info *c);
375void dbg_debugfs_exit_fs(struct ubifs_info *c);
322 376
323#define UBIFS_DBG(op) 377#else /* !CONFIG_UBIFS_FS_DEBUG */
324 378
325/* Use "if (0)" to make compiler check arguments even if debugging is off */ 379/* Use "if (0)" to make compiler check arguments even if debugging is off */
326#define ubifs_assert(expr) do { \ 380#define ubifs_assert(expr) do { \
@@ -360,23 +414,28 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
360#define DBGKEY(key) ((char *)(key)) 414#define DBGKEY(key) ((char *)(key))
361#define DBGKEY1(key) ((char *)(key)) 415#define DBGKEY1(key) ((char *)(key))
362 416
363#define dbg_ntype(type) "" 417#define ubifs_debugging_init(c) 0
364#define dbg_cstate(cmt_state) "" 418#define ubifs_debugging_exit(c) ({})
365#define dbg_get_key_dump(c, key) ({}) 419
366#define dbg_dump_inode(c, inode) ({}) 420#define dbg_ntype(type) ""
367#define dbg_dump_node(c, node) ({}) 421#define dbg_cstate(cmt_state) ""
368#define dbg_dump_budget_req(req) ({}) 422#define dbg_get_key_dump(c, key) ({})
369#define dbg_dump_lstats(lst) ({}) 423#define dbg_dump_inode(c, inode) ({})
370#define dbg_dump_budg(c) ({}) 424#define dbg_dump_node(c, node) ({})
371#define dbg_dump_lprop(c, lp) ({}) 425#define dbg_dump_lpt_node(c, node, lnum, offs) ({})
372#define dbg_dump_lprops(c) ({}) 426#define dbg_dump_budget_req(req) ({})
373#define dbg_dump_lpt_info(c) ({}) 427#define dbg_dump_lstats(lst) ({})
374#define dbg_dump_leb(c, lnum) ({}) 428#define dbg_dump_budg(c) ({})
375#define dbg_dump_znode(c, znode) ({}) 429#define dbg_dump_lprop(c, lp) ({})
376#define dbg_dump_heap(c, heap, cat) ({}) 430#define dbg_dump_lprops(c) ({})
377#define dbg_dump_pnode(c, pnode, parent, iip) ({}) 431#define dbg_dump_lpt_info(c) ({})
378#define dbg_dump_tnc(c) ({}) 432#define dbg_dump_leb(c, lnum) ({})
379#define dbg_dump_index(c) ({}) 433#define dbg_dump_znode(c, znode) ({})
434#define dbg_dump_heap(c, heap, cat) ({})
435#define dbg_dump_pnode(c, pnode, parent, iip) ({})
436#define dbg_dump_tnc(c) ({})
437#define dbg_dump_index(c) ({})
438#define dbg_dump_lpt_lebs(c) ({})
380 439
381#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0 440#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0
382#define dbg_old_index_check_init(c, zroot) 0 441#define dbg_old_index_check_init(c, zroot) 0
@@ -396,9 +455,11 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
396#define dbg_force_in_the_gaps_enabled 0 455#define dbg_force_in_the_gaps_enabled 0
397#define dbg_force_in_the_gaps() 0 456#define dbg_force_in_the_gaps() 0
398#define dbg_failure_mode 0 457#define dbg_failure_mode 0
399#define dbg_failure_mode_registration(c) ({})
400#define dbg_failure_mode_deregistration(c) ({})
401 458
402#endif /* !CONFIG_UBIFS_FS_DEBUG */ 459#define dbg_debugfs_init() 0
460#define dbg_debugfs_exit()
461#define dbg_debugfs_init_fs(c) 0
462#define dbg_debugfs_exit_fs(c) 0
403 463
464#endif /* !CONFIG_UBIFS_FS_DEBUG */
404#endif /* !__UBIFS_DEBUG_H__ */ 465#endif /* !__UBIFS_DEBUG_H__ */
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 2624411d9758..bf37374567fa 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -72,8 +72,8 @@ static int read_block(struct inode *inode, void *addr, unsigned int block,
72 return err; 72 return err;
73 } 73 }
74 74
75 ubifs_assert(le64_to_cpu(dn->ch.sqnum) > ubifs_inode(inode)->creat_sqnum); 75 ubifs_assert(le64_to_cpu(dn->ch.sqnum) >
76 76 ubifs_inode(inode)->creat_sqnum);
77 len = le32_to_cpu(dn->size); 77 len = le32_to_cpu(dn->size);
78 if (len <= 0 || len > UBIFS_BLOCK_SIZE) 78 if (len <= 0 || len > UBIFS_BLOCK_SIZE)
79 goto dump; 79 goto dump;
@@ -219,7 +219,8 @@ static void release_existing_page_budget(struct ubifs_info *c)
219} 219}
220 220
221static int write_begin_slow(struct address_space *mapping, 221static int write_begin_slow(struct address_space *mapping,
222 loff_t pos, unsigned len, struct page **pagep) 222 loff_t pos, unsigned len, struct page **pagep,
223 unsigned flags)
223{ 224{
224 struct inode *inode = mapping->host; 225 struct inode *inode = mapping->host;
225 struct ubifs_info *c = inode->i_sb->s_fs_info; 226 struct ubifs_info *c = inode->i_sb->s_fs_info;
@@ -247,14 +248,14 @@ static int write_begin_slow(struct address_space *mapping,
247 if (unlikely(err)) 248 if (unlikely(err))
248 return err; 249 return err;
249 250
250 page = __grab_cache_page(mapping, index); 251 page = grab_cache_page_write_begin(mapping, index, flags);
251 if (unlikely(!page)) { 252 if (unlikely(!page)) {
252 ubifs_release_budget(c, &req); 253 ubifs_release_budget(c, &req);
253 return -ENOMEM; 254 return -ENOMEM;
254 } 255 }
255 256
256 if (!PageUptodate(page)) { 257 if (!PageUptodate(page)) {
257 if (!(pos & PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) 258 if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE)
258 SetPageChecked(page); 259 SetPageChecked(page);
259 else { 260 else {
260 err = do_readpage(page); 261 err = do_readpage(page);
@@ -438,13 +439,13 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
438 return -EROFS; 439 return -EROFS;
439 440
440 /* Try out the fast-path part first */ 441 /* Try out the fast-path part first */
441 page = __grab_cache_page(mapping, index); 442 page = grab_cache_page_write_begin(mapping, index, flags);
442 if (unlikely(!page)) 443 if (unlikely(!page))
443 return -ENOMEM; 444 return -ENOMEM;
444 445
445 if (!PageUptodate(page)) { 446 if (!PageUptodate(page)) {
446 /* The page is not loaded from the flash */ 447 /* The page is not loaded from the flash */
447 if (!(pos & PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE) 448 if (!(pos & ~PAGE_CACHE_MASK) && len == PAGE_CACHE_SIZE)
448 /* 449 /*
449 * We change whole page so no need to load it. But we 450 * We change whole page so no need to load it. But we
450 * have to set the @PG_checked flag to make the further 451 * have to set the @PG_checked flag to make the further
@@ -483,7 +484,7 @@ static int ubifs_write_begin(struct file *file, struct address_space *mapping,
483 unlock_page(page); 484 unlock_page(page);
484 page_cache_release(page); 485 page_cache_release(page);
485 486
486 return write_begin_slow(mapping, pos, len, pagep); 487 return write_begin_slow(mapping, pos, len, pagep, flags);
487 } 488 }
488 489
489 /* 490 /*
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 5e82cffe9695..6db7a6be6c97 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -154,6 +154,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
154 case FS_IOC_GETFLAGS: 154 case FS_IOC_GETFLAGS:
155 flags = ubifs2ioctl(ubifs_inode(inode)->flags); 155 flags = ubifs2ioctl(ubifs_inode(inode)->flags);
156 156
157 dbg_gen("get flags: %#x, i_flags %#x", flags, inode->i_flags);
157 return put_user(flags, (int __user *) arg); 158 return put_user(flags, (int __user *) arg);
158 159
159 case FS_IOC_SETFLAGS: { 160 case FS_IOC_SETFLAGS: {
@@ -176,6 +177,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
176 err = mnt_want_write(file->f_path.mnt); 177 err = mnt_want_write(file->f_path.mnt);
177 if (err) 178 if (err)
178 return err; 179 return err;
180 dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);
179 err = setflags(inode, flags); 181 err = setflags(inode, flags);
180 mnt_drop_write(file->f_path.mnt); 182 mnt_drop_write(file->f_path.mnt);
181 return err; 183 return err;
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index f91b745908ea..10ae25b7d1db 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -704,7 +704,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
704 data->size = cpu_to_le32(len); 704 data->size = cpu_to_le32(len);
705 zero_data_node_unused(data); 705 zero_data_node_unused(data);
706 706
707 if (!(ui->flags && UBIFS_COMPR_FL)) 707 if (!(ui->flags & UBIFS_COMPR_FL))
708 /* Compression is disabled for this inode */ 708 /* Compression is disabled for this inode */
709 compr_type = UBIFS_COMPR_NONE; 709 compr_type = UBIFS_COMPR_NONE;
710 else 710 else
@@ -1220,7 +1220,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
1220 data_key_init(c, &key, inum, blk); 1220 data_key_init(c, &key, inum, blk);
1221 1221
1222 bit = old_size & (UBIFS_BLOCK_SIZE - 1); 1222 bit = old_size & (UBIFS_BLOCK_SIZE - 1);
1223 blk = (old_size >> UBIFS_BLOCK_SHIFT) - (bit ? 0: 1); 1223 blk = (old_size >> UBIFS_BLOCK_SHIFT) - (bit ? 0 : 1);
1224 data_key_init(c, &to_key, inum, blk); 1224 data_key_init(c, &to_key, inum, blk);
1225 1225
1226 err = ubifs_tnc_remove_range(c, &key, &to_key); 1226 err = ubifs_tnc_remove_range(c, &key, &to_key);
diff --git a/fs/ubifs/key.h b/fs/ubifs/key.h
index 3f1f16bc25c9..efb3430a2581 100644
--- a/fs/ubifs/key.h
+++ b/fs/ubifs/key.h
@@ -38,6 +38,22 @@
38#define __UBIFS_KEY_H__ 38#define __UBIFS_KEY_H__
39 39
40/** 40/**
41 * key_mask_hash - mask a valid hash value.
42 * @val: value to be masked
43 *
44 * We use hash values as offset in directories, so values %0 and %1 are
45 * reserved for "." and "..". %2 is reserved for "end of readdir" marker. This
46 * function makes sure the reserved values are not used.
47 */
48static inline uint32_t key_mask_hash(uint32_t hash)
49{
50 hash &= UBIFS_S_KEY_HASH_MASK;
51 if (unlikely(hash <= 2))
52 hash += 3;
53 return hash;
54}
55
56/**
41 * key_r5_hash - R5 hash function (borrowed from reiserfs). 57 * key_r5_hash - R5 hash function (borrowed from reiserfs).
42 * @s: direntry name 58 * @s: direntry name
43 * @len: name length 59 * @len: name length
@@ -54,16 +70,7 @@ static inline uint32_t key_r5_hash(const char *s, int len)
54 str++; 70 str++;
55 } 71 }
56 72
57 a &= UBIFS_S_KEY_HASH_MASK; 73 return key_mask_hash(a);
58
59 /*
60 * We use hash values as offset in directories, so values %0 and %1 are
61 * reserved for "." and "..". %2 is reserved for "end of readdir"
62 * marker.
63 */
64 if (unlikely(a >= 0 && a <= 2))
65 a += 3;
66 return a;
67} 74}
68 75
69/** 76/**
@@ -77,10 +84,7 @@ static inline uint32_t key_test_hash(const char *str, int len)
77 84
78 len = min_t(uint32_t, len, 4); 85 len = min_t(uint32_t, len, 4);
79 memcpy(&a, str, len); 86 memcpy(&a, str, len);
80 a &= UBIFS_S_KEY_HASH_MASK; 87 return key_mask_hash(a);
81 if (unlikely(a >= 0 && a <= 2))
82 a += 3;
83 return a;
84} 88}
85 89
86/** 90/**
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index f27176e9b70d..dfd2bcece27a 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -520,13 +520,13 @@ static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops)
520 * @flags: new flags 520 * @flags: new flags
521 * @idx_gc_cnt: change to the count of idx_gc list 521 * @idx_gc_cnt: change to the count of idx_gc list
522 * 522 *
523 * This function changes LEB properties. This function does not change a LEB 523 * This function changes LEB properties (@free, @dirty or @flag). However, the
524 * property (@free, @dirty or @flag) if the value passed is %LPROPS_NC. 524 * property which has the %LPROPS_NC value is not changed. Returns a pointer to
525 * the updated LEB properties on success and a negative error code on failure.
525 * 526 *
526 * This function returns a pointer to the updated LEB properties on success 527 * Note, the LEB properties may have had to be copied (due to COW) and
527 * and a negative error code on failure. N.B. the LEB properties may have had to 528 * consequently the pointer returned may not be the same as the pointer
528 * be copied (due to COW) and consequently the pointer returned may not be the 529 * passed.
529 * same as the pointer passed.
530 */ 530 */
531const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c, 531const struct ubifs_lprops *ubifs_change_lp(struct ubifs_info *c,
532 const struct ubifs_lprops *lp, 532 const struct ubifs_lprops *lp,
@@ -1088,7 +1088,7 @@ static int scan_check_cb(struct ubifs_info *c,
1088 } 1088 }
1089 } 1089 }
1090 1090
1091 sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); 1091 sleb = ubifs_scan(c, lnum, 0, c->dbg->buf);
1092 if (IS_ERR(sleb)) { 1092 if (IS_ERR(sleb)) {
1093 /* 1093 /*
1094 * After an unclean unmount, empty and freeable LEBs 1094 * After an unclean unmount, empty and freeable LEBs
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index db8bd0e518b2..b2792e84d245 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -36,15 +36,16 @@
36 * can be written into a single eraseblock. In that case, garbage collection 36 * can be written into a single eraseblock. In that case, garbage collection
37 * consists of just writing the whole table, which therefore makes all other 37 * consists of just writing the whole table, which therefore makes all other
38 * eraseblocks reusable. In the case of the big model, dirty eraseblocks are 38 * eraseblocks reusable. In the case of the big model, dirty eraseblocks are
39 * selected for garbage collection, which consists are marking the nodes in 39 * selected for garbage collection, which consists of marking the clean nodes in
40 * that LEB as dirty, and then only the dirty nodes are written out. Also, in 40 * that LEB as dirty, and then only the dirty nodes are written out. Also, in
41 * the case of the big model, a table of LEB numbers is saved so that the entire 41 * the case of the big model, a table of LEB numbers is saved so that the entire
42 * LPT does not to be scanned looking for empty eraseblocks when UBIFS is first 42 * LPT does not to be scanned looking for empty eraseblocks when UBIFS is first
43 * mounted. 43 * mounted.
44 */ 44 */
45 45
46#include <linux/crc16.h>
47#include "ubifs.h" 46#include "ubifs.h"
47#include <linux/crc16.h>
48#include <linux/math64.h>
48 49
49/** 50/**
50 * do_calc_lpt_geom - calculate sizes for the LPT area. 51 * do_calc_lpt_geom - calculate sizes for the LPT area.
@@ -135,15 +136,13 @@ static void do_calc_lpt_geom(struct ubifs_info *c)
135int ubifs_calc_lpt_geom(struct ubifs_info *c) 136int ubifs_calc_lpt_geom(struct ubifs_info *c)
136{ 137{
137 int lebs_needed; 138 int lebs_needed;
138 uint64_t sz; 139 long long sz;
139 140
140 do_calc_lpt_geom(c); 141 do_calc_lpt_geom(c);
141 142
142 /* Verify that lpt_lebs is big enough */ 143 /* Verify that lpt_lebs is big enough */
143 sz = c->lpt_sz * 2; /* Must have at least 2 times the size */ 144 sz = c->lpt_sz * 2; /* Must have at least 2 times the size */
144 sz += c->leb_size - 1; 145 lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size);
145 do_div(sz, c->leb_size);
146 lebs_needed = sz;
147 if (lebs_needed > c->lpt_lebs) { 146 if (lebs_needed > c->lpt_lebs) {
148 ubifs_err("too few LPT LEBs"); 147 ubifs_err("too few LPT LEBs");
149 return -EINVAL; 148 return -EINVAL;
@@ -156,7 +155,6 @@ int ubifs_calc_lpt_geom(struct ubifs_info *c)
156 } 155 }
157 156
158 c->check_lpt_free = c->big_lpt; 157 c->check_lpt_free = c->big_lpt;
159
160 return 0; 158 return 0;
161} 159}
162 160
@@ -176,7 +174,7 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs,
176 int *big_lpt) 174 int *big_lpt)
177{ 175{
178 int i, lebs_needed; 176 int i, lebs_needed;
179 uint64_t sz; 177 long long sz;
180 178
181 /* Start by assuming the minimum number of LPT LEBs */ 179 /* Start by assuming the minimum number of LPT LEBs */
182 c->lpt_lebs = UBIFS_MIN_LPT_LEBS; 180 c->lpt_lebs = UBIFS_MIN_LPT_LEBS;
@@ -203,9 +201,7 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs,
203 /* Now check there are enough LPT LEBs */ 201 /* Now check there are enough LPT LEBs */
204 for (i = 0; i < 64 ; i++) { 202 for (i = 0; i < 64 ; i++) {
205 sz = c->lpt_sz * 4; /* Allow 4 times the size */ 203 sz = c->lpt_sz * 4; /* Allow 4 times the size */
206 sz += c->leb_size - 1; 204 lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size);
207 do_div(sz, c->leb_size);
208 lebs_needed = sz;
209 if (lebs_needed > c->lpt_lebs) { 205 if (lebs_needed > c->lpt_lebs) {
210 /* Not enough LPT LEBs so try again with more */ 206 /* Not enough LPT LEBs so try again with more */
211 c->lpt_lebs = lebs_needed; 207 c->lpt_lebs = lebs_needed;
@@ -558,7 +554,7 @@ static int calc_nnode_num(int row, int col)
558 * This function calculates and returns the nnode number based on the parent's 554 * This function calculates and returns the nnode number based on the parent's
559 * nnode number and the index in parent. 555 * nnode number and the index in parent.
560 */ 556 */
561static int calc_nnode_num_from_parent(struct ubifs_info *c, 557static int calc_nnode_num_from_parent(const struct ubifs_info *c,
562 struct ubifs_nnode *parent, int iip) 558 struct ubifs_nnode *parent, int iip)
563{ 559{
564 int num, shft; 560 int num, shft;
@@ -583,7 +579,7 @@ static int calc_nnode_num_from_parent(struct ubifs_info *c,
583 * This function calculates and returns the pnode number based on the parent's 579 * This function calculates and returns the pnode number based on the parent's
584 * nnode number and the index in parent. 580 * nnode number and the index in parent.
585 */ 581 */
586static int calc_pnode_num_from_parent(struct ubifs_info *c, 582static int calc_pnode_num_from_parent(const struct ubifs_info *c,
587 struct ubifs_nnode *parent, int iip) 583 struct ubifs_nnode *parent, int iip)
588{ 584{
589 int i, n = c->lpt_hght - 1, pnum = parent->num, num = 0; 585 int i, n = c->lpt_hght - 1, pnum = parent->num, num = 0;
@@ -966,7 +962,7 @@ static int check_lpt_type(uint8_t **addr, int *pos, int type)
966 * 962 *
967 * This function returns %0 on success and a negative error code on failure. 963 * This function returns %0 on success and a negative error code on failure.
968 */ 964 */
969static int unpack_pnode(struct ubifs_info *c, void *buf, 965static int unpack_pnode(const struct ubifs_info *c, void *buf,
970 struct ubifs_pnode *pnode) 966 struct ubifs_pnode *pnode)
971{ 967{
972 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 968 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
@@ -996,15 +992,15 @@ static int unpack_pnode(struct ubifs_info *c, void *buf,
996} 992}
997 993
998/** 994/**
999 * unpack_nnode - unpack a nnode. 995 * ubifs_unpack_nnode - unpack a nnode.
1000 * @c: UBIFS file-system description object 996 * @c: UBIFS file-system description object
1001 * @buf: buffer containing packed nnode to unpack 997 * @buf: buffer containing packed nnode to unpack
1002 * @nnode: nnode structure to fill 998 * @nnode: nnode structure to fill
1003 * 999 *
1004 * This function returns %0 on success and a negative error code on failure. 1000 * This function returns %0 on success and a negative error code on failure.
1005 */ 1001 */
1006static int unpack_nnode(struct ubifs_info *c, void *buf, 1002int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf,
1007 struct ubifs_nnode *nnode) 1003 struct ubifs_nnode *nnode)
1008{ 1004{
1009 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 1005 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
1010 int i, pos = 0, err; 1006 int i, pos = 0, err;
@@ -1036,7 +1032,7 @@ static int unpack_nnode(struct ubifs_info *c, void *buf,
1036 * 1032 *
1037 * This function returns %0 on success and a negative error code on failure. 1033 * This function returns %0 on success and a negative error code on failure.
1038 */ 1034 */
1039static int unpack_ltab(struct ubifs_info *c, void *buf) 1035static int unpack_ltab(const struct ubifs_info *c, void *buf)
1040{ 1036{
1041 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 1037 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
1042 int i, pos = 0, err; 1038 int i, pos = 0, err;
@@ -1068,7 +1064,7 @@ static int unpack_ltab(struct ubifs_info *c, void *buf)
1068 * 1064 *
1069 * This function returns %0 on success and a negative error code on failure. 1065 * This function returns %0 on success and a negative error code on failure.
1070 */ 1066 */
1071static int unpack_lsave(struct ubifs_info *c, void *buf) 1067static int unpack_lsave(const struct ubifs_info *c, void *buf)
1072{ 1068{
1073 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 1069 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
1074 int i, pos = 0, err; 1070 int i, pos = 0, err;
@@ -1096,7 +1092,7 @@ static int unpack_lsave(struct ubifs_info *c, void *buf)
1096 * 1092 *
1097 * This function returns %0 on success and a negative error code on failure. 1093 * This function returns %0 on success and a negative error code on failure.
1098 */ 1094 */
1099static int validate_nnode(struct ubifs_info *c, struct ubifs_nnode *nnode, 1095static int validate_nnode(const struct ubifs_info *c, struct ubifs_nnode *nnode,
1100 struct ubifs_nnode *parent, int iip) 1096 struct ubifs_nnode *parent, int iip)
1101{ 1097{
1102 int i, lvl, max_offs; 1098 int i, lvl, max_offs;
@@ -1140,7 +1136,7 @@ static int validate_nnode(struct ubifs_info *c, struct ubifs_nnode *nnode,
1140 * 1136 *
1141 * This function returns %0 on success and a negative error code on failure. 1137 * This function returns %0 on success and a negative error code on failure.
1142 */ 1138 */
1143static int validate_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode, 1139static int validate_pnode(const struct ubifs_info *c, struct ubifs_pnode *pnode,
1144 struct ubifs_nnode *parent, int iip) 1140 struct ubifs_nnode *parent, int iip)
1145{ 1141{
1146 int i; 1142 int i;
@@ -1174,7 +1170,8 @@ static int validate_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
1174 * This function calculates the LEB numbers for the LEB properties it contains 1170 * This function calculates the LEB numbers for the LEB properties it contains
1175 * based on the pnode number. 1171 * based on the pnode number.
1176 */ 1172 */
1177static void set_pnode_lnum(struct ubifs_info *c, struct ubifs_pnode *pnode) 1173static void set_pnode_lnum(const struct ubifs_info *c,
1174 struct ubifs_pnode *pnode)
1178{ 1175{
1179 int i, lnum; 1176 int i, lnum;
1180 1177
@@ -1227,7 +1224,7 @@ int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip)
1227 err = ubi_read(c->ubi, lnum, buf, offs, c->nnode_sz); 1224 err = ubi_read(c->ubi, lnum, buf, offs, c->nnode_sz);
1228 if (err) 1225 if (err)
1229 goto out; 1226 goto out;
1230 err = unpack_nnode(c, buf, nnode); 1227 err = ubifs_unpack_nnode(c, buf, nnode);
1231 if (err) 1228 if (err)
1232 goto out; 1229 goto out;
1233 } 1230 }
@@ -1816,7 +1813,7 @@ static struct ubifs_nnode *scan_get_nnode(struct ubifs_info *c,
1816 c->nnode_sz); 1813 c->nnode_sz);
1817 if (err) 1814 if (err)
1818 return ERR_PTR(err); 1815 return ERR_PTR(err);
1819 err = unpack_nnode(c, buf, nnode); 1816 err = ubifs_unpack_nnode(c, buf, nnode);
1820 if (err) 1817 if (err)
1821 return ERR_PTR(err); 1818 return ERR_PTR(err);
1822 } 1819 }
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index a41434b42785..96ca95707175 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -320,6 +320,8 @@ no_space:
320 dbg_err("LPT out of space at LEB %d:%d needing %d, done_ltab %d, " 320 dbg_err("LPT out of space at LEB %d:%d needing %d, done_ltab %d, "
321 "done_lsave %d", lnum, offs, len, done_ltab, done_lsave); 321 "done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
322 dbg_dump_lpt_info(c); 322 dbg_dump_lpt_info(c);
323 dbg_dump_lpt_lebs(c);
324 dump_stack();
323 return err; 325 return err;
324} 326}
325 327
@@ -546,8 +548,10 @@ static int write_cnodes(struct ubifs_info *c)
546no_space: 548no_space:
547 ubifs_err("LPT out of space mismatch"); 549 ubifs_err("LPT out of space mismatch");
548 dbg_err("LPT out of space mismatch at LEB %d:%d needing %d, done_ltab " 550 dbg_err("LPT out of space mismatch at LEB %d:%d needing %d, done_ltab "
549 "%d, done_lsave %d", lnum, offs, len, done_ltab, done_lsave); 551 "%d, done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
550 dbg_dump_lpt_info(c); 552 dbg_dump_lpt_info(c);
553 dbg_dump_lpt_lebs(c);
554 dump_stack();
551 return err; 555 return err;
552} 556}
553 557
@@ -749,7 +753,7 @@ static void lpt_tgc_start(struct ubifs_info *c)
749 * LPT trivial garbage collection is where a LPT LEB contains only dirty and 753 * LPT trivial garbage collection is where a LPT LEB contains only dirty and
750 * free space and so may be reused as soon as the next commit is completed. 754 * free space and so may be reused as soon as the next commit is completed.
751 * This function is called after the commit is completed (master node has been 755 * This function is called after the commit is completed (master node has been
752 * written) and unmaps LPT LEBs that were marked for trivial GC. 756 * written) and un-maps LPT LEBs that were marked for trivial GC.
753 */ 757 */
754static int lpt_tgc_end(struct ubifs_info *c) 758static int lpt_tgc_end(struct ubifs_info *c)
755{ 759{
@@ -1025,7 +1029,7 @@ static int make_node_dirty(struct ubifs_info *c, int node_type, int node_num,
1025 * @c: UBIFS file-system description object 1029 * @c: UBIFS file-system description object
1026 * @node_type: LPT node type 1030 * @node_type: LPT node type
1027 */ 1031 */
1028static int get_lpt_node_len(struct ubifs_info *c, int node_type) 1032static int get_lpt_node_len(const struct ubifs_info *c, int node_type)
1029{ 1033{
1030 switch (node_type) { 1034 switch (node_type) {
1031 case UBIFS_LPT_NNODE: 1035 case UBIFS_LPT_NNODE:
@@ -1046,7 +1050,7 @@ static int get_lpt_node_len(struct ubifs_info *c, int node_type)
1046 * @buf: buffer 1050 * @buf: buffer
1047 * @len: length of buffer 1051 * @len: length of buffer
1048 */ 1052 */
1049static int get_pad_len(struct ubifs_info *c, uint8_t *buf, int len) 1053static int get_pad_len(const struct ubifs_info *c, uint8_t *buf, int len)
1050{ 1054{
1051 int offs, pad_len; 1055 int offs, pad_len;
1052 1056
@@ -1063,7 +1067,8 @@ static int get_pad_len(struct ubifs_info *c, uint8_t *buf, int len)
1063 * @buf: buffer 1067 * @buf: buffer
1064 * @node_num: node number is returned here 1068 * @node_num: node number is returned here
1065 */ 1069 */
1066static int get_lpt_node_type(struct ubifs_info *c, uint8_t *buf, int *node_num) 1070static int get_lpt_node_type(const struct ubifs_info *c, uint8_t *buf,
1071 int *node_num)
1067{ 1072{
1068 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 1073 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
1069 int pos = 0, node_type; 1074 int pos = 0, node_type;
@@ -1081,7 +1086,7 @@ static int get_lpt_node_type(struct ubifs_info *c, uint8_t *buf, int *node_num)
1081 * 1086 *
1082 * This function returns %1 if the buffer contains a node or %0 if it does not. 1087 * This function returns %1 if the buffer contains a node or %0 if it does not.
1083 */ 1088 */
1084static int is_a_node(struct ubifs_info *c, uint8_t *buf, int len) 1089static int is_a_node(const struct ubifs_info *c, uint8_t *buf, int len)
1085{ 1090{
1086 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES; 1091 uint8_t *addr = buf + UBIFS_LPT_CRC_BYTES;
1087 int pos = 0, node_type, node_len; 1092 int pos = 0, node_type, node_len;
@@ -1105,7 +1110,6 @@ static int is_a_node(struct ubifs_info *c, uint8_t *buf, int len)
1105 return 1; 1110 return 1;
1106} 1111}
1107 1112
1108
1109/** 1113/**
1110 * lpt_gc_lnum - garbage collect a LPT LEB. 1114 * lpt_gc_lnum - garbage collect a LPT LEB.
1111 * @c: UBIFS file-system description object 1115 * @c: UBIFS file-system description object
@@ -1463,7 +1467,7 @@ void ubifs_lpt_free(struct ubifs_info *c, int wr_only)
1463#ifdef CONFIG_UBIFS_FS_DEBUG 1467#ifdef CONFIG_UBIFS_FS_DEBUG
1464 1468
1465/** 1469/**
1466 * dbg_is_all_ff - determine if a buffer contains only 0xff bytes. 1470 * dbg_is_all_ff - determine if a buffer contains only 0xFF bytes.
1467 * @buf: buffer 1471 * @buf: buffer
1468 * @len: buffer length 1472 * @len: buffer length
1469 */ 1473 */
@@ -1488,7 +1492,7 @@ static int dbg_is_nnode_dirty(struct ubifs_info *c, int lnum, int offs)
1488 struct ubifs_nnode *nnode; 1492 struct ubifs_nnode *nnode;
1489 int hght; 1493 int hght;
1490 1494
1491 /* Entire tree is in memory so first_nnode / next_nnode are ok */ 1495 /* Entire tree is in memory so first_nnode / next_nnode are OK */
1492 nnode = first_nnode(c, &hght); 1496 nnode = first_nnode(c, &hght);
1493 for (; nnode; nnode = next_nnode(c, nnode, &hght)) { 1497 for (; nnode; nnode = next_nnode(c, nnode, &hght)) {
1494 struct ubifs_nbranch *branch; 1498 struct ubifs_nbranch *branch;
@@ -1602,7 +1606,10 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum)
1602{ 1606{
1603 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len; 1607 int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len;
1604 int ret; 1608 int ret;
1605 void *buf = c->dbg_buf; 1609 void *buf = c->dbg->buf;
1610
1611 if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS))
1612 return 0;
1606 1613
1607 dbg_lp("LEB %d", lnum); 1614 dbg_lp("LEB %d", lnum);
1608 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size); 1615 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size);
@@ -1704,6 +1711,9 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
1704 long long free = 0; 1711 long long free = 0;
1705 int i; 1712 int i;
1706 1713
1714 if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS))
1715 return 0;
1716
1707 for (i = 0; i < c->lpt_lebs; i++) { 1717 for (i = 0; i < c->lpt_lebs; i++) {
1708 if (c->ltab[i].tgc || c->ltab[i].cmt) 1718 if (c->ltab[i].tgc || c->ltab[i].cmt)
1709 continue; 1719 continue;
@@ -1716,6 +1726,8 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
1716 dbg_err("LPT space error: free %lld lpt_sz %lld", 1726 dbg_err("LPT space error: free %lld lpt_sz %lld",
1717 free, c->lpt_sz); 1727 free, c->lpt_sz);
1718 dbg_dump_lpt_info(c); 1728 dbg_dump_lpt_info(c);
1729 dbg_dump_lpt_lebs(c);
1730 dump_stack();
1719 return -EINVAL; 1731 return -EINVAL;
1720 } 1732 }
1721 return 0; 1733 return 0;
@@ -1731,15 +1743,19 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
1731 */ 1743 */
1732int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) 1744int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1733{ 1745{
1746 struct ubifs_debug_info *d = c->dbg;
1734 long long chk_lpt_sz, lpt_sz; 1747 long long chk_lpt_sz, lpt_sz;
1735 int err = 0; 1748 int err = 0;
1736 1749
1750 if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS))
1751 return 0;
1752
1737 switch (action) { 1753 switch (action) {
1738 case 0: 1754 case 0:
1739 c->chk_lpt_sz = 0; 1755 d->chk_lpt_sz = 0;
1740 c->chk_lpt_sz2 = 0; 1756 d->chk_lpt_sz2 = 0;
1741 c->chk_lpt_lebs = 0; 1757 d->chk_lpt_lebs = 0;
1742 c->chk_lpt_wastage = 0; 1758 d->chk_lpt_wastage = 0;
1743 if (c->dirty_pn_cnt > c->pnode_cnt) { 1759 if (c->dirty_pn_cnt > c->pnode_cnt) {
1744 dbg_err("dirty pnodes %d exceed max %d", 1760 dbg_err("dirty pnodes %d exceed max %d",
1745 c->dirty_pn_cnt, c->pnode_cnt); 1761 c->dirty_pn_cnt, c->pnode_cnt);
@@ -1752,35 +1768,35 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1752 } 1768 }
1753 return err; 1769 return err;
1754 case 1: 1770 case 1:
1755 c->chk_lpt_sz += len; 1771 d->chk_lpt_sz += len;
1756 return 0; 1772 return 0;
1757 case 2: 1773 case 2:
1758 c->chk_lpt_sz += len; 1774 d->chk_lpt_sz += len;
1759 c->chk_lpt_wastage += len; 1775 d->chk_lpt_wastage += len;
1760 c->chk_lpt_lebs += 1; 1776 d->chk_lpt_lebs += 1;
1761 return 0; 1777 return 0;
1762 case 3: 1778 case 3:
1763 chk_lpt_sz = c->leb_size; 1779 chk_lpt_sz = c->leb_size;
1764 chk_lpt_sz *= c->chk_lpt_lebs; 1780 chk_lpt_sz *= d->chk_lpt_lebs;
1765 chk_lpt_sz += len - c->nhead_offs; 1781 chk_lpt_sz += len - c->nhead_offs;
1766 if (c->chk_lpt_sz != chk_lpt_sz) { 1782 if (d->chk_lpt_sz != chk_lpt_sz) {
1767 dbg_err("LPT wrote %lld but space used was %lld", 1783 dbg_err("LPT wrote %lld but space used was %lld",
1768 c->chk_lpt_sz, chk_lpt_sz); 1784 d->chk_lpt_sz, chk_lpt_sz);
1769 err = -EINVAL; 1785 err = -EINVAL;
1770 } 1786 }
1771 if (c->chk_lpt_sz > c->lpt_sz) { 1787 if (d->chk_lpt_sz > c->lpt_sz) {
1772 dbg_err("LPT wrote %lld but lpt_sz is %lld", 1788 dbg_err("LPT wrote %lld but lpt_sz is %lld",
1773 c->chk_lpt_sz, c->lpt_sz); 1789 d->chk_lpt_sz, c->lpt_sz);
1774 err = -EINVAL; 1790 err = -EINVAL;
1775 } 1791 }
1776 if (c->chk_lpt_sz2 && c->chk_lpt_sz != c->chk_lpt_sz2) { 1792 if (d->chk_lpt_sz2 && d->chk_lpt_sz != d->chk_lpt_sz2) {
1777 dbg_err("LPT layout size %lld but wrote %lld", 1793 dbg_err("LPT layout size %lld but wrote %lld",
1778 c->chk_lpt_sz, c->chk_lpt_sz2); 1794 d->chk_lpt_sz, d->chk_lpt_sz2);
1779 err = -EINVAL; 1795 err = -EINVAL;
1780 } 1796 }
1781 if (c->chk_lpt_sz2 && c->new_nhead_offs != len) { 1797 if (d->chk_lpt_sz2 && d->new_nhead_offs != len) {
1782 dbg_err("LPT new nhead offs: expected %d was %d", 1798 dbg_err("LPT new nhead offs: expected %d was %d",
1783 c->new_nhead_offs, len); 1799 d->new_nhead_offs, len);
1784 err = -EINVAL; 1800 err = -EINVAL;
1785 } 1801 }
1786 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz; 1802 lpt_sz = (long long)c->pnode_cnt * c->pnode_sz;
@@ -1788,26 +1804,146 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
1788 lpt_sz += c->ltab_sz; 1804 lpt_sz += c->ltab_sz;
1789 if (c->big_lpt) 1805 if (c->big_lpt)
1790 lpt_sz += c->lsave_sz; 1806 lpt_sz += c->lsave_sz;
1791 if (c->chk_lpt_sz - c->chk_lpt_wastage > lpt_sz) { 1807 if (d->chk_lpt_sz - d->chk_lpt_wastage > lpt_sz) {
1792 dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld", 1808 dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld",
1793 c->chk_lpt_sz, c->chk_lpt_wastage, lpt_sz); 1809 d->chk_lpt_sz, d->chk_lpt_wastage, lpt_sz);
1794 err = -EINVAL; 1810 err = -EINVAL;
1795 } 1811 }
1796 if (err) 1812 if (err) {
1797 dbg_dump_lpt_info(c); 1813 dbg_dump_lpt_info(c);
1798 c->chk_lpt_sz2 = c->chk_lpt_sz; 1814 dbg_dump_lpt_lebs(c);
1799 c->chk_lpt_sz = 0; 1815 dump_stack();
1800 c->chk_lpt_wastage = 0; 1816 }
1801 c->chk_lpt_lebs = 0; 1817 d->chk_lpt_sz2 = d->chk_lpt_sz;
1802 c->new_nhead_offs = len; 1818 d->chk_lpt_sz = 0;
1819 d->chk_lpt_wastage = 0;
1820 d->chk_lpt_lebs = 0;
1821 d->new_nhead_offs = len;
1803 return err; 1822 return err;
1804 case 4: 1823 case 4:
1805 c->chk_lpt_sz += len; 1824 d->chk_lpt_sz += len;
1806 c->chk_lpt_wastage += len; 1825 d->chk_lpt_wastage += len;
1807 return 0; 1826 return 0;
1808 default: 1827 default:
1809 return -EINVAL; 1828 return -EINVAL;
1810 } 1829 }
1811} 1830}
1812 1831
1832/**
1833 * dbg_dump_lpt_leb - dump an LPT LEB.
1834 * @c: UBIFS file-system description object
1835 * @lnum: LEB number to dump
1836 *
1837 * This function dumps an LEB from LPT area. Nodes in this area are very
1838 * different to nodes in the main area (e.g., they do not have common headers,
1839 * they do not have 8-byte alignments, etc), so we have a separate function to
1840 * dump LPT area LEBs. Note, LPT has to be locked by the caller.
1841 */
1842static void dump_lpt_leb(const struct ubifs_info *c, int lnum)
1843{
1844 int err, len = c->leb_size, node_type, node_num, node_len, offs;
1845 void *buf = c->dbg->buf;
1846
1847 printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n",
1848 current->pid, lnum);
1849 err = ubi_read(c->ubi, lnum, buf, 0, c->leb_size);
1850 if (err) {
1851 ubifs_err("cannot read LEB %d, error %d", lnum, err);
1852 return;
1853 }
1854 while (1) {
1855 offs = c->leb_size - len;
1856 if (!is_a_node(c, buf, len)) {
1857 int pad_len;
1858
1859 pad_len = get_pad_len(c, buf, len);
1860 if (pad_len) {
1861 printk(KERN_DEBUG "LEB %d:%d, pad %d bytes\n",
1862 lnum, offs, pad_len);
1863 buf += pad_len;
1864 len -= pad_len;
1865 continue;
1866 }
1867 if (len)
1868 printk(KERN_DEBUG "LEB %d:%d, free %d bytes\n",
1869 lnum, offs, len);
1870 break;
1871 }
1872
1873 node_type = get_lpt_node_type(c, buf, &node_num);
1874 switch (node_type) {
1875 case UBIFS_LPT_PNODE:
1876 {
1877 node_len = c->pnode_sz;
1878 if (c->big_lpt)
1879 printk(KERN_DEBUG "LEB %d:%d, pnode num %d\n",
1880 lnum, offs, node_num);
1881 else
1882 printk(KERN_DEBUG "LEB %d:%d, pnode\n",
1883 lnum, offs);
1884 break;
1885 }
1886 case UBIFS_LPT_NNODE:
1887 {
1888 int i;
1889 struct ubifs_nnode nnode;
1890
1891 node_len = c->nnode_sz;
1892 if (c->big_lpt)
1893 printk(KERN_DEBUG "LEB %d:%d, nnode num %d, ",
1894 lnum, offs, node_num);
1895 else
1896 printk(KERN_DEBUG "LEB %d:%d, nnode, ",
1897 lnum, offs);
1898 err = ubifs_unpack_nnode(c, buf, &nnode);
1899 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
1900 printk("%d:%d", nnode.nbranch[i].lnum,
1901 nnode.nbranch[i].offs);
1902 if (i != UBIFS_LPT_FANOUT - 1)
1903 printk(", ");
1904 }
1905 printk("\n");
1906 break;
1907 }
1908 case UBIFS_LPT_LTAB:
1909 node_len = c->ltab_sz;
1910 printk(KERN_DEBUG "LEB %d:%d, ltab\n",
1911 lnum, offs);
1912 break;
1913 case UBIFS_LPT_LSAVE:
1914 node_len = c->lsave_sz;
1915 printk(KERN_DEBUG "LEB %d:%d, lsave len\n", lnum, offs);
1916 break;
1917 default:
1918 ubifs_err("LPT node type %d not recognized", node_type);
1919 return;
1920 }
1921
1922 buf += node_len;
1923 len -= node_len;
1924 }
1925
1926 printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n",
1927 current->pid, lnum);
1928}
1929
1930/**
1931 * dbg_dump_lpt_lebs - dump LPT lebs.
1932 * @c: UBIFS file-system description object
1933 *
1934 * This function dumps all LPT LEBs. The caller has to make sure the LPT is
1935 * locked.
1936 */
1937void dbg_dump_lpt_lebs(const struct ubifs_info *c)
1938{
1939 int i;
1940
1941 printk(KERN_DEBUG "(pid %d) start dumping all LPT LEBs\n",
1942 current->pid);
1943 for (i = 0; i < c->lpt_lebs; i++)
1944 dump_lpt_leb(c, i + c->lpt_first);
1945 printk(KERN_DEBUG "(pid %d) finish dumping all LPT LEBs\n",
1946 current->pid);
1947}
1948
1813#endif /* CONFIG_UBIFS_FS_DEBUG */ 1949#endif /* CONFIG_UBIFS_FS_DEBUG */
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index 9bd5a43d4526..9e6f403f170e 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -899,7 +899,7 @@ static int dbg_scan_orphans(struct ubifs_info *c, struct check_info *ci)
899 for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) { 899 for (lnum = c->orph_first; lnum <= c->orph_last; lnum++) {
900 struct ubifs_scan_leb *sleb; 900 struct ubifs_scan_leb *sleb;
901 901
902 sleb = ubifs_scan(c, lnum, 0, c->dbg_buf); 902 sleb = ubifs_scan(c, lnum, 0, c->dbg->buf);
903 if (IS_ERR(sleb)) { 903 if (IS_ERR(sleb)) {
904 err = PTR_ERR(sleb); 904 err = PTR_ERR(sleb);
905 break; 905 break;
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 21f7d047c306..ce42a7b0ca5a 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -144,7 +144,7 @@ static int set_bud_lprops(struct ubifs_info *c, struct replay_entry *r)
144 /* 144 /*
145 * If the replay order was perfect the dirty space would now be 145 * If the replay order was perfect the dirty space would now be
146 * zero. The order is not perfect because the the journal heads 146 * zero. The order is not perfect because the the journal heads
147 * race with eachother. This is not a problem but is does mean 147 * race with each other. This is not a problem but is does mean
148 * that the dirty space may temporarily exceed c->leb_size 148 * that the dirty space may temporarily exceed c->leb_size
149 * during the replay. 149 * during the replay.
150 */ 150 */
@@ -656,7 +656,7 @@ out_dump:
656 * @dirty: amount of dirty space from padding and deletion nodes 656 * @dirty: amount of dirty space from padding and deletion nodes
657 * 657 *
658 * This function inserts a reference node to the replay tree and returns zero 658 * This function inserts a reference node to the replay tree and returns zero
659 * in case of success ort a negative error code in case of failure. 659 * in case of success or a negative error code in case of failure.
660 */ 660 */
661static int insert_ref_node(struct ubifs_info *c, int lnum, int offs, 661static int insert_ref_node(struct ubifs_info *c, int lnum, int offs,
662 unsigned long long sqnum, int free, int dirty) 662 unsigned long long sqnum, int free, int dirty)
@@ -883,7 +883,7 @@ static int replay_log_leb(struct ubifs_info *c, int lnum, int offs, void *sbuf)
883 * This means that we reached end of log and now 883 * This means that we reached end of log and now
884 * look to the older log data, which was already 884 * look to the older log data, which was already
885 * committed but the eraseblock was not erased (UBIFS 885 * committed but the eraseblock was not erased (UBIFS
886 * only unmaps it). So this basically means we have to 886 * only un-maps it). So this basically means we have to
887 * exit with "end of log" code. 887 * exit with "end of log" code.
888 */ 888 */
889 err = 1; 889 err = 1;
@@ -1062,6 +1062,15 @@ int ubifs_replay_journal(struct ubifs_info *c)
1062 if (err) 1062 if (err)
1063 goto out; 1063 goto out;
1064 1064
1065 /*
1066 * UBIFS budgeting calculations use @c->budg_uncommitted_idx variable
1067 * to roughly estimate index growth. Things like @c->min_idx_lebs
1068 * depend on it. This means we have to initialize it to make sure
1069 * budgeting works properly.
1070 */
1071 c->budg_uncommitted_idx = atomic_long_read(&c->dirty_zn_cnt);
1072 c->budg_uncommitted_idx *= c->max_idx_node_sz;
1073
1065 ubifs_assert(c->bud_bytes <= c->max_bud_bytes || c->need_recovery); 1074 ubifs_assert(c->bud_bytes <= c->max_bud_bytes || c->need_recovery);
1066 dbg_mnt("finished, log head LEB %d:%d, max_sqnum %llu, " 1075 dbg_mnt("finished, log head LEB %d:%d, max_sqnum %llu, "
1067 "highest_inum %lu", c->lhead_lnum, c->lhead_offs, c->max_sqnum, 1076 "highest_inum %lu", c->lhead_lnum, c->lhead_offs, c->max_sqnum,
diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
index 0f392351dc5a..e070c643d1bb 100644
--- a/fs/ubifs/sb.c
+++ b/fs/ubifs/sb.c
@@ -28,6 +28,7 @@
28 28
29#include "ubifs.h" 29#include "ubifs.h"
30#include <linux/random.h> 30#include <linux/random.h>
31#include <linux/math64.h>
31 32
32/* 33/*
33 * Default journal size in logical eraseblocks as a percent of total 34 * Default journal size in logical eraseblocks as a percent of total
@@ -80,7 +81,7 @@ static int create_default_filesystem(struct ubifs_info *c)
80 int err, tmp, jnl_lebs, log_lebs, max_buds, main_lebs, main_first; 81 int err, tmp, jnl_lebs, log_lebs, max_buds, main_lebs, main_first;
81 int lpt_lebs, lpt_first, orph_lebs, big_lpt, ino_waste, sup_flags = 0; 82 int lpt_lebs, lpt_first, orph_lebs, big_lpt, ino_waste, sup_flags = 0;
82 int min_leb_cnt = UBIFS_MIN_LEB_CNT; 83 int min_leb_cnt = UBIFS_MIN_LEB_CNT;
83 uint64_t tmp64, main_bytes; 84 long long tmp64, main_bytes;
84 __le64 tmp_le64; 85 __le64 tmp_le64;
85 86
86 /* Some functions called from here depend on the @c->key_len filed */ 87 /* Some functions called from here depend on the @c->key_len filed */
@@ -160,7 +161,7 @@ static int create_default_filesystem(struct ubifs_info *c)
160 if (!sup) 161 if (!sup)
161 return -ENOMEM; 162 return -ENOMEM;
162 163
163 tmp64 = (uint64_t)max_buds * c->leb_size; 164 tmp64 = (long long)max_buds * c->leb_size;
164 if (big_lpt) 165 if (big_lpt)
165 sup_flags |= UBIFS_FLG_BIGLPT; 166 sup_flags |= UBIFS_FLG_BIGLPT;
166 167
@@ -179,14 +180,16 @@ static int create_default_filesystem(struct ubifs_info *c)
179 sup->fanout = cpu_to_le32(DEFAULT_FANOUT); 180 sup->fanout = cpu_to_le32(DEFAULT_FANOUT);
180 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt); 181 sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
181 sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION); 182 sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION);
182 sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
183 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN); 183 sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
184 if (c->mount_opts.override_compr)
185 sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
186 else
187 sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
184 188
185 generate_random_uuid(sup->uuid); 189 generate_random_uuid(sup->uuid);
186 190
187 main_bytes = (uint64_t)main_lebs * c->leb_size; 191 main_bytes = (long long)main_lebs * c->leb_size;
188 tmp64 = main_bytes * DEFAULT_RP_PERCENT; 192 tmp64 = div_u64(main_bytes * DEFAULT_RP_PERCENT, 100);
189 do_div(tmp64, 100);
190 if (tmp64 > DEFAULT_MAX_RP_SIZE) 193 if (tmp64 > DEFAULT_MAX_RP_SIZE)
191 tmp64 = DEFAULT_MAX_RP_SIZE; 194 tmp64 = DEFAULT_MAX_RP_SIZE;
192 sup->rp_size = cpu_to_le64(tmp64); 195 sup->rp_size = cpu_to_le64(tmp64);
@@ -582,16 +585,15 @@ int ubifs_read_superblock(struct ubifs_info *c)
582 c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT; 585 c->jhead_cnt = le32_to_cpu(sup->jhead_cnt) + NONDATA_JHEADS_CNT;
583 c->fanout = le32_to_cpu(sup->fanout); 586 c->fanout = le32_to_cpu(sup->fanout);
584 c->lsave_cnt = le32_to_cpu(sup->lsave_cnt); 587 c->lsave_cnt = le32_to_cpu(sup->lsave_cnt);
585 c->default_compr = le16_to_cpu(sup->default_compr);
586 c->rp_size = le64_to_cpu(sup->rp_size); 588 c->rp_size = le64_to_cpu(sup->rp_size);
587 c->rp_uid = le32_to_cpu(sup->rp_uid); 589 c->rp_uid = le32_to_cpu(sup->rp_uid);
588 c->rp_gid = le32_to_cpu(sup->rp_gid); 590 c->rp_gid = le32_to_cpu(sup->rp_gid);
589 sup_flags = le32_to_cpu(sup->flags); 591 sup_flags = le32_to_cpu(sup->flags);
592 if (!c->mount_opts.override_compr)
593 c->default_compr = le16_to_cpu(sup->default_compr);
590 594
591 c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran); 595 c->vfs_sb->s_time_gran = le32_to_cpu(sup->time_gran);
592
593 memcpy(&c->uuid, &sup->uuid, 16); 596 memcpy(&c->uuid, &sup->uuid, 16);
594
595 c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT); 597 c->big_lpt = !!(sup_flags & UBIFS_FLG_BIGLPT);
596 598
597 /* Automatically increase file system size to the maximum size */ 599 /* Automatically increase file system size to the maximum size */
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index d80b2aef42b6..0d7564b95f8e 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -34,6 +34,8 @@
34#include <linux/parser.h> 34#include <linux/parser.h>
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/mount.h> 36#include <linux/mount.h>
37#include <linux/math64.h>
38#include <linux/writeback.h>
37#include "ubifs.h" 39#include "ubifs.h"
38 40
39/* 41/*
@@ -417,39 +419,54 @@ static int ubifs_show_options(struct seq_file *s, struct vfsmount *mnt)
417 else if (c->mount_opts.chk_data_crc == 1) 419 else if (c->mount_opts.chk_data_crc == 1)
418 seq_printf(s, ",no_chk_data_crc"); 420 seq_printf(s, ",no_chk_data_crc");
419 421
422 if (c->mount_opts.override_compr) {
423 seq_printf(s, ",compr=");
424 seq_printf(s, ubifs_compr_name(c->mount_opts.compr_type));
425 }
426
420 return 0; 427 return 0;
421} 428}
422 429
423static int ubifs_sync_fs(struct super_block *sb, int wait) 430static int ubifs_sync_fs(struct super_block *sb, int wait)
424{ 431{
432 int i, err;
425 struct ubifs_info *c = sb->s_fs_info; 433 struct ubifs_info *c = sb->s_fs_info;
426 int i, ret = 0, err; 434 struct writeback_control wbc = {
427 long long bud_bytes; 435 .sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
428 436 .range_start = 0,
429 if (c->jheads) { 437 .range_end = LLONG_MAX,
430 for (i = 0; i < c->jhead_cnt; i++) { 438 .nr_to_write = LONG_MAX,
431 err = ubifs_wbuf_sync(&c->jheads[i].wbuf); 439 };
432 if (err && !ret) 440
433 ret = err; 441 if (sb->s_flags & MS_RDONLY)
434 } 442 return 0;
435 443
436 /* Commit the journal unless it has too little data */ 444 /*
437 spin_lock(&c->buds_lock); 445 * Synchronize write buffers, because 'ubifs_run_commit()' does not
438 bud_bytes = c->bud_bytes; 446 * do this if it waits for an already running commit.
439 spin_unlock(&c->buds_lock); 447 */
440 if (bud_bytes > c->leb_size) { 448 for (i = 0; i < c->jhead_cnt; i++) {
441 err = ubifs_run_commit(c); 449 err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
442 if (err) 450 if (err)
443 return err; 451 return err;
444 }
445 } 452 }
446 453
447 /* 454 /*
448 * We ought to call sync for c->ubi but it does not have one. If it had 455 * VFS calls '->sync_fs()' before synchronizing all dirty inodes and
449 * it would in turn call mtd->sync, however mtd operations are 456 * pages, so synchronize them first, then commit the journal. Strictly
450 * synchronous anyway, so we don't lose any sleep here. 457 * speaking, it is not necessary to commit the journal here,
458 * synchronizing write-buffers would be enough. But committing makes
459 * UBIFS free space predictions much more accurate, so we want to let
460 * the user be able to get more accurate results of 'statfs()' after
461 * they synchronize the file system.
451 */ 462 */
452 return ret; 463 generic_sync_sb_inodes(sb, &wbc);
464
465 err = ubifs_run_commit(c);
466 if (err)
467 return err;
468
469 return ubi_sync(c->vi.ubi_num);
453} 470}
454 471
455/** 472/**
@@ -596,7 +613,7 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
596} 613}
597 614
598/* 615/*
599 * init_constants_late - initialize UBIFS constants. 616 * init_constants_sb - initialize UBIFS constants.
600 * @c: UBIFS file-system description object 617 * @c: UBIFS file-system description object
601 * 618 *
602 * This is a helper function which initializes various UBIFS constants after 619 * This is a helper function which initializes various UBIFS constants after
@@ -604,10 +621,10 @@ static int bud_wbuf_callback(struct ubifs_info *c, int lnum, int free, int pad)
604 * makes sure they are all right. Returns zero in case of success and a 621 * makes sure they are all right. Returns zero in case of success and a
605 * negative error code in case of failure. 622 * negative error code in case of failure.
606 */ 623 */
607static int init_constants_late(struct ubifs_info *c) 624static int init_constants_sb(struct ubifs_info *c)
608{ 625{
609 int tmp, err; 626 int tmp, err;
610 uint64_t tmp64; 627 long long tmp64;
611 628
612 c->main_bytes = (long long)c->main_lebs * c->leb_size; 629 c->main_bytes = (long long)c->main_lebs * c->leb_size;
613 c->max_znode_sz = sizeof(struct ubifs_znode) + 630 c->max_znode_sz = sizeof(struct ubifs_znode) +
@@ -634,9 +651,8 @@ static int init_constants_late(struct ubifs_info *c)
634 * Make sure that the log is large enough to fit reference nodes for 651 * Make sure that the log is large enough to fit reference nodes for
635 * all buds plus one reserved LEB. 652 * all buds plus one reserved LEB.
636 */ 653 */
637 tmp64 = c->max_bud_bytes; 654 tmp64 = c->max_bud_bytes + c->leb_size - 1;
638 tmp = do_div(tmp64, c->leb_size); 655 c->max_bud_cnt = div_u64(tmp64, c->leb_size);
639 c->max_bud_cnt = tmp64 + !!tmp;
640 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1); 656 tmp = (c->ref_node_alsz * c->max_bud_cnt + c->leb_size - 1);
641 tmp /= c->leb_size; 657 tmp /= c->leb_size;
642 tmp += 1; 658 tmp += 1;
@@ -672,7 +688,7 @@ static int init_constants_late(struct ubifs_info *c)
672 * Consequently, if the journal is too small, UBIFS will treat it as 688 * Consequently, if the journal is too small, UBIFS will treat it as
673 * always full. 689 * always full.
674 */ 690 */
675 tmp64 = (uint64_t)(c->jhead_cnt + 1) * c->leb_size + 1; 691 tmp64 = (long long)(c->jhead_cnt + 1) * c->leb_size + 1;
676 if (c->bg_bud_bytes < tmp64) 692 if (c->bg_bud_bytes < tmp64)
677 c->bg_bud_bytes = tmp64; 693 c->bg_bud_bytes = tmp64;
678 if (c->max_bud_bytes < tmp64 + c->leb_size) 694 if (c->max_bud_bytes < tmp64 + c->leb_size)
@@ -682,6 +698,21 @@ static int init_constants_late(struct ubifs_info *c)
682 if (err) 698 if (err)
683 return err; 699 return err;
684 700
701 return 0;
702}
703
704/*
705 * init_constants_master - initialize UBIFS constants.
706 * @c: UBIFS file-system description object
707 *
708 * This is a helper function which initializes various UBIFS constants after
709 * the master node has been read. It also checks various UBIFS parameters and
710 * makes sure they are all right.
711 */
712static void init_constants_master(struct ubifs_info *c)
713{
714 long long tmp64;
715
685 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c); 716 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c);
686 717
687 /* 718 /*
@@ -690,14 +721,13 @@ static int init_constants_late(struct ubifs_info *c)
690 * necessary to report something for the 'statfs()' call. 721 * necessary to report something for the 'statfs()' call.
691 * 722 *
692 * Subtract the LEB reserved for GC, the LEB which is reserved for 723 * Subtract the LEB reserved for GC, the LEB which is reserved for
693 * deletions, and assume only one journal head is available. 724 * deletions, minimum LEBs for the index, and assume only one journal
725 * head is available.
694 */ 726 */
695 tmp64 = c->main_lebs - 2 - c->jhead_cnt + 1; 727 tmp64 = c->main_lebs - 1 - 1 - MIN_INDEX_LEBS - c->jhead_cnt + 1;
696 tmp64 *= (uint64_t)c->leb_size - c->leb_overhead; 728 tmp64 *= (long long)c->leb_size - c->leb_overhead;
697 tmp64 = ubifs_reported_space(c, tmp64); 729 tmp64 = ubifs_reported_space(c, tmp64);
698 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT; 730 c->block_cnt = tmp64 >> UBIFS_BLOCK_SHIFT;
699
700 return 0;
701} 731}
702 732
703/** 733/**
@@ -878,6 +908,7 @@ static int check_volume_empty(struct ubifs_info *c)
878 * Opt_no_bulk_read: disable bulk-reads 908 * Opt_no_bulk_read: disable bulk-reads
879 * Opt_chk_data_crc: check CRCs when reading data nodes 909 * Opt_chk_data_crc: check CRCs when reading data nodes
880 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes 910 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes
911 * Opt_override_compr: override default compressor
881 * Opt_err: just end of array marker 912 * Opt_err: just end of array marker
882 */ 913 */
883enum { 914enum {
@@ -887,6 +918,7 @@ enum {
887 Opt_no_bulk_read, 918 Opt_no_bulk_read,
888 Opt_chk_data_crc, 919 Opt_chk_data_crc,
889 Opt_no_chk_data_crc, 920 Opt_no_chk_data_crc,
921 Opt_override_compr,
890 Opt_err, 922 Opt_err,
891}; 923};
892 924
@@ -897,6 +929,7 @@ static const match_table_t tokens = {
897 {Opt_no_bulk_read, "no_bulk_read"}, 929 {Opt_no_bulk_read, "no_bulk_read"},
898 {Opt_chk_data_crc, "chk_data_crc"}, 930 {Opt_chk_data_crc, "chk_data_crc"},
899 {Opt_no_chk_data_crc, "no_chk_data_crc"}, 931 {Opt_no_chk_data_crc, "no_chk_data_crc"},
932 {Opt_override_compr, "compr=%s"},
900 {Opt_err, NULL}, 933 {Opt_err, NULL},
901}; 934};
902 935
@@ -950,6 +983,28 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
950 c->mount_opts.chk_data_crc = 1; 983 c->mount_opts.chk_data_crc = 1;
951 c->no_chk_data_crc = 1; 984 c->no_chk_data_crc = 1;
952 break; 985 break;
986 case Opt_override_compr:
987 {
988 char *name = match_strdup(&args[0]);
989
990 if (!name)
991 return -ENOMEM;
992 if (!strcmp(name, "none"))
993 c->mount_opts.compr_type = UBIFS_COMPR_NONE;
994 else if (!strcmp(name, "lzo"))
995 c->mount_opts.compr_type = UBIFS_COMPR_LZO;
996 else if (!strcmp(name, "zlib"))
997 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB;
998 else {
999 ubifs_err("unknown compressor \"%s\"", name);
1000 kfree(name);
1001 return -EINVAL;
1002 }
1003 kfree(name);
1004 c->mount_opts.override_compr = 1;
1005 c->default_compr = c->mount_opts.compr_type;
1006 break;
1007 }
953 default: 1008 default:
954 ubifs_err("unrecognized mount option \"%s\" " 1009 ubifs_err("unrecognized mount option \"%s\" "
955 "or missing value", p); 1010 "or missing value", p);
@@ -1019,6 +1074,30 @@ again:
1019} 1074}
1020 1075
1021/** 1076/**
1077 * check_free_space - check if there is enough free space to mount.
1078 * @c: UBIFS file-system description object
1079 *
1080 * This function makes sure UBIFS has enough free space to be mounted in
1081 * read/write mode. UBIFS must always have some free space to allow deletions.
1082 */
1083static int check_free_space(struct ubifs_info *c)
1084{
1085 ubifs_assert(c->dark_wm > 0);
1086 if (c->lst.total_free + c->lst.total_dirty < c->dark_wm) {
1087 ubifs_err("insufficient free space to mount in read/write mode");
1088 dbg_dump_budg(c);
1089 dbg_dump_lprops(c);
1090 /*
1091 * We return %-EINVAL instead of %-ENOSPC because it seems to
1092 * be the closest error code mentioned in the mount function
1093 * documentation.
1094 */
1095 return -EINVAL;
1096 }
1097 return 0;
1098}
1099
1100/**
1022 * mount_ubifs - mount UBIFS file-system. 1101 * mount_ubifs - mount UBIFS file-system.
1023 * @c: UBIFS file-system description object 1102 * @c: UBIFS file-system description object
1024 * 1103 *
@@ -1039,11 +1118,9 @@ static int mount_ubifs(struct ubifs_info *c)
1039 if (err) 1118 if (err)
1040 return err; 1119 return err;
1041 1120
1042#ifdef CONFIG_UBIFS_FS_DEBUG 1121 err = ubifs_debugging_init(c);
1043 c->dbg_buf = vmalloc(c->leb_size); 1122 if (err)
1044 if (!c->dbg_buf) 1123 return err;
1045 return -ENOMEM;
1046#endif
1047 1124
1048 err = check_volume_empty(c); 1125 err = check_volume_empty(c);
1049 if (err) 1126 if (err)
@@ -1100,27 +1177,25 @@ static int mount_ubifs(struct ubifs_info *c)
1100 goto out_free; 1177 goto out_free;
1101 1178
1102 /* 1179 /*
1103 * Make sure the compressor which is set as the default on in the 1180 * Make sure the compressor which is set as default in the superblock
1104 * superblock was actually compiled in. 1181 * or overridden by mount options is actually compiled in.
1105 */ 1182 */
1106 if (!ubifs_compr_present(c->default_compr)) { 1183 if (!ubifs_compr_present(c->default_compr)) {
1107 ubifs_warn("'%s' compressor is set by superblock, but not " 1184 ubifs_err("'compressor \"%s\" is not compiled in",
1108 "compiled in", ubifs_compr_name(c->default_compr)); 1185 ubifs_compr_name(c->default_compr));
1109 c->default_compr = UBIFS_COMPR_NONE; 1186 goto out_free;
1110 } 1187 }
1111 1188
1112 dbg_failure_mode_registration(c); 1189 err = init_constants_sb(c);
1113
1114 err = init_constants_late(c);
1115 if (err) 1190 if (err)
1116 goto out_dereg; 1191 goto out_free;
1117 1192
1118 sz = ALIGN(c->max_idx_node_sz, c->min_io_size); 1193 sz = ALIGN(c->max_idx_node_sz, c->min_io_size);
1119 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size); 1194 sz = ALIGN(sz + c->max_idx_node_sz, c->min_io_size);
1120 c->cbuf = kmalloc(sz, GFP_NOFS); 1195 c->cbuf = kmalloc(sz, GFP_NOFS);
1121 if (!c->cbuf) { 1196 if (!c->cbuf) {
1122 err = -ENOMEM; 1197 err = -ENOMEM;
1123 goto out_dereg; 1198 goto out_free;
1124 } 1199 }
1125 1200
1126 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id); 1201 sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num, c->vi.vol_id);
@@ -1145,6 +1220,8 @@ static int mount_ubifs(struct ubifs_info *c)
1145 if (err) 1220 if (err)
1146 goto out_master; 1221 goto out_master;
1147 1222
1223 init_constants_master(c);
1224
1148 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) { 1225 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) {
1149 ubifs_msg("recovery needed"); 1226 ubifs_msg("recovery needed");
1150 c->need_recovery = 1; 1227 c->need_recovery = 1;
@@ -1183,12 +1260,9 @@ static int mount_ubifs(struct ubifs_info *c)
1183 if (!mounted_read_only) { 1260 if (!mounted_read_only) {
1184 int lnum; 1261 int lnum;
1185 1262
1186 /* Check for enough free space */ 1263 err = check_free_space(c);
1187 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1264 if (err)
1188 ubifs_err("insufficient available space");
1189 err = -EINVAL;
1190 goto out_orphans; 1265 goto out_orphans;
1191 }
1192 1266
1193 /* Check for enough log space */ 1267 /* Check for enough log space */
1194 lnum = c->lhead_lnum + 1; 1268 lnum = c->lhead_lnum + 1;
@@ -1232,6 +1306,10 @@ static int mount_ubifs(struct ubifs_info *c)
1232 } 1306 }
1233 } 1307 }
1234 1308
1309 err = dbg_debugfs_init_fs(c);
1310 if (err)
1311 goto out_infos;
1312
1235 err = dbg_check_filesystem(c); 1313 err = dbg_check_filesystem(c);
1236 if (err) 1314 if (err)
1237 goto out_infos; 1315 goto out_infos;
@@ -1283,8 +1361,20 @@ static int mount_ubifs(struct ubifs_info *c)
1283 dbg_msg("tree fanout: %d", c->fanout); 1361 dbg_msg("tree fanout: %d", c->fanout);
1284 dbg_msg("reserved GC LEB: %d", c->gc_lnum); 1362 dbg_msg("reserved GC LEB: %d", c->gc_lnum);
1285 dbg_msg("first main LEB: %d", c->main_first); 1363 dbg_msg("first main LEB: %d", c->main_first);
1364 dbg_msg("max. znode size %d", c->max_znode_sz);
1365 dbg_msg("max. index node size %d", c->max_idx_node_sz);
1366 dbg_msg("node sizes: data %zu, inode %zu, dentry %zu",
1367 UBIFS_DATA_NODE_SZ, UBIFS_INO_NODE_SZ, UBIFS_DENT_NODE_SZ);
1368 dbg_msg("node sizes: trun %zu, sb %zu, master %zu",
1369 UBIFS_TRUN_NODE_SZ, UBIFS_SB_NODE_SZ, UBIFS_MST_NODE_SZ);
1370 dbg_msg("node sizes: ref %zu, cmt. start %zu, orph %zu",
1371 UBIFS_REF_NODE_SZ, UBIFS_CS_NODE_SZ, UBIFS_ORPH_NODE_SZ);
1372 dbg_msg("max. node sizes: data %zu, inode %zu dentry %zu",
1373 UBIFS_MAX_DATA_NODE_SZ, UBIFS_MAX_INO_NODE_SZ,
1374 UBIFS_MAX_DENT_NODE_SZ);
1286 dbg_msg("dead watermark: %d", c->dead_wm); 1375 dbg_msg("dead watermark: %d", c->dead_wm);
1287 dbg_msg("dark watermark: %d", c->dark_wm); 1376 dbg_msg("dark watermark: %d", c->dark_wm);
1377 dbg_msg("LEB overhead: %d", c->leb_overhead);
1288 x = (long long)c->main_lebs * c->dark_wm; 1378 x = (long long)c->main_lebs * c->dark_wm;
1289 dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)", 1379 dbg_msg("max. dark space: %lld (%lld KiB, %lld MiB)",
1290 x, x >> 10, x >> 20); 1380 x, x >> 10, x >> 20);
@@ -1320,14 +1410,12 @@ out_wbufs:
1320 free_wbufs(c); 1410 free_wbufs(c);
1321out_cbuf: 1411out_cbuf:
1322 kfree(c->cbuf); 1412 kfree(c->cbuf);
1323out_dereg:
1324 dbg_failure_mode_deregistration(c);
1325out_free: 1413out_free:
1326 kfree(c->bu.buf); 1414 kfree(c->bu.buf);
1327 vfree(c->ileb_buf); 1415 vfree(c->ileb_buf);
1328 vfree(c->sbuf); 1416 vfree(c->sbuf);
1329 kfree(c->bottom_up_buf); 1417 kfree(c->bottom_up_buf);
1330 UBIFS_DBG(vfree(c->dbg_buf)); 1418 ubifs_debugging_exit(c);
1331 return err; 1419 return err;
1332} 1420}
1333 1421
@@ -1345,6 +1433,7 @@ static void ubifs_umount(struct ubifs_info *c)
1345 dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num, 1433 dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num,
1346 c->vi.vol_id); 1434 c->vi.vol_id);
1347 1435
1436 dbg_debugfs_exit_fs(c);
1348 spin_lock(&ubifs_infos_lock); 1437 spin_lock(&ubifs_infos_lock);
1349 list_del(&c->infos_list); 1438 list_del(&c->infos_list);
1350 spin_unlock(&ubifs_infos_lock); 1439 spin_unlock(&ubifs_infos_lock);
@@ -1364,8 +1453,7 @@ static void ubifs_umount(struct ubifs_info *c)
1364 vfree(c->ileb_buf); 1453 vfree(c->ileb_buf);
1365 vfree(c->sbuf); 1454 vfree(c->sbuf);
1366 kfree(c->bottom_up_buf); 1455 kfree(c->bottom_up_buf);
1367 UBIFS_DBG(vfree(c->dbg_buf)); 1456 ubifs_debugging_exit(c);
1368 dbg_failure_mode_deregistration(c);
1369} 1457}
1370 1458
1371/** 1459/**
@@ -1387,12 +1475,9 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1387 c->remounting_rw = 1; 1475 c->remounting_rw = 1;
1388 c->always_chk_crc = 1; 1476 c->always_chk_crc = 1;
1389 1477
1390 /* Check for enough free space */ 1478 err = check_free_space(c);
1391 if (ubifs_calc_available(c, c->min_idx_lebs) <= 0) { 1479 if (err)
1392 ubifs_err("insufficient available space");
1393 err = -EINVAL;
1394 goto out; 1480 goto out;
1395 }
1396 1481
1397 if (c->old_leb_cnt != c->leb_cnt) { 1482 if (c->old_leb_cnt != c->leb_cnt) {
1398 struct ubifs_sb_node *sup; 1483 struct ubifs_sb_node *sup;
@@ -1515,20 +1600,24 @@ out:
1515 * @c: UBIFS file-system description object 1600 * @c: UBIFS file-system description object
1516 * 1601 *
1517 * This function is called during un-mounting and re-mounting, and it commits 1602 * This function is called during un-mounting and re-mounting, and it commits
1518 * the journal unless the "fast unmount" mode is enabled. It also avoids 1603 * the journal unless the "fast unmount" mode is enabled.
1519 * committing the journal if it contains too few data.
1520 */ 1604 */
1521static void commit_on_unmount(struct ubifs_info *c) 1605static void commit_on_unmount(struct ubifs_info *c)
1522{ 1606{
1523 if (!c->fast_unmount) { 1607 struct super_block *sb = c->vfs_sb;
1524 long long bud_bytes; 1608 long long bud_bytes;
1525 1609
1526 spin_lock(&c->buds_lock); 1610 /*
1527 bud_bytes = c->bud_bytes; 1611 * This function is called before the background thread is stopped, so
1528 spin_unlock(&c->buds_lock); 1612 * we may race with ongoing commit, which means we have to take
1529 if (bud_bytes > c->leb_size) 1613 * @c->bud_lock to access @c->bud_bytes.
1530 ubifs_run_commit(c); 1614 */
1531 } 1615 spin_lock(&c->buds_lock);
1616 bud_bytes = c->bud_bytes;
1617 spin_unlock(&c->buds_lock);
1618
1619 if (!c->fast_unmount && !(sb->s_flags & MS_RDONLY) && bud_bytes)
1620 ubifs_run_commit(c);
1532} 1621}
1533 1622
1534/** 1623/**
@@ -1849,7 +1938,6 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
1849 goto out_iput; 1938 goto out_iput;
1850 1939
1851 mutex_unlock(&c->umount_mutex); 1940 mutex_unlock(&c->umount_mutex);
1852
1853 return 0; 1941 return 0;
1854 1942
1855out_iput: 1943out_iput:
@@ -1955,7 +2043,7 @@ static void ubifs_kill_sb(struct super_block *sb)
1955 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' 2043 * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()'
1956 * in order to be outside BKL. 2044 * in order to be outside BKL.
1957 */ 2045 */
1958 if (sb->s_root && !(sb->s_flags & MS_RDONLY)) 2046 if (sb->s_root)
1959 commit_on_unmount(c); 2047 commit_on_unmount(c);
1960 /* The un-mount routine is actually done in put_super() */ 2048 /* The un-mount routine is actually done in put_super() */
1961 generic_shutdown_super(sb); 2049 generic_shutdown_super(sb);
@@ -2021,6 +2109,14 @@ static int __init ubifs_init(void)
2021 BUILD_BUG_ON(UBIFS_REF_NODE_SZ != 64); 2109 BUILD_BUG_ON(UBIFS_REF_NODE_SZ != 64);
2022 2110
2023 /* 2111 /*
2112 * We use 2 bit wide bit-fields to store compression type, which should
2113 * be amended if more compressors are added. The bit-fields are:
2114 * @compr_type in 'struct ubifs_inode', @default_compr in
2115 * 'struct ubifs_info' and @compr_type in 'struct ubifs_mount_opts'.
2116 */
2117 BUILD_BUG_ON(UBIFS_COMPR_TYPES_CNT > 4);
2118
2119 /*
2024 * We require that PAGE_CACHE_SIZE is greater-than-or-equal-to 2120 * We require that PAGE_CACHE_SIZE is greater-than-or-equal-to
2025 * UBIFS_BLOCK_SIZE. It is assumed that both are powers of 2. 2121 * UBIFS_BLOCK_SIZE. It is assumed that both are powers of 2.
2026 */ 2122 */
@@ -2049,11 +2145,17 @@ static int __init ubifs_init(void)
2049 2145
2050 err = ubifs_compressors_init(); 2146 err = ubifs_compressors_init();
2051 if (err) 2147 if (err)
2148 goto out_shrinker;
2149
2150 err = dbg_debugfs_init();
2151 if (err)
2052 goto out_compr; 2152 goto out_compr;
2053 2153
2054 return 0; 2154 return 0;
2055 2155
2056out_compr: 2156out_compr:
2157 ubifs_compressors_exit();
2158out_shrinker:
2057 unregister_shrinker(&ubifs_shrinker_info); 2159 unregister_shrinker(&ubifs_shrinker_info);
2058 kmem_cache_destroy(ubifs_inode_slab); 2160 kmem_cache_destroy(ubifs_inode_slab);
2059out_reg: 2161out_reg:
@@ -2068,6 +2170,7 @@ static void __exit ubifs_exit(void)
2068 ubifs_assert(list_empty(&ubifs_infos)); 2170 ubifs_assert(list_empty(&ubifs_infos));
2069 ubifs_assert(atomic_long_read(&ubifs_clean_zn_cnt) == 0); 2171 ubifs_assert(atomic_long_read(&ubifs_clean_zn_cnt) == 0);
2070 2172
2173 dbg_debugfs_exit();
2071 ubifs_compressors_exit(); 2174 ubifs_compressors_exit();
2072 unregister_shrinker(&ubifs_shrinker_info); 2175 unregister_shrinker(&ubifs_shrinker_info);
2073 kmem_cache_destroy(ubifs_inode_slab); 2176 kmem_cache_destroy(ubifs_inode_slab);
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 6eef5344a145..f7e36f545527 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -2245,12 +2245,11 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key,
2245 if (found) { 2245 if (found) {
2246 /* Ensure the znode is dirtied */ 2246 /* Ensure the znode is dirtied */
2247 if (znode->cnext || !ubifs_zn_dirty(znode)) { 2247 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2248 znode = dirty_cow_bottom_up(c, 2248 znode = dirty_cow_bottom_up(c, znode);
2249 znode); 2249 if (IS_ERR(znode)) {
2250 if (IS_ERR(znode)) { 2250 err = PTR_ERR(znode);
2251 err = PTR_ERR(znode); 2251 goto out_unlock;
2252 goto out_unlock; 2252 }
2253 }
2254 } 2253 }
2255 zbr = &znode->zbranch[n]; 2254 zbr = &znode->zbranch[n];
2256 lnc_free(zbr); 2255 lnc_free(zbr);
@@ -2317,11 +2316,11 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key,
2317 2316
2318 /* Ensure the znode is dirtied */ 2317 /* Ensure the znode is dirtied */
2319 if (znode->cnext || !ubifs_zn_dirty(znode)) { 2318 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2320 znode = dirty_cow_bottom_up(c, znode); 2319 znode = dirty_cow_bottom_up(c, znode);
2321 if (IS_ERR(znode)) { 2320 if (IS_ERR(znode)) {
2322 err = PTR_ERR(znode); 2321 err = PTR_ERR(znode);
2323 goto out_unlock; 2322 goto out_unlock;
2324 } 2323 }
2325 } 2324 }
2326 2325
2327 if (found == 1) { 2326 if (found == 1) {
@@ -2627,11 +2626,11 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key,
2627 2626
2628 /* Ensure the znode is dirtied */ 2627 /* Ensure the znode is dirtied */
2629 if (znode->cnext || !ubifs_zn_dirty(znode)) { 2628 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2630 znode = dirty_cow_bottom_up(c, znode); 2629 znode = dirty_cow_bottom_up(c, znode);
2631 if (IS_ERR(znode)) { 2630 if (IS_ERR(znode)) {
2632 err = PTR_ERR(znode); 2631 err = PTR_ERR(znode);
2633 goto out_unlock; 2632 goto out_unlock;
2634 } 2633 }
2635 } 2634 }
2636 2635
2637 /* Remove all keys in range except the first */ 2636 /* Remove all keys in range except the first */
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 8ac76b1c2d55..fde8d127c768 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -553,8 +553,8 @@ static int layout_in_empty_space(struct ubifs_info *c)
553 } 553 }
554 554
555#ifdef CONFIG_UBIFS_FS_DEBUG 555#ifdef CONFIG_UBIFS_FS_DEBUG
556 c->new_ihead_lnum = lnum; 556 c->dbg->new_ihead_lnum = lnum;
557 c->new_ihead_offs = buf_offs; 557 c->dbg->new_ihead_offs = buf_offs;
558#endif 558#endif
559 559
560 return 0; 560 return 0;
@@ -802,8 +802,10 @@ int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot)
802 * budgeting subsystem to assume the index is already committed, 802 * budgeting subsystem to assume the index is already committed,
803 * even though it is not. 803 * even though it is not.
804 */ 804 */
805 ubifs_assert(c->min_idx_lebs == ubifs_calc_min_idx_lebs(c));
805 c->old_idx_sz = c->calc_idx_sz; 806 c->old_idx_sz = c->calc_idx_sz;
806 c->budg_uncommitted_idx = 0; 807 c->budg_uncommitted_idx = 0;
808 c->min_idx_lebs = ubifs_calc_min_idx_lebs(c);
807 spin_unlock(&c->space_lock); 809 spin_unlock(&c->space_lock);
808 mutex_unlock(&c->tnc_mutex); 810 mutex_unlock(&c->tnc_mutex);
809 811
@@ -1002,7 +1004,8 @@ static int write_index(struct ubifs_info *c)
1002 } 1004 }
1003 1005
1004#ifdef CONFIG_UBIFS_FS_DEBUG 1006#ifdef CONFIG_UBIFS_FS_DEBUG
1005 if (lnum != c->new_ihead_lnum || buf_offs != c->new_ihead_offs) { 1007 if (lnum != c->dbg->new_ihead_lnum ||
1008 buf_offs != c->dbg->new_ihead_offs) {
1006 ubifs_err("inconsistent ihead"); 1009 ubifs_err("inconsistent ihead");
1007 return -EINVAL; 1010 return -EINVAL;
1008 } 1011 }
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h
index 0b378042a3a2..b25fc36cf72f 100644
--- a/fs/ubifs/ubifs-media.h
+++ b/fs/ubifs/ubifs-media.h
@@ -51,6 +51,13 @@
51 */ 51 */
52#define UBIFS_MIN_COMPR_LEN 128 52#define UBIFS_MIN_COMPR_LEN 128
53 53
54/*
55 * If compressed data length is less than %UBIFS_MIN_COMPRESS_DIFF bytes
56 * shorter than uncompressed data length, UBIFS preferes to leave this data
57 * node uncompress, because it'll be read faster.
58 */
59#define UBIFS_MIN_COMPRESS_DIFF 64
60
54/* Root inode number */ 61/* Root inode number */
55#define UBIFS_ROOT_INO 1 62#define UBIFS_ROOT_INO 1
56 63
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 46b172560a06..fc2a4cc66d03 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -63,6 +63,14 @@
63#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL 63#define SQNUM_WARN_WATERMARK 0xFFFFFFFF00000000ULL
64#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL 64#define SQNUM_WATERMARK 0xFFFFFFFFFF000000ULL
65 65
66/*
67 * Minimum amount of LEBs reserved for the index. At present the index needs at
68 * least 2 LEBs: one for the index head and one for in-the-gaps method (which
69 * currently does not cater for the index head and so excludes it from
70 * consideration).
71 */
72#define MIN_INDEX_LEBS 2
73
66/* Minimum amount of data UBIFS writes to the flash */ 74/* Minimum amount of data UBIFS writes to the flash */
67#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8) 75#define MIN_WRITE_SZ (UBIFS_DATA_NODE_SZ + 8)
68 76
@@ -386,12 +394,12 @@ struct ubifs_inode {
386 unsigned int dirty:1; 394 unsigned int dirty:1;
387 unsigned int xattr:1; 395 unsigned int xattr:1;
388 unsigned int bulk_read:1; 396 unsigned int bulk_read:1;
397 unsigned int compr_type:2;
389 struct mutex ui_mutex; 398 struct mutex ui_mutex;
390 spinlock_t ui_lock; 399 spinlock_t ui_lock;
391 loff_t synced_i_size; 400 loff_t synced_i_size;
392 loff_t ui_size; 401 loff_t ui_size;
393 int flags; 402 int flags;
394 int compr_type;
395 pgoff_t last_page_read; 403 pgoff_t last_page_read;
396 pgoff_t read_in_a_row; 404 pgoff_t read_in_a_row;
397 int data_len; 405 int data_len;
@@ -419,7 +427,7 @@ struct ubifs_unclean_leb {
419 * 427 *
420 * LPROPS_UNCAT: not categorized 428 * LPROPS_UNCAT: not categorized
421 * LPROPS_DIRTY: dirty > 0, not index 429 * LPROPS_DIRTY: dirty > 0, not index
422 * LPROPS_DIRTY_IDX: dirty + free > UBIFS_CH_SZ and index 430 * LPROPS_DIRTY_IDX: dirty + free > @c->min_idx_node_sze and index
423 * LPROPS_FREE: free > 0, not empty, not index 431 * LPROPS_FREE: free > 0, not empty, not index
424 * LPROPS_HEAP_CNT: number of heaps used for storing categorized LEBs 432 * LPROPS_HEAP_CNT: number of heaps used for storing categorized LEBs
425 * LPROPS_EMPTY: LEB is empty, not taken 433 * LPROPS_EMPTY: LEB is empty, not taken
@@ -473,8 +481,8 @@ struct ubifs_lprops {
473struct ubifs_lpt_lprops { 481struct ubifs_lpt_lprops {
474 int free; 482 int free;
475 int dirty; 483 int dirty;
476 unsigned tgc : 1; 484 unsigned tgc:1;
477 unsigned cmt : 1; 485 unsigned cmt:1;
478}; 486};
479 487
480/** 488/**
@@ -482,24 +490,26 @@ struct ubifs_lpt_lprops {
482 * @empty_lebs: number of empty LEBs 490 * @empty_lebs: number of empty LEBs
483 * @taken_empty_lebs: number of taken LEBs 491 * @taken_empty_lebs: number of taken LEBs
484 * @idx_lebs: number of indexing LEBs 492 * @idx_lebs: number of indexing LEBs
485 * @total_free: total free space in bytes 493 * @total_free: total free space in bytes (includes all LEBs)
486 * @total_dirty: total dirty space in bytes 494 * @total_dirty: total dirty space in bytes (includes all LEBs)
487 * @total_used: total used space in bytes (includes only data LEBs) 495 * @total_used: total used space in bytes (does not include index LEBs)
488 * @total_dead: total dead space in bytes (includes only data LEBs) 496 * @total_dead: total dead space in bytes (does not include index LEBs)
489 * @total_dark: total dark space in bytes (includes only data LEBs) 497 * @total_dark: total dark space in bytes (does not include index LEBs)
498 *
499 * The @taken_empty_lebs field counts the LEBs that are in the transient state
500 * of having been "taken" for use but not yet written to. @taken_empty_lebs is
501 * needed to account correctly for @gc_lnum, otherwise @empty_lebs could be
502 * used by itself (in which case 'unused_lebs' would be a better name). In the
503 * case of @gc_lnum, it is "taken" at mount time or whenever a LEB is retained
504 * by GC, but unlike other empty LEBs that are "taken", it may not be written
505 * straight away (i.e. before the next commit start or unmount), so either
506 * @gc_lnum must be specially accounted for, or the current approach followed
507 * i.e. count it under @taken_empty_lebs.
490 * 508 *
491 * N.B. total_dirty and total_used are different to other total_* fields, 509 * @empty_lebs includes @taken_empty_lebs.
492 * because they account _all_ LEBs, not just data LEBs.
493 * 510 *
494 * 'taken_empty_lebs' counts the LEBs that are in the transient state of having 511 * @total_used, @total_dead and @total_dark fields do not account indexing
495 * been 'taken' for use but not yet written to. 'taken_empty_lebs' is needed 512 * LEBs.
496 * to account correctly for gc_lnum, otherwise 'empty_lebs' could be used
497 * by itself (in which case 'unused_lebs' would be a better name). In the case
498 * of gc_lnum, it is 'taken' at mount time or whenever a LEB is retained by GC,
499 * but unlike other empty LEBs that are 'taken', it may not be written straight
500 * away (i.e. before the next commit start or unmount), so either gc_lnum must
501 * be specially accounted for, or the current approach followed i.e. count it
502 * under 'taken_empty_lebs'.
503 */ 513 */
504struct ubifs_lp_stats { 514struct ubifs_lp_stats {
505 int empty_lebs; 515 int empty_lebs;
@@ -893,15 +903,25 @@ struct ubifs_orphan {
893/** 903/**
894 * struct ubifs_mount_opts - UBIFS-specific mount options information. 904 * struct ubifs_mount_opts - UBIFS-specific mount options information.
895 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast) 905 * @unmount_mode: selected unmount mode (%0 default, %1 normal, %2 fast)
896 * @bulk_read: enable bulk-reads 906 * @bulk_read: enable/disable bulk-reads (%0 default, %1 disabe, %2 enable)
897 * @chk_data_crc: check CRCs when reading data nodes 907 * @chk_data_crc: enable/disable CRC data checking when reading data nodes
908 * (%0 default, %1 disabe, %2 enable)
909 * @override_compr: override default compressor (%0 - do not override and use
910 * superblock compressor, %1 - override and use compressor
911 * specified in @compr_type)
912 * @compr_type: compressor type to override the superblock compressor with
913 * (%UBIFS_COMPR_NONE, etc)
898 */ 914 */
899struct ubifs_mount_opts { 915struct ubifs_mount_opts {
900 unsigned int unmount_mode:2; 916 unsigned int unmount_mode:2;
901 unsigned int bulk_read:2; 917 unsigned int bulk_read:2;
902 unsigned int chk_data_crc:2; 918 unsigned int chk_data_crc:2;
919 unsigned int override_compr:1;
920 unsigned int compr_type:2;
903}; 921};
904 922
923struct ubifs_debug_info;
924
905/** 925/**
906 * struct ubifs_info - UBIFS file-system description data structure 926 * struct ubifs_info - UBIFS file-system description data structure
907 * (per-superblock). 927 * (per-superblock).
@@ -946,6 +966,7 @@ struct ubifs_mount_opts {
946 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during 966 * @no_chk_data_crc: do not check CRCs when reading data nodes (except during
947 * recovery) 967 * recovery)
948 * @bulk_read: enable bulk-reads 968 * @bulk_read: enable bulk-reads
969 * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc)
949 * 970 *
950 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and 971 * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and
951 * @calc_idx_sz 972 * @calc_idx_sz
@@ -963,8 +984,6 @@ struct ubifs_mount_opts {
963 * @ileb_nxt: next pre-allocated index LEBs 984 * @ileb_nxt: next pre-allocated index LEBs
964 * @old_idx: tree of index nodes obsoleted since the last commit start 985 * @old_idx: tree of index nodes obsoleted since the last commit start
965 * @bottom_up_buf: a buffer which is used by 'dirty_cow_bottom_up()' in tnc.c 986 * @bottom_up_buf: a buffer which is used by 'dirty_cow_bottom_up()' in tnc.c
966 * @new_ihead_lnum: used by debugging to check ihead_lnum
967 * @new_ihead_offs: used by debugging to check ihead_offs
968 * 987 *
969 * @mst_node: master node 988 * @mst_node: master node
970 * @mst_offs: offset of valid master node 989 * @mst_offs: offset of valid master node
@@ -986,7 +1005,6 @@ struct ubifs_mount_opts {
986 * @main_lebs: count of LEBs in the main area 1005 * @main_lebs: count of LEBs in the main area
987 * @main_first: first LEB of the main area 1006 * @main_first: first LEB of the main area
988 * @main_bytes: main area size in bytes 1007 * @main_bytes: main area size in bytes
989 * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc)
990 * 1008 *
991 * @key_hash_type: type of the key hash 1009 * @key_hash_type: type of the key hash
992 * @key_hash: direntry key hash function 1010 * @key_hash: direntry key hash function
@@ -1149,15 +1167,7 @@ struct ubifs_mount_opts {
1149 * @always_chk_crc: always check CRCs (while mounting and remounting rw) 1167 * @always_chk_crc: always check CRCs (while mounting and remounting rw)
1150 * @mount_opts: UBIFS-specific mount options 1168 * @mount_opts: UBIFS-specific mount options
1151 * 1169 *
1152 * @dbg_buf: a buffer of LEB size used for debugging purposes 1170 * @dbg: debugging-related information
1153 * @old_zroot: old index root - used by 'dbg_check_old_index()'
1154 * @old_zroot_level: old index root level - used by 'dbg_check_old_index()'
1155 * @old_zroot_sqnum: old index root sqnum - used by 'dbg_check_old_index()'
1156 * @failure_mode: failure mode for recovery testing
1157 * @fail_delay: 0=>don't delay, 1=>delay a time, 2=>delay a number of calls
1158 * @fail_timeout: time in jiffies when delay of failure mode expires
1159 * @fail_cnt: current number of calls to failure mode I/O functions
1160 * @fail_cnt_max: number of calls by which to delay failure mode
1161 */ 1171 */
1162struct ubifs_info { 1172struct ubifs_info {
1163 struct super_block *vfs_sb; 1173 struct super_block *vfs_sb;
@@ -1196,6 +1206,7 @@ struct ubifs_info {
1196 unsigned int big_lpt:1; 1206 unsigned int big_lpt:1;
1197 unsigned int no_chk_data_crc:1; 1207 unsigned int no_chk_data_crc:1;
1198 unsigned int bulk_read:1; 1208 unsigned int bulk_read:1;
1209 unsigned int default_compr:2;
1199 1210
1200 struct mutex tnc_mutex; 1211 struct mutex tnc_mutex;
1201 struct ubifs_zbranch zroot; 1212 struct ubifs_zbranch zroot;
@@ -1212,10 +1223,6 @@ struct ubifs_info {
1212 int ileb_nxt; 1223 int ileb_nxt;
1213 struct rb_root old_idx; 1224 struct rb_root old_idx;
1214 int *bottom_up_buf; 1225 int *bottom_up_buf;
1215#ifdef CONFIG_UBIFS_FS_DEBUG
1216 int new_ihead_lnum;
1217 int new_ihead_offs;
1218#endif
1219 1226
1220 struct ubifs_mst_node *mst_node; 1227 struct ubifs_mst_node *mst_node;
1221 int mst_offs; 1228 int mst_offs;
@@ -1237,7 +1244,6 @@ struct ubifs_info {
1237 int main_lebs; 1244 int main_lebs;
1238 int main_first; 1245 int main_first;
1239 long long main_bytes; 1246 long long main_bytes;
1240 int default_compr;
1241 1247
1242 uint8_t key_hash_type; 1248 uint8_t key_hash_type;
1243 uint32_t (*key_hash)(const char *str, int len); 1249 uint32_t (*key_hash)(const char *str, int len);
@@ -1315,8 +1321,8 @@ struct ubifs_info {
1315 void *sbuf; 1321 void *sbuf;
1316 struct list_head idx_gc; 1322 struct list_head idx_gc;
1317 int idx_gc_cnt; 1323 int idx_gc_cnt;
1318 volatile int gc_seq; 1324 int gc_seq;
1319 volatile int gced_lnum; 1325 int gced_lnum;
1320 1326
1321 struct list_head infos_list; 1327 struct list_head infos_list;
1322 struct mutex umount_mutex; 1328 struct mutex umount_mutex;
@@ -1391,21 +1397,7 @@ struct ubifs_info {
1391 struct ubifs_mount_opts mount_opts; 1397 struct ubifs_mount_opts mount_opts;
1392 1398
1393#ifdef CONFIG_UBIFS_FS_DEBUG 1399#ifdef CONFIG_UBIFS_FS_DEBUG
1394 void *dbg_buf; 1400 struct ubifs_debug_info *dbg;
1395 struct ubifs_zbranch old_zroot;
1396 int old_zroot_level;
1397 unsigned long long old_zroot_sqnum;
1398 int failure_mode;
1399 int fail_delay;
1400 unsigned long fail_timeout;
1401 unsigned int fail_cnt;
1402 unsigned int fail_cnt_max;
1403 long long chk_lpt_sz;
1404 long long chk_lpt_sz2;
1405 long long chk_lpt_wastage;
1406 int chk_lpt_lebs;
1407 int new_nhead_lnum;
1408 int new_nhead_offs;
1409#endif 1401#endif
1410}; 1402};
1411 1403
@@ -1505,7 +1497,7 @@ void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode,
1505long long ubifs_get_free_space(struct ubifs_info *c); 1497long long ubifs_get_free_space(struct ubifs_info *c);
1506int ubifs_calc_min_idx_lebs(struct ubifs_info *c); 1498int ubifs_calc_min_idx_lebs(struct ubifs_info *c);
1507void ubifs_convert_page_budget(struct ubifs_info *c); 1499void ubifs_convert_page_budget(struct ubifs_info *c);
1508long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free); 1500long long ubifs_reported_space(const struct ubifs_info *c, long long free);
1509long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs); 1501long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs);
1510 1502
1511/* find.c */ 1503/* find.c */
@@ -1639,6 +1631,9 @@ void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty);
1639void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); 1631void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode);
1640uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits); 1632uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits);
1641struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght); 1633struct ubifs_nnode *ubifs_first_nnode(struct ubifs_info *c, int *hght);
1634/* Needed only in debugging code in lpt_commit.c */
1635int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf,
1636 struct ubifs_nnode *nnode);
1642 1637
1643/* lpt_commit.c */ 1638/* lpt_commit.c */
1644int ubifs_lpt_start_commit(struct ubifs_info *c); 1639int ubifs_lpt_start_commit(struct ubifs_info *c);
@@ -1714,7 +1709,7 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1714 1709
1715/* compressor.c */ 1710/* compressor.c */
1716int __init ubifs_compressors_init(void); 1711int __init ubifs_compressors_init(void);
1717void __exit ubifs_compressors_exit(void); 1712void ubifs_compressors_exit(void);
1718void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, 1713void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len,
1719 int *compr_type); 1714 int *compr_type);
1720int ubifs_decompress(const void *buf, int len, void *out, int *out_len, 1715int ubifs_decompress(const void *buf, int len, void *out, int *out_len,
diff --git a/fs/xattr.c b/fs/xattr.c
index 468377e66531..237804cd6b56 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -175,7 +175,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size)
175 if (error) 175 if (error)
176 return error; 176 return error;
177 error = -EOPNOTSUPP; 177 error = -EOPNOTSUPP;
178 if (d->d_inode->i_op && d->d_inode->i_op->listxattr) { 178 if (d->d_inode->i_op->listxattr) {
179 error = d->d_inode->i_op->listxattr(d, list, size); 179 error = d->d_inode->i_op->listxattr(d, list, size);
180 } else { 180 } else {
181 error = security_inode_listsecurity(d->d_inode, list, size); 181 error = security_inode_listsecurity(d->d_inode, list, size);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 3795590e152a..0574add2a1e3 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -127,7 +127,7 @@ struct acpi_processor_performance {
127 unsigned int state_count; 127 unsigned int state_count;
128 struct acpi_processor_px *states; 128 struct acpi_processor_px *states;
129 struct acpi_psd_package domain_info; 129 struct acpi_psd_package domain_info;
130 cpumask_t shared_cpu_map; 130 cpumask_var_t shared_cpu_map;
131 unsigned int shared_type; 131 unsigned int shared_type;
132}; 132};
133 133
@@ -172,7 +172,7 @@ struct acpi_processor_throttling {
172 unsigned int state_count; 172 unsigned int state_count;
173 struct acpi_processor_tx_tss *states_tss; 173 struct acpi_processor_tx_tss *states_tss;
174 struct acpi_tsd_package domain_info; 174 struct acpi_tsd_package domain_info;
175 cpumask_t shared_cpu_map; 175 cpumask_var_t shared_cpu_map;
176 int (*acpi_processor_get_throttling) (struct acpi_processor * pr); 176 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
177 int (*acpi_processor_set_throttling) (struct acpi_processor * pr, 177 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
178 int state); 178 int state);
diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h
index 39456ba0ec17..287f6f697ce2 100644
--- a/include/asm-frv/bitops.h
+++ b/include/asm-frv/bitops.h
@@ -339,6 +339,19 @@ int __ffs(unsigned long x)
339 return 31 - bit; 339 return 31 - bit;
340} 340}
341 341
342/**
343 * __fls - find last (most-significant) set bit in a long word
344 * @word: the word to search
345 *
346 * Undefined if no set bit exists, so code should check against 0 first.
347 */
348static inline unsigned long __fls(unsigned long word)
349{
350 unsigned long bit;
351 asm("scan %1,gr0,%0" : "=r"(bit) : "r"(word));
352 return bit;
353}
354
342/* 355/*
343 * special slimline version of fls() for calculating ilog2_u32() 356 * special slimline version of fls() for calculating ilog2_u32()
344 * - note: no protection against n == 0 357 * - note: no protection against n == 0
diff --git a/include/asm-m32r/bitops.h b/include/asm-m32r/bitops.h
index 6dc9b81bf9f3..aaddf0d57603 100644
--- a/include/asm-m32r/bitops.h
+++ b/include/asm-m32r/bitops.h
@@ -251,6 +251,7 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr)
251#include <asm-generic/bitops/ffz.h> 251#include <asm-generic/bitops/ffz.h>
252#include <asm-generic/bitops/__ffs.h> 252#include <asm-generic/bitops/__ffs.h>
253#include <asm-generic/bitops/fls.h> 253#include <asm-generic/bitops/fls.h>
254#include <asm-generic/bitops/__fls.h>
254#include <asm-generic/bitops/fls64.h> 255#include <asm-generic/bitops/fls64.h>
255 256
256#ifdef __KERNEL__ 257#ifdef __KERNEL__
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 3e8106442d5a..9bde784e7bad 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -315,6 +315,11 @@ static inline int fls(int x)
315 return 32 - cnt; 315 return 32 - cnt;
316} 316}
317 317
318static inline int __fls(int x)
319{
320 return fls(x) - 1;
321}
322
318#include <asm-generic/bitops/fls64.h> 323#include <asm-generic/bitops/fls64.h>
319#include <asm-generic/bitops/sched.h> 324#include <asm-generic/bitops/sched.h>
320#include <asm-generic/bitops/hweight.h> 325#include <asm-generic/bitops/hweight.h>
diff --git a/include/asm-mn10300/bitops.h b/include/asm-mn10300/bitops.h
index cc6d40c05cf3..0b610f482abb 100644
--- a/include/asm-mn10300/bitops.h
+++ b/include/asm-mn10300/bitops.h
@@ -196,6 +196,17 @@ int fls(int x)
196} 196}
197 197
198/** 198/**
199 * __fls - find last (most-significant) set bit in a long word
200 * @word: the word to search
201 *
202 * Undefined if no set bit exists, so code should check against 0 first.
203 */
204static inline unsigned long __fls(unsigned long word)
205{
206 return __ilog2_u32(word);
207}
208
209/**
199 * ffs - find first bit set 210 * ffs - find first bit set
200 * @x: the word to search 211 * @x: the word to search
201 * 212 *
diff --git a/include/asm-xtensa/bitops.h b/include/asm-xtensa/bitops.h
index 23261e8f2e5a..6c3930397bd3 100644
--- a/include/asm-xtensa/bitops.h
+++ b/include/asm-xtensa/bitops.h
@@ -82,6 +82,16 @@ static inline int fls (unsigned int x)
82 return 32 - __cntlz(x); 82 return 32 - __cntlz(x);
83} 83}
84 84
85/**
86 * __fls - find last (most-significant) set bit in a long word
87 * @word: the word to search
88 *
89 * Undefined if no set bit exists, so code should check against 0 first.
90 */
91static inline unsigned long __fls(unsigned long word)
92{
93 return 31 - __cntlz(word);
94}
85#else 95#else
86 96
87/* Use the generic implementation if we don't have the nsa/nsau instructions. */ 97/* Use the generic implementation if we don't have the nsa/nsau instructions. */
@@ -90,6 +100,7 @@ static inline int fls (unsigned int x)
90# include <asm-generic/bitops/__ffs.h> 100# include <asm-generic/bitops/__ffs.h>
91# include <asm-generic/bitops/ffz.h> 101# include <asm-generic/bitops/ffz.h>
92# include <asm-generic/bitops/fls.h> 102# include <asm-generic/bitops/fls.h>
103# include <asm-generic/bitops/__fls.h>
93 104
94#endif 105#endif
95 106
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 95ac82340c3b..39da666067b9 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -56,8 +56,6 @@ header-y += dlm_device.h
56header-y += dlm_netlink.h 56header-y += dlm_netlink.h
57header-y += dm-ioctl.h 57header-y += dm-ioctl.h
58header-y += dn.h 58header-y += dn.h
59header-y += dqblk_v1.h
60header-y += dqblk_v2.h
61header-y += dqblk_xfs.h 59header-y += dqblk_xfs.h
62header-y += efs_fs_sb.h 60header-y += efs_fs_sb.h
63header-y += elf-fdpic.h 61header-y += elf-fdpic.h
@@ -134,8 +132,6 @@ header-y += posix_types.h
134header-y += ppdev.h 132header-y += ppdev.h
135header-y += prctl.h 133header-y += prctl.h
136header-y += qnxtypes.h 134header-y += qnxtypes.h
137header-y += quotaio_v1.h
138header-y += quotaio_v2.h
139header-y += radeonfb.h 135header-y += radeonfb.h
140header-y += raw.h 136header-y += raw.h
141header-y += resource.h 137header-y += resource.h
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 26c4f6f65a46..67e5dbfc2961 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -247,6 +247,18 @@
247#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL) 247#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL)
248#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK) 248#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK)
249 249
250enum {
251 Audit_equal,
252 Audit_not_equal,
253 Audit_bitmask,
254 Audit_bittest,
255 Audit_lt,
256 Audit_gt,
257 Audit_le,
258 Audit_ge,
259 Audit_bad
260};
261
250/* Status symbols */ 262/* Status symbols */
251 /* Mask values */ 263 /* Mask values */
252#define AUDIT_STATUS_ENABLED 0x0001 264#define AUDIT_STATUS_ENABLED 0x0001
@@ -373,6 +385,8 @@ struct audit_krule {
373 struct audit_watch *watch; /* associated watch */ 385 struct audit_watch *watch; /* associated watch */
374 struct audit_tree *tree; /* associated watched tree */ 386 struct audit_tree *tree; /* associated watched tree */
375 struct list_head rlist; /* entry in audit_{watch,tree}.rules list */ 387 struct list_head rlist; /* entry in audit_{watch,tree}.rules list */
388 struct list_head list; /* for AUDIT_LIST* purposes only */
389 u64 prio;
376}; 390};
377 391
378struct audit_field { 392struct audit_field {
@@ -443,70 +457,56 @@ extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid);
443#define audit_get_loginuid(t) ((t)->loginuid) 457#define audit_get_loginuid(t) ((t)->loginuid)
444#define audit_get_sessionid(t) ((t)->sessionid) 458#define audit_get_sessionid(t) ((t)->sessionid)
445extern void audit_log_task_context(struct audit_buffer *ab); 459extern void audit_log_task_context(struct audit_buffer *ab);
446extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp); 460extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
447extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); 461extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
448extern int audit_bprm(struct linux_binprm *bprm); 462extern int audit_bprm(struct linux_binprm *bprm);
449extern int audit_socketcall(int nargs, unsigned long *args); 463extern void audit_socketcall(int nargs, unsigned long *args);
450extern int audit_sockaddr(int len, void *addr); 464extern int audit_sockaddr(int len, void *addr);
451extern int __audit_fd_pair(int fd1, int fd2); 465extern void __audit_fd_pair(int fd1, int fd2);
452extern int audit_set_macxattr(const char *name); 466extern int audit_set_macxattr(const char *name);
453extern int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr); 467extern void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr);
454extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout); 468extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout);
455extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout); 469extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
456extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); 470extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
457extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
458extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, 471extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
459 const struct cred *new, 472 const struct cred *new,
460 const struct cred *old); 473 const struct cred *old);
461extern int __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old); 474extern void __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old);
462 475
463static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) 476static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
464{ 477{
465 if (unlikely(!audit_dummy_context())) 478 if (unlikely(!audit_dummy_context()))
466 return __audit_ipc_obj(ipcp); 479 __audit_ipc_obj(ipcp);
467 return 0;
468}
469static inline int audit_fd_pair(int fd1, int fd2)
470{
471 if (unlikely(!audit_dummy_context()))
472 return __audit_fd_pair(fd1, fd2);
473 return 0;
474} 480}
475static inline int audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) 481static inline void audit_fd_pair(int fd1, int fd2)
476{ 482{
477 if (unlikely(!audit_dummy_context())) 483 if (unlikely(!audit_dummy_context()))
478 return __audit_ipc_set_perm(qbytes, uid, gid, mode); 484 __audit_fd_pair(fd1, fd2);
479 return 0;
480} 485}
481static inline int audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) 486static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode)
482{ 487{
483 if (unlikely(!audit_dummy_context())) 488 if (unlikely(!audit_dummy_context()))
484 return __audit_mq_open(oflag, mode, u_attr); 489 __audit_ipc_set_perm(qbytes, uid, gid, mode);
485 return 0;
486} 490}
487static inline int audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout) 491static inline void audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr)
488{ 492{
489 if (unlikely(!audit_dummy_context())) 493 if (unlikely(!audit_dummy_context()))
490 return __audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); 494 __audit_mq_open(oflag, mode, attr);
491 return 0;
492} 495}
493static inline int audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout) 496static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
494{ 497{
495 if (unlikely(!audit_dummy_context())) 498 if (unlikely(!audit_dummy_context()))
496 return __audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); 499 __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
497 return 0;
498} 500}
499static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) 501static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
500{ 502{
501 if (unlikely(!audit_dummy_context())) 503 if (unlikely(!audit_dummy_context()))
502 return __audit_mq_notify(mqdes, u_notification); 504 __audit_mq_notify(mqdes, notification);
503 return 0;
504} 505}
505static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) 506static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
506{ 507{
507 if (unlikely(!audit_dummy_context())) 508 if (unlikely(!audit_dummy_context()))
508 return __audit_mq_getsetattr(mqdes, mqstat); 509 __audit_mq_getsetattr(mqdes, mqstat);
509 return 0;
510} 510}
511 511
512static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, 512static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
@@ -518,12 +518,11 @@ static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
518 return 0; 518 return 0;
519} 519}
520 520
521static inline int audit_log_capset(pid_t pid, const struct cred *new, 521static inline void audit_log_capset(pid_t pid, const struct cred *new,
522 const struct cred *old) 522 const struct cred *old)
523{ 523{
524 if (unlikely(!audit_dummy_context())) 524 if (unlikely(!audit_dummy_context()))
525 return __audit_log_capset(pid, new, old); 525 __audit_log_capset(pid, new, old);
526 return 0;
527} 526}
528 527
529extern int audit_n_rules; 528extern int audit_n_rules;
@@ -546,20 +545,19 @@ extern int audit_signals;
546#define audit_get_loginuid(t) (-1) 545#define audit_get_loginuid(t) (-1)
547#define audit_get_sessionid(t) (-1) 546#define audit_get_sessionid(t) (-1)
548#define audit_log_task_context(b) do { ; } while (0) 547#define audit_log_task_context(b) do { ; } while (0)
549#define audit_ipc_obj(i) ({ 0; }) 548#define audit_ipc_obj(i) ((void)0)
550#define audit_ipc_set_perm(q,u,g,m) ({ 0; }) 549#define audit_ipc_set_perm(q,u,g,m) ((void)0)
551#define audit_bprm(p) ({ 0; }) 550#define audit_bprm(p) ({ 0; })
552#define audit_socketcall(n,a) ({ 0; }) 551#define audit_socketcall(n,a) ((void)0)
553#define audit_fd_pair(n,a) ({ 0; }) 552#define audit_fd_pair(n,a) ((void)0)
554#define audit_sockaddr(len, addr) ({ 0; }) 553#define audit_sockaddr(len, addr) ({ 0; })
555#define audit_set_macxattr(n) do { ; } while (0) 554#define audit_set_macxattr(n) do { ; } while (0)
556#define audit_mq_open(o,m,a) ({ 0; }) 555#define audit_mq_open(o,m,a) ((void)0)
557#define audit_mq_timedsend(d,l,p,t) ({ 0; }) 556#define audit_mq_sendrecv(d,l,p,t) ((void)0)
558#define audit_mq_timedreceive(d,l,p,t) ({ 0; }) 557#define audit_mq_notify(d,n) ((void)0)
559#define audit_mq_notify(d,n) ({ 0; }) 558#define audit_mq_getsetattr(d,s) ((void)0)
560#define audit_mq_getsetattr(d,s) ({ 0; })
561#define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) 559#define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; })
562#define audit_log_capset(pid, ncr, ocr) ({ 0; }) 560#define audit_log_capset(pid, ncr, ocr) ((void)0)
563#define audit_ptrace(t) ((void)0) 561#define audit_ptrace(t) ((void)0)
564#define audit_n_rules 0 562#define audit_n_rules 0
565#define audit_signals 0 563#define audit_signals 0
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index a08c33a26ca9..2878811c6134 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -137,9 +137,12 @@ extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits);
137 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ 137 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
138) 138)
139 139
140#define small_const_nbits(nbits) \
141 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
142
140static inline void bitmap_zero(unsigned long *dst, int nbits) 143static inline void bitmap_zero(unsigned long *dst, int nbits)
141{ 144{
142 if (nbits <= BITS_PER_LONG) 145 if (small_const_nbits(nbits))
143 *dst = 0UL; 146 *dst = 0UL;
144 else { 147 else {
145 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); 148 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
@@ -150,7 +153,7 @@ static inline void bitmap_zero(unsigned long *dst, int nbits)
150static inline void bitmap_fill(unsigned long *dst, int nbits) 153static inline void bitmap_fill(unsigned long *dst, int nbits)
151{ 154{
152 size_t nlongs = BITS_TO_LONGS(nbits); 155 size_t nlongs = BITS_TO_LONGS(nbits);
153 if (nlongs > 1) { 156 if (!small_const_nbits(nbits)) {
154 int len = (nlongs - 1) * sizeof(unsigned long); 157 int len = (nlongs - 1) * sizeof(unsigned long);
155 memset(dst, 0xff, len); 158 memset(dst, 0xff, len);
156 } 159 }
@@ -160,7 +163,7 @@ static inline void bitmap_fill(unsigned long *dst, int nbits)
160static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, 163static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
161 int nbits) 164 int nbits)
162{ 165{
163 if (nbits <= BITS_PER_LONG) 166 if (small_const_nbits(nbits))
164 *dst = *src; 167 *dst = *src;
165 else { 168 else {
166 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); 169 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
@@ -171,7 +174,7 @@ static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
171static inline void bitmap_and(unsigned long *dst, const unsigned long *src1, 174static inline void bitmap_and(unsigned long *dst, const unsigned long *src1,
172 const unsigned long *src2, int nbits) 175 const unsigned long *src2, int nbits)
173{ 176{
174 if (nbits <= BITS_PER_LONG) 177 if (small_const_nbits(nbits))
175 *dst = *src1 & *src2; 178 *dst = *src1 & *src2;
176 else 179 else
177 __bitmap_and(dst, src1, src2, nbits); 180 __bitmap_and(dst, src1, src2, nbits);
@@ -180,7 +183,7 @@ static inline void bitmap_and(unsigned long *dst, const unsigned long *src1,
180static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, 183static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
181 const unsigned long *src2, int nbits) 184 const unsigned long *src2, int nbits)
182{ 185{
183 if (nbits <= BITS_PER_LONG) 186 if (small_const_nbits(nbits))
184 *dst = *src1 | *src2; 187 *dst = *src1 | *src2;
185 else 188 else
186 __bitmap_or(dst, src1, src2, nbits); 189 __bitmap_or(dst, src1, src2, nbits);
@@ -189,7 +192,7 @@ static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
189static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, 192static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,
190 const unsigned long *src2, int nbits) 193 const unsigned long *src2, int nbits)
191{ 194{
192 if (nbits <= BITS_PER_LONG) 195 if (small_const_nbits(nbits))
193 *dst = *src1 ^ *src2; 196 *dst = *src1 ^ *src2;
194 else 197 else
195 __bitmap_xor(dst, src1, src2, nbits); 198 __bitmap_xor(dst, src1, src2, nbits);
@@ -198,7 +201,7 @@ static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,
198static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1, 201static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1,
199 const unsigned long *src2, int nbits) 202 const unsigned long *src2, int nbits)
200{ 203{
201 if (nbits <= BITS_PER_LONG) 204 if (small_const_nbits(nbits))
202 *dst = *src1 & ~(*src2); 205 *dst = *src1 & ~(*src2);
203 else 206 else
204 __bitmap_andnot(dst, src1, src2, nbits); 207 __bitmap_andnot(dst, src1, src2, nbits);
@@ -207,7 +210,7 @@ static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1,
207static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, 210static inline void bitmap_complement(unsigned long *dst, const unsigned long *src,
208 int nbits) 211 int nbits)
209{ 212{
210 if (nbits <= BITS_PER_LONG) 213 if (small_const_nbits(nbits))
211 *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); 214 *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits);
212 else 215 else
213 __bitmap_complement(dst, src, nbits); 216 __bitmap_complement(dst, src, nbits);
@@ -216,7 +219,7 @@ static inline void bitmap_complement(unsigned long *dst, const unsigned long *sr
216static inline int bitmap_equal(const unsigned long *src1, 219static inline int bitmap_equal(const unsigned long *src1,
217 const unsigned long *src2, int nbits) 220 const unsigned long *src2, int nbits)
218{ 221{
219 if (nbits <= BITS_PER_LONG) 222 if (small_const_nbits(nbits))
220 return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); 223 return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
221 else 224 else
222 return __bitmap_equal(src1, src2, nbits); 225 return __bitmap_equal(src1, src2, nbits);
@@ -225,7 +228,7 @@ static inline int bitmap_equal(const unsigned long *src1,
225static inline int bitmap_intersects(const unsigned long *src1, 228static inline int bitmap_intersects(const unsigned long *src1,
226 const unsigned long *src2, int nbits) 229 const unsigned long *src2, int nbits)
227{ 230{
228 if (nbits <= BITS_PER_LONG) 231 if (small_const_nbits(nbits))
229 return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; 232 return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
230 else 233 else
231 return __bitmap_intersects(src1, src2, nbits); 234 return __bitmap_intersects(src1, src2, nbits);
@@ -234,7 +237,7 @@ static inline int bitmap_intersects(const unsigned long *src1,
234static inline int bitmap_subset(const unsigned long *src1, 237static inline int bitmap_subset(const unsigned long *src1,
235 const unsigned long *src2, int nbits) 238 const unsigned long *src2, int nbits)
236{ 239{
237 if (nbits <= BITS_PER_LONG) 240 if (small_const_nbits(nbits))
238 return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits)); 241 return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
239 else 242 else
240 return __bitmap_subset(src1, src2, nbits); 243 return __bitmap_subset(src1, src2, nbits);
@@ -242,7 +245,7 @@ static inline int bitmap_subset(const unsigned long *src1,
242 245
243static inline int bitmap_empty(const unsigned long *src, int nbits) 246static inline int bitmap_empty(const unsigned long *src, int nbits)
244{ 247{
245 if (nbits <= BITS_PER_LONG) 248 if (small_const_nbits(nbits))
246 return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); 249 return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
247 else 250 else
248 return __bitmap_empty(src, nbits); 251 return __bitmap_empty(src, nbits);
@@ -250,7 +253,7 @@ static inline int bitmap_empty(const unsigned long *src, int nbits)
250 253
251static inline int bitmap_full(const unsigned long *src, int nbits) 254static inline int bitmap_full(const unsigned long *src, int nbits)
252{ 255{
253 if (nbits <= BITS_PER_LONG) 256 if (small_const_nbits(nbits))
254 return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); 257 return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits));
255 else 258 else
256 return __bitmap_full(src, nbits); 259 return __bitmap_full(src, nbits);
@@ -258,7 +261,7 @@ static inline int bitmap_full(const unsigned long *src, int nbits)
258 261
259static inline int bitmap_weight(const unsigned long *src, int nbits) 262static inline int bitmap_weight(const unsigned long *src, int nbits)
260{ 263{
261 if (nbits <= BITS_PER_LONG) 264 if (small_const_nbits(nbits))
262 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); 265 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
263 return __bitmap_weight(src, nbits); 266 return __bitmap_weight(src, nbits);
264} 267}
@@ -266,7 +269,7 @@ static inline int bitmap_weight(const unsigned long *src, int nbits)
266static inline void bitmap_shift_right(unsigned long *dst, 269static inline void bitmap_shift_right(unsigned long *dst,
267 const unsigned long *src, int n, int nbits) 270 const unsigned long *src, int n, int nbits)
268{ 271{
269 if (nbits <= BITS_PER_LONG) 272 if (small_const_nbits(nbits))
270 *dst = *src >> n; 273 *dst = *src >> n;
271 else 274 else
272 __bitmap_shift_right(dst, src, n, nbits); 275 __bitmap_shift_right(dst, src, n, nbits);
@@ -275,7 +278,7 @@ static inline void bitmap_shift_right(unsigned long *dst,
275static inline void bitmap_shift_left(unsigned long *dst, 278static inline void bitmap_shift_left(unsigned long *dst,
276 const unsigned long *src, int n, int nbits) 279 const unsigned long *src, int n, int nbits)
277{ 280{
278 if (nbits <= BITS_PER_LONG) 281 if (small_const_nbits(nbits))
279 *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits); 282 *dst = (*src << n) & BITMAP_LAST_WORD_MASK(nbits);
280 else 283 else
281 __bitmap_shift_left(dst, src, n, nbits); 284 __bitmap_shift_left(dst, src, n, nbits);
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 024f2b027244..61829139795a 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -134,9 +134,20 @@ extern unsigned long find_first_bit(const unsigned long *addr,
134 */ 134 */
135extern unsigned long find_first_zero_bit(const unsigned long *addr, 135extern unsigned long find_first_zero_bit(const unsigned long *addr,
136 unsigned long size); 136 unsigned long size);
137
138#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ 137#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
139 138
139#ifdef CONFIG_GENERIC_FIND_LAST_BIT
140/**
141 * find_last_bit - find the last set bit in a memory region
142 * @addr: The address to start the search at
143 * @size: The maximum size to search
144 *
145 * Returns the bit number of the first set bit, or size.
146 */
147extern unsigned long find_last_bit(const unsigned long *addr,
148 unsigned long size);
149#endif /* CONFIG_GENERIC_FIND_LAST_BIT */
150
140#ifdef CONFIG_GENERIC_FIND_NEXT_BIT 151#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
141 152
142/** 153/**
diff --git a/include/linux/blockgroup_lock.h b/include/linux/blockgroup_lock.h
index 8607312983bd..e44b88ba552b 100644
--- a/include/linux/blockgroup_lock.h
+++ b/include/linux/blockgroup_lock.h
@@ -53,7 +53,10 @@ static inline void bgl_lock_init(struct blockgroup_lock *bgl)
53 * The accessor is a macro so we can embed a blockgroup_lock into different 53 * The accessor is a macro so we can embed a blockgroup_lock into different
54 * superblock types 54 * superblock types
55 */ 55 */
56#define sb_bgl_lock(sb, block_group) \ 56static inline spinlock_t *
57 (&(sb)->s_blockgroup_lock.locks[(block_group) & (NR_BG_LOCKS-1)].lock) 57bgl_lock_ptr(struct blockgroup_lock *bgl, unsigned int block_group)
58{
59 return &bgl->locks[(block_group) & (NR_BG_LOCKS-1)].lock;
60}
58 61
59#endif 62#endif
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
index 2befe6513ce4..8005effc04f1 100644
--- a/include/linux/compiler-gcc3.h
+++ b/include/linux/compiler-gcc3.h
@@ -2,6 +2,10 @@
2#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead." 2#error "Please don't include <linux/compiler-gcc3.h> directly, include <linux/compiler.h> instead."
3#endif 3#endif
4 4
5#if __GNUC_MINOR__ < 2
6# error Sorry, your compiler is too old - please upgrade it.
7#endif
8
5#if __GNUC_MINOR__ >= 3 9#if __GNUC_MINOR__ >= 3
6# define __used __attribute__((__used__)) 10# define __used __attribute__((__used__))
7#else 11#else
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 1ee608fd7b77..484b3abf61bb 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -234,6 +234,7 @@ struct cpufreq_driver {
234 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg); 234 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg);
235 int (*resume) (struct cpufreq_policy *policy); 235 int (*resume) (struct cpufreq_policy *policy);
236 struct freq_attr **attr; 236 struct freq_attr **attr;
237 bool hide_interface;
237}; 238};
238 239
239/* flags */ 240/* flags */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index d4bf52603e6b..9f315382610b 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -144,6 +144,7 @@
144typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; 144typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
145extern cpumask_t _unused_cpumask_arg_; 145extern cpumask_t _unused_cpumask_arg_;
146 146
147#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
147#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst)) 148#define cpu_set(cpu, dst) __cpu_set((cpu), &(dst))
148static inline void __cpu_set(int cpu, volatile cpumask_t *dstp) 149static inline void __cpu_set(int cpu, volatile cpumask_t *dstp)
149{ 150{
@@ -267,6 +268,26 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
267{ 268{
268 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 269 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
269} 270}
271#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
272
273/**
274 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
275 * @bitmap: the bitmap
276 *
277 * There are a few places where cpumask_var_t isn't appropriate and
278 * static cpumasks must be used (eg. very early boot), yet we don't
279 * expose the definition of 'struct cpumask'.
280 *
281 * This does the conversion, and can be used as a constant initializer.
282 */
283#define to_cpumask(bitmap) \
284 ((struct cpumask *)(1 ? (bitmap) \
285 : (void *)sizeof(__check_is_bitmap(bitmap))))
286
287static inline int __check_is_bitmap(const unsigned long *bitmap)
288{
289 return 1;
290}
270 291
271/* 292/*
272 * Special-case data structure for "single bit set only" constant CPU masks. 293 * Special-case data structure for "single bit set only" constant CPU masks.
@@ -278,13 +299,14 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
278extern const unsigned long 299extern const unsigned long
279 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)]; 300 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
280 301
281static inline const cpumask_t *get_cpu_mask(unsigned int cpu) 302static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
282{ 303{
283 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG]; 304 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
284 p -= cpu / BITS_PER_LONG; 305 p -= cpu / BITS_PER_LONG;
285 return (const cpumask_t *)p; 306 return to_cpumask(p);
286} 307}
287 308
309#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
288/* 310/*
289 * In cases where we take the address of the cpumask immediately, 311 * In cases where we take the address of the cpumask immediately,
290 * gcc optimizes it out (it's a constant) and there's no huge stack 312 * gcc optimizes it out (it's a constant) and there's no huge stack
@@ -370,19 +392,22 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
370{ 392{
371 bitmap_fold(dstp->bits, origp->bits, sz, nbits); 393 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
372} 394}
395#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
373 396
374#if NR_CPUS == 1 397#if NR_CPUS == 1
375 398
376#define nr_cpu_ids 1 399#define nr_cpu_ids 1
400#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
377#define first_cpu(src) ({ (void)(src); 0; }) 401#define first_cpu(src) ({ (void)(src); 0; })
378#define next_cpu(n, src) ({ (void)(src); 1; }) 402#define next_cpu(n, src) ({ (void)(src); 1; })
379#define any_online_cpu(mask) 0 403#define any_online_cpu(mask) 0
380#define for_each_cpu_mask(cpu, mask) \ 404#define for_each_cpu_mask(cpu, mask) \
381 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) 405 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
382 406#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
383#else /* NR_CPUS > 1 */ 407#else /* NR_CPUS > 1 */
384 408
385extern int nr_cpu_ids; 409extern int nr_cpu_ids;
410#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
386int __first_cpu(const cpumask_t *srcp); 411int __first_cpu(const cpumask_t *srcp);
387int __next_cpu(int n, const cpumask_t *srcp); 412int __next_cpu(int n, const cpumask_t *srcp);
388int __any_online_cpu(const cpumask_t *mask); 413int __any_online_cpu(const cpumask_t *mask);
@@ -394,8 +419,10 @@ int __any_online_cpu(const cpumask_t *mask);
394 for ((cpu) = -1; \ 419 for ((cpu) = -1; \
395 (cpu) = next_cpu((cpu), (mask)), \ 420 (cpu) = next_cpu((cpu), (mask)), \
396 (cpu) < NR_CPUS; ) 421 (cpu) < NR_CPUS; )
422#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
397#endif 423#endif
398 424
425#ifndef CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
399#if NR_CPUS <= 64 426#if NR_CPUS <= 64
400 427
401#define next_cpu_nr(n, src) next_cpu(n, src) 428#define next_cpu_nr(n, src) next_cpu(n, src)
@@ -413,77 +440,67 @@ int __next_cpu_nr(int n, const cpumask_t *srcp);
413 (cpu) < nr_cpu_ids; ) 440 (cpu) < nr_cpu_ids; )
414 441
415#endif /* NR_CPUS > 64 */ 442#endif /* NR_CPUS > 64 */
443#endif /* !CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS */
416 444
417/* 445/*
418 * The following particular system cpumasks and operations manage 446 * The following particular system cpumasks and operations manage
419 * possible, present, active and online cpus. Each of them is a fixed size 447 * possible, present, active and online cpus.
420 * bitmap of size NR_CPUS.
421 * 448 *
422 * #ifdef CONFIG_HOTPLUG_CPU 449 * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
423 * cpu_possible_map - has bit 'cpu' set iff cpu is populatable 450 * cpu_present_mask - has bit 'cpu' set iff cpu is populated
424 * cpu_present_map - has bit 'cpu' set iff cpu is populated 451 * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler
425 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler 452 * cpu_active_mask - has bit 'cpu' set iff cpu available to migration
426 * cpu_active_map - has bit 'cpu' set iff cpu available to migration
427 * #else
428 * cpu_possible_map - has bit 'cpu' set iff cpu is populated
429 * cpu_present_map - copy of cpu_possible_map
430 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
431 * #endif
432 * 453 *
433 * In either case, NR_CPUS is fixed at compile time, as the static 454 * If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
434 * size of these bitmaps. The cpu_possible_map is fixed at boot
435 * time, as the set of CPU id's that it is possible might ever
436 * be plugged in at anytime during the life of that system boot.
437 * The cpu_present_map is dynamic(*), representing which CPUs
438 * are currently plugged in. And cpu_online_map is the dynamic
439 * subset of cpu_present_map, indicating those CPUs available
440 * for scheduling.
441 * 455 *
442 * If HOTPLUG is enabled, then cpu_possible_map is forced to have 456 * The cpu_possible_mask is fixed at boot time, as the set of CPU id's
457 * that it is possible might ever be plugged in at anytime during the
458 * life of that system boot. The cpu_present_mask is dynamic(*),
459 * representing which CPUs are currently plugged in. And
460 * cpu_online_mask is the dynamic subset of cpu_present_mask,
461 * indicating those CPUs available for scheduling.
462 *
463 * If HOTPLUG is enabled, then cpu_possible_mask is forced to have
443 * all NR_CPUS bits set, otherwise it is just the set of CPUs that 464 * all NR_CPUS bits set, otherwise it is just the set of CPUs that
444 * ACPI reports present at boot. 465 * ACPI reports present at boot.
445 * 466 *
446 * If HOTPLUG is enabled, then cpu_present_map varies dynamically, 467 * If HOTPLUG is enabled, then cpu_present_mask varies dynamically,
447 * depending on what ACPI reports as currently plugged in, otherwise 468 * depending on what ACPI reports as currently plugged in, otherwise
448 * cpu_present_map is just a copy of cpu_possible_map. 469 * cpu_present_mask is just a copy of cpu_possible_mask.
449 * 470 *
450 * (*) Well, cpu_present_map is dynamic in the hotplug case. If not 471 * (*) Well, cpu_present_mask is dynamic in the hotplug case. If not
451 * hotplug, it's a copy of cpu_possible_map, hence fixed at boot. 472 * hotplug, it's a copy of cpu_possible_mask, hence fixed at boot.
452 * 473 *
453 * Subtleties: 474 * Subtleties:
454 * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode 475 * 1) UP arch's (NR_CPUS == 1, CONFIG_SMP not defined) hardcode
455 * assumption that their single CPU is online. The UP 476 * assumption that their single CPU is online. The UP
456 * cpu_{online,possible,present}_maps are placebos. Changing them 477 * cpu_{online,possible,present}_masks are placebos. Changing them
457 * will have no useful affect on the following num_*_cpus() 478 * will have no useful affect on the following num_*_cpus()
458 * and cpu_*() macros in the UP case. This ugliness is a UP 479 * and cpu_*() macros in the UP case. This ugliness is a UP
459 * optimization - don't waste any instructions or memory references 480 * optimization - don't waste any instructions or memory references
460 * asking if you're online or how many CPUs there are if there is 481 * asking if you're online or how many CPUs there are if there is
461 * only one CPU. 482 * only one CPU.
462 * 2) Most SMP arch's #define some of these maps to be some
463 * other map specific to that arch. Therefore, the following
464 * must be #define macros, not inlines. To see why, examine
465 * the assembly code produced by the following. Note that
466 * set1() writes phys_x_map, but set2() writes x_map:
467 * int x_map, phys_x_map;
468 * #define set1(a) x_map = a
469 * inline void set2(int a) { x_map = a; }
470 * #define x_map phys_x_map
471 * main(){ set1(3); set2(5); }
472 */ 483 */
473 484
474extern cpumask_t cpu_possible_map; 485extern const struct cpumask *const cpu_possible_mask;
475extern cpumask_t cpu_online_map; 486extern const struct cpumask *const cpu_online_mask;
476extern cpumask_t cpu_present_map; 487extern const struct cpumask *const cpu_present_mask;
477extern cpumask_t cpu_active_map; 488extern const struct cpumask *const cpu_active_mask;
489
490/* These strip const, as traditionally they weren't const. */
491#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask)
492#define cpu_online_map (*(cpumask_t *)cpu_online_mask)
493#define cpu_present_map (*(cpumask_t *)cpu_present_mask)
494#define cpu_active_map (*(cpumask_t *)cpu_active_mask)
478 495
479#if NR_CPUS > 1 496#if NR_CPUS > 1
480#define num_online_cpus() cpus_weight_nr(cpu_online_map) 497#define num_online_cpus() cpumask_weight(cpu_online_mask)
481#define num_possible_cpus() cpus_weight_nr(cpu_possible_map) 498#define num_possible_cpus() cpumask_weight(cpu_possible_mask)
482#define num_present_cpus() cpus_weight_nr(cpu_present_map) 499#define num_present_cpus() cpumask_weight(cpu_present_mask)
483#define cpu_online(cpu) cpu_isset((cpu), cpu_online_map) 500#define cpu_online(cpu) cpumask_test_cpu((cpu), cpu_online_mask)
484#define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map) 501#define cpu_possible(cpu) cpumask_test_cpu((cpu), cpu_possible_mask)
485#define cpu_present(cpu) cpu_isset((cpu), cpu_present_map) 502#define cpu_present(cpu) cpumask_test_cpu((cpu), cpu_present_mask)
486#define cpu_active(cpu) cpu_isset((cpu), cpu_active_map) 503#define cpu_active(cpu) cpumask_test_cpu((cpu), cpu_active_mask)
487#else 504#else
488#define num_online_cpus() 1 505#define num_online_cpus() 1
489#define num_possible_cpus() 1 506#define num_possible_cpus() 1
@@ -496,10 +513,6 @@ extern cpumask_t cpu_active_map;
496 513
497#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 514#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
498 515
499#define for_each_possible_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_possible_map)
500#define for_each_online_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_online_map)
501#define for_each_present_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_present_map)
502
503/* These are the new versions of the cpumask operators: passed by pointer. 516/* These are the new versions of the cpumask operators: passed by pointer.
504 * The older versions will be implemented in terms of these, then deleted. */ 517 * The older versions will be implemented in terms of these, then deleted. */
505#define cpumask_bits(maskp) ((maskp)->bits) 518#define cpumask_bits(maskp) ((maskp)->bits)
@@ -687,7 +700,7 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)
687 * No static inline type checking - see Subtlety (1) above. 700 * No static inline type checking - see Subtlety (1) above.
688 */ 701 */
689#define cpumask_test_cpu(cpu, cpumask) \ 702#define cpumask_test_cpu(cpu, cpumask) \
690 test_bit(cpumask_check(cpu), (cpumask)->bits) 703 test_bit(cpumask_check(cpu), cpumask_bits((cpumask)))
691 704
692/** 705/**
693 * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask 706 * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask
@@ -930,7 +943,7 @@ static inline void cpumask_copy(struct cpumask *dstp,
930static inline int cpumask_scnprintf(char *buf, int len, 943static inline int cpumask_scnprintf(char *buf, int len,
931 const struct cpumask *srcp) 944 const struct cpumask *srcp)
932{ 945{
933 return bitmap_scnprintf(buf, len, srcp->bits, nr_cpumask_bits); 946 return bitmap_scnprintf(buf, len, cpumask_bits(srcp), nr_cpumask_bits);
934} 947}
935 948
936/** 949/**
@@ -944,7 +957,7 @@ static inline int cpumask_scnprintf(char *buf, int len,
944static inline int cpumask_parse_user(const char __user *buf, int len, 957static inline int cpumask_parse_user(const char __user *buf, int len,
945 struct cpumask *dstp) 958 struct cpumask *dstp)
946{ 959{
947 return bitmap_parse_user(buf, len, dstp->bits, nr_cpumask_bits); 960 return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
948} 961}
949 962
950/** 963/**
@@ -959,7 +972,8 @@ static inline int cpumask_parse_user(const char __user *buf, int len,
959static inline int cpulist_scnprintf(char *buf, int len, 972static inline int cpulist_scnprintf(char *buf, int len,
960 const struct cpumask *srcp) 973 const struct cpumask *srcp)
961{ 974{
962 return bitmap_scnlistprintf(buf, len, srcp->bits, nr_cpumask_bits); 975 return bitmap_scnlistprintf(buf, len, cpumask_bits(srcp),
976 nr_cpumask_bits);
963} 977}
964 978
965/** 979/**
@@ -972,26 +986,7 @@ static inline int cpulist_scnprintf(char *buf, int len,
972 */ 986 */
973static inline int cpulist_parse(const char *buf, struct cpumask *dstp) 987static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
974{ 988{
975 return bitmap_parselist(buf, dstp->bits, nr_cpumask_bits); 989 return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
976}
977
978/**
979 * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
980 * @bitmap: the bitmap
981 *
982 * There are a few places where cpumask_var_t isn't appropriate and
983 * static cpumasks must be used (eg. very early boot), yet we don't
984 * expose the definition of 'struct cpumask'.
985 *
986 * This does the conversion, and can be used as a constant initializer.
987 */
988#define to_cpumask(bitmap) \
989 ((struct cpumask *)(1 ? (bitmap) \
990 : (void *)sizeof(__check_is_bitmap(bitmap))))
991
992static inline int __check_is_bitmap(const unsigned long *bitmap)
993{
994 return 1;
995} 990}
996 991
997/** 992/**
@@ -1025,6 +1020,7 @@ static inline size_t cpumask_size(void)
1025#ifdef CONFIG_CPUMASK_OFFSTACK 1020#ifdef CONFIG_CPUMASK_OFFSTACK
1026typedef struct cpumask *cpumask_var_t; 1021typedef struct cpumask *cpumask_var_t;
1027 1022
1023bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node);
1028bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags); 1024bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags);
1029void alloc_bootmem_cpumask_var(cpumask_var_t *mask); 1025void alloc_bootmem_cpumask_var(cpumask_var_t *mask);
1030void free_cpumask_var(cpumask_var_t mask); 1026void free_cpumask_var(cpumask_var_t mask);
@@ -1038,6 +1034,12 @@ static inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
1038 return true; 1034 return true;
1039} 1035}
1040 1036
1037static inline bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags,
1038 int node)
1039{
1040 return true;
1041}
1042
1041static inline void alloc_bootmem_cpumask_var(cpumask_var_t *mask) 1043static inline void alloc_bootmem_cpumask_var(cpumask_var_t *mask)
1042{ 1044{
1043} 1045}
@@ -1051,12 +1053,6 @@ static inline void free_bootmem_cpumask_var(cpumask_var_t mask)
1051} 1053}
1052#endif /* CONFIG_CPUMASK_OFFSTACK */ 1054#endif /* CONFIG_CPUMASK_OFFSTACK */
1053 1055
1054/* The pointer versions of the maps, these will become the primary versions. */
1055#define cpu_possible_mask ((const struct cpumask *)&cpu_possible_map)
1056#define cpu_online_mask ((const struct cpumask *)&cpu_online_map)
1057#define cpu_present_mask ((const struct cpumask *)&cpu_present_map)
1058#define cpu_active_mask ((const struct cpumask *)&cpu_active_map)
1059
1060/* It's common to want to use cpu_all_mask in struct member initializers, 1056/* It's common to want to use cpu_all_mask in struct member initializers,
1061 * so it has to refer to an address rather than a pointer. */ 1057 * so it has to refer to an address rather than a pointer. */
1062extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); 1058extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
@@ -1065,51 +1061,16 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
1065/* First bits of cpu_bit_bitmap are in fact unset. */ 1061/* First bits of cpu_bit_bitmap are in fact unset. */
1066#define cpu_none_mask to_cpumask(cpu_bit_bitmap[0]) 1062#define cpu_none_mask to_cpumask(cpu_bit_bitmap[0])
1067 1063
1068/* Wrappers for arch boot code to manipulate normally-constant masks */ 1064#define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask)
1069static inline void set_cpu_possible(unsigned int cpu, bool possible) 1065#define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask)
1070{ 1066#define for_each_present_cpu(cpu) for_each_cpu((cpu), cpu_present_mask)
1071 if (possible)
1072 cpumask_set_cpu(cpu, &cpu_possible_map);
1073 else
1074 cpumask_clear_cpu(cpu, &cpu_possible_map);
1075}
1076
1077static inline void set_cpu_present(unsigned int cpu, bool present)
1078{
1079 if (present)
1080 cpumask_set_cpu(cpu, &cpu_present_map);
1081 else
1082 cpumask_clear_cpu(cpu, &cpu_present_map);
1083}
1084
1085static inline void set_cpu_online(unsigned int cpu, bool online)
1086{
1087 if (online)
1088 cpumask_set_cpu(cpu, &cpu_online_map);
1089 else
1090 cpumask_clear_cpu(cpu, &cpu_online_map);
1091}
1092 1067
1093static inline void set_cpu_active(unsigned int cpu, bool active) 1068/* Wrappers for arch boot code to manipulate normally-constant masks */
1094{ 1069void set_cpu_possible(unsigned int cpu, bool possible);
1095 if (active) 1070void set_cpu_present(unsigned int cpu, bool present);
1096 cpumask_set_cpu(cpu, &cpu_active_map); 1071void set_cpu_online(unsigned int cpu, bool online);
1097 else 1072void set_cpu_active(unsigned int cpu, bool active);
1098 cpumask_clear_cpu(cpu, &cpu_active_map); 1073void init_cpu_present(const struct cpumask *src);
1099} 1074void init_cpu_possible(const struct cpumask *src);
1100 1075void init_cpu_online(const struct cpumask *src);
1101static inline void init_cpu_present(const struct cpumask *src)
1102{
1103 cpumask_copy(&cpu_present_map, src);
1104}
1105
1106static inline void init_cpu_possible(const struct cpumask *src)
1107{
1108 cpumask_copy(&cpu_possible_map, src);
1109}
1110
1111static inline void init_cpu_online(const struct cpumask *src)
1112{
1113 cpumask_copy(&cpu_online_map, src);
1114}
1115#endif /* __LINUX_CPUMASK_H */ 1076#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index c17fd334e574..8209e08969f9 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -45,6 +45,8 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti);
45 */ 45 */
46typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio, 46typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
47 union map_info *map_context); 47 union map_info *map_context);
48typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *clone,
49 union map_info *map_context);
48 50
49/* 51/*
50 * Returns: 52 * Returns:
@@ -57,6 +59,9 @@ typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
57typedef int (*dm_endio_fn) (struct dm_target *ti, 59typedef int (*dm_endio_fn) (struct dm_target *ti,
58 struct bio *bio, int error, 60 struct bio *bio, int error,
59 union map_info *map_context); 61 union map_info *map_context);
62typedef int (*dm_request_endio_fn) (struct dm_target *ti,
63 struct request *clone, int error,
64 union map_info *map_context);
60 65
61typedef void (*dm_flush_fn) (struct dm_target *ti); 66typedef void (*dm_flush_fn) (struct dm_target *ti);
62typedef void (*dm_presuspend_fn) (struct dm_target *ti); 67typedef void (*dm_presuspend_fn) (struct dm_target *ti);
@@ -75,6 +80,13 @@ typedef int (*dm_ioctl_fn) (struct dm_target *ti, unsigned int cmd,
75typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm, 80typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm,
76 struct bio_vec *biovec, int max_size); 81 struct bio_vec *biovec, int max_size);
77 82
83/*
84 * Returns:
85 * 0: The target can handle the next I/O immediately.
86 * 1: The target can't handle the next I/O immediately.
87 */
88typedef int (*dm_busy_fn) (struct dm_target *ti);
89
78void dm_error(const char *message); 90void dm_error(const char *message);
79 91
80/* 92/*
@@ -100,14 +112,23 @@ void dm_put_device(struct dm_target *ti, struct dm_dev *d);
100/* 112/*
101 * Information about a target type 113 * Information about a target type
102 */ 114 */
115
116/*
117 * Target features
118 */
119#define DM_TARGET_SUPPORTS_BARRIERS 0x00000001
120
103struct target_type { 121struct target_type {
122 uint64_t features;
104 const char *name; 123 const char *name;
105 struct module *module; 124 struct module *module;
106 unsigned version[3]; 125 unsigned version[3];
107 dm_ctr_fn ctr; 126 dm_ctr_fn ctr;
108 dm_dtr_fn dtr; 127 dm_dtr_fn dtr;
109 dm_map_fn map; 128 dm_map_fn map;
129 dm_map_request_fn map_rq;
110 dm_endio_fn end_io; 130 dm_endio_fn end_io;
131 dm_request_endio_fn rq_end_io;
111 dm_flush_fn flush; 132 dm_flush_fn flush;
112 dm_presuspend_fn presuspend; 133 dm_presuspend_fn presuspend;
113 dm_postsuspend_fn postsuspend; 134 dm_postsuspend_fn postsuspend;
@@ -117,6 +138,7 @@ struct target_type {
117 dm_message_fn message; 138 dm_message_fn message;
118 dm_ioctl_fn ioctl; 139 dm_ioctl_fn ioctl;
119 dm_merge_fn merge; 140 dm_merge_fn merge;
141 dm_busy_fn busy;
120}; 142};
121 143
122struct io_restrictions { 144struct io_restrictions {
@@ -157,8 +179,7 @@ struct dm_target {
157}; 179};
158 180
159int dm_register_target(struct target_type *t); 181int dm_register_target(struct target_type *t);
160int dm_unregister_target(struct target_type *t); 182void dm_unregister_target(struct target_type *t);
161
162 183
163/*----------------------------------------------------------------- 184/*-----------------------------------------------------------------
164 * Functions for creating and manipulating mapped devices. 185 * Functions for creating and manipulating mapped devices.
@@ -276,6 +297,9 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
276 *---------------------------------------------------------------*/ 297 *---------------------------------------------------------------*/
277#define DM_NAME "device-mapper" 298#define DM_NAME "device-mapper"
278 299
300#define DMCRIT(f, arg...) \
301 printk(KERN_CRIT DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
302
279#define DMERR(f, arg...) \ 303#define DMERR(f, arg...) \
280 printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) 304 printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg)
281#define DMERR_LIMIT(f, arg...) \ 305#define DMERR_LIMIT(f, arg...) \
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 952df39c989d..af1dab41674b 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -9,148 +9,24 @@
9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT) 9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK) 10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
11 11
12#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
13#define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK)
14#define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK)
15
16
17/*
18 * 0: Present
19 * 1-11: Reserved
20 * 12-63: Context Ptr (12 - (haw-1))
21 * 64-127: Reserved
22 */
23struct root_entry {
24 u64 val;
25 u64 rsvd1;
26};
27#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
28static inline bool root_present(struct root_entry *root)
29{
30 return (root->val & 1);
31}
32static inline void set_root_present(struct root_entry *root)
33{
34 root->val |= 1;
35}
36static inline void set_root_value(struct root_entry *root, unsigned long value)
37{
38 root->val |= value & VTD_PAGE_MASK;
39}
40
41struct context_entry;
42static inline struct context_entry *
43get_context_addr_from_root(struct root_entry *root)
44{
45 return (struct context_entry *)
46 (root_present(root)?phys_to_virt(
47 root->val & VTD_PAGE_MASK) :
48 NULL);
49}
50
51/*
52 * low 64 bits:
53 * 0: present
54 * 1: fault processing disable
55 * 2-3: translation type
56 * 12-63: address space root
57 * high 64 bits:
58 * 0-2: address width
59 * 3-6: aval
60 * 8-23: domain id
61 */
62struct context_entry {
63 u64 lo;
64 u64 hi;
65};
66#define context_present(c) ((c).lo & 1)
67#define context_fault_disable(c) (((c).lo >> 1) & 1)
68#define context_translation_type(c) (((c).lo >> 2) & 3)
69#define context_address_root(c) ((c).lo & VTD_PAGE_MASK)
70#define context_address_width(c) ((c).hi & 7)
71#define context_domain_id(c) (((c).hi >> 8) & ((1 << 16) - 1))
72
73#define context_set_present(c) do {(c).lo |= 1;} while (0)
74#define context_set_fault_enable(c) \
75 do {(c).lo &= (((u64)-1) << 2) | 1;} while (0)
76#define context_set_translation_type(c, val) \
77 do { \
78 (c).lo &= (((u64)-1) << 4) | 3; \
79 (c).lo |= ((val) & 3) << 2; \
80 } while (0)
81#define CONTEXT_TT_MULTI_LEVEL 0
82#define context_set_address_root(c, val) \
83 do {(c).lo |= (val) & VTD_PAGE_MASK; } while (0)
84#define context_set_address_width(c, val) do {(c).hi |= (val) & 7;} while (0)
85#define context_set_domain_id(c, val) \
86 do {(c).hi |= ((val) & ((1 << 16) - 1)) << 8;} while (0)
87#define context_clear_entry(c) do {(c).lo = 0; (c).hi = 0;} while (0)
88
89/*
90 * 0: readable
91 * 1: writable
92 * 2-6: reserved
93 * 7: super page
94 * 8-11: available
95 * 12-63: Host physcial address
96 */
97struct dma_pte {
98 u64 val;
99};
100#define dma_clear_pte(p) do {(p).val = 0;} while (0)
101
102#define DMA_PTE_READ (1) 12#define DMA_PTE_READ (1)
103#define DMA_PTE_WRITE (2) 13#define DMA_PTE_WRITE (2)
104 14
105#define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while (0)
106#define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while (0)
107#define dma_set_pte_prot(p, prot) \
108 do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
109#define dma_pte_addr(p) ((p).val & VTD_PAGE_MASK)
110#define dma_set_pte_addr(p, addr) do {\
111 (p).val |= ((addr) & VTD_PAGE_MASK); } while (0)
112#define dma_pte_present(p) (((p).val & 3) != 0)
113
114struct intel_iommu; 15struct intel_iommu;
16struct dmar_domain;
17struct root_entry;
115 18
116struct dmar_domain {
117 int id; /* domain id */
118 struct intel_iommu *iommu; /* back pointer to owning iommu */
119
120 struct list_head devices; /* all devices' list */
121 struct iova_domain iovad; /* iova's that belong to this domain */
122
123 struct dma_pte *pgd; /* virtual address */
124 spinlock_t mapping_lock; /* page table lock */
125 int gaw; /* max guest address width */
126
127 /* adjusted guest address width, 0 is level 2 30-bit */
128 int agaw;
129
130#define DOMAIN_FLAG_MULTIPLE_DEVICES 1
131 int flags;
132};
133
134/* PCI domain-device relationship */
135struct device_domain_info {
136 struct list_head link; /* link to domain siblings */
137 struct list_head global; /* link to global list */
138 u8 bus; /* PCI bus numer */
139 u8 devfn; /* PCI devfn number */
140 struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */
141 struct dmar_domain *domain; /* pointer to domain */
142};
143
144extern int init_dmars(void);
145extern void free_dmar_iommu(struct intel_iommu *iommu); 19extern void free_dmar_iommu(struct intel_iommu *iommu);
146 20
147extern int dmar_disabled; 21#ifdef CONFIG_DMAR
148 22extern int iommu_calculate_agaw(struct intel_iommu *iommu);
149#ifndef CONFIG_DMAR_GFX_WA 23#else
150static inline void iommu_prepare_gfx_mapping(void) 24static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
151{ 25{
152 return; 26 return 0;
153} 27}
154#endif /* !CONFIG_DMAR_GFX_WA */ 28#endif
29
30extern int dmar_disabled;
155 31
156#endif 32#endif
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index f1984fc3e06d..f28440784cf0 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -144,7 +144,6 @@ struct dmar_rmrr_unit {
144 list_for_each_entry(rmrr, &dmar_rmrr_units, list) 144 list_for_each_entry(rmrr, &dmar_rmrr_units, list)
145/* Intel DMAR initialization functions */ 145/* Intel DMAR initialization functions */
146extern int intel_iommu_init(void); 146extern int intel_iommu_init(void);
147extern int dmar_disabled;
148#else 147#else
149static inline int intel_iommu_init(void) 148static inline int intel_iommu_init(void)
150{ 149{
diff --git a/include/linux/dqblk_qtree.h b/include/linux/dqblk_qtree.h
new file mode 100644
index 000000000000..82a16527b367
--- /dev/null
+++ b/include/linux/dqblk_qtree.h
@@ -0,0 +1,56 @@
1/*
2 * Definitions of structures and functions for quota formats using trie
3 */
4
5#ifndef _LINUX_DQBLK_QTREE_H
6#define _LINUX_DQBLK_QTREE_H
7
8#include <linux/types.h>
9
10/* Numbers of blocks needed for updates - we count with the smallest
11 * possible block size (1024) */
12#define QTREE_INIT_ALLOC 4
13#define QTREE_INIT_REWRITE 2
14#define QTREE_DEL_ALLOC 0
15#define QTREE_DEL_REWRITE 6
16
17struct dquot;
18
19/* Operations */
20struct qtree_fmt_operations {
21 void (*mem2disk_dqblk)(void *disk, struct dquot *dquot); /* Convert given entry from in memory format to disk one */
22 void (*disk2mem_dqblk)(struct dquot *dquot, void *disk); /* Convert given entry from disk format to in memory one */
23 int (*is_id)(void *disk, struct dquot *dquot); /* Is this structure for given id? */
24};
25
26/* Inmemory copy of version specific information */
27struct qtree_mem_dqinfo {
28 struct super_block *dqi_sb; /* Sb quota is on */
29 int dqi_type; /* Quota type */
30 unsigned int dqi_blocks; /* # of blocks in quota file */
31 unsigned int dqi_free_blk; /* First block in list of free blocks */
32 unsigned int dqi_free_entry; /* First block with free entry */
33 unsigned int dqi_blocksize_bits; /* Block size of quota file */
34 unsigned int dqi_entry_size; /* Size of quota entry in quota file */
35 unsigned int dqi_usable_bs; /* Space usable in block for quota data */
36 unsigned int dqi_qtree_depth; /* Precomputed depth of quota tree */
37 struct qtree_fmt_operations *dqi_ops; /* Operations for entry manipulation */
38};
39
40int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
41int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
42int qtree_delete_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
43int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot);
44int qtree_entry_unused(struct qtree_mem_dqinfo *info, char *disk);
45static inline int qtree_depth(struct qtree_mem_dqinfo *info)
46{
47 unsigned int epb = info->dqi_usable_bs >> 2;
48 unsigned long long entries = epb;
49 int i;
50
51 for (i = 1; entries < (1ULL << 32); i++)
52 entries *= epb;
53 return i;
54}
55
56#endif /* _LINUX_DQBLK_QTREE_H */
diff --git a/include/linux/dqblk_v1.h b/include/linux/dqblk_v1.h
index 57f1250d5a52..3713a7232dd8 100644
--- a/include/linux/dqblk_v1.h
+++ b/include/linux/dqblk_v1.h
@@ -5,9 +5,6 @@
5#ifndef _LINUX_DQBLK_V1_H 5#ifndef _LINUX_DQBLK_V1_H
6#define _LINUX_DQBLK_V1_H 6#define _LINUX_DQBLK_V1_H
7 7
8/* Id of quota format */
9#define QFMT_VFS_OLD 1
10
11/* Root squash turned on */ 8/* Root squash turned on */
12#define V1_DQF_RSQUASH 1 9#define V1_DQF_RSQUASH 1
13 10
@@ -17,8 +14,4 @@
17#define V1_DEL_ALLOC 0 14#define V1_DEL_ALLOC 0
18#define V1_DEL_REWRITE 2 15#define V1_DEL_REWRITE 2
19 16
20/* Special information about quotafile */
21struct v1_mem_dqinfo {
22};
23
24#endif /* _LINUX_DQBLK_V1_H */ 17#endif /* _LINUX_DQBLK_V1_H */
diff --git a/include/linux/dqblk_v2.h b/include/linux/dqblk_v2.h
index 4f853322cb7f..18000a542677 100644
--- a/include/linux/dqblk_v2.h
+++ b/include/linux/dqblk_v2.h
@@ -1,26 +1,16 @@
1/* 1/*
2 * Definitions of structures for vfsv0 quota format 2 * Definitions for vfsv0 quota format
3 */ 3 */
4 4
5#ifndef _LINUX_DQBLK_V2_H 5#ifndef _LINUX_DQBLK_V2_H
6#define _LINUX_DQBLK_V2_H 6#define _LINUX_DQBLK_V2_H
7 7
8#include <linux/types.h> 8#include <linux/dqblk_qtree.h>
9
10/* id numbers of quota format */
11#define QFMT_VFS_V0 2
12 9
13/* Numbers of blocks needed for updates */ 10/* Numbers of blocks needed for updates */
14#define V2_INIT_ALLOC 4 11#define V2_INIT_ALLOC QTREE_INIT_ALLOC
15#define V2_INIT_REWRITE 2 12#define V2_INIT_REWRITE QTREE_INIT_REWRITE
16#define V2_DEL_ALLOC 0 13#define V2_DEL_ALLOC QTREE_DEL_ALLOC
17#define V2_DEL_REWRITE 6 14#define V2_DEL_REWRITE QTREE_DEL_REWRITE
18
19/* Inmemory copy of version specific information */
20struct v2_mem_dqinfo {
21 unsigned int dqi_blocks;
22 unsigned int dqi_free_blk;
23 unsigned int dqi_free_entry;
24};
25 15
26#endif /* _LINUX_DQBLK_V2_H */ 16#endif /* _LINUX_DQBLK_V2_H */
diff --git a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
index 79a8ed8e6a7d..55026b1a40bd 100644
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -62,10 +62,11 @@ typedef enum fe_caps {
62 FE_CAN_HIERARCHY_AUTO = 0x100000, 62 FE_CAN_HIERARCHY_AUTO = 0x100000,
63 FE_CAN_8VSB = 0x200000, 63 FE_CAN_8VSB = 0x200000,
64 FE_CAN_16VSB = 0x400000, 64 FE_CAN_16VSB = 0x400000,
65 FE_HAS_EXTENDED_CAPS = 0x800000, // We need more bitspace for newer APIs, indicate this. 65 FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */
66 FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending) 66 FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */
67 FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically 67 FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */
68 FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output 68 FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */
69 FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */
69} fe_caps_t; 70} fe_caps_t;
70 71
71 72
@@ -121,15 +122,15 @@ typedef enum fe_sec_mini_cmd {
121 122
122 123
123typedef enum fe_status { 124typedef enum fe_status {
124 FE_HAS_SIGNAL = 0x01, /* found something above the noise level */ 125 FE_HAS_SIGNAL = 0x01, /* found something above the noise level */
125 FE_HAS_CARRIER = 0x02, /* found a DVB signal */ 126 FE_HAS_CARRIER = 0x02, /* found a DVB signal */
126 FE_HAS_VITERBI = 0x04, /* FEC is stable */ 127 FE_HAS_VITERBI = 0x04, /* FEC is stable */
127 FE_HAS_SYNC = 0x08, /* found sync bytes */ 128 FE_HAS_SYNC = 0x08, /* found sync bytes */
128 FE_HAS_LOCK = 0x10, /* everything's working... */ 129 FE_HAS_LOCK = 0x10, /* everything's working... */
129 FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */ 130 FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */
130 FE_REINIT = 0x40 /* frontend was reinitialized, */ 131 FE_REINIT = 0x40 /* frontend was reinitialized, */
131} fe_status_t; /* application is recommended to reset */ 132} fe_status_t; /* application is recommended to reset */
132 /* DiSEqC, tone and parameters */ 133 /* DiSEqC, tone and parameters */
133 134
134typedef enum fe_spectral_inversion { 135typedef enum fe_spectral_inversion {
135 INVERSION_OFF, 136 INVERSION_OFF,
diff --git a/include/linux/ext2_fs_sb.h b/include/linux/ext2_fs_sb.h
index f273415ab6f1..dc541f3653d1 100644
--- a/include/linux/ext2_fs_sb.h
+++ b/include/linux/ext2_fs_sb.h
@@ -108,4 +108,10 @@ struct ext2_sb_info {
108 struct ext2_reserve_window_node s_rsv_window_head; 108 struct ext2_reserve_window_node s_rsv_window_head;
109}; 109};
110 110
111static inline spinlock_t *
112sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
113{
114 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
115}
116
111#endif /* _LINUX_EXT2_FS_SB */ 117#endif /* _LINUX_EXT2_FS_SB */
diff --git a/include/linux/ext3_fs_sb.h b/include/linux/ext3_fs_sb.h
index b65f0288b842..e024e38248ff 100644
--- a/include/linux/ext3_fs_sb.h
+++ b/include/linux/ext3_fs_sb.h
@@ -83,4 +83,10 @@ struct ext3_sb_info {
83#endif 83#endif
84}; 84};
85 85
86static inline spinlock_t *
87sb_bgl_lock(struct ext3_sb_info *sbi, unsigned int block_group)
88{
89 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
90}
91
86#endif /* _LINUX_EXT3_FS_SB */ 92#endif /* _LINUX_EXT3_FS_SB */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e2170ee21e18..fb59673c60b1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -423,6 +423,9 @@ enum positive_aop_returns {
423 423
424#define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */ 424#define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */
425#define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */ 425#define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */
426#define AOP_FLAG_NOFS 0x0004 /* used by filesystem to direct
427 * helper code (eg buffer layer)
428 * to clear GFP_FS from alloc */
426 429
427/* 430/*
428 * oh the beauties of C type declarations. 431 * oh the beauties of C type declarations.
@@ -1827,7 +1830,7 @@ extern int __filemap_fdatawrite_range(struct address_space *mapping,
1827extern int filemap_fdatawrite_range(struct address_space *mapping, 1830extern int filemap_fdatawrite_range(struct address_space *mapping,
1828 loff_t start, loff_t end); 1831 loff_t start, loff_t end);
1829 1832
1830extern long do_fsync(struct file *file, int datasync); 1833extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
1831extern void sync_supers(void); 1834extern void sync_supers(void);
1832extern void sync_filesystems(int wait); 1835extern void sync_filesystems(int wait);
1833extern void __fsync_super(struct super_block *sb); 1836extern void __fsync_super(struct super_block *sb);
@@ -2035,7 +2038,7 @@ extern int page_readlink(struct dentry *, char __user *, int);
2035extern void *page_follow_link_light(struct dentry *, struct nameidata *); 2038extern void *page_follow_link_light(struct dentry *, struct nameidata *);
2036extern void page_put_link(struct dentry *, struct nameidata *, void *); 2039extern void page_put_link(struct dentry *, struct nameidata *, void *);
2037extern int __page_symlink(struct inode *inode, const char *symname, int len, 2040extern int __page_symlink(struct inode *inode, const char *symname, int len,
2038 gfp_t gfp_mask); 2041 int nofs);
2039extern int page_symlink(struct inode *inode, const char *symname, int len); 2042extern int page_symlink(struct inode *inode, const char *symname, int len);
2040extern const struct inode_operations page_symlink_inode_operations; 2043extern const struct inode_operations page_symlink_inode_operations;
2041extern int generic_readlink(struct dentry *, char __user *, int); 2044extern int generic_readlink(struct dentry *, char __user *, int);
@@ -2056,6 +2059,9 @@ extern int vfs_fstat(unsigned int, struct kstat *);
2056 2059
2057extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 2060extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
2058 unsigned long arg); 2061 unsigned long arg);
2062extern int __generic_block_fiemap(struct inode *inode,
2063 struct fiemap_extent_info *fieinfo, u64 start,
2064 u64 len, get_block_t *get_block);
2059extern int generic_block_fiemap(struct inode *inode, 2065extern int generic_block_fiemap(struct inode *inode,
2060 struct fiemap_extent_info *fieinfo, u64 start, 2066 struct fiemap_extent_info *fieinfo, u64 start,
2061 u64 len, get_block_t *get_block); 2067 u64 len, get_block_t *get_block);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index e5780f8c934a..81aa84d60c6b 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -403,15 +403,6 @@ struct hid_output_fifo {
403#define HID_STAT_ADDED 1 403#define HID_STAT_ADDED 1
404#define HID_STAT_PARSED 2 404#define HID_STAT_PARSED 2
405 405
406#define HID_CTRL_RUNNING 1
407#define HID_OUT_RUNNING 2
408#define HID_IN_RUNNING 3
409#define HID_RESET_PENDING 4
410#define HID_SUSPENDED 5
411#define HID_CLEAR_HALT 6
412#define HID_DISCONNECTED 7
413#define HID_STARTED 8
414
415struct hid_input { 406struct hid_input {
416 struct list_head list; 407 struct list_head list;
417 struct hid_report *report; 408 struct hid_report *report;
@@ -540,6 +531,8 @@ struct hid_usage_id {
540 * @name: driver name (e.g. "Footech_bar-wheel") 531 * @name: driver name (e.g. "Footech_bar-wheel")
541 * @id_table: which devices is this driver for (must be non-NULL for probe 532 * @id_table: which devices is this driver for (must be non-NULL for probe
542 * to be called) 533 * to be called)
534 * @dyn_list: list of dynamically added device ids
535 * @dyn_lock: lock protecting @dyn_list
543 * @probe: new device inserted 536 * @probe: new device inserted
544 * @remove: device removed (NULL if not a hot-plug capable driver) 537 * @remove: device removed (NULL if not a hot-plug capable driver)
545 * @report_table: on which reports to call raw_event (NULL means all) 538 * @report_table: on which reports to call raw_event (NULL means all)
@@ -567,6 +560,9 @@ struct hid_driver {
567 char *name; 560 char *name;
568 const struct hid_device_id *id_table; 561 const struct hid_device_id *id_table;
569 562
563 struct list_head dyn_list;
564 spinlock_t dyn_lock;
565
570 int (*probe)(struct hid_device *dev, const struct hid_device_id *id); 566 int (*probe)(struct hid_device *dev, const struct hid_device_id *id);
571 void (*remove)(struct hid_device *dev); 567 void (*remove)(struct hid_device *dev);
572 568
@@ -797,6 +793,8 @@ dbg_hid(const char *fmt, ...)
797 793
798#ifdef CONFIG_HID_COMPAT 794#ifdef CONFIG_HID_COMPAT
799#define HID_COMPAT_LOAD_DRIVER(name) \ 795#define HID_COMPAT_LOAD_DRIVER(name) \
796/* prototype to avoid sparse warning */ \
797extern void hid_compat_##name(void); \
800void hid_compat_##name(void) { } \ 798void hid_compat_##name(void) { } \
801EXPORT_SYMBOL(hid_compat_##name) 799EXPORT_SYMBOL(hid_compat_##name)
802#else 800#else
diff --git a/include/linux/hidraw.h b/include/linux/hidraw.h
index dbb5c8c374f0..dd8d69269176 100644
--- a/include/linux/hidraw.h
+++ b/include/linux/hidraw.h
@@ -33,6 +33,8 @@ struct hidraw_devinfo {
33#define HIDIOCGRDESCSIZE _IOR('H', 0x01, int) 33#define HIDIOCGRDESCSIZE _IOR('H', 0x01, int)
34#define HIDIOCGRDESC _IOR('H', 0x02, struct hidraw_report_descriptor) 34#define HIDIOCGRDESC _IOR('H', 0x02, struct hidraw_report_descriptor)
35#define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) 35#define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo)
36#define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len)
37#define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len)
36 38
37#define HIDRAW_FIRST_MINOR 0 39#define HIDRAW_FIRST_MINOR 0
38#define HIDRAW_MAX_DEVICES 64 40#define HIDRAW_MAX_DEVICES 64
diff --git a/include/linux/i2c/dm355evm_msp.h b/include/linux/i2c/dm355evm_msp.h
new file mode 100644
index 000000000000..372470350fab
--- /dev/null
+++ b/include/linux/i2c/dm355evm_msp.h
@@ -0,0 +1,79 @@
1/*
2 * dm355evm_msp.h - support MSP430 microcontroller on DM355EVM board
3 */
4#ifndef __LINUX_I2C_DM355EVM_MSP
5#define __LINUX_I2C_DM355EVM_MSP
6
7/*
8 * Written against Spectrum's writeup for the A4 firmware revision,
9 * and tweaked to match source and rev D2 schematics by removing CPLD
10 * and NOR flash hooks (which were last appropriate in rev B boards).
11 *
12 * Note that the firmware supports a flavor of write posting ... to be
13 * sure a write completes, issue another read or write.
14 */
15
16/* utilities to access "registers" emulated by msp430 firmware */
17extern int dm355evm_msp_write(u8 value, u8 reg);
18extern int dm355evm_msp_read(u8 reg);
19
20
21/* command/control registers */
22#define DM355EVM_MSP_COMMAND 0x00
23# define MSP_COMMAND_NULL 0
24# define MSP_COMMAND_RESET_COLD 1
25# define MSP_COMMAND_RESET_WARM 2
26# define MSP_COMMAND_RESET_WARM_I 3
27# define MSP_COMMAND_POWEROFF 4
28# define MSP_COMMAND_IR_REINIT 5
29#define DM355EVM_MSP_STATUS 0x01
30# define MSP_STATUS_BAD_OFFSET BIT(0)
31# define MSP_STATUS_BAD_COMMAND BIT(1)
32# define MSP_STATUS_POWER_ERROR BIT(2)
33# define MSP_STATUS_RXBUF_OVERRUN BIT(3)
34#define DM355EVM_MSP_RESET 0x02 /* 0 bits == in reset */
35# define MSP_RESET_DC5 BIT(0)
36# define MSP_RESET_TVP5154 BIT(2)
37# define MSP_RESET_IMAGER BIT(3)
38# define MSP_RESET_ETHERNET BIT(4)
39# define MSP_RESET_SYS BIT(5)
40# define MSP_RESET_AIC33 BIT(7)
41
42/* GPIO registers ... bit patterns mostly match the source MSP ports */
43#define DM355EVM_MSP_LED 0x03 /* active low (MSP P4) */
44#define DM355EVM_MSP_SWITCH1 0x04 /* (MSP P5, masked) */
45# define MSP_SWITCH1_SW6_1 BIT(0)
46# define MSP_SWITCH1_SW6_2 BIT(1)
47# define MSP_SWITCH1_SW6_3 BIT(2)
48# define MSP_SWITCH1_SW6_4 BIT(3)
49# define MSP_SWITCH1_J1 BIT(4) /* NTSC/PAL */
50# define MSP_SWITCH1_MSP_INT BIT(5) /* active low */
51#define DM355EVM_MSP_SWITCH2 0x05 /* (MSP P6, masked) */
52# define MSP_SWITCH2_SW10 BIT(3)
53# define MSP_SWITCH2_SW11 BIT(4)
54# define MSP_SWITCH2_SW12 BIT(5)
55# define MSP_SWITCH2_SW13 BIT(6)
56# define MSP_SWITCH2_SW14 BIT(7)
57#define DM355EVM_MSP_SDMMC 0x06 /* (MSP P2, masked) */
58# define MSP_SDMMC_0_WP BIT(1)
59# define MSP_SDMMC_0_CD BIT(2) /* active low */
60# define MSP_SDMMC_1_WP BIT(3)
61# define MSP_SDMMC_1_CD BIT(4) /* active low */
62#define DM355EVM_MSP_FIRMREV 0x07 /* not a GPIO (out of order) */
63#define DM355EVM_MSP_VIDEO_IN 0x08 /* (MSP P3, masked) */
64# define MSP_VIDEO_IMAGER BIT(7) /* low == tvp5146 */
65
66/* power supply registers are currently omitted */
67
68/* RTC registers */
69#define DM355EVM_MSP_RTC_0 0x12 /* LSB */
70#define DM355EVM_MSP_RTC_1 0x13
71#define DM355EVM_MSP_RTC_2 0x14
72#define DM355EVM_MSP_RTC_3 0x15 /* MSB */
73
74/* input event queue registers; code == ((HIGH << 8) | LOW) */
75#define DM355EVM_MSP_INPUT_COUNT 0x16 /* decrement by reading LOW */
76#define DM355EVM_MSP_INPUT_HIGH 0x17
77#define DM355EVM_MSP_INPUT_LOW 0x18
78
79#endif /* __LINUX_I2C_DM355EVM_MSP */
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index fb604dcd38f1..a8f84c01f82e 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -78,8 +78,8 @@ int twl4030_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
78 * IMPORTANT: For twl4030_i2c_write(), allocate num_bytes + 1 78 * IMPORTANT: For twl4030_i2c_write(), allocate num_bytes + 1
79 * for the value, and populate your data starting at offset 1. 79 * for the value, and populate your data starting at offset 1.
80 */ 80 */
81int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes); 81int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
82int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes); 82int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
83 83
84/*----------------------------------------------------------------------*/ 84/*----------------------------------------------------------------------*/
85 85
@@ -278,6 +278,18 @@ struct twl4030_platform_data {
278 struct twl4030_keypad_data *keypad; 278 struct twl4030_keypad_data *keypad;
279 struct twl4030_usb_data *usb; 279 struct twl4030_usb_data *usb;
280 280
281 /* LDO regulators */
282 struct regulator_init_data *vdac;
283 struct regulator_init_data *vpll1;
284 struct regulator_init_data *vpll2;
285 struct regulator_init_data *vmmc1;
286 struct regulator_init_data *vmmc2;
287 struct regulator_init_data *vsim;
288 struct regulator_init_data *vaux1;
289 struct regulator_init_data *vaux2;
290 struct regulator_init_data *vaux3;
291 struct regulator_init_data *vaux4;
292
281 /* REVISIT more to come ... _nothing_ should be hard-wired */ 293 /* REVISIT more to come ... _nothing_ should be hard-wired */
282}; 294};
283 295
@@ -285,33 +297,6 @@ struct twl4030_platform_data {
285 297
286int twl4030_sih_setup(int module); 298int twl4030_sih_setup(int module);
287 299
288/*
289 * FIXME completely stop using TWL4030_IRQ_BASE ... instead, pass the
290 * IRQ data to subsidiary devices using platform device resources.
291 */
292
293/* IRQ information-need base */
294#include <mach/irqs.h>
295/* TWL4030 interrupts */
296
297/* #define TWL4030_MODIRQ_GPIO (TWL4030_IRQ_BASE + 0) */
298#define TWL4030_MODIRQ_KEYPAD (TWL4030_IRQ_BASE + 1)
299#define TWL4030_MODIRQ_BCI (TWL4030_IRQ_BASE + 2)
300#define TWL4030_MODIRQ_MADC (TWL4030_IRQ_BASE + 3)
301/* #define TWL4030_MODIRQ_USB (TWL4030_IRQ_BASE + 4) */
302/* #define TWL4030_MODIRQ_PWR (TWL4030_IRQ_BASE + 5) */
303
304#define TWL4030_PWRIRQ_PWRBTN (TWL4030_PWR_IRQ_BASE + 0)
305/* #define TWL4030_PWRIRQ_CHG_PRES (TWL4030_PWR_IRQ_BASE + 1) */
306/* #define TWL4030_PWRIRQ_USB_PRES (TWL4030_PWR_IRQ_BASE + 2) */
307/* #define TWL4030_PWRIRQ_RTC (TWL4030_PWR_IRQ_BASE + 3) */
308/* #define TWL4030_PWRIRQ_HOT_DIE (TWL4030_PWR_IRQ_BASE + 4) */
309/* #define TWL4030_PWRIRQ_PWROK_TIMEOUT (TWL4030_PWR_IRQ_BASE + 5) */
310/* #define TWL4030_PWRIRQ_MBCHG (TWL4030_PWR_IRQ_BASE + 6) */
311/* #define TWL4030_PWRIRQ_SC_DETECT (TWL4030_PWR_IRQ_BASE + 7) */
312
313/* Rest are unsued currently*/
314
315/* Offsets to Power Registers */ 300/* Offsets to Power Registers */
316#define TWL4030_VDAC_DEV_GRP 0x3B 301#define TWL4030_VDAC_DEV_GRP 0x3B
317#define TWL4030_VDAC_DEDICATED 0x3E 302#define TWL4030_VDAC_DEDICATED 0x3E
@@ -322,10 +307,6 @@ int twl4030_sih_setup(int module);
322#define TWL4030_VAUX3_DEV_GRP 0x1F 307#define TWL4030_VAUX3_DEV_GRP 0x1F
323#define TWL4030_VAUX3_DEDICATED 0x22 308#define TWL4030_VAUX3_DEDICATED 0x22
324 309
325/* TWL4030 GPIO interrupt definitions */
326
327#define TWL4030_GPIO_IRQ_NO(n) (TWL4030_GPIO_IRQ_BASE + (n))
328
329/* 310/*
330 * Exported TWL4030 GPIO APIs 311 * Exported TWL4030 GPIO APIs
331 * 312 *
@@ -340,4 +321,38 @@ int twl4030_set_gpio_debounce(int gpio, int enable);
340 static inline int twl4030charger_usb_en(int enable) { return 0; } 321 static inline int twl4030charger_usb_en(int enable) { return 0; }
341#endif 322#endif
342 323
324/*----------------------------------------------------------------------*/
325
326/* Linux-specific regulator identifiers ... for now, we only support
327 * the LDOs, and leave the three buck converters alone. VDD1 and VDD2
328 * need to tie into hardware based voltage scaling (cpufreq etc), while
329 * VIO is generally fixed.
330 */
331
332/* EXTERNAL dc-to-dc buck converters */
333#define TWL4030_REG_VDD1 0
334#define TWL4030_REG_VDD2 1
335#define TWL4030_REG_VIO 2
336
337/* EXTERNAL LDOs */
338#define TWL4030_REG_VDAC 3
339#define TWL4030_REG_VPLL1 4
340#define TWL4030_REG_VPLL2 5 /* not on all chips */
341#define TWL4030_REG_VMMC1 6
342#define TWL4030_REG_VMMC2 7 /* not on all chips */
343#define TWL4030_REG_VSIM 8 /* not on all chips */
344#define TWL4030_REG_VAUX1 9 /* not on all chips */
345#define TWL4030_REG_VAUX2_4030 10 /* (twl4030-specific) */
346#define TWL4030_REG_VAUX2 11 /* (twl5030 and newer) */
347#define TWL4030_REG_VAUX3 12 /* not on all chips */
348#define TWL4030_REG_VAUX4 13 /* not on all chips */
349
350/* INTERNAL LDOs */
351#define TWL4030_REG_VINTANA1 14
352#define TWL4030_REG_VINTANA2 15
353#define TWL4030_REG_VINTDIG 16
354#define TWL4030_REG_VUSB1V5 17
355#define TWL4030_REG_VUSB1V8 18
356#define TWL4030_REG_VUSB3V1 19
357
343#endif /* End of __TWL4030_H */ 358#endif /* End of __TWL4030_H */
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 3d017cfd245b..c4f6c101dbcd 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -23,8 +23,6 @@
23#define _INTEL_IOMMU_H_ 23#define _INTEL_IOMMU_H_
24 24
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/msi.h>
27#include <linux/sysdev.h>
28#include <linux/iova.h> 26#include <linux/iova.h>
29#include <linux/io.h> 27#include <linux/io.h>
30#include <linux/dma_remapping.h> 28#include <linux/dma_remapping.h>
@@ -289,10 +287,10 @@ struct intel_iommu {
289 void __iomem *reg; /* Pointer to hardware regs, virtual addr */ 287 void __iomem *reg; /* Pointer to hardware regs, virtual addr */
290 u64 cap; 288 u64 cap;
291 u64 ecap; 289 u64 ecap;
292 int seg;
293 u32 gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */ 290 u32 gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */
294 spinlock_t register_lock; /* protect register handling */ 291 spinlock_t register_lock; /* protect register handling */
295 int seq_id; /* sequence id of the iommu */ 292 int seq_id; /* sequence id of the iommu */
293 int agaw; /* agaw of this iommu */
296 294
297#ifdef CONFIG_DMAR 295#ifdef CONFIG_DMAR
298 unsigned long *domain_ids; /* bitmap of domains */ 296 unsigned long *domain_ids; /* bitmap of domains */
@@ -302,8 +300,6 @@ struct intel_iommu {
302 300
303 unsigned int irq; 301 unsigned int irq;
304 unsigned char name[7]; /* Device Name */ 302 unsigned char name[7]; /* Device Name */
305 struct msi_msg saved_msg;
306 struct sys_device sysdev;
307 struct iommu_flush flush; 303 struct iommu_flush flush;
308#endif 304#endif
309 struct q_inval *qi; /* Queued invalidation info */ 305 struct q_inval *qi; /* Queued invalidation info */
@@ -334,25 +330,6 @@ extern int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
334 330
335extern void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); 331extern void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
336 332
337void intel_iommu_domain_exit(struct dmar_domain *domain);
338struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev);
339int intel_iommu_context_mapping(struct dmar_domain *domain,
340 struct pci_dev *pdev);
341int intel_iommu_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
342 u64 hpa, size_t size, int prot);
343void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn);
344struct dmar_domain *intel_iommu_find_domain(struct pci_dev *pdev);
345u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova);
346
347#ifdef CONFIG_DMAR
348int intel_iommu_found(void);
349#else /* CONFIG_DMAR */
350static inline int intel_iommu_found(void)
351{
352 return 0;
353}
354#endif /* CONFIG_DMAR */
355
356extern void *intel_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t); 333extern void *intel_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
357extern void intel_free_coherent(struct device *, size_t, void *, dma_addr_t); 334extern void intel_free_coherent(struct device *, size_t, void *, dma_addr_t);
358extern dma_addr_t intel_map_single(struct device *, phys_addr_t, size_t, int); 335extern dma_addr_t intel_map_single(struct device *, phys_addr_t, size_t, int);
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 990355fbc54e..0702c4d7bdf0 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -109,7 +109,7 @@ extern void enable_irq(unsigned int irq);
109 109
110#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) 110#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
111 111
112extern cpumask_t irq_default_affinity; 112extern cpumask_var_t irq_default_affinity;
113 113
114extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); 114extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask);
115extern int irq_can_set_affinity(unsigned int irq); 115extern int irq_can_set_affinity(unsigned int irq);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
new file mode 100644
index 000000000000..8a7bfb1b6ca0
--- /dev/null
+++ b/include/linux/iommu.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * 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 License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#ifndef __LINUX_IOMMU_H
20#define __LINUX_IOMMU_H
21
22#define IOMMU_READ (1)
23#define IOMMU_WRITE (2)
24
25struct device;
26
27struct iommu_domain {
28 void *priv;
29};
30
31struct iommu_ops {
32 int (*domain_init)(struct iommu_domain *domain);
33 void (*domain_destroy)(struct iommu_domain *domain);
34 int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
35 void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
36 int (*map)(struct iommu_domain *domain, unsigned long iova,
37 phys_addr_t paddr, size_t size, int prot);
38 void (*unmap)(struct iommu_domain *domain, unsigned long iova,
39 size_t size);
40 phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,
41 unsigned long iova);
42};
43
44#ifdef CONFIG_IOMMU_API
45
46extern void register_iommu(struct iommu_ops *ops);
47extern bool iommu_found(void);
48extern struct iommu_domain *iommu_domain_alloc(void);
49extern void iommu_domain_free(struct iommu_domain *domain);
50extern int iommu_attach_device(struct iommu_domain *domain,
51 struct device *dev);
52extern void iommu_detach_device(struct iommu_domain *domain,
53 struct device *dev);
54extern int iommu_map_range(struct iommu_domain *domain, unsigned long iova,
55 phys_addr_t paddr, size_t size, int prot);
56extern void iommu_unmap_range(struct iommu_domain *domain, unsigned long iova,
57 size_t size);
58extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
59 unsigned long iova);
60
61#else /* CONFIG_IOMMU_API */
62
63static inline void register_iommu(struct iommu_ops *ops)
64{
65}
66
67static inline bool iommu_found(void)
68{
69 return false;
70}
71
72static inline struct iommu_domain *iommu_domain_alloc(void)
73{
74 return NULL;
75}
76
77static inline void iommu_domain_free(struct iommu_domain *domain)
78{
79}
80
81static inline int iommu_attach_device(struct iommu_domain *domain,
82 struct device *dev)
83{
84 return -ENODEV;
85}
86
87static inline void iommu_detach_device(struct iommu_domain *domain,
88 struct device *dev)
89{
90}
91
92static inline int iommu_map_range(struct iommu_domain *domain,
93 unsigned long iova, phys_addr_t paddr,
94 size_t size, int prot)
95{
96 return -ENODEV;
97}
98
99static inline void iommu_unmap_range(struct iommu_domain *domain,
100 unsigned long iova, size_t size)
101{
102}
103
104static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
105 unsigned long iova)
106{
107 return 0;
108}
109
110#endif /* CONFIG_IOMMU_API */
111
112#endif /* __LINUX_IOMMU_H */
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index c7d106ef22e2..34456476e761 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -329,6 +329,7 @@ enum jbd_state_bits {
329 BH_State, /* Pins most journal_head state */ 329 BH_State, /* Pins most journal_head state */
330 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */ 330 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
331 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */ 331 BH_Unshadow, /* Dummy bit, for BJ_Shadow wakeup filtering */
332 BH_JBDPrivateStart, /* First bit available for private use by FS */
332}; 333};
333 334
334BUFFER_FNS(JBD, jbd) 335BUFFER_FNS(JBD, jbd)
@@ -1007,6 +1008,35 @@ int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
1007int __jbd2_journal_remove_checkpoint(struct journal_head *); 1008int __jbd2_journal_remove_checkpoint(struct journal_head *);
1008void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *); 1009void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
1009 1010
1011
1012/*
1013 * Triggers
1014 */
1015
1016struct jbd2_buffer_trigger_type {
1017 /*
1018 * Fired just before a buffer is written to the journal.
1019 * mapped_data is a mapped buffer that is the frozen data for
1020 * commit.
1021 */
1022 void (*t_commit)(struct jbd2_buffer_trigger_type *type,
1023 struct buffer_head *bh, void *mapped_data,
1024 size_t size);
1025
1026 /*
1027 * Fired during journal abort for dirty buffers that will not be
1028 * committed.
1029 */
1030 void (*t_abort)(struct jbd2_buffer_trigger_type *type,
1031 struct buffer_head *bh);
1032};
1033
1034extern void jbd2_buffer_commit_trigger(struct journal_head *jh,
1035 void *mapped_data,
1036 struct jbd2_buffer_trigger_type *triggers);
1037extern void jbd2_buffer_abort_trigger(struct journal_head *jh,
1038 struct jbd2_buffer_trigger_type *triggers);
1039
1010/* Buffer IO */ 1040/* Buffer IO */
1011extern int 1041extern int
1012jbd2_journal_write_metadata_buffer(transaction_t *transaction, 1042jbd2_journal_write_metadata_buffer(transaction_t *transaction,
@@ -1045,6 +1075,8 @@ extern int jbd2_journal_extend (handle_t *, int nblocks);
1045extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *); 1075extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
1046extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *); 1076extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
1047extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *); 1077extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
1078void jbd2_journal_set_triggers(struct buffer_head *,
1079 struct jbd2_buffer_trigger_type *type);
1048extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *); 1080extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
1049extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *); 1081extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *);
1050extern int jbd2_journal_forget (handle_t *, struct buffer_head *); 1082extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
diff --git a/include/linux/journal-head.h b/include/linux/journal-head.h
index bb70ebb6a2d5..525aac3c97df 100644
--- a/include/linux/journal-head.h
+++ b/include/linux/journal-head.h
@@ -12,6 +12,8 @@
12 12
13typedef unsigned int tid_t; /* Unique transaction ID */ 13typedef unsigned int tid_t; /* Unique transaction ID */
14typedef struct transaction_s transaction_t; /* Compound transaction type */ 14typedef struct transaction_s transaction_t; /* Compound transaction type */
15
16
15struct buffer_head; 17struct buffer_head;
16 18
17struct journal_head { 19struct journal_head {
@@ -87,6 +89,12 @@ struct journal_head {
87 * [j_list_lock] 89 * [j_list_lock]
88 */ 90 */
89 struct journal_head *b_cpnext, *b_cpprev; 91 struct journal_head *b_cpnext, *b_cpprev;
92
93 /* Trigger type */
94 struct jbd2_buffer_trigger_type *b_triggers;
95
96 /* Trigger type for the committing transaction's frozen data */
97 struct jbd2_buffer_trigger_type *b_frozen_triggers;
90}; 98};
91 99
92#endif /* JOURNAL_HEAD_H_INCLUDED */ 100#endif /* JOURNAL_HEAD_H_INCLUDED */
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 4ee4b3d2316f..570d20413119 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -79,10 +79,13 @@ static inline unsigned int kstat_irqs(unsigned int irq)
79} 79}
80 80
81extern unsigned long long task_delta_exec(struct task_struct *); 81extern unsigned long long task_delta_exec(struct task_struct *);
82extern void account_user_time(struct task_struct *, cputime_t); 82extern void account_user_time(struct task_struct *, cputime_t, cputime_t);
83extern void account_user_time_scaled(struct task_struct *, cputime_t); 83extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t);
84extern void account_system_time(struct task_struct *, int, cputime_t); 84extern void account_steal_time(cputime_t);
85extern void account_system_time_scaled(struct task_struct *, cputime_t); 85extern void account_idle_time(cputime_t);
86extern void account_steal_time(struct task_struct *, cputime_t); 86
87extern void account_process_tick(struct task_struct *, int user);
88extern void account_steal_ticks(unsigned long ticks);
89extern void account_idle_ticks(unsigned long ticks);
87 90
88#endif /* _LINUX_KERNEL_STAT_H */ 91#endif /* _LINUX_KERNEL_STAT_H */
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index eafabd5c66b2..ec49d0be7f52 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -316,6 +316,7 @@ struct kvm_assigned_dev_kernel {
316#define KVM_ASSIGNED_DEV_HOST_MSI (1 << 9) 316#define KVM_ASSIGNED_DEV_HOST_MSI (1 << 9)
317 unsigned long irq_requested_type; 317 unsigned long irq_requested_type;
318 int irq_source_id; 318 int irq_source_id;
319 int flags;
319 struct pci_dev *dev; 320 struct pci_dev *dev;
320 struct kvm *kvm; 321 struct kvm *kvm;
321}; 322};
@@ -327,13 +328,16 @@ void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian);
327int kvm_request_irq_source_id(struct kvm *kvm); 328int kvm_request_irq_source_id(struct kvm *kvm);
328void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); 329void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
329 330
330#ifdef CONFIG_DMAR 331#ifdef CONFIG_IOMMU_API
331int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, 332int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
332 unsigned long npages); 333 unsigned long npages);
333int kvm_iommu_map_guest(struct kvm *kvm, 334int kvm_iommu_map_guest(struct kvm *kvm);
334 struct kvm_assigned_dev_kernel *assigned_dev);
335int kvm_iommu_unmap_guest(struct kvm *kvm); 335int kvm_iommu_unmap_guest(struct kvm *kvm);
336#else /* CONFIG_DMAR */ 336int kvm_assign_device(struct kvm *kvm,
337 struct kvm_assigned_dev_kernel *assigned_dev);
338int kvm_deassign_device(struct kvm *kvm,
339 struct kvm_assigned_dev_kernel *assigned_dev);
340#else /* CONFIG_IOMMU_API */
337static inline int kvm_iommu_map_pages(struct kvm *kvm, 341static inline int kvm_iommu_map_pages(struct kvm *kvm,
338 gfn_t base_gfn, 342 gfn_t base_gfn,
339 unsigned long npages) 343 unsigned long npages)
@@ -341,9 +345,7 @@ static inline int kvm_iommu_map_pages(struct kvm *kvm,
341 return 0; 345 return 0;
342} 346}
343 347
344static inline int kvm_iommu_map_guest(struct kvm *kvm, 348static inline int kvm_iommu_map_guest(struct kvm *kvm)
345 struct kvm_assigned_dev_kernel
346 *assigned_dev)
347{ 349{
348 return -ENODEV; 350 return -ENODEV;
349} 351}
@@ -352,7 +354,19 @@ static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
352{ 354{
353 return 0; 355 return 0;
354} 356}
355#endif /* CONFIG_DMAR */ 357
358static inline int kvm_assign_device(struct kvm *kvm,
359 struct kvm_assigned_dev_kernel *assigned_dev)
360{
361 return 0;
362}
363
364static inline int kvm_deassign_device(struct kvm *kvm,
365 struct kvm_assigned_dev_kernel *assigned_dev)
366{
367 return 0;
368}
369#endif /* CONFIG_IOMMU_API */
356 370
357static inline void kvm_guest_enter(void) 371static inline void kvm_guest_enter(void)
358{ 372{
diff --git a/include/linux/mfd/da903x.h b/include/linux/mfd/da903x.h
index cad314c12439..115dbe965082 100644
--- a/include/linux/mfd/da903x.h
+++ b/include/linux/mfd/da903x.h
@@ -32,6 +32,7 @@ enum {
32 DA9030_ID_LDO18, 32 DA9030_ID_LDO18,
33 DA9030_ID_LDO19, 33 DA9030_ID_LDO19,
34 DA9030_ID_LDO_INT, /* LDO Internal */ 34 DA9030_ID_LDO_INT, /* LDO Internal */
35 DA9030_ID_BAT, /* battery charger */
35 36
36 DA9034_ID_LED_1, 37 DA9034_ID_LED_1,
37 DA9034_ID_LED_2, 38 DA9034_ID_LED_2,
@@ -93,6 +94,43 @@ struct da9034_touch_pdata {
93 int y_inverted; 94 int y_inverted;
94}; 95};
95 96
97/* DA9030 battery charger data */
98struct power_supply_info;
99
100struct da9030_battery_info {
101 /* battery parameters */
102 struct power_supply_info *battery_info;
103
104 /* current and voltage to use for battery charging */
105 unsigned int charge_milliamp;
106 unsigned int charge_millivolt;
107
108 /* voltage thresholds (in millivolts) */
109 int vbat_low;
110 int vbat_crit;
111 int vbat_charge_start;
112 int vbat_charge_stop;
113 int vbat_charge_restart;
114
115 /* battery nominal minimal and maximal voltages in millivolts */
116 int vcharge_min;
117 int vcharge_max;
118
119 /* Temperature thresholds. These are DA9030 register values
120 "as is" and should be measured for each battery type */
121 int tbat_low;
122 int tbat_high;
123 int tbat_restart;
124
125
126 /* battery monitor interval (seconds) */
127 unsigned int batmon_interval;
128
129 /* platform callbacks for battery low and critical events */
130 void (*battery_low)(void);
131 void (*battery_critical)(void);
132};
133
96struct da903x_subdev_info { 134struct da903x_subdev_info {
97 int id; 135 int id;
98 const char *name; 136 const char *name;
@@ -190,11 +228,13 @@ extern int da903x_unregister_notifier(struct device *dev,
190extern int da903x_query_status(struct device *dev, unsigned int status); 228extern int da903x_query_status(struct device *dev, unsigned int status);
191 229
192 230
193/* NOTE: the two functions below are not intended for use outside 231/* NOTE: the functions below are not intended for use outside
194 * of the DA9034 sub-device drivers 232 * of the DA903x sub-device drivers
195 */ 233 */
196extern int da903x_write(struct device *dev, int reg, uint8_t val); 234extern int da903x_write(struct device *dev, int reg, uint8_t val);
235extern int da903x_writes(struct device *dev, int reg, int len, uint8_t *val);
197extern int da903x_read(struct device *dev, int reg, uint8_t *val); 236extern int da903x_read(struct device *dev, int reg, uint8_t *val);
237extern int da903x_reads(struct device *dev, int reg, int len, uint8_t *val);
198extern int da903x_update(struct device *dev, int reg, uint8_t val, uint8_t mask); 238extern int da903x_update(struct device *dev, int reg, uint8_t val, uint8_t mask);
199extern int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask); 239extern int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
200extern int da903x_clr_bits(struct device *dev, int reg, uint8_t bit_mask); 240extern int da903x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
diff --git a/include/linux/mfd/wm8350/comparator.h b/include/linux/mfd/wm8350/comparator.h
index 053788649452..54bc5d0fd502 100644
--- a/include/linux/mfd/wm8350/comparator.h
+++ b/include/linux/mfd/wm8350/comparator.h
@@ -164,4 +164,12 @@
164#define WM8350_AUXADC_BATT 6 164#define WM8350_AUXADC_BATT 6
165#define WM8350_AUXADC_TEMP 7 165#define WM8350_AUXADC_TEMP 7
166 166
167struct wm8350;
168
169/*
170 * AUX ADC Readback
171 */
172int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale,
173 int vref);
174
167#endif 175#endif
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 6ebf97f2a475..980669d50dca 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -29,6 +29,7 @@
29 */ 29 */
30#define WM8350_RESET_ID 0x00 30#define WM8350_RESET_ID 0x00
31#define WM8350_ID 0x01 31#define WM8350_ID 0x01
32#define WM8350_REVISION 0x02
32#define WM8350_SYSTEM_CONTROL_1 0x03 33#define WM8350_SYSTEM_CONTROL_1 0x03
33#define WM8350_SYSTEM_CONTROL_2 0x04 34#define WM8350_SYSTEM_CONTROL_2 0x04
34#define WM8350_SYSTEM_HIBERNATE 0x05 35#define WM8350_SYSTEM_HIBERNATE 0x05
@@ -57,6 +58,10 @@
57#define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25 58#define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25
58#define WM8350_GPIO_INT_STATUS_MASK 0x26 59#define WM8350_GPIO_INT_STATUS_MASK 0x26
59#define WM8350_COMPARATOR_INT_STATUS_MASK 0x27 60#define WM8350_COMPARATOR_INT_STATUS_MASK 0x27
61#define WM8350_CHARGER_OVERRIDES 0xE2
62#define WM8350_MISC_OVERRIDES 0xE3
63#define WM8350_COMPARATOR_OVERRIDES 0xE7
64#define WM8350_STATE_MACHINE_STATUS 0xE9
60 65
61#define WM8350_MAX_REGISTER 0xFF 66#define WM8350_MAX_REGISTER 0xFF
62 67
@@ -77,6 +82,11 @@
77#define WM8350_CUST_ID_MASK 0x00FF 82#define WM8350_CUST_ID_MASK 0x00FF
78 83
79/* 84/*
85 * R2 (0x02) - Revision
86 */
87#define WM8350_MASK_REV_MASK 0x00FF
88
89/*
80 * R3 (0x03) - System Control 1 90 * R3 (0x03) - System Control 1
81 */ 91 */
82#define WM8350_CHIP_ON 0x8000 92#define WM8350_CHIP_ON 0x8000
@@ -523,6 +533,35 @@
523#define WM8350_DC2_STS 0x0002 533#define WM8350_DC2_STS 0x0002
524#define WM8350_DC1_STS 0x0001 534#define WM8350_DC1_STS 0x0001
525 535
536/*
537 * R226 (0xE2) - Charger status
538 */
539#define WM8350_CHG_BATT_HOT_OVRDE 0x8000
540#define WM8350_CHG_BATT_COLD_OVRDE 0x4000
541
542/*
543 * R227 (0xE3) - Misc Overrides
544 */
545#define WM8350_USB_LIMIT_OVRDE 0x0400
546
547/*
548 * R227 (0xE7) - Comparator Overrides
549 */
550#define WM8350_USB_FB_OVRDE 0x8000
551#define WM8350_WALL_FB_OVRDE 0x4000
552#define WM8350_BATT_FB_OVRDE 0x2000
553
554
555/*
556 * R233 (0xE9) - State Machinine Status
557 */
558#define WM8350_USB_SM_MASK 0x0700
559#define WM8350_USB_SM_SHIFT 8
560
561#define WM8350_USB_SM_100_SLV 1
562#define WM8350_USB_SM_500_SLV 5
563#define WM8350_USB_SM_STDBY_SLV 7
564
526/* WM8350 wake up conditions */ 565/* WM8350 wake up conditions */
527#define WM8350_IRQ_WKUP_OFF_STATE 43 566#define WM8350_IRQ_WKUP_OFF_STATE 43
528#define WM8350_IRQ_WKUP_HIB_STATE 44 567#define WM8350_IRQ_WKUP_HIB_STATE 44
@@ -536,6 +575,7 @@
536#define WM8350_REV_E 0x4 575#define WM8350_REV_E 0x4
537#define WM8350_REV_F 0x5 576#define WM8350_REV_F 0x5
538#define WM8350_REV_G 0x6 577#define WM8350_REV_G 0x6
578#define WM8350_REV_H 0x7
539 579
540#define WM8350_NUM_IRQ 63 580#define WM8350_NUM_IRQ 63
541 581
@@ -549,6 +589,14 @@ extern const u16 wm8350_mode0_defaults[];
549extern const u16 wm8350_mode1_defaults[]; 589extern const u16 wm8350_mode1_defaults[];
550extern const u16 wm8350_mode2_defaults[]; 590extern const u16 wm8350_mode2_defaults[];
551extern const u16 wm8350_mode3_defaults[]; 591extern const u16 wm8350_mode3_defaults[];
592extern const u16 wm8351_mode0_defaults[];
593extern const u16 wm8351_mode1_defaults[];
594extern const u16 wm8351_mode2_defaults[];
595extern const u16 wm8351_mode3_defaults[];
596extern const u16 wm8352_mode0_defaults[];
597extern const u16 wm8352_mode1_defaults[];
598extern const u16 wm8352_mode2_defaults[];
599extern const u16 wm8352_mode3_defaults[];
552 600
553struct wm8350; 601struct wm8350;
554 602
@@ -558,8 +606,6 @@ struct wm8350_irq {
558}; 606};
559 607
560struct wm8350 { 608struct wm8350 {
561 int rev; /* chip revision */
562
563 struct device *dev; 609 struct device *dev;
564 610
565 /* device IO */ 611 /* device IO */
@@ -572,6 +618,8 @@ struct wm8350 {
572 void *src); 618 void *src);
573 u16 *reg_cache; 619 u16 *reg_cache;
574 620
621 struct mutex auxadc_mutex;
622
575 /* Interrupt handling */ 623 /* Interrupt handling */
576 struct work_struct irq_work; 624 struct work_struct irq_work;
577 struct mutex irq_mutex; /* IRQ table mutex */ 625 struct mutex irq_mutex; /* IRQ table mutex */
diff --git a/include/linux/mfd/wm8350/pmic.h b/include/linux/mfd/wm8350/pmic.h
index 69b69e07f62f..96acbfc8aa12 100644
--- a/include/linux/mfd/wm8350/pmic.h
+++ b/include/linux/mfd/wm8350/pmic.h
@@ -701,6 +701,10 @@ struct platform_device;
701struct regulator_init_data; 701struct regulator_init_data;
702 702
703struct wm8350_pmic { 703struct wm8350_pmic {
704 /* Number of regulators of each type on this device */
705 int max_dcdc;
706 int max_isink;
707
704 /* ISINK to DCDC mapping */ 708 /* ISINK to DCDC mapping */
705 int isink_A_dcdc; 709 int isink_A_dcdc;
706 int isink_B_dcdc; 710 int isink_B_dcdc;
diff --git a/include/linux/mfd/wm8350/supply.h b/include/linux/mfd/wm8350/supply.h
index 1c8f3cde79b0..2b9479310bbd 100644
--- a/include/linux/mfd/wm8350/supply.h
+++ b/include/linux/mfd/wm8350/supply.h
@@ -13,7 +13,8 @@
13#ifndef __LINUX_MFD_WM8350_SUPPLY_H_ 13#ifndef __LINUX_MFD_WM8350_SUPPLY_H_
14#define __LINUX_MFD_WM8350_SUPPLY_H_ 14#define __LINUX_MFD_WM8350_SUPPLY_H_
15 15
16#include <linux/platform_device.h> 16#include <linux/mutex.h>
17#include <linux/power_supply.h>
17 18
18/* 19/*
19 * Charger registers 20 * Charger registers
@@ -104,8 +105,30 @@
104#define WM8350_IRQ_EXT_WALL_FB 37 105#define WM8350_IRQ_EXT_WALL_FB 37
105#define WM8350_IRQ_EXT_BAT_FB 38 106#define WM8350_IRQ_EXT_BAT_FB 38
106 107
108/*
109 * Policy to control charger state machine.
110 */
111struct wm8350_charger_policy {
112
113 /* charger state machine policy - set in machine driver */
114 int eoc_mA; /* end of charge current (mA) */
115 int charge_mV; /* charge voltage */
116 int fast_limit_mA; /* fast charge current limit */
117 int fast_limit_USB_mA; /* USB fast charge current limit */
118 int charge_timeout; /* charge timeout (mins) */
119 int trickle_start_mV; /* trickle charge starts at mV */
120 int trickle_charge_mA; /* trickle charge current */
121 int trickle_charge_USB_mA; /* USB trickle charge current */
122};
123
107struct wm8350_power { 124struct wm8350_power {
108 struct platform_device *pdev; 125 struct platform_device *pdev;
126 struct power_supply battery;
127 struct power_supply usb;
128 struct power_supply ac;
129 struct wm8350_charger_policy *policy;
130
131 int rev_g_coeff;
109}; 132};
110 133
111#endif 134#endif
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 143cebf0586f..7ac8b500d55c 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -151,4 +151,6 @@ static inline void mmc_claim_host(struct mmc_host *host)
151 __mmc_claim_host(host, NULL); 151 __mmc_claim_host(host, NULL);
152} 152}
153 153
154extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
155
154#endif 156#endif
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index f842f234e44f..4e457256bd33 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -41,6 +41,7 @@ struct mmc_ios {
41 41
42#define MMC_BUS_WIDTH_1 0 42#define MMC_BUS_WIDTH_1 0
43#define MMC_BUS_WIDTH_4 2 43#define MMC_BUS_WIDTH_4 2
44#define MMC_BUS_WIDTH_8 3
44 45
45 unsigned char timing; /* timing specification used */ 46 unsigned char timing; /* timing specification used */
46 47
@@ -116,6 +117,7 @@ struct mmc_host {
116#define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */ 117#define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */
117#define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */ 118#define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */
118#define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */ 119#define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */
120#define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */
119 121
120 /* host specific block data */ 122 /* host specific block data */
121 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ 123 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
index eb1033957486..c1f40c2f7ffb 100644
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -13,6 +13,9 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
13 char *secstrings, 13 char *secstrings,
14 struct module *mod); 14 struct module *mod);
15 15
16/* Additional bytes needed by arch in front of individual sections */
17unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
18
16/* Allocator used for allocating struct module, core sections and init 19/* Allocator used for allocating struct module, core sections and init
17 sections. Returns NULL on failure. */ 20 sections. Returns NULL on failure. */
18void *module_alloc(unsigned long size); 21void *module_alloc(unsigned long size);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 41e1224651cf..c28bbba3c23d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -313,10 +313,11 @@ struct napi_struct {
313#ifdef CONFIG_NETPOLL 313#ifdef CONFIG_NETPOLL
314 spinlock_t poll_lock; 314 spinlock_t poll_lock;
315 int poll_owner; 315 int poll_owner;
316 struct net_device *dev;
317#endif 316#endif
317 struct net_device *dev;
318 struct list_head dev_list; 318 struct list_head dev_list;
319 struct sk_buff *gro_list; 319 struct sk_buff *gro_list;
320 struct sk_buff *skb;
320}; 321};
321 322
322enum 323enum
@@ -990,6 +991,9 @@ struct napi_gro_cb {
990 991
991 /* Number of segments aggregated. */ 992 /* Number of segments aggregated. */
992 int count; 993 int count;
994
995 /* Free the skb? */
996 int free;
993}; 997};
994 998
995#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb) 999#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb)
@@ -1011,6 +1015,14 @@ struct packet_type {
1011 struct list_head list; 1015 struct list_head list;
1012}; 1016};
1013 1017
1018struct napi_gro_fraginfo {
1019 skb_frag_t frags[MAX_SKB_FRAGS];
1020 unsigned int nr_frags;
1021 unsigned int ip_summed;
1022 unsigned int len;
1023 __wsum csum;
1024};
1025
1014#include <linux/interrupt.h> 1026#include <linux/interrupt.h>
1015#include <linux/notifier.h> 1027#include <linux/notifier.h>
1016 1028
@@ -1363,6 +1375,8 @@ extern int netif_receive_skb(struct sk_buff *skb);
1363extern void napi_gro_flush(struct napi_struct *napi); 1375extern void napi_gro_flush(struct napi_struct *napi);
1364extern int napi_gro_receive(struct napi_struct *napi, 1376extern int napi_gro_receive(struct napi_struct *napi,
1365 struct sk_buff *skb); 1377 struct sk_buff *skb);
1378extern int napi_gro_frags(struct napi_struct *napi,
1379 struct napi_gro_fraginfo *info);
1366extern void netif_nit_deliver(struct sk_buff *skb); 1380extern void netif_nit_deliver(struct sk_buff *skb);
1367extern int dev_valid_name(const char *name); 1381extern int dev_valid_name(const char *name);
1368extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 1382extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 709742be02f0..01ca0856caff 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -241,7 +241,8 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t start,
241unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, 241unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
242 int tag, unsigned int nr_pages, struct page **pages); 242 int tag, unsigned int nr_pages, struct page **pages);
243 243
244struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index); 244struct page *grab_cache_page_write_begin(struct address_space *mapping,
245 pgoff_t index, unsigned flags);
245 246
246/* 247/*
247 * Returns locked page at given index in given cache, creating it if needed. 248 * Returns locked page at given index in given cache, creating it if needed.
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f9348cba6dc1..8ff25e0e7f7a 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -45,6 +45,7 @@ enum {
45 POWER_SUPPLY_HEALTH_DEAD, 45 POWER_SUPPLY_HEALTH_DEAD,
46 POWER_SUPPLY_HEALTH_OVERVOLTAGE, 46 POWER_SUPPLY_HEALTH_OVERVOLTAGE,
47 POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, 47 POWER_SUPPLY_HEALTH_UNSPEC_FAILURE,
48 POWER_SUPPLY_HEALTH_COLD,
48}; 49};
49 50
50enum { 51enum {
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 40401b554484..d72d5d84fde5 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -36,17 +36,7 @@
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/types.h> 37#include <linux/types.h>
38 38
39#define __DQUOT_VERSION__ "dquot_6.5.1" 39#define __DQUOT_VERSION__ "dquot_6.5.2"
40#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
41
42/* Size of blocks in which are counted size limits */
43#define QUOTABLOCK_BITS 10
44#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
45
46/* Conversion routines from and to quota blocks */
47#define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
48#define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
49#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
50 40
51#define MAXQUOTAS 2 41#define MAXQUOTAS 2
52#define USRQUOTA 0 /* element used for user quotas */ 42#define USRQUOTA 0 /* element used for user quotas */
@@ -80,16 +70,34 @@
80#define Q_GETQUOTA 0x800007 /* get user quota structure */ 70#define Q_GETQUOTA 0x800007 /* get user quota structure */
81#define Q_SETQUOTA 0x800008 /* set user quota structure */ 71#define Q_SETQUOTA 0x800008 /* set user quota structure */
82 72
73/* Quota format type IDs */
74#define QFMT_VFS_OLD 1
75#define QFMT_VFS_V0 2
76
77/* Size of block in which space limits are passed through the quota
78 * interface */
79#define QIF_DQBLKSIZE_BITS 10
80#define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
81
83/* 82/*
84 * Quota structure used for communication with userspace via quotactl 83 * Quota structure used for communication with userspace via quotactl
85 * Following flags are used to specify which fields are valid 84 * Following flags are used to specify which fields are valid
86 */ 85 */
87#define QIF_BLIMITS 1 86enum {
88#define QIF_SPACE 2 87 QIF_BLIMITS_B = 0,
89#define QIF_ILIMITS 4 88 QIF_SPACE_B,
90#define QIF_INODES 8 89 QIF_ILIMITS_B,
91#define QIF_BTIME 16 90 QIF_INODES_B,
92#define QIF_ITIME 32 91 QIF_BTIME_B,
92 QIF_ITIME_B,
93};
94
95#define QIF_BLIMITS (1 << QIF_BLIMITS_B)
96#define QIF_SPACE (1 << QIF_SPACE_B)
97#define QIF_ILIMITS (1 << QIF_ILIMITS_B)
98#define QIF_INODES (1 << QIF_INODES_B)
99#define QIF_BTIME (1 << QIF_BTIME_B)
100#define QIF_ITIME (1 << QIF_ITIME_B)
93#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS) 101#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
94#define QIF_USAGE (QIF_SPACE | QIF_INODES) 102#define QIF_USAGE (QIF_SPACE | QIF_INODES)
95#define QIF_TIMES (QIF_BTIME | QIF_ITIME) 103#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
@@ -172,7 +180,7 @@ enum {
172#include <asm/atomic.h> 180#include <asm/atomic.h>
173 181
174typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ 182typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
175typedef __u64 qsize_t; /* Type in which we store sizes */ 183typedef long long qsize_t; /* Type in which we store sizes */
176 184
177extern spinlock_t dq_data_lock; 185extern spinlock_t dq_data_lock;
178 186
@@ -187,12 +195,12 @@ extern spinlock_t dq_data_lock;
187 * Data for one user/group kept in memory 195 * Data for one user/group kept in memory
188 */ 196 */
189struct mem_dqblk { 197struct mem_dqblk {
190 __u32 dqb_bhardlimit; /* absolute limit on disk blks alloc */ 198 qsize_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
191 __u32 dqb_bsoftlimit; /* preferred limit on disk blks */ 199 qsize_t dqb_bsoftlimit; /* preferred limit on disk blks */
192 qsize_t dqb_curspace; /* current used space */ 200 qsize_t dqb_curspace; /* current used space */
193 __u32 dqb_ihardlimit; /* absolute limit on allocated inodes */ 201 qsize_t dqb_ihardlimit; /* absolute limit on allocated inodes */
194 __u32 dqb_isoftlimit; /* preferred inode limit */ 202 qsize_t dqb_isoftlimit; /* preferred inode limit */
195 __u32 dqb_curinodes; /* current # allocated inodes */ 203 qsize_t dqb_curinodes; /* current # allocated inodes */
196 time_t dqb_btime; /* time limit for excessive disk use */ 204 time_t dqb_btime; /* time limit for excessive disk use */
197 time_t dqb_itime; /* time limit for excessive inode use */ 205 time_t dqb_itime; /* time limit for excessive inode use */
198}; 206};
@@ -212,10 +220,7 @@ struct mem_dqinfo {
212 unsigned int dqi_igrace; 220 unsigned int dqi_igrace;
213 qsize_t dqi_maxblimit; 221 qsize_t dqi_maxblimit;
214 qsize_t dqi_maxilimit; 222 qsize_t dqi_maxilimit;
215 union { 223 void *dqi_priv;
216 struct v1_mem_dqinfo v1_i;
217 struct v2_mem_dqinfo v2_i;
218 } u;
219}; 224};
220 225
221struct super_block; 226struct super_block;
@@ -249,6 +254,11 @@ extern struct dqstats dqstats;
249#define DQ_FAKE_B 3 /* no limits only usage */ 254#define DQ_FAKE_B 3 /* no limits only usage */
250#define DQ_READ_B 4 /* dquot was read into memory */ 255#define DQ_READ_B 4 /* dquot was read into memory */
251#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */ 256#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
257#define DQ_LASTSET_B 6 /* Following 6 bits (see QIF_) are reserved\
258 * for the mask of entries set via SETQUOTA\
259 * quotactl. They are set under dq_data_lock\
260 * and the quota format handling dquot can\
261 * clear them when it sees fit. */
252 262
253struct dquot { 263struct dquot {
254 struct hlist_node dq_hash; /* Hash list in memory */ 264 struct hlist_node dq_hash; /* Hash list in memory */
@@ -287,11 +297,13 @@ struct dquot_operations {
287 int (*initialize) (struct inode *, int); 297 int (*initialize) (struct inode *, int);
288 int (*drop) (struct inode *); 298 int (*drop) (struct inode *);
289 int (*alloc_space) (struct inode *, qsize_t, int); 299 int (*alloc_space) (struct inode *, qsize_t, int);
290 int (*alloc_inode) (const struct inode *, unsigned long); 300 int (*alloc_inode) (const struct inode *, qsize_t);
291 int (*free_space) (struct inode *, qsize_t); 301 int (*free_space) (struct inode *, qsize_t);
292 int (*free_inode) (const struct inode *, unsigned long); 302 int (*free_inode) (const struct inode *, qsize_t);
293 int (*transfer) (struct inode *, struct iattr *); 303 int (*transfer) (struct inode *, struct iattr *);
294 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */ 304 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
305 struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */
306 void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */
295 int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */ 307 int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
296 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */ 308 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
297 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */ 309 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */
@@ -320,12 +332,42 @@ struct quota_format_type {
320 struct quota_format_type *qf_next; 332 struct quota_format_type *qf_next;
321}; 333};
322 334
323#define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */ 335/* Quota state flags - they actually come in two flavors - for users and groups */
324#define DQUOT_GRP_ENABLED 0x02 /* Group diskquotas enabled */ 336enum {
325#define DQUOT_USR_SUSPENDED 0x04 /* User diskquotas are off, but 337 _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */
338 _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */
339 _DQUOT_SUSPENDED, /* User diskquotas are off, but
326 * we have necessary info in 340 * we have necessary info in
327 * memory to turn them on */ 341 * memory to turn them on */
328#define DQUOT_GRP_SUSPENDED 0x08 /* The same for group quotas */ 342 _DQUOT_STATE_FLAGS
343};
344#define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED)
345#define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED)
346#define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED)
347#define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \
348 DQUOT_SUSPENDED)
349/* Other quota flags */
350#define DQUOT_QUOTA_SYS_FILE (1 << 6) /* Quota file is a special
351 * system file and user cannot
352 * touch it. Filesystem is
353 * responsible for setting
354 * S_NOQUOTA, S_NOATIME flags
355 */
356#define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */
357
358static inline unsigned int dquot_state_flag(unsigned int flags, int type)
359{
360 if (type == USRQUOTA)
361 return flags;
362 return flags << _DQUOT_STATE_FLAGS;
363}
364
365static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
366{
367 if (type == USRQUOTA)
368 return flags;
369 return flags >> _DQUOT_STATE_FLAGS;
370}
329 371
330struct quota_info { 372struct quota_info {
331 unsigned int flags; /* Flags for diskquotas on this device */ 373 unsigned int flags; /* Flags for diskquotas on this device */
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index a558a4c1d35a..21b781a3350f 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -24,12 +24,21 @@ void sync_dquots(struct super_block *sb, int type);
24 24
25int dquot_initialize(struct inode *inode, int type); 25int dquot_initialize(struct inode *inode, int type);
26int dquot_drop(struct inode *inode); 26int dquot_drop(struct inode *inode);
27int dquot_drop_locked(struct inode *inode);
28struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
29void dqput(struct dquot *dquot);
30int dquot_is_cached(struct super_block *sb, unsigned int id, int type);
31int dquot_scan_active(struct super_block *sb,
32 int (*fn)(struct dquot *dquot, unsigned long priv),
33 unsigned long priv);
34struct dquot *dquot_alloc(struct super_block *sb, int type);
35void dquot_destroy(struct dquot *dquot);
27 36
28int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 37int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
29int dquot_alloc_inode(const struct inode *inode, unsigned long number); 38int dquot_alloc_inode(const struct inode *inode, qsize_t number);
30 39
31int dquot_free_space(struct inode *inode, qsize_t number); 40int dquot_free_space(struct inode *inode, qsize_t number);
32int dquot_free_inode(const struct inode *inode, unsigned long number); 41int dquot_free_inode(const struct inode *inode, qsize_t number);
33 42
34int dquot_transfer(struct inode *inode, struct iattr *iattr); 43int dquot_transfer(struct inode *inode, struct iattr *iattr);
35int dquot_commit(struct dquot *dquot); 44int dquot_commit(struct dquot *dquot);
@@ -40,11 +49,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot);
40 49
41int vfs_quota_on(struct super_block *sb, int type, int format_id, 50int vfs_quota_on(struct super_block *sb, int type, int format_id,
42 char *path, int remount); 51 char *path, int remount);
52int vfs_quota_enable(struct inode *inode, int type, int format_id,
53 unsigned int flags);
43int vfs_quota_on_path(struct super_block *sb, int type, int format_id, 54int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
44 struct path *path); 55 struct path *path);
45int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 56int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
46 int format_id, int type); 57 int format_id, int type);
47int vfs_quota_off(struct super_block *sb, int type, int remount); 58int vfs_quota_off(struct super_block *sb, int type, int remount);
59int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
48int vfs_quota_sync(struct super_block *sb, int type); 60int vfs_quota_sync(struct super_block *sb, int type);
49int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 61int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
50int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 62int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
@@ -64,24 +76,22 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
64 * Functions for checking status of quota 76 * Functions for checking status of quota
65 */ 77 */
66 78
67static inline int sb_has_quota_enabled(struct super_block *sb, int type) 79static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type)
68{ 80{
69 if (type == USRQUOTA) 81 return sb_dqopt(sb)->flags &
70 return sb_dqopt(sb)->flags & DQUOT_USR_ENABLED; 82 dquot_state_flag(DQUOT_USAGE_ENABLED, type);
71 return sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED;
72} 83}
73 84
74static inline int sb_any_quota_enabled(struct super_block *sb) 85static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type)
75{ 86{
76 return sb_has_quota_enabled(sb, USRQUOTA) || 87 return sb_dqopt(sb)->flags &
77 sb_has_quota_enabled(sb, GRPQUOTA); 88 dquot_state_flag(DQUOT_LIMITS_ENABLED, type);
78} 89}
79 90
80static inline int sb_has_quota_suspended(struct super_block *sb, int type) 91static inline int sb_has_quota_suspended(struct super_block *sb, int type)
81{ 92{
82 if (type == USRQUOTA) 93 return sb_dqopt(sb)->flags &
83 return sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED; 94 dquot_state_flag(DQUOT_SUSPENDED, type);
84 return sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED;
85} 95}
86 96
87static inline int sb_any_quota_suspended(struct super_block *sb) 97static inline int sb_any_quota_suspended(struct super_block *sb)
@@ -90,6 +100,31 @@ static inline int sb_any_quota_suspended(struct super_block *sb)
90 sb_has_quota_suspended(sb, GRPQUOTA); 100 sb_has_quota_suspended(sb, GRPQUOTA);
91} 101}
92 102
103/* Does kernel know about any quota information for given sb + type? */
104static inline int sb_has_quota_loaded(struct super_block *sb, int type)
105{
106 /* Currently if anything is on, then quota usage is on as well */
107 return sb_has_quota_usage_enabled(sb, type);
108}
109
110static inline int sb_any_quota_loaded(struct super_block *sb)
111{
112 return sb_has_quota_loaded(sb, USRQUOTA) ||
113 sb_has_quota_loaded(sb, GRPQUOTA);
114}
115
116static inline int sb_has_quota_active(struct super_block *sb, int type)
117{
118 return sb_has_quota_loaded(sb, type) &&
119 !sb_has_quota_suspended(sb, type);
120}
121
122static inline int sb_any_quota_active(struct super_block *sb)
123{
124 return sb_has_quota_active(sb, USRQUOTA) ||
125 sb_has_quota_active(sb, GRPQUOTA);
126}
127
93/* 128/*
94 * Operations supported for diskquotas. 129 * Operations supported for diskquotas.
95 */ 130 */
@@ -104,7 +139,7 @@ extern struct quotactl_ops vfs_quotactl_ops;
104static inline void vfs_dq_init(struct inode *inode) 139static inline void vfs_dq_init(struct inode *inode)
105{ 140{
106 BUG_ON(!inode->i_sb); 141 BUG_ON(!inode->i_sb);
107 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) 142 if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
108 inode->i_sb->dq_op->initialize(inode, -1); 143 inode->i_sb->dq_op->initialize(inode, -1);
109} 144}
110 145
@@ -112,7 +147,7 @@ static inline void vfs_dq_init(struct inode *inode)
112 * a transaction (deadlocks possible otherwise) */ 147 * a transaction (deadlocks possible otherwise) */
113static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) 148static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
114{ 149{
115 if (sb_any_quota_enabled(inode->i_sb)) { 150 if (sb_any_quota_active(inode->i_sb)) {
116 /* Used space is updated in alloc_space() */ 151 /* Used space is updated in alloc_space() */
117 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) 152 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
118 return 1; 153 return 1;
@@ -132,7 +167,7 @@ static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
132 167
133static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) 168static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
134{ 169{
135 if (sb_any_quota_enabled(inode->i_sb)) { 170 if (sb_any_quota_active(inode->i_sb)) {
136 /* Used space is updated in alloc_space() */ 171 /* Used space is updated in alloc_space() */
137 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) 172 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
138 return 1; 173 return 1;
@@ -152,7 +187,7 @@ static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
152 187
153static inline int vfs_dq_alloc_inode(struct inode *inode) 188static inline int vfs_dq_alloc_inode(struct inode *inode)
154{ 189{
155 if (sb_any_quota_enabled(inode->i_sb)) { 190 if (sb_any_quota_active(inode->i_sb)) {
156 vfs_dq_init(inode); 191 vfs_dq_init(inode);
157 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) 192 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
158 return 1; 193 return 1;
@@ -162,7 +197,7 @@ static inline int vfs_dq_alloc_inode(struct inode *inode)
162 197
163static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 198static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
164{ 199{
165 if (sb_any_quota_enabled(inode->i_sb)) 200 if (sb_any_quota_active(inode->i_sb))
166 inode->i_sb->dq_op->free_space(inode, nr); 201 inode->i_sb->dq_op->free_space(inode, nr);
167 else 202 else
168 inode_sub_bytes(inode, nr); 203 inode_sub_bytes(inode, nr);
@@ -176,7 +211,7 @@ static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
176 211
177static inline void vfs_dq_free_inode(struct inode *inode) 212static inline void vfs_dq_free_inode(struct inode *inode)
178{ 213{
179 if (sb_any_quota_enabled(inode->i_sb)) 214 if (sb_any_quota_active(inode->i_sb))
180 inode->i_sb->dq_op->free_inode(inode, 1); 215 inode->i_sb->dq_op->free_inode(inode, 1);
181} 216}
182 217
@@ -197,12 +232,12 @@ static inline int vfs_dq_off(struct super_block *sb, int remount)
197 232
198#else 233#else
199 234
200static inline int sb_has_quota_enabled(struct super_block *sb, int type) 235static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type)
201{ 236{
202 return 0; 237 return 0;
203} 238}
204 239
205static inline int sb_any_quota_enabled(struct super_block *sb) 240static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type)
206{ 241{
207 return 0; 242 return 0;
208} 243}
@@ -217,6 +252,27 @@ static inline int sb_any_quota_suspended(struct super_block *sb)
217 return 0; 252 return 0;
218} 253}
219 254
255/* Does kernel know about any quota information for given sb + type? */
256static inline int sb_has_quota_loaded(struct super_block *sb, int type)
257{
258 return 0;
259}
260
261static inline int sb_any_quota_loaded(struct super_block *sb)
262{
263 return 0;
264}
265
266static inline int sb_has_quota_active(struct super_block *sb, int type)
267{
268 return 0;
269}
270
271static inline int sb_any_quota_active(struct super_block *sb)
272{
273 return 0;
274}
275
220/* 276/*
221 * NO-OP when quota not configured. 277 * NO-OP when quota not configured.
222 */ 278 */
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index a916c6660dfa..355f6e80db0d 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -136,7 +136,7 @@ do { \
136 */ 136 */
137static inline void *radix_tree_deref_slot(void **pslot) 137static inline void *radix_tree_deref_slot(void **pslot)
138{ 138{
139 void *ret = *pslot; 139 void *ret = rcu_dereference(*pslot);
140 if (unlikely(radix_tree_is_indirect_ptr(ret))) 140 if (unlikely(radix_tree_is_indirect_ptr(ret)))
141 ret = RADIX_TREE_RETRY; 141 ret = RADIX_TREE_RETRY;
142 return ret; 142 return ret;
diff --git a/include/linux/random.h b/include/linux/random.h
index adbf3bd3c6b3..407ea3646f8f 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -45,56 +45,6 @@ struct rand_pool_info {
45 45
46extern void rand_initialize_irq(int irq); 46extern void rand_initialize_irq(int irq);
47 47
48struct timer_rand_state;
49#ifndef CONFIG_SPARSE_IRQ
50
51extern struct timer_rand_state *irq_timer_state[];
52
53static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq)
54{
55 if (irq >= nr_irqs)
56 return NULL;
57
58 return irq_timer_state[irq];
59}
60
61static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
62{
63 if (irq >= nr_irqs)
64 return;
65
66 irq_timer_state[irq] = state;
67}
68
69#else
70
71#include <linux/irq.h>
72static inline struct timer_rand_state *get_timer_rand_state(unsigned int irq)
73{
74 struct irq_desc *desc;
75
76 desc = irq_to_desc(irq);
77
78 if (!desc)
79 return NULL;
80
81 return desc->timer_rand_state;
82}
83
84static inline void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state)
85{
86 struct irq_desc *desc;
87
88 desc = irq_to_desc(irq);
89
90 if (!desc)
91 return;
92
93 desc->timer_rand_state = state;
94}
95#endif
96
97
98extern void add_input_randomness(unsigned int type, unsigned int code, 48extern void add_input_randomness(unsigned int type, unsigned int code,
99 unsigned int value); 49 unsigned int value);
100extern void add_interrupt_randomness(int irq); 50extern void add_interrupt_randomness(int irq);
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index 301dda829e37..f3f697df1d71 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -59,8 +59,8 @@ struct rcu_ctrlblk {
59 int signaled; 59 int signaled;
60 60
61 spinlock_t lock ____cacheline_internodealigned_in_smp; 61 spinlock_t lock ____cacheline_internodealigned_in_smp;
62 cpumask_t cpumask; /* CPUs that need to switch in order */ 62 DECLARE_BITMAP(cpumask, NR_CPUS); /* CPUs that need to switch for */
63 /* for current batch to proceed. */ 63 /* current batch to proceed. */
64} ____cacheline_internodealigned_in_smp; 64} ____cacheline_internodealigned_in_smp;
65 65
66/* Is batch a before batch b ? */ 66/* Is batch a before batch b ? */
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 91f597ad6acc..4046b75563c1 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -145,6 +145,8 @@ struct rtc_class_ops {
145 int (*irq_set_state)(struct device *, int enabled); 145 int (*irq_set_state)(struct device *, int enabled);
146 int (*irq_set_freq)(struct device *, int freq); 146 int (*irq_set_freq)(struct device *, int freq);
147 int (*read_callback)(struct device *, int data); 147 int (*read_callback)(struct device *, int data);
148 int (*alarm_irq_enable)(struct device *, unsigned int enabled);
149 int (*update_irq_enable)(struct device *, unsigned int enabled);
148}; 150};
149 151
150#define RTC_DEVICE_NAME_SIZE 20 152#define RTC_DEVICE_NAME_SIZE 20
@@ -181,7 +183,7 @@ struct rtc_device
181 struct timer_list uie_timer; 183 struct timer_list uie_timer;
182 /* Those fields are protected by rtc->irq_lock */ 184 /* Those fields are protected by rtc->irq_lock */
183 unsigned int oldsecs; 185 unsigned int oldsecs;
184 unsigned int irq_active:1; 186 unsigned int uie_irq_active:1;
185 unsigned int stop_uie_polling:1; 187 unsigned int stop_uie_polling:1;
186 unsigned int uie_task_active:1; 188 unsigned int uie_task_active:1;
187 unsigned int uie_timer_active:1; 189 unsigned int uie_timer_active:1;
@@ -216,6 +218,10 @@ extern int rtc_irq_set_state(struct rtc_device *rtc,
216 struct rtc_task *task, int enabled); 218 struct rtc_task *task, int enabled);
217extern int rtc_irq_set_freq(struct rtc_device *rtc, 219extern int rtc_irq_set_freq(struct rtc_device *rtc,
218 struct rtc_task *task, int freq); 220 struct rtc_task *task, int freq);
221extern int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled);
222extern int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled);
223extern int rtc_dev_update_irq_enable_emul(struct rtc_device *rtc,
224 unsigned int enabled);
219 225
220typedef struct rtc_task { 226typedef struct rtc_task {
221 void (*func)(void *private_data); 227 void (*func)(void *private_data);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 158d53d07765..38a3f4b15394 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -284,7 +284,6 @@ long io_schedule_timeout(long timeout);
284 284
285extern void cpu_init (void); 285extern void cpu_init (void);
286extern void trap_init(void); 286extern void trap_init(void);
287extern void account_process_tick(struct task_struct *task, int user);
288extern void update_process_times(int user); 287extern void update_process_times(int user);
289extern void scheduler_tick(void); 288extern void scheduler_tick(void);
290 289
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index b3dfa72f13b9..40ea5058c2ec 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -50,10 +50,11 @@ int seq_path(struct seq_file *, struct path *, char *);
50int seq_dentry(struct seq_file *, struct dentry *, char *); 50int seq_dentry(struct seq_file *, struct dentry *, char *);
51int seq_path_root(struct seq_file *m, struct path *path, struct path *root, 51int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
52 char *esc); 52 char *esc);
53int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits); 53int seq_bitmap(struct seq_file *m, const unsigned long *bits,
54static inline int seq_cpumask(struct seq_file *m, cpumask_t *mask) 54 unsigned int nr_bits);
55static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
55{ 56{
56 return seq_bitmap(m, mask->bits, NR_CPUS); 57 return seq_bitmap(m, mask->bits, nr_cpu_ids);
57} 58}
58 59
59static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask) 60static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 6e7ba16ff454..b82466968101 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -21,6 +21,9 @@ struct call_single_data {
21 u16 priv; 21 u16 priv;
22}; 22};
23 23
24/* total number of cpus in this system (may exceed NR_CPUS) */
25extern unsigned int total_cpus;
26
24#ifdef CONFIG_SMP 27#ifdef CONFIG_SMP
25 28
26#include <linux/preempt.h> 29#include <linux/preempt.h>
@@ -64,15 +67,16 @@ extern void smp_cpus_done(unsigned int max_cpus);
64 * Call a function on all other processors 67 * Call a function on all other processors
65 */ 68 */
66int smp_call_function(void(*func)(void *info), void *info, int wait); 69int smp_call_function(void(*func)(void *info), void *info, int wait);
67/* Deprecated: use smp_call_function_many() which uses a cpumask ptr. */ 70void smp_call_function_many(const struct cpumask *mask,
68int smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info, 71 void (*func)(void *info), void *info, bool wait);
69 int wait);
70 72
71static inline void smp_call_function_many(const struct cpumask *mask, 73/* Deprecated: Use smp_call_function_many which takes a pointer to the mask. */
72 void (*func)(void *info), void *info, 74static inline int
73 int wait) 75smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
76 int wait)
74{ 77{
75 smp_call_function_mask(*mask, func, info, wait); 78 smp_call_function_many(&mask, func, info, wait);
79 return 0;
76} 80}
77 81
78int smp_call_function_single(int cpuid, void (*func) (void *info), void *info, 82int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h
index a3626aedaec9..0f4eb165f254 100644
--- a/include/linux/spi/mmc_spi.h
+++ b/include/linux/spi/mmc_spi.h
@@ -1,9 +1,10 @@
1#ifndef __LINUX_SPI_MMC_SPI_H 1#ifndef __LINUX_SPI_MMC_SPI_H
2#define __LINUX_SPI_MMC_SPI_H 2#define __LINUX_SPI_MMC_SPI_H
3 3
4#include <linux/device.h>
5#include <linux/spi/spi.h>
4#include <linux/interrupt.h> 6#include <linux/interrupt.h>
5 7
6struct device;
7struct mmc_host; 8struct mmc_host;
8 9
9/* Put this in platform_data of a device being used to manage an MMC/SD 10/* Put this in platform_data of a device being used to manage an MMC/SD
@@ -41,4 +42,16 @@ struct mmc_spi_platform_data {
41 void (*setpower)(struct device *, unsigned int maskval); 42 void (*setpower)(struct device *, unsigned int maskval);
42}; 43};
43 44
45#ifdef CONFIG_OF
46extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
47extern void mmc_spi_put_pdata(struct spi_device *spi);
48#else
49static inline struct mmc_spi_platform_data *
50mmc_spi_get_pdata(struct spi_device *spi)
51{
52 return spi->dev.platform_data;
53}
54static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
55#endif /* CONFIG_OF */
56
44#endif /* __LINUX_SPI_MMC_SPI_H */ 57#endif /* __LINUX_SPI_MMC_SPI_H */
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 4be01bb44377..82229317753d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -19,6 +19,8 @@
19#ifndef __LINUX_SPI_H 19#ifndef __LINUX_SPI_H
20#define __LINUX_SPI_H 20#define __LINUX_SPI_H
21 21
22#include <linux/device.h>
23
22/* 24/*
23 * INTERFACES between SPI master-side drivers and SPI infrastructure. 25 * INTERFACES between SPI master-side drivers and SPI infrastructure.
24 * (There's no SPI slave support for Linux yet...) 26 * (There's no SPI slave support for Linux yet...)
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index faf1519b5adc..baba3a23a814 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -23,7 +23,7 @@
23 * 23 *
24 * This can be thought of as a very heavy write lock, equivalent to 24 * This can be thought of as a very heavy write lock, equivalent to
25 * grabbing every spinlock in the kernel. */ 25 * grabbing every spinlock in the kernel. */
26int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus); 26int stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus);
27 27
28/** 28/**
29 * __stop_machine: freeze the machine on all CPUs and run this function 29 * __stop_machine: freeze the machine on all CPUs and run this function
@@ -34,11 +34,29 @@ int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
34 * Description: This is a special version of the above, which assumes cpus 34 * Description: This is a special version of the above, which assumes cpus
35 * won't come or go while it's being called. Used by hotplug cpu. 35 * won't come or go while it's being called. Used by hotplug cpu.
36 */ 36 */
37int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus); 37int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus);
38
39/**
40 * stop_machine_create: create all stop_machine threads
41 *
42 * Description: This causes all stop_machine threads to be created before
43 * stop_machine actually gets called. This can be used by subsystems that
44 * need a non failing stop_machine infrastructure.
45 */
46int stop_machine_create(void);
47
48/**
49 * stop_machine_destroy: destroy all stop_machine threads
50 *
51 * Description: This causes all stop_machine threads which were created with
52 * stop_machine_create to be destroyed again.
53 */
54void stop_machine_destroy(void);
55
38#else 56#else
39 57
40static inline int stop_machine(int (*fn)(void *), void *data, 58static inline int stop_machine(int (*fn)(void *), void *data,
41 const cpumask_t *cpus) 59 const struct cpumask *cpus)
42{ 60{
43 int ret; 61 int ret;
44 local_irq_disable(); 62 local_irq_disable();
@@ -46,5 +64,9 @@ static inline int stop_machine(int (*fn)(void *), void *data,
46 local_irq_enable(); 64 local_irq_enable();
47 return ret; 65 return ret;
48} 66}
67
68static inline int stop_machine_create(void) { return 0; }
69static inline void stop_machine_destroy(void) { }
70
49#endif /* CONFIG_SMP */ 71#endif /* CONFIG_SMP */
50#endif /* _LINUX_STOP_MACHINE */ 72#endif /* _LINUX_STOP_MACHINE */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 04fb47bfb920..18d0a243a7b3 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -549,7 +549,7 @@ asmlinkage long sys_inotify_init(void);
549asmlinkage long sys_inotify_init1(int flags); 549asmlinkage long sys_inotify_init1(int flags);
550asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, 550asmlinkage long sys_inotify_add_watch(int fd, const char __user *path,
551 u32 mask); 551 u32 mask);
552asmlinkage long sys_inotify_rm_watch(int fd, u32 wd); 552asmlinkage long sys_inotify_rm_watch(int fd, __s32 wd);
553 553
554asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, 554asmlinkage long sys_spu_run(int fd, __u32 __user *unpc,
555 __u32 __user *ustatus); 555 __u32 __user *ustatus);
diff --git a/include/linux/threads.h b/include/linux/threads.h
index 38d1a5d6568e..052b12bec8bd 100644
--- a/include/linux/threads.h
+++ b/include/linux/threads.h
@@ -8,17 +8,17 @@
8 */ 8 */
9 9
10/* 10/*
11 * Maximum supported processors that can run under SMP. This value is 11 * Maximum supported processors. Setting this smaller saves quite a
12 * set via configure setting. The maximum is equal to the size of the 12 * bit of memory. Use nr_cpu_ids instead of this except for static bitmaps.
13 * bitmasks used on that platform, i.e. 32 or 64. Setting this smaller
14 * saves quite a bit of memory.
15 */ 13 */
16#ifdef CONFIG_SMP 14#ifndef CONFIG_NR_CPUS
17#define NR_CPUS CONFIG_NR_CPUS 15/* FIXME: This should be fixed in the arch's Kconfig */
18#else 16#define CONFIG_NR_CPUS 1
19#define NR_CPUS 1
20#endif 17#endif
21 18
19/* Places which use this should consider cpumask_var_t. */
20#define NR_CPUS CONFIG_NR_CPUS
21
22#define MIN_THREADS_LEFT_FOR_ROOT 4 22#define MIN_THREADS_LEFT_FOR_ROOT 4
23 23
24/* 24/*
diff --git a/include/linux/tick.h b/include/linux/tick.h
index b6ec8189ac0c..469b82d88b3b 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -84,10 +84,10 @@ static inline void tick_cancel_sched_timer(int cpu) { }
84 84
85# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 85# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
86extern struct tick_device *tick_get_broadcast_device(void); 86extern struct tick_device *tick_get_broadcast_device(void);
87extern cpumask_t *tick_get_broadcast_mask(void); 87extern struct cpumask *tick_get_broadcast_mask(void);
88 88
89# ifdef CONFIG_TICK_ONESHOT 89# ifdef CONFIG_TICK_ONESHOT
90extern cpumask_t *tick_get_broadcast_oneshot_mask(void); 90extern struct cpumask *tick_get_broadcast_oneshot_mask(void);
91# endif 91# endif
92 92
93# endif /* BROADCAST */ 93# endif /* BROADCAST */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 1f126e30766c..5571dbe1c0ad 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1370,25 +1370,41 @@ struct v4l2_streamparm {
1370/* 1370/*
1371 * A D V A N C E D D E B U G G I N G 1371 * A D V A N C E D D E B U G G I N G
1372 * 1372 *
1373 * NOTE: EXPERIMENTAL API 1373 * NOTE: EXPERIMENTAL API, NEVER RELY ON THIS IN APPLICATIONS!
1374 * FOR DEBUGGING, TESTING AND INTERNAL USE ONLY!
1374 */ 1375 */
1375 1376
1376/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ 1377/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */
1377 1378
1378#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ 1379#define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */
1379#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ 1380#define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */
1380#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ 1381#define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */
1381#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ 1382#define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */
1382 1383
1383struct v4l2_register { 1384struct v4l2_dbg_match {
1384 __u32 match_type; /* Match type */ 1385 __u32 type; /* Match type */
1385 __u32 match_chip; /* Match this chip, meaning determined by match_type */ 1386 union { /* Match this chip, meaning determined by type */
1387 __u32 addr;
1388 char name[32];
1389 };
1390} __attribute__ ((packed));
1391
1392struct v4l2_dbg_register {
1393 struct v4l2_dbg_match match;
1394 __u32 size; /* register size in bytes */
1386 __u64 reg; 1395 __u64 reg;
1387 __u64 val; 1396 __u64 val;
1388}; 1397} __attribute__ ((packed));
1398
1399/* VIDIOC_DBG_G_CHIP_IDENT */
1400struct v4l2_dbg_chip_ident {
1401 struct v4l2_dbg_match match;
1402 __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */
1403 __u32 revision; /* chip revision, chip specific */
1404} __attribute__ ((packed));
1389 1405
1390/* VIDIOC_G_CHIP_IDENT */ 1406/* VIDIOC_G_CHIP_IDENT_OLD: Deprecated, do not use */
1391struct v4l2_chip_ident { 1407struct v4l2_chip_ident_old {
1392 __u32 match_type; /* Match type */ 1408 __u32 match_type; /* Match type */
1393 __u32 match_chip; /* Match this chip, meaning determined by match_type */ 1409 __u32 match_chip; /* Match this chip, meaning determined by match_type */
1394 __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */ 1410 __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */
@@ -1460,13 +1476,22 @@ struct v4l2_chip_ident {
1460#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx) 1476#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
1461#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd) 1477#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
1462#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd) 1478#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
1479#endif
1463 1480
1464/* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1481#if 1
1465#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_register) 1482/* Experimental, meant for debugging, testing and internal use.
1466#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_register) 1483 Only implemented if CONFIG_VIDEO_ADV_DEBUG is defined.
1467 1484 You must be root to use these ioctls. Never use these in applications! */
1468#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident) 1485#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_dbg_register)
1486#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_dbg_register)
1487
1488/* Experimental, meant for debugging, testing and internal use.
1489 Never use this ioctl in applications! */
1490#define VIDIOC_DBG_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_dbg_chip_ident)
1491/* This is deprecated and will go away in 2.6.30 */
1492#define VIDIOC_G_CHIP_IDENT_OLD _IOWR('V', 81, struct v4l2_chip_ident_old)
1469#endif 1493#endif
1494
1470#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek) 1495#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1471/* Reminder: when adding new ioctls please add support for them to 1496/* Reminder: when adding new ioctls please add support for them to
1472 drivers/media/video/v4l2-compat-ioctl32.c as well! */ 1497 drivers/media/video/v4l2-compat-ioctl32.c as well! */
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 6bbb0d93bb5f..c8d0b23fde29 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -177,9 +177,9 @@ struct saa7146_ext_vv
177 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *); 177 int (*std_callback)(struct saa7146_dev*, struct saa7146_standard *);
178 178
179 struct saa7146_extension_ioctls *ioctls; 179 struct saa7146_extension_ioctls *ioctls;
180 int (*ioctl)(struct saa7146_fh*, unsigned int cmd, void *arg); 180 long (*ioctl)(struct saa7146_fh *, unsigned int cmd, void *arg);
181 181
182 struct file_operations vbi_fops; 182 struct v4l2_file_operations vbi_fops;
183}; 183};
184 184
185struct saa7146_use_ops { 185struct saa7146_use_ops {
@@ -216,7 +216,7 @@ void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
216extern struct saa7146_use_ops saa7146_video_uops; 216extern struct saa7146_use_ops saa7146_video_uops;
217int saa7146_start_preview(struct saa7146_fh *fh); 217int saa7146_start_preview(struct saa7146_fh *fh);
218int saa7146_stop_preview(struct saa7146_fh *fh); 218int saa7146_stop_preview(struct saa7146_fh *fh);
219int saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg); 219long saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg);
220 220
221/* from saa7146_vbi.c */ 221/* from saa7146_vbi.c */
222extern struct saa7146_use_ops saa7146_vbi_uops; 222extern struct saa7146_use_ops saa7146_vbi_uops;
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 425b6a98c95c..7440d9250665 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -164,12 +164,12 @@ struct soc_camera_ops {
164 unsigned long (*query_bus_param)(struct soc_camera_device *); 164 unsigned long (*query_bus_param)(struct soc_camera_device *);
165 int (*set_bus_param)(struct soc_camera_device *, unsigned long); 165 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
166 int (*get_chip_id)(struct soc_camera_device *, 166 int (*get_chip_id)(struct soc_camera_device *,
167 struct v4l2_chip_ident *); 167 struct v4l2_dbg_chip_ident *);
168 int (*set_std)(struct soc_camera_device *, v4l2_std_id *); 168 int (*set_std)(struct soc_camera_device *, v4l2_std_id *);
169 int (*enum_input)(struct soc_camera_device *, struct v4l2_input *); 169 int (*enum_input)(struct soc_camera_device *, struct v4l2_input *);
170#ifdef CONFIG_VIDEO_ADV_DEBUG 170#ifdef CONFIG_VIDEO_ADV_DEBUG
171 int (*get_register)(struct soc_camera_device *, struct v4l2_register *); 171 int (*get_register)(struct soc_camera_device *, struct v4l2_dbg_register *);
172 int (*set_register)(struct soc_camera_device *, struct v4l2_register *); 172 int (*set_register)(struct soc_camera_device *, struct v4l2_dbg_register *);
173#endif 173#endif
174 int (*get_control)(struct soc_camera_device *, struct v4l2_control *); 174 int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
175 int (*set_control)(struct soc_camera_device *, struct v4l2_control *); 175 int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 43dbb659f1f5..9aaf652b20ef 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -2,7 +2,7 @@
2 v4l2 chip identifiers header 2 v4l2 chip identifiers header
3 3
4 This header provides a list of chip identifiers that can be returned 4 This header provides a list of chip identifiers that can be returned
5 through the VIDIOC_G_CHIP_IDENT ioctl. 5 through the VIDIOC_DBG_G_CHIP_IDENT ioctl.
6 6
7 Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> 7 Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 8
@@ -24,7 +24,7 @@
24#ifndef V4L2_CHIP_IDENT_H_ 24#ifndef V4L2_CHIP_IDENT_H_
25#define V4L2_CHIP_IDENT_H_ 25#define V4L2_CHIP_IDENT_H_
26 26
27/* VIDIOC_G_CHIP_IDENT: identifies the actual chip installed on the board */ 27/* VIDIOC_DBG_G_CHIP_IDENT: identifies the actual chip installed on the board */
28enum { 28enum {
29 /* general idents: reserved range 0-49 */ 29 /* general idents: reserved range 0-49 */
30 V4L2_IDENT_NONE = 0, /* No chip matched */ 30 V4L2_IDENT_NONE = 0, /* No chip matched */
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index f99c866d8c37..95e74f1874e1 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -114,10 +114,10 @@ u32 v4l2_ctrl_next(const u32 * const *ctrl_classes, u32 id);
114/* Register/chip ident helper function */ 114/* Register/chip ident helper function */
115 115
116struct i2c_client; /* forward reference */ 116struct i2c_client; /* forward reference */
117int v4l2_chip_match_i2c_client(struct i2c_client *c, u32 id_type, u32 chip_id); 117int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match *match);
118int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_chip_ident *chip, 118int v4l2_chip_ident_i2c_client(struct i2c_client *c, struct v4l2_dbg_chip_ident *chip,
119 u32 ident, u32 revision); 119 u32 ident, u32 revision);
120int v4l2_chip_match_host(u32 id_type, u32 chip_id); 120int v4l2_chip_match_host(const struct v4l2_dbg_match *match);
121 121
122/* ------------------------------------------------------------------------- */ 122/* ------------------------------------------------------------------------- */
123 123
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 0a88d1d17d30..e36faab8459b 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -25,6 +25,7 @@
25#define VFL_TYPE_MAX 4 25#define VFL_TYPE_MAX 4
26 26
27struct v4l2_ioctl_callbacks; 27struct v4l2_ioctl_callbacks;
28struct video_device;
28struct v4l2_device; 29struct v4l2_device;
29 30
30/* Flag to mark the video_device struct as unregistered. 31/* Flag to mark the video_device struct as unregistered.
@@ -32,6 +33,18 @@ struct v4l2_device;
32 device access. It is set by video_unregister_device. */ 33 device access. It is set by video_unregister_device. */
33#define V4L2_FL_UNREGISTERED (0) 34#define V4L2_FL_UNREGISTERED (0)
34 35
36struct v4l2_file_operations {
37 struct module *owner;
38 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
39 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
40 unsigned int (*poll) (struct file *, struct poll_table_struct *);
41 long (*ioctl) (struct file *, unsigned int, unsigned long);
42 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
43 int (*mmap) (struct file *, struct vm_area_struct *);
44 int (*open) (struct file *);
45 int (*release) (struct file *);
46};
47
35/* 48/*
36 * Newer version of video_device, handled by videodev2.c 49 * Newer version of video_device, handled by videodev2.c
37 * This version moves redundant code from video device code to 50 * This version moves redundant code from video device code to
@@ -41,7 +54,7 @@ struct v4l2_device;
41struct video_device 54struct video_device
42{ 55{
43 /* device ops */ 56 /* device ops */
44 const struct file_operations *fops; 57 const struct v4l2_file_operations *fops;
45 58
46 /* sysfs */ 59 /* sysfs */
47 struct device dev; /* v4l device */ 60 struct device dev; /* v4l device */
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 97b283a04289..9bf4ccc93dbf 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -80,7 +80,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd);
80#define __v4l2_device_call_subdevs_until_err(dev, cond, o, f, args...) \ 80#define __v4l2_device_call_subdevs_until_err(dev, cond, o, f, args...) \
81({ \ 81({ \
82 struct v4l2_subdev *sd; \ 82 struct v4l2_subdev *sd; \
83 int err = 0; \ 83 long err = 0; \
84 \ 84 \
85 list_for_each_entry(sd, &(dev)->subdevs, list) { \ 85 list_for_each_entry(sd, &(dev)->subdevs, list) { \
86 if ((cond) && sd->ops->o && sd->ops->o->f) \ 86 if ((cond) && sd->ops->o && sd->ops->o->f) \
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index ecda3c725837..fbf585561570 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -219,7 +219,7 @@ enum v4l2_int_ioctl_num {
219 vidioc_int_reset_num, 219 vidioc_int_reset_num,
220 /* VIDIOC_INT_INIT */ 220 /* VIDIOC_INT_INIT */
221 vidioc_int_init_num, 221 vidioc_int_init_num,
222 /* VIDIOC_INT_G_CHIP_IDENT */ 222 /* VIDIOC_DBG_G_CHIP_IDENT */
223 vidioc_int_g_chip_ident_num, 223 vidioc_int_g_chip_ident_num,
224 224
225 /* 225 /*
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index fcdb58c4ce07..b01c044868d0 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -225,12 +225,12 @@ struct v4l2_ioctl_ops {
225 /* Debugging ioctls */ 225 /* Debugging ioctls */
226#ifdef CONFIG_VIDEO_ADV_DEBUG 226#ifdef CONFIG_VIDEO_ADV_DEBUG
227 int (*vidioc_g_register) (struct file *file, void *fh, 227 int (*vidioc_g_register) (struct file *file, void *fh,
228 struct v4l2_register *reg); 228 struct v4l2_dbg_register *reg);
229 int (*vidioc_s_register) (struct file *file, void *fh, 229 int (*vidioc_s_register) (struct file *file, void *fh,
230 struct v4l2_register *reg); 230 struct v4l2_dbg_register *reg);
231#endif 231#endif
232 int (*vidioc_g_chip_ident) (struct file *file, void *fh, 232 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
233 struct v4l2_chip_ident *chip); 233 struct v4l2_dbg_chip_ident *chip);
234 234
235 int (*vidioc_enum_framesizes) (struct file *file, void *fh, 235 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
236 struct v4l2_frmsizeenum *fsize); 236 struct v4l2_frmsizeenum *fsize);
@@ -239,7 +239,7 @@ struct v4l2_ioctl_ops {
239 struct v4l2_frmivalenum *fival); 239 struct v4l2_frmivalenum *fival);
240 240
241 /* For other private ioctls */ 241 /* For other private ioctls */
242 int (*vidioc_default) (struct file *file, void *fh, 242 long (*vidioc_default) (struct file *file, void *fh,
243 int cmd, void *arg); 243 int cmd, void *arg);
244}; 244};
245 245
@@ -277,36 +277,27 @@ extern const char *v4l2_field_names[];
277extern const char *v4l2_type_names[]; 277extern const char *v4l2_type_names[];
278 278
279/* Compatibility layer interface -- v4l1-compat module */ 279/* Compatibility layer interface -- v4l1-compat module */
280typedef int (*v4l2_kioctl)(struct file *file, 280typedef long (*v4l2_kioctl)(struct file *file,
281 unsigned int cmd, void *arg); 281 unsigned int cmd, void *arg);
282#ifdef CONFIG_VIDEO_V4L1_COMPAT 282#ifdef CONFIG_VIDEO_V4L1_COMPAT
283int v4l_compat_translate_ioctl(struct file *file, 283long v4l_compat_translate_ioctl(struct file *file,
284 int cmd, void *arg, v4l2_kioctl driver_ioctl); 284 int cmd, void *arg, v4l2_kioctl driver_ioctl);
285#else 285#else
286#define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL) 286#define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL)
287#endif 287#endif
288 288
289#ifdef CONFIG_COMPAT
289/* 32 Bits compatibility layer for 64 bits processors */ 290/* 32 Bits compatibility layer for 64 bits processors */
290extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd, 291extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
291 unsigned long arg); 292 unsigned long arg);
293#endif
292 294
293/* Include support for obsoleted stuff */ 295/* Include support for obsoleted stuff */
294extern int video_usercopy(struct file *file, unsigned int cmd, 296extern long video_usercopy(struct file *file, unsigned int cmd,
295 unsigned long arg, v4l2_kioctl func); 297 unsigned long arg, v4l2_kioctl func);
296 298
297/* Standard handlers for V4L ioctl's */ 299/* Standard handlers for V4L ioctl's */
298 300extern long video_ioctl2(struct file *file,
299/* This prototype is used on fops.unlocked_ioctl */
300extern long __video_ioctl2(struct file *file,
301 unsigned int cmd, unsigned long arg);
302
303/* This prototype is used on fops.ioctl
304 * Since fops.ioctl enables Kernel Big Lock, it is preferred
305 * to use __video_ioctl2 instead.
306 * It should be noticed that there's no lock code inside
307 * video_ioctl2().
308 */
309extern int video_ioctl2(struct inode *inode, struct file *file,
310 unsigned int cmd, unsigned long arg); 301 unsigned int cmd, unsigned long arg);
311 302
312#endif /* _V4L2_IOCTL_H */ 303#endif /* _V4L2_IOCTL_H */
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index ceef016bb0b7..37b09e56e943 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -69,7 +69,7 @@ struct tuner_setup;
69 not yet implemented) since ops provide proper type-checking. 69 not yet implemented) since ops provide proper type-checking.
70 */ 70 */
71struct v4l2_subdev_core_ops { 71struct v4l2_subdev_core_ops {
72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip); 72 int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
73 int (*log_status)(struct v4l2_subdev *sd); 73 int (*log_status)(struct v4l2_subdev *sd);
74 int (*init)(struct v4l2_subdev *sd, u32 val); 74 int (*init)(struct v4l2_subdev *sd, u32 val);
75 int (*s_standby)(struct v4l2_subdev *sd, u32 standby); 75 int (*s_standby)(struct v4l2_subdev *sd, u32 standby);
@@ -79,10 +79,10 @@ struct v4l2_subdev_core_ops {
79 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 79 int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
80 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); 80 int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl);
81 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); 81 int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm);
82 int (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); 82 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
83#ifdef CONFIG_VIDEO_ADV_DEBUG 83#ifdef CONFIG_VIDEO_ADV_DEBUG
84 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_register *reg); 84 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
85 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_register *reg); 85 int (*s_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
86#endif 86#endif
87}; 87};
88 88
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index ce532f2222ce..1459ed3e2697 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -155,9 +155,9 @@ static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const s
155{ 155{
156 156
157 if (dev) 157 if (dev)
158 return __neigh_lookup(&nd_tbl, addr, dev, 1); 158 return __neigh_lookup_errno(&nd_tbl, addr, dev);
159 159
160 return NULL; 160 return ERR_PTR(-ENODEV);
161} 161}
162 162
163 163
diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h
index b6870cbaf2b3..426899e529c5 100644
--- a/include/sound/tea575x-tuner.h
+++ b/include/sound/tea575x-tuner.h
@@ -36,7 +36,7 @@ struct snd_tea575x_ops {
36struct snd_tea575x { 36struct snd_tea575x {
37 struct snd_card *card; 37 struct snd_card *card;
38 struct video_device vd; /* video device */ 38 struct video_device vd; /* video device */
39 struct file_operations fops; 39 struct v4l2_file_operations fops;
40 int dev_nr; /* requested device number + 1 */ 40 int dev_nr; /* requested device number + 1 */
41 int vd_registered; /* video device is registered */ 41 int vd_registered; /* video device is registered */
42 int tea5759; /* 5759 chip is present */ 42 int tea5759; /* 5759 chip is present */
diff --git a/init/Kconfig b/init/Kconfig
index f6281711166d..52847eec7398 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -916,12 +916,6 @@ config MODULE_SRCVERSION_ALL
916 the version). With this option, such a "srcversion" field 916 the version). With this option, such a "srcversion" field
917 will be created for all modules. If unsure, say N. 917 will be created for all modules. If unsure, say N.
918 918
919config KMOD
920 def_bool y
921 help
922 This is being removed soon. These days, CONFIG_MODULES
923 implies CONFIG_KMOD, so use that instead.
924
925endif # MODULES 919endif # MODULES
926 920
927config INIT_ALL_POSSIBLE 921config INIT_ALL_POSSIBLE
diff --git a/init/main.c b/init/main.c
index ad8f9f53f8d1..cd168ebc5924 100644
--- a/init/main.c
+++ b/init/main.c
@@ -371,12 +371,7 @@ EXPORT_SYMBOL(nr_cpu_ids);
371/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */ 371/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
372static void __init setup_nr_cpu_ids(void) 372static void __init setup_nr_cpu_ids(void)
373{ 373{
374 int cpu, highest_cpu = 0; 374 nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
375
376 for_each_possible_cpu(cpu)
377 highest_cpu = cpu;
378
379 nr_cpu_ids = highest_cpu + 1;
380} 375}
381 376
382#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA 377#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
@@ -518,9 +513,9 @@ static void __init boot_cpu_init(void)
518{ 513{
519 int cpu = smp_processor_id(); 514 int cpu = smp_processor_id();
520 /* Mark the boot cpu "present", "online" etc for SMP and UP case */ 515 /* Mark the boot cpu "present", "online" etc for SMP and UP case */
521 cpu_set(cpu, cpu_online_map); 516 set_cpu_online(cpu, true);
522 cpu_set(cpu, cpu_present_map); 517 set_cpu_present(cpu, true);
523 cpu_set(cpu, cpu_possible_map); 518 set_cpu_possible(cpu, true);
524} 519}
525 520
526void __init __weak smp_setup_processor_id(void) 521void __init __weak smp_setup_processor_id(void)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d9393f8e4c3e..eddb6247a553 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -120,7 +120,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
120 inode->i_mode = mode; 120 inode->i_mode = mode;
121 inode->i_uid = current_fsuid(); 121 inode->i_uid = current_fsuid();
122 inode->i_gid = current_fsgid(); 122 inode->i_gid = current_fsgid();
123 inode->i_blocks = 0;
124 inode->i_mtime = inode->i_ctime = inode->i_atime = 123 inode->i_mtime = inode->i_ctime = inode->i_atime =
125 CURRENT_TIME; 124 CURRENT_TIME;
126 125
@@ -524,31 +523,27 @@ static void __do_notify(struct mqueue_inode_info *info)
524 wake_up(&info->wait_q); 523 wake_up(&info->wait_q);
525} 524}
526 525
527static long prepare_timeout(const struct timespec __user *u_arg) 526static long prepare_timeout(struct timespec *p)
528{ 527{
529 struct timespec ts, nowts; 528 struct timespec nowts;
530 long timeout; 529 long timeout;
531 530
532 if (u_arg) { 531 if (p) {
533 if (unlikely(copy_from_user(&ts, u_arg, 532 if (unlikely(p->tv_nsec < 0 || p->tv_sec < 0
534 sizeof(struct timespec)))) 533 || p->tv_nsec >= NSEC_PER_SEC))
535 return -EFAULT;
536
537 if (unlikely(ts.tv_nsec < 0 || ts.tv_sec < 0
538 || ts.tv_nsec >= NSEC_PER_SEC))
539 return -EINVAL; 534 return -EINVAL;
540 nowts = CURRENT_TIME; 535 nowts = CURRENT_TIME;
541 /* first subtract as jiffies can't be too big */ 536 /* first subtract as jiffies can't be too big */
542 ts.tv_sec -= nowts.tv_sec; 537 p->tv_sec -= nowts.tv_sec;
543 if (ts.tv_nsec < nowts.tv_nsec) { 538 if (p->tv_nsec < nowts.tv_nsec) {
544 ts.tv_nsec += NSEC_PER_SEC; 539 p->tv_nsec += NSEC_PER_SEC;
545 ts.tv_sec--; 540 p->tv_sec--;
546 } 541 }
547 ts.tv_nsec -= nowts.tv_nsec; 542 p->tv_nsec -= nowts.tv_nsec;
548 if (ts.tv_sec < 0) 543 if (p->tv_sec < 0)
549 return 0; 544 return 0;
550 545
551 timeout = timespec_to_jiffies(&ts) + 1; 546 timeout = timespec_to_jiffies(p) + 1;
552 } else 547 } else
553 return MAX_SCHEDULE_TIMEOUT; 548 return MAX_SCHEDULE_TIMEOUT;
554 549
@@ -592,22 +587,18 @@ static int mq_attr_ok(struct mq_attr *attr)
592 * Invoked when creating a new queue via sys_mq_open 587 * Invoked when creating a new queue via sys_mq_open
593 */ 588 */
594static struct file *do_create(struct dentry *dir, struct dentry *dentry, 589static struct file *do_create(struct dentry *dir, struct dentry *dentry,
595 int oflag, mode_t mode, struct mq_attr __user *u_attr) 590 int oflag, mode_t mode, struct mq_attr *attr)
596{ 591{
597 const struct cred *cred = current_cred(); 592 const struct cred *cred = current_cred();
598 struct mq_attr attr;
599 struct file *result; 593 struct file *result;
600 int ret; 594 int ret;
601 595
602 if (u_attr) { 596 if (attr) {
603 ret = -EFAULT;
604 if (copy_from_user(&attr, u_attr, sizeof(attr)))
605 goto out;
606 ret = -EINVAL; 597 ret = -EINVAL;
607 if (!mq_attr_ok(&attr)) 598 if (!mq_attr_ok(attr))
608 goto out; 599 goto out;
609 /* store for use during create */ 600 /* store for use during create */
610 dentry->d_fsdata = &attr; 601 dentry->d_fsdata = attr;
611 } 602 }
612 603
613 mode &= ~current->fs->umask; 604 mode &= ~current->fs->umask;
@@ -664,11 +655,13 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
664 struct dentry *dentry; 655 struct dentry *dentry;
665 struct file *filp; 656 struct file *filp;
666 char *name; 657 char *name;
658 struct mq_attr attr;
667 int fd, error; 659 int fd, error;
668 660
669 error = audit_mq_open(oflag, mode, u_attr); 661 if (u_attr && copy_from_user(&attr, u_attr, sizeof(struct mq_attr)))
670 if (error != 0) 662 return -EFAULT;
671 return error; 663
664 audit_mq_open(oflag, mode, u_attr ? &attr : NULL);
672 665
673 if (IS_ERR(name = getname(u_name))) 666 if (IS_ERR(name = getname(u_name)))
674 return PTR_ERR(name); 667 return PTR_ERR(name);
@@ -694,7 +687,8 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
694 filp = do_open(dentry, oflag); 687 filp = do_open(dentry, oflag);
695 } else { 688 } else {
696 filp = do_create(mqueue_mnt->mnt_root, dentry, 689 filp = do_create(mqueue_mnt->mnt_root, dentry,
697 oflag, mode, u_attr); 690 oflag, mode,
691 u_attr ? &attr : NULL);
698 } 692 }
699 } else { 693 } else {
700 error = -ENOENT; 694 error = -ENOENT;
@@ -829,17 +823,22 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
829 struct ext_wait_queue *receiver; 823 struct ext_wait_queue *receiver;
830 struct msg_msg *msg_ptr; 824 struct msg_msg *msg_ptr;
831 struct mqueue_inode_info *info; 825 struct mqueue_inode_info *info;
826 struct timespec ts, *p = NULL;
832 long timeout; 827 long timeout;
833 int ret; 828 int ret;
834 829
835 ret = audit_mq_timedsend(mqdes, msg_len, msg_prio, u_abs_timeout); 830 if (u_abs_timeout) {
836 if (ret != 0) 831 if (copy_from_user(&ts, u_abs_timeout,
837 return ret; 832 sizeof(struct timespec)))
833 return -EFAULT;
834 p = &ts;
835 }
838 836
839 if (unlikely(msg_prio >= (unsigned long) MQ_PRIO_MAX)) 837 if (unlikely(msg_prio >= (unsigned long) MQ_PRIO_MAX))
840 return -EINVAL; 838 return -EINVAL;
841 839
842 timeout = prepare_timeout(u_abs_timeout); 840 audit_mq_sendrecv(mqdes, msg_len, msg_prio, p);
841 timeout = prepare_timeout(p);
843 842
844 ret = -EBADF; 843 ret = -EBADF;
845 filp = fget(mqdes); 844 filp = fget(mqdes);
@@ -918,12 +917,17 @@ asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
918 struct inode *inode; 917 struct inode *inode;
919 struct mqueue_inode_info *info; 918 struct mqueue_inode_info *info;
920 struct ext_wait_queue wait; 919 struct ext_wait_queue wait;
920 struct timespec ts, *p = NULL;
921 921
922 ret = audit_mq_timedreceive(mqdes, msg_len, u_msg_prio, u_abs_timeout); 922 if (u_abs_timeout) {
923 if (ret != 0) 923 if (copy_from_user(&ts, u_abs_timeout,
924 return ret; 924 sizeof(struct timespec)))
925 return -EFAULT;
926 p = &ts;
927 }
925 928
926 timeout = prepare_timeout(u_abs_timeout); 929 audit_mq_sendrecv(mqdes, msg_len, 0, p);
930 timeout = prepare_timeout(p);
927 931
928 ret = -EBADF; 932 ret = -EBADF;
929 filp = fget(mqdes); 933 filp = fget(mqdes);
@@ -1003,17 +1007,17 @@ asmlinkage long sys_mq_notify(mqd_t mqdes,
1003 struct mqueue_inode_info *info; 1007 struct mqueue_inode_info *info;
1004 struct sk_buff *nc; 1008 struct sk_buff *nc;
1005 1009
1006 ret = audit_mq_notify(mqdes, u_notification); 1010 if (u_notification) {
1007 if (ret != 0)
1008 return ret;
1009
1010 nc = NULL;
1011 sock = NULL;
1012 if (u_notification != NULL) {
1013 if (copy_from_user(&notification, u_notification, 1011 if (copy_from_user(&notification, u_notification,
1014 sizeof(struct sigevent))) 1012 sizeof(struct sigevent)))
1015 return -EFAULT; 1013 return -EFAULT;
1014 }
1016 1015
1016 audit_mq_notify(mqdes, u_notification ? &notification : NULL);
1017
1018 nc = NULL;
1019 sock = NULL;
1020 if (u_notification != NULL) {
1017 if (unlikely(notification.sigev_notify != SIGEV_NONE && 1021 if (unlikely(notification.sigev_notify != SIGEV_NONE &&
1018 notification.sigev_notify != SIGEV_SIGNAL && 1022 notification.sigev_notify != SIGEV_SIGNAL &&
1019 notification.sigev_notify != SIGEV_THREAD)) 1023 notification.sigev_notify != SIGEV_THREAD))
@@ -1150,11 +1154,7 @@ asmlinkage long sys_mq_getsetattr(mqd_t mqdes,
1150 omqstat = info->attr; 1154 omqstat = info->attr;
1151 omqstat.mq_flags = filp->f_flags & O_NONBLOCK; 1155 omqstat.mq_flags = filp->f_flags & O_NONBLOCK;
1152 if (u_mqstat) { 1156 if (u_mqstat) {
1153 ret = audit_mq_getsetattr(mqdes, &mqstat); 1157 audit_mq_getsetattr(mqdes, &mqstat);
1154 if (ret != 0) {
1155 spin_unlock(&info->lock);
1156 goto out_fput;
1157 }
1158 if (mqstat.mq_flags & O_NONBLOCK) 1158 if (mqstat.mq_flags & O_NONBLOCK)
1159 filp->f_flags |= O_NONBLOCK; 1159 filp->f_flags |= O_NONBLOCK;
1160 else 1160 else
diff --git a/ipc/sem.c b/ipc/sem.c
index 082122469b17..fea0ad3aed7b 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -58,7 +58,7 @@
58 * SMP-threaded, sysctl's added 58 * SMP-threaded, sysctl's added
59 * (c) 1999 Manfred Spraul <manfred@colorfullife.com> 59 * (c) 1999 Manfred Spraul <manfred@colorfullife.com>
60 * Enforced range limit on SEM_UNDO 60 * Enforced range limit on SEM_UNDO
61 * (c) 2001 Red Hat Inc <alan@redhat.com> 61 * (c) 2001 Red Hat Inc
62 * Lockless wakeup 62 * Lockless wakeup
63 * (c) 2003 Manfred Spraul <manfred@colorfullife.com> 63 * (c) 2003 Manfred Spraul <manfred@colorfullife.com>
64 * 64 *
diff --git a/ipc/shm.c b/ipc/shm.c
index 38a055758a9b..57dd50046cef 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -747,9 +747,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
747 goto out; 747 goto out;
748 } 748 }
749 749
750 err = audit_ipc_obj(&(shp->shm_perm)); 750 audit_ipc_obj(&(shp->shm_perm));
751 if (err)
752 goto out_unlock;
753 751
754 if (!capable(CAP_IPC_LOCK)) { 752 if (!capable(CAP_IPC_LOCK)) {
755 uid_t euid = current_euid(); 753 uid_t euid = current_euid();
diff --git a/ipc/util.c b/ipc/util.c
index 5a1808c774a2..7585a72e259b 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -624,10 +624,9 @@ void ipc_rcu_putref(void *ptr)
624int ipcperms (struct kern_ipc_perm *ipcp, short flag) 624int ipcperms (struct kern_ipc_perm *ipcp, short flag)
625{ /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */ 625{ /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
626 uid_t euid = current_euid(); 626 uid_t euid = current_euid();
627 int requested_mode, granted_mode, err; 627 int requested_mode, granted_mode;
628 628
629 if (unlikely((err = audit_ipc_obj(ipcp)))) 629 audit_ipc_obj(ipcp);
630 return err;
631 requested_mode = (flag >> 6) | (flag >> 3) | flag; 630 requested_mode = (flag >> 6) | (flag >> 3) | flag;
632 granted_mode = ipcp->mode; 631 granted_mode = ipcp->mode;
633 if (euid == ipcp->cuid || 632 if (euid == ipcp->cuid ||
@@ -803,16 +802,10 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd,
803 goto out_up; 802 goto out_up;
804 } 803 }
805 804
806 err = audit_ipc_obj(ipcp); 805 audit_ipc_obj(ipcp);
807 if (err) 806 if (cmd == IPC_SET)
808 goto out_unlock; 807 audit_ipc_set_perm(extra_perm, perm->uid,
809
810 if (cmd == IPC_SET) {
811 err = audit_ipc_set_perm(extra_perm, perm->uid,
812 perm->gid, perm->mode); 808 perm->gid, perm->mode);
813 if (err)
814 goto out_unlock;
815 }
816 809
817 euid = current_euid(); 810 euid = current_euid();
818 if (euid == ipcp->cuid || 811 if (euid == ipcp->cuid ||
@@ -820,7 +813,6 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd,
820 return ipcp; 813 return ipcp;
821 814
822 err = -EPERM; 815 err = -EPERM;
823out_unlock:
824 ipc_unlock(ipcp); 816 ipc_unlock(ipcp);
825out_up: 817out_up:
826 up_write(&ids->rw_mutex); 818 up_write(&ids->rw_mutex);
diff --git a/kernel/audit.h b/kernel/audit.h
index 9d6717412fec..16f18cac661b 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -159,11 +159,8 @@ static inline int audit_signal_info(int sig, struct task_struct *t)
159 return __audit_signal_info(sig, t); 159 return __audit_signal_info(sig, t);
160 return 0; 160 return 0;
161} 161}
162extern enum audit_state audit_filter_inodes(struct task_struct *, 162extern void audit_filter_inodes(struct task_struct *, struct audit_context *);
163 struct audit_context *);
164extern void audit_set_auditable(struct audit_context *);
165#else 163#else
166#define audit_signal_info(s,t) AUDIT_DISABLED 164#define audit_signal_info(s,t) AUDIT_DISABLED
167#define audit_filter_inodes(t,c) AUDIT_DISABLED 165#define audit_filter_inodes(t,c) AUDIT_DISABLED
168#define audit_set_auditable(c)
169#endif 166#endif
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 8b509441f49a..8ad9545b8db9 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -450,6 +450,7 @@ static void kill_rules(struct audit_tree *tree)
450 audit_log_end(ab); 450 audit_log_end(ab);
451 rule->tree = NULL; 451 rule->tree = NULL;
452 list_del_rcu(&entry->list); 452 list_del_rcu(&entry->list);
453 list_del(&entry->rule.list);
453 call_rcu(&entry->rcu, audit_free_rule_rcu); 454 call_rcu(&entry->rcu, audit_free_rule_rcu);
454 } 455 }
455 } 456 }
@@ -617,7 +618,7 @@ int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op)
617 618
618 if (pathname[0] != '/' || 619 if (pathname[0] != '/' ||
619 rule->listnr != AUDIT_FILTER_EXIT || 620 rule->listnr != AUDIT_FILTER_EXIT ||
620 op & ~AUDIT_EQUAL || 621 op != Audit_equal ||
621 rule->inode_f || rule->watch || rule->tree) 622 rule->inode_f || rule->watch || rule->tree)
622 return -EINVAL; 623 return -EINVAL;
623 rule->tree = alloc_tree(pathname); 624 rule->tree = alloc_tree(pathname);
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 9fd85a4640a0..fbf24d121d97 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -86,6 +86,14 @@ struct list_head audit_filter_list[AUDIT_NR_FILTERS] = {
86#error Fix audit_filter_list initialiser 86#error Fix audit_filter_list initialiser
87#endif 87#endif
88}; 88};
89static struct list_head audit_rules_list[AUDIT_NR_FILTERS] = {
90 LIST_HEAD_INIT(audit_rules_list[0]),
91 LIST_HEAD_INIT(audit_rules_list[1]),
92 LIST_HEAD_INIT(audit_rules_list[2]),
93 LIST_HEAD_INIT(audit_rules_list[3]),
94 LIST_HEAD_INIT(audit_rules_list[4]),
95 LIST_HEAD_INIT(audit_rules_list[5]),
96};
89 97
90DEFINE_MUTEX(audit_filter_mutex); 98DEFINE_MUTEX(audit_filter_mutex);
91 99
@@ -244,7 +252,8 @@ static inline int audit_to_inode(struct audit_krule *krule,
244 struct audit_field *f) 252 struct audit_field *f)
245{ 253{
246 if (krule->listnr != AUDIT_FILTER_EXIT || 254 if (krule->listnr != AUDIT_FILTER_EXIT ||
247 krule->watch || krule->inode_f || krule->tree) 255 krule->watch || krule->inode_f || krule->tree ||
256 (f->op != Audit_equal && f->op != Audit_not_equal))
248 return -EINVAL; 257 return -EINVAL;
249 258
250 krule->inode_f = f; 259 krule->inode_f = f;
@@ -262,7 +271,7 @@ static int audit_to_watch(struct audit_krule *krule, char *path, int len,
262 271
263 if (path[0] != '/' || path[len-1] == '/' || 272 if (path[0] != '/' || path[len-1] == '/' ||
264 krule->listnr != AUDIT_FILTER_EXIT || 273 krule->listnr != AUDIT_FILTER_EXIT ||
265 op & ~AUDIT_EQUAL || 274 op != Audit_equal ||
266 krule->inode_f || krule->watch || krule->tree) 275 krule->inode_f || krule->watch || krule->tree)
267 return -EINVAL; 276 return -EINVAL;
268 277
@@ -412,12 +421,32 @@ exit_err:
412 return ERR_PTR(err); 421 return ERR_PTR(err);
413} 422}
414 423
424static u32 audit_ops[] =
425{
426 [Audit_equal] = AUDIT_EQUAL,
427 [Audit_not_equal] = AUDIT_NOT_EQUAL,
428 [Audit_bitmask] = AUDIT_BIT_MASK,
429 [Audit_bittest] = AUDIT_BIT_TEST,
430 [Audit_lt] = AUDIT_LESS_THAN,
431 [Audit_gt] = AUDIT_GREATER_THAN,
432 [Audit_le] = AUDIT_LESS_THAN_OR_EQUAL,
433 [Audit_ge] = AUDIT_GREATER_THAN_OR_EQUAL,
434};
435
436static u32 audit_to_op(u32 op)
437{
438 u32 n;
439 for (n = Audit_equal; n < Audit_bad && audit_ops[n] != op; n++)
440 ;
441 return n;
442}
443
444
415/* Translate struct audit_rule to kernel's rule respresentation. 445/* Translate struct audit_rule to kernel's rule respresentation.
416 * Exists for backward compatibility with userspace. */ 446 * Exists for backward compatibility with userspace. */
417static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule) 447static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
418{ 448{
419 struct audit_entry *entry; 449 struct audit_entry *entry;
420 struct audit_field *ino_f;
421 int err = 0; 450 int err = 0;
422 int i; 451 int i;
423 452
@@ -427,12 +456,28 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
427 456
428 for (i = 0; i < rule->field_count; i++) { 457 for (i = 0; i < rule->field_count; i++) {
429 struct audit_field *f = &entry->rule.fields[i]; 458 struct audit_field *f = &entry->rule.fields[i];
459 u32 n;
460
461 n = rule->fields[i] & (AUDIT_NEGATE|AUDIT_OPERATORS);
462
463 /* Support for legacy operators where
464 * AUDIT_NEGATE bit signifies != and otherwise assumes == */
465 if (n & AUDIT_NEGATE)
466 f->op = Audit_not_equal;
467 else if (!n)
468 f->op = Audit_equal;
469 else
470 f->op = audit_to_op(n);
471
472 entry->rule.vers_ops = (n & AUDIT_OPERATORS) ? 2 : 1;
430 473
431 f->op = rule->fields[i] & (AUDIT_NEGATE|AUDIT_OPERATORS);
432 f->type = rule->fields[i] & ~(AUDIT_NEGATE|AUDIT_OPERATORS); 474 f->type = rule->fields[i] & ~(AUDIT_NEGATE|AUDIT_OPERATORS);
433 f->val = rule->values[i]; 475 f->val = rule->values[i];
434 476
435 err = -EINVAL; 477 err = -EINVAL;
478 if (f->op == Audit_bad)
479 goto exit_free;
480
436 switch(f->type) { 481 switch(f->type) {
437 default: 482 default:
438 goto exit_free; 483 goto exit_free;
@@ -454,11 +499,8 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
454 case AUDIT_EXIT: 499 case AUDIT_EXIT:
455 case AUDIT_SUCCESS: 500 case AUDIT_SUCCESS:
456 /* bit ops are only useful on syscall args */ 501 /* bit ops are only useful on syscall args */
457 if (f->op == AUDIT_BIT_MASK || 502 if (f->op == Audit_bitmask || f->op == Audit_bittest)
458 f->op == AUDIT_BIT_TEST) {
459 err = -EINVAL;
460 goto exit_free; 503 goto exit_free;
461 }
462 break; 504 break;
463 case AUDIT_ARG0: 505 case AUDIT_ARG0:
464 case AUDIT_ARG1: 506 case AUDIT_ARG1:
@@ -467,11 +509,8 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
467 break; 509 break;
468 /* arch is only allowed to be = or != */ 510 /* arch is only allowed to be = or != */
469 case AUDIT_ARCH: 511 case AUDIT_ARCH:
470 if ((f->op != AUDIT_NOT_EQUAL) && (f->op != AUDIT_EQUAL) 512 if (f->op != Audit_not_equal && f->op != Audit_equal)
471 && (f->op != AUDIT_NEGATE) && (f->op)) {
472 err = -EINVAL;
473 goto exit_free; 513 goto exit_free;
474 }
475 entry->rule.arch_f = f; 514 entry->rule.arch_f = f;
476 break; 515 break;
477 case AUDIT_PERM: 516 case AUDIT_PERM:
@@ -488,33 +527,10 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
488 goto exit_free; 527 goto exit_free;
489 break; 528 break;
490 } 529 }
491
492 entry->rule.vers_ops = (f->op & AUDIT_OPERATORS) ? 2 : 1;
493
494 /* Support for legacy operators where
495 * AUDIT_NEGATE bit signifies != and otherwise assumes == */
496 if (f->op & AUDIT_NEGATE)
497 f->op = AUDIT_NOT_EQUAL;
498 else if (!f->op)
499 f->op = AUDIT_EQUAL;
500 else if (f->op == AUDIT_OPERATORS) {
501 err = -EINVAL;
502 goto exit_free;
503 }
504 } 530 }
505 531
506 ino_f = entry->rule.inode_f; 532 if (entry->rule.inode_f && entry->rule.inode_f->op == Audit_not_equal)
507 if (ino_f) { 533 entry->rule.inode_f = NULL;
508 switch(ino_f->op) {
509 case AUDIT_NOT_EQUAL:
510 entry->rule.inode_f = NULL;
511 case AUDIT_EQUAL:
512 break;
513 default:
514 err = -EINVAL;
515 goto exit_free;
516 }
517 }
518 534
519exit_nofree: 535exit_nofree:
520 return entry; 536 return entry;
@@ -530,7 +546,6 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
530{ 546{
531 int err = 0; 547 int err = 0;
532 struct audit_entry *entry; 548 struct audit_entry *entry;
533 struct audit_field *ino_f;
534 void *bufp; 549 void *bufp;
535 size_t remain = datasz - sizeof(struct audit_rule_data); 550 size_t remain = datasz - sizeof(struct audit_rule_data);
536 int i; 551 int i;
@@ -546,11 +561,11 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
546 struct audit_field *f = &entry->rule.fields[i]; 561 struct audit_field *f = &entry->rule.fields[i];
547 562
548 err = -EINVAL; 563 err = -EINVAL;
549 if (!(data->fieldflags[i] & AUDIT_OPERATORS) || 564
550 data->fieldflags[i] & ~AUDIT_OPERATORS) 565 f->op = audit_to_op(data->fieldflags[i]);
566 if (f->op == Audit_bad)
551 goto exit_free; 567 goto exit_free;
552 568
553 f->op = data->fieldflags[i] & AUDIT_OPERATORS;
554 f->type = data->fields[i]; 569 f->type = data->fields[i];
555 f->val = data->values[i]; 570 f->val = data->values[i];
556 f->lsm_str = NULL; 571 f->lsm_str = NULL;
@@ -662,18 +677,8 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
662 } 677 }
663 } 678 }
664 679
665 ino_f = entry->rule.inode_f; 680 if (entry->rule.inode_f && entry->rule.inode_f->op == Audit_not_equal)
666 if (ino_f) { 681 entry->rule.inode_f = NULL;
667 switch(ino_f->op) {
668 case AUDIT_NOT_EQUAL:
669 entry->rule.inode_f = NULL;
670 case AUDIT_EQUAL:
671 break;
672 default:
673 err = -EINVAL;
674 goto exit_free;
675 }
676 }
677 682
678exit_nofree: 683exit_nofree:
679 return entry; 684 return entry;
@@ -713,10 +718,10 @@ static struct audit_rule *audit_krule_to_rule(struct audit_krule *krule)
713 rule->fields[i] = krule->fields[i].type; 718 rule->fields[i] = krule->fields[i].type;
714 719
715 if (krule->vers_ops == 1) { 720 if (krule->vers_ops == 1) {
716 if (krule->fields[i].op & AUDIT_NOT_EQUAL) 721 if (krule->fields[i].op == Audit_not_equal)
717 rule->fields[i] |= AUDIT_NEGATE; 722 rule->fields[i] |= AUDIT_NEGATE;
718 } else { 723 } else {
719 rule->fields[i] |= krule->fields[i].op; 724 rule->fields[i] |= audit_ops[krule->fields[i].op];
720 } 725 }
721 } 726 }
722 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) rule->mask[i] = krule->mask[i]; 727 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) rule->mask[i] = krule->mask[i];
@@ -744,7 +749,7 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
744 struct audit_field *f = &krule->fields[i]; 749 struct audit_field *f = &krule->fields[i];
745 750
746 data->fields[i] = f->type; 751 data->fields[i] = f->type;
747 data->fieldflags[i] = f->op; 752 data->fieldflags[i] = audit_ops[f->op];
748 switch(f->type) { 753 switch(f->type) {
749 case AUDIT_SUBJ_USER: 754 case AUDIT_SUBJ_USER:
750 case AUDIT_SUBJ_ROLE: 755 case AUDIT_SUBJ_ROLE:
@@ -919,6 +924,7 @@ static struct audit_entry *audit_dupe_rule(struct audit_krule *old,
919 new->action = old->action; 924 new->action = old->action;
920 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) 925 for (i = 0; i < AUDIT_BITMASK_SIZE; i++)
921 new->mask[i] = old->mask[i]; 926 new->mask[i] = old->mask[i];
927 new->prio = old->prio;
922 new->buflen = old->buflen; 928 new->buflen = old->buflen;
923 new->inode_f = old->inode_f; 929 new->inode_f = old->inode_f;
924 new->watch = NULL; 930 new->watch = NULL;
@@ -987,9 +993,8 @@ static void audit_update_watch(struct audit_parent *parent,
987 993
988 /* If the update involves invalidating rules, do the inode-based 994 /* If the update involves invalidating rules, do the inode-based
989 * filtering now, so we don't omit records. */ 995 * filtering now, so we don't omit records. */
990 if (invalidating && current->audit_context && 996 if (invalidating && current->audit_context)
991 audit_filter_inodes(current, current->audit_context) == AUDIT_RECORD_CONTEXT) 997 audit_filter_inodes(current, current->audit_context);
992 audit_set_auditable(current->audit_context);
993 998
994 nwatch = audit_dupe_watch(owatch); 999 nwatch = audit_dupe_watch(owatch);
995 if (IS_ERR(nwatch)) { 1000 if (IS_ERR(nwatch)) {
@@ -1007,12 +1012,15 @@ static void audit_update_watch(struct audit_parent *parent,
1007 list_del_rcu(&oentry->list); 1012 list_del_rcu(&oentry->list);
1008 1013
1009 nentry = audit_dupe_rule(&oentry->rule, nwatch); 1014 nentry = audit_dupe_rule(&oentry->rule, nwatch);
1010 if (IS_ERR(nentry)) 1015 if (IS_ERR(nentry)) {
1016 list_del(&oentry->rule.list);
1011 audit_panic("error updating watch, removing"); 1017 audit_panic("error updating watch, removing");
1012 else { 1018 } else {
1013 int h = audit_hash_ino((u32)ino); 1019 int h = audit_hash_ino((u32)ino);
1014 list_add(&nentry->rule.rlist, &nwatch->rules); 1020 list_add(&nentry->rule.rlist, &nwatch->rules);
1015 list_add_rcu(&nentry->list, &audit_inode_hash[h]); 1021 list_add_rcu(&nentry->list, &audit_inode_hash[h]);
1022 list_replace(&oentry->rule.list,
1023 &nentry->rule.list);
1016 } 1024 }
1017 1025
1018 call_rcu(&oentry->rcu, audit_free_rule_rcu); 1026 call_rcu(&oentry->rcu, audit_free_rule_rcu);
@@ -1077,6 +1085,7 @@ static void audit_remove_parent_watches(struct audit_parent *parent)
1077 audit_log_end(ab); 1085 audit_log_end(ab);
1078 } 1086 }
1079 list_del(&r->rlist); 1087 list_del(&r->rlist);
1088 list_del(&r->list);
1080 list_del_rcu(&e->list); 1089 list_del_rcu(&e->list);
1081 call_rcu(&e->rcu, audit_free_rule_rcu); 1090 call_rcu(&e->rcu, audit_free_rule_rcu);
1082 } 1091 }
@@ -1102,12 +1111,16 @@ static void audit_inotify_unregister(struct list_head *in_list)
1102/* Find an existing audit rule. 1111/* Find an existing audit rule.
1103 * Caller must hold audit_filter_mutex to prevent stale rule data. */ 1112 * Caller must hold audit_filter_mutex to prevent stale rule data. */
1104static struct audit_entry *audit_find_rule(struct audit_entry *entry, 1113static struct audit_entry *audit_find_rule(struct audit_entry *entry,
1105 struct list_head *list) 1114 struct list_head **p)
1106{ 1115{
1107 struct audit_entry *e, *found = NULL; 1116 struct audit_entry *e, *found = NULL;
1117 struct list_head *list;
1108 int h; 1118 int h;
1109 1119
1110 if (entry->rule.watch) { 1120 if (entry->rule.inode_f) {
1121 h = audit_hash_ino(entry->rule.inode_f->val);
1122 *p = list = &audit_inode_hash[h];
1123 } else if (entry->rule.watch) {
1111 /* we don't know the inode number, so must walk entire hash */ 1124 /* we don't know the inode number, so must walk entire hash */
1112 for (h = 0; h < AUDIT_INODE_BUCKETS; h++) { 1125 for (h = 0; h < AUDIT_INODE_BUCKETS; h++) {
1113 list = &audit_inode_hash[h]; 1126 list = &audit_inode_hash[h];
@@ -1118,6 +1131,8 @@ static struct audit_entry *audit_find_rule(struct audit_entry *entry,
1118 } 1131 }
1119 } 1132 }
1120 goto out; 1133 goto out;
1134 } else {
1135 *p = list = &audit_filter_list[entry->rule.listnr];
1121 } 1136 }
1122 1137
1123 list_for_each_entry(e, list, list) 1138 list_for_each_entry(e, list, list)
@@ -1258,15 +1273,17 @@ static int audit_add_watch(struct audit_krule *krule, struct nameidata *ndp,
1258 return ret; 1273 return ret;
1259} 1274}
1260 1275
1276static u64 prio_low = ~0ULL/2;
1277static u64 prio_high = ~0ULL/2 - 1;
1278
1261/* Add rule to given filterlist if not a duplicate. */ 1279/* Add rule to given filterlist if not a duplicate. */
1262static inline int audit_add_rule(struct audit_entry *entry, 1280static inline int audit_add_rule(struct audit_entry *entry)
1263 struct list_head *list)
1264{ 1281{
1265 struct audit_entry *e; 1282 struct audit_entry *e;
1266 struct audit_field *inode_f = entry->rule.inode_f;
1267 struct audit_watch *watch = entry->rule.watch; 1283 struct audit_watch *watch = entry->rule.watch;
1268 struct audit_tree *tree = entry->rule.tree; 1284 struct audit_tree *tree = entry->rule.tree;
1269 struct nameidata *ndp = NULL, *ndw = NULL; 1285 struct nameidata *ndp = NULL, *ndw = NULL;
1286 struct list_head *list;
1270 int h, err; 1287 int h, err;
1271#ifdef CONFIG_AUDITSYSCALL 1288#ifdef CONFIG_AUDITSYSCALL
1272 int dont_count = 0; 1289 int dont_count = 0;
@@ -1277,13 +1294,8 @@ static inline int audit_add_rule(struct audit_entry *entry,
1277 dont_count = 1; 1294 dont_count = 1;
1278#endif 1295#endif
1279 1296
1280 if (inode_f) {
1281 h = audit_hash_ino(inode_f->val);
1282 list = &audit_inode_hash[h];
1283 }
1284
1285 mutex_lock(&audit_filter_mutex); 1297 mutex_lock(&audit_filter_mutex);
1286 e = audit_find_rule(entry, list); 1298 e = audit_find_rule(entry, &list);
1287 mutex_unlock(&audit_filter_mutex); 1299 mutex_unlock(&audit_filter_mutex);
1288 if (e) { 1300 if (e) {
1289 err = -EEXIST; 1301 err = -EEXIST;
@@ -1319,10 +1331,22 @@ static inline int audit_add_rule(struct audit_entry *entry,
1319 } 1331 }
1320 } 1332 }
1321 1333
1334 entry->rule.prio = ~0ULL;
1335 if (entry->rule.listnr == AUDIT_FILTER_EXIT) {
1336 if (entry->rule.flags & AUDIT_FILTER_PREPEND)
1337 entry->rule.prio = ++prio_high;
1338 else
1339 entry->rule.prio = --prio_low;
1340 }
1341
1322 if (entry->rule.flags & AUDIT_FILTER_PREPEND) { 1342 if (entry->rule.flags & AUDIT_FILTER_PREPEND) {
1343 list_add(&entry->rule.list,
1344 &audit_rules_list[entry->rule.listnr]);
1323 list_add_rcu(&entry->list, list); 1345 list_add_rcu(&entry->list, list);
1324 entry->rule.flags &= ~AUDIT_FILTER_PREPEND; 1346 entry->rule.flags &= ~AUDIT_FILTER_PREPEND;
1325 } else { 1347 } else {
1348 list_add_tail(&entry->rule.list,
1349 &audit_rules_list[entry->rule.listnr]);
1326 list_add_tail_rcu(&entry->list, list); 1350 list_add_tail_rcu(&entry->list, list);
1327 } 1351 }
1328#ifdef CONFIG_AUDITSYSCALL 1352#ifdef CONFIG_AUDITSYSCALL
@@ -1345,15 +1369,14 @@ error:
1345} 1369}
1346 1370
1347/* Remove an existing rule from filterlist. */ 1371/* Remove an existing rule from filterlist. */
1348static inline int audit_del_rule(struct audit_entry *entry, 1372static inline int audit_del_rule(struct audit_entry *entry)
1349 struct list_head *list)
1350{ 1373{
1351 struct audit_entry *e; 1374 struct audit_entry *e;
1352 struct audit_field *inode_f = entry->rule.inode_f;
1353 struct audit_watch *watch, *tmp_watch = entry->rule.watch; 1375 struct audit_watch *watch, *tmp_watch = entry->rule.watch;
1354 struct audit_tree *tree = entry->rule.tree; 1376 struct audit_tree *tree = entry->rule.tree;
1377 struct list_head *list;
1355 LIST_HEAD(inotify_list); 1378 LIST_HEAD(inotify_list);
1356 int h, ret = 0; 1379 int ret = 0;
1357#ifdef CONFIG_AUDITSYSCALL 1380#ifdef CONFIG_AUDITSYSCALL
1358 int dont_count = 0; 1381 int dont_count = 0;
1359 1382
@@ -1363,13 +1386,8 @@ static inline int audit_del_rule(struct audit_entry *entry,
1363 dont_count = 1; 1386 dont_count = 1;
1364#endif 1387#endif
1365 1388
1366 if (inode_f) {
1367 h = audit_hash_ino(inode_f->val);
1368 list = &audit_inode_hash[h];
1369 }
1370
1371 mutex_lock(&audit_filter_mutex); 1389 mutex_lock(&audit_filter_mutex);
1372 e = audit_find_rule(entry, list); 1390 e = audit_find_rule(entry, &list);
1373 if (!e) { 1391 if (!e) {
1374 mutex_unlock(&audit_filter_mutex); 1392 mutex_unlock(&audit_filter_mutex);
1375 ret = -ENOENT; 1393 ret = -ENOENT;
@@ -1404,6 +1422,7 @@ static inline int audit_del_rule(struct audit_entry *entry,
1404 audit_remove_tree_rule(&e->rule); 1422 audit_remove_tree_rule(&e->rule);
1405 1423
1406 list_del_rcu(&e->list); 1424 list_del_rcu(&e->list);
1425 list_del(&e->rule.list);
1407 call_rcu(&e->rcu, audit_free_rule_rcu); 1426 call_rcu(&e->rcu, audit_free_rule_rcu);
1408 1427
1409#ifdef CONFIG_AUDITSYSCALL 1428#ifdef CONFIG_AUDITSYSCALL
@@ -1432,30 +1451,16 @@ out:
1432static void audit_list(int pid, int seq, struct sk_buff_head *q) 1451static void audit_list(int pid, int seq, struct sk_buff_head *q)
1433{ 1452{
1434 struct sk_buff *skb; 1453 struct sk_buff *skb;
1435 struct audit_entry *entry; 1454 struct audit_krule *r;
1436 int i; 1455 int i;
1437 1456
1438 /* This is a blocking read, so use audit_filter_mutex instead of rcu 1457 /* This is a blocking read, so use audit_filter_mutex instead of rcu
1439 * iterator to sync with list writers. */ 1458 * iterator to sync with list writers. */
1440 for (i=0; i<AUDIT_NR_FILTERS; i++) { 1459 for (i=0; i<AUDIT_NR_FILTERS; i++) {
1441 list_for_each_entry(entry, &audit_filter_list[i], list) { 1460 list_for_each_entry(r, &audit_rules_list[i], list) {
1442 struct audit_rule *rule;
1443
1444 rule = audit_krule_to_rule(&entry->rule);
1445 if (unlikely(!rule))
1446 break;
1447 skb = audit_make_reply(pid, seq, AUDIT_LIST, 0, 1,
1448 rule, sizeof(*rule));
1449 if (skb)
1450 skb_queue_tail(q, skb);
1451 kfree(rule);
1452 }
1453 }
1454 for (i = 0; i < AUDIT_INODE_BUCKETS; i++) {
1455 list_for_each_entry(entry, &audit_inode_hash[i], list) {
1456 struct audit_rule *rule; 1461 struct audit_rule *rule;
1457 1462
1458 rule = audit_krule_to_rule(&entry->rule); 1463 rule = audit_krule_to_rule(r);
1459 if (unlikely(!rule)) 1464 if (unlikely(!rule))
1460 break; 1465 break;
1461 skb = audit_make_reply(pid, seq, AUDIT_LIST, 0, 1, 1466 skb = audit_make_reply(pid, seq, AUDIT_LIST, 0, 1,
@@ -1474,30 +1479,16 @@ static void audit_list(int pid, int seq, struct sk_buff_head *q)
1474static void audit_list_rules(int pid, int seq, struct sk_buff_head *q) 1479static void audit_list_rules(int pid, int seq, struct sk_buff_head *q)
1475{ 1480{
1476 struct sk_buff *skb; 1481 struct sk_buff *skb;
1477 struct audit_entry *e; 1482 struct audit_krule *r;
1478 int i; 1483 int i;
1479 1484
1480 /* This is a blocking read, so use audit_filter_mutex instead of rcu 1485 /* This is a blocking read, so use audit_filter_mutex instead of rcu
1481 * iterator to sync with list writers. */ 1486 * iterator to sync with list writers. */
1482 for (i=0; i<AUDIT_NR_FILTERS; i++) { 1487 for (i=0; i<AUDIT_NR_FILTERS; i++) {
1483 list_for_each_entry(e, &audit_filter_list[i], list) { 1488 list_for_each_entry(r, &audit_rules_list[i], list) {
1484 struct audit_rule_data *data;
1485
1486 data = audit_krule_to_data(&e->rule);
1487 if (unlikely(!data))
1488 break;
1489 skb = audit_make_reply(pid, seq, AUDIT_LIST_RULES, 0, 1,
1490 data, sizeof(*data) + data->buflen);
1491 if (skb)
1492 skb_queue_tail(q, skb);
1493 kfree(data);
1494 }
1495 }
1496 for (i=0; i< AUDIT_INODE_BUCKETS; i++) {
1497 list_for_each_entry(e, &audit_inode_hash[i], list) {
1498 struct audit_rule_data *data; 1489 struct audit_rule_data *data;
1499 1490
1500 data = audit_krule_to_data(&e->rule); 1491 data = audit_krule_to_data(r);
1501 if (unlikely(!data)) 1492 if (unlikely(!data))
1502 break; 1493 break;
1503 skb = audit_make_reply(pid, seq, AUDIT_LIST_RULES, 0, 1, 1494 skb = audit_make_reply(pid, seq, AUDIT_LIST_RULES, 0, 1,
@@ -1603,8 +1594,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data,
1603 if (IS_ERR(entry)) 1594 if (IS_ERR(entry))
1604 return PTR_ERR(entry); 1595 return PTR_ERR(entry);
1605 1596
1606 err = audit_add_rule(entry, 1597 err = audit_add_rule(entry);
1607 &audit_filter_list[entry->rule.listnr]);
1608 audit_log_rule_change(loginuid, sessionid, sid, "add", 1598 audit_log_rule_change(loginuid, sessionid, sid, "add",
1609 &entry->rule, !err); 1599 &entry->rule, !err);
1610 1600
@@ -1620,8 +1610,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data,
1620 if (IS_ERR(entry)) 1610 if (IS_ERR(entry))
1621 return PTR_ERR(entry); 1611 return PTR_ERR(entry);
1622 1612
1623 err = audit_del_rule(entry, 1613 err = audit_del_rule(entry);
1624 &audit_filter_list[entry->rule.listnr]);
1625 audit_log_rule_change(loginuid, sessionid, sid, "remove", 1614 audit_log_rule_change(loginuid, sessionid, sid, "remove",
1626 &entry->rule, !err); 1615 &entry->rule, !err);
1627 1616
@@ -1634,28 +1623,29 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data,
1634 return err; 1623 return err;
1635} 1624}
1636 1625
1637int audit_comparator(const u32 left, const u32 op, const u32 right) 1626int audit_comparator(u32 left, u32 op, u32 right)
1638{ 1627{
1639 switch (op) { 1628 switch (op) {
1640 case AUDIT_EQUAL: 1629 case Audit_equal:
1641 return (left == right); 1630 return (left == right);
1642 case AUDIT_NOT_EQUAL: 1631 case Audit_not_equal:
1643 return (left != right); 1632 return (left != right);
1644 case AUDIT_LESS_THAN: 1633 case Audit_lt:
1645 return (left < right); 1634 return (left < right);
1646 case AUDIT_LESS_THAN_OR_EQUAL: 1635 case Audit_le:
1647 return (left <= right); 1636 return (left <= right);
1648 case AUDIT_GREATER_THAN: 1637 case Audit_gt:
1649 return (left > right); 1638 return (left > right);
1650 case AUDIT_GREATER_THAN_OR_EQUAL: 1639 case Audit_ge:
1651 return (left >= right); 1640 return (left >= right);
1652 case AUDIT_BIT_MASK: 1641 case Audit_bitmask:
1653 return (left & right); 1642 return (left & right);
1654 case AUDIT_BIT_TEST: 1643 case Audit_bittest:
1655 return ((left & right) == right); 1644 return ((left & right) == right);
1645 default:
1646 BUG();
1647 return 0;
1656 } 1648 }
1657 BUG();
1658 return 0;
1659} 1649}
1660 1650
1661/* Compare given dentry name with last component in given path, 1651/* Compare given dentry name with last component in given path,
@@ -1778,6 +1768,43 @@ unlock_and_return:
1778 return result; 1768 return result;
1779} 1769}
1780 1770
1771static int update_lsm_rule(struct audit_krule *r)
1772{
1773 struct audit_entry *entry = container_of(r, struct audit_entry, rule);
1774 struct audit_entry *nentry;
1775 struct audit_watch *watch;
1776 struct audit_tree *tree;
1777 int err = 0;
1778
1779 if (!security_audit_rule_known(r))
1780 return 0;
1781
1782 watch = r->watch;
1783 tree = r->tree;
1784 nentry = audit_dupe_rule(r, watch);
1785 if (IS_ERR(nentry)) {
1786 /* save the first error encountered for the
1787 * return value */
1788 err = PTR_ERR(nentry);
1789 audit_panic("error updating LSM filters");
1790 if (watch)
1791 list_del(&r->rlist);
1792 list_del_rcu(&entry->list);
1793 list_del(&r->list);
1794 } else {
1795 if (watch) {
1796 list_add(&nentry->rule.rlist, &watch->rules);
1797 list_del(&r->rlist);
1798 } else if (tree)
1799 list_replace_init(&r->rlist, &nentry->rule.rlist);
1800 list_replace_rcu(&entry->list, &nentry->list);
1801 list_replace(&r->list, &nentry->rule.list);
1802 }
1803 call_rcu(&entry->rcu, audit_free_rule_rcu);
1804
1805 return err;
1806}
1807
1781/* This function will re-initialize the lsm_rule field of all applicable rules. 1808/* This function will re-initialize the lsm_rule field of all applicable rules.
1782 * It will traverse the filter lists serarching for rules that contain LSM 1809 * It will traverse the filter lists serarching for rules that contain LSM
1783 * specific filter fields. When such a rule is found, it is copied, the 1810 * specific filter fields. When such a rule is found, it is copied, the
@@ -1785,45 +1812,19 @@ unlock_and_return:
1785 * updated rule. */ 1812 * updated rule. */
1786int audit_update_lsm_rules(void) 1813int audit_update_lsm_rules(void)
1787{ 1814{
1788 struct audit_entry *entry, *n, *nentry; 1815 struct audit_krule *r, *n;
1789 struct audit_watch *watch;
1790 struct audit_tree *tree;
1791 int i, err = 0; 1816 int i, err = 0;
1792 1817
1793 /* audit_filter_mutex synchronizes the writers */ 1818 /* audit_filter_mutex synchronizes the writers */
1794 mutex_lock(&audit_filter_mutex); 1819 mutex_lock(&audit_filter_mutex);
1795 1820
1796 for (i = 0; i < AUDIT_NR_FILTERS; i++) { 1821 for (i = 0; i < AUDIT_NR_FILTERS; i++) {
1797 list_for_each_entry_safe(entry, n, &audit_filter_list[i], list) { 1822 list_for_each_entry_safe(r, n, &audit_rules_list[i], list) {
1798 if (!security_audit_rule_known(&entry->rule)) 1823 int res = update_lsm_rule(r);
1799 continue; 1824 if (!err)
1800 1825 err = res;
1801 watch = entry->rule.watch;
1802 tree = entry->rule.tree;
1803 nentry = audit_dupe_rule(&entry->rule, watch);
1804 if (IS_ERR(nentry)) {
1805 /* save the first error encountered for the
1806 * return value */
1807 if (!err)
1808 err = PTR_ERR(nentry);
1809 audit_panic("error updating LSM filters");
1810 if (watch)
1811 list_del(&entry->rule.rlist);
1812 list_del_rcu(&entry->list);
1813 } else {
1814 if (watch) {
1815 list_add(&nentry->rule.rlist,
1816 &watch->rules);
1817 list_del(&entry->rule.rlist);
1818 } else if (tree)
1819 list_replace_init(&entry->rule.rlist,
1820 &nentry->rule.rlist);
1821 list_replace_rcu(&entry->list, &nentry->list);
1822 }
1823 call_rcu(&entry->rcu, audit_free_rule_rcu);
1824 } 1826 }
1825 } 1827 }
1826
1827 mutex_unlock(&audit_filter_mutex); 1828 mutex_unlock(&audit_filter_mutex);
1828 1829
1829 return err; 1830 return err;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 4819f3711973..8cbddff6c283 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -124,43 +124,6 @@ struct audit_aux_data {
124/* Number of target pids per aux struct. */ 124/* Number of target pids per aux struct. */
125#define AUDIT_AUX_PIDS 16 125#define AUDIT_AUX_PIDS 16
126 126
127struct audit_aux_data_mq_open {
128 struct audit_aux_data d;
129 int oflag;
130 mode_t mode;
131 struct mq_attr attr;
132};
133
134struct audit_aux_data_mq_sendrecv {
135 struct audit_aux_data d;
136 mqd_t mqdes;
137 size_t msg_len;
138 unsigned int msg_prio;
139 struct timespec abs_timeout;
140};
141
142struct audit_aux_data_mq_notify {
143 struct audit_aux_data d;
144 mqd_t mqdes;
145 struct sigevent notification;
146};
147
148struct audit_aux_data_mq_getsetattr {
149 struct audit_aux_data d;
150 mqd_t mqdes;
151 struct mq_attr mqstat;
152};
153
154struct audit_aux_data_ipcctl {
155 struct audit_aux_data d;
156 struct ipc_perm p;
157 unsigned long qbytes;
158 uid_t uid;
159 gid_t gid;
160 mode_t mode;
161 u32 osid;
162};
163
164struct audit_aux_data_execve { 127struct audit_aux_data_execve {
165 struct audit_aux_data d; 128 struct audit_aux_data d;
166 int argc; 129 int argc;
@@ -168,23 +131,6 @@ struct audit_aux_data_execve {
168 struct mm_struct *mm; 131 struct mm_struct *mm;
169}; 132};
170 133
171struct audit_aux_data_socketcall {
172 struct audit_aux_data d;
173 int nargs;
174 unsigned long args[0];
175};
176
177struct audit_aux_data_sockaddr {
178 struct audit_aux_data d;
179 int len;
180 char a[0];
181};
182
183struct audit_aux_data_fd_pair {
184 struct audit_aux_data d;
185 int fd[2];
186};
187
188struct audit_aux_data_pids { 134struct audit_aux_data_pids {
189 struct audit_aux_data d; 135 struct audit_aux_data d;
190 pid_t target_pid[AUDIT_AUX_PIDS]; 136 pid_t target_pid[AUDIT_AUX_PIDS];
@@ -219,14 +165,14 @@ struct audit_tree_refs {
219struct audit_context { 165struct audit_context {
220 int dummy; /* must be the first element */ 166 int dummy; /* must be the first element */
221 int in_syscall; /* 1 if task is in a syscall */ 167 int in_syscall; /* 1 if task is in a syscall */
222 enum audit_state state; 168 enum audit_state state, current_state;
223 unsigned int serial; /* serial number for record */ 169 unsigned int serial; /* serial number for record */
224 struct timespec ctime; /* time of syscall entry */ 170 struct timespec ctime; /* time of syscall entry */
225 int major; /* syscall number */ 171 int major; /* syscall number */
226 unsigned long argv[4]; /* syscall arguments */ 172 unsigned long argv[4]; /* syscall arguments */
227 int return_valid; /* return code is valid */ 173 int return_valid; /* return code is valid */
228 long return_code;/* syscall return code */ 174 long return_code;/* syscall return code */
229 int auditable; /* 1 if record should be written */ 175 u64 prio;
230 int name_count; 176 int name_count;
231 struct audit_names names[AUDIT_NAMES]; 177 struct audit_names names[AUDIT_NAMES];
232 char * filterkey; /* key for rule that triggered record */ 178 char * filterkey; /* key for rule that triggered record */
@@ -234,7 +180,8 @@ struct audit_context {
234 struct audit_context *previous; /* For nested syscalls */ 180 struct audit_context *previous; /* For nested syscalls */
235 struct audit_aux_data *aux; 181 struct audit_aux_data *aux;
236 struct audit_aux_data *aux_pids; 182 struct audit_aux_data *aux_pids;
237 183 struct sockaddr_storage *sockaddr;
184 size_t sockaddr_len;
238 /* Save things to print about task_struct */ 185 /* Save things to print about task_struct */
239 pid_t pid, ppid; 186 pid_t pid, ppid;
240 uid_t uid, euid, suid, fsuid; 187 uid_t uid, euid, suid, fsuid;
@@ -252,6 +199,49 @@ struct audit_context {
252 struct audit_tree_refs *trees, *first_trees; 199 struct audit_tree_refs *trees, *first_trees;
253 int tree_count; 200 int tree_count;
254 201
202 int type;
203 union {
204 struct {
205 int nargs;
206 long args[6];
207 } socketcall;
208 struct {
209 uid_t uid;
210 gid_t gid;
211 mode_t mode;
212 u32 osid;
213 int has_perm;
214 uid_t perm_uid;
215 gid_t perm_gid;
216 mode_t perm_mode;
217 unsigned long qbytes;
218 } ipc;
219 struct {
220 mqd_t mqdes;
221 struct mq_attr mqstat;
222 } mq_getsetattr;
223 struct {
224 mqd_t mqdes;
225 int sigev_signo;
226 } mq_notify;
227 struct {
228 mqd_t mqdes;
229 size_t msg_len;
230 unsigned int msg_prio;
231 struct timespec abs_timeout;
232 } mq_sendrecv;
233 struct {
234 int oflag;
235 mode_t mode;
236 struct mq_attr attr;
237 } mq_open;
238 struct {
239 pid_t pid;
240 struct audit_cap_data cap;
241 } capset;
242 };
243 int fds[2];
244
255#if AUDIT_DEBUG 245#if AUDIT_DEBUG
256 int put_count; 246 int put_count;
257 int ino_count; 247 int ino_count;
@@ -608,19 +598,12 @@ static int audit_filter_rules(struct task_struct *tsk,
608 } 598 }
609 } 599 }
610 /* Find ipc objects that match */ 600 /* Find ipc objects that match */
611 if (ctx) { 601 if (!ctx || ctx->type != AUDIT_IPC)
612 struct audit_aux_data *aux; 602 break;
613 for (aux = ctx->aux; aux; 603 if (security_audit_rule_match(ctx->ipc.osid,
614 aux = aux->next) { 604 f->type, f->op,
615 if (aux->type == AUDIT_IPC) { 605 f->lsm_rule, ctx))
616 struct audit_aux_data_ipcctl *axi = (void *)aux; 606 ++result;
617 if (security_audit_rule_match(axi->osid, f->type, f->op, f->lsm_rule, ctx)) {
618 ++result;
619 break;
620 }
621 }
622 }
623 }
624 } 607 }
625 break; 608 break;
626 case AUDIT_ARG0: 609 case AUDIT_ARG0:
@@ -647,8 +630,16 @@ static int audit_filter_rules(struct task_struct *tsk,
647 return 0; 630 return 0;
648 } 631 }
649 } 632 }
650 if (rule->filterkey && ctx) 633
651 ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC); 634 if (ctx) {
635 if (rule->prio <= ctx->prio)
636 return 0;
637 if (rule->filterkey) {
638 kfree(ctx->filterkey);
639 ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC);
640 }
641 ctx->prio = rule->prio;
642 }
652 switch (rule->action) { 643 switch (rule->action) {
653 case AUDIT_NEVER: *state = AUDIT_DISABLED; break; 644 case AUDIT_NEVER: *state = AUDIT_DISABLED; break;
654 case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break; 645 case AUDIT_ALWAYS: *state = AUDIT_RECORD_CONTEXT; break;
@@ -661,7 +652,7 @@ static int audit_filter_rules(struct task_struct *tsk,
661 * completely disabled for this task. Since we only have the task 652 * completely disabled for this task. Since we only have the task
662 * structure at this point, we can only check uid and gid. 653 * structure at this point, we can only check uid and gid.
663 */ 654 */
664static enum audit_state audit_filter_task(struct task_struct *tsk) 655static enum audit_state audit_filter_task(struct task_struct *tsk, char **key)
665{ 656{
666 struct audit_entry *e; 657 struct audit_entry *e;
667 enum audit_state state; 658 enum audit_state state;
@@ -669,6 +660,8 @@ static enum audit_state audit_filter_task(struct task_struct *tsk)
669 rcu_read_lock(); 660 rcu_read_lock();
670 list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) { 661 list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TASK], list) {
671 if (audit_filter_rules(tsk, &e->rule, NULL, NULL, &state)) { 662 if (audit_filter_rules(tsk, &e->rule, NULL, NULL, &state)) {
663 if (state == AUDIT_RECORD_CONTEXT)
664 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
672 rcu_read_unlock(); 665 rcu_read_unlock();
673 return state; 666 return state;
674 } 667 }
@@ -702,6 +695,7 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
702 audit_filter_rules(tsk, &e->rule, ctx, NULL, 695 audit_filter_rules(tsk, &e->rule, ctx, NULL,
703 &state)) { 696 &state)) {
704 rcu_read_unlock(); 697 rcu_read_unlock();
698 ctx->current_state = state;
705 return state; 699 return state;
706 } 700 }
707 } 701 }
@@ -715,15 +709,14 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
715 * buckets applicable to the inode numbers in audit_names[]. 709 * buckets applicable to the inode numbers in audit_names[].
716 * Regarding audit_state, same rules apply as for audit_filter_syscall(). 710 * Regarding audit_state, same rules apply as for audit_filter_syscall().
717 */ 711 */
718enum audit_state audit_filter_inodes(struct task_struct *tsk, 712void audit_filter_inodes(struct task_struct *tsk, struct audit_context *ctx)
719 struct audit_context *ctx)
720{ 713{
721 int i; 714 int i;
722 struct audit_entry *e; 715 struct audit_entry *e;
723 enum audit_state state; 716 enum audit_state state;
724 717
725 if (audit_pid && tsk->tgid == audit_pid) 718 if (audit_pid && tsk->tgid == audit_pid)
726 return AUDIT_DISABLED; 719 return;
727 720
728 rcu_read_lock(); 721 rcu_read_lock();
729 for (i = 0; i < ctx->name_count; i++) { 722 for (i = 0; i < ctx->name_count; i++) {
@@ -740,17 +733,20 @@ enum audit_state audit_filter_inodes(struct task_struct *tsk,
740 if ((e->rule.mask[word] & bit) == bit && 733 if ((e->rule.mask[word] & bit) == bit &&
741 audit_filter_rules(tsk, &e->rule, ctx, n, &state)) { 734 audit_filter_rules(tsk, &e->rule, ctx, n, &state)) {
742 rcu_read_unlock(); 735 rcu_read_unlock();
743 return state; 736 ctx->current_state = state;
737 return;
744 } 738 }
745 } 739 }
746 } 740 }
747 rcu_read_unlock(); 741 rcu_read_unlock();
748 return AUDIT_BUILD_CONTEXT;
749} 742}
750 743
751void audit_set_auditable(struct audit_context *ctx) 744static void audit_set_auditable(struct audit_context *ctx)
752{ 745{
753 ctx->auditable = 1; 746 if (!ctx->prio) {
747 ctx->prio = 1;
748 ctx->current_state = AUDIT_RECORD_CONTEXT;
749 }
754} 750}
755 751
756static inline struct audit_context *audit_get_context(struct task_struct *tsk, 752static inline struct audit_context *audit_get_context(struct task_struct *tsk,
@@ -781,23 +777,11 @@ static inline struct audit_context *audit_get_context(struct task_struct *tsk,
781 else 777 else
782 context->return_code = return_code; 778 context->return_code = return_code;
783 779
784 if (context->in_syscall && !context->dummy && !context->auditable) { 780 if (context->in_syscall && !context->dummy) {
785 enum audit_state state; 781 audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]);
786 782 audit_filter_inodes(tsk, context);
787 state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_EXIT]);
788 if (state == AUDIT_RECORD_CONTEXT) {
789 context->auditable = 1;
790 goto get_context;
791 }
792
793 state = audit_filter_inodes(tsk, context);
794 if (state == AUDIT_RECORD_CONTEXT)
795 context->auditable = 1;
796
797 } 783 }
798 784
799get_context:
800
801 tsk->audit_context = NULL; 785 tsk->audit_context = NULL;
802 return context; 786 return context;
803} 787}
@@ -807,8 +791,7 @@ static inline void audit_free_names(struct audit_context *context)
807 int i; 791 int i;
808 792
809#if AUDIT_DEBUG == 2 793#if AUDIT_DEBUG == 2
810 if (context->auditable 794 if (context->put_count + context->ino_count != context->name_count) {
811 ||context->put_count + context->ino_count != context->name_count) {
812 printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d" 795 printk(KERN_ERR "%s:%d(:%d): major=%d in_syscall=%d"
813 " name_count=%d put_count=%d" 796 " name_count=%d put_count=%d"
814 " ino_count=%d [NOT freeing]\n", 797 " ino_count=%d [NOT freeing]\n",
@@ -859,6 +842,7 @@ static inline void audit_zero_context(struct audit_context *context,
859{ 842{
860 memset(context, 0, sizeof(*context)); 843 memset(context, 0, sizeof(*context));
861 context->state = state; 844 context->state = state;
845 context->prio = state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
862} 846}
863 847
864static inline struct audit_context *audit_alloc_context(enum audit_state state) 848static inline struct audit_context *audit_alloc_context(enum audit_state state)
@@ -884,18 +868,21 @@ int audit_alloc(struct task_struct *tsk)
884{ 868{
885 struct audit_context *context; 869 struct audit_context *context;
886 enum audit_state state; 870 enum audit_state state;
871 char *key = NULL;
887 872
888 if (likely(!audit_ever_enabled)) 873 if (likely(!audit_ever_enabled))
889 return 0; /* Return if not auditing. */ 874 return 0; /* Return if not auditing. */
890 875
891 state = audit_filter_task(tsk); 876 state = audit_filter_task(tsk, &key);
892 if (likely(state == AUDIT_DISABLED)) 877 if (likely(state == AUDIT_DISABLED))
893 return 0; 878 return 0;
894 879
895 if (!(context = audit_alloc_context(state))) { 880 if (!(context = audit_alloc_context(state))) {
881 kfree(key);
896 audit_log_lost("out of memory in audit_alloc"); 882 audit_log_lost("out of memory in audit_alloc");
897 return -ENOMEM; 883 return -ENOMEM;
898 } 884 }
885 context->filterkey = key;
899 886
900 tsk->audit_context = context; 887 tsk->audit_context = context;
901 set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT); 888 set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
@@ -921,6 +908,7 @@ static inline void audit_free_context(struct audit_context *context)
921 free_tree_refs(context); 908 free_tree_refs(context);
922 audit_free_aux(context); 909 audit_free_aux(context);
923 kfree(context->filterkey); 910 kfree(context->filterkey);
911 kfree(context->sockaddr);
924 kfree(context); 912 kfree(context);
925 context = previous; 913 context = previous;
926 } while (context); 914 } while (context);
@@ -1230,6 +1218,97 @@ static void audit_log_fcaps(struct audit_buffer *ab, struct audit_names *name)
1230 audit_log_format(ab, " cap_fe=%d cap_fver=%x", name->fcap.fE, name->fcap_ver); 1218 audit_log_format(ab, " cap_fe=%d cap_fver=%x", name->fcap.fE, name->fcap_ver);
1231} 1219}
1232 1220
1221static void show_special(struct audit_context *context, int *call_panic)
1222{
1223 struct audit_buffer *ab;
1224 int i;
1225
1226 ab = audit_log_start(context, GFP_KERNEL, context->type);
1227 if (!ab)
1228 return;
1229
1230 switch (context->type) {
1231 case AUDIT_SOCKETCALL: {
1232 int nargs = context->socketcall.nargs;
1233 audit_log_format(ab, "nargs=%d", nargs);
1234 for (i = 0; i < nargs; i++)
1235 audit_log_format(ab, " a%d=%lx", i,
1236 context->socketcall.args[i]);
1237 break; }
1238 case AUDIT_IPC: {
1239 u32 osid = context->ipc.osid;
1240
1241 audit_log_format(ab, "ouid=%u ogid=%u mode=%#o",
1242 context->ipc.uid, context->ipc.gid, context->ipc.mode);
1243 if (osid) {
1244 char *ctx = NULL;
1245 u32 len;
1246 if (security_secid_to_secctx(osid, &ctx, &len)) {
1247 audit_log_format(ab, " osid=%u", osid);
1248 *call_panic = 1;
1249 } else {
1250 audit_log_format(ab, " obj=%s", ctx);
1251 security_release_secctx(ctx, len);
1252 }
1253 }
1254 if (context->ipc.has_perm) {
1255 audit_log_end(ab);
1256 ab = audit_log_start(context, GFP_KERNEL,
1257 AUDIT_IPC_SET_PERM);
1258 audit_log_format(ab,
1259 "qbytes=%lx ouid=%u ogid=%u mode=%#o",
1260 context->ipc.qbytes,
1261 context->ipc.perm_uid,
1262 context->ipc.perm_gid,
1263 context->ipc.perm_mode);
1264 if (!ab)
1265 return;
1266 }
1267 break; }
1268 case AUDIT_MQ_OPEN: {
1269 audit_log_format(ab,
1270 "oflag=0x%x mode=%#o mq_flags=0x%lx mq_maxmsg=%ld "
1271 "mq_msgsize=%ld mq_curmsgs=%ld",
1272 context->mq_open.oflag, context->mq_open.mode,
1273 context->mq_open.attr.mq_flags,
1274 context->mq_open.attr.mq_maxmsg,
1275 context->mq_open.attr.mq_msgsize,
1276 context->mq_open.attr.mq_curmsgs);
1277 break; }
1278 case AUDIT_MQ_SENDRECV: {
1279 audit_log_format(ab,
1280 "mqdes=%d msg_len=%zd msg_prio=%u "
1281 "abs_timeout_sec=%ld abs_timeout_nsec=%ld",
1282 context->mq_sendrecv.mqdes,
1283 context->mq_sendrecv.msg_len,
1284 context->mq_sendrecv.msg_prio,
1285 context->mq_sendrecv.abs_timeout.tv_sec,
1286 context->mq_sendrecv.abs_timeout.tv_nsec);
1287 break; }
1288 case AUDIT_MQ_NOTIFY: {
1289 audit_log_format(ab, "mqdes=%d sigev_signo=%d",
1290 context->mq_notify.mqdes,
1291 context->mq_notify.sigev_signo);
1292 break; }
1293 case AUDIT_MQ_GETSETATTR: {
1294 struct mq_attr *attr = &context->mq_getsetattr.mqstat;
1295 audit_log_format(ab,
1296 "mqdes=%d mq_flags=0x%lx mq_maxmsg=%ld mq_msgsize=%ld "
1297 "mq_curmsgs=%ld ",
1298 context->mq_getsetattr.mqdes,
1299 attr->mq_flags, attr->mq_maxmsg,
1300 attr->mq_msgsize, attr->mq_curmsgs);
1301 break; }
1302 case AUDIT_CAPSET: {
1303 audit_log_format(ab, "pid=%d", context->capset.pid);
1304 audit_log_cap(ab, "cap_pi", &context->capset.cap.inheritable);
1305 audit_log_cap(ab, "cap_pp", &context->capset.cap.permitted);
1306 audit_log_cap(ab, "cap_pe", &context->capset.cap.effective);
1307 break; }
1308 }
1309 audit_log_end(ab);
1310}
1311
1233static void audit_log_exit(struct audit_context *context, struct task_struct *tsk) 1312static void audit_log_exit(struct audit_context *context, struct task_struct *tsk)
1234{ 1313{
1235 const struct cred *cred; 1314 const struct cred *cred;
@@ -1307,94 +1386,12 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1307 continue; /* audit_panic has been called */ 1386 continue; /* audit_panic has been called */
1308 1387
1309 switch (aux->type) { 1388 switch (aux->type) {
1310 case AUDIT_MQ_OPEN: {
1311 struct audit_aux_data_mq_open *axi = (void *)aux;
1312 audit_log_format(ab,
1313 "oflag=0x%x mode=%#o mq_flags=0x%lx mq_maxmsg=%ld "
1314 "mq_msgsize=%ld mq_curmsgs=%ld",
1315 axi->oflag, axi->mode, axi->attr.mq_flags,
1316 axi->attr.mq_maxmsg, axi->attr.mq_msgsize,
1317 axi->attr.mq_curmsgs);
1318 break; }
1319
1320 case AUDIT_MQ_SENDRECV: {
1321 struct audit_aux_data_mq_sendrecv *axi = (void *)aux;
1322 audit_log_format(ab,
1323 "mqdes=%d msg_len=%zd msg_prio=%u "
1324 "abs_timeout_sec=%ld abs_timeout_nsec=%ld",
1325 axi->mqdes, axi->msg_len, axi->msg_prio,
1326 axi->abs_timeout.tv_sec, axi->abs_timeout.tv_nsec);
1327 break; }
1328
1329 case AUDIT_MQ_NOTIFY: {
1330 struct audit_aux_data_mq_notify *axi = (void *)aux;
1331 audit_log_format(ab,
1332 "mqdes=%d sigev_signo=%d",
1333 axi->mqdes,
1334 axi->notification.sigev_signo);
1335 break; }
1336
1337 case AUDIT_MQ_GETSETATTR: {
1338 struct audit_aux_data_mq_getsetattr *axi = (void *)aux;
1339 audit_log_format(ab,
1340 "mqdes=%d mq_flags=0x%lx mq_maxmsg=%ld mq_msgsize=%ld "
1341 "mq_curmsgs=%ld ",
1342 axi->mqdes,
1343 axi->mqstat.mq_flags, axi->mqstat.mq_maxmsg,
1344 axi->mqstat.mq_msgsize, axi->mqstat.mq_curmsgs);
1345 break; }
1346
1347 case AUDIT_IPC: {
1348 struct audit_aux_data_ipcctl *axi = (void *)aux;
1349 audit_log_format(ab,
1350 "ouid=%u ogid=%u mode=%#o",
1351 axi->uid, axi->gid, axi->mode);
1352 if (axi->osid != 0) {
1353 char *ctx = NULL;
1354 u32 len;
1355 if (security_secid_to_secctx(
1356 axi->osid, &ctx, &len)) {
1357 audit_log_format(ab, " osid=%u",
1358 axi->osid);
1359 call_panic = 1;
1360 } else {
1361 audit_log_format(ab, " obj=%s", ctx);
1362 security_release_secctx(ctx, len);
1363 }
1364 }
1365 break; }
1366
1367 case AUDIT_IPC_SET_PERM: {
1368 struct audit_aux_data_ipcctl *axi = (void *)aux;
1369 audit_log_format(ab,
1370 "qbytes=%lx ouid=%u ogid=%u mode=%#o",
1371 axi->qbytes, axi->uid, axi->gid, axi->mode);
1372 break; }
1373 1389
1374 case AUDIT_EXECVE: { 1390 case AUDIT_EXECVE: {
1375 struct audit_aux_data_execve *axi = (void *)aux; 1391 struct audit_aux_data_execve *axi = (void *)aux;
1376 audit_log_execve_info(context, &ab, axi); 1392 audit_log_execve_info(context, &ab, axi);
1377 break; } 1393 break; }
1378 1394
1379 case AUDIT_SOCKETCALL: {
1380 struct audit_aux_data_socketcall *axs = (void *)aux;
1381 audit_log_format(ab, "nargs=%d", axs->nargs);
1382 for (i=0; i<axs->nargs; i++)
1383 audit_log_format(ab, " a%d=%lx", i, axs->args[i]);
1384 break; }
1385
1386 case AUDIT_SOCKADDR: {
1387 struct audit_aux_data_sockaddr *axs = (void *)aux;
1388
1389 audit_log_format(ab, "saddr=");
1390 audit_log_n_hex(ab, axs->a, axs->len);
1391 break; }
1392
1393 case AUDIT_FD_PAIR: {
1394 struct audit_aux_data_fd_pair *axs = (void *)aux;
1395 audit_log_format(ab, "fd0=%d fd1=%d", axs->fd[0], axs->fd[1]);
1396 break; }
1397
1398 case AUDIT_BPRM_FCAPS: { 1395 case AUDIT_BPRM_FCAPS: {
1399 struct audit_aux_data_bprm_fcaps *axs = (void *)aux; 1396 struct audit_aux_data_bprm_fcaps *axs = (void *)aux;
1400 audit_log_format(ab, "fver=%x", axs->fcap_ver); 1397 audit_log_format(ab, "fver=%x", axs->fcap_ver);
@@ -1409,18 +1406,32 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1409 audit_log_cap(ab, "new_pe", &axs->new_pcap.effective); 1406 audit_log_cap(ab, "new_pe", &axs->new_pcap.effective);
1410 break; } 1407 break; }
1411 1408
1412 case AUDIT_CAPSET: {
1413 struct audit_aux_data_capset *axs = (void *)aux;
1414 audit_log_format(ab, "pid=%d", axs->pid);
1415 audit_log_cap(ab, "cap_pi", &axs->cap.inheritable);
1416 audit_log_cap(ab, "cap_pp", &axs->cap.permitted);
1417 audit_log_cap(ab, "cap_pe", &axs->cap.effective);
1418 break; }
1419
1420 } 1409 }
1421 audit_log_end(ab); 1410 audit_log_end(ab);
1422 } 1411 }
1423 1412
1413 if (context->type)
1414 show_special(context, &call_panic);
1415
1416 if (context->fds[0] >= 0) {
1417 ab = audit_log_start(context, GFP_KERNEL, AUDIT_FD_PAIR);
1418 if (ab) {
1419 audit_log_format(ab, "fd0=%d fd1=%d",
1420 context->fds[0], context->fds[1]);
1421 audit_log_end(ab);
1422 }
1423 }
1424
1425 if (context->sockaddr_len) {
1426 ab = audit_log_start(context, GFP_KERNEL, AUDIT_SOCKADDR);
1427 if (ab) {
1428 audit_log_format(ab, "saddr=");
1429 audit_log_n_hex(ab, (void *)context->sockaddr,
1430 context->sockaddr_len);
1431 audit_log_end(ab);
1432 }
1433 }
1434
1424 for (aux = context->aux_pids; aux; aux = aux->next) { 1435 for (aux = context->aux_pids; aux; aux = aux->next) {
1425 struct audit_aux_data_pids *axs = (void *)aux; 1436 struct audit_aux_data_pids *axs = (void *)aux;
1426 1437
@@ -1536,7 +1547,7 @@ void audit_free(struct task_struct *tsk)
1536 * We use GFP_ATOMIC here because we might be doing this 1547 * We use GFP_ATOMIC here because we might be doing this
1537 * in the context of the idle thread */ 1548 * in the context of the idle thread */
1538 /* that can happen only if we are called from do_exit() */ 1549 /* that can happen only if we are called from do_exit() */
1539 if (context->in_syscall && context->auditable) 1550 if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT)
1540 audit_log_exit(context, tsk); 1551 audit_log_exit(context, tsk);
1541 1552
1542 audit_free_context(context); 1553 audit_free_context(context);
@@ -1620,15 +1631,17 @@ void audit_syscall_entry(int arch, int major,
1620 1631
1621 state = context->state; 1632 state = context->state;
1622 context->dummy = !audit_n_rules; 1633 context->dummy = !audit_n_rules;
1623 if (!context->dummy && (state == AUDIT_SETUP_CONTEXT || state == AUDIT_BUILD_CONTEXT)) 1634 if (!context->dummy && state == AUDIT_BUILD_CONTEXT) {
1635 context->prio = 0;
1624 state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_ENTRY]); 1636 state = audit_filter_syscall(tsk, context, &audit_filter_list[AUDIT_FILTER_ENTRY]);
1637 }
1625 if (likely(state == AUDIT_DISABLED)) 1638 if (likely(state == AUDIT_DISABLED))
1626 return; 1639 return;
1627 1640
1628 context->serial = 0; 1641 context->serial = 0;
1629 context->ctime = CURRENT_TIME; 1642 context->ctime = CURRENT_TIME;
1630 context->in_syscall = 1; 1643 context->in_syscall = 1;
1631 context->auditable = !!(state == AUDIT_RECORD_CONTEXT); 1644 context->current_state = state;
1632 context->ppid = 0; 1645 context->ppid = 0;
1633} 1646}
1634 1647
@@ -1636,17 +1649,20 @@ void audit_finish_fork(struct task_struct *child)
1636{ 1649{
1637 struct audit_context *ctx = current->audit_context; 1650 struct audit_context *ctx = current->audit_context;
1638 struct audit_context *p = child->audit_context; 1651 struct audit_context *p = child->audit_context;
1639 if (!p || !ctx || !ctx->auditable) 1652 if (!p || !ctx)
1653 return;
1654 if (!ctx->in_syscall || ctx->current_state != AUDIT_RECORD_CONTEXT)
1640 return; 1655 return;
1641 p->arch = ctx->arch; 1656 p->arch = ctx->arch;
1642 p->major = ctx->major; 1657 p->major = ctx->major;
1643 memcpy(p->argv, ctx->argv, sizeof(ctx->argv)); 1658 memcpy(p->argv, ctx->argv, sizeof(ctx->argv));
1644 p->ctime = ctx->ctime; 1659 p->ctime = ctx->ctime;
1645 p->dummy = ctx->dummy; 1660 p->dummy = ctx->dummy;
1646 p->auditable = ctx->auditable;
1647 p->in_syscall = ctx->in_syscall; 1661 p->in_syscall = ctx->in_syscall;
1648 p->filterkey = kstrdup(ctx->filterkey, GFP_KERNEL); 1662 p->filterkey = kstrdup(ctx->filterkey, GFP_KERNEL);
1649 p->ppid = current->pid; 1663 p->ppid = current->pid;
1664 p->prio = ctx->prio;
1665 p->current_state = ctx->current_state;
1650} 1666}
1651 1667
1652/** 1668/**
@@ -1670,11 +1686,11 @@ void audit_syscall_exit(int valid, long return_code)
1670 if (likely(!context)) 1686 if (likely(!context))
1671 return; 1687 return;
1672 1688
1673 if (context->in_syscall && context->auditable) 1689 if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT)
1674 audit_log_exit(context, tsk); 1690 audit_log_exit(context, tsk);
1675 1691
1676 context->in_syscall = 0; 1692 context->in_syscall = 0;
1677 context->auditable = 0; 1693 context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
1678 1694
1679 if (context->previous) { 1695 if (context->previous) {
1680 struct audit_context *new_context = context->previous; 1696 struct audit_context *new_context = context->previous;
@@ -1689,8 +1705,13 @@ void audit_syscall_exit(int valid, long return_code)
1689 context->aux_pids = NULL; 1705 context->aux_pids = NULL;
1690 context->target_pid = 0; 1706 context->target_pid = 0;
1691 context->target_sid = 0; 1707 context->target_sid = 0;
1692 kfree(context->filterkey); 1708 context->sockaddr_len = 0;
1693 context->filterkey = NULL; 1709 context->type = 0;
1710 context->fds[0] = -1;
1711 if (context->state != AUDIT_RECORD_CONTEXT) {
1712 kfree(context->filterkey);
1713 context->filterkey = NULL;
1714 }
1694 tsk->audit_context = context; 1715 tsk->audit_context = context;
1695 } 1716 }
1696} 1717}
@@ -2081,7 +2102,10 @@ int auditsc_get_stamp(struct audit_context *ctx,
2081 t->tv_sec = ctx->ctime.tv_sec; 2102 t->tv_sec = ctx->ctime.tv_sec;
2082 t->tv_nsec = ctx->ctime.tv_nsec; 2103 t->tv_nsec = ctx->ctime.tv_nsec;
2083 *serial = ctx->serial; 2104 *serial = ctx->serial;
2084 ctx->auditable = 1; 2105 if (!ctx->prio) {
2106 ctx->prio = 1;
2107 ctx->current_state = AUDIT_RECORD_CONTEXT;
2108 }
2085 return 1; 2109 return 1;
2086} 2110}
2087 2111
@@ -2127,132 +2151,46 @@ int audit_set_loginuid(struct task_struct *task, uid_t loginuid)
2127 * @mode: mode bits 2151 * @mode: mode bits
2128 * @u_attr: queue attributes 2152 * @u_attr: queue attributes
2129 * 2153 *
2130 * Returns 0 for success or NULL context or < 0 on error.
2131 */ 2154 */
2132int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr) 2155void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr)
2133{ 2156{
2134 struct audit_aux_data_mq_open *ax;
2135 struct audit_context *context = current->audit_context; 2157 struct audit_context *context = current->audit_context;
2136 2158
2137 if (!audit_enabled) 2159 if (attr)
2138 return 0; 2160 memcpy(&context->mq_open.attr, attr, sizeof(struct mq_attr));
2139 2161 else
2140 if (likely(!context)) 2162 memset(&context->mq_open.attr, 0, sizeof(struct mq_attr));
2141 return 0;
2142
2143 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2144 if (!ax)
2145 return -ENOMEM;
2146
2147 if (u_attr != NULL) {
2148 if (copy_from_user(&ax->attr, u_attr, sizeof(ax->attr))) {
2149 kfree(ax);
2150 return -EFAULT;
2151 }
2152 } else
2153 memset(&ax->attr, 0, sizeof(ax->attr));
2154 2163
2155 ax->oflag = oflag; 2164 context->mq_open.oflag = oflag;
2156 ax->mode = mode; 2165 context->mq_open.mode = mode;
2157 2166
2158 ax->d.type = AUDIT_MQ_OPEN; 2167 context->type = AUDIT_MQ_OPEN;
2159 ax->d.next = context->aux;
2160 context->aux = (void *)ax;
2161 return 0;
2162} 2168}
2163 2169
2164/** 2170/**
2165 * __audit_mq_timedsend - record audit data for a POSIX MQ timed send 2171 * __audit_mq_sendrecv - record audit data for a POSIX MQ timed send/receive
2166 * @mqdes: MQ descriptor 2172 * @mqdes: MQ descriptor
2167 * @msg_len: Message length 2173 * @msg_len: Message length
2168 * @msg_prio: Message priority 2174 * @msg_prio: Message priority
2169 * @u_abs_timeout: Message timeout in absolute time 2175 * @abs_timeout: Message timeout in absolute time
2170 * 2176 *
2171 * Returns 0 for success or NULL context or < 0 on error.
2172 */ 2177 */
2173int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, 2178void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio,
2174 const struct timespec __user *u_abs_timeout) 2179 const struct timespec *abs_timeout)
2175{ 2180{
2176 struct audit_aux_data_mq_sendrecv *ax;
2177 struct audit_context *context = current->audit_context; 2181 struct audit_context *context = current->audit_context;
2182 struct timespec *p = &context->mq_sendrecv.abs_timeout;
2178 2183
2179 if (!audit_enabled) 2184 if (abs_timeout)
2180 return 0; 2185 memcpy(p, abs_timeout, sizeof(struct timespec));
2181 2186 else
2182 if (likely(!context)) 2187 memset(p, 0, sizeof(struct timespec));
2183 return 0;
2184
2185 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2186 if (!ax)
2187 return -ENOMEM;
2188
2189 if (u_abs_timeout != NULL) {
2190 if (copy_from_user(&ax->abs_timeout, u_abs_timeout, sizeof(ax->abs_timeout))) {
2191 kfree(ax);
2192 return -EFAULT;
2193 }
2194 } else
2195 memset(&ax->abs_timeout, 0, sizeof(ax->abs_timeout));
2196
2197 ax->mqdes = mqdes;
2198 ax->msg_len = msg_len;
2199 ax->msg_prio = msg_prio;
2200
2201 ax->d.type = AUDIT_MQ_SENDRECV;
2202 ax->d.next = context->aux;
2203 context->aux = (void *)ax;
2204 return 0;
2205}
2206
2207/**
2208 * __audit_mq_timedreceive - record audit data for a POSIX MQ timed receive
2209 * @mqdes: MQ descriptor
2210 * @msg_len: Message length
2211 * @u_msg_prio: Message priority
2212 * @u_abs_timeout: Message timeout in absolute time
2213 *
2214 * Returns 0 for success or NULL context or < 0 on error.
2215 */
2216int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len,
2217 unsigned int __user *u_msg_prio,
2218 const struct timespec __user *u_abs_timeout)
2219{
2220 struct audit_aux_data_mq_sendrecv *ax;
2221 struct audit_context *context = current->audit_context;
2222
2223 if (!audit_enabled)
2224 return 0;
2225
2226 if (likely(!context))
2227 return 0;
2228
2229 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2230 if (!ax)
2231 return -ENOMEM;
2232
2233 if (u_msg_prio != NULL) {
2234 if (get_user(ax->msg_prio, u_msg_prio)) {
2235 kfree(ax);
2236 return -EFAULT;
2237 }
2238 } else
2239 ax->msg_prio = 0;
2240
2241 if (u_abs_timeout != NULL) {
2242 if (copy_from_user(&ax->abs_timeout, u_abs_timeout, sizeof(ax->abs_timeout))) {
2243 kfree(ax);
2244 return -EFAULT;
2245 }
2246 } else
2247 memset(&ax->abs_timeout, 0, sizeof(ax->abs_timeout));
2248 2188
2249 ax->mqdes = mqdes; 2189 context->mq_sendrecv.mqdes = mqdes;
2250 ax->msg_len = msg_len; 2190 context->mq_sendrecv.msg_len = msg_len;
2191 context->mq_sendrecv.msg_prio = msg_prio;
2251 2192
2252 ax->d.type = AUDIT_MQ_SENDRECV; 2193 context->type = AUDIT_MQ_SENDRECV;
2253 ax->d.next = context->aux;
2254 context->aux = (void *)ax;
2255 return 0;
2256} 2194}
2257 2195
2258/** 2196/**
@@ -2260,38 +2198,19 @@ int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len,
2260 * @mqdes: MQ descriptor 2198 * @mqdes: MQ descriptor
2261 * @u_notification: Notification event 2199 * @u_notification: Notification event
2262 * 2200 *
2263 * Returns 0 for success or NULL context or < 0 on error.
2264 */ 2201 */
2265 2202
2266int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) 2203void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
2267{ 2204{
2268 struct audit_aux_data_mq_notify *ax;
2269 struct audit_context *context = current->audit_context; 2205 struct audit_context *context = current->audit_context;
2270 2206
2271 if (!audit_enabled) 2207 if (notification)
2272 return 0; 2208 context->mq_notify.sigev_signo = notification->sigev_signo;
2273 2209 else
2274 if (likely(!context)) 2210 context->mq_notify.sigev_signo = 0;
2275 return 0;
2276
2277 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2278 if (!ax)
2279 return -ENOMEM;
2280
2281 if (u_notification != NULL) {
2282 if (copy_from_user(&ax->notification, u_notification, sizeof(ax->notification))) {
2283 kfree(ax);
2284 return -EFAULT;
2285 }
2286 } else
2287 memset(&ax->notification, 0, sizeof(ax->notification));
2288
2289 ax->mqdes = mqdes;
2290 2211
2291 ax->d.type = AUDIT_MQ_NOTIFY; 2212 context->mq_notify.mqdes = mqdes;
2292 ax->d.next = context->aux; 2213 context->type = AUDIT_MQ_NOTIFY;
2293 context->aux = (void *)ax;
2294 return 0;
2295} 2214}
2296 2215
2297/** 2216/**
@@ -2299,55 +2218,29 @@ int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification)
2299 * @mqdes: MQ descriptor 2218 * @mqdes: MQ descriptor
2300 * @mqstat: MQ flags 2219 * @mqstat: MQ flags
2301 * 2220 *
2302 * Returns 0 for success or NULL context or < 0 on error.
2303 */ 2221 */
2304int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) 2222void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
2305{ 2223{
2306 struct audit_aux_data_mq_getsetattr *ax;
2307 struct audit_context *context = current->audit_context; 2224 struct audit_context *context = current->audit_context;
2308 2225 context->mq_getsetattr.mqdes = mqdes;
2309 if (!audit_enabled) 2226 context->mq_getsetattr.mqstat = *mqstat;
2310 return 0; 2227 context->type = AUDIT_MQ_GETSETATTR;
2311
2312 if (likely(!context))
2313 return 0;
2314
2315 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2316 if (!ax)
2317 return -ENOMEM;
2318
2319 ax->mqdes = mqdes;
2320 ax->mqstat = *mqstat;
2321
2322 ax->d.type = AUDIT_MQ_GETSETATTR;
2323 ax->d.next = context->aux;
2324 context->aux = (void *)ax;
2325 return 0;
2326} 2228}
2327 2229
2328/** 2230/**
2329 * audit_ipc_obj - record audit data for ipc object 2231 * audit_ipc_obj - record audit data for ipc object
2330 * @ipcp: ipc permissions 2232 * @ipcp: ipc permissions
2331 * 2233 *
2332 * Returns 0 for success or NULL context or < 0 on error.
2333 */ 2234 */
2334int __audit_ipc_obj(struct kern_ipc_perm *ipcp) 2235void __audit_ipc_obj(struct kern_ipc_perm *ipcp)
2335{ 2236{
2336 struct audit_aux_data_ipcctl *ax;
2337 struct audit_context *context = current->audit_context; 2237 struct audit_context *context = current->audit_context;
2338 2238 context->ipc.uid = ipcp->uid;
2339 ax = kmalloc(sizeof(*ax), GFP_ATOMIC); 2239 context->ipc.gid = ipcp->gid;
2340 if (!ax) 2240 context->ipc.mode = ipcp->mode;
2341 return -ENOMEM; 2241 context->ipc.has_perm = 0;
2342 2242 security_ipc_getsecid(ipcp, &context->ipc.osid);
2343 ax->uid = ipcp->uid; 2243 context->type = AUDIT_IPC;
2344 ax->gid = ipcp->gid;
2345 ax->mode = ipcp->mode;
2346 security_ipc_getsecid(ipcp, &ax->osid);
2347 ax->d.type = AUDIT_IPC;
2348 ax->d.next = context->aux;
2349 context->aux = (void *)ax;
2350 return 0;
2351} 2244}
2352 2245
2353/** 2246/**
@@ -2357,26 +2250,17 @@ int __audit_ipc_obj(struct kern_ipc_perm *ipcp)
2357 * @gid: msgq group id 2250 * @gid: msgq group id
2358 * @mode: msgq mode (permissions) 2251 * @mode: msgq mode (permissions)
2359 * 2252 *
2360 * Returns 0 for success or NULL context or < 0 on error. 2253 * Called only after audit_ipc_obj().
2361 */ 2254 */
2362int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode) 2255void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode)
2363{ 2256{
2364 struct audit_aux_data_ipcctl *ax;
2365 struct audit_context *context = current->audit_context; 2257 struct audit_context *context = current->audit_context;
2366 2258
2367 ax = kmalloc(sizeof(*ax), GFP_ATOMIC); 2259 context->ipc.qbytes = qbytes;
2368 if (!ax) 2260 context->ipc.perm_uid = uid;
2369 return -ENOMEM; 2261 context->ipc.perm_gid = gid;
2370 2262 context->ipc.perm_mode = mode;
2371 ax->qbytes = qbytes; 2263 context->ipc.has_perm = 1;
2372 ax->uid = uid;
2373 ax->gid = gid;
2374 ax->mode = mode;
2375
2376 ax->d.type = AUDIT_IPC_SET_PERM;
2377 ax->d.next = context->aux;
2378 context->aux = (void *)ax;
2379 return 0;
2380} 2264}
2381 2265
2382int audit_bprm(struct linux_binprm *bprm) 2266int audit_bprm(struct linux_binprm *bprm)
@@ -2406,27 +2290,17 @@ int audit_bprm(struct linux_binprm *bprm)
2406 * @nargs: number of args 2290 * @nargs: number of args
2407 * @args: args array 2291 * @args: args array
2408 * 2292 *
2409 * Returns 0 for success or NULL context or < 0 on error.
2410 */ 2293 */
2411int audit_socketcall(int nargs, unsigned long *args) 2294void audit_socketcall(int nargs, unsigned long *args)
2412{ 2295{
2413 struct audit_aux_data_socketcall *ax;
2414 struct audit_context *context = current->audit_context; 2296 struct audit_context *context = current->audit_context;
2415 2297
2416 if (likely(!context || context->dummy)) 2298 if (likely(!context || context->dummy))
2417 return 0; 2299 return;
2418
2419 ax = kmalloc(sizeof(*ax) + nargs * sizeof(unsigned long), GFP_KERNEL);
2420 if (!ax)
2421 return -ENOMEM;
2422
2423 ax->nargs = nargs;
2424 memcpy(ax->args, args, nargs * sizeof(unsigned long));
2425 2300
2426 ax->d.type = AUDIT_SOCKETCALL; 2301 context->type = AUDIT_SOCKETCALL;
2427 ax->d.next = context->aux; 2302 context->socketcall.nargs = nargs;
2428 context->aux = (void *)ax; 2303 memcpy(context->socketcall.args, args, nargs * sizeof(unsigned long));
2429 return 0;
2430} 2304}
2431 2305
2432/** 2306/**
@@ -2434,29 +2308,12 @@ int audit_socketcall(int nargs, unsigned long *args)
2434 * @fd1: the first file descriptor 2308 * @fd1: the first file descriptor
2435 * @fd2: the second file descriptor 2309 * @fd2: the second file descriptor
2436 * 2310 *
2437 * Returns 0 for success or NULL context or < 0 on error.
2438 */ 2311 */
2439int __audit_fd_pair(int fd1, int fd2) 2312void __audit_fd_pair(int fd1, int fd2)
2440{ 2313{
2441 struct audit_context *context = current->audit_context; 2314 struct audit_context *context = current->audit_context;
2442 struct audit_aux_data_fd_pair *ax; 2315 context->fds[0] = fd1;
2443 2316 context->fds[1] = fd2;
2444 if (likely(!context)) {
2445 return 0;
2446 }
2447
2448 ax = kmalloc(sizeof(*ax), GFP_KERNEL);
2449 if (!ax) {
2450 return -ENOMEM;
2451 }
2452
2453 ax->fd[0] = fd1;
2454 ax->fd[1] = fd2;
2455
2456 ax->d.type = AUDIT_FD_PAIR;
2457 ax->d.next = context->aux;
2458 context->aux = (void *)ax;
2459 return 0;
2460} 2317}
2461 2318
2462/** 2319/**
@@ -2468,22 +2325,20 @@ int __audit_fd_pair(int fd1, int fd2)
2468 */ 2325 */
2469int audit_sockaddr(int len, void *a) 2326int audit_sockaddr(int len, void *a)
2470{ 2327{
2471 struct audit_aux_data_sockaddr *ax;
2472 struct audit_context *context = current->audit_context; 2328 struct audit_context *context = current->audit_context;
2473 2329
2474 if (likely(!context || context->dummy)) 2330 if (likely(!context || context->dummy))
2475 return 0; 2331 return 0;
2476 2332
2477 ax = kmalloc(sizeof(*ax) + len, GFP_KERNEL); 2333 if (!context->sockaddr) {
2478 if (!ax) 2334 void *p = kmalloc(sizeof(struct sockaddr_storage), GFP_KERNEL);
2479 return -ENOMEM; 2335 if (!p)
2480 2336 return -ENOMEM;
2481 ax->len = len; 2337 context->sockaddr = p;
2482 memcpy(ax->a, a, len); 2338 }
2483 2339
2484 ax->d.type = AUDIT_SOCKADDR; 2340 context->sockaddr_len = len;
2485 ax->d.next = context->aux; 2341 memcpy(context->sockaddr, a, len);
2486 context->aux = (void *)ax;
2487 return 0; 2342 return 0;
2488} 2343}
2489 2344
@@ -2617,29 +2472,15 @@ int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
2617 * Record the aguments userspace sent to sys_capset for later printing by the 2472 * Record the aguments userspace sent to sys_capset for later printing by the
2618 * audit system if applicable 2473 * audit system if applicable
2619 */ 2474 */
2620int __audit_log_capset(pid_t pid, 2475void __audit_log_capset(pid_t pid,
2621 const struct cred *new, const struct cred *old) 2476 const struct cred *new, const struct cred *old)
2622{ 2477{
2623 struct audit_aux_data_capset *ax;
2624 struct audit_context *context = current->audit_context; 2478 struct audit_context *context = current->audit_context;
2625 2479 context->capset.pid = pid;
2626 if (likely(!audit_enabled || !context || context->dummy)) 2480 context->capset.cap.effective = new->cap_effective;
2627 return 0; 2481 context->capset.cap.inheritable = new->cap_effective;
2628 2482 context->capset.cap.permitted = new->cap_permitted;
2629 ax = kmalloc(sizeof(*ax), GFP_KERNEL); 2483 context->type = AUDIT_CAPSET;
2630 if (!ax)
2631 return -ENOMEM;
2632
2633 ax->d.type = AUDIT_CAPSET;
2634 ax->d.next = context->aux;
2635 context->aux = (void *)ax;
2636
2637 ax->pid = pid;
2638 ax->cap.effective = new->cap_effective;
2639 ax->cap.inheritable = new->cap_effective;
2640 ax->cap.permitted = new->cap_permitted;
2641
2642 return 0;
2643} 2484}
2644 2485
2645/** 2486/**
diff --git a/kernel/capability.c b/kernel/capability.c
index 36b4b4daebec..c598d9d5be4f 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -280,9 +280,7 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
280 if (ret < 0) 280 if (ret < 0)
281 goto error; 281 goto error;
282 282
283 ret = audit_log_capset(pid, new, current_cred()); 283 audit_log_capset(pid, new, current_cred());
284 if (ret < 0)
285 return ret;
286 284
287 return commit_creds(new); 285 return commit_creds(new);
288 286
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 48348dde6d81..87bb0258fd27 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -573,7 +573,6 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb)
573 inode->i_mode = mode; 573 inode->i_mode = mode;
574 inode->i_uid = current_fsuid(); 574 inode->i_uid = current_fsuid();
575 inode->i_gid = current_fsgid(); 575 inode->i_gid = current_fsgid();
576 inode->i_blocks = 0;
577 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 576 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
578 inode->i_mapping->backing_dev_info = &cgroup_backing_dev_info; 577 inode->i_mapping->backing_dev_info = &cgroup_backing_dev_info;
579 } 578 }
@@ -2945,7 +2944,11 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
2945 parent = task_cgroup(tsk, subsys->subsys_id); 2944 parent = task_cgroup(tsk, subsys->subsys_id);
2946 2945
2947 /* Pin the hierarchy */ 2946 /* Pin the hierarchy */
2948 atomic_inc(&parent->root->sb->s_active); 2947 if (!atomic_inc_not_zero(&parent->root->sb->s_active)) {
2948 /* We race with the final deactivate_super() */
2949 mutex_unlock(&cgroup_mutex);
2950 return 0;
2951 }
2949 2952
2950 /* Keep the cgroup alive */ 2953 /* Keep the cgroup alive */
2951 get_css_set(cg); 2954 get_css_set(cg);
diff --git a/kernel/compat.c b/kernel/compat.c
index 8eafe3eb50d9..d52e2ec1deb5 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -454,16 +454,16 @@ asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,
454} 454}
455 455
456static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr, 456static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
457 unsigned len, cpumask_t *new_mask) 457 unsigned len, struct cpumask *new_mask)
458{ 458{
459 unsigned long *k; 459 unsigned long *k;
460 460
461 if (len < sizeof(cpumask_t)) 461 if (len < cpumask_size())
462 memset(new_mask, 0, sizeof(cpumask_t)); 462 memset(new_mask, 0, cpumask_size());
463 else if (len > sizeof(cpumask_t)) 463 else if (len > cpumask_size())
464 len = sizeof(cpumask_t); 464 len = cpumask_size();
465 465
466 k = cpus_addr(*new_mask); 466 k = cpumask_bits(new_mask);
467 return compat_get_bitmap(k, user_mask_ptr, len * 8); 467 return compat_get_bitmap(k, user_mask_ptr, len * 8);
468} 468}
469 469
@@ -471,40 +471,51 @@ asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
471 unsigned int len, 471 unsigned int len,
472 compat_ulong_t __user *user_mask_ptr) 472 compat_ulong_t __user *user_mask_ptr)
473{ 473{
474 cpumask_t new_mask; 474 cpumask_var_t new_mask;
475 int retval; 475 int retval;
476 476
477 retval = compat_get_user_cpu_mask(user_mask_ptr, len, &new_mask); 477 if (!alloc_cpumask_var(&new_mask, GFP_KERNEL))
478 return -ENOMEM;
479
480 retval = compat_get_user_cpu_mask(user_mask_ptr, len, new_mask);
478 if (retval) 481 if (retval)
479 return retval; 482 goto out;
480 483
481 return sched_setaffinity(pid, &new_mask); 484 retval = sched_setaffinity(pid, new_mask);
485out:
486 free_cpumask_var(new_mask);
487 return retval;
482} 488}
483 489
484asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len, 490asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
485 compat_ulong_t __user *user_mask_ptr) 491 compat_ulong_t __user *user_mask_ptr)
486{ 492{
487 int ret; 493 int ret;
488 cpumask_t mask; 494 cpumask_var_t mask;
489 unsigned long *k; 495 unsigned long *k;
490 unsigned int min_length = sizeof(cpumask_t); 496 unsigned int min_length = cpumask_size();
491 497
492 if (NR_CPUS <= BITS_PER_COMPAT_LONG) 498 if (nr_cpu_ids <= BITS_PER_COMPAT_LONG)
493 min_length = sizeof(compat_ulong_t); 499 min_length = sizeof(compat_ulong_t);
494 500
495 if (len < min_length) 501 if (len < min_length)
496 return -EINVAL; 502 return -EINVAL;
497 503
498 ret = sched_getaffinity(pid, &mask); 504 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
505 return -ENOMEM;
506
507 ret = sched_getaffinity(pid, mask);
499 if (ret < 0) 508 if (ret < 0)
500 return ret; 509 goto out;
501 510
502 k = cpus_addr(mask); 511 k = cpumask_bits(mask);
503 ret = compat_put_bitmap(user_mask_ptr, k, min_length * 8); 512 ret = compat_put_bitmap(user_mask_ptr, k, min_length * 8);
504 if (ret) 513 if (ret == 0)
505 return ret; 514 ret = min_length;
506 515
507 return min_length; 516out:
517 free_cpumask_var(mask);
518 return ret;
508} 519}
509 520
510int get_compat_itimerspec(struct itimerspec *dst, 521int get_compat_itimerspec(struct itimerspec *dst,
diff --git a/kernel/cpu.c b/kernel/cpu.c
index bae131a1211b..30e74dd6d01b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -15,30 +15,8 @@
15#include <linux/stop_machine.h> 15#include <linux/stop_machine.h>
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17 17
18/*
19 * Represents all cpu's present in the system
20 * In systems capable of hotplug, this map could dynamically grow
21 * as new cpu's are detected in the system via any platform specific
22 * method, such as ACPI for e.g.
23 */
24cpumask_t cpu_present_map __read_mostly;
25EXPORT_SYMBOL(cpu_present_map);
26
27/*
28 * Represents all cpu's that are currently online.
29 */
30cpumask_t cpu_online_map __read_mostly;
31EXPORT_SYMBOL(cpu_online_map);
32
33#ifdef CONFIG_INIT_ALL_POSSIBLE
34cpumask_t cpu_possible_map __read_mostly = CPU_MASK_ALL;
35#else
36cpumask_t cpu_possible_map __read_mostly;
37#endif
38EXPORT_SYMBOL(cpu_possible_map);
39
40#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
41/* Serializes the updates to cpu_online_map, cpu_present_map */ 19/* Serializes the updates to cpu_online_mask, cpu_present_mask */
42static DEFINE_MUTEX(cpu_add_remove_lock); 20static DEFINE_MUTEX(cpu_add_remove_lock);
43 21
44static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain); 22static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain);
@@ -65,8 +43,6 @@ void __init cpu_hotplug_init(void)
65 cpu_hotplug.refcount = 0; 43 cpu_hotplug.refcount = 0;
66} 44}
67 45
68cpumask_t cpu_active_map;
69
70#ifdef CONFIG_HOTPLUG_CPU 46#ifdef CONFIG_HOTPLUG_CPU
71 47
72void get_online_cpus(void) 48void get_online_cpus(void)
@@ -97,7 +73,7 @@ EXPORT_SYMBOL_GPL(put_online_cpus);
97 73
98/* 74/*
99 * The following two API's must be used when attempting 75 * The following two API's must be used when attempting
100 * to serialize the updates to cpu_online_map, cpu_present_map. 76 * to serialize the updates to cpu_online_mask, cpu_present_mask.
101 */ 77 */
102void cpu_maps_update_begin(void) 78void cpu_maps_update_begin(void)
103{ 79{
@@ -218,7 +194,7 @@ static int __ref take_cpu_down(void *_param)
218static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) 194static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
219{ 195{
220 int err, nr_calls = 0; 196 int err, nr_calls = 0;
221 cpumask_t old_allowed, tmp; 197 cpumask_var_t old_allowed;
222 void *hcpu = (void *)(long)cpu; 198 void *hcpu = (void *)(long)cpu;
223 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 199 unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0;
224 struct take_cpu_down_param tcd_param = { 200 struct take_cpu_down_param tcd_param = {
@@ -232,6 +208,9 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
232 if (!cpu_online(cpu)) 208 if (!cpu_online(cpu))
233 return -EINVAL; 209 return -EINVAL;
234 210
211 if (!alloc_cpumask_var(&old_allowed, GFP_KERNEL))
212 return -ENOMEM;
213
235 cpu_hotplug_begin(); 214 cpu_hotplug_begin();
236 err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod, 215 err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod,
237 hcpu, -1, &nr_calls); 216 hcpu, -1, &nr_calls);
@@ -246,13 +225,11 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
246 } 225 }
247 226
248 /* Ensure that we are not runnable on dying cpu */ 227 /* Ensure that we are not runnable on dying cpu */
249 old_allowed = current->cpus_allowed; 228 cpumask_copy(old_allowed, &current->cpus_allowed);
250 cpus_setall(tmp); 229 set_cpus_allowed_ptr(current,
251 cpu_clear(cpu, tmp); 230 cpumask_of(cpumask_any_but(cpu_online_mask, cpu)));
252 set_cpus_allowed_ptr(current, &tmp);
253 tmp = cpumask_of_cpu(cpu);
254 231
255 err = __stop_machine(take_cpu_down, &tcd_param, &tmp); 232 err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu));
256 if (err) { 233 if (err) {
257 /* CPU didn't die: tell everyone. Can't complain. */ 234 /* CPU didn't die: tell everyone. Can't complain. */
258 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, 235 if (raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
@@ -278,7 +255,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
278 check_for_tasks(cpu); 255 check_for_tasks(cpu);
279 256
280out_allowed: 257out_allowed:
281 set_cpus_allowed_ptr(current, &old_allowed); 258 set_cpus_allowed_ptr(current, old_allowed);
282out_release: 259out_release:
283 cpu_hotplug_done(); 260 cpu_hotplug_done();
284 if (!err) { 261 if (!err) {
@@ -286,13 +263,17 @@ out_release:
286 hcpu) == NOTIFY_BAD) 263 hcpu) == NOTIFY_BAD)
287 BUG(); 264 BUG();
288 } 265 }
266 free_cpumask_var(old_allowed);
289 return err; 267 return err;
290} 268}
291 269
292int __ref cpu_down(unsigned int cpu) 270int __ref cpu_down(unsigned int cpu)
293{ 271{
294 int err = 0; 272 int err;
295 273
274 err = stop_machine_create();
275 if (err)
276 return err;
296 cpu_maps_update_begin(); 277 cpu_maps_update_begin();
297 278
298 if (cpu_hotplug_disabled) { 279 if (cpu_hotplug_disabled) {
@@ -304,7 +285,7 @@ int __ref cpu_down(unsigned int cpu)
304 285
305 /* 286 /*
306 * Make sure the all cpus did the reschedule and are not 287 * Make sure the all cpus did the reschedule and are not
307 * using stale version of the cpu_active_map. 288 * using stale version of the cpu_active_mask.
308 * This is not strictly necessary becuase stop_machine() 289 * This is not strictly necessary becuase stop_machine()
309 * that we run down the line already provides the required 290 * that we run down the line already provides the required
310 * synchronization. But it's really a side effect and we do not 291 * synchronization. But it's really a side effect and we do not
@@ -319,6 +300,7 @@ int __ref cpu_down(unsigned int cpu)
319 300
320out: 301out:
321 cpu_maps_update_done(); 302 cpu_maps_update_done();
303 stop_machine_destroy();
322 return err; 304 return err;
323} 305}
324EXPORT_SYMBOL(cpu_down); 306EXPORT_SYMBOL(cpu_down);
@@ -368,7 +350,7 @@ out_notify:
368int __cpuinit cpu_up(unsigned int cpu) 350int __cpuinit cpu_up(unsigned int cpu)
369{ 351{
370 int err = 0; 352 int err = 0;
371 if (!cpu_isset(cpu, cpu_possible_map)) { 353 if (!cpu_possible(cpu)) {
372 printk(KERN_ERR "can't online cpu %d because it is not " 354 printk(KERN_ERR "can't online cpu %d because it is not "
373 "configured as may-hotadd at boot time\n", cpu); 355 "configured as may-hotadd at boot time\n", cpu);
374#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) 356#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
@@ -393,25 +375,25 @@ out:
393} 375}
394 376
395#ifdef CONFIG_PM_SLEEP_SMP 377#ifdef CONFIG_PM_SLEEP_SMP
396static cpumask_t frozen_cpus; 378static cpumask_var_t frozen_cpus;
397 379
398int disable_nonboot_cpus(void) 380int disable_nonboot_cpus(void)
399{ 381{
400 int cpu, first_cpu, error = 0; 382 int cpu, first_cpu, error = 0;
401 383
402 cpu_maps_update_begin(); 384 cpu_maps_update_begin();
403 first_cpu = first_cpu(cpu_online_map); 385 first_cpu = cpumask_first(cpu_online_mask);
404 /* We take down all of the non-boot CPUs in one shot to avoid races 386 /* We take down all of the non-boot CPUs in one shot to avoid races
405 * with the userspace trying to use the CPU hotplug at the same time 387 * with the userspace trying to use the CPU hotplug at the same time
406 */ 388 */
407 cpus_clear(frozen_cpus); 389 cpumask_clear(frozen_cpus);
408 printk("Disabling non-boot CPUs ...\n"); 390 printk("Disabling non-boot CPUs ...\n");
409 for_each_online_cpu(cpu) { 391 for_each_online_cpu(cpu) {
410 if (cpu == first_cpu) 392 if (cpu == first_cpu)
411 continue; 393 continue;
412 error = _cpu_down(cpu, 1); 394 error = _cpu_down(cpu, 1);
413 if (!error) { 395 if (!error) {
414 cpu_set(cpu, frozen_cpus); 396 cpumask_set_cpu(cpu, frozen_cpus);
415 printk("CPU%d is down\n", cpu); 397 printk("CPU%d is down\n", cpu);
416 } else { 398 } else {
417 printk(KERN_ERR "Error taking CPU%d down: %d\n", 399 printk(KERN_ERR "Error taking CPU%d down: %d\n",
@@ -437,11 +419,11 @@ void __ref enable_nonboot_cpus(void)
437 /* Allow everyone to use the CPU hotplug again */ 419 /* Allow everyone to use the CPU hotplug again */
438 cpu_maps_update_begin(); 420 cpu_maps_update_begin();
439 cpu_hotplug_disabled = 0; 421 cpu_hotplug_disabled = 0;
440 if (cpus_empty(frozen_cpus)) 422 if (cpumask_empty(frozen_cpus))
441 goto out; 423 goto out;
442 424
443 printk("Enabling non-boot CPUs ...\n"); 425 printk("Enabling non-boot CPUs ...\n");
444 for_each_cpu_mask_nr(cpu, frozen_cpus) { 426 for_each_cpu(cpu, frozen_cpus) {
445 error = _cpu_up(cpu, 1); 427 error = _cpu_up(cpu, 1);
446 if (!error) { 428 if (!error) {
447 printk("CPU%d is up\n", cpu); 429 printk("CPU%d is up\n", cpu);
@@ -449,10 +431,18 @@ void __ref enable_nonboot_cpus(void)
449 } 431 }
450 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error); 432 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error);
451 } 433 }
452 cpus_clear(frozen_cpus); 434 cpumask_clear(frozen_cpus);
453out: 435out:
454 cpu_maps_update_done(); 436 cpu_maps_update_done();
455} 437}
438
439static int alloc_frozen_cpus(void)
440{
441 if (!alloc_cpumask_var(&frozen_cpus, GFP_KERNEL|__GFP_ZERO))
442 return -ENOMEM;
443 return 0;
444}
445core_initcall(alloc_frozen_cpus);
456#endif /* CONFIG_PM_SLEEP_SMP */ 446#endif /* CONFIG_PM_SLEEP_SMP */
457 447
458/** 448/**
@@ -468,7 +458,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu)
468 unsigned long val = CPU_STARTING; 458 unsigned long val = CPU_STARTING;
469 459
470#ifdef CONFIG_PM_SLEEP_SMP 460#ifdef CONFIG_PM_SLEEP_SMP
471 if (cpu_isset(cpu, frozen_cpus)) 461 if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus))
472 val = CPU_STARTING_FROZEN; 462 val = CPU_STARTING_FROZEN;
473#endif /* CONFIG_PM_SLEEP_SMP */ 463#endif /* CONFIG_PM_SLEEP_SMP */
474 raw_notifier_call_chain(&cpu_chain, val, (void *)(long)cpu); 464 raw_notifier_call_chain(&cpu_chain, val, (void *)(long)cpu);
@@ -480,7 +470,7 @@ void __cpuinit notify_cpu_starting(unsigned int cpu)
480 * cpu_bit_bitmap[] is a special, "compressed" data structure that 470 * cpu_bit_bitmap[] is a special, "compressed" data structure that
481 * represents all NR_CPUS bits binary values of 1<<nr. 471 * represents all NR_CPUS bits binary values of 1<<nr.
482 * 472 *
483 * It is used by cpumask_of_cpu() to get a constant address to a CPU 473 * It is used by cpumask_of() to get a constant address to a CPU
484 * mask value that has a single bit set only. 474 * mask value that has a single bit set only.
485 */ 475 */
486 476
@@ -503,3 +493,71 @@ EXPORT_SYMBOL_GPL(cpu_bit_bitmap);
503 493
504const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; 494const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
505EXPORT_SYMBOL(cpu_all_bits); 495EXPORT_SYMBOL(cpu_all_bits);
496
497#ifdef CONFIG_INIT_ALL_POSSIBLE
498static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly
499 = CPU_BITS_ALL;
500#else
501static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly;
502#endif
503const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits);
504EXPORT_SYMBOL(cpu_possible_mask);
505
506static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly;
507const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits);
508EXPORT_SYMBOL(cpu_online_mask);
509
510static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly;
511const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits);
512EXPORT_SYMBOL(cpu_present_mask);
513
514static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly;
515const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
516EXPORT_SYMBOL(cpu_active_mask);
517
518void set_cpu_possible(unsigned int cpu, bool possible)
519{
520 if (possible)
521 cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits));
522 else
523 cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits));
524}
525
526void set_cpu_present(unsigned int cpu, bool present)
527{
528 if (present)
529 cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits));
530 else
531 cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits));
532}
533
534void set_cpu_online(unsigned int cpu, bool online)
535{
536 if (online)
537 cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits));
538 else
539 cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits));
540}
541
542void set_cpu_active(unsigned int cpu, bool active)
543{
544 if (active)
545 cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
546 else
547 cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits));
548}
549
550void init_cpu_present(const struct cpumask *src)
551{
552 cpumask_copy(to_cpumask(cpu_present_bits), src);
553}
554
555void init_cpu_possible(const struct cpumask *src)
556{
557 cpumask_copy(to_cpumask(cpu_possible_bits), src);
558}
559
560void init_cpu_online(const struct cpumask *src)
561{
562 cpumask_copy(to_cpumask(cpu_online_bits), src);
563}
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 61c4a9b62165..cd0cd8dcb345 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -16,8 +16,15 @@
16#include "internals.h" 16#include "internals.h"
17 17
18#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
19cpumask_var_t irq_default_affinity;
19 20
20cpumask_t irq_default_affinity = CPU_MASK_ALL; 21static int init_irq_default_affinity(void)
22{
23 alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
24 cpumask_setall(irq_default_affinity);
25 return 0;
26}
27core_initcall(init_irq_default_affinity);
21 28
22/** 29/**
23 * synchronize_irq - wait for pending IRQ handlers (on other CPUs) 30 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
@@ -127,7 +134,7 @@ int do_irq_select_affinity(unsigned int irq, struct irq_desc *desc)
127 desc->status &= ~IRQ_AFFINITY_SET; 134 desc->status &= ~IRQ_AFFINITY_SET;
128 } 135 }
129 136
130 cpumask_and(&desc->affinity, cpu_online_mask, &irq_default_affinity); 137 cpumask_and(&desc->affinity, cpu_online_mask, irq_default_affinity);
131set_affinity: 138set_affinity:
132 desc->chip->set_affinity(irq, &desc->affinity); 139 desc->chip->set_affinity(irq, &desc->affinity);
133 140
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index d2c0e5ee53c5..aae3f742bcec 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -20,7 +20,7 @@ static struct proc_dir_entry *root_irq_dir;
20static int irq_affinity_proc_show(struct seq_file *m, void *v) 20static int irq_affinity_proc_show(struct seq_file *m, void *v)
21{ 21{
22 struct irq_desc *desc = irq_to_desc((long)m->private); 22 struct irq_desc *desc = irq_to_desc((long)m->private);
23 cpumask_t *mask = &desc->affinity; 23 const struct cpumask *mask = &desc->affinity;
24 24
25#ifdef CONFIG_GENERIC_PENDING_IRQ 25#ifdef CONFIG_GENERIC_PENDING_IRQ
26 if (desc->status & IRQ_MOVE_PENDING) 26 if (desc->status & IRQ_MOVE_PENDING)
@@ -54,7 +54,7 @@ static ssize_t irq_affinity_proc_write(struct file *file,
54 if (err) 54 if (err)
55 goto free_cpumask; 55 goto free_cpumask;
56 56
57 if (!is_affinity_mask_valid(*new_value)) { 57 if (!is_affinity_mask_valid(new_value)) {
58 err = -EINVAL; 58 err = -EINVAL;
59 goto free_cpumask; 59 goto free_cpumask;
60 } 60 }
@@ -93,7 +93,7 @@ static const struct file_operations irq_affinity_proc_fops = {
93 93
94static int default_affinity_show(struct seq_file *m, void *v) 94static int default_affinity_show(struct seq_file *m, void *v)
95{ 95{
96 seq_cpumask(m, &irq_default_affinity); 96 seq_cpumask(m, irq_default_affinity);
97 seq_putc(m, '\n'); 97 seq_putc(m, '\n');
98 return 0; 98 return 0;
99} 99}
@@ -101,27 +101,37 @@ static int default_affinity_show(struct seq_file *m, void *v)
101static ssize_t default_affinity_write(struct file *file, 101static ssize_t default_affinity_write(struct file *file,
102 const char __user *buffer, size_t count, loff_t *ppos) 102 const char __user *buffer, size_t count, loff_t *ppos)
103{ 103{
104 cpumask_t new_value; 104 cpumask_var_t new_value;
105 int err; 105 int err;
106 106
107 err = cpumask_parse_user(buffer, count, &new_value); 107 if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
108 return -ENOMEM;
109
110 err = cpumask_parse_user(buffer, count, new_value);
108 if (err) 111 if (err)
109 return err; 112 goto out;
110 113
111 if (!is_affinity_mask_valid(new_value)) 114 if (!is_affinity_mask_valid(new_value)) {
112 return -EINVAL; 115 err = -EINVAL;
116 goto out;
117 }
113 118
114 /* 119 /*
115 * Do not allow disabling IRQs completely - it's a too easy 120 * Do not allow disabling IRQs completely - it's a too easy
116 * way to make the system unusable accidentally :-) At least 121 * way to make the system unusable accidentally :-) At least
117 * one online CPU still has to be targeted. 122 * one online CPU still has to be targeted.
118 */ 123 */
119 if (!cpus_intersects(new_value, cpu_online_map)) 124 if (!cpumask_intersects(new_value, cpu_online_mask)) {
120 return -EINVAL; 125 err = -EINVAL;
126 goto out;
127 }
121 128
122 irq_default_affinity = new_value; 129 cpumask_copy(irq_default_affinity, new_value);
130 err = count;
123 131
124 return count; 132out:
133 free_cpumask_var(new_value);
134 return err;
125} 135}
126 136
127static int default_affinity_open(struct inode *inode, struct file *file) 137static int default_affinity_open(struct inode *inode, struct file *file)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index ac0fde7b54d0..3fb855ad6aa0 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1116,7 +1116,7 @@ void crash_save_cpu(struct pt_regs *regs, int cpu)
1116 struct elf_prstatus prstatus; 1116 struct elf_prstatus prstatus;
1117 u32 *buf; 1117 u32 *buf;
1118 1118
1119 if ((cpu < 0) || (cpu >= NR_CPUS)) 1119 if ((cpu < 0) || (cpu >= nr_cpu_ids))
1120 return; 1120 return;
1121 1121
1122 /* Using ELF notes here is opportunistic. 1122 /* Using ELF notes here is opportunistic.
diff --git a/kernel/module.c b/kernel/module.c
index dd2a54155b54..f47cce910f25 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -757,8 +757,16 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
757 return -EFAULT; 757 return -EFAULT;
758 name[MODULE_NAME_LEN-1] = '\0'; 758 name[MODULE_NAME_LEN-1] = '\0';
759 759
760 if (mutex_lock_interruptible(&module_mutex) != 0) 760 /* Create stop_machine threads since free_module relies on
761 return -EINTR; 761 * a non-failing stop_machine call. */
762 ret = stop_machine_create();
763 if (ret)
764 return ret;
765
766 if (mutex_lock_interruptible(&module_mutex) != 0) {
767 ret = -EINTR;
768 goto out_stop;
769 }
762 770
763 mod = find_module(name); 771 mod = find_module(name);
764 if (!mod) { 772 if (!mod) {
@@ -817,10 +825,12 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
817 825
818 out: 826 out:
819 mutex_unlock(&module_mutex); 827 mutex_unlock(&module_mutex);
828out_stop:
829 stop_machine_destroy();
820 return ret; 830 return ret;
821} 831}
822 832
823static void print_unload_info(struct seq_file *m, struct module *mod) 833static inline void print_unload_info(struct seq_file *m, struct module *mod)
824{ 834{
825 struct module_use *use; 835 struct module_use *use;
826 int printed_something = 0; 836 int printed_something = 0;
@@ -893,7 +903,7 @@ void module_put(struct module *module)
893EXPORT_SYMBOL(module_put); 903EXPORT_SYMBOL(module_put);
894 904
895#else /* !CONFIG_MODULE_UNLOAD */ 905#else /* !CONFIG_MODULE_UNLOAD */
896static void print_unload_info(struct seq_file *m, struct module *mod) 906static inline void print_unload_info(struct seq_file *m, struct module *mod)
897{ 907{
898 /* We don't know the usage count, or what modules are using. */ 908 /* We don't know the usage count, or what modules are using. */
899 seq_printf(m, " - -"); 909 seq_printf(m, " - -");
@@ -1578,11 +1588,21 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
1578 return ret; 1588 return ret;
1579} 1589}
1580 1590
1591/* Additional bytes needed by arch in front of individual sections */
1592unsigned int __weak arch_mod_section_prepend(struct module *mod,
1593 unsigned int section)
1594{
1595 /* default implementation just returns zero */
1596 return 0;
1597}
1598
1581/* Update size with this section: return offset. */ 1599/* Update size with this section: return offset. */
1582static long get_offset(unsigned int *size, Elf_Shdr *sechdr) 1600static long get_offset(struct module *mod, unsigned int *size,
1601 Elf_Shdr *sechdr, unsigned int section)
1583{ 1602{
1584 long ret; 1603 long ret;
1585 1604
1605 *size += arch_mod_section_prepend(mod, section);
1586 ret = ALIGN(*size, sechdr->sh_addralign ?: 1); 1606 ret = ALIGN(*size, sechdr->sh_addralign ?: 1);
1587 *size = ret + sechdr->sh_size; 1607 *size = ret + sechdr->sh_size;
1588 return ret; 1608 return ret;
@@ -1622,7 +1642,7 @@ static void layout_sections(struct module *mod,
1622 || strncmp(secstrings + s->sh_name, 1642 || strncmp(secstrings + s->sh_name,
1623 ".init", 5) == 0) 1643 ".init", 5) == 0)
1624 continue; 1644 continue;
1625 s->sh_entsize = get_offset(&mod->core_size, s); 1645 s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
1626 DEBUGP("\t%s\n", secstrings + s->sh_name); 1646 DEBUGP("\t%s\n", secstrings + s->sh_name);
1627 } 1647 }
1628 if (m == 0) 1648 if (m == 0)
@@ -1640,7 +1660,7 @@ static void layout_sections(struct module *mod,
1640 || strncmp(secstrings + s->sh_name, 1660 || strncmp(secstrings + s->sh_name,
1641 ".init", 5) != 0) 1661 ".init", 5) != 0)
1642 continue; 1662 continue;
1643 s->sh_entsize = (get_offset(&mod->init_size, s) 1663 s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
1644 | INIT_OFFSET_MASK); 1664 | INIT_OFFSET_MASK);
1645 DEBUGP("\t%s\n", secstrings + s->sh_name); 1665 DEBUGP("\t%s\n", secstrings + s->sh_name);
1646 } 1666 }
@@ -1725,15 +1745,15 @@ static const struct kernel_symbol *lookup_symbol(const char *name,
1725 return NULL; 1745 return NULL;
1726} 1746}
1727 1747
1728static int is_exported(const char *name, const struct module *mod) 1748static int is_exported(const char *name, unsigned long value,
1749 const struct module *mod)
1729{ 1750{
1730 if (!mod && lookup_symbol(name, __start___ksymtab, __stop___ksymtab)) 1751 const struct kernel_symbol *ks;
1731 return 1; 1752 if (!mod)
1753 ks = lookup_symbol(name, __start___ksymtab, __stop___ksymtab);
1732 else 1754 else
1733 if (mod && lookup_symbol(name, mod->syms, mod->syms + mod->num_syms)) 1755 ks = lookup_symbol(name, mod->syms, mod->syms + mod->num_syms);
1734 return 1; 1756 return ks != NULL && ks->value == value;
1735 else
1736 return 0;
1737} 1757}
1738 1758
1739/* As per nm */ 1759/* As per nm */
@@ -1865,6 +1885,13 @@ static noinline struct module *load_module(void __user *umod,
1865 /* vmalloc barfs on "unusual" numbers. Check here */ 1885 /* vmalloc barfs on "unusual" numbers. Check here */
1866 if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) 1886 if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
1867 return ERR_PTR(-ENOMEM); 1887 return ERR_PTR(-ENOMEM);
1888
1889 /* Create stop_machine threads since the error path relies on
1890 * a non-failing stop_machine call. */
1891 err = stop_machine_create();
1892 if (err)
1893 goto free_hdr;
1894
1868 if (copy_from_user(hdr, umod, len) != 0) { 1895 if (copy_from_user(hdr, umod, len) != 0) {
1869 err = -EFAULT; 1896 err = -EFAULT;
1870 goto free_hdr; 1897 goto free_hdr;
@@ -2248,6 +2275,7 @@ static noinline struct module *load_module(void __user *umod,
2248 /* Get rid of temporary copy */ 2275 /* Get rid of temporary copy */
2249 vfree(hdr); 2276 vfree(hdr);
2250 2277
2278 stop_machine_destroy();
2251 /* Done! */ 2279 /* Done! */
2252 return mod; 2280 return mod;
2253 2281
@@ -2270,6 +2298,7 @@ static noinline struct module *load_module(void __user *umod,
2270 kfree(args); 2298 kfree(args);
2271 free_hdr: 2299 free_hdr:
2272 vfree(hdr); 2300 vfree(hdr);
2301 stop_machine_destroy();
2273 return ERR_PTR(err); 2302 return ERR_PTR(err);
2274 2303
2275 truncated: 2304 truncated:
@@ -2504,7 +2533,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
2504 strlcpy(name, mod->strtab + mod->symtab[symnum].st_name, 2533 strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
2505 KSYM_NAME_LEN); 2534 KSYM_NAME_LEN);
2506 strlcpy(module_name, mod->name, MODULE_NAME_LEN); 2535 strlcpy(module_name, mod->name, MODULE_NAME_LEN);
2507 *exported = is_exported(name, mod); 2536 *exported = is_exported(name, *value, mod);
2508 preempt_enable(); 2537 preempt_enable();
2509 return 0; 2538 return 0;
2510 } 2539 }
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
index 72016f051477..97890831e1b5 100644
--- a/kernel/power/poweroff.c
+++ b/kernel/power/poweroff.c
@@ -27,7 +27,7 @@ static DECLARE_WORK(poweroff_work, do_poweroff);
27static void handle_poweroff(int key, struct tty_struct *tty) 27static void handle_poweroff(int key, struct tty_struct *tty)
28{ 28{
29 /* run sysrq poweroff on boot cpu */ 29 /* run sysrq poweroff on boot cpu */
30 schedule_work_on(first_cpu(cpu_online_map), &poweroff_work); 30 schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work);
31} 31}
32 32
33static struct sysrq_key_op sysrq_poweroff_op = { 33static struct sysrq_key_op sysrq_poweroff_op = {
diff --git a/kernel/profile.c b/kernel/profile.c
index 4cb7d68fed82..d18e2d2654f2 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -45,7 +45,7 @@ static unsigned long prof_len, prof_shift;
45int prof_on __read_mostly; 45int prof_on __read_mostly;
46EXPORT_SYMBOL_GPL(prof_on); 46EXPORT_SYMBOL_GPL(prof_on);
47 47
48static cpumask_t prof_cpu_mask = CPU_MASK_ALL; 48static cpumask_var_t prof_cpu_mask;
49#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
50static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); 50static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
51static DEFINE_PER_CPU(int, cpu_profile_flip); 51static DEFINE_PER_CPU(int, cpu_profile_flip);
@@ -113,9 +113,13 @@ int __ref profile_init(void)
113 buffer_bytes = prof_len*sizeof(atomic_t); 113 buffer_bytes = prof_len*sizeof(atomic_t);
114 if (!slab_is_available()) { 114 if (!slab_is_available()) {
115 prof_buffer = alloc_bootmem(buffer_bytes); 115 prof_buffer = alloc_bootmem(buffer_bytes);
116 alloc_bootmem_cpumask_var(&prof_cpu_mask);
116 return 0; 117 return 0;
117 } 118 }
118 119
120 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL))
121 return -ENOMEM;
122
119 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL); 123 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL);
120 if (prof_buffer) 124 if (prof_buffer)
121 return 0; 125 return 0;
@@ -128,6 +132,7 @@ int __ref profile_init(void)
128 if (prof_buffer) 132 if (prof_buffer)
129 return 0; 133 return 0;
130 134
135 free_cpumask_var(prof_cpu_mask);
131 return -ENOMEM; 136 return -ENOMEM;
132} 137}
133 138
@@ -386,13 +391,15 @@ out_free:
386 return NOTIFY_BAD; 391 return NOTIFY_BAD;
387 case CPU_ONLINE: 392 case CPU_ONLINE:
388 case CPU_ONLINE_FROZEN: 393 case CPU_ONLINE_FROZEN:
389 cpu_set(cpu, prof_cpu_mask); 394 if (prof_cpu_mask != NULL)
395 cpumask_set_cpu(cpu, prof_cpu_mask);
390 break; 396 break;
391 case CPU_UP_CANCELED: 397 case CPU_UP_CANCELED:
392 case CPU_UP_CANCELED_FROZEN: 398 case CPU_UP_CANCELED_FROZEN:
393 case CPU_DEAD: 399 case CPU_DEAD:
394 case CPU_DEAD_FROZEN: 400 case CPU_DEAD_FROZEN:
395 cpu_clear(cpu, prof_cpu_mask); 401 if (prof_cpu_mask != NULL)
402 cpumask_clear_cpu(cpu, prof_cpu_mask);
396 if (per_cpu(cpu_profile_hits, cpu)[0]) { 403 if (per_cpu(cpu_profile_hits, cpu)[0]) {
397 page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]); 404 page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
398 per_cpu(cpu_profile_hits, cpu)[0] = NULL; 405 per_cpu(cpu_profile_hits, cpu)[0] = NULL;
@@ -430,7 +437,8 @@ void profile_tick(int type)
430 437
431 if (type == CPU_PROFILING && timer_hook) 438 if (type == CPU_PROFILING && timer_hook)
432 timer_hook(regs); 439 timer_hook(regs);
433 if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask)) 440 if (!user_mode(regs) && prof_cpu_mask != NULL &&
441 cpumask_test_cpu(smp_processor_id(), prof_cpu_mask))
434 profile_hit(type, (void *)profile_pc(regs)); 442 profile_hit(type, (void *)profile_pc(regs));
435} 443}
436 444
@@ -442,7 +450,7 @@ void profile_tick(int type)
442static int prof_cpu_mask_read_proc(char *page, char **start, off_t off, 450static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
443 int count, int *eof, void *data) 451 int count, int *eof, void *data)
444{ 452{
445 int len = cpumask_scnprintf(page, count, (cpumask_t *)data); 453 int len = cpumask_scnprintf(page, count, data);
446 if (count - len < 2) 454 if (count - len < 2)
447 return -EINVAL; 455 return -EINVAL;
448 len += sprintf(page + len, "\n"); 456 len += sprintf(page + len, "\n");
@@ -452,16 +460,20 @@ static int prof_cpu_mask_read_proc(char *page, char **start, off_t off,
452static int prof_cpu_mask_write_proc(struct file *file, 460static int prof_cpu_mask_write_proc(struct file *file,
453 const char __user *buffer, unsigned long count, void *data) 461 const char __user *buffer, unsigned long count, void *data)
454{ 462{
455 cpumask_t *mask = (cpumask_t *)data; 463 struct cpumask *mask = data;
456 unsigned long full_count = count, err; 464 unsigned long full_count = count, err;
457 cpumask_t new_value; 465 cpumask_var_t new_value;
458 466
459 err = cpumask_parse_user(buffer, count, &new_value); 467 if (!alloc_cpumask_var(&new_value, GFP_KERNEL))
460 if (err) 468 return -ENOMEM;
461 return err;
462 469
463 *mask = new_value; 470 err = cpumask_parse_user(buffer, count, new_value);
464 return full_count; 471 if (!err) {
472 cpumask_copy(mask, new_value);
473 err = full_count;
474 }
475 free_cpumask_var(new_value);
476 return err;
465} 477}
466 478
467void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir) 479void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
@@ -472,7 +484,7 @@ void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
472 entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir); 484 entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
473 if (!entry) 485 if (!entry)
474 return; 486 return;
475 entry->data = (void *)&prof_cpu_mask; 487 entry->data = prof_cpu_mask;
476 entry->read_proc = prof_cpu_mask_read_proc; 488 entry->read_proc = prof_cpu_mask_read_proc;
477 entry->write_proc = prof_cpu_mask_write_proc; 489 entry->write_proc = prof_cpu_mask_write_proc;
478} 490}
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
index c03ca3e61919..490934fc7ac3 100644
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@ -63,14 +63,14 @@ static struct rcu_ctrlblk rcu_ctrlblk = {
63 .completed = -300, 63 .completed = -300,
64 .pending = -300, 64 .pending = -300,
65 .lock = __SPIN_LOCK_UNLOCKED(&rcu_ctrlblk.lock), 65 .lock = __SPIN_LOCK_UNLOCKED(&rcu_ctrlblk.lock),
66 .cpumask = CPU_MASK_NONE, 66 .cpumask = CPU_BITS_NONE,
67}; 67};
68static struct rcu_ctrlblk rcu_bh_ctrlblk = { 68static struct rcu_ctrlblk rcu_bh_ctrlblk = {
69 .cur = -300, 69 .cur = -300,
70 .completed = -300, 70 .completed = -300,
71 .pending = -300, 71 .pending = -300,
72 .lock = __SPIN_LOCK_UNLOCKED(&rcu_bh_ctrlblk.lock), 72 .lock = __SPIN_LOCK_UNLOCKED(&rcu_bh_ctrlblk.lock),
73 .cpumask = CPU_MASK_NONE, 73 .cpumask = CPU_BITS_NONE,
74}; 74};
75 75
76DEFINE_PER_CPU(struct rcu_data, rcu_data) = { 0L }; 76DEFINE_PER_CPU(struct rcu_data, rcu_data) = { 0L };
@@ -85,7 +85,6 @@ static void force_quiescent_state(struct rcu_data *rdp,
85 struct rcu_ctrlblk *rcp) 85 struct rcu_ctrlblk *rcp)
86{ 86{
87 int cpu; 87 int cpu;
88 cpumask_t cpumask;
89 unsigned long flags; 88 unsigned long flags;
90 89
91 set_need_resched(); 90 set_need_resched();
@@ -96,10 +95,10 @@ static void force_quiescent_state(struct rcu_data *rdp,
96 * Don't send IPI to itself. With irqs disabled, 95 * Don't send IPI to itself. With irqs disabled,
97 * rdp->cpu is the current cpu. 96 * rdp->cpu is the current cpu.
98 * 97 *
99 * cpu_online_map is updated by the _cpu_down() 98 * cpu_online_mask is updated by the _cpu_down()
100 * using __stop_machine(). Since we're in irqs disabled 99 * using __stop_machine(). Since we're in irqs disabled
101 * section, __stop_machine() is not exectuting, hence 100 * section, __stop_machine() is not exectuting, hence
102 * the cpu_online_map is stable. 101 * the cpu_online_mask is stable.
103 * 102 *
104 * However, a cpu might have been offlined _just_ before 103 * However, a cpu might have been offlined _just_ before
105 * we disabled irqs while entering here. 104 * we disabled irqs while entering here.
@@ -107,13 +106,14 @@ static void force_quiescent_state(struct rcu_data *rdp,
107 * notification, leading to the offlined cpu's bit 106 * notification, leading to the offlined cpu's bit
108 * being set in the rcp->cpumask. 107 * being set in the rcp->cpumask.
109 * 108 *
110 * Hence cpumask = (rcp->cpumask & cpu_online_map) to prevent 109 * Hence cpumask = (rcp->cpumask & cpu_online_mask) to prevent
111 * sending smp_reschedule() to an offlined CPU. 110 * sending smp_reschedule() to an offlined CPU.
112 */ 111 */
113 cpus_and(cpumask, rcp->cpumask, cpu_online_map); 112 for_each_cpu_and(cpu,
114 cpu_clear(rdp->cpu, cpumask); 113 to_cpumask(rcp->cpumask), cpu_online_mask) {
115 for_each_cpu_mask_nr(cpu, cpumask) 114 if (cpu != rdp->cpu)
116 smp_send_reschedule(cpu); 115 smp_send_reschedule(cpu);
116 }
117 } 117 }
118 spin_unlock_irqrestore(&rcp->lock, flags); 118 spin_unlock_irqrestore(&rcp->lock, flags);
119} 119}
@@ -193,7 +193,7 @@ static void print_other_cpu_stall(struct rcu_ctrlblk *rcp)
193 193
194 printk(KERN_ERR "INFO: RCU detected CPU stalls:"); 194 printk(KERN_ERR "INFO: RCU detected CPU stalls:");
195 for_each_possible_cpu(cpu) { 195 for_each_possible_cpu(cpu) {
196 if (cpu_isset(cpu, rcp->cpumask)) 196 if (cpumask_test_cpu(cpu, to_cpumask(rcp->cpumask)))
197 printk(" %d", cpu); 197 printk(" %d", cpu);
198 } 198 }
199 printk(" (detected by %d, t=%ld jiffies)\n", 199 printk(" (detected by %d, t=%ld jiffies)\n",
@@ -221,7 +221,8 @@ static void check_cpu_stall(struct rcu_ctrlblk *rcp)
221 long delta; 221 long delta;
222 222
223 delta = jiffies - rcp->jiffies_stall; 223 delta = jiffies - rcp->jiffies_stall;
224 if (cpu_isset(smp_processor_id(), rcp->cpumask) && delta >= 0) { 224 if (cpumask_test_cpu(smp_processor_id(), to_cpumask(rcp->cpumask)) &&
225 delta >= 0) {
225 226
226 /* We haven't checked in, so go dump stack. */ 227 /* We haven't checked in, so go dump stack. */
227 print_cpu_stall(rcp); 228 print_cpu_stall(rcp);
@@ -393,7 +394,8 @@ static void rcu_start_batch(struct rcu_ctrlblk *rcp)
393 * unnecessarily. 394 * unnecessarily.
394 */ 395 */
395 smp_mb(); 396 smp_mb();
396 cpumask_andnot(&rcp->cpumask, cpu_online_mask, nohz_cpu_mask); 397 cpumask_andnot(to_cpumask(rcp->cpumask),
398 cpu_online_mask, nohz_cpu_mask);
397 399
398 rcp->signaled = 0; 400 rcp->signaled = 0;
399 } 401 }
@@ -406,8 +408,8 @@ static void rcu_start_batch(struct rcu_ctrlblk *rcp)
406 */ 408 */
407static void cpu_quiet(int cpu, struct rcu_ctrlblk *rcp) 409static void cpu_quiet(int cpu, struct rcu_ctrlblk *rcp)
408{ 410{
409 cpu_clear(cpu, rcp->cpumask); 411 cpumask_clear_cpu(cpu, to_cpumask(rcp->cpumask));
410 if (cpus_empty(rcp->cpumask)) { 412 if (cpumask_empty(to_cpumask(rcp->cpumask))) {
411 /* batch completed ! */ 413 /* batch completed ! */
412 rcp->completed = rcp->cur; 414 rcp->completed = rcp->cur;
413 rcu_start_batch(rcp); 415 rcu_start_batch(rcp);
diff --git a/kernel/rcupreempt.c b/kernel/rcupreempt.c
index 04982659875a..f9dc8f3720f6 100644
--- a/kernel/rcupreempt.c
+++ b/kernel/rcupreempt.c
@@ -164,7 +164,8 @@ static char *rcu_try_flip_state_names[] =
164 { "idle", "waitack", "waitzero", "waitmb" }; 164 { "idle", "waitack", "waitzero", "waitmb" };
165#endif /* #ifdef CONFIG_RCU_TRACE */ 165#endif /* #ifdef CONFIG_RCU_TRACE */
166 166
167static cpumask_t rcu_cpu_online_map __read_mostly = CPU_MASK_NONE; 167static DECLARE_BITMAP(rcu_cpu_online_map, NR_CPUS) __read_mostly
168 = CPU_BITS_NONE;
168 169
169/* 170/*
170 * Enum and per-CPU flag to determine when each CPU has seen 171 * Enum and per-CPU flag to determine when each CPU has seen
@@ -758,7 +759,7 @@ rcu_try_flip_idle(void)
758 759
759 /* Now ask each CPU for acknowledgement of the flip. */ 760 /* Now ask each CPU for acknowledgement of the flip. */
760 761
761 for_each_cpu_mask_nr(cpu, rcu_cpu_online_map) { 762 for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map)) {
762 per_cpu(rcu_flip_flag, cpu) = rcu_flipped; 763 per_cpu(rcu_flip_flag, cpu) = rcu_flipped;
763 dyntick_save_progress_counter(cpu); 764 dyntick_save_progress_counter(cpu);
764 } 765 }
@@ -776,7 +777,7 @@ rcu_try_flip_waitack(void)
776 int cpu; 777 int cpu;
777 778
778 RCU_TRACE_ME(rcupreempt_trace_try_flip_a1); 779 RCU_TRACE_ME(rcupreempt_trace_try_flip_a1);
779 for_each_cpu_mask_nr(cpu, rcu_cpu_online_map) 780 for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map))
780 if (rcu_try_flip_waitack_needed(cpu) && 781 if (rcu_try_flip_waitack_needed(cpu) &&
781 per_cpu(rcu_flip_flag, cpu) != rcu_flip_seen) { 782 per_cpu(rcu_flip_flag, cpu) != rcu_flip_seen) {
782 RCU_TRACE_ME(rcupreempt_trace_try_flip_ae1); 783 RCU_TRACE_ME(rcupreempt_trace_try_flip_ae1);
@@ -808,7 +809,7 @@ rcu_try_flip_waitzero(void)
808 /* Check to see if the sum of the "last" counters is zero. */ 809 /* Check to see if the sum of the "last" counters is zero. */
809 810
810 RCU_TRACE_ME(rcupreempt_trace_try_flip_z1); 811 RCU_TRACE_ME(rcupreempt_trace_try_flip_z1);
811 for_each_cpu_mask_nr(cpu, rcu_cpu_online_map) 812 for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map))
812 sum += RCU_DATA_CPU(cpu)->rcu_flipctr[lastidx]; 813 sum += RCU_DATA_CPU(cpu)->rcu_flipctr[lastidx];
813 if (sum != 0) { 814 if (sum != 0) {
814 RCU_TRACE_ME(rcupreempt_trace_try_flip_ze1); 815 RCU_TRACE_ME(rcupreempt_trace_try_flip_ze1);
@@ -823,7 +824,7 @@ rcu_try_flip_waitzero(void)
823 smp_mb(); /* ^^^^^^^^^^^^ */ 824 smp_mb(); /* ^^^^^^^^^^^^ */
824 825
825 /* Call for a memory barrier from each CPU. */ 826 /* Call for a memory barrier from each CPU. */
826 for_each_cpu_mask_nr(cpu, rcu_cpu_online_map) { 827 for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map)) {
827 per_cpu(rcu_mb_flag, cpu) = rcu_mb_needed; 828 per_cpu(rcu_mb_flag, cpu) = rcu_mb_needed;
828 dyntick_save_progress_counter(cpu); 829 dyntick_save_progress_counter(cpu);
829 } 830 }
@@ -843,7 +844,7 @@ rcu_try_flip_waitmb(void)
843 int cpu; 844 int cpu;
844 845
845 RCU_TRACE_ME(rcupreempt_trace_try_flip_m1); 846 RCU_TRACE_ME(rcupreempt_trace_try_flip_m1);
846 for_each_cpu_mask_nr(cpu, rcu_cpu_online_map) 847 for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map))
847 if (rcu_try_flip_waitmb_needed(cpu) && 848 if (rcu_try_flip_waitmb_needed(cpu) &&
848 per_cpu(rcu_mb_flag, cpu) != rcu_mb_done) { 849 per_cpu(rcu_mb_flag, cpu) != rcu_mb_done) {
849 RCU_TRACE_ME(rcupreempt_trace_try_flip_me1); 850 RCU_TRACE_ME(rcupreempt_trace_try_flip_me1);
@@ -1032,7 +1033,7 @@ void rcu_offline_cpu(int cpu)
1032 RCU_DATA_CPU(cpu)->rcu_flipctr[0] = 0; 1033 RCU_DATA_CPU(cpu)->rcu_flipctr[0] = 0;
1033 RCU_DATA_CPU(cpu)->rcu_flipctr[1] = 0; 1034 RCU_DATA_CPU(cpu)->rcu_flipctr[1] = 0;
1034 1035
1035 cpu_clear(cpu, rcu_cpu_online_map); 1036 cpumask_clear_cpu(cpu, to_cpumask(rcu_cpu_online_map));
1036 1037
1037 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags); 1038 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags);
1038 1039
@@ -1072,7 +1073,7 @@ void __cpuinit rcu_online_cpu(int cpu)
1072 struct rcu_data *rdp; 1073 struct rcu_data *rdp;
1073 1074
1074 spin_lock_irqsave(&rcu_ctrlblk.fliplock, flags); 1075 spin_lock_irqsave(&rcu_ctrlblk.fliplock, flags);
1075 cpu_set(cpu, rcu_cpu_online_map); 1076 cpumask_set_cpu(cpu, to_cpumask(rcu_cpu_online_map));
1076 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags); 1077 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags);
1077 1078
1078 /* 1079 /*
@@ -1430,7 +1431,7 @@ void __init __rcu_init(void)
1430 * We don't need protection against CPU-Hotplug here 1431 * We don't need protection against CPU-Hotplug here
1431 * since 1432 * since
1432 * a) If a CPU comes online while we are iterating over the 1433 * a) If a CPU comes online while we are iterating over the
1433 * cpu_online_map below, we would only end up making a 1434 * cpu_online_mask below, we would only end up making a
1434 * duplicate call to rcu_online_cpu() which sets the corresponding 1435 * duplicate call to rcu_online_cpu() which sets the corresponding
1435 * CPU's mask in the rcu_cpu_online_map. 1436 * CPU's mask in the rcu_cpu_online_map.
1436 * 1437 *
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index b31065522104..3245b40952c6 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -868,49 +868,52 @@ static int rcu_idle_cpu; /* Force all torture tasks off this CPU */
868 */ 868 */
869static void rcu_torture_shuffle_tasks(void) 869static void rcu_torture_shuffle_tasks(void)
870{ 870{
871 cpumask_t tmp_mask; 871 cpumask_var_t tmp_mask;
872 int i; 872 int i;
873 873
874 cpus_setall(tmp_mask); 874 if (!alloc_cpumask_var(&tmp_mask, GFP_KERNEL))
875 BUG();
876
877 cpumask_setall(tmp_mask);
875 get_online_cpus(); 878 get_online_cpus();
876 879
877 /* No point in shuffling if there is only one online CPU (ex: UP) */ 880 /* No point in shuffling if there is only one online CPU (ex: UP) */
878 if (num_online_cpus() == 1) { 881 if (num_online_cpus() == 1)
879 put_online_cpus(); 882 goto out;
880 return;
881 }
882 883
883 if (rcu_idle_cpu != -1) 884 if (rcu_idle_cpu != -1)
884 cpu_clear(rcu_idle_cpu, tmp_mask); 885 cpumask_clear_cpu(rcu_idle_cpu, tmp_mask);
885 886
886 set_cpus_allowed_ptr(current, &tmp_mask); 887 set_cpus_allowed_ptr(current, tmp_mask);
887 888
888 if (reader_tasks) { 889 if (reader_tasks) {
889 for (i = 0; i < nrealreaders; i++) 890 for (i = 0; i < nrealreaders; i++)
890 if (reader_tasks[i]) 891 if (reader_tasks[i])
891 set_cpus_allowed_ptr(reader_tasks[i], 892 set_cpus_allowed_ptr(reader_tasks[i],
892 &tmp_mask); 893 tmp_mask);
893 } 894 }
894 895
895 if (fakewriter_tasks) { 896 if (fakewriter_tasks) {
896 for (i = 0; i < nfakewriters; i++) 897 for (i = 0; i < nfakewriters; i++)
897 if (fakewriter_tasks[i]) 898 if (fakewriter_tasks[i])
898 set_cpus_allowed_ptr(fakewriter_tasks[i], 899 set_cpus_allowed_ptr(fakewriter_tasks[i],
899 &tmp_mask); 900 tmp_mask);
900 } 901 }
901 902
902 if (writer_task) 903 if (writer_task)
903 set_cpus_allowed_ptr(writer_task, &tmp_mask); 904 set_cpus_allowed_ptr(writer_task, tmp_mask);
904 905
905 if (stats_task) 906 if (stats_task)
906 set_cpus_allowed_ptr(stats_task, &tmp_mask); 907 set_cpus_allowed_ptr(stats_task, tmp_mask);
907 908
908 if (rcu_idle_cpu == -1) 909 if (rcu_idle_cpu == -1)
909 rcu_idle_cpu = num_online_cpus() - 1; 910 rcu_idle_cpu = num_online_cpus() - 1;
910 else 911 else
911 rcu_idle_cpu--; 912 rcu_idle_cpu--;
912 913
914out:
913 put_online_cpus(); 915 put_online_cpus();
916 free_cpumask_var(tmp_mask);
914} 917}
915 918
916/* Shuffle tasks across CPUs, with the intent of allowing each CPU in the 919/* Shuffle tasks across CPUs, with the intent of allowing each CPU in the
diff --git a/kernel/sched.c b/kernel/sched.c
index 27ba1d642f0f..545c6fccd1dc 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3715,7 +3715,7 @@ redo:
3715 * don't kick the migration_thread, if the curr 3715 * don't kick the migration_thread, if the curr
3716 * task on busiest cpu can't be moved to this_cpu 3716 * task on busiest cpu can't be moved to this_cpu
3717 */ 3717 */
3718 if (!cpu_isset(this_cpu, busiest->curr->cpus_allowed)) { 3718 if (!cpumask_test_cpu(this_cpu, &busiest->curr->cpus_allowed)) {
3719 double_unlock_balance(this_rq, busiest); 3719 double_unlock_balance(this_rq, busiest);
3720 all_pinned = 1; 3720 all_pinned = 1;
3721 return ld_moved; 3721 return ld_moved;
@@ -4150,13 +4150,17 @@ unsigned long long task_delta_exec(struct task_struct *p)
4150 * Account user cpu time to a process. 4150 * Account user cpu time to a process.
4151 * @p: the process that the cpu time gets accounted to 4151 * @p: the process that the cpu time gets accounted to
4152 * @cputime: the cpu time spent in user space since the last update 4152 * @cputime: the cpu time spent in user space since the last update
4153 * @cputime_scaled: cputime scaled by cpu frequency
4153 */ 4154 */
4154void account_user_time(struct task_struct *p, cputime_t cputime) 4155void account_user_time(struct task_struct *p, cputime_t cputime,
4156 cputime_t cputime_scaled)
4155{ 4157{
4156 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 4158 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
4157 cputime64_t tmp; 4159 cputime64_t tmp;
4158 4160
4161 /* Add user time to process. */
4159 p->utime = cputime_add(p->utime, cputime); 4162 p->utime = cputime_add(p->utime, cputime);
4163 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
4160 account_group_user_time(p, cputime); 4164 account_group_user_time(p, cputime);
4161 4165
4162 /* Add user time to cpustat. */ 4166 /* Add user time to cpustat. */
@@ -4173,51 +4177,48 @@ void account_user_time(struct task_struct *p, cputime_t cputime)
4173 * Account guest cpu time to a process. 4177 * Account guest cpu time to a process.
4174 * @p: the process that the cpu time gets accounted to 4178 * @p: the process that the cpu time gets accounted to
4175 * @cputime: the cpu time spent in virtual machine since the last update 4179 * @cputime: the cpu time spent in virtual machine since the last update
4180 * @cputime_scaled: cputime scaled by cpu frequency
4176 */ 4181 */
4177static void account_guest_time(struct task_struct *p, cputime_t cputime) 4182static void account_guest_time(struct task_struct *p, cputime_t cputime,
4183 cputime_t cputime_scaled)
4178{ 4184{
4179 cputime64_t tmp; 4185 cputime64_t tmp;
4180 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 4186 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
4181 4187
4182 tmp = cputime_to_cputime64(cputime); 4188 tmp = cputime_to_cputime64(cputime);
4183 4189
4190 /* Add guest time to process. */
4184 p->utime = cputime_add(p->utime, cputime); 4191 p->utime = cputime_add(p->utime, cputime);
4192 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
4185 account_group_user_time(p, cputime); 4193 account_group_user_time(p, cputime);
4186 p->gtime = cputime_add(p->gtime, cputime); 4194 p->gtime = cputime_add(p->gtime, cputime);
4187 4195
4196 /* Add guest time to cpustat. */
4188 cpustat->user = cputime64_add(cpustat->user, tmp); 4197 cpustat->user = cputime64_add(cpustat->user, tmp);
4189 cpustat->guest = cputime64_add(cpustat->guest, tmp); 4198 cpustat->guest = cputime64_add(cpustat->guest, tmp);
4190} 4199}
4191 4200
4192/* 4201/*
4193 * Account scaled user cpu time to a process.
4194 * @p: the process that the cpu time gets accounted to
4195 * @cputime: the cpu time spent in user space since the last update
4196 */
4197void account_user_time_scaled(struct task_struct *p, cputime_t cputime)
4198{
4199 p->utimescaled = cputime_add(p->utimescaled, cputime);
4200}
4201
4202/*
4203 * Account system cpu time to a process. 4202 * Account system cpu time to a process.
4204 * @p: the process that the cpu time gets accounted to 4203 * @p: the process that the cpu time gets accounted to
4205 * @hardirq_offset: the offset to subtract from hardirq_count() 4204 * @hardirq_offset: the offset to subtract from hardirq_count()
4206 * @cputime: the cpu time spent in kernel space since the last update 4205 * @cputime: the cpu time spent in kernel space since the last update
4206 * @cputime_scaled: cputime scaled by cpu frequency
4207 */ 4207 */
4208void account_system_time(struct task_struct *p, int hardirq_offset, 4208void account_system_time(struct task_struct *p, int hardirq_offset,
4209 cputime_t cputime) 4209 cputime_t cputime, cputime_t cputime_scaled)
4210{ 4210{
4211 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 4211 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
4212 struct rq *rq = this_rq();
4213 cputime64_t tmp; 4212 cputime64_t tmp;
4214 4213
4215 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) { 4214 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
4216 account_guest_time(p, cputime); 4215 account_guest_time(p, cputime, cputime_scaled);
4217 return; 4216 return;
4218 } 4217 }
4219 4218
4219 /* Add system time to process. */
4220 p->stime = cputime_add(p->stime, cputime); 4220 p->stime = cputime_add(p->stime, cputime);
4221 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
4221 account_group_system_time(p, cputime); 4222 account_group_system_time(p, cputime);
4222 4223
4223 /* Add system time to cpustat. */ 4224 /* Add system time to cpustat. */
@@ -4226,49 +4227,85 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
4226 cpustat->irq = cputime64_add(cpustat->irq, tmp); 4227 cpustat->irq = cputime64_add(cpustat->irq, tmp);
4227 else if (softirq_count()) 4228 else if (softirq_count())
4228 cpustat->softirq = cputime64_add(cpustat->softirq, tmp); 4229 cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
4229 else if (p != rq->idle)
4230 cpustat->system = cputime64_add(cpustat->system, tmp);
4231 else if (atomic_read(&rq->nr_iowait) > 0)
4232 cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
4233 else 4230 else
4234 cpustat->idle = cputime64_add(cpustat->idle, tmp); 4231 cpustat->system = cputime64_add(cpustat->system, tmp);
4232
4235 /* Account for system time used */ 4233 /* Account for system time used */
4236 acct_update_integrals(p); 4234 acct_update_integrals(p);
4237} 4235}
4238 4236
4239/* 4237/*
4240 * Account scaled system cpu time to a process. 4238 * Account for involuntary wait time.
4241 * @p: the process that the cpu time gets accounted to 4239 * @steal: the cpu time spent in involuntary wait
4242 * @hardirq_offset: the offset to subtract from hardirq_count()
4243 * @cputime: the cpu time spent in kernel space since the last update
4244 */ 4240 */
4245void account_system_time_scaled(struct task_struct *p, cputime_t cputime) 4241void account_steal_time(cputime_t cputime)
4246{ 4242{
4247 p->stimescaled = cputime_add(p->stimescaled, cputime); 4243 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
4244 cputime64_t cputime64 = cputime_to_cputime64(cputime);
4245
4246 cpustat->steal = cputime64_add(cpustat->steal, cputime64);
4248} 4247}
4249 4248
4250/* 4249/*
4251 * Account for involuntary wait time. 4250 * Account for idle time.
4252 * @p: the process from which the cpu time has been stolen 4251 * @cputime: the cpu time spent in idle wait
4253 * @steal: the cpu time spent in involuntary wait
4254 */ 4252 */
4255void account_steal_time(struct task_struct *p, cputime_t steal) 4253void account_idle_time(cputime_t cputime)
4256{ 4254{
4257 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 4255 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
4258 cputime64_t tmp = cputime_to_cputime64(steal); 4256 cputime64_t cputime64 = cputime_to_cputime64(cputime);
4259 struct rq *rq = this_rq(); 4257 struct rq *rq = this_rq();
4260 4258
4261 if (p == rq->idle) { 4259 if (atomic_read(&rq->nr_iowait) > 0)
4262 p->stime = cputime_add(p->stime, steal); 4260 cpustat->iowait = cputime64_add(cpustat->iowait, cputime64);
4263 if (atomic_read(&rq->nr_iowait) > 0) 4261 else
4264 cpustat->iowait = cputime64_add(cpustat->iowait, tmp); 4262 cpustat->idle = cputime64_add(cpustat->idle, cputime64);
4265 else 4263}
4266 cpustat->idle = cputime64_add(cpustat->idle, tmp); 4264
4267 } else 4265#ifndef CONFIG_VIRT_CPU_ACCOUNTING
4268 cpustat->steal = cputime64_add(cpustat->steal, tmp); 4266
4267/*
4268 * Account a single tick of cpu time.
4269 * @p: the process that the cpu time gets accounted to
4270 * @user_tick: indicates if the tick is a user or a system tick
4271 */
4272void account_process_tick(struct task_struct *p, int user_tick)
4273{
4274 cputime_t one_jiffy = jiffies_to_cputime(1);
4275 cputime_t one_jiffy_scaled = cputime_to_scaled(one_jiffy);
4276 struct rq *rq = this_rq();
4277
4278 if (user_tick)
4279 account_user_time(p, one_jiffy, one_jiffy_scaled);
4280 else if (p != rq->idle)
4281 account_system_time(p, HARDIRQ_OFFSET, one_jiffy,
4282 one_jiffy_scaled);
4283 else
4284 account_idle_time(one_jiffy);
4285}
4286
4287/*
4288 * Account multiple ticks of steal time.
4289 * @p: the process from which the cpu time has been stolen
4290 * @ticks: number of stolen ticks
4291 */
4292void account_steal_ticks(unsigned long ticks)
4293{
4294 account_steal_time(jiffies_to_cputime(ticks));
4269} 4295}
4270 4296
4271/* 4297/*
4298 * Account multiple ticks of idle time.
4299 * @ticks: number of stolen ticks
4300 */
4301void account_idle_ticks(unsigned long ticks)
4302{
4303 account_idle_time(jiffies_to_cputime(ticks));
4304}
4305
4306#endif
4307
4308/*
4272 * Use precise platform statistics if available: 4309 * Use precise platform statistics if available:
4273 */ 4310 */
4274#ifdef CONFIG_VIRT_CPU_ACCOUNTING 4311#ifdef CONFIG_VIRT_CPU_ACCOUNTING
@@ -6220,9 +6257,7 @@ static int __migrate_task_irq(struct task_struct *p, int src_cpu, int dest_cpu)
6220static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p) 6257static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p)
6221{ 6258{
6222 int dest_cpu; 6259 int dest_cpu;
6223 /* FIXME: Use cpumask_of_node here. */ 6260 const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(dead_cpu));
6224 cpumask_t _nodemask = node_to_cpumask(cpu_to_node(dead_cpu));
6225 const struct cpumask *nodemask = &_nodemask;
6226 6261
6227again: 6262again:
6228 /* Look for allowed, online CPU in same node. */ 6263 /* Look for allowed, online CPU in same node. */
@@ -7133,21 +7168,18 @@ static int find_next_best_node(int node, nodemask_t *used_nodes)
7133static void sched_domain_node_span(int node, struct cpumask *span) 7168static void sched_domain_node_span(int node, struct cpumask *span)
7134{ 7169{
7135 nodemask_t used_nodes; 7170 nodemask_t used_nodes;
7136 /* FIXME: use cpumask_of_node() */
7137 node_to_cpumask_ptr(nodemask, node);
7138 int i; 7171 int i;
7139 7172
7140 cpus_clear(*span); 7173 cpumask_clear(span);
7141 nodes_clear(used_nodes); 7174 nodes_clear(used_nodes);
7142 7175
7143 cpus_or(*span, *span, *nodemask); 7176 cpumask_or(span, span, cpumask_of_node(node));
7144 node_set(node, used_nodes); 7177 node_set(node, used_nodes);
7145 7178
7146 for (i = 1; i < SD_NODES_PER_DOMAIN; i++) { 7179 for (i = 1; i < SD_NODES_PER_DOMAIN; i++) {
7147 int next_node = find_next_best_node(node, &used_nodes); 7180 int next_node = find_next_best_node(node, &used_nodes);
7148 7181
7149 node_to_cpumask_ptr_next(nodemask, next_node); 7182 cpumask_or(span, span, cpumask_of_node(next_node));
7150 cpus_or(*span, *span, *nodemask);
7151 } 7183 }
7152} 7184}
7153#endif /* CONFIG_NUMA */ 7185#endif /* CONFIG_NUMA */
@@ -7227,9 +7259,7 @@ cpu_to_phys_group(int cpu, const struct cpumask *cpu_map,
7227{ 7259{
7228 int group; 7260 int group;
7229#ifdef CONFIG_SCHED_MC 7261#ifdef CONFIG_SCHED_MC
7230 /* FIXME: Use cpu_coregroup_mask. */ 7262 cpumask_and(mask, cpu_coregroup_mask(cpu), cpu_map);
7231 *mask = cpu_coregroup_map(cpu);
7232 cpus_and(*mask, *mask, *cpu_map);
7233 group = cpumask_first(mask); 7263 group = cpumask_first(mask);
7234#elif defined(CONFIG_SCHED_SMT) 7264#elif defined(CONFIG_SCHED_SMT)
7235 cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map); 7265 cpumask_and(mask, &per_cpu(cpu_sibling_map, cpu), cpu_map);
@@ -7259,10 +7289,8 @@ static int cpu_to_allnodes_group(int cpu, const struct cpumask *cpu_map,
7259 struct cpumask *nodemask) 7289 struct cpumask *nodemask)
7260{ 7290{
7261 int group; 7291 int group;
7262 /* FIXME: use cpumask_of_node */
7263 node_to_cpumask_ptr(pnodemask, cpu_to_node(cpu));
7264 7292
7265 cpumask_and(nodemask, pnodemask, cpu_map); 7293 cpumask_and(nodemask, cpumask_of_node(cpu_to_node(cpu)), cpu_map);
7266 group = cpumask_first(nodemask); 7294 group = cpumask_first(nodemask);
7267 7295
7268 if (sg) 7296 if (sg)
@@ -7313,10 +7341,8 @@ static void free_sched_groups(const struct cpumask *cpu_map,
7313 7341
7314 for (i = 0; i < nr_node_ids; i++) { 7342 for (i = 0; i < nr_node_ids; i++) {
7315 struct sched_group *oldsg, *sg = sched_group_nodes[i]; 7343 struct sched_group *oldsg, *sg = sched_group_nodes[i];
7316 /* FIXME: Use cpumask_of_node */
7317 node_to_cpumask_ptr(pnodemask, i);
7318 7344
7319 cpus_and(*nodemask, *pnodemask, *cpu_map); 7345 cpumask_and(nodemask, cpumask_of_node(i), cpu_map);
7320 if (cpumask_empty(nodemask)) 7346 if (cpumask_empty(nodemask))
7321 continue; 7347 continue;
7322 7348
@@ -7525,9 +7551,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7525 for_each_cpu(i, cpu_map) { 7551 for_each_cpu(i, cpu_map) {
7526 struct sched_domain *sd = NULL, *p; 7552 struct sched_domain *sd = NULL, *p;
7527 7553
7528 /* FIXME: use cpumask_of_node */ 7554 cpumask_and(nodemask, cpumask_of_node(cpu_to_node(i)), cpu_map);
7529 *nodemask = node_to_cpumask(cpu_to_node(i));
7530 cpus_and(*nodemask, *nodemask, *cpu_map);
7531 7555
7532#ifdef CONFIG_NUMA 7556#ifdef CONFIG_NUMA
7533 if (cpumask_weight(cpu_map) > 7557 if (cpumask_weight(cpu_map) >
@@ -7568,9 +7592,8 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7568 sd = &per_cpu(core_domains, i).sd; 7592 sd = &per_cpu(core_domains, i).sd;
7569 SD_INIT(sd, MC); 7593 SD_INIT(sd, MC);
7570 set_domain_attribute(sd, attr); 7594 set_domain_attribute(sd, attr);
7571 *sched_domain_span(sd) = cpu_coregroup_map(i); 7595 cpumask_and(sched_domain_span(sd), cpu_map,
7572 cpumask_and(sched_domain_span(sd), 7596 cpu_coregroup_mask(i));
7573 sched_domain_span(sd), cpu_map);
7574 sd->parent = p; 7597 sd->parent = p;
7575 p->child = sd; 7598 p->child = sd;
7576 cpu_to_core_group(i, cpu_map, &sd->groups, tmpmask); 7599 cpu_to_core_group(i, cpu_map, &sd->groups, tmpmask);
@@ -7606,9 +7629,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7606#ifdef CONFIG_SCHED_MC 7629#ifdef CONFIG_SCHED_MC
7607 /* Set up multi-core groups */ 7630 /* Set up multi-core groups */
7608 for_each_cpu(i, cpu_map) { 7631 for_each_cpu(i, cpu_map) {
7609 /* FIXME: Use cpu_coregroup_mask */ 7632 cpumask_and(this_core_map, cpu_coregroup_mask(i), cpu_map);
7610 *this_core_map = cpu_coregroup_map(i);
7611 cpus_and(*this_core_map, *this_core_map, *cpu_map);
7612 if (i != cpumask_first(this_core_map)) 7633 if (i != cpumask_first(this_core_map))
7613 continue; 7634 continue;
7614 7635
@@ -7620,9 +7641,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7620 7641
7621 /* Set up physical groups */ 7642 /* Set up physical groups */
7622 for (i = 0; i < nr_node_ids; i++) { 7643 for (i = 0; i < nr_node_ids; i++) {
7623 /* FIXME: Use cpumask_of_node */ 7644 cpumask_and(nodemask, cpumask_of_node(i), cpu_map);
7624 *nodemask = node_to_cpumask(i);
7625 cpus_and(*nodemask, *nodemask, *cpu_map);
7626 if (cpumask_empty(nodemask)) 7645 if (cpumask_empty(nodemask))
7627 continue; 7646 continue;
7628 7647
@@ -7644,11 +7663,8 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7644 struct sched_group *sg, *prev; 7663 struct sched_group *sg, *prev;
7645 int j; 7664 int j;
7646 7665
7647 /* FIXME: Use cpumask_of_node */
7648 *nodemask = node_to_cpumask(i);
7649 cpumask_clear(covered); 7666 cpumask_clear(covered);
7650 7667 cpumask_and(nodemask, cpumask_of_node(i), cpu_map);
7651 cpus_and(*nodemask, *nodemask, *cpu_map);
7652 if (cpumask_empty(nodemask)) { 7668 if (cpumask_empty(nodemask)) {
7653 sched_group_nodes[i] = NULL; 7669 sched_group_nodes[i] = NULL;
7654 continue; 7670 continue;
@@ -7679,8 +7695,6 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7679 7695
7680 for (j = 0; j < nr_node_ids; j++) { 7696 for (j = 0; j < nr_node_ids; j++) {
7681 int n = (i + j) % nr_node_ids; 7697 int n = (i + j) % nr_node_ids;
7682 /* FIXME: Use cpumask_of_node */
7683 node_to_cpumask_ptr(pnodemask, n);
7684 7698
7685 cpumask_complement(notcovered, covered); 7699 cpumask_complement(notcovered, covered);
7686 cpumask_and(tmpmask, notcovered, cpu_map); 7700 cpumask_and(tmpmask, notcovered, cpu_map);
@@ -7688,7 +7702,7 @@ static int __build_sched_domains(const struct cpumask *cpu_map,
7688 if (cpumask_empty(tmpmask)) 7702 if (cpumask_empty(tmpmask))
7689 break; 7703 break;
7690 7704
7691 cpumask_and(tmpmask, tmpmask, pnodemask); 7705 cpumask_and(tmpmask, tmpmask, cpumask_of_node(n));
7692 if (cpumask_empty(tmpmask)) 7706 if (cpumask_empty(tmpmask))
7693 continue; 7707 continue;
7694 7708
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 833b6d44483c..954e1a81b796 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1383,7 +1383,8 @@ static inline void init_sched_rt_class(void)
1383 unsigned int i; 1383 unsigned int i;
1384 1384
1385 for_each_possible_cpu(i) 1385 for_each_possible_cpu(i)
1386 alloc_cpumask_var(&per_cpu(local_cpu_mask, i), GFP_KERNEL); 1386 alloc_cpumask_var_node(&per_cpu(local_cpu_mask, i),
1387 GFP_KERNEL, cpu_to_node(i));
1387} 1388}
1388#endif /* CONFIG_SMP */ 1389#endif /* CONFIG_SMP */
1389 1390
diff --git a/kernel/smp.c b/kernel/smp.c
index 75c8dde58c55..5cfa0e5e3e88 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -24,8 +24,8 @@ struct call_function_data {
24 struct call_single_data csd; 24 struct call_single_data csd;
25 spinlock_t lock; 25 spinlock_t lock;
26 unsigned int refs; 26 unsigned int refs;
27 cpumask_t cpumask;
28 struct rcu_head rcu_head; 27 struct rcu_head rcu_head;
28 unsigned long cpumask_bits[];
29}; 29};
30 30
31struct call_single_queue { 31struct call_single_queue {
@@ -110,13 +110,13 @@ void generic_smp_call_function_interrupt(void)
110 list_for_each_entry_rcu(data, &call_function_queue, csd.list) { 110 list_for_each_entry_rcu(data, &call_function_queue, csd.list) {
111 int refs; 111 int refs;
112 112
113 if (!cpu_isset(cpu, data->cpumask)) 113 if (!cpumask_test_cpu(cpu, to_cpumask(data->cpumask_bits)))
114 continue; 114 continue;
115 115
116 data->csd.func(data->csd.info); 116 data->csd.func(data->csd.info);
117 117
118 spin_lock(&data->lock); 118 spin_lock(&data->lock);
119 cpu_clear(cpu, data->cpumask); 119 cpumask_clear_cpu(cpu, to_cpumask(data->cpumask_bits));
120 WARN_ON(data->refs == 0); 120 WARN_ON(data->refs == 0);
121 data->refs--; 121 data->refs--;
122 refs = data->refs; 122 refs = data->refs;
@@ -223,7 +223,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
223 local_irq_save(flags); 223 local_irq_save(flags);
224 func(info); 224 func(info);
225 local_irq_restore(flags); 225 local_irq_restore(flags);
226 } else if ((unsigned)cpu < NR_CPUS && cpu_online(cpu)) { 226 } else if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) {
227 struct call_single_data *data = NULL; 227 struct call_single_data *data = NULL;
228 228
229 if (!wait) { 229 if (!wait) {
@@ -266,51 +266,19 @@ void __smp_call_function_single(int cpu, struct call_single_data *data)
266 generic_exec_single(cpu, data); 266 generic_exec_single(cpu, data);
267} 267}
268 268
269/* Dummy function */ 269/* FIXME: Shim for archs using old arch_send_call_function_ipi API. */
270static void quiesce_dummy(void *unused) 270#ifndef arch_send_call_function_ipi_mask
271{ 271#define arch_send_call_function_ipi_mask(maskp) \
272} 272 arch_send_call_function_ipi(*(maskp))
273 273#endif
274/*
275 * Ensure stack based data used in call function mask is safe to free.
276 *
277 * This is needed by smp_call_function_mask when using on-stack data, because
278 * a single call function queue is shared by all CPUs, and any CPU may pick up
279 * the data item on the queue at any time before it is deleted. So we need to
280 * ensure that all CPUs have transitioned through a quiescent state after
281 * this call.
282 *
283 * This is a very slow function, implemented by sending synchronous IPIs to
284 * all possible CPUs. For this reason, we have to alloc data rather than use
285 * stack based data even in the case of synchronous calls. The stack based
286 * data is then just used for deadlock/oom fallback which will be very rare.
287 *
288 * If a faster scheme can be made, we could go back to preferring stack based
289 * data -- the data allocation/free is non-zero cost.
290 */
291static void smp_call_function_mask_quiesce_stack(cpumask_t mask)
292{
293 struct call_single_data data;
294 int cpu;
295
296 data.func = quiesce_dummy;
297 data.info = NULL;
298
299 for_each_cpu_mask(cpu, mask) {
300 data.flags = CSD_FLAG_WAIT;
301 generic_exec_single(cpu, &data);
302 }
303}
304 274
305/** 275/**
306 * smp_call_function_mask(): Run a function on a set of other CPUs. 276 * smp_call_function_many(): Run a function on a set of other CPUs.
307 * @mask: The set of cpus to run on. 277 * @mask: The set of cpus to run on (only runs on online subset).
308 * @func: The function to run. This must be fast and non-blocking. 278 * @func: The function to run. This must be fast and non-blocking.
309 * @info: An arbitrary pointer to pass to the function. 279 * @info: An arbitrary pointer to pass to the function.
310 * @wait: If true, wait (atomically) until function has completed on other CPUs. 280 * @wait: If true, wait (atomically) until function has completed on other CPUs.
311 * 281 *
312 * Returns 0 on success, else a negative status code.
313 *
314 * If @wait is true, then returns once @func has returned. Note that @wait 282 * If @wait is true, then returns once @func has returned. Note that @wait
315 * will be implicitly turned on in case of allocation failures, since 283 * will be implicitly turned on in case of allocation failures, since
316 * we fall back to on-stack allocation. 284 * we fall back to on-stack allocation.
@@ -319,53 +287,57 @@ static void smp_call_function_mask_quiesce_stack(cpumask_t mask)
319 * hardware interrupt handler or from a bottom half handler. Preemption 287 * hardware interrupt handler or from a bottom half handler. Preemption
320 * must be disabled when calling this function. 288 * must be disabled when calling this function.
321 */ 289 */
322int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info, 290void smp_call_function_many(const struct cpumask *mask,
323 int wait) 291 void (*func)(void *), void *info,
292 bool wait)
324{ 293{
325 struct call_function_data d; 294 struct call_function_data *data;
326 struct call_function_data *data = NULL;
327 cpumask_t allbutself;
328 unsigned long flags; 295 unsigned long flags;
329 int cpu, num_cpus; 296 int cpu, next_cpu;
330 int slowpath = 0;
331 297
332 /* Can deadlock when called with interrupts disabled */ 298 /* Can deadlock when called with interrupts disabled */
333 WARN_ON(irqs_disabled()); 299 WARN_ON(irqs_disabled());
334 300
335 cpu = smp_processor_id(); 301 /* So, what's a CPU they want? Ignoring this one. */
336 allbutself = cpu_online_map; 302 cpu = cpumask_first_and(mask, cpu_online_mask);
337 cpu_clear(cpu, allbutself); 303 if (cpu == smp_processor_id())
338 cpus_and(mask, mask, allbutself); 304 cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
339 num_cpus = cpus_weight(mask); 305 /* No online cpus? We're done. */
340 306 if (cpu >= nr_cpu_ids)
341 /* 307 return;
342 * If zero CPUs, return. If just a single CPU, turn this request 308
343 * into a targetted single call instead since it's faster. 309 /* Do we have another CPU which isn't us? */
344 */ 310 next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
345 if (!num_cpus) 311 if (next_cpu == smp_processor_id())
346 return 0; 312 next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask);
347 else if (num_cpus == 1) { 313
348 cpu = first_cpu(mask); 314 /* Fastpath: do that cpu by itself. */
349 return smp_call_function_single(cpu, func, info, wait); 315 if (next_cpu >= nr_cpu_ids) {
316 smp_call_function_single(cpu, func, info, wait);
317 return;
350 } 318 }
351 319
352 data = kmalloc(sizeof(*data), GFP_ATOMIC); 320 data = kmalloc(sizeof(*data) + cpumask_size(), GFP_ATOMIC);
353 if (data) { 321 if (unlikely(!data)) {
354 data->csd.flags = CSD_FLAG_ALLOC; 322 /* Slow path. */
355 if (wait) 323 for_each_online_cpu(cpu) {
356 data->csd.flags |= CSD_FLAG_WAIT; 324 if (cpu == smp_processor_id())
357 } else { 325 continue;
358 data = &d; 326 if (cpumask_test_cpu(cpu, mask))
359 data->csd.flags = CSD_FLAG_WAIT; 327 smp_call_function_single(cpu, func, info, wait);
360 wait = 1; 328 }
361 slowpath = 1; 329 return;
362 } 330 }
363 331
364 spin_lock_init(&data->lock); 332 spin_lock_init(&data->lock);
333 data->csd.flags = CSD_FLAG_ALLOC;
334 if (wait)
335 data->csd.flags |= CSD_FLAG_WAIT;
365 data->csd.func = func; 336 data->csd.func = func;
366 data->csd.info = info; 337 data->csd.info = info;
367 data->refs = num_cpus; 338 cpumask_and(to_cpumask(data->cpumask_bits), mask, cpu_online_mask);
368 data->cpumask = mask; 339 cpumask_clear_cpu(smp_processor_id(), to_cpumask(data->cpumask_bits));
340 data->refs = cpumask_weight(to_cpumask(data->cpumask_bits));
369 341
370 spin_lock_irqsave(&call_function_lock, flags); 342 spin_lock_irqsave(&call_function_lock, flags);
371 list_add_tail_rcu(&data->csd.list, &call_function_queue); 343 list_add_tail_rcu(&data->csd.list, &call_function_queue);
@@ -377,18 +349,13 @@ int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
377 smp_mb(); 349 smp_mb();
378 350
379 /* Send a message to all CPUs in the map */ 351 /* Send a message to all CPUs in the map */
380 arch_send_call_function_ipi(mask); 352 arch_send_call_function_ipi_mask(to_cpumask(data->cpumask_bits));
381 353
382 /* optionally wait for the CPUs to complete */ 354 /* optionally wait for the CPUs to complete */
383 if (wait) { 355 if (wait)
384 csd_flag_wait(&data->csd); 356 csd_flag_wait(&data->csd);
385 if (unlikely(slowpath))
386 smp_call_function_mask_quiesce_stack(mask);
387 }
388
389 return 0;
390} 357}
391EXPORT_SYMBOL(smp_call_function_mask); 358EXPORT_SYMBOL(smp_call_function_many);
392 359
393/** 360/**
394 * smp_call_function(): Run a function on all other CPUs. 361 * smp_call_function(): Run a function on all other CPUs.
@@ -396,7 +363,7 @@ EXPORT_SYMBOL(smp_call_function_mask);
396 * @info: An arbitrary pointer to pass to the function. 363 * @info: An arbitrary pointer to pass to the function.
397 * @wait: If true, wait (atomically) until function has completed on other CPUs. 364 * @wait: If true, wait (atomically) until function has completed on other CPUs.
398 * 365 *
399 * Returns 0 on success, else a negative status code. 366 * Returns 0.
400 * 367 *
401 * If @wait is true, then returns once @func has returned; otherwise 368 * If @wait is true, then returns once @func has returned; otherwise
402 * it returns just before the target cpu calls @func. In case of allocation 369 * it returns just before the target cpu calls @func. In case of allocation
@@ -407,12 +374,10 @@ EXPORT_SYMBOL(smp_call_function_mask);
407 */ 374 */
408int smp_call_function(void (*func)(void *), void *info, int wait) 375int smp_call_function(void (*func)(void *), void *info, int wait)
409{ 376{
410 int ret;
411
412 preempt_disable(); 377 preempt_disable();
413 ret = smp_call_function_mask(cpu_online_map, func, info, wait); 378 smp_call_function_many(cpu_online_mask, func, info, wait);
414 preempt_enable(); 379 preempt_enable();
415 return ret; 380 return 0;
416} 381}
417EXPORT_SYMBOL(smp_call_function); 382EXPORT_SYMBOL(smp_call_function);
418 383
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 670c1eca47ec..bdbe9de9cd8d 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -733,7 +733,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
733 break; 733 break;
734 /* Unbind so it can run. Fall thru. */ 734 /* Unbind so it can run. Fall thru. */
735 kthread_bind(per_cpu(ksoftirqd, hotcpu), 735 kthread_bind(per_cpu(ksoftirqd, hotcpu),
736 any_online_cpu(cpu_online_map)); 736 cpumask_any(cpu_online_mask));
737 case CPU_DEAD: 737 case CPU_DEAD:
738 case CPU_DEAD_FROZEN: { 738 case CPU_DEAD_FROZEN: {
739 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 739 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 1ab790c67b17..d9188c66278a 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -303,17 +303,15 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
303 break; 303 break;
304 case CPU_ONLINE: 304 case CPU_ONLINE:
305 case CPU_ONLINE_FROZEN: 305 case CPU_ONLINE_FROZEN:
306 check_cpu = any_online_cpu(cpu_online_map); 306 check_cpu = cpumask_any(cpu_online_mask);
307 wake_up_process(per_cpu(watchdog_task, hotcpu)); 307 wake_up_process(per_cpu(watchdog_task, hotcpu));
308 break; 308 break;
309#ifdef CONFIG_HOTPLUG_CPU 309#ifdef CONFIG_HOTPLUG_CPU
310 case CPU_DOWN_PREPARE: 310 case CPU_DOWN_PREPARE:
311 case CPU_DOWN_PREPARE_FROZEN: 311 case CPU_DOWN_PREPARE_FROZEN:
312 if (hotcpu == check_cpu) { 312 if (hotcpu == check_cpu) {
313 cpumask_t temp_cpu_online_map = cpu_online_map; 313 /* Pick any other online cpu. */
314 314 check_cpu = cpumask_any_but(cpu_online_mask, hotcpu);
315 cpu_clear(hotcpu, temp_cpu_online_map);
316 check_cpu = any_online_cpu(temp_cpu_online_map);
317 } 315 }
318 break; 316 break;
319 317
@@ -323,7 +321,7 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
323 break; 321 break;
324 /* Unbind so it can run. Fall thru. */ 322 /* Unbind so it can run. Fall thru. */
325 kthread_bind(per_cpu(watchdog_task, hotcpu), 323 kthread_bind(per_cpu(watchdog_task, hotcpu),
326 any_online_cpu(cpu_online_map)); 324 cpumask_any(cpu_online_mask));
327 case CPU_DEAD: 325 case CPU_DEAD:
328 case CPU_DEAD_FROZEN: 326 case CPU_DEAD_FROZEN:
329 p = per_cpu(watchdog_task, hotcpu); 327 p = per_cpu(watchdog_task, hotcpu);
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 24e8ceacc388..0cd415ee62a2 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -38,7 +38,10 @@ struct stop_machine_data {
38static unsigned int num_threads; 38static unsigned int num_threads;
39static atomic_t thread_ack; 39static atomic_t thread_ack;
40static DEFINE_MUTEX(lock); 40static DEFINE_MUTEX(lock);
41 41/* setup_lock protects refcount, stop_machine_wq and stop_machine_work. */
42static DEFINE_MUTEX(setup_lock);
43/* Users of stop_machine. */
44static int refcount;
42static struct workqueue_struct *stop_machine_wq; 45static struct workqueue_struct *stop_machine_wq;
43static struct stop_machine_data active, idle; 46static struct stop_machine_data active, idle;
44static const cpumask_t *active_cpus; 47static const cpumask_t *active_cpus;
@@ -69,10 +72,10 @@ static void stop_cpu(struct work_struct *unused)
69 int err; 72 int err;
70 73
71 if (!active_cpus) { 74 if (!active_cpus) {
72 if (cpu == first_cpu(cpu_online_map)) 75 if (cpu == cpumask_first(cpu_online_mask))
73 smdata = &active; 76 smdata = &active;
74 } else { 77 } else {
75 if (cpu_isset(cpu, *active_cpus)) 78 if (cpumask_test_cpu(cpu, active_cpus))
76 smdata = &active; 79 smdata = &active;
77 } 80 }
78 /* Simple state machine */ 81 /* Simple state machine */
@@ -109,7 +112,44 @@ static int chill(void *unused)
109 return 0; 112 return 0;
110} 113}
111 114
112int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) 115int stop_machine_create(void)
116{
117 mutex_lock(&setup_lock);
118 if (refcount)
119 goto done;
120 stop_machine_wq = create_rt_workqueue("kstop");
121 if (!stop_machine_wq)
122 goto err_out;
123 stop_machine_work = alloc_percpu(struct work_struct);
124 if (!stop_machine_work)
125 goto err_out;
126done:
127 refcount++;
128 mutex_unlock(&setup_lock);
129 return 0;
130
131err_out:
132 if (stop_machine_wq)
133 destroy_workqueue(stop_machine_wq);
134 mutex_unlock(&setup_lock);
135 return -ENOMEM;
136}
137EXPORT_SYMBOL_GPL(stop_machine_create);
138
139void stop_machine_destroy(void)
140{
141 mutex_lock(&setup_lock);
142 refcount--;
143 if (refcount)
144 goto done;
145 destroy_workqueue(stop_machine_wq);
146 free_percpu(stop_machine_work);
147done:
148 mutex_unlock(&setup_lock);
149}
150EXPORT_SYMBOL_GPL(stop_machine_destroy);
151
152int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
113{ 153{
114 struct work_struct *sm_work; 154 struct work_struct *sm_work;
115 int i, ret; 155 int i, ret;
@@ -142,23 +182,18 @@ int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus)
142 return ret; 182 return ret;
143} 183}
144 184
145int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus) 185int stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus)
146{ 186{
147 int ret; 187 int ret;
148 188
189 ret = stop_machine_create();
190 if (ret)
191 return ret;
149 /* No CPUs can come up or down during this. */ 192 /* No CPUs can come up or down during this. */
150 get_online_cpus(); 193 get_online_cpus();
151 ret = __stop_machine(fn, data, cpus); 194 ret = __stop_machine(fn, data, cpus);
152 put_online_cpus(); 195 put_online_cpus();
153 196 stop_machine_destroy();
154 return ret; 197 return ret;
155} 198}
156EXPORT_SYMBOL_GPL(stop_machine); 199EXPORT_SYMBOL_GPL(stop_machine);
157
158static int __init stop_machine_init(void)
159{
160 stop_machine_wq = create_rt_workqueue("kstop");
161 stop_machine_work = alloc_percpu(struct work_struct);
162 return 0;
163}
164core_initcall(stop_machine_init);
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 6d7dc4ec4aa5..888adbcca30c 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -290,18 +290,17 @@ ret:
290 return; 290 return;
291} 291}
292 292
293static int add_del_listener(pid_t pid, cpumask_t *maskp, int isadd) 293static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd)
294{ 294{
295 struct listener_list *listeners; 295 struct listener_list *listeners;
296 struct listener *s, *tmp; 296 struct listener *s, *tmp;
297 unsigned int cpu; 297 unsigned int cpu;
298 cpumask_t mask = *maskp;
299 298
300 if (!cpus_subset(mask, cpu_possible_map)) 299 if (!cpumask_subset(mask, cpu_possible_mask))
301 return -EINVAL; 300 return -EINVAL;
302 301
303 if (isadd == REGISTER) { 302 if (isadd == REGISTER) {
304 for_each_cpu_mask_nr(cpu, mask) { 303 for_each_cpu(cpu, mask) {
305 s = kmalloc_node(sizeof(struct listener), GFP_KERNEL, 304 s = kmalloc_node(sizeof(struct listener), GFP_KERNEL,
306 cpu_to_node(cpu)); 305 cpu_to_node(cpu));
307 if (!s) 306 if (!s)
@@ -320,7 +319,7 @@ static int add_del_listener(pid_t pid, cpumask_t *maskp, int isadd)
320 319
321 /* Deregister or cleanup */ 320 /* Deregister or cleanup */
322cleanup: 321cleanup:
323 for_each_cpu_mask_nr(cpu, mask) { 322 for_each_cpu(cpu, mask) {
324 listeners = &per_cpu(listener_array, cpu); 323 listeners = &per_cpu(listener_array, cpu);
325 down_write(&listeners->sem); 324 down_write(&listeners->sem);
326 list_for_each_entry_safe(s, tmp, &listeners->list, list) { 325 list_for_each_entry_safe(s, tmp, &listeners->list, list) {
@@ -335,7 +334,7 @@ cleanup:
335 return 0; 334 return 0;
336} 335}
337 336
338static int parse(struct nlattr *na, cpumask_t *mask) 337static int parse(struct nlattr *na, struct cpumask *mask)
339{ 338{
340 char *data; 339 char *data;
341 int len; 340 int len;
@@ -428,23 +427,33 @@ err:
428 427
429static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) 428static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
430{ 429{
431 int rc = 0; 430 int rc;
432 struct sk_buff *rep_skb; 431 struct sk_buff *rep_skb;
433 struct taskstats *stats; 432 struct taskstats *stats;
434 size_t size; 433 size_t size;
435 cpumask_t mask; 434 cpumask_var_t mask;
435
436 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
437 return -ENOMEM;
436 438
437 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask); 439 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask);
438 if (rc < 0) 440 if (rc < 0)
439 return rc; 441 goto free_return_rc;
440 if (rc == 0) 442 if (rc == 0) {
441 return add_del_listener(info->snd_pid, &mask, REGISTER); 443 rc = add_del_listener(info->snd_pid, mask, REGISTER);
444 goto free_return_rc;
445 }
442 446
443 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], &mask); 447 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], mask);
444 if (rc < 0) 448 if (rc < 0)
449 goto free_return_rc;
450 if (rc == 0) {
451 rc = add_del_listener(info->snd_pid, mask, DEREGISTER);
452free_return_rc:
453 free_cpumask_var(mask);
445 return rc; 454 return rc;
446 if (rc == 0) 455 }
447 return add_del_listener(info->snd_pid, &mask, DEREGISTER); 456 free_cpumask_var(mask);
448 457
449 /* 458 /*
450 * Size includes space for nested attributes 459 * Size includes space for nested attributes
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 9ed2eec97526..ca89e1593f08 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -145,10 +145,11 @@ static void clocksource_watchdog(unsigned long data)
145 * Cycle through CPUs to check if the CPUs stay 145 * Cycle through CPUs to check if the CPUs stay
146 * synchronized to each other. 146 * synchronized to each other.
147 */ 147 */
148 int next_cpu = next_cpu_nr(raw_smp_processor_id(), cpu_online_map); 148 int next_cpu = cpumask_next(raw_smp_processor_id(),
149 cpu_online_mask);
149 150
150 if (next_cpu >= nr_cpu_ids) 151 if (next_cpu >= nr_cpu_ids)
151 next_cpu = first_cpu(cpu_online_map); 152 next_cpu = cpumask_first(cpu_online_mask);
152 watchdog_timer.expires += WATCHDOG_INTERVAL; 153 watchdog_timer.expires += WATCHDOG_INTERVAL;
153 add_timer_on(&watchdog_timer, next_cpu); 154 add_timer_on(&watchdog_timer, next_cpu);
154 } 155 }
@@ -173,7 +174,7 @@ static void clocksource_check_watchdog(struct clocksource *cs)
173 watchdog_last = watchdog->read(); 174 watchdog_last = watchdog->read();
174 watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL; 175 watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL;
175 add_timer_on(&watchdog_timer, 176 add_timer_on(&watchdog_timer,
176 first_cpu(cpu_online_map)); 177 cpumask_first(cpu_online_mask));
177 } 178 }
178 } else { 179 } else {
179 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) 180 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS)
@@ -195,7 +196,7 @@ static void clocksource_check_watchdog(struct clocksource *cs)
195 watchdog_timer.expires = 196 watchdog_timer.expires =
196 jiffies + WATCHDOG_INTERVAL; 197 jiffies + WATCHDOG_INTERVAL;
197 add_timer_on(&watchdog_timer, 198 add_timer_on(&watchdog_timer,
198 first_cpu(cpu_online_map)); 199 cpumask_first(cpu_online_mask));
199 } 200 }
200 } 201 }
201 } 202 }
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 9590af2327be..118a3b3b3f9a 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -28,7 +28,9 @@
28 */ 28 */
29 29
30struct tick_device tick_broadcast_device; 30struct tick_device tick_broadcast_device;
31static cpumask_t tick_broadcast_mask; 31/* FIXME: Use cpumask_var_t. */
32static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS);
33static DECLARE_BITMAP(tmpmask, NR_CPUS);
32static DEFINE_SPINLOCK(tick_broadcast_lock); 34static DEFINE_SPINLOCK(tick_broadcast_lock);
33static int tick_broadcast_force; 35static int tick_broadcast_force;
34 36
@@ -46,9 +48,9 @@ struct tick_device *tick_get_broadcast_device(void)
46 return &tick_broadcast_device; 48 return &tick_broadcast_device;
47} 49}
48 50
49cpumask_t *tick_get_broadcast_mask(void) 51struct cpumask *tick_get_broadcast_mask(void)
50{ 52{
51 return &tick_broadcast_mask; 53 return to_cpumask(tick_broadcast_mask);
52} 54}
53 55
54/* 56/*
@@ -72,7 +74,7 @@ int tick_check_broadcast_device(struct clock_event_device *dev)
72 74
73 clockevents_exchange_device(NULL, dev); 75 clockevents_exchange_device(NULL, dev);
74 tick_broadcast_device.evtdev = dev; 76 tick_broadcast_device.evtdev = dev;
75 if (!cpus_empty(tick_broadcast_mask)) 77 if (!cpumask_empty(tick_get_broadcast_mask()))
76 tick_broadcast_start_periodic(dev); 78 tick_broadcast_start_periodic(dev);
77 return 1; 79 return 1;
78} 80}
@@ -104,7 +106,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
104 */ 106 */
105 if (!tick_device_is_functional(dev)) { 107 if (!tick_device_is_functional(dev)) {
106 dev->event_handler = tick_handle_periodic; 108 dev->event_handler = tick_handle_periodic;
107 cpu_set(cpu, tick_broadcast_mask); 109 cpumask_set_cpu(cpu, tick_get_broadcast_mask());
108 tick_broadcast_start_periodic(tick_broadcast_device.evtdev); 110 tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
109 ret = 1; 111 ret = 1;
110 } else { 112 } else {
@@ -116,7 +118,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
116 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) { 118 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
117 int cpu = smp_processor_id(); 119 int cpu = smp_processor_id();
118 120
119 cpu_clear(cpu, tick_broadcast_mask); 121 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
120 tick_broadcast_clear_oneshot(cpu); 122 tick_broadcast_clear_oneshot(cpu);
121 } 123 }
122 } 124 }
@@ -125,9 +127,9 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
125} 127}
126 128
127/* 129/*
128 * Broadcast the event to the cpus, which are set in the mask 130 * Broadcast the event to the cpus, which are set in the mask (mangled).
129 */ 131 */
130static void tick_do_broadcast(cpumask_t mask) 132static void tick_do_broadcast(struct cpumask *mask)
131{ 133{
132 int cpu = smp_processor_id(); 134 int cpu = smp_processor_id();
133 struct tick_device *td; 135 struct tick_device *td;
@@ -135,22 +137,21 @@ static void tick_do_broadcast(cpumask_t mask)
135 /* 137 /*
136 * Check, if the current cpu is in the mask 138 * Check, if the current cpu is in the mask
137 */ 139 */
138 if (cpu_isset(cpu, mask)) { 140 if (cpumask_test_cpu(cpu, mask)) {
139 cpu_clear(cpu, mask); 141 cpumask_clear_cpu(cpu, mask);
140 td = &per_cpu(tick_cpu_device, cpu); 142 td = &per_cpu(tick_cpu_device, cpu);
141 td->evtdev->event_handler(td->evtdev); 143 td->evtdev->event_handler(td->evtdev);
142 } 144 }
143 145
144 if (!cpus_empty(mask)) { 146 if (!cpumask_empty(mask)) {
145 /* 147 /*
146 * It might be necessary to actually check whether the devices 148 * It might be necessary to actually check whether the devices
147 * have different broadcast functions. For now, just use the 149 * have different broadcast functions. For now, just use the
148 * one of the first device. This works as long as we have this 150 * one of the first device. This works as long as we have this
149 * misfeature only on x86 (lapic) 151 * misfeature only on x86 (lapic)
150 */ 152 */
151 cpu = first_cpu(mask); 153 td = &per_cpu(tick_cpu_device, cpumask_first(mask));
152 td = &per_cpu(tick_cpu_device, cpu); 154 td->evtdev->broadcast(mask);
153 td->evtdev->broadcast(&mask);
154 } 155 }
155} 156}
156 157
@@ -160,12 +161,11 @@ static void tick_do_broadcast(cpumask_t mask)
160 */ 161 */
161static void tick_do_periodic_broadcast(void) 162static void tick_do_periodic_broadcast(void)
162{ 163{
163 cpumask_t mask;
164
165 spin_lock(&tick_broadcast_lock); 164 spin_lock(&tick_broadcast_lock);
166 165
167 cpus_and(mask, cpu_online_map, tick_broadcast_mask); 166 cpumask_and(to_cpumask(tmpmask),
168 tick_do_broadcast(mask); 167 cpu_online_mask, tick_get_broadcast_mask());
168 tick_do_broadcast(to_cpumask(tmpmask));
169 169
170 spin_unlock(&tick_broadcast_lock); 170 spin_unlock(&tick_broadcast_lock);
171} 171}
@@ -228,13 +228,13 @@ static void tick_do_broadcast_on_off(void *why)
228 if (!tick_device_is_functional(dev)) 228 if (!tick_device_is_functional(dev))
229 goto out; 229 goto out;
230 230
231 bc_stopped = cpus_empty(tick_broadcast_mask); 231 bc_stopped = cpumask_empty(tick_get_broadcast_mask());
232 232
233 switch (*reason) { 233 switch (*reason) {
234 case CLOCK_EVT_NOTIFY_BROADCAST_ON: 234 case CLOCK_EVT_NOTIFY_BROADCAST_ON:
235 case CLOCK_EVT_NOTIFY_BROADCAST_FORCE: 235 case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
236 if (!cpu_isset(cpu, tick_broadcast_mask)) { 236 if (!cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
237 cpu_set(cpu, tick_broadcast_mask); 237 cpumask_set_cpu(cpu, tick_get_broadcast_mask());
238 if (tick_broadcast_device.mode == 238 if (tick_broadcast_device.mode ==
239 TICKDEV_MODE_PERIODIC) 239 TICKDEV_MODE_PERIODIC)
240 clockevents_shutdown(dev); 240 clockevents_shutdown(dev);
@@ -244,8 +244,8 @@ static void tick_do_broadcast_on_off(void *why)
244 break; 244 break;
245 case CLOCK_EVT_NOTIFY_BROADCAST_OFF: 245 case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
246 if (!tick_broadcast_force && 246 if (!tick_broadcast_force &&
247 cpu_isset(cpu, tick_broadcast_mask)) { 247 cpumask_test_cpu(cpu, tick_get_broadcast_mask())) {
248 cpu_clear(cpu, tick_broadcast_mask); 248 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
249 if (tick_broadcast_device.mode == 249 if (tick_broadcast_device.mode ==
250 TICKDEV_MODE_PERIODIC) 250 TICKDEV_MODE_PERIODIC)
251 tick_setup_periodic(dev, 0); 251 tick_setup_periodic(dev, 0);
@@ -253,7 +253,7 @@ static void tick_do_broadcast_on_off(void *why)
253 break; 253 break;
254 } 254 }
255 255
256 if (cpus_empty(tick_broadcast_mask)) { 256 if (cpumask_empty(tick_get_broadcast_mask())) {
257 if (!bc_stopped) 257 if (!bc_stopped)
258 clockevents_shutdown(bc); 258 clockevents_shutdown(bc);
259 } else if (bc_stopped) { 259 } else if (bc_stopped) {
@@ -272,7 +272,7 @@ out:
272 */ 272 */
273void tick_broadcast_on_off(unsigned long reason, int *oncpu) 273void tick_broadcast_on_off(unsigned long reason, int *oncpu)
274{ 274{
275 if (!cpu_isset(*oncpu, cpu_online_map)) 275 if (!cpumask_test_cpu(*oncpu, cpu_online_mask))
276 printk(KERN_ERR "tick-broadcast: ignoring broadcast for " 276 printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
277 "offline CPU #%d\n", *oncpu); 277 "offline CPU #%d\n", *oncpu);
278 else 278 else
@@ -303,10 +303,10 @@ void tick_shutdown_broadcast(unsigned int *cpup)
303 spin_lock_irqsave(&tick_broadcast_lock, flags); 303 spin_lock_irqsave(&tick_broadcast_lock, flags);
304 304
305 bc = tick_broadcast_device.evtdev; 305 bc = tick_broadcast_device.evtdev;
306 cpu_clear(cpu, tick_broadcast_mask); 306 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
307 307
308 if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) { 308 if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
309 if (bc && cpus_empty(tick_broadcast_mask)) 309 if (bc && cpumask_empty(tick_get_broadcast_mask()))
310 clockevents_shutdown(bc); 310 clockevents_shutdown(bc);
311 } 311 }
312 312
@@ -342,10 +342,10 @@ int tick_resume_broadcast(void)
342 342
343 switch (tick_broadcast_device.mode) { 343 switch (tick_broadcast_device.mode) {
344 case TICKDEV_MODE_PERIODIC: 344 case TICKDEV_MODE_PERIODIC:
345 if(!cpus_empty(tick_broadcast_mask)) 345 if (!cpumask_empty(tick_get_broadcast_mask()))
346 tick_broadcast_start_periodic(bc); 346 tick_broadcast_start_periodic(bc);
347 broadcast = cpu_isset(smp_processor_id(), 347 broadcast = cpumask_test_cpu(smp_processor_id(),
348 tick_broadcast_mask); 348 tick_get_broadcast_mask());
349 break; 349 break;
350 case TICKDEV_MODE_ONESHOT: 350 case TICKDEV_MODE_ONESHOT:
351 broadcast = tick_resume_broadcast_oneshot(bc); 351 broadcast = tick_resume_broadcast_oneshot(bc);
@@ -360,14 +360,15 @@ int tick_resume_broadcast(void)
360 360
361#ifdef CONFIG_TICK_ONESHOT 361#ifdef CONFIG_TICK_ONESHOT
362 362
363static cpumask_t tick_broadcast_oneshot_mask; 363/* FIXME: use cpumask_var_t. */
364static DECLARE_BITMAP(tick_broadcast_oneshot_mask, NR_CPUS);
364 365
365/* 366/*
366 * Debugging: see timer_list.c 367 * Exposed for debugging: see timer_list.c
367 */ 368 */
368cpumask_t *tick_get_broadcast_oneshot_mask(void) 369struct cpumask *tick_get_broadcast_oneshot_mask(void)
369{ 370{
370 return &tick_broadcast_oneshot_mask; 371 return to_cpumask(tick_broadcast_oneshot_mask);
371} 372}
372 373
373static int tick_broadcast_set_event(ktime_t expires, int force) 374static int tick_broadcast_set_event(ktime_t expires, int force)
@@ -389,7 +390,7 @@ int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
389 */ 390 */
390void tick_check_oneshot_broadcast(int cpu) 391void tick_check_oneshot_broadcast(int cpu)
391{ 392{
392 if (cpu_isset(cpu, tick_broadcast_oneshot_mask)) { 393 if (cpumask_test_cpu(cpu, to_cpumask(tick_broadcast_oneshot_mask))) {
393 struct tick_device *td = &per_cpu(tick_cpu_device, cpu); 394 struct tick_device *td = &per_cpu(tick_cpu_device, cpu);
394 395
395 clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_ONESHOT); 396 clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_ONESHOT);
@@ -402,7 +403,6 @@ void tick_check_oneshot_broadcast(int cpu)
402static void tick_handle_oneshot_broadcast(struct clock_event_device *dev) 403static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
403{ 404{
404 struct tick_device *td; 405 struct tick_device *td;
405 cpumask_t mask;
406 ktime_t now, next_event; 406 ktime_t now, next_event;
407 int cpu; 407 int cpu;
408 408
@@ -410,13 +410,13 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
410again: 410again:
411 dev->next_event.tv64 = KTIME_MAX; 411 dev->next_event.tv64 = KTIME_MAX;
412 next_event.tv64 = KTIME_MAX; 412 next_event.tv64 = KTIME_MAX;
413 mask = CPU_MASK_NONE; 413 cpumask_clear(to_cpumask(tmpmask));
414 now = ktime_get(); 414 now = ktime_get();
415 /* Find all expired events */ 415 /* Find all expired events */
416 for_each_cpu_mask_nr(cpu, tick_broadcast_oneshot_mask) { 416 for_each_cpu(cpu, tick_get_broadcast_oneshot_mask()) {
417 td = &per_cpu(tick_cpu_device, cpu); 417 td = &per_cpu(tick_cpu_device, cpu);
418 if (td->evtdev->next_event.tv64 <= now.tv64) 418 if (td->evtdev->next_event.tv64 <= now.tv64)
419 cpu_set(cpu, mask); 419 cpumask_set_cpu(cpu, to_cpumask(tmpmask));
420 else if (td->evtdev->next_event.tv64 < next_event.tv64) 420 else if (td->evtdev->next_event.tv64 < next_event.tv64)
421 next_event.tv64 = td->evtdev->next_event.tv64; 421 next_event.tv64 = td->evtdev->next_event.tv64;
422 } 422 }
@@ -424,7 +424,7 @@ again:
424 /* 424 /*
425 * Wakeup the cpus which have an expired event. 425 * Wakeup the cpus which have an expired event.
426 */ 426 */
427 tick_do_broadcast(mask); 427 tick_do_broadcast(to_cpumask(tmpmask));
428 428
429 /* 429 /*
430 * Two reasons for reprogram: 430 * Two reasons for reprogram:
@@ -476,15 +476,16 @@ void tick_broadcast_oneshot_control(unsigned long reason)
476 goto out; 476 goto out;
477 477
478 if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) { 478 if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
479 if (!cpu_isset(cpu, tick_broadcast_oneshot_mask)) { 479 if (!cpumask_test_cpu(cpu, tick_get_broadcast_oneshot_mask())) {
480 cpu_set(cpu, tick_broadcast_oneshot_mask); 480 cpumask_set_cpu(cpu, tick_get_broadcast_oneshot_mask());
481 clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN); 481 clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
482 if (dev->next_event.tv64 < bc->next_event.tv64) 482 if (dev->next_event.tv64 < bc->next_event.tv64)
483 tick_broadcast_set_event(dev->next_event, 1); 483 tick_broadcast_set_event(dev->next_event, 1);
484 } 484 }
485 } else { 485 } else {
486 if (cpu_isset(cpu, tick_broadcast_oneshot_mask)) { 486 if (cpumask_test_cpu(cpu, tick_get_broadcast_oneshot_mask())) {
487 cpu_clear(cpu, tick_broadcast_oneshot_mask); 487 cpumask_clear_cpu(cpu,
488 tick_get_broadcast_oneshot_mask());
488 clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); 489 clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
489 if (dev->next_event.tv64 != KTIME_MAX) 490 if (dev->next_event.tv64 != KTIME_MAX)
490 tick_program_event(dev->next_event, 1); 491 tick_program_event(dev->next_event, 1);
@@ -502,15 +503,16 @@ out:
502 */ 503 */
503static void tick_broadcast_clear_oneshot(int cpu) 504static void tick_broadcast_clear_oneshot(int cpu)
504{ 505{
505 cpu_clear(cpu, tick_broadcast_oneshot_mask); 506 cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
506} 507}
507 508
508static void tick_broadcast_init_next_event(cpumask_t *mask, ktime_t expires) 509static void tick_broadcast_init_next_event(struct cpumask *mask,
510 ktime_t expires)
509{ 511{
510 struct tick_device *td; 512 struct tick_device *td;
511 int cpu; 513 int cpu;
512 514
513 for_each_cpu_mask_nr(cpu, *mask) { 515 for_each_cpu(cpu, mask) {
514 td = &per_cpu(tick_cpu_device, cpu); 516 td = &per_cpu(tick_cpu_device, cpu);
515 if (td->evtdev) 517 if (td->evtdev)
516 td->evtdev->next_event = expires; 518 td->evtdev->next_event = expires;
@@ -526,7 +528,6 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
526 if (bc->event_handler != tick_handle_oneshot_broadcast) { 528 if (bc->event_handler != tick_handle_oneshot_broadcast) {
527 int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC; 529 int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC;
528 int cpu = smp_processor_id(); 530 int cpu = smp_processor_id();
529 cpumask_t mask;
530 531
531 bc->event_handler = tick_handle_oneshot_broadcast; 532 bc->event_handler = tick_handle_oneshot_broadcast;
532 clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT); 533 clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
@@ -540,13 +541,15 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
540 * oneshot_mask bits for those and program the 541 * oneshot_mask bits for those and program the
541 * broadcast device to fire. 542 * broadcast device to fire.
542 */ 543 */
543 mask = tick_broadcast_mask; 544 cpumask_copy(to_cpumask(tmpmask), tick_get_broadcast_mask());
544 cpu_clear(cpu, mask); 545 cpumask_clear_cpu(cpu, to_cpumask(tmpmask));
545 cpus_or(tick_broadcast_oneshot_mask, 546 cpumask_or(tick_get_broadcast_oneshot_mask(),
546 tick_broadcast_oneshot_mask, mask); 547 tick_get_broadcast_oneshot_mask(),
547 548 to_cpumask(tmpmask));
548 if (was_periodic && !cpus_empty(mask)) { 549
549 tick_broadcast_init_next_event(&mask, tick_next_period); 550 if (was_periodic && !cpumask_empty(to_cpumask(tmpmask))) {
551 tick_broadcast_init_next_event(to_cpumask(tmpmask),
552 tick_next_period);
550 tick_broadcast_set_event(tick_next_period, 1); 553 tick_broadcast_set_event(tick_next_period, 1);
551 } else 554 } else
552 bc->next_event.tv64 = KTIME_MAX; 555 bc->next_event.tv64 = KTIME_MAX;
@@ -585,7 +588,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
585 * Clear the broadcast mask flag for the dead cpu, but do not 588 * Clear the broadcast mask flag for the dead cpu, but do not
586 * stop the broadcast device! 589 * stop the broadcast device!
587 */ 590 */
588 cpu_clear(cpu, tick_broadcast_oneshot_mask); 591 cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
589 592
590 spin_unlock_irqrestore(&tick_broadcast_lock, flags); 593 spin_unlock_irqrestore(&tick_broadcast_lock, flags);
591} 594}
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index f8372be74122..63e05d423a09 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -254,7 +254,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
254 curdev = NULL; 254 curdev = NULL;
255 } 255 }
256 clockevents_exchange_device(curdev, newdev); 256 clockevents_exchange_device(curdev, newdev);
257 tick_setup_device(td, newdev, cpu, &cpumask_of_cpu(cpu)); 257 tick_setup_device(td, newdev, cpu, cpumask_of(cpu));
258 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 258 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT)
259 tick_oneshot_notify(); 259 tick_oneshot_notify();
260 260
@@ -299,9 +299,9 @@ static void tick_shutdown(unsigned int *cpup)
299 } 299 }
300 /* Transfer the do_timer job away from this cpu */ 300 /* Transfer the do_timer job away from this cpu */
301 if (*cpup == tick_do_timer_cpu) { 301 if (*cpup == tick_do_timer_cpu) {
302 int cpu = first_cpu(cpu_online_map); 302 int cpu = cpumask_first(cpu_online_mask);
303 303
304 tick_do_timer_cpu = (cpu != NR_CPUS) ? cpu : 304 tick_do_timer_cpu = (cpu < nr_cpu_ids) ? cpu :
305 TICK_DO_TIMER_NONE; 305 TICK_DO_TIMER_NONE;
306 } 306 }
307 spin_unlock_irqrestore(&tick_device_lock, flags); 307 spin_unlock_irqrestore(&tick_device_lock, flags);
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 76a574bbef97..1b6c05bd0d0a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -419,7 +419,9 @@ void tick_nohz_restart_sched_tick(void)
419{ 419{
420 int cpu = smp_processor_id(); 420 int cpu = smp_processor_id();
421 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); 421 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
422#ifndef CONFIG_VIRT_CPU_ACCOUNTING
422 unsigned long ticks; 423 unsigned long ticks;
424#endif
423 ktime_t now; 425 ktime_t now;
424 426
425 local_irq_disable(); 427 local_irq_disable();
@@ -441,6 +443,7 @@ void tick_nohz_restart_sched_tick(void)
441 tick_do_update_jiffies64(now); 443 tick_do_update_jiffies64(now);
442 cpumask_clear_cpu(cpu, nohz_cpu_mask); 444 cpumask_clear_cpu(cpu, nohz_cpu_mask);
443 445
446#ifndef CONFIG_VIRT_CPU_ACCOUNTING
444 /* 447 /*
445 * We stopped the tick in idle. Update process times would miss the 448 * We stopped the tick in idle. Update process times would miss the
446 * time we slept as update_process_times does only a 1 tick 449 * time we slept as update_process_times does only a 1 tick
@@ -450,12 +453,9 @@ void tick_nohz_restart_sched_tick(void)
450 /* 453 /*
451 * We might be one off. Do not randomly account a huge number of ticks! 454 * We might be one off. Do not randomly account a huge number of ticks!
452 */ 455 */
453 if (ticks && ticks < LONG_MAX) { 456 if (ticks && ticks < LONG_MAX)
454 add_preempt_count(HARDIRQ_OFFSET); 457 account_idle_ticks(ticks);
455 account_system_time(current, HARDIRQ_OFFSET, 458#endif
456 jiffies_to_cputime(ticks));
457 sub_preempt_count(HARDIRQ_OFFSET);
458 }
459 459
460 touch_softlockup_watchdog(); 460 touch_softlockup_watchdog();
461 /* 461 /*
diff --git a/kernel/timer.c b/kernel/timer.c
index 566257d1dc10..dee3f641a7a7 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -1018,21 +1018,6 @@ unsigned long get_next_timer_interrupt(unsigned long now)
1018} 1018}
1019#endif 1019#endif
1020 1020
1021#ifndef CONFIG_VIRT_CPU_ACCOUNTING
1022void account_process_tick(struct task_struct *p, int user_tick)
1023{
1024 cputime_t one_jiffy = jiffies_to_cputime(1);
1025
1026 if (user_tick) {
1027 account_user_time(p, one_jiffy);
1028 account_user_time_scaled(p, cputime_to_scaled(one_jiffy));
1029 } else {
1030 account_system_time(p, HARDIRQ_OFFSET, one_jiffy);
1031 account_system_time_scaled(p, cputime_to_scaled(one_jiffy));
1032 }
1033}
1034#endif
1035
1036/* 1021/*
1037 * Called from the timer interrupt handler to charge one tick to the current 1022 * Called from the timer interrupt handler to charge one tick to the current
1038 * process. user_tick is 1 if the tick is user time, 0 for system. 1023 * process. user_tick is 1 if the tick is user time, 0 for system.
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 1d601a7c4587..a9d9760dc7b6 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -195,7 +195,7 @@ void *ring_buffer_event_data(struct ring_buffer_event *event)
195EXPORT_SYMBOL_GPL(ring_buffer_event_data); 195EXPORT_SYMBOL_GPL(ring_buffer_event_data);
196 196
197#define for_each_buffer_cpu(buffer, cpu) \ 197#define for_each_buffer_cpu(buffer, cpu) \
198 for_each_cpu_mask(cpu, buffer->cpumask) 198 for_each_cpu(cpu, buffer->cpumask)
199 199
200#define TS_SHIFT 27 200#define TS_SHIFT 27
201#define TS_MASK ((1ULL << TS_SHIFT) - 1) 201#define TS_MASK ((1ULL << TS_SHIFT) - 1)
@@ -267,7 +267,7 @@ struct ring_buffer {
267 unsigned pages; 267 unsigned pages;
268 unsigned flags; 268 unsigned flags;
269 int cpus; 269 int cpus;
270 cpumask_t cpumask; 270 cpumask_var_t cpumask;
271 atomic_t record_disabled; 271 atomic_t record_disabled;
272 272
273 struct mutex mutex; 273 struct mutex mutex;
@@ -458,6 +458,9 @@ struct ring_buffer *ring_buffer_alloc(unsigned long size, unsigned flags)
458 if (!buffer) 458 if (!buffer)
459 return NULL; 459 return NULL;
460 460
461 if (!alloc_cpumask_var(&buffer->cpumask, GFP_KERNEL))
462 goto fail_free_buffer;
463
461 buffer->pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE); 464 buffer->pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
462 buffer->flags = flags; 465 buffer->flags = flags;
463 466
@@ -465,14 +468,14 @@ struct ring_buffer *ring_buffer_alloc(unsigned long size, unsigned flags)
465 if (buffer->pages == 1) 468 if (buffer->pages == 1)
466 buffer->pages++; 469 buffer->pages++;
467 470
468 buffer->cpumask = cpu_possible_map; 471 cpumask_copy(buffer->cpumask, cpu_possible_mask);
469 buffer->cpus = nr_cpu_ids; 472 buffer->cpus = nr_cpu_ids;
470 473
471 bsize = sizeof(void *) * nr_cpu_ids; 474 bsize = sizeof(void *) * nr_cpu_ids;
472 buffer->buffers = kzalloc(ALIGN(bsize, cache_line_size()), 475 buffer->buffers = kzalloc(ALIGN(bsize, cache_line_size()),
473 GFP_KERNEL); 476 GFP_KERNEL);
474 if (!buffer->buffers) 477 if (!buffer->buffers)
475 goto fail_free_buffer; 478 goto fail_free_cpumask;
476 479
477 for_each_buffer_cpu(buffer, cpu) { 480 for_each_buffer_cpu(buffer, cpu) {
478 buffer->buffers[cpu] = 481 buffer->buffers[cpu] =
@@ -492,6 +495,9 @@ struct ring_buffer *ring_buffer_alloc(unsigned long size, unsigned flags)
492 } 495 }
493 kfree(buffer->buffers); 496 kfree(buffer->buffers);
494 497
498 fail_free_cpumask:
499 free_cpumask_var(buffer->cpumask);
500
495 fail_free_buffer: 501 fail_free_buffer:
496 kfree(buffer); 502 kfree(buffer);
497 return NULL; 503 return NULL;
@@ -510,6 +516,8 @@ ring_buffer_free(struct ring_buffer *buffer)
510 for_each_buffer_cpu(buffer, cpu) 516 for_each_buffer_cpu(buffer, cpu)
511 rb_free_cpu_buffer(buffer->buffers[cpu]); 517 rb_free_cpu_buffer(buffer->buffers[cpu]);
512 518
519 free_cpumask_var(buffer->cpumask);
520
513 kfree(buffer); 521 kfree(buffer);
514} 522}
515EXPORT_SYMBOL_GPL(ring_buffer_free); 523EXPORT_SYMBOL_GPL(ring_buffer_free);
@@ -1283,7 +1291,7 @@ ring_buffer_lock_reserve(struct ring_buffer *buffer,
1283 1291
1284 cpu = raw_smp_processor_id(); 1292 cpu = raw_smp_processor_id();
1285 1293
1286 if (!cpu_isset(cpu, buffer->cpumask)) 1294 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1287 goto out; 1295 goto out;
1288 1296
1289 cpu_buffer = buffer->buffers[cpu]; 1297 cpu_buffer = buffer->buffers[cpu];
@@ -1396,7 +1404,7 @@ int ring_buffer_write(struct ring_buffer *buffer,
1396 1404
1397 cpu = raw_smp_processor_id(); 1405 cpu = raw_smp_processor_id();
1398 1406
1399 if (!cpu_isset(cpu, buffer->cpumask)) 1407 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1400 goto out; 1408 goto out;
1401 1409
1402 cpu_buffer = buffer->buffers[cpu]; 1410 cpu_buffer = buffer->buffers[cpu];
@@ -1478,7 +1486,7 @@ void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu)
1478{ 1486{
1479 struct ring_buffer_per_cpu *cpu_buffer; 1487 struct ring_buffer_per_cpu *cpu_buffer;
1480 1488
1481 if (!cpu_isset(cpu, buffer->cpumask)) 1489 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1482 return; 1490 return;
1483 1491
1484 cpu_buffer = buffer->buffers[cpu]; 1492 cpu_buffer = buffer->buffers[cpu];
@@ -1498,7 +1506,7 @@ void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu)
1498{ 1506{
1499 struct ring_buffer_per_cpu *cpu_buffer; 1507 struct ring_buffer_per_cpu *cpu_buffer;
1500 1508
1501 if (!cpu_isset(cpu, buffer->cpumask)) 1509 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1502 return; 1510 return;
1503 1511
1504 cpu_buffer = buffer->buffers[cpu]; 1512 cpu_buffer = buffer->buffers[cpu];
@@ -1515,7 +1523,7 @@ unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu)
1515{ 1523{
1516 struct ring_buffer_per_cpu *cpu_buffer; 1524 struct ring_buffer_per_cpu *cpu_buffer;
1517 1525
1518 if (!cpu_isset(cpu, buffer->cpumask)) 1526 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1519 return 0; 1527 return 0;
1520 1528
1521 cpu_buffer = buffer->buffers[cpu]; 1529 cpu_buffer = buffer->buffers[cpu];
@@ -1532,7 +1540,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
1532{ 1540{
1533 struct ring_buffer_per_cpu *cpu_buffer; 1541 struct ring_buffer_per_cpu *cpu_buffer;
1534 1542
1535 if (!cpu_isset(cpu, buffer->cpumask)) 1543 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1536 return 0; 1544 return 0;
1537 1545
1538 cpu_buffer = buffer->buffers[cpu]; 1546 cpu_buffer = buffer->buffers[cpu];
@@ -1850,7 +1858,7 @@ rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
1850 struct buffer_page *reader; 1858 struct buffer_page *reader;
1851 int nr_loops = 0; 1859 int nr_loops = 0;
1852 1860
1853 if (!cpu_isset(cpu, buffer->cpumask)) 1861 if (!cpumask_test_cpu(cpu, buffer->cpumask))
1854 return NULL; 1862 return NULL;
1855 1863
1856 cpu_buffer = buffer->buffers[cpu]; 1864 cpu_buffer = buffer->buffers[cpu];
@@ -2025,7 +2033,7 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
2025 struct ring_buffer_event *event; 2033 struct ring_buffer_event *event;
2026 unsigned long flags; 2034 unsigned long flags;
2027 2035
2028 if (!cpu_isset(cpu, buffer->cpumask)) 2036 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2029 return NULL; 2037 return NULL;
2030 2038
2031 spin_lock_irqsave(&cpu_buffer->reader_lock, flags); 2039 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
@@ -2062,7 +2070,7 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)
2062 struct ring_buffer_iter *iter; 2070 struct ring_buffer_iter *iter;
2063 unsigned long flags; 2071 unsigned long flags;
2064 2072
2065 if (!cpu_isset(cpu, buffer->cpumask)) 2073 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2066 return NULL; 2074 return NULL;
2067 2075
2068 iter = kmalloc(sizeof(*iter), GFP_KERNEL); 2076 iter = kmalloc(sizeof(*iter), GFP_KERNEL);
@@ -2172,7 +2180,7 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
2172 struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu]; 2180 struct ring_buffer_per_cpu *cpu_buffer = buffer->buffers[cpu];
2173 unsigned long flags; 2181 unsigned long flags;
2174 2182
2175 if (!cpu_isset(cpu, buffer->cpumask)) 2183 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2176 return; 2184 return;
2177 2185
2178 spin_lock_irqsave(&cpu_buffer->reader_lock, flags); 2186 spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
@@ -2228,7 +2236,7 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu)
2228{ 2236{
2229 struct ring_buffer_per_cpu *cpu_buffer; 2237 struct ring_buffer_per_cpu *cpu_buffer;
2230 2238
2231 if (!cpu_isset(cpu, buffer->cpumask)) 2239 if (!cpumask_test_cpu(cpu, buffer->cpumask))
2232 return 1; 2240 return 1;
2233 2241
2234 cpu_buffer = buffer->buffers[cpu]; 2242 cpu_buffer = buffer->buffers[cpu];
@@ -2252,8 +2260,8 @@ int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
2252 struct ring_buffer_per_cpu *cpu_buffer_a; 2260 struct ring_buffer_per_cpu *cpu_buffer_a;
2253 struct ring_buffer_per_cpu *cpu_buffer_b; 2261 struct ring_buffer_per_cpu *cpu_buffer_b;
2254 2262
2255 if (!cpu_isset(cpu, buffer_a->cpumask) || 2263 if (!cpumask_test_cpu(cpu, buffer_a->cpumask) ||
2256 !cpu_isset(cpu, buffer_b->cpumask)) 2264 !cpumask_test_cpu(cpu, buffer_b->cpumask))
2257 return -EINVAL; 2265 return -EINVAL;
2258 2266
2259 /* At least make sure the two buffers are somewhat the same */ 2267 /* At least make sure the two buffers are somewhat the same */
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0e91f43b6baf..c580233add95 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -89,10 +89,10 @@ static inline void ftrace_enable_cpu(void)
89 preempt_enable(); 89 preempt_enable();
90} 90}
91 91
92static cpumask_t __read_mostly tracing_buffer_mask; 92static cpumask_var_t __read_mostly tracing_buffer_mask;
93 93
94#define for_each_tracing_cpu(cpu) \ 94#define for_each_tracing_cpu(cpu) \
95 for_each_cpu_mask(cpu, tracing_buffer_mask) 95 for_each_cpu(cpu, tracing_buffer_mask)
96 96
97/* 97/*
98 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops 98 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
@@ -1811,10 +1811,10 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
1811 if (!(iter->iter_flags & TRACE_FILE_ANNOTATE)) 1811 if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
1812 return; 1812 return;
1813 1813
1814 if (cpu_isset(iter->cpu, iter->started)) 1814 if (cpumask_test_cpu(iter->cpu, iter->started))
1815 return; 1815 return;
1816 1816
1817 cpu_set(iter->cpu, iter->started); 1817 cpumask_set_cpu(iter->cpu, iter->started);
1818 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu); 1818 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu);
1819} 1819}
1820 1820
@@ -2646,13 +2646,7 @@ static struct file_operations show_traces_fops = {
2646/* 2646/*
2647 * Only trace on a CPU if the bitmask is set: 2647 * Only trace on a CPU if the bitmask is set:
2648 */ 2648 */
2649static cpumask_t tracing_cpumask = CPU_MASK_ALL; 2649static cpumask_var_t tracing_cpumask;
2650
2651/*
2652 * When tracing/tracing_cpu_mask is modified then this holds
2653 * the new bitmask we are about to install:
2654 */
2655static cpumask_t tracing_cpumask_new;
2656 2650
2657/* 2651/*
2658 * The tracer itself will not take this lock, but still we want 2652 * The tracer itself will not take this lock, but still we want
@@ -2674,7 +2668,7 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf,
2674 2668
2675 mutex_lock(&tracing_cpumask_update_lock); 2669 mutex_lock(&tracing_cpumask_update_lock);
2676 2670
2677 len = cpumask_scnprintf(mask_str, count, &tracing_cpumask); 2671 len = cpumask_scnprintf(mask_str, count, tracing_cpumask);
2678 if (count - len < 2) { 2672 if (count - len < 2) {
2679 count = -EINVAL; 2673 count = -EINVAL;
2680 goto out_err; 2674 goto out_err;
@@ -2693,9 +2687,13 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
2693 size_t count, loff_t *ppos) 2687 size_t count, loff_t *ppos)
2694{ 2688{
2695 int err, cpu; 2689 int err, cpu;
2690 cpumask_var_t tracing_cpumask_new;
2691
2692 if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
2693 return -ENOMEM;
2696 2694
2697 mutex_lock(&tracing_cpumask_update_lock); 2695 mutex_lock(&tracing_cpumask_update_lock);
2698 err = cpumask_parse_user(ubuf, count, &tracing_cpumask_new); 2696 err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
2699 if (err) 2697 if (err)
2700 goto err_unlock; 2698 goto err_unlock;
2701 2699
@@ -2706,26 +2704,28 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
2706 * Increase/decrease the disabled counter if we are 2704 * Increase/decrease the disabled counter if we are
2707 * about to flip a bit in the cpumask: 2705 * about to flip a bit in the cpumask:
2708 */ 2706 */
2709 if (cpu_isset(cpu, tracing_cpumask) && 2707 if (cpumask_test_cpu(cpu, tracing_cpumask) &&
2710 !cpu_isset(cpu, tracing_cpumask_new)) { 2708 !cpumask_test_cpu(cpu, tracing_cpumask_new)) {
2711 atomic_inc(&global_trace.data[cpu]->disabled); 2709 atomic_inc(&global_trace.data[cpu]->disabled);
2712 } 2710 }
2713 if (!cpu_isset(cpu, tracing_cpumask) && 2711 if (!cpumask_test_cpu(cpu, tracing_cpumask) &&
2714 cpu_isset(cpu, tracing_cpumask_new)) { 2712 cpumask_test_cpu(cpu, tracing_cpumask_new)) {
2715 atomic_dec(&global_trace.data[cpu]->disabled); 2713 atomic_dec(&global_trace.data[cpu]->disabled);
2716 } 2714 }
2717 } 2715 }
2718 __raw_spin_unlock(&ftrace_max_lock); 2716 __raw_spin_unlock(&ftrace_max_lock);
2719 local_irq_enable(); 2717 local_irq_enable();
2720 2718
2721 tracing_cpumask = tracing_cpumask_new; 2719 cpumask_copy(tracing_cpumask, tracing_cpumask_new);
2722 2720
2723 mutex_unlock(&tracing_cpumask_update_lock); 2721 mutex_unlock(&tracing_cpumask_update_lock);
2722 free_cpumask_var(tracing_cpumask_new);
2724 2723
2725 return count; 2724 return count;
2726 2725
2727err_unlock: 2726err_unlock:
2728 mutex_unlock(&tracing_cpumask_update_lock); 2727 mutex_unlock(&tracing_cpumask_update_lock);
2728 free_cpumask_var(tracing_cpumask);
2729 2729
2730 return err; 2730 return err;
2731} 2731}
@@ -3114,10 +3114,15 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
3114 if (!iter) 3114 if (!iter)
3115 return -ENOMEM; 3115 return -ENOMEM;
3116 3116
3117 if (!alloc_cpumask_var(&iter->started, GFP_KERNEL)) {
3118 kfree(iter);
3119 return -ENOMEM;
3120 }
3121
3117 mutex_lock(&trace_types_lock); 3122 mutex_lock(&trace_types_lock);
3118 3123
3119 /* trace pipe does not show start of buffer */ 3124 /* trace pipe does not show start of buffer */
3120 cpus_setall(iter->started); 3125 cpumask_setall(iter->started);
3121 3126
3122 iter->tr = &global_trace; 3127 iter->tr = &global_trace;
3123 iter->trace = current_trace; 3128 iter->trace = current_trace;
@@ -3134,6 +3139,7 @@ static int tracing_release_pipe(struct inode *inode, struct file *file)
3134{ 3139{
3135 struct trace_iterator *iter = file->private_data; 3140 struct trace_iterator *iter = file->private_data;
3136 3141
3142 free_cpumask_var(iter->started);
3137 kfree(iter); 3143 kfree(iter);
3138 atomic_dec(&tracing_reader); 3144 atomic_dec(&tracing_reader);
3139 3145
@@ -3752,7 +3758,6 @@ void ftrace_dump(void)
3752 static DEFINE_SPINLOCK(ftrace_dump_lock); 3758 static DEFINE_SPINLOCK(ftrace_dump_lock);
3753 /* use static because iter can be a bit big for the stack */ 3759 /* use static because iter can be a bit big for the stack */
3754 static struct trace_iterator iter; 3760 static struct trace_iterator iter;
3755 static cpumask_t mask;
3756 static int dump_ran; 3761 static int dump_ran;
3757 unsigned long flags; 3762 unsigned long flags;
3758 int cnt = 0, cpu; 3763 int cnt = 0, cpu;
@@ -3786,8 +3791,6 @@ void ftrace_dump(void)
3786 * and then release the locks again. 3791 * and then release the locks again.
3787 */ 3792 */
3788 3793
3789 cpus_clear(mask);
3790
3791 while (!trace_empty(&iter)) { 3794 while (!trace_empty(&iter)) {
3792 3795
3793 if (!cnt) 3796 if (!cnt)
@@ -3823,19 +3826,28 @@ __init static int tracer_alloc_buffers(void)
3823{ 3826{
3824 struct trace_array_cpu *data; 3827 struct trace_array_cpu *data;
3825 int i; 3828 int i;
3829 int ret = -ENOMEM;
3826 3830
3827 /* TODO: make the number of buffers hot pluggable with CPUS */ 3831 if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
3828 tracing_buffer_mask = cpu_possible_map; 3832 goto out;
3833
3834 if (!alloc_cpumask_var(&tracing_cpumask, GFP_KERNEL))
3835 goto out_free_buffer_mask;
3836
3837 cpumask_copy(tracing_buffer_mask, cpu_possible_mask);
3838 cpumask_copy(tracing_cpumask, cpu_all_mask);
3829 3839
3840 /* TODO: make the number of buffers hot pluggable with CPUS */
3830 global_trace.buffer = ring_buffer_alloc(trace_buf_size, 3841 global_trace.buffer = ring_buffer_alloc(trace_buf_size,
3831 TRACE_BUFFER_FLAGS); 3842 TRACE_BUFFER_FLAGS);
3832 if (!global_trace.buffer) { 3843 if (!global_trace.buffer) {
3833 printk(KERN_ERR "tracer: failed to allocate ring buffer!\n"); 3844 printk(KERN_ERR "tracer: failed to allocate ring buffer!\n");
3834 WARN_ON(1); 3845 WARN_ON(1);
3835 return 0; 3846 goto out_free_cpumask;
3836 } 3847 }
3837 global_trace.entries = ring_buffer_size(global_trace.buffer); 3848 global_trace.entries = ring_buffer_size(global_trace.buffer);
3838 3849
3850
3839#ifdef CONFIG_TRACER_MAX_TRACE 3851#ifdef CONFIG_TRACER_MAX_TRACE
3840 max_tr.buffer = ring_buffer_alloc(trace_buf_size, 3852 max_tr.buffer = ring_buffer_alloc(trace_buf_size,
3841 TRACE_BUFFER_FLAGS); 3853 TRACE_BUFFER_FLAGS);
@@ -3843,7 +3855,7 @@ __init static int tracer_alloc_buffers(void)
3843 printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); 3855 printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n");
3844 WARN_ON(1); 3856 WARN_ON(1);
3845 ring_buffer_free(global_trace.buffer); 3857 ring_buffer_free(global_trace.buffer);
3846 return 0; 3858 goto out_free_cpumask;
3847 } 3859 }
3848 max_tr.entries = ring_buffer_size(max_tr.buffer); 3860 max_tr.entries = ring_buffer_size(max_tr.buffer);
3849 WARN_ON(max_tr.entries != global_trace.entries); 3861 WARN_ON(max_tr.entries != global_trace.entries);
@@ -3873,8 +3885,14 @@ __init static int tracer_alloc_buffers(void)
3873 &trace_panic_notifier); 3885 &trace_panic_notifier);
3874 3886
3875 register_die_notifier(&trace_die_notifier); 3887 register_die_notifier(&trace_die_notifier);
3888 ret = 0;
3876 3889
3877 return 0; 3890out_free_cpumask:
3891 free_cpumask_var(tracing_cpumask);
3892out_free_buffer_mask:
3893 free_cpumask_var(tracing_buffer_mask);
3894out:
3895 return ret;
3878} 3896}
3879early_initcall(tracer_alloc_buffers); 3897early_initcall(tracer_alloc_buffers);
3880fs_initcall(tracer_init_debugfs); 3898fs_initcall(tracer_init_debugfs);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index cc7a4f864036..4d3d381bfd95 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -368,7 +368,7 @@ struct trace_iterator {
368 loff_t pos; 368 loff_t pos;
369 long idx; 369 long idx;
370 370
371 cpumask_t started; 371 cpumask_var_t started;
372}; 372};
373 373
374int tracing_is_enabled(void); 374int tracing_is_enabled(void);
diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index 3ccebde28482..366c8c333e13 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -42,7 +42,7 @@ static int boot_trace_init(struct trace_array *tr)
42 int cpu; 42 int cpu;
43 boot_trace = tr; 43 boot_trace = tr;
44 44
45 for_each_cpu_mask(cpu, cpu_possible_map) 45 for_each_cpu(cpu, cpu_possible_mask)
46 tracing_reset(tr, cpu); 46 tracing_reset(tr, cpu);
47 47
48 tracing_sched_switch_assign_trace(tr); 48 tracing_sched_switch_assign_trace(tr);
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 4bf39fcae97a..930c08e5b38e 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -79,7 +79,7 @@ print_graph_cpu(struct trace_seq *s, int cpu)
79 int i; 79 int i;
80 int ret; 80 int ret;
81 int log10_this = log10_cpu(cpu); 81 int log10_this = log10_cpu(cpu);
82 int log10_all = log10_cpu(cpus_weight_nr(cpu_online_map)); 82 int log10_all = log10_cpu(cpumask_weight(cpu_online_mask));
83 83
84 84
85 /* 85 /*
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c
index b6a3e20a49a9..649df22d435f 100644
--- a/kernel/trace/trace_hw_branches.c
+++ b/kernel/trace/trace_hw_branches.c
@@ -46,7 +46,7 @@ static void bts_trace_start(struct trace_array *tr)
46 46
47 tracing_reset_online_cpus(tr); 47 tracing_reset_online_cpus(tr);
48 48
49 for_each_cpu_mask(cpu, cpu_possible_map) 49 for_each_cpu(cpu, cpu_possible_mask)
50 smp_call_function_single(cpu, bts_trace_start_cpu, NULL, 1); 50 smp_call_function_single(cpu, bts_trace_start_cpu, NULL, 1);
51} 51}
52 52
@@ -62,7 +62,7 @@ static void bts_trace_stop(struct trace_array *tr)
62{ 62{
63 int cpu; 63 int cpu;
64 64
65 for_each_cpu_mask(cpu, cpu_possible_map) 65 for_each_cpu(cpu, cpu_possible_mask)
66 smp_call_function_single(cpu, bts_trace_stop_cpu, NULL, 1); 66 smp_call_function_single(cpu, bts_trace_stop_cpu, NULL, 1);
67} 67}
68 68
@@ -172,7 +172,7 @@ static void trace_bts_prepare(struct trace_iterator *iter)
172{ 172{
173 int cpu; 173 int cpu;
174 174
175 for_each_cpu_mask(cpu, cpu_possible_map) 175 for_each_cpu(cpu, cpu_possible_mask)
176 smp_call_function_single(cpu, trace_bts_cpu, iter->tr, 1); 176 smp_call_function_single(cpu, trace_bts_cpu, iter->tr, 1);
177} 177}
178 178
diff --git a/kernel/trace/trace_power.c b/kernel/trace/trace_power.c
index a7172a352f62..7bda248daf55 100644
--- a/kernel/trace/trace_power.c
+++ b/kernel/trace/trace_power.c
@@ -39,7 +39,7 @@ static int power_trace_init(struct trace_array *tr)
39 39
40 trace_power_enabled = 1; 40 trace_power_enabled = 1;
41 41
42 for_each_cpu_mask(cpu, cpu_possible_map) 42 for_each_cpu(cpu, cpu_possible_mask)
43 tracing_reset(tr, cpu); 43 tracing_reset(tr, cpu);
44 return 0; 44 return 0;
45} 45}
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c
index a5779bd975db..eaca5ad803ff 100644
--- a/kernel/trace/trace_sysprof.c
+++ b/kernel/trace/trace_sysprof.c
@@ -196,9 +196,9 @@ static enum hrtimer_restart stack_trace_timer_fn(struct hrtimer *hrtimer)
196 return HRTIMER_RESTART; 196 return HRTIMER_RESTART;
197} 197}
198 198
199static void start_stack_timer(int cpu) 199static void start_stack_timer(void *unused)
200{ 200{
201 struct hrtimer *hrtimer = &per_cpu(stack_trace_hrtimer, cpu); 201 struct hrtimer *hrtimer = &__get_cpu_var(stack_trace_hrtimer);
202 202
203 hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 203 hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
204 hrtimer->function = stack_trace_timer_fn; 204 hrtimer->function = stack_trace_timer_fn;
@@ -208,14 +208,7 @@ static void start_stack_timer(int cpu)
208 208
209static void start_stack_timers(void) 209static void start_stack_timers(void)
210{ 210{
211 cpumask_t saved_mask = current->cpus_allowed; 211 on_each_cpu(start_stack_timer, NULL, 1);
212 int cpu;
213
214 for_each_online_cpu(cpu) {
215 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
216 start_stack_timer(cpu);
217 }
218 set_cpus_allowed_ptr(current, &saved_mask);
219} 212}
220 213
221static void stop_stack_timer(int cpu) 214static void stop_stack_timer(int cpu)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 4952322cba45..2f445833ae37 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -73,7 +73,7 @@ static DEFINE_SPINLOCK(workqueue_lock);
73static LIST_HEAD(workqueues); 73static LIST_HEAD(workqueues);
74 74
75static int singlethread_cpu __read_mostly; 75static int singlethread_cpu __read_mostly;
76static cpumask_t cpu_singlethread_map __read_mostly; 76static const struct cpumask *cpu_singlethread_map __read_mostly;
77/* 77/*
78 * _cpu_down() first removes CPU from cpu_online_map, then CPU_DEAD 78 * _cpu_down() first removes CPU from cpu_online_map, then CPU_DEAD
79 * flushes cwq->worklist. This means that flush_workqueue/wait_on_work 79 * flushes cwq->worklist. This means that flush_workqueue/wait_on_work
@@ -81,7 +81,7 @@ static cpumask_t cpu_singlethread_map __read_mostly;
81 * use cpu_possible_map, the cpumask below is more a documentation 81 * use cpu_possible_map, the cpumask below is more a documentation
82 * than optimization. 82 * than optimization.
83 */ 83 */
84static cpumask_t cpu_populated_map __read_mostly; 84static cpumask_var_t cpu_populated_map __read_mostly;
85 85
86/* If it's single threaded, it isn't in the list of workqueues. */ 86/* If it's single threaded, it isn't in the list of workqueues. */
87static inline int is_wq_single_threaded(struct workqueue_struct *wq) 87static inline int is_wq_single_threaded(struct workqueue_struct *wq)
@@ -89,10 +89,10 @@ static inline int is_wq_single_threaded(struct workqueue_struct *wq)
89 return wq->singlethread; 89 return wq->singlethread;
90} 90}
91 91
92static const cpumask_t *wq_cpu_map(struct workqueue_struct *wq) 92static const struct cpumask *wq_cpu_map(struct workqueue_struct *wq)
93{ 93{
94 return is_wq_single_threaded(wq) 94 return is_wq_single_threaded(wq)
95 ? &cpu_singlethread_map : &cpu_populated_map; 95 ? cpu_singlethread_map : cpu_populated_map;
96} 96}
97 97
98static 98static
@@ -410,7 +410,7 @@ static int flush_cpu_workqueue(struct cpu_workqueue_struct *cwq)
410 */ 410 */
411void flush_workqueue(struct workqueue_struct *wq) 411void flush_workqueue(struct workqueue_struct *wq)
412{ 412{
413 const cpumask_t *cpu_map = wq_cpu_map(wq); 413 const struct cpumask *cpu_map = wq_cpu_map(wq);
414 int cpu; 414 int cpu;
415 415
416 might_sleep(); 416 might_sleep();
@@ -532,7 +532,7 @@ static void wait_on_work(struct work_struct *work)
532{ 532{
533 struct cpu_workqueue_struct *cwq; 533 struct cpu_workqueue_struct *cwq;
534 struct workqueue_struct *wq; 534 struct workqueue_struct *wq;
535 const cpumask_t *cpu_map; 535 const struct cpumask *cpu_map;
536 int cpu; 536 int cpu;
537 537
538 might_sleep(); 538 might_sleep();
@@ -903,7 +903,7 @@ static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq)
903 */ 903 */
904void destroy_workqueue(struct workqueue_struct *wq) 904void destroy_workqueue(struct workqueue_struct *wq)
905{ 905{
906 const cpumask_t *cpu_map = wq_cpu_map(wq); 906 const struct cpumask *cpu_map = wq_cpu_map(wq);
907 int cpu; 907 int cpu;
908 908
909 cpu_maps_update_begin(); 909 cpu_maps_update_begin();
@@ -933,7 +933,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
933 933
934 switch (action) { 934 switch (action) {
935 case CPU_UP_PREPARE: 935 case CPU_UP_PREPARE:
936 cpu_set(cpu, cpu_populated_map); 936 cpumask_set_cpu(cpu, cpu_populated_map);
937 } 937 }
938undo: 938undo:
939 list_for_each_entry(wq, &workqueues, list) { 939 list_for_each_entry(wq, &workqueues, list) {
@@ -964,7 +964,7 @@ undo:
964 switch (action) { 964 switch (action) {
965 case CPU_UP_CANCELED: 965 case CPU_UP_CANCELED:
966 case CPU_POST_DEAD: 966 case CPU_POST_DEAD:
967 cpu_clear(cpu, cpu_populated_map); 967 cpumask_clear_cpu(cpu, cpu_populated_map);
968 } 968 }
969 969
970 return ret; 970 return ret;
@@ -1017,9 +1017,11 @@ EXPORT_SYMBOL_GPL(work_on_cpu);
1017 1017
1018void __init init_workqueues(void) 1018void __init init_workqueues(void)
1019{ 1019{
1020 cpu_populated_map = cpu_online_map; 1020 alloc_cpumask_var(&cpu_populated_map, GFP_KERNEL);
1021 singlethread_cpu = first_cpu(cpu_possible_map); 1021
1022 cpu_singlethread_map = cpumask_of_cpu(singlethread_cpu); 1022 cpumask_copy(cpu_populated_map, cpu_online_mask);
1023 singlethread_cpu = cpumask_first(cpu_possible_mask);
1024 cpu_singlethread_map = cpumask_of(singlethread_cpu);
1023 hotcpu_notifier(workqueue_cpu_callback, 0); 1025 hotcpu_notifier(workqueue_cpu_callback, 0);
1024 keventd_wq = create_workqueue("events"); 1026 keventd_wq = create_workqueue("events");
1025 BUG_ON(!keventd_wq); 1027 BUG_ON(!keventd_wq);
diff --git a/lib/Kconfig b/lib/Kconfig
index 2ba43c4a5b07..03c2c24b9083 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -13,6 +13,10 @@ config GENERIC_FIND_FIRST_BIT
13config GENERIC_FIND_NEXT_BIT 13config GENERIC_FIND_NEXT_BIT
14 bool 14 bool
15 15
16config GENERIC_FIND_LAST_BIT
17 bool
18 default y
19
16config CRC_CCITT 20config CRC_CCITT
17 tristate "CRC-CCITT functions" 21 tristate "CRC-CCITT functions"
18 help 22 help
@@ -166,4 +170,8 @@ config CPUMASK_OFFSTACK
166 them on the stack. This is a bit more expensive, but avoids 170 them on the stack. This is a bit more expensive, but avoids
167 stack overflow. 171 stack overflow.
168 172
173config DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
174 bool "Disable obsolete cpumask functions" if DEBUG_PER_CPU_MAPS
175 depends on EXPERIMENTAL && BROKEN
176
169endmenu 177endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 80fe8a3ec12a..32b0e64ded27 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -37,6 +37,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
37lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o 37lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
38lib-$(CONFIG_GENERIC_FIND_FIRST_BIT) += find_next_bit.o 38lib-$(CONFIG_GENERIC_FIND_FIRST_BIT) += find_next_bit.o
39lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o 39lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
40lib-$(CONFIG_GENERIC_FIND_LAST_BIT) += find_last_bit.o
40obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 41obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
41obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o 42obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
42obj-$(CONFIG_PLIST) += plist.o 43obj-$(CONFIG_PLIST) += plist.o
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 8d03f22c6ced..3389e2440da0 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -76,15 +76,28 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
76 76
77/* These are not inline because of header tangles. */ 77/* These are not inline because of header tangles. */
78#ifdef CONFIG_CPUMASK_OFFSTACK 78#ifdef CONFIG_CPUMASK_OFFSTACK
79bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags) 79/**
80 * alloc_cpumask_var_node - allocate a struct cpumask on a given node
81 * @mask: pointer to cpumask_var_t where the cpumask is returned
82 * @flags: GFP_ flags
83 *
84 * Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
85 * a nop returning a constant 1 (in <linux/cpumask.h>)
86 * Returns TRUE if memory allocation succeeded, FALSE otherwise.
87 *
88 * In addition, mask will be NULL if this fails. Note that gcc is
89 * usually smart enough to know that mask can never be NULL if
90 * CONFIG_CPUMASK_OFFSTACK=n, so does code elimination in that case
91 * too.
92 */
93bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
80{ 94{
81 if (likely(slab_is_available())) 95 if (likely(slab_is_available()))
82 *mask = kmalloc(cpumask_size(), flags); 96 *mask = kmalloc_node(cpumask_size(), flags, node);
83 else { 97 else {
84#ifdef CONFIG_DEBUG_PER_CPU_MAPS 98#ifdef CONFIG_DEBUG_PER_CPU_MAPS
85 printk(KERN_ERR 99 printk(KERN_ERR
86 "=> alloc_cpumask_var: kmalloc not available!\n"); 100 "=> alloc_cpumask_var: kmalloc not available!\n");
87 dump_stack();
88#endif 101#endif
89 *mask = NULL; 102 *mask = NULL;
90 } 103 }
@@ -94,21 +107,64 @@ bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
94 dump_stack(); 107 dump_stack();
95 } 108 }
96#endif 109#endif
110 /* FIXME: Bandaid to save us from old primitives which go to NR_CPUS. */
111 if (*mask) {
112 unsigned int tail;
113 tail = BITS_TO_LONGS(NR_CPUS - nr_cpumask_bits) * sizeof(long);
114 memset(cpumask_bits(*mask) + cpumask_size() - tail,
115 0, tail);
116 }
117
97 return *mask != NULL; 118 return *mask != NULL;
98} 119}
120EXPORT_SYMBOL(alloc_cpumask_var_node);
121
122/**
123 * alloc_cpumask_var - allocate a struct cpumask
124 * @mask: pointer to cpumask_var_t where the cpumask is returned
125 * @flags: GFP_ flags
126 *
127 * Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
128 * a nop returning a constant 1 (in <linux/cpumask.h>).
129 *
130 * See alloc_cpumask_var_node.
131 */
132bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
133{
134 return alloc_cpumask_var_node(mask, flags, numa_node_id());
135}
99EXPORT_SYMBOL(alloc_cpumask_var); 136EXPORT_SYMBOL(alloc_cpumask_var);
100 137
138/**
139 * alloc_bootmem_cpumask_var - allocate a struct cpumask from the bootmem arena.
140 * @mask: pointer to cpumask_var_t where the cpumask is returned
141 *
142 * Only defined when CONFIG_CPUMASK_OFFSTACK=y, otherwise is
143 * a nop (in <linux/cpumask.h>).
144 * Either returns an allocated (zero-filled) cpumask, or causes the
145 * system to panic.
146 */
101void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask) 147void __init alloc_bootmem_cpumask_var(cpumask_var_t *mask)
102{ 148{
103 *mask = alloc_bootmem(cpumask_size()); 149 *mask = alloc_bootmem(cpumask_size());
104} 150}
105 151
152/**
153 * free_cpumask_var - frees memory allocated for a struct cpumask.
154 * @mask: cpumask to free
155 *
156 * This is safe on a NULL mask.
157 */
106void free_cpumask_var(cpumask_var_t mask) 158void free_cpumask_var(cpumask_var_t mask)
107{ 159{
108 kfree(mask); 160 kfree(mask);
109} 161}
110EXPORT_SYMBOL(free_cpumask_var); 162EXPORT_SYMBOL(free_cpumask_var);
111 163
164/**
165 * free_bootmem_cpumask_var - frees result of alloc_bootmem_cpumask_var
166 * @mask: cpumask to free
167 */
112void __init free_bootmem_cpumask_var(cpumask_var_t mask) 168void __init free_bootmem_cpumask_var(cpumask_var_t mask)
113{ 169{
114 free_bootmem((unsigned long)mask, cpumask_size()); 170 free_bootmem((unsigned long)mask, cpumask_size());
diff --git a/lib/find_last_bit.c b/lib/find_last_bit.c
new file mode 100644
index 000000000000..5d202e36bdd8
--- /dev/null
+++ b/lib/find_last_bit.c
@@ -0,0 +1,45 @@
1/* find_last_bit.c: fallback find next bit implementation
2 *
3 * Copyright (C) 2008 IBM Corporation
4 * Written by Rusty Russell <rusty@rustcorp.com.au>
5 * (Inspired by David Howell's find_next_bit implementation)
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/bitops.h>
14#include <linux/module.h>
15#include <asm/types.h>
16#include <asm/byteorder.h>
17
18unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
19{
20 unsigned long words;
21 unsigned long tmp;
22
23 /* Start at final word. */
24 words = size / BITS_PER_LONG;
25
26 /* Partial final word? */
27 if (size & (BITS_PER_LONG-1)) {
28 tmp = (addr[words] & (~0UL >> (BITS_PER_LONG
29 - (size & (BITS_PER_LONG-1)))));
30 if (tmp)
31 goto found;
32 }
33
34 while (words) {
35 tmp = addr[--words];
36 if (tmp) {
37found:
38 return words * BITS_PER_LONG + __fls(tmp);
39 }
40 }
41
42 /* Not found */
43 return size;
44}
45EXPORT_SYMBOL(find_last_bit);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index fa2dc4e5f9ba..7f5e21b9c16b 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -23,7 +23,6 @@
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/swiotlb.h> 24#include <linux/swiotlb.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/swiotlb.h>
27#include <linux/types.h> 26#include <linux/types.h>
28#include <linux/ctype.h> 27#include <linux/ctype.h>
29#include <linux/highmem.h> 28#include <linux/highmem.h>
@@ -116,7 +115,7 @@ setup_io_tlb_npages(char *str)
116__setup("swiotlb=", setup_io_tlb_npages); 115__setup("swiotlb=", setup_io_tlb_npages);
117/* make io_tlb_overflow tunable too? */ 116/* make io_tlb_overflow tunable too? */
118 117
119void * __weak swiotlb_alloc_boot(size_t size, unsigned long nslabs) 118void * __weak __init swiotlb_alloc_boot(size_t size, unsigned long nslabs)
120{ 119{
121 return alloc_bootmem_low_pages(size); 120 return alloc_bootmem_low_pages(size);
122} 121}
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3b777025d876..98d632277ca8 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -661,6 +661,9 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
661 */ 661 */
662static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) 662static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags)
663{ 663{
664 if (!ptr)
665 return string(buf, end, "(null)", field_width, precision, flags);
666
664 switch (*fmt) { 667 switch (*fmt) {
665 case 'F': 668 case 'F':
666 ptr = dereference_function_descriptor(ptr); 669 ptr = dereference_function_descriptor(ptr);
diff --git a/mm/filemap.c b/mm/filemap.c
index f3e5f8944d17..f5769b4dc075 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1766,7 +1766,7 @@ int should_remove_suid(struct dentry *dentry)
1766 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1766 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
1767 kill |= ATTR_KILL_SGID; 1767 kill |= ATTR_KILL_SGID;
1768 1768
1769 if (unlikely(kill && !capable(CAP_FSETID))) 1769 if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode)))
1770 return kill; 1770 return kill;
1771 1771
1772 return 0; 1772 return 0;
@@ -2140,19 +2140,24 @@ EXPORT_SYMBOL(generic_file_direct_write);
2140 * Find or create a page at the given pagecache position. Return the locked 2140 * Find or create a page at the given pagecache position. Return the locked
2141 * page. This function is specifically for buffered writes. 2141 * page. This function is specifically for buffered writes.
2142 */ 2142 */
2143struct page *__grab_cache_page(struct address_space *mapping, pgoff_t index) 2143struct page *grab_cache_page_write_begin(struct address_space *mapping,
2144 pgoff_t index, unsigned flags)
2144{ 2145{
2145 int status; 2146 int status;
2146 struct page *page; 2147 struct page *page;
2148 gfp_t gfp_notmask = 0;
2149 if (flags & AOP_FLAG_NOFS)
2150 gfp_notmask = __GFP_FS;
2147repeat: 2151repeat:
2148 page = find_lock_page(mapping, index); 2152 page = find_lock_page(mapping, index);
2149 if (likely(page)) 2153 if (likely(page))
2150 return page; 2154 return page;
2151 2155
2152 page = page_cache_alloc(mapping); 2156 page = __page_cache_alloc(mapping_gfp_mask(mapping) & ~gfp_notmask);
2153 if (!page) 2157 if (!page)
2154 return NULL; 2158 return NULL;
2155 status = add_to_page_cache_lru(page, mapping, index, GFP_KERNEL); 2159 status = add_to_page_cache_lru(page, mapping, index,
2160 GFP_KERNEL & ~gfp_notmask);
2156 if (unlikely(status)) { 2161 if (unlikely(status)) {
2157 page_cache_release(page); 2162 page_cache_release(page);
2158 if (status == -EEXIST) 2163 if (status == -EEXIST)
@@ -2161,7 +2166,7 @@ repeat:
2161 } 2166 }
2162 return page; 2167 return page;
2163} 2168}
2164EXPORT_SYMBOL(__grab_cache_page); 2169EXPORT_SYMBOL(grab_cache_page_write_begin);
2165 2170
2166static ssize_t generic_perform_write(struct file *file, 2171static ssize_t generic_perform_write(struct file *file,
2167 struct iov_iter *i, loff_t pos) 2172 struct iov_iter *i, loff_t pos)
diff --git a/mm/memory.c b/mm/memory.c
index 0a2010a9518c..7b9db658aca2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2266,7 +2266,7 @@ int vmtruncate(struct inode * inode, loff_t offset)
2266 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); 2266 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
2267 } 2267 }
2268 2268
2269 if (inode->i_op && inode->i_op->truncate) 2269 if (inode->i_op->truncate)
2270 inode->i_op->truncate(inode); 2270 inode->i_op->truncate(inode);
2271 return 0; 2271 return 0;
2272 2272
@@ -2286,7 +2286,7 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
2286 * a way to truncate a range of blocks (punch a hole) - 2286 * a way to truncate a range of blocks (punch a hole) -
2287 * we should return failure right now. 2287 * we should return failure right now.
2288 */ 2288 */
2289 if (!inode->i_op || !inode->i_op->truncate_range) 2289 if (!inode->i_op->truncate_range)
2290 return -ENOSYS; 2290 return -ENOSYS;
2291 2291
2292 mutex_lock(&inode->i_mutex); 2292 mutex_lock(&inode->i_mutex);
diff --git a/mm/mmap.c b/mm/mmap.c
index d4855a682ab6..2c778fcfd9bd 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Written by obz. 4 * Written by obz.
5 * 5 *
6 * Address space accounting code <alan@redhat.com> 6 * Address space accounting code <alan@lxorguk.ukuu.org.uk>
7 */ 7 */
8 8
9#include <linux/slab.h> 9#include <linux/slab.h>
diff --git a/mm/mprotect.c b/mm/mprotect.c
index fded06f923f4..cfb4c4852062 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -4,7 +4,7 @@
4 * (C) Copyright 1994 Linus Torvalds 4 * (C) Copyright 1994 Linus Torvalds
5 * (C) Copyright 2002 Christoph Hellwig 5 * (C) Copyright 2002 Christoph Hellwig
6 * 6 *
7 * Address space accounting code <alan@redhat.com> 7 * Address space accounting code <alan@lxorguk.ukuu.org.uk>
8 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved 8 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved
9 */ 9 */
10 10
diff --git a/mm/mremap.c b/mm/mremap.c
index 58a2908f42f5..646de959aa58 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * (C) Copyright 1996 Linus Torvalds 4 * (C) Copyright 1996 Linus Torvalds
5 * 5 *
6 * Address space accounting code <alan@redhat.com> 6 * Address space accounting code <alan@lxorguk.ukuu.org.uk>
7 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved 7 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved
8 */ 8 */
9 9
diff --git a/mm/msync.c b/mm/msync.c
index 144a7570535d..07dae08cf31c 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -82,7 +82,7 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
82 (vma->vm_flags & VM_SHARED)) { 82 (vma->vm_flags & VM_SHARED)) {
83 get_file(file); 83 get_file(file);
84 up_read(&mm->mmap_sem); 84 up_read(&mm->mmap_sem);
85 error = do_fsync(file, 0); 85 error = vfs_fsync(file, file->f_path.dentry, 0);
86 fput(file); 86 fput(file);
87 if (error || start >= end) 87 if (error || start >= end)
88 goto out; 88 goto out;
diff --git a/mm/nommu.c b/mm/nommu.c
index 7695dc850785..1c28ea3a4e9c 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -86,7 +86,7 @@ do_expand:
86 i_size_write(inode, offset); 86 i_size_write(inode, offset);
87 87
88out_truncate: 88out_truncate:
89 if (inode->i_op && inode->i_op->truncate) 89 if (inode->i_op->truncate)
90 inode->i_op->truncate(inode); 90 inode->i_op->truncate(inode);
91 return 0; 91 return 0;
92out_sig: 92out_sig:
diff --git a/mm/pdflush.c b/mm/pdflush.c
index a0a14c4d5072..15de509b68fd 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -172,7 +172,16 @@ static int __pdflush(struct pdflush_work *my_work)
172static int pdflush(void *dummy) 172static int pdflush(void *dummy)
173{ 173{
174 struct pdflush_work my_work; 174 struct pdflush_work my_work;
175 cpumask_t cpus_allowed; 175 cpumask_var_t cpus_allowed;
176
177 /*
178 * Since the caller doesn't even check kthread_run() worked, let's not
179 * freak out too much if this fails.
180 */
181 if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) {
182 printk(KERN_WARNING "pdflush failed to allocate cpumask\n");
183 return 0;
184 }
176 185
177 /* 186 /*
178 * pdflush can spend a lot of time doing encryption via dm-crypt. We 187 * pdflush can spend a lot of time doing encryption via dm-crypt. We
@@ -187,8 +196,9 @@ static int pdflush(void *dummy)
187 * This is needed as pdflush's are dynamically created and destroyed. 196 * This is needed as pdflush's are dynamically created and destroyed.
188 * The boottime pdflush's are easily placed w/o these 2 lines. 197 * The boottime pdflush's are easily placed w/o these 2 lines.
189 */ 198 */
190 cpuset_cpus_allowed(current, &cpus_allowed); 199 cpuset_cpus_allowed(current, cpus_allowed);
191 set_cpus_allowed_ptr(current, &cpus_allowed); 200 set_cpus_allowed_ptr(current, cpus_allowed);
201 free_cpumask_var(cpus_allowed);
192 202
193 return __pdflush(&my_work); 203 return __pdflush(&my_work);
194} 204}
diff --git a/mm/slab.c b/mm/slab.c
index f97e564bdf11..ddc41f337d58 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2157,7 +2157,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2157 2157
2158 /* 2158 /*
2159 * We use cache_chain_mutex to ensure a consistent view of 2159 * We use cache_chain_mutex to ensure a consistent view of
2160 * cpu_online_map as well. Please see cpuup_callback 2160 * cpu_online_mask as well. Please see cpuup_callback
2161 */ 2161 */
2162 get_online_cpus(); 2162 get_online_cpus();
2163 mutex_lock(&cache_chain_mutex); 2163 mutex_lock(&cache_chain_mutex);
diff --git a/mm/slub.c b/mm/slub.c
index 0d861c3154b6..f0e2892fe403 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1970,7 +1970,7 @@ static DEFINE_PER_CPU(struct kmem_cache_cpu,
1970 kmem_cache_cpu)[NR_KMEM_CACHE_CPU]; 1970 kmem_cache_cpu)[NR_KMEM_CACHE_CPU];
1971 1971
1972static DEFINE_PER_CPU(struct kmem_cache_cpu *, kmem_cache_cpu_free); 1972static DEFINE_PER_CPU(struct kmem_cache_cpu *, kmem_cache_cpu_free);
1973static cpumask_t kmem_cach_cpu_free_init_once = CPU_MASK_NONE; 1973static DECLARE_BITMAP(kmem_cach_cpu_free_init_once, CONFIG_NR_CPUS);
1974 1974
1975static struct kmem_cache_cpu *alloc_kmem_cache_cpu(struct kmem_cache *s, 1975static struct kmem_cache_cpu *alloc_kmem_cache_cpu(struct kmem_cache *s,
1976 int cpu, gfp_t flags) 1976 int cpu, gfp_t flags)
@@ -2045,13 +2045,13 @@ static void init_alloc_cpu_cpu(int cpu)
2045{ 2045{
2046 int i; 2046 int i;
2047 2047
2048 if (cpu_isset(cpu, kmem_cach_cpu_free_init_once)) 2048 if (cpumask_test_cpu(cpu, to_cpumask(kmem_cach_cpu_free_init_once)))
2049 return; 2049 return;
2050 2050
2051 for (i = NR_KMEM_CACHE_CPU - 1; i >= 0; i--) 2051 for (i = NR_KMEM_CACHE_CPU - 1; i >= 0; i--)
2052 free_kmem_cache_cpu(&per_cpu(kmem_cache_cpu, cpu)[i], cpu); 2052 free_kmem_cache_cpu(&per_cpu(kmem_cache_cpu, cpu)[i], cpu);
2053 2053
2054 cpu_set(cpu, kmem_cach_cpu_free_init_once); 2054 cpumask_set_cpu(cpu, to_cpumask(kmem_cach_cpu_free_init_once));
2055} 2055}
2056 2056
2057static void __init init_alloc_cpu(void) 2057static void __init init_alloc_cpu(void)
@@ -3451,7 +3451,7 @@ struct location {
3451 long max_time; 3451 long max_time;
3452 long min_pid; 3452 long min_pid;
3453 long max_pid; 3453 long max_pid;
3454 cpumask_t cpus; 3454 DECLARE_BITMAP(cpus, NR_CPUS);
3455 nodemask_t nodes; 3455 nodemask_t nodes;
3456}; 3456};
3457 3457
@@ -3526,7 +3526,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
3526 if (track->pid > l->max_pid) 3526 if (track->pid > l->max_pid)
3527 l->max_pid = track->pid; 3527 l->max_pid = track->pid;
3528 3528
3529 cpu_set(track->cpu, l->cpus); 3529 cpumask_set_cpu(track->cpu,
3530 to_cpumask(l->cpus));
3530 } 3531 }
3531 node_set(page_to_nid(virt_to_page(track)), l->nodes); 3532 node_set(page_to_nid(virt_to_page(track)), l->nodes);
3532 return 1; 3533 return 1;
@@ -3556,8 +3557,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
3556 l->max_time = age; 3557 l->max_time = age;
3557 l->min_pid = track->pid; 3558 l->min_pid = track->pid;
3558 l->max_pid = track->pid; 3559 l->max_pid = track->pid;
3559 cpus_clear(l->cpus); 3560 cpumask_clear(to_cpumask(l->cpus));
3560 cpu_set(track->cpu, l->cpus); 3561 cpumask_set_cpu(track->cpu, to_cpumask(l->cpus));
3561 nodes_clear(l->nodes); 3562 nodes_clear(l->nodes);
3562 node_set(page_to_nid(virt_to_page(track)), l->nodes); 3563 node_set(page_to_nid(virt_to_page(track)), l->nodes);
3563 return 1; 3564 return 1;
@@ -3638,11 +3639,12 @@ static int list_locations(struct kmem_cache *s, char *buf,
3638 len += sprintf(buf + len, " pid=%ld", 3639 len += sprintf(buf + len, " pid=%ld",
3639 l->min_pid); 3640 l->min_pid);
3640 3641
3641 if (num_online_cpus() > 1 && !cpus_empty(l->cpus) && 3642 if (num_online_cpus() > 1 &&
3643 !cpumask_empty(to_cpumask(l->cpus)) &&
3642 len < PAGE_SIZE - 60) { 3644 len < PAGE_SIZE - 60) {
3643 len += sprintf(buf + len, " cpus="); 3645 len += sprintf(buf + len, " cpus=");
3644 len += cpulist_scnprintf(buf + len, PAGE_SIZE - len - 50, 3646 len += cpulist_scnprintf(buf + len, PAGE_SIZE - len - 50,
3645 &l->cpus); 3647 to_cpumask(l->cpus));
3646 } 3648 }
3647 3649
3648 if (num_online_nodes() > 1 && !nodes_empty(l->nodes) && 3650 if (num_online_nodes() > 1 && !nodes_empty(l->nodes) &&
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1ddb77ba3995..7465f22fec0c 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -151,11 +151,12 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
151 * 151 *
152 * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N] 152 * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N]
153 */ 153 */
154static int vmap_page_range(unsigned long addr, unsigned long end, 154static int vmap_page_range(unsigned long start, unsigned long end,
155 pgprot_t prot, struct page **pages) 155 pgprot_t prot, struct page **pages)
156{ 156{
157 pgd_t *pgd; 157 pgd_t *pgd;
158 unsigned long next; 158 unsigned long next;
159 unsigned long addr = start;
159 int err = 0; 160 int err = 0;
160 int nr = 0; 161 int nr = 0;
161 162
@@ -167,7 +168,7 @@ static int vmap_page_range(unsigned long addr, unsigned long end,
167 if (err) 168 if (err)
168 break; 169 break;
169 } while (pgd++, addr = next, addr != end); 170 } while (pgd++, addr = next, addr != end);
170 flush_cache_vmap(addr, end); 171 flush_cache_vmap(start, end);
171 172
172 if (unlikely(err)) 173 if (unlikely(err))
173 return err; 174 return err;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 62e7f62fb559..d196f46c8808 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1902,7 +1902,7 @@ static int kswapd(void *p)
1902 }; 1902 };
1903 node_to_cpumask_ptr(cpumask, pgdat->node_id); 1903 node_to_cpumask_ptr(cpumask, pgdat->node_id);
1904 1904
1905 if (!cpus_empty(*cpumask)) 1905 if (!cpumask_empty(cpumask))
1906 set_cpus_allowed_ptr(tsk, cpumask); 1906 set_cpus_allowed_ptr(tsk, cpumask);
1907 current->reclaim_state = &reclaim_state; 1907 current->reclaim_state = &reclaim_state;
1908 1908
@@ -2141,7 +2141,7 @@ static int __devinit cpu_callback(struct notifier_block *nfb,
2141 pg_data_t *pgdat = NODE_DATA(nid); 2141 pg_data_t *pgdat = NODE_DATA(nid);
2142 node_to_cpumask_ptr(mask, pgdat->node_id); 2142 node_to_cpumask_ptr(mask, pgdat->node_id);
2143 2143
2144 if (any_online_cpu(*mask) < nr_cpu_ids) 2144 if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids)
2145 /* One of our CPUs online: restore mask */ 2145 /* One of our CPUs online: restore mask */
2146 set_cpus_allowed_ptr(pgdat->kswapd, mask); 2146 set_cpus_allowed_ptr(pgdat->kswapd, mask);
2147 } 2147 }
diff --git a/mm/vmstat.c b/mm/vmstat.c
index c3ccfda23adc..91149746bb8d 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -20,7 +20,7 @@
20DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; 20DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
21EXPORT_PER_CPU_SYMBOL(vm_event_states); 21EXPORT_PER_CPU_SYMBOL(vm_event_states);
22 22
23static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask) 23static void sum_vm_events(unsigned long *ret, const struct cpumask *cpumask)
24{ 24{
25 int cpu; 25 int cpu;
26 int i; 26 int i;
@@ -43,7 +43,7 @@ static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask)
43void all_vm_events(unsigned long *ret) 43void all_vm_events(unsigned long *ret)
44{ 44{
45 get_online_cpus(); 45 get_online_cpus();
46 sum_vm_events(ret, &cpu_online_map); 46 sum_vm_events(ret, cpu_online_mask);
47 put_online_cpus(); 47 put_online_cpus();
48} 48}
49EXPORT_SYMBOL_GPL(all_vm_events); 49EXPORT_SYMBOL_GPL(all_vm_events);
diff --git a/net/can/bcm.c b/net/can/bcm.c
index da0d426c0ce4..6248ae2502c7 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -70,7 +70,7 @@
70 70
71#define CAN_BCM_VERSION CAN_VERSION 71#define CAN_BCM_VERSION CAN_VERSION
72static __initdata const char banner[] = KERN_INFO 72static __initdata const char banner[] = KERN_INFO
73 "can: broadcast manager protocol (rev " CAN_BCM_VERSION ")\n"; 73 "can: broadcast manager protocol (rev " CAN_BCM_VERSION " t)\n";
74 74
75MODULE_DESCRIPTION("PF_CAN broadcast manager protocol"); 75MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
76MODULE_LICENSE("Dual BSD/GPL"); 76MODULE_LICENSE("Dual BSD/GPL");
@@ -90,6 +90,7 @@ struct bcm_op {
90 unsigned long frames_abs, frames_filtered; 90 unsigned long frames_abs, frames_filtered;
91 struct timeval ival1, ival2; 91 struct timeval ival1, ival2;
92 struct hrtimer timer, thrtimer; 92 struct hrtimer timer, thrtimer;
93 struct tasklet_struct tsklet, thrtsklet;
93 ktime_t rx_stamp, kt_ival1, kt_ival2, kt_lastmsg; 94 ktime_t rx_stamp, kt_ival1, kt_ival2, kt_lastmsg;
94 int rx_ifindex; 95 int rx_ifindex;
95 int count; 96 int count;
@@ -341,6 +342,23 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
341 } 342 }
342} 343}
343 344
345static void bcm_tx_timeout_tsklet(unsigned long data)
346{
347 struct bcm_op *op = (struct bcm_op *)data;
348 struct bcm_msg_head msg_head;
349
350 /* create notification to user */
351 msg_head.opcode = TX_EXPIRED;
352 msg_head.flags = op->flags;
353 msg_head.count = op->count;
354 msg_head.ival1 = op->ival1;
355 msg_head.ival2 = op->ival2;
356 msg_head.can_id = op->can_id;
357 msg_head.nframes = 0;
358
359 bcm_send_to_user(op, &msg_head, NULL, 0);
360}
361
344/* 362/*
345 * bcm_tx_timeout_handler - performes cyclic CAN frame transmissions 363 * bcm_tx_timeout_handler - performes cyclic CAN frame transmissions
346 */ 364 */
@@ -352,20 +370,8 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer)
352 if (op->kt_ival1.tv64 && (op->count > 0)) { 370 if (op->kt_ival1.tv64 && (op->count > 0)) {
353 371
354 op->count--; 372 op->count--;
355 if (!op->count && (op->flags & TX_COUNTEVT)) { 373 if (!op->count && (op->flags & TX_COUNTEVT))
356 struct bcm_msg_head msg_head; 374 tasklet_schedule(&op->tsklet);
357
358 /* create notification to user */
359 msg_head.opcode = TX_EXPIRED;
360 msg_head.flags = op->flags;
361 msg_head.count = op->count;
362 msg_head.ival1 = op->ival1;
363 msg_head.ival2 = op->ival2;
364 msg_head.can_id = op->can_id;
365 msg_head.nframes = 0;
366
367 bcm_send_to_user(op, &msg_head, NULL, 0);
368 }
369 } 375 }
370 376
371 if (op->kt_ival1.tv64 && (op->count > 0)) { 377 if (op->kt_ival1.tv64 && (op->count > 0)) {
@@ -402,6 +408,9 @@ static void bcm_rx_changed(struct bcm_op *op, struct can_frame *data)
402 if (op->frames_filtered > ULONG_MAX/100) 408 if (op->frames_filtered > ULONG_MAX/100)
403 op->frames_filtered = op->frames_abs = 0; 409 op->frames_filtered = op->frames_abs = 0;
404 410
411 /* this element is not throttled anymore */
412 data->can_dlc &= (BCM_CAN_DLC_MASK|RX_RECV);
413
405 head.opcode = RX_CHANGED; 414 head.opcode = RX_CHANGED;
406 head.flags = op->flags; 415 head.flags = op->flags;
407 head.count = op->count; 416 head.count = op->count;
@@ -420,37 +429,32 @@ static void bcm_rx_changed(struct bcm_op *op, struct can_frame *data)
420 */ 429 */
421static void bcm_rx_update_and_send(struct bcm_op *op, 430static void bcm_rx_update_and_send(struct bcm_op *op,
422 struct can_frame *lastdata, 431 struct can_frame *lastdata,
423 struct can_frame *rxdata) 432 const struct can_frame *rxdata)
424{ 433{
425 memcpy(lastdata, rxdata, CFSIZ); 434 memcpy(lastdata, rxdata, CFSIZ);
426 435
427 /* mark as used */ 436 /* mark as used and throttled by default */
428 lastdata->can_dlc |= RX_RECV; 437 lastdata->can_dlc |= (RX_RECV|RX_THR);
429 438
430 /* throtteling mode inactive OR data update already on the run ? */ 439 /* throtteling mode inactive ? */
431 if (!op->kt_ival2.tv64 || hrtimer_callback_running(&op->thrtimer)) { 440 if (!op->kt_ival2.tv64) {
432 /* send RX_CHANGED to the user immediately */ 441 /* send RX_CHANGED to the user immediately */
433 bcm_rx_changed(op, rxdata); 442 bcm_rx_changed(op, lastdata);
434 return; 443 return;
435 } 444 }
436 445
437 if (hrtimer_active(&op->thrtimer)) { 446 /* with active throttling timer we are just done here */
438 /* mark as 'throttled' */ 447 if (hrtimer_active(&op->thrtimer))
439 lastdata->can_dlc |= RX_THR;
440 return; 448 return;
441 }
442 449
443 if (!op->kt_lastmsg.tv64) { 450 /* first receiption with enabled throttling mode */
444 /* send first RX_CHANGED to the user immediately */ 451 if (!op->kt_lastmsg.tv64)
445 bcm_rx_changed(op, rxdata); 452 goto rx_changed_settime;
446 op->kt_lastmsg = ktime_get();
447 return;
448 }
449 453
454 /* got a second frame inside a potential throttle period? */
450 if (ktime_us_delta(ktime_get(), op->kt_lastmsg) < 455 if (ktime_us_delta(ktime_get(), op->kt_lastmsg) <
451 ktime_to_us(op->kt_ival2)) { 456 ktime_to_us(op->kt_ival2)) {
452 /* mark as 'throttled' and start timer */ 457 /* do not send the saved data - only start throttle timer */
453 lastdata->can_dlc |= RX_THR;
454 hrtimer_start(&op->thrtimer, 458 hrtimer_start(&op->thrtimer,
455 ktime_add(op->kt_lastmsg, op->kt_ival2), 459 ktime_add(op->kt_lastmsg, op->kt_ival2),
456 HRTIMER_MODE_ABS); 460 HRTIMER_MODE_ABS);
@@ -458,7 +462,8 @@ static void bcm_rx_update_and_send(struct bcm_op *op,
458 } 462 }
459 463
460 /* the gap was that big, that throttling was not needed here */ 464 /* the gap was that big, that throttling was not needed here */
461 bcm_rx_changed(op, rxdata); 465rx_changed_settime:
466 bcm_rx_changed(op, lastdata);
462 op->kt_lastmsg = ktime_get(); 467 op->kt_lastmsg = ktime_get();
463} 468}
464 469
@@ -467,7 +472,7 @@ static void bcm_rx_update_and_send(struct bcm_op *op,
467 * received data stored in op->last_frames[] 472 * received data stored in op->last_frames[]
468 */ 473 */
469static void bcm_rx_cmp_to_index(struct bcm_op *op, int index, 474static void bcm_rx_cmp_to_index(struct bcm_op *op, int index,
470 struct can_frame *rxdata) 475 const struct can_frame *rxdata)
471{ 476{
472 /* 477 /*
473 * no one uses the MSBs of can_dlc for comparation, 478 * no one uses the MSBs of can_dlc for comparation,
@@ -511,14 +516,12 @@ static void bcm_rx_starttimer(struct bcm_op *op)
511 hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL); 516 hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL);
512} 517}
513 518
514/* 519static void bcm_rx_timeout_tsklet(unsigned long data)
515 * bcm_rx_timeout_handler - when the (cyclic) CAN frame receiption timed out
516 */
517static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
518{ 520{
519 struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer); 521 struct bcm_op *op = (struct bcm_op *)data;
520 struct bcm_msg_head msg_head; 522 struct bcm_msg_head msg_head;
521 523
524 /* create notification to user */
522 msg_head.opcode = RX_TIMEOUT; 525 msg_head.opcode = RX_TIMEOUT;
523 msg_head.flags = op->flags; 526 msg_head.flags = op->flags;
524 msg_head.count = op->count; 527 msg_head.count = op->count;
@@ -528,6 +531,17 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
528 msg_head.nframes = 0; 531 msg_head.nframes = 0;
529 532
530 bcm_send_to_user(op, &msg_head, NULL, 0); 533 bcm_send_to_user(op, &msg_head, NULL, 0);
534}
535
536/*
537 * bcm_rx_timeout_handler - when the (cyclic) CAN frame receiption timed out
538 */
539static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
540{
541 struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer);
542
543 /* schedule before NET_RX_SOFTIRQ */
544 tasklet_hi_schedule(&op->tsklet);
531 545
532 /* no restart of the timer is done here! */ 546 /* no restart of the timer is done here! */
533 547
@@ -541,9 +555,25 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer)
541} 555}
542 556
543/* 557/*
558 * bcm_rx_do_flush - helper for bcm_rx_thr_flush
559 */
560static inline int bcm_rx_do_flush(struct bcm_op *op, int update, int index)
561{
562 if ((op->last_frames) && (op->last_frames[index].can_dlc & RX_THR)) {
563 if (update)
564 bcm_rx_changed(op, &op->last_frames[index]);
565 return 1;
566 }
567 return 0;
568}
569
570/*
544 * bcm_rx_thr_flush - Check for throttled data and send it to the userspace 571 * bcm_rx_thr_flush - Check for throttled data and send it to the userspace
572 *
573 * update == 0 : just check if throttled data is available (any irq context)
574 * update == 1 : check and send throttled data to userspace (soft_irq context)
545 */ 575 */
546static int bcm_rx_thr_flush(struct bcm_op *op) 576static int bcm_rx_thr_flush(struct bcm_op *op, int update)
547{ 577{
548 int updated = 0; 578 int updated = 0;
549 579
@@ -551,27 +581,25 @@ static int bcm_rx_thr_flush(struct bcm_op *op)
551 int i; 581 int i;
552 582
553 /* for MUX filter we start at index 1 */ 583 /* for MUX filter we start at index 1 */
554 for (i = 1; i < op->nframes; i++) { 584 for (i = 1; i < op->nframes; i++)
555 if ((op->last_frames) && 585 updated += bcm_rx_do_flush(op, update, i);
556 (op->last_frames[i].can_dlc & RX_THR)) {
557 op->last_frames[i].can_dlc &= ~RX_THR;
558 bcm_rx_changed(op, &op->last_frames[i]);
559 updated++;
560 }
561 }
562 586
563 } else { 587 } else {
564 /* for RX_FILTER_ID and simple filter */ 588 /* for RX_FILTER_ID and simple filter */
565 if (op->last_frames && (op->last_frames[0].can_dlc & RX_THR)) { 589 updated += bcm_rx_do_flush(op, update, 0);
566 op->last_frames[0].can_dlc &= ~RX_THR;
567 bcm_rx_changed(op, &op->last_frames[0]);
568 updated++;
569 }
570 } 590 }
571 591
572 return updated; 592 return updated;
573} 593}
574 594
595static void bcm_rx_thr_tsklet(unsigned long data)
596{
597 struct bcm_op *op = (struct bcm_op *)data;
598
599 /* push the changed data to the userspace */
600 bcm_rx_thr_flush(op, 1);
601}
602
575/* 603/*
576 * bcm_rx_thr_handler - the time for blocked content updates is over now: 604 * bcm_rx_thr_handler - the time for blocked content updates is over now:
577 * Check for throttled data and send it to the userspace 605 * Check for throttled data and send it to the userspace
@@ -580,7 +608,9 @@ static enum hrtimer_restart bcm_rx_thr_handler(struct hrtimer *hrtimer)
580{ 608{
581 struct bcm_op *op = container_of(hrtimer, struct bcm_op, thrtimer); 609 struct bcm_op *op = container_of(hrtimer, struct bcm_op, thrtimer);
582 610
583 if (bcm_rx_thr_flush(op)) { 611 tasklet_schedule(&op->thrtsklet);
612
613 if (bcm_rx_thr_flush(op, 0)) {
584 hrtimer_forward(hrtimer, ktime_get(), op->kt_ival2); 614 hrtimer_forward(hrtimer, ktime_get(), op->kt_ival2);
585 return HRTIMER_RESTART; 615 return HRTIMER_RESTART;
586 } else { 616 } else {
@@ -596,48 +626,38 @@ static enum hrtimer_restart bcm_rx_thr_handler(struct hrtimer *hrtimer)
596static void bcm_rx_handler(struct sk_buff *skb, void *data) 626static void bcm_rx_handler(struct sk_buff *skb, void *data)
597{ 627{
598 struct bcm_op *op = (struct bcm_op *)data; 628 struct bcm_op *op = (struct bcm_op *)data;
599 struct can_frame rxframe; 629 const struct can_frame *rxframe = (struct can_frame *)skb->data;
600 int i; 630 int i;
601 631
602 /* disable timeout */ 632 /* disable timeout */
603 hrtimer_cancel(&op->timer); 633 hrtimer_cancel(&op->timer);
604 634
605 if (skb->len == sizeof(rxframe)) { 635 if (op->can_id != rxframe->can_id)
606 memcpy(&rxframe, skb->data, sizeof(rxframe)); 636 goto rx_freeskb;
607 /* save rx timestamp */
608 op->rx_stamp = skb->tstamp;
609 /* save originator for recvfrom() */
610 op->rx_ifindex = skb->dev->ifindex;
611 /* update statistics */
612 op->frames_abs++;
613 kfree_skb(skb);
614 637
615 } else { 638 /* save rx timestamp */
616 kfree_skb(skb); 639 op->rx_stamp = skb->tstamp;
617 return; 640 /* save originator for recvfrom() */
618 } 641 op->rx_ifindex = skb->dev->ifindex;
619 642 /* update statistics */
620 if (op->can_id != rxframe.can_id) 643 op->frames_abs++;
621 return;
622 644
623 if (op->flags & RX_RTR_FRAME) { 645 if (op->flags & RX_RTR_FRAME) {
624 /* send reply for RTR-request (placed in op->frames[0]) */ 646 /* send reply for RTR-request (placed in op->frames[0]) */
625 bcm_can_tx(op); 647 bcm_can_tx(op);
626 return; 648 goto rx_freeskb;
627 } 649 }
628 650
629 if (op->flags & RX_FILTER_ID) { 651 if (op->flags & RX_FILTER_ID) {
630 /* the easiest case */ 652 /* the easiest case */
631 bcm_rx_update_and_send(op, &op->last_frames[0], &rxframe); 653 bcm_rx_update_and_send(op, &op->last_frames[0], rxframe);
632 bcm_rx_starttimer(op); 654 goto rx_freeskb_starttimer;
633 return;
634 } 655 }
635 656
636 if (op->nframes == 1) { 657 if (op->nframes == 1) {
637 /* simple compare with index 0 */ 658 /* simple compare with index 0 */
638 bcm_rx_cmp_to_index(op, 0, &rxframe); 659 bcm_rx_cmp_to_index(op, 0, rxframe);
639 bcm_rx_starttimer(op); 660 goto rx_freeskb_starttimer;
640 return;
641 } 661 }
642 662
643 if (op->nframes > 1) { 663 if (op->nframes > 1) {
@@ -649,15 +669,19 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
649 */ 669 */
650 670
651 for (i = 1; i < op->nframes; i++) { 671 for (i = 1; i < op->nframes; i++) {
652 if ((GET_U64(&op->frames[0]) & GET_U64(&rxframe)) == 672 if ((GET_U64(&op->frames[0]) & GET_U64(rxframe)) ==
653 (GET_U64(&op->frames[0]) & 673 (GET_U64(&op->frames[0]) &
654 GET_U64(&op->frames[i]))) { 674 GET_U64(&op->frames[i]))) {
655 bcm_rx_cmp_to_index(op, i, &rxframe); 675 bcm_rx_cmp_to_index(op, i, rxframe);
656 break; 676 break;
657 } 677 }
658 } 678 }
659 bcm_rx_starttimer(op);
660 } 679 }
680
681rx_freeskb_starttimer:
682 bcm_rx_starttimer(op);
683rx_freeskb:
684 kfree_skb(skb);
661} 685}
662 686
663/* 687/*
@@ -681,6 +705,12 @@ static void bcm_remove_op(struct bcm_op *op)
681 hrtimer_cancel(&op->timer); 705 hrtimer_cancel(&op->timer);
682 hrtimer_cancel(&op->thrtimer); 706 hrtimer_cancel(&op->thrtimer);
683 707
708 if (op->tsklet.func)
709 tasklet_kill(&op->tsklet);
710
711 if (op->thrtsklet.func)
712 tasklet_kill(&op->thrtsklet);
713
684 if ((op->frames) && (op->frames != &op->sframe)) 714 if ((op->frames) && (op->frames != &op->sframe))
685 kfree(op->frames); 715 kfree(op->frames);
686 716
@@ -891,6 +921,10 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
891 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 921 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
892 op->timer.function = bcm_tx_timeout_handler; 922 op->timer.function = bcm_tx_timeout_handler;
893 923
924 /* initialize tasklet for tx countevent notification */
925 tasklet_init(&op->tsklet, bcm_tx_timeout_tsklet,
926 (unsigned long) op);
927
894 /* currently unused in tx_ops */ 928 /* currently unused in tx_ops */
895 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 929 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
896 930
@@ -1054,9 +1088,17 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1054 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1088 hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1055 op->timer.function = bcm_rx_timeout_handler; 1089 op->timer.function = bcm_rx_timeout_handler;
1056 1090
1091 /* initialize tasklet for rx timeout notification */
1092 tasklet_init(&op->tsklet, bcm_rx_timeout_tsklet,
1093 (unsigned long) op);
1094
1057 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1095 hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1058 op->thrtimer.function = bcm_rx_thr_handler; 1096 op->thrtimer.function = bcm_rx_thr_handler;
1059 1097
1098 /* initialize tasklet for rx throttle handling */
1099 tasklet_init(&op->thrtsklet, bcm_rx_thr_tsklet,
1100 (unsigned long) op);
1101
1060 /* add this bcm_op to the list of the rx_ops */ 1102 /* add this bcm_op to the list of the rx_ops */
1061 list_add(&op->list, &bo->rx_ops); 1103 list_add(&op->list, &bo->rx_ops);
1062 1104
@@ -1102,7 +1144,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1102 */ 1144 */
1103 op->kt_lastmsg = ktime_set(0, 0); 1145 op->kt_lastmsg = ktime_set(0, 0);
1104 hrtimer_cancel(&op->thrtimer); 1146 hrtimer_cancel(&op->thrtimer);
1105 bcm_rx_thr_flush(op); 1147 bcm_rx_thr_flush(op, 1);
1106 } 1148 }
1107 1149
1108 if ((op->flags & STARTTIMER) && op->kt_ival1.tv64) 1150 if ((op->flags & STARTTIMER) && op->kt_ival1.tv64)
diff --git a/net/core/dev.c b/net/core/dev.c
index 09c66a449da6..382df6c09eec 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -132,6 +132,9 @@
132/* Instead of increasing this, you should create a hash table. */ 132/* Instead of increasing this, you should create a hash table. */
133#define MAX_GRO_SKBS 8 133#define MAX_GRO_SKBS 8
134 134
135/* This should be increased if a protocol with a bigger head is added. */
136#define GRO_MAX_HEAD (MAX_HEADER + 128)
137
135/* 138/*
136 * The list of packet types we will receive (as opposed to discard) 139 * The list of packet types we will receive (as opposed to discard)
137 * and the routines to invoke. 140 * and the routines to invoke.
@@ -2345,7 +2348,7 @@ static int napi_gro_complete(struct sk_buff *skb)
2345 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK]; 2348 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
2346 int err = -ENOENT; 2349 int err = -ENOENT;
2347 2350
2348 if (!skb_shinfo(skb)->frag_list) 2351 if (NAPI_GRO_CB(skb)->count == 1)
2349 goto out; 2352 goto out;
2350 2353
2351 rcu_read_lock(); 2354 rcu_read_lock();
@@ -2365,6 +2368,7 @@ static int napi_gro_complete(struct sk_buff *skb)
2365 } 2368 }
2366 2369
2367out: 2370out:
2371 skb_shinfo(skb)->gso_size = 0;
2368 __skb_push(skb, -skb_network_offset(skb)); 2372 __skb_push(skb, -skb_network_offset(skb));
2369 return netif_receive_skb(skb); 2373 return netif_receive_skb(skb);
2370} 2374}
@@ -2383,7 +2387,7 @@ void napi_gro_flush(struct napi_struct *napi)
2383} 2387}
2384EXPORT_SYMBOL(napi_gro_flush); 2388EXPORT_SYMBOL(napi_gro_flush);
2385 2389
2386int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) 2390static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2387{ 2391{
2388 struct sk_buff **pp = NULL; 2392 struct sk_buff **pp = NULL;
2389 struct packet_type *ptype; 2393 struct packet_type *ptype;
@@ -2392,6 +2396,7 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2392 int count = 0; 2396 int count = 0;
2393 int same_flow; 2397 int same_flow;
2394 int mac_len; 2398 int mac_len;
2399 int free;
2395 2400
2396 if (!(skb->dev->features & NETIF_F_GRO)) 2401 if (!(skb->dev->features & NETIF_F_GRO))
2397 goto normal; 2402 goto normal;
@@ -2408,6 +2413,7 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2408 skb->mac_len = mac_len; 2413 skb->mac_len = mac_len;
2409 NAPI_GRO_CB(skb)->same_flow = 0; 2414 NAPI_GRO_CB(skb)->same_flow = 0;
2410 NAPI_GRO_CB(skb)->flush = 0; 2415 NAPI_GRO_CB(skb)->flush = 0;
2416 NAPI_GRO_CB(skb)->free = 0;
2411 2417
2412 for (p = napi->gro_list; p; p = p->next) { 2418 for (p = napi->gro_list; p; p = p->next) {
2413 count++; 2419 count++;
@@ -2427,6 +2433,7 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2427 goto normal; 2433 goto normal;
2428 2434
2429 same_flow = NAPI_GRO_CB(skb)->same_flow; 2435 same_flow = NAPI_GRO_CB(skb)->same_flow;
2436 free = NAPI_GRO_CB(skb)->free;
2430 2437
2431 if (pp) { 2438 if (pp) {
2432 struct sk_buff *nskb = *pp; 2439 struct sk_buff *nskb = *pp;
@@ -2446,17 +2453,91 @@ int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2446 } 2453 }
2447 2454
2448 NAPI_GRO_CB(skb)->count = 1; 2455 NAPI_GRO_CB(skb)->count = 1;
2456 skb_shinfo(skb)->gso_size = skb->len;
2449 skb->next = napi->gro_list; 2457 skb->next = napi->gro_list;
2450 napi->gro_list = skb; 2458 napi->gro_list = skb;
2451 2459
2452ok: 2460ok:
2453 return NET_RX_SUCCESS; 2461 return free;
2454 2462
2455normal: 2463normal:
2456 return netif_receive_skb(skb); 2464 return -1;
2465}
2466
2467int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2468{
2469 switch (__napi_gro_receive(napi, skb)) {
2470 case -1:
2471 return netif_receive_skb(skb);
2472
2473 case 1:
2474 kfree_skb(skb);
2475 break;
2476 }
2477
2478 return NET_RX_SUCCESS;
2457} 2479}
2458EXPORT_SYMBOL(napi_gro_receive); 2480EXPORT_SYMBOL(napi_gro_receive);
2459 2481
2482int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info)
2483{
2484 struct net_device *dev = napi->dev;
2485 struct sk_buff *skb = napi->skb;
2486 int err = NET_RX_DROP;
2487
2488 napi->skb = NULL;
2489
2490 if (!skb) {
2491 skb = netdev_alloc_skb(dev, GRO_MAX_HEAD + NET_IP_ALIGN);
2492 if (!skb)
2493 goto out;
2494
2495 skb_reserve(skb, NET_IP_ALIGN);
2496 }
2497
2498 BUG_ON(info->nr_frags > MAX_SKB_FRAGS);
2499 skb_shinfo(skb)->nr_frags = info->nr_frags;
2500 memcpy(skb_shinfo(skb)->frags, info->frags, sizeof(info->frags));
2501
2502 skb->data_len = info->len;
2503 skb->len += info->len;
2504 skb->truesize += info->len;
2505
2506 if (!pskb_may_pull(skb, ETH_HLEN))
2507 goto reuse;
2508
2509 err = NET_RX_SUCCESS;
2510
2511 skb->protocol = eth_type_trans(skb, dev);
2512
2513 skb->ip_summed = info->ip_summed;
2514 skb->csum = info->csum;
2515
2516 switch (__napi_gro_receive(napi, skb)) {
2517 case -1:
2518 return netif_receive_skb(skb);
2519
2520 case 0:
2521 goto out;
2522 }
2523
2524reuse:
2525 skb_shinfo(skb)->nr_frags = 0;
2526
2527 skb->len -= skb->data_len;
2528 skb->truesize -= skb->data_len;
2529 skb->data_len = 0;
2530
2531 __skb_pull(skb, skb_headlen(skb));
2532 skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));
2533
2534 napi->skb = skb;
2535
2536out:
2537 return err;
2538}
2539EXPORT_SYMBOL(napi_gro_frags);
2540
2460static int process_backlog(struct napi_struct *napi, int quota) 2541static int process_backlog(struct napi_struct *napi, int quota)
2461{ 2542{
2462 int work = 0; 2543 int work = 0;
@@ -2535,11 +2616,12 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
2535{ 2616{
2536 INIT_LIST_HEAD(&napi->poll_list); 2617 INIT_LIST_HEAD(&napi->poll_list);
2537 napi->gro_list = NULL; 2618 napi->gro_list = NULL;
2619 napi->skb = NULL;
2538 napi->poll = poll; 2620 napi->poll = poll;
2539 napi->weight = weight; 2621 napi->weight = weight;
2540 list_add(&napi->dev_list, &dev->napi_list); 2622 list_add(&napi->dev_list, &dev->napi_list);
2541#ifdef CONFIG_NETPOLL
2542 napi->dev = dev; 2623 napi->dev = dev;
2624#ifdef CONFIG_NETPOLL
2543 spin_lock_init(&napi->poll_lock); 2625 spin_lock_init(&napi->poll_lock);
2544 napi->poll_owner = -1; 2626 napi->poll_owner = -1;
2545#endif 2627#endif
@@ -2552,6 +2634,7 @@ void netif_napi_del(struct napi_struct *napi)
2552 struct sk_buff *skb, *next; 2634 struct sk_buff *skb, *next;
2553 2635
2554 list_del_init(&napi->dev_list); 2636 list_del_init(&napi->dev_list);
2637 kfree(napi->skb);
2555 2638
2556 for (skb = napi->gro_list; skb; skb = next) { 2639 for (skb = napi->gro_list; skb; skb = next) {
2557 next = skb->next; 2640 next = skb->next;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b8d0abb26433..5110b359c758 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2594,6 +2594,17 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
2594 2594
2595 if (skb_shinfo(p)->frag_list) 2595 if (skb_shinfo(p)->frag_list)
2596 goto merge; 2596 goto merge;
2597 else if (!skb_headlen(p) && !skb_headlen(skb) &&
2598 skb_shinfo(p)->nr_frags + skb_shinfo(skb)->nr_frags <
2599 MAX_SKB_FRAGS) {
2600 memcpy(skb_shinfo(p)->frags + skb_shinfo(p)->nr_frags,
2601 skb_shinfo(skb)->frags,
2602 skb_shinfo(skb)->nr_frags * sizeof(skb_frag_t));
2603
2604 skb_shinfo(p)->nr_frags += skb_shinfo(skb)->nr_frags;
2605 NAPI_GRO_CB(skb)->free = 1;
2606 goto done;
2607 }
2597 2608
2598 headroom = skb_headroom(p); 2609 headroom = skb_headroom(p);
2599 nskb = netdev_alloc_skb(p->dev, headroom); 2610 nskb = netdev_alloc_skb(p->dev, headroom);
@@ -2613,6 +2624,7 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
2613 2624
2614 *NAPI_GRO_CB(nskb) = *NAPI_GRO_CB(p); 2625 *NAPI_GRO_CB(nskb) = *NAPI_GRO_CB(p);
2615 skb_shinfo(nskb)->frag_list = p; 2626 skb_shinfo(nskb)->frag_list = p;
2627 skb_shinfo(nskb)->gso_size = skb_shinfo(p)->gso_size;
2616 skb_header_release(p); 2628 skb_header_release(p);
2617 nskb->prev = p; 2629 nskb->prev = p;
2618 2630
@@ -2627,11 +2639,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
2627 p = nskb; 2639 p = nskb;
2628 2640
2629merge: 2641merge:
2630 NAPI_GRO_CB(p)->count++;
2631 p->prev->next = skb; 2642 p->prev->next = skb;
2632 p->prev = skb; 2643 p->prev = skb;
2633 skb_header_release(skb); 2644 skb_header_release(skb);
2634 2645
2646done:
2647 NAPI_GRO_CB(p)->count++;
2635 p->data_len += skb->len; 2648 p->data_len += skb->len;
2636 p->truesize += skb->len; 2649 p->truesize += skb->len;
2637 p->len += skb->len; 2650 p->len += skb->len;
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 5dbfe5fdc0d6..8379496de82b 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -191,7 +191,7 @@ static int dcbnl_reply(u8 value, u8 event, u8 cmd, u8 attr, u32 pid,
191 return 0; 191 return 0;
192nlmsg_failure: 192nlmsg_failure:
193err: 193err:
194 kfree(dcbnl_skb); 194 kfree_skb(dcbnl_skb);
195 return ret; 195 return ret;
196} 196}
197 197
@@ -272,7 +272,7 @@ static int dcbnl_getpfccfg(struct net_device *netdev, struct nlattr **tb,
272 return 0; 272 return 0;
273nlmsg_failure: 273nlmsg_failure:
274err: 274err:
275 kfree(dcbnl_skb); 275 kfree_skb(dcbnl_skb);
276err_out: 276err_out:
277 return -EINVAL; 277 return -EINVAL;
278} 278}
@@ -314,7 +314,7 @@ static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlattr **tb,
314 314
315nlmsg_failure: 315nlmsg_failure:
316err: 316err:
317 kfree(dcbnl_skb); 317 kfree_skb(dcbnl_skb);
318err_out: 318err_out:
319 return -EINVAL; 319 return -EINVAL;
320} 320}
@@ -380,7 +380,7 @@ static int dcbnl_getcap(struct net_device *netdev, struct nlattr **tb,
380 return 0; 380 return 0;
381nlmsg_failure: 381nlmsg_failure:
382err: 382err:
383 kfree(dcbnl_skb); 383 kfree_skb(dcbnl_skb);
384err_out: 384err_out:
385 return -EINVAL; 385 return -EINVAL;
386} 386}
@@ -458,7 +458,7 @@ static int dcbnl_getnumtcs(struct net_device *netdev, struct nlattr **tb,
458 return 0; 458 return 0;
459nlmsg_failure: 459nlmsg_failure:
460err: 460err:
461 kfree(dcbnl_skb); 461 kfree_skb(dcbnl_skb);
462err_out: 462err_out:
463 return ret; 463 return ret;
464} 464}
@@ -687,7 +687,7 @@ err_pg:
687 nla_nest_cancel(dcbnl_skb, pg_nest); 687 nla_nest_cancel(dcbnl_skb, pg_nest);
688nlmsg_failure: 688nlmsg_failure:
689err: 689err:
690 kfree(dcbnl_skb); 690 kfree_skb(dcbnl_skb);
691err_out: 691err_out:
692 ret = -EINVAL; 692 ret = -EINVAL;
693 return ret; 693 return ret;
@@ -949,7 +949,7 @@ err_bcn:
949 nla_nest_cancel(dcbnl_skb, bcn_nest); 949 nla_nest_cancel(dcbnl_skb, bcn_nest);
950nlmsg_failure: 950nlmsg_failure:
951err: 951err:
952 kfree(dcbnl_skb); 952 kfree_skb(dcbnl_skb);
953err_out: 953err_out:
954 ret = -EINVAL; 954 ret = -EINVAL;
955 return ret; 955 return ret;
diff --git a/net/dccp/Kconfig b/net/dccp/Kconfig
index 7aa2a7acc7ec..ad6dffd9070e 100644
--- a/net/dccp/Kconfig
+++ b/net/dccp/Kconfig
@@ -1,7 +1,6 @@
1menuconfig IP_DCCP 1menuconfig IP_DCCP
2 tristate "The DCCP Protocol (EXPERIMENTAL)" 2 tristate "The DCCP Protocol (EXPERIMENTAL)"
3 depends on INET && EXPERIMENTAL 3 depends on INET && EXPERIMENTAL
4 select IP_DCCP_CCID2
5 ---help--- 4 ---help---
6 Datagram Congestion Control Protocol (RFC 4340) 5 Datagram Congestion Control Protocol (RFC 4340)
7 6
@@ -25,9 +24,6 @@ config INET_DCCP_DIAG
25 def_tristate y if (IP_DCCP = y && INET_DIAG = y) 24 def_tristate y if (IP_DCCP = y && INET_DIAG = y)
26 def_tristate m 25 def_tristate m
27 26
28config IP_DCCP_ACKVEC
29 bool
30
31source "net/dccp/ccids/Kconfig" 27source "net/dccp/ccids/Kconfig"
32 28
33menu "DCCP Kernel Hacking" 29menu "DCCP Kernel Hacking"
diff --git a/net/dccp/Makefile b/net/dccp/Makefile
index f4f8793aafff..2991efcc8dea 100644
--- a/net/dccp/Makefile
+++ b/net/dccp/Makefile
@@ -2,14 +2,23 @@ obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o
2 2
3dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o 3dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o
4 4
5#
6# CCID algorithms to be used by dccp.ko
7#
8# CCID-2 is default (RFC 4340, p. 77) and has Ack Vectors as dependency
9dccp-y += ccids/ccid2.o ackvec.o
10dccp-$(CONFIG_IP_DCCP_CCID3) += ccids/ccid3.o
11dccp-$(CONFIG_IP_DCCP_TFRC_LIB) += ccids/lib/tfrc.o \
12 ccids/lib/tfrc_equation.o \
13 ccids/lib/packet_history.o \
14 ccids/lib/loss_interval.o
15
5dccp_ipv4-y := ipv4.o 16dccp_ipv4-y := ipv4.o
6 17
7# build dccp_ipv6 as module whenever either IPv6 or DCCP is a module 18# build dccp_ipv6 as module whenever either IPv6 or DCCP is a module
8obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o 19obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o
9dccp_ipv6-y := ipv6.o 20dccp_ipv6-y := ipv6.o
10 21
11dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o
12
13obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o 22obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o
14obj-$(CONFIG_NET_DCCPPROBE) += dccp_probe.o 23obj-$(CONFIG_NET_DCCPPROBE) += dccp_probe.o
15 24
@@ -17,5 +26,3 @@ dccp-$(CONFIG_SYSCTL) += sysctl.o
17 26
18dccp_diag-y := diag.o 27dccp_diag-y := diag.o
19dccp_probe-y := probe.o 28dccp_probe-y := probe.o
20
21obj-y += ccids/
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index 4ccee030524e..45f95e55f873 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -84,7 +84,6 @@ struct dccp_ackvec_record {
84struct sock; 84struct sock;
85struct sk_buff; 85struct sk_buff;
86 86
87#ifdef CONFIG_IP_DCCP_ACKVEC
88extern int dccp_ackvec_init(void); 87extern int dccp_ackvec_init(void);
89extern void dccp_ackvec_exit(void); 88extern void dccp_ackvec_exit(void);
90 89
@@ -106,52 +105,4 @@ static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
106{ 105{
107 return av->av_vec_len; 106 return av->av_vec_len;
108} 107}
109#else /* CONFIG_IP_DCCP_ACKVEC */
110static inline int dccp_ackvec_init(void)
111{
112 return 0;
113}
114
115static inline void dccp_ackvec_exit(void)
116{
117}
118
119static inline struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
120{
121 return NULL;
122}
123
124static inline void dccp_ackvec_free(struct dccp_ackvec *av)
125{
126}
127
128static inline int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
129 const u64 ackno, const u8 state)
130{
131 return -1;
132}
133
134static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
135 struct sock *sk, const u64 ackno)
136{
137}
138
139static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
140 const u64 *ackno, const u8 opt,
141 const u8 *value, const u8 len)
142{
143 return -1;
144}
145
146static inline int dccp_insert_option_ackvec(const struct sock *sk,
147 const struct sk_buff *skb)
148{
149 return -1;
150}
151
152static inline int dccp_ackvec_pending(const struct dccp_ackvec *av)
153{
154 return 0;
155}
156#endif /* CONFIG_IP_DCCP_ACKVEC */
157#endif /* _ACKVEC_H */ 108#endif /* _ACKVEC_H */
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index bcc643f992ae..f3e9ba1cfd01 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -12,56 +12,70 @@
12 */ 12 */
13 13
14#include "ccid.h" 14#include "ccid.h"
15#include "ccids/lib/tfrc.h"
15 16
16static u8 builtin_ccids[] = { 17static struct ccid_operations *ccids[] = {
17 DCCPC_CCID2, /* CCID2 is supported by default */ 18 &ccid2_ops,
18#if defined(CONFIG_IP_DCCP_CCID3) || defined(CONFIG_IP_DCCP_CCID3_MODULE) 19#ifdef CONFIG_IP_DCCP_CCID3
19 DCCPC_CCID3, 20 &ccid3_ops,
20#endif 21#endif
21}; 22};
22 23
23static struct ccid_operations *ccids[CCID_MAX]; 24static struct ccid_operations *ccid_by_number(const u8 id)
24#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
25static atomic_t ccids_lockct = ATOMIC_INIT(0);
26static DEFINE_SPINLOCK(ccids_lock);
27
28/*
29 * The strategy is: modifications ccids vector are short, do not sleep and
30 * veeery rare, but read access should be free of any exclusive locks.
31 */
32static void ccids_write_lock(void)
33{ 25{
34 spin_lock(&ccids_lock); 26 int i;
35 while (atomic_read(&ccids_lockct) != 0) { 27
36 spin_unlock(&ccids_lock); 28 for (i = 0; i < ARRAY_SIZE(ccids); i++)
37 yield(); 29 if (ccids[i]->ccid_id == id)
38 spin_lock(&ccids_lock); 30 return ccids[i];
39 } 31 return NULL;
40} 32}
41 33
42static inline void ccids_write_unlock(void) 34/* check that up to @array_len members in @ccid_array are supported */
35bool ccid_support_check(u8 const *ccid_array, u8 array_len)
43{ 36{
44 spin_unlock(&ccids_lock); 37 while (array_len > 0)
38 if (ccid_by_number(ccid_array[--array_len]) == NULL)
39 return false;
40 return true;
45} 41}
46 42
47static inline void ccids_read_lock(void) 43/**
44 * ccid_get_builtin_ccids - Populate a list of built-in CCIDs
45 * @ccid_array: pointer to copy into
46 * @array_len: value to return length into
47 * This function allocates memory - caller must see that it is freed after use.
48 */
49int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len)
48{ 50{
49 atomic_inc(&ccids_lockct); 51 *ccid_array = kmalloc(ARRAY_SIZE(ccids), gfp_any());
50 smp_mb__after_atomic_inc(); 52 if (*ccid_array == NULL)
51 spin_unlock_wait(&ccids_lock); 53 return -ENOBUFS;
54
55 for (*array_len = 0; *array_len < ARRAY_SIZE(ccids); *array_len += 1)
56 (*ccid_array)[*array_len] = ccids[*array_len]->ccid_id;
57 return 0;
52} 58}
53 59
54static inline void ccids_read_unlock(void) 60int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
61 char __user *optval, int __user *optlen)
55{ 62{
56 atomic_dec(&ccids_lockct); 63 u8 *ccid_array, array_len;
57} 64 int err = 0;
58 65
59#else 66 if (len < ARRAY_SIZE(ccids))
60#define ccids_write_lock() do { } while(0) 67 return -EINVAL;
61#define ccids_write_unlock() do { } while(0) 68
62#define ccids_read_lock() do { } while(0) 69 if (ccid_get_builtin_ccids(&ccid_array, &array_len))
63#define ccids_read_unlock() do { } while(0) 70 return -ENOBUFS;
64#endif 71
72 if (put_user(array_len, optlen) ||
73 copy_to_user(optval, ccid_array, array_len))
74 err = -EFAULT;
75
76 kfree(ccid_array);
77 return err;
78}
65 79
66static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...) 80static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
67{ 81{
@@ -93,48 +107,7 @@ static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
93 } 107 }
94} 108}
95 109
96/* check that up to @array_len members in @ccid_array are supported */ 110static int ccid_activate(struct ccid_operations *ccid_ops)
97bool ccid_support_check(u8 const *ccid_array, u8 array_len)
98{
99 u8 i, j, found;
100
101 for (i = 0, found = 0; i < array_len; i++, found = 0) {
102 for (j = 0; !found && j < ARRAY_SIZE(builtin_ccids); j++)
103 found = (ccid_array[i] == builtin_ccids[j]);
104 if (!found)
105 return false;
106 }
107 return true;
108}
109
110/**
111 * ccid_get_builtin_ccids - Provide copy of `builtin' CCID array
112 * @ccid_array: pointer to copy into
113 * @array_len: value to return length into
114 * This function allocates memory - caller must see that it is freed after use.
115 */
116int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len)
117{
118 *ccid_array = kmemdup(builtin_ccids, sizeof(builtin_ccids), gfp_any());
119 if (*ccid_array == NULL)
120 return -ENOBUFS;
121 *array_len = ARRAY_SIZE(builtin_ccids);
122 return 0;
123}
124
125int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
126 char __user *optval, int __user *optlen)
127{
128 if (len < sizeof(builtin_ccids))
129 return -EINVAL;
130
131 if (put_user(sizeof(builtin_ccids), optlen) ||
132 copy_to_user(optval, builtin_ccids, sizeof(builtin_ccids)))
133 return -EFAULT;
134 return 0;
135}
136
137int ccid_register(struct ccid_operations *ccid_ops)
138{ 111{
139 int err = -ENOBUFS; 112 int err = -ENOBUFS;
140 113
@@ -152,79 +125,40 @@ int ccid_register(struct ccid_operations *ccid_ops)
152 if (ccid_ops->ccid_hc_tx_slab == NULL) 125 if (ccid_ops->ccid_hc_tx_slab == NULL)
153 goto out_free_rx_slab; 126 goto out_free_rx_slab;
154 127
155 ccids_write_lock(); 128 pr_info("CCID: Activated CCID %d (%s)\n",
156 err = -EEXIST;
157 if (ccids[ccid_ops->ccid_id] == NULL) {
158 ccids[ccid_ops->ccid_id] = ccid_ops;
159 err = 0;
160 }
161 ccids_write_unlock();
162 if (err != 0)
163 goto out_free_tx_slab;
164
165 pr_info("CCID: Registered CCID %d (%s)\n",
166 ccid_ops->ccid_id, ccid_ops->ccid_name); 129 ccid_ops->ccid_id, ccid_ops->ccid_name);
130 err = 0;
167out: 131out:
168 return err; 132 return err;
169out_free_tx_slab:
170 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_tx_slab);
171 ccid_ops->ccid_hc_tx_slab = NULL;
172 goto out;
173out_free_rx_slab: 133out_free_rx_slab:
174 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab); 134 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab);
175 ccid_ops->ccid_hc_rx_slab = NULL; 135 ccid_ops->ccid_hc_rx_slab = NULL;
176 goto out; 136 goto out;
177} 137}
178 138
179EXPORT_SYMBOL_GPL(ccid_register); 139static void ccid_deactivate(struct ccid_operations *ccid_ops)
180
181int ccid_unregister(struct ccid_operations *ccid_ops)
182{ 140{
183 ccids_write_lock();
184 ccids[ccid_ops->ccid_id] = NULL;
185 ccids_write_unlock();
186
187 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_tx_slab); 141 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_tx_slab);
188 ccid_ops->ccid_hc_tx_slab = NULL; 142 ccid_ops->ccid_hc_tx_slab = NULL;
189 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab); 143 ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab);
190 ccid_ops->ccid_hc_rx_slab = NULL; 144 ccid_ops->ccid_hc_rx_slab = NULL;
191 145
192 pr_info("CCID: Unregistered CCID %d (%s)\n", 146 pr_info("CCID: Deactivated CCID %d (%s)\n",
193 ccid_ops->ccid_id, ccid_ops->ccid_name); 147 ccid_ops->ccid_id, ccid_ops->ccid_name);
194 return 0;
195} 148}
196 149
197EXPORT_SYMBOL_GPL(ccid_unregister); 150struct ccid *ccid_new(const u8 id, struct sock *sk, bool rx)
198
199struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp)
200{ 151{
201 struct ccid_operations *ccid_ops; 152 struct ccid_operations *ccid_ops = ccid_by_number(id);
202 struct ccid *ccid = NULL; 153 struct ccid *ccid = NULL;
203 154
204 ccids_read_lock();
205#ifdef CONFIG_MODULES
206 if (ccids[id] == NULL) {
207 /* We only try to load if in process context */
208 ccids_read_unlock();
209 if (gfp & GFP_ATOMIC)
210 goto out;
211 request_module("net-dccp-ccid-%d", id);
212 ccids_read_lock();
213 }
214#endif
215 ccid_ops = ccids[id];
216 if (ccid_ops == NULL) 155 if (ccid_ops == NULL)
217 goto out_unlock; 156 goto out;
218
219 if (!try_module_get(ccid_ops->ccid_owner))
220 goto out_unlock;
221
222 ccids_read_unlock();
223 157
224 ccid = kmem_cache_alloc(rx ? ccid_ops->ccid_hc_rx_slab : 158 ccid = kmem_cache_alloc(rx ? ccid_ops->ccid_hc_rx_slab :
225 ccid_ops->ccid_hc_tx_slab, gfp); 159 ccid_ops->ccid_hc_tx_slab, gfp_any());
226 if (ccid == NULL) 160 if (ccid == NULL)
227 goto out_module_put; 161 goto out;
228 ccid->ccid_ops = ccid_ops; 162 ccid->ccid_ops = ccid_ops;
229 if (rx) { 163 if (rx) {
230 memset(ccid + 1, 0, ccid_ops->ccid_hc_rx_obj_size); 164 memset(ccid + 1, 0, ccid_ops->ccid_hc_rx_obj_size);
@@ -239,53 +173,57 @@ struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, gfp_t gfp)
239 } 173 }
240out: 174out:
241 return ccid; 175 return ccid;
242out_unlock:
243 ccids_read_unlock();
244 goto out;
245out_free_ccid: 176out_free_ccid:
246 kmem_cache_free(rx ? ccid_ops->ccid_hc_rx_slab : 177 kmem_cache_free(rx ? ccid_ops->ccid_hc_rx_slab :
247 ccid_ops->ccid_hc_tx_slab, ccid); 178 ccid_ops->ccid_hc_tx_slab, ccid);
248 ccid = NULL; 179 ccid = NULL;
249out_module_put:
250 module_put(ccid_ops->ccid_owner);
251 goto out; 180 goto out;
252} 181}
253 182
254EXPORT_SYMBOL_GPL(ccid_new); 183void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk)
255
256static void ccid_delete(struct ccid *ccid, struct sock *sk, int rx)
257{ 184{
258 struct ccid_operations *ccid_ops; 185 if (ccid != NULL) {
259 186 if (ccid->ccid_ops->ccid_hc_rx_exit != NULL)
260 if (ccid == NULL) 187 ccid->ccid_ops->ccid_hc_rx_exit(sk);
261 return; 188 kmem_cache_free(ccid->ccid_ops->ccid_hc_rx_slab, ccid);
262
263 ccid_ops = ccid->ccid_ops;
264 if (rx) {
265 if (ccid_ops->ccid_hc_rx_exit != NULL)
266 ccid_ops->ccid_hc_rx_exit(sk);
267 kmem_cache_free(ccid_ops->ccid_hc_rx_slab, ccid);
268 } else {
269 if (ccid_ops->ccid_hc_tx_exit != NULL)
270 ccid_ops->ccid_hc_tx_exit(sk);
271 kmem_cache_free(ccid_ops->ccid_hc_tx_slab, ccid);
272 } 189 }
273 ccids_read_lock();
274 if (ccids[ccid_ops->ccid_id] != NULL)
275 module_put(ccid_ops->ccid_owner);
276 ccids_read_unlock();
277} 190}
278 191
279void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk) 192void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk)
280{ 193{
281 ccid_delete(ccid, sk, 1); 194 if (ccid != NULL) {
195 if (ccid->ccid_ops->ccid_hc_tx_exit != NULL)
196 ccid->ccid_ops->ccid_hc_tx_exit(sk);
197 kmem_cache_free(ccid->ccid_ops->ccid_hc_tx_slab, ccid);
198 }
282} 199}
283 200
284EXPORT_SYMBOL_GPL(ccid_hc_rx_delete); 201int __init ccid_initialize_builtins(void)
285
286void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk)
287{ 202{
288 ccid_delete(ccid, sk, 0); 203 int i, err = tfrc_lib_init();
204
205 if (err)
206 return err;
207
208 for (i = 0; i < ARRAY_SIZE(ccids); i++) {
209 err = ccid_activate(ccids[i]);
210 if (err)
211 goto unwind_registrations;
212 }
213 return 0;
214
215unwind_registrations:
216 while(--i >= 0)
217 ccid_deactivate(ccids[i]);
218 tfrc_lib_exit();
219 return err;
289} 220}
290 221
291EXPORT_SYMBOL_GPL(ccid_hc_tx_delete); 222void ccid_cleanup_builtins(void)
223{
224 int i;
225
226 for (i = 0; i < ARRAY_SIZE(ccids); i++)
227 ccid_deactivate(ccids[i]);
228 tfrc_lib_exit();
229}
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index 18f69423a708..facedd20b531 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -29,7 +29,6 @@ struct tcp_info;
29 * @ccid_id: numerical CCID ID (up to %CCID_MAX, cf. table 5 in RFC 4340, 10.) 29 * @ccid_id: numerical CCID ID (up to %CCID_MAX, cf. table 5 in RFC 4340, 10.)
30 * @ccid_ccmps: the CCMPS including network/transport headers (0 when disabled) 30 * @ccid_ccmps: the CCMPS including network/transport headers (0 when disabled)
31 * @ccid_name: alphabetical identifier string for @ccid_id 31 * @ccid_name: alphabetical identifier string for @ccid_id
32 * @ccid_owner: module which implements/owns this CCID
33 * @ccid_hc_{r,t}x_slab: memory pool for the receiver/sender half-connection 32 * @ccid_hc_{r,t}x_slab: memory pool for the receiver/sender half-connection
34 * @ccid_hc_{r,t}x_obj_size: size of the receiver/sender half-connection socket 33 * @ccid_hc_{r,t}x_obj_size: size of the receiver/sender half-connection socket
35 * 34 *
@@ -48,7 +47,6 @@ struct ccid_operations {
48 unsigned char ccid_id; 47 unsigned char ccid_id;
49 __u32 ccid_ccmps; 48 __u32 ccid_ccmps;
50 const char *ccid_name; 49 const char *ccid_name;
51 struct module *ccid_owner;
52 struct kmem_cache *ccid_hc_rx_slab, 50 struct kmem_cache *ccid_hc_rx_slab,
53 *ccid_hc_tx_slab; 51 *ccid_hc_tx_slab;
54 __u32 ccid_hc_rx_obj_size, 52 __u32 ccid_hc_rx_obj_size,
@@ -90,8 +88,13 @@ struct ccid_operations {
90 int __user *optlen); 88 int __user *optlen);
91}; 89};
92 90
93extern int ccid_register(struct ccid_operations *ccid_ops); 91extern struct ccid_operations ccid2_ops;
94extern int ccid_unregister(struct ccid_operations *ccid_ops); 92#ifdef CONFIG_IP_DCCP_CCID3
93extern struct ccid_operations ccid3_ops;
94#endif
95
96extern int ccid_initialize_builtins(void);
97extern void ccid_cleanup_builtins(void);
95 98
96struct ccid { 99struct ccid {
97 struct ccid_operations *ccid_ops; 100 struct ccid_operations *ccid_ops;
@@ -108,8 +111,7 @@ extern int ccid_get_builtin_ccids(u8 **ccid_array, u8 *array_len);
108extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len, 111extern int ccid_getsockopt_builtin_ccids(struct sock *sk, int len,
109 char __user *, int __user *); 112 char __user *, int __user *);
110 113
111extern struct ccid *ccid_new(unsigned char id, struct sock *sk, int rx, 114extern struct ccid *ccid_new(const u8 id, struct sock *sk, bool rx);
112 gfp_t gfp);
113 115
114static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp) 116static inline int ccid_get_current_rx_ccid(struct dccp_sock *dp)
115{ 117{
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 12275943eab8..b28bf962edc3 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -1,80 +1,51 @@
1menu "DCCP CCIDs Configuration (EXPERIMENTAL)" 1menu "DCCP CCIDs Configuration (EXPERIMENTAL)"
2 depends on EXPERIMENTAL 2 depends on EXPERIMENTAL
3 3
4config IP_DCCP_CCID2
5 tristate "CCID2 (TCP-Like) (EXPERIMENTAL)"
6 def_tristate IP_DCCP
7 select IP_DCCP_ACKVEC
8 ---help---
9 CCID 2, TCP-like Congestion Control, denotes Additive Increase,
10 Multiplicative Decrease (AIMD) congestion control with behavior
11 modelled directly on TCP, including congestion window, slow start,
12 timeouts, and so forth [RFC 2581]. CCID 2 achieves maximum
13 bandwidth over the long term, consistent with the use of end-to-end
14 congestion control, but halves its congestion window in response to
15 each congestion event. This leads to the abrupt rate changes
16 typical of TCP. Applications should use CCID 2 if they prefer
17 maximum bandwidth utilization to steadiness of rate. This is often
18 the case for applications that are not playing their data directly
19 to the user. For example, a hypothetical application that
20 transferred files over DCCP, using application-level retransmissions
21 for lost packets, would prefer CCID 2 to CCID 3. On-line games may
22 also prefer CCID 2. See RFC 4341 for further details.
23
24 CCID2 is the default CCID used by DCCP.
25
26config IP_DCCP_CCID2_DEBUG 4config IP_DCCP_CCID2_DEBUG
27 bool "CCID2 debugging messages" 5 bool "CCID-2 debugging messages"
28 depends on IP_DCCP_CCID2 6 ---help---
29 ---help--- 7 Enable CCID-2 specific debugging messages.
30 Enable CCID2-specific debugging messages.
31 8
32 When compiling CCID2 as a module, this debugging output can 9 The debugging output can additionally be toggled by setting the
33 additionally be toggled by setting the ccid2_debug module 10 ccid2_debug parameter to 0 or 1.
34 parameter to 0 or 1.
35 11
36 If in doubt, say N. 12 If in doubt, say N.
37 13
38config IP_DCCP_CCID3 14config IP_DCCP_CCID3
39 tristate "CCID3 (TCP-Friendly) (EXPERIMENTAL)" 15 bool "CCID-3 (TCP-Friendly) (EXPERIMENTAL)"
40 def_tristate IP_DCCP 16 def_bool y if (IP_DCCP = y || IP_DCCP = m)
41 select IP_DCCP_TFRC_LIB
42 ---help--- 17 ---help---
43 CCID 3 denotes TCP-Friendly Rate Control (TFRC), an equation-based 18 CCID-3 denotes TCP-Friendly Rate Control (TFRC), an equation-based
44 rate-controlled congestion control mechanism. TFRC is designed to 19 rate-controlled congestion control mechanism. TFRC is designed to
45 be reasonably fair when competing for bandwidth with TCP-like flows, 20 be reasonably fair when competing for bandwidth with TCP-like flows,
46 where a flow is "reasonably fair" if its sending rate is generally 21 where a flow is "reasonably fair" if its sending rate is generally
47 within a factor of two of the sending rate of a TCP flow under the 22 within a factor of two of the sending rate of a TCP flow under the
48 same conditions. However, TFRC has a much lower variation of 23 same conditions. However, TFRC has a much lower variation of
49 throughput over time compared with TCP, which makes CCID 3 more 24 throughput over time compared with TCP, which makes CCID-3 more
50 suitable than CCID 2 for applications such streaming media where a 25 suitable than CCID-2 for applications such streaming media where a
51 relatively smooth sending rate is of importance. 26 relatively smooth sending rate is of importance.
52 27
53 CCID 3 is further described in RFC 4342, 28 CCID-3 is further described in RFC 4342,
54 http://www.ietf.org/rfc/rfc4342.txt 29 http://www.ietf.org/rfc/rfc4342.txt
55 30
56 The TFRC congestion control algorithms were initially described in 31 The TFRC congestion control algorithms were initially described in
57 RFC 3448. 32 RFC 5448.
58 33
59 This text was extracted from RFC 4340 (sec. 10.2), 34 This text was extracted from RFC 4340 (sec. 10.2),
60 http://www.ietf.org/rfc/rfc4340.txt 35 http://www.ietf.org/rfc/rfc4340.txt
61
62 To compile this CCID as a module, choose M here: the module will be
63 called dccp_ccid3.
64 36
65 If in doubt, say M. 37 If in doubt, say N.
66 38
67config IP_DCCP_CCID3_DEBUG 39config IP_DCCP_CCID3_DEBUG
68 bool "CCID3 debugging messages" 40 bool "CCID-3 debugging messages"
69 depends on IP_DCCP_CCID3 41 depends on IP_DCCP_CCID3
70 ---help--- 42 ---help---
71 Enable CCID3-specific debugging messages. 43 Enable CCID-3 specific debugging messages.
72 44
73 When compiling CCID3 as a module, this debugging output can 45 The debugging output can additionally be toggled by setting the
74 additionally be toggled by setting the ccid3_debug module 46 ccid3_debug parameter to 0 or 1.
75 parameter to 0 or 1.
76 47
77 If in doubt, say N. 48 If in doubt, say N.
78 49
79config IP_DCCP_CCID3_RTO 50config IP_DCCP_CCID3_RTO
80 int "Use higher bound for nofeedback timer" 51 int "Use higher bound for nofeedback timer"
@@ -108,12 +79,8 @@ config IP_DCCP_CCID3_RTO
108 therefore not be performed on WANs. 79 therefore not be performed on WANs.
109 80
110config IP_DCCP_TFRC_LIB 81config IP_DCCP_TFRC_LIB
111 tristate 82 def_bool y if IP_DCCP_CCID3
112 default n
113 83
114config IP_DCCP_TFRC_DEBUG 84config IP_DCCP_TFRC_DEBUG
115 bool 85 def_bool y if IP_DCCP_CCID3_DEBUG
116 depends on IP_DCCP_TFRC_LIB
117 default y if IP_DCCP_CCID3_DEBUG
118
119endmenu 86endmenu
diff --git a/net/dccp/ccids/Makefile b/net/dccp/ccids/Makefile
deleted file mode 100644
index 438f20bccff7..000000000000
--- a/net/dccp/ccids/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1obj-$(CONFIG_IP_DCCP_CCID3) += dccp_ccid3.o
2
3dccp_ccid3-y := ccid3.o
4
5obj-$(CONFIG_IP_DCCP_CCID2) += dccp_ccid2.o
6
7dccp_ccid2-y := ccid2.o
8
9obj-y += lib/
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index c9ea19a4d85e..d235294ace23 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -768,10 +768,9 @@ static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
768 } 768 }
769} 769}
770 770
771static struct ccid_operations ccid2 = { 771struct ccid_operations ccid2_ops = {
772 .ccid_id = DCCPC_CCID2, 772 .ccid_id = DCCPC_CCID2,
773 .ccid_name = "TCP-like", 773 .ccid_name = "TCP-like",
774 .ccid_owner = THIS_MODULE,
775 .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock), 774 .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock),
776 .ccid_hc_tx_init = ccid2_hc_tx_init, 775 .ccid_hc_tx_init = ccid2_hc_tx_init,
777 .ccid_hc_tx_exit = ccid2_hc_tx_exit, 776 .ccid_hc_tx_exit = ccid2_hc_tx_exit,
@@ -784,22 +783,5 @@ static struct ccid_operations ccid2 = {
784 783
785#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 784#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
786module_param(ccid2_debug, bool, 0644); 785module_param(ccid2_debug, bool, 0644);
787MODULE_PARM_DESC(ccid2_debug, "Enable debug messages"); 786MODULE_PARM_DESC(ccid2_debug, "Enable CCID-2 debug messages");
788#endif 787#endif
789
790static __init int ccid2_module_init(void)
791{
792 return ccid_register(&ccid2);
793}
794module_init(ccid2_module_init);
795
796static __exit void ccid2_module_exit(void)
797{
798 ccid_unregister(&ccid2);
799}
800module_exit(ccid2_module_exit);
801
802MODULE_AUTHOR("Andrea Bittau <a.bittau@cs.ucl.ac.uk>");
803MODULE_DESCRIPTION("DCCP TCP-Like (CCID2) CCID");
804MODULE_LICENSE("GPL");
805MODULE_ALIAS("net-dccp-ccid-2");
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 3b8bd7ca6761..a27b7f4c19c5 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -940,10 +940,9 @@ static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
940 return 0; 940 return 0;
941} 941}
942 942
943static struct ccid_operations ccid3 = { 943struct ccid_operations ccid3_ops = {
944 .ccid_id = DCCPC_CCID3, 944 .ccid_id = DCCPC_CCID3,
945 .ccid_name = "TCP-Friendly Rate Control", 945 .ccid_name = "TCP-Friendly Rate Control",
946 .ccid_owner = THIS_MODULE,
947 .ccid_hc_tx_obj_size = sizeof(struct ccid3_hc_tx_sock), 946 .ccid_hc_tx_obj_size = sizeof(struct ccid3_hc_tx_sock),
948 .ccid_hc_tx_init = ccid3_hc_tx_init, 947 .ccid_hc_tx_init = ccid3_hc_tx_init,
949 .ccid_hc_tx_exit = ccid3_hc_tx_exit, 948 .ccid_hc_tx_exit = ccid3_hc_tx_exit,
@@ -964,23 +963,5 @@ static struct ccid_operations ccid3 = {
964 963
965#ifdef CONFIG_IP_DCCP_CCID3_DEBUG 964#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
966module_param(ccid3_debug, bool, 0644); 965module_param(ccid3_debug, bool, 0644);
967MODULE_PARM_DESC(ccid3_debug, "Enable debug messages"); 966MODULE_PARM_DESC(ccid3_debug, "Enable CCID-3 debug messages");
968#endif 967#endif
969
970static __init int ccid3_module_init(void)
971{
972 return ccid_register(&ccid3);
973}
974module_init(ccid3_module_init);
975
976static __exit void ccid3_module_exit(void)
977{
978 ccid_unregister(&ccid3);
979}
980module_exit(ccid3_module_exit);
981
982MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
983 "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
984MODULE_DESCRIPTION("DCCP TFRC CCID3 CCID");
985MODULE_LICENSE("GPL");
986MODULE_ALIAS("net-dccp-ccid-3");
diff --git a/net/dccp/ccids/lib/Makefile b/net/dccp/ccids/lib/Makefile
deleted file mode 100644
index 68c93e3d89dc..000000000000
--- a/net/dccp/ccids/lib/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1obj-$(CONFIG_IP_DCCP_TFRC_LIB) += dccp_tfrc_lib.o
2
3dccp_tfrc_lib-y := tfrc.o tfrc_equation.o packet_history.o loss_interval.o
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 5b3ce0688c5c..4d1e40127264 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -60,7 +60,6 @@ void tfrc_lh_cleanup(struct tfrc_loss_hist *lh)
60 lh->ring[LIH_INDEX(lh->counter)] = NULL; 60 lh->ring[LIH_INDEX(lh->counter)] = NULL;
61 } 61 }
62} 62}
63EXPORT_SYMBOL_GPL(tfrc_lh_cleanup);
64 63
65static void tfrc_lh_calc_i_mean(struct tfrc_loss_hist *lh) 64static void tfrc_lh_calc_i_mean(struct tfrc_loss_hist *lh)
66{ 65{
@@ -121,7 +120,6 @@ u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb)
121 120
122 return (lh->i_mean < old_i_mean); 121 return (lh->i_mean < old_i_mean);
123} 122}
124EXPORT_SYMBOL_GPL(tfrc_lh_update_i_mean);
125 123
126/* Determine if `new_loss' does begin a new loss interval [RFC 4342, 10.2] */ 124/* Determine if `new_loss' does begin a new loss interval [RFC 4342, 10.2] */
127static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur, 125static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur,
@@ -169,7 +167,6 @@ int tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh,
169 } 167 }
170 return 1; 168 return 1;
171} 169}
172EXPORT_SYMBOL_GPL(tfrc_lh_interval_add);
173 170
174int __init tfrc_li_init(void) 171int __init tfrc_li_init(void)
175{ 172{
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index 6cc108afdc3b..b7785b3581ec 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -94,7 +94,6 @@ int tfrc_tx_hist_add(struct tfrc_tx_hist_entry **headp, u64 seqno)
94 *headp = entry; 94 *headp = entry;
95 return 0; 95 return 0;
96} 96}
97EXPORT_SYMBOL_GPL(tfrc_tx_hist_add);
98 97
99void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp) 98void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp)
100{ 99{
@@ -109,7 +108,6 @@ void tfrc_tx_hist_purge(struct tfrc_tx_hist_entry **headp)
109 108
110 *headp = NULL; 109 *headp = NULL;
111} 110}
112EXPORT_SYMBOL_GPL(tfrc_tx_hist_purge);
113 111
114u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno, 112u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno,
115 const ktime_t now) 113 const ktime_t now)
@@ -127,7 +125,6 @@ u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno,
127 125
128 return rtt; 126 return rtt;
129} 127}
130EXPORT_SYMBOL_GPL(tfrc_tx_hist_rtt);
131 128
132 129
133/* 130/*
@@ -172,7 +169,6 @@ void tfrc_rx_hist_add_packet(struct tfrc_rx_hist *h,
172 169
173 tfrc_rx_hist_entry_from_skb(entry, skb, ndp); 170 tfrc_rx_hist_entry_from_skb(entry, skb, ndp);
174} 171}
175EXPORT_SYMBOL_GPL(tfrc_rx_hist_add_packet);
176 172
177/* has the packet contained in skb been seen before? */ 173/* has the packet contained in skb been seen before? */
178int tfrc_rx_hist_duplicate(struct tfrc_rx_hist *h, struct sk_buff *skb) 174int tfrc_rx_hist_duplicate(struct tfrc_rx_hist *h, struct sk_buff *skb)
@@ -189,7 +185,6 @@ int tfrc_rx_hist_duplicate(struct tfrc_rx_hist *h, struct sk_buff *skb)
189 185
190 return 0; 186 return 0;
191} 187}
192EXPORT_SYMBOL_GPL(tfrc_rx_hist_duplicate);
193 188
194static void tfrc_rx_hist_swap(struct tfrc_rx_hist *h, const u8 a, const u8 b) 189static void tfrc_rx_hist_swap(struct tfrc_rx_hist *h, const u8 a, const u8 b)
195{ 190{
@@ -390,7 +385,6 @@ int tfrc_rx_handle_loss(struct tfrc_rx_hist *h,
390 } 385 }
391 return is_new_loss; 386 return is_new_loss;
392} 387}
393EXPORT_SYMBOL_GPL(tfrc_rx_handle_loss);
394 388
395int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h) 389int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h)
396{ 390{
@@ -412,7 +406,6 @@ out_free:
412 } 406 }
413 return -ENOBUFS; 407 return -ENOBUFS;
414} 408}
415EXPORT_SYMBOL_GPL(tfrc_rx_hist_alloc);
416 409
417void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) 410void tfrc_rx_hist_purge(struct tfrc_rx_hist *h)
418{ 411{
@@ -424,7 +417,6 @@ void tfrc_rx_hist_purge(struct tfrc_rx_hist *h)
424 h->ring[i] = NULL; 417 h->ring[i] = NULL;
425 } 418 }
426} 419}
427EXPORT_SYMBOL_GPL(tfrc_rx_hist_purge);
428 420
429/** 421/**
430 * tfrc_rx_hist_rtt_last_s - reference entry to compute RTT samples against 422 * tfrc_rx_hist_rtt_last_s - reference entry to compute RTT samples against
@@ -495,4 +487,3 @@ keep_ref_for_next_time:
495 487
496 return sample; 488 return sample;
497} 489}
498EXPORT_SYMBOL_GPL(tfrc_rx_hist_sample_rtt);
diff --git a/net/dccp/ccids/lib/tfrc.c b/net/dccp/ccids/lib/tfrc.c
index 185916218e07..60c412ccfeef 100644
--- a/net/dccp/ccids/lib/tfrc.c
+++ b/net/dccp/ccids/lib/tfrc.c
@@ -1,20 +1,18 @@
1/* 1/*
2 * TFRC: main module holding the pieces of the TFRC library together 2 * TFRC library initialisation
3 * 3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2007 Arnaldo Carvalho de Melo <acme@redhat.com> 5 * Copyright (c) 2007 Arnaldo Carvalho de Melo <acme@redhat.com>
6 */ 6 */
7#include <linux/module.h>
8#include <linux/moduleparam.h>
9#include "tfrc.h" 7#include "tfrc.h"
10 8
11#ifdef CONFIG_IP_DCCP_TFRC_DEBUG 9#ifdef CONFIG_IP_DCCP_TFRC_DEBUG
12int tfrc_debug; 10int tfrc_debug;
13module_param(tfrc_debug, bool, 0644); 11module_param(tfrc_debug, bool, 0644);
14MODULE_PARM_DESC(tfrc_debug, "Enable debug messages"); 12MODULE_PARM_DESC(tfrc_debug, "Enable TFRC debug messages");
15#endif 13#endif
16 14
17static int __init tfrc_module_init(void) 15int __init tfrc_lib_init(void)
18{ 16{
19 int rc = tfrc_li_init(); 17 int rc = tfrc_li_init();
20 18
@@ -38,18 +36,9 @@ out:
38 return rc; 36 return rc;
39} 37}
40 38
41static void __exit tfrc_module_exit(void) 39void __exit tfrc_lib_exit(void)
42{ 40{
43 tfrc_rx_packet_history_exit(); 41 tfrc_rx_packet_history_exit();
44 tfrc_tx_packet_history_exit(); 42 tfrc_tx_packet_history_exit();
45 tfrc_li_exit(); 43 tfrc_li_exit();
46} 44}
47
48module_init(tfrc_module_init);
49module_exit(tfrc_module_exit);
50
51MODULE_AUTHOR("Gerrit Renker <gerrit@erg.abdn.ac.uk>, "
52 "Ian McDonald <ian.mcdonald@jandi.co.nz>, "
53 "Arnaldo Carvalho de Melo <acme@redhat.com>");
54MODULE_DESCRIPTION("DCCP TFRC library");
55MODULE_LICENSE("GPL");
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index ed9857527acf..e9720b143275 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -17,7 +17,8 @@
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/math64.h> 18#include <linux/math64.h>
19#include "../../dccp.h" 19#include "../../dccp.h"
20/* internal includes that this module exports: */ 20
21/* internal includes that this library exports: */
21#include "loss_interval.h" 22#include "loss_interval.h"
22#include "packet_history.h" 23#include "packet_history.h"
23 24
@@ -66,4 +67,12 @@ extern void tfrc_rx_packet_history_exit(void);
66 67
67extern int tfrc_li_init(void); 68extern int tfrc_li_init(void);
68extern void tfrc_li_exit(void); 69extern void tfrc_li_exit(void);
70
71#ifdef CONFIG_IP_DCCP_TFRC_LIB
72extern int tfrc_lib_init(void);
73extern void tfrc_lib_exit(void);
74#else
75#define tfrc_lib_init() (0)
76#define tfrc_lib_exit()
77#endif
69#endif /* _TFRC_H_ */ 78#endif /* _TFRC_H_ */
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c
index 2f20a29cffe4..c5d3a9e5a5a4 100644
--- a/net/dccp/ccids/lib/tfrc_equation.c
+++ b/net/dccp/ccids/lib/tfrc_equation.c
@@ -659,8 +659,6 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
659 return scaled_div32(result, f); 659 return scaled_div32(result, f);
660} 660}
661 661
662EXPORT_SYMBOL_GPL(tfrc_calc_x);
663
664/** 662/**
665 * tfrc_calc_x_reverse_lookup - try to find p given f(p) 663 * tfrc_calc_x_reverse_lookup - try to find p given f(p)
666 * 664 *
@@ -693,5 +691,3 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue)
693 index = tfrc_binsearch(fvalue, 0); 691 index = tfrc_binsearch(fvalue, 0);
694 return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE; 692 return (index + 1) * 1000000 / TFRC_CALC_X_ARRSIZE;
695} 693}
696
697EXPORT_SYMBOL_GPL(tfrc_calc_x_reverse_lookup);
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 0bc4c9a02e19..f2230fc168e1 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -432,10 +432,8 @@ static inline int dccp_ack_pending(const struct sock *sk)
432{ 432{
433 const struct dccp_sock *dp = dccp_sk(sk); 433 const struct dccp_sock *dp = dccp_sk(sk);
434 return dp->dccps_timestamp_echo != 0 || 434 return dp->dccps_timestamp_echo != 0 ||
435#ifdef CONFIG_IP_DCCP_ACKVEC
436 (dp->dccps_hc_rx_ackvec != NULL && 435 (dp->dccps_hc_rx_ackvec != NULL &&
437 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) || 436 dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) ||
438#endif
439 inet_csk_ack_scheduled(sk); 437 inet_csk_ack_scheduled(sk);
440} 438}
441 439
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 30f9fb76b921..4152308958ab 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -34,7 +34,7 @@
34static int dccp_hdlr_ccid(struct sock *sk, u64 ccid, bool rx) 34static int dccp_hdlr_ccid(struct sock *sk, u64 ccid, bool rx)
35{ 35{
36 struct dccp_sock *dp = dccp_sk(sk); 36 struct dccp_sock *dp = dccp_sk(sk);
37 struct ccid *new_ccid = ccid_new(ccid, sk, rx, gfp_any()); 37 struct ccid *new_ccid = ccid_new(ccid, sk, rx);
38 38
39 if (new_ccid == NULL) 39 if (new_ccid == NULL)
40 return -ENOMEM; 40 return -ENOMEM;
@@ -1214,8 +1214,6 @@ const char *dccp_feat_typename(const u8 type)
1214 return NULL; 1214 return NULL;
1215} 1215}
1216 1216
1217EXPORT_SYMBOL_GPL(dccp_feat_typename);
1218
1219const char *dccp_feat_name(const u8 feat) 1217const char *dccp_feat_name(const u8 feat)
1220{ 1218{
1221 static const char *feature_names[] = { 1219 static const char *feature_names[] = {
@@ -1240,6 +1238,4 @@ const char *dccp_feat_name(const u8 feat)
1240 1238
1241 return feature_names[feat]; 1239 return feature_names[feat];
1242} 1240}
1243
1244EXPORT_SYMBOL_GPL(dccp_feat_name);
1245#endif /* CONFIG_IP_DCCP_DEBUG */ 1241#endif /* CONFIG_IP_DCCP_DEBUG */
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 5eb443f656c1..7648f316310f 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -741,5 +741,3 @@ u32 dccp_sample_rtt(struct sock *sk, long delta)
741 741
742 return delta; 742 return delta;
743} 743}
744
745EXPORT_SYMBOL_GPL(dccp_sample_rtt);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 1747ccae8e8d..945b4d5d23b3 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1118,9 +1118,15 @@ static int __init dccp_init(void)
1118 if (rc) 1118 if (rc)
1119 goto out_ackvec_exit; 1119 goto out_ackvec_exit;
1120 1120
1121 rc = ccid_initialize_builtins();
1122 if (rc)
1123 goto out_sysctl_exit;
1124
1121 dccp_timestamping_init(); 1125 dccp_timestamping_init();
1122out: 1126out:
1123 return rc; 1127 return rc;
1128out_sysctl_exit:
1129 dccp_sysctl_exit();
1124out_ackvec_exit: 1130out_ackvec_exit:
1125 dccp_ackvec_exit(); 1131 dccp_ackvec_exit();
1126out_free_dccp_mib: 1132out_free_dccp_mib:
@@ -1143,6 +1149,7 @@ out_free_percpu:
1143 1149
1144static void __exit dccp_fini(void) 1150static void __exit dccp_fini(void)
1145{ 1151{
1152 ccid_cleanup_builtins();
1146 dccp_mib_exit(); 1153 dccp_mib_exit();
1147 free_pages((unsigned long)dccp_hashinfo.bhash, 1154 free_pages((unsigned long)dccp_hashinfo.bhash,
1148 get_order(dccp_hashinfo.bhash_size * 1155 get_order(dccp_hashinfo.bhash_size *
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index f28acf11fc67..35bcddf8a932 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -580,10 +580,6 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
580 else if (!ret) { 580 else if (!ret) {
581 if (spliced) 581 if (spliced)
582 break; 582 break;
583 if (flags & SPLICE_F_NONBLOCK) {
584 ret = -EAGAIN;
585 break;
586 }
587 if (sock_flag(sk, SOCK_DONE)) 583 if (sock_flag(sk, SOCK_DONE))
588 break; 584 break;
589 if (sk->sk_err) { 585 if (sk->sk_err) {
@@ -2519,9 +2515,7 @@ found:
2519 flush |= memcmp(th + 1, th2 + 1, thlen - sizeof(*th)); 2515 flush |= memcmp(th + 1, th2 + 1, thlen - sizeof(*th));
2520 2516
2521 total = p->len; 2517 total = p->len;
2522 mss = total; 2518 mss = skb_shinfo(p)->gso_size;
2523 if (skb_shinfo(p)->frag_list)
2524 mss = skb_shinfo(p)->frag_list->len;
2525 2519
2526 flush |= skb->len > mss || skb->len <= 0; 2520 flush |= skb->len > mss || skb->len <= 0;
2527 flush |= ntohl(th2->seq) + total != ntohl(th->seq); 2521 flush |= ntohl(th2->seq) + total != ntohl(th->seq);
@@ -2557,7 +2551,6 @@ int tcp_gro_complete(struct sk_buff *skb)
2557 skb->csum_offset = offsetof(struct tcphdr, check); 2551 skb->csum_offset = offsetof(struct tcphdr, check);
2558 skb->ip_summed = CHECKSUM_PARTIAL; 2552 skb->ip_summed = CHECKSUM_PARTIAL;
2559 2553
2560 skb_shinfo(skb)->gso_size = skb_shinfo(skb)->frag_list->len;
2561 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; 2554 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
2562 2555
2563 if (th->cwr) 2556 if (th->cwr)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index eeeaad2e8b5c..40f324655e24 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -404,7 +404,7 @@ sticky_done:
404 else if (optlen < sizeof(struct in6_pktinfo) || optval == NULL) 404 else if (optlen < sizeof(struct in6_pktinfo) || optval == NULL)
405 goto e_inval; 405 goto e_inval;
406 406
407 if (copy_from_user(&pkt, optval, optlen)) { 407 if (copy_from_user(&pkt, optval, sizeof(struct in6_pktinfo))) {
408 retv = -EFAULT; 408 retv = -EFAULT;
409 break; 409 break;
410 } 410 }
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 18c486cf4987..76f06b94ab9f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -627,6 +627,9 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *dad
627 rt = ip6_rt_copy(ort); 627 rt = ip6_rt_copy(ort);
628 628
629 if (rt) { 629 if (rt) {
630 struct neighbour *neigh;
631 int attempts = !in_softirq();
632
630 if (!(rt->rt6i_flags&RTF_GATEWAY)) { 633 if (!(rt->rt6i_flags&RTF_GATEWAY)) {
631 if (rt->rt6i_dst.plen != 128 && 634 if (rt->rt6i_dst.plen != 128 &&
632 ipv6_addr_equal(&rt->rt6i_dst.addr, daddr)) 635 ipv6_addr_equal(&rt->rt6i_dst.addr, daddr))
@@ -646,7 +649,35 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *dad
646 } 649 }
647#endif 650#endif
648 651
649 rt->rt6i_nexthop = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway); 652 retry:
653 neigh = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway);
654 if (IS_ERR(neigh)) {
655 struct net *net = dev_net(rt->rt6i_dev);
656 int saved_rt_min_interval =
657 net->ipv6.sysctl.ip6_rt_gc_min_interval;
658 int saved_rt_elasticity =
659 net->ipv6.sysctl.ip6_rt_gc_elasticity;
660
661 if (attempts-- > 0) {
662 net->ipv6.sysctl.ip6_rt_gc_elasticity = 1;
663 net->ipv6.sysctl.ip6_rt_gc_min_interval = 0;
664
665 ip6_dst_gc(net->ipv6.ip6_dst_ops);
666
667 net->ipv6.sysctl.ip6_rt_gc_elasticity =
668 saved_rt_elasticity;
669 net->ipv6.sysctl.ip6_rt_gc_min_interval =
670 saved_rt_min_interval;
671 goto retry;
672 }
673
674 if (net_ratelimit())
675 printk(KERN_WARNING
676 "Neighbour table overflow.\n");
677 dst_free(&rt->u.dst);
678 return NULL;
679 }
680 rt->rt6i_nexthop = neigh;
650 681
651 } 682 }
652 683
@@ -945,8 +976,11 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
945 dev_hold(dev); 976 dev_hold(dev);
946 if (neigh) 977 if (neigh)
947 neigh_hold(neigh); 978 neigh_hold(neigh);
948 else 979 else {
949 neigh = ndisc_get_neigh(dev, addr); 980 neigh = ndisc_get_neigh(dev, addr);
981 if (IS_ERR(neigh))
982 neigh = NULL;
983 }
950 984
951 rt->rt6i_dev = dev; 985 rt->rt6i_dev = dev;
952 rt->rt6i_idev = idev; 986 rt->rt6i_idev = idev;
@@ -1887,6 +1921,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
1887{ 1921{
1888 struct net *net = dev_net(idev->dev); 1922 struct net *net = dev_net(idev->dev);
1889 struct rt6_info *rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops); 1923 struct rt6_info *rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops);
1924 struct neighbour *neigh;
1890 1925
1891 if (rt == NULL) 1926 if (rt == NULL)
1892 return ERR_PTR(-ENOMEM); 1927 return ERR_PTR(-ENOMEM);
@@ -1909,11 +1944,18 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
1909 rt->rt6i_flags |= RTF_ANYCAST; 1944 rt->rt6i_flags |= RTF_ANYCAST;
1910 else 1945 else
1911 rt->rt6i_flags |= RTF_LOCAL; 1946 rt->rt6i_flags |= RTF_LOCAL;
1912 rt->rt6i_nexthop = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway); 1947 neigh = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway);
1913 if (rt->rt6i_nexthop == NULL) { 1948 if (IS_ERR(neigh)) {
1914 dst_free(&rt->u.dst); 1949 dst_free(&rt->u.dst);
1915 return ERR_PTR(-ENOMEM); 1950
1951 /* We are casting this because that is the return
1952 * value type. But an errno encoded pointer is the
1953 * same regardless of the underlying pointer type,
1954 * and that's what we are returning. So this is OK.
1955 */
1956 return (struct rt6_info *) neigh;
1916 } 1957 }
1958 rt->rt6i_nexthop = neigh;
1917 1959
1918 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 1960 ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
1919 rt->rt6i_dst.plen = 128; 1961 rt->rt6i_dst.plen = 128;
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index af3192d2a5a3..eb8a2a0b6eb7 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -494,7 +494,21 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
494 if (err) { 494 if (err) {
495 iucv_path_free(iucv->path); 495 iucv_path_free(iucv->path);
496 iucv->path = NULL; 496 iucv->path = NULL;
497 err = -ECONNREFUSED; 497 switch (err) {
498 case 0x0b: /* Target communicator is not logged on */
499 err = -ENETUNREACH;
500 break;
501 case 0x0d: /* Max connections for this guest exceeded */
502 case 0x0e: /* Max connections for target guest exceeded */
503 err = -EAGAIN;
504 break;
505 case 0x0f: /* Missing IUCV authorization */
506 err = -EACCES;
507 break;
508 default:
509 err = -ECONNREFUSED;
510 break;
511 }
498 goto done; 512 goto done;
499 } 513 }
500 514
@@ -507,6 +521,13 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
507 release_sock(sk); 521 release_sock(sk);
508 return -ECONNREFUSED; 522 return -ECONNREFUSED;
509 } 523 }
524
525 if (err) {
526 iucv_path_sever(iucv->path, NULL);
527 iucv_path_free(iucv->path);
528 iucv->path = NULL;
529 }
530
510done: 531done:
511 release_sock(sk); 532 release_sock(sk);
512 return err; 533 return err;
@@ -1021,12 +1042,14 @@ static int iucv_callback_connreq(struct iucv_path *path,
1021 ASCEBC(user_data, sizeof(user_data)); 1042 ASCEBC(user_data, sizeof(user_data));
1022 if (sk->sk_state != IUCV_LISTEN) { 1043 if (sk->sk_state != IUCV_LISTEN) {
1023 err = iucv_path_sever(path, user_data); 1044 err = iucv_path_sever(path, user_data);
1045 iucv_path_free(path);
1024 goto fail; 1046 goto fail;
1025 } 1047 }
1026 1048
1027 /* Check for backlog size */ 1049 /* Check for backlog size */
1028 if (sk_acceptq_is_full(sk)) { 1050 if (sk_acceptq_is_full(sk)) {
1029 err = iucv_path_sever(path, user_data); 1051 err = iucv_path_sever(path, user_data);
1052 iucv_path_free(path);
1030 goto fail; 1053 goto fail;
1031 } 1054 }
1032 1055
@@ -1034,6 +1057,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
1034 nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC); 1057 nsk = iucv_sock_alloc(NULL, SOCK_STREAM, GFP_ATOMIC);
1035 if (!nsk) { 1058 if (!nsk) {
1036 err = iucv_path_sever(path, user_data); 1059 err = iucv_path_sever(path, user_data);
1060 iucv_path_free(path);
1037 goto fail; 1061 goto fail;
1038 } 1062 }
1039 1063
@@ -1057,6 +1081,8 @@ static int iucv_callback_connreq(struct iucv_path *path,
1057 err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk); 1081 err = iucv_path_accept(path, &af_iucv_handler, nuser_data, nsk);
1058 if (err) { 1082 if (err) {
1059 err = iucv_path_sever(path, user_data); 1083 err = iucv_path_sever(path, user_data);
1084 iucv_path_free(path);
1085 iucv_sock_kill(nsk);
1060 goto fail; 1086 goto fail;
1061 } 1087 }
1062 1088
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 8f57d4f4328a..032f61e98595 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -517,6 +517,7 @@ static int iucv_enable(void)
517 size_t alloc_size; 517 size_t alloc_size;
518 int cpu, rc; 518 int cpu, rc;
519 519
520 get_online_cpus();
520 rc = -ENOMEM; 521 rc = -ENOMEM;
521 alloc_size = iucv_max_pathid * sizeof(struct iucv_path); 522 alloc_size = iucv_max_pathid * sizeof(struct iucv_path);
522 iucv_path_table = kzalloc(alloc_size, GFP_KERNEL); 523 iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
@@ -524,19 +525,17 @@ static int iucv_enable(void)
524 goto out; 525 goto out;
525 /* Declare per cpu buffers. */ 526 /* Declare per cpu buffers. */
526 rc = -EIO; 527 rc = -EIO;
527 get_online_cpus();
528 for_each_online_cpu(cpu) 528 for_each_online_cpu(cpu)
529 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1); 529 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
530 if (cpus_empty(iucv_buffer_cpumask)) 530 if (cpus_empty(iucv_buffer_cpumask))
531 /* No cpu could declare an iucv buffer. */ 531 /* No cpu could declare an iucv buffer. */
532 goto out_path; 532 goto out;
533 put_online_cpus(); 533 put_online_cpus();
534 return 0; 534 return 0;
535
536out_path:
537 put_online_cpus();
538 kfree(iucv_path_table);
539out: 535out:
536 kfree(iucv_path_table);
537 iucv_path_table = NULL;
538 put_online_cpus();
540 return rc; 539 return rc;
541} 540}
542 541
@@ -551,8 +550,9 @@ static void iucv_disable(void)
551{ 550{
552 get_online_cpus(); 551 get_online_cpus();
553 on_each_cpu(iucv_retrieve_cpu, NULL, 1); 552 on_each_cpu(iucv_retrieve_cpu, NULL, 1);
554 put_online_cpus();
555 kfree(iucv_path_table); 553 kfree(iucv_path_table);
554 iucv_path_table = NULL;
555 put_online_cpus();
556} 556}
557 557
558static int __cpuinit iucv_cpu_notify(struct notifier_block *self, 558static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
@@ -589,10 +589,14 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
589 case CPU_ONLINE_FROZEN: 589 case CPU_ONLINE_FROZEN:
590 case CPU_DOWN_FAILED: 590 case CPU_DOWN_FAILED:
591 case CPU_DOWN_FAILED_FROZEN: 591 case CPU_DOWN_FAILED_FROZEN:
592 if (!iucv_path_table)
593 break;
592 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1); 594 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
593 break; 595 break;
594 case CPU_DOWN_PREPARE: 596 case CPU_DOWN_PREPARE:
595 case CPU_DOWN_PREPARE_FROZEN: 597 case CPU_DOWN_PREPARE_FROZEN:
598 if (!iucv_path_table)
599 break;
596 cpumask = iucv_buffer_cpumask; 600 cpumask = iucv_buffer_cpumask;
597 cpu_clear(cpu, cpumask); 601 cpu_clear(cpu, cpumask);
598 if (cpus_empty(cpumask)) 602 if (cpus_empty(cpumask))
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index 3c94f76d5525..3eaa39403c13 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -54,10 +54,10 @@ static unsigned long rfkill_states_lockdflt[BITS_TO_LONGS(RFKILL_TYPE_MAX)];
54static bool rfkill_epo_lock_active; 54static bool rfkill_epo_lock_active;
55 55
56 56
57#ifdef CONFIG_RFKILL_LEDS
57static void rfkill_led_trigger(struct rfkill *rfkill, 58static void rfkill_led_trigger(struct rfkill *rfkill,
58 enum rfkill_state state) 59 enum rfkill_state state)
59{ 60{
60#ifdef CONFIG_RFKILL_LEDS
61 struct led_trigger *led = &rfkill->led_trigger; 61 struct led_trigger *led = &rfkill->led_trigger;
62 62
63 if (!led->name) 63 if (!led->name)
@@ -66,10 +66,8 @@ static void rfkill_led_trigger(struct rfkill *rfkill,
66 led_trigger_event(led, LED_OFF); 66 led_trigger_event(led, LED_OFF);
67 else 67 else
68 led_trigger_event(led, LED_FULL); 68 led_trigger_event(led, LED_FULL);
69#endif /* CONFIG_RFKILL_LEDS */
70} 69}
71 70
72#ifdef CONFIG_RFKILL_LEDS
73static void rfkill_led_trigger_activate(struct led_classdev *led) 71static void rfkill_led_trigger_activate(struct led_classdev *led)
74{ 72{
75 struct rfkill *rfkill = container_of(led->trigger, 73 struct rfkill *rfkill = container_of(led->trigger,
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 05d178008cbc..07372f60bee3 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -638,8 +638,9 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
638 break; 638 break;
639 639
640 n->next = *ins; 640 n->next = *ins;
641 wmb(); 641 tcf_tree_lock(tp);
642 *ins = n; 642 *ins = n;
643 tcf_tree_unlock(tp);
643 644
644 *arg = (unsigned long)n; 645 *arg = (unsigned long)n;
645 return 0; 646 return 0;
diff --git a/net/socket.c b/net/socket.c
index 2c730fc718ab..06603d73c411 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1313,13 +1313,7 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
1313 goto out_fd1; 1313 goto out_fd1;
1314 } 1314 }
1315 1315
1316 err = audit_fd_pair(fd1, fd2); 1316 audit_fd_pair(fd1, fd2);
1317 if (err < 0) {
1318 fput(newfile1);
1319 fput(newfile2);
1320 goto out_fd;
1321 }
1322
1323 fd_install(fd1, newfile1); 1317 fd_install(fd1, newfile1);
1324 fd_install(fd2, newfile2); 1318 fd_install(fd2, newfile2);
1325 /* fd1 and fd2 may be already another descriptors. 1319 /* fd1 and fd2 may be already another descriptors.
@@ -1349,7 +1343,6 @@ out_fd2:
1349out_fd1: 1343out_fd1:
1350 put_filp(newfile2); 1344 put_filp(newfile2);
1351 sock_release(sock2); 1345 sock_release(sock2);
1352out_fd:
1353 put_unused_fd(fd1); 1346 put_unused_fd(fd1);
1354 put_unused_fd(fd2); 1347 put_unused_fd(fd2);
1355 goto out; 1348 goto out;
@@ -2065,9 +2058,7 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2065 if (copy_from_user(a, args, nargs[call])) 2058 if (copy_from_user(a, args, nargs[call]))
2066 return -EFAULT; 2059 return -EFAULT;
2067 2060
2068 err = audit_socketcall(nargs[call] / sizeof(unsigned long), a); 2061 audit_socketcall(nargs[call] / sizeof(unsigned long), a);
2069 if (err)
2070 return err;
2071 2062
2072 a0 = a[0]; 2063 a0 = a[0];
2073 a1 = a[1]; 2064 a1 = a[1];
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 192453248870..577385a4a5dc 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -522,8 +522,6 @@ rpc_get_inode(struct super_block *sb, int mode)
522 if (!inode) 522 if (!inode)
523 return NULL; 523 return NULL;
524 inode->i_mode = mode; 524 inode->i_mode = mode;
525 inode->i_uid = inode->i_gid = 0;
526 inode->i_blocks = 0;
527 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 525 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
528 switch(mode & S_IFMT) { 526 switch(mode & S_IFMT) {
529 case S_IFDIR: 527 case S_IFDIR:
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index 488a3b1f760f..db30fac3083e 100644
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -14,7 +14,9 @@
14# Only include files located in asm* and linux* are checked. 14# Only include files located in asm* and linux* are checked.
15# The rest are assumed to be system include files. 15# The rest are assumed to be system include files.
16# 16#
17# 2) TODO: check for leaked CONFIG_ symbols 17# 2) It is checked that prototypes does not use "extern"
18#
19# 3) Check for leaked CONFIG_ symbols
18 20
19use strict; 21use strict;
20 22
@@ -32,7 +34,11 @@ foreach my $file (@files) {
32 $lineno = 0; 34 $lineno = 0;
33 while ($line = <FH>) { 35 while ($line = <FH>) {
34 $lineno++; 36 $lineno++;
35 check_include(); 37 &check_include();
38 &check_asm_types();
39 &check_sizetypes();
40 &check_prototypes();
41 &check_config();
36 } 42 }
37 close FH; 43 close FH;
38} 44}
@@ -54,3 +60,63 @@ sub check_include
54 } 60 }
55 } 61 }
56} 62}
63
64sub check_prototypes
65{
66 if ($line =~ m/^\s*extern\b/) {
67 printf STDERR "$filename:$lineno: extern's make no sense in userspace\n";
68 }
69}
70
71sub check_config
72{
73 if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9]+)[^a-zA-Z0-9]/) {
74 printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n";
75 }
76}
77
78my $linux_asm_types;
79sub check_asm_types()
80{
81 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
82 return;
83 }
84 if ($lineno == 1) {
85 $linux_asm_types = 0;
86 } elsif ($linux_asm_types >= 1) {
87 return;
88 }
89 if ($line =~ m/^\s*#\s*include\s+<asm\/types.h>/) {
90 $linux_asm_types = 1;
91 printf STDERR "$filename:$lineno: " .
92 "include of <linux/types.h> is preferred over <asm/types.h>\n"
93 # Warn until headers are all fixed
94 #$ret = 1;
95 }
96}
97
98my $linux_types;
99sub check_sizetypes
100{
101 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
102 return;
103 }
104 if ($lineno == 1) {
105 $linux_types = 0;
106 } elsif ($linux_types >= 1) {
107 return;
108 }
109 if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) {
110 $linux_types = 1;
111 return;
112 }
113 if ($line =~ m/__[us](8|16|32|64)\b/) {
114 printf STDERR "$filename:$lineno: " .
115 "found __[us]{8,16,32,64} type " .
116 "without #include <linux/types.h>\n";
117 $linux_types = 2;
118 # Warn until headers are all fixed
119 #$ret = 1;
120 }
121}
122
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index 7d2b4146e02f..c6ae4052ab43 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -36,6 +36,9 @@ foreach my $file (@files) {
36 $line =~ s/\s__attribute_const__\s/ /g; 36 $line =~ s/\s__attribute_const__\s/ /g;
37 $line =~ s/\s__attribute_const__$//g; 37 $line =~ s/\s__attribute_const__$//g;
38 $line =~ s/^#include <linux\/compiler.h>//; 38 $line =~ s/^#include <linux\/compiler.h>//;
39 $line =~ s/(^|\s)(inline)\b/$1__$2__/g;
40 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
41 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
39 printf OUTFILE "%s", $line; 42 printf OUTFILE "%s", $line;
40 } 43 }
41 close OUTFILE; 44 close OUTFILE;
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 9d4cba1c001d..6408fefae083 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -65,9 +65,13 @@ enum symbol_type {
65 S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER 65 S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
66}; 66};
67 67
68/* enum values are used as index to symbol.def[] */
68enum { 69enum {
69 S_DEF_USER, /* main user value */ 70 S_DEF_USER, /* main user value */
70 S_DEF_AUTO, 71 S_DEF_AUTO, /* values read from auto.conf */
72 S_DEF_DEF3, /* Reserved for UI usage */
73 S_DEF_DEF4, /* Reserved for UI usage */
74 S_DEF_COUNT
71}; 75};
72 76
73struct symbol { 77struct symbol {
@@ -75,7 +79,7 @@ struct symbol {
75 char *name; 79 char *name;
76 enum symbol_type type; 80 enum symbol_type type;
77 struct symbol_value curr; 81 struct symbol_value curr;
78 struct symbol_value def[4]; 82 struct symbol_value def[S_DEF_COUNT];
79 tristate visible; 83 tristate visible;
80 int flags; 84 int flags;
81 struct property *prop; 85 struct property *prop;
@@ -84,42 +88,64 @@ struct symbol {
84 88
85#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) 89#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
86 90
87#define SYMBOL_CONST 0x0001 91#define SYMBOL_CONST 0x0001 /* symbol is const */
88#define SYMBOL_CHECK 0x0008 92#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
89#define SYMBOL_CHOICE 0x0010 93#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
90#define SYMBOL_CHOICEVAL 0x0020 94#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
91#define SYMBOL_VALID 0x0080 95#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
92#define SYMBOL_OPTIONAL 0x0100 96#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
93#define SYMBOL_WRITE 0x0200 97#define SYMBOL_WRITE 0x0200 /* ? */
94#define SYMBOL_CHANGED 0x0400 98#define SYMBOL_CHANGED 0x0400 /* ? */
95#define SYMBOL_AUTO 0x1000 99#define SYMBOL_AUTO 0x1000 /* value from environment variable */
96#define SYMBOL_CHECKED 0x2000 100#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
97#define SYMBOL_WARNED 0x8000 101#define SYMBOL_WARNED 0x8000 /* warning has been issued */
98#define SYMBOL_DEF 0x10000 102
99#define SYMBOL_DEF_USER 0x10000 103/* Set when symbol.def[] is used */
100#define SYMBOL_DEF_AUTO 0x20000 104#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */
101#define SYMBOL_DEF3 0x40000 105#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */
102#define SYMBOL_DEF4 0x80000 106#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */
107#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
108#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
103 109
104#define SYMBOL_MAXLENGTH 256 110#define SYMBOL_MAXLENGTH 256
105#define SYMBOL_HASHSIZE 257 111#define SYMBOL_HASHSIZE 257
106#define SYMBOL_HASHMASK 0xff 112#define SYMBOL_HASHMASK 0xff
107 113
114/* A property represent the config options that can be associated
115 * with a config "symbol".
116 * Sample:
117 * config FOO
118 * default y
119 * prompt "foo prompt"
120 * select BAR
121 * config BAZ
122 * int "BAZ Value"
123 * range 1..255
124 */
108enum prop_type { 125enum prop_type {
109 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, 126 P_UNKNOWN,
110 P_SELECT, P_RANGE, P_ENV 127 P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
128 P_COMMENT, /* text associated with a comment */
129 P_MENU, /* prompt associated with a menuconfig option */
130 P_DEFAULT, /* default y */
131 P_CHOICE, /* choice value */
132 P_SELECT, /* select BAR */
133 P_RANGE, /* range 7..100 (for a symbol) */
134 P_ENV, /* value from environment variable */
111}; 135};
112 136
113struct property { 137struct property {
114 struct property *next; 138 struct property *next; /* next property - null if last */
115 struct symbol *sym; 139 struct symbol *sym; /* the symbol for which the property is associated */
116 enum prop_type type; 140 enum prop_type type; /* type of property */
117 const char *text; 141 const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
118 struct expr_value visible; 142 struct expr_value visible;
119 struct expr *expr; 143 struct expr *expr; /* the optional conditional part of the property */
120 struct menu *menu; 144 struct menu *menu; /* the menu the property are associated with
121 struct file *file; 145 * valid for: P_SELECT, P_RANGE, P_CHOICE,
122 int lineno; 146 * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
147 struct file *file; /* what file was this property defined */
148 int lineno; /* what lineno was this property defined */
123}; 149};
124 150
125#define for_all_properties(sym, st, tok) \ 151#define for_all_properties(sym, st, tok) \
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index 7342ce0a7780..dc3e81807d13 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -2370,11 +2370,14 @@ void zconf_nextfile(const char *name)
2370 current_buf = buf; 2370 current_buf = buf;
2371 2371
2372 if (file->flags & FILE_BUSY) { 2372 if (file->flags & FILE_BUSY) {
2373 printf("recursive scan (%s)?\n", name); 2373 printf("%s:%d: do not source '%s' from itself\n",
2374 zconf_curname(), zconf_lineno(), name);
2374 exit(1); 2375 exit(1);
2375 } 2376 }
2376 if (file->flags & FILE_SCANNED) { 2377 if (file->flags & FILE_SCANNED) {
2377 printf("file %s already scanned?\n", name); 2378 printf("%s:%d: file '%s' is already sourced from '%s'\n",
2379 zconf_curname(), zconf_lineno(), name,
2380 file->parent->name);
2378 exit(1); 2381 exit(1);
2379 } 2382 }
2380 file->flags |= FILE_BUSY; 2383 file->flags |= FILE_BUSY;
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 5164ef7ce499..21ff69c9ad4e 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -314,11 +314,14 @@ void zconf_nextfile(const char *name)
314 current_buf = buf; 314 current_buf = buf;
315 315
316 if (file->flags & FILE_BUSY) { 316 if (file->flags & FILE_BUSY) {
317 printf("recursive scan (%s)?\n", name); 317 printf("%s:%d: do not source '%s' from itself\n",
318 zconf_curname(), zconf_lineno(), name);
318 exit(1); 319 exit(1);
319 } 320 }
320 if (file->flags & FILE_SCANNED) { 321 if (file->flags & FILE_SCANNED) {
321 printf("file %s already scanned?\n", name); 322 printf("%s:%d: file '%s' is already sourced from '%s'\n",
323 zconf_curname(), zconf_lineno(), name,
324 file->parent->name);
322 exit(1); 325 exit(1);
323 } 326 }
324 file->flags |= FILE_BUSY; 327 file->flags |= FILE_BUSY;
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 4e7547209852..9e3451d2c3a1 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -84,7 +84,6 @@ docscope()
84 84
85exuberant() 85exuberant()
86{ 86{
87 all_sources > all
88 all_sources | xargs $1 -a \ 87 all_sources | xargs $1 -a \
89 -I __initdata,__exitdata,__acquires,__releases \ 88 -I __initdata,__exitdata,__acquires,__releases \
90 -I __read_mostly,____cacheline_aligned \ 89 -I __read_mostly,____cacheline_aligned \
diff --git a/security/commoncap.c b/security/commoncap.c
index 79713545cd63..69fc9952650f 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -238,7 +238,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
238 struct inode *inode = dentry->d_inode; 238 struct inode *inode = dentry->d_inode;
239 int error; 239 int error;
240 240
241 if (!inode->i_op || !inode->i_op->getxattr) 241 if (!inode->i_op->getxattr)
242 return 0; 242 return 0;
243 243
244 error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); 244 error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
@@ -259,7 +259,7 @@ int cap_inode_killpriv(struct dentry *dentry)
259{ 259{
260 struct inode *inode = dentry->d_inode; 260 struct inode *inode = dentry->d_inode;
261 261
262 if (!inode->i_op || !inode->i_op->removexattr) 262 if (!inode->i_op->removexattr)
263 return 0; 263 return 0;
264 264
265 return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); 265 return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS);
@@ -317,7 +317,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
317 317
318 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); 318 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data));
319 319
320 if (!inode || !inode->i_op || !inode->i_op->getxattr) 320 if (!inode || !inode->i_op->getxattr)
321 return -ENODATA; 321 return -ENODATA;
322 322
323 size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps, 323 size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps,
diff --git a/security/inode.c b/security/inode.c
index efea5a605466..007ef252dde7 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -61,9 +61,6 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
61 61
62 if (inode) { 62 if (inode) {
63 inode->i_mode = mode; 63 inode->i_mode = mode;
64 inode->i_uid = 0;
65 inode->i_gid = 0;
66 inode->i_blocks = 0;
67 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 64 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
68 switch (mode & S_IFMT) { 65 switch (mode & S_IFMT) {
69 default: 66 default:
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index c86303638235..8f612c8becb5 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -847,8 +847,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
847 847
848 if (ret) { 848 if (ret) {
849 ret->i_mode = mode; 849 ret->i_mode = mode;
850 ret->i_uid = ret->i_gid = 0;
851 ret->i_blocks = 0;
852 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 850 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
853 } 851 }
854 return ret; 852 return ret;
@@ -1211,7 +1209,7 @@ static struct avc_cache_stats *sel_avc_get_stat_idx(loff_t *idx)
1211{ 1209{
1212 int cpu; 1210 int cpu;
1213 1211
1214 for (cpu = *idx; cpu < NR_CPUS; ++cpu) { 1212 for (cpu = *idx; cpu < nr_cpu_ids; ++cpu) {
1215 if (!cpu_possible(cpu)) 1213 if (!cpu_possible(cpu))
1216 continue; 1214 continue;
1217 *idx = cpu + 1; 1215 *idx = cpu + 1;
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 343c8ab14af0..c65e4fe4a0f1 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2602,7 +2602,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
2602 case AUDIT_OBJ_ROLE: 2602 case AUDIT_OBJ_ROLE:
2603 case AUDIT_OBJ_TYPE: 2603 case AUDIT_OBJ_TYPE:
2604 /* only 'equals' and 'not equals' fit user, role, and type */ 2604 /* only 'equals' and 'not equals' fit user, role, and type */
2605 if (op != AUDIT_EQUAL && op != AUDIT_NOT_EQUAL) 2605 if (op != Audit_equal && op != Audit_not_equal)
2606 return -EINVAL; 2606 return -EINVAL;
2607 break; 2607 break;
2608 case AUDIT_SUBJ_SEN: 2608 case AUDIT_SUBJ_SEN:
@@ -2736,10 +2736,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
2736 case AUDIT_SUBJ_USER: 2736 case AUDIT_SUBJ_USER:
2737 case AUDIT_OBJ_USER: 2737 case AUDIT_OBJ_USER:
2738 switch (op) { 2738 switch (op) {
2739 case AUDIT_EQUAL: 2739 case Audit_equal:
2740 match = (ctxt->user == rule->au_ctxt.user); 2740 match = (ctxt->user == rule->au_ctxt.user);
2741 break; 2741 break;
2742 case AUDIT_NOT_EQUAL: 2742 case Audit_not_equal:
2743 match = (ctxt->user != rule->au_ctxt.user); 2743 match = (ctxt->user != rule->au_ctxt.user);
2744 break; 2744 break;
2745 } 2745 }
@@ -2747,10 +2747,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
2747 case AUDIT_SUBJ_ROLE: 2747 case AUDIT_SUBJ_ROLE:
2748 case AUDIT_OBJ_ROLE: 2748 case AUDIT_OBJ_ROLE:
2749 switch (op) { 2749 switch (op) {
2750 case AUDIT_EQUAL: 2750 case Audit_equal:
2751 match = (ctxt->role == rule->au_ctxt.role); 2751 match = (ctxt->role == rule->au_ctxt.role);
2752 break; 2752 break;
2753 case AUDIT_NOT_EQUAL: 2753 case Audit_not_equal:
2754 match = (ctxt->role != rule->au_ctxt.role); 2754 match = (ctxt->role != rule->au_ctxt.role);
2755 break; 2755 break;
2756 } 2756 }
@@ -2758,10 +2758,10 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
2758 case AUDIT_SUBJ_TYPE: 2758 case AUDIT_SUBJ_TYPE:
2759 case AUDIT_OBJ_TYPE: 2759 case AUDIT_OBJ_TYPE:
2760 switch (op) { 2760 switch (op) {
2761 case AUDIT_EQUAL: 2761 case Audit_equal:
2762 match = (ctxt->type == rule->au_ctxt.type); 2762 match = (ctxt->type == rule->au_ctxt.type);
2763 break; 2763 break;
2764 case AUDIT_NOT_EQUAL: 2764 case Audit_not_equal:
2765 match = (ctxt->type != rule->au_ctxt.type); 2765 match = (ctxt->type != rule->au_ctxt.type);
2766 break; 2766 break;
2767 } 2767 }
@@ -2774,31 +2774,31 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
2774 field == AUDIT_OBJ_LEV_LOW) ? 2774 field == AUDIT_OBJ_LEV_LOW) ?
2775 &ctxt->range.level[0] : &ctxt->range.level[1]); 2775 &ctxt->range.level[0] : &ctxt->range.level[1]);
2776 switch (op) { 2776 switch (op) {
2777 case AUDIT_EQUAL: 2777 case Audit_equal:
2778 match = mls_level_eq(&rule->au_ctxt.range.level[0], 2778 match = mls_level_eq(&rule->au_ctxt.range.level[0],
2779 level); 2779 level);
2780 break; 2780 break;
2781 case AUDIT_NOT_EQUAL: 2781 case Audit_not_equal:
2782 match = !mls_level_eq(&rule->au_ctxt.range.level[0], 2782 match = !mls_level_eq(&rule->au_ctxt.range.level[0],
2783 level); 2783 level);
2784 break; 2784 break;
2785 case AUDIT_LESS_THAN: 2785 case Audit_lt:
2786 match = (mls_level_dom(&rule->au_ctxt.range.level[0], 2786 match = (mls_level_dom(&rule->au_ctxt.range.level[0],
2787 level) && 2787 level) &&
2788 !mls_level_eq(&rule->au_ctxt.range.level[0], 2788 !mls_level_eq(&rule->au_ctxt.range.level[0],
2789 level)); 2789 level));
2790 break; 2790 break;
2791 case AUDIT_LESS_THAN_OR_EQUAL: 2791 case Audit_le:
2792 match = mls_level_dom(&rule->au_ctxt.range.level[0], 2792 match = mls_level_dom(&rule->au_ctxt.range.level[0],
2793 level); 2793 level);
2794 break; 2794 break;
2795 case AUDIT_GREATER_THAN: 2795 case Audit_gt:
2796 match = (mls_level_dom(level, 2796 match = (mls_level_dom(level,
2797 &rule->au_ctxt.range.level[0]) && 2797 &rule->au_ctxt.range.level[0]) &&
2798 !mls_level_eq(level, 2798 !mls_level_eq(level,
2799 &rule->au_ctxt.range.level[0])); 2799 &rule->au_ctxt.range.level[0]));
2800 break; 2800 break;
2801 case AUDIT_GREATER_THAN_OR_EQUAL: 2801 case Audit_ge:
2802 match = mls_level_dom(level, 2802 match = mls_level_dom(level,
2803 &rule->au_ctxt.range.level[0]); 2803 &rule->au_ctxt.range.level[0]);
2804 break; 2804 break;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 1b5551dfc1f7..848212fd4845 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2492,7 +2492,7 @@ static int smack_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
2492 if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) 2492 if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER)
2493 return -EINVAL; 2493 return -EINVAL;
2494 2494
2495 if (op != AUDIT_EQUAL && op != AUDIT_NOT_EQUAL) 2495 if (op != Audit_equal && op != Audit_not_equal)
2496 return -EINVAL; 2496 return -EINVAL;
2497 2497
2498 *rule = smk_import(rulestr, 0); 2498 *rule = smk_import(rulestr, 0);
@@ -2556,9 +2556,9 @@ static int smack_audit_rule_match(u32 secid, u32 field, u32 op, void *vrule,
2556 * both pointers will point to the same smack_known 2556 * both pointers will point to the same smack_known
2557 * label. 2557 * label.
2558 */ 2558 */
2559 if (op == AUDIT_EQUAL) 2559 if (op == Audit_equal)
2560 return (rule == smack); 2560 return (rule == smack);
2561 if (op == AUDIT_NOT_EQUAL) 2561 if (op == Audit_not_equal)
2562 return (rule != smack); 2562 return (rule != smack);
2563 2563
2564 return 0; 2564 return 0;
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 549b4eba1496..9d98a6658ac9 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -84,7 +84,7 @@ static void snd_tea575x_set_freq(struct snd_tea575x *tea)
84 * Linux Video interface 84 * Linux Video interface
85 */ 85 */
86 86
87static int snd_tea575x_ioctl(struct inode *inode, struct file *file, 87static long snd_tea575x_ioctl(struct file *file,
88 unsigned int cmd, unsigned long data) 88 unsigned int cmd, unsigned long data)
89{ 89{
90 struct snd_tea575x *tea = video_drvdata(file); 90 struct snd_tea575x *tea = video_drvdata(file);
@@ -174,14 +174,14 @@ static void snd_tea575x_release(struct video_device *vfd)
174{ 174{
175} 175}
176 176
177static int snd_tea575x_exclusive_open(struct inode *inode, struct file *file) 177static int snd_tea575x_exclusive_open(struct file *file)
178{ 178{
179 struct snd_tea575x *tea = video_drvdata(file); 179 struct snd_tea575x *tea = video_drvdata(file);
180 180
181 return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0; 181 return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0;
182} 182}
183 183
184static int snd_tea575x_exclusive_release(struct inode *inode, struct file *file) 184static int snd_tea575x_exclusive_release(struct file *file)
185{ 185{
186 struct snd_tea575x *tea = video_drvdata(file); 186 struct snd_tea575x *tea = video_drvdata(file);
187 187
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index b20e1cede00b..75de40aaab0a 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -25,6 +25,8 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <sound/core.h> 27#include <sound/core.h>
28#include <sound/jack.h>
29
28#include "hda_codec.h" 30#include "hda_codec.h"
29#include "hda_local.h" 31#include "hda_local.h"
30 32
@@ -37,8 +39,21 @@
37#define CONEXANT_HP_EVENT 0x37 39#define CONEXANT_HP_EVENT 0x37
38#define CONEXANT_MIC_EVENT 0x38 40#define CONEXANT_MIC_EVENT 0x38
39 41
42/* Conexant 5051 specific */
43
44#define CXT5051_SPDIF_OUT 0x1C
45#define CXT5051_PORTB_EVENT 0x38
46#define CXT5051_PORTC_EVENT 0x39
40 47
41 48
49struct conexant_jack {
50
51 hda_nid_t nid;
52 int type;
53 struct snd_jack *jack;
54
55};
56
42struct conexant_spec { 57struct conexant_spec {
43 58
44 struct snd_kcontrol_new *mixers[5]; 59 struct snd_kcontrol_new *mixers[5];
@@ -83,6 +98,9 @@ struct conexant_spec {
83 98
84 unsigned int spdif_route; 99 unsigned int spdif_route;
85 100
101 /* jack detection */
102 struct snd_array jacks;
103
86 /* dynamic controls, init_verbs and input_mux */ 104 /* dynamic controls, init_verbs and input_mux */
87 struct auto_pin_cfg autocfg; 105 struct auto_pin_cfg autocfg;
88 struct hda_input_mux private_imux; 106 struct hda_input_mux private_imux;
@@ -329,6 +347,86 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol,
329 &spec->cur_mux[adc_idx]); 347 &spec->cur_mux[adc_idx]);
330} 348}
331 349
350static int conexant_add_jack(struct hda_codec *codec,
351 hda_nid_t nid, int type)
352{
353 struct conexant_spec *spec;
354 struct conexant_jack *jack;
355 const char *name;
356
357 spec = codec->spec;
358 snd_array_init(&spec->jacks, sizeof(*jack), 32);
359 jack = snd_array_new(&spec->jacks);
360 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
361
362 if (!jack)
363 return -ENOMEM;
364
365 jack->nid = nid;
366 jack->type = type;
367
368 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
369}
370
371static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
372{
373 struct conexant_spec *spec = codec->spec;
374 struct conexant_jack *jacks = spec->jacks.list;
375
376 if (jacks) {
377 int i;
378 for (i = 0; i < spec->jacks.used; i++) {
379 if (jacks->nid == nid) {
380 unsigned int present;
381 present = snd_hda_codec_read(codec, nid, 0,
382 AC_VERB_GET_PIN_SENSE, 0) &
383 AC_PINSENSE_PRESENCE;
384
385 present = (present) ? jacks->type : 0 ;
386
387 snd_jack_report(jacks->jack,
388 present);
389 }
390 jacks++;
391 }
392 }
393}
394
395static int conexant_init_jacks(struct hda_codec *codec)
396{
397#ifdef CONFIG_SND_JACK
398 struct conexant_spec *spec = codec->spec;
399 int i;
400
401 for (i = 0; i < spec->num_init_verbs; i++) {
402 const struct hda_verb *hv;
403
404 hv = spec->init_verbs[i];
405 while (hv->nid) {
406 int err = 0;
407 switch (hv->param ^ AC_USRSP_EN) {
408 case CONEXANT_HP_EVENT:
409 err = conexant_add_jack(codec, hv->nid,
410 SND_JACK_HEADPHONE);
411 conexant_report_jack(codec, hv->nid);
412 break;
413 case CXT5051_PORTC_EVENT:
414 case CONEXANT_MIC_EVENT:
415 err = conexant_add_jack(codec, hv->nid,
416 SND_JACK_MICROPHONE);
417 conexant_report_jack(codec, hv->nid);
418 break;
419 }
420 if (err < 0)
421 return err;
422 ++hv;
423 }
424 }
425#endif
426 return 0;
427
428}
429
332static int conexant_init(struct hda_codec *codec) 430static int conexant_init(struct hda_codec *codec)
333{ 431{
334 struct conexant_spec *spec = codec->spec; 432 struct conexant_spec *spec = codec->spec;
@@ -341,6 +439,16 @@ static int conexant_init(struct hda_codec *codec)
341 439
342static void conexant_free(struct hda_codec *codec) 440static void conexant_free(struct hda_codec *codec)
343{ 441{
442#ifdef CONFIG_SND_JACK
443 struct conexant_spec *spec = codec->spec;
444 if (spec->jacks.list) {
445 struct conexant_jack *jacks = spec->jacks.list;
446 int i;
447 for (i = 0; i < spec->jacks.used; i++)
448 snd_device_free(codec->bus->card, &jacks[i].jack);
449 snd_array_free(&spec->jacks);
450 }
451#endif
344 kfree(codec->spec); 452 kfree(codec->spec);
345} 453}
346 454
@@ -1526,9 +1634,6 @@ static int patch_cxt5047(struct hda_codec *codec)
1526/* Conexant 5051 specific */ 1634/* Conexant 5051 specific */
1527static hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; 1635static hda_nid_t cxt5051_dac_nids[1] = { 0x10 };
1528static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; 1636static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 };
1529#define CXT5051_SPDIF_OUT 0x1C
1530#define CXT5051_PORTB_EVENT 0x38
1531#define CXT5051_PORTC_EVENT 0x39
1532 1637
1533static struct hda_channel_mode cxt5051_modes[1] = { 1638static struct hda_channel_mode cxt5051_modes[1] = {
1534 { 2, NULL }, 1639 { 2, NULL },
@@ -1608,6 +1713,7 @@ static void cxt5051_hp_automute(struct hda_codec *codec)
1608static void cxt5051_hp_unsol_event(struct hda_codec *codec, 1713static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1609 unsigned int res) 1714 unsigned int res)
1610{ 1715{
1716 int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20;
1611 switch (res >> 26) { 1717 switch (res >> 26) {
1612 case CONEXANT_HP_EVENT: 1718 case CONEXANT_HP_EVENT:
1613 cxt5051_hp_automute(codec); 1719 cxt5051_hp_automute(codec);
@@ -1619,6 +1725,7 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec,
1619 cxt5051_portc_automic(codec); 1725 cxt5051_portc_automic(codec);
1620 break; 1726 break;
1621 } 1727 }
1728 conexant_report_jack(codec, nid);
1622} 1729}
1623 1730
1624static struct snd_kcontrol_new cxt5051_mixers[] = { 1731static struct snd_kcontrol_new cxt5051_mixers[] = {
@@ -1693,6 +1800,7 @@ static struct hda_verb cxt5051_init_verbs[] = {
1693static int cxt5051_init(struct hda_codec *codec) 1800static int cxt5051_init(struct hda_codec *codec)
1694{ 1801{
1695 conexant_init(codec); 1802 conexant_init(codec);
1803 conexant_init_jacks(codec);
1696 if (codec->patch_ops.unsol_event) { 1804 if (codec->patch_ops.unsol_event) {
1697 cxt5051_hp_automute(codec); 1805 cxt5051_hp_automute(codec);
1698 cxt5051_portb_automic(codec); 1806 cxt5051_portb_automic(codec);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0bd4e6bf354d..9065ebf9c065 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -8467,6 +8467,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8467 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8467 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8468 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8468 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8469 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8469 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8470 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8470 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8471 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8471 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8472 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8472 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), 8473 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
@@ -16638,9 +16639,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
16638 .patch = patch_alc882 }, /* should be patch_alc883() in future */ 16639 .patch = patch_alc882 }, /* should be patch_alc883() in future */
16639 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 16640 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
16640 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, 16641 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
16641 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
16642 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 16642 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16643 .patch = patch_alc883 }, 16643 .patch = patch_alc883 },
16644 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
16644 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, 16645 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
16645 {} /* terminator */ 16646 {} /* terminator */
16646}; 16647};
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 0dfa0540ce2c..bb8d8c766b9d 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -1239,7 +1239,7 @@ static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device)
1239 if (ice->force_pdma4 || ice->force_rdma1) 1239 if (ice->force_pdma4 || ice->force_rdma1)
1240 name = "ICE1724 Secondary"; 1240 name = "ICE1724 Secondary";
1241 else 1241 else
1242 name = "IEC1724 IEC958"; 1242 name = "ICE1724 IEC958";
1243 err = snd_pcm_new(ice->card, name, device, play, capt, &pcm); 1243 err = snd_pcm_new(ice->card, name, device, play, capt, &pcm);
1244 if (err < 0) 1244 if (err < 0)
1245 return err; 1245 return err;
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 51848880504a..31e44e346dc8 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -298,30 +298,107 @@ static const struct soc_enum twl4030_handsfreer_enum =
298static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = 298static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
299SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); 299SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
300 300
301static int outmixer_event(struct snd_soc_dapm_widget *w, 301/* Left analog microphone selection */
302static const char *twl4030_analoglmic_texts[] =
303 {"Off", "Main mic", "Headset mic", "Invalid", "AUXL",
304 "Invalid", "Invalid", "Invalid", "Carkit mic"};
305
306static const struct soc_enum twl4030_analoglmic_enum =
307 SOC_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0,
308 ARRAY_SIZE(twl4030_analoglmic_texts),
309 twl4030_analoglmic_texts);
310
311static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control =
312SOC_DAPM_ENUM("Route", twl4030_analoglmic_enum);
313
314/* Right analog microphone selection */
315static const char *twl4030_analogrmic_texts[] =
316 {"Off", "Sub mic", "Invalid", "Invalid", "AUXR"};
317
318static const struct soc_enum twl4030_analogrmic_enum =
319 SOC_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0,
320 ARRAY_SIZE(twl4030_analogrmic_texts),
321 twl4030_analogrmic_texts);
322
323static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control =
324SOC_DAPM_ENUM("Route", twl4030_analogrmic_enum);
325
326/* TX1 L/R Analog/Digital microphone selection */
327static const char *twl4030_micpathtx1_texts[] =
328 {"Analog", "Digimic0"};
329
330static const struct soc_enum twl4030_micpathtx1_enum =
331 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0,
332 ARRAY_SIZE(twl4030_micpathtx1_texts),
333 twl4030_micpathtx1_texts);
334
335static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control =
336SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
337
338/* TX2 L/R Analog/Digital microphone selection */
339static const char *twl4030_micpathtx2_texts[] =
340 {"Analog", "Digimic1"};
341
342static const struct soc_enum twl4030_micpathtx2_enum =
343 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2,
344 ARRAY_SIZE(twl4030_micpathtx2_texts),
345 twl4030_micpathtx2_texts);
346
347static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
348SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
349
350/*
351 * This function filters out the non valid mux settings, named as "Invalid"
352 * in the enum texts.
353 * Just refuse to set an invalid mux mode.
354 */
355static int twl4030_enum_event(struct snd_soc_dapm_widget *w,
302 struct snd_kcontrol *kcontrol, int event) 356 struct snd_kcontrol *kcontrol, int event)
303{ 357{
304 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 358 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
305 int ret = 0; 359 int ret = 0;
306 int val; 360 int val;
307 361
308 switch (e->reg) { 362 val = w->value >> e->shift_l;
309 case TWL4030_REG_PREDL_CTL: 363 if (!strcmp("Invalid", e->texts[val])) {
310 case TWL4030_REG_PREDR_CTL: 364 printk(KERN_WARNING "Invalid MUX setting on 0x%02x (%d)\n",
311 case TWL4030_REG_EAR_CTL: 365 e->reg, val);
312 val = w->value >> e->shift_l; 366 ret = -1;
313 if (val == 3) {
314 printk(KERN_WARNING
315 "Invalid MUX setting for register 0x%02x (%d)\n",
316 e->reg, val);
317 ret = -1;
318 }
319 break;
320 } 367 }
321 368
322 return ret; 369 return ret;
323} 370}
324 371
372static int micpath_event(struct snd_soc_dapm_widget *w,
373 struct snd_kcontrol *kcontrol, int event)
374{
375 struct soc_enum *e = (struct soc_enum *)w->kcontrols->private_value;
376 unsigned char adcmicsel, micbias_ctl;
377
378 adcmicsel = twl4030_read_reg_cache(w->codec, TWL4030_REG_ADCMICSEL);
379 micbias_ctl = twl4030_read_reg_cache(w->codec, TWL4030_REG_MICBIAS_CTL);
380 /* Prepare the bits for the given TX path:
381 * shift_l == 0: TX1 microphone path
382 * shift_l == 2: TX2 microphone path */
383 if (e->shift_l) {
384 /* TX2 microphone path */
385 if (adcmicsel & TWL4030_TX2IN_SEL)
386 micbias_ctl |= TWL4030_MICBIAS2_CTL; /* digimic */
387 else
388 micbias_ctl &= ~TWL4030_MICBIAS2_CTL;
389 } else {
390 /* TX1 microphone path */
391 if (adcmicsel & TWL4030_TX1IN_SEL)
392 micbias_ctl |= TWL4030_MICBIAS1_CTL; /* digimic */
393 else
394 micbias_ctl &= ~TWL4030_MICBIAS1_CTL;
395 }
396
397 twl4030_write(w->codec, TWL4030_REG_MICBIAS_CTL, micbias_ctl);
398
399 return 0;
400}
401
325static int handsfree_event(struct snd_soc_dapm_widget *w, 402static int handsfree_event(struct snd_soc_dapm_widget *w,
326 struct snd_kcontrol *kcontrol, int event) 403 struct snd_kcontrol *kcontrol, int event)
327{ 404{
@@ -503,162 +580,6 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
503 return err; 580 return err;
504} 581}
505 582
506static int twl4030_get_left_input(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
508{
509 struct snd_soc_codec *codec = kcontrol->private_data;
510 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
511 int result = 0;
512
513 /* one bit must be set a time */
514 reg &= TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN
515 | TWL4030_MAINMIC_EN;
516 if (reg != 0) {
517 result++;
518 while ((reg & 1) == 0) {
519 result++;
520 reg >>= 1;
521 }
522 }
523
524 ucontrol->value.integer.value[0] = result;
525 return 0;
526}
527
528static int twl4030_put_left_input(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
530{
531 struct snd_soc_codec *codec = kcontrol->private_data;
532 int value = ucontrol->value.integer.value[0];
533 u8 anamicl, micbias, avadc_ctl;
534
535 anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
536 anamicl &= ~(TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN
537 | TWL4030_MAINMIC_EN);
538 micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL);
539 micbias &= ~(TWL4030_HSMICBIAS_EN | TWL4030_MICBIAS1_EN);
540 avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL);
541
542 switch (value) {
543 case 1:
544 anamicl |= TWL4030_MAINMIC_EN;
545 micbias |= TWL4030_MICBIAS1_EN;
546 break;
547 case 2:
548 anamicl |= TWL4030_HSMIC_EN;
549 micbias |= TWL4030_HSMICBIAS_EN;
550 break;
551 case 3:
552 anamicl |= TWL4030_AUXL_EN;
553 break;
554 case 4:
555 anamicl |= TWL4030_CKMIC_EN;
556 break;
557 default:
558 break;
559 }
560
561 /* If some input is selected, enable amp and ADC */
562 if (value != 0) {
563 anamicl |= TWL4030_MICAMPL_EN;
564 avadc_ctl |= TWL4030_ADCL_EN;
565 } else {
566 anamicl &= ~TWL4030_MICAMPL_EN;
567 avadc_ctl &= ~TWL4030_ADCL_EN;
568 }
569
570 twl4030_write(codec, TWL4030_REG_ANAMICL, anamicl);
571 twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias);
572 twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl);
573
574 return 1;
575}
576
577static int twl4030_get_right_input(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
579{
580 struct snd_soc_codec *codec = kcontrol->private_data;
581 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR);
582 int value = 0;
583
584 reg &= TWL4030_SUBMIC_EN|TWL4030_AUXR_EN;
585 switch (reg) {
586 case TWL4030_SUBMIC_EN:
587 value = 1;
588 break;
589 case TWL4030_AUXR_EN:
590 value = 2;
591 break;
592 default:
593 break;
594 }
595
596 ucontrol->value.integer.value[0] = value;
597 return 0;
598}
599
600static int twl4030_put_right_input(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
602{
603 struct snd_soc_codec *codec = kcontrol->private_data;
604 int value = ucontrol->value.integer.value[0];
605 u8 anamicr, micbias, avadc_ctl;
606
607 anamicr = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR);
608 anamicr &= ~(TWL4030_SUBMIC_EN|TWL4030_AUXR_EN);
609 micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL);
610 micbias &= ~TWL4030_MICBIAS2_EN;
611 avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL);
612
613 switch (value) {
614 case 1:
615 anamicr |= TWL4030_SUBMIC_EN;
616 micbias |= TWL4030_MICBIAS2_EN;
617 break;
618 case 2:
619 anamicr |= TWL4030_AUXR_EN;
620 break;
621 default:
622 break;
623 }
624
625 if (value != 0) {
626 anamicr |= TWL4030_MICAMPR_EN;
627 avadc_ctl |= TWL4030_ADCR_EN;
628 } else {
629 anamicr &= ~TWL4030_MICAMPR_EN;
630 avadc_ctl &= ~TWL4030_ADCR_EN;
631 }
632
633 twl4030_write(codec, TWL4030_REG_ANAMICR, anamicr);
634 twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias);
635 twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl);
636
637 return 1;
638}
639
640static const char *twl4030_left_in_sel[] = {
641 "None",
642 "Main Mic",
643 "Headset Mic",
644 "Line In",
645 "Carkit Mic",
646};
647
648static const char *twl4030_right_in_sel[] = {
649 "None",
650 "Sub Mic",
651 "Line In",
652};
653
654static const struct soc_enum twl4030_left_input_mux =
655 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_left_in_sel),
656 twl4030_left_in_sel);
657
658static const struct soc_enum twl4030_right_input_mux =
659 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_right_in_sel),
660 twl4030_right_in_sel);
661
662/* 583/*
663 * FGAIN volume control: 584 * FGAIN volume control:
664 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) 585 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
@@ -741,18 +662,15 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = {
741 TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl), 662 TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl),
742 663
743 /* Common capture gain controls */ 664 /* Common capture gain controls */
744 SOC_DOUBLE_R_TLV("Capture Volume", 665 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
745 TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA, 666 TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA,
746 0, 0x1f, 0, digital_capture_tlv), 667 0, 0x1f, 0, digital_capture_tlv),
668 SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
669 TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA,
670 0, 0x1f, 0, digital_capture_tlv),
747 671
748 SOC_DOUBLE_TLV("Input Boost Volume", TWL4030_REG_ANAMIC_GAIN, 672 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
749 0, 3, 5, 0, input_gain_tlv), 673 0, 3, 5, 0, input_gain_tlv),
750
751 /* Input source controls */
752 SOC_ENUM_EXT("Left Input Source", twl4030_left_input_mux,
753 twl4030_get_left_input, twl4030_put_left_input),
754 SOC_ENUM_EXT("Right Input Source", twl4030_right_input_mux,
755 twl4030_get_right_input, twl4030_put_right_input),
756}; 674};
757 675
758/* add non dapm controls */ 676/* add non dapm controls */
@@ -772,9 +690,19 @@ static int twl4030_add_controls(struct snd_soc_codec *codec)
772} 690}
773 691
774static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { 692static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
775 SND_SOC_DAPM_INPUT("INL"), 693 /* Left channel inputs */
776 SND_SOC_DAPM_INPUT("INR"), 694 SND_SOC_DAPM_INPUT("MAINMIC"),
777 695 SND_SOC_DAPM_INPUT("HSMIC"),
696 SND_SOC_DAPM_INPUT("AUXL"),
697 SND_SOC_DAPM_INPUT("CARKITMIC"),
698 /* Right channel inputs */
699 SND_SOC_DAPM_INPUT("SUBMIC"),
700 SND_SOC_DAPM_INPUT("AUXR"),
701 /* Digital microphones (Stereo) */
702 SND_SOC_DAPM_INPUT("DIGIMIC0"),
703 SND_SOC_DAPM_INPUT("DIGIMIC1"),
704
705 /* Outputs */
778 SND_SOC_DAPM_OUTPUT("OUTL"), 706 SND_SOC_DAPM_OUTPUT("OUTL"),
779 SND_SOC_DAPM_OUTPUT("OUTR"), 707 SND_SOC_DAPM_OUTPUT("OUTR"),
780 SND_SOC_DAPM_OUTPUT("EARPIECE"), 708 SND_SOC_DAPM_OUTPUT("EARPIECE"),
@@ -810,14 +738,14 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
810 /* Output MUX controls */ 738 /* Output MUX controls */
811 /* Earpiece */ 739 /* Earpiece */
812 SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0, 740 SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0,
813 &twl4030_dapm_earpiece_control, outmixer_event, 741 &twl4030_dapm_earpiece_control, twl4030_enum_event,
814 SND_SOC_DAPM_PRE_REG), 742 SND_SOC_DAPM_PRE_REG),
815 /* PreDrivL/R */ 743 /* PreDrivL/R */
816 SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0, 744 SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0,
817 &twl4030_dapm_predrivel_control, outmixer_event, 745 &twl4030_dapm_predrivel_control, twl4030_enum_event,
818 SND_SOC_DAPM_PRE_REG), 746 SND_SOC_DAPM_PRE_REG),
819 SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, 747 SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0,
820 &twl4030_dapm_predriver_control, outmixer_event, 748 &twl4030_dapm_predriver_control, twl4030_enum_event,
821 SND_SOC_DAPM_PRE_REG), 749 SND_SOC_DAPM_PRE_REG),
822 /* HeadsetL/R */ 750 /* HeadsetL/R */
823 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, 751 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0,
@@ -837,8 +765,50 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
837 &twl4030_dapm_handsfreer_control, handsfree_event, 765 &twl4030_dapm_handsfreer_control, handsfree_event,
838 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), 766 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
839 767
840 SND_SOC_DAPM_ADC("ADCL", "Left Capture", SND_SOC_NOPM, 0, 0), 768 /* Introducing four virtual ADC, since TWL4030 have four channel for
841 SND_SOC_DAPM_ADC("ADCR", "Right Capture", SND_SOC_NOPM, 0, 0), 769 capture */
770 SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture",
771 SND_SOC_NOPM, 0, 0),
772 SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture",
773 SND_SOC_NOPM, 0, 0),
774 SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture",
775 SND_SOC_NOPM, 0, 0),
776 SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture",
777 SND_SOC_NOPM, 0, 0),
778
779 /* Analog/Digital mic path selection.
780 TX1 Left/Right: either analog Left/Right or Digimic0
781 TX2 Left/Right: either analog Left/Right or Digimic1 */
782 SND_SOC_DAPM_MUX_E("TX1 Capture Route", SND_SOC_NOPM, 0, 0,
783 &twl4030_dapm_micpathtx1_control, micpath_event,
784 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD|
785 SND_SOC_DAPM_POST_REG),
786 SND_SOC_DAPM_MUX_E("TX2 Capture Route", SND_SOC_NOPM, 0, 0,
787 &twl4030_dapm_micpathtx2_control, micpath_event,
788 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD|
789 SND_SOC_DAPM_POST_REG),
790
791 /* Analog input muxes with power switch for the physical ADCL/R */
792 SND_SOC_DAPM_MUX_E("Analog Left Capture Route",
793 TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control,
794 twl4030_enum_event, SND_SOC_DAPM_PRE_REG),
795 SND_SOC_DAPM_MUX_E("Analog Right Capture Route",
796 TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control,
797 twl4030_enum_event, SND_SOC_DAPM_PRE_REG),
798
799 SND_SOC_DAPM_PGA("Analog Left Amplifier",
800 TWL4030_REG_ANAMICL, 4, 0, NULL, 0),
801 SND_SOC_DAPM_PGA("Analog Right Amplifier",
802 TWL4030_REG_ANAMICR, 4, 0, NULL, 0),
803
804 SND_SOC_DAPM_PGA("Digimic0 Enable",
805 TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0),
806 SND_SOC_DAPM_PGA("Digimic1 Enable",
807 TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0),
808
809 SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0),
810 SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0),
811 SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0),
842}; 812};
843 813
844static const struct snd_soc_dapm_route intercon[] = { 814static const struct snd_soc_dapm_route intercon[] = {
@@ -894,9 +864,39 @@ static const struct snd_soc_dapm_route intercon[] = {
894 {"HFL", NULL, "HandsfreeL Mux"}, 864 {"HFL", NULL, "HandsfreeL Mux"},
895 {"HFR", NULL, "HandsfreeR Mux"}, 865 {"HFR", NULL, "HandsfreeR Mux"},
896 866
897 /* inputs */ 867 /* Capture path */
898 {"ADCL", NULL, "INL"}, 868 {"Analog Left Capture Route", "Main mic", "MAINMIC"},
899 {"ADCR", NULL, "INR"}, 869 {"Analog Left Capture Route", "Headset mic", "HSMIC"},
870 {"Analog Left Capture Route", "AUXL", "AUXL"},
871 {"Analog Left Capture Route", "Carkit mic", "CARKITMIC"},
872
873 {"Analog Right Capture Route", "Sub mic", "SUBMIC"},
874 {"Analog Right Capture Route", "AUXR", "AUXR"},
875
876 {"Analog Left Amplifier", NULL, "Analog Left Capture Route"},
877 {"Analog Right Amplifier", NULL, "Analog Right Capture Route"},
878
879 {"Digimic0 Enable", NULL, "DIGIMIC0"},
880 {"Digimic1 Enable", NULL, "DIGIMIC1"},
881
882 /* TX1 Left capture path */
883 {"TX1 Capture Route", "Analog", "Analog Left Amplifier"},
884 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
885 /* TX1 Right capture path */
886 {"TX1 Capture Route", "Analog", "Analog Right Amplifier"},
887 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
888 /* TX2 Left capture path */
889 {"TX2 Capture Route", "Analog", "Analog Left Amplifier"},
890 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
891 /* TX2 Right capture path */
892 {"TX2 Capture Route", "Analog", "Analog Right Amplifier"},
893 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
894
895 {"ADC Virtual Left1", NULL, "TX1 Capture Route"},
896 {"ADC Virtual Right1", NULL, "TX1 Capture Route"},
897 {"ADC Virtual Left2", NULL, "TX2 Capture Route"},
898 {"ADC Virtual Right2", NULL, "TX2 Capture Route"},
899
900}; 900};
901 901
902static int twl4030_add_widgets(struct snd_soc_codec *codec) 902static int twl4030_add_widgets(struct snd_soc_codec *codec)
@@ -923,6 +923,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
923 twl4030_write(codec, TWL4030_REG_ANAMICL, 923 twl4030_write(codec, TWL4030_REG_ANAMICL,
924 anamicl | TWL4030_CNCL_OFFSET_START); 924 anamicl | TWL4030_CNCL_OFFSET_START);
925 925
926
926 /* wait for offset cancellation to complete */ 927 /* wait for offset cancellation to complete */
927 do { 928 do {
928 /* this takes a little while, so don't slam i2c */ 929 /* this takes a little while, so don't slam i2c */
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h
index 54615c76802b..442e5a828617 100644
--- a/sound/soc/codecs/twl4030.h
+++ b/sound/soc/codecs/twl4030.h
@@ -147,6 +147,13 @@
147#define TWL4030_AVADC_CLK_PRIORITY 0x04 147#define TWL4030_AVADC_CLK_PRIORITY 0x04
148#define TWL4030_ADCR_EN 0x02 148#define TWL4030_ADCR_EN 0x02
149 149
150/* TWL4030_REG_ADCMICSEL (0x08) Fields */
151
152#define TWL4030_DIGMIC1_EN 0x08
153#define TWL4030_TX2IN_SEL 0x04
154#define TWL4030_DIGMIC0_EN 0x02
155#define TWL4030_TX1IN_SEL 0x01
156
150/* AUDIO_IF (0x0E) Fields */ 157/* AUDIO_IF (0x0E) Fields */
151 158
152#define TWL4030_AIF_SLAVE_EN 0x80 159#define TWL4030_AIF_SLAVE_EN 0x80
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
index f67579d52765..4935d1bcbd8d 100644
--- a/sound/soc/davinci/davinci-sffsdr.c
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -24,6 +24,7 @@
24#include <sound/soc-dapm.h> 24#include <sound/soc-dapm.h>
25 25
26#include <asm/dma.h> 26#include <asm/dma.h>
27#include <asm/mach-types.h>
27#include <asm/plat-sffsdr/sffsdr-fpga.h> 28#include <asm/plat-sffsdr/sffsdr-fpga.h>
28 29
29#include <mach/mcbsp.h> 30#include <mach/mcbsp.h>
@@ -115,6 +116,9 @@ static int __init sffsdr_init(void)
115{ 116{
116 int ret; 117 int ret;
117 118
119 if (!machine_is_sffsdr())
120 return -EINVAL;
121
118 sffsdr_snd_device = platform_device_alloc("soc-audio", 0); 122 sffsdr_snd_device = platform_device_alloc("soc-audio", 0);
119 if (!sffsdr_snd_device) { 123 if (!sffsdr_snd_device) {
120 printk(KERN_ERR "platform device allocation failed\n"); 124 printk(KERN_ERR "platform device allocation failed\n");
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index c670d08e7c9e..53b9fb127a6d 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -61,9 +61,9 @@ static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream)
61 61
62 __pxa2xx_pcm_hw_free(substream); 62 __pxa2xx_pcm_hw_free(substream);
63 63
64 if (prtd->dma_ch) { 64 if (prtd->dma_ch >= 0) {
65 pxa_free_dma(prtd->dma_ch); 65 pxa_free_dma(prtd->dma_ch);
66 prtd->dma_ch = 0; 66 prtd->dma_ch = -1;
67 } 67 }
68 68
69 return 0; 69 return 0;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b098c0b4c584..f73c1341437c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1300,6 +1300,8 @@ EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1300/** 1300/**
1301 * snd_soc_new_pcms - create new sound card and pcms 1301 * snd_soc_new_pcms - create new sound card and pcms
1302 * @socdev: the SoC audio device 1302 * @socdev: the SoC audio device
1303 * @idx: ALSA card index
1304 * @xid: card identification
1303 * 1305 *
1304 * Create a new sound card based upon the codec and interface pcms. 1306 * Create a new sound card based upon the codec and interface pcms.
1305 * 1307 *
@@ -1472,7 +1474,7 @@ EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1472 * snd_soc_cnew - create new control 1474 * snd_soc_cnew - create new control
1473 * @_template: control template 1475 * @_template: control template
1474 * @data: control private data 1476 * @data: control private data
1475 * @lnng_name: control long name 1477 * @long_name: control long name
1476 * 1478 *
1477 * Create a new mixer control from a template control. 1479 * Create a new mixer control from a template control.
1478 * 1480 *
@@ -1522,7 +1524,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1522/** 1524/**
1523 * snd_soc_get_enum_double - enumerated double mixer get callback 1525 * snd_soc_get_enum_double - enumerated double mixer get callback
1524 * @kcontrol: mixer control 1526 * @kcontrol: mixer control
1525 * @uinfo: control element information 1527 * @ucontrol: control element information
1526 * 1528 *
1527 * Callback to get the value of a double enumerated mixer. 1529 * Callback to get the value of a double enumerated mixer.
1528 * 1530 *
@@ -1551,7 +1553,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
1551/** 1553/**
1552 * snd_soc_put_enum_double - enumerated double mixer put callback 1554 * snd_soc_put_enum_double - enumerated double mixer put callback
1553 * @kcontrol: mixer control 1555 * @kcontrol: mixer control
1554 * @uinfo: control element information 1556 * @ucontrol: control element information
1555 * 1557 *
1556 * Callback to set the value of a double enumerated mixer. 1558 * Callback to set the value of a double enumerated mixer.
1557 * 1559 *
@@ -1668,7 +1670,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
1668/** 1670/**
1669 * snd_soc_get_volsw - single mixer get callback 1671 * snd_soc_get_volsw - single mixer get callback
1670 * @kcontrol: mixer control 1672 * @kcontrol: mixer control
1671 * @uinfo: control element information 1673 * @ucontrol: control element information
1672 * 1674 *
1673 * Callback to get the value of a single mixer control. 1675 * Callback to get the value of a single mixer control.
1674 * 1676 *
@@ -1707,7 +1709,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
1707/** 1709/**
1708 * snd_soc_put_volsw - single mixer put callback 1710 * snd_soc_put_volsw - single mixer put callback
1709 * @kcontrol: mixer control 1711 * @kcontrol: mixer control
1710 * @uinfo: control element information 1712 * @ucontrol: control element information
1711 * 1713 *
1712 * Callback to set the value of a single mixer control. 1714 * Callback to set the value of a single mixer control.
1713 * 1715 *
@@ -1775,7 +1777,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
1775/** 1777/**
1776 * snd_soc_get_volsw_2r - double mixer get callback 1778 * snd_soc_get_volsw_2r - double mixer get callback
1777 * @kcontrol: mixer control 1779 * @kcontrol: mixer control
1778 * @uinfo: control element information 1780 * @ucontrol: control element information
1779 * 1781 *
1780 * Callback to get the value of a double mixer control that spans 2 registers. 1782 * Callback to get the value of a double mixer control that spans 2 registers.
1781 * 1783 *
@@ -1812,7 +1814,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
1812/** 1814/**
1813 * snd_soc_put_volsw_2r - double mixer set callback 1815 * snd_soc_put_volsw_2r - double mixer set callback
1814 * @kcontrol: mixer control 1816 * @kcontrol: mixer control
1815 * @uinfo: control element information 1817 * @ucontrol: control element information
1816 * 1818 *
1817 * Callback to set the value of a double mixer control that spans 2 registers. 1819 * Callback to set the value of a double mixer control that spans 2 registers.
1818 * 1820 *
@@ -1882,7 +1884,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8);
1882/** 1884/**
1883 * snd_soc_get_volsw_s8 - signed mixer get callback 1885 * snd_soc_get_volsw_s8 - signed mixer get callback
1884 * @kcontrol: mixer control 1886 * @kcontrol: mixer control
1885 * @uinfo: control element information 1887 * @ucontrol: control element information
1886 * 1888 *
1887 * Callback to get the value of a signed mixer control. 1889 * Callback to get the value of a signed mixer control.
1888 * 1890 *
@@ -1909,7 +1911,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8);
1909/** 1911/**
1910 * snd_soc_put_volsw_sgn - signed mixer put callback 1912 * snd_soc_put_volsw_sgn - signed mixer put callback
1911 * @kcontrol: mixer control 1913 * @kcontrol: mixer control
1912 * @uinfo: control element information 1914 * @ucontrol: control element information
1913 * 1915 *
1914 * Callback to set the value of a signed mixer control. 1916 * Callback to set the value of a signed mixer control.
1915 * 1917 *
@@ -1954,7 +1956,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
1954/** 1956/**
1955 * snd_soc_dai_set_clkdiv - configure DAI clock dividers. 1957 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
1956 * @dai: DAI 1958 * @dai: DAI
1957 * @clk_id: DAI specific clock divider ID 1959 * @div_id: DAI specific clock divider ID
1958 * @div: new clock divisor. 1960 * @div: new clock divisor.
1959 * 1961 *
1960 * Configures the clock dividers. This is used to derive the best DAI bit and 1962 * Configures the clock dividers. This is used to derive the best DAI bit and
@@ -2060,7 +2062,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
2060/** 2062/**
2061 * snd_soc_register_card - Register a card with the ASoC core 2063 * snd_soc_register_card - Register a card with the ASoC core
2062 * 2064 *
2063 * @param card Card to register 2065 * @card: Card to register
2064 * 2066 *
2065 * Note that currently this is an internal only function: it will be 2067 * Note that currently this is an internal only function: it will be
2066 * exposed to machine drivers after further backporting of ASoC v2 2068 * exposed to machine drivers after further backporting of ASoC v2
@@ -2087,7 +2089,7 @@ static int snd_soc_register_card(struct snd_soc_card *card)
2087/** 2089/**
2088 * snd_soc_unregister_card - Unregister a card with the ASoC core 2090 * snd_soc_unregister_card - Unregister a card with the ASoC core
2089 * 2091 *
2090 * @param card Card to unregister 2092 * @card: Card to unregister
2091 * 2093 *
2092 * Note that currently this is an internal only function: it will be 2094 * Note that currently this is an internal only function: it will be
2093 * exposed to machine drivers after further backporting of ASoC v2 2095 * exposed to machine drivers after further backporting of ASoC v2
@@ -2107,7 +2109,7 @@ static int snd_soc_unregister_card(struct snd_soc_card *card)
2107/** 2109/**
2108 * snd_soc_register_dai - Register a DAI with the ASoC core 2110 * snd_soc_register_dai - Register a DAI with the ASoC core
2109 * 2111 *
2110 * @param dai DAI to register 2112 * @dai: DAI to register
2111 */ 2113 */
2112int snd_soc_register_dai(struct snd_soc_dai *dai) 2114int snd_soc_register_dai(struct snd_soc_dai *dai)
2113{ 2115{
@@ -2134,7 +2136,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dai);
2134/** 2136/**
2135 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core 2137 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core
2136 * 2138 *
2137 * @param dai DAI to unregister 2139 * @dai: DAI to unregister
2138 */ 2140 */
2139void snd_soc_unregister_dai(struct snd_soc_dai *dai) 2141void snd_soc_unregister_dai(struct snd_soc_dai *dai)
2140{ 2142{
@@ -2149,8 +2151,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
2149/** 2151/**
2150 * snd_soc_register_dais - Register multiple DAIs with the ASoC core 2152 * snd_soc_register_dais - Register multiple DAIs with the ASoC core
2151 * 2153 *
2152 * @param dai Array of DAIs to register 2154 * @dai: Array of DAIs to register
2153 * @param count Number of DAIs 2155 * @count: Number of DAIs
2154 */ 2156 */
2155int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count) 2157int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count)
2156{ 2158{
@@ -2175,8 +2177,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dais);
2175/** 2177/**
2176 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core 2178 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core
2177 * 2179 *
2178 * @param dai Array of DAIs to unregister 2180 * @dai: Array of DAIs to unregister
2179 * @param count Number of DAIs 2181 * @count: Number of DAIs
2180 */ 2182 */
2181void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count) 2183void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count)
2182{ 2184{
@@ -2190,7 +2192,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
2190/** 2192/**
2191 * snd_soc_register_platform - Register a platform with the ASoC core 2193 * snd_soc_register_platform - Register a platform with the ASoC core
2192 * 2194 *
2193 * @param platform platform to register 2195 * @platform: platform to register
2194 */ 2196 */
2195int snd_soc_register_platform(struct snd_soc_platform *platform) 2197int snd_soc_register_platform(struct snd_soc_platform *platform)
2196{ 2198{
@@ -2213,7 +2215,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform);
2213/** 2215/**
2214 * snd_soc_unregister_platform - Unregister a platform from the ASoC core 2216 * snd_soc_unregister_platform - Unregister a platform from the ASoC core
2215 * 2217 *
2216 * @param platform platform to unregister 2218 * @platform: platform to unregister
2217 */ 2219 */
2218void snd_soc_unregister_platform(struct snd_soc_platform *platform) 2220void snd_soc_unregister_platform(struct snd_soc_platform *platform)
2219{ 2221{
@@ -2228,7 +2230,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
2228/** 2230/**
2229 * snd_soc_register_codec - Register a codec with the ASoC core 2231 * snd_soc_register_codec - Register a codec with the ASoC core
2230 * 2232 *
2231 * @param codec codec to register 2233 * @codec: codec to register
2232 */ 2234 */
2233int snd_soc_register_codec(struct snd_soc_codec *codec) 2235int snd_soc_register_codec(struct snd_soc_codec *codec)
2234{ 2236{
@@ -2255,7 +2257,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_codec);
2255/** 2257/**
2256 * snd_soc_unregister_codec - Unregister a codec from the ASoC core 2258 * snd_soc_unregister_codec - Unregister a codec from the ASoC core
2257 * 2259 *
2258 * @param codec codec to unregister 2260 * @codec: codec to unregister
2259 */ 2261 */
2260void snd_soc_unregister_codec(struct snd_soc_codec *codec) 2262void snd_soc_unregister_codec(struct snd_soc_codec *codec)
2261{ 2263{
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8863eddbac02..6c79ca6df0bf 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1077,7 +1077,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
1077/** 1077/**
1078 * snd_soc_dapm_get_volsw - dapm mixer get callback 1078 * snd_soc_dapm_get_volsw - dapm mixer get callback
1079 * @kcontrol: mixer control 1079 * @kcontrol: mixer control
1080 * @uinfo: control element information 1080 * @ucontrol: control element information
1081 * 1081 *
1082 * Callback to get the value of a dapm mixer control. 1082 * Callback to get the value of a dapm mixer control.
1083 * 1083 *
@@ -1122,7 +1122,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
1122/** 1122/**
1123 * snd_soc_dapm_put_volsw - dapm mixer set callback 1123 * snd_soc_dapm_put_volsw - dapm mixer set callback
1124 * @kcontrol: mixer control 1124 * @kcontrol: mixer control
1125 * @uinfo: control element information 1125 * @ucontrol: control element information
1126 * 1126 *
1127 * Callback to set the value of a dapm mixer control. 1127 * Callback to set the value of a dapm mixer control.
1128 * 1128 *
@@ -1193,7 +1193,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
1193/** 1193/**
1194 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback 1194 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
1195 * @kcontrol: mixer control 1195 * @kcontrol: mixer control
1196 * @uinfo: control element information 1196 * @ucontrol: control element information
1197 * 1197 *
1198 * Callback to get the value of a dapm enumerated double mixer control. 1198 * Callback to get the value of a dapm enumerated double mixer control.
1199 * 1199 *
@@ -1221,7 +1221,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
1221/** 1221/**
1222 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback 1222 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
1223 * @kcontrol: mixer control 1223 * @kcontrol: mixer control
1224 * @uinfo: control element information 1224 * @ucontrol: control element information
1225 * 1225 *
1226 * Callback to set the value of a dapm enumerated double mixer control. 1226 * Callback to set the value of a dapm enumerated double mixer control.
1227 * 1227 *
@@ -1419,7 +1419,7 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1419 1419
1420/** 1420/**
1421 * snd_soc_dapm_enable_pin - enable pin. 1421 * snd_soc_dapm_enable_pin - enable pin.
1422 * @snd_soc_codec: SoC codec 1422 * @codec: SoC codec
1423 * @pin: pin name 1423 * @pin: pin name
1424 * 1424 *
1425 * Enables input/output pin and it's parents or children widgets iff there is 1425 * Enables input/output pin and it's parents or children widgets iff there is
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index b143ef7152f7..a62500e387a6 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -446,7 +446,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
446 if (!card) 446 if (!card)
447 return -ENOMEM; 447 return -ENOMEM;
448 448
449 dev_set_drvdata(&intf->dev, card); 449 usb_set_intfdata(intf, card);
450 ret = init_card(caiaqdev(card)); 450 ret = init_card(caiaqdev(card));
451 if (ret < 0) { 451 if (ret < 0) {
452 log("unable to init card! (ret=%d)\n", ret); 452 log("unable to init card! (ret=%d)\n", ret);
@@ -460,7 +460,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
460static void snd_disconnect(struct usb_interface *intf) 460static void snd_disconnect(struct usb_interface *intf)
461{ 461{
462 struct snd_usb_caiaqdev *dev; 462 struct snd_usb_caiaqdev *dev;
463 struct snd_card *card = dev_get_drvdata(&intf->dev); 463 struct snd_card *card = usb_get_intfdata(intf);
464 464
465 debug("%s(%p)\n", __func__, intf); 465 debug("%s(%p)\n", __func__, intf);
466 466
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index bbd70d5814a0..c709b9563226 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -3709,7 +3709,7 @@ static int usb_audio_probe(struct usb_interface *intf,
3709 void *chip; 3709 void *chip;
3710 chip = snd_usb_audio_probe(interface_to_usbdev(intf), intf, id); 3710 chip = snd_usb_audio_probe(interface_to_usbdev(intf), intf, id);
3711 if (chip) { 3711 if (chip) {
3712 dev_set_drvdata(&intf->dev, chip); 3712 usb_set_intfdata(intf, chip);
3713 return 0; 3713 return 0;
3714 } else 3714 } else
3715 return -EIO; 3715 return -EIO;
@@ -3718,13 +3718,13 @@ static int usb_audio_probe(struct usb_interface *intf,
3718static void usb_audio_disconnect(struct usb_interface *intf) 3718static void usb_audio_disconnect(struct usb_interface *intf)
3719{ 3719{
3720 snd_usb_audio_disconnect(interface_to_usbdev(intf), 3720 snd_usb_audio_disconnect(interface_to_usbdev(intf),
3721 dev_get_drvdata(&intf->dev)); 3721 usb_get_intfdata(intf));
3722} 3722}
3723 3723
3724#ifdef CONFIG_PM 3724#ifdef CONFIG_PM
3725static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) 3725static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
3726{ 3726{
3727 struct snd_usb_audio *chip = dev_get_drvdata(&intf->dev); 3727 struct snd_usb_audio *chip = usb_get_intfdata(intf);
3728 struct list_head *p; 3728 struct list_head *p;
3729 struct snd_usb_stream *as; 3729 struct snd_usb_stream *as;
3730 3730
@@ -3744,7 +3744,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
3744 3744
3745static int usb_audio_resume(struct usb_interface *intf) 3745static int usb_audio_resume(struct usb_interface *intf)
3746{ 3746{
3747 struct snd_usb_audio *chip = dev_get_drvdata(&intf->dev); 3747 struct snd_usb_audio *chip = usb_get_intfdata(intf);
3748 3748
3749 if (chip == (void *)-1L) 3749 if (chip == (void *)-1L)
3750 return 0; 3750 return 0;
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 6d9f9b135c62..320641ab5be7 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1392,8 +1392,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1392 for (i = 0; i < intfd->bNumEndpoints; ++i) { 1392 for (i = 0; i < intfd->bNumEndpoints; ++i) {
1393 hostep = &hostif->endpoint[i]; 1393 hostep = &hostif->endpoint[i];
1394 ep = get_ep_desc(hostep); 1394 ep = get_ep_desc(hostep);
1395 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK && 1395 if (!usb_endpoint_xfer_bulk(ep) && !usb_endpoint_xfer_int(ep))
1396 (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
1397 continue; 1396 continue;
1398 ms_ep = (struct usb_ms_endpoint_descriptor*)hostep->extra; 1397 ms_ep = (struct usb_ms_endpoint_descriptor*)hostep->extra;
1399 if (hostep->extralen < 4 || 1398 if (hostep->extralen < 4 ||
@@ -1401,15 +1400,15 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1401 ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || 1400 ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT ||
1402 ms_ep->bDescriptorSubtype != MS_GENERAL) 1401 ms_ep->bDescriptorSubtype != MS_GENERAL)
1403 continue; 1402 continue;
1404 if ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 1403 if (usb_endpoint_dir_out(ep)) {
1405 if (endpoints[epidx].out_ep) { 1404 if (endpoints[epidx].out_ep) {
1406 if (++epidx >= MIDI_MAX_ENDPOINTS) { 1405 if (++epidx >= MIDI_MAX_ENDPOINTS) {
1407 snd_printk(KERN_WARNING "too many endpoints\n"); 1406 snd_printk(KERN_WARNING "too many endpoints\n");
1408 break; 1407 break;
1409 } 1408 }
1410 } 1409 }
1411 endpoints[epidx].out_ep = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1410 endpoints[epidx].out_ep = usb_endpoint_num(ep);
1412 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) 1411 if (usb_endpoint_xfer_int(ep))
1413 endpoints[epidx].out_interval = ep->bInterval; 1412 endpoints[epidx].out_interval = ep->bInterval;
1414 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) 1413 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW)
1415 /* 1414 /*
@@ -1428,8 +1427,8 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1428 break; 1427 break;
1429 } 1428 }
1430 } 1429 }
1431 endpoints[epidx].in_ep = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1430 endpoints[epidx].in_ep = usb_endpoint_num(ep);
1432 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) 1431 if (usb_endpoint_xfer_int(ep))
1433 endpoints[epidx].in_interval = ep->bInterval; 1432 endpoints[epidx].in_interval = ep->bInterval;
1434 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) 1433 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW)
1435 endpoints[epidx].in_interval = 1; 1434 endpoints[epidx].in_interval = 1;
@@ -1495,20 +1494,20 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi,
1495 1494
1496 for (i = 0; i < intfd->bNumEndpoints; ++i) { 1495 for (i = 0; i < intfd->bNumEndpoints; ++i) {
1497 epd = get_endpoint(hostif, i); 1496 epd = get_endpoint(hostif, i);
1498 if ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK && 1497 if (!usb_endpoint_xfer_bulk(epd) &&
1499 (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) 1498 !usb_endpoint_xfer_int(epd))
1500 continue; 1499 continue;
1501 if (out_eps < max_endpoints && 1500 if (out_eps < max_endpoints &&
1502 (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 1501 usb_endpoint_dir_out(epd)) {
1503 endpoint[out_eps].out_ep = epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1502 endpoint[out_eps].out_ep = usb_endpoint_num(epd);
1504 if ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) 1503 if (usb_endpoint_xfer_int(epd))
1505 endpoint[out_eps].out_interval = epd->bInterval; 1504 endpoint[out_eps].out_interval = epd->bInterval;
1506 ++out_eps; 1505 ++out_eps;
1507 } 1506 }
1508 if (in_eps < max_endpoints && 1507 if (in_eps < max_endpoints &&
1509 (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) { 1508 usb_endpoint_dir_in(epd)) {
1510 endpoint[in_eps].in_ep = epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1509 endpoint[in_eps].in_ep = usb_endpoint_num(epd);
1511 if ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) 1510 if (usb_endpoint_xfer_int(epd))
1512 endpoint[in_eps].in_interval = epd->bInterval; 1511 endpoint[in_eps].in_interval = epd->bInterval;
1513 ++in_eps; 1512 ++in_eps;
1514 } 1513 }
@@ -1607,21 +1606,19 @@ static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi,
1607 } 1606 }
1608 1607
1609 epd = get_endpoint(hostif, 0); 1608 epd = get_endpoint(hostif, 0);
1610 if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN || 1609 if (!usb_endpoint_dir_in(epd) || !usb_endpoint_xfer_int(epd)) {
1611 (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) {
1612 snd_printdd(KERN_ERR "endpoint[0] isn't interrupt\n"); 1610 snd_printdd(KERN_ERR "endpoint[0] isn't interrupt\n");
1613 return -ENXIO; 1611 return -ENXIO;
1614 } 1612 }
1615 epd = get_endpoint(hostif, 2); 1613 epd = get_endpoint(hostif, 2);
1616 if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_OUT || 1614 if (!usb_endpoint_dir_out(epd) || !usb_endpoint_xfer_bulk(epd)) {
1617 (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) {
1618 snd_printdd(KERN_ERR "endpoint[2] isn't bulk output\n"); 1615 snd_printdd(KERN_ERR "endpoint[2] isn't bulk output\n");
1619 return -ENXIO; 1616 return -ENXIO;
1620 } 1617 }
1621 if (endpoint->out_cables > 0x0001) { 1618 if (endpoint->out_cables > 0x0001) {
1622 epd = get_endpoint(hostif, 4); 1619 epd = get_endpoint(hostif, 4);
1623 if ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_OUT || 1620 if (!usb_endpoint_dir_out(epd) ||
1624 (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_BULK) { 1621 !usb_endpoint_xfer_bulk(epd)) {
1625 snd_printdd(KERN_ERR "endpoint[4] isn't bulk output\n"); 1622 snd_printdd(KERN_ERR "endpoint[4] isn't bulk output\n");
1626 return -ENXIO; 1623 return -ENXIO;
1627 } 1624 }
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index a49246113e75..00397c8a765b 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -1755,11 +1755,10 @@ static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
1755 if (get_iface_desc(hostif)->bNumEndpoints < 1) 1755 if (get_iface_desc(hostif)->bNumEndpoints < 1)
1756 return 0; 1756 return 0;
1757 ep = get_endpoint(hostif, 0); 1757 ep = get_endpoint(hostif, 0);
1758 if ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN || 1758 if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_int(ep))
1759 (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
1760 return 0; 1759 return 0;
1761 1760
1762 epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 1761 epnum = usb_endpoint_num(ep);
1763 buffer_length = le16_to_cpu(ep->wMaxPacketSize); 1762 buffer_length = le16_to_cpu(ep->wMaxPacketSize);
1764 transfer_buffer = kmalloc(buffer_length, GFP_KERNEL); 1763 transfer_buffer = kmalloc(buffer_length, GFP_KERNEL);
1765 if (!transfer_buffer) 1764 if (!transfer_buffer)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index c2515b680f9f..73e59f4403a4 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -589,7 +589,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
589 struct us122l *us122l; 589 struct us122l *us122l;
590 struct list_head *p; 590 struct list_head *p;
591 591
592 card = dev_get_drvdata(&intf->dev); 592 card = usb_get_intfdata(intf);
593 if (!card) 593 if (!card)
594 return 0; 594 return 0;
595 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 595 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -615,7 +615,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
615 struct list_head *p; 615 struct list_head *p;
616 int err; 616 int err;
617 617
618 card = dev_get_drvdata(&intf->dev); 618 card = usb_get_intfdata(intf);
619 if (!card) 619 if (!card)
620 return 0; 620 return 0;
621 621
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index e5981a630314..ca26c532e77e 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -392,7 +392,7 @@ static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_i
392 void *chip; 392 void *chip;
393 chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id); 393 chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id);
394 if (chip) { 394 if (chip) {
395 dev_set_drvdata(&intf->dev, chip); 395 usb_set_intfdata(intf, chip);
396 return 0; 396 return 0;
397 } else 397 } else
398 return -EIO; 398 return -EIO;
@@ -401,7 +401,7 @@ static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_i
401static void snd_usX2Y_disconnect(struct usb_interface *intf) 401static void snd_usX2Y_disconnect(struct usb_interface *intf)
402{ 402{
403 usX2Y_usb_disconnect(interface_to_usbdev(intf), 403 usX2Y_usb_disconnect(interface_to_usbdev(intf),
404 dev_get_drvdata(&intf->dev)); 404 usb_get_intfdata(intf));
405} 405}
406 406
407MODULE_DEVICE_TABLE(usb, snd_usX2Y_usb_id_table); 407MODULE_DEVICE_TABLE(usb, snd_usX2Y_usb_id_table);
diff --git a/virt/kvm/vtd.c b/virt/kvm/iommu.c
index a770874f3a3a..e9693a29d00e 100644
--- a/virt/kvm/vtd.c
+++ b/virt/kvm/iommu.c
@@ -25,6 +25,7 @@
25#include <linux/kvm_host.h> 25#include <linux/kvm_host.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/dmar.h> 27#include <linux/dmar.h>
28#include <linux/iommu.h>
28#include <linux/intel-iommu.h> 29#include <linux/intel-iommu.h>
29 30
30static int kvm_iommu_unmap_memslots(struct kvm *kvm); 31static int kvm_iommu_unmap_memslots(struct kvm *kvm);
@@ -37,7 +38,7 @@ int kvm_iommu_map_pages(struct kvm *kvm,
37 gfn_t gfn = base_gfn; 38 gfn_t gfn = base_gfn;
38 pfn_t pfn; 39 pfn_t pfn;
39 int i, r = 0; 40 int i, r = 0;
40 struct dmar_domain *domain = kvm->arch.intel_iommu_domain; 41 struct iommu_domain *domain = kvm->arch.iommu_domain;
41 42
42 /* check if iommu exists and in use */ 43 /* check if iommu exists and in use */
43 if (!domain) 44 if (!domain)
@@ -45,20 +46,17 @@ int kvm_iommu_map_pages(struct kvm *kvm,
45 46
46 for (i = 0; i < npages; i++) { 47 for (i = 0; i < npages; i++) {
47 /* check if already mapped */ 48 /* check if already mapped */
48 pfn = (pfn_t)intel_iommu_iova_to_pfn(domain, 49 if (iommu_iova_to_phys(domain, gfn_to_gpa(gfn)))
49 gfn_to_gpa(gfn));
50 if (pfn)
51 continue; 50 continue;
52 51
53 pfn = gfn_to_pfn(kvm, gfn); 52 pfn = gfn_to_pfn(kvm, gfn);
54 r = intel_iommu_page_mapping(domain, 53 r = iommu_map_range(domain,
55 gfn_to_gpa(gfn), 54 gfn_to_gpa(gfn),
56 pfn_to_hpa(pfn), 55 pfn_to_hpa(pfn),
57 PAGE_SIZE, 56 PAGE_SIZE,
58 DMA_PTE_READ | 57 IOMMU_READ | IOMMU_WRITE);
59 DMA_PTE_WRITE);
60 if (r) { 58 if (r) {
61 printk(KERN_ERR "kvm_iommu_map_pages:" 59 printk(KERN_ERR "kvm_iommu_map_address:"
62 "iommu failed to map pfn=%lx\n", pfn); 60 "iommu failed to map pfn=%lx\n", pfn);
63 goto unmap_pages; 61 goto unmap_pages;
64 } 62 }
@@ -73,7 +71,7 @@ unmap_pages:
73 71
74static int kvm_iommu_map_memslots(struct kvm *kvm) 72static int kvm_iommu_map_memslots(struct kvm *kvm)
75{ 73{
76 int i, r; 74 int i, r = 0;
77 75
78 down_read(&kvm->slots_lock); 76 down_read(&kvm->slots_lock);
79 for (i = 0; i < kvm->nmemslots; i++) { 77 for (i = 0; i < kvm->nmemslots; i++) {
@@ -86,50 +84,79 @@ static int kvm_iommu_map_memslots(struct kvm *kvm)
86 return r; 84 return r;
87} 85}
88 86
89int kvm_iommu_map_guest(struct kvm *kvm, 87int kvm_assign_device(struct kvm *kvm,
90 struct kvm_assigned_dev_kernel *assigned_dev) 88 struct kvm_assigned_dev_kernel *assigned_dev)
91{ 89{
92 struct pci_dev *pdev = NULL; 90 struct pci_dev *pdev = NULL;
91 struct iommu_domain *domain = kvm->arch.iommu_domain;
93 int r; 92 int r;
94 93
95 if (!intel_iommu_found()) { 94 /* check if iommu exists and in use */
96 printk(KERN_ERR "%s: intel iommu not found\n", __func__); 95 if (!domain)
96 return 0;
97
98 pdev = assigned_dev->dev;
99 if (pdev == NULL)
97 return -ENODEV; 100 return -ENODEV;
101
102 r = iommu_attach_device(domain, &pdev->dev);
103 if (r) {
104 printk(KERN_ERR "assign device %x:%x.%x failed",
105 pdev->bus->number,
106 PCI_SLOT(pdev->devfn),
107 PCI_FUNC(pdev->devfn));
108 return r;
98 } 109 }
99 110
100 printk(KERN_DEBUG "VT-d direct map: host bdf = %x:%x:%x\n", 111 printk(KERN_DEBUG "assign device: host bdf = %x:%x:%x\n",
101 assigned_dev->host_busnr, 112 assigned_dev->host_busnr,
102 PCI_SLOT(assigned_dev->host_devfn), 113 PCI_SLOT(assigned_dev->host_devfn),
103 PCI_FUNC(assigned_dev->host_devfn)); 114 PCI_FUNC(assigned_dev->host_devfn));
115
116 return 0;
117}
118
119int kvm_deassign_device(struct kvm *kvm,
120 struct kvm_assigned_dev_kernel *assigned_dev)
121{
122 struct iommu_domain *domain = kvm->arch.iommu_domain;
123 struct pci_dev *pdev = NULL;
124
125 /* check if iommu exists and in use */
126 if (!domain)
127 return 0;
104 128
105 pdev = assigned_dev->dev; 129 pdev = assigned_dev->dev;
130 if (pdev == NULL)
131 return -ENODEV;
106 132
107 if (pdev == NULL) { 133 iommu_detach_device(domain, &pdev->dev);
108 if (kvm->arch.intel_iommu_domain) { 134
109 intel_iommu_domain_exit(kvm->arch.intel_iommu_domain); 135 printk(KERN_DEBUG "deassign device: host bdf = %x:%x:%x\n",
110 kvm->arch.intel_iommu_domain = NULL; 136 assigned_dev->host_busnr,
111 } 137 PCI_SLOT(assigned_dev->host_devfn),
138 PCI_FUNC(assigned_dev->host_devfn));
139
140 return 0;
141}
142
143int kvm_iommu_map_guest(struct kvm *kvm)
144{
145 int r;
146
147 if (!iommu_found()) {
148 printk(KERN_ERR "%s: iommu not found\n", __func__);
112 return -ENODEV; 149 return -ENODEV;
113 } 150 }
114 151
115 kvm->arch.intel_iommu_domain = intel_iommu_domain_alloc(pdev); 152 kvm->arch.iommu_domain = iommu_domain_alloc();
116 if (!kvm->arch.intel_iommu_domain) 153 if (!kvm->arch.iommu_domain)
117 return -ENODEV; 154 return -ENOMEM;
118 155
119 r = kvm_iommu_map_memslots(kvm); 156 r = kvm_iommu_map_memslots(kvm);
120 if (r) 157 if (r)
121 goto out_unmap; 158 goto out_unmap;
122 159
123 intel_iommu_detach_dev(kvm->arch.intel_iommu_domain,
124 pdev->bus->number, pdev->devfn);
125
126 r = intel_iommu_context_mapping(kvm->arch.intel_iommu_domain,
127 pdev);
128 if (r) {
129 printk(KERN_ERR "Domain context map for %s failed",
130 pci_name(pdev));
131 goto out_unmap;
132 }
133 return 0; 160 return 0;
134 161
135out_unmap: 162out_unmap:
@@ -138,19 +165,26 @@ out_unmap:
138} 165}
139 166
140static void kvm_iommu_put_pages(struct kvm *kvm, 167static void kvm_iommu_put_pages(struct kvm *kvm,
141 gfn_t base_gfn, unsigned long npages) 168 gfn_t base_gfn, unsigned long npages)
142{ 169{
143 gfn_t gfn = base_gfn; 170 gfn_t gfn = base_gfn;
144 pfn_t pfn; 171 pfn_t pfn;
145 struct dmar_domain *domain = kvm->arch.intel_iommu_domain; 172 struct iommu_domain *domain = kvm->arch.iommu_domain;
146 int i; 173 unsigned long i;
174 u64 phys;
175
176 /* check if iommu exists and in use */
177 if (!domain)
178 return;
147 179
148 for (i = 0; i < npages; i++) { 180 for (i = 0; i < npages; i++) {
149 pfn = (pfn_t)intel_iommu_iova_to_pfn(domain, 181 phys = iommu_iova_to_phys(domain, gfn_to_gpa(gfn));
150 gfn_to_gpa(gfn)); 182 pfn = phys >> PAGE_SHIFT;
151 kvm_release_pfn_clean(pfn); 183 kvm_release_pfn_clean(pfn);
152 gfn++; 184 gfn++;
153 } 185 }
186
187 iommu_unmap_range(domain, gfn_to_gpa(base_gfn), PAGE_SIZE * npages);
154} 188}
155 189
156static int kvm_iommu_unmap_memslots(struct kvm *kvm) 190static int kvm_iommu_unmap_memslots(struct kvm *kvm)
@@ -168,24 +202,13 @@ static int kvm_iommu_unmap_memslots(struct kvm *kvm)
168 202
169int kvm_iommu_unmap_guest(struct kvm *kvm) 203int kvm_iommu_unmap_guest(struct kvm *kvm)
170{ 204{
171 struct kvm_assigned_dev_kernel *entry; 205 struct iommu_domain *domain = kvm->arch.iommu_domain;
172 struct dmar_domain *domain = kvm->arch.intel_iommu_domain;
173 206
174 /* check if iommu exists and in use */ 207 /* check if iommu exists and in use */
175 if (!domain) 208 if (!domain)
176 return 0; 209 return 0;
177 210
178 list_for_each_entry(entry, &kvm->arch.assigned_dev_head, list) {
179 printk(KERN_DEBUG "VT-d unmap: host bdf = %x:%x:%x\n",
180 entry->host_busnr,
181 PCI_SLOT(entry->host_devfn),
182 PCI_FUNC(entry->host_devfn));
183
184 /* detach kvm dmar domain */
185 intel_iommu_detach_dev(domain, entry->host_busnr,
186 entry->host_devfn);
187 }
188 kvm_iommu_unmap_memslots(kvm); 211 kvm_iommu_unmap_memslots(kvm);
189 intel_iommu_domain_exit(domain); 212 iommu_domain_free(domain);
190 return 0; 213 return 0;
191} 214}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index fc6127cbea1f..3a5a08298aab 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -496,6 +496,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
496 match->assigned_dev_id = assigned_dev->assigned_dev_id; 496 match->assigned_dev_id = assigned_dev->assigned_dev_id;
497 match->host_busnr = assigned_dev->busnr; 497 match->host_busnr = assigned_dev->busnr;
498 match->host_devfn = assigned_dev->devfn; 498 match->host_devfn = assigned_dev->devfn;
499 match->flags = assigned_dev->flags;
499 match->dev = dev; 500 match->dev = dev;
500 match->irq_source_id = -1; 501 match->irq_source_id = -1;
501 match->kvm = kvm; 502 match->kvm = kvm;
@@ -503,7 +504,12 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
503 list_add(&match->list, &kvm->arch.assigned_dev_head); 504 list_add(&match->list, &kvm->arch.assigned_dev_head);
504 505
505 if (assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU) { 506 if (assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU) {
506 r = kvm_iommu_map_guest(kvm, match); 507 if (!kvm->arch.iommu_domain) {
508 r = kvm_iommu_map_guest(kvm);
509 if (r)
510 goto out_list_del;
511 }
512 r = kvm_assign_device(kvm, match);
507 if (r) 513 if (r)
508 goto out_list_del; 514 goto out_list_del;
509 } 515 }
@@ -525,6 +531,35 @@ out_free:
525} 531}
526#endif 532#endif
527 533
534#ifdef KVM_CAP_DEVICE_DEASSIGNMENT
535static int kvm_vm_ioctl_deassign_device(struct kvm *kvm,
536 struct kvm_assigned_pci_dev *assigned_dev)
537{
538 int r = 0;
539 struct kvm_assigned_dev_kernel *match;
540
541 mutex_lock(&kvm->lock);
542
543 match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
544 assigned_dev->assigned_dev_id);
545 if (!match) {
546 printk(KERN_INFO "%s: device hasn't been assigned before, "
547 "so cannot be deassigned\n", __func__);
548 r = -EINVAL;
549 goto out;
550 }
551
552 if (assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU)
553 kvm_deassign_device(kvm, match);
554
555 kvm_free_assigned_device(kvm, match);
556
557out:
558 mutex_unlock(&kvm->lock);
559 return r;
560}
561#endif
562
528static inline int valid_vcpu(int n) 563static inline int valid_vcpu(int n)
529{ 564{
530 return likely(n >= 0 && n < KVM_MAX_VCPUS); 565 return likely(n >= 0 && n < KVM_MAX_VCPUS);
@@ -1858,6 +1893,19 @@ static long kvm_vm_ioctl(struct file *filp,
1858 break; 1893 break;
1859 } 1894 }
1860#endif 1895#endif
1896#ifdef KVM_CAP_DEVICE_DEASSIGNMENT
1897 case KVM_DEASSIGN_PCI_DEVICE: {
1898 struct kvm_assigned_pci_dev assigned_dev;
1899
1900 r = -EFAULT;
1901 if (copy_from_user(&assigned_dev, argp, sizeof assigned_dev))
1902 goto out;
1903 r = kvm_vm_ioctl_deassign_device(kvm, &assigned_dev);
1904 if (r)
1905 goto out;
1906 break;
1907 }
1908#endif
1861 default: 1909 default:
1862 r = kvm_arch_vm_ioctl(filp, ioctl, arg); 1910 r = kvm_arch_vm_ioctl(filp, ioctl, arg);
1863 } 1911 }