]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Merge branch 'hid-suspend' into picolcd
authorJiri Kosina <jkosina@suse.cz>
Mon, 3 May 2010 13:25:35 +0000 (15:25 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 3 May 2010 13:25:35 +0000 (15:25 +0200)
4692 files changed:
Documentation/ABI/testing/sysfs-bus-usb
Documentation/DMA-API-HOWTO.txt [new file with mode: 0644]
Documentation/PCI/PCI-DMA-mapping.txt [deleted file]
Documentation/cgroups/memory.txt
Documentation/circular-buffers.txt [new file with mode: 0644]
Documentation/connector/cn_test.c
Documentation/filesystems/00-INDEX
Documentation/filesystems/9p.txt
Documentation/filesystems/ceph.txt [new file with mode: 0644]
Documentation/filesystems/tmpfs.txt
Documentation/ioctl/ioctl-number.txt
Documentation/kobject.txt
Documentation/memory-barriers.txt
Documentation/networking/stmmac.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe.txt
Documentation/volatile-considered-harmful.txt
MAINTAINERS
Makefile
arch/alpha/boot/bootp.c
arch/alpha/boot/bootpz.c
arch/alpha/boot/main.c
arch/alpha/boot/misc.c
arch/alpha/include/asm/core_marvel.h
arch/alpha/include/asm/core_mcpcia.h
arch/alpha/include/asm/core_titan.h
arch/alpha/include/asm/core_tsunami.h
arch/alpha/kernel/irq.c
arch/alpha/kernel/osf_sys.c
arch/alpha/kernel/pci-noop.c
arch/alpha/kernel/pci-sysfs.c
arch/alpha/kernel/pci_iommu.c
arch/alpha/kernel/process.c
arch/alpha/kernel/ptrace.c
arch/alpha/kernel/smc37c669.c
arch/alpha/kernel/smc37c93x.c
arch/alpha/kernel/srm_env.c
arch/alpha/kernel/sys_dp264.c
arch/alpha/kernel/sys_titan.c
arch/alpha/kernel/traps.c
arch/alpha/mm/init.c
arch/arm/common/clkdev.c
arch/arm/common/it8152.c
arch/arm/common/locomo.c
arch/arm/include/asm/cacheflush.h
arch/arm/include/asm/clkdev.h
arch/arm/include/asm/irq.h
arch/arm/include/asm/outercache.h [new file with mode: 0644]
arch/arm/include/asm/system.h
arch/arm/kernel/irq.c
arch/arm/kernel/kprobes.c
arch/arm/kernel/module.c
arch/arm/kernel/process.c
arch/arm/kernel/sys_arm.c
arch/arm/lib/memmove.S
arch/arm/lib/uaccess_with_memcpy.c
arch/arm/mach-aaec2000/core.c
arch/arm/mach-bcmring/dma.c
arch/arm/mach-davinci/board-dm365-evm.c
arch/arm/mach-davinci/dma.c
arch/arm/mach-h720x/common.c
arch/arm/mach-integrator/cpu.c
arch/arm/mach-integrator/impd1.c
arch/arm/mach-integrator/integrator_cp.c
arch/arm/mach-integrator/pci_v3.c
arch/arm/mach-iop13xx/pci.c
arch/arm/mach-iop32x/glantank.c
arch/arm/mach-iop32x/iq31244.c
arch/arm/mach-iop32x/iq80321.c
arch/arm/mach-iop32x/n2100.c
arch/arm/mach-iop33x/iq80331.c
arch/arm/mach-iop33x/iq80332.c
arch/arm/mach-ixp2000/enp2611.c
arch/arm/mach-ixp2000/ixdp2400.c
arch/arm/mach-ixp2000/ixdp2800.c
arch/arm/mach-ixp2000/ixdp2x00.c
arch/arm/mach-ixp2000/ixdp2x01.c
arch/arm/mach-ixp2000/pci.c
arch/arm/mach-ixp23xx/include/mach/memory.h
arch/arm/mach-ixp23xx/pci.c
arch/arm/mach-ixp4xx/avila-setup.c
arch/arm/mach-ixp4xx/coyote-setup.c
arch/arm/mach-ixp4xx/gateway7001-setup.c
arch/arm/mach-ixp4xx/gtwx5715-setup.c
arch/arm/mach-ixp4xx/ixdp425-setup.c
arch/arm/mach-ixp4xx/ixp4xx_npe.c
arch/arm/mach-ixp4xx/wg302v2-setup.c
arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c
arch/arm/mach-kirkwood/pcie.c
arch/arm/mach-lh7a40x/clcd.c
arch/arm/mach-mmp/include/mach/uncompress.h
arch/arm/mach-mx3/mach-mx31moboard.c
arch/arm/mach-mx3/mach-pcm037.c
arch/arm/mach-mx3/mx31moboard-devboard.c
arch/arm/mach-mx3/mx31moboard-marxbot.c
arch/arm/mach-netx/fb.c
arch/arm/mach-netx/xc.c
arch/arm/mach-nomadik/gpio.c
arch/arm/mach-ns9xxx/plat-serial8250.c
arch/arm/mach-ns9xxx/processor-ns9360.c
arch/arm/mach-omap1/mcbsp.c
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
arch/arm/mach-omap2/iommu2.c
arch/arm/mach-omap2/mcbsp.c
arch/arm/mach-omap2/mux.c
arch/arm/mach-omap2/pm-debug.c
arch/arm/mach-omap2/pm34xx.c
arch/arm/mach-orion5x/pci.c
arch/arm/mach-orion5x/wrt350n-v2-setup.c
arch/arm/mach-pnx4008/dma.c
arch/arm/mach-pnx4008/pm.c
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/corgi_ssp.c
arch/arm/mach-pxa/cpufreq-pxa3xx.c
arch/arm/mach-pxa/imote2.c
arch/arm/mach-pxa/include/mach/uncompress.h
arch/arm/mach-pxa/mioa701.c
arch/arm/mach-pxa/pm.c
arch/arm/mach-pxa/raumfeld.c
arch/arm/mach-pxa/stargate2.c
arch/arm/mach-pxa/viper.c
arch/arm/mach-realview/core.c
arch/arm/mach-rpc/dma.c
arch/arm/mach-s3c64xx/dma.c
arch/arm/mach-sa1100/jornada720_ssp.c
arch/arm/mach-sa1100/neponset.c
arch/arm/mach-u300/dummyspichip.c
arch/arm/mach-u300/mmc.c
arch/arm/mach-versatile/core.c
arch/arm/mach-versatile/pci.c
arch/arm/mach-w90x900/dev.c
arch/arm/mm/Kconfig
arch/arm/mm/cache-l2x0.c
arch/arm/mm/dma-mapping.c
arch/arm/mm/fault-armv.c
arch/arm/mm/init.c
arch/arm/mm/pgd.c
arch/arm/plat-mxc/audmux-v2.c
arch/arm/plat-mxc/pwm.c
arch/arm/plat-omap/devices.c
arch/arm/plat-omap/dma.c
arch/arm/plat-omap/iommu-debug.c
arch/arm/plat-omap/iommu.c
arch/arm/plat-omap/iovmm.c
arch/arm/plat-omap/mailbox.c
arch/arm/plat-omap/mcbsp.c
arch/arm/plat-omap/omap_device.c
arch/arm/plat-pxa/dma.c
arch/arm/plat-pxa/pwm.c
arch/arm/plat-s3c24xx/cpu-freq.c
arch/arm/plat-s3c24xx/devs.c
arch/arm/plat-s3c24xx/s3c2410-iotiming.c
arch/arm/plat-s3c24xx/s3c2412-iotiming.c
arch/arm/plat-samsung/adc.c
arch/arm/plat-samsung/dev-fb.c
arch/arm/plat-samsung/dev-i2c0.c
arch/arm/plat-samsung/dev-i2c1.c
arch/arm/plat-samsung/dev-nand.c
arch/arm/plat-samsung/dev-usb.c
arch/arm/plat-samsung/pm-check.c
arch/arm/plat-samsung/pwm.c
arch/arm/plat-stmp3xxx/dma.c
arch/arm/tools/mach-types
arch/arm/vfp/vfpmodule.c
arch/avr32/kernel/process.c
arch/avr32/mach-at32ap/at32ap700x.c
arch/avr32/mach-at32ap/extint.c
arch/avr32/mach-at32ap/hsmc.c
arch/avr32/mm/dma-coherent.c
arch/avr32/mm/init.c
arch/avr32/mm/ioremap.c
arch/blackfin/include/asm/mmu_context.h
arch/blackfin/kernel/ipipe.c
arch/blackfin/kernel/process.c
arch/blackfin/mach-common/pm.c
arch/blackfin/mach-common/smp.c
arch/blackfin/mm/init.c
arch/blackfin/mm/isram-driver.c
arch/blackfin/mm/sram-alloc.c
arch/cris/arch-v10/drivers/i2c.c
arch/cris/arch-v10/drivers/sync_serial.c
arch/cris/arch-v10/kernel/process.c
arch/cris/arch-v32/drivers/i2c.c
arch/cris/arch-v32/drivers/pci/bios.c
arch/cris/arch-v32/drivers/pci/dma.c
arch/cris/arch-v32/drivers/sync_serial.c
arch/cris/arch-v32/kernel/process.c
arch/cris/arch-v32/kernel/signal.c
arch/cris/kernel/irq.c
arch/cris/kernel/module.c
arch/cris/kernel/profile.c
arch/cris/mm/init.c
arch/frv/kernel/irq.c
arch/frv/kernel/sysctl.c
arch/frv/mb93090-mb00/pci-dma.c
arch/frv/mb93090-mb00/pci-frv.c
arch/frv/mb93090-mb00/pci-irq.c
arch/frv/mb93090-mb00/pci-vdk.c
arch/frv/mm/dma-alloc.c
arch/frv/mm/init.c
arch/frv/mm/pgalloc.c
arch/h8300/kernel/process.c
arch/h8300/mm/init.c
arch/h8300/mm/kmap.c
arch/h8300/mm/memory.c
arch/ia64/include/asm/dmi.h
arch/ia64/kernel/acpi-ext.c
arch/ia64/kernel/acpi.c
arch/ia64/kernel/cpufreq/acpi-cpufreq.c
arch/ia64/kernel/efi.c
arch/ia64/kernel/iosapic.c
arch/ia64/kernel/irq_ia64.c
arch/ia64/kernel/mca.c
arch/ia64/kernel/mca_drv.c
arch/ia64/kernel/pci-swiotlb.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/process.c
arch/ia64/kernel/ptrace.c
arch/ia64/kernel/topology.c
arch/ia64/kernel/uncached.c
arch/ia64/kvm/kvm-ia64.c
arch/ia64/mm/discontig.c
arch/ia64/mm/hugetlbpage.c
arch/ia64/mm/tlb.c
arch/ia64/sn/kernel/bte.c
arch/ia64/sn/kernel/io_acpi_init.c
arch/ia64/sn/kernel/io_common.c
arch/ia64/sn/kernel/io_init.c
arch/ia64/sn/kernel/irq.c
arch/ia64/sn/kernel/msi_sn.c
arch/ia64/sn/pci/pci_dma.c
arch/ia64/sn/pci/pcibr/pcibr_provider.c
arch/ia64/sn/pci/tioca_provider.c
arch/ia64/sn/pci/tioce_provider.c
arch/ia64/xen/grant-table.c
arch/m32r/kernel/process.c
arch/m32r/mm/init.c
arch/m68k/bvme6000/rtc.c
arch/m68k/kernel/dma.c
arch/m68k/kernel/process.c
arch/m68k/mac/misc.c
arch/m68k/mm/init.c
arch/m68k/mm/memory.c
arch/m68k/mm/motorola.c
arch/m68k/mvme16x/rtc.c
arch/m68k/sun3/sun3dvma.c
arch/m68k/sun3x/dvma.c
arch/m68knommu/kernel/dma.c
arch/m68knommu/kernel/process.c
arch/m68knommu/mm/init.c
arch/m68knommu/mm/kmap.c
arch/m68knommu/mm/memory.c
arch/microblaze/Kconfig
arch/microblaze/Makefile
arch/microblaze/boot/Makefile
arch/microblaze/include/asm/processor.h
arch/microblaze/include/asm/segment.h [deleted file]
arch/microblaze/include/asm/thread_info.h
arch/microblaze/include/asm/tlbflush.h
arch/microblaze/include/asm/uaccess.h
arch/microblaze/kernel/cpu/cpuinfo.c
arch/microblaze/kernel/dma.c
arch/microblaze/kernel/head.S
arch/microblaze/kernel/hw_exception_handler.S
arch/microblaze/kernel/misc.S
arch/microblaze/kernel/module.c
arch/microblaze/kernel/of_platform.c
arch/microblaze/kernel/process.c
arch/microblaze/kernel/setup.c
arch/microblaze/kernel/sys_microblaze.c
arch/microblaze/kernel/traps.c
arch/microblaze/lib/Makefile
arch/microblaze/lib/fastcopy.S
arch/microblaze/lib/memcpy.c
arch/microblaze/lib/memset.c
arch/microblaze/lib/uaccess.c [deleted file]
arch/microblaze/lib/uaccess_old.S
arch/microblaze/mm/consistent.c
arch/microblaze/mm/fault.c
arch/microblaze/mm/init.c
arch/microblaze/mm/pgtable.c
arch/microblaze/pci/pci-common.c
arch/microblaze/pci/pci_32.c
arch/mips/jazz/jazzdma.c
arch/mips/kernel/irq.c
arch/mips/kernel/linux32.c
arch/mips/kernel/process.c
arch/mips/kernel/rtlx.c
arch/mips/kernel/smtc.c
arch/mips/kernel/syscall.c
arch/mips/mipssim/sim_int.c
arch/mips/mm/dma-default.c
arch/mips/mm/hugetlbpage.c
arch/mips/mm/init.c
arch/mips/mm/ioremap.c
arch/mips/mti-malta/malta-int.c
arch/mips/nxp/pnx833x/common/reset.c
arch/mips/nxp/pnx8550/common/int.c
arch/mips/nxp/pnx8550/common/proc.c
arch/mips/nxp/pnx8550/common/reset.c
arch/mips/pci/ops-titan-ht.c
arch/mips/pmc-sierra/msp71xx/msp_prom.c
arch/mips/pmc-sierra/yosemite/ht.c
arch/mips/pmc-sierra/yosemite/irq.c
arch/mips/powertv/asic/asic_devices.c
arch/mips/powertv/asic/asic_int.c
arch/mips/rb532/irq.c
arch/mips/sgi-ip27/ip27-irq.c
arch/mips/sgi-ip32/ip32-irq.c
arch/mips/sibyte/bcm1480/irq.c
arch/mips/sibyte/common/sb_tbprof.c
arch/mips/sibyte/sb1250/irq.c
arch/mips/txx9/generic/pci.c
arch/mips/txx9/generic/setup.c
arch/mips/txx9/generic/spi_eeprom.c
arch/mips/txx9/rbtx4939/setup.c
arch/mn10300/kernel/process.c
arch/mn10300/kernel/setup.c
arch/mn10300/mm/dma-alloc.c
arch/mn10300/mm/init.c
arch/mn10300/mm/pgtable.c
arch/mn10300/unit-asb2305/pci-irq.c
arch/parisc/hpux/fs.c
arch/parisc/kernel/module.c
arch/parisc/kernel/pci-dma.c
arch/parisc/kernel/pci.c
arch/parisc/kernel/process.c
arch/parisc/kernel/signal32.c
arch/parisc/kernel/smp.c
arch/parisc/mm/init.c
arch/powerpc/Kconfig
arch/powerpc/include/asm/asm-compat.h
arch/powerpc/include/asm/ppc-opcode.h
arch/powerpc/include/asm/syscall.h
arch/powerpc/kernel/cacheinfo.c
arch/powerpc/kernel/dma.c
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/kernel/ibmebus.c
arch/powerpc/kernel/iommu.c
arch/powerpc/kernel/kprobes.c
arch/powerpc/kernel/lparcfg.c
arch/powerpc/kernel/misc.S
arch/powerpc/kernel/of_platform.c
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/pci_32.c
arch/powerpc/kernel/pci_dn.c
arch/powerpc/kernel/proc_powerpc.c
arch/powerpc/kernel/rtas.c
arch/powerpc/kernel/rtas_flash.c
arch/powerpc/kernel/rtasd.c
arch/powerpc/kernel/setup_32.c
arch/powerpc/kernel/setup_64.c
arch/powerpc/kernel/smp-tbsync.c
arch/powerpc/kernel/softemu8xx.c
arch/powerpc/kernel/sys_ppc32.c
arch/powerpc/kernel/traps.c
arch/powerpc/kernel/vio.c
arch/powerpc/kvm/44x.c
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/booke.c
arch/powerpc/kvm/e500.c
arch/powerpc/kvm/e500_tlb.c
arch/powerpc/kvm/powerpc.c
arch/powerpc/lib/devres.c
arch/powerpc/mm/dma-noncoherent.c
arch/powerpc/mm/hugetlbpage.c
arch/powerpc/mm/init_32.c
arch/powerpc/mm/init_64.c
arch/powerpc/mm/mem.c
arch/powerpc/mm/mmu_context_hash64.c
arch/powerpc/mm/mmu_context_nohash.c
arch/powerpc/mm/pgtable.c
arch/powerpc/mm/pgtable_32.c
arch/powerpc/mm/pgtable_64.c
arch/powerpc/mm/subpage-prot.c
arch/powerpc/oprofile/cell/spu_task_sync.c
arch/powerpc/oprofile/cell/vma_map.c
arch/powerpc/platforms/44x/warp.c
arch/powerpc/platforms/52xx/mpc52xx_gpio.c
arch/powerpc/platforms/52xx/mpc52xx_gpt.c
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
arch/powerpc/platforms/82xx/ep8248e.c
arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
arch/powerpc/platforms/86xx/gef_gpio.c
arch/powerpc/platforms/8xx/m8xx_setup.c
arch/powerpc/platforms/cell/axon_msi.c
arch/powerpc/platforms/cell/celleb_pci.c
arch/powerpc/platforms/cell/celleb_scc_pciex.c
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/cell/ras.c
arch/powerpc/platforms/cell/setup.c
arch/powerpc/platforms/cell/spider-pci.c
arch/powerpc/platforms/cell/spu_manage.c
arch/powerpc/platforms/cell/spu_priv1_mmio.c
arch/powerpc/platforms/cell/spufs/coredump.c
arch/powerpc/platforms/cell/spufs/file.c
arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
arch/powerpc/platforms/cell/spufs/sched.c
arch/powerpc/platforms/cell/spufs/syscalls.c
arch/powerpc/platforms/chrp/nvram.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/iseries/iommu.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/iseries/pci.c
arch/powerpc/platforms/iseries/vio.c
arch/powerpc/platforms/iseries/viopath.c
arch/powerpc/platforms/maple/setup.c
arch/powerpc/platforms/pasemi/dma_lib.c
arch/powerpc/platforms/pasemi/gpio_mdio.c
arch/powerpc/platforms/pasemi/setup.c
arch/powerpc/platforms/powermac/cpufreq_32.c
arch/powerpc/platforms/powermac/cpufreq_64.c
arch/powerpc/platforms/powermac/low_i2c.c
arch/powerpc/platforms/powermac/nvram.c
arch/powerpc/platforms/powermac/pfunc_core.c
arch/powerpc/platforms/powermac/setup.c
arch/powerpc/platforms/ps3/device-init.c
arch/powerpc/platforms/ps3/mm.c
arch/powerpc/platforms/ps3/os-area.c
arch/powerpc/platforms/ps3/spu.c
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/platforms/pseries/cmm.c
arch/powerpc/platforms/pseries/dlpar.c
arch/powerpc/platforms/pseries/dtl.c
arch/powerpc/platforms/pseries/eeh_cache.c
arch/powerpc/platforms/pseries/eeh_event.c
arch/powerpc/platforms/pseries/nvram.c
arch/powerpc/platforms/pseries/phyp_dump.c
arch/powerpc/platforms/pseries/ras.c
arch/powerpc/platforms/pseries/reconfig.c
arch/powerpc/platforms/pseries/scanlog.c
arch/powerpc/platforms/pseries/setup.c
arch/powerpc/sysdev/cpm1.c
arch/powerpc/sysdev/cpm_common.c
arch/powerpc/sysdev/dart_iommu.c
arch/powerpc/sysdev/fsl_gtm.c
arch/powerpc/sysdev/fsl_msi.c
arch/powerpc/sysdev/fsl_pci.c
arch/powerpc/sysdev/fsl_rio.c
arch/powerpc/sysdev/mpc8xxx_gpio.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/msi_bitmap.c
arch/powerpc/sysdev/of_rtc.c
arch/powerpc/sysdev/pmi.c
arch/powerpc/sysdev/ppc4xx_gpio.c
arch/powerpc/sysdev/ppc4xx_pci.c
arch/powerpc/sysdev/qe_lib/gpio.c
arch/powerpc/sysdev/qe_lib/ucc.c
arch/powerpc/sysdev/simple_gpio.c
arch/powerpc/sysdev/tsi108_pci.c
arch/s390/appldata/appldata_mem.c
arch/s390/appldata/appldata_net_sum.c
arch/s390/boot/compressed/misc.c
arch/s390/crypto/prng.c
arch/s390/hypfs/hypfs_diag.c
arch/s390/hypfs/inode.c
arch/s390/include/asm/system.h
arch/s390/kernel/compat_linux.c
arch/s390/kernel/head.S
arch/s390/kernel/head64.S
arch/s390/kernel/ipl.c
arch/s390/kernel/kprobes.c
arch/s390/kernel/process.c
arch/s390/kernel/setup.c
arch/s390/kernel/smp.c
arch/s390/kernel/sysinfo.c
arch/s390/kernel/time.c
arch/s390/kvm/interrupt.c
arch/s390/kvm/priv.c
arch/s390/kvm/sigp.c
arch/s390/mm/cmm.c
arch/s390/mm/init.c
arch/s390/mm/maccess.c
arch/s390/mm/page-states.c
arch/s390/mm/pgtable.c
arch/s390/mm/vmem.c
arch/score/kernel/sys_score.c
arch/score/mm/init.c
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/boards/mach-se/7724/setup.c
arch/sh/configs/ecovec24_defconfig
arch/sh/drivers/dma/dma-api.c
arch/sh/drivers/dma/dmabrg.c
arch/sh/drivers/heartbeat.c
arch/sh/drivers/pci/pcie-sh7786.c
arch/sh/drivers/push-switch.c
arch/sh/include/asm/elf.h
arch/sh/include/asm/mmu.h
arch/sh/include/cpu-sh4/cpu/mmu_context.h
arch/sh/include/cpu-sh4/cpu/watchdog.h
arch/sh/kernel/cpu/fpu.c
arch/sh/kernel/cpu/hwblk.c
arch/sh/kernel/cpufreq.c
arch/sh/kernel/dwarf.c
arch/sh/kernel/idle.c
arch/sh/kernel/kprobes.c
arch/sh/kernel/perf_event.c
arch/sh/kernel/process.c
arch/sh/kernel/process_32.c
arch/sh/kernel/process_64.c
arch/sh/kernel/ptrace_32.c
arch/sh/kernel/return_address.c
arch/sh/kernel/smp.c
arch/sh/kernel/vsyscall/vsyscall.c
arch/sh/mm/consistent.c
arch/sh/mm/hugetlbpage.c
arch/sh/mm/init.c
arch/sh/mm/ioremap.c
arch/sh/mm/ioremap_fixed.c
arch/sh/mm/pgtable.c
arch/sh/mm/pmb.c
arch/sh/mm/tlb-pteaex.c
arch/sh/mm/tlb-sh3.c
arch/sh/mm/tlb-sh4.c
arch/sh/mm/tlb-urb.c
arch/sh/mm/tlbflush_32.c
arch/sh/mm/uncached.c
arch/sparc/configs/sparc64_defconfig
arch/sparc/include/asm/stat.h
arch/sparc/kernel/central.c
arch/sparc/kernel/cpumap.c
arch/sparc/kernel/helpers.S
arch/sparc/kernel/hvapi.c
arch/sparc/kernel/iommu.c
arch/sparc/kernel/kprobes.c
arch/sparc/kernel/led.c
arch/sparc/kernel/leon_kernel.c
arch/sparc/kernel/leon_smp.c
arch/sparc/kernel/module.c
arch/sparc/kernel/of_device_common.c
arch/sparc/kernel/pci_msi.c
arch/sparc/kernel/perf_event.c
arch/sparc/kernel/process_32.c
arch/sparc/kernel/ptrace_32.c
arch/sparc/kernel/ptrace_64.c
arch/sparc/kernel/setup_64.c
arch/sparc/kernel/smp_64.c
arch/sparc/kernel/sun4c_irq.c
arch/sparc/kernel/sun4m_irq.c
arch/sparc/kernel/sys_sparc32.c
arch/sparc/kernel/sysfs.c
arch/sparc/kernel/traps_64.c
arch/sparc/kernel/us2e_cpufreq.c
arch/sparc/kernel/us3_cpufreq.c
arch/sparc/kernel/vio.c
arch/sparc/mm/hugetlbpage.c
arch/sparc/mm/init_32.c
arch/sparc/mm/init_64.c
arch/sparc/mm/srmmu.c
arch/sparc/mm/sun4c.c
arch/sparc/mm/tsb.c
arch/um/drivers/net_kern.c
arch/um/drivers/port_kern.c
arch/um/drivers/ubd_kern.c
arch/um/kernel/exec.c
arch/um/kernel/irq.c
arch/um/kernel/mem.c
arch/um/kernel/process.c
arch/um/kernel/reboot.c
arch/um/kernel/skas/mmu.c
arch/um/os-Linux/helper.c
arch/um/sys-i386/ldt.c
arch/x86/crypto/fpu.c
arch/x86/ia32/ia32_aout.c
arch/x86/ia32/sys_ia32.c
arch/x86/include/asm/fixmap.h
arch/x86/include/asm/hw_irq.h
arch/x86/include/asm/msr-index.h
arch/x86/include/asm/pgtable_32.h
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/alternative.c
arch/x86/kernel/amd_iommu.c
arch/x86/kernel/amd_iommu_init.c
arch/x86/kernel/apb_timer.c
arch/x86/kernel/apic/es7000_32.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/apic/nmi.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/bootflag.c
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
arch/x86/kernel/cpu/cpufreq/elanfreq.c
arch/x86/kernel/cpu/cpufreq/gx-suspmod.c
arch/x86/kernel/cpu/cpufreq/longrun.c
arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c
arch/x86/kernel/cpu/cpufreq/powernow-k6.c
arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
arch/x86/kernel/cpu/cpufreq/speedstep-lib.c
arch/x86/kernel/cpu/cpufreq/speedstep-smi.c
arch/x86/kernel/cpu/mcheck/mce-inject.c
arch/x86/kernel/cpu/mcheck/mce.c
arch/x86/kernel/cpu/mcheck/mce_amd.c
arch/x86/kernel/cpu/mcheck/mce_intel.c
arch/x86/kernel/cpu/mtrr/generic.c
arch/x86/kernel/cpu/mtrr/if.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event_amd.c
arch/x86/kernel/cpuid.c
arch/x86/kernel/crash_dump_32.c
arch/x86/kernel/dumpstack.h
arch/x86/kernel/head32.c
arch/x86/kernel/head64.c
arch/x86/kernel/hpet.c
arch/x86/kernel/i387.c
arch/x86/kernel/i8259.c
arch/x86/kernel/irqinit.c
arch/x86/kernel/k8.c
arch/x86/kernel/kdebugfs.c
arch/x86/kernel/kgdb.c
arch/x86/kernel/ldt.c
arch/x86/kernel/machine_kexec_64.c
arch/x86/kernel/mca_32.c
arch/x86/kernel/module.c
arch/x86/kernel/msr.c
arch/x86/kernel/pci-dma.c
arch/x86/kernel/pci-gart_64.c
arch/x86/kernel/pci-nommu.c
arch/x86/kernel/process.c
arch/x86/kernel/ptrace.c
arch/x86/kernel/setup.c
arch/x86/kernel/smp.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/tlb_uv.c
arch/x86/kernel/uv_irq.c
arch/x86/kernel/uv_time.c
arch/x86/kernel/vmi_32.c
arch/x86/kernel/vmlinux.lds.S
arch/x86/kvm/i8254.c
arch/x86/kvm/i8259.c
arch/x86/kvm/lapic.c
arch/x86/kvm/mmu.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/mm/hugetlbpage.c
arch/x86/mm/init.c
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
arch/x86/mm/kmmio.c
arch/x86/mm/mmio-mod.c
arch/x86/mm/pageattr.c
arch/x86/mm/pat.c
arch/x86/mm/pgtable.c
arch/x86/mm/pgtable_32.c
arch/x86/pci/acpi.c
arch/x86/pci/common.c
arch/x86/pci/i386.c
arch/x86/pci/irq.c
arch/x86/pci/mmconfig-shared.c
arch/x86/pci/pcbios.c
arch/x86/power/hibernate_32.c
arch/x86/power/hibernate_64.c
arch/x86/vdso/vma.c
arch/x86/xen/debugfs.c
arch/x86/xen/enlighten.c
arch/x86/xen/mmu.c
arch/x86/xen/smp.c
arch/x86/xen/spinlock.c
arch/x86/xen/time.c
arch/xtensa/kernel/pci-dma.c
arch/xtensa/kernel/process.c
arch/xtensa/mm/init.c
arch/xtensa/platforms/iss/console.c
block/blk-barrier.c
block/blk-cgroup.c
block/blk-integrity.c
block/blk-ioc.c
block/blk-settings.c
block/blk-sysfs.c
block/blk-tag.c
block/bsg.c
block/cfq-iosched.c
block/compat_ioctl.c
block/ioctl.c
block/noop-iosched.c
crypto/algapi.c
crypto/algboss.c
crypto/async_tx/async_pq.c
crypto/async_tx/raid6test.c
crypto/hmac.c
crypto/rng.c
crypto/seqiv.c
crypto/tcrypt.c
crypto/xor.c
drivers/acpi/ac.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/acpi_pad.c
drivers/acpi/battery.c
drivers/acpi/bus.c
drivers/acpi/button.c
drivers/acpi/container.c
drivers/acpi/debug.c
drivers/acpi/dock.c
drivers/acpi/ec.c
drivers/acpi/event.c
drivers/acpi/glue.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/pci_slot.c
drivers/acpi/power.c
drivers/acpi/power_meter.c
drivers/acpi/processor_core.c
drivers/acpi/processor_driver.c
drivers/acpi/processor_idle.c
drivers/acpi/processor_perflib.c
drivers/acpi/processor_throttling.c
drivers/acpi/sbs.c
drivers/acpi/sbshc.c
drivers/acpi/scan.c
drivers/acpi/system.c
drivers/acpi/thermal.c
drivers/acpi/utils.c
drivers/acpi/video.c
drivers/ata/ahci.c
drivers/ata/ata_piix.c
drivers/ata/libata-acpi.c
drivers/ata/libata-core.c
drivers/ata/libata-pmp.c
drivers/ata/libata-scsi.c
drivers/ata/libata-sff.c
drivers/ata/pata_acpi.c
drivers/ata/pata_at32.c
drivers/ata/pata_at91.c
drivers/ata/pata_atp867x.c
drivers/ata/pata_cmd640.c
drivers/ata/pata_icside.c
drivers/ata/pata_it821x.c
drivers/ata/pata_macio.c
drivers/ata/pata_mpc52xx.c
drivers/ata/pata_octeon_cf.c
drivers/ata/pata_pcmcia.c
drivers/ata/pata_rb532_cf.c
drivers/ata/pata_rdc.c
drivers/ata/pata_via.c
drivers/ata/pdc_adma.c
drivers/ata/sata_fsl.c
drivers/ata/sata_inic162x.c
drivers/ata/sata_mv.c
drivers/ata/sata_nv.c
drivers/ata/sata_promise.c
drivers/ata/sata_qstor.c
drivers/ata/sata_sil24.c
drivers/ata/sata_sx4.c
drivers/ata/sata_uli.c
drivers/atm/adummy.c
drivers/atm/ambassador.c
drivers/atm/atmtcp.c
drivers/atm/eni.c
drivers/atm/firestream.c
drivers/atm/he.c
drivers/atm/horizon.c
drivers/atm/idt77105.c
drivers/atm/idt77252.c
drivers/atm/iphase.c
drivers/atm/lanai.c
drivers/atm/nicstar.c
drivers/atm/solos-pci.c
drivers/atm/suni.c
drivers/atm/uPD98402.c
drivers/atm/zatm.c
drivers/auxdisplay/cfag12864b.c
drivers/auxdisplay/cfag12864bfb.c
drivers/base/attribute_container.c
drivers/base/bus.c
drivers/base/class.c
drivers/base/core.c
drivers/base/cpu.c
drivers/base/devres.c
drivers/base/devtmpfs.c
drivers/base/dma-coherent.c
drivers/base/dma-mapping.c
drivers/base/driver.c
drivers/base/firmware_class.c
drivers/base/memory.c
drivers/base/module.c
drivers/base/node.c
drivers/base/platform.c
drivers/base/power/main.c
drivers/base/sys.c
drivers/block/amiflop.c
drivers/block/aoe/aoeblk.c
drivers/block/aoe/aoechr.c
drivers/block/aoe/aoecmd.c
drivers/block/aoe/aoedev.c
drivers/block/aoe/aoenet.c
drivers/block/brd.c
drivers/block/drbd/drbd_bitmap.c
drivers/block/drbd/drbd_proc.c
drivers/block/hd.c
drivers/block/loop.c
drivers/block/mg_disk.c
drivers/block/nbd.c
drivers/block/osdblk.c
drivers/block/paride/pd.c
drivers/block/pktcdvd.c
drivers/block/ps3disk.c
drivers/block/ps3vram.c
drivers/block/swim.c
drivers/block/ub.c
drivers/block/umem.c
drivers/block/virtio_blk.c
drivers/block/xd.c
drivers/block/xen-blkfront.c
drivers/block/z2ram.c
drivers/bluetooth/btmrvl_debugfs.c
drivers/bluetooth/btmrvl_drv.h
drivers/bluetooth/btmrvl_sdio.c
drivers/char/agp/amd-k7-agp.c
drivers/char/agp/backend.c
drivers/char/agp/compat_ioctl.c
drivers/char/agp/generic.c
drivers/char/agp/hp-agp.c
drivers/char/agp/intel-agp.c
drivers/char/agp/nvidia-agp.c
drivers/char/agp/sgi-agp.c
drivers/char/agp/uninorth-agp.c
drivers/char/bfin_jtag_comm.c
drivers/char/briq_panel.c
drivers/char/bsr.c
drivers/char/cyclades.c
drivers/char/dsp56k.c
drivers/char/epca.c
drivers/char/generic_serial.c
drivers/char/hpet.c
drivers/char/hvc_console.c
drivers/char/hvc_iucv.c
drivers/char/hvcs.c
drivers/char/hw_random/intel-rng.c
drivers/char/hw_random/octeon-rng.c
drivers/char/hw_random/tx4939-rng.c
drivers/char/ipmi/ipmi_msghandler.c
drivers/char/isicom.c
drivers/char/mbcs.c
drivers/char/misc.c
drivers/char/mmtimer.c
drivers/char/moxa.c
drivers/char/mxser.c
drivers/char/nozomi.c
drivers/char/nvram.c
drivers/char/pcmcia/ipwireless/network.c
drivers/char/ppdev.c
drivers/char/ps3flash.c
drivers/char/pty.c
drivers/char/raw.c
drivers/char/rio/rioinit.c
drivers/char/rio/riointr.c
drivers/char/rio/rioparam.c
drivers/char/rio/rioroute.c
drivers/char/rio/riotty.c
drivers/char/serial167.c
drivers/char/snsc_event.c
drivers/char/sonypi.c
drivers/char/specialix.c
drivers/char/sysrq.c
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm_bios.c
drivers/char/tpm/tpm_nsc.c
drivers/char/tpm/tpm_tis.c
drivers/char/tty_audit.c
drivers/char/tty_buffer.c
drivers/char/tty_io.c
drivers/char/tty_port.c
drivers/char/viotape.c
drivers/char/virtio_console.c
drivers/char/vme_scc.c
drivers/char/vt_ioctl.c
drivers/char/xilinx_hwicap/xilinx_hwicap.c
drivers/clocksource/sh_cmt.c
drivers/clocksource/sh_mtu2.c
drivers/clocksource/sh_tmu.c
drivers/connector/cn_proc.c
drivers/connector/connector.c
drivers/cpufreq/cpufreq_stats.c
drivers/cpuidle/sysfs.c
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/ixp4xx_crypto.c
drivers/crypto/mv_cesa.c
drivers/crypto/padlock-aes.c
drivers/crypto/talitos.c
drivers/dca/dca-core.c
drivers/dca/dca-sysfs.c
drivers/dma/at_hdmac.c
drivers/dma/coh901318_lli.c
drivers/dma/dmaengine.c
drivers/dma/dmatest.c
drivers/dma/fsldma.c
drivers/dma/ioat/dma.c
drivers/dma/ioat/dma_v2.c
drivers/dma/ioat/dma_v3.c
drivers/dma/ioat/pci.c
drivers/dma/iop-adma.c
drivers/dma/iovlock.c
drivers/dma/mpc512x_dma.c
drivers/dma/mv_xor.c
drivers/dma/ppc4xx/adma.c
drivers/dma/shdma.c
drivers/edac/amd76x_edac.c
drivers/edac/cpc925_edac.c
drivers/edac/e752x_edac.c
drivers/edac/e7xxx_edac.c
drivers/edac/edac_device_sysfs.c
drivers/edac/edac_mc_sysfs.c
drivers/edac/edac_mce_amd.c
drivers/edac/edac_pci_sysfs.c
drivers/edac/i3000_edac.c
drivers/edac/i3200_edac.c
drivers/edac/i5100_edac.c
drivers/edac/i82443bxgx_edac.c
drivers/edac/i82860_edac.c
drivers/edac/i82875p_edac.c
drivers/edac/i82975x_edac.c
drivers/edac/mpc85xx_edac.c
drivers/edac/mv64x60_edac.c
drivers/edac/pasemi_edac.c
drivers/edac/r82600_edac.c
drivers/edac/x38_edac.c
drivers/firewire/core-cdev.c
drivers/firewire/core-device.c
drivers/firewire/core-iso.c
drivers/firewire/net.c
drivers/firewire/ohci.c
drivers/firmware/dcdbas.c
drivers/firmware/dell_rbu.c
drivers/firmware/dmi-id.c
drivers/firmware/dmi_scan.c
drivers/firmware/efivars.c
drivers/firmware/iscsi_ibft_find.c
drivers/firmware/memmap.c
drivers/gpio/adp5520-gpio.c
drivers/gpio/adp5588-gpio.c
drivers/gpio/bt8xxgpio.c
drivers/gpio/gpiolib.c
drivers/gpio/langwell_gpio.c
drivers/gpio/max7300.c
drivers/gpio/max7301.c
drivers/gpio/max730x.c
drivers/gpio/mc33880.c
drivers/gpio/mcp23s08.c
drivers/gpio/pca953x.c
drivers/gpio/pl061.c
drivers/gpio/timbgpio.c
drivers/gpio/twl4030-gpio.c
drivers/gpio/wm831x-gpio.c
drivers/gpio/wm8350-gpiolib.c
drivers/gpio/wm8994-gpio.c
drivers/gpio/xilinx_gpio.c
drivers/gpu/drm/drm_agpsupport.c
drivers/gpu/drm/drm_bufs.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_crtc_helper.c
drivers/gpu/drm/drm_debugfs.c
drivers/gpu/drm/drm_dp_i2c_helper.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/drm_fops.c
drivers/gpu/drm/drm_hashtab.c
drivers/gpu/drm/drm_irq.c
drivers/gpu/drm/drm_pci.c
drivers/gpu/drm/drm_proc.c
drivers/gpu/drm/drm_scatter.c
drivers/gpu/drm/drm_stub.c
drivers/gpu/drm/drm_sysfs.c
drivers/gpu/drm/drm_vm.c
drivers/gpu/drm/i810/i810_dma.c
drivers/gpu/drm/i830/i830_dma.c
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_tiling.c
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_bios.c
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_fb.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_i2c.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_modes.c
drivers/gpu/drm/i915/intel_overlay.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/nouveau/Makefile
drivers/gpu/drm/nouveau/nouveau_acpi.c
drivers/gpu/drm/nouveau/nouveau_bios.c
drivers/gpu/drm/nouveau/nouveau_bios.h
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_dma.c
drivers/gpu/drm/nouveau/nouveau_drv.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_grctx.c
drivers/gpu/drm/nouveau/nouveau_irq.c
drivers/gpu/drm/nouveau/nouveau_sgdma.c
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/gpu/drm/nouveau/nv04_crtc.c
drivers/gpu/drm/nouveau/nv04_fbcon.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/nouveau/nv50_fb.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nv50_fbcon.c
drivers/gpu/drm/nouveau/nv50_graph.c
drivers/gpu/drm/nouveau/nv50_grctx.c
drivers/gpu/drm/r128/r128_cce.c
drivers/gpu/drm/radeon/Makefile
drivers/gpu/drm/radeon/atom.c
drivers/gpu/drm/radeon/atom.h
drivers/gpu/drm/radeon/atombios_crtc.c
drivers/gpu/drm/radeon/atombios_dp.c
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r200.c
drivers/gpu/drm/radeon/r300.c
drivers/gpu/drm/radeon/r420.c
drivers/gpu/drm/radeon/r520.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/r600_audio.c
drivers/gpu/drm/radeon/r600_blit_shaders.c
drivers/gpu/drm/radeon/r600_cp.c
drivers/gpu/drm/radeon/r600_cs.c
drivers/gpu/drm/radeon/r600_hdmi.c
drivers/gpu/drm/radeon/r600_reg.h
drivers/gpu/drm/radeon/r600d.h
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.c [new file with mode: 0644]
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_atpx_handler.c
drivers/gpu/drm/radeon/radeon_bios.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_connectors.c
drivers/gpu/drm/radeon/radeon_cs.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_drv.h
drivers/gpu/drm/radeon/radeon_encoders.c
drivers/gpu/drm/radeon/radeon_fb.c
drivers/gpu/drm/radeon/radeon_fence.c
drivers/gpu/drm/radeon/radeon_i2c.c
drivers/gpu/drm/radeon/radeon_irq_kms.c
drivers/gpu/drm/radeon/radeon_kms.c
drivers/gpu/drm/radeon/radeon_legacy_crtc.c
drivers/gpu/drm/radeon/radeon_legacy_tv.c
drivers/gpu/drm/radeon/radeon_mode.h
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/radeon_reg.h
drivers/gpu/drm/radeon/radeon_ring.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/radeon/reg_srcs/r600
drivers/gpu/drm/radeon/rs400.c
drivers/gpu/drm/radeon/rs600.c
drivers/gpu/drm/radeon/rs600d.h
drivers/gpu/drm/radeon/rs690.c
drivers/gpu/drm/radeon/rs690d.h
drivers/gpu/drm/radeon/rv515.c
drivers/gpu/drm/radeon/rv770.c
drivers/gpu/drm/ttm/ttm_agp_backend.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_util.c
drivers/gpu/drm/ttm/ttm_memory.c
drivers/gpu/drm/ttm/ttm_tt.c
drivers/gpu/drm/via/via_dmablit.c
drivers/gpu/drm/vmwgfx/Kconfig
drivers/gpu/vga/vgaarb.c
drivers/hid/hid-3m-pct.c
drivers/hid/hid-a4tech.c
drivers/hid/hid-apple.c
drivers/hid/hid-debug.c
drivers/hid/hid-drff.c
drivers/hid/hid-gaff.c
drivers/hid/hid-gyration.c
drivers/hid/hid-lg2ff.c
drivers/hid/hid-magicmouse.c
drivers/hid/hid-mosart.c
drivers/hid/hid-ntrig.c
drivers/hid/hid-pl.c
drivers/hid/hid-quanta.c
drivers/hid/hid-sjoy.c
drivers/hid/hid-sony.c
drivers/hid/hid-stantum.c
drivers/hid/hid-tmff.c
drivers/hid/hid-wacom.c
drivers/hid/hid-zpff.c
drivers/hid/hidraw.c
drivers/hid/usbhid/hid-core.c
drivers/hid/usbhid/hid-pidff.c
drivers/hid/usbhid/hid-quirks.c
drivers/hwmon/Kconfig
drivers/hwmon/ad7414.c
drivers/hwmon/ad7418.c
drivers/hwmon/adcxx.c
drivers/hwmon/adt7411.c
drivers/hwmon/adt7462.c
drivers/hwmon/adt7470.c
drivers/hwmon/asus_atk0110.c
drivers/hwmon/atxp1.c
drivers/hwmon/coretemp.c
drivers/hwmon/f75375s.c
drivers/hwmon/i5k_amb.c
drivers/hwmon/ibmaem.c
drivers/hwmon/ibmpex.c
drivers/hwmon/lm70.c
drivers/hwmon/lm73.c
drivers/hwmon/max1111.c
drivers/hwmon/mc13783-adc.c
drivers/hwmon/sht15.c
drivers/hwmon/w83793.c
drivers/hwmon/wm831x-hwmon.c
drivers/i2c/algos/i2c-algo-bit.c
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/busses/i2c-amd8111.c
drivers/i2c/busses/i2c-bfin-twi.c
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-designware.c
drivers/i2c/busses/i2c-elektor.c
drivers/i2c/busses/i2c-gpio.c
drivers/i2c/busses/i2c-highlander.c
drivers/i2c/busses/i2c-imx.c
drivers/i2c/busses/i2c-ixp2000.c
drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/i2c-mv64xxx.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-nomadik.c
drivers/i2c/busses/i2c-ocores.c
drivers/i2c/busses/i2c-octeon.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-parport.c
drivers/i2c/busses/i2c-pasemi.c
drivers/i2c/busses/i2c-pnx.c
drivers/i2c/busses/i2c-pxa.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-scmi.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-simtec.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-tiny-usb.c
drivers/i2c/busses/i2c-versatile.c
drivers/i2c/busses/i2c-xiic.c
drivers/i2c/busses/scx200_acb.c
drivers/i2c/i2c-boardinfo.c
drivers/i2c/i2c-smbus.c
drivers/ide/hpt366.c
drivers/ide/ide-acpi.c
drivers/ide/ide-atapi.c
drivers/ide/ide-cd_ioctl.c
drivers/ide/ide-devsets.c
drivers/ide/ide-disk_proc.c
drivers/ide/ide-dma.c
drivers/ide/ide-floppy.c
drivers/ide/ide-gd.c
drivers/ide/ide-ioctls.c
drivers/ide/ide-park.c
drivers/ide/ide-pm.c
drivers/ide/ide-probe.c
drivers/ide/ide-proc.c
drivers/ide/ide.c
drivers/ide/it821x.c
drivers/ide/pmac.c
drivers/ide/rapide.c
drivers/ide/sc1200.c
drivers/ide/via82cxxx.c
drivers/idle/i7300_idle.c
drivers/ieee1394/dma.c
drivers/ieee1394/sbp2.c
drivers/infiniband/core/addr.c
drivers/infiniband/core/cm.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/iwcm.c
drivers/infiniband/core/mad.c
drivers/infiniband/core/mad_rmpp.c
drivers/infiniband/core/multicast.c
drivers/infiniband/core/sysfs.c
drivers/infiniband/core/ucm.c
drivers/infiniband/core/ucma.c
drivers/infiniband/core/umem.c
drivers/infiniband/core/user_mad.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/amso1100/c2.c
drivers/infiniband/hw/amso1100/c2_alloc.c
drivers/infiniband/hw/amso1100/c2_cm.c
drivers/infiniband/hw/amso1100/c2_cq.c
drivers/infiniband/hw/amso1100/c2_mm.c
drivers/infiniband/hw/amso1100/c2_pd.c
drivers/infiniband/hw/amso1100/c2_provider.c
drivers/infiniband/hw/amso1100/c2_qp.c
drivers/infiniband/hw/amso1100/c2_rnic.c
drivers/infiniband/hw/cxgb3/cxio_dbg.c
drivers/infiniband/hw/cxgb3/cxio_hal.c
drivers/infiniband/hw/cxgb3/iwch_cm.c
drivers/infiniband/hw/cxgb3/iwch_ev.c
drivers/infiniband/hw/cxgb3/iwch_mem.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb3/iwch_qp.c
drivers/infiniband/hw/ehca/ehca_av.c
drivers/infiniband/hw/ehca/ehca_cq.c
drivers/infiniband/hw/ehca/ehca_hca.c
drivers/infiniband/hw/ehca/ehca_irq.c
drivers/infiniband/hw/ehca/ehca_mrmw.c
drivers/infiniband/hw/ehca/ehca_pd.c
drivers/infiniband/hw/ehca/ehca_qp.c
drivers/infiniband/hw/ehca/ehca_uverbs.c
drivers/infiniband/hw/ehca/ipz_pt_fn.c
drivers/infiniband/hw/ipath/ipath_cq.c
drivers/infiniband/hw/ipath/ipath_dma.c
drivers/infiniband/hw/ipath/ipath_driver.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/infiniband/hw/ipath/ipath_fs.c
drivers/infiniband/hw/ipath/ipath_init_chip.c
drivers/infiniband/hw/ipath/ipath_mmap.c
drivers/infiniband/hw/ipath/ipath_mr.c
drivers/infiniband/hw/ipath/ipath_qp.c
drivers/infiniband/hw/ipath/ipath_sdma.c
drivers/infiniband/hw/ipath/ipath_srq.c
drivers/infiniband/hw/ipath/ipath_user_pages.c
drivers/infiniband/hw/ipath/ipath_verbs.c
drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
drivers/infiniband/hw/mlx4/ah.c
drivers/infiniband/hw/mlx4/cq.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/mr.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx4/srq.c
drivers/infiniband/hw/mthca/mthca_cmd.c
drivers/infiniband/hw/mthca/mthca_cq.c
drivers/infiniband/hw/mthca/mthca_eq.c
drivers/infiniband/hw/mthca/mthca_main.c
drivers/infiniband/hw/mthca/mthca_mcg.c
drivers/infiniband/hw/mthca/mthca_memfree.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/nes/nes.c
drivers/infiniband/hw/nes/nes_cm.c
drivers/infiniband/hw/nes/nes_hw.c
drivers/infiniband/hw/nes/nes_nic.c
drivers/infiniband/hw/nes/nes_utils.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/ulp/ipoib/ipoib_cm.c
drivers/infiniband/ulp/ipoib/ipoib_fs.c
drivers/infiniband/ulp/ipoib/ipoib_ib.c
drivers/infiniband/ulp/ipoib/ipoib_multicast.c
drivers/infiniband/ulp/ipoib/ipoib_verbs.c
drivers/infiniband/ulp/ipoib/ipoib_vlan.c
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/infiniband/ulp/iser/iser_verbs.c
drivers/input/ff-core.c
drivers/input/ff-memless.c
drivers/input/gameport/lightning.c
drivers/input/input-polldev.c
drivers/input/input.c
drivers/input/joystick/db9.c
drivers/input/joystick/gamecon.c
drivers/input/joystick/turbografx.c
drivers/input/keyboard/adp5520-keys.c
drivers/input/keyboard/adp5588-keys.c
drivers/input/keyboard/bf54x-keys.c
drivers/input/keyboard/davinci_keyscan.c
drivers/input/keyboard/ep93xx_keypad.c
drivers/input/keyboard/gpio_keys.c
drivers/input/keyboard/imx_keypad.c
drivers/input/keyboard/jornada680_kbd.c
drivers/input/keyboard/jornada720_kbd.c
drivers/input/keyboard/lm8323.c
drivers/input/keyboard/matrix_keypad.c
drivers/input/keyboard/max7359_keypad.c
drivers/input/keyboard/omap-keypad.c
drivers/input/keyboard/opencores-kbd.c
drivers/input/keyboard/pxa27x_keypad.c
drivers/input/keyboard/pxa930_rotary.c
drivers/input/keyboard/sh_keysc.c
drivers/input/keyboard/tosakbd.c
drivers/input/keyboard/twl4030_keypad.c
drivers/input/keyboard/w90p910_keypad.c
drivers/input/misc/88pm860x_onkey.c
drivers/input/misc/ati_remote2.c
drivers/input/misc/bfin_rotary.c
drivers/input/misc/cobalt_btns.c
drivers/input/misc/dm355evm_keys.c
drivers/input/misc/pcap_keys.c
drivers/input/misc/pcf50633-input.c
drivers/input/misc/rotary_encoder.c
drivers/input/misc/sgi_btns.c
drivers/input/misc/sparcspkr.c
drivers/input/misc/twl4030-vibra.c
drivers/input/misc/winbond-cir.c
drivers/input/misc/wistron_btns.c
drivers/input/misc/wm831x-on.c
drivers/input/mouse/alps.c
drivers/input/mouse/elantech.c
drivers/input/mouse/hgpk.c
drivers/input/mouse/lifebook.c
drivers/input/mouse/pxa930_trkball.c
drivers/input/mouse/sentelic.c
drivers/input/mouse/synaptics.c
drivers/input/mouse/synaptics_i2c.c
drivers/input/mouse/touchkit_ps2.c
drivers/input/mouse/trackpoint.c
drivers/input/serio/altera_ps2.c
drivers/input/serio/at32psif.c
drivers/input/serio/ct82c710.c
drivers/input/serio/gscps2.c
drivers/input/serio/hil_mlc.c
drivers/input/serio/i8042.c
drivers/input/serio/libps2.c
drivers/input/serio/parkbd.c
drivers/input/serio/pcips2.c
drivers/input/serio/q40kbd.c
drivers/input/serio/rpckbd.c
drivers/input/serio/xilinx_ps2.c
drivers/input/sparse-keymap.c
drivers/input/touchscreen/88pm860x-ts.c
drivers/input/touchscreen/atmel-wm97xx.c
drivers/input/touchscreen/da9034-ts.c
drivers/input/touchscreen/eeti_ts.c
drivers/input/touchscreen/jornada720_ts.c
drivers/input/touchscreen/mc13783_ts.c
drivers/input/touchscreen/mcs5000_ts.c
drivers/input/touchscreen/migor_ts.c
drivers/input/touchscreen/pcap_ts.c
drivers/input/touchscreen/s3c2410_ts.c
drivers/input/touchscreen/ucb1400_ts.c
drivers/input/touchscreen/w90p910_ts.c
drivers/input/touchscreen/wm97xx-core.c
drivers/input/xen-kbdfront.c
drivers/isdn/act2000/module.c
drivers/isdn/capi/capifs.c
drivers/isdn/capi/capilib.c
drivers/isdn/capi/capiutil.c
drivers/isdn/capi/kcapi.c
drivers/isdn/divert/divert_procfs.c
drivers/isdn/divert/isdn_divert.c
drivers/isdn/gigaset/capi.c
drivers/isdn/gigaset/common.c
drivers/isdn/gigaset/gigaset.h
drivers/isdn/gigaset/i4l.c
drivers/isdn/gigaset/ser-gigaset.c
drivers/isdn/hardware/avm/b1.c
drivers/isdn/hardware/avm/b1dma.c
drivers/isdn/hardware/avm/c4.c
drivers/isdn/hardware/avm/t1isa.c
drivers/isdn/hardware/eicon/capimain.c
drivers/isdn/hardware/mISDN/avmfritz.c
drivers/isdn/hardware/mISDN/hfcmulti.c
drivers/isdn/hardware/mISDN/hfcpci.c
drivers/isdn/hardware/mISDN/hfcsusb.c
drivers/isdn/hardware/mISDN/mISDNinfineon.c
drivers/isdn/hardware/mISDN/mISDNipac.c
drivers/isdn/hardware/mISDN/mISDNisar.c
drivers/isdn/hardware/mISDN/netjet.c
drivers/isdn/hardware/mISDN/speedfax.c
drivers/isdn/hardware/mISDN/w6692.c
drivers/isdn/hisax/amd7930_fn.c
drivers/isdn/hisax/avm_pci.c
drivers/isdn/hisax/avma1_cs.c
drivers/isdn/hisax/callc.c
drivers/isdn/hisax/config.c
drivers/isdn/hisax/elsa.c
drivers/isdn/hisax/elsa_cs.c
drivers/isdn/hisax/elsa_ser.c
drivers/isdn/hisax/fsm.c
drivers/isdn/hisax/hfc4s8s_l1.c
drivers/isdn/hisax/hfc_2bds0.c
drivers/isdn/hisax/hfc_2bs0.c
drivers/isdn/hisax/hfc_sx.c
drivers/isdn/hisax/hfc_usb.c
drivers/isdn/hisax/hisax_isac.c
drivers/isdn/hisax/hscx.c
drivers/isdn/hisax/icc.c
drivers/isdn/hisax/ipacx.c
drivers/isdn/hisax/isac.c
drivers/isdn/hisax/isar.c
drivers/isdn/hisax/isdnl1.c
drivers/isdn/hisax/isdnl2.c
drivers/isdn/hisax/isdnl3.c
drivers/isdn/hisax/jade.c
drivers/isdn/hisax/l3dss1.c
drivers/isdn/hisax/l3ni1.c
drivers/isdn/hisax/netjet.c
drivers/isdn/hisax/sedlbauer_cs.c
drivers/isdn/hisax/st5481_b.c
drivers/isdn/hisax/st5481_d.c
drivers/isdn/hisax/tei.c
drivers/isdn/hisax/teles_cs.c
drivers/isdn/hisax/w6692.c
drivers/isdn/hysdn/hycapi.c
drivers/isdn/hysdn/hysdn_procconf.c
drivers/isdn/hysdn/hysdn_proclog.c
drivers/isdn/i4l/isdn_audio.c
drivers/isdn/i4l/isdn_common.c
drivers/isdn/i4l/isdn_net.c
drivers/isdn/i4l/isdn_ppp.c
drivers/isdn/i4l/isdn_tty.c
drivers/isdn/i4l/isdn_x25iface.c
drivers/isdn/icn/icn.c
drivers/isdn/isdnloop/isdnloop.c
drivers/isdn/mISDN/clock.c
drivers/isdn/mISDN/core.c
drivers/isdn/mISDN/dsp_cmx.c
drivers/isdn/mISDN/dsp_core.c
drivers/isdn/mISDN/dsp_pipeline.c
drivers/isdn/mISDN/dsp_tones.c
drivers/isdn/mISDN/hwchannel.c
drivers/isdn/mISDN/l1oip_core.c
drivers/isdn/mISDN/layer1.c
drivers/isdn/mISDN/layer2.c
drivers/isdn/mISDN/socket.c
drivers/isdn/mISDN/stack.c
drivers/isdn/mISDN/tei.c
drivers/isdn/mISDN/timerdev.c
drivers/isdn/pcbit/callbacks.c
drivers/isdn/pcbit/edss1.c
drivers/isdn/sc/init.c
drivers/leds/dell-led.c
drivers/leds/led-triggers.c
drivers/leds/leds-88pm860x.c
drivers/leds/leds-adp5520.c
drivers/leds/leds-atmel-pwm.c
drivers/leds/leds-bd2802.c
drivers/leds/leds-da903x.c
drivers/leds/leds-dac124s085.c
drivers/leds/leds-gpio.c
drivers/leds/leds-lp3944.c
drivers/leds/leds-lt3593.c
drivers/leds/leds-pca9532.c
drivers/leds/leds-pca955x.c
drivers/leds/leds-pwm.c
drivers/leds/leds-regulator.c
drivers/leds/leds-s3c24xx.c
drivers/leds/leds-sunfire.c
drivers/leds/leds-wm831x-status.c
drivers/leds/leds-wm8350.c
drivers/leds/ledtrig-backlight.c
drivers/leds/ledtrig-gpio.c
drivers/leds/ledtrig-heartbeat.c
drivers/leds/ledtrig-timer.c
drivers/lguest/core.c
drivers/lguest/lg.h
drivers/lguest/lguest_device.c
drivers/lguest/lguest_user.c
drivers/lguest/page_tables.c
drivers/macintosh/mac_hid.c
drivers/macintosh/rack-meter.c
drivers/macintosh/smu.c
drivers/macintosh/therm_pm72.c
drivers/macintosh/therm_windtunnel.c
drivers/macintosh/via-pmu68k.c
drivers/macintosh/windfarm_core.c
drivers/md/dm-log-userspace-base.c
drivers/md/dm-log-userspace-transfer.c
drivers/md/dm-region-hash.c
drivers/md/dm-service-time.c
drivers/md/dm-target.c
drivers/md/faulty.c
drivers/md/linear.c
drivers/md/md.c
drivers/md/multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c
drivers/md/raid6algos.c
drivers/media/IR/ir-keytable.c
drivers/media/IR/ir-sysfs.c
drivers/media/common/tuners/max2165.c
drivers/media/common/tuners/mc44s803.c
drivers/media/common/tuners/mt2060.c
drivers/media/common/tuners/mt20xx.c
drivers/media/common/tuners/mt2131.c
drivers/media/common/tuners/mt2266.c
drivers/media/common/tuners/tda827x.c
drivers/media/common/tuners/tda8290.c
drivers/media/common/tuners/tda9887.c
drivers/media/common/tuners/tea5761.c
drivers/media/common/tuners/tea5767.c
drivers/media/common/tuners/tuner-i2c.h
drivers/media/common/tuners/tuner-xc2028.c
drivers/media/dvb/bt8xx/dst_ca.c
drivers/media/dvb/dm1105/dm1105.c
drivers/media/dvb/dvb-core/dmxdev.h
drivers/media/dvb/dvb-core/dvb_frontend.h
drivers/media/dvb/dvb-usb/af9015.c
drivers/media/dvb/dvb-usb/cxusb.c
drivers/media/dvb/firewire/firedtv-1394.c
drivers/media/dvb/firewire/firedtv-rc.c
drivers/media/dvb/frontends/au8522_dig.c
drivers/media/dvb/frontends/dib0070.c
drivers/media/dvb/frontends/dib0090.c
drivers/media/dvb/frontends/dib3000mc.c
drivers/media/dvb/frontends/dib7000m.c
drivers/media/dvb/frontends/dib7000p.c
drivers/media/dvb/frontends/dib8000.c
drivers/media/dvb/frontends/drx397xD.c
drivers/media/dvb/frontends/dvb-pll.c
drivers/media/dvb/frontends/itd1000.c
drivers/media/dvb/frontends/lgdt3304.c
drivers/media/dvb/frontends/lgdt3305.c
drivers/media/dvb/frontends/mb86a16.c
drivers/media/dvb/frontends/s921_module.c
drivers/media/dvb/frontends/stb0899_drv.c
drivers/media/dvb/frontends/stb6000.c
drivers/media/dvb/frontends/stb6100.c
drivers/media/dvb/frontends/stv090x.c
drivers/media/dvb/frontends/stv6110.c
drivers/media/dvb/frontends/stv6110x.c
drivers/media/dvb/frontends/tda665x.c
drivers/media/dvb/frontends/tda8261.c
drivers/media/dvb/frontends/tda826x.c
drivers/media/dvb/frontends/tua6100.c
drivers/media/dvb/frontends/zl10036.c
drivers/media/dvb/mantis/hopper_cards.c
drivers/media/dvb/mantis/mantis_ca.c
drivers/media/dvb/mantis/mantis_cards.c
drivers/media/dvb/ngene/ngene-core.c
drivers/media/dvb/pluto2/pluto2.c
drivers/media/dvb/pt1/pt1.c
drivers/media/dvb/siano/smscoreapi.c
drivers/media/dvb/siano/smsdvb.c
drivers/media/dvb/siano/smssdio.c
drivers/media/dvb/siano/smsusb.c
drivers/media/dvb/ttpci/av7110.c
drivers/media/dvb/ttpci/av7110_ca.c
drivers/media/radio/radio-gemtek-pci.c
drivers/media/radio/radio-maestro.c
drivers/media/radio/radio-maxiradio.c
drivers/media/radio/radio-si4713.c
drivers/media/radio/radio-tea5764.c
drivers/media/radio/radio-timb.c
drivers/media/radio/saa7706h.c
drivers/media/radio/si470x/radio-si470x-i2c.c
drivers/media/radio/si470x/radio-si470x-usb.c
drivers/media/radio/si4713-i2c.c
drivers/media/radio/tef6862.c
drivers/media/video/adv7170.c
drivers/media/video/adv7175.c
drivers/media/video/adv7180.c
drivers/media/video/adv7343.c
drivers/media/video/au0828/au0828-core.c
drivers/media/video/au0828/au0828-dvb.c
drivers/media/video/au0828/au0828-video.c
drivers/media/video/bt819.c
drivers/media/video/bt856.c
drivers/media/video/bt866.c
drivers/media/video/bt8xx/bttv-driver.c
drivers/media/video/bt8xx/bttv-gpio.c
drivers/media/video/bt8xx/bttv-input.c
drivers/media/video/bt8xx/bttv-risc.c
drivers/media/video/cafe_ccic.c
drivers/media/video/cpia_pp.c
drivers/media/video/cs5345.c
drivers/media/video/cs53l32a.c
drivers/media/video/cx18/cx18-alsa-main.c
drivers/media/video/cx18/cx18-controls.c
drivers/media/video/cx18/cx18-driver.h
drivers/media/video/cx231xx/cx231xx-cards.c
drivers/media/video/cx231xx/cx231xx-core.c
drivers/media/video/cx231xx/cx231xx-dvb.c
drivers/media/video/cx231xx/cx231xx-input.c
drivers/media/video/cx231xx/cx231xx-vbi.c
drivers/media/video/cx231xx/cx231xx-video.c
drivers/media/video/cx23885/cx23885-417.c
drivers/media/video/cx23885/cx23885-input.c
drivers/media/video/cx23885/cx23885-vbi.c
drivers/media/video/cx23885/cx23885.h
drivers/media/video/cx23885/cx23888-ir.c
drivers/media/video/cx88/cx88-alsa.c
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-cards.c
drivers/media/video/cx88/cx88-dsp.c
drivers/media/video/cx88/cx88-input.c
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88-tvaudio.c
drivers/media/video/cx88/cx88-vbi.c
drivers/media/video/cx88/cx88-vp3054-i2c.c
drivers/media/video/davinci/dm644x_ccdc.c
drivers/media/video/davinci/vpfe_capture.c
drivers/media/video/davinci/vpif_capture.c
drivers/media/video/davinci/vpif_display.c
drivers/media/video/em28xx/em28xx-cards.c
drivers/media/video/em28xx/em28xx-core.c
drivers/media/video/em28xx/em28xx-dvb.c
drivers/media/video/em28xx/em28xx-input.c
drivers/media/video/em28xx/em28xx-vbi.c
drivers/media/video/em28xx/em28xx-video.c
drivers/media/video/gspca/gspca.h
drivers/media/video/gspca/jeilinj.c
drivers/media/video/gspca/m5602/m5602_s5k83a.c
drivers/media/video/gspca/sn9c20x.c
drivers/media/video/gspca/sonixj.c
drivers/media/video/gspca/sq905.c
drivers/media/video/gspca/sq905c.c
drivers/media/video/gspca/zc3xx.c
drivers/media/video/hdpvr/hdpvr-i2c.c
drivers/media/video/ivtv/ivtv-controls.c
drivers/media/video/ivtv/ivtv-driver.h
drivers/media/video/ivtv/ivtvfb.c
drivers/media/video/ks0127.c
drivers/media/video/m52790.c
drivers/media/video/meye.c
drivers/media/video/msp3400-kthreads.c
drivers/media/video/mt9v011.c
drivers/media/video/mx1_camera.c
drivers/media/video/omap24xxcam.c
drivers/media/video/ov7670.c
drivers/media/video/pms.c
drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
drivers/media/video/pvrusb2/pvrusb2-debugifc.c
drivers/media/video/pvrusb2/pvrusb2-dvb.c
drivers/media/video/pvrusb2/pvrusb2-eeprom.c
drivers/media/video/pvrusb2/pvrusb2-main.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c
drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
drivers/media/video/pvrusb2/pvrusb2-wm8775.c
drivers/media/video/pwc/pwc-dec23.c
drivers/media/video/pwc/pwc-v4l.c
drivers/media/video/pwc/pwc.h
drivers/media/video/pxa_camera.c
drivers/media/video/s2255drv.c
drivers/media/video/saa5246a.c
drivers/media/video/saa5249.c
drivers/media/video/saa7134/saa7134-dvb.c
drivers/media/video/saa7134/saa7134-empress.c
drivers/media/video/saa7134/saa7134-i2c.c
drivers/media/video/saa7134/saa7134-input.c
drivers/media/video/saa7134/saa7134-ts.c
drivers/media/video/saa7134/saa7134-tvaudio.c
drivers/media/video/saa7134/saa7134-vbi.c
drivers/media/video/saa7164/saa7164-api.c
drivers/media/video/saa7164/saa7164-buffer.c
drivers/media/video/saa7164/saa7164-fw.c
drivers/media/video/saa717x.c
drivers/media/video/saa7185.c
drivers/media/video/sh_mobile_ceu_camera.c
drivers/media/video/soc_camera.c
drivers/media/video/tda9840.c
drivers/media/video/tea6415c.c
drivers/media/video/tea6420.c
drivers/media/video/ths7303.c
drivers/media/video/tlg2300/pd-alsa.c
drivers/media/video/tlg2300/pd-dvb.c
drivers/media/video/tlg2300/pd-video.c
drivers/media/video/tlv320aic23b.c
drivers/media/video/tvp514x.c
drivers/media/video/tvp5150.c
drivers/media/video/tvp7002.c
drivers/media/video/upd64031a.c
drivers/media/video/upd64083.c
drivers/media/video/usbvideo/konicawc.c
drivers/media/video/usbvideo/quickcam_messenger.c
drivers/media/video/usbvision/usbvision-core.c
drivers/media/video/usbvision/usbvision-i2c.c
drivers/media/video/uvc/uvc_ctrl.c
drivers/media/video/uvc/uvc_driver.c
drivers/media/video/uvc/uvc_status.c
drivers/media/video/uvc/uvc_v4l2.c
drivers/media/video/uvc/uvc_video.c
drivers/media/video/v4l2-ioctl.c
drivers/media/video/videobuf-dma-contig.c
drivers/media/video/videobuf-dvb.c
drivers/media/video/vino.c
drivers/media/video/vp27smpx.c
drivers/media/video/vpx3220.c
drivers/media/video/w9966.c
drivers/media/video/wm8739.c
drivers/media/video/wm8775.c
drivers/media/video/zoran/zoran_card.c
drivers/memstick/core/memstick.c
drivers/memstick/core/mspro_block.c
drivers/memstick/host/jmb38x_ms.c
drivers/message/fusion/mptfc.c
drivers/message/fusion/mptlan.c
drivers/message/fusion/mptsas.c
drivers/message/fusion/mptscsih.c
drivers/message/fusion/mptspi.c
drivers/message/i2o/i2o_block.c
drivers/message/i2o/i2o_config.c
drivers/message/i2o/i2o_proc.c
drivers/message/i2o/iop.c
drivers/message/i2o/pci.c
drivers/mfd/88pm860x-i2c.c
drivers/mfd/ab3100-core.c
drivers/mfd/ab3100-otp.c
drivers/mfd/ab4500-core.c
drivers/mfd/adp5520.c
drivers/mfd/asic3.c
drivers/mfd/da903x.c
drivers/mfd/ezx-pcap.c
drivers/mfd/htc-egpio.c
drivers/mfd/htc-i2cpld.c
drivers/mfd/htc-pasic3.c
drivers/mfd/max8925-i2c.c
drivers/mfd/mc13783-core.c
drivers/mfd/mcp-sa11x0.c
drivers/mfd/menelaus.c
drivers/mfd/mfd-core.c
drivers/mfd/pcf50633-adc.c
drivers/mfd/pcf50633-core.c
drivers/mfd/sh_mobile_sdhi.c
drivers/mfd/sm501.c
drivers/mfd/t7l66xb.c
drivers/mfd/tc6387xb.c
drivers/mfd/tc6393xb.c
drivers/mfd/timberdale.c
drivers/mfd/twl4030-codec.c
drivers/mfd/twl4030-irq.c
drivers/mfd/ucb1400_core.c
drivers/mfd/wm831x-core.c
drivers/mfd/wm8350-core.c
drivers/mfd/wm8350-i2c.c
drivers/mfd/wm8400-core.c
drivers/mfd/wm8994-core.c
drivers/misc/atmel-ssc.c
drivers/misc/atmel_pwm.c
drivers/misc/atmel_tclib.c
drivers/misc/c2port/core.c
drivers/misc/cb710/core.c
drivers/misc/cb710/debug.c
drivers/misc/cs5535-mfgpt.c
drivers/misc/ds1682.c
drivers/misc/enclosure.c
drivers/misc/ep93xx_pwm.c
drivers/misc/hpilo.c
drivers/misc/ibmasm/command.c
drivers/misc/ibmasm/event.c
drivers/misc/ibmasm/ibmasmfs.c
drivers/misc/ibmasm/module.c
drivers/misc/ics932s401.c
drivers/misc/ioc4.c
drivers/misc/iwmc3200top/debugfs.c
drivers/misc/iwmc3200top/fw-download.c
drivers/misc/iwmc3200top/log.c
drivers/misc/iwmc3200top/main.c
drivers/misc/kgdbts.c
drivers/misc/lkdtm.c
drivers/misc/phantom.c
drivers/misc/sgi-xp/xpc_main.c
drivers/misc/sgi-xp/xpc_partition.c
drivers/misc/sgi-xp/xpc_sn2.c
drivers/misc/sgi-xp/xpc_uv.c
drivers/misc/sgi-xp/xpnet.c
drivers/misc/tifm_core.c
drivers/mmc/card/block.c
drivers/mmc/card/mmc_test.c
drivers/mmc/card/queue.c
drivers/mmc/card/sdio_uart.c
drivers/mmc/core/bus.c
drivers/mmc/core/debugfs.c
drivers/mmc/core/host.c
drivers/mmc/core/mmc.c
drivers/mmc/core/mmc_ops.c
drivers/mmc/core/sd.c
drivers/mmc/core/sdio_bus.c
drivers/mmc/core/sdio_cis.c
drivers/mmc/host/at91_mci.c
drivers/mmc/host/atmel-mci.c
drivers/mmc/host/au1xmmc.c
drivers/mmc/host/bfin_sdh.c
drivers/mmc/host/cb710-mmc.c
drivers/mmc/host/mmc_spi.c
drivers/mmc/host/msm_sdcc.c
drivers/mmc/host/of_mmc_spi.c
drivers/mmc/host/omap.c
drivers/mmc/host/pxamci.c
drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci-s3c.c
drivers/mmc/host/sdhci.c
drivers/mmc/host/wbsd.c
drivers/mtd/devices/block2mtd.c
drivers/mtd/devices/m25p80.c
drivers/mtd/devices/sst25l.c
drivers/mtd/lpddr/lpddr_cmds.c
drivers/mtd/maps/amd76xrom.c
drivers/mtd/maps/bfin-async-flash.c
drivers/mtd/maps/ck804xrom.c
drivers/mtd/maps/esb2rom.c
drivers/mtd/maps/gpio-addr-flash.c
drivers/mtd/maps/ichxrom.c
drivers/mtd/maps/intel_vr_nor.c
drivers/mtd/maps/octagon-5066.c
drivers/mtd/maps/omap_nor.c [deleted file]
drivers/mtd/maps/physmap_of.c
drivers/mtd/maps/pismo.c
drivers/mtd/maps/pmcmsp-flash.c
drivers/mtd/maps/pxa2xx-flash.c
drivers/mtd/maps/sbc_gxx.c
drivers/mtd/maps/sun_uflash.c
drivers/mtd/maps/vmax301.c
drivers/mtd/maps/vmu-flash.c
drivers/mtd/mtdcore.c
drivers/mtd/nand/bcm_umi_nand.c
drivers/mtd/nand/cafe_nand.c
drivers/mtd/nand/cmx270_nand.c
drivers/mtd/nand/davinci_nand.c
drivers/mtd/nand/diskonchip.c
drivers/mtd/nand/fsl_upm.c
drivers/mtd/nand/ndfc.c
drivers/mtd/nand/nomadik_nand.c
drivers/mtd/nand/omap2.c
drivers/mtd/nand/pxa3xx_nand.c
drivers/mtd/nand/sh_flctl.c
drivers/mtd/nand/tmio_nand.c
drivers/mtd/ofpart.c
drivers/mtd/onenand/omap2.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/onenand/onenand_sim.c
drivers/mtd/tests/mtd_nandecctest.c
drivers/mtd/tests/mtd_oobtest.c
drivers/mtd/tests/mtd_pagetest.c
drivers/mtd/tests/mtd_readtest.c
drivers/mtd/tests/mtd_speedtest.c
drivers/mtd/tests/mtd_stresstest.c
drivers/mtd/tests/mtd_subpagetest.c
drivers/mtd/tests/mtd_torturetest.c
drivers/mtd/ubi/build.c
drivers/mtd/ubi/cdev.c
drivers/mtd/ubi/gluebi.c
drivers/mtd/ubi/io.c
drivers/mtd/ubi/kapi.c
drivers/mtd/ubi/scan.c
drivers/mtd/ubi/ubi.h
drivers/mtd/ubi/vmt.c
drivers/mtd/ubi/vtbl.c
drivers/net/3c501.c
drivers/net/3c505.c
drivers/net/3c507.c
drivers/net/3c509.c
drivers/net/3c515.c
drivers/net/3c523.c
drivers/net/3c59x.c
drivers/net/7990.c
drivers/net/8139cp.c
drivers/net/8139too.c
drivers/net/82596.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/a2065.c
drivers/net/acenic.c
drivers/net/amd8111e.c
drivers/net/appletalk/cops.c
drivers/net/appletalk/ipddp.c
drivers/net/appletalk/ltpc.c
drivers/net/arcnet/arc-rawmode.c
drivers/net/arcnet/arc-rimi.c
drivers/net/arcnet/capmode.c
drivers/net/arcnet/com20020-isa.c
drivers/net/arcnet/com20020-pci.c
drivers/net/arcnet/com20020.c
drivers/net/arcnet/com90io.c
drivers/net/arcnet/com90xx.c
drivers/net/arcnet/rfc1051.c
drivers/net/arcnet/rfc1201.c
drivers/net/ariadne.c
drivers/net/arm/at91_ether.c
drivers/net/arm/ep93xx_eth.c
drivers/net/arm/etherh.c
drivers/net/arm/ixp4xx_eth.c
drivers/net/arm/ks8695net.c
drivers/net/arm/w90p910_ether.c
drivers/net/at1700.c
drivers/net/atarilance.c
drivers/net/atl1c/atl1c_ethtool.c
drivers/net/atl1e/atl1e_ethtool.c
drivers/net/atlx/atl1.c
drivers/net/atlx/atl2.c
drivers/net/atp.c
drivers/net/ax88796.c
drivers/net/b44.c
drivers/net/bcm63xx_enet.c
drivers/net/benet/be.h
drivers/net/benet/be_cmds.c
drivers/net/benet/be_ethtool.c
drivers/net/benet/be_main.c
drivers/net/bmac.c
drivers/net/bnx2.c
drivers/net/bonding/bond_main.c
drivers/net/can/bfin_can.c
drivers/net/can/dev.c
drivers/net/can/mcp251x.c
drivers/net/can/sja1000/ems_pci.c
drivers/net/can/sja1000/plx_pci.c
drivers/net/can/vcan.c
drivers/net/chelsio/common.h
drivers/net/chelsio/pm3393.c
drivers/net/chelsio/sge.c
drivers/net/cris/eth_v10.c
drivers/net/cs89x0.c
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb3/cxgb3_offload.c
drivers/net/cxgb3/l2t.c
drivers/net/cxgb3/sge.c
drivers/net/cxgb4/Makefile [new file with mode: 0644]
drivers/net/cxgb4/cxgb4.h [new file with mode: 0644]
drivers/net/cxgb4/cxgb4_main.c [new file with mode: 0644]
drivers/net/cxgb4/cxgb4_uld.h [new file with mode: 0644]
drivers/net/cxgb4/l2t.c [new file with mode: 0644]
drivers/net/cxgb4/l2t.h [new file with mode: 0644]
drivers/net/cxgb4/sge.c [new file with mode: 0644]
drivers/net/cxgb4/t4_hw.c [new file with mode: 0644]
drivers/net/cxgb4/t4_hw.h [new file with mode: 0644]
drivers/net/cxgb4/t4_msg.h [new file with mode: 0644]
drivers/net/cxgb4/t4_regs.h [new file with mode: 0644]
drivers/net/cxgb4/t4fw_api.h [new file with mode: 0644]
drivers/net/dm9000.c
drivers/net/e1000/e1000.h
drivers/net/e1000/e1000_main.c
drivers/net/e1000e/e1000.h
drivers/net/e1000e/ethtool.c
drivers/net/e1000e/netdev.c
drivers/net/eepro.c
drivers/net/eexpress.c
drivers/net/ehea/ehea_main.c
drivers/net/ehea/ehea_qmr.c
drivers/net/enc28j60.c
drivers/net/enic/vnic_dev.c
drivers/net/enic/vnic_rq.c
drivers/net/enic/vnic_wq.c
drivers/net/epic100.c
drivers/net/eql.c
drivers/net/eth16i.c
drivers/net/ethoc.c
drivers/net/fealnx.c
drivers/net/fec_mpc52xx.c
drivers/net/fec_mpc52xx_phy.c
drivers/net/forcedeth.c
drivers/net/fs_enet/mac-fcc.c
drivers/net/fs_enet/mac-fec.c
drivers/net/fs_enet/mac-scc.c
drivers/net/gianfar.c
drivers/net/gianfar.h
drivers/net/gianfar_ethtool.c
drivers/net/gianfar_sysfs.c
drivers/net/greth.c
drivers/net/hamachi.c
drivers/net/hamradio/6pack.c
drivers/net/hamradio/bpqether.c
drivers/net/hamradio/dmascc.c
drivers/net/hamradio/hdlcdrv.c
drivers/net/hamradio/mkiss.c
drivers/net/hamradio/scc.c
drivers/net/hp100.c
drivers/net/hplance.c
drivers/net/hydra.c
drivers/net/ibm_newemac/core.c
drivers/net/ibm_newemac/core.h
drivers/net/ibm_newemac/mal.c
drivers/net/ibm_newemac/rgmii.c
drivers/net/ibm_newemac/zmii.c
drivers/net/ibmlana.c
drivers/net/ibmveth.c
drivers/net/igb/e1000_82575.c
drivers/net/igb/e1000_hw.h
drivers/net/igb/e1000_mac.c
drivers/net/igb/igb.h
drivers/net/igb/igb_ethtool.c
drivers/net/igb/igb_main.c
drivers/net/igbvf/igbvf.h
drivers/net/igbvf/netdev.c
drivers/net/ioc3-eth.c
drivers/net/ipg.c
drivers/net/irda/ali-ircc.c
drivers/net/irda/bfin_sir.h
drivers/net/irda/irtty-sir.c
drivers/net/irda/nsc-ircc.c
drivers/net/irda/pxaficp_ir.c
drivers/net/irda/sh_sir.c
drivers/net/irda/sir_dev.c
drivers/net/irda/smsc-ircc2.c
drivers/net/irda/via-ircc.c
drivers/net/irda/w83977af_ir.c
drivers/net/iseries_veth.c
drivers/net/ixgbe/ixgbe.h
drivers/net/ixgbe/ixgbe_82599.c
drivers/net/ixgbe/ixgbe_ethtool.c
drivers/net/ixgbe/ixgbe_fcoe.c
drivers/net/ixgbe/ixgbe_main.c
drivers/net/ixgbe/ixgbe_type.h
drivers/net/ixgbevf/ethtool.c
drivers/net/ixgbevf/ixgbevf_main.c
drivers/net/ixgbevf/vf.h
drivers/net/ixp2000/ixpdev.c
drivers/net/jazzsonic.c
drivers/net/jme.c
drivers/net/jme.h
drivers/net/ks8851.c
drivers/net/ks8851_mll.c
drivers/net/ksz884x.c
drivers/net/lasi_82596.c
drivers/net/lib82596.c
drivers/net/ll_temac_main.c
drivers/net/ll_temac_mdio.c
drivers/net/mac8390.c
drivers/net/mac89x0.c
drivers/net/mace.c
drivers/net/macmace.c
drivers/net/macsonic.c
drivers/net/macvtap.c
drivers/net/mlx4/cmd.c
drivers/net/mlx4/cq.c
drivers/net/mlx4/en_main.c
drivers/net/mlx4/en_netdev.c
drivers/net/mlx4/en_resources.c
drivers/net/mlx4/en_rx.c
drivers/net/mlx4/en_tx.c
drivers/net/mlx4/eq.c
drivers/net/mlx4/icm.c
drivers/net/mlx4/intf.c
drivers/net/mlx4/main.c
drivers/net/mlx4/mcg.c
drivers/net/mlx4/mr.c
drivers/net/mlx4/profile.c
drivers/net/mlx4/qp.c
drivers/net/mlx4/srq.c
drivers/net/mv643xx_eth.c
drivers/net/mvme147.c
drivers/net/myri10ge/myri10ge.c
drivers/net/myri_sbus.c
drivers/net/ne2.c
drivers/net/netconsole.c
drivers/net/netxen/netxen_nic.h
drivers/net/netxen/netxen_nic_ctx.c
drivers/net/netxen/netxen_nic_hw.c
drivers/net/netxen/netxen_nic_init.c
drivers/net/netxen/netxen_nic_main.c
drivers/net/ni5010.c
drivers/net/ni52.c
drivers/net/niu.c
drivers/net/ns83820.c
drivers/net/octeon/octeon_mgmt.c
drivers/net/pasemi_mac.c
drivers/net/pcmcia/axnet_cs.c
drivers/net/pcmcia/pcnet_cs.c
drivers/net/pcmcia/smc91c92_cs.c
drivers/net/phy/cicada.c
drivers/net/phy/davicom.c
drivers/net/phy/et1011c.c
drivers/net/phy/fixed.c
drivers/net/phy/icplus.c
drivers/net/phy/lxt.c
drivers/net/phy/marvell.c
drivers/net/phy/mdio-bitbang.c
drivers/net/phy/mdio-octeon.c
drivers/net/phy/phy.c
drivers/net/phy/qsemi.c
drivers/net/plip.c
drivers/net/ppp_async.c
drivers/net/ppp_generic.c
drivers/net/ppp_synctty.c
drivers/net/pppox.c
drivers/net/ps3_gelic_net.c
drivers/net/ps3_gelic_wireless.c
drivers/net/qlcnic/qlcnic_hw.c
drivers/net/qlcnic/qlcnic_init.c
drivers/net/qlcnic/qlcnic_main.c
drivers/net/qlge/qlge_dbg.c
drivers/net/qlge/qlge_ethtool.c
drivers/net/r6040.c
drivers/net/r8169.c
drivers/net/rionet.c
drivers/net/rrunner.c
drivers/net/s2io.c
drivers/net/sb1000.c
drivers/net/seeq8005.c
drivers/net/sfc/efx.c
drivers/net/sfc/falcon.c
drivers/net/sfc/mcdi_phy.c
drivers/net/sfc/mtd.c
drivers/net/sfc/qt202x_phy.c
drivers/net/sfc/rx.c
drivers/net/sfc/selftest.c
drivers/net/sfc/siena.c
drivers/net/sfc/tenxpress.c
drivers/net/sfc/tx.c
drivers/net/sgiseeq.c
drivers/net/sh_eth.c
drivers/net/sis190.c
drivers/net/skfp/skfddi.c
drivers/net/skge.c
drivers/net/sky2.c
drivers/net/slhc.c
drivers/net/slip.c
drivers/net/smc911x.c
drivers/net/smc9194.c
drivers/net/smc91x.c
drivers/net/smsc911x.c
drivers/net/smsc9420.c
drivers/net/sni_82596.c
drivers/net/spider_net.c
drivers/net/stmmac/Kconfig
drivers/net/stmmac/dwmac100.c
drivers/net/stmmac/dwmac1000_core.c
drivers/net/stmmac/stmmac_main.c
drivers/net/stmmac/stmmac_mdio.c
drivers/net/sun3_82586.c
drivers/net/sun3lance.c
drivers/net/sunbmac.c
drivers/net/sundance.c
drivers/net/sungem.c
drivers/net/sunlance.c
drivers/net/tehuti.h
drivers/net/tokenring/3c359.c
drivers/net/tokenring/lanstreamer.c
drivers/net/tokenring/madgemc.c
drivers/net/tokenring/smctr.c
drivers/net/tokenring/tms380tr.c
drivers/net/tsi108_eth.c
drivers/net/tulip/de2104x.c
drivers/net/tulip/de4x5.c
drivers/net/tulip/dmfe.c
drivers/net/tulip/eeprom.c
drivers/net/tulip/tulip_core.c
drivers/net/tulip/uli526x.c
drivers/net/tulip/winbond-840.c
drivers/net/typhoon.c
drivers/net/ucc_geth_ethtool.c
drivers/net/usb/asix.c
drivers/net/usb/catc.c
drivers/net/usb/cdc-phonet.c
drivers/net/usb/cdc_eem.c
drivers/net/usb/dm9601.c
drivers/net/usb/gl620a.c
drivers/net/usb/int51x1.c
drivers/net/usb/mcs7830.c
drivers/net/usb/net1080.c
drivers/net/usb/rndis_host.c
drivers/net/usb/smsc75xx.c
drivers/net/usb/smsc95xx.c
drivers/net/usb/usbnet.c
drivers/net/veth.c
drivers/net/via-rhine.c
drivers/net/via-velocity.c
drivers/net/virtio_net.c
drivers/net/vxge/vxge-config.c
drivers/net/vxge/vxge-config.h
drivers/net/vxge/vxge-ethtool.c
drivers/net/vxge/vxge-main.c
drivers/net/wan/dscc4.c
drivers/net/wan/farsync.c
drivers/net/wan/hd64570.c
drivers/net/wan/hd64572.c
drivers/net/wan/hdlc_cisco.c
drivers/net/wan/hdlc_raw.c
drivers/net/wan/hdlc_raw_eth.c
drivers/net/wan/hdlc_x25.c
drivers/net/wan/hostess_sv11.c
drivers/net/wan/ixp4xx_hss.c
drivers/net/wan/lapbether.c
drivers/net/wan/lmc/lmc_media.c
drivers/net/wan/lmc/lmc_proto.c
drivers/net/wan/pc300_drv.c
drivers/net/wan/sbni.c
drivers/net/wan/sealevel.c
drivers/net/wan/x25_asy.c
drivers/net/wan/z85230.c
drivers/net/wimax/i2400m/control.c
drivers/net/wimax/i2400m/driver.c
drivers/net/wimax/i2400m/fw.c
drivers/net/wimax/i2400m/netdev.c
drivers/net/wimax/i2400m/op-rfkill.c
drivers/net/wimax/i2400m/rx.c
drivers/net/wimax/i2400m/sdio-rx.c
drivers/net/wimax/i2400m/sdio.c
drivers/net/wimax/i2400m/tx.c
drivers/net/wimax/i2400m/usb-fw.c
drivers/net/wimax/i2400m/usb-notif.c
drivers/net/wimax/i2400m/usb-rx.c
drivers/net/wimax/i2400m/usb.c
drivers/net/wireless/adm8211.c
drivers/net/wireless/ath/ar9170/main.c
drivers/net/wireless/ath/ar9170/usb.c
drivers/net/wireless/ath/ath5k/attach.c
drivers/net/wireless/ath/ath5k/base.c
drivers/net/wireless/ath/ath5k/eeprom.c
drivers/net/wireless/ath/ath5k/phy.c
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/phy.c
drivers/net/wireless/ath/ath9k/rc.c
drivers/net/wireless/ath/ath9k/virtual.c
drivers/net/wireless/ath/ath9k/xmit.c
drivers/net/wireless/ath/regd.c
drivers/net/wireless/b43/dma.c
drivers/net/wireless/b43/lo.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/b43/pcmcia.c
drivers/net/wireless/b43/phy_a.c
drivers/net/wireless/b43/phy_g.c
drivers/net/wireless/b43/phy_lp.c
drivers/net/wireless/b43/phy_n.c
drivers/net/wireless/b43/pio.c
drivers/net/wireless/b43/sdio.c
drivers/net/wireless/b43legacy/dma.c
drivers/net/wireless/b43legacy/main.c
drivers/net/wireless/b43legacy/phy.c
drivers/net/wireless/b43legacy/pio.c
drivers/net/wireless/hostap/hostap_80211_rx.c
drivers/net/wireless/hostap/hostap_80211_tx.c
drivers/net/wireless/hostap/hostap_ap.c
drivers/net/wireless/hostap/hostap_cs.c
drivers/net/wireless/hostap/hostap_info.c
drivers/net/wireless/hostap/hostap_ioctl.c
drivers/net/wireless/hostap/hostap_pci.c
drivers/net/wireless/hostap/hostap_plx.c
drivers/net/wireless/ipw2x00/ipw2200.c
drivers/net/wireless/ipw2x00/libipw_geo.c
drivers/net/wireless/ipw2x00/libipw_rx.c
drivers/net/wireless/ipw2x00/libipw_wx.c
drivers/net/wireless/iwlwifi/iwl-3945-rs.c
drivers/net/wireless/iwlwifi/iwl-3945.c
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-calib.c
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-debugfs.c
drivers/net/wireless/iwlwifi/iwl-devtrace.c
drivers/net/wireless/iwlwifi/iwl-devtrace.h
drivers/net/wireless/iwlwifi/iwl-eeprom.c
drivers/net/wireless/iwlwifi/iwl-io.h
drivers/net/wireless/iwlwifi/iwl-power.c
drivers/net/wireless/iwlwifi/iwl-rx.c
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-tx.c
drivers/net/wireless/iwlwifi/iwl3945-base.c
drivers/net/wireless/iwmc3200wifi/cfg80211.c
drivers/net/wireless/iwmc3200wifi/commands.c
drivers/net/wireless/iwmc3200wifi/debugfs.c
drivers/net/wireless/iwmc3200wifi/eeprom.c
drivers/net/wireless/iwmc3200wifi/hal.c
drivers/net/wireless/iwmc3200wifi/main.c
drivers/net/wireless/iwmc3200wifi/netdev.c
drivers/net/wireless/iwmc3200wifi/rx.c
drivers/net/wireless/iwmc3200wifi/sdio.c
drivers/net/wireless/iwmc3200wifi/tx.c
drivers/net/wireless/libertas/assoc.c
drivers/net/wireless/libertas/cfg.c
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/cmdresp.c
drivers/net/wireless/libertas/debugfs.c
drivers/net/wireless/libertas/dev.h
drivers/net/wireless/libertas/if_cs.c
drivers/net/wireless/libertas/if_sdio.c
drivers/net/wireless/libertas/if_spi.c
drivers/net/wireless/libertas/if_usb.c
drivers/net/wireless/libertas/main.c
drivers/net/wireless/libertas/rx.c
drivers/net/wireless/libertas/scan.c
drivers/net/wireless/libertas/wext.c
drivers/net/wireless/libertas_tf/cmd.c
drivers/net/wireless/libertas_tf/if_usb.c
drivers/net/wireless/libertas_tf/main.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/mwl8k.c
drivers/net/wireless/orinoco/fw.c
drivers/net/wireless/orinoco/main.c
drivers/net/wireless/orinoco/scan.c
drivers/net/wireless/orinoco/wext.c
drivers/net/wireless/p54/eeprom.c
drivers/net/wireless/p54/fwio.c
drivers/net/wireless/p54/main.c
drivers/net/wireless/p54/p54pci.c
drivers/net/wireless/p54/p54spi.c
drivers/net/wireless/p54/p54usb.c
drivers/net/wireless/prism54/isl_ioctl.c
drivers/net/wireless/prism54/islpci_dev.c
drivers/net/wireless/prism54/islpci_eth.c
drivers/net/wireless/prism54/islpci_mgt.c
drivers/net/wireless/prism54/islpci_mgt.h
drivers/net/wireless/prism54/oid_mgt.c
drivers/net/wireless/ray_cs.c
drivers/net/wireless/rndis_wlan.c
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2x00debug.c
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt2x00queue.c
drivers/net/wireless/rt2x00/rt2x00soc.c
drivers/net/wireless/rt2x00/rt2x00usb.c
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt73usb.c
drivers/net/wireless/rtl818x/rtl8180_dev.c
drivers/net/wireless/rtl818x/rtl8187_dev.c
drivers/net/wireless/wl12xx/wl1251_acx.c
drivers/net/wireless/wl12xx/wl1251_boot.c
drivers/net/wireless/wl12xx/wl1251_cmd.c
drivers/net/wireless/wl12xx/wl1251_debugfs.c
drivers/net/wireless/wl12xx/wl1251_init.c
drivers/net/wireless/wl12xx/wl1251_main.c
drivers/net/wireless/wl12xx/wl1251_rx.c
drivers/net/wireless/wl12xx/wl1251_spi.c
drivers/net/wireless/wl12xx/wl1271_acx.c
drivers/net/wireless/wl12xx/wl1271_boot.c
drivers/net/wireless/wl12xx/wl1271_cmd.c
drivers/net/wireless/wl12xx/wl1271_debugfs.c
drivers/net/wireless/wl12xx/wl1271_init.c
drivers/net/wireless/wl12xx/wl1271_main.c
drivers/net/wireless/wl12xx/wl1271_rx.c
drivers/net/wireless/wl12xx/wl1271_spi.c
drivers/net/wireless/wl12xx/wl1271_testmode.c
drivers/net/wireless/zd1201.c
drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
drivers/net/wireless/zd1211rw/zd_usb.c
drivers/net/xen-netfront.c
drivers/net/xilinx_emaclite.c
drivers/net/xtsonic.c
drivers/net/yellowfin.c
drivers/net/znet.c
drivers/nubus/nubus.c
drivers/of/base.c
drivers/of/fdt.c
drivers/of/gpio.c
drivers/oprofile/buffer_sync.c
drivers/parisc/asp.c
drivers/parisc/ccio-rm-dma.c
drivers/parisc/gsc.c
drivers/parport/daisy.c
drivers/parport/parport_ax88796.c
drivers/parport/parport_ip32.c
drivers/parport/parport_serial.c
drivers/parport/probe.c
drivers/pci/access.c
drivers/pci/bus.c
drivers/pci/dmar.c
drivers/pci/hotplug/acpi_pcihp.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/hotplug/acpiphp_ibm.c
drivers/pci/hotplug/cpqphp_sysfs.c
drivers/pci/hotplug/fakephp.c
drivers/pci/hotplug/pci_hotplug_core.c
drivers/pci/hotplug/pciehp_acpi.c
drivers/pci/hotplug/pciehp_core.c
drivers/pci/hotplug/pciehp_ctrl.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/rpaphp_core.c
drivers/pci/hotplug/sgi_hotplug.c
drivers/pci/hotplug/shpchp_core.c
drivers/pci/hotplug/shpchp_ctrl.c
drivers/pci/htirq.c
drivers/pci/intr_remapping.c
drivers/pci/ioapic.c
drivers/pci/iov.c
drivers/pci/msi.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.c
drivers/pci/pcie/aer/aer_inject.c
drivers/pci/pcie/aer/aerdrv.c
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/pcie/pme/pcie_pme.c
drivers/pci/pcie/portdrv_pci.c
drivers/pci/probe.c
drivers/pci/proc.c
drivers/pci/quirks.c
drivers/pci/search.c
drivers/pci/setup-res.c
drivers/pci/slot.c
drivers/pcmcia/at91_cf.c
drivers/pcmcia/au1000_generic.c
drivers/pcmcia/bcm63xx_pcmcia.c
drivers/pcmcia/bfin_cf_pcmcia.c
drivers/pcmcia/cs.c
drivers/pcmcia/db1xxx_ss.c
drivers/pcmcia/ds.c
drivers/pcmcia/electra_cf.c
drivers/pcmcia/i82092.c
drivers/pcmcia/i82365.c
drivers/pcmcia/m32r_cfc.c
drivers/pcmcia/m32r_pcc.c
drivers/pcmcia/m8xx_pcmcia.c
drivers/pcmcia/omap_cf.c
drivers/pcmcia/pcmcia_ioctl.c
drivers/pcmcia/pcmcia_resource.c
drivers/pcmcia/pd6729.c
drivers/pcmcia/pxa2xx_base.c
drivers/pcmcia/rsrc_mgr.c
drivers/pcmcia/rsrc_nonstatic.c
drivers/pcmcia/sa1100_generic.c
drivers/pcmcia/sa1111_generic.c
drivers/pcmcia/sa11xx_base.c
drivers/pcmcia/socket_sysfs.c
drivers/pcmcia/tcic.c
drivers/pcmcia/vrc4171_card.c
drivers/pcmcia/xxs1500_ss.c
drivers/pcmcia/yenta_socket.c
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/asus-laptop.c
drivers/platform/x86/asus_acpi.c
drivers/platform/x86/classmate-laptop.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/dell-wmi.c
drivers/platform/x86/eeepc-laptop.c
drivers/platform/x86/eeepc-wmi.c [new file with mode: 0644]
drivers/platform/x86/fujitsu-laptop.c
drivers/platform/x86/hp-wmi.c
drivers/platform/x86/intel_menlow.c
drivers/platform/x86/msi-wmi.c
drivers/platform/x86/panasonic-laptop.c
drivers/platform/x86/sony-laptop.c
drivers/platform/x86/tc1100-wmi.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/topstar-laptop.c
drivers/platform/x86/toshiba_acpi.c
drivers/platform/x86/wmi.c
drivers/pnp/isapnp/core.c
drivers/pnp/manager.c
drivers/pnp/pnpacpi/core.c
drivers/pnp/pnpacpi/rsparser.c
drivers/pnp/pnpbios/bioscalls.c
drivers/pnp/pnpbios/rsparser.c
drivers/pnp/resource.c
drivers/power/bq27x00_battery.c
drivers/power/da9030_battery.c
drivers/power/ds2760_battery.c
drivers/power/ds2782_battery.c
drivers/power/max17040_battery.c
drivers/power/max8925_power.c
drivers/power/pcf50633-charger.c
drivers/power/pmu_battery.c
drivers/power/power_supply_leds.c
drivers/power/power_supply_sysfs.c
drivers/power/wm831x_backup.c
drivers/power/wm831x_power.c
drivers/power/wm97xx_battery.c
drivers/pps/kapi.c
drivers/ps3/ps3-lpm.c
drivers/ps3/ps3-vuart.c
drivers/ps3/ps3av.c
drivers/regulator/core.c
drivers/regulator/fixed.c
drivers/regulator/lp3971.c
drivers/regulator/max1586.c
drivers/regulator/max8649.c
drivers/regulator/max8660.c
drivers/regulator/max8925-regulator.c
drivers/regulator/mc13783-regulator.c
drivers/regulator/tps65023-regulator.c
drivers/regulator/tps6507x-regulator.c
drivers/regulator/userspace-consumer.c
drivers/regulator/virtual.c
drivers/regulator/wm831x-dcdc.c
drivers/regulator/wm831x-isink.c
drivers/regulator/wm831x-ldo.c
drivers/regulator/wm8994-regulator.c
drivers/rtc/class.c
drivers/rtc/rtc-at32ap700x.c
drivers/rtc/rtc-at91sam9.c
drivers/rtc/rtc-bfin.c
drivers/rtc/rtc-bq4802.c
drivers/rtc/rtc-coh901331.c
drivers/rtc/rtc-ds1216.c
drivers/rtc/rtc-ds1286.c
drivers/rtc/rtc-ds1305.c
drivers/rtc/rtc-ds1374.c
drivers/rtc/rtc-ds1390.c
drivers/rtc/rtc-ds1511.c
drivers/rtc/rtc-ds1553.c
drivers/rtc/rtc-ds1742.c
drivers/rtc/rtc-ep93xx.c
drivers/rtc/rtc-fm3130.c
drivers/rtc/rtc-m48t35.c
drivers/rtc/rtc-m48t59.c
drivers/rtc/rtc-max8925.c
drivers/rtc/rtc-mc13783.c
drivers/rtc/rtc-mpc5121.c
drivers/rtc/rtc-msm6242.c
drivers/rtc/rtc-mv.c
drivers/rtc/rtc-mxc.c
drivers/rtc/rtc-nuc900.c
drivers/rtc/rtc-pcap.c
drivers/rtc/rtc-pcf2123.c
drivers/rtc/rtc-pcf50633.c
drivers/rtc/rtc-pcf8563.c
drivers/rtc/rtc-pl030.c
drivers/rtc/rtc-pl031.c
drivers/rtc/rtc-pxa.c
drivers/rtc/rtc-rp5c01.c
drivers/rtc/rtc-rs5c348.c
drivers/rtc/rtc-rs5c372.c
drivers/rtc/rtc-rx8025.c
drivers/rtc/rtc-s3c.c
drivers/rtc/rtc-sh.c
drivers/rtc/rtc-stk17ta8.c
drivers/rtc/rtc-stmp3xxx.c
drivers/rtc/rtc-tx4939.c
drivers/rtc/rtc-v3020.c
drivers/rtc/rtc-wm831x.c
drivers/s390/block/dasd_3990_erp.c
drivers/s390/block/dasd_alias.c
drivers/s390/block/dasd_devmap.c
drivers/s390/block/dasd_eckd.c
drivers/s390/block/dasd_eer.c
drivers/s390/block/dasd_ioctl.c
drivers/s390/block/dasd_proc.c
drivers/s390/block/xpram.c
drivers/s390/char/con3270.c
drivers/s390/char/fs3270.c
drivers/s390/char/keyboard.c
drivers/s390/char/monreader.c
drivers/s390/char/monwriter.c
drivers/s390/char/sclp_async.c
drivers/s390/char/sclp_cmd.c
drivers/s390/char/sclp_con.c
drivers/s390/char/sclp_tty.c
drivers/s390/char/sclp_vt220.c
drivers/s390/char/tape_34xx.c
drivers/s390/char/tape_3590.c
drivers/s390/char/tape_class.c
drivers/s390/char/tape_core.c
drivers/s390/char/vmcp.c
drivers/s390/char/vmlogrdr.c
drivers/s390/char/vmur.c
drivers/s390/char/vmwatchdog.c
drivers/s390/char/zcore.c
drivers/s390/cio/blacklist.c
drivers/s390/cio/chp.c
drivers/s390/cio/chsc_sch.c
drivers/s390/cio/qdio_main.c
drivers/s390/cio/qdio_thinint.c
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/zcrypt_api.c
drivers/s390/crypto/zcrypt_cex2a.c
drivers/s390/crypto/zcrypt_pcica.c
drivers/s390/crypto/zcrypt_pcicc.c
drivers/s390/crypto/zcrypt_pcixcc.c
drivers/s390/kvm/kvm_virtio.c
drivers/s390/net/ctcm_dbug.c
drivers/s390/net/ctcm_sysfs.c
drivers/s390/net/fsm.c
drivers/s390/net/lcs.c
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c
drivers/s390/net/qeth_l3_sys.c
drivers/s390/net/smsgiucv.c
drivers/s390/net/smsgiucv_app.c
drivers/s390/scsi/zfcp_aux.c
drivers/s390/scsi/zfcp_cfdc.c
drivers/s390/scsi/zfcp_dbf.c
drivers/s390/scsi/zfcp_fc.c
drivers/s390/scsi/zfcp_fsf.c
drivers/s390/scsi/zfcp_qdio.c
drivers/s390/scsi/zfcp_scsi.c
drivers/s390/scsi/zfcp_sysfs.c
drivers/sbus/char/bbc_envctrl.c
drivers/sbus/char/display7seg.c
drivers/sbus/char/envctrl.c
drivers/sbus/char/flash.c
drivers/sbus/char/jsflash.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-sas.c
drivers/scsi/3w-xxxx.c
drivers/scsi/53c700.c
drivers/scsi/BusLogic.c
drivers/scsi/NCR_D700.c
drivers/scsi/NCR_Q720.c
drivers/scsi/a100u2w.c
drivers/scsi/a2091.c
drivers/scsi/a3000.c
drivers/scsi/a4000t.c
drivers/scsi/aacraid/rx.c
drivers/scsi/aacraid/sa.c
drivers/scsi/advansys.c
drivers/scsi/aha152x.c
drivers/scsi/aha1542.c
drivers/scsi/aha1740.c
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/aic7xxx/aic7xxx_osm.c
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/aic94xx/aic94xx_scb.c
drivers/scsi/aic94xx/aic94xx_sds.c
drivers/scsi/aic94xx/aic94xx_seq.c
drivers/scsi/aic94xx/aic94xx_tmf.c
drivers/scsi/arcmsr/arcmsr_hba.c
drivers/scsi/atari_NCR5380.c
drivers/scsi/atp870u.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bfa/bfad.c
drivers/scsi/bfa/bfad_attr.c
drivers/scsi/bfa/bfad_im.c
drivers/scsi/bfa/rport.c
drivers/scsi/bnx2i/bnx2i_hwi.c
drivers/scsi/bnx2i/bnx2i_iscsi.c
drivers/scsi/bvme6000_scsi.c
drivers/scsi/ch.c
drivers/scsi/cxgb3i/cxgb3i_ddp.c
drivers/scsi/cxgb3i/cxgb3i_ddp.h
drivers/scsi/cxgb3i/cxgb3i_iscsi.c
drivers/scsi/cxgb3i/cxgb3i_offload.c
drivers/scsi/cxgb3i/cxgb3i_pdu.c
drivers/scsi/dc395x.c
drivers/scsi/device_handler/scsi_dh.c
drivers/scsi/device_handler/scsi_dh_alua.c
drivers/scsi/device_handler/scsi_dh_emc.c
drivers/scsi/device_handler/scsi_dh_hp_sw.c
drivers/scsi/device_handler/scsi_dh_rdac.c
drivers/scsi/eata.c
drivers/scsi/eata_pio.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fcoe/libfcoe.c
drivers/scsi/fd_mcs.c
drivers/scsi/fdomain.c
drivers/scsi/fnic/fnic_fcs.c
drivers/scsi/fnic/fnic_main.c
drivers/scsi/fnic/fnic_scsi.c
drivers/scsi/fnic/vnic_dev.c
drivers/scsi/fnic/vnic_rq.c
drivers/scsi/fnic/vnic_wq.c
drivers/scsi/gdth.c
drivers/scsi/gdth_proc.c
drivers/scsi/gvp11.c
drivers/scsi/hosts.c
drivers/scsi/hptiop.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ibmvscsi/ibmvscsi.c
drivers/scsi/ibmvscsi/ibmvstgt.c
drivers/scsi/ibmvscsi/rpa_vscsi.c
drivers/scsi/imm.c
drivers/scsi/ipr.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/jazz_esp.c
drivers/scsi/lasi700.c
drivers/scsi/libfc/fc_disc.c
drivers/scsi/libfc/fc_exch.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/libfc/fc_frame.c
drivers/scsi/libfc/fc_lport.c
drivers/scsi/libfc/fc_rport.c
drivers/scsi/libiscsi.c
drivers/scsi/libiscsi_tcp.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_discover.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_host_smp.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/libsas/sas_scsi_host.c
drivers/scsi/libsrp.c
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_bsg.c
drivers/scsi/lpfc/lpfc_ct.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_mbox.c
drivers/scsi/lpfc/lpfc_mem.c
drivers/scsi/lpfc/lpfc_nportdisc.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_vport.c
drivers/scsi/mac_esp.c
drivers/scsi/megaraid.c
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/megaraid/megaraid_mm.c
drivers/scsi/megaraid/megaraid_sas.c
drivers/scsi/mesh.c
drivers/scsi/mpt2sas/mpt2sas_config.c
drivers/scsi/mpt2sas/mpt2sas_scsih.c
drivers/scsi/mpt2sas/mpt2sas_transport.c
drivers/scsi/mvme16x_scsi.c
drivers/scsi/mvsas/mv_sas.h
drivers/scsi/ncr53c8xx.c
drivers/scsi/nsp32.c
drivers/scsi/osd/osd_initiator.c
drivers/scsi/osd/osd_uld.c
drivers/scsi/osst.c
drivers/scsi/pm8001/pm8001_ctl.c
drivers/scsi/pm8001/pm8001_hwi.c
drivers/scsi/pm8001/pm8001_init.c
drivers/scsi/pm8001/pm8001_sas.c
drivers/scsi/pmcraid.c
drivers/scsi/ppa.c
drivers/scsi/ps3rom.c
drivers/scsi/qla1280.c
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_fw.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_sup.c
drivers/scsi/qla2xxx/qla_version.h
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/qlogicpti.c
drivers/scsi/scsi_debug.c
drivers/scsi/scsi_devinfo.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_netlink.c
drivers/scsi/scsi_proc.c
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/scsi_tgt_if.c
drivers/scsi/scsi_tgt_lib.c
drivers/scsi/scsi_transport_fc.c
drivers/scsi/scsi_transport_iscsi.c
drivers/scsi/scsi_transport_spi.c
drivers/scsi/scsicam.c
drivers/scsi/sd.c
drivers/scsi/ses.c
drivers/scsi/sg.c
drivers/scsi/sim710.c
drivers/scsi/sni_53c710.c
drivers/scsi/sr.c
drivers/scsi/sr_ioctl.c
drivers/scsi/sr_vendor.c
drivers/scsi/st.c
drivers/scsi/stex.c
drivers/scsi/sun3_NCR5380.c
drivers/scsi/sun3x_esp.c
drivers/scsi/sun_esp.c
drivers/scsi/tmscsim.c
drivers/scsi/u14-34f.c
drivers/scsi/vmw_pvscsi.c
drivers/scsi/wd7000.c
drivers/scsi/zorro7xx.c
drivers/serial/68328serial.c
drivers/serial/8250.c
drivers/serial/8250_gsc.c
drivers/serial/8250_hp300.c
drivers/serial/amba-pl010.c
drivers/serial/amba-pl011.c
drivers/serial/bfin_5xx.c
drivers/serial/bfin_sport_uart.c
drivers/serial/cpm_uart/cpm_uart_cpm1.c
drivers/serial/cpm_uart/cpm_uart_cpm2.c
drivers/serial/imx.c
drivers/serial/ioc3_serial.c
drivers/serial/ioc4_serial.c
drivers/serial/jsm/jsm_driver.c
drivers/serial/jsm/jsm_tty.c
drivers/serial/max3100.c
drivers/serial/mpsc.c
drivers/serial/mux.c
drivers/serial/of_serial.c
drivers/serial/pmac_zilog.c
drivers/serial/pxa.c
drivers/serial/serial_cs.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
drivers/serial/sunsu.c
drivers/serial/timbuart.c
drivers/serial/ucc_uart.c
drivers/sh/intc.c
drivers/sn/ioc3.c
drivers/spi/amba-pl022.c
drivers/spi/atmel_spi.c
drivers/spi/au1550_spi.c
drivers/spi/davinci_spi.c
drivers/spi/dw_spi.c
drivers/spi/dw_spi_mmio.c
drivers/spi/dw_spi_pci.c
drivers/spi/mpc52xx_psc_spi.c
drivers/spi/mpc52xx_spi.c
drivers/spi/omap2_mcspi.c
drivers/spi/omap_spi_100k.c
drivers/spi/omap_uwire.c
drivers/spi/pxa2xx_spi.c
drivers/spi/spi.c
drivers/spi/spi_bfin5xx.c
drivers/spi/spi_bitbang.c
drivers/spi/spi_imx.c
drivers/spi/spi_mpc8xxx.c
drivers/spi/spi_nuc900.c
drivers/spi/spi_ppc4xx.c
drivers/spi/spi_s3c24xx.c
drivers/spi/tle62x0.c
drivers/spi/xilinx_spi_of.c
drivers/ssb/driver_gige.c
drivers/ssb/main.c
drivers/ssb/pci.c
drivers/ssb/pcihost_wrapper.c
drivers/ssb/sprom.c
drivers/staging/batman-adv/device.c
drivers/staging/batman-adv/main.h
drivers/staging/batman-adv/soft-interface.c
drivers/staging/comedi/drivers/8255.c
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/amplc_dio200.c
drivers/staging/comedi/drivers/amplc_pci224.c
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/comedi/drivers/comedi_bond.c
drivers/staging/comedi/drivers/das08_cs.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/das1800.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/jr3_pci.c
drivers/staging/comedi/drivers/ni_65xx.c
drivers/staging/comedi/drivers/ni_670x.c
drivers/staging/comedi/drivers/ni_at_a2150.c
drivers/staging/comedi/drivers/ni_daq_700.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc_cs.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/serial2002.c
drivers/staging/comedi/drivers/unioxx5.c
drivers/staging/comedi/kcomedilib/kcomedilib_main.c
drivers/staging/comedi/kcomedilib/ksyms.c
drivers/staging/crystalhd/crystalhd_hw.c
drivers/staging/crystalhd/crystalhd_lnx.c
drivers/staging/crystalhd/crystalhd_misc.c
drivers/staging/cx25821/cx25821-alsa.c
drivers/staging/cx25821/cx25821-audio-upstream.c
drivers/staging/cx25821/cx25821-audups11.c
drivers/staging/cx25821/cx25821-core.c
drivers/staging/cx25821/cx25821-video-upstream-ch2.c
drivers/staging/cx25821/cx25821-video-upstream.c
drivers/staging/dream/camera/msm_camera.c
drivers/staging/dream/camera/msm_v4l2.c
drivers/staging/dream/camera/msm_vfe7x.c
drivers/staging/dream/camera/msm_vfe8x.c
drivers/staging/dream/camera/mt9d112.c
drivers/staging/dream/camera/mt9p012_fox.c
drivers/staging/dream/camera/mt9t013.c
drivers/staging/dream/camera/s5k3e2fx.c
drivers/staging/dream/gpio_axis.c
drivers/staging/dream/gpio_event.c
drivers/staging/dream/gpio_input.c
drivers/staging/dream/gpio_matrix.c
drivers/staging/dream/pmem.c
drivers/staging/dream/qdsp5/adsp.c
drivers/staging/dream/qdsp5/adsp_driver.c
drivers/staging/dream/qdsp5/audio_aac.c
drivers/staging/dream/qdsp5/audio_amrnb.c
drivers/staging/dream/qdsp5/audio_evrc.c
drivers/staging/dream/qdsp5/audio_in.c
drivers/staging/dream/qdsp5/audio_mp3.c
drivers/staging/dream/qdsp5/audio_out.c
drivers/staging/dream/qdsp5/audio_qcelp.c
drivers/staging/dream/qdsp5/audmgr.c
drivers/staging/dream/smd/smd_rpcrouter.c
drivers/staging/dream/smd/smd_rpcrouter_device.c
drivers/staging/dream/smd/smd_rpcrouter_servers.c
drivers/staging/dream/synaptics_i2c_rmi.c
drivers/staging/dt3155/allocator.c
drivers/staging/dt3155/dt3155_isr.c
drivers/staging/et131x/et1310_eeprom.c
drivers/staging/et131x/et1310_mac.c
drivers/staging/et131x/et1310_phy.c
drivers/staging/et131x/et1310_pm.c
drivers/staging/et131x/et131x_initpci.c
drivers/staging/et131x/et131x_isr.c
drivers/staging/et131x/et131x_netdev.c
drivers/staging/go7007/go7007-driver.c
drivers/staging/go7007/go7007-fw.c
drivers/staging/go7007/go7007-v4l2.c
drivers/staging/go7007/s2250-board.c
drivers/staging/go7007/s2250-loader.c
drivers/staging/go7007/snd-go7007.c
drivers/staging/go7007/wis-saa7113.c
drivers/staging/go7007/wis-saa7115.c
drivers/staging/go7007/wis-sony-tuner.c
drivers/staging/go7007/wis-tw2804.c
drivers/staging/go7007/wis-tw9903.c
drivers/staging/hv/Channel.c
drivers/staging/hv/ChannelMgmt.c
drivers/staging/hv/Connection.c
drivers/staging/hv/Hv.c
drivers/staging/hv/NetVsc.c
drivers/staging/hv/RndisFilter.c
drivers/staging/hv/StorVsc.c
drivers/staging/hv/Vmbus.c
drivers/staging/hv/blkvsc_drv.c
drivers/staging/hv/netvsc_drv.c
drivers/staging/hv/osd.c
drivers/staging/hv/storvsc_drv.c
drivers/staging/hv/vmbus_drv.c
drivers/staging/iio/accel/kxsd9.c
drivers/staging/iio/accel/lis3l02dq_core.c
drivers/staging/iio/accel/lis3l02dq_ring.c
drivers/staging/iio/accel/sca3000_core.c
drivers/staging/iio/accel/sca3000_ring.c
drivers/staging/iio/adc/max1363_core.c
drivers/staging/iio/adc/max1363_ring.c
drivers/staging/iio/industrialio-core.c
drivers/staging/iio/industrialio-ring.c
drivers/staging/iio/industrialio-trigger.c
drivers/staging/iio/light/tsl2563.c
drivers/staging/iio/ring_sw.c
drivers/staging/iio/trigger/iio-trig-gpio.c
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
drivers/staging/line6/capture.c
drivers/staging/line6/driver.c
drivers/staging/line6/dumprequest.c
drivers/staging/line6/midi.c
drivers/staging/line6/pcm.c
drivers/staging/line6/playback.c
drivers/staging/line6/pod.c
drivers/staging/line6/variax.c
drivers/staging/netwave/netwave_cs.c
drivers/staging/octeon/ethernet-mem.c
drivers/staging/octeon/ethernet.c
drivers/staging/otus/ioctl.c
drivers/staging/otus/usbdrv.c
drivers/staging/otus/usbdrv.h
drivers/staging/otus/wrap_mem.c
drivers/staging/otus/wrap_pkt.c
drivers/staging/otus/wrap_usb.c
drivers/staging/otus/wwrap.c
drivers/staging/otus/zdusb.c
drivers/staging/poch/poch.c
drivers/staging/pohmelfs/config.c
drivers/staging/pohmelfs/dir.c
drivers/staging/pohmelfs/lock.c
drivers/staging/pohmelfs/net.c
drivers/staging/pohmelfs/path_entry.c
drivers/staging/ramzswap/ramzswap_drv.c
drivers/staging/rt2860/pci_main_dev.c
drivers/staging/rt2860/rt_linux.c
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
drivers/staging/rtl8187se/r8180_core.c
drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192e/r8192E_core.c
drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192su/r8192U_core.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/sep/sep_driver.c
drivers/staging/sm7xx/smtcfb.c
drivers/staging/strip/strip.c
drivers/staging/udlfb/udlfb.c
drivers/staging/usbip/stub_dev.c
drivers/staging/usbip/stub_main.c
drivers/staging/usbip/stub_rx.c
drivers/staging/usbip/stub_tx.c
drivers/staging/usbip/usbip_common.c
drivers/staging/usbip/vhci_hcd.c
drivers/staging/usbip/vhci_rx.c
drivers/staging/usbip/vhci_tx.c
drivers/staging/vme/bridges/vme_ca91cx42.c
drivers/staging/vme/bridges/vme_tsi148.c
drivers/staging/vme/devices/vme_user.c
drivers/staging/vme/vme.c
drivers/staging/vt6655/device_main.c
drivers/staging/winbond/wb35reg.c
drivers/staging/winbond/wb35rx.c
drivers/staging/winbond/wb35tx.c
drivers/staging/wlags49_h2/wl_cs.c
drivers/staging/wlags49_h2/wl_netdev.c
drivers/staging/wlags49_h2/wl_pci.c
drivers/staging/wlags49_h2/wl_priv.c
drivers/staging/wlan-ng/p80211req.c
drivers/staging/wlan-ng/p80211wep.c
drivers/staging/wlan-ng/p80211wext.c
drivers/staging/wlan-ng/prism2fw.c
drivers/staging/wlan-ng/prism2mgmt.c
drivers/staging/wlan-ng/prism2mib.c
drivers/tc/tc.c
drivers/thermal/thermal_sys.c
drivers/uio/uio.c
drivers/uio/uio_aec.c
drivers/uio/uio_cif.c
drivers/uio/uio_netx.c
drivers/uio/uio_pci_generic.c
drivers/uio/uio_pdrv.c
drivers/uio/uio_pdrv_genirq.c
drivers/uio/uio_sercos3.c
drivers/usb/atm/speedtch.c
drivers/usb/atm/ueagle-atm.c
drivers/usb/c67x00/c67x00-drv.c
drivers/usb/c67x00/c67x00-sched.c
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-wdm.c
drivers/usb/class/usbtmc.c
drivers/usb/core/devices.c
drivers/usb/core/devio.c
drivers/usb/core/driver.c
drivers/usb/core/endpoint.c
drivers/usb/core/file.c
drivers/usb/core/urb.c
drivers/usb/gadget/Kconfig
drivers/usb/gadget/at91_udc.c
drivers/usb/gadget/atmel_usba_udc.c
drivers/usb/gadget/ci13xxx_udc.c
drivers/usb/gadget/config.c
drivers/usb/gadget/epautoconf.c
drivers/usb/gadget/f_acm.c
drivers/usb/gadget/f_audio.c
drivers/usb/gadget/f_ecm.c
drivers/usb/gadget/f_eem.c
drivers/usb/gadget/f_loopback.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/f_obex.c
drivers/usb/gadget/f_phonet.c
drivers/usb/gadget/f_rndis.c
drivers/usb/gadget/f_serial.c
drivers/usb/gadget/f_sourcesink.c
drivers/usb/gadget/f_subset.c
drivers/usb/gadget/gadget_chips.h
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/goku_udc.c
drivers/usb/gadget/imx_udc.c
drivers/usb/gadget/lh7a40x_udc.c
drivers/usb/gadget/m66592-udc.c
drivers/usb/gadget/multi.c
drivers/usb/gadget/pxa27x_udc.c
drivers/usb/gadget/r8a66597-udc.c
drivers/usb/gadget/rndis.c
drivers/usb/gadget/s3c-hsotg.c
drivers/usb/gadget/u_audio.c
drivers/usb/gadget/u_ether.c
drivers/usb/gadget/u_serial.c
drivers/usb/gadget/zero.c
drivers/usb/host/Makefile
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-mxc.c
drivers/usb/host/ehci-omap.c
drivers/usb/host/ehci-sched.c
drivers/usb/host/ehci.h
drivers/usb/host/fhci-hcd.c
drivers/usb/host/fhci-mem.c
drivers/usb/host/fhci-q.c
drivers/usb/host/fhci-tds.c
drivers/usb/host/hwa-hc.c
drivers/usb/host/imx21-hcd.c
drivers/usb/host/isp116x-hcd.c
drivers/usb/host/ohci-q.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/host/uhci-debug.c
drivers/usb/host/whci/asl.c
drivers/usb/host/whci/debug.c
drivers/usb/host/whci/init.c
drivers/usb/host/whci/pzl.c
drivers/usb/host/whci/qset.c
drivers/usb/host/xhci-hcd.c [deleted file]
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c [new file with mode: 0644]
drivers/usb/misc/appledisplay.c
drivers/usb/misc/cypress_cy7c63.c
drivers/usb/misc/cytherm.c
drivers/usb/misc/isight_firmware.c
drivers/usb/misc/sisusbvga/sisusb_con.c
drivers/usb/misc/sisusbvga/sisusb_init.c
drivers/usb/misc/trancevibrator.c
drivers/usb/misc/uss720.c
drivers/usb/mon/mon_bin.c
drivers/usb/mon/mon_main.c
drivers/usb/mon/mon_stat.c
drivers/usb/mon/mon_text.c
drivers/usb/musb/blackfin.c
drivers/usb/musb/cppi_dma.c
drivers/usb/musb/davinci.c
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_core.h
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_host.c
drivers/usb/musb/musb_regs.h
drivers/usb/musb/musb_virthub.c
drivers/usb/musb/musbhsdma.c
drivers/usb/musb/omap2430.c
drivers/usb/musb/tusb6010_omap.c
drivers/usb/otg/gpio_vbus.c
drivers/usb/otg/nop-usb-xceiv.c
drivers/usb/otg/twl4030-usb.c
drivers/usb/otg/ulpi.c
drivers/usb/serial/Kconfig
drivers/usb/serial/aircable.c
drivers/usb/serial/ark3116.c
drivers/usb/serial/bus.c
drivers/usb/serial/ch341.c
drivers/usb/serial/console.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio_ids.h
drivers/usb/serial/generic.c
drivers/usb/serial/navman.c
drivers/usb/serial/opticon.c
drivers/usb/serial/option.c
drivers/usb/serial/qcserial.c
drivers/usb/serial/safe_serial.c
drivers/usb/serial/sierra.c
drivers/usb/serial/symbolserial.c
drivers/usb/serial/usb_debug.c
drivers/usb/storage/alauda.c
drivers/usb/storage/karma.c
drivers/usb/storage/option_ms.c
drivers/usb/storage/scsiglue.c
drivers/usb/storage/sierra_ms.c
drivers/usb/storage/transport.c
drivers/usb/storage/unusual_devs.h
drivers/usb/wusbcore/cbaf.c
drivers/usb/wusbcore/crypto.c
drivers/usb/wusbcore/devconnect.c
drivers/usb/wusbcore/mmc.c
drivers/usb/wusbcore/rh.c
drivers/usb/wusbcore/security.c
drivers/usb/wusbcore/wa-hc.c
drivers/usb/wusbcore/wa-nep.c
drivers/usb/wusbcore/wa-rpipe.c
drivers/usb/wusbcore/wa-xfer.c
drivers/uwb/address.c
drivers/uwb/allocator.c
drivers/uwb/beacon.c
drivers/uwb/drp-ie.c
drivers/uwb/drp.c
drivers/uwb/est.c
drivers/uwb/hwa-rc.c
drivers/uwb/i1480/dfu/mac.c
drivers/uwb/i1480/dfu/usb.c
drivers/uwb/i1480/i1480u-wlp/lc.c
drivers/uwb/i1480/i1480u-wlp/netdev.c
drivers/uwb/i1480/i1480u-wlp/rx.c
drivers/uwb/i1480/i1480u-wlp/tx.c
drivers/uwb/ie.c
drivers/uwb/lc-dev.c
drivers/uwb/lc-rc.c
drivers/uwb/neh.c
drivers/uwb/reset.c
drivers/uwb/rsv.c
drivers/uwb/scan.c
drivers/uwb/umc-dev.c
drivers/uwb/uwbd.c
drivers/uwb/whc-rc.c
drivers/uwb/whci.c
drivers/uwb/wlp/eda.c
drivers/uwb/wlp/messages.c
drivers/uwb/wlp/txrx.c
drivers/uwb/wlp/wlp-lc.c
drivers/uwb/wlp/wss-lc.c
drivers/vhost/net.c
drivers/vhost/vhost.c
drivers/video/68328fb.c
drivers/video/acornfb.c
drivers/video/amifb.c
drivers/video/arcfb.c
drivers/video/asiliantfb.c
drivers/video/atafb.c
drivers/video/atmel_lcdfb.c
drivers/video/aty/aty128fb.c
drivers/video/aty/mach64_cursor.c
drivers/video/aty/radeon_backlight.c
drivers/video/aty/radeon_monitor.c
drivers/video/au1100fb.c
drivers/video/au1200fb.c
drivers/video/backlight/88pm860x_bl.c
drivers/video/backlight/adp5520_bl.c
drivers/video/backlight/adx_bl.c
drivers/video/backlight/atmel-pwm-bl.c
drivers/video/backlight/backlight.c
drivers/video/backlight/corgi_lcd.c
drivers/video/backlight/cr_bllcd.c
drivers/video/backlight/da903x_bl.c
drivers/video/backlight/ili9320.c
drivers/video/backlight/l4f00242t03.c
drivers/video/backlight/lcd.c
drivers/video/backlight/lms283gf05.c
drivers/video/backlight/ltv350qv.c
drivers/video/backlight/max8925_bl.c
drivers/video/backlight/omap1_bl.c
drivers/video/backlight/platform_lcd.c
drivers/video/backlight/pwm_bl.c
drivers/video/backlight/tdo24m.c
drivers/video/backlight/tosa_bl.c
drivers/video/backlight/tosa_lcd.c
drivers/video/backlight/wm831x_bl.c
drivers/video/bfin-lq035q1-fb.c
drivers/video/bfin-t350mcqb-fb.c
drivers/video/bw2.c
drivers/video/carminefb.c
drivers/video/cfbcopyarea.c
drivers/video/cg14.c
drivers/video/cg3.c
drivers/video/cg6.c
drivers/video/chipsfb.c
drivers/video/cirrusfb.c
drivers/video/console/bitblit.c
drivers/video/console/fbcon_ccw.c
drivers/video/console/fbcon_cw.c
drivers/video/console/fbcon_rotate.c
drivers/video/console/fbcon_ud.c
drivers/video/console/mdacon.c
drivers/video/da8xx-fb.c
drivers/video/display/display-sysfs.c
drivers/video/dnfb.c
drivers/video/ep93xx-fb.c
drivers/video/epson1355fb.c
drivers/video/fb_ddc.c
drivers/video/fb_defio.c
drivers/video/fbcvt.c
drivers/video/fbmon.c
drivers/video/fbsysfs.c
drivers/video/ffb.c
drivers/video/g364fb.c
drivers/video/gbefb.c
drivers/video/geode/gx1fb_core.c
drivers/video/geode/gxfb_core.c
drivers/video/geode/lxfb.h
drivers/video/geode/lxfb_core.c
drivers/video/geode/lxfb_ops.c
drivers/video/hecubafb.c
drivers/video/hgafb.c
drivers/video/hitfb.c
drivers/video/hpfb.c
drivers/video/i810/i810-i2c.c
drivers/video/imsttfb.c
drivers/video/intelfb/intelfbhw.c
drivers/video/leo.c
drivers/video/matrox/i2c-matroxfb.c
drivers/video/matrox/matroxfb_base.c
drivers/video/matrox/matroxfb_crtc2.c
drivers/video/matrox/matroxfb_maven.c
drivers/video/maxinefb.c
drivers/video/mb862xx/mb862xxfb_accel.c
drivers/video/mbx/mbxdebugfs.c
drivers/video/metronomefb.c
drivers/video/modedb.c
drivers/video/msm/mddi.c
drivers/video/msm/mddi_client_dummy.c
drivers/video/msm/mddi_client_nt35399.c
drivers/video/msm/mddi_client_toshiba.c
drivers/video/msm/mdp.c
drivers/video/msm/msm_fb.c
drivers/video/nvidia/nv_i2c.c
drivers/video/nvidia/nv_of.c
drivers/video/nvidia/nv_setup.c
drivers/video/offb.c
drivers/video/omap/dispc.c
drivers/video/omap/lcd_mipid.c
drivers/video/omap/lcdc.c
drivers/video/omap/omapfb_main.c
drivers/video/omap2/displays/panel-generic.c
drivers/video/omap2/displays/panel-taal.c
drivers/video/omap2/displays/panel-tpo-td043mtea1.c
drivers/video/omap2/dss/dss.c
drivers/video/omap2/dss/manager.c
drivers/video/omap2/dss/overlay.c
drivers/video/omap2/omapfb/omapfb-main.c
drivers/video/omap2/vram.c
drivers/video/output.c
drivers/video/p9100.c
drivers/video/platinumfb.c
drivers/video/pmag-aa-fb.c
drivers/video/pnx4008/pnxrgbfb.c
drivers/video/pnx4008/sdum.c
drivers/video/pxa168fb.c
drivers/video/q40fb.c
drivers/video/s1d13xxxfb.c
drivers/video/s3c-fb.c
drivers/video/s3fb.c
drivers/video/savage/savagefb-i2c.c
drivers/video/sh7760fb.c
drivers/video/sh_mobile_lcdcfb.c
drivers/video/sstfb.c
drivers/video/sunxvr1000.c
drivers/video/sunxvr2500.c
drivers/video/sunxvr500.c
drivers/video/svgalib.c
drivers/video/syscopyarea.c
drivers/video/tcx.c
drivers/video/tgafb.c
drivers/video/tridentfb.c
drivers/video/uvesafb.c
drivers/video/vermilion/vermilion.c
drivers/video/vesafb.c
drivers/video/vfb.c
drivers/video/vga16fb.c
drivers/video/via/viafbdev.c
drivers/video/vt8623fb.c
drivers/video/w100fb.c
drivers/video/xen-fbfront.c
drivers/video/xilinxfb.c
drivers/virtio/virtio_balloon.c
drivers/virtio/virtio_pci.c
drivers/virtio/virtio_ring.c
drivers/vlynq/vlynq.c
drivers/w1/masters/ds1wm.c
drivers/w1/masters/ds2490.c
drivers/w1/masters/mxc_w1.c
drivers/w1/masters/omap_hdq.c
drivers/w1/masters/w1-gpio.c
drivers/w1/slaves/w1_ds2433.c
drivers/w1/slaves/w1_ds2760.c
drivers/w1/w1_int.c
drivers/w1/w1_netlink.c
drivers/watchdog/adx_wdt.c
drivers/watchdog/at32ap700x_wdt.c
drivers/watchdog/cpwd.c
drivers/watchdog/davinci_wdt.c
drivers/watchdog/hpwdt.c
drivers/watchdog/ibmasr.c
drivers/watchdog/max63xx_wdt.c
drivers/watchdog/mpcore_wdt.c
drivers/watchdog/nuc900_wdt.c
drivers/watchdog/omap_wdt.c
drivers/watchdog/pnx4008_wdt.c
drivers/watchdog/riowd.c
drivers/watchdog/s3c2410_wdt.c
drivers/watchdog/ts72xx_wdt.c
drivers/watchdog/twl4030_wdt.c
drivers/xen/balloon.c
drivers/xen/events.c
drivers/xen/evtchn.c
drivers/xen/grant-table.c
drivers/xen/manage.c
drivers/xen/sys-hypervisor.c
drivers/xen/xenbus/xenbus_client.c
drivers/xen/xenbus/xenbus_probe.c
drivers/xen/xencomm.c
drivers/xen/xenfs/xenbus.c
fs/9p/cache.c
fs/9p/fid.c
fs/9p/v9fs.c
fs/9p/v9fs.h
fs/9p/vfs_dentry.c
fs/9p/vfs_dir.c
fs/9p/vfs_inode.c
fs/9p/vfs_super.c
fs/Kconfig
fs/Makefile
fs/adfs/super.c
fs/affs/bitmap.c
fs/affs/inode.c
fs/affs/super.c
fs/afs/cache.c
fs/afs/cmservice.c
fs/afs/dir.c
fs/afs/file.c
fs/afs/fsclient.c
fs/afs/inode.c
fs/afs/mntpt.c
fs/afs/rxrpc.c
fs/afs/security.c
fs/afs/vlclient.c
fs/afs/vlocation.c
fs/afs/vnode.c
fs/anon_inodes.c
fs/autofs/root.c
fs/autofs4/dev-ioctl.c
fs/autofs4/root.c
fs/befs/datastream.c
fs/binfmt_aout.c
fs/binfmt_elf_fdpic.c
fs/binfmt_em86.c
fs/binfmt_script.c
fs/bio-integrity.c
fs/btrfs/acl.c
fs/btrfs/async-thread.c
fs/btrfs/compression.c
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/delayed-ref.c
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/extent_map.c
fs/btrfs/file-item.c
fs/btrfs/file.c
fs/btrfs/free-space-cache.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/locking.c
fs/btrfs/ordered-data.c
fs/btrfs/ref-cache.c
fs/btrfs/relocation.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/tree-log.c
fs/btrfs/volumes.c
fs/cachefiles/interface.c
fs/cachefiles/namei.c
fs/cachefiles/rdwr.c
fs/cachefiles/xattr.c
fs/ceph/Kconfig [new file with mode: 0644]
fs/ceph/Makefile [new file with mode: 0644]
fs/ceph/README [new file with mode: 0644]
fs/ceph/addr.c [new file with mode: 0644]
fs/ceph/armor.c [new file with mode: 0644]
fs/ceph/auth.c [new file with mode: 0644]
fs/ceph/auth.h [new file with mode: 0644]
fs/ceph/auth_none.c [new file with mode: 0644]
fs/ceph/auth_none.h [new file with mode: 0644]
fs/ceph/auth_x.c [new file with mode: 0644]
fs/ceph/auth_x.h [new file with mode: 0644]
fs/ceph/auth_x_protocol.h [new file with mode: 0644]
fs/ceph/buffer.c [new file with mode: 0644]
fs/ceph/buffer.h [new file with mode: 0644]
fs/ceph/caps.c [new file with mode: 0644]
fs/ceph/ceph_debug.h [new file with mode: 0644]
fs/ceph/ceph_frag.c [new file with mode: 0644]
fs/ceph/ceph_frag.h [new file with mode: 0644]
fs/ceph/ceph_fs.c [new file with mode: 0644]
fs/ceph/ceph_fs.h [new file with mode: 0644]
fs/ceph/ceph_hash.c [new file with mode: 0644]
fs/ceph/ceph_hash.h [new file with mode: 0644]
fs/ceph/ceph_strings.c [new file with mode: 0644]
fs/ceph/crush/crush.c [new file with mode: 0644]
fs/ceph/crush/crush.h [new file with mode: 0644]
fs/ceph/crush/hash.c [new file with mode: 0644]
fs/ceph/crush/hash.h [new file with mode: 0644]
fs/ceph/crush/mapper.c [new file with mode: 0644]
fs/ceph/crush/mapper.h [new file with mode: 0644]
fs/ceph/crypto.c [new file with mode: 0644]
fs/ceph/crypto.h [new file with mode: 0644]
fs/ceph/debugfs.c [new file with mode: 0644]
fs/ceph/decode.h [new file with mode: 0644]
fs/ceph/dir.c [new file with mode: 0644]
fs/ceph/export.c [new file with mode: 0644]
fs/ceph/file.c [new file with mode: 0644]
fs/ceph/inode.c [new file with mode: 0644]
fs/ceph/ioctl.c [new file with mode: 0644]
fs/ceph/ioctl.h [new file with mode: 0644]
fs/ceph/mds_client.c [new file with mode: 0644]
fs/ceph/mds_client.h [new file with mode: 0644]
fs/ceph/mdsmap.c [new file with mode: 0644]
fs/ceph/mdsmap.h [new file with mode: 0644]
fs/ceph/messenger.c [new file with mode: 0644]
fs/ceph/messenger.h [new file with mode: 0644]
fs/ceph/mon_client.c [new file with mode: 0644]
fs/ceph/mon_client.h [new file with mode: 0644]
fs/ceph/msgpool.c [new file with mode: 0644]
fs/ceph/msgpool.h [new file with mode: 0644]
fs/ceph/msgr.h [new file with mode: 0644]
fs/ceph/osd_client.c [new file with mode: 0644]
fs/ceph/osd_client.h [new file with mode: 0644]
fs/ceph/osdmap.c [new file with mode: 0644]
fs/ceph/osdmap.h [new file with mode: 0644]
fs/ceph/pagelist.c [new file with mode: 0644]
fs/ceph/pagelist.h [new file with mode: 0644]
fs/ceph/rados.h [new file with mode: 0644]
fs/ceph/snap.c [new file with mode: 0644]
fs/ceph/super.c [new file with mode: 0644]
fs/ceph/super.h [new file with mode: 0644]
fs/ceph/types.h [new file with mode: 0644]
fs/ceph/xattr.c [new file with mode: 0644]
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifs_spnego.c
fs/cifs/cifs_unicode.c
fs/cifs/cifsacl.c
fs/cifs/cifsencrypt.c
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/dir.c
fs/cifs/dns_resolve.c
fs/cifs/file.c
fs/cifs/inode.c
fs/cifs/link.c
fs/cifs/readdir.c
fs/cifs/sess.c
fs/cifs/smbencrypt.c
fs/cifs/transport.c
fs/cifs/xattr.c
fs/coda/dir.c
fs/coda/file.c
fs/coda/inode.c
fs/coda/upcall.c
fs/compat.c
fs/compat_ioctl.c
fs/configfs/inode.c
fs/configfs/mount.c
fs/configfs/symlink.c
fs/debugfs/inode.c
fs/devpts/inode.c
fs/dlm/config.c
fs/dlm/debug_fs.c
fs/dlm/lock.c
fs/dlm/lowcomms.c
fs/dlm/netlink.c
fs/dlm/plock.c
fs/dlm/user.c
fs/ecryptfs/crypto.c
fs/ecryptfs/dentry.c
fs/ecryptfs/file.c
fs/ecryptfs/inode.c
fs/ecryptfs/keystore.c
fs/ecryptfs/kthread.c
fs/ecryptfs/main.c
fs/ecryptfs/messaging.c
fs/ecryptfs/miscdev.c
fs/ecryptfs/mmap.c
fs/ecryptfs/super.c
fs/eventfd.c
fs/exofs/inode.c
fs/exofs/ios.c
fs/exofs/super.c
fs/ext2/balloc.c
fs/ext2/xattr_security.c
fs/ext3/balloc.c
fs/ext3/ialloc.c
fs/ext3/inode.c
fs/ext3/xattr_security.c
fs/ext4/block_validity.c
fs/ext4/ialloc.c
fs/ext4/inode.c
fs/ext4/mballoc.c
fs/ext4/migrate.c
fs/ext4/move_extent.c
fs/ext4/super.c
fs/ext4/xattr_security.c
fs/fat/cache.c
fs/fat/namei_vfat.c
fs/fifo.c
fs/filesystems.c
fs/freevxfs/vxfs_subr.c
fs/fs-writeback.c
fs/fscache/object-list.c
fs/fscache/object.c
fs/fscache/operation.c
fs/fscache/page.c
fs/fuse/cuse.c
fs/generic_acl.c
fs/gfs2/bmap.c
fs/gfs2/dentry.c
fs/gfs2/export.c
fs/gfs2/glops.c
fs/gfs2/lock_dlm.c
fs/gfs2/rgrp.h
fs/gfs2/sys.c
fs/gfs2/util.c
fs/hfs/bnode.c
fs/hfs/btree.c
fs/hfs/mdb.c
fs/hfs/super.c
fs/hfsplus/options.c
fs/hostfs/hostfs_kern.c
fs/hpfs/buffer.c
fs/hpfs/dir.c
fs/hpfs/inode.c
fs/hpfs/super.c
fs/ioprio.c
fs/isofs/dir.c
fs/isofs/namei.c
fs/jbd/commit.c
fs/jbd/recovery.c
fs/jbd2/recovery.c
fs/jffs2/compr_lzo.c
fs/jffs2/compr_zlib.c
fs/jffs2/debug.c
fs/jffs2/file.c
fs/jffs2/nodelist.c
fs/jffs2/nodemgmt.c
fs/jffs2/symlink.c
fs/jffs2/write.c
fs/jfs/acl.c
fs/jfs/jfs_dmap.c
fs/jfs/jfs_dtree.c
fs/jfs/jfs_imap.c
fs/jfs/jfs_logmgr.c
fs/jfs/jfs_metapage.c
fs/jfs/jfs_unicode.h
fs/jfs/super.c
fs/jfs/xattr.c
fs/libfs.c
fs/lockd/clntlock.c
fs/lockd/clntproc.c
fs/lockd/mon.c
fs/lockd/svc.c
fs/lockd/svc4proc.c
fs/lockd/svclock.c
fs/lockd/svcproc.c
fs/lockd/svcsubs.c
fs/logfs/dev_bdev.c
fs/logfs/dir.c
fs/logfs/gc.c
fs/logfs/inode.c
fs/logfs/journal.c
fs/logfs/logfs.h
fs/logfs/readwrite.c
fs/logfs/segment.c
fs/logfs/super.c
fs/minix/itree_v1.c
fs/mpage.c
fs/namei.c
fs/ncpfs/dir.c
fs/ncpfs/file.c
fs/ncpfs/ioctl.c
fs/ncpfs/mmap.c
fs/ncpfs/sock.c
fs/ncpfs/symlink.c
fs/nfs/cache_lib.c
fs/nfs/callback_proc.c
fs/nfs/callback_xdr.c
fs/nfs/client.c
fs/nfs/delegation.c
fs/nfs/direct.c
fs/nfs/dns_resolve.c
fs/nfs/file.c
fs/nfs/fscache.c
fs/nfs/inode.c
fs/nfs/namespace.c
fs/nfs/nfs2xdr.c
fs/nfs/nfs3acl.c
fs/nfs/nfs3proc.c
fs/nfs/nfs3xdr.c
fs/nfs/nfs4namespace.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4xdr.c
fs/nfs/proc.c
fs/nfs/super.c
fs/nfs/symlink.c
fs/nfs_common/nfsacl.c
fs/nfsd/export.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs4acl.c
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4idmap.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4recover.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfscache.c
fs/nfsd/nfsctl.c
fs/nfsd/vfs.c
fs/nilfs2/alloc.c
fs/nilfs2/btnode.c
fs/nilfs2/gcinode.c
fs/nilfs2/inode.c
fs/nilfs2/ioctl.c
fs/nilfs2/mdt.c
fs/nilfs2/page.c
fs/nilfs2/recovery.c
fs/nilfs2/segbuf.c
fs/nilfs2/segment.c
fs/nilfs2/the_nilfs.h
fs/notify/fsnotify.c
fs/notify/inode_mark.c
fs/ntfs/aops.c
fs/ntfs/attrib.c
fs/ntfs/compress.c
fs/ntfs/dir.c
fs/ntfs/file.c
fs/ntfs/index.c
fs/ntfs/mft.c
fs/ntfs/namei.c
fs/ocfs2/acl.c
fs/ocfs2/buffer_head_io.c
fs/ocfs2/cluster/heartbeat.c
fs/ocfs2/cluster/nodemanager.c
fs/ocfs2/cluster/quorum.c
fs/ocfs2/dlm/dlmast.c
fs/ocfs2/dlm/dlmconvert.c
fs/ocfs2/dlm/dlmmaster.c
fs/ocfs2/dlm/dlmthread.c
fs/ocfs2/dlm/dlmunlock.c
fs/ocfs2/extent_map.c
fs/ocfs2/heartbeat.c
fs/ocfs2/inode.c
fs/ocfs2/localalloc.c
fs/ocfs2/locks.c
fs/ocfs2/mmap.c
fs/ocfs2/namei.c
fs/ocfs2/ocfs2.h
fs/ocfs2/quota_global.c
fs/ocfs2/quota_local.c
fs/ocfs2/refcounttree.c
fs/ocfs2/stack_o2cb.c
fs/ocfs2/stack_user.c
fs/ocfs2/suballoc.c
fs/ocfs2/suballoc.h
fs/ocfs2/sysfile.c
fs/ocfs2/xattr.c
fs/omfs/inode.c
fs/open.c
fs/partitions/check.c
fs/partitions/efi.c
fs/partitions/msdos.c
fs/proc/array.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/kcore.c
fs/proc/nommu.c
fs/proc/proc_devtree.c
fs/proc/proc_net.c
fs/proc/stat.c
fs/proc/task_mmu.c
fs/proc/task_nommu.c
fs/proc/vmcore.c
fs/quota/netlink.c
fs/ramfs/file-nommu.c
fs/ramfs/inode.c
fs/read_write.c
fs/reiserfs/dir.c
fs/reiserfs/fix_node.c
fs/reiserfs/inode.c
fs/reiserfs/journal.c
fs/reiserfs/namei.c
fs/reiserfs/super.c
fs/reiserfs/xattr.c
fs/reiserfs/xattr_acl.c
fs/reiserfs/xattr_security.c
fs/signalfd.c
fs/smbfs/file.c
fs/smbfs/smbiod.c
fs/smbfs/symlink.c
fs/splice.c
fs/squashfs/symlink.c
fs/squashfs/zlib_wrapper.c
fs/sync.c
fs/sysfs/inode.c
fs/sysfs/mount.c
fs/sysfs/symlink.c
fs/timerfd.c
fs/ubifs/commit.c
fs/ubifs/debug.c
fs/ubifs/file.c
fs/ubifs/gc.c
fs/ubifs/io.c
fs/ubifs/lpt.c
fs/ubifs/lpt_commit.c
fs/ubifs/recovery.c
fs/ubifs/sb.c
fs/ubifs/tnc.c
fs/ubifs/ubifs.h
fs/ubifs/xattr.c
fs/udf/partition.c
fs/udf/symlink.c
fs/udf/unicode.c
fs/xattr_acl.c
fs/xfs/linux-2.6/kmem.c
fs/xfs/linux-2.6/xfs_acl.c
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_super.c
include/acpi/acpi_drivers.h
include/drm/drmP.h
include/drm/drm_mem_util.h [new file with mode: 0644]
include/drm/drm_pciids.h
include/drm/ttm/ttm_bo_driver.h
include/linux/amba/bus.h
include/linux/amba/pl061.h
include/linux/circ_buf.h
include/linux/clockchips.h
include/linux/delayacct.h
include/linux/ext3_fs.h
include/linux/ext3_fs_i.h
include/linux/freezer.h
include/linux/fscache-cache.h
include/linux/fsnotify.h
include/linux/gameport.h
include/linux/hid.h
include/linux/if_tunnel.h
include/linux/io-mapping.h
include/linux/ioport.h
include/linux/jbd.h
include/linux/jbd2.h
include/linux/kfifo.h
include/linux/libata.h
include/linux/mmc/mmc.h
include/linux/module.h
include/linux/netdevice.h
include/linux/netfilter/nfnetlink.h
include/linux/netfilter_ipv6.h
include/linux/netlink.h
include/linux/percpu.h
include/linux/perf_event.h
include/linux/rcupdate.h
include/linux/reiserfs_xattr.h
include/linux/security.h
include/linux/serial_sci.h
include/linux/skbuff.h
include/linux/socket.h
include/linux/spi/spi.h
include/linux/sunrpc/bc_xprt.h
include/linux/syscalls.h
include/linux/taskstats_kern.h
include/linux/tracepoint.h
include/linux/tty.h
include/linux/usb.h
include/linux/usb/gadget.h
include/linux/vt.h
include/linux/wimax/debug.h
include/net/9p/client.h
include/net/ax25.h
include/net/bluetooth/bluetooth.h
include/net/fib_rules.h
include/net/ipx.h
include/net/iucv/iucv.h
include/net/netfilter/nf_conntrack_extend.h
include/net/netlabel.h
include/net/netlink.h
include/net/netrom.h
include/net/sock.h
include/net/x25.h
include/net/xfrm.h
include/pcmcia/ss.h
include/scsi/libsas.h
include/xen/xenbus.h
init/do_mounts.c
init/do_mounts_rd.c
init/main.c
ipc/compat.c
ipc/mqueue.c
ipc/msg.c
ipc/syscall.c
kernel/async.c
kernel/audit.c
kernel/audit_tree.c
kernel/audit_watch.c
kernel/auditfilter.c
kernel/auditsc.c
kernel/cgroup.c
kernel/cgroup_freezer.c
kernel/compat.c
kernel/cpu.c
kernel/cpuset.c
kernel/cred.c
kernel/early_res.c
kernel/irq/chip.c
kernel/irq/manage.c
kernel/irq/numa_migrate.c
kernel/irq/proc.c
kernel/kallsyms.c
kernel/kgdb.c
kernel/kthread.c
kernel/latencytop.c
kernel/lockdep.c
kernel/module.c
kernel/nsproxy.c
kernel/padata.c
kernel/perf_event.c
kernel/pid_namespace.c
kernel/posix-cpu-timers.c
kernel/power/hibernate.c
kernel/power/hibernate_nvs.c
kernel/power/process.c
kernel/power/snapshot.c
kernel/power/suspend.c
kernel/power/swap.c
kernel/rcupdate.c
kernel/res_counter.c
kernel/resource.c
kernel/sched.c
kernel/sched_cpupri.c
kernel/sched_debug.c
kernel/slow-work.c
kernel/slow-work.h
kernel/smp.c
kernel/softlockup.c
kernel/srcu.c
kernel/sys.c
kernel/sysctl_binary.c
kernel/taskstats.c
kernel/time.c
kernel/time/tick-oneshot.c
kernel/time/timecompare.c
kernel/time/timekeeping.c
kernel/time/timer_list.c
kernel/timer.c
kernel/trace/blktrace.c
kernel/trace/ftrace.c
kernel/trace/power-traces.c
kernel/trace/ring_buffer.c
kernel/trace/trace.c
kernel/trace/trace_clock.c
kernel/trace/trace_event_perf.c
kernel/trace/trace_events.c
kernel/trace/trace_events_filter.c
kernel/trace/trace_functions_graph.c
kernel/trace/trace_ksym.c
kernel/trace/trace_mmiotrace.c
kernel/trace/trace_selftest.c
kernel/trace/trace_stat.c
kernel/trace/trace_syscalls.c
kernel/trace/trace_workqueue.c
lib/Kconfig.debug
lib/cpumask.c
lib/crc32.c
lib/debugobjects.c
lib/devres.c
lib/dynamic_debug.c
lib/genalloc.c
lib/inflate.c
lib/kasprintf.c
lib/kobject_uevent.c
lib/kref.c
lib/radix-tree.c
lib/scatterlist.c
lib/swiotlb.c
lib/textsearch.c
mm/Makefile
mm/bootmem.c
mm/bounce.c
mm/failslab.c
mm/filemap.c
mm/filemap_xip.c
mm/hugetlb.c
mm/kmemleak.c
mm/ksm.c
mm/memcontrol.c
mm/memory-failure.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/mincore.c
mm/mmu_context.c
mm/mmu_notifier.c
mm/mprotect.c
mm/mremap.c
mm/nommu.c
mm/oom_kill.c
mm/page_io.c
mm/percpu.c
mm/percpu_up.c [new file with mode: 0644]
mm/quicklist.c
mm/readahead.c
mm/rmap.c
mm/sparse-vmemmap.c
mm/sparse.c
mm/swap.c
mm/swap_state.c
mm/truncate.c
mm/vmscan.c
mm/vmstat.c
net/802/garp.c
net/802/p8022.c
net/802/p8023.c
net/802/psnap.c
net/802/stp.c
net/802/tr.c
net/8021q/vlan.c
net/8021q/vlan_core.c
net/8021q/vlan_dev.c
net/9p/client.c
net/9p/protocol.c
net/9p/trans_fd.c
net/9p/trans_rdma.c
net/9p/trans_virtio.c
net/9p/util.c
net/appletalk/aarp.c
net/appletalk/ddp.c
net/atm/addr.c
net/atm/atm_sysfs.c
net/atm/br2684.c
net/atm/clip.c
net/atm/common.c
net/atm/lec.c
net/atm/mpc.c
net/atm/mpoa_caches.c
net/atm/mpoa_proc.c
net/atm/pppoatm.c
net/atm/proc.c
net/atm/raw.c
net/atm/resources.c
net/atm/signaling.c
net/ax25/af_ax25.c
net/ax25/ax25_dev.c
net/ax25/ax25_ds_subr.c
net/ax25/ax25_iface.c
net/ax25/ax25_in.c
net/ax25/ax25_ip.c
net/ax25/ax25_out.c
net/ax25/ax25_route.c
net/ax25/ax25_subr.c
net/ax25/ax25_uid.c
net/ax25/sysctl_net_ax25.c
net/bluetooth/af_bluetooth.c
net/bluetooth/bnep/core.c
net/bluetooth/bnep/netdev.c
net/bluetooth/bnep/sock.c
net/bluetooth/cmtp/sock.c
net/bluetooth/hci_sysfs.c
net/bluetooth/hidp/sock.c
net/bluetooth/l2cap.c
net/bluetooth/rfcomm/core.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c
net/bridge/br_fdb.c
net/bridge/br_forward.c
net/bridge/br_if.c
net/bridge/br_input.c
net/bridge/br_ioctl.c
net/bridge/br_netfilter.c
net/bridge/br_netlink.c
net/bridge/br_stp_bpdu.c
net/bridge/netfilter/ebt_ulog.c
net/bridge/netfilter/ebtables.c
net/can/bcm.c
net/can/raw.c
net/compat.c
net/core/datagram.c
net/core/dev.c
net/core/drop_monitor.c
net/core/dst.c
net/core/ethtool.c
net/core/fib_rules.c
net/core/filter.c
net/core/gen_estimator.c
net/core/iovec.c
net/core/link_watch.c
net/core/neighbour.c
net/core/net-sysfs.c
net/core/net-traces.c
net/core/netpoll.c
net/core/scm.c
net/core/sysctl_net_core.c
net/dcb/dcbnl.c
net/dccp/ccid.c
net/dccp/ccids/ccid2.c
net/dccp/feat.c
net/dccp/input.c
net/dccp/ipv4.c
net/dccp/ipv6.c
net/dccp/minisocks.c
net/dccp/output.c
net/dccp/probe.c
net/dccp/proto.c
net/decnet/dn_dev.c
net/decnet/dn_fib.c
net/decnet/dn_neigh.c
net/decnet/dn_nsp_in.c
net/decnet/dn_nsp_out.c
net/decnet/dn_route.c
net/decnet/dn_table.c
net/decnet/netfilter/dn_rtmsg.c
net/dsa/dsa.c
net/dsa/tag_dsa.c
net/dsa/tag_edsa.c
net/dsa/tag_trailer.c
net/econet/af_econet.c
net/ethernet/pe2.c
net/ieee802154/af_ieee802154.c
net/ieee802154/dgram.c
net/ieee802154/netlink.c
net/ieee802154/nl-mac.c
net/ieee802154/nl-phy.c
net/ieee802154/raw.c
net/ieee802154/wpan-class.c
net/ipv4/af_inet.c
net/ipv4/ah4.c
net/ipv4/arp.c
net/ipv4/cipso_ipv4.c
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/fib_hash.c
net/ipv4/fib_semantics.c
net/ipv4/fib_trie.c
net/ipv4/icmp.c
net/ipv4/igmp.c
net/ipv4/inet_diag.c
net/ipv4/inet_fragment.c
net/ipv4/inet_timewait_sock.c
net/ipv4/ip_forward.c
net/ipv4/ip_fragment.c
net/ipv4/ip_gre.c
net/ipv4/ip_input.c
net/ipv4/ip_options.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/ipconfig.c
net/ipv4/ipip.c
net/ipv4/ipmr.c
net/ipv4/netfilter.c
net/ipv4/netfilter/arptable_filter.c
net/ipv4/netfilter/ip_queue.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/netfilter/ipt_REJECT.c
net/ipv4/netfilter/ipt_ULOG.c
net/ipv4/netfilter/iptable_filter.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/iptable_raw.c
net/ipv4/netfilter/iptable_security.c
net/ipv4/netfilter/nf_nat_core.c
net/ipv4/netfilter/nf_nat_helper.c
net/ipv4/netfilter/nf_nat_rule.c
net/ipv4/netfilter/nf_nat_snmp_basic.c
net/ipv4/netfilter/nf_nat_standalone.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_cong.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/tcp_probe.c
net/ipv4/tcp_timer.c
net/ipv4/tunnel4.c
net/ipv4/udp.c
net/ipv4/xfrm4_input.c
net/ipv4/xfrm4_mode_tunnel.c
net/ipv6/addrconf.c
net/ipv6/addrlabel.c
net/ipv6/af_inet6.c
net/ipv6/ah6.c
net/ipv6/anycast.c
net/ipv6/datagram.c
net/ipv6/exthdrs.c
net/ipv6/icmp.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ip6_fib.c
net/ipv6/ip6_flowlabel.c
net/ipv6/ip6_input.c
net/ipv6/ip6_output.c
net/ipv6/ip6_tunnel.c
net/ipv6/ip6mr.c
net/ipv6/ipv6_sockglue.c
net/ipv6/mcast.c
net/ipv6/ndisc.c
net/ipv6/netfilter/ip6_queue.c
net/ipv6/netfilter/ip6t_REJECT.c
net/ipv6/netfilter/ip6table_filter.c
net/ipv6/netfilter/ip6table_mangle.c
net/ipv6/netfilter/ip6table_raw.c
net/ipv6/netfilter/ip6table_security.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/raw.c
net/ipv6/reassembly.c
net/ipv6/route.c
net/ipv6/sit.c
net/ipv6/sysctl_net_ipv6.c
net/ipv6/tcp_ipv6.c
net/ipv6/tunnel6.c
net/ipv6/udp.c
net/ipv6/xfrm6_mode_tunnel.c
net/ipv6/xfrm6_tunnel.c
net/ipx/af_ipx.c
net/ipx/ipx_route.c
net/irda/af_irda.c
net/irda/discovery.c
net/irda/ircomm/ircomm_core.c
net/irda/ircomm/ircomm_lmp.c
net/irda/ircomm/ircomm_param.c
net/irda/ircomm/ircomm_tty.c
net/irda/irda_device.c
net/irda/iriap.c
net/irda/iriap_event.c
net/irda/irias_object.c
net/irda/irlan/irlan_client.c
net/irda/irlan/irlan_common.c
net/irda/irlan/irlan_provider.c
net/irda/irlap_event.c
net/irda/irlap_frame.c
net/irda/irnet/irnet_irda.c
net/irda/irnet/irnet_ppp.c
net/irda/irnetlink.c
net/irda/irqueue.c
net/irda/irttp.c
net/key/af_key.c
net/lapb/lapb_iface.c
net/lapb/lapb_in.c
net/lapb/lapb_out.c
net/lapb/lapb_subr.c
net/llc/af_llc.c
net/llc/llc_c_ac.c
net/llc/llc_conn.c
net/llc/llc_if.c
net/llc/llc_input.c
net/llc/llc_sap.c
net/llc/llc_station.c
net/mac80211/agg-rx.c
net/mac80211/agg-tx.c
net/mac80211/cfg.c
net/mac80211/debugfs_key.c
net/mac80211/debugfs_netdev.c
net/mac80211/ibss.c
net/mac80211/iface.c
net/mac80211/key.c
net/mac80211/led.c
net/mac80211/mesh.c
net/mac80211/mesh_hwmp.c
net/mac80211/mesh_pathtbl.c
net/mac80211/mesh_plink.c
net/mac80211/mlme.c
net/mac80211/rate.c
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel_debugfs.c
net/mac80211/rc80211_pid_algo.c
net/mac80211/rc80211_pid_debugfs.c
net/mac80211/rx.c
net/mac80211/scan.c
net/mac80211/tx.c
net/mac80211/util.c
net/mac80211/wep.c
net/mac80211/work.c
net/mac80211/wpa.c
net/netfilter/core.c
net/netfilter/ipvs/ip_vs_app.c
net/netfilter/ipvs/ip_vs_conn.c
net/netfilter/ipvs/ip_vs_core.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_dh.c
net/netfilter/ipvs/ip_vs_est.c
net/netfilter/ipvs/ip_vs_ftp.c
net/netfilter/ipvs/ip_vs_lblc.c
net/netfilter/ipvs/ip_vs_lblcr.c
net/netfilter/ipvs/ip_vs_proto.c
net/netfilter/ipvs/ip_vs_sh.c
net/netfilter/ipvs/ip_vs_wrr.c
net/netfilter/ipvs/ip_vs_xmit.c
net/netfilter/nf_conntrack_acct.c
net/netfilter/nf_conntrack_amanda.c
net/netfilter/nf_conntrack_ecache.c
net/netfilter/nf_conntrack_ftp.c
net/netfilter/nf_conntrack_h323_main.c
net/netfilter/nf_conntrack_helper.c
net/netfilter/nf_conntrack_irc.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_proto.c
net/netfilter/nf_conntrack_proto_dccp.c
net/netfilter/nf_conntrack_proto_gre.c
net/netfilter/nf_conntrack_sane.c
net/netfilter/nf_conntrack_standalone.c
net/netfilter/nf_queue.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue.c
net/netfilter/x_tables.c
net/netfilter/xt_CT.c
net/netfilter/xt_LED.c
net/netfilter/xt_RATEEST.c
net/netfilter/xt_TCPMSS.c
net/netfilter/xt_connlimit.c
net/netfilter/xt_dccp.c
net/netfilter/xt_hashlimit.c
net/netfilter/xt_limit.c
net/netfilter/xt_quota.c
net/netfilter/xt_recent.c
net/netfilter/xt_statistic.c
net/netfilter/xt_string.c
net/netlabel/netlabel_cipso_v4.c
net/netlabel/netlabel_domainhash.c
net/netlabel/netlabel_kapi.c
net/netlabel/netlabel_mgmt.c
net/netlabel/netlabel_unlabeled.c
net/netlabel/netlabel_user.c
net/netlink/af_netlink.c
net/netlink/genetlink.c
net/netrom/af_netrom.c
net/netrom/nr_dev.c
net/netrom/nr_in.c
net/netrom/nr_loopback.c
net/netrom/nr_out.c
net/netrom/nr_route.c
net/netrom/nr_subr.c
net/packet/af_packet.c
net/phonet/af_phonet.c
net/phonet/datagram.c
net/phonet/pep.c
net/phonet/pn_dev.c
net/phonet/pn_netlink.c
net/phonet/socket.c
net/rds/af_rds.c
net/rds/cong.c
net/rds/connection.c
net/rds/ib.c
net/rds/ib_cm.c
net/rds/ib_rdma.c
net/rds/ib_recv.c
net/rds/info.c
net/rds/iw.c
net/rds/iw_cm.c
net/rds/iw_rdma.c
net/rds/iw_recv.c
net/rds/loop.c
net/rds/message.c
net/rds/page.c
net/rds/rdma.c
net/rds/recv.c
net/rds/send.c
net/rds/tcp.c
net/rds/tcp_listen.c
net/rds/tcp_recv.c
net/rfkill/core.c
net/rose/af_rose.c
net/rose/rose_dev.c
net/rose/rose_link.c
net/rose/rose_loopback.c
net/rose/rose_out.c
net/rose/rose_route.c
net/rose/rose_subr.c
net/rxrpc/af_rxrpc.c
net/rxrpc/ar-accept.c
net/rxrpc/ar-ack.c
net/rxrpc/ar-call.c
net/rxrpc/ar-connection.c
net/rxrpc/ar-input.c
net/rxrpc/ar-key.c
net/rxrpc/ar-local.c
net/rxrpc/ar-output.c
net/rxrpc/ar-peer.c
net/rxrpc/ar-transport.c
net/rxrpc/rxkad.c
net/sched/Kconfig
net/sched/act_api.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/cls_api.c
net/sched/cls_basic.c
net/sched/cls_cgroup.c
net/sched/cls_flow.c
net/sched/cls_fw.c
net/sched/cls_route.c
net/sched/cls_tcindex.c
net/sched/cls_u32.c
net/sched/em_meta.c
net/sched/em_nbyte.c
net/sched/em_text.c
net/sched/ematch.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_drr.c
net/sched/sch_dsmark.c
net/sched/sch_fifo.c
net/sched/sch_generic.c
net/sched/sch_gred.c
net/sched/sch_htb.c
net/sched/sch_mq.c
net/sched/sch_multiq.c
net/sched/sch_netem.c
net/sched/sch_prio.c
net/sched/sch_sfq.c
net/sched/sch_teql.c
net/sctp/auth.c
net/sctp/bind_addr.c
net/sctp/chunk.c
net/sctp/input.c
net/sctp/inqueue.c
net/sctp/ipv6.c
net/sctp/output.c
net/sctp/outqueue.c
net/sctp/primitive.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/sm_sideeffect.c
net/sctp/sm_statefuns.c
net/sctp/socket.c
net/sctp/ssnmap.c
net/sctp/transport.c
net/sctp/tsnmap.c
net/sctp/ulpevent.c
net/sctp/ulpqueue.c
net/socket.c
net/sunrpc/addr.c
net/sunrpc/auth_generic.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/gss_generic_token.c
net/sunrpc/auth_gss/gss_krb5_crypto.c
net/sunrpc/auth_gss/gss_krb5_seal.c
net/sunrpc/auth_gss/gss_krb5_seqnum.c
net/sunrpc/auth_gss/gss_krb5_unseal.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/auth_gss/gss_spkm3_seal.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/auth_unix.c
net/sunrpc/backchannel_rqst.c
net/sunrpc/bc_svc.c
net/sunrpc/clnt.c
net/sunrpc/rpc_pipe.c
net/sunrpc/rpcb_clnt.c
net/sunrpc/socklib.c
net/sunrpc/stats.c
net/sunrpc/svc.c
net/sunrpc/svc_xprt.c
net/sunrpc/svcauth_unix.c
net/sunrpc/xdr.c
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/svc_rdma.c
net/sunrpc/xprtrdma/svc_rdma_transport.c
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtsock.c
net/tipc/core.h
net/tipc/eth_media.c
net/tipc/socket.c
net/unix/garbage.c
net/unix/sysctl_net_unix.c
net/wimax/op-msg.c
net/wimax/stack.c
net/wireless/core.c
net/wireless/debugfs.c
net/wireless/ibss.c
net/wireless/mlme.c
net/wireless/nl80211.c
net/wireless/reg.c
net/wireless/scan.c
net/wireless/sme.c
net/wireless/util.c
net/wireless/wext-compat.c
net/wireless/wext-core.c
net/wireless/wext-priv.c
net/wireless/wext-sme.c
net/x25/af_x25.c
net/x25/x25_dev.c
net/x25/x25_forward.c
net/x25/x25_in.c
net/x25/x25_link.c
net/x25/x25_out.c
net/x25/x25_route.c
net/x25/x25_subr.c
net/xfrm/xfrm_ipcomp.c
net/xfrm/xfrm_output.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_sysctl.c
samples/kobject/kset-example.c
scripts/get_maintainer.pl
scripts/kernel-doc
security/device_cgroup.c
security/integrity/ima/ima_api.c
security/integrity/ima/ima_audit.c
security/integrity/ima/ima_crypto.c
security/integrity/ima/ima_fs.c
security/integrity/ima/ima_iint.c
security/integrity/ima/ima_init.c
security/integrity/ima/ima_main.c
security/integrity/ima/ima_policy.c
security/integrity/ima/ima_queue.c
security/keys/proc.c
security/keys/process_keys.c
security/lsm_audit.c
security/selinux/netif.c
security/selinux/netlabel.c
security/selinux/netlink.c
security/selinux/netnode.c
security/selinux/netport.c
security/selinux/ss/symtab.c
security/selinux/xfrm.c
security/smack/smack_access.c
security/smack/smack_lsm.c
security/smack/smackfs.c
security/tomoyo/common.c
security/tomoyo/domain.c
security/tomoyo/file.c
security/tomoyo/gc.c
security/tomoyo/realpath.c
sound/aoa/codecs/onyx.c
sound/aoa/codecs/tas.c
sound/aoa/codecs/toonie.c
sound/aoa/core/gpio-pmf.c
sound/aoa/fabrics/layout.c
sound/aoa/soundbus/i2sbus/control.c
sound/aoa/soundbus/i2sbus/core.c
sound/aoa/soundbus/i2sbus/pcm.c
sound/arm/pxa2xx-pcm-lib.c
sound/core/control_compat.c
sound/core/hrtimer.c
sound/core/info.c
sound/core/jack.c
sound/core/misc.c
sound/core/oss/route.c
sound/core/pcm_compat.c
sound/core/pcm_lib.c
sound/core/pcm_memory.c
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/oss/seq_oss_midi.c
sound/core/seq/oss/seq_oss_readq.c
sound/core/seq/oss/seq_oss_synth.c
sound/core/seq/oss/seq_oss_timer.c
sound/core/seq/oss/seq_oss_writeq.c
sound/core/seq/seq_compat.c
sound/core/seq/seq_system.c
sound/drivers/ml403-ac97cr.c
sound/drivers/mtpav.c
sound/drivers/mts64.c
sound/drivers/opl3/opl3_oss.c
sound/drivers/opl3/opl3_synth.c
sound/drivers/opl4/opl4_lib.c
sound/drivers/pcsp/pcsp_lib.c
sound/drivers/portman2x4.c
sound/drivers/vx/vx_hwdep.c
sound/i2c/other/tea575x-tuner.c
sound/isa/cmi8330.c
sound/isa/cs423x/cs4236.c
sound/isa/es18xx.c
sound/isa/gus/interwave.c
sound/isa/msnd/msnd_midi.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/emu8000_pcm.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/wavefront/wavefront.c
sound/isa/wavefront/wavefront_fx.c
sound/isa/wavefront/wavefront_synth.c
sound/mips/hal2.c
sound/mips/sgio2audio.c
sound/oss/ad1848.c
sound/oss/dmabuf.c
sound/oss/kahlua.c
sound/oss/mpu401.c
sound/oss/msnd.c
sound/oss/msnd_pinnacle.c
sound/oss/opl3.c
sound/oss/sb_card.c
sound/oss/sb_common.c
sound/oss/sb_midi.c
sound/oss/sb_mixer.c
sound/oss/soundcard.c
sound/oss/uart401.c
sound/oss/v_midi.c
sound/oss/vidc.c
sound/oss/vwsnd.c
sound/oss/waveartist.c
sound/pci/ac97/ac97_patch.c
sound/pci/ac97/ac97_proc.c
sound/pci/als4000.c
sound/pci/aw2/aw2-saa7146.c
sound/pci/ca0106/ca0106_mixer.c
sound/pci/ca0106/ca0106_proc.c
sound/pci/cmipci.c
sound/pci/cs5530.c
sound/pci/cs5535audio/cs5535audio_pcm.c
sound/pci/cs5535audio/cs5535audio_pm.c
sound/pci/ctxfi/ctatc.c
sound/pci/ctxfi/ctpcm.c
sound/pci/echoaudio/darla20.c
sound/pci/echoaudio/darla24.c
sound/pci/echoaudio/echo3g.c
sound/pci/echoaudio/gina20.c
sound/pci/echoaudio/gina24.c
sound/pci/echoaudio/indigo.c
sound/pci/echoaudio/indigodj.c
sound/pci/echoaudio/indigodjx.c
sound/pci/echoaudio/indigoio.c
sound/pci/echoaudio/indigoiox.c
sound/pci/echoaudio/layla20.c
sound/pci/echoaudio/layla24.c
sound/pci/echoaudio/mia.c
sound/pci/echoaudio/mona.c
sound/pci/emu10k1/memory.c
sound/pci/hda/hda_beep.c
sound/pci/hda/hda_eld.c
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_nvhdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/ice1712/ak4xxx.c
sound/pci/ice1712/amp.c
sound/pci/ice1712/vt1720_mobo.c
sound/pci/ice1712/wtm.c
sound/pci/lx6464es/lx6464es.c
sound/pci/mixart/mixart.c
sound/pci/mixart/mixart_hwdep.c
sound/pci/oxygen/oxygen_lib.c
sound/pci/rme32.c
sound/pci/rme96.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/rme9652.c
sound/pci/sis7019.c
sound/pcmcia/pdaudiocf/pdaudiocf_core.c
sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
sound/pcmcia/vx/vxpocket.c
sound/ppc/burgundy.c
sound/ppc/keywest.c
sound/ppc/snd_ps3.c
sound/sh/sh_dac_audio.c
sound/soc/au1x/psc-ac97.c
sound/soc/au1x/psc-i2s.c
sound/soc/blackfin/bf5xx-ac97-pcm.c
sound/soc/blackfin/bf5xx-ac97.c
sound/soc/blackfin/bf5xx-i2s-pcm.c
sound/soc/blackfin/bf5xx-tdm-pcm.c
sound/soc/codecs/ac97.c
sound/soc/codecs/ad1836.c
sound/soc/codecs/ad1938.c
sound/soc/codecs/ad1980.c
sound/soc/codecs/ad73311.c
sound/soc/codecs/ads117x.c
sound/soc/codecs/ak4104.c
sound/soc/codecs/ak4535.c
sound/soc/codecs/ak4642.c
sound/soc/codecs/ak4671.c
sound/soc/codecs/cs4270.c
sound/soc/codecs/cx20442.c
sound/soc/codecs/da7210.c
sound/soc/codecs/pcm3008.c
sound/soc/codecs/ssm2602.c
sound/soc/codecs/stac9766.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/tlv320aic26.c
sound/soc/codecs/tlv320aic3x.c
sound/soc/codecs/tlv320dac33.c
sound/soc/codecs/tpa6130a2.c
sound/soc/codecs/twl4030.c
sound/soc/codecs/uda134x.c
sound/soc/codecs/wm2000.c
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8400.c
sound/soc/codecs/wm8510.c
sound/soc/codecs/wm8523.c
sound/soc/codecs/wm8580.c
sound/soc/codecs/wm8711.c
sound/soc/codecs/wm8727.c
sound/soc/codecs/wm8728.c
sound/soc/codecs/wm8731.c
sound/soc/codecs/wm8750.c
sound/soc/codecs/wm8753.c
sound/soc/codecs/wm8776.c
sound/soc/codecs/wm8900.c
sound/soc/codecs/wm8903.c
sound/soc/codecs/wm8904.c
sound/soc/codecs/wm8940.c
sound/soc/codecs/wm8955.c
sound/soc/codecs/wm8960.c
sound/soc/codecs/wm8961.c
sound/soc/codecs/wm8971.c
sound/soc/codecs/wm8974.c
sound/soc/codecs/wm8978.c
sound/soc/codecs/wm8988.c
sound/soc/codecs/wm8990.c
sound/soc/codecs/wm8993.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm9081.c
sound/soc/codecs/wm9705.c
sound/soc/codecs/wm9712.c
sound/soc/codecs/wm9713.c
sound/soc/codecs/wm_hubs.c
sound/soc/davinci/davinci-i2s.c
sound/soc/davinci/davinci-mcasp.c
sound/soc/fsl/fsl_dma.c
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/mpc5200_dma.c
sound/soc/fsl/mpc8610_hpcd.c
sound/soc/fsl/soc-of-simple.c
sound/soc/imx/Kconfig
sound/soc/imx/imx-pcm-dma-mx2.c
sound/soc/imx/imx-pcm-fiq.c
sound/soc/imx/imx-ssi.c
sound/soc/omap/mcpdm.c
sound/soc/omap/omap-pcm.c
sound/soc/pxa/pxa-ssp.c
sound/soc/s6000/s6000-i2s.c
sound/soc/sh/Kconfig
sound/soc/sh/dma-sh7760.c
sound/soc/sh/fsi.c
sound/soc/sh/siu_dai.c
sound/soc/sh/siu_pcm.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/txx9/txx9aclc-ac97.c
sound/soc/txx9/txx9aclc.c
sound/sound_firmware.c
sound/sparc/cs4231.c
sound/sparc/dbri.c
sound/synth/emux/emux_proc.c
sound/usb/caiaq/audio.c
sound/usb/caiaq/device.c
sound/usb/caiaq/midi.c
sound/usb/usx2y/us122l.c
sound/usb/usx2y/usX2Yhwdep.c
sound/usb/usx2y/usb_stream.c
sound/usb/usx2y/usbusx2y.c
sound/usb/usx2y/usbusx2yaudio.c
sound/usb/usx2y/usx2yhwdeppcm.c
tools/perf/Makefile
tools/perf/builtin-kmem.c
tools/perf/builtin-probe.c
tools/perf/builtin-top.c
tools/perf/util/probe-event.c
tools/perf/util/probe-finder.c
tools/perf/util/probe-finder.h
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/symbol.c
tools/perf/util/symbol.h
virt/kvm/assigned-dev.c
virt/kvm/coalesced_mmio.c
virt/kvm/eventfd.c
virt/kvm/ioapic.c
virt/kvm/irq_comm.c
virt/kvm/kvm_main.c

index a986e9bbba3d2972770f9e2a8196bea6eb119a0f..bcebb9eaedce04da1d4040450bc38878b208428b 100644 (file)
@@ -160,7 +160,7 @@ Description:
                match the driver to the device.  For example:
                # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id
 
-What:          /sys/bus/usb/device/.../avoid_reset
+What:          /sys/bus/usb/device/.../avoid_reset_quirk
 Date:          December 2009
 Contact:       Oliver Neukum <oliver@neukum.org>
 Description:
diff --git a/Documentation/DMA-API-HOWTO.txt b/Documentation/DMA-API-HOWTO.txt
new file mode 100644 (file)
index 0000000..52618ab
--- /dev/null
@@ -0,0 +1,758 @@
+                    Dynamic DMA mapping Guide
+                    =========================
+
+                David S. Miller <davem@redhat.com>
+                Richard Henderson <rth@cygnus.com>
+                 Jakub Jelinek <jakub@redhat.com>
+
+This is a guide to device driver writers on how to use the DMA API
+with example pseudo-code.  For a concise description of the API, see
+DMA-API.txt.
+
+Most of the 64bit platforms have special hardware that translates bus
+addresses (DMA addresses) into physical addresses.  This is similar to
+how page tables and/or a TLB translates virtual addresses to physical
+addresses on a CPU.  This is needed so that e.g. PCI devices can
+access with a Single Address Cycle (32bit DMA address) any page in the
+64bit physical address space.  Previously in Linux those 64bit
+platforms had to set artificial limits on the maximum RAM size in the
+system, so that the virt_to_bus() static scheme works (the DMA address
+translation tables were simply filled on bootup to map each bus
+address to the physical page __pa(bus_to_virt())).
+
+So that Linux can use the dynamic DMA mapping, it needs some help from the
+drivers, namely it has to take into account that DMA addresses should be
+mapped only for the time they are actually used and unmapped after the DMA
+transfer.
+
+The following API will work of course even on platforms where no such
+hardware exists.
+
+Note that the DMA API works with any bus independent of the underlying
+microprocessor architecture. You should use the DMA API rather than
+the bus specific DMA API (e.g. pci_dma_*).
+
+First of all, you should make sure
+
+#include <linux/dma-mapping.h>
+
+is in your driver. This file will obtain for you the definition of the
+dma_addr_t (which can hold any valid DMA address for the platform)
+type which should be used everywhere you hold a DMA (bus) address
+returned from the DMA mapping functions.
+
+                        What memory is DMA'able?
+
+The first piece of information you must know is what kernel memory can
+be used with the DMA mapping facilities.  There has been an unwritten
+set of rules regarding this, and this text is an attempt to finally
+write them down.
+
+If you acquired your memory via the page allocator
+(i.e. __get_free_page*()) or the generic memory allocators
+(i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
+that memory using the addresses returned from those routines.
+
+This means specifically that you may _not_ use the memory/addresses
+returned from vmalloc() for DMA.  It is possible to DMA to the
+_underlying_ memory mapped into a vmalloc() area, but this requires
+walking page tables to get the physical addresses, and then
+translating each of those pages back to a kernel address using
+something like __va().  [ EDIT: Update this when we integrate
+Gerd Knorr's generic code which does this. ]
+
+This rule also means that you may use neither kernel image addresses
+(items in data/text/bss segments), nor module image addresses, nor
+stack addresses for DMA.  These could all be mapped somewhere entirely
+different than the rest of physical memory.  Even if those classes of
+memory could physically work with DMA, you'd need to ensure the I/O
+buffers were cacheline-aligned.  Without that, you'd see cacheline
+sharing problems (data corruption) on CPUs with DMA-incoherent caches.
+(The CPU could write to one word, DMA would write to a different one
+in the same cache line, and one of them could be overwritten.)
+
+Also, this means that you cannot take the return of a kmap()
+call and DMA to/from that.  This is similar to vmalloc().
+
+What about block I/O and networking buffers?  The block I/O and
+networking subsystems make sure that the buffers they use are valid
+for you to DMA from/to.
+
+                       DMA addressing limitations
+
+Does your device have any DMA addressing limitations?  For example, is
+your device only capable of driving the low order 24-bits of address?
+If so, you need to inform the kernel of this fact.
+
+By default, the kernel assumes that your device can address the full
+32-bits.  For a 64-bit capable device, this needs to be increased.
+And for a device with limitations, as discussed in the previous
+paragraph, it needs to be decreased.
+
+Special note about PCI: PCI-X specification requires PCI-X devices to
+support 64-bit addressing (DAC) for all transactions.  And at least
+one platform (SGI SN2) requires 64-bit consistent allocations to
+operate correctly when the IO bus is in PCI-X mode.
+
+For correct operation, you must interrogate the kernel in your device
+probe routine to see if the DMA controller on the machine can properly
+support the DMA addressing limitation your device has.  It is good
+style to do this even if your device holds the default setting,
+because this shows that you did think about these issues wrt. your
+device.
+
+The query is performed via a call to dma_set_mask():
+
+       int dma_set_mask(struct device *dev, u64 mask);
+
+The query for consistent allocations is performed via a call to
+dma_set_coherent_mask():
+
+       int dma_set_coherent_mask(struct device *dev, u64 mask);
+
+Here, dev is a pointer to the device struct of your device, and mask
+is a bit mask describing which bits of an address your device
+supports.  It returns zero if your card can perform DMA properly on
+the machine given the address mask you provided.  In general, the
+device struct of your device is embedded in the bus specific device
+struct of your device.  For example, a pointer to the device struct of
+your PCI device is pdev->dev (pdev is a pointer to the PCI device
+struct of your device).
+
+If it returns non-zero, your device cannot perform DMA properly on
+this platform, and attempting to do so will result in undefined
+behavior.  You must either use a different mask, or not use DMA.
+
+This means that in the failure case, you have three options:
+
+1) Use another DMA mask, if possible (see below).
+2) Use some non-DMA mode for data transfer, if possible.
+3) Ignore this device and do not initialize it.
+
+It is recommended that your driver print a kernel KERN_WARNING message
+when you end up performing either #2 or #3.  In this manner, if a user
+of your driver reports that performance is bad or that the device is not
+even detected, you can ask them for the kernel messages to find out
+exactly why.
+
+The standard 32-bit addressing device would do something like this:
+
+       if (dma_set_mask(dev, DMA_BIT_MASK(32))) {
+               printk(KERN_WARNING
+                      "mydev: No suitable DMA available.\n");
+               goto ignore_this_device;
+       }
+
+Another common scenario is a 64-bit capable device.  The approach here
+is to try for 64-bit addressing, but back down to a 32-bit mask that
+should not fail.  The kernel may fail the 64-bit mask not because the
+platform is not capable of 64-bit addressing.  Rather, it may fail in
+this case simply because 32-bit addressing is done more efficiently
+than 64-bit addressing.  For example, Sparc64 PCI SAC addressing is
+more efficient than DAC addressing.
+
+Here is how you would handle a 64-bit capable device which can drive
+all 64-bits when accessing streaming DMA:
+
+       int using_dac;
+
+       if (!dma_set_mask(dev, DMA_BIT_MASK(64))) {
+               using_dac = 1;
+       } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
+               using_dac = 0;
+       } else {
+               printk(KERN_WARNING
+                      "mydev: No suitable DMA available.\n");
+               goto ignore_this_device;
+       }
+
+If a card is capable of using 64-bit consistent allocations as well,
+the case would look like this:
+
+       int using_dac, consistent_using_dac;
+
+       if (!dma_set_mask(dev, DMA_BIT_MASK(64))) {
+               using_dac = 1;
+               consistent_using_dac = 1;
+               dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
+       } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
+               using_dac = 0;
+               consistent_using_dac = 0;
+               dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
+       } else {
+               printk(KERN_WARNING
+                      "mydev: No suitable DMA available.\n");
+               goto ignore_this_device;
+       }
+
+dma_set_coherent_mask() will always be able to set the same or a
+smaller mask as dma_set_mask(). However for the rare case that a
+device driver only uses consistent allocations, one would have to
+check the return value from dma_set_coherent_mask().
+
+Finally, if your device can only drive the low 24-bits of
+address you might do something like:
+
+       if (dma_set_mask(dev, DMA_BIT_MASK(24))) {
+               printk(KERN_WARNING
+                      "mydev: 24-bit DMA addressing not available.\n");
+               goto ignore_this_device;
+       }
+
+When dma_set_mask() is successful, and returns zero, the kernel saves
+away this mask you have provided.  The kernel will use this
+information later when you make DMA mappings.
+
+There is a case which we are aware of at this time, which is worth
+mentioning in this documentation.  If your device supports multiple
+functions (for example a sound card provides playback and record
+functions) and the various different functions have _different_
+DMA addressing limitations, you may wish to probe each mask and
+only provide the functionality which the machine can handle.  It
+is important that the last call to dma_set_mask() be for the
+most specific mask.
+
+Here is pseudo-code showing how this might be done:
+
+       #define PLAYBACK_ADDRESS_BITS   DMA_BIT_MASK(32)
+       #define RECORD_ADDRESS_BITS     DMA_BIT_MASK(24)
+
+       struct my_sound_card *card;
+       struct device *dev;
+
+       ...
+       if (!dma_set_mask(dev, PLAYBACK_ADDRESS_BITS)) {
+               card->playback_enabled = 1;
+       } else {
+               card->playback_enabled = 0;
+               printk(KERN_WARNING "%s: Playback disabled due to DMA limitations.\n",
+                      card->name);
+       }
+       if (!dma_set_mask(dev, RECORD_ADDRESS_BITS)) {
+               card->record_enabled = 1;
+       } else {
+               card->record_enabled = 0;
+               printk(KERN_WARNING "%s: Record disabled due to DMA limitations.\n",
+                      card->name);
+       }
+
+A sound card was used as an example here because this genre of PCI
+devices seems to be littered with ISA chips given a PCI front end,
+and thus retaining the 16MB DMA addressing limitations of ISA.
+
+                       Types of DMA mappings
+
+There are two types of DMA mappings:
+
+- Consistent DMA mappings which are usually mapped at driver
+  initialization, unmapped at the end and for which the hardware should
+  guarantee that the device and the CPU can access the data
+  in parallel and will see updates made by each other without any
+  explicit software flushing.
+
+  Think of "consistent" as "synchronous" or "coherent".
+
+  The current default is to return consistent memory in the low 32
+  bits of the bus space.  However, for future compatibility you should
+  set the consistent mask even if this default is fine for your
+  driver.
+
+  Good examples of what to use consistent mappings for are:
+
+       - Network card DMA ring descriptors.
+       - SCSI adapter mailbox command data structures.
+       - Device firmware microcode executed out of
+         main memory.
+
+  The invariant these examples all require is that any CPU store
+  to memory is immediately visible to the device, and vice
+  versa.  Consistent mappings guarantee this.
+
+  IMPORTANT: Consistent DMA memory does not preclude the usage of
+             proper memory barriers.  The CPU may reorder stores to
+            consistent memory just as it may normal memory.  Example:
+            if it is important for the device to see the first word
+            of a descriptor updated before the second, you must do
+            something like:
+
+               desc->word0 = address;
+               wmb();
+               desc->word1 = DESC_VALID;
+
+             in order to get correct behavior on all platforms.
+
+            Also, on some platforms your driver may need to flush CPU write
+            buffers in much the same way as it needs to flush write buffers
+            found in PCI bridges (such as by reading a register's value
+            after writing it).
+
+- Streaming DMA mappings which are usually mapped for one DMA
+  transfer, unmapped right after it (unless you use dma_sync_* below)
+  and for which hardware can optimize for sequential accesses.
+
+  This of "streaming" as "asynchronous" or "outside the coherency
+  domain".
+
+  Good examples of what to use streaming mappings for are:
+
+       - Networking buffers transmitted/received by a device.
+       - Filesystem buffers written/read by a SCSI device.
+
+  The interfaces for using this type of mapping were designed in
+  such a way that an implementation can make whatever performance
+  optimizations the hardware allows.  To this end, when using
+  such mappings you must be explicit about what you want to happen.
+
+Neither type of DMA mapping has alignment restrictions that come from
+the underlying bus, although some devices may have such restrictions.
+Also, systems with caches that aren't DMA-coherent will work better
+when the underlying buffers don't share cache lines with other data.
+
+
+                Using Consistent DMA mappings.
+
+To allocate and map large (PAGE_SIZE or so) consistent DMA regions,
+you should do:
+
+       dma_addr_t dma_handle;
+
+       cpu_addr = dma_alloc_coherent(dev, size, &dma_handle, gfp);
+
+where device is a struct device *. This may be called in interrupt
+context with the GFP_ATOMIC flag.
+
+Size is the length of the region you want to allocate, in bytes.
+
+This routine will allocate RAM for that region, so it acts similarly to
+__get_free_pages (but takes size instead of a page order).  If your
+driver needs regions sized smaller than a page, you may prefer using
+the dma_pool interface, described below.
+
+The consistent DMA mapping interfaces, for non-NULL dev, will by
+default return a DMA address which is 32-bit addressable.  Even if the
+device indicates (via DMA mask) that it may address the upper 32-bits,
+consistent allocation will only return > 32-bit addresses for DMA if
+the consistent DMA mask has been explicitly changed via
+dma_set_coherent_mask().  This is true of the dma_pool interface as
+well.
+
+dma_alloc_coherent returns two values: the virtual address which you
+can use to access it from the CPU and dma_handle which you pass to the
+card.
+
+The cpu return address and the DMA bus master address are both
+guaranteed to be aligned to the smallest PAGE_SIZE order which
+is greater than or equal to the requested size.  This invariant
+exists (for example) to guarantee that if you allocate a chunk
+which is smaller than or equal to 64 kilobytes, the extent of the
+buffer you receive will not cross a 64K boundary.
+
+To unmap and free such a DMA region, you call:
+
+       dma_free_coherent(dev, size, cpu_addr, dma_handle);
+
+where dev, size are the same as in the above call and cpu_addr and
+dma_handle are the values dma_alloc_coherent returned to you.
+This function may not be called in interrupt context.
+
+If your driver needs lots of smaller memory regions, you can write
+custom code to subdivide pages returned by dma_alloc_coherent,
+or you can use the dma_pool API to do that.  A dma_pool is like
+a kmem_cache, but it uses dma_alloc_coherent not __get_free_pages.
+Also, it understands common hardware constraints for alignment,
+like queue heads needing to be aligned on N byte boundaries.
+
+Create a dma_pool like this:
+
+       struct dma_pool *pool;
+
+       pool = dma_pool_create(name, dev, size, align, alloc);
+
+The "name" is for diagnostics (like a kmem_cache name); dev and size
+are as above.  The device's hardware alignment requirement for this
+type of data is "align" (which is expressed in bytes, and must be a
+power of two).  If your device has no boundary crossing restrictions,
+pass 0 for alloc; passing 4096 says memory allocated from this pool
+must not cross 4KByte boundaries (but at that time it may be better to
+go for dma_alloc_coherent directly instead).
+
+Allocate memory from a dma pool like this:
+
+       cpu_addr = dma_pool_alloc(pool, flags, &dma_handle);
+
+flags are SLAB_KERNEL if blocking is permitted (not in_interrupt nor
+holding SMP locks), SLAB_ATOMIC otherwise.  Like dma_alloc_coherent,
+this returns two values, cpu_addr and dma_handle.
+
+Free memory that was allocated from a dma_pool like this:
+
+       dma_pool_free(pool, cpu_addr, dma_handle);
+
+where pool is what you passed to dma_pool_alloc, and cpu_addr and
+dma_handle are the values dma_pool_alloc returned. This function
+may be called in interrupt context.
+
+Destroy a dma_pool by calling:
+
+       dma_pool_destroy(pool);
+
+Make sure you've called dma_pool_free for all memory allocated
+from a pool before you destroy the pool. This function may not
+be called in interrupt context.
+
+                       DMA Direction
+
+The interfaces described in subsequent portions of this document
+take a DMA direction argument, which is an integer and takes on
+one of the following values:
+
+ DMA_BIDIRECTIONAL
+ DMA_TO_DEVICE
+ DMA_FROM_DEVICE
+ DMA_NONE
+
+One should provide the exact DMA direction if you know it.
+
+DMA_TO_DEVICE means "from main memory to the device"
+DMA_FROM_DEVICE means "from the device to main memory"
+It is the direction in which the data moves during the DMA
+transfer.
+
+You are _strongly_ encouraged to specify this as precisely
+as you possibly can.
+
+If you absolutely cannot know the direction of the DMA transfer,
+specify DMA_BIDIRECTIONAL.  It means that the DMA can go in
+either direction.  The platform guarantees that you may legally
+specify this, and that it will work, but this may be at the
+cost of performance for example.
+
+The value DMA_NONE is to be used for debugging.  One can
+hold this in a data structure before you come to know the
+precise direction, and this will help catch cases where your
+direction tracking logic has failed to set things up properly.
+
+Another advantage of specifying this value precisely (outside of
+potential platform-specific optimizations of such) is for debugging.
+Some platforms actually have a write permission boolean which DMA
+mappings can be marked with, much like page protections in the user
+program address space.  Such platforms can and do report errors in the
+kernel logs when the DMA controller hardware detects violation of the
+permission setting.
+
+Only streaming mappings specify a direction, consistent mappings
+implicitly have a direction attribute setting of
+DMA_BIDIRECTIONAL.
+
+The SCSI subsystem tells you the direction to use in the
+'sc_data_direction' member of the SCSI command your driver is
+working on.
+
+For Networking drivers, it's a rather simple affair.  For transmit
+packets, map/unmap them with the DMA_TO_DEVICE direction
+specifier.  For receive packets, just the opposite, map/unmap them
+with the DMA_FROM_DEVICE direction specifier.
+
+                 Using Streaming DMA mappings
+
+The streaming DMA mapping routines can be called from interrupt
+context.  There are two versions of each map/unmap, one which will
+map/unmap a single memory region, and one which will map/unmap a
+scatterlist.
+
+To map a single region, you do:
+
+       struct device *dev = &my_dev->dev;
+       dma_addr_t dma_handle;
+       void *addr = buffer->ptr;
+       size_t size = buffer->len;
+
+       dma_handle = dma_map_single(dev, addr, size, direction);
+
+and to unmap it:
+
+       dma_unmap_single(dev, dma_handle, size, direction);
+
+You should call dma_unmap_single when the DMA activity is finished, e.g.
+from the interrupt which told you that the DMA transfer is done.
+
+Using cpu pointers like this for single mappings has a disadvantage,
+you cannot reference HIGHMEM memory in this way.  Thus, there is a
+map/unmap interface pair akin to dma_{map,unmap}_single.  These
+interfaces deal with page/offset pairs instead of cpu pointers.
+Specifically:
+
+       struct device *dev = &my_dev->dev;
+       dma_addr_t dma_handle;
+       struct page *page = buffer->page;
+       unsigned long offset = buffer->offset;
+       size_t size = buffer->len;
+
+       dma_handle = dma_map_page(dev, page, offset, size, direction);
+
+       ...
+
+       dma_unmap_page(dev, dma_handle, size, direction);
+
+Here, "offset" means byte offset within the given page.
+
+With scatterlists, you map a region gathered from several regions by:
+
+       int i, count = dma_map_sg(dev, sglist, nents, direction);
+       struct scatterlist *sg;
+
+       for_each_sg(sglist, sg, count, i) {
+               hw_address[i] = sg_dma_address(sg);
+               hw_len[i] = sg_dma_len(sg);
+       }
+
+where nents is the number of entries in the sglist.
+
+The implementation is free to merge several consecutive sglist entries
+into one (e.g. if DMA mapping is done with PAGE_SIZE granularity, any
+consecutive sglist entries can be merged into one provided the first one
+ends and the second one starts on a page boundary - in fact this is a huge
+advantage for cards which either cannot do scatter-gather or have very
+limited number of scatter-gather entries) and returns the actual number
+of sg entries it mapped them to. On failure 0 is returned.
+
+Then you should loop count times (note: this can be less than nents times)
+and use sg_dma_address() and sg_dma_len() macros where you previously
+accessed sg->address and sg->length as shown above.
+
+To unmap a scatterlist, just call:
+
+       dma_unmap_sg(dev, sglist, nents, direction);
+
+Again, make sure DMA activity has already finished.
+
+PLEASE NOTE:  The 'nents' argument to the dma_unmap_sg call must be
+              the _same_ one you passed into the dma_map_sg call,
+             it should _NOT_ be the 'count' value _returned_ from the
+              dma_map_sg call.
+
+Every dma_map_{single,sg} call should have its dma_unmap_{single,sg}
+counterpart, because the bus address space is a shared resource (although
+in some ports the mapping is per each BUS so less devices contend for the
+same bus address space) and you could render the machine unusable by eating
+all bus addresses.
+
+If you need to use the same streaming DMA region multiple times and touch
+the data in between the DMA transfers, the buffer needs to be synced
+properly in order for the cpu and device to see the most uptodate and
+correct copy of the DMA buffer.
+
+So, firstly, just map it with dma_map_{single,sg}, and after each DMA
+transfer call either:
+
+       dma_sync_single_for_cpu(dev, dma_handle, size, direction);
+
+or:
+
+       dma_sync_sg_for_cpu(dev, sglist, nents, direction);
+
+as appropriate.
+
+Then, if you wish to let the device get at the DMA area again,
+finish accessing the data with the cpu, and then before actually
+giving the buffer to the hardware call either:
+
+       dma_sync_single_for_device(dev, dma_handle, size, direction);
+
+or:
+
+       dma_sync_sg_for_device(dev, sglist, nents, direction);
+
+as appropriate.
+
+After the last DMA transfer call one of the DMA unmap routines
+dma_unmap_{single,sg}. If you don't touch the data from the first dma_map_*
+call till dma_unmap_*, then you don't have to call the dma_sync_*
+routines at all.
+
+Here is pseudo code which shows a situation in which you would need
+to use the dma_sync_*() interfaces.
+
+       my_card_setup_receive_buffer(struct my_card *cp, char *buffer, int len)
+       {
+               dma_addr_t mapping;
+
+               mapping = dma_map_single(cp->dev, buffer, len, DMA_FROM_DEVICE);
+
+               cp->rx_buf = buffer;
+               cp->rx_len = len;
+               cp->rx_dma = mapping;
+
+               give_rx_buf_to_card(cp);
+       }
+
+       ...
+
+       my_card_interrupt_handler(int irq, void *devid, struct pt_regs *regs)
+       {
+               struct my_card *cp = devid;
+
+               ...
+               if (read_card_status(cp) == RX_BUF_TRANSFERRED) {
+                       struct my_card_header *hp;
+
+                       /* Examine the header to see if we wish
+                        * to accept the data.  But synchronize
+                        * the DMA transfer with the CPU first
+                        * so that we see updated contents.
+                        */
+                       dma_sync_single_for_cpu(&cp->dev, cp->rx_dma,
+                                               cp->rx_len,
+                                               DMA_FROM_DEVICE);
+
+                       /* Now it is safe to examine the buffer. */
+                       hp = (struct my_card_header *) cp->rx_buf;
+                       if (header_is_ok(hp)) {
+                               dma_unmap_single(&cp->dev, cp->rx_dma, cp->rx_len,
+                                                DMA_FROM_DEVICE);
+                               pass_to_upper_layers(cp->rx_buf);
+                               make_and_setup_new_rx_buf(cp);
+                       } else {
+                               /* Just sync the buffer and give it back
+                                * to the card.
+                                */
+                               dma_sync_single_for_device(&cp->dev,
+                                                          cp->rx_dma,
+                                                          cp->rx_len,
+                                                          DMA_FROM_DEVICE);
+                               give_rx_buf_to_card(cp);
+                       }
+               }
+       }
+
+Drivers converted fully to this interface should not use virt_to_bus any
+longer, nor should they use bus_to_virt. Some drivers have to be changed a
+little bit, because there is no longer an equivalent to bus_to_virt in the
+dynamic DMA mapping scheme - you have to always store the DMA addresses
+returned by the dma_alloc_coherent, dma_pool_alloc, and dma_map_single
+calls (dma_map_sg stores them in the scatterlist itself if the platform
+supports dynamic DMA mapping in hardware) in your driver structures and/or
+in the card registers.
+
+All drivers should be using these interfaces with no exceptions.  It
+is planned to completely remove virt_to_bus() and bus_to_virt() as
+they are entirely deprecated.  Some ports already do not provide these
+as it is impossible to correctly support them.
+
+               Optimizing Unmap State Space Consumption
+
+On many platforms, dma_unmap_{single,page}() is simply a nop.
+Therefore, keeping track of the mapping address and length is a waste
+of space.  Instead of filling your drivers up with ifdefs and the like
+to "work around" this (which would defeat the whole purpose of a
+portable API) the following facilities are provided.
+
+Actually, instead of describing the macros one by one, we'll
+transform some example code.
+
+1) Use DEFINE_DMA_UNMAP_{ADDR,LEN} in state saving structures.
+   Example, before:
+
+       struct ring_state {
+               struct sk_buff *skb;
+               dma_addr_t mapping;
+               __u32 len;
+       };
+
+   after:
+
+       struct ring_state {
+               struct sk_buff *skb;
+               DEFINE_DMA_UNMAP_ADDR(mapping);
+               DEFINE_DMA_UNMAP_LEN(len);
+       };
+
+2) Use dma_unmap_{addr,len}_set to set these values.
+   Example, before:
+
+       ringp->mapping = FOO;
+       ringp->len = BAR;
+
+   after:
+
+       dma_unmap_addr_set(ringp, mapping, FOO);
+       dma_unmap_len_set(ringp, len, BAR);
+
+3) Use dma_unmap_{addr,len} to access these values.
+   Example, before:
+
+       dma_unmap_single(dev, ringp->mapping, ringp->len,
+                        DMA_FROM_DEVICE);
+
+   after:
+
+       dma_unmap_single(dev,
+                        dma_unmap_addr(ringp, mapping),
+                        dma_unmap_len(ringp, len),
+                        DMA_FROM_DEVICE);
+
+It really should be self-explanatory.  We treat the ADDR and LEN
+separately, because it is possible for an implementation to only
+need the address in order to perform the unmap operation.
+
+                       Platform Issues
+
+If you are just writing drivers for Linux and do not maintain
+an architecture port for the kernel, you can safely skip down
+to "Closing".
+
+1) Struct scatterlist requirements.
+
+   Struct scatterlist must contain, at a minimum, the following
+   members:
+
+       struct page *page;
+       unsigned int offset;
+       unsigned int length;
+
+   The base address is specified by a "page+offset" pair.
+
+   Previous versions of struct scatterlist contained a "void *address"
+   field that was sometimes used instead of page+offset.  As of Linux
+   2.5., page+offset is always used, and the "address" field has been
+   deleted.
+
+2) More to come...
+
+                       Handling Errors
+
+DMA address space is limited on some architectures and an allocation
+failure can be determined by:
+
+- checking if dma_alloc_coherent returns NULL or dma_map_sg returns 0
+
+- checking the returned dma_addr_t of dma_map_single and dma_map_page
+  by using dma_mapping_error():
+
+       dma_addr_t dma_handle;
+
+       dma_handle = dma_map_single(dev, addr, size, direction);
+       if (dma_mapping_error(dev, dma_handle)) {
+               /*
+                * reduce current DMA mapping usage,
+                * delay and try again later or
+                * reset driver.
+                */
+       }
+
+                          Closing
+
+This document, and the API itself, would not be in it's current
+form without the feedback and suggestions from numerous individuals.
+We would like to specifically mention, in no particular order, the
+following people:
+
+       Russell King <rmk@arm.linux.org.uk>
+       Leo Dagum <dagum@barrel.engr.sgi.com>
+       Ralf Baechle <ralf@oss.sgi.com>
+       Grant Grundler <grundler@cup.hp.com>
+       Jay Estabrook <Jay.Estabrook@compaq.com>
+       Thomas Sailer <sailer@ife.ee.ethz.ch>
+       Andrea Arcangeli <andrea@suse.de>
+       Jens Axboe <jens.axboe@oracle.com>
+       David Mosberger-Tang <davidm@hpl.hp.com>
diff --git a/Documentation/PCI/PCI-DMA-mapping.txt b/Documentation/PCI/PCI-DMA-mapping.txt
deleted file mode 100644 (file)
index 52618ab..0000000
+++ /dev/null
@@ -1,758 +0,0 @@
-                    Dynamic DMA mapping Guide
-                    =========================
-
-                David S. Miller <davem@redhat.com>
-                Richard Henderson <rth@cygnus.com>
-                 Jakub Jelinek <jakub@redhat.com>
-
-This is a guide to device driver writers on how to use the DMA API
-with example pseudo-code.  For a concise description of the API, see
-DMA-API.txt.
-
-Most of the 64bit platforms have special hardware that translates bus
-addresses (DMA addresses) into physical addresses.  This is similar to
-how page tables and/or a TLB translates virtual addresses to physical
-addresses on a CPU.  This is needed so that e.g. PCI devices can
-access with a Single Address Cycle (32bit DMA address) any page in the
-64bit physical address space.  Previously in Linux those 64bit
-platforms had to set artificial limits on the maximum RAM size in the
-system, so that the virt_to_bus() static scheme works (the DMA address
-translation tables were simply filled on bootup to map each bus
-address to the physical page __pa(bus_to_virt())).
-
-So that Linux can use the dynamic DMA mapping, it needs some help from the
-drivers, namely it has to take into account that DMA addresses should be
-mapped only for the time they are actually used and unmapped after the DMA
-transfer.
-
-The following API will work of course even on platforms where no such
-hardware exists.
-
-Note that the DMA API works with any bus independent of the underlying
-microprocessor architecture. You should use the DMA API rather than
-the bus specific DMA API (e.g. pci_dma_*).
-
-First of all, you should make sure
-
-#include <linux/dma-mapping.h>
-
-is in your driver. This file will obtain for you the definition of the
-dma_addr_t (which can hold any valid DMA address for the platform)
-type which should be used everywhere you hold a DMA (bus) address
-returned from the DMA mapping functions.
-
-                        What memory is DMA'able?
-
-The first piece of information you must know is what kernel memory can
-be used with the DMA mapping facilities.  There has been an unwritten
-set of rules regarding this, and this text is an attempt to finally
-write them down.
-
-If you acquired your memory via the page allocator
-(i.e. __get_free_page*()) or the generic memory allocators
-(i.e. kmalloc() or kmem_cache_alloc()) then you may DMA to/from
-that memory using the addresses returned from those routines.
-
-This means specifically that you may _not_ use the memory/addresses
-returned from vmalloc() for DMA.  It is possible to DMA to the
-_underlying_ memory mapped into a vmalloc() area, but this requires
-walking page tables to get the physical addresses, and then
-translating each of those pages back to a kernel address using
-something like __va().  [ EDIT: Update this when we integrate
-Gerd Knorr's generic code which does this. ]
-
-This rule also means that you may use neither kernel image addresses
-(items in data/text/bss segments), nor module image addresses, nor
-stack addresses for DMA.  These could all be mapped somewhere entirely
-different than the rest of physical memory.  Even if those classes of
-memory could physically work with DMA, you'd need to ensure the I/O
-buffers were cacheline-aligned.  Without that, you'd see cacheline
-sharing problems (data corruption) on CPUs with DMA-incoherent caches.
-(The CPU could write to one word, DMA would write to a different one
-in the same cache line, and one of them could be overwritten.)
-
-Also, this means that you cannot take the return of a kmap()
-call and DMA to/from that.  This is similar to vmalloc().
-
-What about block I/O and networking buffers?  The block I/O and
-networking subsystems make sure that the buffers they use are valid
-for you to DMA from/to.
-
-                       DMA addressing limitations
-
-Does your device have any DMA addressing limitations?  For example, is
-your device only capable of driving the low order 24-bits of address?
-If so, you need to inform the kernel of this fact.
-
-By default, the kernel assumes that your device can address the full
-32-bits.  For a 64-bit capable device, this needs to be increased.
-And for a device with limitations, as discussed in the previous
-paragraph, it needs to be decreased.
-
-Special note about PCI: PCI-X specification requires PCI-X devices to
-support 64-bit addressing (DAC) for all transactions.  And at least
-one platform (SGI SN2) requires 64-bit consistent allocations to
-operate correctly when the IO bus is in PCI-X mode.
-
-For correct operation, you must interrogate the kernel in your device
-probe routine to see if the DMA controller on the machine can properly
-support the DMA addressing limitation your device has.  It is good
-style to do this even if your device holds the default setting,
-because this shows that you did think about these issues wrt. your
-device.
-
-The query is performed via a call to dma_set_mask():
-
-       int dma_set_mask(struct device *dev, u64 mask);
-
-The query for consistent allocations is performed via a call to
-dma_set_coherent_mask():
-
-       int dma_set_coherent_mask(struct device *dev, u64 mask);
-
-Here, dev is a pointer to the device struct of your device, and mask
-is a bit mask describing which bits of an address your device
-supports.  It returns zero if your card can perform DMA properly on
-the machine given the address mask you provided.  In general, the
-device struct of your device is embedded in the bus specific device
-struct of your device.  For example, a pointer to the device struct of
-your PCI device is pdev->dev (pdev is a pointer to the PCI device
-struct of your device).
-
-If it returns non-zero, your device cannot perform DMA properly on
-this platform, and attempting to do so will result in undefined
-behavior.  You must either use a different mask, or not use DMA.
-
-This means that in the failure case, you have three options:
-
-1) Use another DMA mask, if possible (see below).
-2) Use some non-DMA mode for data transfer, if possible.
-3) Ignore this device and do not initialize it.
-
-It is recommended that your driver print a kernel KERN_WARNING message
-when you end up performing either #2 or #3.  In this manner, if a user
-of your driver reports that performance is bad or that the device is not
-even detected, you can ask them for the kernel messages to find out
-exactly why.
-
-The standard 32-bit addressing device would do something like this:
-
-       if (dma_set_mask(dev, DMA_BIT_MASK(32))) {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
-               goto ignore_this_device;
-       }
-
-Another common scenario is a 64-bit capable device.  The approach here
-is to try for 64-bit addressing, but back down to a 32-bit mask that
-should not fail.  The kernel may fail the 64-bit mask not because the
-platform is not capable of 64-bit addressing.  Rather, it may fail in
-this case simply because 32-bit addressing is done more efficiently
-than 64-bit addressing.  For example, Sparc64 PCI SAC addressing is
-more efficient than DAC addressing.
-
-Here is how you would handle a 64-bit capable device which can drive
-all 64-bits when accessing streaming DMA:
-
-       int using_dac;
-
-       if (!dma_set_mask(dev, DMA_BIT_MASK(64))) {
-               using_dac = 1;
-       } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
-               using_dac = 0;
-       } else {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
-               goto ignore_this_device;
-       }
-
-If a card is capable of using 64-bit consistent allocations as well,
-the case would look like this:
-
-       int using_dac, consistent_using_dac;
-
-       if (!dma_set_mask(dev, DMA_BIT_MASK(64))) {
-               using_dac = 1;
-               consistent_using_dac = 1;
-               dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
-       } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
-               using_dac = 0;
-               consistent_using_dac = 0;
-               dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
-       } else {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
-               goto ignore_this_device;
-       }
-
-dma_set_coherent_mask() will always be able to set the same or a
-smaller mask as dma_set_mask(). However for the rare case that a
-device driver only uses consistent allocations, one would have to
-check the return value from dma_set_coherent_mask().
-
-Finally, if your device can only drive the low 24-bits of
-address you might do something like:
-
-       if (dma_set_mask(dev, DMA_BIT_MASK(24))) {
-               printk(KERN_WARNING
-                      "mydev: 24-bit DMA addressing not available.\n");
-               goto ignore_this_device;
-       }
-
-When dma_set_mask() is successful, and returns zero, the kernel saves
-away this mask you have provided.  The kernel will use this
-information later when you make DMA mappings.
-
-There is a case which we are aware of at this time, which is worth
-mentioning in this documentation.  If your device supports multiple
-functions (for example a sound card provides playback and record
-functions) and the various different functions have _different_
-DMA addressing limitations, you may wish to probe each mask and
-only provide the functionality which the machine can handle.  It
-is important that the last call to dma_set_mask() be for the
-most specific mask.
-
-Here is pseudo-code showing how this might be done:
-
-       #define PLAYBACK_ADDRESS_BITS   DMA_BIT_MASK(32)
-       #define RECORD_ADDRESS_BITS     DMA_BIT_MASK(24)
-
-       struct my_sound_card *card;
-       struct device *dev;
-
-       ...
-       if (!dma_set_mask(dev, PLAYBACK_ADDRESS_BITS)) {
-               card->playback_enabled = 1;
-       } else {
-               card->playback_enabled = 0;
-               printk(KERN_WARNING "%s: Playback disabled due to DMA limitations.\n",
-                      card->name);
-       }
-       if (!dma_set_mask(dev, RECORD_ADDRESS_BITS)) {
-               card->record_enabled = 1;
-       } else {
-               card->record_enabled = 0;
-               printk(KERN_WARNING "%s: Record disabled due to DMA limitations.\n",
-                      card->name);
-       }
-
-A sound card was used as an example here because this genre of PCI
-devices seems to be littered with ISA chips given a PCI front end,
-and thus retaining the 16MB DMA addressing limitations of ISA.
-
-                       Types of DMA mappings
-
-There are two types of DMA mappings:
-
-- Consistent DMA mappings which are usually mapped at driver
-  initialization, unmapped at the end and for which the hardware should
-  guarantee that the device and the CPU can access the data
-  in parallel and will see updates made by each other without any
-  explicit software flushing.
-
-  Think of "consistent" as "synchronous" or "coherent".
-
-  The current default is to return consistent memory in the low 32
-  bits of the bus space.  However, for future compatibility you should
-  set the consistent mask even if this default is fine for your
-  driver.
-
-  Good examples of what to use consistent mappings for are:
-
-       - Network card DMA ring descriptors.
-       - SCSI adapter mailbox command data structures.
-       - Device firmware microcode executed out of
-         main memory.
-
-  The invariant these examples all require is that any CPU store
-  to memory is immediately visible to the device, and vice
-  versa.  Consistent mappings guarantee this.
-
-  IMPORTANT: Consistent DMA memory does not preclude the usage of
-             proper memory barriers.  The CPU may reorder stores to
-            consistent memory just as it may normal memory.  Example:
-            if it is important for the device to see the first word
-            of a descriptor updated before the second, you must do
-            something like:
-
-               desc->word0 = address;
-               wmb();
-               desc->word1 = DESC_VALID;
-
-             in order to get correct behavior on all platforms.
-
-            Also, on some platforms your driver may need to flush CPU write
-            buffers in much the same way as it needs to flush write buffers
-            found in PCI bridges (such as by reading a register's value
-            after writing it).
-
-- Streaming DMA mappings which are usually mapped for one DMA
-  transfer, unmapped right after it (unless you use dma_sync_* below)
-  and for which hardware can optimize for sequential accesses.
-
-  This of "streaming" as "asynchronous" or "outside the coherency
-  domain".
-
-  Good examples of what to use streaming mappings for are:
-
-       - Networking buffers transmitted/received by a device.
-       - Filesystem buffers written/read by a SCSI device.
-
-  The interfaces for using this type of mapping were designed in
-  such a way that an implementation can make whatever performance
-  optimizations the hardware allows.  To this end, when using
-  such mappings you must be explicit about what you want to happen.
-
-Neither type of DMA mapping has alignment restrictions that come from
-the underlying bus, although some devices may have such restrictions.
-Also, systems with caches that aren't DMA-coherent will work better
-when the underlying buffers don't share cache lines with other data.
-
-
-                Using Consistent DMA mappings.
-
-To allocate and map large (PAGE_SIZE or so) consistent DMA regions,
-you should do:
-
-       dma_addr_t dma_handle;
-
-       cpu_addr = dma_alloc_coherent(dev, size, &dma_handle, gfp);
-
-where device is a struct device *. This may be called in interrupt
-context with the GFP_ATOMIC flag.
-
-Size is the length of the region you want to allocate, in bytes.
-
-This routine will allocate RAM for that region, so it acts similarly to
-__get_free_pages (but takes size instead of a page order).  If your
-driver needs regions sized smaller than a page, you may prefer using
-the dma_pool interface, described below.
-
-The consistent DMA mapping interfaces, for non-NULL dev, will by
-default return a DMA address which is 32-bit addressable.  Even if the
-device indicates (via DMA mask) that it may address the upper 32-bits,
-consistent allocation will only return > 32-bit addresses for DMA if
-the consistent DMA mask has been explicitly changed via
-dma_set_coherent_mask().  This is true of the dma_pool interface as
-well.
-
-dma_alloc_coherent returns two values: the virtual address which you
-can use to access it from the CPU and dma_handle which you pass to the
-card.
-
-The cpu return address and the DMA bus master address are both
-guaranteed to be aligned to the smallest PAGE_SIZE order which
-is greater than or equal to the requested size.  This invariant
-exists (for example) to guarantee that if you allocate a chunk
-which is smaller than or equal to 64 kilobytes, the extent of the
-buffer you receive will not cross a 64K boundary.
-
-To unmap and free such a DMA region, you call:
-
-       dma_free_coherent(dev, size, cpu_addr, dma_handle);
-
-where dev, size are the same as in the above call and cpu_addr and
-dma_handle are the values dma_alloc_coherent returned to you.
-This function may not be called in interrupt context.
-
-If your driver needs lots of smaller memory regions, you can write
-custom code to subdivide pages returned by dma_alloc_coherent,
-or you can use the dma_pool API to do that.  A dma_pool is like
-a kmem_cache, but it uses dma_alloc_coherent not __get_free_pages.
-Also, it understands common hardware constraints for alignment,
-like queue heads needing to be aligned on N byte boundaries.
-
-Create a dma_pool like this:
-
-       struct dma_pool *pool;
-
-       pool = dma_pool_create(name, dev, size, align, alloc);
-
-The "name" is for diagnostics (like a kmem_cache name); dev and size
-are as above.  The device's hardware alignment requirement for this
-type of data is "align" (which is expressed in bytes, and must be a
-power of two).  If your device has no boundary crossing restrictions,
-pass 0 for alloc; passing 4096 says memory allocated from this pool
-must not cross 4KByte boundaries (but at that time it may be better to
-go for dma_alloc_coherent directly instead).
-
-Allocate memory from a dma pool like this:
-
-       cpu_addr = dma_pool_alloc(pool, flags, &dma_handle);
-
-flags are SLAB_KERNEL if blocking is permitted (not in_interrupt nor
-holding SMP locks), SLAB_ATOMIC otherwise.  Like dma_alloc_coherent,
-this returns two values, cpu_addr and dma_handle.
-
-Free memory that was allocated from a dma_pool like this:
-
-       dma_pool_free(pool, cpu_addr, dma_handle);
-
-where pool is what you passed to dma_pool_alloc, and cpu_addr and
-dma_handle are the values dma_pool_alloc returned. This function
-may be called in interrupt context.
-
-Destroy a dma_pool by calling:
-
-       dma_pool_destroy(pool);
-
-Make sure you've called dma_pool_free for all memory allocated
-from a pool before you destroy the pool. This function may not
-be called in interrupt context.
-
-                       DMA Direction
-
-The interfaces described in subsequent portions of this document
-take a DMA direction argument, which is an integer and takes on
-one of the following values:
-
- DMA_BIDIRECTIONAL
- DMA_TO_DEVICE
- DMA_FROM_DEVICE
- DMA_NONE
-
-One should provide the exact DMA direction if you know it.
-
-DMA_TO_DEVICE means "from main memory to the device"
-DMA_FROM_DEVICE means "from the device to main memory"
-It is the direction in which the data moves during the DMA
-transfer.
-
-You are _strongly_ encouraged to specify this as precisely
-as you possibly can.
-
-If you absolutely cannot know the direction of the DMA transfer,
-specify DMA_BIDIRECTIONAL.  It means that the DMA can go in
-either direction.  The platform guarantees that you may legally
-specify this, and that it will work, but this may be at the
-cost of performance for example.
-
-The value DMA_NONE is to be used for debugging.  One can
-hold this in a data structure before you come to know the
-precise direction, and this will help catch cases where your
-direction tracking logic has failed to set things up properly.
-
-Another advantage of specifying this value precisely (outside of
-potential platform-specific optimizations of such) is for debugging.
-Some platforms actually have a write permission boolean which DMA
-mappings can be marked with, much like page protections in the user
-program address space.  Such platforms can and do report errors in the
-kernel logs when the DMA controller hardware detects violation of the
-permission setting.
-
-Only streaming mappings specify a direction, consistent mappings
-implicitly have a direction attribute setting of
-DMA_BIDIRECTIONAL.
-
-The SCSI subsystem tells you the direction to use in the
-'sc_data_direction' member of the SCSI command your driver is
-working on.
-
-For Networking drivers, it's a rather simple affair.  For transmit
-packets, map/unmap them with the DMA_TO_DEVICE direction
-specifier.  For receive packets, just the opposite, map/unmap them
-with the DMA_FROM_DEVICE direction specifier.
-
-                 Using Streaming DMA mappings
-
-The streaming DMA mapping routines can be called from interrupt
-context.  There are two versions of each map/unmap, one which will
-map/unmap a single memory region, and one which will map/unmap a
-scatterlist.
-
-To map a single region, you do:
-
-       struct device *dev = &my_dev->dev;
-       dma_addr_t dma_handle;
-       void *addr = buffer->ptr;
-       size_t size = buffer->len;
-
-       dma_handle = dma_map_single(dev, addr, size, direction);
-
-and to unmap it:
-
-       dma_unmap_single(dev, dma_handle, size, direction);
-
-You should call dma_unmap_single when the DMA activity is finished, e.g.
-from the interrupt which told you that the DMA transfer is done.
-
-Using cpu pointers like this for single mappings has a disadvantage,
-you cannot reference HIGHMEM memory in this way.  Thus, there is a
-map/unmap interface pair akin to dma_{map,unmap}_single.  These
-interfaces deal with page/offset pairs instead of cpu pointers.
-Specifically:
-
-       struct device *dev = &my_dev->dev;
-       dma_addr_t dma_handle;
-       struct page *page = buffer->page;
-       unsigned long offset = buffer->offset;
-       size_t size = buffer->len;
-
-       dma_handle = dma_map_page(dev, page, offset, size, direction);
-
-       ...
-
-       dma_unmap_page(dev, dma_handle, size, direction);
-
-Here, "offset" means byte offset within the given page.
-
-With scatterlists, you map a region gathered from several regions by:
-
-       int i, count = dma_map_sg(dev, sglist, nents, direction);
-       struct scatterlist *sg;
-
-       for_each_sg(sglist, sg, count, i) {
-               hw_address[i] = sg_dma_address(sg);
-               hw_len[i] = sg_dma_len(sg);
-       }
-
-where nents is the number of entries in the sglist.
-
-The implementation is free to merge several consecutive sglist entries
-into one (e.g. if DMA mapping is done with PAGE_SIZE granularity, any
-consecutive sglist entries can be merged into one provided the first one
-ends and the second one starts on a page boundary - in fact this is a huge
-advantage for cards which either cannot do scatter-gather or have very
-limited number of scatter-gather entries) and returns the actual number
-of sg entries it mapped them to. On failure 0 is returned.
-
-Then you should loop count times (note: this can be less than nents times)
-and use sg_dma_address() and sg_dma_len() macros where you previously
-accessed sg->address and sg->length as shown above.
-
-To unmap a scatterlist, just call:
-
-       dma_unmap_sg(dev, sglist, nents, direction);
-
-Again, make sure DMA activity has already finished.
-
-PLEASE NOTE:  The 'nents' argument to the dma_unmap_sg call must be
-              the _same_ one you passed into the dma_map_sg call,
-             it should _NOT_ be the 'count' value _returned_ from the
-              dma_map_sg call.
-
-Every dma_map_{single,sg} call should have its dma_unmap_{single,sg}
-counterpart, because the bus address space is a shared resource (although
-in some ports the mapping is per each BUS so less devices contend for the
-same bus address space) and you could render the machine unusable by eating
-all bus addresses.
-
-If you need to use the same streaming DMA region multiple times and touch
-the data in between the DMA transfers, the buffer needs to be synced
-properly in order for the cpu and device to see the most uptodate and
-correct copy of the DMA buffer.
-
-So, firstly, just map it with dma_map_{single,sg}, and after each DMA
-transfer call either:
-
-       dma_sync_single_for_cpu(dev, dma_handle, size, direction);
-
-or:
-
-       dma_sync_sg_for_cpu(dev, sglist, nents, direction);
-
-as appropriate.
-
-Then, if you wish to let the device get at the DMA area again,
-finish accessing the data with the cpu, and then before actually
-giving the buffer to the hardware call either:
-
-       dma_sync_single_for_device(dev, dma_handle, size, direction);
-
-or:
-
-       dma_sync_sg_for_device(dev, sglist, nents, direction);
-
-as appropriate.
-
-After the last DMA transfer call one of the DMA unmap routines
-dma_unmap_{single,sg}. If you don't touch the data from the first dma_map_*
-call till dma_unmap_*, then you don't have to call the dma_sync_*
-routines at all.
-
-Here is pseudo code which shows a situation in which you would need
-to use the dma_sync_*() interfaces.
-
-       my_card_setup_receive_buffer(struct my_card *cp, char *buffer, int len)
-       {
-               dma_addr_t mapping;
-
-               mapping = dma_map_single(cp->dev, buffer, len, DMA_FROM_DEVICE);
-
-               cp->rx_buf = buffer;
-               cp->rx_len = len;
-               cp->rx_dma = mapping;
-
-               give_rx_buf_to_card(cp);
-       }
-
-       ...
-
-       my_card_interrupt_handler(int irq, void *devid, struct pt_regs *regs)
-       {
-               struct my_card *cp = devid;
-
-               ...
-               if (read_card_status(cp) == RX_BUF_TRANSFERRED) {
-                       struct my_card_header *hp;
-
-                       /* Examine the header to see if we wish
-                        * to accept the data.  But synchronize
-                        * the DMA transfer with the CPU first
-                        * so that we see updated contents.
-                        */
-                       dma_sync_single_for_cpu(&cp->dev, cp->rx_dma,
-                                               cp->rx_len,
-                                               DMA_FROM_DEVICE);
-
-                       /* Now it is safe to examine the buffer. */
-                       hp = (struct my_card_header *) cp->rx_buf;
-                       if (header_is_ok(hp)) {
-                               dma_unmap_single(&cp->dev, cp->rx_dma, cp->rx_len,
-                                                DMA_FROM_DEVICE);
-                               pass_to_upper_layers(cp->rx_buf);
-                               make_and_setup_new_rx_buf(cp);
-                       } else {
-                               /* Just sync the buffer and give it back
-                                * to the card.
-                                */
-                               dma_sync_single_for_device(&cp->dev,
-                                                          cp->rx_dma,
-                                                          cp->rx_len,
-                                                          DMA_FROM_DEVICE);
-                               give_rx_buf_to_card(cp);
-                       }
-               }
-       }
-
-Drivers converted fully to this interface should not use virt_to_bus any
-longer, nor should they use bus_to_virt. Some drivers have to be changed a
-little bit, because there is no longer an equivalent to bus_to_virt in the
-dynamic DMA mapping scheme - you have to always store the DMA addresses
-returned by the dma_alloc_coherent, dma_pool_alloc, and dma_map_single
-calls (dma_map_sg stores them in the scatterlist itself if the platform
-supports dynamic DMA mapping in hardware) in your driver structures and/or
-in the card registers.
-
-All drivers should be using these interfaces with no exceptions.  It
-is planned to completely remove virt_to_bus() and bus_to_virt() as
-they are entirely deprecated.  Some ports already do not provide these
-as it is impossible to correctly support them.
-
-               Optimizing Unmap State Space Consumption
-
-On many platforms, dma_unmap_{single,page}() is simply a nop.
-Therefore, keeping track of the mapping address and length is a waste
-of space.  Instead of filling your drivers up with ifdefs and the like
-to "work around" this (which would defeat the whole purpose of a
-portable API) the following facilities are provided.
-
-Actually, instead of describing the macros one by one, we'll
-transform some example code.
-
-1) Use DEFINE_DMA_UNMAP_{ADDR,LEN} in state saving structures.
-   Example, before:
-
-       struct ring_state {
-               struct sk_buff *skb;
-               dma_addr_t mapping;
-               __u32 len;
-       };
-
-   after:
-
-       struct ring_state {
-               struct sk_buff *skb;
-               DEFINE_DMA_UNMAP_ADDR(mapping);
-               DEFINE_DMA_UNMAP_LEN(len);
-       };
-
-2) Use dma_unmap_{addr,len}_set to set these values.
-   Example, before:
-
-       ringp->mapping = FOO;
-       ringp->len = BAR;
-
-   after:
-
-       dma_unmap_addr_set(ringp, mapping, FOO);
-       dma_unmap_len_set(ringp, len, BAR);
-
-3) Use dma_unmap_{addr,len} to access these values.
-   Example, before:
-
-       dma_unmap_single(dev, ringp->mapping, ringp->len,
-                        DMA_FROM_DEVICE);
-
-   after:
-
-       dma_unmap_single(dev,
-                        dma_unmap_addr(ringp, mapping),
-                        dma_unmap_len(ringp, len),
-                        DMA_FROM_DEVICE);
-
-It really should be self-explanatory.  We treat the ADDR and LEN
-separately, because it is possible for an implementation to only
-need the address in order to perform the unmap operation.
-
-                       Platform Issues
-
-If you are just writing drivers for Linux and do not maintain
-an architecture port for the kernel, you can safely skip down
-to "Closing".
-
-1) Struct scatterlist requirements.
-
-   Struct scatterlist must contain, at a minimum, the following
-   members:
-
-       struct page *page;
-       unsigned int offset;
-       unsigned int length;
-
-   The base address is specified by a "page+offset" pair.
-
-   Previous versions of struct scatterlist contained a "void *address"
-   field that was sometimes used instead of page+offset.  As of Linux
-   2.5., page+offset is always used, and the "address" field has been
-   deleted.
-
-2) More to come...
-
-                       Handling Errors
-
-DMA address space is limited on some architectures and an allocation
-failure can be determined by:
-
-- checking if dma_alloc_coherent returns NULL or dma_map_sg returns 0
-
-- checking the returned dma_addr_t of dma_map_single and dma_map_page
-  by using dma_mapping_error():
-
-       dma_addr_t dma_handle;
-
-       dma_handle = dma_map_single(dev, addr, size, direction);
-       if (dma_mapping_error(dev, dma_handle)) {
-               /*
-                * reduce current DMA mapping usage,
-                * delay and try again later or
-                * reset driver.
-                */
-       }
-
-                          Closing
-
-This document, and the API itself, would not be in it's current
-form without the feedback and suggestions from numerous individuals.
-We would like to specifically mention, in no particular order, the
-following people:
-
-       Russell King <rmk@arm.linux.org.uk>
-       Leo Dagum <dagum@barrel.engr.sgi.com>
-       Ralf Baechle <ralf@oss.sgi.com>
-       Grant Grundler <grundler@cup.hp.com>
-       Jay Estabrook <Jay.Estabrook@compaq.com>
-       Thomas Sailer <sailer@ife.ee.ethz.ch>
-       Andrea Arcangeli <andrea@suse.de>
-       Jens Axboe <jens.axboe@oracle.com>
-       David Mosberger-Tang <davidm@hpl.hp.com>
index f8bc802d70b92d05545a87974af9e2645d6af6c6..3a6aecd078ba95c4d5a58e0ffb34ba8048cc879d 100644 (file)
@@ -340,7 +340,7 @@ Note:
 5.3 swappiness
   Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only.
 
-  Following cgroups' swapiness can't be changed.
+  Following cgroups' swappiness can't be changed.
   - root cgroup (uses /proc/sys/vm/swappiness).
   - a cgroup which uses hierarchy and it has child cgroup.
   - a cgroup which uses hierarchy and not the root of hierarchy.
diff --git a/Documentation/circular-buffers.txt b/Documentation/circular-buffers.txt
new file mode 100644 (file)
index 0000000..8117e5b
--- /dev/null
@@ -0,0 +1,234 @@
+                              ================
+                              CIRCULAR BUFFERS
+                              ================
+
+By: David Howells <dhowells@redhat.com>
+    Paul E. McKenney <paulmck@linux.vnet.ibm.com>
+
+
+Linux provides a number of features that can be used to implement circular
+buffering.  There are two sets of such features:
+
+ (1) Convenience functions for determining information about power-of-2 sized
+     buffers.
+
+ (2) Memory barriers for when the producer and the consumer of objects in the
+     buffer don't want to share a lock.
+
+To use these facilities, as discussed below, there needs to be just one
+producer and just one consumer.  It is possible to handle multiple producers by
+serialising them, and to handle multiple consumers by serialising them.
+
+
+Contents:
+
+ (*) What is a circular buffer?
+
+ (*) Measuring power-of-2 buffers.
+
+ (*) Using memory barriers with circular buffers.
+     - The producer.
+     - The consumer.
+
+
+==========================
+WHAT IS A CIRCULAR BUFFER?
+==========================
+
+First of all, what is a circular buffer?  A circular buffer is a buffer of
+fixed, finite size into which there are two indices:
+
+ (1) A 'head' index - the point at which the producer inserts items into the
+     buffer.
+
+ (2) A 'tail' index - the point at which the consumer finds the next item in
+     the buffer.
+
+Typically when the tail pointer is equal to the head pointer, the buffer is
+empty; and the buffer is full when the head pointer is one less than the tail
+pointer.
+
+The head index is incremented when items are added, and the tail index when
+items are removed.  The tail index should never jump the head index, and both
+indices should be wrapped to 0 when they reach the end of the buffer, thus
+allowing an infinite amount of data to flow through the buffer.
+
+Typically, items will all be of the same unit size, but this isn't strictly
+required to use the techniques below.  The indices can be increased by more
+than 1 if multiple items or variable-sized items are to be included in the
+buffer, provided that neither index overtakes the other.  The implementer must
+be careful, however, as a region more than one unit in size may wrap the end of
+the buffer and be broken into two segments.
+
+
+============================
+MEASURING POWER-OF-2 BUFFERS
+============================
+
+Calculation of the occupancy or the remaining capacity of an arbitrarily sized
+circular buffer would normally be a slow operation, requiring the use of a
+modulus (divide) instruction.  However, if the buffer is of a power-of-2 size,
+then a much quicker bitwise-AND instruction can be used instead.
+
+Linux provides a set of macros for handling power-of-2 circular buffers.  These
+can be made use of by:
+
+       #include <linux/circ_buf.h>
+
+The macros are:
+
+ (*) Measure the remaining capacity of a buffer:
+
+       CIRC_SPACE(head_index, tail_index, buffer_size);
+
+     This returns the amount of space left in the buffer[1] into which items
+     can be inserted.
+
+
+ (*) Measure the maximum consecutive immediate space in a buffer:
+
+       CIRC_SPACE_TO_END(head_index, tail_index, buffer_size);
+
+     This returns the amount of consecutive space left in the buffer[1] into
+     which items can be immediately inserted without having to wrap back to the
+     beginning of the buffer.
+
+
+ (*) Measure the occupancy of a buffer:
+
+       CIRC_CNT(head_index, tail_index, buffer_size);
+
+     This returns the number of items currently occupying a buffer[2].
+
+
+ (*) Measure the non-wrapping occupancy of a buffer:
+
+       CIRC_CNT_TO_END(head_index, tail_index, buffer_size);
+
+     This returns the number of consecutive items[2] that can be extracted from
+     the buffer without having to wrap back to the beginning of the buffer.
+
+
+Each of these macros will nominally return a value between 0 and buffer_size-1,
+however:
+
+ [1] CIRC_SPACE*() are intended to be used in the producer.  To the producer
+     they will return a lower bound as the producer controls the head index,
+     but the consumer may still be depleting the buffer on another CPU and
+     moving the tail index.
+
+     To the consumer it will show an upper bound as the producer may be busy
+     depleting the space.
+
+ [2] CIRC_CNT*() are intended to be used in the consumer.  To the consumer they
+     will return a lower bound as the consumer controls the tail index, but the
+     producer may still be filling the buffer on another CPU and moving the
+     head index.
+
+     To the producer it will show an upper bound as the consumer may be busy
+     emptying the buffer.
+
+ [3] To a third party, the order in which the writes to the indices by the
+     producer and consumer become visible cannot be guaranteed as they are
+     independent and may be made on different CPUs - so the result in such a
+     situation will merely be a guess, and may even be negative.
+
+
+===========================================
+USING MEMORY BARRIERS WITH CIRCULAR BUFFERS
+===========================================
+
+By using memory barriers in conjunction with circular buffers, you can avoid
+the need to:
+
+ (1) use a single lock to govern access to both ends of the buffer, thus
+     allowing the buffer to be filled and emptied at the same time; and
+
+ (2) use atomic counter operations.
+
+There are two sides to this: the producer that fills the buffer, and the
+consumer that empties it.  Only one thing should be filling a buffer at any one
+time, and only one thing should be emptying a buffer at any one time, but the
+two sides can operate simultaneously.
+
+
+THE PRODUCER
+------------
+
+The producer will look something like this:
+
+       spin_lock(&producer_lock);
+
+       unsigned long head = buffer->head;
+       unsigned long tail = ACCESS_ONCE(buffer->tail);
+
+       if (CIRC_SPACE(head, tail, buffer->size) >= 1) {
+               /* insert one item into the buffer */
+               struct item *item = buffer[head];
+
+               produce_item(item);
+
+               smp_wmb(); /* commit the item before incrementing the head */
+
+               buffer->head = (head + 1) & (buffer->size - 1);
+
+               /* wake_up() will make sure that the head is committed before
+                * waking anyone up */
+               wake_up(consumer);
+       }
+
+       spin_unlock(&producer_lock);
+
+This will instruct the CPU that the contents of the new item must be written
+before the head index makes it available to the consumer and then instructs the
+CPU that the revised head index must be written before the consumer is woken.
+
+Note that wake_up() doesn't have to be the exact mechanism used, but whatever
+is used must guarantee a (write) memory barrier between the update of the head
+index and the change of state of the consumer, if a change of state occurs.
+
+
+THE CONSUMER
+------------
+
+The consumer will look something like this:
+
+       spin_lock(&consumer_lock);
+
+       unsigned long head = ACCESS_ONCE(buffer->head);
+       unsigned long tail = buffer->tail;
+
+       if (CIRC_CNT(head, tail, buffer->size) >= 1) {
+               /* read index before reading contents at that index */
+               smp_read_barrier_depends();
+
+               /* extract one item from the buffer */
+               struct item *item = buffer[tail];
+
+               consume_item(item);
+
+               smp_mb(); /* finish reading descriptor before incrementing tail */
+
+               buffer->tail = (tail + 1) & (buffer->size - 1);
+       }
+
+       spin_unlock(&consumer_lock);
+
+This will instruct the CPU to make sure the index is up to date before reading
+the new item, and then it shall make sure the CPU has finished reading the item
+before it writes the new tail pointer, which will erase the item.
+
+
+Note the use of ACCESS_ONCE() in both algorithms to read the opposition index.
+This prevents the compiler from discarding and reloading its cached value -
+which some compilers will do across smp_read_barrier_depends().  This isn't
+strictly needed if you can be sure that the opposition index will _only_ be
+used the once.
+
+
+===============
+FURTHER READING
+===============
+
+See also Documentation/memory-barriers.txt for a description of Linux's memory
+barrier facilities.
index b07add3467f1b4d84e07d95a43fece6b8ec7f83e..7764594778d43650afe3423055cd4bcabaf77c17 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 
 #include <linux/connector.h>
index 3bae418c6ad3d51e8597485f15ef014a553a22b2..4303614b5add04f91461453882ecc77d719b32df 100644 (file)
@@ -16,6 +16,8 @@ befs.txt
        - information about the BeOS filesystem for Linux.
 bfs.txt
        - info for the SCO UnixWare Boot Filesystem (BFS).
+ceph.txt
+       - info for the Ceph Distributed File System
 cifs.txt
        - description of the CIFS filesystem.
 coda.txt
index 57e0b80a52747c8ef9af5ddad113802e1c972c37..c0236e753bc854a5a26a9a514465e81819564ccd 100644 (file)
@@ -37,6 +37,15 @@ For Plan 9 From User Space applications (http://swtch.com/plan9)
 
        mount -t 9p `namespace`/acme /mnt/9 -o trans=unix,uname=$USER
 
+For server running on QEMU host with virtio transport:
+
+       mount -t 9p -o trans=virtio <mount_tag> /mnt/9
+
+where mount_tag is the tag associated by the server to each of the exported
+mount points. Each 9P export is seen by the client as a virtio device with an
+associated "mount_tag" property. Available mount tags can be
+seen by reading /sys/bus/virtio/drivers/9pnet_virtio/virtio<n>/mount_tag files.
+
 OPTIONS
 =======
 
@@ -47,7 +56,7 @@ OPTIONS
                        fd      - used passed file descriptors for connection
                                 (see rfdno and wfdno)
                        virtio  - connect to the next virtio channel available
-                               (from lguest or KVM with trans_virtio module)
+                               (from QEMU with trans_virtio module)
                        rdma    - connect to a specified RDMA channel
 
   uname=name   user name to attempt mount as on the remote server.  The
@@ -85,7 +94,12 @@ OPTIONS
 
   port=n       port to connect to on the remote server
 
-  noextend     force legacy mode (no 9p2000.u semantics)
+  noextend     force legacy mode (no 9p2000.u or 9p2000.L semantics)
+
+  version=name Select 9P protocol version. Valid options are:
+                       9p2000          - Legacy mode (same as noextend)
+                       9p2000.u        - Use 9P2000.u protocol
+                       9p2000.L        - Use 9P2000.L protocol
 
   dfltuid      attempt to mount as a particular uid
 
diff --git a/Documentation/filesystems/ceph.txt b/Documentation/filesystems/ceph.txt
new file mode 100644 (file)
index 0000000..0660c9f
--- /dev/null
@@ -0,0 +1,140 @@
+Ceph Distributed File System
+============================
+
+Ceph is a distributed network file system designed to provide good
+performance, reliability, and scalability.
+
+Basic features include:
+
+ * POSIX semantics
+ * Seamless scaling from 1 to many thousands of nodes
+ * High availability and reliability.  No single point of failure.
+ * N-way replication of data across storage nodes
+ * Fast recovery from node failures
+ * Automatic rebalancing of data on node addition/removal
+ * Easy deployment: most FS components are userspace daemons
+
+Also,
+ * Flexible snapshots (on any directory)
+ * Recursive accounting (nested files, directories, bytes)
+
+In contrast to cluster filesystems like GFS, OCFS2, and GPFS that rely
+on symmetric access by all clients to shared block devices, Ceph
+separates data and metadata management into independent server
+clusters, similar to Lustre.  Unlike Lustre, however, metadata and
+storage nodes run entirely as user space daemons.  Storage nodes
+utilize btrfs to store data objects, leveraging its advanced features
+(checksumming, metadata replication, etc.).  File data is striped
+across storage nodes in large chunks to distribute workload and
+facilitate high throughputs.  When storage nodes fail, data is
+re-replicated in a distributed fashion by the storage nodes themselves
+(with some minimal coordination from a cluster monitor), making the
+system extremely efficient and scalable.
+
+Metadata servers effectively form a large, consistent, distributed
+in-memory cache above the file namespace that is extremely scalable,
+dynamically redistributes metadata in response to workload changes,
+and can tolerate arbitrary (well, non-Byzantine) node failures.  The
+metadata server takes a somewhat unconventional approach to metadata
+storage to significantly improve performance for common workloads.  In
+particular, inodes with only a single link are embedded in
+directories, allowing entire directories of dentries and inodes to be
+loaded into its cache with a single I/O operation.  The contents of
+extremely large directories can be fragmented and managed by
+independent metadata servers, allowing scalable concurrent access.
+
+The system offers automatic data rebalancing/migration when scaling
+from a small cluster of just a few nodes to many hundreds, without
+requiring an administrator carve the data set into static volumes or
+go through the tedious process of migrating data between servers.
+When the file system approaches full, new nodes can be easily added
+and things will "just work."
+
+Ceph includes flexible snapshot mechanism that allows a user to create
+a snapshot on any subdirectory (and its nested contents) in the
+system.  Snapshot creation and deletion are as simple as 'mkdir
+.snap/foo' and 'rmdir .snap/foo'.
+
+Ceph also provides some recursive accounting on directories for nested
+files and bytes.  That is, a 'getfattr -d foo' on any directory in the
+system will reveal the total number of nested regular files and
+subdirectories, and a summation of all nested file sizes.  This makes
+the identification of large disk space consumers relatively quick, as
+no 'du' or similar recursive scan of the file system is required.
+
+
+Mount Syntax
+============
+
+The basic mount syntax is:
+
+ # mount -t ceph monip[:port][,monip2[:port]...]:/[subdir] mnt
+
+You only need to specify a single monitor, as the client will get the
+full list when it connects.  (However, if the monitor you specify
+happens to be down, the mount won't succeed.)  The port can be left
+off if the monitor is using the default.  So if the monitor is at
+1.2.3.4,
+
+ # mount -t ceph 1.2.3.4:/ /mnt/ceph
+
+is sufficient.  If /sbin/mount.ceph is installed, a hostname can be
+used instead of an IP address.
+
+
+
+Mount Options
+=============
+
+  ip=A.B.C.D[:N]
+       Specify the IP and/or port the client should bind to locally.
+       There is normally not much reason to do this.  If the IP is not
+       specified, the client's IP address is determined by looking at the
+       address it's connection to the monitor originates from.
+
+  wsize=X
+       Specify the maximum write size in bytes.  By default there is no
+       maximum.  Ceph will normally size writes based on the file stripe
+       size.
+
+  rsize=X
+       Specify the maximum readahead.
+
+  mount_timeout=X
+       Specify the timeout value for mount (in seconds), in the case
+       of a non-responsive Ceph file system.  The default is 30
+       seconds.
+
+  rbytes
+       When stat() is called on a directory, set st_size to 'rbytes',
+       the summation of file sizes over all files nested beneath that
+       directory.  This is the default.
+
+  norbytes
+       When stat() is called on a directory, set st_size to the
+       number of entries in that directory.
+
+  nocrc
+       Disable CRC32C calculation for data writes.  If set, the storage node
+       must rely on TCP's error correction to detect data corruption
+       in the data payload.
+
+  noasyncreaddir
+       Disable client's use its local cache to satisfy readdir
+       requests.  (This does not change correctness; the client uses
+       cached metadata only when a lease or capability ensures it is
+       valid.)
+
+
+More Information
+================
+
+For more information on Ceph, see the home page at
+       http://ceph.newdream.net/
+
+The Linux kernel client source tree is available at
+       git://ceph.newdream.net/git/ceph-client.git
+       git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git
+
+and the source for the full system is at
+       git://ceph.newdream.net/git/ceph.git
index 3015da0c6b2a253c4a1b65559a8a8ec82b24e3e9..fe09a2cb1858de038b39746bdc862af3f6dc21bc 100644 (file)
@@ -82,11 +82,13 @@ tmpfs has a mount option to set the NUMA memory allocation policy for
 all files in that instance (if CONFIG_NUMA is enabled) - which can be
 adjusted on the fly via 'mount -o remount ...'
 
-mpol=default             prefers to allocate memory from the local node
+mpol=default             use the process allocation policy
+                         (see set_mempolicy(2))
 mpol=prefer:Node         prefers to allocate memory from the given Node
 mpol=bind:NodeList       allocates memory only from nodes in NodeList
 mpol=interleave          prefers to allocate from each node in turn
 mpol=interleave:NodeList allocates from each node of NodeList in turn
+mpol=local              prefers to allocate memory from the local node
 
 NodeList format is a comma-separated list of decimal numbers and ranges,
 a range being two hyphen-separated decimal numbers, the smallest and
@@ -134,3 +136,5 @@ Author:
    Christoph Rohland <cr@sap.com>, 1.12.01
 Updated:
    Hugh Dickins, 4 June 2007
+Updated:
+   KOSAKI Motohiro, 16 Mar 2010
index 35c9b51d20ea850b9ae58f16413e5a7595bcdb45..dd5806f4fcc448cdbc7d369e5bcd225d5aa2e0be 100644 (file)
@@ -291,6 +291,7 @@ Code  Seq#(hex)     Include File            Comments
 0x92   00-0F   drivers/usb/mon/mon_bin.c
 0x93   60-7F   linux/auto_fs.h
 0x94   all     fs/btrfs/ioctl.h
+0x97   00-7F   fs/ceph/ioctl.h         Ceph file system
 0x99   00-0F                           537-Addinboard driver
                                        <mailto:buk@buks.ipn.de>
 0xA0   all     linux/sdp/sdp.h         Industrial Device Project
index bdb13817e1e9ebc0ad667482deb4e2107361961b..3ab2472509cbbc86996b31d809543ca2dd93f2c9 100644 (file)
@@ -59,37 +59,56 @@ nice to have in other objects.  The C language does not allow for the
 direct expression of inheritance, so other techniques - such as structure
 embedding - must be used.
 
-So, for example, the UIO code has a structure that defines the memory
-region associated with a uio device:
+(As an aside, for those familiar with the kernel linked list implementation,
+this is analogous as to how "list_head" structs are rarely useful on
+their own, but are invariably found embedded in the larger objects of
+interest.)
 
-struct uio_mem {
+So, for example, the UIO code in drivers/uio/uio.c has a structure that
+defines the memory region associated with a uio device:
+
+    struct uio_map {
        struct kobject kobj;
-       unsigned long addr;
-       unsigned long size;
-       int memtype;
-       void __iomem *internal_addr;
-};
+       struct uio_mem *mem;
+    };
 
-If you have a struct uio_mem structure, finding its embedded kobject is
+If you have a struct uio_map structure, finding its embedded kobject is
 just a matter of using the kobj member.  Code that works with kobjects will
 often have the opposite problem, however: given a struct kobject pointer,
 what is the pointer to the containing structure?  You must avoid tricks
 (such as assuming that the kobject is at the beginning of the structure)
 and, instead, use the container_of() macro, found in <linux/kernel.h>:
 
-       container_of(pointer, type, member)
+    container_of(pointer, type, member)
+
+where:
+
+  * "pointer" is the pointer to the embedded kobject,
+  * "type" is the type of the containing structure, and
+  * "member" is the name of the structure field to which "pointer" points.
+
+The return value from container_of() is a pointer to the corresponding
+container type. So, for example, a pointer "kp" to a struct kobject
+embedded *within* a struct uio_map could be converted to a pointer to the
+*containing* uio_map structure with:
+
+    struct uio_map *u_map = container_of(kp, struct uio_map, kobj);
+
+For convenience, programmers often define a simple macro for "back-casting"
+kobject pointers to the containing type.  Exactly this happens in the
+earlier drivers/uio/uio.c, as you can see here:
+
+    struct uio_map {
+        struct kobject kobj;
+        struct uio_mem *mem;
+    };
 
-where pointer is the pointer to the embedded kobject, type is the type of
-the containing structure, and member is the name of the structure field to
-which pointer points.  The return value from container_of() is a pointer to
-the given type. So, for example, a pointer "kp" to a struct kobject
-embedded within a struct uio_mem could be converted to a pointer to the
-containing uio_mem structure with:
+    #define to_map(map) container_of(map, struct uio_map, kobj)
 
-    struct uio_mem *u_mem = container_of(kp, struct uio_mem, kobj);
+where the macro argument "map" is a pointer to the struct kobject in
+question.  That macro is subsequently invoked with:
 
-Programmers often define a simple macro for "back-casting" kobject pointers
-to the containing type.
+    struct uio_map *map = to_map(kobj);
 
 
 Initialization of kobjects
@@ -387,4 +406,5 @@ called, and the objects in the former circle release each other.
 Example code to copy from
 
 For a more complete example of using ksets and kobjects properly, see the
-sample/kobject/kset-example.c code.
+example programs samples/kobject/{kobject-example.c,kset-example.c},
+which will be built as loadable modules if you select CONFIG_SAMPLE_KOBJECT.
index 7f5809eddee62eaf524103eeda485f5e553d5a01..631ad2f1b229c1d020a9a8b746d8f6cbe72f4531 100644 (file)
@@ -3,6 +3,7 @@
                         ============================
 
 By: David Howells <dhowells@redhat.com>
+    Paul E. McKenney <paulmck@linux.vnet.ibm.com>
 
 Contents:
 
@@ -60,6 +61,10 @@ Contents:
 
      - And then there's the Alpha.
 
+ (*) Example uses.
+
+     - Circular buffers.
+
  (*) References.
 
 
@@ -2226,6 +2231,21 @@ The Alpha defines the Linux kernel's memory barrier model.
 See the subsection on "Cache Coherency" above.
 
 
+============
+EXAMPLE USES
+============
+
+CIRCULAR BUFFERS
+----------------
+
+Memory barriers can be used to implement circular buffering without the need
+of a lock to serialise the producer with the consumer.  See:
+
+       Documentation/circular-buffers.txt
+
+for details.
+
+
 ==========
 REFERENCES
 ==========
diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
new file mode 100644 (file)
index 0000000..7ee770b
--- /dev/null
@@ -0,0 +1,143 @@
+       STMicroelectronics 10/100/1000 Synopsys Ethernet driver
+
+Copyright (C) 2007-2010  STMicroelectronics Ltd
+Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
+
+This is the driver for the MAC 10/100/1000 on-chip Ethernet controllers
+(Synopsys IP blocks); it has been fully tested on STLinux platforms.
+
+Currently this network device driver is for all STM embedded MAC/GMAC
+(7xxx SoCs).
+
+DWC Ether MAC 10/100/1000 Universal version 3.41a and DWC Ether MAC 10/100
+Universal version 4.0 have been used for developing the first code
+implementation.
+
+Please, for more information also visit: www.stlinux.com
+
+1) Kernel Configuration
+The kernel configuration option is STMMAC_ETH:
+ Device Drivers ---> Network device support ---> Ethernet (1000 Mbit) --->
+ STMicroelectronics 10/100/1000 Ethernet driver (STMMAC_ETH)
+
+2) Driver parameters list:
+       debug: message level (0: no output, 16: all);
+       phyaddr: to manually provide the physical address to the PHY device;
+       dma_rxsize: DMA rx ring size;
+       dma_txsize: DMA tx ring size;
+       buf_sz: DMA buffer size;
+       tc: control the HW FIFO threshold;
+       tx_coe: Enable/Disable Tx Checksum Offload engine;
+       watchdog: transmit timeout (in milliseconds);
+       flow_ctrl: Flow control ability [on/off];
+       pause: Flow Control Pause Time;
+       tmrate: timer period (only if timer optimisation is configured).
+
+3) Command line options
+Driver parameters can be also passed in command line by using:
+       stmmaceth=dma_rxsize:128,dma_txsize:512
+
+4) Driver information and notes
+
+4.1) Transmit process
+The xmit method is invoked when the kernel needs to transmit a packet; it sets
+the descriptors in the ring and informs the DMA engine that there is a packet
+ready to be transmitted.
+Once the controller has finished transmitting the packet, an interrupt is
+triggered; So the driver will be able to release the socket buffers.
+By default, the driver sets the NETIF_F_SG bit in the features field of the
+net_device structure enabling the scatter/gather feature.
+
+4.2) Receive process
+When one or more packets are received, an interrupt happens. The interrupts
+are not queued so the driver has to scan all the descriptors in the ring during
+the receive process.
+This is based on NAPI so the interrupt handler signals only if there is work to be
+done, and it exits.
+Then the poll method will be scheduled at some future point.
+The incoming packets are stored, by the DMA, in a list of pre-allocated socket
+buffers in order to avoid the memcpy (Zero-copy).
+
+4.3) Timer-Driver Interrupt
+Instead of having the device that asynchronously notifies the frame receptions, the
+driver configures a timer to generate an interrupt at regular intervals.
+Based on the granularity of the timer, the frames that are received by the device
+will experience different levels of latency. Some NICs have dedicated timer
+device to perform this task. STMMAC can use either the RTC device or the TMU
+channel 2  on STLinux platforms.
+The timers frequency can be passed to the driver as parameter; when change it,
+take care of both hardware capability and network stability/performance impact.
+Several performance tests on STM platforms showed this optimisation allows to spare
+the CPU while having the maximum throughput.
+
+4.4) WOL
+Wake up on Lan feature through Magic Frame is only supported for the GMAC
+core.
+
+4.5) DMA descriptors
+Driver handles both normal and enhanced descriptors. The latter has been only
+tested on DWC Ether MAC 10/100/1000 Universal version 3.41a.
+
+4.6) Ethtool support
+Ethtool is supported. Driver statistics and internal errors can be taken using:
+ethtool -S ethX command. It is possible to dump registers etc.
+
+4.7) Jumbo and Segmentation Offloading
+Jumbo frames are supported and tested for the GMAC.
+The GSO has been also added but it's performed in software.
+LRO is not supported.
+
+4.8) Physical
+The driver is compatible with PAL to work with PHY and GPHY devices.
+
+4.9) Platform information
+Several information came from the platform; please refer to the
+driver's Header file in include/linux directory.
+
+struct plat_stmmacenet_data {
+        int bus_id;
+        int pbl;
+        int has_gmac;
+        void (*fix_mac_speed)(void *priv, unsigned int speed);
+        void (*bus_setup)(unsigned long ioaddr);
+#ifdef CONFIG_STM_DRIVERS
+        struct stm_pad_config *pad_config;
+#endif
+        void *bsp_priv;
+};
+
+Where:
+- pbl (Programmable Burst Length) is maximum number of
+  beats to be transferred in one DMA transaction.
+  GMAC also enables the 4xPBL by default.
+- fix_mac_speed and bus_setup are used to configure internal target
+  registers (on STM platforms);
+- has_gmac: GMAC core is on board (get it at run-time in the next step);
+- bus_id: bus identifier.
+
+struct plat_stmmacphy_data {
+        int bus_id;
+        int phy_addr;
+        unsigned int phy_mask;
+        int interface;
+        int (*phy_reset)(void *priv);
+        void *priv;
+};
+
+Where:
+- bus_id: bus identifier;
+- phy_addr: physical address used for the attached phy device;
+            set it to -1 to get it at run-time;
+- interface: physical MII interface mode;
+- phy_reset: hook to reset HW function.
+
+TODO:
+- Continue to make the driver more generic and suitable for other Synopsys
+  Ethernet controllers used on other architectures (i.e. ARM).
+- 10G controllers are not supported.
+- MAC uses Normal descriptors and GMAC uses enhanced ones.
+  This is a limit that should be reviewed. MAC could want to
+  use the enhanced structure.
+- Checksumming: Rx/Tx csum is done in HW in case of GMAC only.
+- Review the timer optimisation code to use an embedded device that seems to be
+  available in new chip generations.
index 6e37be1eeb2d2cc190780db3d01829acabbf950f..4f8930263dd98035593628228bcfad8b4bcddee7 100644 (file)
@@ -21,6 +21,15 @@ Required properties:
 - fsl,qe-num-snums: define how many serial number(SNUM) the QE can use for the
   threads.
 
+Optional properties:
+- fsl,firmware-phandle:
+    Usage: required only if there is no fsl,qe-firmware child node
+    Value type: <phandle>
+    Definition: Points to a firmware node (see "QE Firmware Node" below)
+        that contains the firmware that should be uploaded for this QE.
+        The compatible property for the firmware node should say,
+        "fsl,qe-firmware".
+
 Recommended properties
 - brg-frequency : the internal clock source frequency for baud-rate
   generators in Hz.
@@ -59,3 +68,48 @@ Example:
                reg = <0 c000>;
        };
      };
+
+* QE Firmware Node
+
+This node defines a firmware binary that is embedded in the device tree, for
+the purpose of passing the firmware from bootloader to the kernel, or from
+the hypervisor to the guest.
+
+The firmware node itself contains the firmware binary contents, a compatible
+property, and any firmware-specific properties.  The node should be placed
+inside a QE node that needs it.  Doing so eliminates the need for a
+fsl,firmware-phandle property.  Other QE nodes that need the same firmware
+should define an fsl,firmware-phandle property that points to the firmware node
+in the first QE node.
+
+The fsl,firmware property can be specified in the DTS (possibly using incbin)
+or can be inserted by the boot loader at boot time.
+
+Required properties:
+  - compatible
+      Usage: required
+      Value type: <string>
+      Definition: A standard property.  Specify a string that indicates what
+          kind of firmware it is.  For QE, this should be "fsl,qe-firmware".
+
+   - fsl,firmware
+      Usage: required
+      Value type: <prop-encoded-array>, encoded as an array of bytes
+      Definition: A standard property.  This property contains the firmware
+          binary "blob".
+
+Example:
+       qe1@e0080000 {
+               compatible = "fsl,qe";
+               qe_firmware:qe-firmware {
+                       compatible = "fsl,qe-firmware";
+                       fsl,firmware = [0x70 0xcd 0x00 0x00 0x01 0x46 0x45 ...];
+               };
+               ...
+       };
+
+       qe2@e0090000 {
+               compatible = "fsl,qe";
+               fsl,firmware-phandle = <&qe_firmware>;
+               ...
+       };
index 991c26a6ef64fcfdef0fc870d3ed404f55751407..db0cb228d64aa4a80a4fe380be3e46439de810e6 100644 (file)
@@ -63,9 +63,9 @@ way to perform a busy wait is:
         cpu_relax();
 
 The cpu_relax() call can lower CPU power consumption or yield to a
-hyperthreaded twin processor; it also happens to serve as a memory barrier,
-so, once again, volatile is unnecessary.  Of course, busy-waiting is
-generally an anti-social act to begin with.
+hyperthreaded twin processor; it also happens to serve as a compiler
+barrier, so, once again, volatile is unnecessary.  Of course, busy-
+waiting is generally an anti-social act to begin with.
 
 There are still a few rare situations where volatile makes sense in the
 kernel:
index 382eaa4d0068540f624ce77c88b266003f2a082a..3d29fa3898883a51626b527ab0f0b21badb815ce 100644 (file)
@@ -797,12 +797,12 @@ M:        Michael Petchkovsky <mkpetch@internode.on.net>
 S:     Maintained
 
 ARM/NOMADIK ARCHITECTURE
-M:     Alessandro Rubini <rubini@unipv.it>
-M:     STEricsson <STEricsson_nomadik_linux@list.st.com>
-L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
-S:     Maintained
-F:     arch/arm/mach-nomadik/
-F:     arch/arm/plat-nomadik/
+M:     Alessandro Rubini <rubini@unipv.it>
+M:     STEricsson <STEricsson_nomadik_linux@list.st.com>
+L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:     Maintained
+F:     arch/arm/mach-nomadik/
+F:     arch/arm/plat-nomadik/
 
 ARM/OPENMOKO NEO FREERUNNER (GTA02) MACHINE SUPPORT
 M:     Nelson Castillo <arhuaco@freaks-unidos.net>
@@ -1441,6 +1441,15 @@ F:       arch/powerpc/include/asm/spu*.h
 F:     arch/powerpc/oprofile/*cell*
 F:     arch/powerpc/platforms/cell/
 
+CEPH DISTRIBUTED FILE SYSTEM CLIENT
+M:     Sage Weil <sage@newdream.net>
+L:     ceph-devel@vger.kernel.org
+W:     http://ceph.newdream.net/
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git
+S:     Supported
+F:     Documentation/filesystems/ceph.txt
+F:     fs/ceph
+
 CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM:
 M:     David Vrabel <david.vrabel@csr.com>
 L:     linux-usb@vger.kernel.org
@@ -1917,17 +1926,17 @@ F:      drivers/scsi/dpt*
 F:     drivers/scsi/dpt/
 
 DRBD DRIVER
-P:     Philipp Reisner
-P:     Lars Ellenberg
-M:     drbd-dev@lists.linbit.com
-L:     drbd-user@lists.linbit.com
-W:     http://www.drbd.org
-T:     git git://git.drbd.org/linux-2.6-drbd.git drbd
-T:     git git://git.drbd.org/drbd-8.3.git
-S:     Supported
-F:     drivers/block/drbd/
-F:     lib/lru_cache.c
-F:     Documentation/blockdev/drbd/
+P:     Philipp Reisner
+P:     Lars Ellenberg
+M:     drbd-dev@lists.linbit.com
+L:     drbd-user@lists.linbit.com
+W:     http://www.drbd.org
+T:     git git://git.drbd.org/linux-2.6-drbd.git drbd
+T:     git git://git.drbd.org/drbd-8.3.git
+S:     Supported
+F:     drivers/block/drbd/
+F:     lib/lru_cache.c
+F:     Documentation/blockdev/drbd/
 
 DRIVER CORE, KOBJECTS, AND SYSFS
 M:     Greg Kroah-Hartman <gregkh@suse.de>
@@ -3074,6 +3083,7 @@ F:        include/scsi/*iscsi*
 ISDN SUBSYSTEM
 M:     Karsten Keil <isdn@linux-pingi.de>
 L:     isdn4linux@listserv.isdn4linux.de (subscribers-only)
+L:     netdev@vger.kernel.org
 W:     http://www.isdn4linux.de
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/kkeil/isdn-2.6.git
 S:     Maintained
@@ -3260,6 +3270,16 @@ S:       Maintained
 F:     include/linux/kexec.h
 F:     kernel/kexec.c
 
+KEYS/KEYRINGS:
+M:     David Howells <dhowells@redhat.com>
+L:     keyrings@linux-nfs.org
+S:     Maintained
+F:     Documentation/keys.txt
+F:     include/linux/key.h
+F:     include/linux/key-type.h
+F:     include/keys/
+F:     security/keys/
+
 KGDB
 M:     Jason Wessel <jason.wessel@windriver.com>
 L:     kgdb-bugreport@lists.sourceforge.net
@@ -3509,8 +3529,8 @@ F:        drivers/scsi/sym53c8xx_2/
 LTP (Linux Test Project)
 M:     Rishikesh K Rajak <risrajak@linux.vnet.ibm.com>
 M:     Garrett Cooper <yanegomi@gmail.com>
-M:     Mike Frysinger <vapier@gentoo.org>
-M:     Subrata Modak <subrata@linux.vnet.ibm.com>
+M:     Mike Frysinger <vapier@gentoo.org>
+M:     Subrata Modak <subrata@linux.vnet.ibm.com>
 L:     ltp-list@lists.sourceforge.net (subscribers-only)
 W:     http://ltp.sourceforge.net/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/galak/ltp.git
@@ -5414,7 +5434,6 @@ S:        Maintained
 F:     sound/soc/codecs/twl4030*
 
 TIPC NETWORK LAYER
-M:     Per Liden <per.liden@ericsson.com>
 M:     Jon Maloy <jon.maloy@ericsson.com>
 M:     Allan Stephens <allan.stephens@windriver.com>
 L:     tipc-discussion@lists.sourceforge.net
@@ -6192,7 +6211,7 @@ F:        arch/x86/
 X86 PLATFORM DRIVERS
 M:     Matthew Garrett <mjg@redhat.com>
 L:     platform-driver-x86@vger.kernel.org
-T:      git git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86.git
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86.git
 S:     Maintained
 F:     drivers/platform/x86
 
index 08ff02da7ce365dc4a3d88964deda0147e1b8001..67c1001cfbf5cee56f16a31bc37b02bffe3ccc14 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 34
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc3
 NAME = Man-Eating Seals of Antiquity
 
 # *DOCUMENTATION*
index 3c8d1b25c66105b3fb34f9b693c712d9b3d05d52..be61670d40963c78fa52e9d2cfef36b15abafe8f 100644 (file)
@@ -8,6 +8,7 @@
  * based significantly on the arch/alpha/boot/main.c of Linus Torvalds
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <generated/utsrelease.h>
 #include <linux/mm.h>
index ade3f129dc2722e26168495bdc28066d24fcd609..c98865f21423016cd8220a574da6d69ca5cc42c4 100644 (file)
@@ -10,6 +10,7 @@
  * and the decompression code from MILO.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <generated/utsrelease.h>
 #include <linux/mm.h>
index 644b7db55438f4f1d1b8136bd9f680bbcf4f75a8..ded57d9a80e1adee23896c9a296476e383bcc2c5 100644 (file)
@@ -6,6 +6,7 @@
  * This file is the bootloader for the Linux/AXP kernel
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <generated/utsrelease.h>
 #include <linux/mm.h>
index 3047a1b3a517160f4c016c032f30549e3c20ca19..3ff9a957a25cdc8b89e3eda0656e54a5a3af79ec 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index 30d55fe7aaf6a60333d9c0b2c4e5ce3925ecb299..dad300fa14ce3778d3e89419d34fbb8498bdbd64 100644 (file)
@@ -12,7 +12,6 @@
 #define __ALPHA_MARVEL__H__
 
 #include <linux/types.h>
-#include <linux/pci.h>
 #include <linux/spinlock.h>
 
 #include <asm/compiler.h>
index acf55b48347207550edadb3691081bf1df1d251e..21ac53383b37eca3cea4e4ff3ac9b0c6d7989d67 100644 (file)
@@ -6,7 +6,6 @@
 #define MCPCIA_ONE_HAE_WINDOW 1
 
 #include <linux/types.h>
-#include <linux/pci.h>
 #include <asm/compiler.h>
 
 /*
index a17f6f33b68ec6f339199ed4371307cf20999d2d..8cf79d1219e159ccda9985df9f4511c04dc78fc1 100644 (file)
@@ -2,7 +2,6 @@
 #define __ALPHA_TITAN__H__
 
 #include <linux/types.h>
-#include <linux/pci.h>
 #include <asm/compiler.h>
 
 /*
index 58d4fe48742c49c09b03657c97d6269d7e930d02..8e39ecf09419c890c8b8ec4e30b44e53eff3a11a 100644 (file)
@@ -2,7 +2,6 @@
 #define __ALPHA_TSUNAMI__H__
 
 #include <linux/types.h>
-#include <linux/pci.h>
 #include <asm/compiler.h>
 
 /*
index 5f2cf23c4648f9d7173fe047448459fc8ff6d752..7f912ba3d9ad79ee9f333f14dfcd0f3dc7bb59c5 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/irq.h>
index 53c213f70fcbc8151b42fea8b50998bf509e5fea..de9d397178085a9b7cb4482d487e2f9379824bbc 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/utsname.h>
 #include <linux/time.h>
@@ -37,6 +36,7 @@
 #include <linux/uio.h>
 #include <linux/vfs.h>
 #include <linux/rcupdate.h>
+#include <linux/slab.h>
 
 #include <asm/fpu.h>
 #include <asm/io.h>
index 823a540f9f5b15b51fd84c300c9d9526598c3847..246100ef07c2474fa5213163b0e1b899d10198a6 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 #include <linux/capability.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
index 6ea822e7f724dfbbf26e4b0692e7377ee58a0c6b..d979e7c7bc4b898be20d445c36e8b93ecb990ffa 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 
 static int hose_mmap_page_range(struct pci_controller *hose,
index ce9e54c887fa01aa9c15583bb246d48e1b627f23..d1dbd9acd1df47d8bbf2046720a3b5c2792d4076 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/bootmem.h>
 #include <linux/scatterlist.h>
 #include <linux/log2.h>
index 289039bb6bb2a07f91b81b2848d035cc39083d88..395a464353b8e48ac4e18ecb725fc0a960809898 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/time.h>
 #include <linux/major.h>
@@ -28,6 +27,7 @@
 #include <linux/reboot.h>
 #include <linux/tty.h>
 #include <linux/console.h>
+#include <linux/slab.h>
 
 #include <asm/reg.h>
 #include <asm/uaccess.h>
index 9acadc6b16a0f8c53f60eb6e3f3019c5e1cbb3d1..baa903602f6a03c86a8d841ba3ce751c3ece0cb9 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
-#include <linux/slab.h>
 #include <linux/security.h>
 #include <linux/signal.h>
 
index bca5bda90cde75407940f0f238d3099c29ca0567..0435921d41c6be15370b58210d8aaaaa2866ea9a 100644 (file)
@@ -3,7 +3,6 @@
  */
 #include <linux/kernel.h>
 
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 2636cc028d06af7d120282eda93c8ea32a6e41af..3e6a2893af9f6e87122ca0e872ec95282cdf3fde 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <linux/kernel.h>
 
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index dbbf04f9230ed0890011e8c63a2db30f8e8d94fe..4afc1a1e2e5a055ccda3d11a7d2f1b96c3670235 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
index d64e1e497e76a1edd304d4036f3f1d7a5a41c83a..4026502ab7077d639b37de28a07dafcc08cb94cd 100644 (file)
@@ -224,7 +224,7 @@ static void
 dp264_device_interrupt(unsigned long vector)
 {
 #if 1
-       printk("dp264_device_interrupt: NOT IMPLEMENTED YET!! \n");
+       printk("dp264_device_interrupt: NOT IMPLEMENTED YET!!\n");
 #else
        unsigned long pld;
        unsigned int i;
index 288053342c83b5e951df1e4a68eb81ba2bd3ad62..9008d0f20c534dcb4ed20a73e2c5f21581df393a 100644 (file)
@@ -171,7 +171,7 @@ titan_set_irq_affinity(unsigned int irq, const struct cpumask *affinity)
 static void
 titan_device_interrupt(unsigned long vector)
 {
-       printk("titan_device_interrupt: NOT IMPLEMENTED YET!! \n");
+       printk("titan_device_interrupt: NOT IMPLEMENTED YET!!\n");
 }
 
 static void 
index 6ee7655b7568bf36719f2447e389831244721f01..b14f015008ada5e90d580b0589d4ff5144a1602e 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kallsyms.h>
+#include <linux/ratelimit.h>
 
 #include <asm/gentrap.h>
 #include <asm/uaccess.h>
@@ -771,8 +772,7 @@ asmlinkage void
 do_entUnaUser(void __user * va, unsigned long opcode,
              unsigned long reg, struct pt_regs *regs)
 {
-       static int cnt = 0;
-       static unsigned long last_time;
+       static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
 
        unsigned long tmp1, tmp2, tmp3, tmp4;
        unsigned long fake_reg, *reg_addr = &fake_reg;
@@ -783,15 +783,11 @@ do_entUnaUser(void __user * va, unsigned long opcode,
           with the unaliged access.  */
 
        if (!test_thread_flag (TIF_UAC_NOPRINT)) {
-               if (cnt >= 5 && time_after(jiffies, last_time + 5 * HZ)) {
-                       cnt = 0;
-               }
-               if (++cnt < 5) {
+               if (__ratelimit(&ratelimit)) {
                        printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
                               current->comm, task_pid_nr(current),
                               regs->pc - 4, va, opcode, reg);
                }
-               last_time = jiffies;
        }
        if (test_thread_flag (TIF_UAC_SIGBUS))
                goto give_sigbus;
index a0902c20d6778edce8dd57deccd70ec7c54a36b8..86425ab53bf5d1afa9bd0d4dddcb2e8543b621e4 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h> /* max_low_pfn */
 #include <linux/vmalloc.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 6416d5b5020d221514b7d8d8eca6bbb3ac2be991..dba4c1da63ed84fffca55fcf6ab44c75064d1654 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/string.h>
 #include <linux/mutex.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <asm/clkdev.h>
 #include <mach/clkdev.h>
index ee1d3b85eb659376c5daa37b7bf07396857b85fd..7974baacafcea74ec055a46ee0f6cea496f24e6f 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/irq.h>
index 90ae00b631c269c4ad5c15117055335e092865c1..9dff07c80ddb2eceec0a864275023a8d7a606636 100644 (file)
@@ -290,7 +290,7 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state)
        save->LCM_GPO     = locomo_readl(lchip->base + LOCOMO_GPO);     /* GPIO */
        locomo_writel(0x00, lchip->base + LOCOMO_GPO);
        save->LCM_SPICT   = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPICT);      /* SPI */
-       locomo_writel(0x40, lchip->base + LOCOMO_SPICT);
+       locomo_writel(0x40, lchip->base + LOCOMO_SPI + LOCOMO_SPICT);
        save->LCM_GPE     = locomo_readl(lchip->base + LOCOMO_GPE);     /* GPIO */
        locomo_writel(0x00, lchip->base + LOCOMO_GPE);
        save->LCM_ASD     = locomo_readl(lchip->base + LOCOMO_ASD);     /* ADSTART */
@@ -418,7 +418,7 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
        /* Longtime timer */
        locomo_writel(0, lchip->base + LOCOMO_LTINT);
        /* SPI */
-       locomo_writel(0, lchip->base + LOCOMO_SPIIE);
+       locomo_writel(0, lchip->base + LOCOMO_SPI + LOCOMO_SPIIE);
 
        locomo_writel(6 + 8 + 320 + 30 - 10, lchip->base + LOCOMO_ASD);
        r = locomo_readl(lchip->base + LOCOMO_ASD);
@@ -707,7 +707,7 @@ void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int
        udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
        if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) {   /* High is error */
                printk(KERN_WARNING "locomo: m62332_senddata Error 1\n");
-               return;
+               goto out;
        }
 
        /* Send Sub address (LSB is channel select) */
@@ -735,7 +735,7 @@ void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int
        udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
        if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) {   /* High is error */
                printk(KERN_WARNING "locomo: m62332_senddata Error 2\n");
-               return;
+               goto out;
        }
 
        /* Send DAC data */
@@ -760,9 +760,9 @@ void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int
        udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
        if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) {   /* High is error */
                printk(KERN_WARNING "locomo: m62332_senddata Error 3\n");
-               return;
        }
 
+out:
        /* stop */
        r = locomo_readl(mapbase + LOCOMO_DAC);
        r &=  ~(LOCOMO_DAC_SCLOEB);
index 72da7e045c6b306e4d2d40bbad1db22a603f4ed7..0d08d4170b64d08f2206ce292489a917a8cb0e99 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/glue.h>
 #include <asm/shmparam.h>
 #include <asm/cachetype.h>
+#include <asm/outercache.h>
 
 #define CACHE_COLOUR(vaddr)    ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
 
@@ -219,12 +220,6 @@ struct cpu_cache_fns {
        void (*dma_flush_range)(const void *, const void *);
 };
 
-struct outer_cache_fns {
-       void (*inv_range)(unsigned long, unsigned long);
-       void (*clean_range)(unsigned long, unsigned long);
-       void (*flush_range)(unsigned long, unsigned long);
-};
-
 /*
  * Select the calling method
  */
@@ -281,37 +276,6 @@ extern void dmac_flush_range(const void *, const void *);
 
 #endif
 
-#ifdef CONFIG_OUTER_CACHE
-
-extern struct outer_cache_fns outer_cache;
-
-static inline void outer_inv_range(unsigned long start, unsigned long end)
-{
-       if (outer_cache.inv_range)
-               outer_cache.inv_range(start, end);
-}
-static inline void outer_clean_range(unsigned long start, unsigned long end)
-{
-       if (outer_cache.clean_range)
-               outer_cache.clean_range(start, end);
-}
-static inline void outer_flush_range(unsigned long start, unsigned long end)
-{
-       if (outer_cache.flush_range)
-               outer_cache.flush_range(start, end);
-}
-
-#else
-
-static inline void outer_inv_range(unsigned long start, unsigned long end)
-{ }
-static inline void outer_clean_range(unsigned long start, unsigned long end)
-{ }
-static inline void outer_flush_range(unsigned long start, unsigned long end)
-{ }
-
-#endif
-
 /*
  * Copy user data from/to a page which is mapped into a different
  * processes address space.  Really, we want to allow our "user
index 7a0690da5e63235b6a8b1345adc2f396b29287c8..b56c1389b6fa49da16bb940a04931480a4466c84 100644 (file)
@@ -13,6 +13,7 @@
 #define __ASM_CLKDEV_H
 
 struct clk;
+struct device;
 
 struct clk_lookup {
        struct list_head        node;
index 328f14a8b79034a3d71e713780a0d8caed9279d6..237282f7c762f3056b2ce76ab1a0e18d75a1499c 100644 (file)
@@ -17,6 +17,7 @@
 
 #ifndef __ASSEMBLY__
 struct irqaction;
+struct pt_regs;
 extern void migrate_irqs(void);
 
 extern void asm_do_IRQ(unsigned int, struct pt_regs *);
diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
new file mode 100644 (file)
index 0000000..25f76ba
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * arch/arm/include/asm/outercache.h
+ *
+ * Copyright (C) 2010 ARM Ltd.
+ * Written by Catalin Marinas <catalin.marinas@arm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __ASM_OUTERCACHE_H
+#define __ASM_OUTERCACHE_H
+
+struct outer_cache_fns {
+       void (*inv_range)(unsigned long, unsigned long);
+       void (*clean_range)(unsigned long, unsigned long);
+       void (*flush_range)(unsigned long, unsigned long);
+#ifdef CONFIG_OUTER_CACHE_SYNC
+       void (*sync)(void);
+#endif
+};
+
+#ifdef CONFIG_OUTER_CACHE
+
+extern struct outer_cache_fns outer_cache;
+
+static inline void outer_inv_range(unsigned long start, unsigned long end)
+{
+       if (outer_cache.inv_range)
+               outer_cache.inv_range(start, end);
+}
+static inline void outer_clean_range(unsigned long start, unsigned long end)
+{
+       if (outer_cache.clean_range)
+               outer_cache.clean_range(start, end);
+}
+static inline void outer_flush_range(unsigned long start, unsigned long end)
+{
+       if (outer_cache.flush_range)
+               outer_cache.flush_range(start, end);
+}
+
+#else
+
+static inline void outer_inv_range(unsigned long start, unsigned long end)
+{ }
+static inline void outer_clean_range(unsigned long start, unsigned long end)
+{ }
+static inline void outer_flush_range(unsigned long start, unsigned long end)
+{ }
+
+#endif
+
+#ifdef CONFIG_OUTER_CACHE_SYNC
+static inline void outer_sync(void)
+{
+       if (outer_cache.sync)
+               outer_cache.sync();
+}
+#else
+static inline void outer_sync(void)
+{ }
+#endif
+
+#endif /* __ASM_OUTERCACHE_H */
index ca88e6a84707350bad0b1ab3bd7eefcd116be506..4ace45ec3ef84f5d15d72db4b96f89a5e87fa3be 100644 (file)
@@ -60,6 +60,8 @@
 #include <linux/linkage.h>
 #include <linux/irqflags.h>
 
+#include <asm/outercache.h>
+
 #define __exception    __attribute__((section(".exception.text")))
 
 struct thread_info;
@@ -137,10 +139,12 @@ extern unsigned int user_debug;
 #define dmb() __asm__ __volatile__ ("" : : : "memory")
 #endif
 
-#if __LINUX_ARM_ARCH__ >= 7 || defined(CONFIG_SMP)
-#define mb()           dmb()
+#ifdef CONFIG_ARCH_HAS_BARRIERS
+#include <mach/barriers.h>
+#elif __LINUX_ARM_ARCH__ >= 7 || defined(CONFIG_SMP)
+#define mb()           do { dsb(); outer_sync(); } while (0)
 #define rmb()          dmb()
-#define wmb()          dmb()
+#define wmb()          mb()
 #else
 #define mb()   do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
 #define rmb()  do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
@@ -152,9 +156,9 @@ extern unsigned int user_debug;
 #define smp_rmb()      barrier()
 #define smp_wmb()      barrier()
 #else
-#define smp_mb()       mb()
-#define smp_rmb()      rmb()
-#define smp_wmb()      wmb()
+#define smp_mb()       dmb()
+#define smp_rmb()      dmb()
+#define smp_wmb()      dmb()
 #endif
 
 #define read_barrier_depends()         do { } while(0)
index b7cb45bb91e8f1cb80eeb18bb05d477aa57fcdc1..3b3d2c80509c0bb4c3499f944414a11425f6e5e6 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/smp.h>
 #include <linux/init.h>
index 60c62c377fa91bffe0de06e14a3b8a4187343240..2ba7deb3072e5962c6cd3de55d4a2ed2594c1589 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/kprobes.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/stop_machine.h>
 #include <linux/stringify.h>
 #include <asm/traps.h>
@@ -393,6 +394,14 @@ void __kprobes jprobe_return(void)
                /*
                 * Setup an empty pt_regs. Fill SP and PC fields as
                 * they're needed by longjmp_break_handler.
+                *
+                * We allocate some slack between the original SP and start of
+                * our fabricated regs. To be precise we want to have worst case
+                * covered which is STMFD with all 16 regs so we allocate 2 *
+                * sizeof(struct_pt_regs)).
+                *
+                * This is to prevent any simulated instruction from writing
+                * over the regs when they are accessing the stack.
                 */
                "sub    sp, %0, %1              \n\t"
                "ldr    r0, ="__stringify(JPROBE_MAGIC_ADDR)"\n\t"
@@ -410,7 +419,7 @@ void __kprobes jprobe_return(void)
                "ldmia  sp, {r0 - pc}           \n\t"
                :
                : "r" (kcb->jprobe_saved_regs.ARM_sp),
-                 "I" (sizeof(struct pt_regs)),
+                 "I" (sizeof(struct pt_regs) * 2),
                  "J" (offsetof(struct pt_regs, ARM_sp)),
                  "J" (offsetof(struct pt_regs, ARM_pc)),
                  "J" (offsetof(struct pt_regs, ARM_cpsr))
index f28c5e9c51ea5e33967186ff07123262e8d0adf0..c628bdf6c4308edbb7517664641a308fdd2164c8 100644 (file)
@@ -16,9 +16,9 @@
 #include <linux/mm.h>
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 
 #include <asm/pgtable.h>
 #include <asm/sections.h>
index ba2adefa53f764200cc31f5ce29f28ddaa62ef97..0e12e0acbf2624d07eac48f3e24a7d74979d38d1 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/delay.h>
 #include <linux/reboot.h>
index 4350f75e578c5815a8fe428aad512df27ca1e6e8..c23501842b98b06465d94071209e6fcc819a651c 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/sem.h>
 #include <linux/msg.h>
@@ -27,6 +26,7 @@
 #include <linux/file.h>
 #include <linux/ipc.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 /* Fork a new task - this creates a new program thread.
  * This is called indirectly via a small wrapper
index 5025c863713d60decb20d5924109bef0a7c48ef9..938fc14f962d35693cc96c9d3f8899ae1b5bd193 100644 (file)
@@ -74,7 +74,7 @@ ENTRY(memmove)
                rsb     ip, ip, #32
                addne   pc, pc, ip              @ C is always clear here
                b       7f
-6:             nop
+6:             W(nop)
                W(ldr)  r3, [r1, #-4]!
                W(ldr)  r4, [r1, #-4]!
                W(ldr)  r5, [r1, #-4]!
@@ -85,7 +85,7 @@ ENTRY(memmove)
 
                add     pc, pc, ip
                nop
-               nop
+               W(nop)
                W(str)  r3, [r0, #-4]!
                W(str)  r4, [r0, #-4]!
                W(str)  r5, [r0, #-4]!
index 6b967ffb6552525efdeb7c121cd5d00ddb3e75db..e2d2f2cd0c4f3b5c9b9c958aa65d073bcbbe722f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/hardirq.h> /* for in_atomic() */
+#include <linux/gfp.h>
 #include <asm/current.h>
 #include <asm/page.h>
 
index b5c5fc6ba3a9d32d39a0d6e4379c8de5d2ffbd42..3ef68330452a7e9037bb9314362130046cead895 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/timex.h>
 #include <linux/signal.h>
 #include <linux/clk.h>
+#include <linux/gfp.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
index 7b20fccb9d4ee7715c513fb6d26f635cbe25b6e1..2ccf670ce1ac2601b826a761354782c4befde8e9 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/irqreturn.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 
 #include <mach/timer.h>
 
index d15beceb632e9bcd784996dbd908ee1261d84994..df4ab2105869c284ae39902538d51fe1c6074f43 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/leds.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/slab.h>
 #include <linux/mtd/nand.h>
 #include <linux/input.h>
 #include <linux/spi/spi.h>
index 15dd886df04ca08cec53abb11ed9a6105a3a81c8..02d939853b882c71fff6665b3871d7318db9588c 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/edma.h>
 
index 7a26148282176a68003467efe52f3609997e0f6d..bdb3f67068016c4b73770719114558c6f741babe 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/mman.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 44d4c2e8207b1b06a368fbe30b99ecc75f726302..f77f20255045aed83f8648bf1be2d0afbed5b7a3 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/cpufreq.h>
-#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/init.h>
index 0058c937719ed7f7400fe8a1388e9c9e8f73e777..41b10725cef73352526e7310d6ba287533e42b84 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/clkdev.h>
 #include <mach/clkdev.h>
index 66ef86d6d9e3d0d80aa46f2e6f09d4314a491426..15e6cc5a352f81e04b69ce27b37bd91978e98e78 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/list.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/sysdev.h>
 #include <linux/amba/bus.h>
@@ -21,6 +20,7 @@
 #include <linux/amba/clcd.h>
 #include <linux/amba/mmci.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <asm/clkdev.h>
 #include <mach/clkdev.h>
index 148d25fc636fbe2c7d91596d4c312272e6460015..ffbd349363af0ec72810dfa5ee7c00bced887a74 100644 (file)
@@ -22,7 +22,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
index 4873f26a42e114796bf660c45f238a466b854b75..6d5a90813d31b6b96532b3b1a5cdb555e972ec41 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
 #include <asm/irq.h>
index 93370a46b620972a66fc810b18dd71132efc426e..10384fc37cb29d4315931483151c961e63e2d033 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/pci.h>
 #include <linux/pm.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index a7a08dda7f331c98f90b27ec17f5f5f9e14c0380..d6ac85ff109deef02935213bc33577f0be2da42a 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/pci.h>
 #include <linux/pm.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index 0200f80c1e171d99f48233e3a98accaf97076928..c6a0e4ee9d911d1b5d311be33b0fd537f65d93c4 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index 2a5c637639bb9984c4a3a4923f511a32cec67967..5d99039286eb86410ca72d5ddeb3bf1a2a083936 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/pci.h>
 #include <linux/pm.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index 394e95a30b75f8a124dc2828401da7766fb118c1..c6ff5523b380f95e26fc4282d895d1e03c54614b 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index a40badf126c29552b303bd0b8d6d7976a15e57a7..fbf55140939407f322af2f1c75441550edb37414 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/mtd/physmap.h>
index c84dfac13882a3b2838ba7b684a1531fa4e19fac..1a557e0d055b56626e5e0b37206b032a055c4818 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/bitops.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serial.h>
 #include <linux/tty.h>
index 4467c4224d73f23723d9e43530ae822f663b7a13..55e5c69352ad4de2395659e8dccc3a1e4e00a637 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/bitops.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 94f68ba9ea50905ba0023f52fd35bbb3b1b9ad79..237b61a85e9a397f6d398c53a686edbd186515ac 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/bitops.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 30451300751beb360ca41cf6e6f46814db1215f9..91fffb9b208443be54be71e9ebfb9bb000daea90 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/bitops.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 4a12327a09a3a5052caf71e3531ae1c4ba22fea6..0369ec4242a687e61c7c4305de54fcec5d4f696b 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/bitops.h>
 #include <linux/pci.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serial.h>
 #include <linux/tty.h>
index 60e9fd08ab803036c6655d6153a8c4b20aadf197..90771cad06f86f7fe3238021ce8ae39ce90cadc2 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 94a3a86cfeb8be7ae854aa26162e33c7796683d0..6ef65d813f161f729fe8e8be91ef6e13deb35603 100644 (file)
@@ -19,7 +19,7 @@
  */
 #define PHYS_OFFSET            (0x00000000)
 
-#define IXP23XX_PCI_SDRAM_OFFSET (*((volatile int *)IXP23XX_PCI_SDRAM_BAR) & 0xfffffff0))
+#define IXP23XX_PCI_SDRAM_OFFSET (*((volatile int *)IXP23XX_PCI_SDRAM_BAR) & 0xfffffff0)
 
 #define __phys_to_bus(x)       ((x) + (IXP23XX_PCI_SDRAM_OFFSET - PHYS_OFFSET))
 #define __bus_to_phys(x)       ((x) - (IXP23XX_PCI_SDRAM_OFFSET - PHYS_OFFSET))
index 59022becb134c93526eab0c350ffef3efdcc4ff4..4b0e598a91c91f4573d927a8016d91aab0154f7d 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 6e558a76457d154a5aa38d0c816b720b062cdc82..d8bc86d76f1d2248b0d936f5cd1413c0ce0ba469 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 #include <linux/i2c-gpio.h>
 #include <asm/types.h>
 #include <asm/setup.h>
index 25bf5ad770eaa14c6213e27579bd0b912691bd69..31a47f6a8939d8fc1bc0ce7c0e78db0495e5b5df 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
index 59b73a0ddfa93fba8b4ef21206566e190496cf6b..2583b2a13174ef02959fb62b70d96c68a978073a 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
index 0bc7185cb6f7282e7447ffe091ea9783f108c206..c67586b79400c8a02084389e297539208dcdb5c1 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 #include <asm/types.h>
 #include <asm/setup.h>
 #include <asm/memory.h>
index bbb768988845dae9dc5910acf3f245ba786a0ec4..827cbc4402f4dff37ce8b8dff110e45598d8b4e4 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 #include <linux/i2c-gpio.h>
 #include <linux/io.h>
 #include <linux/mtd/mtd.h>
index e8bb257781661da9424208d8f79862cc088e377f..a17ed79207a4fce30f67b405f758cd07b23f85ad 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <mach/npe.h>
 
 #define DEBUG_MSG                      0
index 7ea782021d1f56de331f24bef9cacf9d84f8d60c..4dd74863daa9cb4e56c074108436abd2ea39b33d 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/serial.h>
 #include <linux/tty.h>
 #include <linux/serial_8250.h>
-#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
index 0358f45766cbe565c7571483bb251fc490f9f81f..5e6f711b1c6753713b8819078ec0bc053566f200 100644 (file)
@@ -74,9 +74,9 @@ static struct gpio_keys_button mv88f6281gtw_ge_button_pins[] = {
                .desc           = "SWR Button",
                .active_low     = 1,
        }, {
-               .code           = KEY_F1,
+               .code           = KEY_WPS_BUTTON,
                .gpio           = 46,
-               .desc           = "WPS Button(F1)",
+               .desc           = "WPS Button",
                .active_low     = 1,
        },
 };
index a604b2a701aa5408aa72d54e77af10bfedee23a5..dee1eff50d3933d2252a2f66aed2f1d7456d69c3 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/mbus.h>
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
index c472b9e8b37cd3bf6710ae555b0e356b3ab9f01d..7fe4fd347c821c6b97e415e80ba696ddc7599e37 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/sysdev.h>
index a7dcc5307216524b4f2e57c05af043530be64f5a..85bd8a2d84b5e47cc3acc1a24192a8387c3d28ab 100644 (file)
@@ -14,7 +14,7 @@
 #define UART2_BASE     (APB_PHYS_BASE + 0x17000)
 #define UART3_BASE     (APB_PHYS_BASE + 0x18000)
 
-static volatile unsigned long *UART = (unsigned long *)UART2_BASE;
+static volatile unsigned long *UART;
 
 static inline void putc(char c)
 {
@@ -37,6 +37,9 @@ static inline void flush(void)
 
 static inline void arch_decomp_setup(void)
 {
+       /* default to UART2 */
+       UART = (unsigned long *)UART2_BASE;
+
        if (machine_is_avengers_lite())
                UART = (unsigned long *)UART3_BASE;
 }
index a7dc5191bf5ea4de9ffaf09bc0397414ddd80745..fccb9207b78d75112bed0b7ac0d3d45a17367e1b 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/fsl_devices.h>
+#include <linux/gfp.h>
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 11f5315591693380e6bd59c05d7449b6dbee1698..034ec81900657d9b8880d39963c4008b4b7f208a 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 #include <linux/fsl_devices.h>
+#include <linux/gfp.h>
 
 #include <media/soc_camera.h>
 
index 9fbad2eb3a49786cd0f12037b63d31346de4969e..11b906ce7eae45c92c405b107412686043db4f0a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <linux/usb/otg.h>
index 3958515d75bfd7a082dec42a33df40cdf7cc94fe..ffb105e14d88d10a77d54fa86267e04db8515d71 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
index 1d844e228ea92e6a674e92a6b0fcb3e2cb3eef42..5b84bcd30271321a17a38c7e0d2a2f51d4f286c2 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/clcd.h>
 #include <linux/err.h>
+#include <linux/gfp.h>
 
 #include <asm/irq.h>
 
index 181a78ba81654bdae53bda56c7ede38faad6063b..f009b54e8d20e37a33311eb39782c0076a99164e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/firmware.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 
 #include <mach/hardware.h>
index 9a09b2791e037248dfd949baeed5fdd2b7ebfa22..66b1c91ccc7482fb993cbfbb4f1986aa0d75fde2 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/gpio.h>
index 795b15e8982a6e88e8742a186bcfb11e8d66e765..463e92465fda692566169e07c608f2b88a4853bf 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
+#include <linux/slab.h>
 
 #include <mach/regs-board-a9m9750dev.h>
 #include <mach/board.h>
index abee8338735d471884dc057cfac76b3e5cab4790..aed1999d24fc9d16fbbc42b13b356f8420fecda9 100644 (file)
@@ -10,7 +10,6 @@
  */
 #include <linux/io.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 
 #include <asm/page.h>
 #include <asm/mach/map.h>
index f9a5cf750b59cb7bfc88769d2c1135eb0bd1d79e..e9bdff192f8261d39a7cac0a7ad351970b24d633 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <mach/irqs.h>
 #include <plat/dma.h>
index 3b1eac4d539037cd40404a852e5f13bea5415f46..e60ca4e47bbd8a1927e5c11e3e533d3ad5700faf 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #include <plat/clock.h>
 #include <plat/sram.h>
index 6f4b7cc8f4d18c0cbf2624f4b0f0aa9aba08e914..4f63dc6859a435f489544c9c241579c7da95a07e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/jiffies.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/stringify.h>
 
 #include <plat/iommu.h>
index be8fce395a58bf1b76f1b2e3657366076cb8a7b3..2f3cad6f940237680920acc62306344c3524ff62 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <mach/irqs.h>
 #include <plat/dma.h>
index b4ca84ee0a95027b5ffd46d82347d4c5d87a7776..8b3d26935a39423c927b73287d1f60fec31ee996 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/ctype.h>
index c18f7f2f19bce28414084571fe3956803126a387..6cac9817c24394024914b08b6e06cc87d81dea4f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <plat/clock.h>
 #include <plat/board.h>
index fee2efb172e74be9dd7ecb5aaccb51bc52f234de..ea0000bc5358e196df58e88da3f54dd71f0a4706 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/gpio.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <plat/sram.h>
 #include <plat/clockdomain.h>
index bdf96eb523bc5f625de1ff18cf6029abba1d44f9..e8706f15a670638e90711f6cf4108076c8cf1cc9 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/mbus.h>
 #include <asm/irq.h>
 #include <asm/mach/pci.h>
index cb0feca193d442781ffeb887915b601554a5a99b..f9f222ebb7ed0c5b12064cebddfe63c9399b3846 100644 (file)
@@ -77,7 +77,7 @@ static struct gpio_keys_button wrt350n_v2_buttons[] = {
                .desc           = "Reset Button",
                .active_low     = 1,
        }, {
-               .code           = KEY_WLAN,
+               .code           = KEY_WPS_BUTTON,
                .gpio           = 2,
                .desc           = "WPS Button",
                .active_low     = 1,
index 425f7188505ed4bac57decaaa09b6fd1ab37e3f2..7fa4bf2e21259884e41d0c610bc09b815bd51e06 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <mach/hardware.h>
index 1f0585329be48a3e651a365a9bc05b42c60b532b..ee3c29c57ae3b3bb204a5da93705188af1ab09f9 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/cacheflush.h>
 
index 38fbd0a0e4022c1e9076fa43740b6468d50b8d19..5b6ee46fa7f6235b9203ae2b00a66453d28d2849 100644 (file)
@@ -272,7 +272,6 @@ config MACH_H5000
 config MACH_HIMALAYA
        bool "HTC Himalaya Support"
        select CPU_PXA26x
-       select FB_W100
 
 config MACH_MAGICIAN
        bool "Enable HTC Magician Support"
@@ -454,6 +453,13 @@ config PXA_SHARPSL
 config SHARPSL_PM
        bool
        select APM_EMULATION
+       select SHARPSL_PM_MAX1111
+
+config SHARPSL_PM_MAX1111
+       bool
+       depends on !CORGI_SSP_DEPRECATED
+       select HWMON
+       select SENSORS_MAX1111
 
 config CORGI_SSP_DEPRECATED
        bool
@@ -547,7 +553,6 @@ config MACH_E740
        bool "Toshiba e740"
        default y
        depends on ARCH_PXA_ESERIES
-       select FB_W100
        help
          Say Y here if you intend to run this kernel on a Toshiba
          e740 family PDA.
@@ -556,7 +561,6 @@ config MACH_E750
        bool "Toshiba e750"
        default y
        depends on ARCH_PXA_ESERIES
-       select FB_W100
        help
          Say Y here if you intend to run this kernel on a Toshiba
          e750 family PDA.
@@ -573,7 +577,6 @@ config MACH_E800
        bool "Toshiba e800"
        default y
        depends on ARCH_PXA_ESERIES
-       select FB_W100
        help
          Say Y here if you intend to run this kernel on a Toshiba
          e800 family PDA.
index 1d9bc118ee320f947d6b62fd92b1b78ce725f100..9347254f8bcf51f374ed51f9d77103d975b69559 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <mach/hardware.h>
index 149cdd9aee4d51d23977d769d1a3d041897f12ee..27fa329d9a8b7a5677c2cf75e25900797130eb46 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #include <mach/pxa3xx-regs.h>
 
index b2f878bd460b5d136570560b8fe9f769ebb9d675..5161dca8ccc03d38bab8b92c4e1ed82ea2667ed6 100644 (file)
@@ -559,10 +559,6 @@ static void __init imote2_init(void)
        pxa_set_btuart_info(NULL);
        pxa_set_stuart_info(NULL);
 
-       /* SPI chip select directions - all other directions should
-        * be handled by drivers.*/
-       gpio_direction_output(37, 0);
-
        platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
 
        pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
index 5ef91d9d17e47fb08b7d810f4e739726d4802498..759b851ec985e02939d2b8f23cb7b9af8019a1c0 100644 (file)
@@ -16,9 +16,9 @@
 #define BTUART_BASE    (0x40200000)
 #define STUART_BASE    (0x40700000)
 
-static unsigned long uart_base = FFUART_BASE;
-static unsigned int uart_shift = 2;
-static unsigned int uart_is_pxa = 1;
+static unsigned long uart_base;
+static unsigned int uart_shift;
+static unsigned int uart_is_pxa;
 
 static inline unsigned char uart_read(int offset)
 {
@@ -56,6 +56,11 @@ static inline void flush(void)
 
 static inline void arch_decomp_setup(void)
 {
+       /* initialize to default */
+       uart_base = FFUART_BASE;
+       uart_shift = 2;
+       uart_is_pxa = 1;
+
        if (machine_is_littleton() || machine_is_intelmote2()
            || machine_is_csb726() || machine_is_stargate2()
            || machine_is_cm_x300() || machine_is_balloon3())
index 843fcca76e26dc4153cf79128f964f7c20eace94..7a50ed8fce94ddf84795b59531539c9fdc2dc6f3 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
+#include <linux/slab.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
index 7693355ee637a60a5496bd980580380c0d19df39..166c15f629162eeef0b45b356d9eedf32218d001 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/suspend.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include <mach/pm.h>
 
index 3184bdc14526bac6cdf762028f4980996fa8985d..44bb675e47f1f427e7e23cee1d53a14fd8aacac7 100644 (file)
@@ -37,8 +37,6 @@
 #include <linux/lis3lv02d.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/pda_power.h>
-#include <linux/power_supply.h>
 #include <linux/regulator/max8660.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
@@ -444,7 +442,7 @@ static struct gpio_keys_button gpio_keys_button[] = {
                .active_low             = 0,
                .wakeup                 = 0,
                .debounce_interval      = 5, /* ms */
-               .desc                   = "on/off button",
+               .desc                   = "on_off button",
        },
 };
 
index a98a434f011163321a6f1b79cc13e36b5159156f..2041eb1d90ba0be9582c843b241b318b0f8b611a 100644 (file)
@@ -764,11 +764,6 @@ static void __init stargate2_init(void)
        pxa_set_btuart_info(NULL);
        pxa_set_stuart_info(NULL);
 
-       /* spi chip selects */
-       gpio_direction_output(37, 0);
-       gpio_direction_output(24, 0);
-       gpio_direction_output(39, 0);
-
        platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
 
        pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
index 1dd13346f977a14ab0c39b59136a50ca8b2d5d59..9e0c5c3988a1f3fae23ee3dd585c135ab54e95a0 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/major.h>
 #include <linux/module.h>
index 90bd4ef71b2cae9b426d0bf5e707c2a441a35e1c..f2dbce5f3cd4dde9940b1efca6862a3c5a8baacc 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/smsc911x.h>
 #include <linux/ata_platform.h>
 #include <linux/amba/mmci.h>
+#include <linux/gfp.h>
 
 #include <asm/clkdev.h>
 #include <asm/system.h>
index c47d974d52bdacbe5fddcc40b9a630c2f5a914f0..85883b2e0e49cdecb8eed50a3042842972de5a81 100644 (file)
@@ -9,7 +9,6 @@
  *
  *  DMA functions specific to RiscPC architecture
  */
-#include <linux/slab.h>
 #include <linux/mman.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index b62bdf18dca4e156d1b00f3b4ea3c887281893a1..33ccf7bf766a961d35eb71cbae7107547bcf913e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/dmapool.h>
 #include <linux/sysdev.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/err.h>
index 9b6dee5d16dbe859ac3ae2383bf08caf6e12947a..9d490c66891cfb0209e4a27646a758a9b2993428 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/jornada720.h>
index 0b505d9f22d6e7fcc9c568d0dc2a0977fe25f0a6..c601a75a333d147bf138cba667e11b84b9871a14 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/ioport.h>
 #include <linux/serial_core.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
index 962f9de454deafb39b543b31b66c6f9e31d09485..5f55012b7c9edb99d32c5bcb89358686908773d7 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mutex.h>
 #include <linux/spi/spi.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 /*
  * WARNING! Do not include this pl022-specific controller header
  * for any generic driver. It is only done in this dummy chip
index 109f5a6e71c75b48cc598a92d930026e85e99463..77fbb1e0e5281854b4bb7df2480c5a094b0998c5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/gpio.h>
 #include <linux/amba/mmci.h>
+#include <linux/slab.h>
 
 #include "mmc.h"
 #include "padmux.h"
index 9ddb49b1cb719119c2df40c3e807a4c90b36e712..3b1a4ee01815044b965f109745e4d358c5d98c7c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/clockchips.h>
 #include <linux/cnt32_to_63.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <asm/clkdev.h>
 #include <asm/system.h>
index 7161ba23b58a6e2776852abf7eb5a8b857993cd5..334f0df4e948bc46c322c3ca0c50fe8002b676c0 100644 (file)
@@ -16,7 +16,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
index 48876122df91796dcea6d0317554e8fcd37e7cf2..e2958eb567f9f1e5a2047f0dc4aebd7327adaba3 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/mtd.h>
index c4ed9f93f646be93fbdcc048a326c5d7db995bcd..5bd7c89a604515273212ea304a02353ab9af5c39 100644 (file)
@@ -736,6 +736,12 @@ config NEEDS_SYSCALL_FOR_CMPXCHG
 config OUTER_CACHE
        bool
 
+config OUTER_CACHE_SYNC
+       bool
+       help
+         The outer cache has a outer_cache_fns.sync function pointer
+         that can be used to drain the write buffer of the outer cache.
+
 config CACHE_FEROCEON_L2
        bool "Enable the Feroceon L2 cache controller"
        depends on ARCH_KIRKWOOD || ARCH_MV78XX0
@@ -757,6 +763,7 @@ config CACHE_L2X0
                   REALVIEW_EB_A9MP || ARCH_MX35 || ARCH_MX31 || MACH_REALVIEW_PBX || ARCH_NOMADIK || ARCH_OMAP4
        default y
        select OUTER_CACHE
+       select OUTER_CACHE_SYNC
        help
          This option enables the L2x0 PrimeCell.
 
@@ -781,3 +788,9 @@ config ARM_L1_CACHE_SHIFT
        int
        default 6 if ARM_L1_CACHE_SHIFT_6
        default 5
+
+config ARCH_HAS_BARRIERS
+       bool
+       help
+         This option allows the use of custom mandatory barriers
+         included via the mach/barriers.h file.
index 07334632d3e2761293e1880b2486a2e85c3437e4..21ad68ba22bab8a3acd859cbba4df0fc36c93b72 100644 (file)
@@ -93,6 +93,15 @@ static inline void l2x0_flush_line(unsigned long addr)
 }
 #endif
 
+static void l2x0_cache_sync(void)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&l2x0_lock, flags);
+       cache_sync();
+       spin_unlock_irqrestore(&l2x0_lock, flags);
+}
+
 static inline void l2x0_inv_all(void)
 {
        unsigned long flags;
@@ -225,6 +234,7 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
        outer_cache.inv_range = l2x0_inv_range;
        outer_cache.clean_range = l2x0_clean_range;
        outer_cache.flush_range = l2x0_flush_range;
+       outer_cache.sync = l2x0_cache_sync;
 
        printk(KERN_INFO "L2X0 cache controller enabled\n");
 }
index 0da7eccf7749103d26e9545560256f0a8b47dce4..1351edc0b26feba5330e3bf045b74702ffe88683 100644 (file)
@@ -11,7 +11,7 @@
  */
 #include <linux/module.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/errno.h>
 #include <linux/list.h>
 #include <linux/init.h>
index c9b97e9836a201ba752c069731afdf1a10b7cea1..0d414c28eb2c8e679d3a39563fb666753e4fcd3d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
+#include <linux/gfp.h>
 
 #include <asm/bugs.h>
 #include <asm/cacheflush.h>
index 7829cb5425f56e460a62390158114db98f4acc10..83db12a68d569c95a3792cb87dcaea4d52478fbc 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/initrd.h>
 #include <linux/sort.h>
 #include <linux/highmem.h>
+#include <linux/gfp.h>
 
 #include <asm/mach-types.h>
 #include <asm/sections.h>
index 2690146161ba31e01236f6fe6d90d32e7bc76bf4..be5f58e153bf180d4df1da5037f26652cc7ca2cb 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include <linux/highmem.h>
 
 #include <asm/pgalloc.h>
index d983cd6c788cb89bb396785c1eedfd205fa2c5b9..0c2cc5cd4d83ac6ec5129dcba1a896eab8230f00 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <mach/audmux.h>
 #include <mach/hardware.h>
 
index 4ff6dfe0428376a1fdecafb9cb683cab8c53d2bf..c36f2630ed939add19c8afe72afbad86d777487b 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index 4a4cd8774aaa74f440e4d0da6094e9d541d4aff6..95677d17cd1ca02e9626e41e57dae23d16024a7e 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
index 2ab224c8e16c450f6b2bd96fdff71b94aabf864d..5c6c342c53f5a136f78f1b76cf656e2a06130ddd 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <mach/hardware.h>
index afd1c27cff7c891066e738185e422b50a3df1858..e6c0d536899cb7a697e8db32e55bfa4301c93e53 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/platform_device.h>
 #include <linux/debugfs.h>
index 905ed832df569ad3c33a0fc7f482707def80e9b9..0e137663349ce59d60fe45a6c5b3408da64ffe08 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/clk.h>
index 936aef1971cd320afd086f099d59a4d0b9958281..65c6d1ff72370c37a9840ff2942f270de08d95f7 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/device.h>
 #include <linux/scatterlist.h>
index 4229cec531406df095055734ef955ae97152fc89..08a2df766289b0fc3af9927ab4ebfa560fee618b 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <plat/mailbox.h>
 
index 52dfcc81511e27ccf2b797517abfc7df73aa5bcb..e1d0440fd4a88470481d163e661cd67ab8c1f309 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <plat/dma.h>
 #include <plat/mcbsp.h>
index 590435894848e63c78a906d943bde61c72243cca..0f5197479513cff513b25cb49d2979aaee452d76 100644 (file)
@@ -79,6 +79,7 @@
 
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/io.h>
 
index 2975798d411fdbfc48021c4626d3593a69056dc7..742350e0f2a77813651474815cd1f70bd09d46f2 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
index 51dc5c8106c0cc84dd38aa89faf176f46303f019..0732c6c8d511979e354cced2cd6987889702a1e7 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index 2d42efb9f4e9facbc92c559d9605a04aa8b367f3..1ecc15bfe9d40b44a7d6225ba1b413640da2f460 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/sysdev.h>
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
index 8c6de1c9968f4bf22eb2ac78e3d0c676b1c8b8e1..9265f09bfa58e6b005f73fa0c9cf39dc11ec310e 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/serial_core.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
index 963fb0b4379ec4f623050d6463945838c654a158..b1908e56da1b2cfea948efd8ab6e2db746802a71 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/cpufreq.h>
 #include <linux/seq_file.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/map.h>
 #include <mach/regs-mem.h>
index 24993dce10b51eafe1cd64b9b813dd72a09d6e4a..0b46d3895d62b9756a39b925fcb920b584185962 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/amba/pl093.h>
 
index 0b5833b9ac5bcd9aad629b9a93209a58b848efbf..210030d5cfe13e3761e99f19732ab9a3b97a893c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/interrupt.h>
index a90198fc4b0f3d31312c3314e4ffaed4186bf3e4..002a15f313f30bb7e1e798d78b60a287578b574e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/fb.h>
+#include <linux/gfp.h>
 
 #include <mach/irqs.h>
 #include <mach/map.h>
index 4c761529b949d02882d5cacfebca6841ac807891..3a601c16f03c78c4a40dcd81c70d24b503204c09 100644 (file)
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/platform_device.h>
index d44f79110506494fe37cda5575dd9d0a67f1ac45..858ee2a0414c57154129cbb07bb06ccd2aa9121c 100644 (file)
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/platform_device.h>
index a52fb6cf618fb93e77e1aae7a37a14a55efede77..3a7b8891ba4f54ee9c76133e00e14d4893a419bd 100644 (file)
@@ -6,6 +6,7 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 
index 88165657fa5367ade7663cf786b7831a5dfe5719..0e0a3bf5c982121ea08021db043dccfaf7b7d3c1 100644 (file)
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
 */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/platform_device.h>
index 0b5bb774192a59eef8c1af6c040a94ffd51296f6..e4baf76f374ada34260e37dc88916207ad75abf2 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/crc32.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 
 #include <plat/pm.h>
 
index f2d11390d01c8d4e3227e50d8a74273726d00695..2eeb49fa056d6413c1963abc6113fa0eff76caf8 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index ef88f25fb870edac8424254161232da10f86fac2..b4dcf8c0477d9ef95a44a50d0848a6ebb12ae60b 100644 (file)
@@ -15,6 +15,7 @@
  * http://www.opensource.org/licenses/gpl-license.html
  * http://www.gnu.org/copyleft/gpl.html
  */
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/dmapool.h>
index 31c2f4c30a95b94631bc9e9568247e644b9d0eb2..1536f1784cacba080d10c82e2900fe522c0ab4b1 100644 (file)
@@ -12,7 +12,7 @@
 #
 #   http://www.arm.linux.org.uk/developer/machines/?action=new
 #
-# Last update: Sat Feb 20 14:16:15 2010
+# Last update: Sat Mar 20 15:35:41 2010
 #
 # machine_is_xxx       CONFIG_xxxx             MACH_TYPE_xxx           number
 #
@@ -2663,7 +2663,7 @@ reb01                     MACH_REB01              REB01                   2675
 aquila                 MACH_AQUILA             AQUILA                  2676
 spark_sls_hw2          MACH_SPARK_SLS_HW2      SPARK_SLS_HW2           2677
 sheeva_esata           MACH_ESATA_SHEEVAPLUG   ESATA_SHEEVAPLUG        2678
-surf7x30               MACH_SURF7X30           SURF7X30                2679
+msm7x30_surf           MACH_MSM7X30_SURF       MSM7X30_SURF            2679
 micro2440              MACH_MICRO2440          MICRO2440               2680
 am2440                 MACH_AM2440             AM2440                  2681
 tq2440                 MACH_TQ2440             TQ2440                  2682
@@ -2678,3 +2678,74 @@ vc088x                   MACH_VC088X             VC088X                  2690
 mioa702                        MACH_MIOA702            MIOA702                 2691
 hpmin                  MACH_HPMIN              HPMIN                   2692
 ak880xak               MACH_AK880XAK           AK880XAK                2693
+arm926tomap850         MACH_ARM926TOMAP850     ARM926TOMAP850          2694
+lkevm                  MACH_LKEVM              LKEVM                   2695
+mw6410                 MACH_MW6410             MW6410                  2696
+terastation_wxl                MACH_TERASTATION_WXL    TERASTATION_WXL         2697
+cpu8000e               MACH_CPU8000E           CPU8000E                2698
+catania                        MACH_CATANIA            CATANIA                 2699
+tokyo                  MACH_TOKYO              TOKYO                   2700
+msm7201a_surf          MACH_MSM7201A_SURF      MSM7201A_SURF           2701
+msm7201a_ffa           MACH_MSM7201A_FFA       MSM7201A_FFA            2702
+msm7x25_surf           MACH_MSM7X25_SURF       MSM7X25_SURF            2703
+msm7x25_ffa            MACH_MSM7X25_FFA        MSM7X25_FFA             2704
+msm7x27_surf           MACH_MSM7X27_SURF       MSM7X27_SURF            2705
+msm7x27_ffa            MACH_MSM7X27_FFA        MSM7X27_FFA             2706
+msm7x30_ffa            MACH_MSM7X30_FFA        MSM7X30_FFA             2707
+qsd8x50_surf           MACH_QSD8X50_SURF       QSD8X50_SURF            2708
+qsd8x50_comet          MACH_QSD8X50_COMET      QSD8X50_COMET           2709
+qsd8x50_ffa            MACH_QSD8X50_FFA        QSD8X50_FFA             2710
+qsd8x50a_surf          MACH_QSD8X50A_SURF      QSD8X50A_SURF           2711
+qsd8x50a_ffa           MACH_QSD8X50A_FFA       QSD8X50A_FFA            2712
+adx_xgcp10             MACH_ADX_XGCP10         ADX_XGCP10              2713
+mcgwumts2a             MACH_MCGWUMTS2A         MCGWUMTS2A              2714
+mobikt                 MACH_MOBIKT             MOBIKT                  2715
+mx53_evk               MACH_MX53_EVK           MX53_EVK                2716
+igep0030               MACH_IGEP0030           IGEP0030                2717
+axell_h40_h50_ctrl     MACH_AXELL_H40_H50_CTRL AXELL_H40_H50_CTRL      2718
+dtcommod               MACH_DTCOMMOD           DTCOMMOD                2719
+gould                  MACH_GOULD              GOULD                   2720
+siberia                        MACH_SIBERIA            SIBERIA                 2721
+sbc3530                        MACH_SBC3530            SBC3530                 2722
+qarm                   MACH_QARM               QARM                    2723
+mips                   MACH_MIPS               MIPS                    2724
+mx27grb                        MACH_MX27GRB            MX27GRB                 2725
+sbc8100                        MACH_SBC8100            SBC8100                 2726
+saarb                  MACH_SAARB              SAARB                   2727
+omap3mini              MACH_OMAP3MINI          OMAP3MINI               2728
+cnmbook7se             MACH_CNMBOOK7SE         CNMBOOK7SE              2729
+catan                  MACH_CATAN              CATAN                   2730
+harmony                        MACH_HARMONY            HARMONY                 2731
+tonga                  MACH_TONGA              TONGA                   2732
+cybook_orizon          MACH_CYBOOK_ORIZON      CYBOOK_ORIZON           2733
+htcrhodiumcdma         MACH_HTCRHODIUMCDMA     HTCRHODIUMCDMA          2734
+epc_g45                        MACH_EPC_G45            EPC_G45                 2735
+epc_lpc3250            MACH_EPC_LPC3250        EPC_LPC3250             2736
+mxc91341evb            MACH_MXC91341EVB        MXC91341EVB             2737
+rtw1000                        MACH_RTW1000            RTW1000                 2738
+bobcat                 MACH_BOBCAT             BOBCAT                  2739
+trizeps6               MACH_TRIZEPS6           TRIZEPS6                2740
+msm7x30_fluid          MACH_MSM7X30_FLUID      MSM7X30_FLUID           2741
+nedap9263              MACH_NEDAP9263          NEDAP9263               2742
+netgear_ms2110         MACH_NETGEAR_MS2110     NETGEAR_MS2110          2743
+bmx                    MACH_BMX                BMX                     2744
+netstream              MACH_NETSTREAM          NETSTREAM               2745
+vpnext_rcu             MACH_VPNEXT_RCU         VPNEXT_RCU              2746
+vpnext_mpu             MACH_VPNEXT_MPU         VPNEXT_MPU              2747
+bcmring_tablet_v1      MACH_BCMRING_TABLET_V1  BCMRING_TABLET_V1       2748
+sgarm10                        MACH_SGARM10            SGARM10                 2749
+cm_t3517               MACH_CM_T3517           CM_T3517                2750
+omap3_cps              MACH_OMAP3_CPS          OMAP3_CPS               2751
+axar1500_receiver      MACH_AXAR1500_RECEIVER  AXAR1500_RECEIVER       2752
+wbd222                 MACH_WBD222             WBD222                  2753
+mt65xx                 MACH_MT65XX             MT65XX                  2754
+msm8x60_surf           MACH_MSM8X60_SURF       MSM8X60_SURF            2755
+msm8x60_sim            MACH_MSM8X60_SIM        MSM8X60_SIM             2756
+vmc300                 MACH_VMC300             VMC300                  2757
+tcc8000_sdk            MACH_TCC8000_SDK        TCC8000_SDK             2758
+nanos                  MACH_NANOS              NANOS                   2759
+stamp9g10              MACH_STAMP9G10          STAMP9G10               2760
+stamp9g45              MACH_STAMP9G45          STAMP9G45               2761
+h6053                  MACH_H6053              H6053                   2762
+smint01                        MACH_SMINT01            SMINT01                 2763
+prtlvt2                        MACH_PRTLVT2            PRTLVT2                 2764
index 7f3f59fcaa2199dda10eebd5b7bfa62348643342..a420cb9493282c547e0edaae74255d9311374869 100644 (file)
@@ -545,7 +545,7 @@ static int __init vfp_init(void)
                 */
                elf_hwcap |= HWCAP_VFP;
 #ifdef CONFIG_VFPv3
-               if (VFP_arch >= 3) {
+               if (VFP_arch >= 2) {
                        elf_hwcap |= HWCAP_VFPv3;
 
                        /*
index 93c0342530a0d02beb47f61f8e7e8a260fe67764..2d76515745a4f0edf28f7a09a53cfca093da4bda 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/pm.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 #include <linux/reboot.h>
 #include <linux/tick.h>
 #include <linux/uaccess.h>
index 3a4bc1a18433ff52ac5ba10565f70abee1b38028..e67c999454284f46dee1c3ba0742cbbe0221ba23 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/usb/atmel_usba_udc.h>
index 310477ba1bbf170a47af4e68bfc4bfa26d836a8d..e9d12058ffd379287bd4044e522a6a6736dd727c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/irq.h>
 #include <linux/platform_device.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 2875c11be95d5f232d2970e204695fbc83a526d3..f7672d3e86b842b56e74cad31a4892ba42d05e2f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <mach/smc.h>
index 6d8c794c3b81bbd528f170c9dba7fa46e50c525c..3c0042247ea93661adbf504237be51e3d7730cec 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <asm/addrspace.h>
 #include <asm/cacheflush.h>
index 94925641e53e64fbb87b2754b5d927be00a8b3ac..a7314d44b17ba5a2afd1bd83b3edaf8cea222c33 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/init.h>
index f03b79f0e0ab0a75f631e7886ad41a7a855c518d..7def0d84cec63a763e219b53faad1f88b06b65ac 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/pgtable.h>
 #include <asm/addrspace.h>
index 7f363d7e43a53dc97b0f0207b129a3b5f9d08a19..e1a9b4624f919ddae4675b1a8ff122e89944c764 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef __BLACKFIN_MMU_CONTEXT_H__
 #define __BLACKFIN_MMU_CONTEXT_H__
 
-#include <linux/gfp.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <asm/setup.h>
 #include <asm/page.h>
index a77307a4473b3f6ab5395ffb8f1a337982f99483..1a496cd71ba2427fb7dffa75cbc331d522b39275 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
 #include <linux/bitops.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kthread.h>
 #include <linux/unistd.h>
index 29705cec91de6a1af923504f01acf6f76403f083..93ec07da2e513866356aba2baedaa0739e1351f2 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/unistd.h>
 #include <linux/user.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/tick.h>
 #include <linux/fs.h>
index 8837be4edb4a47ebb90501129d2aa69fc725486e..c1f1ccc846f067ade4556eb3c2e98db523a27a50 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/suspend.h>
 #include <linux/sched.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/irq.h>
 
index 7803f22d2ca73039cb83ef0d229a0f76bf1cbf79..7cecbaf0358ab03e0a42e5492475d7a241f31fd3 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/smp.h>
 #include <linux/seq_file.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
 #include <asm/mmu_context.h>
index bb9c98f9cb5b5845bf2caf87589902375a01289d..355b87aa6b9322da7c1e5074e0eb5170fe6d5de3 100644 (file)
@@ -4,6 +4,7 @@
  * Licensed under the GPL-2 or later.
  */
 
+#include <linux/gfp.h>
 #include <linux/swap.h>
 #include <linux/bootmem.h>
 #include <linux/uaccess.h>
index 9213e235788815fbb81c24f9e7d2b33dcbf56e2d..39b058564f62400db2b00af74127d13cd0d83fd4 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/sched.h>
 
index 5732da25ee2d9fb95ac138b204c251378c761faf..49b2ff2c8b74bee191df47682bcbae227b5beac6 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 #include <asm/blackfin.h>
 #include <asm/mem_map.h>
 #include "blackfin_sram.h"
index 7f656ae0b21d2e16d940ad22f81748d36f4730d6..a8737a8eb2294143692a2502d4cef7b9c4a631b3 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
index 562b9a7feae776c5f9ef024726e82ff3dc66774a..109dcd826d171cac5d3fcf31228ab7230f057f1a 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/errno.h>
 #include <linux/major.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/init.h>
index c4c69cf721e5155141f8261ed536ede9570c3e35..93f0f64b132649d9446a5580d6b1ab740df255e3 100644 (file)
@@ -11,9 +11,9 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/fs.h>
-#include <linux/slab.h>
 #include <arch/svinto.h>
 #include <linux/init.h>
 
index 179e7b8043313eaab628b2ceabf79d67ba67dab4..506826399ae72edbcca777b79898a1c886475f59 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
index d4b9c36ddc0fb62f2f8f284897a9504f411307a6..bc0cfdad1cbceecd2c7347c427c087b6ed8105ee 100644 (file)
@@ -50,7 +50,7 @@ pcibios_align_resource(void *data, const struct resource *res,
        if ((res->flags & IORESOURCE_IO) && (start & 0x300))
                start = (start + 0x3ff) & ~0x3ff;
 
-       return start
+       return start;
 }
 
 int pcibios_enable_resources(struct pci_dev *dev, int mask)
index fbe65954ee6c32ab895cbfae568b1613b918b0ee..ee55578d9834159b8e403c0b8e3f26ce2de4d5f4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 
 void *dma_alloc_coherent(struct device *dev, size_t size,
index d2a0fbf5341fc1870e8bf9d245acb980d3f95f6c..4889f196ecd6c2478c11b309c4fc06ca89ebf0c0 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/errno.h>
 #include <linux/major.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/interrupt.h>
 #include <linux/poll.h>
index 120e7f796fea9707f009af5bffbc15aad6fbdd0f..2661a9529d701a85d0d41358627912e192a10539 100644 (file)
@@ -9,9 +9,9 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/fs.h>
-#include <linux/slab.h>
 #include <hwregs/reg_rdwr.h>
 #include <hwregs/reg_map.h>
 #include <hwregs/timer_defs.h>
index 372d0ca6efbc66cfb98fafd6720e57044dc7bcd9..0b7e3f143281c435e5ff5d836fbb23b762758c5d 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
 #include <linux/errno.h>
index 6d7b9eda40367c87c4f9e76540e04eab3442f8c8..469f7f9d62e0805122105648e3e9b8aaef5c66c4 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
index abc13e368b909540df0c66206f7e95ad42d07745..bcd502f74cda46e6ef8c710fe4d76daea0e124f2 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #if 0
 #define DEBUGP printk
index 9aa571169bcc5ea1f9847ab8bea143ccadfc6f14..b917549a7d94b72735fb461d7a213f8a68da8f1e 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/ptrace.h>
 #include <asm/uaccess.h>
index ff68b9f516a17f9fd2a5ace9b3abd263efb14ca0..df33ab89d70f0083c99380db30faaa8114d7512e 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <asm/tlb.h>
index 62d1aba615dc707edeb0784deb4466d239e53822..625136625a7fef7a0aea779e8d34d15f9c2e345c 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
index 035516cb7a974e1fe44539b7cba4672f8e50d9b2..71abd1510a59d5e453b5a4567c237a32a1f18a44 100644 (file)
@@ -9,7 +9,6 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
index 2c912e80516206dd890d52f5c9fb80a48bd4ee1d..85d110b71cf735166a31d3d2872e46fc597bbc6d 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/list.h>
 #include <linux/pci.h>
index 1ed15d7fea20c0e8975b22d492fa1e5da3bfb107..6b4fb28e9f997d1a9bf64f19cd26fba08ac8b9df 100644 (file)
@@ -41,7 +41,7 @@ pcibios_align_resource(void *data, const struct resource *res,
        if ((res->flags & IORESOURCE_IO) && (start & 0x300))
                start = (start + 0x3ff) & ~0x3ff;
 
-       return start
+       return start;
 }
 
 
@@ -94,8 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
                                r = &dev->resource[idx];
                                if (!r->start)
                                        continue;
-                               if (pci_claim_resource(dev, idx) < 0)
-                                       printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev));
+                               pci_claim_resource(dev, idx);
                        }
                }
                pcibios_allocate_bus_resources(&bus->children);
@@ -125,7 +124,6 @@ static void __init pcibios_allocate_resources(int pass)
                                DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
                                    r->start, r->end, r->flags, disabled, pass);
                                if (pci_claim_resource(dev, idx) < 0) {
-                                       printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev));
                                        /* We'll assign a new address later */
                                        r->end -= r->start;
                                        r->start = 0;
index ba587523c015e7755b5e670ec62c96586ead264c..20f6497b2cd5d57cc25e167d3ef31487f7b8c943 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 
index c0dcec65c6b7df665b9ce9dd0e02324a165f9b57..f8dd37e495353f978ca3c4725e330909384d7a58 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 
 #include <asm/segment.h>
 #include <asm/io.h>
index 44840e73e90756c13a670a59321549d4b14c3efc..7a73aaeae3ac987fe5a0d5c8d659d7fde472a9f7 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/hardirq.h>
+#include <linux/gfp.h>
 
 #include <asm/pgalloc.h>
 #include <asm/io.h>
index 0708284f85fb3d690d4e649366ea056282a171b8..ed64588ac3a76662935dc1fddd1b9e015ebaa475 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/pagemap.h>
+#include <linux/gfp.h>
 #include <linux/swap.h>
 #include <linux/mm.h>
 #include <linux/kernel.h>
index 66f616fb4860a779d5cc1eafa68d48d41b4db0e2..c42c83d507bc42c2208b21ff978d92e84c42d161 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include <linux/sched.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/quicklist.h>
index bd883faa983d898eac8d70b873df93f37eb4fad7..8c8b0ffa6ad709d9a9d32b95ff380a3a734f84f0 100644 (file)
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
index 9942f24aff9e19067a5b74ae05bb3ae26dfdb119..7cc3380f250cc608ea8815472a5652d2b1b04c3b 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 
 #include <asm/setup.h>
 #include <asm/segment.h>
index 5c7af09ae8d1c3e830c3ff2ae0dfa2c29ac19e96..944a502c2e561a53905151eb18c0b70d90aab110 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <asm/setup.h>
index 40d8aa811e4e4506dbc97fc5575ba2091845e159..5552ddfaab5ea69c5417f955eb32aa7ddb043c70 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 
 #include <asm/setup.h>
 #include <asm/segment.h>
index 00eb1b130b63fb91cc6594cfa4b2046f4a8cd7d7..1ed4c8fedb8370e7b8403e36244b2fce043e0aae 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _ASM_DMI_H
 #define _ASM_DMI_H 1
 
+#include <linux/slab.h>
 #include <asm/io.h>
 
 /* Use normal IO mappings for DMI */
index b7515bc808a8d815708c45124661e94cc4d63286..8b9318d311a0b81897d9acc84d1a630494de457d 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/acpi.h>
 
 #include <asm/acpi-ext.h>
index f1c9f70b4e45b969183543fc0a6430a90d133786..4d1a7e9314cf53c6b76c6d77c453b520365e6855 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/efi.h>
 #include <linux/mmzone.h>
 #include <linux/nodemask.h>
+#include <linux/slab.h>
 #include <acpi/processor.h>
 #include <asm/io.h>
 #include <asm/iosapic.h>
index 7b435451b3dc225d05f453f14f8e77881f472e2b..b0b4e6e710f24a90fbf1b422d0a92bb038339f02 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
index c745d0aeb6e0a5ea306c819d67e0f4ac6ce6bc81..a0f001928502b6c1b8e692e36095df36e6b7f3b5 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/efi.h>
 #include <linux/kexec.h>
index 95ac77aeae9b8fc2194e25e4c7f0fef05f5bc887..7ded76658d2da69075bb0c748d73c8159beda9dd 100644 (file)
@@ -86,6 +86,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
index d4093a173a3ec29e7d927f1f9b1dd080c3b89af9..640479304ac0f9a1e17b33d32b2422283e479ff3 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/kernel_stat.h>
-#include <linux/slab.h>
 #include <linux/ptrace.h>
 #include <linux/random.h>      /* for rand_initialize_irq() */
 #include <linux/signal.h>
index 378b4833024f110ac7e11265341774f3a6ee75be..a0220dc5ff421effdc55e130aad53a6af39ba348 100644 (file)
@@ -85,6 +85,7 @@
 #include <linux/cpumask.h>
 #include <linux/kdebug.h>
 #include <linux/cpu.h>
+#include <linux/gfp.h>
 
 #include <asm/delay.h>
 #include <asm/machvec.h>
index f94aaa86933fd81f0b347466907e16bdfcf10781..09b4d6828c4544f6088aab1561b897cab083c1f4 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/smp.h>
 #include <linux/workqueue.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <asm/machvec.h>
index 53292abf846c453b45c2f3e3afcd57ca0e9a6308..3095654f9ab394839b9ae52509b5ec786c9f7837 100644 (file)
@@ -1,6 +1,7 @@
 /* Glue code to lib/swiotlb.c */
 
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <linux/cache.h>
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
index 703062c44fb9df33c7eefceefcf82b9598c71c59..ab985f785c140830d1a9b781685696f93ac8909a 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/rcupdate.h>
 #include <linux/completion.h>
 #include <linux/tracehook.h>
+#include <linux/slab.h>
 
 #include <asm/errno.h>
 #include <asm/intrinsics.h>
index d92765cae10a802d920eca6eaf634621b233a467..53f1648c8b813cf496abf851830a0ce21f3aa333 100644 (file)
 #include <linux/kallsyms.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
 #include <linux/personality.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/thread_info.h>
 #include <linux/unistd.h>
index b61afbbe076f6152935e79fca3eb7da61f251c71..0dec7f702448a07b6fc520342969411423d6445a 100644 (file)
@@ -11,7 +11,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/ptrace.h>
index b3a5818088d912c46a63160c016ba3e2fdaad930..28f299de290397361565b4407f3ec0736fd7a018 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/node.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/nodemask.h>
index a595823582d9cd6aa653d4ec56e5d045151c9cdb..c4696d217ce0bfe5216393cd4ad572194937175d 100644 (file)
@@ -18,9 +18,9 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/efi.h>
 #include <linux/genalloc.h>
+#include <linux/gfp.h>
 #include <asm/page.h>
 #include <asm/pal.h>
 #include <asm/system.h>
index 26e0e089bfe76b0b89772bfc7f5617abc02d2a9d..73c5c2b05f648363c87b8adec0009704e63e423e 100644 (file)
@@ -23,8 +23,8 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/percpu.h>
-#include <linux/gfp.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/kvm_host.h>
 #include <linux/kvm.h>
index 8d586d1e2515936b8b09c48215e084a853623403..61620323bb60adadf942288b53446604d8323b69 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/acpi.h>
 #include <linux/efi.h>
 #include <linux/nodemask.h>
+#include <linux/slab.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 #include <asm/meminit.h>
index b0f615759e97461052eb154c431487c90d4cbad3..1841ee7e65f9b2a11f800e1fc3c965d1c9172c10 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/log2.h>
 #include <asm/mman.h>
index f3de9d7a98b481c632fa4960211213f0a3ee307d..5dfd916e9ea610db1a047e0462d6398082bde63e 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/smp.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <asm/mmu_context.h>
index c6d6b62db66c99c05c4cc5ee8c84f19c4a768d5b..cad775a1a157b66566ef761aed4418caa0e4e871 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/bootmem.h>
 #include <linux/string.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/sn/bte.h>
 
index 66f633bff059af9b33539a9a52f89e55c2a6e9cf..8cdcb173a13877842cbcc1833b68d70037c54cfc 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/sn/sn_sal.h>
 #include "xtalk/hubdev.h"
 #include <linux/acpi.h>
+#include <linux/slab.h>
 
 
 /*
index 308e6595110e4e4f6aa03047f12333dd83663dad..4433dd019d3c92ef3fa7cf71d7df61ce58864c6b 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/sn_feature_sets.h>
index ee774c366a06c82840a89c80dfb46b3086ead611..98079f29d9a9ff19bcdcd13bebfd7104ddd06a98 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved.
  */
 
+#include <linux/slab.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/io.h>
index 40d6eeda1c4bbfe2f86031ab12dd1c5386a25311..13c15d968098d90b91beedb38855e331c73e616d 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 #include <linux/rculist.h>
+#include <linux/slab.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/arch.h>
 #include <asm/sn/intr.h>
index fbbfb970120128a29df68c549895187ea3e3013e..ebfdd6a9ae1a0ac6401581ab8de42592175a87c5 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/cpumask.h>
 #include <linux/msi.h>
+#include <linux/slab.h>
 
 #include <asm/sn/addrs.h>
 #include <asm/sn/intr.h>
index 98b684928e12eae87c840344f1e256c1d118702c..a9d310de57da650ac7c3549774729c990ceac583 100644 (file)
@@ -9,6 +9,7 @@
  * a description of how these routines should be used.
  */
 
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 #include <asm/dma.h>
index d13e5a22a558cbc4f3233c02b71bdb4ebf124e8e..3cb5cf37764429de80f7c89fdae1752db15e5ca5 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/geo.h>
index efb454534e525c2e9bbb76d4447dc2a97224332c..4d4536e3b6f3d35f9f0e84a0180a14011215603f 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/bitmap.h>
+#include <linux/slab.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/io.h>
index 012f3b82ee55d4b4792041fd8a51c633550bba52..27faba035f3a348fdb847beb1e6ca831e703ddb7 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/addrs.h>
index 777dd9a9108b1213d372ae42be06d93e0c36342a..48cca37625ebdd04d08136037eeca93d92b71b73 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 
 #include <xen/interface/xen.h>
index 67a01e1e4283f86d07bdc3de5f89c0ab3d6b7a9d..bc8c8c1511b2eb23c07d6ad82c812d62841b5d94 100644 (file)
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/ptrace.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/hardirq.h>
 
 #include <asm/io.h>
index 9f581df3952b5cb87fbae357f858003750fd9400..73e2205ebf5afba2c17ca848701c0ae026f52fab 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/bitops.h>
 #include <linux/nodemask.h>
 #include <linux/pfn.h>
+#include <linux/gfp.h>
 #include <asm/types.h>
 #include <asm/processor.h>
 #include <asm/page.h>
index c50bec8aabb1983e3517857b5abafa75f91b7ace..b46ea1714a890aa8aae707a7fe1315f3d594ec20 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
index 2bb4245404d836ca73e770ed24146f7c6c78e9b4..4bbb3c2a888057e93c264c76e029909dc7bd8884 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <asm/pgalloc.h>
index 17c3f325255de36707bcb2dac5ec0981d57a7f42..1a6be27cf165a0cd60c210e72abcf727c981c462 100644 (file)
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/reboot.h>
 #include <linux/init_task.h>
index 5d818568b343719a7ab82f9a8fb075a048a9535e..0f118ca156d9a0e8bd366e9d742989d57c5be3a3 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/rtc.h>
 #include <linux/mm.h>
index 774549accd2df34096528255822e61599af1a80b..8bc842554e5b4618ad3e77208dc5872cd184fef2 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
index b7473525b43179fa9066d3a1d978120f1caac164..34c77ce24fba5b54a46c63449620259a2a9fdd93 100644 (file)
@@ -9,9 +9,9 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
+#include <linux/gfp.h>
 
 #include <asm/setup.h>
 #include <asm/segment.h>
index 4665fc84b7dcc50ab43174bcf7760f43a5859533..02b7a03e422681032b1a62ebf45183e1ed629b21 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 
 #include <asm/setup.h>
 #include <asm/uaccess.h>
index cea5e3e4e63646abf411aeb34be8172493214a34..8da9c250d3e198e3a2b27d795b66ce9896fb13e1 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/capability.h>
index f9277e8b4159b34e81d79c56c2c47f26e1cf7361..ca0966cac72adfe68cf6eef8b680c395ee7eea5d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/list.h>
 
index 117481e86305798610f894e8f0e7b896315dc573..d5ddcdaa2347356152047deb6d272a5594e0b97a 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/bitops.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <asm/sun3x.h>
index aaf38bbbb6cdff29e9630bd35f757cf1ec85cf0f..fc61541aeb715f6f872ce55275fdf3eb1965275f 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
index 959cb249c759fd4cae926a49259a67c9893fac34..6aa66134b433cf6312703189ad240b004900a5e8 100644 (file)
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
 #include <linux/reboot.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
index f3236d0b522ddceaa39a9a468b7cc4f02d27b5d1..8a6653f56bd8b29c286b3f973191d53557721e78 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 
 #include <asm/setup.h>
 #include <asm/segment.h>
index bc32f38843f0a1cf1ca5c138129a825cfefdb1d2..902c1dfda9e530eefd41aad1ff7367f211ac529b 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <asm/setup.h>
index d5b9e1357808c40661b440b1d00a968068e05d53..8f7949e786d454bb23839707906161e4d1f885f2 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 
 #include <asm/segment.h>
 #include <asm/page.h>
index 203ec61c6d4cf79c9d632aa33b36107218215c37..76818f926539bf444c8aa577d12dc1af1296d665 100644 (file)
@@ -75,9 +75,6 @@ config LOCKDEP_SUPPORT
 config HAVE_LATENCYTOP_SUPPORT
        def_bool y
 
-config PCI
-       def_bool n
-
 config DTC
        def_bool y
 
index 836832dd9b26cb8ba7bff598b805e308f4b95c6d..72f6e85837467679354d37ec148db56eb4868363 100644 (file)
@@ -84,7 +84,7 @@ define archhelp
   echo '* linux.bin    - Create raw binary'
   echo '  linux.bin.gz - Create compressed raw binary'
   echo '  simpleImage.<dt> - ELF image with $(arch)/boot/dts/<dt>.dts linked in'
-  echo '                   - stripped elf with fdt blob
+  echo '                   - stripped elf with fdt blob'
   echo '  simpleImage.<dt>.unstrip - full ELF image with fdt blob'
   echo '  *_defconfig      - Select default config from arch/microblaze/configs'
   echo ''
@@ -94,3 +94,5 @@ define archhelp
   echo '  name of a dts file from the arch/microblaze/boot/dts/ directory'
   echo '  (minus the .dts extension).'
 endef
+
+MRPROPER_FILES += $(boot)/simpleImage.*
index 902cf9846c3cb9b89f0940a8a635554cb265fd0b..57f50c2371c6e36372962886180324ffba5b5fd2 100644 (file)
@@ -23,8 +23,6 @@ $(obj)/system.dtb: $(obj)/$(DTB).dtb
 endif
 
 $(obj)/linux.bin: vmlinux FORCE
-       [ -n $(CONFIG_INITRAMFS_SOURCE) ] && [ ! -e $(CONFIG_INITRAMFS_SOURCE) ] && \
-       touch $(CONFIG_INITRAMFS_SOURCE) || echo "No CPIO image"
        $(call if_changed,objcopy)
        $(call if_changed,uimage)
        @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
@@ -62,6 +60,4 @@ quiet_cmd_dtc = DTC     $@
 $(obj)/%.dtb: $(dtstree)/%.dts FORCE
        $(call if_changed,dtc)
 
-clean-kernel += linux.bin linux.bin.gz simpleImage.*
-
-clean-files += *.dtb simpleImage.*.unstrip
+clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub
index 563c6b9453f030a34344cf0e9d63f1a5dd994318..8eeb09211ece1b7f32fc31b6655a2cd8628d0ea6 100644 (file)
@@ -14,7 +14,6 @@
 #include <asm/ptrace.h>
 #include <asm/setup.h>
 #include <asm/registers.h>
-#include <asm/segment.h>
 #include <asm/entry.h>
 #include <asm/current.h>
 
diff --git a/arch/microblaze/include/asm/segment.h b/arch/microblaze/include/asm/segment.h
deleted file mode 100644 (file)
index 0e7102c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
- * Copyright (C) 2008-2009 PetaLogix
- * Copyright (C) 2006 Atmark Techno, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef _ASM_MICROBLAZE_SEGMENT_H
-#define _ASM_MICROBLAZE_SEGMENT_H
-
-# ifndef __ASSEMBLY__
-
-typedef struct {
-       unsigned long seg;
-} mm_segment_t;
-
-/*
- * On Microblaze the fs value is actually the top of the corresponding
- * address space.
- *
- * The fs value determines whether argument validity checking should be
- * performed or not. If get_fs() == USER_DS, checking is performed, with
- * get_fs() == KERNEL_DS, checking is bypassed.
- *
- * For historical reasons, these macros are grossly misnamed.
- *
- * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal.
- */
-# define MAKE_MM_SEG(s)       ((mm_segment_t) { (s) })
-
-#  ifndef CONFIG_MMU
-#  define KERNEL_DS    MAKE_MM_SEG(0)
-#  define USER_DS      KERNEL_DS
-#  else
-#  define KERNEL_DS    MAKE_MM_SEG(0xFFFFFFFF)
-#  define USER_DS      MAKE_MM_SEG(TASK_SIZE - 1)
-#  endif
-
-# define get_ds()      (KERNEL_DS)
-# define get_fs()      (current_thread_info()->addr_limit)
-# define set_fs(val)   (current_thread_info()->addr_limit = (val))
-
-# define segment_eq(a, b)      ((a).seg == (b).seg)
-
-# endif /* __ASSEMBLY__ */
-#endif /* _ASM_MICROBLAZE_SEGMENT_H */
index 6e92885d381a80ee3adc680632415c3911ecdb64..b2ca80f646403d683fa9d9a10e3ea79f67bafb0c 100644 (file)
@@ -19,7 +19,6 @@
 #ifndef __ASSEMBLY__
 # include <linux/types.h>
 # include <asm/processor.h>
-# include <asm/segment.h>
 
 /*
  * low level task data that entry.S needs immediate access to
@@ -60,6 +59,10 @@ struct cpu_context {
        __u32   fsr;
 };
 
+typedef struct {
+       unsigned long seg;
+} mm_segment_t;
+
 struct thread_info {
        struct task_struct      *task; /* main task structure */
        struct exec_domain      *exec_domain; /* execution domain */
index bcb8b41d55afb9b415f3f803259ada2b3326469a..2e1353c2d18d7d256a0d499ac3f6beae581a6dee 100644 (file)
@@ -24,6 +24,7 @@ extern void _tlbie(unsigned long address);
 extern void _tlbia(void);
 
 #define __tlbia()      { preempt_disable(); _tlbia(); preempt_enable(); }
+#define __tlbie(x)     { _tlbie(x); }
 
 static inline void local_flush_tlb_all(void)
        { __tlbia(); }
@@ -31,7 +32,7 @@ static inline void local_flush_tlb_mm(struct mm_struct *mm)
        { __tlbia(); }
 static inline void local_flush_tlb_page(struct vm_area_struct *vma,
                                unsigned long vmaddr)
-       { _tlbie(vmaddr); }
+       { __tlbie(vmaddr); }
 static inline void local_flush_tlb_range(struct vm_area_struct *vma,
                unsigned long start, unsigned long end)
        { __tlbia(); }
index 371bd6e56d9a20e60624147a050366f9fd06d2ea..446bec29b142bc5509a445f28146c166c756cb11 100644 (file)
 #include <asm/mmu.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
-#include <asm/segment.h>
 #include <linux/string.h>
 
 #define VERIFY_READ    0
 #define VERIFY_WRITE   1
 
-#define __clear_user(addr, n)  (memset((void *)(addr), 0, (n)), 0)
-
-#ifndef CONFIG_MMU
-
-extern int ___range_ok(unsigned long addr, unsigned long size);
-
-#define __range_ok(addr, size) \
-               ___range_ok((unsigned long)(addr), (unsigned long)(size))
-
-#define access_ok(type, addr, size) (__range_ok((addr), (size)) == 0)
-#define __access_ok(add, size) (__range_ok((addr), (size)) == 0)
-
-/* Undefined function to trigger linker error */
-extern int bad_user_access_length(void);
-
-/* FIXME this is function for optimalization -> memcpy */
-#define __get_user(var, ptr)                           \
-({                                                     \
-       int __gu_err = 0;                               \
-       switch (sizeof(*(ptr))) {                       \
-       case 1:                                         \
-       case 2:                                         \
-       case 4:                                         \
-               (var) = *(ptr);                         \
-               break;                                  \
-       case 8:                                         \
-               memcpy((void *) &(var), (ptr), 8);      \
-               break;                                  \
-       default:                                        \
-               (var) = 0;                              \
-               __gu_err = __get_user_bad();            \
-               break;                                  \
-       }                                               \
-       __gu_err;                                       \
-})
+/*
+ * On Microblaze the fs value is actually the top of the corresponding
+ * address space.
+ *
+ * The fs value determines whether argument validity checking should be
+ * performed or not. If get_fs() == USER_DS, checking is performed, with
+ * get_fs() == KERNEL_DS, checking is bypassed.
+ *
+ * For historical reasons, these macros are grossly misnamed.
+ *
+ * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal.
+ */
+# define MAKE_MM_SEG(s)       ((mm_segment_t) { (s) })
 
-#define __get_user_bad()       (bad_user_access_length(), (-EFAULT))
+#  ifndef CONFIG_MMU
+#  define KERNEL_DS    MAKE_MM_SEG(0)
+#  define USER_DS      KERNEL_DS
+#  else
+#  define KERNEL_DS    MAKE_MM_SEG(0xFFFFFFFF)
+#  define USER_DS      MAKE_MM_SEG(TASK_SIZE - 1)
+#  endif
 
-/* FIXME is not there defined __pu_val */
-#define __put_user(var, ptr)                                   \
-({                                                             \
-       int __pu_err = 0;                                       \
-       switch (sizeof(*(ptr))) {                               \
-       case 1:                                                 \
-       case 2:                                                 \
-       case 4:                                                 \
-               *(ptr) = (var);                                 \
-               break;                                          \
-       case 8: {                                               \
-               typeof(*(ptr)) __pu_val = (var);                \
-               memcpy(ptr, &__pu_val, sizeof(__pu_val));       \
-               }                                               \
-               break;                                          \
-       default:                                                \
-               __pu_err = __put_user_bad();                    \
-               break;                                          \
-       }                                                       \
-       __pu_err;                                               \
-})
+# define get_ds()      (KERNEL_DS)
+# define get_fs()      (current_thread_info()->addr_limit)
+# define set_fs(val)   (current_thread_info()->addr_limit = (val))
 
-#define __put_user_bad()       (bad_user_access_length(), (-EFAULT))
+# define segment_eq(a, b)      ((a).seg == (b).seg)
 
-#define put_user(x, ptr)       __put_user((x), (ptr))
-#define get_user(x, ptr)       __get_user((x), (ptr))
+/*
+ * The exception table consists of pairs of addresses: the first is the
+ * address of an instruction that is allowed to fault, and the second is
+ * the address at which the program should continue. No registers are
+ * modified, so it is entirely up to the continuation code to figure out
+ * what to do.
+ *
+ * All the routines below use bits of fixup code that are out of line
+ * with the main instruction path. This means when everything is well,
+ * we don't even have to jump over them. Further, they do not intrude
+ * on our cache or tlb entries.
+ */
+struct exception_table_entry {
+       unsigned long insn, fixup;
+};
 
-#define copy_to_user(to, from, n)      (memcpy((to), (from), (n)), 0)
-#define copy_from_user(to, from, n)    (memcpy((to), (from), (n)), 0)
+/* Returns 0 if exception not found and fixup otherwise.  */
+extern unsigned long search_exception_table(unsigned long);
 
-#define __copy_to_user(to, from, n)    (copy_to_user((to), (from), (n)))
-#define __copy_from_user(to, from, n)  (copy_from_user((to), (from), (n)))
-#define __copy_to_user_inatomic(to, from, n) \
-                       (__copy_to_user((to), (from), (n)))
-#define __copy_from_user_inatomic(to, from, n) \
-                       (__copy_from_user((to), (from), (n)))
+#ifndef CONFIG_MMU
 
-static inline unsigned long clear_user(void *addr, unsigned long size)
+/* Check against bounds of physical memory */
+static inline int ___range_ok(unsigned long addr, unsigned long size)
 {
-       if (access_ok(VERIFY_WRITE, addr, size))
-               size = __clear_user(addr, size);
-       return size;
+       return ((addr < memory_start) ||
+               ((addr + size) > memory_end));
 }
 
-/* Returns 0 if exception not found and fixup otherwise.  */
-extern unsigned long search_exception_table(unsigned long);
+#define __range_ok(addr, size) \
+               ___range_ok((unsigned long)(addr), (unsigned long)(size))
 
-extern long strncpy_from_user(char *dst, const char *src, long count);
-extern long strnlen_user(const char *src, long count);
+#define access_ok(type, addr, size) (__range_ok((addr), (size)) == 0)
 
-#else /* CONFIG_MMU */
+#else
 
 /*
  * Address is valid if:
@@ -129,24 +101,88 @@ extern long strnlen_user(const char *src, long count);
 /* || printk("access_ok failed for %s at 0x%08lx (size %d), seg 0x%08x\n",
  type?"WRITE":"READ",addr,size,get_fs().seg)) */
 
-/*
- * All the __XXX versions macros/functions below do not perform
- * access checking. It is assumed that the necessary checks have been
- * already performed before the finction (macro) is called.
- */
+#endif
 
-#define get_user(x, ptr)                                               \
-({                                                                     \
-       access_ok(VERIFY_READ, (ptr), sizeof(*(ptr)))                   \
-               ? __get_user((x), (ptr)) : -EFAULT;                     \
-})
+#ifdef CONFIG_MMU
+# define __FIXUP_SECTION       ".section .fixup,\"ax\"\n"
+# define __EX_TABLE_SECTION    ".section __ex_table,\"a\"\n"
+#else
+# define __FIXUP_SECTION       ".section .discard,\"ax\"\n"
+# define __EX_TABLE_SECTION    ".section .discard,\"a\"\n"
+#endif
 
-#define put_user(x, ptr)                                               \
-({                                                                     \
-       access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr)))                  \
-               ? __put_user((x), (ptr)) : -EFAULT;                     \
+extern unsigned long __copy_tofrom_user(void __user *to,
+               const void __user *from, unsigned long size);
+
+/* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */
+static inline unsigned long __must_check __clear_user(void __user *to,
+                                                       unsigned long n)
+{
+       /* normal memset with two words to __ex_table */
+       __asm__ __volatile__ (                          \
+                       "1:     sb      r0, %2, r0;"    \
+                       "       addik   %0, %0, -1;"    \
+                       "       bneid   %0, 1b;"        \
+                       "       addik   %2, %2, 1;"     \
+                       "2:                     "       \
+                       __EX_TABLE_SECTION              \
+                       ".word  1b,2b;"                 \
+                       ".previous;"                    \
+               : "=r"(n)                               \
+               : "0"(n), "r"(to)
+       );
+       return n;
+}
+
+static inline unsigned long __must_check clear_user(void __user *to,
+                                                       unsigned long n)
+{
+       might_sleep();
+       if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
+               return n;
+
+       return __clear_user(to, n);
+}
+
+/* put_user and get_user macros */
+extern long __user_bad(void);
+
+#define __get_user_asm(insn, __gu_ptr, __gu_val, __gu_err)     \
+({                                                             \
+       __asm__ __volatile__ (                                  \
+                       "1:"    insn    " %1, %2, r0;"          \
+                       "       addk    %0, r0, r0;"            \
+                       "2:                     "               \
+                       __FIXUP_SECTION                         \
+                       "3:     brid    2b;"                    \
+                       "       addik   %0, r0, %3;"            \
+                       ".previous;"                            \
+                       __EX_TABLE_SECTION                      \
+                       ".word  1b,3b;"                         \
+                       ".previous;"                            \
+               : "=&r"(__gu_err), "=r"(__gu_val)               \
+               : "r"(__gu_ptr), "i"(-EFAULT)                   \
+       );                                                      \
 })
 
+/**
+ * get_user: - Get a simple variable from user space.
+ * @x:   Variable to store result.
+ * @ptr: Source address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple variable from user space to kernel
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and the result of
+ * dereferencing @ptr must be assignable to @x without a cast.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ * On error, the variable @x is set to zero.
+ */
+
 #define __get_user(x, ptr)                                             \
 ({                                                                     \
        unsigned long __gu_val;                                         \
@@ -163,30 +199,74 @@ extern long strnlen_user(const char *src, long count);
                __get_user_asm("lw", (ptr), __gu_val, __gu_err);        \
                break;                                                  \
        default:                                                        \
-               __gu_val = 0; __gu_err = -EINVAL;                       \
+               /* __gu_val = 0; __gu_err = -EINVAL;*/ __gu_err = __user_bad();\
        }                                                               \
        x = (__typeof__(*(ptr))) __gu_val;                              \
        __gu_err;                                                       \
 })
 
-#define __get_user_asm(insn, __gu_ptr, __gu_val, __gu_err)             \
+
+#define get_user(x, ptr)                                               \
 ({                                                                     \
-       __asm__ __volatile__ (                                          \
-                       "1:"    insn    " %1, %2, r0;                   \
-                               addk    %0, r0, r0;                     \
-                       2:                                              \
-                       .section .fixup,\"ax\";                         \
-                       3:      brid    2b;                             \
-                               addik   %0, r0, %3;                     \
-                       .previous;                                      \
-                       .section __ex_table,\"a\";                      \
-                       .word   1b,3b;                                  \
-                       .previous;"                                     \
-               : "=r"(__gu_err), "=r"(__gu_val)                        \
-               : "r"(__gu_ptr), "i"(-EFAULT)                           \
-       );                                                              \
+       access_ok(VERIFY_READ, (ptr), sizeof(*(ptr)))                   \
+               ? __get_user((x), (ptr)) : -EFAULT;                     \
+})
+
+#define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err)     \
+({                                                             \
+       __asm__ __volatile__ (                                  \
+                       "1:"    insn    " %1, %2, r0;"          \
+                       "       addk    %0, r0, r0;"            \
+                       "2:                     "               \
+                       __FIXUP_SECTION                         \
+                       "3:     brid    2b;"                    \
+                       "       addik   %0, r0, %3;"            \
+                       ".previous;"                            \
+                       __EX_TABLE_SECTION                      \
+                       ".word  1b,3b;"                         \
+                       ".previous;"                            \
+               : "=&r"(__gu_err)                               \
+               : "r"(__gu_val), "r"(__gu_ptr), "i"(-EFAULT)    \
+       );                                                      \
 })
 
+#define __put_user_asm_8(__gu_ptr, __gu_val, __gu_err)         \
+({                                                             \
+       __asm__ __volatile__ (" lwi     %0, %1, 0;"             \
+                       "1:     swi     %0, %2, 0;"             \
+                       "       lwi     %0, %1, 4;"             \
+                       "2:     swi     %0, %2, 4;"             \
+                       "       addk    %0, r0, r0;"            \
+                       "3:                     "               \
+                       __FIXUP_SECTION                         \
+                       "4:     brid    3b;"                    \
+                       "       addik   %0, r0, %3;"            \
+                       ".previous;"                            \
+                       __EX_TABLE_SECTION                      \
+                       ".word  1b,4b,2b,4b;"                   \
+                       ".previous;"                            \
+               : "=&r"(__gu_err)                               \
+               : "r"(&__gu_val), "r"(__gu_ptr), "i"(-EFAULT)   \
+               );                                              \
+})
+
+/**
+ * put_user: - Write a simple value into user space.
+ * @x:   Value to copy to user space.
+ * @ptr: Destination address, in user space.
+ *
+ * Context: User context only.  This function may sleep.
+ *
+ * This macro copies a single simple value from kernel space to user
+ * space.  It supports simple types like char and int, but not larger
+ * data types like structures or arrays.
+ *
+ * @ptr must have pointer-to-simple-variable type, and @x must be assignable
+ * to the result of dereferencing @ptr.
+ *
+ * Returns zero on success, or -EFAULT on error.
+ */
+
 #define __put_user(x, ptr)                                             \
 ({                                                                     \
        __typeof__(*(ptr)) volatile __gu_val = (x);                     \
@@ -195,7 +275,7 @@ extern long strnlen_user(const char *src, long count);
        case 1:                                                         \
                __put_user_asm("sb", (ptr), __gu_val, __gu_err);        \
                break;                                                  \
-       case 2:                                                         \
+       case 2:                                                         \
                __put_user_asm("sh", (ptr), __gu_val, __gu_err);        \
                break;                                                  \
        case 4:                                                         \
@@ -205,121 +285,82 @@ extern long strnlen_user(const char *src, long count);
                __put_user_asm_8((ptr), __gu_val, __gu_err);            \
                break;                                                  \
        default:                                                        \
-               __gu_err = -EINVAL;                                     \
+               /*__gu_err = -EINVAL;*/ __gu_err = __user_bad();        \
        }                                                               \
        __gu_err;                                                       \
 })
 
-#define __put_user_asm_8(__gu_ptr, __gu_val, __gu_err) \
-({                                                     \
-__asm__ __volatile__ ("        lwi     %0, %1, 0;              \
-               1:      swi     %0, %2, 0;              \
-                       lwi     %0, %1, 4;              \
-               2:      swi     %0, %2, 4;              \
-                       addk    %0,r0,r0;               \
-               3:                                      \
-               .section .fixup,\"ax\";                 \
-               4:      brid    3b;                     \
-                       addik   %0, r0, %3;             \
-               .previous;                              \
-               .section __ex_table,\"a\";              \
-               .word   1b,4b,2b,4b;                    \
-               .previous;"                             \
-       : "=&r"(__gu_err)                               \
-       : "r"(&__gu_val),                               \
-       "r"(__gu_ptr), "i"(-EFAULT)                     \
-       );                                              \
-})
+#ifndef CONFIG_MMU
 
-#define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err)     \
-({                                                             \
-       __asm__ __volatile__ (                                  \
-                       "1:"    insn    " %1, %2, r0;           \
-                               addk    %0, r0, r0;             \
-                       2:                                      \
-                       .section .fixup,\"ax\";                 \
-                       3:      brid    2b;                     \
-                               addik   %0, r0, %3;             \
-                       .previous;                              \
-                       .section __ex_table,\"a\";              \
-                       .word   1b,3b;                          \
-                       .previous;"                             \
-               : "=r"(__gu_err)                                \
-               : "r"(__gu_val), "r"(__gu_ptr), "i"(-EFAULT)    \
-       );                                                      \
-})
+#define put_user(x, ptr)       __put_user((x), (ptr))
 
-/*
- * Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail.
- */
-static inline int clear_user(char *to, int size)
-{
-       if (size && access_ok(VERIFY_WRITE, to, size)) {
-               __asm__ __volatile__ ("                         \
-                               1:                              \
-                                       sb      r0, %2, r0;     \
-                                       addik   %0, %0, -1;     \
-                                       bneid   %0, 1b;         \
-                                       addik   %2, %2, 1;      \
-                               2:                              \
-                               .section __ex_table,\"a\";      \
-                               .word   1b,2b;                  \
-                               .section .text;"                \
-                       : "=r"(size)                            \
-                       : "0"(size), "r"(to)
-               );
-       }
-       return size;
-}
+#else /* CONFIG_MMU */
 
-#define __copy_from_user(to, from, n)  copy_from_user((to), (from), (n))
+#define put_user(x, ptr)                                               \
+({                                                                     \
+       access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr)))                  \
+               ? __put_user((x), (ptr)) : -EFAULT;                     \
+})
+#endif /* CONFIG_MMU */
+
+/* copy_to_from_user */
+#define __copy_from_user(to, from, n)  \
+       __copy_tofrom_user((__force void __user *)(to), \
+                               (void __user *)(from), (n))
 #define __copy_from_user_inatomic(to, from, n) \
                copy_from_user((to), (from), (n))
 
-#define copy_to_user(to, from, n)                                      \
-       (access_ok(VERIFY_WRITE, (to), (n)) ?                           \
-               __copy_tofrom_user((void __user *)(to),                 \
-                       (__force const void __user *)(from), (n))       \
-               : -EFAULT)
+static inline long copy_from_user(void *to,
+               const void __user *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_READ, from, n))
+               return __copy_from_user(to, from, n);
+       return n;
+}
 
-#define __copy_to_user(to, from, n)    copy_to_user((to), (from), (n))
+#define __copy_to_user(to, from, n)    \
+               __copy_tofrom_user((void __user *)(to), \
+                       (__force const void __user *)(from), (n))
 #define __copy_to_user_inatomic(to, from, n)   copy_to_user((to), (from), (n))
 
-#define copy_from_user(to, from, n)                                    \
-       (access_ok(VERIFY_READ, (from), (n)) ?                          \
-               __copy_tofrom_user((__force void __user *)(to),         \
-                       (void __user *)(from), (n))                     \
-               : -EFAULT)
+static inline long copy_to_user(void __user *to,
+               const void *from, unsigned long n)
+{
+       might_sleep();
+       if (access_ok(VERIFY_WRITE, to, n))
+               return __copy_to_user(to, from, n);
+       return n;
+}
 
+/*
+ * Copy a null terminated string from userspace.
+ */
 extern int __strncpy_user(char *to, const char __user *from, int len);
-extern int __strnlen_user(const char __user *sstr, int len);
 
-#define strncpy_from_user(to, from, len)       \
-               (access_ok(VERIFY_READ, from, 1) ?      \
-                       __strncpy_user(to, from, len) : -EFAULT)
-#define strnlen_user(str, len) \
-               (access_ok(VERIFY_READ, str, 1) ? __strnlen_user(str, len) : 0)
+#define __strncpy_from_user    __strncpy_user
 
-#endif /* CONFIG_MMU */
-
-extern unsigned long __copy_tofrom_user(void __user *to,
-               const void __user *from, unsigned long size);
+static inline long
+strncpy_from_user(char *dst, const char __user *src, long count)
+{
+       if (!access_ok(VERIFY_READ, src, 1))
+               return -EFAULT;
+       return __strncpy_from_user(dst, src, count);
+}
 
 /*
- * The exception table consists of pairs of addresses: the first is the
- * address of an instruction that is allowed to fault, and the second is
- * the address at which the program should continue. No registers are
- * modified, so it is entirely up to the continuation code to figure out
- * what to do.
+ * Return the size of a string (including the ending 0)
  *
- * All the routines below use bits of fixup code that are out of line
- * with the main instruction path. This means when everything is well,
- * we don't even have to jump over them. Further, they do not intrude
- * on our cache or tlb entries.
+ * Return 0 on exception, a value greater than N if too long
  */
-struct exception_table_entry {
-       unsigned long insn, fixup;
-};
+extern int __strnlen_user(const char __user *sstr, int len);
+
+static inline long strnlen_user(const char __user *src, long n)
+{
+       if (!access_ok(VERIFY_READ, src, 1))
+               return 0;
+       return __strnlen_user(src, n);
+}
 
 #endif  /* __ASSEMBLY__ */
 #endif /* __KERNEL__ */
index 991d71311b0ebaad156a03e03f9f4f2cce277d30..255ef880351e793b38ef9b3e853c8c30f6ed40be 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <asm/cpuinfo.h>
 #include <asm/pvr.h>
 
index b1084974fccdb4f49046113b479eb160fd961ed8..ce72dd4967cfe2085ada81f60e54f3c55ee4c2e7 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 #include <linux/dma-debug.h>
 #include <asm/bug.h>
 #include <asm/cacheflush.h>
@@ -37,7 +38,7 @@ static inline void __dma_sync_page(unsigned long paddr, unsigned long offset,
 
 static unsigned long get_dma_direct_offset(struct device *dev)
 {
-       if (dev)
+       if (likely(dev))
                return (unsigned long)dev->archdata.dma_data;
 
        return PCI_DRAM_OFFSET; /* FIXME Not sure if is correct */
index cb7815cfe5ab7d74418f5a4722e7b7854903959e..da6a5f5dc76624797af0dd60a577f8689637f5e1 100644 (file)
@@ -51,6 +51,12 @@ swapper_pg_dir:
 
        .text
 ENTRY(_start)
+#if CONFIG_KERNEL_BASE_ADDR == 0
+       brai    TOPHYS(real_start)
+       .org    0x100
+real_start:
+#endif
+
        mfs     r1, rmsr
        andi    r1, r1, ~2
        mts     rmsr, r1
@@ -99,8 +105,8 @@ no_fdt_arg:
        tophys(r4,r4)                   /* convert to phys address */
        ori     r3, r0, COMMAND_LINE_SIZE - 1 /* number of loops */
 _copy_command_line:
-       lbu     r2, r5, r6 /* r7=r5+r6 - r5 contain pointer to command line */
-       sb      r2, r4, r6              /* addr[r4+r6]= r7*/
+       lbu     r2, r5, r6 /* r2=r5+r6 - r5 contain pointer to command line */
+       sb      r2, r4, r6              /* addr[r4+r6]= r2*/
        addik   r6, r6, 1               /* increment counting */
        bgtid   r3, _copy_command_line  /* loop for all entries       */
        addik   r3, r3, -1              /* descrement loop */
@@ -128,7 +134,7 @@ _copy_bram:
         * virtual to physical.
         */
        nop
-       addik   r3, r0, 63              /* Invalidate all TLB entries */
+       addik   r3, r0, MICROBLAZE_TLB_SIZE -1  /* Invalidate all TLB entries */
 _invalidate:
        mts     rtlbx, r3
        mts     rtlbhi, r0                      /* flush: ensure V is clear   */
index 2b86c03aa84187cb5857974fba2cb949e349ce93..995a2123635bc2dbb0d9121e500e0dc6ead4494c 100644 (file)
@@ -313,13 +313,13 @@ _hw_exception_handler:
        mfs     r5, rmsr;
        nop
        swi     r5, r1, 0;
-       mfs     r3, resr
+       mfs     r4, resr
        nop
-       mfs     r4, rear;
+       mfs     r3, rear;
        nop
 
 #ifndef CONFIG_MMU
-       andi    r5, r3, 0x1000;         /* Check ESR[DS] */
+       andi    r5, r4, 0x1000;         /* Check ESR[DS] */
        beqi    r5, not_in_delay_slot;  /* Branch if ESR[DS] not set */
        mfs     r17, rbtr;      /* ESR[DS] set - return address in BTR */
        nop
@@ -327,13 +327,14 @@ not_in_delay_slot:
        swi     r17, r1, PT_R17
 #endif
 
-       andi    r5, r3, 0x1F;           /* Extract ESR[EXC] */
+       andi    r5, r4, 0x1F;           /* Extract ESR[EXC] */
 
 #ifdef CONFIG_MMU
        /* Calculate exception vector offset = r5 << 2 */
        addk    r6, r5, r5; /* << 1 */
        addk    r6, r6, r6; /* << 2 */
 
+#ifdef DEBUG
 /* counting which exception happen */
        lwi     r5, r0, 0x200 + TOPHYS(r0_ram)
        addi    r5, r5, 1
@@ -341,6 +342,7 @@ not_in_delay_slot:
        lwi     r5, r6, 0x200 + TOPHYS(r0_ram)
        addi    r5, r5, 1
        swi     r5, r6, 0x200 + TOPHYS(r0_ram)
+#endif
 /* end */
        /* Load the HW Exception vector */
        lwi     r6, r6, TOPHYS(_MB_HW_ExceptionVectorTable)
@@ -376,7 +378,7 @@ handle_other_ex: /* Handle Other exceptions here */
        swi     r18, r1, PT_R18
 
        or      r5, r1, r0
-       andi    r6, r3, 0x1F; /* Load ESR[EC] */
+       andi    r6, r4, 0x1F; /* Load ESR[EC] */
        lwi     r7, r0, PER_CPU(KM) /* MS: saving current kernel mode to regs */
        swi     r7, r1, PT_MODE
        mfs     r7, rfsr
@@ -426,11 +428,11 @@ handle_other_ex: /* Handle Other exceptions here */
  */
 handle_unaligned_ex:
        /* Working registers already saved: R3, R4, R5, R6
-        *  R3 = ESR
-        *  R4 = EAR
+        *  R4 = ESR
+        *  R3 = EAR
         */
 #ifdef CONFIG_MMU
-       andi    r6, r3, 0x1000                  /* Check ESR[DS] */
+       andi    r6, r4, 0x1000                  /* Check ESR[DS] */
        beqi    r6, _no_delayslot               /* Branch if ESR[DS] not set */
        mfs     r17, rbtr;      /* ESR[DS] set - return address in BTR */
        nop
@@ -439,7 +441,7 @@ _no_delayslot:
        RESTORE_STATE;
        bri     unaligned_data_trap
 #endif
-       andi    r6, r3, 0x3E0; /* Mask and extract the register operand */
+       andi    r6, r4, 0x3E0; /* Mask and extract the register operand */
        srl     r6, r6; /* r6 >> 5 */
        srl     r6, r6;
        srl     r6, r6;
@@ -448,33 +450,33 @@ _no_delayslot:
        /* Store the register operand in a temporary location */
        sbi     r6, r0, TOPHYS(ex_reg_op);
 
-       andi    r6, r3, 0x400; /* Extract ESR[S] */
+       andi    r6, r4, 0x400; /* Extract ESR[S] */
        bnei    r6, ex_sw;
 ex_lw:
-       andi    r6, r3, 0x800; /* Extract ESR[W] */
+       andi    r6, r4, 0x800; /* Extract ESR[W] */
        beqi    r6, ex_lhw;
-       lbui    r5, r4, 0; /* Exception address in r4 */
+       lbui    r5, r3, 0; /* Exception address in r3 */
        /* Load a word, byte-by-byte from destination address
                and save it in tmp space */
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_0);
-       lbui    r5, r4, 1;
+       lbui    r5, r3, 1;
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_1);
-       lbui    r5, r4, 2;
+       lbui    r5, r3, 2;
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_2);
-       lbui    r5, r4, 3;
+       lbui    r5, r3, 3;
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_3);
-       /* Get the destination register value into r3 */
-       lwi     r3, r0, TOPHYS(ex_tmp_data_loc_0);
+       /* Get the destination register value into r4 */
+       lwi     r4, r0, TOPHYS(ex_tmp_data_loc_0);
        bri     ex_lw_tail;
 ex_lhw:
-       lbui    r5, r4, 0; /* Exception address in r4 */
+       lbui    r5, r3, 0; /* Exception address in r3 */
        /* Load a half-word, byte-by-byte from destination
                address and save it in tmp space */
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_0);
-       lbui    r5, r4, 1;
+       lbui    r5, r3, 1;
        sbi     r5, r0, TOPHYS(ex_tmp_data_loc_1);
-       /* Get the destination register value into r3 */
-       lhui    r3, r0, TOPHYS(ex_tmp_data_loc_0);
+       /* Get the destination register value into r4 */
+       lhui    r4, r0, TOPHYS(ex_tmp_data_loc_0);
 ex_lw_tail:
        /* Get the destination register number into r5 */
        lbui    r5, r0, TOPHYS(ex_reg_op);
@@ -502,25 +504,25 @@ ex_sw_tail:
        andi    r6, r6, 0x800; /* Extract ESR[W] */
        beqi    r6, ex_shw;
        /* Get the word - delay slot */
-       swi     r3, r0, TOPHYS(ex_tmp_data_loc_0);
+       swi     r4, r0, TOPHYS(ex_tmp_data_loc_0);
        /* Store the word, byte-by-byte into destination address */
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_0);
-       sbi     r3, r4, 0;
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_1);
-       sbi     r3, r4, 1;
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_2);
-       sbi     r3, r4, 2;
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_3);
-       sbi     r3, r4, 3;
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_0);
+       sbi     r4, r3, 0;
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_1);
+       sbi     r4, r3, 1;
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_2);
+       sbi     r4, r3, 2;
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_3);
+       sbi     r4, r3, 3;
        bri     ex_handler_done;
 
 ex_shw:
        /* Store the lower half-word, byte-by-byte into destination address */
-       swi     r3, r0, TOPHYS(ex_tmp_data_loc_0);
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_2);
-       sbi     r3, r4, 0;
-       lbui    r3, r0, TOPHYS(ex_tmp_data_loc_3);
-       sbi     r3, r4, 1;
+       swi     r4, r0, TOPHYS(ex_tmp_data_loc_0);
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_2);
+       sbi     r4, r3, 0;
+       lbui    r4, r0, TOPHYS(ex_tmp_data_loc_3);
+       sbi     r4, r3, 1;
 ex_sw_end: /* Exception handling of store word, ends. */
 
 ex_handler_done:
@@ -560,21 +562,16 @@ ex_handler_done:
                 */
                mfs     r11, rpid
                nop
-               bri     4
-               mfs     r3, rear                /* Get faulting address */
-               nop
                /* If we are faulting a kernel address, we have to use the
                 * kernel page tables.
                 */
-               ori     r4, r0, CONFIG_KERNEL_START
-               cmpu    r4, r3, r4
-               bgti    r4, ex3
+               ori     r5, r0, CONFIG_KERNEL_START
+               cmpu    r5, r3, r5
+               bgti    r5, ex3
                /* First, check if it was a zone fault (which means a user
                 * tried to access a kernel or read-protected page - always
                 * a SEGV). All other faults here must be stores, so no
                 * need to check ESR_S as well. */
-               mfs     r4, resr
-               nop
                andi    r4, r4, 0x800           /* ESR_Z - zone protection */
                bnei    r4, ex2
 
@@ -589,8 +586,6 @@ ex_handler_done:
                 * tried to access a kernel or read-protected page - always
                 * a SEGV). All other faults here must be stores, so no
                 * need to check ESR_S as well. */
-               mfs     r4, resr
-               nop
                andi    r4, r4, 0x800           /* ESR_Z */
                bnei    r4, ex2
                /* get current task address */
@@ -665,8 +660,6 @@ ex_handler_done:
                 * R3 = ESR
                 */
 
-               mfs     r3, rear                /* Get faulting address */
-               nop
                RESTORE_STATE;
                bri     page_fault_instr_trap
 
@@ -677,18 +670,15 @@ ex_handler_done:
         */
        handle_data_tlb_miss_exception:
                /* Working registers already saved: R3, R4, R5, R6
-                * R3 = ESR
+                * R3 = EAR, R4 = ESR
                 */
                mfs     r11, rpid
                nop
-               bri     4
-               mfs     r3, rear                /* Get faulting address */
-               nop
 
                /* If we are faulting a kernel address, we have to use the
                 * kernel page tables. */
-               ori     r4, r0, CONFIG_KERNEL_START
-               cmpu    r4, r3, r4
+               ori     r6, r0, CONFIG_KERNEL_START
+               cmpu    r4, r3, r6
                bgti    r4, ex5
                ori     r4, r0, swapper_pg_dir
                mts     rpid, r0                /* TLB will have 0 TID */
@@ -731,9 +721,8 @@ ex_handler_done:
                 * Many of these bits are software only. Bits we don't set
                 * here we (properly should) assume have the appropriate value.
                 */
+               brid    finish_tlb_load
                andni   r4, r4, 0x0ce2          /* Make sure 20, 21 are zero */
-
-               bri     finish_tlb_load
        ex7:
                /* The bailout. Restore registers to pre-exception conditions
                 * and call the heavyweights to help us out.
@@ -754,9 +743,6 @@ ex_handler_done:
                 */
                mfs     r11, rpid
                nop
-               bri     4
-               mfs     r3, rear                /* Get faulting address */
-               nop
 
                /* If we are faulting a kernel address, we have to use the
                 * kernel page tables.
@@ -792,7 +778,7 @@ ex_handler_done:
                lwi     r4, r5, 0               /* Get Linux PTE */
 
                andi    r6, r4, _PAGE_PRESENT
-               beqi    r6, ex7
+               beqi    r6, ex10
 
                ori     r4, r4, _PAGE_ACCESSED
                swi     r4, r5, 0
@@ -805,9 +791,8 @@ ex_handler_done:
                 * Many of these bits are software only. Bits we don't set
                 * here we (properly should) assume have the appropriate value.
                 */
+               brid    finish_tlb_load
                andni   r4, r4, 0x0ce2          /* Make sure 20, 21 are zero */
-
-               bri     finish_tlb_load
        ex10:
                /* The bailout. Restore registers to pre-exception conditions
                 * and call the heavyweights to help us out.
@@ -837,9 +822,9 @@ ex_handler_done:
                andi    r5, r5, (MICROBLAZE_TLB_SIZE-1)
                ori     r6, r0, 1
                cmp     r31, r5, r6
-               blti    r31, sem
+               blti    r31, ex12
                addik   r5, r6, 1
-       sem:
+       ex12:
                /* MS: save back current TLB index */
                swi     r5, r0, TOPHYS(tlb_index)
 
@@ -859,7 +844,6 @@ ex_handler_done:
                nop
 
                /* Done...restore registers and get out of here. */
-       ex12:
                mts     rpid, r11
                nop
                bri 4
index df16c6287a8e54b1ca8e36a10c6f2fe2875d9ff2..7cf86498326cc4eafc0db81a8de13ff06bc654bc 100644 (file)
  * We avoid flushing the pinned 0, 1 and possibly 2 entries.
  */
 .globl _tlbia;
+.type  _tlbia, @function
 .align 4;
 _tlbia:
-       addik   r12, r0, 63 /* flush all entries (63 - 3) */
+       addik   r12, r0, MICROBLAZE_TLB_SIZE - 1 /* flush all entries (63 - 3) */
        /* isync */
 _tlbia_1:
        mts     rtlbx, r12
@@ -41,11 +42,13 @@ _tlbia_1:
        /* sync */
        rtsd    r15, 8
        nop
+       .size  _tlbia, . - _tlbia
 
 /*
  * Flush MMU TLB for a particular address (in r5)
  */
 .globl _tlbie;
+.type  _tlbie, @function
 .align 4;
 _tlbie:
        mts     rtlbsx, r5 /* look up the address in TLB */
@@ -59,17 +62,20 @@ _tlbie_1:
        rtsd    r15, 8
        nop
 
+       .size  _tlbie, . - _tlbie
+
 /*
  * Allocate TLB entry for early console
  */
 .globl early_console_reg_tlb_alloc;
+.type  early_console_reg_tlb_alloc, @function
 .align 4;
 early_console_reg_tlb_alloc:
        /*
         * Load a TLB entry for the UART, so that microblaze_progress() can use
         * the UARTs nice and early.  We use a 4k real==virtual mapping.
         */
-       ori     r4, r0, 63
+       ori     r4, r0, MICROBLAZE_TLB_SIZE - 1
        mts     rtlbx, r4 /* TLB slot 2 */
 
        or      r4,r5,r0
@@ -86,6 +92,8 @@ early_console_reg_tlb_alloc:
        rtsd    r15, 8
        nop
 
+       .size  early_console_reg_tlb_alloc, . - early_console_reg_tlb_alloc
+
 /*
  * Copy a whole page (4096 bytes).
  */
@@ -104,6 +112,7 @@ early_console_reg_tlb_alloc:
 #define DCACHE_LINE_BYTES (4 * 4)
 
 .globl copy_page;
+.type  copy_page, @function
 .align 4;
 copy_page:
        ori     r11, r0, (PAGE_SIZE/DCACHE_LINE_BYTES) - 1
@@ -118,3 +127,5 @@ _copy_page_loop:
        addik   r11, r11, -1
        rtsd    r15, 8
        nop
+
+       .size  copy_page, . - copy_page
index 5a45b1adfef1c91f25b191d968238c95854ee674..cbecf110dc30dbd584672b680dad3920448138fa 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/string.h>
 
index 1c6d684996d7eae768686ba88945e79148180c74..0dc755286d38e44b8ff209d05d4d7c2a1c9d1b9a 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index 812f1bf06c9e5cbfb2a88222974e2931d20f9a24..09bed44dfcd35a5f2300405f9e208982e7208798 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/bitops.h>
 #include <asm/system.h>
 #include <asm/pgalloc.h>
+#include <asm/uaccess.h> /* for USER_DS macros */
 #include <asm/cacheflush.h>
 
 void show_regs(struct pt_regs *regs)
@@ -74,7 +75,10 @@ __setup("hlt", hlt_setup);
 
 void default_idle(void)
 {
-       if (!hlt_counter) {
+       if (likely(hlt_counter)) {
+               while (!need_resched())
+                       cpu_relax();
+       } else {
                clear_thread_flag(TIF_POLLING_NRFLAG);
                smp_mb__after_clear_bit();
                local_irq_disable();
@@ -82,9 +86,7 @@ void default_idle(void)
                        cpu_sleep();
                local_irq_enable();
                set_thread_flag(TIF_POLLING_NRFLAG);
-       } else
-               while (!need_resched())
-                       cpu_relax();
+       }
 }
 
 void cpu_idle(void)
index f974ec7aa357e5b363c9c6a116ff9e0eee5ccee1..17c98dbcec888f698e2c038eee317ddef7e1f7da 100644 (file)
@@ -92,6 +92,12 @@ inline unsigned get_romfs_len(unsigned *addr)
 }
 #endif /* CONFIG_MTD_UCLINUX_EBSS */
 
+#if defined(CONFIG_EARLY_PRINTK) && defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
+#define eprintk early_printk
+#else
+#define eprintk printk
+#endif
+
 void __init machine_early_init(const char *cmdline, unsigned int ram,
                unsigned int fdt, unsigned int msr)
 {
@@ -139,32 +145,32 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
        setup_early_printk(NULL);
 #endif
 
-       early_printk("Ramdisk addr 0x%08x, ", ram);
+       eprintk("Ramdisk addr 0x%08x, ", ram);
        if (fdt)
-               early_printk("FDT at 0x%08x\n", fdt);
+               eprintk("FDT at 0x%08x\n", fdt);
        else
-               early_printk("Compiled-in FDT at 0x%08x\n",
+               eprintk("Compiled-in FDT at 0x%08x\n",
                                        (unsigned int)_fdt_start);
 
 #ifdef CONFIG_MTD_UCLINUX
-       early_printk("Found romfs @ 0x%08x (0x%08x)\n",
+       eprintk("Found romfs @ 0x%08x (0x%08x)\n",
                        romfs_base, romfs_size);
-       early_printk("#### klimit %p ####\n", old_klimit);
+       eprintk("#### klimit %p ####\n", old_klimit);
        BUG_ON(romfs_size < 0); /* What else can we do? */
 
-       early_printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
+       eprintk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
                        romfs_size, romfs_base, (unsigned)&_ebss);
 
-       early_printk("New klimit: 0x%08x\n", (unsigned)klimit);
+       eprintk("New klimit: 0x%08x\n", (unsigned)klimit);
 #endif
 
 #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
        if (msr)
-               early_printk("!!!Your kernel has setup MSR instruction but "
+               eprintk("!!!Your kernel has setup MSR instruction but "
                                "CPU don't have it %d\n", msr);
 #else
        if (!msr)
-               early_printk("!!!Your kernel not setup MSR instruction but "
+               eprintk("!!!Your kernel not setup MSR instruction but "
                                "CPU have it %d\n", msr);
 #endif
 
index 9f3c205fb75b71c47086f21f9e80863b6dcd14df..f4e00b7f12594877e86c780258e7d93d9bd35490 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/semaphore.h>
 #include <linux/uaccess.h>
 #include <linux/unistd.h>
+#include <linux/slab.h>
 
 #include <asm/syscalls.h>
 
index eaaaf805f31b6d32039376df4f0e9ffdec777b5d..5e4570ef515c5fd97937596814d7b8d9ee321d0c 100644 (file)
@@ -22,13 +22,11 @@ void trap_init(void)
        __enable_hw_exceptions();
 }
 
-static int kstack_depth_to_print = 24;
+static unsigned long kstack_depth_to_print = 24;
 
 static int __init kstack_setup(char *s)
 {
-       kstack_depth_to_print = strict_strtoul(s, 0, NULL);
-
-       return 1;
+       return !strict_strtoul(s, 0, &kstack_depth_to_print);
 }
 __setup("kstack=", kstack_setup);
 
index b579db068c06fd3346a1458879145ef8f50063b3..4dfe47d3cd916e51ad21e25eb674afea71ff8551 100644 (file)
@@ -10,5 +10,4 @@ else
 lib-y += memcpy.o memmove.o
 endif
 
-lib-$(CONFIG_NO_MMU) += uaccess.o
-lib-$(CONFIG_MMU) += uaccess_old.o
+lib-y += uaccess_old.o
index 02e3ab4eddf3a2a29c742cf6d5b44ca9fe7bc1e0..fdc48bb065d89fe3b2443ef054d1a6ece3744b54 100644 (file)
@@ -30,8 +30,9 @@
  */
 
 #include <linux/linkage.h>
-
+       .text
        .globl  memcpy
+       .type  memcpy, @function
        .ent    memcpy
 
 memcpy:
@@ -345,9 +346,11 @@ a_done:
        rtsd    r15, 8
        nop
 
+.size  memcpy, . - memcpy
 .end memcpy
 /*----------------------------------------------------------------------------*/
        .globl  memmove
+       .type  memmove, @function
        .ent    memmove
 
 memmove:
@@ -659,4 +662,5 @@ d_done:
        rtsd    r15, 8
        nop
 
+.size  memmove, . - memmove
 .end memmove
index cc2108b6b2602180dc11fbb559d4b090359ef35c..014bac92bdff74553595280c0be125a7b17cfcfb 100644 (file)
@@ -53,7 +53,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
        const uint32_t *i_src;
        uint32_t *i_dst;
 
-       if (c >= 4) {
+       if (likely(c >= 4)) {
                unsigned  value, buf_hold;
 
                /* Align the dstination to a word boundry. */
index 4df851d41a2966f992c09ec8f571fe4fd2f0eee2..ecfb663e1fc159dc33a922b894910f4912d6ed09 100644 (file)
 #ifdef __HAVE_ARCH_MEMSET
 void *memset(void *v_src, int c, __kernel_size_t n)
 {
-
        char *src = v_src;
 #ifdef CONFIG_OPT_LIB_FUNCTION
        uint32_t *i_src;
-       uint32_t w32;
+       uint32_t w32 = 0;
 #endif
        /* Truncate c to 8 bits */
        c = (c & 0xFF);
 
 #ifdef CONFIG_OPT_LIB_FUNCTION
-       /* Make a repeating word out of it */
-       w32 = c;
-       w32 |= w32 << 8;
-       w32 |= w32 << 16;
+       if (unlikely(c)) {
+               /* Make a repeating word out of it */
+               w32 = c;
+               w32 |= w32 << 8;
+               w32 |= w32 << 16;
+       }
 
-       if (n >= 4) {
+       if (likely(n >= 4)) {
                /* Align the destination to a word boundary */
                /* This is done in an endian independant manner */
                switch ((unsigned) src & 3) {
diff --git a/arch/microblaze/lib/uaccess.c b/arch/microblaze/lib/uaccess.c
deleted file mode 100644 (file)
index a853fe0..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Atmark Techno, Inc.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-#include <asm/bug.h>
-
-long strnlen_user(const char __user *src, long count)
-{
-       return strlen(src) + 1;
-}
-
-#define __do_strncpy_from_user(dst, src, count, res)                   \
-       do {                                                            \
-               char *tmp;                                              \
-               strncpy(dst, src, count);                               \
-               for (tmp = dst; *tmp && count > 0; tmp++, count--)      \
-                       ;                                               \
-               res = (tmp - dst);                                      \
-       } while (0)
-
-long __strncpy_from_user(char *dst, const char __user *src, long count)
-{
-       long res;
-       __do_strncpy_from_user(dst, src, count, res);
-       return res;
-}
-
-long strncpy_from_user(char *dst, const char __user *src, long count)
-{
-       long res = -EFAULT;
-       if (access_ok(VERIFY_READ, src, 1))
-               __do_strncpy_from_user(dst, src, count, res);
-       return res;
-}
-
-unsigned long __copy_tofrom_user(void __user *to,
-               const void __user *from, unsigned long size)
-{
-       memcpy(to, from, size);
-       return 0;
-}
index 67f991c14b8a5f24edcd5aa660555368cc3259e6..5810cec54a7a36e356d5c48b4ad29923ee0829e4 100644 (file)
@@ -22,6 +22,7 @@
 
        .text
 .globl __strncpy_user;
+.type  __strncpy_user, @function
 .align 4;
 __strncpy_user:
 
@@ -50,7 +51,7 @@ __strncpy_user:
 3:
        rtsd    r15,8
        nop
-
+       .size   __strncpy_user, . - __strncpy_user
 
        .section        .fixup, "ax"
        .align  2
@@ -72,6 +73,7 @@ __strncpy_user:
 
        .text
 .globl __strnlen_user;
+.type  __strnlen_user, @function
 .align 4;
 __strnlen_user:
        addik   r3,r6,0
@@ -90,7 +92,7 @@ __strnlen_user:
 3:
        rtsd    r15,8
        nop
-
+       .size   __strnlen_user, . - __strnlen_user
 
        .section        .fixup,"ax"
 4:
@@ -108,6 +110,7 @@ __strnlen_user:
  */
        .text
 .globl __copy_tofrom_user;
+.type  __copy_tofrom_user, @function
 .align 4;
 __copy_tofrom_user:
        /*
@@ -116,20 +119,34 @@ __copy_tofrom_user:
         * r7, r3 - count
         * r4 - tempval
         */
-       addik   r3,r7,0
-       beqi    r3,3f
-1:
-       lbu     r4,r6,r0
-       addik   r6,r6,1
-2:
-       sb      r4,r5,r0
-       addik   r3,r3,-1
-       bneid   r3,1b
-       addik   r5,r5,1         /* delay slot */
+       beqid   r7, 3f /* zero size is not likely */
+       andi    r3, r7, 0x3 /* filter add count */
+       bneid   r3, 4f /* if is odd value then byte copying */
+       or      r3, r5, r6 /* find if is any to/from unaligned */
+       andi    r3, r3, 0x3 /* mask unaligned */
+       bneid   r3, 1f /* it is unaligned -> then jump */
+       or      r3, r0, r0
+
+/* at least one 4 byte copy */
+5:     lw      r4, r6, r3
+6:     sw      r4, r5, r3
+       addik   r7, r7, -4
+       bneid   r7, 5b
+       addik   r3, r3, 4
+       addik   r3, r7, 0
+       rtsd    r15, 8
+       nop
+4:     or      r3, r0, r0
+1:     lbu     r4,r6,r3
+2:     sb      r4,r5,r3
+       addik   r7,r7,-1
+       bneid   r7,1b
+       addik   r3,r3,1         /* delay slot */
 3:
+       addik   r3,r7,0
        rtsd    r15,8
        nop
-
+       .size   __copy_tofrom_user, . - __copy_tofrom_user
 
        .section        __ex_table,"a"
-       .word   1b,3b,2b,3b
+       .word   1b,3b,2b,3b,5b,3b,6b,3b
index a9b443e3fb9899e2d7fc5b722df361b0c37acbe7..f956e24fe49ccc11927d4648a62952b1f3036e20 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/highmem.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/gfp.h>
 
 #include <asm/pgalloc.h>
 #include <linux/io.h>
index d9d249a66ff2eda43688483cb1cab0aba3434de9..7af87f4b2c2c73a86ff88d023e5ddfee342d6240 100644 (file)
@@ -106,7 +106,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
        regs->esr = error_code;
 
        /* On a kernel SLB miss we can only check for a valid exception entry */
-       if (kernel_mode(regs) && (address >= TASK_SIZE)) {
+       if (unlikely(kernel_mode(regs) && (address >= TASK_SIZE))) {
                printk(KERN_WARNING "kernel task_size exceed");
                _exception(SIGSEGV, regs, code, address);
        }
@@ -122,7 +122,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
        }
 #endif /* CONFIG_KGDB */
 
-       if (in_atomic() || !mm) {
+       if (unlikely(in_atomic() || !mm)) {
                if (kernel_mode(regs))
                        goto bad_area_nosemaphore;
 
@@ -150,7 +150,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
         * source.  If this is invalid we can skip the address space check,
         * thus avoiding the deadlock.
         */
-       if (!down_read_trylock(&mm->mmap_sem)) {
+       if (unlikely(!down_read_trylock(&mm->mmap_sem))) {
                if (kernel_mode(regs) && !search_exception_tables(regs->pc))
                        goto bad_area_nosemaphore;
 
@@ -158,16 +158,16 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
        }
 
        vma = find_vma(mm, address);
-       if (!vma)
+       if (unlikely(!vma))
                goto bad_area;
 
        if (vma->vm_start <= address)
                goto good_area;
 
-       if (!(vma->vm_flags & VM_GROWSDOWN))
+       if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
                goto bad_area;
 
-       if (!is_write)
+       if (unlikely(!is_write))
                goto bad_area;
 
        /*
@@ -179,7 +179,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
         * before setting the user r1.  Thus we allow the stack to
         * expand to 1MB without further checks.
         */
-       if (address + 0x100000 < vma->vm_end) {
+       if (unlikely(address + 0x100000 < vma->vm_end)) {
 
                /* get user regs even if this fault is in kernel mode */
                struct pt_regs *uregs = current->thread.regs;
@@ -209,15 +209,15 @@ good_area:
        code = SEGV_ACCERR;
 
        /* a write */
-       if (is_write) {
-               if (!(vma->vm_flags & VM_WRITE))
+       if (unlikely(is_write)) {
+               if (unlikely(!(vma->vm_flags & VM_WRITE)))
                        goto bad_area;
        /* a read */
        } else {
                /* protection fault */
-               if (error_code & 0x08000000)
+               if (unlikely(error_code & 0x08000000))
                        goto bad_area;
-               if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
+               if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC))))
                        goto bad_area;
        }
 
@@ -235,7 +235,7 @@ survive:
                        goto do_sigbus;
                BUG();
        }
-       if (fault & VM_FAULT_MAJOR)
+       if (unlikely(fault & VM_FAULT_MAJOR))
                current->maj_flt++;
        else
                current->min_flt++;
index 1608e2e1a44abcb553a82b73b18d6bacef94556f..f42c2dde8b1cbd1752e81cea5e671b9070de0e1c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/initrd.h>
 #include <linux/pagemap.h>
 #include <linux/pfn.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 
 #include <asm/page.h>
@@ -165,7 +166,6 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
        for (addr = begin; addr < end; addr += PAGE_SIZE) {
                ClearPageReserved(virt_to_page(addr));
                init_page_count(virt_to_page(addr));
-               memset((void *)addr, 0xcc, PAGE_SIZE);
                free_page(addr);
                totalram_pages++;
        }
@@ -208,14 +208,6 @@ void __init mem_init(void)
 }
 
 #ifndef CONFIG_MMU
-/* Check against bounds of physical memory */
-int ___range_ok(unsigned long addr, unsigned long size)
-{
-       return ((addr < memory_start) ||
-               ((addr + size) > memory_end));
-}
-EXPORT_SYMBOL(___range_ok);
-
 int page_is_ram(unsigned long pfn)
 {
        return __range_ok(pfn, 0);
index 63a6fd07c48fc611ea79b7c0895750b1f7dcdbce..d31312cde6eac9adcb431825c44134507cd54cbb 100644 (file)
@@ -154,7 +154,7 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
                err = 0;
                set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT,
                                __pgprot(flags)));
-               if (mem_init_done)
+               if (unlikely(mem_init_done))
                        flush_HPTE(0, va, pmd_val(*pd));
                        /* flush_HPTE(0, va, pg); */
        }
index 0be34350d7335e1aea4ead8b142ea35017ea43b9..740bb32ec57ea30d9d266e4131dbe2037b2db0b4 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/syscalls.h>
 #include <linux/irq.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
index 7e0c94f501cce8558c6085f45e928f594be77242..3c3d808d7ce08529def87f83738e52666893f559 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/irq.h>
 #include <linux/list.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
index 0d64d0f464185c0c9c383fcad2e1d30416afc854..9ce9f64cb76fa8fce272100f00373694e8f6d4f7 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/mm.h>
 #include <linux/bootmem.h>
 #include <linux/spinlock.h>
+#include <linux/gfp.h>
 #include <asm/mipsregs.h>
 #include <asm/jazz.h>
 #include <asm/io.h>
index 981f86c26168ca9b838fecc8e627663a04e82017..c6345f579a8a4ea13d00251c4d47272b4afffa1d 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/random.h>
 #include <linux/sched.h>
index a39d0597a37583df6e24d0e09f6ce63f7a96617a..c2dab140dc98fb1588259063699c7ba09b6f8ed7 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/time.h>
 #include <linux/times.h>
 #include <linux/poll.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/filter.h>
 #include <linux/shm.h>
@@ -34,6 +33,7 @@
 #include <linux/compat.h>
 #include <linux/vfs.h>
 #include <linux/ipc.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <net/scm.h>
index f3d73e1831c1567ccb674429eb83492feb2942e1..463b71b90a00fc7b99e5655fe7254822e2483116 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/mman.h>
 #include <linux/personality.h>
 #include <linux/sys.h>
index dcaed1bbbfe5c7e099768a17c9aad126c8c80429..26f9b9ab19cc66b020486be6cef3e21cfe347126 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
-#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
 #include <linux/elf.h>
index 23499b5bd9c3d42f79352d5dd75243a8b49f96dd..25e825aea3270c29c08f1d0cfefd361af5ff3596 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
 #include <linux/ftrace.h>
+#include <linux/slab.h>
 
 #include <asm/cpu.h>
 #include <asm/processor.h>
index e96b1c30c7aac6c708d4b55aa5a09f2fb7af31f9..9587abc67f35cfec1851c609f40e08e460436356 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/string.h>
 #include <linux/syscalls.h>
 #include <linux/file.h>
-#include <linux/slab.h>
 #include <linux/utsname.h>
 #include <linux/unistd.h>
 #include <linux/sem.h>
@@ -29,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/ipc.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 #include <asm/asm.h>
 #include <asm/branch.h>
index 46067ad542dce8640cbfceb5a46beaf8c210b038..5c779be6f082b8d7ce9965047360e7abef8395d6 100644 (file)
@@ -17,7 +17,6 @@
  */
 #include <linux/init.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <asm/mips-boards/simint.h>
index 9367e33fbd1822d92f55302a38fb872982e2fb7d..9547bc0cf188bc2cff41233e67b53ce5bdd0d50c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/scatterlist.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 
 #include <asm/cache.h>
 #include <asm/io.h>
index cd0660c51f28357f4ac1b2a9f5501fe85ad16189..a7fee0dfb7a9daaeb67616804f00cac7365d778f 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
-#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/sysctl.h>
 #include <asm/mman.h>
index 12539af38a990bff5e271a2ddfadce886fd867d5..2efcbd24c82fcfa8d2741243101eb5df116e2d85 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/proc_fs.h>
 #include <linux/pfn.h>
 #include <linux/hardirq.h>
+#include <linux/gfp.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/bootinfo.h>
index 0c43248347bd82e8ad0b7fb97414e401fdbe2bba..cacfd31e8ec9d1121c86e81feb35fac4344a9a3b 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/addrspace.h>
 #include <asm/byteorder.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <asm/cacheflush.h>
 #include <asm/io.h>
index 2cb5ae79020326ecffdc4aa455f74d5a54afa506..15949b0be811f9718af9e2896d4bd9e947c84897 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/irq.h>
 #include <linux/sched.h>
 #include <linux/smp.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel_stat.h>
index a9bc9bacad2b6667ae10e4ec660cc7ec72db1ef1..e0ea96d29fde9fd6d64dca041dda2b8143823306 100644 (file)
@@ -22,7 +22,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include <linux/slab.h>
 #include <linux/reboot.h>
 #include <pnx833x.h>
 
index 7aca7d5375e5cb4917eb23c705c18868cadb2f2f..cfed5051dc6d6323e86ad8e90144e1006bb52b57 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/random.h>
index af094cd1d85bf030341bb6742079fbac5a630d91..3bba5ec828e886b355b3acc4a43955cf2b837916 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/proc_fs.h>
 #include <linux/irq.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/random.h>
index 7b2cbc5b2c7c1b810f62c32f3eb637de22cc6f3d..76bc3ec634ee000636ad8ffaf2937a718c2d7198 100644 (file)
@@ -20,7 +20,6 @@
  * Reset the PNX8550 board.
  *
  */
-#include <linux/slab.h>
 #include <asm/reboot.h>
 #include <glb.h>
 
index 46c636c27e066be2798fc871ccc39be1ac437b4c..749c1922d4205f0da1ea468fc89edef76c49e462 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <asm/io.h>
 
index db98d87a09225679a076e5b5df405e351db1563e..db00deb59b9c678732983efe955bfe1d2c80a5cc 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 
 #include <asm/addrspace.h>
 #include <asm/bootinfo.h>
index fd22597edb64bcf2338e7ae693eed99f855c723f..63be40e470db9baae4269f075feabec031fbaed9 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <asm/pci.h>
 #include <asm/io.h>
 
index 5f673eba142cf6a600e5c4159d84f72f0f6cf6b8..51021cfd04bc1de986912be4346da35cba7df1dd 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/ioport.h>
 #include <linux/irq.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/bitops.h>
 #include <asm/bootinfo.h>
index 217424231eb6f8ebcb1bcdc25735b848f76a25e6..8ee77887306a24986a54b27af1b3dc009011273a 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mm.h>
 #include <linux/platform_device.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <asm/page.h>
 #include <linux/swap.h>
 #include <linux/highmem.h>
index 325fab9685d1c57ce73d806e194dbc0e167f4946..529c44a52d6460ab8d6085d36d8314f2568036d3 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/kernel.h>
index f07882029a90d3d155c17b462812c2936229458c..ea6cec3c1e0dbeecde2d7c3ceab11d26b216f18a 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/delay.h>
 
index c1c8e40d65d6a5f5353768d0729f067097d0dad3..6a123ea72de54a42bfdc3e2d6b5d705731061e94 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/random.h>
 #include <linux/kernel.h>
index d8b65204d28868561d9cff524bc8853fad824f0a..eb40824b172ac1792c541036a5f6c5f8b8790ece 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/irq.h>
 #include <linux/bitops.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/random.h>
 #include <linux/sched.h>
index 06e25d949768bff9f35679951bca010830682484..7a8b0a8b643aec65696d441d30b731cbc04143b1 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/smp.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/kernel_stat.h>
 
 #include <asm/errno.h>
index ed2453eab5cbab8b2f0c8d31da28be35e465570f..d4ed7a9156f59d847985909de7fe64f788664921 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
 #include <linux/errno.h>
index ab44a2f59ee497a973da4c74a2405b6f7f5fcf3c..62371f7725535a7bd8e0a64626244dbb7302d128 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/spinlock.h>
 #include <linux/smp.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/kernel_stat.h>
 
 #include <asm/errno.h>
index 707cfa9c547d98ac63fa619a0f831fbc939dba98..9a0be810cafa37ef731ca746f3d5cb6d456c36ab 100644 (file)
@@ -20,6 +20,7 @@
 #include <asm/txx9/pci.h>
 #ifdef CONFIG_TOSHIBA_FPCIB0
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/i8259.h>
 #include <asm/txx9/smsc_fdc37m81x.h>
 #endif
index 95184a0a1ae6ced2829ae82edfbaabf60efc147b..adc69291f9e2424759cbfaf715ba7c1118de1b04 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/leds.h>
 #include <linux/sysdev.h>
+#include <linux/slab.h>
 #include <asm/bootinfo.h>
 #include <asm/time.h>
 #include <asm/reboot.h>
index 75c347238f47741792eee5846a3eb2167b1be37a..103abc13d6234764469f33545f6c1710ae74b55e 100644 (file)
@@ -10,6 +10,7 @@
  * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
  */
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/eeprom.h>
index b0c241ecf603c3549a98b385176ad701eb7532c6..7dc0fafbec80b896c615ef5bacf3a41c63c26ac3 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/leds.h>
 #include <linux/interrupt.h>
index ec8a21df1142010a2c3bb4e08f5ea6e4615f12dc..82b817c7f7b63b2faca0af0e7c2ad3c671ee2b22 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
@@ -26,6 +25,7 @@
 #include <linux/percpu.h>
 #include <linux/err.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/system.h>
index 3f24c298a3af1cb583f66a809598cfbbbdde6faa..d464affcba0e31a0d201ac07f51fc7e4bd55cbf6 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/ioport.h>
index ee82d624b3c63e8f034112b88729c41fd2a4e161..4e34880bea03b889dcbcaea5865d576045bf1707 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 
 static unsigned long pci_sram_allocated = 0xbc000000;
index dd27a9a35152ff9ab853cd381c035890cb77a176..6e6bc0e51521811895e4c3e11e73fdb2fdc49118 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/types.h>
 #include <linux/ptrace.h>
 #include <linux/mman.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
@@ -27,6 +26,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
index baffc581e031d6cb3389f4e15d2268fbd38d945d..9c1624c9e4e9fa05f33d621877c931dbb9ae1abb 100644 (file)
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/smp.h>
 #include <linux/highmem.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/spinlock.h>
 #include <linux/quicklist.h>
index 58cfb44f0acf626355067b4275175cb775708635..91212ea71e697257350e553c81bffb24b5e2f832 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <asm/io.h>
index 54075360a8fdb5cd43c0abee9669ae4ac9bce7fc..6935123178ebec4a9cd9d3dd6628376f4b081b6b 100644 (file)
@@ -26,8 +26,8 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/file.h>
-#include <linux/slab.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 #include <asm/errno.h>
 #include <asm/uaccess.h>
 
index 212074653df7fc5a109da9222137a13226cc7bff..159a2b81e90c630db82eb9834c2096df7eb66896 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/bug.h>
+#include <linux/slab.h>
 
 #include <asm/unwind.h>
 
index c07f618ff7da9264fc9aa242cfaf1515b72d8af5..a029f74a3c5c54ac7a6c0bd8458d66bc3c59fe6b 100644 (file)
 */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/scatterlist.h>
index 38372e7cbb88f1d53372061e5e6e23684bcbc4a9..9efd97405317726369599d9f11e797c5a48d687c 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <asm/io.h>
index 1f3aa8db02030a1509253b6d0d51d4910f522761..76332dadc6e93e64e6b0557dc0e5c0bd2e0b0986 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/personality.h>
 #include <linux/ptrace.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/kallsyms.h>
index fb59852006defd58fbf9b035c8b3ec49455c5cfe..e14132430762414166a729ae57e647ec5b9f1316 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include <linux/compat.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/unistd.h>
 #include <linux/init.h>
index 3f2fce8ce6b628c5af3121cecd93c231c924d781..69d63d354ef05fac8f86a1ff69e98ddefdd93125 100644 (file)
@@ -18,7 +18,6 @@
 */
 #include <linux/types.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 
 #include <linux/kernel.h>
 #include <linux/module.h>
index 13b6e3e59b994762a7efb47483c4b144ca0c5feb..f4f4d700833affc00d9953871b441eae12227831 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/pci.h>         /* for hppa_dma_ops and pcxl_dma_ops */
index 8a54eb8e37683d8ec1de947ccb51f3abf7672060..2e19500921f9fbdc33f40321ae34f648171faba0 100644 (file)
@@ -313,19 +313,6 @@ config 8XX_MINIMAL_FPEMU
 
          It is recommended that you build a soft-float userspace instead.
 
-config IOMMU_VMERGE
-       bool "Enable IOMMU virtual merging"
-       depends on PPC64
-       default y
-       help
-         Cause IO segments sent to a device for DMA to be merged virtually
-         by the IOMMU when they happen to have been allocated contiguously.
-         This doesn't add pressure to the IOMMU allocator. However, some
-         drivers don't support getting large merged segments coming back
-         from *_map_sg().
-
-         Most drivers don't have this problem; it is safe to say Y here.
-
 config IOMMU_HELPER
        def_bool PPC64
 
index c1b475a941eb9d08a272f6b378cfdfa7d14cdf9c..a9b91ed3d4b9e17ae8494e17ba498d19aa43a89c 100644 (file)
@@ -28,6 +28,7 @@
 #define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh)
 #define PPC_STLCX      stringify_in_c(stdcx.)
 #define PPC_CNTLZL     stringify_in_c(cntlzd)
+#define PPC_LR_STKOFF  16
 
 /* Move to CR, single-entry optimized version. Only available
  * on POWER4 and later.
@@ -51,6 +52,7 @@
 #define PPC_STLCX      stringify_in_c(stwcx.)
 #define PPC_CNTLZL     stringify_in_c(cntlzw)
 #define PPC_MTOCRF     stringify_in_c(mtcrf)
+#define PPC_LR_STKOFF  4
 
 #endif
 
index aea71479759030651b24361b7eb965fefa65772c..d553bbeb726c1c0f1c6bda61455bfe3006400f25 100644 (file)
@@ -25,7 +25,7 @@
 #define PPC_INST_LDARX                 0x7c0000a8
 #define PPC_INST_LSWI                  0x7c0004aa
 #define PPC_INST_LSWX                  0x7c00042a
-#define PPC_INST_LWARX                 0x7c000029
+#define PPC_INST_LWARX                 0x7c000028
 #define PPC_INST_LWSYNC                        0x7c2004ac
 #define PPC_INST_LXVD2X                        0x7c000698
 #define PPC_INST_MCRXR                 0x7c000400
@@ -62,8 +62,8 @@
 #define __PPC_T_TLB(t) (((t) & 0x3) << 21)
 #define __PPC_WC(w)    (((w) & 0x3) << 21)
 /*
- * Only use the larx hint bit on 64bit CPUs. Once we verify it doesn't have
- * any side effects on all 32bit processors, we can do this all the time.
+ * Only use the larx hint bit on 64bit CPUs. e500v1/v2 based CPUs will treat a
+ * larx with EH set as an illegal instruction.
  */
 #ifdef CONFIG_PPC64
 #define __PPC_EH(eh)   (((eh) & 0x1) << 0)
index efa7f0b879f3156345bda9d6ccfa258b1ecb382f..23913e902fc3c50c4307514c159c53db9e7d004d 100644 (file)
@@ -30,7 +30,7 @@ static inline void syscall_rollback(struct task_struct *task,
 static inline long syscall_get_error(struct task_struct *task,
                                     struct pt_regs *regs)
 {
-       return (regs->ccr & 0x1000) ? -regs->gpr[3] : 0;
+       return (regs->ccr & 0x10000000) ? -regs->gpr[3] : 0;
 }
 
 static inline long syscall_get_return_value(struct task_struct *task,
@@ -44,10 +44,10 @@ static inline void syscall_set_return_value(struct task_struct *task,
                                            int error, long val)
 {
        if (error) {
-               regs->ccr |= 0x1000L;
+               regs->ccr |= 0x10000000L;
                regs->gpr[3] = -error;
        } else {
-               regs->ccr &= ~0x1000L;
+               regs->ccr &= ~0x10000000L;
                regs->gpr[3] = val;
        }
 }
index 01fe9ce28379a5bc6bb6738775f5a14c41f43884..a3c684b4c8626a1092875c9bd361245e21411f30 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/notifier.h>
 #include <linux/of.h>
 #include <linux/percpu.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 
 #include "cacheinfo.h"
index 6215062caf8cfed39e66cb162339204340c1aad8..6c1df5757cd6e1a260a96557f5d9f7ea1f807f94 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/dma-debug.h>
+#include <linux/gfp.h>
 #include <linux/lmb.h>
 #include <asm/bug.h>
 #include <asm/abs_addr.h>
index 25793bb0e7828ad5c60ff550bbb19ec832e8a30d..725526547994d76ce6386d23d8398946357c6291 100644 (file)
@@ -746,9 +746,6 @@ finish_tlb_load:
        rlwimi  r12, r11, 32-19, 27, 31 /* extract WIMGE from pte */
 #else
        rlwimi  r12, r11, 26, 27, 31    /* extract WIMGE from pte */
-#endif
-#ifdef CONFIG_SMP
-       ori     r12, r12, MAS2_M
 #endif
        mtspr   SPRN_MAS2, r12
 
@@ -887,13 +884,17 @@ KernelSPE:
        lwz     r3,_MSR(r1)
        oris    r3,r3,MSR_SPE@h
        stw     r3,_MSR(r1)     /* enable use of SPE after return */
+#ifdef CONFIG_PRINTK
        lis     r3,87f@h
        ori     r3,r3,87f@l
        mr      r4,r2           /* current */
        lwz     r5,_NIP(r1)
        bl      printk
+#endif
        b       ret_from_except
+#ifdef CONFIG_PRINTK
 87:    .string "SPE used in kernel  (task=%p, pc=%x)  \n"
+#endif
        .align  4,0
 
 #endif /* CONFIG_SPE */
index a4c8b38b0ba1f7bed97d9788e80a78f9447a3cc2..71cf280da1847f3255a71d0bb9b9cf439b5852f8 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 #include <linux/of_platform.h>
 #include <asm/ibmebus.h>
 #include <asm/abs_addr.h>
index 5547ae6e6b0be605e293ae42c49dab911782f568..ec94f906ea43a7dd6729a518d852d8e9879480ed 100644 (file)
 
 #define DBG(...)
 
-#ifdef CONFIG_IOMMU_VMERGE
-static int novmerge = 0;
-#else
-static int novmerge = 1;
-#endif
-
+static int novmerge;
 static int protect4gb = 1;
 
 static void __iommu_free(struct iommu_table *, dma_addr_t, unsigned int);
index 3fd1af90211236dfad7b488206bdf0b7214deaf3..b36f074524adc48e81f72a9853d90d0287f7354e 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/preempt.h>
 #include <linux/module.h>
 #include <linux/kdebug.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 #include <asm/sstep.h>
 #include <asm/uaccess.h>
index d09d1c615150bcd61b79bae01b0168f5d788d68c..c2c70e1b32cd25eacb691497b6a572c645efe16f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/iseries/hv_lp_config.h>
 #include <asm/lppaca.h>
index 2d29752cbe169ea9398fbd1381cd9eff64ec28c8..22e507c8a5566d1f4dfcfe9db67482e3c0e83e35 100644 (file)
@@ -127,3 +127,29 @@ _GLOBAL(__setup_cpu_power7)
 _GLOBAL(__restore_cpu_power7)
        /* place holder */
        blr
+
+/*
+ * Get a minimal set of registers for our caller's nth caller.
+ * r3 = regs pointer, r5 = n.
+ *
+ * We only get R1 (stack pointer), NIP (next instruction pointer)
+ * and LR (link register).  These are all we can get in the
+ * general case without doing complicated stack unwinding, but
+ * fortunately they are enough to do a stack backtrace, which
+ * is all we need them for.
+ */
+_GLOBAL(perf_arch_fetch_caller_regs)
+       mr      r6,r1
+       cmpwi   r5,0
+       mflr    r4
+       ble     2f
+       mtctr   r5
+1:     PPC_LL  r6,0(r6)
+       bdnz    1b
+       PPC_LL  r4,PPC_LR_STKOFF(r6)
+2:     PPC_LL  r7,0(r6)
+       PPC_LL  r7,PPC_LR_STKOFF(r7)
+       PPC_STL r6,GPR1-STACK_FRAME_OVERHEAD(r3)
+       PPC_STL r4,_NIP-STACK_FRAME_OVERHEAD(r3)
+       PPC_STL r7,_LINK-STACK_FRAME_OVERHEAD(r3)
+       blr
index 666d08db319e313f87c0d1c975a267461df51ca2..6c1dfc3ff8bc16903d976e73a242c6268eadb3d3 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index f3c42ce516e7ed7d2261c6ec22d35c02c099045e..0c0567e58409ae006ae4f077d4a54e2a29fb81d4 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/syscalls.h>
 #include <linux/irq.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
index c13668cf36d940473519e9dc3723e9fc0bd37710..e7db5b48004ab43e30de96e2ac79d93a11b5fd6b 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/irq.h>
 #include <linux/list.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
index d5e36e5dc7c21368cb088c21013c961d9f232328..d56b35ee7f74f04af5290aa10937f2e323e1cc6d 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pci.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
index 1ed3b8d7981e4c4968c3ce6530b978883e8e030d..c8ae3714e79b2b3466600d982eb98d451f60e0c2 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
-#include <linux/slab.h>
 #include <linux/kernel.h>
 
 #include <asm/machdep.h>
index fd0d29493fd629a41ea5623dd77beeef1ef86ff1..74367841615a5ae3a31a2c2c9091916d79a0534c 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/completion.h>
 #include <linux/cpumask.h>
 #include <linux/lmb.h>
+#include <linux/slab.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>
index a85117d5c9a4c3576ac60d0b774df2c43ca4f9fc..bfc2abafac44ab2f8d510384e4eb9a98a9b8cb17 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <asm/delay.h>
 #include <asm/uaccess.h>
index 2e4832ab210802015ba04fcf31dab5c7dc8cd931..4190eae7850a22006e351957064132629b1c5e15 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/cpu.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
index b152de3e64d45a3646356b438ae9e7fedd088e4f..8f58986c2ad9a7c56117f24bee6fd089333b80b6 100644 (file)
@@ -39,7 +39,6 @@
 #include <asm/serial.h>
 #include <asm/udbg.h>
 #include <asm/mmu_context.h>
-#include <asm/swiotlb.h>
 
 #include "setup.h"
 
@@ -343,11 +342,6 @@ void __init setup_arch(char **cmdline_p)
                ppc_md.setup_arch();
        if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
 
-#ifdef CONFIG_SWIOTLB
-       if (ppc_swiotlb_enable)
-               swiotlb_init(1);
-#endif
-
        paging_init();
 
        /* Initialize the MMU context management stuff */
index 63547394048c39dcbdf151f5b98468c54d91bc5c..914389158a9bf65c407ee4436051d513fdaea002 100644 (file)
@@ -61,7 +61,6 @@
 #include <asm/xmon.h>
 #include <asm/udbg.h>
 #include <asm/kexec.h>
-#include <asm/swiotlb.h>
 #include <asm/mmu_context.h>
 
 #include "setup.h"
@@ -541,11 +540,6 @@ void __init setup_arch(char **cmdline_p)
        if (ppc_md.setup_arch)
                ppc_md.setup_arch();
 
-#ifdef CONFIG_SWIOTLB
-       if (ppc_swiotlb_enable)
-               swiotlb_init(1);
-#endif
-
        paging_init();
 
        /* Initialize the MMU context management stuff */
index a5e54526403df182f074ee3bd90c715d6f54b444..03e45c4a9ef1892c9ca904ec393e1d7d66b78a27 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/smp.h>
 #include <linux/unistd.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/smp.h>
 #include <asm/time.h>
index 23c8c5e7dc4d0be08d0e153fb597ebc3b7535bc2..af0e8290b4fc4f90faf3f59136683c10f3c47971 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
 
index c5a4732bcc48d934b20b3f725bd642c36c35cc68..19471a1cef1a23766107c0c60e1d0048e2efe0d7 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/ptrace.h>
 #include <linux/elf.h>
 #include <linux/ipc.h>
+#include <linux/slab.h>
 
 #include <asm/ptrace.h>
 #include <asm/types.h>
index 696626a2e83536f90364dc1c5a0f3136ab8cf8f0..29d128eb6c4353745e05e50534317b08c24ebe68 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
index 77f64218abf3fd116031a3fd9b7fed71e0604e03..82237176a2a3db8c2eadc29db867b5ed0415398f 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/types.h>
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/mm.h>
index f4d1b55aa70bd7b7cf9419285a454b4ce829a852..689a57c2ac8009f3d62a51cb9d94dc90a333d4e3 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 
 #include <asm/reg.h>
index 9a271f0929c727c100fb0cda64dff969f020f49a..25da07fd9f7763b74ef262f30c4d89390e12276b 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/kvm_ppc.h>
 #include <asm/kvm_book3s.h>
 #include <asm/mmu_context.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/vmalloc.h>
 
index 4d686cc6b260a797bbc7dffaa1467b574901714f..2a3a1953d4bd76a66ef49feb2882609b2847118e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/kvm_host.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
index efa1198940ab6b550a9f2e9ccf99d88692e43e61..669a5c5fc7d725db4f9d8ae6bddc47bce21eb475 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 
 #include <asm/reg.h>
index 0d772e6b6318cf30f081b5ec76c9bfe035ca5250..21011e12caeb9e159e258785b0f8709fe52bed2c 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/kvm.h>
 #include <linux/kvm_host.h>
index 51aedd7f16bcb14d5d2f073da2fc55a53ec18575..297fcd2ff7d01a0d9dddf473b1cc4e4415fccf4b 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/vmalloc.h>
 #include <linux/hrtimer.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <asm/cputable.h>
 #include <asm/uaccess.h>
 #include <asm/kvm_ppc.h>
index 292115d98ea9663e4038efe9826262e7c97003e1..deac4d30daf4dfcda8bf3bafcaba3751aa393429 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/device.h>      /* devres_*(), devm_ioremap_release() */
+#include <linux/gfp.h>
 #include <linux/io.h>          /* ioremap_flags() */
 #include <linux/module.h>      /* EXPORT_SYMBOL() */
 
index 36692f5c9a7637348bed0bc6f9318498035af14b..757c0bed9a91e5c76e40dbd2a50346f0bc397b10 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
index 123f7070238a3624287829f7f485d66c8f28a207..9bb249c3046e3eb6aae16bdfc4a4dd3972f363f8 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/mm.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/hugetlb.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
index b1dbd9ee87ccb477f5d18d846994dcc566317132..767333005eb46e1d1075dbfe6674d5ef7eca3fbe 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/initrd.h>
 #include <linux/pagemap.h>
 #include <linux/lmb.h>
+#include <linux/gfp.h>
 
 #include <asm/pgalloc.h>
 #include <asm/prom.h>
index 776f28d02b6b0a163a6c5f8d6bde6532a350d38c..d7fa50b09b4afe86af00ca4cf661ba0f0908d819 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/poison.h>
 #include <linux/lmb.h>
 #include <linux/hugetlb.h>
+#include <linux/slab.h>
 
 #include <asm/pgalloc.h>
 #include <asm/page.h>
index 311224cdb7ad08c53d0a8b70528b3bf888a4b795..0f594d774bf7c034975ab4f20bcdf7199981aba3 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/stddef.h>
@@ -48,6 +49,7 @@
 #include <asm/sparsemem.h>
 #include <asm/vdso.h>
 #include <asm/fixmap.h>
+#include <asm/swiotlb.h>
 
 #include "mmu_decl.h"
 
@@ -320,6 +322,11 @@ void __init mem_init(void)
        struct page *page;
        unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
 
+#ifdef CONFIG_SWIOTLB
+       if (ppc_swiotlb_enable)
+               swiotlb_init(1);
+#endif
+
        num_physpages = lmb.memory.size >> PAGE_SHIFT;
        high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
index 51622daae09d27928591757509c1b23c156decd8..2535828aa84bd0d174b3346c88b826572fe5d50f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/spinlock.h>
 #include <linux/idr.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 
 #include <asm/mmu_context.h>
 
index dbc692145ecb1aea313fc64992010519c73f1c28..1f2d9ff098952d7b760b8d4e15adf7c709fae41d 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/bootmem.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
+#include <linux/slab.h>
 
 #include <asm/mmu_context.h>
 #include <asm/tlbflush.h>
index 99df697c601acbd9a0fa3267cb313e7a21cd7303..ebc2f38eb381a3760fb8bd8014c5a23a38164980 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/percpu.h>
index 573b3bd1c45b46500c38e65495b9f3a2ee3a47a2..b9243e7557ae970fb06aa9d86b53d760312aebb3 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/highmem.h>
 #include <linux/lmb.h>
+#include <linux/slab.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
index 853d5565eed52b88deb8d37b2379d12fe8d6d6bb..d95679a5fb29f9dfccb3f09816288477b07242ba 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/lmb.h>
+#include <linux/slab.h>
 
 #include <asm/pgalloc.h>
 #include <asm/page.h>
index a040b81e93bdd6b49d16b77e4c8b04b0281c7bc6..e4f8f1fc81a570a38e2ab4e63a35023558633309 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/gfp.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
index 6b793aeda72ea041ac2a68f1ca2e2ece7f46badc..642fca137ccb1489c593699b21115ed37c542883 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/notifier.h>
 #include <linux/numa.h>
 #include <linux/oprofile.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include "pr_util.h"
 
index c591339daf58aff5f5b721bc883baeea8928e44e..c579b16845da453b06517662c031d631a9db9b18 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/elf.h>
+#include <linux/slab.h>
 #include "pr_util.h"
 
 
index e5c1b096c3e124186d9a4a4ae5c3f1cac8b06d06..8f771395f424e6d345ad8e6d2a36b093aa9ea946 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/delay.h>
 #include <linux/of_gpio.h>
 #include <linux/of_i2c.h>
+#include <linux/slab.h>
 
 #include <asm/machdep.h>
 #include <asm/prom.h>
index 2b8d8ef32e4eb2175fd822df0b942a35aebb24e4..fda7c2a18282613e8847f577bd425f8aa4367537 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/of.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/of_gpio.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
index 5d7cc88dae6bb2da3ee6db51b7d56c8b89131422..a60ee39d3b783d09ab67f2d3d3280af9bfdaf34d 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/watchdog.h>
 #include <linux/miscdevice.h>
 #include <linux/uaccess.h>
index 929d017535a3cb583f13ac122f39cb5503e8478e..d4f8be307cd5b3aef4adc4b360dbfbf08190a442 100644 (file)
@@ -481,6 +481,8 @@ mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match)
        if (rc)
                goto err_bcom_rx_irq;
 
+       lpbfifo.dma_irqs_enabled = 1;
+
        /* Request the Bestcomm transmit (memory --> fifo) task and IRQ */
        lpbfifo.bcom_tx_task =
                bcom_gen_bd_tx_init(2, res.start + LPBFIFO_REG_FIFO_DATA,
index f9aee182e6f70c55a1d6c4d3e36990ccc412bf08..f21555d3395ae7ab3b5d4c69d600b84fd1a039bc 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/fsl_devices.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/of_mdio.h>
+#include <linux/slab.h>
 #include <linux/of_platform.h>
 
 #include <asm/io.h>
index d4a09f8705b5c030cef0235e4b1287ccfaf71469..5a55d87d6bd6329beebff4cd742a0db47a7bae7a 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/irq.h>
 #include <linux/types.h>
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
index 82a9bcb858b6adaae55cac776e80d559a2a206fb..d119a7c1c17a970385aa43d975f45f59437053fc 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/gpio.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/machdep.h>
 
index 11f7b2b6f49ef9a216bc92d4734b3b5c9e8f788a..b8cb08dbd89c62b435b13a2fa69a2819a974d130 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #define GEF_GPIO_DIRECT                0x00
 #define GEF_GPIO_IN            0x04
index 242954c4293f64fcc6222a15de3eb6df6e8c0941..60168c1f98feb5bba3126c1f01ca6987fbe27f58 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/time.h>
index 96fe896f6df34707587d2694f8dcff13e7d369c9..8efe48192f3f50a0748978641fbad80ca050258c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/msi.h>
 #include <linux/of_platform.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include <asm/dcr.h>
 #include <asm/machdep.h>
index 00eaaa71630fde9252768167c20b1ce71cfd059d..404d1fc04d59e07d936daafd2f290d7d6d035184 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/pci_regs.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 7fca09f990ba4fecc0bdc4e7fe5ad64a594d4043..a881bbee8de0564b6a995ad7ed5e1fe7fb5f637e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/delay.h>
index ca5bfdfe47f2f7a9502e8bacc8b8d6b6ca00bca8..e3ec4976fae7a554c405ce7823d34b09bfbf37c5 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/notifier.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 #include <linux/lmb.h>
 
 #include <asm/prom.h>
index 608fd2b584c910548aff61f8a6c4d421a731b572..1d3c4effea10d1592acf1ea7fdd62370bef7055f 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/reboot.h>
 #include <linux/kexec.h>
index 59305369f6b232bb262521a6abe7cd8c3e2f35d6..50385db586bd951c706f0820d352114abb8adea5 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
index 5122ec145271e0e65608718a0233138144a77561..ca7731c0b59518776ada45d17aa7b20f532f8eea 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 
 #include <asm/ppc-pci.h>
index 891f18e337a269a75f07dbcdfb54a1ae11b9c30d..f465d474ad9b13b7813921bfa6cd4e9260b15d26 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/mm.h>
 #include <linux/io.h>
index 1410443731eb8b6aab3f7fae2f64b35ca92c5e2a..121aec353f268b007c558258acd206821efd13e8 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/mm.h>
 #include <linux/io.h>
index eea120229cdbc800a9540f534e49978adb0a446c..6cf3ec62852776ef78f3daa5864ad1615af36c8f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/file.h>
 #include <linux/fdtable.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/syscalls.h>
index 64a4c2d85f7cbd22671544a7ec3a65aac6fb37e9..5c2808252516500b9d8871dfea5c5e78f67f4268 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/poll.h>
 #include <linux/ptrace.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/time.h>
index 0e9f325c9ff7572318d0e843d707af86593fb78a..a101abf175040eac45df0ab0d972f1765e5d7e6c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <asm/spu.h>
index 4678078fede8ecafb3445195ca4b694a44274131..0b04662849320d662ea3cb974b20e5e4bdc711cb 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/completion.h>
 #include <linux/vmalloc.h>
 #include <linux/smp.h>
index c23617c6baf39ed1f4854f1f2ed2fde10ebd8e33..187a7d32f86a25ea2ff19e1fab99f7c551d0d59e 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/module.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index 8efd4244701c2eb1d0a73b07d9e21888ae066e94..ba3588f2d8e0c2df441907788046d2f8128b092c 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>
 #include <asm/prom.h>
index 8f41685d8f42b5669ee2a7e2492b5755e6919986..8553cc49e0d6a9e933eff573b4ea2b2190c87195 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/major.h>
index 9d53cb481a7cc3ee2714e99ce5bbe67f39d103ac..ce61cea0afb52cc77a4fa806da88cd7489518e88 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/list.h>
 #include <linux/pci.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <asm/iommu.h>
 #include <asm/vio.h>
index 6617915bcb1ae129345936e82fc5573be0a70cca..d2c1d497846e75f46f612d9c85043a56cadcbaa9 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/bcd.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 
 #include <asm/time.h>
 #include <asm/uaccess.h>
index 175aac8ca7e501216578401c8168429acced9af0..b841c9a9db87133ffa16aafef4ea5b1ab6805d98 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
index 2aa8b5631bebe54fc58df8b24d338c5eb2c8c888..00b6730bc48f07392f0604eab8b472badb121242 100644 (file)
@@ -22,7 +22,7 @@
  */
 #include <linux/of.h>
 #include <linux/init.h>
-#include <linux/gfp.h>
+#include <linux/slab.h>
 #include <linux/completion.h>
 #include <linux/proc_fs.h>
 #include <linux/module.h>
index 5aea94f30836c5044fe1fab08378a9535ac35f47..b5f05d943a90526b2f60505a439fa92b5fcf9e86 100644 (file)
@@ -29,6 +29,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/vmalloc.h>
 #include <linux/string.h>
index 0636a3df6978bed791e6d6160655f3cd56f748ff..39df70529d292d594a0f52fad57b5e19425a78c9 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/string.h>
index a6152d92224304bc20da05b3e5f44550956e376a..09695ae50f911c521766ad41fc938c1c05642b1b 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/of.h>
 
 #include <asm/pasemi_dma.h>
index 3bf546797cbba702b3b0c41d05682f399aa41039..0f881f64583e97f9436b48c6156d643db7ddead1 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
index 242f8095c2dfc0991f1108c6581d5969cb3e3516..ac6fdd9732912848dd3cc3ee8d606e9ff8c6a894 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/console.h>
 #include <linux/pci.h>
 #include <linux/of_platform.h>
+#include <linux/gfp.h>
 
 #include <asm/prom.h>
 #include <asm/system.h>
index d4f127d18141192bef0d3771e81bc79529d707fc..1e9eba175ff0d0300b62bbb957132b8bae3ef00e 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/sched.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
-#include <linux/slab.h>
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 #include <linux/sysdev.h>
index 3ed288e68ec4e613546b12b3ce4f9ec734830488..3ca09d3ccce33f35ab47a5fa53296c213085d243 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/cpufreq.h>
 #include <linux/init.h>
 #include <linux/completion.h>
index 345e2da56767998e3f3af53c23d9cc643d59514b..f45331ab97cbca3176a939194bb046e8181feea7 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/timer.h>
 #include <linux/mutex.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <asm/keylargo.h>
 #include <asm/uninorth.h>
 #include <asm/io.h>
index 80a5258d0364f39162a9ce32562b9b3948dfa6fe..b1cdcf94aa8e95daab73fa9cd757795e19d09301 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/string.h>
 #include <linux/nvram.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/adb.h>
index ede49e78a8da4f631632d7e553513dab2924f8af..cec6359426573d87a8d42a3439fc10393d8918ae 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 
index c20522656367c9ecbb02f91c86fcab197f080617..15c2241f9c72a85cb81c554a9a97d9e9e702aa29 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/string.h>
index bb028f165fb3d0008533d2e55b3eddbec898f076..b341018326df780af2f85147b6c3cd97863c1453 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/reboot.h>
 
 #include <asm/firmware.h>
index e81b028a2a48d8aca2efd0dcd7357ee9b4e9e62e..7925751e464acd2941ce5dce7caa037fc210a755 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/memory_hotplug.h>
 #include <linux/lmb.h>
+#include <linux/slab.h>
 
 #include <asm/cell-regs.h>
 #include <asm/firmware.h>
index d6487a9c801900d3aa9ee9db65a245f44f26f702..dd521a181f23bdb5237607e65fabbe7df6d2988a 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/ctype.h>
 #include <linux/lmb.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 
 #include <asm/prom.h>
 
index b3c6a993f9f3bc0d16a415391c631d988b887ef2..39a472e9e80fb9e5ccddfbe92cc25acee96f732a 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/mmzone.h>
 #include <linux/io.h>
 #include <linux/mm.h>
index e34b305a7a52a13cdaa7dee57e11a0262940fde3..6d09f5e3e7e49c77bd286dcc22366b4daf53c4b8 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <asm/udbg.h>
 #include <asm/lv1call.h>
index a277f2e28dbc285cb1ff285cf7ac2ec815e98d58..f4803868642c8248872933257c4abd8effaa663e 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kthread.h>
 #include <linux/module.h>
index 37bce52526da52f156841e364ed6998456d6a18a..e1682bc168a39cdaa89715126c5902625980b1bf 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
 #include <linux/cpu.h>
+#include <linux/slab.h>
 #include "offline_states.h"
 
 #include <asm/prom.h>
index c5f3116b6ca524e8b08aff7193ca796ccd089e00..a00addb559456e6c3ea69658887f630378863ff1 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <asm/smp.h>
 #include <asm/system.h>
index ce37040af870856271deecd0de2c0c42af32457e..30b987b73c20cae978e57c3e8a6fb587b903af3a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/list.h>
 #include <linux/pci.h>
 #include <linux/rbtree.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
 #include <asm/pci-bridge.h>
index ec5df8f519c7417327923bcadafdbda76874ec04..2ec500c130b5173ab497f6e51dc2eac7d860a407 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <asm/eeh_event.h>
 #include <asm/ppc-pci.h>
index 42f7e384e6c438c13350feb34ae7183a7abe3fc6..bc3c7f2abd795322ab579da4137688e17f966663 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>
 #include <asm/nvram.h>
index 225a50ab14be555c9ca6aa92889bb6432e5fcf3d..7ebd9e88d369c242b63dd48b0bd7a02a95f94449 100644 (file)
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kobject.h>
 #include <linux/mm.h>
index d20b96e22c2ed763aa583cd2e387b29b1927f146..db940d2c39a0a8605fb2b2db5a566ee5861f7016 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/interrupt.h>
 #include <linux/timex.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/random.h>
index a2305d29bbbdb822f89cb64041f66e245aaf9ad9..1a58637bcea5d12112ad96b9fa9e928f96e3f244 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kref.h>
 #include <linux/notifier.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
index 1b45c458f952fc6da9cb0b9e3ebb63416023ae06..80e9e7652a4d1371b0a17032fa4eb4edc7e0fbf1 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/rtas.h>
 #include <asm/prom.h>
index ca5f2e10972c32db9c737f28e4bbf36b76a1241e..6710761bf60fb725f6b36d9028c52238b9c2715f 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/major.h>
index ecad10d4e9281790928ea0b7d9512b9ebbc6e68b..4dae3698bf24eda94c12f59265654e9c94f73239 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/8xx_immap.h>
index 9de72c96e6d1b9718631d9a63a9f8e326b133796..88b9812c854fdc2de978871012eeb3c507717569 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/of_device.h>
 #include <linux/spinlock.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 
 #include <asm/udbg.h>
 #include <asm/io.h>
index bafc3f85360d3c3059f490ea9a312642393196c3..c8b96ed7c0158a81137777b050fbfd745d2dab0a 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <linux/init.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
@@ -38,6 +37,7 @@
 #include <linux/vmalloc.h>
 #include <linux/suspend.h>
 #include <linux/lmb.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/iommu.h>
index 714ec02fed2ea84b8f5825c3197b4af44fa49c0b..eca4545dd52ee0619b0bb0ad2b86597a5737d736 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/fsl_gtm.h>
 
 #define GTCFR_STP(x)           ((x) & 1 ? 1 << 5 : 1 << 1)
index e094367d7739e00f8949aab22de0c7c5f0fb1f9d..3482e3fd89c04e99a0205f1fbc82ad7d28313f3e 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/bootmem.h>
 #include <linux/msi.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <asm/prom.h>
index e1a028c1f18d0a94a415038c343f160309eb034c..a14760fe513a6bc7d5bcbc9780470b1b64e84516 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/bootmem.h>
 #include <linux/lmb.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
index 757a83fe5e59f7ecdb28f82a4ae7b68e77e54363..71fba88f50db86e5946593fe0f8407ffc078974b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/rio_drv.h>
 #include <linux/of_platform.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index ee1c0e1cf4a7d814d99788c0c6520fb18bfcd3bf..6478eb10691aafcc85ef4290fe1780802ef0025d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #define MPC8XXX_GPIO_PINS      32
 
index 339e8a3e26d2071cb37cb01d86d050ea446e1b37..260295b10557697d752dde512aae577401acd4a0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/bootmem.h>
 #include <linux/spinlock.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include <asm/ptrace.h>
 #include <asm/signal.h>
index 5a32cbef9b6c25b2adb34b7165e12d9398b05587..5287e95cec3a5ad79e6e6f9997335a3f0abd2e45 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitmap.h>
 #include <asm/msi_bitmap.h>
index 3d54450640c150dca4403602804a01d81ab5c40b..c9e803f3e267a1fba41f6f5d2285440ed758c0d7 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/of.h>
 #include <linux/init.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 static __initdata struct {
        const char *compatible;
index aaa915998eb630cdb0492427a67ac40816e67a68..652652db4ce283f11cee235d689268d0dcfce36d 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/completion.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
index 110efe2a54fca1d82cc0e00b75fee6637bed7181..3812fc366becfcf92af075f9339338d5e3533008 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 
 #define GPIO_MASK(gpio)                (0x80000000 >> (gpio))
 #define GPIO_MASK2(gpio)       (0xc0000000 >> ((gpio) * 2))
index 8aa33021e50b39d412d725e3c6dd72afba5e1099..106d767bf65bfd1c7d4e7332d6459de8a338eec4 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/of.h>
 #include <linux/bootmem.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/pci-bridge.h>
index 8e7a7767dd5c4eacb82be33953df8845126e1d71..dc8f8d61807480dc17faea46939dc30caec8ec39 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <asm/qe.h>
 
 struct qe_gpio_chip {
index ebb442ea191770a9dad1d6c69d9a40ac59583a4b..fa589b21dbcdd7ccfa97fefab11ea4f5ab853218 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
index 43c4569e24b7829a8910f64b7dc6291138b7b792..d5fb173e588cbe602fdd202291f01fc72fd47d76 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include "simple_gpio.h"
 
index 595034cfb85aa34cfad606da9e2a458b16a3f23a..0ab9281e49aec778e054bd32700ce5dfcb76895a 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 
index 4188cbe63a54a954e232a0d5d0dd5f9d4441dc32..e43fe753703114890aaff48dec708aec64f32999 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kernel_stat.h>
 #include <linux/pagemap.h>
index 4ce7fa95880fdb2aaa09169af226371374e1b55e..9a9586f4103f5d4bbea2a1f5d5a0c27b1453e5f4 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kernel_stat.h>
 #include <linux/netdevice.h>
index a97d695258297af2b9de00dfd0e42e7dc1767ff4..14e0479d3888eb8d5178fd0f0f4c851dc37ebdf4 100644 (file)
@@ -24,8 +24,8 @@
 /* Symbols defined by linker scripts */
 extern char input_data[];
 extern int input_len;
-extern int _text;
-extern int _end;
+extern char _text, _end;
+extern char _bss, _ebss;
 
 static void error(char *m);
 
@@ -129,12 +129,12 @@ unsigned long decompress_kernel(void)
        unsigned long output_addr;
        unsigned char *output;
 
+       check_ipl_parmblock((void *) 0, (unsigned long) output + SZ__bss_start);
+       memset(&_bss, 0, &_ebss - &_bss);
        free_mem_ptr = (unsigned long)&_end;
        free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
        output = (unsigned char *) ((free_mem_end_ptr + 4095UL) & -4096UL);
 
-       check_ipl_parmblock((void *) 0, (unsigned long) output + SZ__bss_start);
-
 #ifdef CONFIG_BLK_DEV_INITRD
        /*
         * Move the initrd right behind the end of the decompressed
index a3209906739e8dea52ee28bf51968af73172056a..aa819dac2360e946bf4712fc4f56c129a3113355 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <asm/debug.h>
 #include <asm/uaccess.h>
 
index 87cf523192e98527d85b00c7ee646b79b00b74d5..5b1acdba64957c53622dbf01861b992c78d514dd 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
index cd128b07beda7e1c798043c984d4343aa06ae046..c53f8ac825caf3c6aa6ef54d370fa1ecd9f9688d 100644 (file)
@@ -14,8 +14,8 @@
 #include <linux/fs.h>
 #include <linux/namei.h>
 #include <linux/vfs.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
-#include <linux/gfp.h>
 #include <linux/time.h>
 #include <linux/parser.h>
 #include <linux/sysfs.h>
index 67ee6c3c6bb3aa352484c94449c135315b0763ec..1741c1556a4e975ccc9fa7c655f45bb91fd0a530 100644 (file)
@@ -110,6 +110,7 @@ extern void pfault_fini(void);
 #endif /* CONFIG_PFAULT */
 
 extern void cmma_init(void);
+extern int memcpy_real(void *, void *, size_t);
 
 #define finish_arch_switch(prev) do {                                       \
        set_fs(current->thread.mm_segment);                                  \
@@ -218,8 +219,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
                        "       l       %0,%2\n"
                        "0:     nr      %0,%5\n"
                        "       lr      %1,%0\n"
-                       "       or      %0,%2\n"
-                       "       or      %1,%3\n"
+                       "       or      %0,%3\n"
+                       "       or      %1,%4\n"
                        "       cs      %0,%1,%2\n"
                        "       jnl     1f\n"
                        "       xr      %1,%0\n"
@@ -239,8 +240,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
                        "       l       %0,%2\n"
                        "0:     nr      %0,%5\n"
                        "       lr      %1,%0\n"
-                       "       or      %0,%2\n"
-                       "       or      %1,%3\n"
+                       "       or      %0,%3\n"
+                       "       or      %1,%4\n"
                        "       cs      %0,%1,%2\n"
                        "       jnl     1f\n"
                        "       xr      %1,%0\n"
index 11c3aba664ea6840604c50399a61121e8742d387..73b624ed9cd8ae612eef9521e8e708b458895bab 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
-#include <linux/slab.h>
 #include <linux/uio.h>
 #include <linux/quota.h>
 #include <linux/module.h>
@@ -52,6 +51,7 @@
 #include <linux/ptrace.h>
 #include <linux/fadvise.h>
 #include <linux/ipc.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/uaccess.h>
index ca4a62bd862fc8507966c1efdf64e41cae6efe20..9d1f76702d47acd67d3114c49057f363e7133d6d 100644 (file)
@@ -517,7 +517,10 @@ startup:
        lhi     %r1,2                   # mode 2 = esame (dump)
        sigp    %r1,%r0,0x12            # switch to esame mode
        sam64                           # switch to 64 bit mode
+       larl    %r13,4f
+       lmh     %r0,%r15,0(%r13)        # clear high-order half
        jg      startup_continue
+4:     .fill   16,4,0x0
 #else
        mvi     __LC_AR_MODE_ID,0       # set ESA flag (mode 0)
        l       %r13,4f-.LPG0(%r13)
index 39580e768658e0b23f76587b6fb59e5c000936f1..1f70970de0aa2b0fae5f0c428475e21e82d73100 100644 (file)
@@ -21,7 +21,6 @@ startup_continue:
        larl    %r1,sched_clock_base_cc
        mvc     0(8,%r1),__LC_LAST_UPDATE_CLOCK
        larl    %r13,.LPG1              # get base
-       lmh     %r0,%r15,.Lzero64-.LPG1(%r13)   # clear high-order half
        lctlg   %c0,%c15,.Lctl-.LPG1(%r13)      # load control registers
        lg      %r12,.Lparmaddr-.LPG1(%r13)     # pointer to parameter area
                                        # move IPL device to lowcore
@@ -67,7 +66,6 @@ startup_continue:
 .L4malign:.quad 0xffffffffffc00000
 .Lscan2g:.quad 0x80000000 + 0x20000 - 8        # 2GB + 128K - 8
 .Lnop: .long   0x07000700
-.Lzero64:.fill 16,4,0x0
 .Lparmaddr:
        .quad   PARMAREA
        .align  64
index 7eedbbcb54aa5901bf989397cbaa9b405c260529..72c8b0d070c849f5fb2891473f093ad2650f6ea4 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/reboot.h>
 #include <linux/ctype.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <asm/ipl.h>
 #include <asm/smp.h>
 #include <asm/setup.h>
index 86783efa24eebd95af298fc488d08ac8f30bb009..3d34eef5a2c3a03987479a28df28e4a415e3c2f0 100644 (file)
@@ -29,6 +29,7 @@
 #include <asm/cacheflush.h>
 #include <asm/sections.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
index 00b6d1d292f2a6efecf23d5abde930f89f68878b..1039fdea15b58bdb805f92838c9342d95253c4fb 100644 (file)
@@ -16,9 +16,9 @@
 #include <linux/fs.h>
 #include <linux/smp.h>
 #include <linux/stddef.h>
+#include <linux/slab.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/user.h>
 #include <linux/interrupt.h>
index 77a63ae419f00c8196a5e8cc944ac6224795ad2f..91625f759ccdfacd4c6c65deff5d5a974f7433f4 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/tty.h>
 #include <linux/ioport.h>
@@ -401,7 +400,7 @@ setup_lowcore(void)
         * Setup lowcore for boot cpu
         */
        BUILD_BUG_ON(sizeof(struct _lowcore) != LC_PAGES * 4096);
-       lc = __alloc_bootmem(LC_PAGES * PAGE_SIZE, LC_PAGES * PAGE_SIZE, 0);
+       lc = __alloc_bootmem_low(LC_PAGES * PAGE_SIZE, LC_PAGES * PAGE_SIZE, 0);
        lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
        lc->restart_psw.addr =
                PSW_ADDR_AMODE | (unsigned long) restart_int_handler;
@@ -433,7 +432,7 @@ setup_lowcore(void)
 #ifndef CONFIG_64BIT
        if (MACHINE_HAS_IEEE) {
                lc->extended_save_area_addr = (__u32)
-                       __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0);
+                       __alloc_bootmem_low(PAGE_SIZE, PAGE_SIZE, 0);
                /* enable extended save area */
                __ctl_set_bit(14, 29);
        }
index 29f65bce55e1bea4cac1e9c00297a0fb7eda371a..e4d98de83dd8393586118ec7ee760d4907385c05 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/cpu.h>
 #include <linux/timex.h>
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 #include <asm/asm-offsets.h>
 #include <asm/ipl.h>
 #include <asm/setup.h>
@@ -292,9 +293,9 @@ static void __init smp_get_save_area(unsigned int cpu, unsigned int phy_cpu)
        zfcpdump_save_areas[cpu] = kmalloc(sizeof(struct save_area), GFP_KERNEL);
        while (raw_sigp(phy_cpu, sigp_stop_and_store_status) == sigp_busy)
                cpu_relax();
-       memcpy(zfcpdump_save_areas[cpu],
-              (void *)(unsigned long) store_prefix() + SAVE_AREA_BASE,
-              sizeof(struct save_area));
+       memcpy_real(zfcpdump_save_areas[cpu],
+                   (void *)(unsigned long) store_prefix() + SAVE_AREA_BASE,
+                   sizeof(struct save_area));
 }
 
 struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
index b5e75e1061c82d35b40b63594f1889ce07d0453b..a0ffc7717ed62994609a66b22202982b1c867dba 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/ebcdic.h>
 #include <asm/sysinfo.h>
 #include <asm/cpcmd.h>
index aa2483e460f32a93e0906fd8a838d3b0dc4cdc4b..fba6dec156bf4c27b1f469b9e07543a05d21ded8 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/notifier.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 #include <asm/delay.h>
 #include <asm/s390_ext.h>
index 834774d8d5f3021c3867c6385a6754abbec04410..35c21bf910c55bff4e1ee45ee968eb69726dd182 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kvm_host.h>
 #include <linux/hrtimer.h>
 #include <linux/signal.h>
+#include <linux/slab.h>
 #include <asm/asm-offsets.h>
 #include <asm/uaccess.h>
 #include "kvm-s390.h"
index 28c55677eb399c33f472a564d596666f01bcedd3..44205507717cc673e1906d557f8d8bbe4e77f863 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/kvm.h>
+#include <linux/gfp.h>
 #include <linux/errno.h>
 #include <asm/current.h>
 #include <asm/debug.h>
index 241a48459b666fab172d376ddfda2da4562145ad..eff3c5989b46b1135336cb806794febeebf6c905 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/kvm.h>
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include "gaccess.h"
 #include "kvm-s390.h"
 
index f16bd04e39e9566dabe8928e7cd526bdcd26010c..f87b34731e1d9e377de37c30adfcbc50dec18477 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/sysctl.h>
 #include <linux/ctype.h>
index d5865e4024cebb6f6c6e295f95b34096484e07a7..acc91c75bc94a7e4a3b8f87600cbe312c4bdcc90 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/pfn.h>
 #include <linux/poison.h>
 #include <linux/initrd.h>
+#include <linux/gfp.h>
 #include <asm/processor.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 81756271dc44a51848f26f93bab6c5b2a066982a..a8c2af8c650fabd9c96a4f9efaf3c0c4f530f294 100644 (file)
@@ -59,3 +59,29 @@ long probe_kernel_write(void *dst, void *src, size_t size)
        }
        return copied < 0 ? -EFAULT : 0;
 }
+
+int memcpy_real(void *dest, void *src, size_t count)
+{
+       register unsigned long _dest asm("2") = (unsigned long) dest;
+       register unsigned long _len1 asm("3") = (unsigned long) count;
+       register unsigned long _src  asm("4") = (unsigned long) src;
+       register unsigned long _len2 asm("5") = (unsigned long) count;
+       unsigned long flags;
+       int rc = -EFAULT;
+
+       if (!count)
+               return 0;
+       flags = __raw_local_irq_stnsm(0xf8UL);
+       asm volatile (
+               "0:     mvcle   %1,%2,0x0\n"
+               "1:     jo      0b\n"
+               "       lhi     %0,0x0\n"
+               "2:\n"
+               EX_TABLE(1b,2b)
+               : "+d" (rc), "+d" (_dest), "+d" (_src), "+d" (_len1),
+                 "+d" (_len2), "=m" (*((long *) dest))
+               : "m" (*((long *) src))
+               : "cc", "memory");
+       __raw_local_irq_ssm(flags);
+       return rc;
+}
index 098923ae458fb04563c72a541e0cd7b287870343..a90d45e9dfb0cbb7b1dce5fb8441a249dc0556c3 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 
 #define ESSA_SET_STABLE                1
index ad621e06ada34fd32550bcf66200c24d1e00199c..8d999249d3574fb880da55af3fb5ff40d7f32fe8 100644 (file)
@@ -6,11 +6,11 @@
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/smp.h>
 #include <linux/highmem.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
index 300ab012b0fd875efa119d09f2784a60a3769843..8ea3144b45b805495ae53e85261b485c1f33328d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/list.h>
 #include <linux/hugetlb.h>
+#include <linux/slab.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/setup.h>
index 856ed68a58e6103efd22d0496cb2884438f8cfa0..651096ff8db49e2c9c4b564c00a0a12510a8b050 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/unistd.h>
 #include <linux/syscalls.h>
 #include <asm/syscalls.h>
index 7f001bbedb00a463d0746c2690421eec1df5bf3a..50fdec54c70a75c6aabd281263139f4dca54a6ef 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/errno.h>
 #include <linux/bootmem.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
index 39ed8722d11ad0b12469e6d17d4a98b671328634..6c13b92742e8de0d6410fbf0e3fc9553852d5e75 100644 (file)
@@ -836,6 +836,8 @@ static void __init sh_eth_init(struct sh_eth_plat_data *pd)
                pd->mac_addr[i] = mac_read(a, 0x10 + i);
                msleep(10);
        }
+
+       i2c_put_adapter(a);
 }
 #else
 static void __init sh_eth_init(struct sh_eth_plat_data *pd)
index 66cdbc3c7af9d0ae5e131099da29221fc997b8fd..ccaa290e9aba1cb29222cde90819cecb2f246cc6 100644 (file)
  * and change SW41 to use 720p
  */
 
+/*
+ * about sound
+ *
+ * This setup.c supports FSI slave mode.
+ * Please change J20, J21, J22 pin to 1-2 connection.
+ */
+
 /* Heartbeat */
 static struct resource heartbeat_resource = {
        .start  = PA_LED,
@@ -276,6 +283,7 @@ static struct clk fsimcka_clk = {
        .rate           = 0, /* unknown */
 };
 
+/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
 struct sh_fsi_platform_info fsi_info = {
        .porta_flags = SH_FSI_BRS_INV |
                       SH_FSI_OUT_SLAVE_MODE |
index 18e3356406f3cfa071794aa62901753bc4399d40..6041c66dd10ee1c22bc961262358c4dc9b3bdddb 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.33-rc2
-# Mon Jan  4 11:20:36 2010
+# Linux kernel version: 2.6.34-rc2
+# Mon Mar 29 02:21:58 2010
 #
 CONFIG_SUPERH=y
 CONFIG_SUPERH32=y
@@ -13,8 +13,8 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
-CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_IRQ_PER_CPU=y
+CONFIG_SPARSE_IRQ=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_CLOCKEVENTS=y
@@ -32,6 +32,7 @@ CONFIG_ARCH_NO_VIRT_TO_BUS=y
 CONFIG_ARCH_HAS_DEFAULT_IDLE=y
 CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
 CONFIG_DMA_NONCOHERENT=y
+CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 CONFIG_CONSTRUCTORS=y
 
@@ -47,9 +48,11 @@ CONFIG_LOCALVERSION=""
 CONFIG_HAVE_KERNEL_GZIP=y
 CONFIG_HAVE_KERNEL_BZIP2=y
 CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_HAVE_KERNEL_LZO=y
 CONFIG_KERNEL_GZIP=y
 # CONFIG_KERNEL_BZIP2 is not set
 # CONFIG_KERNEL_LZMA is not set
+# CONFIG_KERNEL_LZO is not set
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
@@ -71,14 +74,8 @@ CONFIG_RCU_FANOUT=32
 # CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-CONFIG_GROUP_SCHED=y
-CONFIG_FAIR_GROUP_SCHED=y
-# CONFIG_RT_GROUP_SCHED is not set
-CONFIG_USER_SCHED=y
-# CONFIG_CGROUP_SCHED is not set
 # CONFIG_CGROUPS is not set
-CONFIG_SYSFS_DEPRECATED=y
-CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 # CONFIG_BLK_DEV_INITRD is not set
@@ -107,7 +104,7 @@ CONFIG_PERF_USE_VMALLOC=y
 #
 # Kernel Performance Events And Counters
 #
-# CONFIG_PERF_EVENTS is not set
+CONFIG_PERF_EVENTS=y
 # CONFIG_PERF_COUNTERS is not set
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_COMPAT_BRK=y
@@ -116,13 +113,13 @@ CONFIG_SLAB=y
 # CONFIG_SLOB is not set
 # CONFIG_PROFILING is not set
 CONFIG_HAVE_OPROFILE=y
-CONFIG_HAVE_IOREMAP_PROT=y
 CONFIG_HAVE_KPROBES=y
 CONFIG_HAVE_KRETPROBES=y
 CONFIG_HAVE_ARCH_TRACEHOOK=y
 CONFIG_HAVE_DMA_ATTRS=y
 CONFIG_HAVE_CLK=y
 CONFIG_HAVE_DMA_API_DEBUG=y
+CONFIG_HAVE_HW_BREAKPOINT=y
 
 #
 # GCOV-based kernel profiling
@@ -234,12 +231,12 @@ CONFIG_CPU_SUBTYPE_SH7724=y
 CONFIG_QUICKLIST=y
 CONFIG_MMU=y
 CONFIG_PAGE_OFFSET=0x80000000
-CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_FORCE_MAX_ZONEORDER=12
 CONFIG_MEMORY_START=0x08000000
 CONFIG_MEMORY_SIZE=0x10000000
 CONFIG_29BIT=y
-# CONFIG_PMB_ENABLE is not set
-# CONFIG_X2TLB is not set
+# CONFIG_PMB is not set
+CONFIG_X2TLB=y
 CONFIG_VSYSCALL=y
 CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
@@ -247,6 +244,8 @@ CONFIG_ARCH_SPARSEMEM_DEFAULT=y
 CONFIG_MAX_ACTIVE_REGIONS=1
 CONFIG_ARCH_POPULATES_NODE_MAP=y
 CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_IOREMAP_FIXED=y
+CONFIG_UNCACHED_MAPPING=y
 CONFIG_PAGE_SIZE_4KB=y
 # CONFIG_PAGE_SIZE_8KB is not set
 # CONFIG_PAGE_SIZE_16KB is not set
@@ -262,7 +261,7 @@ CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
-CONFIG_NR_QUICK=2
+CONFIG_NR_QUICK=1
 # CONFIG_KSM is not set
 CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 
@@ -337,7 +336,6 @@ CONFIG_SECCOMP=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 CONFIG_PREEMPT=y
 CONFIG_GUSA=y
-# CONFIG_SPARSE_IRQ is not set
 
 #
 # Boot options
@@ -347,7 +345,7 @@ CONFIG_BOOT_LINK_OFFSET=0x00800000
 CONFIG_ENTRY_OFFSET=0x00001000
 CONFIG_CMDLINE_OVERWRITE=y
 # CONFIG_CMDLINE_EXTEND is not set
-CONFIG_CMDLINE="console=tty0, console=ttySC0,115200 root=/dev/nfs ip=dhcp mem=120M memchunk.vpu=4m"
+CONFIG_CMDLINE="console=tty0, console=ttySC0,115200 root=/dev/nfs ip=dhcp mem=248M memchunk.vpu=8m memchunk.veu0=4m"
 
 #
 # Bus options
@@ -373,6 +371,7 @@ CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
 # CONFIG_HIBERNATION is not set
 CONFIG_PM_RUNTIME=y
+CONFIG_PM_OPS=y
 # CONFIG_CPU_IDLE is not set
 CONFIG_NET=y
 
@@ -380,7 +379,6 @@ CONFIG_NET=y
 # Networking options
 #
 CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
@@ -445,7 +443,45 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
-# CONFIG_IRDA is not set
+CONFIG_IRDA=y
+
+#
+# IrDA protocols
+#
+# CONFIG_IRLAN is not set
+# CONFIG_IRCOMM is not set
+# CONFIG_IRDA_ULTRA is not set
+
+#
+# IrDA options
+#
+# CONFIG_IRDA_CACHE_LAST_LSAP is not set
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+# CONFIG_IRTTY_SIR is not set
+
+#
+# Dongle support
+#
+CONFIG_SH_SIR=y
+# CONFIG_KINGSUN_DONGLE is not set
+# CONFIG_KSDAZZLE_DONGLE is not set
+# CONFIG_KS959_DONGLE is not set
+
+#
+# FIR device drivers
+#
+# CONFIG_USB_IRDA is not set
+# CONFIG_SIGMATEL_FIR is not set
+# CONFIG_MCS_FIR is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
 CONFIG_WIRELESS=y
@@ -556,6 +592,7 @@ CONFIG_MTD_NAND_IDS=y
 # CONFIG_MTD_NAND_NANDSIM is not set
 # CONFIG_MTD_NAND_PLATFORM is not set
 # CONFIG_MTD_ALAUDA is not set
+# CONFIG_MTD_NAND_SH_FLCTL is not set
 # CONFIG_MTD_ONENAND is not set
 
 #
@@ -597,6 +634,7 @@ CONFIG_MISC_DEVICES=y
 # CONFIG_ICS932S401 is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
 # CONFIG_ISL29003 is not set
+# CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_DS1682 is not set
 # CONFIG_TI_DAC7512 is not set
 # CONFIG_C2PORT is not set
@@ -616,6 +654,7 @@ CONFIG_HAVE_IDE=y
 #
 # SCSI device support
 #
+CONFIG_SCSI_MOD=y
 # CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=y
 CONFIG_SCSI_DMA=y
@@ -768,7 +807,29 @@ CONFIG_KEYBOARD_SH_KEYSC=y
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_DYNAPRO is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
+# CONFIG_TOUCHSCREEN_FUJITSU is not set
+# CONFIG_TOUCHSCREEN_GUNZE is not set
+# CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
+# CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
+# CONFIG_TOUCHSCREEN_MK712 is not set
+# CONFIG_TOUCHSCREEN_PENMOUNT is not set
+# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
+# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
+# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+CONFIG_TOUCHSCREEN_TSC2007=y
+# CONFIG_TOUCHSCREEN_W90X900 is not set
 # CONFIG_INPUT_MISC is not set
 
 #
@@ -802,10 +863,10 @@ CONFIG_SERIAL_SH_SCI_NR_UARTS=6
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_TIMBERDALE is not set
 CONFIG_UNIX98_PTYS=y
 # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 CONFIG_HW_RANDOM=y
 # CONFIG_HW_RANDOM_TIMERIOMEM is not set
@@ -830,6 +891,7 @@ CONFIG_I2C_HELPER_AUTO=y
 # CONFIG_I2C_OCORES is not set
 CONFIG_I2C_SH_MOBILE=y
 # CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
 
 #
 # External I2C/SMBus adapter drivers
@@ -843,15 +905,9 @@ CONFIG_I2C_SH_MOBILE=y
 #
 # CONFIG_I2C_PCA_PLATFORM is not set
 # CONFIG_I2C_STUB is not set
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
 # CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
 CONFIG_SPI=y
 CONFIG_SPI_MASTER=y
 
@@ -882,13 +938,16 @@ CONFIG_GPIOLIB=y
 #
 # Memory mapped GPIO expanders:
 #
+# CONFIG_GPIO_IT8761E is not set
 
 #
 # I2C GPIO expanders:
 #
+# CONFIG_GPIO_MAX7300 is not set
 # CONFIG_GPIO_MAX732X is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_ADP5588 is not set
 
 #
 # PCI GPIO expanders:
@@ -919,23 +978,26 @@ CONFIG_SSB_POSSIBLE=y
 #
 # Multifunction device drivers
 #
-# CONFIG_MFD_CORE is not set
+CONFIG_MFD_CORE=y
+# CONFIG_MFD_88PM860X is not set
 # CONFIG_MFD_SM501 is not set
-# CONFIG_MFD_SH_MOBILE_SDHI is not set
+CONFIG_MFD_SH_MOBILE_SDHI=y
 # CONFIG_HTC_PASIC3 is not set
+# CONFIG_HTC_I2CPLD is not set
 # CONFIG_TPS65010 is not set
 # CONFIG_TWL4030_CORE is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_PMIC_DA903X is not set
 # CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_MAX8925 is not set
 # CONFIG_MFD_WM8400 is not set
 # CONFIG_MFD_WM831X is not set
 # CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
 # CONFIG_MFD_PCF50633 is not set
 # CONFIG_MFD_MC13783 is not set
 # CONFIG_AB3100_CORE is not set
 # CONFIG_EZX_PCAP is not set
-# CONFIG_MFD_88PM8607 is not set
 # CONFIG_AB4500_CORE is not set
 # CONFIG_REGULATOR is not set
 CONFIG_MEDIA_SUPPORT=y
@@ -985,10 +1047,10 @@ CONFIG_SOC_CAMERA=y
 # CONFIG_SOC_CAMERA_MT9M001 is not set
 # CONFIG_SOC_CAMERA_MT9M111 is not set
 # CONFIG_SOC_CAMERA_MT9T031 is not set
-# CONFIG_SOC_CAMERA_MT9T112 is not set
+CONFIG_SOC_CAMERA_MT9T112=y
 # CONFIG_SOC_CAMERA_MT9V022 is not set
 # CONFIG_SOC_CAMERA_RJ54N1 is not set
-# CONFIG_SOC_CAMERA_TW9910 is not set
+CONFIG_SOC_CAMERA_TW9910=y
 # CONFIG_SOC_CAMERA_PLATFORM is not set
 # CONFIG_SOC_CAMERA_OV772X is not set
 # CONFIG_SOC_CAMERA_OV9640 is not set
@@ -1001,6 +1063,7 @@ CONFIG_RADIO_ADAPTERS=y
 # CONFIG_RADIO_SI470X is not set
 # CONFIG_USB_MR800 is not set
 # CONFIG_RADIO_TEA5764 is not set
+# CONFIG_RADIO_SAA7706H is not set
 # CONFIG_RADIO_TEF6862 is not set
 # CONFIG_DAB is not set
 
@@ -1034,6 +1097,7 @@ CONFIG_FB_DEFERRED_IO=y
 #
 # CONFIG_FB_S1D13XXX is not set
 CONFIG_FB_SH_MOBILE_LCDC=y
+# CONFIG_FB_TMIO is not set
 # CONFIG_FB_VIRTUAL is not set
 # CONFIG_FB_METRONOME is not set
 # CONFIG_FB_MB862XX is not set
@@ -1062,7 +1126,46 @@ CONFIG_LOGO=y
 # CONFIG_LOGO_SUPERH_MONO is not set
 # CONFIG_LOGO_SUPERH_VGA16 is not set
 CONFIG_LOGO_SUPERH_CLUT224=y
-# CONFIG_SOUND is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_JACK=y
+CONFIG_SND_SEQUENCER=y
+CONFIG_SND_SEQ_DUMMY=y
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
+# CONFIG_SND_SEQUENCER_OSS is not set
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+# CONFIG_SND_DRIVERS is not set
+# CONFIG_SND_SPI is not set
+CONFIG_SND_SUPERH=y
+# CONFIG_SND_USB is not set
+CONFIG_SND_SOC=y
+
+#
+# SoC Audio support for SuperH
+#
+CONFIG_SND_SOC_SH4_FSI=y
+# CONFIG_SND_FSI_AK4642 is not set
+CONFIG_SND_FSI_DA7210=y
+CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_ALL_CODECS is not set
+CONFIG_SND_SOC_DA7210=y
+# CONFIG_SOUND_PRIME is not set
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
 # CONFIG_HIDRAW is not set
@@ -1077,6 +1180,7 @@ CONFIG_USB_HID=y
 #
 # Special HID drivers
 #
+# CONFIG_HID_3M_PCT is not set
 # CONFIG_HID_A4TECH is not set
 # CONFIG_HID_APPLE is not set
 # CONFIG_HID_BELKIN is not set
@@ -1091,12 +1195,16 @@ CONFIG_USB_HID=y
 # CONFIG_HID_KENSINGTON is not set
 # CONFIG_HID_LOGITECH is not set
 # CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MOSART is not set
 # CONFIG_HID_MONTEREY is not set
 # CONFIG_HID_NTRIG is not set
+# CONFIG_HID_ORTEK is not set
 # CONFIG_HID_PANTHERLORD is not set
 # CONFIG_HID_PETALYNX is not set
+# CONFIG_HID_QUANTA is not set
 # CONFIG_HID_SAMSUNG is not set
 # CONFIG_HID_SONY is not set
+# CONFIG_HID_STANTUM is not set
 # CONFIG_HID_SUNPLUS is not set
 # CONFIG_HID_GREENASIA is not set
 # CONFIG_HID_SMARTJOYPLUS is not set
@@ -1136,6 +1244,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_SL811_HCD is not set
 CONFIG_USB_R8A66597_HCD=y
 # CONFIG_USB_HWA_HCD is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
 # USB Device Class drivers
@@ -1188,7 +1297,6 @@ CONFIG_USB_STORAGE=y
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
-# CONFIG_USB_BERRY_CHARGE is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
@@ -1200,8 +1308,45 @@ CONFIG_USB_STORAGE=y
 # CONFIG_USB_IOWARRIOR is not set
 # CONFIG_USB_TEST is not set
 # CONFIG_USB_ISIGHTFW is not set
-# CONFIG_USB_VST is not set
-# CONFIG_USB_GADGET is not set
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+CONFIG_USB_GADGET_R8A66597=y
+CONFIG_USB_R8A66597=y
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_ETH is not set
+# CONFIG_USB_GADGETFS is not set
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+# CONFIG_USB_MASS_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+# CONFIG_USB_G_NOKIA is not set
+# CONFIG_USB_G_MULTI is not set
 
 #
 # OTG and related infrastructure
@@ -1224,10 +1369,8 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 # MMC/SD/SDIO Host Controller Drivers
 #
 # CONFIG_MMC_SDHCI is not set
-# CONFIG_MMC_AT91 is not set
-# CONFIG_MMC_ATMELMCI is not set
 CONFIG_MMC_SPI=y
-# CONFIG_MMC_TMIO is not set
+CONFIG_MMC_TMIO=y
 # CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
 # CONFIG_ACCESSIBILITY is not set
@@ -1253,10 +1396,10 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_DS1374 is not set
 # CONFIG_RTC_DRV_DS1672 is not set
 # CONFIG_RTC_DRV_MAX6900 is not set
-# CONFIG_RTC_DRV_RS5C372 is not set
+CONFIG_RTC_DRV_RS5C372=y
 # CONFIG_RTC_DRV_ISL1208 is not set
 # CONFIG_RTC_DRV_X1205 is not set
-CONFIG_RTC_DRV_PCF8563=y
+# CONFIG_RTC_DRV_PCF8563 is not set
 # CONFIG_RTC_DRV_PCF8583 is not set
 # CONFIG_RTC_DRV_M41T80 is not set
 # CONFIG_RTC_DRV_BQ32K is not set
@@ -1303,8 +1446,6 @@ CONFIG_RTC_DRV_PCF8563=y
 CONFIG_UIO=y
 # CONFIG_UIO_PDRV is not set
 CONFIG_UIO_PDRV_GENIRQ=y
-# CONFIG_UIO_SMX is not set
-# CONFIG_UIO_SERCOS3 is not set
 
 #
 # TI VLYNQ
@@ -1390,6 +1531,7 @@ CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_EFS_FS is not set
 # CONFIG_JFFS2_FS is not set
 # CONFIG_UBIFS_FS is not set
+# CONFIG_LOGFS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
@@ -1418,6 +1560,7 @@ CONFIG_SUNRPC=y
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CEPH_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
@@ -1487,6 +1630,7 @@ CONFIG_DEBUG_FS=y
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_LKDTM is not set
 # CONFIG_LATENCYTOP is not set
 CONFIG_SYSCTL_SYSCALL_CHECK=y
 CONFIG_HAVE_FUNCTION_TRACER=y
@@ -1618,7 +1762,7 @@ CONFIG_CRYPTO_HW=y
 #
 CONFIG_BITREVERSE=y
 CONFIG_GENERIC_FIND_LAST_BIT=y
-# CONFIG_CRC_CCITT is not set
+CONFIG_CRC_CCITT=y
 # CONFIG_CRC16 is not set
 CONFIG_CRC_T10DIF=y
 CONFIG_CRC_ITU_T=y
index 727126e907e33c01cdf616529b3c8e0221794398..4a277224a871f9d846210916d48eab26f80ab489 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/dma.h>
 
 DEFINE_SPINLOCK(dma_spin_lock);
index 72622e3076136d425c8e574487332619dc910fab..6ab9c4a1543994f3deafbd8dfccfe1e8392ad948 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <asm/dma.h>
 #include <asm/dmabrg.h>
 #include <asm/io.h>
index 2acbc793032de7da013c16db1c3e1e4eb3ed2c12..7efc9c354fc7e7847f00334d4687075c1416a26d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/heartbeat.h>
 
 #define DRV_NAME "heartbeat"
index ae91a2dd9183c829ee2177af54c6df627f9c75cb..68cb9b0ac9d28294d00c8cb63a9ece18a5ad7bfd 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "pcie-sh7786.h"
 #include <asm/sizes.h>
 
index 725be6de589b4e81081ea63a364229ed6bf54911..7b42c247316c56e1e0fc85da723407c041f2097f 100644 (file)
@@ -8,6 +8,7 @@
  * for more details.
  */
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
index ac04255022b69548e6f71f07f0502e97664c881f..ce830faeebbf50705e1ba1126b240ea274bbd77c 100644 (file)
@@ -211,7 +211,9 @@ extern void __kernel_vsyscall;
 
 #define VSYSCALL_AUX_ENT                                       \
        if (vdso_enabled)                                       \
-               NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE);
+               NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE);        \
+       else                                                    \
+               NEW_AUX_ENT(AT_IGNORE, 0);
 #else
 #define VSYSCALL_AUX_ENT
 #endif /* CONFIG_VSYSCALL */
@@ -219,7 +221,7 @@ extern void __kernel_vsyscall;
 #ifdef CONFIG_SH_FPU
 #define FPU_AUX_ENT    NEW_AUX_ENT(AT_FPUCW, FPSCR_INIT)
 #else
-#define FPU_AUX_ENT
+#define FPU_AUX_ENT    NEW_AUX_ENT(AT_IGNORE, 0)
 #endif
 
 extern int l1i_cache_shape, l1d_cache_shape, l2_cache_shape;
index 19fe84550b4915b7e951b97d52637c86cbd77b31..56e4418c19b984832589a53ccce34b554e56c2ed 100644 (file)
@@ -66,6 +66,13 @@ int pmb_unmap(void __iomem *addr);
 
 #else
 
+static inline int
+pmb_bolt_mapping(unsigned long virt, phys_addr_t phys,
+                unsigned long size, pgprot_t prot)
+{
+       return -EINVAL;
+}
+
 static inline void __iomem *
 pmb_remap_caller(phys_addr_t phys, unsigned long size,
                 pgprot_t prot, void *caller)
index 03ea75c5315d4887380d996624e153e603d486df..5963124c1d4ad0f105605e139ea6f1e7d55cc845 100644 (file)
@@ -19,6 +19,8 @@
 
 #define MMUCR          0xFF000010      /* MMU Control Register */
 
+#define MMU_ITLB_ADDRESS_ARRAY  0xF2000000
+#define MMU_ITLB_ADDRESS_ARRAY2        0xF2800000
 #define MMU_UTLB_ADDRESS_ARRAY 0xF6000000
 #define MMU_UTLB_ADDRESS_ARRAY2        0xF6800000
 #define MMU_PAGE_ASSOC_BIT     0x80
@@ -28,6 +30,8 @@
 #define MMUCR_URB              0x00FC0000
 #define MMUCR_URB_SHIFT                18
 #define MMUCR_URB_NENTRIES     64
+#define MMUCR_URC              0x0000FC00
+#define MMUCR_URC_SHIFT                10
 
 #if defined(CONFIG_32BIT) && defined(CONFIG_CPU_SUBTYPE_ST40)
 #define MMUCR_SE               (1 << 4)
index 7672301d0c70917da242ce4e398fa5d4b84712f9..7f62b9380938203ad6d25a221db7c44424b1c46f 100644 (file)
 #define WTCNT          0xffcc0000 /*WDTST*/
 #define WTST           WTCNT
 #define WTBST          0xffcc0008 /*WDTBST*/
+/* Register definitions */
+#elif  defined(CONFIG_CPU_SUBTYPE_SH7722) || \
+       defined(CONFIG_CPU_SUBTYPE_SH7723) || \
+       defined(CONFIG_CPU_SUBTYPE_SH7724)
+#define WTCNT          0xa4520000
+#define WTCSR          0xa4520004
 #else
 /* Register definitions */
 #define WTCNT          0xffc00008
index f059ed62cf57176cbae60d679a16436dff2793c3..7f1b70cace35d74be094e5078df32fe63c7eb680 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/processor.h>
 #include <asm/fpu.h>
 
index c0ad7d46e7848687b5103ad826bb1a92b1a284de..67a1e811cfe852851d353f3e63216dc0d99c619a 100644 (file)
@@ -1,6 +1,5 @@
 #include <linux/clk.h>
 #include <linux/compiler.h>
-#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
 #include <asm/suspend.h>
index dce4f3ff09324f8340327379bac3ea49d6df0878..0fffacea6ed96aebda4c692ace9b1185468d74b5 100644 (file)
@@ -48,7 +48,7 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
                return -ENODEV;
 
        cpus_allowed = current->cpus_allowed;
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
        BUG_ON(smp_processor_id() != cpu);
 
@@ -66,7 +66,7 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
        freqs.flags     = 0;
 
        cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
        clk_set_rate(cpuclk, freq);
        cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 
index bd1c497280a66b927b1b07e8eaa4817fd278920a..a8234b2010d183c8c0e9374d91f402b799920f0f 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/elf.h>
 #include <linux/ftrace.h>
+#include <linux/slab.h>
 #include <asm/dwarf.h>
 #include <asm/unwinder.h>
 #include <asm/sections.h>
@@ -727,7 +728,7 @@ static int dwarf_parse_cie(void *entry, void *p, unsigned long len,
                           unsigned char *end, struct module *mod)
 {
        struct rb_node **rb_node = &cie_root.rb_node;
-       struct rb_node *parent;
+       struct rb_node *parent = *rb_node;
        struct dwarf_cie *cie;
        unsigned long flags;
        int count;
@@ -856,7 +857,7 @@ static int dwarf_parse_fde(void *entry, u32 entry_type,
                           unsigned char *end, struct module *mod)
 {
        struct rb_node **rb_node = &fde_root.rb_node;
-       struct rb_node *parent;
+       struct rb_node *parent = *rb_node;
        struct dwarf_fde *fde;
        struct dwarf_cie *cie;
        unsigned long flags;
index 0fd7b41f0a2242c0e6a59e4e00048f7bd7f01c25..273f890b17ae3eb0fd643473e3a62b775cb8f51a 100644 (file)
@@ -112,7 +112,7 @@ void cpu_idle(void)
        }
 }
 
-void __cpuinit select_idle_routine(void)
+void __init select_idle_routine(void)
 {
        /*
         * If a platform has set its own idle routine, leave it alone.
index c96850b061fb8e4830c26afd5c083ab861ab0a06..4049d99f76e13ff5983b4a840a0673ed7ca47d5e 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ptrace.h>
 #include <linux/preempt.h>
 #include <linux/kdebug.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 #include <asm/uaccess.h>
 
index 9f253e9cce01283315f000d11d7ffc08427734d3..81b6de41ae5d1c3bfb87c340acee5291a499a036 100644 (file)
@@ -315,7 +315,7 @@ void hw_perf_disable(void)
        sh_pmu->disable_all();
 }
 
-int register_sh_pmu(struct sh_pmu *pmu)
+int __cpuinit register_sh_pmu(struct sh_pmu *pmu)
 {
        if (sh_pmu)
                return -EBUSY;
index 81add9b9ea6eccb8380b685b94fda321b7b63218..17f89aa4e1b3bad5d035e2515eb65c7d19f3d55c 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/mm.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 struct kmem_cache *task_xstate_cachep = NULL;
index 3cb88f114d7affd459d6db2db55ac67be00b5423..052981972ae68ecd299a00bf8ca1196de6605507 100644 (file)
@@ -15,6 +15,7 @@
  */
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/elfcore.h>
 #include <linux/kallsyms.h>
 #include <linux/fs.h>
index c90957a459ac9f59bf85d82f68b2c6caba917071..d4ca6480e355bebce7ccd9a628817cb37f825e84 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/ptrace.h>
 #include <linux/reboot.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -504,13 +505,6 @@ out:
        return error;
 }
 
-/*
- * These bracket the sleeping functions..
- */
-extern void interruptible_sleep_on(wait_queue_head_t *q);
-
-#define mid_sched      ((unsigned long) interruptible_sleep_on)
-
 #ifdef CONFIG_FRAME_POINTER
 static int in_sh64_switch_to(unsigned long pc)
 {
index c625cdab76dd4143d6001f8b3913699c26e351df..7759a9a93211279d8df3a3d4217b7d723146a195 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
-#include <linux/slab.h>
 #include <linux/security.h>
 #include <linux/signal.h>
 #include <linux/io.h>
index df3ab5811074f0bfcada56897092f9eeaed937e1..cbf1dd5372b2d223f399ab884fd46bfbd83246d1 100644 (file)
@@ -9,6 +9,7 @@
  * for more details.
  */
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <asm/dwarf.h>
 
 #ifdef CONFIG_DWARF_UNWINDER
@@ -52,3 +53,5 @@ void *return_address(unsigned int depth)
 }
 
 #endif
+
+EXPORT_SYMBOL_GPL(return_address);
index e124cf7008df46ed2e6de79f450901bd4161fbc5..002cc612deef5ce9c93499e8a2ea4043050eb189 100644 (file)
@@ -69,6 +69,7 @@ asmlinkage void __cpuinit start_secondary(void)
        unsigned int cpu;
        struct mm_struct *mm = &init_mm;
 
+       enable_mmu();
        atomic_inc(&mm->mm_count);
        atomic_inc(&mm->mm_users);
        current->active_mm = mm;
index 3f7e415be86ade5ee681e11b174754d91f231d6b..242117cbad67bfa5f936911dbd70024905a68c2b 100644 (file)
@@ -11,7 +11,6 @@
  * for more details.
  */
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/gfp.h>
index 902967e3f84165d683ded5f4a0b9db43a536eb5c..c86a08540258bf72ac09821f13a5c1c94fe9b41d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/dma-debug.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <asm/cacheflush.h>
 #include <asm/addrspace.h>
 
index 9304117039c4f887d7a94f70e48a73c6d1549ef8..9163db3e8d15c521d75a8ca2a505428cc3409072 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
-#include <linux/slab.h>
 #include <linux/sysctl.h>
 
 #include <asm/mman.h>
index 68028e8f26ce76a42ad5173684f1700406007802..c505de61a5ca468ed017af3f044c7f9bb2635fc4 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/bootmem.h>
 #include <linux/proc_fs.h>
 #include <linux/pagemap.h>
index 1ab2385ecefee5bd195e26949d62eb30ca51ccd1..0c99ec2e7ed8ade5d04614fc7468ecd60464a4c2 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/vmalloc.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/io.h>
index 7f682e5dafcf2a1465cd1578dfdd2ce803e46fc2..efbe84af9983e61d127856f6b49a6cfb21c3077f 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/io.h>
 #include <linux/bootmem.h>
 #include <linux/proc_fs.h>
-#include <linux/slab.h>
 #include <asm/fixmap.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
index 6f21fb1d8726e257abf6ebd46210fc3383a94cdf..26e03a1f7ca4b6d602e9cc80d2b04ff9bb28600f 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/mm.h>
+#include <linux/slab.h>
 
 #define PGALLOC_GFP GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO
 
index a4662e2782c3fd84c8743dfb56394fdce971fe95..e43ec600afcfbc9b853522ea4df330d1991de589 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/sysdev.h>
 #include <linux/cpu.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/fs.h>
@@ -323,6 +322,7 @@ static void __clear_pmb_entry(struct pmb_entry *pmbe)
        writel_uncached(data_val & ~PMB_V, data);
 }
 
+#ifdef CONFIG_PM
 static void set_pmb_entry(struct pmb_entry *pmbe)
 {
        unsigned long flags;
@@ -331,6 +331,7 @@ static void set_pmb_entry(struct pmb_entry *pmbe)
        __set_pmb_entry(pmbe);
        spin_unlock_irqrestore(&pmbe->lock, flags);
 }
+#endif /* CONFIG_PM */
 
 int pmb_bolt_mapping(unsigned long vaddr, phys_addr_t phys,
                     unsigned long size, pgprot_t prot)
@@ -802,7 +803,7 @@ void __init pmb_init(void)
        writel_uncached(0, PMB_IRMCR);
 
        /* Flush out the TLB */
-       __raw_writel(__raw_readl(MMUCR) | MMUCR_TI, MMUCR);
+       local_flush_tlb_all();
        ctrl_barrier();
 }
 
index 32dc674c550c12ec2424adaf46c5856b90a0ea72..b71db6af806088b1d3d84dd4a214b139e44a8700 100644 (file)
@@ -73,5 +73,35 @@ void local_flush_tlb_one(unsigned long asid, unsigned long page)
        jump_to_uncached();
        __raw_writel(page, MMU_UTLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
        __raw_writel(asid, MMU_UTLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
+       __raw_writel(page, MMU_ITLB_ADDRESS_ARRAY | MMU_PAGE_ASSOC_BIT);
+       __raw_writel(asid, MMU_ITLB_ADDRESS_ARRAY2 | MMU_PAGE_ASSOC_BIT);
        back_to_cached();
 }
+
+void local_flush_tlb_all(void)
+{
+       unsigned long flags, status;
+       int i;
+
+       /*
+        * Flush all the TLB.
+        */
+       local_irq_save(flags);
+       jump_to_uncached();
+
+       status = __raw_readl(MMUCR);
+       status = ((status & MMUCR_URB) >> MMUCR_URB_SHIFT);
+
+       if (status == 0)
+               status = MMUCR_URB_NENTRIES;
+
+       for (i = 0; i < status; i++)
+               __raw_writel(0x0, MMU_UTLB_ADDRESS_ARRAY | (i << 8));
+
+       for (i = 0; i < 4; i++)
+               __raw_writel(0x0, MMU_ITLB_ADDRESS_ARRAY | (i << 8));
+
+       back_to_cached();
+       ctrl_barrier();
+       local_irq_restore(flags);
+}
index 4f5f7cbdd508e7e9f1e87f4f5404eab538118281..7a940dbfc2e9d0ecccf71c342b816a9f7bebf577 100644 (file)
@@ -77,3 +77,22 @@ void local_flush_tlb_one(unsigned long asid, unsigned long page)
        for (i = 0; i < ways; i++)
                __raw_writel(data, addr + (i << 8));
 }
+
+void local_flush_tlb_all(void)
+{
+       unsigned long flags, status;
+
+       /*
+        * Flush all the TLB.
+        *
+        * Write to the MMU control register's bit:
+        *      TF-bit for SH-3, TI-bit for SH-4.
+        *      It's same position, bit #2.
+        */
+       local_irq_save(flags);
+       status = __raw_readl(MMUCR);
+       status |= 0x04;
+       __raw_writel(status, MMUCR);
+       ctrl_barrier();
+       local_irq_restore(flags);
+}
index ccac77f504a8532192d063ef2d423b4c4a613948..cfdf7930d2946723262ea5eaf1d1b3f1595eef2e 100644 (file)
@@ -80,3 +80,31 @@ void local_flush_tlb_one(unsigned long asid, unsigned long page)
        __raw_writel(data, addr);
        back_to_cached();
 }
+
+void local_flush_tlb_all(void)
+{
+       unsigned long flags, status;
+       int i;
+
+       /*
+        * Flush all the TLB.
+        */
+       local_irq_save(flags);
+       jump_to_uncached();
+
+       status = __raw_readl(MMUCR);
+       status = ((status & MMUCR_URB) >> MMUCR_URB_SHIFT);
+
+       if (status == 0)
+               status = MMUCR_URB_NENTRIES;
+
+       for (i = 0; i < status; i++)
+               __raw_writel(0x0, MMU_UTLB_ADDRESS_ARRAY | (i << 8));
+
+       for (i = 0; i < 4; i++)
+               __raw_writel(0x0, MMU_ITLB_ADDRESS_ARRAY | (i << 8));
+
+       back_to_cached();
+       ctrl_barrier();
+       local_irq_restore(flags);
+}
index bb5b9098956d9157c2d1bf7c4166b20990bd99a0..c92ce20db39bf478dd6db83a0c3ed6dc430ca027 100644 (file)
@@ -24,13 +24,9 @@ void tlb_wire_entry(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
 
        local_irq_save(flags);
 
-       /* Load the entry into the TLB */
-       __update_tlb(vma, addr, pte);
-
-       /* ... and wire it up. */
        status = __raw_readl(MMUCR);
        urb = (status & MMUCR_URB) >> MMUCR_URB_SHIFT;
-       status &= ~MMUCR_URB;
+       status &= ~MMUCR_URC;
 
        /*
         * Make sure we're not trying to wire the last TLB entry slot.
@@ -39,7 +35,23 @@ void tlb_wire_entry(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
 
        urb = urb % MMUCR_URB_NENTRIES;
 
+       /*
+        * Insert this entry into the highest non-wired TLB slot (via
+        * the URC field).
+        */
+       status |= (urb << MMUCR_URC_SHIFT);
+       __raw_writel(status, MMUCR);
+       ctrl_barrier();
+
+       /* Load the entry into the TLB */
+       __update_tlb(vma, addr, pte);
+
+       /* ... and wire it up. */
+       status = __raw_readl(MMUCR);
+
+       status &= ~MMUCR_URB;
        status |= (urb << MMUCR_URB_SHIFT);
+
        __raw_writel(status, MMUCR);
        ctrl_barrier();
 
index 004bb3f25b5f5f7e080505e967fea140328d480b..3fbe03ce8fe3a665768516dd4e341e783e164e69 100644 (file)
@@ -119,22 +119,3 @@ void local_flush_tlb_mm(struct mm_struct *mm)
                local_irq_restore(flags);
        }
 }
-
-void local_flush_tlb_all(void)
-{
-       unsigned long flags, status;
-
-       /*
-        * Flush all the TLB.
-        *
-        * Write to the MMU control register's bit:
-        *      TF-bit for SH-3, TI-bit for SH-4.
-        *      It's same position, bit #2.
-        */
-       local_irq_save(flags);
-       status = __raw_readl(MMUCR);
-       status |= 0x04;
-       __raw_writel(status, MMUCR);
-       ctrl_barrier();
-       local_irq_restore(flags);
-}
index cf20a5c5136a72ef6b0a89519f203894239343a9..8a4eca551fc0a08542085faddeac7af373ad091b 100644 (file)
@@ -1,6 +1,8 @@
 #include <linux/init.h>
+#include <linux/module.h>
 #include <asm/sizes.h>
 #include <asm/page.h>
+#include <asm/addrspace.h>
 
 /*
  * This is the offset of the uncached section from its cached alias.
 unsigned long cached_to_uncached = SZ_512M;
 unsigned long uncached_size = SZ_512M;
 unsigned long uncached_start, uncached_end;
+EXPORT_SYMBOL(uncached_start);
+EXPORT_SYMBOL(uncached_end);
 
 int virt_addr_uncached(unsigned long kaddr)
 {
        return (kaddr >= uncached_start) && (kaddr < uncached_end);
 }
+EXPORT_SYMBOL(virt_addr_uncached);
 
 void __init uncached_init(void)
 {
+#ifdef CONFIG_29BIT
+       uncached_start = P2SEG;
+#else
        uncached_start = memory_end;
+#endif
        uncached_end = uncached_start + uncached_size;
 }
 
index 56e3163673e304d333cb856538f1e5544b64d4c7..259e3fd50993a95a2970f404a9c7a4a5224a1b5d 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.33
-# Wed Mar  3 02:54:29 2010
+# Linux kernel version: 2.6.34-rc3
+# Sat Apr  3 15:49:56 2010
 #
 CONFIG_64BIT=y
 CONFIG_SPARC=y
@@ -23,6 +23,7 @@ CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
 CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
 CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
 CONFIG_MMU=y
+CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_ARCH_NO_VIRT_TO_BUS=y
 CONFIG_OF=y
 CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
@@ -439,6 +440,7 @@ CONFIG_MISC_DEVICES=y
 # CONFIG_ENCLOSURE_SERVICES is not set
 # CONFIG_HP_ILO is not set
 # CONFIG_ISL29003 is not set
+# CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_DS1682 is not set
 # CONFIG_C2PORT is not set
 
@@ -511,6 +513,7 @@ CONFIG_BLK_DEV_IDEDMA=y
 #
 # SCSI device support
 #
+CONFIG_SCSI_MOD=y
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=y
 CONFIG_SCSI_DMA=y
@@ -888,6 +891,7 @@ CONFIG_SERIAL_SUNHV=y
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_JSM is not set
+# CONFIG_SERIAL_TIMBERDALE is not set
 # CONFIG_SERIAL_GRLIB_GAISLER_APBUART is not set
 CONFIG_UNIX98_PTYS=y
 # CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
@@ -935,6 +939,7 @@ CONFIG_I2C_ALGOBIT=y
 #
 # CONFIG_I2C_OCORES is not set
 # CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
 
 #
 # External I2C/SMBus adapter drivers
@@ -948,15 +953,9 @@ CONFIG_I2C_ALGOBIT=y
 #
 # CONFIG_I2C_PCA_PLATFORM is not set
 # CONFIG_I2C_STUB is not set
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
 # CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
 # CONFIG_SPI is not set
 
 #
@@ -982,10 +981,11 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_ADM1029 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ADM9240 is not set
+# CONFIG_SENSORS_ADT7411 is not set
 # CONFIG_SENSORS_ADT7462 is not set
 # CONFIG_SENSORS_ADT7470 is not set
-# CONFIG_SENSORS_ADT7473 is not set
 # CONFIG_SENSORS_ADT7475 is not set
+# CONFIG_SENSORS_ASC7621 is not set
 # CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_I5K_AMB is not set
@@ -1052,18 +1052,21 @@ CONFIG_SSB_POSSIBLE=y
 # Multifunction device drivers
 #
 # CONFIG_MFD_CORE is not set
+# CONFIG_MFD_88PM860X is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
 # CONFIG_TWL4030_CORE is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_PMIC_DA903X is not set
 # CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_MAX8925 is not set
 # CONFIG_MFD_WM8400 is not set
 # CONFIG_MFD_WM831X is not set
 # CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
 # CONFIG_MFD_PCF50633 is not set
 # CONFIG_AB3100_CORE is not set
-# CONFIG_MFD_88PM8607 is not set
+# CONFIG_LPC_SCH is not set
 # CONFIG_REGULATOR is not set
 # CONFIG_MEDIA_SUPPORT is not set
 
@@ -1113,6 +1116,7 @@ CONFIG_FB_FFB=y
 # CONFIG_FB_LEO is not set
 CONFIG_FB_XVR500=y
 CONFIG_FB_XVR2500=y
+CONFIG_FB_XVR1000=y
 # CONFIG_FB_S1D13XXX is not set
 # CONFIG_FB_NVIDIA is not set
 # CONFIG_FB_RIVA is not set
@@ -1430,7 +1434,6 @@ CONFIG_USB_STORAGE=m
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
-# CONFIG_USB_BERRY_CHARGE is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
@@ -1443,7 +1446,6 @@ CONFIG_USB_STORAGE=m
 # CONFIG_USB_IOWARRIOR is not set
 # CONFIG_USB_TEST is not set
 # CONFIG_USB_ISIGHTFW is not set
-# CONFIG_USB_VST is not set
 # CONFIG_USB_GADGET is not set
 
 #
@@ -1610,6 +1612,7 @@ CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_LOGFS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
@@ -1624,6 +1627,7 @@ CONFIG_NETWORK_FILESYSTEMS=y
 # CONFIG_NFS_FS is not set
 # CONFIG_NFSD is not set
 # CONFIG_SMB_FS is not set
+# CONFIG_CEPH_FS is not set
 # CONFIG_CIFS is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
index 39327d6a57eb3b60b50d5bd47473c9f14223581c..a232e9e1f4e515d19e8f089872a797c746241777 100644 (file)
@@ -53,8 +53,8 @@ struct stat {
        ino_t           st_ino;
        mode_t          st_mode;
        short           st_nlink;
-       uid16_t         st_uid;
-       gid16_t         st_gid;
+       unsigned short  st_uid;
+       unsigned short  st_gid;
        unsigned short  st_rdev;
        off_t           st_size;
        time_t          st_atime;
index 4589ca33220ff6463dbd7191259d01debb5fb13f..415c86d5a8dac990c011309bde3d89afe9a307c7 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/of_device.h>
index 7430ed080b23183b4dc781240846b3f1f718b14e..8de64c8126bcc3f7d19abc7d4c9f49e2eb485471 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/cpumask.h>
index 314dd0c9fc5b24e5c8064f92520cc37e7cdd3c47..92090cc9e82937a2daf6730dca89668ce9e04869 100644 (file)
@@ -46,6 +46,81 @@ stack_trace_flush:
         nop
        .size           stack_trace_flush,.-stack_trace_flush
 
+#ifdef CONFIG_PERF_EVENTS
+       .globl          perf_arch_fetch_caller_regs
+       .type           perf_arch_fetch_caller_regs,#function
+perf_arch_fetch_caller_regs:
+       /* We always read the %pstate into %o5 since we will use
+        * that to construct a fake %tstate to store into the regs.
+        */
+       rdpr            %pstate, %o5
+       brz,pn          %o2, 50f
+        mov            %o2, %g7
+
+       /* Turn off interrupts while we walk around the register
+        * window by hand.
+        */
+       wrpr            %o5, PSTATE_IE, %pstate
+
+       /* The %canrestore tells us how many register windows are
+        * still live in the chip above us, past that we have to
+        * walk the frame as saved on the stack.   We stash away
+        * the %cwp in %g1 so we can return back to the original
+        * register window.
+        */
+       rdpr            %cwp, %g1
+       rdpr            %canrestore, %g2
+       sub             %g1, 1, %g3
+
+       /* We have the skip count in %g7, if it hits zero then
+        * %fp/%i7 are the registers we need.  Otherwise if our
+        * %canrestore count maintained in %g2 hits zero we have
+        * to start traversing the stack.
+        */
+10:    brz,pn          %g2, 4f
+        sub            %g2, 1, %g2
+       wrpr            %g3, %cwp
+       subcc           %g7, 1, %g7
+       bne,pt          %xcc, 10b
+        sub            %g3, 1, %g3
+
+       /* We found the values we need in the cpu's register
+        * windows.
+        */
+       mov             %fp, %g3
+       ba,pt           %xcc, 3f
+        mov            %i7, %g2
+
+50:    mov             %fp, %g3
+       ba,pt           %xcc, 2f
+        mov            %i7, %g2
+
+       /* We hit the end of the valid register windows in the
+        * cpu, start traversing the stack frame.
+        */
+4:     mov             %fp, %g3
+
+20:    ldx             [%g3 + STACK_BIAS + RW_V9_I7], %g2
+       subcc           %g7, 1, %g7
+       bne,pn          %xcc, 20b
+        ldx            [%g3 + STACK_BIAS + RW_V9_I6], %g3
+
+       /* Restore the current register window position and
+        * re-enable interrupts.
+        */
+3:     wrpr            %g1, %cwp
+       wrpr            %o5, %pstate
+
+2:     stx             %g3, [%o0 + PT_V9_FP]
+       sllx            %o5, 8, %o5
+       stx             %o5, [%o0 + PT_V9_TSTATE]
+       stx             %g2, [%o0 + PT_V9_TPC]
+       add             %g2, 4, %g2
+       retl
+        stx            %g2, [%o0 + PT_V9_TNPC]
+       .size           perf_arch_fetch_caller_regs,.-perf_arch_fetch_caller_regs
+#endif /* CONFIG_PERF_EVENTS */
+
 #ifdef CONFIG_SMP
        .globl          hard_smp_processor_id
        .type           hard_smp_processor_id,#function
index 1d272c3b574084d7c8eb52a45dae241315b10261..7c60afb835b0426571654fb5aa719e84e6cc9bec 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 
 #include <asm/hypervisor.h>
 #include <asm/oplib.h>
index 8414549c1834e728e114ef4bdd9546de686b1a3e..47977a77f6c64ae1bb7dd5a16de27f14b3e59807 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
index 6716584e48ab4c052a3d7cf941a1781949f885e6..a39d1ba5a1190cf4c3b23479481734ed0e465e48 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/kprobes.h>
 #include <linux/module.h>
 #include <linux/kdebug.h>
+#include <linux/slab.h>
 #include <asm/signal.h>
 #include <asm/cacheflush.h>
 #include <asm/uaccess.h>
index 00d034ea2164d63148d7b0ff04538420b163c513..3ae36f36e7581f107c59af05bb886c57f8032636 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/jiffies.h>
 #include <linux/timer.h>
index 0409d62d8ca2c2b477248c69b66d1308b566b2c7..6a7b4dbc8e09b6c11f8853002ab89130b1547b9e 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/mutex.h>
-#include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/interrupt.h>
index 85787577f683e2c818443c1934899cfd3941cd5d..e1656fc41ccbc275dece71ed001a2bead7005ac8 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/profile.h>
 #include <linux/pm.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
index 0ee642f63234a19ce1d32b5d9feab15e9309cc5a..f848aadf54dc1c2c1feb537752fdf3410efbe9d8 100644 (file)
@@ -9,9 +9,9 @@
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 
 #include <asm/processor.h>
index cb8eb799bb6cfb01c4794eb4a7ec065b14d1ad8d..0247e68210b3417eba430ae12ef98facbf0ab76d 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/irq.h>
 #include <linux/of_device.h>
index e1b0541feb19d07475a732c152c1f8c35b873a23..e0ef847219c3b0f11b3330d15b57a4858549567d 100644 (file)
@@ -4,6 +4,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/irq.h>
 
 #include "pci_impl.h"
index 68cb9b42088f2e36a6dc28fca5ce64e6619e7d74..e2771939341d538111417aa518d5c2c9cf249b25 100644 (file)
@@ -1337,7 +1337,7 @@ static void perf_callchain_user_32(struct pt_regs *regs,
        callchain_store(entry, PERF_CONTEXT_USER);
        callchain_store(entry, regs->tpc);
 
-       ufp = regs->u_regs[UREG_I6];
+       ufp = regs->u_regs[UREG_I6] & 0xffffffffUL;
        do {
                struct sparc_stackf32 *usf, sf;
                unsigned long pc;
index c49865b30719d2e8113313591834f34d4d5fa063..40e29fc8a4d62bff77080a791ebf0a8a280efaae 100644 (file)
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/smp.h>
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <asm/auxio.h>
 #include <asm/oplib.h>
index 7e3dfd9bb97ed677715adc641dc530e2c0d63c9b..e608f397e11f68db6b980d0d9f97ca55416c41dd 100644 (file)
@@ -65,6 +65,7 @@ static int genregs32_get(struct task_struct *target,
                        *k++ = regs->u_regs[pos++];
 
                reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                for (; count > 0 && pos < 32; count--) {
                        if (get_user(*k++, &reg_window[pos++]))
                                return -EFAULT;
@@ -76,6 +77,7 @@ static int genregs32_get(struct task_struct *target,
                }
 
                reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                for (; count > 0 && pos < 32; count--) {
                        if (get_user(reg, &reg_window[pos++]) ||
                            put_user(reg, u++))
@@ -141,6 +143,7 @@ static int genregs32_set(struct task_struct *target,
                        regs->u_regs[pos++] = *k++;
 
                reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                for (; count > 0 && pos < 32; count--) {
                        if (put_user(*k++, &reg_window[pos++]))
                                return -EFAULT;
@@ -153,6 +156,7 @@ static int genregs32_set(struct task_struct *target,
                }
 
                reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                for (; count > 0 && pos < 32; count--) {
                        if (get_user(reg, u++) ||
                            put_user(reg, &reg_window[pos++]))
index 2f6524d1a817a3906f99109edfb953217bb16c1a..aa90da08bf61c84d54876e6a0e7962ef87b374c7 100644 (file)
@@ -492,6 +492,7 @@ static int genregs32_get(struct task_struct *target,
                        *k++ = regs->u_regs[pos++];
 
                reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                if (target == current) {
                        for (; count > 0 && pos < 32; count--) {
                                if (get_user(*k++, &reg_window[pos++]))
@@ -516,6 +517,7 @@ static int genregs32_get(struct task_struct *target,
                }
 
                reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                if (target == current) {
                        for (; count > 0 && pos < 32; count--) {
                                if (get_user(reg, &reg_window[pos++]) ||
@@ -599,6 +601,7 @@ static int genregs32_set(struct task_struct *target,
                        regs->u_regs[pos++] = *k++;
 
                reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                if (target == current) {
                        for (; count > 0 && pos < 32; count--) {
                                if (put_user(*k++, &reg_window[pos++]))
@@ -625,6 +628,7 @@ static int genregs32_set(struct task_struct *target,
                }
 
                reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
+               reg_window -= 16;
                if (target == current) {
                        for (; count > 0 && pos < 32; count--) {
                                if (get_user(reg, u++) ||
index a2a79e76344f78c606fed829ce18c4c77775b3ac..5f72de67588b876989ec96243b03e633442ad59c 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <asm/smp.h>
 #include <linux/user.h>
 #include <linux/screen_info.h>
index eb14844a0021bbccb76d6981c3f9cabb9ac75c35..4c53345281093713d8492233e198fd5c07fcbdfe 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/bootmem.h>
 #include <linux/vmalloc.h>
 #include <linux/cpu.h>
+#include <linux/slab.h>
 
 #include <asm/head.h>
 #include <asm/ptrace.h>
index bc3adbf79c6a8006ca61053f905cde8474cec9fd..892fb884910a52619582d36a0426211db186d4d1 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index 301892e2d7186fd41d32da167ff6218a5e5ce9d2..7f3b97ff62c17394604d8134cafa5b5211e24256 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/ptrace.h>
 #include <linux/smp.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/of.h>
index daded3b9639861b4b0ee0f63c5c54cd9cc447d72..c0ca87553e1c22e34c7aa11669795e0e74c34965 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
-#include <linux/slab.h>
 #include <linux/uio.h>
 #include <linux/nfs_fs.h>
 #include <linux/quota.h>
@@ -44,6 +43,7 @@
 #include <linux/compat.h>
 #include <linux/vfs.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>
 #include <asm/uaccess.h>
index ca39c606fe8e41d90506c574f5ed23c8f89d147d..1eb8b00aed75f293b5df18076e1fc3b81b2cf9c7 100644 (file)
@@ -107,12 +107,12 @@ static unsigned long run_on_cpu(unsigned long cpu,
        unsigned long ret;
 
        /* should return -EINVAL to userspace */
-       if (set_cpus_allowed(current, cpumask_of_cpu(cpu)))
+       if (set_cpus_allowed_ptr(current, cpumask_of(cpu)))
                return 0;
 
        ret = func(arg);
 
-       set_cpus_allowed(current, old_affinity);
+       set_cpus_allowed_ptr(current, &old_affinity);
 
        return ret;
 }
index bdc05a21908b98afab4189b7307a72a6b81a985f..837dfc2390d6ff2071afc8335f4f7a47d7829d22 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/kdebug.h>
+#include <linux/gfp.h>
 
 #include <asm/smp.h>
 #include <asm/delay.h>
index 791c15138f3a4abf3cb368e12041fcd7f304842c..8f982b76c71259e7a28f1f1551629eb397023a31 100644 (file)
@@ -238,12 +238,12 @@ static unsigned int us2e_freq_get(unsigned int cpu)
                return 0;
 
        cpus_allowed = current->cpus_allowed;
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
        clock_tick = sparc64_get_clock_tick(cpu) / 1000;
        estar = read_hbreg(HBIRD_ESTAR_MODE_ADDR);
 
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 
        return clock_tick / estar_to_divisor(estar);
 }
@@ -259,7 +259,7 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
                return;
 
        cpus_allowed = current->cpus_allowed;
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
        new_freq = clock_tick = sparc64_get_clock_tick(cpu) / 1000;
        new_bits = index_to_estar_mode(index);
@@ -281,7 +281,7 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index)
 
        cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 }
 
 static int us2e_freq_target(struct cpufreq_policy *policy,
index 365b6464e2ce20037e27af6023aa330ba6380612..f35d1e794548eb8541bee5198f4a353f346d1e3e 100644 (file)
@@ -86,12 +86,12 @@ static unsigned int us3_freq_get(unsigned int cpu)
                return 0;
 
        cpus_allowed = current->cpus_allowed;
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
        reg = read_safari_cfg();
        ret = get_current_freq(cpu, reg);
 
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 
        return ret;
 }
@@ -106,7 +106,7 @@ static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index)
                return;
 
        cpus_allowed = current->cpus_allowed;
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       set_cpus_allowed_ptr(current, cpumask_of(cpu));
 
        new_freq = sparc64_get_clock_tick(cpu) / 1000;
        switch (index) {
@@ -140,7 +140,7 @@ static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index)
 
        cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
 
-       set_cpus_allowed(current, cpus_allowed);
+       set_cpus_allowed_ptr(current, &cpus_allowed);
 }
 
 static int us3_freq_target(struct cpufreq_policy *policy,
index c28c71449a6c72652706e49cf1897c639e2f441b..3cb1def9806c307df84a8da15f33dbc484255c51 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/irq.h>
 #include <linux/init.h>
 
index f27d10369e0cdea561c78c7e3be4e0b326ffd8be..5fdddf134caa6992afb6c4fdf2056a93e7ffdb2d 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
-#include <linux/slab.h>
 #include <linux/sysctl.h>
 
 #include <asm/mman.h>
index dc7c3b17a15f2badfbdc03dc3a1c2cac77ed0818..6d0e02c4fe09cdc318d6da849668495546d21897 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/bootmem.h>
 #include <linux/pagemap.h>
 #include <linux/poison.h>
+#include <linux/gfp.h>
 
 #include <asm/sections.h>
 #include <asm/system.h>
index 9245a822a2f17cf8a20fc9edd12f217156f973ac..b2831dc3c121c135a0ed41fe09aaf975f1aa678f 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/bootmem.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
-#include <linux/slab.h>
 #include <linux/initrd.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
@@ -26,6 +25,7 @@
 #include <linux/percpu.h>
 #include <linux/lmb.h>
 #include <linux/mmzone.h>
+#include <linux/gfp.h>
 
 #include <asm/head.h>
 #include <asm/system.h>
@@ -2117,7 +2117,7 @@ int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node)
                               "node=%d entry=%lu/%lu\n", start, block, nr,
                               node,
                               addr >> VMEMMAP_CHUNK_SHIFT,
-                              VMEMMAP_SIZE >> VMEMMAP_CHUNK_SHIFT);
+                              VMEMMAP_SIZE);
                }
        }
        return 0;
index df49b200ca4c12317077c44712d0f89f107ff872..f5f75a58e0b3cc7077f78a610f6cc6107c75bcb8 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <linux/kernel.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
@@ -20,6 +19,7 @@
 #include <linux/seq_file.h>
 #include <linux/kdebug.h>
 #include <linux/log2.h>
+#include <linux/gfp.h>
 
 #include <asm/bitext.h>
 #include <asm/page.h>
index 18652534b91a592a2dfb3c97cce676323fe471f2..cf38846753dd55c3ece5d7be244b23d9ca3fbda3 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/fs.h>
index 36a0813f9517b39ec9b7b86c17a03233d442483e..101d7c82870be8a704a2ab84f07d97a2d890f37a 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/kernel.h>
 #include <linux/preempt.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/page.h>
 #include <asm/tlbflush.h>
index a74245ae3a84db98443460ed794ec70ce15eb15a..f05372694233a55734500b8aa3578a0338f00d43 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include "init.h"
 #include "irq_kern.h"
index 4ebc8a34738f7d43a6020c8a05e604d8cad7d8e5..a11573be0961fd7b233a02ff40421aa3a53940c7 100644 (file)
@@ -7,6 +7,7 @@
 #include "linux/interrupt.h"
 #include "linux/list.h"
 #include "linux/mutex.h"
+#include "linux/slab.h"
 #include "linux/workqueue.h"
 #include "asm/atomic.h"
 #include "init.h"
index c1ff6903b622126789945164c0a33101d0a7943a..da992a3ad6b78254ee2cda6346dd10fd0e86ec0b 100644 (file)
@@ -31,6 +31,7 @@
 #include "linux/ctype.h"
 #include "linux/capability.h"
 #include "linux/mm.h"
+#include "linux/slab.h"
 #include "linux/vmalloc.h"
 #include "linux/blkpg.h"
 #include "linux/genhd.h"
index fda30d21fb90628cec430c151f9e3993df74fc5c..97974c1bdd126b8c92ab5023aa3806e3115be4dc 100644 (file)
@@ -8,6 +8,7 @@
 #include "linux/smp_lock.h"
 #include "linux/ptrace.h"
 #include "linux/sched.h"
+#include "linux/slab.h"
 #include "asm/current.h"
 #include "asm/processor.h"
 #include "asm/uaccess.h"
index 89474ba0741e616cdfc2598553198ba99cf86bcb..a3f0b04d7101ccb1fea64254339328fbec12412f 100644 (file)
@@ -12,6 +12,7 @@
 #include "linux/module.h"
 #include "linux/sched.h"
 #include "linux/seq_file.h"
+#include "linux/slab.h"
 #include "as-layout.h"
 #include "kern_util.h"
 #include "os.h"
index a5d5e70cf6f55bb0db78971b1bce19cab31abeec..8137ccc9635b5c98ae902fb8f6c5884faf67b8fe 100644 (file)
@@ -5,10 +5,10 @@
 
 #include <linux/stddef.h>
 #include <linux/bootmem.h>
-#include <linux/gfp.h>
 #include <linux/highmem.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
+#include <linux/slab.h>
 #include <asm/fixmap.h>
 #include <asm/page.h>
 #include "as-layout.h"
index 2f910a1b745452fdcccc1c167cdd3671d2275023..fab4371184f6e49affeba13f3fc0965ec7f29727 100644 (file)
@@ -7,13 +7,13 @@
 #include <linux/stddef.h>
 #include <linux/err.h>
 #include <linux/hardirq.h>
-#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/personality.h>
 #include <linux/proc_fs.h>
 #include <linux/ptrace.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/tick.h>
index 00197d3d21ec96daba38fe57b74db08183fc1310..869bec9f2516d8ae46d6deb4c96d73b1c64e9817 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include "linux/sched.h"
+#include "linux/slab.h"
 #include "kern_util.h"
 #include "os.h"
 #include "skas.h"
index 8bfd1e90581225eb0e19fada92611399d2a1d4c8..3d099f97478595be72b5cd15b5eebb9877ea32c6 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "linux/mm.h"
 #include "linux/sched.h"
+#include "linux/slab.h"
 #include "asm/pgalloc.h"
 #include "asm/pgtable.h"
 #include "as-layout.h"
index b6b1096152aac3f2e98b2da44aa3ea46a02cf4ba..06d6ccf0e4449e84a298412ee576c352276900a5 100644 (file)
@@ -8,6 +8,7 @@
 #include <errno.h>
 #include <sched.h>
 #include <linux/limits.h>
+#include <linux/slab.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include "kern_constants.h"
index a4846a84a7be2ddae740675dfcec28e5a6a88328..3f2bf208d884ec6973d550f84a9f5d0625ae2e5f 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/mm.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/unistd.h>
 #include "os.h"
 #include "proc_mm.h"
index daef6cd2b45d6bae0c63228002478c01251adaf7..1a8f8649c035b2e6fe5b30b0032382760cc9e495 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/i387.h>
 
 struct crypto_fpu_ctx {
index 280c019cfad8c8475741178daed7406214a8308c..0350311906ae731ca91e9ecedbc3e7acbaa668d0 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
-#include <linux/slab.h>
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
index 74c35431b7d830ebb4ca7979945cdbf19714f8ff..626be156d88def72a0fa7bf87f5e3f822c9c63bd 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/ptrace.h>
 #include <linux/highuid.h>
 #include <linux/sysctl.h>
+#include <linux/slab.h>
 #include <asm/mman.h>
 #include <asm/types.h>
 #include <asm/uaccess.h>
index 635f03bb499528ff7905b3b96f112a910d4c57e3..d07b44f7d1dc014b3d1cb77e49138ef5f97f5d24 100644 (file)
@@ -82,6 +82,9 @@ enum fixed_addresses {
 #endif
        FIX_DBGP_BASE,
        FIX_EARLYCON_MEM_BASE,
+#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
+       FIX_OHCI1394_BASE,
+#endif
 #ifdef CONFIG_X86_LOCAL_APIC
        FIX_APIC_BASE,  /* local (CPU) APIC) -- required for SMP or not */
 #endif
@@ -132,9 +135,6 @@ enum fixed_addresses {
           (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1))
         : __end_of_permanent_fixed_addresses,
        FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
-#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
-       FIX_OHCI1394_BASE,
-#endif
 #ifdef CONFIG_X86_32
        FIX_WP_TEST,
 #endif
index a929c9ede33d55db556e5fc603facb61b39d5d68..46c0fe05f230112b5aa5e176d4292e56526f8279 100644 (file)
@@ -133,6 +133,7 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void);
 
 typedef int vector_irq_t[NR_VECTORS];
 DECLARE_PER_CPU(vector_irq_t, vector_irq);
+extern void setup_vector_irq(int cpu);
 
 #ifdef CONFIG_X86_IO_APIC
 extern void lock_vector_lock(void);
index 1cd58cdbc03f2e97dee6983b5a8ea2ebef7d0061..4604e6a54d36eb2fe13fdc88b432d6c018252087 100644 (file)
 #define MSR_AMD64_PATCH_LEVEL          0x0000008b
 #define MSR_AMD64_NB_CFG               0xc001001f
 #define MSR_AMD64_PATCH_LOADER         0xc0010020
+#define MSR_AMD64_OSVW_ID_LENGTH       0xc0010140
+#define MSR_AMD64_OSVW_STATUS          0xc0010141
 #define MSR_AMD64_IBSFETCHCTL          0xc0011030
 #define MSR_AMD64_IBSFETCHLINAD                0xc0011031
 #define MSR_AMD64_IBSFETCHPHYSAD       0xc0011032
index 47339a1ac7b6607306a1157ad984ba4b86f14108..2984a25ff383d5db7a3dffac2d38dca3f9628d69 100644 (file)
@@ -19,7 +19,6 @@
 #include <asm/paravirt.h>
 
 #include <linux/bitops.h>
-#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 
index 0061ea2630615efe9e1f3af3fd8d851821c9f3b0..cd40aba6aa9563cf5bdb9282fa076ef474d4e163 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/bootmem.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
index 3a4bf35c179b7e54b8d1902d22d734cdc4cc4b89..1a160d5d44d0bd0f47b0b88b9e6a98f4b9b7f2b3 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/vmalloc.h>
 #include <linux/memory.h>
 #include <linux/stop_machine.h>
+#include <linux/slab.h>
 #include <asm/alternative.h>
 #include <asm/sections.h>
 #include <asm/pgtable.h>
index adb0ba025702938b37586c9a8c2999cf68b135dd..f3dadb571d9b6583f10e83d254089521f453c2a8 100644 (file)
@@ -18,8 +18,8 @@
  */
 
 #include <linux/pci.h>
-#include <linux/gfp.h>
 #include <linux/bitmap.h>
+#include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <linux/scatterlist.h>
 #include <linux/dma-mapping.h>
index 9dc91b4314703ff6157222bfbecac53329c34372..42f5350b908f292b7a6a555954cd0b646fe553ca 100644 (file)
@@ -19,8 +19,8 @@
 
 #include <linux/pci.h>
 #include <linux/acpi.h>
-#include <linux/gfp.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/sysdev.h>
 #include <linux/interrupt.h>
 #include <linux/msi.h>
index 4b7099526d2c1c8c6c496f4ce0f8e028fbac9eab..ff469e47005921779f3c589ec3e77e401a4346a3 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/sysdev.h>
+#include <linux/slab.h>
 #include <linux/pm.h>
 #include <linux/pci.h>
 #include <linux/sfi.h>
index dd2b5f26464364611bf603f10689289630bdd00e..03ba1b895f5ec69cdadde8509e6bf887b046ef21 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/errno.h>
 #include <linux/acpi.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/nmi.h>
 #include <linux/smp.h>
 #include <linux/io.h>
index e4e0ddcb1546bde04f0d01675756622b9d2434bd..127b8718abfb0abd389334865f0bf3159b8e0fa3 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/freezer.h>
 #include <linux/kthread.h>
 #include <linux/jiffies.h>     /* time_after() */
+#include <linux/slab.h>
 #ifdef CONFIG_ACPI
 #include <acpi/acpi_bus.h>
 #endif
@@ -1268,6 +1269,14 @@ void __setup_vector_irq(int cpu)
        /* Mark the inuse vectors */
        for_each_irq_desc(irq, desc) {
                cfg = desc->chip_data;
+
+               /*
+                * If it is a legacy IRQ handled by the legacy PIC, this cpu
+                * will be part of the irq_cfg's domain.
+                */
+               if (irq < legacy_pic->nr_legacy_irqs && !IO_APIC_IRQ(irq))
+                       cpumask_set_cpu(cpu, cfg->domain);
+
                if (!cpumask_test_cpu(cpu, cfg->domain))
                        continue;
                vector = cfg->vector;
index 8aa65adbd25d75340fe2d73434528207921f4a83..1edaf15c0b8eef05b36653a0ed9087a9b3717f9e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/sysdev.h>
 #include <linux/sysctl.h>
 #include <linux/percpu.h>
index 49dbeaef2a27b03f092b2eb267d26b6028b9c382..c085d52dbaf2f1305ea35c16e0877fb11abcb7e7 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/ctype.h>
 #include <linux/sched.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/cpu.h>
 #include <linux/init.h>
 #include <linux/io.h>
index 30f25a75fe2876ef93605181f81c386c02953bfb..5de7f4c5697136e180e4a24e153bde77c7112b8c 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/acpi.h>
 #include <asm/io.h>
index 1b1920fa7c8085934cbd846e9329cc538c25be4b..459168083b770ee14cd5b314c4a735187edd2c01 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/cpufreq.h>
 #include <linux/compiler.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include <trace/events/power.h>
 
 #include <linux/acpi.h>
index 006b278b0d5d973f794e3c0f17a0e9f925369f52..c587db472a75a21eeabb0c52a1df3b7f48b549f4 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/cpufreq.h>
 
index ac27ec2264d50afd3601ae7a5a10caf93bb94858..16e3483be9e3c13db575daddf9d1a18bc84ab1ec 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/cpufreq.h>
 #include <linux/pci.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include <asm/processor-cyrix.h>
 
index da5f70fcb766d1f4a257466e5710c7da62af6d5e..e7b559d74c5242c0ea0c490e21c6e298ff9dd557 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/cpufreq.h>
 #include <linux/timex.h>
 
index 869615193720c1b126dc5069d37cc9620f1049b3..7b8a8ba67b0779911991ba8fbb1cbab28b6fa749 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/cpufreq.h>
-#include <linux/slab.h>
 #include <linux/cpumask.h>
 #include <linux/timex.h>
 
index ff36d2979a909ddee0748e79f30608206e2e5c9b..ce7cde713e7174e8293b552b332f968946a46904 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/cpufreq.h>
 #include <linux/compiler.h>
+#include <linux/slab.h>
 
 #include <linux/acpi.h>
 #include <linux/io.h>
index cb01dac267d3de14486db1bf3ed081be5999a45e..b3379d6a5c57214cadb73f8f6dffc37b83ccb6e9 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/timex.h>
 #include <linux/io.h>
 
index 8d672ef162cef76306d7e978556f5910e7da4184..9b1ff37de46ae6a729f48d2d94ad30548806884d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/sched.h>       /* current */
 #include <linux/delay.h>
 #include <linux/compiler.h>
+#include <linux/gfp.h>
 
 #include <asm/msr.h>
 #include <asm/processor.h>
index 2ce8e0b5cc541b38052f4c2075fbd021f745ba06..561758e951802356aa88bb78d4b10c5da2c4e6c7 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include "speedstep-lib.h"
index ad0083abfa23f7fcdc30c4a5e8d0ada72214db92..a94ec6be69fa5c798381d41c1c4cb10a0029d385 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
-#include <linux/slab.h>
 
 #include <asm/msr.h>
 #include <asm/tsc.h>
index 04d73c114e4944d4bcceaa577c82b8f9545a9a53..8abd869baabfb7eccbb9c5888a20ccd8b29e91bd 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <asm/ist.h>
index 73734baa50f2200e6925104fbc9f9c2f057ea9a1..e7dbde7bfedb6a114536ff4448188ab76ebbd6bd 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kdebug.h>
 #include <linux/cpu.h>
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include <asm/mce.h>
 #include <asm/apic.h>
 
index 3ab9c886b61338e80f9a4f4fbc66814fc177f58b..8a6f0afa767ec804c0a1ffa2f6bfee6e87168cb1 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/sysfs.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/poll.h>
index cda932ca3ade1c9eaff1e4847349110057943814..224392d8fe8c095390439a10ea45af2e21bc0930 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/cpu.h>
 #include <linux/smp.h>
index d15df6e49bf02936be5f51854040efbf7a7e89cf..62b48e40920a2fe2445bc68ba562fcc2e4d8c987 100644 (file)
@@ -5,6 +5,7 @@
  * Author: Andi Kleen
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
index 9aa5dc76ff4a156304a3c864776c3665628004e4..fd31a441c61cbecf51e554d2292a2600b7a70295 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/mm.h>
 
index e006e56f699c24d1fe193a307bf799fda3801c6d..79289632cb270cb4aa02c1e5cc58d4c3de5b53b1 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #define LINE_SIZE 80
index 60398a0d947c855fbc25687694bb6a2b41100a3d..db5bdc8addf82f1df406488025a5b4877ed53419 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kdebug.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/cpu.h>
 #include <linux/bitops.h>
@@ -28,6 +29,7 @@
 #include <asm/apic.h>
 #include <asm/stacktrace.h>
 #include <asm/nmi.h>
+#include <asm/compat.h>
 
 static u64 perf_event_mask __read_mostly;
 
@@ -158,7 +160,7 @@ struct x86_pmu {
                                                 struct perf_event *event);
        struct event_constraint *event_constraints;
 
-       void            (*cpu_prepare)(int cpu);
+       int             (*cpu_prepare)(int cpu);
        void            (*cpu_starting)(int cpu);
        void            (*cpu_dying)(int cpu);
        void            (*cpu_dead)(int cpu);
@@ -1333,11 +1335,12 @@ static int __cpuinit
 x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
+       int ret = NOTIFY_OK;
 
        switch (action & ~CPU_TASKS_FROZEN) {
        case CPU_UP_PREPARE:
                if (x86_pmu.cpu_prepare)
-                       x86_pmu.cpu_prepare(cpu);
+                       ret = x86_pmu.cpu_prepare(cpu);
                break;
 
        case CPU_STARTING:
@@ -1350,6 +1353,7 @@ x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
                        x86_pmu.cpu_dying(cpu);
                break;
 
+       case CPU_UP_CANCELED:
        case CPU_DEAD:
                if (x86_pmu.cpu_dead)
                        x86_pmu.cpu_dead(cpu);
@@ -1359,7 +1363,7 @@ x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
                break;
        }
 
-       return NOTIFY_OK;
+       return ret;
 }
 
 static void __init pmu_check_apic(void)
@@ -1628,14 +1632,42 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
        return len;
 }
 
-static int copy_stack_frame(const void __user *fp, struct stack_frame *frame)
+#ifdef CONFIG_COMPAT
+static inline int
+perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
 {
-       unsigned long bytes;
+       /* 32-bit process in 64-bit kernel. */
+       struct stack_frame_ia32 frame;
+       const void __user *fp;
 
-       bytes = copy_from_user_nmi(frame, fp, sizeof(*frame));
+       if (!test_thread_flag(TIF_IA32))
+               return 0;
+
+       fp = compat_ptr(regs->bp);
+       while (entry->nr < PERF_MAX_STACK_DEPTH) {
+               unsigned long bytes;
+               frame.next_frame     = 0;
+               frame.return_address = 0;
+
+               bytes = copy_from_user_nmi(&frame, fp, sizeof(frame));
+               if (bytes != sizeof(frame))
+                       break;
+
+               if (fp < compat_ptr(regs->sp))
+                       break;
 
-       return bytes == sizeof(*frame);
+               callchain_store(entry, frame.return_address);
+               fp = compat_ptr(frame.next_frame);
+       }
+       return 1;
+}
+#else
+static inline int
+perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
+{
+    return 0;
 }
+#endif
 
 static void
 perf_callchain_user(struct pt_regs *regs, struct perf_callchain_entry *entry)
@@ -1651,11 +1683,16 @@ perf_callchain_user(struct pt_regs *regs, struct perf_callchain_entry *entry)
        callchain_store(entry, PERF_CONTEXT_USER);
        callchain_store(entry, regs->ip);
 
+       if (perf_callchain_user32(regs, entry))
+               return;
+
        while (entry->nr < PERF_MAX_STACK_DEPTH) {
+               unsigned long bytes;
                frame.next_frame             = NULL;
                frame.return_address = 0;
 
-               if (!copy_stack_frame(fp, &frame))
+               bytes = copy_from_user_nmi(&frame, fp, sizeof(frame));
+               if (bytes != sizeof(frame))
                        break;
 
                if ((unsigned long)fp < regs->sp)
@@ -1702,7 +1739,6 @@ struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
        return entry;
 }
 
-#ifdef CONFIG_EVENT_TRACING
 void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip)
 {
        regs->ip = ip;
@@ -1714,4 +1750,3 @@ void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int ski
        regs->cs = __KERNEL_CS;
        local_save_flags(regs->flags);
 }
-#endif
index 573458f1caf23c91ab39930fc0613cf78d27d55f..db6f7d4056e110873cbef10b92841152458871a1 100644 (file)
@@ -137,6 +137,13 @@ static inline int amd_is_nb_event(struct hw_perf_event *hwc)
        return (hwc->config & 0xe0) == 0xe0;
 }
 
+static inline int amd_has_nb(struct cpu_hw_events *cpuc)
+{
+       struct amd_nb *nb = cpuc->amd_nb;
+
+       return nb && nb->nb_id != -1;
+}
+
 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
                                      struct perf_event *event)
 {
@@ -147,7 +154,7 @@ static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
        /*
         * only care about NB events
         */
-       if (!(nb && amd_is_nb_event(hwc)))
+       if (!(amd_has_nb(cpuc) && amd_is_nb_event(hwc)))
                return;
 
        /*
@@ -214,7 +221,7 @@ amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
        /*
         * if not NB event or no NB, then no constraints
         */
-       if (!(nb && amd_is_nb_event(hwc)))
+       if (!(amd_has_nb(cpuc) && amd_is_nb_event(hwc)))
                return &unconstrained;
 
        /*
@@ -293,51 +300,55 @@ static struct amd_nb *amd_alloc_nb(int cpu, int nb_id)
        return nb;
 }
 
-static void amd_pmu_cpu_online(int cpu)
+static int amd_pmu_cpu_prepare(int cpu)
+{
+       struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
+
+       WARN_ON_ONCE(cpuc->amd_nb);
+
+       if (boot_cpu_data.x86_max_cores < 2)
+               return NOTIFY_OK;
+
+       cpuc->amd_nb = amd_alloc_nb(cpu, -1);
+       if (!cpuc->amd_nb)
+               return NOTIFY_BAD;
+
+       return NOTIFY_OK;
+}
+
+static void amd_pmu_cpu_starting(int cpu)
 {
-       struct cpu_hw_events *cpu1, *cpu2;
-       struct amd_nb *nb = NULL;
+       struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
+       struct amd_nb *nb;
        int i, nb_id;
 
        if (boot_cpu_data.x86_max_cores < 2)
                return;
 
-       /*
-        * function may be called too early in the
-        * boot process, in which case nb_id is bogus
-        */
        nb_id = amd_get_nb_id(cpu);
-       if (nb_id == BAD_APICID)
-               return;
-
-       cpu1 = &per_cpu(cpu_hw_events, cpu);
-       cpu1->amd_nb = NULL;
+       WARN_ON_ONCE(nb_id == BAD_APICID);
 
        raw_spin_lock(&amd_nb_lock);
 
        for_each_online_cpu(i) {
-               cpu2 = &per_cpu(cpu_hw_events, i);
-               nb = cpu2->amd_nb;
-               if (!nb)
+               nb = per_cpu(cpu_hw_events, i).amd_nb;
+               if (WARN_ON_ONCE(!nb))
                        continue;
-               if (nb->nb_id == nb_id)
-                       goto found;
-       }
 
-       nb = amd_alloc_nb(cpu, nb_id);
-       if (!nb) {
-               pr_err("perf_events: failed NB allocation for CPU%d\n", cpu);
-               raw_spin_unlock(&amd_nb_lock);
-               return;
+               if (nb->nb_id == nb_id) {
+                       kfree(cpuc->amd_nb);
+                       cpuc->amd_nb = nb;
+                       break;
+               }
        }
-found:
-       nb->refcnt++;
-       cpu1->amd_nb = nb;
+
+       cpuc->amd_nb->nb_id = nb_id;
+       cpuc->amd_nb->refcnt++;
 
        raw_spin_unlock(&amd_nb_lock);
 }
 
-static void amd_pmu_cpu_offline(int cpu)
+static void amd_pmu_cpu_dead(int cpu)
 {
        struct cpu_hw_events *cpuhw;
 
@@ -348,10 +359,14 @@ static void amd_pmu_cpu_offline(int cpu)
 
        raw_spin_lock(&amd_nb_lock);
 
-       if (--cpuhw->amd_nb->refcnt == 0)
-               kfree(cpuhw->amd_nb);
+       if (cpuhw->amd_nb) {
+               struct amd_nb *nb = cpuhw->amd_nb;
+
+               if (nb->nb_id == -1 || --nb->refcnt == 0)
+                       kfree(nb);
 
-       cpuhw->amd_nb = NULL;
+               cpuhw->amd_nb = NULL;
+       }
 
        raw_spin_unlock(&amd_nb_lock);
 }
@@ -377,8 +392,9 @@ static __initconst struct x86_pmu amd_pmu = {
        .get_event_constraints  = amd_get_event_constraints,
        .put_event_constraints  = amd_put_event_constraints,
 
-       .cpu_prepare            = amd_pmu_cpu_online,
-       .cpu_dead               = amd_pmu_cpu_offline,
+       .cpu_prepare            = amd_pmu_cpu_prepare,
+       .cpu_starting           = amd_pmu_cpu_starting,
+       .cpu_dead               = amd_pmu_cpu_dead,
 };
 
 static __init int amd_pmu_init(void)
index 83e5e628de73a7234f90c2f7130e98fa4df4fe4e..8b862d5900fe4a29b6bc100770e371db41ee0d91 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/uaccess.h>
+#include <linux/gfp.h>
 
 #include <asm/processor.h>
 #include <asm/msr.h>
index cd97ce18c29d10e27e6c9f0421f1492137a313e6..67414550c3ccf25b3d5a3094ba42b5d0f158610d 100644 (file)
@@ -5,6 +5,7 @@
  *     Copyright (C) IBM Corporation, 2004. All rights reserved
  */
 
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/highmem.h>
 #include <linux/crash_dump.h>
index 29e5f7c845b25e4ef3d92f6bc79a7e79c050e942..e39e77168a3786e4e5f21e09d6523bd47d5be631 100644 (file)
@@ -30,6 +30,11 @@ struct stack_frame {
        unsigned long return_address;
 };
 
+struct stack_frame_ia32 {
+    u32 next_frame;
+    u32 return_address;
+};
+
 static inline unsigned long rewind_frame_pointer(int n)
 {
        struct stack_frame *frame;
index adedeef1dedcad654c9955c88c677709fec22f6c..b2e2460373920128697e5bf7e93e3ca708de64ca 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/init.h>
 #include <linux/start_kernel.h>
+#include <linux/mm.h>
 
 #include <asm/setup.h>
 #include <asm/sections.h>
@@ -44,9 +45,10 @@ void __init i386_start_kernel(void)
 #ifdef CONFIG_BLK_DEV_INITRD
        /* Reserve INITRD */
        if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
+               /* Assume only end is not page aligned */
                u64 ramdisk_image = boot_params.hdr.ramdisk_image;
                u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
-               u64 ramdisk_end   = ramdisk_image + ramdisk_size;
+               u64 ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
                reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
        }
 #endif
index b5a9896ca1e74be8805c4f5384ffc8d50f6589b6..7147143fd614e429392741ae13ce5577c7be5364 100644 (file)
@@ -103,9 +103,10 @@ void __init x86_64_start_reservations(char *real_mode_data)
 #ifdef CONFIG_BLK_DEV_INITRD
        /* Reserve INITRD */
        if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
+               /* Assume only end is not page aligned */
                unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
                unsigned long ramdisk_size  = boot_params.hdr.ramdisk_size;
-               unsigned long ramdisk_end   = ramdisk_image + ramdisk_size;
+               unsigned long ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
                reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
        }
 #endif
index ee4fa1bfcb33354b96069b4728dd5cf367e74e12..d10a7e7294f4f3a07541cdce1cc8687d314b38c3 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/sysdev.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/hpet.h>
 #include <linux/init.h>
 #include <linux/cpu.h>
index c01a2b846d478a94d86ec94416394094f80ccd5e..54c31c285488e4d0db84826dcd697878e20fc953 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/regset.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/sigcontext.h>
 #include <asm/processor.h>
index fb725ee15f5515c9fb6333145f586a7079acae20..7c9f02c130f3ca9167e81205f39c968174a8e9ef 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
index ef257fc2921b1a0ed133493d53186e3b064e2529..0ed2d300cd4601dbbf23e15e32eae363d5058a5a 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/timex.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/kprobes.h>
 #include <linux/init.h>
@@ -141,6 +140,28 @@ void __init init_IRQ(void)
        x86_init.irqs.intr_init();
 }
 
+/*
+ * Setup the vector to irq mappings.
+ */
+void setup_vector_irq(int cpu)
+{
+#ifndef CONFIG_X86_IO_APIC
+       int irq;
+
+       /*
+        * On most of the platforms, legacy PIC delivers the interrupts on the
+        * boot cpu. But there are certain platforms where PIC interrupts are
+        * delivered to multiple cpu's. If the legacy IRQ is handled by the
+        * legacy PIC, for the new cpu that is coming online, setup the static
+        * legacy vector to irq mapping:
+        */
+       for (irq = 0; irq < legacy_pic->nr_legacy_irqs; irq++)
+               per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq;
+#endif
+
+       __setup_vector_irq(cpu);
+}
+
 static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP
index 9b895464dd0311f9c0c4619b5cf7e3f5e94dd2de..0f7bc20cfcdedd58f66b6b036bfb7d824e599e37 100644 (file)
@@ -2,8 +2,8 @@
  * Shared support code for AMD K8 northbridges and derivates.
  * Copyright 2006 Andi Kleen, SUSE Labs. Subject to GPLv2.
  */
-#include <linux/gfp.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/module.h>
index e444357375ce1421e137d6731adc3edba30def28..8afd9f321f100de0a8ddc236f1f411d4d98680ad 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/stat.h>
 #include <linux/io.h>
index bfba6019d762aa6652e58b3b09681a83b2e74525..b2258ca9100349c2618d00e4aadf8c7cdd62bb26 100644 (file)
@@ -618,8 +618,8 @@ int kgdb_arch_init(void)
         * portion of kgdb because this operation requires mutexs to
         * complete.
         */
+       hw_breakpoint_init(&attr);
        attr.bp_addr = (unsigned long)kgdb_arch_init;
-       attr.type = PERF_TYPE_BREAKPOINT;
        attr.bp_len = HW_BREAKPOINT_LEN_1;
        attr.bp_type = HW_BREAKPOINT_W;
        attr.disabled = 1;
index ec6ef60cbd170b0809d20287a60c226fb8fc25ed..ea697263b3738d2b20ef1131cb28ff8be44aa021 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/mm.h>
index 4a8bb82248ae8a9a945854105c19447fec8a6530..035c8c529181fa351c042f8d6a5b8ec3240dec8f 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/kexec.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 #include <linux/reboot.h>
 #include <linux/numa.h>
 #include <linux/ftrace.h>
index 845d80ce1ef1143b591852b7ac16177080d3c07a..63eaf6596233b8cbe19425460ba8fe4a0ef888c1 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/kernel.h>
 #include <linux/mca.h>
 #include <linux/kprobes.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <linux/proc_fs.h>
index 89f386f044e43fa4ed4d29503bfc838900e3841c..e0bc186d7501f123265ae288ae071e772016e89b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/bug.h>
 #include <linux/mm.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/page.h>
index 206735ac8cbdbaf053e039fb5f6e4fb5c50a5f8a..4d4468e9f47cbc7ba182ea92c78ec989c0a8b555 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/uaccess.h>
+#include <linux/gfp.h>
 
 #include <asm/processor.h>
 #include <asm/msr.h>
index a4ac764a6880fdaa7b06fc984b5d1976b2b2ee0f..4b7e3d8b01ddfdeb5b1e49bbdfc4519e2b102ac1 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/dma-debug.h>
 #include <linux/dmar.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/kmemleak.h>
 
index f3af115a573a5adbb053eae3a6c6921acf8b41fd..68cd24f9deae2a66e67b0a3c562e662bb354c433 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/iommu-helper.h>
 #include <linux/sysdev.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 #include <asm/atomic.h>
 #include <asm/mtrr.h>
 #include <asm/pgtable.h>
index 22be12b60a8ff2b12678e5198379d19260de9ce4..3af4af810c07947d9a697444f3010bf2d5427e45 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/mm.h>
 
index ad9540676fccb7138917dc6520cdf88dd95b10f8..28ad9f4d8b94aa9743386f3f76f8f2e9634f6b10 100644 (file)
@@ -526,21 +526,37 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c)
 }
 
 /*
- * Check for AMD CPUs, which have potentially C1E support
+ * Check for AMD CPUs, where APIC timer interrupt does not wake up CPU from C1e.
+ * For more information see
+ * - Erratum #400 for NPT family 0xf and family 0x10 CPUs
+ * - Erratum #365 for family 0x11 (not affected because C1e not in use)
  */
 static int __cpuinit check_c1e_idle(const struct cpuinfo_x86 *c)
 {
+       u64 val;
        if (c->x86_vendor != X86_VENDOR_AMD)
-               return 0;
-
-       if (c->x86 < 0x0F)
-               return 0;
+               goto no_c1e_idle;
 
        /* Family 0x0f models < rev F do not have C1E */
-       if (c->x86 == 0x0f && c->x86_model < 0x40)
-               return 0;
+       if (c->x86 == 0x0F && c->x86_model >= 0x40)
+               return 1;
 
-       return 1;
+       if (c->x86 == 0x10) {
+               /*
+                * check OSVW bit for CPUs that are not affected
+                * by erratum #400
+                */
+               rdmsrl(MSR_AMD64_OSVW_ID_LENGTH, val);
+               if (val >= 2) {
+                       rdmsrl(MSR_AMD64_OSVW_STATUS, val);
+                       if (!(val & BIT(1)))
+                               goto no_c1e_idle;
+               }
+               return 1;
+       }
+
+no_c1e_idle:
+       return 0;
 }
 
 static cpumask_var_t c1e_mask;
index a503b1fd04e51048c25fca9b675add81cac37304..2e9b55027b7e10e5a8ee31dc270ed7497439384c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mm.h>
 #include <linux/smp.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/ptrace.h>
 #include <linux/regset.h>
 #include <linux/tracehook.h>
index 5d7ba1a449bde18735d58777f3f510c04eaa5280..9570541caf7ca344b5a0c6d7d808a98f12c180af 100644 (file)
@@ -55,7 +55,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/user.h>
 #include <linux/delay.h>
 
@@ -314,16 +313,17 @@ static void __init reserve_brk(void)
 #define MAX_MAP_CHUNK  (NR_FIX_BTMAPS << PAGE_SHIFT)
 static void __init relocate_initrd(void)
 {
-
+       /* Assume only end is not page aligned */
        u64 ramdisk_image = boot_params.hdr.ramdisk_image;
        u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
+       u64 area_size     = PAGE_ALIGN(ramdisk_size);
        u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
        u64 ramdisk_here;
        unsigned long slop, clen, mapaddr;
        char *p, *q;
 
        /* We need to move the initrd down into lowmem */
-       ramdisk_here = find_e820_area(0, end_of_lowmem, ramdisk_size,
+       ramdisk_here = find_e820_area(0, end_of_lowmem, area_size,
                                         PAGE_SIZE);
 
        if (ramdisk_here == -1ULL)
@@ -332,7 +332,7 @@ static void __init relocate_initrd(void)
 
        /* Note: this includes all the lowmem currently occupied by
           the initrd, we rely on that fact to keep the data intact. */
-       reserve_early(ramdisk_here, ramdisk_here + ramdisk_size,
+       reserve_early(ramdisk_here, ramdisk_here + area_size,
                         "NEW RAMDISK");
        initrd_start = ramdisk_here + PAGE_OFFSET;
        initrd_end   = initrd_start + ramdisk_size;
@@ -376,9 +376,10 @@ static void __init relocate_initrd(void)
 
 static void __init reserve_initrd(void)
 {
+       /* Assume only end is not page aligned */
        u64 ramdisk_image = boot_params.hdr.ramdisk_image;
        u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
-       u64 ramdisk_end   = ramdisk_image + ramdisk_size;
+       u64 ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
        u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
 
        if (!boot_params.hdr.type_of_loader ||
index ec1de97600e70638bcfdcb53da52a83bc1288829..d801210945d6f5d93e3a8c672243a67792bca3cd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/cache.h>
 #include <linux/interrupt.h>
 #include <linux/cpu.h>
+#include <linux/gfp.h>
 
 #include <asm/mtrr.h>
 #include <asm/tlbflush.h>
index a02e80c3c54bedbfdcb05d8741461d0abdc6fe9d..763d815e27a005159ca5b52c68df4f43010b9832 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/nmi.h>
 #include <linux/tboot.h>
 #include <linux/stackprotector.h>
+#include <linux/gfp.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -242,12 +243,10 @@ static void __cpuinit smp_callin(void)
        end_local_APIC_setup();
        map_cpu_to_logical_apicid();
 
-       notify_cpu_starting(cpuid);
-
        /*
         * Need to setup vector mappings before we enable interrupts.
         */
-       __setup_vector_irq(smp_processor_id());
+       setup_vector_irq(smp_processor_id());
        /*
         * Get our bogomips.
         *
@@ -264,6 +263,8 @@ static void __cpuinit smp_callin(void)
         */
        smp_store_cpu_info(cpuid);
 
+       notify_cpu_starting(cpuid);
+
        /*
         * Allow the master to continue.
         */
index 364d015efebcc88dd6966cbfb741dfc41ccc410a..17b03dd3a6b50f45cb87e7f4cfb1312414a35274 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include <asm/mmu_context.h>
 #include <asm/uv/uv.h>
index ece73d8e32409feffaba8fde7d8b8e042c6771e7..1d40336b030adc9206a48cc0a5e39ba0c22dcf7e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/module.h>
 #include <linux/rbtree.h>
+#include <linux/slab.h>
 #include <linux/irq.h>
 
 #include <asm/apic.h>
index 2b75ef638dbc6f0716d02c58dd23cc8a97acc45a..56e421bc379b19931d4db718b35e3b92e71c3d5e 100644 (file)
@@ -19,6 +19,7 @@
  *  Copyright (c) Dimitri Sivanich
  */
 #include <linux/clockchips.h>
+#include <linux/slab.h>
 
 #include <asm/uv/uv_mmrs.h>
 #include <asm/uv/uv_hub.h>
index 7dd599deca4a7f34139fc338eb4a959e7bcbd80e..ce9fbacb7526284f35c8290d994a8f804c4e61c0 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include <asm/vmi.h>
 #include <asm/io.h>
 #include <asm/fixmap.h>
index 44879df55696407556d711b69b0f83fdc311f7f0..2cc249718c46e47ca28dd9e48ff1691a3c39d185 100644 (file)
@@ -291,8 +291,8 @@ SECTIONS
        .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
                __smp_locks = .;
                *(.smp_locks)
-               __smp_locks_end = .;
                . = ALIGN(PAGE_SIZE);
+               __smp_locks_end = .;
        }
 
 #ifdef CONFIG_X86_64
index 294698b6daff60c288dcd1304470ab7c6254000f..0150affad25d082c4dd8eea9546b30ee12491731 100644 (file)
@@ -32,6 +32,7 @@
 #define pr_fmt(fmt) "pit: " fmt
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 
 #include "irq.h"
 #include "i8254.h"
index 07771da85de55a75db97f4c7522ad465ce386b26..a790fa128a9fada66d5e816bc342b2b27186a92a 100644 (file)
@@ -26,6 +26,7 @@
  *   Port from Qemu.
  */
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/bitops.h>
 #include "irq.h"
 
index 4b224f90087bd602ce3c74a09392cb7dc5d23f07..1eb7a4ae0c9c0382ac64b44040f02e3accc4d005 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/page.h>
index 741373e8ca777a318ed7e487ef8982a181ea24f4..48aeee8eefb0e52d2cfbf870eaec5630f788376d 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/hugetlb.h>
 #include <linux/compiler.h>
 #include <linux/srcu.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 #include <asm/cmpxchg.h>
index 52f78dd03010569eba75d6db749d83e4c19265e9..445c59411ed0b7ace775ca65416ec9cc1af40170 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/highmem.h>
 #include <linux/sched.h>
 #include <linux/ftrace_event.h>
+#include <linux/slab.h>
 
 #include <asm/desc.h>
 
index 14873b9f84308ad125ae12969e0eeed269705de4..686492ed3079b6a9ab101a2298f76e8483840f88 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/moduleparam.h>
 #include <linux/ftrace_event.h>
+#include <linux/slab.h>
 #include "kvm_cache_regs.h"
 #include "x86.h"
 
index e46282a565658bdcc3ed2bae40677948cfcb3bf9..24cd0ee896e90e3f596689ffff9dd31ef0bced04 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/cpufreq.h>
 #include <linux/user-return-notifier.h>
 #include <linux/srcu.h>
+#include <linux/slab.h>
 #include <trace/events/kvm.h>
 #undef TRACE_INCLUDE_FILE
 #define CREATE_TRACE_POINTS
index f46c340727b8be21fb8270618ff9d03962667409..069ce7c37c016f0b34fc017fd005babc08d0ef53 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
-#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/sysctl.h>
 #include <asm/mman.h>
index e71c5cbc8f3561f6ce701582377749155af587b8..b278535b14aa00ce5b46de5e5bdd01cc75dc0c8a 100644 (file)
@@ -1,3 +1,4 @@
+#include <linux/gfp.h>
 #include <linux/initrd.h>
 #include <linux/ioport.h>
 #include <linux/swap.h>
@@ -331,11 +332,23 @@ int devmem_is_allowed(unsigned long pagenr)
 
 void free_init_pages(char *what, unsigned long begin, unsigned long end)
 {
-       unsigned long addr = begin;
+       unsigned long addr;
+       unsigned long begin_aligned, end_aligned;
 
-       if (addr >= end)
+       /* Make sure boundaries are page aligned */
+       begin_aligned = PAGE_ALIGN(begin);
+       end_aligned   = end & PAGE_MASK;
+
+       if (WARN_ON(begin_aligned != begin || end_aligned != end)) {
+               begin = begin_aligned;
+               end   = end_aligned;
+       }
+
+       if (begin >= end)
                return;
 
+       addr = begin;
+
        /*
         * If debugging page accesses then do not free this memory but
         * mark them not present - any buggy init-section access will
@@ -343,7 +356,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
         */
 #ifdef CONFIG_DEBUG_PAGEALLOC
        printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
-               begin, PAGE_ALIGN(end));
+               begin, end);
        set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
 #else
        /*
@@ -358,8 +371,7 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
        for (; addr < end; addr += PAGE_SIZE) {
                ClearPageReserved(virt_to_page(addr));
                init_page_count(virt_to_page(addr));
-               memset((void *)(addr & ~(PAGE_SIZE-1)),
-                       POISON_FREE_INITMEM, PAGE_SIZE);
+               memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
                free_page(addr);
                totalram_pages++;
        }
@@ -376,6 +388,15 @@ void free_initmem(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       free_init_pages("initrd memory", start, end);
+       /*
+        * end could be not aligned, and We can not align that,
+        * decompresser could be confused by aligned initrd_end
+        * We already reserve the end partial page before in
+        *   - i386_start_kernel()
+        *   - x86_64_start_kernel()
+        *   - relocate_initrd()
+        * So here We can do PAGE_ALIGN() safely to get partial page to be freed
+        */
+       free_init_pages("initrd memory", start, PAGE_ALIGN(end));
 }
 #endif
index 5cb3f0f54f47070c3f9268af39c9f5dcb0e08f57..bca79091b9d6158bcab97bdba2d8b767babeea46 100644 (file)
 #include <linux/pfn.h>
 #include <linux/poison.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/memory_hotplug.h>
 #include <linux/initrd.h>
 #include <linux/cpumask.h>
+#include <linux/gfp.h>
 
 #include <asm/asm.h>
 #include <asm/bios_ebda.h>
index e9b040e1cde5cb2ee1ad926845e2cc0e4b1f1907..ee41bba315d1897a5d30602a830d944f94f42fc7 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/memory_hotplug.h>
 #include <linux/nmi.h>
+#include <linux/gfp.h>
 
 #include <asm/processor.h>
 #include <asm/bios_ebda.h>
index 536fb682336601bce1cd428faac9cc0b1ed1a20b..5d0e67fff1a655454145c945ffe65a87ec7331a9 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kdebug.h>
 #include <linux/mutex.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <linux/errno.h>
index 34a3291ca1038969be2657ce8cc7e49fd64a4381..3adff7dcc148585339565e9d358fe315e0de818a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/module.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/version.h>
index cf07c26d9a4a59b9637a7b5389ffe33efbf5a701..28195c350b97e9470c499bea879c0839ff56d339 100644 (file)
@@ -6,13 +6,13 @@
 #include <linux/bootmem.h>
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
 #include <linux/pfn.h>
 #include <linux/percpu.h>
+#include <linux/gfp.h>
 
 #include <asm/e820.h>
 #include <asm/processor.h>
index ae9648eb1c7f44b919cf93ef7d8f008714409f4e..edc8b95afc1a345f97c4abe6daf9da628b831d2d 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/gfp.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/rbtree.h>
index c9ba9deafe83f30daaae9b0e998c3de715671d43..5c4ee422590e5dc23aec0071e642bf246b627565 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/tlb.h>
index 46c8834aedc0fe3c16e5c88d70012f62f436a3c3..1a8faf09afed2135174396055cd1d82fc5bbfd8a 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/swap.h>
 #include <linux/smp.h>
 #include <linux/highmem.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
index 6e22454bfaa6d51e4f22ce9eb5c379e1770319d6..c7b1ebfb7da79b3ee0f7b3cdaad17ba760b9e05e 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include <asm/numa.h>
 #include <asm/pci_x86.h>
 
@@ -122,8 +123,8 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
        struct acpi_resource_address64 addr;
        acpi_status status;
        unsigned long flags;
-       struct resource *root;
-       u64 start, end;
+       struct resource *root, *conflict;
+       u64 start, end, max_len;
 
        status = resource_to_addr(acpi_res, &addr);
        if (!ACPI_SUCCESS(status))
@@ -140,6 +141,17 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
        } else
                return AE_OK;
 
+       max_len = addr.maximum - addr.minimum + 1;
+       if (addr.address_length > max_len) {
+               dev_printk(KERN_DEBUG, &info->bridge->dev,
+                          "host bridge window length %#llx doesn't fit in "
+                          "%#llx-%#llx, trimming\n",
+                          (unsigned long long) addr.address_length,
+                          (unsigned long long) addr.minimum,
+                          (unsigned long long) addr.maximum);
+               addr.address_length = max_len;
+       }
+
        start = addr.minimum + addr.translation_offset;
        end = start + addr.address_length - 1;
 
@@ -157,9 +169,12 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
                return AE_OK;
        }
 
-       if (insert_resource(root, res)) {
+       conflict = insert_resource_conflict(root, res);
+       if (conflict) {
                dev_err(&info->bridge->dev,
-                       "can't allocate host bridge window %pR\n", res);
+                       "address space collision: host bridge window %pR "
+                       "conflicts with %s %pR\n",
+                       res, conflict->name, conflict);
        } else {
                pci_bus_add_resource(info->bus, res, 0);
                info->res_num++;
index 294e10cb11e108a82ce6140b44a67049d12dc3e6..cf2e93869c489ee14b8e074817a62a55dacf3845 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #include <asm/acpi.h>
 #include <asm/segment.h>
index dece3eb9c90639731811f8bc4bd7139d51a7fd69..46fd43f791037cb318b6de9405435f434f84065b 100644 (file)
@@ -127,9 +127,6 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
                                        continue;
                                if (!r->start ||
                                    pci_claim_resource(dev, idx) < 0) {
-                                       dev_info(&dev->dev,
-                                                "can't reserve window %pR\n",
-                                                r);
                                        /*
                                         * Something is wrong with the region.
                                         * Invalidate the resource to prevent
@@ -181,8 +178,6 @@ static void __init pcibios_allocate_resources(int pass)
                                        "BAR %d: reserving %pr (d=%d, p=%d)\n",
                                        idx, r, disabled, pass);
                                if (pci_claim_resource(dev, idx) < 0) {
-                                       dev_info(&dev->dev,
-                                                "can't reserve %pR\n", r);
                                        /* We'll assign a new address later */
                                        r->end -= r->start;
                                        r->start = 0;
index 8b107521d24e63f235cdd86ddf4ee86826e36ded..5d362b5ba06f35146d40cd161b6b19ade0ff84e6 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/dmi.h>
 #include <linux/io.h>
index 8f3f9a50b1e0b4891be7fbba0d62ee16bff6a273..39b9ebe8f8863d598345991c90942b5aed70ae21 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sfi_acpi.h>
 #include <linux/bitmap.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include <asm/e820.h>
 #include <asm/pci_x86.h>
 #include <asm/acpi.h>
index 1c975cc9839e0617e3b08d245e91277ec10450e3..59a225c17b84264f07bb07ca4db54b8962fce9c4 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
 #include <asm/pci_x86.h>
index 81197c62d5b3f8240b7f261cf2efee90ea110fb2..3769079874d8f57702bbea42bcc7446908b5af23 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (c) 2006 Rafael J. Wysocki <rjw@sisk.pl>
  */
 
+#include <linux/gfp.h>
 #include <linux/suspend.h>
 #include <linux/bootmem.h>
 
index 65fdc86e923fd92175b95bfef56ad1c82d64bc2d..d24f983ba1e5f670cc4cb9dbaf0bf056416e8278 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright (c) 2001 Patrick Mochel <mochel@osdl.org>
  */
 
+#include <linux/gfp.h>
 #include <linux/smp.h>
 #include <linux/suspend.h>
 #include <asm/proto.h>
index 21e1aeb9f3ea1b1f839445dbae69ad461ddf188f..ac74869b8140754b45277126fb6f5dcc5a9e6834 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/mm.h>
 #include <linux/err.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/elf.h>
index e133ce25e29022d20bdd5e954c9a6697bfc7ab91..1304bcec8ee57d1b15c8cb72aed55cea283d2d5b 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/init.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "debugfs.h"
index b607239c1ba8304f2732f0e7035a81f2ee1bff8c..65d8d79b46a8467cbc11c4495a160d7b416a0b32 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/highmem.h>
 #include <linux/console.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 
 #include <xen/xen.h>
 #include <xen/interface/xen.h>
index f9eb7de74f42998745872dea255ec821e2abe1ce..914f04695ce5e1a917e786ab2ac231369083ec1e 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/debugfs.h>
 #include <linux/bug.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
index deafb65ef44edb7a18ef96e6846843948c7b90b1..a29693fd3138e06bbd46ad875249da6c5a35cdce 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/sched.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/smp.h>
 
 #include <asm/paravirt.h>
index 24ded31b5aeceeabfadc05fc5c5ff7aa95fa2b97..e0500646585d4a5d7bc64338798ba955494ab387 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/spinlock.h>
 #include <linux/debugfs.h>
 #include <linux/log2.h>
+#include <linux/gfp.h>
 
 #include <asm/paravirt.h>
 
index 0d3f07cd1b5fe9aee977674b11b0beb311e25eb0..32764b8880b5f85b6d88032bbb1fbee0d7f7359c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/clockchips.h>
 #include <linux/kernel_stat.h>
 #include <linux/math64.h>
+#include <linux/gfp.h>
 
 #include <asm/pvclock.h>
 #include <asm/xen/hypervisor.h>
index f5319d78c876135326374c530f7f85f13f961d72..2783fda76ddc18f052494c7b9010db3e0e208cfa 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <asm/cacheflush.h>
 
index e1a04a346e75811cde445b4ad4bce4cd0c679cd9..f167e0f5e05e524b6deffbbda3127da8ae3905c8 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/stddef.h>
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/elf.h>
 #include <linux/init.h>
 #include <linux/prctl.h>
@@ -31,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/mqueue.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
index cdbc27ca9665dea72be443a347120a3c547a8386..ba150e5de2ebe6583c2b708525a26e33b8acbfb2 100644 (file)
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/bootmem.h>
+#include <linux/gfp.h>
 #include <linux/swap.h>
 #include <linux/mman.h>
 #include <linux/nodemask.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 
 #include <asm/bootparam.h>
 #include <asm/page.h>
index e60a1f57022f358a6ca1e61119ed8e71f547bcbf..2c723e8b30da4f7b08b9bb7418735356d69639fb 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/sched.h>
 #include <linux/console.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/major.h>
 #include <linux/param.h>
index 8618d8996fea9c9b278b7529d44ac958c24fa465..6d88544b677fe8865922795ccac817d1d301954f 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/gfp.h>
 
 #include "blk.h"
 
index 4b686ad08eaaad5384f7d0c6535b5b4154679c5f..5fe03def34b24c396f299aa57bda4b1cc5a3df2a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kdev_t.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include "blk-cgroup.h"
 
 static DEFINE_SPINLOCK(blkio_list_lock);
index 96e83c2bdb94f0a06e4cd4f2f04e86b3b115fdb4..edce1ef7933d69d553b890fcd4d42edaed1a01be 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mempool.h>
 #include <linux/bio.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include "blk.h"
 
index 3f65c8aadb2fb9ba6116f82653e314efce950a51..d22c4c55c40689c23b7d275fbb76af17c0b23efa 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/bootmem.h>     /* for max_pfn/max_low_pfn */
+#include <linux/slab.h>
 
 #include "blk.h"
 
index 31e7a9375c1333cc35ab40d565c5c1ed4e8703e7..d9a9db5f0a2bddfbdd6e5dbfe8a8c0c7a73b24b0 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/bootmem.h>     /* for max_pfn/max_low_pfn */
 #include <linux/gcd.h>
 #include <linux/jiffies.h>
+#include <linux/gfp.h>
 
 #include "blk.h"
 
index 2ae2cb3f362fb4984907d54a625c6e5af3b5f779..c2b821fa324a115b95c5dd93920b34dd189f9dc7 100644 (file)
@@ -2,6 +2,7 @@
  * Functions related to sysfs handling
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
index 6b0f52c20964e484c95a2e6c120dc77e2b821b88..ece65fc4c79b511c37fb3eb89c4a746dc105ba8d 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include "blk.h"
 
index 46597a6bd112d9c209904dab7cc6da723cbc9fb8..82d58829ba591eeef13a3ed4eca96b8a019c4d85 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/idr.h>
 #include <linux/bsg.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_ioctl.h>
index dee9d9378fee18658875fba10122ed0cbe308d04..fc98a48554fd46025c4dcc9a12f75dc4a98e609b 100644 (file)
@@ -7,6 +7,7 @@
  *  Copyright (C) 2003 Jens Axboe <axboe@kernel.dk>
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/elevator.h>
 #include <linux/jiffies.h>
index 4eb8e9ea4af561cd9d141a44709cb94138a25594..f26051f446814d24cf2bb1bb4077de455ffe54af 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/elevator.h>
 #include <linux/fd.h>
 #include <linux/hdreg.h>
+#include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/smp_lock.h>
 #include <linux/types.h>
index be48ea51faee2e3a73fd5d5fcc1c7071772db061..8905d2a2a717c1adde73d0fb63014bb71271e4ae 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/capability.h>
 #include <linux/blkdev.h>
+#include <linux/gfp.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
 #include <linux/backing-dev.h>
index 3a0d369d08c7488f8f475091ef3ee6b5dfe46211..232c4b38cd3769d31e0c79700a49f42915c683a6 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/elevator.h>
 #include <linux/bio.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 struct noop_data {
index 3e4524e6139bcf3b58e8f44a8de33a96e9333aee..76fae27ed01cb9834049e2b641d9e561ef0844e5 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include "internal.h"
index 412241ce4cfae25822a6beccf9360c9f52ccc89f..c3c196b5823a2e12c790cce27b9ae8439c20d445 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/notifier.h>
 #include <linux/rtnetlink.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include "internal.h"
index ec87f53d50595f0c545df398932799d5d2054c0d..fdd8257d35d9d8133098f3592f5e3d1c2fd09261 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/raid/pq.h>
 #include <linux/async_tx.h>
+#include <linux/gfp.h>
 
 /**
  * pq_scribble_page - space to hold throwaway P or Q buffer for
index f84f6b4301d98df03dd02c05db9d4351885bc39e..c1321935ebcc587f31e991c6a0c917986164102e 100644 (file)
@@ -20,6 +20,7 @@
  *
  */
 #include <linux/async_tx.h>
+#include <linux/gfp.h>
 #include <linux/random.h>
 
 #undef pr
index 15c2eb53454194971aa3122a2d5f7f0c84773409..8d9544cf8169fd30d12fdea1d6303cfd3f4e7158 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/scatterlist.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 
 struct hmac_ctx {
index ba05e7380e76c6d340d6273c2d4602a0c597f9b1..f93cb5311182bbc6faf48c46599e4b92578410bf 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mutex.h>
 #include <linux/random.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 static DEFINE_MUTEX(crypto_default_rng_lock);
index 5a013a8bf87a3ceb1a61036a459d71f3520ba09e..4c44912294178816688177e56faada3c85d6267d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 
index aa3f84ccc78632ca241f0cc87d14c6a98444f946..a35159947a262f779041fe7bff86671cac00ed98 100644 (file)
@@ -18,8 +18,8 @@
 #include <crypto/hash.h>
 #include <linux/err.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <linux/moduleparam.h>
index fc5b836f343084f74b76f516133adbe455e04ab7..b75182d8ab1460b141619cc63af15d03fe6b2475 100644 (file)
@@ -18,6 +18,7 @@
 
 #define BH_TRACE 0
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/raid/xor.h>
 #include <linux/jiffies.h>
 #include <asm/xor.h>
index b6ed60b57b0dd095686479862064ae42d4fc8a2c..56205a0b85dfc60eb3dc85def0a7432639ea0142 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #ifdef CONFIG_ACPI_PROCFS_POWER
index 3597d73f28f6029dcf7e6b037c216cae1018b998..d98571385656154b8ef39664852e808397846a11 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/memory_hotplug.h>
+#include <linux/slab.h>
 #include <acpi/acpi_drivers.h>
 
 #define ACPI_MEMORY_DEVICE_CLASS               "memory"
index 7e52295f1ecc020d65582eb9d1c867126673a1d6..19dacfd43163759df8aae2d4e018502cbc19fb1c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/freezer.h>
 #include <linux/cpu.h>
 #include <linux/clockchips.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
index 75f39f2c166d88b3b186a0bb2633fac77165753b..5717bd300869939154f02ce85a69ea61497f47e2 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/jiffies.h>
 #include <linux/async.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_ACPI_PROCFS_POWER
 #include <linux/proc_fs.h>
index b70cd37561423bc360c0f9bf15cdfdfe731a34a8..37132dc2da03df35ec25b1e8e203715ceb172aac 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/device.h>
 #include <linux/proc_fs.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #ifdef CONFIG_X86
 #include <asm/mpspec.h>
 #endif
index f53fbe307c9dba027d9e4dc53867f0579da2f783..fd51c4ab4829dee0f37446f32a15a4679065675c 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
index 5faf6c21257d3fa7f483d671dfd47b975c5d7c1a..45cd03b4630e00579d1b0840c5c1afb3657b9b94 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
index cc421b7ae166c4ffe6a005c73b3f2714a36db2b9..146135e7a6a125731ec902e898bfe4b9364c0d6e 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <acpi/acpi_drivers.h>
 
index d9a85f1ddde6ca62ac1d529f4023df10b140714d..a9c429c5d50fb7ce724152cba10bf4f743f53a72 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/notifier.h>
index 1ac28c6a672ea3667331772f5535515d8b129e9d..35ba2547f544080067e417504987e0bdd4e87f58 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
index c511071bfd79bfac075012eb52f90d9a45646acc..d439314a75d8b183f4eecda98a3a6ef4dbcfa7ee 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/poll.h>
+#include <linux/gfp.h>
 #include <acpi/acpi_drivers.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
index 6d5b64b7d526e8c00f3e695d999708f55aae3540..4af6301601e701e1ad0938e47eb65df8400faa4d 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/rwsem.h>
 #include <linux/acpi.h>
 
index 843699ed93f25b9ce5613c6ca250f9509bfecf07..b0a71ecee6820c198feb628184c90bf0b54ebfe9 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/pm.h>
 #include <linux/pci.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
index 04b0f007c9b79e5d5708aeed1529069e85afb45e..8d47a5846aebc192479d943b0a4826030b5a4344 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/pm.h>
 #include <linux/pci.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
index d724736d56c8e0f25345d28c50f8b76295f4bfaa..aefce33f2a09c88d8fb3fec7b2bd7fa57a899de2 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/pci.h>
 #include <linux/pci-acpi.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
index 11f219743204fa9b8ffa6c7682d9f852d7838273..07f7fea8a4e26471ce6fabd4b90ade3c69ec9e43 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/acpi.h>
index 0f30c3c1eea475b7e2c0bb247981903ba6e006b3..ddc76787b8424f1a11d50ef0f7810b920ad05ef9 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <acpi/acpi_bus.h>
index 834c5af0de4bead0ec1b77f67d6d0357a8ccb1e6..e8c32a49f14e552b4c19ad54065593f5008a2587 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/jiffies.h>
 #include <linux/mutex.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include <linux/kdev_t.h>
 #include <linux/sched.h>
 #include <linux/time.h>
index 791ac7b0f8dffbf9c7f5823a17d00871d3a6bf20..51284351418f4a5cb0f176e1475d94db1e5e4b83 100644 (file)
@@ -8,6 +8,7 @@
  *     - Added _PDC for platforms with Intel CPUs
  */
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #include <acpi/acpi_drivers.h>
 #include <acpi/processor.h>
index b5658cdce27fec45f4d718e924af3229308249e0..5675d9747e871f1007070081fbc59557576c6d65 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/dmi.h>
 #include <linux/moduleparam.h>
 #include <linux/cpuidle.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
index 37dfce749398b35abc6ef3b00fac13ce678146b3..5939e7f7d8e9004ea794408c61b6665d52f92851 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/acpi.h>
index d648a9860b88d2557e13ae958c2a7e3b0480464b..ba1bd263d903094692c3683c9557e8b919d1d985 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_X86
 #include <asm/cpufeature.h>
index 29c6f5766dcfa1ecee58af693c1dcebde9135bd3..9ade1a5b32edbef3b07142cac70cfa116ce31b89 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/cpufreq.h>
index 89ad11138e48fa36f3e5d154cbfff73fff228509..4ff76e8174ebf716db53b1d5f2d3bbecd82ad332 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
index fd09229282eaccd8dda3ccde049b417814c3ad29..36704b887ccf34cfbc1313f2dc5bb72060c84cb5 100644 (file)
@@ -11,6 +11,7 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include "sbshc.h"
index fb7fc24fe72725817ee38e970dc9b90f07998522..0261b116d051628768f974f94fa3842b31a386b2 100644 (file)
@@ -4,10 +4,12 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/acpi.h>
 #include <linux/signal.h>
 #include <linux/kthread.h>
+#include <linux/dmi.h>
 
 #include <acpi/acpi_drivers.h>
 
@@ -1032,6 +1034,41 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
        list_add_tail(&id->list, &device->pnp.ids);
 }
 
+/*
+ * Old IBM workstations have a DSDT bug wherein the SMBus object
+ * lacks the SMBUS01 HID and the methods do not have the necessary "_"
+ * prefix.  Work around this.
+ */
+static int acpi_ibm_smbus_match(struct acpi_device *device)
+{
+       acpi_handle h_dummy;
+       struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
+       int result;
+
+       if (!dmi_name_in_vendors("IBM"))
+               return -ENODEV;
+
+       /* Look for SMBS object */
+       result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path);
+       if (result)
+               return result;
+
+       if (strcmp("SMBS", path.pointer)) {
+               result = -ENODEV;
+               goto out;
+       }
+
+       /* Does it have the necessary (but misnamed) methods? */
+       result = -ENODEV;
+       if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) &&
+           ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) &&
+           ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy)))
+               result = 0;
+out:
+       kfree(path.pointer);
+       return result;
+}
+
 static void acpi_device_set_id(struct acpi_device *device)
 {
        acpi_status status;
@@ -1082,6 +1119,8 @@ static void acpi_device_set_id(struct acpi_device *device)
                        acpi_add_id(device, ACPI_BAY_HID);
                else if (ACPI_SUCCESS(acpi_dock_match(device)))
                        acpi_add_id(device, ACPI_DOCK_HID);
+               else if (!acpi_ibm_smbus_match(device))
+                       acpi_add_id(device, ACPI_SMBUS_IBM_HID);
 
                break;
        case ACPI_BUS_TYPE_POWER:
index 743f2445e2a13f48ce549c8a87e18063d17f84e5..4aaf2497613804d1fcc6673f93da998537ea8696 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/string.h>
 #include <asm/uaccess.h>
index 5d3893558cf73566e128f36e6e11482c13ccbef2..efad1f33aeb588b1c4910697ac97dfcfc2ad2b92 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/jiffies.h>
index c9a49f4747e675707e67aeeaa708fec550f2a5bf..b002a471c5d49d7afdb9c5db81e78ae65743c4ff 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <acpi/acpi_bus.h>
index cbe6f3924a102d327cb92511255c8df0d63329b1..6a0143796772df266d6eb5c2d8498b96330070bf 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/sort.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/dmi.h>
 #include <acpi/acpi_bus.h>
index fdc9bcbe55a205688e4eab48dde45307fc4ea9ae..5326af28a4100fbb4c611c8aa76bcb490938bb97 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/device.h>
 #include <linux/dmi.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
index c33806654e46d5bfb984866c7bdad185c4f90ffe..83bc49fac9bb543d3857a3b81c9e5286cfb466db 100644 (file)
@@ -90,6 +90,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/dmi.h>
index 292fdbc0431a20e872509809ccd733683f61bb9c..7b5eea7e01dc83e5a42f0c075472ca67ef7e38ee 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/acpi.h>
 #include <linux/libata.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <scsi/scsi_device.h>
 #include "libata.h"
 
index 4a28420efff22a2059c50bbe6a15804d79c73dc1..49cffb6094a3183958fe536542c1b9208becaaf2 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/io.h>
 #include <linux/async.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
@@ -1493,6 +1494,7 @@ static int ata_hpa_resize(struct ata_device *dev)
 {
        struct ata_eh_context *ehc = &dev->link->eh_context;
        int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
+       bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
        u64 sectors = ata_id_n_sectors(dev->id);
        u64 native_sectors;
        int rc;
@@ -1509,7 +1511,7 @@ static int ata_hpa_resize(struct ata_device *dev)
                /* If device aborted the command or HPA isn't going to
                 * be unlocked, skip HPA resizing.
                 */
-               if (rc == -EACCES || !ata_ignore_hpa) {
+               if (rc == -EACCES || !unlock_hpa) {
                        ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
                                       "broken, skipping HPA handling\n");
                        dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
@@ -1524,7 +1526,7 @@ static int ata_hpa_resize(struct ata_device *dev)
        dev->n_native_sectors = native_sectors;
 
        /* nothing to do? */
-       if (native_sectors <= sectors || !ata_ignore_hpa) {
+       if (native_sectors <= sectors || !unlock_hpa) {
                if (!print_info || native_sectors == sectors)
                        return 0;
 
@@ -4185,36 +4187,51 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
                goto fail;
 
        /* verify n_sectors hasn't changed */
-       if (dev->class == ATA_DEV_ATA && n_sectors &&
-           dev->n_sectors != n_sectors) {
-               ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch "
-                              "%llu != %llu\n",
-                              (unsigned long long)n_sectors,
-                              (unsigned long long)dev->n_sectors);
-               /*
-                * Something could have caused HPA to be unlocked
-                * involuntarily.  If n_native_sectors hasn't changed
-                * and the new size matches it, keep the device.
-                */
-               if (dev->n_native_sectors == n_native_sectors &&
-                   dev->n_sectors > n_sectors &&
-                   dev->n_sectors == n_native_sectors) {
-                       ata_dev_printk(dev, KERN_WARNING,
-                                      "new n_sectors matches native, probably "
-                                      "late HPA unlock, continuing\n");
-                       /* keep using the old n_sectors */
-                       dev->n_sectors = n_sectors;
-               } else {
-                       /* restore original n_[native]_sectors and fail */
-                       dev->n_native_sectors = n_native_sectors;
-                       dev->n_sectors = n_sectors;
-                       rc = -ENODEV;
-                       goto fail;
-               }
+       if (dev->class != ATA_DEV_ATA || !n_sectors ||
+           dev->n_sectors == n_sectors)
+               return 0;
+
+       /* n_sectors has changed */
+       ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n",
+                      (unsigned long long)n_sectors,
+                      (unsigned long long)dev->n_sectors);
+
+       /*
+        * Something could have caused HPA to be unlocked
+        * involuntarily.  If n_native_sectors hasn't changed and the
+        * new size matches it, keep the device.
+        */
+       if (dev->n_native_sectors == n_native_sectors &&
+           dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) {
+               ata_dev_printk(dev, KERN_WARNING,
+                              "new n_sectors matches native, probably "
+                              "late HPA unlock, continuing\n");
+               /* keep using the old n_sectors */
+               dev->n_sectors = n_sectors;
+               return 0;
        }
 
-       return 0;
+       /*
+        * Some BIOSes boot w/o HPA but resume w/ HPA locked.  Try
+        * unlocking HPA in those cases.
+        *
+        * https://bugzilla.kernel.org/show_bug.cgi?id=15396
+        */
+       if (dev->n_native_sectors == n_native_sectors &&
+           dev->n_sectors < n_sectors && n_sectors == n_native_sectors &&
+           !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) {
+               ata_dev_printk(dev, KERN_WARNING,
+                              "old n_sectors matches native, probably "
+                              "late HPA lock, will try to unlock HPA\n");
+               /* try unlocking HPA */
+               dev->flags |= ATA_DFLAG_UNLOCK_HPA;
+               rc = -EIO;
+       } else
+               rc = -ENODEV;
 
+       /* restore original n_[native_]sectors and fail */
+       dev->n_native_sectors = n_native_sectors;
+       dev->n_sectors = n_sectors;
  fail:
        ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
        return rc;
@@ -4353,6 +4370,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        { "HTS541080G9SA00",    "MB4OC60D",     ATA_HORKAGE_NONCQ, },
        { "HTS541010G9SA00",    "MBZOC60D",     ATA_HORKAGE_NONCQ, },
 
+       /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */
+       { "C300-CTFDDAC128MAG", "0001",         ATA_HORKAGE_NONCQ, },
+
        /* devices which puke on READ_NATIVE_MAX */
        { "HDS724040KLSA80",    "KFAOA20N",     ATA_HORKAGE_BROKEN_HPA, },
        { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA },
index 51f0ffb78cbd62af877453cd2bea3a07e999cc46..00305f41ed86397a0af8746cccd03160020a2881 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/libata.h>
+#include <linux/slab.h>
 #include "libata.h"
 
 const struct ata_port_operations sata_pmp_port_ops = {
index bea003a24d277268fb7cd9337e9851269e0c809c..0088cdeb0b1ee14e127a759650e087b59de6bb22 100644 (file)
@@ -33,6 +33,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
 #include <linux/spinlock.h>
index 561dec2481cb2da91bed31b037edc31e2301b57b..e3877b6843c9ad4d16b469770b9c4595cdd0a086 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/libata.h>
 #include <linux/highmem.h>
@@ -1667,6 +1668,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
 {
        struct ata_eh_info *ehi = &ap->link.eh_info;
        u8 status, host_stat = 0;
+       bool bmdma_stopped = false;
 
        VPRINTK("ata%u: protocol %d task_state %d\n",
                ap->print_id, qc->tf.protocol, ap->hsm_task_state);
@@ -1699,6 +1701,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
 
                        /* before we do anything else, clear DMA-Start bit */
                        ap->ops->bmdma_stop(qc);
+                       bmdma_stopped = true;
 
                        if (unlikely(host_stat & ATA_DMA_ERR)) {
                                /* error when transfering data to/from memory */
@@ -1716,8 +1719,14 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
 
        /* check main status, clearing INTRQ if needed */
        status = ata_sff_irq_status(ap);
-       if (status & ATA_BUSY)
-               goto idle_irq;
+       if (status & ATA_BUSY) {
+               if (bmdma_stopped) {
+                       /* BMDMA engine is already stopped, we're screwed */
+                       qc->err_mask |= AC_ERR_HSM;
+                       ap->hsm_task_state = HSM_ST_ERR;
+               } else
+                       goto idle_irq;
+       }
 
        /* ack bmdma irq events */
        ap->ops->sff_irq_clear(ap);
@@ -1762,13 +1771,16 @@ EXPORT_SYMBOL_GPL(ata_sff_host_intr);
 irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
 {
        struct ata_host *host = dev_instance;
+       bool retried = false;
        unsigned int i;
-       unsigned int handled = 0, polling = 0;
+       unsigned int handled, idle, polling;
        unsigned long flags;
 
        /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
        spin_lock_irqsave(&host->lock, flags);
 
+retry:
+       handled = idle = polling = 0;
        for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap = host->ports[i];
                struct ata_queued_cmd *qc;
@@ -1782,7 +1794,8 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
                                handled |= ata_sff_host_intr(ap, qc);
                        else
                                polling |= 1 << i;
-               }
+               } else
+                       idle |= 1 << i;
        }
 
        /*
@@ -1790,7 +1803,9 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
         * asserting IRQ line, nobody cared will ensue.  Check IRQ
         * pending status if available and clear spurious IRQ.
         */
-       if (!handled) {
+       if (!handled && !retried) {
+               bool retry = false;
+
                for (i = 0; i < host->n_ports; i++) {
                        struct ata_port *ap = host->ports[i];
 
@@ -1801,12 +1816,23 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
                            !ap->ops->sff_irq_check(ap))
                                continue;
 
-                       if (printk_ratelimit())
-                               ata_port_printk(ap, KERN_INFO,
-                                               "clearing spurious IRQ\n");
+                       if (idle & (1 << i)) {
+                               ap->ops->sff_check_status(ap);
+                               ap->ops->sff_irq_clear(ap);
+                       } else {
+                               /* clear INTRQ and check if BUSY cleared */
+                               if (!(ap->ops->sff_check_status(ap) & ATA_BUSY))
+                                       retry |= true;
+                               /*
+                                * With command in flight, we can't do
+                                * sff_irq_clear() w/o racing with completion.
+                                */
+                       }
+               }
 
-                       ap->ops->sff_check_status(ap);
-                       ap->ops->sff_irq_clear(ap);
+               if (retry) {
+                       retried = true;
+                       goto retry;
                }
        }
 
index 8e5e13210426d9effb029058453f2c2cb9ae7504..1ea2be0f4b94fea1ff90137a15b891191b47bab9 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <acpi/acpi_bus.h>
 
index 5c129f99a7e36256c18772b074ac87eb95bfdcb5..66ce6a526f2732d186630cef161678aeb0052853 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <scsi/scsi_host.h>
 #include <linux/ata.h>
 #include <linux/libata.h>
index 376dd380b43c7243e214a4b74c42addfb398960f..c6a946aa252c1f05d40e847921435a40439eb201 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/ata.h>
 #include <linux/clk.h>
index 6fe7ded40c6a346027bf091019ea6dc65edbdf5e..bb6e0746e07d110a5a31f561fc72c52923238031 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
index 6cd5d5dd9e3b04a42799c9e4f2712a82505dc769..45896b3c65389ad8e43d6a091fbb0563c8c08072 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
index b663b7ffae4bf4f9a0298910443e10a65e95f7e4..fa812e206eeb2e4670b59d23a96015d0167a44ff 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/ata.h>
 #include <linux/libata.h>
index 9bde1cb5f981891536dac2656bec4fcc14d61409..5cb286fd839e62d6e4ecc51843f43a9ce4a80ea6 100644 (file)
@@ -75,6 +75,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
index 4cc7bbd10ec20d441311b655ee1323801bfcb7c3..211b6438b3a015db5a9ccaa1db5da525b54a53e8 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/pmu.h>
 #include <linux/scatterlist.h>
 #include <linux/of.h>
+#include <linux/gfp.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
index 2bc2dbe30e8fe6d4635cf90f986ad866926c0feb..9f5b053611ddef3c29aa7c460643638055579377 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/libata.h>
 #include <linux/of_platform.h>
index 37ef416c12428e811c777b14a38248de7ab6a429..005a44483a7b5e1b76eb3b2c69cbf376f13721e0 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/libata.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_host.h>
index 147de2fd66d2f67358058a26baa024a08db28d4b..3c3172d3c34e8928140703f2b859406f177c2064 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <scsi/scsi_host.h>
 #include <linux/ata.h>
 #include <linux/libata.h>
index 45f1e10f917b473f41f19cf1859658d2f3bb95c7..0ffd631000b76daf758668321bf2f7a4b7568945 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index 237a24d41a2d2d8d17ef007d1aa41806d5f790f8..37092cfd7bc67a168a548570aaaef0947a0b72ea 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/dmi.h>
index 3059ec017de3fde4c4f2100d99da286ccdf93836..741e7cb69d8c269adc9d2f1f4815726cd8dee260 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <linux/dmi.h>
@@ -576,6 +577,10 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                        u8 rev = isa->revision;
                        pci_dev_put(isa);
 
+                       if ((id->device == 0x0415 || id->device == 0x3164) &&
+                           (config->id != id->device))
+                               continue;
+
                        if (rev >= config->rev_min && rev <= config->rev_max)
                                break;
                }
@@ -677,6 +682,7 @@ static const struct pci_device_id via[] = {
        { PCI_VDEVICE(VIA, 0x3164), },
        { PCI_VDEVICE(VIA, 0x5324), },
        { PCI_VDEVICE(VIA, 0xC409), VIA_IDFLAG_SINGLE },
+       { PCI_VDEVICE(VIA, 0x9001), VIA_IDFLAG_SINGLE },
 
        { },
 };
index 6c65b0776a2cc900c6b97dd437a458cc7fd125ed..5904cfdb8dbed34d68cfc9aaf07df51571d04826 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
index ce4136eea08fa5f309855a621dd981a412fd6d9b..a69192b38b438411cf4b8e839cbe32dfcd357f6c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
index 4406902b4293f4ee838fd0388b89fb64b6cfc085..27dc6c86a4cd27305037cf1e41d8393c6cf9b93a 100644 (file)
@@ -39,6 +39,7 @@
  * happy to assist.
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
index df8ee325d3ca3869c1fb6609a3432d590178d8c7..71cc0d42f9e1c015ba90d27d4a457d5e247fddc5 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/ata_platform.h>
 #include <linux/mbus.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
index 684fe04dbbb7f8200f710c578206d83bd6239030..2a98b09ab7357cca4ee654ff2b7e7e79b2ba6eb7 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
index 63306285c8437a8e14271013d55f53e647a762f4..5356ec00d2b44d6ea587bc09e94a8fbb8c165121 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
index 326c0cfc29b34c366c146ea0c2a6c128d5f7f2f4..92ba45e6689b2e403f66158b4380d488ff2f05a1 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
index 1370df6c420ceed4317ff3cec8800a7f00a7507d..433b6b89c795e9ba2562b407d45d0805f2340622 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
index bbcf970068ad0916a42db2fb7ea663d91d0b7011..232468f2ea90eed5ae195e32270270c62e4c7b4a 100644 (file)
@@ -81,6 +81,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
index e5bff47e8aa132415d00200ff566757d6a15177e..011e098590d16f80f714e12e8808e036a7e3c0f7 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
index 5effec6f545870a071f003923666b8b4cb310d53..6d44f07b69f8fc656b75397c26552f4170b7366d 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mm.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
index 8af23411743c2924eead86ac7fda5f0f5fa50d19..9d18644c897e9f43ef6d8f7cd93d90c237d98322 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/mutex.h>
 #include <linux/firmware.h>
 #include <linux/ihex.h>
+#include <linux/slab.h>
 
 #include <asm/atomic.h>
 #include <asm/io.h>
index 02ad83d6b562b6e0d14142a126622b26c7e9f180..b86712167eb8fddc08d4be0cfe1843550ab9df2d 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/atm_tcp.h>
 #include <linux/bitops.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
 
index 0c302614544382992bf67fb656a001cffa9c5edd..719ec5a0dca547091df22ef8464a5bf2dcbfe241 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/atm_eni.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
index cd5049af47a9a11144d58e8cceed873c2bfb2483..6e600afd06ae6d0fbbaeb96d7aa02093954771b5 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/init.h>
 #include <linux/capability.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/string.h>
index e8c6529dc366a6401730d4b16d12a98597d6ab0b..c213e0da0343d4d9cda4d7283664537939a3ab8a 100644 (file)
@@ -67,6 +67,7 @@
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
index 4e49021e67ee465b5ecc8ffb312e1c7a88399431..54720baa7363996203a9489a0bfae45e0fa4a7da 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index 84672dc57f7afdebd84dbb760cfb3979d590dd97..dab5cf5274fb4d6c7a37915f9d2d7e2f86d546e8 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/capability.h>
 #include <linux/atm_idt77105.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/param.h>
 #include <asm/uaccess.h>
index 01f36c08cb52cb7ac5a91d3c844c4feb3cc6114d..98657a6a330d00a5ad8f1489e34784cfa3085a37 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/wait.h>
 #include <linux/jiffies.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
index 25a4c86f839b29a5436f1de6cf2829c543296435..ee9ddeb53417c7da782d252f7d9e4f8113ee44b4 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/uio.h>  
 #include <linux/init.h>  
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <asm/system.h>  
 #include <asm/io.h>  
 #include <asm/atomic.h>  
index 23d95054705be2f2671555a144d889cf8aaa2e02..cbe15a86c6698b2044b45469fa57f8d199aca15e 100644 (file)
@@ -55,6 +55,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/atmdev.h>
 #include <asm/io.h>
index 50838407b11792e61bbff23373e33ace90ab0a8d..b7473a6110a7600b8bbfdbab35a3289618cd12c7 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
index 51eed679a0596dd959b713743777cc430da0e4db..ded76c4c9f4f1599d6b8087eff93d9247e4f8526 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/firmware.h>
 #include <linux/ctype.h>
 #include <linux/swab.h>
+#include <linux/slab.h>
 
 #define VERSION "0.07"
 #define PTAG "solos-pci"
index 6dd3f591996820be5580044d7f14d21043ea30ca..da4b91ffa53e7aade73d36ed12819853ae2ffff6 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/capability.h>
 #include <linux/atm_suni.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/param.h>
 #include <asm/uaccess.h>
index fc8cb07c24779033dd95bfa1e7d3c343bd50836c..c45ae0573bbd2cb69c43f7057f3954ee638b46dc 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/atmdev.h>
 #include <linux/sonet.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
 
index 2e9635be048c2fdb4e8b4773a49464558ba4f351..702accec89e9d3f42aec6ef905d278be4dd65650 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/capability.h>
 #include <linux/bitops.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/system.h>
 #include <asm/string.h>
index eacb175f6bd37a4e5c4314c65a039a1fb04b91d8..49758593a5ba6d79c283df0317ef961b70c62729 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/cdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
index b0ca5a47f47d99dbf5b7572e266091548fb2f407..3fecfb446d90b0e09c257da5950aa4cde7581061 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/fb.h>
 #include <linux/mm.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/cfag12864b.h>
index b9cda053d3c0c20182a264c6da5424fe872c6e5e..8fc200b2e2c0a3ceed42364b467a2ea26b574fcf 100644 (file)
@@ -328,6 +328,7 @@ attribute_container_add_attrs(struct device *classdev)
                return sysfs_create_group(&classdev->kobj, cont->grp);
 
        for (i = 0; attrs[i]; i++) {
+               sysfs_attr_init(&attrs[i]->attr);
                error = device_create_file(classdev, attrs[i]);
                if (error)
                        return error;
index 71f6af5c8b0bdfda4fce6fd9bf83cb82ebdadcf7..12eec3f633b13f0b6e6544a6ce895ff298d4cd84 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/string.h>
 #include "base.h"
index 0147f476b8a9d81be9792aa5572617d910ebaaaa..9c6a0d6408e7b7a609bdd2170c75def1277326ca 100644 (file)
@@ -219,6 +219,8 @@ static void class_create_release(struct class *cls)
  * This is used to create a struct class pointer that can then be used
  * in calls to device_create().
  *
+ * Returns &struct class pointer on success, or ERR_PTR() on error.
+ *
  * Note, the pointer created here is to be destroyed when finished by
  * making a call to class_destroy().
  */
index ef55df34ddd0274e66d7328bad4f230f83884e9a..b56a0ba31d4a0f7f2c677bb20a216bf1698cfe88 100644 (file)
@@ -1345,6 +1345,8 @@ static void root_device_release(struct device *dev)
  * 'module' symlink which points to the @owner directory
  * in sysfs.
  *
+ * Returns &struct device pointer on success, or ERR_PTR() on error.
+ *
  * Note: You probably want to use root_device_register().
  */
 struct device *__root_device_register(const char *name, struct module *owner)
@@ -1432,6 +1434,8 @@ static void device_create_release(struct device *dev)
  * Any further sysfs files that might be required can be created using this
  * pointer.
  *
+ * Returns &struct device pointer on success, or ERR_PTR() on error.
+ *
  * Note: the struct class passed to this function must have previously
  * been created with a call to class_create().
  */
@@ -1492,6 +1496,8 @@ EXPORT_SYMBOL_GPL(device_create_vargs);
  * Any further sysfs files that might be required can be created using this
  * pointer.
  *
+ * Returns &struct device pointer on success, or ERR_PTR() on error.
+ *
  * Note: the struct class passed to this function must have previously
  * been created with a call to class_create().
  */
index 7036e8e96ab89080231f3287f52cac1e801e6d0b..f35719aab3c1f38f046a118e8326d6022a51e2cf 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/topology.h>
 #include <linux/device.h>
 #include <linux/node.h>
+#include <linux/gfp.h>
 
 #include "base.h"
 
@@ -79,24 +80,24 @@ void unregister_cpu(struct cpu *cpu)
 }
 
 #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
-static ssize_t cpu_probe_store(struct sys_device *dev,
-                               struct sysdev_attribute *attr,
-                               const char *buf,
+static ssize_t cpu_probe_store(struct sysdev_class *class,
+                              struct sysdev_class_attribute *attr,
+                              const char *buf,
                               size_t count)
 {
        return arch_cpu_probe(buf, count);
 }
 
-static ssize_t cpu_release_store(struct sys_device *dev,
-                               struct sysdev_attribute *attr,
-                               const char *buf,
+static ssize_t cpu_release_store(struct sysdev_class *class,
+                                struct sysdev_class_attribute *attr,
+                                const char *buf,
                                 size_t count)
 {
        return arch_cpu_release(buf, count);
 }
 
-static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
-static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store);
+static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
+static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
 
 #else /* ... !CONFIG_HOTPLUG_CPU */
index 05dd307e8f024038bfe6e9d762e3dff1dd6281ee..cf7a0c78805278e64f195921b3991c577691da66 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/device.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "base.h"
 
index dac478c6e46089c5bf8070dfa4127659b44fb6ec..057cf11326bff9c84e3e18b24cee28250a49562a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/cred.h>
 #include <linux/sched.h>
 #include <linux/init_task.h>
+#include <linux/slab.h>
 
 static struct vfsmount *dev_mnt;
 
index 962a3b574f21eb4d5d4fed4b84ab91e64b5e453e..d4d8ce53886aa8276165ef151aab2dca46b2ecac 100644 (file)
@@ -2,6 +2,7 @@
  * Coherent per-device memory handling.
  * Borrowed from i386
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/dma-mapping.h>
 
index ca9186f70a695378c9bc9f5e7622d1d601cc6787..763d59c1eb65d0e329a727b1f58953e6ab2bca9b 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 /*
  * Managed DMA API
index 90c9fff09eadff6fbbd2e554e39db3653867ea9c..b631f7c59453c2a51f1ce4d65c6fec458cde51e3 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include "base.h"
 
index d0dc26ad53871df760302961376ed779c58a113c..985da11174e7a139a9269fce26d29ea2f1a0e32b 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kthread.h>
 #include <linux/highmem.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #define to_dev(obj) container_of(obj, struct device, kobj)
 
@@ -78,6 +79,7 @@ firmware_timeout_show(struct class *class,
 /**
  * firmware_timeout_store - set number of seconds to wait for firmware
  * @class: device class pointer
+ * @attr: device attribute pointer
  * @buf: buffer to scan for timeout value
  * @count: number of bytes in @buf
  *
@@ -442,6 +444,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
        fw_priv = dev_get_drvdata(f_dev);
 
        fw_priv->fw = fw;
+       sysfs_bin_attr_init(&fw_priv->attr_data);
        retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
        if (retval) {
                dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
index db0848e54cc639f7ad63d7673cd48e90d570fb34..4f4aa5897b4cee4722fed70a0820df5e49f9d000 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/mutex.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
index 103be9cacb050bc23364cb3718b2ea51734bfc21..f32f2f9b7be5fadb9a6f16300dc91cfcd7065ea3 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include "base.h"
 
index ad43185ec15adebc4d48d80ffb58275b18827da3..985abd7f49a7b5c03282fe6d53f7f8ad647fd095 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/cpu.h>
 #include <linux/device.h>
 #include <linux/swap.h>
+#include <linux/gfp.h>
 
 static struct sysdev_class_attribute *node_state_attrs[];
 
@@ -165,8 +166,11 @@ static ssize_t node_read_distance(struct sys_device * dev,
        int len = 0;
        int i;
 
-       /* buf currently PAGE_SIZE, need ~4 chars per node */
-       BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2);
+       /*
+        * buf is currently PAGE_SIZE in length and each node needs 4 chars
+        * at the most (distance + space or newline).
+        */
+       BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE);
 
        for_each_online_node(i)
                len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
index 1ba9d617d241ba170842eba208b5dca64783960a..4b4b565c835f9c1c6da550fdb7d69ae27396fbf0 100644 (file)
@@ -362,6 +362,8 @@ EXPORT_SYMBOL_GPL(platform_device_unregister);
  * enumeration tasks, they don't fully conform to the Linux driver model.
  * In particular, when such drivers are built as modules, they can't be
  * "hotplugged".
+ *
+ * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
  */
 struct platform_device *platform_device_register_simple(const char *name,
                                                        int id,
@@ -408,6 +410,8 @@ EXPORT_SYMBOL_GPL(platform_device_register_simple);
  * allocated for the device allows drivers using such devices to be
  * unloaded without waiting for the last reference to the device to be
  * dropped.
+ *
+ * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
  */
 struct platform_device *platform_device_register_data(
                struct device *parent,
@@ -559,6 +563,8 @@ EXPORT_SYMBOL_GPL(platform_driver_probe);
  *
  * Use this in legacy-style modules that probe hardware directly and
  * register a single platform device and corresponding platform driver.
+ *
+ * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
  */
 struct platform_device * __init_or_module platform_create_bundle(
                        struct platform_driver *driver,
@@ -1052,9 +1058,11 @@ static __initdata LIST_HEAD(early_platform_driver_list);
 static __initdata LIST_HEAD(early_platform_device_list);
 
 /**
- * early_platform_driver_register
+ * early_platform_driver_register - register early platform driver
  * @epdrv: early_platform driver structure
  * @buf: string passed from early_param()
+ *
+ * Helper function for early_platform_init() / early_platform_init_buffer()
  */
 int __init early_platform_driver_register(struct early_platform_driver *epdrv,
                                          char *buf)
@@ -1106,9 +1114,12 @@ int __init early_platform_driver_register(struct early_platform_driver *epdrv,
 }
 
 /**
- * early_platform_add_devices - add a numbers of early platform devices
+ * early_platform_add_devices - adds a number of early platform devices
  * @devs: array of early platform devices to add
  * @num: number of early platform devices in array
+ *
+ * Used by early architecture code to register early platform devices and
+ * their platform data.
  */
 void __init early_platform_add_devices(struct platform_device **devs, int num)
 {
@@ -1128,8 +1139,12 @@ void __init early_platform_add_devices(struct platform_device **devs, int num)
 }
 
 /**
- * early_platform_driver_register_all
+ * early_platform_driver_register_all - register early platform drivers
  * @class_str: string to identify early platform driver class
+ *
+ * Used by architecture code to register all early platform drivers
+ * for a certain class. If omitted then only early platform drivers
+ * with matching kernel command line class parameters will be registered.
  */
 void __init early_platform_driver_register_all(char *class_str)
 {
@@ -1151,7 +1166,7 @@ void __init early_platform_driver_register_all(char *class_str)
 }
 
 /**
- * early_platform_match
+ * early_platform_match - find early platform device matching driver
  * @epdrv: early platform driver structure
  * @id: id to match against
  */
@@ -1169,7 +1184,7 @@ early_platform_match(struct early_platform_driver *epdrv, int id)
 }
 
 /**
- * early_platform_left
+ * early_platform_left - check if early platform driver has matching devices
  * @epdrv: early platform driver structure
  * @id: return true if id or above exists
  */
@@ -1187,7 +1202,7 @@ static  __init int early_platform_left(struct early_platform_driver *epdrv,
 }
 
 /**
- * early_platform_driver_probe_id
+ * early_platform_driver_probe_id - probe drivers matching class_str and id
  * @class_str: string to identify early platform driver class
  * @id: id to match against
  * @nr_probe: number of platform devices to successfully probe before exiting
@@ -1257,10 +1272,14 @@ static int __init early_platform_driver_probe_id(char *class_str,
 }
 
 /**
- * early_platform_driver_probe
+ * early_platform_driver_probe - probe a class of registered drivers
  * @class_str: string to identify early platform driver class
  * @nr_probe: number of platform devices to successfully probe before exiting
  * @user_only: only probe user specified early platform devices
+ *
+ * Used by architecture code to probe registered early platform drivers
+ * within a certain class. For probe to happen a registered early platform
+ * device matching a registered early platform driver is needed.
  */
 int __init early_platform_driver_probe(char *class_str,
                                       int nr_probe,
index d477f4dc5e514b202aaaa1efe0a6b20b3eeb62e3..941fcb87e52a12765df2aaa2e2ab21267693af9f 100644 (file)
@@ -439,8 +439,23 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
        if (dev->bus && dev->bus->pm) {
                pm_dev_dbg(dev, state, "EARLY ");
                error = pm_noirq_op(dev, dev->bus->pm, state);
+               if (error)
+                       goto End;
        }
 
+       if (dev->type && dev->type->pm) {
+               pm_dev_dbg(dev, state, "EARLY type ");
+               error = pm_noirq_op(dev, dev->type->pm, state);
+               if (error)
+                       goto End;
+       }
+
+       if (dev->class && dev->class->pm) {
+               pm_dev_dbg(dev, state, "EARLY class ");
+               error = pm_noirq_op(dev, dev->class->pm, state);
+       }
+
+End:
        TRACE_RESUME(error);
        return error;
 }
@@ -735,10 +750,26 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
 {
        int error = 0;
 
+       if (dev->class && dev->class->pm) {
+               pm_dev_dbg(dev, state, "LATE class ");
+               error = pm_noirq_op(dev, dev->class->pm, state);
+               if (error)
+                       goto End;
+       }
+
+       if (dev->type && dev->type->pm) {
+               pm_dev_dbg(dev, state, "LATE type ");
+               error = pm_noirq_op(dev, dev->type->pm, state);
+               if (error)
+                       goto End;
+       }
+
        if (dev->bus && dev->bus->pm) {
                pm_dev_dbg(dev, state, "LATE ");
                error = pm_noirq_op(dev, dev->bus->pm, state);
        }
+
+End:
        return error;
 }
 
index 8980feec5d14e37bbbb947bcd91900d147582ff4..9354dc10a3635b25e87ca10fe92babffb9faba9d 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/pm.h>
 #include <linux/device.h>
index 0552258390240ae8f71ebf89d09c4542eff749e9..0182a22c423a910c7e70dfb41730d39b017da794 100644 (file)
@@ -54,6 +54,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/fd.h>
 #include <linux/hdreg.h>
index 3af97d4da2db7ac30dc808da80b036acbd848256..035cefe4045ae76f076f3d56a85b058c3bb68fc7 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/backing-dev.h>
 #include <linux/fs.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <linux/genhd.h>
 #include <linux/netdevice.h>
 #include "aoe.h"
index 62141ec09a227f2637464173f1f52af5bcac9f33..4a1b9e7464aa51e0d529ba920bbc597d5f9a381d 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/completion.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/skbuff.h>
 #include "aoe.h"
index 64a223b0cc2229fb14250dd60fd572b8f8bd9c59..5674bd01d96dffc86a8818f6a62a72207092c71e 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/ata.h>
+#include <linux/slab.h>
 #include <linux/hdreg.h>
 #include <linux/blkdev.h>
 #include <linux/skbuff.h>
index fa67027789aab80ca8c11deccad4e2d3ec225697..0849280bfc1c11adb175e4034126b269f52b3492 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/blkdev.h>
 #include <linux/netdevice.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "aoe.h"
 
 static void dummy_timer(ulong);
index ce0d62cd71b265de46e12447b3a665b10c479131..4d3bc0d49df59394ea550a74c05c4ad0c84c436b 100644 (file)
@@ -4,6 +4,7 @@
  * Ethernet portion of AoE driver
  */
 
+#include <linux/gfp.h>
 #include <linux/hdreg.h>
 #include <linux/blkdev.h>
 #include <linux/netdevice.h>
index c6ddeacb77fdaa2541f55c294ec25dfa0dd7004b..6081e81d5738b3fecb90da4350d7325b6b78d28a 100644 (file)
@@ -15,9 +15,9 @@
 #include <linux/blkdev.h>
 #include <linux/bio.h>
 #include <linux/highmem.h>
-#include <linux/gfp.h>
 #include <linux/radix-tree.h>
 #include <linux/buffer_head.h> /* invalidate_bh_lrus() */
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index b61057e7788219f6a574aa35df82d6e9d532c526..3d6f3d988949f913269d2cd7c5db642319bab6f0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/vmalloc.h>
 #include <linux/string.h>
 #include <linux/drbd.h>
+#include <linux/slab.h>
 #include <asm/kmap_types.h>
 #include "drbd_int.h"
 
index df8ad9660d8f969adff252371ce86be9f2ab4aab..be3374b6846057734b6e6bd75e4f2d64065a84d2 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/uaccess.h>
 #include <linux/fs.h>
 #include <linux/file.h>
-#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/drbd.h>
index 5116c65c07cb71e9384372faaf7a7d9fa8c29d89..034e6dfc878c04778ee0a2862bf0afee2c52ba62 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/genhd.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
index bd112c8c7bcde9b3efdbceadc6fc89d65f6c9ea0..cb69929d917a5a8221a5045eba71f0ebd480ffc2 100644 (file)
@@ -71,7 +71,6 @@
 #include <linux/buffer_head.h>         /* for invalidate_bdev() */
 #include <linux/completion.h>
 #include <linux/highmem.h>
-#include <linux/gfp.h>
 #include <linux/kthread.h>
 #include <linux/splice.h>
 
index 5416c9a606e43694b59dc0dec09075b8257bf964..28db925dbdad9f659cf1fc981df6755729aa5b17 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/mg_disk.h>
+#include <linux/slab.h>
 
 #define MG_RES_SEC (CONFIG_MG_DISK_RES << 1)
 
index cc923a5b430c51d11f0cc4fd1b2c32405c72ca6a..218d091f3c52180106633075f8750db044a11434 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/net.h>
 #include <linux/kthread.h>
index eb2091aa1c19e2abf7ccfdafce320c44f7d14abb..6cd8b705b11be399bca98b3ca44f503c68fbbf98 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <scsi/osd_initiator.h>
 #include <scsi/osd_attributes.h>
 #include <scsi/osd_sec.h>
index e712cd51af1543c75ca13092c1662e551df256f4..c1e5cd029b23bf42562d3e07392f4713e7ab3b47 100644 (file)
@@ -145,6 +145,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/hdreg.h>
index 39c8514442eb7364e42fa868e1c5499f9d3d10c7..ddf19425245dd4004832cd6c7c4343f8ba8764ec 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/miscdevice.h>
 #include <linux/freezer.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_ioctl.h>
 #include <scsi/scsi.h>
index bc95469d33c122018e96ccbc9576370e64c89afd..3b419e3fffa1d4a366b2e1d3b10654e47c06d63f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/ata.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include <asm/lv1call.h>
 #include <asm/ps3stor.h>
index e4460822997293c324e3a5d617ec49acd0801ccd..b3bdb8af89cfad5e80e8ea9d01f5134c1872fbbe 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/cell-regs.h>
 #include <asm/firmware.h>
index 821c2833f9cf343407df6b90367567ac6fd99e3a..e463657569ff06e3039822a62ca888624160eca2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/module.h>
 #include <linux/fd.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/kernel.h>
index 2e889838e819016c8c693cba1d0498595a027565..0536b5b29adcb02ff76c4fcf8b4501668220a6d3 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/blkdev.h>
 #include <linux/timer.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 
 #define DRV_NAME "ub"
index ad1ba393801ae4fe222d0117a1bd7d6a6fedc187..2f9470ff8f7cec7c7d3de70ea0c347a0e92bf4e1 100644 (file)
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
+#include <linux/gfp.h>
 #include <linux/ioctl.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 
 #include <linux/fcntl.h>        /* O_ACCMODE */
index 3c64af05fa82a0fa79dbf26c9cf84c509b54c604..4b12b820c9a62f655e0745b8d2eae87c16d55437 100644 (file)
@@ -1,5 +1,6 @@
 //#define DEBUG
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/virtio.h>
index 1a325fb05c9282745013d53e541e13b7b748d1a8..18a80ff57ce89f821fd3f5910a09207b7f5db605 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/blkpg.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 9c09694b2520cc5a2422416431576a46d0871eaf..82ed403147c06c66143b0d5fdbcf5ddfccdc8232 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/hdreg.h>
 #include <linux/cdrom.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/scatterlist.h>
 
 #include <xen/xen.h>
index 64f941e0f14b07180ebe1089786f1842a22b7b94..9114654b54d9a933b1728830b120a9059bcf24c3 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/blkdev.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #include <asm/setup.h>
 #include <asm/amigahw.h>
index 3126a3d0c45c0e7a43350ad41e45018a39968dab..b50b41d97a7f2d781ebf5e0c58a79e1298171f1b 100644 (file)
@@ -19,6 +19,7 @@
  **/
 
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
index 523d197b9824571a0a9b810f096f2516d794fe62..204727586ee913896b1511e87ceffe3fcf8d6d88 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/kthread.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <net/bluetooth/bluetooth.h>
 
 #define BTM_HEADER_LEN                 4
index 94f1f55f81f0472583d929d6f9f211bd78ecd51c..0dba76aa2232d9231e466ef2e610fffb29513df9 100644 (file)
@@ -19,6 +19,7 @@
  **/
 
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/sdio_ids.h>
 #include <linux/mmc/sdio_func.h>
index 73dbf40c874d956900819ffb6502e620bfcaa917..a7637d72cef6ba42ae2c92715d3ba1b5157449a2 100644 (file)
@@ -6,9 +6,9 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/agp_backend.h>
-#include <linux/gfp.h>
 #include <linux/page-flags.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include "agp.h"
 
 #define AMD_MMBASE     0x14
index c3ab46da51a35da4bfb5a6965a02e4c5d8c96401..ee4f855611b676b589046fad44f1e934bd615896 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/miscdevice.h>
 #include <linux/pm.h>
index 58c57cb2518cc7dcd4322c4bfbd97eeab69afdcb..9d2c97a69cdd2f280aec61be7eb57b32b52b3f66 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include <linux/fs.h>
 #include <linux/agpgart.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include "agp.h"
 #include "compat_ioctl.h"
index c50543966eb22deaf622ff991f888a61e587910a..fb86708e47edb69693969d1be821ba71f2f31715 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/cacheflush.h>
 #include <asm/pgtable.h>
index 58752b70efead7a76ca65c1441574dfa50931a07..056b289a1e89e2452613bbf875e49b28f6db9d16 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/agp_backend.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 #include <asm/acpi-ext.h>
 
index a3e10dc7cc25ff375674a79c510effbcdfc452f9..d41331bc2aa7355ce9491c49a15e821c5a3ba0c4 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/pagemap.h>
@@ -97,6 +98,9 @@ EXPORT_SYMBOL(intel_agp_enabled);
 #define IS_PINEVIEW (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB || \
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_HB)
 
+#define IS_SNB (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \
+               agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
+
 #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_EAGLELAKE_HB || \
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \
@@ -107,8 +111,7 @@ EXPORT_SYMBOL(intel_agp_enabled);
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \
                agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \
-               agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \
-               agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
+               IS_SNB)
 
 extern int agp_memory_reserved;
 
@@ -175,6 +178,10 @@ extern int agp_memory_reserved;
 #define SNB_GMCH_GMS_STOLEN_448M       (0xe << 3)
 #define SNB_GMCH_GMS_STOLEN_480M       (0xf << 3)
 #define SNB_GMCH_GMS_STOLEN_512M       (0x10 << 3)
+#define SNB_GTT_SIZE_0M                        (0 << 8)
+#define SNB_GTT_SIZE_1M                        (1 << 8)
+#define SNB_GTT_SIZE_2M                        (2 << 8)
+#define SNB_GTT_SIZE_MASK              (3 << 8)
 
 static const struct aper_size_info_fixed intel_i810_sizes[] =
 {
@@ -1200,6 +1207,9 @@ static void intel_i9xx_setup_flush(void)
        if (intel_private.ifp_resource.start)
                return;
 
+       if (IS_SNB)
+               return;
+
        /* setup a resource for this object */
        intel_private.ifp_resource.name = "Intel Flush Page";
        intel_private.ifp_resource.flags = IORESOURCE_MEM;
@@ -1438,6 +1448,8 @@ static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
 
 static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
 {
+       u16 snb_gmch_ctl;
+
        switch (agp_bridge->dev->device) {
        case PCI_DEVICE_ID_INTEL_GM45_HB:
        case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB:
@@ -1449,9 +1461,26 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
        case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB:
        case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB:
        case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB:
+               *gtt_offset = *gtt_size = MB(2);
+               break;
        case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB:
        case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB:
-               *gtt_offset = *gtt_size = MB(2);
+               *gtt_offset = MB(2);
+
+               pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
+               switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
+               default:
+               case SNB_GTT_SIZE_0M:
+                       printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
+                       *gtt_size = MB(0);
+                       break;
+               case SNB_GTT_SIZE_1M:
+                       *gtt_size = MB(1);
+                       break;
+               case SNB_GTT_SIZE_2M:
+                       *gtt_size = MB(2);
+                       break;
+               }
                break;
        default:
                *gtt_offset = *gtt_size = KB(512);
index 7e36d2b4f9d4fc863bc5392d588b152a69d8614c..10f24e349a26cf0059c9ba7566a6c3659803ac40 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/agp_backend.h>
-#include <linux/gfp.h>
 #include <linux/page-flags.h>
 #include <linux/mm.h>
 #include <linux/jiffies.h>
index 0d426ae39c850adaa86e379a764ee315767f992f..ffa888cd1c882818aebbe2eea0bedbc1929f439d 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/agp_backend.h>
 #include <asm/sn/addrs.h>
index d89da4ac061f2d0c3aea71b51666039b203537ec..6f48931ac1cec7d9a82aa4ab1d80509876678eb2 100644 (file)
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
 #include <linux/agp_backend.h>
index 2628c7415ea863b07b0caa5064bbf0c0c42f3dfb..e397df3ad98e2f451a51e9bcb91cd3c47deaa610 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
index d8cff909001c1e4cbd68c8aa22f08eb70d08bbdb..555cd93c2ee5124c102ab892b49bc0cd3da3d2c8 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/kernel.h>
 #include <linux/wait.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/miscdevice.h>
index c02db01f736ea46bc536190910a2f4a9e336bfbb..7fef305774dee184ecc0ac34fe0d39b77005ffc7 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/cdev.h>
 #include <linux/list.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
 
index b861c08263a443c653ae948ed774d4c3011a03c3..9824b41629041e6fd610805cd08441e05d532287 100644 (file)
@@ -79,6 +79,7 @@
 #include <linux/bitops.h>
 #include <linux/firmware.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 #include <linux/io.h>
 #include <linux/uaccess.h>
index 85832ab924e662ffa3f1d4cf588c1b5fb7becab2..8a1b28a10ef0af184e4ff4e03e9eaaf4783f97ca 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/slab.h>        /* for kmalloc() and kfree() */
 #include <linux/major.h>
 #include <linux/types.h>
 #include <linux/errno.h>
index 17b044a71e026fc8c943de8ea5bf64c852abc75c..6f5ffe1320f700f330beabd0481e62b5b9a56f48 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/ctype.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
index d400cbd280f2fbb858102f0defb111a583979f3a..5954ee1dc9538c4eb4849f07c1d28e06558782a3 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/interrupt.h>
 #include <linux/tty_flip.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 
 #define DEBUG 
index 9c5eea3ea4deb22b7cb215184b3dd3a9b8a69152..9ded667625ac06c91d1940bf79ba261b65943b59 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/seq_file.h>
 #include <linux/bitops.h>
 #include <linux/clocksource.h>
+#include <linux/slab.h>
 
 #include <asm/current.h>
 #include <asm/uaccess.h>
index 465185fc0f524bb2eb15cc4d3cf251af264a48ae..d3890e8d30e11ef8ba090481b6b1175553b7dd1a 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/freezer.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
@@ -312,6 +313,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
        spin_lock_irqsave(&hp->lock, flags);
        /* Check and then increment for fast path open. */
        if (hp->count++ > 0) {
+               tty_kref_get(tty);
                spin_unlock_irqrestore(&hp->lock, flags);
                hvc_kick();
                return 0;
@@ -319,7 +321,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
 
        tty->driver_data = hp;
 
-       hp->tty = tty;
+       hp->tty = tty_kref_get(tty);
 
        spin_unlock_irqrestore(&hp->lock, flags);
 
@@ -336,6 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
                spin_lock_irqsave(&hp->lock, flags);
                hp->tty = NULL;
                spin_unlock_irqrestore(&hp->lock, flags);
+               tty_kref_put(tty);
                tty->driver_data = NULL;
                kref_put(&hp->kref, destroy_hvc_struct);
                printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
@@ -363,13 +366,18 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
                return;
 
        hp = tty->driver_data;
+
        spin_lock_irqsave(&hp->lock, flags);
+       tty_kref_get(tty);
 
        if (--hp->count == 0) {
                /* We are done with the tty pointer now. */
                hp->tty = NULL;
                spin_unlock_irqrestore(&hp->lock, flags);
 
+               /* Put the ref obtained in hvc_open() */
+               tty_kref_put(tty);
+
                if (hp->ops->notifier_del)
                        hp->ops->notifier_del(hp, hp->data);
 
@@ -389,6 +397,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
                spin_unlock_irqrestore(&hp->lock, flags);
        }
 
+       tty_kref_put(tty);
        kref_put(&hp->kref, destroy_hvc_struct);
 }
 
@@ -424,10 +433,11 @@ static void hvc_hangup(struct tty_struct *tty)
        spin_unlock_irqrestore(&hp->lock, flags);
 
        if (hp->ops->notifier_hangup)
-                       hp->ops->notifier_hangup(hp, hp->data);
+               hp->ops->notifier_hangup(hp, hp->data);
 
        while(temp_open_count) {
                --temp_open_count;
+               tty_kref_put(tty);
                kref_put(&hp->kref, destroy_hvc_struct);
        }
 }
@@ -592,7 +602,7 @@ int hvc_poll(struct hvc_struct *hp)
        }
 
        /* No tty attached, just skip */
-       tty = hp->tty;
+       tty = tty_kref_get(hp->tty);
        if (tty == NULL)
                goto bail;
 
@@ -672,6 +682,8 @@ int hvc_poll(struct hvc_struct *hp)
 
                tty_flip_buffer_push(tty);
        }
+       if (tty)
+               tty_kref_put(tty);
 
        return poll_mask;
 }
@@ -807,7 +819,7 @@ int hvc_remove(struct hvc_struct *hp)
        struct tty_struct *tty;
 
        spin_lock_irqsave(&hp->lock, flags);
-       tty = hp->tty;
+       tty = tty_kref_get(hp->tty);
 
        if (hp->index < MAX_NR_HVC_CONSOLES)
                vtermnos[hp->index] = -1;
@@ -819,18 +831,18 @@ int hvc_remove(struct hvc_struct *hp)
        /*
         * We 'put' the instance that was grabbed when the kref instance
         * was initialized using kref_init().  Let the last holder of this
-        * kref cause it to be removed, which will probably be the tty_hangup
+        * kref cause it to be removed, which will probably be the tty_vhangup
         * below.
         */
        kref_put(&hp->kref, destroy_hvc_struct);
 
        /*
-        * This function call will auto chain call hvc_hangup.  The tty should
-        * always be valid at this time unless a simultaneous tty close already
-        * cleaned up the hvc_struct.
+        * This function call will auto chain call hvc_hangup.
         */
-       if (tty)
-               tty_hangup(tty);
+       if (tty) {
+               tty_vhangup(tty);
+               tty_kref_put(tty);
+       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(hvc_remove);
index 37b0542a4eeb055e52fbe7e137a7cc2f65081ce1..5a80ad68ef22c259a734c2ae987cf5375aafda55 100644 (file)
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt)            KMSG_COMPONENT ": " fmt
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <asm/ebcdic.h>
 #include <linux/ctype.h>
 #include <linux/delay.h>
index 266b858b8f857e9573a8ed568bc8c054974dd7b9..bedc6c1b6fa5ef290db126aa9bef863f9b68fe22 100644 (file)
@@ -74,6 +74,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
 #include <linux/tty.h>
index 91b53eb1c053bff15349b80d6b949abb71ad4fb8..86fe45c19968a14fef860dae956c3827eb2a067c 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include <linux/stop_machine.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 
index 54b0d9ba65cf4e74b7dfde417176cad5e7219f60..9cd0feca318c3e5f7f9bde8bce6932dbc0be4eba 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/hw_random.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-rnm-defs.h>
index 544d9085a8e8088da17604a677471c5f3d6423ae..0bc0cb70210b4bb04b7869c9ffd7ac198950bba7 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/hw_random.h>
+#include <linux/gfp.h>
 
 #define TX4939_RNG_RCSR                0x00000000
 #define TX4939_RNG_ROR(n)      (0x00000018 + (n) * 8)
index ec5e3f8df648ba1e719836a9b8349246005ba685..c6ad4234378d7e5cd0818d839e81c3b641e1d426 100644 (file)
@@ -2272,42 +2272,52 @@ static int create_files(struct bmc_device *bmc)
        bmc->device_id_attr.attr.name = "device_id";
        bmc->device_id_attr.attr.mode = S_IRUGO;
        bmc->device_id_attr.show = device_id_show;
+       sysfs_attr_init(&bmc->device_id_attr.attr);
 
        bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
        bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
        bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
+       sysfs_attr_init(&bmc->provides_dev_sdrs_attr.attr);
 
        bmc->revision_attr.attr.name = "revision";
        bmc->revision_attr.attr.mode = S_IRUGO;
        bmc->revision_attr.show = revision_show;
+       sysfs_attr_init(&bmc->revision_attr.attr);
 
        bmc->firmware_rev_attr.attr.name = "firmware_revision";
        bmc->firmware_rev_attr.attr.mode = S_IRUGO;
        bmc->firmware_rev_attr.show = firmware_rev_show;
+       sysfs_attr_init(&bmc->firmware_rev_attr.attr);
 
        bmc->version_attr.attr.name = "ipmi_version";
        bmc->version_attr.attr.mode = S_IRUGO;
        bmc->version_attr.show = ipmi_version_show;
+       sysfs_attr_init(&bmc->version_attr.attr);
 
        bmc->add_dev_support_attr.attr.name = "additional_device_support";
        bmc->add_dev_support_attr.attr.mode = S_IRUGO;
        bmc->add_dev_support_attr.show = add_dev_support_show;
+       sysfs_attr_init(&bmc->add_dev_support_attr.attr);
 
        bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
        bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
        bmc->manufacturer_id_attr.show = manufacturer_id_show;
+       sysfs_attr_init(&bmc->manufacturer_id_attr.attr);
 
        bmc->product_id_attr.attr.name = "product_id";
        bmc->product_id_attr.attr.mode = S_IRUGO;
        bmc->product_id_attr.show = product_id_show;
+       sysfs_attr_init(&bmc->product_id_attr.attr);
 
        bmc->guid_attr.attr.name = "guid";
        bmc->guid_attr.attr.mode = S_IRUGO;
        bmc->guid_attr.show = guid_show;
+       sysfs_attr_init(&bmc->guid_attr.attr);
 
        bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
        bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
        bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
+       sysfs_attr_init(&bmc->aux_firmware_rev_attr.attr);
 
        err = device_create_file(&bmc->dev->dev,
                           &bmc->device_id_attr);
index be2e8f9a27c336e52bed89e1827e290c243de342..0fa2e4a0835d7b5362bd9623f99f7037db2afa1d 100644 (file)
 #include <linux/timer.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 
 #include <linux/uaccess.h>
 #include <linux/io.h>
index 87c67b42bc08b03a17aaf410705f8c3e6e2d3638..83bef4efe37636869f418756462516d00a4f3ccd 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/uio.h>
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
index 94a136e96c06c69b51aea6c31162606382ff6330..92ab03d282945bfe804ee3b48d3d6f428e4d55b8 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/miscdevice.h>
 #include <linux/kernel.h>
 #include <linux/major.h>
-#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -49,6 +48,7 @@
 #include <linux/device.h>
 #include <linux/tty.h>
 #include <linux/kmod.h>
+#include <linux/gfp.h>
 
 /*
  * Head entry for the doubly linked miscdevice list
index 04fd0d843b3b2871625015e8f88f04d8eeb628ae..ea7c99fa978f9e8d2877ba8a783daeef5214cc5c 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/math64.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/sn/addrs.h>
index 166495d6a1d7dc8acea02b934b3c8c87c0de875b..107b0bd58d1911e028257893490d11542181a210 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index e0c5d2a690464d37138daf88f5842aab027defe0..95c9f54f3d302ea52ed8cb0f59850ddf0ea72f14 100644 (file)
 #include <linux/string.h>
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
-#include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index a3f32a15fde4196ce889b02be3cb2ada16b16d12..a6638003f530ff55688231f2acf09b3e12262b05 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/init.h>
 #include <linux/kfifo.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include <linux/delay.h>
index 5eb83c3ca20de35be340031015a93495ae19e12b..47e8f7b0e4c18d1893e3caba579581e7ee755762 100644 (file)
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/fcntl.h>
 #include <linux/mc146818rtc.h>
index 590762a7f21790d64ea2b65725ff2a88902b1946..65920163f53d5206bb0e8f0f1eca8a2bde278a6c 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/netdevice.h>
 #include <linux/ppp_channel.h>
 #include <linux/ppp_defs.h>
+#include <linux/slab.h>
 #include <linux/if_ppp.h>
 #include <linux/skbuff.h>
 
index 432655bcb04c138f7446d3d1bb08e76cba0f3b51..fdd37543aa79e6d0b159767f791024d4c31e83fb 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/parport.h>
 #include <linux/ctype.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/major.h>
 #include <linux/ppdev.h>
 #include <linux/smp_lock.h>
index f424d394a286415e82c8aafdc634073f916f6521..606048b72bcf2e0adbebf8590a92e4f1b55fd5b5 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #include <asm/lv1call.h>
index 5ee4248172630066c6233631ca71a56a9323f116..d83a43130df433962d7b0764ef6fc9c59f781f81 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/uaccess.h>
 #include <linux/bitops.h>
 #include <linux/devpts_fs.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 
index 64acd05f71c8743330e47a1d9883fc59acc22081..d331c59b571c5c2520787e8a753062a91e2ef22c 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 
index be0ba401966e237bee1daf46dbd2d8ab81baa795..24a282bb89d4bd06fa2d0c82dd52333aad112c19 100644 (file)
@@ -31,7 +31,6 @@
 */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <asm/io.h>
index 71f87600907ce04f1da12bb7d3279650a19c2857..2e71aecae206a434fb72501df914f34e90a6b6fb 100644 (file)
@@ -31,7 +31,6 @@
 */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
index d687c17be15247343b9f0fd0c4f2882a8ae6f089..6415f3f32a724b4549ccf492487a762be18af999 100644 (file)
@@ -31,7 +31,6 @@
 */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
 #include <asm/io.h>
index 706c2a25f7aa137de5f732df4fd62f1c605da178..f9b936ac3394de7e6a4c07b109049ef639b2d546 100644 (file)
@@ -31,7 +31,6 @@
 */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/system.h>
index 47fab7c3307302d3d0b553b61e8276a7e5be0824..8a90393faf3c652e1f8fcce37f4c6c99cf474cd2 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
 #include <linux/string.h>
index 1ec3d5cd748f5e602fbf7813ca7a23266102daeb..8dfd24721a82156e6c7415ecd5274e7a2ad45780 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/tty_flip.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index 55a95892ccf91d1005bad85fab371a7104fabe42..ee156948b9f810d3cd66fbb3ff303e218f884a53 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/unaligned.h>
index bba727c3807e355391df8df0c54385be0af07e5a..73f66d03624dfd2b1e51a0aab8c236fc6ec4c7d6 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/err.h>
 #include <linux/kfifo.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
index 07ac14d949ce2f12dc94ab6e3b3c0a7ae3a32931..2c24fcdc722a920fe00861be3b77fe76f168d2e6 100644 (file)
@@ -94,6 +94,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/uaccess.h>
+#include <linux/gfp.h>
 
 #include "specialix_io8.h"
 #include "cd1865.h"
index 1ae2de7d8b4f333bed6a3bc5e2e63460cb4e1336..59de2525d3030ac972f48295f1b5191513784790 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/workqueue.h>
 #include <linux/hrtimer.h>
 #include <linux/oom.h>
+#include <linux/slab.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq_regs.h>
index f06bb37defb12d300eec4c7f5de67efa3d59b9f8..068c816e69423bb0065100f4599310907eb08bc9 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
 
index bf2170fb1cdd7d1d01581aeb9b5abe129a42d32b..0636520fa9bfc4521e02d5b968dd4329bbbf58fa 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/fs.h>
 #include <linux/security.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <acpi/acpi.h>
 #include "tpm.h"
 
index 70efba2ee05321a8960d6391b9cc742eb953dae7..a605cb7dd89887676d3af3102fde78b2ccbd3c51 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include "tpm.h"
 
 /* National definitions */
index 2405f17b29ddd87994f354e5530f264c726d5761..94345994f8a635c3f610327010eb391add6f6234 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/pnp.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/wait.h>
 #include "tpm.h"
index 283a15bc84e36e562704228958265a56e01071fa..1b8ee590b4caeebf0c2e1a5587d73eef996fe824 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/audit.h>
+#include <linux/slab.h>
 #include <linux/tty.h>
 
 struct tty_audit_buf {
index af8d97715728b4829ec152dcd22b5fa4516e9bbc..7ee52164d474b198d481bd4869da64dab33dbade 100644 (file)
@@ -248,7 +248,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
 {
        int copied = 0;
        do {
-               int goal = min(size - copied, TTY_BUFFER_PAGE);
+               int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
                int space = tty_buffer_request_room(tty, goal);
                struct tty_buffer *tb = tty->buf.tail;
                /* If there is no space then tb may be NULL */
@@ -285,7 +285,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
 {
        int copied = 0;
        do {
-               int goal = min(size - copied, TTY_BUFFER_PAGE);
+               int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
                int space = tty_buffer_request_room(tty, goal);
                struct tty_buffer *tb = tty->buf.tail;
                /* If there is no space then tb may be NULL */
index a42c466f7092e2f519f8428be2669ab964a56575..6da962c9b21c880262a883db546ea1c8c7a99764 100644 (file)
@@ -1423,6 +1423,8 @@ static void release_one_tty(struct work_struct *work)
        list_del_init(&tty->tty_files);
        file_list_unlock();
 
+       put_pid(tty->pgrp);
+       put_pid(tty->session);
        free_tty_struct(tty);
 }
 
index be492dd664370a787b6da7a2b294b3bf53451de6..a3bd1d0b66cfe3fbba3bf9592c0bfbab26bb88a3 100644 (file)
@@ -119,7 +119,7 @@ EXPORT_SYMBOL(tty_port_tty_set);
 static void tty_port_shutdown(struct tty_port *port)
 {
        mutex_lock(&port->mutex);
-       if (port->ops->shutdown &&
+       if (port->ops->shutdown && !port->console &&
                test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags))
                        port->ops->shutdown(port);
        mutex_unlock(&port->mutex);
index 042c8149a6d12248cdbbf2e212628cf497f8f1ea..1144a04cda6e99e91f18b057be2f92f2630edda0 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
index f404ccfc9c20992f342eb366dd21231642d078ea..026ea6c27e07df30a9e777c0f43a70f3258af4b6 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/list.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/virtio.h>
 #include <linux/virtio_console.h>
@@ -681,6 +682,10 @@ static void resize_console(struct port *port)
        struct virtio_device *vdev;
        struct winsize ws;
 
+       /* The port could have been hot-unplugged */
+       if (!port)
+               return;
+
        vdev = port->portdev->vdev;
        if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {
                vdev->config->get(vdev,
@@ -947,11 +952,18 @@ static void handle_control_message(struct ports_device *portdev,
                 */
                err = sysfs_create_group(&port->dev->kobj,
                                         &port_attribute_group);
-               if (err)
+               if (err) {
                        dev_err(port->dev,
                                "Error %d creating sysfs device attributes\n",
                                err);
-
+               } else {
+                       /*
+                        * Generate a udev event so that appropriate
+                        * symlinks can be created based on udev
+                        * rules.
+                        */
+                       kobject_uevent(&port->dev->kobj, KOBJ_CHANGE);
+               }
                break;
        case VIRTIO_CONSOLE_PORT_REMOVE:
                /*
index 8b24729fec89d2ebbee70dc3011d7fd2de670001..12de1202d22cc5b02dabd7362864d5120741cefc 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/fcntl.h>
 #include <linux/major.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/miscdevice.h>
 #include <linux/console.h>
 #include <linux/init.h>
index 87778dcf87277b71c74c6f287558fc1effc40893..6aa10284104aeb6e4bc3a22833ea347e67c5d976 100644 (file)
@@ -888,7 +888,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
                        ret = -EFAULT;
                        goto out;
                }
-               if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS && tmp.mode != VT_PROCESS_AUTO) {
+               if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) {
                        ret = -EINVAL;
                        goto out;
                }
@@ -1622,7 +1622,7 @@ static void complete_change_console(struct vc_data *vc)
         * telling it that it has acquired. Also check if it has died and
         * clean up (similar to logic employed in change_console())
         */
-       if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) {
+       if (vc->vt_mode.mode == VT_PROCESS) {
                /*
                 * Send the signal as privileged - kill_pid() will
                 * tell us if the process has gone or something else
@@ -1682,7 +1682,7 @@ void change_console(struct vc_data *new_vc)
         * vt to auto control.
         */
        vc = vc_cons[fg_console].d;
-       if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) {
+       if (vc->vt_mode.mode == VT_PROCESS) {
                /*
                 * Send the signal as privileged - kill_pid() will
                 * tell us if the process has gone or something else
@@ -1693,28 +1693,27 @@ void change_console(struct vc_data *new_vc)
                 */
                vc->vt_newvt = new_vc->vc_num;
                if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
-                       if(vc->vt_mode.mode == VT_PROCESS)
-                               /*
-                                * It worked. Mark the vt to switch to and
-                                * return. The process needs to send us a
-                                * VT_RELDISP ioctl to complete the switch.
-                                */
-                               return;
-               } else {
                        /*
-                        * The controlling process has died, so we revert back to
-                        * normal operation. In this case, we'll also change back
-                        * to KD_TEXT mode. I'm not sure if this is strictly correct
-                        * but it saves the agony when the X server dies and the screen
-                        * remains blanked due to KD_GRAPHICS! It would be nice to do
-                        * this outside of VT_PROCESS but there is no single process
-                        * to account for and tracking tty count may be undesirable.
+                        * It worked. Mark the vt to switch to and
+                        * return. The process needs to send us a
+                        * VT_RELDISP ioctl to complete the switch.
                         */
-                       reset_vc(vc);
+                       return;
                }
 
                /*
-                * Fall through to normal (VT_AUTO and VT_PROCESS_AUTO) handling of the switch...
+                * The controlling process has died, so we revert back to
+                * normal operation. In this case, we'll also change back
+                * to KD_TEXT mode. I'm not sure if this is strictly correct
+                * but it saves the agony when the X server dies and the screen
+                * remains blanked due to KD_GRAPHICS! It would be nice to do
+                * this outside of VT_PROCESS but there is no single process
+                * to account for and tracking tty count may be undesirable.
+                */
+               reset_vc(vc);
+
+               /*
+                * Fall through to normal (VT_AUTO) handling of the switch...
                 */
        }
 
index 4846d50199f3d1c917d23d2a13aa1108d28cace9..7261b8d9087c01bfea7c8eea55d6f4c61b198b5b 100644 (file)
@@ -86,6 +86,7 @@
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
index 578595c4425d2836cdf283eb44e0e1039e060fa5..744f748cc84b7ee0b16146024af02951531fe69e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
 #include <linux/sh_timer.h>
+#include <linux/slab.h>
 
 struct sh_cmt_priv {
        void __iomem *mapbase;
index 4c8a759e60cdb56c14cf57002a9672f81100822e..5fb78bfd73bb7a3fcc84e5fee62fac0ab6f08ba2 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/err.h>
 #include <linux/clockchips.h>
 #include <linux/sh_timer.h>
+#include <linux/slab.h>
 
 struct sh_mtu2_priv {
        void __iomem *mapbase;
index 961f5b5ef6a3584c558c45dbe20a05074fe325b1..fc9ff1e5b7706e64cfb37e536aca2678afab1228 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
 #include <linux/sh_timer.h>
+#include <linux/slab.h>
 
 struct sh_tmu_priv {
        void __iomem *mapbase;
index 60697909ebdb00c9e0a4546764fe7e283e4fe800..a7f046b0096ca26121a1016922fef359ee4d805c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/ktime.h>
 #include <linux/init.h>
 #include <linux/connector.h>
+#include <linux/gfp.h>
 #include <asm/atomic.h>
 #include <asm/unaligned.h>
 
index 537c29ac4487bea4e4d27313f442ddbbc0f35ddc..1d48f40342cbfadd6834b5edaf06d39dddabe315 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/netlink.h>
 #include <linux/moduleparam.h>
 #include <linux/connector.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
index 5a62d678dd1932f777f17fec0bdbda8d6c9398f9..00d73fc8e4e2853d26d217761a2d2e40a2b22ead 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/sysdev.h>
 #include <linux/cpu.h>
 #include <linux/sysfs.h>
index 8719b36e1a4d9adc858d2327fcac40d66e7df121..0ba9c8b8ee743e960eed3db8e5d9108d7c5eeadc 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 #include <linux/cpu.h>
 
 #include "cpuidle.h"
index 1c3849f6b7a2e6c65d68245c2af3809befe40325..6c4c8b7ce3aa195e5dac4e05f7db38c6051a783b 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 #include <asm/dcr.h>
 #include <asm/dcr-regs.h>
 #include <asm/cacheflush.h>
index 6c6656d3b1e2f25c718f85c654a133e21c3090d5..f17ddf37a1edd3852def9fbe0f4f84b1a5348bca 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/gfp.h>
 
 #include <crypto/ctr.h>
 #include <crypto/des.h>
index b21ef635f3521cbf41f61ff5ce7d01fd45902142..6f29012bcc434dbcc1101782072678991d53a509 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kthread.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include "mv_cesa.h"
 /*
index 8c2f3703ec855f27a6863cb964c5d58a9d01dfa2..2e992bc8015b7bd63bf0c5b4b878b8da1bfa69c4 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/percpu.h>
 #include <linux/smp.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/processor.h>
 #include <asm/i387.h>
index fd529d68c5ba5e2494fc44d0ec33eca8741d951e..dc558a09731105bd5b88a93b46acd6b7211d6e6c 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/io.h>
 #include <linux/spinlock.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 
 #include <crypto/algapi.h>
 #include <crypto/aes.h>
index 52e6bb70a490d8bebf26745191bcf80ce5338ca2..8661c84a105d86751e1990636f6dbcdeb4962cf3 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/notifier.h>
 #include <linux/device.h>
 #include <linux/dca.h>
+#include <linux/slab.h>
 
 #define DCA_VERSION "1.12.1"
 
index ee916c9857eed0896460e6efb65451082ddbe593..5e8f335e6f6ef36145da8ec7461ba15c04f6344c 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kdev_t.h>
 #include <linux/err.h>
 #include <linux/dca.h>
+#include <linux/gfp.h>
 
 static struct class *dca_class;
 static struct idr dca_idr;
index efc1a61ca2310bec0b517d20d7675c3f800f0717..278cf5bceef209ad95b796e184239b71978765ab 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "at_hdmac_regs.h"
 
index 71d58c1a1e862409287ccecb5d874c51fd567e34..9f7e0e6a7eea12e8487cef8fd1395c38cfbdc7a0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/spinlock.h>
 #include <linux/dmapool.h>
 #include <linux/memory.h>
+#include <linux/gfp.h>
 #include <mach/coh901318.h>
 
 #include "coh901318_lli.h"
index 87399cafce37f3036e228a916126a266d0b501b2..d18b5d069d7eb768789a7f99b783b7c632bb2660 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/jiffies.h>
 #include <linux/rculist.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 
 static DEFINE_MUTEX(dma_list_mutex);
 static LIST_HEAD(dma_device_list);
index 6fa55fe3dd248034ef5dc3259755c2ce731be47e..68d58c414cf0d67ad5fa975f6ae144a9b0c40012 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/wait.h>
 
 static unsigned int test_buf_size = 16384;
index bbb4be5a3ff493be3bf35ac07474e43002efd71d..88f470f0d820ae5d599f09bf0452351bab203217 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
index 0099340b96165e326b3682eae05219d7fafcf4b6..3e5a8005c62b9561465609358424acad3c153322 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
index 1ed5d66d7dca0f87f5765bb3ee2242fa684cb7a0..b5ae56c211e6edfd6b1f821f00a872381b309e58 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
index 26febc56dab111470f0eed860a34faea40554e98..6740e319c9cf5422ff4b918c648d4b57e46c97a7 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include "registers.h"
index d545fae30f370f933154a35ba095780fae81e13e..99ec26725bae89699ed758fbee0dd6af9be68582 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/dca.h>
+#include <linux/slab.h>
 #include "dma.h"
 #include "dma_v2.h"
 #include "registers.h"
index ca6e6a0cb7931e32a85b0f9d8da9bb2f5855b63a..1ebc801678b0159e2d7a7017036234160a9493be 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/memory.h>
 #include <linux/ioport.h>
 #include <linux/raid/pq.h>
+#include <linux/slab.h>
 
 #include <mach/adma.h>
 
index c0a272c7368267ad25bd5185e14d5fa965cb2751..bb48a57c2fc1ee291941639754354bf8b7284dc4 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/dmaengine.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <net/tcp.h> /* for memcpy_toiovec */
 #include <asm/io.h>
 #include <asm/uaccess.h>
index 3fdf1f46bd635763772418515ddb1431ff8de574..bbbd58566625cc4b92cb5edf5669528140b03167 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 
index 466ab10c1ff10de1d001178fde9fdce203c410e3..e2fd34da64f2b2d2930c6fedb00d0aee5a02396a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
index e69d87f24a257210c14381722617246a1fd184d7..d44626fa35ad08c14c3cb3c6f7a8eb91b655b5b6 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/proc_fs.h>
 #include <linux/of.h>
index 5d17e09cb625412beaf0e8275f39142b7006a4c1..7cc31b3f40d810c2d3ad6c93b312399146f254b8 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
index 2b95f1a3edfc318fe93ebf58b9bbd89cc8035599..f2330f81cb5ea9b05f5a6c229737f627d5dba601 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 3d50274f1348d97b6e3cc4bc9d9f071e73ebb2ec..1609a19df49532b735a6170fe7f56c01114099b6 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/edac.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 
 #include "edac_core.h"
 #include "edac_module.h"
index 243e9aacad69dd28cbcbf58893670f2ac9856bce..ae3f80c54198a29918f3809b1299918a330277ac 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index c7d11cc4e21a5d608c96695f64cb29d78fb54f15..1731d7245816fdedf681d14a5b9290acdeb11a1f 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 5fdedbc0f54529de3ef0e8b79a5a49ef6f0f5259..070968178a24a80703708dd50ba363301ad71aac 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/ctype.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "edac_core.h"
 #include "edac_module.h"
index 88840e9fa3e09c200d01b5fb733df7746d32091a..418b65f1a1da858c5b127c863ced032f773424e1 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/bug.h>
 
 #include "edac_core.h"
index 8fc91a019620d57fab83e04ed34fac8d826f0e32..f5b6d9fe4def622c3a39cd872429a9dcf34ef57f 100644 (file)
@@ -316,7 +316,12 @@ void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
                if (regs->nbsh & K8_NBSH_ERR_CPU_VAL)
                        pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf));
        } else {
-               pr_cont(", core: %d\n", fls((regs->nbsh & 0xf) - 1));
+               u8 assoc_cpus = regs->nbsh & 0xf;
+
+               if (assoc_cpus > 0)
+                       pr_cont(", core: %d", fls(assoc_cpus) - 1);
+
+               pr_cont("\n");
        }
 
        pr_emerg("%s.\n", EXT_ERR_MSG(xec));
index bef94e3d99444eddaa6f6a149a9ba6fe005b073e..c39697df9cb41e87c8177c76bab788b85567003e 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <linux/module.h>
 #include <linux/sysdev.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 
 #include "edac_core.h"
index 6c9a0f2a593cd89fbc998182798bf1e21894d5ea..c0510b3d7035314ecaf89f0bf97ba8092b051f29 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index fde4db91c4d2c193d117676c15170d6d06df28aa..d41f9002da45d403eb8bc36ca5cc1dccaf477490 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include <linux/io.h>
 #include "edac_core.h"
index 7785d8ffa40486841e3d3f09d66f50416fb91b6e..ee9753cf362ce04901b9924fa82d43a58c3a8224 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include <linux/delay.h>
 #include <linux/mmzone.h>
index 577760a82a0f7d5519cd2631ccf1d7fd99f3ec05..7f3884fcbd467426ad4beec3c53fe91ec99ad46b 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
 
-#include <linux/slab.h>
 
 #include <linux/edac.h>
 #include "edac_core.h"
index c0088ba9672b754429d0bcd8bea19329f36c4064..b8a95cf50718b8e6ef15f74a9c12d49b2b486568 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index b2d83b95033d382c3d2818c56533287ff4d77d67..b2fd1e899142a15d0020f618e79f218e366a0676 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 2eed3ea2cf621303320aec118f0ed3bcfcd9764f..3218819b7286008c908f53869506a73063fa9a57 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 94cac0aacea301babafb4abb3ef3cfad3170bae0..4471647b4807eadb31b6e4e278a5298bcfed97e8 100644 (file)
  */
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/ctype.h>
 #include <linux/io.h>
 #include <linux/mod_devicetable.h>
 #include <linux/edac.h>
 #include <linux/smp.h>
+#include <linux/gfp.h>
 
 #include <linux/of_platform.h>
 #include <linux/of_device.h>
index a6b9fec13a74cd4a8afb8a10a89c55e240a7fa86..7e5ff367705c66c25f8ad914772729a04cf585f4 100644 (file)
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/edac.h>
+#include <linux/gfp.h>
 
 #include "edac_core.h"
 #include "edac_module.h"
index 8e6b91bd2e99994525cba93fbdaac6750ec6da23..7f71ee43674486fe3051013729b7b287225f4619 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 9900675e9598c25006dd696f6f4d20af3694a223..d55f8e9de78878fc4379645fb26631b487f4cb7c 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index d4ec6059317604e40aae2e705b50f636dc26c4b9..b6f47de152f31f4130938e04c468b1bbe7933a00 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/slab.h>
 #include <linux/edac.h>
 #include "edac_core.h"
 
index 8be720b278b7a435d2c106794c2cd663438c92a7..702dcc98c074f853c29b8e74c6700202e10b6aa6 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/mutex.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/time.h>
index 5db0518c66da687068c5ede57bce232fb4463283..4b8523f00dce3c1e006bcf05a0c17a608d58d939 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/rwsem.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/workqueue.h>
@@ -126,97 +127,74 @@ int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)
 }
 EXPORT_SYMBOL(fw_csr_string);
 
-static bool is_fw_unit(struct device *dev);
-
-static int match_unit_directory(const u32 *directory, u32 match_flags,
-                               const struct ieee1394_device_id *id)
+static void get_ids(const u32 *directory, int *id)
 {
        struct fw_csr_iterator ci;
-       int key, value, match;
+       int key, value;
 
-       match = 0;
        fw_csr_iterator_init(&ci, directory);
        while (fw_csr_iterator_next(&ci, &key, &value)) {
-               if (key == CSR_VENDOR && value == id->vendor_id)
-                       match |= IEEE1394_MATCH_VENDOR_ID;
-               if (key == CSR_MODEL && value == id->model_id)
-                       match |= IEEE1394_MATCH_MODEL_ID;
-               if (key == CSR_SPECIFIER_ID && value == id->specifier_id)
-                       match |= IEEE1394_MATCH_SPECIFIER_ID;
-               if (key == CSR_VERSION && value == id->version)
-                       match |= IEEE1394_MATCH_VERSION;
+               switch (key) {
+               case CSR_VENDOR:        id[0] = value; break;
+               case CSR_MODEL:         id[1] = value; break;
+               case CSR_SPECIFIER_ID:  id[2] = value; break;
+               case CSR_VERSION:       id[3] = value; break;
+               }
        }
+}
+
+static void get_modalias_ids(struct fw_unit *unit, int *id)
+{
+       get_ids(&fw_parent_device(unit)->config_rom[5], id);
+       get_ids(unit->directory, id);
+}
+
+static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
+{
+       int match = 0;
+
+       if (id[0] == id_table->vendor_id)
+               match |= IEEE1394_MATCH_VENDOR_ID;
+       if (id[1] == id_table->model_id)
+               match |= IEEE1394_MATCH_MODEL_ID;
+       if (id[2] == id_table->specifier_id)
+               match |= IEEE1394_MATCH_SPECIFIER_ID;
+       if (id[3] == id_table->version)
+               match |= IEEE1394_MATCH_VERSION;
 
-       return (match & match_flags) == match_flags;
+       return (match & id_table->match_flags) == id_table->match_flags;
 }
 
+static bool is_fw_unit(struct device *dev);
+
 static int fw_unit_match(struct device *dev, struct device_driver *drv)
 {
-       struct fw_unit *unit = fw_unit(dev);
-       struct fw_device *device;
-       const struct ieee1394_device_id *id;
+       const struct ieee1394_device_id *id_table =
+                       container_of(drv, struct fw_driver, driver)->id_table;
+       int id[] = {0, 0, 0, 0};
 
        /* We only allow binding to fw_units. */
        if (!is_fw_unit(dev))
                return 0;
 
-       device = fw_parent_device(unit);
-       id = container_of(drv, struct fw_driver, driver)->id_table;
+       get_modalias_ids(fw_unit(dev), id);
 
-       for (; id->match_flags != 0; id++) {
-               if (match_unit_directory(unit->directory, id->match_flags, id))
+       for (; id_table->match_flags != 0; id_table++)
+               if (match_ids(id_table, id))
                        return 1;
 
-               /* Also check vendor ID in the root directory. */
-               if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
-                   match_unit_directory(&device->config_rom[5],
-                               IEEE1394_MATCH_VENDOR_ID, id) &&
-                   match_unit_directory(unit->directory, id->match_flags
-                               & ~IEEE1394_MATCH_VENDOR_ID, id))
-                       return 1;
-       }
-
        return 0;
 }
 
 static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
 {
-       struct fw_device *device = fw_parent_device(unit);
-       struct fw_csr_iterator ci;
+       int id[] = {0, 0, 0, 0};
 
-       int key, value;
-       int vendor = 0;
-       int model = 0;
-       int specifier_id = 0;
-       int version = 0;
-
-       fw_csr_iterator_init(&ci, &device->config_rom[5]);
-       while (fw_csr_iterator_next(&ci, &key, &value)) {
-               switch (key) {
-               case CSR_VENDOR:
-                       vendor = value;
-                       break;
-               case CSR_MODEL:
-                       model = value;
-                       break;
-               }
-       }
-
-       fw_csr_iterator_init(&ci, unit->directory);
-       while (fw_csr_iterator_next(&ci, &key, &value)) {
-               switch (key) {
-               case CSR_SPECIFIER_ID:
-                       specifier_id = value;
-                       break;
-               case CSR_VERSION:
-                       version = value;
-                       break;
-               }
-       }
+       get_modalias_ids(unit, id);
 
        return snprintf(buffer, buffer_size,
                        "ieee1394:ven%08Xmo%08Xsp%08Xver%08X",
-                       vendor, model, specifier_id, version);
+                       id[0], id[1], id[2], id[3]);
 }
 
 static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
index 1c0b504a42f3068e852fa1b7423ee5c37bfb0abd..3784a47865b7d3a5642bbc96643617c4a0e44daa 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/firewire-constants.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/vmalloc.h>
 
@@ -331,8 +332,9 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
        if (ret < 0)
                *bandwidth = 0;
 
-       if (allocate && ret < 0 && c >= 0) {
-               deallocate_channel(card, irm_id, generation, c, buffer);
+       if (allocate && ret < 0) {
+               if (c >= 0)
+                       deallocate_channel(card, irm_id, generation, c, buffer);
                *channel = ret;
        }
 }
index 2d3dc7ded0a94d88fd80e8506685e755ce09113e..7142eeec8074374d87109ec98d65f78d28bd0e74 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <asm/unaligned.h>
index 75dc6988cffd5d174ae8eb5445b5ce8744e0f4b0..0cf4d7f562c5a023670a0756c810ae5f360443e5 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/firewire.h>
 #include <linux/firewire-constants.h>
-#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -35,6 +34,7 @@
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 
@@ -231,6 +231,8 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
 
 static char ohci_driver_name[] = KBUILD_MODNAME;
 
+#define PCI_DEVICE_ID_TI_TSB12LV22     0x8009
+
 #define QUIRK_CYCLE_TIMER              1
 #define QUIRK_RESET_PACKET             2
 #define QUIRK_BE_HEADERS               4
@@ -239,6 +241,8 @@ static char ohci_driver_name[] = KBUILD_MODNAME;
 static const struct {
        unsigned short vendor, device, flags;
 } ohci_quirks[] = {
+       {PCI_VENDOR_ID_TI,      PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER |
+                                                           QUIRK_RESET_PACKET},
        {PCI_VENDOR_ID_TI,      PCI_ANY_ID,     QUIRK_RESET_PACKET},
        {PCI_VENDOR_ID_AL,      PCI_ANY_ID,     QUIRK_CYCLE_TIMER},
        {PCI_VENDOR_ID_NEC,     PCI_ANY_ID,     QUIRK_CYCLE_TIMER},
index 18d65fb42ee71850d0914f5fd44cd6a91eaf3111..fb09bb3c0ad6bb9d418b2078e139d9215c0fa816 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/mc146818rtc.h>
index b3a0cf57442e440c55d6da83f6213969715448a5..3a4460265b10e094cc5b8df72fc450a9dee44b3e 100644 (file)
@@ -36,6 +36,7 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/blkdev.h>
index dbdf6fadfc795f5378b71fa2dec7fa09521971fe..a777a35381d2ca80ac0dd8846d860d650ef7bf00 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/dmi.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 struct dmi_device_attribute{
        struct device_attribute dev_attr;
index 31b983d9462c7c9f5a01b87fa0a449076bd12aa1..d46467271349d79adbabd04a76bb55a7b7cff19f 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/dmi.h>
 #include <linux/efi.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
 #include <asm/dmi.h>
 
 /*
index 082f06ecd327e0db54087f49ab104b50b23c78f9..81b70bd075861c97b0d529c27237c2036f492eed 100644 (file)
@@ -77,6 +77,7 @@
 #include <linux/sysfs.h>
 #include <linux/kobject.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index dfb15c06c88ff8482de2b03164679633748848b7..134dd7328397a123bf8613ebd4a395203a825634 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/limits.h>
 #include <linux/module.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/types.h>
index d59f7cad2269d817d21e8eebb3044a97c0b8435b..adc07102a20d0caef9fc98290f25be6c5b2b6a3d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 
 /*
  * Data types ------------------------------------------------------------------
index 0f93105873cd263b61bb9c2af47007622e6c2f33..9f278153700121850982f626afd925d3fdf6780f 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
index afc097a16b3330393f08b544d4baf87b19d81029..2e8e9e24f887ff790e7866d2ac1e1f27b906ac89 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/gpio.h>
index 2559f2289409f13c431bd60d9ff95a503813b8b1..aa4f09ad3cede46381641831d0b00a305f9c9099 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 /* Steal the hardware definitions from the bttv driver. */
 #include "../media/video/bt8xx/bt848.h"
index 6d1b86661e633410b5698ca075047fa2f62a12a2..76be229c814d40479f37d158c9cc1532a94e9b33 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/seq_file.h>
 #include <linux/gpio.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 
 
 /* Optional implementation infrastructure for GPIO interfaces.
index 6c0ebbdc659ee3bdba7fa17256b74462c4858ff2..00c3a14127af0059b08206fd49eabf07f8ed4cd9 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 struct lnw_gpio_register {
        u32     GPLR[2];
index 9d74eef1157ad4b9c5adb2bcddad5436bc8b565a..962f661c18c72d65a4f68a01e639e4b24159e0dd 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mutex.h>
 #include <linux/i2c.h>
 #include <linux/spi/max7301.h>
+#include <linux/slab.h>
 
 static int max7300_i2c_write(struct device *dev, unsigned int reg,
                                unsigned int val)
index 965d9b1ea13edf88f53ba780aa3fa2c57be48d36..92a100ddef6bb506d599fd9bd36343c541979b1e 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/max7301.h>
 
index c9bced55f82bc501288d90f8d5536b27e6e9a848..7696a5625d58c1944d8e15a72cf0f4768ff3f550 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/mutex.h>
 #include <linux/spi/max7301.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 /*
  * Pin configurations, see MAX7301 datasheet page 6
@@ -242,3 +243,7 @@ int __devexit __max730x_remove(struct device *dev)
        return ret;
 }
 EXPORT_SYMBOL_GPL(__max730x_remove);
+
+MODULE_AUTHOR("Juergen Beisert, Wolfram Sang");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("MAX730x GPIO-Expanders, generic parts");
index e7d01bd8fdb3cd1bc6e60834e1b12e28aa6bffb1..935479da6705b3161213521b8791f2ebf7633193 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/mc33880.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "mc33880"
 
index cd651ec8d0349e1621e0ef941dea3db489d86c0c..69f6f1955a31a650f31a9d9113c031a18b44a901 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/mcp23s08.h>
+#include <linux/slab.h>
 
 
 /* Registers are all 8 bits wide.
index ab5daab14bc2589e884316018ddaf0a2fc9a0d62..7d521e1d17e14e9802dfa4b70154c4dcfe4c989b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/irq.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/slab.h>
 #ifdef CONFIG_OF_GPIO
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
index 3ad1eeb496099cceb8118d5666460377aec8d5d0..5ad8f778ced4b2f4388dd75710233666b936c5ef 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/pl061.h>
+#include <linux/slab.h>
 
 #define GPIODIR 0x400
 #define GPIOIS  0x404
index d4295fa5369e4bc129e498b69be67ba52ac645ee..ac4d0f0ea02bb362ef6d210884d3c25f7c33c01f 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/io.h>
 #include <linux/timb_gpio.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "timb-gpio"
 
index 7fe881e2bdfb7c4cb5044b12bb9b5160ba8d47a4..57635ac35a73d6408785861e3aa8f2bb46508098 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 
 #include <linux/i2c/twl.h>
 
index d09021f4a7d38042dceed014643fb3a84b52423e..1fa449a1a4cb9f5df485ee505bb3263aeaac120c 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
 #include <linux/mfd/core.h>
index 511840d1c7ba601616585a3ddacd7969c3400a05..359999290f5585783a3d0a6ffdb68e9693778875 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
 #include <linux/mfd/core.h>
index de28b4a470eaf8b188ea27941455276af4767051..7607cc61e1ddfd70c9520b61707710fcf4e9143d 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
 #include <linux/mfd/core.h>
index 3c1177abebd30c5b620114925faa32b5741d592d..b8fa65b5bfca56ca8320e23916d45dbc56a68b1c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/of_gpio.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 /* Register Offset Definitions */
 #define XGPIO_DATA_OFFSET   (0x0)      /* Data register  */
index d68888fe3df997e21a489d13e94ab4da433a46f5..ba38e0147220e7b199b73b9d0d13804ff80254f3 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "drmP.h"
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #if __OS_HAS_AGP
 
index 8417cc4c43f1104a5ae6bfe35e28936db9f5235a..f7ba82ebf65ae03ead6f466d9f2579cc753a0c95 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/log2.h>
 #include <asm/shmparam.h>
 #include "drmP.h"
index d91fb8c0b7b31673f43b885e8b0c38b0c1b6ec50..61b9bcfdf040d134403de46acbfd592b23819cdd 100644 (file)
@@ -30,6 +30,7 @@
  *      Jesse Barnes <jesse.barnes@intel.com>
  */
 #include <linux/list.h>
+#include <linux/slab.h>
 #include "drm.h"
 #include "drmP.h"
 #include "drm_crtc.h"
index f2aaf39be3981944fefc63a23fd8edcc9e3a614f..51103aa469f8c1bf773859e6176a004076a70e9a 100644 (file)
@@ -104,6 +104,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
        if (connector->status == connector_status_disconnected) {
                DRM_DEBUG_KMS("%s is disconnected\n",
                          drm_get_connector_name(connector));
+               drm_mode_connector_update_edid_property(connector, NULL);
                goto prune;
        }
 
index 9903f270e4409c8239add50adc2a3db80ca56623..677b275fa721affe2fec2508e780c1b1970f4f73 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 
 #if defined(CONFIG_DEBUG_FS)
index 548887c8506fa018139c2d83b29a50fd90c2b436..f7eba0a0973a78ce12669b878711a9983f14cbdb 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
index f3c58e2bd75cde20720712d3416229bcece0bb27..4a66201edaec0ea89ccc9d791a67f29d2ea58245 100644 (file)
@@ -47,6 +47,7 @@
  */
 
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm_core.h"
 
index f97e7c42ac8e1f7bdf53573e491feb0a80f2989f..2cc6e87d849d6d9f16271fdd0c17032aa4a8d5a6 100644 (file)
@@ -27,6 +27,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 #include "drmP.h"
@@ -707,15 +708,6 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
        mode->vsync_end = mode->vsync_start + vsync_pulse_width;
        mode->vtotal = mode->vdisplay + vblank;
 
-       /* perform the basic check for the detailed timing */
-       if (mode->hsync_end > mode->htotal ||
-               mode->vsync_end > mode->vtotal) {
-               drm_mode_destroy(dev, mode);
-               DRM_DEBUG_KMS("Incorrect detailed timing. "
-                               "Sync is beyond the blank.\n");
-               return NULL;
-       }
-
        /* Some EDIDs have bogus h/vtotal values */
        if (mode->hsync_end > mode->htotal)
                mode->htotal = mode->hsync_end + 1;
index 50549703584f5b7d91c54d24f037dfa5d26f5ebc..288ea2f327720b17992d7332f333f717f34f1adc 100644 (file)
@@ -29,6 +29,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/sysrq.h>
+#include <linux/slab.h>
 #include <linux/fb.h>
 #include "drmP.h"
 #include "drm_crtc.h"
@@ -283,6 +284,8 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
        .help_msg = "force-fb(V)",
        .action_msg = "Restore framebuffer console",
 };
+#else
+static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
 static void drm_fb_helper_on(struct fb_info *info)
index 08d14df3bb422d41bd561eea171d4cd91a662a3e..9d532d7fdf59a8e551233c1c44ef730eb22778ca 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "drmP.h"
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 
 static int drm_open_helper(struct inode *inode, struct file *filp,
@@ -140,14 +141,16 @@ int drm_open(struct inode *inode, struct file *filp)
                spin_unlock(&dev->count_lock);
        }
 out:
-       mutex_lock(&dev->struct_mutex);
-       if (minor->type == DRM_MINOR_LEGACY) {
-               BUG_ON((dev->dev_mapping != NULL) &&
-                       (dev->dev_mapping != inode->i_mapping));
-               if (dev->dev_mapping == NULL)
-                       dev->dev_mapping = inode->i_mapping;
+       if (!retcode) {
+               mutex_lock(&dev->struct_mutex);
+               if (minor->type == DRM_MINOR_LEGACY) {
+                       if (dev->dev_mapping == NULL)
+                               dev->dev_mapping = inode->i_mapping;
+                       else if (dev->dev_mapping != inode->i_mapping)
+                               retcode = -ENODEV;
+               }
+               mutex_unlock(&dev->struct_mutex);
        }
-       mutex_unlock(&dev->struct_mutex);
 
        return retcode;
 }
index f36b21c5b2e1501ac3950b7d4521e00570f93558..a93d7b4ddaa6a75c795e88113d6faf07fe3f9024 100644 (file)
@@ -35,6 +35,7 @@
 #include "drmP.h"
 #include "drm_hashtab.h"
 #include <linux/hash.h>
+#include <linux/slab.h>
 
 int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
 {
index b98384dbd9a7ace015a358c6085b01dc5de0a620..3bd872761567bebf2c23441746d908b41ff9b43e 100644 (file)
@@ -36,6 +36,7 @@
 #include "drmP.h"
 
 #include <linux/interrupt.h>   /* For task queue support */
+#include <linux/slab.h>
 
 #include <linux/vgaarb.h>
 /**
index e68ebf92fa2a5187c0e6b56a5e089a26d0516da2..2ea9ad4a8d699847bb4e8a7d0f1e7dc58ace90e4 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include "drmP.h"
 
index d379c4f2892f1bad75b1d1e9eedd7c1afd127d5c..a9ba6b69ad3526dacce63039457f0c48f961e3db 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 
 /***************************************************
index c7823c863d4f35fb85b0fc5056b19cd08da4b336..9034c4c6100dd2352c78b8b6d207001b0ce53bb5 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include "drmP.h"
 
 #define DEBUG_SCATTER 0
index ad73e141afdbd8096e2908d75e5849962ae1f069..b743411d814422f578bd2cf3858cbe7c7f3fa948 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm_core.h"
 
index 014ce24761b98f60b0ed9f8dead7327d2a26f1cf..1a1825b29f5f096c7d5fc31bbfb0dea7f9101b42 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/device.h>
 #include <linux/kdev_t.h>
+#include <linux/gfp.h>
 #include <linux/err.h>
 
 #include "drm_sysfs.h"
index 4ac900f4647f521be90a1279a18a452c21ee48bd..c3b13fb41d0cd557dcf1bf2897d9a5b331356828 100644 (file)
@@ -36,6 +36,7 @@
 #include "drmP.h"
 #if defined(__ia64__)
 #include <linux/efi.h>
+#include <linux/slab.h>
 #endif
 
 static void drm_vm_open(struct vm_area_struct *vma);
index de32d22a8c3974fecb41f64c32af246aa1764eb9..997d91707ad217f545c9720c0b0b9a604617f7e2 100644 (file)
@@ -36,6 +36,7 @@
 #include "i810_drv.h"
 #include <linux/interrupt.h>   /* For task queue support */
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 
 #define I810_BUF_FREE          2
index 06bd732e6463b23e6ed9968e5500299bd37bcd9e..65759a9a85c8e425714c3281f080880eaaf8d0fc 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/interrupt.h>   /* For task queue support */
 #include <linux/pagemap.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #define I830_BUF_FREE          2
index 1376dfe44c952a2ec9ae9bed4ad1befa10c1bcb3..b574503dddd0eb1f95db2912a7023fcc2010a198 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "i915_drm.h"
index 8bfc0bbf13e658fd050457c87cfa57f3c8857e8f..2dc93939507d0fba845426298083bb2c2e604099 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/acpi.h>
 #include <linux/pnp.h>
 #include <linux/vga_switcheroo.h>
+#include <linux/slab.h>
 
 /* Really want an OS-independent resettable timer.  Would like to have
  * this loop run for (eg) 3 sec, but have the timer reset every time
@@ -1881,29 +1882,29 @@ struct drm_ioctl_desc i915_ioctls[] = {
        DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE,  i915_vblank_pipe_get, DRM_AUTH ),
        DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
-       DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, 0),
-       DRM_IOCTL_DEF(DRM_I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW),
-       DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW),
+       DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+       DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
index 1b2e95455c05d0cce04d17483c7bd4ff9f218fe0..4b26919abdb27b2645f58de590a19a44f2192908 100644 (file)
@@ -139,12 +139,12 @@ const static struct intel_device_info intel_ironlake_m_info = {
 
 const static struct intel_device_info intel_sandybridge_d_info = {
        .is_i965g = 1, .is_i9xx = 1, .need_gfx_hws = 1,
-       .has_hotplug = 1,
+       .has_hotplug = 1, .is_gen6 = 1,
 };
 
 const static struct intel_device_info intel_sandybridge_m_info = {
        .is_i965g = 1, .is_mobile = 1, .is_i9xx = 1, .need_gfx_hws = 1,
-       .has_hotplug = 1,
+       .has_hotplug = 1, .is_gen6 = 1,
 };
 
 const static struct pci_device_id pciidlist[] = {
index 979439cfb827998f9301a1bcee3626957828c268..aba8260fbc5ed6cb7510a22dd961681d02ccaa6d 100644 (file)
@@ -205,6 +205,7 @@ struct intel_device_info {
        u8 is_g4x : 1;
        u8 is_pineview : 1;
        u8 is_ironlake : 1;
+       u8 is_gen6 : 1;
        u8 has_fbc : 1;
        u8 has_rc6 : 1;
        u8 has_pipe_cxsr : 1;
@@ -1084,6 +1085,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
 #define IS_IRONLAKE_M(dev)     ((dev)->pci_device == 0x0046)
 #define IS_IRONLAKE(dev)       (INTEL_INFO(dev)->is_ironlake)
 #define IS_I9XX(dev)           (INTEL_INFO(dev)->is_i9xx)
+#define IS_GEN6(dev)           (INTEL_INFO(dev)->is_gen6)
 #define IS_MOBILE(dev)         (INTEL_INFO(dev)->is_mobile)
 
 #define IS_GEN3(dev)   (IS_I915G(dev) ||                       \
@@ -1107,8 +1109,6 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
 
 #define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
 
-#define IS_GEN6(dev)   ((dev)->pci_device == 0x0102)
-
 /* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
  * rows, which changed the alignment requirements and fence programming.
  */
index fba37e9f775d6fefdacaacfd0bd0868f6075328f..368d726853d18f94695fd2c1ab8d7f4efed2c66b 100644 (file)
@@ -31,6 +31,7 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/pci.h>
 
@@ -1466,9 +1467,6 @@ i915_gem_object_put_pages(struct drm_gem_object *obj)
                obj_priv->dirty = 0;
 
        for (i = 0; i < page_count; i++) {
-               if (obj_priv->pages[i] == NULL)
-                       break;
-
                if (obj_priv->dirty)
                        set_page_dirty(obj_priv->pages[i]);
 
@@ -2227,11 +2225,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
                                seqno = i915_add_request(dev, NULL, obj->write_domain);
                                if (seqno == 0)
                                        return -ENOMEM;
-
-                               ret = i915_wait_request(dev, seqno);
-                               if (ret)
-                                       return ret;
-
                                continue;
                        }
                }
@@ -2256,7 +2249,6 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
        struct address_space *mapping;
        struct inode *inode;
        struct page *page;
-       int ret;
 
        if (obj_priv->pages_refcount++ != 0)
                return 0;
@@ -2279,11 +2271,9 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
                                           mapping_gfp_mask (mapping) |
                                           __GFP_COLD |
                                           gfpmask);
-               if (IS_ERR(page)) {
-                       ret = PTR_ERR(page);
-                       i915_gem_object_put_pages(obj);
-                       return ret;
-               }
+               if (IS_ERR(page))
+                       goto err_pages;
+
                obj_priv->pages[i] = page;
        }
 
@@ -2291,6 +2281,15 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
                i915_gem_object_do_bit_17_swizzle(obj);
 
        return 0;
+
+err_pages:
+       while (i--)
+               page_cache_release(obj_priv->pages[i]);
+
+       drm_free_large(obj_priv->pages);
+       obj_priv->pages = NULL;
+       obj_priv->pages_refcount--;
+       return PTR_ERR(page);
 }
 
 static void sandybridge_write_fence_reg(struct drm_i915_fence_reg *reg)
@@ -4730,6 +4729,11 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
                        ring->space += ring->Size;
        }
 
+       if (IS_I9XX(dev) && !IS_GEN3(dev)) {
+               I915_WRITE(MI_MODE,
+                          (VS_TIMER_DISPATCH) << 16 | VS_TIMER_DISPATCH);
+       }
+
        return 0;
 }
 
index b5c55d88ff76f260f87a0dc64b140739dcc7ec4f..c01c878e51baf3ff206388c32312f685a73156f5 100644 (file)
@@ -325,9 +325,12 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
                 * need to ensure that any fence register is cleared.
                 */
                if (!i915_gem_object_fence_offset_ok(obj, args->tiling_mode))
-                   ret = i915_gem_object_unbind(obj);
+                       ret = i915_gem_object_unbind(obj);
+               else if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
+                       ret = i915_gem_object_put_fence_reg(obj);
                else
-                   ret = i915_gem_object_put_fence_reg(obj);
+                       i915_gem_release_mmap(obj);
+
                if (ret != 0) {
                        WARN(ret != -ERESTARTSYS,
                             "failed to reset object for tiling switch");
index 5388354da0d176df4ff2a3b7c33de069abff12da..49c458bc650242c5a6340e4737c95d124499f9d1 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/sysrq.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "i915_drm.h"
index 3d59862c7ccd01d9c14904c97ef1b4853c9a22b8..cbbf59f56dfa93c23008e4c98d0b38353a65a6a7 100644 (file)
 #define INSTDONE       0x02090
 #define NOPID          0x02094
 #define HWSTAM         0x02098
+
+#define MI_MODE                0x0209c
+# define VS_TIMER_DISPATCH                             (1 << 6)
+
 #define SCPD0          0x0209c /* 915+ only */
 #define IER            0x020a0
 #define IIR            0x020a4
 #define   FBC_CTL_PERIODIC     (1<<30)
 #define   FBC_CTL_INTERVAL_SHIFT (16)
 #define   FBC_CTL_UNCOMPRESSIBLE (1<<14)
-#define   FBC_C3_IDLE          (1<<13)
+#define   FBC_CTL_C3_IDLE      (1<<13)
 #define   FBC_CTL_STRIDE_SHIFT (5)
 #define   FBC_CTL_FENCENO      (1<<0)
 #define FBC_COMMAND            0x0320c
 #define DISPLAY_PORT_PLL_BIOS_1         0x46010
 #define DISPLAY_PORT_PLL_BIOS_2         0x46014
 
+#define PCH_DSPCLK_GATE_D      0x42020
+# define DPFDUNIT_CLOCK_GATE_DISABLE           (1 << 7)
+# define DPARBUNIT_CLOCK_GATE_DISABLE          (1 << 5)
+
+#define PCH_3DCGDIS0           0x46020
+# define MARIUNIT_CLOCK_GATE_DISABLE           (1 << 18)
+# define SVSMUNIT_CLOCK_GATE_DISABLE           (1 << 1)
+
 #define FDI_PLL_FREQ_CTL        0x46030
 #define  FDI_PLL_FREQ_CHANGE_REQUEST    (1<<24)
 #define  FDI_PLL_FREQ_LOCK_LIMIT_MASK   0xfff00
index 70c9d4ba7042b57dc677a9e2fcbcf03a6abe5e4e..f9ba452f0cbf2479649e7dbe947accdeed070f30 100644 (file)
@@ -417,8 +417,9 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
        edp = find_section(bdb, BDB_EDP);
        if (!edp) {
                if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp_support) {
-                       DRM_DEBUG_KMS("No eDP BDB found but eDP panel supported,\
-                                      assume 18bpp panel color depth.\n");
+                       DRM_DEBUG_KMS("No eDP BDB found but eDP panel "
+                                     "supported, assume 18bpp panel color "
+                                     "depth.\n");
                        dev_priv->edp_bpp = 18;
                }
                return;
index fccf07470c8f6f512a8950555095ca122ed95c08..38110ce742a5503613e48f2fe50f91de9ab828f9 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "drm_crtc.h"
index 9cd6de5f99061a2916af6d453dd46e2de2ea11fe..e7e753b2845f01359304aaef5b24adc41dd10952 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/input.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "intel_drv.h"
 #include "i915_drm.h"
@@ -1032,7 +1033,7 @@ static void i8xx_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
        /* enable it... */
        fbc_ctl = FBC_CTL_EN | FBC_CTL_PERIODIC;
        if (IS_I945GM(dev))
-               fbc_ctl |= FBC_C3_IDLE; /* 945 needs special SR handling */
+               fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */
        fbc_ctl |= (dev_priv->cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT;
        fbc_ctl |= (interval & 0x2fff) << FBC_CTL_INTERVAL_SHIFT;
        if (obj_priv->tiling_mode != I915_TILING_NONE)
@@ -4717,6 +4718,20 @@ void intel_init_clock_gating(struct drm_device *dev)
         * specs, but enable as much else as we can.
         */
        if (HAS_PCH_SPLIT(dev)) {
+               uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
+
+               if (IS_IRONLAKE(dev)) {
+                       /* Required for FBC */
+                       dspclk_gate |= DPFDUNIT_CLOCK_GATE_DISABLE;
+                       /* Required for CxSR */
+                       dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE;
+
+                       I915_WRITE(PCH_3DCGDIS0,
+                                  MARIUNIT_CLOCK_GATE_DISABLE |
+                                  SVSMUNIT_CLOCK_GATE_DISABLE);
+               }
+
+               I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
                return;
        } else if (IS_G4X(dev)) {
                uint32_t dspclk_gate;
index 3ef3a0d0edd0a45a8ac50f9c420dca4695248bd5..8e283f75941d4de59901e3db34e254ad4480a8f9 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "drm_crtc.h"
index a4d2606de778c3d419713c3d8552290d828826c0..0427ca5a2514e6a39ba017bbf7aba446d4d14f93 100644 (file)
@@ -25,6 +25,7 @@
  *     Eric Anholt <eric@anholt.net>
  */
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "drm_crtc.h"
index 8cd791dc5b298d1d11217429798f8f66f0ff0089..69bbef92f1302b6d31e0052e189c553b60540002 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
-#include <linux/slab.h>
 #include <linux/sysrq.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
index a30f8bfc198563d3f8beb8634b82e8dc6bb6a915..1ed02f64125858f9c36acbf57564e6b485f045b2 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "drmP.h"
 #include "drm.h"
index fcc753ca5d9446434e026197ba8318cbcfbda9b8..c2649c7df14c7e654aba8eb495c3874c698707b5 100644 (file)
@@ -26,6 +26,7 @@
  *     Eric Anholt <eric@anholt.net>
  */
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/i2c-id.h>
 #include <linux/i2c-algo-bit.h>
 #include "drmP.h"
index 14e516fdc2dd5c71b69f403bf184450171f3f185..216e9f52b6e05818bfd5986b4cd04f0f05b9462f 100644 (file)
@@ -30,6 +30,7 @@
 #include <acpi/button.h>
 #include <linux/dmi.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "drm_crtc.h"
@@ -607,53 +608,6 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
        I915_WRITE(PFIT_CONTROL, lvds_priv->pfit_control);
 }
 
-/* Some lid devices report incorrect lid status, assume they're connected */
-static const struct dmi_system_id bad_lid_status[] = {
-       {
-               .ident = "Compaq nx9020",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
-                       DMI_MATCH(DMI_BOARD_NAME, "3084"),
-               },
-       },
-       {
-               .ident = "Samsung SX20S",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
-                       DMI_MATCH(DMI_BOARD_NAME, "SX20S"),
-               },
-       },
-       {
-               .ident = "Aspire One",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire one"),
-               },
-       },
-       {
-               .ident = "Aspire 1810T",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1810T"),
-               },
-       },
-       {
-               .ident = "PC-81005",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "MALATA"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "PC-81005"),
-               },
-       },
-       {
-               .ident = "Clevo M5x0N",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
-                       DMI_MATCH(DMI_BOARD_NAME, "M5x0N"),
-               },
-       },
-       { }
-};
-
 /**
  * Detect the LVDS connection.
  *
@@ -669,12 +623,9 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect
        /* ACPI lid methods were generally unreliable in this generation, so
         * don't even bother.
         */
-       if (IS_GEN2(dev))
+       if (IS_GEN2(dev) || IS_GEN3(dev))
                return connector_status_connected;
 
-       if (!dmi_check_system(bad_lid_status) && !acpi_lid_open())
-               status = connector_status_disconnected;
-
        return status;
 }
 
index 67e2f4632a2451fd77200e0f9810a18c83afca1d..89d303d1d3fb2de12f744f4407d872c17f8b13fc 100644 (file)
@@ -23,6 +23,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/fb.h>
 #include "drmP.h"
index d355d1d527e766438a3a177218eed2dbb9210a7d..60595fc26fdd3511d0b9ec7d0d5336a0c5a3a4f3 100644 (file)
@@ -1068,14 +1068,18 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
 
        drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id,
                         DRM_MODE_OBJECT_CRTC);
-       if (!drmmode_obj)
-               return -ENOENT;
+       if (!drmmode_obj) {
+               ret = -ENOENT;
+               goto out_free;
+       }
        crtc = to_intel_crtc(obj_to_crtc(drmmode_obj));
 
        new_bo = drm_gem_object_lookup(dev, file_priv,
                        put_image_rec->bo_handle);
-       if (!new_bo)
-               return -ENOENT;
+       if (!new_bo) {
+               ret = -ENOENT;
+               goto out_free;
+       }
 
        mutex_lock(&dev->mode_config.mutex);
        mutex_lock(&dev->struct_mutex);
@@ -1165,6 +1169,7 @@ out_unlock:
        mutex_unlock(&dev->struct_mutex);
        mutex_unlock(&dev->mode_config.mutex);
        drm_gem_object_unreference_unlocked(new_bo);
+out_free:
        kfree(params);
 
        return ret;
index 48daee5c9c63bad7a813655ff6635784f3b6ef75..26e13a0bf30b8d68fd57826d4727a93aefa345a2 100644 (file)
@@ -26,6 +26,7 @@
  *     Eric Anholt <eric@anholt.net>
  */
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "drmP.h"
 #include "drm.h"
index 32db806f3b5aa53e82a25797c271b8f4ca8fa2c0..7f0d807a0d0d4f1bc220ef59ca02ce917aa0dfde 100644 (file)
@@ -12,7 +12,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_dp.o nouveau_grctx.o \
              nv04_timer.o \
              nv04_mc.o nv40_mc.o nv50_mc.o \
-             nv04_fb.o nv10_fb.o nv40_fb.o \
+             nv04_fb.o nv10_fb.o nv40_fb.o nv50_fb.o \
              nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \
              nv04_graph.o nv10_graph.o nv20_graph.o \
              nv40_graph.o nv50_graph.o \
index 0e0730a531371e9e59ec01d1db10b72143c0c67b..e13f6af0037ac4dc805a821d785bf5ef541d9c07 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/pci.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 
index 75bceee76044e8ab25b6035e690e09fa3e29f850..b5a9336a2e88f58d3e90129c631262896f0f163b 100644 (file)
@@ -5210,6 +5210,21 @@ divine_connector_type(struct nvbios *bios, int index)
        return type;
 }
 
+static void
+apply_dcb_connector_quirks(struct nvbios *bios, int idx)
+{
+       struct dcb_connector_table_entry *cte = &bios->dcb.connector.entry[idx];
+       struct drm_device *dev = bios->dev;
+
+       /* Gigabyte NX85T */
+       if ((dev->pdev->device == 0x0421) &&
+           (dev->pdev->subsystem_vendor == 0x1458) &&
+           (dev->pdev->subsystem_device == 0x344c)) {
+               if (cte->type == DCB_CONNECTOR_HDMI_1)
+                       cte->type = DCB_CONNECTOR_DVI_I;
+       }
+}
+
 static void
 parse_dcb_connector_table(struct nvbios *bios)
 {
@@ -5238,13 +5253,14 @@ parse_dcb_connector_table(struct nvbios *bios)
        entry = conntab + conntab[1];
        cte = &ct->entry[0];
        for (i = 0; i < conntab[2]; i++, entry += conntab[3], cte++) {
+               cte->index = i;
                if (conntab[3] == 2)
                        cte->entry = ROM16(entry[0]);
                else
                        cte->entry = ROM32(entry[0]);
 
                cte->type  = (cte->entry & 0x000000ff) >> 0;
-               cte->index = (cte->entry & 0x00000f00) >> 8;
+               cte->index2 = (cte->entry & 0x00000f00) >> 8;
                switch (cte->entry & 0x00033000) {
                case 0x00001000:
                        cte->gpio_tag = 0x07;
@@ -5266,6 +5282,8 @@ parse_dcb_connector_table(struct nvbios *bios)
                if (cte->type == 0xff)
                        continue;
 
+               apply_dcb_connector_quirks(bios, i);
+
                NV_INFO(dev, "  %d: 0x%08x: type 0x%02x idx %d tag 0x%02x\n",
                        i, cte->entry, cte->type, cte->index, cte->gpio_tag);
 
@@ -5287,10 +5305,16 @@ parse_dcb_connector_table(struct nvbios *bios)
                        break;
                default:
                        cte->type = divine_connector_type(bios, cte->index);
-                       NV_WARN(dev, "unknown type, using 0x%02x", cte->type);
+                       NV_WARN(dev, "unknown type, using 0x%02x\n", cte->type);
                        break;
                }
 
+               if (nouveau_override_conntype) {
+                       int type = divine_connector_type(bios, cte->index);
+                       if (type != cte->type)
+                               NV_WARN(dev, " -> type 0x%02x\n", cte->type);
+               }
+
        }
 }
 
index 9f688aa9a65559cb3c1febd4183e8c15b8032396..4f88e6924d272846eff330a9a84307aa05fa3dc7 100644 (file)
@@ -72,9 +72,10 @@ enum dcb_connector_type {
 };
 
 struct dcb_connector_table_entry {
+       uint8_t index;
        uint32_t entry;
        enum dcb_connector_type type;
-       uint8_t index;
+       uint8_t index2;
        uint8_t gpio_tag;
 };
 
index 028719fddf761e94b1f1ae44ef50f5fc860e2813..9042dd7fb05899ebb3a1673f2244aed40920846b 100644 (file)
@@ -34,6 +34,7 @@
 #include "nouveau_dma.h"
 
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 static void
 nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
@@ -439,8 +440,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
 
        switch (bo->mem.mem_type) {
        case TTM_PL_VRAM:
-               nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT |
-                                        TTM_PL_FLAG_SYSTEM);
+               nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT);
                break;
        default:
                nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM);
index 24327f468c4b864b459fc0af3034c6548c2d3840..14afe1e47e57dff81a70dadada1bac8ec9f88c8d 100644 (file)
@@ -302,7 +302,7 @@ nouveau_connector_detect(struct drm_connector *connector)
 
 detect_analog:
        nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG);
-       if (!nv_encoder)
+       if (!nv_encoder && !nouveau_tv_disable)
                nv_encoder = find_encoder_by_type(connector, OUTPUT_TV);
        if (nv_encoder) {
                struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
index c8482a108a7801c321875ecbf5ff4e041563d3e9..65c441a1999facfeeb3b9ca191198fad732583d8 100644 (file)
@@ -190,6 +190,11 @@ nv50_dma_push(struct nouveau_channel *chan, struct nouveau_bo *bo,
        nouveau_bo_wr32(pb, ip++, upper_32_bits(offset) | length << 8);
 
        chan->dma.ib_put = (chan->dma.ib_put + 1) & chan->dma.ib_max;
+
+       DRM_MEMORYBARRIER();
+       /* Flush writes. */
+       nouveau_bo_rd32(pb, 0);
+
        nvchan_wr32(chan, 0x8c, chan->dma.ib_put);
        chan->dma.ib_free--;
 }
index 30cc09e8a709383a458baab1d77ff89ca84de9da..1de974acbc656a1dc195df0e7f6b57f52f9c0d37 100644 (file)
@@ -83,6 +83,14 @@ MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
 int nouveau_nofbaccel = 0;
 module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
 
+MODULE_PARM_DESC(override_conntype, "Ignore DCB connector type");
+int nouveau_override_conntype = 0;
+module_param_named(override_conntype, nouveau_override_conntype, int, 0400);
+
+MODULE_PARM_DESC(tv_disable, "Disable TV-out detection\n");
+int nouveau_tv_disable = 0;
+module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
+
 MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
                 "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n"
                 "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n"
@@ -154,9 +162,11 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
        if (pm_state.event == PM_EVENT_PRETHAW)
                return 0;
 
+       NV_INFO(dev, "Disabling fbcon acceleration...\n");
        fbdev_flags = dev_priv->fbdev_info->flags;
        dev_priv->fbdev_info->flags |= FBINFO_HWACCEL_DISABLED;
 
+       NV_INFO(dev, "Unpinning framebuffer(s)...\n");
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                struct nouveau_framebuffer *nouveau_fb;
 
index 4b9aaf2a8d0f0052bbafd498998e2c71b1e38434..d8b559011777a2094187d93a7dc836f80122ec16 100644 (file)
@@ -681,6 +681,7 @@ extern int nouveau_uscript_tmds;
 extern int nouveau_vram_pushbuf;
 extern int nouveau_vram_notify;
 extern int nouveau_fbpercrtc;
+extern int nouveau_tv_disable;
 extern char *nouveau_tv_norm;
 extern int nouveau_reg_debug;
 extern char *nouveau_vbios;
@@ -688,6 +689,7 @@ extern int nouveau_ctxfw;
 extern int nouveau_ignorelid;
 extern int nouveau_nofbaccel;
 extern int nouveau_noaccel;
+extern int nouveau_override_conntype;
 
 extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
 extern int nouveau_pci_resume(struct pci_dev *pdev);
@@ -926,6 +928,10 @@ extern void nv40_fb_takedown(struct drm_device *);
 extern void nv40_fb_set_region_tiling(struct drm_device *, int, uint32_t,
                                      uint32_t, uint32_t);
 
+/* nv50_fb.c */
+extern int  nv50_fb_init(struct drm_device *);
+extern void nv50_fb_takedown(struct drm_device *);
+
 /* nv04_fifo.c */
 extern int  nv04_fifo_init(struct drm_device *);
 extern void nv04_fifo_disable(struct drm_device *);
index 68cedd9194fe0f3792c4152b1282b043300faf23..8e7dc1d4912a4d889938bf9741ff6fa774b51c50 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
-#include <linux/slab.h>
 #include <linux/sysrq.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
index c7ebec696747266f0c413a9b92ec368bb832e727..32f0e495464ca83068e0bcfb345cb9248e68185e 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include "drmP.h"
 #include "nouveau_drv.h"
index 95220ddebb45a0f1880e3b200e161480588a9133..2bd59a92fee50439ddd892c96f839f909af50bf2 100644 (file)
@@ -311,6 +311,31 @@ nouveau_print_bitfield_names_(uint32_t value,
 #define nouveau_print_bitfield_names(val, namelist) \
        nouveau_print_bitfield_names_((val), (namelist), ARRAY_SIZE(namelist))
 
+struct nouveau_enum_names {
+       uint32_t value;
+       const char *name;
+};
+
+static void
+nouveau_print_enum_names_(uint32_t value,
+                               const struct nouveau_enum_names *namelist,
+                               const int namelist_len)
+{
+       /*
+        * Caller must have already printed the KERN_* log level for us.
+        * Also the caller is responsible for adding the newline.
+        */
+       int i;
+       for (i = 0; i < namelist_len; ++i) {
+               if (value == namelist[i].value) {
+                       printk("%s", namelist[i].name);
+                       return;
+               }
+       }
+       printk("unknown value 0x%08x", value);
+}
+#define nouveau_print_enum_names(val, namelist) \
+       nouveau_print_enum_names_((val), (namelist), ARRAY_SIZE(namelist))
 
 static int
 nouveau_graph_chid_from_grctx(struct drm_device *dev)
@@ -427,14 +452,16 @@ nouveau_graph_dump_trap_info(struct drm_device *dev, const char *id,
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        uint32_t nsource = trap->nsource, nstatus = trap->nstatus;
 
-       NV_INFO(dev, "%s - nSource:", id);
-       nouveau_print_bitfield_names(nsource, nsource_names);
-       printk(", nStatus:");
-       if (dev_priv->card_type < NV_10)
-               nouveau_print_bitfield_names(nstatus, nstatus_names);
-       else
-               nouveau_print_bitfield_names(nstatus, nstatus_names_nv10);
-       printk("\n");
+       if (dev_priv->card_type < NV_50) {
+               NV_INFO(dev, "%s - nSource:", id);
+               nouveau_print_bitfield_names(nsource, nsource_names);
+               printk(", nStatus:");
+               if (dev_priv->card_type < NV_10)
+                       nouveau_print_bitfield_names(nstatus, nstatus_names);
+               else
+                       nouveau_print_bitfield_names(nstatus, nstatus_names_nv10);
+               printk("\n");
+       }
 
        NV_INFO(dev, "%s - Ch %d/%d Class 0x%04x Mthd 0x%04x "
                                        "Data 0x%08x:0x%08x\n",
@@ -577,28 +604,503 @@ nouveau_pgraph_irq_handler(struct drm_device *dev)
        nv_wr32(dev, NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING);
 }
 
+static void
+nv50_pfb_vm_trap(struct drm_device *dev, int display, const char *name)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       uint32_t trap[6];
+       int i, ch;
+       uint32_t idx = nv_rd32(dev, 0x100c90);
+       if (idx & 0x80000000) {
+               idx &= 0xffffff;
+               if (display) {
+                       for (i = 0; i < 6; i++) {
+                               nv_wr32(dev, 0x100c90, idx | i << 24);
+                               trap[i] = nv_rd32(dev, 0x100c94);
+                       }
+                       for (ch = 0; ch < dev_priv->engine.fifo.channels; ch++) {
+                               struct nouveau_channel *chan = dev_priv->fifos[ch];
+
+                               if (!chan || !chan->ramin)
+                                       continue;
+
+                               if (trap[1] == chan->ramin->instance >> 12)
+                                       break;
+                       }
+                       NV_INFO(dev, "%s - VM: Trapped %s at %02x%04x%04x status %08x %08x channel %d\n",
+                                       name, (trap[5]&0x100?"read":"write"),
+                                       trap[5]&0xff, trap[4]&0xffff,
+                                       trap[3]&0xffff, trap[0], trap[2], ch);
+               }
+               nv_wr32(dev, 0x100c90, idx | 0x80000000);
+       } else if (display) {
+               NV_INFO(dev, "%s - no VM fault?\n", name);
+       }
+}
+
+static struct nouveau_enum_names nv50_mp_exec_error_names[] =
+{
+       { 3, "STACK_UNDERFLOW" },
+       { 4, "QUADON_ACTIVE" },
+       { 8, "TIMEOUT" },
+       { 0x10, "INVALID_OPCODE" },
+       { 0x40, "BREAKPOINT" },
+};
+
+static void
+nv50_pgraph_mp_trap(struct drm_device *dev, int tpid, int display)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       uint32_t units = nv_rd32(dev, 0x1540);
+       uint32_t addr, mp10, status, pc, oplow, ophigh;
+       int i;
+       int mps = 0;
+       for (i = 0; i < 4; i++) {
+               if (!(units & 1 << (i+24)))
+                       continue;
+               if (dev_priv->chipset < 0xa0)
+                       addr = 0x408200 + (tpid << 12) + (i << 7);
+               else
+                       addr = 0x408100 + (tpid << 11) + (i << 7);
+               mp10 = nv_rd32(dev, addr + 0x10);
+               status = nv_rd32(dev, addr + 0x14);
+               if (!status)
+                       continue;
+               if (display) {
+                       nv_rd32(dev, addr + 0x20);
+                       pc = nv_rd32(dev, addr + 0x24);
+                       oplow = nv_rd32(dev, addr + 0x70);
+                       ophigh= nv_rd32(dev, addr + 0x74);
+                       NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - "
+                                       "TP %d MP %d: ", tpid, i);
+                       nouveau_print_enum_names(status,
+                                       nv50_mp_exec_error_names);
+                       printk(" at %06x warp %d, opcode %08x %08x\n",
+                                       pc&0xffffff, pc >> 24,
+                                       oplow, ophigh);
+               }
+               nv_wr32(dev, addr + 0x10, mp10);
+               nv_wr32(dev, addr + 0x14, 0);
+               mps++;
+       }
+       if (!mps && display)
+               NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - TP %d: "
+                               "No MPs claiming errors?\n", tpid);
+}
+
+static void
+nv50_pgraph_tp_trap(struct drm_device *dev, int type, uint32_t ustatus_old,
+               uint32_t ustatus_new, int display, const char *name)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       int tps = 0;
+       uint32_t units = nv_rd32(dev, 0x1540);
+       int i, r;
+       uint32_t ustatus_addr, ustatus;
+       for (i = 0; i < 16; i++) {
+               if (!(units & (1 << i)))
+                       continue;
+               if (dev_priv->chipset < 0xa0)
+                       ustatus_addr = ustatus_old + (i << 12);
+               else
+                       ustatus_addr = ustatus_new + (i << 11);
+               ustatus = nv_rd32(dev, ustatus_addr) & 0x7fffffff;
+               if (!ustatus)
+                       continue;
+               tps++;
+               switch (type) {
+               case 6: /* texture error... unknown for now */
+                       nv50_pfb_vm_trap(dev, display, name);
+                       if (display) {
+                               NV_ERROR(dev, "magic set %d:\n", i);
+                               for (r = ustatus_addr + 4; r <= ustatus_addr + 0x10; r += 4)
+                                       NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
+                                               nv_rd32(dev, r));
+                       }
+                       break;
+               case 7: /* MP error */
+                       if (ustatus & 0x00010000) {
+                               nv50_pgraph_mp_trap(dev, i, display);
+                               ustatus &= ~0x00010000;
+                       }
+                       break;
+               case 8: /* TPDMA error */
+                       {
+                       uint32_t e0c = nv_rd32(dev, ustatus_addr + 4);
+                       uint32_t e10 = nv_rd32(dev, ustatus_addr + 8);
+                       uint32_t e14 = nv_rd32(dev, ustatus_addr + 0xc);
+                       uint32_t e18 = nv_rd32(dev, ustatus_addr + 0x10);
+                       uint32_t e1c = nv_rd32(dev, ustatus_addr + 0x14);
+                       uint32_t e20 = nv_rd32(dev, ustatus_addr + 0x18);
+                       uint32_t e24 = nv_rd32(dev, ustatus_addr + 0x1c);
+                       nv50_pfb_vm_trap(dev, display, name);
+                       /* 2d engine destination */
+                       if (ustatus & 0x00000010) {
+                               if (display) {
+                                       NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
+                                                       i, e14, e10);
+                                       NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
+                                                       i, e0c, e18, e1c, e20, e24);
+                               }
+                               ustatus &= ~0x00000010;
+                       }
+                       /* Render target */
+                       if (ustatus & 0x00000040) {
+                               if (display) {
+                                       NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
+                                                       i, e14, e10);
+                                       NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
+                                                       i, e0c, e18, e1c, e20, e24);
+                               }
+                               ustatus &= ~0x00000040;
+                       }
+                       /* CUDA memory: l[], g[] or stack. */
+                       if (ustatus & 0x00000080) {
+                               if (display) {
+                                       if (e18 & 0x80000000) {
+                                               /* g[] read fault? */
+                                               NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
+                                                               i, e14, e10 | ((e18 >> 24) & 0x1f));
+                                               e18 &= ~0x1f000000;
+                                       } else if (e18 & 0xc) {
+                                               /* g[] write fault? */
+                                               NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
+                                                               i, e14, e10 | ((e18 >> 7) & 0x1f));
+                                               e18 &= ~0x00000f80;
+                                       } else {
+                                               NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
+                                                               i, e14, e10);
+                                       }
+                                       NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
+                                                       i, e0c, e18, e1c, e20, e24);
+                               }
+                               ustatus &= ~0x00000080;
+                       }
+                       }
+                       break;
+               }
+               if (ustatus) {
+                       if (display)
+                               NV_INFO(dev, "%s - TP%d: Unhandled ustatus 0x%08x\n", name, i, ustatus);
+               }
+               nv_wr32(dev, ustatus_addr, 0xc0000000);
+       }
+
+       if (!tps && display)
+               NV_INFO(dev, "%s - No TPs claiming errors?\n", name);
+}
+
+static void
+nv50_pgraph_trap_handler(struct drm_device *dev)
+{
+       struct nouveau_pgraph_trap trap;
+       uint32_t status = nv_rd32(dev, 0x400108);
+       uint32_t ustatus;
+       int display = nouveau_ratelimit();
+
+
+       if (!status && display) {
+               nouveau_graph_trap_info(dev, &trap);
+               nouveau_graph_dump_trap_info(dev, "PGRAPH_TRAP", &trap);
+               NV_INFO(dev, "PGRAPH_TRAP - no units reporting traps?\n");
+       }
+
+       /* DISPATCH: Relays commands to other units and handles NOTIFY,
+        * COND, QUERY. If you get a trap from it, the command is still stuck
+        * in DISPATCH and you need to do something about it. */
+       if (status & 0x001) {
+               ustatus = nv_rd32(dev, 0x400804) & 0x7fffffff;
+               if (!ustatus && display) {
+                       NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
+               }
+
+               /* Known to be triggered by screwed up NOTIFY and COND... */
+               if (ustatus & 0x00000001) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_DISPATCH_FAULT");
+                       nv_wr32(dev, 0x400500, 0);
+                       if (nv_rd32(dev, 0x400808) & 0x80000000) {
+                               if (display) {
+                                       if (nouveau_graph_trapped_channel(dev, &trap.channel))
+                                               trap.channel = -1;
+                                       trap.class = nv_rd32(dev, 0x400814);
+                                       trap.mthd = nv_rd32(dev, 0x400808) & 0x1ffc;
+                                       trap.subc = (nv_rd32(dev, 0x400808) >> 16) & 0x7;
+                                       trap.data = nv_rd32(dev, 0x40080c);
+                                       trap.data2 = nv_rd32(dev, 0x400810);
+                                       nouveau_graph_dump_trap_info(dev,
+                                                       "PGRAPH_TRAP_DISPATCH_FAULT", &trap);
+                                       NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - 400808: %08x\n", nv_rd32(dev, 0x400808));
+                                       NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - 400848: %08x\n", nv_rd32(dev, 0x400848));
+                               }
+                               nv_wr32(dev, 0x400808, 0);
+                       } else if (display) {
+                               NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - No stuck command?\n");
+                       }
+                       nv_wr32(dev, 0x4008e8, nv_rd32(dev, 0x4008e8) & 3);
+                       nv_wr32(dev, 0x400848, 0);
+                       ustatus &= ~0x00000001;
+               }
+               if (ustatus & 0x00000002) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_DISPATCH_QUERY");
+                       nv_wr32(dev, 0x400500, 0);
+                       if (nv_rd32(dev, 0x40084c) & 0x80000000) {
+                               if (display) {
+                                       if (nouveau_graph_trapped_channel(dev, &trap.channel))
+                                               trap.channel = -1;
+                                       trap.class = nv_rd32(dev, 0x400814);
+                                       trap.mthd = nv_rd32(dev, 0x40084c) & 0x1ffc;
+                                       trap.subc = (nv_rd32(dev, 0x40084c) >> 16) & 0x7;
+                                       trap.data = nv_rd32(dev, 0x40085c);
+                                       trap.data2 = 0;
+                                       nouveau_graph_dump_trap_info(dev,
+                                                       "PGRAPH_TRAP_DISPATCH_QUERY", &trap);
+                                       NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_QUERY - 40084c: %08x\n", nv_rd32(dev, 0x40084c));
+                               }
+                               nv_wr32(dev, 0x40084c, 0);
+                       } else if (display) {
+                               NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_QUERY - No stuck command?\n");
+                       }
+                       ustatus &= ~0x00000002;
+               }
+               if (ustatus && display)
+                       NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - Unhandled ustatus 0x%08x\n", ustatus);
+               nv_wr32(dev, 0x400804, 0xc0000000);
+               nv_wr32(dev, 0x400108, 0x001);
+               status &= ~0x001;
+       }
+
+       /* TRAPs other than dispatch use the "normal" trap regs. */
+       if (status && display) {
+               nouveau_graph_trap_info(dev, &trap);
+               nouveau_graph_dump_trap_info(dev,
+                               "PGRAPH_TRAP", &trap);
+       }
+
+       /* M2MF: Memory to memory copy engine. */
+       if (status & 0x002) {
+               ustatus = nv_rd32(dev, 0x406800) & 0x7fffffff;
+               if (!ustatus && display) {
+                       NV_INFO(dev, "PGRAPH_TRAP_M2MF - no ustatus?\n");
+               }
+               if (ustatus & 0x00000001) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_NOTIFY");
+                       ustatus &= ~0x00000001;
+               }
+               if (ustatus & 0x00000002) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_IN");
+                       ustatus &= ~0x00000002;
+               }
+               if (ustatus & 0x00000004) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_OUT");
+                       ustatus &= ~0x00000004;
+               }
+               NV_INFO (dev, "PGRAPH_TRAP_M2MF - %08x %08x %08x %08x\n",
+                               nv_rd32(dev, 0x406804),
+                               nv_rd32(dev, 0x406808),
+                               nv_rd32(dev, 0x40680c),
+                               nv_rd32(dev, 0x406810));
+               if (ustatus && display)
+                       NV_INFO(dev, "PGRAPH_TRAP_M2MF - Unhandled ustatus 0x%08x\n", ustatus);
+               /* No sane way found yet -- just reset the bugger. */
+               nv_wr32(dev, 0x400040, 2);
+               nv_wr32(dev, 0x400040, 0);
+               nv_wr32(dev, 0x406800, 0xc0000000);
+               nv_wr32(dev, 0x400108, 0x002);
+               status &= ~0x002;
+       }
+
+       /* VFETCH: Fetches data from vertex buffers. */
+       if (status & 0x004) {
+               ustatus = nv_rd32(dev, 0x400c04) & 0x7fffffff;
+               if (!ustatus && display) {
+                       NV_INFO(dev, "PGRAPH_TRAP_VFETCH - no ustatus?\n");
+               }
+               if (ustatus & 0x00000001) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_VFETCH_FAULT");
+                       NV_INFO (dev, "PGRAPH_TRAP_VFETCH_FAULT - %08x %08x %08x %08x\n",
+                                       nv_rd32(dev, 0x400c00),
+                                       nv_rd32(dev, 0x400c08),
+                                       nv_rd32(dev, 0x400c0c),
+                                       nv_rd32(dev, 0x400c10));
+                       ustatus &= ~0x00000001;
+               }
+               if (ustatus && display)
+                       NV_INFO(dev, "PGRAPH_TRAP_VFETCH - Unhandled ustatus 0x%08x\n", ustatus);
+               nv_wr32(dev, 0x400c04, 0xc0000000);
+               nv_wr32(dev, 0x400108, 0x004);
+               status &= ~0x004;
+       }
+
+       /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
+       if (status & 0x008) {
+               ustatus = nv_rd32(dev, 0x401800) & 0x7fffffff;
+               if (!ustatus && display) {
+                       NV_INFO(dev, "PGRAPH_TRAP_STRMOUT - no ustatus?\n");
+               }
+               if (ustatus & 0x00000001) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_STRMOUT_FAULT");
+                       NV_INFO (dev, "PGRAPH_TRAP_STRMOUT_FAULT - %08x %08x %08x %08x\n",
+                                       nv_rd32(dev, 0x401804),
+                                       nv_rd32(dev, 0x401808),
+                                       nv_rd32(dev, 0x40180c),
+                                       nv_rd32(dev, 0x401810));
+                       ustatus &= ~0x00000001;
+               }
+               if (ustatus && display)
+                       NV_INFO(dev, "PGRAPH_TRAP_STRMOUT - Unhandled ustatus 0x%08x\n", ustatus);
+               /* No sane way found yet -- just reset the bugger. */
+               nv_wr32(dev, 0x400040, 0x80);
+               nv_wr32(dev, 0x400040, 0);
+               nv_wr32(dev, 0x401800, 0xc0000000);
+               nv_wr32(dev, 0x400108, 0x008);
+               status &= ~0x008;
+       }
+
+       /* CCACHE: Handles code and c[] caches and fills them. */
+       if (status & 0x010) {
+               ustatus = nv_rd32(dev, 0x405018) & 0x7fffffff;
+               if (!ustatus && display) {
+                       NV_INFO(dev, "PGRAPH_TRAP_CCACHE - no ustatus?\n");
+               }
+               if (ustatus & 0x00000001) {
+                       nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_CCACHE_FAULT");
+                       NV_INFO (dev, "PGRAPH_TRAP_CCACHE_FAULT - %08x %08x %08x %08x %08x %08x %08x\n",
+                                       nv_rd32(dev, 0x405800),
+                                       nv_rd32(dev, 0x405804),
+                                       nv_rd32(dev, 0x405808),
+                                       nv_rd32(dev, 0x40580c),
+                                       nv_rd32(dev, 0x405810),
+                                       nv_rd32(dev, 0x405814),
+                                       nv_rd32(dev, 0x40581c));
+                       ustatus &= ~0x00000001;
+               }
+               if (ustatus && display)
+                       NV_INFO(dev, "PGRAPH_TRAP_CCACHE - Unhandled ustatus 0x%08x\n", ustatus);
+               nv_wr32(dev, 0x405018, 0xc0000000);
+               nv_wr32(dev, 0x400108, 0x010);
+               status &= ~0x010;
+       }
+
+       /* Unknown, not seen yet... 0x402000 is the only trap status reg
+        * remaining, so try to handle it anyway. Perhaps related to that
+        * unknown DMA slot on tesla? */
+       if (status & 0x20) {
+               nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_UNKC04");
+               ustatus = nv_rd32(dev, 0x402000) & 0x7fffffff;
+               if (display)
+                       NV_INFO(dev, "PGRAPH_TRAP_UNKC04 - Unhandled ustatus 0x%08x\n", ustatus);
+               nv_wr32(dev, 0x402000, 0xc0000000);
+               /* no status modifiction on purpose */
+       }
+
+       /* TEXTURE: CUDA texturing units */
+       if (status & 0x040) {
+               nv50_pgraph_tp_trap (dev, 6, 0x408900, 0x408600, display,
+                               "PGRAPH_TRAP_TEXTURE");
+               nv_wr32(dev, 0x400108, 0x040);
+               status &= ~0x040;
+       }
+
+       /* MP: CUDA execution engines. */
+       if (status & 0x080) {
+               nv50_pgraph_tp_trap (dev, 7, 0x408314, 0x40831c, display,
+                               "PGRAPH_TRAP_MP");
+               nv_wr32(dev, 0x400108, 0x080);
+               status &= ~0x080;
+       }
+
+       /* TPDMA:  Handles TP-initiated uncached memory accesses:
+        * l[], g[], stack, 2d surfaces, render targets. */
+       if (status & 0x100) {
+               nv50_pgraph_tp_trap (dev, 8, 0x408e08, 0x408708, display,
+                               "PGRAPH_TRAP_TPDMA");
+               nv_wr32(dev, 0x400108, 0x100);
+               status &= ~0x100;
+       }
+
+       if (status) {
+               if (display)
+                       NV_INFO(dev, "PGRAPH_TRAP - Unknown trap 0x%08x\n",
+                               status);
+               nv_wr32(dev, 0x400108, status);
+       }
+}
+
+/* There must be a *lot* of these. Will take some time to gather them up. */
+static struct nouveau_enum_names nv50_data_error_names[] =
+{
+       { 4,    "INVALID_VALUE" },
+       { 5,    "INVALID_ENUM" },
+       { 8,    "INVALID_OBJECT" },
+       { 0xc,  "INVALID_BITFIELD" },
+       { 0x28, "MP_NO_REG_SPACE" },
+       { 0x2b, "MP_BLOCK_SIZE_MISMATCH" },
+};
+
 static void
 nv50_pgraph_irq_handler(struct drm_device *dev)
 {
+       struct nouveau_pgraph_trap trap;
+       int unhandled = 0;
        uint32_t status;
 
        while ((status = nv_rd32(dev, NV03_PGRAPH_INTR))) {
-               uint32_t nsource = nv_rd32(dev, NV03_PGRAPH_NSOURCE);
-
+               /* NOTIFY: You've set a NOTIFY an a command and it's done. */
                if (status & 0x00000001) {
-                       nouveau_pgraph_intr_notify(dev, nsource);
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_NOTIFY", &trap);
                        status &= ~0x00000001;
                        nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000001);
                }
 
-               if (status & 0x00000010) {
-                       nouveau_pgraph_intr_error(dev, nsource |
-                                       NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD);
+               /* COMPUTE_QUERY: Purpose and exact cause unknown, happens
+                * when you write 0x200 to 0x50c0 method 0x31c. */
+               if (status & 0x00000002) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_COMPUTE_QUERY", &trap);
+                       status &= ~0x00000002;
+                       nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000002);
+               }
 
+               /* Unknown, never seen: 0x4 */
+
+               /* ILLEGAL_MTHD: You used a wrong method for this class. */
+               if (status & 0x00000010) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_pgraph_intr_swmthd(dev, &trap))
+                               unhandled = 1;
+                       if (unhandled && nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_ILLEGAL_MTHD", &trap);
                        status &= ~0x00000010;
                        nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000010);
                }
 
+               /* ILLEGAL_CLASS: You used a wrong class. */
+               if (status & 0x00000020) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_ILLEGAL_CLASS", &trap);
+                       status &= ~0x00000020;
+                       nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000020);
+               }
+
+               /* DOUBLE_NOTIFY: You tried to set a NOTIFY on another NOTIFY. */
+               if (status & 0x00000040) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_DOUBLE_NOTIFY", &trap);
+                       status &= ~0x00000040;
+                       nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000040);
+               }
+
+               /* CONTEXT_SWITCH: PGRAPH needs us to load a new context */
                if (status & 0x00001000) {
                        nv_wr32(dev, 0x400500, 0x00000000);
                        nv_wr32(dev, NV03_PGRAPH_INTR,
@@ -613,49 +1115,59 @@ nv50_pgraph_irq_handler(struct drm_device *dev)
                        status &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
                }
 
-               if (status & 0x00100000) {
-                       nouveau_pgraph_intr_error(dev, nsource |
-                                       NV03_PGRAPH_NSOURCE_DATA_ERROR);
+               /* BUFFER_NOTIFY: Your m2mf transfer finished */
+               if (status & 0x00010000) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_BUFFER_NOTIFY", &trap);
+                       status &= ~0x00010000;
+                       nv_wr32(dev, NV03_PGRAPH_INTR, 0x00010000);
+               }
 
+               /* DATA_ERROR: Invalid value for this method, or invalid
+                * state in current PGRAPH context for this operation */
+               if (status & 0x00100000) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit()) {
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_DATA_ERROR", &trap);
+                               NV_INFO (dev, "PGRAPH_DATA_ERROR - ");
+                               nouveau_print_enum_names(nv_rd32(dev, 0x400110),
+                                               nv50_data_error_names);
+                               printk("\n");
+                       }
                        status &= ~0x00100000;
                        nv_wr32(dev, NV03_PGRAPH_INTR, 0x00100000);
                }
 
+               /* TRAP: Something bad happened in the middle of command
+                * execution.  Has a billion types, subtypes, and even
+                * subsubtypes. */
                if (status & 0x00200000) {
-                       int r;
-
-                       nouveau_pgraph_intr_error(dev, nsource |
-                                       NV03_PGRAPH_NSOURCE_PROTECTION_ERROR);
-
-                       NV_ERROR(dev, "magic set 1:\n");
-                       for (r = 0x408900; r <= 0x408910; r += 4)
-                               NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
-                                       nv_rd32(dev, r));
-                       nv_wr32(dev, 0x408900,
-                               nv_rd32(dev, 0x408904) | 0xc0000000);
-                       for (r = 0x408e08; r <= 0x408e24; r += 4)
-                               NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
-                                                       nv_rd32(dev, r));
-                       nv_wr32(dev, 0x408e08,
-                               nv_rd32(dev, 0x408e08) | 0xc0000000);
-
-                       NV_ERROR(dev, "magic set 2:\n");
-                       for (r = 0x409900; r <= 0x409910; r += 4)
-                               NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
-                                       nv_rd32(dev, r));
-                       nv_wr32(dev, 0x409900,
-                               nv_rd32(dev, 0x409904) | 0xc0000000);
-                       for (r = 0x409e08; r <= 0x409e24; r += 4)
-                               NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
-                                       nv_rd32(dev, r));
-                       nv_wr32(dev, 0x409e08,
-                               nv_rd32(dev, 0x409e08) | 0xc0000000);
-
+                       nv50_pgraph_trap_handler(dev);
                        status &= ~0x00200000;
-                       nv_wr32(dev, NV03_PGRAPH_NSOURCE, nsource);
                        nv_wr32(dev, NV03_PGRAPH_INTR, 0x00200000);
                }
 
+               /* Unknown, never seen: 0x00400000 */
+
+               /* SINGLE_STEP: Happens on every method if you turned on
+                * single stepping in 40008c */
+               if (status & 0x01000000) {
+                       nouveau_graph_trap_info(dev, &trap);
+                       if (nouveau_ratelimit())
+                               nouveau_graph_dump_trap_info(dev,
+                                               "PGRAPH_SINGLE_STEP", &trap);
+                       status &= ~0x01000000;
+                       nv_wr32(dev, NV03_PGRAPH_INTR, 0x01000000);
+               }
+
+               /* 0x02000000 happens when you pause a ctxprog...
+                * but the only way this can happen that I know is by
+                * poking the relevant MMIO register, and we don't
+                * do that. */
+
                if (status) {
                        NV_INFO(dev, "Unhandled PGRAPH_INTR - 0x%08x\n",
                                status);
@@ -672,7 +1184,8 @@ nv50_pgraph_irq_handler(struct drm_device *dev)
        }
 
        nv_wr32(dev, NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING);
-       nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
+       if (nv_rd32(dev, 0x400824) & (1 << 31))
+               nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
 }
 
 static void
index ed1590577b6c0d73d425be296718b440f756895b..86785b8d42ed75a66b9ad01f04ab0a138d21f59d 100644 (file)
@@ -1,6 +1,7 @@
 #include "drmP.h"
 #include "nouveau_drv.h"
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 
 #define NV_CTXDMA_PAGE_SHIFT 12
 #define NV_CTXDMA_PAGE_SIZE  (1 << NV_CTXDMA_PAGE_SHIFT)
index eb8f084d5f537ec4edeb2444b992763e15549ade..10656a6be8e6aff3cac3bd93795176347a5bb2e8 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/swab.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "drm_sarea.h"
@@ -35,7 +36,6 @@
 #include "nouveau_drm.h"
 #include "nv50_display.h"
 
-static int nouveau_stub_init(struct drm_device *dev) { return 0; }
 static void nouveau_stub_takedown(struct drm_device *dev) {}
 
 static int nouveau_init_engine_ptrs(struct drm_device *dev)
@@ -277,8 +277,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
                engine->timer.init              = nv04_timer_init;
                engine->timer.read              = nv04_timer_read;
                engine->timer.takedown          = nv04_timer_takedown;
-               engine->fb.init                 = nouveau_stub_init;
-               engine->fb.takedown             = nouveau_stub_takedown;
+               engine->fb.init                 = nv50_fb_init;
+               engine->fb.takedown             = nv50_fb_takedown;
                engine->graph.grclass           = nv50_graph_grclass;
                engine->graph.init              = nv50_graph_init;
                engine->graph.takedown          = nv50_graph_takedown;
index a1d1ebb073d930e64342847ebd0a6add0ec0bc03..eba687f1099e24fcb164eb7a3f3e18550acc0508 100644 (file)
@@ -230,9 +230,9 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
        struct drm_framebuffer *fb = crtc->fb;
 
        /* Calculate our timings */
-       int horizDisplay        = (mode->crtc_hdisplay >> 3)    - 1;
-       int horizStart          = (mode->crtc_hsync_start >> 3)         - 1;
-       int horizEnd            = (mode->crtc_hsync_end >> 3)   - 1;
+       int horizDisplay        = (mode->crtc_hdisplay >> 3)            - 1;
+       int horizStart          = (mode->crtc_hsync_start >> 3)         + 1;
+       int horizEnd            = (mode->crtc_hsync_end >> 3)           + 1;
        int horizTotal          = (mode->crtc_htotal >> 3)              - 5;
        int horizBlankStart     = (mode->crtc_hdisplay >> 3)            - 1;
        int horizBlankEnd       = (mode->crtc_htotal >> 3)              - 1;
index 3da90c2c4e634910eba368bdb691bf9684cd5b95..813b25cec7269a6ff5e1ec5ec5aeb2875480dcb3 100644 (file)
@@ -118,8 +118,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
                return;
        }
 
-       width = ALIGN(image->width, 32);
-       dsize = (width * image->height) >> 5;
+       width = ALIGN(image->width, 8);
+       dsize = ALIGN(width * image->height, 32) >> 5;
 
        if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
            info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
@@ -136,8 +136,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
                         ((image->dx + image->width) & 0xffff));
        OUT_RING(chan, bg);
        OUT_RING(chan, fg);
-       OUT_RING(chan, (image->height << 16) | image->width);
        OUT_RING(chan, (image->height << 16) | width);
+       OUT_RING(chan, (image->height << 16) | image->width);
        OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
 
        while (dsize) {
index 61a89f2dc5535ecf1d74f08b9c342727997c1766..fac6c88a2b1f1042b88720c853ba466fd7807c8b 100644 (file)
@@ -522,8 +522,8 @@ int nv50_display_create(struct drm_device *dev)
        }
 
        for (i = 0 ; i < dcb->connector.entries; i++) {
-               if (i != 0 && dcb->connector.entry[i].index ==
-                             dcb->connector.entry[i - 1].index)
+               if (i != 0 && dcb->connector.entry[i].index2 ==
+                             dcb->connector.entry[i - 1].index2)
                        continue;
                nouveau_connector_create(dev, &dcb->connector.entry[i]);
        }
diff --git a/drivers/gpu/drm/nouveau/nv50_fb.c b/drivers/gpu/drm/nouveau/nv50_fb.c
new file mode 100644 (file)
index 0000000..a95e694
--- /dev/null
@@ -0,0 +1,32 @@
+#include "drmP.h"
+#include "drm.h"
+#include "nouveau_drv.h"
+#include "nouveau_drm.h"
+
+int
+nv50_fb_init(struct drm_device *dev)
+{
+       /* This is needed to get meaningful information from 100c90
+        * on traps. No idea what these values mean exactly. */
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+       switch (dev_priv->chipset) {
+       case 0x50:
+               nv_wr32(dev, 0x100c90, 0x0707ff);
+               break;
+       case 0xa5:
+       case 0xa8:
+               nv_wr32(dev, 0x100c90, 0x0d0fff);
+               break;
+       default:
+               nv_wr32(dev, 0x100c90, 0x1d07ff);
+               break;
+       }
+
+       return 0;
+}
+
+void
+nv50_fb_takedown(struct drm_device *dev)
+{
+}
index 993c7126fbded104b6ed3a16cac2e5f07f757474..25a3cd8794f919991ab0ed717e129557eafaad55 100644 (file)
@@ -233,7 +233,7 @@ nv50_fbcon_accel_init(struct fb_info *info)
        BEGIN_RING(chan, NvSub2D, 0x0808, 3);
        OUT_RING(chan, 0);
        OUT_RING(chan, 0);
-       OUT_RING(chan, 0);
+       OUT_RING(chan, 1);
        BEGIN_RING(chan, NvSub2D, 0x081c, 1);
        OUT_RING(chan, 1);
        BEGIN_RING(chan, NvSub2D, 0x0840, 4);
index 857a09671a394c80a534d350b659261d8f56c223..c62b33a02f889431fc6cde830138d16e3f0c6f40 100644 (file)
@@ -56,6 +56,10 @@ nv50_graph_init_intr(struct drm_device *dev)
 static void
 nv50_graph_init_regs__nv(struct drm_device *dev)
 {
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       uint32_t units = nv_rd32(dev, 0x1540);
+       int i;
+
        NV_DEBUG(dev, "\n");
 
        nv_wr32(dev, 0x400804, 0xc0000000);
@@ -65,6 +69,20 @@ nv50_graph_init_regs__nv(struct drm_device *dev)
        nv_wr32(dev, 0x405018, 0xc0000000);
        nv_wr32(dev, 0x402000, 0xc0000000);
 
+       for (i = 0; i < 16; i++) {
+               if (units & 1 << i) {
+                       if (dev_priv->chipset < 0xa0) {
+                               nv_wr32(dev, 0x408900 + (i << 12), 0xc0000000);
+                               nv_wr32(dev, 0x408e08 + (i << 12), 0xc0000000);
+                               nv_wr32(dev, 0x408314 + (i << 12), 0xc0000000);
+                       } else {
+                               nv_wr32(dev, 0x408600 + (i << 11), 0xc0000000);
+                               nv_wr32(dev, 0x408708 + (i << 11), 0xc0000000);
+                               nv_wr32(dev, 0x40831c + (i << 11), 0xc0000000);
+                       }
+               }
+       }
+
        nv_wr32(dev, 0x400108, 0xffffffff);
 
        nv_wr32(dev, 0x400824, 0x00004000);
@@ -229,10 +247,6 @@ nv50_graph_create_context(struct nouveau_channel *chan)
                nouveau_grctx_vals_load(dev, ctx);
        }
        nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12);
-       if ((dev_priv->chipset & 0xf0) == 0xa0)
-               nv_wo32(dev, ctx, 0x00004/4, 0x00000000);
-       else
-               nv_wo32(dev, ctx, 0x0011c/4, 0x00000000);
        dev_priv->engine.instmem.finish_access(dev);
 
        return 0;
index d105fcd42ca0d06febbed6db006b254928f8521e..546b31949a3079a8a8b4c82ab5d5534498437532 100644 (file)
@@ -64,6 +64,9 @@
 #define CP_FLAG_ALWAYS                ((2 * 32) + 13)
 #define CP_FLAG_ALWAYS_FALSE          0
 #define CP_FLAG_ALWAYS_TRUE           1
+#define CP_FLAG_INTR                  ((2 * 32) + 15)
+#define CP_FLAG_INTR_NOT_PENDING      0
+#define CP_FLAG_INTR_PENDING          1
 
 #define CP_CTX                   0x00100000
 #define CP_CTX_COUNT             0x000f0000
@@ -214,6 +217,8 @@ nv50_grctx_init(struct nouveau_grctx *ctx)
        cp_name(ctx, cp_setup_save);
        cp_set (ctx, UNK1D, SET);
        cp_wait(ctx, STATUS, BUSY);
+       cp_wait(ctx, INTR, PENDING);
+       cp_bra (ctx, STATUS, BUSY, cp_setup_save);
        cp_set (ctx, UNK01, SET);
        cp_set (ctx, SWAP_DIRECTION, SAVE);
 
@@ -269,7 +274,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
        int offset, base;
        uint32_t units = nv_rd32 (ctx->dev, 0x1540);
 
-       /* 0800 */
+       /* 0800: DISPATCH */
        cp_ctx(ctx, 0x400808, 7);
        gr_def(ctx, 0x400814, 0x00000030);
        cp_ctx(ctx, 0x400834, 0x32);
@@ -300,7 +305,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
                gr_def(ctx, 0x400b20, 0x0001629d);
        }
 
-       /* 0C00 */
+       /* 0C00: VFETCH */
        cp_ctx(ctx, 0x400c08, 0x2);
        gr_def(ctx, 0x400c08, 0x0000fe0c);
 
@@ -326,7 +331,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
        cp_ctx(ctx, 0x401540, 0x5);
        gr_def(ctx, 0x401550, 0x00001018);
 
-       /* 1800 */
+       /* 1800: STREAMOUT */
        cp_ctx(ctx, 0x401814, 0x1);
        gr_def(ctx, 0x401814, 0x000000ff);
        if (dev_priv->chipset == 0x50) {
@@ -641,7 +646,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
        if (dev_priv->chipset == 0x50)
                cp_ctx(ctx, 0x4063e0, 0x1);
 
-       /* 6800 */
+       /* 6800: M2MF */
        if (dev_priv->chipset < 0x90) {
                cp_ctx(ctx, 0x406814, 0x2b);
                gr_def(ctx, 0x406818, 0x00000f80);
index 4c39a407aa4af51b6f3554c3a40fc9bd9acffb7f..e671d0e74d4c2c626b12d2daf0e2f7faf09b05c6 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/firmware.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "drmP.h"
 #include "drm.h"
index ed38262d9985e326e4bdffceb0fca5ea865e3362..3c91312dea9a00d8aa93b097d2d5d476487fb2d8 100644 (file)
@@ -50,7 +50,7 @@ $(obj)/r600_cs.o: $(obj)/r600_reg_safe.h
 radeon-y := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o \
        radeon_irq.o r300_cmdbuf.o r600_cp.o
 # add KMS driver
-radeon-y += radeon_device.o radeon_kms.o \
+radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
        radeon_atombios.o radeon_agp.o atombios_crtc.o radeon_combios.o \
        atom.o radeon_fence.o radeon_ttm.o radeon_object.o radeon_gart.o \
        radeon_legacy_crtc.o radeon_legacy_encoders.o radeon_connectors.o \
index d75788feac6c6a64fe042e0e7d3e4a446d8b2e26..07b7ebf1f466a3be426bf1bb3aabe68756973916 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #define ATOM_DEBUG
 
 typedef struct {
        struct atom_context *ctx;
-
        uint32_t *ps, *ws;
        int ps_shift;
        uint16_t start;
+       unsigned last_jump;
+       unsigned long last_jump_jiffies;
+       bool abort;
 } atom_exec_context;
 
 int atom_debug = 0;
-static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
-void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);
+static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
+int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);
 
 static uint32_t atom_arg_mask[8] =
     { 0xFFFFFFFF, 0xFFFF, 0xFFFF00, 0xFFFF0000, 0xFF, 0xFF00, 0xFF0000,
@@ -604,12 +607,17 @@ static void atom_op_beep(atom_exec_context *ctx, int *ptr, int arg)
 static void atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
 {
        int idx = U8((*ptr)++);
+       int r = 0;
+
        if (idx < ATOM_TABLE_NAMES_CNT)
                SDEBUG("   table: %d (%s)\n", idx, atom_table_names[idx]);
        else
                SDEBUG("   table: %d\n", idx);
        if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
-               atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
+               r = atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
+       if (r) {
+               ctx->abort = true;
+       }
 }
 
 static void atom_op_clear(atom_exec_context *ctx, int *ptr, int arg)
@@ -673,6 +681,8 @@ static void atom_op_eot(atom_exec_context *ctx, int *ptr, int arg)
 static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
 {
        int execute = 0, target = U16(*ptr);
+       unsigned long cjiffies;
+
        (*ptr) += 2;
        switch (arg) {
        case ATOM_COND_ABOVE:
@@ -700,8 +710,25 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
        if (arg != ATOM_COND_ALWAYS)
                SDEBUG("   taken: %s\n", execute ? "yes" : "no");
        SDEBUG("   target: 0x%04X\n", target);
-       if (execute)
+       if (execute) {
+               if (ctx->last_jump == (ctx->start + target)) {
+                       cjiffies = jiffies;
+                       if (time_after(cjiffies, ctx->last_jump_jiffies)) {
+                               cjiffies -= ctx->last_jump_jiffies;
+                               if ((jiffies_to_msecs(cjiffies) > 1000)) {
+                                       DRM_ERROR("atombios stuck in loop for more than 1sec aborting\n");
+                                       ctx->abort = true;
+                               }
+                       } else {
+                               /* jiffies wrap around we will just wait a little longer */
+                               ctx->last_jump_jiffies = jiffies;
+                       }
+               } else {
+                       ctx->last_jump = ctx->start + target;
+                       ctx->last_jump_jiffies = jiffies;
+               }
                *ptr = ctx->start + target;
+       }
 }
 
 static void atom_op_mask(atom_exec_context *ctx, int *ptr, int arg)
@@ -1104,7 +1131,7 @@ static struct {
        atom_op_shr, ATOM_ARG_MC}, {
 atom_op_debug, 0},};
 
-static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params)
+static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params)
 {
        int base = CU16(ctx->cmd_table + 4 + 2 * index);
        int len, ws, ps, ptr;
@@ -1112,7 +1139,7 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
        atom_exec_context ectx;
 
        if (!base)
-               return;
+               return -EINVAL;
 
        len = CU16(base + ATOM_CT_SIZE_PTR);
        ws = CU8(base + ATOM_CT_WS_PTR);
@@ -1125,6 +1152,8 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
        ectx.ps_shift = ps / 4;
        ectx.start = base;
        ectx.ps = params;
+       ectx.abort = false;
+       ectx.last_jump = 0;
        if (ws)
                ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
        else
@@ -1137,6 +1166,11 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
                        SDEBUG("%s @ 0x%04X\n", atom_op_names[op], ptr - 1);
                else
                        SDEBUG("[%d] @ 0x%04X\n", op, ptr - 1);
+               if (ectx.abort) {
+                       DRM_ERROR("atombios stuck executing %04X (len %d, WS %d, PS %d) @ 0x%04X\n",
+                               base, len, ws, ps, ptr - 1);
+                       return -EINVAL;
+               }
 
                if (op < ATOM_OP_CNT && op > 0)
                        opcode_table[op].func(&ectx, &ptr,
@@ -1152,10 +1186,13 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
 
        if (ws)
                kfree(ectx.ws);
+       return 0;
 }
 
-void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
+int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
 {
+       int r;
+
        mutex_lock(&ctx->mutex);
        /* reset reg block */
        ctx->reg_block = 0;
@@ -1163,8 +1200,9 @@ void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
        ctx->fb_base = 0;
        /* reset io mode */
        ctx->io_mode = ATOM_IO_MM;
-       atom_execute_table_locked(ctx, index, params);
+       r = atom_execute_table_locked(ctx, index, params);
        mutex_unlock(&ctx->mutex);
+       return r;
 }
 
 static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 };
@@ -1248,9 +1286,7 @@ int atom_asic_init(struct atom_context *ctx)
 
        if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT))
                return 1;
-       atom_execute_table(ctx, ATOM_CMD_INIT, ps);
-
-       return 0;
+       return atom_execute_table(ctx, ATOM_CMD_INIT, ps);
 }
 
 void atom_destroy(struct atom_context *ctx)
@@ -1260,12 +1296,16 @@ void atom_destroy(struct atom_context *ctx)
        kfree(ctx);
 }
 
-void atom_parse_data_header(struct atom_context *ctx, int index,
+bool atom_parse_data_header(struct atom_context *ctx, int index,
                            uint16_t * size, uint8_t * frev, uint8_t * crev,
                            uint16_t * data_start)
 {
        int offset = index * 2 + 4;
        int idx = CU16(ctx->data_table + offset);
+       u16 *mdt = (u16 *)(ctx->bios + ctx->data_table + 4);
+
+       if (!mdt[index])
+               return false;
 
        if (size)
                *size = CU16(idx);
@@ -1274,38 +1314,42 @@ void atom_parse_data_header(struct atom_context *ctx, int index,
        if (crev)
                *crev = CU8(idx + 3);
        *data_start = idx;
-       return;
+       return true;
 }
 
-void atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t * frev,
+bool atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t * frev,
                           uint8_t * crev)
 {
        int offset = index * 2 + 4;
        int idx = CU16(ctx->cmd_table + offset);
+       u16 *mct = (u16 *)(ctx->bios + ctx->cmd_table + 4);
+
+       if (!mct[index])
+               return false;
 
        if (frev)
                *frev = CU8(idx + 2);
        if (crev)
                *crev = CU8(idx + 3);
-       return;
+       return true;
 }
 
 int atom_allocate_fb_scratch(struct atom_context *ctx)
 {
        int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware);
        uint16_t data_offset;
-       int usage_bytes;
+       int usage_bytes = 0;
        struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage;
 
-       atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
+       if (atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) {
+               firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset);
 
-       firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset);
+               DRM_DEBUG("atom firmware requested %08x %dkb\n",
+                         firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
+                         firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
 
-       DRM_DEBUG("atom firmware requested %08x %dkb\n",
-                 firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
-                 firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
-
-       usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
+               usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
+       }
        if (usage_bytes == 0)
                usage_bytes = 20 * 1024;
        /* allocate some scratch memory */
index bc73781423a17599fadf9e2bfa1bca556b5504ca..cd1b64ab5ca7c0c4b24e29bd4dd04e8b52387b16 100644 (file)
@@ -140,11 +140,13 @@ struct atom_context {
 extern int atom_debug;
 
 struct atom_context *atom_parse(struct card_info *, void *);
-void atom_execute_table(struct atom_context *, int, uint32_t *);
+int atom_execute_table(struct atom_context *, int, uint32_t *);
 int atom_asic_init(struct atom_context *);
 void atom_destroy(struct atom_context *);
-void atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size, uint8_t *frev, uint8_t *crev, uint16_t *data_start);
-void atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t *frev, uint8_t *crev);
+bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
+                           uint8_t *frev, uint8_t *crev, uint16_t *data_start);
+bool atom_parse_cmd_header(struct atom_context *ctx, int index,
+                          uint8_t *frev, uint8_t *crev);
 int atom_allocate_fb_scratch(struct atom_context *ctx);
 #include "atom-types.h"
 #include "atombios.h"
index dd9fdf560611521aeb49d52f90da3fc3a59290df..fd4ef6d1884968345dcf0debbd70161fc31b3b4a 100644 (file)
@@ -353,12 +353,55 @@ static void atombios_crtc_set_timing(struct drm_crtc *crtc,
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 }
 
+static void atombios_disable_ss(struct drm_crtc *crtc)
+{
+       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+       struct drm_device *dev = crtc->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       u32 ss_cntl;
+
+       if (ASIC_IS_DCE4(rdev)) {
+               switch (radeon_crtc->pll_id) {
+               case ATOM_PPLL1:
+                       ss_cntl = RREG32(EVERGREEN_P1PLL_SS_CNTL);
+                       ss_cntl &= ~EVERGREEN_PxPLL_SS_EN;
+                       WREG32(EVERGREEN_P1PLL_SS_CNTL, ss_cntl);
+                       break;
+               case ATOM_PPLL2:
+                       ss_cntl = RREG32(EVERGREEN_P2PLL_SS_CNTL);
+                       ss_cntl &= ~EVERGREEN_PxPLL_SS_EN;
+                       WREG32(EVERGREEN_P2PLL_SS_CNTL, ss_cntl);
+                       break;
+               case ATOM_DCPLL:
+               case ATOM_PPLL_INVALID:
+                       return;
+               }
+       } else if (ASIC_IS_AVIVO(rdev)) {
+               switch (radeon_crtc->pll_id) {
+               case ATOM_PPLL1:
+                       ss_cntl = RREG32(AVIVO_P1PLL_INT_SS_CNTL);
+                       ss_cntl &= ~1;
+                       WREG32(AVIVO_P1PLL_INT_SS_CNTL, ss_cntl);
+                       break;
+               case ATOM_PPLL2:
+                       ss_cntl = RREG32(AVIVO_P2PLL_INT_SS_CNTL);
+                       ss_cntl &= ~1;
+                       WREG32(AVIVO_P2PLL_INT_SS_CNTL, ss_cntl);
+                       break;
+               case ATOM_DCPLL:
+               case ATOM_PPLL_INVALID:
+                       return;
+               }
+       }
+}
+
+
 union atom_enable_ss {
        ENABLE_LVDS_SS_PARAMETERS legacy;
        ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION v1;
 };
 
-static void atombios_set_ss(struct drm_crtc *crtc, int enable)
+static void atombios_enable_ss(struct drm_crtc *crtc)
 {
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
@@ -387,9 +430,9 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
                                        step = dig->ss->step;
                                        delay = dig->ss->delay;
                                        range = dig->ss->range;
-                               } else if (enable)
+                               } else
                                        return;
-                       } else if (enable)
+                       } else
                                return;
                        break;
                }
@@ -406,13 +449,13 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
                args.v1.ucSpreadSpectrumDelay = delay;
                args.v1.ucSpreadSpectrumRange = range;
                args.v1.ucPpll = radeon_crtc->crtc_id ? ATOM_PPLL2 : ATOM_PPLL1;
-               args.v1.ucEnable = enable;
+               args.v1.ucEnable = ATOM_ENABLE;
        } else {
                args.legacy.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
                args.legacy.ucSpreadSpectrumType = type;
                args.legacy.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2;
                args.legacy.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4;
-               args.legacy.ucEnable = enable;
+               args.legacy.ucEnable = ATOM_ENABLE;
        }
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
 }
@@ -478,11 +521,6 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
                                /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */
                                if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1)
                                        adjusted_clock = mode->clock * 2;
-                               /* LVDS PLL quirks */
-                               if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) {
-                                       struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
-                                       pll->algo = dig->pll_algo;
-                               }
                        } else {
                                if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
                                        pll->flags |= RADEON_PLL_NO_ODD_POST_DIV;
@@ -503,8 +541,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
                int index;
 
                index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll);
-               atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
-                                     &crev);
+               if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
+                                          &crev))
+                       return adjusted_clock;
 
                memset(&args, 0, sizeof(args));
 
@@ -542,11 +581,16 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
                                        }
                                } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
                                        /* may want to enable SS on DP/eDP eventually */
-                                       args.v3.sInput.ucDispPllConfig |=
-                                               DISPPLL_CONFIG_SS_ENABLE;
-                                       if (mode->clock > 165000)
+                                       /*args.v3.sInput.ucDispPllConfig |=
+                                               DISPPLL_CONFIG_SS_ENABLE;*/
+                                       if (encoder_mode == ATOM_ENCODER_MODE_DP)
                                                args.v3.sInput.ucDispPllConfig |=
-                                                       DISPPLL_CONFIG_DUAL_LINK;
+                                                       DISPPLL_CONFIG_COHERENT_MODE;
+                                       else {
+                                               if (mode->clock > 165000)
+                                                       args.v3.sInput.ucDispPllConfig |=
+                                                               DISPPLL_CONFIG_DUAL_LINK;
+                                       }
                                }
                                atom_execute_table(rdev->mode_info.atom_context,
                                                   index, (uint32_t *)&args);
@@ -592,8 +636,9 @@ static void atombios_crtc_set_dcpll(struct drm_crtc *crtc)
        memset(&args, 0, sizeof(args));
 
        index = GetIndexIntoMasterTable(COMMAND, SetPixelClock);
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
-                             &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
+                                  &crev))
+               return;
 
        switch (frev) {
        case 1:
@@ -667,8 +712,9 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
                           &ref_div, &post_div);
 
        index = GetIndexIntoMasterTable(COMMAND, SetPixelClock);
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
-                             &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
+                                  &crev))
+               return;
 
        switch (frev) {
        case 1:
@@ -1083,15 +1129,12 @@ int atombios_crtc_mode_set(struct drm_crtc *crtc,
 
        /* TODO color tiling */
 
-       /* pick pll */
-       radeon_crtc->pll_id = radeon_atom_pick_pll(crtc);
-
-       atombios_set_ss(crtc, 0);
+       atombios_disable_ss(crtc);
        /* always set DCPLL */
        if (ASIC_IS_DCE4(rdev))
                atombios_crtc_set_dcpll(crtc);
        atombios_crtc_set_pll(crtc, adjusted_mode);
-       atombios_set_ss(crtc, 1);
+       atombios_enable_ss(crtc);
 
        if (ASIC_IS_DCE4(rdev))
                atombios_set_crtc_dtd_timing(crtc, adjusted_mode);
@@ -1120,6 +1163,11 @@ static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc,
 
 static void atombios_crtc_prepare(struct drm_crtc *crtc)
 {
+       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
+
+       /* pick pll */
+       radeon_crtc->pll_id = radeon_atom_pick_pll(crtc);
+
        atombios_lock_crtc(crtc, ATOM_ENABLE);
        atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 }
index 8a133bda00a25b092e764f1eec2bca80c57cb569..28b31c64f48dd4eee064356c1d8a2bd840165f0d 100644 (file)
@@ -745,14 +745,14 @@ void dp_link_train(struct drm_encoder *encoder,
                          >> DP_TRAIN_PRE_EMPHASIS_SHIFT);
 
        /* disable the training pattern on the sink */
+       dp_set_training(radeon_connector, DP_TRAINING_PATTERN_DISABLE);
+
+       /* disable the training pattern on the source */
        if (ASIC_IS_DCE4(rdev))
                atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_LINK_TRAINING_COMPLETE);
        else
                radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_TRAINING_COMPLETE,
                                          dig_connector->dp_clock, enc_id, 0);
-
-       radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_TRAINING_COMPLETE,
-                                 dig_connector->dp_clock, enc_id, 0);
 }
 
 int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
index bd2e7aa85c1d66e710b1b6f97c7652b941db6d34..e8f447e20507313ed0367748b8fa585fdeec2bbf 100644 (file)
  */
 #include <linux/firmware.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "radeon_drm.h"
 #include "rv770d.h"
 #include "atom.h"
@@ -436,7 +438,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
 
 int evergreen_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
        u32 tmp;
        int chansize, numchan;
 
@@ -481,12 +482,8 @@ int evergreen_mc_init(struct radeon_device *rdev)
                rdev->mc.real_vram_size = rdev->mc.aper_size;
        }
        r600_vram_gtt_location(rdev, &rdev->mc);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+       radeon_update_bandwidth_info(rdev);
+
        return 0;
 }
 
@@ -746,6 +743,7 @@ int evergreen_init(struct radeon_device *rdev)
 
 void evergreen_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        evergreen_suspend(rdev);
 #if 0
        r600_blit_fini(rdev);
index 91eb762eb3f918625f3b17f0a8360551d628480e..c9580497ede40abcaa3a5cf465a8a95702e1d18d 100644 (file)
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "radeon_drm.h"
 #include "radeon_reg.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "r100d.h"
 #include "rs100d.h"
 #include "rv200d.h"
@@ -235,9 +237,9 @@ int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
 
 void r100_pci_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        r100_pci_gart_disable(rdev);
        radeon_gart_table_ram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 int r100_irq_set(struct radeon_device *rdev)
@@ -312,10 +314,12 @@ int r100_irq_process(struct radeon_device *rdev)
                /* Vertical blank interrupts */
                if (status & RADEON_CRTC_VBLANK_STAT) {
                        drm_handle_vblank(rdev->ddev, 0);
+                       rdev->pm.vblank_sync = true;
                        wake_up(&rdev->irq.vblank_queue);
                }
                if (status & RADEON_CRTC2_VBLANK_STAT) {
                        drm_handle_vblank(rdev->ddev, 1);
+                       rdev->pm.vblank_sync = true;
                        wake_up(&rdev->irq.vblank_queue);
                }
                if (status & RADEON_FP_DETECT_STAT) {
@@ -741,6 +745,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
        udelay(10);
        rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
        rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR);
+       /* protect against crazy HW on resume */
+       rdev->cp.wptr &= rdev->cp.ptr_mask;
        /* Set cp mode to bus mastering & enable cp*/
        WREG32(RADEON_CP_CSQ_MODE,
               REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
@@ -1804,6 +1810,7 @@ void r100_set_common_regs(struct radeon_device *rdev)
 {
        struct drm_device *dev = rdev->ddev;
        bool force_dac2 = false;
+       u32 tmp;
 
        /* set these so they don't interfere with anything */
        WREG32(RADEON_OV0_SCALE_CNTL, 0);
@@ -1875,6 +1882,12 @@ void r100_set_common_regs(struct radeon_device *rdev)
                WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
                WREG32(RADEON_DAC_CNTL2, dac2_cntl);
        }
+
+       /* switch PM block to ACPI mode */
+       tmp = RREG32_PLL(RADEON_PLL_PWRMGT_CNTL);
+       tmp &= ~RADEON_PM_MODE_SEL;
+       WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp);
+
 }
 
 /*
@@ -2022,6 +2035,7 @@ void r100_mc_init(struct radeon_device *rdev)
        radeon_vram_location(rdev, &rdev->mc, base);
        if (!(rdev->flags & RADEON_IS_AGP))
                radeon_gtt_location(rdev, &rdev->mc);
+       radeon_update_bandwidth_info(rdev);
 }
 
 
@@ -2385,6 +2399,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
        uint32_t pixel_bytes1 = 0;
        uint32_t pixel_bytes2 = 0;
 
+       radeon_update_display_priority(rdev);
+
        if (rdev->mode_info.crtcs[0]->base.enabled) {
                mode1 = &rdev->mode_info.crtcs[0]->base.mode;
                pixel_bytes1 = rdev->mode_info.crtcs[0]->base.fb->bits_per_pixel / 8;
@@ -2413,11 +2429,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
        /*
         * determine is there is enough bw for current mode
         */
-       mclk_ff.full = rfixed_const(rdev->clock.default_mclk);
-       temp_ff.full = rfixed_const(100);
-       mclk_ff.full = rfixed_div(mclk_ff, temp_ff);
-       sclk_ff.full = rfixed_const(rdev->clock.default_sclk);
-       sclk_ff.full = rfixed_div(sclk_ff, temp_ff);
+       sclk_ff = rdev->pm.sclk;
+       mclk_ff = rdev->pm.mclk;
 
        temp = (rdev->mc.vram_width / 8) * (rdev->mc.vram_is_ddr ? 2 : 1);
        temp_ff.full = rfixed_const(temp);
@@ -3440,6 +3453,7 @@ int r100_suspend(struct radeon_device *rdev)
 
 void r100_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index 1146c9909c2c11457f583edf73e8b5c31e0ab5b1..85617c3112127e09bd23442d6b84566ac99a29bd 100644 (file)
@@ -30,6 +30,7 @@
 #include "radeon_drm.h"
 #include "radeon_reg.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 
 #include "r100d.h"
 #include "r200_reg_safe.h"
index 4cef90cd74e5176fe01b41b37eb38d1050db1fb4..561048a7c0a4e876f2b5565593eee5785b9460b1 100644 (file)
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "radeon_reg.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "radeon_drm.h"
 #include "r100_track.h"
 #include "r300d.h"
@@ -164,9 +166,9 @@ void rv370_pcie_gart_disable(struct radeon_device *rdev)
 
 void rv370_pcie_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        rv370_pcie_gart_disable(rdev);
        radeon_gart_table_vram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 void r300_fence_ring_emit(struct radeon_device *rdev,
@@ -481,6 +483,7 @@ void r300_mc_init(struct radeon_device *rdev)
        radeon_vram_location(rdev, &rdev->mc, base);
        if (!(rdev->flags & RADEON_IS_AGP))
                radeon_gtt_location(rdev, &rdev->mc);
+       radeon_update_bandwidth_info(rdev);
 }
 
 void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes)
@@ -1334,6 +1337,7 @@ int r300_suspend(struct radeon_device *rdev)
 
 void r300_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index c7593b8f58eeaf61d41c8860fc0f74306071564e..3dc968c9f5a4c85e460d5175c2ec512995204ecd 100644 (file)
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "radeon_reg.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "atom.h"
 #include "r100d.h"
 #include "r420d.h"
@@ -266,6 +268,7 @@ int r420_suspend(struct radeon_device *rdev)
 
 void r420_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index 2b8a5dd1351672bbacbf260d33441910514ff7a9..3c44b8d393180283c71f566656b2edc78d0017bb 100644 (file)
@@ -27,6 +27,7 @@
  */
 #include "drmP.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "atom.h"
 #include "r520d.h"
 
@@ -121,19 +122,13 @@ static void r520_vram_get_type(struct radeon_device *rdev)
 
 void r520_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
 
        r520_vram_get_type(rdev);
        r100_vram_init_sizes(rdev);
        radeon_vram_location(rdev, &rdev->mc, 0);
        if (!(rdev->flags & RADEON_IS_AGP))
                radeon_gtt_location(rdev, &rdev->mc);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+       radeon_update_bandwidth_info(rdev);
 }
 
 void r520_mc_program(struct radeon_device *rdev)
index c52290197292a1a958d05dcd3896587055542b8b..8f3454e2056ae7520aea7dbb960833aaa72ad53c 100644 (file)
  *          Alex Deucher
  *          Jerome Glisse
  */
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/firmware.h>
 #include <linux/platform_device.h>
 #include "drmP.h"
 #include "radeon_drm.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "radeon_mode.h"
 #include "r600d.h"
 #include "atom.h"
@@ -491,9 +493,9 @@ void r600_pcie_gart_disable(struct radeon_device *rdev)
 
 void r600_pcie_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        r600_pcie_gart_disable(rdev);
        radeon_gart_table_vram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 void r600_agp_enable(struct radeon_device *rdev)
@@ -675,7 +677,6 @@ void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
 
 int r600_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
        u32 tmp;
        int chansize, numchan;
 
@@ -719,14 +720,10 @@ int r600_mc_init(struct radeon_device *rdev)
                rdev->mc.real_vram_size = rdev->mc.aper_size;
        }
        r600_vram_gtt_location(rdev, &rdev->mc);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+
        if (rdev->flags & RADEON_IS_IGP)
                rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
+       radeon_update_bandwidth_info(rdev);
        return 0;
 }
 
@@ -1132,6 +1129,7 @@ void r600_gpu_init(struct radeon_device *rdev)
        /* Setup pipes */
        WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
        WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
+       WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
 
        tmp = R6XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8);
        WREG32(VGT_OUT_DEALLOC_CNTL, (tmp * 4) & DEALLOC_DIST_MASK);
@@ -2119,6 +2117,7 @@ int r600_init(struct radeon_device *rdev)
 
 void r600_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r600_audio_fini(rdev);
        r600_blit_fini(rdev);
        r600_cp_fini(rdev);
@@ -2398,19 +2397,19 @@ static void r600_disable_interrupt_state(struct radeon_device *rdev)
                WREG32(DC_HPD4_INT_CONTROL, tmp);
                if (ASIC_IS_DCE32(rdev)) {
                        tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY;
-                       WREG32(DC_HPD5_INT_CONTROL, 0);
+                       WREG32(DC_HPD5_INT_CONTROL, tmp);
                        tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY;
-                       WREG32(DC_HPD6_INT_CONTROL, 0);
+                       WREG32(DC_HPD6_INT_CONTROL, tmp);
                }
        } else {
                WREG32(DACA_AUTODETECT_INT_CONTROL, 0);
                WREG32(DACB_AUTODETECT_INT_CONTROL, 0);
                tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
-               WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, 0);
+               WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp);
                tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
-               WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, 0);
+               WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp);
                tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
-               WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, 0);
+               WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, tmp);
        }
 }
 
@@ -2765,6 +2764,7 @@ restart_ih:
                        case 0: /* D1 vblank */
                                if (disp_int & LB_D1_VBLANK_INTERRUPT) {
                                        drm_handle_vblank(rdev->ddev, 0);
+                                       rdev->pm.vblank_sync = true;
                                        wake_up(&rdev->irq.vblank_queue);
                                        disp_int &= ~LB_D1_VBLANK_INTERRUPT;
                                        DRM_DEBUG("IH: D1 vblank\n");
@@ -2786,6 +2786,7 @@ restart_ih:
                        case 0: /* D2 vblank */
                                if (disp_int & LB_D2_VBLANK_INTERRUPT) {
                                        drm_handle_vblank(rdev->ddev, 1);
+                                       rdev->pm.vblank_sync = true;
                                        wake_up(&rdev->irq.vblank_queue);
                                        disp_int &= ~LB_D2_VBLANK_INTERRUPT;
                                        DRM_DEBUG("IH: D2 vblank\n");
@@ -2834,14 +2835,14 @@ restart_ih:
                                break;
                        case 10:
                                if (disp_int_cont2 & DC_HPD5_INTERRUPT) {
-                                       disp_int_cont &= ~DC_HPD5_INTERRUPT;
+                                       disp_int_cont2 &= ~DC_HPD5_INTERRUPT;
                                        queue_hotplug = true;
                                        DRM_DEBUG("IH: HPD5\n");
                                }
                                break;
                        case 12:
                                if (disp_int_cont2 & DC_HPD6_INTERRUPT) {
-                                       disp_int_cont &= ~DC_HPD6_INTERRUPT;
+                                       disp_int_cont2 &= ~DC_HPD6_INTERRUPT;
                                        queue_hotplug = true;
                                        DRM_DEBUG("IH: HPD6\n");
                                }
index db928016d034cc1e5fce5eba0718cc1a45dc3c0a..dac7042b797e031b47a049f1a09a6be853bfec02 100644 (file)
@@ -181,41 +181,6 @@ int r600_audio_init(struct radeon_device *rdev)
        return 0;
 }
 
-/*
- * determin how the encoders and audio interface is wired together
- */
-int r600_audio_tmds_index(struct drm_encoder *encoder)
-{
-       struct drm_device *dev = encoder->dev;
-       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-       struct drm_encoder *other;
-
-       switch (radeon_encoder->encoder_id) {
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
-               return 0;
-
-       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
-               /* special case check if an TMDS1 is present */
-               list_for_each_entry(other, &dev->mode_config.encoder_list, head) {
-                       if (to_radeon_encoder(other)->encoder_id ==
-                               ENCODER_OBJECT_ID_INTERNAL_TMDS1)
-                               return 1;
-               }
-               return 0;
-
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
-               return 1;
-
-       default:
-               DRM_ERROR("Unsupported encoder type 0x%02X\n",
-                         radeon_encoder->encoder_id);
-               return -1;
-       }
-}
-
 /*
  * atach the audio codec to the clock source of the encoder
  */
@@ -224,6 +189,7 @@ void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
        struct drm_device *dev = encoder->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
        int base_rate = 48000;
 
        switch (radeon_encoder->encoder_id) {
@@ -231,32 +197,34 @@ void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
        case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
                WREG32_P(R600_AUDIO_TIMING, 0, ~0x301);
                break;
-
        case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
        case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
        case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
        case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
                WREG32_P(R600_AUDIO_TIMING, 0x100, ~0x301);
                break;
-
        default:
                DRM_ERROR("Unsupported encoder type 0x%02X\n",
                          radeon_encoder->encoder_id);
                return;
        }
 
-       switch (r600_audio_tmds_index(encoder)) {
+       switch (dig->dig_encoder) {
        case 0:
-               WREG32(R600_AUDIO_PLL1_MUL, base_rate*50);
-               WREG32(R600_AUDIO_PLL1_DIV, clock*100);
+               WREG32(R600_AUDIO_PLL1_MUL, base_rate * 50);
+               WREG32(R600_AUDIO_PLL1_DIV, clock * 100);
                WREG32(R600_AUDIO_CLK_SRCSEL, 0);
                break;
 
        case 1:
-               WREG32(R600_AUDIO_PLL2_MUL, base_rate*50);
-               WREG32(R600_AUDIO_PLL2_DIV, clock*100);
+               WREG32(R600_AUDIO_PLL2_MUL, base_rate * 50);
+               WREG32(R600_AUDIO_PLL2_DIV, clock * 100);
                WREG32(R600_AUDIO_CLK_SRCSEL, 1);
                break;
+       default:
+               dev_err(rdev->dev, "Unsupported DIG on encoder 0x%02X\n",
+                         radeon_encoder->encoder_id);
+               return;
        }
 }
 
index a112c59f9d824988a8f0a399380c4041eace903d..0271b53fa2ddb0b49f7c99539287827d38197fb7 100644 (file)
@@ -1,7 +1,42 @@
+/*
+ * Copyright 2009 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Alex Deucher <alexander.deucher@amd.com>
+ */
 
 #include <linux/types.h>
 #include <linux/kernel.h>
 
+/*
+ * R6xx+ cards need to use the 3D engine to blit data which requires
+ * quite a bit of hw state setup.  Rather than pull the whole 3D driver
+ * (which normally generates the 3D state) into the DRM, we opt to use
+ * statically generated state tables.  The regsiter state and shaders
+ * were hand generated to support blitting functionality.  See the 3D
+ * driver or documentation for descriptions of the registers and
+ * shader instructions.
+ */
+
 const u32 r6xx_default_state[] =
 {
        0xc0002400,
index 40416c068d9f431491f85acba93462839700d22b..68e6f434930908a8ed4c1a48f702b904206f5c64 100644 (file)
@@ -1548,10 +1548,13 @@ static void r700_gfx_init(struct drm_device *dev,
 
        RADEON_WRITE(R600_CC_RB_BACKEND_DISABLE,      cc_rb_backend_disable);
        RADEON_WRITE(R600_CC_GC_SHADER_PIPE_CONFIG,   cc_gc_shader_pipe_config);
+       RADEON_WRITE(R600_GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
 
        RADEON_WRITE(R700_CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
        RADEON_WRITE(R700_CGTS_SYS_TCC_DISABLE, 0);
        RADEON_WRITE(R700_CGTS_TCC_DISABLE, 0);
+       RADEON_WRITE(R700_CGTS_USER_SYS_TCC_DISABLE, 0);
+       RADEON_WRITE(R700_CGTS_USER_TCC_DISABLE, 0);
 
        num_qd_pipes =
                R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & R600_INACTIVE_QD_PIPES_MASK) >> 8);
index cd2c63bce50172f6136dbeb64abfe69254e2d122..c39c1bc13016075f2bd7151937b3faadc2bf0143 100644 (file)
@@ -45,6 +45,7 @@ struct r600_cs_track {
        u32                     nbanks;
        u32                     npipes;
        /* value we track */
+       u32                     sq_config;
        u32                     nsamples;
        u32                     cb_color_base_last[8];
        struct radeon_bo        *cb_color_bo[8];
@@ -141,6 +142,8 @@ static void r600_cs_track_init(struct r600_cs_track *track)
 {
        int i;
 
+       /* assume DX9 mode */
+       track->sq_config = DX9_CONSTS;
        for (i = 0; i < 8; i++) {
                track->cb_color_base_last[i] = 0;
                track->cb_color_size[i] = 0;
@@ -715,6 +718,9 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
                tmp =radeon_get_ib_value(p, idx);
                ib[idx] = 0;
                break;
+       case SQ_CONFIG:
+               track->sq_config = radeon_get_ib_value(p, idx);
+               break;
        case R_028800_DB_DEPTH_CONTROL:
                track->db_depth_control = radeon_get_ib_value(p, idx);
                break;
@@ -869,6 +875,54 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
        case SQ_PGM_START_VS:
        case SQ_PGM_START_GS:
        case SQ_PGM_START_PS:
+       case SQ_ALU_CONST_CACHE_GS_0:
+       case SQ_ALU_CONST_CACHE_GS_1:
+       case SQ_ALU_CONST_CACHE_GS_2:
+       case SQ_ALU_CONST_CACHE_GS_3:
+       case SQ_ALU_CONST_CACHE_GS_4:
+       case SQ_ALU_CONST_CACHE_GS_5:
+       case SQ_ALU_CONST_CACHE_GS_6:
+       case SQ_ALU_CONST_CACHE_GS_7:
+       case SQ_ALU_CONST_CACHE_GS_8:
+       case SQ_ALU_CONST_CACHE_GS_9:
+       case SQ_ALU_CONST_CACHE_GS_10:
+       case SQ_ALU_CONST_CACHE_GS_11:
+       case SQ_ALU_CONST_CACHE_GS_12:
+       case SQ_ALU_CONST_CACHE_GS_13:
+       case SQ_ALU_CONST_CACHE_GS_14:
+       case SQ_ALU_CONST_CACHE_GS_15:
+       case SQ_ALU_CONST_CACHE_PS_0:
+       case SQ_ALU_CONST_CACHE_PS_1:
+       case SQ_ALU_CONST_CACHE_PS_2:
+       case SQ_ALU_CONST_CACHE_PS_3:
+       case SQ_ALU_CONST_CACHE_PS_4:
+       case SQ_ALU_CONST_CACHE_PS_5:
+       case SQ_ALU_CONST_CACHE_PS_6:
+       case SQ_ALU_CONST_CACHE_PS_7:
+       case SQ_ALU_CONST_CACHE_PS_8:
+       case SQ_ALU_CONST_CACHE_PS_9:
+       case SQ_ALU_CONST_CACHE_PS_10:
+       case SQ_ALU_CONST_CACHE_PS_11:
+       case SQ_ALU_CONST_CACHE_PS_12:
+       case SQ_ALU_CONST_CACHE_PS_13:
+       case SQ_ALU_CONST_CACHE_PS_14:
+       case SQ_ALU_CONST_CACHE_PS_15:
+       case SQ_ALU_CONST_CACHE_VS_0:
+       case SQ_ALU_CONST_CACHE_VS_1:
+       case SQ_ALU_CONST_CACHE_VS_2:
+       case SQ_ALU_CONST_CACHE_VS_3:
+       case SQ_ALU_CONST_CACHE_VS_4:
+       case SQ_ALU_CONST_CACHE_VS_5:
+       case SQ_ALU_CONST_CACHE_VS_6:
+       case SQ_ALU_CONST_CACHE_VS_7:
+       case SQ_ALU_CONST_CACHE_VS_8:
+       case SQ_ALU_CONST_CACHE_VS_9:
+       case SQ_ALU_CONST_CACHE_VS_10:
+       case SQ_ALU_CONST_CACHE_VS_11:
+       case SQ_ALU_CONST_CACHE_VS_12:
+       case SQ_ALU_CONST_CACHE_VS_13:
+       case SQ_ALU_CONST_CACHE_VS_14:
+       case SQ_ALU_CONST_CACHE_VS_15:
                r = r600_cs_packet_next_reloc(p, &reloc);
                if (r) {
                        dev_warn(p->dev, "bad SET_CONTEXT_REG "
@@ -1226,13 +1280,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
                }
                break;
        case PACKET3_SET_ALU_CONST:
-               start_reg = (idx_value << 2) + PACKET3_SET_ALU_CONST_OFFSET;
-               end_reg = 4 * pkt->count + start_reg - 4;
-               if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) ||
-                   (start_reg >= PACKET3_SET_ALU_CONST_END) ||
-                   (end_reg >= PACKET3_SET_ALU_CONST_END)) {
-                       DRM_ERROR("bad SET_ALU_CONST\n");
-                       return -EINVAL;
+               if (track->sq_config & DX9_CONSTS) {
+                       start_reg = (idx_value << 2) + PACKET3_SET_ALU_CONST_OFFSET;
+                       end_reg = 4 * pkt->count + start_reg - 4;
+                       if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) ||
+                           (start_reg >= PACKET3_SET_ALU_CONST_END) ||
+                           (end_reg >= PACKET3_SET_ALU_CONST_END)) {
+                               DRM_ERROR("bad SET_ALU_CONST\n");
+                               return -EINVAL;
+                       }
                }
                break;
        case PACKET3_SET_BOOL_CONST:
index fcc949df0e5d26ac8b3271b24549e88d6524a39b..029fa1406d1d43b3a8a99708fa117d324be5adb8 100644 (file)
@@ -42,13 +42,13 @@ enum r600_hdmi_color_format {
  */
 enum r600_hdmi_iec_status_bits {
        AUDIO_STATUS_DIG_ENABLE   = 0x01,
-       AUDIO_STATUS_V      = 0x02,
-       AUDIO_STATUS_VCFG        = 0x04,
+       AUDIO_STATUS_V            = 0x02,
+       AUDIO_STATUS_VCFG         = 0x04,
        AUDIO_STATUS_EMPHASIS     = 0x08,
        AUDIO_STATUS_COPYRIGHT    = 0x10,
        AUDIO_STATUS_NONAUDIO     = 0x20,
        AUDIO_STATUS_PROFESSIONAL = 0x40,
-       AUDIO_STATUS_LEVEL      = 0x80
+       AUDIO_STATUS_LEVEL        = 0x80
 };
 
 struct {
@@ -85,7 +85,7 @@ struct {
 static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
 {
        if (*CTS == 0)
-               *CTS = clock*N/(128*freq)*1000;
+               *CTS = clock * N / (128 * freq) * 1000;
        DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
                  N, *CTS, freq);
 }
@@ -131,11 +131,11 @@ static void r600_hdmi_infoframe_checksum(uint8_t packetType,
                                         uint8_t length,
                                         uint8_t *frame)
 {
-    int i;
-    frame[0] = packetType + versionNumber + length;
-    for (i = 1; i <= length; i++)
-       frame[0] += frame[i];
-    frame[0] = 0x100 - frame[0];
+       int i;
+       frame[0] = packetType + versionNumber + length;
+       for (i = 1; i <= length; i++)
+               frame[0] += frame[i];
+       frame[0] = 0x100 - frame[0];
 }
 
 /*
@@ -417,90 +417,141 @@ void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
        WREG32_P(offset+R600_HDMI_CNTL, 0x04000000, ~0x04000000);
 }
 
-/*
- * enable/disable the HDMI engine
- */
-void r600_hdmi_enable(struct drm_encoder *encoder, int enable)
+static int r600_hdmi_find_free_block(struct drm_device *dev)
+{
+       struct radeon_device *rdev = dev->dev_private;
+       struct drm_encoder *encoder;
+       struct radeon_encoder *radeon_encoder;
+       bool free_blocks[3] = { true, true, true };
+
+       list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+               radeon_encoder = to_radeon_encoder(encoder);
+               switch (radeon_encoder->hdmi_offset) {
+               case R600_HDMI_BLOCK1:
+                       free_blocks[0] = false;
+                       break;
+               case R600_HDMI_BLOCK2:
+                       free_blocks[1] = false;
+                       break;
+               case R600_HDMI_BLOCK3:
+                       free_blocks[2] = false;
+                       break;
+               }
+       }
+
+       if (rdev->family == CHIP_RS600 || rdev->family == CHIP_RS690) {
+               return free_blocks[0] ? R600_HDMI_BLOCK1 : 0;
+       } else if (rdev->family >= CHIP_R600) {
+               if (free_blocks[0])
+                       return R600_HDMI_BLOCK1;
+               else if (free_blocks[1])
+                       return R600_HDMI_BLOCK2;
+       }
+       return 0;
+}
+
+static void r600_hdmi_assign_block(struct drm_encoder *encoder)
 {
        struct drm_device *dev = encoder->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+       struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 
-       if (!offset)
+       if (!dig) {
+               dev_err(rdev->dev, "Enabling HDMI on non-dig encoder\n");
                return;
+       }
 
-       DRM_DEBUG("%s HDMI interface @ 0x%04X\n", enable ? "Enabling" : "Disabling", offset);
-
-       /* some version of atombios ignore the enable HDMI flag
-        * so enabling/disabling HDMI was moved here for TMDS1+2 */
-       switch (radeon_encoder->encoder_id) {
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
-               WREG32_P(AVIVO_TMDSA_CNTL, enable ? 0x4 : 0x0, ~0x4);
-               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x101 : 0x0);
-               break;
-
-       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
-               WREG32_P(AVIVO_LVTMA_CNTL, enable ? 0x4 : 0x0, ~0x4);
-               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x105 : 0x0);
-               break;
-
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
-               /* This part is doubtfull in my opinion */
-               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x110 : 0x0);
-               break;
-
-       default:
-               DRM_ERROR("unknown HDMI output type\n");
-               break;
+       if (ASIC_IS_DCE4(rdev)) {
+               /* TODO */
+       } else if (ASIC_IS_DCE3(rdev)) {
+               radeon_encoder->hdmi_offset = dig->dig_encoder ?
+                       R600_HDMI_BLOCK3 : R600_HDMI_BLOCK1;
+               if (ASIC_IS_DCE32(rdev))
+                       radeon_encoder->hdmi_config_offset = dig->dig_encoder ?
+                               R600_HDMI_CONFIG2 : R600_HDMI_CONFIG1;
+       } else if (rdev->family >= CHIP_R600) {
+               radeon_encoder->hdmi_offset = r600_hdmi_find_free_block(dev);
        }
 }
 
 /*
- * determin at which register offset the HDMI encoder is
+ * enable the HDMI engine
  */
-void r600_hdmi_init(struct drm_encoder *encoder)
+void r600_hdmi_enable(struct drm_encoder *encoder)
 {
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 
-       switch (radeon_encoder->encoder_id) {
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
-               radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
-               break;
-
-       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
-               switch (r600_audio_tmds_index(encoder)) {
-               case 0:
-                       radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
+       if (!radeon_encoder->hdmi_offset) {
+               r600_hdmi_assign_block(encoder);
+               if (!radeon_encoder->hdmi_offset) {
+                       dev_warn(rdev->dev, "Could not find HDMI block for "
+                               "0x%x encoder\n", radeon_encoder->encoder_id);
+                       return;
+               }
+       }
+
+       if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
+               WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0x1, ~0x1);
+       } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
+               int offset = radeon_encoder->hdmi_offset;
+               switch (radeon_encoder->encoder_id) {
+               case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+                       WREG32_P(AVIVO_TMDSA_CNTL, 0x4, ~0x4);
+                       WREG32(offset + R600_HDMI_ENABLE, 0x101);
                        break;
-               case 1:
-                       radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
+               case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+                       WREG32_P(AVIVO_LVTMA_CNTL, 0x4, ~0x4);
+                       WREG32(offset + R600_HDMI_ENABLE, 0x105);
                        break;
                default:
-                       radeon_encoder->hdmi_offset = 0;
+                       dev_err(rdev->dev, "Unknown HDMI output type\n");
                        break;
                }
-       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
-               radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
-               break;
+       }
 
-       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
-               radeon_encoder->hdmi_offset = R600_HDMI_DIG;
-               break;
+       DRM_DEBUG("Enabling HDMI interface @ 0x%04X for encoder 0x%x\n",
+               radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
+}
 
-       default:
-               radeon_encoder->hdmi_offset = 0;
-               break;
+/*
+ * disable the HDMI engine
+ */
+void r600_hdmi_disable(struct drm_encoder *encoder)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+
+       if (!radeon_encoder->hdmi_offset) {
+               dev_err(rdev->dev, "Disabling not enabled HDMI\n");
+               return;
        }
 
-       DRM_DEBUG("using HDMI engine at offset 0x%04X for encoder 0x%x\n",
-                 radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
+       DRM_DEBUG("Disabling HDMI interface @ 0x%04X for encoder 0x%x\n",
+               radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
+
+       if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
+               WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0, ~0x1);
+       } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
+               int offset = radeon_encoder->hdmi_offset;
+               switch (radeon_encoder->encoder_id) {
+               case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+                       WREG32_P(AVIVO_TMDSA_CNTL, 0, ~0x4);
+                       WREG32(offset + R600_HDMI_ENABLE, 0);
+                       break;
+               case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+                       WREG32_P(AVIVO_LVTMA_CNTL, 0, ~0x4);
+                       WREG32(offset + R600_HDMI_ENABLE, 0);
+                       break;
+               default:
+                       dev_err(rdev->dev, "Unknown HDMI output type\n");
+                       break;
+               }
+       }
 
-       /* TODO: make this configureable */
-       radeon_encoder->hdmi_audio_workaround = 0;
+       radeon_encoder->hdmi_offset = 0;
+       radeon_encoder->hdmi_config_offset = 0;
 }
index d0e28ffdeda9400564ce40cea7a22e7fca2533f5..7b1d22370f6e2bc2fb78521b3a8e61aa49e8d44f 100644 (file)
 #define R600_AUDIO_STATUS_BITS            0x73d8
 
 /* HDMI base register addresses */
-#define R600_HDMI_TMDS1                   0x7400
-#define R600_HDMI_TMDS2                   0x7700
-#define R600_HDMI_DIG                     0x7800
+#define R600_HDMI_BLOCK1                  0x7400
+#define R600_HDMI_BLOCK2                  0x7700
+#define R600_HDMI_BLOCK3                  0x7800
 
 /* HDMI registers */
 #define R600_HDMI_ENABLE           0x00
 #define R600_HDMI_AUDIO_DEBUG_2    0xe8
 #define R600_HDMI_AUDIO_DEBUG_3    0xec
 
+/* HDMI additional config base register addresses */
+#define R600_HDMI_CONFIG1                 0x7600
+#define R600_HDMI_CONFIG2                 0x7a00
+
 #endif
index 5b2e4d44282394ba85598c2ae6a91bd7ffc42b79..59c1f8793e608df971466a9545ccc32c81e529fd 100644 (file)
 #define CB_COLOR0_FRAG                                  0x280e0
 #define CB_COLOR0_MASK                                  0x28100
 
+#define SQ_ALU_CONST_CACHE_PS_0                                0x28940
+#define SQ_ALU_CONST_CACHE_PS_1                                0x28944
+#define SQ_ALU_CONST_CACHE_PS_2                                0x28948
+#define SQ_ALU_CONST_CACHE_PS_3                                0x2894c
+#define SQ_ALU_CONST_CACHE_PS_4                                0x28950
+#define SQ_ALU_CONST_CACHE_PS_5                                0x28954
+#define SQ_ALU_CONST_CACHE_PS_6                                0x28958
+#define SQ_ALU_CONST_CACHE_PS_7                                0x2895c
+#define SQ_ALU_CONST_CACHE_PS_8                                0x28960
+#define SQ_ALU_CONST_CACHE_PS_9                                0x28964
+#define SQ_ALU_CONST_CACHE_PS_10                       0x28968
+#define SQ_ALU_CONST_CACHE_PS_11                       0x2896c
+#define SQ_ALU_CONST_CACHE_PS_12                       0x28970
+#define SQ_ALU_CONST_CACHE_PS_13                       0x28974
+#define SQ_ALU_CONST_CACHE_PS_14                       0x28978
+#define SQ_ALU_CONST_CACHE_PS_15                       0x2897c
+#define SQ_ALU_CONST_CACHE_VS_0                                0x28980
+#define SQ_ALU_CONST_CACHE_VS_1                                0x28984
+#define SQ_ALU_CONST_CACHE_VS_2                                0x28988
+#define SQ_ALU_CONST_CACHE_VS_3                                0x2898c
+#define SQ_ALU_CONST_CACHE_VS_4                                0x28990
+#define SQ_ALU_CONST_CACHE_VS_5                                0x28994
+#define SQ_ALU_CONST_CACHE_VS_6                                0x28998
+#define SQ_ALU_CONST_CACHE_VS_7                                0x2899c
+#define SQ_ALU_CONST_CACHE_VS_8                                0x289a0
+#define SQ_ALU_CONST_CACHE_VS_9                                0x289a4
+#define SQ_ALU_CONST_CACHE_VS_10                       0x289a8
+#define SQ_ALU_CONST_CACHE_VS_11                       0x289ac
+#define SQ_ALU_CONST_CACHE_VS_12                       0x289b0
+#define SQ_ALU_CONST_CACHE_VS_13                       0x289b4
+#define SQ_ALU_CONST_CACHE_VS_14                       0x289b8
+#define SQ_ALU_CONST_CACHE_VS_15                       0x289bc
+#define SQ_ALU_CONST_CACHE_GS_0                                0x289c0
+#define SQ_ALU_CONST_CACHE_GS_1                                0x289c4
+#define SQ_ALU_CONST_CACHE_GS_2                                0x289c8
+#define SQ_ALU_CONST_CACHE_GS_3                                0x289cc
+#define SQ_ALU_CONST_CACHE_GS_4                                0x289d0
+#define SQ_ALU_CONST_CACHE_GS_5                                0x289d4
+#define SQ_ALU_CONST_CACHE_GS_6                                0x289d8
+#define SQ_ALU_CONST_CACHE_GS_7                                0x289dc
+#define SQ_ALU_CONST_CACHE_GS_8                                0x289e0
+#define SQ_ALU_CONST_CACHE_GS_9                                0x289e4
+#define SQ_ALU_CONST_CACHE_GS_10                       0x289e8
+#define SQ_ALU_CONST_CACHE_GS_11                       0x289ec
+#define SQ_ALU_CONST_CACHE_GS_12                       0x289f0
+#define SQ_ALU_CONST_CACHE_GS_13                       0x289f4
+#define SQ_ALU_CONST_CACHE_GS_14                       0x289f8
+#define SQ_ALU_CONST_CACHE_GS_15                       0x289fc
+
 #define        CONFIG_MEMSIZE                                  0x5428
 #define CONFIG_CNTL                                    0x5424
 #define        CP_STAT                                         0x8680
index 829e26e8a4bb877f43dc2b8f12646e5d840753cb..034218c3dbbbb11d8248606074debc81fe42df8b 100644 (file)
@@ -91,6 +91,8 @@ extern int radeon_tv;
 extern int radeon_new_pll;
 extern int radeon_dynpm;
 extern int radeon_audio;
+extern int radeon_disp_priority;
+extern int radeon_hw_i2c;
 
 /*
  * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -168,6 +170,7 @@ struct radeon_clock {
  * Power management
  */
 int radeon_pm_init(struct radeon_device *rdev);
+void radeon_pm_fini(struct radeon_device *rdev);
 void radeon_pm_compute_clocks(struct radeon_device *rdev);
 void radeon_combios_get_power_modes(struct radeon_device *rdev);
 void radeon_atombios_get_power_modes(struct radeon_device *rdev);
@@ -687,6 +690,7 @@ struct radeon_pm {
        bool                    downclocked;
        int                     active_crtcs;
        int                     req_vblank;
+       bool                    vblank_sync;
        fixed20_12              max_bandwidth;
        fixed20_12              igp_sideport_mclk;
        fixed20_12              igp_system_mclk;
@@ -697,6 +701,7 @@ struct radeon_pm {
        fixed20_12              ht_bandwidth;
        fixed20_12              core_bandwidth;
        fixed20_12              sclk;
+       fixed20_12              mclk;
        fixed20_12              needed_bandwidth;
        /* XXX: use a define for num power modes */
        struct radeon_power_state power_state[8];
@@ -707,6 +712,7 @@ struct radeon_pm {
        struct radeon_power_state *requested_power_state;
        struct radeon_pm_clock_info *requested_clock_mode;
        struct radeon_power_state *default_power_state;
+       struct radeon_i2c_chan *i2c_bus;
 };
 
 
@@ -729,8 +735,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
                             struct drm_info_list *files,
                             unsigned nfiles);
 int radeon_debugfs_fence_init(struct radeon_device *rdev);
-int r100_debugfs_rbbm_init(struct radeon_device *rdev);
-int r100_debugfs_cp_init(struct radeon_device *rdev);
 
 
 /*
@@ -782,7 +786,7 @@ struct radeon_asic {
        int (*set_surface_reg)(struct radeon_device *rdev, int reg,
                               uint32_t tiling_flags, uint32_t pitch,
                               uint32_t offset, uint32_t obj_size);
-       int (*clear_surface_reg)(struct radeon_device *rdev, int reg);
+       void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
        void (*bandwidth_update)(struct radeon_device *rdev);
        void (*hpd_init)(struct radeon_device *rdev);
        void (*hpd_fini)(struct radeon_device *rdev);
@@ -862,6 +866,12 @@ union radeon_asic_config {
        struct rv770_asic       rv770;
 };
 
+/*
+ * asic initizalization from radeon_asic.c
+ */
+void radeon_agp_disable(struct radeon_device *rdev);
+int radeon_asic_init(struct radeon_device *rdev);
+
 
 /*
  * IOCTL.
@@ -1172,6 +1182,8 @@ extern void radeon_gart_restore(struct radeon_device *rdev);
 extern int radeon_modeset_init(struct radeon_device *rdev);
 extern void radeon_modeset_fini(struct radeon_device *rdev);
 extern bool radeon_card_posted(struct radeon_device *rdev);
+extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
+extern void radeon_update_display_priority(struct radeon_device *rdev);
 extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
 extern int radeon_clocks_init(struct radeon_device *rdev);
 extern void radeon_clocks_fini(struct radeon_device *rdev);
@@ -1188,51 +1200,6 @@ extern int radeon_resume_kms(struct drm_device *dev);
 extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
 
 /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
-struct r100_mc_save {
-       u32     GENMO_WT;
-       u32     CRTC_EXT_CNTL;
-       u32     CRTC_GEN_CNTL;
-       u32     CRTC2_GEN_CNTL;
-       u32     CUR_OFFSET;
-       u32     CUR2_OFFSET;
-};
-extern void r100_cp_disable(struct radeon_device *rdev);
-extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
-extern void r100_cp_fini(struct radeon_device *rdev);
-extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
-extern int r100_pci_gart_init(struct radeon_device *rdev);
-extern void r100_pci_gart_fini(struct radeon_device *rdev);
-extern int r100_pci_gart_enable(struct radeon_device *rdev);
-extern void r100_pci_gart_disable(struct radeon_device *rdev);
-extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
-extern int r100_debugfs_mc_info_init(struct radeon_device *rdev);
-extern int r100_gui_wait_for_idle(struct radeon_device *rdev);
-extern void r100_ib_fini(struct radeon_device *rdev);
-extern int r100_ib_init(struct radeon_device *rdev);
-extern void r100_irq_disable(struct radeon_device *rdev);
-extern int r100_irq_set(struct radeon_device *rdev);
-extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
-extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
-extern void r100_vram_init_sizes(struct radeon_device *rdev);
-extern void r100_wb_disable(struct radeon_device *rdev);
-extern void r100_wb_fini(struct radeon_device *rdev);
-extern int r100_wb_init(struct radeon_device *rdev);
-extern void r100_hdp_reset(struct radeon_device *rdev);
-extern int r100_rb2d_reset(struct radeon_device *rdev);
-extern int r100_cp_reset(struct radeon_device *rdev);
-extern void r100_vga_render_disable(struct radeon_device *rdev);
-extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
-                                               struct radeon_cs_packet *pkt,
-                                               struct radeon_bo *robj);
-extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
-                               struct radeon_cs_packet *pkt,
-                               const unsigned *auth, unsigned n,
-                               radeon_packet0_check_t check);
-extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
-                               struct radeon_cs_packet *pkt,
-                               unsigned idx);
-extern void r100_enable_bm(struct radeon_device *rdev);
-extern void r100_set_common_regs(struct radeon_device *rdev);
 
 /* rv200,rv250,rv280 */
 extern void r200_set_safe_registers(struct radeon_device *rdev);
@@ -1322,7 +1289,8 @@ extern int r600_audio_tmds_index(struct drm_encoder *encoder);
 extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);
 extern void r600_audio_fini(struct radeon_device *rdev);
 extern void r600_hdmi_init(struct drm_encoder *encoder);
-extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable);
+extern void r600_hdmi_enable(struct drm_encoder *encoder);
+extern void r600_hdmi_disable(struct drm_encoder *encoder);
 extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
 extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder);
 extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
new file mode 100644 (file)
index 0000000..a4b4bc9
--- /dev/null
@@ -0,0 +1,772 @@
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ * Copyright 2008 Red Hat Inc.
+ * Copyright 2009 Jerome Glisse.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Dave Airlie
+ *          Alex Deucher
+ *          Jerome Glisse
+ */
+
+#include <linux/console.h>
+#include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/radeon_drm.h>
+#include <linux/vgaarb.h>
+#include <linux/vga_switcheroo.h>
+#include "radeon_reg.h"
+#include "radeon.h"
+#include "radeon_asic.h"
+#include "atom.h"
+
+/*
+ * Registers accessors functions.
+ */
+static uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg)
+{
+       DRM_ERROR("Invalid callback to read register 0x%04X\n", reg);
+       BUG_ON(1);
+       return 0;
+}
+
+static void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
+{
+       DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n",
+                 reg, v);
+       BUG_ON(1);
+}
+
+static void radeon_register_accessor_init(struct radeon_device *rdev)
+{
+       rdev->mc_rreg = &radeon_invalid_rreg;
+       rdev->mc_wreg = &radeon_invalid_wreg;
+       rdev->pll_rreg = &radeon_invalid_rreg;
+       rdev->pll_wreg = &radeon_invalid_wreg;
+       rdev->pciep_rreg = &radeon_invalid_rreg;
+       rdev->pciep_wreg = &radeon_invalid_wreg;
+
+       /* Don't change order as we are overridding accessor. */
+       if (rdev->family < CHIP_RV515) {
+               rdev->pcie_reg_mask = 0xff;
+       } else {
+               rdev->pcie_reg_mask = 0x7ff;
+       }
+       /* FIXME: not sure here */
+       if (rdev->family <= CHIP_R580) {
+               rdev->pll_rreg = &r100_pll_rreg;
+               rdev->pll_wreg = &r100_pll_wreg;
+       }
+       if (rdev->family >= CHIP_R420) {
+               rdev->mc_rreg = &r420_mc_rreg;
+               rdev->mc_wreg = &r420_mc_wreg;
+       }
+       if (rdev->family >= CHIP_RV515) {
+               rdev->mc_rreg = &rv515_mc_rreg;
+               rdev->mc_wreg = &rv515_mc_wreg;
+       }
+       if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
+               rdev->mc_rreg = &rs400_mc_rreg;
+               rdev->mc_wreg = &rs400_mc_wreg;
+       }
+       if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
+               rdev->mc_rreg = &rs690_mc_rreg;
+               rdev->mc_wreg = &rs690_mc_wreg;
+       }
+       if (rdev->family == CHIP_RS600) {
+               rdev->mc_rreg = &rs600_mc_rreg;
+               rdev->mc_wreg = &rs600_mc_wreg;
+       }
+       if ((rdev->family >= CHIP_R600) && (rdev->family <= CHIP_RV740)) {
+               rdev->pciep_rreg = &r600_pciep_rreg;
+               rdev->pciep_wreg = &r600_pciep_wreg;
+       }
+}
+
+
+/* helper to disable agp */
+void radeon_agp_disable(struct radeon_device *rdev)
+{
+       rdev->flags &= ~RADEON_IS_AGP;
+       if (rdev->family >= CHIP_R600) {
+               DRM_INFO("Forcing AGP to PCIE mode\n");
+               rdev->flags |= RADEON_IS_PCIE;
+       } else if (rdev->family >= CHIP_RV515 ||
+                       rdev->family == CHIP_RV380 ||
+                       rdev->family == CHIP_RV410 ||
+                       rdev->family == CHIP_R423) {
+               DRM_INFO("Forcing AGP to PCIE mode\n");
+               rdev->flags |= RADEON_IS_PCIE;
+               rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
+               rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
+       } else {
+               DRM_INFO("Forcing AGP to PCI mode\n");
+               rdev->flags |= RADEON_IS_PCI;
+               rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
+               rdev->asic->gart_set_page = &r100_pci_gart_set_page;
+       }
+       rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
+}
+
+/*
+ * ASIC
+ */
+static struct radeon_asic r100_asic = {
+       .init = &r100_init,
+       .fini = &r100_fini,
+       .suspend = &r100_suspend,
+       .resume = &r100_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r100_gpu_reset,
+       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
+       .gart_set_page = &r100_pci_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r100_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r100_fence_ring_emit,
+       .cs_parse = &r100_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = NULL,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_legacy_get_engine_clock,
+       .set_engine_clock = &radeon_legacy_set_engine_clock,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
+       .set_memory_clock = NULL,
+       .get_pcie_lanes = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_legacy_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r200_asic = {
+       .init = &r100_init,
+       .fini = &r100_fini,
+       .suspend = &r100_suspend,
+       .resume = &r100_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r100_gpu_reset,
+       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
+       .gart_set_page = &r100_pci_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r100_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r100_fence_ring_emit,
+       .cs_parse = &r100_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_legacy_get_engine_clock,
+       .set_engine_clock = &radeon_legacy_set_engine_clock,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
+       .set_memory_clock = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_legacy_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r300_asic = {
+       .init = &r300_init,
+       .fini = &r300_fini,
+       .suspend = &r300_suspend,
+       .resume = &r300_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
+       .gart_set_page = &r100_pci_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_legacy_get_engine_clock,
+       .set_engine_clock = &radeon_legacy_set_engine_clock,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
+       .set_memory_clock = NULL,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = &rv370_set_pcie_lanes,
+       .set_clock_gating = &radeon_legacy_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r300_asic_pcie = {
+       .init = &r300_init,
+       .fini = &r300_fini,
+       .suspend = &r300_suspend,
+       .resume = &r300_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
+       .gart_set_page = &rv370_pcie_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_legacy_get_engine_clock,
+       .set_engine_clock = &radeon_legacy_set_engine_clock,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
+       .set_memory_clock = NULL,
+       .set_pcie_lanes = &rv370_set_pcie_lanes,
+       .set_clock_gating = &radeon_legacy_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r420_asic = {
+       .init = &r420_init,
+       .fini = &r420_fini,
+       .suspend = &r420_suspend,
+       .resume = &r420_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
+       .gart_set_page = &rv370_pcie_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = &rv370_set_pcie_lanes,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic rs400_asic = {
+       .init = &rs400_init,
+       .fini = &rs400_fini,
+       .suspend = &rs400_suspend,
+       .resume = &rs400_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &rs400_gart_tlb_flush,
+       .gart_set_page = &rs400_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &r100_irq_set,
+       .irq_process = &r100_irq_process,
+       .get_vblank_counter = &r100_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_legacy_get_engine_clock,
+       .set_engine_clock = &radeon_legacy_set_engine_clock,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
+       .set_memory_clock = NULL,
+       .get_pcie_lanes = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_legacy_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &r100_bandwidth_update,
+       .hpd_init = &r100_hpd_init,
+       .hpd_fini = &r100_hpd_fini,
+       .hpd_sense = &r100_hpd_sense,
+       .hpd_set_polarity = &r100_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic rs600_asic = {
+       .init = &rs600_init,
+       .fini = &rs600_fini,
+       .suspend = &rs600_suspend,
+       .resume = &rs600_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &rs600_gart_tlb_flush,
+       .gart_set_page = &rs600_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &rs600_irq_set,
+       .irq_process = &rs600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &rs600_bandwidth_update,
+       .hpd_init = &rs600_hpd_init,
+       .hpd_fini = &rs600_hpd_fini,
+       .hpd_sense = &rs600_hpd_sense,
+       .hpd_set_polarity = &rs600_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic rs690_asic = {
+       .init = &rs690_init,
+       .fini = &rs690_fini,
+       .suspend = &rs690_suspend,
+       .resume = &rs690_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &r300_gpu_reset,
+       .gart_tlb_flush = &rs400_gart_tlb_flush,
+       .gart_set_page = &rs400_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &r300_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &rs600_irq_set,
+       .irq_process = &rs600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r200_copy_dma,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &rs690_bandwidth_update,
+       .hpd_init = &rs600_hpd_init,
+       .hpd_fini = &rs600_hpd_fini,
+       .hpd_sense = &rs600_hpd_sense,
+       .hpd_set_polarity = &rs600_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic rv515_asic = {
+       .init = &rv515_init,
+       .fini = &rv515_fini,
+       .suspend = &rv515_suspend,
+       .resume = &rv515_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &rv515_gpu_reset,
+       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
+       .gart_set_page = &rv370_pcie_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &rv515_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &rs600_irq_set,
+       .irq_process = &rs600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = &rv370_set_pcie_lanes,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &rv515_bandwidth_update,
+       .hpd_init = &rs600_hpd_init,
+       .hpd_fini = &rs600_hpd_fini,
+       .hpd_sense = &rs600_hpd_sense,
+       .hpd_set_polarity = &rs600_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r520_asic = {
+       .init = &r520_init,
+       .fini = &rv515_fini,
+       .suspend = &rv515_suspend,
+       .resume = &r520_resume,
+       .vga_set_state = &r100_vga_set_state,
+       .gpu_reset = &rv515_gpu_reset,
+       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
+       .gart_set_page = &rv370_pcie_gart_set_page,
+       .cp_commit = &r100_cp_commit,
+       .ring_start = &rv515_ring_start,
+       .ring_test = &r100_ring_test,
+       .ring_ib_execute = &r100_ring_ib_execute,
+       .irq_set = &rs600_irq_set,
+       .irq_process = &rs600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r300_fence_ring_emit,
+       .cs_parse = &r300_cs_parse,
+       .copy_blit = &r100_copy_blit,
+       .copy_dma = &r200_copy_dma,
+       .copy = &r100_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = &rv370_set_pcie_lanes,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r100_set_surface_reg,
+       .clear_surface_reg = r100_clear_surface_reg,
+       .bandwidth_update = &rv515_bandwidth_update,
+       .hpd_init = &rs600_hpd_init,
+       .hpd_fini = &rs600_hpd_fini,
+       .hpd_sense = &rs600_hpd_sense,
+       .hpd_set_polarity = &rs600_hpd_set_polarity,
+       .ioctl_wait_idle = NULL,
+};
+
+static struct radeon_asic r600_asic = {
+       .init = &r600_init,
+       .fini = &r600_fini,
+       .suspend = &r600_suspend,
+       .resume = &r600_resume,
+       .cp_commit = &r600_cp_commit,
+       .vga_set_state = &r600_vga_set_state,
+       .gpu_reset = &r600_gpu_reset,
+       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
+       .gart_set_page = &rs600_gart_set_page,
+       .ring_test = &r600_ring_test,
+       .ring_ib_execute = &r600_ring_ib_execute,
+       .irq_set = &r600_irq_set,
+       .irq_process = &r600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r600_fence_ring_emit,
+       .cs_parse = &r600_cs_parse,
+       .copy_blit = &r600_copy_blit,
+       .copy_dma = &r600_copy_blit,
+       .copy = &r600_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = NULL,
+       .set_surface_reg = r600_set_surface_reg,
+       .clear_surface_reg = r600_clear_surface_reg,
+       .bandwidth_update = &rv515_bandwidth_update,
+       .hpd_init = &r600_hpd_init,
+       .hpd_fini = &r600_hpd_fini,
+       .hpd_sense = &r600_hpd_sense,
+       .hpd_set_polarity = &r600_hpd_set_polarity,
+       .ioctl_wait_idle = r600_ioctl_wait_idle,
+};
+
+static struct radeon_asic rs780_asic = {
+       .init = &r600_init,
+       .fini = &r600_fini,
+       .suspend = &r600_suspend,
+       .resume = &r600_resume,
+       .cp_commit = &r600_cp_commit,
+       .vga_set_state = &r600_vga_set_state,
+       .gpu_reset = &r600_gpu_reset,
+       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
+       .gart_set_page = &rs600_gart_set_page,
+       .ring_test = &r600_ring_test,
+       .ring_ib_execute = &r600_ring_ib_execute,
+       .irq_set = &r600_irq_set,
+       .irq_process = &r600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r600_fence_ring_emit,
+       .cs_parse = &r600_cs_parse,
+       .copy_blit = &r600_copy_blit,
+       .copy_dma = &r600_copy_blit,
+       .copy = &r600_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = NULL,
+       .set_memory_clock = NULL,
+       .get_pcie_lanes = NULL,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = NULL,
+       .set_surface_reg = r600_set_surface_reg,
+       .clear_surface_reg = r600_clear_surface_reg,
+       .bandwidth_update = &rs690_bandwidth_update,
+       .hpd_init = &r600_hpd_init,
+       .hpd_fini = &r600_hpd_fini,
+       .hpd_sense = &r600_hpd_sense,
+       .hpd_set_polarity = &r600_hpd_set_polarity,
+       .ioctl_wait_idle = r600_ioctl_wait_idle,
+};
+
+static struct radeon_asic rv770_asic = {
+       .init = &rv770_init,
+       .fini = &rv770_fini,
+       .suspend = &rv770_suspend,
+       .resume = &rv770_resume,
+       .cp_commit = &r600_cp_commit,
+       .gpu_reset = &rv770_gpu_reset,
+       .vga_set_state = &r600_vga_set_state,
+       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
+       .gart_set_page = &rs600_gart_set_page,
+       .ring_test = &r600_ring_test,
+       .ring_ib_execute = &r600_ring_ib_execute,
+       .irq_set = &r600_irq_set,
+       .irq_process = &r600_irq_process,
+       .get_vblank_counter = &rs600_get_vblank_counter,
+       .fence_ring_emit = &r600_fence_ring_emit,
+       .cs_parse = &r600_cs_parse,
+       .copy_blit = &r600_copy_blit,
+       .copy_dma = &r600_copy_blit,
+       .copy = &r600_copy_blit,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .get_pcie_lanes = &rv370_get_pcie_lanes,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = &radeon_atom_set_clock_gating,
+       .set_surface_reg = r600_set_surface_reg,
+       .clear_surface_reg = r600_clear_surface_reg,
+       .bandwidth_update = &rv515_bandwidth_update,
+       .hpd_init = &r600_hpd_init,
+       .hpd_fini = &r600_hpd_fini,
+       .hpd_sense = &r600_hpd_sense,
+       .hpd_set_polarity = &r600_hpd_set_polarity,
+       .ioctl_wait_idle = r600_ioctl_wait_idle,
+};
+
+static struct radeon_asic evergreen_asic = {
+       .init = &evergreen_init,
+       .fini = &evergreen_fini,
+       .suspend = &evergreen_suspend,
+       .resume = &evergreen_resume,
+       .cp_commit = NULL,
+       .gpu_reset = &evergreen_gpu_reset,
+       .vga_set_state = &r600_vga_set_state,
+       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
+       .gart_set_page = &rs600_gart_set_page,
+       .ring_test = NULL,
+       .ring_ib_execute = NULL,
+       .irq_set = NULL,
+       .irq_process = NULL,
+       .get_vblank_counter = NULL,
+       .fence_ring_emit = NULL,
+       .cs_parse = NULL,
+       .copy_blit = NULL,
+       .copy_dma = NULL,
+       .copy = NULL,
+       .get_engine_clock = &radeon_atom_get_engine_clock,
+       .set_engine_clock = &radeon_atom_set_engine_clock,
+       .get_memory_clock = &radeon_atom_get_memory_clock,
+       .set_memory_clock = &radeon_atom_set_memory_clock,
+       .set_pcie_lanes = NULL,
+       .set_clock_gating = NULL,
+       .set_surface_reg = r600_set_surface_reg,
+       .clear_surface_reg = r600_clear_surface_reg,
+       .bandwidth_update = &evergreen_bandwidth_update,
+       .hpd_init = &evergreen_hpd_init,
+       .hpd_fini = &evergreen_hpd_fini,
+       .hpd_sense = &evergreen_hpd_sense,
+       .hpd_set_polarity = &evergreen_hpd_set_polarity,
+};
+
+int radeon_asic_init(struct radeon_device *rdev)
+{
+       radeon_register_accessor_init(rdev);
+       switch (rdev->family) {
+       case CHIP_R100:
+       case CHIP_RV100:
+       case CHIP_RS100:
+       case CHIP_RV200:
+       case CHIP_RS200:
+               rdev->asic = &r100_asic;
+               break;
+       case CHIP_R200:
+       case CHIP_RV250:
+       case CHIP_RS300:
+       case CHIP_RV280:
+               rdev->asic = &r200_asic;
+               break;
+       case CHIP_R300:
+       case CHIP_R350:
+       case CHIP_RV350:
+       case CHIP_RV380:
+               if (rdev->flags & RADEON_IS_PCIE)
+                       rdev->asic = &r300_asic_pcie;
+               else
+                       rdev->asic = &r300_asic;
+               break;
+       case CHIP_R420:
+       case CHIP_R423:
+       case CHIP_RV410:
+               rdev->asic = &r420_asic;
+               break;
+       case CHIP_RS400:
+       case CHIP_RS480:
+               rdev->asic = &rs400_asic;
+               break;
+       case CHIP_RS600:
+               rdev->asic = &rs600_asic;
+               break;
+       case CHIP_RS690:
+       case CHIP_RS740:
+               rdev->asic = &rs690_asic;
+               break;
+       case CHIP_RV515:
+               rdev->asic = &rv515_asic;
+               break;
+       case CHIP_R520:
+       case CHIP_RV530:
+       case CHIP_RV560:
+       case CHIP_RV570:
+       case CHIP_R580:
+               rdev->asic = &r520_asic;
+               break;
+       case CHIP_R600:
+       case CHIP_RV610:
+       case CHIP_RV630:
+       case CHIP_RV620:
+       case CHIP_RV635:
+       case CHIP_RV670:
+               rdev->asic = &r600_asic;
+               break;
+       case CHIP_RS780:
+       case CHIP_RS880:
+               rdev->asic = &rs780_asic;
+               break;
+       case CHIP_RV770:
+       case CHIP_RV730:
+       case CHIP_RV710:
+       case CHIP_RV740:
+               rdev->asic = &rv770_asic;
+               break;
+       case CHIP_CEDAR:
+       case CHIP_REDWOOD:
+       case CHIP_JUNIPER:
+       case CHIP_CYPRESS:
+       case CHIP_HEMLOCK:
+               rdev->asic = &evergreen_asic;
+               break;
+       default:
+               /* FIXME: not supported yet */
+               return -EINVAL;
+       }
+
+       if (rdev->flags & RADEON_IS_IGP) {
+               rdev->asic->get_memory_clock = NULL;
+               rdev->asic->set_memory_clock = NULL;
+       }
+
+       /* set the number of crtcs */
+       if (rdev->flags & RADEON_SINGLE_CRTC)
+               rdev->num_crtc = 1;
+       else {
+               if (ASIC_IS_DCE4(rdev))
+                       rdev->num_crtc = 6;
+               else
+                       rdev->num_crtc = 2;
+       }
+
+       return 0;
+}
+
+/*
+ * Wrapper around modesetting bits. Move to radeon_clocks.c?
+ */
+int radeon_clocks_init(struct radeon_device *rdev)
+{
+       int r;
+
+       r = radeon_static_clocks_init(rdev->ddev);
+       if (r) {
+               return r;
+       }
+       DRM_INFO("Clocks initialized !\n");
+       return 0;
+}
+
+void radeon_clocks_fini(struct radeon_device *rdev)
+{
+}
index d3a157b2bcb73ab51e1d68d0430c65a9916a70b0..a0b8280663d1ba9d17dd6252cce1274d73b7181d 100644 (file)
@@ -45,10 +45,18 @@ void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
 /*
  * r100,rv100,rs100,rv200,rs200
  */
-extern int r100_init(struct radeon_device *rdev);
-extern void r100_fini(struct radeon_device *rdev);
-extern int r100_suspend(struct radeon_device *rdev);
-extern int r100_resume(struct radeon_device *rdev);
+struct r100_mc_save {
+       u32     GENMO_WT;
+       u32     CRTC_EXT_CNTL;
+       u32     CRTC_GEN_CNTL;
+       u32     CRTC2_GEN_CNTL;
+       u32     CUR_OFFSET;
+       u32     CUR2_OFFSET;
+};
+int r100_init(struct radeon_device *rdev);
+void r100_fini(struct radeon_device *rdev);
+int r100_suspend(struct radeon_device *rdev);
+int r100_resume(struct radeon_device *rdev);
 uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg);
 void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
 void r100_vga_set_state(struct radeon_device *rdev, bool state);
@@ -73,7 +81,7 @@ int r100_copy_blit(struct radeon_device *rdev,
 int r100_set_surface_reg(struct radeon_device *rdev, int reg,
                         uint32_t tiling_flags, uint32_t pitch,
                         uint32_t offset, uint32_t obj_size);
-int r100_clear_surface_reg(struct radeon_device *rdev, int reg);
+void r100_clear_surface_reg(struct radeon_device *rdev, int reg);
 void r100_bandwidth_update(struct radeon_device *rdev);
 void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
 int r100_ring_test(struct radeon_device *rdev);
@@ -82,44 +90,42 @@ void r100_hpd_fini(struct radeon_device *rdev);
 bool r100_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
 void r100_hpd_set_polarity(struct radeon_device *rdev,
                           enum radeon_hpd_id hpd);
-
-static struct radeon_asic r100_asic = {
-       .init = &r100_init,
-       .fini = &r100_fini,
-       .suspend = &r100_suspend,
-       .resume = &r100_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r100_gpu_reset,
-       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
-       .gart_set_page = &r100_pci_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r100_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r100_fence_ring_emit,
-       .cs_parse = &r100_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = NULL,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_legacy_get_engine_clock,
-       .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = &radeon_legacy_get_memory_clock,
-       .set_memory_clock = NULL,
-       .get_pcie_lanes = NULL,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_legacy_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
+int r100_debugfs_rbbm_init(struct radeon_device *rdev);
+int r100_debugfs_cp_init(struct radeon_device *rdev);
+void r100_cp_disable(struct radeon_device *rdev);
+int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
+void r100_cp_fini(struct radeon_device *rdev);
+int r100_pci_gart_init(struct radeon_device *rdev);
+void r100_pci_gart_fini(struct radeon_device *rdev);
+int r100_pci_gart_enable(struct radeon_device *rdev);
+void r100_pci_gart_disable(struct radeon_device *rdev);
+int r100_debugfs_mc_info_init(struct radeon_device *rdev);
+int r100_gui_wait_for_idle(struct radeon_device *rdev);
+void r100_ib_fini(struct radeon_device *rdev);
+int r100_ib_init(struct radeon_device *rdev);
+void r100_irq_disable(struct radeon_device *rdev);
+void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
+void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
+void r100_vram_init_sizes(struct radeon_device *rdev);
+void r100_wb_disable(struct radeon_device *rdev);
+void r100_wb_fini(struct radeon_device *rdev);
+int r100_wb_init(struct radeon_device *rdev);
+void r100_hdp_reset(struct radeon_device *rdev);
+int r100_rb2d_reset(struct radeon_device *rdev);
+int r100_cp_reset(struct radeon_device *rdev);
+void r100_vga_render_disable(struct radeon_device *rdev);
+int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
+                                        struct radeon_cs_packet *pkt,
+                                        struct radeon_bo *robj);
+int r100_cs_parse_packet0(struct radeon_cs_parser *p,
+                         struct radeon_cs_packet *pkt,
+                         const unsigned *auth, unsigned n,
+                         radeon_packet0_check_t check);
+int r100_cs_packet_parse(struct radeon_cs_parser *p,
+                        struct radeon_cs_packet *pkt,
+                        unsigned idx);
+void r100_enable_bm(struct radeon_device *rdev);
+void r100_set_common_regs(struct radeon_device *rdev);
 
 /*
  * r200,rv250,rs300,rv280
@@ -129,43 +135,6 @@ extern int r200_copy_dma(struct radeon_device *rdev,
                        uint64_t dst_offset,
                        unsigned num_pages,
                        struct radeon_fence *fence);
-static struct radeon_asic r200_asic = {
-       .init = &r100_init,
-       .fini = &r100_fini,
-       .suspend = &r100_suspend,
-       .resume = &r100_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r100_gpu_reset,
-       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
-       .gart_set_page = &r100_pci_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r100_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r100_fence_ring_emit,
-       .cs_parse = &r100_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_legacy_get_engine_clock,
-       .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = &radeon_legacy_get_memory_clock,
-       .set_memory_clock = NULL,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_legacy_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 
 /*
  * r300,r350,rv350,rv380
@@ -186,82 +155,6 @@ extern void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v
 extern void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes);
 extern int rv370_get_pcie_lanes(struct radeon_device *rdev);
 
-static struct radeon_asic r300_asic = {
-       .init = &r300_init,
-       .fini = &r300_fini,
-       .suspend = &r300_suspend,
-       .resume = &r300_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &r100_pci_gart_tlb_flush,
-       .gart_set_page = &r100_pci_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_legacy_get_engine_clock,
-       .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = &radeon_legacy_get_memory_clock,
-       .set_memory_clock = NULL,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = &rv370_set_pcie_lanes,
-       .set_clock_gating = &radeon_legacy_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
-
-static struct radeon_asic r300_asic_pcie = {
-       .init = &r300_init,
-       .fini = &r300_fini,
-       .suspend = &r300_suspend,
-       .resume = &r300_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
-       .gart_set_page = &rv370_pcie_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_legacy_get_engine_clock,
-       .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = &radeon_legacy_get_memory_clock,
-       .set_memory_clock = NULL,
-       .set_pcie_lanes = &rv370_set_pcie_lanes,
-       .set_clock_gating = &radeon_legacy_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 /*
  * r420,r423,rv410
  */
@@ -269,44 +162,6 @@ extern int r420_init(struct radeon_device *rdev);
 extern void r420_fini(struct radeon_device *rdev);
 extern int r420_suspend(struct radeon_device *rdev);
 extern int r420_resume(struct radeon_device *rdev);
-static struct radeon_asic r420_asic = {
-       .init = &r420_init,
-       .fini = &r420_fini,
-       .suspend = &r420_suspend,
-       .resume = &r420_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
-       .gart_set_page = &rv370_pcie_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = &rv370_set_pcie_lanes,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 
 /*
  * rs400,rs480
@@ -319,44 +174,6 @@ void rs400_gart_tlb_flush(struct radeon_device *rdev);
 int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
 uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg);
 void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
-static struct radeon_asic rs400_asic = {
-       .init = &rs400_init,
-       .fini = &rs400_fini,
-       .suspend = &rs400_suspend,
-       .resume = &rs400_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &rs400_gart_tlb_flush,
-       .gart_set_page = &rs400_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &r100_irq_set,
-       .irq_process = &r100_irq_process,
-       .get_vblank_counter = &r100_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_legacy_get_engine_clock,
-       .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = &radeon_legacy_get_memory_clock,
-       .set_memory_clock = NULL,
-       .get_pcie_lanes = NULL,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_legacy_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &r100_bandwidth_update,
-       .hpd_init = &r100_hpd_init,
-       .hpd_fini = &r100_hpd_fini,
-       .hpd_sense = &r100_hpd_sense,
-       .hpd_set_polarity = &r100_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 
 /*
  * rs600.
@@ -379,45 +196,6 @@ bool rs600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
 void rs600_hpd_set_polarity(struct radeon_device *rdev,
                            enum radeon_hpd_id hpd);
 
-static struct radeon_asic rs600_asic = {
-       .init = &rs600_init,
-       .fini = &rs600_fini,
-       .suspend = &rs600_suspend,
-       .resume = &rs600_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &rs600_gart_tlb_flush,
-       .gart_set_page = &rs600_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &rs600_irq_set,
-       .irq_process = &rs600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = NULL,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &rs600_bandwidth_update,
-       .hpd_init = &rs600_hpd_init,
-       .hpd_fini = &rs600_hpd_fini,
-       .hpd_sense = &rs600_hpd_sense,
-       .hpd_set_polarity = &rs600_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
-
 /*
  * rs690,rs740
  */
@@ -428,44 +206,6 @@ int rs690_suspend(struct radeon_device *rdev);
 uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg);
 void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
 void rs690_bandwidth_update(struct radeon_device *rdev);
-static struct radeon_asic rs690_asic = {
-       .init = &rs690_init,
-       .fini = &rs690_fini,
-       .suspend = &rs690_suspend,
-       .resume = &rs690_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &r300_gpu_reset,
-       .gart_tlb_flush = &rs400_gart_tlb_flush,
-       .gart_set_page = &rs400_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &r300_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &rs600_irq_set,
-       .irq_process = &rs600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r200_copy_dma,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = NULL,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &rs690_bandwidth_update,
-       .hpd_init = &rs600_hpd_init,
-       .hpd_fini = &rs600_hpd_fini,
-       .hpd_sense = &rs600_hpd_sense,
-       .hpd_set_polarity = &rs600_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 
 /*
  * rv515
@@ -481,87 +221,12 @@ void rv515_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
 void rv515_bandwidth_update(struct radeon_device *rdev);
 int rv515_resume(struct radeon_device *rdev);
 int rv515_suspend(struct radeon_device *rdev);
-static struct radeon_asic rv515_asic = {
-       .init = &rv515_init,
-       .fini = &rv515_fini,
-       .suspend = &rv515_suspend,
-       .resume = &rv515_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &rv515_gpu_reset,
-       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
-       .gart_set_page = &rv370_pcie_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &rv515_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &rs600_irq_set,
-       .irq_process = &rs600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = &rv370_set_pcie_lanes,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &rv515_bandwidth_update,
-       .hpd_init = &rs600_hpd_init,
-       .hpd_fini = &rs600_hpd_fini,
-       .hpd_sense = &rs600_hpd_sense,
-       .hpd_set_polarity = &rs600_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
-
 
 /*
  * r520,rv530,rv560,rv570,r580
  */
 int r520_init(struct radeon_device *rdev);
 int r520_resume(struct radeon_device *rdev);
-static struct radeon_asic r520_asic = {
-       .init = &r520_init,
-       .fini = &rv515_fini,
-       .suspend = &rv515_suspend,
-       .resume = &r520_resume,
-       .vga_set_state = &r100_vga_set_state,
-       .gpu_reset = &rv515_gpu_reset,
-       .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
-       .gart_set_page = &rv370_pcie_gart_set_page,
-       .cp_commit = &r100_cp_commit,
-       .ring_start = &rv515_ring_start,
-       .ring_test = &r100_ring_test,
-       .ring_ib_execute = &r100_ring_ib_execute,
-       .irq_set = &rs600_irq_set,
-       .irq_process = &rs600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r300_fence_ring_emit,
-       .cs_parse = &r300_cs_parse,
-       .copy_blit = &r100_copy_blit,
-       .copy_dma = &r200_copy_dma,
-       .copy = &r100_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = &rv370_set_pcie_lanes,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r100_set_surface_reg,
-       .clear_surface_reg = r100_clear_surface_reg,
-       .bandwidth_update = &rv515_bandwidth_update,
-       .hpd_init = &rs600_hpd_init,
-       .hpd_fini = &rs600_hpd_fini,
-       .hpd_sense = &rs600_hpd_sense,
-       .hpd_set_polarity = &rs600_hpd_set_polarity,
-       .ioctl_wait_idle = NULL,
-};
 
 /*
  * r600,rv610,rv630,rv620,rv635,rv670,rs780,rs880
@@ -591,7 +256,7 @@ int r600_gpu_reset(struct radeon_device *rdev);
 int r600_set_surface_reg(struct radeon_device *rdev, int reg,
                         uint32_t tiling_flags, uint32_t pitch,
                         uint32_t offset, uint32_t obj_size);
-int r600_clear_surface_reg(struct radeon_device *rdev, int reg);
+void r600_clear_surface_reg(struct radeon_device *rdev, int reg);
 void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
 int r600_ring_test(struct radeon_device *rdev);
 int r600_copy_blit(struct radeon_device *rdev,
@@ -604,43 +269,6 @@ void r600_hpd_set_polarity(struct radeon_device *rdev,
                           enum radeon_hpd_id hpd);
 extern void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo);
 
-static struct radeon_asic r600_asic = {
-       .init = &r600_init,
-       .fini = &r600_fini,
-       .suspend = &r600_suspend,
-       .resume = &r600_resume,
-       .cp_commit = &r600_cp_commit,
-       .vga_set_state = &r600_vga_set_state,
-       .gpu_reset = &r600_gpu_reset,
-       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
-       .gart_set_page = &rs600_gart_set_page,
-       .ring_test = &r600_ring_test,
-       .ring_ib_execute = &r600_ring_ib_execute,
-       .irq_set = &r600_irq_set,
-       .irq_process = &r600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r600_fence_ring_emit,
-       .cs_parse = &r600_cs_parse,
-       .copy_blit = &r600_copy_blit,
-       .copy_dma = &r600_copy_blit,
-       .copy = &r600_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = NULL,
-       .set_surface_reg = r600_set_surface_reg,
-       .clear_surface_reg = r600_clear_surface_reg,
-       .bandwidth_update = &rv515_bandwidth_update,
-       .hpd_init = &r600_hpd_init,
-       .hpd_fini = &r600_hpd_fini,
-       .hpd_sense = &r600_hpd_sense,
-       .hpd_set_polarity = &r600_hpd_set_polarity,
-       .ioctl_wait_idle = r600_ioctl_wait_idle,
-};
-
 /*
  * rv770,rv730,rv710,rv740
  */
@@ -650,43 +278,6 @@ int rv770_suspend(struct radeon_device *rdev);
 int rv770_resume(struct radeon_device *rdev);
 int rv770_gpu_reset(struct radeon_device *rdev);
 
-static struct radeon_asic rv770_asic = {
-       .init = &rv770_init,
-       .fini = &rv770_fini,
-       .suspend = &rv770_suspend,
-       .resume = &rv770_resume,
-       .cp_commit = &r600_cp_commit,
-       .gpu_reset = &rv770_gpu_reset,
-       .vga_set_state = &r600_vga_set_state,
-       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
-       .gart_set_page = &rs600_gart_set_page,
-       .ring_test = &r600_ring_test,
-       .ring_ib_execute = &r600_ring_ib_execute,
-       .irq_set = &r600_irq_set,
-       .irq_process = &r600_irq_process,
-       .get_vblank_counter = &rs600_get_vblank_counter,
-       .fence_ring_emit = &r600_fence_ring_emit,
-       .cs_parse = &r600_cs_parse,
-       .copy_blit = &r600_copy_blit,
-       .copy_dma = &r600_copy_blit,
-       .copy = &r600_copy_blit,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .get_pcie_lanes = &rv370_get_pcie_lanes,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = &radeon_atom_set_clock_gating,
-       .set_surface_reg = r600_set_surface_reg,
-       .clear_surface_reg = r600_clear_surface_reg,
-       .bandwidth_update = &rv515_bandwidth_update,
-       .hpd_init = &r600_hpd_init,
-       .hpd_fini = &r600_hpd_fini,
-       .hpd_sense = &r600_hpd_sense,
-       .hpd_set_polarity = &r600_hpd_set_polarity,
-       .ioctl_wait_idle = r600_ioctl_wait_idle,
-};
-
 /*
  * evergreen
  */
@@ -701,40 +292,4 @@ void evergreen_hpd_fini(struct radeon_device *rdev);
 bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
 void evergreen_hpd_set_polarity(struct radeon_device *rdev,
                                enum radeon_hpd_id hpd);
-
-static struct radeon_asic evergreen_asic = {
-       .init = &evergreen_init,
-       .fini = &evergreen_fini,
-       .suspend = &evergreen_suspend,
-       .resume = &evergreen_resume,
-       .cp_commit = NULL,
-       .gpu_reset = &evergreen_gpu_reset,
-       .vga_set_state = &r600_vga_set_state,
-       .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
-       .gart_set_page = &rs600_gart_set_page,
-       .ring_test = NULL,
-       .ring_ib_execute = NULL,
-       .irq_set = NULL,
-       .irq_process = NULL,
-       .get_vblank_counter = NULL,
-       .fence_ring_emit = NULL,
-       .cs_parse = NULL,
-       .copy_blit = NULL,
-       .copy_dma = NULL,
-       .copy = NULL,
-       .get_engine_clock = &radeon_atom_get_engine_clock,
-       .set_engine_clock = &radeon_atom_set_engine_clock,
-       .get_memory_clock = &radeon_atom_get_memory_clock,
-       .set_memory_clock = &radeon_atom_set_memory_clock,
-       .set_pcie_lanes = NULL,
-       .set_clock_gating = NULL,
-       .set_surface_reg = r600_set_surface_reg,
-       .clear_surface_reg = r600_clear_surface_reg,
-       .bandwidth_update = &evergreen_bandwidth_update,
-       .hpd_init = &evergreen_hpd_init,
-       .hpd_fini = &evergreen_hpd_fini,
-       .hpd_sense = &evergreen_hpd_sense,
-       .hpd_set_polarity = &evergreen_hpd_set_polarity,
-};
-
 #endif
index 93783b15c81d8226d9833c730af74250d8e3fb5e..1fff95505cf5fec08f5506c47e26b8e00866632c 100644 (file)
@@ -75,46 +75,45 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev
        memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
        i2c.valid = false;
 
-       atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
-
-       i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
-
-
-       for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
-               gpio = &i2c_info->asGPIO_Info[i];
-
-               if (gpio->sucI2cId.ucAccess == id) {
-                       i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
-                       i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
-                       i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
-                       i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
-                       i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
-                       i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
-                       i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
-                       i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
-                       i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
-                       i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
-                       i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
-                       i2c.en_data_mask = (1 << gpio->ucDataEnShift);
-                       i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
-                       i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
-                       i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
-                       i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
-
-                       if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
-                               i2c.hw_capable = true;
-                       else
-                               i2c.hw_capable = false;
-
-                       if (gpio->sucI2cId.ucAccess == 0xa0)
-                               i2c.mm_i2c = true;
-                       else
-                               i2c.mm_i2c = false;
-
-                       i2c.i2c_id = gpio->sucI2cId.ucAccess;
-
-                       i2c.valid = true;
-                       break;
+       if (atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) {
+               i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
+
+               for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
+                       gpio = &i2c_info->asGPIO_Info[i];
+
+                       if (gpio->sucI2cId.ucAccess == id) {
+                               i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
+                               i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
+                               i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
+                               i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
+                               i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
+                               i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
+                               i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
+                               i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
+                               i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
+                               i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
+                               i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
+                               i2c.en_data_mask = (1 << gpio->ucDataEnShift);
+                               i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
+                               i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
+                               i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
+                               i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
+
+                               if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
+                                       i2c.hw_capable = true;
+                               else
+                                       i2c.hw_capable = false;
+
+                               if (gpio->sucI2cId.ucAccess == 0xa0)
+                                       i2c.mm_i2c = true;
+                               else
+                                       i2c.mm_i2c = false;
+
+                               i2c.i2c_id = gpio->sucI2cId.ucAccess;
+
+                               i2c.valid = true;
+                               break;
+                       }
                }
        }
 
@@ -135,20 +134,21 @@ static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rd
        memset(&gpio, 0, sizeof(struct radeon_gpio_rec));
        gpio.valid = false;
 
-       atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset);
+       if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
+               gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset);
 
-       gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset);
+               num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
+                       sizeof(ATOM_GPIO_PIN_ASSIGNMENT);
 
-       num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(ATOM_GPIO_PIN_ASSIGNMENT);
-
-       for (i = 0; i < num_indices; i++) {
-               pin = &gpio_info->asGPIO_Pin[i];
-               if (id == pin->ucGPIO_ID) {
-                       gpio.id = pin->ucGPIO_ID;
-                       gpio.reg = pin->usGpioPin_AIndex * 4;
-                       gpio.mask = (1 << pin->ucGpioPinBitShift);
-                       gpio.valid = true;
-                       break;
+               for (i = 0; i < num_indices; i++) {
+                       pin = &gpio_info->asGPIO_Pin[i];
+                       if (id == pin->ucGPIO_ID) {
+                               gpio.id = pin->ucGPIO_ID;
+                               gpio.reg = pin->usGpioPin_AIndex * 4;
+                               gpio.mask = (1 << pin->ucGpioPinBitShift);
+                               gpio.valid = true;
+                               break;
+                       }
                }
        }
 
@@ -264,6 +264,8 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
                if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) ||
                    (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
                        return false;
+               if (supported_device == ATOM_DEVICE_CRT2_SUPPORT)
+                       *line_mux = 0x90;
        }
 
        /* ASUS HD 3600 XT board lists the DVI port as HDMI */
@@ -395,9 +397,7 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
        struct radeon_gpio_rec gpio;
        struct radeon_hpd hpd;
 
-       atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
-
-       if (data_offset == 0)
+       if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
                return false;
 
        if (crev < 2)
@@ -449,37 +449,43 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
                                    GetIndexIntoMasterTable(DATA,
                                                            IntegratedSystemInfo);
 
-                               atom_parse_data_header(ctx, index, &size, &frev,
-                                                      &crev, &igp_offset);
-
-                               if (crev >= 2) {
-                                       igp_obj =
-                                           (ATOM_INTEGRATED_SYSTEM_INFO_V2
-                                            *) (ctx->bios + igp_offset);
-
-                                       if (igp_obj) {
-                                               uint32_t slot_config, ct;
-
-                                               if (con_obj_num == 1)
-                                                       slot_config =
-                                                           igp_obj->
-                                                           ulDDISlot1Config;
-                                               else
-                                                       slot_config =
-                                                           igp_obj->
-                                                           ulDDISlot2Config;
-
-                                               ct = (slot_config >> 16) & 0xff;
-                                               connector_type =
-                                                   object_connector_convert
-                                                   [ct];
-                                               connector_object_id = ct;
-                                               igp_lane_info =
-                                                   slot_config & 0xffff;
+                               if (atom_parse_data_header(ctx, index, &size, &frev,
+                                                          &crev, &igp_offset)) {
+
+                                       if (crev >= 2) {
+                                               igp_obj =
+                                                       (ATOM_INTEGRATED_SYSTEM_INFO_V2
+                                                        *) (ctx->bios + igp_offset);
+
+                                               if (igp_obj) {
+                                                       uint32_t slot_config, ct;
+
+                                                       if (con_obj_num == 1)
+                                                               slot_config =
+                                                                       igp_obj->
+                                                                       ulDDISlot1Config;
+                                                       else
+                                                               slot_config =
+                                                                       igp_obj->
+                                                                       ulDDISlot2Config;
+
+                                                       ct = (slot_config >> 16) & 0xff;
+                                                       connector_type =
+                                                               object_connector_convert
+                                                               [ct];
+                                                       connector_object_id = ct;
+                                                       igp_lane_info =
+                                                               slot_config & 0xffff;
+                                               } else
+                                                       continue;
                                        } else
                                                continue;
-                               } else
-                                       continue;
+                               } else {
+                                       igp_lane_info = 0;
+                                       connector_type =
+                                               object_connector_convert[con_obj_id];
+                                       connector_object_id = con_obj_id;
+                               }
                        } else {
                                igp_lane_info = 0;
                                connector_type =
@@ -627,20 +633,23 @@ static uint16_t atombios_get_connector_object_id(struct drm_device *dev,
                uint8_t frev, crev;
                ATOM_XTMDS_INFO *xtmds;
 
-               atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
-               xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset);
+               if (atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset)) {
+                       xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset);
 
-               if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) {
-                       if (connector_type == DRM_MODE_CONNECTOR_DVII)
-                               return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
-                       else
-                               return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
-               } else {
-                       if (connector_type == DRM_MODE_CONNECTOR_DVII)
-                               return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
-                       else
-                               return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
-               }
+                       if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) {
+                               if (connector_type == DRM_MODE_CONNECTOR_DVII)
+                                       return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
+                               else
+                                       return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
+                       } else {
+                               if (connector_type == DRM_MODE_CONNECTOR_DVII)
+                                       return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
+                               else
+                                       return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
+                       }
+               } else
+                       return supported_devices_connector_object_id_convert
+                               [connector_type];
        } else {
                return supported_devices_connector_object_id_convert
                        [connector_type];
@@ -672,7 +681,8 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
        int i, j, max_device;
        struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
 
-       atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
+       if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
+               return false;
 
        supported_devices =
            (union atom_supported_devices *)(ctx->bios + data_offset);
@@ -865,14 +875,11 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)
        struct radeon_pll *mpll = &rdev->clock.mpll;
        uint16_t data_offset;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
-                              &crev, &data_offset);
-
-       firmware_info =
-           (union firmware_info *)(mode_info->atom_context->bios +
-                                   data_offset);
-
-       if (firmware_info) {
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               firmware_info =
+                       (union firmware_info *)(mode_info->atom_context->bios +
+                                               data_offset);
                /* pixel clocks */
                p1pll->reference_freq =
                    le16_to_cpu(firmware_info->info.usReferenceClock);
@@ -887,6 +894,20 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)
                p1pll->pll_out_max =
                    le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output);
 
+               if (crev >= 4) {
+                       p1pll->lcd_pll_out_min =
+                               le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100;
+                       if (p1pll->lcd_pll_out_min == 0)
+                               p1pll->lcd_pll_out_min = p1pll->pll_out_min;
+                       p1pll->lcd_pll_out_max =
+                               le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100;
+                       if (p1pll->lcd_pll_out_max == 0)
+                               p1pll->lcd_pll_out_max = p1pll->pll_out_max;
+               } else {
+                       p1pll->lcd_pll_out_min = p1pll->pll_out_min;
+                       p1pll->lcd_pll_out_max = p1pll->pll_out_max;
+               }
+
                if (p1pll->pll_out_min == 0) {
                        if (ASIC_IS_AVIVO(rdev))
                                p1pll->pll_out_min = 64800;
@@ -992,13 +1013,10 @@ bool radeon_atombios_sideport_present(struct radeon_device *rdev)
        u8 frev, crev;
        u16 data_offset;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
-                              &crev, &data_offset);
-
-       igp_info = (union igp_info *)(mode_info->atom_context->bios +
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               igp_info = (union igp_info *)(mode_info->atom_context->bios +
                                      data_offset);
-
-       if (igp_info) {
                switch (crev) {
                case 1:
                        if (igp_info->info.ucMemoryType & 0xf0)
@@ -1029,14 +1047,12 @@ bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder,
        uint16_t maxfreq;
        int i;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
-                              &crev, &data_offset);
-
-       tmds_info =
-           (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
-                                      data_offset);
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               tmds_info =
+                       (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
+                                                  data_offset);
 
-       if (tmds_info) {
                maxfreq = le16_to_cpu(tmds_info->usMaxFrequency);
                for (i = 0; i < 4; i++) {
                        tmds->tmds_pll[i].freq =
@@ -1085,13 +1101,11 @@ static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
        if (id > ATOM_MAX_SS_ENTRY)
                return NULL;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
-                              &crev, &data_offset);
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               ss_info =
+                       (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
 
-       ss_info =
-           (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
-
-       if (ss_info) {
                ss =
                    kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
 
@@ -1114,30 +1128,6 @@ static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
        return ss;
 }
 
-static void radeon_atom_apply_lvds_quirks(struct drm_device *dev,
-                                         struct radeon_encoder_atom_dig *lvds)
-{
-
-       /* Toshiba A300-1BU laptop panel doesn't like new pll divider algo */
-       if ((dev->pdev->device == 0x95c4) &&
-           (dev->pdev->subsystem_vendor == 0x1179) &&
-           (dev->pdev->subsystem_device == 0xff50)) {
-               if ((lvds->native_mode.hdisplay == 1280) &&
-                   (lvds->native_mode.vdisplay == 800))
-                       lvds->pll_algo = PLL_ALGO_LEGACY;
-       }
-
-       /* Dell Studio 15 laptop panel doesn't like new pll divider algo */
-       if ((dev->pdev->device == 0x95c4) &&
-           (dev->pdev->subsystem_vendor == 0x1028) &&
-           (dev->pdev->subsystem_device == 0x029f)) {
-               if ((lvds->native_mode.hdisplay == 1280) &&
-                   (lvds->native_mode.vdisplay == 800))
-                       lvds->pll_algo = PLL_ALGO_LEGACY;
-       }
-
-}
-
 union lvds_info {
        struct _ATOM_LVDS_INFO info;
        struct _ATOM_LVDS_INFO_V12 info_12;
@@ -1156,13 +1146,10 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
        uint8_t frev, crev;
        struct radeon_encoder_atom_dig *lvds = NULL;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev,
-                              &crev, &data_offset);
-
-       lvds_info =
-           (union lvds_info *)(mode_info->atom_context->bios + data_offset);
-
-       if (lvds_info) {
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               lvds_info =
+                       (union lvds_info *)(mode_info->atom_context->bios + data_offset);
                lvds =
                    kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL);
 
@@ -1220,9 +1207,6 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
                                lvds->pll_algo = PLL_ALGO_LEGACY;
                }
 
-               /* LVDS quirks */
-               radeon_atom_apply_lvds_quirks(dev, lvds);
-
                encoder->native_mode = lvds->native_mode;
        }
        return lvds;
@@ -1241,11 +1225,11 @@ radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder)
        uint8_t bg, dac;
        struct radeon_encoder_primary_dac *p_dac = NULL;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
-
-       dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset);
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               dac_info = (struct _COMPASSIONATE_DATA *)
+                       (mode_info->atom_context->bios + data_offset);
 
-       if (dac_info) {
                p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL);
 
                if (!p_dac)
@@ -1270,7 +1254,9 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
        u8 frev, crev;
        u16 data_offset, misc;
 
-       atom_parse_data_header(mode_info->atom_context, data_index, NULL, &frev, &crev, &data_offset);
+       if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL,
+                                   &frev, &crev, &data_offset))
+               return false;
 
        switch (crev) {
        case 1:
@@ -1362,47 +1348,50 @@ radeon_atombios_get_tv_info(struct radeon_device *rdev)
        struct _ATOM_ANALOG_TV_INFO *tv_info;
        enum radeon_tv_std tv_std = TV_STD_NTSC;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
 
-       tv_info = (struct _ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
+               tv_info = (struct _ATOM_ANALOG_TV_INFO *)
+                       (mode_info->atom_context->bios + data_offset);
 
-       switch (tv_info->ucTV_BootUpDefaultStandard) {
-       case ATOM_TV_NTSC:
-               tv_std = TV_STD_NTSC;
-               DRM_INFO("Default TV standard: NTSC\n");
-               break;
-       case ATOM_TV_NTSCJ:
-               tv_std = TV_STD_NTSC_J;
-               DRM_INFO("Default TV standard: NTSC-J\n");
-               break;
-       case ATOM_TV_PAL:
-               tv_std = TV_STD_PAL;
-               DRM_INFO("Default TV standard: PAL\n");
-               break;
-       case ATOM_TV_PALM:
-               tv_std = TV_STD_PAL_M;
-               DRM_INFO("Default TV standard: PAL-M\n");
-               break;
-       case ATOM_TV_PALN:
-               tv_std = TV_STD_PAL_N;
-               DRM_INFO("Default TV standard: PAL-N\n");
-               break;
-       case ATOM_TV_PALCN:
-               tv_std = TV_STD_PAL_CN;
-               DRM_INFO("Default TV standard: PAL-CN\n");
-               break;
-       case ATOM_TV_PAL60:
-               tv_std = TV_STD_PAL_60;
-               DRM_INFO("Default TV standard: PAL-60\n");
-               break;
-       case ATOM_TV_SECAM:
-               tv_std = TV_STD_SECAM;
-               DRM_INFO("Default TV standard: SECAM\n");
-               break;
-       default:
-               tv_std = TV_STD_NTSC;
-               DRM_INFO("Unknown TV standard; defaulting to NTSC\n");
-               break;
+               switch (tv_info->ucTV_BootUpDefaultStandard) {
+               case ATOM_TV_NTSC:
+                       tv_std = TV_STD_NTSC;
+                       DRM_INFO("Default TV standard: NTSC\n");
+                       break;
+               case ATOM_TV_NTSCJ:
+                       tv_std = TV_STD_NTSC_J;
+                       DRM_INFO("Default TV standard: NTSC-J\n");
+                       break;
+               case ATOM_TV_PAL:
+                       tv_std = TV_STD_PAL;
+                       DRM_INFO("Default TV standard: PAL\n");
+                       break;
+               case ATOM_TV_PALM:
+                       tv_std = TV_STD_PAL_M;
+                       DRM_INFO("Default TV standard: PAL-M\n");
+                       break;
+               case ATOM_TV_PALN:
+                       tv_std = TV_STD_PAL_N;
+                       DRM_INFO("Default TV standard: PAL-N\n");
+                       break;
+               case ATOM_TV_PALCN:
+                       tv_std = TV_STD_PAL_CN;
+                       DRM_INFO("Default TV standard: PAL-CN\n");
+                       break;
+               case ATOM_TV_PAL60:
+                       tv_std = TV_STD_PAL_60;
+                       DRM_INFO("Default TV standard: PAL-60\n");
+                       break;
+               case ATOM_TV_SECAM:
+                       tv_std = TV_STD_SECAM;
+                       DRM_INFO("Default TV standard: SECAM\n");
+                       break;
+               default:
+                       tv_std = TV_STD_NTSC;
+                       DRM_INFO("Unknown TV standard; defaulting to NTSC\n");
+                       break;
+               }
        }
        return tv_std;
 }
@@ -1420,11 +1409,12 @@ radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
        uint8_t bg, dac;
        struct radeon_encoder_tv_dac *tv_dac = NULL;
 
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
 
-       dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset);
+               dac_info = (struct _COMPASSIONATE_DATA *)
+                       (mode_info->atom_context->bios + data_offset);
 
-       if (dac_info) {
                tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
 
                if (!tv_dac)
@@ -1447,6 +1437,30 @@ radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
        return tv_dac;
 }
 
+static const char *thermal_controller_names[] = {
+       "NONE",
+       "LM63",
+       "ADM1032",
+       "ADM1030",
+       "MUA6649",
+       "LM64",
+       "F75375",
+       "ASC7512",
+};
+
+static const char *pp_lib_thermal_controller_names[] = {
+       "NONE",
+       "LM63",
+       "ADM1032",
+       "ADM1030",
+       "MUA6649",
+       "LM64",
+       "F75375",
+       "RV6xx",
+       "RV770",
+       "ADT7473",
+};
+
 union power_info {
        struct _ATOM_POWERPLAY_INFO info;
        struct _ATOM_POWERPLAY_INFO_V2 info_2;
@@ -1466,15 +1480,22 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
        struct _ATOM_PPLIB_STATE *power_state;
        int num_modes = 0, i, j;
        int state_index = 0, mode_index = 0;
-
-       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
-
-       power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
+       struct radeon_i2c_bus_rec i2c_bus;
 
        rdev->pm.default_power_state = NULL;
 
-       if (power_info) {
+       if (atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
                if (frev < 4) {
+                       /* add the i2c bus for thermal/fan chip */
+                       if (power_info->info.ucOverdriveThermalController > 0) {
+                               DRM_INFO("Possible %s thermal controller at 0x%02x\n",
+                                        thermal_controller_names[power_info->info.ucOverdriveThermalController],
+                                        power_info->info.ucOverdriveControllerAddress >> 1);
+                               i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine);
+                               rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
+                       }
                        num_modes = power_info->info.ucNumOfPowerModeEntries;
                        if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK)
                                num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
@@ -1684,6 +1705,24 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
                                }
                        }
                } else if (frev == 4) {
+                       /* add the i2c bus for thermal/fan chip */
+                       /* no support for internal controller yet */
+                       if (power_info->info_4.sThermalController.ucType > 0) {
+                               if ((power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) ||
+                                   (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV770)) {
+                                       DRM_INFO("Internal thermal controller %s fan control\n",
+                                                (power_info->info_4.sThermalController.ucFanParameters &
+                                                 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
+                               } else {
+                                       DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n",
+                                                pp_lib_thermal_controller_names[power_info->info_4.sThermalController.ucType],
+                                                power_info->info_4.sThermalController.ucI2cAddress >> 1,
+                                                (power_info->info_4.sThermalController.ucFanParameters &
+                                                 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
+                                       i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info_4.sThermalController.ucI2cLine);
+                                       rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
+                               }
+                       }
                        for (i = 0; i < power_info->info_4.ucNumStates; i++) {
                                mode_index = 0;
                                power_state = (struct _ATOM_PPLIB_STATE *)
index 3f557c4151e0bb7fe2af9e9aaa1bdbec7d2da60f..ed5dfe58f29c0845e8eb8a478560b9a01fe17677 100644 (file)
@@ -7,6 +7,7 @@
  * ATPX support for both Intel/ATI
  */
 #include <linux/vga_switcheroo.h>
+#include <linux/slab.h>
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>
 #include <linux/pci.h>
index 557240460526828aeef9bc3aec07cfef26800fc0..8ad71f70131624562ae4d02d6eabe159ede924e4 100644 (file)
@@ -31,6 +31,7 @@
 #include "atom.h"
 
 #include <linux/vga_switcheroo.h>
+#include <linux/slab.h>
 /*
  * BIOS.
  */
index e9ea38ece37558a6bf123b18a982b06ec252872a..2becdeda68a34ae4d94d8102f33d0d87fe6de959 100644 (file)
@@ -531,10 +531,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
        case CHIP_RS300:
                switch (ddc_line) {
                case RADEON_GPIO_DVI_DDC:
-                       /* in theory this should be hw capable,
-                        * but it doesn't seem to work
-                        */
-                       i2c.hw_capable = false;
+                       i2c.hw_capable = true;
                        break;
                default:
                        i2c.hw_capable = false;
@@ -633,6 +630,8 @@ bool radeon_combios_get_clock_info(struct drm_device *dev)
                p1pll->reference_div = RBIOS16(pll_info + 0x10);
                p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
                p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
+               p1pll->lcd_pll_out_min = p1pll->pll_out_min;
+               p1pll->lcd_pll_out_max = p1pll->pll_out_max;
 
                if (rev > 9) {
                        p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
index ee0083f982d8ba2a926688e083ea930716e0de91..60d59816b94ff6a4d94784482d2d613a88c56543 100644 (file)
@@ -940,7 +940,7 @@ static void radeon_dp_connector_destroy(struct drm_connector *connector)
        if (radeon_connector->edid)
                kfree(radeon_connector->edid);
        if (radeon_dig_connector->dp_i2c_bus)
-               radeon_i2c_destroy_dp(radeon_dig_connector->dp_i2c_bus);
+               radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus);
        kfree(radeon_connector->con_priv);
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
index 70ba02ed77237ba31299a7cbc56694dc3e62d57a..f9b0fe002c0ab7f27430a697f95a841667281e41 100644 (file)
@@ -193,9 +193,11 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
                radeon_bo_list_fence(&parser->validated, parser->ib->fence);
        }
        radeon_bo_list_unreserve(&parser->validated);
-       for (i = 0; i < parser->nrelocs; i++) {
-               if (parser->relocs[i].gobj)
-                       drm_gem_object_unreference_unlocked(parser->relocs[i].gobj);
+       if (parser->relocs != NULL) {
+               for (i = 0; i < parser->nrelocs; i++) {
+                       if (parser->relocs[i].gobj)
+                               drm_gem_object_unreference_unlocked(parser->relocs[i].gobj);
+               }
        }
        kfree(parser->track);
        kfree(parser->relocs);
@@ -243,7 +245,8 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
        }
        r = radeon_cs_parser_relocs(&parser);
        if (r) {
-               DRM_ERROR("Failed to parse relocation !\n");
+               if (r != -ERESTARTSYS)
+                       DRM_ERROR("Failed to parse relocation %d!\n", r);
                radeon_cs_parser_fini(&parser, r);
                mutex_unlock(&rdev->cs_mutex);
                return r;
index e28e4ed5f720d5340c1e23595ca099d1559273c0..bddf17f97da8eb23904424750a866408d5db5fb7 100644 (file)
@@ -26,6 +26,7 @@
  *          Jerome Glisse
  */
 #include <linux/console.h>
+#include <linux/slab.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/radeon_drm.h>
@@ -33,7 +34,6 @@
 #include <linux/vga_switcheroo.h>
 #include "radeon_reg.h"
 #include "radeon.h"
-#include "radeon_asic.h"
 #include "atom.h"
 
 /*
@@ -242,6 +242,36 @@ bool radeon_card_posted(struct radeon_device *rdev)
 
 }
 
+void radeon_update_bandwidth_info(struct radeon_device *rdev)
+{
+       fixed20_12 a;
+       u32 sclk, mclk;
+
+       if (rdev->flags & RADEON_IS_IGP) {
+               sclk = radeon_get_engine_clock(rdev);
+               mclk = rdev->clock.default_mclk;
+
+               a.full = rfixed_const(100);
+               rdev->pm.sclk.full = rfixed_const(sclk);
+               rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+               rdev->pm.mclk.full = rfixed_const(mclk);
+               rdev->pm.mclk.full = rfixed_div(rdev->pm.mclk, a);
+
+               a.full = rfixed_const(16);
+               /* core_bandwidth = sclk(Mhz) * 16 */
+               rdev->pm.core_bandwidth.full = rfixed_div(rdev->pm.sclk, a);
+       } else {
+               sclk = radeon_get_engine_clock(rdev);
+               mclk = radeon_get_memory_clock(rdev);
+
+               a.full = rfixed_const(100);
+               rdev->pm.sclk.full = rfixed_const(sclk);
+               rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+               rdev->pm.mclk.full = rfixed_const(mclk);
+               rdev->pm.mclk.full = rfixed_div(rdev->pm.mclk, a);
+       }
+}
+
 bool radeon_boot_test_post_card(struct radeon_device *rdev)
 {
        if (radeon_card_posted(rdev))
@@ -288,181 +318,6 @@ void radeon_dummy_page_fini(struct radeon_device *rdev)
 }
 
 
-/*
- * Registers accessors functions.
- */
-uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg)
-{
-       DRM_ERROR("Invalid callback to read register 0x%04X\n", reg);
-       BUG_ON(1);
-       return 0;
-}
-
-void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
-{
-       DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n",
-                 reg, v);
-       BUG_ON(1);
-}
-
-void radeon_register_accessor_init(struct radeon_device *rdev)
-{
-       rdev->mc_rreg = &radeon_invalid_rreg;
-       rdev->mc_wreg = &radeon_invalid_wreg;
-       rdev->pll_rreg = &radeon_invalid_rreg;
-       rdev->pll_wreg = &radeon_invalid_wreg;
-       rdev->pciep_rreg = &radeon_invalid_rreg;
-       rdev->pciep_wreg = &radeon_invalid_wreg;
-
-       /* Don't change order as we are overridding accessor. */
-       if (rdev->family < CHIP_RV515) {
-               rdev->pcie_reg_mask = 0xff;
-       } else {
-               rdev->pcie_reg_mask = 0x7ff;
-       }
-       /* FIXME: not sure here */
-       if (rdev->family <= CHIP_R580) {
-               rdev->pll_rreg = &r100_pll_rreg;
-               rdev->pll_wreg = &r100_pll_wreg;
-       }
-       if (rdev->family >= CHIP_R420) {
-               rdev->mc_rreg = &r420_mc_rreg;
-               rdev->mc_wreg = &r420_mc_wreg;
-       }
-       if (rdev->family >= CHIP_RV515) {
-               rdev->mc_rreg = &rv515_mc_rreg;
-               rdev->mc_wreg = &rv515_mc_wreg;
-       }
-       if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
-               rdev->mc_rreg = &rs400_mc_rreg;
-               rdev->mc_wreg = &rs400_mc_wreg;
-       }
-       if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
-               rdev->mc_rreg = &rs690_mc_rreg;
-               rdev->mc_wreg = &rs690_mc_wreg;
-       }
-       if (rdev->family == CHIP_RS600) {
-               rdev->mc_rreg = &rs600_mc_rreg;
-               rdev->mc_wreg = &rs600_mc_wreg;
-       }
-       if ((rdev->family >= CHIP_R600) && (rdev->family <= CHIP_RV740)) {
-               rdev->pciep_rreg = &r600_pciep_rreg;
-               rdev->pciep_wreg = &r600_pciep_wreg;
-       }
-}
-
-
-/*
- * ASIC
- */
-int radeon_asic_init(struct radeon_device *rdev)
-{
-       radeon_register_accessor_init(rdev);
-       switch (rdev->family) {
-       case CHIP_R100:
-       case CHIP_RV100:
-       case CHIP_RS100:
-       case CHIP_RV200:
-       case CHIP_RS200:
-               rdev->asic = &r100_asic;
-               break;
-       case CHIP_R200:
-       case CHIP_RV250:
-       case CHIP_RS300:
-       case CHIP_RV280:
-               rdev->asic = &r200_asic;
-               break;
-       case CHIP_R300:
-       case CHIP_R350:
-       case CHIP_RV350:
-       case CHIP_RV380:
-               if (rdev->flags & RADEON_IS_PCIE)
-                       rdev->asic = &r300_asic_pcie;
-               else
-                       rdev->asic = &r300_asic;
-               break;
-       case CHIP_R420:
-       case CHIP_R423:
-       case CHIP_RV410:
-               rdev->asic = &r420_asic;
-               break;
-       case CHIP_RS400:
-       case CHIP_RS480:
-               rdev->asic = &rs400_asic;
-               break;
-       case CHIP_RS600:
-               rdev->asic = &rs600_asic;
-               break;
-       case CHIP_RS690:
-       case CHIP_RS740:
-               rdev->asic = &rs690_asic;
-               break;
-       case CHIP_RV515:
-               rdev->asic = &rv515_asic;
-               break;
-       case CHIP_R520:
-       case CHIP_RV530:
-       case CHIP_RV560:
-       case CHIP_RV570:
-       case CHIP_R580:
-               rdev->asic = &r520_asic;
-               break;
-       case CHIP_R600:
-       case CHIP_RV610:
-       case CHIP_RV630:
-       case CHIP_RV620:
-       case CHIP_RV635:
-       case CHIP_RV670:
-       case CHIP_RS780:
-       case CHIP_RS880:
-               rdev->asic = &r600_asic;
-               break;
-       case CHIP_RV770:
-       case CHIP_RV730:
-       case CHIP_RV710:
-       case CHIP_RV740:
-               rdev->asic = &rv770_asic;
-               break;
-       case CHIP_CEDAR:
-       case CHIP_REDWOOD:
-       case CHIP_JUNIPER:
-       case CHIP_CYPRESS:
-       case CHIP_HEMLOCK:
-               rdev->asic = &evergreen_asic;
-               break;
-       default:
-               /* FIXME: not supported yet */
-               return -EINVAL;
-       }
-
-       if (rdev->flags & RADEON_IS_IGP) {
-               rdev->asic->get_memory_clock = NULL;
-               rdev->asic->set_memory_clock = NULL;
-       }
-
-       return 0;
-}
-
-
-/*
- * Wrapper around modesetting bits.
- */
-int radeon_clocks_init(struct radeon_device *rdev)
-{
-       int r;
-
-       r = radeon_static_clocks_init(rdev->ddev);
-       if (r) {
-               return r;
-       }
-       DRM_INFO("Clocks initialized !\n");
-       return 0;
-}
-
-void radeon_clocks_fini(struct radeon_device *rdev)
-{
-}
-
 /* ATOM accessor methods */
 static uint32_t cail_pll_read(struct card_info *info, uint32_t reg)
 {
@@ -567,29 +422,6 @@ static unsigned int radeon_vga_set_decode(void *cookie, bool state)
                return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
-void radeon_agp_disable(struct radeon_device *rdev)
-{
-       rdev->flags &= ~RADEON_IS_AGP;
-       if (rdev->family >= CHIP_R600) {
-               DRM_INFO("Forcing AGP to PCIE mode\n");
-               rdev->flags |= RADEON_IS_PCIE;
-       } else if (rdev->family >= CHIP_RV515 ||
-                       rdev->family == CHIP_RV380 ||
-                       rdev->family == CHIP_RV410 ||
-                       rdev->family == CHIP_R423) {
-               DRM_INFO("Forcing AGP to PCIE mode\n");
-               rdev->flags |= RADEON_IS_PCIE;
-               rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
-               rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
-       } else {
-               DRM_INFO("Forcing AGP to PCI mode\n");
-               rdev->flags |= RADEON_IS_PCI;
-               rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
-               rdev->asic->gart_set_page = &r100_pci_gart_set_page;
-       }
-       rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
-}
-
 void radeon_check_arguments(struct radeon_device *rdev)
 {
        /* vramlimit must be a power of two */
@@ -731,6 +563,14 @@ int radeon_device_init(struct radeon_device *rdev,
                return r;
        radeon_check_arguments(rdev);
 
+       /* all of the newer IGP chips have an internal gart
+        * However some rs4xx report as AGP, so remove that here.
+        */
+       if ((rdev->family >= CHIP_RS400) &&
+           (rdev->flags & RADEON_IS_IGP)) {
+               rdev->flags &= ~RADEON_IS_AGP;
+       }
+
        if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) {
                radeon_agp_disable(rdev);
        }
index ba8d806dcf3939fe91285820793e7b733ffb0541..b8d6728282468c09e56640807c2d8464bdcb5033 100644 (file)
@@ -368,10 +368,9 @@ static bool radeon_setup_enc_conn(struct drm_device *dev)
 
        if (rdev->bios) {
                if (rdev->is_atom_bios) {
-                       if (rdev->family >= CHIP_R600)
+                       ret = radeon_get_atom_connector_info_from_supported_devices_table(dev);
+                       if (ret == false)
                                ret = radeon_get_atom_connector_info_from_object_table(dev);
-                       else
-                               ret = radeon_get_atom_connector_info_from_supported_devices_table(dev);
                } else {
                        ret = radeon_get_legacy_connector_info_from_bios(dev);
                        if (ret == false)
@@ -469,10 +468,19 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
        uint32_t best_error = 0xffffffff;
        uint32_t best_vco_diff = 1;
        uint32_t post_div;
+       u32 pll_out_min, pll_out_max;
 
        DRM_DEBUG("PLL freq %llu %u %u\n", freq, pll->min_ref_div, pll->max_ref_div);
        freq = freq * 1000;
 
+       if (pll->flags & RADEON_PLL_IS_LCD) {
+               pll_out_min = pll->lcd_pll_out_min;
+               pll_out_max = pll->lcd_pll_out_max;
+       } else {
+               pll_out_min = pll->pll_out_min;
+               pll_out_max = pll->pll_out_max;
+       }
+
        if (pll->flags & RADEON_PLL_USE_REF_DIV)
                min_ref_div = max_ref_div = pll->reference_div;
        else {
@@ -536,10 +544,10 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
                                tmp = (uint64_t)pll->reference_freq * feedback_div;
                                vco = radeon_div(tmp, ref_div);
 
-                               if (vco < pll->pll_out_min) {
+                               if (vco < pll_out_min) {
                                        min_feed_div = feedback_div + 1;
                                        continue;
-                               } else if (vco > pll->pll_out_max) {
+                               } else if (vco > pll_out_max) {
                                        max_feed_div = feedback_div;
                                        continue;
                                }
@@ -675,6 +683,15 @@ calc_fb_ref_div(struct radeon_pll *pll,
 {
        fixed20_12 ffreq, max_error, error, pll_out, a;
        u32 vco;
+       u32 pll_out_min, pll_out_max;
+
+       if (pll->flags & RADEON_PLL_IS_LCD) {
+               pll_out_min = pll->lcd_pll_out_min;
+               pll_out_max = pll->lcd_pll_out_max;
+       } else {
+               pll_out_min = pll->pll_out_min;
+               pll_out_max = pll->pll_out_max;
+       }
 
        ffreq.full = rfixed_const(freq);
        /* max_error = ffreq * 0.0025; */
@@ -686,7 +703,7 @@ calc_fb_ref_div(struct radeon_pll *pll,
                        vco = pll->reference_freq * (((*fb_div) * 10) + (*fb_div_frac));
                        vco = vco / ((*ref_div) * 10);
 
-                       if ((vco < pll->pll_out_min) || (vco > pll->pll_out_max))
+                       if ((vco < pll_out_min) || (vco > pll_out_max))
                                continue;
 
                        /* pll_out = vco / post_div; */
@@ -714,6 +731,15 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
 {
        u32 fb_div = 0, fb_div_frac = 0, post_div = 0, ref_div = 0;
        u32 best_freq = 0, vco_frequency;
+       u32 pll_out_min, pll_out_max;
+
+       if (pll->flags & RADEON_PLL_IS_LCD) {
+               pll_out_min = pll->lcd_pll_out_min;
+               pll_out_max = pll->lcd_pll_out_max;
+       } else {
+               pll_out_min = pll->pll_out_min;
+               pll_out_max = pll->pll_out_max;
+       }
 
        /* freq = freq / 10; */
        do_div(freq, 10);
@@ -724,7 +750,7 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
                        goto done;
 
                vco_frequency = freq * post_div;
-               if ((vco_frequency < pll->pll_out_min) || (vco_frequency > pll->pll_out_max))
+               if ((vco_frequency < pll_out_min) || (vco_frequency > pll_out_max))
                        goto done;
 
                if (pll->flags & RADEON_PLL_USE_REF_DIV) {
@@ -749,7 +775,7 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
                                continue;
 
                        vco_frequency = freq * post_div;
-                       if ((vco_frequency < pll->pll_out_min) || (vco_frequency > pll->pll_out_max))
+                       if ((vco_frequency < pll_out_min) || (vco_frequency > pll_out_max))
                                continue;
                        if (pll->flags & RADEON_PLL_USE_REF_DIV) {
                                ref_div = pll->reference_div;
@@ -945,6 +971,23 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
        return 0;
 }
 
+void radeon_update_display_priority(struct radeon_device *rdev)
+{
+       /* adjustment options for the display watermarks */
+       if ((radeon_disp_priority == 0) || (radeon_disp_priority > 2)) {
+               /* set display priority to high for r3xx, rv515 chips
+                * this avoids flickering due to underflow to the
+                * display controllers during heavy acceleration.
+                */
+               if (ASIC_IS_R300(rdev) || (rdev->family == CHIP_RV515))
+                       rdev->disp_priority = 2;
+               else
+                       rdev->disp_priority = 0;
+       } else
+               rdev->disp_priority = radeon_disp_priority;
+
+}
+
 int radeon_modeset_init(struct radeon_device *rdev)
 {
        int i;
@@ -976,15 +1019,6 @@ int radeon_modeset_init(struct radeon_device *rdev)
                radeon_combios_check_hardcoded_edid(rdev);
        }
 
-       if (rdev->flags & RADEON_SINGLE_CRTC)
-               rdev->num_crtc = 1;
-       else {
-               if (ASIC_IS_DCE4(rdev))
-                       rdev->num_crtc = 6;
-               else
-                       rdev->num_crtc = 2;
-       }
-
        /* allocate crtcs */
        for (i = 0; i < rdev->num_crtc; i++) {
                radeon_crtc_init(rdev->ddev, i);
index 6eec0ece6a6ccd6d14e9ae05a2fee63d0879ce41..055a51732dcb7b76a100d79ee2b642de9cc9eefe 100644 (file)
  * KMS wrapper.
  * - 2.0.0 - initial interface
  * - 2.1.0 - add square tiling interface
+ * - 2.2.0 - add r6xx/r7xx const buffer support
  */
 #define KMS_DRIVER_MAJOR       2
-#define KMS_DRIVER_MINOR       1
+#define KMS_DRIVER_MINOR       2
 #define KMS_DRIVER_PATCHLEVEL  0
 int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
 int radeon_driver_unload_kms(struct drm_device *dev);
@@ -91,6 +92,8 @@ int radeon_tv = 1;
 int radeon_new_pll = -1;
 int radeon_dynpm = -1;
 int radeon_audio = 1;
+int radeon_disp_priority = 0;
+int radeon_hw_i2c = 0;
 
 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
 module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -134,6 +137,12 @@ module_param_named(dynpm, radeon_dynpm, int, 0444);
 MODULE_PARM_DESC(audio, "Audio enable (0 = disable)");
 module_param_named(audio, radeon_audio, int, 0444);
 
+MODULE_PARM_DESC(disp_priority, "Display Priority (0 = auto, 1 = normal, 2 = high)");
+module_param_named(disp_priority, radeon_disp_priority, int, 0444);
+
+MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
+module_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
+
 static int radeon_suspend(struct drm_device *dev, pm_message_t state)
 {
        drm_radeon_private_t *dev_priv = dev->dev_private;
index ec55f2b23c2298f39d7b108d183bf52a59ddad34..448eba89d1e62e2dec8089480e951086c7caa2f6 100644 (file)
  * 1.30- Add support for occlusion queries
  * 1.31- Add support for num Z pipes from GET_PARAM
  * 1.32- fixes for rv740 setup
+ * 1.33- Add r6xx/r7xx const buffer support
  */
 #define DRIVER_MAJOR           1
-#define DRIVER_MINOR           32
+#define DRIVER_MINOR           33
 #define DRIVER_PATCHLEVEL      0
 
 enum radeon_cp_microcode_version {
index bc926ea0a530e014c2b075fed8ac35e0a94d04ae..52d6f96f274b2722ec0617cf5420ced519514442 100644 (file)
@@ -302,7 +302,7 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
        }
 
        if (ASIC_IS_DCE3(rdev) &&
-           (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT))) {
+           (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT))) {
                struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
                radeon_dp_set_link_config(connector, mode);
        }
@@ -519,7 +519,8 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
                break;
        }
 
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
+               return;
 
        switch (frev) {
        case 1:
@@ -593,7 +594,6 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
        }
 
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
-       r600_hdmi_enable(encoder, hdmi_detected);
 }
 
 int
@@ -708,7 +708,7 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action)
        struct radeon_connector_atom_dig *dig_connector =
                radeon_get_atom_connector_priv_from_encoder(encoder);
        union dig_encoder_control args;
-       int index = 0, num = 0;
+       int index = 0;
        uint8_t frev, crev;
 
        if (!dig || !dig_connector)
@@ -724,9 +724,9 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action)
                else
                        index = GetIndexIntoMasterTable(COMMAND, DIG1EncoderControl);
        }
-       num = dig->dig_encoder + 1;
 
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
+               return;
 
        args.v1.ucAction = action;
        args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -785,7 +785,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
        struct drm_connector *connector;
        struct radeon_connector *radeon_connector;
        union dig_transmitter_control args;
-       int index = 0, num = 0;
+       int index = 0;
        uint8_t frev, crev;
        bool is_dp = false;
        int pll_id = 0;
@@ -814,7 +814,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
                }
        }
 
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
+               return;
 
        args.v1.ucAction = action;
        if (action == ATOM_TRANSMITTER_ACTION_INIT) {
@@ -860,15 +861,12 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
                switch (radeon_encoder->encoder_id) {
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
                        args.v3.acConfig.ucTransmitterSel = 0;
-                       num = 0;
                        break;
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
                        args.v3.acConfig.ucTransmitterSel = 1;
-                       num = 1;
                        break;
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
                        args.v3.acConfig.ucTransmitterSel = 2;
-                       num = 2;
                        break;
                }
 
@@ -879,23 +877,19 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
                                args.v3.acConfig.fCoherentMode = 1;
                }
        } else if (ASIC_IS_DCE32(rdev)) {
-               if (dig->dig_encoder == 1)
-                       args.v2.acConfig.ucEncoderSel = 1;
+               args.v2.acConfig.ucEncoderSel = dig->dig_encoder;
                if (dig_connector->linkb)
                        args.v2.acConfig.ucLinkSel = 1;
 
                switch (radeon_encoder->encoder_id) {
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
                        args.v2.acConfig.ucTransmitterSel = 0;
-                       num = 0;
                        break;
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
                        args.v2.acConfig.ucTransmitterSel = 1;
-                       num = 1;
                        break;
                case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
                        args.v2.acConfig.ucTransmitterSel = 2;
-                       num = 2;
                        break;
                }
 
@@ -913,31 +907,25 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
                else
                        args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER;
 
-               switch (radeon_encoder->encoder_id) {
-               case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
-                       if (rdev->flags & RADEON_IS_IGP) {
-                               if (radeon_encoder->pixel_clock > 165000) {
-                                       if (dig_connector->igp_lane_info & 0x3)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7;
-                                       else if (dig_connector->igp_lane_info & 0xc)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15;
-                               } else {
-                                       if (dig_connector->igp_lane_info & 0x1)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3;
-                                       else if (dig_connector->igp_lane_info & 0x2)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7;
-                                       else if (dig_connector->igp_lane_info & 0x4)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11;
-                                       else if (dig_connector->igp_lane_info & 0x8)
-                                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15;
-                               }
+               if ((rdev->flags & RADEON_IS_IGP) &&
+                   (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY)) {
+                       if (is_dp || (radeon_encoder->pixel_clock <= 165000)) {
+                               if (dig_connector->igp_lane_info & 0x1)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3;
+                               else if (dig_connector->igp_lane_info & 0x2)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7;
+                               else if (dig_connector->igp_lane_info & 0x4)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11;
+                               else if (dig_connector->igp_lane_info & 0x8)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15;
+                       } else {
+                               if (dig_connector->igp_lane_info & 0x3)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7;
+                               else if (dig_connector->igp_lane_info & 0xc)
+                                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15;
                        }
-                       break;
                }
 
-               if (radeon_encoder->pixel_clock > 165000)
-                       args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
-
                if (dig_connector->linkb)
                        args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKB;
                else
@@ -948,6 +936,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
                else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
                        if (dig->coherent_mode)
                                args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT;
+                       if (radeon_encoder->pixel_clock > 165000)
+                               args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
                }
        }
 
@@ -1054,16 +1044,25 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
        if (is_dig) {
                switch (mode) {
                case DRM_MODE_DPMS_ON:
-                       atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
-                       {
+                       if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
                                struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
+
                                dp_link_train(encoder, connector);
+                               if (ASIC_IS_DCE4(rdev))
+                                       atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON);
                        }
+                       if (!ASIC_IS_DCE4(rdev))
+                               atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
                        break;
                case DRM_MODE_DPMS_STANDBY:
                case DRM_MODE_DPMS_SUSPEND:
                case DRM_MODE_DPMS_OFF:
-                       atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
+                       if (!ASIC_IS_DCE4(rdev))
+                               atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
+                       if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
+                               if (ASIC_IS_DCE4(rdev))
+                                       atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF);
+                       }
                        break;
                }
        } else {
@@ -1104,7 +1103,8 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
 
        memset(&args, 0, sizeof(args));
 
-       atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev);
+       if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
+               return;
 
        switch (frev) {
        case 1:
@@ -1216,6 +1216,9 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
        }
 
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
+
+       /* update scratch regs with new routing */
+       radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
 }
 
 static void
@@ -1326,19 +1329,9 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
        struct drm_device *dev = encoder->dev;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-       struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
 
-       if (radeon_encoder->active_device &
-           (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) {
-               struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
-               if (dig)
-                       dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder);
-       }
        radeon_encoder->pixel_clock = adjusted_mode->clock;
 
-       radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
-       atombios_set_encoder_crtc_source(encoder);
-
        if (ASIC_IS_AVIVO(rdev)) {
                if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT))
                        atombios_yuv_setup(encoder, true);
@@ -1396,9 +1389,10 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
        }
        atombios_apply_encoder_quirks(encoder, adjusted_mode);
 
-       /* XXX */
-       if (!ASIC_IS_DCE4(rdev))
+       if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) {
+               r600_hdmi_enable(encoder);
                r600_hdmi_setmode(encoder, adjusted_mode);
+       }
 }
 
 static bool
@@ -1418,7 +1412,8 @@ atombios_dac_load_detect(struct drm_encoder *encoder, struct drm_connector *conn
 
                memset(&args, 0, sizeof(args));
 
-               atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev);
+               if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
+                       return false;
 
                args.sDacload.ucMisc = 0;
 
@@ -1492,8 +1487,20 @@ radeon_atom_dac_detect(struct drm_encoder *encoder, struct drm_connector *connec
 
 static void radeon_atom_encoder_prepare(struct drm_encoder *encoder)
 {
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+
+       if (radeon_encoder->active_device &
+           (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) {
+               struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+               if (dig)
+                       dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder);
+       }
+
        radeon_atom_output_lock(encoder, true);
        radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
+
+       /* this is needed for the pll/ss setup to work correctly in some cases */
+       atombios_set_encoder_crtc_source(encoder);
 }
 
 static void radeon_atom_encoder_commit(struct drm_encoder *encoder)
@@ -1509,6 +1516,8 @@ static void radeon_atom_encoder_disable(struct drm_encoder *encoder)
        radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
 
        if (radeon_encoder_is_digital(encoder)) {
+               if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI)
+                       r600_hdmi_disable(encoder);
                dig = radeon_encoder->enc_priv;
                dig->dig_encoder = -1;
        }
@@ -1659,6 +1668,4 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t su
                drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
                break;
        }
-
-       r600_hdmi_init(encoder);
 }
index 8fccbf29235e76efe2e7aecf12d53253e3f896c7..9ac57a09784b08d72eb5278880f7cb98cfd560f2 100644 (file)
@@ -28,6 +28,7 @@
      */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/fb.h>
 
 #include "drmP.h"
index 8495d4e32e1890daf1626c1c963c978b969d3e61..d90f95b405c5e9942af5400719978465b03c11e9 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/wait.h>
 #include <linux/list.h>
 #include <linux/kref.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "drm.h"
 #include "radeon_reg.h"
index 4ae50c19589fe8b4e4f89304862515416cbe72c5..5def6f5dff38c1f7dfb0357aa5f9f8cc2583576a 100644 (file)
@@ -59,6 +59,7 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
        return false;
 }
 
+/* bit banging i2c */
 
 static void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state)
 {
@@ -181,13 +182,30 @@ static void set_data(void *i2c_priv, int data)
        WREG32(rec->en_data_reg, val);
 }
 
+static int pre_xfer(struct i2c_adapter *i2c_adap)
+{
+       struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
+
+       radeon_i2c_do_lock(i2c, 1);
+
+       return 0;
+}
+
+static void post_xfer(struct i2c_adapter *i2c_adap)
+{
+       struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
+
+       radeon_i2c_do_lock(i2c, 0);
+}
+
+/* hw i2c */
+
 static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
 {
-       struct radeon_pll *spll = &rdev->clock.spll;
        u32 sclk = radeon_get_engine_clock(rdev);
        u32 prescale = 0;
-       u32 nm;
-       u8 loop;
+       u32 nm;
+       u8 n, m, loop;
        int i2c_clock;
 
        switch (rdev->family) {
@@ -203,13 +221,15 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
        case CHIP_R300:
        case CHIP_R350:
        case CHIP_RV350:
-               n = (spll->reference_freq) / (4 * 6);
+               i2c_clock = 60;
+               nm = (sclk * 10) / (i2c_clock * 4);
                for (loop = 1; loop < 255; loop++) {
-                       if ((loop * (loop - 1)) > n)
+                       if ((nm / loop) < loop)
                                break;
                }
-               m = loop - 1;
-               prescale = m | (loop << 8);
+               n = loop - 1;
+               m = loop - 2;
+               prescale = m | (n << 8);
                break;
        case CHIP_RV380:
        case CHIP_RS400:
@@ -217,7 +237,6 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
        case CHIP_R420:
        case CHIP_R423:
        case CHIP_RV410:
-               sclk = radeon_get_engine_clock(rdev);
                prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128;
                break;
        case CHIP_RS600:
@@ -232,7 +251,6 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
        case CHIP_RV570:
        case CHIP_R580:
                i2c_clock = 50;
-               sclk = radeon_get_engine_clock(rdev);
                if (rdev->family == CHIP_R520)
                        prescale = (127 << 8) + ((sclk * 10) / (4 * 127 * i2c_clock));
                else
@@ -291,6 +309,7 @@ static int r100_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
        prescale = radeon_get_i2c_prescale(rdev);
 
        reg = ((prescale << RADEON_I2C_PRESCALE_SHIFT) |
+              RADEON_I2C_DRIVE_EN |
               RADEON_I2C_START |
               RADEON_I2C_STOP |
               RADEON_I2C_GO);
@@ -757,26 +776,13 @@ done:
        return ret;
 }
 
-static int radeon_sw_i2c_xfer(struct i2c_adapter *i2c_adap,
+static int radeon_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
                              struct i2c_msg *msgs, int num)
-{
-       struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
-       int ret;
-
-       radeon_i2c_do_lock(i2c, 1);
-       ret = i2c_transfer(&i2c->algo.radeon.bit_adapter, msgs, num);
-       radeon_i2c_do_lock(i2c, 0);
-
-       return ret;
-}
-
-static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
-                          struct i2c_msg *msgs, int num)
 {
        struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
        struct radeon_device *rdev = i2c->dev->dev_private;
        struct radeon_i2c_bus_rec *rec = &i2c->rec;
-       int ret;
+       int ret = 0;
 
        switch (rdev->family) {
        case CHIP_R100:
@@ -797,16 +803,12 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
        case CHIP_RV410:
        case CHIP_RS400:
        case CHIP_RS480:
-               if (rec->hw_capable)
-                       ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
-               else
-                       ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
+               ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
                break;
        case CHIP_RS600:
        case CHIP_RS690:
        case CHIP_RS740:
                /* XXX fill in hw i2c implementation */
-               ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
                break;
        case CHIP_RV515:
        case CHIP_R520:
@@ -814,20 +816,16 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
        case CHIP_RV560:
        case CHIP_RV570:
        case CHIP_R580:
-               if (rec->hw_capable) {
-                       if (rec->mm_i2c)
-                               ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
-                       else
-                               ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
-               } else
-                       ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
+               if (rec->mm_i2c)
+                       ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
+               else
+                       ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
                break;
        case CHIP_R600:
        case CHIP_RV610:
        case CHIP_RV630:
        case CHIP_RV670:
                /* XXX fill in hw i2c implementation */
-               ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
                break;
        case CHIP_RV620:
        case CHIP_RV635:
@@ -838,7 +836,6 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
        case CHIP_RV710:
        case CHIP_RV740:
                /* XXX fill in hw i2c implementation */
-               ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
                break;
        case CHIP_CEDAR:
        case CHIP_REDWOOD:
@@ -846,7 +843,6 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
        case CHIP_CYPRESS:
        case CHIP_HEMLOCK:
                /* XXX fill in hw i2c implementation */
-               ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
                break;
        default:
                DRM_ERROR("i2c: unhandled radeon chip\n");
@@ -857,20 +853,21 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
        return ret;
 }
 
-static u32 radeon_i2c_func(struct i2c_adapter *adap)
+static u32 radeon_hw_i2c_func(struct i2c_adapter *adap)
 {
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
 static const struct i2c_algorithm radeon_i2c_algo = {
-       .master_xfer = radeon_i2c_xfer,
-       .functionality = radeon_i2c_func,
+       .master_xfer = radeon_hw_i2c_xfer,
+       .functionality = radeon_hw_i2c_func,
 };
 
 struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
                                          struct radeon_i2c_bus_rec *rec,
                                          const char *name)
 {
+       struct radeon_device *rdev = dev->dev_private;
        struct radeon_i2c_chan *i2c;
        int ret;
 
@@ -878,37 +875,43 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
        if (i2c == NULL)
                return NULL;
 
-       /* set the internal bit adapter */
-       i2c->algo.radeon.bit_adapter.owner = THIS_MODULE;
-       i2c_set_adapdata(&i2c->algo.radeon.bit_adapter, i2c);
-       sprintf(i2c->algo.radeon.bit_adapter.name, "Radeon internal i2c bit bus %s", name);
-       i2c->algo.radeon.bit_adapter.algo_data = &i2c->algo.radeon.bit_data;
-       i2c->algo.radeon.bit_data.setsda = set_data;
-       i2c->algo.radeon.bit_data.setscl = set_clock;
-       i2c->algo.radeon.bit_data.getsda = get_data;
-       i2c->algo.radeon.bit_data.getscl = get_clock;
-       i2c->algo.radeon.bit_data.udelay = 20;
-       /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always
-        * make this, 2 jiffies is a lot more reliable */
-       i2c->algo.radeon.bit_data.timeout = 2;
-       i2c->algo.radeon.bit_data.data = i2c;
-       ret = i2c_bit_add_bus(&i2c->algo.radeon.bit_adapter);
-       if (ret) {
-               DRM_ERROR("Failed to register internal bit i2c %s\n", name);
-               goto out_free;
-       }
-       /* set the radeon i2c adapter */
-       i2c->dev = dev;
        i2c->rec = *rec;
        i2c->adapter.owner = THIS_MODULE;
+       i2c->dev = dev;
        i2c_set_adapdata(&i2c->adapter, i2c);
-       sprintf(i2c->adapter.name, "Radeon i2c %s", name);
-       i2c->adapter.algo_data = &i2c->algo.radeon;
-       i2c->adapter.algo = &radeon_i2c_algo;
-       ret = i2c_add_adapter(&i2c->adapter);
-       if (ret) {
-               DRM_ERROR("Failed to register i2c %s\n", name);
-               goto out_free;
+       if (rec->mm_i2c ||
+           (rec->hw_capable &&
+            radeon_hw_i2c &&
+            ((rdev->family <= CHIP_RS480) ||
+             ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
+               /* set the radeon hw i2c adapter */
+               sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name);
+               i2c->adapter.algo = &radeon_i2c_algo;
+               ret = i2c_add_adapter(&i2c->adapter);
+               if (ret) {
+                       DRM_ERROR("Failed to register hw i2c %s\n", name);
+                       goto out_free;
+               }
+       } else {
+               /* set the radeon bit adapter */
+               sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name);
+               i2c->adapter.algo_data = &i2c->algo.bit;
+               i2c->algo.bit.pre_xfer = pre_xfer;
+               i2c->algo.bit.post_xfer = post_xfer;
+               i2c->algo.bit.setsda = set_data;
+               i2c->algo.bit.setscl = set_clock;
+               i2c->algo.bit.getsda = get_data;
+               i2c->algo.bit.getscl = get_clock;
+               i2c->algo.bit.udelay = 20;
+               /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always
+                * make this, 2 jiffies is a lot more reliable */
+               i2c->algo.bit.timeout = 2;
+               i2c->algo.bit.data = i2c;
+               ret = i2c_bit_add_bus(&i2c->adapter);
+               if (ret) {
+                       DRM_ERROR("Failed to register bit i2c %s\n", name);
+                       goto out_free;
+               }
        }
 
        return i2c;
@@ -953,16 +956,6 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c)
 {
        if (!i2c)
                return;
-       i2c_del_adapter(&i2c->algo.radeon.bit_adapter);
-       i2c_del_adapter(&i2c->adapter);
-       kfree(i2c);
-}
-
-void radeon_i2c_destroy_dp(struct radeon_i2c_chan *i2c)
-{
-       if (!i2c)
-               return;
-
        i2c_del_adapter(&i2c->adapter);
        kfree(i2c);
 }
index 3cfd60fd00835343f8cacececcb01ba600521133..a212041e8b0b0a5ef0d47d7949f057d38be480ed 100644 (file)
@@ -67,9 +67,10 @@ void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
 
        /* Disable *all* interrupts */
        rdev->irq.sw_int = false;
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < rdev->num_crtc; i++)
                rdev->irq.crtc_vblank_int[i] = false;
-       }
+       for (i = 0; i < 6; i++)
+               rdev->irq.hpd[i] = false;
        radeon_irq_set(rdev);
        /* Clear bits */
        radeon_irq_process(rdev);
@@ -95,34 +96,29 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
        }
        /* Disable *all* interrupts */
        rdev->irq.sw_int = false;
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < rdev->num_crtc; i++)
                rdev->irq.crtc_vblank_int[i] = false;
+       for (i = 0; i < 6; i++)
                rdev->irq.hpd[i] = false;
-       }
        radeon_irq_set(rdev);
 }
 
 int radeon_irq_kms_init(struct radeon_device *rdev)
 {
        int r = 0;
-       int num_crtc = 2;
 
-       if (rdev->flags & RADEON_SINGLE_CRTC)
-               num_crtc = 1;
        spin_lock_init(&rdev->irq.sw_lock);
-       r = drm_vblank_init(rdev->ddev, num_crtc);
+       r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
        if (r) {
                return r;
        }
        /* enable msi */
        rdev->msi_enabled = 0;
-       /* MSIs don't seem to work on my rs780;
-        * not sure about rs880 or other rs780s.
-        * Needs more investigation.
+       /* MSIs don't seem to work reliably on all IGP
+        * chips.  Disable MSI on them for now.
         */
        if ((rdev->family >= CHIP_RV380) &&
-           (rdev->family != CHIP_RS780) &&
-           (rdev->family != CHIP_RS880)) {
+           (!(rdev->flags & RADEON_IS_IGP))) {
                int ret = pci_enable_msi(rdev->pdev);
                if (!ret) {
                        rdev->msi_enabled = 1;
index 20ec276e7596c1937a2a6a4beaceb1247bdfb085..d3657dcfdd26335ea9b1ed26e5df4a8d57b52094 100644 (file)
@@ -31,6 +31,7 @@
 #include "radeon_drm.h"
 
 #include <linux/vga_switcheroo.h>
+#include <linux/slab.h>
 
 int radeon_driver_unload_kms(struct drm_device *dev)
 {
index df23d6a01d02297a8ee0832a9f800f48b4ea957c..88865e38fe30a100d2263f5a8db3c51b21a9445c 100644 (file)
@@ -603,6 +603,10 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
                                      ? RADEON_CRTC2_INTERLACE_EN
                                      : 0));
 
+               /* rs4xx chips seem to like to have the crtc enabled when the timing is set */
+               if ((rdev->family == CHIP_RS400) || (rdev->family == CHIP_RS480))
+                       crtc2_gen_cntl |= RADEON_CRTC2_EN;
+
                disp2_merge_cntl = RREG32(RADEON_DISP2_MERGE_CNTL);
                disp2_merge_cntl &= ~RADEON_DISP2_RGB_OFFSET_EN;
 
@@ -630,6 +634,10 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
                                    ? RADEON_CRTC_INTERLACE_EN
                                    : 0));
 
+               /* rs4xx chips seem to like to have the crtc enabled when the timing is set */
+               if ((rdev->family == CHIP_RS400) || (rdev->family == CHIP_RS480))
+                       crtc_gen_cntl |= RADEON_CRTC_EN;
+
                crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
                crtc_ext_cntl |= (RADEON_XCRT_CNT_EN |
                                  RADEON_CRTC_VSYNC_DIS |
index 417684daef4cb4009057caffb128b6c7533e85c6..f2ed27c8055bc90c0f9004471e063d0e89471801 100644 (file)
 #define NTSC_TV_PLL_N_14 693
 #define NTSC_TV_PLL_P_14 7
 
+#define PAL_TV_PLL_M_14 19
+#define PAL_TV_PLL_N_14 353
+#define PAL_TV_PLL_P_14 5
+
 #define VERT_LEAD_IN_LINES 2
 #define FRAC_BITS 0xe
 #define FRAC_MASK 0x3fff
@@ -205,9 +209,24 @@ static const struct radeon_tv_mode_constants available_tv_modes[] = {
                630627,             /* defRestart */
                347,                /* crtcPLL_N */
                14,                 /* crtcPLL_M */
-                       8,                  /* crtcPLL_postDiv */
+               8,                  /* crtcPLL_postDiv */
                1022,               /* pixToTV */
        },
+       { /* PAL timing for 14 Mhz ref clk */
+               800,                /* horResolution */
+               600,                /* verResolution */
+               TV_STD_PAL,         /* standard */
+               1131,               /* horTotal */
+               742,                /* verTotal */
+               813,                /* horStart */
+               840,                /* horSyncStart */
+               633,                /* verSyncStart */
+               708369,             /* defRestart */
+               211,                /* crtcPLL_N */
+               9,                  /* crtcPLL_M */
+               8,                  /* crtcPLL_postDiv */
+               759,                /* pixToTV */
+       },
 };
 
 #define N_AVAILABLE_MODES ARRAY_SIZE(available_tv_modes)
@@ -242,7 +261,7 @@ static const struct radeon_tv_mode_constants *radeon_legacy_tv_get_std_mode(stru
                if (pll->reference_freq == 2700)
                        const_ptr = &available_tv_modes[1];
                else
-                       const_ptr = &available_tv_modes[1]; /* FIX ME */
+                       const_ptr = &available_tv_modes[3];
        }
        return const_ptr;
 }
@@ -685,9 +704,9 @@ void radeon_legacy_tv_mode_set(struct drm_encoder *encoder,
                        n = PAL_TV_PLL_N_27;
                        p = PAL_TV_PLL_P_27;
                } else {
-                       m = PAL_TV_PLL_M_27;
-                       n = PAL_TV_PLL_N_27;
-                       p = PAL_TV_PLL_P_27;
+                       m = PAL_TV_PLL_M_14;
+                       n = PAL_TV_PLL_N_14;
+                       p = PAL_TV_PLL_P_14;
                }
        }
 
index 1702b820aa4d3137e0559d44bd64bc37d8c28d7c..0b8e32776b10930b3dc67266c49a21fce3933a46 100644 (file)
@@ -129,6 +129,7 @@ struct radeon_tmds_pll {
 #define RADEON_PLL_USE_FRAC_FB_DIV      (1 << 10)
 #define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11)
 #define RADEON_PLL_USE_POST_DIV         (1 << 12)
+#define RADEON_PLL_IS_LCD               (1 << 13)
 
 /* pll algo */
 enum radeon_pll_algo {
@@ -149,6 +150,8 @@ struct radeon_pll {
        uint32_t pll_in_max;
        uint32_t pll_out_min;
        uint32_t pll_out_max;
+       uint32_t lcd_pll_out_min;
+       uint32_t lcd_pll_out_max;
        uint32_t best_vco;
 
        /* divider limits */
@@ -170,17 +173,12 @@ struct radeon_pll {
        enum radeon_pll_algo algo;
 };
 
-struct i2c_algo_radeon_data {
-       struct i2c_adapter bit_adapter;
-       struct i2c_algo_bit_data bit_data;
-};
-
 struct radeon_i2c_chan {
        struct i2c_adapter adapter;
        struct drm_device *dev;
        union {
+               struct i2c_algo_bit_data bit;
                struct i2c_algo_dp_aux_data dp;
-               struct i2c_algo_radeon_data radeon;
        } algo;
        struct radeon_i2c_bus_rec rec;
 };
@@ -342,6 +340,7 @@ struct radeon_encoder {
        struct drm_display_mode native_mode;
        void *enc_priv;
        int hdmi_offset;
+       int hdmi_config_offset;
        int hdmi_audio_workaround;
        int hdmi_buffer_status;
 };
@@ -431,7 +430,6 @@ extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
                                                 struct radeon_i2c_bus_rec *rec,
                                                 const char *name);
 extern void radeon_i2c_destroy(struct radeon_i2c_chan *i2c);
-extern void radeon_i2c_destroy_dp(struct radeon_i2c_chan *i2c);
 extern void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus,
                                u8 slave_addr,
                                u8 addr,
index fc9d00ac6b15ff68494c437dd758aff4f3214f66..122774742bd551ebecdd6b5509f904ff24ebe660 100644 (file)
@@ -30,6 +30,7 @@
  *    Dave Airlie
  */
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <drm/drmP.h>
 #include "radeon_drm.h"
 #include "radeon.h"
@@ -185,8 +186,10 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
                return 0;
        }
        radeon_ttm_placement_from_domain(bo, domain);
-       /* force to pin into visible video ram */
-       bo->placement.lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
+       if (domain == RADEON_GEM_DOMAIN_VRAM) {
+               /* force to pin into visible video ram */
+               bo->placement.lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
+       }
        for (i = 0; i < bo->placement.num_placement; i++)
                bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
        r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
index d4d1c39a0e99e4e8636dd9e1d095da4473c61e87..a4b57493aa78cca3809558f3a428262f389a7837 100644 (file)
@@ -28,6 +28,7 @@
 #define RADEON_RECLOCK_DELAY_MS 200
 #define RADEON_WAIT_VBLANK_TIMEOUT 200
 
+static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish);
 static void radeon_pm_set_clocks_locked(struct radeon_device *rdev);
 static void radeon_pm_set_clocks(struct radeon_device *rdev);
 static void radeon_pm_idle_work_handler(struct work_struct *work);
@@ -179,6 +180,16 @@ static void radeon_get_power_state(struct radeon_device *rdev,
                 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
 }
 
+static inline void radeon_sync_with_vblank(struct radeon_device *rdev)
+{
+       if (rdev->pm.active_crtcs) {
+               rdev->pm.vblank_sync = false;
+               wait_event_timeout(
+                       rdev->irq.vblank_queue, rdev->pm.vblank_sync,
+                       msecs_to_jiffies(RADEON_WAIT_VBLANK_TIMEOUT));
+       }
+}
+
 static void radeon_set_power_state(struct radeon_device *rdev)
 {
        /* if *_clock_mode are the same, *_power_state are as well */
@@ -189,11 +200,28 @@ static void radeon_set_power_state(struct radeon_device *rdev)
                 rdev->pm.requested_clock_mode->sclk,
                 rdev->pm.requested_clock_mode->mclk,
                 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
+
        /* set pcie lanes */
+       /* TODO */
+
        /* set voltage */
+       /* TODO */
+
        /* set engine clock */
+       radeon_sync_with_vblank(rdev);
+       radeon_pm_debug_check_in_vbl(rdev, false);
        radeon_set_engine_clock(rdev, rdev->pm.requested_clock_mode->sclk);
+       radeon_pm_debug_check_in_vbl(rdev, true);
+
+#if 0
        /* set memory clock */
+       if (rdev->asic->set_memory_clock) {
+               radeon_sync_with_vblank(rdev);
+               radeon_pm_debug_check_in_vbl(rdev, false);
+               radeon_set_memory_clock(rdev, rdev->pm.requested_clock_mode->mclk);
+               radeon_pm_debug_check_in_vbl(rdev, true);
+       }
+#endif
 
        rdev->pm.current_power_state = rdev->pm.requested_power_state;
        rdev->pm.current_clock_mode = rdev->pm.requested_clock_mode;
@@ -229,6 +257,12 @@ int radeon_pm_init(struct radeon_device *rdev)
        return 0;
 }
 
+void radeon_pm_fini(struct radeon_device *rdev)
+{
+       if (rdev->pm.i2c_bus)
+               radeon_i2c_destroy(rdev->pm.i2c_bus);
+}
+
 void radeon_pm_compute_clocks(struct radeon_device *rdev)
 {
        struct drm_device *ddev = rdev->ddev;
@@ -245,7 +279,8 @@ void radeon_pm_compute_clocks(struct radeon_device *rdev)
        list_for_each_entry(connector,
                &ddev->mode_config.connector_list, head) {
                if (connector->encoder &&
-                       connector->dpms != DRM_MODE_DPMS_OFF) {
+                   connector->encoder->crtc &&
+                   connector->dpms != DRM_MODE_DPMS_OFF) {
                        radeon_crtc = to_radeon_crtc(connector->encoder->crtc);
                        rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
                        ++count;
@@ -333,10 +368,7 @@ static void radeon_pm_set_clocks_locked(struct radeon_device *rdev)
                break;
        }
 
-       /* check if we are in vblank */
-       radeon_pm_debug_check_in_vbl(rdev, false);
        radeon_set_power_state(rdev);
-       radeon_pm_debug_check_in_vbl(rdev, true);
        rdev->pm.planned_action = PM_ACTION_NONE;
 }
 
@@ -353,10 +385,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
                rdev->pm.req_vblank |= (1 << 1);
                drm_vblank_get(rdev->ddev, 1);
        }
-       if (rdev->pm.active_crtcs)
-               wait_event_interruptible_timeout(
-                       rdev->irq.vblank_queue, 0,
-                       msecs_to_jiffies(RADEON_WAIT_VBLANK_TIMEOUT));
+       radeon_pm_set_clocks_locked(rdev);
        if (rdev->pm.req_vblank & (1 << 0)) {
                rdev->pm.req_vblank &= ~(1 << 0);
                drm_vblank_put(rdev->ddev, 0);
@@ -366,7 +395,6 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
                drm_vblank_put(rdev->ddev, 1);
        }
 
-       radeon_pm_set_clocks_locked(rdev);
        mutex_unlock(&rdev->cp.mutex);
 }
 
index 5c0dc082d3307752a7dbf7067ea1b98f5cafaafa..eabbc9cf30a72fede242b8b13bd19a8c61508216 100644 (file)
 #       define RADEON_TVPLL_PWRMGT_OFF      (1 << 30)
 #       define RADEON_TVCLK_TURNOFF         (1 << 31)
 #define RADEON_PLL_PWRMGT_CNTL              0x0015 /* PLL */
+#      define RADEON_PM_MODE_SEL           (1 << 13)
 #       define RADEON_TCL_BYPASS_DISABLE    (1 << 20)
 #define RADEON_CLR_CMP_CLR_3D               0x1a24
 #define RADEON_CLR_CMP_CLR_DST              0x15c8
index e50513a627351983edbea71e2d369e959434e069..f6e1e8d4d986df18bd06a2ac7ae047eeb4706182 100644 (file)
@@ -26,6 +26,7 @@
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "radeon_drm.h"
 #include "radeon_reg.h"
index 43c5ab34b634bf78383b940e3e2bafdda4c5d89e..d031b6863082c9feb99dbe412ce9a92662d21f60 100644 (file)
@@ -36,6 +36,7 @@
 #include <drm/drmP.h>
 #include <drm/radeon_drm.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "radeon_reg.h"
 #include "radeon.h"
 
index 8f414a5f520fe50790a1c5037fbbcd13dc94fb32..af0da4ae3f55acb5223f2791940ec90c1db20bce 100644 (file)
@@ -26,20 +26,16 @@ r600 0x9400
 0x00028408 VGT_INDX_OFFSET
 0x00028AA0 VGT_INSTANCE_STEP_RATE_0
 0x00028AA4 VGT_INSTANCE_STEP_RATE_1
-0x000088C0 VGT_LAST_COPY_STATE
 0x00028400 VGT_MAX_VTX_INDX
-0x000088D8 VGT_MC_LAT_CNTL
 0x00028404 VGT_MIN_VTX_INDX
 0x00028A94 VGT_MULTI_PRIM_IB_RESET_EN
 0x0002840C VGT_MULTI_PRIM_IB_RESET_INDX
 0x00008970 VGT_NUM_INDICES
 0x00008974 VGT_NUM_INSTANCES
 0x00028A10 VGT_OUTPUT_PATH_CNTL
-0x00028C5C VGT_OUT_DEALLOC_CNTL
 0x00028A84 VGT_PRIMITIVEID_EN
 0x00008958 VGT_PRIMITIVE_TYPE
 0x00028AB4 VGT_REUSE_OFF
-0x00028C58 VGT_VERTEX_REUSE_BLOCK_CNTL
 0x00028AB8 VGT_VTX_CNT_EN
 0x000088B0 VGT_VTX_VECT_EJECT_REG
 0x00028810 PA_CL_CLIP_CNTL
@@ -280,7 +276,6 @@ r600 0x9400
 0x00028E00 PA_SU_POLY_OFFSET_FRONT_SCALE
 0x00028814 PA_SU_SC_MODE_CNTL
 0x00028C08 PA_SU_VTX_CNTL
-0x00008C00 SQ_CONFIG
 0x00008C04 SQ_GPR_RESOURCE_MGMT_1
 0x00008C08 SQ_GPR_RESOURCE_MGMT_2
 0x00008C10 SQ_STACK_RESOURCE_MGMT_1
@@ -320,18 +315,6 @@ r600 0x9400
 0x000283FC SQ_VTX_SEMANTIC_31
 0x000288E0 SQ_VTX_SEMANTIC_CLEAR
 0x0003CFF4 SQ_VTX_START_INST_LOC
-0x0003C000 SQ_TEX_SAMPLER_WORD0_0
-0x0003C004 SQ_TEX_SAMPLER_WORD1_0
-0x0003C008 SQ_TEX_SAMPLER_WORD2_0
-0x00030000 SQ_ALU_CONSTANT0_0
-0x00030004 SQ_ALU_CONSTANT1_0
-0x00030008 SQ_ALU_CONSTANT2_0
-0x0003000C SQ_ALU_CONSTANT3_0
-0x0003E380 SQ_BOOL_CONST_0
-0x0003E384 SQ_BOOL_CONST_1
-0x0003E388 SQ_BOOL_CONST_2
-0x0003E200 SQ_LOOP_CONST_0
-0x0003E200 SQ_LOOP_CONST_DX10_0
 0x000281C0 SQ_ALU_CONST_BUFFER_SIZE_GS_0
 0x000281C4 SQ_ALU_CONST_BUFFER_SIZE_GS_1
 0x000281C8 SQ_ALU_CONST_BUFFER_SIZE_GS_2
@@ -380,54 +363,6 @@ r600 0x9400
 0x000281B4 SQ_ALU_CONST_BUFFER_SIZE_VS_13
 0x000281B8 SQ_ALU_CONST_BUFFER_SIZE_VS_14
 0x000281BC SQ_ALU_CONST_BUFFER_SIZE_VS_15
-0x000289C0 SQ_ALU_CONST_CACHE_GS_0
-0x000289C4 SQ_ALU_CONST_CACHE_GS_1
-0x000289C8 SQ_ALU_CONST_CACHE_GS_2
-0x000289CC SQ_ALU_CONST_CACHE_GS_3
-0x000289D0 SQ_ALU_CONST_CACHE_GS_4
-0x000289D4 SQ_ALU_CONST_CACHE_GS_5
-0x000289D8 SQ_ALU_CONST_CACHE_GS_6
-0x000289DC SQ_ALU_CONST_CACHE_GS_7
-0x000289E0 SQ_ALU_CONST_CACHE_GS_8
-0x000289E4 SQ_ALU_CONST_CACHE_GS_9
-0x000289E8 SQ_ALU_CONST_CACHE_GS_10
-0x000289EC SQ_ALU_CONST_CACHE_GS_11
-0x000289F0 SQ_ALU_CONST_CACHE_GS_12
-0x000289F4 SQ_ALU_CONST_CACHE_GS_13
-0x000289F8 SQ_ALU_CONST_CACHE_GS_14
-0x000289FC SQ_ALU_CONST_CACHE_GS_15
-0x00028940 SQ_ALU_CONST_CACHE_PS_0
-0x00028944 SQ_ALU_CONST_CACHE_PS_1
-0x00028948 SQ_ALU_CONST_CACHE_PS_2
-0x0002894C SQ_ALU_CONST_CACHE_PS_3
-0x00028950 SQ_ALU_CONST_CACHE_PS_4
-0x00028954 SQ_ALU_CONST_CACHE_PS_5
-0x00028958 SQ_ALU_CONST_CACHE_PS_6
-0x0002895C SQ_ALU_CONST_CACHE_PS_7
-0x00028960 SQ_ALU_CONST_CACHE_PS_8
-0x00028964 SQ_ALU_CONST_CACHE_PS_9
-0x00028968 SQ_ALU_CONST_CACHE_PS_10
-0x0002896C SQ_ALU_CONST_CACHE_PS_11
-0x00028970 SQ_ALU_CONST_CACHE_PS_12
-0x00028974 SQ_ALU_CONST_CACHE_PS_13
-0x00028978 SQ_ALU_CONST_CACHE_PS_14
-0x0002897C SQ_ALU_CONST_CACHE_PS_15
-0x00028980 SQ_ALU_CONST_CACHE_VS_0
-0x00028984 SQ_ALU_CONST_CACHE_VS_1
-0x00028988 SQ_ALU_CONST_CACHE_VS_2
-0x0002898C SQ_ALU_CONST_CACHE_VS_3
-0x00028990 SQ_ALU_CONST_CACHE_VS_4
-0x00028994 SQ_ALU_CONST_CACHE_VS_5
-0x00028998 SQ_ALU_CONST_CACHE_VS_6
-0x0002899C SQ_ALU_CONST_CACHE_VS_7
-0x000289A0 SQ_ALU_CONST_CACHE_VS_8
-0x000289A4 SQ_ALU_CONST_CACHE_VS_9
-0x000289A8 SQ_ALU_CONST_CACHE_VS_10
-0x000289AC SQ_ALU_CONST_CACHE_VS_11
-0x000289B0 SQ_ALU_CONST_CACHE_VS_12
-0x000289B4 SQ_ALU_CONST_CACHE_VS_13
-0x000289B8 SQ_ALU_CONST_CACHE_VS_14
-0x000289BC SQ_ALU_CONST_CACHE_VS_15
 0x000288D8 SQ_PGM_CF_OFFSET_ES
 0x000288DC SQ_PGM_CF_OFFSET_FS
 0x000288D4 SQ_PGM_CF_OFFSET_GS
@@ -494,12 +429,7 @@ r600 0x9400
 0x00028438 SX_ALPHA_REF
 0x00028410 SX_ALPHA_TEST_CONTROL
 0x00028350 SX_MISC
-0x0000A020 SMX_DC_CTL0
-0x0000A024 SMX_DC_CTL1
-0x0000A028 SMX_DC_CTL2
-0x00009608 TC_CNTL
 0x00009604 TC_INVALIDATE
-0x00009490 TD_CNTL
 0x00009400 TD_FILTER4
 0x00009404 TD_FILTER4_1
 0x00009408 TD_FILTER4_2
@@ -824,14 +754,9 @@ r600 0x9400
 0x00028428 CB_FOG_GREEN
 0x00028424 CB_FOG_RED
 0x00008040 WAIT_UNTIL
-0x00008950 CC_GC_SHADER_PIPE_CONFIG
-0x00008954 GC_USER_SHADER_PIPE_CONFIG
 0x00009714 VC_ENHANCE
 0x00009830 DB_DEBUG
 0x00009838 DB_WATERMARKS
 0x00028D28 DB_SRESULTS_COMPARE_STATE0
 0x00028D44 DB_ALPHA_TO_MASK
-0x00009504 TA_CNTL
 0x00009700 VC_CNTL
-0x00009718 VC_CONFIG
-0x0000A02C SMX_DC_MC_INTF_CTL
index 626d51891ee968613efeffc6612698387b46f1d4..1a41cb268b72c7ac6594f74ee80ccc47325b4ce7 100644 (file)
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <drm/drmP.h>
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "rs400d.h"
 
 /* This files gather functions specifics to : rs400,rs480 */
@@ -202,9 +204,9 @@ void rs400_gart_disable(struct radeon_device *rdev)
 
 void rs400_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        rs400_gart_disable(rdev);
        radeon_gart_table_ram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
@@ -264,6 +266,7 @@ void rs400_mc_init(struct radeon_device *rdev)
        base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
        radeon_vram_location(rdev, &rdev->mc, base);
        radeon_gtt_location(rdev, &rdev->mc);
+       radeon_update_bandwidth_info(rdev);
 }
 
 uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -388,6 +391,8 @@ static int rs400_startup(struct radeon_device *rdev)
 {
        int r;
 
+       r100_set_common_regs(rdev);
+
        rs400_mc_program(rdev);
        /* Resume clock */
        r300_clock_startup(rdev);
@@ -453,6 +458,7 @@ int rs400_suspend(struct radeon_device *rdev)
 
 void rs400_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index 47f046b78c6ba9c19c93a2560179310b92f322d6..abf824c2123d5e0067d822ce6874ffeeb24c4857 100644 (file)
@@ -37,6 +37,7 @@
  */
 #include "drmP.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "atom.h"
 #include "rs600d.h"
 
@@ -267,9 +268,9 @@ void rs600_gart_disable(struct radeon_device *rdev)
 
 void rs600_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        rs600_gart_disable(rdev);
        radeon_gart_table_vram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 #define R600_PTE_VALID     (1 << 0)
@@ -392,10 +393,12 @@ int rs600_irq_process(struct radeon_device *rdev)
                /* Vertical blank interrupts */
                if (G_007EDC_LB_D1_VBLANK_INTERRUPT(r500_disp_int)) {
                        drm_handle_vblank(rdev->ddev, 0);
+                       rdev->pm.vblank_sync = true;
                        wake_up(&rdev->irq.vblank_queue);
                }
                if (G_007EDC_LB_D2_VBLANK_INTERRUPT(r500_disp_int)) {
                        drm_handle_vblank(rdev->ddev, 1);
+                       rdev->pm.vblank_sync = true;
                        wake_up(&rdev->irq.vblank_queue);
                }
                if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(r500_disp_int)) {
@@ -472,13 +475,38 @@ void rs600_mc_init(struct radeon_device *rdev)
        rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
        base = RREG32_MC(R_000004_MC_FB_LOCATION);
        base = G_000004_MC_FB_START(base) << 16;
+       rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
        radeon_vram_location(rdev, &rdev->mc, base);
        radeon_gtt_location(rdev, &rdev->mc);
+       radeon_update_bandwidth_info(rdev);
 }
 
 void rs600_bandwidth_update(struct radeon_device *rdev)
 {
-       /* FIXME: implement, should this be like rs690 ? */
+       struct drm_display_mode *mode0 = NULL;
+       struct drm_display_mode *mode1 = NULL;
+       u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt;
+       /* FIXME: implement full support */
+
+       radeon_update_display_priority(rdev);
+
+       if (rdev->mode_info.crtcs[0]->base.enabled)
+               mode0 = &rdev->mode_info.crtcs[0]->base.mode;
+       if (rdev->mode_info.crtcs[1]->base.enabled)
+               mode1 = &rdev->mode_info.crtcs[1]->base.mode;
+
+       rs690_line_buffer_adjust(rdev, mode0, mode1);
+
+       if (rdev->disp_priority == 2) {
+               d1mode_priority_a_cnt = RREG32(R_006548_D1MODE_PRIORITY_A_CNT);
+               d2mode_priority_a_cnt = RREG32(R_006D48_D2MODE_PRIORITY_A_CNT);
+               d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
+               d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
+               WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
+               WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
+               WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
+               WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
+       }
 }
 
 uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -598,6 +626,7 @@ int rs600_suspend(struct radeon_device *rdev)
 
 void rs600_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index c1c8f5885cbbc0727e484c49972e21790b5d3d74..e52d2695510b7375af024f99cb15083ebbba9c7d 100644 (file)
 #define   G_00016C_INVALIDATE_L1_TLB(x)                (((x) >> 20) & 0x1)
 #define   C_00016C_INVALIDATE_L1_TLB                   0xFFEFFFFF
 
+#define R_006548_D1MODE_PRIORITY_A_CNT               0x006548
+#define   S_006548_D1MODE_PRIORITY_MARK_A(x)           (((x) & 0x7FFF) << 0)
+#define   G_006548_D1MODE_PRIORITY_MARK_A(x)           (((x) >> 0) & 0x7FFF)
+#define   C_006548_D1MODE_PRIORITY_MARK_A              0xFFFF8000
+#define   S_006548_D1MODE_PRIORITY_A_OFF(x)            (((x) & 0x1) << 16)
+#define   G_006548_D1MODE_PRIORITY_A_OFF(x)            (((x) >> 16) & 0x1)
+#define   C_006548_D1MODE_PRIORITY_A_OFF               0xFFFEFFFF
+#define   S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) & 0x1) << 20)
+#define   G_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) >> 20) & 0x1)
+#define   C_006548_D1MODE_PRIORITY_A_ALWAYS_ON         0xFFEFFFFF
+#define   S_006548_D1MODE_PRIORITY_A_FORCE_MASK(x)     (((x) & 0x1) << 24)
+#define   G_006548_D1MODE_PRIORITY_A_FORCE_MASK(x)     (((x) >> 24) & 0x1)
+#define   C_006548_D1MODE_PRIORITY_A_FORCE_MASK        0xFEFFFFFF
+#define R_00654C_D1MODE_PRIORITY_B_CNT               0x00654C
+#define   S_00654C_D1MODE_PRIORITY_MARK_B(x)           (((x) & 0x7FFF) << 0)
+#define   G_00654C_D1MODE_PRIORITY_MARK_B(x)           (((x) >> 0) & 0x7FFF)
+#define   C_00654C_D1MODE_PRIORITY_MARK_B              0xFFFF8000
+#define   S_00654C_D1MODE_PRIORITY_B_OFF(x)            (((x) & 0x1) << 16)
+#define   G_00654C_D1MODE_PRIORITY_B_OFF(x)            (((x) >> 16) & 0x1)
+#define   C_00654C_D1MODE_PRIORITY_B_OFF               0xFFFEFFFF
+#define   S_00654C_D1MODE_PRIORITY_B_ALWAYS_ON(x)      (((x) & 0x1) << 20)
+#define   G_00654C_D1MODE_PRIORITY_B_ALWAYS_ON(x)      (((x) >> 20) & 0x1)
+#define   C_00654C_D1MODE_PRIORITY_B_ALWAYS_ON         0xFFEFFFFF
+#define   S_00654C_D1MODE_PRIORITY_B_FORCE_MASK(x)     (((x) & 0x1) << 24)
+#define   G_00654C_D1MODE_PRIORITY_B_FORCE_MASK(x)     (((x) >> 24) & 0x1)
+#define   C_00654C_D1MODE_PRIORITY_B_FORCE_MASK        0xFEFFFFFF
+#define R_006D48_D2MODE_PRIORITY_A_CNT               0x006D48
+#define   S_006D48_D2MODE_PRIORITY_MARK_A(x)           (((x) & 0x7FFF) << 0)
+#define   G_006D48_D2MODE_PRIORITY_MARK_A(x)           (((x) >> 0) & 0x7FFF)
+#define   C_006D48_D2MODE_PRIORITY_MARK_A              0xFFFF8000
+#define   S_006D48_D2MODE_PRIORITY_A_OFF(x)            (((x) & 0x1) << 16)
+#define   G_006D48_D2MODE_PRIORITY_A_OFF(x)            (((x) >> 16) & 0x1)
+#define   C_006D48_D2MODE_PRIORITY_A_OFF               0xFFFEFFFF
+#define   S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) & 0x1) << 20)
+#define   G_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) >> 20) & 0x1)
+#define   C_006D48_D2MODE_PRIORITY_A_ALWAYS_ON         0xFFEFFFFF
+#define   S_006D48_D2MODE_PRIORITY_A_FORCE_MASK(x)     (((x) & 0x1) << 24)
+#define   G_006D48_D2MODE_PRIORITY_A_FORCE_MASK(x)     (((x) >> 24) & 0x1)
+#define   C_006D48_D2MODE_PRIORITY_A_FORCE_MASK        0xFEFFFFFF
+#define R_006D4C_D2MODE_PRIORITY_B_CNT               0x006D4C
+#define   S_006D4C_D2MODE_PRIORITY_MARK_B(x)           (((x) & 0x7FFF) << 0)
+#define   G_006D4C_D2MODE_PRIORITY_MARK_B(x)           (((x) >> 0) & 0x7FFF)
+#define   C_006D4C_D2MODE_PRIORITY_MARK_B              0xFFFF8000
+#define   S_006D4C_D2MODE_PRIORITY_B_OFF(x)            (((x) & 0x1) << 16)
+#define   G_006D4C_D2MODE_PRIORITY_B_OFF(x)            (((x) >> 16) & 0x1)
+#define   C_006D4C_D2MODE_PRIORITY_B_OFF               0xFFFEFFFF
+#define   S_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON(x)      (((x) & 0x1) << 20)
+#define   G_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON(x)      (((x) >> 20) & 0x1)
+#define   C_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON         0xFFEFFFFF
+#define   S_006D4C_D2MODE_PRIORITY_B_FORCE_MASK(x)     (((x) & 0x1) << 24)
+#define   G_006D4C_D2MODE_PRIORITY_B_FORCE_MASK(x)     (((x) >> 24) & 0x1)
+#define   C_006D4C_D2MODE_PRIORITY_B_FORCE_MASK        0xFEFFFFFF
+
 #endif
index 83b9174f76f255e9fb488a3fe294a87eb0fafd62..bbf3da790fd59fc7a8a03e65f260487d6fa7bca0 100644 (file)
@@ -27,6 +27,7 @@
  */
 #include "drmP.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "atom.h"
 #include "rs690d.h"
 
@@ -57,42 +58,57 @@ static void rs690_gpu_init(struct radeon_device *rdev)
        }
 }
 
+union igp_info {
+       struct _ATOM_INTEGRATED_SYSTEM_INFO info;
+       struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_v2;
+};
+
 void rs690_pm_info(struct radeon_device *rdev)
 {
        int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo);
-       struct _ATOM_INTEGRATED_SYSTEM_INFO *info;
-       struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 *info_v2;
-       void *ptr;
+       union igp_info *info;
        uint16_t data_offset;
        uint8_t frev, crev;
        fixed20_12 tmp;
 
-       atom_parse_data_header(rdev->mode_info.atom_context, index, NULL,
-                              &frev, &crev, &data_offset);
-       ptr = rdev->mode_info.atom_context->bios + data_offset;
-       info = (struct _ATOM_INTEGRATED_SYSTEM_INFO *)ptr;
-       info_v2 = (struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 *)ptr;
-       /* Get various system informations from bios */
-       switch (crev) {
-       case 1:
-               tmp.full = rfixed_const(100);
-               rdev->pm.igp_sideport_mclk.full = rfixed_const(info->ulBootUpMemoryClock);
-               rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
-               rdev->pm.igp_system_mclk.full = rfixed_const(le16_to_cpu(info->usK8MemoryClock));
-               rdev->pm.igp_ht_link_clk.full = rfixed_const(le16_to_cpu(info->usFSBClock));
-               rdev->pm.igp_ht_link_width.full = rfixed_const(info->ucHTLinkWidth);
-               break;
-       case 2:
-               tmp.full = rfixed_const(100);
-               rdev->pm.igp_sideport_mclk.full = rfixed_const(info_v2->ulBootUpSidePortClock);
-               rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
-               rdev->pm.igp_system_mclk.full = rfixed_const(info_v2->ulBootUpUMAClock);
-               rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp);
-               rdev->pm.igp_ht_link_clk.full = rfixed_const(info_v2->ulHTLinkFreq);
-               rdev->pm.igp_ht_link_clk.full = rfixed_div(rdev->pm.igp_ht_link_clk, tmp);
-               rdev->pm.igp_ht_link_width.full = rfixed_const(le16_to_cpu(info_v2->usMinHTLinkWidth));
-               break;
-       default:
+       if (atom_parse_data_header(rdev->mode_info.atom_context, index, NULL,
+                                  &frev, &crev, &data_offset)) {
+               info = (union igp_info *)(rdev->mode_info.atom_context->bios + data_offset);
+
+               /* Get various system informations from bios */
+               switch (crev) {
+               case 1:
+                       tmp.full = rfixed_const(100);
+                       rdev->pm.igp_sideport_mclk.full = rfixed_const(info->info.ulBootUpMemoryClock);
+                       rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
+                       rdev->pm.igp_system_mclk.full = rfixed_const(le16_to_cpu(info->info.usK8MemoryClock));
+                       rdev->pm.igp_ht_link_clk.full = rfixed_const(le16_to_cpu(info->info.usFSBClock));
+                       rdev->pm.igp_ht_link_width.full = rfixed_const(info->info.ucHTLinkWidth);
+                       break;
+               case 2:
+                       tmp.full = rfixed_const(100);
+                       rdev->pm.igp_sideport_mclk.full = rfixed_const(info->info_v2.ulBootUpSidePortClock);
+                       rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
+                       rdev->pm.igp_system_mclk.full = rfixed_const(info->info_v2.ulBootUpUMAClock);
+                       rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp);
+                       rdev->pm.igp_ht_link_clk.full = rfixed_const(info->info_v2.ulHTLinkFreq);
+                       rdev->pm.igp_ht_link_clk.full = rfixed_div(rdev->pm.igp_ht_link_clk, tmp);
+                       rdev->pm.igp_ht_link_width.full = rfixed_const(le16_to_cpu(info->info_v2.usMinHTLinkWidth));
+                       break;
+               default:
+                       tmp.full = rfixed_const(100);
+                       /* We assume the slower possible clock ie worst case */
+                       /* DDR 333Mhz */
+                       rdev->pm.igp_sideport_mclk.full = rfixed_const(333);
+                       /* FIXME: system clock ? */
+                       rdev->pm.igp_system_mclk.full = rfixed_const(100);
+                       rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp);
+                       rdev->pm.igp_ht_link_clk.full = rfixed_const(200);
+                       rdev->pm.igp_ht_link_width.full = rfixed_const(8);
+                       DRM_ERROR("No integrated system info for your GPU, using safe default\n");
+                       break;
+               }
+       } else {
                tmp.full = rfixed_const(100);
                /* We assume the slower possible clock ie worst case */
                /* DDR 333Mhz */
@@ -103,7 +119,6 @@ void rs690_pm_info(struct radeon_device *rdev)
                rdev->pm.igp_ht_link_clk.full = rfixed_const(200);
                rdev->pm.igp_ht_link_width.full = rfixed_const(8);
                DRM_ERROR("No integrated system info for your GPU, using safe default\n");
-               break;
        }
        /* Compute various bandwidth */
        /* k8_bandwidth = (memory_clk / 2) * 2 * 8 * 0.5 = memory_clk * 4  */
@@ -131,7 +146,6 @@ void rs690_pm_info(struct radeon_device *rdev)
 
 void rs690_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
        u64 base;
 
        rs400_gart_adjust_size(rdev);
@@ -145,18 +159,10 @@ void rs690_mc_init(struct radeon_device *rdev)
        base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
        base = G_000100_MC_FB_START(base) << 16;
        rs690_pm_info(rdev);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
-       a.full = rfixed_const(16);
-       /* core_bandwidth = sclk(Mhz) * 16 */
-       rdev->pm.core_bandwidth.full = rfixed_div(rdev->pm.sclk, a);
        rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
        radeon_vram_location(rdev, &rdev->mc, base);
        radeon_gtt_location(rdev, &rdev->mc);
+       radeon_update_bandwidth_info(rdev);
 }
 
 void rs690_line_buffer_adjust(struct radeon_device *rdev,
@@ -394,10 +400,12 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
        struct drm_display_mode *mode1 = NULL;
        struct rs690_watermark wm0;
        struct rs690_watermark wm1;
-       u32 tmp;
+       u32 tmp, d1mode_priority_a_cnt, d2mode_priority_a_cnt;
        fixed20_12 priority_mark02, priority_mark12, fill_rate;
        fixed20_12 a, b;
 
+       radeon_update_display_priority(rdev);
+
        if (rdev->mode_info.crtcs[0]->base.enabled)
                mode0 = &rdev->mode_info.crtcs[0]->base.mode;
        if (rdev->mode_info.crtcs[1]->base.enabled)
@@ -407,7 +415,8 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
         * modes if the user specifies HIGH for displaypriority
         * option.
         */
-       if (rdev->disp_priority == 2) {
+       if ((rdev->disp_priority == 2) &&
+           ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740))) {
                tmp = RREG32_MC(R_000104_MC_INIT_MISC_LAT_TIMER);
                tmp &= C_000104_MC_DISP0R_INIT_LAT;
                tmp &= C_000104_MC_DISP1R_INIT_LAT;
@@ -482,10 +491,16 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
                        priority_mark12.full = 0;
                if (wm1.priority_mark_max.full > priority_mark12.full)
                        priority_mark12.full = wm1.priority_mark_max.full;
-               WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
-               WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
-               WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
-               WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
+               d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
+               d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
+               if (rdev->disp_priority == 2) {
+                       d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
+                       d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
+               }
+               WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
+               WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
+               WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
+               WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
        } else if (mode0) {
                if (rfixed_trunc(wm0.dbpp) > 64)
                        a.full = rfixed_mul(wm0.dbpp, wm0.num_line_pair);
@@ -512,8 +527,11 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
                        priority_mark02.full = 0;
                if (wm0.priority_mark_max.full > priority_mark02.full)
                        priority_mark02.full = wm0.priority_mark_max.full;
-               WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
-               WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
+               d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
+               if (rdev->disp_priority == 2)
+                       d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
+               WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
+               WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
                WREG32(R_006D48_D2MODE_PRIORITY_A_CNT,
                        S_006D48_D2MODE_PRIORITY_A_OFF(1));
                WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT,
@@ -544,12 +562,15 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
                        priority_mark12.full = 0;
                if (wm1.priority_mark_max.full > priority_mark12.full)
                        priority_mark12.full = wm1.priority_mark_max.full;
+               d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
+               if (rdev->disp_priority == 2)
+                       d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
                WREG32(R_006548_D1MODE_PRIORITY_A_CNT,
                        S_006548_D1MODE_PRIORITY_A_OFF(1));
                WREG32(R_00654C_D1MODE_PRIORITY_B_CNT,
                        S_00654C_D1MODE_PRIORITY_B_OFF(1));
-               WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
-               WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
+               WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
+               WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
        }
 }
 
@@ -657,6 +678,7 @@ int rs690_suspend(struct radeon_device *rdev)
 
 void rs690_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
index 62d31e7a897f89e3327235d1ab91f671d26d6f8f..36e6398a98aea242520f5772bd556ea9293af48a 100644 (file)
 #define   S_006548_D1MODE_PRIORITY_A_OFF(x)            (((x) & 0x1) << 16)
 #define   G_006548_D1MODE_PRIORITY_A_OFF(x)            (((x) >> 16) & 0x1)
 #define   C_006548_D1MODE_PRIORITY_A_OFF               0xFFFEFFFF
+#define   S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) & 0x1) << 20)
+#define   G_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x)      (((x) >> 20) & 0x1)
+#define   C_006548_D1MODE_PRIORITY_A_ALWAYS_ON         0xFFEFFFFF
 #define   S_006548_D1MODE_PRIORITY_A_FORCE_MASK(x)     (((x) & 0x1) << 24)
 #define   G_006548_D1MODE_PRIORITY_A_FORCE_MASK(x)     (((x) >> 24) & 0x1)
 #define   C_006548_D1MODE_PRIORITY_A_FORCE_MASK        0xFEFFFFFF
index bea747da123ffef833df17c8d71e9ee1b0c02121..9035121f4b584bc1282c334130db4e0e16eefab2 100644 (file)
  *          Jerome Glisse
  */
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "rv515d.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "atom.h"
 #include "rv515_reg_safe.h"
 
@@ -279,19 +281,13 @@ static void rv515_vram_get_type(struct radeon_device *rdev)
 
 void rv515_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
 
        rv515_vram_get_type(rdev);
        r100_vram_init_sizes(rdev);
        radeon_vram_location(rdev, &rdev->mc, 0);
        if (!(rdev->flags & RADEON_IS_AGP))
                radeon_gtt_location(rdev, &rdev->mc);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+       radeon_update_bandwidth_info(rdev);
 }
 
 uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -539,6 +535,7 @@ void rv515_set_safe_registers(struct radeon_device *rdev)
 
 void rv515_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r100_cp_fini(rdev);
        r100_wb_fini(rdev);
        r100_ib_fini(rdev);
@@ -1020,7 +1017,7 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
        struct drm_display_mode *mode1 = NULL;
        struct rv515_watermark wm0;
        struct rv515_watermark wm1;
-       u32 tmp;
+       u32 tmp, d1mode_priority_a_cnt, d2mode_priority_a_cnt;
        fixed20_12 priority_mark02, priority_mark12, fill_rate;
        fixed20_12 a, b;
 
@@ -1088,10 +1085,16 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
                        priority_mark12.full = 0;
                if (wm1.priority_mark_max.full > priority_mark12.full)
                        priority_mark12.full = wm1.priority_mark_max.full;
-               WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
-               WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
-               WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
-               WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
+               d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
+               d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
+               if (rdev->disp_priority == 2) {
+                       d1mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
+                       d2mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
+               }
+               WREG32(D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
+               WREG32(D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
+               WREG32(D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
+               WREG32(D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
        } else if (mode0) {
                if (rfixed_trunc(wm0.dbpp) > 64)
                        a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
@@ -1118,8 +1121,11 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
                        priority_mark02.full = 0;
                if (wm0.priority_mark_max.full > priority_mark02.full)
                        priority_mark02.full = wm0.priority_mark_max.full;
-               WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
-               WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
+               d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
+               if (rdev->disp_priority == 2)
+                       d1mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
+               WREG32(D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
+               WREG32(D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
                WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
                WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
        } else {
@@ -1148,10 +1154,13 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
                        priority_mark12.full = 0;
                if (wm1.priority_mark_max.full > priority_mark12.full)
                        priority_mark12.full = wm1.priority_mark_max.full;
+               d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
+               if (rdev->disp_priority == 2)
+                       d2mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
                WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
                WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
-               WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
-               WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
+               WREG32(D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
+               WREG32(D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
        }
 }
 
@@ -1161,6 +1170,8 @@ void rv515_bandwidth_update(struct radeon_device *rdev)
        struct drm_display_mode *mode0 = NULL;
        struct drm_display_mode *mode1 = NULL;
 
+       radeon_update_display_priority(rdev);
+
        if (rdev->mode_info.crtcs[0]->base.enabled)
                mode0 = &rdev->mode_info.crtcs[0]->base.mode;
        if (rdev->mode_info.crtcs[1]->base.enabled)
@@ -1170,7 +1181,8 @@ void rv515_bandwidth_update(struct radeon_device *rdev)
         * modes if the user specifies HIGH for displaypriority
         * option.
         */
-       if (rdev->disp_priority == 2) {
+       if ((rdev->disp_priority == 2) &&
+           (rdev->family == CHIP_RV515)) {
                tmp = RREG32_MC(MC_MISC_LAT_TIMER);
                tmp &= ~MC_DISP1R_INIT_LAT_MASK;
                tmp &= ~MC_DISP0R_INIT_LAT_MASK;
index 37887dee12afc48fa999fcf4f828433396604213..97958a64df1a5c7e438939d854ef95bcf47d2750 100644 (file)
  */
 #include <linux/firmware.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include "drmP.h"
 #include "radeon.h"
+#include "radeon_asic.h"
 #include "radeon_drm.h"
 #include "rv770d.h"
 #include "atom.h"
@@ -125,9 +127,9 @@ void rv770_pcie_gart_disable(struct radeon_device *rdev)
 
 void rv770_pcie_gart_fini(struct radeon_device *rdev)
 {
+       radeon_gart_fini(rdev);
        rv770_pcie_gart_disable(rdev);
        radeon_gart_table_vram_free(rdev);
-       radeon_gart_fini(rdev);
 }
 
 
@@ -647,10 +649,13 @@ static void rv770_gpu_init(struct radeon_device *rdev)
 
        WREG32(CC_RB_BACKEND_DISABLE,      cc_rb_backend_disable);
        WREG32(CC_GC_SHADER_PIPE_CONFIG,   cc_gc_shader_pipe_config);
+       WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
        WREG32(CC_SYS_RB_BACKEND_DISABLE,  cc_rb_backend_disable);
 
        WREG32(CGTS_SYS_TCC_DISABLE, 0);
        WREG32(CGTS_TCC_DISABLE, 0);
+       WREG32(CGTS_USER_SYS_TCC_DISABLE, 0);
+       WREG32(CGTS_USER_TCC_DISABLE, 0);
 
        num_qd_pipes =
                R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8);
@@ -864,7 +869,6 @@ static void rv770_gpu_init(struct radeon_device *rdev)
 
 int rv770_mc_init(struct radeon_device *rdev)
 {
-       fixed20_12 a;
        u32 tmp;
        int chansize, numchan;
 
@@ -908,12 +912,8 @@ int rv770_mc_init(struct radeon_device *rdev)
                rdev->mc.real_vram_size = rdev->mc.aper_size;
        }
        r600_vram_gtt_location(rdev, &rdev->mc);
-       /* FIXME: we should enforce default clock in case GPU is not in
-        * default setup
-        */
-       a.full = rfixed_const(100);
-       rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
-       rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
+       radeon_update_bandwidth_info(rdev);
+
        return 0;
 }
 
@@ -1013,6 +1013,13 @@ int rv770_resume(struct radeon_device *rdev)
                DRM_ERROR("radeon: failled testing IB (%d).\n", r);
                return r;
        }
+
+       r = r600_audio_init(rdev);
+       if (r) {
+               dev_err(rdev->dev, "radeon: audio init failed\n");
+               return r;
+       }
+
        return r;
 
 }
@@ -1021,6 +1028,7 @@ int rv770_suspend(struct radeon_device *rdev)
 {
        int r;
 
+       r600_audio_fini(rdev);
        /* FIXME: we should wait for ring to be empty */
        r700_cp_stop(rdev);
        rdev->cp.ready = false;
@@ -1144,11 +1152,19 @@ int rv770_init(struct radeon_device *rdev)
                        }
                }
        }
+
+       r = r600_audio_init(rdev);
+       if (r) {
+               dev_err(rdev->dev, "radeon: audio init failed\n");
+               return r;
+       }
+
        return 0;
 }
 
 void rv770_fini(struct radeon_device *rdev)
 {
+       radeon_pm_fini(rdev);
        r600_blit_fini(rdev);
        r600_cp_fini(rdev);
        r600_wb_fini(rdev);
index 4648ed2f01433a4dcce37c349de3722f7a77664a..4bf69c4044913d7e890f06a93aa2e5d25ca40fb9 100644 (file)
@@ -35,6 +35,7 @@
 #include "ttm/ttm_placement.h"
 #include <linux/agp_backend.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <asm/agp.h>
 
index 89c38c49066f2d87a69ecf58d528f2cf209a26af..dd47b2a9a791fc2f539c0df6cf797661570c47dc 100644 (file)
@@ -1425,8 +1425,8 @@ int ttm_bo_global_init(struct ttm_global_reference *ref)
 
        atomic_set(&glob->bo_count, 0);
 
-       kobject_init(&glob->kobj, &ttm_bo_glob_kobj_type);
-       ret = kobject_add(&glob->kobj, ttm_get_kobj(), "buffer_objects");
+       ret = kobject_init_and_add(
+               &glob->kobj, &ttm_bo_glob_kobj_type, ttm_get_kobj(), "buffer_objects");
        if (unlikely(ret != 0))
                kobject_put(&glob->kobj);
        return ret;
index 5ca37a58a98c80be24beb227cef980f2cdbf7abf..d764e82e799b4a264618a723ad66d46aa3e9b217 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/io.h>
 #include <linux/highmem.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/module.h>
 
index eb143e04d40242a35c99d774f981cdf610979f6b..801b702566e6d61fc94205372d886723e9459b9f 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/wait.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #define TTM_MEMORY_ALLOC_RETRIES 4
 
@@ -260,8 +261,8 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
        zone->used_mem = 0;
        zone->glob = glob;
        glob->zone_kernel = zone;
-       kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
-       ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
+       ret = kobject_init_and_add(
+               &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
        if (unlikely(ret != 0)) {
                kobject_put(&zone->kobj);
                return ret;
@@ -296,8 +297,8 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob,
        zone->used_mem = 0;
        zone->glob = glob;
        glob->zone_highmem = zone;
-       kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
-       ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
+       ret = kobject_init_and_add(
+               &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
        if (unlikely(ret != 0)) {
                kobject_put(&zone->kobj);
                return ret;
@@ -343,8 +344,8 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
        zone->used_mem = 0;
        zone->glob = glob;
        glob->zone_dma32 = zone;
-       kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type);
-       ret = kobject_add(&zone->kobj, &glob->kobj, zone->name);
+       ret = kobject_init_and_add(
+               &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
        if (unlikely(ret != 0)) {
                kobject_put(&zone->kobj);
                return ret;
@@ -365,10 +366,8 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
        glob->swap_queue = create_singlethread_workqueue("ttm_swap");
        INIT_WORK(&glob->work, ttm_shrink_work);
        init_waitqueue_head(&glob->queue);
-       kobject_init(&glob->kobj, &ttm_mem_glob_kobj_type);
-       ret = kobject_add(&glob->kobj,
-                         ttm_get_kobj(),
-                         "memory_accounting");
+       ret = kobject_init_and_add(
+               &glob->kobj, &ttm_mem_glob_kobj_type, ttm_get_kobj(), "memory_accounting");
        if (unlikely(ret != 0)) {
                kobject_put(&glob->kobj);
                return ret;
index a759170763bb6bc2e878a26834f7aa665dff943e..d5fd5b8faeb3559ed46c2ef53a78800ecc4fc129 100644 (file)
  * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
  */
 
-#include <linux/vmalloc.h>
 #include <linux/sched.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/file.h>
 #include <linux/swap.h>
+#include <linux/slab.h>
 #include "drm_cache.h"
+#include "drm_mem_util.h"
 #include "ttm/ttm_module.h"
 #include "ttm/ttm_bo_driver.h"
 #include "ttm/ttm_placement.h"
@@ -43,32 +44,15 @@ static int ttm_tt_swapin(struct ttm_tt *ttm);
 
 /**
  * Allocates storage for pointers to the pages that back the ttm.
- *
- * Uses kmalloc if possible. Otherwise falls back to vmalloc.
  */
 static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
-       unsigned long size = ttm->num_pages * sizeof(*ttm->pages);
-       ttm->pages = NULL;
-
-       if (size <= PAGE_SIZE)
-               ttm->pages = kzalloc(size, GFP_KERNEL);
-
-       if (!ttm->pages) {
-               ttm->pages = vmalloc_user(size);
-               if (ttm->pages)
-                       ttm->page_flags |= TTM_PAGE_FLAG_VMALLOC;
-       }
+       ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
 }
 
 static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
 {
-       if (ttm->page_flags & TTM_PAGE_FLAG_VMALLOC) {
-               vfree(ttm->pages);
-               ttm->page_flags &= ~TTM_PAGE_FLAG_VMALLOC;
-       } else {
-               kfree(ttm->pages);
-       }
+       drm_free_large(ttm->pages);
        ttm->pages = NULL;
 }
 
index 327380888b4a5f15880bbef8f17f93658d12ab89..4c54f043068ed3195595863f563a6c19c01bf7fc 100644 (file)
@@ -40,6 +40,7 @@
 #include "via_dmablit.h"
 
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 
 #define VIA_PGDN(x)         (((unsigned long)(x)) & PAGE_MASK)
 #define VIA_PGOFF(x)       (((unsigned long)(x)) & ~PAGE_MASK)
index f20b8bcbef3998cfd447eee2a3e2d8e904827dc8..30ad13344f7b96da384ffff3209dc2683e1e282a 100644 (file)
@@ -1,6 +1,6 @@
 config DRM_VMWGFX
        tristate "DRM driver for VMware Virtual GPU"
-       depends on DRM && PCI
+       depends on DRM && PCI && FB
        select FB_DEFERRED_IO
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
index 8827814d0735fbc7c3ff619b6f608476c82a4172..441e38c95a8535b863d924aea1c468872ba6d27a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
+#include <linux/slab.h>
 
 #include <linux/uaccess.h>
 
index 2370aefc86b2f6371bfca1355b2f474b2a7e00e1..c31e0be8ccea34eea7d6c0956f5a759debf324dc 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
index df474c699fb8007603c884a2e06f4b4540a20ed6..3a2b223c1da4a23e3fb346116cba22ed5278d92a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/input.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "hid-ids.h"
 
index 78286b184ace5ebe58850623b5ab670d1c995a64..bba05d0a8980e1b43aa8ec6548400b7cf8d174b8 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "hid-ids.h"
index 0c4e75573186ba08e78f7b301c20bcb749ffd80e..56f314fbd4f9e337027fe9f890171fa026e2ece2 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/poll.h>
 
index a239d20ad7a5f1e08d84500f9b02d821fa604ab3..968b04f9b796cf8208c5839fb8c1f61fbc7467ee 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/hid.h>
 
index 8a11ccddaf2e4b2b1382ee809db43cc55c82336c..88dfcf49a5d72b0f2e61d9e07557c1a2e6a8cd55 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/hid.h>
 #include "hid-ids.h"
index cab13e8c7d292c7ed93a06b8a58acc6072d50fd3..62416e6baecaf7611e9d536e64ac84e5d98bbad9 100644 (file)
@@ -53,10 +53,13 @@ static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 static int gyration_event(struct hid_device *hdev, struct hid_field *field,
                struct hid_usage *usage, __s32 value)
 {
-       struct input_dev *input = field->hidinput->input;
+
+       if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
+               return 0;
 
        if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK &&
                        (usage->hid & 0xff) == 0x82) {
+               struct input_dev *input = field->hidinput->input;
                input_event(input, usage->type, usage->code, 1);
                input_sync(input);
                input_event(input, usage->type, usage->code, 0);
index 4e6dc6e26523a22a8d109d4d71fe68d89628641b..d888f1e6794f5a48e4ddebf053d40c0826f8af9c 100644 (file)
@@ -22,6 +22,7 @@
 
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/hid.h>
 
index c174b64c381067fbf7644cd848d8a30e543558c9..0d471fc2ab82b9f1f2f4b5d35fb7456526dda763 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "hid-ids.h"
index c8718168fe426446bfdc4175f746cf5452ed4fa6..e91437c189061cf7c862a74b3b6054f369528af7 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include "usbhid/usbhid.h"
 
index edcc0c4247bb6c62f99b2bcbd22d77c90ab05577..9b24fc510712fe17023969579f5d8261a154089d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "hid-ids.h"
 
index c6d7dbc935b18b2f7445f948f2a6f5f0f0132fab..9f41e2bd84839ed085ec15cc1c88fe6266371393 100644 (file)
@@ -39,6 +39,7 @@
 #define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg)
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/hid.h>
 
index 01dd51c4986cb42bc7aa77483f5272dd219bb0fb..54d3db50605b25e3beeecbccc9c0f96facc5e6dc 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
 MODULE_DESCRIPTION("Quanta dual-touch panel");
index 203c438b016f38bd099df7f675a839438118f881..e10a7687ebf2848e15210bf7466356a060765054 100644 (file)
@@ -27,6 +27,7 @@
 /* #define DEBUG */
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/hid.h>
 #include "hid-ids.h"
index 9bf00d77d92b8f7201b910fe39ab374ba1015ae0..7502a4b2fa86170325d40318db60cca1324cf726 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "hid-ids.h"
index 2e592a06654e4061e808e406125254c2f26cf64b..90df886c5e048023f6839f8fcea1c62f00e6004f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
 MODULE_DESCRIPTION("Stantum HID multitouch panels");
index c32f32c84ac8706d2220b4be1516fe1ac60eea69..15434c814793409bd7d00a2e0a4ee20ea8302456 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/hid.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "hid-ids.h"
index 8d3b46f5d14956ea4bf60bde0f067cf8bed22105..f7700cf497213bf1e3c4857dd699e0ae55c03f96 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/hid.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "hid-ids.h"
 
index a79f0d78c6be23944e70b3d0f35f23f069ea1980..b7acceabba803fe8af9bba278872ed406ab6bff8 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/hid.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "hid-ids.h"
index d04476700b7b4eb792e41d381a61b535e0666f8f..6eadf1a9b3cca9b31e80fb231a85a56ec0393c45 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/poll.h>
 #include <linux/device.h>
 #include <linux/major.h>
+#include <linux/slab.h>
 #include <linux/hid.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
index 3e7909b0f1291af190db7ea233909c8035efb28e..17eb3ec3fbb83cf45009d60dee4ea6037ae412b4 100644 (file)
@@ -1291,6 +1291,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
                {
                        set_bit(HID_REPORTED_IDLE, &usbhid->iofl);
                        spin_unlock_irq(&usbhid->lock);
+                       if (hid->driver && hid->driver->suspend) {
+                               status = hid->driver->suspend(hid, message);
+                               if (status < 0)
+                                       return status;
+                       }
                } else {
                        usbhid_mark_busy(usbhid);
                        spin_unlock_irq(&usbhid->lock);
@@ -1298,6 +1303,11 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
                }
 
        } else {
+               if (hid->driver && hid->driver->suspend) {
+                       status = hid->driver->suspend(hid, message);
+                       if (status < 0)
+                               return status;
+               }
                spin_lock_irq(&usbhid->lock);
                set_bit(HID_REPORTED_IDLE, &usbhid->iofl);
                spin_unlock_irq(&usbhid->lock);
@@ -1352,6 +1362,11 @@ static int hid_resume(struct usb_interface *intf)
                hid_io_error(hid);
        usbhid_restart_queues(usbhid);
 
+       if (status >= 0 && hid->driver && hid->driver->resume) {
+               int ret = hid->driver->resume(hid);
+               if (ret < 0)
+                       status = ret;
+       }
        dev_dbg(&intf->dev, "resume status %d\n", status);
        return 0;
 }
@@ -1360,9 +1375,16 @@ static int hid_reset_resume(struct usb_interface *intf)
 {
        struct hid_device *hid = usb_get_intfdata(intf);
        struct usbhid_device *usbhid = hid->driver_data;
+       int status;
 
        clear_bit(HID_REPORTED_IDLE, &usbhid->iofl);
-       return hid_post_reset(intf);
+       status = hid_post_reset(intf);
+       if (status >= 0 && hid->driver && hid->driver->reset_resume) {
+               int ret = hid->driver->reset_resume(hid);
+               if (ret < 0)
+                       status = ret;
+       }
+       return status;
 }
 
 #endif /* CONFIG_PM */
index e565dbe91d97f6ac2d7d44f4ac72d2f166791712..ef381d79cfa81e969b14fcb3fd62cabde2dbb272 100644 (file)
@@ -25,6 +25,7 @@
 #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg)
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include <linux/hid.h>
index 928943c7ce9a676aaaaa62e2fdb5652aef4ed16c..1152f9b5fd444c13492de3ae976ef644fb36c9f7 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/hid.h>
+#include <linux/slab.h>
 
 #include "../hid-ids.h"
 
@@ -60,6 +61,7 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET },
+       { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
index e4595e6147b420de2a4545d45e498d5d5e886ba4..9be8e1754a0bafdc850e7af7ff0932e8b05e509b 100644 (file)
@@ -217,8 +217,8 @@ config SENSORS_ASC7621
        depends on HWMON && I2C
        help
          If you say yes here you get support for the aSC7621
-         family of SMBus sensors chip found on most Intel X48, X38, 975,
-         965 and 945 desktop boards.  Currently supported chips:
+         family of SMBus sensors chip found on most Intel X38, X48, X58,
+         945, 965 and 975 desktop boards.  Currently supported chips:
          aSC7621
          aSC7621a
 
index bfda8c80ef2473923a1ff1e38db845252b0bb16b..1e4c21fc1a890b38894e26f0b0713fef1bb0fd63 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 
 
 /* AD7414 registers */
index f97b5b356875b77857c0b69ce77d94b33a608ba7..ffc781fec18518f34c7b622ed6a384f440a64643 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "lm75.h"
 
index 74d9c5195e446ce59242be8f7b1ccb474a151dfd..fbdc7655303b71b49027828f8e125e8c6d606b5a 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/sysfs.h>
index 3471884e42d23c87724c31259498bae438ec6fe8..4086c7257f912f23608c261f1b29f68b3c04a602 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/slab.h>
 
 #define ADT7411_REG_INT_TEMP_VDD_LSB           0x03
 #define ADT7411_REG_EXT_TEMP_AIN14_LSB         0x04
index b8156b4893bb51f107b83da463a5906f01641553..2af0c7b6b4e4cd5a30adb5c202187913c340d95e 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
index 3445ce1cba81e730d2bc6c4a664587be6e644517..9e775717abb7f36ab8c7aaf8103de53264e95951 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/delay.h>
 #include <linux/log2.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
index 028284f544e306780860e97b6e5363c94b92056d..75f3fa55663d1d8a9f3cb64e0df7554f40e9addd 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/hwmon.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acpixf.h>
index 94cadc19f0c54d36885f80a21530905b99ab5bca..33cc143b2069442c5ba80611904b4c394436af9e 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
index 2d7bceeed0bc3daf10a8ae2d58d106d575107eb2..e9b7fbc5a4476b9cfdb2bd01ec58719b097cf7cb 100644 (file)
@@ -228,7 +228,7 @@ static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *
                if (err) {
                        dev_warn(dev,
                                 "Unable to access MSR 0xEE, for Tjmax, left"
-                                " at default");
+                                " at default\n");
                } else if (eax & 0x40000000) {
                        tjmax = tjmax_ee;
                }
@@ -466,7 +466,7 @@ static int __init coretemp_init(void)
                           family 6 CPU */
                        if ((c->x86 == 0x6) && (c->x86_model > 0xf))
                                printk(KERN_WARNING DRVNAME ": Unknown CPU "
-                                       "model %x\n", c->x86_model);
+                                       "model 0x%x\n", c->x86_model);
                        continue;
                }
 
index 277398f9c93826dddb5233d7d4765c0f515011cc..bad2cf3ef4a448aa76a72033b527647c6434f9d3 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/f75375s.h>
+#include <linux/slab.h>
 
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END };
index 27d7f72a5f11a254ae5c2a9a6e35578683e594a7..e880e2c3871d0e2098913c7b130c3a35de7e4f65 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/log2.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #define DRVNAME "i5k_amb"
 
index 405d3fb5d76f9e90aa9115b56eb4676c4e1b03bb..eaee546af19a1c519758783ee66217a1d8bae46d 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kdev_t.h>
 #include <linux/spinlock.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/platform_device.h>
 #include <linux/math64.h>
index a36363312f2ff5116ef5557ae19fe7176455b68a..06d4eafcf76b231fdc74e0418341e496387b78d9 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/jiffies.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #define REFRESH_INTERVAL       (2 * HZ)
 #define DRVNAME                        "ibmpex"
index ab8a5d3c769048a1a15635c09648740bad64e9ef..fd108cfc05c7c8cad39b960b484e377ded238b5a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/mutex.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 
 #define DRVNAME                "lm70"
index c5f39ba103c0341d5a0207ec805d0b38c9f689e5..4d1b76bc81486b64dc6963d8ee415c2608c0fb82 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
index 9ac497271adfa06e160de4811fc8450b0ecf153b..12a54aa297760b1c6913a3fe772ab3dc7cb0c3ee 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 #define MAX1111_TX_BUF_SIZE    1
 #define MAX1111_RX_BUF_SIZE    2
index 883fa8197da42845086fb180e9196afb7e825e0e..ce3c7bc81814e3d5198d3d703824b288336c8909 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/hwmon.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
 
index 864a371f6eb98443f0565b1d1263cb66a370e152..6b2d8ae64fe11f870797dd34ca8ace6d8493e6d9 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/err.h>
 #include <linux/sht15.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 
 #define SHT15_MEASURE_TEMP     3
index 9de81a4c15a2127b774766bda5244bf519d750cf..612807d9715533b3f03afcdf6738fb79767ee55e 100644 (file)
@@ -1294,7 +1294,7 @@ static int watchdog_close(struct inode *inode, struct file *filp)
 static ssize_t watchdog_write(struct file *filp, const char __user *buf,
        size_t count, loff_t *offset)
 {
-       size_t ret;
+       ssize_t ret;
        struct w83793_data *data = filp->private_data;
 
        if (count) {
index c16e9e74c356df56fa681104415fda5591446100..97b1f834a4714b540fd95352271bb253ef130c9c 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/auxadc.h>
index e8d568c3fb09ac2c6aefadd8e84c3aadf775a955..a39e6cff86e7ad8d64b5b786e7b5452f9290a458 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
index 6b6bd06202b20fff3db405f077bd98aab2638260..5eebf562ff31b9094fffa7c0300003223382affe 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/i2c.h>
index d0dc970d7370a8f6116f7222cb605fbbf2ece88b..2fbef27b6cd60f6af5245e41fd42591b3d3f12ca 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 MODULE_LICENSE("GPL");
index fe3fb567317d08939345fa10ec960cc43fa53335..f1e14dd590c977fdbb7e128cd0dfc5285f5379dd 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/timer.h>
index c89687a10835538307212949317042f40042129c..4523364e67221d3930cb3fd5c6ceb65b7fab7d4e 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 
index 3e72b69aa7f8a39ac8dc752a45048935d33d78b5..b664ed8bbdb3883ce3fde9bfe4f9dafd79a966a1 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /*
  * Registers offset
index 448b4bf35eb7f3cf9788c1638f5ecc0b11676d7f..612255614a66d763527c32cf6610a4fb016bb1b3 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
index 32104eac8d3db3d61e12907558262f1fe4ecffed..c21077d248af98f342a37219ecfa19b580e65c32 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/i2c-gpio.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 
 #include <asm/gpio.h>
index 87ecace415da39ac49449c25acdd3e377c3f5a8b..ce87a902c94dbaf1081a28fa7fb7c397e3043307 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/completion.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #define SMCR           0x00
 #define SMCR_START     (1 << 0)
index 32375bddae7df6aa4fca67d17a045c00b3c9f9de..f7e27b70237596bd0c03f62f07072514815d227c 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/sched.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <mach/irqs.h>
 #include <mach/hardware.h>
index c016f7a2c5fc2712433dbd83ec7d1c6dd1d48f3b..5d8aed5ec21bb85863743e4855d450403074cf64 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>     /* Pick up IXP2000-specific bits */
 #include <mach/gpio.h>
index 78a15af3294231f1d1403ab593dc704c27ef1f06..f1321f7637891d09846a1c1f988856c68845c81c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/of_platform.h>
 #include <linux/of_i2c.h>
+#include <linux/slab.h>
 
 #include <linux/io.h>
 #include <linux/fsl_devices.h>
index ed387ffa47307b1a28b90f9646e4d8dd3b6262c9..3623a44990849987bc872480122bc1d987e2b004 100644 (file)
@@ -10,6 +10,7 @@
  * or implied.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/i2c.h>
index 4a700587ef18176cf5877ee1506cf248d100a00f..4a48dd4ef7870cb7d9789ee34d12f13ca6f5b3db 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/delay.h>
 #include <linux/dmi.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 MODULE_LICENSE("GPL");
index a15f731fa451577edb92c7cb0354c791af450bcd..a4f8d33fa389ac95eb2e79e7969428565d150e31 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/err.h>
index 0dabe643ec5116faa9140505c6cc464b03bbf8e0..b4ed4ca802ed97d9f829adcc60b850548582f50f 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/wait.h>
 #include <linux/i2c-ocores.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 struct ocores_i2c {
index 60375504fa49b733a2f992ce2c7c34a27c56a217..a2481f40ea1c92312282a21a8998aadf60578b81 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #include <linux/io.h>
index c7c237537f8147d8ff72cd8d7b5eee692cbb8fbe..6bd0f19cd451c69a38cbd48b7b7022b280dc6836 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /* I2C controller revisions */
 #define OMAP_I2C_REV_2                 0x20
index 220fca7f23a6751e2f591df26ffb4b22d841b6d8..846583ed476352168bd4bde779adb224cad08470 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 #include <linux/i2c-smbus.h>
+#include <linux/slab.h>
 #include "i2c-parport.h"
 
 /* ----- Device list ------------------------------------------------------ */
index 0d20ff46a518b837533078dc73dc413aaae3fea8..d3d4a4b43a1d015527f565027b761291711d8f24 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/sched.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 static struct pci_driver pasemi_smb_driver;
index 9532dee6b580b8c088bffdf04fbdcd953512451a..247103372a066ae35fd418089f8ecaa076497211 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/i2c.h>
index 90ffbf6f9d4f23149c5a68f70f5fa00f21fd93be..14d249f5ed3f3db236b6c8664df152fc583a5003 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
index 1d8c98613fa057c88f75b4a7bd793348c60b8da8..d27072b2249ff5d3236c2ee1da0469e1d694616a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
index 365e0becaf121f7261cbc31ea2f19596415646d6..388cbdc96db7306280b5d4ab6fcc99871e77b7ca 100644 (file)
@@ -33,6 +33,7 @@ struct acpi_smbus_cmi {
        u8 cap_info:1;
        u8 cap_read:1;
        u8 cap_write:1;
+       struct smbus_methods_t *methods;
 };
 
 static const struct smbus_methods_t smbus_methods = {
@@ -41,10 +42,19 @@ static const struct smbus_methods_t smbus_methods = {
        .mt_sbw  = "_SBW",
 };
 
+/* Some IBM BIOSes omit the leading underscore */
+static const struct smbus_methods_t ibm_smbus_methods = {
+       .mt_info = "SBI_",
+       .mt_sbr  = "SBR_",
+       .mt_sbw  = "SBW_",
+};
+
 static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
-       {"SMBUS01", 0},
+       {"SMBUS01", (kernel_ulong_t)&smbus_methods},
+       {ACPI_SMBUS_IBM_HID, (kernel_ulong_t)&ibm_smbus_methods},
        {"", 0}
 };
+MODULE_DEVICE_TABLE(acpi, acpi_smbus_cmi_ids);
 
 #define ACPI_SMBUS_STATUS_OK                   0x00
 #define ACPI_SMBUS_STATUS_FAIL                 0x07
@@ -150,11 +160,11 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
 
        if (read_write == I2C_SMBUS_READ) {
                protocol |= ACPI_SMBUS_PRTCL_READ;
-               method = smbus_methods.mt_sbr;
+               method = smbus_cmi->methods->mt_sbr;
                input.count = 3;
        } else {
                protocol |= ACPI_SMBUS_PRTCL_WRITE;
-               method = smbus_methods.mt_sbw;
+               method = smbus_cmi->methods->mt_sbw;
                input.count = 5;
        }
 
@@ -290,13 +300,13 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
        union acpi_object *obj;
        acpi_status status;
 
-       if (!strcmp(name, smbus_methods.mt_info)) {
+       if (!strcmp(name, smbus_cmi->methods->mt_info)) {
                status = acpi_evaluate_object(smbus_cmi->handle,
-                                       smbus_methods.mt_info,
+                                       smbus_cmi->methods->mt_info,
                                        NULL, &buffer);
                if (ACPI_FAILURE(status)) {
                        ACPI_ERROR((AE_INFO, "Evaluating %s: %i",
-                                  smbus_methods.mt_info, status));
+                                  smbus_cmi->methods->mt_info, status));
                        return -EIO;
                }
 
@@ -319,9 +329,9 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
 
                kfree(buffer.pointer);
                smbus_cmi->cap_info = 1;
-       } else if (!strcmp(name, smbus_methods.mt_sbr))
+       } else if (!strcmp(name, smbus_cmi->methods->mt_sbr))
                smbus_cmi->cap_read = 1;
-       else if (!strcmp(name, smbus_methods.mt_sbw))
+       else if (!strcmp(name, smbus_cmi->methods->mt_sbw))
                smbus_cmi->cap_write = 1;
        else
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n",
@@ -349,6 +359,7 @@ static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level,
 static int acpi_smbus_cmi_add(struct acpi_device *device)
 {
        struct acpi_smbus_cmi *smbus_cmi;
+       const struct acpi_device_id *id;
 
        smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL);
        if (!smbus_cmi)
@@ -362,6 +373,11 @@ static int acpi_smbus_cmi_add(struct acpi_device *device)
        smbus_cmi->cap_read = 0;
        smbus_cmi->cap_write = 0;
 
+       for (id = acpi_smbus_cmi_ids; id->id[0]; id++)
+               if (!strcmp(id->id, acpi_device_hid(device)))
+                       smbus_cmi->methods =
+                               (struct smbus_methods_t *) id->driver_data;
+
        acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1,
                            acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL);
 
index ccc46418ef7f16b2409c28cdf7f7f8ebdb6796d4..ffb405d7c6f24caaf61a9837e66de0b4f417d490 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /* Transmit operation:                                                      */
 /*                                                                          */
index 6407f47bda82db92b5ba2f2926851f774a938e91..78b06107342cde80bdb33c4b25ecdc97dfebb38e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
index d2728a28a8dba926e563957ad6339db653a7c632..1f5b38be73bc41277f1ab6176dc89f208b934ba9 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /* the name of this kernel module */
 #define NAME "stu300"
index b5b1bbf37d3c5bafc2979860c8ce33d7a4aa69bf..d03b04002f0d3cc55cf25d2aab551a9595a116dc 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 /* include interfaces to usb layer */
index 70de821634631a3e5108221ec6d1753aab0d654f..5c473833d948e3a4e5428f0fb8fb33f2ad894dfc 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/i2c-algo-bit.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index f0ef8da6c554556c0e1c35ef23b655398f49b912..a9c419e075a511589233147d1b229d0842933e4e 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/wait.h>
 #include <linux/i2c-xiic.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "xiic-i2c"
 
index cf994bd01d9c2ef34cf0f964578d4c68db12e21a..684395b6f3e2dc5af4343074017f47c27ad9f564 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include <linux/scx200.h>
index a26a34a06641bde2cf2320d5e054ebbdbe493448..7e6a63b571650b1f100c4707309f31de1af415bb 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/kernel.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/rwsem.h>
 
 #include "i2c-core.h"
index 7a8201ed21816a0fe9df1e6ca0472b710c5ed289..a24e0bfe9201a87a7012b1f42791d925aaf5b76f 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/workqueue.h>
 #include <linux/i2c.h>
 #include <linux/i2c-smbus.h>
+#include <linux/slab.h>
 
 struct i2c_smbus_alert {
        unsigned int            alert_edge_triggered:1;
index b885c1d548f505f05048dadebd290e908c8aaeba..45163693f7374c2d47e3205ae816a976ee0951a6 100644 (file)
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ide.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
index 5cb01e5c323c993c08d0226d72c16815310febc7..c26c11905ffe0063eec29b07a236b5e24a0922c9 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <acpi/acpi.h>
 #include <linux/ide.h>
 #include <linux/pci.h>
index eb2181a6a11cbe9dfd825daae8c03a73aa85fc19..a4046e94158d0c0b4b052459014bd10f057d0843 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/delay.h>
 #include <linux/ide.h>
 #include <linux/scatterlist.h>
+#include <linux/gfp.h>
 
 #include <scsi/scsi.h>
 
index df3df0041eb61b8b0050703bbeb5585500bbc8fd..02712bf045c1bdece00d845d35662fd065e12c41 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/kernel.h>
 #include <linux/cdrom.h>
+#include <linux/gfp.h>
 #include <linux/ide.h>
 #include <scsi/scsi.h>
 
index c6935c78757cfbfaacb06fb820223dc6fd19bec8..9e98122f646e3190c85dc3d2813102f5a00f49ec 100644 (file)
@@ -1,5 +1,6 @@
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/ide.h>
 
 DEFINE_MUTEX(ide_setting_mtx);
index 60b0590ccc9cf16be3128ba62e8a4aee6df5f37c..f9bbd904eae72651d65e33b4dba06ec4f95f69ee 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/kernel.h>
 #include <linux/ide.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 
 #include "ide-disk.h"
index ee58c88dee5a61f51d437d1f618fd89745144785..2c17e3fb43e32a73a2cfa37d936012d245ef610a 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/ide.h>
 #include <linux/scatterlist.h>
index efd907623469fbc92a5e372fda19a4d6e260574d..4713bdca20b6acb447362d8ae622a5c5e276c5fd 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/major.h>
 #include <linux/errno.h>
 #include <linux/genhd.h>
-#include <linux/slab.h>
 #include <linux/cdrom.h>
 #include <linux/ide.h>
 #include <linux/hdreg.h>
index 753241429c26b4e9b370c72e388a79990a780028..c32d83996ae1dea17464b5ae9a772c6d0aec06c4 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/ide.h>
 #include <linux/hdreg.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
 #define IDE_DISK_MINORS                (1 << PARTN_BITS)
index 6e7ae2b6cfc64c018131349e4474f04506b6aa36..9965ecd5078c63e37aa4fb34d1b7df722fd22d63 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/hdreg.h>
 #include <linux/ide.h>
+#include <linux/slab.h>
 
 static const struct ide_ioctl_devset ide_ioctl_settings[] = {
 { HDIO_GET_32BIT,       HDIO_SET_32BIT,        &ide_devset_io_32bit  },
index a914023d6d035d9e530178ff2422a7bf386cc2cd..88a380c5a4708bd9f396a52da5dd47128137f74f 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/ide.h>
 #include <linux/jiffies.h>
 #include <linux/blkdev.h>
index ad7be2669dcb9020bc5b91612079d80f21fd6869..1c08311b0a0e0566076b428c47ff8fbf3bebb239 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/ide.h>
 
 int generic_ide_suspend(struct device *dev, pm_message_t mesg)
index fbedd35feb449194e85fe78ee110ccb5ba101e9f..4c3d1bfec0c5b450fbbe68014e1c15fe9e29c454 100644 (file)
@@ -695,14 +695,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
        if (irqd)
                disable_irq(hwif->irq);
 
-       rc = ide_port_wait_ready(hwif);
-       if (rc == -ENODEV) {
-               printk(KERN_INFO "%s: no devices on the port\n", hwif->name);
-               goto out;
-       } else if (rc == -EBUSY)
-               printk(KERN_ERR "%s: not ready before the probe\n", hwif->name);
-       else
-               rc = -ENODEV;
+       if (ide_port_wait_ready(hwif) == -EBUSY)
+               printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
 
        /*
         * Second drive should only exist if first drive was found,
@@ -713,7 +707,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
                if (drive->dev_flags & IDE_DFLAG_PRESENT)
                        rc = 0;
        }
-out:
+
        /*
         * Use cached IRQ number. It might be (and is...) changed by probe
         * code above
index 017c09540c2f70b416af3a39eaf122a5a49287f1..a3133d7b2a0cf91b259eb3fb19db091b4c88bd86 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ctype.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 16d056939f9f313119c5a0c51da62456d85669aa..3cb9c4e056ffdf0c7d2952c9c160051af7f910ab 100644 (file)
@@ -52,7 +52,6 @@
 #include <linux/major.h>
 #include <linux/errno.h>
 #include <linux/genhd.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/ide.h>
index b2709c7334852b69badfd0f0314b02b1f020d8b5..2e3169f2acda26b50e16ac56232dd5e8b5e8ca24 100644 (file)
@@ -61,6 +61,7 @@
 
 #include <linux/types.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/ide.h>
 #include <linux/init.h>
index 850ee452e9bb34db31d833cab4a9f66674b92658..159955d16c475e69314c12efa4a19166cfec4eaf 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/adb.h>
 #include <linux/pmu.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include <asm/prom.h>
 #include <asm/io.h>
index 00f54248f41f0d76fbf62e2c791123a0bf17dfe9..48d976aad7abaf685754ea647280c21ff4c99c38 100644 (file)
@@ -3,7 +3,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/errno.h>
 #include <linux/ide.h>
index 134f1fd138665e01d3d7a3bb84ae431104f87db4..356b9b504ffd421c4088316694f7392e34b5ed42 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ide.h>
index e65d010b708db1fcff3182d7b87a1ed1e7214f06..101f4002238601eb6be0048236df78f6ca667380 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/ide.h>
@@ -110,7 +111,6 @@ struct via82cxxx_dev
 {
        struct via_isa_bridge *via_config;
        unsigned int via_80w;
-       u8 cached_device[2];
 };
 
 /**
@@ -403,66 +403,10 @@ static const struct ide_port_ops via_port_ops = {
        .cable_detect           = via82cxxx_cable_detect,
 };
 
-static void via_write_devctl(ide_hwif_t *hwif, u8 ctl)
-{
-       struct via82cxxx_dev *vdev = hwif->host->host_priv;
-
-       outb(ctl, hwif->io_ports.ctl_addr);
-       outb(vdev->cached_device[hwif->channel], hwif->io_ports.device_addr);
-}
-
-static void __via_dev_select(ide_drive_t *drive, u8 select)
-{
-       ide_hwif_t *hwif = drive->hwif;
-       struct via82cxxx_dev *vdev = hwif->host->host_priv;
-
-       outb(select, hwif->io_ports.device_addr);
-       vdev->cached_device[hwif->channel] = select;
-}
-
-static void via_dev_select(ide_drive_t *drive)
-{
-       __via_dev_select(drive, drive->select | ATA_DEVICE_OBS);
-}
-
-static void via_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
-{
-       ide_hwif_t *hwif = drive->hwif;
-       struct ide_io_ports *io_ports = &hwif->io_ports;
-
-       if (valid & IDE_VALID_FEATURE)
-               outb(tf->feature, io_ports->feature_addr);
-       if (valid & IDE_VALID_NSECT)
-               outb(tf->nsect, io_ports->nsect_addr);
-       if (valid & IDE_VALID_LBAL)
-               outb(tf->lbal, io_ports->lbal_addr);
-       if (valid & IDE_VALID_LBAM)
-               outb(tf->lbam, io_ports->lbam_addr);
-       if (valid & IDE_VALID_LBAH)
-               outb(tf->lbah, io_ports->lbah_addr);
-       if (valid & IDE_VALID_DEVICE)
-               __via_dev_select(drive, tf->device);
-}
-
-const struct ide_tp_ops via_tp_ops = {
-       .exec_command           = ide_exec_command,
-       .read_status            = ide_read_status,
-       .read_altstatus         = ide_read_altstatus,
-       .write_devctl           = via_write_devctl,
-
-       .dev_select             = via_dev_select,
-       .tf_load                = via_tf_load,
-       .tf_read                = ide_tf_read,
-
-       .input_data             = ide_input_data,
-       .output_data            = ide_output_data,
-};
-
 static const struct ide_port_info via82cxxx_chipset __devinitdata = {
        .name           = DRV_NAME,
        .init_chipset   = init_chipset_via82cxxx,
        .enablebits     = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
-       .tp_ops         = &via_tp_ops,
        .port_ops       = &via_port_ops,
        .host_flags     = IDE_HFLAG_PIO_NO_BLACKLIST |
                          IDE_HFLAG_POST_SET_MODE |
index dd253002cd50c973bd8e1ffcc5041415cf0abe1b..15341fc1c68b0600e769141562bf08897c1718fe 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/notifier.h>
 #include <linux/cpumask.h>
index 8e7e3344c4b3fdfdd54ae4591843c4313fb93d7a..d178699b194a054381d5e37067f78594ae5ef480 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/scatterlist.h>
 
index c88696a6cf8aa8a5d79b726f3b22ac3790837f67..4565cb5d3d1a7e3c808c6945b899d165a321bbee 100644 (file)
@@ -56,7 +56,6 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
-#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
index abbb06996f9e008c0a5c5957a18b46d10ef032d7..0b926e45afe2f0b64824d36b6acfbb50ed0d3afa 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/mutex.h>
 #include <linux/inetdevice.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <net/arp.h>
 #include <net/neighbour.h>
index 764787ebe8d80f661ba9e7edf0b0e98c38502bfc..fc73d6ac11b62ee3bd21d9e58f1bae7ed564e216 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/random.h>
 #include <linux/rbtree.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/workqueue.h>
 #include <linux/kdev_t.h>
index 875e34e0b235d93a68b44290fbc7f1417104773c..7794249430ca50cff387e44e63931deb60151642 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/random.h>
 #include <linux/idr.h>
 #include <linux/inetdevice.h>
+#include <linux/slab.h>
 
 #include <net/tcp.h>
 #include <net/ipv6.h>
index 0f89909abce98f1e68d36289cb47642126bf4e2e..bfead5bc25f6e14efcc09c4e5be51050785acb53 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/completion.h>
+#include <linux/slab.h>
 
 #include <rdma/iw_cm.h>
 #include <rdma/ib_addr.h>
index e351b15485356b5489c1e2e668bcd7eb19bfb8c0..1df1194aeba420d7288e47a4225dde559259f563 100644 (file)
@@ -34,6 +34,7 @@
  *
  */
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <rdma/ib_cache.h>
 
 #include "mad_priv.h"
index 4e0f2829e0e5f11fd0bade45cfc4bef18ccf4026..f37878c9c06eb43812b022ba72a034418a1a238e 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "mad_priv.h"
 #include "mad_rmpp.h"
 
index 8d82ba17135366317ba2d3e856c78c4cfb97829a..a519801dcfb758f785a885ce49259fa7b1a01f8d 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/bitops.h>
 #include <linux/random.h>
 
index 1558bb7fc74dd6c2ce19da6d9c277292c0ba0e7b..f901957abc8b54ce68815eb19a26129a0e6b8867 100644 (file)
@@ -461,6 +461,7 @@ alloc_group_attrs(ssize_t (*show)(struct ib_port *,
                element->attr.attr.mode  = S_IRUGO;
                element->attr.show       = show;
                element->index           = i;
+               sysfs_attr_init(&element->attr.attr);
 
                tab_attr[i] = &element->attr.attr;
        }
index 017d6e24448fa83f278826343cb6609f025d0df0..512b1c43460c2d40dfb5c410996dff1905ec56df 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/cdev.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index b2e16c332d5b038703e083057339da6cd0434749..46185084121e28b7cd233ccd9df581d4579106d0 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/miscdevice.h>
+#include <linux/slab.h>
 
 #include <rdma/rdma_user_cm.h>
 #include <rdma/ib_marshall.h>
index 4f906f0614f0f10826e35cb5b447774f70de3c29..415e186eee320e5dc0295f4d7d828ceba3f59338 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/sched.h>
 #include <linux/hugetlb.h>
 #include <linux/dma-attrs.h>
+#include <linux/slab.h>
 
 #include "uverbs.h"
 
index 04b585e86cb210f9975c34104131d553de404979..e7db054fb1c888900c9e9a1df4e136e6cd7910d1 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/compat.h>
 #include <linux/sched.h>
 #include <linux/semaphore.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index f71cf138d674109c6d3f10381f64d4ffcb8c5358..6fcfbeb24a234a419ec9313c956c7c4ba581bcf6 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/file.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index d805cf365c8d3218d81c024b50dff58d6c78f6c6..fb35262544260144c52cd7c583a1750cebd730e4 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/file.h>
 #include <linux/cdev.h>
 #include <linux/anon_inodes.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index c61fd2b4a5563c62d18393a479f29bd72c3eae8e..dc85d777578ed087979b94829c886919c03c008a 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/tcp.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index e9110163aeffc65c79858b5fff83d710293e2136..d4f5f5d42e90e36bb417b9f613933f4c5acf0ee1 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/bitmap.h>
 
 #include "c2.h"
index 75b93e9b88100638a10c3d59b77e51a59ad420be..95f58ab1e0b881d7913bc97c9f9ae0e2ac15ad43 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  *
  */
+#include <linux/slab.h>
+
 #include "c2.h"
 #include "c2_wr.h"
 #include "c2_vq.h"
index f5c45b194f534df104bf4be40c39c302b9788e5e..f7b0fc23f41365242300ed5fc6b66086062f2fdb 100644 (file)
@@ -35,6 +35,8 @@
  * SOFTWARE.
  *
  */
+#include <linux/gfp.h>
+
 #include "c2.h"
 #include "c2_vq.h"
 #include "c2_status.h"
index b506fe22b4d4d4f3b21cc309a66f7b6a867c3d1f..119c4f3d9791a81c44164737f5c9f147b5455139 100644 (file)
@@ -30,6 +30,8 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#include <linux/slab.h>
+
 #include "c2.h"
 #include "c2_vq.h"
 
index 00c709926c8dc7a9b749e9c893bb69aad610d1cd..161f2a285351a7c41ad5352318d63a91ec775197 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 
 #include "c2.h"
index ad723bd8bf498090560c72bc78a1a06dc72e9730..c47f618d12e89084b4ea2945ee02b03a344373c4 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/if_arp.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index ad518868df77642608281fd11d4c093c11c02711..d8f4bb8bf42e71f332abf85dd2cf846441455815 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include "c2.h"
 #include "c2_vq.h"
index dd05c48356425f30e2109cd4b17ba484c2919a0d..78c4bcc6ef608b131bfc04cf07c0da93bced375f 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/mm.h>
 #include <linux/inet.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include <linux/route.h>
 
index a8d24d53f3070466893fe47cdfc7ee7985c215a3..8bca6b4ec9af2003e40cbb48767c0f1106646e76 100644 (file)
@@ -31,6 +31,7 @@
  */
 #ifdef DEBUG
 #include <linux/types.h>
+#include <linux/slab.h>
 #include "common.h"
 #include "cxgb3_ioctl.h"
 #include "cxio_hal.h"
index a28e862f2d6881d9eec49fa8764c5539d4d418d0..35f286f1ad1e9280e261444b68a46d21e7350504 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 
 #include "cxio_resource.h"
index d94388b81a4005b1e5d0dab5bdb780910c1d3665..4fef032962761062c23bdb206301cea1d51dad6d 100644 (file)
@@ -31,6 +31,7 @@
  */
 #include <linux/module.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/skbuff.h>
 #include <linux/timer.h>
index 743c5d8b880686a11357e5ed39c50a60ffde91a2..6afc89e7572c8d880db196cc34402d3a168e39d8 100644 (file)
@@ -29,7 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/mman.h>
 #include <net/sock.h>
 #include "iwch_provider.h"
index e1ec65ebb016e4c7cfbfe81ca1e2095ba614ce08..5c36ee2809acf52f8f212483dfb81e5649357baf 100644 (file)
@@ -29,6 +29,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include <rdma/iw_cm.h>
index 47b35c6608d2d284d5706cc3cad521bf8a9a5ccc..19b1c4a62a2366c4018ca23ec9d5462ed8780340 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/ethtool.h>
 #include <linux/rtnetlink.h>
 #include <linux/inetdevice.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index b4d893de365059d671546d0c9f2af9f28fad1444..ae47bfd22bd525eb4d4ff2b317790a3b408cc635 100644 (file)
@@ -30,6 +30,7 @@
  * SOFTWARE.
  */
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include "iwch_provider.h"
 #include "iwch.h"
 #include "iwch_cm.h"
index 56735ea2fc576746ebb22350e8c3b18009279f79..465926319f3dc2a85d078c2d9f33e0b02e7d3e49 100644 (file)
@@ -41,6 +41,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_tools.h"
 #include "ehca_iverbs.h"
 #include "hcp_if.h"
index 97e4b231cdc42b66e7e52c4554a6fa035dd370ca..d9b0ebcb67d7371946f8a644d26066e3a175df28 100644 (file)
@@ -43,6 +43,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_iverbs.h"
 #include "ehca_classes.h"
 #include "ehca_irq.h"
index 8b92f85d4dd0eef382420e9d6dd69d7e1c594af1..73edc3668663a2cb8f2b987db1c8945016df4714 100644 (file)
@@ -39,6 +39,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/gfp.h>
+
 #include "ehca_tools.h"
 #include "ehca_iverbs.h"
 #include "hcp_if.h"
index b2b6fea2b141f3b7c933d2fb551374623689a09d..07cae552cafba60be9efb413b210d6e1ae767243 100644 (file)
@@ -41,6 +41,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_classes.h"
 #include "ehca_irq.h"
 #include "ehca_iverbs.h"
index 7550a534005c9a6d002a8b77284125c9522d6ccd..31a68b9c52d0c96f4739447f86918a5c4ed020fc 100644 (file)
@@ -40,6 +40,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
 #include <rdma/ib_umem.h>
 
 #include "ehca_iverbs.h"
index 2fe554855fa5bbdef4ee1ff0aa63982231393094..351577a6670a5be1c24cf61416793f763aac3510 100644 (file)
@@ -38,6 +38,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_tools.h"
 #include "ehca_iverbs.h"
 
index b105f664d3efb24db69d304cca6bb24c29fcf7b2..47d388ec1cdebe4555eedf54f957efbb6f345222 100644 (file)
@@ -43,6 +43,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_classes.h"
 #include "ehca_tools.h"
 #include "ehca_qes.h"
index f1565cae8ec6c6be02c56185121f2f913ceaff2e..45ee89b65c23fbf57350e8a5cb04840180bd2035 100644 (file)
@@ -40,6 +40,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_classes.h"
 #include "ehca_iverbs.h"
 #include "ehca_mrmw.h"
index 1227c593627a62b5a1e27a237a63175c4038dfe0..1596e30853443991c15c2847657935d72b5357db 100644 (file)
@@ -38,6 +38,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include "ehca_tools.h"
 #include "ipz_pt_fn.h"
 #include "ehca_classes.h"
index d385e4168c975993e55c7667ac034b30c7ecd882..0416c6c0e126f3dd8728fe2518b0d1ce018ce6dc 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "ipath_verbs.h"
index e90a0ea538a05b75b3fe0ca06edcda968bb4d364..644c2c74e054dce8a50fa30ac64ecfd2d59654e5 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/scatterlist.h>
+#include <linux/gfp.h>
 #include <rdma/ib_verbs.h>
 
 #include "ipath_verbs.h"
index d2787fe80304e65facbd6fb90e6df953c009445a..6302626d17f005536229657b465c1be3b76c01fd 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/netdevice.h>
 #include <linux/vmalloc.h>
 #include <linux/bitmap.h>
+#include <linux/slab.h>
 
 #include "ipath_kernel.h"
 #include "ipath_verbs.h"
index 73933a41ce840ad4a3079f69259b7397fa654c67..9c5c66d16a2316fc58db3d3aa3e82b85d941b36a 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/cdev.h>
 #include <linux/swap.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/jiffies.h>
index 100da8542bbaecf5d153a34b4d75bddc8ab61de9..2fca70836daea5d4f24f16ecc65d32f1a4249099 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/pagemap.h>
 #include <linux/init.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 
 #include "ipath_kernel.h"
 
index 077879c0bdb51a63f19326b21cf6f5350f43f6fe..776938299e4c9e91bd5a075b513773a8bae74066 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/pci.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "ipath_kernel.h"
index b28865faf435179078a1aed86e16c38326da10c8..e73274229404f39d7ab70ce056f3f2b125b8f9a3 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/module.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
 #include <asm/pgtable.h>
index 9d343b7c2f3b64b7729114a98773accab45baec8..e346d3890a0e5fbefd179fd8133cc3b4590dc8ec 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include <rdma/ib_umem.h>
 #include <rdma/ib_pack.h>
 #include <rdma/ib_smi.h>
index cb2d3ef2ae12426a2ee3da2937118de3145c0c61..0857a9c3cd3d3ca4e731091b5b9ef129cf5024f1 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/err.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "ipath_verbs.h"
index 4b06985908507a355ad19dbdd115fb27d1ed7986..98ac18ec977e4099f9ee154e8a53353d6206751d 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/gfp.h>
 
 #include "ipath_kernel.h"
 #include "ipath_verbs.h"
index e3d80ca84c1afb6edd42eece87eb9aecb4560c18..386e2c717c53b4b03707c8a21fd027cf8121199f 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "ipath_verbs.h"
index eb7d59abd12d283dcb8c6b307fc266870520dbe7..5e86d73eba2af2af953257f6d03d873324a81aa8 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/mm.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include "ipath_kernel.h"
index 9289ab4b0ae86dd0a37da2d7334538d627d090a5..559f39be0dcc16a5b0e8ceff53005d30060c2303 100644 (file)
@@ -34,6 +34,7 @@
 #include <rdma/ib_mad.h>
 #include <rdma/ib_user_verbs.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/utsname.h>
 #include <linux/rculist.h>
 
index 6923e1d986da49b95e9c8e39a3a8955f2a2ffac9..6216ea9238531a9a0c10a6a0dd10a43740db4a12 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/rculist.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "ipath_verbs.h"
 
index c75ac9463e20e477a78383debc290baa8d88a319..11a236f8d884a4902b6243139eddd6da6c98c76a 100644 (file)
@@ -30,6 +30,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "mlx4_ib.h"
 
 struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
index de5263beab4a721a8c261b8c8403996bb54e26b8..cc2ddd29ac57dc62e5f4f0d88eeb6bc64ee40c4c 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/mlx4/cq.h>
 #include <linux/mlx4/qp.h>
+#include <linux/slab.h>
 
 #include "mlx4_ib.h"
 #include "user.h"
index 19e68ab6616897b5ef8281eb8bbdff8c9ecd46c4..f38d5b1189273d8fb320374d06c3c3f044d7cec2 100644 (file)
@@ -34,6 +34,7 @@
 #include <rdma/ib_smi.h>
 
 #include <linux/mlx4/cmd.h>
+#include <linux/gfp.h>
 
 #include "mlx4_ib.h"
 
index e596537ff3533cd53b607eeb5d2e5795cca49c90..01f2a3f93355c3e6a26004f84ea5a28dce248114 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 
 #include <rdma/ib_smi.h>
index 8f3666b20ea43991d2f6f742d70161490b2851c8..56147b28a23a69c86366c74b98b0834b3d15a9e2 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "mlx4_ib.h"
 
 static u32 convert_access(int acc)
index ae75389937d6b1fe9a8100d8d6cbc406fa6b2cf1..5643f4a8ffefd2c983ed603615871dfe2ff55974 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 #include <rdma/ib_cache.h>
 #include <rdma/ib_pack.h>
index cf8085bcbd6d294927f2c2cc44c048bf5c41da40..818b7ecace5e3c812b7f7500ba44a13ac46ef397 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <linux/mlx4/qp.h>
 #include <linux/mlx4/srq.h>
+#include <linux/slab.h>
 
 #include "mlx4_ib.h"
 #include "user.h"
index 8c2ed994d5401cc7fa86844ee7e1eff2ab927c63..3603ae89b60692149c4fc63bf4ac64d71eb30868 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/pci.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <rdma/ib_mad.h>
 
index d9f4735c2b3766dee2f3e5907463415efa12f90d..18ee3fa4b88ccec241b0d4b866341a6b7e086af3 100644 (file)
@@ -34,6 +34,7 @@
  * SOFTWARE.
  */
 
+#include <linux/gfp.h>
 #include <linux/hardirq.h>
 #include <linux/sched.h>
 
index 8c31fa36e95e7102a96ecf9ca6b31988b0f99640..9388164b6053c71c785b1bfbc67f07e0138600de 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "mthca_dev.h"
 #include "mthca_cmd.h"
index b01b28987874e9145d241310347e4691695c2716..5eee6665919a46480e4d0023eb3a53f228acf9c0 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/errno.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/gfp.h>
 
 #include "mthca_dev.h"
 #include "mthca_config_reg.h"
index d4c81053e439fe0fa46bae57e42e92738792b9e6..515790a606e6e56369e57840e39cadc2a2ee166d 100644 (file)
@@ -31,7 +31,7 @@
  */
 
 #include <linux/string.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 
 #include "mthca_dev.h"
 #include "mthca_cmd.h"
index 1f7d1a29d2a82250182bb5a91a5902b64eda0379..8c2a83732b5d53ca1a4f019a1303de335233ec9f 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 
index bcf7a401482015f3b5c09afdc4177bab3d10577f..f080a784bc795da07fa380a7d72cc0aef900e0f6 100644 (file)
@@ -39,6 +39,7 @@
 #include <rdma/ib_user_verbs.h>
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 
 #include "mthca_dev.h"
index 4272c52e38a45bc65667e5ab24cff805359a7629..de7b9d7166f3a8226ef920f9c308cf1295332f00 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/init.h>
 #include <linux/if_arp.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/byteorder.h>
index 2a49ee40b52003e109b039896c773f5c3209d2bd..986d6f32ddedf8ac0d225aca4a61321469f1d3a1 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/list.h>
 #include <linux/threads.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/neighbour.h>
 #include <net/route.h>
index 925075557dc251d449e15a3adcb5ab5039621362..c36a3f51492901d696e25f37f89ac79e5a62bc21 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/tcp.h>
 #include <linux/if_vlan.h>
 #include <linux/inet_lro.h>
+#include <linux/slab.h>
 
 #include "nes.h"
 
index 91fdde382e82e9d936d263d012993415aa2ca640..b7c813f4be43266327446692c0a8496b039fdff6 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/if_arp.h>
 #include <linux/if_vlan.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 #include <net/tcp.h>
 
 #include <net/inet_common.h>
index 729d525c5b70514eca4e6d3b0f1dd88f1e46b953..186623d8695987b04cee7f82222be4bafd7c8523 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 #include <linux/crc32.h>
 #include <linux/in.h>
 #include <linux/ip.h>
index 69928296d74bf3b8f41e5f80449ecc66b4fc6375..5a076e8f116ad67f556fa2b05dbd093d8cc932d4 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/moduleparam.h>
 #include <linux/random.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include <rdma/ib_verbs.h>
index bc658373ad557a05d428df81697b9938e85b6d5e..bb1004114dec09c6f3b6df7c9dab66d1f09f5bae 100644 (file)
@@ -35,6 +35,7 @@
 #include <net/icmp.h>
 #include <linux/icmpv6.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "ipoib.h"
index 961c585da216a9eb3db964b08cfc72b20b981a24..86eae229dc49eb5c12d517f4c6c8d60a139160e6 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/err.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 struct file_operations;
 
index 5df40b128f81b1b13f8cd9d30133a4ea43148875..ec6b4fbe25e4416fb45ef9e76f5703093c26e86a 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <linux/ip.h>
 #include <linux/tcp.h>
index d41ea27be5e196998d97ced405837433d46586cb..b166bb75753d07c8457cdb19c9874a1582a2cc90 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/inetdevice.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
+#include <linux/slab.h>
 
 #include <net/dst.h>
 
index 68325119f740da879a3d9deaa6095907ee3554bf..049a997caff35875ca8e5e1ad2870a4b3af0a933 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "ipoib.h"
 
 int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
index e3bf00d8cd259cdb1f167b19aeb0bda4b9af6b86..d7e9740c724804afcdf20ba9c54fbe4fe91fdb87 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/module.h>
 
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/seq_file.h>
 
 #include <asm/uaccess.h>
index e78af36d3a0e7c0601ef06b8cac08d1ffc75dcec..93399dff0c6fa8eb95217d15d4590dabcdc5b22a 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/net.h>
 #include <linux/scatterlist.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 
index 308d17bb514641767a109f9e65d2bcea370cee82..b89d76b39a131873dc4548bdf57e703c4eb09f5e 100644 (file)
@@ -32,6 +32,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "iscsi_iser.h"
index b2f07aa1604bec5de42095ab7ba4fef5c5980a7d..03078c08309a09cff9b5c1011dcd1c1ce855048e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 /*
  * Check that the effect_id is a valid effect and whether the user
index f967008f332e3a79fda20adb4d967957ab29f3e5..1d881c96ba8fc2c0db1c5ce289af448288ff42a5 100644 (file)
@@ -25,6 +25,7 @@
 
 #define debug(format, arg...) pr_debug("ff-memless: " format "\n", ## arg)
 
+#include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
index 06ad36ed348329e9ff4d4dabb7141eb07cd61d56..85d6ee09f11f4b7881b66acc9eaceb068b0bde7d 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/gameport.h>
-#include <linux/slab.h>
 
 #define L4_PORT                        0x201
 #define L4_SELECT_ANALOG       0xa4
index 291d9393d359c8e0e7f82a0d20e4a2cfc0f2e8a6..10c9b0a845f07abb41b0d071133d9166e601c763 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/input-polldev.h>
 
index e2aad0a51826b1214e9f55a9c6a45d7e69e1525e..afd4e2b7658cff9a6e557e9dada0cb35826379b9 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/input.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/major.h>
 #include <linux/proc_fs.h>
index 523959484753fdabf3e9faa2dddb8ca45c8370c4..8e7de5c7754ffa98ef0fb869e7668b00b9a32be4 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/parport.h>
 #include <linux/input.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver");
index 7a55714a14866386909153cf794844918bb09a1a..fbd62abb66f9dc3017fc4f678dddd28cd889309e 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/parport.h>
 #include <linux/input.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
index b6f859869540d3b1995acc4c50b3edde52d9d4a1..d53b9e900234e7ba95c2c0b9500a830b96c07803 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
index a7ba27fb4109e32b7fff3bb8b22e67b93eb2967e..3db8006dac3a8f93e1e31a01e56766044cd194ed 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/mfd/adp5520.h>
+#include <linux/slab.h>
 
 struct adp5520_keys {
        struct input_dev *input;
index b5142d2d5112a0470cf34e924e9c0063124d56f3..4771ab172b59b22dda93eaa5437aba8019d7a208 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include <linux/i2c/adp5588.h>
 
index 593c052416b90c94581c65808302445b05996eff..7d989603f875f6a417c395624cffbc2b7171ac26 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/fs.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
 #include <linux/sysctl.h>
index d410d7a52f1d6bd3c60f85564203fb685f76f89b..a91ee941b5c1f0a5f36a6064dd59c30c85c93567 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 
index bd25a3af16644a63885e7be741bb6a97728a7329..c8242dd190d0c920f64ff105903fd76c2e5a6be1 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/ep93xx_keypad.h>
index 2b708aa85553358a2b375cbb602fb07d1ea36c02..b8213fd13c3f0ab277a51ad167b7ae85ab7fcdff 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/sched.h>
 #include <linux/pm.h>
+#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
 #include <linux/delay.h>
index 2ee5b798024d89d3b12cceeddc701a17d933dbec..d92c15c39e683cd58eb5dc354c26f5a56559a6dd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 
 /*
index 781fc61028606a7048bd330e85de10249264e233..5fc976dbce0b0506e466bd9aa3f7ec899c46b0b2 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <asm/io.h>
index 4e016d823069a65cce32c3fbd5cd94667e2de93c..2cd3e1d56ea4340a450b23974b58b4d7899871f0 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <mach/jornada720.h>
 #include <mach/hardware.h>
index 574eda2a4957a908cd4924d2ba2ae6b4fe958645..60ac4684f87508fe5a3a17c6299f04dfa688e7e0 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/input.h>
 #include <linux/leds.h>
 #include <linux/i2c/lm8323.h>
+#include <linux/slab.h>
 
 /* Commands to send to the chip. */
 #define LM8323_CMD_READ_ID             0x80 /* Read chip ID. */
index d3c8b61a941d46aa677e8f13dff3aba9edcb6f56..ffc25cfcef7abe4863170fd1536da082eea2eb36 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/gpio.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/slab.h>
 
 struct matrix_keypad {
        const struct matrix_keypad_platform_data *pdata;
index 3b5b948eba39fa79fbd38047cdb094c82b1939c9..7fc8185e5c1bd8ab914cedb0f0d78e15e974ed89 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/input/matrix_keypad.h>
index 1a494d505431a3babe4b08c6911fa8db6c9652bd..a72e61ddca919a46eb4bf276575eea3138bb0857 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <mach/gpio.h>
 #include <plat/keypad.h>
 #include <plat/menelaus.h>
index 78cccddbf551b55a8fdb15163e6867d79202a8aa..1f1a5563f60a8b7c367acbd68543d998fb50cf8f 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 struct opencores_kbd {
        struct input_dev *input;
index 79cd3e9fdf2e2f60d6266fdf4d5df85c5057325c..0e53b3bc39afe4d7925d4aec0cea66174dfc1e5e 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/slab.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
index 95fbba470e65f1190eb3de992dfee577ae7b8406..b7123a44b6ece5389989f07a7d9c1d1147a3e2d2 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/input.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/pxa930_rotary.h>
 
index 854e2035cd6e66108fb14f57ee7038991d5106fc..d7dafd9425b69b0682035822185900b8e8ac3d72 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/bitmap.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 static const struct {
        unsigned char kymd, keyout, keyin;
index 42cb3faf7336256ad8de736d7afcb2c4dc1e7756..3910f269cfc8a6a0b57ea1b184336b77b28635c0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/input.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include <mach/gpio.h>
 #include <mach/tosa.h>
index 21d6184efa96059ed773b6f63a09e3d37025686f..7aa59e07b6893bead02dcc97bd8035aca08a3773 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/input.h>
 #include <linux/platform_device.h>
 #include <linux/i2c/twl.h>
+#include <linux/slab.h>
 
 
 /*
index 6032def03707f34b3d4169d5944056e8bb849288..4ef764cc493c06c49fa135e735ed6dcf2e2aa93e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/w90p910_keypad.h>
 
index 69a48e8701b9988acbfaf782f40fd51a98ff6c23..40dabd8487b5933903b8062a4b82fd7c2153da85 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/input.h>
 #include <linux/interrupt.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/slab.h>
 
 #define PM8607_WAKEUP          0x0b
 
index 15be5430bc6d6010bc3e4e3bcc93fe7bc9d696d4..2124b99378bbb057b74809560d60bdcf428ad932 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/usb/input.h>
+#include <linux/slab.h>
 
 #define DRIVER_DESC    "ATI/Philips USB RF remote driver"
 #define DRIVER_VERSION "0.3"
index 61d10177fa83750b0162468956742564466e9e25..4f72bdd694102eb626011956d1b3b642d6d1ae63 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include <asm/portmux.h>
 #include <asm/bfin_rotary.h>
index ee73d7219c9280c6be1a3e3c7b4c82d6ef4a0b72..fd8407a29631030b1f4a088f01e214b46eb9a4f5 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #define BUTTONS_POLL_INTERVAL  30      /* msec */
 #define BUTTONS_COUNT_THRESHOLD        3
index 766c06911f41a1adda9505d0705799b8126a980b..19af682c24fb4f567ef0f193b189efe0b177c15e 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
 #include <linux/platform_device.h>
index 7ea969347ca993ec34c2edb5d5679a1af25e68f6..99335c286250594933967ea3132aba3a948b4b4f 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/mfd/ezx-pcap.h>
+#include <linux/slab.h>
 
 struct pcap_keys {
        struct pcap_chip *pcap;
index 008de0c5834b711d5efbf2de439f0104a3019916..95562735728d6d5c2f472767284b778546ab529c 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/pcf50633/core.h>
 
index 4ae07935985e744f2987246ff04435034b81b5c8..1f8e0108962eff45fc03a1fc0257e39486f4aaed 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/rotary_encoder.h>
+#include <linux/slab.h>
 
 #define DRV_NAME "rotary-encoder"
 
index be3a15f5b25d85203b748a40af65defe02083e36..1a80c0dab83bce0204a6532413a759d830451fdc 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_SGI_IP22
 #include <asm/sgi/ioc.h>
index b064419b90a235fbe3ad58be8c25ab437252c6e0..0d45422f8095040f9354b3fe40d4a520218e7c88 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/of_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 2fb79e064da3d1b8cb348cbf5055a3a5b6927af4..fee9eac8e04ab830fbfb4fab89ef79b10138187a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/mfd/twl4030-codec.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 /* MODULE ID2 */
 #define LEDEN          0x00
index 9c155a43abc2afd811348f88808952cd9be59c75..64f1de7960c699845337ad1080c9deb78598f12a 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/io.h>
 #include <linux/bitrev.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #define DRVNAME "winbond-cir"
 
index c0afb71a3a6d7a34919a8a32f98731a3b28e8001..04d5a4a3181ff847cbdfc9bf4bec1a5e9c8f1540 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/preempt.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/platform_device.h>
 #include <linux/leds.h>
index 1e54bce72db54d976f8cc882c61f71893bfb1776..c3d7ba5f5b47037c3b8c46b62ca7d6ad931e62db 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/input.h>
index 7490f1da4a532d8d04506320f840254deb91f351..99d58764ef03573e94c624625ae64f710d06ee69 100644 (file)
@@ -15,6 +15,7 @@
  * the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/serio.h>
 #include <linux/libps2.h>
index b27684f267bf815ac30b2ba6fcd7deab01532b36..a138b5da79f9e17a5337f238aaaf556887ef18b8 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/input.h>
 #include <linux/serio.h>
index 9169d1591c1fea50c854c82a129bff8663d2fe12..08d66d820d2bfd94f17e736f58c3b0d3ec653e5c 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #define DEBUG
+#include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/serio.h>
 #include <linux/libps2.h>
index 7c1d7d420ae3f1ae8ba19952cef65aac1fe99246..c31ad11df6bb11f5a3dbf77d000670ebd655ffbd 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/serio.h>
 #include <linux/libps2.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #include "psmouse.h"
 #include "lifebook.h"
index 1e827ad0afbedd58a36438cb1fe23e4a0ad3adf8..943cfec15665f336c2d21a481f55ffe4251d4ae5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/pxa930_trkball.h>
index 81a6b81cb2fe7c194a2250c7cd3366c910290f8f..1242775fee1938c498b3dda6da6e8acb6990c67b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/libps2.h>
 #include <linux/serio.h>
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 
 #include "psmouse.h"
 #include "sentelic.h"
index d3f5243fa093c8ce1152cd17f737250f0002c888..026df6010161afb63e85d6ee3ca684298b60d133 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/input.h>
 #include <linux/serio.h>
 #include <linux/libps2.h>
+#include <linux/slab.h>
 #include "psmouse.h"
 #include "synaptics.h"
 
index 9867dfe2a638fd8b3ec345f9868f54433df6aa9e..8291e7399ffab3606d2563a8e7257e513b5179f6 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/input.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME            "synaptics_i2c"
 /* maximum product id is 15 characters */
index 909431c31ab44a539591e6edc8210f70db2462b1..88121c59c3cc42d52f4eb37c7785ea9f90c7120f 100644 (file)
@@ -26,7 +26,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 
 #include <linux/input.h>
 #include <linux/serio.h>
index 63d4a67830f2d9cda217544262abb6c27c83c162..0643e49ca6039ea239e777c0b7f695040fed53bb 100644 (file)
@@ -8,6 +8,7 @@
  * Trademarks are the property of their respective owners.
  */
 
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serio.h>
 #include <linux/module.h>
index 320b7ca48bf8567a5c1bbdbb114ce971dcb8a960..7998560a1904cd7f98e72d763c65c4176afb8bd4 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define DRV_NAME "altera_ps2"
 
index b54452a8c77141043011c3329ea5c70c5452597f..6ee8f0ddad51abe615325f8335a02ec99fb311e2 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 /* PSIF register offsets */
 #define PSIF_CR                                0x00
index d1380fc72cc6ee5c81da9ecd093085de57fa0930..4a3084695c00b554af42be46075047c9c5d9538c 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 06addfa7cc47b639979a64a272b75e2f6841d8e6..3c287dd879d32be0b68f732ab020974c38ac10f5 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/serio.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
index 6cd03ebaf5fb39e6dfb8db0445f02b4ffdf552b4..c92f4edfee7beef3a326e0af4e43275093fba8dc 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/list.h>
 
index 9302ba0e48f814ea730f5c681cf3a3add3489412..577688b5b951d15062be40f08eeb76ddda09404f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/rcupdate.h>
 #include <linux/platform_device.h>
 #include <linux/i8042.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index f3876acc3e8394e4810fcf16a67773fe96cdc0e1..980af94ba9c822aef9fc520ac41962c9b0d249a2 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/serio.h>
index b089977e0ef96b76895d9f12f47991287ff0a2bd..26b45936f9fdf3334c6f083aeaa7c5ee5bb178dd 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <linux/module.h>
 #include <linux/parport.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/serio.h>
 
index 797314be7af2ffadc6361a44f7d87403fda419ed..43494742541c380a4d672134fe38fd052db182fe 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/ioport.h>
 #include <linux/input.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/serio.h>
 #include <linux/delay.h>
index e36a0901646cb2d2d91be060771946af9d60f75b..5eb84b3b67fbb7b69776fa33b15db6a690818a1f 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/err.h>
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
index ed045c99f84b017d7ac4b252e5e5d33f329577e2..9da6fbcaaa7e8d2ffbc0b7d3c84abee821d5d5e3 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <mach/hardware.h>
index 8298e1f68234df7cbd33afbc4d452595155530c0..f84f8e32e3f1789fac1655752eeb051b3139cb93 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/serio.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/io.h>
index e6bde55e5203c06f651dfaa7e6ef7f1cfc1633a8..82ae18d2968561f0221d3c66ee39645bcb429e2d 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
 MODULE_DESCRIPTION("Generic support for sparse keymaps");
index 286bb490a9f29cd16e37b4bbf5b3b0940070a272..b3aebc2166ba666256fd083da1f5c733545530fc 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/slab.h>
 
 #define MEAS_LEN               (8)
 #define ACCURATE_BIT           (12)
index a12242f77e23c3937730c07488dc57e0a5ca0901..fa8e56bd9094ec8df9ac43119a5a2213c4785f09 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/timer.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define AC97C_ICA              0x10
 #define AC97C_CBRHR            0x30
index 3ffd4c4b170c6ae21354e191d2483637e4048224..2b72a5923c16a41f9cfbd1400f958f736842fd6f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/input.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/da903x.h>
+#include <linux/slab.h>
 
 #define DA9034_MANUAL_CTRL     0x50
 #define DA9034_LDO_ADC_EN      (1 << 4)
index 9029bd3f34e5ee9b5c12e3ef41c04c09001a45b1..204b8a1a601c50b15d4fd460095fd7db32a8c2f2 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/timer.h>
 #include <linux/gpio.h>
 #include <linux/input/eeti_ts.h>
+#include <linux/slab.h>
 
 static int flip_x;
 module_param(flip_x, bool, 0644);
index c8b7e8a45c4d91292c09afeb239be90efe598c79..4b0a061811ffabea4e17630b6b9b01fa31934466 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/input.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/jornada720.h>
index be54fd639acaedad630ff0ab0343c44d9d29ea86..c5bc62d85bb6e1987ebd1377888de3f1ddfa6a79 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/input.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #define MC13783_TS_NAME        "mc13783-ts"
index 4c28b89757f9ebf0fbe3505cf8964afeb79287b1..ce8ab0269f6fc755f6496e90a5a4cd4c8157b816 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 /* Registers */
 #define MCS5000_TS_STATUS              0x00
index 141dd584330ee1106f4557a24faf3cab54048619..defe5dd3627ce98d84104ef3ffea64214ee173fc 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/i2c.h>
 #include <linux/timer.h>
index b79097e3028a10e381f1c259c78ce0259985f2f1..ea6ef16e59b428e9b7338ce57bde07d51bbb44e0 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/pm.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
index 3755a47d053caea796fd4650c18889e0f7ea4fa4..98a7d1279486f1fb4ad7dca35314b7d021b9f6f3 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/init.h>
index 89dcbe7b4b02c770dc32c1ed753547eadf6dee05..028a5363eea14612a15dee19f0f61c858d4fe87a 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/suspend.h>
-#include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/ucb1400.h>
index 6ccbdbbf33fec2725fc9495b0271af7aa82b81f5..cc18265be1a8f2266480f93841c0530d3e180cea 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/clk.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 /* ADC controller bit defines */
 #define ADC_DELAY      0xf00
index f944918466e5bd24d2909a0081b975cb3be770f7..5109bf3dd8587b79ba735dba8e0e2ed6c0cb12a5 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/wm97xx.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define TS_NAME                        "wm97xx"
 #define WM_CORE_VERSION                "1.00"
index d30436fee4760f02486e952e9468af375432161c..e14081675bb2b5a8709570ad45e657a30381f3fb 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include <asm/xen/hypervisor.h>
 
index f774e12bb64dc4cbf816c27878813e844a814c19..05ed72c4cf59f60413950411b82fbe2e9766809c 100644 (file)
@@ -16,6 +16,7 @@
 #include "act2000_isa.h"
 #include "capi.h"
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 static unsigned short act2000_isa_ports[] =
index 8596bd1a4d26536ebf340aa43ef3ef56b31c01fa..2b83850997c3903df974e6088b81854e9d5c1ebb 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/fs.h>
 #include <linux/mount.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/module.h>
 #include <linux/init.h>
index fcaa1241ee7714bb835aa7d7b0db648c50e19a45..0b041df2108c644340eb937c4a9ccc7615b5a8f1 100644 (file)
@@ -1,4 +1,5 @@
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/isdn/capilli.h>
index 26626eead82857408fb7729e1f59b530b5a6d2b3..03c469e4451feae3102f96994420ebfddd1223ce 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/isdn/capiutil.h>
+#include <linux/slab.h>
 
 /* from CAPI2.0 DDK AVM Berlin GmbH */
 
index ce9b05b9e93a93ab6974ddf714a28fa3867299b3..bd00dceacaf0d6cac10a1ab8da423264f706a313 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/moduleparam.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/isdn/capicmd.h>
 #include <linux/isdn/capiutil.h>
index 3697c409bec66d5b9c2dbe0b31577f22fef2ef1c..9f49d906579177430c463d03f78dbe514237def5 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #else
index 77e9fdda0597381741691709529c2006a994fc8c..70cf6bac7a5aa1041cfa6067df7a62c1964debd5 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/jiffies.h>
 
index 0220c19351d92ced75c5669ea6d1cf0d77a323ea..eb7e27105a828756bb6dbf4c5917b32fa977f908 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include "gigaset.h"
+#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
index bdc01cb9f0ab247960bc786fad05820c910fd532..0b39b387c1253ca0e88160b561f86e82f4842779 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/ctype.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 
 /* Version Information */
 #define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers"
index cdd144ecdc5f462c972425b11ce1d978bb588eb8..9ef5b0463fd5076d25708e67e61edebaeb5ac59d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/usb.h>
 #include <linux/skbuff.h>
index c22e5ace8276a99fe39188eb13941e56f6b07cb4..c99fb9790a13bfa2a73af8b347282fc7da9832c0 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "gigaset.h"
 #include <linux/isdnif.h>
+#include <linux/slab.h>
 
 #define HW_HDR_LEN     2       /* Header size used to store ack info */
 
index 168d585d64d8550e9bfe62fb6dcef5371cf5e069..8b0afd203a0730852cfd7e8c65f60f632503e13a 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/tty.h>
 #include <linux/completion.h>
+#include <linux/slab.h>
 
 /* Version Information */
 #define DRIVER_AUTHOR "Tilman Schmidt"
index c38fa0f4c7296ea451fd47ba892813c69762ae77..2a57da590d797ecf82ca5aedb8e0b07ef96c1c41 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/ioport.h>
 #include <linux/capi.h>
 #include <linux/kernelcapi.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
index 124550d0dbf361f2d28a006f6b9787e83c02685a..9c8d7aa053c5ae4d2631aa22590f1967e00562e8 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/ioport.h>
 #include <linux/capi.h>
 #include <linux/kernelcapi.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
index de6e6b31181938484e0c0d425502b7fdc47f9b98..7715d3242ec81849dbd725cbbaaf52a7cd597380 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/capi.h>
 #include <linux/kernelcapi.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <linux/netdevice.h>
index baeeb3c2a3ee1cc720bb28e07bae96f02d7bfb94..08216b14be13c30a7b4b2655eb0915ca0e2072a0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kernelcapi.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <linux/isdn/capicmd.h>
 #include <linux/isdn/capiutil.h>
index 0f073cd73763f98dc7698e3c2bec2d0ef42c7102..97a20964cfc7235785090335774e7d981230a5be 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
 #include <linux/seq_file.h>
index 81ac541d40d9eedfb80a6338b77d757b201ace23..d4215369bb59dde8f5ab629db3ceb259d0c0480e 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "ipac.h"
 
index 8affba3e569d888dfea0518d3610280e1ac6bb09..75e71b5d921533b0299c69db36b984f37db99279 100644 (file)
 #define HFC_MULTI_VERSION      "2.03"
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
index 70e6b0e0112132d3f07b6779d0b42075ef1e0cc7..5940a2c12074a285bce286fb6659eb73944dd96f 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 
 #include "hfc_pci.h"
 
index a64bb6c67ba7ff673cbd9bf4907bcff335798d2e..b3b7e2879bac25873da4d2666567f2c52fae434f 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/usb.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 #include "hfcsusb.h"
 
 static const char *hfcsusb_rev = "Revision: 0.3.3 (socket), 2008-11-05";
index 36c6c616a6553355796233ff91483c7f921ad6e5..f5b3d2b26a0811455bccd1824face31364eaa372 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 #include "ipac.h"
 
 #define INFINEON_REV   "1.0"
index 613ba043537254eb57307beb8591317661fc1549..64ecc6f5ffaf8d0159bc4e3c1cd35eb82835d82c 100644 (file)
@@ -20,6 +20,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mISDNhw.h>
 #include "ipac.h"
index f0bc6fa958097b01e4318e78b98c131cd253ee8f..38eb31439a7316102ad40110312a43230dd8cb3a 100644 (file)
@@ -25,6 +25,7 @@
  */
 /* #define DEBUG */
 
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/vmalloc.h>
 #include <linux/mISDNhw.h>
index 6c1b164937a916068c728b67b6e02ffbf3409150..0a3553df065fcd38d884e939e040486760073de7 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 #include "ipac.h"
 #include "iohelper.h"
 #include "netjet.h"
index 7726afdbb40b72f043df0299ca64788a4e7599d9..d097a4e40e2ba66442ad87d4f44824927f8a0ab2 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
index 2952a58c7a6158a824f3afec084ea471d7179592..31f9d71fb22f7f094fc5d373b0b4e3e9a33a51c4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/mISDNhw.h>
+#include <linux/slab.h>
 #include "w6692.h"
 
 #define W6692_REV      "2.0"
index d6fdf1f66754b5886eae439a1ad61becac5e6b4f..5d72783978784ed0bc962b9f43d438ae038d373a 100644 (file)
@@ -59,6 +59,7 @@
 #include "amd7930_fn.h"
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 
 static void Amd7930_new_ph(struct IsdnCardState *cs);
 
index 14295a155e716818bd96193bec62e33c484f8178..fcf4ed1cb4b9f2c44eef2bc1591faaf8b4343d9b 100644 (file)
@@ -17,6 +17,7 @@
 #include "isac.h"
 #include "isdnl1.h"
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/isapnp.h>
 #include <linux/interrupt.h>
 
index e5deb15cf40c9ec2a2354375ef174afe83e8e05f..8d1d63a02b341f3084410c67c43bb216e35fa1d9 100644 (file)
@@ -50,7 +50,7 @@ module_param(isdnprot, int, 0);
    handler.
 */
 
-static int avma1cs_config(struct pcmcia_device *link);
+static int avma1cs_config(struct pcmcia_device *link) __devinit ;
 static void avma1cs_release(struct pcmcia_device *link);
 
 /*
@@ -59,7 +59,7 @@ static void avma1cs_release(struct pcmcia_device *link);
    needed to manage one actual PCMCIA card.
 */
 
-static void avma1cs_detach(struct pcmcia_device *p_dev);
+static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ;
 
 
 /*
@@ -99,7 +99,7 @@ typedef struct local_info_t {
     
 ======================================================================*/
 
-static int avma1cs_probe(struct pcmcia_device *p_dev)
+static int __devinit avma1cs_probe(struct pcmcia_device *p_dev)
 {
     local_info_t *local;
 
@@ -140,7 +140,7 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
 
 ======================================================================*/
 
-static void avma1cs_detach(struct pcmcia_device *link)
+static void __devexit avma1cs_detach(struct pcmcia_device *link)
 {
        dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link);
        avma1cs_release(link);
@@ -174,7 +174,7 @@ static int avma1cs_configcheck(struct pcmcia_device *p_dev,
 }
 
 
-static int avma1cs_config(struct pcmcia_device *link)
+static int __devinit avma1cs_config(struct pcmcia_device *link)
 {
     local_info_t *dev;
     int i;
@@ -282,7 +282,7 @@ static struct pcmcia_driver avma1cs_driver = {
                .name   = "avma1_cs",
        },
        .probe          = avma1cs_probe,
-       .remove         = avma1cs_detach,
+       .remove         = __devexit_p(avma1cs_detach),
        .id_table       = avma1cs_ids,
 };
 
index 475b1a020003fcb986de41f9fbf8d56f5167a9e5..f58ded8f403f2f8d740cffb908a939394f720bd1 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include "hisax.h"
 #include <linux/isdn/capicmd.h>
index 4fab18d4d02fecf84e42d7da99c4ef1d318a877f..544cf4b1cce3a1580b512d33d80dd92d428e754d 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #define HISAX_STATUS_BUFSIZE 4096
 
 /*
index 23c41fcd864e7cff1c70480cfd265be83aa8c542..5d9d338814aa0d09729fbfd4bf52ed0ca35e92ff 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include "hisax.h"
 #include "arcofi.h"
 #include "isac.h"
index c9a30b1c92372373a652f877dad6d62d65dbf19f..c9f2279e21f5f0812a9632f16c15081eb0e77773 100644 (file)
@@ -76,7 +76,7 @@ module_param(protocol, int, 0);
    handler.
 */
 
-static int elsa_cs_config(struct pcmcia_device *link);
+static int elsa_cs_config(struct pcmcia_device *link) __devinit ;
 static void elsa_cs_release(struct pcmcia_device *link);
 
 /*
@@ -85,7 +85,7 @@ static void elsa_cs_release(struct pcmcia_device *link);
    needed to manage one actual PCMCIA card.
 */
 
-static void elsa_cs_detach(struct pcmcia_device *p_dev);
+static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit;
 
 /*
    A driver needs to provide a dev_node_t structure for each device
@@ -121,7 +121,7 @@ typedef struct local_info_t {
 
 ======================================================================*/
 
-static int elsa_cs_probe(struct pcmcia_device *link)
+static int __devinit elsa_cs_probe(struct pcmcia_device *link)
 {
     local_info_t *local;
 
@@ -166,7 +166,7 @@ static int elsa_cs_probe(struct pcmcia_device *link)
 
 ======================================================================*/
 
-static void elsa_cs_detach(struct pcmcia_device *link)
+static void __devexit elsa_cs_detach(struct pcmcia_device *link)
 {
        local_info_t *info = link->priv;
 
@@ -210,7 +210,7 @@ static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
        return -ENODEV;
 }
 
-static int elsa_cs_config(struct pcmcia_device *link)
+static int __devinit elsa_cs_config(struct pcmcia_device *link)
 {
     local_info_t *dev;
     int i;
@@ -327,7 +327,7 @@ static struct pcmcia_driver elsa_cs_driver = {
                .name   = "elsa_cs",
        },
        .probe          = elsa_cs_probe,
-       .remove         = elsa_cs_detach,
+       .remove         = __devexit_p(elsa_cs_detach),
        .id_table       = elsa_ids,
        .suspend        = elsa_suspend,
        .resume         = elsa_resume,
index 1657bba7879ee9c5ca8242b6f20864f49bd16a2e..cbda3790a10daa8a2c3d3775d498c63a331e3a15 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/serial.h>
 #include <linux/serial_reg.h>
+#include <linux/slab.h>
 
 #define MAX_MODEM_BUF  256
 #define WAKEUP_CHARS   (MAX_MODEM_BUF/2)
index 34fade96a581248834c27c6aa9ebf4f0c11ff840..732ea633758ceac7b2cae2e3bf00d276da0050f1 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include "hisax.h"
 
index ab98e135bcbb689eacb0679a50ca1557089f9d55..051b44e2556cbf7dc420a83bf93ca884de52ee37 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/skbuff.h>
 #include <linux/wait.h>
index 8d22f50760eb2e52d6919c843b2729e7b670f190..7250f56a5246f4daad7d8573f3d1f59b5ee95d21 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "hisax.h"
 #include "hfc_2bds0.h"
 #include "isdnl1.h"
index d0520ad306775a773f338a429a31936c9a97fc93..b1f6481e119371b51ce43516fb25cefd7b852502 100644 (file)
@@ -16,6 +16,7 @@
 #include "isac.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 static inline int
 WaitForBusy(struct IsdnCardState *cs)
index 419f87cad8cbeb634596f57f6c7868dde6b6e236..be5faf4aa8689b7475485a6e25d9a3b606f2a65e 100644 (file)
@@ -17,6 +17,7 @@
 #include "isdnl1.h"
 #include <linux/interrupt.h>
 #include <linux/isapnp.h>
+#include <linux/slab.h>
 
 static const char *hfcsx_revision = "$Revision: 1.12.2.5 $";
 
index aaaeaafd86f4caa0b1e92aeacc4848346081fd49..ed9527aa5f2cd8e93c3233cd6d8d53ce3a4292c8 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include "hisax.h"
 #include "hisax_if.h"
 #include "hfc_usb.h"
index d0fefcf999cb7226b89e81c50021cfc1be263ee9..a8447fa2f4705940da20ea3dbc9db9be6c0aa0ce 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
 #include "hisax_isac.h"
index c8f9951f7914a4c8d1e387544c3d5bbab4a1cd8f..904b9100df95d63fec52ec7c29cac834f6c99b02 100644 (file)
@@ -16,6 +16,7 @@
 #include "isac.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 static char *HSCXVer[] =
 {"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
index c80cbb8a2ef9f5ceb6452162bad1b01ccb6a7b0c..63057268cc3d7d4211fe0e0d4cc1c5e130ed1771 100644 (file)
@@ -20,6 +20,7 @@
 // #include "arcofi.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #define DBUSY_TIMER_VALUE 80
 #define ARCOFI_USE 0
index 00afd553890925b21d224956646916250185ac62..751b25f2ff5811f7be494ae6457f1d73ac3b47c1 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include "hisax_if.h"
 #include "hisax.h"
index a19354d943433872d49c2e5c836cc2c21b030a6a..2b66728136d5d1e0b659d91872c481aa4bd4a2a9 100644 (file)
@@ -18,6 +18,7 @@
 #include "arcofi.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #define DBUSY_TIMER_VALUE 80
index 6bde16c00fb53c8e0959f1d3a05a294f77da5cfa..40b914bded8c2a3237abca74d295d8d80a02b2e3 100644 (file)
@@ -13,6 +13,7 @@
 #include "isar.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #define DBG_LOADFIRM   0
 #define DUMP_MBOXFRAME 2
index 9ce6abe05b1a242ad1508a97dffc14babc676091..d5eeacf565d696b7af80c762ed5b118fa76fd743 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include "hisax.h"
 #include "isdnl1.h"
 
index 7b9496a63b5f2d2a77f69f7395db8eec780e7c08..0858791978d8852f4171b7c7a3d0b332546d8e73 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include "hisax.h"
 #include "isdnl2.h"
 
index 06766022d3ae3440826c3d5248c9f8043f262bdd..fd0b643ab7408cfee4b288447ab30587b623796a 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include "hisax.h"
 #include "isdnl3.h"
 
index 70840a710acfe1938323f8436a07652892486310..ea8f840871d0ed81eadbf79a84e3d16417025b2d 100644 (file)
@@ -17,6 +17,7 @@
 #include "jade.h"
 #include "isdnl1.h"
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 
 int
index a12fa4d34903f699a43bcc1a62b41904279e3a8f..cc6ee2d398803a6785241968c678d5272edc9c58 100644 (file)
@@ -23,6 +23,7 @@
 #include "isdnl3.h"
 #include "l3dss1.h"
 #include <linux/ctype.h>
+#include <linux/slab.h>
 
 extern char *HiSax_getrev(const char *revision);
 static const char *dss1_revision = "$Revision: 2.32.2.3 $";
index 4622d43c7e1047d747579131451c7483b767bb25..f9584491fe8e42eca96560967892f31d0d53d8f4 100644 (file)
@@ -22,6 +22,7 @@
 #include "isdnl3.h"
 #include "l3ni1.h"
 #include <linux/ctype.h>
+#include <linux/slab.h>
 
 extern char *HiSax_getrev(const char *revision);
 static const char *ni1_revision = "$Revision: 2.8.2.3 $";
index 02c6fbaeccf82927a6e62423eff8be1efb1e0fb0..5d7f0f2ff9b9c99133272ce5e7e91bc61c9ca785 100644 (file)
@@ -21,6 +21,7 @@
 #include "isdnl1.h"
 #include <linux/interrupt.h>
 #include <linux/ppp_defs.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include "netjet.h"
 
index 7836ec3c7f86fb723131c10185a1ef432ec12d13..71b3ddef03bb790836d7d5ff63a24e8261329eb0 100644 (file)
@@ -76,7 +76,7 @@ module_param(protocol, int, 0);
    event handler. 
 */
 
-static int sedlbauer_config(struct pcmcia_device *link);
+static int sedlbauer_config(struct pcmcia_device *link) __devinit ;
 static void sedlbauer_release(struct pcmcia_device *link);
 
 /*
@@ -85,7 +85,7 @@ static void sedlbauer_release(struct pcmcia_device *link);
    needed to manage one actual PCMCIA card.
 */
 
-static void sedlbauer_detach(struct pcmcia_device *p_dev);
+static void sedlbauer_detach(struct pcmcia_device *p_dev) __devexit;
 
 /*
    You'll also need to prototype all the functions that will actually
@@ -129,7 +129,7 @@ typedef struct local_info_t {
     
 ======================================================================*/
 
-static int sedlbauer_probe(struct pcmcia_device *link)
+static int __devinit sedlbauer_probe(struct pcmcia_device *link)
 {
     local_info_t *local;
 
@@ -177,7 +177,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)
 
 ======================================================================*/
 
-static void sedlbauer_detach(struct pcmcia_device *link)
+static void __devexit sedlbauer_detach(struct pcmcia_device *link)
 {
        dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link);
 
@@ -283,7 +283,7 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
 
 
 
-static int sedlbauer_config(struct pcmcia_device *link)
+static int __devinit sedlbauer_config(struct pcmcia_device *link)
 {
     local_info_t *dev = link->priv;
     win_req_t *req;
@@ -441,7 +441,7 @@ static struct pcmcia_driver sedlbauer_driver = {
                .name   = "sedlbauer_cs",
        },
        .probe          = sedlbauer_probe,
-       .remove         = sedlbauer_detach,
+       .remove         = __devexit_p(sedlbauer_detach),
        .id_table       = sedlbauer_ids,
        .suspend        = sedlbauer_suspend,
        .resume         = sedlbauer_resume,
index 95b1cdd979584999707bbf3c84b80fed1129d66f..e56e5af889b63402dc5e3a09d9b1e2e6f70a42c2 100644 (file)
@@ -11,8 +11,8 @@
  */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/usb.h>
-#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/bitrev.h>
 #include "st5481.h"
index 39e8e49cfd2de8ee0ae293eda4409a5b707f006e..b7876b19fe7348ad03ab04d3740cf610845705c5 100644 (file)
@@ -11,8 +11,8 @@
  */
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/usb.h>
-#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include "st5481.h"
 
index 6e65424f1f0463355fdc1fe517954e0bb53e78bf..f4cb178b0666ab3d6f9b594bb367d040bb507a3b 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "hisax.h"
 #include "isdnl2.h"
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/random.h>
 
index b0c5976cbdb356c8941d77a0dfc54a166379e4d0..d010a0da8e19bdcc04b8a78e631ba6a05f330a15 100644 (file)
@@ -57,7 +57,7 @@ module_param(protocol, int, 0);
    handler.
 */
 
-static int teles_cs_config(struct pcmcia_device *link);
+static int teles_cs_config(struct pcmcia_device *link) __devinit ;
 static void teles_cs_release(struct pcmcia_device *link);
 
 /*
@@ -66,7 +66,7 @@ static void teles_cs_release(struct pcmcia_device *link);
    needed to manage one actual PCMCIA card.
 */
 
-static void teles_detach(struct pcmcia_device *p_dev);
+static void teles_detach(struct pcmcia_device *p_dev) __devexit ;
 
 /*
    A linked list of "instances" of the teles_cs device.  Each actual
@@ -112,7 +112,7 @@ typedef struct local_info_t {
 
 ======================================================================*/
 
-static int teles_probe(struct pcmcia_device *link)
+static int __devinit teles_probe(struct pcmcia_device *link)
 {
     local_info_t *local;
 
@@ -156,7 +156,7 @@ static int teles_probe(struct pcmcia_device *link)
 
 ======================================================================*/
 
-static void teles_detach(struct pcmcia_device *link)
+static void __devexit teles_detach(struct pcmcia_device *link)
 {
        local_info_t *info = link->priv;
 
@@ -200,7 +200,7 @@ static int teles_cs_configcheck(struct pcmcia_device *p_dev,
        return -ENODEV;
 }
 
-static int teles_cs_config(struct pcmcia_device *link)
+static int __devinit teles_cs_config(struct pcmcia_device *link)
 {
     local_info_t *dev;
     int i;
@@ -319,7 +319,7 @@ static struct pcmcia_driver teles_cs_driver = {
                .name   = "teles_cs",
        },
        .probe          = teles_probe,
-       .remove         = teles_detach,
+       .remove         = __devexit_p(teles_detach),
        .id_table       = teles_ids,
        .suspend        = teles_suspend,
        .resume         = teles_resume,
index 9d6e864023fe18fd33add31997ed078edbd733a5..e2cfb6f5aa4236ee917480085204623a38a35435 100644 (file)
@@ -16,6 +16,7 @@
 #include "isdnl1.h"
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 /* table entry in the PCI devices list */
 typedef struct {
index fe874afa4f81347e773a062a1ba2546338cc8581..6299b06ae00912b64471dbb7a86b0ece1ed2ac72 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #define        VER_DRIVER      0
 #define        VER_CARDTYPE    1
index 90b35e1a4b7e6e85c9d8ea4374184d3c6c02f40c..80966462d6dcba0eb58caf57ba87768188a0a36b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <net/net_namespace.h>
 
index 8bcae28c4409ea0edbf40a65db309214463ec81c..e83f6fda32fe797065fc07049e9175ce92b0f507 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 
 #include "hysdn_defs.h"
index fb350c567c6ba01c768c87845ed37c70db6a79b2..861bdf3421f2b5372452c610eff1fc5546e86c7c 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/isdn.h>
+#include <linux/slab.h>
 #include "isdn_audio.h"
 #include "isdn_common.h"
 
index 00c60e2e0ff70fa7c398c2b8688dc20d0ca3b793..70044ee4b2280f37a58151d995d90170f582f9fa 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/isdn.h>
 #include <linux/smp_lock.h>
index 507e13d9a57c1579ac1b29d1548949847ff4fcf5..8c85d1e88cc6259c41dff0b4615f32681edd39ac 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/isdn.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/dst.h>
 #include <net/pkt_sched.h>
index 45df6675e8edac5c09b05090e18861db190fb3ad..f37b8f68d0aa0d3b00f7405d1f7bb31c8ab5e6bb 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/isdn.h>
 #include <linux/poll.h>
 #include <linux/ppp-comp.h>
+#include <linux/slab.h>
 #ifdef CONFIG_IPPP_FILTER
 #include <linux/filter.h>
 #endif
index 2881a66c1aa97c2e78e0c9f3029bbbd44ef0046a..fc8454d2eea5f9343be87eaf0f3e867fb4294ca4 100644 (file)
@@ -12,6 +12,7 @@
 #undef ISDN_TTY_STAT_DEBUG
 
 #include <linux/isdn.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/smp_lock.h>
 #include "isdn_common.h"
index 8b3efc243161a201fd8029d5d43900371c48b2b5..efcf1f9327e5cc408026e8535fab61a75942b091 100644 (file)
@@ -20,6 +20,7 @@
 /* #include <linux/isdn.h> */
 #include <linux/netdevice.h>
 #include <linux/concap.h>
+#include <linux/slab.h>
 #include <linux/wanrouter.h>
 #include <net/x25device.h>
 #include "isdn_x25iface.h"
index bf7997abc4ac6da27bf972677ac3283e7e68d49c..2e847a90bad0d601f8bcc5f9a7bd4d7440f929c0 100644 (file)
@@ -12,6 +12,7 @@
 #include "icn.h"
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 static int portbase = ICN_BASEADDR;
index a335c85a736e25a472c3d66157ef40a0313304da..b8a1098b66edfb07c62c3810dbe8d52beec7f8cb 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include "isdnloop.h"
index f1bbc88763b283656777209c9164a0cb9847d371..1fa629b3b940a94743267c5898ab2ee8876c1e51 100644 (file)
@@ -33,6 +33,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/spinlock.h>
index 21d34be5af6a2300fa49b646515e0413eea77db0..afeebb00fe0bcafc8e690e199613daa54d6e901e 100644 (file)
@@ -12,6 +12,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/module.h>
index 9c7c0d1ba55f1c80d13c1f21e9bb1f56010594f8..713ef2b805a2aabec1803b6f7607f9104517fc84 100644 (file)
 
 /* delay.h is required for hw_lock.h */
 
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/mISDNif.h>
 #include <linux/mISDNdsp.h>
index 6eac588e0a374c94cb8916cbc1f08cee283eedfc..6f5b548642837b44c93c18ed5318fc907e6a2192 100644 (file)
  */
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/mISDNif.h>
 #include <linux/mISDNdsp.h>
 #include <linux/module.h>
index e9941678edfa52ff51baa83b75a8d659017926b9..621f310070953822a3c782f0c1a73caa91d4fc29 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/string.h>
 #include <linux/mISDNif.h>
index 1debf53670de6408f98ddbbbacd681a0cef9b93f..7dbe54ed1debf77231cd7c6e6f91841e2367904d 100644 (file)
@@ -8,6 +8,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/mISDNif.h>
 #include <linux/mISDNdsp.h>
 #include "core.h"
index e8049be552aa88800dee7d749489616628a7d20a..307bd6e8988bed710830db7ddbb3ce8c3a08aac4 100644 (file)
@@ -15,6 +15,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/mISDNhw.h>
 
index 325b1ad7d4b87d8e2445fb28dad77a906d976e2b..22f38e48ac4eddca6e27afa74df9c5122b940e4f 100644 (file)
@@ -233,6 +233,7 @@ socket process and create a new one.
 #include <linux/inet.h>
 #include <linux/workqueue.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include "core.h"
 #include "l1oip.h"
index e826eeb1ecec58a45ef7483df0bb55599a2fbe7c..ac4aa18c632b0f2040cef841a4e5fd98a0cd7f5a 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mISDNhw.h>
 #include "core.h"
index e17f0044e0b6d2869175c5faed183df60bab074f..c97371788764df3af6a45ad9f402ece12f59a1b3 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/mISDNif.h>
+#include <linux/slab.h>
 #include "core.h"
 #include "fsm.h"
 #include "layer2.h"
index fcfe17a19a612976ef87f099946210667601b071..3232206406b15bcdba06b39b837545307902d3e1 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/mISDNif.h>
+#include <linux/slab.h>
 #include "core.h"
 
 static u_int   *debug;
index 0d05ec43012cf14104cf4ef96f4ec0cc780ae6cd..b159bd59e64e1f65b898fb371ea3c73e85d81f64 100644 (file)
@@ -15,6 +15,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/mISDNif.h>
 #include <linux/kthread.h>
 #include <linux/smp_lock.h>
index 6d4da60958855a4103021b8a9a2863f7e9dae6c1..34e898fe2f4f32539d6a53144fad72e18a2b3f67 100644 (file)
@@ -16,6 +16,7 @@
  */
 #include "layer2.h"
 #include <linux/random.h>
+#include <linux/slab.h>
 #include "core.h"
 
 #define ID_REQUEST     1
index 5b7e9bf514f10c59e55f7439fc82b7c8bfabd81a..8785004e85e09759a5b9db53bd81225a7e0f5342 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/poll.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
index 43ecd0f5423567c0dc2026106512383126bf813a..976143b2346d06247e54256515fec879e2ab5180 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/skbuff.h>
 
index 37e9626cebf6ccdd3d5013aee3a4f8d8be10c385..d5920ae22d730024f23c8f6175b8a260cebd94f9 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/skbuff.h>
 
index 5a0774880d560640e669734ea689a1874ce4dd94..ca710ab278ec49788a50a483375c7de08b340a1b 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "includes.h"
 #include "hardware.h"
 #include "card.h"
index ee310891fff8352c6976bf4b49abe281c7086eb3..52590296af33e4a3f3af3b5de975741c3ffb1fc4 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/acpi.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Louis Davis/Jim Dailey");
 MODULE_DESCRIPTION("Dell LED Control Driver");
index d8ddd9ef89949da41b8b7b1f9e840b302772ff19..f1c00db88b5e148fd229410d5959f4c4e0e9580b 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/timer.h>
 #include <linux/rwsem.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 #include "leds.h"
 
 /*
index d196073a6aebb4442f6a889f225d8379f5df10df..16a60c06c96c62c7bd6eb4d87fac77d46af1b66a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/88pm860x.h>
 
index a8f315902131b5699a105de2a9df0cc064b541b5..7ba4c7b5b97e07ce6ff11d26895a154b25b5a956 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/leds.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/adp5520.h>
+#include <linux/slab.h>
 
 struct adp5520_led {
        struct led_classdev     cdev;
index 52297c3ab246c38a78e3580895c21e1c00d7b6f6..c941d906bba6e585f750616480ad1cccdcf3b4b9 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/leds.h>
 #include <linux/io.h>
 #include <linux/atmel_pwm.h>
+#include <linux/slab.h>
 
 
 struct pwmled {
index 779d7f262c04c39f1355e0dd2a190ca02fb067e3..286b501a3573d3b7d0d4cec872fa7b40008c83d5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/leds.h>
 #include <linux/leds-bd2802.h>
+#include <linux/slab.h>
 
 
 #define LED_CTL(rgb2en, rgb1en) ((rgb2en) << 4 | ((rgb1en) << 0))
index 1f3cc512eff898af0bc3b74c878d8b862c3cbad0..f28931cf6781049562018d0af5d59e014b2936d2 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/leds.h>
 #include <linux/workqueue.h>
 #include <linux/mfd/da903x.h>
+#include <linux/slab.h>
 
 #define DA9030_LED1_CONTROL    0x20
 #define DA9030_LED2_CONTROL    0x21
index 2913d76ad3d254f45d29a914dc40d8b177f20803..31cf0d60a9a546052e782d5177b8461c9673d941 100644 (file)
@@ -9,7 +9,6 @@
  * LED driver for the DAC124S085 SPI DAC
  */
 
-#include <linux/gfp.h>
 #include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
index 0823e2622e8c569013d2da5111d20a3cfb435be4..c6e4b772b7575206f9cb9a093b682f5060d2df82 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 
 #include <asm/gpio.h>
index 5946208ba26e586aa42ce4fb944f011fc9ff43bf..8d5ecceba1813f4a6de912c21c7cffe95ca965c1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/leds.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
index fee40a84195920c814086fedc7c920b903544670..2579678f97a6c8e02ca897c363e1b1d107d67715 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/workqueue.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 struct lt3593_led_data {
        struct led_classdev cdev;
index adc561eb59d2ed022873bacf35501b9462e19bbc..6682175fa9f7c4e3c5a91d99120c83b2003f6b9a 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/leds.h>
 #include <linux/input.h>
 #include <linux/mutex.h>
index 4e2d1a42b48f41ed4ae0bcabfb672fec5b7e0600..8ff50f234190a38129342d743a14c8c7c201ad6c 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 /* LED select registers determine the source that drives LED outputs */
 #define PCA955X_LS_LED_ON      0x0     /* Output LOW */
index 88b1dd091cfb9f3887ec052f75a3f4e0620d69ad..da3fa8dcdf5b924f71a7f117c05009f0fc671514 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/pwm.h>
 #include <linux/leds_pwm.h>
+#include <linux/slab.h>
 
 struct led_pwm_data {
        struct led_classdev     cdev;
index 7f00de3ef9224a42eb4404e14e2c45f3d81d6f89..3790816643bef85bee2dd1824bcb29818a693f86 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/leds.h>
 #include <linux/leds-regulator.h>
index aa7acf3b92248e44ead8cc8da59586b11ed255f6..a77771dc2e9542fca0bf77cfa5a1466f71fa2e47 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/leds.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <mach/regs-gpio.h>
index 6b008f0c3f623460273cd985101e5da0d32354b4..ab6d18f5c39f343b3324fbd5d03a58fa4bcfbeda 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/leds.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/fhc.h>
 #include <asm/upa.h>
index c586d05e336a5ed6327dd331f90fb2597f2974da..ef5c24140a44deb5890a1620d66e89b071963993 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/leds.h>
 #include <linux/err.h>
 #include <linux/mfd/wm831x/core.h>
index 38c6bcb07e6c55e7113397911bae3fb0fb8a5221..5aab32ce4f4d2a18e1f7997482a79925e75aa39d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/err.h>
 #include <linux/mfd/wm8350/pmic.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
 /* Microamps */
 static const int isink_cur[] = {
index d3dfcfb417b89befb8706f8d8a208b904baaeb33..f948e57bd9b83018f425de0823725b95ec053a5c 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/leds.h>
index f5913372d691a034bd18223a4494f568d337d27c..991d93be0f447313945b6925a0a196c19a9586e2 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/workqueue.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 #include "leds.h"
 
 struct gpio_trig_data {
index c1c1ea6f817b1eb7ddb7f2433cbdc917e20d164e..759c0bba4a8fa54d95b12d5434ad72a643a25f88 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/sched.h>
 #include <linux/leds.h>
index 38b3378be442b3d6501b8ffb9aa67e8eaba21ef4..82b77bd482ffdb4f952f0785c197db6efe1e8736 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/timer.h>
 #include <linux/ctype.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 #include "leds.h"
 
 struct timer_trig_data {
index 8744d24ac6e639213e4366cc7dd12d06ec039a4e..efa202499e37f792eb808188bf80652ce3cd07fc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/cpu.h>
 #include <linux/freezer.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <asm/paravirt.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
index bc28745d05af9794f756a5a29e64bb0b51a230ff..9136411fadd53e10c47c0624cf8576e7ae9d70b2 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/wait.h>
 #include <linux/hrtimer.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <asm/lguest.h>
 
index b6200bc39b5814460c4a7e451d63c680e593e1f7..07090f379c63c27db684d9a6d94e64137b7c1490 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/interrupt.h>
 #include <linux/virtio_ring.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/paravirt.h>
 #include <asm/lguest_hcall.h>
index bd1632388e4a37f0f12268e83d645b92e96632ff..85b714df8eae8d8ef372f74bedeb4497eab1f8d7 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/sched.h>
 #include <linux/eventfd.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 #include "lg.h"
 
 /*L:056
index cf94326f1b597f1b46ccc3ddc996b5aa0ef84f5f..04b22128a47421cac65a6dd73480ee56c87ded1d 100644 (file)
@@ -10,6 +10,7 @@
 /* Copyright (C) Rusty Russell IBM Corporation 2006.
  * GPL v2 and any later version */
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <linux/random.h>
index e943d2a29253d53b60d35c08cfe89e83902508ac..067f9962f499e4941c1e97b11dbf469c8b27e043 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/sysctl.h>
 #include <linux/input.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 
index 93fb32038b14cf2e822708763669dfc855f4e49d..7c54d80c4fb2309e1873cd52981fe7ff186853b5 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
index f96feeb6b9ce0da9d22acb9a47697eac4f1e3efb..888448cf7f1f1fedf4af2212ca242f06f88d04f7 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
index 921373e4e3af9b1c5d4d9f022df5bb2555e301d5..b18fa948f3d1be64c3f3df73cbc715596fb05de7 100644 (file)
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
index 7fb8b4da35a7a740c81dbd005e2d05d1f656926d..0839770e4ec54faa6c742c4c7f06ac81fecb7080 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/i2c.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kthread.h>
 #include <linux/of_platform.h>
index fb9fa614a0e8e2f1f4ff0792c3b0ec1e476239ff..aeb30d07d5a29bd9981759d3cc91ab535520ea9c 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/miscdevice.h>
 #include <linux/blkdev.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 
index 419795f4a2aabb7ce5c311d42d075f2e6038bcf2..c092354591bb7544f215e50f6ffcd8b7b7d606b3 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/kthread.h>
index 7ac2c1450d1004c4de300df3aab50fead2cfe5e0..1ed0094f064b351aa121e0858fbb31cbaee9f166 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/bio.h>
+#include <linux/slab.h>
 #include <linux/dm-dirty-log.h>
 #include <linux/device-mapper.h>
 #include <linux/dm-log-userspace.h>
index f1c8cae70b4ba0c8de108a88ee72ecc26def140a..075cbcf8a9f51ab4607810c6071a7d54c0a38c38 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/workqueue.h>
 #include <linux/connector.h>
index 168bd38f50060968cf59e3543708701f1f1f575a..bd5c58b2886849a795b762823246c55b9d8e49ea 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "dm.h"
index cfa668f46c40f1b746cb1e2c230385855f5a5997..9c6c2e47ad625a6a12328d33d3491c7b413ca8f4 100644 (file)
@@ -11,6 +11,8 @@
 #include "dm.h"
 #include "dm-path-selector.h"
 
+#include <linux/slab.h>
+
 #define DM_MSG_PREFIX  "multipath service-time"
 #define ST_MIN_IO      1
 #define ST_MAX_RELATIVE_THROUGHPUT     100
index 04feccf2a997947968260029419e7813cb222553..11dea11dc0b649e16594e071163f79647c274293 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/init.h>
 #include <linux/kmod.h>
 #include <linux/bio.h>
-#include <linux/slab.h>
 
 #define DM_MSG_PREFIX "target"
 
index 713acd02ab39f1cd9662b5238c6e770fcc73c00c..8e3850b98cca508f2bb60de9aa0c843c3328779b 100644 (file)
@@ -64,6 +64,7 @@
 #define MaxFault       50
 #include <linux/blkdev.h>
 #include <linux/raid/md_u.h>
+#include <linux/slab.h>
 #include "md.h"
 #include <linux/seq_file.h>
 
index bb2a23159b21494f72797aaa3fc23e6d0764c939..09437e958235e469c75aaab913d6b651ccde9f64 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/blkdev.h>
 #include <linux/raid/md_u.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "md.h"
 #include "linear.h"
 
index fdc1890b6ac58310bd988f518ca4751df1a95cd4..9712b2e97be48b709575be868585da13e447a58a 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/delay.h>
 #include <linux/raid/md_p.h>
 #include <linux/raid/md_u.h>
+#include <linux/slab.h>
 #include "md.h"
 #include "bitmap.h"
 
index 5558ebc705c87ed29a95092068da2c8f9d03a627..789bf535d29cbd7d9b6b00b9f825dd6c6f663791 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/blkdev.h>
 #include <linux/raid/md_u.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "md.h"
 #include "multipath.h"
 
index 377cf2a3c3331e5276c19563b7883e7c4797c425..c3bec024612e63682a9367cc58579c89c1303f5f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "md.h"
 #include "raid0.h"
 
index f741f77eeb2b48aa9c51793ba778e7adb43bbcab..e59b10e66edb961c8a270b8ebd11830a62551ca3 100644 (file)
@@ -31,6 +31,7 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/blkdev.h>
 #include <linux/seq_file.h>
index b4ba41ecbd2030fa9e8d0e4ed765b5a8d133ee84..e2766d8251a184a6c28a67430ca34c7e68d0df67 100644 (file)
@@ -18,6 +18,7 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/blkdev.h>
 #include <linux/seq_file.h>
index 70ffbd071b2e797be6f715dd40de19a93c6567d3..e3e9a36ea3b7d9fa5fcaa8558d106756863143e7 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/async.h>
 #include <linux/seq_file.h>
 #include <linux/cpu.h>
+#include <linux/slab.h>
 #include "md.h"
 #include "raid5.h"
 #include "bitmap.h"
index bffc61bff5ab7c743d4ce0da3d716cd8642112f0..1f8784bfd44de61972e655363e01105840c29445 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/raid/pq.h>
+#include <linux/gfp.h>
 #ifndef __KERNEL__
 #include <sys/mman.h>
 #include <stdio.h>
index 0a3b4ed38e488ebd3015042c2b8a5b0c1b0160ba..bfca26d51827823fdb42c15778843bb2f5889c51 100644 (file)
@@ -14,6 +14,7 @@
 
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <media/ir-common.h>
 
 #define IR_TAB_MIN_SIZE        32
index bf5fbcd84238c670ccd7893d77f8ca482153e774..e14e6c486b52ce8eae41db83bc8f6acd0b4ce493 100644 (file)
@@ -12,6 +12,7 @@
  *  GNU General Public License for more details.
  */
 
+#include <linux/slab.h>
 #include <linux/input.h>
 #include <linux/device.h>
 #include <media/ir-core.h>
index 3d03640cf1fe42aab8475419755f9294467e4968..937e4b00d7eea162e9a966f01d8456f41db14587 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 
index 20c4485ce16a642a9724af9efb1cfed2667e64b3..fe5c4b8d83eeddaa203806da48726822e93eeb49 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 
index c7abe3d8f90e1eccdfface5dd7471d3fd0a5fef5..2d0e7689c6a224eae8757c5c054972f1ab03d2a6 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 
index 44608ad4e2d205132e2b9f86cfc62beaddd67fd4..d0e70e10a7178214d8cee4a7892f4c73ea2d232f 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include <linux/delay.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include "tuner-i2c.h"
 #include "mt20xx.h"
index e8d3c48f86059d13aab958f0465346413439b2b8..a4f830bb25d1346a8961f15fd477d64023424604 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 
index 54b18f94b14bc427511a69fd9a116d3197bc98bb..25a8ea342c466d60a767d7d4b4ea622003125add 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 #include "mt2266.h"
index 36a7bc7585ab6c12473033a12ceeb72cb12e4861..b21b6ea68b2501164fa503ac77f6ffb02f9b3aba 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/types.h>
 #include <linux/dvb/frontend.h>
 #include <linux/videodev2.h>
index 2833137fa8195bdc41c8337267bcbee81168082a..c9062ceddc719d25cb05fbe253c1f8d3dc46b8ae 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include "tuner-i2c.h"
index a71c100c95df674c60ff3033624f675f420f14c9..bf14bd79e2fc599b7216e43d0a1c78564479dd7e 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
index 60ed872f3d44681c4e85656dcf38b10fbd77105c..925399dffbed6c4f2820841d2139325edaaf43ed 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include <media/tuner.h>
index 223a226d20a19e6b137a6316913fca8de46fd5c8..36e85d81acb2ca10c953ab83966502c138035392 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include "tuner-i2c.h"
index cb1c7141f0c6d9e96d76110e6ce657ae18148c15..18f005634c676e9789e08e644541cdf650508e79 100644 (file)
@@ -22,6 +22,7 @@
 #define __TUNER_I2C_H__
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 struct tuner_i2c_props {
        u8 addr;
index be51c294b375b5a17a33d8a48e2ab3b4db88e923..96d61707f501cfc28b7caf1136741fcfc415f0aa 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <media/tuner.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "tuner-i2c.h"
 #include "tuner-xc2028.h"
index 0e246eaad05ab441360963e02672945e6d61534b..770243c720d2e3d06a5fb733ff05ba505c0eb88b 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/string.h>
index 383cca378b8c5bb38e8b5935a013405c0bcac315..b6d46961a99e8726954f4adb2381e59fa05d60a3 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <media/ir-common.h>
 
 #include "demux.h"
index c1379b56dfb4d47f4da21caa8c6c399a51c8003e..02ebe28f830d811b9ea7079ad450cc626a6b3863 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <linux/dvb/dmx.h>
 
index 80dda308ff740bf67479f7397d6b107bfac44069..bf0e6bed28dd13bb0b49648a7d73a4dd6e579317 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <linux/dvb/frontend.h>
 
index d7975383d31b58a7257cc42266afb335af6bf8ef..74d94e45324d8d1bc4fe8acdd5533fdc1e640c42 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/hash.h>
+#include <linux/slab.h>
 
 #include "af9015.h"
 #include "af9013.h"
index a7b8405c291e472570958ba713b1712223b37c68..960376da7d59b4e5a23fe3014e9f3a99aca9f95d 100644 (file)
@@ -25,6 +25,7 @@
  */
 #include <media/tuner.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include "cxusb.h"
 
index c3e0ec2dcfca56641b680162e5420ed976d19e4c..26333b4f4d3e9b039460513189383fcf45199745 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
index 599d66e5843dcd51668077ad7404618336d10ae5..fcf3828472b847b537887c8a6f996fe4d2093f79 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/bitops.h>
 #include <linux/input.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
index 956b80f4979ca95af361162ec6adde484a1c9c89..a1fed0fa8ed4905ba8a31b92e2664f66a1c25ac1 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include "dvb_frontend.h"
 #include "au8522.h"
index 0d12763603b47d7bdcb2f4f008fb1eff875f97ae..d4e466a90e43d08d0e3fb6c3a24589ccd8f91857 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 #include "dvb_frontend.h"
index 7eac178f57b2c10093198c653b4e03e332c9e431..65240b7801e83c9dbfed88aa03ec1ea0eb94ff28 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 #include "dvb_frontend.h"
index fa851601e7d4af1baae5312cce3819380df2a523..40a099810279315b3b5502be0db64ddece9f584c 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 #include "dvb_frontend.h"
index 0109720353bd475e6458c347ea42dfca0663d3de..0f09fd31cb293cbcaa2bd5a34414411fca4459da 100644 (file)
@@ -9,6 +9,7 @@
  *     published by the Free Software Foundation, version 2.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 #include "dvb_frontend.h"
index 750ae61a20f4ba7555581f15710f187d584692f6..85468a45c344d96b15c321a250edfa022da38bfd 100644 (file)
@@ -8,6 +8,7 @@
  *     published by the Free Software Foundation, version 2.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 #include "dvb_math.h"
index 2aa97dd6a8afdb71e93b49a1e20b0c6fac32df1c..df17b91b3250b45596619a6a752d63061f4c8a45 100644 (file)
@@ -8,6 +8,7 @@
  *  published by the Free Software Foundation, version 2.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include "dvb_math.h"
 
index 868b78bfae75e4b3cf8e6ba9e11ceec27311e384..f74cca6dc26b278ba657834de7660b93e02de8f2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/delay.h>
 #include <linux/string.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <asm/div64.h>
 
 #include "dvb_frontend.h"
index 6d865d6161d78b33ffe05472de147bdf5360d06b..4d4d0bb5920ac1821dfcc2d2a28de3b016a9573a 100644 (file)
@@ -18,6 +18,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 #include <asm/types.h>
index 600dad6b41ea8a59641bea1bc5bc36b3aea36e71..f7a40a18777a0e13a90dfdc7f4e75ce87a952955 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/dvb/frontend.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 
index e334b5d4e5785d1ad93a07f46d808cbea87edecd..45a529b06b9d31b13531d0181a29259ae54b8f98 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "dvb_frontend.h"
 #include "lgdt3304.h"
index fde8c59700fbee05d63b6b6433adedd7ec9499a9..d69c775f8645419116f13befc0d4476cc2629016 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <asm/div64.h>
 #include <linux/dvb/frontend.h>
+#include <linux/slab.h>
 #include "dvb_math.h"
 #include "lgdt3305.h"
 
index d05f7500e0c514fb966fdc12b2db8824e017ab70..599d1aa519a31ca160306471c237a1ba362a7ba3 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 #include "mb86a16.h"
index 3156b64cfc9642d2d0c7230716091fc70e38d26f..0eefff61cc50cac76952427539bd47445c505e23 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "dvb_frontend.h"
 #include "s921_module.h"
index 1570669837ea72aae6646dd333ee6d9df0418774..8e38fcee564e918bb107c13bda376d1c6e962872 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include <linux/dvb/frontend.h>
index 0e2cb0df144171cffa183a72b813dede4078d026..ed699647050e5eec49422391e98f660d7c9611cf 100644 (file)
@@ -20,6 +20,7 @@
 
   */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 #include <asm/types.h>
index 60ee18a94f43228b74a944cadad7c5ed430301d2..f73c13323e902166e64746e30d67acd12acc419f 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include "dvb_frontend.h"
index c52c3357dc54dc71900f332c8e5c91e4b1f50cd5..a3c07fe0e6c494869f56d98353597cbd5f344713 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 
 #include <linux/dvb/frontend.h>
index bef0cc83847129e25a87f83bcc13c5a39935ba2f..2dca7c8e5148bb989b1e75b7ec5605afdf72851d 100644 (file)
@@ -22,6 +22,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 
index f931ed07e92d6083b088db293e43931f69cbe4b8..dea4245f077c9b2a9fff430a0287bf131ffda3c1 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #include "dvb_frontend.h"
index c44fefe92d97c9614e36876707b72b8bfcadce76..2c1c759a4f42f2ee1b073bba1b4d127da1d00f6b 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 #include "tda665x.h"
index 614afcec05f119c6cea50540d551503a19dbedbc..1742056a34e8c0a8270aee6a81a8ecba4917fc9e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 #include "tda8261.h"
index a051554b5e2589aeb32060ebb0a41c1c38b65e84..06c94800b9402955ccbf799f8ee66e93c2a4f956 100644 (file)
@@ -20,6 +20,7 @@
 
   */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 #include <asm/types.h>
index 1790baee014c4c7cb0f1f3cdf749d386d978ebbc..bcb95c2ef296092dfb50fcc18196cd5204fe97eb 100644 (file)
@@ -28,6 +28,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 #include <asm/types.h>
index 34c5de491d2b416287c1ccdfa05e24a9744be76d..4627f491656bcf90f239ff419a1a627672ddb38f 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include "zl10036.h"
index d073c61e3c0d1101404911ac8fc6db17b0b3fb29..09e9fc785189c2196fb04fe2273efcc4e867a1c3 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <asm/irq.h>
 #include <linux/interrupt.h>
 
index 403ce043d00e7a91b4bf7564806468eb3dbea4ea..330216febd780652ae393d88b31fd9d1e05ebe27 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include <linux/signal.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 
index 16f1708fd3bc9fc28a70c0cac0b6ae9930cda44d..cf4b39ffdaad608dc0e5399def4f74ca63e10543 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <asm/irq.h>
 #include <linux/interrupt.h>
 
index 0150dfe7cfbb9c85c50d04b0e21552ab20e63304..645e8b8a71377664dc3a02e1e80957beaa7c0839 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/io.h>
 #include <asm/div64.h>
index 80d14a065bad0755fda4af3f27edb0b9fbe18308..1c798219dc7ce02205205576b763a25e9da9de66 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include "demux.h"
 #include "dmxdev.h"
index 81e623a90f09d70905ec1080f545f93e1cdd43ec..6aded234aa61daafdeb92de9846eed6d9cb74952 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/pci.h>
 #include <linux/kthread.h>
index 4bfd3451b5682ca5a49a9f6b8fdea2726f554d63..0c87a3c3899ada10eceee75b0cd2ec07be1030fc 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/firmware.h>
 #include <linux/wait.h>
index 5f3939821ca3eef3c786678cc91b9ef5ca326382..b80d09b035a1ad56f5f746213f34cbd289c16262 100644 (file)
@@ -20,6 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************/
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #include "dmxdev.h"
index 195244a3e69b35400df3dd83a9856c76417cef9b..e57d38b0197c65e7c2d64e475a9a7c5b56beef43 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/delay.h>
 #include <linux/mmc/card.h>
index 5eac27287d9ceff598d346348581106466440069..a9c27fb69ba747272393bb033c65d4f48a7e194d 100644 (file)
@@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <linux/init.h>
 #include <linux/usb.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include "smscoreapi.h"
 #include "sms-cards.h"
index baf3159a3aa63cb7f646e867e9463e8221da5ee1..38915591c6e52402938ac193c27739b174ad32f0 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/crc32.h>
 #include <linux/i2c.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <asm/byteorder.h>
 
index c7a65b1544a330e34a2e500883981336ba23c6c4..ac7779c45c5b15e561d70ecc23e3de5b270ff5f5 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/fs.h>
 #include <linux/timer.h>
 #include <linux/poll.h>
+#include <linux/gfp.h>
 
 #include "av7110.h"
 #include "av7110_hw.h"
index 000f4d34087ce2352fbd9c4ae8b47846f49aaa82..79039674a0e0bddff9976de584437a60b948e789 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/errno.h>
 #include <linux/version.h>      /* for KERNEL_VERSION MACRO     */
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 
index f8213b7c8ddc2a6c97ac94e8c52846fe9606711a..08f1051979cae6f7508026dc0e957a23de775795 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/pci.h>
 #include <linux/videodev2.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 
index 44b4dbedb322a57108483494f4785b7b02252076..4349213b403b55944f0ecac6edfbd3fe9e18f2bb 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/videodev2.h>
 #include <linux/version.h>      /* for KERNEL_VERSION MACRO     */
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 
index 170bbe554787b9c54aca8c85ed7186aa70ba3d2f..13554ab13f76afd8c29893aabde59a1c3d5d6a20 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
index 8e718bfcdad3200041b3bf458bf893f26cbedf2e..789d2ec66e1948d2d071c3424f92dc820b0bcc0b 100644 (file)
@@ -32,6 +32,7 @@
  *  add RDS support
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>                        /* Initdata                     */
 #include <linux/videodev2.h>           /* kernel radio structs         */
index 0de457f6e6eb3efe1efe65cdb275c4e498497452..b8bb3ef47df5c72153e7e1964ddbc679b3c1b8ed 100644 (file)
@@ -22,6 +22,7 @@
 #include <media/v4l2-device.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <media/timb_radio.h>
 
index 5db5528a8b2593d53af6a9cfe52a0985f66d01e6..585680ffbfb64b121a4eb01eff27da0346660f6b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 
index 5466015346a10be27b191659ff285d20b7d195bc..a5844d08d8b7917c19702d9f7879a1bc0244aba4 100644 (file)
@@ -31,6 +31,7 @@
 
 /* kernel includes */
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
index 6f60841828dace59eda8b836475dc70a9b35e6c7..5ec13e50a9f0c22a3a81a6900cc2ee426ae14a2c 100644 (file)
@@ -37,6 +37,7 @@
 /* kernel includes */
 #include <linux/usb.h>
 #include <linux/hid.h>
+#include <linux/slab.h>
 
 #include "radio-si470x.h"
 
index 6a0028eb461f91ea767a609c56c09a9732ec2544..ab63dd5b25c44798523f51a6b4d88199b9e95c7a 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-common.h>
index 6e607ff0c1699b4c0366b757f69e3201da75980e..90cae90277e7dc6ea35e170f70d5301914b124dc 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
+#include <linux/slab.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
index 97b003449c91f33e3df579d06f188634031931cd..48e89fbf391b1399ed2662c7d8c4a51cc039f813 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index cf8c06c85ded992adf227ac24d306af3c2813868..f1ba0d742c65a934c2c08b8b0b0713c975f30e7b 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index 0826f0dabc172a72ad2aaa70f931ac2b0b05463a..23e610f6273663b8e46707ed0f31ca6b4f9a5a3f 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
+#include <linux/slab.h>
 #include <media/v4l2-ioctl.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
index df26f2fe44ebd23a5b37abd1efb865b498777bdd..41b2930d0ce4e59640ab946e81db7e234f5aca06 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/device.h>
 #include <linux/delay.h>
index 3544a2f12f13a1497f54ca30609a26e8e9ba8a49..ca342e4c61fcdc5bf59108a5a2bb38ebbbea81b0 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <linux/mutex.h>
index b8a4b52e8d472c3041230d8600d25371f399ba16..f1edf1d4afe8e4c3d1111cb59ff333b18827f679 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/suspend.h>
index dc67bc40f36fb60e4d21973f966a2fab39b64522..8c140c01c5e62e05b155331936ebebd141efe865 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/suspend.h>
index 547e1a93c421d004f78b0adc091eb098bcece593..770cb9accf81c6a55013ea05ab6318790dc8e3e6 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-i2c-drv.h>
index d0b4d4925ff84502e7ea09b0dd26aeecfce9106b..ae333739250552255ec61afdf8d5cb426545c27f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index af7e3a5bac9ff3adf96302f7eb0626137c3a6d04..62ac422bb1596a86527f77bfb6398796bb8216ea 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index cb46e8fa8aaa3b9ce2d64a4d565a47a098950674..f4860f03dfc369d6478d7b132b1d456653b32d99 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
index 74c325e594a2eaf3509b139ef6b46a7a2f4d242a..fd604d32bbb9ae767bde852e94f8111f5633961e 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include "bttvp.h"
index b320dbd635aab0844b69ad2c2a99ed0e5b8b52b7..aa153a986ade3e7e264ab27815dd71db0538af18 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include "bttv.h"
 #include "bttvp.h"
index d16af28363798d45a19336b3d621836b9b9dcb85..c24b1c100e13fe0fb1c225950c6427da7b50db7f 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
index cbbf7e80d2cf856b5de2aed6ab6ca4d14b8d76f9..be35e6965829115a44b3f3a6c9a2ce5f1776ee4c 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-chip-ident.h>
index c431df8248d659199c66da758e6afcd35a918575..f5604c16a0927d5217b83de41ceb2692935c02fb 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/workqueue.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <linux/kmod.h>
 
index 57dc1704b6c000d2bba62df2c398c1fa1b2dce7d..8362db509e2c60610aa334656bc0ee5b370b1ede 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-i2c-drv.h>
index 80bca8df9fbfddbfdf6ed0d4f786dc563206e44b..3cc135a98d827d624c35fda62020857d8da7abc1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index eb41d7ec65b95fc919a5858c6e6f511c7045941d..b5d7cbf4528ab9d0d455e76ab6ff278493f56ec1 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index 93f0dae01350316d9c13110504df129baa4f5ecb..7fa589240ff2ab03ae71a6ad39172fd19a6465bc 100644 (file)
@@ -21,6 +21,7 @@
  *  02111-1307  USA
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "cx18-driver.h"
 #include "cx18-cards.h"
index 23ad6d548dc52c51b45e6cd5ace9371e57f13c2d..b9728e8eee40b7e00cf4dc6d4c0811307045cf01 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/pagemap.h>
 #include <linux/workqueue.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include <linux/dvb/video.h>
index a549082350095311121ba0694045eb55cfdeeb70..6bdc0ef18119716dadc5facc2347f22fda5c6192 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/usb.h>
index 4a60dfbc347deaf06f3e1f0ec707cda91690340b..b24eee115e7e19af226ea70b932685435b1e3282 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/vmalloc.h>
 #include <media/v4l2-common.h>
index 64e025e2bdf1a477b255bd2a0cfcda719568e5da..4ea3776b39fba2a4c46abb0f7c238887184d01ed 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "cx231xx.h"
index c5771db3bfce8d6269113f3c1eb5f4cab2e1ffc6..b473cd8367f59ba170de3b76d187cd725c0a297f 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "cx231xx.h"
 
index e97b8023a6557a8fe15c39c921b0c36038733730..689c5e25776c1f545cf4de9c192bef53a00fa1ae 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/i2c.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
index d4f546f11d7490a833628a4017fa843f6e972b00..16a73eab6726aa9b7b3f1d381c1d0cb42672ba08 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/version.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
index 2ab97ad7b6fb6d26f32fef3dcf3b614666a2a291..a8ddc227cf8643410846737038f92ac892b89015 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/device.h>
 #include <linux/firmware.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/cx2341x.h>
index 9c6620f86dcae8531649001b731718d3a19ecf50..8e9d990dbe9385b223fa5c3d95e1dff5c2a54ecc 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <media/ir-common.h>
 #include <media/v4l2-subdev.h>
 
index 5b297f0323b6485a5099a255d9bf8511414db848..708a8c766d1ad3377bdbce956a62fbe467bef546 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 
 #include "cx23885.h"
 
index 0e3a98d243c5529179dd78dbbb543160def4fec4..8d6a55e54ee7da7b12350a65bedfb135fd62ae1a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 #include <linux/kdev_t.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-device.h>
 #include <media/tuner.h>
index 2bf57a4527d3484167e42ddde0c4bfb7b41d61de..ad728d767d699eba750ebbe5b65915d857a42b50 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/kfifo.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
index 64b350df78e3ab2c1efc7ead7bbe08c6b3183d49..33082c96745ed91d9eb23aceba34562cc66e4c4a 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/vmalloc.h>
 #include <linux/dma-mapping.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <sound/core.h>
index 6fe30e6c426221283c8df5c0984083f7daf6fbcb..e46e1ceef72c3f1f074cad2acc82171b730d3070 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/device.h>
index eaf0ee7de832ecb599e4c95ff31955a15b6fadc6..2918a6e38fe8e5fa9039a0e088c59024443e7f71 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "cx88.h"
 #include "tea5767.h"
index 3e5eaf3fe2a6c05cfaad26d17fe0fbf6d6aafeaf..a94e00a4ac5d7a699d866fbf1ca21f3aafd490c6 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/jiffies.h>
index de180d4d5a2139c3a7c430e484724421df4e305d..6b6abf062c21bd7c08f9fedefd751526b54fbf46 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/hrtimer.h>
 #include <linux/input.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "cx88.h"
index 338af77f7f01f2df2ff8dc9c4f9efb214e616365..6aba7af9160afbdf4137dde92f62629830a4b9dd 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
index e8316cf7f32f70b8e76b78eac4569b205cddf15d..239631568f3b50aa3e5ccbf69853717ba03d8ff6 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/errno.h>
 #include <linux/freezer.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/poll.h>
 #include <linux/signal.h>
index 0943060682bcd4ebf6039f32e3288f3d391fa76b..d9445b0e7ab2e294ca07db9acbdbf25d28cd3944 100644 (file)
@@ -3,7 +3,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 
 #include "cx88.h"
 
index 20800425c51ed5d1f5c4e08f82ecaf183d75deec..794f2932b75554bee6cb1adef6e24e9856b9f74a 100644 (file)
@@ -23,6 +23,7 @@
 */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #include <asm/io.h>
index 0c394cade22a5919173c0ea9b0e612d480f2022b..b4cc96dc99ef46eb358c9f731d27c35c7979fca9 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/uaccess.h>
 #include <linux/videodev2.h>
+#include <linux/gfp.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 
index 885cd54499cf6952abbae826e7526ca5ac186673..7cf042f9b3775b025a4e405aa09a404310db7578 100644 (file)
@@ -67,6 +67,7 @@
  *             - Support for control ioctls
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
index 78130721f578fc9bd310a92ac4b6c63771737b3d..2e5a7fb2d0c9e0e678f9f34f800c3c545611418b 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/version.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 
index dfddef7228dd2c08d40f1b2ec462cec93085a303..13c3a1b9776076d8db80da930f3e01c30f14f49f 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/version.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/page.h>
index ecbcefb08739db90ea57f60db7ebff0b237579e3..b0fb083377107f6b1f7ffc6668c32c5e665823d4 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/usb.h>
index 5a37eccbd7d681001e509539060bea638e16e77d..a41cc55667783e610db233b963605ff85e8909b3 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/vmalloc.h>
 #include <media/v4l2-common.h>
index 1b96356b3ab270c2e195c520b3d455c16092a24d..bcd3c371009b9467ac6cdf4551cc2adc0b858a93 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "em28xx.h"
index 1fb754e208752fa93ec4995740a72dc12abe099e..20a0001e88850c97e3f1282eeb82f1700a5b5d32 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/input.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "em28xx.h"
 
index c7dce39823d89ef9e88438074c5353a6597f853c..7f1c4a2173b68fb4bb6450129c383f8f30fa99d7 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 
 #include "em28xx.h"
 
index ac2bd935927e713e19e0ee67ef861f0154e33a86..0fe20110bfd679404337acded2f2c20df7517d63 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/version.h>
 #include <linux/mm.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include "em28xx.h"
 #include <media/v4l2-common.h>
index 02c696a22be005fb4df1eeb4c052b735c9bb3aa5..8bb242fb79dec93e9f3f4bb05bac0724b4ab6372 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 /* compilation option */
 #define GSPCA_DEBUG 1
index 2019b04f9235261fc92e06b5168ce23ff9b06633..84ecd56c64709d722988008dba531e929ead1027 100644 (file)
@@ -24,6 +24,7 @@
 #define MODULE_NAME "jeilinj"
 
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include "gspca.h"
 #include "jpeg.h"
 
index fbd91545497a8e6b36d36ecae38898664c8e4d34..6b3be4fa2c067be5a9045ea0926f040528608692 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include "m5602_s5k83a.h"
 
 static int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val);
index 4a1bc08f82b9a85719a007912165a3cd25648f65..38a6e15e096b85f42ff999f44a24e8ea6945b1e0 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/freezer.h>
 #include <linux/usb/input.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #endif
 
 #include "gspca.h"
index 83d5773d4629efda315fd96899541aa5f00f1155..1d61b92f6bfc8dc280904aef066249917448971d 100644 (file)
@@ -22,6 +22,7 @@
 #define MODULE_NAME "sonixj"
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include "gspca.h"
 #include "jpeg.h"
 
index 1fcaca6a87f7f161352941ce5d7f4f95f11de64c..09b3f93fa4d6ddfad07accab20f867fa1ae3b20e 100644 (file)
@@ -36,6 +36,7 @@
 #define MODULE_NAME "sq905"
 
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include "gspca.h"
 
 MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, "
index e646620529920d3656e17301777c16d79870bbe6..4c70628ca615e5b16543ffc85ba53f787e744c1d 100644 (file)
@@ -30,6 +30,7 @@
 #define MODULE_NAME "sq905c"
 
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include "gspca.h"
 
 MODULE_AUTHOR("Theodore Kilgore <kilgota@auburn.edu>");
index 50986da3d912038d28c875d9820bea1d0d87d787..7d7814c43f9245f2cb46bed6c1107423f34f5c2b 100644 (file)
@@ -22,6 +22,7 @@
 #define MODULE_NAME "zc3xx"
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include "gspca.h"
 #include "jpeg.h"
 
index 296330a0e1e55cd0dc732680dfa3a79d2c52dcd5..463b81bef6e29585e2c3f0802adc40863f9845f2 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 
 #include "hdpvr.h"
 
index 4a9c8ce0ecb307cc07d167a0c6685bcd3583fefe..b59475bfc243990a7397281ca90ac2c2b9170402 100644 (file)
@@ -18,6 +18,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "ivtv-driver.h"
 #include "ivtv-cards.h"
index e4816da6482b655d9b5be7311a5e1b25cafca036..5028e31c564a9aeed1f395b5a5274c88f61c7439 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/scatterlist.h>
 #include <linux/workqueue.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/byteorder.h>
index fa6bb85cb4b06ebf7626f5dd6557b9d345107bee..de2ff1c6ac3476453ef1c3c59732b81510b959fe 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/kernel.h>
 #include <linux/fb.h>
 #include <linux/ivtvfb.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
index fab8e0254bbc1c7ad7bbd76406df973c24622545..94734828053b92bbec041df93638c3ef9625802e 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/kernel.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-i2c-drv.h>
index d7317e798cc474cb86bbca07a3fc945fbf800502..4491d018eba6518c0e663419bc7e7a3a292f6511 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index b421858ccf907f8fe6a9cc06c62782b11d026ec1..4404e5ef818fdc92159cdbb527a83c3dce576593 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/videodev.h>
+#include <linux/gfp.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <asm/uaccess.h>
index 168bca703614e589cfb02e213f41f8f4d8e6f9ec..d5a69c5ee5e4f45a370ea266b1379f96f4c071bd 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/freezer.h>
 #include <linux/videodev2.h>
index cc85f77a570694e39fc0cc0fbc37eef118a568fa..72e55be0b4abae5fdc59651117613e84c6f4e348 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/delay.h>
 #include <asm/div64.h>
index c167cc3de4928cee1f0a28b1dbade61320d1bcf7..3c8ebfcb742ecbe7704e92e0df2dbd8d453226d1 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/version.h>
 #include <linux/videodev2.h>
index 142c327afb321e053938e5d26b905c08f95843bf..b189fe63394b79a0364d9fd0b3f6dd94dab93a8f 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
index 0e2184ec994efa0ee4b39ed55031e139ecb6de97..aaa50f9b8e7809cfb386a981c060ff955f726764 100644 (file)
@@ -12,6 +12,7 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
index 11a2c26399b53d846945a2afdbc74033a063fc97..0598bbd3f368da323398fedbf378ebedcc21ff3d 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
index 68980e19409f8f4a053388530b2c03d8d9e05e8c..88320900dbd4815affc177264613a474a3b4c206 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 
 struct routing_scheme {
        const int *def;
index 82c13583575350ded7b32edabb8efb2f498a9ca0..2222da8d0ca67cf97985388a6d42e1428e9d4c8e 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 
 
 struct routing_scheme_item {
index ae977668c4969d29fd1e9d983e1b394dbcd9e968..e9b11e119f629f72c001945c39b6f77c38b47798 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include <linux/string.h>
-#include <linux/slab.h>
 #include "pvrusb2-debugifc.h"
 #include "pvrusb2-hdw.h"
 #include "pvrusb2-debug.h"
index b7f5c49b1dbc19f35bc7ce59461d9996cef111a6..8c95793433e79b8d93470e4b9b757dc7ef656dd6 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include "dvbdev.h"
 #include "pvrusb2-debug.h"
index 299afa4fa96953ac804ef778a50cd3329dc6741d..aeed1c2945fb2cb4cd8705777a4747c99d75207b 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include "pvrusb2-eeprom.h"
 #include "pvrusb2-hdw-internal.h"
 #include "pvrusb2-debug.h"
index 8689ddb54420d05c0fb3b4e428aff6647a5ab719..eeacd0f67855d118b49aa8ad5cd4a11bfe9d3ce6 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
 #include <linux/videodev2.h>
index cc8ddb2d2382902bb8e67194e3b79dfeaad0a65c..bf1e0fe9f4d237b9c6feecf53b4a4596e72b85fd 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include "pvrusb2-context.h"
 #include "pvrusb2-hdw.h"
index 4c96cf48c79627125b10cce2178141015c4d03d2..2e205c99eb969933eec6a5de339efecfd48f87ff 100644 (file)
@@ -37,7 +37,6 @@
 #include <media/v4l2-common.h>
 #include <media/saa7115.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 
 struct routing_scheme {
        const int *def;
index 8c1eae05aa08837072c54298e2d136885862022f..3ac8d751a5c0f6b0e19d1599baa66d558423f68e 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 
 void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
 {
index 9e2d91f26bfe065ca6c72ba716d5506929d0c771..0c801b8f3eca5a621f635a63eb8e48238254d851 100644 (file)
@@ -30,6 +30,7 @@
 #include <media/pwc-ioctl.h>
 
 #include <linux/string.h>
+#include <linux/slab.h>
 
 /*
  * USE_LOOKUP_TABLE_TO_CLAMP
index bdb4ced57496c34b45c93709d7a6ddac8a25a97c..62d89b3113a402e04cd00da06ff2c035ffde01d6 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/poll.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <asm/io.h>
 
index 0902355dfa77a3daadaa7f025ac359d66e3171b1..f1b20663295760206202884f2b766e75f8749c30 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/version.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <asm/errno.h>
 #include <linux/videodev.h>
 #include <media/v4l2-common.h>
index 322ac4eecf0ae0cf39b82e33baaa2ef5294a6fe4..5ecc30daef2d96ebf49619c353a3e95f24b0e40b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-common.h>
 #include <media/v4l2-dev.h>
index fb742f1ae711a6a5408586810b1726d6ce208f32..3de914deb8ee6991ec3f0c9a5a8da5d58fba91a9 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/firmware.h>
 #include <linux/kernel.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/version.h>
 #include <linux/mm.h>
index 5ab6a0f901c022e190087926a40173131cdf7348..6b3b09ef89787cbc86830dae1f269c391cd534a3 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/videotext.h>
 #include <linux/videodev2.h>
index 12835fb82c9557c56d09d16825d954dd0d24920e..31ff27df4cbf652d0ff7dd7a604e4c39504852f9 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/delay.h>
 #include <linux/videotext.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-ioctl.h>
index 73739d2a63dd529857461087fd95d60383667599..4ab4a987c9b9593006eced5106f946e8ec6268ed 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
 #include <linux/suspend.h>
index ee5bff02a92cb098a669c2f8204e24da90659bf5..ea877a50f52d9b65963e1edfcf81b81f356b807e 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/delay.h>
 
index 8096dace5f6c77d9b2eafde934300aea74a05f50..da41b6b1e64a2239569256ca3c7eaffef1b43382 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "saa7134-reg.h"
index 9499000f66b6bc8a6e640cfd57ae9d7492a9e821..58a0cdc8414a36a654e8d2e067fd0821e89624ec 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include "saa7134-reg.h"
 #include "saa7134.h"
index b9817d74943fa014b9f4861c58e002dec19dcd43..2e3f4b412d8c8d667efda9fff55b70a6a810acd5 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "saa7134-reg.h"
index 76b16407b01e89ac3b7e0ef8cb8cd94869da0a03..3e7d2fd1688f3b27b669e7e603bd76c04f6958c6 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/freezer.h>
 #include <asm/div64.h>
index cb0304298a96ec27419ba219259012ab021037b4..e9aa94b807f11271d5a0b9c61500566fbed4b508 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 
 #include "saa7134-reg.h"
 #include "saa7134.h"
index 1d487c1503408decf21a9f407ceff3d6fbc048e9..3f1262b00cc0b78c54947bb10538e36a6bb80336 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/wait.h>
+#include <linux/slab.h>
 
 #include "saa7164.h"
 
index 9ca5c83d165b636d410323e21a37bcb808f3a03f..5713f3a4b76c952bf9b1db333bb547caf3e40376 100644 (file)
@@ -19,6 +19,8 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
+
 #include "saa7164.h"
 
 /* The PCI address space for buffer handling looks like this:
index ee0af3534ede39a0e22f9683a81d17e03fb13856..270245d275abe967b7e8ebaf97b87ee6143b61cf 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include "saa7164.h"
 
index 6818df571168660229f743b3183334f20a727dfc..d521c648e15706fa29e2d26dd012330519aaedff 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include <linux/videodev2.h>
index 212baa10829bf4535ed5bd6d396cfd5b14f8c453..77db2039291032a925b2242e96157635db5e28d7 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index fb88c63188f3c02ab7b8930938a0168fbc79a332..6e16b3979326fd2e39b6bfc910df9fa66ef23e1e 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/moduleparam.h>
 #include <linux/time.h>
 #include <linux/version.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/videodev2.h>
index 80f6bfa2632bcb7e5fd140147c10d83e32bd8524..a24174ddec4631b7171e05c06cd64fb0daa253b4 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include <media/soc_camera.h>
index d381fce3db407c6062f73dc4d75162ccb77d5f4a..92d22d8931c130888820e7e163709ba931e0dd12 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
index 1585839bd0bd3d352270a6f1f2caa039a1a00bff..3021a1e6b7bb846910a63b574dca35cbeebce33c 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
index 6bf6bc7dbc7f2540e73090de0ec69c537581c6d2..49dafc5e1e2f584219eefee65b9cbddca47e7ad0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/module.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
index 21781f8a0e8e897da916182f8c1e56241631c51d..61b1dd118364f905078d72ff7a49ffd6a9a07e54 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/device.h>
 #include <linux/delay.h>
index 6f42621ad478a1fc09e2914907ae6797a3b2b0e9..9f8b7da56b671fe2eeee8f942e490dbb8b65c154 100644 (file)
@@ -4,10 +4,10 @@
 #include <linux/sound.h>
 #include <linux/spinlock.h>
 #include <linux/soundcard.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/proc_fs.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 4133aee568bf13e981f958dfef9367c561395830..ebd9cb5bec7429c6251bec628cd91d501796d9ec 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/usb.h>
 #include <linux/dvb/dmx.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include "vendorcmds.h"
 #include <linux/sched.h>
index becfba6a304173d7b89dc1a1033d6f026d8bd12a..cf8f18c007e6cdd65e883f873743f415fbd895f7 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/usb.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
index 07789c64814cf4d133da0b83b84090a730c54721..9ddb32bc7af05164b34be594646bba23eb218406 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index 26b4e718cd6d74226cd0320c1a633cedae16041c..e4815a1806e30e03482c55ca17390f6e4c95ba4c 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 
index 2d38e253f14e395416cbec779ffb6e31452f55ee..908ffb68e926efb87f25a1b4a6322ffecd9c0b37 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/delay.h>
 #include <media/v4l2-device.h>
index 5a878bca02d419da34d0b1369b953d146a0e3e32..4a69bcc738f33069c6cd57136d431e59184e03fe 100644 (file)
@@ -26,6 +26,7 @@
  */
 #include <linux/delay.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <media/tvp7002.h>
 #include <media/v4l2-device.h>
index a07a3fbb51eb8aad3af201289ff9a677e765dc5f..36c0c461d8be8af15d029c38b45ee2174ddca1d2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-i2c-drv.h>
index 6eb0e5b00c3282012c8437d45a3d78fdd6bca068..c5af93b30a2b170f1c66f2a4c17911fe903911d4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-i2c-drv.h>
index a0addcb04295078d758ae95dcf96320b8d1d2fad..562e1d170be0123955d570336e4488b31dd8b43c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/usb/input.h>
+#include <linux/gfp.h>
 
 #include "usbvideo.h"
 
index c4d1b96b5cee3d83e34252a393667c97f4eb9251..fab48ec6c0eae57bc8386766b1aa9603ee0d7469 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/usb/input.h>
+#include <linux/slab.h>
 
 #include "usbvideo.h"
 #include "quickcam_messenger.h"
index e0f91e4ab653ccb975676a908e6f2b11db5eedd0..f7aae2293758eeae3999f247688407a96c61fb95 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/timer.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
index 0613922997e0c588ac1f9e1884b92ba54bc82e77..083765238a6a5d9a34e45df6bd3a9337459b0b34 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
 #include <linux/ioport.h>
index 3b2e7800d56f9a2f134abcbe29670d7b53b3a189..6d3850b37161ed21914deb4f06c7569f549a68ee 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/videodev2.h>
index a814820a3f6ee8fceb812645274dd88210369d7e..86ff8c12ea58f591609819d3347aadcbe79ae027 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/videodev2.h>
 #include <linux/vmalloc.h>
index 1ca6dff7361241069f2a05ba4631bb00ec5b11d5..85019bdacdf757a31952e2602bd074d829fa4169 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/input.h>
 
index 43152aa522271763ca831edf15671bb6efac3b59..7c9ab2933496ea4515f6b0544c561b7769f87052 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/version.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/videodev2.h>
 #include <linux/vmalloc.h>
index 6b0666be370fdb6e6cc23398f2939b5865fa828d..821a9969b7bf8a09fa87044e4a342f574fee53cb 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/videodev2.h>
 #include <linux/vmalloc.h>
index 4b11257c31846759132243f39a7a6a885a9cbff6..7d59c107f13b52baf31661044e5fed9f86fb6ce6 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 
index 22c01097e8a821f95c04ae9d8ae9432623381d46..dce4f3aa4af1adc1f77aee4d58484a6b13b38f40 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/pagemap.h>
 #include <linux/dma-mapping.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <media/videobuf-dma-contig.h>
 
 struct videobuf_dma_contig_memory {
index a56cf0d3a6d618134d70f046059df84919f3b1d0..0afb62e63d99f615d29c76ef508f67209b27d28a 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fs.h>
 #include <linux/kthread.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 
 #include <linux/freezer.h>
 
index a15d1e7cbed8529dc69bbe37304a5eba0ac42523..3eb15f72ac092bc98cce5c9bdc04387fa62f21a1 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/time.h>
 #include <linux/version.h>
index 38e53b303cc35bd836361c9e0652aaec23a67489..ca8303bd2401f06b29b01ec90a24e2d8400c6974 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index 33205d7537d8f59524edb2dc617f54468f642785..77ebcea7c3da6f66dafeeaecf31d406339c25678 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
index dcade619cbd8454db5ba93166064eba0ccf39c35..bf9bf650a317de709506c989a6bb2f342a526250 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/videodev.h>
+#include <linux/slab.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <linux/parport.h>
index b572ce288e14857d2e6f3f9fffe2675a5f111d89..a11b99b4226b86c864595bfbe09a0c8fd78228d8 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index f1f261a35245830b4217268e92b6b34af66d43fd..5c2ba599c0c731735ce5dc08170ae8217723b665 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <asm/uaccess.h>
 #include <linux/i2c.h>
index be70574870de4f5eeda5ed13d6c634c6c7322065..bfcd3aef50f95913aa37244987ddba60f091f053 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include <linux/proc_fs.h>
 #include <linux/i2c.h>
index b3bf1c44d74d92c67452b96e89cf4d9741d68d4f..c00fe8253c517970bca643dcd68bb63e7f4d2e98 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/idr.h>
 #include <linux/fs.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "memstick"
 
index 972b87069d55aad0e6d27eba6b7fbbba55064598..8327e248520ac654596b41560fb51f4d913eedcb 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/hdreg.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/memstick.h>
 
 #define DRIVER_NAME "mspro_block"
index f4a162a4bece30532ca15cf4a4f49e247787b160..f2b894cd8b026b49d9bdd1cec95ef55535abde8d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/highmem.h>
 #include <linux/memstick.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "jmb38x_ms"
 
index 612ab3c51a6b7c9e31ff2eaacd460fa87e09a916..33f7256055b1ae08011122163f18de6c895245a2 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/reboot.h>      /* notifier code */
 #include <linux/workqueue.h>
 #include <linux/sort.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 34f3f36f819befac8ef345e24a3c85abe3e814c9..4fa9665cbe933c5fabb78b33f86037570055a3ff 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #define my_VERSION     MPT_LINUX_VERSION_COMMON
 #define MYNAM          "mptlan"
index c20bbe45da82d4811d57618cb1144fa8af44f662..76687126b573c99082f93e7b7c533e94d1c8f973 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/jiffies.h>
index 4a7d1afcb666aabda50adb4f6122a91a9c824713..6796597dcee0c122be63e927f19ff85f49e796e4 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/kdev_t.h>
index 69f4257419b59d0cce00ec984a33382dae0f785d..e44365193fdf581d963734700d0c5510b967cc78 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/kdev_t.h>
index 2658b1484a2c7ba0480d99ad413087fb70cf523b..fc593fbab6963896446bb4e7e14133186e71af15 100644 (file)
@@ -51,6 +51,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/i2o.h>
 
 #include <linux/mempool.h>
index 3d5f40cd69df2e70d5d1ffee42b91e31d36473e4..11073fa3d9f49106a3c1384e1dfbea23a3c1351c 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/miscdevice.h>
 #include <linux/smp_lock.h>
 #include <linux/compat.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index 949a648f8e2e16c9dcd6447ccbb66d526dbfd088..07dbeaf9df997b1ff6a64ded115062b183ef7e50 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/i2o.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
index ef5ce2676f0534686132caf1534c0a99391d7724..090d2a3a6548e0aa2d56ca5350a6ae2d012945a7 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/i2o.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "core.h"
 
 #define OSM_NAME       "i2o"
index 35ba2ae38b4233d541efed5ae35b7af98586a511..73e4658af53c5216b27c029cdc078ee0d379148e 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/i2o.h>
 #include "core.h"
 
index c37e12bf3004b943cdbcd9d9d7b58936cd9c5687..4a6e7186334e31ce4eccea8b0937312c20b5e29f 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/slab.h>
 
 static inline int pm860x_read_device(struct i2c_client *i2c,
                                     int reg, int bytes, void *dest)
index a2ce3b6af4a21855651055202456772ae21c6900..e4ca5909e4242261ac9a2588954607ec129f18d4 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mutex.h>
 #include <linux/list.h>
 #include <linux/notifier.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/device.h>
index b603469dff698807d961d8dbbcd2d8459014ac2d..2d14655fdebdfb722b57cfaa15f24e798d5fa18c 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/ab3100.h>
index 1c44c19e073a10455e971143df832a9e3dd6a0dc..c275daa3ab1a03bc5a0881993b792f1f89a05eaa 100644 (file)
@@ -15,6 +15,7 @@
  * Interrupt management to be added - TODO.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index b26644772d02fee2fc32ef6dd97ed69d0c052f5b..005532865654b0bbfa036bc873a37858220ffac1 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/err.h>
index 95c1e6bd1729d84c3e176f3990a95655628f6c17..7de708d15d7251e62f490ca1f6eed1b75e8ff098 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 
index e5ffe561739387837a37bd66454ee089b580f4d9..67181b147ab3a2265b1ea27be0fe3a21b6145044 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/mfd/da903x.h>
+#include <linux/slab.h>
 
 #define DA9030_CHIP_ID         0x00
 #define DA9030_EVENT_A         0x01
index df405af968fa2f1f1237b1b45a828249ecde65a1..134c69aa47909142c20a292e61c56ed65267eaf0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/mfd/ezx-pcap.h>
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #define PCAP_ADC_MAXQ          8
 struct pcap_adc_request {
index addb846c1e34940e59400a1bb2b9f7a09471c161..d3e74f8585e0b087507c47618bc344d751c8800c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mfd/htc-egpio.h>
 
index 37b9fdab4f36391a958539560beff8bcd04505a6..594c9a8e25e160b43a90bf8eceea7c5661b2709d 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/spinlock.h>
 #include <linux/htcpld.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 struct htcpld_chip {
        spinlock_t              lock;
index cb73051e43db8ca04e1eabbdafd65af4966f47ef..f04300e05fd611d79e1c0acaf72bf79df57a44b3 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/ds1wm.h>
 #include <linux/mfd/htc-pasic3.h>
+#include <linux/slab.h>
 
 struct pasic3_data {
        void __iomem *mapping;
index c0b883c14f41c15ff5c81084b367b97a13317af0..d9fd8785da4d76a78a9e9a95661d1f93c7d46e72 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/mfd/max8925.h>
+#include <linux/slab.h>
 
 #define RTC_I2C_ADDR           0x68
 #define ADC_I2C_ADDR           0x47
index 62a847e4c2d840f8f6c28c06785a0c49a1604c57..1f68ecadddc24a17ab37d37e6aa6e28cb32dd3d9 100644 (file)
@@ -9,6 +9,7 @@
  * the terms of the GNU General Public License version 2 as published by the
  * Free Software Foundation.
  */
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spi/spi.h>
 #include <linux/mfd/core.h>
index 25842723272858ccaace40d73d02f3c8d2c2d8ab..2dab02d9ac8b6f87168e3e6e1069023f9372fe93 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/mcp.h>
 
index 970afa103261db15172eb189457888ec2adcfd2c..a94b131a18efc72a2a7a6ebb4ec8bce6ef8ada2a 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/delay.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #include <asm/mach/irq.h>
 
index aa17f4bddc56a1a77fee6f1a641e064f3aed1059..8ffbb7a85a7e67091105408f643e170f58bdcb1d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/acpi.h>
 #include <linux/mfd/core.h>
+#include <linux/slab.h>
 
 static int mfd_add_device(struct device *parent, int id,
                          const struct mfd_cell *cell,
index 6d2e8466df1dd804d2943144f9a8564309f76f96..fe8f922f6654b6b43efe26670cdaae96b32c6eb7 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/device.h>
index 03dcc92007070605b2ec0e7f7a8164eeca00183a..63a614d696c1994ab037320b5d8fdbb51e7125c1 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/pcf50633/core.h>
 
index 468fd366d4dabbf3a7c82dc3827e79a0dd6f70d6..497f91b6138edc4dba97ff82c9c1845a83ca6454 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/kernel.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/mmc/host.h>
 #include <linux/mfd/core.h>
index 7b6652f6011731a016597d6540da78ff50d4fa15..bc9275c12133f2817c54dafb04fd1856a54870c1 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/pci.h>
 #include <linux/i2c-gpio.h>
+#include <linux/slab.h>
 
 #include <linux/sm501.h>
 #include <linux/sm501-regs.h>
index 26d9176fca91968b3b450c698bc0dd1e1fca3d8d..da6383a934ac33ac57a39a010f23f94ba1c9daa1 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/irq.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
index 5c7f04343d5c3be1d8ce446d1b2d206df4044915..517f9bcdeaacb4b7435273e3e278d0b703da9cae 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/tmio.h>
 #include <linux/mfd/tc6387xb.h>
+#include <linux/slab.h>
 
 enum {
        TC6387XB_CELL_MMC,
index c59e5c5737d05fb2961eed8528a98e114fa29b2a..fcf9068810fb24eb73af3f05fce1c3e89133e886 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/mfd/tmio.h>
 #include <linux/mfd/tc6393xb.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #define SCR_REVID      0x08            /* b Revision ID        */
 #define SCR_ISR                0x50            /* b Interrupt Status   */
index 1ed44d283803803989295cae91efdc35659bdb14..7f478ec4184b47d8aa0f04b54cbeccf2a418e258 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/pci.h>
 #include <linux/msi.h>
 #include <linux/mfd/core.h>
+#include <linux/slab.h>
 
 #include <linux/timb_gpio.h>
 
index 700b149c1b918251285cd2a0d80582521cf1f976..add6f67d80323a42824709337958fe90df55e443 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
index 9df9a5ad38f9142ebc0c53e58d51541a0a0c133f..202bdd59632d4e90355ea4bf8c733e1ee3719d18 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include <linux/i2c/twl.h>
 
index 85fd9421be94240f30dd35c9f4f6c76bb1c7dfb0..dbe280153f9e769d2c24d9211c5768587c8fb78c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/ucb1400.h>
 
 unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
index 07101e9e1cba14dfc71aaaf4f9300c2660c3e032..a3d5728b64492e6ac3a0fabc1b8fa2fc1862aeb9 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/bcd.h>
 #include <linux/delay.h>
 #include <linux/mfd/core.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/pdata.h>
index bd75807d5302e7f60649bd1b133ee1c75d5e77ba..e400a3bed06374786cf22974097b882e4434d218 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/bug.h>
 #include <linux/device.h>
 #include <linux/delay.h>
index 8d8c932175729621f77b43b360b5fea9871b3b4c..65830f57c093574baace391c8fb8bb78d78c4473 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/wm8350/core.h>
+#include <linux/slab.h>
 
 static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
                                  int bytes, void *dest)
index ecfc8bbe89b9fc37ad03d3bcfa97738d7dcd9d00..865ce013a821fafffd7def52636d45c77900eb8a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/wm8400-private.h>
 #include <linux/mfd/wm8400-audio.h>
+#include <linux/slab.h>
 
 static struct {
        u16  readable;    /* Mask of readable bits */
index 844e1c1b7d9033c22d7c4a4b511031bb76b8f527..cc524df10aa1fad0e8abd7c4d39780954d256e2a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/mfd/core.h>
index 558bf3f2c27698154a6088c43a8daa781577c42b..4afffe610f99d09a34e28790cbf67971012c70ea 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/spinlock.h>
 #include <linux/atmel-ssc.h>
+#include <linux/slab.h>
 
 /* Serialize access to ssc_list and user count */
 static DEFINE_SPINLOCK(user_lock);
index 6aa5294dfec4fc681305b03a63c1f8e63aecf0ee..0f3fb4f03bdf0b93851cfa10156296c6303d7557 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/module.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
index 05dc8a31f2806e181d975981f787edb21196e273..3891124001f28331946b284a22564e15b029ce6a 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 /* Number of bytes to reserve for the iomem resource */
 #define ATMEL_TC_IOMEM_SIZE    256
index b5346b4db91a2021d43c470b09bd53fbdc7a4170..ed090e77c9cd4d65fec1402972f59bd84246c60b 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/idr.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <linux/c2port.h>
 
@@ -912,8 +913,8 @@ struct c2port_device *c2port_device_register(char *name,
 
        c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
                                        "c2port%d", id);
-       if (unlikely(!c2dev->dev)) {
-               ret = -ENOMEM;
+       if (unlikely(IS_ERR(c2dev->dev))) {
+               ret = PTR_ERR(c2dev->dev);
                goto error_device_create;
        }
        dev_set_drvdata(c2dev->dev, c2dev);
index b14eab0f2ba584b77e226b68ab335c65478d389e..efec4139c3f68f512cded3fd51631e7097895d19 100644 (file)
@@ -9,11 +9,11 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/idr.h>
 #include <linux/cb710.h>
+#include <linux/gfp.h>
 
 static DEFINE_IDA(cb710_ida);
 static DEFINE_SPINLOCK(cb710_ida_lock);
index 02358d086e030e6a25b56561f8613cd864b7eb24..fcb3b8e30c528c4202736a50fa2c1e34a1779c6c 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/cb710.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 
 #define CB710_REG_COUNT                0x80
 
index 8110460558ff96c4e698f04666a96a84d8356f34..9bec24db4d41385efe8a1c891f0a6e9daf072488 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/cs5535.h>
+#include <linux/slab.h>
 
 #define DRV_NAME "cs5535-mfgpt"
 #define MFGPT_BAR 2
index f3ee4a1abb7714fa2dca513043dce44947d8b962..9197cfc550158b532be740c914d7b64c1ee1b435 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/string.h>
 #include <linux/list.h>
index 1eac626e710a38dddab8673b1cc5f751a1df7366..48c84a58163e460b36ac68c7951b55e01f06bc09 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 static LIST_HEAD(container_list);
 static DEFINE_MUTEX(container_list_lock);
index ba4694169d796ca97580ffcbb1c4791b325f026b..46b3439673e9036ed9f46e4a275819c7e45da061 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
index a92a3a742b439fdf2e6277929ccdd5ed3fff2dcf..98ad0120aa9bc6a134af1a5da728f0c6d8f9c8c8 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 #include <linux/wait.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include "hpilo.h"
 
 static struct class *ilo_class;
index e2031739aa29fda4a188d4ac35101bc9f7439ee0..5c766b4fb2380763011ae6a05b10bf4fd997d5e4 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "ibmasm.h"
 #include "lowlevel.h"
 
index 572d41ffc186a37fbd4d90dbea14554570681ecf..76bfda1ffaa9106adbc41d65d42ffae086284456 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "ibmasm.h"
 #include "lowlevel.h"
 
index aecf40ecb3a4f560a57cc699094c80f7fd194f50..8844a3f45381e8bd34c2a13901f77810fe87aa95 100644 (file)
@@ -75,6 +75,7 @@
 
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include "ibmasm.h"
index dc14b0b9cbfa27ff0bfb0cc2e97ed93e0e8d52a7..a234d965243bcb8b1e42024a41259955dc7b7347 100644 (file)
@@ -52,6 +52,7 @@
 
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include "ibmasm.h"
 #include "lowlevel.h"
 #include "remote.h"
index 395a4ea64e9cd81623abc06be926d5f3e4eadd6b..152e9d93eecb2881fa5b804f791ef6db7b74ed6b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END };
index 09dcb699e6674e4ba5d3301149be994fcf17c46d..193206602d88946112f02e189bee1ee9b2b2ab65 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include <linux/ioc4.h>
 #include <linux/ktime.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/time.h>
 #include <asm/io.h>
index 0c8ea0a1c8a3197c5a7edd53d408ec58901617e7..e9eda471f6e0fd9ee4e2781e8d9176761a752591 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/mmc/sdio_func.h>
index 9dbaeb574e6380c936381a781617cde8bb8c9412..e27afde6e99f056c39f24419d753b90fb3acde15 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/firmware.h>
 #include <linux/mmc/sdio_func.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "iwmc3200top.h"
index d569279698f654dc76ab2dba27ee1fe55742eadd..a36a55a49cac7855eaaa597acab0d0c380ed1e41 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/kernel.h>
 #include <linux/mmc/sdio_func.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 #include "fw-msg.h"
 #include "iwmc3200top.h"
index 3b7292a5cea95916cdf4574393c6664a38bc648b..c73cef2c3c5e076a94501967a824a0df953bff1d 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/debugfs.h>
index fcb6ec1af173dfe22e3130ef6016f348c3f24858..72450237a0f418e0a41552cbdefd7943545add78 100644 (file)
@@ -295,6 +295,10 @@ static int check_and_rewind_pc(char *put_str, char *arg)
        /* On x86 a breakpoint stop requires it to be decremented */
        if (addr + 1 == kgdbts_regs.ip)
                offset = -1;
+#elif defined(CONFIG_SUPERH)
+       /* On SUPERH a breakpoint stop requires it to be decremented */
+       if (addr + 2 == kgdbts_regs.pc)
+               offset = -2;
 #endif
        if (strcmp(arg, "silent") &&
                instruction_pointer(&kgdbts_regs) + offset != addr) {
@@ -305,6 +309,8 @@ static int check_and_rewind_pc(char *put_str, char *arg)
 #ifdef CONFIG_X86
        /* On x86 adjust the instruction pointer if needed */
        kgdbts_regs.ip += offset;
+#elif defined(CONFIG_SUPERH)
+       kgdbts_regs.pc += offset;
 #endif
        return 0;
 }
index 4a0648301fdfc4af0762c76e891ad3cfa0c3de9d..31a991161f0a0f984ab73354d1281ccf8aa4943b 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/hrtimer.h>
+#include <linux/slab.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/debugfs.h>
 
index 779aa8ebe4cfc2ab3f4f5108a8a8e4b966075b74..75ee0d3f6f457707d79cbf5f5d021469710eb06d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/poll.h>
 #include <linux/interrupt.h>
 #include <linux/cdev.h>
+#include <linux/slab.h>
 #include <linux/phantom.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
index 832ed4c88cf759f022cca50021055e67142eb725..8d082b46426b756681c0590581501b8d8cac198a 100644 (file)
@@ -44,6 +44,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/device.h>
 #include <linux/delay.h>
index 9a6268c89fddc0c49f65001941e13d045a5063a5..d551f09ccb792175d49a83c4a929df7394f50a8a 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/device.h>
 #include <linux/hardirq.h>
+#include <linux/slab.h>
 #include "xpc.h"
 #include <asm/uv/uv_hub.h>
 
index 8b70e03f939f9c0a78f3708a0393b46d8f61e8c8..7d71c04fc938873fa1798dfcc0e6a6b7a043346a 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/uncached.h>
 #include <asm/sn/mspec.h>
 #include <asm/sn/sn_sal.h>
index 8725d5e8ab0c29bff2f6ab27fbacbc33891b48aa..1f59ee2226ca4220e470842326ec64fba62377a2 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <asm/uv/uv_hub.h>
 #if defined CONFIG_X86_64
 #include <asm/uv/bios.h>
index 57b152f8d1b9c8dc1a90a09af32f8bdb8bfd874d..ee5109a3cd984f287c824fd71d3221ead361bccd 100644 (file)
@@ -20,6 +20,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
index 98bcba521da2ab6c8d658f07a547476a51b3326c..5f6852dff40bd3d04d82704e59ae4ef0335d3491 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/tifm.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/idr.h>
 
index 1f552c6e7579b5a42a665e89a69b5e7f798d161c..cb9fbc83b09095f8a0aa77572c0e9304641f300b 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/hdreg.h>
 #include <linux/kdev_t.h>
index e7f8027165e697b3f2a1ef3926f2ce0b3e2153f1..445d7db2277e4c91fbf9770cff6d1b04ddc76a5a 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
+#include <linux/slab.h>
 
 #include <linux/scatterlist.h>
 
index 381fe032caa129039c89da492a0b092f5540aed1..d6ded247d941197734c289e36f665a2bdeb96737 100644 (file)
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  *
  */
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
 #include <linux/freezer.h>
index 723e50894db9c769a08235aa99cca0ce630f1e57..a0716967b7c867f4cd6a88003b41678de69cd22a 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/serial_reg.h>
 #include <linux/circ_buf.h>
-#include <linux/gfp.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/kfifo.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/core.h>
 #include <linux/mmc/card.h>
index bdb165f93046f9cdce780a614ddafcc41f3cab91..49d9dcaeca493ddea3b108e98a06315a9c3768c6 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
index 96d10f40fb23e1ba6db97359c53c4e6a8415660f..53cb380c0987d9d5e460828c801e2f25790c1f40 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 
 #include <linux/mmc/card.h>
index a268d12f1af0d0276787642ff4728060a1ab2624..47353909e345caaafa8a37f51a535fc734d5af4c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/idr.h>
 #include <linux/pagemap.h>
 #include <linux/leds.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/host.h>
 
index 0eac6c81490462fb640d768edbbdec54659510fa..89f7a25b7ac12ab17f7baa9a18e0d980fe1c50eb 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
@@ -225,7 +226,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
                        mmc_card_set_blockaddr(card);
        }
 
-       switch (ext_csd[EXT_CSD_CARD_TYPE]) {
+       switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) {
        case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
                card->ext_csd.hs_max_dtr = 52000000;
                break;
@@ -237,7 +238,6 @@ static int mmc_read_ext_csd(struct mmc_card *card)
                printk(KERN_WARNING "%s: card is mmc v4 but doesn't "
                        "support any high-speed modes.\n",
                        mmc_hostname(card->host));
-               goto out;
        }
 
        if (card->ext_csd.rev >= 3) {
index d2cb5c6343920371e6c6ba367a3b8c14a1282b4c..326447c9ede8aa5a9153f8019a47f706f20917ec 100644 (file)
@@ -9,6 +9,7 @@
  * your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/scatterlist.h>
 
index fdd414eded09a9eef14968a59d026e369c046aa5..5eac21df4809feb070a2c5943c5c3a45538c8288 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
index 9e060c87e64db6775fc5aa7b8aa07033dae7e365..4a890dcb95ab413c14ac5a457036d57a1ea6b1b0 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
index 9538389783c10e17d4494e875499c302b93ed01b..541bdb89e0c5e03cadcbad743bea8814542446d4 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
index 91dc60cd032b37b676226f508d87329b6af065ae..a6dd7da37357a11667755d22d6898df8e3fc97e9 100644 (file)
@@ -65,6 +65,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/clk.h>
 #include <linux/atmel_pdc.h>
+#include <linux/gfp.h>
 
 #include <linux/mmc/host.h>
 
index 8072128e933b80a8ff6f68f2ed160a964ed04bc2..88be37d9e9a565c831c7d5ddf4e8832e96f5e899 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 
 #include <linux/mmc/host.h>
index 57b21198828fbd18ad8ac980b667b7e9dc41b2a6..f5834449400e0b06d6cd4d60f85c9ce4d303705a 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/scatterlist.h>
 #include <linux/leds.h>
 #include <linux/mmc/host.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/mach-au1x00/au1000.h>
index 56f7b448b9112e8360e4d31c2178431243d545bd..6919e844072c9dbf683359764ea6fe55a763906b 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mmc/host.h>
 #include <linux/proc_fs.h>
+#include <linux/gfp.h>
 
 #include <asm/cacheflush.h>
 #include <asm/dma.h>
index 4e72964a7b431345c37cd0868056de1145b1c76f..92a324f7417c3eb0a710a19fcd47b1f792b067f7 100644 (file)
@@ -9,7 +9,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include "cb710-mmc.h"
index d55fe4fb793559430c9557a9e67f2e43c402f9d8..ad847a24a6756f8f88ec97f6ea8031b8a7169842 100644 (file)
@@ -26,6 +26,7 @@
  */
 #include <linux/sched.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/bio.h>
 #include <linux/dma-mapping.h>
 #include <linux/crc7.h>
index 4c068e5fe6b2502ec45df9c9edd60a462b5fc0e7..04ae884383f690d6fdc41cae87da020afbbbfad9 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/debugfs.h>
 #include <linux/io.h>
 #include <linux/memory.h>
+#include <linux/gfp.h>
 
 #include <asm/cacheflush.h>
 #include <asm/div64.h>
index 0c7a63c1f12f4c9aeed7679b28da66e1a5f9a9b8..bb6cc54b558ee235f17b28990f5e80da8304f2b6 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
index c6d7e8ecadbf586691d484cdbf7b94b7f4550913..84d280406341f1bf071e07430e6118766cea87c5 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/clk.h>
 #include <linux/scatterlist.h>
 #include <linux/i2c/tps65010.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 0d783f3e79edf609f2297c7eaab42240d678feb0..0ed48959b590e81b3e6e9a8754fc7da23df0bc26 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/io.h>
 #include <linux/regulator/consumer.h>
 #include <linux/gpio.h>
+#include <linux/gfp.h>
 
 #include <asm/sizes.h>
 
index 8e1020cf73f42dfdeb85c1e9abe0a65f5b2b259f..6701af629c30e3b8c0fb86c606f546cddf7519b7 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/highmem.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <linux/mmc/host.h>
 
index 50997d2a63e7effcd533d9d95fea45b9ebf34efc..2136794c0cfaf66fed55c5433f8e4bc574e19604 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/clk.h>
 #include <linux/io.h>
 
index d6ab62d539fb2aa03f084eee2a305fcee3d5bd84..9d4fdfa685e57521a711c29904c100a66df4cd48 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/scatterlist.h>
 
 #include <linux/leds.h>
index 89bf8cd25cacec9a6df3d9d231a429c82ce36e40..69efe01eece829cb2f0011b8771471d91245818a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/highmem.h>
 #include <linux/mmc/host.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 8c295f40d2acfd3dde7f2cab8c753a01a2c07aff..ce6424008ed9c38bbb11e2794a0522592ae7f948 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/buffer_head.h>
 #include <linux/mutex.h>
 #include <linux/mount.h>
+#include <linux/slab.h>
 
 #define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
 #define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)
index f3f4768d6e18df89ba99e4efc5723c5e6593715d..81e49a9b017e32efd4137618c5ad4593e18c3658 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/mod_devicetable.h>
 
index 0a11721f146e0857947af8fddbdcd49b8f318d7c..fe17054ee2fe69c4190b38f26afde0a6620c861d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include <linux/mtd/mtd.h>
index e22ca49583e78beb9f2b7609ae76c963d8b4737b..a73ee12aad81387f44032203e1f63bbdf7caf48b 100644 (file)
@@ -26,6 +26,7 @@
  */
 #include <linux/mtd/pfow.h>
 #include <linux/mtd/qinfo.h>
+#include <linux/slab.h>
 
 static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,
                                        size_t *retlen, u_char *buf);
index 237733d094c41feb17170d97ff1a72ce7c657350..19fe92db0c46fb90051c97146be5a170dff46a9a 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index a7c808b577d376a5f99edc98adcf5dd49cc2cba0..c0fd99b0c525d7173674cadf017ab43e1b8ad361 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <asm/blackfin.h>
index 424f17d6ffd1270bfae71befae6975781814f168..ddb462bea9b51727593cdb5c67ca809f5807edeb 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 11a2f57df9cf5d8c87f0a5f907a239d409f7e544..d12c93dc1aad9aa843decb459f6d4964fbe24eff 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 1ad5caf9fe693e2fbf500f626bc65ad50c5fbe8d..32e89d773b4ead7dbaa6172e331fb6c9f11f17ec 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); })
index c32bc28920b35fe3927f960a528a52fd2f6fa5c6..f102bf243a7418b5482b71ec8833ea205fc50355 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 1e7814ae212a2eb372b9d3ad7791f0be1baa18e8..fc1998512eb407bd26e9cf235cbf8a2f92ecfa26 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/mtd/mtd.h>
index 2b2e45093218fca47a36a80fba14f6505421e67c..23fe1786770f140c686215cc05925a5d4f6c2d8d 100644 (file)
@@ -24,7 +24,6 @@
    ##################################################################### */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <asm/io.h>
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
deleted file mode 100644 (file)
index e69de29..0000000
index 61e4eb48bb2d5a37dfad765e3399e3b22d6270f9..101ee6ead05c16af55f34434df390ba859bcd27b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mtd/concat.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 struct of_flash_list {
        struct mtd_info *mtd;
index 30e12c88d1dae5b98bb3098628ac4b3db9c738a0..60c068db452d8678718790947340464ad61acc58 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
index c8fd8da4bc8780407b7b5e07a633da68c1909572..acb13fa5001ca7a14c3f872be849b7cc6001c722 100644 (file)
@@ -28,6 +28,7 @@
  *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
index b13f6417b5b262a81b149713184fe4de9364bea9..91dc6331053f512fc881ee6b28376da93616c294 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
index 1b1c0b7e11ef410e64921cdb34db049d86968183..04b2781fc6278ba852b47f4e7208f3dc228e6209 100644 (file)
@@ -45,7 +45,6 @@ separate MTD devices.
 // Includes
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <asm/io.h>
index fd7a1017399a069da8f8e78dd62a08d1ad6dcf3e..fadc4c45b455aaabfab873d35c09a1e7c05c1960 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/ioport.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
index 6d452dcdfe34756656e2014739ccdabeb9d29064..6adaa6acc1936716ad74e063613c84abe7c5d856 100644 (file)
@@ -16,7 +16,6 @@
    ##################################################################### */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
index 82afad0ddd726ca0efd0dbaa6e6a0c040219d718..4afc167731ef5e980383d0f442c9417ab58494f4 100644 (file)
@@ -8,6 +8,7 @@
  * GNU General Public Licence
  */
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/maple.h>
index c356c0a30c3e46b82d5dca258491390494098c82..5b38b17d222936863054189e3a0c7b8ff3534aeb 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/major.h>
index 7d1cca7a31a9ec7ff6d5880dd5bc1853518ca2cf..c997f98eeb3de717730fc3aee2395a9c61e7f31b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
 #include <linux/device.h>
index c828d9ac7bd71a7709fac3ea16bd1e9419e062f6..e5a9f9ccea60ff48b376a59eaf9a1d84c91434fd 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #define CAFE_NAND_CTRL1                0x00
index 826cacffcefc81b94229bcb77334603839b3460c..6e6495278258f040e51bcfc1e41f6b0f6d45f1d2 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 
 #include <asm/io.h>
index fe3eba87de40687225658d2aea50f1760b15de1f..76e2dc8e62f71b7fbabc73c2b5078d9184be75c4 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/io.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/slab.h>
 
 #include <mach/nand.h>
 
index b126cf8874763b318fa2d045ff33e96b60b08594..47067bc98248bec58f547e72d89713961ff89983 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/rslib.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include <linux/mtd/mtd.h>
index 071a60cb42041b4d660189a1b01223a17b081b00..4b96296af321e5d5e0dba823b1e1ed7568943279 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/fsl_lbc.h>
 
 #define FSL_UPM_WAIT_RUN_PATTERN  0x1
index 40b5658bdbe6f39ae574fb8b41257c64c17c14b5..b983cae8c298288a2d2942e4170114f047182559 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mtd/nand_ecc.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/ndfc.h>
+#include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <linux/of_platform.h>
 #include <asm/io.h>
index 66123419f65d4561f4912a60e68d499d9e0406e7..1f6f741af5da786cd101d6e13ebcdb89059dfb0a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/mtd/partitions.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <mach/nand.h>
 #include <mach/fsmc.h>
 
index 26aec00801848590333a62252599c5406a345904..7545568fce479dda7f12d31383948fb23ca5d321 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <plat/dma.h>
 #include <plat/gpmc.h>
index 1a5a0365c9835784d38b635f1fa87bc46fb62924..5d55152162cf5c4e2e09b738535388f55cf4b512 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 #include <mach/dma.h>
 #include <plat/pxa3xx_nand.h>
index 1842df8bdd934fcec9955f445984af556ebf13bb..34752fce079305b6f41a73bcead9ed18d1166d1c 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
index 92c73344a669eebbd56f2b450161260d07872409..fa28f01ae009439d24f7332109e682e2e8a5c346 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand_ecc.h>
 #include <linux/mtd/partitions.h>
+#include <linux/slab.h>
 
 /*--------------------------------------------------------------------------*/
 
index 62d6a78c4eeea43ae34aac65508d270b163b985d..4f0d635674f334a0dd5d1699edff8659f82451d0 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
 int __devinit of_mtd_parse_partitions(struct device *dev,
index 75f38b95811ea729b0e9f2494399253d93ed8472..fd406348fdfd5b269cbadb8c10de362320ba4bb7 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/mach/flash.h>
 #include <plat/gpmc.h>
index f63b1db3ffb3f0266658a787bc59dd09dd7f2a2a..32f0ed33afe09bdc776f84b644944ea6d4e79622 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
index f6e3c8aebd3a107b43c711a05fdebcdc283e05f8..8b246061d511ad5c7ed1cd4f6f833833863e6ee5 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/vmalloc.h>
index c1f31051784c895a244aeef144f20ff5f0cddd70..70d6d7d0d65696b5cae7b5a1dd2aa57674a6f264 100644 (file)
@@ -1,7 +1,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/list.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/string.h>
 #include <linux/bitops.h>
index 5813920e79a5f346278247de54990a03062e91c8..dec92ae6111a190b0ad8493ad5098c996a7a0616 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_oobtest: "
index ce17cbe918c5a1e4fe411a51eb7d92eafa22308e..921a85df9196fafa08393da12ffb46407e8fb5d7 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_pagetest: "
index 25c5dd03a8373c93a692578ffb1a0724dcd2b33e..7107fccbc7dec049b72585e1ab38a4f330145ea9 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_readtest: "
index 7fbb51d4eabec7897811265d0fba5ee0e2ee1369..56ca62bb96bf5e14e0a2a60a624717900b0033d7 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_speedtest: "
index a99d3cd737d82caf30ffcce266bebdd56fa9e0f5..3854afec56d0575b65d00c824d898c2347d69529 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/vmalloc.h>
 
index 5b889724268ed020a04fcf0d9732aa6daf9743fe..700237a3d120ecc2169a0329eedc42c8cf2cec0d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_subpagetest: "
index 631a0ab3a33c506ef575fff3b5e5fd1769f3e6f6..5c6c3d2489014960056a5f27916a8c2924810549 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/moduleparam.h>
 #include <linux/err.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #define PRINT_PREF KERN_INFO "mtd_torturetest: "
index fad40aa6f099c3070c64d8ba9c7321e20fcb88db..55c726dde9427838a8ab6501b32f74acd18a43a1 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/kthread.h>
 #include <linux/reboot.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include "ubi.h"
 
 /* Maximum length of the 'mtd=' parameter */
index 111ea41c4ecd7aa956be1f21c26d775dc68270e4..72ebb3f06b86b835658870247cdf582b61724704 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <linux/module.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/ioctl.h>
 #include <linux/capability.h>
 #include <linux/uaccess.h>
index b5e478fa26612b188aa664541503457b2e58d2af..9aa81584c8a29dc4afbbba437613c85b51f60ca8 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/err.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/math64.h>
 #include <linux/module.h>
index b4ecc84c75490dea7405dea6198b3e1614339585..533b1a4b9af16bc2df1d7153b7d51ea80e6e8d06 100644 (file)
@@ -88,6 +88,7 @@
 
 #include <linux/crc32.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include "ubi.h"
 
 #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
index 1361574e2b00157bb2ab98fcc1be6254b1e002f9..17f287decc36dfba8a291122bda31a5e44d4c5f2 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/fs.h>
 #include <asm/div64.h>
index 594184bbd56a816526129d432a9522306ac92e70..dc5f688699dad6ab3db196e684092a495d7cfb09 100644 (file)
@@ -41,6 +41,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/crc32.h>
 #include <linux/math64.h>
 #include "ubi.h"
index 1af08178defd57bc346f9056f57f7b5816bba9ff..5176d4886518fa12a9b2ac5bab24e986484ce543 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
 #include <linux/notifier.h>
index ab64cb56df6e11c3bce686035bc5ac34251a6374..e42afab9a9fe2c290585a0f3111ca2543581a7ee 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/err.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 #include "ubi.h"
 
 #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
index 40044028d6824e217a6e5f5cbe9e1ea232a291f8..cd90ff3b76b139b5d8971dbc537da3cd6614d4dc 100644 (file)
@@ -58,6 +58,7 @@
 
 #include <linux/crc32.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <asm/div64.h>
 #include "ubi.h"
 
index b6de7b1e2a5cbaeff1ae9caf47b13836e4f63244..3ea42ff176577900c734b5e9d7bbd67973a1d324 100644 (file)
@@ -117,7 +117,6 @@ static const char version[] =
 #include <linux/fcntl.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/spinlock.h>
index 04b5bba19021c8c93f340b0aa814dc93e3305a60..29b8d1d63bdeacdfb6cc7b432590216a448ab7e5 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
index 77cf0901a441146b99292755353d25bfd50222ae..b32b7a1710b735dd3a074d4073baf94b3256b301 100644 (file)
@@ -58,7 +58,6 @@ static const char version[] =
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
 
index 902435a7646664e61aa870656dcc446c85b26a67..ab9bb3c520020f3a047181c58f957aadddd58f7a 100644 (file)
@@ -76,7 +76,6 @@
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
index 1e898b1c80682ab190434b3f02cb82dca55332d6..2e17837be546b2d5f0a90e7984ae80a4fc15ea6c 100644 (file)
@@ -65,7 +65,6 @@ static int max_interrupt_work = 20;
 #include <linux/errno.h>
 #include <linux/in.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/etherdevice.h>
 #include <linux/interrupt.h>
index beed4fa10c6e69662057c83ee5d55912f50c1782..1719079cc498f86c0289e904c3f54ce16fcbf824 100644 (file)
@@ -99,7 +99,6 @@
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/mca-legacy.h>
index f965431f4924f16b6599cb52e8c504460651a7df..5f92fdbe66e2d3d43ab79f839e408adfd3978c6e 100644 (file)
@@ -77,7 +77,6 @@ static int vortex_debug = 1;
 #include <linux/errno.h>
 #include <linux/in.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/mii.h>
@@ -90,6 +89,7 @@ static int vortex_debug = 1;
 #include <linux/eisa.h>
 #include <linux/bitops.h>
 #include <linux/jiffies.h>
+#include <linux/gfp.h>
 #include <asm/irq.h>                   /* For nr_irqs only. */
 #include <asm/io.h>
 #include <asm/uaccess.h>
index 4e9a5a20b6a671941c0f4dfb5d1a627bf50b0f52..500e135723bd0f8ab4f0d031eba8db02f2d03c30 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/ioport.h>
 #include <linux/in.h>
 #include <linux/route.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
 #include <asm/irq.h>
index 3d4406b1665814b64b31d06e9d29eba20f9b459d..a09e6ce3eaa0a66f12b6efd93652bf8a2b2b2e23 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/ethtool.h>
+#include <linux/gfp.h>
 #include <linux/mii.h>
 #include <linux/if_vlan.h>
 #include <linux/crc32.h>
index b4efc913978bb2330cc1040519d52cbcaad01fa4..a03d291de8548e1f23f77726830e6df838540f5e 100644 (file)
 #include <linux/crc32.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
+#include <linux/gfp.h>
 #include <asm/irq.h>
 
 #define RTL8139_DRIVER_NAME   DRV_NAME " Fast Ethernet driver " DRV_VERSION
index f94d17d78bb0a6145d66389870dd0dfd1c8078ec..56e68db488610d4375445481c53bc1a189e9de86 100644 (file)
@@ -45,7 +45,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
@@ -53,6 +52,7 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 0ba5b8e50a7cde9fba5ba976e656682dedfa2164..7b832c727f873b6964b1faa1c121a73796b113e4 100644 (file)
@@ -2582,6 +2582,31 @@ config CHELSIO_T3
          To compile this driver as a module, choose M here: the module
          will be called cxgb3.
 
+config CHELSIO_T4_DEPENDS
+       tristate
+       depends on PCI && INET
+       default y
+
+config CHELSIO_T4
+       tristate "Chelsio Communications T4 Ethernet support"
+       depends on CHELSIO_T4_DEPENDS
+       select FW_LOADER
+       select MDIO
+       help
+         This driver supports Chelsio T4-based gigabit and 10Gb Ethernet
+         adapters.
+
+         For general information about Chelsio and our products, visit
+         our website at <http://www.chelsio.com>.
+
+         For customer support, please visit our customer support page at
+         <http://www.chelsio.com/support.htm>.
+
+         Please send feedback to <linux-bugs@chelsio.com>.
+
+         To compile this driver as a module choose M here; the module
+         will be called cxgb4.
+
 config EHEA
        tristate "eHEA Ethernet support"
        depends on IBMEBUS && INET && SPARSEMEM
index 478886234c285dd43ff082ab2d170c469df89233..a583b50d9de8bd4402fccefed7ae6effa6ff4ff8 100644 (file)
@@ -19,6 +19,7 @@ obj-$(CONFIG_IXGB) += ixgb/
 obj-$(CONFIG_IP1000) += ipg.o
 obj-$(CONFIG_CHELSIO_T1) += chelsio/
 obj-$(CONFIG_CHELSIO_T3) += cxgb3/
+obj-$(CONFIG_CHELSIO_T4) += cxgb4/
 obj-$(CONFIG_EHEA) += ehea/
 obj-$(CONFIG_CAN) += can/
 obj-$(CONFIG_BONDING) += bonding/
index bd4d829eca129cc93acb5f5f2c20728a3105a471..ed5e9742be2c5c18d44f72c07dde4b26a9a4a046 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
index 4ae750ef1e104c28991df24453b9bcc492820e3a..97a3dfd94dfa4878dc84c28ce0d1e710e46a816d 100644 (file)
@@ -67,6 +67,7 @@
 #include <linux/highmem.h>
 #include <linux/sockios.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 #include <linux/if_vlan.h>
index b8a59d255b49882313069d020e980b92db14899b..8d58f0a8f42f74f16fa06a388aaf80a4434a557d 100644 (file)
@@ -73,7 +73,6 @@ Revision History:
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/compiler.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
index 73b38c204eb91872df4c16e0bbebf2acac3fe052..6f8d6206b5c483a6bbac6102a57a0a96813bcb59 100644 (file)
@@ -56,7 +56,6 @@ static const char *version =
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index eb0448b03f413d10620c93b06310b98318df7634..79636ee35829f60fff841a677db4065bd5231064 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/ip.h>
 #include <linux/atalk.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/route.h>
 #include <asm/uaccess.h>
 
index 8ea4ec705bef1a1f9934801f451d678d023c3f7c..6af65b656f31e7e6e64a7234a53e385bc23168a3 100644 (file)
@@ -215,7 +215,6 @@ static int dma;
 #include <linux/ioport.h>
 #include <linux/spinlock.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -228,6 +227,7 @@ static int dma;
 #include <linux/timer.h>
 #include <linux/atalk.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/dma.h>
index 8ea9c7545c12b815dc899ec64e00de1e56d95c59..705e6ce2eb90b9debb4e635af396ddfdbb53a594 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/if_arp.h>
 #include <net/arp.h>
index e6afab2455b1ebe1e5cf30f95f23a14d091544ef..9efbbbae47ca966485474d405de869bebf758f8c 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/bootmem.h>
index 66bcbbb6babc057480676a4b413419b016681b8c..355797f7004808938ef9684df1693457c5b0a7ca 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/if_arp.h>
 #include <net/arp.h>
index db08fc24047a5b569a3f0e411b1cafea435cd5e2..0402da30a4ed22c9781a051a2b65cda98767bae2 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
index b68e1eb405ff4d4622c59ef453fc9ecb0b608fab..2c712af6c2653ba4de8694dae5b962cfb1a523ee 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/init.h>
index 0a74f21409c5c91a7362ac9aa78460ba30c5dc66..c9e459400ff967dca9a6561d0f3395ed96595780 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
index 28dea518d554bcca703171f5472c30699c214438..4cb401813b7e7ec9af98ec10334ec8a99b53069f 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/bootmem.h>
index 112e230cb13d22d46f6c7d2bc38db1075c9ddb94..f3b46f71e293d9ac7bb39dda6bd0a2937a1452cd 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/arcdevice.h>
 
index 06f8fa2f8f2fb90b0317bf02cdacb3476a2823c7..f81db4070a574500172fa4dd5521859cc6e063e3 100644 (file)
@@ -24,6 +24,7 @@
  * **********************
  */
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/if_arp.h>
 #include <net/arp.h>
index 745530651c454c3fd25ab85313e90e40b69624a9..b71431aae0846ee8cb69101974f341246265fe59 100644 (file)
@@ -23,6 +23,7 @@
  *
  * **********************
  */
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/if_arp.h>
index 08d8be47dae00c8bd1859d1765c86571da4e816c..fa1a2354f5f99f78b8c45ffb3e4a2e07ca82fff6 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/interrupt.h>
index 8b23d5a175bfed5581541f5f8da590cc3190352f..aed5b5479b505d1268bc31063edb1c40ba27bd02 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/ethtool.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
index bf72d57a0afdab7c8f48467d9b7d664935ea8144..6995169d285ab10b71ede945c68451d6dc972f21 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 
index f52f668c49bfae5fcf526d299f9368661dd0d32c..4af235d41fda656990a7a280976ecd6e477d2a49 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
index 6e2ae1d06df16c54b6aaaf129c3b8a339fb42315..6be8b098b8b48b58be55df6aaf529dabee07decc 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/phy.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <mach/npe.h>
 #include <mach/qmgr.h>
 
index a1d4188c430b6d1ecc321482bba6f46736e88b4f..84f8a8f73802f4b6b54bbc51c3665a146185f102 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 
@@ -449,11 +450,10 @@ ks8695_rx_irq(int irq, void *dev_id)
 }
 
 /**
- *     ks8695_rx - Receive packets  called by NAPI poll method
+ *     ks8695_rx - Receive packets called by NAPI poll method
  *     @ksp: Private data for the KS8695 Ethernet
- *     @budget: The max packets would be receive
+ *     @budget: Number of packets allowed to process
  */
-
 static int ks8695_rx(struct ks8695_priv *ksp, int budget)
 {
        struct net_device *ndev = ksp->ndev;
@@ -461,7 +461,6 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget)
        int buff_n;
        u32 flags;
        int pktlen;
-       int last_rx_processed = -1;
        int received = 0;
 
        buff_n = ksp->next_rx_desc_read;
@@ -471,6 +470,7 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget)
                                        cpu_to_le32(RDES_OWN)))) {
                        rmb();
                        flags = le32_to_cpu(ksp->rx_ring[buff_n].status);
+
                        /* Found an SKB which we own, this means we
                         * received a packet
                         */
@@ -533,23 +533,18 @@ rx_failure:
                        ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN);
 rx_finished:
                        received++;
-                       /* And note this as processed so we can start
-                        * from here next time
-                        */
-                       last_rx_processed = buff_n;
                        buff_n = (buff_n + 1) & MAX_RX_DESC_MASK;
-                       /*And note which RX descriptor we last did */
-                       if (likely(last_rx_processed != -1))
-                               ksp->next_rx_desc_read =
-                                       (last_rx_processed + 1) &
-                                       MAX_RX_DESC_MASK;
        }
+
+       /* And note which RX descriptor we last did */
+       ksp->next_rx_desc_read = buff_n;
+
        /* And refill the buffers */
        ks8695_refill_rxbuffers(ksp);
 
-       /* Kick the RX DMA engine, in case it became
-        *  suspended */
+       /* Kick the RX DMA engine, in case it became suspended */
        ks8695_writereg(ksp, KS8695_DRSC, 0);
+
        return received;
 }
 
index febd813c916d06474b05b55b861b0f136f19dacc..f7c9ca1dfb17b67664a7656ef2d74bf1105e5efa 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/ethtool.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/gfp.h>
 
 #define DRV_MODULE_NAME                "w90p910-emc"
 #define DRV_MODULE_VERSION     "0.1"
index 309843ab886925e7a1a1fe3b745d86de01824bd2..10a20fb9ae6518f808232fd5439519cceffc9d4b 100644 (file)
@@ -47,7 +47,6 @@
 #include <linux/ioport.h>
 #include <linux/in.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
index 280cfff48b49fc91160276c3e31e33c55a18ac00..a8686bfec7a18c7c7537308b73750635aef33628 100644 (file)
@@ -53,7 +53,6 @@ static char version[] = "atarilance.c: v1.3 04/04/96 "
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
index 61a0f2ff11e98437057711aebafea9797a22a93f..32339243d61f84dd4f644cbd04f033605ac634ba 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 
 #include "atl1c.h"
 
index a76006c1bc6ba46e65a482fa80b0363338844150..ffd696ee7c8ed5ebc13e53438282424c24049317 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 
 #include "atl1e.h"
 
index 9ba547069db3c44d13005532e550837ea1bb8350..0ebd8208f606afdaf0f387ad3353ccb7b3d958e8 100644 (file)
@@ -84,7 +84,7 @@
 
 #define ATLX_DRIVER_VERSION "2.1.3"
 MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \
-       Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
+Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(ATLX_DRIVER_VERSION);
 
index 7061d7108f08b8cc6e1e1a293a63c93718319f4f..54662f24f9bb0587b841e43776ae0aa2a426bbcf 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/pci_ids.h>
 #include <linux/pm.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/tcp.h>
index 6ad16205dc1781cfcb9c760246b56020b4a8d166..55039d44dc474545062e942a39b0b1ef46b4cb03 100644 (file)
@@ -129,7 +129,6 @@ static int xcvr[NUM_UNITS];                         /* The data transfer mode. */
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index 1dd4403247ca02d972fdd0f9e2a3651c862a5ce7..b718dc60afc4114783c13697e88787f31077d94e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/eeprom_93cx6.h>
+#include <linux/slab.h>
 
 #include <net/ax88796.h>
 
index 332c60356285688fe7807b0f692fcce9a9c153ff..69d9f3d368aee82a817f6d5645df275a9f2497dc 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
 #include <linux/ssb/ssb.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
index 8cdcab7655c0751c70aaf93b74ca48982b4f3936..17460aba3baee4614e41b4222f131336580df8a5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/clk.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
index 8f0752553681f6c2df21f559f055c9a907df2651..56387b191c963aed41549412b7f1697f72ac7424 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include "be_hw.h"
 
index 50e6259b50e4db0489d443715252aa8c6a3b754a..d0ef4ac987cde52db2ecb24e2144c43d1339c997 100644 (file)
@@ -1464,8 +1464,8 @@ int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
 
        req->params.op_type = cpu_to_le32(IMG_TYPE_REDBOOT);
        req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT);
-       req->params.offset = offset;
-       req->params.data_buf_size = 0x4;
+       req->params.offset = cpu_to_le32(offset);
+       req->params.data_buf_size = cpu_to_le32(0x4);
 
        status = be_mcc_notify_wait(adapter);
        if (!status)
index 9560d48944ab526a49737b6fcfdb23f668e8af20..51e1065e78977df6f27a06eaf58dcdba64da5502 100644 (file)
@@ -490,7 +490,7 @@ be_test_ddr_dma(struct be_adapter *adapter)
 {
        int ret, i;
        struct be_dma_mem ddrdma_cmd;
-       u64 pattern[2] = {0x5a5a5a5a5a5a5a5a, 0xa5a5a5a5a5a5a5a5};
+       u64 pattern[2] = {0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL};
 
        ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
        ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size,
index 43e8032f9236f5e27809aba771434c76550ef89c..ec6ace802256087c4bd310c4669c48fc919999ae 100644 (file)
@@ -807,7 +807,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
                        return;
                }
                vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
-               vid = be16_to_cpu(vid);
+               vid = swab16(vid);
                vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, vid);
        } else {
                netif_receive_skb(skb);
@@ -884,7 +884,7 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter,
                napi_gro_frags(&eq_obj->napi);
        } else {
                vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
-               vid = be16_to_cpu(vid);
+               vid = swab16(vid);
 
                if (!adapter->vlan_grp || adapter->vlans_added == 0)
                        return;
@@ -1855,7 +1855,7 @@ static bool be_flash_redboot(struct be_adapter *adapter,
        p += crc_offset;
 
        status = be_cmd_get_flash_crc(adapter, flashed_crc,
-                       (img_start + image_size - 4));
+                       (image_size - 4));
        if (status) {
                dev_err(&adapter->pdev->dev,
                "could not get crc from flash, not flashing redboot\n");
@@ -1991,7 +1991,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
        struct flash_file_hdr_g3 *fhdr3;
        struct image_hdr *img_hdr_ptr = NULL;
        struct be_dma_mem flash_cmd;
-       int status, i = 0;
+       int status, i = 0, num_imgs = 0;
        const u8 *p;
 
        strcpy(fw_file, func);
@@ -2017,15 +2017,14 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
        if ((adapter->generation == BE_GEN3) &&
                        (get_ufigen_type(fhdr) == BE_GEN3)) {
                fhdr3 = (struct flash_file_hdr_g3 *) fw->data;
-               for (i = 0; i < fhdr3->num_imgs; i++) {
+               num_imgs = le32_to_cpu(fhdr3->num_imgs);
+               for (i = 0; i < num_imgs; i++) {
                        img_hdr_ptr = (struct image_hdr *) (fw->data +
                                        (sizeof(struct flash_file_hdr_g3) +
-                                       i * sizeof(struct image_hdr)));
-                       if (img_hdr_ptr->imageid == 1) {
-                               status = be_flash_data(adapter, fw,
-                                               &flash_cmd, fhdr3->num_imgs);
-                       }
-
+                                        i * sizeof(struct image_hdr)));
+                       if (le32_to_cpu(img_hdr_ptr->imageid) == 1)
+                               status = be_flash_data(adapter, fw, &flash_cmd,
+                                                       num_imgs);
                }
        } else if ((adapter->generation == BE_GEN2) &&
                        (get_ufigen_type(fhdr) == BE_GEN2)) {
index 119468e76323de626291e3d0af96790fc9907f5b..598b007f1991dfac42c54bd0e263f2b1694176cc 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/crc32.h>
 #include <linux/bitrev.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
index 381887ba677c36b39e422e7f76273a5dbfa4f2ff..a257babd1bb4085c184604c4d0b8dcdbbc59f203 100644 (file)
@@ -246,6 +246,8 @@ static const struct flash_spec flash_5709 = {
 
 MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
 
+static void bnx2_init_napi(struct bnx2 *bp);
+
 static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
 {
        u32 diff;
@@ -6197,6 +6199,7 @@ bnx2_open(struct net_device *dev)
        bnx2_disable_int(bp);
 
        bnx2_setup_int_mode(bp, disable_msi);
+       bnx2_init_napi(bp);
        bnx2_napi_enable(bp);
        rc = bnx2_alloc_mem(bp);
        if (rc)
@@ -7643,9 +7646,11 @@ poll_bnx2(struct net_device *dev)
        int i;
 
        for (i = 0; i < bp->irq_nvecs; i++) {
-               disable_irq(bp->irq_tbl[i].vector);
-               bnx2_interrupt(bp->irq_tbl[i].vector, &bp->bnx2_napi[i]);
-               enable_irq(bp->irq_tbl[i].vector);
+               struct bnx2_irq *irq = &bp->irq_tbl[i];
+
+               disable_irq(irq->vector);
+               irq->handler(irq->vector, &bp->bnx2_napi[i]);
+               enable_irq(irq->vector);
        }
 }
 #endif
@@ -8207,7 +8212,7 @@ bnx2_init_napi(struct bnx2 *bp)
 {
        int i;
 
-       for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
+       for (i = 0; i < bp->irq_nvecs; i++) {
                struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
                int (*poll)(struct napi_struct *, int);
 
@@ -8276,7 +8281,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        dev->ethtool_ops = &bnx2_ethtool_ops;
 
        bp = netdev_priv(dev);
-       bnx2_init_napi(bp);
 
        pci_set_drvdata(pdev, dev);
 
index 430c02267d7e9ec26d3c8b59922d919fc5fedb97..0075514bf32fc1d78e15bab0a717c91f945227d6 100644 (file)
@@ -1235,6 +1235,11 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
                        write_lock_bh(&bond->curr_slave_lock);
                }
        }
+
+       /* resend IGMP joins since all were sent on curr_active_slave */
+       if (bond->params.mode == BOND_MODE_ROUNDROBIN) {
+               bond_resend_igmp_join_requests(bond);
+       }
 }
 
 /**
@@ -4138,22 +4143,41 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
        struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave, *start_at;
        int i, slave_no, res = 1;
+       struct iphdr *iph = ip_hdr(skb);
 
        read_lock(&bond->lock);
 
        if (!BOND_IS_OK(bond))
                goto out;
-
        /*
-        * Concurrent TX may collide on rr_tx_counter; we accept that
-        * as being rare enough not to justify using an atomic op here
+        * Start with the curr_active_slave that joined the bond as the
+        * default for sending IGMP traffic.  For failover purposes one
+        * needs to maintain some consistency for the interface that will
+        * send the join/membership reports.  The curr_active_slave found
+        * will send all of this type of traffic.
         */
-       slave_no = bond->rr_tx_counter++ % bond->slave_cnt;
+       if ((iph->protocol == IPPROTO_IGMP) &&
+           (skb->protocol == htons(ETH_P_IP))) {
 
-       bond_for_each_slave(bond, slave, i) {
-               slave_no--;
-               if (slave_no < 0)
-                       break;
+               read_lock(&bond->curr_slave_lock);
+               slave = bond->curr_active_slave;
+               read_unlock(&bond->curr_slave_lock);
+
+               if (!slave)
+                       goto out;
+       } else {
+               /*
+                * Concurrent TX may collide on rr_tx_counter; we accept
+                * that as being rare enough not to justify using an
+                * atomic op here.
+                */
+               slave_no = bond->rr_tx_counter++ % bond->slave_cnt;
+
+               bond_for_each_slave(bond, slave, i) {
+                       slave_no--;
+                       if (slave_no < 0)
+                               break;
+               }
        }
 
        start_at = slave;
@@ -4426,6 +4450,14 @@ static const struct net_device_ops bond_netdev_ops = {
        .ndo_vlan_rx_kill_vid   = bond_vlan_rx_kill_vid,
 };
 
+static void bond_destructor(struct net_device *bond_dev)
+{
+       struct bonding *bond = netdev_priv(bond_dev);
+       if (bond->wq)
+               destroy_workqueue(bond->wq);
+       free_netdev(bond_dev);
+}
+
 static void bond_setup(struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
@@ -4446,7 +4478,7 @@ static void bond_setup(struct net_device *bond_dev)
        bond_dev->ethtool_ops = &bond_ethtool_ops;
        bond_set_mode_ops(bond, bond->params.mode);
 
-       bond_dev->destructor = free_netdev;
+       bond_dev->destructor = bond_destructor;
 
        /* Initialize the device options */
        bond_dev->tx_queue_len = 0;
@@ -4518,9 +4550,6 @@ static void bond_uninit(struct net_device *bond_dev)
 
        bond_remove_proc_entry(bond);
 
-       if (bond->wq)
-               destroy_workqueue(bond->wq);
-
        netif_addr_lock_bh(bond_dev);
        bond_mc_list_destroy(bond);
        netif_addr_unlock_bh(bond_dev);
@@ -4932,8 +4961,8 @@ int bond_create(struct net *net, const char *name)
                                bond_setup);
        if (!bond_dev) {
                pr_err("%s: eek! can't alloc netdev!\n", name);
-               res = -ENOMEM;
-               goto out;
+               rtnl_unlock();
+               return -ENOMEM;
        }
 
        dev_net_set(bond_dev, net);
@@ -4942,19 +4971,16 @@ int bond_create(struct net *net, const char *name)
        if (!name) {
                res = dev_alloc_name(bond_dev, "bond%d");
                if (res < 0)
-                       goto out_netdev;
+                       goto out;
        }
 
        res = register_netdevice(bond_dev);
-       if (res < 0)
-               goto out_netdev;
 
 out:
        rtnl_unlock();
+       if (res < 0)
+               bond_destructor(bond_dev);
        return res;
-out_netdev:
-       free_netdev(bond_dev);
-       goto out;
 }
 
 static int __net_init bond_net_init(struct net *net)
index 866905fa4119e5c66d18d56875b7e9525a4713c2..03489864376df7ca060927c3afd3d058b41e088b 100644 (file)
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
 
+#include <asm/bfin_can.h>
 #include <asm/portmux.h>
 
 #define DRV_NAME "bfin_can"
 #define BFIN_CAN_TIMEOUT 100
 #define TX_ECHO_SKB_MAX  1
 
-/*
- * transmit and receive channels
- */
-#define TRANSMIT_CHL            24
-#define RECEIVE_STD_CHL         0
-#define RECEIVE_EXT_CHL         4
-#define RECEIVE_RTR_CHL         8
-#define RECEIVE_EXT_RTR_CHL     12
-#define MAX_CHL_NUMBER          32
-
-/*
- * bfin can registers layout
- */
-struct bfin_can_mask_regs {
-       u16 aml;
-       u16 dummy1;
-       u16 amh;
-       u16 dummy2;
-};
-
-struct bfin_can_channel_regs {
-       u16 data[8];
-       u16 dlc;
-       u16 dummy1;
-       u16 tsv;
-       u16 dummy2;
-       u16 id0;
-       u16 dummy3;
-       u16 id1;
-       u16 dummy4;
-};
-
-struct bfin_can_regs {
-       /*
-        * global control and status registers
-        */
-       u16 mc1;           /* offset 0 */
-       u16 dummy1;
-       u16 md1;           /* offset 4 */
-       u16 rsv1[13];
-       u16 mbtif1;        /* offset 0x20 */
-       u16 dummy2;
-       u16 mbrif1;        /* offset 0x24 */
-       u16 dummy3;
-       u16 mbim1;         /* offset 0x28 */
-       u16 rsv2[11];
-       u16 mc2;           /* offset 0x40 */
-       u16 dummy4;
-       u16 md2;           /* offset 0x44 */
-       u16 dummy5;
-       u16 trs2;          /* offset 0x48 */
-       u16 rsv3[11];
-       u16 mbtif2;        /* offset 0x60 */
-       u16 dummy6;
-       u16 mbrif2;        /* offset 0x64 */
-       u16 dummy7;
-       u16 mbim2;         /* offset 0x68 */
-       u16 rsv4[11];
-       u16 clk;           /* offset 0x80 */
-       u16 dummy8;
-       u16 timing;        /* offset 0x84 */
-       u16 rsv5[3];
-       u16 status;        /* offset 0x8c */
-       u16 dummy9;
-       u16 cec;           /* offset 0x90 */
-       u16 dummy10;
-       u16 gis;           /* offset 0x94 */
-       u16 dummy11;
-       u16 gim;           /* offset 0x98 */
-       u16 rsv6[3];
-       u16 ctrl;          /* offset 0xa0 */
-       u16 dummy12;
-       u16 intr;          /* offset 0xa4 */
-       u16 rsv7[7];
-       u16 esr;           /* offset 0xb4 */
-       u16 rsv8[37];
-
-       /*
-        * channel(mailbox) mask and message registers
-        */
-       struct bfin_can_mask_regs msk[MAX_CHL_NUMBER];    /* offset 0x100 */
-       struct bfin_can_channel_regs chl[MAX_CHL_NUMBER]; /* offset 0x200 */
-};
-
 /*
  * bfin can private data
  */
@@ -163,7 +80,7 @@ static int bfin_can_set_bittiming(struct net_device *dev)
        if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
                timing |= SAM;
 
-       bfin_write16(&reg->clk, clk);
+       bfin_write16(&reg->clock, clk);
        bfin_write16(&reg->timing, timing);
 
        dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n",
@@ -185,11 +102,11 @@ static void bfin_can_set_reset_mode(struct net_device *dev)
        bfin_write16(&reg->gim, 0);
 
        /* reset can and enter configuration mode */
-       bfin_write16(&reg->ctrl, SRS | CCR);
+       bfin_write16(&reg->control, SRS | CCR);
        SSYNC();
-       bfin_write16(&reg->ctrl, CCR);
+       bfin_write16(&reg->control, CCR);
        SSYNC();
-       while (!(bfin_read16(&reg->ctrl) & CCA)) {
+       while (!(bfin_read16(&reg->control) & CCA)) {
                udelay(10);
                if (--timeout == 0) {
                        dev_err(dev->dev.parent,
@@ -244,7 +161,7 @@ static void bfin_can_set_normal_mode(struct net_device *dev)
        /*
         * leave configuration mode
         */
-       bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) & ~CCR);
+       bfin_write16(&reg->control, bfin_read16(&reg->control) & ~CCR);
 
        while (bfin_read16(&reg->status) & CCA) {
                udelay(10);
@@ -726,7 +643,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
 
        if (netif_running(dev)) {
                /* enter sleep mode */
-               bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) | SMR);
+               bfin_write16(&reg->control, bfin_read16(&reg->control) | SMR);
                SSYNC();
                while (!(bfin_read16(&reg->intr) & SMACK)) {
                        udelay(10);
index 904aa369f80e13c0d02a664fa23aee2019246b8d..d0f8c7e67e7d2a738c2716a68f80b4b7a22a21f2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/can.h>
index f8cc168ec76cd29db433bee4face5726c11bd43a..b39b108318b48cfa584d25a124babe936af1a9ec 100644 (file)
@@ -73,6 +73,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/uaccess.h>
 
index 87300606abb9db79bb683ca4b92deb3206d456b7..5f53da0bc40ceddc2ce58c8949b536f789b1b15d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/can.h>
 #include <linux/can/dev.h>
index 6b46a6395f80218a76c1d1c5da70d24ab49b8b5e..4aff4070db96236a90229380cebcf1e2e7f1e53c 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/can.h>
 #include <linux/can/dev.h>
index d124d837ae58c4c1c5de7ce1d6a90d3fc86c5d52..a30b8f480f611f35b56493062ac907c042bdefce 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/if_ether.h>
 #include <linux/can.h>
 #include <linux/can/dev.h>
+#include <linux/slab.h>
 #include <net/rtnetlink.h>
 
 static __initdata const char banner[] =
index 2d11afe4531069ead920b4c8a0d660169cdd57ba..036b2dfb1d40b2c1155d54a34ecfb0ae75056acc 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/mdio.h>
 #include <linux/crc32.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/pci_ids.h>
 
index a6eb30a6e2b98a74cf7060bbbc2e56bcd4f92a67..9e631b9d3948cb9d04e6461c66b23db4f2afe893 100644 (file)
@@ -44,6 +44,7 @@
 #include "suni1x10gexp_regs.h"
 
 #include <linux/crc32.h>
+#include <linux/slab.h>
 
 #define OFFSET(REG_ADDR)    ((REG_ADDR) << 2)
 
index 55d99ca82f8ad5a67785aed9a1ecf684ba404a09..df3a1410696eeb6f53e36a5ed0609f466d27cedf 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/ip.h>
 #include <linux/in.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 
 #include "cpl5_cmd.h"
 #include "sge.h"
index dd24aadb778ca8be8e48c534697468cb324e61b8..61a33914e96f87b4550404247748cf9248305666 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
index b0208e474f7eabaebebc646491e76747b378ba4b..4c38491b8efb02584e9e543a650494641bbd2692 100644 (file)
 #include <linux/ioport.h>
 #include <linux/in.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index 9e3e8750b46a69dcbcead02cb0281c0d4fd084be..aced6c5e635cedf6a50694eb3fd61a8cc94f4ba2 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/log2.h>
 #include <linux/stringify.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #include "common.h"
index 9498361119d6747dfdd7190a90982bcc9c8b87f5..c6485b39eb0e630c67a5f91cd683ab7365362928 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/neighbour.h>
 #include <linux/notifier.h>
 #include <asm/atomic.h>
index ff1611f90e7aab04436c71d3851708ff51695650..2f3ee721c3e11c7075e327f74e1b4cdde1be1024 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/if.h>
 #include <linux/if_vlan.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 #include <net/neighbour.h>
 #include "common.h"
 #include "t3cdev.h"
index 67e61b2a8c42332b2b2d678d560111fb134a203c..07d7e7fab3f5683e4189f349973940d9e9a99d9a 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include "common.h"
 #include "regs.h"
diff --git a/drivers/net/cxgb4/Makefile b/drivers/net/cxgb4/Makefile
new file mode 100644 (file)
index 0000000..4986674
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Chelsio T4 driver
+#
+
+obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
+
+cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
diff --git a/drivers/net/cxgb4/cxgb4.h b/drivers/net/cxgb4/cxgb4.h
new file mode 100644 (file)
index 0000000..3d8ff48
--- /dev/null
@@ -0,0 +1,741 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __CXGB4_H__
+#define __CXGB4_H__
+
+#include <linux/bitops.h>
+#include <linux/cache.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/spinlock.h>
+#include <linux/timer.h>
+#include <asm/io.h>
+#include "cxgb4_uld.h"
+#include "t4_hw.h"
+
+#define FW_VERSION_MAJOR 1
+#define FW_VERSION_MINOR 1
+#define FW_VERSION_MICRO 0
+
+enum {
+       MAX_NPORTS = 4,     /* max # of ports */
+       SERNUM_LEN = 16,    /* Serial # length */
+       EC_LEN     = 16,    /* E/C length */
+       ID_LEN     = 16,    /* ID length */
+};
+
+enum {
+       MEM_EDC0,
+       MEM_EDC1,
+       MEM_MC
+};
+
+enum dev_master {
+       MASTER_CANT,
+       MASTER_MAY,
+       MASTER_MUST
+};
+
+enum dev_state {
+       DEV_STATE_UNINIT,
+       DEV_STATE_INIT,
+       DEV_STATE_ERR
+};
+
+enum {
+       PAUSE_RX      = 1 << 0,
+       PAUSE_TX      = 1 << 1,
+       PAUSE_AUTONEG = 1 << 2
+};
+
+struct port_stats {
+       u64 tx_octets;            /* total # of octets in good frames */
+       u64 tx_frames;            /* all good frames */
+       u64 tx_bcast_frames;      /* all broadcast frames */
+       u64 tx_mcast_frames;      /* all multicast frames */
+       u64 tx_ucast_frames;      /* all unicast frames */
+       u64 tx_error_frames;      /* all error frames */
+
+       u64 tx_frames_64;         /* # of Tx frames in a particular range */
+       u64 tx_frames_65_127;
+       u64 tx_frames_128_255;
+       u64 tx_frames_256_511;
+       u64 tx_frames_512_1023;
+       u64 tx_frames_1024_1518;
+       u64 tx_frames_1519_max;
+
+       u64 tx_drop;              /* # of dropped Tx frames */
+       u64 tx_pause;             /* # of transmitted pause frames */
+       u64 tx_ppp0;              /* # of transmitted PPP prio 0 frames */
+       u64 tx_ppp1;              /* # of transmitted PPP prio 1 frames */
+       u64 tx_ppp2;              /* # of transmitted PPP prio 2 frames */
+       u64 tx_ppp3;              /* # of transmitted PPP prio 3 frames */
+       u64 tx_ppp4;              /* # of transmitted PPP prio 4 frames */
+       u64 tx_ppp5;              /* # of transmitted PPP prio 5 frames */
+       u64 tx_ppp6;              /* # of transmitted PPP prio 6 frames */
+       u64 tx_ppp7;              /* # of transmitted PPP prio 7 frames */
+
+       u64 rx_octets;            /* total # of octets in good frames */
+       u64 rx_frames;            /* all good frames */
+       u64 rx_bcast_frames;      /* all broadcast frames */
+       u64 rx_mcast_frames;      /* all multicast frames */
+       u64 rx_ucast_frames;      /* all unicast frames */
+       u64 rx_too_long;          /* # of frames exceeding MTU */
+       u64 rx_jabber;            /* # of jabber frames */
+       u64 rx_fcs_err;           /* # of received frames with bad FCS */
+       u64 rx_len_err;           /* # of received frames with length error */
+       u64 rx_symbol_err;        /* symbol errors */
+       u64 rx_runt;              /* # of short frames */
+
+       u64 rx_frames_64;         /* # of Rx frames in a particular range */
+       u64 rx_frames_65_127;
+       u64 rx_frames_128_255;
+       u64 rx_frames_256_511;
+       u64 rx_frames_512_1023;
+       u64 rx_frames_1024_1518;
+       u64 rx_frames_1519_max;
+
+       u64 rx_pause;             /* # of received pause frames */
+       u64 rx_ppp0;              /* # of received PPP prio 0 frames */
+       u64 rx_ppp1;              /* # of received PPP prio 1 frames */
+       u64 rx_ppp2;              /* # of received PPP prio 2 frames */
+       u64 rx_ppp3;              /* # of received PPP prio 3 frames */
+       u64 rx_ppp4;              /* # of received PPP prio 4 frames */
+       u64 rx_ppp5;              /* # of received PPP prio 5 frames */
+       u64 rx_ppp6;              /* # of received PPP prio 6 frames */
+       u64 rx_ppp7;              /* # of received PPP prio 7 frames */
+
+       u64 rx_ovflow0;           /* drops due to buffer-group 0 overflows */
+       u64 rx_ovflow1;           /* drops due to buffer-group 1 overflows */
+       u64 rx_ovflow2;           /* drops due to buffer-group 2 overflows */
+       u64 rx_ovflow3;           /* drops due to buffer-group 3 overflows */
+       u64 rx_trunc0;            /* buffer-group 0 truncated packets */
+       u64 rx_trunc1;            /* buffer-group 1 truncated packets */
+       u64 rx_trunc2;            /* buffer-group 2 truncated packets */
+       u64 rx_trunc3;            /* buffer-group 3 truncated packets */
+};
+
+struct lb_port_stats {
+       u64 octets;
+       u64 frames;
+       u64 bcast_frames;
+       u64 mcast_frames;
+       u64 ucast_frames;
+       u64 error_frames;
+
+       u64 frames_64;
+       u64 frames_65_127;
+       u64 frames_128_255;
+       u64 frames_256_511;
+       u64 frames_512_1023;
+       u64 frames_1024_1518;
+       u64 frames_1519_max;
+
+       u64 drop;
+
+       u64 ovflow0;
+       u64 ovflow1;
+       u64 ovflow2;
+       u64 ovflow3;
+       u64 trunc0;
+       u64 trunc1;
+       u64 trunc2;
+       u64 trunc3;
+};
+
+struct tp_tcp_stats {
+       u32 tcpOutRsts;
+       u64 tcpInSegs;
+       u64 tcpOutSegs;
+       u64 tcpRetransSegs;
+};
+
+struct tp_err_stats {
+       u32 macInErrs[4];
+       u32 hdrInErrs[4];
+       u32 tcpInErrs[4];
+       u32 tnlCongDrops[4];
+       u32 ofldChanDrops[4];
+       u32 tnlTxDrops[4];
+       u32 ofldVlanDrops[4];
+       u32 tcp6InErrs[4];
+       u32 ofldNoNeigh;
+       u32 ofldCongDefer;
+};
+
+struct tp_params {
+       unsigned int ntxchan;        /* # of Tx channels */
+       unsigned int tre;            /* log2 of core clocks per TP tick */
+};
+
+struct vpd_params {
+       unsigned int cclk;
+       u8 ec[EC_LEN + 1];
+       u8 sn[SERNUM_LEN + 1];
+       u8 id[ID_LEN + 1];
+};
+
+struct pci_params {
+       unsigned char speed;
+       unsigned char width;
+};
+
+struct adapter_params {
+       struct tp_params  tp;
+       struct vpd_params vpd;
+       struct pci_params pci;
+
+       unsigned int fw_vers;
+       unsigned int tp_vers;
+       u8 api_vers[7];
+
+       unsigned short mtus[NMTUS];
+       unsigned short a_wnd[NCCTRL_WIN];
+       unsigned short b_wnd[NCCTRL_WIN];
+
+       unsigned char nports;             /* # of ethernet ports */
+       unsigned char portvec;
+       unsigned char rev;                /* chip revision */
+       unsigned char offload;
+
+       unsigned int ofldq_wr_cred;
+};
+
+struct trace_params {
+       u32 data[TRACE_LEN / 4];
+       u32 mask[TRACE_LEN / 4];
+       unsigned short snap_len;
+       unsigned short min_len;
+       unsigned char skip_ofst;
+       unsigned char skip_len;
+       unsigned char invert;
+       unsigned char port;
+};
+
+struct link_config {
+       unsigned short supported;        /* link capabilities */
+       unsigned short advertising;      /* advertised capabilities */
+       unsigned short requested_speed;  /* speed user has requested */
+       unsigned short speed;            /* actual link speed */
+       unsigned char  requested_fc;     /* flow control user has requested */
+       unsigned char  fc;               /* actual link flow control */
+       unsigned char  autoneg;          /* autonegotiating? */
+       unsigned char  link_ok;          /* link up? */
+};
+
+#define FW_LEN16(fw_struct) FW_CMD_LEN16(sizeof(fw_struct) / 16)
+
+enum {
+       MAX_ETH_QSETS = 32,           /* # of Ethernet Tx/Rx queue sets */
+       MAX_OFLD_QSETS = 16,          /* # of offload Tx/Rx queue sets */
+       MAX_CTRL_QUEUES = NCHAN,      /* # of control Tx queues */
+       MAX_RDMA_QUEUES = NCHAN,      /* # of streaming RDMA Rx queues */
+};
+
+enum {
+       MAX_EGRQ = 128,         /* max # of egress queues, including FLs */
+       MAX_INGQ = 64           /* max # of interrupt-capable ingress queues */
+};
+
+struct adapter;
+struct vlan_group;
+struct sge_rspq;
+
+struct port_info {
+       struct adapter *adapter;
+       struct vlan_group *vlan_grp;
+       u16    viid;
+       s16    xact_addr_filt;        /* index of exact MAC address filter */
+       u16    rss_size;              /* size of VI's RSS table slice */
+       s8     mdio_addr;
+       u8     port_type;
+       u8     mod_type;
+       u8     port_id;
+       u8     tx_chan;
+       u8     lport;                 /* associated offload logical port */
+       u8     rx_offload;            /* CSO, etc */
+       u8     nqsets;                /* # of qsets */
+       u8     first_qset;            /* index of first qset */
+       struct link_config link_cfg;
+};
+
+/* port_info.rx_offload flags */
+enum {
+       RX_CSO = 1 << 0,
+};
+
+struct dentry;
+struct work_struct;
+
+enum {                                 /* adapter flags */
+       FULL_INIT_DONE     = (1 << 0),
+       USING_MSI          = (1 << 1),
+       USING_MSIX         = (1 << 2),
+       QUEUES_BOUND       = (1 << 3),
+       FW_OK              = (1 << 4),
+};
+
+struct rx_sw_desc;
+
+struct sge_fl {                     /* SGE free-buffer queue state */
+       unsigned int avail;         /* # of available Rx buffers */
+       unsigned int pend_cred;     /* new buffers since last FL DB ring */
+       unsigned int cidx;          /* consumer index */
+       unsigned int pidx;          /* producer index */
+       unsigned long alloc_failed; /* # of times buffer allocation failed */
+       unsigned long large_alloc_failed;
+       unsigned long starving;
+       /* RO fields */
+       unsigned int cntxt_id;      /* SGE context id for the free list */
+       unsigned int size;          /* capacity of free list */
+       struct rx_sw_desc *sdesc;   /* address of SW Rx descriptor ring */
+       __be64 *desc;               /* address of HW Rx descriptor ring */
+       dma_addr_t addr;            /* bus address of HW ring start */
+};
+
+/* A packet gather list */
+struct pkt_gl {
+       skb_frag_t frags[MAX_SKB_FRAGS];
+       void *va;                         /* virtual address of first byte */
+       unsigned int nfrags;              /* # of fragments */
+       unsigned int tot_len;             /* total length of fragments */
+};
+
+typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
+                             const struct pkt_gl *gl);
+
+struct sge_rspq {                   /* state for an SGE response queue */
+       struct napi_struct napi;
+       const __be64 *cur_desc;     /* current descriptor in queue */
+       unsigned int cidx;          /* consumer index */
+       u8 gen;                     /* current generation bit */
+       u8 intr_params;             /* interrupt holdoff parameters */
+       u8 next_intr_params;        /* holdoff params for next interrupt */
+       u8 pktcnt_idx;              /* interrupt packet threshold */
+       u8 uld;                     /* ULD handling this queue */
+       u8 idx;                     /* queue index within its group */
+       int offset;                 /* offset into current Rx buffer */
+       u16 cntxt_id;               /* SGE context id for the response q */
+       u16 abs_id;                 /* absolute SGE id for the response q */
+       __be64 *desc;               /* address of HW response ring */
+       dma_addr_t phys_addr;       /* physical address of the ring */
+       unsigned int iqe_len;       /* entry size */
+       unsigned int size;          /* capacity of response queue */
+       struct adapter *adap;
+       struct net_device *netdev;  /* associated net device */
+       rspq_handler_t handler;
+};
+
+struct sge_eth_stats {              /* Ethernet queue statistics */
+       unsigned long pkts;         /* # of ethernet packets */
+       unsigned long lro_pkts;     /* # of LRO super packets */
+       unsigned long lro_merged;   /* # of wire packets merged by LRO */
+       unsigned long rx_cso;       /* # of Rx checksum offloads */
+       unsigned long vlan_ex;      /* # of Rx VLAN extractions */
+       unsigned long rx_drops;     /* # of packets dropped due to no mem */
+};
+
+struct sge_eth_rxq {                /* SW Ethernet Rx queue */
+       struct sge_rspq rspq;
+       struct sge_fl fl;
+       struct sge_eth_stats stats;
+} ____cacheline_aligned_in_smp;
+
+struct sge_ofld_stats {             /* offload queue statistics */
+       unsigned long pkts;         /* # of packets */
+       unsigned long imm;          /* # of immediate-data packets */
+       unsigned long an;           /* # of asynchronous notifications */
+       unsigned long nomem;        /* # of responses deferred due to no mem */
+};
+
+struct sge_ofld_rxq {               /* SW offload Rx queue */
+       struct sge_rspq rspq;
+       struct sge_fl fl;
+       struct sge_ofld_stats stats;
+} ____cacheline_aligned_in_smp;
+
+struct tx_desc {
+       __be64 flit[8];
+};
+
+struct tx_sw_desc;
+
+struct sge_txq {
+       unsigned int  in_use;       /* # of in-use Tx descriptors */
+       unsigned int  size;         /* # of descriptors */
+       unsigned int  cidx;         /* SW consumer index */
+       unsigned int  pidx;         /* producer index */
+       unsigned long stops;        /* # of times q has been stopped */
+       unsigned long restarts;     /* # of queue restarts */
+       unsigned int  cntxt_id;     /* SGE context id for the Tx q */
+       struct tx_desc *desc;       /* address of HW Tx descriptor ring */
+       struct tx_sw_desc *sdesc;   /* address of SW Tx descriptor ring */
+       struct sge_qstat *stat;     /* queue status entry */
+       dma_addr_t    phys_addr;    /* physical address of the ring */
+};
+
+struct sge_eth_txq {                /* state for an SGE Ethernet Tx queue */
+       struct sge_txq q;
+       struct netdev_queue *txq;   /* associated netdev TX queue */
+       unsigned long tso;          /* # of TSO requests */
+       unsigned long tx_cso;       /* # of Tx checksum offloads */
+       unsigned long vlan_ins;     /* # of Tx VLAN insertions */
+       unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
+} ____cacheline_aligned_in_smp;
+
+struct sge_ofld_txq {               /* state for an SGE offload Tx queue */
+       struct sge_txq q;
+       struct adapter *adap;
+       struct sk_buff_head sendq;  /* list of backpressured packets */
+       struct tasklet_struct qresume_tsk; /* restarts the queue */
+       u8 full;                    /* the Tx ring is full */
+       unsigned long mapping_err;  /* # of I/O MMU packet mapping errors */
+} ____cacheline_aligned_in_smp;
+
+struct sge_ctrl_txq {               /* state for an SGE control Tx queue */
+       struct sge_txq q;
+       struct adapter *adap;
+       struct sk_buff_head sendq;  /* list of backpressured packets */
+       struct tasklet_struct qresume_tsk; /* restarts the queue */
+       u8 full;                    /* the Tx ring is full */
+} ____cacheline_aligned_in_smp;
+
+struct sge {
+       struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
+       struct sge_ofld_txq ofldtxq[MAX_OFLD_QSETS];
+       struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
+
+       struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
+       struct sge_ofld_rxq ofldrxq[MAX_OFLD_QSETS];
+       struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
+       struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
+
+       struct sge_rspq intrq ____cacheline_aligned_in_smp;
+       spinlock_t intrq_lock;
+
+       u16 max_ethqsets;           /* # of available Ethernet queue sets */
+       u16 ethqsets;               /* # of active Ethernet queue sets */
+       u16 ethtxq_rover;           /* Tx queue to clean up next */
+       u16 ofldqsets;              /* # of active offload queue sets */
+       u16 rdmaqs;                 /* # of available RDMA Rx queues */
+       u16 ofld_rxq[MAX_OFLD_QSETS];
+       u16 rdma_rxq[NCHAN];
+       u16 timer_val[SGE_NTIMERS];
+       u8 counter_val[SGE_NCOUNTERS];
+       unsigned int starve_thres;
+       u8 idma_state[2];
+       void *egr_map[MAX_EGRQ];    /* qid->queue egress queue map */
+       struct sge_rspq *ingr_map[MAX_INGQ]; /* qid->queue ingress queue map */
+       DECLARE_BITMAP(starving_fl, MAX_EGRQ);
+       DECLARE_BITMAP(txq_maperr, MAX_EGRQ);
+       struct timer_list rx_timer; /* refills starving FLs */
+       struct timer_list tx_timer; /* checks Tx queues */
+};
+
+#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
+#define for_each_ofldrxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
+#define for_each_rdmarxq(sge, i) for (i = 0; i < (sge)->rdmaqs; i++)
+
+struct l2t_data;
+
+struct adapter {
+       void __iomem *regs;
+       struct pci_dev *pdev;
+       struct device *pdev_dev;
+       unsigned long registered_device_map;
+       unsigned long open_device_map;
+       unsigned long flags;
+
+       const char *name;
+       int msg_enable;
+
+       struct adapter_params params;
+       struct cxgb4_virt_res vres;
+       unsigned int swintr;
+
+       unsigned int wol;
+
+       struct {
+               unsigned short vec;
+               char desc[14];
+       } msix_info[MAX_INGQ + 1];
+
+       struct sge sge;
+
+       struct net_device *port[MAX_NPORTS];
+       u8 chan_map[NCHAN];                   /* channel -> port map */
+
+       struct l2t_data *l2t;
+       void *uld_handle[CXGB4_ULD_MAX];
+       struct list_head list_node;
+
+       struct tid_info tids;
+       void **tid_release_head;
+       spinlock_t tid_release_lock;
+       struct work_struct tid_release_task;
+       bool tid_release_task_busy;
+
+       struct dentry *debugfs_root;
+
+       spinlock_t stats_lock;
+};
+
+static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
+{
+       return readl(adap->regs + reg_addr);
+}
+
+static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
+{
+       writel(val, adap->regs + reg_addr);
+}
+
+#ifndef readq
+static inline u64 readq(const volatile void __iomem *addr)
+{
+       return readl(addr) + ((u64)readl(addr + 4) << 32);
+}
+
+static inline void writeq(u64 val, volatile void __iomem *addr)
+{
+       writel(val, addr);
+       writel(val >> 32, addr + 4);
+}
+#endif
+
+static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
+{
+       return readq(adap->regs + reg_addr);
+}
+
+static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
+{
+       writeq(val, adap->regs + reg_addr);
+}
+
+/**
+ * netdev2pinfo - return the port_info structure associated with a net_device
+ * @dev: the netdev
+ *
+ * Return the struct port_info associated with a net_device
+ */
+static inline struct port_info *netdev2pinfo(const struct net_device *dev)
+{
+       return netdev_priv(dev);
+}
+
+/**
+ * adap2pinfo - return the port_info of a port
+ * @adap: the adapter
+ * @idx: the port index
+ *
+ * Return the port_info structure for the port of the given index.
+ */
+static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
+{
+       return netdev_priv(adap->port[idx]);
+}
+
+/**
+ * netdev2adap - return the adapter structure associated with a net_device
+ * @dev: the netdev
+ *
+ * Return the struct adapter associated with a net_device
+ */
+static inline struct adapter *netdev2adap(const struct net_device *dev)
+{
+       return netdev2pinfo(dev)->adapter;
+}
+
+void t4_os_portmod_changed(const struct adapter *adap, int port_id);
+void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
+
+void *t4_alloc_mem(size_t size);
+void t4_free_mem(void *addr);
+
+void t4_free_sge_resources(struct adapter *adap);
+irq_handler_t t4_intr_handler(struct adapter *adap);
+netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
+int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
+                    const struct pkt_gl *gl);
+int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
+int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
+int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
+                    struct net_device *dev, int intr_idx,
+                    struct sge_fl *fl, rspq_handler_t hnd);
+int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
+                        struct net_device *dev, struct netdev_queue *netdevq,
+                        unsigned int iqid);
+int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
+                         struct net_device *dev, unsigned int iqid,
+                         unsigned int cmplqid);
+int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
+                         struct net_device *dev, unsigned int iqid);
+irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
+void t4_sge_init(struct adapter *adap);
+void t4_sge_start(struct adapter *adap);
+void t4_sge_stop(struct adapter *adap);
+
+#define for_each_port(adapter, iter) \
+       for (iter = 0; iter < (adapter)->params.nports; ++iter)
+
+static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
+{
+       return adap->params.vpd.cclk / 1000;
+}
+
+static inline unsigned int us_to_core_ticks(const struct adapter *adap,
+                                           unsigned int us)
+{
+       return (us * adap->params.vpd.cclk) / 1000;
+}
+
+void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
+                     u32 val);
+
+int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
+                   void *rpl, bool sleep_ok);
+
+static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
+                            int size, void *rpl)
+{
+       return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
+}
+
+static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
+                               int size, void *rpl)
+{
+       return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
+}
+
+void t4_intr_enable(struct adapter *adapter);
+void t4_intr_disable(struct adapter *adapter);
+void t4_intr_clear(struct adapter *adapter);
+int t4_slow_intr_handler(struct adapter *adapter);
+
+int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
+                 struct link_config *lc);
+int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
+int t4_seeprom_wp(struct adapter *adapter, bool enable);
+int t4_read_flash(struct adapter *adapter, unsigned int addr,
+                 unsigned int nwords, u32 *data, int byte_oriented);
+int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
+int t4_check_fw_version(struct adapter *adapter);
+int t4_prep_adapter(struct adapter *adapter);
+int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
+void t4_fatal_err(struct adapter *adapter);
+void t4_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on);
+int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
+                       int filter_index, int enable);
+void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
+                        int filter_index, int *enabled);
+int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
+                       int start, int n, const u16 *rspq, unsigned int nrspq);
+int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
+                      unsigned int flags);
+int t4_read_rss(struct adapter *adapter, u16 *entries);
+int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *parity);
+int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
+               u64 *parity);
+
+void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
+void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
+
+void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
+void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st);
+void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
+                        struct tp_tcp_stats *v6);
+void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
+                 const unsigned short *alpha, const unsigned short *beta);
+
+void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
+                        const u8 *addr);
+int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
+                     u64 mask0, u64 mask1, unsigned int crc, bool enable);
+
+int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
+               enum dev_master master, enum dev_state *state);
+int t4_fw_bye(struct adapter *adap, unsigned int mbox);
+int t4_early_init(struct adapter *adap, unsigned int mbox);
+int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
+int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int nparams, const u32 *params,
+                   u32 *val);
+int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                 unsigned int vf, unsigned int nparams, const u32 *params,
+                 const u32 *val);
+int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
+               unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
+               unsigned int rxqi, unsigned int rxq, unsigned int tc,
+               unsigned int vi, unsigned int cmask, unsigned int pmask,
+               unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
+int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
+               unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
+               unsigned int *rss_size);
+int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
+              unsigned int vf, unsigned int viid);
+int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
+               int mtu, int promisc, int all_multi, int bcast, bool sleep_ok);
+int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
+                     unsigned int viid, bool free, unsigned int naddr,
+                     const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
+int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                 int idx, const u8 *addr, bool persist, bool add_smt);
+int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                    bool ucast, u64 vec, bool sleep_ok);
+int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                bool rx_en, bool tx_en);
+int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                    unsigned int nblinks);
+int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
+              unsigned int mmd, unsigned int reg, u16 *valp);
+int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
+              unsigned int mmd, unsigned int reg, u16 val);
+int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
+                    unsigned int pf, unsigned int vf, unsigned int iqid,
+                    unsigned int fl0id, unsigned int fl1id);
+int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+              unsigned int vf, unsigned int iqtype, unsigned int iqid,
+              unsigned int fl0id, unsigned int fl1id);
+int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                  unsigned int vf, unsigned int eqid);
+int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int eqid);
+int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int eqid);
+int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
+#endif /* __CXGB4_H__ */
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
new file mode 100644 (file)
index 0000000..a7e30a2
--- /dev/null
@@ -0,0 +1,3388 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/bitmap.h>
+#include <linux/crc32.h>
+#include <linux/ctype.h>
+#include <linux/debugfs.h>
+#include <linux/err.h>
+#include <linux/etherdevice.h>
+#include <linux/firmware.h>
+#include <linux/if_vlan.h>
+#include <linux/init.h>
+#include <linux/log2.h>
+#include <linux/mdio.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/aer.h>
+#include <linux/rtnetlink.h>
+#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/sockios.h>
+#include <linux/vmalloc.h>
+#include <linux/workqueue.h>
+#include <net/neighbour.h>
+#include <net/netevent.h>
+#include <asm/uaccess.h>
+
+#include "cxgb4.h"
+#include "t4_regs.h"
+#include "t4_msg.h"
+#include "t4fw_api.h"
+#include "l2t.h"
+
+#define DRV_VERSION "1.0.0-ko"
+#define DRV_DESC "Chelsio T4 Network Driver"
+
+/*
+ * Max interrupt hold-off timer value in us.  Queues fall back to this value
+ * under extreme memory pressure so it's largish to give the system time to
+ * recover.
+ */
+#define MAX_SGE_TIMERVAL 200U
+
+enum {
+       MEMWIN0_APERTURE = 65536,
+       MEMWIN0_BASE     = 0x30000,
+       MEMWIN1_APERTURE = 32768,
+       MEMWIN1_BASE     = 0x28000,
+       MEMWIN2_APERTURE = 2048,
+       MEMWIN2_BASE     = 0x1b800,
+};
+
+enum {
+       MAX_TXQ_ENTRIES      = 16384,
+       MAX_CTRL_TXQ_ENTRIES = 1024,
+       MAX_RSPQ_ENTRIES     = 16384,
+       MAX_RX_BUFFERS       = 16384,
+       MIN_TXQ_ENTRIES      = 32,
+       MIN_CTRL_TXQ_ENTRIES = 32,
+       MIN_RSPQ_ENTRIES     = 128,
+       MIN_FL_ENTRIES       = 16
+};
+
+#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \
+                        NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\
+                        NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
+
+#define CH_DEVICE(devid) { PCI_VDEVICE(CHELSIO, devid), 0 }
+
+static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
+       CH_DEVICE(0xa000),  /* PE10K */
+       { 0, }
+};
+
+#define FW_FNAME "cxgb4/t4fw.bin"
+
+MODULE_DESCRIPTION(DRV_DESC);
+MODULE_AUTHOR("Chelsio Communications");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(DRV_VERSION);
+MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl);
+MODULE_FIRMWARE(FW_FNAME);
+
+static int dflt_msg_enable = DFLT_MSG_ENABLE;
+
+module_param(dflt_msg_enable, int, 0644);
+MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T4 default message enable bitmap");
+
+/*
+ * The driver uses the best interrupt scheme available on a platform in the
+ * order MSI-X, MSI, legacy INTx interrupts.  This parameter determines which
+ * of these schemes the driver may consider as follows:
+ *
+ * msi = 2: choose from among all three options
+ * msi = 1: only consider MSI and INTx interrupts
+ * msi = 0: force INTx interrupts
+ */
+static int msi = 2;
+
+module_param(msi, int, 0644);
+MODULE_PARM_DESC(msi, "whether to use INTx (0), MSI (1) or MSI-X (2)");
+
+/*
+ * Queue interrupt hold-off timer values.  Queues default to the first of these
+ * upon creation.
+ */
+static unsigned int intr_holdoff[SGE_NTIMERS - 1] = { 5, 10, 20, 50, 100 };
+
+module_param_array(intr_holdoff, uint, NULL, 0644);
+MODULE_PARM_DESC(intr_holdoff, "values for queue interrupt hold-off timers "
+                "0..4 in microseconds");
+
+static unsigned int intr_cnt[SGE_NCOUNTERS - 1] = { 4, 8, 16 };
+
+module_param_array(intr_cnt, uint, NULL, 0644);
+MODULE_PARM_DESC(intr_cnt,
+                "thresholds 1..3 for queue interrupt packet counters");
+
+static int vf_acls;
+
+#ifdef CONFIG_PCI_IOV
+module_param(vf_acls, bool, 0644);
+MODULE_PARM_DESC(vf_acls, "if set enable virtualization L2 ACL enforcement");
+
+static unsigned int num_vf[4];
+
+module_param_array(num_vf, uint, NULL, 0644);
+MODULE_PARM_DESC(num_vf, "number of VFs for each of PFs 0-3");
+#endif
+
+static struct dentry *cxgb4_debugfs_root;
+
+static LIST_HEAD(adapter_list);
+static DEFINE_MUTEX(uld_mutex);
+static struct cxgb4_uld_info ulds[CXGB4_ULD_MAX];
+static const char *uld_str[] = { "RDMA", "iSCSI" };
+
+static void link_report(struct net_device *dev)
+{
+       if (!netif_carrier_ok(dev))
+               netdev_info(dev, "link down\n");
+       else {
+               static const char *fc[] = { "no", "Rx", "Tx", "Tx/Rx" };
+
+               const char *s = "10Mbps";
+               const struct port_info *p = netdev_priv(dev);
+
+               switch (p->link_cfg.speed) {
+               case SPEED_10000:
+                       s = "10Gbps";
+                       break;
+               case SPEED_1000:
+                       s = "1000Mbps";
+                       break;
+               case SPEED_100:
+                       s = "100Mbps";
+                       break;
+               }
+
+               netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s,
+                           fc[p->link_cfg.fc]);
+       }
+}
+
+void t4_os_link_changed(struct adapter *adapter, int port_id, int link_stat)
+{
+       struct net_device *dev = adapter->port[port_id];
+
+       /* Skip changes from disabled ports. */
+       if (netif_running(dev) && link_stat != netif_carrier_ok(dev)) {
+               if (link_stat)
+                       netif_carrier_on(dev);
+               else
+                       netif_carrier_off(dev);
+
+               link_report(dev);
+       }
+}
+
+void t4_os_portmod_changed(const struct adapter *adap, int port_id)
+{
+       static const char *mod_str[] = {
+               NULL, "LR", "SR", "ER", "passive DA", "active DA"
+       };
+
+       const struct net_device *dev = adap->port[port_id];
+       const struct port_info *pi = netdev_priv(dev);
+
+       if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
+               netdev_info(dev, "port module unplugged\n");
+       else
+               netdev_info(dev, "%s module inserted\n", mod_str[pi->mod_type]);
+}
+
+/*
+ * Configure the exact and hash address filters to handle a port's multicast
+ * and secondary unicast MAC addresses.
+ */
+static int set_addr_filters(const struct net_device *dev, bool sleep)
+{
+       u64 mhash = 0;
+       u64 uhash = 0;
+       bool free = true;
+       u16 filt_idx[7];
+       const u8 *addr[7];
+       int ret, naddr = 0;
+       const struct dev_addr_list *d;
+       const struct netdev_hw_addr *ha;
+       int uc_cnt = netdev_uc_count(dev);
+       const struct port_info *pi = netdev_priv(dev);
+
+       /* first do the secondary unicast addresses */
+       netdev_for_each_uc_addr(ha, dev) {
+               addr[naddr++] = ha->addr;
+               if (--uc_cnt == 0 || naddr >= ARRAY_SIZE(addr)) {
+                       ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free,
+                                       naddr, addr, filt_idx, &uhash, sleep);
+                       if (ret < 0)
+                               return ret;
+
+                       free = false;
+                       naddr = 0;
+               }
+       }
+
+       /* next set up the multicast addresses */
+       netdev_for_each_mc_addr(d, dev) {
+               addr[naddr++] = d->dmi_addr;
+               if (naddr >= ARRAY_SIZE(addr) || d->next == NULL) {
+                       ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free,
+                                       naddr, addr, filt_idx, &mhash, sleep);
+                       if (ret < 0)
+                               return ret;
+
+                       free = false;
+                       naddr = 0;
+               }
+       }
+
+       return t4_set_addr_hash(pi->adapter, 0, pi->viid, uhash != 0,
+                               uhash | mhash, sleep);
+}
+
+/*
+ * Set Rx properties of a port, such as promiscruity, address filters, and MTU.
+ * If @mtu is -1 it is left unchanged.
+ */
+static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
+{
+       int ret;
+       struct port_info *pi = netdev_priv(dev);
+
+       ret = set_addr_filters(dev, sleep_ok);
+       if (ret == 0)
+               ret = t4_set_rxmode(pi->adapter, 0, pi->viid, mtu,
+                                   (dev->flags & IFF_PROMISC) ? 1 : 0,
+                                   (dev->flags & IFF_ALLMULTI) ? 1 : 0, 1,
+                                   sleep_ok);
+       return ret;
+}
+
+/**
+ *     link_start - enable a port
+ *     @dev: the port to enable
+ *
+ *     Performs the MAC and PHY actions needed to enable a port.
+ */
+static int link_start(struct net_device *dev)
+{
+       int ret;
+       struct port_info *pi = netdev_priv(dev);
+
+       /*
+        * We do not set address filters and promiscuity here, the stack does
+        * that step explicitly.
+        */
+       ret = t4_set_rxmode(pi->adapter, 0, pi->viid, dev->mtu, -1, -1, -1,
+                           true);
+       if (ret == 0) {
+               ret = t4_change_mac(pi->adapter, 0, pi->viid,
+                                   pi->xact_addr_filt, dev->dev_addr, true,
+                                   false);
+               if (ret >= 0) {
+                       pi->xact_addr_filt = ret;
+                       ret = 0;
+               }
+       }
+       if (ret == 0)
+               ret = t4_link_start(pi->adapter, 0, pi->tx_chan, &pi->link_cfg);
+       if (ret == 0)
+               ret = t4_enable_vi(pi->adapter, 0, pi->viid, true, true);
+       return ret;
+}
+
+/*
+ * Response queue handler for the FW event queue.
+ */
+static int fwevtq_handler(struct sge_rspq *q, const __be64 *rsp,
+                         const struct pkt_gl *gl)
+{
+       u8 opcode = ((const struct rss_header *)rsp)->opcode;
+
+       rsp++;                                          /* skip RSS header */
+       if (likely(opcode == CPL_SGE_EGR_UPDATE)) {
+               const struct cpl_sge_egr_update *p = (void *)rsp;
+               unsigned int qid = EGR_QID(ntohl(p->opcode_qid));
+               struct sge_txq *txq = q->adap->sge.egr_map[qid];
+
+               txq->restarts++;
+               if ((u8 *)txq < (u8 *)q->adap->sge.ethrxq) {
+                       struct sge_eth_txq *eq;
+
+                       eq = container_of(txq, struct sge_eth_txq, q);
+                       netif_tx_wake_queue(eq->txq);
+               } else {
+                       struct sge_ofld_txq *oq;
+
+                       oq = container_of(txq, struct sge_ofld_txq, q);
+                       tasklet_schedule(&oq->qresume_tsk);
+               }
+       } else if (opcode == CPL_FW6_MSG || opcode == CPL_FW4_MSG) {
+               const struct cpl_fw6_msg *p = (void *)rsp;
+
+               if (p->type == 0)
+                       t4_handle_fw_rpl(q->adap, p->data);
+       } else if (opcode == CPL_L2T_WRITE_RPL) {
+               const struct cpl_l2t_write_rpl *p = (void *)rsp;
+
+               do_l2t_write_rpl(q->adap, p);
+       } else
+               dev_err(q->adap->pdev_dev,
+                       "unexpected CPL %#x on FW event queue\n", opcode);
+       return 0;
+}
+
+/**
+ *     uldrx_handler - response queue handler for ULD queues
+ *     @q: the response queue that received the packet
+ *     @rsp: the response queue descriptor holding the offload message
+ *     @gl: the gather list of packet fragments
+ *
+ *     Deliver an ingress offload packet to a ULD.  All processing is done by
+ *     the ULD, we just maintain statistics.
+ */
+static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
+                        const struct pkt_gl *gl)
+{
+       struct sge_ofld_rxq *rxq = container_of(q, struct sge_ofld_rxq, rspq);
+
+       if (ulds[q->uld].rx_handler(q->adap->uld_handle[q->uld], rsp, gl)) {
+               rxq->stats.nomem++;
+               return -1;
+       }
+       if (gl == NULL)
+               rxq->stats.imm++;
+       else if (gl == CXGB4_MSG_AN)
+               rxq->stats.an++;
+       else
+               rxq->stats.pkts++;
+       return 0;
+}
+
+static void disable_msi(struct adapter *adapter)
+{
+       if (adapter->flags & USING_MSIX) {
+               pci_disable_msix(adapter->pdev);
+               adapter->flags &= ~USING_MSIX;
+       } else if (adapter->flags & USING_MSI) {
+               pci_disable_msi(adapter->pdev);
+               adapter->flags &= ~USING_MSI;
+       }
+}
+
+/*
+ * Interrupt handler for non-data events used with MSI-X.
+ */
+static irqreturn_t t4_nondata_intr(int irq, void *cookie)
+{
+       struct adapter *adap = cookie;
+
+       u32 v = t4_read_reg(adap, MYPF_REG(PL_PF_INT_CAUSE));
+       if (v & PFSW) {
+               adap->swintr = 1;
+               t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE), v);
+       }
+       t4_slow_intr_handler(adap);
+       return IRQ_HANDLED;
+}
+
+/*
+ * Name the MSI-X interrupts.
+ */
+static void name_msix_vecs(struct adapter *adap)
+{
+       int i, j, msi_idx = 2, n = sizeof(adap->msix_info[0].desc) - 1;
+
+       /* non-data interrupts */
+       snprintf(adap->msix_info[0].desc, n, "%s", adap->name);
+       adap->msix_info[0].desc[n] = 0;
+
+       /* FW events */
+       snprintf(adap->msix_info[1].desc, n, "%s-FWeventq", adap->name);
+       adap->msix_info[1].desc[n] = 0;
+
+       /* Ethernet queues */
+       for_each_port(adap, j) {
+               struct net_device *d = adap->port[j];
+               const struct port_info *pi = netdev_priv(d);
+
+               for (i = 0; i < pi->nqsets; i++, msi_idx++) {
+                       snprintf(adap->msix_info[msi_idx].desc, n, "%s-Rx%d",
+                                d->name, i);
+                       adap->msix_info[msi_idx].desc[n] = 0;
+               }
+       }
+
+       /* offload queues */
+       for_each_ofldrxq(&adap->sge, i) {
+               snprintf(adap->msix_info[msi_idx].desc, n, "%s-ofld%d",
+                        adap->name, i);
+               adap->msix_info[msi_idx++].desc[n] = 0;
+       }
+       for_each_rdmarxq(&adap->sge, i) {
+               snprintf(adap->msix_info[msi_idx].desc, n, "%s-rdma%d",
+                        adap->name, i);
+               adap->msix_info[msi_idx++].desc[n] = 0;
+       }
+}
+
+static int request_msix_queue_irqs(struct adapter *adap)
+{
+       struct sge *s = &adap->sge;
+       int err, ethqidx, ofldqidx = 0, rdmaqidx = 0, msi = 2;
+
+       err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0,
+                         adap->msix_info[1].desc, &s->fw_evtq);
+       if (err)
+               return err;
+
+       for_each_ethrxq(s, ethqidx) {
+               err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+                                 adap->msix_info[msi].desc,
+                                 &s->ethrxq[ethqidx].rspq);
+               if (err)
+                       goto unwind;
+               msi++;
+       }
+       for_each_ofldrxq(s, ofldqidx) {
+               err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+                                 adap->msix_info[msi].desc,
+                                 &s->ofldrxq[ofldqidx].rspq);
+               if (err)
+                       goto unwind;
+               msi++;
+       }
+       for_each_rdmarxq(s, rdmaqidx) {
+               err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
+                                 adap->msix_info[msi].desc,
+                                 &s->rdmarxq[rdmaqidx].rspq);
+               if (err)
+                       goto unwind;
+               msi++;
+       }
+       return 0;
+
+unwind:
+       while (--rdmaqidx >= 0)
+               free_irq(adap->msix_info[--msi].vec,
+                        &s->rdmarxq[rdmaqidx].rspq);
+       while (--ofldqidx >= 0)
+               free_irq(adap->msix_info[--msi].vec,
+                        &s->ofldrxq[ofldqidx].rspq);
+       while (--ethqidx >= 0)
+               free_irq(adap->msix_info[--msi].vec, &s->ethrxq[ethqidx].rspq);
+       free_irq(adap->msix_info[1].vec, &s->fw_evtq);
+       return err;
+}
+
+static void free_msix_queue_irqs(struct adapter *adap)
+{
+       int i, msi = 2;
+       struct sge *s = &adap->sge;
+
+       free_irq(adap->msix_info[1].vec, &s->fw_evtq);
+       for_each_ethrxq(s, i)
+               free_irq(adap->msix_info[msi++].vec, &s->ethrxq[i].rspq);
+       for_each_ofldrxq(s, i)
+               free_irq(adap->msix_info[msi++].vec, &s->ofldrxq[i].rspq);
+       for_each_rdmarxq(s, i)
+               free_irq(adap->msix_info[msi++].vec, &s->rdmarxq[i].rspq);
+}
+
+/**
+ *     setup_rss - configure RSS
+ *     @adap: the adapter
+ *
+ *     Sets up RSS to distribute packets to multiple receive queues.  We
+ *     configure the RSS CPU lookup table to distribute to the number of HW
+ *     receive queues, and the response queue lookup table to narrow that
+ *     down to the response queues actually configured for each port.
+ *     We always configure the RSS mapping for all ports since the mapping
+ *     table has plenty of entries.
+ */
+static int setup_rss(struct adapter *adap)
+{
+       int i, j, err;
+       u16 rss[MAX_ETH_QSETS];
+
+       for_each_port(adap, i) {
+               const struct port_info *pi = adap2pinfo(adap, i);
+               const struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
+
+               for (j = 0; j < pi->nqsets; j++)
+                       rss[j] = q[j].rspq.abs_id;
+
+               err = t4_config_rss_range(adap, 0, pi->viid, 0, pi->rss_size,
+                                         rss, pi->nqsets);
+               if (err)
+                       return err;
+       }
+       return 0;
+}
+
+/*
+ * Wait until all NAPI handlers are descheduled.
+ */
+static void quiesce_rx(struct adapter *adap)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
+               struct sge_rspq *q = adap->sge.ingr_map[i];
+
+               if (q && q->handler)
+                       napi_disable(&q->napi);
+       }
+}
+
+/*
+ * Enable NAPI scheduling and interrupt generation for all Rx queues.
+ */
+static void enable_rx(struct adapter *adap)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
+               struct sge_rspq *q = adap->sge.ingr_map[i];
+
+               if (!q)
+                       continue;
+               if (q->handler)
+                       napi_enable(&q->napi);
+               /* 0-increment GTS to start the timer and enable interrupts */
+               t4_write_reg(adap, MYPF_REG(SGE_PF_GTS),
+                            SEINTARM(q->intr_params) |
+                            INGRESSQID(q->cntxt_id));
+       }
+}
+
+/**
+ *     setup_sge_queues - configure SGE Tx/Rx/response queues
+ *     @adap: the adapter
+ *
+ *     Determines how many sets of SGE queues to use and initializes them.
+ *     We support multiple queue sets per port if we have MSI-X, otherwise
+ *     just one queue set per port.
+ */
+static int setup_sge_queues(struct adapter *adap)
+{
+       int err, msi_idx, i, j;
+       struct sge *s = &adap->sge;
+
+       bitmap_zero(s->starving_fl, MAX_EGRQ);
+       bitmap_zero(s->txq_maperr, MAX_EGRQ);
+
+       if (adap->flags & USING_MSIX)
+               msi_idx = 1;         /* vector 0 is for non-queue interrupts */
+       else {
+               err = t4_sge_alloc_rxq(adap, &s->intrq, false, adap->port[0], 0,
+                                      NULL, NULL);
+               if (err)
+                       return err;
+               msi_idx = -((int)s->intrq.abs_id + 1);
+       }
+
+       err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
+                              msi_idx, NULL, fwevtq_handler);
+       if (err) {
+freeout:       t4_free_sge_resources(adap);
+               return err;
+       }
+
+       for_each_port(adap, i) {
+               struct net_device *dev = adap->port[i];
+               struct port_info *pi = netdev_priv(dev);
+               struct sge_eth_rxq *q = &s->ethrxq[pi->first_qset];
+               struct sge_eth_txq *t = &s->ethtxq[pi->first_qset];
+
+               for (j = 0; j < pi->nqsets; j++, q++) {
+                       if (msi_idx > 0)
+                               msi_idx++;
+                       err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev,
+                                              msi_idx, &q->fl,
+                                              t4_ethrx_handler);
+                       if (err)
+                               goto freeout;
+                       q->rspq.idx = j;
+                       memset(&q->stats, 0, sizeof(q->stats));
+               }
+               for (j = 0; j < pi->nqsets; j++, t++) {
+                       err = t4_sge_alloc_eth_txq(adap, t, dev,
+                                       netdev_get_tx_queue(dev, j),
+                                       s->fw_evtq.cntxt_id);
+                       if (err)
+                               goto freeout;
+               }
+       }
+
+       j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */
+       for_each_ofldrxq(s, i) {
+               struct sge_ofld_rxq *q = &s->ofldrxq[i];
+               struct net_device *dev = adap->port[i / j];
+
+               if (msi_idx > 0)
+                       msi_idx++;
+               err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev, msi_idx,
+                                      &q->fl, uldrx_handler);
+               if (err)
+                       goto freeout;
+               memset(&q->stats, 0, sizeof(q->stats));
+               s->ofld_rxq[i] = q->rspq.abs_id;
+               err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], dev,
+                                           s->fw_evtq.cntxt_id);
+               if (err)
+                       goto freeout;
+       }
+
+       for_each_rdmarxq(s, i) {
+               struct sge_ofld_rxq *q = &s->rdmarxq[i];
+
+               if (msi_idx > 0)
+                       msi_idx++;
+               err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
+                                      msi_idx, &q->fl, uldrx_handler);
+               if (err)
+                       goto freeout;
+               memset(&q->stats, 0, sizeof(q->stats));
+               s->rdma_rxq[i] = q->rspq.abs_id;
+       }
+
+       for_each_port(adap, i) {
+               /*
+                * Note that ->rdmarxq[i].rspq.cntxt_id below is 0 if we don't
+                * have RDMA queues, and that's the right value.
+                */
+               err = t4_sge_alloc_ctrl_txq(adap, &s->ctrlq[i], adap->port[i],
+                                           s->fw_evtq.cntxt_id,
+                                           s->rdmarxq[i].rspq.cntxt_id);
+               if (err)
+                       goto freeout;
+       }
+
+       t4_write_reg(adap, MPS_TRC_RSS_CONTROL,
+                    RSSCONTROL(netdev2pinfo(adap->port[0])->tx_chan) |
+                    QUEUENUMBER(s->ethrxq[0].rspq.abs_id));
+       return 0;
+}
+
+/*
+ * Returns 0 if new FW was successfully loaded, a positive errno if a load was
+ * started but failed, and a negative errno if flash load couldn't start.
+ */
+static int upgrade_fw(struct adapter *adap)
+{
+       int ret;
+       u32 vers;
+       const struct fw_hdr *hdr;
+       const struct firmware *fw;
+       struct device *dev = adap->pdev_dev;
+
+       ret = request_firmware(&fw, FW_FNAME, dev);
+       if (ret < 0) {
+               dev_err(dev, "unable to load firmware image " FW_FNAME
+                       ", error %d\n", ret);
+               return ret;
+       }
+
+       hdr = (const struct fw_hdr *)fw->data;
+       vers = ntohl(hdr->fw_ver);
+       if (FW_HDR_FW_VER_MAJOR_GET(vers) != FW_VERSION_MAJOR) {
+               ret = -EINVAL;              /* wrong major version, won't do */
+               goto out;
+       }
+
+       /*
+        * If the flash FW is unusable or we found something newer, load it.
+        */
+       if (FW_HDR_FW_VER_MAJOR_GET(adap->params.fw_vers) != FW_VERSION_MAJOR ||
+           vers > adap->params.fw_vers) {
+               ret = -t4_load_fw(adap, fw->data, fw->size);
+               if (!ret)
+                       dev_info(dev, "firmware upgraded to version %pI4 from "
+                                FW_FNAME "\n", &hdr->fw_ver);
+       }
+out:   release_firmware(fw);
+       return ret;
+}
+
+/*
+ * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
+ * The allocated memory is cleared.
+ */
+void *t4_alloc_mem(size_t size)
+{
+       void *p = kmalloc(size, GFP_KERNEL);
+
+       if (!p)
+               p = vmalloc(size);
+       if (p)
+               memset(p, 0, size);
+       return p;
+}
+
+/*
+ * Free memory allocated through alloc_mem().
+ */
+void t4_free_mem(void *addr)
+{
+       if (is_vmalloc_addr(addr))
+               vfree(addr);
+       else
+               kfree(addr);
+}
+
+static inline int is_offload(const struct adapter *adap)
+{
+       return adap->params.offload;
+}
+
+/*
+ * Implementation of ethtool operations.
+ */
+
+static u32 get_msglevel(struct net_device *dev)
+{
+       return netdev2adap(dev)->msg_enable;
+}
+
+static void set_msglevel(struct net_device *dev, u32 val)
+{
+       netdev2adap(dev)->msg_enable = val;
+}
+
+static char stats_strings[][ETH_GSTRING_LEN] = {
+       "TxOctetsOK         ",
+       "TxFramesOK         ",
+       "TxBroadcastFrames  ",
+       "TxMulticastFrames  ",
+       "TxUnicastFrames    ",
+       "TxErrorFrames      ",
+
+       "TxFrames64         ",
+       "TxFrames65To127    ",
+       "TxFrames128To255   ",
+       "TxFrames256To511   ",
+       "TxFrames512To1023  ",
+       "TxFrames1024To1518 ",
+       "TxFrames1519ToMax  ",
+
+       "TxFramesDropped    ",
+       "TxPauseFrames      ",
+       "TxPPP0Frames       ",
+       "TxPPP1Frames       ",
+       "TxPPP2Frames       ",
+       "TxPPP3Frames       ",
+       "TxPPP4Frames       ",
+       "TxPPP5Frames       ",
+       "TxPPP6Frames       ",
+       "TxPPP7Frames       ",
+
+       "RxOctetsOK         ",
+       "RxFramesOK         ",
+       "RxBroadcastFrames  ",
+       "RxMulticastFrames  ",
+       "RxUnicastFrames    ",
+
+       "RxFramesTooLong    ",
+       "RxJabberErrors     ",
+       "RxFCSErrors        ",
+       "RxLengthErrors     ",
+       "RxSymbolErrors     ",
+       "RxRuntFrames       ",
+
+       "RxFrames64         ",
+       "RxFrames65To127    ",
+       "RxFrames128To255   ",
+       "RxFrames256To511   ",
+       "RxFrames512To1023  ",
+       "RxFrames1024To1518 ",
+       "RxFrames1519ToMax  ",
+
+       "RxPauseFrames      ",
+       "RxPPP0Frames       ",
+       "RxPPP1Frames       ",
+       "RxPPP2Frames       ",
+       "RxPPP3Frames       ",
+       "RxPPP4Frames       ",
+       "RxPPP5Frames       ",
+       "RxPPP6Frames       ",
+       "RxPPP7Frames       ",
+
+       "RxBG0FramesDropped ",
+       "RxBG1FramesDropped ",
+       "RxBG2FramesDropped ",
+       "RxBG3FramesDropped ",
+       "RxBG0FramesTrunc   ",
+       "RxBG1FramesTrunc   ",
+       "RxBG2FramesTrunc   ",
+       "RxBG3FramesTrunc   ",
+
+       "TSO                ",
+       "TxCsumOffload      ",
+       "RxCsumGood         ",
+       "VLANextractions    ",
+       "VLANinsertions     ",
+};
+
+static int get_sset_count(struct net_device *dev, int sset)
+{
+       switch (sset) {
+       case ETH_SS_STATS:
+               return ARRAY_SIZE(stats_strings);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+#define T4_REGMAP_SIZE (160 * 1024)
+
+static int get_regs_len(struct net_device *dev)
+{
+       return T4_REGMAP_SIZE;
+}
+
+static int get_eeprom_len(struct net_device *dev)
+{
+       return EEPROMSIZE;
+}
+
+static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+       struct adapter *adapter = netdev2adap(dev);
+
+       strcpy(info->driver, KBUILD_MODNAME);
+       strcpy(info->version, DRV_VERSION);
+       strcpy(info->bus_info, pci_name(adapter->pdev));
+
+       if (!adapter->params.fw_vers)
+               strcpy(info->fw_version, "N/A");
+       else
+               snprintf(info->fw_version, sizeof(info->fw_version),
+                       "%u.%u.%u.%u, TP %u.%u.%u.%u",
+                       FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers),
+                       FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers),
+                       FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers),
+                       FW_HDR_FW_VER_BUILD_GET(adapter->params.fw_vers),
+                       FW_HDR_FW_VER_MAJOR_GET(adapter->params.tp_vers),
+                       FW_HDR_FW_VER_MINOR_GET(adapter->params.tp_vers),
+                       FW_HDR_FW_VER_MICRO_GET(adapter->params.tp_vers),
+                       FW_HDR_FW_VER_BUILD_GET(adapter->params.tp_vers));
+}
+
+static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
+{
+       if (stringset == ETH_SS_STATS)
+               memcpy(data, stats_strings, sizeof(stats_strings));
+}
+
+/*
+ * port stats maintained per queue of the port.  They should be in the same
+ * order as in stats_strings above.
+ */
+struct queue_port_stats {
+       u64 tso;
+       u64 tx_csum;
+       u64 rx_csum;
+       u64 vlan_ex;
+       u64 vlan_ins;
+};
+
+static void collect_sge_port_stats(const struct adapter *adap,
+               const struct port_info *p, struct queue_port_stats *s)
+{
+       int i;
+       const struct sge_eth_txq *tx = &adap->sge.ethtxq[p->first_qset];
+       const struct sge_eth_rxq *rx = &adap->sge.ethrxq[p->first_qset];
+
+       memset(s, 0, sizeof(*s));
+       for (i = 0; i < p->nqsets; i++, rx++, tx++) {
+               s->tso += tx->tso;
+               s->tx_csum += tx->tx_cso;
+               s->rx_csum += rx->stats.rx_cso;
+               s->vlan_ex += rx->stats.vlan_ex;
+               s->vlan_ins += tx->vlan_ins;
+       }
+}
+
+static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
+                     u64 *data)
+{
+       struct port_info *pi = netdev_priv(dev);
+       struct adapter *adapter = pi->adapter;
+
+       t4_get_port_stats(adapter, pi->tx_chan, (struct port_stats *)data);
+
+       data += sizeof(struct port_stats) / sizeof(u64);
+       collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
+}
+
+/*
+ * Return a version number to identify the type of adapter.  The scheme is:
+ * - bits 0..9: chip version
+ * - bits 10..15: chip revision
+ */
+static inline unsigned int mk_adap_vers(const struct adapter *ap)
+{
+       return 4 | (ap->params.rev << 10);
+}
+
+static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start,
+                          unsigned int end)
+{
+       u32 *p = buf + start;
+
+       for ( ; start <= end; start += sizeof(u32))
+               *p++ = t4_read_reg(ap, start);
+}
+
+static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
+                    void *buf)
+{
+       static const unsigned int reg_ranges[] = {
+               0x1008, 0x1108,
+               0x1180, 0x11b4,
+               0x11fc, 0x123c,
+               0x1300, 0x173c,
+               0x1800, 0x18fc,
+               0x3000, 0x30d8,
+               0x30e0, 0x5924,
+               0x5960, 0x59d4,
+               0x5a00, 0x5af8,
+               0x6000, 0x6098,
+               0x6100, 0x6150,
+               0x6200, 0x6208,
+               0x6240, 0x6248,
+               0x6280, 0x6338,
+               0x6370, 0x638c,
+               0x6400, 0x643c,
+               0x6500, 0x6524,
+               0x6a00, 0x6a38,
+               0x6a60, 0x6a78,
+               0x6b00, 0x6b84,
+               0x6bf0, 0x6c84,
+               0x6cf0, 0x6d84,
+               0x6df0, 0x6e84,
+               0x6ef0, 0x6f84,
+               0x6ff0, 0x7084,
+               0x70f0, 0x7184,
+               0x71f0, 0x7284,
+               0x72f0, 0x7384,
+               0x73f0, 0x7450,
+               0x7500, 0x7530,
+               0x7600, 0x761c,
+               0x7680, 0x76cc,
+               0x7700, 0x7798,
+               0x77c0, 0x77fc,
+               0x7900, 0x79fc,
+               0x7b00, 0x7c38,
+               0x7d00, 0x7efc,
+               0x8dc0, 0x8e1c,
+               0x8e30, 0x8e78,
+               0x8ea0, 0x8f6c,
+               0x8fc0, 0x9074,
+               0x90fc, 0x90fc,
+               0x9400, 0x9458,
+               0x9600, 0x96bc,
+               0x9800, 0x9808,
+               0x9820, 0x983c,
+               0x9850, 0x9864,
+               0x9c00, 0x9c6c,
+               0x9c80, 0x9cec,
+               0x9d00, 0x9d6c,
+               0x9d80, 0x9dec,
+               0x9e00, 0x9e6c,
+               0x9e80, 0x9eec,
+               0x9f00, 0x9f6c,
+               0x9f80, 0x9fec,
+               0xd004, 0xd03c,
+               0xdfc0, 0xdfe0,
+               0xe000, 0xea7c,
+               0xf000, 0x11190,
+               0x19040, 0x19124,
+               0x19150, 0x191b0,
+               0x191d0, 0x191e8,
+               0x19238, 0x1924c,
+               0x193f8, 0x19474,
+               0x19490, 0x194f8,
+               0x19800, 0x19f30,
+               0x1a000, 0x1a06c,
+               0x1a0b0, 0x1a120,
+               0x1a128, 0x1a138,
+               0x1a190, 0x1a1c4,
+               0x1a1fc, 0x1a1fc,
+               0x1e040, 0x1e04c,
+               0x1e240, 0x1e28c,
+               0x1e2c0, 0x1e2c0,
+               0x1e2e0, 0x1e2e0,
+               0x1e300, 0x1e384,
+               0x1e3c0, 0x1e3c8,
+               0x1e440, 0x1e44c,
+               0x1e640, 0x1e68c,
+               0x1e6c0, 0x1e6c0,
+               0x1e6e0, 0x1e6e0,
+               0x1e700, 0x1e784,
+               0x1e7c0, 0x1e7c8,
+               0x1e840, 0x1e84c,
+               0x1ea40, 0x1ea8c,
+               0x1eac0, 0x1eac0,
+               0x1eae0, 0x1eae0,
+               0x1eb00, 0x1eb84,
+               0x1ebc0, 0x1ebc8,
+               0x1ec40, 0x1ec4c,
+               0x1ee40, 0x1ee8c,
+               0x1eec0, 0x1eec0,
+               0x1eee0, 0x1eee0,
+               0x1ef00, 0x1ef84,
+               0x1efc0, 0x1efc8,
+               0x1f040, 0x1f04c,
+               0x1f240, 0x1f28c,
+               0x1f2c0, 0x1f2c0,
+               0x1f2e0, 0x1f2e0,
+               0x1f300, 0x1f384,
+               0x1f3c0, 0x1f3c8,
+               0x1f440, 0x1f44c,
+               0x1f640, 0x1f68c,
+               0x1f6c0, 0x1f6c0,
+               0x1f6e0, 0x1f6e0,
+               0x1f700, 0x1f784,
+               0x1f7c0, 0x1f7c8,
+               0x1f840, 0x1f84c,
+               0x1fa40, 0x1fa8c,
+               0x1fac0, 0x1fac0,
+               0x1fae0, 0x1fae0,
+               0x1fb00, 0x1fb84,
+               0x1fbc0, 0x1fbc8,
+               0x1fc40, 0x1fc4c,
+               0x1fe40, 0x1fe8c,
+               0x1fec0, 0x1fec0,
+               0x1fee0, 0x1fee0,
+               0x1ff00, 0x1ff84,
+               0x1ffc0, 0x1ffc8,
+               0x20000, 0x2002c,
+               0x20100, 0x2013c,
+               0x20190, 0x201c8,
+               0x20200, 0x20318,
+               0x20400, 0x20528,
+               0x20540, 0x20614,
+               0x21000, 0x21040,
+               0x2104c, 0x21060,
+               0x210c0, 0x210ec,
+               0x21200, 0x21268,
+               0x21270, 0x21284,
+               0x212fc, 0x21388,
+               0x21400, 0x21404,
+               0x21500, 0x21518,
+               0x2152c, 0x2153c,
+               0x21550, 0x21554,
+               0x21600, 0x21600,
+               0x21608, 0x21628,
+               0x21630, 0x2163c,
+               0x21700, 0x2171c,
+               0x21780, 0x2178c,
+               0x21800, 0x21c38,
+               0x21c80, 0x21d7c,
+               0x21e00, 0x21e04,
+               0x22000, 0x2202c,
+               0x22100, 0x2213c,
+               0x22190, 0x221c8,
+               0x22200, 0x22318,
+               0x22400, 0x22528,
+               0x22540, 0x22614,
+               0x23000, 0x23040,
+               0x2304c, 0x23060,
+               0x230c0, 0x230ec,
+               0x23200, 0x23268,
+               0x23270, 0x23284,
+               0x232fc, 0x23388,
+               0x23400, 0x23404,
+               0x23500, 0x23518,
+               0x2352c, 0x2353c,
+               0x23550, 0x23554,
+               0x23600, 0x23600,
+               0x23608, 0x23628,
+               0x23630, 0x2363c,
+               0x23700, 0x2371c,
+               0x23780, 0x2378c,
+               0x23800, 0x23c38,
+               0x23c80, 0x23d7c,
+               0x23e00, 0x23e04,
+               0x24000, 0x2402c,
+               0x24100, 0x2413c,
+               0x24190, 0x241c8,
+               0x24200, 0x24318,
+               0x24400, 0x24528,
+               0x24540, 0x24614,
+               0x25000, 0x25040,
+               0x2504c, 0x25060,
+               0x250c0, 0x250ec,
+               0x25200, 0x25268,
+               0x25270, 0x25284,
+               0x252fc, 0x25388,
+               0x25400, 0x25404,
+               0x25500, 0x25518,
+               0x2552c, 0x2553c,
+               0x25550, 0x25554,
+               0x25600, 0x25600,
+               0x25608, 0x25628,
+               0x25630, 0x2563c,
+               0x25700, 0x2571c,
+               0x25780, 0x2578c,
+               0x25800, 0x25c38,
+               0x25c80, 0x25d7c,
+               0x25e00, 0x25e04,
+               0x26000, 0x2602c,
+               0x26100, 0x2613c,
+               0x26190, 0x261c8,
+               0x26200, 0x26318,
+               0x26400, 0x26528,
+               0x26540, 0x26614,
+               0x27000, 0x27040,
+               0x2704c, 0x27060,
+               0x270c0, 0x270ec,
+               0x27200, 0x27268,
+               0x27270, 0x27284,
+               0x272fc, 0x27388,
+               0x27400, 0x27404,
+               0x27500, 0x27518,
+               0x2752c, 0x2753c,
+               0x27550, 0x27554,
+               0x27600, 0x27600,
+               0x27608, 0x27628,
+               0x27630, 0x2763c,
+               0x27700, 0x2771c,
+               0x27780, 0x2778c,
+               0x27800, 0x27c38,
+               0x27c80, 0x27d7c,
+               0x27e00, 0x27e04
+       };
+
+       int i;
+       struct adapter *ap = netdev2adap(dev);
+
+       regs->version = mk_adap_vers(ap);
+
+       memset(buf, 0, T4_REGMAP_SIZE);
+       for (i = 0; i < ARRAY_SIZE(reg_ranges); i += 2)
+               reg_block_dump(ap, buf, reg_ranges[i], reg_ranges[i + 1]);
+}
+
+static int restart_autoneg(struct net_device *dev)
+{
+       struct port_info *p = netdev_priv(dev);
+
+       if (!netif_running(dev))
+               return -EAGAIN;
+       if (p->link_cfg.autoneg != AUTONEG_ENABLE)
+               return -EINVAL;
+       t4_restart_aneg(p->adapter, 0, p->tx_chan);
+       return 0;
+}
+
+static int identify_port(struct net_device *dev, u32 data)
+{
+       if (data == 0)
+               data = 2;     /* default to 2 seconds */
+
+       return t4_identify_port(netdev2adap(dev), 0, netdev2pinfo(dev)->viid,
+                               data * 5);
+}
+
+static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps)
+{
+       unsigned int v = 0;
+
+       if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XAUI) {
+               v |= SUPPORTED_TP;
+               if (caps & FW_PORT_CAP_SPEED_100M)
+                       v |= SUPPORTED_100baseT_Full;
+               if (caps & FW_PORT_CAP_SPEED_1G)
+                       v |= SUPPORTED_1000baseT_Full;
+               if (caps & FW_PORT_CAP_SPEED_10G)
+                       v |= SUPPORTED_10000baseT_Full;
+       } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
+               v |= SUPPORTED_Backplane;
+               if (caps & FW_PORT_CAP_SPEED_1G)
+                       v |= SUPPORTED_1000baseKX_Full;
+               if (caps & FW_PORT_CAP_SPEED_10G)
+                       v |= SUPPORTED_10000baseKX4_Full;
+       } else if (type == FW_PORT_TYPE_KR)
+               v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
+       else if (type == FW_PORT_TYPE_FIBER)
+               v |= SUPPORTED_FIBRE;
+
+       if (caps & FW_PORT_CAP_ANEG)
+               v |= SUPPORTED_Autoneg;
+       return v;
+}
+
+static unsigned int to_fw_linkcaps(unsigned int caps)
+{
+       unsigned int v = 0;
+
+       if (caps & ADVERTISED_100baseT_Full)
+               v |= FW_PORT_CAP_SPEED_100M;
+       if (caps & ADVERTISED_1000baseT_Full)
+               v |= FW_PORT_CAP_SPEED_1G;
+       if (caps & ADVERTISED_10000baseT_Full)
+               v |= FW_PORT_CAP_SPEED_10G;
+       return v;
+}
+
+static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       const struct port_info *p = netdev_priv(dev);
+
+       if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
+           p->port_type == FW_PORT_TYPE_BT_XAUI)
+               cmd->port = PORT_TP;
+       else if (p->port_type == FW_PORT_TYPE_FIBER)
+               cmd->port = PORT_FIBRE;
+       else if (p->port_type == FW_PORT_TYPE_TWINAX)
+               cmd->port = PORT_DA;
+       else
+               cmd->port = PORT_OTHER;
+
+       if (p->mdio_addr >= 0) {
+               cmd->phy_address = p->mdio_addr;
+               cmd->transceiver = XCVR_EXTERNAL;
+               cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
+                       MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
+       } else {
+               cmd->phy_address = 0;  /* not really, but no better option */
+               cmd->transceiver = XCVR_INTERNAL;
+               cmd->mdio_support = 0;
+       }
+
+       cmd->supported = from_fw_linkcaps(p->port_type, p->link_cfg.supported);
+       cmd->advertising = from_fw_linkcaps(p->port_type,
+                                           p->link_cfg.advertising);
+       cmd->speed = netif_carrier_ok(dev) ? p->link_cfg.speed : 0;
+       cmd->duplex = DUPLEX_FULL;
+       cmd->autoneg = p->link_cfg.autoneg;
+       cmd->maxtxpkt = 0;
+       cmd->maxrxpkt = 0;
+       return 0;
+}
+
+static unsigned int speed_to_caps(int speed)
+{
+       if (speed == SPEED_100)
+               return FW_PORT_CAP_SPEED_100M;
+       if (speed == SPEED_1000)
+               return FW_PORT_CAP_SPEED_1G;
+       if (speed == SPEED_10000)
+               return FW_PORT_CAP_SPEED_10G;
+       return 0;
+}
+
+static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+       unsigned int cap;
+       struct port_info *p = netdev_priv(dev);
+       struct link_config *lc = &p->link_cfg;
+
+       if (cmd->duplex != DUPLEX_FULL)     /* only full-duplex supported */
+               return -EINVAL;
+
+       if (!(lc->supported & FW_PORT_CAP_ANEG)) {
+               /*
+                * PHY offers a single speed.  See if that's what's
+                * being requested.
+                */
+               if (cmd->autoneg == AUTONEG_DISABLE &&
+                   (lc->supported & speed_to_caps(cmd->speed)))
+                               return 0;
+               return -EINVAL;
+       }
+
+       if (cmd->autoneg == AUTONEG_DISABLE) {
+               cap = speed_to_caps(cmd->speed);
+
+               if (!(lc->supported & cap) || cmd->speed == SPEED_1000 ||
+                   cmd->speed == SPEED_10000)
+                       return -EINVAL;
+               lc->requested_speed = cap;
+               lc->advertising = 0;
+       } else {
+               cap = to_fw_linkcaps(cmd->advertising);
+               if (!(lc->supported & cap))
+                       return -EINVAL;
+               lc->requested_speed = 0;
+               lc->advertising = cap | FW_PORT_CAP_ANEG;
+       }
+       lc->autoneg = cmd->autoneg;
+
+       if (netif_running(dev))
+               return t4_link_start(p->adapter, 0, p->tx_chan, lc);
+       return 0;
+}
+
+static void get_pauseparam(struct net_device *dev,
+                          struct ethtool_pauseparam *epause)
+{
+       struct port_info *p = netdev_priv(dev);
+
+       epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
+       epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0;
+       epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0;
+}
+
+static int set_pauseparam(struct net_device *dev,
+                         struct ethtool_pauseparam *epause)
+{
+       struct port_info *p = netdev_priv(dev);
+       struct link_config *lc = &p->link_cfg;
+
+       if (epause->autoneg == AUTONEG_DISABLE)
+               lc->requested_fc = 0;
+       else if (lc->supported & FW_PORT_CAP_ANEG)
+               lc->requested_fc = PAUSE_AUTONEG;
+       else
+               return -EINVAL;
+
+       if (epause->rx_pause)
+               lc->requested_fc |= PAUSE_RX;
+       if (epause->tx_pause)
+               lc->requested_fc |= PAUSE_TX;
+       if (netif_running(dev))
+               return t4_link_start(p->adapter, 0, p->tx_chan, lc);
+       return 0;
+}
+
+static u32 get_rx_csum(struct net_device *dev)
+{
+       struct port_info *p = netdev_priv(dev);
+
+       return p->rx_offload & RX_CSO;
+}
+
+static int set_rx_csum(struct net_device *dev, u32 data)
+{
+       struct port_info *p = netdev_priv(dev);
+
+       if (data)
+               p->rx_offload |= RX_CSO;
+       else
+               p->rx_offload &= ~RX_CSO;
+       return 0;
+}
+
+static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
+{
+       const struct port_info *pi = netdev_priv(dev);
+       const struct sge *s = &pi->adapter->sge;
+
+       e->rx_max_pending = MAX_RX_BUFFERS;
+       e->rx_mini_max_pending = MAX_RSPQ_ENTRIES;
+       e->rx_jumbo_max_pending = 0;
+       e->tx_max_pending = MAX_TXQ_ENTRIES;
+
+       e->rx_pending = s->ethrxq[pi->first_qset].fl.size - 8;
+       e->rx_mini_pending = s->ethrxq[pi->first_qset].rspq.size;
+       e->rx_jumbo_pending = 0;
+       e->tx_pending = s->ethtxq[pi->first_qset].q.size;
+}
+
+static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
+{
+       int i;
+       const struct port_info *pi = netdev_priv(dev);
+       struct adapter *adapter = pi->adapter;
+       struct sge *s = &adapter->sge;
+
+       if (e->rx_pending > MAX_RX_BUFFERS || e->rx_jumbo_pending ||
+           e->tx_pending > MAX_TXQ_ENTRIES ||
+           e->rx_mini_pending > MAX_RSPQ_ENTRIES ||
+           e->rx_mini_pending < MIN_RSPQ_ENTRIES ||
+           e->rx_pending < MIN_FL_ENTRIES || e->tx_pending < MIN_TXQ_ENTRIES)
+               return -EINVAL;
+
+       if (adapter->flags & FULL_INIT_DONE)
+               return -EBUSY;
+
+       for (i = 0; i < pi->nqsets; ++i) {
+               s->ethtxq[pi->first_qset + i].q.size = e->tx_pending;
+               s->ethrxq[pi->first_qset + i].fl.size = e->rx_pending + 8;
+               s->ethrxq[pi->first_qset + i].rspq.size = e->rx_mini_pending;
+       }
+       return 0;
+}
+
+static int closest_timer(const struct sge *s, int time)
+{
+       int i, delta, match = 0, min_delta = INT_MAX;
+
+       for (i = 0; i < ARRAY_SIZE(s->timer_val); i++) {
+               delta = time - s->timer_val[i];
+               if (delta < 0)
+                       delta = -delta;
+               if (delta < min_delta) {
+                       min_delta = delta;
+                       match = i;
+               }
+       }
+       return match;
+}
+
+static int closest_thres(const struct sge *s, int thres)
+{
+       int i, delta, match = 0, min_delta = INT_MAX;
+
+       for (i = 0; i < ARRAY_SIZE(s->counter_val); i++) {
+               delta = thres - s->counter_val[i];
+               if (delta < 0)
+                       delta = -delta;
+               if (delta < min_delta) {
+                       min_delta = delta;
+                       match = i;
+               }
+       }
+       return match;
+}
+
+/*
+ * Return a queue's interrupt hold-off time in us.  0 means no timer.
+ */
+static unsigned int qtimer_val(const struct adapter *adap,
+                              const struct sge_rspq *q)
+{
+       unsigned int idx = q->intr_params >> 1;
+
+       return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
+}
+
+/**
+ *     set_rxq_intr_params - set a queue's interrupt holdoff parameters
+ *     @adap: the adapter
+ *     @q: the Rx queue
+ *     @us: the hold-off time in us, or 0 to disable timer
+ *     @cnt: the hold-off packet count, or 0 to disable counter
+ *
+ *     Sets an Rx queue's interrupt hold-off time and packet count.  At least
+ *     one of the two needs to be enabled for the queue to generate interrupts.
+ */
+static int set_rxq_intr_params(struct adapter *adap, struct sge_rspq *q,
+                              unsigned int us, unsigned int cnt)
+{
+       if ((us | cnt) == 0)
+               cnt = 1;
+
+       if (cnt) {
+               int err;
+               u32 v, new_idx;
+
+               new_idx = closest_thres(&adap->sge, cnt);
+               if (q->desc && q->pktcnt_idx != new_idx) {
+                       /* the queue has already been created, update it */
+                       v = FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
+                           FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH) |
+                           FW_PARAMS_PARAM_YZ(q->cntxt_id);
+                       err = t4_set_params(adap, 0, 0, 0, 1, &v, &new_idx);
+                       if (err)
+                               return err;
+               }
+               q->pktcnt_idx = new_idx;
+       }
+
+       us = us == 0 ? 6 : closest_timer(&adap->sge, us);
+       q->intr_params = QINTR_TIMER_IDX(us) | (cnt > 0 ? QINTR_CNT_EN : 0);
+       return 0;
+}
+
+static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
+{
+       const struct port_info *pi = netdev_priv(dev);
+       struct adapter *adap = pi->adapter;
+
+       return set_rxq_intr_params(adap, &adap->sge.ethrxq[pi->first_qset].rspq,
+                       c->rx_coalesce_usecs, c->rx_max_coalesced_frames);
+}
+
+static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
+{
+       const struct port_info *pi = netdev_priv(dev);
+       const struct adapter *adap = pi->adapter;
+       const struct sge_rspq *rq = &adap->sge.ethrxq[pi->first_qset].rspq;
+
+       c->rx_coalesce_usecs = qtimer_val(adap, rq);
+       c->rx_max_coalesced_frames = (rq->intr_params & QINTR_CNT_EN) ?
+               adap->sge.counter_val[rq->pktcnt_idx] : 0;
+       return 0;
+}
+
+/*
+ * Translate a physical EEPROM address to virtual.  The first 1K is accessed
+ * through virtual addresses starting at 31K, the rest is accessed through
+ * virtual addresses starting at 0.  This mapping is correct only for PF0.
+ */
+static int eeprom_ptov(unsigned int phys_addr)
+{
+       if (phys_addr < 1024)
+               return phys_addr + (31 << 10);
+       if (phys_addr < EEPROMSIZE)
+               return phys_addr - 1024;
+       return -EINVAL;
+}
+
+/*
+ * The next two routines implement eeprom read/write from physical addresses.
+ * The physical->virtual translation is correct only for PF0.
+ */
+static int eeprom_rd_phys(struct adapter *adap, unsigned int phys_addr, u32 *v)
+{
+       int vaddr = eeprom_ptov(phys_addr);
+
+       if (vaddr >= 0)
+               vaddr = pci_read_vpd(adap->pdev, vaddr, sizeof(u32), v);
+       return vaddr < 0 ? vaddr : 0;
+}
+
+static int eeprom_wr_phys(struct adapter *adap, unsigned int phys_addr, u32 v)
+{
+       int vaddr = eeprom_ptov(phys_addr);
+
+       if (vaddr >= 0)
+               vaddr = pci_write_vpd(adap->pdev, vaddr, sizeof(u32), &v);
+       return vaddr < 0 ? vaddr : 0;
+}
+
+#define EEPROM_MAGIC 0x38E2F10C
+
+static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
+                     u8 *data)
+{
+       int i, err = 0;
+       struct adapter *adapter = netdev2adap(dev);
+
+       u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       e->magic = EEPROM_MAGIC;
+       for (i = e->offset & ~3; !err && i < e->offset + e->len; i += 4)
+               err = eeprom_rd_phys(adapter, i, (u32 *)&buf[i]);
+
+       if (!err)
+               memcpy(data, buf + e->offset, e->len);
+       kfree(buf);
+       return err;
+}
+
+static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
+                     u8 *data)
+{
+       u8 *buf;
+       int err = 0;
+       u32 aligned_offset, aligned_len, *p;
+       struct adapter *adapter = netdev2adap(dev);
+
+       if (eeprom->magic != EEPROM_MAGIC)
+               return -EINVAL;
+
+       aligned_offset = eeprom->offset & ~3;
+       aligned_len = (eeprom->len + (eeprom->offset & 3) + 3) & ~3;
+
+       if (aligned_offset != eeprom->offset || aligned_len != eeprom->len) {
+               /*
+                * RMW possibly needed for first or last words.
+                */
+               buf = kmalloc(aligned_len, GFP_KERNEL);
+               if (!buf)
+                       return -ENOMEM;
+               err = eeprom_rd_phys(adapter, aligned_offset, (u32 *)buf);
+               if (!err && aligned_len > 4)
+                       err = eeprom_rd_phys(adapter,
+                                            aligned_offset + aligned_len - 4,
+                                            (u32 *)&buf[aligned_len - 4]);
+               if (err)
+                       goto out;
+               memcpy(buf + (eeprom->offset & 3), data, eeprom->len);
+       } else
+               buf = data;
+
+       err = t4_seeprom_wp(adapter, false);
+       if (err)
+               goto out;
+
+       for (p = (u32 *)buf; !err && aligned_len; aligned_len -= 4, p++) {
+               err = eeprom_wr_phys(adapter, aligned_offset, *p);
+               aligned_offset += 4;
+       }
+
+       if (!err)
+               err = t4_seeprom_wp(adapter, true);
+out:
+       if (buf != data)
+               kfree(buf);
+       return err;
+}
+
+static int set_flash(struct net_device *netdev, struct ethtool_flash *ef)
+{
+       int ret;
+       const struct firmware *fw;
+       struct adapter *adap = netdev2adap(netdev);
+
+       ef->data[sizeof(ef->data) - 1] = '\0';
+       ret = request_firmware(&fw, ef->data, adap->pdev_dev);
+       if (ret < 0)
+               return ret;
+
+       ret = t4_load_fw(adap, fw->data, fw->size);
+       release_firmware(fw);
+       if (!ret)
+               dev_info(adap->pdev_dev, "loaded firmware %s\n", ef->data);
+       return ret;
+}
+
+#define WOL_SUPPORTED (WAKE_BCAST | WAKE_MAGIC)
+#define BCAST_CRC 0xa0ccc1a6
+
+static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       wol->supported = WAKE_BCAST | WAKE_MAGIC;
+       wol->wolopts = netdev2adap(dev)->wol;
+       memset(&wol->sopass, 0, sizeof(wol->sopass));
+}
+
+static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       int err = 0;
+       struct port_info *pi = netdev_priv(dev);
+
+       if (wol->wolopts & ~WOL_SUPPORTED)
+               return -EINVAL;
+       t4_wol_magic_enable(pi->adapter, pi->tx_chan,
+                           (wol->wolopts & WAKE_MAGIC) ? dev->dev_addr : NULL);
+       if (wol->wolopts & WAKE_BCAST) {
+               err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0xfe, ~0ULL,
+                                       ~0ULL, 0, false);
+               if (!err)
+                       err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 1,
+                                               ~6ULL, ~0ULL, BCAST_CRC, true);
+       } else
+               t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0, 0, 0, 0, false);
+       return err;
+}
+
+static int set_tso(struct net_device *dev, u32 value)
+{
+       if (value)
+               dev->features |= NETIF_F_TSO | NETIF_F_TSO6;
+       else
+               dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
+       return 0;
+}
+
+static struct ethtool_ops cxgb_ethtool_ops = {
+       .get_settings      = get_settings,
+       .set_settings      = set_settings,
+       .get_drvinfo       = get_drvinfo,
+       .get_msglevel      = get_msglevel,
+       .set_msglevel      = set_msglevel,
+       .get_ringparam     = get_sge_param,
+       .set_ringparam     = set_sge_param,
+       .get_coalesce      = get_coalesce,
+       .set_coalesce      = set_coalesce,
+       .get_eeprom_len    = get_eeprom_len,
+       .get_eeprom        = get_eeprom,
+       .set_eeprom        = set_eeprom,
+       .get_pauseparam    = get_pauseparam,
+       .set_pauseparam    = set_pauseparam,
+       .get_rx_csum       = get_rx_csum,
+       .set_rx_csum       = set_rx_csum,
+       .set_tx_csum       = ethtool_op_set_tx_ipv6_csum,
+       .set_sg            = ethtool_op_set_sg,
+       .get_link          = ethtool_op_get_link,
+       .get_strings       = get_strings,
+       .phys_id           = identify_port,
+       .nway_reset        = restart_autoneg,
+       .get_sset_count    = get_sset_count,
+       .get_ethtool_stats = get_stats,
+       .get_regs_len      = get_regs_len,
+       .get_regs          = get_regs,
+       .get_wol           = get_wol,
+       .set_wol           = set_wol,
+       .set_tso           = set_tso,
+       .flash_device      = set_flash,
+};
+
+/*
+ * debugfs support
+ */
+
+static int mem_open(struct inode *inode, struct file *file)
+{
+       file->private_data = inode->i_private;
+       return 0;
+}
+
+static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
+                       loff_t *ppos)
+{
+       loff_t pos = *ppos;
+       loff_t avail = file->f_path.dentry->d_inode->i_size;
+       unsigned int mem = (uintptr_t)file->private_data & 3;
+       struct adapter *adap = file->private_data - mem;
+
+       if (pos < 0)
+               return -EINVAL;
+       if (pos >= avail)
+               return 0;
+       if (count > avail - pos)
+               count = avail - pos;
+
+       while (count) {
+               size_t len;
+               int ret, ofst;
+               __be32 data[16];
+
+               if (mem == MEM_MC)
+                       ret = t4_mc_read(adap, pos, data, NULL);
+               else
+                       ret = t4_edc_read(adap, mem, pos, data, NULL);
+               if (ret)
+                       return ret;
+
+               ofst = pos % sizeof(data);
+               len = min(count, sizeof(data) - ofst);
+               if (copy_to_user(buf, (u8 *)data + ofst, len))
+                       return -EFAULT;
+
+               buf += len;
+               pos += len;
+               count -= len;
+       }
+       count = pos - *ppos;
+       *ppos = pos;
+       return count;
+}
+
+static const struct file_operations mem_debugfs_fops = {
+       .owner   = THIS_MODULE,
+       .open    = mem_open,
+       .read    = mem_read,
+};
+
+static void __devinit add_debugfs_mem(struct adapter *adap, const char *name,
+                                     unsigned int idx, unsigned int size_mb)
+{
+       struct dentry *de;
+
+       de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root,
+                                (void *)adap + idx, &mem_debugfs_fops);
+       if (de && de->d_inode)
+               de->d_inode->i_size = size_mb << 20;
+}
+
+static int __devinit setup_debugfs(struct adapter *adap)
+{
+       int i;
+
+       if (IS_ERR_OR_NULL(adap->debugfs_root))
+               return -1;
+
+       i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
+       if (i & EDRAM0_ENABLE)
+               add_debugfs_mem(adap, "edc0", MEM_EDC0, 5);
+       if (i & EDRAM1_ENABLE)
+               add_debugfs_mem(adap, "edc1", MEM_EDC1, 5);
+       if (i & EXT_MEM_ENABLE)
+               add_debugfs_mem(adap, "mc", MEM_MC,
+                       EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR)));
+       if (adap->l2t)
+               debugfs_create_file("l2t", S_IRUSR, adap->debugfs_root, adap,
+                                   &t4_l2t_fops);
+       return 0;
+}
+
+/*
+ * upper-layer driver support
+ */
+
+/*
+ * Allocate an active-open TID and set it to the supplied value.
+ */
+int cxgb4_alloc_atid(struct tid_info *t, void *data)
+{
+       int atid = -1;
+
+       spin_lock_bh(&t->atid_lock);
+       if (t->afree) {
+               union aopen_entry *p = t->afree;
+
+               atid = p - t->atid_tab;
+               t->afree = p->next;
+               p->data = data;
+               t->atids_in_use++;
+       }
+       spin_unlock_bh(&t->atid_lock);
+       return atid;
+}
+EXPORT_SYMBOL(cxgb4_alloc_atid);
+
+/*
+ * Release an active-open TID.
+ */
+void cxgb4_free_atid(struct tid_info *t, unsigned int atid)
+{
+       union aopen_entry *p = &t->atid_tab[atid];
+
+       spin_lock_bh(&t->atid_lock);
+       p->next = t->afree;
+       t->afree = p;
+       t->atids_in_use--;
+       spin_unlock_bh(&t->atid_lock);
+}
+EXPORT_SYMBOL(cxgb4_free_atid);
+
+/*
+ * Allocate a server TID and set it to the supplied value.
+ */
+int cxgb4_alloc_stid(struct tid_info *t, int family, void *data)
+{
+       int stid;
+
+       spin_lock_bh(&t->stid_lock);
+       if (family == PF_INET) {
+               stid = find_first_zero_bit(t->stid_bmap, t->nstids);
+               if (stid < t->nstids)
+                       __set_bit(stid, t->stid_bmap);
+               else
+                       stid = -1;
+       } else {
+               stid = bitmap_find_free_region(t->stid_bmap, t->nstids, 2);
+               if (stid < 0)
+                       stid = -1;
+       }
+       if (stid >= 0) {
+               t->stid_tab[stid].data = data;
+               stid += t->stid_base;
+               t->stids_in_use++;
+       }
+       spin_unlock_bh(&t->stid_lock);
+       return stid;
+}
+EXPORT_SYMBOL(cxgb4_alloc_stid);
+
+/*
+ * Release a server TID.
+ */
+void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family)
+{
+       stid -= t->stid_base;
+       spin_lock_bh(&t->stid_lock);
+       if (family == PF_INET)
+               __clear_bit(stid, t->stid_bmap);
+       else
+               bitmap_release_region(t->stid_bmap, stid, 2);
+       t->stid_tab[stid].data = NULL;
+       t->stids_in_use--;
+       spin_unlock_bh(&t->stid_lock);
+}
+EXPORT_SYMBOL(cxgb4_free_stid);
+
+/*
+ * Populate a TID_RELEASE WR.  Caller must properly size the skb.
+ */
+static void mk_tid_release(struct sk_buff *skb, unsigned int chan,
+                          unsigned int tid)
+{
+       struct cpl_tid_release *req;
+
+       set_wr_txq(skb, CPL_PRIORITY_SETUP, chan);
+       req = (struct cpl_tid_release *)__skb_put(skb, sizeof(*req));
+       INIT_TP_WR(req, tid);
+       OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
+}
+
+/*
+ * Queue a TID release request and if necessary schedule a work queue to
+ * process it.
+ */
+void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
+                            unsigned int tid)
+{
+       void **p = &t->tid_tab[tid];
+       struct adapter *adap = container_of(t, struct adapter, tids);
+
+       spin_lock_bh(&adap->tid_release_lock);
+       *p = adap->tid_release_head;
+       /* Low 2 bits encode the Tx channel number */
+       adap->tid_release_head = (void **)((uintptr_t)p | chan);
+       if (!adap->tid_release_task_busy) {
+               adap->tid_release_task_busy = true;
+               schedule_work(&adap->tid_release_task);
+       }
+       spin_unlock_bh(&adap->tid_release_lock);
+}
+EXPORT_SYMBOL(cxgb4_queue_tid_release);
+
+/*
+ * Process the list of pending TID release requests.
+ */
+static void process_tid_release_list(struct work_struct *work)
+{
+       struct sk_buff *skb;
+       struct adapter *adap;
+
+       adap = container_of(work, struct adapter, tid_release_task);
+
+       spin_lock_bh(&adap->tid_release_lock);
+       while (adap->tid_release_head) {
+               void **p = adap->tid_release_head;
+               unsigned int chan = (uintptr_t)p & 3;
+               p = (void *)p - chan;
+
+               adap->tid_release_head = *p;
+               *p = NULL;
+               spin_unlock_bh(&adap->tid_release_lock);
+
+               while (!(skb = alloc_skb(sizeof(struct cpl_tid_release),
+                                        GFP_KERNEL)))
+                       schedule_timeout_uninterruptible(1);
+
+               mk_tid_release(skb, chan, p - adap->tids.tid_tab);
+               t4_ofld_send(adap, skb);
+               spin_lock_bh(&adap->tid_release_lock);
+       }
+       adap->tid_release_task_busy = false;
+       spin_unlock_bh(&adap->tid_release_lock);
+}
+
+/*
+ * Release a TID and inform HW.  If we are unable to allocate the release
+ * message we defer to a work queue.
+ */
+void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid)
+{
+       void *old;
+       struct sk_buff *skb;
+       struct adapter *adap = container_of(t, struct adapter, tids);
+
+       old = t->tid_tab[tid];
+       skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_ATOMIC);
+       if (likely(skb)) {
+               t->tid_tab[tid] = NULL;
+               mk_tid_release(skb, chan, tid);
+               t4_ofld_send(adap, skb);
+       } else
+               cxgb4_queue_tid_release(t, chan, tid);
+       if (old)
+               atomic_dec(&t->tids_in_use);
+}
+EXPORT_SYMBOL(cxgb4_remove_tid);
+
+/*
+ * Allocate and initialize the TID tables.  Returns 0 on success.
+ */
+static int tid_init(struct tid_info *t)
+{
+       size_t size;
+       unsigned int natids = t->natids;
+
+       size = t->ntids * sizeof(*t->tid_tab) + natids * sizeof(*t->atid_tab) +
+              t->nstids * sizeof(*t->stid_tab) +
+              BITS_TO_LONGS(t->nstids) * sizeof(long);
+       t->tid_tab = t4_alloc_mem(size);
+       if (!t->tid_tab)
+               return -ENOMEM;
+
+       t->atid_tab = (union aopen_entry *)&t->tid_tab[t->ntids];
+       t->stid_tab = (struct serv_entry *)&t->atid_tab[natids];
+       t->stid_bmap = (unsigned long *)&t->stid_tab[t->nstids];
+       spin_lock_init(&t->stid_lock);
+       spin_lock_init(&t->atid_lock);
+
+       t->stids_in_use = 0;
+       t->afree = NULL;
+       t->atids_in_use = 0;
+       atomic_set(&t->tids_in_use, 0);
+
+       /* Setup the free list for atid_tab and clear the stid bitmap. */
+       if (natids) {
+               while (--natids)
+                       t->atid_tab[natids - 1].next = &t->atid_tab[natids];
+               t->afree = t->atid_tab;
+       }
+       bitmap_zero(t->stid_bmap, t->nstids);
+       return 0;
+}
+
+/**
+ *     cxgb4_create_server - create an IP server
+ *     @dev: the device
+ *     @stid: the server TID
+ *     @sip: local IP address to bind server to
+ *     @sport: the server's TCP port
+ *     @queue: queue to direct messages from this server to
+ *
+ *     Create an IP server for the given port and address.
+ *     Returns <0 on error and one of the %NET_XMIT_* values on success.
+ */
+int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
+                       __be32 sip, __be16 sport, unsigned int queue)
+{
+       unsigned int chan;
+       struct sk_buff *skb;
+       struct adapter *adap;
+       struct cpl_pass_open_req *req;
+
+       skb = alloc_skb(sizeof(*req), GFP_KERNEL);
+       if (!skb)
+               return -ENOMEM;
+
+       adap = netdev2adap(dev);
+       req = (struct cpl_pass_open_req *)__skb_put(skb, sizeof(*req));
+       INIT_TP_WR(req, 0);
+       OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, stid));
+       req->local_port = sport;
+       req->peer_port = htons(0);
+       req->local_ip = sip;
+       req->peer_ip = htonl(0);
+       chan = netdev2pinfo(adap->sge.ingr_map[queue]->netdev)->tx_chan;
+       req->opt0 = cpu_to_be64(TX_CHAN(chan));
+       req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
+                               SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
+       return t4_mgmt_tx(adap, skb);
+}
+EXPORT_SYMBOL(cxgb4_create_server);
+
+/**
+ *     cxgb4_create_server6 - create an IPv6 server
+ *     @dev: the device
+ *     @stid: the server TID
+ *     @sip: local IPv6 address to bind server to
+ *     @sport: the server's TCP port
+ *     @queue: queue to direct messages from this server to
+ *
+ *     Create an IPv6 server for the given port and address.
+ *     Returns <0 on error and one of the %NET_XMIT_* values on success.
+ */
+int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
+                        const struct in6_addr *sip, __be16 sport,
+                        unsigned int queue)
+{
+       unsigned int chan;
+       struct sk_buff *skb;
+       struct adapter *adap;
+       struct cpl_pass_open_req6 *req;
+
+       skb = alloc_skb(sizeof(*req), GFP_KERNEL);
+       if (!skb)
+               return -ENOMEM;
+
+       adap = netdev2adap(dev);
+       req = (struct cpl_pass_open_req6 *)__skb_put(skb, sizeof(*req));
+       INIT_TP_WR(req, 0);
+       OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, stid));
+       req->local_port = sport;
+       req->peer_port = htons(0);
+       req->local_ip_hi = *(__be64 *)(sip->s6_addr);
+       req->local_ip_lo = *(__be64 *)(sip->s6_addr + 8);
+       req->peer_ip_hi = cpu_to_be64(0);
+       req->peer_ip_lo = cpu_to_be64(0);
+       chan = netdev2pinfo(adap->sge.ingr_map[queue]->netdev)->tx_chan;
+       req->opt0 = cpu_to_be64(TX_CHAN(chan));
+       req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
+                               SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
+       return t4_mgmt_tx(adap, skb);
+}
+EXPORT_SYMBOL(cxgb4_create_server6);
+
+/**
+ *     cxgb4_best_mtu - find the entry in the MTU table closest to an MTU
+ *     @mtus: the HW MTU table
+ *     @mtu: the target MTU
+ *     @idx: index of selected entry in the MTU table
+ *
+ *     Returns the index and the value in the HW MTU table that is closest to
+ *     but does not exceed @mtu, unless @mtu is smaller than any value in the
+ *     table, in which case that smallest available value is selected.
+ */
+unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
+                           unsigned int *idx)
+{
+       unsigned int i = 0;
+
+       while (i < NMTUS - 1 && mtus[i + 1] <= mtu)
+               ++i;
+       if (idx)
+               *idx = i;
+       return mtus[i];
+}
+EXPORT_SYMBOL(cxgb4_best_mtu);
+
+/**
+ *     cxgb4_port_chan - get the HW channel of a port
+ *     @dev: the net device for the port
+ *
+ *     Return the HW Tx channel of the given port.
+ */
+unsigned int cxgb4_port_chan(const struct net_device *dev)
+{
+       return netdev2pinfo(dev)->tx_chan;
+}
+EXPORT_SYMBOL(cxgb4_port_chan);
+
+/**
+ *     cxgb4_port_viid - get the VI id of a port
+ *     @dev: the net device for the port
+ *
+ *     Return the VI id of the given port.
+ */
+unsigned int cxgb4_port_viid(const struct net_device *dev)
+{
+       return netdev2pinfo(dev)->viid;
+}
+EXPORT_SYMBOL(cxgb4_port_viid);
+
+/**
+ *     cxgb4_port_idx - get the index of a port
+ *     @dev: the net device for the port
+ *
+ *     Return the index of the given port.
+ */
+unsigned int cxgb4_port_idx(const struct net_device *dev)
+{
+       return netdev2pinfo(dev)->port_id;
+}
+EXPORT_SYMBOL(cxgb4_port_idx);
+
+/**
+ *     cxgb4_netdev_by_hwid - return the net device of a HW port
+ *     @pdev: identifies the adapter
+ *     @id: the HW port id
+ *
+ *     Return the net device associated with the interface with the given HW
+ *     id.
+ */
+struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id)
+{
+       const struct adapter *adap = pci_get_drvdata(pdev);
+
+       if (!adap || id >= NCHAN)
+               return NULL;
+       id = adap->chan_map[id];
+       return id < MAX_NPORTS ? adap->port[id] : NULL;
+}
+EXPORT_SYMBOL(cxgb4_netdev_by_hwid);
+
+void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
+                        struct tp_tcp_stats *v6)
+{
+       struct adapter *adap = pci_get_drvdata(pdev);
+
+       spin_lock(&adap->stats_lock);
+       t4_tp_get_tcp_stats(adap, v4, v6);
+       spin_unlock(&adap->stats_lock);
+}
+EXPORT_SYMBOL(cxgb4_get_tcp_stats);
+
+void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
+                     const unsigned int *pgsz_order)
+{
+       struct adapter *adap = netdev2adap(dev);
+
+       t4_write_reg(adap, ULP_RX_ISCSI_TAGMASK, tag_mask);
+       t4_write_reg(adap, ULP_RX_ISCSI_PSZ, HPZ0(pgsz_order[0]) |
+                    HPZ1(pgsz_order[1]) | HPZ2(pgsz_order[2]) |
+                    HPZ3(pgsz_order[3]));
+}
+EXPORT_SYMBOL(cxgb4_iscsi_init);
+
+static struct pci_driver cxgb4_driver;
+
+static void check_neigh_update(struct neighbour *neigh)
+{
+       const struct device *parent;
+       const struct net_device *netdev = neigh->dev;
+
+       if (netdev->priv_flags & IFF_802_1Q_VLAN)
+               netdev = vlan_dev_real_dev(netdev);
+       parent = netdev->dev.parent;
+       if (parent && parent->driver == &cxgb4_driver.driver)
+               t4_l2t_update(dev_get_drvdata(parent), neigh);
+}
+
+static int netevent_cb(struct notifier_block *nb, unsigned long event,
+                      void *data)
+{
+       switch (event) {
+       case NETEVENT_NEIGH_UPDATE:
+               check_neigh_update(data);
+               break;
+       case NETEVENT_PMTU_UPDATE:
+       case NETEVENT_REDIRECT:
+       default:
+               break;
+       }
+       return 0;
+}
+
+static bool netevent_registered;
+static struct notifier_block cxgb4_netevent_nb = {
+       .notifier_call = netevent_cb
+};
+
+static void uld_attach(struct adapter *adap, unsigned int uld)
+{
+       void *handle;
+       struct cxgb4_lld_info lli;
+
+       lli.pdev = adap->pdev;
+       lli.l2t = adap->l2t;
+       lli.tids = &adap->tids;
+       lli.ports = adap->port;
+       lli.vr = &adap->vres;
+       lli.mtus = adap->params.mtus;
+       if (uld == CXGB4_ULD_RDMA) {
+               lli.rxq_ids = adap->sge.rdma_rxq;
+               lli.nrxq = adap->sge.rdmaqs;
+       } else if (uld == CXGB4_ULD_ISCSI) {
+               lli.rxq_ids = adap->sge.ofld_rxq;
+               lli.nrxq = adap->sge.ofldqsets;
+       }
+       lli.ntxq = adap->sge.ofldqsets;
+       lli.nchan = adap->params.nports;
+       lli.nports = adap->params.nports;
+       lli.wr_cred = adap->params.ofldq_wr_cred;
+       lli.adapter_type = adap->params.rev;
+       lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
+       lli.udb_density = 1 << QUEUESPERPAGEPF0_GET(
+                       t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF));
+       lli.ucq_density = 1 << QUEUESPERPAGEPF0_GET(
+                       t4_read_reg(adap, SGE_INGRESS_QUEUES_PER_PAGE_PF));
+       lli.gts_reg = adap->regs + MYPF_REG(SGE_PF_GTS);
+       lli.db_reg = adap->regs + MYPF_REG(SGE_PF_KDOORBELL);
+       lli.fw_vers = adap->params.fw_vers;
+
+       handle = ulds[uld].add(&lli);
+       if (IS_ERR(handle)) {
+               dev_warn(adap->pdev_dev,
+                        "could not attach to the %s driver, error %ld\n",
+                        uld_str[uld], PTR_ERR(handle));
+               return;
+       }
+
+       adap->uld_handle[uld] = handle;
+
+       if (!netevent_registered) {
+               register_netevent_notifier(&cxgb4_netevent_nb);
+               netevent_registered = true;
+       }
+}
+
+static void attach_ulds(struct adapter *adap)
+{
+       unsigned int i;
+
+       mutex_lock(&uld_mutex);
+       list_add_tail(&adap->list_node, &adapter_list);
+       for (i = 0; i < CXGB4_ULD_MAX; i++)
+               if (ulds[i].add)
+                       uld_attach(adap, i);
+       mutex_unlock(&uld_mutex);
+}
+
+static void detach_ulds(struct adapter *adap)
+{
+       unsigned int i;
+
+       mutex_lock(&uld_mutex);
+       list_del(&adap->list_node);
+       for (i = 0; i < CXGB4_ULD_MAX; i++)
+               if (adap->uld_handle[i]) {
+                       ulds[i].state_change(adap->uld_handle[i],
+                                            CXGB4_STATE_DETACH);
+                       adap->uld_handle[i] = NULL;
+               }
+       if (netevent_registered && list_empty(&adapter_list)) {
+               unregister_netevent_notifier(&cxgb4_netevent_nb);
+               netevent_registered = false;
+       }
+       mutex_unlock(&uld_mutex);
+}
+
+static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
+{
+       unsigned int i;
+
+       mutex_lock(&uld_mutex);
+       for (i = 0; i < CXGB4_ULD_MAX; i++)
+               if (adap->uld_handle[i])
+                       ulds[i].state_change(adap->uld_handle[i], new_state);
+       mutex_unlock(&uld_mutex);
+}
+
+/**
+ *     cxgb4_register_uld - register an upper-layer driver
+ *     @type: the ULD type
+ *     @p: the ULD methods
+ *
+ *     Registers an upper-layer driver with this driver and notifies the ULD
+ *     about any presently available devices that support its type.  Returns
+ *     %-EBUSY if a ULD of the same type is already registered.
+ */
+int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p)
+{
+       int ret = 0;
+       struct adapter *adap;
+
+       if (type >= CXGB4_ULD_MAX)
+               return -EINVAL;
+       mutex_lock(&uld_mutex);
+       if (ulds[type].add) {
+               ret = -EBUSY;
+               goto out;
+       }
+       ulds[type] = *p;
+       list_for_each_entry(adap, &adapter_list, list_node)
+               uld_attach(adap, type);
+out:   mutex_unlock(&uld_mutex);
+       return ret;
+}
+EXPORT_SYMBOL(cxgb4_register_uld);
+
+/**
+ *     cxgb4_unregister_uld - unregister an upper-layer driver
+ *     @type: the ULD type
+ *
+ *     Unregisters an existing upper-layer driver.
+ */
+int cxgb4_unregister_uld(enum cxgb4_uld type)
+{
+       struct adapter *adap;
+
+       if (type >= CXGB4_ULD_MAX)
+               return -EINVAL;
+       mutex_lock(&uld_mutex);
+       list_for_each_entry(adap, &adapter_list, list_node)
+               adap->uld_handle[type] = NULL;
+       ulds[type].add = NULL;
+       mutex_unlock(&uld_mutex);
+       return 0;
+}
+EXPORT_SYMBOL(cxgb4_unregister_uld);
+
+/**
+ *     cxgb_up - enable the adapter
+ *     @adap: adapter being enabled
+ *
+ *     Called when the first port is enabled, this function performs the
+ *     actions necessary to make an adapter operational, such as completing
+ *     the initialization of HW modules, and enabling interrupts.
+ *
+ *     Must be called with the rtnl lock held.
+ */
+static int cxgb_up(struct adapter *adap)
+{
+       int err = 0;
+
+       if (!(adap->flags & FULL_INIT_DONE)) {
+               err = setup_sge_queues(adap);
+               if (err)
+                       goto out;
+               err = setup_rss(adap);
+               if (err) {
+                       t4_free_sge_resources(adap);
+                       goto out;
+               }
+               if (adap->flags & USING_MSIX)
+                       name_msix_vecs(adap);
+               adap->flags |= FULL_INIT_DONE;
+       }
+
+       if (adap->flags & USING_MSIX) {
+               err = request_irq(adap->msix_info[0].vec, t4_nondata_intr, 0,
+                                 adap->msix_info[0].desc, adap);
+               if (err)
+                       goto irq_err;
+
+               err = request_msix_queue_irqs(adap);
+               if (err) {
+                       free_irq(adap->msix_info[0].vec, adap);
+                       goto irq_err;
+               }
+       } else {
+               err = request_irq(adap->pdev->irq, t4_intr_handler(adap),
+                                 (adap->flags & USING_MSI) ? 0 : IRQF_SHARED,
+                                 adap->name, adap);
+               if (err)
+                       goto irq_err;
+       }
+       enable_rx(adap);
+       t4_sge_start(adap);
+       t4_intr_enable(adap);
+       notify_ulds(adap, CXGB4_STATE_UP);
+ out:
+       return err;
+ irq_err:
+       dev_err(adap->pdev_dev, "request_irq failed, err %d\n", err);
+       goto out;
+}
+
+static void cxgb_down(struct adapter *adapter)
+{
+       t4_intr_disable(adapter);
+       cancel_work_sync(&adapter->tid_release_task);
+       adapter->tid_release_task_busy = false;
+
+       if (adapter->flags & USING_MSIX) {
+               free_msix_queue_irqs(adapter);
+               free_irq(adapter->msix_info[0].vec, adapter);
+       } else
+               free_irq(adapter->pdev->irq, adapter);
+       quiesce_rx(adapter);
+}
+
+/*
+ * net_device operations
+ */
+static int cxgb_open(struct net_device *dev)
+{
+       int err;
+       struct port_info *pi = netdev_priv(dev);
+       struct adapter *adapter = pi->adapter;
+
+       if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0)
+               return err;
+
+       dev->real_num_tx_queues = pi->nqsets;
+       set_bit(pi->tx_chan, &adapter->open_device_map);
+       link_start(dev);
+       netif_tx_start_all_queues(dev);
+       return 0;
+}
+
+static int cxgb_close(struct net_device *dev)
+{
+       int ret;
+       struct port_info *pi = netdev_priv(dev);
+       struct adapter *adapter = pi->adapter;
+
+       netif_tx_stop_all_queues(dev);
+       netif_carrier_off(dev);
+       ret = t4_enable_vi(adapter, 0, pi->viid, false, false);
+
+       clear_bit(pi->tx_chan, &adapter->open_device_map);
+
+       if (!adapter->open_device_map)
+               cxgb_down(adapter);
+       return 0;
+}
+
+static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
+{
+       struct port_stats stats;
+       struct port_info *p = netdev_priv(dev);
+       struct adapter *adapter = p->adapter;
+       struct net_device_stats *ns = &dev->stats;
+
+       spin_lock(&adapter->stats_lock);
+       t4_get_port_stats(adapter, p->tx_chan, &stats);
+       spin_unlock(&adapter->stats_lock);
+
+       ns->tx_bytes   = stats.tx_octets;
+       ns->tx_packets = stats.tx_frames;
+       ns->rx_bytes   = stats.rx_octets;
+       ns->rx_packets = stats.rx_frames;
+       ns->multicast  = stats.rx_mcast_frames;
+
+       /* detailed rx_errors */
+       ns->rx_length_errors = stats.rx_jabber + stats.rx_too_long +
+                              stats.rx_runt;
+       ns->rx_over_errors   = 0;
+       ns->rx_crc_errors    = stats.rx_fcs_err;
+       ns->rx_frame_errors  = stats.rx_symbol_err;
+       ns->rx_fifo_errors   = stats.rx_ovflow0 + stats.rx_ovflow1 +
+                              stats.rx_ovflow2 + stats.rx_ovflow3 +
+                              stats.rx_trunc0 + stats.rx_trunc1 +
+                              stats.rx_trunc2 + stats.rx_trunc3;
+       ns->rx_missed_errors = 0;
+
+       /* detailed tx_errors */
+       ns->tx_aborted_errors   = 0;
+       ns->tx_carrier_errors   = 0;
+       ns->tx_fifo_errors      = 0;
+       ns->tx_heartbeat_errors = 0;
+       ns->tx_window_errors    = 0;
+
+       ns->tx_errors = stats.tx_error_frames;
+       ns->rx_errors = stats.rx_symbol_err + stats.rx_fcs_err +
+               ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors;
+       return ns;
+}
+
+static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
+{
+       int ret = 0, prtad, devad;
+       struct port_info *pi = netdev_priv(dev);
+       struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data;
+
+       switch (cmd) {
+       case SIOCGMIIPHY:
+               if (pi->mdio_addr < 0)
+                       return -EOPNOTSUPP;
+               data->phy_id = pi->mdio_addr;
+               break;
+       case SIOCGMIIREG:
+       case SIOCSMIIREG:
+               if (mdio_phy_id_is_c45(data->phy_id)) {
+                       prtad = mdio_phy_id_prtad(data->phy_id);
+                       devad = mdio_phy_id_devad(data->phy_id);
+               } else if (data->phy_id < 32) {
+                       prtad = data->phy_id;
+                       devad = 0;
+                       data->reg_num &= 0x1f;
+               } else
+                       return -EINVAL;
+
+               if (cmd == SIOCGMIIREG)
+                       ret = t4_mdio_rd(pi->adapter, 0, prtad, devad,
+                                        data->reg_num, &data->val_out);
+               else
+                       ret = t4_mdio_wr(pi->adapter, 0, prtad, devad,
+                                        data->reg_num, data->val_in);
+               break;
+       default:
+               return -EOPNOTSUPP;
+       }
+       return ret;
+}
+
+static void cxgb_set_rxmode(struct net_device *dev)
+{
+       /* unfortunately we can't return errors to the stack */
+       set_rxmode(dev, -1, false);
+}
+
+static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
+{
+       int ret;
+       struct port_info *pi = netdev_priv(dev);
+
+       if (new_mtu < 81 || new_mtu > MAX_MTU)         /* accommodate SACK */
+               return -EINVAL;
+       ret = t4_set_rxmode(pi->adapter, 0, pi->viid, new_mtu, -1, -1, -1,
+                           true);
+       if (!ret)
+               dev->mtu = new_mtu;
+       return ret;
+}
+
+static int cxgb_set_mac_addr(struct net_device *dev, void *p)
+{
+       int ret;
+       struct sockaddr *addr = p;
+       struct port_info *pi = netdev_priv(dev);
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EINVAL;
+
+       ret = t4_change_mac(pi->adapter, 0, pi->viid, pi->xact_addr_filt,
+                           addr->sa_data, true, true);
+       if (ret < 0)
+               return ret;
+
+       memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+       pi->xact_addr_filt = ret;
+       return 0;
+}
+
+static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
+{
+       struct port_info *pi = netdev_priv(dev);
+
+       pi->vlan_grp = grp;
+       t4_set_vlan_accel(pi->adapter, 1 << pi->tx_chan, grp != NULL);
+}
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void cxgb_netpoll(struct net_device *dev)
+{
+       struct port_info *pi = netdev_priv(dev);
+       struct adapter *adap = pi->adapter;
+
+       if (adap->flags & USING_MSIX) {
+               int i;
+               struct sge_eth_rxq *rx = &adap->sge.ethrxq[pi->first_qset];
+
+               for (i = pi->nqsets; i; i--, rx++)
+                       t4_sge_intr_msix(0, &rx->rspq);
+       } else
+               t4_intr_handler(adap)(0, adap);
+}
+#endif
+
+static const struct net_device_ops cxgb4_netdev_ops = {
+       .ndo_open             = cxgb_open,
+       .ndo_stop             = cxgb_close,
+       .ndo_start_xmit       = t4_eth_xmit,
+       .ndo_get_stats        = cxgb_get_stats,
+       .ndo_set_rx_mode      = cxgb_set_rxmode,
+       .ndo_set_mac_address  = cxgb_set_mac_addr,
+       .ndo_validate_addr    = eth_validate_addr,
+       .ndo_do_ioctl         = cxgb_ioctl,
+       .ndo_change_mtu       = cxgb_change_mtu,
+       .ndo_vlan_rx_register = vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller  = cxgb_netpoll,
+#endif
+};
+
+void t4_fatal_err(struct adapter *adap)
+{
+       t4_set_reg_field(adap, SGE_CONTROL, GLOBALENABLE, 0);
+       t4_intr_disable(adap);
+       dev_alert(adap->pdev_dev, "encountered fatal error, adapter stopped\n");
+}
+
+static void setup_memwin(struct adapter *adap)
+{
+       u32 bar0;
+
+       bar0 = pci_resource_start(adap->pdev, 0);  /* truncation intentional */
+       t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 0),
+                    (bar0 + MEMWIN0_BASE) | BIR(0) |
+                    WINDOW(ilog2(MEMWIN0_APERTURE) - 10));
+       t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 1),
+                    (bar0 + MEMWIN1_BASE) | BIR(0) |
+                    WINDOW(ilog2(MEMWIN1_APERTURE) - 10));
+       t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2),
+                    (bar0 + MEMWIN2_BASE) | BIR(0) |
+                    WINDOW(ilog2(MEMWIN2_APERTURE) - 10));
+}
+
+/*
+ * Max # of ATIDs.  The absolute HW max is 16K but we keep it lower.
+ */
+#define MAX_ATIDS 8192U
+
+/*
+ * Phase 0 of initialization: contact FW, obtain config, perform basic init.
+ */
+static int adap_init0(struct adapter *adap)
+{
+       int ret;
+       u32 v, port_vec;
+       enum dev_state state;
+       u32 params[7], val[7];
+       struct fw_caps_config_cmd c;
+
+       ret = t4_check_fw_version(adap);
+       if (ret == -EINVAL || ret > 0) {
+               if (upgrade_fw(adap) >= 0)             /* recache FW version */
+                       ret = t4_check_fw_version(adap);
+       }
+       if (ret < 0)
+               return ret;
+
+       /* contact FW, request master */
+       ret = t4_fw_hello(adap, 0, 0, MASTER_MUST, &state);
+       if (ret < 0) {
+               dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
+                       ret);
+               return ret;
+       }
+
+       /* reset device */
+       ret = t4_fw_reset(adap, 0, PIORSTMODE | PIORST);
+       if (ret < 0)
+               goto bye;
+
+       /* get device capabilities */
+       memset(&c, 0, sizeof(c));
+       c.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
+                             FW_CMD_REQUEST | FW_CMD_READ);
+       c.retval_len16 = htonl(FW_LEN16(c));
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
+       if (ret < 0)
+               goto bye;
+
+       /* select capabilities we'll be using */
+       if (c.niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) {
+               if (!vf_acls)
+                       c.niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM);
+               else
+                       c.niccaps = htons(FW_CAPS_CONFIG_NIC_VM);
+       } else if (vf_acls) {
+               dev_err(adap->pdev_dev, "virtualization ACLs not supported");
+               goto bye;
+       }
+       c.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
+                             FW_CMD_REQUEST | FW_CMD_WRITE);
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), NULL);
+       if (ret < 0)
+               goto bye;
+
+       ret = t4_config_glbl_rss(adap, 0,
+                                FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL,
+                                FW_RSS_GLB_CONFIG_CMD_TNLMAPEN |
+                                FW_RSS_GLB_CONFIG_CMD_TNLALLLKP);
+       if (ret < 0)
+               goto bye;
+
+       ret = t4_cfg_pfvf(adap, 0, 0, 0, 64, 64, 64, 0, 0, 4, 0xf, 0xf, 16,
+                         FW_CMD_CAP_PF, FW_CMD_CAP_PF);
+       if (ret < 0)
+               goto bye;
+
+       for (v = 0; v < SGE_NTIMERS - 1; v++)
+               adap->sge.timer_val[v] = min(intr_holdoff[v], MAX_SGE_TIMERVAL);
+       adap->sge.timer_val[SGE_NTIMERS - 1] = MAX_SGE_TIMERVAL;
+       adap->sge.counter_val[0] = 1;
+       for (v = 1; v < SGE_NCOUNTERS; v++)
+               adap->sge.counter_val[v] = min(intr_cnt[v - 1],
+                                              THRESHOLD_3_MASK);
+       t4_sge_init(adap);
+
+       /* get basic stuff going */
+       ret = t4_early_init(adap, 0);
+       if (ret < 0)
+               goto bye;
+
+#define FW_PARAM_DEV(param) \
+       (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | \
+        FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
+
+#define FW_PARAM_PFVF(param) \
+       (FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
+        FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param))
+
+       params[0] = FW_PARAM_DEV(PORTVEC);
+       params[1] = FW_PARAM_PFVF(L2T_START);
+       params[2] = FW_PARAM_PFVF(L2T_END);
+       params[3] = FW_PARAM_PFVF(FILTER_START);
+       params[4] = FW_PARAM_PFVF(FILTER_END);
+       ret = t4_query_params(adap, 0, 0, 0, 5, params, val);
+       if (ret < 0)
+               goto bye;
+       port_vec = val[0];
+       adap->tids.ftid_base = val[3];
+       adap->tids.nftids = val[4] - val[3] + 1;
+
+       if (c.ofldcaps) {
+               /* query offload-related parameters */
+               params[0] = FW_PARAM_DEV(NTID);
+               params[1] = FW_PARAM_PFVF(SERVER_START);
+               params[2] = FW_PARAM_PFVF(SERVER_END);
+               params[3] = FW_PARAM_PFVF(TDDP_START);
+               params[4] = FW_PARAM_PFVF(TDDP_END);
+               params[5] = FW_PARAM_DEV(FLOWC_BUFFIFO_SZ);
+               ret = t4_query_params(adap, 0, 0, 0, 6, params, val);
+               if (ret < 0)
+                       goto bye;
+               adap->tids.ntids = val[0];
+               adap->tids.natids = min(adap->tids.ntids / 2, MAX_ATIDS);
+               adap->tids.stid_base = val[1];
+               adap->tids.nstids = val[2] - val[1] + 1;
+               adap->vres.ddp.start = val[3];
+               adap->vres.ddp.size = val[4] - val[3] + 1;
+               adap->params.ofldq_wr_cred = val[5];
+               adap->params.offload = 1;
+       }
+       if (c.rdmacaps) {
+               params[0] = FW_PARAM_PFVF(STAG_START);
+               params[1] = FW_PARAM_PFVF(STAG_END);
+               params[2] = FW_PARAM_PFVF(RQ_START);
+               params[3] = FW_PARAM_PFVF(RQ_END);
+               params[4] = FW_PARAM_PFVF(PBL_START);
+               params[5] = FW_PARAM_PFVF(PBL_END);
+               ret = t4_query_params(adap, 0, 0, 0, 6, params, val);
+               if (ret < 0)
+                       goto bye;
+               adap->vres.stag.start = val[0];
+               adap->vres.stag.size = val[1] - val[0] + 1;
+               adap->vres.rq.start = val[2];
+               adap->vres.rq.size = val[3] - val[2] + 1;
+               adap->vres.pbl.start = val[4];
+               adap->vres.pbl.size = val[5] - val[4] + 1;
+       }
+       if (c.iscsicaps) {
+               params[0] = FW_PARAM_PFVF(ISCSI_START);
+               params[1] = FW_PARAM_PFVF(ISCSI_END);
+               ret = t4_query_params(adap, 0, 0, 0, 2, params, val);
+               if (ret < 0)
+                       goto bye;
+               adap->vres.iscsi.start = val[0];
+               adap->vres.iscsi.size = val[1] - val[0] + 1;
+       }
+#undef FW_PARAM_PFVF
+#undef FW_PARAM_DEV
+
+       adap->params.nports = hweight32(port_vec);
+       adap->params.portvec = port_vec;
+       adap->flags |= FW_OK;
+
+       /* These are finalized by FW initialization, load their values now */
+       v = t4_read_reg(adap, TP_TIMER_RESOLUTION);
+       adap->params.tp.tre = TIMERRESOLUTION_GET(v);
+       t4_read_mtu_tbl(adap, adap->params.mtus, NULL);
+       t4_load_mtus(adap, adap->params.mtus, adap->params.a_wnd,
+                    adap->params.b_wnd);
+
+       /* tweak some settings */
+       t4_write_reg(adap, TP_SHIFT_CNT, 0x64f8849);
+       t4_write_reg(adap, ULP_RX_TDDP_PSZ, HPZ0(PAGE_SHIFT - 12));
+       t4_write_reg(adap, TP_PIO_ADDR, TP_INGRESS_CONFIG);
+       v = t4_read_reg(adap, TP_PIO_DATA);
+       t4_write_reg(adap, TP_PIO_DATA, v & ~CSUM_HAS_PSEUDO_HDR);
+       setup_memwin(adap);
+       return 0;
+
+       /*
+        * If a command timed out or failed with EIO FW does not operate within
+        * its spec or something catastrophic happened to HW/FW, stop issuing
+        * commands.
+        */
+bye:   if (ret != -ETIMEDOUT && ret != -EIO)
+               t4_fw_bye(adap, 0);
+       return ret;
+}
+
+static inline bool is_10g_port(const struct link_config *lc)
+{
+       return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
+}
+
+static inline void init_rspq(struct sge_rspq *q, u8 timer_idx, u8 pkt_cnt_idx,
+                            unsigned int size, unsigned int iqe_size)
+{
+       q->intr_params = QINTR_TIMER_IDX(timer_idx) |
+                        (pkt_cnt_idx < SGE_NCOUNTERS ? QINTR_CNT_EN : 0);
+       q->pktcnt_idx = pkt_cnt_idx < SGE_NCOUNTERS ? pkt_cnt_idx : 0;
+       q->iqe_len = iqe_size;
+       q->size = size;
+}
+
+/*
+ * Perform default configuration of DMA queues depending on the number and type
+ * of ports we found and the number of available CPUs.  Most settings can be
+ * modified by the admin prior to actual use.
+ */
+static void __devinit cfg_queues(struct adapter *adap)
+{
+       struct sge *s = &adap->sge;
+       int i, q10g = 0, n10g = 0, qidx = 0;
+
+       for_each_port(adap, i)
+               n10g += is_10g_port(&adap2pinfo(adap, i)->link_cfg);
+
+       /*
+        * We default to 1 queue per non-10G port and up to # of cores queues
+        * per 10G port.
+        */
+       if (n10g)
+               q10g = (MAX_ETH_QSETS - (adap->params.nports - n10g)) / n10g;
+       if (q10g > num_online_cpus())
+               q10g = num_online_cpus();
+
+       for_each_port(adap, i) {
+               struct port_info *pi = adap2pinfo(adap, i);
+
+               pi->first_qset = qidx;
+               pi->nqsets = is_10g_port(&pi->link_cfg) ? q10g : 1;
+               qidx += pi->nqsets;
+       }
+
+       s->ethqsets = qidx;
+       s->max_ethqsets = qidx;   /* MSI-X may lower it later */
+
+       if (is_offload(adap)) {
+               /*
+                * For offload we use 1 queue/channel if all ports are up to 1G,
+                * otherwise we divide all available queues amongst the channels
+                * capped by the number of available cores.
+                */
+               if (n10g) {
+                       i = min_t(int, ARRAY_SIZE(s->ofldrxq),
+                                 num_online_cpus());
+                       s->ofldqsets = roundup(i, adap->params.nports);
+               } else
+                       s->ofldqsets = adap->params.nports;
+               /* For RDMA one Rx queue per channel suffices */
+               s->rdmaqs = adap->params.nports;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
+               struct sge_eth_rxq *r = &s->ethrxq[i];
+
+               init_rspq(&r->rspq, 0, 0, 1024, 64);
+               r->fl.size = 72;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(s->ethtxq); i++)
+               s->ethtxq[i].q.size = 1024;
+
+       for (i = 0; i < ARRAY_SIZE(s->ctrlq); i++)
+               s->ctrlq[i].q.size = 512;
+
+       for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++)
+               s->ofldtxq[i].q.size = 1024;
+
+       for (i = 0; i < ARRAY_SIZE(s->ofldrxq); i++) {
+               struct sge_ofld_rxq *r = &s->ofldrxq[i];
+
+               init_rspq(&r->rspq, 0, 0, 1024, 64);
+               r->rspq.uld = CXGB4_ULD_ISCSI;
+               r->fl.size = 72;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(s->rdmarxq); i++) {
+               struct sge_ofld_rxq *r = &s->rdmarxq[i];
+
+               init_rspq(&r->rspq, 0, 0, 511, 64);
+               r->rspq.uld = CXGB4_ULD_RDMA;
+               r->fl.size = 72;
+       }
+
+       init_rspq(&s->fw_evtq, 6, 0, 512, 64);
+       init_rspq(&s->intrq, 6, 0, 2 * MAX_INGQ, 64);
+}
+
+/*
+ * Reduce the number of Ethernet queues across all ports to at most n.
+ * n provides at least one queue per port.
+ */
+static void __devinit reduce_ethqs(struct adapter *adap, int n)
+{
+       int i;
+       struct port_info *pi;
+
+       while (n < adap->sge.ethqsets)
+               for_each_port(adap, i) {
+                       pi = adap2pinfo(adap, i);
+                       if (pi->nqsets > 1) {
+                               pi->nqsets--;
+                               adap->sge.ethqsets--;
+                               if (adap->sge.ethqsets <= n)
+                                       break;
+                       }
+               }
+
+       n = 0;
+       for_each_port(adap, i) {
+               pi = adap2pinfo(adap, i);
+               pi->first_qset = n;
+               n += pi->nqsets;
+       }
+}
+
+/* 2 MSI-X vectors needed for the FW queue and non-data interrupts */
+#define EXTRA_VECS 2
+
+static int __devinit enable_msix(struct adapter *adap)
+{
+       int ofld_need = 0;
+       int i, err, want, need;
+       struct sge *s = &adap->sge;
+       unsigned int nchan = adap->params.nports;
+       struct msix_entry entries[MAX_INGQ + 1];
+
+       for (i = 0; i < ARRAY_SIZE(entries); ++i)
+               entries[i].entry = i;
+
+       want = s->max_ethqsets + EXTRA_VECS;
+       if (is_offload(adap)) {
+               want += s->rdmaqs + s->ofldqsets;
+               /* need nchan for each possible ULD */
+               ofld_need = 2 * nchan;
+       }
+       need = adap->params.nports + EXTRA_VECS + ofld_need;
+
+       while ((err = pci_enable_msix(adap->pdev, entries, want)) >= need)
+               want = err;
+
+       if (!err) {
+               /*
+                * Distribute available vectors to the various queue groups.
+                * Every group gets its minimum requirement and NIC gets top
+                * priority for leftovers.
+                */
+               i = want - EXTRA_VECS - ofld_need;
+               if (i < s->max_ethqsets) {
+                       s->max_ethqsets = i;
+                       if (i < s->ethqsets)
+                               reduce_ethqs(adap, i);
+               }
+               if (is_offload(adap)) {
+                       i = want - EXTRA_VECS - s->max_ethqsets;
+                       i -= ofld_need - nchan;
+                       s->ofldqsets = (i / nchan) * nchan;  /* round down */
+               }
+               for (i = 0; i < want; ++i)
+                       adap->msix_info[i].vec = entries[i].vector;
+       } else if (err > 0)
+               dev_info(adap->pdev_dev,
+                        "only %d MSI-X vectors left, not using MSI-X\n", err);
+       return err;
+}
+
+#undef EXTRA_VECS
+
+static void __devinit print_port_info(struct adapter *adap)
+{
+       static const char *base[] = {
+               "R", "KX4", "T", "KX", "T", "KR", "CX4"
+       };
+
+       int i;
+       char buf[80];
+
+       for_each_port(adap, i) {
+               struct net_device *dev = adap->port[i];
+               const struct port_info *pi = netdev_priv(dev);
+               char *bufp = buf;
+
+               if (!test_bit(i, &adap->registered_device_map))
+                       continue;
+
+               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M)
+                       bufp += sprintf(bufp, "100/");
+               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
+                       bufp += sprintf(bufp, "1000/");
+               if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
+                       bufp += sprintf(bufp, "10G/");
+               if (bufp != buf)
+                       --bufp;
+               sprintf(bufp, "BASE-%s", base[pi->port_type]);
+
+               netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s\n",
+                           adap->params.vpd.id, adap->params.rev,
+                           buf, is_offload(adap) ? "R" : "",
+                           adap->params.pci.width,
+                           (adap->flags & USING_MSIX) ? " MSI-X" :
+                           (adap->flags & USING_MSI) ? " MSI" : "");
+               if (adap->name == dev->name)
+                       netdev_info(dev, "S/N: %s, E/C: %s\n",
+                                   adap->params.vpd.sn, adap->params.vpd.ec);
+       }
+}
+
+#define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | NETIF_F_TSO6 |\
+                  NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
+
+static int __devinit init_one(struct pci_dev *pdev,
+                             const struct pci_device_id *ent)
+{
+       int func, i, err;
+       struct port_info *pi;
+       unsigned int highdma = 0;
+       struct adapter *adapter = NULL;
+
+       printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
+
+       err = pci_request_regions(pdev, KBUILD_MODNAME);
+       if (err) {
+               /* Just info, some other driver may have claimed the device. */
+               dev_info(&pdev->dev, "cannot obtain PCI resources\n");
+               return err;
+       }
+
+       /* We control everything through PF 0 */
+       func = PCI_FUNC(pdev->devfn);
+       if (func > 0)
+               goto sriov;
+
+       err = pci_enable_device(pdev);
+       if (err) {
+               dev_err(&pdev->dev, "cannot enable PCI device\n");
+               goto out_release_regions;
+       }
+
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
+               highdma = NETIF_F_HIGHDMA;
+               err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+               if (err) {
+                       dev_err(&pdev->dev, "unable to obtain 64-bit DMA for "
+                               "coherent allocations\n");
+                       goto out_disable_device;
+               }
+       } else {
+               err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+               if (err) {
+                       dev_err(&pdev->dev, "no usable DMA configuration\n");
+                       goto out_disable_device;
+               }
+       }
+
+       pci_enable_pcie_error_reporting(pdev);
+       pci_set_master(pdev);
+       pci_save_state(pdev);
+
+       adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
+       if (!adapter) {
+               err = -ENOMEM;
+               goto out_disable_device;
+       }
+
+       adapter->regs = pci_ioremap_bar(pdev, 0);
+       if (!adapter->regs) {
+               dev_err(&pdev->dev, "cannot map device registers\n");
+               err = -ENOMEM;
+               goto out_free_adapter;
+       }
+
+       adapter->pdev = pdev;
+       adapter->pdev_dev = &pdev->dev;
+       adapter->name = pci_name(pdev);
+       adapter->msg_enable = dflt_msg_enable;
+       memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
+
+       spin_lock_init(&adapter->stats_lock);
+       spin_lock_init(&adapter->tid_release_lock);
+
+       INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
+
+       err = t4_prep_adapter(adapter);
+       if (err)
+               goto out_unmap_bar;
+       err = adap_init0(adapter);
+       if (err)
+               goto out_unmap_bar;
+
+       for_each_port(adapter, i) {
+               struct net_device *netdev;
+
+               netdev = alloc_etherdev_mq(sizeof(struct port_info),
+                                          MAX_ETH_QSETS);
+               if (!netdev) {
+                       err = -ENOMEM;
+                       goto out_free_dev;
+               }
+
+               SET_NETDEV_DEV(netdev, &pdev->dev);
+
+               adapter->port[i] = netdev;
+               pi = netdev_priv(netdev);
+               pi->adapter = adapter;
+               pi->xact_addr_filt = -1;
+               pi->rx_offload = RX_CSO;
+               pi->port_id = i;
+               netif_carrier_off(netdev);
+               netif_tx_stop_all_queues(netdev);
+               netdev->irq = pdev->irq;
+
+               netdev->features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6;
+               netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
+               netdev->features |= NETIF_F_GRO | highdma;
+               netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
+               netdev->vlan_features = netdev->features & VLAN_FEAT;
+
+               netdev->netdev_ops = &cxgb4_netdev_ops;
+               SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops);
+       }
+
+       pci_set_drvdata(pdev, adapter);
+
+       if (adapter->flags & FW_OK) {
+               err = t4_port_init(adapter, 0, 0, 0);
+               if (err)
+                       goto out_free_dev;
+       }
+
+       /*
+        * Configure queues and allocate tables now, they can be needed as
+        * soon as the first register_netdev completes.
+        */
+       cfg_queues(adapter);
+
+       adapter->l2t = t4_init_l2t();
+       if (!adapter->l2t) {
+               /* We tolerate a lack of L2T, giving up some functionality */
+               dev_warn(&pdev->dev, "could not allocate L2T, continuing\n");
+               adapter->params.offload = 0;
+       }
+
+       if (is_offload(adapter) && tid_init(&adapter->tids) < 0) {
+               dev_warn(&pdev->dev, "could not allocate TID table, "
+                        "continuing\n");
+               adapter->params.offload = 0;
+       }
+
+       /*
+        * The card is now ready to go.  If any errors occur during device
+        * registration we do not fail the whole card but rather proceed only
+        * with the ports we manage to register successfully.  However we must
+        * register at least one net device.
+        */
+       for_each_port(adapter, i) {
+               err = register_netdev(adapter->port[i]);
+               if (err)
+                       dev_warn(&pdev->dev,
+                                "cannot register net device %s, skipping\n",
+                                adapter->port[i]->name);
+               else {
+                       /*
+                        * Change the name we use for messages to the name of
+                        * the first successfully registered interface.
+                        */
+                       if (!adapter->registered_device_map)
+                               adapter->name = adapter->port[i]->name;
+
+                       __set_bit(i, &adapter->registered_device_map);
+                       adapter->chan_map[adap2pinfo(adapter, i)->tx_chan] = i;
+               }
+       }
+       if (!adapter->registered_device_map) {
+               dev_err(&pdev->dev, "could not register any net devices\n");
+               goto out_free_dev;
+       }
+
+       if (cxgb4_debugfs_root) {
+               adapter->debugfs_root = debugfs_create_dir(pci_name(pdev),
+                                                          cxgb4_debugfs_root);
+               setup_debugfs(adapter);
+       }
+
+       /* See what interrupts we'll be using */
+       if (msi > 1 && enable_msix(adapter) == 0)
+               adapter->flags |= USING_MSIX;
+       else if (msi > 0 && pci_enable_msi(pdev) == 0)
+               adapter->flags |= USING_MSI;
+
+       if (is_offload(adapter))
+               attach_ulds(adapter);
+
+       print_port_info(adapter);
+
+sriov:
+#ifdef CONFIG_PCI_IOV
+       if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
+               if (pci_enable_sriov(pdev, num_vf[func]) == 0)
+                       dev_info(&pdev->dev,
+                                "instantiated %u virtual functions\n",
+                                num_vf[func]);
+#endif
+       return 0;
+
+ out_free_dev:
+       t4_free_mem(adapter->tids.tid_tab);
+       t4_free_mem(adapter->l2t);
+       for_each_port(adapter, i)
+               if (adapter->port[i])
+                       free_netdev(adapter->port[i]);
+       if (adapter->flags & FW_OK)
+               t4_fw_bye(adapter, 0);
+ out_unmap_bar:
+       iounmap(adapter->regs);
+ out_free_adapter:
+       kfree(adapter);
+ out_disable_device:
+       pci_disable_pcie_error_reporting(pdev);
+       pci_disable_device(pdev);
+ out_release_regions:
+       pci_release_regions(pdev);
+       pci_set_drvdata(pdev, NULL);
+       return err;
+}
+
+static void __devexit remove_one(struct pci_dev *pdev)
+{
+       struct adapter *adapter = pci_get_drvdata(pdev);
+
+       pci_disable_sriov(pdev);
+
+       if (adapter) {
+               int i;
+
+               if (is_offload(adapter))
+                       detach_ulds(adapter);
+
+               for_each_port(adapter, i)
+                       if (test_bit(i, &adapter->registered_device_map))
+                               unregister_netdev(adapter->port[i]);
+
+               if (adapter->debugfs_root)
+                       debugfs_remove_recursive(adapter->debugfs_root);
+
+               t4_sge_stop(adapter);
+               t4_free_sge_resources(adapter);
+               t4_free_mem(adapter->l2t);
+               t4_free_mem(adapter->tids.tid_tab);
+               disable_msi(adapter);
+
+               for_each_port(adapter, i)
+                       if (adapter->port[i])
+                               free_netdev(adapter->port[i]);
+
+               if (adapter->flags & FW_OK)
+                       t4_fw_bye(adapter, 0);
+               iounmap(adapter->regs);
+               kfree(adapter);
+               pci_disable_pcie_error_reporting(pdev);
+               pci_disable_device(pdev);
+               pci_release_regions(pdev);
+               pci_set_drvdata(pdev, NULL);
+       } else if (PCI_FUNC(pdev->devfn) > 0)
+               pci_release_regions(pdev);
+}
+
+static struct pci_driver cxgb4_driver = {
+       .name     = KBUILD_MODNAME,
+       .id_table = cxgb4_pci_tbl,
+       .probe    = init_one,
+       .remove   = __devexit_p(remove_one),
+};
+
+static int __init cxgb4_init_module(void)
+{
+       int ret;
+
+       /* Debugfs support is optional, just warn if this fails */
+       cxgb4_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
+       if (!cxgb4_debugfs_root)
+               pr_warning("could not create debugfs entry, continuing\n");
+
+       ret = pci_register_driver(&cxgb4_driver);
+       if (ret < 0)
+               debugfs_remove(cxgb4_debugfs_root);
+       return ret;
+}
+
+static void __exit cxgb4_cleanup_module(void)
+{
+       pci_unregister_driver(&cxgb4_driver);
+       debugfs_remove(cxgb4_debugfs_root);  /* NULL ok */
+}
+
+module_init(cxgb4_init_module);
+module_exit(cxgb4_cleanup_module);
diff --git a/drivers/net/cxgb4/cxgb4_uld.h b/drivers/net/cxgb4/cxgb4_uld.h
new file mode 100644 (file)
index 0000000..5b98546
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __CXGB4_OFLD_H
+#define __CXGB4_OFLD_H
+
+#include <linux/cache.h>
+#include <linux/spinlock.h>
+#include <linux/skbuff.h>
+#include <asm/atomic.h>
+
+/* CPL message priority levels */
+enum {
+       CPL_PRIORITY_DATA     = 0,  /* data messages */
+       CPL_PRIORITY_SETUP    = 1,  /* connection setup messages */
+       CPL_PRIORITY_TEARDOWN = 0,  /* connection teardown messages */
+       CPL_PRIORITY_LISTEN   = 1,  /* listen start/stop messages */
+       CPL_PRIORITY_ACK      = 1,  /* RX ACK messages */
+       CPL_PRIORITY_CONTROL  = 1   /* control messages */
+};
+
+#define INIT_TP_WR(w, tid) do { \
+       (w)->wr.wr_hi = htonl(FW_WR_OP(FW_TP_WR) | \
+                             FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \
+       (w)->wr.wr_mid = htonl(FW_WR_LEN16(DIV_ROUND_UP(sizeof(*w), 16)) | \
+                              FW_WR_FLOWID(tid)); \
+       (w)->wr.wr_lo = cpu_to_be64(0); \
+} while (0)
+
+#define INIT_TP_WR_CPL(w, cpl, tid) do { \
+       INIT_TP_WR(w, tid); \
+       OPCODE_TID(w) = htonl(MK_OPCODE_TID(cpl, tid)); \
+} while (0)
+
+#define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
+       (w)->wr.wr_hi = htonl(FW_WR_OP(FW_ULPTX_WR) | FW_WR_ATOMIC(atomic)); \
+       (w)->wr.wr_mid = htonl(FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
+                              FW_WR_FLOWID(tid)); \
+       (w)->wr.wr_lo = cpu_to_be64(0); \
+} while (0)
+
+/* Special asynchronous notification message */
+#define CXGB4_MSG_AN ((void *)1)
+
+struct serv_entry {
+       void *data;
+};
+
+union aopen_entry {
+       void *data;
+       union aopen_entry *next;
+};
+
+/*
+ * Holds the size, base address, free list start, etc of the TID, server TID,
+ * and active-open TID tables.  The tables themselves are allocated dynamically.
+ */
+struct tid_info {
+       void **tid_tab;
+       unsigned int ntids;
+
+       struct serv_entry *stid_tab;
+       unsigned long *stid_bmap;
+       unsigned int nstids;
+       unsigned int stid_base;
+
+       union aopen_entry *atid_tab;
+       unsigned int natids;
+
+       unsigned int nftids;
+       unsigned int ftid_base;
+
+       spinlock_t atid_lock ____cacheline_aligned_in_smp;
+       union aopen_entry *afree;
+       unsigned int atids_in_use;
+
+       spinlock_t stid_lock;
+       unsigned int stids_in_use;
+
+       atomic_t tids_in_use;
+};
+
+static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
+{
+       return tid < t->ntids ? t->tid_tab[tid] : NULL;
+}
+
+static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
+{
+       return atid < t->natids ? t->atid_tab[atid].data : NULL;
+}
+
+static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
+{
+       stid -= t->stid_base;
+       return stid < t->nstids ? t->stid_tab[stid].data : NULL;
+}
+
+static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
+                                   unsigned int tid)
+{
+       t->tid_tab[tid] = data;
+       atomic_inc(&t->tids_in_use);
+}
+
+int cxgb4_alloc_atid(struct tid_info *t, void *data);
+int cxgb4_alloc_stid(struct tid_info *t, int family, void *data);
+void cxgb4_free_atid(struct tid_info *t, unsigned int atid);
+void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family);
+void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid);
+void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
+                            unsigned int tid);
+
+struct in6_addr;
+
+int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
+                       __be32 sip, __be16 sport, unsigned int queue);
+int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
+                        const struct in6_addr *sip, __be16 sport,
+                        unsigned int queue);
+
+static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
+{
+       skb_set_queue_mapping(skb, (queue << 1) | prio);
+}
+
+enum cxgb4_uld {
+       CXGB4_ULD_RDMA,
+       CXGB4_ULD_ISCSI,
+       CXGB4_ULD_MAX
+};
+
+enum cxgb4_state {
+       CXGB4_STATE_UP,
+       CXGB4_STATE_START_RECOVERY,
+       CXGB4_STATE_DOWN,
+       CXGB4_STATE_DETACH
+};
+
+struct pci_dev;
+struct l2t_data;
+struct net_device;
+struct pkt_gl;
+struct tp_tcp_stats;
+
+struct cxgb4_range {
+       unsigned int start;
+       unsigned int size;
+};
+
+struct cxgb4_virt_res {                      /* virtualized HW resources */
+       struct cxgb4_range ddp;
+       struct cxgb4_range iscsi;
+       struct cxgb4_range stag;
+       struct cxgb4_range rq;
+       struct cxgb4_range pbl;
+};
+
+/*
+ * Block of information the LLD provides to ULDs attaching to a device.
+ */
+struct cxgb4_lld_info {
+       struct pci_dev *pdev;                /* associated PCI device */
+       struct l2t_data *l2t;                /* L2 table */
+       struct tid_info *tids;               /* TID table */
+       struct net_device **ports;           /* device ports */
+       const struct cxgb4_virt_res *vr;     /* assorted HW resources */
+       const unsigned short *mtus;          /* MTU table */
+       const unsigned short *rxq_ids;       /* the ULD's Rx queue ids */
+       unsigned short nrxq;                 /* # of Rx queues */
+       unsigned short ntxq;                 /* # of Tx queues */
+       unsigned char nchan:4;               /* # of channels */
+       unsigned char nports:4;              /* # of ports */
+       unsigned char wr_cred;               /* WR 16-byte credits */
+       unsigned char adapter_type;          /* type of adapter */
+       unsigned char fw_api_ver;            /* FW API version */
+       unsigned int fw_vers;                /* FW version */
+       unsigned int iscsi_iolen;            /* iSCSI max I/O length */
+       unsigned short udb_density;          /* # of user DB/page */
+       unsigned short ucq_density;          /* # of user CQs/page */
+       void __iomem *gts_reg;               /* address of GTS register */
+       void __iomem *db_reg;                /* address of kernel doorbell */
+};
+
+struct cxgb4_uld_info {
+       const char *name;
+       void *(*add)(const struct cxgb4_lld_info *p);
+       int (*rx_handler)(void *handle, const __be64 *rsp,
+                         const struct pkt_gl *gl);
+       int (*state_change)(void *handle, enum cxgb4_state new_state);
+};
+
+int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p);
+int cxgb4_unregister_uld(enum cxgb4_uld type);
+int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb);
+unsigned int cxgb4_port_chan(const struct net_device *dev);
+unsigned int cxgb4_port_viid(const struct net_device *dev);
+unsigned int cxgb4_port_idx(const struct net_device *dev);
+struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id);
+unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
+                           unsigned int *idx);
+void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
+                        struct tp_tcp_stats *v6);
+void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
+                     const unsigned int *pgsz_order);
+struct sk_buff *cxgb4_pktgl_to_skb(const struct pkt_gl *gl,
+                                  unsigned int skb_len, unsigned int pull_len);
+#endif  /* !__CXGB4_OFLD_H */
diff --git a/drivers/net/cxgb4/l2t.c b/drivers/net/cxgb4/l2t.c
new file mode 100644 (file)
index 0000000..9f96724
--- /dev/null
@@ -0,0 +1,624 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/if.h>
+#include <linux/if_vlan.h>
+#include <linux/jhash.h>
+#include <net/neighbour.h>
+#include "cxgb4.h"
+#include "l2t.h"
+#include "t4_msg.h"
+#include "t4fw_api.h"
+
+#define VLAN_NONE 0xfff
+
+/* identifies sync vs async L2T_WRITE_REQs */
+#define F_SYNC_WR    (1 << 12)
+
+enum {
+       L2T_STATE_VALID,      /* entry is up to date */
+       L2T_STATE_STALE,      /* entry may be used but needs revalidation */
+       L2T_STATE_RESOLVING,  /* entry needs address resolution */
+       L2T_STATE_SYNC_WRITE, /* synchronous write of entry underway */
+
+       /* when state is one of the below the entry is not hashed */
+       L2T_STATE_SWITCHING,  /* entry is being used by a switching filter */
+       L2T_STATE_UNUSED      /* entry not in use */
+};
+
+struct l2t_data {
+       rwlock_t lock;
+       atomic_t nfree;             /* number of free entries */
+       struct l2t_entry *rover;    /* starting point for next allocation */
+       struct l2t_entry l2tab[L2T_SIZE];
+};
+
+static inline unsigned int vlan_prio(const struct l2t_entry *e)
+{
+       return e->vlan >> 13;
+}
+
+static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e)
+{
+       if (atomic_add_return(1, &e->refcnt) == 1)  /* 0 -> 1 transition */
+               atomic_dec(&d->nfree);
+}
+
+/*
+ * To avoid having to check address families we do not allow v4 and v6
+ * neighbors to be on the same hash chain.  We keep v4 entries in the first
+ * half of available hash buckets and v6 in the second.
+ */
+enum {
+       L2T_SZ_HALF = L2T_SIZE / 2,
+       L2T_HASH_MASK = L2T_SZ_HALF - 1
+};
+
+static inline unsigned int arp_hash(const u32 *key, int ifindex)
+{
+       return jhash_2words(*key, ifindex, 0) & L2T_HASH_MASK;
+}
+
+static inline unsigned int ipv6_hash(const u32 *key, int ifindex)
+{
+       u32 xor = key[0] ^ key[1] ^ key[2] ^ key[3];
+
+       return L2T_SZ_HALF + (jhash_2words(xor, ifindex, 0) & L2T_HASH_MASK);
+}
+
+static unsigned int addr_hash(const u32 *addr, int addr_len, int ifindex)
+{
+       return addr_len == 4 ? arp_hash(addr, ifindex) :
+                              ipv6_hash(addr, ifindex);
+}
+
+/*
+ * Checks if an L2T entry is for the given IP/IPv6 address.  It does not check
+ * whether the L2T entry and the address are of the same address family.
+ * Callers ensure an address is only checked against L2T entries of the same
+ * family, something made trivial by the separation of IP and IPv6 hash chains
+ * mentioned above.  Returns 0 if there's a match,
+ */
+static int addreq(const struct l2t_entry *e, const u32 *addr)
+{
+       if (e->v6)
+               return (e->addr[0] ^ addr[0]) | (e->addr[1] ^ addr[1]) |
+                      (e->addr[2] ^ addr[2]) | (e->addr[3] ^ addr[3]);
+       return e->addr[0] ^ addr[0];
+}
+
+static void neigh_replace(struct l2t_entry *e, struct neighbour *n)
+{
+       neigh_hold(n);
+       if (e->neigh)
+               neigh_release(e->neigh);
+       e->neigh = n;
+}
+
+/*
+ * Write an L2T entry.  Must be called with the entry locked.
+ * The write may be synchronous or asynchronous.
+ */
+static int write_l2e(struct adapter *adap, struct l2t_entry *e, int sync)
+{
+       struct sk_buff *skb;
+       struct cpl_l2t_write_req *req;
+
+       skb = alloc_skb(sizeof(*req), GFP_ATOMIC);
+       if (!skb)
+               return -ENOMEM;
+
+       req = (struct cpl_l2t_write_req *)__skb_put(skb, sizeof(*req));
+       INIT_TP_WR(req, 0);
+
+       OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_L2T_WRITE_REQ,
+                                       e->idx | (sync ? F_SYNC_WR : 0) |
+                                       TID_QID(adap->sge.fw_evtq.abs_id)));
+       req->params = htons(L2T_W_PORT(e->lport) | L2T_W_NOREPLY(!sync));
+       req->l2t_idx = htons(e->idx);
+       req->vlan = htons(e->vlan);
+       if (e->neigh)
+               memcpy(e->dmac, e->neigh->ha, sizeof(e->dmac));
+       memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac));
+
+       set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
+       t4_ofld_send(adap, skb);
+
+       if (sync && e->state != L2T_STATE_SWITCHING)
+               e->state = L2T_STATE_SYNC_WRITE;
+       return 0;
+}
+
+/*
+ * Send packets waiting in an L2T entry's ARP queue.  Must be called with the
+ * entry locked.
+ */
+static void send_pending(struct adapter *adap, struct l2t_entry *e)
+{
+       while (e->arpq_head) {
+               struct sk_buff *skb = e->arpq_head;
+
+               e->arpq_head = skb->next;
+               skb->next = NULL;
+               t4_ofld_send(adap, skb);
+       }
+       e->arpq_tail = NULL;
+}
+
+/*
+ * Process a CPL_L2T_WRITE_RPL.  Wake up the ARP queue if it completes a
+ * synchronous L2T_WRITE.  Note that the TID in the reply is really the L2T
+ * index it refers to.
+ */
+void do_l2t_write_rpl(struct adapter *adap, const struct cpl_l2t_write_rpl *rpl)
+{
+       unsigned int tid = GET_TID(rpl);
+       unsigned int idx = tid & (L2T_SIZE - 1);
+
+       if (unlikely(rpl->status != CPL_ERR_NONE)) {
+               dev_err(adap->pdev_dev,
+                       "Unexpected L2T_WRITE_RPL status %u for entry %u\n",
+                       rpl->status, idx);
+               return;
+       }
+
+       if (tid & F_SYNC_WR) {
+               struct l2t_entry *e = &adap->l2t->l2tab[idx];
+
+               spin_lock(&e->lock);
+               if (e->state != L2T_STATE_SWITCHING) {
+                       send_pending(adap, e);
+                       e->state = (e->neigh->nud_state & NUD_STALE) ?
+                                       L2T_STATE_STALE : L2T_STATE_VALID;
+               }
+               spin_unlock(&e->lock);
+       }
+}
+
+/*
+ * Add a packet to an L2T entry's queue of packets awaiting resolution.
+ * Must be called with the entry's lock held.
+ */
+static inline void arpq_enqueue(struct l2t_entry *e, struct sk_buff *skb)
+{
+       skb->next = NULL;
+       if (e->arpq_head)
+               e->arpq_tail->next = skb;
+       else
+               e->arpq_head = skb;
+       e->arpq_tail = skb;
+}
+
+int cxgb4_l2t_send(struct net_device *dev, struct sk_buff *skb,
+                  struct l2t_entry *e)
+{
+       struct adapter *adap = netdev2adap(dev);
+
+again:
+       switch (e->state) {
+       case L2T_STATE_STALE:     /* entry is stale, kick off revalidation */
+               neigh_event_send(e->neigh, NULL);
+               spin_lock_bh(&e->lock);
+               if (e->state == L2T_STATE_STALE)
+                       e->state = L2T_STATE_VALID;
+               spin_unlock_bh(&e->lock);
+       case L2T_STATE_VALID:     /* fast-path, send the packet on */
+               return t4_ofld_send(adap, skb);
+       case L2T_STATE_RESOLVING:
+       case L2T_STATE_SYNC_WRITE:
+               spin_lock_bh(&e->lock);
+               if (e->state != L2T_STATE_SYNC_WRITE &&
+                   e->state != L2T_STATE_RESOLVING) {
+                       spin_unlock_bh(&e->lock);
+                       goto again;
+               }
+               arpq_enqueue(e, skb);
+               spin_unlock_bh(&e->lock);
+
+               if (e->state == L2T_STATE_RESOLVING &&
+                   !neigh_event_send(e->neigh, NULL)) {
+                       spin_lock_bh(&e->lock);
+                       if (e->state == L2T_STATE_RESOLVING && e->arpq_head)
+                               write_l2e(adap, e, 1);
+                       spin_unlock_bh(&e->lock);
+               }
+       }
+       return 0;
+}
+EXPORT_SYMBOL(cxgb4_l2t_send);
+
+/*
+ * Allocate a free L2T entry.  Must be called with l2t_data.lock held.
+ */
+static struct l2t_entry *alloc_l2e(struct l2t_data *d)
+{
+       struct l2t_entry *end, *e, **p;
+
+       if (!atomic_read(&d->nfree))
+               return NULL;
+
+       /* there's definitely a free entry */
+       for (e = d->rover, end = &d->l2tab[L2T_SIZE]; e != end; ++e)
+               if (atomic_read(&e->refcnt) == 0)
+                       goto found;
+
+       for (e = d->l2tab; atomic_read(&e->refcnt); ++e)
+               ;
+found:
+       d->rover = e + 1;
+       atomic_dec(&d->nfree);
+
+       /*
+        * The entry we found may be an inactive entry that is
+        * presently in the hash table.  We need to remove it.
+        */
+       if (e->state < L2T_STATE_SWITCHING)
+               for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next)
+                       if (*p == e) {
+                               *p = e->next;
+                               e->next = NULL;
+                               break;
+                       }
+
+       e->state = L2T_STATE_UNUSED;
+       return e;
+}
+
+/*
+ * Called when an L2T entry has no more users.
+ */
+static void t4_l2e_free(struct l2t_entry *e)
+{
+       struct l2t_data *d;
+
+       spin_lock_bh(&e->lock);
+       if (atomic_read(&e->refcnt) == 0) {  /* hasn't been recycled */
+               if (e->neigh) {
+                       neigh_release(e->neigh);
+                       e->neigh = NULL;
+               }
+       }
+       spin_unlock_bh(&e->lock);
+
+       d = container_of(e, struct l2t_data, l2tab[e->idx]);
+       atomic_inc(&d->nfree);
+}
+
+void cxgb4_l2t_release(struct l2t_entry *e)
+{
+       if (atomic_dec_and_test(&e->refcnt))
+               t4_l2e_free(e);
+}
+EXPORT_SYMBOL(cxgb4_l2t_release);
+
+/*
+ * Update an L2T entry that was previously used for the same next hop as neigh.
+ * Must be called with softirqs disabled.
+ */
+static void reuse_entry(struct l2t_entry *e, struct neighbour *neigh)
+{
+       unsigned int nud_state;
+
+       spin_lock(&e->lock);                /* avoid race with t4_l2t_free */
+       if (neigh != e->neigh)
+               neigh_replace(e, neigh);
+       nud_state = neigh->nud_state;
+       if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)) ||
+           !(nud_state & NUD_VALID))
+               e->state = L2T_STATE_RESOLVING;
+       else if (nud_state & NUD_CONNECTED)
+               e->state = L2T_STATE_VALID;
+       else
+               e->state = L2T_STATE_STALE;
+       spin_unlock(&e->lock);
+}
+
+struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
+                               const struct net_device *physdev,
+                               unsigned int priority)
+{
+       u8 lport;
+       u16 vlan;
+       struct l2t_entry *e;
+       int addr_len = neigh->tbl->key_len;
+       u32 *addr = (u32 *)neigh->primary_key;
+       int ifidx = neigh->dev->ifindex;
+       int hash = addr_hash(addr, addr_len, ifidx);
+
+       if (neigh->dev->flags & IFF_LOOPBACK)
+               lport = netdev2pinfo(physdev)->tx_chan + 4;
+       else
+               lport = netdev2pinfo(physdev)->lport;
+
+       if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
+               vlan = vlan_dev_vlan_id(neigh->dev);
+       else
+               vlan = VLAN_NONE;
+
+       write_lock_bh(&d->lock);
+       for (e = d->l2tab[hash].first; e; e = e->next)
+               if (!addreq(e, addr) && e->ifindex == ifidx &&
+                   e->vlan == vlan && e->lport == lport) {
+                       l2t_hold(d, e);
+                       if (atomic_read(&e->refcnt) == 1)
+                               reuse_entry(e, neigh);
+                       goto done;
+               }
+
+       /* Need to allocate a new entry */
+       e = alloc_l2e(d);
+       if (e) {
+               spin_lock(&e->lock);          /* avoid race with t4_l2t_free */
+               e->state = L2T_STATE_RESOLVING;
+               memcpy(e->addr, addr, addr_len);
+               e->ifindex = ifidx;
+               e->hash = hash;
+               e->lport = lport;
+               e->v6 = addr_len == 16;
+               atomic_set(&e->refcnt, 1);
+               neigh_replace(e, neigh);
+               e->vlan = vlan;
+               e->next = d->l2tab[hash].first;
+               d->l2tab[hash].first = e;
+               spin_unlock(&e->lock);
+       }
+done:
+       write_unlock_bh(&d->lock);
+       return e;
+}
+EXPORT_SYMBOL(cxgb4_l2t_get);
+
+/*
+ * Called when address resolution fails for an L2T entry to handle packets
+ * on the arpq head.  If a packet specifies a failure handler it is invoked,
+ * otherwise the packet is sent to the device.
+ */
+static void handle_failed_resolution(struct adapter *adap, struct sk_buff *arpq)
+{
+       while (arpq) {
+               struct sk_buff *skb = arpq;
+               const struct l2t_skb_cb *cb = L2T_SKB_CB(skb);
+
+               arpq = skb->next;
+               skb->next = NULL;
+               if (cb->arp_err_handler)
+                       cb->arp_err_handler(cb->handle, skb);
+               else
+                       t4_ofld_send(adap, skb);
+       }
+}
+
+/*
+ * Called when the host's neighbor layer makes a change to some entry that is
+ * loaded into the HW L2 table.
+ */
+void t4_l2t_update(struct adapter *adap, struct neighbour *neigh)
+{
+       struct l2t_entry *e;
+       struct sk_buff *arpq = NULL;
+       struct l2t_data *d = adap->l2t;
+       int addr_len = neigh->tbl->key_len;
+       u32 *addr = (u32 *) neigh->primary_key;
+       int ifidx = neigh->dev->ifindex;
+       int hash = addr_hash(addr, addr_len, ifidx);
+
+       read_lock_bh(&d->lock);
+       for (e = d->l2tab[hash].first; e; e = e->next)
+               if (!addreq(e, addr) && e->ifindex == ifidx) {
+                       spin_lock(&e->lock);
+                       if (atomic_read(&e->refcnt))
+                               goto found;
+                       spin_unlock(&e->lock);
+                       break;
+               }
+       read_unlock_bh(&d->lock);
+       return;
+
+ found:
+       read_unlock(&d->lock);
+
+       if (neigh != e->neigh)
+               neigh_replace(e, neigh);
+
+       if (e->state == L2T_STATE_RESOLVING) {
+               if (neigh->nud_state & NUD_FAILED) {
+                       arpq = e->arpq_head;
+                       e->arpq_head = e->arpq_tail = NULL;
+               } else if ((neigh->nud_state & (NUD_CONNECTED | NUD_STALE)) &&
+                          e->arpq_head) {
+                       write_l2e(adap, e, 1);
+               }
+       } else {
+               e->state = neigh->nud_state & NUD_CONNECTED ?
+                       L2T_STATE_VALID : L2T_STATE_STALE;
+               if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)))
+                       write_l2e(adap, e, 0);
+       }
+
+       spin_unlock_bh(&e->lock);
+
+       if (arpq)
+               handle_failed_resolution(adap, arpq);
+}
+
+/*
+ * Allocate an L2T entry for use by a switching rule.  Such entries need to be
+ * explicitly freed and while busy they are not on any hash chain, so normal
+ * address resolution updates do not see them.
+ */
+struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d)
+{
+       struct l2t_entry *e;
+
+       write_lock_bh(&d->lock);
+       e = alloc_l2e(d);
+       if (e) {
+               spin_lock(&e->lock);          /* avoid race with t4_l2t_free */
+               e->state = L2T_STATE_SWITCHING;
+               atomic_set(&e->refcnt, 1);
+               spin_unlock(&e->lock);
+       }
+       write_unlock_bh(&d->lock);
+       return e;
+}
+
+/*
+ * Sets/updates the contents of a switching L2T entry that has been allocated
+ * with an earlier call to @t4_l2t_alloc_switching.
+ */
+int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
+                        u8 port, u8 *eth_addr)
+{
+       e->vlan = vlan;
+       e->lport = port;
+       memcpy(e->dmac, eth_addr, ETH_ALEN);
+       return write_l2e(adap, e, 0);
+}
+
+struct l2t_data *t4_init_l2t(void)
+{
+       int i;
+       struct l2t_data *d;
+
+       d = t4_alloc_mem(sizeof(*d));
+       if (!d)
+               return NULL;
+
+       d->rover = d->l2tab;
+       atomic_set(&d->nfree, L2T_SIZE);
+       rwlock_init(&d->lock);
+
+       for (i = 0; i < L2T_SIZE; ++i) {
+               d->l2tab[i].idx = i;
+               d->l2tab[i].state = L2T_STATE_UNUSED;
+               spin_lock_init(&d->l2tab[i].lock);
+               atomic_set(&d->l2tab[i].refcnt, 0);
+       }
+       return d;
+}
+
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+static inline void *l2t_get_idx(struct seq_file *seq, loff_t pos)
+{
+       struct l2t_entry *l2tab = seq->private;
+
+       return pos >= L2T_SIZE ? NULL : &l2tab[pos];
+}
+
+static void *l2t_seq_start(struct seq_file *seq, loff_t *pos)
+{
+       return *pos ? l2t_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
+}
+
+static void *l2t_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+       v = l2t_get_idx(seq, *pos);
+       if (v)
+               ++*pos;
+       return v;
+}
+
+static void l2t_seq_stop(struct seq_file *seq, void *v)
+{
+}
+
+static char l2e_state(const struct l2t_entry *e)
+{
+       switch (e->state) {
+       case L2T_STATE_VALID: return 'V';
+       case L2T_STATE_STALE: return 'S';
+       case L2T_STATE_SYNC_WRITE: return 'W';
+       case L2T_STATE_RESOLVING: return e->arpq_head ? 'A' : 'R';
+       case L2T_STATE_SWITCHING: return 'X';
+       default:
+               return 'U';
+       }
+}
+
+static int l2t_seq_show(struct seq_file *seq, void *v)
+{
+       if (v == SEQ_START_TOKEN)
+               seq_puts(seq, " Idx IP address                "
+                        "Ethernet address  VLAN/P LP State Users Port\n");
+       else {
+               char ip[60];
+               struct l2t_entry *e = v;
+
+               spin_lock_bh(&e->lock);
+               if (e->state == L2T_STATE_SWITCHING)
+                       ip[0] = '\0';
+               else
+                       sprintf(ip, e->v6 ? "%pI6c" : "%pI4", e->addr);
+               seq_printf(seq, "%4u %-25s %17pM %4d %u %2u   %c   %5u %s\n",
+                          e->idx, ip, e->dmac,
+                          e->vlan & VLAN_VID_MASK, vlan_prio(e), e->lport,
+                          l2e_state(e), atomic_read(&e->refcnt),
+                          e->neigh ? e->neigh->dev->name : "");
+               spin_unlock_bh(&e->lock);
+       }
+       return 0;
+}
+
+static const struct seq_operations l2t_seq_ops = {
+       .start = l2t_seq_start,
+       .next = l2t_seq_next,
+       .stop = l2t_seq_stop,
+       .show = l2t_seq_show
+};
+
+static int l2t_seq_open(struct inode *inode, struct file *file)
+{
+       int rc = seq_open(file, &l2t_seq_ops);
+
+       if (!rc) {
+               struct adapter *adap = inode->i_private;
+               struct seq_file *seq = file->private_data;
+
+               seq->private = adap->l2t->l2tab;
+       }
+       return rc;
+}
+
+const struct file_operations t4_l2t_fops = {
+       .owner = THIS_MODULE,
+       .open = l2t_seq_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = seq_release,
+};
diff --git a/drivers/net/cxgb4/l2t.h b/drivers/net/cxgb4/l2t.h
new file mode 100644 (file)
index 0000000..643f27e
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __CXGB4_L2T_H
+#define __CXGB4_L2T_H
+
+#include <linux/spinlock.h>
+#include <linux/if_ether.h>
+#include <asm/atomic.h>
+
+struct adapter;
+struct l2t_data;
+struct neighbour;
+struct net_device;
+struct file_operations;
+struct cpl_l2t_write_rpl;
+
+/*
+ * Each L2T entry plays multiple roles.  First of all, it keeps state for the
+ * corresponding entry of the HW L2 table and maintains a queue of offload
+ * packets awaiting address resolution.  Second, it is a node of a hash table
+ * chain, where the nodes of the chain are linked together through their next
+ * pointer.  Finally, each node is a bucket of a hash table, pointing to the
+ * first element in its chain through its first pointer.
+ */
+struct l2t_entry {
+       u16 state;                  /* entry state */
+       u16 idx;                    /* entry index */
+       u32 addr[4];                /* next hop IP or IPv6 address */
+       int ifindex;                /* neighbor's net_device's ifindex */
+       struct neighbour *neigh;    /* associated neighbour */
+       struct l2t_entry *first;    /* start of hash chain */
+       struct l2t_entry *next;     /* next l2t_entry on chain */
+       struct sk_buff *arpq_head;  /* queue of packets awaiting resolution */
+       struct sk_buff *arpq_tail;
+       spinlock_t lock;
+       atomic_t refcnt;            /* entry reference count */
+       u16 hash;                   /* hash bucket the entry is on */
+       u16 vlan;                   /* VLAN TCI (id: bits 0-11, prio: 13-15 */
+       u8 v6;                      /* whether entry is for IPv6 */
+       u8 lport;                   /* associated offload logical interface */
+       u8 dmac[ETH_ALEN];          /* neighbour's MAC address */
+};
+
+typedef void (*arp_err_handler_t)(void *handle, struct sk_buff *skb);
+
+/*
+ * Callback stored in an skb to handle address resolution failure.
+ */
+struct l2t_skb_cb {
+       void *handle;
+       arp_err_handler_t arp_err_handler;
+};
+
+#define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
+
+static inline void t4_set_arp_err_handler(struct sk_buff *skb, void *handle,
+                                         arp_err_handler_t handler)
+{
+       L2T_SKB_CB(skb)->handle = handle;
+       L2T_SKB_CB(skb)->arp_err_handler = handler;
+}
+
+void cxgb4_l2t_release(struct l2t_entry *e);
+int cxgb4_l2t_send(struct net_device *dev, struct sk_buff *skb,
+                  struct l2t_entry *e);
+struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
+                               const struct net_device *physdev,
+                               unsigned int priority);
+
+void t4_l2t_update(struct adapter *adap, struct neighbour *neigh);
+struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d);
+int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
+                        u8 port, u8 *eth_addr);
+struct l2t_data *t4_init_l2t(void);
+void do_l2t_write_rpl(struct adapter *p, const struct cpl_l2t_write_rpl *rpl);
+
+extern const struct file_operations t4_l2t_fops;
+#endif  /* __CXGB4_L2T_H */
diff --git a/drivers/net/cxgb4/sge.c b/drivers/net/cxgb4/sge.c
new file mode 100644 (file)
index 0000000..14adc58
--- /dev/null
@@ -0,0 +1,2431 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
+#include <linux/ip.h>
+#include <linux/dma-mapping.h>
+#include <linux/jiffies.h>
+#include <net/ipv6.h>
+#include <net/tcp.h>
+#include "cxgb4.h"
+#include "t4_regs.h"
+#include "t4_msg.h"
+#include "t4fw_api.h"
+
+/*
+ * Rx buffer size.  We use largish buffers if possible but settle for single
+ * pages under memory shortage.
+ */
+#if PAGE_SHIFT >= 16
+# define FL_PG_ORDER 0
+#else
+# define FL_PG_ORDER (16 - PAGE_SHIFT)
+#endif
+
+/* RX_PULL_LEN should be <= RX_COPY_THRES */
+#define RX_COPY_THRES    256
+#define RX_PULL_LEN      128
+
+/*
+ * Main body length for sk_buffs used for Rx Ethernet packets with fragments.
+ * Should be >= RX_PULL_LEN but possibly bigger to give pskb_may_pull some room.
+ */
+#define RX_PKT_SKB_LEN   512
+
+/* Ethernet header padding prepended to RX_PKTs */
+#define RX_PKT_PAD 2
+
+/*
+ * Max number of Tx descriptors we clean up at a time.  Should be modest as
+ * freeing skbs isn't cheap and it happens while holding locks.  We just need
+ * to free packets faster than they arrive, we eventually catch up and keep
+ * the amortized cost reasonable.  Must be >= 2 * TXQ_STOP_THRES.
+ */
+#define MAX_TX_RECLAIM 16
+
+/*
+ * Max number of Rx buffers we replenish at a time.  Again keep this modest,
+ * allocating buffers isn't cheap either.
+ */
+#define MAX_RX_REFILL 16U
+
+/*
+ * Period of the Rx queue check timer.  This timer is infrequent as it has
+ * something to do only when the system experiences severe memory shortage.
+ */
+#define RX_QCHECK_PERIOD (HZ / 2)
+
+/*
+ * Period of the Tx queue check timer.
+ */
+#define TX_QCHECK_PERIOD (HZ / 2)
+
+/*
+ * Max number of Tx descriptors to be reclaimed by the Tx timer.
+ */
+#define MAX_TIMER_TX_RECLAIM 100
+
+/*
+ * Timer index used when backing off due to memory shortage.
+ */
+#define NOMEM_TMR_IDX (SGE_NTIMERS - 1)
+
+/*
+ * An FL with <= FL_STARVE_THRES buffers is starving and a periodic timer will
+ * attempt to refill it.
+ */
+#define FL_STARVE_THRES 4
+
+/*
+ * Suspend an Ethernet Tx queue with fewer available descriptors than this.
+ * This is the same as calc_tx_descs() for a TSO packet with
+ * nr_frags == MAX_SKB_FRAGS.
+ */
+#define ETHTXQ_STOP_THRES \
+       (1 + DIV_ROUND_UP((3 * MAX_SKB_FRAGS) / 2 + (MAX_SKB_FRAGS & 1), 8))
+
+/*
+ * Suspension threshold for non-Ethernet Tx queues.  We require enough room
+ * for a full sized WR.
+ */
+#define TXQ_STOP_THRES (SGE_MAX_WR_LEN / sizeof(struct tx_desc))
+
+/*
+ * Max Tx descriptor space we allow for an Ethernet packet to be inlined
+ * into a WR.
+ */
+#define MAX_IMM_TX_PKT_LEN 128
+
+/*
+ * Max size of a WR sent through a control Tx queue.
+ */
+#define MAX_CTRL_WR_LEN SGE_MAX_WR_LEN
+
+enum {
+       /* packet alignment in FL buffers */
+       FL_ALIGN = L1_CACHE_BYTES < 32 ? 32 : L1_CACHE_BYTES,
+       /* egress status entry size */
+       STAT_LEN = L1_CACHE_BYTES > 64 ? 128 : 64
+};
+
+struct tx_sw_desc {                /* SW state per Tx descriptor */
+       struct sk_buff *skb;
+       struct ulptx_sgl *sgl;
+};
+
+struct rx_sw_desc {                /* SW state per Rx descriptor */
+       struct page *page;
+       dma_addr_t dma_addr;
+};
+
+/*
+ * The low bits of rx_sw_desc.dma_addr have special meaning.
+ */
+enum {
+       RX_LARGE_BUF    = 1 << 0, /* buffer is larger than PAGE_SIZE */
+       RX_UNMAPPED_BUF = 1 << 1, /* buffer is not mapped */
+};
+
+static inline dma_addr_t get_buf_addr(const struct rx_sw_desc *d)
+{
+       return d->dma_addr & ~(dma_addr_t)(RX_LARGE_BUF | RX_UNMAPPED_BUF);
+}
+
+static inline bool is_buf_mapped(const struct rx_sw_desc *d)
+{
+       return !(d->dma_addr & RX_UNMAPPED_BUF);
+}
+
+/**
+ *     txq_avail - return the number of available slots in a Tx queue
+ *     @q: the Tx queue
+ *
+ *     Returns the number of descriptors in a Tx queue available to write new
+ *     packets.
+ */
+static inline unsigned int txq_avail(const struct sge_txq *q)
+{
+       return q->size - 1 - q->in_use;
+}
+
+/**
+ *     fl_cap - return the capacity of a free-buffer list
+ *     @fl: the FL
+ *
+ *     Returns the capacity of a free-buffer list.  The capacity is less than
+ *     the size because one descriptor needs to be left unpopulated, otherwise
+ *     HW will think the FL is empty.
+ */
+static inline unsigned int fl_cap(const struct sge_fl *fl)
+{
+       return fl->size - 8;   /* 1 descriptor = 8 buffers */
+}
+
+static inline bool fl_starving(const struct sge_fl *fl)
+{
+       return fl->avail - fl->pend_cred <= FL_STARVE_THRES;
+}
+
+static int map_skb(struct device *dev, const struct sk_buff *skb,
+                  dma_addr_t *addr)
+{
+       const skb_frag_t *fp, *end;
+       const struct skb_shared_info *si;
+
+       *addr = dma_map_single(dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
+       if (dma_mapping_error(dev, *addr))
+               goto out_err;
+
+       si = skb_shinfo(skb);
+       end = &si->frags[si->nr_frags];
+
+       for (fp = si->frags; fp < end; fp++) {
+               *++addr = dma_map_page(dev, fp->page, fp->page_offset, fp->size,
+                                      DMA_TO_DEVICE);
+               if (dma_mapping_error(dev, *addr))
+                       goto unwind;
+       }
+       return 0;
+
+unwind:
+       while (fp-- > si->frags)
+               dma_unmap_page(dev, *--addr, fp->size, DMA_TO_DEVICE);
+
+       dma_unmap_single(dev, addr[-1], skb_headlen(skb), DMA_TO_DEVICE);
+out_err:
+       return -ENOMEM;
+}
+
+#ifdef CONFIG_NEED_DMA_MAP_STATE
+static void unmap_skb(struct device *dev, const struct sk_buff *skb,
+                     const dma_addr_t *addr)
+{
+       const skb_frag_t *fp, *end;
+       const struct skb_shared_info *si;
+
+       dma_unmap_single(dev, *addr++, skb_headlen(skb), DMA_TO_DEVICE);
+
+       si = skb_shinfo(skb);
+       end = &si->frags[si->nr_frags];
+       for (fp = si->frags; fp < end; fp++)
+               dma_unmap_page(dev, *addr++, fp->size, DMA_TO_DEVICE);
+}
+
+/**
+ *     deferred_unmap_destructor - unmap a packet when it is freed
+ *     @skb: the packet
+ *
+ *     This is the packet destructor used for Tx packets that need to remain
+ *     mapped until they are freed rather than until their Tx descriptors are
+ *     freed.
+ */
+static void deferred_unmap_destructor(struct sk_buff *skb)
+{
+       unmap_skb(skb->dev->dev.parent, skb, (dma_addr_t *)skb->head);
+}
+#endif
+
+static void unmap_sgl(struct device *dev, const struct sk_buff *skb,
+                     const struct ulptx_sgl *sgl, const struct sge_txq *q)
+{
+       const struct ulptx_sge_pair *p;
+       unsigned int nfrags = skb_shinfo(skb)->nr_frags;
+
+       if (likely(skb_headlen(skb)))
+               dma_unmap_single(dev, be64_to_cpu(sgl->addr0), ntohl(sgl->len0),
+                                DMA_TO_DEVICE);
+       else {
+               dma_unmap_page(dev, be64_to_cpu(sgl->addr0), ntohl(sgl->len0),
+                              DMA_TO_DEVICE);
+               nfrags--;
+       }
+
+       /*
+        * the complexity below is because of the possibility of a wrap-around
+        * in the middle of an SGL
+        */
+       for (p = sgl->sge; nfrags >= 2; nfrags -= 2) {
+               if (likely((u8 *)(p + 1) <= (u8 *)q->stat)) {
+unmap:                 dma_unmap_page(dev, be64_to_cpu(p->addr[0]),
+                                      ntohl(p->len[0]), DMA_TO_DEVICE);
+                       dma_unmap_page(dev, be64_to_cpu(p->addr[1]),
+                                      ntohl(p->len[1]), DMA_TO_DEVICE);
+                       p++;
+               } else if ((u8 *)p == (u8 *)q->stat) {
+                       p = (const struct ulptx_sge_pair *)q->desc;
+                       goto unmap;
+               } else if ((u8 *)p + 8 == (u8 *)q->stat) {
+                       const __be64 *addr = (const __be64 *)q->desc;
+
+                       dma_unmap_page(dev, be64_to_cpu(addr[0]),
+                                      ntohl(p->len[0]), DMA_TO_DEVICE);
+                       dma_unmap_page(dev, be64_to_cpu(addr[1]),
+                                      ntohl(p->len[1]), DMA_TO_DEVICE);
+                       p = (const struct ulptx_sge_pair *)&addr[2];
+               } else {
+                       const __be64 *addr = (const __be64 *)q->desc;
+
+                       dma_unmap_page(dev, be64_to_cpu(p->addr[0]),
+                                      ntohl(p->len[0]), DMA_TO_DEVICE);
+                       dma_unmap_page(dev, be64_to_cpu(addr[0]),
+                                      ntohl(p->len[1]), DMA_TO_DEVICE);
+                       p = (const struct ulptx_sge_pair *)&addr[1];
+               }
+       }
+       if (nfrags) {
+               __be64 addr;
+
+               if ((u8 *)p == (u8 *)q->stat)
+                       p = (const struct ulptx_sge_pair *)q->desc;
+               addr = (u8 *)p + 16 <= (u8 *)q->stat ? p->addr[0] :
+                                                      *(const __be64 *)q->desc;
+               dma_unmap_page(dev, be64_to_cpu(addr), ntohl(p->len[0]),
+                              DMA_TO_DEVICE);
+       }
+}
+
+/**
+ *     free_tx_desc - reclaims Tx descriptors and their buffers
+ *     @adapter: the adapter
+ *     @q: the Tx queue to reclaim descriptors from
+ *     @n: the number of descriptors to reclaim
+ *     @unmap: whether the buffers should be unmapped for DMA
+ *
+ *     Reclaims Tx descriptors from an SGE Tx queue and frees the associated
+ *     Tx buffers.  Called with the Tx queue lock held.
+ */
+static void free_tx_desc(struct adapter *adap, struct sge_txq *q,
+                        unsigned int n, bool unmap)
+{
+       struct tx_sw_desc *d;
+       unsigned int cidx = q->cidx;
+       struct device *dev = adap->pdev_dev;
+
+       d = &q->sdesc[cidx];
+       while (n--) {
+               if (d->skb) {                       /* an SGL is present */
+                       if (unmap)
+                               unmap_sgl(dev, d->skb, d->sgl, q);
+                       kfree_skb(d->skb);
+                       d->skb = NULL;
+               }
+               ++d;
+               if (++cidx == q->size) {
+                       cidx = 0;
+                       d = q->sdesc;
+               }
+       }
+       q->cidx = cidx;
+}
+
+/*
+ * Return the number of reclaimable descriptors in a Tx queue.
+ */
+static inline int reclaimable(const struct sge_txq *q)
+{
+       int hw_cidx = ntohs(q->stat->cidx);
+       hw_cidx -= q->cidx;
+       return hw_cidx < 0 ? hw_cidx + q->size : hw_cidx;
+}
+
+/**
+ *     reclaim_completed_tx - reclaims completed Tx descriptors
+ *     @adap: the adapter
+ *     @q: the Tx queue to reclaim completed descriptors from
+ *     @unmap: whether the buffers should be unmapped for DMA
+ *
+ *     Reclaims Tx descriptors that the SGE has indicated it has processed,
+ *     and frees the associated buffers if possible.  Called with the Tx
+ *     queue locked.
+ */
+static inline void reclaim_completed_tx(struct adapter *adap, struct sge_txq *q,
+                                       bool unmap)
+{
+       int avail = reclaimable(q);
+
+       if (avail) {
+               /*
+                * Limit the amount of clean up work we do at a time to keep
+                * the Tx lock hold time O(1).
+                */
+               if (avail > MAX_TX_RECLAIM)
+                       avail = MAX_TX_RECLAIM;
+
+               free_tx_desc(adap, q, avail, unmap);
+               q->in_use -= avail;
+       }
+}
+
+static inline int get_buf_size(const struct rx_sw_desc *d)
+{
+#if FL_PG_ORDER > 0
+       return (d->dma_addr & RX_LARGE_BUF) ? (PAGE_SIZE << FL_PG_ORDER) :
+                                             PAGE_SIZE;
+#else
+       return PAGE_SIZE;
+#endif
+}
+
+/**
+ *     free_rx_bufs - free the Rx buffers on an SGE free list
+ *     @adap: the adapter
+ *     @q: the SGE free list to free buffers from
+ *     @n: how many buffers to free
+ *
+ *     Release the next @n buffers on an SGE free-buffer Rx queue.   The
+ *     buffers must be made inaccessible to HW before calling this function.
+ */
+static void free_rx_bufs(struct adapter *adap, struct sge_fl *q, int n)
+{
+       while (n--) {
+               struct rx_sw_desc *d = &q->sdesc[q->cidx];
+
+               if (is_buf_mapped(d))
+                       dma_unmap_page(adap->pdev_dev, get_buf_addr(d),
+                                      get_buf_size(d), PCI_DMA_FROMDEVICE);
+               put_page(d->page);
+               d->page = NULL;
+               if (++q->cidx == q->size)
+                       q->cidx = 0;
+               q->avail--;
+       }
+}
+
+/**
+ *     unmap_rx_buf - unmap the current Rx buffer on an SGE free list
+ *     @adap: the adapter
+ *     @q: the SGE free list
+ *
+ *     Unmap the current buffer on an SGE free-buffer Rx queue.   The
+ *     buffer must be made inaccessible to HW before calling this function.
+ *
+ *     This is similar to @free_rx_bufs above but does not free the buffer.
+ *     Do note that the FL still loses any further access to the buffer.
+ */
+static void unmap_rx_buf(struct adapter *adap, struct sge_fl *q)
+{
+       struct rx_sw_desc *d = &q->sdesc[q->cidx];
+
+       if (is_buf_mapped(d))
+               dma_unmap_page(adap->pdev_dev, get_buf_addr(d),
+                              get_buf_size(d), PCI_DMA_FROMDEVICE);
+       d->page = NULL;
+       if (++q->cidx == q->size)
+               q->cidx = 0;
+       q->avail--;
+}
+
+static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
+{
+       if (q->pend_cred >= 8) {
+               wmb();
+               t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO |
+                            QID(q->cntxt_id) | PIDX(q->pend_cred / 8));
+               q->pend_cred &= 7;
+       }
+}
+
+static inline void set_rx_sw_desc(struct rx_sw_desc *sd, struct page *pg,
+                                 dma_addr_t mapping)
+{
+       sd->page = pg;
+       sd->dma_addr = mapping;      /* includes size low bits */
+}
+
+/**
+ *     refill_fl - refill an SGE Rx buffer ring
+ *     @adap: the adapter
+ *     @q: the ring to refill
+ *     @n: the number of new buffers to allocate
+ *     @gfp: the gfp flags for the allocations
+ *
+ *     (Re)populate an SGE free-buffer queue with up to @n new packet buffers,
+ *     allocated with the supplied gfp flags.  The caller must assure that
+ *     @n does not exceed the queue's capacity.  If afterwards the queue is
+ *     found critically low mark it as starving in the bitmap of starving FLs.
+ *
+ *     Returns the number of buffers allocated.
+ */
+static unsigned int refill_fl(struct adapter *adap, struct sge_fl *q, int n,
+                             gfp_t gfp)
+{
+       struct page *pg;
+       dma_addr_t mapping;
+       unsigned int cred = q->avail;
+       __be64 *d = &q->desc[q->pidx];
+       struct rx_sw_desc *sd = &q->sdesc[q->pidx];
+
+       gfp |= __GFP_NOWARN;         /* failures are expected */
+
+#if FL_PG_ORDER > 0
+       /*
+        * Prefer large buffers
+        */
+       while (n) {
+               pg = alloc_pages(gfp | __GFP_COMP, FL_PG_ORDER);
+               if (unlikely(!pg)) {
+                       q->large_alloc_failed++;
+                       break;       /* fall back to single pages */
+               }
+
+               mapping = dma_map_page(adap->pdev_dev, pg, 0,
+                                      PAGE_SIZE << FL_PG_ORDER,
+                                      PCI_DMA_FROMDEVICE);
+               if (unlikely(dma_mapping_error(adap->pdev_dev, mapping))) {
+                       __free_pages(pg, FL_PG_ORDER);
+                       goto out;   /* do not try small pages for this error */
+               }
+               mapping |= RX_LARGE_BUF;
+               *d++ = cpu_to_be64(mapping);
+
+               set_rx_sw_desc(sd, pg, mapping);
+               sd++;
+
+               q->avail++;
+               if (++q->pidx == q->size) {
+                       q->pidx = 0;
+                       sd = q->sdesc;
+                       d = q->desc;
+               }
+               n--;
+       }
+#endif
+
+       while (n--) {
+               pg = __netdev_alloc_page(adap->port[0], gfp);
+               if (unlikely(!pg)) {
+                       q->alloc_failed++;
+                       break;
+               }
+
+               mapping = dma_map_page(adap->pdev_dev, pg, 0, PAGE_SIZE,
+                                      PCI_DMA_FROMDEVICE);
+               if (unlikely(dma_mapping_error(adap->pdev_dev, mapping))) {
+                       netdev_free_page(adap->port[0], pg);
+                       goto out;
+               }
+               *d++ = cpu_to_be64(mapping);
+
+               set_rx_sw_desc(sd, pg, mapping);
+               sd++;
+
+               q->avail++;
+               if (++q->pidx == q->size) {
+                       q->pidx = 0;
+                       sd = q->sdesc;
+                       d = q->desc;
+               }
+       }
+
+out:   cred = q->avail - cred;
+       q->pend_cred += cred;
+       ring_fl_db(adap, q);
+
+       if (unlikely(fl_starving(q))) {
+               smp_wmb();
+               set_bit(q->cntxt_id, adap->sge.starving_fl);
+       }
+
+       return cred;
+}
+
+static inline void __refill_fl(struct adapter *adap, struct sge_fl *fl)
+{
+       refill_fl(adap, fl, min(MAX_RX_REFILL, fl_cap(fl) - fl->avail),
+                 GFP_ATOMIC);
+}
+
+/**
+ *     alloc_ring - allocate resources for an SGE descriptor ring
+ *     @dev: the PCI device's core device
+ *     @nelem: the number of descriptors
+ *     @elem_size: the size of each descriptor
+ *     @sw_size: the size of the SW state associated with each ring element
+ *     @phys: the physical address of the allocated ring
+ *     @metadata: address of the array holding the SW state for the ring
+ *     @stat_size: extra space in HW ring for status information
+ *
+ *     Allocates resources for an SGE descriptor ring, such as Tx queues,
+ *     free buffer lists, or response queues.  Each SGE ring requires
+ *     space for its HW descriptors plus, optionally, space for the SW state
+ *     associated with each HW entry (the metadata).  The function returns
+ *     three values: the virtual address for the HW ring (the return value
+ *     of the function), the bus address of the HW ring, and the address
+ *     of the SW ring.
+ */
+static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size,
+                       size_t sw_size, dma_addr_t *phys, void *metadata,
+                       size_t stat_size)
+{
+       size_t len = nelem * elem_size + stat_size;
+       void *s = NULL;
+       void *p = dma_alloc_coherent(dev, len, phys, GFP_KERNEL);
+
+       if (!p)
+               return NULL;
+       if (sw_size) {
+               s = kcalloc(nelem, sw_size, GFP_KERNEL);
+
+               if (!s) {
+                       dma_free_coherent(dev, len, p, *phys);
+                       return NULL;
+               }
+       }
+       if (metadata)
+               *(void **)metadata = s;
+       memset(p, 0, len);
+       return p;
+}
+
+/**
+ *     sgl_len - calculates the size of an SGL of the given capacity
+ *     @n: the number of SGL entries
+ *
+ *     Calculates the number of flits needed for a scatter/gather list that
+ *     can hold the given number of entries.
+ */
+static inline unsigned int sgl_len(unsigned int n)
+{
+       n--;
+       return (3 * n) / 2 + (n & 1) + 2;
+}
+
+/**
+ *     flits_to_desc - returns the num of Tx descriptors for the given flits
+ *     @n: the number of flits
+ *
+ *     Returns the number of Tx descriptors needed for the supplied number
+ *     of flits.
+ */
+static inline unsigned int flits_to_desc(unsigned int n)
+{
+       BUG_ON(n > SGE_MAX_WR_LEN / 8);
+       return DIV_ROUND_UP(n, 8);
+}
+
+/**
+ *     is_eth_imm - can an Ethernet packet be sent as immediate data?
+ *     @skb: the packet
+ *
+ *     Returns whether an Ethernet packet is small enough to fit as
+ *     immediate data.
+ */
+static inline int is_eth_imm(const struct sk_buff *skb)
+{
+       return skb->len <= MAX_IMM_TX_PKT_LEN - sizeof(struct cpl_tx_pkt);
+}
+
+/**
+ *     calc_tx_flits - calculate the number of flits for a packet Tx WR
+ *     @skb: the packet
+ *
+ *     Returns the number of flits needed for a Tx WR for the given Ethernet
+ *     packet, including the needed WR and CPL headers.
+ */
+static inline unsigned int calc_tx_flits(const struct sk_buff *skb)
+{
+       unsigned int flits;
+
+       if (is_eth_imm(skb))
+               return DIV_ROUND_UP(skb->len + sizeof(struct cpl_tx_pkt), 8);
+
+       flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4;
+       if (skb_shinfo(skb)->gso_size)
+               flits += 2;
+       return flits;
+}
+
+/**
+ *     calc_tx_descs - calculate the number of Tx descriptors for a packet
+ *     @skb: the packet
+ *
+ *     Returns the number of Tx descriptors needed for the given Ethernet
+ *     packet, including the needed WR and CPL headers.
+ */
+static inline unsigned int calc_tx_descs(const struct sk_buff *skb)
+{
+       return flits_to_desc(calc_tx_flits(skb));
+}
+
+/**
+ *     write_sgl - populate a scatter/gather list for a packet
+ *     @skb: the packet
+ *     @q: the Tx queue we are writing into
+ *     @sgl: starting location for writing the SGL
+ *     @end: points right after the end of the SGL
+ *     @start: start offset into skb main-body data to include in the SGL
+ *     @addr: the list of bus addresses for the SGL elements
+ *
+ *     Generates a gather list for the buffers that make up a packet.
+ *     The caller must provide adequate space for the SGL that will be written.
+ *     The SGL includes all of the packet's page fragments and the data in its
+ *     main body except for the first @start bytes.  @sgl must be 16-byte
+ *     aligned and within a Tx descriptor with available space.  @end points
+ *     right after the end of the SGL but does not account for any potential
+ *     wrap around, i.e., @end > @sgl.
+ */
+static void write_sgl(const struct sk_buff *skb, struct sge_txq *q,
+                     struct ulptx_sgl *sgl, u64 *end, unsigned int start,
+                     const dma_addr_t *addr)
+{
+       unsigned int i, len;
+       struct ulptx_sge_pair *to;
+       const struct skb_shared_info *si = skb_shinfo(skb);
+       unsigned int nfrags = si->nr_frags;
+       struct ulptx_sge_pair buf[MAX_SKB_FRAGS / 2 + 1];
+
+       len = skb_headlen(skb) - start;
+       if (likely(len)) {
+               sgl->len0 = htonl(len);
+               sgl->addr0 = cpu_to_be64(addr[0] + start);
+               nfrags++;
+       } else {
+               sgl->len0 = htonl(si->frags[0].size);
+               sgl->addr0 = cpu_to_be64(addr[1]);
+       }
+
+       sgl->cmd_nsge = htonl(ULPTX_CMD(ULP_TX_SC_DSGL) | ULPTX_NSGE(nfrags));
+       if (likely(--nfrags == 0))
+               return;
+       /*
+        * Most of the complexity below deals with the possibility we hit the
+        * end of the queue in the middle of writing the SGL.  For this case
+        * only we create the SGL in a temporary buffer and then copy it.
+        */
+       to = (u8 *)end > (u8 *)q->stat ? buf : sgl->sge;
+
+       for (i = (nfrags != si->nr_frags); nfrags >= 2; nfrags -= 2, to++) {
+               to->len[0] = cpu_to_be32(si->frags[i].size);
+               to->len[1] = cpu_to_be32(si->frags[++i].size);
+               to->addr[0] = cpu_to_be64(addr[i]);
+               to->addr[1] = cpu_to_be64(addr[++i]);
+       }
+       if (nfrags) {
+               to->len[0] = cpu_to_be32(si->frags[i].size);
+               to->len[1] = cpu_to_be32(0);
+               to->addr[0] = cpu_to_be64(addr[i + 1]);
+       }
+       if (unlikely((u8 *)end > (u8 *)q->stat)) {
+               unsigned int part0 = (u8 *)q->stat - (u8 *)sgl->sge, part1;
+
+               if (likely(part0))
+                       memcpy(sgl->sge, buf, part0);
+               part1 = (u8 *)end - (u8 *)q->stat;
+               memcpy(q->desc, (u8 *)buf + part0, part1);
+               end = (void *)q->desc + part1;
+       }
+       if ((uintptr_t)end & 8)           /* 0-pad to multiple of 16 */
+               *(u64 *)end = 0;
+}
+
+/**
+ *     ring_tx_db - check and potentially ring a Tx queue's doorbell
+ *     @adap: the adapter
+ *     @q: the Tx queue
+ *     @n: number of new descriptors to give to HW
+ *
+ *     Ring the doorbel for a Tx queue.
+ */
+static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n)
+{
+       wmb();            /* write descriptors before telling HW */
+       t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
+                    QID(q->cntxt_id) | PIDX(n));
+}
+
+/**
+ *     inline_tx_skb - inline a packet's data into Tx descriptors
+ *     @skb: the packet
+ *     @q: the Tx queue where the packet will be inlined
+ *     @pos: starting position in the Tx queue where to inline the packet
+ *
+ *     Inline a packet's contents directly into Tx descriptors, starting at
+ *     the given position within the Tx DMA ring.
+ *     Most of the complexity of this operation is dealing with wrap arounds
+ *     in the middle of the packet we want to inline.
+ */
+static void inline_tx_skb(const struct sk_buff *skb, const struct sge_txq *q,
+                         void *pos)
+{
+       u64 *p;
+       int left = (void *)q->stat - pos;
+
+       if (likely(skb->len <= left)) {
+               if (likely(!skb->data_len))
+                       skb_copy_from_linear_data(skb, pos, skb->len);
+               else
+                       skb_copy_bits(skb, 0, pos, skb->len);
+               pos += skb->len;
+       } else {
+               skb_copy_bits(skb, 0, pos, left);
+               skb_copy_bits(skb, left, q->desc, skb->len - left);
+               pos = (void *)q->desc + (skb->len - left);
+       }
+
+       /* 0-pad to multiple of 16 */
+       p = PTR_ALIGN(pos, 8);
+       if ((uintptr_t)p & 8)
+               *p = 0;
+}
+
+/*
+ * Figure out what HW csum a packet wants and return the appropriate control
+ * bits.
+ */
+static u64 hwcsum(const struct sk_buff *skb)
+{
+       int csum_type;
+       const struct iphdr *iph = ip_hdr(skb);
+
+       if (iph->version == 4) {
+               if (iph->protocol == IPPROTO_TCP)
+                       csum_type = TX_CSUM_TCPIP;
+               else if (iph->protocol == IPPROTO_UDP)
+                       csum_type = TX_CSUM_UDPIP;
+               else {
+nocsum:                        /*
+                        * unknown protocol, disable HW csum
+                        * and hope a bad packet is detected
+                        */
+                       return TXPKT_L4CSUM_DIS;
+               }
+       } else {
+               /*
+                * this doesn't work with extension headers
+                */
+               const struct ipv6hdr *ip6h = (const struct ipv6hdr *)iph;
+
+               if (ip6h->nexthdr == IPPROTO_TCP)
+                       csum_type = TX_CSUM_TCPIP6;
+               else if (ip6h->nexthdr == IPPROTO_UDP)
+                       csum_type = TX_CSUM_UDPIP6;
+               else
+                       goto nocsum;
+       }
+
+       if (likely(csum_type >= TX_CSUM_TCPIP))
+               return TXPKT_CSUM_TYPE(csum_type) |
+                       TXPKT_IPHDR_LEN(skb_network_header_len(skb)) |
+                       TXPKT_ETHHDR_LEN(skb_network_offset(skb) - ETH_HLEN);
+       else {
+               int start = skb_transport_offset(skb);
+
+               return TXPKT_CSUM_TYPE(csum_type) | TXPKT_CSUM_START(start) |
+                       TXPKT_CSUM_LOC(start + skb->csum_offset);
+       }
+}
+
+static void eth_txq_stop(struct sge_eth_txq *q)
+{
+       netif_tx_stop_queue(q->txq);
+       q->q.stops++;
+}
+
+static inline void txq_advance(struct sge_txq *q, unsigned int n)
+{
+       q->in_use += n;
+       q->pidx += n;
+       if (q->pidx >= q->size)
+               q->pidx -= q->size;
+}
+
+/**
+ *     t4_eth_xmit - add a packet to an Ethernet Tx queue
+ *     @skb: the packet
+ *     @dev: the egress net device
+ *
+ *     Add a packet to an SGE Ethernet Tx queue.  Runs with softirqs disabled.
+ */
+netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+       u32 wr_mid;
+       u64 cntrl, *end;
+       int qidx, credits;
+       unsigned int flits, ndesc;
+       struct adapter *adap;
+       struct sge_eth_txq *q;
+       const struct port_info *pi;
+       struct fw_eth_tx_pkt_wr *wr;
+       struct cpl_tx_pkt_core *cpl;
+       const struct skb_shared_info *ssi;
+       dma_addr_t addr[MAX_SKB_FRAGS + 1];
+
+       /*
+        * The chip min packet length is 10 octets but play safe and reject
+        * anything shorter than an Ethernet header.
+        */
+       if (unlikely(skb->len < ETH_HLEN)) {
+out_free:      dev_kfree_skb(skb);
+               return NETDEV_TX_OK;
+       }
+
+       pi = netdev_priv(dev);
+       adap = pi->adapter;
+       qidx = skb_get_queue_mapping(skb);
+       q = &adap->sge.ethtxq[qidx + pi->first_qset];
+
+       reclaim_completed_tx(adap, &q->q, true);
+
+       flits = calc_tx_flits(skb);
+       ndesc = flits_to_desc(flits);
+       credits = txq_avail(&q->q) - ndesc;
+
+       if (unlikely(credits < 0)) {
+               eth_txq_stop(q);
+               dev_err(adap->pdev_dev,
+                       "%s: Tx ring %u full while queue awake!\n",
+                       dev->name, qidx);
+               return NETDEV_TX_BUSY;
+       }
+
+       if (!is_eth_imm(skb) &&
+           unlikely(map_skb(adap->pdev_dev, skb, addr) < 0)) {
+               q->mapping_err++;
+               goto out_free;
+       }
+
+       wr_mid = FW_WR_LEN16(DIV_ROUND_UP(flits, 2));
+       if (unlikely(credits < ETHTXQ_STOP_THRES)) {
+               eth_txq_stop(q);
+               wr_mid |= FW_WR_EQUEQ | FW_WR_EQUIQ;
+       }
+
+       wr = (void *)&q->q.desc[q->q.pidx];
+       wr->equiq_to_len16 = htonl(wr_mid);
+       wr->r3 = cpu_to_be64(0);
+       end = (u64 *)wr + flits;
+
+       ssi = skb_shinfo(skb);
+       if (ssi->gso_size) {
+               struct cpl_tx_pkt_lso *lso = (void *)wr;
+               bool v6 = (ssi->gso_type & SKB_GSO_TCPV6) != 0;
+               int l3hdr_len = skb_network_header_len(skb);
+               int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
+
+               wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
+                                      FW_WR_IMMDLEN(sizeof(*lso)));
+               lso->lso_ctrl = htonl(LSO_OPCODE(CPL_TX_PKT_LSO) |
+                                     LSO_FIRST_SLICE | LSO_LAST_SLICE |
+                                     LSO_IPV6(v6) |
+                                     LSO_ETHHDR_LEN(eth_xtra_len / 4) |
+                                     LSO_IPHDR_LEN(l3hdr_len / 4) |
+                                     LSO_TCPHDR_LEN(tcp_hdr(skb)->doff));
+               lso->ipid_ofst = htons(0);
+               lso->mss = htons(ssi->gso_size);
+               lso->seqno_offset = htonl(0);
+               lso->len = htonl(skb->len);
+               cpl = (void *)(lso + 1);
+               cntrl = TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
+                       TXPKT_IPHDR_LEN(l3hdr_len) |
+                       TXPKT_ETHHDR_LEN(eth_xtra_len);
+               q->tso++;
+               q->tx_cso += ssi->gso_segs;
+       } else {
+               int len;
+
+               len = is_eth_imm(skb) ? skb->len + sizeof(*cpl) : sizeof(*cpl);
+               wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
+                                      FW_WR_IMMDLEN(len));
+               cpl = (void *)(wr + 1);
+               if (skb->ip_summed == CHECKSUM_PARTIAL) {
+                       cntrl = hwcsum(skb) | TXPKT_IPCSUM_DIS;
+                       q->tx_cso++;
+               } else
+                       cntrl = TXPKT_L4CSUM_DIS | TXPKT_IPCSUM_DIS;
+       }
+
+       if (vlan_tx_tag_present(skb)) {
+               q->vlan_ins++;
+               cntrl |= TXPKT_VLAN_VLD | TXPKT_VLAN(vlan_tx_tag_get(skb));
+       }
+
+       cpl->ctrl0 = htonl(TXPKT_OPCODE(CPL_TX_PKT_XT) |
+                          TXPKT_INTF(pi->tx_chan) | TXPKT_PF(0));
+       cpl->pack = htons(0);
+       cpl->len = htons(skb->len);
+       cpl->ctrl1 = cpu_to_be64(cntrl);
+
+       if (is_eth_imm(skb)) {
+               inline_tx_skb(skb, &q->q, cpl + 1);
+               dev_kfree_skb(skb);
+       } else {
+               int last_desc;
+
+               write_sgl(skb, &q->q, (struct ulptx_sgl *)(cpl + 1), end, 0,
+                         addr);
+               skb_orphan(skb);
+
+               last_desc = q->q.pidx + ndesc - 1;
+               if (last_desc >= q->q.size)
+                       last_desc -= q->q.size;
+               q->q.sdesc[last_desc].skb = skb;
+               q->q.sdesc[last_desc].sgl = (struct ulptx_sgl *)(cpl + 1);
+       }
+
+       txq_advance(&q->q, ndesc);
+
+       ring_tx_db(adap, &q->q, ndesc);
+       return NETDEV_TX_OK;
+}
+
+/**
+ *     reclaim_completed_tx_imm - reclaim completed control-queue Tx descs
+ *     @q: the SGE control Tx queue
+ *
+ *     This is a variant of reclaim_completed_tx() that is used for Tx queues
+ *     that send only immediate data (presently just the control queues) and
+ *     thus do not have any sk_buffs to release.
+ */
+static inline void reclaim_completed_tx_imm(struct sge_txq *q)
+{
+       int hw_cidx = ntohs(q->stat->cidx);
+       int reclaim = hw_cidx - q->cidx;
+
+       if (reclaim < 0)
+               reclaim += q->size;
+
+       q->in_use -= reclaim;
+       q->cidx = hw_cidx;
+}
+
+/**
+ *     is_imm - check whether a packet can be sent as immediate data
+ *     @skb: the packet
+ *
+ *     Returns true if a packet can be sent as a WR with immediate data.
+ */
+static inline int is_imm(const struct sk_buff *skb)
+{
+       return skb->len <= MAX_CTRL_WR_LEN;
+}
+
+/**
+ *     ctrlq_check_stop - check if a control queue is full and should stop
+ *     @q: the queue
+ *     @wr: most recent WR written to the queue
+ *
+ *     Check if a control queue has become full and should be stopped.
+ *     We clean up control queue descriptors very lazily, only when we are out.
+ *     If the queue is still full after reclaiming any completed descriptors
+ *     we suspend it and have the last WR wake it up.
+ */
+static void ctrlq_check_stop(struct sge_ctrl_txq *q, struct fw_wr_hdr *wr)
+{
+       reclaim_completed_tx_imm(&q->q);
+       if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES)) {
+               wr->lo |= htonl(FW_WR_EQUEQ | FW_WR_EQUIQ);
+               q->q.stops++;
+               q->full = 1;
+       }
+}
+
+/**
+ *     ctrl_xmit - send a packet through an SGE control Tx queue
+ *     @q: the control queue
+ *     @skb: the packet
+ *
+ *     Send a packet through an SGE control Tx queue.  Packets sent through
+ *     a control queue must fit entirely as immediate data.
+ */
+static int ctrl_xmit(struct sge_ctrl_txq *q, struct sk_buff *skb)
+{
+       unsigned int ndesc;
+       struct fw_wr_hdr *wr;
+
+       if (unlikely(!is_imm(skb))) {
+               WARN_ON(1);
+               dev_kfree_skb(skb);
+               return NET_XMIT_DROP;
+       }
+
+       ndesc = DIV_ROUND_UP(skb->len, sizeof(struct tx_desc));
+       spin_lock(&q->sendq.lock);
+
+       if (unlikely(q->full)) {
+               skb->priority = ndesc;                  /* save for restart */
+               __skb_queue_tail(&q->sendq, skb);
+               spin_unlock(&q->sendq.lock);
+               return NET_XMIT_CN;
+       }
+
+       wr = (struct fw_wr_hdr *)&q->q.desc[q->q.pidx];
+       inline_tx_skb(skb, &q->q, wr);
+
+       txq_advance(&q->q, ndesc);
+       if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES))
+               ctrlq_check_stop(q, wr);
+
+       ring_tx_db(q->adap, &q->q, ndesc);
+       spin_unlock(&q->sendq.lock);
+
+       kfree_skb(skb);
+       return NET_XMIT_SUCCESS;
+}
+
+/**
+ *     restart_ctrlq - restart a suspended control queue
+ *     @data: the control queue to restart
+ *
+ *     Resumes transmission on a suspended Tx control queue.
+ */
+static void restart_ctrlq(unsigned long data)
+{
+       struct sk_buff *skb;
+       unsigned int written = 0;
+       struct sge_ctrl_txq *q = (struct sge_ctrl_txq *)data;
+
+       spin_lock(&q->sendq.lock);
+       reclaim_completed_tx_imm(&q->q);
+       BUG_ON(txq_avail(&q->q) < TXQ_STOP_THRES);  /* q should be empty */
+
+       while ((skb = __skb_dequeue(&q->sendq)) != NULL) {
+               struct fw_wr_hdr *wr;
+               unsigned int ndesc = skb->priority;     /* previously saved */
+
+               /*
+                * Write descriptors and free skbs outside the lock to limit
+                * wait times.  q->full is still set so new skbs will be queued.
+                */
+               spin_unlock(&q->sendq.lock);
+
+               wr = (struct fw_wr_hdr *)&q->q.desc[q->q.pidx];
+               inline_tx_skb(skb, &q->q, wr);
+               kfree_skb(skb);
+
+               written += ndesc;
+               txq_advance(&q->q, ndesc);
+               if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES)) {
+                       unsigned long old = q->q.stops;
+
+                       ctrlq_check_stop(q, wr);
+                       if (q->q.stops != old) {          /* suspended anew */
+                               spin_lock(&q->sendq.lock);
+                               goto ringdb;
+                       }
+               }
+               if (written > 16) {
+                       ring_tx_db(q->adap, &q->q, written);
+                       written = 0;
+               }
+               spin_lock(&q->sendq.lock);
+       }
+       q->full = 0;
+ringdb: if (written)
+               ring_tx_db(q->adap, &q->q, written);
+       spin_unlock(&q->sendq.lock);
+}
+
+/**
+ *     t4_mgmt_tx - send a management message
+ *     @adap: the adapter
+ *     @skb: the packet containing the management message
+ *
+ *     Send a management message through control queue 0.
+ */
+int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
+{
+       int ret;
+
+       local_bh_disable();
+       ret = ctrl_xmit(&adap->sge.ctrlq[0], skb);
+       local_bh_enable();
+       return ret;
+}
+
+/**
+ *     is_ofld_imm - check whether a packet can be sent as immediate data
+ *     @skb: the packet
+ *
+ *     Returns true if a packet can be sent as an offload WR with immediate
+ *     data.  We currently use the same limit as for Ethernet packets.
+ */
+static inline int is_ofld_imm(const struct sk_buff *skb)
+{
+       return skb->len <= MAX_IMM_TX_PKT_LEN;
+}
+
+/**
+ *     calc_tx_flits_ofld - calculate # of flits for an offload packet
+ *     @skb: the packet
+ *
+ *     Returns the number of flits needed for the given offload packet.
+ *     These packets are already fully constructed and no additional headers
+ *     will be added.
+ */
+static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
+{
+       unsigned int flits, cnt;
+
+       if (is_ofld_imm(skb))
+               return DIV_ROUND_UP(skb->len, 8);
+
+       flits = skb_transport_offset(skb) / 8U;   /* headers */
+       cnt = skb_shinfo(skb)->nr_frags;
+       if (skb->tail != skb->transport_header)
+               cnt++;
+       return flits + sgl_len(cnt);
+}
+
+/**
+ *     txq_stop_maperr - stop a Tx queue due to I/O MMU exhaustion
+ *     @adap: the adapter
+ *     @q: the queue to stop
+ *
+ *     Mark a Tx queue stopped due to I/O MMU exhaustion and resulting
+ *     inability to map packets.  A periodic timer attempts to restart
+ *     queues so marked.
+ */
+static void txq_stop_maperr(struct sge_ofld_txq *q)
+{
+       q->mapping_err++;
+       q->q.stops++;
+       set_bit(q->q.cntxt_id, q->adap->sge.txq_maperr);
+}
+
+/**
+ *     ofldtxq_stop - stop an offload Tx queue that has become full
+ *     @q: the queue to stop
+ *     @skb: the packet causing the queue to become full
+ *
+ *     Stops an offload Tx queue that has become full and modifies the packet
+ *     being written to request a wakeup.
+ */
+static void ofldtxq_stop(struct sge_ofld_txq *q, struct sk_buff *skb)
+{
+       struct fw_wr_hdr *wr = (struct fw_wr_hdr *)skb->data;
+
+       wr->lo |= htonl(FW_WR_EQUEQ | FW_WR_EQUIQ);
+       q->q.stops++;
+       q->full = 1;
+}
+
+/**
+ *     service_ofldq - restart a suspended offload queue
+ *     @q: the offload queue
+ *
+ *     Services an offload Tx queue by moving packets from its packet queue
+ *     to the HW Tx ring.  The function starts and ends with the queue locked.
+ */
+static void service_ofldq(struct sge_ofld_txq *q)
+{
+       u64 *pos;
+       int credits;
+       struct sk_buff *skb;
+       unsigned int written = 0;
+       unsigned int flits, ndesc;
+
+       while ((skb = skb_peek(&q->sendq)) != NULL && !q->full) {
+               /*
+                * We drop the lock but leave skb on sendq, thus retaining
+                * exclusive access to the state of the queue.
+                */
+               spin_unlock(&q->sendq.lock);
+
+               reclaim_completed_tx(q->adap, &q->q, false);
+
+               flits = skb->priority;                /* previously saved */
+               ndesc = flits_to_desc(flits);
+               credits = txq_avail(&q->q) - ndesc;
+               BUG_ON(credits < 0);
+               if (unlikely(credits < TXQ_STOP_THRES))
+                       ofldtxq_stop(q, skb);
+
+               pos = (u64 *)&q->q.desc[q->q.pidx];
+               if (is_ofld_imm(skb))
+                       inline_tx_skb(skb, &q->q, pos);
+               else if (map_skb(q->adap->pdev_dev, skb,
+                                (dma_addr_t *)skb->head)) {
+                       txq_stop_maperr(q);
+                       spin_lock(&q->sendq.lock);
+                       break;
+               } else {
+                       int last_desc, hdr_len = skb_transport_offset(skb);
+
+                       memcpy(pos, skb->data, hdr_len);
+                       write_sgl(skb, &q->q, (void *)pos + hdr_len,
+                                 pos + flits, hdr_len,
+                                 (dma_addr_t *)skb->head);
+#ifdef CONFIG_NEED_DMA_MAP_STATE
+                       skb->dev = q->adap->port[0];
+                       skb->destructor = deferred_unmap_destructor;
+#endif
+                       last_desc = q->q.pidx + ndesc - 1;
+                       if (last_desc >= q->q.size)
+                               last_desc -= q->q.size;
+                       q->q.sdesc[last_desc].skb = skb;
+               }
+
+               txq_advance(&q->q, ndesc);
+               written += ndesc;
+               if (unlikely(written > 32)) {
+                       ring_tx_db(q->adap, &q->q, written);
+                       written = 0;
+               }
+
+               spin_lock(&q->sendq.lock);
+               __skb_unlink(skb, &q->sendq);
+               if (is_ofld_imm(skb))
+                       kfree_skb(skb);
+       }
+       if (likely(written))
+               ring_tx_db(q->adap, &q->q, written);
+}
+
+/**
+ *     ofld_xmit - send a packet through an offload queue
+ *     @q: the Tx offload queue
+ *     @skb: the packet
+ *
+ *     Send an offload packet through an SGE offload queue.
+ */
+static int ofld_xmit(struct sge_ofld_txq *q, struct sk_buff *skb)
+{
+       skb->priority = calc_tx_flits_ofld(skb);       /* save for restart */
+       spin_lock(&q->sendq.lock);
+       __skb_queue_tail(&q->sendq, skb);
+       if (q->sendq.qlen == 1)
+               service_ofldq(q);
+       spin_unlock(&q->sendq.lock);
+       return NET_XMIT_SUCCESS;
+}
+
+/**
+ *     restart_ofldq - restart a suspended offload queue
+ *     @data: the offload queue to restart
+ *
+ *     Resumes transmission on a suspended Tx offload queue.
+ */
+static void restart_ofldq(unsigned long data)
+{
+       struct sge_ofld_txq *q = (struct sge_ofld_txq *)data;
+
+       spin_lock(&q->sendq.lock);
+       q->full = 0;            /* the queue actually is completely empty now */
+       service_ofldq(q);
+       spin_unlock(&q->sendq.lock);
+}
+
+/**
+ *     skb_txq - return the Tx queue an offload packet should use
+ *     @skb: the packet
+ *
+ *     Returns the Tx queue an offload packet should use as indicated by bits
+ *     1-15 in the packet's queue_mapping.
+ */
+static inline unsigned int skb_txq(const struct sk_buff *skb)
+{
+       return skb->queue_mapping >> 1;
+}
+
+/**
+ *     is_ctrl_pkt - return whether an offload packet is a control packet
+ *     @skb: the packet
+ *
+ *     Returns whether an offload packet should use an OFLD or a CTRL
+ *     Tx queue as indicated by bit 0 in the packet's queue_mapping.
+ */
+static inline unsigned int is_ctrl_pkt(const struct sk_buff *skb)
+{
+       return skb->queue_mapping & 1;
+}
+
+static inline int ofld_send(struct adapter *adap, struct sk_buff *skb)
+{
+       unsigned int idx = skb_txq(skb);
+
+       if (unlikely(is_ctrl_pkt(skb)))
+               return ctrl_xmit(&adap->sge.ctrlq[idx], skb);
+       return ofld_xmit(&adap->sge.ofldtxq[idx], skb);
+}
+
+/**
+ *     t4_ofld_send - send an offload packet
+ *     @adap: the adapter
+ *     @skb: the packet
+ *
+ *     Sends an offload packet.  We use the packet queue_mapping to select the
+ *     appropriate Tx queue as follows: bit 0 indicates whether the packet
+ *     should be sent as regular or control, bits 1-15 select the queue.
+ */
+int t4_ofld_send(struct adapter *adap, struct sk_buff *skb)
+{
+       int ret;
+
+       local_bh_disable();
+       ret = ofld_send(adap, skb);
+       local_bh_enable();
+       return ret;
+}
+
+/**
+ *     cxgb4_ofld_send - send an offload packet
+ *     @dev: the net device
+ *     @skb: the packet
+ *
+ *     Sends an offload packet.  This is an exported version of @t4_ofld_send,
+ *     intended for ULDs.
+ */
+int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb)
+{
+       return t4_ofld_send(netdev2adap(dev), skb);
+}
+EXPORT_SYMBOL(cxgb4_ofld_send);
+
+static inline void copy_frags(struct skb_shared_info *ssi,
+                             const struct pkt_gl *gl, unsigned int offset)
+{
+       unsigned int n;
+
+       /* usually there's just one frag */
+       ssi->frags[0].page = gl->frags[0].page;
+       ssi->frags[0].page_offset = gl->frags[0].page_offset + offset;
+       ssi->frags[0].size = gl->frags[0].size - offset;
+       ssi->nr_frags = gl->nfrags;
+       n = gl->nfrags - 1;
+       if (n)
+               memcpy(&ssi->frags[1], &gl->frags[1], n * sizeof(skb_frag_t));
+
+       /* get a reference to the last page, we don't own it */
+       get_page(gl->frags[n].page);
+}
+
+/**
+ *     cxgb4_pktgl_to_skb - build an sk_buff from a packet gather list
+ *     @gl: the gather list
+ *     @skb_len: size of sk_buff main body if it carries fragments
+ *     @pull_len: amount of data to move to the sk_buff's main body
+ *
+ *     Builds an sk_buff from the given packet gather list.  Returns the
+ *     sk_buff or %NULL if sk_buff allocation failed.
+ */
+struct sk_buff *cxgb4_pktgl_to_skb(const struct pkt_gl *gl,
+                                  unsigned int skb_len, unsigned int pull_len)
+{
+       struct sk_buff *skb;
+
+       /*
+        * Below we rely on RX_COPY_THRES being less than the smallest Rx buffer
+        * size, which is expected since buffers are at least PAGE_SIZEd.
+        * In this case packets up to RX_COPY_THRES have only one fragment.
+        */
+       if (gl->tot_len <= RX_COPY_THRES) {
+               skb = dev_alloc_skb(gl->tot_len);
+               if (unlikely(!skb))
+                       goto out;
+               __skb_put(skb, gl->tot_len);
+               skb_copy_to_linear_data(skb, gl->va, gl->tot_len);
+       } else {
+               skb = dev_alloc_skb(skb_len);
+               if (unlikely(!skb))
+                       goto out;
+               __skb_put(skb, pull_len);
+               skb_copy_to_linear_data(skb, gl->va, pull_len);
+
+               copy_frags(skb_shinfo(skb), gl, pull_len);
+               skb->len = gl->tot_len;
+               skb->data_len = skb->len - pull_len;
+               skb->truesize += skb->data_len;
+       }
+out:   return skb;
+}
+EXPORT_SYMBOL(cxgb4_pktgl_to_skb);
+
+/**
+ *     t4_pktgl_free - free a packet gather list
+ *     @gl: the gather list
+ *
+ *     Releases the pages of a packet gather list.  We do not own the last
+ *     page on the list and do not free it.
+ */
+void t4_pktgl_free(const struct pkt_gl *gl)
+{
+       int n;
+       const skb_frag_t *p;
+
+       for (p = gl->frags, n = gl->nfrags - 1; n--; p++)
+               put_page(p->page);
+}
+
+/*
+ * Process an MPS trace packet.  Give it an unused protocol number so it won't
+ * be delivered to anyone and send it to the stack for capture.
+ */
+static noinline int handle_trace_pkt(struct adapter *adap,
+                                    const struct pkt_gl *gl)
+{
+       struct sk_buff *skb;
+       struct cpl_trace_pkt *p;
+
+       skb = cxgb4_pktgl_to_skb(gl, RX_PULL_LEN, RX_PULL_LEN);
+       if (unlikely(!skb)) {
+               t4_pktgl_free(gl);
+               return 0;
+       }
+
+       p = (struct cpl_trace_pkt *)skb->data;
+       __skb_pull(skb, sizeof(*p));
+       skb_reset_mac_header(skb);
+       skb->protocol = htons(0xffff);
+       skb->dev = adap->port[0];
+       netif_receive_skb(skb);
+       return 0;
+}
+
+static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
+                  const struct cpl_rx_pkt *pkt)
+{
+       int ret;
+       struct sk_buff *skb;
+
+       skb = napi_get_frags(&rxq->rspq.napi);
+       if (unlikely(!skb)) {
+               t4_pktgl_free(gl);
+               rxq->stats.rx_drops++;
+               return;
+       }
+
+       copy_frags(skb_shinfo(skb), gl, RX_PKT_PAD);
+       skb->len = gl->tot_len - RX_PKT_PAD;
+       skb->data_len = skb->len;
+       skb->truesize += skb->data_len;
+       skb->ip_summed = CHECKSUM_UNNECESSARY;
+       skb_record_rx_queue(skb, rxq->rspq.idx);
+
+       if (unlikely(pkt->vlan_ex)) {
+               struct port_info *pi = netdev_priv(rxq->rspq.netdev);
+               struct vlan_group *grp = pi->vlan_grp;
+
+               rxq->stats.vlan_ex++;
+               if (likely(grp)) {
+                       ret = vlan_gro_frags(&rxq->rspq.napi, grp,
+                                            ntohs(pkt->vlan));
+                       goto stats;
+               }
+       }
+       ret = napi_gro_frags(&rxq->rspq.napi);
+stats: if (ret == GRO_HELD)
+               rxq->stats.lro_pkts++;
+       else if (ret == GRO_MERGED || ret == GRO_MERGED_FREE)
+               rxq->stats.lro_merged++;
+       rxq->stats.pkts++;
+       rxq->stats.rx_cso++;
+}
+
+/**
+ *     t4_ethrx_handler - process an ingress ethernet packet
+ *     @q: the response queue that received the packet
+ *     @rsp: the response queue descriptor holding the RX_PKT message
+ *     @si: the gather list of packet fragments
+ *
+ *     Process an ingress ethernet packet and deliver it to the stack.
+ */
+int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
+                    const struct pkt_gl *si)
+{
+       bool csum_ok;
+       struct sk_buff *skb;
+       struct port_info *pi;
+       const struct cpl_rx_pkt *pkt;
+       struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq);
+
+       if (unlikely(*(u8 *)rsp == CPL_TRACE_PKT))
+               return handle_trace_pkt(q->adap, si);
+
+       pkt = (void *)&rsp[1];
+       csum_ok = pkt->csum_calc && !pkt->err_vec;
+       if ((pkt->l2info & htonl(RXF_TCP)) &&
+           (q->netdev->features & NETIF_F_GRO) && csum_ok && !pkt->ip_frag) {
+               do_gro(rxq, si, pkt);
+               return 0;
+       }
+
+       skb = cxgb4_pktgl_to_skb(si, RX_PKT_SKB_LEN, RX_PULL_LEN);
+       if (unlikely(!skb)) {
+               t4_pktgl_free(si);
+               rxq->stats.rx_drops++;
+               return 0;
+       }
+
+       __skb_pull(skb, RX_PKT_PAD);      /* remove ethernet header padding */
+       skb->protocol = eth_type_trans(skb, q->netdev);
+       skb_record_rx_queue(skb, q->idx);
+       pi = netdev_priv(skb->dev);
+       rxq->stats.pkts++;
+
+       if (csum_ok && (pi->rx_offload & RX_CSO) &&
+           (pkt->l2info & htonl(RXF_UDP | RXF_TCP))) {
+               if (!pkt->ip_frag)
+                       skb->ip_summed = CHECKSUM_UNNECESSARY;
+               else {
+                       __sum16 c = (__force __sum16)pkt->csum;
+                       skb->csum = csum_unfold(c);
+                       skb->ip_summed = CHECKSUM_COMPLETE;
+               }
+               rxq->stats.rx_cso++;
+       } else
+               skb->ip_summed = CHECKSUM_NONE;
+
+       if (unlikely(pkt->vlan_ex)) {
+               struct vlan_group *grp = pi->vlan_grp;
+
+               rxq->stats.vlan_ex++;
+               if (likely(grp))
+                       vlan_hwaccel_receive_skb(skb, grp, ntohs(pkt->vlan));
+               else
+                       dev_kfree_skb_any(skb);
+       } else
+               netif_receive_skb(skb);
+
+       return 0;
+}
+
+/**
+ *     restore_rx_bufs - put back a packet's Rx buffers
+ *     @si: the packet gather list
+ *     @q: the SGE free list
+ *     @frags: number of FL buffers to restore
+ *
+ *     Puts back on an FL the Rx buffers associated with @si.  The buffers
+ *     have already been unmapped and are left unmapped, we mark them so to
+ *     prevent further unmapping attempts.
+ *
+ *     This function undoes a series of @unmap_rx_buf calls when we find out
+ *     that the current packet can't be processed right away afterall and we
+ *     need to come back to it later.  This is a very rare event and there's
+ *     no effort to make this particularly efficient.
+ */
+static void restore_rx_bufs(const struct pkt_gl *si, struct sge_fl *q,
+                           int frags)
+{
+       struct rx_sw_desc *d;
+
+       while (frags--) {
+               if (q->cidx == 0)
+                       q->cidx = q->size - 1;
+               else
+                       q->cidx--;
+               d = &q->sdesc[q->cidx];
+               d->page = si->frags[frags].page;
+               d->dma_addr |= RX_UNMAPPED_BUF;
+               q->avail++;
+       }
+}
+
+/**
+ *     is_new_response - check if a response is newly written
+ *     @r: the response descriptor
+ *     @q: the response queue
+ *
+ *     Returns true if a response descriptor contains a yet unprocessed
+ *     response.
+ */
+static inline bool is_new_response(const struct rsp_ctrl *r,
+                                  const struct sge_rspq *q)
+{
+       return RSPD_GEN(r->type_gen) == q->gen;
+}
+
+/**
+ *     rspq_next - advance to the next entry in a response queue
+ *     @q: the queue
+ *
+ *     Updates the state of a response queue to advance it to the next entry.
+ */
+static inline void rspq_next(struct sge_rspq *q)
+{
+       q->cur_desc = (void *)q->cur_desc + q->iqe_len;
+       if (unlikely(++q->cidx == q->size)) {
+               q->cidx = 0;
+               q->gen ^= 1;
+               q->cur_desc = q->desc;
+       }
+}
+
+/**
+ *     process_responses - process responses from an SGE response queue
+ *     @q: the ingress queue to process
+ *     @budget: how many responses can be processed in this round
+ *
+ *     Process responses from an SGE response queue up to the supplied budget.
+ *     Responses include received packets as well as control messages from FW
+ *     or HW.
+ *
+ *     Additionally choose the interrupt holdoff time for the next interrupt
+ *     on this queue.  If the system is under memory shortage use a fairly
+ *     long delay to help recovery.
+ */
+static int process_responses(struct sge_rspq *q, int budget)
+{
+       int ret, rsp_type;
+       int budget_left = budget;
+       const struct rsp_ctrl *rc;
+       struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq);
+
+       while (likely(budget_left)) {
+               rc = (void *)q->cur_desc + (q->iqe_len - sizeof(*rc));
+               if (!is_new_response(rc, q))
+                       break;
+
+               rmb();
+               rsp_type = RSPD_TYPE(rc->type_gen);
+               if (likely(rsp_type == RSP_TYPE_FLBUF)) {
+                       skb_frag_t *fp;
+                       struct pkt_gl si;
+                       const struct rx_sw_desc *rsd;
+                       u32 len = ntohl(rc->pldbuflen_qid), bufsz, frags;
+
+                       if (len & RSPD_NEWBUF) {
+                               if (likely(q->offset > 0)) {
+                                       free_rx_bufs(q->adap, &rxq->fl, 1);
+                                       q->offset = 0;
+                               }
+                               len &= RSPD_LEN;
+                       }
+                       si.tot_len = len;
+
+                       /* gather packet fragments */
+                       for (frags = 0, fp = si.frags; ; frags++, fp++) {
+                               rsd = &rxq->fl.sdesc[rxq->fl.cidx];
+                               bufsz = get_buf_size(rsd);
+                               fp->page = rsd->page;
+                               fp->page_offset = q->offset;
+                               fp->size = min(bufsz, len);
+                               len -= fp->size;
+                               if (!len)
+                                       break;
+                               unmap_rx_buf(q->adap, &rxq->fl);
+                       }
+
+                       /*
+                        * Last buffer remains mapped so explicitly make it
+                        * coherent for CPU access.
+                        */
+                       dma_sync_single_for_cpu(q->adap->pdev_dev,
+                                               get_buf_addr(rsd),
+                                               fp->size, DMA_FROM_DEVICE);
+
+                       si.va = page_address(si.frags[0].page) +
+                               si.frags[0].page_offset;
+                       prefetch(si.va);
+
+                       si.nfrags = frags + 1;
+                       ret = q->handler(q, q->cur_desc, &si);
+                       if (likely(ret == 0))
+                               q->offset += ALIGN(fp->size, FL_ALIGN);
+                       else
+                               restore_rx_bufs(&si, &rxq->fl, frags);
+               } else if (likely(rsp_type == RSP_TYPE_CPL)) {
+                       ret = q->handler(q, q->cur_desc, NULL);
+               } else {
+                       ret = q->handler(q, (const __be64 *)rc, CXGB4_MSG_AN);
+               }
+
+               if (unlikely(ret)) {
+                       /* couldn't process descriptor, back off for recovery */
+                       q->next_intr_params = QINTR_TIMER_IDX(NOMEM_TMR_IDX);
+                       break;
+               }
+
+               rspq_next(q);
+               budget_left--;
+       }
+
+       if (q->offset >= 0 && rxq->fl.size - rxq->fl.avail >= 16)
+               __refill_fl(q->adap, &rxq->fl);
+       return budget - budget_left;
+}
+
+/**
+ *     napi_rx_handler - the NAPI handler for Rx processing
+ *     @napi: the napi instance
+ *     @budget: how many packets we can process in this round
+ *
+ *     Handler for new data events when using NAPI.  This does not need any
+ *     locking or protection from interrupts as data interrupts are off at
+ *     this point and other adapter interrupts do not interfere (the latter
+ *     in not a concern at all with MSI-X as non-data interrupts then have
+ *     a separate handler).
+ */
+static int napi_rx_handler(struct napi_struct *napi, int budget)
+{
+       unsigned int params;
+       struct sge_rspq *q = container_of(napi, struct sge_rspq, napi);
+       int work_done = process_responses(q, budget);
+
+       if (likely(work_done < budget)) {
+               napi_complete(napi);
+               params = q->next_intr_params;
+               q->next_intr_params = q->intr_params;
+       } else
+               params = QINTR_TIMER_IDX(7);
+
+       t4_write_reg(q->adap, MYPF_REG(SGE_PF_GTS), CIDXINC(work_done) |
+                    INGRESSQID((u32)q->cntxt_id) | SEINTARM(params));
+       return work_done;
+}
+
+/*
+ * The MSI-X interrupt handler for an SGE response queue.
+ */
+irqreturn_t t4_sge_intr_msix(int irq, void *cookie)
+{
+       struct sge_rspq *q = cookie;
+
+       napi_schedule(&q->napi);
+       return IRQ_HANDLED;
+}
+
+/*
+ * Process the indirect interrupt entries in the interrupt queue and kick off
+ * NAPI for each queue that has generated an entry.
+ */
+static unsigned int process_intrq(struct adapter *adap)
+{
+       unsigned int credits;
+       const struct rsp_ctrl *rc;
+       struct sge_rspq *q = &adap->sge.intrq;
+
+       spin_lock(&adap->sge.intrq_lock);
+       for (credits = 0; ; credits++) {
+               rc = (void *)q->cur_desc + (q->iqe_len - sizeof(*rc));
+               if (!is_new_response(rc, q))
+                       break;
+
+               rmb();
+               if (RSPD_TYPE(rc->type_gen) == RSP_TYPE_INTR) {
+                       unsigned int qid = ntohl(rc->pldbuflen_qid);
+
+                       napi_schedule(&adap->sge.ingr_map[qid]->napi);
+               }
+
+               rspq_next(q);
+       }
+
+       t4_write_reg(adap, MYPF_REG(SGE_PF_GTS), CIDXINC(credits) |
+                    INGRESSQID(q->cntxt_id) | SEINTARM(q->intr_params));
+       spin_unlock(&adap->sge.intrq_lock);
+       return credits;
+}
+
+/*
+ * The MSI interrupt handler, which handles data events from SGE response queues
+ * as well as error and other async events as they all use the same MSI vector.
+ */
+static irqreturn_t t4_intr_msi(int irq, void *cookie)
+{
+       struct adapter *adap = cookie;
+
+       t4_slow_intr_handler(adap);
+       process_intrq(adap);
+       return IRQ_HANDLED;
+}
+
+/*
+ * Interrupt handler for legacy INTx interrupts.
+ * Handles data events from SGE response queues as well as error and other
+ * async events as they all use the same interrupt line.
+ */
+static irqreturn_t t4_intr_intx(int irq, void *cookie)
+{
+       struct adapter *adap = cookie;
+
+       t4_write_reg(adap, MYPF_REG(PCIE_PF_CLI), 0);
+       if (t4_slow_intr_handler(adap) | process_intrq(adap))
+               return IRQ_HANDLED;
+       return IRQ_NONE;             /* probably shared interrupt */
+}
+
+/**
+ *     t4_intr_handler - select the top-level interrupt handler
+ *     @adap: the adapter
+ *
+ *     Selects the top-level interrupt handler based on the type of interrupts
+ *     (MSI-X, MSI, or INTx).
+ */
+irq_handler_t t4_intr_handler(struct adapter *adap)
+{
+       if (adap->flags & USING_MSIX)
+               return t4_sge_intr_msix;
+       if (adap->flags & USING_MSI)
+               return t4_intr_msi;
+       return t4_intr_intx;
+}
+
+static void sge_rx_timer_cb(unsigned long data)
+{
+       unsigned long m;
+       unsigned int i, cnt[2];
+       struct adapter *adap = (struct adapter *)data;
+       struct sge *s = &adap->sge;
+
+       for (i = 0; i < ARRAY_SIZE(s->starving_fl); i++)
+               for (m = s->starving_fl[i]; m; m &= m - 1) {
+                       struct sge_eth_rxq *rxq;
+                       unsigned int id = __ffs(m) + i * BITS_PER_LONG;
+                       struct sge_fl *fl = s->egr_map[id];
+
+                       clear_bit(id, s->starving_fl);
+                       smp_mb__after_clear_bit();
+
+                       if (fl_starving(fl)) {
+                               rxq = container_of(fl, struct sge_eth_rxq, fl);
+                               if (napi_reschedule(&rxq->rspq.napi))
+                                       fl->starving++;
+                               else
+                                       set_bit(id, s->starving_fl);
+                       }
+               }
+
+       t4_write_reg(adap, SGE_DEBUG_INDEX, 13);
+       cnt[0] = t4_read_reg(adap, SGE_DEBUG_DATA_HIGH);
+       cnt[1] = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
+
+       for (i = 0; i < 2; i++)
+               if (cnt[i] >= s->starve_thres) {
+                       if (s->idma_state[i] || cnt[i] == 0xffffffff)
+                               continue;
+                       s->idma_state[i] = 1;
+                       t4_write_reg(adap, SGE_DEBUG_INDEX, 11);
+                       m = t4_read_reg(adap, SGE_DEBUG_DATA_LOW) >> (i * 16);
+                       dev_warn(adap->pdev_dev,
+                                "SGE idma%u starvation detected for "
+                                "queue %lu\n", i, m & 0xffff);
+               } else if (s->idma_state[i])
+                       s->idma_state[i] = 0;
+
+       mod_timer(&s->rx_timer, jiffies + RX_QCHECK_PERIOD);
+}
+
+static void sge_tx_timer_cb(unsigned long data)
+{
+       unsigned long m;
+       unsigned int i, budget;
+       struct adapter *adap = (struct adapter *)data;
+       struct sge *s = &adap->sge;
+
+       for (i = 0; i < ARRAY_SIZE(s->txq_maperr); i++)
+               for (m = s->txq_maperr[i]; m; m &= m - 1) {
+                       unsigned long id = __ffs(m) + i * BITS_PER_LONG;
+                       struct sge_ofld_txq *txq = s->egr_map[id];
+
+                       clear_bit(id, s->txq_maperr);
+                       tasklet_schedule(&txq->qresume_tsk);
+               }
+
+       budget = MAX_TIMER_TX_RECLAIM;
+       i = s->ethtxq_rover;
+       do {
+               struct sge_eth_txq *q = &s->ethtxq[i];
+
+               if (q->q.in_use &&
+                   time_after_eq(jiffies, q->txq->trans_start + HZ / 100) &&
+                   __netif_tx_trylock(q->txq)) {
+                       int avail = reclaimable(&q->q);
+
+                       if (avail) {
+                               if (avail > budget)
+                                       avail = budget;
+
+                               free_tx_desc(adap, &q->q, avail, true);
+                               q->q.in_use -= avail;
+                               budget -= avail;
+                       }
+                       __netif_tx_unlock(q->txq);
+               }
+
+               if (++i >= s->ethqsets)
+                       i = 0;
+       } while (budget && i != s->ethtxq_rover);
+       s->ethtxq_rover = i;
+       mod_timer(&s->tx_timer, jiffies + (budget ? TX_QCHECK_PERIOD : 2));
+}
+
+int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
+                    struct net_device *dev, int intr_idx,
+                    struct sge_fl *fl, rspq_handler_t hnd)
+{
+       int ret, flsz = 0;
+       struct fw_iq_cmd c;
+       struct port_info *pi = netdev_priv(dev);
+
+       /* Size needs to be multiple of 16, including status entry. */
+       iq->size = roundup(iq->size, 16);
+
+       iq->desc = alloc_ring(adap->pdev_dev, iq->size, iq->iqe_len, 0,
+                             &iq->phys_addr, NULL, 0);
+       if (!iq->desc)
+               return -ENOMEM;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_CMD_EXEC |
+                           FW_IQ_CMD_PFN(0) | FW_IQ_CMD_VFN(0));
+       c.alloc_to_len16 = htonl(FW_IQ_CMD_ALLOC | FW_IQ_CMD_IQSTART(1) |
+                                FW_LEN16(c));
+       c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE(FW_IQ_TYPE_FL_INT_CAP) |
+               FW_IQ_CMD_IQASYNCH(fwevtq) | FW_IQ_CMD_VIID(pi->viid) |
+               FW_IQ_CMD_IQANDST(intr_idx < 0) | FW_IQ_CMD_IQANUD(1) |
+               FW_IQ_CMD_IQANDSTINDEX(intr_idx >= 0 ? intr_idx :
+                                                       -intr_idx - 1));
+       c.iqdroprss_to_iqesize = htons(FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
+               FW_IQ_CMD_IQGTSMODE |
+               FW_IQ_CMD_IQINTCNTTHRESH(iq->pktcnt_idx) |
+               FW_IQ_CMD_IQESIZE(ilog2(iq->iqe_len) - 4));
+       c.iqsize = htons(iq->size);
+       c.iqaddr = cpu_to_be64(iq->phys_addr);
+
+       if (fl) {
+               fl->size = roundup(fl->size, 8);
+               fl->desc = alloc_ring(adap->pdev_dev, fl->size, sizeof(__be64),
+                                     sizeof(struct rx_sw_desc), &fl->addr,
+                                     &fl->sdesc, STAT_LEN);
+               if (!fl->desc)
+                       goto fl_nomem;
+
+               flsz = fl->size / 8 + STAT_LEN / sizeof(struct tx_desc);
+               c.iqns_to_fl0congen = htonl(FW_IQ_CMD_FL0PACKEN |
+                                           FW_IQ_CMD_FL0PADEN);
+               c.fl0dcaen_to_fl0cidxfthresh = htons(FW_IQ_CMD_FL0FBMIN(2) |
+                               FW_IQ_CMD_FL0FBMAX(3));
+               c.fl0size = htons(flsz);
+               c.fl0addr = cpu_to_be64(fl->addr);
+       }
+
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
+       if (ret)
+               goto err;
+
+       netif_napi_add(dev, &iq->napi, napi_rx_handler, 64);
+       iq->cur_desc = iq->desc;
+       iq->cidx = 0;
+       iq->gen = 1;
+       iq->next_intr_params = iq->intr_params;
+       iq->cntxt_id = ntohs(c.iqid);
+       iq->abs_id = ntohs(c.physiqid);
+       iq->size--;                           /* subtract status entry */
+       iq->adap = adap;
+       iq->netdev = dev;
+       iq->handler = hnd;
+
+       /* set offset to -1 to distinguish ingress queues without FL */
+       iq->offset = fl ? 0 : -1;
+
+       adap->sge.ingr_map[iq->cntxt_id] = iq;
+
+       if (fl) {
+               fl->cntxt_id = htons(c.fl0id);
+               fl->avail = fl->pend_cred = 0;
+               fl->pidx = fl->cidx = 0;
+               fl->alloc_failed = fl->large_alloc_failed = fl->starving = 0;
+               adap->sge.egr_map[fl->cntxt_id] = fl;
+               refill_fl(adap, fl, fl_cap(fl), GFP_KERNEL);
+       }
+       return 0;
+
+fl_nomem:
+       ret = -ENOMEM;
+err:
+       if (iq->desc) {
+               dma_free_coherent(adap->pdev_dev, iq->size * iq->iqe_len,
+                                 iq->desc, iq->phys_addr);
+               iq->desc = NULL;
+       }
+       if (fl && fl->desc) {
+               kfree(fl->sdesc);
+               fl->sdesc = NULL;
+               dma_free_coherent(adap->pdev_dev, flsz * sizeof(struct tx_desc),
+                                 fl->desc, fl->addr);
+               fl->desc = NULL;
+       }
+       return ret;
+}
+
+static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id)
+{
+       q->in_use = 0;
+       q->cidx = q->pidx = 0;
+       q->stops = q->restarts = 0;
+       q->stat = (void *)&q->desc[q->size];
+       q->cntxt_id = id;
+       adap->sge.egr_map[id] = q;
+}
+
+int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
+                        struct net_device *dev, struct netdev_queue *netdevq,
+                        unsigned int iqid)
+{
+       int ret, nentries;
+       struct fw_eq_eth_cmd c;
+       struct port_info *pi = netdev_priv(dev);
+
+       /* Add status entries */
+       nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
+
+       txq->q.desc = alloc_ring(adap->pdev_dev, txq->q.size,
+                       sizeof(struct tx_desc), sizeof(struct tx_sw_desc),
+                       &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN);
+       if (!txq->q.desc)
+               return -ENOMEM;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_ETH_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_CMD_EXEC |
+                           FW_EQ_ETH_CMD_PFN(0) | FW_EQ_ETH_CMD_VFN(0));
+       c.alloc_to_len16 = htonl(FW_EQ_ETH_CMD_ALLOC |
+                                FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c));
+       c.viid_pkd = htonl(FW_EQ_ETH_CMD_VIID(pi->viid));
+       c.fetchszm_to_iqid = htonl(FW_EQ_ETH_CMD_HOSTFCMODE(2) |
+                                  FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) |
+                                  FW_EQ_ETH_CMD_IQID(iqid));
+       c.dcaen_to_eqsize = htonl(FW_EQ_ETH_CMD_FBMIN(2) |
+                                 FW_EQ_ETH_CMD_FBMAX(3) |
+                                 FW_EQ_ETH_CMD_CIDXFTHRESH(5) |
+                                 FW_EQ_ETH_CMD_EQSIZE(nentries));
+       c.eqaddr = cpu_to_be64(txq->q.phys_addr);
+
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
+       if (ret) {
+               kfree(txq->q.sdesc);
+               txq->q.sdesc = NULL;
+               dma_free_coherent(adap->pdev_dev,
+                                 nentries * sizeof(struct tx_desc),
+                                 txq->q.desc, txq->q.phys_addr);
+               txq->q.desc = NULL;
+               return ret;
+       }
+
+       init_txq(adap, &txq->q, FW_EQ_ETH_CMD_EQID_GET(ntohl(c.eqid_pkd)));
+       txq->txq = netdevq;
+       txq->tso = txq->tx_cso = txq->vlan_ins = 0;
+       txq->mapping_err = 0;
+       return 0;
+}
+
+int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
+                         struct net_device *dev, unsigned int iqid,
+                         unsigned int cmplqid)
+{
+       int ret, nentries;
+       struct fw_eq_ctrl_cmd c;
+       struct port_info *pi = netdev_priv(dev);
+
+       /* Add status entries */
+       nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
+
+       txq->q.desc = alloc_ring(adap->pdev_dev, nentries,
+                                sizeof(struct tx_desc), 0, &txq->q.phys_addr,
+                                NULL, 0);
+       if (!txq->q.desc)
+               return -ENOMEM;
+
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_CTRL_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_CMD_EXEC |
+                           FW_EQ_CTRL_CMD_PFN(0) | FW_EQ_CTRL_CMD_VFN(0));
+       c.alloc_to_len16 = htonl(FW_EQ_CTRL_CMD_ALLOC |
+                                FW_EQ_CTRL_CMD_EQSTART | FW_LEN16(c));
+       c.cmpliqid_eqid = htonl(FW_EQ_CTRL_CMD_CMPLIQID(cmplqid));
+       c.physeqid_pkd = htonl(0);
+       c.fetchszm_to_iqid = htonl(FW_EQ_CTRL_CMD_HOSTFCMODE(2) |
+                                  FW_EQ_CTRL_CMD_PCIECHN(pi->tx_chan) |
+                                  FW_EQ_CTRL_CMD_IQID(iqid));
+       c.dcaen_to_eqsize = htonl(FW_EQ_CTRL_CMD_FBMIN(2) |
+                                 FW_EQ_CTRL_CMD_FBMAX(3) |
+                                 FW_EQ_CTRL_CMD_CIDXFTHRESH(5) |
+                                 FW_EQ_CTRL_CMD_EQSIZE(nentries));
+       c.eqaddr = cpu_to_be64(txq->q.phys_addr);
+
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
+       if (ret) {
+               dma_free_coherent(adap->pdev_dev,
+                                 nentries * sizeof(struct tx_desc),
+                                 txq->q.desc, txq->q.phys_addr);
+               txq->q.desc = NULL;
+               return ret;
+       }
+
+       init_txq(adap, &txq->q, FW_EQ_CTRL_CMD_EQID_GET(ntohl(c.cmpliqid_eqid)));
+       txq->adap = adap;
+       skb_queue_head_init(&txq->sendq);
+       tasklet_init(&txq->qresume_tsk, restart_ctrlq, (unsigned long)txq);
+       txq->full = 0;
+       return 0;
+}
+
+int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
+                         struct net_device *dev, unsigned int iqid)
+{
+       int ret, nentries;
+       struct fw_eq_ofld_cmd c;
+       struct port_info *pi = netdev_priv(dev);
+
+       /* Add status entries */
+       nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
+
+       txq->q.desc = alloc_ring(adap->pdev_dev, txq->q.size,
+                       sizeof(struct tx_desc), sizeof(struct tx_sw_desc),
+                       &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN);
+       if (!txq->q.desc)
+               return -ENOMEM;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_OFLD_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_CMD_EXEC |
+                           FW_EQ_OFLD_CMD_PFN(0) | FW_EQ_OFLD_CMD_VFN(0));
+       c.alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_ALLOC |
+                                FW_EQ_OFLD_CMD_EQSTART | FW_LEN16(c));
+       c.fetchszm_to_iqid = htonl(FW_EQ_OFLD_CMD_HOSTFCMODE(2) |
+                                  FW_EQ_OFLD_CMD_PCIECHN(pi->tx_chan) |
+                                  FW_EQ_OFLD_CMD_IQID(iqid));
+       c.dcaen_to_eqsize = htonl(FW_EQ_OFLD_CMD_FBMIN(2) |
+                                 FW_EQ_OFLD_CMD_FBMAX(3) |
+                                 FW_EQ_OFLD_CMD_CIDXFTHRESH(5) |
+                                 FW_EQ_OFLD_CMD_EQSIZE(nentries));
+       c.eqaddr = cpu_to_be64(txq->q.phys_addr);
+
+       ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
+       if (ret) {
+               kfree(txq->q.sdesc);
+               txq->q.sdesc = NULL;
+               dma_free_coherent(adap->pdev_dev,
+                                 nentries * sizeof(struct tx_desc),
+                                 txq->q.desc, txq->q.phys_addr);
+               txq->q.desc = NULL;
+               return ret;
+       }
+
+       init_txq(adap, &txq->q, FW_EQ_OFLD_CMD_EQID_GET(ntohl(c.eqid_pkd)));
+       txq->adap = adap;
+       skb_queue_head_init(&txq->sendq);
+       tasklet_init(&txq->qresume_tsk, restart_ofldq, (unsigned long)txq);
+       txq->full = 0;
+       txq->mapping_err = 0;
+       return 0;
+}
+
+static void free_txq(struct adapter *adap, struct sge_txq *q)
+{
+       dma_free_coherent(adap->pdev_dev,
+                         q->size * sizeof(struct tx_desc) + STAT_LEN,
+                         q->desc, q->phys_addr);
+       q->cntxt_id = 0;
+       q->sdesc = NULL;
+       q->desc = NULL;
+}
+
+static void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq,
+                        struct sge_fl *fl)
+{
+       unsigned int fl_id = fl ? fl->cntxt_id : 0xffff;
+
+       adap->sge.ingr_map[rq->cntxt_id] = NULL;
+       t4_iq_free(adap, 0, 0, 0, FW_IQ_TYPE_FL_INT_CAP, rq->cntxt_id, fl_id,
+                  0xffff);
+       dma_free_coherent(adap->pdev_dev, (rq->size + 1) * rq->iqe_len,
+                         rq->desc, rq->phys_addr);
+       netif_napi_del(&rq->napi);
+       rq->netdev = NULL;
+       rq->cntxt_id = rq->abs_id = 0;
+       rq->desc = NULL;
+
+       if (fl) {
+               free_rx_bufs(adap, fl, fl->avail);
+               dma_free_coherent(adap->pdev_dev, fl->size * 8 + STAT_LEN,
+                                 fl->desc, fl->addr);
+               kfree(fl->sdesc);
+               fl->sdesc = NULL;
+               fl->cntxt_id = 0;
+               fl->desc = NULL;
+       }
+}
+
+/**
+ *     t4_free_sge_resources - free SGE resources
+ *     @adap: the adapter
+ *
+ *     Frees resources used by the SGE queue sets.
+ */
+void t4_free_sge_resources(struct adapter *adap)
+{
+       int i;
+       struct sge_eth_rxq *eq = adap->sge.ethrxq;
+       struct sge_eth_txq *etq = adap->sge.ethtxq;
+       struct sge_ofld_rxq *oq = adap->sge.ofldrxq;
+
+       /* clean up Ethernet Tx/Rx queues */
+       for (i = 0; i < adap->sge.ethqsets; i++, eq++, etq++) {
+               if (eq->rspq.desc)
+                       free_rspq_fl(adap, &eq->rspq, &eq->fl);
+               if (etq->q.desc) {
+                       t4_eth_eq_free(adap, 0, 0, 0, etq->q.cntxt_id);
+                       free_tx_desc(adap, &etq->q, etq->q.in_use, true);
+                       kfree(etq->q.sdesc);
+                       free_txq(adap, &etq->q);
+               }
+       }
+
+       /* clean up RDMA and iSCSI Rx queues */
+       for (i = 0; i < adap->sge.ofldqsets; i++, oq++) {
+               if (oq->rspq.desc)
+                       free_rspq_fl(adap, &oq->rspq, &oq->fl);
+       }
+       for (i = 0, oq = adap->sge.rdmarxq; i < adap->sge.rdmaqs; i++, oq++) {
+               if (oq->rspq.desc)
+                       free_rspq_fl(adap, &oq->rspq, &oq->fl);
+       }
+
+       /* clean up offload Tx queues */
+       for (i = 0; i < ARRAY_SIZE(adap->sge.ofldtxq); i++) {
+               struct sge_ofld_txq *q = &adap->sge.ofldtxq[i];
+
+               if (q->q.desc) {
+                       tasklet_kill(&q->qresume_tsk);
+                       t4_ofld_eq_free(adap, 0, 0, 0, q->q.cntxt_id);
+                       free_tx_desc(adap, &q->q, q->q.in_use, false);
+                       kfree(q->q.sdesc);
+                       __skb_queue_purge(&q->sendq);
+                       free_txq(adap, &q->q);
+               }
+       }
+
+       /* clean up control Tx queues */
+       for (i = 0; i < ARRAY_SIZE(adap->sge.ctrlq); i++) {
+               struct sge_ctrl_txq *cq = &adap->sge.ctrlq[i];
+
+               if (cq->q.desc) {
+                       tasklet_kill(&cq->qresume_tsk);
+                       t4_ctrl_eq_free(adap, 0, 0, 0, cq->q.cntxt_id);
+                       __skb_queue_purge(&cq->sendq);
+                       free_txq(adap, &cq->q);
+               }
+       }
+
+       if (adap->sge.fw_evtq.desc)
+               free_rspq_fl(adap, &adap->sge.fw_evtq, NULL);
+
+       if (adap->sge.intrq.desc)
+               free_rspq_fl(adap, &adap->sge.intrq, NULL);
+
+       /* clear the reverse egress queue map */
+       memset(adap->sge.egr_map, 0, sizeof(adap->sge.egr_map));
+}
+
+void t4_sge_start(struct adapter *adap)
+{
+       adap->sge.ethtxq_rover = 0;
+       mod_timer(&adap->sge.rx_timer, jiffies + RX_QCHECK_PERIOD);
+       mod_timer(&adap->sge.tx_timer, jiffies + TX_QCHECK_PERIOD);
+}
+
+/**
+ *     t4_sge_stop - disable SGE operation
+ *     @adap: the adapter
+ *
+ *     Stop tasklets and timers associated with the DMA engine.  Note that
+ *     this is effective only if measures have been taken to disable any HW
+ *     events that may restart them.
+ */
+void t4_sge_stop(struct adapter *adap)
+{
+       int i;
+       struct sge *s = &adap->sge;
+
+       if (in_interrupt())  /* actions below require waiting */
+               return;
+
+       if (s->rx_timer.function)
+               del_timer_sync(&s->rx_timer);
+       if (s->tx_timer.function)
+               del_timer_sync(&s->tx_timer);
+
+       for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++) {
+               struct sge_ofld_txq *q = &s->ofldtxq[i];
+
+               if (q->q.desc)
+                       tasklet_kill(&q->qresume_tsk);
+       }
+       for (i = 0; i < ARRAY_SIZE(s->ctrlq); i++) {
+               struct sge_ctrl_txq *cq = &s->ctrlq[i];
+
+               if (cq->q.desc)
+                       tasklet_kill(&cq->qresume_tsk);
+       }
+}
+
+/**
+ *     t4_sge_init - initialize SGE
+ *     @adap: the adapter
+ *
+ *     Performs SGE initialization needed every time after a chip reset.
+ *     We do not initialize any of the queues here, instead the driver
+ *     top-level must request them individually.
+ */
+void t4_sge_init(struct adapter *adap)
+{
+       struct sge *s = &adap->sge;
+       unsigned int fl_align_log = ilog2(FL_ALIGN);
+
+       t4_set_reg_field(adap, SGE_CONTROL, PKTSHIFT_MASK |
+                        INGPADBOUNDARY_MASK | EGRSTATUSPAGESIZE,
+                        INGPADBOUNDARY(fl_align_log - 5) | PKTSHIFT(2) |
+                        RXPKTCPLMODE |
+                        (STAT_LEN == 128 ? EGRSTATUSPAGESIZE : 0));
+       t4_set_reg_field(adap, SGE_HOST_PAGE_SIZE, HOSTPAGESIZEPF0_MASK,
+                        HOSTPAGESIZEPF0(PAGE_SHIFT - 10));
+       t4_write_reg(adap, SGE_FL_BUFFER_SIZE0, PAGE_SIZE);
+#if FL_PG_ORDER > 0
+       t4_write_reg(adap, SGE_FL_BUFFER_SIZE1, PAGE_SIZE << FL_PG_ORDER);
+#endif
+       t4_write_reg(adap, SGE_INGRESS_RX_THRESHOLD,
+                    THRESHOLD_0(s->counter_val[0]) |
+                    THRESHOLD_1(s->counter_val[1]) |
+                    THRESHOLD_2(s->counter_val[2]) |
+                    THRESHOLD_3(s->counter_val[3]));
+       t4_write_reg(adap, SGE_TIMER_VALUE_0_AND_1,
+                    TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[0])) |
+                    TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[1])));
+       t4_write_reg(adap, SGE_TIMER_VALUE_2_AND_3,
+                    TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[2])) |
+                    TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[3])));
+       t4_write_reg(adap, SGE_TIMER_VALUE_4_AND_5,
+                    TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[4])) |
+                    TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[5])));
+       setup_timer(&s->rx_timer, sge_rx_timer_cb, (unsigned long)adap);
+       setup_timer(&s->tx_timer, sge_tx_timer_cb, (unsigned long)adap);
+       s->starve_thres = core_ticks_per_usec(adap) * 1000000;  /* 1 s */
+       s->idma_state[0] = s->idma_state[1] = 0;
+       spin_lock_init(&s->intrq_lock);
+}
diff --git a/drivers/net/cxgb4/t4_hw.c b/drivers/net/cxgb4/t4_hw.c
new file mode 100644 (file)
index 0000000..a814a3a
--- /dev/null
@@ -0,0 +1,3131 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include "cxgb4.h"
+#include "t4_regs.h"
+#include "t4fw_api.h"
+
+/**
+ *     t4_wait_op_done_val - wait until an operation is completed
+ *     @adapter: the adapter performing the operation
+ *     @reg: the register to check for completion
+ *     @mask: a single-bit field within @reg that indicates completion
+ *     @polarity: the value of the field when the operation is completed
+ *     @attempts: number of check iterations
+ *     @delay: delay in usecs between iterations
+ *     @valp: where to store the value of the register at completion time
+ *
+ *     Wait until an operation is completed by checking a bit in a register
+ *     up to @attempts times.  If @valp is not NULL the value of the register
+ *     at the time it indicated completion is stored there.  Returns 0 if the
+ *     operation completes and -EAGAIN otherwise.
+ */
+int t4_wait_op_done_val(struct adapter *adapter, int reg, u32 mask,
+                       int polarity, int attempts, int delay, u32 *valp)
+{
+       while (1) {
+               u32 val = t4_read_reg(adapter, reg);
+
+               if (!!(val & mask) == polarity) {
+                       if (valp)
+                               *valp = val;
+                       return 0;
+               }
+               if (--attempts == 0)
+                       return -EAGAIN;
+               if (delay)
+                       udelay(delay);
+       }
+}
+
+static inline int t4_wait_op_done(struct adapter *adapter, int reg, u32 mask,
+                                 int polarity, int attempts, int delay)
+{
+       return t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
+                                  delay, NULL);
+}
+
+/**
+ *     t4_set_reg_field - set a register field to a value
+ *     @adapter: the adapter to program
+ *     @addr: the register address
+ *     @mask: specifies the portion of the register to modify
+ *     @val: the new value for the register field
+ *
+ *     Sets a register field specified by the supplied mask to the
+ *     given value.
+ */
+void t4_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask,
+                     u32 val)
+{
+       u32 v = t4_read_reg(adapter, addr) & ~mask;
+
+       t4_write_reg(adapter, addr, v | val);
+       (void) t4_read_reg(adapter, addr);      /* flush */
+}
+
+/**
+ *     t4_read_indirect - read indirectly addressed registers
+ *     @adap: the adapter
+ *     @addr_reg: register holding the indirect address
+ *     @data_reg: register holding the value of the indirect register
+ *     @vals: where the read register values are stored
+ *     @nregs: how many indirect registers to read
+ *     @start_idx: index of first indirect register to read
+ *
+ *     Reads registers that are accessed indirectly through an address/data
+ *     register pair.
+ */
+void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
+                     unsigned int data_reg, u32 *vals, unsigned int nregs,
+                     unsigned int start_idx)
+{
+       while (nregs--) {
+               t4_write_reg(adap, addr_reg, start_idx);
+               *vals++ = t4_read_reg(adap, data_reg);
+               start_idx++;
+       }
+}
+
+/**
+ *     t4_write_indirect - write indirectly addressed registers
+ *     @adap: the adapter
+ *     @addr_reg: register holding the indirect addresses
+ *     @data_reg: register holding the value for the indirect registers
+ *     @vals: values to write
+ *     @nregs: how many indirect registers to write
+ *     @start_idx: address of first indirect register to write
+ *
+ *     Writes a sequential block of registers that are accessed indirectly
+ *     through an address/data register pair.
+ */
+void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
+                      unsigned int data_reg, const u32 *vals,
+                      unsigned int nregs, unsigned int start_idx)
+{
+       while (nregs--) {
+               t4_write_reg(adap, addr_reg, start_idx++);
+               t4_write_reg(adap, data_reg, *vals++);
+       }
+}
+
+/*
+ * Get the reply to a mailbox command and store it in @rpl in big-endian order.
+ */
+static void get_mbox_rpl(struct adapter *adap, __be64 *rpl, int nflit,
+                        u32 mbox_addr)
+{
+       for ( ; nflit; nflit--, mbox_addr += 8)
+               *rpl++ = cpu_to_be64(t4_read_reg64(adap, mbox_addr));
+}
+
+/*
+ * Handle a FW assertion reported in a mailbox.
+ */
+static void fw_asrt(struct adapter *adap, u32 mbox_addr)
+{
+       struct fw_debug_cmd asrt;
+
+       get_mbox_rpl(adap, (__be64 *)&asrt, sizeof(asrt) / 8, mbox_addr);
+       dev_alert(adap->pdev_dev,
+                 "FW assertion at %.16s:%u, val0 %#x, val1 %#x\n",
+                 asrt.u.assert.filename_0_7, ntohl(asrt.u.assert.line),
+                 ntohl(asrt.u.assert.x), ntohl(asrt.u.assert.y));
+}
+
+static void dump_mbox(struct adapter *adap, int mbox, u32 data_reg)
+{
+       dev_err(adap->pdev_dev,
+               "mbox %d: %llx %llx %llx %llx %llx %llx %llx %llx\n", mbox,
+               (unsigned long long)t4_read_reg64(adap, data_reg),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 8),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 16),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 24),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 32),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 40),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 48),
+               (unsigned long long)t4_read_reg64(adap, data_reg + 56));
+}
+
+/**
+ *     t4_wr_mbox_meat - send a command to FW through the given mailbox
+ *     @adap: the adapter
+ *     @mbox: index of the mailbox to use
+ *     @cmd: the command to write
+ *     @size: command length in bytes
+ *     @rpl: where to optionally store the reply
+ *     @sleep_ok: if true we may sleep while awaiting command completion
+ *
+ *     Sends the given command to FW through the selected mailbox and waits
+ *     for the FW to execute the command.  If @rpl is not %NULL it is used to
+ *     store the FW's reply to the command.  The command and its optional
+ *     reply are of the same length.  FW can take up to %FW_CMD_MAX_TIMEOUT ms
+ *     to respond.  @sleep_ok determines whether we may sleep while awaiting
+ *     the response.  If sleeping is allowed we use progressive backoff
+ *     otherwise we spin.
+ *
+ *     The return value is 0 on success or a negative errno on failure.  A
+ *     failure can happen either because we are not able to execute the
+ *     command or FW executes it but signals an error.  In the latter case
+ *     the return value is the error code indicated by FW (negated).
+ */
+int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
+                   void *rpl, bool sleep_ok)
+{
+       static int delay[] = {
+               1, 1, 3, 5, 10, 10, 20, 50, 100, 200
+       };
+
+       u32 v;
+       u64 res;
+       int i, ms, delay_idx;
+       const __be64 *p = cmd;
+       u32 data_reg = PF_REG(mbox, CIM_PF_MAILBOX_DATA);
+       u32 ctl_reg = PF_REG(mbox, CIM_PF_MAILBOX_CTRL);
+
+       if ((size & 15) || size > MBOX_LEN)
+               return -EINVAL;
+
+       v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
+       for (i = 0; v == MBOX_OWNER_NONE && i < 3; i++)
+               v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
+
+       if (v != MBOX_OWNER_DRV)
+               return v ? -EBUSY : -ETIMEDOUT;
+
+       for (i = 0; i < size; i += 8)
+               t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
+
+       t4_write_reg(adap, ctl_reg, MBMSGVALID | MBOWNER(MBOX_OWNER_FW));
+       t4_read_reg(adap, ctl_reg);          /* flush write */
+
+       delay_idx = 0;
+       ms = delay[0];
+
+       for (i = 0; i < FW_CMD_MAX_TIMEOUT; i += ms) {
+               if (sleep_ok) {
+                       ms = delay[delay_idx];  /* last element may repeat */
+                       if (delay_idx < ARRAY_SIZE(delay) - 1)
+                               delay_idx++;
+                       msleep(ms);
+               } else
+                       mdelay(ms);
+
+               v = t4_read_reg(adap, ctl_reg);
+               if (MBOWNER_GET(v) == MBOX_OWNER_DRV) {
+                       if (!(v & MBMSGVALID)) {
+                               t4_write_reg(adap, ctl_reg, 0);
+                               continue;
+                       }
+
+                       res = t4_read_reg64(adap, data_reg);
+                       if (FW_CMD_OP_GET(res >> 32) == FW_DEBUG_CMD) {
+                               fw_asrt(adap, data_reg);
+                               res = FW_CMD_RETVAL(EIO);
+                       } else if (rpl)
+                               get_mbox_rpl(adap, rpl, size / 8, data_reg);
+
+                       if (FW_CMD_RETVAL_GET((int)res))
+                               dump_mbox(adap, mbox, data_reg);
+                       t4_write_reg(adap, ctl_reg, 0);
+                       return -FW_CMD_RETVAL_GET((int)res);
+               }
+       }
+
+       dump_mbox(adap, mbox, data_reg);
+       dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
+               *(const u8 *)cmd, mbox);
+       return -ETIMEDOUT;
+}
+
+/**
+ *     t4_mc_read - read from MC through backdoor accesses
+ *     @adap: the adapter
+ *     @addr: address of first byte requested
+ *     @data: 64 bytes of data containing the requested address
+ *     @ecc: where to store the corresponding 64-bit ECC word
+ *
+ *     Read 64 bytes of data from MC starting at a 64-byte-aligned address
+ *     that covers the requested address @addr.  If @parity is not %NULL it
+ *     is assigned the 64-bit ECC word for the read data.
+ */
+int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *ecc)
+{
+       int i;
+
+       if (t4_read_reg(adap, MC_BIST_CMD) & START_BIST)
+               return -EBUSY;
+       t4_write_reg(adap, MC_BIST_CMD_ADDR, addr & ~0x3fU);
+       t4_write_reg(adap, MC_BIST_CMD_LEN, 64);
+       t4_write_reg(adap, MC_BIST_DATA_PATTERN, 0xc);
+       t4_write_reg(adap, MC_BIST_CMD, BIST_OPCODE(1) | START_BIST |
+                    BIST_CMD_GAP(1));
+       i = t4_wait_op_done(adap, MC_BIST_CMD, START_BIST, 0, 10, 1);
+       if (i)
+               return i;
+
+#define MC_DATA(i) MC_BIST_STATUS_REG(MC_BIST_STATUS_RDATA, i)
+
+       for (i = 15; i >= 0; i--)
+               *data++ = htonl(t4_read_reg(adap, MC_DATA(i)));
+       if (ecc)
+               *ecc = t4_read_reg64(adap, MC_DATA(16));
+#undef MC_DATA
+       return 0;
+}
+
+/**
+ *     t4_edc_read - read from EDC through backdoor accesses
+ *     @adap: the adapter
+ *     @idx: which EDC to access
+ *     @addr: address of first byte requested
+ *     @data: 64 bytes of data containing the requested address
+ *     @ecc: where to store the corresponding 64-bit ECC word
+ *
+ *     Read 64 bytes of data from EDC starting at a 64-byte-aligned address
+ *     that covers the requested address @addr.  If @parity is not %NULL it
+ *     is assigned the 64-bit ECC word for the read data.
+ */
+int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
+{
+       int i;
+
+       idx *= EDC_STRIDE;
+       if (t4_read_reg(adap, EDC_BIST_CMD + idx) & START_BIST)
+               return -EBUSY;
+       t4_write_reg(adap, EDC_BIST_CMD_ADDR + idx, addr & ~0x3fU);
+       t4_write_reg(adap, EDC_BIST_CMD_LEN + idx, 64);
+       t4_write_reg(adap, EDC_BIST_DATA_PATTERN + idx, 0xc);
+       t4_write_reg(adap, EDC_BIST_CMD + idx,
+                    BIST_OPCODE(1) | BIST_CMD_GAP(1) | START_BIST);
+       i = t4_wait_op_done(adap, EDC_BIST_CMD + idx, START_BIST, 0, 10, 1);
+       if (i)
+               return i;
+
+#define EDC_DATA(i) (EDC_BIST_STATUS_REG(EDC_BIST_STATUS_RDATA, i) + idx)
+
+       for (i = 15; i >= 0; i--)
+               *data++ = htonl(t4_read_reg(adap, EDC_DATA(i)));
+       if (ecc)
+               *ecc = t4_read_reg64(adap, EDC_DATA(16));
+#undef EDC_DATA
+       return 0;
+}
+
+#define VPD_ENTRY(name, len) \
+       u8 name##_kword[2]; u8 name##_len; u8 name##_data[len]
+
+/*
+ * Partial EEPROM Vital Product Data structure.  Includes only the ID and
+ * VPD-R sections.
+ */
+struct t4_vpd {
+       u8  id_tag;
+       u8  id_len[2];
+       u8  id_data[ID_LEN];
+       u8  vpdr_tag;
+       u8  vpdr_len[2];
+       VPD_ENTRY(pn, 16);                     /* part number */
+       VPD_ENTRY(ec, EC_LEN);                 /* EC level */
+       VPD_ENTRY(sn, SERNUM_LEN);             /* serial number */
+       VPD_ENTRY(na, 12);                     /* MAC address base */
+       VPD_ENTRY(port_type, 8);               /* port types */
+       VPD_ENTRY(gpio, 14);                   /* GPIO usage */
+       VPD_ENTRY(cclk, 6);                    /* core clock */
+       VPD_ENTRY(port_addr, 8);               /* port MDIO addresses */
+       VPD_ENTRY(rv, 1);                      /* csum */
+       u32 pad;                  /* for multiple-of-4 sizing and alignment */
+};
+
+#define EEPROM_STAT_ADDR   0x7bfc
+#define VPD_BASE           0
+
+/**
+ *     t4_seeprom_wp - enable/disable EEPROM write protection
+ *     @adapter: the adapter
+ *     @enable: whether to enable or disable write protection
+ *
+ *     Enables or disables write protection on the serial EEPROM.
+ */
+int t4_seeprom_wp(struct adapter *adapter, bool enable)
+{
+       unsigned int v = enable ? 0xc : 0;
+       int ret = pci_write_vpd(adapter->pdev, EEPROM_STAT_ADDR, 4, &v);
+       return ret < 0 ? ret : 0;
+}
+
+/**
+ *     get_vpd_params - read VPD parameters from VPD EEPROM
+ *     @adapter: adapter to read
+ *     @p: where to store the parameters
+ *
+ *     Reads card parameters stored in VPD EEPROM.
+ */
+static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
+{
+       int ret;
+       struct t4_vpd vpd;
+       u8 *q = (u8 *)&vpd, csum;
+
+       ret = pci_read_vpd(adapter->pdev, VPD_BASE, sizeof(vpd), &vpd);
+       if (ret < 0)
+               return ret;
+
+       for (csum = 0; q <= vpd.rv_data; q++)
+               csum += *q;
+
+       if (csum) {
+               dev_err(adapter->pdev_dev,
+                       "corrupted VPD EEPROM, actual csum %u\n", csum);
+               return -EINVAL;
+       }
+
+       p->cclk = simple_strtoul(vpd.cclk_data, NULL, 10);
+       memcpy(p->id, vpd.id_data, sizeof(vpd.id_data));
+       strim(p->id);
+       memcpy(p->ec, vpd.ec_data, sizeof(vpd.ec_data));
+       strim(p->ec);
+       memcpy(p->sn, vpd.sn_data, sizeof(vpd.sn_data));
+       strim(p->sn);
+       return 0;
+}
+
+/* serial flash and firmware constants */
+enum {
+       SF_ATTEMPTS = 10,             /* max retries for SF operations */
+
+       /* flash command opcodes */
+       SF_PROG_PAGE    = 2,          /* program page */
+       SF_WR_DISABLE   = 4,          /* disable writes */
+       SF_RD_STATUS    = 5,          /* read status register */
+       SF_WR_ENABLE    = 6,          /* enable writes */
+       SF_RD_DATA_FAST = 0xb,        /* read flash */
+       SF_ERASE_SECTOR = 0xd8,       /* erase sector */
+
+       FW_START_SEC = 8,             /* first flash sector for FW */
+       FW_END_SEC = 15,              /* last flash sector for FW */
+       FW_IMG_START = FW_START_SEC * SF_SEC_SIZE,
+       FW_MAX_SIZE = (FW_END_SEC - FW_START_SEC + 1) * SF_SEC_SIZE,
+};
+
+/**
+ *     sf1_read - read data from the serial flash
+ *     @adapter: the adapter
+ *     @byte_cnt: number of bytes to read
+ *     @cont: whether another operation will be chained
+ *     @lock: whether to lock SF for PL access only
+ *     @valp: where to store the read data
+ *
+ *     Reads up to 4 bytes of data from the serial flash.  The location of
+ *     the read needs to be specified prior to calling this by issuing the
+ *     appropriate commands to the serial flash.
+ */
+static int sf1_read(struct adapter *adapter, unsigned int byte_cnt, int cont,
+                   int lock, u32 *valp)
+{
+       int ret;
+
+       if (!byte_cnt || byte_cnt > 4)
+               return -EINVAL;
+       if (t4_read_reg(adapter, SF_OP) & BUSY)
+               return -EBUSY;
+       cont = cont ? SF_CONT : 0;
+       lock = lock ? SF_LOCK : 0;
+       t4_write_reg(adapter, SF_OP, lock | cont | BYTECNT(byte_cnt - 1));
+       ret = t4_wait_op_done(adapter, SF_OP, BUSY, 0, SF_ATTEMPTS, 5);
+       if (!ret)
+               *valp = t4_read_reg(adapter, SF_DATA);
+       return ret;
+}
+
+/**
+ *     sf1_write - write data to the serial flash
+ *     @adapter: the adapter
+ *     @byte_cnt: number of bytes to write
+ *     @cont: whether another operation will be chained
+ *     @lock: whether to lock SF for PL access only
+ *     @val: value to write
+ *
+ *     Writes up to 4 bytes of data to the serial flash.  The location of
+ *     the write needs to be specified prior to calling this by issuing the
+ *     appropriate commands to the serial flash.
+ */
+static int sf1_write(struct adapter *adapter, unsigned int byte_cnt, int cont,
+                    int lock, u32 val)
+{
+       if (!byte_cnt || byte_cnt > 4)
+               return -EINVAL;
+       if (t4_read_reg(adapter, SF_OP) & BUSY)
+               return -EBUSY;
+       cont = cont ? SF_CONT : 0;
+       lock = lock ? SF_LOCK : 0;
+       t4_write_reg(adapter, SF_DATA, val);
+       t4_write_reg(adapter, SF_OP, lock |
+                    cont | BYTECNT(byte_cnt - 1) | OP_WR);
+       return t4_wait_op_done(adapter, SF_OP, BUSY, 0, SF_ATTEMPTS, 5);
+}
+
+/**
+ *     flash_wait_op - wait for a flash operation to complete
+ *     @adapter: the adapter
+ *     @attempts: max number of polls of the status register
+ *     @delay: delay between polls in ms
+ *
+ *     Wait for a flash operation to complete by polling the status register.
+ */
+static int flash_wait_op(struct adapter *adapter, int attempts, int delay)
+{
+       int ret;
+       u32 status;
+
+       while (1) {
+               if ((ret = sf1_write(adapter, 1, 1, 1, SF_RD_STATUS)) != 0 ||
+                   (ret = sf1_read(adapter, 1, 0, 1, &status)) != 0)
+                       return ret;
+               if (!(status & 1))
+                       return 0;
+               if (--attempts == 0)
+                       return -EAGAIN;
+               if (delay)
+                       msleep(delay);
+       }
+}
+
+/**
+ *     t4_read_flash - read words from serial flash
+ *     @adapter: the adapter
+ *     @addr: the start address for the read
+ *     @nwords: how many 32-bit words to read
+ *     @data: where to store the read data
+ *     @byte_oriented: whether to store data as bytes or as words
+ *
+ *     Read the specified number of 32-bit words from the serial flash.
+ *     If @byte_oriented is set the read data is stored as a byte array
+ *     (i.e., big-endian), otherwise as 32-bit words in the platform's
+ *     natural endianess.
+ */
+int t4_read_flash(struct adapter *adapter, unsigned int addr,
+                 unsigned int nwords, u32 *data, int byte_oriented)
+{
+       int ret;
+
+       if (addr + nwords * sizeof(u32) > SF_SIZE || (addr & 3))
+               return -EINVAL;
+
+       addr = swab32(addr) | SF_RD_DATA_FAST;
+
+       if ((ret = sf1_write(adapter, 4, 1, 0, addr)) != 0 ||
+           (ret = sf1_read(adapter, 1, 1, 0, data)) != 0)
+               return ret;
+
+       for ( ; nwords; nwords--, data++) {
+               ret = sf1_read(adapter, 4, nwords > 1, nwords == 1, data);
+               if (nwords == 1)
+                       t4_write_reg(adapter, SF_OP, 0);    /* unlock SF */
+               if (ret)
+                       return ret;
+               if (byte_oriented)
+                       *data = htonl(*data);
+       }
+       return 0;
+}
+
+/**
+ *     t4_write_flash - write up to a page of data to the serial flash
+ *     @adapter: the adapter
+ *     @addr: the start address to write
+ *     @n: length of data to write in bytes
+ *     @data: the data to write
+ *
+ *     Writes up to a page of data (256 bytes) to the serial flash starting
+ *     at the given address.  All the data must be written to the same page.
+ */
+static int t4_write_flash(struct adapter *adapter, unsigned int addr,
+                         unsigned int n, const u8 *data)
+{
+       int ret;
+       u32 buf[64];
+       unsigned int i, c, left, val, offset = addr & 0xff;
+
+       if (addr >= SF_SIZE || offset + n > SF_PAGE_SIZE)
+               return -EINVAL;
+
+       val = swab32(addr) | SF_PROG_PAGE;
+
+       if ((ret = sf1_write(adapter, 1, 0, 1, SF_WR_ENABLE)) != 0 ||
+           (ret = sf1_write(adapter, 4, 1, 1, val)) != 0)
+               goto unlock;
+
+       for (left = n; left; left -= c) {
+               c = min(left, 4U);
+               for (val = 0, i = 0; i < c; ++i)
+                       val = (val << 8) + *data++;
+
+               ret = sf1_write(adapter, c, c != left, 1, val);
+               if (ret)
+                       goto unlock;
+       }
+       ret = flash_wait_op(adapter, 5, 1);
+       if (ret)
+               goto unlock;
+
+       t4_write_reg(adapter, SF_OP, 0);    /* unlock SF */
+
+       /* Read the page to verify the write succeeded */
+       ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, 1);
+       if (ret)
+               return ret;
+
+       if (memcmp(data - n, (u8 *)buf + offset, n)) {
+               dev_err(adapter->pdev_dev,
+                       "failed to correctly write the flash page at %#x\n",
+                       addr);
+               return -EIO;
+       }
+       return 0;
+
+unlock:
+       t4_write_reg(adapter, SF_OP, 0);    /* unlock SF */
+       return ret;
+}
+
+/**
+ *     get_fw_version - read the firmware version
+ *     @adapter: the adapter
+ *     @vers: where to place the version
+ *
+ *     Reads the FW version from flash.
+ */
+static int get_fw_version(struct adapter *adapter, u32 *vers)
+{
+       return t4_read_flash(adapter,
+                            FW_IMG_START + offsetof(struct fw_hdr, fw_ver), 1,
+                            vers, 0);
+}
+
+/**
+ *     get_tp_version - read the TP microcode version
+ *     @adapter: the adapter
+ *     @vers: where to place the version
+ *
+ *     Reads the TP microcode version from flash.
+ */
+static int get_tp_version(struct adapter *adapter, u32 *vers)
+{
+       return t4_read_flash(adapter, FW_IMG_START + offsetof(struct fw_hdr,
+                                                             tp_microcode_ver),
+                            1, vers, 0);
+}
+
+/**
+ *     t4_check_fw_version - check if the FW is compatible with this driver
+ *     @adapter: the adapter
+ *
+ *     Checks if an adapter's FW is compatible with the driver.  Returns 0
+ *     if there's exact match, a negative error if the version could not be
+ *     read or there's a major version mismatch, and a positive value if the
+ *     expected major version is found but there's a minor version mismatch.
+ */
+int t4_check_fw_version(struct adapter *adapter)
+{
+       u32 api_vers[2];
+       int ret, major, minor, micro;
+
+       ret = get_fw_version(adapter, &adapter->params.fw_vers);
+       if (!ret)
+               ret = get_tp_version(adapter, &adapter->params.tp_vers);
+       if (!ret)
+               ret = t4_read_flash(adapter,
+                       FW_IMG_START + offsetof(struct fw_hdr, intfver_nic),
+                       2, api_vers, 1);
+       if (ret)
+               return ret;
+
+       major = FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers);
+       minor = FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers);
+       micro = FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers);
+       memcpy(adapter->params.api_vers, api_vers,
+              sizeof(adapter->params.api_vers));
+
+       if (major != FW_VERSION_MAJOR) {            /* major mismatch - fail */
+               dev_err(adapter->pdev_dev,
+                       "card FW has major version %u, driver wants %u\n",
+                       major, FW_VERSION_MAJOR);
+               return -EINVAL;
+       }
+
+       if (minor == FW_VERSION_MINOR && micro == FW_VERSION_MICRO)
+               return 0;                                   /* perfect match */
+
+       /* Minor/micro version mismatch.  Report it but often it's OK. */
+       return 1;
+}
+
+/**
+ *     t4_flash_erase_sectors - erase a range of flash sectors
+ *     @adapter: the adapter
+ *     @start: the first sector to erase
+ *     @end: the last sector to erase
+ *
+ *     Erases the sectors in the given inclusive range.
+ */
+static int t4_flash_erase_sectors(struct adapter *adapter, int start, int end)
+{
+       int ret = 0;
+
+       while (start <= end) {
+               if ((ret = sf1_write(adapter, 1, 0, 1, SF_WR_ENABLE)) != 0 ||
+                   (ret = sf1_write(adapter, 4, 0, 1,
+                                    SF_ERASE_SECTOR | (start << 8))) != 0 ||
+                   (ret = flash_wait_op(adapter, 5, 500)) != 0) {
+                       dev_err(adapter->pdev_dev,
+                               "erase of flash sector %d failed, error %d\n",
+                               start, ret);
+                       break;
+               }
+               start++;
+       }
+       t4_write_reg(adapter, SF_OP, 0);    /* unlock SF */
+       return ret;
+}
+
+/**
+ *     t4_load_fw - download firmware
+ *     @adap: the adapter
+ *     @fw_data: the firmware image to write
+ *     @size: image size
+ *
+ *     Write the supplied firmware image to the card's serial flash.
+ */
+int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
+{
+       u32 csum;
+       int ret, addr;
+       unsigned int i;
+       u8 first_page[SF_PAGE_SIZE];
+       const u32 *p = (const u32 *)fw_data;
+       const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
+
+       if (!size) {
+               dev_err(adap->pdev_dev, "FW image has no data\n");
+               return -EINVAL;
+       }
+       if (size & 511) {
+               dev_err(adap->pdev_dev,
+                       "FW image size not multiple of 512 bytes\n");
+               return -EINVAL;
+       }
+       if (ntohs(hdr->len512) * 512 != size) {
+               dev_err(adap->pdev_dev,
+                       "FW image size differs from size in FW header\n");
+               return -EINVAL;
+       }
+       if (size > FW_MAX_SIZE) {
+               dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n",
+                       FW_MAX_SIZE);
+               return -EFBIG;
+       }
+
+       for (csum = 0, i = 0; i < size / sizeof(csum); i++)
+               csum += ntohl(p[i]);
+
+       if (csum != 0xffffffff) {
+               dev_err(adap->pdev_dev,
+                       "corrupted firmware image, checksum %#x\n", csum);
+               return -EINVAL;
+       }
+
+       i = DIV_ROUND_UP(size, SF_SEC_SIZE);        /* # of sectors spanned */
+       ret = t4_flash_erase_sectors(adap, FW_START_SEC, FW_START_SEC + i - 1);
+       if (ret)
+               goto out;
+
+       /*
+        * We write the correct version at the end so the driver can see a bad
+        * version if the FW write fails.  Start by writing a copy of the
+        * first page with a bad version.
+        */
+       memcpy(first_page, fw_data, SF_PAGE_SIZE);
+       ((struct fw_hdr *)first_page)->fw_ver = htonl(0xffffffff);
+       ret = t4_write_flash(adap, FW_IMG_START, SF_PAGE_SIZE, first_page);
+       if (ret)
+               goto out;
+
+       addr = FW_IMG_START;
+       for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {
+               addr += SF_PAGE_SIZE;
+               fw_data += SF_PAGE_SIZE;
+               ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data);
+               if (ret)
+                       goto out;
+       }
+
+       ret = t4_write_flash(adap,
+                            FW_IMG_START + offsetof(struct fw_hdr, fw_ver),
+                            sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);
+out:
+       if (ret)
+               dev_err(adap->pdev_dev, "firmware download failed, error %d\n",
+                       ret);
+       return ret;
+}
+
+#define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
+                    FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_ANEG)
+
+/**
+ *     t4_link_start - apply link configuration to MAC/PHY
+ *     @phy: the PHY to setup
+ *     @mac: the MAC to setup
+ *     @lc: the requested link configuration
+ *
+ *     Set up a port's MAC and PHY according to a desired link configuration.
+ *     - If the PHY can auto-negotiate first decide what to advertise, then
+ *       enable/disable auto-negotiation as desired, and reset.
+ *     - If the PHY does not auto-negotiate just reset it.
+ *     - If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
+ *       otherwise do it later based on the outcome of auto-negotiation.
+ */
+int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
+                 struct link_config *lc)
+{
+       struct fw_port_cmd c;
+       unsigned int fc = 0, mdi = FW_PORT_MDI(FW_PORT_MDI_AUTO);
+
+       lc->link_ok = 0;
+       if (lc->requested_fc & PAUSE_RX)
+               fc |= FW_PORT_CAP_FC_RX;
+       if (lc->requested_fc & PAUSE_TX)
+               fc |= FW_PORT_CAP_FC_TX;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) | FW_CMD_REQUEST |
+                              FW_CMD_EXEC | FW_PORT_CMD_PORTID(port));
+       c.action_to_len16 = htonl(FW_PORT_CMD_ACTION(FW_PORT_ACTION_L1_CFG) |
+                                 FW_LEN16(c));
+
+       if (!(lc->supported & FW_PORT_CAP_ANEG)) {
+               c.u.l1cfg.rcap = htonl((lc->supported & ADVERT_MASK) | fc);
+               lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
+       } else if (lc->autoneg == AUTONEG_DISABLE) {
+               c.u.l1cfg.rcap = htonl(lc->requested_speed | fc | mdi);
+               lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
+       } else
+               c.u.l1cfg.rcap = htonl(lc->advertising | fc | mdi);
+
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_restart_aneg - restart autonegotiation
+ *     @adap: the adapter
+ *     @mbox: mbox to use for the FW command
+ *     @port: the port id
+ *
+ *     Restarts autonegotiation for the selected port.
+ */
+int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port)
+{
+       struct fw_port_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) | FW_CMD_REQUEST |
+                              FW_CMD_EXEC | FW_PORT_CMD_PORTID(port));
+       c.action_to_len16 = htonl(FW_PORT_CMD_ACTION(FW_PORT_ACTION_L1_CFG) |
+                                 FW_LEN16(c));
+       c.u.l1cfg.rcap = htonl(FW_PORT_CAP_ANEG);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_set_vlan_accel - configure HW VLAN extraction
+ *     @adap: the adapter
+ *     @ports: bitmap of adapter ports to operate on
+ *     @on: enable (1) or disable (0) HW VLAN extraction
+ *
+ *     Enables or disables HW extraction of VLAN tags for the ports specified
+ *     by @ports.  @ports is a bitmap with the ith bit designating the port
+ *     associated with the ith adapter channel.
+ */
+void t4_set_vlan_accel(struct adapter *adap, unsigned int ports, int on)
+{
+       ports <<= VLANEXTENABLE_SHIFT;
+       t4_set_reg_field(adap, TP_OUT_CONFIG, ports, on ? ports : 0);
+}
+
+struct intr_info {
+       unsigned int mask;       /* bits to check in interrupt status */
+       const char *msg;         /* message to print or NULL */
+       short stat_idx;          /* stat counter to increment or -1 */
+       unsigned short fatal;    /* whether the condition reported is fatal */
+};
+
+/**
+ *     t4_handle_intr_status - table driven interrupt handler
+ *     @adapter: the adapter that generated the interrupt
+ *     @reg: the interrupt status register to process
+ *     @acts: table of interrupt actions
+ *
+ *     A table driven interrupt handler that applies a set of masks to an
+ *     interrupt status word and performs the corresponding actions if the
+ *     interrupts described by the mask have occured.  The actions include
+ *     optionally emitting a warning or alert message.  The table is terminated
+ *     by an entry specifying mask 0.  Returns the number of fatal interrupt
+ *     conditions.
+ */
+static int t4_handle_intr_status(struct adapter *adapter, unsigned int reg,
+                                const struct intr_info *acts)
+{
+       int fatal = 0;
+       unsigned int mask = 0;
+       unsigned int status = t4_read_reg(adapter, reg);
+
+       for ( ; acts->mask; ++acts) {
+               if (!(status & acts->mask))
+                       continue;
+               if (acts->fatal) {
+                       fatal++;
+                       dev_alert(adapter->pdev_dev, "%s (0x%x)\n", acts->msg,
+                                 status & acts->mask);
+               } else if (acts->msg && printk_ratelimit())
+                       dev_warn(adapter->pdev_dev, "%s (0x%x)\n", acts->msg,
+                                status & acts->mask);
+               mask |= acts->mask;
+       }
+       status &= mask;
+       if (status)                           /* clear processed interrupts */
+               t4_write_reg(adapter, reg, status);
+       return fatal;
+}
+
+/*
+ * Interrupt handler for the PCIE module.
+ */
+static void pcie_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info sysbus_intr_info[] = {
+               { RNPP, "RXNP array parity error", -1, 1 },
+               { RPCP, "RXPC array parity error", -1, 1 },
+               { RCIP, "RXCIF array parity error", -1, 1 },
+               { RCCP, "Rx completions control array parity error", -1, 1 },
+               { RFTP, "RXFT array parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info pcie_port_intr_info[] = {
+               { TPCP, "TXPC array parity error", -1, 1 },
+               { TNPP, "TXNP array parity error", -1, 1 },
+               { TFTP, "TXFT array parity error", -1, 1 },
+               { TCAP, "TXCA array parity error", -1, 1 },
+               { TCIP, "TXCIF array parity error", -1, 1 },
+               { RCAP, "RXCA array parity error", -1, 1 },
+               { OTDD, "outbound request TLP discarded", -1, 1 },
+               { RDPE, "Rx data parity error", -1, 1 },
+               { TDUE, "Tx uncorrectable data error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info pcie_intr_info[] = {
+               { MSIADDRLPERR, "MSI AddrL parity error", -1, 1 },
+               { MSIADDRHPERR, "MSI AddrH parity error", -1, 1 },
+               { MSIDATAPERR, "MSI data parity error", -1, 1 },
+               { MSIXADDRLPERR, "MSI-X AddrL parity error", -1, 1 },
+               { MSIXADDRHPERR, "MSI-X AddrH parity error", -1, 1 },
+               { MSIXDATAPERR, "MSI-X data parity error", -1, 1 },
+               { MSIXDIPERR, "MSI-X DI parity error", -1, 1 },
+               { PIOCPLPERR, "PCI PIO completion FIFO parity error", -1, 1 },
+               { PIOREQPERR, "PCI PIO request FIFO parity error", -1, 1 },
+               { TARTAGPERR, "PCI PCI target tag FIFO parity error", -1, 1 },
+               { CCNTPERR, "PCI CMD channel count parity error", -1, 1 },
+               { CREQPERR, "PCI CMD channel request parity error", -1, 1 },
+               { CRSPPERR, "PCI CMD channel response parity error", -1, 1 },
+               { DCNTPERR, "PCI DMA channel count parity error", -1, 1 },
+               { DREQPERR, "PCI DMA channel request parity error", -1, 1 },
+               { DRSPPERR, "PCI DMA channel response parity error", -1, 1 },
+               { HCNTPERR, "PCI HMA channel count parity error", -1, 1 },
+               { HREQPERR, "PCI HMA channel request parity error", -1, 1 },
+               { HRSPPERR, "PCI HMA channel response parity error", -1, 1 },
+               { CFGSNPPERR, "PCI config snoop FIFO parity error", -1, 1 },
+               { FIDPERR, "PCI FID parity error", -1, 1 },
+               { INTXCLRPERR, "PCI INTx clear parity error", -1, 1 },
+               { MATAGPERR, "PCI MA tag parity error", -1, 1 },
+               { PIOTAGPERR, "PCI PIO tag parity error", -1, 1 },
+               { RXCPLPERR, "PCI Rx completion parity error", -1, 1 },
+               { RXWRPERR, "PCI Rx write parity error", -1, 1 },
+               { RPLPERR, "PCI replay buffer parity error", -1, 1 },
+               { PCIESINT, "PCI core secondary fault", -1, 1 },
+               { PCIEPINT, "PCI core primary fault", -1, 1 },
+               { UNXSPLCPLERR, "PCI unexpected split completion error", -1, 0 },
+               { 0 }
+       };
+
+       int fat;
+
+       fat = t4_handle_intr_status(adapter,
+                                   PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
+                                   sysbus_intr_info) +
+             t4_handle_intr_status(adapter,
+                                   PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
+                                   pcie_port_intr_info) +
+             t4_handle_intr_status(adapter, PCIE_INT_CAUSE, pcie_intr_info);
+       if (fat)
+               t4_fatal_err(adapter);
+}
+
+/*
+ * TP interrupt handler.
+ */
+static void tp_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info tp_intr_info[] = {
+               { 0x3fffffff, "TP parity error", -1, 1 },
+               { FLMTXFLSTEMPTY, "TP out of Tx pages", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, TP_INT_CAUSE, tp_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * SGE interrupt handler.
+ */
+static void sge_intr_handler(struct adapter *adapter)
+{
+       u64 v;
+
+       static struct intr_info sge_intr_info[] = {
+               { ERR_CPL_EXCEED_IQE_SIZE,
+                 "SGE received CPL exceeding IQE size", -1, 1 },
+               { ERR_INVALID_CIDX_INC,
+                 "SGE GTS CIDX increment too large", -1, 0 },
+               { ERR_CPL_OPCODE_0, "SGE received 0-length CPL", -1, 0 },
+               { ERR_DROPPED_DB, "SGE doorbell dropped", -1, 0 },
+               { ERR_DATA_CPL_ON_HIGH_QID1 | ERR_DATA_CPL_ON_HIGH_QID0,
+                 "SGE IQID > 1023 received CPL for FL", -1, 0 },
+               { ERR_BAD_DB_PIDX3, "SGE DBP 3 pidx increment too large", -1,
+                 0 },
+               { ERR_BAD_DB_PIDX2, "SGE DBP 2 pidx increment too large", -1,
+                 0 },
+               { ERR_BAD_DB_PIDX1, "SGE DBP 1 pidx increment too large", -1,
+                 0 },
+               { ERR_BAD_DB_PIDX0, "SGE DBP 0 pidx increment too large", -1,
+                 0 },
+               { ERR_ING_CTXT_PRIO,
+                 "SGE too many priority ingress contexts", -1, 0 },
+               { ERR_EGR_CTXT_PRIO,
+                 "SGE too many priority egress contexts", -1, 0 },
+               { INGRESS_SIZE_ERR, "SGE illegal ingress QID", -1, 0 },
+               { EGRESS_SIZE_ERR, "SGE illegal egress QID", -1, 0 },
+               { 0 }
+       };
+
+       v = (u64)t4_read_reg(adapter, SGE_INT_CAUSE1) |
+           ((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
+       if (v) {
+               dev_alert(adapter->pdev_dev, "SGE parity error (%#llx)\n",
+                        (unsigned long long)v);
+               t4_write_reg(adapter, SGE_INT_CAUSE1, v);
+               t4_write_reg(adapter, SGE_INT_CAUSE2, v >> 32);
+       }
+
+       if (t4_handle_intr_status(adapter, SGE_INT_CAUSE3, sge_intr_info) ||
+           v != 0)
+               t4_fatal_err(adapter);
+}
+
+/*
+ * CIM interrupt handler.
+ */
+static void cim_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info cim_intr_info[] = {
+               { PREFDROPINT, "CIM control register prefetch drop", -1, 1 },
+               { OBQPARERR, "CIM OBQ parity error", -1, 1 },
+               { IBQPARERR, "CIM IBQ parity error", -1, 1 },
+               { MBUPPARERR, "CIM mailbox uP parity error", -1, 1 },
+               { MBHOSTPARERR, "CIM mailbox host parity error", -1, 1 },
+               { TIEQINPARERRINT, "CIM TIEQ outgoing parity error", -1, 1 },
+               { TIEQOUTPARERRINT, "CIM TIEQ incoming parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info cim_upintr_info[] = {
+               { RSVDSPACEINT, "CIM reserved space access", -1, 1 },
+               { ILLTRANSINT, "CIM illegal transaction", -1, 1 },
+               { ILLWRINT, "CIM illegal write", -1, 1 },
+               { ILLRDINT, "CIM illegal read", -1, 1 },
+               { ILLRDBEINT, "CIM illegal read BE", -1, 1 },
+               { ILLWRBEINT, "CIM illegal write BE", -1, 1 },
+               { SGLRDBOOTINT, "CIM single read from boot space", -1, 1 },
+               { SGLWRBOOTINT, "CIM single write to boot space", -1, 1 },
+               { BLKWRBOOTINT, "CIM block write to boot space", -1, 1 },
+               { SGLRDFLASHINT, "CIM single read from flash space", -1, 1 },
+               { SGLWRFLASHINT, "CIM single write to flash space", -1, 1 },
+               { BLKWRFLASHINT, "CIM block write to flash space", -1, 1 },
+               { SGLRDEEPROMINT, "CIM single EEPROM read", -1, 1 },
+               { SGLWREEPROMINT, "CIM single EEPROM write", -1, 1 },
+               { BLKRDEEPROMINT, "CIM block EEPROM read", -1, 1 },
+               { BLKWREEPROMINT, "CIM block EEPROM write", -1, 1 },
+               { SGLRDCTLINT , "CIM single read from CTL space", -1, 1 },
+               { SGLWRCTLINT , "CIM single write to CTL space", -1, 1 },
+               { BLKRDCTLINT , "CIM block read from CTL space", -1, 1 },
+               { BLKWRCTLINT , "CIM block write to CTL space", -1, 1 },
+               { SGLRDPLINT , "CIM single read from PL space", -1, 1 },
+               { SGLWRPLINT , "CIM single write to PL space", -1, 1 },
+               { BLKRDPLINT , "CIM block read from PL space", -1, 1 },
+               { BLKWRPLINT , "CIM block write to PL space", -1, 1 },
+               { REQOVRLOOKUPINT , "CIM request FIFO overwrite", -1, 1 },
+               { RSPOVRLOOKUPINT , "CIM response FIFO overwrite", -1, 1 },
+               { TIMEOUTINT , "CIM PIF timeout", -1, 1 },
+               { TIMEOUTMAINT , "CIM PIF MA timeout", -1, 1 },
+               { 0 }
+       };
+
+       int fat;
+
+       fat = t4_handle_intr_status(adapter, CIM_HOST_INT_CAUSE,
+                                   cim_intr_info) +
+             t4_handle_intr_status(adapter, CIM_HOST_UPACC_INT_CAUSE,
+                                   cim_upintr_info);
+       if (fat)
+               t4_fatal_err(adapter);
+}
+
+/*
+ * ULP RX interrupt handler.
+ */
+static void ulprx_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info ulprx_intr_info[] = {
+               { 0x7fffff, "ULPRX parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, ULP_RX_INT_CAUSE, ulprx_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * ULP TX interrupt handler.
+ */
+static void ulptx_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info ulptx_intr_info[] = {
+               { PBL_BOUND_ERR_CH3, "ULPTX channel 3 PBL out of bounds", -1,
+                 0 },
+               { PBL_BOUND_ERR_CH2, "ULPTX channel 2 PBL out of bounds", -1,
+                 0 },
+               { PBL_BOUND_ERR_CH1, "ULPTX channel 1 PBL out of bounds", -1,
+                 0 },
+               { PBL_BOUND_ERR_CH0, "ULPTX channel 0 PBL out of bounds", -1,
+                 0 },
+               { 0xfffffff, "ULPTX parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, ULP_TX_INT_CAUSE, ulptx_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * PM TX interrupt handler.
+ */
+static void pmtx_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info pmtx_intr_info[] = {
+               { PCMD_LEN_OVFL0, "PMTX channel 0 pcmd too large", -1, 1 },
+               { PCMD_LEN_OVFL1, "PMTX channel 1 pcmd too large", -1, 1 },
+               { PCMD_LEN_OVFL2, "PMTX channel 2 pcmd too large", -1, 1 },
+               { ZERO_C_CMD_ERROR, "PMTX 0-length pcmd", -1, 1 },
+               { PMTX_FRAMING_ERROR, "PMTX framing error", -1, 1 },
+               { OESPI_PAR_ERROR, "PMTX oespi parity error", -1, 1 },
+               { DB_OPTIONS_PAR_ERROR, "PMTX db_options parity error", -1, 1 },
+               { ICSPI_PAR_ERROR, "PMTX icspi parity error", -1, 1 },
+               { C_PCMD_PAR_ERROR, "PMTX c_pcmd parity error", -1, 1},
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, PM_TX_INT_CAUSE, pmtx_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * PM RX interrupt handler.
+ */
+static void pmrx_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info pmrx_intr_info[] = {
+               { ZERO_E_CMD_ERROR, "PMRX 0-length pcmd", -1, 1 },
+               { PMRX_FRAMING_ERROR, "PMRX framing error", -1, 1 },
+               { OCSPI_PAR_ERROR, "PMRX ocspi parity error", -1, 1 },
+               { DB_OPTIONS_PAR_ERROR, "PMRX db_options parity error", -1, 1 },
+               { IESPI_PAR_ERROR, "PMRX iespi parity error", -1, 1 },
+               { E_PCMD_PAR_ERROR, "PMRX e_pcmd parity error", -1, 1},
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, PM_RX_INT_CAUSE, pmrx_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * CPL switch interrupt handler.
+ */
+static void cplsw_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info cplsw_intr_info[] = {
+               { CIM_OP_MAP_PERR, "CPLSW CIM op_map parity error", -1, 1 },
+               { CIM_OVFL_ERROR, "CPLSW CIM overflow", -1, 1 },
+               { TP_FRAMING_ERROR, "CPLSW TP framing error", -1, 1 },
+               { SGE_FRAMING_ERROR, "CPLSW SGE framing error", -1, 1 },
+               { CIM_FRAMING_ERROR, "CPLSW CIM framing error", -1, 1 },
+               { ZERO_SWITCH_ERROR, "CPLSW no-switch error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adapter, CPL_INTR_CAUSE, cplsw_intr_info))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * LE interrupt handler.
+ */
+static void le_intr_handler(struct adapter *adap)
+{
+       static struct intr_info le_intr_info[] = {
+               { LIPMISS, "LE LIP miss", -1, 0 },
+               { LIP0, "LE 0 LIP error", -1, 0 },
+               { PARITYERR, "LE parity error", -1, 1 },
+               { UNKNOWNCMD, "LE unknown command", -1, 1 },
+               { REQQPARERR, "LE request queue parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adap, LE_DB_INT_CAUSE, le_intr_info))
+               t4_fatal_err(adap);
+}
+
+/*
+ * MPS interrupt handler.
+ */
+static void mps_intr_handler(struct adapter *adapter)
+{
+       static struct intr_info mps_rx_intr_info[] = {
+               { 0xffffff, "MPS Rx parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_tx_intr_info[] = {
+               { TPFIFO, "MPS Tx TP FIFO parity error", -1, 1 },
+               { NCSIFIFO, "MPS Tx NC-SI FIFO parity error", -1, 1 },
+               { TXDATAFIFO, "MPS Tx data FIFO parity error", -1, 1 },
+               { TXDESCFIFO, "MPS Tx desc FIFO parity error", -1, 1 },
+               { BUBBLE, "MPS Tx underflow", -1, 1 },
+               { SECNTERR, "MPS Tx SOP/EOP error", -1, 1 },
+               { FRMERR, "MPS Tx framing error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_trc_intr_info[] = {
+               { FILTMEM, "MPS TRC filter parity error", -1, 1 },
+               { PKTFIFO, "MPS TRC packet FIFO parity error", -1, 1 },
+               { MISCPERR, "MPS TRC misc parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_stat_sram_intr_info[] = {
+               { 0x1fffff, "MPS statistics SRAM parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_stat_tx_intr_info[] = {
+               { 0xfffff, "MPS statistics Tx FIFO parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_stat_rx_intr_info[] = {
+               { 0xffffff, "MPS statistics Rx FIFO parity error", -1, 1 },
+               { 0 }
+       };
+       static struct intr_info mps_cls_intr_info[] = {
+               { MATCHSRAM, "MPS match SRAM parity error", -1, 1 },
+               { MATCHTCAM, "MPS match TCAM parity error", -1, 1 },
+               { HASHSRAM, "MPS hash SRAM parity error", -1, 1 },
+               { 0 }
+       };
+
+       int fat;
+
+       fat = t4_handle_intr_status(adapter, MPS_RX_PERR_INT_CAUSE,
+                                   mps_rx_intr_info) +
+             t4_handle_intr_status(adapter, MPS_TX_INT_CAUSE,
+                                   mps_tx_intr_info) +
+             t4_handle_intr_status(adapter, MPS_TRC_INT_CAUSE,
+                                   mps_trc_intr_info) +
+             t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_SRAM,
+                                   mps_stat_sram_intr_info) +
+             t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_TX_FIFO,
+                                   mps_stat_tx_intr_info) +
+             t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_RX_FIFO,
+                                   mps_stat_rx_intr_info) +
+             t4_handle_intr_status(adapter, MPS_CLS_INT_CAUSE,
+                                   mps_cls_intr_info);
+
+       t4_write_reg(adapter, MPS_INT_CAUSE, CLSINT | TRCINT |
+                    RXINT | TXINT | STATINT);
+       t4_read_reg(adapter, MPS_INT_CAUSE);                    /* flush */
+       if (fat)
+               t4_fatal_err(adapter);
+}
+
+#define MEM_INT_MASK (PERR_INT_CAUSE | ECC_CE_INT_CAUSE | ECC_UE_INT_CAUSE)
+
+/*
+ * EDC/MC interrupt handler.
+ */
+static void mem_intr_handler(struct adapter *adapter, int idx)
+{
+       static const char name[3][5] = { "EDC0", "EDC1", "MC" };
+
+       unsigned int addr, cnt_addr, v;
+
+       if (idx <= MEM_EDC1) {
+               addr = EDC_REG(EDC_INT_CAUSE, idx);
+               cnt_addr = EDC_REG(EDC_ECC_STATUS, idx);
+       } else {
+               addr = MC_INT_CAUSE;
+               cnt_addr = MC_ECC_STATUS;
+       }
+
+       v = t4_read_reg(adapter, addr) & MEM_INT_MASK;
+       if (v & PERR_INT_CAUSE)
+               dev_alert(adapter->pdev_dev, "%s FIFO parity error\n",
+                         name[idx]);
+       if (v & ECC_CE_INT_CAUSE) {
+               u32 cnt = ECC_CECNT_GET(t4_read_reg(adapter, cnt_addr));
+
+               t4_write_reg(adapter, cnt_addr, ECC_CECNT_MASK);
+               if (printk_ratelimit())
+                       dev_warn(adapter->pdev_dev,
+                                "%u %s correctable ECC data error%s\n",
+                                cnt, name[idx], cnt > 1 ? "s" : "");
+       }
+       if (v & ECC_UE_INT_CAUSE)
+               dev_alert(adapter->pdev_dev,
+                         "%s uncorrectable ECC data error\n", name[idx]);
+
+       t4_write_reg(adapter, addr, v);
+       if (v & (PERR_INT_CAUSE | ECC_UE_INT_CAUSE))
+               t4_fatal_err(adapter);
+}
+
+/*
+ * MA interrupt handler.
+ */
+static void ma_intr_handler(struct adapter *adap)
+{
+       u32 v, status = t4_read_reg(adap, MA_INT_CAUSE);
+
+       if (status & MEM_PERR_INT_CAUSE)
+               dev_alert(adap->pdev_dev,
+                         "MA parity error, parity status %#x\n",
+                         t4_read_reg(adap, MA_PARITY_ERROR_STATUS));
+       if (status & MEM_WRAP_INT_CAUSE) {
+               v = t4_read_reg(adap, MA_INT_WRAP_STATUS);
+               dev_alert(adap->pdev_dev, "MA address wrap-around error by "
+                         "client %u to address %#x\n",
+                         MEM_WRAP_CLIENT_NUM_GET(v),
+                         MEM_WRAP_ADDRESS_GET(v) << 4);
+       }
+       t4_write_reg(adap, MA_INT_CAUSE, status);
+       t4_fatal_err(adap);
+}
+
+/*
+ * SMB interrupt handler.
+ */
+static void smb_intr_handler(struct adapter *adap)
+{
+       static struct intr_info smb_intr_info[] = {
+               { MSTTXFIFOPARINT, "SMB master Tx FIFO parity error", -1, 1 },
+               { MSTRXFIFOPARINT, "SMB master Rx FIFO parity error", -1, 1 },
+               { SLVFIFOPARINT, "SMB slave FIFO parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adap, SMB_INT_CAUSE, smb_intr_info))
+               t4_fatal_err(adap);
+}
+
+/*
+ * NC-SI interrupt handler.
+ */
+static void ncsi_intr_handler(struct adapter *adap)
+{
+       static struct intr_info ncsi_intr_info[] = {
+               { CIM_DM_PRTY_ERR, "NC-SI CIM parity error", -1, 1 },
+               { MPS_DM_PRTY_ERR, "NC-SI MPS parity error", -1, 1 },
+               { TXFIFO_PRTY_ERR, "NC-SI Tx FIFO parity error", -1, 1 },
+               { RXFIFO_PRTY_ERR, "NC-SI Rx FIFO parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adap, NCSI_INT_CAUSE, ncsi_intr_info))
+               t4_fatal_err(adap);
+}
+
+/*
+ * XGMAC interrupt handler.
+ */
+static void xgmac_intr_handler(struct adapter *adap, int port)
+{
+       u32 v = t4_read_reg(adap, PORT_REG(port, XGMAC_PORT_INT_CAUSE));
+
+       v &= TXFIFO_PRTY_ERR | RXFIFO_PRTY_ERR;
+       if (!v)
+               return;
+
+       if (v & TXFIFO_PRTY_ERR)
+               dev_alert(adap->pdev_dev, "XGMAC %d Tx FIFO parity error\n",
+                         port);
+       if (v & RXFIFO_PRTY_ERR)
+               dev_alert(adap->pdev_dev, "XGMAC %d Rx FIFO parity error\n",
+                         port);
+       t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_INT_CAUSE), v);
+       t4_fatal_err(adap);
+}
+
+/*
+ * PL interrupt handler.
+ */
+static void pl_intr_handler(struct adapter *adap)
+{
+       static struct intr_info pl_intr_info[] = {
+               { FATALPERR, "T4 fatal parity error", -1, 1 },
+               { PERRVFID, "PL VFID_MAP parity error", -1, 1 },
+               { 0 }
+       };
+
+       if (t4_handle_intr_status(adap, PL_PL_INT_CAUSE, pl_intr_info))
+               t4_fatal_err(adap);
+}
+
+#define PF_INTR_MASK (PFSW | PFCIM)
+#define GLBL_INTR_MASK (CIM | MPS | PL | PCIE | MC | EDC0 | \
+               EDC1 | LE | TP | MA | PM_TX | PM_RX | ULP_RX | \
+               CPL_SWITCH | SGE | ULP_TX)
+
+/**
+ *     t4_slow_intr_handler - control path interrupt handler
+ *     @adapter: the adapter
+ *
+ *     T4 interrupt handler for non-data global interrupt events, e.g., errors.
+ *     The designation 'slow' is because it involves register reads, while
+ *     data interrupts typically don't involve any MMIOs.
+ */
+int t4_slow_intr_handler(struct adapter *adapter)
+{
+       u32 cause = t4_read_reg(adapter, PL_INT_CAUSE);
+
+       if (!(cause & GLBL_INTR_MASK))
+               return 0;
+       if (cause & CIM)
+               cim_intr_handler(adapter);
+       if (cause & MPS)
+               mps_intr_handler(adapter);
+       if (cause & NCSI)
+               ncsi_intr_handler(adapter);
+       if (cause & PL)
+               pl_intr_handler(adapter);
+       if (cause & SMB)
+               smb_intr_handler(adapter);
+       if (cause & XGMAC0)
+               xgmac_intr_handler(adapter, 0);
+       if (cause & XGMAC1)
+               xgmac_intr_handler(adapter, 1);
+       if (cause & XGMAC_KR0)
+               xgmac_intr_handler(adapter, 2);
+       if (cause & XGMAC_KR1)
+               xgmac_intr_handler(adapter, 3);
+       if (cause & PCIE)
+               pcie_intr_handler(adapter);
+       if (cause & MC)
+               mem_intr_handler(adapter, MEM_MC);
+       if (cause & EDC0)
+               mem_intr_handler(adapter, MEM_EDC0);
+       if (cause & EDC1)
+               mem_intr_handler(adapter, MEM_EDC1);
+       if (cause & LE)
+               le_intr_handler(adapter);
+       if (cause & TP)
+               tp_intr_handler(adapter);
+       if (cause & MA)
+               ma_intr_handler(adapter);
+       if (cause & PM_TX)
+               pmtx_intr_handler(adapter);
+       if (cause & PM_RX)
+               pmrx_intr_handler(adapter);
+       if (cause & ULP_RX)
+               ulprx_intr_handler(adapter);
+       if (cause & CPL_SWITCH)
+               cplsw_intr_handler(adapter);
+       if (cause & SGE)
+               sge_intr_handler(adapter);
+       if (cause & ULP_TX)
+               ulptx_intr_handler(adapter);
+
+       /* Clear the interrupts just processed for which we are the master. */
+       t4_write_reg(adapter, PL_INT_CAUSE, cause & GLBL_INTR_MASK);
+       (void) t4_read_reg(adapter, PL_INT_CAUSE); /* flush */
+       return 1;
+}
+
+/**
+ *     t4_intr_enable - enable interrupts
+ *     @adapter: the adapter whose interrupts should be enabled
+ *
+ *     Enable PF-specific interrupts for the calling function and the top-level
+ *     interrupt concentrator for global interrupts.  Interrupts are already
+ *     enabled at each module, here we just enable the roots of the interrupt
+ *     hierarchies.
+ *
+ *     Note: this function should be called only when the driver manages
+ *     non PF-specific interrupts from the various HW modules.  Only one PCI
+ *     function at a time should be doing this.
+ */
+void t4_intr_enable(struct adapter *adapter)
+{
+       u32 pf = SOURCEPF_GET(t4_read_reg(adapter, PL_WHOAMI));
+
+       t4_write_reg(adapter, SGE_INT_ENABLE3, ERR_CPL_EXCEED_IQE_SIZE |
+                    ERR_INVALID_CIDX_INC | ERR_CPL_OPCODE_0 |
+                    ERR_DROPPED_DB | ERR_DATA_CPL_ON_HIGH_QID1 |
+                    ERR_DATA_CPL_ON_HIGH_QID0 | ERR_BAD_DB_PIDX3 |
+                    ERR_BAD_DB_PIDX2 | ERR_BAD_DB_PIDX1 |
+                    ERR_BAD_DB_PIDX0 | ERR_ING_CTXT_PRIO |
+                    ERR_EGR_CTXT_PRIO | INGRESS_SIZE_ERR |
+                    EGRESS_SIZE_ERR);
+       t4_write_reg(adapter, MYPF_REG(PL_PF_INT_ENABLE), PF_INTR_MASK);
+       t4_set_reg_field(adapter, PL_INT_MAP0, 0, 1 << pf);
+}
+
+/**
+ *     t4_intr_disable - disable interrupts
+ *     @adapter: the adapter whose interrupts should be disabled
+ *
+ *     Disable interrupts.  We only disable the top-level interrupt
+ *     concentrators.  The caller must be a PCI function managing global
+ *     interrupts.
+ */
+void t4_intr_disable(struct adapter *adapter)
+{
+       u32 pf = SOURCEPF_GET(t4_read_reg(adapter, PL_WHOAMI));
+
+       t4_write_reg(adapter, MYPF_REG(PL_PF_INT_ENABLE), 0);
+       t4_set_reg_field(adapter, PL_INT_MAP0, 1 << pf, 0);
+}
+
+/**
+ *     t4_intr_clear - clear all interrupts
+ *     @adapter: the adapter whose interrupts should be cleared
+ *
+ *     Clears all interrupts.  The caller must be a PCI function managing
+ *     global interrupts.
+ */
+void t4_intr_clear(struct adapter *adapter)
+{
+       static const unsigned int cause_reg[] = {
+               SGE_INT_CAUSE1, SGE_INT_CAUSE2, SGE_INT_CAUSE3,
+               PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
+               PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
+               PCIE_NONFAT_ERR, PCIE_INT_CAUSE,
+               MC_INT_CAUSE,
+               MA_INT_WRAP_STATUS, MA_PARITY_ERROR_STATUS, MA_INT_CAUSE,
+               EDC_INT_CAUSE, EDC_REG(EDC_INT_CAUSE, 1),
+               CIM_HOST_INT_CAUSE, CIM_HOST_UPACC_INT_CAUSE,
+               MYPF_REG(CIM_PF_HOST_INT_CAUSE),
+               TP_INT_CAUSE,
+               ULP_RX_INT_CAUSE, ULP_TX_INT_CAUSE,
+               PM_RX_INT_CAUSE, PM_TX_INT_CAUSE,
+               MPS_RX_PERR_INT_CAUSE,
+               CPL_INTR_CAUSE,
+               MYPF_REG(PL_PF_INT_CAUSE),
+               PL_PL_INT_CAUSE,
+               LE_DB_INT_CAUSE,
+       };
+
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(cause_reg); ++i)
+               t4_write_reg(adapter, cause_reg[i], 0xffffffff);
+
+       t4_write_reg(adapter, PL_INT_CAUSE, GLBL_INTR_MASK);
+       (void) t4_read_reg(adapter, PL_INT_CAUSE);          /* flush */
+}
+
+/**
+ *     hash_mac_addr - return the hash value of a MAC address
+ *     @addr: the 48-bit Ethernet MAC address
+ *
+ *     Hashes a MAC address according to the hash function used by HW inexact
+ *     (hash) address matching.
+ */
+static int hash_mac_addr(const u8 *addr)
+{
+       u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
+       u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
+       a ^= b;
+       a ^= (a >> 12);
+       a ^= (a >> 6);
+       return a & 0x3f;
+}
+
+/**
+ *     t4_config_rss_range - configure a portion of the RSS mapping table
+ *     @adapter: the adapter
+ *     @mbox: mbox to use for the FW command
+ *     @viid: virtual interface whose RSS subtable is to be written
+ *     @start: start entry in the table to write
+ *     @n: how many table entries to write
+ *     @rspq: values for the response queue lookup table
+ *     @nrspq: number of values in @rspq
+ *
+ *     Programs the selected part of the VI's RSS mapping table with the
+ *     provided values.  If @nrspq < @n the supplied values are used repeatedly
+ *     until the full table range is populated.
+ *
+ *     The caller must ensure the values in @rspq are in the range allowed for
+ *     @viid.
+ */
+int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
+                       int start, int n, const u16 *rspq, unsigned int nrspq)
+{
+       int ret;
+       const u16 *rsp = rspq;
+       const u16 *rsp_end = rspq + nrspq;
+       struct fw_rss_ind_tbl_cmd cmd;
+
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.op_to_viid = htonl(FW_CMD_OP(FW_RSS_IND_TBL_CMD) |
+                              FW_CMD_REQUEST | FW_CMD_WRITE |
+                              FW_RSS_IND_TBL_CMD_VIID(viid));
+       cmd.retval_len16 = htonl(FW_LEN16(cmd));
+
+       /* each fw_rss_ind_tbl_cmd takes up to 32 entries */
+       while (n > 0) {
+               int nq = min(n, 32);
+               __be32 *qp = &cmd.iq0_to_iq2;
+
+               cmd.niqid = htons(nq);
+               cmd.startidx = htons(start);
+
+               start += nq;
+               n -= nq;
+
+               while (nq > 0) {
+                       unsigned int v;
+
+                       v = FW_RSS_IND_TBL_CMD_IQ0(*rsp);
+                       if (++rsp >= rsp_end)
+                               rsp = rspq;
+                       v |= FW_RSS_IND_TBL_CMD_IQ1(*rsp);
+                       if (++rsp >= rsp_end)
+                               rsp = rspq;
+                       v |= FW_RSS_IND_TBL_CMD_IQ2(*rsp);
+                       if (++rsp >= rsp_end)
+                               rsp = rspq;
+
+                       *qp++ = htonl(v);
+                       nq -= 3;
+               }
+
+               ret = t4_wr_mbox(adapter, mbox, &cmd, sizeof(cmd), NULL);
+               if (ret)
+                       return ret;
+       }
+       return 0;
+}
+
+/**
+ *     t4_config_glbl_rss - configure the global RSS mode
+ *     @adapter: the adapter
+ *     @mbox: mbox to use for the FW command
+ *     @mode: global RSS mode
+ *     @flags: mode-specific flags
+ *
+ *     Sets the global RSS mode.
+ */
+int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
+                      unsigned int flags)
+{
+       struct fw_rss_glb_config_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_write = htonl(FW_CMD_OP(FW_RSS_GLB_CONFIG_CMD) |
+                             FW_CMD_REQUEST | FW_CMD_WRITE);
+       c.retval_len16 = htonl(FW_LEN16(c));
+       if (mode == FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL) {
+               c.u.manual.mode_pkd = htonl(FW_RSS_GLB_CONFIG_CMD_MODE(mode));
+       } else if (mode == FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL) {
+               c.u.basicvirtual.mode_pkd =
+                       htonl(FW_RSS_GLB_CONFIG_CMD_MODE(mode));
+               c.u.basicvirtual.synmapen_to_hashtoeplitz = htonl(flags);
+       } else
+               return -EINVAL;
+       return t4_wr_mbox(adapter, mbox, &c, sizeof(c), NULL);
+}
+
+/* Read an RSS table row */
+static int rd_rss_row(struct adapter *adap, int row, u32 *val)
+{
+       t4_write_reg(adap, TP_RSS_LKP_TABLE, 0xfff00000 | row);
+       return t4_wait_op_done_val(adap, TP_RSS_LKP_TABLE, LKPTBLROWVLD, 1,
+                                  5, 0, val);
+}
+
+/**
+ *     t4_read_rss - read the contents of the RSS mapping table
+ *     @adapter: the adapter
+ *     @map: holds the contents of the RSS mapping table
+ *
+ *     Reads the contents of the RSS hash->queue mapping table.
+ */
+int t4_read_rss(struct adapter *adapter, u16 *map)
+{
+       u32 val;
+       int i, ret;
+
+       for (i = 0; i < RSS_NENTRIES / 2; ++i) {
+               ret = rd_rss_row(adapter, i, &val);
+               if (ret)
+                       return ret;
+               *map++ = LKPTBLQUEUE0_GET(val);
+               *map++ = LKPTBLQUEUE1_GET(val);
+       }
+       return 0;
+}
+
+/**
+ *     t4_tp_get_tcp_stats - read TP's TCP MIB counters
+ *     @adap: the adapter
+ *     @v4: holds the TCP/IP counter values
+ *     @v6: holds the TCP/IPv6 counter values
+ *
+ *     Returns the values of TP's TCP/IP and TCP/IPv6 MIB counters.
+ *     Either @v4 or @v6 may be %NULL to skip the corresponding stats.
+ */
+void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
+                        struct tp_tcp_stats *v6)
+{
+       u32 val[TP_MIB_TCP_RXT_SEG_LO - TP_MIB_TCP_OUT_RST + 1];
+
+#define STAT_IDX(x) ((TP_MIB_TCP_##x) - TP_MIB_TCP_OUT_RST)
+#define STAT(x)     val[STAT_IDX(x)]
+#define STAT64(x)   (((u64)STAT(x##_HI) << 32) | STAT(x##_LO))
+
+       if (v4) {
+               t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, val,
+                                ARRAY_SIZE(val), TP_MIB_TCP_OUT_RST);
+               v4->tcpOutRsts = STAT(OUT_RST);
+               v4->tcpInSegs  = STAT64(IN_SEG);
+               v4->tcpOutSegs = STAT64(OUT_SEG);
+               v4->tcpRetransSegs = STAT64(RXT_SEG);
+       }
+       if (v6) {
+               t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, val,
+                                ARRAY_SIZE(val), TP_MIB_TCP_V6OUT_RST);
+               v6->tcpOutRsts = STAT(OUT_RST);
+               v6->tcpInSegs  = STAT64(IN_SEG);
+               v6->tcpOutSegs = STAT64(OUT_SEG);
+               v6->tcpRetransSegs = STAT64(RXT_SEG);
+       }
+#undef STAT64
+#undef STAT
+#undef STAT_IDX
+}
+
+/**
+ *     t4_tp_get_err_stats - read TP's error MIB counters
+ *     @adap: the adapter
+ *     @st: holds the counter values
+ *
+ *     Returns the values of TP's error counters.
+ */
+void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st)
+{
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->macInErrs,
+                        12, TP_MIB_MAC_IN_ERR_0);
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlCongDrops,
+                        8, TP_MIB_TNL_CNG_DROP_0);
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlTxDrops,
+                        4, TP_MIB_TNL_DROP_0);
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->ofldVlanDrops,
+                        4, TP_MIB_OFD_VLN_DROP_0);
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tcp6InErrs,
+                        4, TP_MIB_TCP_V6IN_ERR_0);
+       t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, &st->ofldNoNeigh,
+                        2, TP_MIB_OFD_ARP_DROP);
+}
+
+/**
+ *     t4_read_mtu_tbl - returns the values in the HW path MTU table
+ *     @adap: the adapter
+ *     @mtus: where to store the MTU values
+ *     @mtu_log: where to store the MTU base-2 log (may be %NULL)
+ *
+ *     Reads the HW path MTU table.
+ */
+void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log)
+{
+       u32 v;
+       int i;
+
+       for (i = 0; i < NMTUS; ++i) {
+               t4_write_reg(adap, TP_MTU_TABLE,
+                            MTUINDEX(0xff) | MTUVALUE(i));
+               v = t4_read_reg(adap, TP_MTU_TABLE);
+               mtus[i] = MTUVALUE_GET(v);
+               if (mtu_log)
+                       mtu_log[i] = MTUWIDTH_GET(v);
+       }
+}
+
+/**
+ *     init_cong_ctrl - initialize congestion control parameters
+ *     @a: the alpha values for congestion control
+ *     @b: the beta values for congestion control
+ *
+ *     Initialize the congestion control parameters.
+ */
+static void __devinit init_cong_ctrl(unsigned short *a, unsigned short *b)
+{
+       a[0] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = 1;
+       a[9] = 2;
+       a[10] = 3;
+       a[11] = 4;
+       a[12] = 5;
+       a[13] = 6;
+       a[14] = 7;
+       a[15] = 8;
+       a[16] = 9;
+       a[17] = 10;
+       a[18] = 14;
+       a[19] = 17;
+       a[20] = 21;
+       a[21] = 25;
+       a[22] = 30;
+       a[23] = 35;
+       a[24] = 45;
+       a[25] = 60;
+       a[26] = 80;
+       a[27] = 100;
+       a[28] = 200;
+       a[29] = 300;
+       a[30] = 400;
+       a[31] = 500;
+
+       b[0] = b[1] = b[2] = b[3] = b[4] = b[5] = b[6] = b[7] = b[8] = 0;
+       b[9] = b[10] = 1;
+       b[11] = b[12] = 2;
+       b[13] = b[14] = b[15] = b[16] = 3;
+       b[17] = b[18] = b[19] = b[20] = b[21] = 4;
+       b[22] = b[23] = b[24] = b[25] = b[26] = b[27] = 5;
+       b[28] = b[29] = 6;
+       b[30] = b[31] = 7;
+}
+
+/* The minimum additive increment value for the congestion control table */
+#define CC_MIN_INCR 2U
+
+/**
+ *     t4_load_mtus - write the MTU and congestion control HW tables
+ *     @adap: the adapter
+ *     @mtus: the values for the MTU table
+ *     @alpha: the values for the congestion control alpha parameter
+ *     @beta: the values for the congestion control beta parameter
+ *
+ *     Write the HW MTU table with the supplied MTUs and the high-speed
+ *     congestion control table with the supplied alpha, beta, and MTUs.
+ *     We write the two tables together because the additive increments
+ *     depend on the MTUs.
+ */
+void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
+                 const unsigned short *alpha, const unsigned short *beta)
+{
+       static const unsigned int avg_pkts[NCCTRL_WIN] = {
+               2, 6, 10, 14, 20, 28, 40, 56, 80, 112, 160, 224, 320, 448, 640,
+               896, 1281, 1792, 2560, 3584, 5120, 7168, 10240, 14336, 20480,
+               28672, 40960, 57344, 81920, 114688, 163840, 229376
+       };
+
+       unsigned int i, w;
+
+       for (i = 0; i < NMTUS; ++i) {
+               unsigned int mtu = mtus[i];
+               unsigned int log2 = fls(mtu);
+
+               if (!(mtu & ((1 << log2) >> 2)))     /* round */
+                       log2--;
+               t4_write_reg(adap, TP_MTU_TABLE, MTUINDEX(i) |
+                            MTUWIDTH(log2) | MTUVALUE(mtu));
+
+               for (w = 0; w < NCCTRL_WIN; ++w) {
+                       unsigned int inc;
+
+                       inc = max(((mtu - 40) * alpha[w]) / avg_pkts[w],
+                                 CC_MIN_INCR);
+
+                       t4_write_reg(adap, TP_CCTRL_TABLE, (i << 21) |
+                                    (w << 16) | (beta[w] << 13) | inc);
+               }
+       }
+}
+
+/**
+ *     t4_set_trace_filter - configure one of the tracing filters
+ *     @adap: the adapter
+ *     @tp: the desired trace filter parameters
+ *     @idx: which filter to configure
+ *     @enable: whether to enable or disable the filter
+ *
+ *     Configures one of the tracing filters available in HW.  If @enable is
+ *     %0 @tp is not examined and may be %NULL.
+ */
+int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp,
+                       int idx, int enable)
+{
+       int i, ofst = idx * 4;
+       u32 data_reg, mask_reg, cfg;
+       u32 multitrc = TRCMULTIFILTER;
+
+       if (!enable) {
+               t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
+               goto out;
+       }
+
+       if (tp->port > 11 || tp->invert > 1 || tp->skip_len > 0x1f ||
+           tp->skip_ofst > 0x1f || tp->min_len > 0x1ff ||
+           tp->snap_len > 9600 || (idx && tp->snap_len > 256))
+               return -EINVAL;
+
+       if (tp->snap_len > 256) {            /* must be tracer 0 */
+               if ((t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 4) |
+                    t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 8) |
+                    t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 12)) & TFEN)
+                       return -EINVAL;  /* other tracers are enabled */
+               multitrc = 0;
+       } else if (idx) {
+               i = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B);
+               if (TFCAPTUREMAX_GET(i) > 256 &&
+                   (t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A) & TFEN))
+                       return -EINVAL;
+       }
+
+       /* stop the tracer we'll be changing */
+       t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
+
+       /* disable tracing globally if running in the wrong single/multi mode */
+       cfg = t4_read_reg(adap, MPS_TRC_CFG);
+       if ((cfg & TRCEN) && multitrc != (cfg & TRCMULTIFILTER)) {
+               t4_write_reg(adap, MPS_TRC_CFG, cfg ^ TRCEN);
+               t4_read_reg(adap, MPS_TRC_CFG);                  /* flush */
+               msleep(1);
+               if (!(t4_read_reg(adap, MPS_TRC_CFG) & TRCFIFOEMPTY))
+                       return -ETIMEDOUT;
+       }
+       /*
+        * At this point either the tracing is enabled and in the right mode or
+        * disabled.
+        */
+
+       idx *= (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH);
+       data_reg = MPS_TRC_FILTER0_MATCH + idx;
+       mask_reg = MPS_TRC_FILTER0_DONT_CARE + idx;
+
+       for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
+               t4_write_reg(adap, data_reg, tp->data[i]);
+               t4_write_reg(adap, mask_reg, ~tp->mask[i]);
+       }
+       t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst,
+                    TFCAPTUREMAX(tp->snap_len) |
+                    TFMINPKTSIZE(tp->min_len));
+       t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst,
+                    TFOFFSET(tp->skip_ofst) | TFLENGTH(tp->skip_len) |
+                    TFPORT(tp->port) | TFEN |
+                    (tp->invert ? TFINVERTMATCH : 0));
+
+       cfg &= ~TRCMULTIFILTER;
+       t4_write_reg(adap, MPS_TRC_CFG, cfg | TRCEN | multitrc);
+out:   t4_read_reg(adap, MPS_TRC_CFG);  /* flush */
+       return 0;
+}
+
+/**
+ *     t4_get_trace_filter - query one of the tracing filters
+ *     @adap: the adapter
+ *     @tp: the current trace filter parameters
+ *     @idx: which trace filter to query
+ *     @enabled: non-zero if the filter is enabled
+ *
+ *     Returns the current settings of one of the HW tracing filters.
+ */
+void t4_get_trace_filter(struct adapter *adap, struct trace_params *tp, int idx,
+                        int *enabled)
+{
+       u32 ctla, ctlb;
+       int i, ofst = idx * 4;
+       u32 data_reg, mask_reg;
+
+       ctla = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst);
+       ctlb = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst);
+
+       *enabled = !!(ctla & TFEN);
+       tp->snap_len = TFCAPTUREMAX_GET(ctlb);
+       tp->min_len = TFMINPKTSIZE_GET(ctlb);
+       tp->skip_ofst = TFOFFSET_GET(ctla);
+       tp->skip_len = TFLENGTH_GET(ctla);
+       tp->invert = !!(ctla & TFINVERTMATCH);
+       tp->port = TFPORT_GET(ctla);
+
+       ofst = (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH) * idx;
+       data_reg = MPS_TRC_FILTER0_MATCH + ofst;
+       mask_reg = MPS_TRC_FILTER0_DONT_CARE + ofst;
+
+       for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
+               tp->mask[i] = ~t4_read_reg(adap, mask_reg);
+               tp->data[i] = t4_read_reg(adap, data_reg) & tp->mask[i];
+       }
+}
+
+/**
+ *     get_mps_bg_map - return the buffer groups associated with a port
+ *     @adap: the adapter
+ *     @idx: the port index
+ *
+ *     Returns a bitmap indicating which MPS buffer groups are associated
+ *     with the given port.  Bit i is set if buffer group i is used by the
+ *     port.
+ */
+static unsigned int get_mps_bg_map(struct adapter *adap, int idx)
+{
+       u32 n = NUMPORTS_GET(t4_read_reg(adap, MPS_CMN_CTL));
+
+       if (n == 0)
+               return idx == 0 ? 0xf : 0;
+       if (n == 1)
+               return idx < 2 ? (3 << (2 * idx)) : 0;
+       return 1 << idx;
+}
+
+/**
+ *     t4_get_port_stats - collect port statistics
+ *     @adap: the adapter
+ *     @idx: the port index
+ *     @p: the stats structure to fill
+ *
+ *     Collect statistics related to the given port from HW.
+ */
+void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
+{
+       u32 bgmap = get_mps_bg_map(adap, idx);
+
+#define GET_STAT(name) \
+       t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_##name##_L))
+#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
+
+       p->tx_octets           = GET_STAT(TX_PORT_BYTES);
+       p->tx_frames           = GET_STAT(TX_PORT_FRAMES);
+       p->tx_bcast_frames     = GET_STAT(TX_PORT_BCAST);
+       p->tx_mcast_frames     = GET_STAT(TX_PORT_MCAST);
+       p->tx_ucast_frames     = GET_STAT(TX_PORT_UCAST);
+       p->tx_error_frames     = GET_STAT(TX_PORT_ERROR);
+       p->tx_frames_64        = GET_STAT(TX_PORT_64B);
+       p->tx_frames_65_127    = GET_STAT(TX_PORT_65B_127B);
+       p->tx_frames_128_255   = GET_STAT(TX_PORT_128B_255B);
+       p->tx_frames_256_511   = GET_STAT(TX_PORT_256B_511B);
+       p->tx_frames_512_1023  = GET_STAT(TX_PORT_512B_1023B);
+       p->tx_frames_1024_1518 = GET_STAT(TX_PORT_1024B_1518B);
+       p->tx_frames_1519_max  = GET_STAT(TX_PORT_1519B_MAX);
+       p->tx_drop             = GET_STAT(TX_PORT_DROP);
+       p->tx_pause            = GET_STAT(TX_PORT_PAUSE);
+       p->tx_ppp0             = GET_STAT(TX_PORT_PPP0);
+       p->tx_ppp1             = GET_STAT(TX_PORT_PPP1);
+       p->tx_ppp2             = GET_STAT(TX_PORT_PPP2);
+       p->tx_ppp3             = GET_STAT(TX_PORT_PPP3);
+       p->tx_ppp4             = GET_STAT(TX_PORT_PPP4);
+       p->tx_ppp5             = GET_STAT(TX_PORT_PPP5);
+       p->tx_ppp6             = GET_STAT(TX_PORT_PPP6);
+       p->tx_ppp7             = GET_STAT(TX_PORT_PPP7);
+
+       p->rx_octets           = GET_STAT(RX_PORT_BYTES);
+       p->rx_frames           = GET_STAT(RX_PORT_FRAMES);
+       p->rx_bcast_frames     = GET_STAT(RX_PORT_BCAST);
+       p->rx_mcast_frames     = GET_STAT(RX_PORT_MCAST);
+       p->rx_ucast_frames     = GET_STAT(RX_PORT_UCAST);
+       p->rx_too_long         = GET_STAT(RX_PORT_MTU_ERROR);
+       p->rx_jabber           = GET_STAT(RX_PORT_MTU_CRC_ERROR);
+       p->rx_fcs_err          = GET_STAT(RX_PORT_CRC_ERROR);
+       p->rx_len_err          = GET_STAT(RX_PORT_LEN_ERROR);
+       p->rx_symbol_err       = GET_STAT(RX_PORT_SYM_ERROR);
+       p->rx_runt             = GET_STAT(RX_PORT_LESS_64B);
+       p->rx_frames_64        = GET_STAT(RX_PORT_64B);
+       p->rx_frames_65_127    = GET_STAT(RX_PORT_65B_127B);
+       p->rx_frames_128_255   = GET_STAT(RX_PORT_128B_255B);
+       p->rx_frames_256_511   = GET_STAT(RX_PORT_256B_511B);
+       p->rx_frames_512_1023  = GET_STAT(RX_PORT_512B_1023B);
+       p->rx_frames_1024_1518 = GET_STAT(RX_PORT_1024B_1518B);
+       p->rx_frames_1519_max  = GET_STAT(RX_PORT_1519B_MAX);
+       p->rx_pause            = GET_STAT(RX_PORT_PAUSE);
+       p->rx_ppp0             = GET_STAT(RX_PORT_PPP0);
+       p->rx_ppp1             = GET_STAT(RX_PORT_PPP1);
+       p->rx_ppp2             = GET_STAT(RX_PORT_PPP2);
+       p->rx_ppp3             = GET_STAT(RX_PORT_PPP3);
+       p->rx_ppp4             = GET_STAT(RX_PORT_PPP4);
+       p->rx_ppp5             = GET_STAT(RX_PORT_PPP5);
+       p->rx_ppp6             = GET_STAT(RX_PORT_PPP6);
+       p->rx_ppp7             = GET_STAT(RX_PORT_PPP7);
+
+       p->rx_ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_DROP_FRAME) : 0;
+       p->rx_ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_DROP_FRAME) : 0;
+       p->rx_ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_DROP_FRAME) : 0;
+       p->rx_ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_DROP_FRAME) : 0;
+       p->rx_trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_TRUNC_FRAME) : 0;
+       p->rx_trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_TRUNC_FRAME) : 0;
+       p->rx_trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_TRUNC_FRAME) : 0;
+       p->rx_trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_TRUNC_FRAME) : 0;
+
+#undef GET_STAT
+#undef GET_STAT_COM
+}
+
+/**
+ *     t4_get_lb_stats - collect loopback port statistics
+ *     @adap: the adapter
+ *     @idx: the loopback port index
+ *     @p: the stats structure to fill
+ *
+ *     Return HW statistics for the given loopback port.
+ */
+void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p)
+{
+       u32 bgmap = get_mps_bg_map(adap, idx);
+
+#define GET_STAT(name) \
+       t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_LB_PORT_##name##_L))
+#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
+
+       p->octets           = GET_STAT(BYTES);
+       p->frames           = GET_STAT(FRAMES);
+       p->bcast_frames     = GET_STAT(BCAST);
+       p->mcast_frames     = GET_STAT(MCAST);
+       p->ucast_frames     = GET_STAT(UCAST);
+       p->error_frames     = GET_STAT(ERROR);
+
+       p->frames_64        = GET_STAT(64B);
+       p->frames_65_127    = GET_STAT(65B_127B);
+       p->frames_128_255   = GET_STAT(128B_255B);
+       p->frames_256_511   = GET_STAT(256B_511B);
+       p->frames_512_1023  = GET_STAT(512B_1023B);
+       p->frames_1024_1518 = GET_STAT(1024B_1518B);
+       p->frames_1519_max  = GET_STAT(1519B_MAX);
+       p->drop             = t4_read_reg(adap, PORT_REG(idx,
+                                         MPS_PORT_STAT_LB_PORT_DROP_FRAMES));
+
+       p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
+       p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
+       p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
+       p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
+       p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
+       p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
+       p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
+       p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
+
+#undef GET_STAT
+#undef GET_STAT_COM
+}
+
+/**
+ *     t4_wol_magic_enable - enable/disable magic packet WoL
+ *     @adap: the adapter
+ *     @port: the physical port index
+ *     @addr: MAC address expected in magic packets, %NULL to disable
+ *
+ *     Enables/disables magic packet wake-on-LAN for the selected port.
+ */
+void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
+                        const u8 *addr)
+{
+       if (addr) {
+               t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO),
+                            (addr[2] << 24) | (addr[3] << 16) |
+                            (addr[4] << 8) | addr[5]);
+               t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI),
+                            (addr[0] << 8) | addr[1]);
+       }
+       t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2), MAGICEN,
+                        addr ? MAGICEN : 0);
+}
+
+/**
+ *     t4_wol_pat_enable - enable/disable pattern-based WoL
+ *     @adap: the adapter
+ *     @port: the physical port index
+ *     @map: bitmap of which HW pattern filters to set
+ *     @mask0: byte mask for bytes 0-63 of a packet
+ *     @mask1: byte mask for bytes 64-127 of a packet
+ *     @crc: Ethernet CRC for selected bytes
+ *     @enable: enable/disable switch
+ *
+ *     Sets the pattern filters indicated in @map to mask out the bytes
+ *     specified in @mask0/@mask1 in received packets and compare the CRC of
+ *     the resulting packet against @crc.  If @enable is %true pattern-based
+ *     WoL is enabled, otherwise disabled.
+ */
+int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
+                     u64 mask0, u64 mask1, unsigned int crc, bool enable)
+{
+       int i;
+
+       if (!enable) {
+               t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2),
+                                PATEN, 0);
+               return 0;
+       }
+       if (map > 0xff)
+               return -EINVAL;
+
+#define EPIO_REG(name) PORT_REG(port, XGMAC_PORT_EPIO_##name)
+
+       t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32);
+       t4_write_reg(adap, EPIO_REG(DATA2), mask1);
+       t4_write_reg(adap, EPIO_REG(DATA3), mask1 >> 32);
+
+       for (i = 0; i < NWOL_PAT; i++, map >>= 1) {
+               if (!(map & 1))
+                       continue;
+
+               /* write byte masks */
+               t4_write_reg(adap, EPIO_REG(DATA0), mask0);
+               t4_write_reg(adap, EPIO_REG(OP), ADDRESS(i) | EPIOWR);
+               t4_read_reg(adap, EPIO_REG(OP));                /* flush */
+               if (t4_read_reg(adap, EPIO_REG(OP)) & BUSY)
+                       return -ETIMEDOUT;
+
+               /* write CRC */
+               t4_write_reg(adap, EPIO_REG(DATA0), crc);
+               t4_write_reg(adap, EPIO_REG(OP), ADDRESS(i + 32) | EPIOWR);
+               t4_read_reg(adap, EPIO_REG(OP));                /* flush */
+               if (t4_read_reg(adap, EPIO_REG(OP)) & BUSY)
+                       return -ETIMEDOUT;
+       }
+#undef EPIO_REG
+
+       t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2), 0, PATEN);
+       return 0;
+}
+
+#define INIT_CMD(var, cmd, rd_wr) do { \
+       (var).op_to_write = htonl(FW_CMD_OP(FW_##cmd##_CMD) | \
+                                 FW_CMD_REQUEST | FW_CMD_##rd_wr); \
+       (var).retval_len16 = htonl(FW_LEN16(var)); \
+} while (0)
+
+/**
+ *     t4_mdio_rd - read a PHY register through MDIO
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @phy_addr: the PHY address
+ *     @mmd: the PHY MMD to access (0 for clause 22 PHYs)
+ *     @reg: the register to read
+ *     @valp: where to store the value
+ *
+ *     Issues a FW command through the given mailbox to read a PHY register.
+ */
+int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
+              unsigned int mmd, unsigned int reg, u16 *valp)
+{
+       int ret;
+       struct fw_ldst_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_addrspace = htonl(FW_CMD_OP(FW_LDST_CMD) | FW_CMD_REQUEST |
+               FW_CMD_READ | FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_MDIO));
+       c.cycles_to_len16 = htonl(FW_LEN16(c));
+       c.u.mdio.paddr_mmd = htons(FW_LDST_CMD_PADDR(phy_addr) |
+                                  FW_LDST_CMD_MMD(mmd));
+       c.u.mdio.raddr = htons(reg);
+
+       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+       if (ret == 0)
+               *valp = ntohs(c.u.mdio.rval);
+       return ret;
+}
+
+/**
+ *     t4_mdio_wr - write a PHY register through MDIO
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @phy_addr: the PHY address
+ *     @mmd: the PHY MMD to access (0 for clause 22 PHYs)
+ *     @reg: the register to write
+ *     @valp: value to write
+ *
+ *     Issues a FW command through the given mailbox to write a PHY register.
+ */
+int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
+              unsigned int mmd, unsigned int reg, u16 val)
+{
+       struct fw_ldst_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_addrspace = htonl(FW_CMD_OP(FW_LDST_CMD) | FW_CMD_REQUEST |
+               FW_CMD_WRITE | FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_MDIO));
+       c.cycles_to_len16 = htonl(FW_LEN16(c));
+       c.u.mdio.paddr_mmd = htons(FW_LDST_CMD_PADDR(phy_addr) |
+                                  FW_LDST_CMD_MMD(mmd));
+       c.u.mdio.raddr = htons(reg);
+       c.u.mdio.rval = htons(val);
+
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_fw_hello - establish communication with FW
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @evt_mbox: mailbox to receive async FW events
+ *     @master: specifies the caller's willingness to be the device master
+ *     @state: returns the current device state
+ *
+ *     Issues a command to establish communication with FW.
+ */
+int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
+               enum dev_master master, enum dev_state *state)
+{
+       int ret;
+       struct fw_hello_cmd c;
+
+       INIT_CMD(c, HELLO, WRITE);
+       c.err_to_mbasyncnot = htonl(
+               FW_HELLO_CMD_MASTERDIS(master == MASTER_CANT) |
+               FW_HELLO_CMD_MASTERFORCE(master == MASTER_MUST) |
+               FW_HELLO_CMD_MBMASTER(master == MASTER_MUST ? mbox : 0xff) |
+               FW_HELLO_CMD_MBASYNCNOT(evt_mbox));
+
+       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+       if (ret == 0 && state) {
+               u32 v = ntohl(c.err_to_mbasyncnot);
+               if (v & FW_HELLO_CMD_INIT)
+                       *state = DEV_STATE_INIT;
+               else if (v & FW_HELLO_CMD_ERR)
+                       *state = DEV_STATE_ERR;
+               else
+                       *state = DEV_STATE_UNINIT;
+       }
+       return ret;
+}
+
+/**
+ *     t4_fw_bye - end communication with FW
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *
+ *     Issues a command to terminate communication with FW.
+ */
+int t4_fw_bye(struct adapter *adap, unsigned int mbox)
+{
+       struct fw_bye_cmd c;
+
+       INIT_CMD(c, BYE, WRITE);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_init_cmd - ask FW to initialize the device
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *
+ *     Issues a command to FW to partially initialize the device.  This
+ *     performs initialization that generally doesn't depend on user input.
+ */
+int t4_early_init(struct adapter *adap, unsigned int mbox)
+{
+       struct fw_initialize_cmd c;
+
+       INIT_CMD(c, INITIALIZE, WRITE);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_fw_reset - issue a reset to FW
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @reset: specifies the type of reset to perform
+ *
+ *     Issues a reset command of the specified type to FW.
+ */
+int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset)
+{
+       struct fw_reset_cmd c;
+
+       INIT_CMD(c, RESET, WRITE);
+       c.val = htonl(reset);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_query_params - query FW or device parameters
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF
+ *     @vf: the VF
+ *     @nparams: the number of parameters
+ *     @params: the parameter names
+ *     @val: the parameter values
+ *
+ *     Reads the value of FW or device parameters.  Up to 7 parameters can be
+ *     queried at once.
+ */
+int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int nparams, const u32 *params,
+                   u32 *val)
+{
+       int i, ret;
+       struct fw_params_cmd c;
+       __be32 *p = &c.param[0].mnem;
+
+       if (nparams > 7)
+               return -EINVAL;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_PARAMS_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_READ | FW_PARAMS_CMD_PFN(pf) |
+                           FW_PARAMS_CMD_VFN(vf));
+       c.retval_len16 = htonl(FW_LEN16(c));
+       for (i = 0; i < nparams; i++, p += 2)
+               *p = htonl(*params++);
+
+       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+       if (ret == 0)
+               for (i = 0, p = &c.param[0].val; i < nparams; i++, p += 2)
+                       *val++ = ntohl(*p);
+       return ret;
+}
+
+/**
+ *     t4_set_params - sets FW or device parameters
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF
+ *     @vf: the VF
+ *     @nparams: the number of parameters
+ *     @params: the parameter names
+ *     @val: the parameter values
+ *
+ *     Sets the value of FW or device parameters.  Up to 7 parameters can be
+ *     specified at once.
+ */
+int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                 unsigned int vf, unsigned int nparams, const u32 *params,
+                 const u32 *val)
+{
+       struct fw_params_cmd c;
+       __be32 *p = &c.param[0].mnem;
+
+       if (nparams > 7)
+               return -EINVAL;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_PARAMS_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_PARAMS_CMD_PFN(pf) |
+                           FW_PARAMS_CMD_VFN(vf));
+       c.retval_len16 = htonl(FW_LEN16(c));
+       while (nparams--) {
+               *p++ = htonl(*params++);
+               *p++ = htonl(*val++);
+       }
+
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_cfg_pfvf - configure PF/VF resource limits
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF being configured
+ *     @vf: the VF being configured
+ *     @txq: the max number of egress queues
+ *     @txq_eth_ctrl: the max number of egress Ethernet or control queues
+ *     @rxqi: the max number of interrupt-capable ingress queues
+ *     @rxq: the max number of interruptless ingress queues
+ *     @tc: the PCI traffic class
+ *     @vi: the max number of virtual interfaces
+ *     @cmask: the channel access rights mask for the PF/VF
+ *     @pmask: the port access rights mask for the PF/VF
+ *     @nexact: the maximum number of exact MPS filters
+ *     @rcaps: read capabilities
+ *     @wxcaps: write/execute capabilities
+ *
+ *     Configures resource limits and capabilities for a physical or virtual
+ *     function.
+ */
+int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
+               unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
+               unsigned int rxqi, unsigned int rxq, unsigned int tc,
+               unsigned int vi, unsigned int cmask, unsigned int pmask,
+               unsigned int nexact, unsigned int rcaps, unsigned int wxcaps)
+{
+       struct fw_pfvf_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_PFVF_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_PFVF_CMD_PFN(pf) |
+                           FW_PFVF_CMD_VFN(vf));
+       c.retval_len16 = htonl(FW_LEN16(c));
+       c.niqflint_niq = htonl(FW_PFVF_CMD_NIQFLINT(rxqi) |
+                              FW_PFVF_CMD_NIQ(rxq));
+       c.cmask_to_neq = htonl(FW_PFVF_CMD_CMASK(cmask) |
+                              FW_PFVF_CMD_PMASK(pmask) |
+                              FW_PFVF_CMD_NEQ(txq));
+       c.tc_to_nexactf = htonl(FW_PFVF_CMD_TC(tc) | FW_PFVF_CMD_NVI(vi) |
+                               FW_PFVF_CMD_NEXACTF(nexact));
+       c.r_caps_to_nethctrl = htonl(FW_PFVF_CMD_R_CAPS(rcaps) |
+                                    FW_PFVF_CMD_WX_CAPS(wxcaps) |
+                                    FW_PFVF_CMD_NETHCTRL(txq_eth_ctrl));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_alloc_vi - allocate a virtual interface
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @port: physical port associated with the VI
+ *     @pf: the PF owning the VI
+ *     @vf: the VF owning the VI
+ *     @nmac: number of MAC addresses needed (1 to 5)
+ *     @mac: the MAC addresses of the VI
+ *     @rss_size: size of RSS table slice associated with this VI
+ *
+ *     Allocates a virtual interface for the given physical port.  If @mac is
+ *     not %NULL it contains the MAC addresses of the VI as assigned by FW.
+ *     @mac should be large enough to hold @nmac Ethernet addresses, they are
+ *     stored consecutively so the space needed is @nmac * 6 bytes.
+ *     Returns a negative error number or the non-negative VI id.
+ */
+int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
+               unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
+               unsigned int *rss_size)
+{
+       int ret;
+       struct fw_vi_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_VI_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_WRITE | FW_CMD_EXEC |
+                           FW_VI_CMD_PFN(pf) | FW_VI_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_VI_CMD_ALLOC | FW_LEN16(c));
+       c.portid_pkd = FW_VI_CMD_PORTID(port);
+       c.nmac = nmac - 1;
+
+       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+       if (ret)
+               return ret;
+
+       if (mac) {
+               memcpy(mac, c.mac, sizeof(c.mac));
+               switch (nmac) {
+               case 5:
+                       memcpy(mac + 24, c.nmac3, sizeof(c.nmac3));
+               case 4:
+                       memcpy(mac + 18, c.nmac2, sizeof(c.nmac2));
+               case 3:
+                       memcpy(mac + 12, c.nmac1, sizeof(c.nmac1));
+               case 2:
+                       memcpy(mac + 6,  c.nmac0, sizeof(c.nmac0));
+               }
+       }
+       if (rss_size)
+               *rss_size = FW_VI_CMD_RSSSIZE_GET(ntohs(c.rsssize_pkd));
+       return ntohs(c.viid_pkd);
+}
+
+/**
+ *     t4_free_vi - free a virtual interface
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the VI
+ *     @vf: the VF owning the VI
+ *     @viid: virtual interface identifiler
+ *
+ *     Free a previously allocated virtual interface.
+ */
+int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
+              unsigned int vf, unsigned int viid)
+{
+       struct fw_vi_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_VI_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_VI_CMD_PFN(pf) |
+                           FW_VI_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_VI_CMD_FREE | FW_LEN16(c));
+       c.viid_pkd = htons(FW_VI_CMD_VIID(viid));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+}
+
+/**
+ *     t4_set_rxmode - set Rx properties of a virtual interface
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @mtu: the new MTU or -1
+ *     @promisc: 1 to enable promiscuous mode, 0 to disable it, -1 no change
+ *     @all_multi: 1 to enable all-multi mode, 0 to disable it, -1 no change
+ *     @bcast: 1 to enable broadcast Rx, 0 to disable it, -1 no change
+ *     @sleep_ok: if true we may sleep while awaiting command completion
+ *
+ *     Sets Rx properties of a virtual interface.
+ */
+int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                 int mtu, int promisc, int all_multi, int bcast, bool sleep_ok)
+{
+       struct fw_vi_rxmode_cmd c;
+
+       /* convert to FW values */
+       if (mtu < 0)
+               mtu = FW_RXMODE_MTU_NO_CHG;
+       if (promisc < 0)
+               promisc = FW_VI_RXMODE_CMD_PROMISCEN_MASK;
+       if (all_multi < 0)
+               all_multi = FW_VI_RXMODE_CMD_ALLMULTIEN_MASK;
+       if (bcast < 0)
+               bcast = FW_VI_RXMODE_CMD_BROADCASTEN_MASK;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_RXMODE_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_WRITE | FW_VI_RXMODE_CMD_VIID(viid));
+       c.retval_len16 = htonl(FW_LEN16(c));
+       c.mtu_to_broadcasten = htonl(FW_VI_RXMODE_CMD_MTU(mtu) |
+                                    FW_VI_RXMODE_CMD_PROMISCEN(promisc) |
+                                    FW_VI_RXMODE_CMD_ALLMULTIEN(all_multi) |
+                                    FW_VI_RXMODE_CMD_BROADCASTEN(bcast));
+       return t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), NULL, sleep_ok);
+}
+
+/**
+ *     t4_alloc_mac_filt - allocates exact-match filters for MAC addresses
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @free: if true any existing filters for this VI id are first removed
+ *     @naddr: the number of MAC addresses to allocate filters for (up to 7)
+ *     @addr: the MAC address(es)
+ *     @idx: where to store the index of each allocated filter
+ *     @hash: pointer to hash address filter bitmap
+ *     @sleep_ok: call is allowed to sleep
+ *
+ *     Allocates an exact-match filter for each of the supplied addresses and
+ *     sets it to the corresponding address.  If @idx is not %NULL it should
+ *     have at least @naddr entries, each of which will be set to the index of
+ *     the filter allocated for the corresponding MAC address.  If a filter
+ *     could not be allocated for an address its index is set to 0xffff.
+ *     If @hash is not %NULL addresses that fail to allocate an exact filter
+ *     are hashed and update the hash filter bitmap pointed at by @hash.
+ *
+ *     Returns a negative error number or the number of filters allocated.
+ */
+int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
+                     unsigned int viid, bool free, unsigned int naddr,
+                     const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok)
+{
+       int i, ret;
+       struct fw_vi_mac_cmd c;
+       struct fw_vi_mac_exact *p;
+
+       if (naddr > 7)
+               return -EINVAL;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_WRITE | (free ? FW_CMD_EXEC : 0) |
+                            FW_VI_MAC_CMD_VIID(viid));
+       c.freemacs_to_len16 = htonl(FW_VI_MAC_CMD_FREEMACS(free) |
+                                   FW_CMD_LEN16((naddr + 2) / 2));
+
+       for (i = 0, p = c.u.exact; i < naddr; i++, p++) {
+               p->valid_to_idx = htons(FW_VI_MAC_CMD_VALID |
+                                     FW_VI_MAC_CMD_IDX(FW_VI_MAC_ADD_MAC));
+               memcpy(p->macaddr, addr[i], sizeof(p->macaddr));
+       }
+
+       ret = t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), &c, sleep_ok);
+       if (ret)
+               return ret;
+
+       for (i = 0, p = c.u.exact; i < naddr; i++, p++) {
+               u16 index = FW_VI_MAC_CMD_IDX_GET(ntohs(p->valid_to_idx));
+
+               if (idx)
+                       idx[i] = index >= NEXACT_MAC ? 0xffff : index;
+               if (index < NEXACT_MAC)
+                       ret++;
+               else if (hash)
+                       *hash |= (1 << hash_mac_addr(addr[i]));
+       }
+       return ret;
+}
+
+/**
+ *     t4_change_mac - modifies the exact-match filter for a MAC address
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @idx: index of existing filter for old value of MAC address, or -1
+ *     @addr: the new MAC address value
+ *     @persist: whether a new MAC allocation should be persistent
+ *     @add_smt: if true also add the address to the HW SMT
+ *
+ *     Modifies an exact-match filter and sets it to the new MAC address.
+ *     Note that in general it is not possible to modify the value of a given
+ *     filter so the generic way to modify an address filter is to free the one
+ *     being used by the old address value and allocate a new filter for the
+ *     new address value.  @idx can be -1 if the address is a new addition.
+ *
+ *     Returns a negative error number or the index of the filter with the new
+ *     MAC value.
+ */
+int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                 int idx, const u8 *addr, bool persist, bool add_smt)
+{
+       int ret, mode;
+       struct fw_vi_mac_cmd c;
+       struct fw_vi_mac_exact *p = c.u.exact;
+
+       if (idx < 0)                             /* new allocation */
+               idx = persist ? FW_VI_MAC_ADD_PERSIST_MAC : FW_VI_MAC_ADD_MAC;
+       mode = add_smt ? FW_VI_MAC_SMT_AND_MPSTCAM : FW_VI_MAC_MPS_TCAM_ENTRY;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_WRITE | FW_VI_MAC_CMD_VIID(viid));
+       c.freemacs_to_len16 = htonl(FW_CMD_LEN16(1));
+       p->valid_to_idx = htons(FW_VI_MAC_CMD_VALID |
+                               FW_VI_MAC_CMD_SMAC_RESULT(mode) |
+                               FW_VI_MAC_CMD_IDX(idx));
+       memcpy(p->macaddr, addr, sizeof(p->macaddr));
+
+       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+       if (ret == 0) {
+               ret = FW_VI_MAC_CMD_IDX_GET(ntohs(p->valid_to_idx));
+               if (ret >= NEXACT_MAC)
+                       ret = -ENOMEM;
+       }
+       return ret;
+}
+
+/**
+ *     t4_set_addr_hash - program the MAC inexact-match hash filter
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @ucast: whether the hash filter should also match unicast addresses
+ *     @vec: the value to be written to the hash filter
+ *     @sleep_ok: call is allowed to sleep
+ *
+ *     Sets the 64-bit inexact-match hash filter for a virtual interface.
+ */
+int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                    bool ucast, u64 vec, bool sleep_ok)
+{
+       struct fw_vi_mac_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_WRITE | FW_VI_ENABLE_CMD_VIID(viid));
+       c.freemacs_to_len16 = htonl(FW_VI_MAC_CMD_HASHVECEN |
+                                   FW_VI_MAC_CMD_HASHUNIEN(ucast) |
+                                   FW_CMD_LEN16(1));
+       c.u.hash.hashvec = cpu_to_be64(vec);
+       return t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), NULL, sleep_ok);
+}
+
+/**
+ *     t4_enable_vi - enable/disable a virtual interface
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @rx_en: 1=enable Rx, 0=disable Rx
+ *     @tx_en: 1=enable Tx, 0=disable Tx
+ *
+ *     Enables/disables a virtual interface.
+ */
+int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                bool rx_en, bool tx_en)
+{
+       struct fw_vi_enable_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid));
+       c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_IEN(rx_en) |
+                              FW_VI_ENABLE_CMD_EEN(tx_en) | FW_LEN16(c));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_identify_port - identify a VI's port by blinking its LED
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @viid: the VI id
+ *     @nblinks: how many times to blink LED at 2.5 Hz
+ *
+ *     Identifies a VI's port by blinking its LED.
+ */
+int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
+                    unsigned int nblinks)
+{
+       struct fw_vi_enable_cmd c;
+
+       c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST |
+                            FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid));
+       c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_LED | FW_LEN16(c));
+       c.blinkdur = htons(nblinks);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_iq_start_stop - enable/disable an ingress queue and its FLs
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @start: %true to enable the queues, %false to disable them
+ *     @pf: the PF owning the queues
+ *     @vf: the VF owning the queues
+ *     @iqid: ingress queue id
+ *     @fl0id: FL0 queue id or 0xffff if no attached FL0
+ *     @fl1id: FL1 queue id or 0xffff if no attached FL1
+ *
+ *     Starts or stops an ingress queue and its associated FLs, if any.
+ */
+int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
+                    unsigned int pf, unsigned int vf, unsigned int iqid,
+                    unsigned int fl0id, unsigned int fl1id)
+{
+       struct fw_iq_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_IQ_CMD_PFN(pf) |
+                           FW_IQ_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_IQ_CMD_IQSTART(start) |
+                                FW_IQ_CMD_IQSTOP(!start) | FW_LEN16(c));
+       c.iqid = htons(iqid);
+       c.fl0id = htons(fl0id);
+       c.fl1id = htons(fl1id);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_iq_free - free an ingress queue and its FLs
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the queues
+ *     @vf: the VF owning the queues
+ *     @iqtype: the ingress queue type
+ *     @iqid: ingress queue id
+ *     @fl0id: FL0 queue id or 0xffff if no attached FL0
+ *     @fl1id: FL1 queue id or 0xffff if no attached FL1
+ *
+ *     Frees an ingress queue and its associated FLs, if any.
+ */
+int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+              unsigned int vf, unsigned int iqtype, unsigned int iqid,
+              unsigned int fl0id, unsigned int fl1id)
+{
+       struct fw_iq_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_IQ_CMD_PFN(pf) |
+                           FW_IQ_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_IQ_CMD_FREE | FW_LEN16(c));
+       c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE(iqtype));
+       c.iqid = htons(iqid);
+       c.fl0id = htons(fl0id);
+       c.fl1id = htons(fl1id);
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_eth_eq_free - free an Ethernet egress queue
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the queue
+ *     @vf: the VF owning the queue
+ *     @eqid: egress queue id
+ *
+ *     Frees an Ethernet egress queue.
+ */
+int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                  unsigned int vf, unsigned int eqid)
+{
+       struct fw_eq_eth_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_ETH_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_EQ_ETH_CMD_PFN(pf) |
+                           FW_EQ_ETH_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_EQ_ETH_CMD_FREE | FW_LEN16(c));
+       c.eqid_pkd = htonl(FW_EQ_ETH_CMD_EQID(eqid));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_ctrl_eq_free - free a control egress queue
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the queue
+ *     @vf: the VF owning the queue
+ *     @eqid: egress queue id
+ *
+ *     Frees a control egress queue.
+ */
+int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int eqid)
+{
+       struct fw_eq_ctrl_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_CTRL_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_EQ_CTRL_CMD_PFN(pf) |
+                           FW_EQ_CTRL_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_EQ_CTRL_CMD_FREE | FW_LEN16(c));
+       c.cmpliqid_eqid = htonl(FW_EQ_CTRL_CMD_EQID(eqid));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_ofld_eq_free - free an offload egress queue
+ *     @adap: the adapter
+ *     @mbox: mailbox to use for the FW command
+ *     @pf: the PF owning the queue
+ *     @vf: the VF owning the queue
+ *     @eqid: egress queue id
+ *
+ *     Frees a control egress queue.
+ */
+int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
+                   unsigned int vf, unsigned int eqid)
+{
+       struct fw_eq_ofld_cmd c;
+
+       memset(&c, 0, sizeof(c));
+       c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_OFLD_CMD) | FW_CMD_REQUEST |
+                           FW_CMD_EXEC | FW_EQ_OFLD_CMD_PFN(pf) |
+                           FW_EQ_OFLD_CMD_VFN(vf));
+       c.alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_FREE | FW_LEN16(c));
+       c.eqid_pkd = htonl(FW_EQ_OFLD_CMD_EQID(eqid));
+       return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
+}
+
+/**
+ *     t4_handle_fw_rpl - process a FW reply message
+ *     @adap: the adapter
+ *     @rpl: start of the FW message
+ *
+ *     Processes a FW message, such as link state change messages.
+ */
+int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
+{
+       u8 opcode = *(const u8 *)rpl;
+
+       if (opcode == FW_PORT_CMD) {    /* link/module state change message */
+               int speed = 0, fc = 0;
+               const struct fw_port_cmd *p = (void *)rpl;
+               int chan = FW_PORT_CMD_PORTID_GET(ntohl(p->op_to_portid));
+               int port = adap->chan_map[chan];
+               struct port_info *pi = adap2pinfo(adap, port);
+               struct link_config *lc = &pi->link_cfg;
+               u32 stat = ntohl(p->u.info.lstatus_to_modtype);
+               int link_ok = (stat & FW_PORT_CMD_LSTATUS) != 0;
+               u32 mod = FW_PORT_CMD_MODTYPE_GET(stat);
+
+               if (stat & FW_PORT_CMD_RXPAUSE)
+                       fc |= PAUSE_RX;
+               if (stat & FW_PORT_CMD_TXPAUSE)
+                       fc |= PAUSE_TX;
+               if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
+                       speed = SPEED_100;
+               else if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
+                       speed = SPEED_1000;
+               else if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
+                       speed = SPEED_10000;
+
+               if (link_ok != lc->link_ok || speed != lc->speed ||
+                   fc != lc->fc) {                    /* something changed */
+                       lc->link_ok = link_ok;
+                       lc->speed = speed;
+                       lc->fc = fc;
+                       t4_os_link_changed(adap, port, link_ok);
+               }
+               if (mod != pi->mod_type) {
+                       pi->mod_type = mod;
+                       t4_os_portmod_changed(adap, port);
+               }
+       }
+       return 0;
+}
+
+static void __devinit get_pci_mode(struct adapter *adapter,
+                                  struct pci_params *p)
+{
+       u16 val;
+       u32 pcie_cap = pci_pcie_cap(adapter->pdev);
+
+       if (pcie_cap) {
+               pci_read_config_word(adapter->pdev, pcie_cap + PCI_EXP_LNKSTA,
+                                    &val);
+               p->speed = val & PCI_EXP_LNKSTA_CLS;
+               p->width = (val & PCI_EXP_LNKSTA_NLW) >> 4;
+       }
+}
+
+/**
+ *     init_link_config - initialize a link's SW state
+ *     @lc: structure holding the link state
+ *     @caps: link capabilities
+ *
+ *     Initializes the SW state maintained for each link, including the link's
+ *     capabilities and default speed/flow-control/autonegotiation settings.
+ */
+static void __devinit init_link_config(struct link_config *lc,
+                                      unsigned int caps)
+{
+       lc->supported = caps;
+       lc->requested_speed = 0;
+       lc->speed = 0;
+       lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX;
+       if (lc->supported & FW_PORT_CAP_ANEG) {
+               lc->advertising = lc->supported & ADVERT_MASK;
+               lc->autoneg = AUTONEG_ENABLE;
+               lc->requested_fc |= PAUSE_AUTONEG;
+       } else {
+               lc->advertising = 0;
+               lc->autoneg = AUTONEG_DISABLE;
+       }
+}
+
+static int __devinit wait_dev_ready(struct adapter *adap)
+{
+       if (t4_read_reg(adap, PL_WHOAMI) != 0xffffffff)
+               return 0;
+       msleep(500);
+       return t4_read_reg(adap, PL_WHOAMI) != 0xffffffff ? 0 : -EIO;
+}
+
+/**
+ *     t4_prep_adapter - prepare SW and HW for operation
+ *     @adapter: the adapter
+ *     @reset: if true perform a HW reset
+ *
+ *     Initialize adapter SW state for the various HW modules, set initial
+ *     values for some adapter tunables, take PHYs out of reset, and
+ *     initialize the MDIO interface.
+ */
+int __devinit t4_prep_adapter(struct adapter *adapter)
+{
+       int ret;
+
+       ret = wait_dev_ready(adapter);
+       if (ret < 0)
+               return ret;
+
+       get_pci_mode(adapter, &adapter->params.pci);
+       adapter->params.rev = t4_read_reg(adapter, PL_REV);
+
+       ret = get_vpd_params(adapter, &adapter->params.vpd);
+       if (ret < 0)
+               return ret;
+
+       init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd);
+
+       /*
+        * Default port for debugging in case we can't reach FW.
+        */
+       adapter->params.nports = 1;
+       adapter->params.portvec = 1;
+       return 0;
+}
+
+int __devinit t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
+{
+       u8 addr[6];
+       int ret, i, j = 0;
+       struct fw_port_cmd c;
+
+       memset(&c, 0, sizeof(c));
+
+       for_each_port(adap, i) {
+               unsigned int rss_size;
+               struct port_info *p = adap2pinfo(adap, i);
+
+               while ((adap->params.portvec & (1 << j)) == 0)
+                       j++;
+
+               c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) |
+                                      FW_CMD_REQUEST | FW_CMD_READ |
+                                      FW_PORT_CMD_PORTID(j));
+               c.action_to_len16 = htonl(
+                       FW_PORT_CMD_ACTION(FW_PORT_ACTION_GET_PORT_INFO) |
+                       FW_LEN16(c));
+               ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+               if (ret)
+                       return ret;
+
+               ret = t4_alloc_vi(adap, mbox, j, pf, vf, 1, addr, &rss_size);
+               if (ret < 0)
+                       return ret;
+
+               p->viid = ret;
+               p->tx_chan = j;
+               p->lport = j;
+               p->rss_size = rss_size;
+               memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN);
+               memcpy(adap->port[i]->perm_addr, addr, ETH_ALEN);
+
+               ret = ntohl(c.u.info.lstatus_to_modtype);
+               p->mdio_addr = (ret & FW_PORT_CMD_MDIOCAP) ?
+                       FW_PORT_CMD_MDIOADDR_GET(ret) : -1;
+               p->port_type = FW_PORT_CMD_PTYPE_GET(ret);
+               p->mod_type = FW_PORT_CMD_MODTYPE_GET(ret);
+
+               init_link_config(&p->link_cfg, ntohs(c.u.info.pcap));
+               j++;
+       }
+       return 0;
+}
diff --git a/drivers/net/cxgb4/t4_hw.h b/drivers/net/cxgb4/t4_hw.h
new file mode 100644 (file)
index 0000000..0256232
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __T4_HW_H
+#define __T4_HW_H
+
+#include <linux/types.h>
+
+enum {
+       NCHAN          = 4,     /* # of HW channels */
+       MAX_MTU        = 9600,  /* max MAC MTU, excluding header + FCS */
+       EEPROMSIZE     = 17408, /* Serial EEPROM physical size */
+       EEPROMVSIZE    = 32768, /* Serial EEPROM virtual address space size */
+       RSS_NENTRIES   = 2048,  /* # of entries in RSS mapping table */
+       TCB_SIZE       = 128,   /* TCB size */
+       NMTUS          = 16,    /* size of MTU table */
+       NCCTRL_WIN     = 32,    /* # of congestion control windows */
+       NEXACT_MAC     = 336,   /* # of exact MAC address filters */
+       L2T_SIZE       = 4096,  /* # of L2T entries */
+       MBOX_LEN       = 64,    /* mailbox size in bytes */
+       TRACE_LEN      = 112,   /* length of trace data and mask */
+       FILTER_OPT_LEN = 36,    /* filter tuple width for optional components */
+       NWOL_PAT       = 8,     /* # of WoL patterns */
+       WOL_PAT_LEN    = 128,   /* length of WoL patterns */
+};
+
+enum {
+       SF_PAGE_SIZE = 256,           /* serial flash page size */
+       SF_SEC_SIZE = 64 * 1024,      /* serial flash sector size */
+       SF_SIZE = SF_SEC_SIZE * 16,   /* serial flash size */
+};
+
+enum { RSP_TYPE_FLBUF, RSP_TYPE_CPL, RSP_TYPE_INTR }; /* response entry types */
+
+enum { MBOX_OWNER_NONE, MBOX_OWNER_FW, MBOX_OWNER_DRV };    /* mailbox owners */
+
+enum {
+       SGE_MAX_WR_LEN = 512,     /* max WR size in bytes */
+       SGE_NTIMERS = 6,          /* # of interrupt holdoff timer values */
+       SGE_NCOUNTERS = 4,        /* # of interrupt packet counter values */
+};
+
+struct sge_qstat {                /* data written to SGE queue status entries */
+       __be32 qid;
+       __be16 cidx;
+       __be16 pidx;
+};
+
+/*
+ * Structure for last 128 bits of response descriptors
+ */
+struct rsp_ctrl {
+       __be32 hdrbuflen_pidx;
+       __be32 pldbuflen_qid;
+       union {
+               u8 type_gen;
+               __be64 last_flit;
+       };
+};
+
+#define RSPD_NEWBUF 0x80000000U
+#define RSPD_LEN    0x7fffffffU
+
+#define RSPD_GEN(x)  ((x) >> 7)
+#define RSPD_TYPE(x) (((x) >> 4) & 3)
+
+#define QINTR_CNT_EN       0x1
+#define QINTR_TIMER_IDX(x) ((x) << 1)
+#endif /* __T4_HW_H */
diff --git a/drivers/net/cxgb4/t4_msg.h b/drivers/net/cxgb4/t4_msg.h
new file mode 100644 (file)
index 0000000..fdb1174
--- /dev/null
@@ -0,0 +1,664 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __T4_MSG_H
+#define __T4_MSG_H
+
+#include <linux/types.h>
+
+enum {
+       CPL_PASS_OPEN_REQ     = 0x1,
+       CPL_PASS_ACCEPT_RPL   = 0x2,
+       CPL_ACT_OPEN_REQ      = 0x3,
+       CPL_SET_TCB_FIELD     = 0x5,
+       CPL_GET_TCB           = 0x6,
+       CPL_CLOSE_CON_REQ     = 0x8,
+       CPL_CLOSE_LISTSRV_REQ = 0x9,
+       CPL_ABORT_REQ         = 0xA,
+       CPL_ABORT_RPL         = 0xB,
+       CPL_RX_DATA_ACK       = 0xD,
+       CPL_TX_PKT            = 0xE,
+       CPL_L2T_WRITE_REQ     = 0x12,
+       CPL_TID_RELEASE       = 0x1A,
+
+       CPL_CLOSE_LISTSRV_RPL = 0x20,
+       CPL_L2T_WRITE_RPL     = 0x23,
+       CPL_PASS_OPEN_RPL     = 0x24,
+       CPL_ACT_OPEN_RPL      = 0x25,
+       CPL_PEER_CLOSE        = 0x26,
+       CPL_ABORT_REQ_RSS     = 0x2B,
+       CPL_ABORT_RPL_RSS     = 0x2D,
+
+       CPL_CLOSE_CON_RPL     = 0x32,
+       CPL_ISCSI_HDR         = 0x33,
+       CPL_RDMA_CQE          = 0x35,
+       CPL_RDMA_CQE_READ_RSP = 0x36,
+       CPL_RDMA_CQE_ERR      = 0x37,
+       CPL_RX_DATA           = 0x39,
+       CPL_SET_TCB_RPL       = 0x3A,
+       CPL_RX_PKT            = 0x3B,
+       CPL_RX_DDP_COMPLETE   = 0x3F,
+
+       CPL_ACT_ESTABLISH     = 0x40,
+       CPL_PASS_ESTABLISH    = 0x41,
+       CPL_RX_DATA_DDP       = 0x42,
+       CPL_PASS_ACCEPT_REQ   = 0x44,
+
+       CPL_RDMA_READ_REQ     = 0x60,
+
+       CPL_PASS_OPEN_REQ6    = 0x81,
+       CPL_ACT_OPEN_REQ6     = 0x83,
+
+       CPL_RDMA_TERMINATE    = 0xA2,
+       CPL_RDMA_WRITE        = 0xA4,
+       CPL_SGE_EGR_UPDATE    = 0xA5,
+
+       CPL_TRACE_PKT         = 0xB0,
+
+       CPL_FW4_MSG           = 0xC0,
+       CPL_FW4_PLD           = 0xC1,
+       CPL_FW4_ACK           = 0xC3,
+
+       CPL_FW6_MSG           = 0xE0,
+       CPL_FW6_PLD           = 0xE1,
+       CPL_TX_PKT_LSO        = 0xED,
+       CPL_TX_PKT_XT         = 0xEE,
+
+       NUM_CPL_CMDS
+};
+
+enum CPL_error {
+       CPL_ERR_NONE               = 0,
+       CPL_ERR_TCAM_FULL          = 3,
+       CPL_ERR_BAD_LENGTH         = 15,
+       CPL_ERR_BAD_ROUTE          = 18,
+       CPL_ERR_CONN_RESET         = 20,
+       CPL_ERR_CONN_EXIST_SYNRECV = 21,
+       CPL_ERR_CONN_EXIST         = 22,
+       CPL_ERR_ARP_MISS           = 23,
+       CPL_ERR_BAD_SYN            = 24,
+       CPL_ERR_CONN_TIMEDOUT      = 30,
+       CPL_ERR_XMIT_TIMEDOUT      = 31,
+       CPL_ERR_PERSIST_TIMEDOUT   = 32,
+       CPL_ERR_FINWAIT2_TIMEDOUT  = 33,
+       CPL_ERR_KEEPALIVE_TIMEDOUT = 34,
+       CPL_ERR_RTX_NEG_ADVICE     = 35,
+       CPL_ERR_PERSIST_NEG_ADVICE = 36,
+       CPL_ERR_ABORT_FAILED       = 42,
+       CPL_ERR_IWARP_FLM          = 50,
+};
+
+enum {
+       ULP_MODE_NONE          = 0,
+       ULP_MODE_ISCSI         = 2,
+       ULP_MODE_RDMA          = 4,
+       ULP_MODE_FCOE          = 6,
+};
+
+enum {
+       ULP_CRC_HEADER = 1 << 0,
+       ULP_CRC_DATA   = 1 << 1
+};
+
+enum {
+       CPL_ABORT_SEND_RST = 0,
+       CPL_ABORT_NO_RST,
+};
+
+enum {                     /* TX_PKT_XT checksum types */
+       TX_CSUM_TCP    = 0,
+       TX_CSUM_UDP    = 1,
+       TX_CSUM_CRC16  = 4,
+       TX_CSUM_CRC32  = 5,
+       TX_CSUM_CRC32C = 6,
+       TX_CSUM_FCOE   = 7,
+       TX_CSUM_TCPIP  = 8,
+       TX_CSUM_UDPIP  = 9,
+       TX_CSUM_TCPIP6 = 10,
+       TX_CSUM_UDPIP6 = 11,
+       TX_CSUM_IP     = 12,
+};
+
+union opcode_tid {
+       __be32 opcode_tid;
+       u8 opcode;
+};
+
+#define CPL_OPCODE(x) ((x) << 24)
+#define MK_OPCODE_TID(opcode, tid) (CPL_OPCODE(opcode) | (tid))
+#define OPCODE_TID(cmd) ((cmd)->ot.opcode_tid)
+#define GET_TID(cmd) (ntohl(OPCODE_TID(cmd)) & 0xFFFFFF)
+
+/* partitioning of TID fields that also carry a queue id */
+#define GET_TID_TID(x) ((x) & 0x3fff)
+#define GET_TID_QID(x) (((x) >> 14) & 0x3ff)
+#define TID_QID(x)     ((x) << 14)
+
+struct rss_header {
+       u8 opcode;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+       u8 channel:2;
+       u8 filter_hit:1;
+       u8 filter_tid:1;
+       u8 hash_type:2;
+       u8 ipv6:1;
+       u8 send2fw:1;
+#else
+       u8 send2fw:1;
+       u8 ipv6:1;
+       u8 hash_type:2;
+       u8 filter_tid:1;
+       u8 filter_hit:1;
+       u8 channel:2;
+#endif
+       __be16 qid;
+       __be32 hash_val;
+};
+
+struct work_request_hdr {
+       __be32 wr_hi;
+       __be32 wr_mid;
+       __be64 wr_lo;
+};
+
+#define WR_HDR struct work_request_hdr wr
+
+struct cpl_pass_open_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 local_port;
+       __be16 peer_port;
+       __be32 local_ip;
+       __be32 peer_ip;
+       __be64 opt0;
+#define TX_CHAN(x)    ((x) << 2)
+#define DELACK(x)     ((x) << 5)
+#define ULP_MODE(x)   ((x) << 8)
+#define RCV_BUFSIZ(x) ((x) << 12)
+#define DSCP(x)       ((x) << 22)
+#define SMAC_SEL(x)   ((u64)(x) << 28)
+#define L2T_IDX(x)    ((u64)(x) << 36)
+#define NAGLE(x)      ((u64)(x) << 49)
+#define WND_SCALE(x)  ((u64)(x) << 50)
+#define KEEP_ALIVE(x) ((u64)(x) << 54)
+#define MSS_IDX(x)    ((u64)(x) << 60)
+       __be64 opt1;
+#define SYN_RSS_ENABLE   (1 << 0)
+#define SYN_RSS_QUEUE(x) ((x) << 2)
+#define CONN_POLICY_ASK  (1 << 22)
+};
+
+struct cpl_pass_open_req6 {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 local_port;
+       __be16 peer_port;
+       __be64 local_ip_hi;
+       __be64 local_ip_lo;
+       __be64 peer_ip_hi;
+       __be64 peer_ip_lo;
+       __be64 opt0;
+       __be64 opt1;
+};
+
+struct cpl_pass_open_rpl {
+       union opcode_tid ot;
+       u8 rsvd[3];
+       u8 status;
+};
+
+struct cpl_pass_accept_rpl {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 opt2;
+#define RSS_QUEUE(x)         ((x) << 0)
+#define RSS_QUEUE_VALID      (1 << 10)
+#define RX_COALESCE_VALID(x) ((x) << 11)
+#define RX_COALESCE(x)       ((x) << 12)
+#define TX_QUEUE(x)          ((x) << 23)
+#define RX_CHANNEL(x)        ((x) << 26)
+#define WND_SCALE_EN(x)      ((x) << 28)
+#define TSTAMPS_EN(x)        ((x) << 29)
+#define SACK_EN(x)           ((x) << 30)
+       __be64 opt0;
+};
+
+struct cpl_act_open_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 local_port;
+       __be16 peer_port;
+       __be32 local_ip;
+       __be32 peer_ip;
+       __be64 opt0;
+       __be32 params;
+       __be32 opt2;
+};
+
+struct cpl_act_open_req6 {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 local_port;
+       __be16 peer_port;
+       __be64 local_ip_hi;
+       __be64 local_ip_lo;
+       __be64 peer_ip_hi;
+       __be64 peer_ip_lo;
+       __be64 opt0;
+       __be32 params;
+       __be32 opt2;
+};
+
+struct cpl_act_open_rpl {
+       union opcode_tid ot;
+       __be32 atid_status;
+#define GET_AOPEN_STATUS(x) ((x) & 0xff)
+#define GET_AOPEN_ATID(x)   (((x) >> 8) & 0xffffff)
+};
+
+struct cpl_pass_establish {
+       union opcode_tid ot;
+       __be32 rsvd;
+       __be32 tos_stid;
+#define GET_POPEN_TID(x) ((x) & 0xffffff)
+#define GET_POPEN_TOS(x) (((x) >> 24) & 0xff)
+       __be16 mac_idx;
+       __be16 tcp_opt;
+#define GET_TCPOPT_WSCALE_OK(x)  (((x) >> 5) & 1)
+#define GET_TCPOPT_SACK(x)       (((x) >> 6) & 1)
+#define GET_TCPOPT_TSTAMP(x)     (((x) >> 7) & 1)
+#define GET_TCPOPT_SND_WSCALE(x) (((x) >> 8) & 0xf)
+#define GET_TCPOPT_MSS(x)        (((x) >> 12) & 0xf)
+       __be32 snd_isn;
+       __be32 rcv_isn;
+};
+
+struct cpl_act_establish {
+       union opcode_tid ot;
+       __be32 rsvd;
+       __be32 tos_atid;
+       __be16 mac_idx;
+       __be16 tcp_opt;
+       __be32 snd_isn;
+       __be32 rcv_isn;
+};
+
+struct cpl_get_tcb {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 reply_ctrl;
+#define QUEUENO(x)    ((x) << 0)
+#define REPLY_CHAN(x) ((x) << 14)
+#define NO_REPLY(x)   ((x) << 15)
+       __be16 cookie;
+};
+
+struct cpl_set_tcb_field {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 reply_ctrl;
+       __be16 word_cookie;
+#define TCB_WORD(x)   ((x) << 0)
+#define TCB_COOKIE(x) ((x) << 5)
+       __be64 mask;
+       __be64 val;
+};
+
+struct cpl_set_tcb_rpl {
+       union opcode_tid ot;
+       __be16 rsvd;
+       u8 cookie;
+       u8 status;
+       __be64 oldval;
+};
+
+struct cpl_close_con_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 rsvd;
+};
+
+struct cpl_close_con_rpl {
+       union opcode_tid ot;
+       u8 rsvd[3];
+       u8 status;
+       __be32 snd_nxt;
+       __be32 rcv_nxt;
+};
+
+struct cpl_close_listsvr_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 reply_ctrl;
+#define LISTSVR_IPV6 (1 << 14)
+       __be16 rsvd;
+};
+
+struct cpl_close_listsvr_rpl {
+       union opcode_tid ot;
+       u8 rsvd[3];
+       u8 status;
+};
+
+struct cpl_abort_req_rss {
+       union opcode_tid ot;
+       u8 rsvd[3];
+       u8 status;
+};
+
+struct cpl_abort_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 rsvd0;
+       u8 rsvd1;
+       u8 cmd;
+       u8 rsvd2[6];
+};
+
+struct cpl_abort_rpl_rss {
+       union opcode_tid ot;
+       u8 rsvd[3];
+       u8 status;
+};
+
+struct cpl_abort_rpl {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 rsvd0;
+       u8 rsvd1;
+       u8 cmd;
+       u8 rsvd2[6];
+};
+
+struct cpl_peer_close {
+       union opcode_tid ot;
+       __be32 rcv_nxt;
+};
+
+struct cpl_tid_release {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 rsvd;
+};
+
+struct cpl_tx_pkt_core {
+       __be32 ctrl0;
+#define TXPKT_VF(x)        ((x) << 0)
+#define TXPKT_PF(x)        ((x) << 8)
+#define TXPKT_VF_VLD       (1 << 11)
+#define TXPKT_OVLAN_IDX(x) ((x) << 12)
+#define TXPKT_INTF(x)      ((x) << 16)
+#define TXPKT_INS_OVLAN    (1 << 21)
+#define TXPKT_OPCODE(x)    ((x) << 24)
+       __be16 pack;
+       __be16 len;
+       __be64 ctrl1;
+#define TXPKT_CSUM_END(x)   ((x) << 12)
+#define TXPKT_CSUM_START(x) ((x) << 20)
+#define TXPKT_IPHDR_LEN(x)  ((u64)(x) << 20)
+#define TXPKT_CSUM_LOC(x)   ((u64)(x) << 30)
+#define TXPKT_ETHHDR_LEN(x) ((u64)(x) << 34)
+#define TXPKT_CSUM_TYPE(x)  ((u64)(x) << 40)
+#define TXPKT_VLAN(x)       ((u64)(x) << 44)
+#define TXPKT_VLAN_VLD      (1ULL << 60)
+#define TXPKT_IPCSUM_DIS    (1ULL << 62)
+#define TXPKT_L4CSUM_DIS    (1ULL << 63)
+};
+
+struct cpl_tx_pkt {
+       WR_HDR;
+       struct cpl_tx_pkt_core c;
+};
+
+#define cpl_tx_pkt_xt cpl_tx_pkt
+
+struct cpl_tx_pkt_lso {
+       WR_HDR;
+       __be32 lso_ctrl;
+#define LSO_TCPHDR_LEN(x) ((x) << 0)
+#define LSO_IPHDR_LEN(x)  ((x) << 4)
+#define LSO_ETHHDR_LEN(x) ((x) << 16)
+#define LSO_IPV6(x)       ((x) << 20)
+#define LSO_LAST_SLICE    (1 << 22)
+#define LSO_FIRST_SLICE   (1 << 23)
+#define LSO_OPCODE(x)     ((x) << 24)
+       __be16 ipid_ofst;
+       __be16 mss;
+       __be32 seqno_offset;
+       __be32 len;
+       /* encapsulated CPL (TX_PKT, TX_PKT_XT or TX_DATA) follows here */
+};
+
+struct cpl_iscsi_hdr {
+       union opcode_tid ot;
+       __be16 pdu_len_ddp;
+#define ISCSI_PDU_LEN(x) ((x) & 0x7FFF)
+#define ISCSI_DDP        (1 << 15)
+       __be16 len;
+       __be32 seq;
+       __be16 urg;
+       u8 rsvd;
+       u8 status;
+};
+
+struct cpl_rx_data {
+       union opcode_tid ot;
+       __be16 rsvd;
+       __be16 len;
+       __be32 seq;
+       __be16 urg;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+       u8 dack_mode:2;
+       u8 psh:1;
+       u8 heartbeat:1;
+       u8 ddp_off:1;
+       u8 :3;
+#else
+       u8 :3;
+       u8 ddp_off:1;
+       u8 heartbeat:1;
+       u8 psh:1;
+       u8 dack_mode:2;
+#endif
+       u8 status;
+};
+
+struct cpl_rx_data_ack {
+       WR_HDR;
+       union opcode_tid ot;
+       __be32 credit_dack;
+#define RX_CREDITS(x)   ((x) << 0)
+#define RX_FORCE_ACK(x) ((x) << 28)
+};
+
+struct cpl_rx_pkt {
+       u8 opcode;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+       u8 iff:4;
+       u8 csum_calc:1;
+       u8 ipmi_pkt:1;
+       u8 vlan_ex:1;
+       u8 ip_frag:1;
+#else
+       u8 ip_frag:1;
+       u8 vlan_ex:1;
+       u8 ipmi_pkt:1;
+       u8 csum_calc:1;
+       u8 iff:4;
+#endif
+       __be16 csum;
+       __be16 vlan;
+       __be16 len;
+       __be32 l2info;
+#define RXF_UDP (1 << 22)
+#define RXF_TCP (1 << 23)
+       __be16 hdr_len;
+       __be16 err_vec;
+};
+
+struct cpl_trace_pkt {
+       u8 opcode;
+       u8 intf;
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+       u8 runt:4;
+       u8 filter_hit:4;
+       u8 :6;
+       u8 err:1;
+       u8 trunc:1;
+#else
+       u8 filter_hit:4;
+       u8 runt:4;
+       u8 trunc:1;
+       u8 err:1;
+       u8 :6;
+#endif
+       __be16 rsvd;
+       __be16 len;
+       __be64 tstamp;
+};
+
+struct cpl_l2t_write_req {
+       WR_HDR;
+       union opcode_tid ot;
+       __be16 params;
+#define L2T_W_INFO(x)    ((x) << 2)
+#define L2T_W_PORT(x)    ((x) << 8)
+#define L2T_W_NOREPLY(x) ((x) << 15)
+       __be16 l2t_idx;
+       __be16 vlan;
+       u8 dst_mac[6];
+};
+
+struct cpl_l2t_write_rpl {
+       union opcode_tid ot;
+       u8 status;
+       u8 rsvd[3];
+};
+
+struct cpl_rdma_terminate {
+       union opcode_tid ot;
+       __be16 rsvd;
+       __be16 len;
+};
+
+struct cpl_sge_egr_update {
+       __be32 opcode_qid;
+#define EGR_QID(x) ((x) & 0x1FFFF)
+       __be16 cidx;
+       __be16 pidx;
+};
+
+struct cpl_fw4_pld {
+       u8 opcode;
+       u8 rsvd0[3];
+       u8 type;
+       u8 rsvd1;
+       __be16 len;
+       __be64 data;
+       __be64 rsvd2;
+};
+
+struct cpl_fw6_pld {
+       u8 opcode;
+       u8 rsvd[5];
+       __be16 len;
+       __be64 data[4];
+};
+
+struct cpl_fw4_msg {
+       u8 opcode;
+       u8 type;
+       __be16 rsvd0;
+       __be32 rsvd1;
+       __be64 data[2];
+};
+
+struct cpl_fw4_ack {
+       union opcode_tid ot;
+       u8 credits;
+       u8 rsvd0[2];
+       u8 seq_vld;
+       __be32 snd_nxt;
+       __be32 snd_una;
+       __be64 rsvd1;
+};
+
+struct cpl_fw6_msg {
+       u8 opcode;
+       u8 type;
+       __be16 rsvd0;
+       __be32 rsvd1;
+       __be64 data[4];
+};
+
+enum {
+       ULP_TX_MEM_READ = 2,
+       ULP_TX_MEM_WRITE = 3,
+       ULP_TX_PKT = 4
+};
+
+enum {
+       ULP_TX_SC_NOOP = 0x80,
+       ULP_TX_SC_IMM  = 0x81,
+       ULP_TX_SC_DSGL = 0x82,
+       ULP_TX_SC_ISGL = 0x83
+};
+
+struct ulptx_sge_pair {
+       __be32 len[2];
+       __be64 addr[2];
+};
+
+struct ulptx_sgl {
+       __be32 cmd_nsge;
+#define ULPTX_CMD(x) ((x) << 24)
+#define ULPTX_NSGE(x) ((x) << 0)
+       __be32 len0;
+       __be64 addr0;
+       struct ulptx_sge_pair sge[0];
+};
+
+struct ulp_mem_io {
+       WR_HDR;
+       __be32 cmd;
+#define ULP_MEMIO_ORDER(x) ((x) << 23)
+       __be32 len16;             /* command length */
+       __be32 dlen;              /* data length in 32-byte units */
+#define ULP_MEMIO_DATA_LEN(x) ((x) << 0)
+       __be32 lock_addr;
+#define ULP_MEMIO_ADDR(x) ((x) << 0)
+#define ULP_MEMIO_LOCK(x) ((x) << 31)
+};
+
+#endif  /* __T4_MSG_H */
diff --git a/drivers/net/cxgb4/t4_regs.h b/drivers/net/cxgb4/t4_regs.h
new file mode 100644 (file)
index 0000000..5ed5648
--- /dev/null
@@ -0,0 +1,878 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __T4_REGS_H
+#define __T4_REGS_H
+
+#define MYPF_BASE 0x1b000
+#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr))
+
+#define PF0_BASE 0x1e000
+#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr))
+
+#define PF_STRIDE 0x400
+#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE)
+#define PF_REG(idx, reg) (PF_BASE(idx) + (reg))
+
+#define MYPORT_BASE 0x1c000
+#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr))
+
+#define PORT0_BASE 0x20000
+#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr))
+
+#define PORT_STRIDE 0x2000
+#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE)
+#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg))
+
+#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR)
+#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx)
+
+#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
+#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
+#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
+#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
+
+#define SGE_PF_KDOORBELL 0x0
+#define  QID_MASK    0xffff8000U
+#define  QID_SHIFT   15
+#define  QID(x)      ((x) << QID_SHIFT)
+#define  DBPRIO      0x00004000U
+#define  PIDX_MASK   0x00003fffU
+#define  PIDX_SHIFT  0
+#define  PIDX(x)     ((x) << PIDX_SHIFT)
+
+#define SGE_PF_GTS 0x4
+#define  INGRESSQID_MASK   0xffff0000U
+#define  INGRESSQID_SHIFT  16
+#define  INGRESSQID(x)     ((x) << INGRESSQID_SHIFT)
+#define  TIMERREG_MASK     0x0000e000U
+#define  TIMERREG_SHIFT    13
+#define  TIMERREG(x)       ((x) << TIMERREG_SHIFT)
+#define  SEINTARM_MASK     0x00001000U
+#define  SEINTARM_SHIFT    12
+#define  SEINTARM(x)       ((x) << SEINTARM_SHIFT)
+#define  CIDXINC_MASK      0x00000fffU
+#define  CIDXINC_SHIFT     0
+#define  CIDXINC(x)        ((x) << CIDXINC_SHIFT)
+
+#define SGE_CONTROL 0x1008
+#define  DCASYSTYPE             0x00080000U
+#define  RXPKTCPLMODE           0x00040000U
+#define  EGRSTATUSPAGESIZE      0x00020000U
+#define  PKTSHIFT_MASK          0x00001c00U
+#define  PKTSHIFT_SHIFT         10
+#define  PKTSHIFT(x)            ((x) << PKTSHIFT_SHIFT)
+#define  INGPCIEBOUNDARY_MASK   0x00000380U
+#define  INGPCIEBOUNDARY_SHIFT  7
+#define  INGPCIEBOUNDARY(x)     ((x) << INGPCIEBOUNDARY_SHIFT)
+#define  INGPADBOUNDARY_MASK    0x00000070U
+#define  INGPADBOUNDARY_SHIFT   4
+#define  INGPADBOUNDARY(x)      ((x) << INGPADBOUNDARY_SHIFT)
+#define  EGRPCIEBOUNDARY_MASK   0x0000000eU
+#define  EGRPCIEBOUNDARY_SHIFT  1
+#define  EGRPCIEBOUNDARY(x)     ((x) << EGRPCIEBOUNDARY_SHIFT)
+#define  GLOBALENABLE           0x00000001U
+
+#define SGE_HOST_PAGE_SIZE 0x100c
+#define  HOSTPAGESIZEPF0_MASK   0x0000000fU
+#define  HOSTPAGESIZEPF0_SHIFT  0
+#define  HOSTPAGESIZEPF0(x)     ((x) << HOSTPAGESIZEPF0_SHIFT)
+
+#define SGE_EGRESS_QUEUES_PER_PAGE_PF 0x1010
+#define  QUEUESPERPAGEPF0_MASK   0x0000000fU
+#define  QUEUESPERPAGEPF0_GET(x) ((x) & QUEUESPERPAGEPF0_MASK)
+
+#define SGE_INT_CAUSE1 0x1024
+#define SGE_INT_CAUSE2 0x1030
+#define SGE_INT_CAUSE3 0x103c
+#define  ERR_FLM_DBP               0x80000000U
+#define  ERR_FLM_IDMA1             0x40000000U
+#define  ERR_FLM_IDMA0             0x20000000U
+#define  ERR_FLM_HINT              0x10000000U
+#define  ERR_PCIE_ERROR3           0x08000000U
+#define  ERR_PCIE_ERROR2           0x04000000U
+#define  ERR_PCIE_ERROR1           0x02000000U
+#define  ERR_PCIE_ERROR0           0x01000000U
+#define  ERR_TIMER_ABOVE_MAX_QID   0x00800000U
+#define  ERR_CPL_EXCEED_IQE_SIZE   0x00400000U
+#define  ERR_INVALID_CIDX_INC      0x00200000U
+#define  ERR_ITP_TIME_PAUSED       0x00100000U
+#define  ERR_CPL_OPCODE_0          0x00080000U
+#define  ERR_DROPPED_DB            0x00040000U
+#define  ERR_DATA_CPL_ON_HIGH_QID1 0x00020000U
+#define  ERR_DATA_CPL_ON_HIGH_QID0 0x00010000U
+#define  ERR_BAD_DB_PIDX3          0x00008000U
+#define  ERR_BAD_DB_PIDX2          0x00004000U
+#define  ERR_BAD_DB_PIDX1          0x00002000U
+#define  ERR_BAD_DB_PIDX0          0x00001000U
+#define  ERR_ING_PCIE_CHAN         0x00000800U
+#define  ERR_ING_CTXT_PRIO         0x00000400U
+#define  ERR_EGR_CTXT_PRIO         0x00000200U
+#define  DBFIFO_HP_INT             0x00000100U
+#define  DBFIFO_LP_INT             0x00000080U
+#define  REG_ADDRESS_ERR           0x00000040U
+#define  INGRESS_SIZE_ERR          0x00000020U
+#define  EGRESS_SIZE_ERR           0x00000010U
+#define  ERR_INV_CTXT3             0x00000008U
+#define  ERR_INV_CTXT2             0x00000004U
+#define  ERR_INV_CTXT1             0x00000002U
+#define  ERR_INV_CTXT0             0x00000001U
+
+#define SGE_INT_ENABLE3 0x1040
+#define SGE_FL_BUFFER_SIZE0 0x1044
+#define SGE_FL_BUFFER_SIZE1 0x1048
+#define SGE_INGRESS_RX_THRESHOLD 0x10a0
+#define  THRESHOLD_0_MASK   0x3f000000U
+#define  THRESHOLD_0_SHIFT  24
+#define  THRESHOLD_0(x)     ((x) << THRESHOLD_0_SHIFT)
+#define  THRESHOLD_0_GET(x) (((x) & THRESHOLD_0_MASK) >> THRESHOLD_0_SHIFT)
+#define  THRESHOLD_1_MASK   0x003f0000U
+#define  THRESHOLD_1_SHIFT  16
+#define  THRESHOLD_1(x)     ((x) << THRESHOLD_1_SHIFT)
+#define  THRESHOLD_1_GET(x) (((x) & THRESHOLD_1_MASK) >> THRESHOLD_1_SHIFT)
+#define  THRESHOLD_2_MASK   0x00003f00U
+#define  THRESHOLD_2_SHIFT  8
+#define  THRESHOLD_2(x)     ((x) << THRESHOLD_2_SHIFT)
+#define  THRESHOLD_2_GET(x) (((x) & THRESHOLD_2_MASK) >> THRESHOLD_2_SHIFT)
+#define  THRESHOLD_3_MASK   0x0000003fU
+#define  THRESHOLD_3_SHIFT  0
+#define  THRESHOLD_3(x)     ((x) << THRESHOLD_3_SHIFT)
+#define  THRESHOLD_3_GET(x) (((x) & THRESHOLD_3_MASK) >> THRESHOLD_3_SHIFT)
+
+#define SGE_TIMER_VALUE_0_AND_1 0x10b8
+#define  TIMERVALUE0_MASK   0xffff0000U
+#define  TIMERVALUE0_SHIFT  16
+#define  TIMERVALUE0(x)     ((x) << TIMERVALUE0_SHIFT)
+#define  TIMERVALUE0_GET(x) (((x) & TIMERVALUE0_MASK) >> TIMERVALUE0_SHIFT)
+#define  TIMERVALUE1_MASK   0x0000ffffU
+#define  TIMERVALUE1_SHIFT  0
+#define  TIMERVALUE1(x)     ((x) << TIMERVALUE1_SHIFT)
+#define  TIMERVALUE1_GET(x) (((x) & TIMERVALUE1_MASK) >> TIMERVALUE1_SHIFT)
+
+#define SGE_TIMER_VALUE_2_AND_3 0x10bc
+#define SGE_TIMER_VALUE_4_AND_5 0x10c0
+#define SGE_DEBUG_INDEX 0x10cc
+#define SGE_DEBUG_DATA_HIGH 0x10d0
+#define SGE_DEBUG_DATA_LOW 0x10d4
+#define SGE_INGRESS_QUEUES_PER_PAGE_PF 0x10f4
+
+#define PCIE_PF_CLI 0x44
+#define PCIE_INT_CAUSE 0x3004
+#define  UNXSPLCPLERR  0x20000000U
+#define  PCIEPINT      0x10000000U
+#define  PCIESINT      0x08000000U
+#define  RPLPERR       0x04000000U
+#define  RXWRPERR      0x02000000U
+#define  RXCPLPERR     0x01000000U
+#define  PIOTAGPERR    0x00800000U
+#define  MATAGPERR     0x00400000U
+#define  INTXCLRPERR   0x00200000U
+#define  FIDPERR       0x00100000U
+#define  CFGSNPPERR    0x00080000U
+#define  HRSPPERR      0x00040000U
+#define  HREQPERR      0x00020000U
+#define  HCNTPERR      0x00010000U
+#define  DRSPPERR      0x00008000U
+#define  DREQPERR      0x00004000U
+#define  DCNTPERR      0x00002000U
+#define  CRSPPERR      0x00001000U
+#define  CREQPERR      0x00000800U
+#define  CCNTPERR      0x00000400U
+#define  TARTAGPERR    0x00000200U
+#define  PIOREQPERR    0x00000100U
+#define  PIOCPLPERR    0x00000080U
+#define  MSIXDIPERR    0x00000040U
+#define  MSIXDATAPERR  0x00000020U
+#define  MSIXADDRHPERR 0x00000010U
+#define  MSIXADDRLPERR 0x00000008U
+#define  MSIDATAPERR   0x00000004U
+#define  MSIADDRHPERR  0x00000002U
+#define  MSIADDRLPERR  0x00000001U
+
+#define PCIE_NONFAT_ERR 0x3010
+#define PCIE_MEM_ACCESS_BASE_WIN 0x3068
+#define  PCIEOFST_MASK   0xfffffc00U
+#define  BIR_MASK        0x00000300U
+#define  BIR_SHIFT       8
+#define  BIR(x)          ((x) << BIR_SHIFT)
+#define  WINDOW_MASK     0x000000ffU
+#define  WINDOW_SHIFT    0
+#define  WINDOW(x)       ((x) << WINDOW_SHIFT)
+
+#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS 0x5908
+#define  RNPP 0x80000000U
+#define  RPCP 0x20000000U
+#define  RCIP 0x08000000U
+#define  RCCP 0x04000000U
+#define  RFTP 0x00800000U
+#define  PTRP 0x00100000U
+
+#define PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS 0x59a4
+#define  TPCP 0x40000000U
+#define  TNPP 0x20000000U
+#define  TFTP 0x10000000U
+#define  TCAP 0x08000000U
+#define  TCIP 0x04000000U
+#define  RCAP 0x02000000U
+#define  PLUP 0x00800000U
+#define  PLDN 0x00400000U
+#define  OTDD 0x00200000U
+#define  GTRP 0x00100000U
+#define  RDPE 0x00040000U
+#define  TDCE 0x00020000U
+#define  TDUE 0x00010000U
+
+#define MC_INT_CAUSE 0x7518
+#define  ECC_UE_INT_CAUSE 0x00000004U
+#define  ECC_CE_INT_CAUSE 0x00000002U
+#define  PERR_INT_CAUSE   0x00000001U
+
+#define MC_ECC_STATUS 0x751c
+#define  ECC_CECNT_MASK   0xffff0000U
+#define  ECC_CECNT_SHIFT  16
+#define  ECC_CECNT(x)     ((x) << ECC_CECNT_SHIFT)
+#define  ECC_CECNT_GET(x) (((x) & ECC_CECNT_MASK) >> ECC_CECNT_SHIFT)
+#define  ECC_UECNT_MASK   0x0000ffffU
+#define  ECC_UECNT_SHIFT  0
+#define  ECC_UECNT(x)     ((x) << ECC_UECNT_SHIFT)
+#define  ECC_UECNT_GET(x) (((x) & ECC_UECNT_MASK) >> ECC_UECNT_SHIFT)
+
+#define MC_BIST_CMD 0x7600
+#define  START_BIST          0x80000000U
+#define  BIST_CMD_GAP_MASK   0x0000ff00U
+#define  BIST_CMD_GAP_SHIFT  8
+#define  BIST_CMD_GAP(x)     ((x) << BIST_CMD_GAP_SHIFT)
+#define  BIST_OPCODE_MASK    0x00000003U
+#define  BIST_OPCODE_SHIFT   0
+#define  BIST_OPCODE(x)      ((x) << BIST_OPCODE_SHIFT)
+
+#define MC_BIST_CMD_ADDR 0x7604
+#define MC_BIST_CMD_LEN 0x7608
+#define MC_BIST_DATA_PATTERN 0x760c
+#define  BIST_DATA_TYPE_MASK   0x0000000fU
+#define  BIST_DATA_TYPE_SHIFT  0
+#define  BIST_DATA_TYPE(x)     ((x) << BIST_DATA_TYPE_SHIFT)
+
+#define MC_BIST_STATUS_RDATA 0x7688
+
+#define MA_EXT_MEMORY_BAR 0x77c8
+#define  EXT_MEM_SIZE_MASK   0x00000fffU
+#define  EXT_MEM_SIZE_SHIFT  0
+#define  EXT_MEM_SIZE_GET(x) (((x) & EXT_MEM_SIZE_MASK) >> EXT_MEM_SIZE_SHIFT)
+
+#define MA_TARGET_MEM_ENABLE 0x77d8
+#define  EXT_MEM_ENABLE 0x00000004U
+#define  EDRAM1_ENABLE  0x00000002U
+#define  EDRAM0_ENABLE  0x00000001U
+
+#define MA_INT_CAUSE 0x77e0
+#define  MEM_PERR_INT_CAUSE 0x00000002U
+#define  MEM_WRAP_INT_CAUSE 0x00000001U
+
+#define MA_INT_WRAP_STATUS 0x77e4
+#define  MEM_WRAP_ADDRESS_MASK   0xfffffff0U
+#define  MEM_WRAP_ADDRESS_SHIFT  4
+#define  MEM_WRAP_ADDRESS_GET(x) (((x) & MEM_WRAP_ADDRESS_MASK) >> MEM_WRAP_ADDRESS_SHIFT)
+#define  MEM_WRAP_CLIENT_NUM_MASK   0x0000000fU
+#define  MEM_WRAP_CLIENT_NUM_SHIFT  0
+#define  MEM_WRAP_CLIENT_NUM_GET(x) (((x) & MEM_WRAP_CLIENT_NUM_MASK) >> MEM_WRAP_CLIENT_NUM_SHIFT)
+
+#define MA_PARITY_ERROR_STATUS 0x77f4
+
+#define EDC_0_BASE_ADDR 0x7900
+
+#define EDC_BIST_CMD 0x7904
+#define EDC_BIST_CMD_ADDR 0x7908
+#define EDC_BIST_CMD_LEN 0x790c
+#define EDC_BIST_DATA_PATTERN 0x7910
+#define EDC_BIST_STATUS_RDATA 0x7928
+#define EDC_INT_CAUSE 0x7978
+#define  ECC_UE_PAR     0x00000020U
+#define  ECC_CE_PAR     0x00000010U
+#define  PERR_PAR_CAUSE 0x00000008U
+
+#define EDC_ECC_STATUS 0x797c
+
+#define EDC_1_BASE_ADDR 0x7980
+
+#define CIM_PF_MAILBOX_DATA 0x240
+#define CIM_PF_MAILBOX_CTRL 0x280
+#define  MBMSGVALID     0x00000008U
+#define  MBINTREQ       0x00000004U
+#define  MBOWNER_MASK   0x00000003U
+#define  MBOWNER_SHIFT  0
+#define  MBOWNER(x)     ((x) << MBOWNER_SHIFT)
+#define  MBOWNER_GET(x) (((x) & MBOWNER_MASK) >> MBOWNER_SHIFT)
+
+#define CIM_PF_HOST_INT_CAUSE 0x28c
+#define  MBMSGRDYINT 0x00080000U
+
+#define CIM_HOST_INT_CAUSE 0x7b2c
+#define  TIEQOUTPARERRINT  0x00100000U
+#define  TIEQINPARERRINT   0x00080000U
+#define  MBHOSTPARERR      0x00040000U
+#define  MBUPPARERR        0x00020000U
+#define  IBQPARERR         0x0001f800U
+#define  IBQTP0PARERR      0x00010000U
+#define  IBQTP1PARERR      0x00008000U
+#define  IBQULPPARERR      0x00004000U
+#define  IBQSGELOPARERR    0x00002000U
+#define  IBQSGEHIPARERR    0x00001000U
+#define  IBQNCSIPARERR     0x00000800U
+#define  OBQPARERR         0x000007e0U
+#define  OBQULP0PARERR     0x00000400U
+#define  OBQULP1PARERR     0x00000200U
+#define  OBQULP2PARERR     0x00000100U
+#define  OBQULP3PARERR     0x00000080U
+#define  OBQSGEPARERR      0x00000040U
+#define  OBQNCSIPARERR     0x00000020U
+#define  PREFDROPINT       0x00000002U
+#define  UPACCNONZERO      0x00000001U
+
+#define CIM_HOST_UPACC_INT_CAUSE 0x7b34
+#define  EEPROMWRINT      0x40000000U
+#define  TIMEOUTMAINT     0x20000000U
+#define  TIMEOUTINT       0x10000000U
+#define  RSPOVRLOOKUPINT  0x08000000U
+#define  REQOVRLOOKUPINT  0x04000000U
+#define  BLKWRPLINT       0x02000000U
+#define  BLKRDPLINT       0x01000000U
+#define  SGLWRPLINT       0x00800000U
+#define  SGLRDPLINT       0x00400000U
+#define  BLKWRCTLINT      0x00200000U
+#define  BLKRDCTLINT      0x00100000U
+#define  SGLWRCTLINT      0x00080000U
+#define  SGLRDCTLINT      0x00040000U
+#define  BLKWREEPROMINT   0x00020000U
+#define  BLKRDEEPROMINT   0x00010000U
+#define  SGLWREEPROMINT   0x00008000U
+#define  SGLRDEEPROMINT   0x00004000U
+#define  BLKWRFLASHINT    0x00002000U
+#define  BLKRDFLASHINT    0x00001000U
+#define  SGLWRFLASHINT    0x00000800U
+#define  SGLRDFLASHINT    0x00000400U
+#define  BLKWRBOOTINT     0x00000200U
+#define  BLKRDBOOTINT     0x00000100U
+#define  SGLWRBOOTINT     0x00000080U
+#define  SGLRDBOOTINT     0x00000040U
+#define  ILLWRBEINT       0x00000020U
+#define  ILLRDBEINT       0x00000010U
+#define  ILLRDINT         0x00000008U
+#define  ILLWRINT         0x00000004U
+#define  ILLTRANSINT      0x00000002U
+#define  RSVDSPACEINT     0x00000001U
+
+#define TP_OUT_CONFIG 0x7d04
+#define  VLANEXTENABLE_MASK  0x0000f000U
+#define  VLANEXTENABLE_SHIFT 12
+
+#define TP_PARA_REG2 0x7d68
+#define  MAXRXDATA_MASK    0xffff0000U
+#define  MAXRXDATA_SHIFT   16
+#define  MAXRXDATA_GET(x) (((x) & MAXRXDATA_MASK) >> MAXRXDATA_SHIFT)
+
+#define TP_TIMER_RESOLUTION 0x7d90
+#define  TIMERRESOLUTION_MASK   0x00ff0000U
+#define  TIMERRESOLUTION_SHIFT  16
+#define  TIMERRESOLUTION_GET(x) (((x) & TIMERRESOLUTION_MASK) >> TIMERRESOLUTION_SHIFT)
+
+#define TP_SHIFT_CNT 0x7dc0
+
+#define TP_CCTRL_TABLE 0x7ddc
+#define TP_MTU_TABLE 0x7de4
+#define  MTUINDEX_MASK   0xff000000U
+#define  MTUINDEX_SHIFT  24
+#define  MTUINDEX(x)     ((x) << MTUINDEX_SHIFT)
+#define  MTUWIDTH_MASK   0x000f0000U
+#define  MTUWIDTH_SHIFT  16
+#define  MTUWIDTH(x)     ((x) << MTUWIDTH_SHIFT)
+#define  MTUWIDTH_GET(x) (((x) & MTUWIDTH_MASK) >> MTUWIDTH_SHIFT)
+#define  MTUVALUE_MASK   0x00003fffU
+#define  MTUVALUE_SHIFT  0
+#define  MTUVALUE(x)     ((x) << MTUVALUE_SHIFT)
+#define  MTUVALUE_GET(x) (((x) & MTUVALUE_MASK) >> MTUVALUE_SHIFT)
+
+#define TP_RSS_LKP_TABLE 0x7dec
+#define  LKPTBLROWVLD        0x80000000U
+#define  LKPTBLQUEUE1_MASK   0x000ffc00U
+#define  LKPTBLQUEUE1_SHIFT  10
+#define  LKPTBLQUEUE1(x)     ((x) << LKPTBLQUEUE1_SHIFT)
+#define  LKPTBLQUEUE1_GET(x) (((x) & LKPTBLQUEUE1_MASK) >> LKPTBLQUEUE1_SHIFT)
+#define  LKPTBLQUEUE0_MASK   0x000003ffU
+#define  LKPTBLQUEUE0_SHIFT  0
+#define  LKPTBLQUEUE0(x)     ((x) << LKPTBLQUEUE0_SHIFT)
+#define  LKPTBLQUEUE0_GET(x) (((x) & LKPTBLQUEUE0_MASK) >> LKPTBLQUEUE0_SHIFT)
+
+#define TP_PIO_ADDR 0x7e40
+#define TP_PIO_DATA 0x7e44
+#define TP_MIB_INDEX 0x7e50
+#define TP_MIB_DATA 0x7e54
+#define TP_INT_CAUSE 0x7e74
+#define  FLMTXFLSTEMPTY 0x40000000U
+
+#define TP_INGRESS_CONFIG 0x141
+#define  VNIC                0x00000800U
+#define  CSUM_HAS_PSEUDO_HDR 0x00000400U
+#define  RM_OVLAN            0x00000200U
+#define  LOOKUPEVERYPKT      0x00000100U
+
+#define TP_MIB_MAC_IN_ERR_0 0x0
+#define TP_MIB_TCP_OUT_RST 0xc
+#define TP_MIB_TCP_IN_SEG_HI 0x10
+#define TP_MIB_TCP_IN_SEG_LO 0x11
+#define TP_MIB_TCP_OUT_SEG_HI 0x12
+#define TP_MIB_TCP_OUT_SEG_LO 0x13
+#define TP_MIB_TCP_RXT_SEG_HI 0x14
+#define TP_MIB_TCP_RXT_SEG_LO 0x15
+#define TP_MIB_TNL_CNG_DROP_0 0x18
+#define TP_MIB_TCP_V6IN_ERR_0 0x28
+#define TP_MIB_TCP_V6OUT_RST 0x2c
+#define TP_MIB_OFD_ARP_DROP 0x36
+#define TP_MIB_TNL_DROP_0 0x44
+#define TP_MIB_OFD_VLN_DROP_0 0x58
+
+#define ULP_TX_INT_CAUSE 0x8dcc
+#define  PBL_BOUND_ERR_CH3 0x80000000U
+#define  PBL_BOUND_ERR_CH2 0x40000000U
+#define  PBL_BOUND_ERR_CH1 0x20000000U
+#define  PBL_BOUND_ERR_CH0 0x10000000U
+
+#define PM_RX_INT_CAUSE 0x8fdc
+#define  ZERO_E_CMD_ERROR     0x00400000U
+#define  PMRX_FRAMING_ERROR   0x003ffff0U
+#define  OCSPI_PAR_ERROR      0x00000008U
+#define  DB_OPTIONS_PAR_ERROR 0x00000004U
+#define  IESPI_PAR_ERROR      0x00000002U
+#define  E_PCMD_PAR_ERROR     0x00000001U
+
+#define PM_TX_INT_CAUSE 0x8ffc
+#define  PCMD_LEN_OVFL0     0x80000000U
+#define  PCMD_LEN_OVFL1     0x40000000U
+#define  PCMD_LEN_OVFL2     0x20000000U
+#define  ZERO_C_CMD_ERROR   0x10000000U
+#define  PMTX_FRAMING_ERROR 0x0ffffff0U
+#define  OESPI_PAR_ERROR    0x00000008U
+#define  ICSPI_PAR_ERROR    0x00000002U
+#define  C_PCMD_PAR_ERROR   0x00000001U
+
+#define MPS_PORT_STAT_TX_PORT_BYTES_L 0x400
+#define MPS_PORT_STAT_TX_PORT_BYTES_H 0x404
+#define MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408
+#define MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c
+#define MPS_PORT_STAT_TX_PORT_BCAST_L 0x410
+#define MPS_PORT_STAT_TX_PORT_BCAST_H 0x414
+#define MPS_PORT_STAT_TX_PORT_MCAST_L 0x418
+#define MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c
+#define MPS_PORT_STAT_TX_PORT_UCAST_L 0x420
+#define MPS_PORT_STAT_TX_PORT_UCAST_H 0x424
+#define MPS_PORT_STAT_TX_PORT_ERROR_L 0x428
+#define MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c
+#define MPS_PORT_STAT_TX_PORT_64B_L 0x430
+#define MPS_PORT_STAT_TX_PORT_64B_H 0x434
+#define MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438
+#define MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c
+#define MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440
+#define MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444
+#define MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448
+#define MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c
+#define MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450
+#define MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454
+#define MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458
+#define MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c
+#define MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460
+#define MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464
+#define MPS_PORT_STAT_TX_PORT_DROP_L 0x468
+#define MPS_PORT_STAT_TX_PORT_DROP_H 0x46c
+#define MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470
+#define MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474
+#define MPS_PORT_STAT_TX_PORT_PPP0_L 0x478
+#define MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c
+#define MPS_PORT_STAT_TX_PORT_PPP1_L 0x480
+#define MPS_PORT_STAT_TX_PORT_PPP1_H 0x484
+#define MPS_PORT_STAT_TX_PORT_PPP2_L 0x488
+#define MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c
+#define MPS_PORT_STAT_TX_PORT_PPP3_L 0x490
+#define MPS_PORT_STAT_TX_PORT_PPP3_H 0x494
+#define MPS_PORT_STAT_TX_PORT_PPP4_L 0x498
+#define MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c
+#define MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0
+#define MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4
+#define MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8
+#define MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac
+#define MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0
+#define MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4
+#define MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0
+#define MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4
+#define MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8
+#define MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc
+#define MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0
+#define MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4
+#define MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8
+#define MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc
+#define MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0
+#define MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4
+#define MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8
+#define MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec
+#define MPS_PORT_STAT_LB_PORT_64B_L 0x4f0
+#define MPS_PORT_STAT_LB_PORT_64B_H 0x4f4
+#define MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8
+#define MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc
+#define MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500
+#define MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504
+#define MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508
+#define MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c
+#define MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510
+#define MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514
+#define MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518
+#define MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c
+#define MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520
+#define MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524
+#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528
+#define MPS_PORT_STAT_RX_PORT_BYTES_L 0x540
+#define MPS_PORT_STAT_RX_PORT_BYTES_H 0x544
+#define MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548
+#define MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c
+#define MPS_PORT_STAT_RX_PORT_BCAST_L 0x550
+#define MPS_PORT_STAT_RX_PORT_BCAST_H 0x554
+#define MPS_PORT_STAT_RX_PORT_MCAST_L 0x558
+#define MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c
+#define MPS_PORT_STAT_RX_PORT_UCAST_L 0x560
+#define MPS_PORT_STAT_RX_PORT_UCAST_H 0x564
+#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568
+#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c
+#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570
+#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574
+#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578
+#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c
+#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580
+#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584
+#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588
+#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c
+#define MPS_PORT_STAT_RX_PORT_64B_L 0x590
+#define MPS_PORT_STAT_RX_PORT_64B_H 0x594
+#define MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598
+#define MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c
+#define MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0
+#define MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4
+#define MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8
+#define MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac
+#define MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0
+#define MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4
+#define MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8
+#define MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc
+#define MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0
+#define MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4
+#define MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8
+#define MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc
+#define MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0
+#define MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4
+#define MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8
+#define MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc
+#define MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0
+#define MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4
+#define MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8
+#define MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec
+#define MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0
+#define MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4
+#define MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8
+#define MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc
+#define MPS_PORT_STAT_RX_PORT_PPP6_L 0x600
+#define MPS_PORT_STAT_RX_PORT_PPP6_H 0x604
+#define MPS_PORT_STAT_RX_PORT_PPP7_L 0x608
+#define MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c
+#define MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610
+#define MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614
+#define MPS_CMN_CTL 0x9000
+#define  NUMPORTS_MASK   0x00000003U
+#define  NUMPORTS_SHIFT  0
+#define  NUMPORTS_GET(x) (((x) & NUMPORTS_MASK) >> NUMPORTS_SHIFT)
+
+#define MPS_INT_CAUSE 0x9008
+#define  STATINT 0x00000020U
+#define  TXINT   0x00000010U
+#define  RXINT   0x00000008U
+#define  TRCINT  0x00000004U
+#define  CLSINT  0x00000002U
+#define  PLINT   0x00000001U
+
+#define MPS_TX_INT_CAUSE 0x9408
+#define  PORTERR    0x00010000U
+#define  FRMERR     0x00008000U
+#define  SECNTERR   0x00004000U
+#define  BUBBLE     0x00002000U
+#define  TXDESCFIFO 0x00001e00U
+#define  TXDATAFIFO 0x000001e0U
+#define  NCSIFIFO   0x00000010U
+#define  TPFIFO     0x0000000fU
+
+#define MPS_STAT_PERR_INT_CAUSE_SRAM 0x9614
+#define MPS_STAT_PERR_INT_CAUSE_TX_FIFO 0x9620
+#define MPS_STAT_PERR_INT_CAUSE_RX_FIFO 0x962c
+
+#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640
+#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644
+#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648
+#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c
+#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650
+#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654
+#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658
+#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c
+#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660
+#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664
+#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668
+#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c
+#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670
+#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674
+#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678
+#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c
+#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680
+#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684
+#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688
+#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c
+#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690
+#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694
+#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698
+#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c
+#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0
+#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4
+#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8
+#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac
+#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0
+#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4
+#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8
+#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc
+#define MPS_TRC_CFG 0x9800
+#define  TRCFIFOEMPTY       0x00000010U
+#define  TRCIGNOREDROPINPUT 0x00000008U
+#define  TRCKEEPDUPLICATES  0x00000004U
+#define  TRCEN              0x00000002U
+#define  TRCMULTIFILTER     0x00000001U
+
+#define MPS_TRC_RSS_CONTROL 0x9808
+#define  RSSCONTROL_MASK    0x00ff0000U
+#define  RSSCONTROL_SHIFT   16
+#define  RSSCONTROL(x)      ((x) << RSSCONTROL_SHIFT)
+#define  QUEUENUMBER_MASK   0x0000ffffU
+#define  QUEUENUMBER_SHIFT  0
+#define  QUEUENUMBER(x)     ((x) << QUEUENUMBER_SHIFT)
+
+#define MPS_TRC_FILTER_MATCH_CTL_A 0x9810
+#define  TFINVERTMATCH   0x01000000U
+#define  TFPKTTOOLARGE   0x00800000U
+#define  TFEN            0x00400000U
+#define  TFPORT_MASK     0x003c0000U
+#define  TFPORT_SHIFT    18
+#define  TFPORT(x)       ((x) << TFPORT_SHIFT)
+#define  TFPORT_GET(x)   (((x) & TFPORT_MASK) >> TFPORT_SHIFT)
+#define  TFDROP          0x00020000U
+#define  TFSOPEOPERR     0x00010000U
+#define  TFLENGTH_MASK   0x00001f00U
+#define  TFLENGTH_SHIFT  8
+#define  TFLENGTH(x)     ((x) << TFLENGTH_SHIFT)
+#define  TFLENGTH_GET(x) (((x) & TFLENGTH_MASK) >> TFLENGTH_SHIFT)
+#define  TFOFFSET_MASK   0x0000001fU
+#define  TFOFFSET_SHIFT  0
+#define  TFOFFSET(x)     ((x) << TFOFFSET_SHIFT)
+#define  TFOFFSET_GET(x) (((x) & TFOFFSET_MASK) >> TFOFFSET_SHIFT)
+
+#define MPS_TRC_FILTER_MATCH_CTL_B 0x9820
+#define  TFMINPKTSIZE_MASK   0x01ff0000U
+#define  TFMINPKTSIZE_SHIFT  16
+#define  TFMINPKTSIZE(x)     ((x) << TFMINPKTSIZE_SHIFT)
+#define  TFMINPKTSIZE_GET(x) (((x) & TFMINPKTSIZE_MASK) >> TFMINPKTSIZE_SHIFT)
+#define  TFCAPTUREMAX_MASK   0x00003fffU
+#define  TFCAPTUREMAX_SHIFT  0
+#define  TFCAPTUREMAX(x)     ((x) << TFCAPTUREMAX_SHIFT)
+#define  TFCAPTUREMAX_GET(x) (((x) & TFCAPTUREMAX_MASK) >> TFCAPTUREMAX_SHIFT)
+
+#define MPS_TRC_INT_CAUSE 0x985c
+#define  MISCPERR 0x00000100U
+#define  PKTFIFO  0x000000f0U
+#define  FILTMEM  0x0000000fU
+
+#define MPS_TRC_FILTER0_MATCH 0x9c00
+#define MPS_TRC_FILTER0_DONT_CARE 0x9c80
+#define MPS_TRC_FILTER1_MATCH 0x9d00
+#define MPS_CLS_INT_CAUSE 0xd028
+#define  PLERRENB  0x00000008U
+#define  HASHSRAM  0x00000004U
+#define  MATCHTCAM 0x00000002U
+#define  MATCHSRAM 0x00000001U
+
+#define MPS_RX_PERR_INT_CAUSE 0x11074
+
+#define CPL_INTR_CAUSE 0x19054
+#define  CIM_OP_MAP_PERR   0x00000020U
+#define  CIM_OVFL_ERROR    0x00000010U
+#define  TP_FRAMING_ERROR  0x00000008U
+#define  SGE_FRAMING_ERROR 0x00000004U
+#define  CIM_FRAMING_ERROR 0x00000002U
+#define  ZERO_SWITCH_ERROR 0x00000001U
+
+#define SMB_INT_CAUSE 0x19090
+#define  MSTTXFIFOPARINT 0x00200000U
+#define  MSTRXFIFOPARINT 0x00100000U
+#define  SLVFIFOPARINT   0x00080000U
+
+#define ULP_RX_INT_CAUSE 0x19158
+#define ULP_RX_ISCSI_TAGMASK 0x19164
+#define ULP_RX_ISCSI_PSZ 0x19168
+#define  HPZ3_MASK   0x0f000000U
+#define  HPZ3_SHIFT  24
+#define  HPZ3(x)     ((x) << HPZ3_SHIFT)
+#define  HPZ2_MASK   0x000f0000U
+#define  HPZ2_SHIFT  16
+#define  HPZ2(x)     ((x) << HPZ2_SHIFT)
+#define  HPZ1_MASK   0x00000f00U
+#define  HPZ1_SHIFT  8
+#define  HPZ1(x)     ((x) << HPZ1_SHIFT)
+#define  HPZ0_MASK   0x0000000fU
+#define  HPZ0_SHIFT  0
+#define  HPZ0(x)     ((x) << HPZ0_SHIFT)
+
+#define ULP_RX_TDDP_PSZ 0x19178
+
+#define SF_DATA 0x193f8
+#define SF_OP 0x193fc
+#define  BUSY          0x80000000U
+#define  SF_LOCK       0x00000010U
+#define  SF_CONT       0x00000008U
+#define  BYTECNT_MASK  0x00000006U
+#define  BYTECNT_SHIFT 1
+#define  BYTECNT(x)    ((x) << BYTECNT_SHIFT)
+#define  OP_WR         0x00000001U
+
+#define PL_PF_INT_CAUSE 0x3c0
+#define  PFSW  0x00000008U
+#define  PFSGE 0x00000004U
+#define  PFCIM 0x00000002U
+#define  PFMPS 0x00000001U
+
+#define PL_PF_INT_ENABLE 0x3c4
+#define PL_PF_CTL 0x3c8
+#define  SWINT 0x00000001U
+
+#define PL_WHOAMI 0x19400
+#define  SOURCEPF_MASK   0x00000700U
+#define  SOURCEPF_SHIFT  8
+#define  SOURCEPF(x)     ((x) << SOURCEPF_SHIFT)
+#define  SOURCEPF_GET(x) (((x) & SOURCEPF_MASK) >> SOURCEPF_SHIFT)
+#define  ISVF            0x00000080U
+#define  VFID_MASK       0x0000007fU
+#define  VFID_SHIFT      0
+#define  VFID(x)         ((x) << VFID_SHIFT)
+#define  VFID_GET(x)     (((x) & VFID_MASK) >> VFID_SHIFT)
+
+#define PL_INT_CAUSE 0x1940c
+#define  ULP_TX     0x08000000U
+#define  SGE        0x04000000U
+#define  HMA        0x02000000U
+#define  CPL_SWITCH 0x01000000U
+#define  ULP_RX     0x00800000U
+#define  PM_RX      0x00400000U
+#define  PM_TX      0x00200000U
+#define  MA         0x00100000U
+#define  TP         0x00080000U
+#define  LE         0x00040000U
+#define  EDC1       0x00020000U
+#define  EDC0       0x00010000U
+#define  MC         0x00008000U
+#define  PCIE       0x00004000U
+#define  PMU        0x00002000U
+#define  XGMAC_KR1  0x00001000U
+#define  XGMAC_KR0  0x00000800U
+#define  XGMAC1     0x00000400U
+#define  XGMAC0     0x00000200U
+#define  SMB        0x00000100U
+#define  SF         0x00000080U
+#define  PL         0x00000040U
+#define  NCSI       0x00000020U
+#define  MPS        0x00000010U
+#define  MI         0x00000008U
+#define  DBG        0x00000004U
+#define  I2CM       0x00000002U
+#define  CIM        0x00000001U
+
+#define PL_INT_MAP0 0x19414
+#define PL_RST 0x19428
+#define  PIORST     0x00000002U
+#define  PIORSTMODE 0x00000001U
+
+#define PL_PL_INT_CAUSE 0x19430
+#define  FATALPERR 0x00000010U
+#define  PERRVFID  0x00000001U
+
+#define PL_REV 0x1943c
+
+#define LE_DB_CONFIG 0x19c04
+#define  HASHEN 0x00100000U
+
+#define LE_DB_SERVER_INDEX 0x19c18
+#define LE_DB_ACT_CNT_IPV4 0x19c20
+#define LE_DB_ACT_CNT_IPV6 0x19c24
+
+#define LE_DB_INT_CAUSE 0x19c3c
+#define  REQQPARERR 0x00010000U
+#define  UNKNOWNCMD 0x00008000U
+#define  PARITYERR  0x00000040U
+#define  LIPMISS    0x00000020U
+#define  LIP0       0x00000010U
+
+#define LE_DB_TID_HASHBASE 0x19df8
+
+#define NCSI_INT_CAUSE 0x1a0d8
+#define  CIM_DM_PRTY_ERR 0x00000100U
+#define  MPS_DM_PRTY_ERR 0x00000080U
+#define  TXFIFO_PRTY_ERR 0x00000002U
+#define  RXFIFO_PRTY_ERR 0x00000001U
+
+#define XGMAC_PORT_CFG2 0x1018
+#define  PATEN   0x00040000U
+#define  MAGICEN 0x00020000U
+
+#define XGMAC_PORT_MAGIC_MACID_LO 0x1024
+#define XGMAC_PORT_MAGIC_MACID_HI 0x1028
+
+#define XGMAC_PORT_EPIO_DATA0 0x10c0
+#define XGMAC_PORT_EPIO_DATA1 0x10c4
+#define XGMAC_PORT_EPIO_DATA2 0x10c8
+#define XGMAC_PORT_EPIO_DATA3 0x10cc
+#define XGMAC_PORT_EPIO_OP 0x10d0
+#define  EPIOWR         0x00000100U
+#define  ADDRESS_MASK   0x000000ffU
+#define  ADDRESS_SHIFT  0
+#define  ADDRESS(x)     ((x) << ADDRESS_SHIFT)
+
+#define XGMAC_PORT_INT_CAUSE 0x10dc
+#endif /* __T4_REGS_H */
diff --git a/drivers/net/cxgb4/t4fw_api.h b/drivers/net/cxgb4/t4fw_api.h
new file mode 100644 (file)
index 0000000..3393d05
--- /dev/null
@@ -0,0 +1,1580 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _T4FW_INTERFACE_H_
+#define _T4FW_INTERFACE_H_
+
+#define FW_T4VF_SGE_BASE_ADDR      0x0000
+#define FW_T4VF_MPS_BASE_ADDR      0x0100
+#define FW_T4VF_PL_BASE_ADDR       0x0200
+#define FW_T4VF_MBDATA_BASE_ADDR   0x0240
+#define FW_T4VF_CIM_BASE_ADDR      0x0300
+
+enum fw_wr_opcodes {
+       FW_FILTER_WR                   = 0x02,
+       FW_ULPTX_WR                    = 0x04,
+       FW_TP_WR                       = 0x05,
+       FW_ETH_TX_PKT_WR               = 0x08,
+       FW_FLOWC_WR                    = 0x0a,
+       FW_OFLD_TX_DATA_WR             = 0x0b,
+       FW_CMD_WR                      = 0x10,
+       FW_ETH_TX_PKT_VM_WR            = 0x11,
+       FW_RI_RES_WR                   = 0x0c,
+       FW_RI_INIT_WR                  = 0x0d,
+       FW_RI_RDMA_WRITE_WR            = 0x14,
+       FW_RI_SEND_WR                  = 0x15,
+       FW_RI_RDMA_READ_WR             = 0x16,
+       FW_RI_RECV_WR                  = 0x17,
+       FW_RI_BIND_MW_WR               = 0x18,
+       FW_RI_FR_NSMR_WR               = 0x19,
+       FW_RI_INV_LSTAG_WR             = 0x1a,
+       FW_LASTC2E_WR                  = 0x40
+};
+
+struct fw_wr_hdr {
+       __be32 hi;
+       __be32 lo;
+};
+
+#define FW_WR_OP(x)     ((x) << 24)
+#define FW_WR_ATOMIC(x)         ((x) << 23)
+#define FW_WR_FLUSH(x)   ((x) << 22)
+#define FW_WR_COMPL(x)   ((x) << 21)
+#define FW_WR_IMMDLEN(x) ((x) << 0)
+
+#define FW_WR_EQUIQ    (1U << 31)
+#define FW_WR_EQUEQ    (1U << 30)
+#define FW_WR_FLOWID(x)        ((x) << 8)
+#define FW_WR_LEN16(x) ((x) << 0)
+
+struct fw_ulptx_wr {
+       __be32 op_to_compl;
+       __be32 flowid_len16;
+       u64 cookie;
+};
+
+struct fw_tp_wr {
+       __be32 op_to_immdlen;
+       __be32 flowid_len16;
+       u64 cookie;
+};
+
+struct fw_eth_tx_pkt_wr {
+       __be32 op_immdlen;
+       __be32 equiq_to_len16;
+       __be64 r3;
+};
+
+enum fw_flowc_mnem {
+       FW_FLOWC_MNEM_PFNVFN,           /* PFN [15:8] VFN [7:0] */
+       FW_FLOWC_MNEM_CH,
+       FW_FLOWC_MNEM_PORT,
+       FW_FLOWC_MNEM_IQID,
+       FW_FLOWC_MNEM_SNDNXT,
+       FW_FLOWC_MNEM_RCVNXT,
+       FW_FLOWC_MNEM_SNDBUF,
+       FW_FLOWC_MNEM_MSS,
+};
+
+struct fw_flowc_mnemval {
+       u8 mnemonic;
+       u8 r4[3];
+       __be32 val;
+};
+
+struct fw_flowc_wr {
+       __be32 op_to_nparams;
+#define FW_FLOWC_WR_NPARAMS(x) ((x) << 0)
+       __be32 flowid_len16;
+       struct fw_flowc_mnemval mnemval[0];
+};
+
+struct fw_ofld_tx_data_wr {
+       __be32 op_to_immdlen;
+       __be32 flowid_len16;
+       __be32 plen;
+       __be32 tunnel_to_proxy;
+#define FW_OFLD_TX_DATA_WR_TUNNEL(x)    ((x) << 19)
+#define FW_OFLD_TX_DATA_WR_SAVE(x)      ((x) << 18)
+#define FW_OFLD_TX_DATA_WR_FLUSH(x)     ((x) << 17)
+#define FW_OFLD_TX_DATA_WR_URGENT(x)    ((x) << 16)
+#define FW_OFLD_TX_DATA_WR_MORE(x)      ((x) << 15)
+#define FW_OFLD_TX_DATA_WR_SHOVE(x)     ((x) << 14)
+#define FW_OFLD_TX_DATA_WR_ULPMODE(x)   ((x) << 10)
+#define FW_OFLD_TX_DATA_WR_ULPSUBMODE(x) ((x) << 6)
+};
+
+struct fw_cmd_wr {
+       __be32 op_dma;
+#define FW_CMD_WR_DMA (1U << 17)
+       __be32 len16_pkd;
+       __be64 cookie_daddr;
+};
+
+struct fw_eth_tx_pkt_vm_wr {
+       __be32 op_immdlen;
+       __be32 equiq_to_len16;
+       __be32 r3[2];
+       u8 ethmacdst[6];
+       u8 ethmacsrc[6];
+       __be16 ethtype;
+       __be16 vlantci;
+};
+
+#define FW_CMD_MAX_TIMEOUT 3000
+
+enum fw_cmd_opcodes {
+       FW_LDST_CMD                    = 0x01,
+       FW_RESET_CMD                   = 0x03,
+       FW_HELLO_CMD                   = 0x04,
+       FW_BYE_CMD                     = 0x05,
+       FW_INITIALIZE_CMD              = 0x06,
+       FW_CAPS_CONFIG_CMD             = 0x07,
+       FW_PARAMS_CMD                  = 0x08,
+       FW_PFVF_CMD                    = 0x09,
+       FW_IQ_CMD                      = 0x10,
+       FW_EQ_MNGT_CMD                 = 0x11,
+       FW_EQ_ETH_CMD                  = 0x12,
+       FW_EQ_CTRL_CMD                 = 0x13,
+       FW_EQ_OFLD_CMD                 = 0x21,
+       FW_VI_CMD                      = 0x14,
+       FW_VI_MAC_CMD                  = 0x15,
+       FW_VI_RXMODE_CMD               = 0x16,
+       FW_VI_ENABLE_CMD               = 0x17,
+       FW_ACL_MAC_CMD                 = 0x18,
+       FW_ACL_VLAN_CMD                = 0x19,
+       FW_VI_STATS_CMD                = 0x1a,
+       FW_PORT_CMD                    = 0x1b,
+       FW_PORT_STATS_CMD              = 0x1c,
+       FW_PORT_LB_STATS_CMD           = 0x1d,
+       FW_PORT_TRACE_CMD              = 0x1e,
+       FW_PORT_TRACE_MMAP_CMD         = 0x1f,
+       FW_RSS_IND_TBL_CMD             = 0x20,
+       FW_RSS_GLB_CONFIG_CMD          = 0x22,
+       FW_RSS_VI_CONFIG_CMD           = 0x23,
+       FW_LASTC2E_CMD                 = 0x40,
+       FW_ERROR_CMD                   = 0x80,
+       FW_DEBUG_CMD                   = 0x81,
+};
+
+enum fw_cmd_cap {
+       FW_CMD_CAP_PF                  = 0x01,
+       FW_CMD_CAP_DMAQ                = 0x02,
+       FW_CMD_CAP_PORT                = 0x04,
+       FW_CMD_CAP_PORTPROMISC         = 0x08,
+       FW_CMD_CAP_PORTSTATS           = 0x10,
+       FW_CMD_CAP_VF                  = 0x80,
+};
+
+/*
+ * Generic command header flit0
+ */
+struct fw_cmd_hdr {
+       __be32 hi;
+       __be32 lo;
+};
+
+#define FW_CMD_OP(x)           ((x) << 24)
+#define FW_CMD_OP_GET(x)        (((x) >> 24) & 0xff)
+#define FW_CMD_REQUEST          (1U << 23)
+#define FW_CMD_READ            (1U << 22)
+#define FW_CMD_WRITE           (1U << 21)
+#define FW_CMD_EXEC            (1U << 20)
+#define FW_CMD_RAMASK(x)       ((x) << 20)
+#define FW_CMD_RETVAL(x)       ((x) << 8)
+#define FW_CMD_RETVAL_GET(x)   (((x) >> 8) & 0xff)
+#define FW_CMD_LEN16(x)         ((x) << 0)
+
+enum fw_ldst_addrspc {
+       FW_LDST_ADDRSPC_FIRMWARE  = 0x0001,
+       FW_LDST_ADDRSPC_SGE_EGRC  = 0x0008,
+       FW_LDST_ADDRSPC_SGE_INGC  = 0x0009,
+       FW_LDST_ADDRSPC_SGE_FLMC  = 0x000a,
+       FW_LDST_ADDRSPC_SGE_CONMC = 0x000b,
+       FW_LDST_ADDRSPC_TP_PIO    = 0x0010,
+       FW_LDST_ADDRSPC_TP_TM_PIO = 0x0011,
+       FW_LDST_ADDRSPC_TP_MIB    = 0x0012,
+       FW_LDST_ADDRSPC_MDIO      = 0x0018,
+       FW_LDST_ADDRSPC_MPS       = 0x0020,
+       FW_LDST_ADDRSPC_FUNC      = 0x0028
+};
+
+enum fw_ldst_mps_fid {
+       FW_LDST_MPS_ATRB,
+       FW_LDST_MPS_RPLC
+};
+
+enum fw_ldst_func_access_ctl {
+       FW_LDST_FUNC_ACC_CTL_VIID,
+       FW_LDST_FUNC_ACC_CTL_FID
+};
+
+enum fw_ldst_func_mod_index {
+       FW_LDST_FUNC_MPS
+};
+
+struct fw_ldst_cmd {
+       __be32 op_to_addrspace;
+#define FW_LDST_CMD_ADDRSPACE(x) ((x) << 0)
+       __be32 cycles_to_len16;
+       union fw_ldst {
+               struct fw_ldst_addrval {
+                       __be32 addr;
+                       __be32 val;
+               } addrval;
+               struct fw_ldst_idctxt {
+                       __be32 physid;
+                       __be32 msg_pkd;
+                       __be32 ctxt_data7;
+                       __be32 ctxt_data6;
+                       __be32 ctxt_data5;
+                       __be32 ctxt_data4;
+                       __be32 ctxt_data3;
+                       __be32 ctxt_data2;
+                       __be32 ctxt_data1;
+                       __be32 ctxt_data0;
+               } idctxt;
+               struct fw_ldst_mdio {
+                       __be16 paddr_mmd;
+                       __be16 raddr;
+                       __be16 vctl;
+                       __be16 rval;
+               } mdio;
+               struct fw_ldst_mps {
+                       __be16 fid_ctl;
+                       __be16 rplcpf_pkd;
+                       __be32 rplc127_96;
+                       __be32 rplc95_64;
+                       __be32 rplc63_32;
+                       __be32 rplc31_0;
+                       __be32 atrb;
+                       __be16 vlan[16];
+               } mps;
+               struct fw_ldst_func {
+                       u8 access_ctl;
+                       u8 mod_index;
+                       __be16 ctl_id;
+                       __be32 offset;
+                       __be64 data0;
+                       __be64 data1;
+               } func;
+       } u;
+};
+
+#define FW_LDST_CMD_MSG(x)     ((x) << 31)
+#define FW_LDST_CMD_PADDR(x)   ((x) << 8)
+#define FW_LDST_CMD_MMD(x)     ((x) << 0)
+#define FW_LDST_CMD_FID(x)     ((x) << 15)
+#define FW_LDST_CMD_CTL(x)     ((x) << 0)
+#define FW_LDST_CMD_RPLCPF(x)  ((x) << 0)
+
+struct fw_reset_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       __be32 val;
+       __be32 r3;
+};
+
+struct fw_hello_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       __be32 err_to_mbasyncnot;
+#define FW_HELLO_CMD_ERR           (1U << 31)
+#define FW_HELLO_CMD_INIT          (1U << 30)
+#define FW_HELLO_CMD_MASTERDIS(x)   ((x) << 29)
+#define FW_HELLO_CMD_MASTERFORCE(x) ((x) << 28)
+#define FW_HELLO_CMD_MBMASTER(x)    ((x) << 24)
+#define FW_HELLO_CMD_MBASYNCNOT(x)  ((x) << 20)
+       __be32 fwrev;
+};
+
+struct fw_bye_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       __be64 r3;
+};
+
+struct fw_initialize_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       __be64 r3;
+};
+
+enum fw_caps_config_hm {
+       FW_CAPS_CONFIG_HM_PCIE          = 0x00000001,
+       FW_CAPS_CONFIG_HM_PL            = 0x00000002,
+       FW_CAPS_CONFIG_HM_SGE           = 0x00000004,
+       FW_CAPS_CONFIG_HM_CIM           = 0x00000008,
+       FW_CAPS_CONFIG_HM_ULPTX         = 0x00000010,
+       FW_CAPS_CONFIG_HM_TP            = 0x00000020,
+       FW_CAPS_CONFIG_HM_ULPRX         = 0x00000040,
+       FW_CAPS_CONFIG_HM_PMRX          = 0x00000080,
+       FW_CAPS_CONFIG_HM_PMTX          = 0x00000100,
+       FW_CAPS_CONFIG_HM_MC            = 0x00000200,
+       FW_CAPS_CONFIG_HM_LE            = 0x00000400,
+       FW_CAPS_CONFIG_HM_MPS           = 0x00000800,
+       FW_CAPS_CONFIG_HM_XGMAC         = 0x00001000,
+       FW_CAPS_CONFIG_HM_CPLSWITCH     = 0x00002000,
+       FW_CAPS_CONFIG_HM_T4DBG         = 0x00004000,
+       FW_CAPS_CONFIG_HM_MI            = 0x00008000,
+       FW_CAPS_CONFIG_HM_I2CM          = 0x00010000,
+       FW_CAPS_CONFIG_HM_NCSI          = 0x00020000,
+       FW_CAPS_CONFIG_HM_SMB           = 0x00040000,
+       FW_CAPS_CONFIG_HM_MA            = 0x00080000,
+       FW_CAPS_CONFIG_HM_EDRAM         = 0x00100000,
+       FW_CAPS_CONFIG_HM_PMU           = 0x00200000,
+       FW_CAPS_CONFIG_HM_UART          = 0x00400000,
+       FW_CAPS_CONFIG_HM_SF            = 0x00800000,
+};
+
+enum fw_caps_config_nbm {
+       FW_CAPS_CONFIG_NBM_IPMI         = 0x00000001,
+       FW_CAPS_CONFIG_NBM_NCSI         = 0x00000002,
+};
+
+enum fw_caps_config_link {
+       FW_CAPS_CONFIG_LINK_PPP         = 0x00000001,
+       FW_CAPS_CONFIG_LINK_QFC         = 0x00000002,
+       FW_CAPS_CONFIG_LINK_DCBX        = 0x00000004,
+};
+
+enum fw_caps_config_switch {
+       FW_CAPS_CONFIG_SWITCH_INGRESS   = 0x00000001,
+       FW_CAPS_CONFIG_SWITCH_EGRESS    = 0x00000002,
+};
+
+enum fw_caps_config_nic {
+       FW_CAPS_CONFIG_NIC              = 0x00000001,
+       FW_CAPS_CONFIG_NIC_VM           = 0x00000002,
+};
+
+enum fw_caps_config_ofld {
+       FW_CAPS_CONFIG_OFLD             = 0x00000001,
+};
+
+enum fw_caps_config_rdma {
+       FW_CAPS_CONFIG_RDMA_RDDP        = 0x00000001,
+       FW_CAPS_CONFIG_RDMA_RDMAC       = 0x00000002,
+};
+
+enum fw_caps_config_iscsi {
+       FW_CAPS_CONFIG_ISCSI_INITIATOR_PDU = 0x00000001,
+       FW_CAPS_CONFIG_ISCSI_TARGET_PDU = 0x00000002,
+       FW_CAPS_CONFIG_ISCSI_INITIATOR_CNXOFLD = 0x00000004,
+       FW_CAPS_CONFIG_ISCSI_TARGET_CNXOFLD = 0x00000008,
+};
+
+enum fw_caps_config_fcoe {
+       FW_CAPS_CONFIG_FCOE_INITIATOR   = 0x00000001,
+       FW_CAPS_CONFIG_FCOE_TARGET      = 0x00000002,
+};
+
+struct fw_caps_config_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       __be32 r2;
+       __be32 hwmbitmap;
+       __be16 nbmcaps;
+       __be16 linkcaps;
+       __be16 switchcaps;
+       __be16 r3;
+       __be16 niccaps;
+       __be16 ofldcaps;
+       __be16 rdmacaps;
+       __be16 r4;
+       __be16 iscsicaps;
+       __be16 fcoecaps;
+       __be32 r5;
+       __be64 r6;
+};
+
+/*
+ * params command mnemonics
+ */
+enum fw_params_mnem {
+       FW_PARAMS_MNEM_DEV              = 1,    /* device params */
+       FW_PARAMS_MNEM_PFVF             = 2,    /* function params */
+       FW_PARAMS_MNEM_REG              = 3,    /* limited register access */
+       FW_PARAMS_MNEM_DMAQ             = 4,    /* dma queue params */
+       FW_PARAMS_MNEM_LAST
+};
+
+/*
+ * device parameters
+ */
+enum fw_params_param_dev {
+       FW_PARAMS_PARAM_DEV_CCLK        = 0x00, /* chip core clock in khz */
+       FW_PARAMS_PARAM_DEV_PORTVEC     = 0x01, /* the port vector */
+       FW_PARAMS_PARAM_DEV_NTID        = 0x02, /* reads the number of TIDs
+                                                * allocated by the device's
+                                                * Lookup Engine
+                                                */
+       FW_PARAMS_PARAM_DEV_FLOWC_BUFFIFO_SZ = 0x03,
+       FW_PARAMS_PARAM_DEV_INTVER_NIC  = 0x04,
+       FW_PARAMS_PARAM_DEV_INTVER_VNIC = 0x05,
+       FW_PARAMS_PARAM_DEV_INTVER_OFLD = 0x06,
+       FW_PARAMS_PARAM_DEV_INTVER_RI   = 0x07,
+       FW_PARAMS_PARAM_DEV_INTVER_ISCSIPDU = 0x08,
+       FW_PARAMS_PARAM_DEV_INTVER_ISCSI = 0x09,
+       FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A
+};
+
+/*
+ * physical and virtual function parameters
+ */
+enum fw_params_param_pfvf {
+       FW_PARAMS_PARAM_PFVF_RWXCAPS    = 0x00,
+       FW_PARAMS_PARAM_PFVF_ROUTE_START = 0x01,
+       FW_PARAMS_PARAM_PFVF_ROUTE_END = 0x02,
+       FW_PARAMS_PARAM_PFVF_CLIP_START = 0x03,
+       FW_PARAMS_PARAM_PFVF_CLIP_END = 0x04,
+       FW_PARAMS_PARAM_PFVF_FILTER_START = 0x05,
+       FW_PARAMS_PARAM_PFVF_FILTER_END = 0x06,
+       FW_PARAMS_PARAM_PFVF_SERVER_START = 0x07,
+       FW_PARAMS_PARAM_PFVF_SERVER_END = 0x08,
+       FW_PARAMS_PARAM_PFVF_TDDP_START = 0x09,
+       FW_PARAMS_PARAM_PFVF_TDDP_END = 0x0A,
+       FW_PARAMS_PARAM_PFVF_ISCSI_START = 0x0B,
+       FW_PARAMS_PARAM_PFVF_ISCSI_END = 0x0C,
+       FW_PARAMS_PARAM_PFVF_STAG_START = 0x0D,
+       FW_PARAMS_PARAM_PFVF_STAG_END = 0x0E,
+       FW_PARAMS_PARAM_PFVF_RQ_START = 0x1F,
+       FW_PARAMS_PARAM_PFVF_RQ_END     = 0x10,
+       FW_PARAMS_PARAM_PFVF_PBL_START = 0x11,
+       FW_PARAMS_PARAM_PFVF_PBL_END    = 0x12,
+       FW_PARAMS_PARAM_PFVF_L2T_START = 0x13,
+       FW_PARAMS_PARAM_PFVF_L2T_END = 0x14,
+       FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH = 0x20,
+};
+
+/*
+ * dma queue parameters
+ */
+enum fw_params_param_dmaq {
+       FW_PARAMS_PARAM_DMAQ_IQ_DCAEN_DCACPU = 0x00,
+       FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH = 0x01,
+       FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_MNGT = 0x10,
+       FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL = 0x11,
+       FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH = 0x12,
+};
+
+#define FW_PARAMS_MNEM(x)      ((x) << 24)
+#define FW_PARAMS_PARAM_X(x)   ((x) << 16)
+#define FW_PARAMS_PARAM_Y(x)   ((x) << 8)
+#define FW_PARAMS_PARAM_Z(x)   ((x) << 0)
+#define FW_PARAMS_PARAM_XYZ(x) ((x) << 0)
+#define FW_PARAMS_PARAM_YZ(x)  ((x) << 0)
+
+struct fw_params_cmd {
+       __be32 op_to_vfn;
+       __be32 retval_len16;
+       struct fw_params_param {
+               __be32 mnem;
+               __be32 val;
+       } param[7];
+};
+
+#define FW_PARAMS_CMD_PFN(x) ((x) << 8)
+#define FW_PARAMS_CMD_VFN(x) ((x) << 0)
+
+struct fw_pfvf_cmd {
+       __be32 op_to_vfn;
+       __be32 retval_len16;
+       __be32 niqflint_niq;
+       __be32 cmask_to_neq;
+       __be32 tc_to_nexactf;
+       __be32 r_caps_to_nethctrl;
+       __be16 nricq;
+       __be16 nriqp;
+       __be32 r4;
+};
+
+#define FW_PFVF_CMD_PFN(x) ((x) << 8)
+#define FW_PFVF_CMD_VFN(x) ((x) << 0)
+
+#define FW_PFVF_CMD_NIQFLINT(x) ((x) << 20)
+#define FW_PFVF_CMD_NIQFLINT_GET(x) (((x) >> 20) & 0xfff)
+
+#define FW_PFVF_CMD_NIQ(x) ((x) << 0)
+#define FW_PFVF_CMD_NIQ_GET(x) (((x) >> 0) & 0xfffff)
+
+#define FW_PFVF_CMD_CMASK(x) ((x) << 24)
+#define FW_PFVF_CMD_CMASK_GET(x) (((x) >> 24) & 0xf)
+
+#define FW_PFVF_CMD_PMASK(x) ((x) << 20)
+#define FW_PFVF_CMD_PMASK_GET(x) (((x) >> 20) & 0xf)
+
+#define FW_PFVF_CMD_NEQ(x) ((x) << 0)
+#define FW_PFVF_CMD_NEQ_GET(x) (((x) >> 0) & 0xfffff)
+
+#define FW_PFVF_CMD_TC(x) ((x) << 24)
+#define FW_PFVF_CMD_TC_GET(x) (((x) >> 24) & 0xff)
+
+#define FW_PFVF_CMD_NVI(x) ((x) << 16)
+#define FW_PFVF_CMD_NVI_GET(x) (((x) >> 16) & 0xff)
+
+#define FW_PFVF_CMD_NEXACTF(x) ((x) << 0)
+#define FW_PFVF_CMD_NEXACTF_GET(x) (((x) >> 0) & 0xffff)
+
+#define FW_PFVF_CMD_R_CAPS(x) ((x) << 24)
+#define FW_PFVF_CMD_R_CAPS_GET(x) (((x) >> 24) & 0xff)
+
+#define FW_PFVF_CMD_WX_CAPS(x) ((x) << 16)
+#define FW_PFVF_CMD_WX_CAPS_GET(x) (((x) >> 16) & 0xff)
+
+#define FW_PFVF_CMD_NETHCTRL(x) ((x) << 0)
+#define FW_PFVF_CMD_NETHCTRL_GET(x) (((x) >> 0) & 0xffff)
+
+enum fw_iq_type {
+       FW_IQ_TYPE_FL_INT_CAP,
+       FW_IQ_TYPE_NO_FL_INT_CAP
+};
+
+struct fw_iq_cmd {
+       __be32 op_to_vfn;
+       __be32 alloc_to_len16;
+       __be16 physiqid;
+       __be16 iqid;
+       __be16 fl0id;
+       __be16 fl1id;
+       __be32 type_to_iqandstindex;
+       __be16 iqdroprss_to_iqesize;
+       __be16 iqsize;
+       __be64 iqaddr;
+       __be32 iqns_to_fl0congen;
+       __be16 fl0dcaen_to_fl0cidxfthresh;
+       __be16 fl0size;
+       __be64 fl0addr;
+       __be32 fl1cngchmap_to_fl1congen;
+       __be16 fl1dcaen_to_fl1cidxfthresh;
+       __be16 fl1size;
+       __be64 fl1addr;
+};
+
+#define FW_IQ_CMD_PFN(x) ((x) << 8)
+#define FW_IQ_CMD_VFN(x) ((x) << 0)
+
+#define FW_IQ_CMD_ALLOC (1U << 31)
+#define FW_IQ_CMD_FREE (1U << 30)
+#define FW_IQ_CMD_MODIFY (1U << 29)
+#define FW_IQ_CMD_IQSTART(x) ((x) << 28)
+#define FW_IQ_CMD_IQSTOP(x) ((x) << 27)
+
+#define FW_IQ_CMD_TYPE(x) ((x) << 29)
+#define FW_IQ_CMD_IQASYNCH(x) ((x) << 28)
+#define FW_IQ_CMD_VIID(x) ((x) << 16)
+#define FW_IQ_CMD_IQANDST(x) ((x) << 15)
+#define FW_IQ_CMD_IQANUS(x) ((x) << 14)
+#define FW_IQ_CMD_IQANUD(x) ((x) << 12)
+#define FW_IQ_CMD_IQANDSTINDEX(x) ((x) << 0)
+
+#define FW_IQ_CMD_IQDROPRSS (1U << 15)
+#define FW_IQ_CMD_IQGTSMODE (1U << 14)
+#define FW_IQ_CMD_IQPCIECH(x) ((x) << 12)
+#define FW_IQ_CMD_IQDCAEN(x) ((x) << 11)
+#define FW_IQ_CMD_IQDCACPU(x) ((x) << 6)
+#define FW_IQ_CMD_IQINTCNTTHRESH(x) ((x) << 4)
+#define FW_IQ_CMD_IQO (1U << 3)
+#define FW_IQ_CMD_IQCPRIO(x) ((x) << 2)
+#define FW_IQ_CMD_IQESIZE(x) ((x) << 0)
+
+#define FW_IQ_CMD_IQNS(x) ((x) << 31)
+#define FW_IQ_CMD_IQRO(x) ((x) << 30)
+#define FW_IQ_CMD_IQFLINTIQHSEN(x) ((x) << 28)
+#define FW_IQ_CMD_IQFLINTCONGEN(x) ((x) << 27)
+#define FW_IQ_CMD_IQFLINTISCSIC(x) ((x) << 26)
+#define FW_IQ_CMD_FL0CNGCHMAP(x) ((x) << 20)
+#define FW_IQ_CMD_FL0CACHELOCK(x) ((x) << 15)
+#define FW_IQ_CMD_FL0DBP(x) ((x) << 14)
+#define FW_IQ_CMD_FL0DATANS(x) ((x) << 13)
+#define FW_IQ_CMD_FL0DATARO(x) ((x) << 12)
+#define FW_IQ_CMD_FL0CONGCIF(x) ((x) << 11)
+#define FW_IQ_CMD_FL0ONCHIP(x) ((x) << 10)
+#define FW_IQ_CMD_FL0STATUSPGNS(x) ((x) << 9)
+#define FW_IQ_CMD_FL0STATUSPGRO(x) ((x) << 8)
+#define FW_IQ_CMD_FL0FETCHNS(x) ((x) << 7)
+#define FW_IQ_CMD_FL0FETCHRO(x) ((x) << 6)
+#define FW_IQ_CMD_FL0HOSTFCMODE(x) ((x) << 4)
+#define FW_IQ_CMD_FL0CPRIO(x) ((x) << 3)
+#define FW_IQ_CMD_FL0PADEN (1U << 2)
+#define FW_IQ_CMD_FL0PACKEN (1U << 1)
+#define FW_IQ_CMD_FL0CONGEN (1U << 0)
+
+#define FW_IQ_CMD_FL0DCAEN(x) ((x) << 15)
+#define FW_IQ_CMD_FL0DCACPU(x) ((x) << 10)
+#define FW_IQ_CMD_FL0FBMIN(x) ((x) << 7)
+#define FW_IQ_CMD_FL0FBMAX(x) ((x) << 4)
+#define FW_IQ_CMD_FL0CIDXFTHRESHO (1U << 3)
+#define FW_IQ_CMD_FL0CIDXFTHRESH(x) ((x) << 0)
+
+#define FW_IQ_CMD_FL1CNGCHMAP(x) ((x) << 20)
+#define FW_IQ_CMD_FL1CACHELOCK(x) ((x) << 15)
+#define FW_IQ_CMD_FL1DBP(x) ((x) << 14)
+#define FW_IQ_CMD_FL1DATANS(x) ((x) << 13)
+#define FW_IQ_CMD_FL1DATARO(x) ((x) << 12)
+#define FW_IQ_CMD_FL1CONGCIF(x) ((x) << 11)
+#define FW_IQ_CMD_FL1ONCHIP(x) ((x) << 10)
+#define FW_IQ_CMD_FL1STATUSPGNS(x) ((x) << 9)
+#define FW_IQ_CMD_FL1STATUSPGRO(x) ((x) << 8)
+#define FW_IQ_CMD_FL1FETCHNS(x) ((x) << 7)
+#define FW_IQ_CMD_FL1FETCHRO(x) ((x) << 6)
+#define FW_IQ_CMD_FL1HOSTFCMODE(x) ((x) << 4)
+#define FW_IQ_CMD_FL1CPRIO(x) ((x) << 3)
+#define FW_IQ_CMD_FL1PADEN (1U << 2)
+#define FW_IQ_CMD_FL1PACKEN (1U << 1)
+#define FW_IQ_CMD_FL1CONGEN (1U << 0)
+
+#define FW_IQ_CMD_FL1DCAEN(x) ((x) << 15)
+#define FW_IQ_CMD_FL1DCACPU(x) ((x) << 10)
+#define FW_IQ_CMD_FL1FBMIN(x) ((x) << 7)
+#define FW_IQ_CMD_FL1FBMAX(x) ((x) << 4)
+#define FW_IQ_CMD_FL1CIDXFTHRESHO (1U << 3)
+#define FW_IQ_CMD_FL1CIDXFTHRESH(x) ((x) << 0)
+
+struct fw_eq_eth_cmd {
+       __be32 op_to_vfn;
+       __be32 alloc_to_len16;
+       __be32 eqid_pkd;
+       __be32 physeqid_pkd;
+       __be32 fetchszm_to_iqid;
+       __be32 dcaen_to_eqsize;
+       __be64 eqaddr;
+       __be32 viid_pkd;
+       __be32 r8_lo;
+       __be64 r9;
+};
+
+#define FW_EQ_ETH_CMD_PFN(x) ((x) << 8)
+#define FW_EQ_ETH_CMD_VFN(x) ((x) << 0)
+#define FW_EQ_ETH_CMD_ALLOC (1U << 31)
+#define FW_EQ_ETH_CMD_FREE (1U << 30)
+#define FW_EQ_ETH_CMD_MODIFY (1U << 29)
+#define FW_EQ_ETH_CMD_EQSTART (1U << 28)
+#define FW_EQ_ETH_CMD_EQSTOP (1U << 27)
+
+#define FW_EQ_ETH_CMD_EQID(x) ((x) << 0)
+#define FW_EQ_ETH_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
+#define FW_EQ_ETH_CMD_PHYSEQID(x) ((x) << 0)
+
+#define FW_EQ_ETH_CMD_FETCHSZM(x) ((x) << 26)
+#define FW_EQ_ETH_CMD_STATUSPGNS(x) ((x) << 25)
+#define FW_EQ_ETH_CMD_STATUSPGRO(x) ((x) << 24)
+#define FW_EQ_ETH_CMD_FETCHNS(x) ((x) << 23)
+#define FW_EQ_ETH_CMD_FETCHRO(x) ((x) << 22)
+#define FW_EQ_ETH_CMD_HOSTFCMODE(x) ((x) << 20)
+#define FW_EQ_ETH_CMD_CPRIO(x) ((x) << 19)
+#define FW_EQ_ETH_CMD_ONCHIP(x) ((x) << 18)
+#define FW_EQ_ETH_CMD_PCIECHN(x) ((x) << 16)
+#define FW_EQ_ETH_CMD_IQID(x) ((x) << 0)
+
+#define FW_EQ_ETH_CMD_DCAEN(x) ((x) << 31)
+#define FW_EQ_ETH_CMD_DCACPU(x) ((x) << 26)
+#define FW_EQ_ETH_CMD_FBMIN(x) ((x) << 23)
+#define FW_EQ_ETH_CMD_FBMAX(x) ((x) << 20)
+#define FW_EQ_ETH_CMD_CIDXFTHRESHO(x) ((x) << 19)
+#define FW_EQ_ETH_CMD_CIDXFTHRESH(x) ((x) << 16)
+#define FW_EQ_ETH_CMD_EQSIZE(x) ((x) << 0)
+
+#define FW_EQ_ETH_CMD_VIID(x) ((x) << 16)
+
+struct fw_eq_ctrl_cmd {
+       __be32 op_to_vfn;
+       __be32 alloc_to_len16;
+       __be32 cmpliqid_eqid;
+       __be32 physeqid_pkd;
+       __be32 fetchszm_to_iqid;
+       __be32 dcaen_to_eqsize;
+       __be64 eqaddr;
+};
+
+#define FW_EQ_CTRL_CMD_PFN(x) ((x) << 8)
+#define FW_EQ_CTRL_CMD_VFN(x) ((x) << 0)
+
+#define FW_EQ_CTRL_CMD_ALLOC (1U << 31)
+#define FW_EQ_CTRL_CMD_FREE (1U << 30)
+#define FW_EQ_CTRL_CMD_MODIFY (1U << 29)
+#define FW_EQ_CTRL_CMD_EQSTART (1U << 28)
+#define FW_EQ_CTRL_CMD_EQSTOP (1U << 27)
+
+#define FW_EQ_CTRL_CMD_CMPLIQID(x) ((x) << 20)
+#define FW_EQ_CTRL_CMD_EQID(x) ((x) << 0)
+#define FW_EQ_CTRL_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
+#define FW_EQ_CTRL_CMD_PHYSEQID_GET(x) (((x) >> 0) & 0xfffff)
+
+#define FW_EQ_CTRL_CMD_FETCHSZM (1U << 26)
+#define FW_EQ_CTRL_CMD_STATUSPGNS (1U << 25)
+#define FW_EQ_CTRL_CMD_STATUSPGRO (1U << 24)
+#define FW_EQ_CTRL_CMD_FETCHNS (1U << 23)
+#define FW_EQ_CTRL_CMD_FETCHRO (1U << 22)
+#define FW_EQ_CTRL_CMD_HOSTFCMODE(x) ((x) << 20)
+#define FW_EQ_CTRL_CMD_CPRIO(x) ((x) << 19)
+#define FW_EQ_CTRL_CMD_ONCHIP(x) ((x) << 18)
+#define FW_EQ_CTRL_CMD_PCIECHN(x) ((x) << 16)
+#define FW_EQ_CTRL_CMD_IQID(x) ((x) << 0)
+
+#define FW_EQ_CTRL_CMD_DCAEN(x) ((x) << 31)
+#define FW_EQ_CTRL_CMD_DCACPU(x) ((x) << 26)
+#define FW_EQ_CTRL_CMD_FBMIN(x) ((x) << 23)
+#define FW_EQ_CTRL_CMD_FBMAX(x) ((x) << 20)
+#define FW_EQ_CTRL_CMD_CIDXFTHRESHO(x) ((x) << 19)
+#define FW_EQ_CTRL_CMD_CIDXFTHRESH(x) ((x) << 16)
+#define FW_EQ_CTRL_CMD_EQSIZE(x) ((x) << 0)
+
+struct fw_eq_ofld_cmd {
+       __be32 op_to_vfn;
+       __be32 alloc_to_len16;
+       __be32 eqid_pkd;
+       __be32 physeqid_pkd;
+       __be32 fetchszm_to_iqid;
+       __be32 dcaen_to_eqsize;
+       __be64 eqaddr;
+};
+
+#define FW_EQ_OFLD_CMD_PFN(x) ((x) << 8)
+#define FW_EQ_OFLD_CMD_VFN(x) ((x) << 0)
+
+#define FW_EQ_OFLD_CMD_ALLOC (1U << 31)
+#define FW_EQ_OFLD_CMD_FREE (1U << 30)
+#define FW_EQ_OFLD_CMD_MODIFY (1U << 29)
+#define FW_EQ_OFLD_CMD_EQSTART (1U << 28)
+#define FW_EQ_OFLD_CMD_EQSTOP (1U << 27)
+
+#define FW_EQ_OFLD_CMD_EQID(x) ((x) << 0)
+#define FW_EQ_OFLD_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
+#define FW_EQ_OFLD_CMD_PHYSEQID_GET(x) (((x) >> 0) & 0xfffff)
+
+#define FW_EQ_OFLD_CMD_FETCHSZM(x) ((x) << 26)
+#define FW_EQ_OFLD_CMD_STATUSPGNS(x) ((x) << 25)
+#define FW_EQ_OFLD_CMD_STATUSPGRO(x) ((x) << 24)
+#define FW_EQ_OFLD_CMD_FETCHNS(x) ((x) << 23)
+#define FW_EQ_OFLD_CMD_FETCHRO(x) ((x) << 22)
+#define FW_EQ_OFLD_CMD_HOSTFCMODE(x) ((x) << 20)
+#define FW_EQ_OFLD_CMD_CPRIO(x) ((x) << 19)
+#define FW_EQ_OFLD_CMD_ONCHIP(x) ((x) << 18)
+#define FW_EQ_OFLD_CMD_PCIECHN(x) ((x) << 16)
+#define FW_EQ_OFLD_CMD_IQID(x) ((x) << 0)
+
+#define FW_EQ_OFLD_CMD_DCAEN(x) ((x) << 31)
+#define FW_EQ_OFLD_CMD_DCACPU(x) ((x) << 26)
+#define FW_EQ_OFLD_CMD_FBMIN(x) ((x) << 23)
+#define FW_EQ_OFLD_CMD_FBMAX(x) ((x) << 20)
+#define FW_EQ_OFLD_CMD_CIDXFTHRESHO(x) ((x) << 19)
+#define FW_EQ_OFLD_CMD_CIDXFTHRESH(x) ((x) << 16)
+#define FW_EQ_OFLD_CMD_EQSIZE(x) ((x) << 0)
+
+/*
+ * Macros for VIID parsing:
+ * VIID - [10:8] PFN, [7] VI Valid, [6:0] VI number
+ */
+#define FW_VIID_PFN_GET(x) (((x) >> 8) & 0x7)
+#define FW_VIID_VIVLD_GET(x) (((x) >> 7) & 0x1)
+#define FW_VIID_VIN_GET(x) (((x) >> 0) & 0x7F)
+
+struct fw_vi_cmd {
+       __be32 op_to_vfn;
+       __be32 alloc_to_len16;
+       __be16 viid_pkd;
+       u8 mac[6];
+       u8 portid_pkd;
+       u8 nmac;
+       u8 nmac0[6];
+       __be16 rsssize_pkd;
+       u8 nmac1[6];
+       __be16 r7;
+       u8 nmac2[6];
+       __be16 r8;
+       u8 nmac3[6];
+       __be64 r9;
+       __be64 r10;
+};
+
+#define FW_VI_CMD_PFN(x) ((x) << 8)
+#define FW_VI_CMD_VFN(x) ((x) << 0)
+#define FW_VI_CMD_ALLOC (1U << 31)
+#define FW_VI_CMD_FREE (1U << 30)
+#define FW_VI_CMD_VIID(x) ((x) << 0)
+#define FW_VI_CMD_PORTID(x) ((x) << 4)
+#define FW_VI_CMD_RSSSIZE_GET(x) (((x) >> 0) & 0x7ff)
+
+/* Special VI_MAC command index ids */
+#define FW_VI_MAC_ADD_MAC              0x3FF
+#define FW_VI_MAC_ADD_PERSIST_MAC      0x3FE
+#define FW_VI_MAC_MAC_BASED_FREE       0x3FD
+
+enum fw_vi_mac_smac {
+       FW_VI_MAC_MPS_TCAM_ENTRY,
+       FW_VI_MAC_MPS_TCAM_ONLY,
+       FW_VI_MAC_SMT_ONLY,
+       FW_VI_MAC_SMT_AND_MPSTCAM
+};
+
+enum fw_vi_mac_result {
+       FW_VI_MAC_R_SUCCESS,
+       FW_VI_MAC_R_F_NONEXISTENT_NOMEM,
+       FW_VI_MAC_R_SMAC_FAIL,
+       FW_VI_MAC_R_F_ACL_CHECK
+};
+
+struct fw_vi_mac_cmd {
+       __be32 op_to_viid;
+       __be32 freemacs_to_len16;
+       union fw_vi_mac {
+               struct fw_vi_mac_exact {
+                       __be16 valid_to_idx;
+                       u8 macaddr[6];
+               } exact[7];
+               struct fw_vi_mac_hash {
+                       __be64 hashvec;
+               } hash;
+       } u;
+};
+
+#define FW_VI_MAC_CMD_VIID(x) ((x) << 0)
+#define FW_VI_MAC_CMD_FREEMACS(x) ((x) << 31)
+#define FW_VI_MAC_CMD_HASHVECEN (1U << 23)
+#define FW_VI_MAC_CMD_HASHUNIEN(x) ((x) << 22)
+#define FW_VI_MAC_CMD_VALID (1U << 15)
+#define FW_VI_MAC_CMD_PRIO(x) ((x) << 12)
+#define FW_VI_MAC_CMD_SMAC_RESULT(x) ((x) << 10)
+#define FW_VI_MAC_CMD_SMAC_RESULT_GET(x) (((x) >> 10) & 0x3)
+#define FW_VI_MAC_CMD_IDX(x) ((x) << 0)
+#define FW_VI_MAC_CMD_IDX_GET(x) (((x) >> 0) & 0x3ff)
+
+#define FW_RXMODE_MTU_NO_CHG   65535
+
+struct fw_vi_rxmode_cmd {
+       __be32 op_to_viid;
+       __be32 retval_len16;
+       __be32 mtu_to_broadcasten;
+       __be32 r4_lo;
+};
+
+#define FW_VI_RXMODE_CMD_VIID(x) ((x) << 0)
+#define FW_VI_RXMODE_CMD_MTU(x) ((x) << 16)
+#define FW_VI_RXMODE_CMD_PROMISCEN_MASK 0x3
+#define FW_VI_RXMODE_CMD_PROMISCEN(x) ((x) << 14)
+#define FW_VI_RXMODE_CMD_ALLMULTIEN_MASK 0x3
+#define FW_VI_RXMODE_CMD_ALLMULTIEN(x) ((x) << 12)
+#define FW_VI_RXMODE_CMD_BROADCASTEN_MASK 0x3
+#define FW_VI_RXMODE_CMD_BROADCASTEN(x) ((x) << 10)
+
+struct fw_vi_enable_cmd {
+       __be32 op_to_viid;
+       __be32 ien_to_len16;
+       __be16 blinkdur;
+       __be16 r3;
+       __be32 r4;
+};
+
+#define FW_VI_ENABLE_CMD_VIID(x) ((x) << 0)
+#define FW_VI_ENABLE_CMD_IEN(x) ((x) << 31)
+#define FW_VI_ENABLE_CMD_EEN(x) ((x) << 30)
+#define FW_VI_ENABLE_CMD_LED (1U << 29)
+
+/* VI VF stats offset definitions */
+#define VI_VF_NUM_STATS        16
+enum fw_vi_stats_vf_index {
+       FW_VI_VF_STAT_TX_BCAST_BYTES_IX,
+       FW_VI_VF_STAT_TX_BCAST_FRAMES_IX,
+       FW_VI_VF_STAT_TX_MCAST_BYTES_IX,
+       FW_VI_VF_STAT_TX_MCAST_FRAMES_IX,
+       FW_VI_VF_STAT_TX_UCAST_BYTES_IX,
+       FW_VI_VF_STAT_TX_UCAST_FRAMES_IX,
+       FW_VI_VF_STAT_TX_DROP_FRAMES_IX,
+       FW_VI_VF_STAT_TX_OFLD_BYTES_IX,
+       FW_VI_VF_STAT_TX_OFLD_FRAMES_IX,
+       FW_VI_VF_STAT_RX_BCAST_BYTES_IX,
+       FW_VI_VF_STAT_RX_BCAST_FRAMES_IX,
+       FW_VI_VF_STAT_RX_MCAST_BYTES_IX,
+       FW_VI_VF_STAT_RX_MCAST_FRAMES_IX,
+       FW_VI_VF_STAT_RX_UCAST_BYTES_IX,
+       FW_VI_VF_STAT_RX_UCAST_FRAMES_IX,
+       FW_VI_VF_STAT_RX_ERR_FRAMES_IX
+};
+
+/* VI PF stats offset definitions */
+#define VI_PF_NUM_STATS        17
+enum fw_vi_stats_pf_index {
+       FW_VI_PF_STAT_TX_BCAST_BYTES_IX,
+       FW_VI_PF_STAT_TX_BCAST_FRAMES_IX,
+       FW_VI_PF_STAT_TX_MCAST_BYTES_IX,
+       FW_VI_PF_STAT_TX_MCAST_FRAMES_IX,
+       FW_VI_PF_STAT_TX_UCAST_BYTES_IX,
+       FW_VI_PF_STAT_TX_UCAST_FRAMES_IX,
+       FW_VI_PF_STAT_TX_OFLD_BYTES_IX,
+       FW_VI_PF_STAT_TX_OFLD_FRAMES_IX,
+       FW_VI_PF_STAT_RX_BYTES_IX,
+       FW_VI_PF_STAT_RX_FRAMES_IX,
+       FW_VI_PF_STAT_RX_BCAST_BYTES_IX,
+       FW_VI_PF_STAT_RX_BCAST_FRAMES_IX,
+       FW_VI_PF_STAT_RX_MCAST_BYTES_IX,
+       FW_VI_PF_STAT_RX_MCAST_FRAMES_IX,
+       FW_VI_PF_STAT_RX_UCAST_BYTES_IX,
+       FW_VI_PF_STAT_RX_UCAST_FRAMES_IX,
+       FW_VI_PF_STAT_RX_ERR_FRAMES_IX
+};
+
+struct fw_vi_stats_cmd {
+       __be32 op_to_viid;
+       __be32 retval_len16;
+       union fw_vi_stats {
+               struct fw_vi_stats_ctl {
+                       __be16 nstats_ix;
+                       __be16 r6;
+                       __be32 r7;
+                       __be64 stat0;
+                       __be64 stat1;
+                       __be64 stat2;
+                       __be64 stat3;
+                       __be64 stat4;
+                       __be64 stat5;
+               } ctl;
+               struct fw_vi_stats_pf {
+                       __be64 tx_bcast_bytes;
+                       __be64 tx_bcast_frames;
+                       __be64 tx_mcast_bytes;
+                       __be64 tx_mcast_frames;
+                       __be64 tx_ucast_bytes;
+                       __be64 tx_ucast_frames;
+                       __be64 tx_offload_bytes;
+                       __be64 tx_offload_frames;
+                       __be64 rx_pf_bytes;
+                       __be64 rx_pf_frames;
+                       __be64 rx_bcast_bytes;
+                       __be64 rx_bcast_frames;
+                       __be64 rx_mcast_bytes;
+                       __be64 rx_mcast_frames;
+                       __be64 rx_ucast_bytes;
+                       __be64 rx_ucast_frames;
+                       __be64 rx_err_frames;
+               } pf;
+               struct fw_vi_stats_vf {
+                       __be64 tx_bcast_bytes;
+                       __be64 tx_bcast_frames;
+                       __be64 tx_mcast_bytes;
+                       __be64 tx_mcast_frames;
+                       __be64 tx_ucast_bytes;
+                       __be64 tx_ucast_frames;
+                       __be64 tx_drop_frames;
+                       __be64 tx_offload_bytes;
+                       __be64 tx_offload_frames;
+                       __be64 rx_bcast_bytes;
+                       __be64 rx_bcast_frames;
+                       __be64 rx_mcast_bytes;
+                       __be64 rx_mcast_frames;
+                       __be64 rx_ucast_bytes;
+                       __be64 rx_ucast_frames;
+                       __be64 rx_err_frames;
+               } vf;
+       } u;
+};
+
+#define FW_VI_STATS_CMD_VIID(x) ((x) << 0)
+#define FW_VI_STATS_CMD_NSTATS(x) ((x) << 12)
+#define FW_VI_STATS_CMD_IX(x) ((x) << 0)
+
+struct fw_acl_mac_cmd {
+       __be32 op_to_vfn;
+       __be32 en_to_len16;
+       u8 nmac;
+       u8 r3[7];
+       __be16 r4;
+       u8 macaddr0[6];
+       __be16 r5;
+       u8 macaddr1[6];
+       __be16 r6;
+       u8 macaddr2[6];
+       __be16 r7;
+       u8 macaddr3[6];
+};
+
+#define FW_ACL_MAC_CMD_PFN(x) ((x) << 8)
+#define FW_ACL_MAC_CMD_VFN(x) ((x) << 0)
+#define FW_ACL_MAC_CMD_EN(x) ((x) << 31)
+
+struct fw_acl_vlan_cmd {
+       __be32 op_to_vfn;
+       __be32 en_to_len16;
+       u8 nvlan;
+       u8 dropnovlan_fm;
+       u8 r3_lo[6];
+       __be16 vlanid[16];
+};
+
+#define FW_ACL_VLAN_CMD_PFN(x) ((x) << 8)
+#define FW_ACL_VLAN_CMD_VFN(x) ((x) << 0)
+#define FW_ACL_VLAN_CMD_EN(x) ((x) << 31)
+#define FW_ACL_VLAN_CMD_DROPNOVLAN(x) ((x) << 7)
+#define FW_ACL_VLAN_CMD_FM(x) ((x) << 6)
+
+enum fw_port_cap {
+       FW_PORT_CAP_SPEED_100M          = 0x0001,
+       FW_PORT_CAP_SPEED_1G            = 0x0002,
+       FW_PORT_CAP_SPEED_2_5G          = 0x0004,
+       FW_PORT_CAP_SPEED_10G           = 0x0008,
+       FW_PORT_CAP_SPEED_40G           = 0x0010,
+       FW_PORT_CAP_SPEED_100G          = 0x0020,
+       FW_PORT_CAP_FC_RX               = 0x0040,
+       FW_PORT_CAP_FC_TX               = 0x0080,
+       FW_PORT_CAP_ANEG                = 0x0100,
+       FW_PORT_CAP_MDI_0               = 0x0200,
+       FW_PORT_CAP_MDI_1               = 0x0400,
+       FW_PORT_CAP_BEAN                = 0x0800,
+       FW_PORT_CAP_PMA_LPBK            = 0x1000,
+       FW_PORT_CAP_PCS_LPBK            = 0x2000,
+       FW_PORT_CAP_PHYXS_LPBK          = 0x4000,
+       FW_PORT_CAP_FAR_END_LPBK        = 0x8000,
+};
+
+enum fw_port_mdi {
+       FW_PORT_MDI_UNCHANGED,
+       FW_PORT_MDI_AUTO,
+       FW_PORT_MDI_F_STRAIGHT,
+       FW_PORT_MDI_F_CROSSOVER
+};
+
+#define FW_PORT_MDI(x) ((x) << 9)
+
+enum fw_port_action {
+       FW_PORT_ACTION_L1_CFG           = 0x0001,
+       FW_PORT_ACTION_L2_CFG           = 0x0002,
+       FW_PORT_ACTION_GET_PORT_INFO    = 0x0003,
+       FW_PORT_ACTION_L2_PPP_CFG       = 0x0004,
+       FW_PORT_ACTION_L2_DCB_CFG       = 0x0005,
+       FW_PORT_ACTION_LOW_PWR_TO_NORMAL = 0x0010,
+       FW_PORT_ACTION_L1_LOW_PWR_EN    = 0x0011,
+       FW_PORT_ACTION_L2_WOL_MODE_EN   = 0x0012,
+       FW_PORT_ACTION_LPBK_TO_NORMAL   = 0x0020,
+       FW_PORT_ACTION_L1_LPBK          = 0x0021,
+       FW_PORT_ACTION_L1_PMA_LPBK      = 0x0022,
+       FW_PORT_ACTION_L1_PCS_LPBK      = 0x0023,
+       FW_PORT_ACTION_L1_PHYXS_CSIDE_LPBK = 0x0024,
+       FW_PORT_ACTION_L1_PHYXS_ESIDE_LPBK = 0x0025,
+       FW_PORT_ACTION_PHY_RESET        = 0x0040,
+       FW_PORT_ACTION_PMA_RESET        = 0x0041,
+       FW_PORT_ACTION_PCS_RESET        = 0x0042,
+       FW_PORT_ACTION_PHYXS_RESET      = 0x0043,
+       FW_PORT_ACTION_DTEXS_REEST      = 0x0044,
+       FW_PORT_ACTION_AN_RESET         = 0x0045
+};
+
+enum fw_port_l2cfg_ctlbf {
+       FW_PORT_L2_CTLBF_OVLAN0 = 0x01,
+       FW_PORT_L2_CTLBF_OVLAN1 = 0x02,
+       FW_PORT_L2_CTLBF_OVLAN2 = 0x04,
+       FW_PORT_L2_CTLBF_OVLAN3 = 0x08,
+       FW_PORT_L2_CTLBF_IVLAN  = 0x10,
+       FW_PORT_L2_CTLBF_TXIPG  = 0x20
+};
+
+enum fw_port_dcb_cfg {
+       FW_PORT_DCB_CFG_PG      = 0x01,
+       FW_PORT_DCB_CFG_PFC     = 0x02,
+       FW_PORT_DCB_CFG_APPL    = 0x04
+};
+
+enum fw_port_dcb_cfg_rc {
+       FW_PORT_DCB_CFG_SUCCESS = 0x0,
+       FW_PORT_DCB_CFG_ERROR   = 0x1
+};
+
+struct fw_port_cmd {
+       __be32 op_to_portid;
+       __be32 action_to_len16;
+       union fw_port {
+               struct fw_port_l1cfg {
+                       __be32 rcap;
+                       __be32 r;
+               } l1cfg;
+               struct fw_port_l2cfg {
+                       __be16 ctlbf_to_ivlan0;
+                       __be16 ivlantype;
+                       __be32 txipg_pkd;
+                       __be16 ovlan0mask;
+                       __be16 ovlan0type;
+                       __be16 ovlan1mask;
+                       __be16 ovlan1type;
+                       __be16 ovlan2mask;
+                       __be16 ovlan2type;
+                       __be16 ovlan3mask;
+                       __be16 ovlan3type;
+               } l2cfg;
+               struct fw_port_info {
+                       __be32 lstatus_to_modtype;
+                       __be16 pcap;
+                       __be16 acap;
+               } info;
+               struct fw_port_ppp {
+                       __be32 pppen_to_ncsich;
+                       __be32 r11;
+               } ppp;
+               struct fw_port_dcb {
+                       __be16 cfg;
+                       u8 up_map;
+                       u8 sf_cfgrc;
+                       __be16 prot_ix;
+                       u8 pe7_to_pe0;
+                       u8 numTCPFCs;
+                       __be32 pgid0_to_pgid7;
+                       __be32 numTCs_oui;
+                       u8 pgpc[8];
+               } dcb;
+       } u;
+};
+
+#define FW_PORT_CMD_READ (1U << 22)
+
+#define FW_PORT_CMD_PORTID(x) ((x) << 0)
+#define FW_PORT_CMD_PORTID_GET(x) (((x) >> 0) & 0xf)
+
+#define FW_PORT_CMD_ACTION(x) ((x) << 16)
+
+#define FW_PORT_CMD_CTLBF(x) ((x) << 10)
+#define FW_PORT_CMD_OVLAN3(x) ((x) << 7)
+#define FW_PORT_CMD_OVLAN2(x) ((x) << 6)
+#define FW_PORT_CMD_OVLAN1(x) ((x) << 5)
+#define FW_PORT_CMD_OVLAN0(x) ((x) << 4)
+#define FW_PORT_CMD_IVLAN0(x) ((x) << 3)
+
+#define FW_PORT_CMD_TXIPG(x) ((x) << 19)
+
+#define FW_PORT_CMD_LSTATUS (1U << 31)
+#define FW_PORT_CMD_LSPEED(x) ((x) << 24)
+#define FW_PORT_CMD_LSPEED_GET(x) (((x) >> 24) & 0x3f)
+#define FW_PORT_CMD_TXPAUSE (1U << 23)
+#define FW_PORT_CMD_RXPAUSE (1U << 22)
+#define FW_PORT_CMD_MDIOCAP (1U << 21)
+#define FW_PORT_CMD_MDIOADDR_GET(x) (((x) >> 16) & 0x1f)
+#define FW_PORT_CMD_LPTXPAUSE (1U << 15)
+#define FW_PORT_CMD_LPRXPAUSE (1U << 14)
+#define FW_PORT_CMD_PTYPE_MASK 0x1f
+#define FW_PORT_CMD_PTYPE_GET(x) (((x) >> 8) & FW_PORT_CMD_PTYPE_MASK)
+#define FW_PORT_CMD_MODTYPE_MASK 0x1f
+#define FW_PORT_CMD_MODTYPE_GET(x) (((x) >> 0) & FW_PORT_CMD_MODTYPE_MASK)
+
+#define FW_PORT_CMD_PPPEN(x) ((x) << 31)
+#define FW_PORT_CMD_TPSRC(x) ((x) << 28)
+#define FW_PORT_CMD_NCSISRC(x) ((x) << 24)
+
+#define FW_PORT_CMD_CH0(x) ((x) << 20)
+#define FW_PORT_CMD_CH1(x) ((x) << 16)
+#define FW_PORT_CMD_CH2(x) ((x) << 12)
+#define FW_PORT_CMD_CH3(x) ((x) << 8)
+#define FW_PORT_CMD_NCSICH(x) ((x) << 4)
+
+enum fw_port_type {
+       FW_PORT_TYPE_FIBER,
+       FW_PORT_TYPE_KX4,
+       FW_PORT_TYPE_BT_SGMII,
+       FW_PORT_TYPE_KX,
+       FW_PORT_TYPE_BT_XAUI,
+       FW_PORT_TYPE_KR,
+       FW_PORT_TYPE_CX4,
+       FW_PORT_TYPE_TWINAX,
+
+       FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_MASK
+};
+
+enum fw_port_module_type {
+       FW_PORT_MOD_TYPE_NA,
+       FW_PORT_MOD_TYPE_LR,
+       FW_PORT_MOD_TYPE_SR,
+       FW_PORT_MOD_TYPE_ER,
+
+       FW_PORT_MOD_TYPE_NONE = FW_PORT_CMD_MODTYPE_MASK
+};
+
+/* port stats */
+#define FW_NUM_PORT_STATS 50
+#define FW_NUM_PORT_TX_STATS 23
+#define FW_NUM_PORT_RX_STATS 27
+
+enum fw_port_stats_tx_index {
+       FW_STAT_TX_PORT_BYTES_IX,
+       FW_STAT_TX_PORT_FRAMES_IX,
+       FW_STAT_TX_PORT_BCAST_IX,
+       FW_STAT_TX_PORT_MCAST_IX,
+       FW_STAT_TX_PORT_UCAST_IX,
+       FW_STAT_TX_PORT_ERROR_IX,
+       FW_STAT_TX_PORT_64B_IX,
+       FW_STAT_TX_PORT_65B_127B_IX,
+       FW_STAT_TX_PORT_128B_255B_IX,
+       FW_STAT_TX_PORT_256B_511B_IX,
+       FW_STAT_TX_PORT_512B_1023B_IX,
+       FW_STAT_TX_PORT_1024B_1518B_IX,
+       FW_STAT_TX_PORT_1519B_MAX_IX,
+       FW_STAT_TX_PORT_DROP_IX,
+       FW_STAT_TX_PORT_PAUSE_IX,
+       FW_STAT_TX_PORT_PPP0_IX,
+       FW_STAT_TX_PORT_PPP1_IX,
+       FW_STAT_TX_PORT_PPP2_IX,
+       FW_STAT_TX_PORT_PPP3_IX,
+       FW_STAT_TX_PORT_PPP4_IX,
+       FW_STAT_TX_PORT_PPP5_IX,
+       FW_STAT_TX_PORT_PPP6_IX,
+       FW_STAT_TX_PORT_PPP7_IX
+};
+
+enum fw_port_stat_rx_index {
+       FW_STAT_RX_PORT_BYTES_IX,
+       FW_STAT_RX_PORT_FRAMES_IX,
+       FW_STAT_RX_PORT_BCAST_IX,
+       FW_STAT_RX_PORT_MCAST_IX,
+       FW_STAT_RX_PORT_UCAST_IX,
+       FW_STAT_RX_PORT_MTU_ERROR_IX,
+       FW_STAT_RX_PORT_MTU_CRC_ERROR_IX,
+       FW_STAT_RX_PORT_CRC_ERROR_IX,
+       FW_STAT_RX_PORT_LEN_ERROR_IX,
+       FW_STAT_RX_PORT_SYM_ERROR_IX,
+       FW_STAT_RX_PORT_64B_IX,
+       FW_STAT_RX_PORT_65B_127B_IX,
+       FW_STAT_RX_PORT_128B_255B_IX,
+       FW_STAT_RX_PORT_256B_511B_IX,
+       FW_STAT_RX_PORT_512B_1023B_IX,
+       FW_STAT_RX_PORT_1024B_1518B_IX,
+       FW_STAT_RX_PORT_1519B_MAX_IX,
+       FW_STAT_RX_PORT_PAUSE_IX,
+       FW_STAT_RX_PORT_PPP0_IX,
+       FW_STAT_RX_PORT_PPP1_IX,
+       FW_STAT_RX_PORT_PPP2_IX,
+       FW_STAT_RX_PORT_PPP3_IX,
+       FW_STAT_RX_PORT_PPP4_IX,
+       FW_STAT_RX_PORT_PPP5_IX,
+       FW_STAT_RX_PORT_PPP6_IX,
+       FW_STAT_RX_PORT_PPP7_IX,
+       FW_STAT_RX_PORT_LESS_64B_IX
+};
+
+struct fw_port_stats_cmd {
+       __be32 op_to_portid;
+       __be32 retval_len16;
+       union fw_port_stats {
+               struct fw_port_stats_ctl {
+                       u8 nstats_bg_bm;
+                       u8 tx_ix;
+                       __be16 r6;
+                       __be32 r7;
+                       __be64 stat0;
+                       __be64 stat1;
+                       __be64 stat2;
+                       __be64 stat3;
+                       __be64 stat4;
+                       __be64 stat5;
+               } ctl;
+               struct fw_port_stats_all {
+                       __be64 tx_bytes;
+                       __be64 tx_frames;
+                       __be64 tx_bcast;
+                       __be64 tx_mcast;
+                       __be64 tx_ucast;
+                       __be64 tx_error;
+                       __be64 tx_64b;
+                       __be64 tx_65b_127b;
+                       __be64 tx_128b_255b;
+                       __be64 tx_256b_511b;
+                       __be64 tx_512b_1023b;
+                       __be64 tx_1024b_1518b;
+                       __be64 tx_1519b_max;
+                       __be64 tx_drop;
+                       __be64 tx_pause;
+                       __be64 tx_ppp0;
+                       __be64 tx_ppp1;
+                       __be64 tx_ppp2;
+                       __be64 tx_ppp3;
+                       __be64 tx_ppp4;
+                       __be64 tx_ppp5;
+                       __be64 tx_ppp6;
+                       __be64 tx_ppp7;
+                       __be64 rx_bytes;
+                       __be64 rx_frames;
+                       __be64 rx_bcast;
+                       __be64 rx_mcast;
+                       __be64 rx_ucast;
+                       __be64 rx_mtu_error;
+                       __be64 rx_mtu_crc_error;
+                       __be64 rx_crc_error;
+                       __be64 rx_len_error;
+                       __be64 rx_sym_error;
+                       __be64 rx_64b;
+                       __be64 rx_65b_127b;
+                       __be64 rx_128b_255b;
+                       __be64 rx_256b_511b;
+                       __be64 rx_512b_1023b;
+                       __be64 rx_1024b_1518b;
+                       __be64 rx_1519b_max;
+                       __be64 rx_pause;
+                       __be64 rx_ppp0;
+                       __be64 rx_ppp1;
+                       __be64 rx_ppp2;
+                       __be64 rx_ppp3;
+                       __be64 rx_ppp4;
+                       __be64 rx_ppp5;
+                       __be64 rx_ppp6;
+                       __be64 rx_ppp7;
+                       __be64 rx_less_64b;
+                       __be64 rx_bg_drop;
+                       __be64 rx_bg_trunc;
+               } all;
+       } u;
+};
+
+#define FW_PORT_STATS_CMD_NSTATS(x) ((x) << 4)
+#define FW_PORT_STATS_CMD_BG_BM(x) ((x) << 0)
+#define FW_PORT_STATS_CMD_TX(x) ((x) << 7)
+#define FW_PORT_STATS_CMD_IX(x) ((x) << 0)
+
+/* port loopback stats */
+#define FW_NUM_LB_STATS 16
+enum fw_port_lb_stats_index {
+       FW_STAT_LB_PORT_BYTES_IX,
+       FW_STAT_LB_PORT_FRAMES_IX,
+       FW_STAT_LB_PORT_BCAST_IX,
+       FW_STAT_LB_PORT_MCAST_IX,
+       FW_STAT_LB_PORT_UCAST_IX,
+       FW_STAT_LB_PORT_ERROR_IX,
+       FW_STAT_LB_PORT_64B_IX,
+       FW_STAT_LB_PORT_65B_127B_IX,
+       FW_STAT_LB_PORT_128B_255B_IX,
+       FW_STAT_LB_PORT_256B_511B_IX,
+       FW_STAT_LB_PORT_512B_1023B_IX,
+       FW_STAT_LB_PORT_1024B_1518B_IX,
+       FW_STAT_LB_PORT_1519B_MAX_IX,
+       FW_STAT_LB_PORT_DROP_FRAMES_IX
+};
+
+struct fw_port_lb_stats_cmd {
+       __be32 op_to_lbport;
+       __be32 retval_len16;
+       union fw_port_lb_stats {
+               struct fw_port_lb_stats_ctl {
+                       u8 nstats_bg_bm;
+                       u8 ix_pkd;
+                       __be16 r6;
+                       __be32 r7;
+                       __be64 stat0;
+                       __be64 stat1;
+                       __be64 stat2;
+                       __be64 stat3;
+                       __be64 stat4;
+                       __be64 stat5;
+               } ctl;
+               struct fw_port_lb_stats_all {
+                       __be64 tx_bytes;
+                       __be64 tx_frames;
+                       __be64 tx_bcast;
+                       __be64 tx_mcast;
+                       __be64 tx_ucast;
+                       __be64 tx_error;
+                       __be64 tx_64b;
+                       __be64 tx_65b_127b;
+                       __be64 tx_128b_255b;
+                       __be64 tx_256b_511b;
+                       __be64 tx_512b_1023b;
+                       __be64 tx_1024b_1518b;
+                       __be64 tx_1519b_max;
+                       __be64 rx_lb_drop;
+                       __be64 rx_lb_trunc;
+               } all;
+       } u;
+};
+
+#define FW_PORT_LB_STATS_CMD_LBPORT(x) ((x) << 0)
+#define FW_PORT_LB_STATS_CMD_NSTATS(x) ((x) << 4)
+#define FW_PORT_LB_STATS_CMD_BG_BM(x) ((x) << 0)
+#define FW_PORT_LB_STATS_CMD_IX(x) ((x) << 0)
+
+struct fw_rss_ind_tbl_cmd {
+       __be32 op_to_viid;
+#define FW_RSS_IND_TBL_CMD_VIID(x) ((x) << 0)
+       __be32 retval_len16;
+       __be16 niqid;
+       __be16 startidx;
+       __be32 r3;
+       __be32 iq0_to_iq2;
+#define FW_RSS_IND_TBL_CMD_IQ0(x) ((x) << 20)
+#define FW_RSS_IND_TBL_CMD_IQ1(x) ((x) << 10)
+#define FW_RSS_IND_TBL_CMD_IQ2(x) ((x) << 0)
+       __be32 iq3_to_iq5;
+       __be32 iq6_to_iq8;
+       __be32 iq9_to_iq11;
+       __be32 iq12_to_iq14;
+       __be32 iq15_to_iq17;
+       __be32 iq18_to_iq20;
+       __be32 iq21_to_iq23;
+       __be32 iq24_to_iq26;
+       __be32 iq27_to_iq29;
+       __be32 iq30_iq31;
+       __be32 r15_lo;
+};
+
+struct fw_rss_glb_config_cmd {
+       __be32 op_to_write;
+       __be32 retval_len16;
+       union fw_rss_glb_config {
+               struct fw_rss_glb_config_manual {
+                       __be32 mode_pkd;
+                       __be32 r3;
+                       __be64 r4;
+                       __be64 r5;
+               } manual;
+               struct fw_rss_glb_config_basicvirtual {
+                       __be32 mode_pkd;
+                       __be32 synmapen_to_hashtoeplitz;
+#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN      (1U << 8)
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 (1U << 7)
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 (1U << 6)
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 (1U << 5)
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 (1U << 4)
+#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN      (1U << 3)
+#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN      (1U << 2)
+#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP     (1U << 1)
+#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ  (1U << 0)
+                       __be64 r8;
+                       __be64 r9;
+               } basicvirtual;
+       } u;
+};
+
+#define FW_RSS_GLB_CONFIG_CMD_MODE(x)  ((x) << 28)
+
+#define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL      0
+#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL        1
+
+struct fw_rss_vi_config_cmd {
+       __be32 op_to_viid;
+#define FW_RSS_VI_CONFIG_CMD_VIID(x) ((x) << 0)
+       __be32 retval_len16;
+       union fw_rss_vi_config {
+               struct fw_rss_vi_config_manual {
+                       __be64 r3;
+                       __be64 r4;
+                       __be64 r5;
+               } manual;
+               struct fw_rss_vi_config_basicvirtual {
+                       __be32 r6;
+                       __be32 defaultq_to_ip4udpen;
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ(x)  ((x) << 16)
+#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN (1U << 4)
+#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN  (1U << 3)
+#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN (1U << 2)
+#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN  (1U << 1)
+#define FW_RSS_VI_CONFIG_CMD_IP4UDPEN     (1U << 0)
+                       __be64 r9;
+                       __be64 r10;
+               } basicvirtual;
+       } u;
+};
+
+enum fw_error_type {
+       FW_ERROR_TYPE_EXCEPTION         = 0x0,
+       FW_ERROR_TYPE_HWMODULE          = 0x1,
+       FW_ERROR_TYPE_WR                = 0x2,
+       FW_ERROR_TYPE_ACL               = 0x3,
+};
+
+struct fw_error_cmd {
+       __be32 op_to_type;
+       __be32 len16_pkd;
+       union fw_error {
+               struct fw_error_exception {
+                       __be32 info[6];
+               } exception;
+               struct fw_error_hwmodule {
+                       __be32 regaddr;
+                       __be32 regval;
+               } hwmodule;
+               struct fw_error_wr {
+                       __be16 cidx;
+                       __be16 pfn_vfn;
+                       __be32 eqid;
+                       u8 wrhdr[16];
+               } wr;
+               struct fw_error_acl {
+                       __be16 cidx;
+                       __be16 pfn_vfn;
+                       __be32 eqid;
+                       __be16 mv_pkd;
+                       u8 val[6];
+                       __be64 r4;
+               } acl;
+       } u;
+};
+
+struct fw_debug_cmd {
+       __be32 op_type;
+#define FW_DEBUG_CMD_TYPE_GET(x) ((x) & 0xff)
+       __be32 len16_pkd;
+       union fw_debug {
+               struct fw_debug_assert {
+                       __be32 fcid;
+                       __be32 line;
+                       __be32 x;
+                       __be32 y;
+                       u8 filename_0_7[8];
+                       u8 filename_8_15[8];
+                       __be64 r3;
+               } assert;
+               struct fw_debug_prt {
+                       __be16 dprtstridx;
+                       __be16 r3[3];
+                       __be32 dprtstrparam0;
+                       __be32 dprtstrparam1;
+                       __be32 dprtstrparam2;
+                       __be32 dprtstrparam3;
+               } prt;
+       } u;
+};
+
+struct fw_hdr {
+       u8 ver;
+       u8 reserved1;
+       __be16  len512;                 /* bin length in units of 512-bytes */
+       __be32  fw_ver;                 /* firmware version */
+       __be32  tp_microcode_ver;
+       u8 intfver_nic;
+       u8 intfver_vnic;
+       u8 intfver_ofld;
+       u8 intfver_ri;
+       u8 intfver_iscsipdu;
+       u8 intfver_iscsi;
+       u8 intfver_fcoe;
+       u8 reserved2;
+       __be32  reserved3[27];
+};
+
+#define FW_HDR_FW_VER_MAJOR_GET(x) (((x) >> 24) & 0xff)
+#define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff)
+#define FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff)
+#define FW_HDR_FW_VER_BUILD_GET(x) (((x) >> 0) & 0xff)
+#endif /* _T4FW_INTERFACE_H_ */
index 1c67f1138ca7edb90b56124d08da15c80e7ce0c3..7f9960f718e35972dabedc30fb3f8faa3f7a3155 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <asm/irq.h>
index 9902b33b716052f7974cad7126b923a3068a27be..2f29c213185113c4d36eb095cc88b1190bef6603 100644 (file)
@@ -261,7 +261,6 @@ struct e1000_adapter {
        /* TX */
        struct e1000_tx_ring *tx_ring;      /* One per active queue */
        unsigned int restart_queue;
-       unsigned long tx_queue_len;
        u32 txd_cmd;
        u32 tx_int_delay;
        u32 tx_abs_int_delay;
index 8be6faee43e6e519519d015dd6c1d63a864d7b05..b15ece26ed8469136df4d40eced1b98839e4acce 100644 (file)
@@ -383,8 +383,6 @@ static void e1000_configure(struct e1000_adapter *adapter)
                adapter->alloc_rx_buf(adapter, ring,
                                      E1000_DESC_UNUSED(ring));
        }
-
-       adapter->tx_queue_len = netdev->tx_queue_len;
 }
 
 int e1000_up(struct e1000_adapter *adapter)
@@ -503,7 +501,6 @@ void e1000_down(struct e1000_adapter *adapter)
        del_timer_sync(&adapter->watchdog_timer);
        del_timer_sync(&adapter->phy_info_timer);
 
-       netdev->tx_queue_len = adapter->tx_queue_len;
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
        netif_carrier_off(netdev);
@@ -2316,19 +2313,15 @@ static void e1000_watchdog(unsigned long data)
                                E1000_CTRL_RFCE) ? "RX" : ((ctrl &
                                E1000_CTRL_TFCE) ? "TX" : "None" )));
 
-                       /* tweak tx_queue_len according to speed/duplex
-                        * and adjust the timeout factor */
-                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       /* adjust timeout factor according to speed/duplex */
                        adapter->tx_timeout_factor = 1;
                        switch (adapter->link_speed) {
                        case SPEED_10:
                                txb2b = false;
-                               netdev->tx_queue_len = 10;
                                adapter->tx_timeout_factor = 16;
                                break;
                        case SPEED_100:
                                txb2b = false;
-                               netdev->tx_queue_len = 100;
                                /* maybe add some timeout factor ? */
                                break;
                        }
index c2ec095d2163980953e0bd4ad464fdb8736a9450..118bdf4835938301b37af18b10a45c206abe2b24 100644 (file)
@@ -279,7 +279,6 @@ struct e1000_adapter {
 
        struct napi_struct napi;
 
-       unsigned long tx_queue_len;
        unsigned int restart_queue;
        u32 txd_cmd;
 
index b33e3cbe9ab03dd22fb8d97c104b9080e94b2b68..983493f2330c37e6e89fb89e1525310ed779c6f2 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "e1000.h"
index 88d54d3efcef2ff78bd66bd2cd358c8809c22820..cfd09cea721450e12483ee4b63206f24eaabb07f 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/netdevice.h>
 #include <linux/tcp.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <linux/mii.h>
@@ -2289,8 +2290,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
        ew32(TCTL, tctl);
 
        e1000e_config_collision_dist(hw);
-
-       adapter->tx_queue_len = adapter->netdev->tx_queue_len;
 }
 
 /**
@@ -2877,7 +2876,6 @@ void e1000e_down(struct e1000_adapter *adapter)
        del_timer_sync(&adapter->watchdog_timer);
        del_timer_sync(&adapter->phy_info_timer);
 
-       netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
@@ -3588,21 +3586,15 @@ static void e1000_watchdog_task(struct work_struct *work)
                                               "link gets many collisions.\n");
                        }
 
-                       /*
-                        * tweak tx_queue_len according to speed/duplex
-                        * and adjust the timeout factor
-                        */
-                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       /* adjust timeout factor according to speed/duplex */
                        adapter->tx_timeout_factor = 1;
                        switch (adapter->link_speed) {
                        case SPEED_10:
                                txb2b = 0;
-                               netdev->tx_queue_len = 10;
                                adapter->tx_timeout_factor = 16;
                                break;
                        case SPEED_100:
                                txb2b = 0;
-                               netdev->tx_queue_len = 100;
                                adapter->tx_timeout_factor = 10;
                                break;
                        }
index 1b05bdf62c3ceffb6f8f61a215d3c34585c7d56c..27c7bdbfa0030a2d6274716d6c91eaa0fb926341 100644 (file)
@@ -137,7 +137,6 @@ static const char version[] =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
index 7013dc8a6cbcde21c52f338aa456f536b4633dc6..1a7322b80ea7e6dfee43d84f7a0d793753d26fdd 100644 (file)
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/mca-legacy.h>
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
index b004eaba3d7bc334f12d8136961cf50cb8e8133e..809ccc9ff09cc8913a8e19ab1982cf76e7d69000 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/udp.h>
 #include <linux/if.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/if_ether.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
index 18d405f78c0f953f402f93da0dcb260af070a0d0..a1b4c7e563679f854b698e7f5f5f0f585a2d9fa6 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include "ehea.h"
 #include "ehea_phyp.h"
 #include "ehea_qmr.h"
index 3ee32e58c7ecaeba0ff0d5ce51f618e95ab95833..ff27f728fd9db290132db8f6a0a91952a1962079 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index 69b9b70c7da08c441f5cfa77c45a4ab1e3ab9745..cf22de71014e2ef5729928766d085ea0b1aa1d56 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 
 #include "vnic_resource.h"
 #include "vnic_devcmd.h"
index 75583978a5e54f01fd37f6f921fab22027ccb641..e186efaf9da1fc0c5d552fdb90aac7885b553a86 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "vnic_dev.h"
 #include "vnic_rq.h"
index d2e00e51b7b56a1fdafb032b0cc9332b60b54efe..d5f984357f5cb2437a3a48172e75bcaf93f77db1 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "vnic_dev.h"
 #include "vnic_wq.h"
index 39c271b6be443a689d5eacc6cf32cdeed2ba6b4a..7a567201e8295f8c17763c2f350e96f3b8495a0c 100644 (file)
@@ -73,7 +73,6 @@ static int rx_copybreak;
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
index f5b96cadeb2544994c4aadeeb45f30113c082116..b34a2ddeef4c810b37dca41faad2ed4cc12955b9 100644 (file)
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/netdevice.h>
 #include <net/net_namespace.h>
index d3abeee3f1104d390e5f9e0f8e87e78d116a3ae1..d4e24f08b3ba3bb0c51d925109cd0ffc88964b1c 100644 (file)
@@ -152,7 +152,6 @@ static char *version =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index 209742304e209121dc314a80099494a62558d329..a8d92503226e3d00a9e68ade94e97a2b892ec1cc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/ethoc.h>
 
 static int buffer_size = 0x8000; /* 32 KBytes */
index 9d5ad08a119f4c73a71fb1857840900b14e33729..d11ae5197f01533f20cf141f023d1516b2b37765 100644 (file)
@@ -74,7 +74,6 @@ static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
index 0dbd7219bbde2fa067134666cab69bc37325a147..4a43e56b739496fddaf8daba5202f2f20831271d 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
index ee0f3c6d3f888e636c6da076a83d5b3ac4187d72..7658a082e390cd4c8d86c066cdf0d76aa1d72d80 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/netdevice.h>
 #include <linux/phy.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 #include <linux/of_mdio.h>
 #include <asm/io.h>
 #include <asm/mpc52xx.h>
index ca05e5662029d8a4566a2d95fbcde3a55ba27ce3..73b260c3c6542cfba8f95a9489e0b7329d8f9cd6 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/init.h>
 #include <linux/if_vlan.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
index cf4f674f9e2eed1cc66600881b3f819434dfe007..0a973e71876b591e2fc371e90dd1a8437ced969d 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
@@ -34,6 +33,7 @@
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/mpc8260.h>
index cd2c6cca5f2425d2333ffd91ba76b39cdf8bfdf5..ec81f50d59196aac31d58fcc6146a9a44e72f01b 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
@@ -33,6 +32,7 @@
 #include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
index c490a466cae15010403f091ce77160deb40250f9..34d3da751eb4001bc8925848de903cc7ce4a9270 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index b6715553cf173e44bb5dc86be57745ed12009b1b..080d1cea5b265704819d54b1c60e96393d1b7749 100644 (file)
@@ -676,7 +676,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
                priv->rx_queue[i] = NULL;
 
        for (i = 0; i < priv->num_tx_queues; i++) {
-               priv->tx_queue[i] =  (struct gfar_priv_tx_q *)kmalloc(
+               priv->tx_queue[i] =  (struct gfar_priv_tx_q *)kzalloc(
                                sizeof (struct gfar_priv_tx_q), GFP_KERNEL);
                if (!priv->tx_queue[i]) {
                        err = -ENOMEM;
@@ -689,7 +689,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
        }
 
        for (i = 0; i < priv->num_rx_queues; i++) {
-               priv->rx_queue[i] = (struct gfar_priv_rx_q *)kmalloc(
+               priv->rx_queue[i] = (struct gfar_priv_rx_q *)kzalloc(
                                        sizeof (struct gfar_priv_rx_q), GFP_KERNEL);
                if (!priv->rx_queue[i]) {
                        err = -ENOMEM;
@@ -1120,10 +1120,10 @@ static int gfar_probe(struct of_device *ofdev,
        /* provided which set of benchmarks. */
        printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);
        for (i = 0; i < priv->num_rx_queues; i++)
-               printk(KERN_INFO "%s: :RX BD ring size for Q[%d]: %d\n",
+               printk(KERN_INFO "%s: RX BD ring size for Q[%d]: %d\n",
                        dev->name, i, priv->rx_queue[i]->rx_ring_size);
        for(i = 0; i < priv->num_tx_queues; i++)
-                printk(KERN_INFO "%s:TX BD ring size for Q[%d]: %d\n",
+                printk(KERN_INFO "%s: TX BD ring size for Q[%d]: %d\n",
                        dev->name, i, priv->tx_queue[i]->tx_ring_size);
 
        return 0;
@@ -1638,13 +1638,13 @@ static void free_skb_resources(struct gfar_private *priv)
        /* Go through all the buffer descriptors and free their data buffers */
        for (i = 0; i < priv->num_tx_queues; i++) {
                tx_queue = priv->tx_queue[i];
-               if(!tx_queue->tx_skbuff)
+               if(tx_queue->tx_skbuff)
                        free_skb_tx_queue(tx_queue);
        }
 
        for (i = 0; i < priv->num_rx_queues; i++) {
                rx_queue = priv->rx_queue[i];
-               if(!rx_queue->rx_skbuff)
+               if(rx_queue->rx_skbuff)
                        free_skb_rx_queue(rx_queue);
        }
 
@@ -2393,6 +2393,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev)
         * as many bytes as needed to align the data properly
         */
        skb_reserve(skb, alignamount);
+       GFAR_CB(skb)->alignamount = alignamount;
 
        return skb;
 }
@@ -2533,13 +2534,13 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
                                newskb = skb;
                        else if (skb) {
                                /*
-                                * We need to reset ->data to what it
+                                * We need to un-reserve() the skb to what it
                                 * was before gfar_new_skb() re-aligned
                                 * it to an RXBUF_ALIGNMENT boundary
                                 * before we put the skb back on the
                                 * recycle list.
                                 */
-                               skb->data = skb->head + NET_SKB_PAD;
+                               skb_reserve(skb, -GFAR_CB(skb)->alignamount);
                                __skb_queue_head(&priv->rx_recycle, skb);
                        }
                } else {
index 3d72dc43dca56bdbaba7a510e4e9cb624aa8044f..17d25e714236f305908670efc53fc0c6ace07a08 100644 (file)
@@ -566,6 +566,12 @@ struct rxfcb {
        u16     vlctl;  /* VLAN control word */
 };
 
+struct gianfar_skb_cb {
+       int alignamount;
+};
+
+#define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb))
+
 struct rmon_mib
 {
        u32     tr64;   /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
index 1010367695e46c7659704080eb067e90a9784b47..9bda023c0235664f9000411fa543ce182371259f 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index b98c6c512299d94305f71a57e072dcadd072a409..64f4094ac7f16f63ca2227d966e5d59b5d689325 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
index 2b9c1cbc9ec1b3e33d2275aa1682a78fe7becbf1..3a90430de918bc1b1a1de8bd05e0d0f5f11bda6e 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/mii.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 #include <asm/byteorder.h>
 
index 373546dd083116da8b21c8220725ac32d85fb840..5d6f138795925dc2fecf2e729a918b01d6d7e8e1 100644 (file)
@@ -153,7 +153,6 @@ static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 #include <linux/time.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/init.h>
index 689b9bd377a52bd3f571aac96c43acfb403f12d2..4b52c767ad056ced9aafcafea8299384b807c169 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
index bdadf3e23c94be378b148a006f415fa74cb053f1..14f01d156db9cf588a7640de77998cbba65a3c75 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 9ee76b42668fa5c2c27a767f1a3e4936d6dbfe32..52b14256e2c0818be269f34e7e9475dfc2ec1470 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/rtnetlink.h>
 #include <linux/sockios.h>
 #include <linux/workqueue.h>
index 91c5790c9581ded3ad1cdc790b99eb77913accc5..b8bdf9d51cd44c5b145af8c860e0f2a0a771a898 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/net.h>
 #include <linux/in.h>
 #include <linux/if.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
index 7db0a1c3216c7b8dc86703ac23074b9afbe82867..66e88bd59caada26f9cdaa4b6dbb7c1a78026e1f 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/in.h>
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
index 35c936175bba2eab1fdf30f813ebeea04256ec95..f3a96b8439110856b1446ab32876161205226ec9 100644 (file)
 #include <linux/in.h>
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
index b766a69bf0caa15fc8704d9522e80539bb61d550..4daad8cd56ea885af08391c9c0cef4481e7ad416 100644 (file)
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/eisa.h>
 #include <linux/pci.h>
index 3e3528ade259d73f072d614f2181fe04c2083940..b6060f7538dfc42d250ef9bbd59bb93221fd6fd7 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index d496b6f4a478d127f193c07212ca6ac2633a3725..24724b4ad7096fc31ada3c8b0f4ff8078189f23e 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
index fb0ac6d7c0400eb6f5034d0b618bbbe9643e918f..dd873cc41c2b718262c053642593c5461134f458 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/bitops.h>
 #include <linux/workqueue.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
index 18d56c6c4238e75673e34c3bdd7c0ec2a55563bb..b1cbe6fdfc7a05802294c5bbcd8926aad4e0b7f4 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/dcr.h>
index 2a2fc17b28780678eff7efaf0f6d17586e09e7c2..5b3d94419fe6aa1ba94c2e1c8e00cc30f925ccdc 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "core.h"
 #include <asm/dcr-regs.h>
index 8d76cb89dbd61e6d252ed30fbe1bf211f5081732..5b90d34c845502dc789b4c87b6bc35e9f2a89f64 100644 (file)
@@ -21,6 +21,7 @@
  * option) any later version.
  *
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/ethtool.h>
 #include <asm/io.h>
index 17b154124943e5baf89e6640f26643ade28be72c..1f038f808ab32512fdb78ae01b4f54f9f152d5a2 100644 (file)
@@ -21,6 +21,7 @@
  * option) any later version.
  *
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/ethtool.h>
 #include <asm/io.h>
index b5d0f4e973f70cbb9fa68eff005b4ff594104f11..7d6cf3340c113041216fbca52ea23a3c9514d8c3 100644 (file)
@@ -79,7 +79,6 @@ History:
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/time.h>
index 0bc777bac9b47dd4ac45c29a30be13f347e2e706..cd508a8ee25b3f9a5a81b568e5a733e68e4d961e 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/proc_fs.h>
 #include <linux/in.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <asm/hvcall.h>
 #include <asm/atomic.h>
index 9d7fa2fb85ea0cb9de0b7582da337d03d7b9c917..4a32bed77c719acab24f459e2a4f57b3600a777e 100644 (file)
@@ -30,7 +30,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/if_ether.h>
 
 #include "e1000_mac.h"
@@ -94,6 +93,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
        case E1000_DEV_ID_82576_FIBER:
        case E1000_DEV_ID_82576_SERDES:
        case E1000_DEV_ID_82576_QUAD_COPPER:
+       case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
        case E1000_DEV_ID_82576_SERDES_QUAD:
                mac->type = e1000_82576;
                break;
index 448005276b26b68bdba25be9606aa41185a7ebe6..82a533f5192a545e5d6d631b2cc671e0bb042a5b 100644 (file)
@@ -41,6 +41,7 @@ struct e1000_hw;
 #define E1000_DEV_ID_82576_FIBER              0x10E6
 #define E1000_DEV_ID_82576_SERDES             0x10E7
 #define E1000_DEV_ID_82576_QUAD_COPPER        0x10E8
+#define E1000_DEV_ID_82576_QUAD_COPPER_ET2    0x1526
 #define E1000_DEV_ID_82576_NS                 0x150A
 #define E1000_DEV_ID_82576_NS_SERDES          0x1518
 #define E1000_DEV_ID_82576_SERDES_QUAD        0x150D
index 2a8a886b37eb698bfed13f145b3e677cf363e9c2..be8d010e40213a7b51616fad0e320464a43c751a 100644 (file)
@@ -1367,7 +1367,8 @@ out:
  *  igb_enable_mng_pass_thru - Enable processing of ARP's
  *  @hw: pointer to the HW structure
  *
- *  Verifies the hardware needs to allow ARPs to be processed by the host.
+ *  Verifies the hardware needs to leave interface enabled so that frames can
+ *  be directed to and from the management interface.
  **/
 bool igb_enable_mng_pass_thru(struct e1000_hw *hw)
 {
@@ -1380,8 +1381,7 @@ bool igb_enable_mng_pass_thru(struct e1000_hw *hw)
 
        manc = rd32(E1000_MANC);
 
-       if (!(manc & E1000_MANC_RCV_TCO_EN) ||
-           !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
+       if (!(manc & E1000_MANC_RCV_TCO_EN))
                goto out;
 
        if (hw->mac.arc_subsystem_valid) {
index a1775705b24c93759daf7d63cf0d02a0fd36f089..3b772b822a5dcc61548c8bc98297c8bd9c47efb6 100644 (file)
@@ -267,7 +267,6 @@ struct igb_adapter {
 
        /* TX */
        struct igb_ring *tx_ring[16];
-       unsigned long tx_queue_len;
        u32 tx_timeout_count;
 
        /* RX */
index a4cead12fd987541a48e5f840f94e0bc22b50ce0..d313fae992da8d87c205641067a209de24ec6678 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/if_ether.h>
 #include <linux/ethtool.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "igb.h"
 
index 0ed25f059a00732345f34ecbf721a167ed9c1cc2..9b3c51ab1758fb5474cf52cdcf11b67681f869da 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/pagemap.h>
 #include <linux/netdevice.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <linux/net_tstamp.h>
@@ -72,6 +73,7 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES_QUAD), board_82575 },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER_ET2), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 },
@@ -1104,9 +1106,6 @@ static void igb_configure(struct igb_adapter *adapter)
                struct igb_ring *ring = adapter->rx_ring[i];
                igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring));
        }
-
-
-       adapter->tx_queue_len = netdev->tx_queue_len;
 }
 
 /**
@@ -1212,7 +1211,6 @@ void igb_down(struct igb_adapter *adapter)
        del_timer_sync(&adapter->watchdog_timer);
        del_timer_sync(&adapter->phy_info_timer);
 
-       netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
 
        /* record the stats before reset*/
@@ -3105,17 +3103,13 @@ static void igb_watchdog_task(struct work_struct *work)
                               ((ctrl & E1000_CTRL_RFCE) ?  "RX" :
                               ((ctrl & E1000_CTRL_TFCE) ?  "TX" : "None")));
 
-                       /* tweak tx_queue_len according to speed/duplex and
-                        * adjust the timeout factor */
-                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       /* adjust timeout factor according to speed/duplex */
                        adapter->tx_timeout_factor = 1;
                        switch (adapter->link_speed) {
                        case SPEED_10:
-                               netdev->tx_queue_len = 10;
                                adapter->tx_timeout_factor = 14;
                                break;
                        case SPEED_100:
-                               netdev->tx_queue_len = 100;
                                /* maybe add some timeout factor ? */
                                break;
                        }
@@ -3962,7 +3956,7 @@ void igb_update_stats(struct igb_adapter *adapter)
        struct net_device_stats *net_stats = igb_get_stats(adapter->netdev);
        struct e1000_hw *hw = &adapter->hw;
        struct pci_dev *pdev = adapter->pdev;
-       u32 rnbc, reg;
+       u32 reg, mpc;
        u16 phy_tmp;
        int i;
        u64 bytes, packets;
@@ -4020,7 +4014,9 @@ void igb_update_stats(struct igb_adapter *adapter)
        adapter->stats.symerrs += rd32(E1000_SYMERRS);
        adapter->stats.sec += rd32(E1000_SEC);
 
-       adapter->stats.mpc += rd32(E1000_MPC);
+       mpc = rd32(E1000_MPC);
+       adapter->stats.mpc += mpc;
+       net_stats->rx_fifo_errors += mpc;
        adapter->stats.scc += rd32(E1000_SCC);
        adapter->stats.ecol += rd32(E1000_ECOL);
        adapter->stats.mcc += rd32(E1000_MCC);
@@ -4035,9 +4031,7 @@ void igb_update_stats(struct igb_adapter *adapter)
        adapter->stats.gptc += rd32(E1000_GPTC);
        adapter->stats.gotc += rd32(E1000_GOTCL);
        rd32(E1000_GOTCH); /* clear GOTCL */
-       rnbc = rd32(E1000_RNBC);
-       adapter->stats.rnbc += rnbc;
-       net_stats->rx_fifo_errors += rnbc;
+       adapter->stats.rnbc += rd32(E1000_RNBC);
        adapter->stats.ruc += rd32(E1000_RUC);
        adapter->stats.rfc += rd32(E1000_RFC);
        adapter->stats.rjc += rd32(E1000_RJC);
@@ -5109,7 +5103,7 @@ static void igb_receive_skb(struct igb_q_vector *q_vector,
 {
        struct igb_adapter *adapter = q_vector->adapter;
 
-       if (vlan_tag)
+       if (vlan_tag && adapter->vlgrp)
                vlan_gro_receive(&q_vector->napi, adapter->vlgrp,
                                 vlan_tag, skb);
        else
index a1774b29d222093851ce46e29d5871d9cc69e286..debeee2dc717c6f86261c53ea93f46b84a07e9ca 100644 (file)
@@ -198,7 +198,6 @@ struct igbvf_adapter {
        struct igbvf_ring *tx_ring /* One per active queue */
        ____cacheline_aligned_in_smp;
 
-       unsigned long tx_queue_len;
        unsigned int restart_queue;
        u32 txd_cmd;
 
index a77afd8a14bbfd30fed68c02cb1861e6113f50fa..1b1edad1eb5e68de5a583a2a1ac14d68e6a2a7dd 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/netdevice.h>
 #include <linux/tcp.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <linux/mii.h>
@@ -1304,8 +1305,6 @@ static void igbvf_configure_tx(struct igbvf_adapter *adapter)
 
        /* enable Report Status bit */
        adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS;
-
-       adapter->tx_queue_len = adapter->netdev->tx_queue_len;
 }
 
 /**
@@ -1524,7 +1523,6 @@ void igbvf_down(struct igbvf_adapter *adapter)
 
        del_timer_sync(&adapter->watchdog_timer);
 
-       netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
 
        /* record the stats before reset*/
@@ -1857,21 +1855,15 @@ static void igbvf_watchdog_task(struct work_struct *work)
                                                  &adapter->link_duplex);
                        igbvf_print_link_info(adapter);
 
-                       /*
-                        * tweak tx_queue_len according to speed/duplex
-                        * and adjust the timeout factor
-                        */
-                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       /* adjust timeout factor according to speed/duplex */
                        adapter->tx_timeout_factor = 1;
                        switch (adapter->link_speed) {
                        case SPEED_10:
                                txb2b = 0;
-                               netdev->tx_queue_len = 10;
                                adapter->tx_timeout_factor = 16;
                                break;
                        case SPEED_100:
                                txb2b = 0;
-                               netdev->tx_queue_len = 100;
                                /* maybe add some timeout factor ? */
                                break;
                        }
index 70871b9b045a05c9d2221724fade93d77dfd64ca..8f6197d647c0433a227dd74f4057df0cc9905fbf 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #ifdef CONFIG_SERIAL_8250
 #include <linux/serial_core.h>
index 150415e83f61e21e3cdc25f85a9d892b849c7016..639bf9fb027974b65b0376a5a2a188f3171dec26 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <linux/crc32.h>
 #include <linux/ethtool.h>
+#include <linux/gfp.h>
 #include <linux/mii.h>
 #include <linux/mutex.h>
 
index 12c7b006f767cbf5b2eac5442306d2c079d5959c..28992c815cba14282dc17a999ca32c8a6fd450c9 100644 (file)
@@ -22,6 +22,7 @@
  ********************************************************************/
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -29,7 +30,6 @@
 #include <linux/netdevice.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/serial_reg.h>
index dac71b1f4f9bcaa2f38cea6b0829efdf3192f1d1..b54a6f08db45917ebf25890bf45040b7be5c4a2c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/wrapper.h>
index 20f9bc6266882eae0dae82707d9935f6bee1b8d4..ee1dde52e8fcf1b6ddd620b06fb989972e1528e3 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
index 2413295ebd903980eb335c85357a892e9dc68eda..e30cdbb1474567885d64a9c4cd2d281fcf6d32c8 100644 (file)
@@ -43,6 +43,7 @@
  ********************************************************************/
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -50,7 +51,6 @@
 #include <linux/netdevice.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/dma-mapping.h>
index 84db145d2b59ad3ed3ef02ce8d621c7bf9eedea9..1a54f6bb68c5066612af0125c358abcf9285ccdc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irmod.h>
index d7c983dc91adff1436c7b3ac24d5aa9d6bf8d8c1..0745581c4b5ec873d7ba06e9e817f93d7dd0e16d 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <net/irda/wrapper.h>
 #include <net/irda/irda_device.h>
 #include <asm/clock.h>
index 4b2a1a9eac2afad94d29e85745ba3d1a25d5f9fe..de91cd14016be75de37513939d018d8b35df806e 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 
index 8f7d0d146f240c32208bee6d7f5464c90f3540b5..6af84d88cd03c960237927ee71752a06c087de60 100644 (file)
 #include <linux/netdevice.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/serial_reg.h>
 #include <linux/dma-mapping.h>
 #include <linux/pnp.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 6533c010cf5c494f1e574da6ca43d64b507e9e53..b0a6cd815be198e11334880d9ce8a728ee28d4e4 100644 (file)
@@ -45,11 +45,11 @@ F02 Oct/28/02: Add SB device ID for 3147 and 3177.
 #include <linux/netdevice.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 980625feb2c09b3f5fd38ad608ad5d01a688cee9..cb0cb758be64a23e5eae893b296bc2d642451975 100644 (file)
 #include <linux/netdevice.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index e6e972d9b7ca40b63e1b5ea6a525d5e1daaff2b8..773c59c8969162fac202202b854e6e77a6c43a67 100644 (file)
@@ -69,6 +69,7 @@
 #include <linux/mm.h>
 #include <linux/ethtool.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 
 #include <asm/abs_addr.h>
 #include <asm/iseries/mf.h>
index 19e94ee155a265f09a7560d3e78ae5d796528e31..79c35ae3718c96186898452e286d59d5e0482814 100644 (file)
@@ -204,14 +204,17 @@ enum ixgbe_ring_f_enum {
 #define IXGBE_MAX_FDIR_INDICES 64
 #ifdef IXGBE_FCOE
 #define IXGBE_MAX_FCOE_INDICES  8
+#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
+#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
+#else
+#define MAX_RX_QUEUES IXGBE_MAX_FDIR_INDICES
+#define MAX_TX_QUEUES IXGBE_MAX_FDIR_INDICES
 #endif /* IXGBE_FCOE */
 struct ixgbe_ring_feature {
        int indices;
        int mask;
 } ____cacheline_internodealigned_in_smp;
 
-#define MAX_RX_QUEUES 128
-#define MAX_TX_QUEUES 128
 
 #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
                               ? 8 : 1)
index 1f30e163bd9cc2ff904b4349acb3960ff6974035..b405a00817c66f248ac671476f214a7aaffe2f3c 100644 (file)
@@ -39,6 +39,7 @@
 #define IXGBE_82599_MC_TBL_SIZE   128
 #define IXGBE_82599_VFT_TBL_SIZE  128
 
+void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
 s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                                           ixgbe_link_speed speed,
                                           bool autoneg,
@@ -68,7 +69,9 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
        if (hw->phy.multispeed_fiber) {
                /* Set up dual speed SFP+ support */
                mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
+               mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
        } else {
+               mac->ops.flap_tx_laser = NULL;
                if ((mac->ops.get_media_type(hw) ==
                     ixgbe_media_type_backplane) &&
                    (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
@@ -412,6 +415,41 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
        return status;
 }
 
+/**
+ *  ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
+ *  @hw: pointer to hardware structure
+ *
+ *  When the driver changes the link speeds that it can support,
+ *  it sets autotry_restart to true to indicate that we need to
+ *  initiate a new autotry session with the link partner.  To do
+ *  so, we set the speed then disable and re-enable the tx laser, to
+ *  alert the link partner that it also needs to restart autotry on its
+ *  end.  This is consistent with true clause 37 autoneg, which also
+ *  involves a loss of signal.
+ **/
+void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
+{
+       u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
+
+       hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n");
+
+       if (hw->mac.autotry_restart) {
+               /* Disable tx laser; allow 100us to go dark per spec */
+               esdp_reg |= IXGBE_ESDP_SDP3;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+               IXGBE_WRITE_FLUSH(hw);
+               udelay(100);
+
+               /* Enable tx laser; allow 100ms to light up */
+               esdp_reg &= ~IXGBE_ESDP_SDP3;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+               IXGBE_WRITE_FLUSH(hw);
+               msleep(100);
+
+               hw->mac.autotry_restart = false;
+       }
+}
+
 /**
  *  ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
  *  @hw: pointer to hardware structure
@@ -439,16 +477,6 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
        hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation);
        speed &= phy_link_speed;
 
-       /*
-        * When the driver changes the link speeds that it can support,
-        * it sets autotry_restart to true to indicate that we need to
-        * initiate a new autotry session with the link partner.  To do
-        * so, we set the speed then disable and re-enable the tx laser, to
-        * alert the link partner that it also needs to restart autotry on its
-        * end.  This is consistent with true clause 37 autoneg, which also
-        * involves a loss of signal.
-        */
-
        /*
         * Try each speed one by one, highest priority first.  We do this in
         * software because 10gb fiber doesn't support speed autonegotiation.
@@ -466,6 +494,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                /* Set the module link speed */
                esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
                IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+               IXGBE_WRITE_FLUSH(hw);
 
                /* Allow module to change analog characteristics (1G->10G) */
                msleep(40);
@@ -478,19 +507,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                        return status;
 
                /* Flap the tx laser if it has not already been done */
-               if (hw->mac.autotry_restart) {
-                       /* Disable tx laser; allow 100us to go dark per spec */
-                       esdp_reg |= IXGBE_ESDP_SDP3;
-                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-                       udelay(100);
-
-                       /* Enable tx laser; allow 2ms to light up per spec */
-                       esdp_reg &= ~IXGBE_ESDP_SDP3;
-                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-                       msleep(2);
-
-                       hw->mac.autotry_restart = false;
-               }
+               hw->mac.ops.flap_tx_laser(hw);
 
                /*
                 * Wait for the controller to acquire link.  Per IEEE 802.3ap,
@@ -525,6 +542,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                esdp_reg &= ~IXGBE_ESDP_SDP5;
                esdp_reg |= IXGBE_ESDP_SDP5_DIR;
                IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+               IXGBE_WRITE_FLUSH(hw);
 
                /* Allow module to change analog characteristics (10G->1G) */
                msleep(40);
@@ -537,19 +555,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                        return status;
 
                /* Flap the tx laser if it has not already been done */
-               if (hw->mac.autotry_restart) {
-                       /* Disable tx laser; allow 100us to go dark per spec */
-                       esdp_reg |= IXGBE_ESDP_SDP3;
-                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-                       udelay(100);
-
-                       /* Enable tx laser; allow 2ms to light up per spec */
-                       esdp_reg &= ~IXGBE_ESDP_SDP3;
-                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-                       msleep(2);
-
-                       hw->mac.autotry_restart = false;
-               }
+               hw->mac.ops.flap_tx_laser(hw);
 
                /* Wait for the link partner to also set speed */
                msleep(100);
index 7949a446e4c7673f2587ec6da3b33c1a06574cae..8f461d5cee7775da632822317da4151ac02a2ff4 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/types.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
@@ -1853,6 +1854,26 @@ static void ixgbe_diag_test(struct net_device *netdev,
                if (ixgbe_link_test(adapter, &data[4]))
                        eth_test->flags |= ETH_TEST_FL_FAILED;
 
+               if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
+                       int i;
+                       for (i = 0; i < adapter->num_vfs; i++) {
+                               if (adapter->vfinfo[i].clear_to_send) {
+                                       netdev_warn(netdev, "%s",
+                                                   "offline diagnostic is not "
+                                                   "supported when VFs are "
+                                                   "present\n");
+                                       data[0] = 1;
+                                       data[1] = 1;
+                                       data[2] = 1;
+                                       data[3] = 1;
+                                       eth_test->flags |= ETH_TEST_FL_FAILED;
+                                       clear_bit(__IXGBE_TESTING,
+                                                 &adapter->state);
+                                       goto skip_ol_tests;
+                               }
+                       }
+               }
+
                if (if_running)
                        /* indicate we're in test mode */
                        dev_close(netdev);
@@ -1908,6 +1929,7 @@ skip_loopback:
 
                clear_bit(__IXGBE_TESTING, &adapter->state);
        }
+skip_ol_tests:
        msleep_interruptible(4 * 1000);
 }
 
index 4123dec0dfb7aa39554624f01b6258579f44f004..6493049b663d95e13f73ea5c252bffcd88e0c2cd 100644 (file)
@@ -31,6 +31,7 @@
 #include "ixgbe_dcb_82599.h"
 #endif /* CONFIG_IXGBE_DCB */
 #include <linux/if_ether.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <scsi/fc/fc_fs.h>
@@ -202,6 +203,15 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
                addr = sg_dma_address(sg);
                len = sg_dma_len(sg);
                while (len) {
+                       /* max number of buffers allowed in one DDP context */
+                       if (j >= IXGBE_BUFFCNT_MAX) {
+                               netif_err(adapter, drv, adapter->netdev,
+                                         "xid=%x:%d,%d,%d:addr=%llx "
+                                         "not enough descriptors\n",
+                                         xid, i, j, dmacount, (u64)addr);
+                               goto out_noddp_free;
+                       }
+
                        /* get the offset of length of current buffer */
                        thisoff = addr & ((dma_addr_t)bufflen - 1);
                        thislen = min((bufflen - thisoff), len);
@@ -227,20 +237,13 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
                        len -= thislen;
                        addr += thislen;
                        j++;
-                       /* max number of buffers allowed in one DDP context */
-                       if (j > IXGBE_BUFFCNT_MAX) {
-                               DPRINTK(DRV, ERR, "xid=%x:%d,%d,%d:addr=%llx "
-                                       "not enough descriptors\n",
-                                       xid, i, j, dmacount, (u64)addr);
-                               goto out_noddp_free;
-                       }
                }
        }
        /* only the last buffer may have non-full bufflen */
        lastsize = thisoff + thislen;
 
        fcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT);
-       fcbuff |= (j << IXGBE_FCBUFF_BUFFCNT_SHIFT);
+       fcbuff |= ((j & 0xff) << IXGBE_FCBUFF_BUFFCNT_SHIFT);
        fcbuff |= (firstoff << IXGBE_FCBUFF_OFFSET_SHIFT);
        fcbuff |= (IXGBE_FCBUFF_VALID);
 
@@ -520,6 +523,9 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
        /* Enable L2 eth type filter for FCoE */
        IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FCOE),
                        (ETH_P_FCOE | IXGBE_ETQF_FCOE | IXGBE_ETQF_FILTER_EN));
+       /* Enable L2 eth type filter for FIP */
+       IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FIP),
+                       (ETH_P_FIP | IXGBE_ETQF_FILTER_EN));
        if (adapter->ring_feature[RING_F_FCOE].indices) {
                /* Use multiple rx queues for FCoE by redirection table */
                for (i = 0; i < IXGBE_FCRETA_SIZE; i++) {
@@ -530,6 +536,12 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
                }
                IXGBE_WRITE_REG(hw, IXGBE_FCRECTL, IXGBE_FCRECTL_ENA);
                IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FCOE), 0);
+               fcoe_i = f->mask;
+               fcoe_i &= IXGBE_FCRETA_ENTRY_MASK;
+               fcoe_q = adapter->rx_ring[fcoe_i]->reg_idx;
+               IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FIP),
+                               IXGBE_ETQS_QUEUE_EN |
+                               (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
        } else  {
                /* Use single rx queue for FCoE */
                fcoe_i = f->mask;
@@ -539,6 +551,12 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
                                IXGBE_ETQS_QUEUE_EN |
                                (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
        }
+       /* send FIP frames to the first FCoE queue */
+       fcoe_i = f->mask;
+       fcoe_q = adapter->rx_ring[fcoe_i]->reg_idx;
+       IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FIP),
+                       IXGBE_ETQS_QUEUE_EN |
+                       (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
 
        IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL,
                        IXGBE_FCRXCTRL_FCOELLI |
@@ -614,9 +632,9 @@ int ixgbe_fcoe_enable(struct net_device *netdev)
        netdev->vlan_features |= NETIF_F_FSO;
        netdev->vlan_features |= NETIF_F_FCOE_MTU;
        netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1;
-       netdev_features_change(netdev);
 
        ixgbe_init_interrupt_scheme(adapter);
+       netdev_features_change(netdev);
 
        if (netif_running(netdev))
                netdev->netdev_ops->ndo_open(netdev);
@@ -660,11 +678,11 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
        netdev->vlan_features &= ~NETIF_F_FSO;
        netdev->vlan_features &= ~NETIF_F_FCOE_MTU;
        netdev->fcoe_ddp_xid = 0;
-       netdev_features_change(netdev);
 
        ixgbe_cleanup_fcoe(adapter);
-
        ixgbe_init_interrupt_scheme(adapter);
+       netdev_features_change(netdev);
+
        if (netif_running(netdev))
                netdev->netdev_ops->ndo_open(netdev);
        rc = 0;
index 684af371462dc32975f955ef0e96ac8063c09b02..8f677cb8629053f2ce8f89501facf81218988d73 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/tcp.h>
 #include <linux/pkt_sched.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <linux/ethtool.h>
@@ -935,10 +936,12 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
                        if (skb->prev)
                                skb = ixgbe_transform_rsc_queue(skb, &(rx_ring->rsc_count));
                        if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
-                               if (IXGBE_RSC_CB(skb)->dma)
+                               if (IXGBE_RSC_CB(skb)->dma) {
                                        pci_unmap_single(pdev, IXGBE_RSC_CB(skb)->dma,
                                                         rx_ring->rx_buf_len,
                                                         PCI_DMA_FROMDEVICE);
+                                       IXGBE_RSC_CB(skb)->dma = 0;
+                               }
                                if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED)
                                        rx_ring->rsc_count += skb_shinfo(skb)->nr_frags;
                                else
@@ -3054,6 +3057,14 @@ void ixgbe_reinit_locked(struct ixgbe_adapter *adapter)
        while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
                msleep(1);
        ixgbe_down(adapter);
+       /*
+        * If SR-IOV enabled then wait a bit before bringing the adapter
+        * back up to give the VFs time to respond to the reset.  The
+        * two second wait is based upon the watchdog timer cycle in
+        * the VF driver.
+        */
+       if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
+               msleep(2000);
        ixgbe_up(adapter);
        clear_bit(__IXGBE_RESETTING, &adapter->state);
 }
@@ -3126,10 +3137,12 @@ static void ixgbe_clean_rx_ring(struct ixgbe_adapter *adapter,
                        rx_buffer_info->skb = NULL;
                        do {
                                struct sk_buff *this = skb;
-                               if (IXGBE_RSC_CB(this)->dma)
+                               if (IXGBE_RSC_CB(this)->dma) {
                                        pci_unmap_single(pdev, IXGBE_RSC_CB(this)->dma,
                                                         rx_ring->rx_buf_len,
                                                         PCI_DMA_FROMDEVICE);
+                                       IXGBE_RSC_CB(this)->dma = 0;
+                               }
                                skb = skb->prev;
                                dev_kfree_skb(this);
                        } while (skb);
@@ -3232,13 +3245,15 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
 
        /* disable receive for all VFs and wait one second */
        if (adapter->num_vfs) {
-               for (i = 0 ; i < adapter->num_vfs; i++)
-                       adapter->vfinfo[i].clear_to_send = 0;
-
                /* ping all the active vfs to let them know we are going down */
                ixgbe_ping_all_vfs(adapter);
+
                /* Disable all VFTE/VFRE TX/RX */
                ixgbe_disable_tx_rx(adapter);
+
+               /* Mark all the VFs as inactive */
+               for (i = 0 ; i < adapter->num_vfs; i++)
+                       adapter->vfinfo[i].clear_to_send = 0;
        }
 
        /* disable receives */
@@ -5018,6 +5033,7 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work)
        autoneg = hw->phy.autoneg_advertised;
        if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
                hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
+       hw->mac.autotry_restart = false;
        if (hw->mac.ops.setup_link)
                hw->mac.ops.setup_link(hw, autoneg, negotiation, true);
        adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -5633,7 +5649,8 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
 
 #ifdef IXGBE_FCOE
        if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
-           (skb->protocol == htons(ETH_P_FCOE))) {
+           ((skb->protocol == htons(ETH_P_FCOE)) ||
+            (skb->protocol == htons(ETH_P_FIP)))) {
                txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
                txq += adapter->ring_feature[RING_F_FCOE].mask;
                return txq;
@@ -5680,18 +5697,25 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
 
        tx_ring = adapter->tx_ring[skb->queue_mapping];
 
-       if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
-           (skb->protocol == htons(ETH_P_FCOE))) {
-               tx_flags |= IXGBE_TX_FLAGS_FCOE;
 #ifdef IXGBE_FCOE
+       if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
 #ifdef CONFIG_IXGBE_DCB
-               tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
-                             << IXGBE_TX_FLAGS_VLAN_SHIFT);
-               tx_flags |= ((adapter->fcoe.up << 13)
-                             << IXGBE_TX_FLAGS_VLAN_SHIFT);
-#endif
+               /* for FCoE with DCB, we force the priority to what
+                * was specified by the switch */
+               if ((skb->protocol == htons(ETH_P_FCOE)) ||
+                   (skb->protocol == htons(ETH_P_FIP))) {
+                       tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
+                                     << IXGBE_TX_FLAGS_VLAN_SHIFT);
+                       tx_flags |= ((adapter->fcoe.up << 13)
+                                    << IXGBE_TX_FLAGS_VLAN_SHIFT);
+               }
 #endif
+               /* flag for FCoE offloads */
+               if (skb->protocol == htons(ETH_P_FCOE))
+                       tx_flags |= IXGBE_TX_FLAGS_FCOE;
        }
+#endif
+
        /* four things can cause us to need a context descriptor */
        if (skb_is_gso(skb) ||
            (skb->ip_summed == CHECKSUM_PARTIAL) ||
@@ -6046,7 +6070,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        indices += min_t(unsigned int, num_possible_cpus(),
                         IXGBE_MAX_FCOE_INDICES);
 #endif
-       indices = min_t(unsigned int, indices, MAX_TX_QUEUES);
        netdev = alloc_etherdev_mq(sizeof(struct ixgbe_adapter), indices);
        if (!netdev) {
                err = -ENOMEM;
@@ -6245,9 +6268,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
        case IXGBE_DEV_ID_82599_KX4:
                adapter->wol = (IXGBE_WUFC_MAG | IXGBE_WUFC_EX |
                                IXGBE_WUFC_MC | IXGBE_WUFC_BC);
-               /* Enable ACPI wakeup in GRC */
-               IXGBE_WRITE_REG(hw, IXGBE_GRC,
-                            (IXGBE_READ_REG(hw, IXGBE_GRC) & ~IXGBE_GRC_APME));
                break;
        default:
                adapter->wol = 0;
@@ -6380,6 +6400,16 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
        del_timer_sync(&adapter->sfp_timer);
        cancel_work_sync(&adapter->watchdog_task);
        cancel_work_sync(&adapter->sfp_task);
+       if (adapter->hw.phy.multispeed_fiber) {
+               struct ixgbe_hw *hw = &adapter->hw;
+               /*
+                * Restart clause 37 autoneg, disable and re-enable
+                * the tx laser, to clear & alert the link partner
+                * that it needs to restart autotry
+                */
+               hw->mac.autotry_restart = true;
+               hw->mac.ops.flap_tx_laser(hw);
+       }
        cancel_work_sync(&adapter->multispeed_fiber_task);
        cancel_work_sync(&adapter->sfp_config_module_task);
        if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE ||
index 2be907466593a6e1c119403981226a6155be869c..4ec6dc1a5b75c06a800d3bc7d61f8c2e6cab7853 100644 (file)
 #define IXGBE_ETQF_FILTER_BCN            1
 #define IXGBE_ETQF_FILTER_FCOE           2
 #define IXGBE_ETQF_FILTER_1588           3
+#define IXGBE_ETQF_FILTER_FIP            4
 /* VLAN Control Bit Masks */
 #define IXGBE_VLNCTRL_VET       0x0000FFFF  /* bits 0-15 */
 #define IXGBE_VLNCTRL_CFI       0x10000000  /* bit 28 */
@@ -2397,6 +2398,7 @@ struct ixgbe_mac_operations {
        s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
 
        /* Link */
+       void (*flap_tx_laser)(struct ixgbe_hw *);
        s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
        s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
        s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
index 399be0c34c36d8593cc8c513745be26d0448775d..4680b069b84fe5d953841ecdf98717088ce21bb1 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/types.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
@@ -46,22 +47,32 @@ struct ixgbe_stats {
        int sizeof_stat;
        int stat_offset;
        int base_stat_offset;
+       int saved_reset_offset;
 };
 
-#define IXGBEVF_STAT(m, b)  sizeof(((struct ixgbevf_adapter *)0)->m), \
-                           offsetof(struct ixgbevf_adapter, m),      \
-                           offsetof(struct ixgbevf_adapter, b)
+#define IXGBEVF_STAT(m, b, r)  sizeof(((struct ixgbevf_adapter *)0)->m), \
+                           offsetof(struct ixgbevf_adapter, m),         \
+                           offsetof(struct ixgbevf_adapter, b),         \
+                           offsetof(struct ixgbevf_adapter, r)
 static struct ixgbe_stats ixgbe_gstrings_stats[] = {
-       {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc)},
-       {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc)},
-       {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc)},
-       {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc)},
-       {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base)},
-       {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc)},
-       {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base)},
-       {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base)},
-       {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base)},
-       {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base)},
+       {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
+                                   stats.saved_reset_vfgprc)},
+       {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc,
+                                   stats.saved_reset_vfgptc)},
+       {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc,
+                                 stats.saved_reset_vfgorc)},
+       {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc,
+                                 stats.saved_reset_vfgotc)},
+       {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base, zero_base)},
+       {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc,
+                                  stats.saved_reset_vfmprc)},
+       {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base,
+                                             zero_base)},
+       {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base,
+                                               zero_base)},
+       {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base,
+                                             zero_base)},
+       {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base, zero_base)},
 };
 
 #define IXGBE_QUEUE_STATS_LEN 0
@@ -455,10 +466,14 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
                        ixgbe_gstrings_stats[i].stat_offset;
                char *b = (char *)adapter +
                        ixgbe_gstrings_stats[i].base_stat_offset;
+               char *r = (char *)adapter +
+                       ixgbe_gstrings_stats[i].saved_reset_offset;
                data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat ==
                            sizeof(u64)) ? *(u64 *)p : *(u32 *)p) -
                          ((ixgbe_gstrings_stats[i].sizeof_stat ==
-                           sizeof(u64)) ? *(u64 *)b : *(u32 *)b);
+                           sizeof(u64)) ? *(u64 *)b : *(u32 *)b) +
+                         ((ixgbe_gstrings_stats[i].sizeof_stat ==
+                           sizeof(u64)) ? *(u64 *)r : *(u32 *)r);
        }
 }
 
index ca653c49b765ecd44d9b45616bcf91c7e6372d48..0cd6202dfaccfc541c0aee86471997e5189f2cf5 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <linux/ethtool.h>
@@ -965,7 +966,7 @@ static irqreturn_t ixgbevf_msix_mbx(int irq, void *data)
 
        if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG)
                mod_timer(&adapter->watchdog_timer,
-                         round_jiffies(jiffies + 10));
+                         round_jiffies(jiffies + 1));
 
        return IRQ_HANDLED;
 }
@@ -1610,6 +1611,44 @@ static inline void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
                                (adapter->rx_ring[rxr].count - 1));
 }
 
+static void ixgbevf_save_reset_stats(struct ixgbevf_adapter *adapter)
+{
+       /* Only save pre-reset stats if there are some */
+       if (adapter->stats.vfgprc || adapter->stats.vfgptc) {
+               adapter->stats.saved_reset_vfgprc += adapter->stats.vfgprc -
+                       adapter->stats.base_vfgprc;
+               adapter->stats.saved_reset_vfgptc += adapter->stats.vfgptc -
+                       adapter->stats.base_vfgptc;
+               adapter->stats.saved_reset_vfgorc += adapter->stats.vfgorc -
+                       adapter->stats.base_vfgorc;
+               adapter->stats.saved_reset_vfgotc += adapter->stats.vfgotc -
+                       adapter->stats.base_vfgotc;
+               adapter->stats.saved_reset_vfmprc += adapter->stats.vfmprc -
+                       adapter->stats.base_vfmprc;
+       }
+}
+
+static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+
+       adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
+       adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
+       adapter->stats.last_vfgorc |=
+               (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
+       adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
+       adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
+       adapter->stats.last_vfgotc |=
+               (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
+       adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
+
+       adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
+       adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
+       adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
+       adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
+       adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
+}
+
 static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
@@ -1656,6 +1695,9 @@ static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
        /* enable transmits */
        netif_tx_start_all_queues(netdev);
 
+       ixgbevf_save_reset_stats(adapter);
+       ixgbevf_init_last_counter_stats(adapter);
+
        /* bring the link up in the watchdog, this could race with our first
         * link up interrupt but shouldn't be a problem */
        adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -2228,27 +2270,6 @@ out:
        return err;
 }
 
-static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
-{
-       struct ixgbe_hw *hw = &adapter->hw;
-
-       adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
-       adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
-       adapter->stats.last_vfgorc |=
-               (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
-       adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
-       adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
-       adapter->stats.last_vfgotc |=
-               (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
-       adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
-
-       adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
-       adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
-       adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
-       adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
-       adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
-}
-
 #define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter)    \
        {                                                       \
                u32 current_counter = IXGBE_READ_REG(hw, reg);  \
@@ -2399,7 +2420,7 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
                if (!netif_carrier_ok(netdev)) {
                        hw_dbg(&adapter->hw, "NIC Link is Up %s, ",
                               ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) ?
-                               "10 Gbps" : "1 Gbps"));
+                               "10 Gbps\n" : "1 Gbps\n"));
                        netif_carrier_on(netdev);
                        netif_tx_wake_all_queues(netdev);
                } else {
@@ -2416,9 +2437,9 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
                }
        }
 
-pf_has_reset:
        ixgbevf_update_stats(adapter);
 
+pf_has_reset:
        /* Force detection of hung controller every watchdog period */
        adapter->detect_tx_hung = true;
 
@@ -2675,7 +2696,7 @@ static int ixgbevf_open(struct net_device *netdev)
                if (hw->adapter_stopped) {
                        err = IXGBE_ERR_MBX;
                        printk(KERN_ERR "Unable to start - perhaps the PF"
-                              "Driver isn't up yet\n");
+                              " Driver isn't up yet\n");
                        goto err_setup_reset;
                }
        }
@@ -2923,9 +2944,10 @@ static int ixgbevf_tx_map(struct ixgbevf_adapter *adapter,
        struct ixgbevf_tx_buffer *tx_buffer_info;
        unsigned int len;
        unsigned int total = skb->len;
-       unsigned int offset = 0, size, count = 0, i;
+       unsigned int offset = 0, size, count = 0;
        unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
        unsigned int f;
+       int i;
 
        i = tx_ring->next_to_use;
 
@@ -3390,8 +3412,6 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
        /* setup the private structure */
        err = ixgbevf_sw_init(adapter);
 
-       ixgbevf_init_last_counter_stats(adapter);
-
 #ifdef MAX_SKB_FRAGS
        netdev->features = NETIF_F_SG |
                           NETIF_F_IP_CSUM |
@@ -3449,6 +3469,8 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
 
        adapter->netdev_registered = true;
 
+       ixgbevf_init_last_counter_stats(adapter);
+
        /* print the MAC address */
        hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
               netdev->dev_addr[0],
index 799600e927002863c7003b6529ba3c0c758241b9..1f31b052d4b4b788a7e670199b6c16503cfc5b08 100644 (file)
@@ -157,6 +157,12 @@ struct ixgbevf_hw_stats {
        u64 vfgorc;
        u64 vfgotc;
        u64 vfmprc;
+
+       u64 saved_reset_vfgprc;
+       u64 saved_reset_vfgptc;
+       u64 saved_reset_vfgorc;
+       u64 saved_reset_vfgotc;
+       u64 saved_reset_vfmprc;
 };
 
 struct ixgbevf_info {
index e9d9d595e1b705635d12aefee9655030b5b88512..d5932ca3e27db3700c84f19e9518edf447f71250 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/moduleparam.h>
+#include <linux/gfp.h>
 #include <asm/hardware/uengine.h>
 #include <asm/io.h>
 #include "ixp2400_rx.ucode"
index f47d4d663b1901db46568d430c6806e4c32cb481..3e6aaf9e5ce7c4060b1bc042cf4d46608549297a 100644 (file)
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
+#include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -35,6 +35,7 @@
 #include <linux/skbuff.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/bootinfo.h>
 #include <asm/system.h>
index 0f31497833df518795f34fadeb4f1f5af85772c6..b705ad3a53a785a0f64c5f83f831177b192b8c6a 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 #include <net/ip6_checksum.h>
 #include "jme.h"
 
@@ -946,6 +947,8 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
                                jme->jme_vlan_rx(skb, jme->vlgrp,
                                        le16_to_cpu(rxdesc->descwb.vlan));
                                NET_STAT(jme).rx_bytes += 4;
+                       } else {
+                               dev_kfree_skb(skb);
                        }
                } else {
                        jme->jme_rx(skb);
@@ -2081,12 +2084,45 @@ jme_tx_timeout(struct net_device *netdev)
        jme_reset_link(jme);
 }
 
+static inline void jme_pause_rx(struct jme_adapter *jme)
+{
+       atomic_dec(&jme->link_changing);
+
+       jme_set_rx_pcc(jme, PCC_OFF);
+       if (test_bit(JME_FLAG_POLL, &jme->flags)) {
+               JME_NAPI_DISABLE(jme);
+       } else {
+               tasklet_disable(&jme->rxclean_task);
+               tasklet_disable(&jme->rxempty_task);
+       }
+}
+
+static inline void jme_resume_rx(struct jme_adapter *jme)
+{
+       struct dynpcc_info *dpi = &(jme->dpi);
+
+       if (test_bit(JME_FLAG_POLL, &jme->flags)) {
+               JME_NAPI_ENABLE(jme);
+       } else {
+               tasklet_hi_enable(&jme->rxclean_task);
+               tasklet_hi_enable(&jme->rxempty_task);
+       }
+       dpi->cur                = PCC_P1;
+       dpi->attempt            = PCC_P1;
+       dpi->cnt                = 0;
+       jme_set_rx_pcc(jme, PCC_P1);
+
+       atomic_inc(&jme->link_changing);
+}
+
 static void
 jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
 {
        struct jme_adapter *jme = netdev_priv(netdev);
 
+       jme_pause_rx(jme);
        jme->vlgrp = grp;
+       jme_resume_rx(jme);
 }
 
 static void
index c19db9146a2f38ef44d4a776d0df9f5b39a26e8d..07ad3a457185c3f440c65e9d2a04cb6de1214aa3 100644 (file)
@@ -25,7 +25,7 @@
 #define __JME_H_INCLUDED__
 
 #define DRV_NAME       "jme"
-#define DRV_VERSION    "1.0.5"
+#define DRV_VERSION    "1.0.6"
 #define PFX            DRV_NAME ": "
 
 #define PCI_DEVICE_ID_JMICRON_JMC250   0x0250
index 0573e0bb4444162e5153043532023b82b7a16bb0..13cc1ca261d9cf57905adea50e6c179ea925c6f0 100644 (file)
@@ -976,7 +976,6 @@ static void ks8851_set_rx_mode(struct net_device *dev)
                        crc >>= (32 - 6);  /* get top six bits */
 
                        rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf));
-                       mcptr = mcptr->next;
                }
 
                rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA;
index 84b0e15831f943d0bf46327cb44b7c6be42b49c1..6354ab3a45a651beb59e5b47d97c7d909357a7a9 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/mii.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #define        DRV_NAME        "ks8851_mll"
 
index 0f59099ee72f8d504d314ef41af592d377f58795..0606a1f359fb8a2c2d1ca47fe6907565ce3e489c 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/if_vlan.h>
 #include <linux/crc32.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 
 /* DMA Registers */
@@ -6322,7 +6323,7 @@ static int netdev_set_eeprom(struct net_device *dev,
        int len;
 
        if (eeprom->magic != EEPROM_MAGIC)
-               return 1;
+               return -EINVAL;
 
        len = (eeprom->offset + eeprom->len + 1) / 2;
        for (i = eeprom->offset / 2; i < len; i++)
index b77238dbafb85182dc154e8faaf51857cc493b62..6eba352c52e0809127d7e02ffea24e413ca82a47 100644 (file)
@@ -74,7 +74,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
index 443c39a3732f30ea494175793b80566423099bd5..973390b82ec28850cf17f1ab26c18e7538f656a9 100644 (file)
@@ -73,7 +73,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
@@ -85,6 +84,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/gfp.h>
 
 /* DEBUG flags
  */
index a18e3485476e51fa96ce9c1af9994026538bf0e7..ba617e3cf1bbd6c9442419e8fd591bcc582eaab2 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/in.h>
 #include <linux/io.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 
 #include "ll_temac.h"
 
index da0e462308d51a82c367aa73628f4c26c4bc7d84..5ae28c975b384bf64ff7a7dc763a3d1766669b5a 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/phy.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/slab.h>
 #include <linux/of_mdio.h>
 
 #include "ll_temac.h"
index a8768672dc5aece9741081e3cde63835b5d80c01..c8e68fde0664862dd0af4da936f4f0d1ae87f32e 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/ioport.h>
 #include <linux/nubus.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index c292a608f9a9c1d04bd1dabd8f439f22a60b6b73..c0876e915eed7afe6adf84df917bf426a497707b 100644 (file)
@@ -88,7 +88,6 @@ static char *version =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/nubus.h>
 #include <linux/errno.h>
@@ -98,6 +97,7 @@ static char *version =
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index ab5f0bf6d1ae8531d7042ad6c0edc7a8a3a0fe0b..962c41d0c8dfb07d7837ee79d3c836fdf2cd90fb 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/crc32.h>
 #include <linux/spinlock.h>
 #include <linux/bitrev.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/dbdma.h>
 #include <asm/io.h>
index 13ba8f4afb7e6712f34bca4203e1f5e36b058373..52e9a51c4c4fcf0788d2b33f74f033284779271a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/bitrev.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/macintosh.h>
index 24109c288108109575fdba9d7e0b8cff3c917d9c..adb54fe2d82a3e024880c64657ffb88253a40d2b 100644 (file)
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
+#include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/nubus.h>
@@ -50,6 +50,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/bitrev.h>
+#include <linux/slab.h>
 
 #include <asm/bootinfo.h>
 #include <asm/system.h>
index 55ceae09738e91c68e44046b7c21646e7fa27528..abba3cc81f129d99116f6e8dccafa29a0ad5dc75 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/cache.h>
 #include <linux/sched.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/wait.h>
 #include <linux/cdev.h>
index 65ec77dc31f5b5c4a542a22a2f7d11c464a9d664..23cee7b6af918c146f2f447291bf180a6af4bb58 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/errno.h>
 
index ccfe276943f09f7e036899d90a09ea6220ab77cf..7cd34e9c7c7efdf42af40cce389c20b3cbf09e94 100644 (file)
@@ -35,6 +35,7 @@
  */
 
 #include <linux/hardirq.h>
+#include <linux/gfp.h>
 
 #include <linux/mlx4/cmd.h>
 #include <linux/mlx4/cq.h>
index 507e11fce9ed7f202e9d6aa59e3135326d6aa94d..cbabf14f95d027aa57be9cf77126cd30bae4b0d2 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include <linux/mlx4/driver.h>
 #include <linux/mlx4/device.h>
index c48b0f4b17b7c395bcecf527413035aa82166657..73c3d20c64534248768d29385b5cb6799b2fc8ba 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/tcp.h>
 #include <linux/if_vlan.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <linux/mlx4/driver.h>
 #include <linux/mlx4/device.h>
index 16256784a943bf13b0ebe8fd5184eaa8fea83033..0dfb4ec8a9dd09295de01eb422b68511ab891c5e 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/mlx4/qp.h>
 
index 64394647dddc2a1a64a9ab15ba149ee347f0cd81..8e2fcb7103c3a12a3072549881a7529d3062bc85 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/mlx4/cq.h>
+#include <linux/slab.h>
 #include <linux/mlx4/qp.h>
 #include <linux/skbuff.h>
 #include <linux/if_ether.h>
index 3d1396af9462795f123c4602e7ff01f6d3022549..580968f304eb9d24f752e38fc368e64208700510 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <asm/page.h>
 #include <linux/mlx4/cq.h>
+#include <linux/slab.h>
 #include <linux/mlx4/qp.h>
 #include <linux/skbuff.h>
 #include <linux/if_vlan.h>
index bffb7995cb70a4f6a9b09bdcc137cd317e3a641e..7365bf488b81a6a1572971da726b7f9662f042e6 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
 
index 04b382fcb8c881c2ab76fea05636deb63c64effd..57288ca1395f1e6b0974655396afb5341566b37a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/errno.h>
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include <linux/mlx4/cmd.h>
 
index 0e7eb1038f9f443e8b0af3525a5fd9b871c608d7..5550678027513fa6f7b443bffe63e72198f4ec1c 100644 (file)
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "mlx4.h"
 
 struct mlx4_device_context {
index 8f6e816a7395f78dadfa12c7a64269ce820d0b7d..e3e0d54a7c87851ca15df3f640326de174dc9a42 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/errno.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <linux/mlx4/device.h>
 #include <linux/mlx4/doorbell.h>
@@ -1023,6 +1024,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
        info->port_attr.attr.mode = S_IRUGO | S_IWUSR;
        info->port_attr.show      = show_port_type;
        info->port_attr.store     = set_port_type;
+       sysfs_attr_init(&info->port_attr.attr);
 
        err = device_create_file(&dev->pdev->dev, &info->port_attr);
        if (err) {
index 5ccbce9866fe0b70918f362fba4b9a6e4bef8da3..c4f88b7ef7b6dbc33a4d6d08bb2bca1b9a010ff3 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <linux/string.h>
-#include <linux/slab.h>
 
 #include <linux/mlx4/cmd.h>
 
index ca7ab8e7b4cc3917cc94599315f6d16f8e930150..3dc69be4949f2b175418273a2905c866dad4acd0 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include <linux/mlx4/cmd.h>
 
index ca25b9dc837853e979650a3c5fc8b01f6a71e961..5caf0115fa5b4e923e3d10d760c6c1284a21c694 100644 (file)
@@ -32,6 +32,8 @@
  * SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "mlx4.h"
 #include "fw.h"
 
index 42ab9fc01d3e1f04e40623f194903fbecc11568e..ec9350e5f21ab7072dc00a062b28cb9781af2d7b 100644 (file)
@@ -33,6 +33,7 @@
  * SOFTWARE.
  */
 
+#include <linux/gfp.h>
 #include <linux/mlx4/cmd.h>
 #include <linux/mlx4/qp.h>
 
index 1377d0dc8f1f41d7de9f35d9a97bf49c0e0c433b..3b07b80a0456baec10d02146c1a71aa1feed872e 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/mlx4/cmd.h>
+#include <linux/gfp.h>
 
 #include "mlx4.h"
 #include "icm.h"
index c97b6e4365a96c1af84515f0d1f95864e0ccec79..8613a52ddf171b59a78ca652203cef2a8ccb409d 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/io.h>
 #include <linux/types.h>
 #include <linux/inet_lro.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 
 static char mv643xx_eth_driver_name[] = "mv643xx_eth";
index 93c709d63e2f5abc9f91d2cefacf2651057e7708..3a7ad840d5b5b36c54f676bd97b66d60417f4e1d 100644 (file)
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 /* Used for the temporal inet entries and routing */
 #include <linux/socket.h>
 #include <linux/route.h>
index e84dd3ee9c5aa72fa227b4afca14c4a59dd76c40..471887742b02ccc56fc039cdaab7b1aad0b344aa 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/moduleparam.h>
 #include <linux/io.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/ip.h>
 #include <net/tcp.h>
index 8b4313085359ce703f2f4bd6c91c815c43a2c030..b72e749afdf102d5bb690be5e29617044a927a75 100644 (file)
@@ -14,7 +14,6 @@ static char version[] =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -26,6 +25,7 @@ static char version[] =
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/firmware.h>
+#include <linux/gfp.h>
 
 #include <net/dst.h>
 #include <net/arp.h>
index a53bb201d3c7612f92ba6015fbfd4ae15726ae32..ff3c4c81498847c825869ff009ac8d74ab2243d2 100644 (file)
@@ -66,7 +66,6 @@ static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.o
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index bf4af5248cb75549a46415f21ab7685c948e1b42..a361dea35574db454a82d25ddcc9050f057c4a90 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/console.h>
 #include <linux/moduleparam.h>
 #include <linux/string.h>
index 144d2e8804225a16e20f3799eface6c1f8a6f165..0f703838e21ad73b5ad775e35b9984146d60cf5f 100644 (file)
@@ -53,8 +53,8 @@
 
 #define _NETXEN_NIC_LINUX_MAJOR 4
 #define _NETXEN_NIC_LINUX_MINOR 0
-#define _NETXEN_NIC_LINUX_SUBVERSION 72
-#define NETXEN_NIC_LINUX_VERSIONID  "4.0.72"
+#define _NETXEN_NIC_LINUX_SUBVERSION 73
+#define NETXEN_NIC_LINUX_VERSIONID  "4.0.73"
 
 #define NETXEN_VERSION_CODE(a, b, c)   (((a) << 24) + ((b) << 16) + (c))
 #define _major(v)      (((v) >> 24) & 0xff)
index 2a8ef5fc9663b094bcfdfb5fc24c2f4adbff31be..f26e54716c886569f9e30d9a8a5c34d6056b58e6 100644 (file)
@@ -669,13 +669,15 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
                }
                sds_ring->desc_head = (struct status_desc *)addr;
 
-               sds_ring->crb_sts_consumer =
-                       netxen_get_ioaddr(adapter,
-                       recv_crb_registers[port].crb_sts_consumer[ring]);
+               if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
+                       sds_ring->crb_sts_consumer =
+                               netxen_get_ioaddr(adapter,
+                               recv_crb_registers[port].crb_sts_consumer[ring]);
 
-               sds_ring->crb_intr_mask =
-                       netxen_get_ioaddr(adapter,
-                       recv_crb_registers[port].sw_int_mask[ring]);
+                       sds_ring->crb_intr_mask =
+                               netxen_get_ioaddr(adapter,
+                               recv_crb_registers[port].sw_int_mask[ring]);
+               }
        }
 
 
index a945591298a8519b314144bd86e8c751bf8cc272..b1cf46a0c48c887c7c0903b2a6343fbcd2ba9135 100644 (file)
@@ -23,6 +23,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include "netxen_nic.h"
 #include "netxen_nic_hw.h"
 
index 1c63610ead422a29b4628e525b7c1be37de300dd..02876f59cbb21bbcf7f4660868e4f47a8f778f44 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "netxen_nic.h"
 #include "netxen_nic_hw.h"
 
@@ -761,7 +762,7 @@ nx_get_bios_version(struct netxen_adapter *adapter)
        if (adapter->fw_type == NX_UNIFIED_ROMIMAGE) {
                bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off])
                                                + NX_UNI_BIOS_VERSION_OFF));
-               return (bios_ver << 24) + ((bios_ver >> 8) & 0xff00) +
+               return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) +
                                                        (bios_ver >> 24);
        } else
                return cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]);
index 08780ef1c1f885d56b38d9c4ff68b4f790711f58..ce838f7c8b0f3e1cd33702fc72cf5f2a82b6c3ae 100644 (file)
@@ -23,6 +23,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 #include "netxen_nic_hw.h"
@@ -604,16 +605,14 @@ netxen_cleanup_pci_map(struct netxen_adapter *adapter)
 static int
 netxen_setup_pci_map(struct netxen_adapter *adapter)
 {
-       void __iomem *mem_ptr0 = NULL;
-       void __iomem *mem_ptr1 = NULL;
-       void __iomem *mem_ptr2 = NULL;
        void __iomem *db_ptr = NULL;
 
        resource_size_t mem_base, db_base;
-       unsigned long mem_len, db_len = 0, pci_len0 = 0;
+       unsigned long mem_len, db_len = 0;
 
        struct pci_dev *pdev = adapter->pdev;
        int pci_func = adapter->ahw.pci_func;
+       struct netxen_hardware_context *ahw = &adapter->ahw;
 
        int err = 0;
 
@@ -630,24 +629,40 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
 
        /* 128 Meg of memory */
        if (mem_len == NETXEN_PCI_128MB_SIZE) {
-               mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
-               mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
+
+               ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
+               ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
                                SECOND_PAGE_GROUP_SIZE);
-               mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
+               ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
                                THIRD_PAGE_GROUP_SIZE);
-               pci_len0 = FIRST_PAGE_GROUP_SIZE;
+               if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL ||
+                                               ahw->pci_base2 == NULL) {
+                       dev_err(&pdev->dev, "failed to map PCI bar 0\n");
+                       err = -EIO;
+                       goto err_out;
+               }
+
+               ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE;
+
        } else if (mem_len == NETXEN_PCI_32MB_SIZE) {
-               mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
-               mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
+
+               ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
+               ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
                        SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
+               if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) {
+                       dev_err(&pdev->dev, "failed to map PCI bar 0\n");
+                       err = -EIO;
+                       goto err_out;
+               }
+
        } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
 
-               mem_ptr0 = pci_ioremap_bar(pdev, 0);
-               if (mem_ptr0 == NULL) {
+               ahw->pci_base0 = pci_ioremap_bar(pdev, 0);
+               if (ahw->pci_base0 == NULL) {
                        dev_err(&pdev->dev, "failed to map PCI bar 0\n");
                        return -EIO;
                }
-               pci_len0 = mem_len;
+               ahw->pci_len0 = mem_len;
        } else {
                return -EIO;
        }
@@ -656,11 +671,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
 
        dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
 
-       adapter->ahw.pci_base0 = mem_ptr0;
-       adapter->ahw.pci_len0 = pci_len0;
-       adapter->ahw.pci_base1 = mem_ptr1;
-       adapter->ahw.pci_base2 = mem_ptr2;
-
        if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) {
                adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter,
                        NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func)));
@@ -1246,8 +1256,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        int pci_func_id = PCI_FUNC(pdev->devfn);
        uint8_t revision_id;
 
-       if (pdev->revision >= NX_P3_A0 && pdev->revision < NX_P3_B1) {
-               pr_warning("%s: chip revisions between 0x%x-0x%x"
+       if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) {
+               pr_warning("%s: chip revisions between 0x%x-0x%x "
                                "will not be enabled.\n",
                                module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1);
                return -ENODEV;
index c16cbfb4061b716beb8c24fcc594140e9d47eaba..3892330f244a0e65b6a96bf3be8e2b72236f6e79 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index 05c29c2cef2a62327e3932796b1026961914d528..f7a8f707361e8bbf60bc9071f40e3bb715a7ee5e 100644 (file)
@@ -109,7 +109,6 @@ static int fifo = 0x8;      /* don't change */
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index 0678f3106cbcca5981cd1aa50df08919e04968e2..d5cd16bfc907b32a3e287258c9cf41761cd5de1d 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/jiffies.h>
 #include <linux/crc32.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include <linux/io.h>
 
index 8dd509c09bc8cd19cff96535e9ea0d0ab13f4bc0..e88e97cd1b10805803fb876c73af9c06848cb47f 100644 (file)
 #include <linux/if_vlan.h>
 #include <linux/rtnetlink.h>
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
index be368e5cbf7589a1897a6b8bd88f752767d928b2..8aadc8e2ddd7e062bde2c2a0757019bcfd746ae6 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 #include <linux/phy.h>
 #include <linux/spinlock.h>
 
index d44d4a208bbf144ceecd4f7ba6dab36d16e6eb38..370c147d08a3d6d1759a55ad8db01a95ad28e71f 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
index 09291e60d309a38cf5563e06ddcdbfdfc11b5504..9f3d593f14edba92882e3283fcadcfccfa371f64 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
index 776cad2f57150d1ecf209ec7063a0ed393bc3fec..4c0368de18158e29161e965cbdf33875d762d3e5 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
@@ -1549,6 +1548,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
        PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x021b, 0x0101),
        PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x08a1, 0xc0ab),
        PCMCIA_PFC_DEVICE_PROD_ID12(0, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
+       PCMCIA_PFC_DEVICE_PROD_ID12(0, "ATKK", "LM33-PCM-T", 0xba9eb7e2, 0x077c174e),
        PCMCIA_PFC_DEVICE_PROD_ID12(0, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
        PCMCIA_PFC_DEVICE_PROD_ID12(0, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
        PCMCIA_PFC_DEVICE_PROD_ID12(0, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033),
@@ -1740,7 +1740,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
        PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"),
        PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"),
        PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"),
-       PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "cis/LA-PCM.cis"),
+       PCMCIA_DEVICE_CIS_PROD_ID12("Allied Telesis,K.K", "Ethernet LAN Card", 0x2ad62f3c, 0x9fd2f0a2, "cis/LA-PCM.cis"),
        PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "cis/PE520.cis"),
        PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "cis/NE2K.cis"),
        PCMCIA_DEVICE_CIS_PROD_ID12("PMX   ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "cis/PE-200.cis"),
index 5adc662c4bfbd3b15d42ab80c47f1d9b5b633506..ff7eb9116b6a94eb4cc86b93382dec84c40ba04e 100644 (file)
@@ -493,13 +493,14 @@ static int pcmcia_get_versmac(struct pcmcia_device *p_dev,
 {
        struct net_device *dev = priv;
        cisparse_t parse;
+       u8 *buf;
 
        if (pcmcia_parse_tuple(tuple, &parse))
                return -EINVAL;
 
-       if ((parse.version_1.ns > 3) &&
-           (cvt_ascii_address(dev,
-                              (parse.version_1.str + parse.version_1.ofs[3]))))
+       buf = parse.version_1.str + parse.version_1.ofs[3];
+
+       if ((parse.version_1.ns > 3) && (cvt_ascii_address(dev, buf) == 0))
                return 0;
 
        return -EINVAL;
@@ -528,7 +529,7 @@ static int mhz_setup(struct pcmcia_device *link)
     len = pcmcia_get_tuple(link, 0x81, &buf);
     if (buf && len >= 13) {
            buf[12] = '\0';
-           if (cvt_ascii_address(dev, buf))
+           if (cvt_ascii_address(dev, buf) == 0)
                    rc = 0;
     }
     kfree(buf);
@@ -910,7 +911,7 @@ static int smc91c92_config(struct pcmcia_device *link)
 
     if (i != 0) {
        printk(KERN_NOTICE "smc91c92_cs: Unable to find hardware address.\n");
-       goto config_undo;
+       goto config_failed;
     }
 
     smc->duplex = 0;
@@ -998,6 +999,7 @@ config_undo:
     unregister_netdev(dev);
 config_failed:
     smc91c92_release(link);
+    free_netdev(dev);
     return -ENODEV;
 } /* smc91c92_config */
 
index a1bd599c8a5b5014c1465cd4e7f56be3701567a5..92282b31d94bf64d5c53617f385140b305ad14f9 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index d926168bc7809c62e46d32d5d9fe98e493ad6e7e..c722e95853ff5d9d775191504f9d7e918680cc83 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index b031fa21f1aa0a6f4640e9a61099210ab0a88306..7712ebeba9bf0a6881f3cb6a03c2124579546046 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index e7070515d2e360d68f25c76f0795f0f1943ab323..1fa4d73c3cca5e0d6ff4579abd986a910ab67305 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/phy.h>
 #include <linux/phy_fixed.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #define MII_REGS_NUM 29
 
index af3f1f2a9f8721aafe0dbfff30859967b43717f9..904208b95d4b81221fa96271492ee6fd85707cce 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 4cf3324ba166405ef45a86f4161cc97ac16802fb..057ecaacde6b77fa275b0805aced7259c652724d 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 65ed385c2ceb430f091cf26ef0b1acfc87a6978a..64c7fbe0a8e7e09a451a4c8e000e075e149c4c0d 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 2576055b350be1101ae699a8f5c75b98b0534b24..19e70d7e27ab15e68eda7830bcc674015c282c30 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <linux/module.h>
 #include <linux/mdio-bitbang.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/delay.h>
 
index 61a4461cbda5ccf3a9642be06f67c252b750a5e9..a872aea4ed7455f5b3f539c193232b4297cab860 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 2009 Cavium Networks
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index 0295097d6c4435c7fb720e6fe580bd637be33173..64be4664ccab0c906f34ce05f49c66d7cbf6def3 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 23062d0672314a3e5a9fb8d130cab45e43acc824..f6e190f73c3215c1c0c6c4877a9e7552c06e831e 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 3327e9fc7b51336c2628968fde94dfa64ac3564d..9a2103a69e172280e933de679b8cf303ff8ce767 100644 (file)
@@ -94,6 +94,7 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n"
 #include <linux/fcntl.h>
 #include <linux/interrupt.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/if_ether.h>
 #include <linux/in.h>
 #include <linux/errno.h>
index 6a375ea4947de45164268bf382151ee4e7cb80a8..6c2e8fa0ca31cd2865ad9f80d2f0fdc99103498b 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/string.h>
 
index 6d61602208c1f1470409c34717e7641e038b86a5..6e281bc825e57360704237270d571e36304b2ef0 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/stddef.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/slhc_vj.h>
 #include <asm/atomic.h>
 
index 3a13cecae3e2f29df464d486f68b20d545bdfcf2..52938da1e5420554db460c5c88680a4a349c0f24 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #define PPP_VERSION    "2.4.2"
index ac806b27c658a66f73e3614c9715a674db0d3453..d4191ef9cad14fed8d1cd6c0d284ddb7e51c8163 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/string.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/net.h>
index a849f6f23a17f8e5d9c11624042f0fdb577c4005..5bf229bb34c26e55879ddc62e13be82183e028c7 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
index 2663b2fdc0bb0170b6054188e02defdfb74241f1..f0be507e5324a69c5fe2a7c308e38eb122ec0537 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
index da00e162b6d348c62558a0aa9194b193e4a844c2..a6ef266a2fe29142fa6a7f01b2587493802845d3 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "qlcnic.h"
 
+#include <linux/slab.h>
 #include <net/ip.h>
 
 #define MASK(n) ((1ULL<<(n))-1)
index 7c34e4e29b3f79e64d2e3ac8f926c7dc0b48b57e..9d2c124048fa3934fadf15b68fcf3278e6dc5824 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "qlcnic.h"
 
 struct crb_addr_pair {
index fc721564e69ef60f12210b86cd293bbd8d988c2a..234dab1f99823c588e2532ba6ea0a6e35ed6a8e0 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 
index ff8550d2ca827cd266b1ad40e255f7ee2c531432..3626646289376c6b5940774ee8868818ad60bc3a 100644 (file)
@@ -1,3 +1,5 @@
+#include <linux/slab.h>
+
 #include "qlge.h"
 
 /* Read a NIC register from the alternate function. */
index 7dbff87480dc6d6d844ae5bce2230c561a5ea7f9..7e09ff4a57554d72bd546356c654db5aa7aaa401 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/pagemap.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/dmapool.h>
 #include <linux/mempool.h>
 #include <linux/spinlock.h>
index 15d5373dc8f30b70747941e26a8808e03236a601..43afdb6b25e680a4dd5c42934583c72430ce2848 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
index 9d3ebf3e975e0abfe5519bf2cd3371ed9278743d..dbb1f5a1824c7e7ddd251d9c75cbe3d4bab8469a 100644 (file)
@@ -186,8 +186,13 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = {
 
 MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
 
-static int rx_copybreak = 200;
-static int use_dac = -1;
+/*
+ * we set our copybreak very high so that we don't have
+ * to allocate 16k frames all the time (see note in
+ * rtl8169_open()
+ */
+static int rx_copybreak = 16383;
+static int use_dac;
 static struct {
        u32 msg_enable;
 } debug = { -1 };
@@ -511,8 +516,7 @@ MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
 module_param(rx_copybreak, int, 0);
 MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
 module_param(use_dac, int, 0);
-MODULE_PARM_DESC(use_dac, "Enable PCI DAC. -1 defaults on for PCI Express only."
-" Unsafe on 32 bit PCI slot.");
+MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
 module_param_named(debug, debug.msg_enable, int, 0);
 MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
 MODULE_LICENSE("GPL");
@@ -2821,8 +2825,8 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
        spin_lock_irq(&tp->lock);
 
        RTL_W8(Cfg9346, Cfg9346_Unlock);
-       RTL_W32(MAC0, low);
        RTL_W32(MAC4, high);
+       RTL_W32(MAC0, low);
        RTL_W8(Cfg9346, Cfg9346_Lock);
 
        spin_unlock_irq(&tp->lock);
@@ -2974,7 +2978,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        void __iomem *ioaddr;
        unsigned int i;
        int rc;
-       int this_use_dac = use_dac;
 
        if (netif_msg_drv(&debug)) {
                printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
@@ -3040,17 +3043,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        tp->cp_cmd = PCIMulRW | RxChkSum;
 
-       tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-       if (!tp->pcie_cap)
-               netif_info(tp, probe, dev, "no PCI Express capability\n");
-
-       if (this_use_dac < 0)
-               this_use_dac = tp->pcie_cap != 0;
-
        if ((sizeof(dma_addr_t) > 4) &&
-           this_use_dac &&
-           !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
-               netif_info(tp, probe, dev, "using 64-bit DMA\n");
+           !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) {
                tp->cp_cmd |= PCIDAC;
                dev->features |= NETIF_F_HIGHDMA;
        } else {
@@ -3069,6 +3063,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_out_free_res_4;
        }
 
+       tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+       if (!tp->pcie_cap)
+               netif_info(tp, probe, dev, "no PCI Express capability\n");
+
        RTL_W16(IntrMask, 0x0000);
 
        /* Soft reset the chip. */
@@ -3224,9 +3222,13 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
 }
 
 static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
-                                 struct net_device *dev)
+                                 unsigned int mtu)
 {
-       unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+       unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
+
+       if (max_frame != 16383)
+               printk(KERN_WARNING PFX "WARNING! Changing of MTU on this "
+                       "NIC may lead to frame reception errors!\n");
 
        tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE;
 }
@@ -3238,7 +3240,17 @@ static int rtl8169_open(struct net_device *dev)
        int retval = -ENOMEM;
 
 
-       rtl8169_set_rxbufsize(tp, dev);
+       /*
+        * Note that we use a magic value here, its wierd I know
+        * its done because, some subset of rtl8169 hardware suffers from
+        * a problem in which frames received that are longer than
+        * the size set in RxMaxSize register return garbage sizes
+        * when received.  To avoid this we need to turn off filtering,
+        * which is done by setting a value of 16383 in the RxMaxSize register
+        * and allocating 16k frames to handle the largest possible rx value
+        * thats what the magic math below does.
+        */
+       rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN);
 
        /*
         * Rx and Tx desscriptors needs 256 bytes alignment.
@@ -3891,7 +3903,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
 
        rtl8169_down(dev);
 
-       rtl8169_set_rxbufsize(tp, dev);
+       rtl8169_set_rxbufsize(tp, dev->mtu);
 
        ret = rtl8169_init_ring(dev);
        if (ret < 0)
@@ -4754,8 +4766,8 @@ static void rtl_set_rx_mode(struct net_device *dev)
                mc_filter[1] = swab32(data);
        }
 
-       RTL_W32(MAR0 + 0, mc_filter[0]);
        RTL_W32(MAR0 + 4, mc_filter[1]);
+       RTL_W32(MAR0 + 0, mc_filter[0]);
 
        RTL_W32(RxConfig, tmp);
 
index ede937ee50c704e373554f9881782dea7840b31b..07eb884ff982405c3d15204a04d6188394e329f3 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/rio.h>
 #include <linux/rio_drv.h>
+#include <linux/slab.h>
 #include <linux/rio_ids.h>
 
 #include <linux/netdevice.h>
index 266baf5349641ffef8f2afd578b79c684030d657..f2e335f0d1b760d7e8c0d23ae9cb5999d24f013c 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #include <asm/system.h>
index 2eb7f8a0d926a1a1e20ce3d1f82c071882308629..92ae8d3de39be642cccc50321696895bac745f1c 100644 (file)
@@ -79,6 +79,7 @@
 #include <linux/tcp.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <net/tcp.h>
 
 #include <asm/system.h>
index 9f83a11973750a2711eee50e7b985af5159c5cec..abc8eefdd4b6bcd7c7b075d2cccfd7c70e9b92d3 100644 (file)
@@ -42,7 +42,6 @@ static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n";
 #include <linux/errno.h>
 #include <linux/if_cablemodem.h> /* for SIOGCM/SIOSCM stuff */
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
@@ -52,6 +51,7 @@ static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n";
 #include <linux/pnp.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/processor.h>
index fe806bd9b95f662e3093f024cd087f525f701629..374832cca11fd092a42ee15719a8421f106e4f24 100644 (file)
@@ -37,7 +37,6 @@ static const char version[] =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index 88f2fb193abe5de97f3a5972ff183e4129649e35..6486657c47b86ee4de771419d0f48b33d88fd196 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/crc32.h>
 #include <linux/ethtool.h>
 #include <linux/topology.h>
+#include <linux/gfp.h>
 #include "net_driver.h"
 #include "efx.h"
 #include "mdio_10g.h"
index 1b8d83657aaa85e235e87686e6135775f0afd799..d294d66fd6006fe874036e3c23ff89871c279290 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/seq_file.h>
 #include <linux/i2c.h>
 #include <linux/mii.h>
+#include <linux/slab.h>
 #include "net_driver.h"
 #include "bitfield.h"
 #include "efx.h"
index 34c22fa986e2b3147a08a27666a7f0dd4a545b6b..2f2354696663cc8f207af5bc8449b8f7d3d31e2a 100644 (file)
@@ -11,6 +11,7 @@
  * Driver for PHY related operations via MCDI.
  */
 
+#include <linux/slab.h>
 #include "efx.h"
 #include "phy.h"
 #include "mcdi.h"
index 407bbaddfea6e88a95fcd5a869f6715aae4511a5..f3ac7f30b5e718e3178dbdcf2797b5a0d13703d7 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/rtnetlink.h>
 
 #define EFX_DRIVER_NAME "sfc_mtd"
index 1bee62c83001e18515d05cca6cbfbb4da100b30f..e077bef08a504258a4e37778c1778600cd640f92 100644 (file)
@@ -10,6 +10,7 @@
  * Driver for AMCC QT202x SFP+ and XFP adapters; see www.amcc.com for details
  */
 
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
 #include "efx.h"
index a97c923b560c4e177e82eac628771b47382c884e..e308818b9f5512e8679c9ac486ea141daa6285a9 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
index cf0139a7d9a42a8b6115a711dfe8b038ccea845f..0106b1d9aae216312f344d6d25e5899c4ae4c2e6 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/in.h>
 #include <linux/udp.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include "net_driver.h"
 #include "efx.h"
index 1619fb5a64f5c0574b3dca25cdb49abd7d5f5571..38dcc42c4f790648fb2add771b0610ee394e3380 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include "net_driver.h"
 #include "bitfield.h"
 #include "efx.h"
index 10db071bd8378c29822b4f360f7f729b16f3ccc1..f21efe7bd316e3618664cbcd0f1e94ef42a97ea9 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/rtnetlink.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "efx.h"
 #include "mdio_10g.h"
 #include "nic.h"
index a8b70ef6d817ea51a867c217f25fa78871cf5624..be0e110a1f73b4584582868e475cf3492cead862 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ip.h>
 #include <linux/in.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/ipv6.h>
 #include <linux/if_ether.h>
 #include <linux/highmem.h>
index ed999d31f1fa802e4738d466c68ea7e03f263ce0..c8fc896fc4600dfc348d0229f0cf91b8755be037 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -592,8 +593,10 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev)
        /* Setup... */
        len = skb->len;
        if (len < ETH_ZLEN) {
-               if (skb_padto(skb, ETH_ZLEN))
+               if (skb_padto(skb, ETH_ZLEN)) {
+                       spin_unlock_irqrestore(&sp->tx_lock, flags);
                        return NETDEV_TX_OK;
+               }
                len = ETH_ZLEN;
        }
 
index 42a35f086a9f5dccc9fc466340525f6154918df7..6242b85d5d1589bfeb8728308ad4e5a93b7bf4d3 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/cache.h>
 #include <linux/io.h>
 #include <linux/pm_runtime.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 
 #include "sh_eth.h"
index 760d9e83a46514fb603d97e7d1abdf667968a86f..b30ce752bbf3986987061a9b7323c4b59892ea98 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/delay.h>
 #include <linux/crc32.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/irq.h>
 
 #define PHY_MAX_ADDR           32
index 1921a54ea9952edcd4ea8b51bbce9d9582921869..d9016b75abc2d023e64da67db02acf172a4598dc 100644 (file)
@@ -78,13 +78,13 @@ static const char * const boot_msg =
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/fddidevice.h>
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
index d0058e5bb6aeba703784eaef9e25f4631db0e179..50eb70609f2039622feb551c981cbdc848c2e45e 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/mii.h>
+#include <linux/slab.h>
 #include <asm/irq.h>
 
 #include "skge.h"
index d8ec4c11fd49fec6a52bab0b8914cd1749419644..088c797eb73b8a215e36fa09ef6f8e96ffa42b79 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/ethtool.h>
 #include <linux/pci.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <linux/tcp.h>
 #include <linux/in.h>
index d640c0f5470be3bf315c5f53a5d37274a2afdbce..140d63f3cafa8ff2b976e3d26fd5ef488c9cb4d7 100644 (file)
@@ -51,6 +51,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/errno.h>
index ba5bbc503446134ee77a1000b08cfc541bfa8ea4..89696156c059a826231dd8c6bb8c2ae14ca6645e 100644 (file)
@@ -83,6 +83,7 @@
 #include <linux/compat.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include "slip.h"
 #ifdef CONFIG_INET
 #include <linux/ip.h>
index 9871a2b61f869c65e051e8515540e7089c158c75..635820d42b194252004bda1426d6c0d796c345f1 100644 (file)
@@ -59,7 +59,6 @@ static const char version[] =
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
index f9a960e7fc1fdc351e69f34bb74c694560f77235..3f2f7843aa4eacb86fc2923dec080695fd67647c 100644 (file)
@@ -64,7 +64,6 @@ static const char version[] =
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/crc32.h>
index fc1b5a1a3583d7d15983400ab384a81f6c1732b3..860339d51d586c14915596807b31dfa322ccc921 100644 (file)
@@ -70,7 +70,6 @@ static const char version[] =
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
index 4fd1d8b38788b6c7f68889c94ff5990d755f20c7..cbf520d38eacf02a25a1f902168210505c4a4758 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/bug.h>
 #include <linux/bitops.h>
index 34fa10d8ad40077e085d571633b59329a28672af..aafaebf4574895689ea2aa15da6e7a34f2cb44cd 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/if_vlan.h>
 #include <linux/dma-mapping.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "smsc9420.h"
 
index 854ccf2b4105efd1958a46eb942bb96928d511d2..6b2a888174732e613ec5094153fd68f29505d749 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
index 5ba9d989f8fc6819ca02e0dd21e8be5d042057f5..dd3cb0f2d21fe5b2af2643b25d1b2076595024f9 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/if_vlan.h>
 #include <linux/in.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/ip.h>
 #include <linux/kernel.h>
@@ -40,7 +41,6 @@
 #include <linux/device.h>
 #include <linux/pci.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/tcp.h>
 #include <linux/types.h>
 #include <linux/vmalloc.h>
index fb287649a3054a16e55bda06027be354431e7990..eb63d44748a76cd3182e002284afe84296552d1e 100644 (file)
@@ -2,6 +2,7 @@ config STMMAC_ETH
        tristate "STMicroelectronics 10/100/1000 Ethernet driver"
        select MII
        select PHYLIB
+       select CRC32
        depends on NETDEVICES && CPU_SUBTYPE_ST40
        help
          This is the driver for the Ethernet IPs are built around a
index 803b0373d843229447d68cbd88c75d49fb25c850..4cacca614fc12b10e3ba44adc79c136655839a5e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/crc32.h>
 #include <linux/mii.h>
 #include <linux/phy.h>
+#include <linux/slab.h>
 
 #include "common.h"
 #include "dwmac100.h"
index a6538ae4694cfc864172083246d377faf855fa5a..5bd95ebfe498837ec0313ac49b7df51e42a41636 100644 (file)
@@ -27,6 +27,7 @@
 *******************************************************************************/
 
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include "dwmac1000.h"
 
 static void dwmac1000_core_init(unsigned long ioaddr)
index a6733612d64a66fb5f083699254d792da867bacf..a214a1627e8b31ee6b7b435fa03e88b6613b46c2 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/phy.h>
 #include <linux/if_vlan.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include "stmmac.h"
 
 #define STMMAC_RESOURCE_NAME   "stmmaceth"
index fffe1d037fe667bfd2d2d6a39822e821d1227009..40b2c79297192455e954ad73f7ea195709fc56e1 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/mii.h>
 #include <linux/phy.h>
+#include <linux/slab.h>
 
 #include "stmmac.h"
 
index 2f6a760e5f21b5f5c68594ec4007d39fae0b81a0..8b28c89a9a77c50566ddb39601f37ed2d765a5b5 100644 (file)
@@ -33,7 +33,6 @@ static int fifo=0x8;  /* don't change */
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/init.h>
index 99998862c22e018ca1c3b8fe27184af9d31b7486..1694ca5bfb41a4f85c5ebee6e1b067938e982130 100644 (file)
@@ -28,7 +28,6 @@ static char *version = "sun3lance.c: v1.2 1/12/2001  Sam Creasey (sammy@sammy.ne
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
index a0bd361d5eca713fb52d6d6c77ec3db7c37852d3..ed7865a0b5b2efeacebda8db16aff1cab2aa5058 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -25,6 +24,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/auxio.h>
 #include <asm/byteorder.h>
index a855934dfc3b4f433e61c9d8c68c948361646420..8249a394a4e16b68df683f52acbac224f9ef2649 100644 (file)
@@ -84,7 +84,6 @@ static char *media[MAX_UNITS];
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
index 70196bc5fe61973de756b5d41793546e3e93b73a..e6880f1c4e8cf872320656761aa416ec75a3a3d7 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/ioport.h>
 #include <linux/in.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -58,6 +57,7 @@
 #include <linux/bitops.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index d7c73f478ef5f989bd1d05417e6ab35eebec7cd1..0c21653ff9f90d3022d8e6e4e83d1bb03ee9f874 100644 (file)
@@ -78,7 +78,6 @@ static char lancestr[] = "LANCE";
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -94,6 +93,7 @@ static char lancestr[] = "LANCE";
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index a19dcf8b6b5611632ffb9d1f582c81845046b87c..cff98d07cba8c0a44e3751cbe5c87a449bf9423c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/firmware.h>
 #include <asm/byteorder.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 /* Compile Time Switches */
 /* start */
index 0fb930feea4566130fc3cc6dfc0816bb1c9a78cf..7d7f3eef1ab3e4d71aad3fa6cf2d3c934dda5536 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include <net/checksum.h>
 
index dd028fee9dc2d6a130895f6bdde2057a1b159c6e..7a5fbf5a9d7136afa7bf39afa643dbcf788426e1 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/bitops.h>
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/checksum.h>
index 456f8bff40bec45f65ebffae80dfe34c326b9a3f..53f631ebb162d55021739a4bd4898b023eda5c8d 100644 (file)
@@ -21,6 +21,7 @@ static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
 
 #include <linux/module.h>
 #include <linux/mca.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
index 5401d86a7be413199f1fbd3e3058e4f920202395..e40560137c460938633c4750986d9b4a9d1cdd7c 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/errno.h>
index ee71bcfb3753021ce13a454b0ff78f12ddaa860b..8b508c922410cf4e010aa6b1bcbe8cd72b634bb2 100644 (file)
@@ -85,7 +85,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/errno.h>
index 647cdd1d4e20a555182deb64352603d4a83d7d72..5b1fbb3c3b516871635d3a3aa6cd68c245ce0d76 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
 #include <linux/crc32.h>
@@ -48,6 +47,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/timer.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index cb429723b2c8ea705aa47a343f7fa642660d366b..19cafc2b418dab716bebfab2005eee7efd61bb1e 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/compiler.h>
 #include <linux/rtnetlink.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index c4ecb9a954097f212fcbad7637222094017116b5..09b57193a16a146784aca8f2ccae616242e11b24 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/eisa.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/moduleparam.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 95b38d803e9b445e5ca5f1084e2c0cc54962c4da..9568156dea982aa8058479774a2ad1e59c8c7846 100644 (file)
@@ -74,7 +74,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
index 49f05d1431f5c6a67b3ffdff698e6866010ed259..6002e651b9ea5f4f9510f89fa008b439f25fa664 100644 (file)
@@ -13,6 +13,7 @@
 */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include "tulip.h"
 #include <linux/init.h>
 #include <asm/unaligned.h>
index 7f544ef2f5fcfcad23aa77b148f165cab8b82936..3810db9dc2de3a4ae17067b1ba087e32004fbc66 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include "tulip.h"
 #include <linux/init.h>
 #include <linux/etherdevice.h>
index 0ab05af237e5c78d68d110c40fe3efe55edb07c9..a589dd34891ee646e279b7a8de15c42d5c49a393 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/init.h>
@@ -851,13 +850,15 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
 
                        if ( !(rdes0 & 0x8000) ||
                                ((db->cr6_data & CR6_PM) && (rxlen>6)) ) {
+                               struct sk_buff *new_skb = NULL;
+
                                skb = rxptr->rx_skb_ptr;
 
                                /* Good packet, send to upper layer */
                                /* Shorst packet used new SKB */
-                               if ( (rxlen < RX_COPY_SIZE) &&
-                                       ( (skb = dev_alloc_skb(rxlen + 2) )
-                                       != NULL) ) {
+                               if ((rxlen < RX_COPY_SIZE) &&
+                                   (((new_skb = dev_alloc_skb(rxlen + 2)) != NULL))) {
+                                       skb = new_skb;
                                        /* size less than COPY_SIZE, allocate a rxlen SKB */
                                        skb_reserve(skb, 2); /* 16byte align */
                                        memcpy(skb_put(skb, rxlen),
index 304f43866c4482e9b204e1be25585ad43e8d0f6a..98dbf6cc1d683d5e6fc5746ae76b85d8ba696e01 100644 (file)
@@ -114,7 +114,6 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
index cd24e5f2b2a27944054f9ee4192910a81ab01795..98d818daa77ecae5f95b8ac8b4cfe0b7f6ca4d41 100644 (file)
@@ -109,7 +109,6 @@ static const int multicast_filter_limit = 32;
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
index 7075f26e97daa22bd090ebd9ef125c24836fceae..6f92e48f02d33f5ffccd2510384976441a2a2bb2 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
index 9e05639435f2397a36a143545c78be1c56bd9080..35f56fc828032090512658216b56b712bf035999 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/usb.h>
 #include <linux/crc32.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 
 #define DRIVER_VERSION "14-Jun-2006"
 static const char driver_name [] = "asix";
index 96f1ebe0d3484d490fb1bb1d514e6df15c4aa1c0..602e123b2741672994755fa9884a57f167b39bda 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
@@ -44,6 +43,7 @@
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 
 #undef DEBUG
index 6491c9c00c83ac174857e2025b4002151ff851cf..dc9444525b4901c2035d50e5c84b7f39b510bc6d 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/usb.h>
 #include <linux/usb/cdc.h>
 #include <linux/netdevice.h>
index a4a85a6ed86de394e1bd532e5a10566275b3f5ed..5f3b97668e63c80ae37cb07dcd556d04a113c696 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/crc32.h>
 #include <linux/usb/cdc.h>
 #include <linux/usb/usbnet.h>
+#include <linux/gfp.h>
 
 
 /*
index 269339769f476cd1643b3f75087d7c1fc1a508a3..04b281002a762c81a99270fa1da365c7992e21ad 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/usb.h>
 #include <linux/crc32.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 
 /* datasheet:
  http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf
index f7ccfad9384e60024bccb27ce03a8391089a52a5..dcd57c37ef733322a894cfebcb3956aa2d4705c7 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/mii.h>
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
+#include <linux/gfp.h>
 
 
 /*
index 3c228df57062d2cc86212eeb410b27795dfa3869..be02a25da71a4572fc96ac9d3c699da4db248822 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
+#include <linux/slab.h>
 #include <linux/mii.h>
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
index 70978219e98afb8005a1519e4120a6f8acd7e23d..9f24e3f871e1ff67cdff9e9e4327cca53da3e867 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/mii.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
 
index bdcad45954a3a4d59217dfb3c6119eae6743491a..961a8ed38d8f40622a49f9929184a0c7c4f6042c 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/mii.h>
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 
 #include <asm/unaligned.h>
 
index 4ce331fb1e1e980eb18f6b9ab76a6ee6afb81d23..dd8a4adf48cadf3d1c85507dc9c71c9d9c316004 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include <linux/mii.h>
 #include <linux/usb.h>
 #include <linux/usb/cdc.h>
index 300e3e764fa2d74f0bf979570a359b3b3a5d559d..35b98b1b79e479f8ecf9924fe16aa72dddba7b5e 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/usb.h>
 #include <linux/crc32.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 #include "smsc75xx.h"
 
 #define SMSC_CHIPNAME                  "smsc75xx"
index d222d7e2527392a79990de49f909e0330483c871..3135af63d3785f8ba38cfe3b516841bfdc2a1c92 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/usb.h>
 #include <linux/crc32.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 #include "smsc95xx.h"
 
 #define SMSC_CHIPNAME                  "smsc95xx"
@@ -1189,9 +1190,21 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
        }
 
        if (csum) {
-               u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
-               skb_push(skb, 4);
-               memcpy(skb->data, &csum_preamble, 4);
+               if (skb->len <= 45) {
+                       /* workaround - hardware tx checksum does not work
+                        * properly with extremely small packets */
+                       long csstart = skb->csum_start - skb_headroom(skb);
+                       __wsum calc = csum_partial(skb->data + csstart,
+                               skb->len - csstart, 0);
+                       *((__sum16 *)(skb->data + csstart
+                               + skb->csum_offset)) = csum_fold(calc);
+
+                       csum = false;
+               } else {
+                       u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
+                       skb_push(skb, 4);
+                       memcpy(skb->data, &csum_preamble, 4);
+               }
        }
 
        skb_push(skb, 4);
index 17b6a62d206e0d6825b8a7b0e83794fed4930e02..7177abc78dc6b664fbe722a8bb18263ad7c3d1b1 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/mii.h>
 #include <linux/usb.h>
 #include <linux/usb/usbnet.h>
+#include <linux/slab.h>
 
 #define DRIVER_VERSION         "22-Aug-2005"
 
index b583d4968add5064b57417b25f9e67f8a6549240..f9f0730b53d5d411c3f79fc813c8890c87c88f03 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/ethtool.h>
 #include <linux/etherdevice.h>
 
index 50f881aa3939a50606f34412bd05cdbe2d2ad381..388751aa66e05f287ec40422936a30bac95d4407 100644 (file)
@@ -89,7 +89,6 @@ static const int multicast_filter_limit = 32;
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
index 3a486f3bad3ddd6477c0fa15102e47c668ea3566..bc278d4ee89debb359c4d70ef21e06bfd7479ae3 100644 (file)
@@ -812,7 +812,7 @@ static void set_mii_flow_control(struct velocity_info *vptr)
 
        case FLOW_CNTL_TX_RX:
                MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
-               MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
+               MII_REG_BITS_OFF(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
                break;
 
        case FLOW_CNTL_DISABLE:
index 25dc77ccbf5876f3bbf27100fdd7b77be3c01a02..6fb783ce20b987fe6b74377a3fa96a0e0a8be18f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/virtio_net.h>
 #include <linux/scatterlist.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 
 static int napi_weight = 128;
 module_param(napi_weight, int, 0444);
index 32a75fa935ed4cc892c86ab6715a9db43f2802c9..a21a25d218b695c737a2647d6407c4acc448605d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
+#include <linux/slab.h>
 
 #include "vxge-traffic.h"
 #include "vxge-config.h"
index e7877df092f357bb3d4085858a35ce69ab2873b3..13f5416307f8013ed5259137b5470fc99ce0445b 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef VXGE_CONFIG_H
 #define VXGE_CONFIG_H
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #ifndef VXGE_CACHE_LINE_SIZE
 #define VXGE_CACHE_LINE_SIZE 128
index c6736b9726352b07044693af19c7d4545b249500..aaf374cfd322d641024c8e1921e3881b630888e3 100644 (file)
@@ -12,6 +12,7 @@
  * Copyright(c) 2002-2009 Neterion Inc.
  ******************************************************************************/
 #include<linux/ethtool.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/etherdevice.h>
 
index 46a7c9e689ec7dc26d2e29d6760f606562ea5dc5..ba6d0da78c3019b111e537ef894ce66940fca324 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <linux/if_vlan.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/tcp.h>
 #include <net/ip.h>
 #include <linux/netdevice.h>
index f88c07c131978dfd58e046543b04d818e037fbd9..a4859f7a7cc0c9aa62ce537dcef3740999890b29 100644 (file)
@@ -89,6 +89,7 @@
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/cache.h>
index 40d724a8e02044fbfc8d144fa520c47c7681b472..e087b9a6daaa50078fa761acc2deabbb70b315b5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/version.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/if.h>
index 80114c93bae74c52db4d53c32f3681938022c49d..4dde2ea4a189d75ae6e7c3da6ec03469c13bc253 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <asm/io.h>
index 84f01373e11fb769794dd885b0586e61607c9692..aad9ed45c254c52af53510ba2158b2a11b22ced0 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <asm/io.h>
index 1ceccf1ca6c7952e277dbf11e43421206657b8a6..ee7083fbea50708a076c68af7e289320cb4d355c 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/poll.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 
 #undef DEBUG_HARD_HEADER
 
index 19f51fdd55227debdbcae8b10ab100feb93ee3d6..5dc153e8a29d14d9d0a68579dbe85718ea6d7955 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/poll.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 
 
 static int raw_ioctl(struct net_device *dev, struct ifreq *ifr);
index 1b30fcc2414531edc8be3fff8175ae8685ea3e6b..05c9b0b96239d17f9896000f409bdd8d17cdff46 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/errno.h>
 #include <linux/etherdevice.h>
+#include <linux/gfp.h>
 #include <linux/hdlc.h>
 #include <linux/if_arp.h>
 #include <linux/inetdevice.h>
@@ -21,7 +22,6 @@
 #include <linux/poll.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 
 static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr);
 
index 6e1ca256effd8f8752b3387c23ca75d7522cb1d8..c7adbb79f7cc34daf5c1b13f1398ff654d143b33 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/hdlc.h>
 #include <linux/if_arp.h>
 #include <linux/inetdevice.h>
@@ -21,7 +22,6 @@
 #include <linux/poll.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <net/x25device.h>
 
 static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
index 74164d29524c92be79f490861fb3bf9ea39711ee..48edc5f4dac8e4bba19a7366e95463e6426f80b3 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/delay.h>
 #include <linux/hdlc.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 
 #include <asm/irq.h>
index c705046d86158f0cbe8de8e521ef364808ba34a3..0c2cdde686a03fd6f50efa58fa9d3538c2f8407a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <mach/npe.h>
 #include <mach/qmgr.h>
 
index d1e3c673e9b298376344bb501dca4d2bdd3850d6..98e2f99903d775e7ddfdd78ea93a56f9304ea77d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/net.h>
index f327674fc93ae139c88d70a7881d38ab393e10ee..5920c996fcdf24679944920fac6e577c0c4c472b 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/in.h>
 #include <linux/if_arp.h>
index 044a48175c42e4d4076d950cc23b0a2ffc162765..f600075e84a248c9afd481f6cd7e8453e5eeb8b4 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/in.h>
 #include <linux/if_arp.h>
index f4f1c00d0d23737cfc7b6b8e0066c2d2e6490743..3f744c6430946905cc312eb257d77eaef57c7878 100644 (file)
@@ -228,6 +228,7 @@ static char rcsid[] =
 #include <linux/etherdevice.h>
 #include <linux/spinlock.h>
 #include <linux/if.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 
 #include <asm/io.h>
index 25477b5cde4769d3a0be456bb07e3ac6f3e95ce3..cff13a9597cd27ee80de90089423df8ea660bdde 100644 (file)
@@ -43,7 +43,6 @@
 #include <linux/fcntl.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
index 61249f489e3782e5be8ea90a9f15b69b5dde1e6e..e91457d6023ecd7a2d8512a0a151368491261ec6 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/hdlc.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 
 #include <asm/irq.h>
index b9f520b7db6adb71f4cb26bc3a64fde1a3400423..80d5c5834a0bf976c0446a02e7a3050823158c4a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/compat.h>
+#include <linux/slab.h>
 #include "x25_asy.h"
 
 #include <net/x25device.h>
index 0be7ec7299dbb960641f7c385b2dace9482ca7fd..fbf5e843d48c1fd9f88b55ef993ea74474488041 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/hdlc.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #define RT_LOCK
index 9449455403911266fb05c1c49fde856765dd2cdc..6180772dcc092011bf98f995048b45b81df2efa5 100644 (file)
@@ -76,6 +76,7 @@
 #include <stdarg.h>
 #include "i2400m.h"
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/wimax/i2400m.h>
 
 
index 6cead321bc15d664f924105852f5deef740cf392..94dc83c3969d7498d7a625d48685741c1642a788 100644 (file)
@@ -69,6 +69,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/suspend.h>
+#include <linux/slab.h>
 
 #define D_SUBMODULE driver
 #include "debug-levels.h"
index 25c24f0368d8d4c921cacb60582e21708ef66cc9..3f283bff0ff7146447419ea714ef7cdd78884b12 100644 (file)
  */
 #include <linux/firmware.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include "i2400m.h"
 
index 599aa4eb9baa9bc8dd51cfd4ef3ac076583e99b4..b811c2f1f5e978dc42e8cacea806307a6cff70c7 100644 (file)
@@ -73,6 +73,7 @@
  *                        alloc_netdev.
  */
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
 #include "i2400m.h"
index 43927b5d7ad6158a959b06f305e008b56bb306b5..035e4cf3e6ed1a9b7d7b0184dc4f95128b366b0a 100644 (file)
@@ -34,6 +34,7 @@
  */
 #include "i2400m.h"
 #include <linux/wimax/i2400m.h>
+#include <linux/slab.h>
 
 
 
index 7ddb173fd4a7b4f2470adfce618e6612375fa534..fa2e11e5b4b9cb32718bb827f41ecbe1c3c580ef 100644 (file)
  *       i2400m_msg_size_check
  *       wimax_msg
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
 #include <linux/netdevice.h>
index 8adf6c9b6f8f245e16e153c4fe132f6dbb3eef53..d619da33f20b9adad0642678545810a143d93aea 100644 (file)
@@ -65,6 +65,7 @@
 #include <linux/skbuff.h>
 #include <linux/mmc/sdio.h>
 #include <linux/mmc/sdio_func.h>
+#include <linux/slab.h>
 #include "i2400m-sdio.h"
 
 #define D_SUBMODULE rx
index 14f876b1358b8e78b56c0b90782fd935768553ba..7632f80954e3e56620b95b474ccf79d4e90037c8 100644 (file)
@@ -48,6 +48,7 @@
  *     __i2400ms_send_barker()
  */
 
+#include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <linux/mmc/sdio_ids.h>
 #include <linux/mmc/sdio.h>
index 54480e8947f1a6acd0b306798ad25b81c2b76fd9..b0cb90624cf62f4f25d6f30732a00da538e558c2 100644 (file)
  *                               (FIFO empty).
  */
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include "i2400m.h"
 
 
index ce6b9938fde08ed80bd99ad6d2c6c8f94424394e..b58ec56b86f8b29556cc9fe2a9b1453cf0d5baa9 100644 (file)
@@ -73,6 +73,7 @@
  *   i2400m_notif_submit
  */
 #include <linux/usb.h>
+#include <linux/gfp.h>
 #include "i2400m-usb.h"
 
 
index f88d1c6e35cbb056a69666366505ba6adab25bbd..7b6a1d98bd74321af344c47916422dae6002108a 100644 (file)
@@ -56,6 +56,7 @@
  *     i2400mu_rx_kick()
  */
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include "i2400m-usb.h"
 
 
index ba1b02362dfcba8b7daaabe3872ee133711b6da4..a26483a812a50679088b6f9fae058821275d3dc0 100644 (file)
@@ -83,6 +83,7 @@
  * i2400mu_rx_release()            called from i2400mu_bus_dev_stop()
  */
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include "i2400m-usb.h"
 
index 99f04c4758981425f6a95dd89697edb75b1fb581..d8c4d6497fdfb8dc4b4d97baafd55210833ea89a 100644 (file)
@@ -66,6 +66,7 @@
 #include "i2400m-usb.h"
 #include <linux/wimax/i2400m.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 
 #define D_SUBMODULE usb
index 547912e6843f2efeac20f9361409707f64233302..ab61d2b558d6c944cb9f653f609e511256d90a6c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/if.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
index 257c734733d1d362a6290631075b790bc17b9fc5..c53692980990153ca3b05562978cb3d010d6d215 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/etherdevice.h>
 #include <net/mac80211.h>
index 4e30197afff6702e5630373d893b2615db53d1cb..99a6da464bd377caf51059c2f9869420161cf317 100644 (file)
@@ -38,6 +38,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
@@ -94,6 +95,8 @@ static struct usb_device_id ar9170_usb_ids[] = {
        { USB_DEVICE(0x04bb, 0x093f) },
        /* AVM FRITZ!WLAN USB Stick N */
        { USB_DEVICE(0x057C, 0x8401) },
+       /* NEC WL300NU-G */
+       { USB_DEVICE(0x0409, 0x0249) },
        /* AVM FRITZ!WLAN USB Stick N 2.4 */
        { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY },
 
@@ -416,7 +419,7 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
        spin_unlock_irqrestore(&aru->common.cmdlock, flags);
 
        usb_fill_int_urb(urb, aru->udev,
-                        usb_sndbulkpipe(aru->udev, AR9170_EP_CMD),
+                        usb_sndintpipe(aru->udev, AR9170_EP_CMD),
                         aru->common.cmdbuf, plen + 4,
                         ar9170_usb_tx_urb_complete, NULL, 1);
 
index 42284445b75e72beeb6cc68d0356c74cc4ba21fc..dc0786cc26393666f3d63ffdb56b5c4e11c4318f 100644 (file)
@@ -21,6 +21,7 @@
 \*************************************/
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include "ath5k.h"
 #include "reg.h"
 #include "debug.h"
index 8dce0077b02355b3b6f91bdf0aa808cb1091e0c6..3abbe7513ab5602df918ae91d0702a2487c4d706 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/pci.h>
 #include <linux/ethtool.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 #include <net/ieee80211_radiotap.h>
 
index 10b52262b23219a5eacdc28ada3dc28abca2032a..67665cdc7afe256822f610968c292dc8031d1549 100644 (file)
@@ -21,6 +21,8 @@
 * EEPROM access functions and helpers *
 \*************************************/
 
+#include <linux/slab.h>
+
 #include "ath5k.h"
 #include "reg.h"
 #include "debug.h"
index eff3323efb4bf82afc965fa30ab83110e1ac6114..68e2bccd90d34418d3b85070b0f7b09ee468a93f 100644 (file)
@@ -23,6 +23,7 @@
 #define _ATH5K_PHY
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "ath5k.h"
 #include "reg.h"
index 42d2a506845a43ea929b0d8159bb12b44bcb5e17..081e0085ed4ce3460c82d2ba8f44eab5a090a4e7 100644 (file)
@@ -14,6 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "ath9k.h"
index 2e767cf22f1ef8bf6f41f07a51addfd2aefe8c33..78b571129c92a57e8cf921f7f02040aa0f47b959 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "hw.h"
index 623c2f884987fbc25502dab79bf06132e84a24c1..3d4d897add6d9bc07f250dcee458633e4ae7355f 100644 (file)
@@ -14,6 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "ath9k.h"
 
 static char *dev_info = "ath9k";
index c3b59390fe386ac6b6cd7a6f524476805c7636e4..2547b3c4a26cd841efc5cd1fb2aeb00fbd63c0a2 100644 (file)
@@ -39,6 +39,8 @@
  * AR9287 - 11n single-band 1x1 MIMO for USB
  */
 
+#include <linux/slab.h>
+
 #include "hw.h"
 
 /**
index 0e79e58cf4c96fb4704390645b0974516d995828..244e1c6291776dc9f5c0a931ef1cb7cdcbbfb14a 100644 (file)
@@ -15,6 +15,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "ath9k.h"
 
 static const struct ath_rate_table ar5416_11na_ratetable = {
index a43fbf84dab9c7c5efc45029a2a0b85a9c0eee11..00c0e21a4af77269fb2b013a3bf25291ce39adc3 100644 (file)
@@ -14,6 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/slab.h>
+
 #include "ath9k.h"
 
 struct ath9k_vif_iter_data {
index b2c8207f7bc17790b55c42e18a70e47f9a40320a..294b486bc3ed2043d09fc679a9ad76983e854286 100644 (file)
@@ -1353,25 +1353,6 @@ static enum ath9k_pkt_type get_hw_packet_type(struct sk_buff *skb)
        return htype;
 }
 
-static bool is_pae(struct sk_buff *skb)
-{
-       struct ieee80211_hdr *hdr;
-       __le16 fc;
-
-       hdr = (struct ieee80211_hdr *)skb->data;
-       fc = hdr->frame_control;
-
-       if (ieee80211_is_data(fc)) {
-               if (ieee80211_is_nullfunc(fc) ||
-                   /* Port Access Entity (IEEE 802.1X) */
-                   (skb->protocol == cpu_to_be16(ETH_P_PAE))) {
-                       return true;
-               }
-       }
-
-       return false;
-}
-
 static int get_hw_crypto_keytype(struct sk_buff *skb)
 {
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -1696,7 +1677,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
                        goto tx_done;
                }
 
-               if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && !is_pae(skb)) {
+               if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
                        /*
                         * Try aggregation if it's a unicast data frame
                         * and the destination is HT capable.
index 04abd1f556b78a2863f352da74972b76f6c15a37..00489c40be0cb66ec6993122bc3b2c8793fa1798 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <net/cfg80211.h>
 #include <net/mac80211.h>
 #include "regd.h"
index be7abf8916ad3af2100fc74b902d7f91a09f790b..fa40fdfea719da1b24767550d2d17c932ba10993 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/delay.h>
 #include <linux/skbuff.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <asm/div64.h>
 
 
index 976104f634a10f9448056233db1057d5f85c8ff3..94e4f1378fc3c5660bd42b008c3e6384768d798d 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 
 static struct b43_lo_calib *b43_find_lo_calib(struct b43_txpower_lo_control *lo,
index 1521b1e78d2194309a0b12cd836925b07b9d5a85..9a374ef83a224e151b5dc66c7fb4956dace905de 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/skbuff.h>
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "b43.h"
index 984174bc7b0ff5411b7961f59b494cd8edeafc36..609e7051e01806a015660e029a8eb545e98bb85a 100644 (file)
@@ -24,6 +24,7 @@
 #include "pcmcia.h"
 
 #include <linux/ssb/ssb.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
index d90217c3a70623cb165af8b1c2f4ef81289ed349..b6428ec16dd638faf0fe167616ab2c9efb21d91a 100644 (file)
@@ -26,6 +26,8 @@
 
 */
 
+#include <linux/slab.h>
+
 #include "b43.h"
 #include "phy_a.h"
 #include "phy_common.h"
index 382826a8da822c49434a2d6028be1544e959f50e..29bf34ced86552cb35ec284cf45d297c2f0479f7 100644 (file)
@@ -33,6 +33,7 @@
 #include "main.h"
 
 #include <linux/bitrev.h>
+#include <linux/slab.h>
 
 
 static const s8 b43_tssi2dbm_g_table[] = {
index 185219e0a55243deed19cb3a6d50c0640d5ccb32..c6afe9d94590f2e15cf66db6d908ded47d94ac92 100644 (file)
@@ -23,6 +23,8 @@
 
 */
 
+#include <linux/slab.h>
+
 #include "b43.h"
 #include "main.h"
 #include "phy_lp.h"
index 795bb1e3345dce2d4756520b875aba514a0c0782..9c7cd282e46c5c9423e9f976f4098a688942f58f 100644 (file)
@@ -23,6 +23,7 @@
 */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include "b43.h"
index a6062c3e89a571305ac05106164b59ae00a84443..aa12273ae716482544f71f0733beb8d70c45ff84 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 
 static u16 generate_cookie(struct b43_pio_txqueue *q,
index 0d3ac64147a5713e8190b6c01481911a3f35f1d4..4e56b7bbcebd0b46c4a56c7822713b62be29446b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/slab.h>
 #include <linux/ssb/ssb.h>
 
 #include "sdio.h"
index 8b9387c6ff36936d31680e97c8e028ac39e4ba57..e91520d0312e1d18d8b3c944afaa72975686d1d7 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/dst.h>
 
 /* 32bit DMA ops. */
index 1d070be5a678de09584f49adb88fa8da2212b3c9..bb2dd9329aa0fd88ff7f7b2dc85d841e1a193209 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/sched.h>
 #include <linux/skbuff.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <net/dst.h>
 #include <asm/unaligned.h>
 
index aaf227203a98f94dd93854bf936e95ec0c6841d1..35033dd342ce2e7fb63cc31a7bf9a0e3d2810d57 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include "b43legacy.h"
index 017c0e9c37ef4dc6f67f3884a1d084675ae3fd9e..b033b0ed4ca099dc63a9dbea167fdb88fed64c2d 100644 (file)
@@ -29,6 +29,7 @@
 #include "xmit.h"
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 
 static void tx_start(struct b43legacy_pioqueue *queue)
index 3816df96a663e0f544dcf6a53694d8bcf1c33895..f4c56121d3878307f63fa9552b3e084ae89af130 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/lib80211.h>
 #include <linux/if_arp.h>
 
index 90108b698f11acfe43d572dff28165d571bcfe78..c34a3b7f12924db3cbc2c75b3b173bcfc4da3d73 100644 (file)
@@ -1,3 +1,5 @@
+#include <linux/slab.h>
+
 #include "hostap_80211.h"
 #include "hostap_common.h"
 #include "hostap_wlan.h"
index a2a203c90ba3da30dae1d041df49a3b8c683a295..7e72ac1de49b96b4abb8672240e26d3c3f121eb4 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/random.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 
 #include "hostap_wlan.h"
 #include "hostap.h"
index d19748d90aaf42d423936c0b8906d9ea5d11a6bc..a36501dbbe02471ecdb3eb58f455134b0ac130d4 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/if.h>
+#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/timer.h>
 #include <linux/skbuff.h>
index 4dfb40a84c96ed9d54d83ef8b091bafabc28b215..d737091cf6acc1c4abd45d0a8d058e3e3b9799d3 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <linux/if_arp.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "hostap_wlan.h"
 #include "hostap.h"
 #include "hostap_ap.h"
index 9419cebca8a582f8d9dab12bc442a67409ddebea..9a082308a9d467ae5e431b5ffb716df9f944d67a 100644 (file)
@@ -1,5 +1,6 @@
 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/ethtool.h>
index 4d97ae37499bd7a64e9368c8d48d4d8c4bd0d8ca..d24dc7dc072328fcecab649193ed4cbad0c17caa 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/if.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
index fc04ccdc5befa36f3126c4e2a0b888b6d6d7b700..33e79037770b38673e2e5c0fa18ec39a4619cba5 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/if.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
index 5c7aa1b1eb566e0bac134294874ffcadd3366a39..8d72e3d1958680bfaa9dbb79974cabf889e7b0ac 100644 (file)
@@ -31,6 +31,7 @@
 ******************************************************************************/
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "ipw2200.h"
 
 
index 65e8c175a4a0c356d5b3e5879dddd654ddb24409..c9fe3c99cb003c087729b12380b16df014827f8b 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/tcp.h>
 #include <linux/types.h>
 #include <linux/wireless.h>
index 282b1f7ff1e9543d937308ba3275f0a232c50d0d..39a34da52d52858d89c439067066cfa2110ae23a 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
+#include <linux/gfp.h>
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/kernel.h>
@@ -24,7 +25,6 @@
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/tcp.h>
 #include <linux/types.h>
 #include <linux/wireless.h>
index 4d89f66f53b2b0233eaae018b969d7504c0ef53f..3633c6682e4967575ef040ad620fbb8550531c35 100644 (file)
@@ -31,6 +31,7 @@
 ******************************************************************************/
 
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/jiffies.h>
 
index 47909f94271e1d41ac73a7c90921f6906b2d45ba..902c4d4293e9634bbcfd135c880c79d7a3b27772 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <net/mac80211.h>
 
index e0678d92105537fc169eee73c12628f4ca4cd97b..0728054a22d4f15f7cbfa9801300fb598bee7fa0 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
index 1bd2cd8360262f265ec329a174a9f4fa23476442..83c52a682622a518d5b42bbddd17edfdd895db69 100644 (file)
@@ -2041,16 +2041,14 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
                                   tx_resp->failure_frame);
 
                freed = iwl_tx_queue_reclaim(priv, txq_id, index);
-               if (qc && likely(sta_id != IWL_INVALID_STATION))
-                       priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
+               iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
 
                if (priv->mac80211_registered &&
                    (iwl_queue_space(&txq->q) > txq->q.low_mark))
                        iwl_wake_queue(priv, txq_id);
        }
 
-       if (qc && likely(sta_id != IWL_INVALID_STATION))
-               iwl_txq_check_empty(priv, sta_id, tid, txq_id);
+       iwl_txq_check_empty(priv, sta_id, tid, txq_id);
 
        if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
                IWL_ERR(priv, "TODO:  Implement Tx ABORT REQUIRED!!!\n");
index 8bf7c20b9d3928b4aba502062800ee006092aae9..35f819ac87a3948ede685d6d2a86536b0a515cac 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <net/mac80211.h>
 
index 818367b57babfa0d3b00a0b173245e48cb1bf238..8b8e3e1cbb440076fcb9751abe8869136a4d8a2d 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
@@ -1258,7 +1259,15 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
        /* Ack/clear/reset pending uCode interrupts.
         * Note:  Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
         */
-       iwl_write32(priv, CSR_INT, priv->inta);
+       /* There is a hardware bug in the interrupt mask function that some
+        * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
+        * they are disabled in the CSR_INT_MASK register. Furthermore the
+        * ICT interrupt handling mechanism has another bug that might cause
+        * these unmasked interrupts fail to be detected. We workaround the
+        * hardware bugs here by ACKing all the possible interrupts so that
+        * interrupt coalescing can still be achieved.
+        */
+       iwl_write32(priv, CSR_INT, priv->inta | ~priv->inta_mask);
 
        inta = priv->inta;
 
@@ -2644,7 +2653,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
                BIT(NL80211_IFTYPE_STATION) |
                BIT(NL80211_IFTYPE_ADHOC);
 
-       hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY |
+       hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
                            WIPHY_FLAG_DISABLE_BEACON_HINTS;
 
        /*
index 845831ac053e2fa4bb320abb5024b87d4a5632b9..de3b3f403d1f2cfe68db5a4a6f0182366fdc633a 100644 (file)
@@ -60,6 +60,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#include <linux/slab.h>
 #include <net/mac80211.h>
 
 #include "iwl-dev.h"
index 112149e9b31e40d9951ddd25581b2df1c2a1e780..db050b811232279e06bfe208c71d92b325bee71d 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/etherdevice.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 
 #include "iwl-eeprom.h"
index 7bf44f1467993d911d3f95bd18892cea408306aa..b6e1b0ebe230075292d5c2f4676f7bd9685e086d 100644 (file)
@@ -26,6 +26,7 @@
  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *****************************************************************************/
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/debugfs.h>
index 36580d8d8b8db4cbb6e5b38b2242d69ec8153045..2ffc2edbf4f08c0e189a09802f62080e31281aca 100644 (file)
@@ -28,6 +28,8 @@
 
 /* sparse doesn't like tracepoint macros */
 #ifndef __CHECKER__
+#include "iwl-dev.h"
+
 #define CREATE_TRACE_POINTS
 #include "iwl-devtrace.h"
 
index ff4d012ce2600dfbaf5ac7317138daa628e15880..ae7319bb3a9973f675e409d8e7c64968069adbcd 100644 (file)
@@ -28,7 +28,6 @@
 #define __IWLWIFI_DEVICE_TRACE
 
 #include <linux/tracepoint.h>
-#include "iwl-dev.h"
 
 #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
 #undef TRACE_EVENT
index fd37152abae3afe3f393e99ce93e929e36f50576..fb5bb487f3bc9991bbfd63ecb645454fae161202 100644 (file)
@@ -63,6 +63,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #include <net/mac80211.h>
index c719baf2585a49583f2cef7a4b02107e044830a5..16eb3ced9b30c1f9301f0327b31487322c2248c3 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/io.h>
 
+#include "iwl-dev.h"
 #include "iwl-debug.h"
 #include "iwl-devtrace.h"
 
index 1a1a9f081cc712288b552e49f667601bc7e5d5a9..548dac2f6a960363b5046f1df0e8f5cf034941ae 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 
 #include <net/mac80211.h>
index df257bc15f495c02fff299ef1c91f46836772419..e5eb339107ddfd6ef65c838a14a9d2cbf9b2ae49 100644 (file)
@@ -28,6 +28,7 @@
  *****************************************************************************/
 
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include <asm/unaligned.h>
 #include "iwl-eeprom.h"
index bd2f7c420563611bbba6437c7fb51b9134417164..9ab0e412bf10a5f86a1dbdbc29a6cab21f00b28e 100644 (file)
@@ -25,6 +25,7 @@
  *  Intel Linux Wireless <ilw@linux.intel.com>
  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  *****************************************************************************/
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/etherdevice.h>
 #include <net/mac80211.h>
index 1ed5206721ecb587688bbd8b463f172e0f5d2de1..f0b7e6cfbe4fa23f94a8fdc9535533a5e9eb571a 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/etherdevice.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "iwl-eeprom.h"
 #include "iwl-dev.h"
@@ -124,7 +125,7 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
        if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed)
                priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
        else {
-               IWL_ERR(priv, "free more than tfds_in_queue (%u:%d)\n",
+               IWL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n",
                        priv->stations[sta_id].tid[tid].tfds_in_queue,
                        freed);
                priv->stations[sta_id].tid[tid].tfds_in_queue = 0;
index 54daa38ecba3b1475bcff226be08b8be1375f9d1..b55e4f39a9e17ef13d71c8657bf4f7915c08668f 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
@@ -1955,7 +1956,7 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv,
 {
        int i;
 
-       for (i = 0; i < IWL_RATE_COUNT; i++) {
+       for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) {
                rates[i].bitrate = iwl3945_rates[i].ieee * 5;
                rates[i].hw_value = i; /* Rate scaling will work on indexes */
                rates[i].hw_value_short = i;
@@ -3921,7 +3922,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
                BIT(NL80211_IFTYPE_STATION) |
                BIT(NL80211_IFTYPE_ADHOC);
 
-       hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY |
+       hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
                            WIPHY_FLAG_DISABLE_BEACON_HINTS;
 
        hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
index 7c4f44a9c3e6b2a8429fe168a08ce53588feb9c8..a1d45cce0ebcab1f7b92568cafacf0dea4537014 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/cfg80211.h>
 
 #include "iwm.h"
index 1e41ad0fcad5c8cd5989dcadf0fa1345e6634dc5..42df7262f9f7391d1c71faed6193ea3066052428 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ieee80211.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "iwm.h"
 #include "bus.h"
index c29c994de0e252867eeba263a032fca5b4982f70..cbb81befdb5596ed85eb3af77fd84a095d777bbb 100644 (file)
@@ -21,6 +21,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
index 8091421ee5e5da1d1a94595f89d147fff1e62f52..e80e776b74f78a35aebd708a6da2d38416fa8b73 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "iwm.h"
 #include "umac.h"
index d13c8853ee8281048ac836cd26f2f2c5ca8303f1..229de990379c151b5b1a31c2434b92a7b488bc31 100644 (file)
@@ -98,6 +98,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include "iwm.h"
 #include "bus.h"
index 7f34d6dd3c41a8158055798c665293aada555419..23856d359e123b40ce080a2f6f7511c3fcc258bd 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/sched.h>
 #include <linux/ieee80211.h>
 #include <linux/wireless.h>
+#include <linux/slab.h>
 
 #include "iwm.h"
 #include "debug.h"
index c4c0d23c63ecbcefc6a8b7896849bbd779ece0dc..13a69ebf2a94cbe67834f5dd9dec9c752e6deaf2 100644 (file)
@@ -46,6 +46,7 @@
  *              -> sdio_disable_func()
  */
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include "iwm.h"
 #include "commands.h"
index 8456b4dbd14694dd22fbbfad751a07daeeac8533..3257d4fad835a03c3cd45e01abca00b60f453142 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/ieee80211.h>
 #include <linux/if_arp.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 
 #include "iwm.h"
index a7ec7eac913796576a191653816663c4198232cb..1eafd6dec3fd1536766983f8c5a67ef994cbb0a2 100644 (file)
@@ -63,6 +63,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/debugfs.h>
 #include <linux/mmc/sdio_ids.h>
index 55905f02309c1d2a41fbf4e9022fdcbca49b8e6f..f6a02f123f31b182927b2071627eb7de274e372e 100644 (file)
@@ -64,6 +64,7 @@
  * (i.e. half of the max size). [iwm_tx_worker]
  */
 
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/ieee80211.h>
index f03d5e4e59c31c1da78c271d4665f158825c712f..12a2ef9dacea9aca87c59f0cd8d41b2d8732d6c1 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ieee80211.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/lib80211.h>
 
 #include "assoc.h"
index 4396dccd12ac127b27dda8134e1edefccd00324a..ce7bec402a33bbc885647b733d0e00dff50c6022 100644 (file)
@@ -6,6 +6,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <net/cfg80211.h>
 
 #include "cfg.h"
@@ -172,6 +173,8 @@ int lbs_cfg_register(struct lbs_private *priv)
        if (ret < 0)
                lbs_pr_err("cannot register wiphy device\n");
 
+       priv->wiphy_registered = true;
+
        ret = register_netdev(priv->dev);
        if (ret)
                lbs_pr_err("cannot register network device\n");
@@ -190,9 +193,11 @@ void lbs_cfg_free(struct lbs_private *priv)
        if (!wdev)
                return;
 
-       if (wdev->wiphy) {
+       if (priv->wiphy_registered)
                wiphy_unregister(wdev->wiphy);
+
+       if (wdev->wiphy)
                wiphy_free(wdev->wiphy);
-       }
+
        kfree(wdev);
 }
index 82371ef395241901d175ea73ed6dddfa755d5ff6..cdb9b9650d73aaf1de0114966e398defa4cae8d1 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/kfifo.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "host.h"
 #include "decl.h"
index e7470442f76b5852bebf6661622d98f7a4dd772b..88f7131d66e9cba7e62f6a46076a2878a3c05716 100644 (file)
@@ -2,6 +2,7 @@
   * This file contains the handling of command
   * responses as well as events generated by firmware.
   */
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/if_arp.h>
index 587b0cb0088da57baa26be6fe34059bf0aeac670..a48ccaffb288a785c78c944953943cf5296eed9b 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 #include <net/lib80211.h>
 
index 6977ee82021411ecebba130a2a10c6b5c40992df..6875e1498bd57e36f54e826c763bb041a9bd3283 100644 (file)
@@ -36,6 +36,7 @@ struct lbs_private {
 
        /* CFG80211 */
        struct wireless_dev *wdev;
+       bool wiphy_registered;
 
        /* Mesh */
        struct net_device *mesh_dev; /* Virtual device */
index 1f6cb58dd66c08051a78f4b081f92f8790d65c95..6d55439a7b97a59f32a309cc43a35ca7484b7178 100644 (file)
@@ -22,6 +22,7 @@
 */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
index 7a73f625273ba7730aac480e377a85df64161aa5..7d1a3c6b6ce0cd0f86b05d7a8959bafcf6d97feb 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/netdevice.h>
 #include <linux/delay.h>
index 3ea03f259ee764c864b29fc819917f7750d4c2ae..fe3f08028eb3a07881ea62bc33cc34b931d34883 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/semaphore.h>
+#include <linux/slab.h>
 #include <linux/spi/libertas_spi.h>
 #include <linux/spi/spi.h>
 
index 65e174595d12f89bbd8fcdc2fb1ae9ba9d1a6b01..fcea5741ba62b9c295cea309de05f21fb9f285e9 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #ifdef CONFIG_OLPC
index 28a1c9d1627a7cb0a73c36d07b25d594d17d00d3..598080414b173654f25fb6d4767298b23462b865 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kfifo.h>
 #include <linux/stddef.h>
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
 
index 2daf8ffdb7e18ee8ef0ee9d593b51d4c2b8cb8cd..784dae7147055b64b91821b5366887e4c72c6bb0 100644 (file)
@@ -2,6 +2,7 @@
   * This file contains the handling of RX in wlan driver.
   */
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include "host.h"
index 220361e69cd3adc7a8a2f680457b49cec2711aaa..24cd54b3a8060955ec7138caf30ce4c95aa5416c 100644 (file)
@@ -4,6 +4,7 @@
   * IOCTL handlers as well as command preperation and response routines
   *  for sending scan commands to the firmware.
   */
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/etherdevice.h>
index 71f88a08e0906200b6053fcb5875dbeed91da894..9b555884b08a99dd1c936f49245549a5b87266db 100644 (file)
@@ -2,6 +2,7 @@
   * This file contains ioctl functions
   */
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/if.h>
 #include <linux/if_arp.h>
index 28790e03dc43ef797a2150d9cbb48a1afdf99a76..b620daf59ef7fa3927c3e323779d70d3ec4e49bd 100644 (file)
@@ -7,6 +7,8 @@
  *  the Free Software Foundation; either version 2 of the License, or (at
  *  your option) any later version.
  */
+#include <linux/slab.h>
+
 #include "libertas_tf.h"
 
 static const struct channel_range channel_ranges[] = {
index 3691c307e6741950f499889756c746fb37f73178..8cc9db60c14b5c8e52fe8183feac773406cdcbc1 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #define DRV_NAME "lbtf_usb"
index 6ab30033c26c07fff18b1c54a0fc5d1bd19cca82..7945ff5aa3345fc5013ed7942878b598483482b4 100644 (file)
@@ -7,6 +7,8 @@
  *  the Free Software Foundation; either version 2 of the License, or (at
  *  your option) any later version.
  */
+#include <linux/slab.h>
+
 #include "libertas_tf.h"
 #include "linux/etherdevice.h"
 
index 6ea77e95277ba52d4b04fe58ef38bf76ff16bba6..7cd5f56662fcfe1176deeeffc2a010b7ed843a3e 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <net/dst.h>
 #include <net/xfrm.h>
index ac65e13eb0de8ea31fed54c02dd42add8528b85f..12fdcb25fd382dfc245aafd85dcb462ebdfa8f77 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/completion.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
@@ -3851,6 +3852,7 @@ MODULE_FIRMWARE("mwl8k/helper_8366.fw");
 MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
 
 static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
+       { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
        { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
        { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
        { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = MWL8687, },
index cfa72962052bca7db982368db0441233743b80c7..5ea0f7cf85b1d2f8653eb0941f2a50eeaf7861dc 100644 (file)
@@ -3,6 +3,7 @@
  * See copyright notice in main.c
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/device.h>
 
index b42634c614b5814a9822ef3011efd11b6ab30345..413e9ab6cab3bb1fb70782f85c07066ec55eac31 100644 (file)
@@ -78,6 +78,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/device.h>
index d2f10e9c21627a71059b82b5992d6a5ac47bf212..330d42d453330ddbe7209fe81cff1de7b1f2b608 100644 (file)
@@ -3,6 +3,7 @@
  * See copyright notice in main.c
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ieee80211.h>
index 31ca241f775351a7129ff3007c1eea0f6e621b0d..fbcc6e1a2e1d55f9631304e1f4562db55118bb01 100644 (file)
@@ -2,6 +2,7 @@
  *
  * See copyright notice in main.c
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
 #include <linux/wireless.h>
index 8e3818f6832e12987b6294eb4fdb304e0454ede1..187e263b045ae813dae3fb59a7c0b27b9d85c4fe 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
 #include <linux/sort.h>
+#include <linux/slab.h>
 
 #include <net/mac80211.h>
 
index e7b9e9cb39f5520d2cacd2bf0f89eeb37accd156..c43a5d461ab21feb6a2e9ad98854bb929c06e770 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
 
index 4f752a21495f77aa265a6569e8548beb953c9c58..a7cb9eb759a154023acbaa72e87a1d42788727c2 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
 
index ed4bdffdd63e4ede90f262760dd1abbae27ffb88..269fda362836befbf3c95e4ccc576998d1ab9126 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
index afd26bf06649a06690bf7e29a67592c00151a5b9..c8f09da1f84df425dacdd5a29a55cb4479d4ad37 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/spi/spi.h>
 #include <linux/etherdevice.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include "p54spi.h"
 #include "p54spi_eeprom.h"
index b3c4fbd80d8d42cc4af9f98758b871cf68b87b54..743a6c68b29d023cf9e5be018a46390d32b50a55 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/usb.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
@@ -35,6 +36,7 @@ MODULE_FIRMWARE("isl3887usb");
 static struct usb_device_id p54u_table[] __devinitdata = {
        /* Version 1 devices (pci chip + net2280) */
        {USB_DEVICE(0x0506, 0x0a11)},   /* 3COM 3CRWE254G72 */
+       {USB_DEVICE(0x06b9, 0x0120)},   /* Thomson SpeedTouch 120g */
        {USB_DEVICE(0x0707, 0xee06)},   /* SMC 2862W-G */
        {USB_DEVICE(0x07aa, 0x001c)},   /* Corega CG-WLUSB2GT */
        {USB_DEVICE(0x083a, 0x4501)},   /* Accton 802.11g WN4501 USB */
index f7f5c793514b2516e1f0b8d0c21362b543314bb6..a45818ebfdfb250b991d14983de249b3c2ee82bb 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 
 #include <asm/uaccess.h>
index a3ba3539db027df101ce154d986ff1645be71fee..689d59a13d5b295b0db107807ee9ef22a2131af0 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/netdevice.h>
 #include <linux/ethtool.h>
index 872b64783e780e8bf2e1570348114195457b94d8..ac99eaaeabcee9831afdf5928271b6cc431e7d28 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 
 #include <linux/pci.h>
 #include <linux/delay.h>
index 69d2f882fd065e18af75ac62ca88fec3e776ab39..adb289723a967e5fe474332e1c256b7aa94649ad 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/system.h>
index 87a1734663dac15fb91b5ce599e20970cf3a1d8a..0b27e50fe0d5420d2d0273801bdecec4f4d7c61f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/wireless.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 /*
  *  Function definitions
index 1187e6112a641ee1de6cbc6c8ac80d1cee4a40d9..d66933d70fb9cac31c0ce007e05de592dcabca99 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "prismcompat.h"
 #include "islpci_dev.h"
index 84c530aa52f9d42f11f3f62f816c8fdd95767b43..11865ea21875331c53b6b2850a0f01f8c3ab5f5c 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/proc_fs.h>
 #include <linux/ptrace.h>
 #include <linux/seq_file.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/init.h>
index 2887047069f217824c9d21cec142167ae1f42fbc..1de5b22d3efe8402a514d769ebd893c1a5d3549a 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/if_arp.h>
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
 #include <linux/usb/usbnet.h>
index c22b04042d5cacc8f4813f2445fa908045227e57..5f5204b8289178941f579ea81319230ced397e77 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/eeprom_93cx6.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00pci.h"
index 52bbcf1bd17c4f51d1114ffb9213518908c730f6..2a73f593aab0cb82ef4bdaa1e949b82cd7e7d4a2 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/eeprom_93cx6.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00pci.h"
index 9b04964deced458e85a8c814580db05052838fb3..8ebb705fe106f6c6403bcc953c6e04d18a9403dd 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "rt2x00.h"
@@ -1642,6 +1643,11 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
        char *tx_power;
        unsigned int i;
 
+       /*
+        * Disable powersaving as default.
+        */
+       rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
+
        /*
         * Initialize all hw fields.
         */
index 18d4d8e4ae6ba587734574b2095cc435a7fd5e49..c015ce9fdd09925da8e46dff2495c9d69e24d7a8 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
@@ -812,9 +813,9 @@ static void rt2800_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
        rt2800_rfcsr_write(rt2x00dev, 24,
                              rt2x00dev->calibration[conf_is_ht40(conf)]);
 
-       rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
+       rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
        rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
-       rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
+       rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
 }
 
 static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
index 28a1c46ec4eb28194e315a3a3c22baacc059b762..9569fb4e5bc5625b5586b13294b6435fbb83e398 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #include "rt2x00.h"
index dd5ab8fe232180dfc0a44c19330d649780a171ae..eda73ba735a6e388ed8d9f68d22668af84ead912 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00lib.h"
index 047123b766fce5576bd6f1ff3d297ec87ef6767f..cf3f1c0c43822fe70d0390bfd4ff060c306c07c3 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00pci.h"
index 5b6b789cad3d6a4f0bd88ad0747e53aabcaf4774..a0bd36fc4d2e928227478f7b7f266978ccb4813b 100644 (file)
@@ -24,6 +24,7 @@
        Abstract: rt2x00 queue specific routines.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
index 111c0ff5c6c79f500fb20a9c868261dc36e64e04..fc98063de71dab47d265e0b7c3f5084b68a6728d 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "rt2x00.h"
 #include "rt2x00soc.h"
index 0a751e73aa0f6ecb341b59a314b8d14e9179ac98..f9a7f8b1741134e57e840ea01baa0bb4ace149b8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/bug.h>
 
index 17747274217243792f462cf9e6c0009cd674f44f..432e75f960b72d409cb3f925fb3249312eff6071 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/eeprom_93cx6.h>
 
index 290d70bc5d221a74bd353ad4a5b8feb554959a7d..bb58d797fb72910afdd0598450d3323732bcd8ce 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "rt2x00.h"
index 2b928ecf47bdb9815289bf35819bd4fbe4cc42b9..2131a442831aa678746bf359d03e46a1745c9f06 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
 #include <linux/eeprom_93cx6.h>
index 0fb850e0c6569ca991ba03b59e2fec76626bfa4e..1d30792973f5ef78dfaad45ea439f23c159618c2 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/init.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
 #include <linux/eeprom_93cx6.h>
index beff084040b569499efae9dc637a15bb25be3c34..91891f9280706266b2ab8e6f8d283e587d833c70 100644 (file)
@@ -1,6 +1,7 @@
 #include "wl1251_acx.h"
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/crc7.h>
 
 #include "wl1251.h"
index 28a808674080952b73e1615fefcba75d784ef406..d5ac79aeaa735cecdca705f6e556b774807c69c6 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include "wl1251_reg.h"
 #include "wl1251_boot.h"
index 0320b478bb3f0dfde1fc6cfbee04859fe9b01a35..a37b30cef4894c6da466989be64546de3f38af94 100644 (file)
@@ -1,6 +1,7 @@
 #include "wl1251_cmd.h"
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/crc7.h>
 
 #include "wl1251.h"
index 0ccba57fb9fb9548eaceaf267481af256f9928d3..5e4465ac08fadbbb435db0ad890edc4d610e2ae6 100644 (file)
@@ -24,6 +24,7 @@
 #include "wl1251_debugfs.h"
 
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include "wl1251.h"
 #include "wl1251_acx.h"
@@ -466,7 +467,8 @@ out:
 
 void wl1251_debugfs_reset(struct wl1251 *wl)
 {
-       memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
+       if (wl->stats.fw_stats != NULL)
+               memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
        wl->stats.retry_count = 0;
        wl->stats.excessive_retries = 0;
 }
index 5aad56ea71536fa1dbc5875d601f7bd76eaae961..b538bdd7b320f41e8abdf2516d755179d780f94e 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "wl1251_init.h"
 #include "wl12xx_80211.h"
index 24ae6a360ac8f6e09ca719e6f48bfede224df683..1c8226eee40938aafc13cbb89e1797305c8e5df9 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/crc32.h>
 #include <linux/etherdevice.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include "wl1251.h"
 #include "wl12xx_80211.h"
index b56732226cc09943638b976b0e4c95114ad7b15a..6f229e0990f4efc45d3a54facaad939d994cbf3c 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/skbuff.h>
+#include <linux/gfp.h>
 #include <net/mac80211.h>
 
 #include "wl1251.h"
index 9cc8c323830fdf8a34f5bf49cd7c43206fd523ea..3bfb59bd4635413422c3031625c5fb89c090ab0d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/crc7.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/wl12xx.h>
index 60f10dce48000f7a54dbaa7bd7b91ce10a9af636..308782421fce5afb777b22caa755e2c395e6fc9f 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/crc7.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 #include "wl1271.h"
 #include "wl12xx_80211.h"
index 2be76ee42bb9b2a4aeda9a40a5ac46153fa97fe0..0243562630657098d5b3f05802500f5d151c8704 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include "wl1271_acx.h"
 #include "wl1271_reg.h"
index 36a64e06f2907c3b088de1cd6b351717b123c896..e7832f3318eba7e38629e3f43adce326c6a6f411 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/crc7.h>
 #include <linux/spi/spi.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 
 #include "wl1271.h"
 #include "wl1271_reg.h"
index 8d7588ca68fd0c14adc8c6508d1ab5456b674cf9..3f7ff8d0cf5acc3f2c48e7eb820bc034aff6bb05 100644 (file)
@@ -24,6 +24,7 @@
 #include "wl1271_debugfs.h"
 
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include "wl1271.h"
 #include "wl1271_acx.h"
index 86c30a86a456cd5952f2b28c5ee65baaf9763fe7..d189e8fe05a645a268f4a315b5b0798b44ca04af 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "wl1271_init.h"
 #include "wl12xx_80211.h"
index 2a864b24291da705e47a38bf5874a7dbaf657f39..65a1aeba2419116f793a5cfba18ffae7b44839d7 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/vmalloc.h>
 #include <linux/spi/wl12xx.h>
 #include <linux/inetdevice.h>
+#include <linux/slab.h>
 
 #include "wl1271.h"
 #include "wl12xx_80211.h"
index 6730f5b96e76a7e2baa2ba6ec7dd0c0726828149..c723d9c7e1310c4eb7f263f4405786832b6ef80b 100644 (file)
@@ -21,6 +21,8 @@
  *
  */
 
+#include <linux/gfp.h>
+
 #include "wl1271.h"
 #include "wl1271_acx.h"
 #include "wl1271_reg.h"
index 67a82934f36eca4e8344fcfecb6e43442de625f9..053c84aceb4900263ddcd40b188467bfd4e73ce7 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/platform_device.h>
 #include <linux/crc7.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 #include "wl1271.h"
 #include "wl12xx_80211.h"
index 3919102e942e012509659e2038b6b09c118252a9..5c1c4f565fd8be475f3665316a1a6b931bd31497 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include "wl1271_testmode.h"
 
+#include <linux/slab.h>
 #include <net/genetlink.h>
 
 #include "wl1271.h"
index 6917286edcae555df02297b793ac6f42b6d91692..9d12778746452161990e55363487b312dc449be8 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
index 7ca95c414fa83d9e6b19e7fccb1b4ee43c7965a6..b2af3c549bb39e21010051f55a3eaa21df00a30a 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include "zd_def.h"
 #include "zd_chip.h"
index 00e09e26c826e444dfb9eec223b653012917f8c4..16fa289ad77b20367aeff3cd9f1327eb66b25f0c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/jiffies.h>
 #include <net/ieee80211_radiotap.h>
index 439799b84876b9f597d0ec8004f2fae39f9a67a4..9e74eb1b67d508ac6e16a9462899eb5744ae7229 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "zd_rf.h"
 #include "zd_usb.h"
index 442fc1117326bbaefdb11975c7166d8cf8387987..d91ad1a612afd23ef64a0045cc41e70ce99537f8 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/firmware.h>
 #include <linux/device.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/usb.h>
 #include <linux/workqueue.h>
index a869b45d3d37b2f38a986c4dfb0146d10be4416d..d504e2b6025705ded7ee1ac4524791818d8c5ec5 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/udp.h>
 #include <linux/moduleparam.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 
 #include <xen/xen.h>
index 1a74594224b1b8303c74b4247b444cf251e58119..1e783ccc306ebe7866de609f2df0c4ff5a277ca3 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
index 389ba9df71206a12f933b3b5931499c8a6b3337e..fdba9cb3a599e65b77522008930f98226722f4c4 100644 (file)
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
+#include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -33,6 +33,7 @@
 #include <linux/skbuff.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/pgtable.h>
index 7d4107f5eeb020d830a2e387dd275fdd47164b36..ede5b2436f2271f31743cd1efa285b281bf1a6c2 100644 (file)
@@ -90,7 +90,6 @@ static int gx_fix;
 #include <linux/timer.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/init.h>
index def49d2ec69ac8c29695ddfced8aec23e8b4cc4d..dbfef8d70f2dfdf7660496c473308b5302f1b1d9 100644 (file)
@@ -88,6 +88,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
index f5f75844954cf829641774ec940307fd8e71b635..b764ac22d523276a59c4055b914cba90f7e13d64 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/setup.h>
 #include <asm/system.h>
 #include <asm/page.h>
index cb96888d142785c4f9ea82f19e1de26ffcd448c7..b5ad9740d8b21a6eb6b3e3f3bd1586e8a5645426 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 
 struct device_node *allnodes;
index 406757a9d7ea62056680808392acd02e2889cda9..dee4fb56b094106381dc891d94bdc47341480131 100644 (file)
@@ -376,8 +376,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
                if (!np->type)
                        np->type = "<NULL>";
        }
-       while (tag == OF_DT_BEGIN_NODE) {
-               mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
+       while (tag == OF_DT_BEGIN_NODE || tag == OF_DT_NOP) {
+               if (tag == OF_DT_NOP)
+                       *p += 4;
+               else
+                       mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
                tag = be32_to_cpup((__be32 *)(*p));
        }
        if (tag != OF_DT_END_NODE) {
index 24c3606217f86a5db00bbf36547ba90d0489e2b2..a1b31a4abae4479e647e3e1a5eacd314139fbad1 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 #include <linux/of_gpio.h>
 #include <asm/prom.h>
 
index c9e2ae90f19508db8f74f91440636689d50321d8..a9352b2c7ac430d4e4aafac3d65a1b46005ea505 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/fs.h>
 #include <linux/oprofile.h>
 #include <linux/sched.h>
+#include <linux/gfp.h>
 
 #include "oprofile_stats.h"
 #include "event_buffer.h"
index 9ca21098b146c73e54e0facbf101e657e21ddaa0..6a1ab2512a53625aea4f54ae842bef2c38e77649 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/io.h>
 #include <asm/led.h>
index 356b8357bcccefc0dba8e2fa3e91fe53766c6878..f78f6f1aef47409f6066ea68560690c87dd386e7 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 
index c4e1f3c3c2fadd9cc1c4bf6f5e6561e803b3002d..20a1bce1a03163e4a9cb9b983a7bd8e00b5bb517 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <asm/hardware.h>
index 3c8f06c3a5a07acc4c1f041fee7c495a2386c53e..5bed17f68ef4d164bdef53a22c6c0c65c6e83e8c 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/parport.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 
 #include <asm/current.h>
index 6938d2e9f18f8171d41adcaa0e33e1e487334305..2c5ac2bf5c565ecd03041b4b9117f8742fb877bf 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 6d58bf895b1ac8690d786ad390e6b7c282ce5f62..d3d7809af8bf5287653ebe4b3e968489eba2c4cd 100644 (file)
 #include <linux/module.h>
 #include <linux/parport.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/stddef.h>
 #include <linux/types.h>
index c3bb84ac931ee577645aa13db06c8cdb9778c783..40e208d130f5b8ccf5a6e95be316f8af7e35440a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/parport.h>
index 0f6550719bcf179d9fc493407b5d2a3dc38f447a..d763bc9e44c1c1a0e98d7f69b490afdc0721004e 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/parport.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 static const struct {
index db23200c487426d6fd9d9b04e53e518b88ebd50f..2f646fe1260f3831b13036cdfd5b26cb56078c8e 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/wait.h>
 
index 26301cb25e7f7cc682bd0f5ce102466a7810088b..628ea20a884190afbbffff2f80e0faf5cbaade1b 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/ioport.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include "pci.h"
 
index 83aae47475940b383fe89c5fd3cf30c7c7cb3ec4..33ead97f0c4b24e2e030ae913bef26cdf435d533 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/tboot.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 
 #define PREFIX "DMAR: "
 
index 3c76fc67cf0e62f8598877881ce40efb0c7a12ae..45fcc1e96df9ac08718696e7ea8a8f487f33072f 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/pci_hotplug.h>
 #include <linux/acpi.h>
 #include <linux/pci-acpi.h>
+#include <linux/slab.h>
 
 #define MY_NAME        "acpi_pcihp"
 
index b5dad9f374537a92012fbd4dc274b0b076458fcb..cb23aa2ebf96b1c768b6c2edae033984c2959fac 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/pci_hotplug.h>
 #include <linux/pci-acpi.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include "../pci.h"
 #include "acpiphp.h"
index aa5df485f8cf8e8b029e23b99f0f7780f67f4e58..6ecbfb27db9d1c95fa00d2c2e6bcf0a9395dcfff 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <acpi/acpi_bus.h>
index e6089bdb6e5bddbc2b08e09c9419d26056e543e7..56215322930ad143c5d0d3adba42823d70f77c12 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/workqueue.h>
index 0a894efd4b9b34da6ddcaacd84c62cafd2a859d2..5317e4d7d96eab58ac6c24a450022ae82a5c13e5 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include "../pci.h"
 
 struct legacy_slot {
index 728b119f71ad4dbaadfe65ce51ce1e7b1271bf99..6d2eea93298fbbcf31afb03cba64b262b228e313 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
 #include <linux/pagemap.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
index b09b083011d69ad43e743490bad963266f6af36b..1f4000a5a108fa8d9f57383ffc03f9313c9fc2c0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/acpi.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
+#include <linux/slab.h>
 #include "pciehp.h"
 
 #define PCIEHP_DETECT_PCIE     (0)
index 920f820edf8798dd4c75103d7969eb4061a8d8a5..3588ea61b0dd244df58ac3fdc92adc61cdc512be 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include "pciehp.h"
index 9a7f247e8ac155e164158da9fe13fe8b8a640b2c..8f58148be044ae3a53e1b7b0419f222698a76558 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/workqueue.h>
 #include "../pci.h"
index 40b48f569b1e3daf9c6de0330f4f4f9f2fab4317..0cd42047d89b07fd965fcc757b49fa699b154dd8 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
+#include <linux/slab.h>
 
 #include "../pci.h"
 #include "pciehp.h"
@@ -832,9 +833,8 @@ static inline void dbg_ctrl(struct controller *ctrl)
        for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
                if (!pci_resource_len(pdev, i))
                        continue;
-               ctrl_info(ctrl, "  PCI resource [%d]     : 0x%llx@0x%llx\n",
-                         i, (unsigned long long)pci_resource_len(pdev, i),
-                         (unsigned long long)pci_resource_start(pdev, i));
+               ctrl_info(ctrl, "  PCI resource [%d]     : %pR\n",
+                         i, &pdev->resource[i]);
        }
        ctrl_info(ctrl, "Slot Capabilities      : 0x%08x\n", ctrl->slot_cap);
        ctrl_info(ctrl, "  Physical Slot Number : %d\n", PSN(ctrl));
index dcaae725fd791185278805bf2b5af343f2ccb290..7197022407802fea905fc9df905a6145c60749b3 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/init.h>
 #include <asm/eeh.h>       /* for eeh_add_device() */
index 8aebe1e9d3d6ae21c664f998a4192194547b7afe..72d507b6a2aa8d446d06fcbbcfc3aa68799434f5 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/mutex.h>
 
index a5062297f4886e255c6c9f006b1bc729460f84c6..a7bd5048396ed61ba1d379b713215c39725e0bd0 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/workqueue.h>
 #include "shpchp.h"
index 3bba0c0888ff180100d1d8ee1c2e58cbcf5dda73..3387fbfb0c54bed289e5a9ddfeac1f5bb36f653b 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/workqueue.h>
 #include "../pci.h"
index 737a1c44b07af9a8ed81ed6e2191fce7934603fd..98abf8b912943f12b6cbcdfe90e4779f3650294e 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
-#include <linux/gfp.h>
 #include <linux/htirq.h>
 
 /* Global ht irq lock.
index 95b849130ad41189ea2540272ffc84f5407a5bc6..6ee98a56946fff4a887b80f39c281ac495eb479b 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/interrupt.h>
 #include <linux/dmar.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/hpet.h>
 #include <linux/pci.h>
index 3e0d7b5dd1b904e0e02425f1ea005915cafb2610..203508b227b7ca383498a485947dbd482da98b7d 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/pci.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 
 struct ioapic {
@@ -31,9 +32,9 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
        acpi_status status;
        unsigned long long gsb;
        struct ioapic *ioapic;
-       u64 addr;
        int ret;
        char *type;
+       struct resource *res;
 
        handle = DEVICE_ACPI_HANDLE(&dev->dev);
        if (!handle)
@@ -69,13 +70,12 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
        if (pci_request_region(dev, 0, type))
                goto exit_disable;
 
-       addr = pci_resource_start(dev, 0);
-       if (acpi_register_ioapic(ioapic->handle, addr, ioapic->gsi_base))
+       res = &dev->resource[0];
+       if (acpi_register_ioapic(ioapic->handle, res->start, ioapic->gsi_base))
                goto exit_release;
 
        pci_set_drvdata(dev, ioapic);
-       dev_info(&dev->dev, "%s at %#llx, GSI %u\n", type, addr,
-                ioapic->gsi_base);
+       dev_info(&dev->dev, "%s at %pR, GSI %u\n", type, res, ioapic->gsi_base);
        return 0;
 
 exit_release:
index 3e5ab2bf6a5c05f7f87374b6f3a2955a1c32aa51..ce6a3666b3d9878f70be6fb65f3e1272fdf6b6b2 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/delay.h>
index f9cf3173b23dcc9e8bea22d1ff6679523bcb0944..77b68eaf021e43152c4bbd257bd190a4a210473c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/smp.h>
 #include <linux/errno.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include "pci.h"
 #include "msi.h"
index de296452c957b7fb7ecb352ed03b7926913c98a9..fad93983bfed09a2780822b8a8c36bad18a32828 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mm.h>
 #include <linux/capability.h>
 #include <linux/pci-aspm.h>
+#include <linux/slab.h>
 #include "pci.h"
 
 static int sysfs_initialized;  /* = 0 */
@@ -655,8 +656,8 @@ void pci_create_legacy_files(struct pci_bus *b)
                goto legacy_io_err;
 
        /* Allocated above after the legacy_io struct */
-       sysfs_bin_attr_init(b->legacy_mem);
        b->legacy_mem = b->legacy_io + 1;
+       sysfs_bin_attr_init(b->legacy_mem);
        b->legacy_mem->attr.name = "legacy_mem";
        b->legacy_mem->size = 1024*1024;
        b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;
index cb1dd5f4988c72d533cabefa9b6b540761c294d6..5ea587e59e48c8250be369f200872b36ec09df56 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/pm.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
@@ -2576,18 +2577,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function);
  */
 int pcix_get_max_mmrbc(struct pci_dev *dev)
 {
-       int err, cap;
+       int cap;
        u32 stat;
 
        cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
        if (!cap)
                return -EINVAL;
 
-       err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat);
-       if (err)
+       if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
                return -EINVAL;
 
-       return (stat & PCI_X_STATUS_MAX_READ) >> 12;
+       return 512 << ((stat & PCI_X_STATUS_MAX_READ) >> 21);
 }
 EXPORT_SYMBOL(pcix_get_max_mmrbc);
 
@@ -2600,18 +2600,17 @@ EXPORT_SYMBOL(pcix_get_max_mmrbc);
  */
 int pcix_get_mmrbc(struct pci_dev *dev)
 {
-       int ret, cap;
-       u32 cmd;
+       int cap;
+       u16 cmd;
 
        cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
        if (!cap)
                return -EINVAL;
 
-       ret = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd);
-       if (!ret)
-               ret = 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
+       if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
+               return -EINVAL;
 
-       return ret;
+       return 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
 }
 EXPORT_SYMBOL(pcix_get_mmrbc);
 
@@ -2626,28 +2625,27 @@ EXPORT_SYMBOL(pcix_get_mmrbc);
  */
 int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
 {
-       int cap, err = -EINVAL;
-       u32 stat, cmd, v, o;
+       int cap;
+       u32 stat, v, o;
+       u16 cmd;
 
        if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
-               goto out;
+               return -EINVAL;
 
        v = ffs(mmrbc) - 10;
 
        cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
        if (!cap)
-               goto out;
+               return -EINVAL;
 
-       err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat);
-       if (err)
-               goto out;
+       if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
+               return -EINVAL;
 
        if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21)
                return -E2BIG;
 
-       err = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd);
-       if (err)
-               goto out;
+       if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
+               return -EINVAL;
 
        o = (cmd & PCI_X_CMD_MAX_READ) >> 2;
        if (o != v) {
@@ -2657,10 +2655,10 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
 
                cmd &= ~PCI_X_CMD_MAX_READ;
                cmd |= v << 2;
-               err = pci_write_config_dword(dev, cap + PCI_X_CMD, cmd);
+               if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd))
+                       return -EIO;
        }
-out:
-       return err;
+       return 0;
 }
 EXPORT_SYMBOL(pcix_set_mmrbc);
 
@@ -3023,7 +3021,6 @@ EXPORT_SYMBOL(pcim_pin_device);
 EXPORT_SYMBOL(pci_disable_device);
 EXPORT_SYMBOL(pci_find_capability);
 EXPORT_SYMBOL(pci_bus_find_capability);
-EXPORT_SYMBOL(pci_register_set_vga_state);
 EXPORT_SYMBOL(pci_release_regions);
 EXPORT_SYMBOL(pci_request_regions);
 EXPORT_SYMBOL(pci_request_regions_exclusive);
index 223052b735634c697739ca37396d10154c93c72c..f8f425b8731ddb91f8663069da23495bf75befcb 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
 #include <linux/stddef.h>
index 21f215f4daa30cc090424ee25f4b24bb90d27115..aa495ad9bbd4b98ae78cac3623ff5bb9b9eeee69 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/pcieport_if.h>
+#include <linux/slab.h>
 
 #include "aerdrv.h"
 #include "../../pci.h"
index c843a799814d28fde6e8a4832edf986ccde977f0..aceb04b67b60f55979258256e84e93209faf3f24 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pm.h>
 #include <linux/suspend.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "aerdrv.h"
 
 static int forceload;
index 7b3cbff547ee9021ab1e680abf3c07ebf22b4b5a..aac285a16b62bec0f84690c5241c4ee82185e383 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
index 127e8f169d9c2409baa283ca48582e56cbde31fc..3debed25e46bb63f4e70e4a58b0d9abff3fd33be 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/errno.h>
 #include <linux/pm.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/pcieport_if.h>
 #include <linux/aer.h>
 #include <linux/dmi.h>
index 2a943090a3b7838b3a8fcb86a9caa89dfe611133..882bd8d29fe3c14903282c5c2ec20ea52b8a5347 100644 (file)
@@ -174,14 +174,19 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
        pci_read_config_dword(dev, pos, &sz);
        pci_write_config_dword(dev, pos, l);
 
+       if (!sz)
+               goto fail;      /* BAR not implemented */
+
        /*
         * All bits set in sz means the device isn't working properly.
-        * If the BAR isn't implemented, all bits must be 0.  If it's a
-        * memory BAR or a ROM, bit 0 must be clear; if it's an io BAR, bit
-        * 1 must be clear.
+        * If it's a memory BAR or a ROM, bit 0 must be clear; if it's
+        * an io BAR, bit 1 must be clear.
         */
-       if (!sz || sz == 0xffffffff)
+       if (sz == 0xffffffff) {
+               dev_err(&dev->dev, "reg %x: invalid size %#x; broken device?\n",
+                       pos, sz);
                goto fail;
+       }
 
        /*
         * I don't know how l can have all bits set.  Copied from old code.
@@ -244,13 +249,17 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
                                   pos, res);
                }
        } else {
-               sz = pci_size(l, sz, mask);
+               u32 size = pci_size(l, sz, mask);
 
-               if (!sz)
+               if (!size) {
+                       dev_err(&dev->dev, "reg %x: invalid size "
+                               "(l %#x sz %#x mask %#x); broken device?",
+                               pos, l, sz, mask);
                        goto fail;
+               }
 
                res->start = l;
-               res->end = l + sz;
+               res->end = l + size;
 
                dev_printk(KERN_DEBUG, &dev->dev, "reg %x: %pR\n", pos, res);
        }
@@ -312,7 +321,7 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
                dev_printk(KERN_DEBUG, &dev->dev, "  bridge window %pR\n", res);
        } else {
                dev_printk(KERN_DEBUG, &dev->dev,
-                        "  bridge window [io  %04lx - %04lx] reg reading\n",
+                        "  bridge window [io  %#06lx-%#06lx] (disabled)\n",
                                 base, limit);
        }
 }
@@ -336,7 +345,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child)
                dev_printk(KERN_DEBUG, &dev->dev, "  bridge window %pR\n", res);
        } else {
                dev_printk(KERN_DEBUG, &dev->dev,
-                       "  bridge window [mem 0x%08lx - 0x%08lx] reg reading\n",
+                       "  bridge window [mem %#010lx-%#010lx] (disabled)\n",
                                         base, limit + 0xfffff);
        }
 }
@@ -387,7 +396,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
                dev_printk(KERN_DEBUG, &dev->dev, "  bridge window %pR\n", res);
        } else {
                dev_printk(KERN_DEBUG, &dev->dev,
-                    "  bridge window [mem 0x%08lx - %08lx pref] reg reading\n",
+                    "  bridge window [mem %#010lx-%#010lx pref] (disabled)\n",
                                         base, limit + 0xfffff);
        }
 }
@@ -673,16 +682,20 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
        int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
        u32 buses, i, j = 0;
        u16 bctl;
+       u8 primary, secondary, subordinate;
        int broken = 0;
 
        pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
+       primary = buses & 0xFF;
+       secondary = (buses >> 8) & 0xFF;
+       subordinate = (buses >> 16) & 0xFF;
 
-       dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n",
-               buses & 0xffffff, pass);
+       dev_dbg(&dev->dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n",
+               secondary, subordinate, pass);
 
        /* Check if setup is sensible at all */
        if (!pass &&
-           ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) {
+           (primary != bus->number || secondary <= bus->number)) {
                dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
                broken = 1;
        }
@@ -693,15 +706,15 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
        pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
                              bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
 
-       if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) {
-               unsigned int cmax, busnr;
+       if ((secondary || subordinate) && !pcibios_assign_all_busses() &&
+           !is_cardbus && !broken) {
+               unsigned int cmax;
                /*
                 * Bus already configured by firmware, process it in the first
                 * pass and just note the configuration.
                 */
                if (pass)
                        goto out;
-               busnr = (buses >> 8) & 0xFF;
 
                /*
                 * If we already got to this bus through a different bridge,
@@ -710,13 +723,13 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
                 * However, we continue to descend down the hierarchy and
                 * scan remaining child buses.
                 */
-               child = pci_find_bus(pci_domain_nr(bus), busnr);
+               child = pci_find_bus(pci_domain_nr(bus), secondary);
                if (!child) {
-                       child = pci_add_new_bus(bus, dev, busnr);
+                       child = pci_add_new_bus(bus, dev, secondary);
                        if (!child)
                                goto out;
-                       child->primary = buses & 0xFF;
-                       child->subordinate = (buses >> 16) & 0xFF;
+                       child->primary = primary;
+                       child->subordinate = subordinate;
                        child->bridge_ctl = bctl;
                }
 
index 593bb844b8db68258a41647f709f1d5d6807640d..449e890267a2bae74de8a2b6b0bedf30023b7de0 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
index 81d19d5683ace216b2edd8728c0bde78f3fccf31..27c0e6eb7136030b8c419e91e2c3dae595322a0c 100644 (file)
@@ -368,8 +368,9 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,
                bus_region.end = res->end;
                pcibios_bus_to_resource(dev, res, &bus_region);
 
-               pci_claim_resource(dev, nr);
-               dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name);
+               if (pci_claim_resource(dev, nr) == 0)
+                       dev_info(&dev->dev, "quirk: %pR claimed by %s\n",
+                                res, name);
        }
 }      
 
@@ -1977,11 +1978,25 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
        /*
         * Disable PCI Bus Parking and PCI Master read caching on CX700
         * which causes unspecified timing errors with a VT6212L on the PCI
-        * bus leading to USB2.0 packet loss. The defaults are that these
-        * features are turned off but some BIOSes turn them on.
+        * bus leading to USB2.0 packet loss.
+        *
+        * This quirk is only enabled if a second (on the external PCI bus)
+        * VT6212L is found -- the CX700 core itself also contains a USB
+        * host controller with the same PCI ID as the VT6212L.
         */
 
+       /* Count VT6212L instances */
+       struct pci_dev *p = pci_get_device(PCI_VENDOR_ID_VIA,
+               PCI_DEVICE_ID_VIA_8235_USB_2, NULL);
        uint8_t b;
+
+       /* p should contain the first (internal) VT6212L -- see if we have
+          an external one by searching again */
+       p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, p);
+       if (!p)
+               return;
+       pci_dev_put(p);
+
        if (pci_read_config_byte(dev, 0x76, &b) == 0) {
                if (b & 0x40) {
                        /* Turn off PCI Bus Parking */
@@ -2008,7 +2023,7 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
                }
        }
 }
-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching);
 
 /*
  * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the
@@ -2108,6 +2123,10 @@ static void __devinit quirk_disable_msi(struct pci_dev *dev)
        }
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9602, quirk_disable_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASUSTEK, 0x9602, quirk_disable_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AI, 0x9602, quirk_disable_msi);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi);
 
 /* Go through the list of Hypertransport capabilities and
  * return 1 if a HT MSI capability is found and enabled */
index 4a471dc4f4b9c6167a11de5d8041df65aa371fc1..20d03f7722890807b5a128a2032878180794435d 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include "pci.h"
index 7d678bb15ffb30daed8bebf18d1ef5642a30a13b..17bed18d24ad10eb021e7d3148f8456ff5fe2277 100644 (file)
@@ -93,8 +93,7 @@ void pci_update_resource(struct pci_dev *dev, int resno)
 int pci_claim_resource(struct pci_dev *dev, int resource)
 {
        struct resource *res = &dev->resource[resource];
-       struct resource *root;
-       int err;
+       struct resource *root, *conflict;
 
        root = pci_find_parent_resource(dev, res);
        if (!root) {
@@ -103,12 +102,15 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
                return -EINVAL;
        }
 
-       err = request_resource(root, res);
-       if (err)
+       conflict = request_resource_conflict(root, res);
+       if (conflict) {
                dev_err(&dev->dev,
-                       "address space collision: %pR already in use\n", res);
+                       "address space collision: %pR conflicts with %s %pR\n",
+                       res, conflict->name, conflict);
+               return -EBUSY;
+       }
 
-       return err;
+       return 0;
 }
 EXPORT_SYMBOL(pci_claim_resource);
 
index f75a44d37fbed588ffda8a8742904eca4386b1cf..659eaa0fc48facf81dad9c0b5c430498e01398e3 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/kobject.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/err.h>
 #include "pci.h"
index 5d228071ec69b938fb860ef51470c3adc3ea8025..fb33fa42d249847d1c900a5c374b6859f3cd8dde 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include <pcmcia/ss.h>
 
@@ -361,7 +362,6 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
        struct at91_cf_socket   *cf = platform_get_drvdata(pdev);
        struct at91_cf_data     *board = cf->board;
 
-       pcmcia_socket_dev_suspend(&pdev->dev);
        if (device_may_wakeup(&pdev->dev)) {
                enable_irq_wake(board->det_pin);
                if (board->irq_pin)
@@ -381,7 +381,6 @@ static int at91_cf_resume(struct platform_device *pdev)
                        disable_irq_wake(board->irq_pin);
        }
 
-       pcmcia_socket_dev_resume(&pdev->dev);
        return 0;
 }
 
index 171c8a654887a65dcb91663e1173d48242923653..88c4c4098789e1e3e3b08dc3847412c570ebfc35 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -510,17 +511,6 @@ static int au1x00_drv_pcmcia_probe(struct platform_device *dev)
        return ret;
 }
 
-static int au1x00_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int au1x00_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-
 static struct platform_driver au1x00_pcmcia_driver = {
        .driver = {
                .name           = "au1x00-pcmcia",
@@ -528,8 +518,6 @@ static struct platform_driver au1x00_pcmcia_driver = {
        },
        .probe          = au1x00_drv_pcmcia_probe,
        .remove         = au1x00_drv_pcmcia_remove,
-       .suspend        = au1x00_drv_pcmcia_suspend,
-       .resume         = au1x00_drv_pcmcia_resume,
 };
 
 
index bc88a3b19bb349761be651054e070f1ff701d409..693577e0fefc3c52a037bd9af6e63567f67a43c8 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/ioport.h>
 #include <linux/timer.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/gpio.h>
index 2482ce7ac6dcb3f9845eeebe664ab30defeb76b8..9e84d039de41f8d4cf1bedf0ba5902244f25ea49 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/platform_device.h>
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -300,16 +301,6 @@ static int __devexit bfin_cf_remove(struct platform_device *pdev)
        return 0;
 }
 
-static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
-{
-       return pcmcia_socket_dev_suspend(&pdev->dev);
-}
-
-static int bfin_cf_resume(struct platform_device *pdev)
-{
-       return pcmcia_socket_dev_resume(&pdev->dev);
-}
-
 static struct platform_driver bfin_cf_driver = {
        .driver = {
                   .name = (char *)driver_name,
@@ -317,8 +308,6 @@ static struct platform_driver bfin_cf_driver = {
                   },
        .probe = bfin_cf_probe,
        .remove = __devexit_p(bfin_cf_remove),
-       .suspend = bfin_cf_suspend,
-       .resume = bfin_cf_resume,
 };
 
 static int __init bfin_cf_init(void)
index e679e708db630e3c8a93a7f6d87ded908a2c397e..75ed866e6953944c871dd46bfc94f4a54da997bd 100644 (file)
@@ -76,65 +76,6 @@ DECLARE_RWSEM(pcmcia_socket_list_rwsem);
 EXPORT_SYMBOL(pcmcia_socket_list_rwsem);
 
 
-/*
- * Low-level PCMCIA socket drivers need to register with the PCCard
- * core using pcmcia_register_socket.
- *
- * socket drivers are expected to use the following callbacks in their
- * .drv struct:
- *  - pcmcia_socket_dev_suspend
- *  - pcmcia_socket_dev_resume
- * These functions check for the appropriate struct pcmcia_soket arrays,
- * and pass them to the low-level functions pcmcia_{suspend,resume}_socket
- */
-static int socket_early_resume(struct pcmcia_socket *skt);
-static int socket_late_resume(struct pcmcia_socket *skt);
-static int socket_resume(struct pcmcia_socket *skt);
-static int socket_suspend(struct pcmcia_socket *skt);
-
-static void pcmcia_socket_dev_run(struct device *dev,
-                                 int (*cb)(struct pcmcia_socket *))
-{
-       struct pcmcia_socket *socket;
-
-       down_read(&pcmcia_socket_list_rwsem);
-       list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
-               if (socket->dev.parent != dev)
-                       continue;
-               mutex_lock(&socket->skt_mutex);
-               cb(socket);
-               mutex_unlock(&socket->skt_mutex);
-       }
-       up_read(&pcmcia_socket_list_rwsem);
-}
-
-int pcmcia_socket_dev_suspend(struct device *dev)
-{
-       pcmcia_socket_dev_run(dev, socket_suspend);
-       return 0;
-}
-EXPORT_SYMBOL(pcmcia_socket_dev_suspend);
-
-void pcmcia_socket_dev_early_resume(struct device *dev)
-{
-       pcmcia_socket_dev_run(dev, socket_early_resume);
-}
-EXPORT_SYMBOL(pcmcia_socket_dev_early_resume);
-
-void pcmcia_socket_dev_late_resume(struct device *dev)
-{
-       pcmcia_socket_dev_run(dev, socket_late_resume);
-}
-EXPORT_SYMBOL(pcmcia_socket_dev_late_resume);
-
-int pcmcia_socket_dev_resume(struct device *dev)
-{
-       pcmcia_socket_dev_run(dev, socket_resume);
-       return 0;
-}
-EXPORT_SYMBOL(pcmcia_socket_dev_resume);
-
-
 struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
 {
        struct device *dev = get_device(&skt->dev);
@@ -578,12 +519,18 @@ static int socket_early_resume(struct pcmcia_socket *skt)
 
 static int socket_late_resume(struct pcmcia_socket *skt)
 {
+       int ret;
+
        mutex_lock(&skt->ops_mutex);
        skt->state &= ~SOCKET_SUSPEND;
        mutex_unlock(&skt->ops_mutex);
 
-       if (!(skt->state & SOCKET_PRESENT))
-               return socket_insert(skt);
+       if (!(skt->state & SOCKET_PRESENT)) {
+               ret = socket_insert(skt);
+               if (ret == -ENODEV)
+                       ret = 0;
+               return ret;
+       }
 
        if (skt->resume_status) {
                socket_shutdown(skt);
@@ -919,11 +866,66 @@ static void pcmcia_release_socket_class(struct class *data)
 }
 
 
+#ifdef CONFIG_PM
+
+static int __pcmcia_pm_op(struct device *dev,
+                         int (*callback) (struct pcmcia_socket *skt))
+{
+       struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
+       int ret;
+
+       mutex_lock(&s->skt_mutex);
+       ret = callback(s);
+       mutex_unlock(&s->skt_mutex);
+
+       return ret;
+}
+
+static int pcmcia_socket_dev_suspend_noirq(struct device *dev)
+{
+       return __pcmcia_pm_op(dev, socket_suspend);
+}
+
+static int pcmcia_socket_dev_resume_noirq(struct device *dev)
+{
+       return __pcmcia_pm_op(dev, socket_early_resume);
+}
+
+static int pcmcia_socket_dev_resume(struct device *dev)
+{
+       return __pcmcia_pm_op(dev, socket_late_resume);
+}
+
+static const struct dev_pm_ops pcmcia_socket_pm_ops = {
+       /* dev_resume may be called with IRQs enabled */
+       SET_SYSTEM_SLEEP_PM_OPS(NULL,
+                               pcmcia_socket_dev_resume)
+
+       /* late suspend must be called with IRQs disabled */
+       .suspend_noirq = pcmcia_socket_dev_suspend_noirq,
+       .freeze_noirq = pcmcia_socket_dev_suspend_noirq,
+       .poweroff_noirq = pcmcia_socket_dev_suspend_noirq,
+
+       /* early resume must be called with IRQs disabled */
+       .resume_noirq = pcmcia_socket_dev_resume_noirq,
+       .thaw_noirq = pcmcia_socket_dev_resume_noirq,
+       .restore_noirq = pcmcia_socket_dev_resume_noirq,
+};
+
+#define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
+
+#else /* CONFIG_PM */
+
+#define PCMCIA_SOCKET_CLASS_PM_OPS NULL
+
+#endif /* CONFIG_PM */
+
 struct class pcmcia_socket_class = {
        .name = "pcmcia_socket",
        .dev_uevent = pcmcia_socket_uevent,
        .dev_release = pcmcia_release_socket,
        .class_release = pcmcia_release_socket_class,
+       .pm = PCMCIA_SOCKET_CLASS_PM_OPS,
 };
 EXPORT_SYMBOL(pcmcia_socket_class);
 
index 9254ab0b29b1b1262fdc1fdb9b1c705041128ae7..6206408e196cd9c2f0332fb89283c53368ce7811 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/resource.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <pcmcia/cs_types.h>
@@ -558,37 +559,10 @@ static int __devexit db1x_pcmcia_socket_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int db1x_pcmcia_suspend(struct device *dev)
-{
-       return pcmcia_socket_dev_suspend(dev);
-}
-
-static int db1x_pcmcia_resume(struct device *dev)
-{
-       return pcmcia_socket_dev_resume(dev);
-}
-
-static struct dev_pm_ops db1x_pcmcia_pmops = {
-       .resume         = db1x_pcmcia_resume,
-       .suspend        = db1x_pcmcia_suspend,
-       .thaw           = db1x_pcmcia_resume,
-       .freeze         = db1x_pcmcia_suspend,
-};
-
-#define DB1XXX_SS_PMOPS &db1x_pcmcia_pmops
-
-#else
-
-#define DB1XXX_SS_PMOPS NULL
-
-#endif
-
 static struct platform_driver db1x_pcmcia_socket_driver = {
        .driver = {
                .name   = "db1xxx_pcmcia",
                .owner  = THIS_MODULE,
-               .pm     = DB1XXX_SS_PMOPS
        },
        .probe          = db1x_pcmcia_socket_probe,
        .remove         = __devexit_p(db1x_pcmcia_socket_remove),
index ad93ebd7b2a2f8d3e5cdd65b07bff388d49e3db2..cb6036d89e598e79d01ce5dc7f4256dc361ee068 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/firmware.h>
 #include <linux/kref.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
@@ -509,8 +510,12 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
        p_dev->device_no = (s->device_count++);
        mutex_unlock(&s->ops_mutex);
 
-       /* max of 2 devices per card */
-       if (p_dev->device_no >= 2)
+       /* max of 2 PFC devices */
+       if ((p_dev->device_no >= 2) && (function == 0))
+               goto err_free;
+
+       /* max of 4 devices overall */
+       if (p_dev->device_no >= 4)
                goto err_free;
 
        p_dev->socket = s;
index 89cfddca089a7fea87e2e92dcdcb91aaf14adcae..2e59fe947d28095c15fb96327499e07edd8b32ea 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/of_platform.h>
+#include <linux/slab.h>
 
 #include <pcmcia/ss.h>
 
index f5da6265331331a5209f9a938d32b1d3989f430f..3003bb3dfcc0d08912897b2192e732ea26cccbf3 100644 (file)
@@ -39,27 +39,11 @@ static struct pci_device_id i82092aa_pci_ids[] = {
 };
 MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
 
-#ifdef CONFIG_PM
-static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int i82092aa_socket_resume (struct pci_dev *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-#endif
-
 static struct pci_driver i82092aa_pci_driver = {
        .name           = "i82092aa",
        .id_table       = i82092aa_pci_ids,
        .probe          = i82092aa_pci_probe,
        .remove         = __devexit_p(i82092aa_pci_remove),
-#ifdef CONFIG_PM
-       .suspend        = i82092aa_socket_suspend,
-       .resume         = i82092aa_socket_resume,
-#endif
 };
 
 
index c13fd9360511b89fe3b52f37477bb86a6dab5f1a..9e2a15628de57af889115628a3c9e4aaca7e4a60 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
@@ -1223,16 +1222,7 @@ static int pcic_init(struct pcmcia_socket *s)
        return 0;
 }
 
-static int i82365_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
 
-static int i82365_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
 static struct pccard_operations pcic_operations = {
        .init                   = pcic_init,
        .get_status             = pcic_get_status,
@@ -1248,8 +1238,6 @@ static struct platform_driver i82365_driver = {
                .name = "i82365",
                .owner          = THIS_MODULE,
        },
-       .suspend        = i82365_drv_pcmcia_suspend,
-       .resume         = i82365_drv_pcmcia_resume,
 };
 
 static struct platform_device *i82365_device;
index 0ece2cd4a85ea9640bd408fe0dc55ebe65a5692e..7e16ed8eb0a4e0b9ee3b425636fc2d52f0dd5ee1 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
@@ -685,16 +684,7 @@ static struct pccard_operations pcc_operations = {
        .set_mem_map            = pcc_set_mem_map,
 };
 
-static int cfc_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
 
-static int cfc_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
 /*====================================================================*/
 
 static struct platform_driver pcc_driver = {
@@ -702,8 +692,6 @@ static struct platform_driver pcc_driver = {
                .name           = "cfc",
                .owner          = THIS_MODULE,
        },
-       .suspend        = cfc_drv_pcmcia_suspend,
-       .resume         = cfc_drv_pcmcia_resume,
 };
 
 static struct platform_device pcc_device = {
index 72844c5a6d05fb53999ded835e5bf56f22ba6a21..6c5c3f910d71435ff542c71eab7e6a0285abfc42 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
@@ -663,16 +662,6 @@ static struct pccard_operations pcc_operations = {
        .set_mem_map            = pcc_set_mem_map,
 };
 
-static int pcc_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int pcc_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
 /*====================================================================*/
 
 static struct platform_driver pcc_driver = {
@@ -680,8 +669,6 @@ static struct platform_driver pcc_driver = {
                .name           = "pcc",
                .owner          = THIS_MODULE,
        },
-       .suspend        = pcc_drv_pcmcia_suspend,
-       .resume         = pcc_drv_pcmcia_resume,
 };
 
 static struct platform_device pcc_device = {
index 61c2159181288e5442381696b1eb60e2eaed8994..41cc954a5ffee1dd2a87bd4374bd69f22ddb4f9e 100644 (file)
@@ -42,7 +42,6 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
@@ -1288,21 +1287,6 @@ static int m8xx_remove(struct of_device *ofdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int m8xx_suspend(struct platform_device *pdev, pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&pdev->dev);
-}
-
-static int m8xx_resume(struct platform_device *pdev)
-{
-       return pcmcia_socket_dev_resume(&pdev->dev);
-}
-#else
-#define m8xx_suspend NULL
-#define m8xx_resume NULL
-#endif
-
 static const struct of_device_id m8xx_pcmcia_match[] = {
        {
         .type = "pcmcia",
@@ -1318,8 +1302,6 @@ static struct of_platform_driver m8xx_pcmcia_driver = {
        .match_table = m8xx_pcmcia_match,
        .probe = m8xx_probe,
        .remove = m8xx_remove,
-       .suspend = m8xx_suspend,
-       .resume = m8xx_resume,
 };
 
 static int __init m8xx_init(void)
index 3ef991552398095ddc9de8b7f2505be88108437f..a7cfc7964c7c6453d3e9de3e1c6e7d214d8f611f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include <pcmcia/ss.h>
 
@@ -330,24 +331,12 @@ static int __exit omap_cf_remove(struct platform_device *pdev)
        return 0;
 }
 
-static int omap_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
-{
-       return pcmcia_socket_dev_suspend(&pdev->dev);
-}
-
-static int omap_cf_resume(struct platform_device *pdev)
-{
-       return pcmcia_socket_dev_resume(&pdev->dev);
-}
-
 static struct platform_driver omap_cf_driver = {
        .driver = {
                .name   = (char *) driver_name,
                .owner  = THIS_MODULE,
        },
        .remove         = __exit_p(omap_cf_remove),
-       .suspend        = omap_cf_suspend,
-       .resume         = omap_cf_resume,
 };
 
 static int __init omap_cf_init(void)
index 13a7132cf6885577bbb096e24e87dd32d3fee754..104e73d5d86c02b2f4e0fa8df6a0326dbe7486aa 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/proc_fs.h>
 #include <linux/poll.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/smp_lock.h>
 #include <linux/workqueue.h>
index c4612c52e4cbb6a0b572e6dfde98d91f5c5a5ccf..caec1dee2a4bc9e9925ba1ed15c4fbce02933efd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/pci.h>
 #include <linux/device.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
index 7ba57a565cd72500d01a6666fde4d64ec4610fd7..b61a13663a0a79babf86a0d86722b76d8c02ad40 100644 (file)
@@ -9,18 +9,19 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
+#include <linux/io.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
 #include <pcmcia/cs.h>
 
 #include <asm/system.h>
-#include <asm/io.h>
 
 #include "pd6729.h"
 #include "i82365.h"
@@ -222,9 +223,9 @@ static irqreturn_t pd6729_interrupt(int irq, void *dev)
                                                ? SS_READY : 0;
                        }
 
-                       if (events) {
+                       if (events)
                                pcmcia_parse_events(&socket[i].socket, events);
-                       }
+
                        active |= events;
                }
 
@@ -256,9 +257,8 @@ static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
        status = indirect_read(socket, I365_STATUS);
        *value = 0;
 
-       if ((status & I365_CS_DETECT) == I365_CS_DETECT) {
+       if ((status & I365_CS_DETECT) == I365_CS_DETECT)
                *value |= SS_DETECT;
-       }
 
        /*
         * IO cards have a different meaning of bits 0,1
@@ -308,7 +308,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
        socket->card_irq = state->io_irq;
 
        reg = 0;
-       /* The reset bit has "inverse" logic */
+       /* The reset bit has "inverse" logic */
        if (!(state->flags & SS_RESET))
                reg |= I365_PC_RESET;
        if (state->flags & SS_IOCARD)
@@ -380,7 +380,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
                indirect_write(socket, I365_POWER, reg);
 
        if (irq_mode == 1) {
-                /* all interrupts are to be done as PCI interrupts */
+               /* all interrupts are to be done as PCI interrupts */
                data = PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ;
        } else
                data = 0;
@@ -391,9 +391,9 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
        /* Enable specific interrupt events */
 
        reg = 0x00;
-       if (state->csc_mask & SS_DETECT) {
+       if (state->csc_mask & SS_DETECT)
                reg |= I365_CSC_DETECT;
-       }
+
        if (state->flags & SS_IOCARD) {
                if (state->csc_mask & SS_STSCHG)
                        reg |= I365_CSC_STSCHG;
@@ -450,9 +450,12 @@ static int pd6729_set_io_map(struct pcmcia_socket *sock,
 
        ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
 
-       if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map);
-       if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map);
-       if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map);
+       if (io->flags & MAP_0WS)
+               ioctl |= I365_IOCTL_0WS(map);
+       if (io->flags & MAP_16BIT)
+               ioctl |= I365_IOCTL_16BIT(map);
+       if (io->flags & MAP_AUTOSZ)
+               ioctl |= I365_IOCTL_IOCS16(map);
 
        indirect_write(socket, I365_IOCTL, ioctl);
 
@@ -497,7 +500,7 @@ static int pd6729_set_mem_map(struct pcmcia_socket *sock,
 
        /* write the stop address */
 
-       i= (mem->res->end >> 12) & 0x0fff;
+       i = (mem->res->end >> 12) & 0x0fff;
        switch (to_cycles(mem->speed)) {
        case 0:
                break;
@@ -563,7 +566,7 @@ static int pd6729_init(struct pcmcia_socket *sock)
 
 /* the pccard structure and its functions */
 static struct pccard_operations pd6729_operations = {
-       .init                   = pd6729_init,
+       .init                   = pd6729_init,
        .get_status             = pd6729_get_status,
        .set_socket             = pd6729_set_socket,
        .set_io_map             = pd6729_set_io_map,
@@ -578,8 +581,13 @@ static irqreturn_t pd6729_test(int irq, void *dev)
 
 static int pd6729_check_irq(int irq)
 {
-       if (request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x", pd6729_test)
-               != 0) return -1;
+       int ret;
+
+       ret = request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x",
+                         pd6729_test);
+       if (ret)
+               return -1;
+
        free_irq(irq, pd6729_test);
        return 0;
 }
@@ -591,7 +599,7 @@ static u_int __devinit pd6729_isa_scan(void)
 
        if (irq_mode == 1) {
                printk(KERN_INFO "pd6729: PCI card interrupts, "
-                                               "PCI status changes\n");
+                      "PCI status changes\n");
                return 0;
        }
 
@@ -607,9 +615,10 @@ static u_int __devinit pd6729_isa_scan(void)
                if (mask & (1<<i))
                        printk("%s%d", ((mask & ((1<<i)-1)) ? "," : ""), i);
 
-       if (mask == 0) printk("none!");
-
-       printk("  polling status changes.\n");
+       if (mask == 0)
+               printk("none!");
+       else
+               printk("  polling status changes.\n");
 
        return mask;
 }
@@ -624,11 +633,16 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
 
        socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
                         GFP_KERNEL);
-       if (!socket)
+       if (!socket) {
+               dev_warn(&dev->dev, "failed to kzalloc socket.\n");
                return -ENOMEM;
+       }
 
-       if ((ret = pci_enable_device(dev)))
+       ret = pci_enable_device(dev);
+       if (ret) {
+               dev_warn(&dev->dev, "failed to enable pci_device.\n");
                goto err_out_free_mem;
+       }
 
        if (!pci_resource_start(dev, 0)) {
                dev_warn(&dev->dev, "refusing to load the driver as the "
@@ -639,7 +653,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
        dev_info(&dev->dev, "Cirrus PD6729 PCI to PCMCIA Bridge at 0x%llx "
                "on irq %d\n",
                (unsigned long long)pci_resource_start(dev, 0), dev->irq);
-       /*
+       /*
         * Since we have no memory BARs some firmware may not
         * have had PCI_COMMAND_MEMORY enabled, yet the device needs it.
         */
@@ -685,8 +699,9 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
        pci_set_drvdata(dev, socket);
        if (irq_mode == 1) {
                /* Register the interrupt handler */
-               if ((ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED,
-                                                       "pd6729", socket))) {
+               ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED,
+                                 "pd6729", socket);
+               if (ret) {
                        dev_err(&dev->dev, "Failed to register irq %d\n",
                                dev->irq);
                        goto err_out_free_res;
@@ -750,18 +765,6 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev)
        kfree(socket);
 }
 
-#ifdef CONFIG_PM
-static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int pd6729_socket_resume(struct pci_dev *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-#endif
-
 static struct pci_device_id pd6729_pci_ids[] = {
        {
                .vendor         = PCI_VENDOR_ID_CIRRUS,
@@ -778,10 +781,6 @@ static struct pci_driver pd6729_pci_driver = {
        .id_table       = pd6729_pci_ids,
        .probe          = pd6729_pci_probe,
        .remove         = __devexit_p(pd6729_pci_remove),
-#ifdef CONFIG_PM
-       .suspend        = pd6729_socket_suspend,
-       .resume         = pd6729_socket_resume,
-#endif
 };
 
 static int pd6729_module_init(void)
index 76e640bccde848c258799b2d4b245e73a17e37bb..df4532e91b1a0da9627a7fc5916c2438a5829af1 100644 (file)
@@ -17,6 +17,7 @@
   ======================================================================*/
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/cpufreq.h>
 #include <linux/ioport.h>
@@ -325,19 +326,13 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
        return 0;
 }
 
-static int pxa2xx_drv_pcmcia_suspend(struct device *dev)
-{
-       return pcmcia_socket_dev_suspend(dev);
-}
-
 static int pxa2xx_drv_pcmcia_resume(struct device *dev)
 {
        pxa2xx_configure_sockets(dev);
-       return pcmcia_socket_dev_resume(dev);
+       return 0;
 }
 
 static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = {
-       .suspend        = pxa2xx_drv_pcmcia_suspend,
        .resume         = pxa2xx_drv_pcmcia_resume,
 };
 
index 452c83b512c47eb8413ae55ffebf1a74251eca84..ffa5f3cae57b4ba543a5664e372281dff36ad000 100644 (file)
@@ -12,6 +12,7 @@
  * (C) 1999            David A. Hinds
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 
index 4663b3fa9f9616a66db5214fc6f5ef16c1b37dc0..2e47991eccf6267c6ed1ec0c0ad3ec995ed713a6 100644 (file)
@@ -810,6 +810,13 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
        unsigned long size = end - start + 1;
        int ret = 0;
 
+#if defined(CONFIG_X86)
+       /* on x86, avoid anything < 0x100 for it is often used for
+        * legacy platform devices */
+       if (start < 0x100)
+               start = 0x100;
+#endif
+
        if (end < start)
                return -EINVAL;
 
@@ -867,10 +874,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
                        if (res == &ioport_resource)
                                continue;
                        dev_printk(KERN_INFO, &s->cb_dev->dev,
-                                  "pcmcia: parent PCI bridge I/O "
-                                  "window: 0x%llx - 0x%llx\n",
-                                  (unsigned long long)res->start,
-                                  (unsigned long long)res->end);
+                                  "pcmcia: parent PCI bridge window: %pR\n",
+                                  res);
                        if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
                                done |= IORESOURCE_IO;
 
@@ -880,10 +885,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
                        if (res == &iomem_resource)
                                continue;
                        dev_printk(KERN_INFO, &s->cb_dev->dev,
-                                  "pcmcia: parent PCI bridge Memory "
-                                  "window: 0x%llx - 0x%llx\n",
-                                  (unsigned long long)res->start,
-                                  (unsigned long long)res->end);
+                                  "pcmcia: parent PCI bridge window: %pR\n",
+                                  res);
                        if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
                                done |= IORESOURCE_MEM;
                }
index 8db86b90c200e089a59dc5ea0fd17e721e490411..edbd8c472628fd8312334803ba21b2c7175d5236 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 
 #include <pcmcia/cs_types.h>
@@ -95,17 +96,6 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
        return 0;
 }
 
-static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-
 static struct platform_driver sa11x0_pcmcia_driver = {
        .driver = {
                .name           = "sa11x0-pcmcia",
@@ -113,8 +103,6 @@ static struct platform_driver sa11x0_pcmcia_driver = {
        },
        .probe          = sa11x0_drv_pcmcia_probe,
        .remove         = sa11x0_drv_pcmcia_remove,
-       .suspend        = sa11x0_drv_pcmcia_suspend,
-       .resume         = sa11x0_drv_pcmcia_resume,
 };
 
 /* sa11x0_pcmcia_init()
index db79ca61cf964ec7ba51b71b2d41f7d97dd8e62b..59866905ea37e5f2150221506cf9bac73b2eaa6d 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <pcmcia/ss.h>
 
@@ -213,16 +214,6 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev)
        return 0;
 }
 
-static int pcmcia_suspend(struct sa1111_dev *dev, pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int pcmcia_resume(struct sa1111_dev *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-
 static struct sa1111_driver pcmcia_driver = {
        .drv = {
                .name   = "sa1111-pcmcia",
@@ -230,8 +221,6 @@ static struct sa1111_driver pcmcia_driver = {
        .devid          = SA1111_DEVID_PCMCIA,
        .probe          = pcmcia_probe,
        .remove         = __devexit_p(pcmcia_remove),
-       .suspend        = pcmcia_suspend,
-       .resume         = pcmcia_resume,
 };
 
 static int __init sa1111_drv_pcmcia_init(void)
index fc9a6527019b033d21a3d234cc09b2d0c29b792d..fa28d8911b00ade20122e4c2ebe9042835eaea60 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
index 08278016e58dde68a2d8526d6b3cf0d6e9c1a9ef..80e36bc407dac811ab1b6e9e54c1b8bc36f79e77 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/string.h>
 #include <linux/major.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
index 12c49ee135e1edb36ce47a17d06f3be9ee2fe822..56004a1b5bbaefa4683a584a57fbf86d46525ed1 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
@@ -348,16 +347,6 @@ static int __init get_tcic_id(void)
     return id;
 }
 
-static int tcic_drv_pcmcia_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int tcic_drv_pcmcia_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
 /*====================================================================*/
 
 static struct platform_driver tcic_driver = {
@@ -365,8 +354,6 @@ static struct platform_driver tcic_driver = {
                .name = "tcic-pcmcia",
                .owner          = THIS_MODULE,
        },
-       .suspend        = tcic_drv_pcmcia_suspend,
-       .resume         = tcic_drv_pcmcia_resume,
 };
 
 static struct platform_device tcic_device = {
index aaccdb9f4ba170672a1de284769a03e4f361212d..86e4a1a3c6426d4524a79effd9310fa48c7bc2e3 100644 (file)
@@ -705,24 +705,11 @@ static int __devinit vrc4171_card_setup(char *options)
 
 __setup("vrc4171_card=", vrc4171_card_setup);
 
-static int vrc4171_card_suspend(struct platform_device *dev,
-                                    pm_message_t state)
-{
-       return pcmcia_socket_dev_suspend(&dev->dev);
-}
-
-static int vrc4171_card_resume(struct platform_device *dev)
-{
-       return pcmcia_socket_dev_resume(&dev->dev);
-}
-
 static struct platform_driver vrc4171_card_driver = {
        .driver = {
                .name           = vrc4171_card_name,
                .owner          = THIS_MODULE,
        },
-       .suspend        = vrc4171_card_suspend,
-       .resume         = vrc4171_card_resume,
 };
 
 static int __devinit vrc4171_card_init(void)
index f9009d34254b7c2a3edcc0fb1f3161d83eeb8c14..201ccfa1e97b59a383e2fe05fd12082e3c63f6d5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/resource.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <pcmcia/cs_types.h>
index 418988ab6edf336892675a39241aec7b9111910f..83ace277426ca5592cebc5a461b877b90c9c7a6e 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/ss.h>
@@ -1290,12 +1291,9 @@ static int yenta_dev_suspend_noirq(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct yenta_socket *socket = pci_get_drvdata(pdev);
-       int ret;
-
-       ret = pcmcia_socket_dev_suspend(dev);
 
        if (!socket)
-               return ret;
+               return 0;
 
        if (socket->type && socket->type->save_state)
                socket->type->save_state(socket);
@@ -1312,7 +1310,7 @@ static int yenta_dev_suspend_noirq(struct device *dev)
         */
        /* pci_set_power_state(dev, 3); */
 
-       return ret;
+       return 0;
 }
 
 static int yenta_dev_resume_noirq(struct device *dev)
@@ -1336,26 +1334,16 @@ static int yenta_dev_resume_noirq(struct device *dev)
        if (socket->type && socket->type->restore_state)
                socket->type->restore_state(socket);
 
-       pcmcia_socket_dev_early_resume(dev);
-       return 0;
-}
-
-static int yenta_dev_resume(struct device *dev)
-{
-       pcmcia_socket_dev_late_resume(dev);
        return 0;
 }
 
 static const struct dev_pm_ops yenta_pm_ops = {
        .suspend_noirq = yenta_dev_suspend_noirq,
        .resume_noirq = yenta_dev_resume_noirq,
-       .resume = yenta_dev_resume,
        .freeze_noirq = yenta_dev_suspend_noirq,
        .thaw_noirq = yenta_dev_resume_noirq,
-       .thaw = yenta_dev_resume,
        .poweroff_noirq = yenta_dev_suspend_noirq,
        .restore_noirq = yenta_dev_resume_noirq,
-       .restore = yenta_dev_resume,
 };
 
 #define YENTA_PM_OPS   (&yenta_pm_ops)
index e631dbeafd798ff87d9d7a0eee27953c6d5aa446..7bec4588c268c3d420a0c12a421b443152644200 100644 (file)
@@ -385,6 +385,16 @@ config EEEPC_LAPTOP
 
          If you have an Eee PC laptop, say Y or M here.
 
+config EEEPC_WMI
+       tristate "Eee PC WMI Hotkey Driver (EXPERIMENTAL)"
+       depends on ACPI_WMI
+       depends on INPUT
+       depends on EXPERIMENTAL
+       ---help---
+         Say Y here if you want to support WMI-based hotkeys on Eee PC laptops.
+
+         To compile this driver as a module, choose M here: the module will
+         be called eeepc-wmi.
 
 config ACPI_WMI
        tristate "WMI"
index 9cd9fa0a27e640389cd22a0872cbbdf48933adf5..a906490e3530a91f44b41b571af0b9737d85feae 100644 (file)
@@ -4,6 +4,7 @@
 #
 obj-$(CONFIG_ASUS_LAPTOP)      += asus-laptop.o
 obj-$(CONFIG_EEEPC_LAPTOP)     += eeepc-laptop.o
+obj-$(CONFIG_EEEPC_WMI)                += eeepc-wmi.o
 obj-$(CONFIG_MSI_LAPTOP)       += msi-laptop.o
 obj-$(CONFIG_ACPI_CMPC)                += classmate-laptop.o
 obj-$(CONFIG_COMPAL_LAPTOP)    += compal-laptop.o
index cbca40aa400612f7a61b8a7267e4efbec51c6bdd..1ea6c434d3304756cedc826616e117aaa70c1050 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/rfkill.h>
 #include <linux/workqueue.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include <acpi/acpi_drivers.h>
 
index db5f7db2ba33e4821b41dae2226fe656c32b2518..52262b012abb20c287260d242a61acf7310cc381 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
 #include <linux/rfkill.h>
+#include <linux/slab.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 
@@ -139,7 +140,7 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
 
 /* Backlight */
 static acpi_handle lcd_switch_handle;
-static const char *lcd_switch_paths[] = {
+static char *lcd_switch_paths[] = {
   "\\_SB.PCI0.SBRG.EC0._Q10",  /* All new models */
   "\\_SB.PCI0.ISA.EC0._Q10",   /* A1x */
   "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */
@@ -153,7 +154,7 @@ static const char *lcd_switch_paths[] = {
 #define METHOD_SWITCH_DISPLAY  "SDSP"
 
 static acpi_handle display_get_handle;
-static const char *display_get_paths[] = {
+static char *display_get_paths[] = {
   /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */
   "\\_SB.PCI0.P0P1.VGA.GETD",
   /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */
index ee520357abaad9e3f310b57b219df9722e97f6c6..92fd30c9379ce3eb2f6ab6bf4b6b7dbfb7dc5b9f 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
index c696cf1c26167cf7b19a2b63389adb683b300d3e..7f9e5ddc949841ba3c80d15aa75d94a60e9385c0 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <acpi/acpi_drivers.h>
 #include <linux/backlight.h>
index 46435ac4684f91a9ba1738e0b995bb294aeadeb2..661e3ac4d5b112edfa417b154ae6a60e104c2ffa 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/acpi.h>
 #include <linux/mm.h>
 #include <linux/i8042.h>
+#include <linux/slab.h>
 #include "../../firmware/dcdbas.h"
 
 #define BRIGHTNESS_TOKEN 0x7d
index bed764e3ea2a03f5892194d8e992bc4ccf9987c1..6ba6c30e5bb67723ae27f421795af51a1f8e0857 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/input.h>
 #include <acpi/acpi_drivers.h>
index 3fdf21e0052e5ee320b915439e50ce96ddde24d7..54a015785ca8b5e7bee52c281c1e0cf556f55eab 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/fb.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
+#include <linux/slab.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <linux/uaccess.h>
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
new file mode 100644 (file)
index 0000000..9f88226
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Eee PC WMI hotkey driver
+ *
+ * Copyright(C) 2010 Intel Corporation.
+ *
+ * Portions based on wistron_btns.c:
+ * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
+ * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
+ * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>");
+MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
+
+#define EEEPC_WMI_EVENT_GUID   "ABBC0F72-8EA1-11D1-00A0-C90629100000"
+
+MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
+
+#define NOTIFY_BRNUP_MIN       0x11
+#define NOTIFY_BRNUP_MAX       0x1f
+#define NOTIFY_BRNDOWN_MIN     0x20
+#define NOTIFY_BRNDOWN_MAX     0x2e
+
+static const struct key_entry eeepc_wmi_keymap[] = {
+       /* Sleep already handled via generic ACPI code */
+       { KE_KEY, 0x5d, { KEY_WLAN } },
+       { KE_KEY, 0x32, { KEY_MUTE } },
+       { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
+       { KE_KEY, 0x30, { KEY_VOLUMEUP } },
+       { KE_IGNORE, NOTIFY_BRNDOWN_MIN, { KEY_BRIGHTNESSDOWN } },
+       { KE_IGNORE, NOTIFY_BRNUP_MIN, { KEY_BRIGHTNESSUP } },
+       { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
+       { KE_END, 0},
+};
+
+static struct input_dev *eeepc_wmi_input_dev;
+
+static void eeepc_wmi_notify(u32 value, void *context)
+{
+       struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *obj;
+       acpi_status status;
+       int code;
+
+       status = wmi_get_event_data(value, &response);
+       if (status != AE_OK) {
+               pr_err("EEEPC WMI: bad event status 0x%x\n", status);
+               return;
+       }
+
+       obj = (union acpi_object *)response.pointer;
+
+       if (obj && obj->type == ACPI_TYPE_INTEGER) {
+               code = obj->integer.value;
+
+               if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
+                       code = NOTIFY_BRNUP_MIN;
+               else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
+                       code = NOTIFY_BRNDOWN_MIN;
+
+               if (!sparse_keymap_report_event(eeepc_wmi_input_dev,
+                                               code, 1, true))
+                       pr_info("EEEPC WMI: Unknown key %x pressed\n", code);
+       }
+
+       kfree(obj);
+}
+
+static int eeepc_wmi_input_setup(void)
+{
+       int err;
+
+       eeepc_wmi_input_dev = input_allocate_device();
+       if (!eeepc_wmi_input_dev)
+               return -ENOMEM;
+
+       eeepc_wmi_input_dev->name = "Eee PC WMI hotkeys";
+       eeepc_wmi_input_dev->phys = "wmi/input0";
+       eeepc_wmi_input_dev->id.bustype = BUS_HOST;
+
+       err = sparse_keymap_setup(eeepc_wmi_input_dev, eeepc_wmi_keymap, NULL);
+       if (err)
+               goto err_free_dev;
+
+       err = input_register_device(eeepc_wmi_input_dev);
+       if (err)
+               goto err_free_keymap;
+
+       return 0;
+
+err_free_keymap:
+       sparse_keymap_free(eeepc_wmi_input_dev);
+err_free_dev:
+       input_free_device(eeepc_wmi_input_dev);
+       return err;
+}
+
+static int __init eeepc_wmi_init(void)
+{
+       int err;
+       acpi_status status;
+
+       if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID)) {
+               pr_warning("EEEPC WMI: No known WMI GUID found\n");
+               return -ENODEV;
+       }
+
+       err = eeepc_wmi_input_setup();
+       if (err)
+               return err;
+
+       status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID,
+                                       eeepc_wmi_notify, NULL);
+       if (ACPI_FAILURE(status)) {
+               sparse_keymap_free(eeepc_wmi_input_dev);
+               input_unregister_device(eeepc_wmi_input_dev);
+               pr_err("EEEPC WMI: Unable to register notify handler - %d\n",
+                       status);
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static void __exit eeepc_wmi_exit(void)
+{
+       wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID);
+       sparse_keymap_free(eeepc_wmi_input_dev);
+       input_unregister_device(eeepc_wmi_input_dev);
+}
+
+module_init(eeepc_wmi_init);
+module_exit(eeepc_wmi_exit);
index c1074b32490e4346f06241b52ab7fd4a94e465c7..47b4fd75aa344966b3933af9ca7b09acf7eee613 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/kfifo.h>
 #include <linux/video_output.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
 #include <linux/leds.h>
 #endif
index 56086363becc21fba3dfcd1f8f31397881d5d76d..51c07a05a7bca4056b548ecdbb7b06afaf3cfad3 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/input.h>
 #include <acpi/acpi_drivers.h>
index f0a90a6bf396a39b8ea3f8133a79798db2a66e2b..1190bad4297fb06d796153a0df77661b40b63090 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/pm.h>
index 367caaae2f3cfcc388238e3459b84835b1ca46c2..d1736009636fadcd3f8bf7ad63f125b798cbe37a 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/input/sparse-keymap.h>
 #include <linux/acpi.h>
 #include <linux/backlight.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
 MODULE_DESCRIPTION("MSI laptop WMI hotkeys driver");
index 726f02affcb65ef7441347e33060866f1f3292c7..2fb9a32926f86f5258e685847f1eac0c8aa75e59 100644 (file)
 #include <linux/ctype.h>
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <linux/input.h>
index 6553b91caaa4a4d1373065861ec296e9e34a6c3c..1387c5f9c24d926aef958528cc031a5478475e1f 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/kfifo.h>
 #include <linux/workqueue.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
 #include <asm/uaccess.h>
index dd33b51c34869b098ee43ce9e63e36b89c3d4a22..1fe0f1feff71607e9397dac7aed322af871b9424 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <acpi/acpi.h>
index 770b85327f84b0177bbaab47c224b8f5c1b55b57..63290b33c8796e203113309536ed8716a42ef1f7 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <linux/nvram.h>
 #include <linux/proc_fs.h>
index 4d6516fded7eeaea8f5f98ebf19254cd17363d7b..ff4b476f1950856f101959c7c1ccc6caa2e89b4a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/input.h>
 
index def4841183be621b8a140a503b559f3766d45ebb..37aa1479855136c10f2384edc814da5eda6dc6c9 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/platform_device.h>
 #include <linux/rfkill.h>
 #include <linux/input.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index 09e9918c69c145820f92e19fc2fc76947c7321bc..39ec5b6c2e3a804518bdad78257bb766812e3274 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/device.h>
 #include <linux/list.h>
 #include <linux/acpi.h>
+#include <linux/slab.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
index e851160e14f06e6d98179f19716ac04b51e7a598..918d5f044865b3dc513a5f3ad877b458592aa243 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/isapnp.h>
index 00fd3577b98575abb218972a4e35d1d62f6366c2..0a15664eef1c65f2c9670f24ab03af0a604122c6 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/pnp.h>
-#include <linux/slab.h>
 #include <linux/bitmap.h>
 #include <linux/mutex.h>
 #include "base.h"
index 5314bf630bc4c7fe1b227e4eb0e39b6cf618e79b..f7ff628b7d9437a096d534ff6d829ce2c7cca49f 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/acpi.h>
 #include <linux/pnp.h>
+#include <linux/slab.h>
 #include <linux/mod_devicetable.h>
 #include <acpi/acpi_bus.h>
 
index 54514aa35b093f27d11604d4bca986e5b6c53e5c..c6c552f681b7040df86ea8841c2dc784ffe910f5 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/acpi.h>
 #include <linux/pci.h>
 #include <linux/pnp.h>
+#include <linux/slab.h>
 #include "../base.h"
 #include "pnpacpi.h"
 
index fc83783c3a96b16cf4a67a584b48bf23e447110b..8591f6ab1b3562f6642e0adb20afb198d2087def 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/pnp.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
-#include <linux/slab.h>
 #include <linux/kmod.h>
 #include <linux/completion.h>
 #include <linux/spinlock.h>
index a5135ebe5f077da279f8688ae259d4f0817a0cc9..cb1f47bfee96685637d81ca51c3f9415092fe7e3 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/ctype.h>
 #include <linux/pnp.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 
 #ifdef CONFIG_PCI
 #include <linux/pci.h>
index 5b277dbaacde5df589b227ac754056fe86757428..2e54e6a23c72c8ff44b610412e3c1c92baac81b8 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
index bece33ed873cbc425accae82fb7ed7bdadb08615..3ec9c6a8896b5ea9c22c0da72705b51ab79ca6fc 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/power_supply.h>
 #include <linux/idr.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #define DRIVER_VERSION                 "1.1.0"
index a2e71f7b27fb6d68a26029086e88e2b830744400..d2c793cf676582516ef97af4bb4deae08750c728 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/device.h>
index 6f1dba5a519dfa4c458e66a784aafadf8fee2460..3bf8d1f622e31319144a8077420d683231ed1195 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/jiffies.h>
 #include <linux/workqueue.h>
 #include <linux/pm.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
 
index da14f374cb60893c2fa9962f73664186386cc078..99c89976a902b1166cded15540f12aa53de0721e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/idr.h>
 #include <linux/power_supply.h>
+#include <linux/slab.h>
 
 #define DS2782_REG_RARC                0x06    /* Remaining active relative capacity */
 
index 87b98bf27ae1f66311927a9a641b8f4b2332f6a1..f3e22c9fe20a538581a70fc0d0134bf78a5a1b33 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/power_supply.h>
 #include <linux/max17040_battery.h>
+#include <linux/slab.h>
 
 #define MAX17040_VCELL_MSB     0x02
 #define MAX17040_VCELL_LSB     0x03
index a1b4410544d7fea415097183e84f0296dafa1d3b..8e5aec26086681c03908a91cfd3e3ea4a314e9f5 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
index ea3fdfaca90dd70cd31815d4fdc23901414f0b4c..066f994e6fe5ac4b74dda65ba658450b283cbe9f 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/device.h>
index 9c87ad564803b96f0b915b75edaf2ae48fd7bfaf..023d24993b871de656da8a631b8f73fc827acbfc 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/power_supply.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
+#include <linux/slab.h>
 
 static struct pmu_battery_dev {
        struct power_supply bat;
index 2dece40c544f2098dae9b94ae110f31c8f50be31..031a554837f78d2958b2c3368268c27466251837 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/power_supply.h>
+#include <linux/slab.h>
 
 #include "power_supply.h"
 
index ff05e61897682343e0fa6f5c892fcd050e67be41..5b6e352ac7c1e935fc7cfce0f5683028a541f94f 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/ctype.h>
 #include <linux/power_supply.h>
+#include <linux/slab.h>
 
 #include "power_supply.h"
 
index bf4f387a80098a33c1ed1186473d994e70271e7a..0fd130d80f5d914826029c9f8bb370d44718472f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/auxadc.h>
index f85e80b1b400c917963010d679dd394c0326b7d7..875c4d0f776b90570058eef2e41328488f3f0b51 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/auxadc.h>
index 23eed356a854c880fc3d26854fe90f15105c0f21..94c70650aafc90275fd24d74b798d6d66f91263c 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
index 2d414e23d390174c7b49942a7723dbfda8cb800e..1aa02db3ff4e50f592455cb50cb7f9d0f5c8797a 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/idr.h>
 #include <linux/fs.h>
 #include <linux/pps_kernel.h>
+#include <linux/slab.h>
 
 /*
  * Global variables
index fe96793e3f080e155abfae2ef804b211f3c0e166..8000985d0e8c80f3df68802b9210736a25f499f2 100644 (file)
@@ -18,6 +18,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
index e4ad5ba5d0a3da7b4014c003f7582d9146323a44..d9fb729535a1691b976d475c5b089bab6fa60cfe 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/workqueue.h>
index 95a689befc84b5887ea0e629f85579006c4cf15c..a409fa050a1a910e0074ce0098e76e0868988b52 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/notifier.h>
 #include <linux/ioctl.h>
 #include <linux/fb.h>
+#include <linux/slab.h>
 
 #include <asm/firmware.h>
 #include <asm/ps3av.h>
index c7bbe30010f70b3dc69542eb99fe14488cd31f45..2b4e40d311902c3a05061aa99e4d4fd65b38a167 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
 #include <linux/suspend.h>
@@ -1038,6 +1039,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
                        goto overflow_err;
 
                regulator->dev = dev;
+               sysfs_attr_init(&regulator->dev_attr.attr);
                regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
                if (regulator->dev_attr.attr.name == NULL)
                        goto attr_name_err;
index d11f7622430bfa4a00d6ade280f1ad70edb7e93b..2fe9d99c9f23107366ab8d485831bd65bce0663f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/regulator/fixed.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 struct fixed_voltage_data {
        struct regulator_desc desc;
index f5532ed79272c08976723687684f461f49b5b281..671a7d1f1f0e33e5f9f0fd4e016b742a870da3a4 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/lp3971.h>
+#include <linux/slab.h>
 
 struct lp3971 {
        struct device *dev;
@@ -45,7 +46,7 @@ static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val);
        LP3971_BUCK2 -> 4
        LP3971_BUCK3 -> 6
 */
-#define BUCK_VOL_CHANGE_SHIFT(x) (((1 << x) & ~0x01) << 1)
+#define BUCK_VOL_CHANGE_SHIFT(x) (((!!x) << 2) | (x & ~0x01))
 #define BUCK_VOL_CHANGE_FLAG_GO 0x01
 #define BUCK_VOL_CHANGE_FLAG_TARGET 0x02
 #define BUCK_VOL_CHANGE_FLAG_MASK 0x03
@@ -187,7 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
                return -EINVAL;
 
        return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
-               LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), val);
+                       LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
+                       val << LDO_VOL_CONTR_SHIFT(ldo));
 }
 
 static struct regulator_ops lp3971_ldo_ops = {
@@ -439,6 +441,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
        lp3971->num_regulators = pdata->num_regulators;
        lp3971->rdev = kcalloc(pdata->num_regulators,
                                sizeof(struct regulator_dev *), GFP_KERNEL);
+       if (!lp3971->rdev) {
+               err = -ENOMEM;
+               goto err_nomem;
+       }
 
        /* Instantiate the regulators */
        for (i = 0; i < pdata->num_regulators; i++) {
@@ -461,6 +467,7 @@ error:
                regulator_unregister(lp3971->rdev[i]);
        kfree(lp3971->rdev);
        lp3971->rdev = NULL;
+err_nomem:
        return err;
 }
 
index a49fc952c9a98bd7495b59957b60a139e91b0f45..b3c1afc16889434f47c9fd74e387da39bb255737 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/slab.h>
 #include <linux/regulator/max1586.h>
 
 #define MAX1586_V3_MAX_VSEL 31
@@ -243,8 +244,8 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
        for (i = 0; i <= MAX1586_V6; i++)
                if (rdev[i])
                        regulator_unregister(rdev[i]);
-       kfree(rdev);
        i2c_set_clientdata(client, NULL);
+       kfree(rdev);
 
        return 0;
 }
index 3ebdf698c648f6cb588a0637cbcd15ab6782f3e3..bfc4c5ffdc966f3ab03081259faf52adce239906 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/slab.h>
 #include <linux/regulator/max8649.h>
 
 #define MAX8649_DCDC_VMIN      750000          /* uV */
@@ -356,6 +357,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
        dev_info(info->dev, "Max8649 regulator device is detected.\n");
        return 0;
 out:
+       i2c_set_clientdata(client, NULL);
        kfree(info);
        return ret;
 }
@@ -367,9 +369,9 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client)
        if (info) {
                if (info->regulator)
                        regulator_unregister(info->regulator);
+               i2c_set_clientdata(client, NULL);
                kfree(info);
        }
-       i2c_set_clientdata(client, NULL);
 
        return 0;
 }
index f12f1bb62138f95851ae7da9289a1b89d159924c..3790b21879ff2f8d2c5b8000fe216f1f0770a436 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/slab.h>
 #include <linux/regulator/max8660.h>
 
 #define MAX8660_DCDC_MIN_UV     725000
@@ -470,8 +471,8 @@ static int __devexit max8660_remove(struct i2c_client *client)
        for (i = 0; i < MAX8660_V_END; i++)
                if (rdev[i])
                        regulator_unregister(rdev[i]);
-       kfree(rdev);
        i2c_set_clientdata(client, NULL);
+       kfree(rdev);
 
        return 0;
 }
index 67873f08ed40cccd89b52a764058affb0cb4e2b2..b6218f11c957ada5b98d5f3bd50d5c2093260ddd 100644 (file)
@@ -230,7 +230,7 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
        MAX8925_LDO(20, 750, 3900, 50),
 };
 
-static inline struct max8925_regulator_info *find_regulator_info(int id)
+static struct max8925_regulator_info * __devinit find_regulator_info(int id)
 {
        struct max8925_regulator_info *ri;
        int i;
@@ -247,7 +247,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
 {
        struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
        struct max8925_platform_data *pdata = chip->dev->platform_data;
-       struct max8925_regulator_info *ri = NULL;
+       struct max8925_regulator_info *ri;
        struct regulator_dev *rdev;
 
        ri = find_regulator_info(pdev->id);
@@ -274,7 +274,9 @@ static int __devexit max8925_regulator_remove(struct platform_device *pdev)
 {
        struct regulator_dev *rdev = platform_get_drvdata(pdev);
 
+       platform_set_drvdata(pdev, NULL);
        regulator_unregister(rdev);
+
        return 0;
 }
 
index f7b81845a196223f5fdf5051115fa9ecd2a69d7f..a681f5e8f78602db461bb44d2e089367a4498476 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/regulator/driver.h>
 #include <linux/platform_device.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
 
index 1f183543bdbd68fa2570cba036438d274f721837..8e2f2098b00562fd2e9608494569f28f9b85a83f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 /* Register definitions */
 #define        TPS65023_REG_VERSION            0
index c2a9539acd723377c8f82f91a97448bdde14e742..74841abcc9cc5d037e5837eebe1bd4971719986a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 /* Register definitions */
 #define        TPS6507X_REG_PPATH1                             0X01
index 44917da4ac97a3853420ca99856c1c436c15e985..9d5ba93575975f22e8d00a620613cc1848ffb8fe 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regulator/userspace-consumer.h>
+#include <linux/slab.h>
 
 struct userspace_consumer_data {
        const char *name;
index d96cecaac73d7aeb5b1e2f0dc9f599764148a078..69e550f57638cbde4ebde30990318cb21816ad0a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
 struct virtual_consumer_data {
        struct mutex lock;
index 6e18e56d850ba7159312938baf59d6f50ecc3fa3..dbfaf5945e48a683c20cd87ff185dfc816b789e7 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/regulator.h>
index ca0f6b6c384b34ef327f09d77cc5be44148d4a65..6c446cd6ad546839aa455d2302fff558921ea3c3 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/regulator.h>
index d2406c1519a195a16437561bd3e2fadde4859f9b..e686cdb61b97cd8a54ab7fbecb1312a41e333595 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/regulator.h>
index 95454a4637b7ef771c426d0540df313afe5fe087..5a1dc8a24d355bcdf5e9e741c0a9acab6e7ced5c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm8994/core.h>
 #include <linux/mfd/wm8994/registers.h>
index 40845c7e93221c7a13a236619ab8225e9638e9ca..565562ba6ac9dacc7d8aa4842c7ddedb29de074d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/rtc.h>
 #include <linux/kdev_t.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 
 #include "rtc-core.h"
 
index 8825695777df281777a3d61e7179b0afa9d61f55..b2752b6e7a2f903da45d39a7c275248b174988a1 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/io.h>
 
index 78a018b5c941c5acf51184a46189e9aedbfdff80..f677e0710ca1160957940b51d403885fd71d603e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/rtc.h>
 #include <linux/interrupt.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 
 #include <mach/board.h>
 #include <mach/at91_rtt.h>
index b11485b9f21ca1c3c90f7bc96cfffb32c66e0b8c..72b2bcc2c22413b1a63e465e355ea65084ec7b8e 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/blackfin.h>
 
index 280fe48ada0bfa629556a9da28d232d7f3462064..128270ce355d08f0689b8e0961d39bb565923bf5 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
 MODULE_DESCRIPTION("TI BQ4802 RTC driver");
index 44c4399ee7144fc2e8cffca50d8a96426b05a8fb..316f484999b55fb861667b5c6950654959ab7b75 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /*
  * Registers in the COH 901 331
index 4aedc705518c773a40739aa5292d06f2f7e193db..45cd8c9f5a39acd4e135b46908aee500da306415 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #define DRV_VERSION "0.2"
 
index 4fcb16bbff4ab801ca0fe31b03d61e1ef0d5e108..bf430f9091ed0ba3b10b66dfeab207ca4cda3287 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/bcd.h>
 #include <linux/ds1286.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define DRV_VERSION            "1.0"
 
index 9630e7d3314e59d19dd9e94be9f917cab7307f16..7836c9cec5578a559170e1c356284f795f6be409 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/workqueue.h>
 
index 5317bbcbc7a0c7cb3f60e16e6bafac483327a666..61945734ad003c379fde6424c708942b1afbbf8a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/rtc.h>
 #include <linux/bcd.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #define DS1374_REG_TOD0                0x00 /* Time of Day */
 #define DS1374_REG_TOD1                0x01
index cdb705057091f1cb8bbbca35f42be3154e86d07a..26a86d235051ff283115c34324ae2605a860a42f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/rtc.h>
 #include <linux/spi/spi.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #define DS1390_REG_100THS              0x00
 #define DS1390_REG_SECONDS             0x01
index 4166b84cb514f6ff68d918d4e0ebf3fbd0c97bc5..06b8566c4532ebefe541d5a0bc164d29642cb2f0 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/bcd.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/rtc.h>
index ed1ef7c9cc069fc2d2634429827f66c783734aa6..244f9994bcbbade98fa1615dc243acdfadf39be8 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/bcd.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
 #include <linux/interrupt.h>
index cad9ceb89bafea483c0cdbf0de70742bde2bb220..2b4b0bc42d6f7a0768ff63f73524d928029023fa 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/bcd.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
 #include <linux/rtc.h>
index 91bde976bc0fb79031f18faf5756069f04c38ac6..11ae64dcbf3c7b1a365853ae16cb095cbb38ea9f 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #define EP93XX_RTC_DATA                        0x000
 #define EP93XX_RTC_MATCH               0x004
index 812c667550837ea6f12adaedcfbff41f32d2a30e..ff6fce61ea41afff5e0d9d6bd8bd480c6f8d37d4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #define FM3130_RTC_CONTROL     (0x0)
 #define FM3130_CAL_CONTROL     (0x1)
index 8cb5b8959e5b2c2befd63f59323e89f7657324ab..7410875e5838957d0763a079f967c78c72a0751c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/module.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/bcd.h>
 #include <linux/io.h>
index ede43b8468596e3ac0037d9b25e4b251d1466036..365ff3ac23486fe2e08eae2fddb03720e6c8ba94 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/rtc.h>
 #include <linux/rtc/m48t59.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #ifndef NO_IRQ
 #define NO_IRQ (-1)
index acdbb1760187af5da1cb122aba25f0b1e3a8aaf3..174036dda78652ce106afc23d12699f1d310000b 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/max8925.h>
index d60c81b7b693c9c26afa236cf85abafd1b6e2ec2..675bfb51536722bbea5d703146a9972bb4be5d30 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 
 #define DRIVER_NAME "mc13783-rtc"
@@ -319,35 +320,38 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 {
        int ret;
        struct mc13783_rtc *priv;
+       struct mc13783 *mc13783;
        int rtcrst_pending;
 
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
-       priv->mc13783 = dev_get_drvdata(pdev->dev.parent);
+       mc13783 = dev_get_drvdata(pdev->dev.parent);
+       priv->mc13783 = mc13783;
+
        platform_set_drvdata(pdev, priv);
 
-       mc13783_lock(priv->mc13783);
+       mc13783_lock(mc13783);
 
-       ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_RTCRST,
+       ret = mc13783_irq_request(mc13783, MC13783_IRQ_RTCRST,
                        mc13783_rtc_reset_handler, DRIVER_NAME, priv);
        if (ret)
                goto err_reset_irq_request;
 
-       ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_RTCRST,
+       ret = mc13783_irq_status(mc13783, MC13783_IRQ_RTCRST,
                        NULL, &rtcrst_pending);
        if (ret)
                goto err_reset_irq_status;
 
        priv->valid = !rtcrst_pending;
 
-       ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_1HZ,
+       ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_1HZ,
                        mc13783_rtc_update_handler, DRIVER_NAME, priv);
        if (ret)
                goto err_update_irq_request;
 
-       ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_TODA,
+       ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_TODA,
                        mc13783_rtc_alarm_handler, DRIVER_NAME, priv);
        if (ret)
                goto err_alarm_irq_request;
@@ -357,22 +361,22 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
        if (IS_ERR(priv->rtc)) {
                ret = PTR_ERR(priv->rtc);
 
-               mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv);
+               mc13783_irq_free(mc13783, MC13783_IRQ_TODA, priv);
 err_alarm_irq_request:
 
-               mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
+               mc13783_irq_free(mc13783, MC13783_IRQ_1HZ, priv);
 err_update_irq_request:
 
 err_reset_irq_status:
 
-               mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
+               mc13783_irq_free(mc13783, MC13783_IRQ_RTCRST, priv);
 err_reset_irq_request:
 
                platform_set_drvdata(pdev, NULL);
                kfree(priv);
        }
 
-       mc13783_unlock(priv->mc13783);
+       mc13783_unlock(mc13783);
 
        return ret;
 }
index 4313ca03a96d8da6b3ee4f80c8c53f83ba8306fd..f0dbf9cb8f9c42f30e51b6db7dba823d887c6f61 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 struct mpc5121_rtc_regs {
        u8 set_time;            /* RTC + 0x00 */
index 5f5968a4892584ae2f2a3d8ae4e61bdfb280397c..b2fff0ca49f8c734e9337244c56511470cf7c0db 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 
 
 enum {
index dc052ce6e63a8af6525cd067d0748927298c0c41..bcca4729855402f68b4b1601120779a5b35df742 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 
 #define RTC_TIME_REG_OFFS      0
index 8710f9415d98ce35a42757b6974065d80c784f2c..c77f6f72f95008c2bf5079e5c8c31b089dbc796a 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/io.h>
 #include <linux/rtc.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
index bf59c9c586b2d1d38076d629c09f84bf747146a6..a351bd5d81765d785d9b3b41972961446615d12b 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/delay.h>
 #include <linux/io.h>
index a99c28992d21658a25663e5e01c7110116ea5bdb..25c0b3fd44f1ba901f96b0b8582a6941335640b4 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/mfd/ezx-pcap.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 
 struct pcap_rtc {
index 2ceb365533b2a3d8d0701753a4e54716dccefb81..71bab0ef54436bd19be3882f95df4f62dbbd96a4 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/spi/spi.h>
 
index 854c3cb365a1919d0c6a92dad726f2a648ed4a5e..16edf94ab42f2826f20024ef3a57778f8e15a0c6 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
index 65f346b2fbaebfcf73b58759e6622d6e9ababefd..1af42b4a6f59c07146c83b4001709a921f161225 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/i2c.h>
 #include <linux/bcd.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 
 #define DRV_VERSION "0.4.3"
 
index 457231bb1029748ca4c1be64d1689577ae4ad00d..bbdb2f02798a13187c91475696fa9f84594f8f47 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/interrupt.h>
 #include <linux/amba/bus.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #define RTC_DR         (0)
 #define RTC_MR         (4)
index c256aacfa9542232c121bd6a91a95456a16406c6..3587d9922f2895832059f1ea1163e715750dd19a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/bcd.h>
 #include <linux/delay.h>
 #include <linux/version.h>
+#include <linux/slab.h>
 
 /*
  * Register definitions
index e6351b743da644cd78dd34b0cfd73b667e885cfe..e9c6fa035989ad328f094f58396cfea79c28ae3d 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 
index e1313feb060f0bde073b18b05050d763a405a2ae..a95f733bb15aa5aa1c8cc6af6ad49e33292b196a 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 
 
 enum {
index 2099037cb3eab5921be8497205e74e4f2ba84127..368d0e63cf836a3f054a56adcc7f86f12fcc278a 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
index 2f2c68d476daa924028e167be775859d35ce21b4..90cf0a6ff23e3cce363958cb0c3e81cde08c14af 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/i2c.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 #define DRV_VERSION "0.6"
 
index b1a29bcfdf1339b06ec6b4ff190dcaa2cbf04d21..b65c82f792d9cd6f86614304db1f4c9d99077c6b 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bcd.h>
 #include <linux/i2c.h>
index e0d7b9991505564c412e4771f8061154c5adc449..4969b6059c896e3fafe9ee9d8bf591fdc87f03b0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/bcd.h>
 #include <linux/clk.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <asm/uaccess.h>
index e95cc6f8d61e28c035fed8d0648fd92463ed595e..5efbd5990ff8dee1ea6431540405082303fd3119 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/io.h>
 #include <linux/log2.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 #include <asm/rtc.h>
 
 #define DRV_NAME       "sh-rtc"
index 67700831b5c991e948e7b03b48e9ea75777b5938..875ba099e7a554ffcd35d71e3b4ae83cc6db82eb 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/bcd.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/jiffies.h>
 #include <linux/interrupt.h>
index d7ce1a5c857dfa92925c6f568b46e1ee3432ef7d..7e7d0c806f2db8eaea1da72cbf3e3052649a7f1b 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 
 #include <mach/platform.h>
 #include <mach/stmp3xxx.h>
index 9ee81d8aa7c02ecd88c637776b82d14978e063ef..20bfc64a15c82f1a06d9b6e42594ea84c9d9c2f0 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 #include <asm/txx9/tx4939.h>
 
 struct tx4939rtc_plat_data {
index bed4cab07043674615ab7fef5d3093e67577af44..f71c3ce180369225938f8ba21a6960e605f9d251 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/rtc-v3020.h>
 #include <linux/delay.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <linux/io.h>
 
index 000c7e481e594ab8216b5c5d05098af188a9d876..b16cfe57a484b8590ab78e855963dc8840bd6d46 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/time.h>
 #include <linux/rtc.h>
+#include <linux/slab.h>
 #include <linux/bcd.h>
 #include <linux/interrupt.h>
 #include <linux/ioctl.h>
index 51224f76b980eaf15908897b7a30fb19cca0ecfe..6927e751ce3ed661f5c640492e93b0c5d49fc037 100644 (file)
@@ -10,7 +10,6 @@
 #define KMSG_COMPONENT "dasd-eckd"
 
 #include <linux/timer.h>
-#include <linux/slab.h>
 #include <asm/idals.h>
 
 #define PRINTK_HEADER "dasd_erp(3990): "
@@ -2287,7 +2286,8 @@ static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
 
        if (cqr->cpmode == 1) {
                cplength = 0;
-               datasize = sizeof(struct tcw) + sizeof(struct tsb);
+               /* TCW needs to be 64 byte aligned, so leave enough room */
+               datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
        } else {
                cplength = 2;
                datasize = 0;
@@ -2316,8 +2316,8 @@ static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
        if (cqr->cpmode == 1) {
                /* make a shallow copy of the original tcw but set new tsb */
                erp->cpmode = 1;
-               erp->cpaddr = erp->data;
-               tcw = erp->data;
+               erp->cpaddr = PTR_ALIGN(erp->data, 64);
+               tcw = erp->cpaddr;
                tsb = (struct tsb *) &tcw[1];
                *tcw = *((struct tcw *)cqr->cpaddr);
                tcw->tsb = (long)tsb;
index 148b1dd240704e8d472b6ba83f5c435d40fb0fb3..8c4814258e93c9fe58e3711be1051a49b0af0269 100644 (file)
@@ -8,6 +8,7 @@
 #define KMSG_COMPONENT "dasd-eckd"
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <asm/ebcdic.h>
 #include "dasd_int.h"
 #include "dasd_eckd.h"
index 8e23919c870484a02159411f99f92c17c20a6a22..eff9c812c5c2befa559e1281fd2a1cb152451659 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <asm/debug.h>
 #include <asm/uaccess.h>
index 01f4e7a34aa8b2aa8570bd16c4078b53c9f415cf..0cb2331168551ef4f290adb65683d8ee1902b30a 100644 (file)
@@ -3155,11 +3155,11 @@ static void dasd_eckd_dump_sense_tcw(struct dasd_device *device,
 
        tsb = NULL;
        sense = NULL;
-       if (irb->scsw.tm.tcw)
+       if (irb->scsw.tm.tcw && (irb->scsw.tm.fcxs == 0x01))
                tsb = tcw_get_tsb(
                        (struct tcw *)(unsigned long)irb->scsw.tm.tcw);
 
-       if (tsb && (irb->scsw.tm.fcxs == 0x01)) {
+       if (tsb) {
                len += sprintf(page + len, KERN_ERR PRINTK_HEADER
                               " tsb->length %d\n", tsb->length);
                len += sprintf(page + len, KERN_ERR PRINTK_HEADER
index 1f3e967aaba8f650d4618a2e57ed3c9c72cbde84..dd88803e4899c415e1cba6e0fe402f3b79a77664 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
index 3479f8158a1b3206039dc55551503eb138a0b104..1557214944f718fda7b239a88de50b10e97973fd 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fs.h>
 #include <linux/blkpg.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/compat.h>
 #include <asm/ccwdev.h>
 #include <asm/cmb.h>
index f13a0bdd148cae363315ef7d6f1ad895554e0568..2eb02559280927594f7a10efbfe19ead060be9aa 100644 (file)
@@ -14,6 +14,7 @@
 #define KMSG_COMPONENT "dasd"
 
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
index 118de392af63895b98b42afc0123911f054168f5..c881a14fa5dd7796c2f07a08120e3891254a66df 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/ctype.h>  /* isdigit, isxdigit */
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>  /* HDIO_GETGEO */
@@ -41,6 +40,7 @@
 #include <linux/bio.h>
 #include <linux/suspend.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 
 #define XPRAM_NAME     "xpram"
index 6bca81aea3966e0da735d72fb9c3829566efa2bd..bb07577e8fd4409331aeef22562edec3c838a468 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/reboot.h>
 
index 31c59b0d6df0c1509a191ece52a77c3ba4f6e0ae..0eabcca3c92d45f47e2001a046c996ac077df7fd 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/smp_lock.h>
 
index cee4d4e4242907bb7a917070b0e3ac7b706cb794..cb6bffe7141a948feb3f8f370f360eb941861991 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/sysrq.h>
 
 #include <linux/consolemap.h>
index 33e96484d54fd1bf5d28aeb369751eed9dbef539..2ed3f82e5c30e1e5ead0f0a159a83174c70d2079 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <net/iucv/iucv.h>
 #include <asm/uaccess.h>
 #include <asm/ebcdic.h>
index 668a0579b26b8b7767d2fbc912c220d02d3a874b..98a49dfda1de0d425b8f6b3157c1e0c131d3a8a5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/poll.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/ebcdic.h>
 #include <asm/io.h>
index 740fe405c3959f199ca9d393d9d912443653101b..2aecf7f21361b9d430b531e9b6697a8515a84923 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/device.h>
 #include <linux/stat.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/kmod.h>
 #include <linux/err.h>
@@ -84,6 +85,7 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
                rc = copy_from_user(buf, buffer, sizeof(buf));
                if (rc != 0)
                        return -EFAULT;
+               buf[len - 1] = '\0';
                if (strict_strtoul(buf, 0, &val) != 0)
                        return -EINVAL;
                if (val != 0 && val != 1)
index fc7ae05ce48ae262374b0becc3373a1b42d00690..4b60ede07f0e0f9738d22c70d53c3393eff1b37e 100644 (file)
@@ -308,6 +308,13 @@ struct assign_storage_sccb {
        u16 rn;
 } __packed;
 
+int arch_get_memory_phys_device(unsigned long start_pfn)
+{
+       if (!rzm)
+               return 0;
+       return PFN_PHYS(start_pfn) >> ilog2(rzm);
+}
+
 static unsigned long long rn2addr(u16 rn)
 {
        return (unsigned long long) (rn - 1) * rzm;
@@ -704,13 +711,6 @@ int sclp_chp_deconfigure(struct chp_id chpid)
        return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8);
 }
 
-int arch_get_memory_phys_device(unsigned long start_pfn)
-{
-       if (!rzm)
-               return 0;
-       return PFN_PHYS(start_pfn) / rzm;
-}
-
 struct chp_info_sccb {
        struct sccb_header header;
        u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
index ad698d30cb3b5db6dbfb52e147fa1f60592c07b9..ecf45c54f8c469c84da45049e006225593283a90 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/termios.h>
 #include <linux/err.h>
 #include <linux/reboot.h>
+#include <linux/gfp.h>
 
 #include "sclp.h"
 #include "sclp_rw.h"
index 434ba04b1309529e0e0959eea440a074085a5535..8258d590505f1444e9a4a4ed8cab036fe400b72e 100644 (file)
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
-#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 
 #include "ctrlchar.h"
index 3796ffdb847995c89ff74acf9bb5078f28a7eff5..5d706e6c946fb37ea87d78dddfef45a628bb00d0 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/reboot.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include "sclp.h"
index cb70fa1cf5398fb5d8ff5cd58b5c0a24f45baec6..c17f35b6136ace01d56cd643ed0bffdaae8e7b86 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/bio.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #define TAPE_DBF_AREA  tape_34xx_dbf
 
index 9821c58866137710bfa2e52aaa5bd6a2045831ae..fc993acf99b656a273475588be808c2894c72884 100644 (file)
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/bio.h>
 #include <asm/ebcdic.h>
index b2864e3edb6da8a80cb70ff99b2812918c7cfefb..55343df61edde6a583328d1a7faa0c2515491670 100644 (file)
@@ -11,6 +11,8 @@
 #define KMSG_COMPONENT "tape"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/slab.h>
+
 #include "tape_class.h"
 
 MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>");
index 81b094e480e66f0f9d7823a0afeb0a2067d340b1..29c2d73d719db55ab963660efdbfe6b9db55c030 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/spinlock.h>  // for locks
 #include <linux/vmalloc.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include <asm/types.h>      // for variable types
 
index 921dcda77676b1e94f6e857c695a8d36737c9c5c..5bb59d36a6d496431d8375168d7d723acccf1679 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/compat.h>
 #include <asm/cpcmd.h>
 #include <asm/debug.h>
index 7dfa5412d5a8bc9d5c0b6ddcacffc6fe6d958981..e40a1b89286667d02329800f64c03d2fa35cfdda 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
index cc56fc708baeced52b18918fcf659e016e31b5b1..1de672f21037bd70f57e06b4abcd43a89b65a864 100644 (file)
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/cdev.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 
 #include <asm/uaccess.h>
index c974058e48d2a4da6976755d48d371e87b15fe90..e13508c98b1a754c38509f5cb89ce06eb2044e44 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/miscdevice.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/suspend.h>
 #include <linux/watchdog.h>
 
index 3438658b66b76fb7f7aaf261310fe3512fa1cc70..18daf16aa3572bdf5cfa7d0cc1290942bf758b01 100644 (file)
@@ -13,6 +13,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/miscdevice.h>
 #include <linux/debugfs.h>
 #include <asm/asm-offsets.h>
@@ -141,33 +142,6 @@ static int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)
        return memcpy_hsa(dest, src, count, TO_KERNEL);
 }
 
-static int memcpy_real(void *dest, unsigned long src, size_t count)
-{
-       unsigned long flags;
-       int rc = -EFAULT;
-       register unsigned long _dest asm("2") = (unsigned long) dest;
-       register unsigned long _len1 asm("3") = (unsigned long) count;
-       register unsigned long _src  asm("4") = src;
-       register unsigned long _len2 asm("5") = (unsigned long) count;
-
-       if (count == 0)
-               return 0;
-       flags = __raw_local_irq_stnsm(0xf8UL); /* switch to real mode */
-       asm volatile (
-               "0:     mvcle   %1,%2,0x0\n"
-               "1:     jo      0b\n"
-               "       lhi     %0,0x0\n"
-               "2:\n"
-               EX_TABLE(1b,2b)
-               : "+d" (rc), "+d" (_dest), "+d" (_src), "+d" (_len1),
-                 "+d" (_len2), "=m" (*((long*)dest))
-               : "m" (*((long*)src))
-               : "cc", "memory");
-       __raw_local_irq_ssm(flags);
-
-       return rc;
-}
-
 static int memcpy_real_user(void __user *dest, unsigned long src, size_t count)
 {
        static char buf[4096];
@@ -175,7 +149,7 @@ static int memcpy_real_user(void __user *dest, unsigned long src, size_t count)
 
        while (offs < count) {
                size = min(sizeof(buf), count - offs);
-               if (memcpy_real(buf, src + offs, size))
+               if (memcpy_real(buf, (void *) src + offs, size))
                        return -EFAULT;
                if (copy_to_user(dest + offs, buf, size))
                        return -EFAULT;
@@ -663,7 +637,7 @@ static int __init zcore_reipl_init(void)
        if (ipib_info.ipib < ZFCPDUMP_HSA_SIZE)
                rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE);
        else
-               rc = memcpy_real(ipl_block, ipib_info.ipib, PAGE_SIZE);
+               rc = memcpy_real(ipl_block, (void *) ipib_info.ipib, PAGE_SIZE);
        if (rc) {
                free_page((unsigned long) ipl_block);
                return rc;
index 7eab9ab9f40650902c1405a98551e43362c9c21b..13cb60162e429675a2f0233e903f48ccea9d89ed 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/init.h>
 #include <linux/vmalloc.h>
-#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/ctype.h>
index c268a2e5b7c332901c7225e30afe7872cfbd7bbd..1d16189f2f2dbd60b17f29e5400a11cf8da5477e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/wait.h>
 #include <linux/mutex.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <asm/chpid.h>
 #include <asm/sclp.h>
 #include <asm/crw.h>
index 852612f5dba0607d81b29c8ae5ecd8c7ca44053d..404f630c27ca2ad4c110378b786707caf0451e3e 100644 (file)
@@ -7,6 +7,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
index 4f8f7431177867f3657c54c18fdce2e1127ce0d4..88be7b9ea6e10a6129d867f1abcc8890097f6bf1 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/timer.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <asm/atomic.h>
 #include <asm/debug.h>
 #include <asm/qdio.h>
index 9942c1031b25332ba133ff4916907c395e4c0b7b..ce5f8910ff83a376e0d2df6fd3d4cd895662aa8c 100644 (file)
@@ -7,6 +7,7 @@
  *           Jan Glauber <jang@linux.vnet.ibm.com>
  */
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/debug.h>
 #include <asm/qdio.h>
index 20836eff88c574c4094e9b5b8f392972b4e0c516..91c6028d7b74016157bba24247da45cf5aac141d 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include <linux/notifier.h>
 #include <linux/kthread.h>
 #include <linux/mutex.h>
index ba50fe02e572a40957780eebf825581e46c7c1c6..304caf549973268496d076298def900a38be061d 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/seq_file.h>
 #include <linux/compat.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 #include <linux/hw_random.h>
index c6fb0aa895074ad417c3c6949fd2a4b6b424f9d3..9c409efa1ecf49dd0170b433fba563f7edc653b8 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
 #include <asm/atomic.h>
index e78df3671caf46ea42715fccab429954e1dfd0f5..09e934b295a0210e67c5649cebfea9597d0a1c6f 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/err.h>
 #include <asm/atomic.h>
index 142f72a2ca5a75ec7ea1bf4d2d3fa2a2219dad1f..9dec5c77cff46869def7d4f70a05b183f9da95f7 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/err.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
index 68f3e6204db87079d5c1f49e700a1309026d3624..510fab4577d430f56f303a39b2601439943701b2 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 
index b2fc4fd63f7f09b1be3ee84ac90d12287e6ec99e..4e298bc8949d36c84a1fb5cdecbe67360369a7b0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/err.h>
 #include <linux/virtio.h>
 #include <linux/virtio_config.h>
+#include <linux/slab.h>
 #include <linux/virtio_console.h>
 #include <linux/interrupt.h>
 #include <linux/virtio_ring.h>
index 1ca58f15347048b775beb879012faf3e383a6f1b..d962fd741a2327cc68c33fea9d36bd4437057104 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/sysctl.h>
 #include <linux/module.h>
index 738ad26c74a737c1f6c9b5a8ceb6d853f7e86719..2b24550e865e672e9ef6761b667beba2231b235e 100644 (file)
@@ -14,6 +14,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 #include "ctcm_main.h"
 
 /*
index cae48cbc5e965b9f970728f0d8656a267636e276..e5dea67f902e81b3569eb6829f2926e14bab3622 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "fsm.h"
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 
 MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
index f6cc46dc0501644ca5eef0f82646b4876056bd37..9b19ea13b4d8593302620a60da62bf8c653abdef 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/igmp.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/ip.h>
 
index 3bd4206f347090fa793e1d67da31c1f22f3c1693..3ba738b2e27117eb4c932143fffedce377919df1 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/tcp.h>
 #include <linux/mii.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include <asm/ebcdic.h>
 #include <asm/io.h>
index 6f1e3036bafd00f1c6c7772a0f861a50c468ed96..6a801dc3bf8eb6546ccb3bc6960ca8b6c632ac4c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/etherdevice.h>
 #include <linux/mii.h>
 #include <linux/ip.h>
index b3b6e872d8066e640e6f9d7bea456625fae83760..fc6ca1da8b983b568d49271f4ec2914d72b76a1f 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ipv6.h>
 #include <linux/inetdevice.h>
 #include <linux/igmp.h>
+#include <linux/slab.h>
 
 #include <net/ip.h>
 #include <net/arp.h>
index 3f08b11274aeede53cffa6822738ebd4f5ed1396..25b3e7aae44f336ce9d354f8a99c37cfced240f6 100644 (file)
@@ -8,6 +8,8 @@
  *              Frank Blaschka <frank.blaschka@de.ibm.com>
  */
 
+#include <linux/slab.h>
+
 #include "qeth_l3.h"
 
 #define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \
index ecef1edee701013420d64fb99e2677e8a42e18df..70491274da16a7cf74120eaf79b416d12789c618 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <net/iucv/iucv.h>
 #include <asm/cpcmd.h>
 #include <asm/ebcdic.h>
index 91579dc6a2b059ae6959eae39d5cbca06ecaa0b2..137688790207248c5153d08ea880bcbec8d287a6 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/list.h>
 #include <linux/kobject.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <net/iucv/iucv.h>
index 66d6c01fcf3e32ed9e720ad4a3f58733f6c4798b..1e6183a86ce5f4f7ccd91cfdd0566ee85ff70db3 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/miscdevice.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "zfcp_ext.h"
 #include "zfcp_fc.h"
 #include "zfcp_reqlist.h"
index 0eb6eefd2c1a0c457e7d19cdbe536af1f72fd941..25d9e0ae9c5726abbc76b3c8a24b79f63e2f954f 100644 (file)
@@ -10,6 +10,7 @@
 #define KMSG_COMPONENT "zfcp"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/miscdevice.h>
 #include <asm/compat.h>
index 7a149fd85f6de3801e334df219809262742a987d..075852f6968c478d5920c9b5230470bf3e1c73d6 100644 (file)
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <asm/debug.h>
 #include "zfcp_dbf.h"
 #include "zfcp_ext.h"
index 5219670f0c99f015d61a5a8dea757c7c7c5061b5..2a1cbb74b99b624cb7bec855b16caba61dd7cf0f 100644 (file)
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <scsi/fc/fc_els.h>
 #include <scsi/libfc.h>
 #include "zfcp_ext.h"
index 6538742b421a1737ae84d766a34990ebfa484277..18564891ea6174b4afe18b7c997555012e38f6c1 100644 (file)
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/blktrace_api.h>
+#include <linux/slab.h>
 #include <scsi/fc/fc_els.h>
 #include "zfcp_ext.h"
 #include "zfcp_fc.h"
index 6479273a30940bd93743d6d66192fa03080b40ce..dbfa312a7f50bb19e66812c310f22cd02fa4439b 100644 (file)
@@ -9,6 +9,7 @@
 #define KMSG_COMPONENT "zfcp"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/slab.h>
 #include "zfcp_ext.h"
 #include "zfcp_qdio.h"
 
index c3c4178888afbc2a344c708add3d936f8256b59e..174b6d57d5769c23735ae137bdce73849031253f 100644 (file)
@@ -10,6 +10,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <scsi/fc/fc_fcp.h>
 #include <asm/atomic.h>
 #include "zfcp_ext.h"
index a43035d4bd70d6b4bca8947b9060de52c8d374e5..f5f60698dc4c96c0d69ff09db3dc0221a11c92c3 100644 (file)
@@ -9,6 +9,7 @@
 #define KMSG_COMPONENT "zfcp"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/slab.h>
 #include "zfcp_ext.h"
 
 #define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \
index 28d86f9df83c64717d3d173283cc5c5679c8a539..b4951eb0358e4046ca64bc38a7c9d2f2cd41dd4a 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/kmod.h>
 #include <linux/reboot.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 #include <linux/of_device.h>
 #include <asm/oplib.h>
 
index 4431578d8c451fb7f11d60703221efe6548c5cd7..3e59189f4137292f3eab85a11fe9a1db268649be 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/ioport.h>              /* request_region */
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index aa2b60a868baf0314b85591e3a7bb7fad837fd61..c6e2eff19409c6cd3cdf6c4bcbe75bd77cccc3fc 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/miscdevice.h>
 #include <linux/kmod.h>
 #include <linux/reboot.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index 41083472ff4f46298ce3c8f97484d38df6acb788..19f255b97c868aa14bab6dd4e057961e09f47e27 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
-#include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/poll.h>
 #include <linux/init.h>
index 869a30b49edc93620b38848b369395dbae37bf13..4942050dc5b6f0ea795d62e992368669ab1f6f6a 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
-#include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/poll.h>
 #include <linux/init.h>
index 84d3bbaa95e7868f8cb3d2aa20e3844c721e79c6..e9788f55ab1348050edff7025bf79fe0664cf11f 100644 (file)
@@ -91,6 +91,7 @@
 #include <linux/time.h>
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
index 4d314d740de443f34e28c100f88932c580f42c24..54c5ffb1eaa14168b60daffce5918cb11ee24e41 100644 (file)
@@ -65,6 +65,7 @@
 #include <linux/time.h>
 #include <linux/mutex.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
index f65a1e92340c91b24841751c6d44f44657540da2..5faf903ca8c8257f879c9c07f7b77dbb242fa496 100644 (file)
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/time.h>
 #include <linux/mutex.h>
index 9f4a911a6d8c31af416dae58f29b47491bd38bf7..80dc3ac12cdef2b422cfc36778bad44c3fec0139 100644 (file)
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
index 1ddcf4031d4cf6b21dac5bb95e06ae7117eb577a..fc0b4b81d5522ddaff339d3dc6187ce72a4c7d9a 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/spinlock.h>
 #include <linux/jiffies.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <scsi/scsicam.h>
 
 #include <asm/dma.h>
index 1cdf09a4779a560532e7dc2edafc4dc4f91e2170..8647256ad66df3540e0fee4c264c202ef9bc0eca 100644 (file)
@@ -97,6 +97,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mca.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
index a8bbdc2273b84d8d110cf93e4b6462b1da2f97c8..afdbb9addf18aec48ba703152ce24e258de74129 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mca.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/delay.h>
index ff5716d5f044d2fdd3521cc264a5a738d37c74a2..dbbc601948e5328e4c9a0bbfeb18ee8ac7f7fd91 100644 (file)
@@ -69,7 +69,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
 
 #include <asm/io.h>
index 4b38c4750f77ab2f27af3a4ea9088d25e34cd64f..d8fe5b76fee030b549f1dc7577b1d9a8a963cf06 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/types.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 6970ce82c4ac37a7ca03d1c456596e92fcb81922..c35fc55f1c96b321ea5a6bd9f1665540eb8f93d4 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/types.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
index e3519fa5a3ba628e8fbb61a0846a3a1951efa42b..11ae6be8aeaf81ee466609eff419961d82c76d19 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
 #include <scsi/scsi_host.h>
index f70d9f8e79e5a871be73376296c33bfed3dcaa69..04057ab72a8bf2131f315d6a8ddf3bda5ab6e4d5 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
index b6a3c5c187b6ec2707505150da52610e9794ad9d..622c21c68e65f8be4b36b9169319bdfe66dfacf6 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/completion.h>
index 22626abdb630ac2e4e696213dfcc6e6e8c9b3e8f..9201afe65609bd23ee732818534b91d41252ea9b 100644 (file)
@@ -4781,12 +4781,14 @@ static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
        if (err) {
                printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
                       fwname, err);
+               asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
                return err;
        }
        if (fw->size < 4) {
                printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
                       fw->size, fwname);
                release_firmware(fw);
+               asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
                return -EINVAL;
        }
        chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -5110,12 +5112,14 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
        if (err) {
                printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
                       fwname, err);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return err;
        }
        if (fw->size < 4) {
                printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
                       fw->size, fwname);
                release_firmware(fw);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return -EINVAL;
        }
        chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -5624,12 +5628,14 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
        if (err) {
                printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
                       fwname, err);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return err;
        }
        if (fw->size < 4) {
                printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
                       fw->size, fwname);
                release_firmware(fw);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return -EINVAL;
        }
        chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -6124,12 +6130,14 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
        if (err) {
                printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
                       fwname, err);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return err;
        }
        if (fw->size < 4) {
                printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
                       fw->size, fwname);
                release_firmware(fw);
+               asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
                return -EINVAL;
        }
        chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
index 1e5478abd90ee8ae6c2371ff7f043d6f4f9122bf..8eab8587ff21b6c35bb31129fd62a30d8ddc9f06 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
index 80594947c6f6c1a97117be2bedde8fa9b83c75a8..2a8cf137f609f695748328ca677d5289794a7bd4 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/blkdev.h>
 #include <linux/mca.h>
 #include <linux/mca-legacy.h>
+#include <linux/slab.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
index 538135783aab017b0c2ba0ea782801912b0b93a1..0107a4cc33319bfef8c8e22cb5dbde9e9a700fe8 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/device.h>
 #include <linux/eisa.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
index 1222a7ac698ad0c0f16637d6f4d4c31fea7c43f5..4c41332a354bc46dfd60a1bf27f686d7075d8cd0 100644 (file)
@@ -53,6 +53,7 @@ static struct scsi_transport_template *ahd_linux_transport_template = NULL;
 #include <linux/blkdev.h>              /* For block_size() */
 #include <linux/delay.h>       /* For ssleep/msleep */
 #include <linux/device.h>
+#include <linux/slab.h>
 
 /*
  * Bucket size for counting good commands in between bad ones.
index 8cb05dc8e6a1f265aeaf22c3b85df6e0eacadae1..5e42dac23505f7b2dd27168eea34b03a0577a4f6 100644 (file)
@@ -129,6 +129,7 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL;
 #include <linux/mm.h>          /* For fetching system memory size */
 #include <linux/blkdev.h>              /* For block_size() */
 #include <linux/delay.h>       /* For ssleep/msleep */
+#include <linux/slab.h>
 
 
 /*
index eb9dc3195fdfdbe7918b7d3ce0a3547e53e55ce4..81b736c76fffab7bf40be168ff1ae3fb2388faad 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/firmware.h>
index 996f7224f90e2d32e39d9a109b5da16a814237e1..24ac2315c5c7f2becb398500382699a38e63fff0 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_host.h>
 
index ca55013b6ae588cd699dde7739faf1f8dcbc3025..c43698b1cb6449af1de81bb3059ffba83354bd6a 100644 (file)
@@ -24,6 +24,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <scsi/scsi_host.h>
 
 #include "aic94xx.h"
index 8630a75b2872730132e28a1b8d11350eeb37456e..edb43fda9f36f34d5834f3f516fc9227aea67af6 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "aic94xx.h"
index 8f98e33155e9dbd9e8c391544a08ef5bd306c5ec..d01dcc62b39a413f9e793dc6183c3614cb0bce91 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/module.h>
 #include <linux/firmware.h>
index 78eb86fc627666f3a5c2ceaa13205ada76149b4f..0add73bdf2a4f6f98d34379c9999b91313026a03 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/gfp.h>
 #include "aic94xx.h"
 #include "aic94xx_sas.h"
 #include "aic94xx_hwi.h"
index 47d5d19f8c9221bb3e288fdf779f7cc8994dadf5..ffbe2192da3c4bc42ac32e0bd8233db84eb1926f 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/timer.h>
 #include <linux/pci.h>
 #include <linux/aer.h>
+#include <linux/slab.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <asm/system.h>
index 4240b05aef6d191f8c7f5782ac2c51b07a403de3..158ebc3644d83f2188a1e0007950799db4246652 100644 (file)
@@ -651,6 +651,7 @@ static inline void NCR5380_print_phase(struct Scsi_Host *instance)
  * interrupt or bottom half.
  */
 
+#include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 
index b137e561f5bc715951145592d5569bae80e19893..ab5bdda6903e3f6f650fa63c203ab6401bcd71a4 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/pci.h>
 #include <linux/blkdev.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/io.h>
 
index fcfb29e02d8a039e5cc4cd8efa0984cedfbd17c5..dd5b105f8f47a73ab45e3c73e43a2f9f9353b52a 100644 (file)
@@ -19,6 +19,7 @@
  */
 #include <linux/reboot.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/blkdev.h>
 #include <linux/pci.h>
index 6bff08ea40291d6bb84b10c493e9eff806a1d6b7..13f5feb308c2304bb2559d33332670fe2f28b73f 100644 (file)
@@ -19,6 +19,7 @@
  *  bfad.c Linux driver PCI interface module.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kthread.h>
 #include "bfad_drv.h"
index d97f69191838239ad8132b5ab1c81b596e561fe0..6a2efdd5ef24b5b4ce3d675a3e10d708e695348e 100644 (file)
@@ -19,6 +19,7 @@
  *  bfa_attr.c Linux driver configuration interface module.
  */
 
+#include <linux/slab.h>
 #include "bfad_drv.h"
 #include "bfad_im.h"
 #include "bfad_trcmod.h"
index f9fc67a25bf2720fde382c56ab4753f2efd0baab..78f42aa57369572785d83e803a2a9db45a0b66a0 100644 (file)
@@ -19,6 +19,7 @@
  *  bfad_im.c Linux driver IM module.
  */
 
+#include <linux/slab.h>
 #include "bfad_drv.h"
 #include "bfad_im.h"
 #include "bfad_trcmod.h"
index 8e73dd9a625addab8e7c3f3f0173654bfcbc578f..7b096f2e38369065f609442796e177c198312ed2 100644 (file)
@@ -19,6 +19,7 @@
  *  rport.c Remote port implementation.
  */
 
+#include <linux/slab.h>
 #include <bfa.h>
 #include <bfa_svc.h>
 #include "fcbuild.h"
index 1af578dec276da2b2254cf85451d9c4c235503f0..18352ff821018b588f2094277564957ae46a2b9c 100644 (file)
@@ -11,6 +11,7 @@
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
  */
 
+#include <linux/gfp.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/libiscsi.h>
 #include "bnx2i.h"
index cb71dc984797fd8293ded5f6c7806acfc6204ed1..f2e9b18fe76c66b00d2714ef50458be05802894f 100644 (file)
@@ -12,6 +12,7 @@
  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
  */
 
+#include <linux/slab.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/libiscsi.h>
 #include "bnx2i.h"
index 5799cb5cba6b5643e4128cab450aa49d1f0f754c..d40ea2f5be106374a71d037b17eb7c91263b5e88 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/bvme6000hw.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
index fe11c1d4b31d58a5cab85c92be0e8e824330f9ae..4799d439120358395519b7c3def4dc0ff9575362 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/mutex.h>
 #include <linux/idr.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 344fd53b9954c263ef1189ee489e40d54cd5055a..b58d9134ac1b53cdd3f13defbdd79a03e142f956 100644 (file)
@@ -10,6 +10,7 @@
  * Written by: Karen Xie (kxie@chelsio.com)
  */
 
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/scatterlist.h>
 
index 87dd56b422bfb4ed07c783765d94c32e38173529..6761b329124decf34f89f0b86710ba542cbbdea7 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __CXGB3I_ULP2_DDP_H__
 #define __CXGB3I_ULP2_DDP_H__
 
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 /**
index b7c30585daddb577fc833179bf564d2646ef51d9..7b686abaae6459cfffabe331e053cd798b7226e1 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <linux/crypto.h>
 #include <linux/if_vlan.h>
 #include <net/dst.h>
index 3e08c430ff2997c25d2727d013f02f71aff0cb1c..a175be9c496f479c0687bf15a126a13fb0b13941 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 
 #include "cxgb3_defs.h"
index 9c38539557fc9fc356f383a91b8ebe121cd37bb7..dc5e3e77a351c5ec421f36a0be9f681427acbb3f 100644 (file)
@@ -12,6 +12,7 @@
  * Written by: Karen Xie (kxie@chelsio.com)
  */
 
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/crypto.h>
 #include <scsi/scsi_cmnd.h>
index 6c59c02c1ed9959e487e54258a1dd5f966742976..bd977be7544e37355c35b2addf55d02ef9747039 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/pci.h>
 #include <linux/list.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include <scsi/scsi.h>
index e19a1a55270c03b443e47cfbba7b15bd65cfe7fd..6fae3d285ae79d5680f3d1e5d4cad02f5b47d3b6 100644 (file)
@@ -21,6 +21,7 @@
  *               Mike Anderson <andmike@linux.vnet.ibm.com>
  */
 
+#include <linux/slab.h>
 #include <scsi/scsi_dh.h>
 #include "../scsi_priv.h"
 
index bc9e94f5915e1227a14262b907f14858711c134b..1a970a76b1b959cc3906dd0579159b22eb1eaadc 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
  */
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_dh.h>
index 63032ec3db92a684863555cd4275e7d94e2de47b..e8a0bc3efd491a91d212233e46c3b29f94498967 100644 (file)
@@ -20,6 +20,7 @@
  * along with this program; see the file COPYING.  If not, write to
  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_dh.h>
index 857fdd6032b25a8df5efee8e70740ea135ae07be..e3916641e627883418d18b4eeb94bcbe1ddec018 100644 (file)
@@ -21,6 +21,7 @@
  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_eh.h>
index 1a660191a90547039ae7b5815e3ad8620a8b79d3..5b683e4295420a2e3e67dd3f298cebbec9c3273d 100644 (file)
@@ -23,6 +23,7 @@
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_dh.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #define RDAC_NAME "rdac"
 #define RDAC_RETRY_COUNT 5
index 3c5abf7cd762d0fa3229e37fc14914e86d64de89..d1c31378f6da9823b67e895ae7143578cfa110ee 100644 (file)
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include <asm/dma.h>
 #include <asm/io.h>
index 152dd15db276c42af82ccc39bde3ed0d9d346cb3..60886c19065e290a4475822d183aa92c8dc4de0c 100644 (file)
@@ -50,7 +50,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/in.h>
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
index 2f47ae7cce91a21069d4335b603bc26aa6320613..f01b9b44e8aa8a6ab387a969e7b7701400a4d1cf 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <linux/cpu.h>
 #include <linux/fs.h>
 #include <linux/sysfs.h>
index 511cb6b371eec6429b92cd7a9bfd7c626a1d0357..3440da48d1698d3b2fde2796d1df1ea333edd3a9 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/if_vlan.h>
 #include <linux/errno.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <net/rtnetlink.h>
 
 #include <scsi/fc/fc_els.h>
index 85bd54c77b50b950947157d4521370ce2dec36b3..2ad95aa8f58536a664a4c7d2114c4505d27355fe 100644 (file)
@@ -88,6 +88,7 @@
 #include <linux/delay.h>
 #include <linux/mca.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <scsi/scsicam.h>
 #include <linux/mca-legacy.h>
 
index 32eef66114c74a40cb01ab6b8351ccc1af38e997..e296bcc57d5c8920a2b90cf9a0858cac91e60d07 100644 (file)
 #include <linux/stat.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <scsi/scsicam.h>
 
 #include <asm/system.h>
index 54f8d0e5407f4ba179344bedb06e68d1f260bd87..5259888fbfb19fe95137dfdbe9f543e0c56e7cec 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/errno.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
index 507e26c1c29f05c29727509ba3aaf8e363da5306..97b212570bcc67f2431d86b17740e1051812f031 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/mempool.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/pci.h>
index 65a39b0f6dc24a6430d4434bb59312d594a5ead5..3cc47c6e1ada8d4e38309cc496bfca641d090102 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
index 566770645086612f9371b6be1f3e83f0d34d0e0a..db710148d1568ba8d3b7e12b726954c767a8c09e 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 #include "vnic_resource.h"
 #include "vnic_devcmd.h"
 #include "vnic_dev.h"
index bedd0d285630287ffc1b5d5cc379437cd3da4734..fd2068f5ae1675478d6ee2edd325633581a79f7c 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "vnic_dev.h"
 #include "vnic_rq.h"
 
index 1f9ea790d1301c6d604fa60b4d5350e40b00c7b2..a414135460dba770e318ffa72746a6972fdcc3de 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include "vnic_dev.h"
 #include "vnic_wq.h"
 
index ba3c94c9c25f22cb00bbf2dd64db394e85c51944..35a4b3073ec3fa992a406162b9bf3dac038bff97 100644 (file)
 #include <linux/dma-mapping.h>
 #include <linux/list.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 
 #ifdef GDTH_RTC
 #include <linux/mc146818rtc.h>
index ffb2b21992bae81dc7424b130489141aed80eb8a..0572b9bf4bd6e79c8b7650a4ef970039744a58cf 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <linux/completion.h>
+#include <linux/slab.h>
 
 int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,   
                    int inout)
index 5d1bf7e3d245988649b75ac4ae352579a31cc087..48f406850c6507f1532f5a9d843d1eb4ed78ebe9 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/types.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 09dbcb847b73c307ecb835e6463735f00ce9139c..6660fa92ffa149a3419ca3c87f7744453e3706fb 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/string.h>
 #include <linux/mm.h>
index 4f0556571f80d933aa1fdc6f0b9ed34a493e2790..645f7cdf21abb377731690c393434b0c202c1507 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/spinlock.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/div64.h>
index 4e577e2fee3888f6ef5c555bdbf754722528e2d4..c2eea711a5ceea72103b8ac4bbeff90519c2747e 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/pm.h>
 #include <linux/stringify.h>
index dc1bcbe3b1765789a09439d3cd2f6bbe34c34aa8..ff5ec5ac1fb5803651dd45501b10c0e8a117cdc9 100644 (file)
@@ -70,6 +70,7 @@
 #include <linux/moduleparam.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/pm.h>
 #include <asm/firmware.h>
index d5eaf972710978a9b24464c4e20fadbdac5babae..e2056d517e99d07fdf4b2bd3f4771643b5e9bfa1 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport_srp.h>
index 63a30cbbf9de5396629b9e061fc9438b88ea56b0..a864ccc0a342867d387c949e3e11b44ff071f95f 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/iommu.h>
 #include <asm/hvcall.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include "ibmvscsi.h"
 
index c2a9a13d788f2bb6f68e7c921b71270a5dc6d20b..4734ab0b3ff6ab9297352d532bf5aeb530757fe8 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/parport.h>
 #include <linux/workqueue.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include <scsi/scsi.h>
index c79cd98eb6bfed927e635c2731f65f8dbf5d5d5b..520461b9bc09036449f1ff2ccd58a09f538ed84f 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
index 249053a9d4fa74c483ecc7f41eb0c77ae2aadbf7..0ee725ced51104944b1d5ef56339a7e4fde0578c 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/types.h>
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/blkdev.h>
 #include <linux/crypto.h>
index b2d481dd37505f43f25d9c0cc79659e900bb25ca..08e26d4e3731c4d35dd010317b4d642947dbbc51 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/init.h>
index b3d31315ac32daea6321968eedca52cb921ade3a..23880f8fe7e4fccb985997d782fce852b916ed54 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/blkdev.h>
 #include <linux/ioport.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 #include <asm/pgtable.h>
index 9b0a5192a965d94552396d9ccac680892c795921..1087a7f18e845d9b1bafd8b7ba26b34581645f27 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <asm/unaligned.h>
 
index 7f4364770e4a5b90050e28fbc5cbe8fb634e8e88..e5df0d4db67ed7190e5d6a5c6d4e178cd039bc42 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #include <linux/timer.h>
-#include <linux/gfp.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 
 #include <scsi/fc/fc_fc2.h>
index 774e7ac837a593ba69d2bf6be41f7a660a129a60..17396c708b0807aaf57f36fda331c6045f1a4411 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/scatterlist.h>
 #include <linux/err.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsi.h>
index 6da01c6169641ee882df5f56359b474485abef30..981329a17c488384491ee1bc31169586635ba85c 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/crc32.h>
+#include <linux/gfp.h>
 
 #include <scsi/fc_frame.h>
 
index 7ec8ce75007c06ba4bcbe02b3dd81071818c394e..d126ecfff70484ea49908f1cde4e8d007a64bbb8 100644 (file)
@@ -88,6 +88,7 @@
  */
 
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include <scsi/fc/fc_gs.h>
index 97923bb07765e60cc43c121666c0e9b19a4734fb..b37d0ff28b352c380f5359bfe0e1b6e72faf7cfd 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/rcupdate.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
index 685eaec532180d107de1dbff954a9e679170b1ea..6d5ae4474bb32fb77b7f1051bcbf15d89fb47892 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kfifo.h>
 #include <linux/delay.h>
 #include <linux/log2.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <net/tcp.h>
 #include <scsi/scsi_cmnd.h>
@@ -3087,14 +3088,15 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
                session->state = ISCSI_STATE_TERMINATE;
        else if (conn->stop_stage != STOP_CONN_RECOVER)
                session->state = ISCSI_STATE_IN_RECOVERY;
+
+       old_stop_stage = conn->stop_stage;
+       conn->stop_stage = flag;
        spin_unlock_bh(&session->lock);
 
        del_timer_sync(&conn->transport_timer);
        iscsi_suspend_tx(conn);
 
        spin_lock_bh(&session->lock);
-       old_stop_stage = conn->stop_stage;
-       conn->stop_stage = flag;
        conn->c_stage = ISCSI_CONN_STOPPED;
        spin_unlock_bh(&session->lock);
 
index 4ad87fd74ddd926be593e684ca3d9c0f37bb9917..5c92620292fba3b6e35076f366db1b338228c9a4 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/blkdev.h>
 #include <linux/crypto.h>
index e15501170698a19957d22f92c6fbc2e3e89ac0c6..b00efd19aadb38a64bdd4a24245dacbf77dd5974 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include <scsi/sas_ata.h>
 #include "sas_internal.h"
index facc5bfcf7db673ae9f994a6e2c5deb1507bcd9a..f5831930df9bd31e540516b792673f8fd7ce5ab5 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_eh.h>
 #include "sas_internal.h"
index 33cf988c8c8a2cd25548ce5be0f67d97ee58e997..c65af02dcfe832f59ff2a8f5ff05b4c18b8d7323 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/scatterlist.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include "sas_internal.h"
 
index 1bc3b75679947ac1d8bcca33d132835cf16854f8..04ad8dd1a74cf8267982e29a551efd1503a5ef1c 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/scatterlist.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include "sas_internal.h"
 
index 9cd5abe9e714e3f243ffddce6cda0500f3257f92..2dc55343f671f6c7b4fa681278233c85c3db314e 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/spinlock.h>
index 14b13196b22d0ab57619a51e1c4753d525a6144a..2660e1b4569a21adb1217a178b4994c3165c1943 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/err.h>
 #include <linux/blkdev.h>
 #include <linux/freezer.h>
+#include <linux/gfp.h>
 #include <linux/scatterlist.h>
 #include <linux/libata.h>
 
index 22775165bf6ad79371b72db2055ee5e93a465d23..ff6a28ce9b6900f647145120830cb7de96b439b7 100644 (file)
@@ -19,6 +19,7 @@
  * 02110-1301 USA
  */
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/kfifo.h>
 #include <linux/scatterlist.h>
 #include <linux/dma-mapping.h>
index 64cd17eedb642a5ac0c46f8d7eab3061bb1ed46d..1849e33e68f91ef5facd2bfa23bc6037d952450b 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/aer.h>
+#include <linux/gfp.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
index 692c29f6048e3cfaf80239e2096df7991de99db6..ec3723831e8968c5d6dc4080f5f5bc46ce4989f0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/mempool.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include <scsi/scsi.h>
index c7e921973f66adedf93bb087f229b4e3fc2485ea..463b74902ac4b2b32368e2b99227321515e1d314 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/blkdev.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/utsname.h>
 
 #include <scsi/scsi.h>
index 391584183d81fc7102453bd73a5f7faf1a5e1798..a80d938fafc90ae1530f9c2b8573a4ed39e61242 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/idr.h>
 #include <linux/interrupt.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
 #include <linux/ctype.h>
index ee980bd668691b01467f835e8b28668a2f18a5fa..5fbdb22c1899a82be318ff127b28d93ffa1f8285 100644 (file)
@@ -21,6 +21,7 @@
 /* See Fibre Channel protocol T11 FC-LS for details */
 #include <linux/blkdev.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 
 #include <scsi/scsi.h>
index c555e3b7f202cf25dc8683b7363a2a1a0d9dcd50..e1466eec56b703ce1d8fda03d85d29b2be1d31cd 100644 (file)
@@ -20,6 +20,7 @@
  *******************************************************************/
 
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/kthread.h>
 #include <linux/interrupt.h>
index ea44239eeb3360796b6f21a99808af176448320e..774663e8e1fe0ff39caf1171de5c29b5ec6d3697 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/spinlock.h>
 #include <linux/ctype.h>
 #include <linux/aer.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
index 1e61ae3bc4eb5318a0ae6a56a81ae41837bb9805..72e6adb0643e09e50357706549a5a658703ee447 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 
 #include <scsi/scsi_device.h>
index a1b6db6016da0aee42bf9753833012d26bad85e9..8f879e477e9d3a666f7cc490072cda2b29deaba0 100644 (file)
@@ -20,6 +20,7 @@
  *******************************************************************/
 
 #include <linux/mempool.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 
index d20ae6b3b3cf77552ad7061d8e311b34dd3f85b9..e331204a4d56a38c62398d76ffc76dd6f32be16e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 
 #include <scsi/scsi.h>
index b16bb2c9978bce87d1f819a6aa251b39741c7edb..dccdb822328c2233ff72c89393acb663f53fc568 100644 (file)
@@ -19,6 +19,7 @@
  * included with this package.                                     *
  *******************************************************************/
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <asm/unaligned.h>
index fe6660ca6452f32b68f658093170b01d3dca1c39..049fb9a17b3f2c7ae730253709c65187289f418e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 869f76cbc58a8eb3bb3bc982b3e5f382043bd404..ffd575c379f34b9b046415f4c11737e10677b6e4 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/kthread.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <scsi/scsi.h>
index 4a90eaf7cb63ac5a7e8f874ca9868f596924567a..3893337e3dd3ff05155f7dd99cf5db356adde3f0 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/nubus.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/dma.h>
index 49eb0612d5af03f10e8b2ad591ed0bbf25943557..4bf7edca9e69a249fa29642650640250053dde56 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
index 7f977967b884892c5626a0e09c75756a7127d625..a7810a106b37aed653e5183c192e60d1758d30bb 100644 (file)
@@ -70,6 +70,7 @@
  * For history of changes, see Documentation/ChangeLog.megaraid
  */
 
+#include <linux/slab.h>
 #include "megaraid_mbox.h"
 
 static int megaraid_init(void);
index f680561d2c6f6101bac31fb4ad5ef7dcf2ded20c..36e0b7d05c1dbc13cc6252094f02b68fbabc02c4 100644 (file)
@@ -15,6 +15,7 @@
  * Common management module
  */
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include "megaraid_mm.h"
 
index 409648f5845f06c6ff3d0c435164efc060e561ba..99e4478c3f3ed4efc8d018ee2cc5f3b98d941514 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/smp_lock.h>
 #include <linux/uio.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/fs.h>
 #include <linux/compat.h>
index 11aa917629acda4924a7db48e2f7e5bd5254347f..a1c97e88068ae961ce3605ecfe1143f2c80af7b3 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
index 411c27d7f787f1bed4d85f7fd956d8f211709698..cf44b355bc972797cff74ea6b88e56c0d210ddcf 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/workqueue.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "mpt2sas_base.h"
 
index c7ec3f17478220e5637750a52fc5621a38390443..be171ed682e08c2fe165bcee16fa627cac33f702 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/raid_class.h>
+#include <linux/slab.h>
 
 #include "mpt2sas_base.h"
 
index 789f9ee7f00157fa10ec3f292725c9b1ee666d7c..bd7ca2b49f81516989469f84971e726a9227d5bb 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/workqueue.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index b5fbfd6ce870af0294bb909fa3ea42455bf8a8ae..39f554f5f26114b1e5a7f401036974d9119cc697 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <asm/mvme16xhw.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
index aa2270af1bac55c2d926c14ff955ac5d85cc15ad..885858bcc403b56e906a30bc5883d21d2b4e761c 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <scsi/libsas.h>
 #include <scsi/scsi_tcq.h>
index a2d569828308f341bb8261b7ff824f118ee74cad..d013a2aa2fd54aac8e6d251f4aa2267ebe669922 100644 (file)
@@ -98,6 +98,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
index 2c98a6ee973bc442d8ce40a924be3c456aa9ac6f..4c1e545452009c957baed7fa590018d93b4a3bfe 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/ioport.h>
index 60de8509150228a5bd09210b54420b2cefa91ecf..ee4b6914667f9cb2a55c9f20f493bfb971357a9d 100644 (file)
@@ -39,6 +39,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
+
 #include <scsi/osd_initiator.h>
 #include <scsi/osd_sec.h>
 #include <scsi/osd_attributes.h>
index 0a90702b3d710101904b73defb89a9a8d5580c67..ffdd9fdb9995bcd158ae293e353fbaf99a19171f 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/idr.h>
 #include <linux/major.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_driver.h>
index acb835837eec6213cae3f70679406570a5eba557..b219118f8bd6abccc03d6cc9e3c9f4500c7c9de3 100644 (file)
@@ -38,6 +38,7 @@ static const char * osst_version = "0.99.4";
 #include <linux/sched.h>
 #include <linux/proc_fs.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/errno.h>
index 14b13acae6dde617a416d85a4c05185dbb61b0a3..45bc197bc22f2a45c46f5176cabefddc69e077f2 100644 (file)
@@ -38,6 +38,7 @@
  *
  */
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include "pm8001_sas.h"
 #include "pm8001_ctl.h"
 
index 7985ae45d68867487cad097777cdbbc0f11918fe..909c00ec044f35e0904b19ce9c900917f02a03a8 100644 (file)
@@ -37,6 +37,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  *
  */
+ #include <linux/slab.h>
  #include "pm8001_sas.h"
  #include "pm8001_hwi.h"
  #include "pm8001_chips.h"
index f80c1da8f6ca340b187ae08fc3a09e3341fe99b7..f8c86b28f03f8155c70c9303c9f57de9543acff9 100644 (file)
@@ -38,6 +38,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include "pm8001_sas.h"
 #include "pm8001_chips.h"
 
index 3b2c98fba834323e000d77eeae2fb3d7b3b2f3a9..bff4f5139b9cb87dceedeb7074a479047f1b686e 100644 (file)
@@ -38,6 +38,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include "pm8001_sas.h"
 
 /**
index 9b1c1433c26bd1b538833397bd8e38d5f619a6da..53aefffbaead2027c09d2da7925fe3c0afecb607 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/hdreg.h>
 #include <linux/version.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/irq.h>
 #include <asm/processor.h>
 #include <linux/libata.h>
index 8aa0bd987e29e95d2f18578e8d64c9900e59062e..7bc2d796e4037712dd1113fe1e94d81f09782b85 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
 #include <linux/parport.h>
index db90caf43f42d06eccd70516c857aea39fe4e437..92ffbb5104980dc98bde7d839dce1cd6548d385d 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/cdrom.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 49ac4148493b9746a31cfdc50dcbe8a6d705f618..b8166ecfd0e35f17894a077679d5f5d2a29701cf 100644 (file)
 * General Public License for more details.
 *
 ******************************************************************************/
-#define QLA1280_VERSION      "3.27"
+#define QLA1280_VERSION      "3.27.1"
 /*****************************************************************************
     Revision History:
+    Rev  3.27.1, February 8, 2010, Michael Reed
+       - Retain firmware image for error recovery.
     Rev  3.27, February 10, 2009, Michael Reed
        - General code cleanup.
        - Improve error recovery.
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
-#include <linux/slab.h>
 #include <linux/pci_ids.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
@@ -538,9 +539,9 @@ __setup("qla1280=", qla1280_setup);
 /*****************************************/
 
 struct qla_boards {
-       unsigned char name[9];  /* Board ID String */
+       char *name;             /* Board ID String */
        int numPorts;           /* Number of SCSI ports */
-       char *fwname;           /* firmware name        */
+       int fw_index;           /* index into qla1280_fw_tbl for firmware */
 };
 
 /* NOTE: the last argument in each entry is used to index ql1280_board_tbl */
@@ -561,15 +562,30 @@ static struct pci_device_id qla1280_pci_tbl[] = {
 };
 MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl);
 
+DEFINE_MUTEX(qla1280_firmware_mutex);
+
+struct qla_fw {
+       char *fwname;
+       const struct firmware *fw;
+};
+
+#define QL_NUM_FW_IMAGES 3
+
+struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = {
+       {"qlogic/1040.bin",  NULL},     /* image 0 */
+       {"qlogic/1280.bin",  NULL},     /* image 1 */
+       {"qlogic/12160.bin", NULL},     /* image 2 */
+};
+
+/* NOTE: Order of boards in this table must match order in qla1280_pci_tbl */
 static struct qla_boards ql1280_board_tbl[] = {
-       /* Name ,  Number of ports, FW details */
-       {"QLA12160",    2, "qlogic/12160.bin"},
-       {"QLA1040",     1, "qlogic/1040.bin"},
-       {"QLA1080",     1, "qlogic/1280.bin"},
-       {"QLA1240",     2, "qlogic/1280.bin"},
-       {"QLA1280",     2, "qlogic/1280.bin"},
-       {"QLA10160",    1, "qlogic/12160.bin"},
-       {"        ",    0, "   "},
+       {.name = "QLA12160", .numPorts = 2, .fw_index = 2},
+       {.name = "QLA1040" , .numPorts = 1, .fw_index = 0},
+       {.name = "QLA1080" , .numPorts = 1, .fw_index = 1},
+       {.name = "QLA1240" , .numPorts = 2, .fw_index = 1},
+       {.name = "QLA1280" , .numPorts = 2, .fw_index = 1},
+       {.name = "QLA10160", .numPorts = 1, .fw_index = 2},
+       {.name = "        ", .numPorts = 0, .fw_index = -1},
 };
 
 static int qla1280_verbose = 1;
@@ -1511,6 +1527,63 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha)
        return status;
 }
 
+/*
+ * qla1280_request_firmware
+ *      Acquire firmware for chip.  Retain in memory
+ *      for error recovery.
+ *
+ * Input:
+ *      ha = adapter block pointer.
+ *
+ * Returns:
+ *      Pointer to firmware image or an error code
+ *      cast to pointer via ERR_PTR().
+ */
+static const struct firmware *
+qla1280_request_firmware(struct scsi_qla_host *ha)
+{
+       const struct firmware *fw;
+       int err;
+       int index;
+       char *fwname;
+
+       spin_unlock_irq(ha->host->host_lock);
+       mutex_lock(&qla1280_firmware_mutex);
+
+       index = ql1280_board_tbl[ha->devnum].fw_index;
+       fw = qla1280_fw_tbl[index].fw;
+       if (fw)
+               goto out;
+
+       fwname = qla1280_fw_tbl[index].fwname;
+       err = request_firmware(&fw, fwname, &ha->pdev->dev);
+
+       if (err) {
+               printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
+                      fwname, err);
+               fw = ERR_PTR(err);
+               goto unlock;
+       }
+       if ((fw->size % 2) || (fw->size < 6)) {
+               printk(KERN_ERR "Invalid firmware length %zu in image \"%s\"\n",
+                      fw->size, fwname);
+               release_firmware(fw);
+               fw = ERR_PTR(-EINVAL);
+               goto unlock;
+       }
+
+       qla1280_fw_tbl[index].fw = fw;
+
+ out:
+       ha->fwver1 = fw->data[0];
+       ha->fwver2 = fw->data[1];
+       ha->fwver3 = fw->data[2];
+ unlock:
+       mutex_unlock(&qla1280_firmware_mutex);
+       spin_lock_irq(ha->host->host_lock);
+       return fw;
+}
+
 /*
  * Chip diagnostics
  *      Test chip for proper operation.
@@ -1634,30 +1707,18 @@ qla1280_chip_diag(struct scsi_qla_host *ha)
 static int
 qla1280_load_firmware_pio(struct scsi_qla_host *ha)
 {
+       /* enter with host_lock acquired */
+
        const struct firmware *fw;
        const __le16 *fw_data;
        uint16_t risc_address, risc_code_size;
        uint16_t mb[MAILBOX_REGISTER_COUNT], i;
-       int err;
+       int err = 0;
+
+       fw = qla1280_request_firmware(ha);
+       if (IS_ERR(fw))
+               return PTR_ERR(fw);
 
-       spin_unlock_irq(ha->host->host_lock);
-       err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname,
-                              &ha->pdev->dev);
-       spin_lock_irq(ha->host->host_lock);
-       if (err) {
-               printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
-                      ql1280_board_tbl[ha->devnum].fwname, err);
-               return err;
-       }
-       if ((fw->size % 2) || (fw->size < 6)) {
-               printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
-                      fw->size, ql1280_board_tbl[ha->devnum].fwname);
-               err = -EINVAL;
-               goto out;
-       }
-       ha->fwver1 = fw->data[0];
-       ha->fwver2 = fw->data[1];
-       ha->fwver3 = fw->data[2];
        fw_data = (const __le16 *)&fw->data[0];
        ha->fwstart = __le16_to_cpu(fw_data[2]);
 
@@ -1675,11 +1736,10 @@ qla1280_load_firmware_pio(struct scsi_qla_host *ha)
                if (err) {
                        printk(KERN_ERR "scsi(%li): Failed to load firmware\n",
                                        ha->host_no);
-                       goto out;
+                       break;
                }
        }
-out:
-       release_firmware(fw);
+
        return err;
 }
 
@@ -1687,6 +1747,7 @@ out:
 static int
 qla1280_load_firmware_dma(struct scsi_qla_host *ha)
 {
+       /* enter with host_lock acquired */
        const struct firmware *fw;
        const __le16 *fw_data;
        uint16_t risc_address, risc_code_size;
@@ -1701,24 +1762,10 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
                return -ENOMEM;
 #endif
 
-       spin_unlock_irq(ha->host->host_lock);
-       err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname,
-                              &ha->pdev->dev);
-       spin_lock_irq(ha->host->host_lock);
-       if (err) {
-               printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
-                      ql1280_board_tbl[ha->devnum].fwname, err);
-               return err;
-       }
-       if ((fw->size % 2) || (fw->size < 6)) {
-               printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
-                      fw->size, ql1280_board_tbl[ha->devnum].fwname);
-               err = -EINVAL;
-               goto out;
-       }
-       ha->fwver1 = fw->data[0];
-       ha->fwver2 = fw->data[1];
-       ha->fwver3 = fw->data[2];
+       fw = qla1280_request_firmware(ha);
+       if (IS_ERR(fw))
+               return PTR_ERR(fw);
+
        fw_data = (const __le16 *)&fw->data[0];
        ha->fwstart = __le16_to_cpu(fw_data[2]);
 
@@ -1803,7 +1850,6 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
 #if DUMP_IT_BACK
        pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf);
 #endif
-       release_firmware(fw);
        return err;
 }
 
@@ -1842,6 +1888,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha)
 static int
 qla1280_load_firmware(struct scsi_qla_host *ha)
 {
+       /* enter with host_lock taken */
        int err;
 
        err = qla1280_chip_diag(ha);
@@ -4420,7 +4467,16 @@ qla1280_init(void)
 static void __exit
 qla1280_exit(void)
 {
+       int i;
+
        pci_unregister_driver(&qla1280_pci_driver);
+       /* release any allocated firmware images */
+       for (i = 0; i < QL_NUM_FW_IMAGES; i++) {
+               if (qla1280_fw_tbl[i].fw) {
+                       release_firmware(qla1280_fw_tbl[i].fw);
+                       qla1280_fw_tbl[i].fw = NULL;
+               }
+       }
 }
 
 module_init(qla1280_init);
index 90d1e062ec4f13461bc428d41c17f4e03e007932..359e9a71a021498ddf1211b826ac65ef9e673cec 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/kthread.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 static int qla24xx_vport_disable(struct fc_vport *, bool);
@@ -1274,7 +1275,11 @@ qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
        int rval = QLA_FUNCTION_FAILED;
        uint16_t state[5];
 
-       if (!vha->hw->flags.eeh_busy)
+       if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
+               test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
+               DEBUG2_3_11(printk("%s(%ld): isp reset in progress.\n",
+                       __func__, vha->host_no));
+       else if (!vha->hw->flags.eeh_busy)
                rval = qla2x00_get_firmware_state(vha, state);
        if (rval != QLA_SUCCESS)
                memset(state, -1, sizeof(state));
index cebf4f1bb7d9686248a8abb6f787e75c2658ac00..42c5587cc50cd0e8cfdc24edb6e6c038d04cdf0a 100644 (file)
@@ -1592,10 +1592,22 @@ struct nvram_81xx {
 
        /* Offset 384. */
        uint8_t reserved_21[16];
-       uint16_t reserved_22[8];
+       uint16_t reserved_22[3];
+
+       /*
+        * BIT 0 = Extended BB credits for LR
+        * BIT 1 = Virtual Fabric Enable
+        * BIT 2 = Enhanced Features Unused
+        * BIT 3-7 = Enhanced Features Reserved
+        */
+       /* Enhanced Features */
+       uint8_t enhanced_features;
+
+       uint8_t reserved_23;
+       uint16_t reserved_24[4];
 
        /* Offset 416. */
-       uint16_t reserved_23[32];
+       uint16_t reserved_25[32];
 
        /* Offset 480. */
        uint8_t model_name[16];
@@ -1603,7 +1615,7 @@ struct nvram_81xx {
        /* Offset 496. */
        uint16_t feature_mask_l;
        uint16_t feature_mask_h;
-       uint16_t reserved_24[2];
+       uint16_t reserved_26[2];
 
        uint16_t subsystem_vendor_id;
        uint16_t subsystem_device_id;
index a67b2bafb88242201a047da0e47dc8880d9a6312..4229bb483c5e02421d5746c8070a42450392ddec 100644 (file)
@@ -8,6 +8,7 @@
 #include "qla_gbl.h"
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "qla_devtbl.h"
index ab90329ff2e4877ce57ccd15e1a7ee28ab5acd9f..db539b0c3dae71cbe8b86609b44409c6c7f3f56b 100644 (file)
@@ -7,6 +7,7 @@
 #include "qla_def.h"
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsi_bsg_fc.h>
 
@@ -620,11 +621,10 @@ skip_rio:
                 *           vp_idx does not match
                 *       Event is not global, vp_idx does not match
                 */
-               if ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff)
-                       || (mb[1] != 0xffff)) {
-                       if (vha->vp_idx != (mb[3] & 0xff))
-                               break;
-               }
+               if (IS_QLA2XXX_MIDTYPE(ha) &&
+                   ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) ||
+                       (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff))
+                       break;
 
                /* Global event -- port logout or port unavailable. */
                if (mb[1] == 0xffff && mb[2] == 0x7) {
@@ -2272,30 +2272,28 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
 
        /* If possible, enable MSI-X. */
        if (!IS_QLA2432(ha) && !IS_QLA2532(ha) &&
-           !IS_QLA8432(ha) && !IS_QLA8001(ha))
-               goto skip_msix;
+               !IS_QLA8432(ha) && !IS_QLA8001(ha))
+               goto skip_msi;
+
+       if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
+               (ha->pdev->subsystem_device == 0x7040 ||
+               ha->pdev->subsystem_device == 0x7041 ||
+               ha->pdev->subsystem_device == 0x1705)) {
+               DEBUG2(qla_printk(KERN_WARNING, ha,
+                       "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X,0x%X).\n",
+                       ha->pdev->subsystem_vendor,
+                       ha->pdev->subsystem_device));
+               goto skip_msi;
+       }
 
        if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX ||
                !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) {
                DEBUG2(qla_printk(KERN_WARNING, ha,
                "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n",
                        ha->pdev->revision, ha->fw_attributes));
-
                goto skip_msix;
        }
 
-       if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
-           (ha->pdev->subsystem_device == 0x7040 ||
-               ha->pdev->subsystem_device == 0x7041 ||
-               ha->pdev->subsystem_device == 0x1705)) {
-               DEBUG2(qla_printk(KERN_WARNING, ha,
-                   "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X, 0x%X).\n",
-                   ha->pdev->subsystem_vendor,
-                   ha->pdev->subsystem_device));
-
-               goto skip_msi;
-       }
-
        ret = qla24xx_enable_msix(ha, rsp);
        if (!ret) {
                DEBUG2(qla_printk(KERN_INFO, ha,
index 6e53bdbb1da8ffe3a3fb240a9867efd08fbf3efd..42eb7ffd5942ed2e9a4243a01ece11e85bceeb0f 100644 (file)
@@ -7,6 +7,7 @@
 #include "qla_def.h"
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 
 /*
@@ -339,6 +340,7 @@ qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr,
        return rval;
 }
 
+#define        EXTENDED_BB_CREDITS     BIT_0
 /*
  * qla2x00_execute_fw
  *     Start adapter firmware.
@@ -371,7 +373,12 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
                mcp->mb[1] = MSW(risc_addr);
                mcp->mb[2] = LSW(risc_addr);
                mcp->mb[3] = 0;
-               mcp->mb[4] = 0;
+               if (IS_QLA81XX(ha)) {
+                       struct nvram_81xx *nv = ha->nvram;
+                       mcp->mb[4] = (nv->enhanced_features &
+                           EXTENDED_BB_CREDITS);
+               } else
+                       mcp->mb[4] = 0;
                mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1;
                mcp->in_mb |= MBX_1;
        } else {
index ff17dee286131f3c6ba49a9f5c1626bb93189b3a..8220e7b9799bb4cc7dd819bd28dc59c11f082a96 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 
 #include <scsi/scsi_tcq.h>
index 46720b23028f72850989cdef77b3a13cd477479f..48c37e38ed0172b137b99a0effaabc9049375a9b 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <linux/kobject.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsicam.h>
@@ -1676,9 +1677,11 @@ skip_pio:
 
        /* Determine queue resources */
        ha->max_req_queues = ha->max_rsp_queues = 1;
-       if ((ql2xmaxqueues <= 1 || ql2xmultique_tag < 1) &&
+       if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) ||
+               (ql2xmaxqueues > 1 && ql2xmultique_tag) ||
                (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
                goto mqiobase_exit;
+
        ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
                        pci_resource_len(ha->pdev, 3));
        if (ha->mqiobase) {
index 371dc895972ae349ffb878eff28b62b5015e8366..8b3de4e54c28bfb5ebdd6b5901e62e37101fe36f 100644 (file)
@@ -7,6 +7,7 @@
 #include "qla_def.h"
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <asm/uaccess.h>
 
index 8d2fc2fa7a6be830f5bedad880cf5e85c9891c05..109068df933fe794275c2f01426524416cc8f403 100644 (file)
@@ -7,9 +7,9 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION      "8.03.02-k1"
+#define QLA2XXX_VERSION      "8.03.02-k2"
 
 #define QLA_DRIVER_MAJOR_VER   8
 #define QLA_DRIVER_MINOR_VER   3
 #define QLA_DRIVER_PATCH_VER   2
-#define QLA_DRIVER_BETA_VER    1
+#define QLA_DRIVER_BETA_VER    2
index 83c8b5e4fc8b45856a37f2a58fb5727a4a740fa7..2ccad36bee9f0843a6807ede4cd44b5fd62dc48f 100644 (file)
@@ -5,6 +5,7 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsicam.h>
index 1b8217076b0e6e18d2ff0ee5f16963ecc0ac8f86..aa406497eebcf912cd296dd1554fdc9120611aa2 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/string.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/blkdev.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
index 0b575c8710075e48c183547ac0dfd42eda6adb1e..3e10c306de946b76002738fc0b214a786d6cbc7b 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/genhd.h>
index 37af178b2d1743b0b3d3da54f8a6880faaa602ce..43fad4c09beb6714ec2712fbc1ba8d39af607845 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/moduleparam.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_devinfo.h>
index 08ed506e6059db96cd09c02588ea306800a54cb0..d45c69ca5737b335644fb4490bedf3fd6cf8779c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
index 0fd6ae6911ad822eb035fd3c7fb020bd1e7799f8..d53e6503c6d5bd052df0f98c7047a5edcae29e6c 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/jiffies.h>
 #include <linux/security.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netlink.h>
 
index 77fbddb507fdcb65b5d4fc940e6780ae756f6da9..c99da926fdac02e1d5a43faa9a9436f4d55a8f0b 100644 (file)
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/errno.h>
 #include <linux/blkdev.h>
 #include <linux/seq_file.h>
 #include <linux/mutex.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 
 #include <scsi/scsi.h>
index 4bc8b77a2ef3ae55d71606310213f3007f2c1a56..38518b0880739a5d2dded941e5b6cfbdb85c131d 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/kthread.h>
 #include <linux/spinlock.h>
 #include <linux/async.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 19ec9e2d3f391c1189e57b178173bd446ed14b20..429c9b73e3e4de02254ac71af588f334a21e877b 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/device.h>
index 0e9533f7aabc4bcd38befa28c1727db45cd41a1e..a87e21c35ef269ecae82f68e49ee235dd3d0eced 100644 (file)
@@ -20,6 +20,7 @@
  * 02110-1301 USA
  */
 #include <linux/miscdevice.h>
+#include <linux/gfp.h>
 #include <linux/file.h>
 #include <linux/smp_lock.h>
 #include <net/tcp.h>
index 10303272ba4573082f942a4ec8e9cd7e4d0a9e95..66241dd525ae7fac133197064a0eaa86e5e0e624 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/hash.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
index 1d5b72173dd8fb9a3df7ed1901716b2722a5a467..6cfffc88022a317490a91e34704b3d3bbbddffd8 100644 (file)
@@ -27,6 +27,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
@@ -3852,7 +3853,7 @@ fc_bsg_request_handler(struct request_queue *q, struct Scsi_Host *shost,
                if (rport && (rport->port_state != FC_PORTSTATE_ONLINE)) {
                        req->errors = -ENXIO;
                        spin_unlock_irq(q->queue_lock);
-                       blk_end_request(req, -ENXIO, blk_rq_bytes(req));
+                       blk_end_request_all(req, -ENXIO);
                        spin_lock_irq(q->queue_lock);
                        continue;
                }
@@ -3862,7 +3863,7 @@ fc_bsg_request_handler(struct request_queue *q, struct Scsi_Host *shost,
                ret = fc_req_to_bsgjob(shost, rport, req);
                if (ret) {
                        req->errors = ret;
-                       blk_end_request(req, ret, blk_rq_bytes(req));
+                       blk_end_request_all(req, ret);
                        spin_lock_irq(q->queue_lock);
                        continue;
                }
index ea3892e7e0f76a46ef219c12e97b23e13abe326e..1e6d4793542c30943602fbc13a2abcbae82080b2 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/tcp.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
index c25bd9a34e02f4fa2b106694d0e93a8fa28b1e3b..8a172d4f4564670c57450d06f484af6be0052827 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include "scsi_priv.h"
 #include <scsi/scsi_device.h>
index 3f21bc65e8c66e6cbbb65d6a376de096a3cdfbee..6803b1e26eccd63986dda5198bcc9cc2abe36f38 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/genhd.h>
 #include <linux/kernel.h>
index 7b75c8a2a49dbdd9e607f67722c92136d8178f4c..58c62ff42ab3953f98e27e230f236bb4cb98d99f 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/mutex.h>
 #include <linux/string_helpers.h>
 #include <linux/async.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 
index 0d9d6f7567f5a60352b5462fd48c056c279a191e..7f5a6a86f820fbae8baee63e7de722b480c96462 100644 (file)
@@ -21,6 +21,7 @@
 **-----------------------------------------------------------------------------
 */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/enclosure.h>
index c996d98636f340704b82c0fab8d445c1591823ff..dee1c96288d4420e2461c68c4d18ac253d46c6f7 100644 (file)
@@ -38,6 +38,7 @@ static int sg_version_num = 30534;    /* 2 digits for each component */
 #include <linux/errno.h>
 #include <linux/mtio.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
 #include <linux/poll.h>
index 6dc8b846c1127ee75273817ba830ee6490d2ee72..8ac6ce792b696763e54a4a88c6eb6b3120492a31 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/blkdev.h>
 #include <linux/device.h>
index 56cf0bb4ed1f998af1d460d6ffa1725aa2014523..9acc2b2a36019f30fe2150feb55db56c3ae6730f 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/mm.h>
 #include <linux/blkdev.h>
index d6f340f48a3bcecebbf57aef61d5b0e8cd67d3b5..0a90abc7f140215fcc5aa50301ea927cd5564e8f 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #include <scsi/scsi.h>
index 291236e6e4351f6ef3517832b0e5ce901b7b26e3..cbb38c5197fad67299f32a36792ab1fc5cdeec3e 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/blkpg.h>
 #include <linux/cdrom.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 
index 4ad3e017213f868ed85af9a7032912194836abea..92cc2efb25d70e00d33e3b1a555f6b8505348a10 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/string.h>
 #include <linux/bcd.h>
 #include <linux/blkdev.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index f67d1a159aad9173982bacce034b88f7d7cb6732..3ea1a713ef250fcc35a64b10c71a65ac73ea6e42 100644 (file)
@@ -27,6 +27,7 @@ static const char *verstr = "20081215";
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/mtio.h>
 #include <linux/cdrom.h>
index fd7b15be7640fa8d5b89c616f76a849606704445..9c73dbda3bbb8d3137e8adaed717b61d83cf6551 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/pci.h>
 #include <linux/blkdev.h>
index 75da6e58ce550ecd03031cb05ee4d8a8b9290ba1..b5838d547c68aabdb62b4b6af7a57f5c823d94f7 100644 (file)
@@ -645,6 +645,7 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { };
  * interrupt or bottom half.
  */
 
+#include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 
index 34a99620e5bd35ca2d7ed411ed42004d59788240..0621037f027129970748ac77ad918ef0dd6d1442 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/module.h>
index 3d73aad4bc8201196946e2a1e2c19e4e98157327..fc23d273fb1a6c17d37a648e6fd05c1cbaccbf75 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/irq.h>
 #include <asm/io.h>
index 9a4273445c0d0537e61fe1f0dd732bc572779815..27866b0adfebd4901dbb1a38a4ebc752ecfd3d70 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include <scsi/scsi.h>
index 26e8e0e6b8ddeedd3b3c40b5d87a717ec84a5288..5d9fdeeb2315cdd5e9958bf24ea56cd3669fca47 100644 (file)
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
 
index e4ac5829b637b2c99e0cc7fdc37b7ba875bc1056..26894459c37fe375076464330ef7809345b57408 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/pci.h>
 
index 2f6e9d8eaf71b18bba107769b4dd38a2070b0587..d0b7d2ff9ac547235c2fc4fd1de2abccef15ad36 100644 (file)
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/ioport.h>
 #include <linux/proc_fs.h>
index 64d40a2d4d4d5699167d04d12cecea1c6574b7e0..105449c15fa95879bc6c01d69837573f7c75914f 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/zorro.h>
+#include <linux/slab.h>
 
 #include <asm/amigahw.h>
 #include <asm/amigaints.h>
index ae0251ef6f4ef76b087f119901a46f6d8c5c8b7b..78ed24bb6a35d4eb09f9a4f90939f5b4f7151d20 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/pm.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index c3db16b7afa12f6b43e94fe5437bde3ca7aeea4a..2b1ea3d4c4f41e4b444c0541ce9285703f5f28fc 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/serial_8250.h>
 #include <linux/nmi.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 33149d982e82a3e6329e811d9a8e2440f0a86858..d8c0ffbfa6e39b53bafaef22f2d090e2739613e9 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/module.h>
 #include <linux/serial_core.h>
 #include <linux/signal.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 
 #include <asm/hardware.h>
index 0e1410f2c03394362f25a07b6ce27981dff38ab2..c13438c930129a0b4e736fd67630a1ef9338345b 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/dio.h>
 #include <linux/console.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #include "8250.h"
index e4b3c2c88bb65098bd806219ac32f682cb3b2c90..b09a638d051fde98c37e52a58eb2cb9a25756663 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index ce6c35333ff7b9faaf65acfc087ace884f150c60..743ebf5f16da8942bc6c7d23508cc69cfd9eb229 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/serial.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/sizes.h>
index fcf273e3f48c5faee2741e316d7de927d3ac204e..96f7e7484feebf4269c631862f9a01b227eac0f6 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/ioport.h>
+#include <linux/gfp.h>
 #include <linux/io.h>
 #include <linux/init.h>
 #include <linux/console.h>
index 7c72888fbf94e20ca3c7982edeec7cffffc31c06..c88f8ad3ff821d16fef218c5021adede8c9c6cf1 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/sysrq.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
index 1b94c56ec23914a0c7a44acd04ebe61594f39273..3fc1d66e32c651cbcca46808a4aa1fac7ba9ca85 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/module.h>
 #include <linux/tty.h>
+#include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/serial.h>
index a9802e76b5fabbd91f44adedb16708fda49f289b..814ac006393fabac29f97d0f3cb129fe125f1ee3 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/tty.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -61,7 +62,7 @@ void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
        void __iomem *pram;
        unsigned long offset;
        struct resource res;
-       unsigned long len;
+       resource_size_t len;
 
        /* Don't remap parameter RAM if it has already been initialized
         * during console setup.
@@ -74,7 +75,7 @@ void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
        if (of_address_to_resource(np, 1, &res))
                return NULL;
 
-       len = 1 + res.end - res.start;
+       len = resource_size(&res);
        pram = ioremap(res.start, len);
        if (!pram)
                return NULL;
index e579d7a1807ab4728bed3d94520f5c8e1e499ae4..4315b23590bd9895ae867f9020446b33b8aae407 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/rational.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 23ba6b40b3ac4ac9d62f12c0ff2b55c5cd403a5c..f164ba4eba02292806cd04ece8864f7efb2f3570 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/pci.h>
 #include <linux/serial_core.h>
 #include <linux/ioc3.h>
+#include <linux/slab.h>
 
 /*
  * Interesting things about the ioc3
index 836d9ab4f729669ac11f941a3b3e246b367fdcb3..8ad28fc64926a88e2d5399439f3852d3818f243f 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/ioc4.h>
 #include <linux/serial_core.h>
+#include <linux/slab.h>
 
 /*
  * interesting things about the ioc4
index 12cb5e446a4f07580219360cdb6c61415d218df1..eaf545014119cda24fe4a115e5b3c3a7ffe9b9e4 100644 (file)
@@ -26,6 +26,7 @@
  ***********************************************************************/
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "jsm.h"
 
index 5673ca9dfdc884fce7150428207cff30b5941677..7a4a914ecff0b0b96186a61812528d2750d05f1a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/serial_reg.h>
 #include <linux/delay.h>       /* For udelay */
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "jsm.h"
 
index 3c30c56aa2e16eb4c24907545d1d423d39b10c08..3351c3bd59e4089f11bc3081df0c91443ab01a7e 100644 (file)
@@ -41,6 +41,7 @@
 #define MAX_MAX3100 4
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/serial_core.h>
 #include <linux/serial.h>
index b5496c28e60be5b486d90a587b9a5746f5f25a04..55e113a0be0332631f500e36ca560441db63092d 100644 (file)
@@ -70,6 +70,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mv643xx.h>
 #include <linux/platform_device.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index 7571aaa138b0ce1884b82826dff428efcbc2be30..9711e06a8374c73561524fc79369b20e4c33825b 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/serial.h>
 #include <linux/console.h>
-#include <linux/slab.h>
 #include <linux/delay.h> /* for udelay */
 #include <linux/device.h>
 #include <asm/io.h>
index cdf172eda2e3792a61abc155d1c63b7c0396b92c..4abfebdb0fccdb5ca4131c2c9bbe3c3cf0288eee 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
 #include <linux/of_platform.h>
index f020de1cdd5035155bbb4f3c95ba847e81b1c52b..4eaa043ca2a8c40552eebb258b7d447ef6de2818 100644 (file)
@@ -54,7 +54,6 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/console.h>
-#include <linux/slab.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
 #include <linux/bitops.h>
index 56ee082157aaf121c755fd3a42ef4005e9667f14..1102a39b44f5497c4daf4512123ba49fbeb9cf54 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/serial_core.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 struct uart_pxa_port {
        struct uart_port        port;
index e91db4b380120fb1eae857179c1d42006b545bb1..175d202ab37ee20c1915b871b27dfe8a122ec293 100644 (file)
@@ -745,6 +745,7 @@ static struct pcmcia_device_id serial_ids[] = {
        PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29),
        PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719),
        PCMCIA_PFC_DEVICE_PROD_ID12(1, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
+       PCMCIA_PFC_DEVICE_PROD_ID12(1, "ATKK", "LM33-PCM-T", 0xba9eb7e2, 0x077c174e),
        PCMCIA_PFC_DEVICE_PROD_ID12(1, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
        PCMCIA_PFC_DEVICE_PROD_ID12(1, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c),
        PCMCIA_PFC_DEVICE_PROD_ID12(1, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
index 980f39449ee5635ccb7b4f681151892e92a493b0..8eb094c1f61b2c2ab17cb68e420f16ad42428823 100644 (file)
@@ -50,7 +50,7 @@
 #include <linux/list.h>
 #include <linux/dmaengine.h>
 #include <linux/scatterlist.h>
-#include <linux/timer.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_SUPERH
 #include <asm/sh_bios.h>
@@ -780,10 +780,6 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
        if ((ssr_status & SCxSR_BRK(port)) && err_enabled)
                ret = sci_br_interrupt(irq, ptr);
 
-       WARN_ONCE(ret == IRQ_NONE,
-                 "%s: %d IRQ %d, status %x, control %x\n", __func__,
-                 irq, port->line, ssr_status, scr_status);
-
        return ret;
 }
 
index fad67d33b0bdddf5a04cfb103842c83ac0a72d35..f70c49f915fa11c7878747f58973bebc899f5542 100644 (file)
@@ -31,7 +31,9 @@
 # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
 #elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \
       defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-      defined(CONFIG_ARCH_SHMOBILE)
+      defined(CONFIG_ARCH_SH7367) || \
+      defined(CONFIG_ARCH_SH7377) || \
+      defined(CONFIG_ARCH_SH7372)
 # define SCSCR_INIT(port)  0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
 # define PORT_PTCR        0xA405011EUL
 # define PORT_PVCR        0xA4050122UL
@@ -94,7 +96,9 @@
 # define SCSCR_INIT(port)       0x0038  /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
 #elif defined(CONFIG_CPU_SUBTYPE_SH7724)
 # define SCIF_ORER              0x0001  /* overrun error bit */
-# define SCSCR_INIT(port)       0x0038  /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
+# define SCSCR_INIT(port) ((port)->type == PORT_SCIFA ? \
+       0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
+       0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
 #elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
 # define SCSPTR2 0xffe80020 /* 16 bit SCIF */
 # define SCIF_ORER 0x0001   /* overrun error bit */
     defined(CONFIG_CPU_SUBTYPE_SH7786)  || \
     defined(CONFIG_CPU_SUBTYPE_SHX3)
 #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
+#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
+#define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8)
 #else
 #define SCI_CTRL_FLAGS_REIE 0
 #endif
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
     defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-    defined(CONFIG_ARCH_SHMOBILE)
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 # define SCIF_ORER    0x0200
 # define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
 # define SCIF_RFDC_MASK 0x007f
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
     defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-    defined(CONFIG_ARCH_SHMOBILE)
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 # define SCxSR_RDxF_CLEAR(port)         (sci_in(port, SCxSR) & 0xfffc)
 # define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
 # define SCxSR_TDxE_CLEAR(port)         (sci_in(port, SCxSR) & 0xffdf)
     SCI_OUT(sci_size, sci_offset, value);                              \
   }
 
-#if defined(CONFIG_CPU_SH3) || defined(CONFIG_ARCH_SHMOBILE)
+#if defined(CONFIG_CPU_SH3) || \
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 #if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
 #define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
                                sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
 #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
       defined(CONFIG_CPU_SUBTYPE_SH7720) || \
       defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-      defined(CONFIG_ARCH_SHMOBILE)
+      defined(CONFIG_ARCH_SH7367) || \
+      defined(CONFIG_ARCH_SH7377) || \
+      defined(CONFIG_ARCH_SH7372)
 #define SCIF_FNS(name, scif_offset, scif_size) \
   CPU_SCIF_FNS(name, scif_offset, scif_size)
 #else
 #if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
     defined(CONFIG_CPU_SUBTYPE_SH7720) || \
     defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-    defined(CONFIG_ARCH_SHMOBILE)
+    defined(CONFIG_ARCH_SH7367) || \
+    defined(CONFIG_ARCH_SH7377) || \
+    defined(CONFIG_ARCH_SH7372)
 
 SCIF_FNS(SCSMR,  0x00, 16)
 SCIF_FNS(SCBRR,  0x04,  8)
@@ -589,7 +606,9 @@ static inline int sci_rxd_in(struct uart_port *port)
 #elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
       defined(CONFIG_CPU_SUBTYPE_SH7720) || \
       defined(CONFIG_CPU_SUBTYPE_SH7721) || \
-      defined(CONFIG_ARCH_SHMOBILE)
+      defined(CONFIG_ARCH_SH7367) || \
+      defined(CONFIG_ARCH_SH7377) || \
+      defined(CONFIG_ARCH_SH7372)
 #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
 #elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
       defined(CONFIG_CPU_SUBTYPE_SH7724)
index 170d3d68c8f04d38fb67f8d3b84c9c977f57f7a1..01f7731e59b89feed0745b89d5ab4282699b2164 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/serial.h>
 #include <linux/sysrq.h>
 #include <linux/console.h>
+#include <linux/slab.h>
 #ifdef CONFIG_SERIO
 #include <linux/serio.h>
 #endif
@@ -1453,8 +1454,10 @@ static int __devinit su_probe(struct of_device *op, const struct of_device_id *m
        if (up->su_type == SU_PORT_KBD || up->su_type == SU_PORT_MS) {
                err = sunsu_kbd_ms_init(up);
                if (err) {
+                       of_iounmap(&op->resource[0],
+                                  up->port.membase, up->reg_size);
                        kfree(up);
-                       goto out_unmap;
+                       return err;
                }
                dev_set_drvdata(&op->dev, up);
 
index 7bf10264a6ac7fd7310106440b6b7f1cd65a442d..786ba85c170ba622d638a010fc27b1c1213142a3 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 
 #include "timbuart.h"
 
index 465f2fae1025ebeef99a7c7a657a14de23858341..074904912f642caa23a89af5a8b7e838501e9fd5 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/module.h>
 #include <linux/serial.h>
+#include <linux/slab.h>
 #include <linux/serial_core.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
index c2750391fd34402efb405e24cd5b0e3d1b4a43c3..94ad6bd86a00c02754d6c3ac2666cc347a2816c7 100644 (file)
@@ -2,7 +2,7 @@
  * Shared interrupt handling code for IPR and INTC2 types of IRQs.
  *
  * Copyright (C) 2007, 2008 Magnus Damm
- * Copyright (C) 2009 Paul Mundt
+ * Copyright (C) 2009, 2010 Paul Mundt
  *
  * Based on intc2.c and ipr.c
  *
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/sh_intc.h>
 #include <linux/sysdev.h>
 #include <linux/list.h>
 #include <linux/topology.h>
 #include <linux/bitmap.h>
+#include <linux/cpumask.h>
 
 #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \
        ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \
@@ -234,6 +236,10 @@ static inline void _intc_enable(unsigned int irq, unsigned long handle)
        unsigned int cpu;
 
        for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_E(handle)); cpu++) {
+#ifdef CONFIG_SMP
+               if (!cpumask_test_cpu(cpu, irq_to_desc(irq)->affinity))
+                       continue;
+#endif
                addr = INTC_REG(d, _INTC_ADDR_E(handle), cpu);
                intc_enable_fns[_INTC_MODE(handle)](addr, handle, intc_reg_fns\
                                                    [_INTC_FN(handle)], irq);
@@ -253,6 +259,10 @@ static void intc_disable(unsigned int irq)
        unsigned int cpu;
 
        for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_D(handle)); cpu++) {
+#ifdef CONFIG_SMP
+               if (!cpumask_test_cpu(cpu, irq_to_desc(irq)->affinity))
+                       continue;
+#endif
                addr = INTC_REG(d, _INTC_ADDR_D(handle), cpu);
                intc_disable_fns[_INTC_MODE(handle)](addr, handle,intc_reg_fns\
                                                     [_INTC_FN(handle)], irq);
@@ -301,6 +311,23 @@ static int intc_set_wake(unsigned int irq, unsigned int on)
        return 0; /* allow wakeup, but setup hardware in intc_suspend() */
 }
 
+#ifdef CONFIG_SMP
+/*
+ * This is held with the irq desc lock held, so we don't require any
+ * additional locking here at the intc desc level. The affinity mask is
+ * later tested in the enable/disable paths.
+ */
+static int intc_set_affinity(unsigned int irq, const struct cpumask *cpumask)
+{
+       if (!cpumask_intersects(cpumask, cpu_online_mask))
+               return -1;
+
+       cpumask_copy(irq_to_desc(irq)->affinity, cpumask);
+
+       return 0;
+}
+#endif
+
 static void intc_mask_ack(unsigned int irq)
 {
        struct intc_desc_int *d = get_intc_desc(irq);
@@ -847,6 +874,9 @@ void __init register_intc_controller(struct intc_desc *desc)
        d->chip.shutdown = intc_disable;
        d->chip.set_type = intc_set_sense;
        d->chip.set_wake = intc_set_wake;
+#ifdef CONFIG_SMP
+       d->chip.set_affinity = intc_set_affinity;
+#endif
 
        if (hw->ack_regs) {
                for (i = 0; i < hw->nr_ack_regs; i++)
index 66802a4390ccff59bd51025dbb62800e6fd92336..b3b33fa26acda7bb99483341980f47bed9e6a213 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/ioc3.h>
 #include <linux/rwsem.h>
+#include <linux/slab.h>
 
 #define IOC3_PCI_SIZE 0x100000
 
index 9aeb6811310001619baa9ffffbc4d4de2274ffcc..e9aeee16d922aba598f731e3cbd61b48e6d5b63c 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/amba/bus.h>
 #include <linux/amba/pl022.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /*
  * This macro is used to define some register default values.
index d21c24eaf0a95537baae7f22e783bff8658aa816..c4e04428992de8302b3b3e2a512927bdb159643b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <mach/board.h>
index ba8ac4f599d3966179eb1ce3847dd5a268a96d2a..3c9ade69643f6526128114afbf892aae6958e28a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
index 225ab60b02c466e8f0b9802b4f8c9a263bf5207c..95afb6b77395f3c60b4c8a18bafe2b4146369229 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
+#include <linux/slab.h>
 
 #include <mach/spi.h>
 #include <mach/edma.h>
index 8ed38f1d6c18d36daab177affb9fb1e015cd2c07..d256cb00604c55db5cc2ce25233b8d8e189c69be 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/highmem.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <linux/spi/dw_spi.h>
 #include <linux/spi/spi.h>
index e35b45ac5174f54c44cd3fe02d09127b1db50a32..db35bd9c1b24bf89f15c308de5915ce7fd04d97e 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/clk.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/spi/dw_spi.h>
 #include <linux/spi/spi.h>
 
index 1f0735f9cc76ab0232aa282f19f071b89be827ce..1f52755dc87824e9764b354557c86dfd901dc4a3 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/spi/dw_spi.h>
 #include <linux/spi/spi.h>
 
index 04747868d6c4d4605ec679f21306b650b4475657..77d4cc88edea137251be529ded2a53dc11a8aa61 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
 #include <linux/fsl_devices.h>
+#include <linux/slab.h>
 
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
index 6eab46537a0ae3a6bb1d52d9a9662fc24c60da18..cd68f1ce5cc3ffa78dcd7d6ad49bc49396dee834 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/of_spi.h>
 #include <linux/io.h>
 #include <linux/of_gpio.h>
+#include <linux/slab.h>
 #include <asm/time.h>
 #include <asm/mpc52xx.h>
 
index 4dd786b99b8b683e2be39c51c92155a94b8ffe2d..d8356af118a8c3ba121dff0eddfd616d9da53192 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 
index 5355d90d1bee10fc08a2a3728d1836f6d1a82696..24668b30a52d4a88a6bec93499e82c35886f7f31 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 
index 6c3a8557db2761871764983cde3f9ac7fa3adceb..160d3266205f864f4e49cc951171c7329a373500 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/interrupt.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
index c2f707e5ce74accbc44a4c3766a25ea2fde93272..36828358a4d8602a1fdbbc56f5aeb588e3467d1a 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
index b76f2468a84a10d6afa8f6a583b1e9bb44c79bc3..9ffb0fdbd6fe6b7235ccb6c73963b4a75f219aee 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/cache.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
 
index 1d41058bbab2a4227dc663f388e3e026e1ce84b3..10a6dc3d37ac835568083698b1165ea027893739 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/irq.h>
index f1db395dd88981ca4bf7f2e8777c8e9f2c6cceee..5265330a528fb2a367f164465fefb0b496e25c31 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
index 0ddbbe45e83442f77f2334e7e84a87d5d77ac810..7972e90774738d87d75b835be0a8555d63b78c58 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/types.h>
index 4f0cc9d457e04b6c115d08a72014e83ff4e5bd58..14d052316502cfcf7334cbb57cf5181e02c2c3be 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
 #include <linux/of_spi.h>
+#include <linux/slab.h>
 
 #include <sysdev/fsl_soc.h>
 #include <asm/cpm.h>
index b319f9bf9b9b902012ef33998d6e14f95d196ec7..dff63be0d0a8c7b23205d9374c209e3914805bfb 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
index 6d8d4026a07a6569e0ba2812a0ce705dc94c5b67..7cb5ff37f6e2662254eb66a321b1be2acb2c604b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/wait.h>
 #include <linux/of_platform.h>
index 1fabede9e06184e49564456f74587c7c648fbdc6..151a95e40653e8908e362968212abd182aeaa5ae 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
index bf9540f5fb98de7ad1f7c523a96548382984848d..a3938958147c887ecbf803c6c806d668735b62de 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/tle62x0.h>
index ed34a8d419c7545b1a3912d9737e48c100852fb2..748d33a76d290286c6435ff3d11965c2e023525d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/of_platform.h>
 #include <linux/of_device.h>
index 172f90407b93aa1159fc2618e90e16ea1beb70fb..5ba92a2719a46e28453fbc913ba460080bb02b7c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/ssb/ssb_driver_gige.h>
 #include <linux/pci.h>
 #include <linux/pci_regs.h>
+#include <linux/slab.h>
 
 
 /*
index 03dfd27c4bfba8cb78df400a12589be531879f6b..80ff7d9e60ded74e35c78dc1064cfd950af1eea3 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/pci.h>
 #include <linux/mmc/sdio_func.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
index 9e50896233aa969e5fa145bcf630dd0ba9055363..a8dbb06623c96f17e61ad996df9647ab699a6740 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/ssb/ssb.h>
 #include <linux/ssb/ssb_regs.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 
index 26737a010c6d03080f345955ecfa97c30cc8fa27..6536a041d90dd671966bf478a474aefe2ec926ef 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/ssb/ssb.h>
 
 
index d0e6762fec50c6316193eae92a1b787320cbb276..f2f920fef10df9f2d0f5845fcf7ff70875c12350 100644 (file)
@@ -14,6 +14,7 @@
 #include "ssb_private.h"
 
 #include <linux/ctype.h>
+#include <linux/slab.h>
 
 
 static const struct ssb_sprom *fallback_sprom;
index e7f44215b5f383834b865b0791737f55e5838991..2f61500186f275b034e99e4e84edb31e75e4455f 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/slab.h>
 #include "main.h"
 #include "device.h"
 #include "send.h"
index deb41f5beda6d9c08abb45a5641df4dfbbe93bc8..2e9bb891a5dece8f93eb88c1e03a8416b0ad01ef 100644 (file)
@@ -109,6 +109,7 @@ extern int bat_debug_type(int type);
 #include <linux/kthread.h>     /* kernel threads */
 #include <linux/pkt_sched.h>   /* schedule types */
 #include <linux/workqueue.h>   /* workqueue */
+#include <linux/slab.h>
 #include <net/sock.h>          /* struct sock */
 #include <linux/jiffies.h>
 #include "types.h"
index c9b35d9f799121774e3abe64a6c6789c60d0d39c..0e2307f3cb96f6892f18d6df6df7d817acc73041 100644 (file)
@@ -26,6 +26,7 @@
 #include "translation-table.h"
 #include "types.h"
 #include "hash.h"
+#include <linux/slab.h>
 #include <linux/ethtool.h>
 #include <linux/etherdevice.h>
 
index 10f488f0e5ee732f49f6ad319ad046aa5e637a4a..2d54993ffb12c414eb8bca65ac8fec43f2fb5ddb 100644 (file)
@@ -81,6 +81,7 @@ I/O port base address can be found in the output of 'lspci -v'.
 #include "../comedidev.h"
 
 #include <linux/ioport.h>
+#include <linux/slab.h>
 
 #define _8255_SIZE 4
 
index 8db5ab63e36313714d1bb62676c7ab7a431283be..6625fdc8e9036348c84659dc7803dd1fdf52967b 100644 (file)
@@ -50,7 +50,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
@@ -58,6 +57,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 #include <linux/timex.h>
 #include <linux/timer.h>
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include "../../comedidev.h"
 #include <asm/io.h>
 #if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
index 9934a3cf25489cdf27330ab8c5e513da0b5bcabd..944f20ae5a6a311edc62bfc5f3e1b8ca0896cff6 100644 (file)
@@ -66,6 +66,7 @@ Configuration options:
 #include "../pci_ids.h"
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/interrupt.h>
 
 #include "amcc_s5933.h"
index 204f30ef6e9602b8d2b27cac5729bd74f1bfb007..92bcc205dd4bc84a200709ddd95b04f1e30efdae 100644 (file)
@@ -206,6 +206,7 @@ order they appear in the channel list.
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include "../comedidev.h"
 
index b41e5e5963aa5f3caeeecfb8be0981e40d28060d..c54cca8b2565b05069f70a05d3796132c5a42bb3 100644 (file)
@@ -104,6 +104,7 @@ Caveats:
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include "../comedidev.h"
 
index bc375e73abc105cdc6a3523d2c7e1c7583f13046..5632991760af52f61c6e6e61ecba5e76d2d2ffda 100644 (file)
@@ -32,6 +32,7 @@ Status: experimental
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 #include <linux/delay.h>
 #include <linux/pci.h>
index d7260cc86985665d5c41fcb92c70db15c229777b..41311d99473b89937a2c4964fb009e58114502cb 100644 (file)
@@ -90,6 +90,7 @@ Configuration Options:
 #include "../comedilib.h"
 #include "../comedidev.h"
 #include <linux/string.h>
+#include <linux/slab.h>
 
 /* The maxiumum number of channels per subdevice. */
 #define MAX_CHANS 256
index f12ef1cd6f53b3c8eb3447901b36b687ec2436da..9164ce158dcde3bf1477512ae73f42fab32aba1e 100644 (file)
@@ -43,6 +43,7 @@ Command support does not exist, but could be added for this board.
 
 #include <linux/delay.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "das08.h"
 
index 10a87e6a809516ce80a9f0afd7d800b648bd390e..f2aadda9b2414dbe34c622f2f9b5448618273c32 100644 (file)
@@ -79,6 +79,7 @@ Computer boards manuals also available from their website www.measurementcomputi
 */
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <asm/dma.h>
 #include "../comedidev.h"
index 6ea59cc6b2bb5554fe08523e4ea266de9dadbed0..3c3e0455c7c412077f2066b71881edada32fd5f0 100644 (file)
@@ -101,6 +101,7 @@ TODO:
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include <linux/ioport.h>
index 99ca294b1ec560539961eae28d759d4ccab7f60a..e548763cf2f3ca1fcdab7bdf5f8199d2b683487a 100644 (file)
@@ -58,6 +58,7 @@ Notes:
 
 #include "../comedidev.h"
 
+#include <linux/gfp.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <asm/dma.h>
index fe5b4953f7ec617af8805df12b6fda0327759716..d330b1886846f866103ba746d2fb93653619258b 100644 (file)
@@ -46,6 +46,7 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
 #include <linux/ctype.h>
 #include <linux/firmware.h>
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include "comedi_pci.h"
 #include "jr3_pci.h"
index c223f76031f6aa6eed91e04adec2a1af7cc0ff4d..9a4fffe5655ffb19fcb901a3e44607a13997d3b6 100644 (file)
@@ -52,6 +52,7 @@ except maybe the 6514.
 #define DEBUG 1
 #define DEBUG_FLAGS
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include "mite.h"
index 1e792d592f7343056af1637283442b740cf6daa3..68221bfba5dd64bf37051e1f142d67b5aefff304 100644 (file)
@@ -42,6 +42,7 @@ Commands are not supported.
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include "mite.h"
index dd75dfb34309f793e52a6f0528a8180417c4892b..9bff34cf06d1a709199c5e41cecf05710a4f6ea5 100644 (file)
@@ -65,6 +65,7 @@ TRIG_WAKE_EOS
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include <linux/ioport.h>
index c9b0395a61037c37e7c7c4fe79f3c54fee02c237..7ea64538e0556482f187f8b19b07bdd9ced246f8 100644 (file)
@@ -42,6 +42,7 @@ IRQ is assigned but not used.
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include <linux/ioport.h>
index 9017be3a92f15939e3fcd2c9123dbe2171101496..ddc312b5d20da3eef4519556071370c5de092cfb 100644 (file)
@@ -41,6 +41,7 @@ the PCMCIA interface.
 #undef LABPC_DEBUG
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include <linux/ioport.h>
index 3c88caaa9dabc2d72dcaf879be5d05bb3fb86cae..558e525fed37db604286071dd6cbf546ffe32c09 100644 (file)
@@ -77,6 +77,7 @@ NI manuals:
 /* #define LABPC_DEBUG    enable debugging messages */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 
 #include <linux/delay.h>
index 0b963bb3328bdcaff6efdbc3fae2baf6ea15876d..8ad1055a5cc1a66192c1405a3f70e9d8224baa10 100644 (file)
@@ -64,6 +64,7 @@ NI manuals:
 #include "../comedidev.h"
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "8253.h"
 #include "8255.h"
index d4634c4f02dc2ec7cd14e86c2a3de9056d3859a3..1ddc19c705a6b186f9aab5fb59f8be06bdee1a8a 100644 (file)
@@ -108,6 +108,7 @@ Options for ACL-8113, ISO-813:
 */
 
 #include <linux/interrupt.h>
+#include <linux/gfp.h>
 #include "../comedidev.h"
 
 #include <linux/delay.h>
index 9820759ec54f9da66f6c0ecb9d3cf5d0dfc32766..71c2a3aa379e419e477b3973e90db17b95b8f501 100644 (file)
@@ -36,6 +36,7 @@ Configuration Options:
 
 #include <linux/ioport.h>
 #include <linux/mc146818rtc.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <asm/dma.h>
 
index c9d75385755d471f703a6677e3f7ea6e8ebcdf00..9d6aa393ef13b83785efff2bee825662714c64fd 100644 (file)
@@ -102,6 +102,7 @@ A word or two about DMA. Driver support DMA operations at two ways:
 
 #include <linux/ioport.h>
 #include <linux/mc146818rtc.h>
+#include <linux/gfp.h>
 #include <linux/delay.h>
 #include <asm/dma.h>
 
index 6ca4105610c182b4e159aaf3d66a012f15ce1c7b..025a52e8981d1868d68497359b4a165d96bfc24a 100644 (file)
@@ -77,6 +77,7 @@ Configuration Options:
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 #include "pcm_common.h"
 #include <linux/pci.h>         /* for PCI devices */
index c1ae20ffb37957f77048bd021a944c5f17255f6c..5af4c8448a3a6ab1a670c2a72ce350bbd0dfac51 100644 (file)
@@ -76,6 +76,7 @@ Configuration Options:
 */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "../comedidev.h"
 #include "pcm_common.h"
 
index dd2b903727942ddd0dbd122b7b038dba4491f5ba..0792617ebc3557c327d5c05f36389c6af1d1ae7d 100644 (file)
@@ -36,6 +36,7 @@ Status: in development
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/termios.h>
 #include <asm/ioctls.h>
index 75a9a62e1a7040f8d07afb570b547ee841401434..be1d83df0de51bd9448ed18de1daca41c6cc2e54 100644 (file)
@@ -44,6 +44,7 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5),
 
 #include "../comedidev.h"
 #include <linux/ioport.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "unioxx5"
 #define UNIOXX5_SIZE 0x10
index 6552ef6d82978f11b99e89a8028c7b5d6557399e..288fef4fcbcc345788cc46e87c5cdd1de00b66cb 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <asm/io.h>
 
 #include "../comedi.h"
index 19293d1f998da37ffd8ca42a65004d824ec86db3..8bf4471ce6c14c01912a4089b5857625b486b6fc 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 
 /* functions specific to kcomedilib */
 
index 01819d34201aec7b66cca833af6f1dc975e4f899..c438c489aa92fc9344e8a9defd9c633f1bda6b54 100644 (file)
@@ -23,6 +23,7 @@
  **********************************************************************/
 
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "crystalhd_hw.h"
 
index 3eac70aa213c85231db2e0418fdfe40161228ece..54bad652c0c5022c195c6ca22c9881d8a778cc10 100644 (file)
@@ -16,6 +16,7 @@
 ***************************************************************************/
 
 #include <linux/version.h>
+#include <linux/slab.h>
 
 #include "crystalhd_lnx.h"
 
index 587dcc47786517bb77da2754121eb3f772f314be..73593b078b339fb3cf276941ee2fd3c870da8521 100644 (file)
@@ -24,6 +24,8 @@
  * along with this driver.  If not, see <http://www.gnu.org/licenses/>.
  **********************************************************************/
 
+#include <linux/slab.h>
+
 #include "crystalhd_misc.h"
 #include "crystalhd_lnx.h"
 
index e0eef12759e46eb9fc93c725957bd22ef7770be5..061add30ba8aa3c79569cb3b857fb257b3b9ef36 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/vmalloc.h>
 #include <linux/dma-mapping.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include <asm/delay.h>
 #include <sound/core.h>
index ddddf651266baa461915fb6c02b023b6dff57a7e..11c56bdb0ceb0ba6be38d48b130116c1d1c7b4c2 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/file.h>
 #include <linux/fcntl.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
index 46c7f78bb972ed2f4785a102d3402b8944565fcf..e76451c309f1f1b37eadb9a263b921c302e3a688 100644 (file)
@@ -21,6 +21,8 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
+
 #include "cx25821-video.h"
 
 static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
index 67f689de4daada8a8d110c9377ce65e62f6efc60..9e9b8c3c931157f2d78039a429bfe39f1c79653e 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include "cx25821.h"
 #include "cx25821-sram.h"
 #include "cx25821-video.h"
index c8905e0ac509563abfdfb851981e9632ec399db9..cc51618cffa9b419c0deb46631f8293e97df285b 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/syscalls.h>
 #include <linux/file.h>
 #include <linux/fcntl.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
index 3d7dd3f66541d9d3d91a050cdd5a3892d4eeaafa..6d48a1e26d1bf872668245f2919d731139598795 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/syscalls.h>
 #include <linux/file.h>
 #include <linux/fcntl.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
index dc7c603625c7ea28055c4149452b8f74f4d7bec8..81bd71fd816ee69a56d928b9122dc50fa34fa129 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <mach/board.h>
index 6a7d46cf11eb18e6cd856ee16f9b53f1f339ad48..c276f2f7583ac239c028ddf62918a760e784f0b7 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/spinlock.h>
 #include <linux/videodev2.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <media/v4l2-dev.h>
 #include <media/msm_camera.h>
 #include <mach/camera.h>
index 62fd24d632d5cef6ef36d5ddc757862bf7be07aa..198656ac3de530ba68f39afd08b9bfa3be2fb22f 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/android_pmem.h>
+#include <linux/slab.h>
 #include <mach/msm_adsp.h>
 #include <linux/delay.h>
 #include <linux/wait.h>
index 03de6ec2eb44178d985f4c918f0acaae882f59fc..e61fdba6283867ac56cda2a2c21c557418378936 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2008-2009 QUALCOMM Incorporated.
  */
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/interrupt.h>
 #include <mach/irqs.h>
index 4f938f9dfc4709bc9960ac084de65703a5e4b084..e6f2d5124611d2202c608ed8b160d76274711cf6 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/i2c.h>
 #include <linux/uaccess.h>
index 70119d5e0ab3230a8e11eb4cc9d129133fa31f3c..791bd6c406154e5d82c1e9cc914b90938099d204 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/delay.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/uaccess.h>
 #include <linux/miscdevice.h>
index 88229f2663b56409007a5586dd85042b990dc70c..8fd7727ba234ee6636205f08e02a4a7f3080d051 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/delay.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/uaccess.h>
 #include <linux/miscdevice.h>
index 841792e2624b23bda21cb28fc21bd5843d752cf2..1459903a339d40d9fbb1d8b1d6669811da08b38b 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/i2c.h>
 #include <linux/uaccess.h>
index c801172aa9eecf024f9d38fe08f0f2037b7042c3..eb54724b1d3a59bb465291efc58174feec919f57 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/gpio_event.h>
 #include <linux/interrupt.h>
index e60e2c0db9c04d349411376e074a0e3c29fb58e8..97a511d11f49f168f2c973f68ef604b00e620f3d 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/input.h>
 #include <linux/gpio_event.h>
index 0638ec43601a9058b05ae7eb7b2f5de7fd7a261e..ca29e5eb070a37e79765d33dd7334b73c0ec76cf 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/hrtimer.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 enum {
        DEBOUNCE_UNSTABLE     = BIT(0), /* Got irq, while debouncing */
index 796de4faf85929d2dcd43cc7b718463ee53c7a78..b377ee1f5a5f7e1537154478127623bd1eaec10b 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/gpio_event.h>
 #include <linux/hrtimer.h>
index 503ba212dc9647bfa86bd8ae0a44b3a6b8c50938..6edfdd4ef80419e3fb8ff2e5805f8020876111d8 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/android_pmem.h>
 #include <linux/mempolicy.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
index 9069535fcaf18ba213086066dddf7dde9a46b764..f1e9d81674e85be3ef31118f1dddc73ebfe8be49 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/wait.h>
 
index e55a0db53a93f39bb8b1e20d280da85e8766e11e..8197765aae1e8d8b173ff120473e3f9eda421385 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/list.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #include "adsp.h"
index ad2390f32a4f59bf903abac35d385886e3313844..a373f3522384aba567ba33213aad568ee55d8a5a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kthread.h>
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <linux/delay.h>
 
index cd818a526f836b122287e3faf4da5a9ec583f216..07b79d5836e5e984ac834f77695b7ee7596c80ce 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kthread.h>
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <linux/delay.h>
 
index 4b43e183f9e863568bf9b17696417033f4c49946..ad989ee87690a13dd53ed8f05f2c65c6bd868d2d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include <asm/atomic.h>
 #include <asm/ioctls.h>
index 3d950a245895f92a24964db9ae8aa6b2211e29d9..6ae48e72d1459cdb938a062bed40a9ed5b05c6a3 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kthread.h>
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <linux/delay.h>
 
index 7ed6e261d6c97ab0cb13e4c05961b04a75f840d9..530e1f35eed35946a799800ec28386a691b0ef4a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kthread.h>
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <linux/delay.h>
 
index df87ca337b9476e313bdaf358dad5c432983d615..fe7809dd440100901f81b3d3077364303e9b3636 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/wakelock.h>
+#include <linux/gfp.h>
 
 #include <linux/msm_audio.h>
 
index f0f50e36805a3b38ec4f2ec0b5278ee1ae2ab4c4..effa96f34fdceddfe020fce8b656b4e4faa6d23e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <asm/ioctls.h>
 #include <mach/msm_adsp.h>
index 1ad8b82c257019ab7836a9f0aadd0b3d9604ec3f..427ae6c0bea8730dd53c97fc80ea2321f2bf63bb 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/wait.h>
 
index 69911a7bc87ac74fa122320ccb502c43a5c2350b..8744a6e499cbf530ec4e9f0e859db0c39a6ba1e8 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/err.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <linux/platform_device.h>
index cd3910bcc4ed7491375e161b664f390e9df5f2a0..e9c28eddce3128117300a4fbf8c1fda54ffad57c 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/poll.h>
 #include <linux/platform_device.h>
 #include <linux/msm_rpcrouter.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
index 2597bbbc6f5e9da65fd14fa579320cc94b6a8566..1b152abb27830daecd2a3a2bc1ac63809a1e10b2 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/wakelock.h>
+#include <linux/slab.h>
 
 #include <linux/msm_rpcrouter.h>
 #include <linux/uaccess.h>
index 4de6bc9175954899b314c2ec14fa4bed8805c257..d2ca116a1c256beafc955db859175d984f62a740 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #ifdef CONFIG_HAS_EARLYSUSPEND
 #include <linux/earlysuspend.h>
 #endif
index c74234c66895eeaadfda57fe3267ecc2aac29631..db382ef90217727f9c0012528a7c223f8c5c83d4 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/types.h>
 #include <linux/mm.h>  /* PAGE_ALIGN() */
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 
index fd7f93d6c33df19b7ff9fa0cb7c772e74df73ddb..09d7d9b8272dce495075598658e125ab84d14601 100644 (file)
@@ -45,7 +45,7 @@ Purpose: Buffer management routines, and other routines for the ISR
 */
 
 #include <asm/system.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 
index 3ca253672ba1f5bd7bcbb3fb5aa319b18690caf4..e4d095b0b52a7a2fa3031a2a063ee3ddad67515d 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index a292b1edc41435886ceecc013db7754d67fe6f01..16fa13d4821f56694ef861c4e47e07e0ba71f978 100644 (file)
@@ -65,7 +65,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
@@ -226,7 +225,7 @@ void ConfigMACRegs2(struct et131x_adapter *etdev)
        }
 
        /* Enable TXMAC */
-       ctl |= 0x05;    /* TX mac enable, FC disable */
+       ctl |= 0x09;    /* TX mac enable, FC disable */
        writel(ctl, &etdev->regs->txmac.ctl);
 
        /* Ready to start the RXDMA/TXDMA engine */
index 4a55fbfbd59dbd73ba08c1a19a102c857bfae27a..34cd5d1b586ac854fdcda316e5f5bbcf40d1c953 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index 41019e390af5cd2c426a00f20160d3a5e03157f7..c64bb2c6d0d69d6c9f6ed605d6e80b9aa0518a61 100644 (file)
@@ -65,7 +65,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index 5ad7e5a6f6313041c9955b929503b37e38c2608f..1dd5fa5b888b231461fb1b44b8efb3a1f734a457 100644 (file)
@@ -68,7 +68,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index 8b6e0b7ec5688a9e4a2527e49c965962d50c358d..cb7f6775ce0a72c23f1fd319f2eaacf2f0917255 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index 40f8954dde478b526039b3729ad9267b9d16ce6f..ab047f2ff72cd10e1a3a17e34803f4e8f04b1893 100644 (file)
@@ -65,7 +65,6 @@
 
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index d42ba1696999af76b9e677dd6b93f73239d4f7fb..372a7c6791ca29a0af3e496d1a6312199e49db4e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/firmware.h>
 #include <linux/mutex.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <linux/videodev2.h>
 #include <media/tuner.h>
index a8bb264e0074edca23e0e8f77940c0524344cb6f..ee622ff1707e063482ee1611b16b6b2605988415 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/device.h>
 #include <linux/i2c.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include "go7007-priv.h"
index 3af79242313e5cdfb6281b46d08e0a0ef9a3a346..723c1a64d87f3007f5f7da252e160d7cd0453f66 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/unistd.h>
 #include <linux/time.h>
index dc89502ea1b7ddce759040df0dc9d7a9b77658bb..93f26048e3b4570ba1b1a5c467740bc82883be7d 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/usb.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-i2c-drv.h>
index 1de2dfb16d3f7c1b30c0633b9cd403d282b0cdd0..7547a8f77345a00fc3c261ed0624eb3a31b95306 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/usb.h>
 #include <dvb-usb.h>
index 03c4dfc138a1e08fe5faa31603bc929d84a983fc..deac938d850535b367cf35d0f5a3c195b5faa96c 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/i2c.h>
 #include <linux/mutex.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
index d196e16fe72b679023b04efd615b5e233ed53818..5c12b4d384595013bbd7667c7d5f0b70a035f837 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 
 #include "wis-i2c.h"
 
index 0f2b4a0ceccfd566610ba940843e4bfde3203956..73f2283a88034f0b285d3499b05e22b2c57188e5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 
 #include "wis-i2c.h"
 
index c723e4aa7147bfa338dce705ba18a3516e5fde0b..b1013291190f162f6668af96c8593c81b57cb7e9 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
+#include <linux/slab.h>
 #include <media/tuner.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
index 1983839f554d0aa2c7e450f79b1d83bcc36fbd27..315268d130dd61311873a36bd3ae373ed75f3539 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 
 #include "wis-i2c.h"
 
index f97e2be3c0b51d49f2b262980d7942d5204f0f00..3ac6f785c4ad6c4796de320952980e2606a4c0dd 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 
 #include "wis-i2c.h"
 
index d46eb145484f1f24a5d70322baa1732fd5c01022..e69e9ee704ace1017e5c9648e466149a3211f619 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include "osd.h"
 #include "logging.h"
 #include "VmbusPrivate.h"
index ef38467ed4e20d51ce71033265717d1ebc3023dd..5f92c2102ab4ca854e73a9c3e0a61eb0fbf5948c 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include "osd.h"
 #include "logging.h"
index 43c2e685501554ae6d12664ea03cf12fbba3de09..e0ea9cf90f0312044a91474110b5d5571bd0e5f5 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include "osd.h"
 #include "logging.h"
index 51149e69f3e84032b05fd76dbd11aed89f2922d8..5d53889fb4a42196d88bfc590eaadd2339a21f63 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include "osd.h"
 #include "logging.h"
index 1c717f9a554ef36cc1dd43725f54989b99db5b9f..e4bf8229750469d4e20ca92a90767a6743cfb002 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include "osd.h"
 #include "logging.h"
 #include "NetVsc.h"
index 1ab7fa97d3735bb608f395f02a5734c522c85c69..cd2930de217690371a8e9767bdca61c60731d1fa 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include "osd.h"
 #include "logging.h"
index 38ea1407f222d8308ad42f5098f1f9a4ce9711eb..e426a23ca537e12d60b4c913612b92dedc258bd0 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include "osd.h"
index 3d0a240ed664c30590bcfaf5c4a237485e7dd532..2f84bf7c0a9f8d59bf6edc127d806d69e4615d84 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include "osd.h"
 #include "logging.h"
 #include "VersionInfo.h"
index abeac12c093d4900a06bf75162808a7cd58c603f..8f1fda3256ad2492119808b5a5f2bd87916a76fc 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/major.h>
 #include <linux/delay.h>
 #include <linux/hdreg.h>
+#include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_eh.h>
index 1af3dcbafd6554507c7da8f01618cf6ead2271f8..2ccb6b93fe473928dbfaa1caf8e06d09ffea8068 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/route.h>
 #include <net/sock.h>
index 3a4793a0fd050996d83c2de8e07d5e1183dfd4c4..9aea31067295b29b62aa9243c94c560d4de0fb35 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/time.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include "osd.h"
 
 struct osd_callback_struct {
index 3988f4bec1cef29b830e3d9b43dbc2992aee0415..8a58272b8039af95322c341dede29465d4b649e1 100644 (file)
@@ -19,6 +19,7 @@
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/blkdev.h>
index 2c906195b9c8b5a65d825386c0017c856e0a4700..3397ef08e0aaa87c25152b48c840a4b2d015949b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/sysctl.h>
 #include <linux/pci.h>
 #include <linux/dmi.h>
+#include <linux/slab.h>
 #include "VersionInfo.h"
 #include "osd.h"
 #include "logging.h"
index 33d16b6f7b50089eca6c915d0caa3f6d8deae37a..db2dd537ffb0dcb57ce478c69efcf7e444515e3f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/sysfs.h>
 #include <linux/rtc.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
index f008837e5a147f44d3508bc738e07f8c5af5bba5..ea76902797bb93ac6a9531f426e90b72ef3bdb4a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 
 #include <linux/sysfs.h>
 #include <linux/list.h>
index a6b7c72a86f48c8925cc7e4642e74c2b027ca124..93712430e579192f4a9b6528d24aedc360f3ade1 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
index cedcaa2b3d1f2d5d81d4bac4a59878aeb8be4662..1c229869a22defb8a4ba582ad9182f70cece1115 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/gpio.h>
 #include <linux/fs.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
index d5ea237793a6b88c917ba297a97a83b81ffec18a..40cbab2a659223e4ea0ba50b7b01950e055e93e4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/gpio.h>
 #include <linux/fs.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
index 9703881cb3f8b0e0116bcb2ad6cd94c00c2e72c7..790d1cc9cdc3298527d00afca9b2a20f1707d615 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/i2c.h>
 #include <linux/rtc.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
index a953eac6fd62e8b7e32a620f9233b5823a7e5ab7..f94fe2d38a977e712daad3c2477e6156846a44a2 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/gpio.h>
 #include <linux/workqueue.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
index b456dfc8fe27b008387bce803db0df9cd9aaa0c6..37f58f66e49127dfebd5e10d1c81dbd60349d37e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/cdev.h>
+#include <linux/slab.h>
 #include "iio.h"
 #include "trigger_consumer.h"
 
index ebe5cccb4034ce5711f6b0a765f4986abefb05bf..e53e214bfeb0eb59ee4663b57f3b9cb97522fdf9 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/cdev.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 
 #include "iio.h"
 #include "ring_generic.h"
index 693ebc48597cf1d7b4495c837a98e20de620109b..35ec80ba444fc09c266c6e1a93b2ecce34e84a50 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include "iio.h"
 #include "trigger.h"
index 78b9432c81057bcf8b019bf9835c32d2e5d875b2..1ba4aa392f6e75955415c7bd2f8e1bc16a9e74e2 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/pm.h>
 #include <linux/hwmon.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include "../iio.h"
 #include "tsl2563.h"
index 6f7f4d5a93f3ef83aea226fa2ca6bb51d2383ead..b104c3d9c35ef44b79e1a08bbed3eb30a2b71d12 100644 (file)
@@ -7,6 +7,7 @@
  * the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/device.h>
index 539e4169a02e8bc32b21c56c2f47b8fb5735e7cf..0c3bad3187f50648046072617876e4648bb8dd7b 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include "../iio.h"
 #include "../trigger.h"
index e310dc0098559c424d5100d03401109d2976d21c..4295bbc7b50d0f55646eea055974aa555c79c150 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/rtc.h>
 #include "../iio.h"
 #include "../trigger.h"
index fd4890de8dbcd3cf6837099d29d5fa608ec5d40c..ca092247f363602bdbf62c227223f42928ac27ee 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "driver.h"
 
+#include <linux/slab.h>
+
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 0392a4bc8cc8cf96ce253d61c7072fcbe8ee8496..258555417bc7aeaa02a53f80222721d77a870e2d 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "audio.h"
index decbaa971b68f7ebbefe47520632e5451b1e29e4..bb8c9da5803ff24de76f610256238d037a3ae958 100644 (file)
@@ -10,6 +10,9 @@
  */
 
 #include "driver.h"
+
+#include <linux/slab.h>
+
 #include "dumprequest.h"
 
 
index 6ef4455d87d8754b1ae6d1f3f7046316f80517a9..32b6ca75cadbcf89f3c02527c7b6f2c823846faa 100644 (file)
@@ -12,6 +12,7 @@
 #include "driver.h"
 
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/rawmidi.h>
index dd98121eb80bb582bf515b8e4a9b740bd6f5a545..fbe4b083eac5bdb9ddd19f9c8a9eca48a6748193 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "driver.h"
 
+#include <linux/slab.h>
+
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/pcm.h>
index 3431f5cd28525d527157f50ab2516a3fd7e277e1..fbcd6e150aaff741a2868be754d6c584a36bacb8 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "driver.h"
 
+#include <linux/slab.h>
+
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 685c529950eb56541683a2439b9dfd1a71702354..4983f2b51cf2df1e7cb5f9df5b539de4eecb7158 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "driver.h"
 
+#include <linux/slab.h>
+
 #include "audio.h"
 #include "capture.h"
 #include "control.h"
index 58fef82c247d991a30db7c6b653bc6b107db9efe..28eb89983f36be2ab088ccdf17fa2345a000a080 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "driver.h"
 
+#include <linux/slab.h>
+
 #include "audio.h"
 #include "control.h"
 #include "variax.h"
index e936717d1f4bb2aefbaeb36c4edde83bbee4ff03..3875a722d12b76629bea142dd3c80ea58eb7b922 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
 #include <linux/in.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/errno.h>
index 00cc91df6b46a2448d2da9040fa3ba196644b2a2..635bb86cdcff38297e7d9a2201f3b35544977c20 100644 (file)
@@ -26,6 +26,7 @@
 **********************************************************************/
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include <asm/octeon/octeon.h>
 
index 4a2161f70c7f734646f131013f5d8914296970a9..e50a17d807072c150f082daf655b3a459fb9b1cf 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/phy.h>
+#include <linux/slab.h>
 
 #include <net/dst.h>
 
index 8c47b1a686271f041fc4701ba83ced08ba7098e6..84be4b2cd692f77976bb33eeb66dedca717d49ec 100644 (file)
@@ -23,6 +23,7 @@
 /*     Platform dependent.                                              */
 /*                                                                      */
 /************************************************************************/
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/if_arp.h>
 #include <linux/uaccess.h>
index 5e6a12037b12e10af4e285b93fc86b26ff532310..0ce65b5b9456dad4e795e134358b3dfc128eb4ba 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "linux/netlink.h"
 #include "linux/rtnetlink.h"
+#include "linux/slab.h"
 
 #include <net/iw_handler.h>
 
index 330d1b95cb889435670aa31d361a5204dbb242be..7e66c2d72a6913c6dbac5fe23d98d0458a479188 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/uaccess.h>
 #include <linux/wireless.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 
 #include "zdcompat.h"
index 47cbce1346a9384ea820ccf58d53dac061cbf342..b0037568e870127bb4d556887a65840ed47431f9 100644 (file)
@@ -27,6 +27,7 @@
 #include "usbdrv.h"
 
 #include <linux/netlink.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 
 /* Memory management */
index a2f5cb1f529884dc1d995bfddbeb458af8d39f7a..5ecf38e355a8e02c77da3ea851336b1e3be382c0 100644 (file)
@@ -28,6 +28,7 @@
 #include "usbdrv.h"
 
 #include <linux/netlink.h>
+#include <linux/gfp.h>
 #include <net/iw_handler.h>
 
 
index 6b336ede8867eaf989986eb869cb5b83de8ed19b..93459cadc472f75dee6c3ff52f4409ba992e6d8e 100644 (file)
@@ -28,6 +28,7 @@
 #include "usbdrv.h"
 
 #include <linux/netlink.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 
 extern void zfLnxInitUsbTxQ(zdev_t *dev);
index 53d2a45d55f9672deddb79aa25dc61cda1eef57d..a74f7eea56e466e159f29700c716cede9a00e471 100644 (file)
@@ -26,6 +26,7 @@
 #include "usbdrv.h"
 
 #include <linux/netlink.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 
 extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
index 4cd9b7f5a8871fcba539183869cf8e47120c5652..bb89d85a4c7ce3e20fbeecdad6c5ffe3f0156b3f 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "usbdrv.h"
index 9095158fb1b3a1a908c55a1bc5b7f3ff0773681a..f940a34c1a0c3d712ba0808bd1d139a0e2869cab 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/ioctl.h>
 #include <linux/io.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "poch.h"
 
index 5d04bf5b021a8c24b9534339ec194bc3f5659e05..eed0e5545a557d1904fecaaf0e66ed5a7c39713e 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 
 #include "netfs.h"
 
index aacd25bfb0cb8e00fc554f30316890cc7ada47e0..79819f07bfb93c5bb4f053692555c7b8545bea74 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fs.h>
 #include <linux/jhash.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 
 #include "netfs.h"
index 22fef18cae90565ee9b4e7659905260586b865f8..6710114cd425962f8caa7cae425bc050aec2c909 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/backing-dev.h>
 #include <linux/fs.h>
 #include <linux/fsnotify.h>
-#include <linux/slab.h>
 #include <linux/mempool.h>
 
 #include "netfs.h"
index af7f262e68c2040e86440d845055a08c6d2f8b46..4a86f0b1ea888fcadbfebaa5ac5fe303b5bc6322 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/kthread.h>
 #include <linux/pagemap.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/syscalls.h>
 #include <linux/vmalloc.h>
index 3bad888ced13bb669e122e26daa7f71030c75f29..cdc4dd50d638a51abc240c780989b4433856b27c 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/ktime.h>
 #include <linux/fs_struct.h>
index 5e422e254ee8931e561cce301bfc2654ce958bba..ee5eb12b9285a8579bfdbef821cf80548a4e5ad7 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/device.h>
 #include <linux/genhd.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <linux/lzo.h>
 #include <linux/string.h>
 #include <linux/swap.h>
index 6af430419070046c8277f75ae3c8b24ef1ff9acc..e665d862281ccd25997fff341903ce063dbe5324 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "rt_config.h"
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 /* Following information will be show when you run 'modinfo' */
 /* *** If you have a solution for the bug in current version of driver, please mail to me. */
index b5c78aecf5e3a18d20b3cdc750158fbdf327c3e8..fd9a2072139b668670f3a69fa4d323c0a2d3e18a 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/firmware.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "rt_config.h"
 
 unsigned long RTDebugLevel = RT_DEBUG_ERROR;
index c2f472ee6eb6f20cd936ac031d024cba162555df..be2d17f60c35e8a1f873c971cc578b4d84cd908d 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include <asm/uaccess.h>
 
index bd5e77bf716213df8c27900c9c1f6d00a2a63ea3..c5b80f9c32c0638b29c4c0785d82a37ee35db575 100644 (file)
@@ -31,6 +31,7 @@
 ******************************************************************************/
 #include <linux/wireless.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "ieee80211.h"
index b1757acabedcd331e706d785b344a7f518da6756..55d12e3271de685b0230eeed253fa71e8cf95ff0 100644 (file)
@@ -30,6 +30,7 @@
 #undef RX_DONT_PASS_UL
 #undef DUMMY_RX
 
+#include <linux/slab.h>
 #include <linux/syscalls.h>
 #include <linux/eeprom_93cx6.h>
 
index ea96c49569304fbac8a1b4c6a882b841baec6f59..d1d7b0866755522db2970bf4e7cc92b303cb8fee 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include <asm/uaccess.h>
 #ifdef ENABLE_DOT11D
index a3302d5e01ab55d88b8c0e84844cb8343494ad1d..de57967b9681d71c72ae630b0d3e3b0364aac79c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/wireless.h>
 #include <linux/version.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "ieee80211.h"
index e2cbfd3aa00f11d564f73137253b9a0a03c61765..e8699616fad44a0fd0fa1446af942e4aeb755151 100644 (file)
@@ -1,5 +1,6 @@
 #include "ieee80211.h"
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include "rtl819x_TS.h"
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
index 886105db8b7c3bd97790da9b2f5531b350824cc3..bb7e1ef28d3b20c5eb4acb04b09bc959a69e8bb0 100644 (file)
@@ -47,6 +47,7 @@
 
 //#define CONFIG_RTL8192_IO_MAP
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include "r8192E_hw.h"
 #include "r8192E.h"
index 9d8cb0e575d3def3b6ebbf0c3c99ba3ed461c207..84a4e23b60b3fa6518c4ff25f174707bfb9f16c1 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include <asm/uaccess.h>
 #include "dot11d.h"
index 122f8004904b1a4484fa4bd8e166001913ec65f3..727cc552c5eef4e93d65b226ade2bbd8836125e6 100644 (file)
@@ -31,6 +31,7 @@
 ******************************************************************************/
 #include <linux/wireless.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "ieee80211.h"
index 60cf1f8781ce41f35ce27cba4cda0bb76d713915..38468c53967506a2a7f2b306613084dba9785406 100644 (file)
@@ -1,5 +1,6 @@
 #include "ieee80211.h"
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include "rtl819x_TS.h"
 
 void TsSetupTimeOut(unsigned long data)
index 7d0305cc21062320969ed6426d3f0adb9ecb752f..e16256fe595a2d5b88cbd69fa04d3aad96e566d4 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #undef LOOP_TEST
 #undef DUMP_RX
index 27d925712cddfca52b7d92eccfc4b0c7f2499c33..d54e3a77423ff2f79b70c47f312e7b4af7066341 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/random.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include <asm/uaccess.h>
 #ifdef ENABLE_DOT11D
index c0b2c02b0ac458fbcf56ec727f252f74c876bce5..750e94e17114dfd65f5530b79310abca3d633910 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/wireless.h>
 #include <linux/version.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 #include "ieee80211.h"
index d1275e887f0cdcd198903db17bd0c22b4c4f7ef2..451120ff2130e62f6fd3a155614721eb493f2756 100644 (file)
@@ -1,5 +1,6 @@
 #include "ieee80211.h"
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include "rtl819x_TS.h"
 
 void TsSetupTimeOut(unsigned long data)
index f1e085ba1cf1639c7b9f7761feaf04bf320dc470..68ebb02567714ef22095e02d87f7acad7addd352 100644 (file)
@@ -70,6 +70,7 @@ double __extendsfdf2(float a) {return a;}
 #include "r8192U_dm.h"
 //#include "r8192xU_phyreg.h"
 #include <linux/usb.h>
+#include <linux/slab.h>
 // FIXME: check if 2.6.7 is ok
 
 #ifdef CONFIG_RTL8192_PM
index 265de7949a78758e8c83cd9381b5681785f762c7..88880734921a8a8a1dd8ea7a50354bf255e41bab 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/sched.h>
 #include <linux/pci.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <asm/ioctl.h>
 #include <linux/ioport.h>
 #include <asm/io.h>
index 9c82a1a81ccc8ba06a0bfe9cb90791e158eb5e59..8d7261c052eb4d9337feab41b3fb436b1fc17b76 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/fb.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/console.h>
 #include <linux/screen_info.h>
index 698aade79d40a3eb921415d0e4befef4b9a3217c..c976c6b4d28a6165c74d702b5c124eb6f19280f7 100644 (file)
@@ -107,6 +107,7 @@ static const char StripVersion[] = "1.3A-STUART.CHESHIRE";
 #include <linux/serialP.h>
 #include <linux/rcupdate.h>
 #include <linux/compat.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/net_namespace.h>
 
index 8f6223c8303a6f9a390fa6158e6268eac738de9f..a78ade0dc6874fa78cfa2e6072f27751f2c19dfd 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/fb.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include "udlfb.h"
 
index 173b018c56d8c6011ba73d98b542564649cff5fc..3f95605427a7447c92ebd2e2b95d7600adafa20e 100644 (file)
@@ -17,6 +17,8 @@
  * USA.
  */
 
+#include <linux/slab.h>
+
 #include "usbip_common.h"
 #include "stub.h"
 
index ba1678fa6311b33b736bfad74fe5cdd02b1f944e..6665cefe573b539a2c4046bc2280594500f8d2a6 100644 (file)
@@ -17,6 +17,7 @@
  * USA.
  */
 
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "stub.h"
index 815fb7cc3b2362d45c2af9e0def402d9a24ff195..bc2674086673b058d769744baae59b93bdd24b4a 100644 (file)
@@ -17,6 +17,8 @@
  * USA.
  */
 
+#include <linux/slab.h>
+
 #include "usbip_common.h"
 #include "stub.h"
 #include "../../usb/core/hcd.h"
index e2ab4f3fdac236e2464b43a9e84c51756361e068..d7136e2c86faa16a1e64638047dc0109dca0d533 100644 (file)
@@ -17,6 +17,8 @@
  * USA.
  */
 
+#include <linux/slab.h>
+
 #include "usbip_common.h"
 #include "stub.h"
 
index 7a45da8f9565e3731538095531402ad5833d87d6..e3fa4216c1cdaf0552f1e8f45c9e826bbf35f622 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/tcp.h>
 #include <linux/in.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include "usbip_common.h"
 
 /* version information */
index ef4371358dbe9fe0a4bb0e837fe4acecf05a9e16..0b1766122d389f42fb086f839d03a0cbf27f3ce7 100644 (file)
@@ -17,6 +17,7 @@
  * USA.
  */
 
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
index 7636d86c23881589346167506f098e055aa4cafa..8147d7202b2dc092e8986891baaf463e6e3f1bf3 100644 (file)
@@ -17,6 +17,8 @@
  * USA.
  */
 
+#include <linux/slab.h>
+
 #include "usbip_common.h"
 #include "vhci.h"
 
index 7a00eb44b7954846506fed6355232f740a3b1dd6..b71b4c2fbd86e20bd1706ee16aeca23f1f53b59d 100644 (file)
@@ -17,6 +17,8 @@
  * USA.
  */
 
+#include <linux/slab.h>
+
 #include "usbip_common.h"
 #include "vhci.h"
 
index 2795ff2411e030e5f9a1291f5457c1a071b72c04..b159ea58adf7a72db94aa1b02b857ede17b7fb03 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/time.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
index faf652edb70ff89e89c413c373af157760cea7d8..68f24425977f29367097a1fc1772090380675084 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <asm/time.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
index c60c80fb241d506b079de6b3240fbacdd2f79d87..1ab9a985dfb94fb51cbbc8c122cca4c422fc63b0 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/pagemap.h>
 #include <linux/pci.h>
 #include <linux/semaphore.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/syscalls.h>
 #include <linux/types.h>
index d6d84ebeeec0a3d0fc3cd3cf2a02ad573d966854..934283a19ca5c9c75dc0497ab2b42f1d50f812d0 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/syscalls.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include "vme.h"
 #include "vme_bridge.h"
index 1d643653a7ed85f25ab52bc7b4c13200525ef71e..e40a2e990f4f6e389da82b567026ba00871da29f 100644 (file)
@@ -84,6 +84,7 @@
 #include "iowpa.h"
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 //#define      DEBUG
 /*---------------------  Static Definitions -------------------------*/
index f5608ad9ed00e0871148fb6b365b22e307cce6f0..1b93547ff5bcd2a37793a5d5074621e9bc09ebe0 100644 (file)
@@ -2,6 +2,7 @@
 #include "wb35reg_f.h"
 
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency);
 
index 4d41f6c3563c75052140fb88752ddb9e45025346..d7b57e62db08caff270ba800c0605ce4daed3a2c 100644 (file)
@@ -9,6 +9,7 @@
 //
 //============================================================================
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "core.h"
 #include "sysdef.h"
index 5869ef473fcd2e2e7644c683ab6bda9b721e8ed6..bda7a913edf84ec06908ab08423057203222e065 100644 (file)
@@ -9,6 +9,7 @@
 //
 //============================================================================
 #include <linux/usb.h>
+#include <linux/gfp.h>
 
 #include "wb35tx_f.h"
 #include "mds_f.h"
index 811a8daa660ec5913e53558d1b8a858b53c3a986..9da42e66085e0039a007be1e5f8b03bc25e01fed 100644 (file)
@@ -67,7 +67,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/timer.h>
index fa082d90fcade4820f710a094f7a91e83588d982..1db73ebcae28798407b9e02eb65a6ca2cc27c409 100644 (file)
@@ -65,6 +65,7 @@
 #include <wl_version.h>
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 // #include <linux/sched.h>
index 01e4bec9fd5be1118bef73e2a68c2ec7bd4bed01..6751b4bad2e43560c60f92939f6a3c5ac8fcf3fb 100644 (file)
@@ -71,7 +71,6 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 //#include <linux/timer.h>
index ee610c76457e99235575a91532c0a688353377ad..727ea8a483af313d7bd3b855db44ca0f6e6b23f2 100644 (file)
@@ -65,6 +65,7 @@
 
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <asm/uaccess.h>
 
index c2e95f166828f42ddeb9f9bc23ff26f0d17d1018..e1e7bf1bf27c6eb058e4468f07bf9aadbe073bf9 100644 (file)
@@ -55,7 +55,6 @@
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
-#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
index ecbb15b297ae99ff687a3aacff5f69f68285bc63..80c2d3b672bb9e47c471c3c8fb8760ac0af42727 100644 (file)
@@ -50,7 +50,6 @@
 
 #include <linux/netdevice.h>
 #include <linux/wireless.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/kernel.h>
 
index 2fa1dfa23783e16924c1e476f0597809b8de5f3c..83f1d6cd7991f8fc0ccee7b4ce9cca6ff1014553 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
index 4be54cea6ad7bd8c029f9e9735aee19832f53170..d383ea85c9bc0053721489a6bac416c355365f18 100644 (file)
@@ -48,6 +48,7 @@
 /*================================================================*/
 /* System Includes */
 #include <linux/ihex.h>
+#include <linux/slab.h>
 
 /*================================================================*/
 /* Local Constants */
index ad163da72ae466d1a5de12cefdb73e29fe2c67a5..4d1cdfc3542098054518aa12b10aa0a10afe5c44 100644 (file)
@@ -63,7 +63,6 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <linux/netdevice.h>
 #include <linux/delay.h>
index 98a5d58c3f55065d8b415ee090ff11214fb1e4bc..0b0ec9c59a5dc1be9c9e053e5d61f06bf654b315 100644 (file)
@@ -54,7 +54,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <linux/netdevice.h>
 #include <linux/io.h>
index e5bd4470a570a4d45fcd7ef97d6a93c0a90aa601..a8aaf6ac2ae2275e2071dc53c174d0543db64dd8 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/tc.h>
 #include <linux/types.h>
index 5066de5cfc0c5b3f2b9bc7709e09a1bb801b8bbc..9b6297f07b83cd227e75494c598b1723365f5e0f 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/kdev_t.h>
 #include <linux/idr.h>
 #include <linux/thermal.h>
index 4de382acd8f26ecc64d74dfcdaf5deba7d7d87cd..bff1afbde5a4b0ad01d0314b1661d43c972c3d84 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/idr.h>
 #include <linux/sched.h>
index b7830e9a3baabf1373ab8c62fcdc8602d0faf0aa..72b22d44e8b90b9645f08a612656c9042dbb629c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/io.h>
 #include <linux/uaccess.h>
 #include <linux/uio_driver.h>
+#include <linux/slab.h>
 
 #define PCI_VENDOR_ID_AEC 0xaecb
 #define PCI_DEVICE_ID_AEC_VITCLTC 0x6250
index 28034c812914e024b5494fecb818f1a3ddfa315d..371f87f8bc229f7cdcabca5d7cee7944a6b3cf7f 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/uio_driver.h>
 
 #include <asm/io.h>
index afbf0bd55cc9ea3f6b3c3475ec85c7d39ee0d31a..5a18e9f7b8362787dbf60c0dc09fe48c23d627be 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/uio_driver.h>
 
 #define PCI_VENDOR_ID_HILSCHER         0x15CF
index 313da35984afece38a4614e427431d5ab4be6772..85c9884a67fdd1497ae99fde326cc8def67838a9 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/uio_driver.h>
 #include <linux/spinlock.h>
 
index d494ce9288c37e9b59c34962c66b291f7185a313..7d3e469b99045be5ad1ff6e0dfecc4dd1870d50e 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/platform_device.h>
 #include <linux/uio_driver.h>
 #include <linux/stringify.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "uio_pdrv"
 
index 1ef3b8fc50b33063ed3fa988dd7b7ea9740bde08..61e569df2bba60cabc46a6e85d5f33007fd58a6c 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/stringify.h>
 #include <linux/pm_runtime.h>
+#include <linux/slab.h>
 
 #define DRIVER_NAME "uio_pdrv_genirq"
 
index a6d1b2bc47f3379f1930c9a610df7cb85706b8c3..3d461cd73e6b5bf9487a5e6662dbbc3da538a338 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/pci.h>
 #include <linux/uio_driver.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 /* ID's for SERCOS III PCI card (PLX 9030) */
 #define SERCOS_SUB_VENDOR_ID  0x1971
index 3e862401a638e15141460190208270a03aa0a756..1e9ba4bdffeff65e501751569eb41c5d8944966c 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/firmware.h>
-#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
index c5395246886d060b11c4ba2e12867c5784d2e211..25f01b536f67c3551b0452d9e7f1b2edcf3ca35c 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <linux/freezer.h>
+#include <linux/slab.h>
 
 #include <asm/unaligned.h>
 
index 029ee4a8a1f33b4b3bf4d28dd4a46723b9fdc72a..b6d49234e5217a9fd0779944469790cef5f479d0 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/c67x00.h>
 
index 85dfe29656618dfd17fe3f32b1b436e56dea38c0..f6b3c253f3fa92db1afe24be7cbcbf99684558d3 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include "c67x00.h"
 #include "c67x00-hcd.h"
index 975d556b47874e5148b1520ff5bb5cc6a8c072bc..be6331e2c2764f0f4b1d36a85efd773e0c76bdd5 100644 (file)
@@ -1441,7 +1441,7 @@ static int acm_resume(struct usb_interface *intf)
                        wb = acm->delayed_wb;
                        acm->delayed_wb = NULL;
                        spin_unlock_irq(&acm->write_lock);
-                       acm_start_wb(acm, acm->delayed_wb);
+                       acm_start_wb(acm, wb);
                } else {
                        spin_unlock_irq(&acm->write_lock);
                }
index 18aafcb08fc8be08536a4ff3caf75859bc003116..189141ca4e0513c8775a70f8c125777ff410fbbc 100644 (file)
@@ -52,7 +52,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
 #define WDM_READ               4
 #define WDM_INT_STALL          5
 #define WDM_POLL_RUNNING       6
-
+#define WDM_RESPONDING         7
+#define WDM_SUSPENDING         8
 
 #define WDM_MAX                        16
 
@@ -87,9 +88,7 @@ struct wdm_device {
        int                     count;
        dma_addr_t              shandle;
        dma_addr_t              ihandle;
-       struct mutex            wlock;
-       struct mutex            rlock;
-       struct mutex            plock;
+       struct mutex            lock;
        wait_queue_head_t       wait;
        struct work_struct      rxwork;
        int                     werr;
@@ -117,21 +116,22 @@ static void wdm_in_callback(struct urb *urb)
        int status = urb->status;
 
        spin_lock(&desc->iuspin);
+       clear_bit(WDM_RESPONDING, &desc->flags);
 
        if (status) {
                switch (status) {
                case -ENOENT:
                        dev_dbg(&desc->intf->dev,
                                "nonzero urb status received: -ENOENT");
-                       break;
+                       goto skip_error;
                case -ECONNRESET:
                        dev_dbg(&desc->intf->dev,
                                "nonzero urb status received: -ECONNRESET");
-                       break;
+                       goto skip_error;
                case -ESHUTDOWN:
                        dev_dbg(&desc->intf->dev,
                                "nonzero urb status received: -ESHUTDOWN");
-                       break;
+                       goto skip_error;
                case -EPIPE:
                        dev_err(&desc->intf->dev,
                                "nonzero urb status received: -EPIPE\n");
@@ -147,6 +147,7 @@ static void wdm_in_callback(struct urb *urb)
        desc->reslength = urb->actual_length;
        memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
        desc->length += desc->reslength;
+skip_error:
        wake_up(&desc->wait);
 
        set_bit(WDM_READ, &desc->flags);
@@ -229,13 +230,16 @@ static void wdm_int_callback(struct urb *urb)
        desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
        spin_lock(&desc->iuspin);
        clear_bit(WDM_READ, &desc->flags);
-       if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
+       set_bit(WDM_RESPONDING, &desc->flags);
+       if (!test_bit(WDM_DISCONNECTING, &desc->flags)
+               && !test_bit(WDM_SUSPENDING, &desc->flags)) {
                rv = usb_submit_urb(desc->response, GFP_ATOMIC);
                dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
                        __func__, rv);
        }
        spin_unlock(&desc->iuspin);
        if (rv < 0) {
+               clear_bit(WDM_RESPONDING, &desc->flags);
                if (rv == -EPERM)
                        return;
                if (rv == -ENOMEM) {
@@ -305,14 +309,38 @@ static ssize_t wdm_write
        if (we < 0)
                return -EIO;
 
-       r = mutex_lock_interruptible(&desc->wlock); /* concurrent writes */
+       desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
+       if (!buf) {
+               rv = -ENOMEM;
+               goto outnl;
+       }
+
+       r = copy_from_user(buf, buffer, count);
+       if (r > 0) {
+               kfree(buf);
+               rv = -EFAULT;
+               goto outnl;
+       }
+
+       /* concurrent writes and disconnect */
+       r = mutex_lock_interruptible(&desc->lock);
        rv = -ERESTARTSYS;
-       if (r)
+       if (r) {
+               kfree(buf);
                goto outnl;
+       }
+
+       if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
+               kfree(buf);
+               rv = -ENODEV;
+               goto outnp;
+       }
 
        r = usb_autopm_get_interface(desc->intf);
-       if (r < 0)
+       if (r < 0) {
+               kfree(buf);
                goto outnp;
+       }
 
        if (!file->f_flags && O_NONBLOCK)
                r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
@@ -320,24 +348,8 @@ static ssize_t wdm_write
        else
                if (test_bit(WDM_IN_USE, &desc->flags))
                        r = -EAGAIN;
-       if (r < 0)
-               goto out;
-
-       if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
-               rv = -ENODEV;
-               goto out;
-       }
-
-       desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
-       if (!buf) {
-               rv = -ENOMEM;
-               goto out;
-       }
-
-       r = copy_from_user(buf, buffer, count);
-       if (r > 0) {
+       if (r < 0) {
                kfree(buf);
-               rv = -EFAULT;
                goto out;
        }
 
@@ -374,7 +386,7 @@ static ssize_t wdm_write
 out:
        usb_autopm_put_interface(desc->intf);
 outnp:
-       mutex_unlock(&desc->wlock);
+       mutex_unlock(&desc->lock);
 outnl:
        return rv < 0 ? rv : count;
 }
@@ -387,7 +399,7 @@ static ssize_t wdm_read
        struct wdm_device *desc = file->private_data;
 
 
-       rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
+       rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */
        if (rv < 0)
                return -ERESTARTSYS;
 
@@ -424,11 +436,8 @@ retry:
                spin_lock_irq(&desc->iuspin);
 
                if (desc->rerr) { /* read completed, error happened */
-                       int t = desc->rerr;
                        desc->rerr = 0;
                        spin_unlock_irq(&desc->iuspin);
-                       dev_err(&desc->intf->dev,
-                               "reading had resulted in %d\n", t);
                        rv = -EIO;
                        goto err;
                }
@@ -465,9 +474,7 @@ retry:
        rv = cntr;
 
 err:
-       mutex_unlock(&desc->rlock);
-       if (rv < 0 && rv != -EAGAIN)
-               dev_err(&desc->intf->dev, "wdm_read: exit error\n");
+       mutex_unlock(&desc->lock);
        return rv;
 }
 
@@ -533,7 +540,7 @@ static int wdm_open(struct inode *inode, struct file *file)
        }
        intf->needs_remote_wakeup = 1;
 
-       mutex_lock(&desc->plock);
+       mutex_lock(&desc->lock);
        if (!desc->count++) {
                rv = usb_submit_urb(desc->validity, GFP_KERNEL);
                if (rv < 0) {
@@ -544,7 +551,7 @@ static int wdm_open(struct inode *inode, struct file *file)
        } else {
                rv = 0;
        }
-       mutex_unlock(&desc->plock);
+       mutex_unlock(&desc->lock);
        usb_autopm_put_interface(desc->intf);
 out:
        mutex_unlock(&wdm_mutex);
@@ -556,9 +563,9 @@ static int wdm_release(struct inode *inode, struct file *file)
        struct wdm_device *desc = file->private_data;
 
        mutex_lock(&wdm_mutex);
-       mutex_lock(&desc->plock);
+       mutex_lock(&desc->lock);
        desc->count--;
-       mutex_unlock(&desc->plock);
+       mutex_unlock(&desc->lock);
 
        if (!desc->count) {
                dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
@@ -655,9 +662,7 @@ next_desc:
        desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
        if (!desc)
                goto out;
-       mutex_init(&desc->wlock);
-       mutex_init(&desc->rlock);
-       mutex_init(&desc->plock);
+       mutex_init(&desc->lock);
        spin_lock_init(&desc->iuspin);
        init_waitqueue_head(&desc->wait);
        desc->wMaxCommand = maxcom;
@@ -771,14 +776,17 @@ static void wdm_disconnect(struct usb_interface *intf)
        /* to terminate pending flushes */
        clear_bit(WDM_IN_USE, &desc->flags);
        spin_unlock_irqrestore(&desc->iuspin, flags);
-       cancel_work_sync(&desc->rxwork);
+       mutex_lock(&desc->lock);
        kill_urbs(desc);
+       cancel_work_sync(&desc->rxwork);
+       mutex_unlock(&desc->lock);
        wake_up_all(&desc->wait);
        if (!desc->count)
                cleanup(desc);
        mutex_unlock(&wdm_mutex);
 }
 
+#ifdef CONFIG_PM
 static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
 {
        struct wdm_device *desc = usb_get_intfdata(intf);
@@ -786,22 +794,30 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
 
        dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
 
-       mutex_lock(&desc->plock);
-#ifdef CONFIG_PM
+       /* if this is an autosuspend the caller does the locking */
+       if (!(message.event & PM_EVENT_AUTO))
+               mutex_lock(&desc->lock);
+       spin_lock_irq(&desc->iuspin);
+
        if ((message.event & PM_EVENT_AUTO) &&
-                       test_bit(WDM_IN_USE, &desc->flags)) {
+                       (test_bit(WDM_IN_USE, &desc->flags)
+                       || test_bit(WDM_RESPONDING, &desc->flags))) {
+               spin_unlock_irq(&desc->iuspin);
                rv = -EBUSY;
        } else {
-#endif
-               cancel_work_sync(&desc->rxwork);
+
+               set_bit(WDM_SUSPENDING, &desc->flags);
+               spin_unlock_irq(&desc->iuspin);
+               /* callback submits work - order is essential */
                kill_urbs(desc);
-#ifdef CONFIG_PM
+               cancel_work_sync(&desc->rxwork);
        }
-#endif
-       mutex_unlock(&desc->plock);
+       if (!(message.event & PM_EVENT_AUTO))
+               mutex_unlock(&desc->lock);
 
        return rv;
 }
+#endif
 
 static int recover_from_urb_loss(struct wdm_device *desc)
 {
@@ -815,23 +831,27 @@ static int recover_from_urb_loss(struct wdm_device *desc)
        }
        return rv;
 }
+
+#ifdef CONFIG_PM
 static int wdm_resume(struct usb_interface *intf)
 {
        struct wdm_device *desc = usb_get_intfdata(intf);
        int rv;
 
        dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
-       mutex_lock(&desc->plock);
+
+       clear_bit(WDM_SUSPENDING, &desc->flags);
        rv = recover_from_urb_loss(desc);
-       mutex_unlock(&desc->plock);
+
        return rv;
 }
+#endif
 
 static int wdm_pre_reset(struct usb_interface *intf)
 {
        struct wdm_device *desc = usb_get_intfdata(intf);
 
-       mutex_lock(&desc->plock);
+       mutex_lock(&desc->lock);
        return 0;
 }
 
@@ -841,7 +861,7 @@ static int wdm_post_reset(struct usb_interface *intf)
        int rv;
 
        rv = recover_from_urb_loss(desc);
-       mutex_unlock(&desc->plock);
+       mutex_unlock(&desc->lock);
        return 0;
 }
 
@@ -849,9 +869,11 @@ static struct usb_driver wdm_driver = {
        .name =         "cdc_wdm",
        .probe =        wdm_probe,
        .disconnect =   wdm_disconnect,
+#ifdef CONFIG_PM
        .suspend =      wdm_suspend,
        .resume =       wdm_resume,
        .reset_resume = wdm_resume,
+#endif
        .pre_reset =    wdm_pre_reset,
        .post_reset =   wdm_post_reset,
        .id_table =     wdm_ids,
index 8588c0937a89ea948dd8d839af7902e815e7d02e..3e7c1b800ebb03e8668ac6a506cc137d26bcf41a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/fs.h>
 #include <linux/uaccess.h>
 #include <linux/kref.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/usb.h>
 #include <linux/usb/tmc.h>
index d41811bfef2a35acc1eb52127cb3649c42efc87c..19bc03a9fecf3d8bbaba0bafafaf9f49d472e6b2 100644 (file)
@@ -50,7 +50,7 @@
 
 #include <linux/fs.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/poll.h>
 #include <linux/usb.h>
 #include <linux/smp_lock.h>
index e909ff7b9094051c1ea1812d1252718d96ba23cc..3466fdc5bb11e7cdc42871982c5e85cde38ae0bc 100644 (file)
@@ -1207,6 +1207,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
                        free_async(as);
                        return -ENOMEM;
                }
+               /* Isochronous input data may end up being discontiguous
+                * if some of the packets are short.  Clear the buffer so
+                * that the gaps don't leak kernel data to userspace.
+                */
+               if (is_in && uurb->type == USBDEVFS_URB_TYPE_ISO)
+                       memset(as->urb->transfer_buffer, 0,
+                                       uurb->buffer_length);
        }
        as->urb->dev = ps->dev;
        as->urb->pipe = (uurb->type << 30) |
@@ -1345,10 +1352,14 @@ static int processcompl(struct async *as, void __user * __user *arg)
        void __user *addr = as->userurb;
        unsigned int i;
 
-       if (as->userbuffer && urb->actual_length)
-               if (copy_to_user(as->userbuffer, urb->transfer_buffer,
-                                urb->actual_length))
+       if (as->userbuffer && urb->actual_length) {
+               if (urb->number_of_packets > 0)         /* Isochronous */
+                       i = urb->transfer_buffer_length;
+               else                                    /* Non-Isoc */
+                       i = urb->actual_length;
+               if (copy_to_user(as->userbuffer, urb->transfer_buffer, i))
                        goto err_out;
+       }
        if (put_user(as->status, &userurb->status))
                goto err_out;
        if (put_user(urb->actual_length, &userurb->actual_length))
index f3c233806fa3415a5489842f3ccbf4030da55f8f..6a3b5cae3a6e7d3b4b16fe0229caf59f3ad315f1 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/quirks.h>
 #include <linux/pm_runtime.h>
index d26b9ea981f92f322c5c402f38e53d7c075e7e52..4f84a41ee7a85a39bbe939be6e96bc3ba48c2445 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/idr.h>
 #include <linux/usb.h>
 #include "usb.h"
index c3536f151f029674bfd49d33a093a30069ce8904..f06f5dbc8cdc22fbedfa463c05b18672cbb99516 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/rwsem.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/usb.h>
 
index 27080561a1c2386567160b7aec7394028e1a60b3..45a32dadb40664388169a67d1443cdd6e7cf086c 100644 (file)
@@ -453,6 +453,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
                        if (urb->interval > (1 << 15))
                                return -EINVAL;
                        max = 1 << 15;
+                       break;
                case USB_SPEED_WIRELESS:
                        if (urb->interval > 16)
                                return -EINVAL;
index 7460cd797f454fd13f23dc157e6845a788dbe505..11a3e0fa433181363c1eb76c259e0b120a2f03b1 100644 (file)
@@ -747,7 +747,7 @@ config USB_MASS_STORAGE
          which may be used with composite framework.
 
          Say "y" to link the driver statically, or "m" to build
-         a dynamically linked module called "g_file_storage".  If unsure,
+         a dynamically linked module called "g_mass_storage".  If unsure,
          consider File-backed Storage Gadget.
 
 config USB_G_SERIAL
index 12ac9cd32a07562ec665f04636b75a263f68d9a8..df1bae9b048e4585f13f4b06ff720c497e667c54 100644 (file)
@@ -1370,6 +1370,12 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
 {
        struct at91_udc         *udc = _udc;
        u32                     rescans = 5;
+       int                     disable_clock = 0;
+
+       if (!udc->clocked) {
+               clk_on(udc);
+               disable_clock = 1;
+       }
 
        while (rescans--) {
                u32 status;
@@ -1458,6 +1464,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
                }
        }
 
+       if (disable_clock)
+               clk_off(udc);
+
        return IRQ_HANDLED;
 }
 
index f79bdfe4bed9f9e694146a38970c11d32fd1719f..75a256f3d45be57ee2791692672e4a9e57071d5b 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/list.h>
index c7cb87a6fee22a4519a0f720fcf3f3451eb22920..699695128e33de185f743afa8f26ed51f38f9295 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 
index e1191b9a316a6b3751c90c23e263849e5a5d6c51..47e8e722682c6c638de6b938485ac83849a3cedc 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/string.h>
index 65a5f94cbc0435153dfe76fda74bc5e4ff3481a5..3568de210f7977f75ead536e25e56c90f67c2c86 100644 (file)
@@ -266,7 +266,7 @@ struct usb_ep * __init usb_ep_autoconfig (
                }
 
 #ifdef CONFIG_BLACKFIN
-       } else if (gadget_is_musbhsfc(gadget) || gadget_is_musbhdrc(gadget)) {
+       } else if (gadget_is_musbhdrc(gadget)) {
                if ((USB_ENDPOINT_XFER_BULK == type) ||
                    (USB_ENDPOINT_XFER_ISOC == type)) {
                        if (USB_DIR_IN & desc->bEndpointAddress)
index e49c7325dce2e8c4eeef62f38b8217febd8b079e..400e1ebe6976678f4f991b3d3c9112a112278d79 100644 (file)
@@ -14,6 +14,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index f1e3aad76c3766fec509b898d7e50ac0fdb9ee23..43bf44514c417d0431b52604569bef796871248b 100644 (file)
@@ -9,6 +9,7 @@
  * Licensed under the GPL-2 or later.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <asm/atomic.h>
index 2fff530efc19f163eb466cf2d577cfdc525a5ac1..4e595324c614f6c8578055f8c577ad7a818b3e99 100644 (file)
@@ -21,6 +21,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/etherdevice.h>
index d4f0db58a8ad11238ee9ded4995f4f5780b863ab..38226e9a371d2d39dcb932a64144372545e75542 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 
 #include "u_ether.h"
 
index 6cb29d3df575b3757abb639de812d0cd42eb8daf..e91d1b16d9bed4901037fba7fbcc0c4af548db32 100644 (file)
@@ -21,6 +21,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index 5a3cdd08f1d05c7d589399670fa2ac4eec7eb4a7..f4911c09022e92c2c16cc1b294045a56a0aca231 100644 (file)
@@ -2910,7 +2910,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
 }
 
 
-static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
+static int __init fsg_bind(struct usb_configuration *c, struct usb_function *f)
 {
        struct fsg_dev          *fsg = fsg_from_func(f);
        struct usb_gadget       *gadget = c->cdev->gadget;
@@ -2954,7 +2954,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
 autoconf_fail:
        ERROR(fsg, "unable to autoconfigure all endpoints\n");
        rc = -ENOTSUPP;
-       fsg_unbind(c, f);
        return rc;
 }
 
index b4a3ba654ea53def501a4b7b6befdf83ba78bad1..8f8c64371475c28565e15406894080cf5f10cd07 100644 (file)
@@ -23,6 +23,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index d2de10b9dc4b0520d5151bb4a2d40c897893ad0f..3c6e1a058745c739e40cdd825882993a5671661f 100644 (file)
@@ -20,6 +20,7 @@
  * 02110-1301 USA
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index a30e60c7f129dc19ec732b51d9b7465ff7e71317..56b022150f227d8dbfd7ca939d80e376d0916e1c 100644 (file)
@@ -24,6 +24,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/etherdevice.h>
index db0aa93606ef90b4615e4acb5d908ba79944f5ce..490b00b01a7d68774263c4d84c89b7775eb4acad 100644 (file)
@@ -10,6 +10,7 @@
  * either version 2 of that License or (at your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index 09cba273d2dbda8c7fd346745410c9717fc87df2..6d3cc443d914010d6ee7fafac601f3980e04ccf8 100644 (file)
@@ -21,6 +21,7 @@
 
 /* #define VERBOSE_DEBUG */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 
index a9c98fdb626d75e855eb1515cef19dfb8100e299..8675ca415329ce535ab97e44251884c19c83ed33 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/etherdevice.h>
index 1edbc12fff18fdc172cd44627fc8e7d397f0b46c..e511fec9f26d8d5f529d3a6a7ba7ae5a648aa24e 100644 (file)
 #define        gadget_is_r8a66597(g)   0
 #endif
 
+#ifdef CONFIG_USB_S3C_HSOTG
+#define gadget_is_s3c_hsotg(g)    (!strcmp("s3c-hsotg", (g)->name))
+#else
+#define gadget_is_s3c_hsotg(g)    0
+#endif
+
 
 /**
  * usb_gadget_controller_number - support bcdDevice id convention
@@ -192,6 +198,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
                return 0x24;
        else if (gadget_is_r8a66597(gadget))
                return 0x25;
+       else if (gadget_is_s3c_hsotg(gadget))
+               return 0x26;
        return -ENOENT;
 }
 
index 04f6224b7e06b1b65972609f37a8cf7228b43174..2b56ce62185297de5d954fbc04719de818e9dfa6 100644 (file)
@@ -21,6 +21,7 @@
 /* #define VERBOSE_DEBUG */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/utsname.h>
 #include <linux/device.h>
 
index e8edc640381e5bdbd8275b3a580da2ea78a966ab..1088d08c7ed8fac07146bd8d6fbde9d59a1897ca 100644 (file)
@@ -1768,7 +1768,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
         * usb_gadget_driver_{register,unregister}() must change.
         */
        if (the_controller) {
-               WARNING(dev, "ignoring %s\n", pci_name(pdev));
+               pr_warning("ignoring %s\n", pci_name(pdev));
                return -EBUSY;
        }
        if (!pdev->irq) {
index 01ee0b9bc9575e7e8902fd67a66bea7ae4234fff..e743122fcd93e0f74ec23f8b1f0efa050d9a5f10 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
index 6cd3d54f56409d9255da3620e624f500b75511ed..fded3fca793b5850add32e2cb9798740cf6e02f3 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "lh7a40x_udc.h"
 
index a8c8543d1b08962666af3415ad4c8ce5c552b3c1..166bf71fd3482252e00fde5455fc529e8f22337b 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
index 76496f5d272c59cebd3856aa8cce245d5c4352f3..a930d7fd7e7a5425fff7bd6c77044acaf0dc2355 100644 (file)
@@ -211,8 +211,6 @@ static int __init cdc_do_config(struct usb_configuration *c)
        ret = fsg_add(c->cdev, c, fsg_common);
        if (ret < 0)
                return ret;
-       if (ret < 0)
-               return ret;
 
        return 0;
 }
index 05b892c3d686ccf0492dc87dc34fefc794e2084e..85b0d8921eae4fbfe14c86c1ac7bf1f9ffae3705 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 
 #include <asm/byteorder.h>
 #include <mach/hardware.h>
index 8b45145b913618ea302bf062e905a67ed87baaf2..888d8f166c0b1c9d4ddcac3fbf364935041458be 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
index 48267bc0b2e00c151bf05e8ed6caa2662e1de9a5..5c0d06c79a81f1f5e5198aa1576e5e2d29d369f7 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/netdevice.h>
 
index f742c8e7397ccf06a0759f88a0769723287522cd..124a8ccfdcdaee760ed6b24f8e61cdbc9e05e8e0 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/seq_file.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
index 35e0930f5bbb7c4927bceb6523af63e5562a59b8..7a86d2c9109c6bae8341e4d659792a9315d1a19f 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/ctype.h>
index 84ca195c2d10f8a2b71346bdd031ba18a15e1571..07f4178ad1788ef10363fba7899fae05ff14a036 100644 (file)
@@ -23,6 +23,7 @@
 /* #define VERBOSE_DEBUG */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/device.h>
 #include <linux/ctype.h>
 #include <linux/etherdevice.h>
index adf8260c3a6aeff9f295e4ad5bf45cdfcb23233c..16bdf77f582a02526f2b60750e26dbfb2e425228 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/delay.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
+#include <linux/slab.h>
 
 #include "u_serial.h"
 
index fac81ee193dd0100d71bcf344f4badb0d341a153..807280d069f96e815ea11c1eddddb29cbe6692fd 100644 (file)
@@ -50,6 +50,7 @@
 /* #define VERBOSE_DEBUG */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/utsname.h>
 #include <linux/device.h>
 
index 4e0c67f1f51ba1dbc5e4efb964936b01c4afe037..b6315aa47f7a91592b2ec613c965f86a49c61f5b 100644 (file)
@@ -12,7 +12,7 @@ fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
 ifeq ($(CONFIG_FHCI_DEBUG),y)
 fhci-objs += fhci-dbg.o
 endif
-xhci-objs := xhci-hcd.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o
+xhci-hcd-objs := xhci.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o
 
 obj-$(CONFIG_USB_WHCI_HCD)     += whci/
 
@@ -25,7 +25,7 @@ obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD)     += ohci-hcd.o
 obj-$(CONFIG_USB_UHCI_HCD)     += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD)     += fhci.o
-obj-$(CONFIG_USB_XHCI_HCD)     += xhci.o
+obj-$(CONFIG_USB_XHCI_HCD)     += xhci-hcd.o
 obj-$(CONFIG_USB_SL811_HCD)    += sl811-hcd.o
 obj-$(CONFIG_USB_SL811_CS)     += sl811_cs.o
 obj-$(CONFIG_USB_U132_HCD)     += u132-hcd.o
index d8d6d3461d3270de5fb71188c598557b465116f2..207e7a85aeb044f106f3a6a9a2c51b4f7c8c15ee 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -35,6 +34,7 @@
 #include <linux/moduleparam.h>
 #include <linux/dma-mapping.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include "../core/hcd.h"
 
@@ -995,7 +995,7 @@ rescan:
        /* endpoints can be iso streams.  for now, we don't
         * accelerate iso completions ... so spin a while.
         */
-       if (qh->hw->hw_info1 == 0) {
+       if (qh->hw == NULL) {
                ehci_vdbg (ehci, "iso delay\n");
                goto idle_timeout;
        }
index 23cd917088b41fa73a74abad13f66fba82a9df85..ead59f42e69b10e75be28c14a2186573d0723fdd 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/usb/otg.h>
+#include <linux/slab.h>
 
 #include <mach/mxc_ehci.h>
 
index f0282d6bb7aa63e42484b5868b31d96553c9fb7d..a67a0030dd57f8a44ec8c26a5478a8cdd2531065 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <plat/usb.h>
 
 /*
index 39340ae00ac488bcd6a0a3f1ed5ac71931dbe63e..a0aaaaff256070de68bffcd39d5d4815ee03200b 100644 (file)
@@ -1123,8 +1123,8 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
                                        urb->interval);
                }
 
-       /* if dev->ep [epnum] is a QH, info1.maxpacket is nonzero */
-       } else if (unlikely (stream->hw_info1 != 0)) {
+       /* if dev->ep [epnum] is a QH, hw is set */
+       } else if (unlikely (stream->hw != NULL)) {
                ehci_dbg (ehci, "dev %s ep%d%s, not iso??\n",
                        urb->dev->devpath, epnum,
                        usb_pipein(urb->pipe) ? "in" : "out");
@@ -1565,13 +1565,27 @@ itd_patch(
 static inline void
 itd_link (struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd)
 {
-       /* always prepend ITD/SITD ... only QH tree is order-sensitive */
-       itd->itd_next = ehci->pshadow [frame];
-       itd->hw_next = ehci->periodic [frame];
-       ehci->pshadow [frame].itd = itd;
+       union ehci_shadow       *prev = &ehci->pshadow[frame];
+       __hc32                  *hw_p = &ehci->periodic[frame];
+       union ehci_shadow       here = *prev;
+       __hc32                  type = 0;
+
+       /* skip any iso nodes which might belong to previous microframes */
+       while (here.ptr) {
+               type = Q_NEXT_TYPE(ehci, *hw_p);
+               if (type == cpu_to_hc32(ehci, Q_TYPE_QH))
+                       break;
+               prev = periodic_next_shadow(ehci, prev, type);
+               hw_p = shadow_next_periodic(ehci, &here, type);
+               here = *prev;
+       }
+
+       itd->itd_next = here;
+       itd->hw_next = *hw_p;
+       prev->itd = itd;
        itd->frame = frame;
        wmb ();
-       ehci->periodic[frame] = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD);
+       *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD);
 }
 
 /* fit urb's itds into the selected schedule slot; activate as needed */
index 2d85e21ff282e9199be521fe630588cf8b3e01fb..b1dce96dd621aa2fbf0d0280fe33f67b47190ce7 100644 (file)
@@ -394,9 +394,8 @@ struct ehci_iso_sched {
  * acts like a qh would, if EHCI had them for ISO.
  */
 struct ehci_iso_stream {
-       /* first two fields match QH, but info1 == 0 */
-       __hc32                  hw_next;
-       __hc32                  hw_info1;
+       /* first field matches ehci_hq, but is NULL */
+       struct ehci_qh_hw       *hw;
 
        u32                     refcount;
        u8                      bEndpointAddress;
index 5dcfb3de9945788798b5fae2ce91a67706458e4d..15379c636143e86fa5d684b5af5dc21f662f0ba5 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/usb.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
+#include <linux/slab.h>
 #include <asm/qe.h>
 #include <asm/fsl_gtm.h>
 #include "../core/hcd.h"
index 2c0736c9971242d3f7ec6a54d28f7ed72152d741..5591bfb499d19d2b8ccbe829b957452996651078 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/usb.h>
 #include "../core/hcd.h"
index b0a1446ba292542eecd682aaa6f2f3afd5f7ef07..f73c92359beb34579676a32b8a6cca72ecea3f59 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/types.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/usb.h>
 #include "../core/hcd.h"
index e1232890c78bb9f9f4d931589dc14adeb363f2ba..57013479d7f7c6d911a480b4a4652a8b5cfa9c20 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/io.h>
 #include <linux/usb.h>
index 88b03214622b96683f3c0f6d9b5db73e8d98f2d5..35742f8c7cdaf714d0562a9a1a5e3ae7a2f5d06e 100644 (file)
@@ -55,6 +55,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/wait.h>
index 213e270e1c2983ae4b430af95451519398efe1fb..8a12f297645fae9dfb08c191f0635ebe7d0b1b02 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "../core/hcd.h"
index a2b305477afef25b1a37c0e03a7cfeff42e6acf6..92de71dc7729f88fcd33b5b9a85cfc682ed21f8a 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/isp116x.h>
 #include <linux/platform_device.h>
index 35288bcae0dbc10ccc04fe380e36ba8026f1220a..83094d067e0f40bdf18370210e90cbd4d7b24ef8 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv)
 {
index bee558aed42778ce153b5a1db9c4c55376575431..d478ffad59b4db18eb1b5c0eb0654e4882b94efe 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <asm/cacheflush.h>
 
 #include "../core/hcd.h"
@@ -418,7 +419,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
 
 /* this function must be called with interrupt disabled */
 static void free_usb_address(struct r8a66597 *r8a66597,
-                            struct r8a66597_device *dev)
+                            struct r8a66597_device *dev, int reset)
 {
        int port;
 
@@ -430,7 +431,13 @@ static void free_usb_address(struct r8a66597 *r8a66597,
        dev->state = USB_STATE_DEFAULT;
        r8a66597->address_map &= ~(1 << dev->address);
        dev->address = 0;
-       dev_set_drvdata(&dev->udev->dev, NULL);
+       /*
+        * Only when resetting USB, it is necessary to erase drvdata. When
+        * a usb device with usb hub is disconnect, "dev->udev" is already
+        * freed on usb_desconnect(). So we cannot access the data.
+        */
+       if (reset)
+               dev_set_drvdata(&dev->udev->dev, NULL);
        list_del(&dev->device_list);
        kfree(dev);
 
@@ -1069,7 +1076,7 @@ static void r8a66597_usb_disconnect(struct r8a66597 *r8a66597, int port)
        struct r8a66597_device *dev = r8a66597->root_hub[port].dev;
 
        disable_r8a66597_pipe_all(r8a66597, dev);
-       free_usb_address(r8a66597, dev);
+       free_usb_address(r8a66597, dev, 0);
 
        start_root_hub_sampling(r8a66597, port, 0);
 }
@@ -2085,7 +2092,7 @@ static void update_usb_address_map(struct r8a66597 *r8a66597,
                                spin_lock_irqsave(&r8a66597->lock, flags);
                                dev = get_r8a66597_device(r8a66597, addr);
                                disable_r8a66597_pipe_all(r8a66597, dev);
-                               free_usb_address(r8a66597, dev);
+                               free_usb_address(r8a66597, dev, 0);
                                put_child_connect_map(r8a66597, addr);
                                spin_unlock_irqrestore(&r8a66597->lock, flags);
                        }
@@ -2228,7 +2235,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        rh->port |= (1 << USB_PORT_FEAT_RESET);
 
                        disable_r8a66597_pipe_all(r8a66597, dev);
-                       free_usb_address(r8a66597, dev);
+                       free_usb_address(r8a66597, dev, 1);
 
                        r8a66597_mdfy(r8a66597, USBRST, USBRST | UACT,
                                      get_dvstctr_reg(port));
index e52b954dda471d1a492e5be2a10ff2b5a19d8bdf..98cf0b26b9684b2da11b7aa2c0628196479cc2a1 100644 (file)
@@ -9,6 +9,7 @@
  * (C) Copyright 1999-2001 Johannes Erdfelt
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/debugfs.h>
 #include <linux/smp_lock.h>
index 562eba108816cb689bda3eee2b9b2125150c77fe..773249306031bd6a45ef7a49a22b9b7366e0a613 100644 (file)
@@ -16,6 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/dma-mapping.h>
 #include <linux/uwb/umc.h>
 #include <linux/usb.h>
index 8c1c610c9513222aa494e86e6977799c57cbc991..c5305b599ca052a1acc27e68386942e306f7c6e1 100644 (file)
@@ -15,6 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
index 34a783cb0133914b6806c9bcd322852f362a0888..f7582e8e2169216c64e0f75ff6e67e037579f885 100644 (file)
@@ -16,6 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/dma-mapping.h>
 #include <linux/uwb/umc.h>
 
index 0db3fb2dc03ae500f545b8356485c6b460c12859..33c5580b4d25f78c93b9abe7625edcf083f4011e 100644 (file)
@@ -16,6 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/dma-mapping.h>
 #include <linux/uwb/umc.h>
 #include <linux/usb.h>
index 7d4204db0f61c7ce18bb9e897700b22335094139..141d049beb3ee973df29af238728909d8353c27c 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/uwb/umc.h>
 #include <linux/usb.h>
 
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
deleted file mode 100644 (file)
index 4cb69e0..0000000
+++ /dev/null
@@ -1,1916 +0,0 @@
-/*
- * xHCI host controller driver
- *
- * Copyright (C) 2008 Intel Corp.
- *
- * Author: Sarah Sharp
- * Some code borrowed from the Linux EHCI driver.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/irq.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-
-#include "xhci.h"
-
-#define DRIVER_AUTHOR "Sarah Sharp"
-#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
-
-/* Some 0.95 hardware can't handle the chain bit on a Link TRB being cleared */
-static int link_quirk;
-module_param(link_quirk, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
-
-/* TODO: copied from ehci-hcd.c - can this be refactored? */
-/*
- * handshake - spin reading hc until handshake completes or fails
- * @ptr: address of hc register to be read
- * @mask: bits to look at in result of read
- * @done: value of those bits when handshake succeeds
- * @usec: timeout in microseconds
- *
- * Returns negative errno, or zero on success
- *
- * Success happens when the "mask" bits have the specified value (hardware
- * handshake done).  There are two failure modes:  "usec" have passed (major
- * hardware flakeout), or the register reads as all-ones (hardware removed).
- */
-static int handshake(struct xhci_hcd *xhci, void __iomem *ptr,
-                     u32 mask, u32 done, int usec)
-{
-       u32     result;
-
-       do {
-               result = xhci_readl(xhci, ptr);
-               if (result == ~(u32)0)          /* card removed */
-                       return -ENODEV;
-               result &= mask;
-               if (result == done)
-                       return 0;
-               udelay(1);
-               usec--;
-       } while (usec > 0);
-       return -ETIMEDOUT;
-}
-
-/*
- * Disable interrupts and begin the xHCI halting process.
- */
-void xhci_quiesce(struct xhci_hcd *xhci)
-{
-       u32 halted;
-       u32 cmd;
-       u32 mask;
-
-       mask = ~(XHCI_IRQS);
-       halted = xhci_readl(xhci, &xhci->op_regs->status) & STS_HALT;
-       if (!halted)
-               mask &= ~CMD_RUN;
-
-       cmd = xhci_readl(xhci, &xhci->op_regs->command);
-       cmd &= mask;
-       xhci_writel(xhci, cmd, &xhci->op_regs->command);
-}
-
-/*
- * Force HC into halt state.
- *
- * Disable any IRQs and clear the run/stop bit.
- * HC will complete any current and actively pipelined transactions, and
- * should halt within 16 microframes of the run/stop bit being cleared.
- * Read HC Halted bit in the status register to see when the HC is finished.
- * XXX: shouldn't we set HC_STATE_HALT here somewhere?
- */
-int xhci_halt(struct xhci_hcd *xhci)
-{
-       xhci_dbg(xhci, "// Halt the HC\n");
-       xhci_quiesce(xhci);
-
-       return handshake(xhci, &xhci->op_regs->status,
-                       STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
-}
-
-/*
- * Reset a halted HC, and set the internal HC state to HC_STATE_HALT.
- *
- * This resets pipelines, timers, counters, state machines, etc.
- * Transactions will be terminated immediately, and operational registers
- * will be set to their defaults.
- */
-int xhci_reset(struct xhci_hcd *xhci)
-{
-       u32 command;
-       u32 state;
-
-       state = xhci_readl(xhci, &xhci->op_regs->status);
-       if ((state & STS_HALT) == 0) {
-               xhci_warn(xhci, "Host controller not halted, aborting reset.\n");
-               return 0;
-       }
-
-       xhci_dbg(xhci, "// Reset the HC\n");
-       command = xhci_readl(xhci, &xhci->op_regs->command);
-       command |= CMD_RESET;
-       xhci_writel(xhci, command, &xhci->op_regs->command);
-       /* XXX: Why does EHCI set this here?  Shouldn't other code do this? */
-       xhci_to_hcd(xhci)->state = HC_STATE_HALT;
-
-       return handshake(xhci, &xhci->op_regs->command, CMD_RESET, 0, 250 * 1000);
-}
-
-
-#if 0
-/* Set up MSI-X table for entry 0 (may claim other entries later) */
-static int xhci_setup_msix(struct xhci_hcd *xhci)
-{
-       int ret;
-       struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
-
-       xhci->msix_count = 0;
-       /* XXX: did I do this right?  ixgbe does kcalloc for more than one */
-       xhci->msix_entries = kmalloc(sizeof(struct msix_entry), GFP_KERNEL);
-       if (!xhci->msix_entries) {
-               xhci_err(xhci, "Failed to allocate MSI-X entries\n");
-               return -ENOMEM;
-       }
-       xhci->msix_entries[0].entry = 0;
-
-       ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count);
-       if (ret) {
-               xhci_err(xhci, "Failed to enable MSI-X\n");
-               goto free_entries;
-       }
-
-       /*
-        * Pass the xhci pointer value as the request_irq "cookie".
-        * If more irqs are added, this will need to be unique for each one.
-        */
-       ret = request_irq(xhci->msix_entries[0].vector, &xhci_irq, 0,
-                       "xHCI", xhci_to_hcd(xhci));
-       if (ret) {
-               xhci_err(xhci, "Failed to allocate MSI-X interrupt\n");
-               goto disable_msix;
-       }
-       xhci_dbg(xhci, "Finished setting up MSI-X\n");
-       return 0;
-
-disable_msix:
-       pci_disable_msix(pdev);
-free_entries:
-       kfree(xhci->msix_entries);
-       xhci->msix_entries = NULL;
-       return ret;
-}
-
-/* XXX: code duplication; can xhci_setup_msix call this? */
-/* Free any IRQs and disable MSI-X */
-static void xhci_cleanup_msix(struct xhci_hcd *xhci)
-{
-       struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
-       if (!xhci->msix_entries)
-               return;
-
-       free_irq(xhci->msix_entries[0].vector, xhci);
-       pci_disable_msix(pdev);
-       kfree(xhci->msix_entries);
-       xhci->msix_entries = NULL;
-       xhci_dbg(xhci, "Finished cleaning up MSI-X\n");
-}
-#endif
-
-/*
- * Initialize memory for HCD and xHC (one-time init).
- *
- * Program the PAGESIZE register, initialize the device context array, create
- * device contexts (?), set up a command ring segment (or two?), create event
- * ring (one for now).
- */
-int xhci_init(struct usb_hcd *hcd)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       int retval = 0;
-
-       xhci_dbg(xhci, "xhci_init\n");
-       spin_lock_init(&xhci->lock);
-       if (link_quirk) {
-               xhci_dbg(xhci, "QUIRK: Not clearing Link TRB chain bits.\n");
-               xhci->quirks |= XHCI_LINK_TRB_QUIRK;
-       } else {
-               xhci_dbg(xhci, "xHCI doesn't need link TRB QUIRK\n");
-       }
-       retval = xhci_mem_init(xhci, GFP_KERNEL);
-       xhci_dbg(xhci, "Finished xhci_init\n");
-
-       return retval;
-}
-
-/*
- * Called in interrupt context when there might be work
- * queued on the event ring
- *
- * xhci->lock must be held by caller.
- */
-static void xhci_work(struct xhci_hcd *xhci)
-{
-       u32 temp;
-       u64 temp_64;
-
-       /*
-        * Clear the op reg interrupt status first,
-        * so we can receive interrupts from other MSI-X interrupters.
-        * Write 1 to clear the interrupt status.
-        */
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
-       temp |= STS_EINT;
-       xhci_writel(xhci, temp, &xhci->op_regs->status);
-       /* FIXME when MSI-X is supported and there are multiple vectors */
-       /* Clear the MSI-X event interrupt status */
-
-       /* Acknowledge the interrupt */
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       temp |= 0x3;
-       xhci_writel(xhci, temp, &xhci->ir_set->irq_pending);
-       /* Flush posted writes */
-       xhci_readl(xhci, &xhci->ir_set->irq_pending);
-
-       if (xhci->xhc_state & XHCI_STATE_DYING)
-               xhci_dbg(xhci, "xHCI dying, ignoring interrupt. "
-                               "Shouldn't IRQs be disabled?\n");
-       else
-               /* FIXME this should be a delayed service routine
-                * that clears the EHB.
-                */
-               xhci_handle_event(xhci);
-
-       /* Clear the event handler busy flag (RW1C); the event ring should be empty. */
-       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
-       xhci_write_64(xhci, temp_64 | ERST_EHB, &xhci->ir_set->erst_dequeue);
-       /* Flush posted writes -- FIXME is this necessary? */
-       xhci_readl(xhci, &xhci->ir_set->irq_pending);
-}
-
-/*-------------------------------------------------------------------------*/
-
-/*
- * xHCI spec says we can get an interrupt, and if the HC has an error condition,
- * we might get bad data out of the event ring.  Section 4.10.2.7 has a list of
- * indicators of an event TRB error, but we check the status *first* to be safe.
- */
-irqreturn_t xhci_irq(struct usb_hcd *hcd)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       u32 temp, temp2;
-       union xhci_trb *trb;
-
-       spin_lock(&xhci->lock);
-       trb = xhci->event_ring->dequeue;
-       /* Check if the xHC generated the interrupt, or the irq is shared */
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
-       temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       if (temp == 0xffffffff && temp2 == 0xffffffff)
-               goto hw_died;
-
-       if (!(temp & STS_EINT) && !ER_IRQ_PENDING(temp2)) {
-               spin_unlock(&xhci->lock);
-               return IRQ_NONE;
-       }
-       xhci_dbg(xhci, "op reg status = %08x\n", temp);
-       xhci_dbg(xhci, "ir set irq_pending = %08x\n", temp2);
-       xhci_dbg(xhci, "Event ring dequeue ptr:\n");
-       xhci_dbg(xhci, "@%llx %08x %08x %08x %08x\n",
-                       (unsigned long long)xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, trb),
-                       lower_32_bits(trb->link.segment_ptr),
-                       upper_32_bits(trb->link.segment_ptr),
-                       (unsigned int) trb->link.intr_target,
-                       (unsigned int) trb->link.control);
-
-       if (temp & STS_FATAL) {
-               xhci_warn(xhci, "WARNING: Host System Error\n");
-               xhci_halt(xhci);
-hw_died:
-               xhci_to_hcd(xhci)->state = HC_STATE_HALT;
-               spin_unlock(&xhci->lock);
-               return -ESHUTDOWN;
-       }
-
-       xhci_work(xhci);
-       spin_unlock(&xhci->lock);
-
-       return IRQ_HANDLED;
-}
-
-#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
-void xhci_event_ring_work(unsigned long arg)
-{
-       unsigned long flags;
-       int temp;
-       u64 temp_64;
-       struct xhci_hcd *xhci = (struct xhci_hcd *) arg;
-       int i, j;
-
-       xhci_dbg(xhci, "Poll event ring: %lu\n", jiffies);
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
-       xhci_dbg(xhci, "op reg status = 0x%x\n", temp);
-       if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
-               xhci_dbg(xhci, "HW died, polling stopped.\n");
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               return;
-       }
-
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       xhci_dbg(xhci, "ir_set 0 pending = 0x%x\n", temp);
-       xhci_dbg(xhci, "No-op commands handled = %d\n", xhci->noops_handled);
-       xhci_dbg(xhci, "HC error bitmask = 0x%x\n", xhci->error_bitmask);
-       xhci->error_bitmask = 0;
-       xhci_dbg(xhci, "Event ring:\n");
-       xhci_debug_segment(xhci, xhci->event_ring->deq_seg);
-       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
-       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
-       temp_64 &= ~ERST_PTR_MASK;
-       xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
-       xhci_dbg(xhci, "Command ring:\n");
-       xhci_debug_segment(xhci, xhci->cmd_ring->deq_seg);
-       xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
-       xhci_dbg_cmd_ptrs(xhci);
-       for (i = 0; i < MAX_HC_SLOTS; ++i) {
-               if (!xhci->devs[i])
-                       continue;
-               for (j = 0; j < 31; ++j) {
-                       struct xhci_ring *ring = xhci->devs[i]->eps[j].ring;
-                       if (!ring)
-                               continue;
-                       xhci_dbg(xhci, "Dev %d endpoint ring %d:\n", i, j);
-                       xhci_debug_segment(xhci, ring->deq_seg);
-               }
-       }
-
-       if (xhci->noops_submitted != NUM_TEST_NOOPS)
-               if (xhci_setup_one_noop(xhci))
-                       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       if (!xhci->zombie)
-               mod_timer(&xhci->event_ring_timer, jiffies + POLL_TIMEOUT * HZ);
-       else
-               xhci_dbg(xhci, "Quit polling the event ring.\n");
-}
-#endif
-
-/*
- * Start the HC after it was halted.
- *
- * This function is called by the USB core when the HC driver is added.
- * Its opposite is xhci_stop().
- *
- * xhci_init() must be called once before this function can be called.
- * Reset the HC, enable device slot contexts, program DCBAAP, and
- * set command ring pointer and event ring pointer.
- *
- * Setup MSI-X vectors and enable interrupts.
- */
-int xhci_run(struct usb_hcd *hcd)
-{
-       u32 temp;
-       u64 temp_64;
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       void (*doorbell)(struct xhci_hcd *) = NULL;
-
-       hcd->uses_new_polling = 1;
-       hcd->poll_rh = 0;
-
-       xhci_dbg(xhci, "xhci_run\n");
-#if 0  /* FIXME: MSI not setup yet */
-       /* Do this at the very last minute */
-       ret = xhci_setup_msix(xhci);
-       if (!ret)
-               return ret;
-
-       return -ENOSYS;
-#endif
-#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
-       init_timer(&xhci->event_ring_timer);
-       xhci->event_ring_timer.data = (unsigned long) xhci;
-       xhci->event_ring_timer.function = xhci_event_ring_work;
-       /* Poll the event ring */
-       xhci->event_ring_timer.expires = jiffies + POLL_TIMEOUT * HZ;
-       xhci->zombie = 0;
-       xhci_dbg(xhci, "Setting event ring polling timer\n");
-       add_timer(&xhci->event_ring_timer);
-#endif
-
-       xhci_dbg(xhci, "Command ring memory map follows:\n");
-       xhci_debug_ring(xhci, xhci->cmd_ring);
-       xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
-       xhci_dbg_cmd_ptrs(xhci);
-
-       xhci_dbg(xhci, "ERST memory map follows:\n");
-       xhci_dbg_erst(xhci, &xhci->erst);
-       xhci_dbg(xhci, "Event ring:\n");
-       xhci_debug_ring(xhci, xhci->event_ring);
-       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
-       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
-       temp_64 &= ~ERST_PTR_MASK;
-       xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
-
-       xhci_dbg(xhci, "// Set the interrupt modulation register\n");
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
-       temp &= ~ER_IRQ_INTERVAL_MASK;
-       temp |= (u32) 160;
-       xhci_writel(xhci, temp, &xhci->ir_set->irq_control);
-
-       /* Set the HCD state before we enable the irqs */
-       hcd->state = HC_STATE_RUNNING;
-       temp = xhci_readl(xhci, &xhci->op_regs->command);
-       temp |= (CMD_EIE);
-       xhci_dbg(xhci, "// Enable interrupts, cmd = 0x%x.\n",
-                       temp);
-       xhci_writel(xhci, temp, &xhci->op_regs->command);
-
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       xhci_dbg(xhci, "// Enabling event ring interrupter %p by writing 0x%x to irq_pending\n",
-                       xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
-       xhci_writel(xhci, ER_IRQ_ENABLE(temp),
-                       &xhci->ir_set->irq_pending);
-       xhci_print_ir_set(xhci, xhci->ir_set, 0);
-
-       if (NUM_TEST_NOOPS > 0)
-               doorbell = xhci_setup_one_noop(xhci);
-
-       temp = xhci_readl(xhci, &xhci->op_regs->command);
-       temp |= (CMD_RUN);
-       xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
-                       temp);
-       xhci_writel(xhci, temp, &xhci->op_regs->command);
-       /* Flush PCI posted writes */
-       temp = xhci_readl(xhci, &xhci->op_regs->command);
-       xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp);
-       if (doorbell)
-               (*doorbell)(xhci);
-
-       xhci_dbg(xhci, "Finished xhci_run\n");
-       return 0;
-}
-
-/*
- * Stop xHCI driver.
- *
- * This function is called by the USB core when the HC driver is removed.
- * Its opposite is xhci_run().
- *
- * Disable device contexts, disable IRQs, and quiesce the HC.
- * Reset the HC, finish any completed transactions, and cleanup memory.
- */
-void xhci_stop(struct usb_hcd *hcd)
-{
-       u32 temp;
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-
-       spin_lock_irq(&xhci->lock);
-       xhci_halt(xhci);
-       xhci_reset(xhci);
-       spin_unlock_irq(&xhci->lock);
-
-#if 0  /* No MSI yet */
-       xhci_cleanup_msix(xhci);
-#endif
-#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
-       /* Tell the event ring poll function not to reschedule */
-       xhci->zombie = 1;
-       del_timer_sync(&xhci->event_ring_timer);
-#endif
-
-       xhci_dbg(xhci, "// Disabling event ring interrupts\n");
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
-       xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       xhci_writel(xhci, ER_IRQ_DISABLE(temp),
-                       &xhci->ir_set->irq_pending);
-       xhci_print_ir_set(xhci, xhci->ir_set, 0);
-
-       xhci_dbg(xhci, "cleaning up memory\n");
-       xhci_mem_cleanup(xhci);
-       xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
-                   xhci_readl(xhci, &xhci->op_regs->status));
-}
-
-/*
- * Shutdown HC (not bus-specific)
- *
- * This is called when the machine is rebooting or halting.  We assume that the
- * machine will be powered off, and the HC's internal state will be reset.
- * Don't bother to free memory.
- */
-void xhci_shutdown(struct usb_hcd *hcd)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-
-       spin_lock_irq(&xhci->lock);
-       xhci_halt(xhci);
-       spin_unlock_irq(&xhci->lock);
-
-#if 0
-       xhci_cleanup_msix(xhci);
-#endif
-
-       xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
-                   xhci_readl(xhci, &xhci->op_regs->status));
-}
-
-/*-------------------------------------------------------------------------*/
-
-/**
- * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and
- * HCDs.  Find the index for an endpoint given its descriptor.  Use the return
- * value to right shift 1 for the bitmask.
- *
- * Index  = (epnum * 2) + direction - 1,
- * where direction = 0 for OUT, 1 for IN.
- * For control endpoints, the IN index is used (OUT index is unused), so
- * index = (epnum * 2) + direction - 1 = (epnum * 2) + 1 - 1 = (epnum * 2)
- */
-unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc)
-{
-       unsigned int index;
-       if (usb_endpoint_xfer_control(desc))
-               index = (unsigned int) (usb_endpoint_num(desc)*2);
-       else
-               index = (unsigned int) (usb_endpoint_num(desc)*2) +
-                       (usb_endpoint_dir_in(desc) ? 1 : 0) - 1;
-       return index;
-}
-
-/* Find the flag for this endpoint (for use in the control context).  Use the
- * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
- * bit 1, etc.
- */
-unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc)
-{
-       return 1 << (xhci_get_endpoint_index(desc) + 1);
-}
-
-/* Find the flag for this endpoint (for use in the control context).  Use the
- * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
- * bit 1, etc.
- */
-unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index)
-{
-       return 1 << (ep_index + 1);
-}
-
-/* Compute the last valid endpoint context index.  Basically, this is the
- * endpoint index plus one.  For slot contexts with more than valid endpoint,
- * we find the most significant bit set in the added contexts flags.
- * e.g. ep 1 IN (with epnum 0x81) => added_ctxs = 0b1000
- * fls(0b1000) = 4, but the endpoint context index is 3, so subtract one.
- */
-unsigned int xhci_last_valid_endpoint(u32 added_ctxs)
-{
-       return fls(added_ctxs) - 1;
-}
-
-/* Returns 1 if the arguments are OK;
- * returns 0 this is a root hub; returns -EINVAL for NULL pointers.
- */
-int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
-               struct usb_host_endpoint *ep, int check_ep, const char *func) {
-       if (!hcd || (check_ep && !ep) || !udev) {
-               printk(KERN_DEBUG "xHCI %s called with invalid args\n",
-                               func);
-               return -EINVAL;
-       }
-       if (!udev->parent) {
-               printk(KERN_DEBUG "xHCI %s called for root hub\n",
-                               func);
-               return 0;
-       }
-       if (!udev->slot_id) {
-               printk(KERN_DEBUG "xHCI %s called with unaddressed device\n",
-                               func);
-               return -EINVAL;
-       }
-       return 1;
-}
-
-static int xhci_configure_endpoint(struct xhci_hcd *xhci,
-               struct usb_device *udev, struct xhci_command *command,
-               bool ctx_change, bool must_succeed);
-
-/*
- * Full speed devices may have a max packet size greater than 8 bytes, but the
- * USB core doesn't know that until it reads the first 8 bytes of the
- * descriptor.  If the usb_device's max packet size changes after that point,
- * we need to issue an evaluate context command and wait on it.
- */
-static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
-               unsigned int ep_index, struct urb *urb)
-{
-       struct xhci_container_ctx *in_ctx;
-       struct xhci_container_ctx *out_ctx;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       struct xhci_ep_ctx *ep_ctx;
-       int max_packet_size;
-       int hw_max_packet_size;
-       int ret = 0;
-
-       out_ctx = xhci->devs[slot_id]->out_ctx;
-       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
-       hw_max_packet_size = MAX_PACKET_DECODED(ep_ctx->ep_info2);
-       max_packet_size = urb->dev->ep0.desc.wMaxPacketSize;
-       if (hw_max_packet_size != max_packet_size) {
-               xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n");
-               xhci_dbg(xhci, "Max packet size in usb_device = %d\n",
-                               max_packet_size);
-               xhci_dbg(xhci, "Max packet size in xHCI HW = %d\n",
-                               hw_max_packet_size);
-               xhci_dbg(xhci, "Issuing evaluate context command.\n");
-
-               /* Set up the modified control endpoint 0 */
-               xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx,
-                               xhci->devs[slot_id]->out_ctx, ep_index);
-               in_ctx = xhci->devs[slot_id]->in_ctx;
-               ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
-               ep_ctx->ep_info2 &= ~MAX_PACKET_MASK;
-               ep_ctx->ep_info2 |= MAX_PACKET(max_packet_size);
-
-               /* Set up the input context flags for the command */
-               /* FIXME: This won't work if a non-default control endpoint
-                * changes max packet sizes.
-                */
-               ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
-               ctrl_ctx->add_flags = EP0_FLAG;
-               ctrl_ctx->drop_flags = 0;
-
-               xhci_dbg(xhci, "Slot %d input context\n", slot_id);
-               xhci_dbg_ctx(xhci, in_ctx, ep_index);
-               xhci_dbg(xhci, "Slot %d output context\n", slot_id);
-               xhci_dbg_ctx(xhci, out_ctx, ep_index);
-
-               ret = xhci_configure_endpoint(xhci, urb->dev, NULL,
-                               true, false);
-
-               /* Clean up the input context for later use by bandwidth
-                * functions.
-                */
-               ctrl_ctx->add_flags = SLOT_FLAG;
-       }
-       return ret;
-}
-
-/*
- * non-error returns are a promise to giveback() the urb later
- * we drop ownership so next owner (or urb unlink) can get it
- */
-int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       unsigned long flags;
-       int ret = 0;
-       unsigned int slot_id, ep_index;
-
-
-       if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0)
-               return -EINVAL;
-
-       slot_id = urb->dev->slot_id;
-       ep_index = xhci_get_endpoint_index(&urb->ep->desc);
-
-       if (!xhci->devs || !xhci->devs[slot_id]) {
-               if (!in_interrupt())
-                       dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n");
-               ret = -EINVAL;
-               goto exit;
-       }
-       if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
-               if (!in_interrupt())
-                       xhci_dbg(xhci, "urb submitted during PCI suspend\n");
-               ret = -ESHUTDOWN;
-               goto exit;
-       }
-       if (usb_endpoint_xfer_control(&urb->ep->desc)) {
-               /* Check to see if the max packet size for the default control
-                * endpoint changed during FS device enumeration
-                */
-               if (urb->dev->speed == USB_SPEED_FULL) {
-                       ret = xhci_check_maxpacket(xhci, slot_id,
-                                       ep_index, urb);
-                       if (ret < 0)
-                               return ret;
-               }
-
-               /* We have a spinlock and interrupts disabled, so we must pass
-                * atomic context to this function, which may allocate memory.
-                */
-               spin_lock_irqsave(&xhci->lock, flags);
-               if (xhci->xhc_state & XHCI_STATE_DYING)
-                       goto dying;
-               ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,
-                               slot_id, ep_index);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-       } else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) {
-               spin_lock_irqsave(&xhci->lock, flags);
-               if (xhci->xhc_state & XHCI_STATE_DYING)
-                       goto dying;
-               ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,
-                               slot_id, ep_index);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-       } else if (usb_endpoint_xfer_int(&urb->ep->desc)) {
-               spin_lock_irqsave(&xhci->lock, flags);
-               if (xhci->xhc_state & XHCI_STATE_DYING)
-                       goto dying;
-               ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb,
-                               slot_id, ep_index);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-       } else {
-               ret = -EINVAL;
-       }
-exit:
-       return ret;
-dying:
-       xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for "
-                       "non-responsive xHCI host.\n",
-                       urb->ep->desc.bEndpointAddress, urb);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-       return -ESHUTDOWN;
-}
-
-/*
- * Remove the URB's TD from the endpoint ring.  This may cause the HC to stop
- * USB transfers, potentially stopping in the middle of a TRB buffer.  The HC
- * should pick up where it left off in the TD, unless a Set Transfer Ring
- * Dequeue Pointer is issued.
- *
- * The TRBs that make up the buffers for the canceled URB will be "removed" from
- * the ring.  Since the ring is a contiguous structure, they can't be physically
- * removed.  Instead, there are two options:
- *
- *  1) If the HC is in the middle of processing the URB to be canceled, we
- *     simply move the ring's dequeue pointer past those TRBs using the Set
- *     Transfer Ring Dequeue Pointer command.  This will be the common case,
- *     when drivers timeout on the last submitted URB and attempt to cancel.
- *
- *  2) If the HC is in the middle of a different TD, we turn the TRBs into a
- *     series of 1-TRB transfer no-op TDs.  (No-ops shouldn't be chained.)  The
- *     HC will need to invalidate the any TRBs it has cached after the stop
- *     endpoint command, as noted in the xHCI 0.95 errata.
- *
- *  3) The TD may have completed by the time the Stop Endpoint Command
- *     completes, so software needs to handle that case too.
- *
- * This function should protect against the TD enqueueing code ringing the
- * doorbell while this code is waiting for a Stop Endpoint command to complete.
- * It also needs to account for multiple cancellations on happening at the same
- * time for the same endpoint.
- *
- * Note that this function can be called in any context, or so says
- * usb_hcd_unlink_urb()
- */
-int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
-{
-       unsigned long flags;
-       int ret;
-       u32 temp;
-       struct xhci_hcd *xhci;
-       struct xhci_td *td;
-       unsigned int ep_index;
-       struct xhci_ring *ep_ring;
-       struct xhci_virt_ep *ep;
-
-       xhci = hcd_to_xhci(hcd);
-       spin_lock_irqsave(&xhci->lock, flags);
-       /* Make sure the URB hasn't completed or been unlinked already */
-       ret = usb_hcd_check_unlink_urb(hcd, urb, status);
-       if (ret || !urb->hcpriv)
-               goto done;
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
-       if (temp == 0xffffffff) {
-               xhci_dbg(xhci, "HW died, freeing TD.\n");
-               td = (struct xhci_td *) urb->hcpriv;
-
-               usb_hcd_unlink_urb_from_ep(hcd, urb);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, -ESHUTDOWN);
-               kfree(td);
-               return ret;
-       }
-       if (xhci->xhc_state & XHCI_STATE_DYING) {
-               xhci_dbg(xhci, "Ep 0x%x: URB %p to be canceled on "
-                               "non-responsive xHCI host.\n",
-                               urb->ep->desc.bEndpointAddress, urb);
-               /* Let the stop endpoint command watchdog timer (which set this
-                * state) finish cleaning up the endpoint TD lists.  We must
-                * have caught it in the middle of dropping a lock and giving
-                * back an URB.
-                */
-               goto done;
-       }
-
-       xhci_dbg(xhci, "Cancel URB %p\n", urb);
-       xhci_dbg(xhci, "Event ring:\n");
-       xhci_debug_ring(xhci, xhci->event_ring);
-       ep_index = xhci_get_endpoint_index(&urb->ep->desc);
-       ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index];
-       ep_ring = ep->ring;
-       xhci_dbg(xhci, "Endpoint ring:\n");
-       xhci_debug_ring(xhci, ep_ring);
-       td = (struct xhci_td *) urb->hcpriv;
-
-       list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list);
-       /* Queue a stop endpoint command, but only if this is
-        * the first cancellation to be handled.
-        */
-       if (!(ep->ep_state & EP_HALT_PENDING)) {
-               ep->ep_state |= EP_HALT_PENDING;
-               ep->stop_cmds_pending++;
-               ep->stop_cmd_timer.expires = jiffies +
-                       XHCI_STOP_EP_CMD_TIMEOUT * HZ;
-               add_timer(&ep->stop_cmd_timer);
-               xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index);
-               xhci_ring_cmd_db(xhci);
-       }
-done:
-       spin_unlock_irqrestore(&xhci->lock, flags);
-       return ret;
-}
-
-/* Drop an endpoint from a new bandwidth configuration for this device.
- * Only one call to this function is allowed per endpoint before
- * check_bandwidth() or reset_bandwidth() must be called.
- * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
- * add the endpoint to the schedule with possibly new parameters denoted by a
- * different endpoint descriptor in usb_host_endpoint.
- * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
- * not allowed.
- *
- * The USB core will not allow URBs to be queued to an endpoint that is being
- * disabled, so there's no need for mutual exclusion to protect
- * the xhci->devs[slot_id] structure.
- */
-int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
-               struct usb_host_endpoint *ep)
-{
-       struct xhci_hcd *xhci;
-       struct xhci_container_ctx *in_ctx, *out_ctx;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       struct xhci_slot_ctx *slot_ctx;
-       unsigned int last_ctx;
-       unsigned int ep_index;
-       struct xhci_ep_ctx *ep_ctx;
-       u32 drop_flag;
-       u32 new_add_flags, new_drop_flags, new_slot_info;
-       int ret;
-
-       ret = xhci_check_args(hcd, udev, ep, 1, __func__);
-       if (ret <= 0)
-               return ret;
-       xhci = hcd_to_xhci(hcd);
-       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
-
-       drop_flag = xhci_get_endpoint_flag(&ep->desc);
-       if (drop_flag == SLOT_FLAG || drop_flag == EP0_FLAG) {
-               xhci_dbg(xhci, "xHCI %s - can't drop slot or ep 0 %#x\n",
-                               __func__, drop_flag);
-               return 0;
-       }
-
-       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
-               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
-                               __func__);
-               return -EINVAL;
-       }
-
-       in_ctx = xhci->devs[udev->slot_id]->in_ctx;
-       out_ctx = xhci->devs[udev->slot_id]->out_ctx;
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
-       ep_index = xhci_get_endpoint_index(&ep->desc);
-       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
-       /* If the HC already knows the endpoint is disabled,
-        * or the HCD has noted it is disabled, ignore this request
-        */
-       if ((ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED ||
-                       ctrl_ctx->drop_flags & xhci_get_endpoint_flag(&ep->desc)) {
-               xhci_warn(xhci, "xHCI %s called with disabled ep %p\n",
-                               __func__, ep);
-               return 0;
-       }
-
-       ctrl_ctx->drop_flags |= drop_flag;
-       new_drop_flags = ctrl_ctx->drop_flags;
-
-       ctrl_ctx->add_flags &= ~drop_flag;
-       new_add_flags = ctrl_ctx->add_flags;
-
-       last_ctx = xhci_last_valid_endpoint(ctrl_ctx->add_flags);
-       slot_ctx = xhci_get_slot_ctx(xhci, in_ctx);
-       /* Update the last valid endpoint context, if we deleted the last one */
-       if ((slot_ctx->dev_info & LAST_CTX_MASK) > LAST_CTX(last_ctx)) {
-               slot_ctx->dev_info &= ~LAST_CTX_MASK;
-               slot_ctx->dev_info |= LAST_CTX(last_ctx);
-       }
-       new_slot_info = slot_ctx->dev_info;
-
-       xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
-
-       xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
-                       (unsigned int) ep->desc.bEndpointAddress,
-                       udev->slot_id,
-                       (unsigned int) new_drop_flags,
-                       (unsigned int) new_add_flags,
-                       (unsigned int) new_slot_info);
-       return 0;
-}
-
-/* Add an endpoint to a new possible bandwidth configuration for this device.
- * Only one call to this function is allowed per endpoint before
- * check_bandwidth() or reset_bandwidth() must be called.
- * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
- * add the endpoint to the schedule with possibly new parameters denoted by a
- * different endpoint descriptor in usb_host_endpoint.
- * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
- * not allowed.
- *
- * The USB core will not allow URBs to be queued to an endpoint until the
- * configuration or alt setting is installed in the device, so there's no need
- * for mutual exclusion to protect the xhci->devs[slot_id] structure.
- */
-int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
-               struct usb_host_endpoint *ep)
-{
-       struct xhci_hcd *xhci;
-       struct xhci_container_ctx *in_ctx, *out_ctx;
-       unsigned int ep_index;
-       struct xhci_ep_ctx *ep_ctx;
-       struct xhci_slot_ctx *slot_ctx;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       u32 added_ctxs;
-       unsigned int last_ctx;
-       u32 new_add_flags, new_drop_flags, new_slot_info;
-       int ret = 0;
-
-       ret = xhci_check_args(hcd, udev, ep, 1, __func__);
-       if (ret <= 0) {
-               /* So we won't queue a reset ep command for a root hub */
-               ep->hcpriv = NULL;
-               return ret;
-       }
-       xhci = hcd_to_xhci(hcd);
-
-       added_ctxs = xhci_get_endpoint_flag(&ep->desc);
-       last_ctx = xhci_last_valid_endpoint(added_ctxs);
-       if (added_ctxs == SLOT_FLAG || added_ctxs == EP0_FLAG) {
-               /* FIXME when we have to issue an evaluate endpoint command to
-                * deal with ep0 max packet size changing once we get the
-                * descriptors
-                */
-               xhci_dbg(xhci, "xHCI %s - can't add slot or ep 0 %#x\n",
-                               __func__, added_ctxs);
-               return 0;
-       }
-
-       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
-               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
-                               __func__);
-               return -EINVAL;
-       }
-
-       in_ctx = xhci->devs[udev->slot_id]->in_ctx;
-       out_ctx = xhci->devs[udev->slot_id]->out_ctx;
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
-       ep_index = xhci_get_endpoint_index(&ep->desc);
-       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
-       /* If the HCD has already noted the endpoint is enabled,
-        * ignore this request.
-        */
-       if (ctrl_ctx->add_flags & xhci_get_endpoint_flag(&ep->desc)) {
-               xhci_warn(xhci, "xHCI %s called with enabled ep %p\n",
-                               __func__, ep);
-               return 0;
-       }
-
-       /*
-        * Configuration and alternate setting changes must be done in
-        * process context, not interrupt context (or so documenation
-        * for usb_set_interface() and usb_set_configuration() claim).
-        */
-       if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id],
-                               udev, ep, GFP_NOIO) < 0) {
-               dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
-                               __func__, ep->desc.bEndpointAddress);
-               return -ENOMEM;
-       }
-
-       ctrl_ctx->add_flags |= added_ctxs;
-       new_add_flags = ctrl_ctx->add_flags;
-
-       /* If xhci_endpoint_disable() was called for this endpoint, but the
-        * xHC hasn't been notified yet through the check_bandwidth() call,
-        * this re-adds a new state for the endpoint from the new endpoint
-        * descriptors.  We must drop and re-add this endpoint, so we leave the
-        * drop flags alone.
-        */
-       new_drop_flags = ctrl_ctx->drop_flags;
-
-       slot_ctx = xhci_get_slot_ctx(xhci, in_ctx);
-       /* Update the last valid endpoint context, if we just added one past */
-       if ((slot_ctx->dev_info & LAST_CTX_MASK) < LAST_CTX(last_ctx)) {
-               slot_ctx->dev_info &= ~LAST_CTX_MASK;
-               slot_ctx->dev_info |= LAST_CTX(last_ctx);
-       }
-       new_slot_info = slot_ctx->dev_info;
-
-       /* Store the usb_device pointer for later use */
-       ep->hcpriv = udev;
-
-       xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
-                       (unsigned int) ep->desc.bEndpointAddress,
-                       udev->slot_id,
-                       (unsigned int) new_drop_flags,
-                       (unsigned int) new_add_flags,
-                       (unsigned int) new_slot_info);
-       return 0;
-}
-
-static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev)
-{
-       struct xhci_input_control_ctx *ctrl_ctx;
-       struct xhci_ep_ctx *ep_ctx;
-       struct xhci_slot_ctx *slot_ctx;
-       int i;
-
-       /* When a device's add flag and drop flag are zero, any subsequent
-        * configure endpoint command will leave that endpoint's state
-        * untouched.  Make sure we don't leave any old state in the input
-        * endpoint contexts.
-        */
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
-       ctrl_ctx->drop_flags = 0;
-       ctrl_ctx->add_flags = 0;
-       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
-       slot_ctx->dev_info &= ~LAST_CTX_MASK;
-       /* Endpoint 0 is always valid */
-       slot_ctx->dev_info |= LAST_CTX(1);
-       for (i = 1; i < 31; ++i) {
-               ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i);
-               ep_ctx->ep_info = 0;
-               ep_ctx->ep_info2 = 0;
-               ep_ctx->deq = 0;
-               ep_ctx->tx_info = 0;
-       }
-}
-
-static int xhci_configure_endpoint_result(struct xhci_hcd *xhci,
-               struct usb_device *udev, int *cmd_status)
-{
-       int ret;
-
-       switch (*cmd_status) {
-       case COMP_ENOMEM:
-               dev_warn(&udev->dev, "Not enough host controller resources "
-                               "for new device state.\n");
-               ret = -ENOMEM;
-               /* FIXME: can we allocate more resources for the HC? */
-               break;
-       case COMP_BW_ERR:
-               dev_warn(&udev->dev, "Not enough bandwidth "
-                               "for new device state.\n");
-               ret = -ENOSPC;
-               /* FIXME: can we go back to the old state? */
-               break;
-       case COMP_TRB_ERR:
-               /* the HCD set up something wrong */
-               dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, "
-                               "add flag = 1, "
-                               "and endpoint is not disabled.\n");
-               ret = -EINVAL;
-               break;
-       case COMP_SUCCESS:
-               dev_dbg(&udev->dev, "Successful Endpoint Configure command\n");
-               ret = 0;
-               break;
-       default:
-               xhci_err(xhci, "ERROR: unexpected command completion "
-                               "code 0x%x.\n", *cmd_status);
-               ret = -EINVAL;
-               break;
-       }
-       return ret;
-}
-
-static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
-               struct usb_device *udev, int *cmd_status)
-{
-       int ret;
-       struct xhci_virt_device *virt_dev = xhci->devs[udev->slot_id];
-
-       switch (*cmd_status) {
-       case COMP_EINVAL:
-               dev_warn(&udev->dev, "WARN: xHCI driver setup invalid evaluate "
-                               "context command.\n");
-               ret = -EINVAL;
-               break;
-       case COMP_EBADSLT:
-               dev_warn(&udev->dev, "WARN: slot not enabled for"
-                               "evaluate context command.\n");
-       case COMP_CTX_STATE:
-               dev_warn(&udev->dev, "WARN: invalid context state for "
-                               "evaluate context command.\n");
-               xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1);
-               ret = -EINVAL;
-               break;
-       case COMP_SUCCESS:
-               dev_dbg(&udev->dev, "Successful evaluate context command\n");
-               ret = 0;
-               break;
-       default:
-               xhci_err(xhci, "ERROR: unexpected command completion "
-                               "code 0x%x.\n", *cmd_status);
-               ret = -EINVAL;
-               break;
-       }
-       return ret;
-}
-
-/* Issue a configure endpoint command or evaluate context command
- * and wait for it to finish.
- */
-static int xhci_configure_endpoint(struct xhci_hcd *xhci,
-               struct usb_device *udev,
-               struct xhci_command *command,
-               bool ctx_change, bool must_succeed)
-{
-       int ret;
-       int timeleft;
-       unsigned long flags;
-       struct xhci_container_ctx *in_ctx;
-       struct completion *cmd_completion;
-       int *cmd_status;
-       struct xhci_virt_device *virt_dev;
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       virt_dev = xhci->devs[udev->slot_id];
-       if (command) {
-               in_ctx = command->in_ctx;
-               cmd_completion = command->completion;
-               cmd_status = &command->status;
-               command->command_trb = xhci->cmd_ring->enqueue;
-               list_add_tail(&command->cmd_list, &virt_dev->cmd_list);
-       } else {
-               in_ctx = virt_dev->in_ctx;
-               cmd_completion = &virt_dev->cmd_completion;
-               cmd_status = &virt_dev->cmd_status;
-       }
-
-       if (!ctx_change)
-               ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma,
-                               udev->slot_id, must_succeed);
-       else
-               ret = xhci_queue_evaluate_context(xhci, in_ctx->dma,
-                               udev->slot_id);
-       if (ret < 0) {
-               if (command)
-                       list_del(&command->cmd_list);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               xhci_dbg(xhci, "FIXME allocate a new ring segment\n");
-               return -ENOMEM;
-       }
-       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       /* Wait for the configure endpoint command to complete */
-       timeleft = wait_for_completion_interruptible_timeout(
-                       cmd_completion,
-                       USB_CTRL_SET_TIMEOUT);
-       if (timeleft <= 0) {
-               xhci_warn(xhci, "%s while waiting for %s command\n",
-                               timeleft == 0 ? "Timeout" : "Signal",
-                               ctx_change == 0 ?
-                                       "configure endpoint" :
-                                       "evaluate context");
-               /* FIXME cancel the configure endpoint command */
-               return -ETIME;
-       }
-
-       if (!ctx_change)
-               return xhci_configure_endpoint_result(xhci, udev, cmd_status);
-       return xhci_evaluate_context_result(xhci, udev, cmd_status);
-}
-
-/* Called after one or more calls to xhci_add_endpoint() or
- * xhci_drop_endpoint().  If this call fails, the USB core is expected
- * to call xhci_reset_bandwidth().
- *
- * Since we are in the middle of changing either configuration or
- * installing a new alt setting, the USB core won't allow URBs to be
- * enqueued for any endpoint on the old config or interface.  Nothing
- * else should be touching the xhci->devs[slot_id] structure, so we
- * don't need to take the xhci->lock for manipulating that.
- */
-int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       int i;
-       int ret = 0;
-       struct xhci_hcd *xhci;
-       struct xhci_virt_device *virt_dev;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       struct xhci_slot_ctx *slot_ctx;
-
-       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
-       if (ret <= 0)
-               return ret;
-       xhci = hcd_to_xhci(hcd);
-
-       if (!udev->slot_id || !xhci->devs || !xhci->devs[udev->slot_id]) {
-               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
-                               __func__);
-               return -EINVAL;
-       }
-       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
-       virt_dev = xhci->devs[udev->slot_id];
-
-       /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
-       ctrl_ctx->add_flags |= SLOT_FLAG;
-       ctrl_ctx->add_flags &= ~EP0_FLAG;
-       ctrl_ctx->drop_flags &= ~SLOT_FLAG;
-       ctrl_ctx->drop_flags &= ~EP0_FLAG;
-       xhci_dbg(xhci, "New Input Control Context:\n");
-       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
-       xhci_dbg_ctx(xhci, virt_dev->in_ctx,
-                       LAST_CTX_TO_EP_NUM(slot_ctx->dev_info));
-
-       ret = xhci_configure_endpoint(xhci, udev, NULL,
-                       false, false);
-       if (ret) {
-               /* Callee should call reset_bandwidth() */
-               return ret;
-       }
-
-       xhci_dbg(xhci, "Output context after successful config ep cmd:\n");
-       xhci_dbg_ctx(xhci, virt_dev->out_ctx,
-                       LAST_CTX_TO_EP_NUM(slot_ctx->dev_info));
-
-       xhci_zero_in_ctx(xhci, virt_dev);
-       /* Install new rings and free or cache any old rings */
-       for (i = 1; i < 31; ++i) {
-               if (!virt_dev->eps[i].new_ring)
-                       continue;
-               /* Only cache or free the old ring if it exists.
-                * It may not if this is the first add of an endpoint.
-                */
-               if (virt_dev->eps[i].ring) {
-                       xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
-               }
-               virt_dev->eps[i].ring = virt_dev->eps[i].new_ring;
-               virt_dev->eps[i].new_ring = NULL;
-       }
-
-       return ret;
-}
-
-void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       struct xhci_hcd *xhci;
-       struct xhci_virt_device *virt_dev;
-       int i, ret;
-
-       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
-       if (ret <= 0)
-               return;
-       xhci = hcd_to_xhci(hcd);
-
-       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
-               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
-                               __func__);
-               return;
-       }
-       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
-       virt_dev = xhci->devs[udev->slot_id];
-       /* Free any rings allocated for added endpoints */
-       for (i = 0; i < 31; ++i) {
-               if (virt_dev->eps[i].new_ring) {
-                       xhci_ring_free(xhci, virt_dev->eps[i].new_ring);
-                       virt_dev->eps[i].new_ring = NULL;
-               }
-       }
-       xhci_zero_in_ctx(xhci, virt_dev);
-}
-
-static void xhci_setup_input_ctx_for_config_ep(struct xhci_hcd *xhci,
-               struct xhci_container_ctx *in_ctx,
-               struct xhci_container_ctx *out_ctx,
-               u32 add_flags, u32 drop_flags)
-{
-       struct xhci_input_control_ctx *ctrl_ctx;
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
-       ctrl_ctx->add_flags = add_flags;
-       ctrl_ctx->drop_flags = drop_flags;
-       xhci_slot_copy(xhci, in_ctx, out_ctx);
-       ctrl_ctx->add_flags |= SLOT_FLAG;
-
-       xhci_dbg(xhci, "Input Context:\n");
-       xhci_dbg_ctx(xhci, in_ctx, xhci_last_valid_endpoint(add_flags));
-}
-
-void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
-               unsigned int slot_id, unsigned int ep_index,
-               struct xhci_dequeue_state *deq_state)
-{
-       struct xhci_container_ctx *in_ctx;
-       struct xhci_ep_ctx *ep_ctx;
-       u32 added_ctxs;
-       dma_addr_t addr;
-
-       xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx,
-                       xhci->devs[slot_id]->out_ctx, ep_index);
-       in_ctx = xhci->devs[slot_id]->in_ctx;
-       ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
-       addr = xhci_trb_virt_to_dma(deq_state->new_deq_seg,
-                       deq_state->new_deq_ptr);
-       if (addr == 0) {
-               xhci_warn(xhci, "WARN Cannot submit config ep after "
-                               "reset ep command\n");
-               xhci_warn(xhci, "WARN deq seg = %p, deq ptr = %p\n",
-                               deq_state->new_deq_seg,
-                               deq_state->new_deq_ptr);
-               return;
-       }
-       ep_ctx->deq = addr | deq_state->new_cycle_state;
-
-       added_ctxs = xhci_get_endpoint_flag_from_index(ep_index);
-       xhci_setup_input_ctx_for_config_ep(xhci, xhci->devs[slot_id]->in_ctx,
-                       xhci->devs[slot_id]->out_ctx, added_ctxs, added_ctxs);
-}
-
-void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
-               struct usb_device *udev, unsigned int ep_index)
-{
-       struct xhci_dequeue_state deq_state;
-       struct xhci_virt_ep *ep;
-
-       xhci_dbg(xhci, "Cleaning up stalled endpoint ring\n");
-       ep = &xhci->devs[udev->slot_id]->eps[ep_index];
-       /* We need to move the HW's dequeue pointer past this TD,
-        * or it will attempt to resend it on the next doorbell ring.
-        */
-       xhci_find_new_dequeue_state(xhci, udev->slot_id,
-                       ep_index, ep->stopped_td,
-                       &deq_state);
-
-       /* HW with the reset endpoint quirk will use the saved dequeue state to
-        * issue a configure endpoint command later.
-        */
-       if (!(xhci->quirks & XHCI_RESET_EP_QUIRK)) {
-               xhci_dbg(xhci, "Queueing new dequeue state\n");
-               xhci_queue_new_dequeue_state(xhci, udev->slot_id,
-                               ep_index, &deq_state);
-       } else {
-               /* Better hope no one uses the input context between now and the
-                * reset endpoint completion!
-                */
-               xhci_dbg(xhci, "Setting up input context for "
-                               "configure endpoint command\n");
-               xhci_setup_input_ctx_for_quirk(xhci, udev->slot_id,
-                               ep_index, &deq_state);
-       }
-}
-
-/* Deal with stalled endpoints.  The core should have sent the control message
- * to clear the halt condition.  However, we need to make the xHCI hardware
- * reset its sequence number, since a device will expect a sequence number of
- * zero after the halt condition is cleared.
- * Context: in_interrupt
- */
-void xhci_endpoint_reset(struct usb_hcd *hcd,
-               struct usb_host_endpoint *ep)
-{
-       struct xhci_hcd *xhci;
-       struct usb_device *udev;
-       unsigned int ep_index;
-       unsigned long flags;
-       int ret;
-       struct xhci_virt_ep *virt_ep;
-
-       xhci = hcd_to_xhci(hcd);
-       udev = (struct usb_device *) ep->hcpriv;
-       /* Called with a root hub endpoint (or an endpoint that wasn't added
-        * with xhci_add_endpoint()
-        */
-       if (!ep->hcpriv)
-               return;
-       ep_index = xhci_get_endpoint_index(&ep->desc);
-       virt_ep = &xhci->devs[udev->slot_id]->eps[ep_index];
-       if (!virt_ep->stopped_td) {
-               xhci_dbg(xhci, "Endpoint 0x%x not halted, refusing to reset.\n",
-                               ep->desc.bEndpointAddress);
-               return;
-       }
-       if (usb_endpoint_xfer_control(&ep->desc)) {
-               xhci_dbg(xhci, "Control endpoint stall already handled.\n");
-               return;
-       }
-
-       xhci_dbg(xhci, "Queueing reset endpoint command\n");
-       spin_lock_irqsave(&xhci->lock, flags);
-       ret = xhci_queue_reset_ep(xhci, udev->slot_id, ep_index);
-       /*
-        * Can't change the ring dequeue pointer until it's transitioned to the
-        * stopped state, which is only upon a successful reset endpoint
-        * command.  Better hope that last command worked!
-        */
-       if (!ret) {
-               xhci_cleanup_stalled_ring(xhci, udev, ep_index);
-               kfree(virt_ep->stopped_td);
-               xhci_ring_cmd_db(xhci);
-       }
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       if (ret)
-               xhci_warn(xhci, "FIXME allocate a new ring segment\n");
-}
-
-/*
- * This submits a Reset Device Command, which will set the device state to 0,
- * set the device address to 0, and disable all the endpoints except the default
- * control endpoint.  The USB core should come back and call
- * xhci_address_device(), and then re-set up the configuration.  If this is
- * called because of a usb_reset_and_verify_device(), then the old alternate
- * settings will be re-installed through the normal bandwidth allocation
- * functions.
- *
- * Wait for the Reset Device command to finish.  Remove all structures
- * associated with the endpoints that were disabled.  Clear the input device
- * structure?  Cache the rings?  Reset the control endpoint 0 max packet size?
- */
-int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       int ret, i;
-       unsigned long flags;
-       struct xhci_hcd *xhci;
-       unsigned int slot_id;
-       struct xhci_virt_device *virt_dev;
-       struct xhci_command *reset_device_cmd;
-       int timeleft;
-       int last_freed_endpoint;
-
-       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
-       if (ret <= 0)
-               return ret;
-       xhci = hcd_to_xhci(hcd);
-       slot_id = udev->slot_id;
-       virt_dev = xhci->devs[slot_id];
-       if (!virt_dev) {
-               xhci_dbg(xhci, "%s called with invalid slot ID %u\n",
-                               __func__, slot_id);
-               return -EINVAL;
-       }
-
-       xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id);
-       /* Allocate the command structure that holds the struct completion.
-        * Assume we're in process context, since the normal device reset
-        * process has to wait for the device anyway.  Storage devices are
-        * reset as part of error handling, so use GFP_NOIO instead of
-        * GFP_KERNEL.
-        */
-       reset_device_cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
-       if (!reset_device_cmd) {
-               xhci_dbg(xhci, "Couldn't allocate command structure.\n");
-               return -ENOMEM;
-       }
-
-       /* Attempt to submit the Reset Device command to the command ring */
-       spin_lock_irqsave(&xhci->lock, flags);
-       reset_device_cmd->command_trb = xhci->cmd_ring->enqueue;
-       list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list);
-       ret = xhci_queue_reset_device(xhci, slot_id);
-       if (ret) {
-               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
-               list_del(&reset_device_cmd->cmd_list);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               goto command_cleanup;
-       }
-       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       /* Wait for the Reset Device command to finish */
-       timeleft = wait_for_completion_interruptible_timeout(
-                       reset_device_cmd->completion,
-                       USB_CTRL_SET_TIMEOUT);
-       if (timeleft <= 0) {
-               xhci_warn(xhci, "%s while waiting for reset device command\n",
-                               timeleft == 0 ? "Timeout" : "Signal");
-               spin_lock_irqsave(&xhci->lock, flags);
-               /* The timeout might have raced with the event ring handler, so
-                * only delete from the list if the item isn't poisoned.
-                */
-               if (reset_device_cmd->cmd_list.next != LIST_POISON1)
-                       list_del(&reset_device_cmd->cmd_list);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               ret = -ETIME;
-               goto command_cleanup;
-       }
-
-       /* The Reset Device command can't fail, according to the 0.95/0.96 spec,
-        * unless we tried to reset a slot ID that wasn't enabled,
-        * or the device wasn't in the addressed or configured state.
-        */
-       ret = reset_device_cmd->status;
-       switch (ret) {
-       case COMP_EBADSLT: /* 0.95 completion code for bad slot ID */
-       case COMP_CTX_STATE: /* 0.96 completion code for same thing */
-               xhci_info(xhci, "Can't reset device (slot ID %u) in %s state\n",
-                               slot_id,
-                               xhci_get_slot_state(xhci, virt_dev->out_ctx));
-               xhci_info(xhci, "Not freeing device rings.\n");
-               /* Don't treat this as an error.  May change my mind later. */
-               ret = 0;
-               goto command_cleanup;
-       case COMP_SUCCESS:
-               xhci_dbg(xhci, "Successful reset device command.\n");
-               break;
-       default:
-               if (xhci_is_vendor_info_code(xhci, ret))
-                       break;
-               xhci_warn(xhci, "Unknown completion code %u for "
-                               "reset device command.\n", ret);
-               ret = -EINVAL;
-               goto command_cleanup;
-       }
-
-       /* Everything but endpoint 0 is disabled, so free or cache the rings. */
-       last_freed_endpoint = 1;
-       for (i = 1; i < 31; ++i) {
-               if (!virt_dev->eps[i].ring)
-                       continue;
-               xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
-               last_freed_endpoint = i;
-       }
-       xhci_dbg(xhci, "Output context after successful reset device cmd:\n");
-       xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint);
-       ret = 0;
-
-command_cleanup:
-       xhci_free_command(xhci, reset_device_cmd);
-       return ret;
-}
-
-/*
- * At this point, the struct usb_device is about to go away, the device has
- * disconnected, and all traffic has been stopped and the endpoints have been
- * disabled.  Free any HC data structures associated with that device.
- */
-void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       struct xhci_virt_device *virt_dev;
-       unsigned long flags;
-       u32 state;
-       int i;
-
-       if (udev->slot_id == 0)
-               return;
-       virt_dev = xhci->devs[udev->slot_id];
-       if (!virt_dev)
-               return;
-
-       /* Stop any wayward timer functions (which may grab the lock) */
-       for (i = 0; i < 31; ++i) {
-               virt_dev->eps[i].ep_state &= ~EP_HALT_PENDING;
-               del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
-       }
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       /* Don't disable the slot if the host controller is dead. */
-       state = xhci_readl(xhci, &xhci->op_regs->status);
-       if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
-               xhci_free_virt_device(xhci, udev->slot_id);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               return;
-       }
-
-       if (xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id)) {
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
-               return;
-       }
-       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-       /*
-        * Event command completion handler will free any data structures
-        * associated with the slot.  XXX Can free sleep?
-        */
-}
-
-/*
- * Returns 0 if the xHC ran out of device slots, the Enable Slot command
- * timed out, or allocating memory failed.  Returns 1 on success.
- */
-int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       unsigned long flags;
-       int timeleft;
-       int ret;
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0);
-       if (ret) {
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
-               return 0;
-       }
-       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       /* XXX: how much time for xHC slot assignment? */
-       timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
-                       USB_CTRL_SET_TIMEOUT);
-       if (timeleft <= 0) {
-               xhci_warn(xhci, "%s while waiting for a slot\n",
-                               timeleft == 0 ? "Timeout" : "Signal");
-               /* FIXME cancel the enable slot request */
-               return 0;
-       }
-
-       if (!xhci->slot_id) {
-               xhci_err(xhci, "Error while assigning device slot ID\n");
-               return 0;
-       }
-       /* xhci_alloc_virt_device() does not touch rings; no need to lock */
-       if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) {
-               /* Disable slot, if we can do it without mem alloc */
-               xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
-               spin_lock_irqsave(&xhci->lock, flags);
-               if (!xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id))
-                       xhci_ring_cmd_db(xhci);
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               return 0;
-       }
-       udev->slot_id = xhci->slot_id;
-       /* Is this a LS or FS device under a HS hub? */
-       /* Hub or peripherial? */
-       return 1;
-}
-
-/*
- * Issue an Address Device command (which will issue a SetAddress request to
- * the device).
- * We should be protected by the usb_address0_mutex in khubd's hub_port_init, so
- * we should only issue and wait on one address command at the same time.
- *
- * We add one to the device address issued by the hardware because the USB core
- * uses address 1 for the root hubs (even though they're not really devices).
- */
-int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
-{
-       unsigned long flags;
-       int timeleft;
-       struct xhci_virt_device *virt_dev;
-       int ret = 0;
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       struct xhci_slot_ctx *slot_ctx;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       u64 temp_64;
-
-       if (!udev->slot_id) {
-               xhci_dbg(xhci, "Bad Slot ID %d\n", udev->slot_id);
-               return -EINVAL;
-       }
-
-       virt_dev = xhci->devs[udev->slot_id];
-
-       /* If this is a Set Address to an unconfigured device, setup ep 0 */
-       if (!udev->config)
-               xhci_setup_addressable_virt_dev(xhci, udev);
-       /* Otherwise, assume the core has the device configured how it wants */
-       xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
-       xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma,
-                                       udev->slot_id);
-       if (ret) {
-               spin_unlock_irqrestore(&xhci->lock, flags);
-               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
-               return ret;
-       }
-       xhci_ring_cmd_db(xhci);
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       /* ctrl tx can take up to 5 sec; XXX: need more time for xHC? */
-       timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
-                       USB_CTRL_SET_TIMEOUT);
-       /* FIXME: From section 4.3.4: "Software shall be responsible for timing
-        * the SetAddress() "recovery interval" required by USB and aborting the
-        * command on a timeout.
-        */
-       if (timeleft <= 0) {
-               xhci_warn(xhci, "%s while waiting for a slot\n",
-                               timeleft == 0 ? "Timeout" : "Signal");
-               /* FIXME cancel the address device command */
-               return -ETIME;
-       }
-
-       switch (virt_dev->cmd_status) {
-       case COMP_CTX_STATE:
-       case COMP_EBADSLT:
-               xhci_err(xhci, "Setup ERROR: address device command for slot %d.\n",
-                               udev->slot_id);
-               ret = -EINVAL;
-               break;
-       case COMP_TX_ERR:
-               dev_warn(&udev->dev, "Device not responding to set address.\n");
-               ret = -EPROTO;
-               break;
-       case COMP_SUCCESS:
-               xhci_dbg(xhci, "Successful Address Device command\n");
-               break;
-       default:
-               xhci_err(xhci, "ERROR: unexpected command completion "
-                               "code 0x%x.\n", virt_dev->cmd_status);
-               xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
-               xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
-               ret = -EINVAL;
-               break;
-       }
-       if (ret) {
-               return ret;
-       }
-       temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
-       xhci_dbg(xhci, "Op regs DCBAA ptr = %#016llx\n", temp_64);
-       xhci_dbg(xhci, "Slot ID %d dcbaa entry @%p = %#016llx\n",
-                       udev->slot_id,
-                       &xhci->dcbaa->dev_context_ptrs[udev->slot_id],
-                       (unsigned long long)
-                               xhci->dcbaa->dev_context_ptrs[udev->slot_id]);
-       xhci_dbg(xhci, "Output Context DMA address = %#08llx\n",
-                       (unsigned long long)virt_dev->out_ctx->dma);
-       xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
-       xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
-       xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
-       xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
-       /*
-        * USB core uses address 1 for the roothubs, so we add one to the
-        * address given back to us by the HC.
-        */
-       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
-       udev->devnum = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1;
-       /* Zero the input context control for later use */
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
-       ctrl_ctx->add_flags = 0;
-       ctrl_ctx->drop_flags = 0;
-
-       xhci_dbg(xhci, "Device address = %d\n", udev->devnum);
-       /* XXX Meh, not sure if anyone else but choose_address uses this. */
-       set_bit(udev->devnum, udev->bus->devmap.devicemap);
-
-       return 0;
-}
-
-/* Once a hub descriptor is fetched for a device, we need to update the xHC's
- * internal data structures for the device.
- */
-int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
-                       struct usb_tt *tt, gfp_t mem_flags)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       struct xhci_virt_device *vdev;
-       struct xhci_command *config_cmd;
-       struct xhci_input_control_ctx *ctrl_ctx;
-       struct xhci_slot_ctx *slot_ctx;
-       unsigned long flags;
-       unsigned think_time;
-       int ret;
-
-       /* Ignore root hubs */
-       if (!hdev->parent)
-               return 0;
-
-       vdev = xhci->devs[hdev->slot_id];
-       if (!vdev) {
-               xhci_warn(xhci, "Cannot update hub desc for unknown device.\n");
-               return -EINVAL;
-       }
-       config_cmd = xhci_alloc_command(xhci, true, true, mem_flags);
-       if (!config_cmd) {
-               xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
-               return -ENOMEM;
-       }
-
-       spin_lock_irqsave(&xhci->lock, flags);
-       xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx);
-       ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx);
-       ctrl_ctx->add_flags |= SLOT_FLAG;
-       slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx);
-       slot_ctx->dev_info |= DEV_HUB;
-       if (tt->multi)
-               slot_ctx->dev_info |= DEV_MTT;
-       if (xhci->hci_version > 0x95) {
-               xhci_dbg(xhci, "xHCI version %x needs hub "
-                               "TT think time and number of ports\n",
-                               (unsigned int) xhci->hci_version);
-               slot_ctx->dev_info2 |= XHCI_MAX_PORTS(hdev->maxchild);
-               /* Set TT think time - convert from ns to FS bit times.
-                * 0 = 8 FS bit times, 1 = 16 FS bit times,
-                * 2 = 24 FS bit times, 3 = 32 FS bit times.
-                */
-               think_time = tt->think_time;
-               if (think_time != 0)
-                       think_time = (think_time / 666) - 1;
-               slot_ctx->tt_info |= TT_THINK_TIME(think_time);
-       } else {
-               xhci_dbg(xhci, "xHCI version %x doesn't need hub "
-                               "TT think time or number of ports\n",
-                               (unsigned int) xhci->hci_version);
-       }
-       slot_ctx->dev_state = 0;
-       spin_unlock_irqrestore(&xhci->lock, flags);
-
-       xhci_dbg(xhci, "Set up %s for hub device.\n",
-                       (xhci->hci_version > 0x95) ?
-                       "configure endpoint" : "evaluate context");
-       xhci_dbg(xhci, "Slot %u Input Context:\n", hdev->slot_id);
-       xhci_dbg_ctx(xhci, config_cmd->in_ctx, 0);
-
-       /* Issue and wait for the configure endpoint or
-        * evaluate context command.
-        */
-       if (xhci->hci_version > 0x95)
-               ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
-                               false, false);
-       else
-               ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
-                               true, false);
-
-       xhci_dbg(xhci, "Slot %u Output Context:\n", hdev->slot_id);
-       xhci_dbg_ctx(xhci, vdev->out_ctx, 0);
-
-       xhci_free_command(xhci, config_cmd);
-       return ret;
-}
-
-int xhci_get_frame(struct usb_hcd *hcd)
-{
-       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       /* EHCI mods by the periodic size.  Why? */
-       return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3;
-}
-
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_LICENSE("GPL");
-
-static int __init xhci_hcd_init(void)
-{
-#ifdef CONFIG_PCI
-       int retval = 0;
-
-       retval = xhci_register_pci();
-
-       if (retval < 0) {
-               printk(KERN_DEBUG "Problem registering PCI driver.");
-               return retval;
-       }
-#endif
-       /*
-        * Check the compiler generated sizes of structures that must be laid
-        * out in specific ways for hardware access.
-        */
-       BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_slot_ctx) != 8*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_ep_ctx) != 8*32/8);
-       /* xhci_device_control has eight fields, and also
-        * embeds one xhci_slot_ctx and 31 xhci_ep_ctx
-        */
-       BUILD_BUG_ON(sizeof(struct xhci_stream_ctx) != 4*32/8);
-       BUILD_BUG_ON(sizeof(union xhci_trb) != 4*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_erst_entry) != 4*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_cap_regs) != 7*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
-       /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
-       BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
-       BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8);
-       return 0;
-}
-module_init(xhci_hcd_init);
-
-static void __exit xhci_hcd_cleanup(void)
-{
-#ifdef CONFIG_PCI
-       xhci_unregister_pci();
-#endif
-}
-module_exit(xhci_hcd_cleanup);
index 49f7d72f8b1b0e5e936077024b3f9720d15178e0..c09539bad1ee0ab15c5ad3def5fed46ef68c117f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/usb.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/dmapool.h>
 
 #include "xhci.h"
@@ -566,8 +567,13 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
                        if (interval < 3)
                                interval = 3;
                        if ((1 << interval) != 8*ep->desc.bInterval)
-                               dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n",
-                                               ep->desc.bEndpointAddress, 1 << interval);
+                               dev_warn(&udev->dev,
+                                               "ep %#x - rounding interval"
+                                               " to %d microframes, "
+                                               "ep desc says %d microframes\n",
+                                               ep->desc.bEndpointAddress,
+                                               1 << interval,
+                                               8*ep->desc.bInterval);
                }
                break;
        default:
index 6ba841bca4a28f24db9a76f6808f87e08c599194..85d7e8f2085e70481cb0cdcf4207f15efa1ba886 100644 (file)
@@ -65,6 +65,7 @@
  */
 
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include "xhci.h"
 
 /*
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
new file mode 100644 (file)
index 0000000..7e42772
--- /dev/null
@@ -0,0 +1,1918 @@
+/*
+ * xHCI host controller driver
+ *
+ * Copyright (C) 2008 Intel Corp.
+ *
+ * Author: Sarah Sharp
+ * Some code borrowed from the Linux EHCI driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/slab.h>
+
+#include "xhci.h"
+
+#define DRIVER_AUTHOR "Sarah Sharp"
+#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
+
+/* Some 0.95 hardware can't handle the chain bit on a Link TRB being cleared */
+static int link_quirk;
+module_param(link_quirk, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB");
+
+/* TODO: copied from ehci-hcd.c - can this be refactored? */
+/*
+ * handshake - spin reading hc until handshake completes or fails
+ * @ptr: address of hc register to be read
+ * @mask: bits to look at in result of read
+ * @done: value of those bits when handshake succeeds
+ * @usec: timeout in microseconds
+ *
+ * Returns negative errno, or zero on success
+ *
+ * Success happens when the "mask" bits have the specified value (hardware
+ * handshake done).  There are two failure modes:  "usec" have passed (major
+ * hardware flakeout), or the register reads as all-ones (hardware removed).
+ */
+static int handshake(struct xhci_hcd *xhci, void __iomem *ptr,
+                     u32 mask, u32 done, int usec)
+{
+       u32     result;
+
+       do {
+               result = xhci_readl(xhci, ptr);
+               if (result == ~(u32)0)          /* card removed */
+                       return -ENODEV;
+               result &= mask;
+               if (result == done)
+                       return 0;
+               udelay(1);
+               usec--;
+       } while (usec > 0);
+       return -ETIMEDOUT;
+}
+
+/*
+ * Disable interrupts and begin the xHCI halting process.
+ */
+void xhci_quiesce(struct xhci_hcd *xhci)
+{
+       u32 halted;
+       u32 cmd;
+       u32 mask;
+
+       mask = ~(XHCI_IRQS);
+       halted = xhci_readl(xhci, &xhci->op_regs->status) & STS_HALT;
+       if (!halted)
+               mask &= ~CMD_RUN;
+
+       cmd = xhci_readl(xhci, &xhci->op_regs->command);
+       cmd &= mask;
+       xhci_writel(xhci, cmd, &xhci->op_regs->command);
+}
+
+/*
+ * Force HC into halt state.
+ *
+ * Disable any IRQs and clear the run/stop bit.
+ * HC will complete any current and actively pipelined transactions, and
+ * should halt within 16 microframes of the run/stop bit being cleared.
+ * Read HC Halted bit in the status register to see when the HC is finished.
+ * XXX: shouldn't we set HC_STATE_HALT here somewhere?
+ */
+int xhci_halt(struct xhci_hcd *xhci)
+{
+       xhci_dbg(xhci, "// Halt the HC\n");
+       xhci_quiesce(xhci);
+
+       return handshake(xhci, &xhci->op_regs->status,
+                       STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
+}
+
+/*
+ * Reset a halted HC, and set the internal HC state to HC_STATE_HALT.
+ *
+ * This resets pipelines, timers, counters, state machines, etc.
+ * Transactions will be terminated immediately, and operational registers
+ * will be set to their defaults.
+ */
+int xhci_reset(struct xhci_hcd *xhci)
+{
+       u32 command;
+       u32 state;
+
+       state = xhci_readl(xhci, &xhci->op_regs->status);
+       if ((state & STS_HALT) == 0) {
+               xhci_warn(xhci, "Host controller not halted, aborting reset.\n");
+               return 0;
+       }
+
+       xhci_dbg(xhci, "// Reset the HC\n");
+       command = xhci_readl(xhci, &xhci->op_regs->command);
+       command |= CMD_RESET;
+       xhci_writel(xhci, command, &xhci->op_regs->command);
+       /* XXX: Why does EHCI set this here?  Shouldn't other code do this? */
+       xhci_to_hcd(xhci)->state = HC_STATE_HALT;
+
+       return handshake(xhci, &xhci->op_regs->command, CMD_RESET, 0, 250 * 1000);
+}
+
+
+#if 0
+/* Set up MSI-X table for entry 0 (may claim other entries later) */
+static int xhci_setup_msix(struct xhci_hcd *xhci)
+{
+       int ret;
+       struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
+
+       xhci->msix_count = 0;
+       /* XXX: did I do this right?  ixgbe does kcalloc for more than one */
+       xhci->msix_entries = kmalloc(sizeof(struct msix_entry), GFP_KERNEL);
+       if (!xhci->msix_entries) {
+               xhci_err(xhci, "Failed to allocate MSI-X entries\n");
+               return -ENOMEM;
+       }
+       xhci->msix_entries[0].entry = 0;
+
+       ret = pci_enable_msix(pdev, xhci->msix_entries, xhci->msix_count);
+       if (ret) {
+               xhci_err(xhci, "Failed to enable MSI-X\n");
+               goto free_entries;
+       }
+
+       /*
+        * Pass the xhci pointer value as the request_irq "cookie".
+        * If more irqs are added, this will need to be unique for each one.
+        */
+       ret = request_irq(xhci->msix_entries[0].vector, &xhci_irq, 0,
+                       "xHCI", xhci_to_hcd(xhci));
+       if (ret) {
+               xhci_err(xhci, "Failed to allocate MSI-X interrupt\n");
+               goto disable_msix;
+       }
+       xhci_dbg(xhci, "Finished setting up MSI-X\n");
+       return 0;
+
+disable_msix:
+       pci_disable_msix(pdev);
+free_entries:
+       kfree(xhci->msix_entries);
+       xhci->msix_entries = NULL;
+       return ret;
+}
+
+/* XXX: code duplication; can xhci_setup_msix call this? */
+/* Free any IRQs and disable MSI-X */
+static void xhci_cleanup_msix(struct xhci_hcd *xhci)
+{
+       struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
+       if (!xhci->msix_entries)
+               return;
+
+       free_irq(xhci->msix_entries[0].vector, xhci);
+       pci_disable_msix(pdev);
+       kfree(xhci->msix_entries);
+       xhci->msix_entries = NULL;
+       xhci_dbg(xhci, "Finished cleaning up MSI-X\n");
+}
+#endif
+
+/*
+ * Initialize memory for HCD and xHC (one-time init).
+ *
+ * Program the PAGESIZE register, initialize the device context array, create
+ * device contexts (?), set up a command ring segment (or two?), create event
+ * ring (one for now).
+ */
+int xhci_init(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       int retval = 0;
+
+       xhci_dbg(xhci, "xhci_init\n");
+       spin_lock_init(&xhci->lock);
+       if (link_quirk) {
+               xhci_dbg(xhci, "QUIRK: Not clearing Link TRB chain bits.\n");
+               xhci->quirks |= XHCI_LINK_TRB_QUIRK;
+       } else {
+               xhci_dbg(xhci, "xHCI doesn't need link TRB QUIRK\n");
+       }
+       retval = xhci_mem_init(xhci, GFP_KERNEL);
+       xhci_dbg(xhci, "Finished xhci_init\n");
+
+       return retval;
+}
+
+/*
+ * Called in interrupt context when there might be work
+ * queued on the event ring
+ *
+ * xhci->lock must be held by caller.
+ */
+static void xhci_work(struct xhci_hcd *xhci)
+{
+       u32 temp;
+       u64 temp_64;
+
+       /*
+        * Clear the op reg interrupt status first,
+        * so we can receive interrupts from other MSI-X interrupters.
+        * Write 1 to clear the interrupt status.
+        */
+       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       temp |= STS_EINT;
+       xhci_writel(xhci, temp, &xhci->op_regs->status);
+       /* FIXME when MSI-X is supported and there are multiple vectors */
+       /* Clear the MSI-X event interrupt status */
+
+       /* Acknowledge the interrupt */
+       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       temp |= 0x3;
+       xhci_writel(xhci, temp, &xhci->ir_set->irq_pending);
+       /* Flush posted writes */
+       xhci_readl(xhci, &xhci->ir_set->irq_pending);
+
+       if (xhci->xhc_state & XHCI_STATE_DYING)
+               xhci_dbg(xhci, "xHCI dying, ignoring interrupt. "
+                               "Shouldn't IRQs be disabled?\n");
+       else
+               /* FIXME this should be a delayed service routine
+                * that clears the EHB.
+                */
+               xhci_handle_event(xhci);
+
+       /* Clear the event handler busy flag (RW1C); the event ring should be empty. */
+       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
+       xhci_write_64(xhci, temp_64 | ERST_EHB, &xhci->ir_set->erst_dequeue);
+       /* Flush posted writes -- FIXME is this necessary? */
+       xhci_readl(xhci, &xhci->ir_set->irq_pending);
+}
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * xHCI spec says we can get an interrupt, and if the HC has an error condition,
+ * we might get bad data out of the event ring.  Section 4.10.2.7 has a list of
+ * indicators of an event TRB error, but we check the status *first* to be safe.
+ */
+irqreturn_t xhci_irq(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       u32 temp, temp2;
+       union xhci_trb *trb;
+
+       spin_lock(&xhci->lock);
+       trb = xhci->event_ring->dequeue;
+       /* Check if the xHC generated the interrupt, or the irq is shared */
+       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       temp2 = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       if (temp == 0xffffffff && temp2 == 0xffffffff)
+               goto hw_died;
+
+       if (!(temp & STS_EINT) && !ER_IRQ_PENDING(temp2)) {
+               spin_unlock(&xhci->lock);
+               return IRQ_NONE;
+       }
+       xhci_dbg(xhci, "op reg status = %08x\n", temp);
+       xhci_dbg(xhci, "ir set irq_pending = %08x\n", temp2);
+       xhci_dbg(xhci, "Event ring dequeue ptr:\n");
+       xhci_dbg(xhci, "@%llx %08x %08x %08x %08x\n",
+                       (unsigned long long)xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, trb),
+                       lower_32_bits(trb->link.segment_ptr),
+                       upper_32_bits(trb->link.segment_ptr),
+                       (unsigned int) trb->link.intr_target,
+                       (unsigned int) trb->link.control);
+
+       if (temp & STS_FATAL) {
+               xhci_warn(xhci, "WARNING: Host System Error\n");
+               xhci_halt(xhci);
+hw_died:
+               xhci_to_hcd(xhci)->state = HC_STATE_HALT;
+               spin_unlock(&xhci->lock);
+               return -ESHUTDOWN;
+       }
+
+       xhci_work(xhci);
+       spin_unlock(&xhci->lock);
+
+       return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+void xhci_event_ring_work(unsigned long arg)
+{
+       unsigned long flags;
+       int temp;
+       u64 temp_64;
+       struct xhci_hcd *xhci = (struct xhci_hcd *) arg;
+       int i, j;
+
+       xhci_dbg(xhci, "Poll event ring: %lu\n", jiffies);
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       xhci_dbg(xhci, "op reg status = 0x%x\n", temp);
+       if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
+               xhci_dbg(xhci, "HW died, polling stopped.\n");
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               return;
+       }
+
+       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       xhci_dbg(xhci, "ir_set 0 pending = 0x%x\n", temp);
+       xhci_dbg(xhci, "No-op commands handled = %d\n", xhci->noops_handled);
+       xhci_dbg(xhci, "HC error bitmask = 0x%x\n", xhci->error_bitmask);
+       xhci->error_bitmask = 0;
+       xhci_dbg(xhci, "Event ring:\n");
+       xhci_debug_segment(xhci, xhci->event_ring->deq_seg);
+       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
+       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
+       temp_64 &= ~ERST_PTR_MASK;
+       xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
+       xhci_dbg(xhci, "Command ring:\n");
+       xhci_debug_segment(xhci, xhci->cmd_ring->deq_seg);
+       xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
+       xhci_dbg_cmd_ptrs(xhci);
+       for (i = 0; i < MAX_HC_SLOTS; ++i) {
+               if (!xhci->devs[i])
+                       continue;
+               for (j = 0; j < 31; ++j) {
+                       struct xhci_ring *ring = xhci->devs[i]->eps[j].ring;
+                       if (!ring)
+                               continue;
+                       xhci_dbg(xhci, "Dev %d endpoint ring %d:\n", i, j);
+                       xhci_debug_segment(xhci, ring->deq_seg);
+               }
+       }
+
+       if (xhci->noops_submitted != NUM_TEST_NOOPS)
+               if (xhci_setup_one_noop(xhci))
+                       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       if (!xhci->zombie)
+               mod_timer(&xhci->event_ring_timer, jiffies + POLL_TIMEOUT * HZ);
+       else
+               xhci_dbg(xhci, "Quit polling the event ring.\n");
+}
+#endif
+
+/*
+ * Start the HC after it was halted.
+ *
+ * This function is called by the USB core when the HC driver is added.
+ * Its opposite is xhci_stop().
+ *
+ * xhci_init() must be called once before this function can be called.
+ * Reset the HC, enable device slot contexts, program DCBAAP, and
+ * set command ring pointer and event ring pointer.
+ *
+ * Setup MSI-X vectors and enable interrupts.
+ */
+int xhci_run(struct usb_hcd *hcd)
+{
+       u32 temp;
+       u64 temp_64;
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       void (*doorbell)(struct xhci_hcd *) = NULL;
+
+       hcd->uses_new_polling = 1;
+       hcd->poll_rh = 0;
+
+       xhci_dbg(xhci, "xhci_run\n");
+#if 0  /* FIXME: MSI not setup yet */
+       /* Do this at the very last minute */
+       ret = xhci_setup_msix(xhci);
+       if (!ret)
+               return ret;
+
+       return -ENOSYS;
+#endif
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+       init_timer(&xhci->event_ring_timer);
+       xhci->event_ring_timer.data = (unsigned long) xhci;
+       xhci->event_ring_timer.function = xhci_event_ring_work;
+       /* Poll the event ring */
+       xhci->event_ring_timer.expires = jiffies + POLL_TIMEOUT * HZ;
+       xhci->zombie = 0;
+       xhci_dbg(xhci, "Setting event ring polling timer\n");
+       add_timer(&xhci->event_ring_timer);
+#endif
+
+       xhci_dbg(xhci, "Command ring memory map follows:\n");
+       xhci_debug_ring(xhci, xhci->cmd_ring);
+       xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
+       xhci_dbg_cmd_ptrs(xhci);
+
+       xhci_dbg(xhci, "ERST memory map follows:\n");
+       xhci_dbg_erst(xhci, &xhci->erst);
+       xhci_dbg(xhci, "Event ring:\n");
+       xhci_debug_ring(xhci, xhci->event_ring);
+       xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
+       temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
+       temp_64 &= ~ERST_PTR_MASK;
+       xhci_dbg(xhci, "ERST deq = 64'h%0lx\n", (long unsigned int) temp_64);
+
+       xhci_dbg(xhci, "// Set the interrupt modulation register\n");
+       temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
+       temp &= ~ER_IRQ_INTERVAL_MASK;
+       temp |= (u32) 160;
+       xhci_writel(xhci, temp, &xhci->ir_set->irq_control);
+
+       /* Set the HCD state before we enable the irqs */
+       hcd->state = HC_STATE_RUNNING;
+       temp = xhci_readl(xhci, &xhci->op_regs->command);
+       temp |= (CMD_EIE);
+       xhci_dbg(xhci, "// Enable interrupts, cmd = 0x%x.\n",
+                       temp);
+       xhci_writel(xhci, temp, &xhci->op_regs->command);
+
+       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       xhci_dbg(xhci, "// Enabling event ring interrupter %p by writing 0x%x to irq_pending\n",
+                       xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
+       xhci_writel(xhci, ER_IRQ_ENABLE(temp),
+                       &xhci->ir_set->irq_pending);
+       xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+       if (NUM_TEST_NOOPS > 0)
+               doorbell = xhci_setup_one_noop(xhci);
+
+       temp = xhci_readl(xhci, &xhci->op_regs->command);
+       temp |= (CMD_RUN);
+       xhci_dbg(xhci, "// Turn on HC, cmd = 0x%x.\n",
+                       temp);
+       xhci_writel(xhci, temp, &xhci->op_regs->command);
+       /* Flush PCI posted writes */
+       temp = xhci_readl(xhci, &xhci->op_regs->command);
+       xhci_dbg(xhci, "// @%p = 0x%x\n", &xhci->op_regs->command, temp);
+       if (doorbell)
+               (*doorbell)(xhci);
+
+       xhci_dbg(xhci, "Finished xhci_run\n");
+       return 0;
+}
+
+/*
+ * Stop xHCI driver.
+ *
+ * This function is called by the USB core when the HC driver is removed.
+ * Its opposite is xhci_run().
+ *
+ * Disable device contexts, disable IRQs, and quiesce the HC.
+ * Reset the HC, finish any completed transactions, and cleanup memory.
+ */
+void xhci_stop(struct usb_hcd *hcd)
+{
+       u32 temp;
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+       spin_lock_irq(&xhci->lock);
+       xhci_halt(xhci);
+       xhci_reset(xhci);
+       spin_unlock_irq(&xhci->lock);
+
+#if 0  /* No MSI yet */
+       xhci_cleanup_msix(xhci);
+#endif
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+       /* Tell the event ring poll function not to reschedule */
+       xhci->zombie = 1;
+       del_timer_sync(&xhci->event_ring_timer);
+#endif
+
+       xhci_dbg(xhci, "// Disabling event ring interrupts\n");
+       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
+       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       xhci_writel(xhci, ER_IRQ_DISABLE(temp),
+                       &xhci->ir_set->irq_pending);
+       xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+       xhci_dbg(xhci, "cleaning up memory\n");
+       xhci_mem_cleanup(xhci);
+       xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
+                   xhci_readl(xhci, &xhci->op_regs->status));
+}
+
+/*
+ * Shutdown HC (not bus-specific)
+ *
+ * This is called when the machine is rebooting or halting.  We assume that the
+ * machine will be powered off, and the HC's internal state will be reset.
+ * Don't bother to free memory.
+ */
+void xhci_shutdown(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+       spin_lock_irq(&xhci->lock);
+       xhci_halt(xhci);
+       spin_unlock_irq(&xhci->lock);
+
+#if 0
+       xhci_cleanup_msix(xhci);
+#endif
+
+       xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
+                   xhci_readl(xhci, &xhci->op_regs->status));
+}
+
+/*-------------------------------------------------------------------------*/
+
+/**
+ * xhci_get_endpoint_index - Used for passing endpoint bitmasks between the core and
+ * HCDs.  Find the index for an endpoint given its descriptor.  Use the return
+ * value to right shift 1 for the bitmask.
+ *
+ * Index  = (epnum * 2) + direction - 1,
+ * where direction = 0 for OUT, 1 for IN.
+ * For control endpoints, the IN index is used (OUT index is unused), so
+ * index = (epnum * 2) + direction - 1 = (epnum * 2) + 1 - 1 = (epnum * 2)
+ */
+unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc)
+{
+       unsigned int index;
+       if (usb_endpoint_xfer_control(desc))
+               index = (unsigned int) (usb_endpoint_num(desc)*2);
+       else
+               index = (unsigned int) (usb_endpoint_num(desc)*2) +
+                       (usb_endpoint_dir_in(desc) ? 1 : 0) - 1;
+       return index;
+}
+
+/* Find the flag for this endpoint (for use in the control context).  Use the
+ * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
+ * bit 1, etc.
+ */
+unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc)
+{
+       return 1 << (xhci_get_endpoint_index(desc) + 1);
+}
+
+/* Find the flag for this endpoint (for use in the control context).  Use the
+ * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
+ * bit 1, etc.
+ */
+unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index)
+{
+       return 1 << (ep_index + 1);
+}
+
+/* Compute the last valid endpoint context index.  Basically, this is the
+ * endpoint index plus one.  For slot contexts with more than valid endpoint,
+ * we find the most significant bit set in the added contexts flags.
+ * e.g. ep 1 IN (with epnum 0x81) => added_ctxs = 0b1000
+ * fls(0b1000) = 4, but the endpoint context index is 3, so subtract one.
+ */
+unsigned int xhci_last_valid_endpoint(u32 added_ctxs)
+{
+       return fls(added_ctxs) - 1;
+}
+
+/* Returns 1 if the arguments are OK;
+ * returns 0 this is a root hub; returns -EINVAL for NULL pointers.
+ */
+int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
+               struct usb_host_endpoint *ep, int check_ep, const char *func) {
+       if (!hcd || (check_ep && !ep) || !udev) {
+               printk(KERN_DEBUG "xHCI %s called with invalid args\n",
+                               func);
+               return -EINVAL;
+       }
+       if (!udev->parent) {
+               printk(KERN_DEBUG "xHCI %s called for root hub\n",
+                               func);
+               return 0;
+       }
+       if (!udev->slot_id) {
+               printk(KERN_DEBUG "xHCI %s called with unaddressed device\n",
+                               func);
+               return -EINVAL;
+       }
+       return 1;
+}
+
+static int xhci_configure_endpoint(struct xhci_hcd *xhci,
+               struct usb_device *udev, struct xhci_command *command,
+               bool ctx_change, bool must_succeed);
+
+/*
+ * Full speed devices may have a max packet size greater than 8 bytes, but the
+ * USB core doesn't know that until it reads the first 8 bytes of the
+ * descriptor.  If the usb_device's max packet size changes after that point,
+ * we need to issue an evaluate context command and wait on it.
+ */
+static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
+               unsigned int ep_index, struct urb *urb)
+{
+       struct xhci_container_ctx *in_ctx;
+       struct xhci_container_ctx *out_ctx;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       struct xhci_ep_ctx *ep_ctx;
+       int max_packet_size;
+       int hw_max_packet_size;
+       int ret = 0;
+
+       out_ctx = xhci->devs[slot_id]->out_ctx;
+       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
+       hw_max_packet_size = MAX_PACKET_DECODED(ep_ctx->ep_info2);
+       max_packet_size = urb->dev->ep0.desc.wMaxPacketSize;
+       if (hw_max_packet_size != max_packet_size) {
+               xhci_dbg(xhci, "Max Packet Size for ep 0 changed.\n");
+               xhci_dbg(xhci, "Max packet size in usb_device = %d\n",
+                               max_packet_size);
+               xhci_dbg(xhci, "Max packet size in xHCI HW = %d\n",
+                               hw_max_packet_size);
+               xhci_dbg(xhci, "Issuing evaluate context command.\n");
+
+               /* Set up the modified control endpoint 0 */
+               xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx,
+                               xhci->devs[slot_id]->out_ctx, ep_index);
+               in_ctx = xhci->devs[slot_id]->in_ctx;
+               ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
+               ep_ctx->ep_info2 &= ~MAX_PACKET_MASK;
+               ep_ctx->ep_info2 |= MAX_PACKET(max_packet_size);
+
+               /* Set up the input context flags for the command */
+               /* FIXME: This won't work if a non-default control endpoint
+                * changes max packet sizes.
+                */
+               ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
+               ctrl_ctx->add_flags = EP0_FLAG;
+               ctrl_ctx->drop_flags = 0;
+
+               xhci_dbg(xhci, "Slot %d input context\n", slot_id);
+               xhci_dbg_ctx(xhci, in_ctx, ep_index);
+               xhci_dbg(xhci, "Slot %d output context\n", slot_id);
+               xhci_dbg_ctx(xhci, out_ctx, ep_index);
+
+               ret = xhci_configure_endpoint(xhci, urb->dev, NULL,
+                               true, false);
+
+               /* Clean up the input context for later use by bandwidth
+                * functions.
+                */
+               ctrl_ctx->add_flags = SLOT_FLAG;
+       }
+       return ret;
+}
+
+/*
+ * non-error returns are a promise to giveback() the urb later
+ * we drop ownership so next owner (or urb unlink) can get it
+ */
+int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       unsigned long flags;
+       int ret = 0;
+       unsigned int slot_id, ep_index;
+
+
+       if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0)
+               return -EINVAL;
+
+       slot_id = urb->dev->slot_id;
+       ep_index = xhci_get_endpoint_index(&urb->ep->desc);
+
+       if (!xhci->devs || !xhci->devs[slot_id]) {
+               if (!in_interrupt())
+                       dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n");
+               ret = -EINVAL;
+               goto exit;
+       }
+       if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
+               if (!in_interrupt())
+                       xhci_dbg(xhci, "urb submitted during PCI suspend\n");
+               ret = -ESHUTDOWN;
+               goto exit;
+       }
+       if (usb_endpoint_xfer_control(&urb->ep->desc)) {
+               /* Check to see if the max packet size for the default control
+                * endpoint changed during FS device enumeration
+                */
+               if (urb->dev->speed == USB_SPEED_FULL) {
+                       ret = xhci_check_maxpacket(xhci, slot_id,
+                                       ep_index, urb);
+                       if (ret < 0)
+                               return ret;
+               }
+
+               /* We have a spinlock and interrupts disabled, so we must pass
+                * atomic context to this function, which may allocate memory.
+                */
+               spin_lock_irqsave(&xhci->lock, flags);
+               if (xhci->xhc_state & XHCI_STATE_DYING)
+                       goto dying;
+               ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,
+                               slot_id, ep_index);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+       } else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) {
+               spin_lock_irqsave(&xhci->lock, flags);
+               if (xhci->xhc_state & XHCI_STATE_DYING)
+                       goto dying;
+               ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,
+                               slot_id, ep_index);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+       } else if (usb_endpoint_xfer_int(&urb->ep->desc)) {
+               spin_lock_irqsave(&xhci->lock, flags);
+               if (xhci->xhc_state & XHCI_STATE_DYING)
+                       goto dying;
+               ret = xhci_queue_intr_tx(xhci, GFP_ATOMIC, urb,
+                               slot_id, ep_index);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+       } else {
+               ret = -EINVAL;
+       }
+exit:
+       return ret;
+dying:
+       xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for "
+                       "non-responsive xHCI host.\n",
+                       urb->ep->desc.bEndpointAddress, urb);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+       return -ESHUTDOWN;
+}
+
+/*
+ * Remove the URB's TD from the endpoint ring.  This may cause the HC to stop
+ * USB transfers, potentially stopping in the middle of a TRB buffer.  The HC
+ * should pick up where it left off in the TD, unless a Set Transfer Ring
+ * Dequeue Pointer is issued.
+ *
+ * The TRBs that make up the buffers for the canceled URB will be "removed" from
+ * the ring.  Since the ring is a contiguous structure, they can't be physically
+ * removed.  Instead, there are two options:
+ *
+ *  1) If the HC is in the middle of processing the URB to be canceled, we
+ *     simply move the ring's dequeue pointer past those TRBs using the Set
+ *     Transfer Ring Dequeue Pointer command.  This will be the common case,
+ *     when drivers timeout on the last submitted URB and attempt to cancel.
+ *
+ *  2) If the HC is in the middle of a different TD, we turn the TRBs into a
+ *     series of 1-TRB transfer no-op TDs.  (No-ops shouldn't be chained.)  The
+ *     HC will need to invalidate the any TRBs it has cached after the stop
+ *     endpoint command, as noted in the xHCI 0.95 errata.
+ *
+ *  3) The TD may have completed by the time the Stop Endpoint Command
+ *     completes, so software needs to handle that case too.
+ *
+ * This function should protect against the TD enqueueing code ringing the
+ * doorbell while this code is waiting for a Stop Endpoint command to complete.
+ * It also needs to account for multiple cancellations on happening at the same
+ * time for the same endpoint.
+ *
+ * Note that this function can be called in any context, or so says
+ * usb_hcd_unlink_urb()
+ */
+int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
+{
+       unsigned long flags;
+       int ret;
+       u32 temp;
+       struct xhci_hcd *xhci;
+       struct xhci_td *td;
+       unsigned int ep_index;
+       struct xhci_ring *ep_ring;
+       struct xhci_virt_ep *ep;
+
+       xhci = hcd_to_xhci(hcd);
+       spin_lock_irqsave(&xhci->lock, flags);
+       /* Make sure the URB hasn't completed or been unlinked already */
+       ret = usb_hcd_check_unlink_urb(hcd, urb, status);
+       if (ret || !urb->hcpriv)
+               goto done;
+       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       if (temp == 0xffffffff) {
+               xhci_dbg(xhci, "HW died, freeing TD.\n");
+               td = (struct xhci_td *) urb->hcpriv;
+
+               usb_hcd_unlink_urb_from_ep(hcd, urb);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               usb_hcd_giveback_urb(xhci_to_hcd(xhci), urb, -ESHUTDOWN);
+               kfree(td);
+               return ret;
+       }
+       if (xhci->xhc_state & XHCI_STATE_DYING) {
+               xhci_dbg(xhci, "Ep 0x%x: URB %p to be canceled on "
+                               "non-responsive xHCI host.\n",
+                               urb->ep->desc.bEndpointAddress, urb);
+               /* Let the stop endpoint command watchdog timer (which set this
+                * state) finish cleaning up the endpoint TD lists.  We must
+                * have caught it in the middle of dropping a lock and giving
+                * back an URB.
+                */
+               goto done;
+       }
+
+       xhci_dbg(xhci, "Cancel URB %p\n", urb);
+       xhci_dbg(xhci, "Event ring:\n");
+       xhci_debug_ring(xhci, xhci->event_ring);
+       ep_index = xhci_get_endpoint_index(&urb->ep->desc);
+       ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index];
+       ep_ring = ep->ring;
+       xhci_dbg(xhci, "Endpoint ring:\n");
+       xhci_debug_ring(xhci, ep_ring);
+       td = (struct xhci_td *) urb->hcpriv;
+
+       list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list);
+       /* Queue a stop endpoint command, but only if this is
+        * the first cancellation to be handled.
+        */
+       if (!(ep->ep_state & EP_HALT_PENDING)) {
+               ep->ep_state |= EP_HALT_PENDING;
+               ep->stop_cmds_pending++;
+               ep->stop_cmd_timer.expires = jiffies +
+                       XHCI_STOP_EP_CMD_TIMEOUT * HZ;
+               add_timer(&ep->stop_cmd_timer);
+               xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index);
+               xhci_ring_cmd_db(xhci);
+       }
+done:
+       spin_unlock_irqrestore(&xhci->lock, flags);
+       return ret;
+}
+
+/* Drop an endpoint from a new bandwidth configuration for this device.
+ * Only one call to this function is allowed per endpoint before
+ * check_bandwidth() or reset_bandwidth() must be called.
+ * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
+ * add the endpoint to the schedule with possibly new parameters denoted by a
+ * different endpoint descriptor in usb_host_endpoint.
+ * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
+ * not allowed.
+ *
+ * The USB core will not allow URBs to be queued to an endpoint that is being
+ * disabled, so there's no need for mutual exclusion to protect
+ * the xhci->devs[slot_id] structure.
+ */
+int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
+               struct usb_host_endpoint *ep)
+{
+       struct xhci_hcd *xhci;
+       struct xhci_container_ctx *in_ctx, *out_ctx;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       struct xhci_slot_ctx *slot_ctx;
+       unsigned int last_ctx;
+       unsigned int ep_index;
+       struct xhci_ep_ctx *ep_ctx;
+       u32 drop_flag;
+       u32 new_add_flags, new_drop_flags, new_slot_info;
+       int ret;
+
+       ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+       if (ret <= 0)
+               return ret;
+       xhci = hcd_to_xhci(hcd);
+       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+
+       drop_flag = xhci_get_endpoint_flag(&ep->desc);
+       if (drop_flag == SLOT_FLAG || drop_flag == EP0_FLAG) {
+               xhci_dbg(xhci, "xHCI %s - can't drop slot or ep 0 %#x\n",
+                               __func__, drop_flag);
+               return 0;
+       }
+
+       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+                               __func__);
+               return -EINVAL;
+       }
+
+       in_ctx = xhci->devs[udev->slot_id]->in_ctx;
+       out_ctx = xhci->devs[udev->slot_id]->out_ctx;
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
+       ep_index = xhci_get_endpoint_index(&ep->desc);
+       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
+       /* If the HC already knows the endpoint is disabled,
+        * or the HCD has noted it is disabled, ignore this request
+        */
+       if ((ep_ctx->ep_info & EP_STATE_MASK) == EP_STATE_DISABLED ||
+                       ctrl_ctx->drop_flags & xhci_get_endpoint_flag(&ep->desc)) {
+               xhci_warn(xhci, "xHCI %s called with disabled ep %p\n",
+                               __func__, ep);
+               return 0;
+       }
+
+       ctrl_ctx->drop_flags |= drop_flag;
+       new_drop_flags = ctrl_ctx->drop_flags;
+
+       ctrl_ctx->add_flags &= ~drop_flag;
+       new_add_flags = ctrl_ctx->add_flags;
+
+       last_ctx = xhci_last_valid_endpoint(ctrl_ctx->add_flags);
+       slot_ctx = xhci_get_slot_ctx(xhci, in_ctx);
+       /* Update the last valid endpoint context, if we deleted the last one */
+       if ((slot_ctx->dev_info & LAST_CTX_MASK) > LAST_CTX(last_ctx)) {
+               slot_ctx->dev_info &= ~LAST_CTX_MASK;
+               slot_ctx->dev_info |= LAST_CTX(last_ctx);
+       }
+       new_slot_info = slot_ctx->dev_info;
+
+       xhci_endpoint_zero(xhci, xhci->devs[udev->slot_id], ep);
+
+       xhci_dbg(xhci, "drop ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
+                       (unsigned int) ep->desc.bEndpointAddress,
+                       udev->slot_id,
+                       (unsigned int) new_drop_flags,
+                       (unsigned int) new_add_flags,
+                       (unsigned int) new_slot_info);
+       return 0;
+}
+
+/* Add an endpoint to a new possible bandwidth configuration for this device.
+ * Only one call to this function is allowed per endpoint before
+ * check_bandwidth() or reset_bandwidth() must be called.
+ * A call to xhci_drop_endpoint() followed by a call to xhci_add_endpoint() will
+ * add the endpoint to the schedule with possibly new parameters denoted by a
+ * different endpoint descriptor in usb_host_endpoint.
+ * A call to xhci_add_endpoint() followed by a call to xhci_drop_endpoint() is
+ * not allowed.
+ *
+ * The USB core will not allow URBs to be queued to an endpoint until the
+ * configuration or alt setting is installed in the device, so there's no need
+ * for mutual exclusion to protect the xhci->devs[slot_id] structure.
+ */
+int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
+               struct usb_host_endpoint *ep)
+{
+       struct xhci_hcd *xhci;
+       struct xhci_container_ctx *in_ctx, *out_ctx;
+       unsigned int ep_index;
+       struct xhci_ep_ctx *ep_ctx;
+       struct xhci_slot_ctx *slot_ctx;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       u32 added_ctxs;
+       unsigned int last_ctx;
+       u32 new_add_flags, new_drop_flags, new_slot_info;
+       int ret = 0;
+
+       ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+       if (ret <= 0) {
+               /* So we won't queue a reset ep command for a root hub */
+               ep->hcpriv = NULL;
+               return ret;
+       }
+       xhci = hcd_to_xhci(hcd);
+
+       added_ctxs = xhci_get_endpoint_flag(&ep->desc);
+       last_ctx = xhci_last_valid_endpoint(added_ctxs);
+       if (added_ctxs == SLOT_FLAG || added_ctxs == EP0_FLAG) {
+               /* FIXME when we have to issue an evaluate endpoint command to
+                * deal with ep0 max packet size changing once we get the
+                * descriptors
+                */
+               xhci_dbg(xhci, "xHCI %s - can't add slot or ep 0 %#x\n",
+                               __func__, added_ctxs);
+               return 0;
+       }
+
+       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+                               __func__);
+               return -EINVAL;
+       }
+
+       in_ctx = xhci->devs[udev->slot_id]->in_ctx;
+       out_ctx = xhci->devs[udev->slot_id]->out_ctx;
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
+       ep_index = xhci_get_endpoint_index(&ep->desc);
+       ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
+       /* If the HCD has already noted the endpoint is enabled,
+        * ignore this request.
+        */
+       if (ctrl_ctx->add_flags & xhci_get_endpoint_flag(&ep->desc)) {
+               xhci_warn(xhci, "xHCI %s called with enabled ep %p\n",
+                               __func__, ep);
+               return 0;
+       }
+
+       /*
+        * Configuration and alternate setting changes must be done in
+        * process context, not interrupt context (or so documenation
+        * for usb_set_interface() and usb_set_configuration() claim).
+        */
+       if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id],
+                               udev, ep, GFP_NOIO) < 0) {
+               dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
+                               __func__, ep->desc.bEndpointAddress);
+               return -ENOMEM;
+       }
+
+       ctrl_ctx->add_flags |= added_ctxs;
+       new_add_flags = ctrl_ctx->add_flags;
+
+       /* If xhci_endpoint_disable() was called for this endpoint, but the
+        * xHC hasn't been notified yet through the check_bandwidth() call,
+        * this re-adds a new state for the endpoint from the new endpoint
+        * descriptors.  We must drop and re-add this endpoint, so we leave the
+        * drop flags alone.
+        */
+       new_drop_flags = ctrl_ctx->drop_flags;
+
+       slot_ctx = xhci_get_slot_ctx(xhci, in_ctx);
+       /* Update the last valid endpoint context, if we just added one past */
+       if ((slot_ctx->dev_info & LAST_CTX_MASK) < LAST_CTX(last_ctx)) {
+               slot_ctx->dev_info &= ~LAST_CTX_MASK;
+               slot_ctx->dev_info |= LAST_CTX(last_ctx);
+       }
+       new_slot_info = slot_ctx->dev_info;
+
+       /* Store the usb_device pointer for later use */
+       ep->hcpriv = udev;
+
+       xhci_dbg(xhci, "add ep 0x%x, slot id %d, new drop flags = %#x, new add flags = %#x, new slot info = %#x\n",
+                       (unsigned int) ep->desc.bEndpointAddress,
+                       udev->slot_id,
+                       (unsigned int) new_drop_flags,
+                       (unsigned int) new_add_flags,
+                       (unsigned int) new_slot_info);
+       return 0;
+}
+
+static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev)
+{
+       struct xhci_input_control_ctx *ctrl_ctx;
+       struct xhci_ep_ctx *ep_ctx;
+       struct xhci_slot_ctx *slot_ctx;
+       int i;
+
+       /* When a device's add flag and drop flag are zero, any subsequent
+        * configure endpoint command will leave that endpoint's state
+        * untouched.  Make sure we don't leave any old state in the input
+        * endpoint contexts.
+        */
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
+       ctrl_ctx->drop_flags = 0;
+       ctrl_ctx->add_flags = 0;
+       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
+       slot_ctx->dev_info &= ~LAST_CTX_MASK;
+       /* Endpoint 0 is always valid */
+       slot_ctx->dev_info |= LAST_CTX(1);
+       for (i = 1; i < 31; ++i) {
+               ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, i);
+               ep_ctx->ep_info = 0;
+               ep_ctx->ep_info2 = 0;
+               ep_ctx->deq = 0;
+               ep_ctx->tx_info = 0;
+       }
+}
+
+static int xhci_configure_endpoint_result(struct xhci_hcd *xhci,
+               struct usb_device *udev, int *cmd_status)
+{
+       int ret;
+
+       switch (*cmd_status) {
+       case COMP_ENOMEM:
+               dev_warn(&udev->dev, "Not enough host controller resources "
+                               "for new device state.\n");
+               ret = -ENOMEM;
+               /* FIXME: can we allocate more resources for the HC? */
+               break;
+       case COMP_BW_ERR:
+               dev_warn(&udev->dev, "Not enough bandwidth "
+                               "for new device state.\n");
+               ret = -ENOSPC;
+               /* FIXME: can we go back to the old state? */
+               break;
+       case COMP_TRB_ERR:
+               /* the HCD set up something wrong */
+               dev_warn(&udev->dev, "ERROR: Endpoint drop flag = 0, "
+                               "add flag = 1, "
+                               "and endpoint is not disabled.\n");
+               ret = -EINVAL;
+               break;
+       case COMP_SUCCESS:
+               dev_dbg(&udev->dev, "Successful Endpoint Configure command\n");
+               ret = 0;
+               break;
+       default:
+               xhci_err(xhci, "ERROR: unexpected command completion "
+                               "code 0x%x.\n", *cmd_status);
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
+static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
+               struct usb_device *udev, int *cmd_status)
+{
+       int ret;
+       struct xhci_virt_device *virt_dev = xhci->devs[udev->slot_id];
+
+       switch (*cmd_status) {
+       case COMP_EINVAL:
+               dev_warn(&udev->dev, "WARN: xHCI driver setup invalid evaluate "
+                               "context command.\n");
+               ret = -EINVAL;
+               break;
+       case COMP_EBADSLT:
+               dev_warn(&udev->dev, "WARN: slot not enabled for"
+                               "evaluate context command.\n");
+       case COMP_CTX_STATE:
+               dev_warn(&udev->dev, "WARN: invalid context state for "
+                               "evaluate context command.\n");
+               xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1);
+               ret = -EINVAL;
+               break;
+       case COMP_SUCCESS:
+               dev_dbg(&udev->dev, "Successful evaluate context command\n");
+               ret = 0;
+               break;
+       default:
+               xhci_err(xhci, "ERROR: unexpected command completion "
+                               "code 0x%x.\n", *cmd_status);
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
+/* Issue a configure endpoint command or evaluate context command
+ * and wait for it to finish.
+ */
+static int xhci_configure_endpoint(struct xhci_hcd *xhci,
+               struct usb_device *udev,
+               struct xhci_command *command,
+               bool ctx_change, bool must_succeed)
+{
+       int ret;
+       int timeleft;
+       unsigned long flags;
+       struct xhci_container_ctx *in_ctx;
+       struct completion *cmd_completion;
+       int *cmd_status;
+       struct xhci_virt_device *virt_dev;
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       virt_dev = xhci->devs[udev->slot_id];
+       if (command) {
+               in_ctx = command->in_ctx;
+               cmd_completion = command->completion;
+               cmd_status = &command->status;
+               command->command_trb = xhci->cmd_ring->enqueue;
+               list_add_tail(&command->cmd_list, &virt_dev->cmd_list);
+       } else {
+               in_ctx = virt_dev->in_ctx;
+               cmd_completion = &virt_dev->cmd_completion;
+               cmd_status = &virt_dev->cmd_status;
+       }
+       init_completion(cmd_completion);
+
+       if (!ctx_change)
+               ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma,
+                               udev->slot_id, must_succeed);
+       else
+               ret = xhci_queue_evaluate_context(xhci, in_ctx->dma,
+                               udev->slot_id);
+       if (ret < 0) {
+               if (command)
+                       list_del(&command->cmd_list);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_dbg(xhci, "FIXME allocate a new ring segment\n");
+               return -ENOMEM;
+       }
+       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       /* Wait for the configure endpoint command to complete */
+       timeleft = wait_for_completion_interruptible_timeout(
+                       cmd_completion,
+                       USB_CTRL_SET_TIMEOUT);
+       if (timeleft <= 0) {
+               xhci_warn(xhci, "%s while waiting for %s command\n",
+                               timeleft == 0 ? "Timeout" : "Signal",
+                               ctx_change == 0 ?
+                                       "configure endpoint" :
+                                       "evaluate context");
+               /* FIXME cancel the configure endpoint command */
+               return -ETIME;
+       }
+
+       if (!ctx_change)
+               return xhci_configure_endpoint_result(xhci, udev, cmd_status);
+       return xhci_evaluate_context_result(xhci, udev, cmd_status);
+}
+
+/* Called after one or more calls to xhci_add_endpoint() or
+ * xhci_drop_endpoint().  If this call fails, the USB core is expected
+ * to call xhci_reset_bandwidth().
+ *
+ * Since we are in the middle of changing either configuration or
+ * installing a new alt setting, the USB core won't allow URBs to be
+ * enqueued for any endpoint on the old config or interface.  Nothing
+ * else should be touching the xhci->devs[slot_id] structure, so we
+ * don't need to take the xhci->lock for manipulating that.
+ */
+int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       int i;
+       int ret = 0;
+       struct xhci_hcd *xhci;
+       struct xhci_virt_device *virt_dev;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       struct xhci_slot_ctx *slot_ctx;
+
+       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+       if (ret <= 0)
+               return ret;
+       xhci = hcd_to_xhci(hcd);
+
+       if (!udev->slot_id || !xhci->devs || !xhci->devs[udev->slot_id]) {
+               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+                               __func__);
+               return -EINVAL;
+       }
+       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+       virt_dev = xhci->devs[udev->slot_id];
+
+       /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
+       ctrl_ctx->add_flags |= SLOT_FLAG;
+       ctrl_ctx->add_flags &= ~EP0_FLAG;
+       ctrl_ctx->drop_flags &= ~SLOT_FLAG;
+       ctrl_ctx->drop_flags &= ~EP0_FLAG;
+       xhci_dbg(xhci, "New Input Control Context:\n");
+       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
+       xhci_dbg_ctx(xhci, virt_dev->in_ctx,
+                       LAST_CTX_TO_EP_NUM(slot_ctx->dev_info));
+
+       ret = xhci_configure_endpoint(xhci, udev, NULL,
+                       false, false);
+       if (ret) {
+               /* Callee should call reset_bandwidth() */
+               return ret;
+       }
+
+       xhci_dbg(xhci, "Output context after successful config ep cmd:\n");
+       xhci_dbg_ctx(xhci, virt_dev->out_ctx,
+                       LAST_CTX_TO_EP_NUM(slot_ctx->dev_info));
+
+       xhci_zero_in_ctx(xhci, virt_dev);
+       /* Install new rings and free or cache any old rings */
+       for (i = 1; i < 31; ++i) {
+               if (!virt_dev->eps[i].new_ring)
+                       continue;
+               /* Only cache or free the old ring if it exists.
+                * It may not if this is the first add of an endpoint.
+                */
+               if (virt_dev->eps[i].ring) {
+                       xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
+               }
+               virt_dev->eps[i].ring = virt_dev->eps[i].new_ring;
+               virt_dev->eps[i].new_ring = NULL;
+       }
+
+       return ret;
+}
+
+void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       struct xhci_hcd *xhci;
+       struct xhci_virt_device *virt_dev;
+       int i, ret;
+
+       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+       if (ret <= 0)
+               return;
+       xhci = hcd_to_xhci(hcd);
+
+       if (!xhci->devs || !xhci->devs[udev->slot_id]) {
+               xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
+                               __func__);
+               return;
+       }
+       xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
+       virt_dev = xhci->devs[udev->slot_id];
+       /* Free any rings allocated for added endpoints */
+       for (i = 0; i < 31; ++i) {
+               if (virt_dev->eps[i].new_ring) {
+                       xhci_ring_free(xhci, virt_dev->eps[i].new_ring);
+                       virt_dev->eps[i].new_ring = NULL;
+               }
+       }
+       xhci_zero_in_ctx(xhci, virt_dev);
+}
+
+static void xhci_setup_input_ctx_for_config_ep(struct xhci_hcd *xhci,
+               struct xhci_container_ctx *in_ctx,
+               struct xhci_container_ctx *out_ctx,
+               u32 add_flags, u32 drop_flags)
+{
+       struct xhci_input_control_ctx *ctrl_ctx;
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
+       ctrl_ctx->add_flags = add_flags;
+       ctrl_ctx->drop_flags = drop_flags;
+       xhci_slot_copy(xhci, in_ctx, out_ctx);
+       ctrl_ctx->add_flags |= SLOT_FLAG;
+
+       xhci_dbg(xhci, "Input Context:\n");
+       xhci_dbg_ctx(xhci, in_ctx, xhci_last_valid_endpoint(add_flags));
+}
+
+void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
+               unsigned int slot_id, unsigned int ep_index,
+               struct xhci_dequeue_state *deq_state)
+{
+       struct xhci_container_ctx *in_ctx;
+       struct xhci_ep_ctx *ep_ctx;
+       u32 added_ctxs;
+       dma_addr_t addr;
+
+       xhci_endpoint_copy(xhci, xhci->devs[slot_id]->in_ctx,
+                       xhci->devs[slot_id]->out_ctx, ep_index);
+       in_ctx = xhci->devs[slot_id]->in_ctx;
+       ep_ctx = xhci_get_ep_ctx(xhci, in_ctx, ep_index);
+       addr = xhci_trb_virt_to_dma(deq_state->new_deq_seg,
+                       deq_state->new_deq_ptr);
+       if (addr == 0) {
+               xhci_warn(xhci, "WARN Cannot submit config ep after "
+                               "reset ep command\n");
+               xhci_warn(xhci, "WARN deq seg = %p, deq ptr = %p\n",
+                               deq_state->new_deq_seg,
+                               deq_state->new_deq_ptr);
+               return;
+       }
+       ep_ctx->deq = addr | deq_state->new_cycle_state;
+
+       added_ctxs = xhci_get_endpoint_flag_from_index(ep_index);
+       xhci_setup_input_ctx_for_config_ep(xhci, xhci->devs[slot_id]->in_ctx,
+                       xhci->devs[slot_id]->out_ctx, added_ctxs, added_ctxs);
+}
+
+void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
+               struct usb_device *udev, unsigned int ep_index)
+{
+       struct xhci_dequeue_state deq_state;
+       struct xhci_virt_ep *ep;
+
+       xhci_dbg(xhci, "Cleaning up stalled endpoint ring\n");
+       ep = &xhci->devs[udev->slot_id]->eps[ep_index];
+       /* We need to move the HW's dequeue pointer past this TD,
+        * or it will attempt to resend it on the next doorbell ring.
+        */
+       xhci_find_new_dequeue_state(xhci, udev->slot_id,
+                       ep_index, ep->stopped_td,
+                       &deq_state);
+
+       /* HW with the reset endpoint quirk will use the saved dequeue state to
+        * issue a configure endpoint command later.
+        */
+       if (!(xhci->quirks & XHCI_RESET_EP_QUIRK)) {
+               xhci_dbg(xhci, "Queueing new dequeue state\n");
+               xhci_queue_new_dequeue_state(xhci, udev->slot_id,
+                               ep_index, &deq_state);
+       } else {
+               /* Better hope no one uses the input context between now and the
+                * reset endpoint completion!
+                */
+               xhci_dbg(xhci, "Setting up input context for "
+                               "configure endpoint command\n");
+               xhci_setup_input_ctx_for_quirk(xhci, udev->slot_id,
+                               ep_index, &deq_state);
+       }
+}
+
+/* Deal with stalled endpoints.  The core should have sent the control message
+ * to clear the halt condition.  However, we need to make the xHCI hardware
+ * reset its sequence number, since a device will expect a sequence number of
+ * zero after the halt condition is cleared.
+ * Context: in_interrupt
+ */
+void xhci_endpoint_reset(struct usb_hcd *hcd,
+               struct usb_host_endpoint *ep)
+{
+       struct xhci_hcd *xhci;
+       struct usb_device *udev;
+       unsigned int ep_index;
+       unsigned long flags;
+       int ret;
+       struct xhci_virt_ep *virt_ep;
+
+       xhci = hcd_to_xhci(hcd);
+       udev = (struct usb_device *) ep->hcpriv;
+       /* Called with a root hub endpoint (or an endpoint that wasn't added
+        * with xhci_add_endpoint()
+        */
+       if (!ep->hcpriv)
+               return;
+       ep_index = xhci_get_endpoint_index(&ep->desc);
+       virt_ep = &xhci->devs[udev->slot_id]->eps[ep_index];
+       if (!virt_ep->stopped_td) {
+               xhci_dbg(xhci, "Endpoint 0x%x not halted, refusing to reset.\n",
+                               ep->desc.bEndpointAddress);
+               return;
+       }
+       if (usb_endpoint_xfer_control(&ep->desc)) {
+               xhci_dbg(xhci, "Control endpoint stall already handled.\n");
+               return;
+       }
+
+       xhci_dbg(xhci, "Queueing reset endpoint command\n");
+       spin_lock_irqsave(&xhci->lock, flags);
+       ret = xhci_queue_reset_ep(xhci, udev->slot_id, ep_index);
+       /*
+        * Can't change the ring dequeue pointer until it's transitioned to the
+        * stopped state, which is only upon a successful reset endpoint
+        * command.  Better hope that last command worked!
+        */
+       if (!ret) {
+               xhci_cleanup_stalled_ring(xhci, udev, ep_index);
+               kfree(virt_ep->stopped_td);
+               xhci_ring_cmd_db(xhci);
+       }
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       if (ret)
+               xhci_warn(xhci, "FIXME allocate a new ring segment\n");
+}
+
+/*
+ * This submits a Reset Device Command, which will set the device state to 0,
+ * set the device address to 0, and disable all the endpoints except the default
+ * control endpoint.  The USB core should come back and call
+ * xhci_address_device(), and then re-set up the configuration.  If this is
+ * called because of a usb_reset_and_verify_device(), then the old alternate
+ * settings will be re-installed through the normal bandwidth allocation
+ * functions.
+ *
+ * Wait for the Reset Device command to finish.  Remove all structures
+ * associated with the endpoints that were disabled.  Clear the input device
+ * structure?  Cache the rings?  Reset the control endpoint 0 max packet size?
+ */
+int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       int ret, i;
+       unsigned long flags;
+       struct xhci_hcd *xhci;
+       unsigned int slot_id;
+       struct xhci_virt_device *virt_dev;
+       struct xhci_command *reset_device_cmd;
+       int timeleft;
+       int last_freed_endpoint;
+
+       ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+       if (ret <= 0)
+               return ret;
+       xhci = hcd_to_xhci(hcd);
+       slot_id = udev->slot_id;
+       virt_dev = xhci->devs[slot_id];
+       if (!virt_dev) {
+               xhci_dbg(xhci, "%s called with invalid slot ID %u\n",
+                               __func__, slot_id);
+               return -EINVAL;
+       }
+
+       xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id);
+       /* Allocate the command structure that holds the struct completion.
+        * Assume we're in process context, since the normal device reset
+        * process has to wait for the device anyway.  Storage devices are
+        * reset as part of error handling, so use GFP_NOIO instead of
+        * GFP_KERNEL.
+        */
+       reset_device_cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
+       if (!reset_device_cmd) {
+               xhci_dbg(xhci, "Couldn't allocate command structure.\n");
+               return -ENOMEM;
+       }
+
+       /* Attempt to submit the Reset Device command to the command ring */
+       spin_lock_irqsave(&xhci->lock, flags);
+       reset_device_cmd->command_trb = xhci->cmd_ring->enqueue;
+       list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list);
+       ret = xhci_queue_reset_device(xhci, slot_id);
+       if (ret) {
+               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+               list_del(&reset_device_cmd->cmd_list);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               goto command_cleanup;
+       }
+       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       /* Wait for the Reset Device command to finish */
+       timeleft = wait_for_completion_interruptible_timeout(
+                       reset_device_cmd->completion,
+                       USB_CTRL_SET_TIMEOUT);
+       if (timeleft <= 0) {
+               xhci_warn(xhci, "%s while waiting for reset device command\n",
+                               timeleft == 0 ? "Timeout" : "Signal");
+               spin_lock_irqsave(&xhci->lock, flags);
+               /* The timeout might have raced with the event ring handler, so
+                * only delete from the list if the item isn't poisoned.
+                */
+               if (reset_device_cmd->cmd_list.next != LIST_POISON1)
+                       list_del(&reset_device_cmd->cmd_list);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               ret = -ETIME;
+               goto command_cleanup;
+       }
+
+       /* The Reset Device command can't fail, according to the 0.95/0.96 spec,
+        * unless we tried to reset a slot ID that wasn't enabled,
+        * or the device wasn't in the addressed or configured state.
+        */
+       ret = reset_device_cmd->status;
+       switch (ret) {
+       case COMP_EBADSLT: /* 0.95 completion code for bad slot ID */
+       case COMP_CTX_STATE: /* 0.96 completion code for same thing */
+               xhci_info(xhci, "Can't reset device (slot ID %u) in %s state\n",
+                               slot_id,
+                               xhci_get_slot_state(xhci, virt_dev->out_ctx));
+               xhci_info(xhci, "Not freeing device rings.\n");
+               /* Don't treat this as an error.  May change my mind later. */
+               ret = 0;
+               goto command_cleanup;
+       case COMP_SUCCESS:
+               xhci_dbg(xhci, "Successful reset device command.\n");
+               break;
+       default:
+               if (xhci_is_vendor_info_code(xhci, ret))
+                       break;
+               xhci_warn(xhci, "Unknown completion code %u for "
+                               "reset device command.\n", ret);
+               ret = -EINVAL;
+               goto command_cleanup;
+       }
+
+       /* Everything but endpoint 0 is disabled, so free or cache the rings. */
+       last_freed_endpoint = 1;
+       for (i = 1; i < 31; ++i) {
+               if (!virt_dev->eps[i].ring)
+                       continue;
+               xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
+               last_freed_endpoint = i;
+       }
+       xhci_dbg(xhci, "Output context after successful reset device cmd:\n");
+       xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint);
+       ret = 0;
+
+command_cleanup:
+       xhci_free_command(xhci, reset_device_cmd);
+       return ret;
+}
+
+/*
+ * At this point, the struct usb_device is about to go away, the device has
+ * disconnected, and all traffic has been stopped and the endpoints have been
+ * disabled.  Free any HC data structures associated with that device.
+ */
+void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct xhci_virt_device *virt_dev;
+       unsigned long flags;
+       u32 state;
+       int i;
+
+       if (udev->slot_id == 0)
+               return;
+       virt_dev = xhci->devs[udev->slot_id];
+       if (!virt_dev)
+               return;
+
+       /* Stop any wayward timer functions (which may grab the lock) */
+       for (i = 0; i < 31; ++i) {
+               virt_dev->eps[i].ep_state &= ~EP_HALT_PENDING;
+               del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
+       }
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       /* Don't disable the slot if the host controller is dead. */
+       state = xhci_readl(xhci, &xhci->op_regs->status);
+       if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING)) {
+               xhci_free_virt_device(xhci, udev->slot_id);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               return;
+       }
+
+       if (xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id)) {
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+               return;
+       }
+       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+       /*
+        * Event command completion handler will free any data structures
+        * associated with the slot.  XXX Can free sleep?
+        */
+}
+
+/*
+ * Returns 0 if the xHC ran out of device slots, the Enable Slot command
+ * timed out, or allocating memory failed.  Returns 1 on success.
+ */
+int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       unsigned long flags;
+       int timeleft;
+       int ret;
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       ret = xhci_queue_slot_control(xhci, TRB_ENABLE_SLOT, 0);
+       if (ret) {
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+               return 0;
+       }
+       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       /* XXX: how much time for xHC slot assignment? */
+       timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
+                       USB_CTRL_SET_TIMEOUT);
+       if (timeleft <= 0) {
+               xhci_warn(xhci, "%s while waiting for a slot\n",
+                               timeleft == 0 ? "Timeout" : "Signal");
+               /* FIXME cancel the enable slot request */
+               return 0;
+       }
+
+       if (!xhci->slot_id) {
+               xhci_err(xhci, "Error while assigning device slot ID\n");
+               return 0;
+       }
+       /* xhci_alloc_virt_device() does not touch rings; no need to lock */
+       if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) {
+               /* Disable slot, if we can do it without mem alloc */
+               xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
+               spin_lock_irqsave(&xhci->lock, flags);
+               if (!xhci_queue_slot_control(xhci, TRB_DISABLE_SLOT, udev->slot_id))
+                       xhci_ring_cmd_db(xhci);
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               return 0;
+       }
+       udev->slot_id = xhci->slot_id;
+       /* Is this a LS or FS device under a HS hub? */
+       /* Hub or peripherial? */
+       return 1;
+}
+
+/*
+ * Issue an Address Device command (which will issue a SetAddress request to
+ * the device).
+ * We should be protected by the usb_address0_mutex in khubd's hub_port_init, so
+ * we should only issue and wait on one address command at the same time.
+ *
+ * We add one to the device address issued by the hardware because the USB core
+ * uses address 1 for the root hubs (even though they're not really devices).
+ */
+int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       unsigned long flags;
+       int timeleft;
+       struct xhci_virt_device *virt_dev;
+       int ret = 0;
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct xhci_slot_ctx *slot_ctx;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       u64 temp_64;
+
+       if (!udev->slot_id) {
+               xhci_dbg(xhci, "Bad Slot ID %d\n", udev->slot_id);
+               return -EINVAL;
+       }
+
+       virt_dev = xhci->devs[udev->slot_id];
+
+       /* If this is a Set Address to an unconfigured device, setup ep 0 */
+       if (!udev->config)
+               xhci_setup_addressable_virt_dev(xhci, udev);
+       /* Otherwise, assume the core has the device configured how it wants */
+       xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
+       xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma,
+                                       udev->slot_id);
+       if (ret) {
+               spin_unlock_irqrestore(&xhci->lock, flags);
+               xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
+               return ret;
+       }
+       xhci_ring_cmd_db(xhci);
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       /* ctrl tx can take up to 5 sec; XXX: need more time for xHC? */
+       timeleft = wait_for_completion_interruptible_timeout(&xhci->addr_dev,
+                       USB_CTRL_SET_TIMEOUT);
+       /* FIXME: From section 4.3.4: "Software shall be responsible for timing
+        * the SetAddress() "recovery interval" required by USB and aborting the
+        * command on a timeout.
+        */
+       if (timeleft <= 0) {
+               xhci_warn(xhci, "%s while waiting for a slot\n",
+                               timeleft == 0 ? "Timeout" : "Signal");
+               /* FIXME cancel the address device command */
+               return -ETIME;
+       }
+
+       switch (virt_dev->cmd_status) {
+       case COMP_CTX_STATE:
+       case COMP_EBADSLT:
+               xhci_err(xhci, "Setup ERROR: address device command for slot %d.\n",
+                               udev->slot_id);
+               ret = -EINVAL;
+               break;
+       case COMP_TX_ERR:
+               dev_warn(&udev->dev, "Device not responding to set address.\n");
+               ret = -EPROTO;
+               break;
+       case COMP_SUCCESS:
+               xhci_dbg(xhci, "Successful Address Device command\n");
+               break;
+       default:
+               xhci_err(xhci, "ERROR: unexpected command completion "
+                               "code 0x%x.\n", virt_dev->cmd_status);
+               xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
+               xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
+               ret = -EINVAL;
+               break;
+       }
+       if (ret) {
+               return ret;
+       }
+       temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
+       xhci_dbg(xhci, "Op regs DCBAA ptr = %#016llx\n", temp_64);
+       xhci_dbg(xhci, "Slot ID %d dcbaa entry @%p = %#016llx\n",
+                       udev->slot_id,
+                       &xhci->dcbaa->dev_context_ptrs[udev->slot_id],
+                       (unsigned long long)
+                               xhci->dcbaa->dev_context_ptrs[udev->slot_id]);
+       xhci_dbg(xhci, "Output Context DMA address = %#08llx\n",
+                       (unsigned long long)virt_dev->out_ctx->dma);
+       xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
+       xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
+       xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
+       xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
+       /*
+        * USB core uses address 1 for the roothubs, so we add one to the
+        * address given back to us by the HC.
+        */
+       slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
+       udev->devnum = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1;
+       /* Zero the input context control for later use */
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
+       ctrl_ctx->add_flags = 0;
+       ctrl_ctx->drop_flags = 0;
+
+       xhci_dbg(xhci, "Device address = %d\n", udev->devnum);
+       /* XXX Meh, not sure if anyone else but choose_address uses this. */
+       set_bit(udev->devnum, udev->bus->devmap.devicemap);
+
+       return 0;
+}
+
+/* Once a hub descriptor is fetched for a device, we need to update the xHC's
+ * internal data structures for the device.
+ */
+int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
+                       struct usb_tt *tt, gfp_t mem_flags)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct xhci_virt_device *vdev;
+       struct xhci_command *config_cmd;
+       struct xhci_input_control_ctx *ctrl_ctx;
+       struct xhci_slot_ctx *slot_ctx;
+       unsigned long flags;
+       unsigned think_time;
+       int ret;
+
+       /* Ignore root hubs */
+       if (!hdev->parent)
+               return 0;
+
+       vdev = xhci->devs[hdev->slot_id];
+       if (!vdev) {
+               xhci_warn(xhci, "Cannot update hub desc for unknown device.\n");
+               return -EINVAL;
+       }
+       config_cmd = xhci_alloc_command(xhci, true, true, mem_flags);
+       if (!config_cmd) {
+               xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
+               return -ENOMEM;
+       }
+
+       spin_lock_irqsave(&xhci->lock, flags);
+       xhci_slot_copy(xhci, config_cmd->in_ctx, vdev->out_ctx);
+       ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx);
+       ctrl_ctx->add_flags |= SLOT_FLAG;
+       slot_ctx = xhci_get_slot_ctx(xhci, config_cmd->in_ctx);
+       slot_ctx->dev_info |= DEV_HUB;
+       if (tt->multi)
+               slot_ctx->dev_info |= DEV_MTT;
+       if (xhci->hci_version > 0x95) {
+               xhci_dbg(xhci, "xHCI version %x needs hub "
+                               "TT think time and number of ports\n",
+                               (unsigned int) xhci->hci_version);
+               slot_ctx->dev_info2 |= XHCI_MAX_PORTS(hdev->maxchild);
+               /* Set TT think time - convert from ns to FS bit times.
+                * 0 = 8 FS bit times, 1 = 16 FS bit times,
+                * 2 = 24 FS bit times, 3 = 32 FS bit times.
+                */
+               think_time = tt->think_time;
+               if (think_time != 0)
+                       think_time = (think_time / 666) - 1;
+               slot_ctx->tt_info |= TT_THINK_TIME(think_time);
+       } else {
+               xhci_dbg(xhci, "xHCI version %x doesn't need hub "
+                               "TT think time or number of ports\n",
+                               (unsigned int) xhci->hci_version);
+       }
+       slot_ctx->dev_state = 0;
+       spin_unlock_irqrestore(&xhci->lock, flags);
+
+       xhci_dbg(xhci, "Set up %s for hub device.\n",
+                       (xhci->hci_version > 0x95) ?
+                       "configure endpoint" : "evaluate context");
+       xhci_dbg(xhci, "Slot %u Input Context:\n", hdev->slot_id);
+       xhci_dbg_ctx(xhci, config_cmd->in_ctx, 0);
+
+       /* Issue and wait for the configure endpoint or
+        * evaluate context command.
+        */
+       if (xhci->hci_version > 0x95)
+               ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
+                               false, false);
+       else
+               ret = xhci_configure_endpoint(xhci, hdev, config_cmd,
+                               true, false);
+
+       xhci_dbg(xhci, "Slot %u Output Context:\n", hdev->slot_id);
+       xhci_dbg_ctx(xhci, vdev->out_ctx, 0);
+
+       xhci_free_command(xhci, config_cmd);
+       return ret;
+}
+
+int xhci_get_frame(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       /* EHCI mods by the periodic size.  Why? */
+       return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3;
+}
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_LICENSE("GPL");
+
+static int __init xhci_hcd_init(void)
+{
+#ifdef CONFIG_PCI
+       int retval = 0;
+
+       retval = xhci_register_pci();
+
+       if (retval < 0) {
+               printk(KERN_DEBUG "Problem registering PCI driver.");
+               return retval;
+       }
+#endif
+       /*
+        * Check the compiler generated sizes of structures that must be laid
+        * out in specific ways for hardware access.
+        */
+       BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_slot_ctx) != 8*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_ep_ctx) != 8*32/8);
+       /* xhci_device_control has eight fields, and also
+        * embeds one xhci_slot_ctx and 31 xhci_ep_ctx
+        */
+       BUILD_BUG_ON(sizeof(struct xhci_stream_ctx) != 4*32/8);
+       BUILD_BUG_ON(sizeof(union xhci_trb) != 4*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_erst_entry) != 4*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_cap_regs) != 7*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
+       /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
+       BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
+       BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8);
+       return 0;
+}
+module_init(xhci_hcd_init);
+
+static void __exit xhci_hcd_cleanup(void)
+{
+#ifdef CONFIG_PCI
+       xhci_unregister_pci();
+#endif
+}
+module_exit(xhci_hcd_cleanup);
index 3adab041355a56a9e1b76b0c0ebd20232f41ee31..094f91cbc5780b78ab9f3eb67c1d87c1583b9cd8 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/backlight.h>
 #include <linux/timer.h>
index 1547d8cac5fb96fcae8f87b0085a63c277eb1320..2f43c57743c9c905b26e8e06dc517df6b5bb7c26 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #define DRIVER_AUTHOR          "Oliver Bock (bock@tfh-berlin.de)"
index b9cbbbda824558f20802d18b28ae9151ce59a3d3..1d7251bc1b5f5f395376ccf01f829c097d5ec82f 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
 
index 06e990adc6cdd50e77657beeb5a690d7684ed224..fe1d44319d0a1eb2d373c14c6fccbfdfedd505c9 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/firmware.h>
 #include <linux/errno.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 static const struct usb_device_id id_table[] = {
        {USB_DEVICE(0x05ac, 0x8300)},
index b624320df903da090c8380f59d06593d8c648302..b271b0557a1f9fb0db8ea382898fcbe5e18e09c8 100644 (file)
@@ -58,7 +58,6 @@
 #include <linux/string.h>
 #include <linux/kd.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/vt_kern.h>
 #include <linux/selection.h>
 #include <linux/spinlock.h>
index 0ab990744830c4fc321eca69fa485c59997670ba..cb8a3d91f9706d14fbf6ee4a710c404047ea7ece 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/errno.h>
 #include <linux/poll.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include "sisusb.h"
index 5da28eaee314c0e0ecdba8bed88f925e71a123ed..d77aba46ae85675e58afb532078458b74b7b29a7 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
 
index f56fed53f2dd202b8f6cc551488e3590f006af7a..796e2f68f7494fad857349e9ffc82ac4f9303984 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/delay.h>
 #include <linux/completion.h>
 #include <linux/kref.h>
+#include <linux/slab.h>
 
 /*
  * Version Information
index 6dd44bc1f5ff4cb98791691a077d344960894690..ddf7f9a1b3362c37178ac2cccc9f81f828d7bfcd 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 
index e0c2db3b767b7cb91539e1ed1fe8f386beebc268..e4af18b93c7d85b7bc512872d7cb46f88bd07882 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/notifier.h>
 #include <linux/mutex.h>
 
index ac8b0d5ce7f852c663dca9af9fbb8dc389348591..1becdc3837e6ce5f897d5b6a2e4b0f4dcdd12c3b 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/fs.h>
 #include <asm/uaccess.h>
index 31c11888ec6a9e3bed63f56628761a98e193789d..4d0be130f49b5282af7b70654b94ead4e0cf2e9b 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/mutex.h>
 #include <linux/debugfs.h>
index bcee1339d4fdfdbb0a53c7a96ddbdeceda360b85..719a22d664efb41769d98c141f97b3bc627ad272 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/gpio.h>
index 3c69a76ec392fdd8574bd061e1e113df341175ad..59dc3d351b60269f3c3872b859c0b39d7fcbe449 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 
 #include "musb_core.h"
index a883f9dd3f8aea7da8f894b54ccdf694eb47b1b9..29bce5c0fd104bfce4966a6af4c66d4ff4e032ea 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/delay.h>
index b4bbf8f2c2381bb0f4de4d0042b85b2260a843d0..0e8b8ab1d1682c7513348816f65ffbc36d6f2b4e 100644 (file)
@@ -379,7 +379,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                u8 devctl, u8 power)
 {
        irqreturn_t handled = IRQ_NONE;
-       void __iomem *mbase = musb->mregs;
 
        DBG(3, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
                int_usb);
@@ -394,6 +393,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
 
                if (devctl & MUSB_DEVCTL_HM) {
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
+                       void __iomem *mbase = musb->mregs;
+
                        switch (musb->xceiv->state) {
                        case OTG_STATE_A_SUSPEND:
                                /* remote wakeup?  later, GetPortStatus
@@ -471,6 +472,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
        /* see manual for the order of the tests */
        if (int_usb & MUSB_INTR_SESSREQ) {
+               void __iomem *mbase = musb->mregs;
+
                DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb));
 
                /* IRQ arrives from ID pin sense or (later, if VBUS power
@@ -519,6 +522,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                case OTG_STATE_A_WAIT_BCON:
                case OTG_STATE_A_WAIT_VRISE:
                        if (musb->vbuserr_retry) {
+                               void __iomem *mbase = musb->mregs;
+
                                musb->vbuserr_retry--;
                                ignore = 1;
                                devctl |= MUSB_DEVCTL_SESSION;
@@ -622,6 +627,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
 
        if (int_usb & MUSB_INTR_CONNECT) {
                struct usb_hcd *hcd = musb_to_hcd(musb);
+               void __iomem *mbase = musb->mregs;
 
                handled = IRQ_HANDLED;
                musb->is_active = 1;
@@ -2007,7 +2013,6 @@ bad_config:
        /* host side needs more setup */
        if (is_host_enabled(musb)) {
                struct usb_hcd  *hcd = musb_to_hcd(musb);
-               u8 busctl;
 
                otg_set_host(musb->xceiv, &hcd->self);
 
@@ -2018,9 +2023,9 @@ bad_config:
 
                /* program PHY to use external vBus if required */
                if (plat->extvbus) {
-                       busctl = musb_readb(musb->mregs, MUSB_ULPI_BUSCONTROL);
+                       u8 busctl = musb_read_ulpi_buscontrol(musb->mregs);
                        busctl |= MUSB_ULPI_USE_EXTVBUS;
-                       musb_writeb(musb->mregs, MUSB_ULPI_BUSCONTROL, busctl);
+                       musb_write_ulpi_buscontrol(musb->mregs, busctl);
                }
        }
 
index d849fb81c131cb6cae9bcb3f9d7ce58020219c46..cd9f4a9a06c6408288a861727790eae9776870ff 100644 (file)
@@ -469,7 +469,7 @@ struct musb_csr_regs {
 
 struct musb_context_registers {
 
-#if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430)
+#ifdef CONFIG_PM
        u32 otg_sysconfig, otg_forcestandby;
 #endif
        u8 power;
@@ -483,7 +483,7 @@ struct musb_context_registers {
        struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
 };
 
-#if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430)
+#ifdef CONFIG_PM
 extern void musb_platform_save_context(struct musb *musb,
                struct musb_context_registers *musb_context);
 extern void musb_platform_restore_context(struct musb *musb,
index a9f288cd70ed2817ce36fceb4a006888e79e5233..6fca870e957ed3b5061f19deec76a9472d6d5211 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/moduleparam.h>
 #include <linux/stat.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include "musb_core.h"
 
index 3421cf9858b5100ee3eddd2093af35aaf1dc7f25..dec896e888db3ad93e64bf7925c650851039ecc3 100644 (file)
@@ -1689,7 +1689,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
                                dma->desired_mode = 1;
                        if (rx_count < hw_ep->max_packet_sz_rx) {
                                length = rx_count;
-                               dma->bDesiredMode = 0;
+                               dma->desired_mode = 0;
                        } else {
                                length = urb->transfer_buffer_length;
                        }
index 8d8062b10e2ff5749394bb9f64099fdbab2adfdb..fa55aacc385d3541b6fa162e4ee00000c96cd7a2 100644 (file)
@@ -326,6 +326,11 @@ static inline void  musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
        musb_writew(mbase, MUSB_RXFIFOADD, c_off);
 }
 
+static inline void musb_write_ulpi_buscontrol(void __iomem *mbase, u8 val)
+{
+       musb_writeb(mbase, MUSB_ULPI_BUSCONTROL, val);
+}
+
 static inline u8 musb_read_txfifosz(void __iomem *mbase)
 {
        return musb_readb(mbase, MUSB_TXFIFOSZ);
@@ -346,6 +351,11 @@ static inline u16  musb_read_rxfifoadd(void __iomem *mbase)
        return musb_readw(mbase, MUSB_RXFIFOADD);
 }
 
+static inline u8 musb_read_ulpi_buscontrol(void __iomem *mbase)
+{
+       return musb_readb(mbase, MUSB_ULPI_BUSCONTROL);
+}
+
 static inline u8 musb_read_configdata(void __iomem *mbase)
 {
        musb_writeb(mbase, MUSB_INDEX, 0);
@@ -510,20 +520,33 @@ static inline void  musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
 {
 }
 
+static inline void musb_write_ulpi_buscontrol(void __iomem *mbase, u8 val)
+{
+}
+
 static inline u8 musb_read_txfifosz(void __iomem *mbase)
 {
+       return 0;
 }
 
 static inline u16 musb_read_txfifoadd(void __iomem *mbase)
 {
+       return 0;
 }
 
 static inline u8 musb_read_rxfifosz(void __iomem *mbase)
 {
+       return 0;
 }
 
 static inline u16  musb_read_rxfifoadd(void __iomem *mbase)
 {
+       return 0;
+}
+
+static inline u8 musb_read_ulpi_buscontrol(void __iomem *mbase)
+{
+       return 0;
 }
 
 static inline u8 musb_read_configdata(void __iomem *mbase)
@@ -577,22 +600,27 @@ static inline void  musb_write_txhubport(void __iomem *mbase, u8 epnum,
 
 static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum)
 {
+       return 0;
 }
 
 static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum)
 {
+       return 0;
 }
 
 static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum)
 {
+       return 0;
 }
 
 static inline u8  musb_read_txfunaddr(void __iomem *mbase, u8 epnum)
 {
+       return 0;
 }
 
 static inline u8  musb_read_txhubaddr(void __iomem *mbase, u8 epnum)
 {
+       return 0;
 }
 
 static inline void  musb_read_txhubport(void __iomem *mbase, u8 epnum)
index bfe5fe4ebfeeb87b49e6f762aa670d0aed4da8aa..7775e1c0a215fd81b780bf54ba024845868f0fda 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/time.h>
index 2fa7d5c00f313eadf7c83c061a9b0774c74279fa..1008044a3bbc38efc580ae72211fd7a33b29d4d3 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include "musb_core.h"
 #include "musbhsdma.h"
 
index 3fe16867b5a87f0338f861f1b37901eb3ad15a7f..490cdf15ccb6ee68f6176f97727ff82756726f4c 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/clk.h>
index 1c868096bd6fb2697adff17fe018d5ec4400b11a..5afa070d7dc95aae24fdb0792c3e92e3b05a1b6c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/usb.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <plat/dma.h>
 #include <plat/mux.h>
 
index 1c26c94513e9e5bd14299d1ae046125a6d1cce07..221c44444ec677a5679d15a86b2dd9fd0a5e72be 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/usb.h>
 #include <linux/workqueue.h>
index af456b48985f06f3ebe09ae43363f47f7d0bfec7..e70014ab0976ae0ea737c8faa210544c233d4dcd 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/usb/otg.h>
+#include <linux/slab.h>
 
 struct nop_usb_xceiv {
        struct otg_transceiver  otg;
index 3e4e9f434d78d31f6f6699c0e507a1e6e09e91a7..223cdf46ccb78cad3b7aa4d0e2b0da72b93db72b 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
 #include <linux/notifier.h>
+#include <linux/slab.h>
 
 /* Register defines */
 
index 896527456b7e4fee4632672b47c9822d39d33da6..9010225e0d063a6be854000a43efea8f6faebcf3 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
index c78b255e3f831ee7cd086c6053f7728915062783..a0ecb42cb33a13cf5b7518bc5b2344f6d71e192f 100644 (file)
@@ -474,14 +474,14 @@ config USB_SERIAL_OTI6858
 
 config USB_SERIAL_QCAUX
        tristate "USB Qualcomm Auxiliary Serial Port Driver"
-       ---help---
+       help
          Say Y here if you want to use the auxiliary serial ports provided
          by many modems based on Qualcomm chipsets.  These ports often use
          a proprietary protocol called DM and cannot be used for AT- or
          PPP-based communication.
 
          To compile this driver as a module, choose M here: the
-         module will be called moto_modem.  If unsure, choose N.
+         module will be called qcaux.  If unsure, choose N.
 
 config USB_SERIAL_QUALCOMM
        tristate "USB Qualcomm Serial modem"
index 365db1097bfdbdca5761fff631a8b37b6f280c10..4fd7af98b1aeb267c63328646708f93924a10bb2 100644 (file)
@@ -43,6 +43,7 @@
  */
 
 #include <linux/tty.h>
+#include <linux/slab.h>
 #include <linux/tty_flip.h>
 #include <linux/circ_buf.h>
 #include <linux/usb.h>
index 547c9448c28c345fd2f90966e3410b8e7949f2d3..9b66bf19f751061ce998bde586908275dda40a99 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/ioctl.h>
 #include <linux/tty.h>
+#include <linux/slab.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/usb.h>
index ba555c528cc6cc8c5b88356140cd0a4e288d1ed1..7f547dc3a5903fd25e0837441115007320ae122d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
index 9f4fed1968b52ae64e9c58f0132fd5571efde772..7e8e398184145f3d36e14a4632c9984378c44469 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/tty.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include <linux/serial.h>
index b22ac3258523af80e46a63fd0660117e51232553..f347da2ef00a04c6c8a875e54657c1eb5c87edb4 100644 (file)
@@ -181,6 +181,7 @@ static int usb_console_setup(struct console *co, char *options)
        /* The console is special in terms of closing the device so
         * indicate this port is now acting as a system console. */
        port->console = 1;
+       port->port.console = 1;
 
        mutex_unlock(&serial->disc_mutex);
        return retval;
index 507382b0a9ed1d377330344c62024fbd8e661d9d..ec9b0449ccf6658bbd013ef3a18989a34f1afcf2 100644 (file)
@@ -313,11 +313,6 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
                return -EPROTO;
        }
 
-       /* Single data value */
-       result = usb_control_msg(serial->dev,
-                       usb_sndctrlpipe(serial->dev, 0),
-                       request, REQTYPE_HOST_TO_DEVICE, data[0],
-                       0, NULL, 0, 300);
        return 0;
 }
 
index 6af0dfa5f5ac22e31a0fc9d70c8996ba33cbe53a..1d7c4fac02e8e14db7bc0f12017194be8041226c 100644 (file)
@@ -91,7 +91,7 @@ struct ftdi_private {
        unsigned long tx_outstanding_bytes;
        unsigned long tx_outstanding_urbs;
        unsigned short max_packet_size;
-       struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() */
+       struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
 };
 
 /* struct ftdi_sio_quirk is used by devices requiring special attention. */
@@ -658,6 +658,7 @@ static struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
        { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
        { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
+       { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
@@ -1272,8 +1273,8 @@ check_and_exit:
             (priv->flags & ASYNC_SPD_MASK)) ||
            (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
             (old_priv.custom_divisor != priv->custom_divisor))) {
-               mutex_unlock(&priv->cfg_lock);
                change_speed(tty, port);
+               mutex_unlock(&priv->cfg_lock);
        }
        else
                mutex_unlock(&priv->cfg_lock);
@@ -2264,9 +2265,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
                clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
        } else {
                /* set the baudrate determined before */
+               mutex_lock(&priv->cfg_lock);
                if (change_speed(tty, port))
                        dev_err(&port->dev, "%s urb failed to set baudrate\n",
                                __func__);
+               mutex_unlock(&priv->cfg_lock);
                /* Ensure RTS and DTR are raised when baudrate changed from 0 */
                if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
                        set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
index 0727e198503e5b402af505b2e5ef286937f325b5..75482cbc39989fb51059f9de69781c82717eef92 100644 (file)
 #define CONTEC_VID             0x06CE  /* Vendor ID */
 #define CONTEC_COM1USBH_PID    0x8311  /* COM-1(USB)H */
 
+/*
+ * Contec products (http://www.contec.com)
+ * Submitted by Daniel Sangorrin
+ */
+#define CONTEC_VID             0x06CE  /* Vendor ID */
+#define CONTEC_COM1USBH_PID    0x8311  /* COM-1(USB)H */
+
 /*
  * Definitions for B&B Electronics products.
  */
index 89fac36684c56d83caa67e9426c723e3cfb00009..f804acb138ec508f85fe63481b9b6622e084ace1 100644 (file)
@@ -130,7 +130,7 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
        spin_unlock_irqrestore(&port->lock, flags);
 
        /* if we have a bulk endpoint, start reading from it */
-       if (serial->num_bulk_in) {
+       if (port->bulk_in_size) {
                /* Start reading from the device */
                usb_fill_bulk_urb(port->read_urb, serial->dev,
                                   usb_rcvbulkpipe(serial->dev,
@@ -159,10 +159,10 @@ static void generic_cleanup(struct usb_serial_port *port)
        dbg("%s - port %d", __func__, port->number);
 
        if (serial->dev) {
-               /* shutdown any bulk reads that might be going on */
-               if (serial->num_bulk_out)
+               /* shutdown any bulk transfers that might be going on */
+               if (port->bulk_out_size)
                        usb_kill_urb(port->write_urb);
-               if (serial->num_bulk_in)
+               if (port->bulk_in_size)
                        usb_kill_urb(port->read_urb);
        }
 }
@@ -333,15 +333,15 @@ int usb_serial_generic_write(struct tty_struct *tty,
 
        dbg("%s - port %d", __func__, port->number);
 
+       /* only do something if we have a bulk out endpoint */
+       if (!port->bulk_out_size)
+               return -ENODEV;
+
        if (count == 0) {
                dbg("%s - write request of 0 bytes", __func__);
                return 0;
        }
 
-       /* only do something if we have a bulk out endpoint */
-       if (!serial->num_bulk_out)
-               return 0;
-
        if (serial->type->max_in_flight_urbs)
                return usb_serial_multi_urb_write(tty, port,
                                                  buf, count);
@@ -364,14 +364,19 @@ int usb_serial_generic_write_room(struct tty_struct *tty)
        int room = 0;
 
        dbg("%s - port %d", __func__, port->number);
+
+       if (!port->bulk_out_size)
+               return 0;
+
        spin_lock_irqsave(&port->lock, flags);
        if (serial->type->max_in_flight_urbs) {
                if (port->urbs_in_flight < serial->type->max_in_flight_urbs)
                        room = port->bulk_out_size *
                                (serial->type->max_in_flight_urbs -
                                 port->urbs_in_flight);
-       } else if (serial->num_bulk_out)
+       } else {
                room = kfifo_avail(&port->write_fifo);
+       }
        spin_unlock_irqrestore(&port->lock, flags);
 
        dbg("%s - returns %d", __func__, room);
@@ -382,15 +387,18 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
-       int chars = 0;
        unsigned long flags;
+       int chars;
 
        dbg("%s - port %d", __func__, port->number);
 
+       if (!port->bulk_out_size)
+               return 0;
+
        spin_lock_irqsave(&port->lock, flags);
        if (serial->type->max_in_flight_urbs)
                chars = port->tx_bytes_flight;
-       else if (serial->num_bulk_out)
+       else
                chars = kfifo_len(&port->write_fifo);
        spin_unlock_irqrestore(&port->lock, flags);
 
@@ -415,11 +423,13 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
                           ((serial->type->read_bulk_callback) ?
                             serial->type->read_bulk_callback :
                             usb_serial_generic_read_bulk_callback), port);
+
        result = usb_submit_urb(urb, mem_flags);
-       if (result)
+       if (result && result != -EPERM) {
                dev_err(&port->dev,
                        "%s - failed resubmitting read urb, error %d\n",
                                                        __func__, result);
+       }
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb);
 
@@ -498,23 +508,18 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
                if (port->urbs_in_flight < 0)
                        port->urbs_in_flight = 0;
                spin_unlock_irqrestore(&port->lock, flags);
-
-               if (status) {
-                       dbg("%s - nonzero multi-urb write bulk status "
-                               "received: %d", __func__, status);
-                       return;
-               }
        } else {
                port->write_urb_busy = 0;
 
-               if (status) {
-                       dbg("%s - nonzero multi-urb write bulk status "
-                               "received: %d", __func__, status);
+               if (status)
                        kfifo_reset_out(&port->write_fifo);
-               else
+               else
                        usb_serial_generic_write_start(port);
        }
 
+       if (status)
+               dbg("%s - non-zero urb status: %d", __func__, status);
+
        usb_serial_port_softint(port);
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
index 04a6cbbed2c0f1de6837d9b3d611a3f543e18e97..a6b207c84917425db5f4c9ea1a1da075a6798002 100644 (file)
@@ -12,6 +12,7 @@
  *     flags as the navman is rx only so cannot echo.
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/tty.h>
index 701452ae91979a23129d24d656a5e4a2df7b8946..ed01f3b2de8c037675667cedabf19040fa81c876 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
+#include <linux/slab.h>
 #include <linux/tty_flip.h>
 #include <linux/serial.h>
 #include <linux/module.h>
index 847b805d63a3b7444b554462efb4c78dc4581fba..ca9d866672aa8f10ef2be1727b76f62fa6ffaca5 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/errno.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/usb.h>
@@ -288,7 +289,9 @@ static int  option_resume(struct usb_serial *serial);
 
 #define QUALCOMM_VENDOR_ID                     0x05C6
 
-#define MAXON_VENDOR_ID                                0x16d8
+#define CMOTECH_VENDOR_ID                      0x16d8
+#define CMOTECH_PRODUCT_6008                   0x6008
+#define CMOTECH_PRODUCT_6280                   0x6280
 
 #define TELIT_VENDOR_ID                                0x1bc7
 #define TELIT_PRODUCT_UC864E                   0x1003
@@ -309,6 +312,7 @@ static int  option_resume(struct usb_serial *serial);
 #define DLINK_VENDOR_ID                                0x1186
 #define DLINK_PRODUCT_DWM_652                  0x3e04
 #define DLINK_PRODUCT_DWM_652_U5               0xce16
+#define DLINK_PRODUCT_DWM_652_U5A              0xce1e
 
 #define QISDA_VENDOR_ID                                0x1da5
 #define QISDA_PRODUCT_H21_4512                 0x4512
@@ -332,6 +336,24 @@ static int  option_resume(struct usb_serial *serial);
 #define ALCATEL_VENDOR_ID                      0x1bbb
 #define ALCATEL_PRODUCT_X060S                  0x0000
 
+#define PIRELLI_VENDOR_ID                      0x1266
+#define PIRELLI_PRODUCT_C100_1                 0x1002
+#define PIRELLI_PRODUCT_C100_2                 0x1003
+#define PIRELLI_PRODUCT_1004                   0x1004
+#define PIRELLI_PRODUCT_1005                   0x1005
+#define PIRELLI_PRODUCT_1006                   0x1006
+#define PIRELLI_PRODUCT_1007                   0x1007
+#define PIRELLI_PRODUCT_1008                   0x1008
+#define PIRELLI_PRODUCT_1009                   0x1009
+#define PIRELLI_PRODUCT_100A                   0x100a
+#define PIRELLI_PRODUCT_100B                   0x100b
+#define PIRELLI_PRODUCT_100C                   0x100c
+#define PIRELLI_PRODUCT_100D                   0x100d
+#define PIRELLI_PRODUCT_100E                   0x100e
+#define PIRELLI_PRODUCT_100F                   0x100f
+#define PIRELLI_PRODUCT_1011                   0x1011
+#define PIRELLI_PRODUCT_1012                   0x1012
+
 /* Airplus products */
 #define AIRPLUS_VENDOR_ID                      0x1011
 #define AIRPLUS_PRODUCT_MCD650                 0x3198
@@ -547,7 +569,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
-       { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
+       { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
+       { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
        { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -659,6 +682,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
        { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
        { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
+       { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
        { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
        { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
        { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
@@ -666,7 +690,6 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
        { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
        { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
-       { USB_DEVICE(ALINK_VENDOR_ID, 0xce16) },
        { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
        { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) },
        { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
@@ -675,6 +698,24 @@ static const struct usb_device_id option_ids[] = {
          .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
        },
        { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
+       /* Pirelli  */
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) },
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) },
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) },
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) },
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) },
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)},
+       { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)},
+
        { } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, option_ids);
@@ -798,12 +839,19 @@ static int option_probe(struct usb_serial *serial,
                        const struct usb_device_id *id)
 {
        struct option_intf_private *data;
+
        /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
        if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
                serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
                serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
                return -ENODEV;
 
+       /* Bandrich modem and AT command interface is 0xff */
+       if ((serial->dev->descriptor.idVendor == BANDRICH_VENDOR_ID ||
+               serial->dev->descriptor.idVendor == PIRELLI_VENDOR_ID) &&
+               serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff)
+               return -ENODEV;
+
        data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
index 310ff6ec65678d1c38da316cfdb4fe8a06936c52..53a2d5a935a24505bead07eaeec3da5a01566ed8 100644 (file)
@@ -47,6 +47,35 @@ static const struct usb_device_id id_table[] = {
        {USB_DEVICE(0x05c6, 0x9221)},   /* Generic Gobi QDL device */
        {USB_DEVICE(0x05c6, 0x9231)},   /* Generic Gobi QDL device */
        {USB_DEVICE(0x1f45, 0x0001)},   /* Unknown Gobi QDL device */
+       {USB_DEVICE(0x413c, 0x8185)},   /* Dell Gobi 2000 QDL device (N0218, VU936) */
+       {USB_DEVICE(0x413c, 0x8186)},   /* Dell Gobi 2000 Modem device (N0218, VU936) */
+       {USB_DEVICE(0x05c6, 0x9224)},   /* Sony Gobi 2000 QDL device (N0279, VU730) */
+       {USB_DEVICE(0x05c6, 0x9225)},   /* Sony Gobi 2000 Modem device (N0279, VU730) */
+       {USB_DEVICE(0x05c6, 0x9244)},   /* Samsung Gobi 2000 QDL device (VL176) */
+       {USB_DEVICE(0x05c6, 0x9245)},   /* Samsung Gobi 2000 Modem device (VL176) */
+       {USB_DEVICE(0x03f0, 0x241d)},   /* HP Gobi 2000 QDL device (VP412) */
+       {USB_DEVICE(0x03f0, 0x251d)},   /* HP Gobi 2000 Modem device (VP412) */
+       {USB_DEVICE(0x05c6, 0x9214)},   /* Acer Gobi 2000 QDL device (VP413) */
+       {USB_DEVICE(0x05c6, 0x9215)},   /* Acer Gobi 2000 Modem device (VP413) */
+       {USB_DEVICE(0x05c6, 0x9264)},   /* Asus Gobi 2000 QDL device (VR305) */
+       {USB_DEVICE(0x05c6, 0x9265)},   /* Asus Gobi 2000 Modem device (VR305) */
+       {USB_DEVICE(0x05c6, 0x9234)},   /* Top Global Gobi 2000 QDL device (VR306) */
+       {USB_DEVICE(0x05c6, 0x9235)},   /* Top Global Gobi 2000 Modem device (VR306) */
+       {USB_DEVICE(0x05c6, 0x9274)},   /* iRex Technologies Gobi 2000 QDL device (VR307) */
+       {USB_DEVICE(0x05c6, 0x9275)},   /* iRex Technologies Gobi 2000 Modem device (VR307) */
+       {USB_DEVICE(0x1199, 0x9000)},   /* Sierra Wireless Gobi 2000 QDL device (VT773) */
+       {USB_DEVICE(0x1199, 0x9001)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9002)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9003)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9004)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9005)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9006)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9007)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9008)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x9009)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x1199, 0x900a)},   /* Sierra Wireless Gobi 2000 Modem device (VT773) */
+       {USB_DEVICE(0x16d8, 0x8001)},   /* CMDTech Gobi 2000 QDL device (VU922) */
+       {USB_DEVICE(0x16d8, 0x8002)},   /* CMDTech Gobi 2000 Modem device (VU922) */
        { }                             /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, id_table);
index 4b463cd140ef6436b392a8a5255c6c6cf5d523b5..43a0cadd5782361e0f4753c1ce586c184c7a0bb9 100644 (file)
@@ -64,8 +64,8 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
index 34e6f894cba9c422769c4607d49d2fd8081b7747..9202f94505e649ddd26b4e7f09c6b0f854b04bac 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/jiffies.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
+#include <linux/slab.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/usb.h>
index ee190cc1757ce84dd0b78114fb9ca190b1c7e9e1..d9457bd4fe10a925423b9f3f1d3b5670e5ac5822 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/tty.h>
+#include <linux/slab.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
index 252cc2d993b2992b7bbb7480f76c3760800322f3..28026b47344a2bee655a776f5cd5b72a79dede08 100644 (file)
@@ -8,6 +8,7 @@
  *     2 as published by the Free Software Foundation.
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/tty.h>
index 67edc65acb8efc69e8a214fd032aa4da7c6eebaf..42d0eaed4a0133282678792d9d74bd7ebc4045a7 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 7953d93a7739bd6ac5d89902a7f257e3c8d3c37d..ba1b789068802c138549e96542fa18a7dac8952d 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
index 773a5cd38c5aa7773f5b7f1837351a8945b3f084..89460181d122759ba00ff064b49b2ff3c8b28268 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "usb.h"
 #include "transport.h"
index 4cc035562cc2e0669e588d4a376ad9bf1c25b032..d8d98cfecadad457ddde6393730af86f097d39d4 100644 (file)
@@ -43,7 +43,6 @@
  * 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 
index 4395c4100ec2096313933d029e8b25191eefe6c9..57fc2f532cabe985b9b10fdd57c7042b6d0fd4be 100644 (file)
@@ -3,6 +3,7 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "usb.h"
 #include "transport.h"
index 468038126e5eb00ba5180585a8923575103be9d0..f253edec3bb827c29a0d90173fd7cafa18173b00 100644 (file)
@@ -44,8 +44,8 @@
  */
 
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 
 #include <linux/usb/quirks.h>
 
index 98b549b1cab25f0799c8846aaa43edc98e4c8cc7..ccf1dbbb87efd60e930a4d9a4fdfc62a80759fae 100644 (file)
@@ -374,6 +374,15 @@ UNUSUAL_DEV(  0x04ce, 0x0002, 0x0074, 0x0074,
                US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY),
 
+/* Reported by Ondrej Zary <linux@rainbow-software.org>
+ * The device reports one sector more and breaks when that sector is accessed
+ */
+UNUSUAL_DEV(  0x04ce, 0x0002, 0x026c, 0x026c,
+               "ScanLogic",
+               "SL11R-IDE",
+               US_SC_DEVICE, US_PR_DEVICE, NULL,
+               US_FL_FIX_CAPACITY),
+
 /* Reported by Kriston Fincher <kriston@airmail.net>
  * Patch submitted by Sean Millichamp <sean@bruenor.org>
  * This is to support the Panasonic PalmCam PV-SD4090
@@ -1380,20 +1389,6 @@ UNUSUAL_DEV(  0x0f19, 0x0105, 0x0100, 0x0100,
                US_SC_DEVICE, US_PR_DEVICE, NULL,
                US_FL_IGNORE_RESIDUE ),
 
-/* Jeremy Katz <katzj@redhat.com>:
- * The Blackberry Pearl can run in two modes; a usb-storage only mode
- * and a mode that allows access via mass storage and to its database.
- * The berry_charge module will set the device to dual mode and thus we
- * should ignore its native mode if that module is built
- */
-#ifdef CONFIG_USB_BERRY_CHARGE
-UNUSUAL_DEV(  0x0fca, 0x0006, 0x0001, 0x0001,
-               "RIM",
-               "Blackberry Pearl",
-               US_SC_DEVICE, US_PR_DEVICE, NULL,
-               US_FL_IGNORE_DEVICE ),
-#endif
-
 /* Reported by Michael Stattmann <michael@stattmann.com> */
 UNUSUAL_DEV(  0x0fce, 0xd008, 0x0000, 0x0000,
                "Sony Ericsson",
index 51a8e0d5789d0da9654e13dca6e6ab53290d51cc..c0c5665e60a917de8ca6680164bfd598b0d4f83c 100644 (file)
@@ -92,6 +92,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/uwb.h>
 #include <linux/usb/wusb.h>
index 9579cf4c38bf6717c56e3677938e6afb19f022b9..827c87f10cc5a80c06f84afd38d7d66b7249f0d6 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/uwb.h>
+#include <linux/slab.h>
 #include <linux/usb/wusb.h>
 #include <linux/scatterlist.h>
 
index 1c918286159cd683f71916c891ba9cd7d6f5753e..46e79d3494986a44896884d0a42dde65e18f43f6 100644 (file)
@@ -88,6 +88,7 @@
 
 #include <linux/jiffies.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include "wusbhc.h"
 
index 2d827397e30b2dbddd121342a8899d9e028b0867..0a57ff0a0b0c6df4b802f5ff5316ceb77ae7a2a1 100644 (file)
@@ -37,6 +37,7 @@
  *  - add timers that autoremove intervalled IEs?
  */
 #include <linux/usb/wusb.h>
+#include <linux/slab.h>
 #include "wusbhc.h"
 
 /* Initialize the MMCIEs handling mechanism */
index 9fe4246cecb98d5bb5fa2cb77ca23bd3bae90c9e..a68ad7aa0b592948e0c5168435b609d174231ea1 100644 (file)
@@ -69,6 +69,7 @@
  *
  * wusbhc_rh_start_port_reset() ??? unimplemented
  */
+#include <linux/slab.h>
 #include "wusbhc.h"
 
 /*
index edcd2d7560378f1681f8c2ec74dc042a4e0815f6..b60799b811c144e5513e9e201f2f6fb38b5a709b 100644 (file)
@@ -23,6 +23,7 @@
  * FIXME: docs
  */
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/usb/ch9.h>
 #include <linux/random.h>
 #include "wusbhc.h"
index 9d04722415bb5bbf8f14bc63e903f165720635dd..59a748a0e5dae07cbaa1ae5107654b9666712156 100644 (file)
@@ -22,6 +22,7 @@
  *
  * FIXME: docs
  */
+#include <linux/slab.h>
 #include "wusbhc.h"
 #include "wa-hc.h"
 
index 17d2626038be6ab1ef085c820f88eb8d4ff14647..f67f7f1e6df9502680868d2bfa5e0493df0cf36d 100644 (file)
@@ -51,6 +51,7 @@
  */
 #include <linux/workqueue.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 
 #include "wa-hc.h"
 #include "wusbhc.h"
index 7369655f69cdc9722f0aa281e3803748e13fa2dc..c7b1d8108de94338ea610f1286134a74fe13f593 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/init.h>
 #include <asm/atomic.h>
 #include <linux/bitmap.h>
+#include <linux/slab.h>
 
 #include "wusbhc.h"
 #include "wa-hc.h"
index 489b47833e2c54ff7f1b225c35f1a51283ef2494..112ef7e26f6bf69af4f32c78d4255b68af2e554a 100644 (file)
@@ -81,6 +81,7 @@
  */
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/hash.h>
 
 #include "wa-hc.h"
index ad21b1d7218cb327be2e4d4ab22d861f8f023130..973321327c44b897ae3ae14eb95f2d33b784732f 100644 (file)
@@ -23,6 +23,7 @@
  * FIXME: docs
  */
 
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/device.h>
index c13cec7dcbc5ee6cdfa6a6ee0ff29280de910ce3..436e4f7110cbddc41cda3d4677fdb2eca6c0ab17 100644 (file)
@@ -16,6 +16,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/uwb.h>
 
 #include "uwb-internal.h"
index 36bc3158006f5e21012e0d79af888ff27605c99b..dcdd59bfcd09cff5e7cc0d9235af3850dad287e5 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/kdev_t.h>
+#include <linux/slab.h>
 
 #include "uwb-internal.h"
 
index 2840d7bf9e67eff12c9b743c04eb01c0120763cd..520673109a7ea7a63627cc3f697ea419b6d355f6 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/uwb.h>
 
 #include "uwb-internal.h"
index 4f5ca99a04b9de20c513b015e84e7b6d0ad972e3..a8d83e25e3b66e21bb3ac48f2548b9334dbaf8ee 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include "uwb-internal.h"
 
index 328fcc2b60990af30a56eb35896b0a3db322bae8..a2eaa3c33b0b2b90a870bf775aeb274213eacc47 100644 (file)
@@ -40,6 +40,7 @@
  *   uwb_est_get_size()
  */
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include "uwb-internal.h"
 
index e7eeb63fab23a11632a1b94176def00e28bc9d27..2babcd4fbfc13b6bebd4238444925eca6f99e401 100644 (file)
@@ -53,6 +53,7 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/wusb.h>
 #include <linux/usb/wusb-wa.h>
@@ -891,7 +892,7 @@ static int hwarc_post_reset(struct usb_interface *iface)
 }
 
 /** USB device ID's that we handle */
-static struct usb_device_id hwarc_id_table[] = {
+static const struct usb_device_id hwarc_id_table[] = {
        /* D-Link DUB-1210 */
        { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02),
          .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
index 694d0daf88aba1594bcc0d259e01fc4e89e6f137..6ec14f5fcde47f951fd8b1092f82deb0940fdeeb 100644 (file)
@@ -28,6 +28,7 @@
  */
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <linux/uwb.h>
 #include "i1480-dfu.h"
 
index 0bb665a0c02454e41745d55a129c35bb65f40b84..ba8664328afa965ab63d5b2ee305a517fa0ed9a2 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/module.h>
 #include <linux/usb.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/uwb.h>
 #include <linux/usb/wusb.h>
@@ -120,8 +121,7 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address,
                result = usb_control_msg(
                        i1480_usb->usb_dev, usb_sndctrlpipe(i1480_usb->usb_dev, 0),
                        0xf0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-                       cpu_to_le16(memory_address & 0xffff),
-                       cpu_to_le16((memory_address >> 16) & 0xffff),
+                       memory_address, (memory_address >> 16),
                        i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */);
                if (result < 0)
                        break;
@@ -166,8 +166,7 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size)
                result = usb_control_msg(
                        i1480_usb->usb_dev, usb_rcvctrlpipe(i1480_usb->usb_dev, 0),
                        0xf0, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-                       cpu_to_le16(itr_addr & 0xffff),
-                       cpu_to_le16((itr_addr >> 16) & 0xffff),
+                       itr_addr, (itr_addr >> 16),
                        i1480->cmd_buf + itr, itr_size,
                        100 /* FIXME: arbitrary */);
                if (result < 0) {
@@ -413,6 +412,10 @@ error:
        return result;
 }
 
+MODULE_FIRMWARE("i1480-pre-phy-0.0.bin");
+MODULE_FIRMWARE("i1480-usb-0.0.bin");
+MODULE_FIRMWARE("i1480-phy-0.0.bin");
+
 #define i1480_USB_DEV(v, p)                            \
 {                                                      \
        .match_flags = USB_DEVICE_ID_MATCH_DEVICE       \
@@ -430,7 +433,7 @@ error:
 
 
 /** USB device ID's that we handle */
-static struct usb_device_id i1480_usb_id_table[] = {
+static const struct usb_device_id i1480_usb_id_table[] = {
        i1480_USB_DEV(0x8086, 0xdf3b),
        i1480_USB_DEV(0x15a9, 0x0005),
        i1480_USB_DEV(0x07d1, 0x3802),
index f272dfe54d491ed75dc0a0a8d0b3e3450f6f7e32..def778cf221690846df58dafe75794aaded7184a 100644 (file)
@@ -55,6 +55,7 @@
  *                          is being removed.
  *         i1480u_rm()
  */
+#include <linux/gfp.h>
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
 
index b236e6969942f29b4031095e000e2ed4d6d287b0..f98f6ce8b9e7372f0605ab06aaea752fc0f81f8b 100644 (file)
@@ -39,6 +39,7 @@
  *     i1480u_set_config():
  */
 
+#include <linux/slab.h>
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
 
index 25a2758beb61d2d078d51de5847e30d92dd42c82..d4e51e108aa4aa52d5dc015430575f9920bba535 100644 (file)
@@ -64,6 +64,7 @@
  *
  */
 
+#include <linux/gfp.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include "i1480u-wlp.h"
index 3db3449dbda46962171f71acdf3ebca250a4d860..3c117a3645642e142c9e251910233f12e8ea9c6a 100644 (file)
@@ -54,6 +54,7 @@
  *          the times the MTU will be smaller than one page...
  */
 
+#include <linux/slab.h>
 #include "i1480u-wlp.h"
 
 enum {
index ab976686175be5694589192636d69d685979b90c..30acec740425e48ea48c1e11d32028bbd837d710 100644 (file)
@@ -24,6 +24,7 @@
  * FIXME: docs
  */
 
+#include <linux/slab.h>
 #include "uwb-internal.h"
 
 /**
index 1097e81b56d01029f9ec8aac68fdb262c9874ed9..90113bafefca8dafbd4aa210fc2ef81887238cae 100644 (file)
@@ -23,6 +23,7 @@
  * FIXME: docs
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/kdev_t.h>
index 9611ef3b787a39c3de7b295c39d99a7e376a2afe..b0091c771b9a2d3c8d29fd782000df41cc777c31 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/kdev_t.h>
 #include <linux/etherdevice.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "uwb-internal.h"
 
index 78510a1f410d793350d5b3a1efe55247bf0f8029..697e56a5bcdd0c7e4233774ce2670b70ae8a9373 100644 (file)
@@ -83,6 +83,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 
 #include "uwb-internal.h"
index 7f0512e43d9dea10c5005e298ac0902c32ae0c70..27849292b552aab93c7ac3be1eae6650607a1d1a 100644 (file)
@@ -30,6 +30,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include "uwb-internal.h"
index 6b76f4bb4cc7dc5a25da658c0cc2d006ba3662f0..78c892233cf1d9acb2eac33e87b5e41f8a3bb79e 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/uwb.h>
+#include <linux/slab.h>
 #include <linux/random.h>
 
 #include "uwb-internal.h"
index 2d270748f32be0fdf4eda5e12f36a1031fe6a5e3..76a1a1ed7d3ec1e5831ca1d8024367e676cac266 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include "uwb-internal.h"
 
 
index 1fc7d8270bb83054198f141fd8b6ec6911411b52..43ea9982e68776a37c80f33ff19e2624fbec546d 100644 (file)
@@ -6,6 +6,7 @@
  * This file is released under the GNU GPL v2.
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/uwb/umc.h>
 
 static void umc_device_release(struct device *dev)
index 6210fe1fd1bbfb64b9015a03da8dbb37a5a2b753..001c8b4020a84c7073f2fc99489bf9047571e086 100644 (file)
@@ -69,6 +69,7 @@
  * Handler functions are called normally uwbd_evt_handle_*().
  */
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/freezer.h>
 
index 01950c62dc8dd4ca58e1e4e0700f5e9b51771dc7..73495583c4444bba046779115b56c905e2c0c424 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/sched.h>
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/uwb.h>
 #include <linux/uwb/whci.h>
index 2e2784627ad66cf8502361fa59c2ad029e138d82..b221142446a29d5690d332628389cd763856fa32 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/uwb/whci.h>
 #include <linux/uwb/umc.h>
 
index 69e020039718aed4711849b0b9fee3c80dfea866..086fc0cf94019f657757af6ba959b39afeb07d64 100644 (file)
@@ -53,6 +53,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/wlp.h>
 #include "wlp-internal.h"
 
index aa42fcee4c4f8e052a2e25b24d1c8aaa75a3ac9a..3a8e033dce21c7a88d68f77e224b43b2423c9c17 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/wlp.h>
+#include <linux/slab.h>
 
 #include "wlp-internal.h"
 
@@ -259,6 +260,63 @@ out:
 }
 
 
+static ssize_t wlp_get_attribute(struct wlp *wlp, u16 type_code,
+       struct wlp_attr_hdr *attr_hdr, void *value, ssize_t value_len,
+       ssize_t buflen)
+{
+       struct device *dev = &wlp->rc->uwb_dev.dev;
+       ssize_t attr_len = sizeof(*attr_hdr) + value_len;
+       if (buflen < 0)
+               return -EINVAL;
+       if (buflen < attr_len) {
+               dev_err(dev, "WLP: Not enough space in buffer to parse"
+                       " attribute field. Need %d, received %zu\n",
+                       (int)attr_len, buflen);
+               return -EIO;
+       }
+       if (wlp_check_attr_hdr(wlp, attr_hdr, type_code, value_len) < 0) {
+               dev_err(dev, "WLP: Header verification failed. \n");
+               return -EINVAL;
+       }
+       memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), value_len);
+       return attr_len;
+}
+
+static ssize_t wlp_vget_attribute(struct wlp *wlp, u16 type_code,
+       struct wlp_attr_hdr *attr_hdr, void *value, ssize_t max_value_len,
+       ssize_t buflen)
+{
+       struct device *dev = &wlp->rc->uwb_dev.dev;
+       size_t len;
+       if (buflen < 0)
+               return -EINVAL;
+       if (buflen < sizeof(*attr_hdr)) {
+               dev_err(dev, "WLP: Not enough space in buffer to parse"
+                       " header.\n");
+               return -EIO;
+       }
+       if (le16_to_cpu(attr_hdr->type) != type_code) {
+               dev_err(dev, "WLP: Unexpected attribute type. Got %u, "
+                       "expected %u.\n", le16_to_cpu(attr_hdr->type),
+                       type_code);
+               return -EINVAL;
+       }
+       len = le16_to_cpu(attr_hdr->length);
+       if (len > max_value_len) {
+               dev_err(dev, "WLP: Attribute larger than maximum "
+                       "allowed. Received %zu, max is %d.\n", len,
+                       (int)max_value_len);
+               return -EFBIG;
+       }
+       if (buflen < sizeof(*attr_hdr) + len) {
+               dev_err(dev, "WLP: Not enough space in buffer to parse "
+                       "variable data.\n");
+               return -EIO;
+       }
+       memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), len);
+       return sizeof(*attr_hdr) + len;
+}
+
 /**
  * Get value of attribute from fixed size attribute field.
  *
@@ -274,22 +332,8 @@ out:
 ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr,  \
                      type *value, ssize_t buflen)                      \
 {                                                                      \
-       struct device *dev = &wlp->rc->uwb_dev.dev;                     \
-       if (buflen < 0)                                                 \
-               return -EINVAL;                                         \
-       if (buflen < sizeof(*attr)) {                                   \
-               dev_err(dev, "WLP: Not enough space in buffer to parse" \
-                       " attribute field. Need %d, received %zu\n",    \
-                       (int)sizeof(*attr), buflen);                    \
-               return -EIO;                                            \
-       }                                                               \
-       if (wlp_check_attr_hdr(wlp, &attr->hdr, type_code,              \
-                              sizeof(attr->name)) < 0) {               \
-               dev_err(dev, "WLP: Header verification failed. \n");    \
-               return -EINVAL;                                         \
-       }                                                               \
-       *value = attr->name;                                            \
-       return sizeof(*attr);                                           \
+       return wlp_get_attribute(wlp, (type_code), &attr->hdr,          \
+                                value, sizeof(*value), buflen);        \
 }
 
 #define wlp_get_sparse(type, type_code, name) \
@@ -313,35 +357,8 @@ static ssize_t wlp_get_##name(struct wlp *wlp,                             \
                              struct wlp_attr_##name *attr,             \
                              type_val *value, ssize_t buflen)          \
 {                                                                      \
-       struct device *dev = &wlp->rc->uwb_dev.dev;                     \
-       size_t len;                                                     \
-       if (buflen < 0)                                                 \
-               return -EINVAL;                                         \
-       if (buflen < sizeof(*attr)) {                                   \
-               dev_err(dev, "WLP: Not enough space in buffer to parse" \
-                       " header.\n");                                  \
-               return -EIO;                                            \
-       }                                                               \
-       if (le16_to_cpu(attr->hdr.type) != type_code) {                 \
-               dev_err(dev, "WLP: Unexpected attribute type. Got %u, " \
-                       "expected %u.\n", le16_to_cpu(attr->hdr.type),  \
-                       type_code);                                     \
-               return -EINVAL;                                         \
-       }                                                               \
-       len = le16_to_cpu(attr->hdr.length);                            \
-       if (len > max) {                                                \
-               dev_err(dev, "WLP: Attribute larger than maximum "      \
-                       "allowed. Received %zu, max is %d.\n", len,     \
-                       (int)max);                                      \
-               return -EFBIG;                                          \
-       }                                                               \
-       if (buflen < sizeof(*attr) + len) {                             \
-               dev_err(dev, "WLP: Not enough space in buffer to parse "\
-                       "variable data.\n");                            \
-               return -EIO;                                            \
-       }                                                               \
-       memcpy(value, (void *) attr + sizeof(*attr), len);              \
-       return sizeof(*attr) + len;                                     \
+       return wlp_vget_attribute(wlp, (type_code), &attr->hdr,         \
+                             value, (max), buflen);                    \
 }
 
 wlp_get(u8, WLP_ATTR_WLP_VER, version)
index 7350ed6909f888fb9a974737da561d45586275de..05dde44b35929ebcf1db8c1ba8fe70456a42ade8 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <linux/wlp.h>
 
 #include "wlp-internal.h"
index 13db739c4e397621487b88abbcd7b2c07c93f332..7f6a630bf26c47e4f2a5f13a5478d81f5cdcf346 100644 (file)
@@ -22,6 +22,7 @@
  * FIXME: docs
  */
 #include <linux/wlp.h>
+#include <linux/slab.h>
 
 #include "wlp-internal.h"
 
index 5913c7a5d922ec7749a866bbc276132b6384ef94..90accdd54c07e14877e5018d2491b15b77cfd9e5 100644 (file)
@@ -45,6 +45,7 @@
  */
 #include <linux/etherdevice.h> /* for is_valid_ether_addr */
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/wlp.h>
 
 #include "wlp-internal.h"
index ad37da2b6cb5bba78ac91664d93088f7ec2fb59c..9777583218ff9fa4abaa7be5896de223b92f77ab 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/workqueue.h>
 #include <linux/rcupdate.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 
 #include <linux/net.h>
 #include <linux/if_packet.h>
@@ -125,7 +126,7 @@ static void handle_tx(struct vhost_net *net)
        mutex_lock(&vq->mutex);
        vhost_disable_notify(vq);
 
-       if (wmem < sock->sk->sk_sndbuf * 2)
+       if (wmem < sock->sk->sk_sndbuf / 2)
                tx_poll_stop(net);
        hdr_size = vq->hdr_size;
 
@@ -508,12 +509,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
        /* Verify that ring has been setup correctly. */
        if (!vhost_vq_access_ok(vq)) {
                r = -EFAULT;
-               goto err;
+               goto err_vq;
        }
        sock = get_socket(fd);
        if (IS_ERR(sock)) {
                r = PTR_ERR(sock);
-               goto err;
+               goto err_vq;
        }
 
        /* start polling new socket */
@@ -524,12 +525,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
        vhost_net_disable_vq(n, vq);
        rcu_assign_pointer(vq->private_data, sock);
        vhost_net_enable_vq(n, vq);
-       mutex_unlock(&vq->mutex);
 done:
        if (oldsock) {
                vhost_net_flush_vq(n, index);
                fput(oldsock->file);
        }
+
+err_vq:
+       mutex_unlock(&vq->mutex);
 err:
        mutex_unlock(&n->dev.mutex);
        return r;
index 7cd55e07879455abe95e04fa06656623b415c9a9..5be11c99e18f7e44f220baa67315e0c14aa1bd79 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/poll.h>
 #include <linux/file.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 
 #include <linux/net.h>
 #include <linux/if_packet.h>
@@ -476,8 +477,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
                if (r < 0)
                        break;
                eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
-               if (IS_ERR(eventfp))
-                       return PTR_ERR(eventfp);
+               if (IS_ERR(eventfp)) {
+                       r = PTR_ERR(eventfp);
+                       break;
+               }
                if (eventfp != vq->kick) {
                        pollstop = filep = vq->kick;
                        pollstart = vq->kick = eventfp;
@@ -489,8 +492,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
                if (r < 0)
                        break;
                eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
-               if (IS_ERR(eventfp))
-                       return PTR_ERR(eventfp);
+               if (IS_ERR(eventfp)) {
+                       r = PTR_ERR(eventfp);
+                       break;
+               }
                if (eventfp != vq->call) {
                        filep = vq->call;
                        ctx = vq->call_ctx;
@@ -505,8 +510,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
                if (r < 0)
                        break;
                eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
-               if (IS_ERR(eventfp))
-                       return PTR_ERR(eventfp);
+               if (IS_ERR(eventfp)) {
+                       r = PTR_ERR(eventfp);
+                       break;
+               }
                if (eventfp != vq->error) {
                        filep = vq->error;
                        vq->error = eventfp;
index 2110556f76b3fde28f5edc6a6adc49a2ddd9efd4..75a39eab70c38e291363473074ff8373dcf30135 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 43d7d506736154bee53d3a67fa99fce943a935c0..82acb8dc4aa144dab7888e567238a1ce332e49c8 100644 (file)
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
index 82bedd7f778967ee879258d27bc9183111107036..dca48df9844405d9827868c29e1f6e0e25adc796 100644 (file)
@@ -45,7 +45,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/fb.h>
index 01554d6965281435c9a4a8e1876a68e551d3a0cd..8d406fb689c132330dcaa4972a60cd271f3b348d 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index e70bc225fe315d39288d20d6d34011647571fe6c..8cdf88e20b4b649136439aef85af97be7baf2d91 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index b7687c55fe16b6d04efed50a5059dd1b100672ec..f3aada20fa02ad5e51264b1f347dd50e6120e85e 100644 (file)
@@ -52,7 +52,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 11de3bfd4e543f29d152308b363767205f969aee..8dce25126330f48639607e97398267a131c7d959 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/backlight.h>
+#include <linux/gfp.h>
 
 #include <mach/board.h>
 #include <mach/cpu.h>
index a489be0c461493dd6b61669b82961a2a207f9a74..34a0851bcbfa1f7a8d119e4e340062315a3ed5f0 100644 (file)
@@ -52,7 +52,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 04c710804bb04e93e67cd1b81fe7b811d5c87bce..2ba8b3c421a1e03af15524c4e49d233ebcec8149 100644 (file)
@@ -2,7 +2,6 @@
  *  ATI Mach64 CT/VT/GT/LT Cursor Support
  */
 
-#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/string.h>
index 9fc8c66be3cece99f453ec50300403252b1da718..256966e9667db3bfa776e71c51a694c3239c3432 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "radeonfb.h"
 #include <linux/backlight.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
index b4d4b88afc093d752f8ffce2ccbc14109e234eea..9261c918fde87cc61712b993f93aae2f4dd28c84 100644 (file)
@@ -1,4 +1,7 @@
 #include "radeonfb.h"
+
+#include <linux/slab.h>
+
 #include "../edid.h"
 
 static struct fb_var_screeninfo radeonfb_default_var = {
index a699aab638205c01b0765610cd9846a5468a8944..40f61320ce1665b156b04761b739b8c4bbc96862 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/ctype.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/mach-au1x00/au1000.h>
 
index 0d96f1d2d4c5bd0d3d490becbc84a0c012d7e443..e77e8e4280fb4005854f68c5450031d4764b040b 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/interrupt.h>
 #include <linux/ctype.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <asm/mach-au1x00/au1000.h>
 #include "au1200fb.h"
index 93e25c77aeb2816434322a5a09a1545f475092a5..68d2518fadaa67fc56af119fde89fd7dd49648a3 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/i2c.h>
 #include <linux/backlight.h>
 #include <linux/mfd/88pm860x.h>
+#include <linux/slab.h>
 
 #define MAX_BRIGHTNESS         (0xFF)
 #define MIN_BRIGHTNESS         (0)
index 5183f0e4d3145986d0d68998aa752c240bf3fd5e..9f436e014f85b3e809198f37e42d8b57cc387fe1 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/fb.h>
 #include <linux/backlight.h>
 #include <linux/mfd/adp5520.h>
+#include <linux/slab.h>
 
 struct adp5520_bl {
        struct device *master;
index b0624b983889273c72219d4b94ade29b7c0ce603..7f4a7c30a98b1f3a09fd020c4c5906f386a1015c 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/backlight.h>
 #include <linux/fb.h>
+#include <linux/gfp.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index 2d9760551a4b738e1d0ebaef4ffed32f2a4fdf2f..e6a66dab088c10a697f438625651d6d17f2aed4c 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/backlight.h>
 #include <linux/atmel_pwm.h>
 #include <linux/atmel-pwm-bl.h>
+#include <linux/slab.h>
 
 struct atmel_pwm_bl {
        const struct atmel_pwm_bl_platform_data *pdata;
index 68bb838b9f115677e09c5cb874de195c109e5c88..e207810bba3cfe9e0042f02bc447ad5b01564ff0 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <linux/fb.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
index 73bdd8454c943ed587b6fd3bf7abbf83a64ef622..1e71c35083bb4ca8505031efeee5db036a2a2c51 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/lcd.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/corgi_lcd.h>
+#include <linux/slab.h>
 #include <asm/mach/sharpsl_param.h>
 
 #define POWER_IS_ON(pwr)       ((pwr) <= FB_BLANK_NORMAL)
index 1cce6031bff24a5736a505e007d316270104cfc1..a4f4546f0be08555f8a2d793b6b94beaae91186f 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/backlight.h>
 #include <linux/lcd.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 /* The LVDS- and panel power controls sits on the
  * GPIO port of the ISA bridge.
index 686e4a789238832f80fda14b2e4af8218f095640..87659ed79bd7aa3eae7cc1fafd6e12e8cad79e25 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/fb.h>
 #include <linux/backlight.h>
 #include <linux/mfd/da903x.h>
+#include <linux/slab.h>
 
 #define DA9030_WLED_CONTROL    0x25
 #define DA9030_WLED_CP_EN      (1 << 6)
index ba89b41b639cde4517fa8bb64237441ee8fa9e5e..5118a9f029aba5a872c231239d9f86c52738b73c 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/lcd.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 
index 74abd6994b09ee22bc607ab3df6a870632de66b0..bcdb12c93efddeed8f35c3d55d0bf6a63d170f89 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/gpio.h>
 #include <linux/lcd.h>
+#include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 
 #include <linux/spi/spi.h>
index 9b3be74cee5a7f2e9f000bf4b64f9cec8c7a2715..71a11cadffc48134b3ab164cb798f7278be6f802 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <linux/fb.h>
+#include <linux/slab.h>
 
 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
                           defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
index 447b542a20ca61f208e539af84dc75489567edfb..abc43a0eb97dd054f7c526b47fa014e61e458dc0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/lcd.h>
 
index 4631ca8fa4a4a33dcc39eb3801dfbc5ee21de121..8010aaeb5adb4437620bd51c63604897198bd0e1 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/lcd.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spi/spi.h>
 
 #include "ltv350qv.h"
index c91adaf492cf9eb52fb596516d128f43beb1d0a5..b5accc957ad37e50d5644f68749bb37d44667acf 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/i2c.h>
 #include <linux/backlight.h>
 #include <linux/mfd/max8925.h>
+#include <linux/slab.h>
 
 #define MAX_BRIGHTNESS         (0xff)
 #define MIN_BRIGHTNESS         (0)
index 333d28e6b062ff448550bf2352d3f8a4ff76694d..d3bc56296c8d98007321a1cce4945c7bdd7e0259 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/fb.h>
 #include <linux/backlight.h>
+#include <linux/slab.h>
 
 #include <mach/hardware.h>
 #include <plat/board.h>
index 738694d23889069805a752f1be14ba9b3d102ece..302330acf6284e0b22e7dc77a6ea055603aa5358 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/fb.h>
 #include <linux/backlight.h>
 #include <linux/lcd.h>
+#include <linux/slab.h>
 
 #include <video/platform_lcd.h>
 
index b89eebc3f77d357c0f68c64aa45b0b68b65f9909..550443518891d41345234f4aa72929798b1f68a8 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/err.h>
 #include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
+#include <linux/slab.h>
 
 struct pwm_bl_data {
        struct pwm_device       *pwm;
index 4a3d46e08016cc9ff49100f51574d67850249db2..1997e12a105783d0b3d40a4310cebcdacc826906 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/spi/tdo24m.h>
 #include <linux/fb.h>
 #include <linux/lcd.h>
+#include <linux/slab.h>
 
 #define POWER_IS_ON(pwr)       ((pwr) <= FB_BLANK_NORMAL)
 
index f57bbf170049c8c7444210155a4d143a43ec0090..e03e60bbfd855f01301ab14d71b1fc9d94453bcc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/gpio.h>
 #include <linux/fb.h>
 #include <linux/backlight.h>
+#include <linux/slab.h>
 
 #include <asm/mach/sharpsl_param.h>
 
index fa32b94a45466c0d4c5f024e7ea95bfb4920d434..772f6015219a91764a78a481071b2830824e4272 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/lcd.h>
index a4312709fb1bfffe83e83a6152873a8ad65e11b0..08fd87f3aecce368219ed7cb08dfdaa0aebafef6 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/fb.h>
 #include <linux/backlight.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/pdata.h>
index 03872365a36d4b38e5b793c7c4aefb8890bf2ab4..2baac7cc14255ea3b7401f442951f42580a0d7a3 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/fb.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
index 31a2dec927bb4da2615b1023307a83c2a0e10061..44e49c28b2a75c021b16ac65d91d714eabdb49be 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/types.h>
index b0b147cb4cb3aae5a0090e38145f8b48d1b0e25b..43320925c4cea48b980a905fa0d5766cadcad335 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 0c02f8ec4bf3dafe14965025a3a1121e19ab4dfd..d8345fcc4fe33f95edb460e410cf09b8f4e87bf5 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/fb.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "carminefb.h"
 #include "carminefb_regs.h"
index 79e5f40e6486687c8e43062c6aaece0c1dc2a071..bb5a96b1645dc4a46600ee38f387e6d4267f3618 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/fb.h>
-#include <linux/slab.h>
 #include <asm/types.h>
 #include <asm/io.h>
 #include "fb_draw.h"
index fe45a3b8d0e060141e8a7cef3d7702fff15a44fa..77a040af20a7860626b9bae5696b88fce42a0c20 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index b2319fa7286f8c77d8649ff4892f02ace8fb45e0..30eedf79322c4dcff534da06fe7938a5753d112c 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 0d47c6030e3d084011d697bf7aefe34d6f02021f..6d0fcb43696ec10bed2b44a020ee46e787b238e4 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 57b9d276497ed07e485311f38e95c6ef86af870e..d637e1f53172ac8180fcfec902cbe580dbca3072 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 4c2bf923418c34bea4254318faeafb2d84190255..8d8dfda2f86801648d1b4a3d0779b769fab30a88 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
index 6b7c8fbc5495cf6429a9206e4ebb92a1ec85caee..af88651b0735d9f270c9f11baebdc8786802802a 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/vt_kern.h>
index bdf913ecf001de64916ede55b21c9b318743ee04..d135671d996184be2907dc43897222987c22d442 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/vt_kern.h>
index a6819b9d1770cccd2690e9ee4c95f52736c27d42..126110f8454ff5b305a83e0af55de6a8176fd1d6 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/vt_kern.h>
index 00884e013f0f2713591bad338b978ac37713b5cf..db6528f2d3f29506cd33c55b48ee5ece6fef4a37 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/vt_kern.h>
index d9b5d6eb68a73c4e9129a84679532dc191cf4693..93a3e7381b5062d4e4c3596129f2c30d3b5671e8 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/vt_kern.h>
index dd3eaaad44417781a6cef9a1537ca055812d3d65..0b67866cae10334200e1570d421cc5f74d56c7ea 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/console.h>
 #include <linux/string.h>
 #include <linux/kd.h>
-#include <linux/slab.h>
 #include <linux/vt_kern.h>
 #include <linux/vt_buffer.h>
 #include <linux/selection.h>
index 369a5b3ac6493b578425a7435ad45b4c2bc3759b..8d244ba0f6019689293bb7929a60ed065de6fdca 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
 #include <linux/console.h>
+#include <linux/slab.h>
 #include <video/da8xx-fb.h>
 
 #define DRIVER_NAME "da8xx_lcdc"
index 80abbf323b99befaa77bd0588463cb01ad1fe578..f6a09ab0dac6dad6184f783a9fe89e9dc04934b6 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/idr.h>
 #include <linux/err.h>
 #include <linux/kdev_t.h>
+#include <linux/slab.h>
 
 static ssize_t display_show_name(struct device *dev,
                                struct device_attribute *attr, char *buf)
index 606da043f4b479cd46c31f1778a7a1272dc4d872..ec56d2544c734aea151fd49ad97b88092b7beb5e 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
index 27aab4a0619851b0d38301f2d3ecba0a761c24db..0c99de0562ca7ccfd4a144d0b348c76b58073256 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/clk.h>
 #include <linux/fb.h>
 
index 6d755bb3a2bcf0ee832476504a0329b2c4b9e445..db9713b49ce9a8a7ebd160fa87a0d9ee68d4b58d 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
index 0cf96eb8a60f610b3fc26f0bc827453eb1c201fc..4a874c8d039c2867246d6e58c749b9d6f8170dbf 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/fb.h>
 #include <linux/i2c-algo-bit.h>
+#include <linux/slab.h>
 
 #include "edid.h"
 
index 44ce908a478b5f4d4ef116e6e92c93172e44b760..6113c47e095aaa0e94805c42622c47a344ff4dce 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 0847c5e72cbd73ff2fcf53afe59c1d729810e2d9..7293eaccd81bd4b5846c187f848cb30ccb32d735 100644 (file)
@@ -13,6 +13,7 @@
  *
  */
 #include <linux/fb.h>
+#include <linux/slab.h>
 
 #define FB_CVT_CELLSIZE               8
 #define FB_CVT_GTF_C                 40
index 9ae9cd32bd065b1142d63c9975ad51fd1a1972e5..563a98b88e9bf17ce32edeaf4268fbfcee48681c 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/fb.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <video/edid.h>
 #ifdef CONFIG_PPC_OF
 #include <asm/prom.h>
index d4a2c11d980975be84131abd3a94670a1e2f7c98..81aa3129c17d75cbf67daf7d8226abb630c9d22a 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/console.h>
 #include <linux/module.h>
index 9dbb9646081f670a92c6c29733184a25c4ef107e..a42fabab69dfe5d43b96cd63902625b219845f46 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index b7655c05da53ad25a2bd6099992f503eff0e2d92..d662317d85e30fb01782b29f0bb681d327b766df 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 5643a35c1746681ae1f464fe39036b5d42334b0f..7d8c55d7fd28a42c5d73a7f9e5f226bd9362a799 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index f20eff8c4a816e1b9751ef1110f868e788f2e6a0..c6b554f72c6d255b61e1925e32f6effb9f300978 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
index b3e639d1e12cbf67addef7eaa7455b8684b47b43..76e7dac6f25901843da1717d6fb55a3c721a8e16 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/console.h>
index cc781c00f75d04a11a9b371db177dca3ea64b06d..e4c4d89b786034c33aaf687b9616feddd3c76bbd 100644 (file)
@@ -365,6 +365,8 @@ enum fp_registers {
        FP_CRC, /* 0x458 */
 };
 
+#define FP_PT2_HSP                     (1 << 22)
+#define FP_PT2_VSP                     (1 << 23)
 #define FP_PT2_SCRC                    (1 << 27)       /* shfclk free */
 
 #define FP_PM_P                                (1 << 24)       /* panel power ctl */
index 889cbe39e5800a27346cdc7377e6662d915bd459..1a18da86d3fa3cbde2b899831ec136a178527340 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/string.h>
 #include <linux/console.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/suspend.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
index 0e5d8c7c3ebae2ad81a62bd693c857e10771f01a..bc35a95e59d417ef85df900e26824f5de67eaa35 100644 (file)
@@ -274,7 +274,15 @@ static void lx_graphics_enable(struct fb_info *info)
                u32 msrlo, msrhi;
 
                write_fp(par, FP_PT1, 0);
-               write_fp(par, FP_PT2, FP_PT2_SCRC);
+               temp = FP_PT2_SCRC;
+
+               if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
+                       temp |= FP_PT2_HSP;
+
+               if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
+                       temp |= FP_PT2_VSP;
+
+               write_fp(par, FP_PT2, temp);
                write_fp(par, FP_DFC, FP_DFC_BC);
 
                msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW;
index f9d77adf035d92a027ef29a2d376eb2e237b23a9..c77bcc6ab463c2ce1cfd17abdb813d490c4376bd 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index db9b785b56eb929d3baceba900a3f79921c54e57..8bbf251f83d9800ffef5dbe6efccc02105f5b065 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
index bf78779199c6ff48fd253993d451b15ee8d74637..393f3f3d3dfe4149957c524d1cd56de8011c42e0 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
index b8ebff1e8493e2290b21530ad5086b5d55172089..c8e280f1bb0bf78181570a8d9b36956d55683ae6 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 9dd55e5324a13d9653b0b77a0a77ca1e8f9be751..cd2c728a809bd0f8338e7b0b6ac844197893779d 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/fb.h>
 #include "i810.h"
index 15d50b9906ced3eb1d76da6e1bc45844d9165f99..efb2c10656b0a89aa88d23276d47926805bbb4b2 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 81627466804e1f7ceeba08f63bf7517562ac3ef4..38065cf94ac4cf5dbaf195233871712af4607ab6 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
index e145e2d16fe37414d40e7c1ce4df3831b3752ddc..1db55f128490213ebfc35a6ad6ed87176af670fb 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index f3728ab262f8a7d7c9c63b5d93940e5c7f4e37b7..403b14445a7830c7c29744acb8e92d6c9eb3ab2f 100644 (file)
@@ -13,6 +13,7 @@
 #include "matroxfb_base.h"
 #include "matroxfb_maven.h"
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/i2c-algo-bit.h>
 
 /* MGA-TVO I2C for G200, G400 */
index 7064fb4427b6f44b2c45fd26860e31a2e6ccdefc..052dd9f0b7607978fd50a22c8502f5134d903dbe 100644 (file)
 #include "matroxfb_g450.h"
 #include <linux/matroxfb.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #ifdef CONFIG_PPC_PMAC
index 78414baa5a54f185da5d43f2b9deaa7c70e66e0d..d7112c39614b0006736c8b9ea76f91e07a748683 100644 (file)
@@ -15,6 +15,7 @@
 #include "matroxfb_misc.h"
 #include "matroxfb_DAC1064.h"
 #include <linux/matroxfb.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 /* **************************************************** */
index 91af9159111ffb58c83fb3f572c0c8a48417934c..1e3e8f19783e30f408ca82a480b92832ee437423 100644 (file)
@@ -17,6 +17,7 @@
 #include "matroxfb_DAC1064.h"
 #include <linux/i2c.h>
 #include <linux/matroxfb.h>
+#include <linux/slab.h>
 #include <asm/div64.h>
 
 #define MGATVO_B       1
index 7854c7a37dc58430e3751ebedbce9c6286cf6280..5cf52d3c8e75065bddeed87299c7aef7ddd82e87 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 049256052b1aff2548ab48ea37b5c07543c62eb7..841424912ece3d98c0e22785c1e2afc2a208d3bc 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #if defined(CONFIG_OF)
 #include <linux/of_platform.h>
 #endif
index 15b8b3c4330ec3b3aca5813a985ef87101dcb295..ecad96524570882b143827c9cfc10aa29c0b9a97 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #define BIG_BUFFER_SIZE        (1024)
 
index 661bfd20d1943e805dd6aa2865d4c2f361a38eb1..9b3d6e4584cca075387682eaf18ba3b76038a03b 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index b895aae41630b3d1b6dd90b54038986bf350b331..0a4dbdc1693a4462bddb82cdf5e0b9ab5ec4bed2 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/kernel.h>
 
index 474421fe79a646dfa98d04ad28c72930061575a5..c1ff271017a93c06e2d2594c4ea2de9d541e3264 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/spinlock.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index ebbae87885b69f1ff5e09ba46363970e82fc25f2..d2a091cebe2c31f42edabb2524d7053acc5956e3 100644 (file)
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
index c9e9349451cbbbaa097ff71b08148c14cc4570ae..f239f4a25e014d5f93b6099c7024a85f5de4f88e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <mach/msm_fb.h>
 
 static DECLARE_WAIT_QUEUE_HEAD(nt35399_vsync_wait);
index 71048e78f7f01810404dc687a51f94f6d5696fdc..f9bc932ac46b32809ff3ff4d9b13fe8a4d459b5d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <mach/msm_fb.h>
 
 
index 6c519e2fa2b7a1bece0557f23e082c22f673f621..19c01c6208e880d4090dd845c358f96d3e2c6be9 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/clk.h>
 #include <linux/file.h>
 #include <linux/major.h>
+#include <linux/slab.h>
 
 #include <mach/msm_iomap.h>
 #include <mach/msm_fb.h>
index 49101dda45ee5906b8abb1fcd1e3cf23eff1ec98..debe5933fd2e6c0d3c3e272242e093632f2732cf 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/module.h>
 #include <linux/fb.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include <linux/freezer.h>
index 6aaddb4f678897383b187cf45decea12166c13e9..d7994a1732459d831775374d61f135ecaf5e06c5 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/fb.h>
 
index 73afd7eb9977b4b34d22254aa3f57bb6199a3426..3bc13df4b120fd12c9d888a40de7bef5f7ed3372 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/fb.h>
 
index eef2bb298d9f08b4c831a4cce8a78ec7ab5ff965..2f2e162134fabe193add5d945cfc69a725aa6f03 100644 (file)
@@ -50,6 +50,7 @@
 #include <video/vga.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include "nv_type.h"
 #include "nv_local.h"
 #include "nv_proto.h"
index b043ac83c41265b884bbe07e2510519be4ba91dd..61f8b8f919b07417a78c29be1592abbb690217d7 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index e192b058a6888002ddecbcfed4413ec85269da58..529483467abf0254fbe6da582c938e57c8494e8a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <plat/sram.h>
 #include <plat/board.h>
index abe1c76a3257249cf7e6eaca2cc2965dd145d079..64dcc7439c991f704d7920897a715941bfba4c7e 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
 
index 9557f963662e2fb42b1a40a0119fc38b495d7f94..43ab7d8b66b2bf9e32d2e687747a8e6427daa6d5 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/vmalloc.h>
 #include <linux/clk.h>
+#include <linux/gfp.h>
 
 #include <mach/lcdc.h>
 #include <plat/dma.h>
index 8ce60e1b220a23f366a9eb886a0460efe634a4b5..e264efd0278f24cf2fa9650e4002d25a0c7160c2 100644 (file)
@@ -26,6 +26,7 @@
  */
 #include <linux/platform_device.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #include <plat/dma.h>
index c59e4baed8b2b7d780a67c24bd45ce50c25b4de7..300eff5de1b4830490e6a5f36d48adf8b63a5b1e 100644 (file)
@@ -116,6 +116,24 @@ static int generic_panel_resume(struct omap_dss_device *dssdev)
        return 0;
 }
 
+static void generic_panel_set_timings(struct omap_dss_device *dssdev,
+               struct omap_video_timings *timings)
+{
+       dpi_set_timings(dssdev, timings);
+}
+
+static void generic_panel_get_timings(struct omap_dss_device *dssdev,
+               struct omap_video_timings *timings)
+{
+       *timings = dssdev->panel.timings;
+}
+
+static int generic_panel_check_timings(struct omap_dss_device *dssdev,
+               struct omap_video_timings *timings)
+{
+       return dpi_check_timings(dssdev, timings);
+}
+
 static struct omap_dss_driver generic_driver = {
        .probe          = generic_panel_probe,
        .remove         = generic_panel_remove,
@@ -125,6 +143,10 @@ static struct omap_dss_driver generic_driver = {
        .suspend        = generic_panel_suspend,
        .resume         = generic_panel_resume,
 
+       .set_timings    = generic_panel_set_timings,
+       .get_timings    = generic_panel_get_timings,
+       .check_timings  = generic_panel_check_timings,
+
        .driver         = {
                .name   = "generic_panel",
                .owner  = THIS_MODULE,
index 59769e85d41cca70c3499dbfa34628978ff2c228..4f3988a4108215eba3a0e504a5aef2b3e6ba3d97 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/gpio.h>
 #include <linux/completion.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 #include <plat/display.h>
 
index d578feee3550b53a29c70c26eeb6851e9ada1ce5..e866e76b13d02bfc746656c33d1167d94d7d84fb 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/gpio.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 
 #include <plat/display.h>
 
index 8254a4232a536d3c844214e165bd67507d94c943..54344184dd733ceae5df78e9cff33ffa51c7629f 100644 (file)
@@ -590,6 +590,9 @@ int dss_init(bool skip_init)
                }
        }
 
+       dss.dsi_clk_source = DSS_SRC_DSS1_ALWON_FCLK;
+       dss.dispc_clk_source = DSS_SRC_DSS1_ALWON_FCLK;
+
        dss_save_context();
 
        rev = dss_read_reg(DSS_REVISION);
index 9acef00c47eaad1c4727c1721c01ccb10c85684d..0820986d4a68b986fb66e303bc22e8fd997a540c 100644 (file)
@@ -23,6 +23,7 @@
 #define DSS_SUBSYS_NAME "MANAGER"
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
index aed3f31943478d6c8c52d6a43b1c87963d5bd1ce..82336583adeffa7333975ba71d3796a604e1981b 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kobject.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <plat/display.h>
 #include <plat/cpu.h>
index 4a76917b7cc8dcd6e0aa6787477ce37168dcfd78..4b4506da96da360ad706f0fbc59716dd8013cd8d 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/dma-mapping.h>
 #include <linux/vmalloc.h>
index 55a4de5e5d10df6cc45c7dd6c9ef68c97636cd40..3b1237ad85ed384a3adba6dfe07451d2a732ed11 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/bootmem.h>
 #include <linux/completion.h>
@@ -511,13 +512,14 @@ static u32 omap_vram_sdram_size __initdata;
 static u32 omap_vram_def_sdram_size __initdata;
 static u32 omap_vram_def_sdram_start __initdata;
 
-static void __init omap_vram_early_vram(char **p)
+static int __init omap_vram_early_vram(char *p)
 {
-       omap_vram_def_sdram_size = memparse(*p, p);
-       if (**p == ',')
-               omap_vram_def_sdram_start = simple_strtoul((*p) + 1, p, 16);
+       omap_vram_def_sdram_size = memparse(p, &p);
+       if (*p == ',')
+               omap_vram_def_sdram_start = simple_strtoul(p + 1, &p, 16);
+       return 0;
 }
-__early_param("vram=", omap_vram_early_vram);
+early_param("vram", omap_vram_early_vram);
 
 /*
  * Called from map_io. We need to call to this early enough so that we
index 5137aa016b833589b3ed2855daba5e076a2183d6..0d6f2cda93696fa96322d77a15f122d81555311a 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include <linux/module.h>
 #include <linux/video_output.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/ctype.h>
 
index 7fa4ab01b0d36281536875ed1d28e68606d78984..81440f2b90919c2e9904343c24528fe989472270 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 0a366d86f08ea8faf50918128266431e9f4abd21..8a204e7a5b5b655a95897ba533c12b032434f16b 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 6515ec11c16ba250f55f6cbe6a10b6a74f7effca..838424817de2307e0af1c92358ebaf412d5b7c92 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index 4db6b48a87155b1f7316ad6f5145d37922edec8f..b2252fea2858c732533af9063c889931ab27c895 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 2aa09bce3944bdb2b0b9fb73fbf878d5fb31aff7..5ec4f2d439c949efd03f8b6d6024ac77cea81e83 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -29,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
 #include <linux/clk.h>
+#include <linux/gfp.h>
 #include <asm/uaccess.h>
 #include <mach/gpio.h>
 
index 75285d3f393cba74c77eb35017e98b229d639769..c91a7f70f7b086f56882ba07f97ba38e314adfd6 100644 (file)
@@ -668,7 +668,7 @@ static int __init pxa168fb_probe(struct platform_device *pdev)
        /*
         * Map LCD controller registers.
         */
-       fbi->reg_base = ioremap_nocache(res->start, res->end - res->start);
+       fbi->reg_base = ioremap_nocache(res->start, resource_size(res));
        if (fbi->reg_base == NULL) {
                ret = -ENOMEM;
                goto failed;
index de40a626dc76b0effe165e84d258e816ccabf409..fc32c323a38115c6e7430767d607dfc06e920545 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
index 7b63429f1a7cc17bc2e1da3190473241d1ca9249..a6247fc081ab9fb80671b6fd34b611d0484586d5 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/fb.h>
 #include <linux/spinlock_types.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 53cb722c45a02f37e23403e2b0874d110c8e25c5..9682ecc60e12f4f4719ff0ef082948a74fe9d102 100644 (file)
@@ -16,8 +16,8 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/gfp.h>
 #include <linux/clk.h>
 #include <linux/fb.h>
 #include <linux/io.h>
index c3fad34309eda24e32f5be510d6385f873d7f643..d4471b4c037476e82a8ade24acac32164fc6727e 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/svga.h>
index 574b29e9f8f2dff6782a27d997001f861f750609..ed371c868b3ac6d7ab0c171689415092d55dc9b7 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/pci.h>
 #include <linux/fb.h>
 
index 9f6d6e61f0cc73a91f6ce93c959b61b090f38464..bea38fce2470298f4bf27345ab72b0007abb260b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <asm/sh7760fb.h>
 
index bbd1dbf4026a32439bf5ef7b96b037974c5c6416..e14bd07491293d35da6ea6edb4dfe3ebc17275d5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/interrupt.h>
 #include <linux/vmalloc.h>
 #include <linux/ioctl.h>
+#include <linux/slab.h>
 #include <video/sh_mobile_lcdc.h>
 #include <asm/atomic.h>
 
index 79840f11fecbba5467388cd1987be73401343044..dee64c3b1e678f06c1878d769c3652457cbb4441 100644 (file)
@@ -86,7 +86,6 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <asm/io.h>
 #include <linux/uaccess.h>
 #include <video/sstfb.h>
index a8248c0b9192d4425411971006c785f47d0ff43c..23e69e834a18de9b3e97056f5b6aebc85bea008f 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/of_device.h>
index b1dde09e70156d31c8cfcd7a5345b241155875d7..5848436c19da294040fd3e5a9e652809b89b702b 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
 #include <linux/init.h>
index 4cd50497264d3c65d092e1ca9c4fd55d2a7d0e22..b9c2b948d34d515b4cdccaa6c70d5ab1da29e063 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
 #include <linux/init.h>
@@ -242,11 +241,27 @@ static int __devinit e3d_set_fbinfo(struct e3d_info *ep)
 static int __devinit e3d_pci_register(struct pci_dev *pdev,
                                      const struct pci_device_id *ent)
 {
+       struct device_node *of_node;
+       const char *device_type;
        struct fb_info *info;
        struct e3d_info *ep;
        unsigned int line_length;
        int err;
 
+       of_node = pci_device_to_OF_node(pdev);
+       if (!of_node) {
+               printk(KERN_ERR "e3d: Cannot find OF node of %s\n",
+                      pci_name(pdev));
+               return -ENODEV;
+       }
+
+       device_type = of_get_property(of_node, "device_type", NULL);
+       if (!device_type) {
+               printk(KERN_INFO "e3d: Ignoring secondary output device "
+                      "at %s\n", pci_name(pdev));
+               return -ENODEV;
+       }
+
        err = pci_enable_device(pdev);
        if (err < 0) {
                printk(KERN_ERR "e3d: Cannot enable PCI device %s\n",
@@ -265,13 +280,7 @@ static int __devinit e3d_pci_register(struct pci_dev *pdev,
        ep->info = info;
        ep->pdev = pdev;
        spin_lock_init(&ep->lock);
-       ep->of_node = pci_device_to_OF_node(pdev);
-       if (!ep->of_node) {
-               printk(KERN_ERR "e3d: Cannot find OF node of %s\n",
-                      pci_name(pdev));
-               err = -ENODEV;
-               goto err_release_fb;
-       }
+       ep->of_node = of_node;
 
        /* Read the PCI base register of the frame buffer, which we
         * need in order to interpret the RAMDAC_VID_*FB* values in
index 9c7106701572409a967e563585209f1e9cb5198c..fdb45674e2f628b906e3997cf22eebe7c38f6711 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <linux/svga.h>
-#include <linux/slab.h>
 #include <asm/types.h>
 #include <asm/io.h>
 
index a352d5f46bbf08be1badbe0b23313fc07d8f4090..844a32fd38ed9640b5197e6e963a3f960e6f11b8 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/fb.h>
-#include <linux/slab.h>
 #include <asm/types.h>
 #include <asm/io.h>
 #include "fb_draw.h"
index 45b883598bf02739083c19ba32106fe527dda081..c0c2b18fcdcff6229bdd7afaffa2cbd36c30a891 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
index a86046ff60ad527f7f10cf16a0451df33abc45a2..1b3b1c718e80d4cd775b359464a73321ac70a3b6 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/selection.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/tc.h>
 
index 03a9c35e9f552a951ff9ed6798536633d515e020..c6c77562839d9663cef133f9b23e0d1607a5d2c8 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include <linux/delay.h>
 #include <video/vga.h>
index 54fbb2995a5f3007d2ed5fbceea54738e9314904..7b8839ebf3c402ced009123ac6260c97a51a922a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/fb.h>
 #include <linux/io.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <video/edid.h>
 #include <video/uvesafb.h>
 #ifdef CONFIG_X86
index c18f1884b550b923d797e6b1d8b1eb768edb266a..931a567f9aff4219cf015f7855189725313b810b 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/fb.h>
 #include <linux/pci.h>
index ef4128c8e57af0a31833908b00be09732c8a4fd7..54ac91dc070bc7ebef08db305741456259bb7f9e 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
index b8ab995fbda75f92248e62f6508deefb917ca034..9b5532b4de35fe9f622b37a7d1fbe14815ba5049 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index 76d8dae5b1bb44d6ab7e7dc67ed0c3cf60c95b7c..bf638a47a5b3957da6e02c429d5f27d442476b19 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/ioport.h>
index ce7783b63f6a6c39881da9e7f6b81647f039256d..777b38a06d40b2390a0cc8778ba5212546ff74f5 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/module.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 #define _MASTER_FILE
 
index 65ccd215d4969672fa218ee0d44c6a39705779ab..d31dc96f838a29576d1c11a0cbd6857d266475ac 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/tty.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/svga.h>
index 5d223959778a7898b6abc2ae5822f17635952e04..31b0e17ed090f4316dc39fed9c99e73ba2455893 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
 #include <asm/io.h>
index 603598f4dbb1a5ddc969478d42a41912d1bfe1fe..fa97d3e7c21ab2e9c7ae0098971f6b3530845a60 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/errno.h>
 #include <linux/fb.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
 
index ed7c8d0ddccb47394b2cff3dd6608a826a8d0a7c..3fcb83f03881e58f94c27004e05ebdd82eca8e93 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/of_platform.h>
 #include <linux/io.h>
 #include <linux/xilinxfb.h>
+#include <linux/slab.h>
 #include <asm/dcr.h>
 
 #define DRIVER_NAME            "xilinxfb"
index 369f2eebbad14d5a2999712549894260f4e407e4..3aed38886f94be0a71bad7a47e88ed6da2b08f2f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 struct virtio_balloon
 {
index 625447f645d935d59cc23ee5813357ae044ae8ce..24747aef1952880ca686a1b8d9506acb1e174f55 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/list.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/virtio.h>
 #include <linux/virtio_config.h>
index 0db906b3c95d71bd985fa97b2fc62c52a7244104..0f90634bcb85d170e64ce6e2addee12f5fb37f82 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/virtio_ring.h>
 #include <linux/virtio_config.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 /* virtio guest is communicating with a virtual "device" that actually runs on
  * a host processor.  Memory barriers are used to control SMP effects. */
index 9554ad5f9af799641e6eda438f136886704a061a..f2d9e667972da120d3c39ab87965566fe5c13506 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/vlynq.h>
 
index 37f08c85060877508a85ed58cdf0e2a7974fb67b..6b85e7fefa43c52a5636b8a9ec41fb8c30503418 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/ds1wm.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 
index 59ad6e95af8f0b0dded05413115c45bee2d2276b..02bf7bf7160bcbb79e2d94b36e4fa32022ff3be0 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
 #include <linux/usb.h>
+#include <linux/slab.h>
 
 #include "../w1_int.h"
 #include "../w1.h"
index 492670358cbf1ad7e00a1ac59617e69dc0109e2f..a3b6a74c67a729b93949a1e06c89c40cf252c1a1 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 
index 22977d30f89e58660b99ee62f406a3a3c7eefd76..ef36fca2eed4dfa806fbf9991b604b3278c72865 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index 6f8866d6a905fd746256bb6bb3b0b90e6f308834..fcbe742188a50e93b15105e6ccfa77d7a53663a6 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/w1-gpio.h>
 
 #include "../w1.h"
index 1394471488228d2f747475256a3236103a7973f4..d2bf32118a987c91e334b01591336291ebf1c192 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/device.h>
 #include <linux/types.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #ifdef CONFIG_W1_SLAVE_DS2433_CRC
 #include <linux/crc16.h>
 
index 59f708efe25f061b0573358d028d317622fe41a7..6e153343e117fe4b0a5b56ad615ff1b9d780e17b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/idr.h>
+#include <linux/gfp.h>
 
 #include "../w1.h"
 #include "../w1_int.h"
index 4a46ed58ece938621ea3dc3c016efff9f053379f..b50be3f1073d0fc92af534cc61dc757408e57a5b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/list.h>
 #include <linux/delay.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include "w1.h"
 #include "w1_log.h"
index 45c126fea31dcdad608a666964d316214386e1fb..7e667bc77ef2d02649fbe32cd69b4ab94e06e9f6 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/connector.h>
index a5ca7a6ee133a3fbd0524c5063fe3b0f5faf52b5..af6e6b16475afeb831f16df00e846f160f452647 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/io.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
index 6873376f986c1ea69dd93b085a64aafd7ba7b90c..1cddf92cb9a604f8afd43312af0b46ef4d145bd8 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #define TIMEOUT_MIN            1
 #define TIMEOUT_MAX            2
index 37ea052d4dee95d2483a8ffca20fcb5e81cf963e..ba2efce4b40ef795ee7f7fd6e3ca469d3f0f5a43 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/io.h>
 #include <linux/of.h>
index 56162c87f5d8b4bb4eb881f3cd23d434b507c5e7..596ba604e78d11cdc1e451d80281c69de1825e32 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/io.h>
 #include <linux/device.h>
 #include <linux/clk.h>
+#include <linux/slab.h>
 
 #define MODULE_NAME "DAVINCI-WDT: "
 
index 70c2c24660d0e4f2250b2bb06d5ec06717dcbe1d..72f5a3707b48fd81d47701d1869680b9018afd2c 100644 (file)
@@ -39,7 +39,6 @@
 #include <linux/efi.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
-#include <linux/slab.h>
 #include <asm/desc.h>
 #include <asm/cacheflush.h>
 
index 89fcefcc8510da969bfb13a99677e4f73faf7463..195e0f798e769d4fda32ea7e164b3fd818c41d69 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <linux/fs.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/timer.h>
index 6eb91d75760466e83e983ad3875973f4cf8c3264..75f3a83c0361d9f0a30d70c9722b64a891253edd 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 #define DEFAULT_HEARTBEAT 60
 #define MAX_HEARTBEAT     60
index b0646dac924e9510e304037933c6d62cb6f599c4..016c6a791cab2f11188032e04840a7d144d661c4 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 #include <asm/hardware/arm_twd.h>
 
index adefe3a9d510e8e48f6936f4c1db7f73827c428d..6cee33d4b1612cba6ff4ea1b96cfae5691689c36 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/types.h>
 #include <linux/watchdog.h>
index c6aaf2845741379a69235ccc069cc8589600cbf0..76b58abf445182d6708e39f7801c77c062004769 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/bitops.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <mach/hardware.h>
 #include <plat/prcm.h>
 
index c7a9479934af87558e45bf16a036803060ede2f2..bf5b97c546eb4d699edbbd0fa3aa3f22727c7570 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/spinlock.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <mach/hardware.h>
 
 #define MODULE_NAME "PNX4008-WDT: "
index ae57bf9e1b03c49bb2b0e175ed7d1e4c5a6422f2..ea7f803f624862f973a024737d9e49ef039202a0 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of_device.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 
 /* RIO uses the NatSemi Super I/O power management logical device
index 8760a26ab2a3996fd7b48b4615d7d68f85055b1d..e4cebef55177f62e3067e0b2a7195f76ee03d725 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #include <mach/map.h>
 
index 565a2c3321e556e89015a0a576585259d1c3dc2c..458c499c1223c6f73aaab93f9a6bdc7c816de5a2 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <linux/watchdog.h>
 #include <linux/uaccess.h>
 
index 8162a40d15220aed9f2b6cfe972f9221a4520166..dcabe77ad14128384b26722fa1e57a7e0d5fe22a 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/watchdog.h>
index f6738d8b02bcdd55d7b3ebdde6782f3394726831..1a0d8c2a0354475bd2c331fe8fd8a3690adc5c20 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/mutex.h>
 #include <linux/list.h>
 #include <linux/sysdev.h>
+#include <linux/gfp.h>
 
 #include <asm/page.h>
 #include <asm/pgalloc.h>
index 2f8413794d05b98b48558ac527af7c1c9d63c566..db8f506817f0ad30f2b54bde0ff778a7405ba59b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/bootmem.h>
+#include <linux/slab.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>
index f70a4f4698c5994348a14dd216bb91ad72ec5b6a..66e185cfe92fa8bb70c29d27de013fed1685c6d2 100644 (file)
@@ -45,7 +45,6 @@
 #include <linux/poll.h>
 #include <linux/irq.h>
 #include <linux/init.h>
-#include <linux/gfp.h>
 #include <linux/mutex.h>
 #include <linux/cpu.h>
 
index 4c6c0bd636a8073ab743dbcc2a643d3ea7fd73a0..f66db3b91d6100b2fe875d410553ca0038fadabc 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/uaccess.h>
 
index 5d42d55e299bd39cbb869fdc264532fb3b06e9dc..2ac4440e7b087c1a9ac9c0b087d09a12be3f3a2e 100644 (file)
@@ -3,6 +3,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/reboot.h>
 #include <linux/sysrq.h>
 #include <linux/stop_machine.h>
index bb71ab2336c896069faadd9e2a18b6633843bc77..60f1827a32cb7fc56b70a8ec829fc3c9fcaaee3c 100644 (file)
@@ -7,6 +7,7 @@
  *  published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/kobject.h>
index 92a1ef80a288173a7ccae8d5fc10f484d1acd613..7b3e973a1aee8ca5525ae334efba433d6bd3e12a 100644 (file)
@@ -30,6 +30,7 @@
  * IN THE SOFTWARE.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/vmalloc.h>
 #include <asm/xen/hypervisor.h>
index 2f7aaa99dc47e5d26701308e761612a2cdcbec8e..3479332113e998abfd311ffc079d548a342878c5 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/kthread.h>
 #include <linux/mutex.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 #include <asm/pgtable.h>
index a240b2c20b9952d4c69a1b365590119bcecef477..b91f8ff50d05996148f6cbc589bcdae06d72efc3 100644 (file)
@@ -18,8 +18,8 @@
  * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  */
 
-#include <linux/gfp.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <asm/page.h>
 #include <xen/xencomm.h>
 #include <xen/interface/xen.h>
index 6c4269b836b7f22ddadc2ca39d5531e467cffc95..f28ece397361c8545549b233a2b563a5ef617285 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/init.h>
 #include <linux/namei.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 
 #include "xenfs.h"
 #include "../xenbus/xenbus_comms.h"
index e777961939f3e6ed0354560c3e256247f6d24f66..0dbe0d139ac2aa3e03375188f1308c7cbadf6b57 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/jiffies.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
index 08b2eb157048b26aafd052daaeba4c8e38239f0a..7317b39b28159b2e712de1eec7bed5fce2312b3a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/idr.h>
 #include <net/9p/9p.h>
@@ -110,7 +111,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
 {
        int i, n, l, clone, any, access;
        u32 uid;
-       struct p9_fid *fid;
+       struct p9_fid *fid, *old_fid = NULL;
        struct dentry *d, *ds;
        struct v9fs_session_info *v9ses;
        char **wnames, *uname;
@@ -183,10 +184,18 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry)
                l = min(n - i, P9_MAXWELEM);
                fid = p9_client_walk(fid, l, &wnames[i], clone);
                if (IS_ERR(fid)) {
+                       if (old_fid) {
+                               /*
+                                * If we fail, clunk fid which are mapping
+                                * to path component and not the last component
+                                * of the path.
+                                */
+                               p9_client_clunk(old_fid);
+                       }
                        kfree(wnames);
                        return fid;
                }
-
+               old_fid = fid;
                i += l;
                clone = 0;
        }
index 6c7f6a2511154a3016eb1bc433f012bb1d3128f5..5c5bc8480070b27e5253904df5a7fbddc7db5572 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/sched.h>
 #include <linux/parser.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 #include <net/9p/transport.h>
@@ -241,7 +242,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
        list_add(&v9ses->slist, &v9fs_sessionlist);
        spin_unlock(&v9fs_sessionlist_lock);
 
-       v9ses->flags = V9FS_PROTO_2000U | V9FS_ACCESS_USER;
+       v9ses->flags = V9FS_ACCESS_USER;
        strcpy(v9ses->uname, V9FS_DEFUSER);
        strcpy(v9ses->aname, V9FS_DEFANAME);
        v9ses->uid = ~0;
@@ -262,8 +263,10 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
                goto error;
        }
 
-       if (!p9_is_proto_dotu(v9ses->clnt))
-               v9ses->flags &= ~V9FS_PROTO_2000U;
+       if (p9_is_proto_dotl(v9ses->clnt))
+               v9ses->flags |= V9FS_PROTO_2000L;
+       else if (p9_is_proto_dotu(v9ses->clnt))
+               v9ses->flags |= V9FS_PROTO_2000U;
 
        v9ses->maxdata = v9ses->clnt->msize - P9_IOHDRSZ;
 
@@ -340,6 +343,19 @@ void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
        p9_client_disconnect(v9ses->clnt);
 }
 
+/**
+ * v9fs_session_begin_cancel - Begin terminate of a session
+ * @v9ses: session to terminate
+ *
+ * After this call we don't allow any request other than clunk.
+ */
+
+void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses)
+{
+       P9_DPRINTK(P9_DEBUG_ERROR, "begin cancel session %p\n", v9ses);
+       p9_client_begin_disconnect(v9ses->clnt);
+}
+
 extern int v9fs_error_init(void);
 
 static struct kobject *v9fs_kobj;
index 6b801d1ddf4b22de50a7d663d220e5e171facfdc..a0a8d3dd1361645e117190e3be351c2a0066f2c3 100644 (file)
@@ -108,6 +108,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
                                                                        char *);
 void v9fs_session_close(struct v9fs_session_info *v9ses);
 void v9fs_session_cancel(struct v9fs_session_info *v9ses);
+void v9fs_session_begin_cancel(struct v9fs_session_info *v9ses);
 
 #define V9FS_MAGIC 0x01021997
 
index d74325295b1e43d74617d89798a8deb78ef6a5d6..cbf4e50f3933aa3cb8b714a518a530203a3e5385 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/namei.h>
 #include <linux/idr.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
index d8a3afe4ff722fcac539863e59a3278d459ec0bd..0adfd64dfcee88117a93aa9d2a0547cb6852d6e4 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/inet.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
@@ -130,6 +131,8 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
        rdir = (struct p9_rdir *) fid->rdir;
 
        err = mutex_lock_interruptible(&rdir->mutex);
+       if (err)
+               return err;
        while (err == 0) {
                if (rdir->tail == rdir->head) {
                        err = v9fs_file_readn(filp, rdir->buf, NULL,
index 5fe45d692c9f32d47751209930c3cc4196705671..f2434fc9d2c44f620e2e579a19318321e12d6e71 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/namei.h>
 #include <linux/idr.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
@@ -431,6 +432,7 @@ error:
 
 static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
 {
+       int retval;
        struct inode *file_inode;
        struct v9fs_session_info *v9ses;
        struct p9_fid *v9fid;
@@ -444,7 +446,10 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
        if (IS_ERR(v9fid))
                return PTR_ERR(v9fid);
 
-       return p9_client_remove(v9fid);
+       retval = p9_client_remove(v9fid);
+       if (!retval)
+               drop_nlink(file_inode);
+       return retval;
 }
 
 static int
@@ -656,6 +661,9 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
        P9_DPRINTK(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p nameidata: %p\n",
                dir, dentry->d_name.name, dentry, nameidata);
 
+       if (dentry->d_name.len > NAME_MAX)
+               return ERR_PTR(-ENAMETOOLONG);
+
        sb = dir->i_sb;
        v9ses = v9fs_inode2v9ses(dir);
        dfid = v9fs_fid_lookup(dentry->d_parent);
index 69357c0d9899c1c3e52e090b0ce3d4725b18c41b..491108bd6e0d976ff74b54a679b3ead372e6d4b1 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/mount.h>
 #include <linux/idr.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
@@ -193,6 +194,7 @@ static void v9fs_kill_super(struct super_block *s)
 
        kill_anon_super(s);
 
+       v9fs_session_cancel(v9ses);
        v9fs_session_close(v9ses);
        kfree(v9ses);
        s->s_fs_info = NULL;
@@ -205,7 +207,7 @@ v9fs_umount_begin(struct super_block *sb)
        struct v9fs_session_info *v9ses;
 
        v9ses = sb->s_fs_info;
-       v9fs_session_cancel(v9ses);
+       v9fs_session_begin_cancel(v9ses);
 }
 
 static const struct super_operations v9fs_super_ops = {
index 7405f071be671480ebbc4b79b24f1d11e41bc616..5f85b5947613f4a4cfaaf42149d6658d69627799 100644 (file)
@@ -235,6 +235,7 @@ config NFS_COMMON
 
 source "net/sunrpc/Kconfig"
 source "fs/smbfs/Kconfig"
+source "fs/ceph/Kconfig"
 source "fs/cifs/Kconfig"
 source "fs/ncpfs/Kconfig"
 source "fs/coda/Kconfig"
index c3633aa46911556ce8dd56e621bfacdc916769a2..97f340f14ba2d7a181e0788a404ed3698a382ed9 100644 (file)
@@ -125,3 +125,4 @@ obj-$(CONFIG_OCFS2_FS)              += ocfs2/
 obj-$(CONFIG_BTRFS_FS)         += btrfs/
 obj-$(CONFIG_GFS2_FS)           += gfs2/
 obj-$(CONFIG_EXOFS_FS)          += exofs/
+obj-$(CONFIG_CEPH_FS)          += ceph/
index 6910a98bd73cefc29cc0e8435dfd0949625d34fd..4a3af7075c1d09058347ef532edc8c3105a9f9d5 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/parser.h>
 #include <linux/mount.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/statfs.h>
 #include "adfs.h"
index 8306d53307ed0e06a9b1d7b3bb51676c0d9e64ad..3e262711ae06edfc0202e0914bd1627c1ccb643f 100644 (file)
@@ -7,6 +7,7 @@
  *  block allocation, deallocation, calculation of free space.
  */
 
+#include <linux/slab.h>
 #include "affs.h"
 
 /* This is, of course, shamelessly stolen from fs/minix */
index c9744d771d98b80d907378b611d90d4576b6132f..f4b2a4ee4f911bde737b152c0e4434322bb0a82f 100644 (file)
@@ -10,6 +10,7 @@
  *  (C) 1991  Linus Torvalds - minix filesystem
  */
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include "affs.h"
 
 extern const struct inode_operations affs_symlink_inode_operations;
index d41e9673cd9736fae4efb1db81accbeec6c1f7eb..16a3e4765f68769c80a6d838d39a5b4eb55ce2c6 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/magic.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include "affs.h"
 
 extern struct timezone sys_tz;
index e2b1d3f165191444e96f3eebfbeb909aa07f5db1..0fb315dd4d2a77758da40ae63ce9252282305fcd 100644 (file)
@@ -9,7 +9,6 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#include <linux/slab.h>
 #include <linux/sched.h>
 #include "internal.h"
 
index eb765489164f85c4c51d9ac1595a3b48e5d41cd2..a3bcec75c54aa2302728edddfd93de15f4ac513c 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/ip.h>
 #include "internal.h"
index 88067f36e5e7bea4c4d51cff5dd0a9e24e79b3ad..adc1cb771b57ef6be60bee4b90c5da577d0faaa4 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/ctype.h>
index 39b301662f22449e0896e77bf9a964e68bd9a9f0..0df9bc2b724d86c1b310d0a987c15132dbf980e8 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/writeback.h>
+#include <linux/gfp.h>
 #include "internal.h"
 
 static int afs_readpage(struct file *file, struct page *page);
index 023b95b0d9d7612b41ef895c4a2989513fa6b47a..4bd0218473a9bb407a9c86be49f0400461621f24 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/circ_buf.h>
 #include "internal.h"
index c048f06587512c93535e7ca1221d6d7b3ee77f02..d00b312e31108c8a4477e168f445982cd5e30743 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/sched.h>
index 5ffb570cd3a8e1d962b62d2b43324012741ff888..5e813a816ce47b51e9aa7ef1af85145041064a0e 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
+#include <linux/gfp.h>
 #include "internal.h"
 
 
index bde3f19c0995015b2a2496aaf805807a7d7348db..67cf810e0fd6e6cbadde116cf3916555d96226bb 100644 (file)
@@ -9,6 +9,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <rxrpc/packet.h>
index 3ef504370034c2311fdd50f631856ac95ab76903..bb4ed144d0e446c627fb8b4e391664058d094b87 100644 (file)
@@ -189,8 +189,9 @@ void afs_cache_permit(struct afs_vnode *vnode, struct key *key, long acl_order)
        if (!permits)
                goto out_unlock;
 
-       memcpy(permits->permits, xpermits->permits,
-              count * sizeof(struct afs_permit));
+       if (xpermits)
+               memcpy(permits->permits, xpermits->permits,
+                       count * sizeof(struct afs_permit));
 
        _debug("key %x access %x",
               key_serial(key), vnode->status.caller_access);
index 36c1306e09e017b9461b1aefe773664ba5c9ff8b..340afd0cd18290e319bcc1d9695c887b39284025 100644 (file)
@@ -9,6 +9,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include "internal.h"
index 6e689208def255c946cf39d1f44c562aedf51448..9ac260d1361de8e3b50f1bd6f9abad13b8b97594 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include "internal.h"
index 2f05c4fc2a70ad4a1e74c1712d7ba562be2f33aa..25cf4c3f4ff7ded56a2b0f0183b00584668104c7 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include "internal.h"
index 2de009565d8ecf305d40fbdd014855246a43dea5..e4b75d6eda839d6fddae166904d1002f85a4d09f 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/file.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/mount.h>
index 4a1401cea0a1737e45b19d4d7850fe17da55282d..8713c7cfbc799efe1fa604df04dcbebe3966f225 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
index c8a80dffb4557d80999b71c66b94cb4a7d2b75fe..d29b7f6df86285d173de7340c7a338d2d75d09fc 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/magic.h>
 #include <linux/dcache.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 #include "autofs_i.h"
 
index a015b49891df6347f70f6c318666b63a74638dc8..109a6c606d9292d3438795291d22c7a3c9a94b9e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/param.h>
 #include <linux/time.h>
 #include "autofs_i.h"
index e3287d0d1a58815020044ef9f47383eec92cddcb..59096b5e0fc7e85f64867b7b257fb12d25adbbed 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/buffer_head.h>
 #include <linux/string.h>
 
index 15d80bb35d6f7c9e10adcb7ac62d587813449870..f96eff04e11ab4a8b23f7489ee4b0de50e67e152 100644 (file)
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
 #include <linux/user.h>
-#include <linux/slab.h>
 #include <linux/binfmts.h>
 #include <linux/personality.h>
 #include <linux/init.h>
 #include <linux/coredump.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -75,14 +75,16 @@ static int aout_core_dump(struct coredump_params *cprm)
        struct file *file = cprm->file;
        mm_segment_t fs;
        int has_dumped = 0;
-       unsigned long dump_start, dump_size;
+       void __user *dump_start;
+       int dump_size;
        struct user dump;
 #ifdef __alpha__
-#       define START_DATA(u)   (u.start_data)
+#       define START_DATA(u)   ((void __user *)u.start_data)
 #else
-#      define START_DATA(u)    ((u.u_tsize << PAGE_SHIFT) + u.start_code)
+#      define START_DATA(u)    ((void __user *)((u.u_tsize << PAGE_SHIFT) + \
+                                u.start_code))
 #endif
-#       define START_STACK(u)   (u.start_stack)
+#       define START_STACK(u)   ((void __user *)u.start_stack)
 
        fs = get_fs();
        set_fs(KERNEL_DS);
@@ -104,9 +106,9 @@ static int aout_core_dump(struct coredump_params *cprm)
 
 /* make sure we actually have a data and stack area to dump */
        set_fs(USER_DS);
-       if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
+       if (!access_ok(VERIFY_READ, START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
                dump.u_dsize = 0;
-       if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
+       if (!access_ok(VERIFY_READ, START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
                dump.u_ssize = 0;
 
        set_fs(KERNEL_DS);
index 2c32d00a66904883339fe2b25ebe991cdeb6a489..7ab23e006e4cbb20c31c7d4fca47d283c96e3121 100644 (file)
@@ -1590,7 +1590,7 @@ static size_t elf_core_vma_data_size(unsigned long mm_flags)
        struct vm_area_struct *vma;
        size_t size = 0;
 
-       for (vma = current->mm->mmap; vma; vma->vm_next)
+       for (vma = current->mm->mmap; vma; vma = vma->vm_next)
                if (maydump(vma, mm_flags))
                        size += vma->vm_end - vma->vm_start;
        return size;
index 32fb00b52cd069ed600d9c1a925f2b831621325e..b8e8b0acf9bd8df4b3ca369a152afbe01cd9d476 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/stat.h>
-#include <linux/slab.h>
 #include <linux/binfmts.h>
 #include <linux/elf.h>
 #include <linux/init.h>
index 08343505e18455dedebace59a8c489ecb3b1cf7a..aca9d55afb220fddd5998a5d37bfd7a402bb5995 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/stat.h>
-#include <linux/slab.h>
 #include <linux/binfmts.h>
 #include <linux/init.h>
 #include <linux/file.h>
index a16f29e888cd837dd1de4669755c0883bfeb715a..612a5c38d3c1a5fc49e0d0990e19550c27217650 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/mempool.h>
 #include <linux/bio.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 
 struct integrity_slab {
        struct kmem_cache *slab;
index 6df6d6ed74fd9e6296f1249cbd37d8d1885a552c..6ef7b26724ec6cd964400c1074db9ed5f95289f1 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/posix_acl_xattr.h>
 #include <linux/posix_acl.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include "ctree.h"
 #include "btrfs_inode.h"
index c0861e781cdbdfde4b7c42ec1b90032f2059e69a..462859a30141faa7c6ee645ad750cf0ae48c9692 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/freezer.h>
index 28b92a7218ab4cea7c59db65912c071f13b3697b..396039b3a8a24ecb7f37fbec9ef831ed05d5cf94 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/swap.h>
 #include <linux/writeback.h>
 #include <linux/bit_spinlock.h>
-#include <linux/pagevec.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
@@ -445,7 +445,6 @@ static noinline int add_ra_bio_pages(struct inode *inode,
        unsigned long nr_pages = 0;
        struct extent_map *em;
        struct address_space *mapping = inode->i_mapping;
-       struct pagevec pvec;
        struct extent_map_tree *em_tree;
        struct extent_io_tree *tree;
        u64 end;
@@ -461,7 +460,6 @@ static noinline int add_ra_bio_pages(struct inode *inode,
 
        end_index = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
 
-       pagevec_init(&pvec, 0);
        while (last_offset < compressed_end) {
                page_index = last_offset >> PAGE_CACHE_SHIFT;
 
@@ -478,26 +476,17 @@ static noinline int add_ra_bio_pages(struct inode *inode,
                        goto next;
                }
 
-               page = alloc_page(mapping_gfp_mask(mapping) & ~__GFP_FS);
+               page = __page_cache_alloc(mapping_gfp_mask(mapping) &
+                                                               ~__GFP_FS);
                if (!page)
                        break;
 
-               page->index = page_index;
-               /*
-                * what we want to do here is call add_to_page_cache_lru,
-                * but that isn't exported, so we reproduce it here
-                */
-               if (add_to_page_cache(page, mapping,
-                                     page->index, GFP_NOFS)) {
+               if (add_to_page_cache_lru(page, mapping, page_index,
+                                                               GFP_NOFS)) {
                        page_cache_release(page);
                        goto next;
                }
 
-               /* open coding of lru_cache_add, also not exported */
-               page_cache_get(page);
-               if (!pagevec_add(&pvec, page))
-                       __pagevec_lru_add_file(&pvec);
-
                end = last_offset + PAGE_CACHE_SIZE - 1;
                /*
                 * at this point, we have a locked page in the page cache
@@ -551,8 +540,6 @@ static noinline int add_ra_bio_pages(struct inode *inode,
 next:
                last_offset += PAGE_CACHE_SIZE;
        }
-       if (pagevec_count(&pvec))
-               __pagevec_lru_add_file(&pvec);
        return 0;
 }
 
index c4bc570a396eebf5ede775dc39b004c9ff493227..6795a713b2052bbd7560590dccbba8b33ca6c717 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -3040,6 +3041,10 @@ static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans,
        if (ret > 0 || item_size != btrfs_item_size_nr(leaf, path->slots[0]))
                goto err;
 
+       /* the leaf has  changed, it now has room.  return now */
+       if (btrfs_leaf_free_space(root, path->nodes[0]) >= ins_len)
+               goto err;
+
        if (key.type == BTRFS_EXTENT_DATA_KEY) {
                fi = btrfs_item_ptr(leaf, path->slots[0],
                                    struct btrfs_file_extent_item);
index 0af2e3868573467b60d3d8990e9d82720bc26df3..746a7248678ebe3d7396c7bd5746b4ce3b654f80 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/completion.h>
 #include <linux/backing-dev.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <asm/kmap_types.h>
 #include "extent_io.h"
 #include "extent_map.h"
@@ -834,7 +835,6 @@ struct btrfs_fs_info {
        u64 last_trans_log_full_commit;
        u64 open_ioctl_trans;
        unsigned long mount_opt;
-       u64 max_extent;
        u64 max_inline;
        u64 alloc_start;
        struct btrfs_transaction *running_transaction;
index 84e6781413b177acfd04c1a922c72da48c8f4e01..902ce507c4e34a01e4e5afbcba26aa31c9d18d63 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/sort.h>
 #include "ctree.h"
 #include "delayed-ref.h"
index 11d0ad30e203c7ebecd9845d2989fe1c04311f60..e7b8f2c89ccb23555a81df04249f8f5f14e32f75 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/crc32c.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
@@ -1634,7 +1635,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        atomic_set(&fs_info->async_submit_draining, 0);
        atomic_set(&fs_info->nr_async_bios, 0);
        fs_info->sb = sb;
-       fs_info->max_extent = (u64)-1;
        fs_info->max_inline = 8192 * 1024;
        fs_info->metadata_ratio = 0;
 
@@ -1922,7 +1922,11 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 
        csum_root->track_dirty = 1;
 
-       btrfs_read_block_groups(extent_root);
+       ret = btrfs_read_block_groups(extent_root);
+       if (ret) {
+               printk(KERN_ERR "Failed to read block groups: %d\n", ret);
+               goto fail_block_groups;
+       }
 
        fs_info->generation = generation;
        fs_info->last_trans_committed = generation;
@@ -1932,7 +1936,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
                                               "btrfs-cleaner");
        if (IS_ERR(fs_info->cleaner_kthread))
-               goto fail_csum_root;
+               goto fail_block_groups;
 
        fs_info->transaction_kthread = kthread_run(transaction_kthread,
                                                   tree_root,
@@ -2020,7 +2024,8 @@ fail_cleaner:
        filemap_write_and_wait(fs_info->btree_inode->i_mapping);
        invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 
-fail_csum_root:
+fail_block_groups:
+       btrfs_free_block_groups(fs_info);
        free_extent_buffer(csum_root->node);
        free_extent_buffer(csum_root->commit_root);
 fail_dev_root:
index 1727b26fb1944706f87210ddec2ca07a944b83e0..9e23ffea7f54f9c71513cd23cf548f0548358621 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/sort.h>
 #include <linux/rcupdate.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "hash.h"
 #include "ctree.h"
@@ -2676,6 +2677,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags,
 
        INIT_LIST_HEAD(&found->block_groups);
        init_rwsem(&found->groups_sem);
+       init_waitqueue_head(&found->flush_wait);
+       init_waitqueue_head(&found->allocate_wait);
        spin_lock_init(&found->lock);
        found->flags = flags;
        found->total_bytes = total_bytes;
@@ -2846,7 +2849,7 @@ int btrfs_unreserve_metadata_for_delalloc(struct btrfs_root *root,
        }
        spin_unlock(&BTRFS_I(inode)->accounting_lock);
 
-       BTRFS_I(inode)->reserved_extents--;
+       BTRFS_I(inode)->reserved_extents -= num_items;
        BUG_ON(BTRFS_I(inode)->reserved_extents < 0);
 
        if (meta_sinfo->bytes_delalloc < num_bytes) {
@@ -2944,12 +2947,10 @@ static void flush_delalloc(struct btrfs_root *root,
 
        spin_lock(&info->lock);
 
-       if (!info->flushing) {
+       if (!info->flushing)
                info->flushing = 1;
-               init_waitqueue_head(&info->flush_wait);
-       } else {
+       else
                wait = true;
-       }
 
        spin_unlock(&info->lock);
 
@@ -3011,7 +3012,6 @@ static int maybe_allocate_chunk(struct btrfs_root *root,
        if (!info->allocating_chunk) {
                info->force_alloc = 1;
                info->allocating_chunk = 1;
-               init_waitqueue_head(&info->allocate_wait);
        } else {
                wait = true;
        }
@@ -3111,7 +3111,7 @@ again:
                return -ENOSPC;
        }
 
-       BTRFS_I(inode)->reserved_extents++;
+       BTRFS_I(inode)->reserved_extents += num_items;
        check_force_delalloc(meta_sinfo);
        spin_unlock(&meta_sinfo->lock);
 
@@ -4170,6 +4170,10 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
        ins->offset = 0;
 
        space_info = __find_space_info(root->fs_info, data);
+       if (!space_info) {
+               printk(KERN_ERR "No space info for %d\n", data);
+               return -ENOSPC;
+       }
 
        if (orig_root->ref_cows || empty_size)
                allowed_chunk_alloc = 1;
@@ -5205,6 +5209,8 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
        next = btrfs_find_tree_block(root, bytenr, blocksize);
        if (!next) {
                next = btrfs_find_create_tree_block(root, bytenr, blocksize);
+               if (!next)
+                       return -ENOMEM;
                reada = 1;
        }
        btrfs_tree_lock(next);
@@ -5417,7 +5423,8 @@ static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
                if (ret > 0) {
                        path->slots[level]++;
                        continue;
-               }
+               } else if (ret < 0)
+                       return ret;
                level = wc->level;
        }
        return 0;
@@ -7369,7 +7376,6 @@ static int find_first_block_group(struct btrfs_root *root,
                }
                path->slots[0]++;
        }
-       ret = -ENOENT;
 out:
        return ret;
 }
index c99121ac5d6b7f1f9f3b05b2c4b1e47e1ac06cbf..d2d03684fab261fb9663f1d18ef19d9f23d98b78 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/slab.h>
 #include <linux/bio.h>
 #include <linux/mm.h>
-#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/page-flags.h>
 #include <linux/module.h>
@@ -2679,33 +2678,20 @@ int extent_readpages(struct extent_io_tree *tree,
 {
        struct bio *bio = NULL;
        unsigned page_idx;
-       struct pagevec pvec;
        unsigned long bio_flags = 0;
 
-       pagevec_init(&pvec, 0);
        for (page_idx = 0; page_idx < nr_pages; page_idx++) {
                struct page *page = list_entry(pages->prev, struct page, lru);
 
                prefetchw(&page->flags);
                list_del(&page->lru);
-               /*
-                * what we want to do here is call add_to_page_cache_lru,
-                * but that isn't exported, so we reproduce it here
-                */
-               if (!add_to_page_cache(page, mapping,
+               if (!add_to_page_cache_lru(page, mapping,
                                        page->index, GFP_KERNEL)) {
-
-                       /* open coding of lru_cache_add, also not exported */
-                       page_cache_get(page);
-                       if (!pagevec_add(&pvec, page))
-                               __pagevec_lru_add_file(&pvec);
                        __extent_read_full_page(tree, page, get_extent,
                                                &bio, 0, &bio_flags);
                }
                page_cache_release(page);
        }
-       if (pagevec_count(&pvec))
-               __pagevec_lru_add_file(&pvec);
        BUG_ON(!list_empty(pages));
        if (bio)
                submit_one_bio(READ, bio, 0, bio_flags);
index 28d87ba60ce8170d0c10d14225dc5ce37eb24beb..454ca52d6451b649b78b48cba908f3fd1eb2bada 100644 (file)
@@ -1,5 +1,4 @@
 #include <linux/err.h>
-#include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
index 9b99886562d0b2c8ea9e883f3f2623b0ec6d8674..54a255065aa3235a7672d64f5fcf506615ae8ef3 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/bio.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
 #include "ctree.h"
index ee3323c7fc1c8fe2554ab222d2e424b6938ad335..29ff749ff4caaa35386f35173b169502e9ac3ded 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/writeback.h>
 #include <linux/statfs.h>
 #include <linux/compat.h>
+#include <linux/slab.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
index dd831ed31eead2c4bda12eaf37a4c331458a9646..f488fac04d99ea45eea93607bbf17c021b5b2207 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/math64.h>
 #include "ctree.h"
 #include "free-space-cache.h"
index 02bb099845fd07dcf3566a1adef85c2fffed71ab..2bfdc641d4e3ba046f3afd89400f362ec959e46b 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/xattr.h>
 #include <linux/posix_acl.h>
 #include <linux/falloc.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
@@ -796,7 +797,7 @@ static noinline int cow_file_range(struct inode *inode,
        while (disk_num_bytes > 0) {
                unsigned long op;
 
-               cur_alloc_size = min(disk_num_bytes, root->fs_info->max_extent);
+               cur_alloc_size = disk_num_bytes;
                ret = btrfs_reserve_extent(trans, root, cur_alloc_size,
                                           root->sectorsize, 0, alloc_hint,
                                           (u64)-1, &ins, 1);
@@ -1227,30 +1228,9 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
 static int btrfs_split_extent_hook(struct inode *inode,
                                    struct extent_state *orig, u64 split)
 {
-       struct btrfs_root *root = BTRFS_I(inode)->root;
-       u64 size;
-
        if (!(orig->state & EXTENT_DELALLOC))
                return 0;
 
-       size = orig->end - orig->start + 1;
-       if (size > root->fs_info->max_extent) {
-               u64 num_extents;
-               u64 new_size;
-
-               new_size = orig->end - split + 1;
-               num_extents = div64_u64(size + root->fs_info->max_extent - 1,
-                                       root->fs_info->max_extent);
-
-               /*
-                * if we break a large extent up then leave oustanding_extents
-                * be, since we've already accounted for the large extent.
-                */
-               if (div64_u64(new_size + root->fs_info->max_extent - 1,
-                             root->fs_info->max_extent) < num_extents)
-                       return 0;
-       }
-
        spin_lock(&BTRFS_I(inode)->accounting_lock);
        BTRFS_I(inode)->outstanding_extents++;
        spin_unlock(&BTRFS_I(inode)->accounting_lock);
@@ -1268,38 +1248,10 @@ static int btrfs_merge_extent_hook(struct inode *inode,
                                   struct extent_state *new,
                                   struct extent_state *other)
 {
-       struct btrfs_root *root = BTRFS_I(inode)->root;
-       u64 new_size, old_size;
-       u64 num_extents;
-
        /* not delalloc, ignore it */
        if (!(other->state & EXTENT_DELALLOC))
                return 0;
 
-       old_size = other->end - other->start + 1;
-       if (new->start < other->start)
-               new_size = other->end - new->start + 1;
-       else
-               new_size = new->end - other->start + 1;
-
-       /* we're not bigger than the max, unreserve the space and go */
-       if (new_size <= root->fs_info->max_extent) {
-               spin_lock(&BTRFS_I(inode)->accounting_lock);
-               BTRFS_I(inode)->outstanding_extents--;
-               spin_unlock(&BTRFS_I(inode)->accounting_lock);
-               return 0;
-       }
-
-       /*
-        * If we grew by another max_extent, just return, we want to keep that
-        * reserved amount.
-        */
-       num_extents = div64_u64(old_size + root->fs_info->max_extent - 1,
-                               root->fs_info->max_extent);
-       if (div64_u64(new_size + root->fs_info->max_extent - 1,
-                     root->fs_info->max_extent) > num_extents)
-               return 0;
-
        spin_lock(&BTRFS_I(inode)->accounting_lock);
        BTRFS_I(inode)->outstanding_extents--;
        spin_unlock(&BTRFS_I(inode)->accounting_lock);
@@ -1328,6 +1280,7 @@ static int btrfs_set_bit_hook(struct inode *inode, u64 start, u64 end,
                BTRFS_I(inode)->outstanding_extents++;
                spin_unlock(&BTRFS_I(inode)->accounting_lock);
                btrfs_delalloc_reserve_space(root, inode, end - start + 1);
+
                spin_lock(&root->fs_info->delalloc_lock);
                BTRFS_I(inode)->delalloc_bytes += end - start + 1;
                root->fs_info->delalloc_bytes += end - start + 1;
@@ -1356,6 +1309,7 @@ static int btrfs_clear_bit_hook(struct inode *inode,
 
                if (bits & EXTENT_DO_ACCOUNTING) {
                        spin_lock(&BTRFS_I(inode)->accounting_lock);
+                       WARN_ON(!BTRFS_I(inode)->outstanding_extents);
                        BTRFS_I(inode)->outstanding_extents--;
                        spin_unlock(&BTRFS_I(inode)->accounting_lock);
                        btrfs_unreserve_metadata_for_delalloc(root, inode, 1);
@@ -5384,7 +5338,6 @@ free:
 void btrfs_drop_inode(struct inode *inode)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
-
        if (inode->i_nlink > 0 && btrfs_root_refs(&root->root_item) == 0)
                generic_delete_inode(inode);
        else
@@ -5788,18 +5741,15 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
        struct btrfs_trans_handle *trans;
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_key ins;
-       u64 alloc_size;
        u64 cur_offset = start;
        u64 num_bytes = end - start;
        int ret = 0;
        u64 i_size;
 
        while (num_bytes > 0) {
-               alloc_size = min(num_bytes, root->fs_info->max_extent);
-
                trans = btrfs_start_transaction(root, 1);
 
-               ret = btrfs_reserve_extent(trans, root, alloc_size,
+               ret = btrfs_reserve_extent(trans, root, num_bytes,
                                           root->sectorsize, 0, alloc_hint,
                                           (u64)-1, &ins, 1);
                if (ret) {
index 2845c6ceecd247f78adcd2b049ea220bbe764ff4..e84ef60ffe35bc13830e78754c6698a135e7683c 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/security.h>
 #include <linux/xattr.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
@@ -48,7 +49,6 @@
 #include "print-tree.h"
 #include "volumes.h"
 #include "locking.h"
-#include "ctree.h"
 
 /* Mask out flags that are inappropriate for the given type of inode. */
 static inline __u32 btrfs_mask_flags(umode_t mode, __u32 flags)
@@ -511,7 +511,7 @@ static int should_defrag_range(struct inode *inode, u64 start, u64 len,
                em = btrfs_get_extent(inode, NULL, 0, start, len, 0);
                unlock_extent(io_tree, start, start + len - 1, GFP_NOFS);
 
-               if (!em)
+               if (IS_ERR(em))
                        return 0;
        }
 
@@ -1212,6 +1212,9 @@ static noinline int btrfs_ioctl_ino_lookup(struct file *file,
                return -EPERM;
 
        args = kmalloc(sizeof(*args), GFP_KERNEL);
+       if (!args)
+               return -ENOMEM;
+
        if (copy_from_user(args, argp, sizeof(*args))) {
                kfree(args);
                return -EFAULT;
@@ -1375,6 +1378,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
                                           sizeof(*range))) {
                                ret = -EFAULT;
                                kfree(range);
+                               goto out;
                        }
                        /* compression requires us to start the IO */
                        if ((range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)) {
index 1c36e5cd8f55495843631f7e5d3e6245d47684dd..6151f2ea38bb193eaeed1f45bc7f2d1f60c0b1d7 100644 (file)
@@ -16,7 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 #include <linux/sched.h>
-#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/spinlock.h>
 #include <linux/page-flags.h>
index a8ffecd0b4912f297e935153fda10217c7c02d0e..a127c0ebb2dcaec1d6ac6733855ac88cb6aff4a3 100644 (file)
@@ -16,7 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/writeback.h>
@@ -303,6 +302,7 @@ static int __btrfs_remove_ordered_extent(struct inode *inode,
                                struct btrfs_ordered_extent *entry)
 {
        struct btrfs_ordered_inode_tree *tree;
+       struct btrfs_root *root = BTRFS_I(inode)->root;
        struct rb_node *node;
 
        tree = &BTRFS_I(inode)->ordered_tree;
@@ -312,12 +312,13 @@ static int __btrfs_remove_ordered_extent(struct inode *inode,
        set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags);
 
        spin_lock(&BTRFS_I(inode)->accounting_lock);
+       WARN_ON(!BTRFS_I(inode)->outstanding_extents);
        BTRFS_I(inode)->outstanding_extents--;
        spin_unlock(&BTRFS_I(inode)->accounting_lock);
        btrfs_unreserve_metadata_for_delalloc(BTRFS_I(inode)->root,
                                              inode, 1);
 
-       spin_lock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock);
+       spin_lock(&root->fs_info->ordered_extent_lock);
        list_del_init(&entry->root_extent_list);
 
        /*
@@ -329,7 +330,7 @@ static int __btrfs_remove_ordered_extent(struct inode *inode,
            !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) {
                list_del_init(&BTRFS_I(inode)->ordered_operations);
        }
-       spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock);
+       spin_unlock(&root->fs_info->ordered_extent_lock);
 
        return 0;
 }
index d0cc62bccb948e776fb9845c7da1a8f2119788f6..a97314cf6bd6ef7ac44aa60a4485261a74e241a7 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/sort.h>
 #include "ctree.h"
 #include "ref-cache.h"
index 0b23942cbc0dfc5296afe724759013c14188ac54..e558dd941ded32d39493a9a605156d77983abed2 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/writeback.h>
 #include <linux/blkdev.h>
 #include <linux/rbtree.h>
+#include <linux/slab.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
index 9ac612e6ca60b7b2a3ea3882821a433cd3989a48..1866dff0538ef626a17d2dcbf29d9df4df46b3aa 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/namei.h>
 #include <linux/miscdevice.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 #include "compat.h"
 #include "ctree.h"
 #include "disk-io.h"
@@ -64,10 +65,9 @@ static void btrfs_put_super(struct super_block *sb)
 
 enum {
        Opt_degraded, Opt_subvol, Opt_subvolid, Opt_device, Opt_nodatasum,
-       Opt_nodatacow, Opt_max_extent, Opt_max_inline, Opt_alloc_start,
-       Opt_nobarrier, Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool,
-       Opt_noacl, Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio,
-       Opt_flushoncommit,
+       Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd,
+       Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress,
+       Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
        Opt_discard, Opt_err,
 };
 
@@ -79,7 +79,6 @@ static match_table_t tokens = {
        {Opt_nodatasum, "nodatasum"},
        {Opt_nodatacow, "nodatacow"},
        {Opt_nobarrier, "nobarrier"},
-       {Opt_max_extent, "max_extent=%s"},
        {Opt_max_inline, "max_inline=%s"},
        {Opt_alloc_start, "alloc_start=%s"},
        {Opt_thread_pool, "thread_pool=%d"},
@@ -188,18 +187,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
                                       info->thread_pool_size);
                        }
                        break;
-               case Opt_max_extent:
-                       num = match_strdup(&args[0]);
-                       if (num) {
-                               info->max_extent = memparse(num, NULL);
-                               kfree(num);
-
-                               info->max_extent = max_t(u64,
-                                       info->max_extent, root->sectorsize);
-                               printk(KERN_INFO "btrfs: max_extent at %llu\n",
-                                      (unsigned long long)info->max_extent);
-                       }
-                       break;
                case Opt_max_inline:
                        num = match_strdup(&args[0]);
                        if (num) {
@@ -529,9 +516,6 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
                seq_puts(seq, ",nodatacow");
        if (btrfs_test_opt(root, NOBARRIER))
                seq_puts(seq, ",nobarrier");
-       if (info->max_extent != (u64)-1)
-               seq_printf(seq, ",max_extent=%llu",
-                          (unsigned long long)info->max_extent);
        if (info->max_inline != 8192 * 1024)
                seq_printf(seq, ",max_inline=%llu",
                           (unsigned long long)info->max_inline);
index 2d654c1c794d2f7690409a53bfcbc02ae95890a9..2cb116099b90207d0f1910176de8a029bd23c93f 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/writeback.h>
 #include <linux/pagemap.h>
@@ -147,18 +148,13 @@ static void wait_current_trans(struct btrfs_root *root)
                while (1) {
                        prepare_to_wait(&root->fs_info->transaction_wait, &wait,
                                        TASK_UNINTERRUPTIBLE);
-                       if (cur_trans->blocked) {
-                               mutex_unlock(&root->fs_info->trans_mutex);
-                               schedule();
-                               mutex_lock(&root->fs_info->trans_mutex);
-                               finish_wait(&root->fs_info->transaction_wait,
-                                           &wait);
-                       } else {
-                               finish_wait(&root->fs_info->transaction_wait,
-                                           &wait);
+                       if (!cur_trans->blocked)
                                break;
-                       }
+                       mutex_unlock(&root->fs_info->trans_mutex);
+                       schedule();
+                       mutex_lock(&root->fs_info->trans_mutex);
                }
+               finish_wait(&root->fs_info->transaction_wait, &wait);
                put_transaction(cur_trans);
        }
 }
@@ -760,10 +756,17 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        struct btrfs_root_item *new_root_item;
        struct btrfs_root *tree_root = fs_info->tree_root;
        struct btrfs_root *root = pending->root;
+       struct btrfs_root *parent_root;
+       struct inode *parent_inode;
        struct extent_buffer *tmp;
        struct extent_buffer *old;
        int ret;
        u64 objectid;
+       int namelen;
+       u64 index = 0;
+
+       parent_inode = pending->dentry->d_parent->d_inode;
+       parent_root = BTRFS_I(parent_inode)->root;
 
        new_root_item = kmalloc(sizeof(*new_root_item), GFP_NOFS);
        if (!new_root_item) {
@@ -774,79 +777,59 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        if (ret)
                goto fail;
 
-       record_root_in_trans(trans, root);
-       btrfs_set_root_last_snapshot(&root->root_item, trans->transid);
-       memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
-
        key.objectid = objectid;
        /* record when the snapshot was created in key.offset */
        key.offset = trans->transid;
        btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
 
-       old = btrfs_lock_root_node(root);
-       btrfs_cow_block(trans, root, old, NULL, 0, &old);
-       btrfs_set_lock_blocking(old);
-
-       btrfs_copy_root(trans, root, old, &tmp, objectid);
-       btrfs_tree_unlock(old);
-       free_extent_buffer(old);
-
-       btrfs_set_root_node(new_root_item, tmp);
-       ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
-                               new_root_item);
-       btrfs_tree_unlock(tmp);
-       free_extent_buffer(tmp);
-       if (ret)
-               goto fail;
-
-       key.offset = (u64)-1;
        memcpy(&pending->root_key, &key, sizeof(key));
-fail:
-       kfree(new_root_item);
-       return ret;
-}
-
-static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info,
-                                  struct btrfs_pending_snapshot *pending)
-{
-       int ret;
-       int namelen;
-       u64 index = 0;
-       struct btrfs_trans_handle *trans;
-       struct inode *parent_inode;
-       struct btrfs_root *parent_root;
-
-       parent_inode = pending->dentry->d_parent->d_inode;
-       parent_root = BTRFS_I(parent_inode)->root;
-       trans = btrfs_join_transaction(parent_root, 1);
+       pending->root_key.offset = (u64)-1;
 
+       record_root_in_trans(trans, parent_root);
        /*
         * insert the directory item
         */
        namelen = strlen(pending->name);
        ret = btrfs_set_inode_index(parent_inode, &index);
+       BUG_ON(ret);
        ret = btrfs_insert_dir_item(trans, parent_root,
                            pending->name, namelen,
                            parent_inode->i_ino,
                            &pending->root_key, BTRFS_FT_DIR, index);
-
-       if (ret)
-               goto fail;
+       BUG_ON(ret);
 
        btrfs_i_size_write(parent_inode, parent_inode->i_size + namelen * 2);
        ret = btrfs_update_inode(trans, parent_root, parent_inode);
        BUG_ON(ret);
 
+       record_root_in_trans(trans, root);
+       btrfs_set_root_last_snapshot(&root->root_item, trans->transid);
+       memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
+
+       old = btrfs_lock_root_node(root);
+       btrfs_cow_block(trans, root, old, NULL, 0, &old);
+       btrfs_set_lock_blocking(old);
+
+       btrfs_copy_root(trans, root, old, &tmp, objectid);
+       btrfs_tree_unlock(old);
+       free_extent_buffer(old);
+
+       btrfs_set_root_node(new_root_item, tmp);
+       ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
+                               new_root_item);
+       BUG_ON(ret);
+       btrfs_tree_unlock(tmp);
+       free_extent_buffer(tmp);
+
        ret = btrfs_add_root_ref(trans, parent_root->fs_info->tree_root,
                                 pending->root_key.objectid,
                                 parent_root->root_key.objectid,
                                 parent_inode->i_ino, index, pending->name,
                                 namelen);
-
        BUG_ON(ret);
 
 fail:
-       btrfs_end_transaction(trans, fs_info->fs_root);
+       kfree(new_root_item);
        return ret;
 }
 
@@ -867,25 +850,6 @@ static noinline int create_pending_snapshots(struct btrfs_trans_handle *trans,
        return 0;
 }
 
-static noinline int finish_pending_snapshots(struct btrfs_trans_handle *trans,
-                                            struct btrfs_fs_info *fs_info)
-{
-       struct btrfs_pending_snapshot *pending;
-       struct list_head *head = &trans->transaction->pending_snapshots;
-       int ret;
-
-       while (!list_empty(head)) {
-               pending = list_entry(head->next,
-                                    struct btrfs_pending_snapshot, list);
-               ret = finish_pending_snapshot(fs_info, pending);
-               BUG_ON(ret);
-               list_del(&pending->list);
-               kfree(pending->name);
-               kfree(pending);
-       }
-       return 0;
-}
-
 static void update_super_roots(struct btrfs_root *root)
 {
        struct btrfs_root_item *root_item;
@@ -1097,9 +1061,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_finish_extent_commit(trans, root);
 
-       /* do the directory inserts of any pending snapshot creations */
-       finish_pending_snapshots(trans, root->fs_info);
-
        mutex_lock(&root->fs_info->trans_mutex);
 
        cur_trans->commit_done = 1;
index 1255fcc8ade5805abfa9230052e39f250c9c7a64..af57dd2b43d429777ff2530dfbc978ed33f76e2a 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "ctree.h"
 #include "transaction.h"
 #include "disk-io.h"
index 9df8e3f1ccabea1daa2e3d4fd93fdb6424fa4555..aa7dc36dac786a34d594a39525718acbb35a4e7e 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/sched.h>
 #include <linux/bio.h>
+#include <linux/slab.h>
 #include <linux/buffer_head.h>
 #include <linux/blkdev.h>
 #include <linux/random.h>
@@ -2198,9 +2199,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                min_stripes = 2;
        }
        if (type & (BTRFS_BLOCK_GROUP_RAID1)) {
-               num_stripes = min_t(u64, 2, fs_devices->rw_devices);
-               if (num_stripes < 2)
+               if (fs_devices->rw_devices < 2)
                        return -ENOSPC;
+               num_stripes = 2;
                min_stripes = 2;
        }
        if (type & (BTRFS_BLOCK_GROUP_RAID10)) {
@@ -2244,8 +2245,10 @@ again:
                do_div(calc_size, stripe_len);
                calc_size *= stripe_len;
        }
+
        /* we don't want tiny stripes */
-       calc_size = max_t(u64, min_stripe_size, calc_size);
+       if (!looped)
+               calc_size = max_t(u64, min_stripe_size, calc_size);
 
        do_div(calc_size, stripe_len);
        calc_size *= stripe_len;
@@ -3389,6 +3392,8 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
        key.type = 0;
 again:
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
+       if (ret < 0)
+               goto error;
        while (1) {
                leaf = path->nodes[0];
                slot = path->slots[0];
index 27089311fbea467b4ca6ec7d6522ae0525231c6f..37fe101a4e0dd22a85f4628e98285cc33c3ad879 100644 (file)
@@ -9,6 +9,7 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/buffer_head.h>
 #include "internal.h"
index eeb4986ea7db7cbb65b0b48685ae0a0d3f6a1a7e..d5db84a1ee0d6ab8b2b6b1e7cdf83d71bccc4c55 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/security.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 #define CACHEFILES_KEYBUF_SIZE 512
index 1d8332563863ce5d858971a68f4a7463c72385c2..0f0d41fbb03f96466393fed9766776d3113d4153 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/mount.h>
+#include <linux/slab.h>
 #include <linux/file.h>
 #include "internal.h"
 
index f3e7a0bf068b17cf4cb2e5a5f6fa701daf08d4e5..e18b183b47e1c2e11aa49ad37ec6cf227305f68f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/fsnotify.h>
 #include <linux/quotaops.h>
 #include <linux/xattr.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 static const char cachefiles_xattr_cache[] =
diff --git a/fs/ceph/Kconfig b/fs/ceph/Kconfig
new file mode 100644 (file)
index 0000000..04b8280
--- /dev/null
@@ -0,0 +1,27 @@
+config CEPH_FS
+        tristate "Ceph distributed file system (EXPERIMENTAL)"
+       depends on INET && EXPERIMENTAL
+       select LIBCRC32C
+       select CONFIG_CRYPTO_AES
+       help
+         Choose Y or M here to include support for mounting the
+         experimental Ceph distributed file system.  Ceph is an extremely
+         scalable file system designed to provide high performance,
+         reliable access to petabytes of storage.
+
+         More information at http://ceph.newdream.net/.
+
+         If unsure, say N.
+
+config CEPH_FS_PRETTYDEBUG
+       bool "Include file:line in ceph debug output"
+       depends on CEPH_FS
+       default n
+       help
+         If you say Y here, debug output will include a filename and
+         line to aid debugging.  This icnreases kernel size and slows
+         execution slightly when debug call sites are enabled (e.g.,
+         via CONFIG_DYNAMIC_DEBUG).
+
+         If unsure, say N.
+
diff --git a/fs/ceph/Makefile b/fs/ceph/Makefile
new file mode 100644 (file)
index 0000000..6a660e6
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# Makefile for CEPH filesystem.
+#
+
+ifneq ($(KERNELRELEASE),)
+
+obj-$(CONFIG_CEPH_FS) += ceph.o
+
+ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \
+       export.o caps.o snap.o xattr.o \
+       messenger.o msgpool.o buffer.o pagelist.o \
+       mds_client.o mdsmap.o \
+       mon_client.o \
+       osd_client.o osdmap.o crush/crush.o crush/mapper.o crush/hash.o \
+       debugfs.o \
+       auth.o auth_none.o \
+       crypto.o armor.o \
+       auth_x.o \
+       ceph_fs.o ceph_strings.o ceph_hash.o ceph_frag.o
+
+else
+#Otherwise we were called directly from the command
+# line; invoke the kernel build system.
+
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+PWD := $(shell pwd)
+
+default: all
+
+all:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_FS=m modules
+
+modules_install:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_CEPH_FS=m modules_install
+
+clean:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
+
+endif
diff --git a/fs/ceph/README b/fs/ceph/README
new file mode 100644 (file)
index 0000000..18352fa
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# The following files are shared by (and manually synchronized
+# between) the Ceph userland and kernel client.
+#
+# userland                  kernel
+src/include/ceph_fs.h      fs/ceph/ceph_fs.h
+src/include/ceph_fs.cc     fs/ceph/ceph_fs.c
+src/include/msgr.h         fs/ceph/msgr.h
+src/include/rados.h        fs/ceph/rados.h
+src/include/ceph_strings.cc fs/ceph/ceph_strings.c
+src/include/ceph_frag.h            fs/ceph/ceph_frag.h
+src/include/ceph_frag.cc    fs/ceph/ceph_frag.c
+src/include/ceph_hash.h            fs/ceph/ceph_hash.h
+src/include/ceph_hash.cc    fs/ceph/ceph_hash.c
+src/crush/crush.c          fs/ceph/crush/crush.c
+src/crush/crush.h          fs/ceph/crush/crush.h
+src/crush/mapper.c         fs/ceph/crush/mapper.c
+src/crush/mapper.h         fs/ceph/crush/mapper.h
+src/crush/hash.h           fs/ceph/crush/hash.h
+src/crush/hash.c           fs/ceph/crush/hash.c
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
new file mode 100644 (file)
index 0000000..aa3cd7c
--- /dev/null
@@ -0,0 +1,1195 @@
+#include "ceph_debug.h"
+
+#include <linux/backing-dev.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/writeback.h>   /* generic_writepages */
+#include <linux/slab.h>
+#include <linux/pagevec.h>
+#include <linux/task_io_accounting_ops.h>
+
+#include "super.h"
+#include "osd_client.h"
+
+/*
+ * Ceph address space ops.
+ *
+ * There are a few funny things going on here.
+ *
+ * The page->private field is used to reference a struct
+ * ceph_snap_context for _every_ dirty page.  This indicates which
+ * snapshot the page was logically dirtied in, and thus which snap
+ * context needs to be associated with the osd write during writeback.
+ *
+ * Similarly, struct ceph_inode_info maintains a set of counters to
+ * count dirty pages on the inode.  In the absense of snapshots,
+ * i_wrbuffer_ref == i_wrbuffer_ref_head == the dirty page count.
+ *
+ * When a snapshot is taken (that is, when the client receives
+ * notification that a snapshot was taken), each inode with caps and
+ * with dirty pages (dirty pages implies there is a cap) gets a new
+ * ceph_cap_snap in the i_cap_snaps list (which is sorted in ascending
+ * order, new snaps go to the tail).  The i_wrbuffer_ref_head count is
+ * moved to capsnap->dirty. (Unless a sync write is currently in
+ * progress.  In that case, the capsnap is said to be "pending", new
+ * writes cannot start, and the capsnap isn't "finalized" until the
+ * write completes (or fails) and a final size/mtime for the inode for
+ * that snap can be settled upon.)  i_wrbuffer_ref_head is reset to 0.
+ *
+ * On writeback, we must submit writes to the osd IN SNAP ORDER.  So,
+ * we look for the first capsnap in i_cap_snaps and write out pages in
+ * that snap context _only_.  Then we move on to the next capsnap,
+ * eventually reaching the "live" or "head" context (i.e., pages that
+ * are not yet snapped) and are writing the most recently dirtied
+ * pages.
+ *
+ * Invalidate and so forth must take care to ensure the dirty page
+ * accounting is preserved.
+ */
+
+#define CONGESTION_ON_THRESH(congestion_kb) (congestion_kb >> (PAGE_SHIFT-10))
+#define CONGESTION_OFF_THRESH(congestion_kb)                           \
+       (CONGESTION_ON_THRESH(congestion_kb) -                          \
+        (CONGESTION_ON_THRESH(congestion_kb) >> 2))
+
+
+
+/*
+ * Dirty a page.  Optimistically adjust accounting, on the assumption
+ * that we won't race with invalidate.  If we do, readjust.
+ */
+static int ceph_set_page_dirty(struct page *page)
+{
+       struct address_space *mapping = page->mapping;
+       struct inode *inode;
+       struct ceph_inode_info *ci;
+       int undo = 0;
+       struct ceph_snap_context *snapc;
+
+       if (unlikely(!mapping))
+               return !TestSetPageDirty(page);
+
+       if (TestSetPageDirty(page)) {
+               dout("%p set_page_dirty %p idx %lu -- already dirty\n",
+                    mapping->host, page, page->index);
+               return 0;
+       }
+
+       inode = mapping->host;
+       ci = ceph_inode(inode);
+
+       /*
+        * Note that we're grabbing a snapc ref here without holding
+        * any locks!
+        */
+       snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
+
+       /* dirty the head */
+       spin_lock(&inode->i_lock);
+       if (ci->i_wrbuffer_ref_head == 0)
+               ci->i_head_snapc = ceph_get_snap_context(snapc);
+       ++ci->i_wrbuffer_ref_head;
+       if (ci->i_wrbuffer_ref == 0)
+               igrab(inode);
+       ++ci->i_wrbuffer_ref;
+       dout("%p set_page_dirty %p idx %lu head %d/%d -> %d/%d "
+            "snapc %p seq %lld (%d snaps)\n",
+            mapping->host, page, page->index,
+            ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1,
+            ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
+            snapc, snapc->seq, snapc->num_snaps);
+       spin_unlock(&inode->i_lock);
+
+       /* now adjust page */
+       spin_lock_irq(&mapping->tree_lock);
+       if (page->mapping) {    /* Race with truncate? */
+               WARN_ON_ONCE(!PageUptodate(page));
+
+               if (mapping_cap_account_dirty(mapping)) {
+                       __inc_zone_page_state(page, NR_FILE_DIRTY);
+                       __inc_bdi_stat(mapping->backing_dev_info,
+                                       BDI_RECLAIMABLE);
+                       task_io_account_write(PAGE_CACHE_SIZE);
+               }
+               radix_tree_tag_set(&mapping->page_tree,
+                               page_index(page), PAGECACHE_TAG_DIRTY);
+
+               /*
+                * Reference snap context in page->private.  Also set
+                * PagePrivate so that we get invalidatepage callback.
+                */
+               page->private = (unsigned long)snapc;
+               SetPagePrivate(page);
+       } else {
+               dout("ANON set_page_dirty %p (raced truncate?)\n", page);
+               undo = 1;
+       }
+
+       spin_unlock_irq(&mapping->tree_lock);
+
+       if (undo)
+               /* whoops, we failed to dirty the page */
+               ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
+
+       __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
+
+       BUG_ON(!PageDirty(page));
+       return 1;
+}
+
+/*
+ * If we are truncating the full page (i.e. offset == 0), adjust the
+ * dirty page counters appropriately.  Only called if there is private
+ * data on the page.
+ */
+static void ceph_invalidatepage(struct page *page, unsigned long offset)
+{
+       struct inode *inode;
+       struct ceph_inode_info *ci;
+       struct ceph_snap_context *snapc = (void *)page->private;
+
+       BUG_ON(!PageLocked(page));
+       BUG_ON(!page->private);
+       BUG_ON(!PagePrivate(page));
+       BUG_ON(!page->mapping);
+
+       inode = page->mapping->host;
+
+       /*
+        * We can get non-dirty pages here due to races between
+        * set_page_dirty and truncate_complete_page; just spit out a
+        * warning, in case we end up with accounting problems later.
+        */
+       if (!PageDirty(page))
+               pr_err("%p invalidatepage %p page not dirty\n", inode, page);
+
+       if (offset == 0)
+               ClearPageChecked(page);
+
+       ci = ceph_inode(inode);
+       if (offset == 0) {
+               dout("%p invalidatepage %p idx %lu full dirty page %lu\n",
+                    inode, page, page->index, offset);
+               ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
+               ceph_put_snap_context(snapc);
+               page->private = 0;
+               ClearPagePrivate(page);
+       } else {
+               dout("%p invalidatepage %p idx %lu partial dirty page\n",
+                    inode, page, page->index);
+       }
+}
+
+/* just a sanity check */
+static int ceph_releasepage(struct page *page, gfp_t g)
+{
+       struct inode *inode = page->mapping ? page->mapping->host : NULL;
+       dout("%p releasepage %p idx %lu\n", inode, page, page->index);
+       WARN_ON(PageDirty(page));
+       WARN_ON(page->private);
+       WARN_ON(PagePrivate(page));
+       return 0;
+}
+
+/*
+ * read a single page, without unlocking it.
+ */
+static int readpage_nounlock(struct file *filp, struct page *page)
+{
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
+       int err = 0;
+       u64 len = PAGE_CACHE_SIZE;
+
+       dout("readpage inode %p file %p page %p index %lu\n",
+            inode, filp, page, page->index);
+       err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
+                                 page->index << PAGE_CACHE_SHIFT, &len,
+                                 ci->i_truncate_seq, ci->i_truncate_size,
+                                 &page, 1);
+       if (err == -ENOENT)
+               err = 0;
+       if (err < 0) {
+               SetPageError(page);
+               goto out;
+       } else if (err < PAGE_CACHE_SIZE) {
+               /* zero fill remainder of page */
+               zero_user_segment(page, err, PAGE_CACHE_SIZE);
+       }
+       SetPageUptodate(page);
+
+out:
+       return err < 0 ? err : 0;
+}
+
+static int ceph_readpage(struct file *filp, struct page *page)
+{
+       int r = readpage_nounlock(filp, page);
+       unlock_page(page);
+       return r;
+}
+
+/*
+ * Build a vector of contiguous pages from the provided page list.
+ */
+static struct page **page_vector_from_list(struct list_head *page_list,
+                                          unsigned *nr_pages)
+{
+       struct page **pages;
+       struct page *page;
+       int next_index, contig_pages = 0;
+
+       /* build page vector */
+       pages = kmalloc(sizeof(*pages) * *nr_pages, GFP_NOFS);
+       if (!pages)
+               return ERR_PTR(-ENOMEM);
+
+       BUG_ON(list_empty(page_list));
+       next_index = list_entry(page_list->prev, struct page, lru)->index;
+       list_for_each_entry_reverse(page, page_list, lru) {
+               if (page->index == next_index) {
+                       dout("readpages page %d %p\n", contig_pages, page);
+                       pages[contig_pages] = page;
+                       contig_pages++;
+                       next_index++;
+               } else {
+                       break;
+               }
+       }
+       *nr_pages = contig_pages;
+       return pages;
+}
+
+/*
+ * Read multiple pages.  Leave pages we don't read + unlock in page_list;
+ * the caller (VM) cleans them up.
+ */
+static int ceph_readpages(struct file *file, struct address_space *mapping,
+                         struct list_head *page_list, unsigned nr_pages)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
+       int rc = 0;
+       struct page **pages;
+       struct pagevec pvec;
+       loff_t offset;
+       u64 len;
+
+       dout("readpages %p file %p nr_pages %d\n",
+            inode, file, nr_pages);
+
+       pages = page_vector_from_list(page_list, &nr_pages);
+       if (IS_ERR(pages))
+               return PTR_ERR(pages);
+
+       /* guess read extent */
+       offset = pages[0]->index << PAGE_CACHE_SHIFT;
+       len = nr_pages << PAGE_CACHE_SHIFT;
+       rc = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
+                                offset, &len,
+                                ci->i_truncate_seq, ci->i_truncate_size,
+                                pages, nr_pages);
+       if (rc == -ENOENT)
+               rc = 0;
+       if (rc < 0)
+               goto out;
+
+       /* set uptodate and add to lru in pagevec-sized chunks */
+       pagevec_init(&pvec, 0);
+       for (; !list_empty(page_list) && len > 0;
+            rc -= PAGE_CACHE_SIZE, len -= PAGE_CACHE_SIZE) {
+               struct page *page =
+                       list_entry(page_list->prev, struct page, lru);
+
+               list_del(&page->lru);
+
+               if (rc < (int)PAGE_CACHE_SIZE) {
+                       /* zero (remainder of) page */
+                       int s = rc < 0 ? 0 : rc;
+                       zero_user_segment(page, s, PAGE_CACHE_SIZE);
+               }
+
+               if (add_to_page_cache(page, mapping, page->index, GFP_NOFS)) {
+                       page_cache_release(page);
+                       dout("readpages %p add_to_page_cache failed %p\n",
+                            inode, page);
+                       continue;
+               }
+               dout("readpages %p adding %p idx %lu\n", inode, page,
+                    page->index);
+               flush_dcache_page(page);
+               SetPageUptodate(page);
+               unlock_page(page);
+               if (pagevec_add(&pvec, page) == 0)
+                       pagevec_lru_add_file(&pvec);   /* add to lru */
+       }
+       pagevec_lru_add_file(&pvec);
+       rc = 0;
+
+out:
+       kfree(pages);
+       return rc;
+}
+
+/*
+ * Get ref for the oldest snapc for an inode with dirty data... that is, the
+ * only snap context we are allowed to write back.
+ *
+ * Caller holds i_lock.
+ */
+static struct ceph_snap_context *__get_oldest_context(struct inode *inode,
+                                                     u64 *snap_size)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_snap_context *snapc = NULL;
+       struct ceph_cap_snap *capsnap = NULL;
+
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
+               dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap,
+                    capsnap->context, capsnap->dirty_pages);
+               if (capsnap->dirty_pages) {
+                       snapc = ceph_get_snap_context(capsnap->context);
+                       if (snap_size)
+                               *snap_size = capsnap->size;
+                       break;
+               }
+       }
+       if (!snapc && ci->i_snap_realm) {
+               snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
+               dout(" head snapc %p has %d dirty pages\n",
+                    snapc, ci->i_wrbuffer_ref_head);
+       }
+       return snapc;
+}
+
+static struct ceph_snap_context *get_oldest_context(struct inode *inode,
+                                                   u64 *snap_size)
+{
+       struct ceph_snap_context *snapc = NULL;
+
+       spin_lock(&inode->i_lock);
+       snapc = __get_oldest_context(inode, snap_size);
+       spin_unlock(&inode->i_lock);
+       return snapc;
+}
+
+/*
+ * Write a single page, but leave the page locked.
+ *
+ * If we get a write error, set the page error bit, but still adjust the
+ * dirty page accounting (i.e., page is no longer dirty).
+ */
+static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
+{
+       struct inode *inode;
+       struct ceph_inode_info *ci;
+       struct ceph_client *client;
+       struct ceph_osd_client *osdc;
+       loff_t page_off = page->index << PAGE_CACHE_SHIFT;
+       int len = PAGE_CACHE_SIZE;
+       loff_t i_size;
+       int err = 0;
+       struct ceph_snap_context *snapc;
+       u64 snap_size = 0;
+       long writeback_stat;
+
+       dout("writepage %p idx %lu\n", page, page->index);
+
+       if (!page->mapping || !page->mapping->host) {
+               dout("writepage %p - no mapping\n", page);
+               return -EFAULT;
+       }
+       inode = page->mapping->host;
+       ci = ceph_inode(inode);
+       client = ceph_inode_to_client(inode);
+       osdc = &client->osdc;
+
+       /* verify this is a writeable snap context */
+       snapc = (void *)page->private;
+       if (snapc == NULL) {
+               dout("writepage %p page %p not dirty?\n", inode, page);
+               goto out;
+       }
+       if (snapc != get_oldest_context(inode, &snap_size)) {
+               dout("writepage %p page %p snapc %p not writeable - noop\n",
+                    inode, page, (void *)page->private);
+               /* we should only noop if called by kswapd */
+               WARN_ON((current->flags & PF_MEMALLOC) == 0);
+               goto out;
+       }
+
+       /* is this a partial page at end of file? */
+       if (snap_size)
+               i_size = snap_size;
+       else
+               i_size = i_size_read(inode);
+       if (i_size < page_off + len)
+               len = i_size - page_off;
+
+       dout("writepage %p page %p index %lu on %llu~%u\n",
+            inode, page, page->index, page_off, len);
+
+       writeback_stat = atomic_long_inc_return(&client->writeback_count);
+       if (writeback_stat >
+           CONGESTION_ON_THRESH(client->mount_args->congestion_kb))
+               set_bdi_congested(&client->backing_dev_info, BLK_RW_ASYNC);
+
+       set_page_writeback(page);
+       err = ceph_osdc_writepages(osdc, ceph_vino(inode),
+                                  &ci->i_layout, snapc,
+                                  page_off, len,
+                                  ci->i_truncate_seq, ci->i_truncate_size,
+                                  &inode->i_mtime,
+                                  &page, 1, 0, 0, true);
+       if (err < 0) {
+               dout("writepage setting page/mapping error %d %p\n", err, page);
+               SetPageError(page);
+               mapping_set_error(&inode->i_data, err);
+               if (wbc)
+                       wbc->pages_skipped++;
+       } else {
+               dout("writepage cleaned page %p\n", page);
+               err = 0;  /* vfs expects us to return 0 */
+       }
+       page->private = 0;
+       ClearPagePrivate(page);
+       end_page_writeback(page);
+       ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
+       ceph_put_snap_context(snapc);
+out:
+       return err;
+}
+
+static int ceph_writepage(struct page *page, struct writeback_control *wbc)
+{
+       int err;
+       struct inode *inode = page->mapping->host;
+       BUG_ON(!inode);
+       igrab(inode);
+       err = writepage_nounlock(page, wbc);
+       unlock_page(page);
+       iput(inode);
+       return err;
+}
+
+
+/*
+ * lame release_pages helper.  release_pages() isn't exported to
+ * modules.
+ */
+static void ceph_release_pages(struct page **pages, int num)
+{
+       struct pagevec pvec;
+       int i;
+
+       pagevec_init(&pvec, 0);
+       for (i = 0; i < num; i++) {
+               if (pagevec_add(&pvec, pages[i]) == 0)
+                       pagevec_release(&pvec);
+       }
+       pagevec_release(&pvec);
+}
+
+
+/*
+ * async writeback completion handler.
+ *
+ * If we get an error, set the mapping error bit, but not the individual
+ * page error bits.
+ */
+static void writepages_finish(struct ceph_osd_request *req,
+                             struct ceph_msg *msg)
+{
+       struct inode *inode = req->r_inode;
+       struct ceph_osd_reply_head *replyhead;
+       struct ceph_osd_op *op;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       unsigned wrote;
+       struct page *page;
+       int i;
+       struct ceph_snap_context *snapc = req->r_snapc;
+       struct address_space *mapping = inode->i_mapping;
+       struct writeback_control *wbc = req->r_wbc;
+       __s32 rc = -EIO;
+       u64 bytes = 0;
+       struct ceph_client *client = ceph_inode_to_client(inode);
+       long writeback_stat;
+       unsigned issued = __ceph_caps_issued(ci, NULL);
+
+       /* parse reply */
+       replyhead = msg->front.iov_base;
+       WARN_ON(le32_to_cpu(replyhead->num_ops) == 0);
+       op = (void *)(replyhead + 1);
+       rc = le32_to_cpu(replyhead->result);
+       bytes = le64_to_cpu(op->extent.length);
+
+       if (rc >= 0) {
+               /*
+                * Assume we wrote the pages we originally sent.  The
+                * osd might reply with fewer pages if our writeback
+                * raced with a truncation and was adjusted at the osd,
+                * so don't believe the reply.
+                */
+               wrote = req->r_num_pages;
+       } else {
+               wrote = 0;
+               mapping_set_error(mapping, rc);
+       }
+       dout("writepages_finish %p rc %d bytes %llu wrote %d (pages)\n",
+            inode, rc, bytes, wrote);
+
+       /* clean all pages */
+       for (i = 0; i < req->r_num_pages; i++) {
+               page = req->r_pages[i];
+               BUG_ON(!page);
+               WARN_ON(!PageUptodate(page));
+
+               writeback_stat =
+                       atomic_long_dec_return(&client->writeback_count);
+               if (writeback_stat <
+                   CONGESTION_OFF_THRESH(client->mount_args->congestion_kb))
+                       clear_bdi_congested(&client->backing_dev_info,
+                                           BLK_RW_ASYNC);
+
+               if (i >= wrote) {
+                       dout("inode %p skipping page %p\n", inode, page);
+                       wbc->pages_skipped++;
+               }
+               page->private = 0;
+               ClearPagePrivate(page);
+               ceph_put_snap_context(snapc);
+               dout("unlocking %d %p\n", i, page);
+               end_page_writeback(page);
+
+               /*
+                * We lost the cache cap, need to truncate the page before
+                * it is unlocked, otherwise we'd truncate it later in the
+                * page truncation thread, possibly losing some data that
+                * raced its way in
+                */
+               if ((issued & CEPH_CAP_FILE_CACHE) == 0)
+                       generic_error_remove_page(inode->i_mapping, page);
+
+               unlock_page(page);
+       }
+       dout("%p wrote+cleaned %d pages\n", inode, wrote);
+       ceph_put_wrbuffer_cap_refs(ci, req->r_num_pages, snapc);
+
+       ceph_release_pages(req->r_pages, req->r_num_pages);
+       if (req->r_pages_from_pool)
+               mempool_free(req->r_pages,
+                            ceph_client(inode->i_sb)->wb_pagevec_pool);
+       else
+               kfree(req->r_pages);
+       ceph_osdc_put_request(req);
+}
+
+/*
+ * allocate a page vec, either directly, or if necessary, via a the
+ * mempool.  we avoid the mempool if we can because req->r_num_pages
+ * may be less than the maximum write size.
+ */
+static void alloc_page_vec(struct ceph_client *client,
+                          struct ceph_osd_request *req)
+{
+       req->r_pages = kmalloc(sizeof(struct page *) * req->r_num_pages,
+                              GFP_NOFS);
+       if (!req->r_pages) {
+               req->r_pages = mempool_alloc(client->wb_pagevec_pool, GFP_NOFS);
+               req->r_pages_from_pool = 1;
+               WARN_ON(!req->r_pages);
+       }
+}
+
+/*
+ * initiate async writeback
+ */
+static int ceph_writepages_start(struct address_space *mapping,
+                                struct writeback_control *wbc)
+{
+       struct inode *inode = mapping->host;
+       struct backing_dev_info *bdi = mapping->backing_dev_info;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_client *client;
+       pgoff_t index, start, end;
+       int range_whole = 0;
+       int should_loop = 1;
+       pgoff_t max_pages = 0, max_pages_ever = 0;
+       struct ceph_snap_context *snapc = NULL, *last_snapc = NULL;
+       struct pagevec pvec;
+       int done = 0;
+       int rc = 0;
+       unsigned wsize = 1 << inode->i_blkbits;
+       struct ceph_osd_request *req = NULL;
+       int do_sync;
+       u64 snap_size = 0;
+
+       /*
+        * Include a 'sync' in the OSD request if this is a data
+        * integrity write (e.g., O_SYNC write or fsync()), or if our
+        * cap is being revoked.
+        */
+       do_sync = wbc->sync_mode == WB_SYNC_ALL;
+       if (ceph_caps_revoking(ci, CEPH_CAP_FILE_BUFFER))
+               do_sync = 1;
+       dout("writepages_start %p dosync=%d (mode=%s)\n",
+            inode, do_sync,
+            wbc->sync_mode == WB_SYNC_NONE ? "NONE" :
+            (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD"));
+
+       client = ceph_inode_to_client(inode);
+       if (client->mount_state == CEPH_MOUNT_SHUTDOWN) {
+               pr_warning("writepage_start %p on forced umount\n", inode);
+               return -EIO; /* we're in a forced umount, don't write! */
+       }
+       if (client->mount_args->wsize && client->mount_args->wsize < wsize)
+               wsize = client->mount_args->wsize;
+       if (wsize < PAGE_CACHE_SIZE)
+               wsize = PAGE_CACHE_SIZE;
+       max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
+
+       pagevec_init(&pvec, 0);
+
+       /* ?? */
+       if (wbc->nonblocking && bdi_write_congested(bdi)) {
+               dout(" writepages congested\n");
+               wbc->encountered_congestion = 1;
+               goto out_final;
+       }
+
+       /* where to start/end? */
+       if (wbc->range_cyclic) {
+               start = mapping->writeback_index; /* Start from prev offset */
+               end = -1;
+               dout(" cyclic, start at %lu\n", start);
+       } else {
+               start = wbc->range_start >> PAGE_CACHE_SHIFT;
+               end = wbc->range_end >> PAGE_CACHE_SHIFT;
+               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
+                       range_whole = 1;
+               should_loop = 0;
+               dout(" not cyclic, %lu to %lu\n", start, end);
+       }
+       index = start;
+
+retry:
+       /* find oldest snap context with dirty data */
+       ceph_put_snap_context(snapc);
+       snapc = get_oldest_context(inode, &snap_size);
+       if (!snapc) {
+               /* hmm, why does writepages get called when there
+                  is no dirty data? */
+               dout(" no snap context with dirty data?\n");
+               goto out;
+       }
+       dout(" oldest snapc is %p seq %lld (%d snaps)\n",
+            snapc, snapc->seq, snapc->num_snaps);
+       if (last_snapc && snapc != last_snapc) {
+               /* if we switched to a newer snapc, restart our scan at the
+                * start of the original file range. */
+               dout("  snapc differs from last pass, restarting at %lu\n",
+                    index);
+               index = start;
+       }
+       last_snapc = snapc;
+
+       while (!done && index <= end) {
+               unsigned i;
+               int first;
+               pgoff_t next;
+               int pvec_pages, locked_pages;
+               struct page *page;
+               int want;
+               u64 offset, len;
+               struct ceph_osd_request_head *reqhead;
+               struct ceph_osd_op *op;
+               long writeback_stat;
+
+               next = 0;
+               locked_pages = 0;
+               max_pages = max_pages_ever;
+
+get_more_pages:
+               first = -1;
+               want = min(end - index,
+                          min((pgoff_t)PAGEVEC_SIZE,
+                              max_pages - (pgoff_t)locked_pages) - 1)
+                       + 1;
+               pvec_pages = pagevec_lookup_tag(&pvec, mapping, &index,
+                                               PAGECACHE_TAG_DIRTY,
+                                               want);
+               dout("pagevec_lookup_tag got %d\n", pvec_pages);
+               if (!pvec_pages && !locked_pages)
+                       break;
+               for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) {
+                       page = pvec.pages[i];
+                       dout("? %p idx %lu\n", page, page->index);
+                       if (locked_pages == 0)
+                               lock_page(page);  /* first page */
+                       else if (!trylock_page(page))
+                               break;
+
+                       /* only dirty pages, or our accounting breaks */
+                       if (unlikely(!PageDirty(page)) ||
+                           unlikely(page->mapping != mapping)) {
+                               dout("!dirty or !mapping %p\n", page);
+                               unlock_page(page);
+                               break;
+                       }
+                       if (!wbc->range_cyclic && page->index > end) {
+                               dout("end of range %p\n", page);
+                               done = 1;
+                               unlock_page(page);
+                               break;
+                       }
+                       if (next && (page->index != next)) {
+                               dout("not consecutive %p\n", page);
+                               unlock_page(page);
+                               break;
+                       }
+                       if (wbc->sync_mode != WB_SYNC_NONE) {
+                               dout("waiting on writeback %p\n", page);
+                               wait_on_page_writeback(page);
+                       }
+                       if ((snap_size && page_offset(page) > snap_size) ||
+                           (!snap_size &&
+                            page_offset(page) > i_size_read(inode))) {
+                               dout("%p page eof %llu\n", page, snap_size ?
+                                    snap_size : i_size_read(inode));
+                               done = 1;
+                               unlock_page(page);
+                               break;
+                       }
+                       if (PageWriteback(page)) {
+                               dout("%p under writeback\n", page);
+                               unlock_page(page);
+                               break;
+                       }
+
+                       /* only if matching snap context */
+                       if (snapc != (void *)page->private) {
+                               dout("page snapc %p != oldest %p\n",
+                                    (void *)page->private, snapc);
+                               unlock_page(page);
+                               if (!locked_pages)
+                                       continue; /* keep looking for snap */
+                               break;
+                       }
+
+                       if (!clear_page_dirty_for_io(page)) {
+                               dout("%p !clear_page_dirty_for_io\n", page);
+                               unlock_page(page);
+                               break;
+                       }
+
+                       /* ok */
+                       if (locked_pages == 0) {
+                               /* prepare async write request */
+                               offset = page->index << PAGE_CACHE_SHIFT;
+                               len = wsize;
+                               req = ceph_osdc_new_request(&client->osdc,
+                                           &ci->i_layout,
+                                           ceph_vino(inode),
+                                           offset, &len,
+                                           CEPH_OSD_OP_WRITE,
+                                           CEPH_OSD_FLAG_WRITE |
+                                                   CEPH_OSD_FLAG_ONDISK,
+                                           snapc, do_sync,
+                                           ci->i_truncate_seq,
+                                           ci->i_truncate_size,
+                                           &inode->i_mtime, true, 1);
+                               max_pages = req->r_num_pages;
+
+                               alloc_page_vec(client, req);
+                               req->r_callback = writepages_finish;
+                               req->r_inode = inode;
+                               req->r_wbc = wbc;
+                       }
+
+                       /* note position of first page in pvec */
+                       if (first < 0)
+                               first = i;
+                       dout("%p will write page %p idx %lu\n",
+                            inode, page, page->index);
+
+                       writeback_stat = atomic_long_inc_return(&client->writeback_count);
+                       if (writeback_stat > CONGESTION_ON_THRESH(client->mount_args->congestion_kb)) {
+                               set_bdi_congested(&client->backing_dev_info, BLK_RW_ASYNC);
+                       }
+
+                       set_page_writeback(page);
+                       req->r_pages[locked_pages] = page;
+                       locked_pages++;
+                       next = page->index + 1;
+               }
+
+               /* did we get anything? */
+               if (!locked_pages)
+                       goto release_pvec_pages;
+               if (i) {
+                       int j;
+                       BUG_ON(!locked_pages || first < 0);
+
+                       if (pvec_pages && i == pvec_pages &&
+                           locked_pages < max_pages) {
+                               dout("reached end pvec, trying for more\n");
+                               pagevec_reinit(&pvec);
+                               goto get_more_pages;
+                       }
+
+                       /* shift unused pages over in the pvec...  we
+                        * will need to release them below. */
+                       for (j = i; j < pvec_pages; j++) {
+                               dout(" pvec leftover page %p\n",
+                                    pvec.pages[j]);
+                               pvec.pages[j-i+first] = pvec.pages[j];
+                       }
+                       pvec.nr -= i-first;
+               }
+
+               /* submit the write */
+               offset = req->r_pages[0]->index << PAGE_CACHE_SHIFT;
+               len = min((snap_size ? snap_size : i_size_read(inode)) - offset,
+                         (u64)locked_pages << PAGE_CACHE_SHIFT);
+               dout("writepages got %d pages at %llu~%llu\n",
+                    locked_pages, offset, len);
+
+               /* revise final length, page count */
+               req->r_num_pages = locked_pages;
+               reqhead = req->r_request->front.iov_base;
+               op = (void *)(reqhead + 1);
+               op->extent.length = cpu_to_le64(len);
+               op->payload_len = cpu_to_le32(len);
+               req->r_request->hdr.data_len = cpu_to_le32(len);
+
+               ceph_osdc_start_request(&client->osdc, req, true);
+               req = NULL;
+
+               /* continue? */
+               index = next;
+               wbc->nr_to_write -= locked_pages;
+               if (wbc->nr_to_write <= 0)
+                       done = 1;
+
+release_pvec_pages:
+               dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr,
+                    pvec.nr ? pvec.pages[0] : NULL);
+               pagevec_release(&pvec);
+
+               if (locked_pages && !done)
+                       goto retry;
+       }
+
+       if (should_loop && !done) {
+               /* more to do; loop back to beginning of file */
+               dout("writepages looping back to beginning of file\n");
+               should_loop = 0;
+               index = 0;
+               goto retry;
+       }
+
+       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
+               mapping->writeback_index = index;
+
+out:
+       if (req)
+               ceph_osdc_put_request(req);
+       if (rc > 0)
+               rc = 0;  /* vfs expects us to return 0 */
+       ceph_put_snap_context(snapc);
+       dout("writepages done, rc = %d\n", rc);
+out_final:
+       return rc;
+}
+
+
+
+/*
+ * See if a given @snapc is either writeable, or already written.
+ */
+static int context_is_writeable_or_written(struct inode *inode,
+                                          struct ceph_snap_context *snapc)
+{
+       struct ceph_snap_context *oldest = get_oldest_context(inode, NULL);
+       return !oldest || snapc->seq <= oldest->seq;
+}
+
+/*
+ * We are only allowed to write into/dirty the page if the page is
+ * clean, or already dirty within the same snap context.
+ *
+ * called with page locked.
+ * return success with page locked,
+ * or any failure (incl -EAGAIN) with page unlocked.
+ */
+static int ceph_update_writeable_page(struct file *file,
+                           loff_t pos, unsigned len,
+                           struct page *page)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
+       loff_t page_off = pos & PAGE_CACHE_MASK;
+       int pos_in_page = pos & ~PAGE_CACHE_MASK;
+       int end_in_page = pos_in_page + len;
+       loff_t i_size;
+       struct ceph_snap_context *snapc;
+       int r;
+
+retry_locked:
+       /* writepages currently holds page lock, but if we change that later, */
+       wait_on_page_writeback(page);
+
+       /* check snap context */
+       BUG_ON(!ci->i_snap_realm);
+       down_read(&mdsc->snap_rwsem);
+       BUG_ON(!ci->i_snap_realm->cached_context);
+       if (page->private &&
+           (void *)page->private != ci->i_snap_realm->cached_context) {
+               /*
+                * this page is already dirty in another (older) snap
+                * context!  is it writeable now?
+                */
+               snapc = get_oldest_context(inode, NULL);
+               up_read(&mdsc->snap_rwsem);
+
+               if (snapc != (void *)page->private) {
+                       dout(" page %p snapc %p not current or oldest\n",
+                            page, (void *)page->private);
+                       /*
+                        * queue for writeback, and wait for snapc to
+                        * be writeable or written
+                        */
+                       snapc = ceph_get_snap_context((void *)page->private);
+                       unlock_page(page);
+                       ceph_queue_writeback(inode);
+                       r = wait_event_interruptible(ci->i_cap_wq,
+                              context_is_writeable_or_written(inode, snapc));
+                       ceph_put_snap_context(snapc);
+                       if (r == -ERESTARTSYS)
+                               return r;
+                       return -EAGAIN;
+               }
+
+               /* yay, writeable, do it now (without dropping page lock) */
+               dout(" page %p snapc %p not current, but oldest\n",
+                    page, snapc);
+               if (!clear_page_dirty_for_io(page))
+                       goto retry_locked;
+               r = writepage_nounlock(page, NULL);
+               if (r < 0)
+                       goto fail_nosnap;
+               goto retry_locked;
+       }
+
+       if (PageUptodate(page)) {
+               dout(" page %p already uptodate\n", page);
+               return 0;
+       }
+
+       /* full page? */
+       if (pos_in_page == 0 && len == PAGE_CACHE_SIZE)
+               return 0;
+
+       /* past end of file? */
+       i_size = inode->i_size;   /* caller holds i_mutex */
+
+       if (i_size + len > inode->i_sb->s_maxbytes) {
+               /* file is too big */
+               r = -EINVAL;
+               goto fail;
+       }
+
+       if (page_off >= i_size ||
+           (pos_in_page == 0 && (pos+len) >= i_size &&
+            end_in_page - pos_in_page != PAGE_CACHE_SIZE)) {
+               dout(" zeroing %p 0 - %d and %d - %d\n",
+                    page, pos_in_page, end_in_page, (int)PAGE_CACHE_SIZE);
+               zero_user_segments(page,
+                                  0, pos_in_page,
+                                  end_in_page, PAGE_CACHE_SIZE);
+               return 0;
+       }
+
+       /* we need to read it. */
+       up_read(&mdsc->snap_rwsem);
+       r = readpage_nounlock(file, page);
+       if (r < 0)
+               goto fail_nosnap;
+       goto retry_locked;
+
+fail:
+       up_read(&mdsc->snap_rwsem);
+fail_nosnap:
+       unlock_page(page);
+       return r;
+}
+
+/*
+ * We are only allowed to write into/dirty the page if the page is
+ * clean, or already dirty within the same snap context.
+ */
+static int ceph_write_begin(struct file *file, struct address_space *mapping,
+                           loff_t pos, unsigned len, unsigned flags,
+                           struct page **pagep, void **fsdata)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct page *page;
+       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+       int r;
+
+       do {
+               /* get a page */
+               page = grab_cache_page_write_begin(mapping, index, 0);
+               if (!page)
+                       return -ENOMEM;
+               *pagep = page;
+
+               dout("write_begin file %p inode %p page %p %d~%d\n", file,
+               inode, page, (int)pos, (int)len);
+
+               r = ceph_update_writeable_page(file, pos, len, page);
+       } while (r == -EAGAIN);
+
+       return r;
+}
+
+/*
+ * we don't do anything in here that simple_write_end doesn't do
+ * except adjust dirty page accounting and drop read lock on
+ * mdsc->snap_rwsem.
+ */
+static int ceph_write_end(struct file *file, struct address_space *mapping,
+                         loff_t pos, unsigned len, unsigned copied,
+                         struct page *page, void *fsdata)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_client *client = ceph_inode_to_client(inode);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+       int check_cap = 0;
+
+       dout("write_end file %p inode %p page %p %d~%d (%d)\n", file,
+            inode, page, (int)pos, (int)copied, (int)len);
+
+       /* zero the stale part of the page if we did a short copy */
+       if (copied < len)
+               zero_user_segment(page, from+copied, len);
+
+       /* did file size increase? */
+       /* (no need for i_size_read(); we caller holds i_mutex */
+       if (pos+copied > inode->i_size)
+               check_cap = ceph_inode_set_size(inode, pos+copied);
+
+       if (!PageUptodate(page))
+               SetPageUptodate(page);
+
+       set_page_dirty(page);
+
+       unlock_page(page);
+       up_read(&mdsc->snap_rwsem);
+       page_cache_release(page);
+
+       if (check_cap)
+               ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY, NULL);
+
+       return copied;
+}
+
+/*
+ * we set .direct_IO to indicate direct io is supported, but since we
+ * intercept O_DIRECT reads and writes early, this function should
+ * never get called.
+ */
+static ssize_t ceph_direct_io(int rw, struct kiocb *iocb,
+                             const struct iovec *iov,
+                             loff_t pos, unsigned long nr_segs)
+{
+       WARN_ON(1);
+       return -EINVAL;
+}
+
+const struct address_space_operations ceph_aops = {
+       .readpage = ceph_readpage,
+       .readpages = ceph_readpages,
+       .writepage = ceph_writepage,
+       .writepages = ceph_writepages_start,
+       .write_begin = ceph_write_begin,
+       .write_end = ceph_write_end,
+       .set_page_dirty = ceph_set_page_dirty,
+       .invalidatepage = ceph_invalidatepage,
+       .releasepage = ceph_releasepage,
+       .direct_IO = ceph_direct_io,
+};
+
+
+/*
+ * vm ops
+ */
+
+/*
+ * Reuse write_begin here for simplicity.
+ */
+static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+       struct inode *inode = vma->vm_file->f_dentry->d_inode;
+       struct page *page = vmf->page;
+       struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
+       loff_t off = page->index << PAGE_CACHE_SHIFT;
+       loff_t size, len;
+       int ret;
+
+       size = i_size_read(inode);
+       if (off + PAGE_CACHE_SIZE <= size)
+               len = PAGE_CACHE_SIZE;
+       else
+               len = size & ~PAGE_CACHE_MASK;
+
+       dout("page_mkwrite %p %llu~%llu page %p idx %lu\n", inode,
+            off, len, page, page->index);
+
+       lock_page(page);
+
+       ret = VM_FAULT_NOPAGE;
+       if ((off > size) ||
+           (page->mapping != inode->i_mapping))
+               goto out;
+
+       ret = ceph_update_writeable_page(vma->vm_file, off, len, page);
+       if (ret == 0) {
+               /* success.  we'll keep the page locked. */
+               set_page_dirty(page);
+               up_read(&mdsc->snap_rwsem);
+               ret = VM_FAULT_LOCKED;
+       } else {
+               if (ret == -ENOMEM)
+                       ret = VM_FAULT_OOM;
+               else
+                       ret = VM_FAULT_SIGBUS;
+       }
+out:
+       dout("page_mkwrite %p %llu~%llu = %d\n", inode, off, len, ret);
+       if (ret != VM_FAULT_LOCKED)
+               unlock_page(page);
+       return ret;
+}
+
+static struct vm_operations_struct ceph_vmops = {
+       .fault          = filemap_fault,
+       .page_mkwrite   = ceph_page_mkwrite,
+};
+
+int ceph_mmap(struct file *file, struct vm_area_struct *vma)
+{
+       struct address_space *mapping = file->f_mapping;
+
+       if (!mapping->a_ops->readpage)
+               return -ENOEXEC;
+       file_accessed(file);
+       vma->vm_ops = &ceph_vmops;
+       vma->vm_flags |= VM_CAN_NONLINEAR;
+       return 0;
+}
diff --git a/fs/ceph/armor.c b/fs/ceph/armor.c
new file mode 100644 (file)
index 0000000..67b2c03
--- /dev/null
@@ -0,0 +1,99 @@
+
+#include <linux/errno.h>
+
+/*
+ * base64 encode/decode.
+ */
+
+const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static int encode_bits(int c)
+{
+       return pem_key[c];
+}
+
+static int decode_bits(char c)
+{
+       if (c >= 'A' && c <= 'Z')
+               return c - 'A';
+       if (c >= 'a' && c <= 'z')
+               return c - 'a' + 26;
+       if (c >= '0' && c <= '9')
+               return c - '0' + 52;
+       if (c == '+')
+               return 62;
+       if (c == '/')
+               return 63;
+       if (c == '=')
+               return 0; /* just non-negative, please */
+       return -EINVAL;
+}
+
+int ceph_armor(char *dst, const char *src, const char *end)
+{
+       int olen = 0;
+       int line = 0;
+
+       while (src < end) {
+               unsigned char a, b, c;
+
+               a = *src++;
+               *dst++ = encode_bits(a >> 2);
+               if (src < end) {
+                       b = *src++;
+                       *dst++ = encode_bits(((a & 3) << 4) | (b >> 4));
+                       if (src < end) {
+                               c = *src++;
+                               *dst++ = encode_bits(((b & 15) << 2) |
+                                                    (c >> 6));
+                               *dst++ = encode_bits(c & 63);
+                       } else {
+                               *dst++ = encode_bits((b & 15) << 2);
+                               *dst++ = '=';
+                       }
+               } else {
+                       *dst++ = encode_bits(((a & 3) << 4));
+                       *dst++ = '=';
+                       *dst++ = '=';
+               }
+               olen += 4;
+               line += 4;
+               if (line == 64) {
+                       line = 0;
+                       *(dst++) = '\n';
+                       olen++;
+               }
+       }
+       return olen;
+}
+
+int ceph_unarmor(char *dst, const char *src, const char *end)
+{
+       int olen = 0;
+
+       while (src < end) {
+               int a, b, c, d;
+
+               if (src < end && src[0] == '\n')
+                       src++;
+               if (src + 4 > end)
+                       return -EINVAL;
+               a = decode_bits(src[0]);
+               b = decode_bits(src[1]);
+               c = decode_bits(src[2]);
+               d = decode_bits(src[3]);
+               if (a < 0 || b < 0 || c < 0 || d < 0)
+                       return -EINVAL;
+
+               *dst++ = (a << 2) | (b >> 4);
+               if (src[2] == '=')
+                       return olen + 1;
+               *dst++ = ((b & 15) << 4) | (c >> 2);
+               if (src[3] == '=')
+                       return olen + 2;
+               *dst++ = ((c & 3) << 6) | d;
+               olen += 3;
+               src += 4;
+       }
+       return olen;
+}
diff --git a/fs/ceph/auth.c b/fs/ceph/auth.c
new file mode 100644 (file)
index 0000000..f6394b9
--- /dev/null
@@ -0,0 +1,258 @@
+#include "ceph_debug.h"
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+
+#include "types.h"
+#include "auth_none.h"
+#include "auth_x.h"
+#include "decode.h"
+#include "super.h"
+
+#include "messenger.h"
+
+/*
+ * get protocol handler
+ */
+static u32 supported_protocols[] = {
+       CEPH_AUTH_NONE,
+       CEPH_AUTH_CEPHX
+};
+
+int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
+{
+       switch (protocol) {
+       case CEPH_AUTH_NONE:
+               return ceph_auth_none_init(ac);
+       case CEPH_AUTH_CEPHX:
+               return ceph_x_init(ac);
+       default:
+               return -ENOENT;
+       }
+}
+
+/*
+ * setup, teardown.
+ */
+struct ceph_auth_client *ceph_auth_init(const char *name, const char *secret)
+{
+       struct ceph_auth_client *ac;
+       int ret;
+
+       dout("auth_init name '%s' secret '%s'\n", name, secret);
+
+       ret = -ENOMEM;
+       ac = kzalloc(sizeof(*ac), GFP_NOFS);
+       if (!ac)
+               goto out;
+
+       ac->negotiating = true;
+       if (name)
+               ac->name = name;
+       else
+               ac->name = CEPH_AUTH_NAME_DEFAULT;
+       dout("auth_init name %s secret %s\n", ac->name, secret);
+       ac->secret = secret;
+       return ac;
+
+out:
+       return ERR_PTR(ret);
+}
+
+void ceph_auth_destroy(struct ceph_auth_client *ac)
+{
+       dout("auth_destroy %p\n", ac);
+       if (ac->ops)
+               ac->ops->destroy(ac);
+       kfree(ac);
+}
+
+/*
+ * Reset occurs when reconnecting to the monitor.
+ */
+void ceph_auth_reset(struct ceph_auth_client *ac)
+{
+       dout("auth_reset %p\n", ac);
+       if (ac->ops && !ac->negotiating)
+               ac->ops->reset(ac);
+       ac->negotiating = true;
+}
+
+int ceph_entity_name_encode(const char *name, void **p, void *end)
+{
+       int len = strlen(name);
+
+       if (*p + 2*sizeof(u32) + len > end)
+               return -ERANGE;
+       ceph_encode_32(p, CEPH_ENTITY_TYPE_CLIENT);
+       ceph_encode_32(p, len);
+       ceph_encode_copy(p, name, len);
+       return 0;
+}
+
+/*
+ * Initiate protocol negotiation with monitor.  Include entity name
+ * and list supported protocols.
+ */
+int ceph_auth_build_hello(struct ceph_auth_client *ac, void *buf, size_t len)
+{
+       struct ceph_mon_request_header *monhdr = buf;
+       void *p = monhdr + 1, *end = buf + len, *lenp;
+       int i, num;
+       int ret;
+
+       dout("auth_build_hello\n");
+       monhdr->have_version = 0;
+       monhdr->session_mon = cpu_to_le16(-1);
+       monhdr->session_mon_tid = 0;
+
+       ceph_encode_32(&p, 0);  /* no protocol, yet */
+
+       lenp = p;
+       p += sizeof(u32);
+
+       ceph_decode_need(&p, end, 1 + sizeof(u32), bad);
+       ceph_encode_8(&p, 1);
+       num = ARRAY_SIZE(supported_protocols);
+       ceph_encode_32(&p, num);
+       ceph_decode_need(&p, end, num * sizeof(u32), bad);
+       for (i = 0; i < num; i++)
+               ceph_encode_32(&p, supported_protocols[i]);
+
+       ret = ceph_entity_name_encode(ac->name, &p, end);
+       if (ret < 0)
+               return ret;
+       ceph_decode_need(&p, end, sizeof(u64), bad);
+       ceph_encode_64(&p, ac->global_id);
+
+       ceph_encode_32(&lenp, p - lenp - sizeof(u32));
+       return p - buf;
+
+bad:
+       return -ERANGE;
+}
+
+int ceph_build_auth_request(struct ceph_auth_client *ac,
+                          void *msg_buf, size_t msg_len)
+{
+       struct ceph_mon_request_header *monhdr = msg_buf;
+       void *p = monhdr + 1;
+       void *end = msg_buf + msg_len;
+       int ret;
+
+       monhdr->have_version = 0;
+       monhdr->session_mon = cpu_to_le16(-1);
+       monhdr->session_mon_tid = 0;
+
+       ceph_encode_32(&p, ac->protocol);
+
+       ret = ac->ops->build_request(ac, p + sizeof(u32), end);
+       if (ret < 0) {
+               pr_err("error %d building request\n", ret);
+               return ret;
+       }
+       dout(" built request %d bytes\n", ret);
+       ceph_encode_32(&p, ret);
+       return p + ret - msg_buf;
+}
+
+/*
+ * Handle auth message from monitor.
+ */
+int ceph_handle_auth_reply(struct ceph_auth_client *ac,
+                          void *buf, size_t len,
+                          void *reply_buf, size_t reply_len)
+{
+       void *p = buf;
+       void *end = buf + len;
+       int protocol;
+       s32 result;
+       u64 global_id;
+       void *payload, *payload_end;
+       int payload_len;
+       char *result_msg;
+       int result_msg_len;
+       int ret = -EINVAL;
+
+       dout("handle_auth_reply %p %p\n", p, end);
+       ceph_decode_need(&p, end, sizeof(u32) * 3 + sizeof(u64), bad);
+       protocol = ceph_decode_32(&p);
+       result = ceph_decode_32(&p);
+       global_id = ceph_decode_64(&p);
+       payload_len = ceph_decode_32(&p);
+       payload = p;
+       p += payload_len;
+       ceph_decode_need(&p, end, sizeof(u32), bad);
+       result_msg_len = ceph_decode_32(&p);
+       result_msg = p;
+       p += result_msg_len;
+       if (p != end)
+               goto bad;
+
+       dout(" result %d '%.*s' gid %llu len %d\n", result, result_msg_len,
+            result_msg, global_id, payload_len);
+
+       payload_end = payload + payload_len;
+
+       if (global_id && ac->global_id != global_id) {
+               dout(" set global_id %lld -> %lld\n", ac->global_id, global_id);
+               ac->global_id = global_id;
+       }
+
+       if (ac->negotiating) {
+               /* server does not support our protocols? */
+               if (!protocol && result < 0) {
+                       ret = result;
+                       goto out;
+               }
+               /* set up (new) protocol handler? */
+               if (ac->protocol && ac->protocol != protocol) {
+                       ac->ops->destroy(ac);
+                       ac->protocol = 0;
+                       ac->ops = NULL;
+               }
+               if (ac->protocol != protocol) {
+                       ret = ceph_auth_init_protocol(ac, protocol);
+                       if (ret) {
+                               pr_err("error %d on auth protocol %d init\n",
+                                      ret, protocol);
+                               goto out;
+                       }
+               }
+
+               ac->negotiating = false;
+       }
+
+       ret = ac->ops->handle_reply(ac, result, payload, payload_end);
+       if (ret == -EAGAIN) {
+               return ceph_build_auth_request(ac, reply_buf, reply_len);
+       } else if (ret) {
+               pr_err("authentication error %d\n", ret);
+               return ret;
+       }
+       return 0;
+
+bad:
+       pr_err("failed to decode auth msg\n");
+out:
+       return ret;
+}
+
+int ceph_build_auth(struct ceph_auth_client *ac,
+                   void *msg_buf, size_t msg_len)
+{
+       if (!ac->protocol)
+               return ceph_auth_build_hello(ac, msg_buf, msg_len);
+       BUG_ON(!ac->ops);
+       if (!ac->ops->is_authenticated(ac))
+               return ceph_build_auth_request(ac, msg_buf, msg_len);
+       return 0;
+}
+
+int ceph_auth_is_authenticated(struct ceph_auth_client *ac)
+{
+       if (!ac->ops)
+               return 0;
+       return ac->ops->is_authenticated(ac);
+}
diff --git a/fs/ceph/auth.h b/fs/ceph/auth.h
new file mode 100644 (file)
index 0000000..ca4f57c
--- /dev/null
@@ -0,0 +1,84 @@
+#ifndef _FS_CEPH_AUTH_H
+#define _FS_CEPH_AUTH_H
+
+#include "types.h"
+#include "buffer.h"
+
+/*
+ * Abstract interface for communicating with the authenticate module.
+ * There is some handshake that takes place between us and the monitor
+ * to acquire the necessary keys.  These are used to generate an
+ * 'authorizer' that we use when connecting to a service (mds, osd).
+ */
+
+struct ceph_auth_client;
+struct ceph_authorizer;
+
+struct ceph_auth_client_ops {
+       /*
+        * true if we are authenticated and can connect to
+        * services.
+        */
+       int (*is_authenticated)(struct ceph_auth_client *ac);
+
+       /*
+        * build requests and process replies during monitor
+        * handshake.  if handle_reply returns -EAGAIN, we build
+        * another request.
+        */
+       int (*build_request)(struct ceph_auth_client *ac, void *buf, void *end);
+       int (*handle_reply)(struct ceph_auth_client *ac, int result,
+                           void *buf, void *end);
+
+       /*
+        * Create authorizer for connecting to a service, and verify
+        * the response to authenticate the service.
+        */
+       int (*create_authorizer)(struct ceph_auth_client *ac, int peer_type,
+                                struct ceph_authorizer **a,
+                                void **buf, size_t *len,
+                                void **reply_buf, size_t *reply_len);
+       int (*verify_authorizer_reply)(struct ceph_auth_client *ac,
+                                      struct ceph_authorizer *a, size_t len);
+       void (*destroy_authorizer)(struct ceph_auth_client *ac,
+                                  struct ceph_authorizer *a);
+       void (*invalidate_authorizer)(struct ceph_auth_client *ac,
+                                     int peer_type);
+
+       /* reset when we (re)connect to a monitor */
+       void (*reset)(struct ceph_auth_client *ac);
+
+       void (*destroy)(struct ceph_auth_client *ac);
+};
+
+struct ceph_auth_client {
+       u32 protocol;           /* CEPH_AUTH_* */
+       void *private;          /* for use by protocol implementation */
+       const struct ceph_auth_client_ops *ops;  /* null iff protocol==0 */
+
+       bool negotiating;       /* true if negotiating protocol */
+       const char *name;       /* entity name */
+       u64 global_id;          /* our unique id in system */
+       const char *secret;     /* our secret key */
+       unsigned want_keys;     /* which services we want */
+};
+
+extern struct ceph_auth_client *ceph_auth_init(const char *name,
+                                              const char *secret);
+extern void ceph_auth_destroy(struct ceph_auth_client *ac);
+
+extern void ceph_auth_reset(struct ceph_auth_client *ac);
+
+extern int ceph_auth_build_hello(struct ceph_auth_client *ac,
+                                void *buf, size_t len);
+extern int ceph_handle_auth_reply(struct ceph_auth_client *ac,
+                                 void *buf, size_t len,
+                                 void *reply_buf, size_t reply_len);
+extern int ceph_entity_name_encode(const char *name, void **p, void *end);
+
+extern int ceph_build_auth(struct ceph_auth_client *ac,
+                   void *msg_buf, size_t msg_len);
+
+extern int ceph_auth_is_authenticated(struct ceph_auth_client *ac);
+
+#endif
diff --git a/fs/ceph/auth_none.c b/fs/ceph/auth_none.c
new file mode 100644 (file)
index 0000000..8cd9e3a
--- /dev/null
@@ -0,0 +1,122 @@
+
+#include "ceph_debug.h"
+
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/slab.h>
+
+#include "auth_none.h"
+#include "auth.h"
+#include "decode.h"
+
+static void reset(struct ceph_auth_client *ac)
+{
+       struct ceph_auth_none_info *xi = ac->private;
+
+       xi->starting = true;
+       xi->built_authorizer = false;
+}
+
+static void destroy(struct ceph_auth_client *ac)
+{
+       kfree(ac->private);
+       ac->private = NULL;
+}
+
+static int is_authenticated(struct ceph_auth_client *ac)
+{
+       struct ceph_auth_none_info *xi = ac->private;
+
+       return !xi->starting;
+}
+
+/*
+ * the generic auth code decode the global_id, and we carry no actual
+ * authenticate state, so nothing happens here.
+ */
+static int handle_reply(struct ceph_auth_client *ac, int result,
+                       void *buf, void *end)
+{
+       struct ceph_auth_none_info *xi = ac->private;
+
+       xi->starting = false;
+       return result;
+}
+
+/*
+ * build an 'authorizer' with our entity_name and global_id.  we can
+ * reuse a single static copy since it is identical for all services
+ * we connect to.
+ */
+static int ceph_auth_none_create_authorizer(
+       struct ceph_auth_client *ac, int peer_type,
+       struct ceph_authorizer **a,
+       void **buf, size_t *len,
+       void **reply_buf, size_t *reply_len)
+{
+       struct ceph_auth_none_info *ai = ac->private;
+       struct ceph_none_authorizer *au = &ai->au;
+       void *p, *end;
+       int ret;
+
+       if (!ai->built_authorizer) {
+               p = au->buf;
+               end = p + sizeof(au->buf);
+               ceph_encode_8(&p, 1);
+               ret = ceph_entity_name_encode(ac->name, &p, end - 8);
+               if (ret < 0)
+                       goto bad;
+               ceph_decode_need(&p, end, sizeof(u64), bad2);
+               ceph_encode_64(&p, ac->global_id);
+               au->buf_len = p - (void *)au->buf;
+               ai->built_authorizer = true;
+               dout("built authorizer len %d\n", au->buf_len);
+       }
+
+       *a = (struct ceph_authorizer *)au;
+       *buf = au->buf;
+       *len = au->buf_len;
+       *reply_buf = au->reply_buf;
+       *reply_len = sizeof(au->reply_buf);
+       return 0;
+
+bad2:
+       ret = -ERANGE;
+bad:
+       return ret;
+}
+
+static void ceph_auth_none_destroy_authorizer(struct ceph_auth_client *ac,
+                                     struct ceph_authorizer *a)
+{
+       /* nothing to do */
+}
+
+static const struct ceph_auth_client_ops ceph_auth_none_ops = {
+       .reset = reset,
+       .destroy = destroy,
+       .is_authenticated = is_authenticated,
+       .handle_reply = handle_reply,
+       .create_authorizer = ceph_auth_none_create_authorizer,
+       .destroy_authorizer = ceph_auth_none_destroy_authorizer,
+};
+
+int ceph_auth_none_init(struct ceph_auth_client *ac)
+{
+       struct ceph_auth_none_info *xi;
+
+       dout("ceph_auth_none_init %p\n", ac);
+       xi = kzalloc(sizeof(*xi), GFP_NOFS);
+       if (!xi)
+               return -ENOMEM;
+
+       xi->starting = true;
+       xi->built_authorizer = false;
+
+       ac->protocol = CEPH_AUTH_NONE;
+       ac->private = xi;
+       ac->ops = &ceph_auth_none_ops;
+       return 0;
+}
+
diff --git a/fs/ceph/auth_none.h b/fs/ceph/auth_none.h
new file mode 100644 (file)
index 0000000..56c0553
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef _FS_CEPH_AUTH_NONE_H
+#define _FS_CEPH_AUTH_NONE_H
+
+#include "auth.h"
+
+/*
+ * null security mode.
+ *
+ * we use a single static authorizer that simply encodes our entity name
+ * and global id.
+ */
+
+struct ceph_none_authorizer {
+       char buf[128];
+       int buf_len;
+       char reply_buf[0];
+};
+
+struct ceph_auth_none_info {
+       bool starting;
+       bool built_authorizer;
+       struct ceph_none_authorizer au;   /* we only need one; it's static */
+};
+
+extern int ceph_auth_none_init(struct ceph_auth_client *ac);
+
+#endif
+
diff --git a/fs/ceph/auth_x.c b/fs/ceph/auth_x.c
new file mode 100644 (file)
index 0000000..d9001a4
--- /dev/null
@@ -0,0 +1,680 @@
+
+#include "ceph_debug.h"
+
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/random.h>
+#include <linux/slab.h>
+
+#include "auth_x.h"
+#include "auth_x_protocol.h"
+#include "crypto.h"
+#include "auth.h"
+#include "decode.h"
+
+struct kmem_cache *ceph_x_ticketbuf_cachep;
+
+#define TEMP_TICKET_BUF_LEN    256
+
+static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed);
+
+static int ceph_x_is_authenticated(struct ceph_auth_client *ac)
+{
+       struct ceph_x_info *xi = ac->private;
+       int need;
+
+       ceph_x_validate_tickets(ac, &need);
+       dout("ceph_x_is_authenticated want=%d need=%d have=%d\n",
+            ac->want_keys, need, xi->have_keys);
+       return (ac->want_keys & xi->have_keys) == ac->want_keys;
+}
+
+static int ceph_x_encrypt_buflen(int ilen)
+{
+       return sizeof(struct ceph_x_encrypt_header) + ilen + 16 +
+               sizeof(u32);
+}
+
+static int ceph_x_encrypt(struct ceph_crypto_key *secret,
+                         void *ibuf, int ilen, void *obuf, size_t olen)
+{
+       struct ceph_x_encrypt_header head = {
+               .struct_v = 1,
+               .magic = cpu_to_le64(CEPHX_ENC_MAGIC)
+       };
+       size_t len = olen - sizeof(u32);
+       int ret;
+
+       ret = ceph_encrypt2(secret, obuf + sizeof(u32), &len,
+                           &head, sizeof(head), ibuf, ilen);
+       if (ret)
+               return ret;
+       ceph_encode_32(&obuf, len);
+       return len + sizeof(u32);
+}
+
+static int ceph_x_decrypt(struct ceph_crypto_key *secret,
+                         void **p, void *end, void *obuf, size_t olen)
+{
+       struct ceph_x_encrypt_header head;
+       size_t head_len = sizeof(head);
+       int len, ret;
+
+       len = ceph_decode_32(p);
+       if (*p + len > end)
+               return -EINVAL;
+
+       dout("ceph_x_decrypt len %d\n", len);
+       ret = ceph_decrypt2(secret, &head, &head_len, obuf, &olen,
+                           *p, len);
+       if (ret)
+               return ret;
+       if (head.struct_v != 1 || le64_to_cpu(head.magic) != CEPHX_ENC_MAGIC)
+               return -EPERM;
+       *p += len;
+       return olen;
+}
+
+/*
+ * get existing (or insert new) ticket handler
+ */
+struct ceph_x_ticket_handler *get_ticket_handler(struct ceph_auth_client *ac,
+                                                int service)
+{
+       struct ceph_x_ticket_handler *th;
+       struct ceph_x_info *xi = ac->private;
+       struct rb_node *parent = NULL, **p = &xi->ticket_handlers.rb_node;
+
+       while (*p) {
+               parent = *p;
+               th = rb_entry(parent, struct ceph_x_ticket_handler, node);
+               if (service < th->service)
+                       p = &(*p)->rb_left;
+               else if (service > th->service)
+                       p = &(*p)->rb_right;
+               else
+                       return th;
+       }
+
+       /* add it */
+       th = kzalloc(sizeof(*th), GFP_NOFS);
+       if (!th)
+               return ERR_PTR(-ENOMEM);
+       th->service = service;
+       rb_link_node(&th->node, parent, p);
+       rb_insert_color(&th->node, &xi->ticket_handlers);
+       return th;
+}
+
+static void remove_ticket_handler(struct ceph_auth_client *ac,
+                                 struct ceph_x_ticket_handler *th)
+{
+       struct ceph_x_info *xi = ac->private;
+
+       dout("remove_ticket_handler %p %d\n", th, th->service);
+       rb_erase(&th->node, &xi->ticket_handlers);
+       ceph_crypto_key_destroy(&th->session_key);
+       if (th->ticket_blob)
+               ceph_buffer_put(th->ticket_blob);
+       kfree(th);
+}
+
+static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
+                                   struct ceph_crypto_key *secret,
+                                   void *buf, void *end)
+{
+       struct ceph_x_info *xi = ac->private;
+       int num;
+       void *p = buf;
+       int ret;
+       char *dbuf;
+       char *ticket_buf;
+       u8 struct_v;
+
+       dbuf = kmem_cache_alloc(ceph_x_ticketbuf_cachep, GFP_NOFS | GFP_ATOMIC);
+       if (!dbuf)
+               return -ENOMEM;
+
+       ret = -ENOMEM;
+       ticket_buf = kmem_cache_alloc(ceph_x_ticketbuf_cachep,
+                                     GFP_NOFS | GFP_ATOMIC);
+       if (!ticket_buf)
+               goto out_dbuf;
+
+       ceph_decode_need(&p, end, 1 + sizeof(u32), bad);
+       struct_v = ceph_decode_8(&p);
+       if (struct_v != 1)
+               goto bad;
+       num = ceph_decode_32(&p);
+       dout("%d tickets\n", num);
+       while (num--) {
+               int type;
+               u8 struct_v;
+               struct ceph_x_ticket_handler *th;
+               void *dp, *dend;
+               int dlen;
+               char is_enc;
+               struct timespec validity;
+               struct ceph_crypto_key old_key;
+               void *tp, *tpend;
+               struct ceph_timespec new_validity;
+               struct ceph_crypto_key new_session_key;
+               struct ceph_buffer *new_ticket_blob;
+               unsigned long new_expires, new_renew_after;
+               u64 new_secret_id;
+
+               ceph_decode_need(&p, end, sizeof(u32) + 1, bad);
+
+               type = ceph_decode_32(&p);
+               dout(" ticket type %d %s\n", type, ceph_entity_type_name(type));
+
+               struct_v = ceph_decode_8(&p);
+               if (struct_v != 1)
+                       goto bad;
+
+               th = get_ticket_handler(ac, type);
+               if (IS_ERR(th)) {
+                       ret = PTR_ERR(th);
+                       goto out;
+               }
+
+               /* blob for me */
+               dlen = ceph_x_decrypt(secret, &p, end, dbuf,
+                                     TEMP_TICKET_BUF_LEN);
+               if (dlen <= 0) {
+                       ret = dlen;
+                       goto out;
+               }
+               dout(" decrypted %d bytes\n", dlen);
+               dend = dbuf + dlen;
+               dp = dbuf;
+
+               struct_v = ceph_decode_8(&dp);
+               if (struct_v != 1)
+                       goto bad;
+
+               memcpy(&old_key, &th->session_key, sizeof(old_key));
+               ret = ceph_crypto_key_decode(&new_session_key, &dp, dend);
+               if (ret)
+                       goto out;
+
+               ceph_decode_copy(&dp, &new_validity, sizeof(new_validity));
+               ceph_decode_timespec(&validity, &new_validity);
+               new_expires = get_seconds() + validity.tv_sec;
+               new_renew_after = new_expires - (validity.tv_sec / 4);
+               dout(" expires=%lu renew_after=%lu\n", new_expires,
+                    new_renew_after);
+
+               /* ticket blob for service */
+               ceph_decode_8_safe(&p, end, is_enc, bad);
+               tp = ticket_buf;
+               if (is_enc) {
+                       /* encrypted */
+                       dout(" encrypted ticket\n");
+                       dlen = ceph_x_decrypt(&old_key, &p, end, ticket_buf,
+                                             TEMP_TICKET_BUF_LEN);
+                       if (dlen < 0) {
+                               ret = dlen;
+                               goto out;
+                       }
+                       dlen = ceph_decode_32(&tp);
+               } else {
+                       /* unencrypted */
+                       ceph_decode_32_safe(&p, end, dlen, bad);
+                       ceph_decode_need(&p, end, dlen, bad);
+                       ceph_decode_copy(&p, ticket_buf, dlen);
+               }
+               tpend = tp + dlen;
+               dout(" ticket blob is %d bytes\n", dlen);
+               ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad);
+               struct_v = ceph_decode_8(&tp);
+               new_secret_id = ceph_decode_64(&tp);
+               ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend);
+               if (ret)
+                       goto out;
+
+               /* all is well, update our ticket */
+               ceph_crypto_key_destroy(&th->session_key);
+               if (th->ticket_blob)
+                       ceph_buffer_put(th->ticket_blob);
+               th->session_key = new_session_key;
+               th->ticket_blob = new_ticket_blob;
+               th->validity = new_validity;
+               th->secret_id = new_secret_id;
+               th->expires = new_expires;
+               th->renew_after = new_renew_after;
+               dout(" got ticket service %d (%s) secret_id %lld len %d\n",
+                    type, ceph_entity_type_name(type), th->secret_id,
+                    (int)th->ticket_blob->vec.iov_len);
+               xi->have_keys |= th->service;
+       }
+
+       ret = 0;
+out:
+       kmem_cache_free(ceph_x_ticketbuf_cachep, ticket_buf);
+out_dbuf:
+       kmem_cache_free(ceph_x_ticketbuf_cachep, dbuf);
+       return ret;
+
+bad:
+       ret = -EINVAL;
+       goto out;
+}
+
+static int ceph_x_build_authorizer(struct ceph_auth_client *ac,
+                                  struct ceph_x_ticket_handler *th,
+                                  struct ceph_x_authorizer *au)
+{
+       int maxlen;
+       struct ceph_x_authorize_a *msg_a;
+       struct ceph_x_authorize_b msg_b;
+       void *p, *end;
+       int ret;
+       int ticket_blob_len =
+               (th->ticket_blob ? th->ticket_blob->vec.iov_len : 0);
+
+       dout("build_authorizer for %s %p\n",
+            ceph_entity_type_name(th->service), au);
+
+       maxlen = sizeof(*msg_a) + sizeof(msg_b) +
+               ceph_x_encrypt_buflen(ticket_blob_len);
+       dout("  need len %d\n", maxlen);
+       if (au->buf && au->buf->alloc_len < maxlen) {
+               ceph_buffer_put(au->buf);
+               au->buf = NULL;
+       }
+       if (!au->buf) {
+               au->buf = ceph_buffer_new(maxlen, GFP_NOFS);
+               if (!au->buf)
+                       return -ENOMEM;
+       }
+       au->service = th->service;
+
+       msg_a = au->buf->vec.iov_base;
+       msg_a->struct_v = 1;
+       msg_a->global_id = cpu_to_le64(ac->global_id);
+       msg_a->service_id = cpu_to_le32(th->service);
+       msg_a->ticket_blob.struct_v = 1;
+       msg_a->ticket_blob.secret_id = cpu_to_le64(th->secret_id);
+       msg_a->ticket_blob.blob_len = cpu_to_le32(ticket_blob_len);
+       if (ticket_blob_len) {
+               memcpy(msg_a->ticket_blob.blob, th->ticket_blob->vec.iov_base,
+                      th->ticket_blob->vec.iov_len);
+       }
+       dout(" th %p secret_id %lld %lld\n", th, th->secret_id,
+            le64_to_cpu(msg_a->ticket_blob.secret_id));
+
+       p = msg_a + 1;
+       p += ticket_blob_len;
+       end = au->buf->vec.iov_base + au->buf->vec.iov_len;
+
+       get_random_bytes(&au->nonce, sizeof(au->nonce));
+       msg_b.struct_v = 1;
+       msg_b.nonce = cpu_to_le64(au->nonce);
+       ret = ceph_x_encrypt(&th->session_key, &msg_b, sizeof(msg_b),
+                            p, end - p);
+       if (ret < 0)
+               goto out_buf;
+       p += ret;
+       au->buf->vec.iov_len = p - au->buf->vec.iov_base;
+       dout(" built authorizer nonce %llx len %d\n", au->nonce,
+            (int)au->buf->vec.iov_len);
+       BUG_ON(au->buf->vec.iov_len > maxlen);
+       return 0;
+
+out_buf:
+       ceph_buffer_put(au->buf);
+       au->buf = NULL;
+       return ret;
+}
+
+static int ceph_x_encode_ticket(struct ceph_x_ticket_handler *th,
+                               void **p, void *end)
+{
+       ceph_decode_need(p, end, 1 + sizeof(u64), bad);
+       ceph_encode_8(p, 1);
+       ceph_encode_64(p, th->secret_id);
+       if (th->ticket_blob) {
+               const char *buf = th->ticket_blob->vec.iov_base;
+               u32 len = th->ticket_blob->vec.iov_len;
+
+               ceph_encode_32_safe(p, end, len, bad);
+               ceph_encode_copy_safe(p, end, buf, len, bad);
+       } else {
+               ceph_encode_32_safe(p, end, 0, bad);
+       }
+
+       return 0;
+bad:
+       return -ERANGE;
+}
+
+static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed)
+{
+       int want = ac->want_keys;
+       struct ceph_x_info *xi = ac->private;
+       int service;
+
+       *pneed = ac->want_keys & ~(xi->have_keys);
+
+       for (service = 1; service <= want; service <<= 1) {
+               struct ceph_x_ticket_handler *th;
+
+               if (!(ac->want_keys & service))
+                       continue;
+
+               if (*pneed & service)
+                       continue;
+
+               th = get_ticket_handler(ac, service);
+
+               if (!th) {
+                       *pneed |= service;
+                       continue;
+               }
+
+               if (get_seconds() >= th->renew_after)
+                       *pneed |= service;
+               if (get_seconds() >= th->expires)
+                       xi->have_keys &= ~service;
+       }
+}
+
+
+static int ceph_x_build_request(struct ceph_auth_client *ac,
+                               void *buf, void *end)
+{
+       struct ceph_x_info *xi = ac->private;
+       int need;
+       struct ceph_x_request_header *head = buf;
+       int ret;
+       struct ceph_x_ticket_handler *th =
+               get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
+
+       ceph_x_validate_tickets(ac, &need);
+
+       dout("build_request want %x have %x need %x\n",
+            ac->want_keys, xi->have_keys, need);
+
+       if (need & CEPH_ENTITY_TYPE_AUTH) {
+               struct ceph_x_authenticate *auth = (void *)(head + 1);
+               void *p = auth + 1;
+               struct ceph_x_challenge_blob tmp;
+               char tmp_enc[40];
+               u64 *u;
+
+               if (p > end)
+                       return -ERANGE;
+
+               dout(" get_auth_session_key\n");
+               head->op = cpu_to_le16(CEPHX_GET_AUTH_SESSION_KEY);
+
+               /* encrypt and hash */
+               get_random_bytes(&auth->client_challenge, sizeof(u64));
+               tmp.client_challenge = auth->client_challenge;
+               tmp.server_challenge = cpu_to_le64(xi->server_challenge);
+               ret = ceph_x_encrypt(&xi->secret, &tmp, sizeof(tmp),
+                                    tmp_enc, sizeof(tmp_enc));
+               if (ret < 0)
+                       return ret;
+
+               auth->struct_v = 1;
+               auth->key = 0;
+               for (u = (u64 *)tmp_enc; u + 1 <= (u64 *)(tmp_enc + ret); u++)
+                       auth->key ^= *u;
+               dout(" server_challenge %llx client_challenge %llx key %llx\n",
+                    xi->server_challenge, le64_to_cpu(auth->client_challenge),
+                    le64_to_cpu(auth->key));
+
+               /* now encode the old ticket if exists */
+               ret = ceph_x_encode_ticket(th, &p, end);
+               if (ret < 0)
+                       return ret;
+
+               return p - buf;
+       }
+
+       if (need) {
+               void *p = head + 1;
+               struct ceph_x_service_ticket_request *req;
+
+               if (p > end)
+                       return -ERANGE;
+               head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY);
+
+               BUG_ON(!th);
+               ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer);
+               if (ret)
+                       return ret;
+               ceph_encode_copy(&p, xi->auth_authorizer.buf->vec.iov_base,
+                                xi->auth_authorizer.buf->vec.iov_len);
+
+               req = p;
+               req->keys = cpu_to_le32(need);
+               p += sizeof(*req);
+               return p - buf;
+       }
+
+       return 0;
+}
+
+static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result,
+                              void *buf, void *end)
+{
+       struct ceph_x_info *xi = ac->private;
+       struct ceph_x_reply_header *head = buf;
+       struct ceph_x_ticket_handler *th;
+       int len = end - buf;
+       int op;
+       int ret;
+
+       if (result)
+               return result;  /* XXX hmm? */
+
+       if (xi->starting) {
+               /* it's a hello */
+               struct ceph_x_server_challenge *sc = buf;
+
+               if (len != sizeof(*sc))
+                       return -EINVAL;
+               xi->server_challenge = le64_to_cpu(sc->server_challenge);
+               dout("handle_reply got server challenge %llx\n",
+                    xi->server_challenge);
+               xi->starting = false;
+               xi->have_keys &= ~CEPH_ENTITY_TYPE_AUTH;
+               return -EAGAIN;
+       }
+
+       op = le32_to_cpu(head->op);
+       result = le32_to_cpu(head->result);
+       dout("handle_reply op %d result %d\n", op, result);
+       switch (op) {
+       case CEPHX_GET_AUTH_SESSION_KEY:
+               /* verify auth key */
+               ret = ceph_x_proc_ticket_reply(ac, &xi->secret,
+                                              buf + sizeof(*head), end);
+               break;
+
+       case CEPHX_GET_PRINCIPAL_SESSION_KEY:
+               th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
+               BUG_ON(!th);
+               ret = ceph_x_proc_ticket_reply(ac, &th->session_key,
+                                              buf + sizeof(*head), end);
+               break;
+
+       default:
+               return -EINVAL;
+       }
+       if (ret)
+               return ret;
+       if (ac->want_keys == xi->have_keys)
+               return 0;
+       return -EAGAIN;
+}
+
+static int ceph_x_create_authorizer(
+       struct ceph_auth_client *ac, int peer_type,
+       struct ceph_authorizer **a,
+       void **buf, size_t *len,
+       void **reply_buf, size_t *reply_len)
+{
+       struct ceph_x_authorizer *au;
+       struct ceph_x_ticket_handler *th;
+       int ret;
+
+       th = get_ticket_handler(ac, peer_type);
+       if (IS_ERR(th))
+               return PTR_ERR(th);
+
+       au = kzalloc(sizeof(*au), GFP_NOFS);
+       if (!au)
+               return -ENOMEM;
+
+       ret = ceph_x_build_authorizer(ac, th, au);
+       if (ret) {
+               kfree(au);
+               return ret;
+       }
+
+       *a = (struct ceph_authorizer *)au;
+       *buf = au->buf->vec.iov_base;
+       *len = au->buf->vec.iov_len;
+       *reply_buf = au->reply_buf;
+       *reply_len = sizeof(au->reply_buf);
+       return 0;
+}
+
+static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
+                                         struct ceph_authorizer *a, size_t len)
+{
+       struct ceph_x_authorizer *au = (void *)a;
+       struct ceph_x_ticket_handler *th;
+       int ret = 0;
+       struct ceph_x_authorize_reply reply;
+       void *p = au->reply_buf;
+       void *end = p + sizeof(au->reply_buf);
+
+       th = get_ticket_handler(ac, au->service);
+       if (!th)
+               return -EIO;  /* hrm! */
+       ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply));
+       if (ret < 0)
+               return ret;
+       if (ret != sizeof(reply))
+               return -EPERM;
+
+       if (au->nonce + 1 != le64_to_cpu(reply.nonce_plus_one))
+               ret = -EPERM;
+       else
+               ret = 0;
+       dout("verify_authorizer_reply nonce %llx got %llx ret %d\n",
+            au->nonce, le64_to_cpu(reply.nonce_plus_one), ret);
+       return ret;
+}
+
+static void ceph_x_destroy_authorizer(struct ceph_auth_client *ac,
+                                     struct ceph_authorizer *a)
+{
+       struct ceph_x_authorizer *au = (void *)a;
+
+       ceph_buffer_put(au->buf);
+       kfree(au);
+}
+
+
+static void ceph_x_reset(struct ceph_auth_client *ac)
+{
+       struct ceph_x_info *xi = ac->private;
+
+       dout("reset\n");
+       xi->starting = true;
+       xi->server_challenge = 0;
+}
+
+static void ceph_x_destroy(struct ceph_auth_client *ac)
+{
+       struct ceph_x_info *xi = ac->private;
+       struct rb_node *p;
+
+       dout("ceph_x_destroy %p\n", ac);
+       ceph_crypto_key_destroy(&xi->secret);
+
+       while ((p = rb_first(&xi->ticket_handlers)) != NULL) {
+               struct ceph_x_ticket_handler *th =
+                       rb_entry(p, struct ceph_x_ticket_handler, node);
+               remove_ticket_handler(ac, th);
+       }
+
+       kmem_cache_destroy(ceph_x_ticketbuf_cachep);
+
+       kfree(ac->private);
+       ac->private = NULL;
+}
+
+static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac,
+                                  int peer_type)
+{
+       struct ceph_x_ticket_handler *th;
+
+       th = get_ticket_handler(ac, peer_type);
+       if (th && !IS_ERR(th))
+               remove_ticket_handler(ac, th);
+}
+
+
+static const struct ceph_auth_client_ops ceph_x_ops = {
+       .is_authenticated = ceph_x_is_authenticated,
+       .build_request = ceph_x_build_request,
+       .handle_reply = ceph_x_handle_reply,
+       .create_authorizer = ceph_x_create_authorizer,
+       .verify_authorizer_reply = ceph_x_verify_authorizer_reply,
+       .destroy_authorizer = ceph_x_destroy_authorizer,
+       .invalidate_authorizer = ceph_x_invalidate_authorizer,
+       .reset =  ceph_x_reset,
+       .destroy = ceph_x_destroy,
+};
+
+
+int ceph_x_init(struct ceph_auth_client *ac)
+{
+       struct ceph_x_info *xi;
+       int ret;
+
+       dout("ceph_x_init %p\n", ac);
+       xi = kzalloc(sizeof(*xi), GFP_NOFS);
+       if (!xi)
+               return -ENOMEM;
+
+       ret = -ENOMEM;
+       ceph_x_ticketbuf_cachep = kmem_cache_create("ceph_x_ticketbuf",
+                                     TEMP_TICKET_BUF_LEN, 8,
+                                     (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD),
+                                     NULL);
+       if (!ceph_x_ticketbuf_cachep)
+               goto done_nomem;
+       ret = -EINVAL;
+       if (!ac->secret) {
+               pr_err("no secret set (for auth_x protocol)\n");
+               goto done_nomem;
+       }
+
+       ret = ceph_crypto_key_unarmor(&xi->secret, ac->secret);
+       if (ret)
+               goto done_nomem;
+
+       xi->starting = true;
+       xi->ticket_handlers = RB_ROOT;
+
+       ac->protocol = CEPH_AUTH_CEPHX;
+       ac->private = xi;
+       ac->ops = &ceph_x_ops;
+       return 0;
+
+done_nomem:
+       kfree(xi);
+       if (ceph_x_ticketbuf_cachep)
+               kmem_cache_destroy(ceph_x_ticketbuf_cachep);
+       return ret;
+}
+
+
diff --git a/fs/ceph/auth_x.h b/fs/ceph/auth_x.h
new file mode 100644 (file)
index 0000000..ff6f818
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef _FS_CEPH_AUTH_X_H
+#define _FS_CEPH_AUTH_X_H
+
+#include <linux/rbtree.h>
+
+#include "crypto.h"
+#include "auth.h"
+#include "auth_x_protocol.h"
+
+/*
+ * Handle ticket for a single service.
+ */
+struct ceph_x_ticket_handler {
+       struct rb_node node;
+       unsigned service;
+
+       struct ceph_crypto_key session_key;
+       struct ceph_timespec validity;
+
+       u64 secret_id;
+       struct ceph_buffer *ticket_blob;
+
+       unsigned long renew_after, expires;
+};
+
+
+struct ceph_x_authorizer {
+       struct ceph_buffer *buf;
+       unsigned service;
+       u64 nonce;
+       char reply_buf[128];  /* big enough for encrypted blob */
+};
+
+struct ceph_x_info {
+       struct ceph_crypto_key secret;
+
+       bool starting;
+       u64 server_challenge;
+
+       unsigned have_keys;
+       struct rb_root ticket_handlers;
+
+       struct ceph_x_authorizer auth_authorizer;
+};
+
+extern int ceph_x_init(struct ceph_auth_client *ac);
+
+#endif
+
diff --git a/fs/ceph/auth_x_protocol.h b/fs/ceph/auth_x_protocol.h
new file mode 100644 (file)
index 0000000..671d305
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef __FS_CEPH_AUTH_X_PROTOCOL
+#define __FS_CEPH_AUTH_X_PROTOCOL
+
+#define CEPHX_GET_AUTH_SESSION_KEY      0x0100
+#define CEPHX_GET_PRINCIPAL_SESSION_KEY 0x0200
+#define CEPHX_GET_ROTATING_KEY          0x0400
+
+/* common bits */
+struct ceph_x_ticket_blob {
+       __u8 struct_v;
+       __le64 secret_id;
+       __le32 blob_len;
+       char blob[];
+} __attribute__ ((packed));
+
+
+/* common request/reply headers */
+struct ceph_x_request_header {
+       __le16 op;
+} __attribute__ ((packed));
+
+struct ceph_x_reply_header {
+       __le16 op;
+       __le32 result;
+} __attribute__ ((packed));
+
+
+/* authenticate handshake */
+
+/* initial hello (no reply header) */
+struct ceph_x_server_challenge {
+       __u8 struct_v;
+       __le64 server_challenge;
+} __attribute__ ((packed));
+
+struct ceph_x_authenticate {
+       __u8 struct_v;
+       __le64 client_challenge;
+       __le64 key;
+       /* ticket blob */
+} __attribute__ ((packed));
+
+struct ceph_x_service_ticket_request {
+       __u8 struct_v;
+       __le32 keys;
+} __attribute__ ((packed));
+
+struct ceph_x_challenge_blob {
+       __le64 server_challenge;
+       __le64 client_challenge;
+} __attribute__ ((packed));
+
+
+
+/* authorize handshake */
+
+/*
+ * The authorizer consists of two pieces:
+ *  a - service id, ticket blob
+ *  b - encrypted with session key
+ */
+struct ceph_x_authorize_a {
+       __u8 struct_v;
+       __le64 global_id;
+       __le32 service_id;
+       struct ceph_x_ticket_blob ticket_blob;
+} __attribute__ ((packed));
+
+struct ceph_x_authorize_b {
+       __u8 struct_v;
+       __le64 nonce;
+} __attribute__ ((packed));
+
+struct ceph_x_authorize_reply {
+       __u8 struct_v;
+       __le64 nonce_plus_one;
+} __attribute__ ((packed));
+
+
+/*
+ * encyption bundle
+ */
+#define CEPHX_ENC_MAGIC 0xff009cad8826aa55ull
+
+struct ceph_x_encrypt_header {
+       __u8 struct_v;
+       __le64 magic;
+} __attribute__ ((packed));
+
+#endif
diff --git a/fs/ceph/buffer.c b/fs/ceph/buffer.c
new file mode 100644 (file)
index 0000000..c67535d
--- /dev/null
@@ -0,0 +1,81 @@
+
+#include "ceph_debug.h"
+
+#include <linux/slab.h>
+
+#include "buffer.h"
+#include "decode.h"
+
+struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp)
+{
+       struct ceph_buffer *b;
+
+       b = kmalloc(sizeof(*b), gfp);
+       if (!b)
+               return NULL;
+
+       b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN);
+       if (b->vec.iov_base) {
+               b->is_vmalloc = false;
+       } else {
+               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
+               if (!b->vec.iov_base) {
+                       kfree(b);
+                       return NULL;
+               }
+               b->is_vmalloc = true;
+       }
+
+       kref_init(&b->kref);
+       b->alloc_len = len;
+       b->vec.iov_len = len;
+       dout("buffer_new %p\n", b);
+       return b;
+}
+
+void ceph_buffer_release(struct kref *kref)
+{
+       struct ceph_buffer *b = container_of(kref, struct ceph_buffer, kref);
+
+       dout("buffer_release %p\n", b);
+       if (b->vec.iov_base) {
+               if (b->is_vmalloc)
+                       vfree(b->vec.iov_base);
+               else
+                       kfree(b->vec.iov_base);
+       }
+       kfree(b);
+}
+
+int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
+{
+       b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN);
+       if (b->vec.iov_base) {
+               b->is_vmalloc = false;
+       } else {
+               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
+               b->is_vmalloc = true;
+       }
+       if (!b->vec.iov_base)
+               return -ENOMEM;
+       b->alloc_len = len;
+       b->vec.iov_len = len;
+       return 0;
+}
+
+int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end)
+{
+       size_t len;
+
+       ceph_decode_need(p, end, sizeof(u32), bad);
+       len = ceph_decode_32(p);
+       dout("decode_buffer len %d\n", (int)len);
+       ceph_decode_need(p, end, len, bad);
+       *b = ceph_buffer_new(len, GFP_NOFS);
+       if (!*b)
+               return -ENOMEM;
+       ceph_decode_copy(p, (*b)->vec.iov_base, len);
+       return 0;
+bad:
+       return -EINVAL;
+}
diff --git a/fs/ceph/buffer.h b/fs/ceph/buffer.h
new file mode 100644 (file)
index 0000000..58d1901
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __FS_CEPH_BUFFER_H
+#define __FS_CEPH_BUFFER_H
+
+#include <linux/kref.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/types.h>
+#include <linux/uio.h>
+
+/*
+ * a simple reference counted buffer.
+ *
+ * use kmalloc for small sizes (<= one page), vmalloc for larger
+ * sizes.
+ */
+struct ceph_buffer {
+       struct kref kref;
+       struct kvec vec;
+       size_t alloc_len;
+       bool is_vmalloc;
+};
+
+extern struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp);
+extern void ceph_buffer_release(struct kref *kref);
+
+static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)
+{
+       kref_get(&b->kref);
+       return b;
+}
+
+static inline void ceph_buffer_put(struct ceph_buffer *b)
+{
+       kref_put(&b->kref, ceph_buffer_release);
+}
+
+extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);
+
+#endif
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
new file mode 100644 (file)
index 0000000..3710e07
--- /dev/null
@@ -0,0 +1,2933 @@
+#include "ceph_debug.h"
+
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/wait.h>
+#include <linux/writeback.h>
+
+#include "super.h"
+#include "decode.h"
+#include "messenger.h"
+
+/*
+ * Capability management
+ *
+ * The Ceph metadata servers control client access to inode metadata
+ * and file data by issuing capabilities, granting clients permission
+ * to read and/or write both inode field and file data to OSDs
+ * (storage nodes).  Each capability consists of a set of bits
+ * indicating which operations are allowed.
+ *
+ * If the client holds a *_SHARED cap, the client has a coherent value
+ * that can be safely read from the cached inode.
+ *
+ * In the case of a *_EXCL (exclusive) or FILE_WR capabilities, the
+ * client is allowed to change inode attributes (e.g., file size,
+ * mtime), note its dirty state in the ceph_cap, and asynchronously
+ * flush that metadata change to the MDS.
+ *
+ * In the event of a conflicting operation (perhaps by another
+ * client), the MDS will revoke the conflicting client capabilities.
+ *
+ * In order for a client to cache an inode, it must hold a capability
+ * with at least one MDS server.  When inodes are released, release
+ * notifications are batched and periodically sent en masse to the MDS
+ * cluster to release server state.
+ */
+
+
+/*
+ * Generate readable cap strings for debugging output.
+ */
+#define MAX_CAP_STR 20
+static char cap_str[MAX_CAP_STR][40];
+static DEFINE_SPINLOCK(cap_str_lock);
+static int last_cap_str;
+
+static char *gcap_string(char *s, int c)
+{
+       if (c & CEPH_CAP_GSHARED)
+               *s++ = 's';
+       if (c & CEPH_CAP_GEXCL)
+               *s++ = 'x';
+       if (c & CEPH_CAP_GCACHE)
+               *s++ = 'c';
+       if (c & CEPH_CAP_GRD)
+               *s++ = 'r';
+       if (c & CEPH_CAP_GWR)
+               *s++ = 'w';
+       if (c & CEPH_CAP_GBUFFER)
+               *s++ = 'b';
+       if (c & CEPH_CAP_GLAZYIO)
+               *s++ = 'l';
+       return s;
+}
+
+const char *ceph_cap_string(int caps)
+{
+       int i;
+       char *s;
+       int c;
+
+       spin_lock(&cap_str_lock);
+       i = last_cap_str++;
+       if (last_cap_str == MAX_CAP_STR)
+               last_cap_str = 0;
+       spin_unlock(&cap_str_lock);
+
+       s = cap_str[i];
+
+       if (caps & CEPH_CAP_PIN)
+               *s++ = 'p';
+
+       c = (caps >> CEPH_CAP_SAUTH) & 3;
+       if (c) {
+               *s++ = 'A';
+               s = gcap_string(s, c);
+       }
+
+       c = (caps >> CEPH_CAP_SLINK) & 3;
+       if (c) {
+               *s++ = 'L';
+               s = gcap_string(s, c);
+       }
+
+       c = (caps >> CEPH_CAP_SXATTR) & 3;
+       if (c) {
+               *s++ = 'X';
+               s = gcap_string(s, c);
+       }
+
+       c = caps >> CEPH_CAP_SFILE;
+       if (c) {
+               *s++ = 'F';
+               s = gcap_string(s, c);
+       }
+
+       if (s == cap_str[i])
+               *s++ = '-';
+       *s = 0;
+       return cap_str[i];
+}
+
+/*
+ * Cap reservations
+ *
+ * Maintain a global pool of preallocated struct ceph_caps, referenced
+ * by struct ceph_caps_reservations.  This ensures that we preallocate
+ * memory needed to successfully process an MDS response.  (If an MDS
+ * sends us cap information and we fail to process it, we will have
+ * problems due to the client and MDS being out of sync.)
+ *
+ * Reservations are 'owned' by a ceph_cap_reservation context.
+ */
+static spinlock_t caps_list_lock;
+static struct list_head caps_list;  /* unused (reserved or unreserved) */
+static int caps_total_count;        /* total caps allocated */
+static int caps_use_count;          /* in use */
+static int caps_reserve_count;      /* unused, reserved */
+static int caps_avail_count;        /* unused, unreserved */
+static int caps_min_count;          /* keep at least this many (unreserved) */
+
+void __init ceph_caps_init(void)
+{
+       INIT_LIST_HEAD(&caps_list);
+       spin_lock_init(&caps_list_lock);
+}
+
+void ceph_caps_finalize(void)
+{
+       struct ceph_cap *cap;
+
+       spin_lock(&caps_list_lock);
+       while (!list_empty(&caps_list)) {
+               cap = list_first_entry(&caps_list, struct ceph_cap, caps_item);
+               list_del(&cap->caps_item);
+               kmem_cache_free(ceph_cap_cachep, cap);
+       }
+       caps_total_count = 0;
+       caps_avail_count = 0;
+       caps_use_count = 0;
+       caps_reserve_count = 0;
+       caps_min_count = 0;
+       spin_unlock(&caps_list_lock);
+}
+
+void ceph_adjust_min_caps(int delta)
+{
+       spin_lock(&caps_list_lock);
+       caps_min_count += delta;
+       BUG_ON(caps_min_count < 0);
+       spin_unlock(&caps_list_lock);
+}
+
+int ceph_reserve_caps(struct ceph_cap_reservation *ctx, int need)
+{
+       int i;
+       struct ceph_cap *cap;
+       int have;
+       int alloc = 0;
+       LIST_HEAD(newcaps);
+       int ret = 0;
+
+       dout("reserve caps ctx=%p need=%d\n", ctx, need);
+
+       /* first reserve any caps that are already allocated */
+       spin_lock(&caps_list_lock);
+       if (caps_avail_count >= need)
+               have = need;
+       else
+               have = caps_avail_count;
+       caps_avail_count -= have;
+       caps_reserve_count += have;
+       BUG_ON(caps_total_count != caps_use_count + caps_reserve_count +
+              caps_avail_count);
+       spin_unlock(&caps_list_lock);
+
+       for (i = have; i < need; i++) {
+               cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS);
+               if (!cap) {
+                       ret = -ENOMEM;
+                       goto out_alloc_count;
+               }
+               list_add(&cap->caps_item, &newcaps);
+               alloc++;
+       }
+       BUG_ON(have + alloc != need);
+
+       spin_lock(&caps_list_lock);
+       caps_total_count += alloc;
+       caps_reserve_count += alloc;
+       list_splice(&newcaps, &caps_list);
+
+       BUG_ON(caps_total_count != caps_use_count + caps_reserve_count +
+              caps_avail_count);
+       spin_unlock(&caps_list_lock);
+
+       ctx->count = need;
+       dout("reserve caps ctx=%p %d = %d used + %d resv + %d avail\n",
+            ctx, caps_total_count, caps_use_count, caps_reserve_count,
+            caps_avail_count);
+       return 0;
+
+out_alloc_count:
+       /* we didn't manage to reserve as much as we needed */
+       pr_warning("reserve caps ctx=%p ENOMEM need=%d got=%d\n",
+                  ctx, need, have);
+       return ret;
+}
+
+int ceph_unreserve_caps(struct ceph_cap_reservation *ctx)
+{
+       dout("unreserve caps ctx=%p count=%d\n", ctx, ctx->count);
+       if (ctx->count) {
+               spin_lock(&caps_list_lock);
+               BUG_ON(caps_reserve_count < ctx->count);
+               caps_reserve_count -= ctx->count;
+               caps_avail_count += ctx->count;
+               ctx->count = 0;
+               dout("unreserve caps %d = %d used + %d resv + %d avail\n",
+                    caps_total_count, caps_use_count, caps_reserve_count,
+                    caps_avail_count);
+               BUG_ON(caps_total_count != caps_use_count + caps_reserve_count +
+                      caps_avail_count);
+               spin_unlock(&caps_list_lock);
+       }
+       return 0;
+}
+
+static struct ceph_cap *get_cap(struct ceph_cap_reservation *ctx)
+{
+       struct ceph_cap *cap = NULL;
+
+       /* temporary, until we do something about cap import/export */
+       if (!ctx)
+               return kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS);
+
+       spin_lock(&caps_list_lock);
+       dout("get_cap ctx=%p (%d) %d = %d used + %d resv + %d avail\n",
+            ctx, ctx->count, caps_total_count, caps_use_count,
+            caps_reserve_count, caps_avail_count);
+       BUG_ON(!ctx->count);
+       BUG_ON(ctx->count > caps_reserve_count);
+       BUG_ON(list_empty(&caps_list));
+
+       ctx->count--;
+       caps_reserve_count--;
+       caps_use_count++;
+
+       cap = list_first_entry(&caps_list, struct ceph_cap, caps_item);
+       list_del(&cap->caps_item);
+
+       BUG_ON(caps_total_count != caps_use_count + caps_reserve_count +
+              caps_avail_count);
+       spin_unlock(&caps_list_lock);
+       return cap;
+}
+
+void ceph_put_cap(struct ceph_cap *cap)
+{
+       spin_lock(&caps_list_lock);
+       dout("put_cap %p %d = %d used + %d resv + %d avail\n",
+            cap, caps_total_count, caps_use_count,
+            caps_reserve_count, caps_avail_count);
+       caps_use_count--;
+       /*
+        * Keep some preallocated caps around (ceph_min_count), to
+        * avoid lots of free/alloc churn.
+        */
+       if (caps_avail_count >= caps_reserve_count + caps_min_count) {
+               caps_total_count--;
+               kmem_cache_free(ceph_cap_cachep, cap);
+       } else {
+               caps_avail_count++;
+               list_add(&cap->caps_item, &caps_list);
+       }
+
+       BUG_ON(caps_total_count != caps_use_count + caps_reserve_count +
+              caps_avail_count);
+       spin_unlock(&caps_list_lock);
+}
+
+void ceph_reservation_status(struct ceph_client *client,
+                            int *total, int *avail, int *used, int *reserved,
+                            int *min)
+{
+       if (total)
+               *total = caps_total_count;
+       if (avail)
+               *avail = caps_avail_count;
+       if (used)
+               *used = caps_use_count;
+       if (reserved)
+               *reserved = caps_reserve_count;
+       if (min)
+               *min = caps_min_count;
+}
+
+/*
+ * Find ceph_cap for given mds, if any.
+ *
+ * Called with i_lock held.
+ */
+static struct ceph_cap *__get_cap_for_mds(struct ceph_inode_info *ci, int mds)
+{
+       struct ceph_cap *cap;
+       struct rb_node *n = ci->i_caps.rb_node;
+
+       while (n) {
+               cap = rb_entry(n, struct ceph_cap, ci_node);
+               if (mds < cap->mds)
+                       n = n->rb_left;
+               else if (mds > cap->mds)
+                       n = n->rb_right;
+               else
+                       return cap;
+       }
+       return NULL;
+}
+
+/*
+ * Return id of any MDS with a cap, preferably FILE_WR|WRBUFFER|EXCL, else
+ * -1.
+ */
+static int __ceph_get_cap_mds(struct ceph_inode_info *ci, u32 *mseq)
+{
+       struct ceph_cap *cap;
+       int mds = -1;
+       struct rb_node *p;
+
+       /* prefer mds with WR|WRBUFFER|EXCL caps */
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               mds = cap->mds;
+               if (mseq)
+                       *mseq = cap->mseq;
+               if (cap->issued & (CEPH_CAP_FILE_WR |
+                                  CEPH_CAP_FILE_BUFFER |
+                                  CEPH_CAP_FILE_EXCL))
+                       break;
+       }
+       return mds;
+}
+
+int ceph_get_cap_mds(struct inode *inode)
+{
+       int mds;
+       spin_lock(&inode->i_lock);
+       mds = __ceph_get_cap_mds(ceph_inode(inode), NULL);
+       spin_unlock(&inode->i_lock);
+       return mds;
+}
+
+/*
+ * Called under i_lock.
+ */
+static void __insert_cap_node(struct ceph_inode_info *ci,
+                             struct ceph_cap *new)
+{
+       struct rb_node **p = &ci->i_caps.rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_cap *cap = NULL;
+
+       while (*p) {
+               parent = *p;
+               cap = rb_entry(parent, struct ceph_cap, ci_node);
+               if (new->mds < cap->mds)
+                       p = &(*p)->rb_left;
+               else if (new->mds > cap->mds)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->ci_node, parent, p);
+       rb_insert_color(&new->ci_node, &ci->i_caps);
+}
+
+/*
+ * (re)set cap hold timeouts, which control the delayed release
+ * of unused caps back to the MDS.  Should be called on cap use.
+ */
+static void __cap_set_timeouts(struct ceph_mds_client *mdsc,
+                              struct ceph_inode_info *ci)
+{
+       struct ceph_mount_args *ma = mdsc->client->mount_args;
+
+       ci->i_hold_caps_min = round_jiffies(jiffies +
+                                           ma->caps_wanted_delay_min * HZ);
+       ci->i_hold_caps_max = round_jiffies(jiffies +
+                                           ma->caps_wanted_delay_max * HZ);
+       dout("__cap_set_timeouts %p min %lu max %lu\n", &ci->vfs_inode,
+            ci->i_hold_caps_min - jiffies, ci->i_hold_caps_max - jiffies);
+}
+
+/*
+ * (Re)queue cap at the end of the delayed cap release list.
+ *
+ * If I_FLUSH is set, leave the inode at the front of the list.
+ *
+ * Caller holds i_lock
+ *    -> we take mdsc->cap_delay_lock
+ */
+static void __cap_delay_requeue(struct ceph_mds_client *mdsc,
+                               struct ceph_inode_info *ci)
+{
+       __cap_set_timeouts(mdsc, ci);
+       dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode,
+            ci->i_ceph_flags, ci->i_hold_caps_max);
+       if (!mdsc->stopping) {
+               spin_lock(&mdsc->cap_delay_lock);
+               if (!list_empty(&ci->i_cap_delay_list)) {
+                       if (ci->i_ceph_flags & CEPH_I_FLUSH)
+                               goto no_change;
+                       list_del_init(&ci->i_cap_delay_list);
+               }
+               list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list);
+no_change:
+               spin_unlock(&mdsc->cap_delay_lock);
+       }
+}
+
+/*
+ * Queue an inode for immediate writeback.  Mark inode with I_FLUSH,
+ * indicating we should send a cap message to flush dirty metadata
+ * asap, and move to the front of the delayed cap list.
+ */
+static void __cap_delay_requeue_front(struct ceph_mds_client *mdsc,
+                                     struct ceph_inode_info *ci)
+{
+       dout("__cap_delay_requeue_front %p\n", &ci->vfs_inode);
+       spin_lock(&mdsc->cap_delay_lock);
+       ci->i_ceph_flags |= CEPH_I_FLUSH;
+       if (!list_empty(&ci->i_cap_delay_list))
+               list_del_init(&ci->i_cap_delay_list);
+       list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list);
+       spin_unlock(&mdsc->cap_delay_lock);
+}
+
+/*
+ * Cancel delayed work on cap.
+ *
+ * Caller must hold i_lock.
+ */
+static void __cap_delay_cancel(struct ceph_mds_client *mdsc,
+                              struct ceph_inode_info *ci)
+{
+       dout("__cap_delay_cancel %p\n", &ci->vfs_inode);
+       if (list_empty(&ci->i_cap_delay_list))
+               return;
+       spin_lock(&mdsc->cap_delay_lock);
+       list_del_init(&ci->i_cap_delay_list);
+       spin_unlock(&mdsc->cap_delay_lock);
+}
+
+/*
+ * Common issue checks for add_cap, handle_cap_grant.
+ */
+static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap,
+                             unsigned issued)
+{
+       unsigned had = __ceph_caps_issued(ci, NULL);
+
+       /*
+        * Each time we receive FILE_CACHE anew, we increment
+        * i_rdcache_gen.
+        */
+       if ((issued & CEPH_CAP_FILE_CACHE) &&
+           (had & CEPH_CAP_FILE_CACHE) == 0)
+               ci->i_rdcache_gen++;
+
+       /*
+        * if we are newly issued FILE_SHARED, clear I_COMPLETE; we
+        * don't know what happened to this directory while we didn't
+        * have the cap.
+        */
+       if ((issued & CEPH_CAP_FILE_SHARED) &&
+           (had & CEPH_CAP_FILE_SHARED) == 0) {
+               ci->i_shared_gen++;
+               if (S_ISDIR(ci->vfs_inode.i_mode)) {
+                       dout(" marking %p NOT complete\n", &ci->vfs_inode);
+                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+               }
+       }
+}
+
+/*
+ * Add a capability under the given MDS session.
+ *
+ * Caller should hold session snap_rwsem (read) and s_mutex.
+ *
+ * @fmode is the open file mode, if we are opening a file, otherwise
+ * it is < 0.  (This is so we can atomically add the cap and add an
+ * open file reference to it.)
+ */
+int ceph_add_cap(struct inode *inode,
+                struct ceph_mds_session *session, u64 cap_id,
+                int fmode, unsigned issued, unsigned wanted,
+                unsigned seq, unsigned mseq, u64 realmino, int flags,
+                struct ceph_cap_reservation *caps_reservation)
+{
+       struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_cap *new_cap = NULL;
+       struct ceph_cap *cap;
+       int mds = session->s_mds;
+       int actual_wanted;
+
+       dout("add_cap %p mds%d cap %llx %s seq %d\n", inode,
+            session->s_mds, cap_id, ceph_cap_string(issued), seq);
+
+       /*
+        * If we are opening the file, include file mode wanted bits
+        * in wanted.
+        */
+       if (fmode >= 0)
+               wanted |= ceph_caps_for_mode(fmode);
+
+retry:
+       spin_lock(&inode->i_lock);
+       cap = __get_cap_for_mds(ci, mds);
+       if (!cap) {
+               if (new_cap) {
+                       cap = new_cap;
+                       new_cap = NULL;
+               } else {
+                       spin_unlock(&inode->i_lock);
+                       new_cap = get_cap(caps_reservation);
+                       if (new_cap == NULL)
+                               return -ENOMEM;
+                       goto retry;
+               }
+
+               cap->issued = 0;
+               cap->implemented = 0;
+               cap->mds = mds;
+               cap->mds_wanted = 0;
+
+               cap->ci = ci;
+               __insert_cap_node(ci, cap);
+
+               /* clear out old exporting info?  (i.e. on cap import) */
+               if (ci->i_cap_exporting_mds == mds) {
+                       ci->i_cap_exporting_issued = 0;
+                       ci->i_cap_exporting_mseq = 0;
+                       ci->i_cap_exporting_mds = -1;
+               }
+
+               /* add to session cap list */
+               cap->session = session;
+               spin_lock(&session->s_cap_lock);
+               list_add_tail(&cap->session_caps, &session->s_caps);
+               session->s_nr_caps++;
+               spin_unlock(&session->s_cap_lock);
+       }
+
+       if (!ci->i_snap_realm) {
+               /*
+                * add this inode to the appropriate snap realm
+                */
+               struct ceph_snap_realm *realm = ceph_lookup_snap_realm(mdsc,
+                                                              realmino);
+               if (realm) {
+                       ceph_get_snap_realm(mdsc, realm);
+                       spin_lock(&realm->inodes_with_caps_lock);
+                       ci->i_snap_realm = realm;
+                       list_add(&ci->i_snap_realm_item,
+                                &realm->inodes_with_caps);
+                       spin_unlock(&realm->inodes_with_caps_lock);
+               } else {
+                       pr_err("ceph_add_cap: couldn't find snap realm %llx\n",
+                              realmino);
+               }
+       }
+
+       __check_cap_issue(ci, cap, issued);
+
+       /*
+        * If we are issued caps we don't want, or the mds' wanted
+        * value appears to be off, queue a check so we'll release
+        * later and/or update the mds wanted value.
+        */
+       actual_wanted = __ceph_caps_wanted(ci);
+       if ((wanted & ~actual_wanted) ||
+           (issued & ~actual_wanted & CEPH_CAP_ANY_WR)) {
+               dout(" issued %s, mds wanted %s, actual %s, queueing\n",
+                    ceph_cap_string(issued), ceph_cap_string(wanted),
+                    ceph_cap_string(actual_wanted));
+               __cap_delay_requeue(mdsc, ci);
+       }
+
+       if (flags & CEPH_CAP_FLAG_AUTH)
+               ci->i_auth_cap = cap;
+       else if (ci->i_auth_cap == cap)
+               ci->i_auth_cap = NULL;
+
+       dout("add_cap inode %p (%llx.%llx) cap %p %s now %s seq %d mds%d\n",
+            inode, ceph_vinop(inode), cap, ceph_cap_string(issued),
+            ceph_cap_string(issued|cap->issued), seq, mds);
+       cap->cap_id = cap_id;
+       cap->issued = issued;
+       cap->implemented |= issued;
+       cap->mds_wanted |= wanted;
+       cap->seq = seq;
+       cap->issue_seq = seq;
+       cap->mseq = mseq;
+       cap->cap_gen = session->s_cap_gen;
+
+       if (fmode >= 0)
+               __ceph_get_fmode(ci, fmode);
+       spin_unlock(&inode->i_lock);
+       wake_up(&ci->i_cap_wq);
+       return 0;
+}
+
+/*
+ * Return true if cap has not timed out and belongs to the current
+ * generation of the MDS session (i.e. has not gone 'stale' due to
+ * us losing touch with the mds).
+ */
+static int __cap_is_valid(struct ceph_cap *cap)
+{
+       unsigned long ttl;
+       u32 gen;
+
+       spin_lock(&cap->session->s_cap_lock);
+       gen = cap->session->s_cap_gen;
+       ttl = cap->session->s_cap_ttl;
+       spin_unlock(&cap->session->s_cap_lock);
+
+       if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) {
+               dout("__cap_is_valid %p cap %p issued %s "
+                    "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode,
+                    cap, ceph_cap_string(cap->issued), cap->cap_gen, gen);
+               return 0;
+       }
+
+       return 1;
+}
+
+/*
+ * Return set of valid cap bits issued to us.  Note that caps time
+ * out, and may be invalidated in bulk if the client session times out
+ * and session->s_cap_gen is bumped.
+ */
+int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented)
+{
+       int have = ci->i_snap_caps | ci->i_cap_exporting_issued;
+       struct ceph_cap *cap;
+       struct rb_node *p;
+
+       if (implemented)
+               *implemented = 0;
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               if (!__cap_is_valid(cap))
+                       continue;
+               dout("__ceph_caps_issued %p cap %p issued %s\n",
+                    &ci->vfs_inode, cap, ceph_cap_string(cap->issued));
+               have |= cap->issued;
+               if (implemented)
+                       *implemented |= cap->implemented;
+       }
+       return have;
+}
+
+/*
+ * Get cap bits issued by caps other than @ocap
+ */
+int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap)
+{
+       int have = ci->i_snap_caps;
+       struct ceph_cap *cap;
+       struct rb_node *p;
+
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               if (cap == ocap)
+                       continue;
+               if (!__cap_is_valid(cap))
+                       continue;
+               have |= cap->issued;
+       }
+       return have;
+}
+
+/*
+ * Move a cap to the end of the LRU (oldest caps at list head, newest
+ * at list tail).
+ */
+static void __touch_cap(struct ceph_cap *cap)
+{
+       struct ceph_mds_session *s = cap->session;
+
+       spin_lock(&s->s_cap_lock);
+       if (s->s_cap_iterator == NULL) {
+               dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap,
+                    s->s_mds);
+               list_move_tail(&cap->session_caps, &s->s_caps);
+       } else {
+               dout("__touch_cap %p cap %p mds%d NOP, iterating over caps\n",
+                    &cap->ci->vfs_inode, cap, s->s_mds);
+       }
+       spin_unlock(&s->s_cap_lock);
+}
+
+/*
+ * Check if we hold the given mask.  If so, move the cap(s) to the
+ * front of their respective LRUs.  (This is the preferred way for
+ * callers to check for caps they want.)
+ */
+int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch)
+{
+       struct ceph_cap *cap;
+       struct rb_node *p;
+       int have = ci->i_snap_caps;
+
+       if ((have & mask) == mask) {
+               dout("__ceph_caps_issued_mask %p snap issued %s"
+                    " (mask %s)\n", &ci->vfs_inode,
+                    ceph_cap_string(have),
+                    ceph_cap_string(mask));
+               return 1;
+       }
+
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               if (!__cap_is_valid(cap))
+                       continue;
+               if ((cap->issued & mask) == mask) {
+                       dout("__ceph_caps_issued_mask %p cap %p issued %s"
+                            " (mask %s)\n", &ci->vfs_inode, cap,
+                            ceph_cap_string(cap->issued),
+                            ceph_cap_string(mask));
+                       if (touch)
+                               __touch_cap(cap);
+                       return 1;
+               }
+
+               /* does a combination of caps satisfy mask? */
+               have |= cap->issued;
+               if ((have & mask) == mask) {
+                       dout("__ceph_caps_issued_mask %p combo issued %s"
+                            " (mask %s)\n", &ci->vfs_inode,
+                            ceph_cap_string(cap->issued),
+                            ceph_cap_string(mask));
+                       if (touch) {
+                               struct rb_node *q;
+
+                               /* touch this + preceeding caps */
+                               __touch_cap(cap);
+                               for (q = rb_first(&ci->i_caps); q != p;
+                                    q = rb_next(q)) {
+                                       cap = rb_entry(q, struct ceph_cap,
+                                                      ci_node);
+                                       if (!__cap_is_valid(cap))
+                                               continue;
+                                       __touch_cap(cap);
+                               }
+                       }
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+/*
+ * Return true if mask caps are currently being revoked by an MDS.
+ */
+int ceph_caps_revoking(struct ceph_inode_info *ci, int mask)
+{
+       struct inode *inode = &ci->vfs_inode;
+       struct ceph_cap *cap;
+       struct rb_node *p;
+       int ret = 0;
+
+       spin_lock(&inode->i_lock);
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               if (__cap_is_valid(cap) &&
+                   (cap->implemented & ~cap->issued & mask)) {
+                       ret = 1;
+                       break;
+               }
+       }
+       spin_unlock(&inode->i_lock);
+       dout("ceph_caps_revoking %p %s = %d\n", inode,
+            ceph_cap_string(mask), ret);
+       return ret;
+}
+
+int __ceph_caps_used(struct ceph_inode_info *ci)
+{
+       int used = 0;
+       if (ci->i_pin_ref)
+               used |= CEPH_CAP_PIN;
+       if (ci->i_rd_ref)
+               used |= CEPH_CAP_FILE_RD;
+       if (ci->i_rdcache_ref || ci->i_rdcache_gen)
+               used |= CEPH_CAP_FILE_CACHE;
+       if (ci->i_wr_ref)
+               used |= CEPH_CAP_FILE_WR;
+       if (ci->i_wrbuffer_ref)
+               used |= CEPH_CAP_FILE_BUFFER;
+       return used;
+}
+
+/*
+ * wanted, by virtue of open file modes
+ */
+int __ceph_caps_file_wanted(struct ceph_inode_info *ci)
+{
+       int want = 0;
+       int mode;
+       for (mode = 0; mode < 4; mode++)
+               if (ci->i_nr_by_mode[mode])
+                       want |= ceph_caps_for_mode(mode);
+       return want;
+}
+
+/*
+ * Return caps we have registered with the MDS(s) as 'wanted'.
+ */
+int __ceph_caps_mds_wanted(struct ceph_inode_info *ci)
+{
+       struct ceph_cap *cap;
+       struct rb_node *p;
+       int mds_wanted = 0;
+
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               if (!__cap_is_valid(cap))
+                       continue;
+               mds_wanted |= cap->mds_wanted;
+       }
+       return mds_wanted;
+}
+
+/*
+ * called under i_lock
+ */
+static int __ceph_is_any_caps(struct ceph_inode_info *ci)
+{
+       return !RB_EMPTY_ROOT(&ci->i_caps) || ci->i_cap_exporting_mds >= 0;
+}
+
+/*
+ * caller should hold i_lock.
+ * caller will not hold session s_mutex if called from destroy_inode.
+ */
+void __ceph_remove_cap(struct ceph_cap *cap)
+{
+       struct ceph_mds_session *session = cap->session;
+       struct ceph_inode_info *ci = cap->ci;
+       struct ceph_mds_client *mdsc = &ceph_client(ci->vfs_inode.i_sb)->mdsc;
+
+       dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode);
+
+       /* remove from inode list */
+       rb_erase(&cap->ci_node, &ci->i_caps);
+       cap->ci = NULL;
+       if (ci->i_auth_cap == cap)
+               ci->i_auth_cap = NULL;
+
+       /* remove from session list */
+       spin_lock(&session->s_cap_lock);
+       if (session->s_cap_iterator == cap) {
+               /* not yet, we are iterating over this very cap */
+               dout("__ceph_remove_cap  delaying %p removal from session %p\n",
+                    cap, cap->session);
+       } else {
+               list_del_init(&cap->session_caps);
+               session->s_nr_caps--;
+               cap->session = NULL;
+       }
+       spin_unlock(&session->s_cap_lock);
+
+       if (cap->session == NULL)
+               ceph_put_cap(cap);
+
+       if (!__ceph_is_any_caps(ci) && ci->i_snap_realm) {
+               struct ceph_snap_realm *realm = ci->i_snap_realm;
+               spin_lock(&realm->inodes_with_caps_lock);
+               list_del_init(&ci->i_snap_realm_item);
+               ci->i_snap_realm_counter++;
+               ci->i_snap_realm = NULL;
+               spin_unlock(&realm->inodes_with_caps_lock);
+               ceph_put_snap_realm(mdsc, realm);
+       }
+       if (!__ceph_is_any_real_caps(ci))
+               __cap_delay_cancel(mdsc, ci);
+}
+
+/*
+ * Build and send a cap message to the given MDS.
+ *
+ * Caller should be holding s_mutex.
+ */
+static int send_cap_msg(struct ceph_mds_session *session,
+                       u64 ino, u64 cid, int op,
+                       int caps, int wanted, int dirty,
+                       u32 seq, u64 flush_tid, u32 issue_seq, u32 mseq,
+                       u64 size, u64 max_size,
+                       struct timespec *mtime, struct timespec *atime,
+                       u64 time_warp_seq,
+                       uid_t uid, gid_t gid, mode_t mode,
+                       u64 xattr_version,
+                       struct ceph_buffer *xattrs_buf,
+                       u64 follows)
+{
+       struct ceph_mds_caps *fc;
+       struct ceph_msg *msg;
+
+       dout("send_cap_msg %s %llx %llx caps %s wanted %s dirty %s"
+            " seq %u/%u mseq %u follows %lld size %llu/%llu"
+            " xattr_ver %llu xattr_len %d\n", ceph_cap_op_name(op),
+            cid, ino, ceph_cap_string(caps), ceph_cap_string(wanted),
+            ceph_cap_string(dirty),
+            seq, issue_seq, mseq, follows, size, max_size,
+            xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);
+
+       msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), 0, 0, NULL);
+       if (IS_ERR(msg))
+               return PTR_ERR(msg);
+
+       msg->hdr.tid = cpu_to_le64(flush_tid);
+
+       fc = msg->front.iov_base;
+       memset(fc, 0, sizeof(*fc));
+
+       fc->cap_id = cpu_to_le64(cid);
+       fc->op = cpu_to_le32(op);
+       fc->seq = cpu_to_le32(seq);
+       fc->issue_seq = cpu_to_le32(issue_seq);
+       fc->migrate_seq = cpu_to_le32(mseq);
+       fc->caps = cpu_to_le32(caps);
+       fc->wanted = cpu_to_le32(wanted);
+       fc->dirty = cpu_to_le32(dirty);
+       fc->ino = cpu_to_le64(ino);
+       fc->snap_follows = cpu_to_le64(follows);
+
+       fc->size = cpu_to_le64(size);
+       fc->max_size = cpu_to_le64(max_size);
+       if (mtime)
+               ceph_encode_timespec(&fc->mtime, mtime);
+       if (atime)
+               ceph_encode_timespec(&fc->atime, atime);
+       fc->time_warp_seq = cpu_to_le32(time_warp_seq);
+
+       fc->uid = cpu_to_le32(uid);
+       fc->gid = cpu_to_le32(gid);
+       fc->mode = cpu_to_le32(mode);
+
+       fc->xattr_version = cpu_to_le64(xattr_version);
+       if (xattrs_buf) {
+               msg->middle = ceph_buffer_get(xattrs_buf);
+               fc->xattr_len = cpu_to_le32(xattrs_buf->vec.iov_len);
+               msg->hdr.middle_len = cpu_to_le32(xattrs_buf->vec.iov_len);
+       }
+
+       ceph_con_send(&session->s_con, msg);
+       return 0;
+}
+
+/*
+ * Queue cap releases when an inode is dropped from our cache.  Since
+ * inode is about to be destroyed, there is no need for i_lock.
+ */
+void ceph_queue_caps_release(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct rb_node *p;
+
+       p = rb_first(&ci->i_caps);
+       while (p) {
+               struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node);
+               struct ceph_mds_session *session = cap->session;
+               struct ceph_msg *msg;
+               struct ceph_mds_cap_release *head;
+               struct ceph_mds_cap_item *item;
+
+               spin_lock(&session->s_cap_lock);
+               BUG_ON(!session->s_num_cap_releases);
+               msg = list_first_entry(&session->s_cap_releases,
+                                      struct ceph_msg, list_head);
+
+               dout(" adding %p release to mds%d msg %p (%d left)\n",
+                    inode, session->s_mds, msg, session->s_num_cap_releases);
+
+               BUG_ON(msg->front.iov_len + sizeof(*item) > PAGE_CACHE_SIZE);
+               head = msg->front.iov_base;
+               head->num = cpu_to_le32(le32_to_cpu(head->num) + 1);
+               item = msg->front.iov_base + msg->front.iov_len;
+               item->ino = cpu_to_le64(ceph_ino(inode));
+               item->cap_id = cpu_to_le64(cap->cap_id);
+               item->migrate_seq = cpu_to_le32(cap->mseq);
+               item->seq = cpu_to_le32(cap->issue_seq);
+
+               session->s_num_cap_releases--;
+
+               msg->front.iov_len += sizeof(*item);
+               if (le32_to_cpu(head->num) == CEPH_CAPS_PER_RELEASE) {
+                       dout(" release msg %p full\n", msg);
+                       list_move_tail(&msg->list_head,
+                                      &session->s_cap_releases_done);
+               } else {
+                       dout(" release msg %p at %d/%d (%d)\n", msg,
+                            (int)le32_to_cpu(head->num),
+                            (int)CEPH_CAPS_PER_RELEASE,
+                            (int)msg->front.iov_len);
+               }
+               spin_unlock(&session->s_cap_lock);
+               p = rb_next(p);
+               __ceph_remove_cap(cap);
+       }
+}
+
+/*
+ * Send a cap msg on the given inode.  Update our caps state, then
+ * drop i_lock and send the message.
+ *
+ * Make note of max_size reported/requested from mds, revoked caps
+ * that have now been implemented.
+ *
+ * Make half-hearted attempt ot to invalidate page cache if we are
+ * dropping RDCACHE.  Note that this will leave behind locked pages
+ * that we'll then need to deal with elsewhere.
+ *
+ * Return non-zero if delayed release, or we experienced an error
+ * such that the caller should requeue + retry later.
+ *
+ * called with i_lock, then drops it.
+ * caller should hold snap_rwsem (read), s_mutex.
+ */
+static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
+                     int op, int used, int want, int retain, int flushing,
+                     unsigned *pflush_tid)
+       __releases(cap->ci->vfs_inode->i_lock)
+{
+       struct ceph_inode_info *ci = cap->ci;
+       struct inode *inode = &ci->vfs_inode;
+       u64 cap_id = cap->cap_id;
+       int held, revoking, dropping, keep;
+       u64 seq, issue_seq, mseq, time_warp_seq, follows;
+       u64 size, max_size;
+       struct timespec mtime, atime;
+       int wake = 0;
+       mode_t mode;
+       uid_t uid;
+       gid_t gid;
+       struct ceph_mds_session *session;
+       u64 xattr_version = 0;
+       int delayed = 0;
+       u64 flush_tid = 0;
+       int i;
+       int ret;
+
+       held = cap->issued | cap->implemented;
+       revoking = cap->implemented & ~cap->issued;
+       retain &= ~revoking;
+       dropping = cap->issued & ~retain;
+
+       dout("__send_cap %p cap %p session %p %s -> %s (revoking %s)\n",
+            inode, cap, cap->session,
+            ceph_cap_string(held), ceph_cap_string(held & retain),
+            ceph_cap_string(revoking));
+       BUG_ON((retain & CEPH_CAP_PIN) == 0);
+
+       session = cap->session;
+
+       /* don't release wanted unless we've waited a bit. */
+       if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 &&
+           time_before(jiffies, ci->i_hold_caps_min)) {
+               dout(" delaying issued %s -> %s, wanted %s -> %s on send\n",
+                    ceph_cap_string(cap->issued),
+                    ceph_cap_string(cap->issued & retain),
+                    ceph_cap_string(cap->mds_wanted),
+                    ceph_cap_string(want));
+               want |= cap->mds_wanted;
+               retain |= cap->issued;
+               delayed = 1;
+       }
+       ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH);
+
+       cap->issued &= retain;  /* drop bits we don't want */
+       if (cap->implemented & ~cap->issued) {
+               /*
+                * Wake up any waiters on wanted -> needed transition.
+                * This is due to the weird transition from buffered
+                * to sync IO... we need to flush dirty pages _before_
+                * allowing sync writes to avoid reordering.
+                */
+               wake = 1;
+       }
+       cap->implemented &= cap->issued | used;
+       cap->mds_wanted = want;
+
+       if (flushing) {
+               /*
+                * assign a tid for flush operations so we can avoid
+                * flush1 -> dirty1 -> flush2 -> flushack1 -> mark
+                * clean type races.  track latest tid for every bit
+                * so we can handle flush AxFw, flush Fw, and have the
+                * first ack clean Ax.
+                */
+               flush_tid = ++ci->i_cap_flush_last_tid;
+               if (pflush_tid)
+                       *pflush_tid = flush_tid;
+               dout(" cap_flush_tid %d\n", (int)flush_tid);
+               for (i = 0; i < CEPH_CAP_BITS; i++)
+                       if (flushing & (1 << i))
+                               ci->i_cap_flush_tid[i] = flush_tid;
+       }
+
+       keep = cap->implemented;
+       seq = cap->seq;
+       issue_seq = cap->issue_seq;
+       mseq = cap->mseq;
+       size = inode->i_size;
+       ci->i_reported_size = size;
+       max_size = ci->i_wanted_max_size;
+       ci->i_requested_max_size = max_size;
+       mtime = inode->i_mtime;
+       atime = inode->i_atime;
+       time_warp_seq = ci->i_time_warp_seq;
+       follows = ci->i_snap_realm->cached_context->seq;
+       uid = inode->i_uid;
+       gid = inode->i_gid;
+       mode = inode->i_mode;
+
+       if (dropping & CEPH_CAP_XATTR_EXCL) {
+               __ceph_build_xattrs_blob(ci);
+               xattr_version = ci->i_xattrs.version + 1;
+       }
+
+       spin_unlock(&inode->i_lock);
+
+       ret = send_cap_msg(session, ceph_vino(inode).ino, cap_id,
+               op, keep, want, flushing, seq, flush_tid, issue_seq, mseq,
+               size, max_size, &mtime, &atime, time_warp_seq,
+               uid, gid, mode,
+               xattr_version,
+               (flushing & CEPH_CAP_XATTR_EXCL) ? ci->i_xattrs.blob : NULL,
+               follows);
+       if (ret < 0) {
+               dout("error sending cap msg, must requeue %p\n", inode);
+               delayed = 1;
+       }
+
+       if (wake)
+               wake_up(&ci->i_cap_wq);
+
+       return delayed;
+}
+
+/*
+ * When a snapshot is taken, clients accumulate dirty metadata on
+ * inodes with capabilities in ceph_cap_snaps to describe the file
+ * state at the time the snapshot was taken.  This must be flushed
+ * asynchronously back to the MDS once sync writes complete and dirty
+ * data is written out.
+ *
+ * Called under i_lock.  Takes s_mutex as needed.
+ */
+void __ceph_flush_snaps(struct ceph_inode_info *ci,
+                       struct ceph_mds_session **psession)
+{
+       struct inode *inode = &ci->vfs_inode;
+       int mds;
+       struct ceph_cap_snap *capsnap;
+       u32 mseq;
+       struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
+       struct ceph_mds_session *session = NULL; /* if session != NULL, we hold
+                                                   session->s_mutex */
+       u64 next_follows = 0;  /* keep track of how far we've gotten through the
+                            i_cap_snaps list, and skip these entries next time
+                            around to avoid an infinite loop */
+
+       if (psession)
+               session = *psession;
+
+       dout("__flush_snaps %p\n", inode);
+retry:
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
+               /* avoid an infiniute loop after retry */
+               if (capsnap->follows < next_follows)
+                       continue;
+               /*
+                * we need to wait for sync writes to complete and for dirty
+                * pages to be written out.
+                */
+               if (capsnap->dirty_pages || capsnap->writing)
+                       continue;
+
+               /* pick mds, take s_mutex */
+               mds = __ceph_get_cap_mds(ci, &mseq);
+               if (session && session->s_mds != mds) {
+                       dout("oops, wrong session %p mutex\n", session);
+                       mutex_unlock(&session->s_mutex);
+                       ceph_put_mds_session(session);
+                       session = NULL;
+               }
+               if (!session) {
+                       spin_unlock(&inode->i_lock);
+                       mutex_lock(&mdsc->mutex);
+                       session = __ceph_lookup_mds_session(mdsc, mds);
+                       mutex_unlock(&mdsc->mutex);
+                       if (session) {
+                               dout("inverting session/ino locks on %p\n",
+                                    session);
+                               mutex_lock(&session->s_mutex);
+                       }
+                       /*
+                        * if session == NULL, we raced against a cap
+                        * deletion.  retry, and we'll get a better
+                        * @mds value next time.
+                        */
+                       spin_lock(&inode->i_lock);
+                       goto retry;
+               }
+
+               capsnap->flush_tid = ++ci->i_cap_flush_last_tid;
+               atomic_inc(&capsnap->nref);
+               if (!list_empty(&capsnap->flushing_item))
+                       list_del_init(&capsnap->flushing_item);
+               list_add_tail(&capsnap->flushing_item,
+                             &session->s_cap_snaps_flushing);
+               spin_unlock(&inode->i_lock);
+
+               dout("flush_snaps %p cap_snap %p follows %lld size %llu\n",
+                    inode, capsnap, next_follows, capsnap->size);
+               send_cap_msg(session, ceph_vino(inode).ino, 0,
+                            CEPH_CAP_OP_FLUSHSNAP, capsnap->issued, 0,
+                            capsnap->dirty, 0, capsnap->flush_tid, 0, mseq,
+                            capsnap->size, 0,
+                            &capsnap->mtime, &capsnap->atime,
+                            capsnap->time_warp_seq,
+                            capsnap->uid, capsnap->gid, capsnap->mode,
+                            0, NULL,
+                            capsnap->follows);
+
+               next_follows = capsnap->follows + 1;
+               ceph_put_cap_snap(capsnap);
+
+               spin_lock(&inode->i_lock);
+               goto retry;
+       }
+
+       /* we flushed them all; remove this inode from the queue */
+       spin_lock(&mdsc->snap_flush_lock);
+       list_del_init(&ci->i_snap_flush_item);
+       spin_unlock(&mdsc->snap_flush_lock);
+
+       if (psession)
+               *psession = session;
+       else if (session) {
+               mutex_unlock(&session->s_mutex);
+               ceph_put_mds_session(session);
+       }
+}
+
+static void ceph_flush_snaps(struct ceph_inode_info *ci)
+{
+       struct inode *inode = &ci->vfs_inode;
+
+       spin_lock(&inode->i_lock);
+       __ceph_flush_snaps(ci, NULL);
+       spin_unlock(&inode->i_lock);
+}
+
+/*
+ * Mark caps dirty.  If inode is newly dirty, add to the global dirty
+ * list.
+ */
+void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
+{
+       struct ceph_mds_client *mdsc = &ceph_client(ci->vfs_inode.i_sb)->mdsc;
+       struct inode *inode = &ci->vfs_inode;
+       int was = ci->i_dirty_caps;
+       int dirty = 0;
+
+       dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode,
+            ceph_cap_string(mask), ceph_cap_string(was),
+            ceph_cap_string(was | mask));
+       ci->i_dirty_caps |= mask;
+       if (was == 0) {
+               dout(" inode %p now dirty\n", &ci->vfs_inode);
+               BUG_ON(!list_empty(&ci->i_dirty_item));
+               spin_lock(&mdsc->cap_dirty_lock);
+               list_add(&ci->i_dirty_item, &mdsc->cap_dirty);
+               spin_unlock(&mdsc->cap_dirty_lock);
+               if (ci->i_flushing_caps == 0) {
+                       igrab(inode);
+                       dirty |= I_DIRTY_SYNC;
+               }
+       }
+       BUG_ON(list_empty(&ci->i_dirty_item));
+       if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
+           (mask & CEPH_CAP_FILE_BUFFER))
+               dirty |= I_DIRTY_DATASYNC;
+       if (dirty)
+               __mark_inode_dirty(inode, dirty);
+       __cap_delay_requeue(mdsc, ci);
+}
+
+/*
+ * Add dirty inode to the flushing list.  Assigned a seq number so we
+ * can wait for caps to flush without starving.
+ *
+ * Called under i_lock.
+ */
+static int __mark_caps_flushing(struct inode *inode,
+                                struct ceph_mds_session *session)
+{
+       struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int flushing;
+
+       BUG_ON(ci->i_dirty_caps == 0);
+       BUG_ON(list_empty(&ci->i_dirty_item));
+
+       flushing = ci->i_dirty_caps;
+       dout("__mark_caps_flushing flushing %s, flushing_caps %s -> %s\n",
+            ceph_cap_string(flushing),
+            ceph_cap_string(ci->i_flushing_caps),
+            ceph_cap_string(ci->i_flushing_caps | flushing));
+       ci->i_flushing_caps |= flushing;
+       ci->i_dirty_caps = 0;
+       dout(" inode %p now !dirty\n", inode);
+
+       spin_lock(&mdsc->cap_dirty_lock);
+       list_del_init(&ci->i_dirty_item);
+
+       ci->i_cap_flush_seq = ++mdsc->cap_flush_seq;
+       if (list_empty(&ci->i_flushing_item)) {
+               list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing);
+               mdsc->num_cap_flushing++;
+               dout(" inode %p now flushing seq %lld\n", inode,
+                    ci->i_cap_flush_seq);
+       } else {
+               list_move_tail(&ci->i_flushing_item, &session->s_cap_flushing);
+               dout(" inode %p now flushing (more) seq %lld\n", inode,
+                    ci->i_cap_flush_seq);
+       }
+       spin_unlock(&mdsc->cap_dirty_lock);
+
+       return flushing;
+}
+
+/*
+ * try to invalidate mapping pages without blocking.
+ */
+static int mapping_is_empty(struct address_space *mapping)
+{
+       struct page *page = find_get_page(mapping, 0);
+
+       if (!page)
+               return 1;
+
+       put_page(page);
+       return 0;
+}
+
+static int try_nonblocking_invalidate(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       u32 invalidating_gen = ci->i_rdcache_gen;
+
+       spin_unlock(&inode->i_lock);
+       invalidate_mapping_pages(&inode->i_data, 0, -1);
+       spin_lock(&inode->i_lock);
+
+       if (mapping_is_empty(&inode->i_data) &&
+           invalidating_gen == ci->i_rdcache_gen) {
+               /* success. */
+               dout("try_nonblocking_invalidate %p success\n", inode);
+               ci->i_rdcache_gen = 0;
+               ci->i_rdcache_revoking = 0;
+               return 0;
+       }
+       dout("try_nonblocking_invalidate %p failed\n", inode);
+       return -1;
+}
+
+/*
+ * Swiss army knife function to examine currently used and wanted
+ * versus held caps.  Release, flush, ack revoked caps to mds as
+ * appropriate.
+ *
+ *  CHECK_CAPS_NODELAY - caller is delayed work and we should not delay
+ *    cap release further.
+ *  CHECK_CAPS_AUTHONLY - we should only check the auth cap
+ *  CHECK_CAPS_FLUSH - we should flush any dirty caps immediately, without
+ *    further delay.
+ */
+void ceph_check_caps(struct ceph_inode_info *ci, int flags,
+                    struct ceph_mds_session *session)
+       __releases(session->s_mutex)
+{
+       struct ceph_client *client = ceph_inode_to_client(&ci->vfs_inode);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct inode *inode = &ci->vfs_inode;
+       struct ceph_cap *cap;
+       int file_wanted, used;
+       int took_snap_rwsem = 0;             /* true if mdsc->snap_rwsem held */
+       int issued, implemented, want, retain, revoking, flushing = 0;
+       int mds = -1;   /* keep track of how far we've gone through i_caps list
+                          to avoid an infinite loop on retry */
+       struct rb_node *p;
+       int tried_invalidate = 0;
+       int delayed = 0, sent = 0, force_requeue = 0, num;
+       int queue_invalidate = 0;
+       int is_delayed = flags & CHECK_CAPS_NODELAY;
+
+       /* if we are unmounting, flush any unused caps immediately. */
+       if (mdsc->stopping)
+               is_delayed = 1;
+
+       spin_lock(&inode->i_lock);
+
+       if (ci->i_ceph_flags & CEPH_I_FLUSH)
+               flags |= CHECK_CAPS_FLUSH;
+
+       /* flush snaps first time around only */
+       if (!list_empty(&ci->i_cap_snaps))
+               __ceph_flush_snaps(ci, &session);
+       goto retry_locked;
+retry:
+       spin_lock(&inode->i_lock);
+retry_locked:
+       file_wanted = __ceph_caps_file_wanted(ci);
+       used = __ceph_caps_used(ci);
+       want = file_wanted | used;
+       issued = __ceph_caps_issued(ci, &implemented);
+       revoking = implemented & ~issued;
+
+       retain = want | CEPH_CAP_PIN;
+       if (!mdsc->stopping && inode->i_nlink > 0) {
+               if (want) {
+                       retain |= CEPH_CAP_ANY;       /* be greedy */
+               } else {
+                       retain |= CEPH_CAP_ANY_SHARED;
+                       /*
+                        * keep RD only if we didn't have the file open RW,
+                        * because then the mds would revoke it anyway to
+                        * journal max_size=0.
+                        */
+                       if (ci->i_max_size == 0)
+                               retain |= CEPH_CAP_ANY_RD;
+               }
+       }
+
+       dout("check_caps %p file_want %s used %s dirty %s flushing %s"
+            " issued %s revoking %s retain %s %s%s%s\n", inode,
+            ceph_cap_string(file_wanted),
+            ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps),
+            ceph_cap_string(ci->i_flushing_caps),
+            ceph_cap_string(issued), ceph_cap_string(revoking),
+            ceph_cap_string(retain),
+            (flags & CHECK_CAPS_AUTHONLY) ? " AUTHONLY" : "",
+            (flags & CHECK_CAPS_NODELAY) ? " NODELAY" : "",
+            (flags & CHECK_CAPS_FLUSH) ? " FLUSH" : "");
+
+       /*
+        * If we no longer need to hold onto old our caps, and we may
+        * have cached pages, but don't want them, then try to invalidate.
+        * If we fail, it's because pages are locked.... try again later.
+        */
+       if ((!is_delayed || mdsc->stopping) &&
+           ci->i_wrbuffer_ref == 0 &&               /* no dirty pages... */
+           ci->i_rdcache_gen &&                     /* may have cached pages */
+           (file_wanted == 0 ||                     /* no open files */
+            (revoking & CEPH_CAP_FILE_CACHE)) &&     /*  or revoking cache */
+           !tried_invalidate) {
+               dout("check_caps trying to invalidate on %p\n", inode);
+               if (try_nonblocking_invalidate(inode) < 0) {
+                       if (revoking & CEPH_CAP_FILE_CACHE) {
+                               dout("check_caps queuing invalidate\n");
+                               queue_invalidate = 1;
+                               ci->i_rdcache_revoking = ci->i_rdcache_gen;
+                       } else {
+                               dout("check_caps failed to invalidate pages\n");
+                               /* we failed to invalidate pages.  check these
+                                  caps again later. */
+                               force_requeue = 1;
+                               __cap_set_timeouts(mdsc, ci);
+                       }
+               }
+               tried_invalidate = 1;
+               goto retry_locked;
+       }
+
+       num = 0;
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               cap = rb_entry(p, struct ceph_cap, ci_node);
+               num++;
+
+               /* avoid looping forever */
+               if (mds >= cap->mds ||
+                   ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap))
+                       continue;
+
+               /* NOTE: no side-effects allowed, until we take s_mutex */
+
+               revoking = cap->implemented & ~cap->issued;
+               if (revoking)
+                       dout(" mds%d revoking %s\n", cap->mds,
+                            ceph_cap_string(revoking));
+
+               if (cap == ci->i_auth_cap &&
+                   (cap->issued & CEPH_CAP_FILE_WR)) {
+                       /* request larger max_size from MDS? */
+                       if (ci->i_wanted_max_size > ci->i_max_size &&
+                           ci->i_wanted_max_size > ci->i_requested_max_size) {
+                               dout("requesting new max_size\n");
+                               goto ack;
+                       }
+
+                       /* approaching file_max? */
+                       if ((inode->i_size << 1) >= ci->i_max_size &&
+                           (ci->i_reported_size << 1) < ci->i_max_size) {
+                               dout("i_size approaching max_size\n");
+                               goto ack;
+                       }
+               }
+               /* flush anything dirty? */
+               if (cap == ci->i_auth_cap && (flags & CHECK_CAPS_FLUSH) &&
+                   ci->i_dirty_caps) {
+                       dout("flushing dirty caps\n");
+                       goto ack;
+               }
+
+               /* completed revocation? going down and there are no caps? */
+               if (revoking && (revoking & used) == 0) {
+                       dout("completed revocation of %s\n",
+                            ceph_cap_string(cap->implemented & ~cap->issued));
+                       goto ack;
+               }
+
+               /* want more caps from mds? */
+               if (want & ~(cap->mds_wanted | cap->issued))
+                       goto ack;
+
+               /* things we might delay */
+               if ((cap->issued & ~retain) == 0 &&
+                   cap->mds_wanted == want)
+                       continue;     /* nope, all good */
+
+               if (is_delayed)
+                       goto ack;
+
+               /* delay? */
+               if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 &&
+                   time_before(jiffies, ci->i_hold_caps_max)) {
+                       dout(" delaying issued %s -> %s, wanted %s -> %s\n",
+                            ceph_cap_string(cap->issued),
+                            ceph_cap_string(cap->issued & retain),
+                            ceph_cap_string(cap->mds_wanted),
+                            ceph_cap_string(want));
+                       delayed++;
+                       continue;
+               }
+
+ack:
+               if (ci->i_ceph_flags & CEPH_I_NOFLUSH) {
+                       dout(" skipping %p I_NOFLUSH set\n", inode);
+                       continue;
+               }
+
+               if (session && session != cap->session) {
+                       dout("oops, wrong session %p mutex\n", session);
+                       mutex_unlock(&session->s_mutex);
+                       session = NULL;
+               }
+               if (!session) {
+                       session = cap->session;
+                       if (mutex_trylock(&session->s_mutex) == 0) {
+                               dout("inverting session/ino locks on %p\n",
+                                    session);
+                               spin_unlock(&inode->i_lock);
+                               if (took_snap_rwsem) {
+                                       up_read(&mdsc->snap_rwsem);
+                                       took_snap_rwsem = 0;
+                               }
+                               mutex_lock(&session->s_mutex);
+                               goto retry;
+                       }
+               }
+               /* take snap_rwsem after session mutex */
+               if (!took_snap_rwsem) {
+                       if (down_read_trylock(&mdsc->snap_rwsem) == 0) {
+                               dout("inverting snap/in locks on %p\n",
+                                    inode);
+                               spin_unlock(&inode->i_lock);
+                               down_read(&mdsc->snap_rwsem);
+                               took_snap_rwsem = 1;
+                               goto retry;
+                       }
+                       took_snap_rwsem = 1;
+               }
+
+               if (cap == ci->i_auth_cap && ci->i_dirty_caps)
+                       flushing = __mark_caps_flushing(inode, session);
+
+               mds = cap->mds;  /* remember mds, so we don't repeat */
+               sent++;
+
+               /* __send_cap drops i_lock */
+               delayed += __send_cap(mdsc, cap, CEPH_CAP_OP_UPDATE, used, want,
+                                     retain, flushing, NULL);
+               goto retry; /* retake i_lock and restart our cap scan. */
+       }
+
+       /*
+        * Reschedule delayed caps release if we delayed anything,
+        * otherwise cancel.
+        */
+       if (delayed && is_delayed)
+               force_requeue = 1;   /* __send_cap delayed release; requeue */
+       if (!delayed && !is_delayed)
+               __cap_delay_cancel(mdsc, ci);
+       else if (!is_delayed || force_requeue)
+               __cap_delay_requeue(mdsc, ci);
+
+       spin_unlock(&inode->i_lock);
+
+       if (queue_invalidate)
+               ceph_queue_invalidate(inode);
+
+       if (session)
+               mutex_unlock(&session->s_mutex);
+       if (took_snap_rwsem)
+               up_read(&mdsc->snap_rwsem);
+}
+
+/*
+ * Try to flush dirty caps back to the auth mds.
+ */
+static int try_flush_caps(struct inode *inode, struct ceph_mds_session *session,
+                         unsigned *flush_tid)
+{
+       struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int unlock_session = session ? 0 : 1;
+       int flushing = 0;
+
+retry:
+       spin_lock(&inode->i_lock);
+       if (ci->i_ceph_flags & CEPH_I_NOFLUSH) {
+               dout("try_flush_caps skipping %p I_NOFLUSH set\n", inode);
+               goto out;
+       }
+       if (ci->i_dirty_caps && ci->i_auth_cap) {
+               struct ceph_cap *cap = ci->i_auth_cap;
+               int used = __ceph_caps_used(ci);
+               int want = __ceph_caps_wanted(ci);
+               int delayed;
+
+               if (!session) {
+                       spin_unlock(&inode->i_lock);
+                       session = cap->session;
+                       mutex_lock(&session->s_mutex);
+                       goto retry;
+               }
+               BUG_ON(session != cap->session);
+               if (cap->session->s_state < CEPH_MDS_SESSION_OPEN)
+                       goto out;
+
+               flushing = __mark_caps_flushing(inode, session);
+
+               /* __send_cap drops i_lock */
+               delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, used, want,
+                                    cap->issued | cap->implemented, flushing,
+                                    flush_tid);
+               if (!delayed)
+                       goto out_unlocked;
+
+               spin_lock(&inode->i_lock);
+               __cap_delay_requeue(mdsc, ci);
+       }
+out:
+       spin_unlock(&inode->i_lock);
+out_unlocked:
+       if (session && unlock_session)
+               mutex_unlock(&session->s_mutex);
+       return flushing;
+}
+
+/*
+ * Return true if we've flushed caps through the given flush_tid.
+ */
+static int caps_are_flushed(struct inode *inode, unsigned tid)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int dirty, i, ret = 1;
+
+       spin_lock(&inode->i_lock);
+       dirty = __ceph_caps_dirty(ci);
+       for (i = 0; i < CEPH_CAP_BITS; i++)
+               if ((ci->i_flushing_caps & (1 << i)) &&
+                   ci->i_cap_flush_tid[i] <= tid) {
+                       /* still flushing this bit */
+                       ret = 0;
+                       break;
+               }
+       spin_unlock(&inode->i_lock);
+       return ret;
+}
+
+/*
+ * Wait on any unsafe replies for the given inode.  First wait on the
+ * newest request, and make that the upper bound.  Then, if there are
+ * more requests, keep waiting on the oldest as long as it is still older
+ * than the original request.
+ */
+static void sync_write_wait(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct list_head *head = &ci->i_unsafe_writes;
+       struct ceph_osd_request *req;
+       u64 last_tid;
+
+       spin_lock(&ci->i_unsafe_lock);
+       if (list_empty(head))
+               goto out;
+
+       /* set upper bound as _last_ entry in chain */
+       req = list_entry(head->prev, struct ceph_osd_request,
+                        r_unsafe_item);
+       last_tid = req->r_tid;
+
+       do {
+               ceph_osdc_get_request(req);
+               spin_unlock(&ci->i_unsafe_lock);
+               dout("sync_write_wait on tid %llu (until %llu)\n",
+                    req->r_tid, last_tid);
+               wait_for_completion(&req->r_safe_completion);
+               spin_lock(&ci->i_unsafe_lock);
+               ceph_osdc_put_request(req);
+
+               /*
+                * from here on look at first entry in chain, since we
+                * only want to wait for anything older than last_tid
+                */
+               if (list_empty(head))
+                       break;
+               req = list_entry(head->next, struct ceph_osd_request,
+                                r_unsafe_item);
+       } while (req->r_tid < last_tid);
+out:
+       spin_unlock(&ci->i_unsafe_lock);
+}
+
+int ceph_fsync(struct file *file, struct dentry *dentry, int datasync)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       unsigned flush_tid;
+       int ret;
+       int dirty;
+
+       dout("fsync %p%s\n", inode, datasync ? " datasync" : "");
+       sync_write_wait(inode);
+
+       ret = filemap_write_and_wait(inode->i_mapping);
+       if (ret < 0)
+               return ret;
+
+       dirty = try_flush_caps(inode, NULL, &flush_tid);
+       dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
+
+       /*
+        * only wait on non-file metadata writeback (the mds
+        * can recover size and mtime, so we don't need to
+        * wait for that)
+        */
+       if (!datasync && (dirty & ~CEPH_CAP_ANY_FILE_WR)) {
+               dout("fsync waiting for flush_tid %u\n", flush_tid);
+               ret = wait_event_interruptible(ci->i_cap_wq,
+                                      caps_are_flushed(inode, flush_tid));
+       }
+
+       dout("fsync %p%s done\n", inode, datasync ? " datasync" : "");
+       return ret;
+}
+
+/*
+ * Flush any dirty caps back to the mds.  If we aren't asked to wait,
+ * queue inode for flush but don't do so immediately, because we can
+ * get by with fewer MDS messages if we wait for data writeback to
+ * complete first.
+ */
+int ceph_write_inode(struct inode *inode, struct writeback_control *wbc)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       unsigned flush_tid;
+       int err = 0;
+       int dirty;
+       int wait = wbc->sync_mode == WB_SYNC_ALL;
+
+       dout("write_inode %p wait=%d\n", inode, wait);
+       if (wait) {
+               dirty = try_flush_caps(inode, NULL, &flush_tid);
+               if (dirty)
+                       err = wait_event_interruptible(ci->i_cap_wq,
+                                      caps_are_flushed(inode, flush_tid));
+       } else {
+               struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc;
+
+               spin_lock(&inode->i_lock);
+               if (__ceph_caps_dirty(ci))
+                       __cap_delay_requeue_front(mdsc, ci);
+               spin_unlock(&inode->i_lock);
+       }
+       return err;
+}
+
+/*
+ * After a recovering MDS goes active, we need to resend any caps
+ * we were flushing.
+ *
+ * Caller holds session->s_mutex.
+ */
+static void kick_flushing_capsnaps(struct ceph_mds_client *mdsc,
+                                  struct ceph_mds_session *session)
+{
+       struct ceph_cap_snap *capsnap;
+
+       dout("kick_flushing_capsnaps mds%d\n", session->s_mds);
+       list_for_each_entry(capsnap, &session->s_cap_snaps_flushing,
+                           flushing_item) {
+               struct ceph_inode_info *ci = capsnap->ci;
+               struct inode *inode = &ci->vfs_inode;
+               struct ceph_cap *cap;
+
+               spin_lock(&inode->i_lock);
+               cap = ci->i_auth_cap;
+               if (cap && cap->session == session) {
+                       dout("kick_flushing_caps %p cap %p capsnap %p\n", inode,
+                            cap, capsnap);
+                       __ceph_flush_snaps(ci, &session);
+               } else {
+                       pr_err("%p auth cap %p not mds%d ???\n", inode,
+                              cap, session->s_mds);
+                       spin_unlock(&inode->i_lock);
+               }
+       }
+}
+
+void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc,
+                            struct ceph_mds_session *session)
+{
+       struct ceph_inode_info *ci;
+
+       kick_flushing_capsnaps(mdsc, session);
+
+       dout("kick_flushing_caps mds%d\n", session->s_mds);
+       list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) {
+               struct inode *inode = &ci->vfs_inode;
+               struct ceph_cap *cap;
+               int delayed = 0;
+
+               spin_lock(&inode->i_lock);
+               cap = ci->i_auth_cap;
+               if (cap && cap->session == session) {
+                       dout("kick_flushing_caps %p cap %p %s\n", inode,
+                            cap, ceph_cap_string(ci->i_flushing_caps));
+                       delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH,
+                                            __ceph_caps_used(ci),
+                                            __ceph_caps_wanted(ci),
+                                            cap->issued | cap->implemented,
+                                            ci->i_flushing_caps, NULL);
+                       if (delayed) {
+                               spin_lock(&inode->i_lock);
+                               __cap_delay_requeue(mdsc, ci);
+                               spin_unlock(&inode->i_lock);
+                       }
+               } else {
+                       pr_err("%p auth cap %p not mds%d ???\n", inode,
+                              cap, session->s_mds);
+                       spin_unlock(&inode->i_lock);
+               }
+       }
+}
+
+
+/*
+ * Take references to capabilities we hold, so that we don't release
+ * them to the MDS prematurely.
+ *
+ * Protected by i_lock.
+ */
+static void __take_cap_refs(struct ceph_inode_info *ci, int got)
+{
+       if (got & CEPH_CAP_PIN)
+               ci->i_pin_ref++;
+       if (got & CEPH_CAP_FILE_RD)
+               ci->i_rd_ref++;
+       if (got & CEPH_CAP_FILE_CACHE)
+               ci->i_rdcache_ref++;
+       if (got & CEPH_CAP_FILE_WR)
+               ci->i_wr_ref++;
+       if (got & CEPH_CAP_FILE_BUFFER) {
+               if (ci->i_wrbuffer_ref == 0)
+                       igrab(&ci->vfs_inode);
+               ci->i_wrbuffer_ref++;
+               dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n",
+                    &ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref);
+       }
+}
+
+/*
+ * Try to grab cap references.  Specify those refs we @want, and the
+ * minimal set we @need.  Also include the larger offset we are writing
+ * to (when applicable), and check against max_size here as well.
+ * Note that caller is responsible for ensuring max_size increases are
+ * requested from the MDS.
+ */
+static int try_get_cap_refs(struct ceph_inode_info *ci, int need, int want,
+                           int *got, loff_t endoff, int *check_max, int *err)
+{
+       struct inode *inode = &ci->vfs_inode;
+       int ret = 0;
+       int have, implemented;
+       int file_wanted;
+
+       dout("get_cap_refs %p need %s want %s\n", inode,
+            ceph_cap_string(need), ceph_cap_string(want));
+       spin_lock(&inode->i_lock);
+
+       /* make sure file is actually open */
+       file_wanted = __ceph_caps_file_wanted(ci);
+       if ((file_wanted & need) == 0) {
+               dout("try_get_cap_refs need %s file_wanted %s, EBADF\n",
+                    ceph_cap_string(need), ceph_cap_string(file_wanted));
+               *err = -EBADF;
+               ret = 1;
+               goto out;
+       }
+
+       if (need & CEPH_CAP_FILE_WR) {
+               if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) {
+                       dout("get_cap_refs %p endoff %llu > maxsize %llu\n",
+                            inode, endoff, ci->i_max_size);
+                       if (endoff > ci->i_wanted_max_size) {
+                               *check_max = 1;
+                               ret = 1;
+                       }
+                       goto out;
+               }
+               /*
+                * If a sync write is in progress, we must wait, so that we
+                * can get a final snapshot value for size+mtime.
+                */
+               if (__ceph_have_pending_cap_snap(ci)) {
+                       dout("get_cap_refs %p cap_snap_pending\n", inode);
+                       goto out;
+               }
+       }
+       have = __ceph_caps_issued(ci, &implemented);
+
+       /*
+        * disallow writes while a truncate is pending
+        */
+       if (ci->i_truncate_pending)
+               have &= ~CEPH_CAP_FILE_WR;
+
+       if ((have & need) == need) {
+               /*
+                * Look at (implemented & ~have & not) so that we keep waiting
+                * on transition from wanted -> needed caps.  This is needed
+                * for WRBUFFER|WR -> WR to avoid a new WR sync write from
+                * going before a prior buffered writeback happens.
+                */
+               int not = want & ~(have & need);
+               int revoking = implemented & ~have;
+               dout("get_cap_refs %p have %s but not %s (revoking %s)\n",
+                    inode, ceph_cap_string(have), ceph_cap_string(not),
+                    ceph_cap_string(revoking));
+               if ((revoking & not) == 0) {
+                       *got = need | (have & want);
+                       __take_cap_refs(ci, *got);
+                       ret = 1;
+               }
+       } else {
+               dout("get_cap_refs %p have %s needed %s\n", inode,
+                    ceph_cap_string(have), ceph_cap_string(need));
+       }
+out:
+       spin_unlock(&inode->i_lock);
+       dout("get_cap_refs %p ret %d got %s\n", inode,
+            ret, ceph_cap_string(*got));
+       return ret;
+}
+
+/*
+ * Check the offset we are writing up to against our current
+ * max_size.  If necessary, tell the MDS we want to write to
+ * a larger offset.
+ */
+static void check_max_size(struct inode *inode, loff_t endoff)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int check = 0;
+
+       /* do we need to explicitly request a larger max_size? */
+       spin_lock(&inode->i_lock);
+       if ((endoff >= ci->i_max_size ||
+            endoff > (inode->i_size << 1)) &&
+           endoff > ci->i_wanted_max_size) {
+               dout("write %p at large endoff %llu, req max_size\n",
+                    inode, endoff);
+               ci->i_wanted_max_size = endoff;
+               check = 1;
+       }
+       spin_unlock(&inode->i_lock);
+       if (check)
+               ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
+}
+
+/*
+ * Wait for caps, and take cap references.  If we can't get a WR cap
+ * due to a small max_size, make sure we check_max_size (and possibly
+ * ask the mds) so we don't get hung up indefinitely.
+ */
+int ceph_get_caps(struct ceph_inode_info *ci, int need, int want, int *got,
+                 loff_t endoff)
+{
+       int check_max, ret, err;
+
+retry:
+       if (endoff > 0)
+               check_max_size(&ci->vfs_inode, endoff);
+       check_max = 0;
+       err = 0;
+       ret = wait_event_interruptible(ci->i_cap_wq,
+                                      try_get_cap_refs(ci, need, want,
+                                                       got, endoff,
+                                                       &check_max, &err));
+       if (err)
+               ret = err;
+       if (check_max)
+               goto retry;
+       return ret;
+}
+
+/*
+ * Take cap refs.  Caller must already know we hold at least one ref
+ * on the caps in question or we don't know this is safe.
+ */
+void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps)
+{
+       spin_lock(&ci->vfs_inode.i_lock);
+       __take_cap_refs(ci, caps);
+       spin_unlock(&ci->vfs_inode.i_lock);
+}
+
+/*
+ * Release cap refs.
+ *
+ * If we released the last ref on any given cap, call ceph_check_caps
+ * to release (or schedule a release).
+ *
+ * If we are releasing a WR cap (from a sync write), finalize any affected
+ * cap_snap, and wake up any waiters.
+ */
+void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
+{
+       struct inode *inode = &ci->vfs_inode;
+       int last = 0, put = 0, flushsnaps = 0, wake = 0;
+       struct ceph_cap_snap *capsnap;
+
+       spin_lock(&inode->i_lock);
+       if (had & CEPH_CAP_PIN)
+               --ci->i_pin_ref;
+       if (had & CEPH_CAP_FILE_RD)
+               if (--ci->i_rd_ref == 0)
+                       last++;
+       if (had & CEPH_CAP_FILE_CACHE)
+               if (--ci->i_rdcache_ref == 0)
+                       last++;
+       if (had & CEPH_CAP_FILE_BUFFER) {
+               if (--ci->i_wrbuffer_ref == 0) {
+                       last++;
+                       put++;
+               }
+               dout("put_cap_refs %p wrbuffer %d -> %d (?)\n",
+                    inode, ci->i_wrbuffer_ref+1, ci->i_wrbuffer_ref);
+       }
+       if (had & CEPH_CAP_FILE_WR)
+               if (--ci->i_wr_ref == 0) {
+                       last++;
+                       if (!list_empty(&ci->i_cap_snaps)) {
+                               capsnap = list_first_entry(&ci->i_cap_snaps,
+                                                    struct ceph_cap_snap,
+                                                    ci_item);
+                               if (capsnap->writing) {
+                                       capsnap->writing = 0;
+                                       flushsnaps =
+                                               __ceph_finish_cap_snap(ci,
+                                                                      capsnap);
+                                       wake = 1;
+                               }
+                       }
+               }
+       spin_unlock(&inode->i_lock);
+
+       dout("put_cap_refs %p had %s %s\n", inode, ceph_cap_string(had),
+            last ? "last" : "");
+
+       if (last && !flushsnaps)
+               ceph_check_caps(ci, 0, NULL);
+       else if (flushsnaps)
+               ceph_flush_snaps(ci);
+       if (wake)
+               wake_up(&ci->i_cap_wq);
+       if (put)
+               iput(inode);
+}
+
+/*
+ * Release @nr WRBUFFER refs on dirty pages for the given @snapc snap
+ * context.  Adjust per-snap dirty page accounting as appropriate.
+ * Once all dirty data for a cap_snap is flushed, flush snapped file
+ * metadata back to the MDS.  If we dropped the last ref, call
+ * ceph_check_caps.
+ */
+void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
+                               struct ceph_snap_context *snapc)
+{
+       struct inode *inode = &ci->vfs_inode;
+       int last = 0;
+       int last_snap = 0;
+       int found = 0;
+       struct ceph_cap_snap *capsnap = NULL;
+
+       spin_lock(&inode->i_lock);
+       ci->i_wrbuffer_ref -= nr;
+       last = !ci->i_wrbuffer_ref;
+
+       if (ci->i_head_snapc == snapc) {
+               ci->i_wrbuffer_ref_head -= nr;
+               if (!ci->i_wrbuffer_ref_head) {
+                       ceph_put_snap_context(ci->i_head_snapc);
+                       ci->i_head_snapc = NULL;
+               }
+               dout("put_wrbuffer_cap_refs on %p head %d/%d -> %d/%d %s\n",
+                    inode,
+                    ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr,
+                    ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
+                    last ? " LAST" : "");
+       } else {
+               list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
+                       if (capsnap->context == snapc) {
+                               found = 1;
+                               capsnap->dirty_pages -= nr;
+                               last_snap = !capsnap->dirty_pages;
+                               break;
+                       }
+               }
+               BUG_ON(!found);
+               dout("put_wrbuffer_cap_refs on %p cap_snap %p "
+                    " snap %lld %d/%d -> %d/%d %s%s\n",
+                    inode, capsnap, capsnap->context->seq,
+                    ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr,
+                    ci->i_wrbuffer_ref, capsnap->dirty_pages,
+                    last ? " (wrbuffer last)" : "",
+                    last_snap ? " (capsnap last)" : "");
+       }
+
+       spin_unlock(&inode->i_lock);
+
+       if (last) {
+               ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
+               iput(inode);
+       } else if (last_snap) {
+               ceph_flush_snaps(ci);
+               wake_up(&ci->i_cap_wq);
+       }
+}
+
+/*
+ * Handle a cap GRANT message from the MDS.  (Note that a GRANT may
+ * actually be a revocation if it specifies a smaller cap set.)
+ *
+ * caller holds s_mutex and i_lock, we drop both.
+ *
+ * return value:
+ *  0 - ok
+ *  1 - check_caps on auth cap only (writeback)
+ *  2 - check_caps (ack revoke)
+ */
+static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
+                            struct ceph_mds_session *session,
+                            struct ceph_cap *cap,
+                            struct ceph_buffer *xattr_buf)
+       __releases(inode->i_lock)
+       __releases(session->s_mutex)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int mds = session->s_mds;
+       int seq = le32_to_cpu(grant->seq);
+       int newcaps = le32_to_cpu(grant->caps);
+       int issued, implemented, used, wanted, dirty;
+       u64 size = le64_to_cpu(grant->size);
+       u64 max_size = le64_to_cpu(grant->max_size);
+       struct timespec mtime, atime, ctime;
+       int check_caps = 0;
+       int wake = 0;
+       int writeback = 0;
+       int revoked_rdcache = 0;
+       int queue_invalidate = 0;
+
+       dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
+            inode, cap, mds, seq, ceph_cap_string(newcaps));
+       dout(" size %llu max_size %llu, i_size %llu\n", size, max_size,
+               inode->i_size);
+
+       /*
+        * If CACHE is being revoked, and we have no dirty buffers,
+        * try to invalidate (once).  (If there are dirty buffers, we
+        * will invalidate _after_ writeback.)
+        */
+       if (((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) &&
+           !ci->i_wrbuffer_ref) {
+               if (try_nonblocking_invalidate(inode) == 0) {
+                       revoked_rdcache = 1;
+               } else {
+                       /* there were locked pages.. invalidate later
+                          in a separate thread. */
+                       if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
+                               queue_invalidate = 1;
+                               ci->i_rdcache_revoking = ci->i_rdcache_gen;
+                       }
+               }
+       }
+
+       /* side effects now are allowed */
+
+       issued = __ceph_caps_issued(ci, &implemented);
+       issued |= implemented | __ceph_caps_dirty(ci);
+
+       cap->cap_gen = session->s_cap_gen;
+
+       __check_cap_issue(ci, cap, newcaps);
+
+       if ((issued & CEPH_CAP_AUTH_EXCL) == 0) {
+               inode->i_mode = le32_to_cpu(grant->mode);
+               inode->i_uid = le32_to_cpu(grant->uid);
+               inode->i_gid = le32_to_cpu(grant->gid);
+               dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode,
+                    inode->i_uid, inode->i_gid);
+       }
+
+       if ((issued & CEPH_CAP_LINK_EXCL) == 0)
+               inode->i_nlink = le32_to_cpu(grant->nlink);
+
+       if ((issued & CEPH_CAP_XATTR_EXCL) == 0 && grant->xattr_len) {
+               int len = le32_to_cpu(grant->xattr_len);
+               u64 version = le64_to_cpu(grant->xattr_version);
+
+               if (version > ci->i_xattrs.version) {
+                       dout(" got new xattrs v%llu on %p len %d\n",
+                            version, inode, len);
+                       if (ci->i_xattrs.blob)
+                               ceph_buffer_put(ci->i_xattrs.blob);
+                       ci->i_xattrs.blob = ceph_buffer_get(xattr_buf);
+                       ci->i_xattrs.version = version;
+               }
+       }
+
+       /* size/ctime/mtime/atime? */
+       ceph_fill_file_size(inode, issued,
+                           le32_to_cpu(grant->truncate_seq),
+                           le64_to_cpu(grant->truncate_size), size);
+       ceph_decode_timespec(&mtime, &grant->mtime);
+       ceph_decode_timespec(&atime, &grant->atime);
+       ceph_decode_timespec(&ctime, &grant->ctime);
+       ceph_fill_file_time(inode, issued,
+                           le32_to_cpu(grant->time_warp_seq), &ctime, &mtime,
+                           &atime);
+
+       /* max size increase? */
+       if (max_size != ci->i_max_size) {
+               dout("max_size %lld -> %llu\n", ci->i_max_size, max_size);
+               ci->i_max_size = max_size;
+               if (max_size >= ci->i_wanted_max_size) {
+                       ci->i_wanted_max_size = 0;  /* reset */
+                       ci->i_requested_max_size = 0;
+               }
+               wake = 1;
+       }
+
+       /* check cap bits */
+       wanted = __ceph_caps_wanted(ci);
+       used = __ceph_caps_used(ci);
+       dirty = __ceph_caps_dirty(ci);
+       dout(" my wanted = %s, used = %s, dirty %s\n",
+            ceph_cap_string(wanted),
+            ceph_cap_string(used),
+            ceph_cap_string(dirty));
+       if (wanted != le32_to_cpu(grant->wanted)) {
+               dout("mds wanted %s -> %s\n",
+                    ceph_cap_string(le32_to_cpu(grant->wanted)),
+                    ceph_cap_string(wanted));
+               grant->wanted = cpu_to_le32(wanted);
+       }
+
+       cap->seq = seq;
+
+       /* file layout may have changed */
+       ci->i_layout = grant->layout;
+
+       /* revocation, grant, or no-op? */
+       if (cap->issued & ~newcaps) {
+               dout("revocation: %s -> %s\n", ceph_cap_string(cap->issued),
+                    ceph_cap_string(newcaps));
+               if ((used & ~newcaps) & CEPH_CAP_FILE_BUFFER)
+                       writeback = 1; /* will delay ack */
+               else if (dirty & ~newcaps)
+                       check_caps = 1;  /* initiate writeback in check_caps */
+               else if (((used & ~newcaps) & CEPH_CAP_FILE_CACHE) == 0 ||
+                          revoked_rdcache)
+                       check_caps = 2;     /* send revoke ack in check_caps */
+               cap->issued = newcaps;
+               cap->implemented |= newcaps;
+       } else if (cap->issued == newcaps) {
+               dout("caps unchanged: %s -> %s\n",
+                    ceph_cap_string(cap->issued), ceph_cap_string(newcaps));
+       } else {
+               dout("grant: %s -> %s\n", ceph_cap_string(cap->issued),
+                    ceph_cap_string(newcaps));
+               cap->issued = newcaps;
+               cap->implemented |= newcaps; /* add bits only, to
+                                             * avoid stepping on a
+                                             * pending revocation */
+               wake = 1;
+       }
+       BUG_ON(cap->issued & ~cap->implemented);
+
+       spin_unlock(&inode->i_lock);
+       if (writeback)
+               /*
+                * queue inode for writeback: we can't actually call
+                * filemap_write_and_wait, etc. from message handler
+                * context.
+                */
+               ceph_queue_writeback(inode);
+       if (queue_invalidate)
+               ceph_queue_invalidate(inode);
+       if (wake)
+               wake_up(&ci->i_cap_wq);
+
+       if (check_caps == 1)
+               ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_AUTHONLY,
+                               session);
+       else if (check_caps == 2)
+               ceph_check_caps(ci, CHECK_CAPS_NODELAY, session);
+       else
+               mutex_unlock(&session->s_mutex);
+}
+
+/*
+ * Handle FLUSH_ACK from MDS, indicating that metadata we sent to the
+ * MDS has been safely committed.
+ */
+static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,
+                                struct ceph_mds_caps *m,
+                                struct ceph_mds_session *session,
+                                struct ceph_cap *cap)
+       __releases(inode->i_lock)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc;
+       unsigned seq = le32_to_cpu(m->seq);
+       int dirty = le32_to_cpu(m->dirty);
+       int cleaned = 0;
+       int drop = 0;
+       int i;
+
+       for (i = 0; i < CEPH_CAP_BITS; i++)
+               if ((dirty & (1 << i)) &&
+                   flush_tid == ci->i_cap_flush_tid[i])
+                       cleaned |= 1 << i;
+
+       dout("handle_cap_flush_ack inode %p mds%d seq %d on %s cleaned %s,"
+            " flushing %s -> %s\n",
+            inode, session->s_mds, seq, ceph_cap_string(dirty),
+            ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps),
+            ceph_cap_string(ci->i_flushing_caps & ~cleaned));
+
+       if (ci->i_flushing_caps == (ci->i_flushing_caps & ~cleaned))
+               goto out;
+
+       ci->i_flushing_caps &= ~cleaned;
+
+       spin_lock(&mdsc->cap_dirty_lock);
+       if (ci->i_flushing_caps == 0) {
+               list_del_init(&ci->i_flushing_item);
+               if (!list_empty(&session->s_cap_flushing))
+                       dout(" mds%d still flushing cap on %p\n",
+                            session->s_mds,
+                            &list_entry(session->s_cap_flushing.next,
+                                        struct ceph_inode_info,
+                                        i_flushing_item)->vfs_inode);
+               mdsc->num_cap_flushing--;
+               wake_up(&mdsc->cap_flushing_wq);
+               dout(" inode %p now !flushing\n", inode);
+
+               if (ci->i_dirty_caps == 0) {
+                       dout(" inode %p now clean\n", inode);
+                       BUG_ON(!list_empty(&ci->i_dirty_item));
+                       drop = 1;
+               } else {
+                       BUG_ON(list_empty(&ci->i_dirty_item));
+               }
+       }
+       spin_unlock(&mdsc->cap_dirty_lock);
+       wake_up(&ci->i_cap_wq);
+
+out:
+       spin_unlock(&inode->i_lock);
+       if (drop)
+               iput(inode);
+}
+
+/*
+ * Handle FLUSHSNAP_ACK.  MDS has flushed snap data to disk and we can
+ * throw away our cap_snap.
+ *
+ * Caller hold s_mutex.
+ */
+static void handle_cap_flushsnap_ack(struct inode *inode, u64 flush_tid,
+                                    struct ceph_mds_caps *m,
+                                    struct ceph_mds_session *session)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       u64 follows = le64_to_cpu(m->snap_follows);
+       struct ceph_cap_snap *capsnap;
+       int drop = 0;
+
+       dout("handle_cap_flushsnap_ack inode %p ci %p mds%d follows %lld\n",
+            inode, ci, session->s_mds, follows);
+
+       spin_lock(&inode->i_lock);
+       list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
+               if (capsnap->follows == follows) {
+                       if (capsnap->flush_tid != flush_tid) {
+                               dout(" cap_snap %p follows %lld tid %lld !="
+                                    " %lld\n", capsnap, follows,
+                                    flush_tid, capsnap->flush_tid);
+                               break;
+                       }
+                       WARN_ON(capsnap->dirty_pages || capsnap->writing);
+                       dout(" removing cap_snap %p follows %lld\n",
+                            capsnap, follows);
+                       ceph_put_snap_context(capsnap->context);
+                       list_del(&capsnap->ci_item);
+                       list_del(&capsnap->flushing_item);
+                       ceph_put_cap_snap(capsnap);
+                       drop = 1;
+                       break;
+               } else {
+                       dout(" skipping cap_snap %p follows %lld\n",
+                            capsnap, capsnap->follows);
+               }
+       }
+       spin_unlock(&inode->i_lock);
+       if (drop)
+               iput(inode);
+}
+
+/*
+ * Handle TRUNC from MDS, indicating file truncation.
+ *
+ * caller hold s_mutex.
+ */
+static void handle_cap_trunc(struct inode *inode,
+                            struct ceph_mds_caps *trunc,
+                            struct ceph_mds_session *session)
+       __releases(inode->i_lock)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int mds = session->s_mds;
+       int seq = le32_to_cpu(trunc->seq);
+       u32 truncate_seq = le32_to_cpu(trunc->truncate_seq);
+       u64 truncate_size = le64_to_cpu(trunc->truncate_size);
+       u64 size = le64_to_cpu(trunc->size);
+       int implemented = 0;
+       int dirty = __ceph_caps_dirty(ci);
+       int issued = __ceph_caps_issued(ceph_inode(inode), &implemented);
+       int queue_trunc = 0;
+
+       issued |= implemented | dirty;
+
+       dout("handle_cap_trunc inode %p mds%d seq %d to %lld seq %d\n",
+            inode, mds, seq, truncate_size, truncate_seq);
+       queue_trunc = ceph_fill_file_size(inode, issued,
+                                         truncate_seq, truncate_size, size);
+       spin_unlock(&inode->i_lock);
+
+       if (queue_trunc)
+               ceph_queue_vmtruncate(inode);
+}
+
+/*
+ * Handle EXPORT from MDS.  Cap is being migrated _from_ this mds to a
+ * different one.  If we are the most recent migration we've seen (as
+ * indicated by mseq), make note of the migrating cap bits for the
+ * duration (until we see the corresponding IMPORT).
+ *
+ * caller holds s_mutex
+ */
+static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
+                             struct ceph_mds_session *session)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int mds = session->s_mds;
+       unsigned mseq = le32_to_cpu(ex->migrate_seq);
+       struct ceph_cap *cap = NULL, *t;
+       struct rb_node *p;
+       int remember = 1;
+
+       dout("handle_cap_export inode %p ci %p mds%d mseq %d\n",
+            inode, ci, mds, mseq);
+
+       spin_lock(&inode->i_lock);
+
+       /* make sure we haven't seen a higher mseq */
+       for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) {
+               t = rb_entry(p, struct ceph_cap, ci_node);
+               if (ceph_seq_cmp(t->mseq, mseq) > 0) {
+                       dout(" higher mseq on cap from mds%d\n",
+                            t->session->s_mds);
+                       remember = 0;
+               }
+               if (t->session->s_mds == mds)
+                       cap = t;
+       }
+
+       if (cap) {
+               if (remember) {
+                       /* make note */
+                       ci->i_cap_exporting_mds = mds;
+                       ci->i_cap_exporting_mseq = mseq;
+                       ci->i_cap_exporting_issued = cap->issued;
+               }
+               __ceph_remove_cap(cap);
+       }
+       /* else, we already released it */
+
+       spin_unlock(&inode->i_lock);
+}
+
+/*
+ * Handle cap IMPORT.  If there are temp bits from an older EXPORT,
+ * clean them up.
+ *
+ * caller holds s_mutex.
+ */
+static void handle_cap_import(struct ceph_mds_client *mdsc,
+                             struct inode *inode, struct ceph_mds_caps *im,
+                             struct ceph_mds_session *session,
+                             void *snaptrace, int snaptrace_len)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int mds = session->s_mds;
+       unsigned issued = le32_to_cpu(im->caps);
+       unsigned wanted = le32_to_cpu(im->wanted);
+       unsigned seq = le32_to_cpu(im->seq);
+       unsigned mseq = le32_to_cpu(im->migrate_seq);
+       u64 realmino = le64_to_cpu(im->realm);
+       u64 cap_id = le64_to_cpu(im->cap_id);
+
+       if (ci->i_cap_exporting_mds >= 0 &&
+           ceph_seq_cmp(ci->i_cap_exporting_mseq, mseq) < 0) {
+               dout("handle_cap_import inode %p ci %p mds%d mseq %d"
+                    " - cleared exporting from mds%d\n",
+                    inode, ci, mds, mseq,
+                    ci->i_cap_exporting_mds);
+               ci->i_cap_exporting_issued = 0;
+               ci->i_cap_exporting_mseq = 0;
+               ci->i_cap_exporting_mds = -1;
+       } else {
+               dout("handle_cap_import inode %p ci %p mds%d mseq %d\n",
+                    inode, ci, mds, mseq);
+       }
+
+       down_write(&mdsc->snap_rwsem);
+       ceph_update_snap_trace(mdsc, snaptrace, snaptrace+snaptrace_len,
+                              false);
+       downgrade_write(&mdsc->snap_rwsem);
+       ceph_add_cap(inode, session, cap_id, -1,
+                    issued, wanted, seq, mseq, realmino, CEPH_CAP_FLAG_AUTH,
+                    NULL /* no caps context */);
+       try_flush_caps(inode, session, NULL);
+       up_read(&mdsc->snap_rwsem);
+}
+
+/*
+ * Handle a caps message from the MDS.
+ *
+ * Identify the appropriate session, inode, and call the right handler
+ * based on the cap op.
+ */
+void ceph_handle_caps(struct ceph_mds_session *session,
+                     struct ceph_msg *msg)
+{
+       struct ceph_mds_client *mdsc = session->s_mdsc;
+       struct super_block *sb = mdsc->client->sb;
+       struct inode *inode;
+       struct ceph_cap *cap;
+       struct ceph_mds_caps *h;
+       int mds = session->s_mds;
+       int op;
+       u32 seq;
+       struct ceph_vino vino;
+       u64 cap_id;
+       u64 size, max_size;
+       u64 tid;
+       void *snaptrace;
+
+       dout("handle_caps from mds%d\n", mds);
+
+       /* decode */
+       tid = le64_to_cpu(msg->hdr.tid);
+       if (msg->front.iov_len < sizeof(*h))
+               goto bad;
+       h = msg->front.iov_base;
+       snaptrace = h + 1;
+       op = le32_to_cpu(h->op);
+       vino.ino = le64_to_cpu(h->ino);
+       vino.snap = CEPH_NOSNAP;
+       cap_id = le64_to_cpu(h->cap_id);
+       seq = le32_to_cpu(h->seq);
+       size = le64_to_cpu(h->size);
+       max_size = le64_to_cpu(h->max_size);
+
+       mutex_lock(&session->s_mutex);
+       session->s_seq++;
+       dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq,
+            (unsigned)seq);
+
+       /* lookup ino */
+       inode = ceph_find_inode(sb, vino);
+       dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
+            vino.snap, inode);
+       if (!inode) {
+               dout(" i don't have ino %llx\n", vino.ino);
+               goto done;
+       }
+
+       /* these will work even if we don't have a cap yet */
+       switch (op) {
+       case CEPH_CAP_OP_FLUSHSNAP_ACK:
+               handle_cap_flushsnap_ack(inode, tid, h, session);
+               goto done;
+
+       case CEPH_CAP_OP_EXPORT:
+               handle_cap_export(inode, h, session);
+               goto done;
+
+       case CEPH_CAP_OP_IMPORT:
+               handle_cap_import(mdsc, inode, h, session,
+                                 snaptrace, le32_to_cpu(h->snap_trace_len));
+               ceph_check_caps(ceph_inode(inode), CHECK_CAPS_NODELAY,
+                               session);
+               goto done_unlocked;
+       }
+
+       /* the rest require a cap */
+       spin_lock(&inode->i_lock);
+       cap = __get_cap_for_mds(ceph_inode(inode), mds);
+       if (!cap) {
+               dout("no cap on %p ino %llx.%llx from mds%d, releasing\n",
+                    inode, ceph_ino(inode), ceph_snap(inode), mds);
+               spin_unlock(&inode->i_lock);
+               goto done;
+       }
+
+       /* note that each of these drops i_lock for us */
+       switch (op) {
+       case CEPH_CAP_OP_REVOKE:
+       case CEPH_CAP_OP_GRANT:
+               handle_cap_grant(inode, h, session, cap, msg->middle);
+               goto done_unlocked;
+
+       case CEPH_CAP_OP_FLUSH_ACK:
+               handle_cap_flush_ack(inode, tid, h, session, cap);
+               break;
+
+       case CEPH_CAP_OP_TRUNC:
+               handle_cap_trunc(inode, h, session);
+               break;
+
+       default:
+               spin_unlock(&inode->i_lock);
+               pr_err("ceph_handle_caps: unknown cap op %d %s\n", op,
+                      ceph_cap_op_name(op));
+       }
+
+done:
+       mutex_unlock(&session->s_mutex);
+done_unlocked:
+       if (inode)
+               iput(inode);
+       return;
+
+bad:
+       pr_err("ceph_handle_caps: corrupt message\n");
+       ceph_msg_dump(msg);
+       return;
+}
+
+/*
+ * Delayed work handler to process end of delayed cap release LRU list.
+ */
+void ceph_check_delayed_caps(struct ceph_mds_client *mdsc)
+{
+       struct ceph_inode_info *ci;
+       int flags = CHECK_CAPS_NODELAY;
+
+       dout("check_delayed_caps\n");
+       while (1) {
+               spin_lock(&mdsc->cap_delay_lock);
+               if (list_empty(&mdsc->cap_delay_list))
+                       break;
+               ci = list_first_entry(&mdsc->cap_delay_list,
+                                     struct ceph_inode_info,
+                                     i_cap_delay_list);
+               if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 &&
+                   time_before(jiffies, ci->i_hold_caps_max))
+                       break;
+               list_del_init(&ci->i_cap_delay_list);
+               spin_unlock(&mdsc->cap_delay_lock);
+               dout("check_delayed_caps on %p\n", &ci->vfs_inode);
+               ceph_check_caps(ci, flags, NULL);
+       }
+       spin_unlock(&mdsc->cap_delay_lock);
+}
+
+/*
+ * Flush all dirty caps to the mds
+ */
+void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)
+{
+       struct ceph_inode_info *ci, *nci = NULL;
+       struct inode *inode, *ninode = NULL;
+       struct list_head *p, *n;
+
+       dout("flush_dirty_caps\n");
+       spin_lock(&mdsc->cap_dirty_lock);
+       list_for_each_safe(p, n, &mdsc->cap_dirty) {
+               if (nci) {
+                       ci = nci;
+                       inode = ninode;
+                       ci->i_ceph_flags &= ~CEPH_I_NOFLUSH;
+                       dout("flush_dirty_caps inode %p (was next inode)\n",
+                            inode);
+               } else {
+                       ci = list_entry(p, struct ceph_inode_info,
+                                       i_dirty_item);
+                       inode = igrab(&ci->vfs_inode);
+                       BUG_ON(!inode);
+                       dout("flush_dirty_caps inode %p\n", inode);
+               }
+               if (n != &mdsc->cap_dirty) {
+                       nci = list_entry(n, struct ceph_inode_info,
+                                        i_dirty_item);
+                       ninode = igrab(&nci->vfs_inode);
+                       BUG_ON(!ninode);
+                       nci->i_ceph_flags |= CEPH_I_NOFLUSH;
+                       dout("flush_dirty_caps next inode %p, noflush\n",
+                            ninode);
+               } else {
+                       nci = NULL;
+                       ninode = NULL;
+               }
+               spin_unlock(&mdsc->cap_dirty_lock);
+               if (inode) {
+                       ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_FLUSH,
+                                       NULL);
+                       iput(inode);
+               }
+               spin_lock(&mdsc->cap_dirty_lock);
+       }
+       spin_unlock(&mdsc->cap_dirty_lock);
+}
+
+/*
+ * Drop open file reference.  If we were the last open file,
+ * we may need to release capabilities to the MDS (or schedule
+ * their delayed release).
+ */
+void ceph_put_fmode(struct ceph_inode_info *ci, int fmode)
+{
+       struct inode *inode = &ci->vfs_inode;
+       int last = 0;
+
+       spin_lock(&inode->i_lock);
+       dout("put_fmode %p fmode %d %d -> %d\n", inode, fmode,
+            ci->i_nr_by_mode[fmode], ci->i_nr_by_mode[fmode]-1);
+       BUG_ON(ci->i_nr_by_mode[fmode] == 0);
+       if (--ci->i_nr_by_mode[fmode] == 0)
+               last++;
+       spin_unlock(&inode->i_lock);
+
+       if (last && ci->i_vino.snap == CEPH_NOSNAP)
+               ceph_check_caps(ci, 0, NULL);
+}
+
+/*
+ * Helpers for embedding cap and dentry lease releases into mds
+ * requests.
+ *
+ * @force is used by dentry_release (below) to force inclusion of a
+ * record for the directory inode, even when there aren't any caps to
+ * drop.
+ */
+int ceph_encode_inode_release(void **p, struct inode *inode,
+                             int mds, int drop, int unless, int force)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_cap *cap;
+       struct ceph_mds_request_release *rel = *p;
+       int ret = 0;
+       int used = 0;
+
+       spin_lock(&inode->i_lock);
+       used = __ceph_caps_used(ci);
+
+       dout("encode_inode_release %p mds%d used %s drop %s unless %s\n", inode,
+            mds, ceph_cap_string(used), ceph_cap_string(drop),
+            ceph_cap_string(unless));
+
+       /* only drop unused caps */
+       drop &= ~used;
+
+       cap = __get_cap_for_mds(ci, mds);
+       if (cap && __cap_is_valid(cap)) {
+               if (force ||
+                   ((cap->issued & drop) &&
+                    (cap->issued & unless) == 0)) {
+                       if ((cap->issued & drop) &&
+                           (cap->issued & unless) == 0) {
+                               dout("encode_inode_release %p cap %p %s -> "
+                                    "%s\n", inode, cap,
+                                    ceph_cap_string(cap->issued),
+                                    ceph_cap_string(cap->issued & ~drop));
+                               cap->issued &= ~drop;
+                               cap->implemented &= ~drop;
+                               if (ci->i_ceph_flags & CEPH_I_NODELAY) {
+                                       int wanted = __ceph_caps_wanted(ci);
+                                       dout("  wanted %s -> %s (act %s)\n",
+                                            ceph_cap_string(cap->mds_wanted),
+                                            ceph_cap_string(cap->mds_wanted &
+                                                            ~wanted),
+                                            ceph_cap_string(wanted));
+                                       cap->mds_wanted &= wanted;
+                               }
+                       } else {
+                               dout("encode_inode_release %p cap %p %s"
+                                    " (force)\n", inode, cap,
+                                    ceph_cap_string(cap->issued));
+                       }
+
+                       rel->ino = cpu_to_le64(ceph_ino(inode));
+                       rel->cap_id = cpu_to_le64(cap->cap_id);
+                       rel->seq = cpu_to_le32(cap->seq);
+                       rel->issue_seq = cpu_to_le32(cap->issue_seq),
+                       rel->mseq = cpu_to_le32(cap->mseq);
+                       rel->caps = cpu_to_le32(cap->issued);
+                       rel->wanted = cpu_to_le32(cap->mds_wanted);
+                       rel->dname_len = 0;
+                       rel->dname_seq = 0;
+                       *p += sizeof(*rel);
+                       ret = 1;
+               } else {
+                       dout("encode_inode_release %p cap %p %s\n",
+                            inode, cap, ceph_cap_string(cap->issued));
+               }
+       }
+       spin_unlock(&inode->i_lock);
+       return ret;
+}
+
+int ceph_encode_dentry_release(void **p, struct dentry *dentry,
+                              int mds, int drop, int unless)
+{
+       struct inode *dir = dentry->d_parent->d_inode;
+       struct ceph_mds_request_release *rel = *p;
+       struct ceph_dentry_info *di = ceph_dentry(dentry);
+       int force = 0;
+       int ret;
+
+       /*
+        * force an record for the directory caps if we have a dentry lease.
+        * this is racy (can't take i_lock and d_lock together), but it
+        * doesn't have to be perfect; the mds will revoke anything we don't
+        * release.
+        */
+       spin_lock(&dentry->d_lock);
+       if (di->lease_session && di->lease_session->s_mds == mds)
+               force = 1;
+       spin_unlock(&dentry->d_lock);
+
+       ret = ceph_encode_inode_release(p, dir, mds, drop, unless, force);
+
+       spin_lock(&dentry->d_lock);
+       if (ret && di->lease_session && di->lease_session->s_mds == mds) {
+               dout("encode_dentry_release %p mds%d seq %d\n",
+                    dentry, mds, (int)di->lease_seq);
+               rel->dname_len = cpu_to_le32(dentry->d_name.len);
+               memcpy(*p, dentry->d_name.name, dentry->d_name.len);
+               *p += dentry->d_name.len;
+               rel->dname_seq = cpu_to_le32(di->lease_seq);
+       }
+       spin_unlock(&dentry->d_lock);
+       return ret;
+}
diff --git a/fs/ceph/ceph_debug.h b/fs/ceph/ceph_debug.h
new file mode 100644 (file)
index 0000000..1818c23
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _FS_CEPH_DEBUG_H
+#define _FS_CEPH_DEBUG_H
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#ifdef CONFIG_CEPH_FS_PRETTYDEBUG
+
+/*
+ * wrap pr_debug to include a filename:lineno prefix on each line.
+ * this incurs some overhead (kernel size and execution time) due to
+ * the extra function call at each call site.
+ */
+
+# if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
+extern const char *ceph_file_part(const char *s, int len);
+#  define dout(fmt, ...)                                               \
+       pr_debug(" %12.12s:%-4d : " fmt,                                \
+                ceph_file_part(__FILE__, sizeof(__FILE__)),            \
+                __LINE__, ##__VA_ARGS__)
+# else
+/* faux printk call just to see any compiler warnings. */
+#  define dout(fmt, ...)       do {                            \
+               if (0)                                          \
+                       printk(KERN_DEBUG fmt, ##__VA_ARGS__);  \
+       } while (0)
+# endif
+
+#else
+
+/*
+ * or, just wrap pr_debug
+ */
+# define dout(fmt, ...)        pr_debug(" " fmt, ##__VA_ARGS__)
+
+#endif
+
+#endif
diff --git a/fs/ceph/ceph_frag.c b/fs/ceph/ceph_frag.c
new file mode 100644 (file)
index 0000000..ab6cf35
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Ceph 'frag' type
+ */
+#include "types.h"
+
+int ceph_frag_compare(__u32 a, __u32 b)
+{
+       unsigned va = ceph_frag_value(a);
+       unsigned vb = ceph_frag_value(b);
+       if (va < vb)
+               return -1;
+       if (va > vb)
+               return 1;
+       va = ceph_frag_bits(a);
+       vb = ceph_frag_bits(b);
+       if (va < vb)
+               return -1;
+       if (va > vb)
+               return 1;
+       return 0;
+}
diff --git a/fs/ceph/ceph_frag.h b/fs/ceph/ceph_frag.h
new file mode 100644 (file)
index 0000000..793f50c
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef _FS_CEPH_FRAG_H
+#define _FS_CEPH_FRAG_H
+
+/*
+ * "Frags" are a way to describe a subset of a 32-bit number space,
+ * using a mask and a value to match against that mask.  Any given frag
+ * (subset of the number space) can be partitioned into 2^n sub-frags.
+ *
+ * Frags are encoded into a 32-bit word:
+ *   8 upper bits = "bits"
+ *  24 lower bits = "value"
+ * (We could go to 5+27 bits, but who cares.)
+ *
+ * We use the _most_ significant bits of the 24 bit value.  This makes
+ * values logically sort.
+ *
+ * Unfortunately, because the "bits" field is still in the high bits, we
+ * can't sort encoded frags numerically.  However, it does allow you
+ * to feed encoded frags as values into frag_contains_value.
+ */
+static inline __u32 ceph_frag_make(__u32 b, __u32 v)
+{
+       return (b << 24) |
+               (v & (0xffffffu << (24-b)) & 0xffffffu);
+}
+static inline __u32 ceph_frag_bits(__u32 f)
+{
+       return f >> 24;
+}
+static inline __u32 ceph_frag_value(__u32 f)
+{
+       return f & 0xffffffu;
+}
+static inline __u32 ceph_frag_mask(__u32 f)
+{
+       return (0xffffffu << (24-ceph_frag_bits(f))) & 0xffffffu;
+}
+static inline __u32 ceph_frag_mask_shift(__u32 f)
+{
+       return 24 - ceph_frag_bits(f);
+}
+
+static inline int ceph_frag_contains_value(__u32 f, __u32 v)
+{
+       return (v & ceph_frag_mask(f)) == ceph_frag_value(f);
+}
+static inline int ceph_frag_contains_frag(__u32 f, __u32 sub)
+{
+       /* is sub as specific as us, and contained by us? */
+       return ceph_frag_bits(sub) >= ceph_frag_bits(f) &&
+              (ceph_frag_value(sub) & ceph_frag_mask(f)) == ceph_frag_value(f);
+}
+
+static inline __u32 ceph_frag_parent(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f) - 1,
+                        ceph_frag_value(f) & (ceph_frag_mask(f) << 1));
+}
+static inline int ceph_frag_is_left_child(__u32 f)
+{
+       return ceph_frag_bits(f) > 0 &&
+               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 0;
+}
+static inline int ceph_frag_is_right_child(__u32 f)
+{
+       return ceph_frag_bits(f) > 0 &&
+               (ceph_frag_value(f) & (0x1000000 >> ceph_frag_bits(f))) == 1;
+}
+static inline __u32 ceph_frag_sibling(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f),
+                     ceph_frag_value(f) ^ (0x1000000 >> ceph_frag_bits(f)));
+}
+static inline __u32 ceph_frag_left_child(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f)+1, ceph_frag_value(f));
+}
+static inline __u32 ceph_frag_right_child(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f)+1,
+             ceph_frag_value(f) | (0x1000000 >> (1+ceph_frag_bits(f))));
+}
+static inline __u32 ceph_frag_make_child(__u32 f, int by, int i)
+{
+       int newbits = ceph_frag_bits(f) + by;
+       return ceph_frag_make(newbits,
+                        ceph_frag_value(f) | (i << (24 - newbits)));
+}
+static inline int ceph_frag_is_leftmost(__u32 f)
+{
+       return ceph_frag_value(f) == 0;
+}
+static inline int ceph_frag_is_rightmost(__u32 f)
+{
+       return ceph_frag_value(f) == ceph_frag_mask(f);
+}
+static inline __u32 ceph_frag_next(__u32 f)
+{
+       return ceph_frag_make(ceph_frag_bits(f),
+                        ceph_frag_value(f) + (0x1000000 >> ceph_frag_bits(f)));
+}
+
+/*
+ * comparator to sort frags logically, as when traversing the
+ * number space in ascending order...
+ */
+int ceph_frag_compare(__u32 a, __u32 b);
+
+#endif
diff --git a/fs/ceph/ceph_fs.c b/fs/ceph/ceph_fs.c
new file mode 100644 (file)
index 0000000..79d76bc
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Some non-inline ceph helpers
+ */
+#include "types.h"
+
+/*
+ * return true if @layout appears to be valid
+ */
+int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
+{
+       __u32 su = le32_to_cpu(layout->fl_stripe_unit);
+       __u32 sc = le32_to_cpu(layout->fl_stripe_count);
+       __u32 os = le32_to_cpu(layout->fl_object_size);
+
+       /* stripe unit, object size must be non-zero, 64k increment */
+       if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1)))
+               return 0;
+       if (!os || (os & (CEPH_MIN_STRIPE_UNIT-1)))
+               return 0;
+       /* object size must be a multiple of stripe unit */
+       if (os < su || os % su)
+               return 0;
+       /* stripe count must be non-zero */
+       if (!sc)
+               return 0;
+       return 1;
+}
+
+
+int ceph_flags_to_mode(int flags)
+{
+#ifdef O_DIRECTORY  /* fixme */
+       if ((flags & O_DIRECTORY) == O_DIRECTORY)
+               return CEPH_FILE_MODE_PIN;
+#endif
+#ifdef O_LAZY
+       if (flags & O_LAZY)
+               return CEPH_FILE_MODE_LAZY;
+#endif
+       if ((flags & O_APPEND) == O_APPEND)
+               flags |= O_WRONLY;
+
+       flags &= O_ACCMODE;
+       if ((flags & O_RDWR) == O_RDWR)
+               return CEPH_FILE_MODE_RDWR;
+       if ((flags & O_WRONLY) == O_WRONLY)
+               return CEPH_FILE_MODE_WR;
+       return CEPH_FILE_MODE_RD;
+}
+
+int ceph_caps_for_mode(int mode)
+{
+       switch (mode) {
+       case CEPH_FILE_MODE_PIN:
+               return CEPH_CAP_PIN;
+       case CEPH_FILE_MODE_RD:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE;
+       case CEPH_FILE_MODE_RDWR:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_EXCL |
+                       CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE |
+                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
+                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
+                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
+       case CEPH_FILE_MODE_WR:
+               return CEPH_CAP_PIN | CEPH_CAP_FILE_SHARED |
+                       CEPH_CAP_FILE_EXCL |
+                       CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |
+                       CEPH_CAP_AUTH_SHARED | CEPH_CAP_AUTH_EXCL |
+                       CEPH_CAP_XATTR_SHARED | CEPH_CAP_XATTR_EXCL;
+       }
+       return 0;
+}
diff --git a/fs/ceph/ceph_fs.h b/fs/ceph/ceph_fs.h
new file mode 100644 (file)
index 0000000..0c2241e
--- /dev/null
@@ -0,0 +1,650 @@
+/*
+ * ceph_fs.h - Ceph constants and data types to share between kernel and
+ * user space.
+ *
+ * Most types in this file are defined as little-endian, and are
+ * primarily intended to describe data structures that pass over the
+ * wire or that are stored on disk.
+ *
+ * LGPL2
+ */
+
+#ifndef _FS_CEPH_CEPH_FS_H
+#define _FS_CEPH_CEPH_FS_H
+
+#include "msgr.h"
+#include "rados.h"
+
+/*
+ * Ceph release version
+ */
+#define CEPH_VERSION_MAJOR 0
+#define CEPH_VERSION_MINOR 19
+#define CEPH_VERSION_PATCH 0
+
+#define _CEPH_STRINGIFY(x) #x
+#define CEPH_STRINGIFY(x) _CEPH_STRINGIFY(x)
+#define CEPH_MAKE_VERSION(x, y, z) CEPH_STRINGIFY(x) "." CEPH_STRINGIFY(y) \
+       "." CEPH_STRINGIFY(z)
+#define CEPH_VERSION CEPH_MAKE_VERSION(CEPH_VERSION_MAJOR, \
+                                      CEPH_VERSION_MINOR, CEPH_VERSION_PATCH)
+
+/*
+ * subprotocol versions.  when specific messages types or high-level
+ * protocols change, bump the affected components.  we keep rev
+ * internal cluster protocols separately from the public,
+ * client-facing protocol.
+ */
+#define CEPH_OSD_PROTOCOL     8 /* cluster internal */
+#define CEPH_MDS_PROTOCOL     9 /* cluster internal */
+#define CEPH_MON_PROTOCOL     5 /* cluster internal */
+#define CEPH_OSDC_PROTOCOL   24 /* server/client */
+#define CEPH_MDSC_PROTOCOL   32 /* server/client */
+#define CEPH_MONC_PROTOCOL   15 /* server/client */
+
+
+#define CEPH_INO_ROOT  1
+#define CEPH_INO_CEPH  2        /* hidden .ceph dir */
+
+/* arbitrary limit on max # of monitors (cluster of 3 is typical) */
+#define CEPH_MAX_MON   31
+
+
+/*
+ * feature bits
+ */
+#define CEPH_FEATURE_SUPPORTED  0
+#define CEPH_FEATURE_REQUIRED   0
+
+
+/*
+ * ceph_file_layout - describe data layout for a file/inode
+ */
+struct ceph_file_layout {
+       /* file -> object mapping */
+       __le32 fl_stripe_unit;     /* stripe unit, in bytes.  must be multiple
+                                     of page size. */
+       __le32 fl_stripe_count;    /* over this many objects */
+       __le32 fl_object_size;     /* until objects are this big, then move to
+                                     new objects */
+       __le32 fl_cas_hash;        /* 0 = none; 1 = sha256 */
+
+       /* pg -> disk layout */
+       __le32 fl_object_stripe_unit;  /* for per-object parity, if any */
+
+       /* object -> pg layout */
+       __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */
+       __le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
+} __attribute__ ((packed));
+
+#define CEPH_MIN_STRIPE_UNIT 65536
+
+int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
+
+
+/* crypto algorithms */
+#define CEPH_CRYPTO_NONE 0x0
+#define CEPH_CRYPTO_AES  0x1
+
+/* security/authentication protocols */
+#define CEPH_AUTH_UNKNOWN      0x0
+#define CEPH_AUTH_NONE         0x1
+#define CEPH_AUTH_CEPHX                0x2
+
+
+/*********************************************
+ * message layer
+ */
+
+/*
+ * message types
+ */
+
+/* misc */
+#define CEPH_MSG_SHUTDOWN               1
+#define CEPH_MSG_PING                   2
+
+/* client <-> monitor */
+#define CEPH_MSG_MON_MAP                4
+#define CEPH_MSG_MON_GET_MAP            5
+#define CEPH_MSG_STATFS                 13
+#define CEPH_MSG_STATFS_REPLY           14
+#define CEPH_MSG_MON_SUBSCRIBE          15
+#define CEPH_MSG_MON_SUBSCRIBE_ACK      16
+#define CEPH_MSG_AUTH                  17
+#define CEPH_MSG_AUTH_REPLY            18
+
+/* client <-> mds */
+#define CEPH_MSG_MDS_MAP                21
+
+#define CEPH_MSG_CLIENT_SESSION         22
+#define CEPH_MSG_CLIENT_RECONNECT       23
+
+#define CEPH_MSG_CLIENT_REQUEST         24
+#define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
+#define CEPH_MSG_CLIENT_REPLY           26
+#define CEPH_MSG_CLIENT_CAPS            0x310
+#define CEPH_MSG_CLIENT_LEASE           0x311
+#define CEPH_MSG_CLIENT_SNAP            0x312
+#define CEPH_MSG_CLIENT_CAPRELEASE      0x313
+
+/* osd */
+#define CEPH_MSG_OSD_MAP          41
+#define CEPH_MSG_OSD_OP           42
+#define CEPH_MSG_OSD_OPREPLY      43
+
+struct ceph_mon_request_header {
+       __le64 have_version;
+       __le16 session_mon;
+       __le64 session_mon_tid;
+} __attribute__ ((packed));
+
+struct ceph_mon_statfs {
+       struct ceph_mon_request_header monhdr;
+       struct ceph_fsid fsid;
+} __attribute__ ((packed));
+
+struct ceph_statfs {
+       __le64 kb, kb_used, kb_avail;
+       __le64 num_objects;
+} __attribute__ ((packed));
+
+struct ceph_mon_statfs_reply {
+       struct ceph_fsid fsid;
+       __le64 version;
+       struct ceph_statfs st;
+} __attribute__ ((packed));
+
+struct ceph_osd_getmap {
+       struct ceph_mon_request_header monhdr;
+       struct ceph_fsid fsid;
+       __le32 start;
+} __attribute__ ((packed));
+
+struct ceph_mds_getmap {
+       struct ceph_mon_request_header monhdr;
+       struct ceph_fsid fsid;
+} __attribute__ ((packed));
+
+struct ceph_client_mount {
+       struct ceph_mon_request_header monhdr;
+} __attribute__ ((packed));
+
+struct ceph_mon_subscribe_item {
+       __le64 have_version;    __le64 have;
+       __u8 onetime;
+} __attribute__ ((packed));
+
+struct ceph_mon_subscribe_ack {
+       __le32 duration;         /* seconds */
+       struct ceph_fsid fsid;
+} __attribute__ ((packed));
+
+/*
+ * mds states
+ *   > 0 -> in
+ *  <= 0 -> out
+ */
+#define CEPH_MDS_STATE_DNE          0  /* down, does not exist. */
+#define CEPH_MDS_STATE_STOPPED     -1  /* down, once existed, but no subtrees.
+                                         empty log. */
+#define CEPH_MDS_STATE_BOOT        -4  /* up, boot announcement. */
+#define CEPH_MDS_STATE_STANDBY     -5  /* up, idle.  waiting for assignment. */
+#define CEPH_MDS_STATE_CREATING    -6  /* up, creating MDS instance. */
+#define CEPH_MDS_STATE_STARTING    -7  /* up, starting previously stopped mds */
+#define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
+
+#define CEPH_MDS_STATE_REPLAY       8  /* up, replaying journal. */
+#define CEPH_MDS_STATE_RESOLVE      9  /* up, disambiguating distributed
+                                         operations (import, rename, etc.) */
+#define CEPH_MDS_STATE_RECONNECT    10 /* up, reconnect to clients */
+#define CEPH_MDS_STATE_REJOIN       11 /* up, rejoining distributed cache */
+#define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
+#define CEPH_MDS_STATE_ACTIVE       13 /* up, active */
+#define CEPH_MDS_STATE_STOPPING     14 /* up, but exporting metadata */
+
+extern const char *ceph_mds_state_name(int s);
+
+
+/*
+ * metadata lock types.
+ *  - these are bitmasks.. we can compose them
+ *  - they also define the lock ordering by the MDS
+ *  - a few of these are internal to the mds
+ */
+#define CEPH_LOCK_DN          1
+#define CEPH_LOCK_ISNAP       2
+#define CEPH_LOCK_IVERSION    4     /* mds internal */
+#define CEPH_LOCK_IFILE       8     /* mds internal */
+#define CEPH_LOCK_IAUTH       32
+#define CEPH_LOCK_ILINK       64
+#define CEPH_LOCK_IDFT        128   /* dir frag tree */
+#define CEPH_LOCK_INEST       256   /* mds internal */
+#define CEPH_LOCK_IXATTR      512
+#define CEPH_LOCK_INO         2048  /* immutable inode bits; not a lock */
+
+/* client_session ops */
+enum {
+       CEPH_SESSION_REQUEST_OPEN,
+       CEPH_SESSION_OPEN,
+       CEPH_SESSION_REQUEST_CLOSE,
+       CEPH_SESSION_CLOSE,
+       CEPH_SESSION_REQUEST_RENEWCAPS,
+       CEPH_SESSION_RENEWCAPS,
+       CEPH_SESSION_STALE,
+       CEPH_SESSION_RECALL_STATE,
+};
+
+extern const char *ceph_session_op_name(int op);
+
+struct ceph_mds_session_head {
+       __le32 op;
+       __le64 seq;
+       struct ceph_timespec stamp;
+       __le32 max_caps, max_leases;
+} __attribute__ ((packed));
+
+/* client_request */
+/*
+ * metadata ops.
+ *  & 0x001000 -> write op
+ *  & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
+ &  & 0x100000 -> use weird ino/path trace
+ */
+#define CEPH_MDS_OP_WRITE        0x001000
+enum {
+       CEPH_MDS_OP_LOOKUP     = 0x00100,
+       CEPH_MDS_OP_GETATTR    = 0x00101,
+       CEPH_MDS_OP_LOOKUPHASH = 0x00102,
+       CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
+
+       CEPH_MDS_OP_SETXATTR   = 0x01105,
+       CEPH_MDS_OP_RMXATTR    = 0x01106,
+       CEPH_MDS_OP_SETLAYOUT  = 0x01107,
+       CEPH_MDS_OP_SETATTR    = 0x01108,
+
+       CEPH_MDS_OP_MKNOD      = 0x01201,
+       CEPH_MDS_OP_LINK       = 0x01202,
+       CEPH_MDS_OP_UNLINK     = 0x01203,
+       CEPH_MDS_OP_RENAME     = 0x01204,
+       CEPH_MDS_OP_MKDIR      = 0x01220,
+       CEPH_MDS_OP_RMDIR      = 0x01221,
+       CEPH_MDS_OP_SYMLINK    = 0x01222,
+
+       CEPH_MDS_OP_CREATE     = 0x01301,
+       CEPH_MDS_OP_OPEN       = 0x00302,
+       CEPH_MDS_OP_READDIR    = 0x00305,
+
+       CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
+       CEPH_MDS_OP_MKSNAP     = 0x01400,
+       CEPH_MDS_OP_RMSNAP     = 0x01401,
+       CEPH_MDS_OP_LSSNAP     = 0x00402,
+};
+
+extern const char *ceph_mds_op_name(int op);
+
+
+#define CEPH_SETATTR_MODE   1
+#define CEPH_SETATTR_UID    2
+#define CEPH_SETATTR_GID    4
+#define CEPH_SETATTR_MTIME  8
+#define CEPH_SETATTR_ATIME 16
+#define CEPH_SETATTR_SIZE  32
+#define CEPH_SETATTR_CTIME 64
+
+union ceph_mds_request_args {
+       struct {
+               __le32 mask;                 /* CEPH_CAP_* */
+       } __attribute__ ((packed)) getattr;
+       struct {
+               __le32 mode;
+               __le32 uid;
+               __le32 gid;
+               struct ceph_timespec mtime;
+               struct ceph_timespec atime;
+               __le64 size, old_size;       /* old_size needed by truncate */
+               __le32 mask;                 /* CEPH_SETATTR_* */
+       } __attribute__ ((packed)) setattr;
+       struct {
+               __le32 frag;                 /* which dir fragment */
+               __le32 max_entries;          /* how many dentries to grab */
+       } __attribute__ ((packed)) readdir;
+       struct {
+               __le32 mode;
+               __le32 rdev;
+       } __attribute__ ((packed)) mknod;
+       struct {
+               __le32 mode;
+       } __attribute__ ((packed)) mkdir;
+       struct {
+               __le32 flags;
+               __le32 mode;
+               __le32 stripe_unit;          /* layout for newly created file */
+               __le32 stripe_count;         /* ... */
+               __le32 object_size;
+               __le32 file_replication;
+               __le32 preferred;
+       } __attribute__ ((packed)) open;
+       struct {
+               __le32 flags;
+       } __attribute__ ((packed)) setxattr;
+       struct {
+               struct ceph_file_layout layout;
+       } __attribute__ ((packed)) setlayout;
+} __attribute__ ((packed));
+
+#define CEPH_MDS_FLAG_REPLAY        1  /* this is a replayed op */
+#define CEPH_MDS_FLAG_WANT_DENTRY   2  /* want dentry in reply */
+
+struct ceph_mds_request_head {
+       __le64 oldest_client_tid;
+       __le32 mdsmap_epoch;           /* on client */
+       __le32 flags;                  /* CEPH_MDS_FLAG_* */
+       __u8 num_retry, num_fwd;       /* count retry, fwd attempts */
+       __le16 num_releases;           /* # include cap/lease release records */
+       __le32 op;                     /* mds op code */
+       __le32 caller_uid, caller_gid;
+       __le64 ino;                    /* use this ino for openc, mkdir, mknod,
+                                         etc. (if replaying) */
+       union ceph_mds_request_args args;
+} __attribute__ ((packed));
+
+/* cap/lease release record */
+struct ceph_mds_request_release {
+       __le64 ino, cap_id;            /* ino and unique cap id */
+       __le32 caps, wanted;           /* new issued, wanted */
+       __le32 seq, issue_seq, mseq;
+       __le32 dname_seq;              /* if releasing a dentry lease, a */
+       __le32 dname_len;              /* string follows. */
+} __attribute__ ((packed));
+
+/* client reply */
+struct ceph_mds_reply_head {
+       __le32 op;
+       __le32 result;
+       __le32 mdsmap_epoch;
+       __u8 safe;                     /* true if committed to disk */
+       __u8 is_dentry, is_target;     /* true if dentry, target inode records
+                                         are included with reply */
+} __attribute__ ((packed));
+
+/* one for each node split */
+struct ceph_frag_tree_split {
+       __le32 frag;                   /* this frag splits... */
+       __le32 by;                     /* ...by this many bits */
+} __attribute__ ((packed));
+
+struct ceph_frag_tree_head {
+       __le32 nsplits;                /* num ceph_frag_tree_split records */
+       struct ceph_frag_tree_split splits[];
+} __attribute__ ((packed));
+
+/* capability issue, for bundling with mds reply */
+struct ceph_mds_reply_cap {
+       __le32 caps, wanted;           /* caps issued, wanted */
+       __le64 cap_id;
+       __le32 seq, mseq;
+       __le64 realm;                  /* snap realm */
+       __u8 flags;                    /* CEPH_CAP_FLAG_* */
+} __attribute__ ((packed));
+
+#define CEPH_CAP_FLAG_AUTH  1          /* cap is issued by auth mds */
+
+/* inode record, for bundling with mds reply */
+struct ceph_mds_reply_inode {
+       __le64 ino;
+       __le64 snapid;
+       __le32 rdev;
+       __le64 version;                /* inode version */
+       __le64 xattr_version;          /* version for xattr blob */
+       struct ceph_mds_reply_cap cap; /* caps issued for this inode */
+       struct ceph_file_layout layout;
+       struct ceph_timespec ctime, mtime, atime;
+       __le32 time_warp_seq;
+       __le64 size, max_size, truncate_size;
+       __le32 truncate_seq;
+       __le32 mode, uid, gid;
+       __le32 nlink;
+       __le64 files, subdirs, rbytes, rfiles, rsubdirs;  /* dir stats */
+       struct ceph_timespec rctime;
+       struct ceph_frag_tree_head fragtree;  /* (must be at end of struct) */
+} __attribute__ ((packed));
+/* followed by frag array, then symlink string, then xattr blob */
+
+/* reply_lease follows dname, and reply_inode */
+struct ceph_mds_reply_lease {
+       __le16 mask;            /* lease type(s) */
+       __le32 duration_ms;     /* lease duration */
+       __le32 seq;
+} __attribute__ ((packed));
+
+struct ceph_mds_reply_dirfrag {
+       __le32 frag;            /* fragment */
+       __le32 auth;            /* auth mds, if this is a delegation point */
+       __le32 ndist;           /* number of mds' this is replicated on */
+       __le32 dist[];
+} __attribute__ ((packed));
+
+/* file access modes */
+#define CEPH_FILE_MODE_PIN        0
+#define CEPH_FILE_MODE_RD         1
+#define CEPH_FILE_MODE_WR         2
+#define CEPH_FILE_MODE_RDWR       3  /* RD | WR */
+#define CEPH_FILE_MODE_LAZY       4  /* lazy io */
+#define CEPH_FILE_MODE_NUM        8  /* bc these are bit fields.. mostly */
+
+int ceph_flags_to_mode(int flags);
+
+
+/* capability bits */
+#define CEPH_CAP_PIN         1  /* no specific capabilities beyond the pin */
+
+/* generic cap bits */
+#define CEPH_CAP_GSHARED     1  /* client can reads */
+#define CEPH_CAP_GEXCL       2  /* client can read and update */
+#define CEPH_CAP_GCACHE      4  /* (file) client can cache reads */
+#define CEPH_CAP_GRD         8  /* (file) client can read */
+#define CEPH_CAP_GWR        16  /* (file) client can write */
+#define CEPH_CAP_GBUFFER    32  /* (file) client can buffer writes */
+#define CEPH_CAP_GWREXTEND  64  /* (file) client can extend EOF */
+#define CEPH_CAP_GLAZYIO   128  /* (file) client can perform lazy io */
+
+/* per-lock shift */
+#define CEPH_CAP_SAUTH      2
+#define CEPH_CAP_SLINK      4
+#define CEPH_CAP_SXATTR     6
+#define CEPH_CAP_SFILE      8   /* goes at the end (uses >2 cap bits) */
+
+#define CEPH_CAP_BITS       16
+
+/* composed values */
+#define CEPH_CAP_AUTH_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SAUTH)
+#define CEPH_CAP_AUTH_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SAUTH)
+#define CEPH_CAP_LINK_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SLINK)
+#define CEPH_CAP_LINK_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SLINK)
+#define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED  << CEPH_CAP_SXATTR)
+#define CEPH_CAP_XATTR_EXCL    (CEPH_CAP_GEXCL     << CEPH_CAP_SXATTR)
+#define CEPH_CAP_FILE(x)    (x << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_SHARED   (CEPH_CAP_GSHARED   << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_CACHE    (CEPH_CAP_GCACHE    << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_RD       (CEPH_CAP_GRD       << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_WR       (CEPH_CAP_GWR       << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_BUFFER   (CEPH_CAP_GBUFFER   << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
+#define CEPH_CAP_FILE_LAZYIO   (CEPH_CAP_GLAZYIO   << CEPH_CAP_SFILE)
+
+/* cap masks (for getattr) */
+#define CEPH_STAT_CAP_INODE    CEPH_CAP_PIN
+#define CEPH_STAT_CAP_TYPE     CEPH_CAP_PIN  /* mode >> 12 */
+#define CEPH_STAT_CAP_SYMLINK  CEPH_CAP_PIN
+#define CEPH_STAT_CAP_UID      CEPH_CAP_AUTH_SHARED
+#define CEPH_STAT_CAP_GID      CEPH_CAP_AUTH_SHARED
+#define CEPH_STAT_CAP_MODE     CEPH_CAP_AUTH_SHARED
+#define CEPH_STAT_CAP_NLINK    CEPH_CAP_LINK_SHARED
+#define CEPH_STAT_CAP_LAYOUT   CEPH_CAP_FILE_SHARED
+#define CEPH_STAT_CAP_MTIME    CEPH_CAP_FILE_SHARED
+#define CEPH_STAT_CAP_SIZE     CEPH_CAP_FILE_SHARED
+#define CEPH_STAT_CAP_ATIME    CEPH_CAP_FILE_SHARED  /* fixme */
+#define CEPH_STAT_CAP_XATTR    CEPH_CAP_XATTR_SHARED
+#define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN |                        \
+                                CEPH_CAP_AUTH_SHARED | \
+                                CEPH_CAP_LINK_SHARED | \
+                                CEPH_CAP_FILE_SHARED | \
+                                CEPH_CAP_XATTR_SHARED)
+
+#define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED |                    \
+                             CEPH_CAP_LINK_SHARED |                    \
+                             CEPH_CAP_XATTR_SHARED |                   \
+                             CEPH_CAP_FILE_SHARED)
+#define CEPH_CAP_ANY_RD   (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD |    \
+                          CEPH_CAP_FILE_CACHE)
+
+#define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL |                \
+                          CEPH_CAP_LINK_EXCL |         \
+                          CEPH_CAP_XATTR_EXCL |        \
+                          CEPH_CAP_FILE_EXCL)
+#define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |        \
+                             CEPH_CAP_FILE_EXCL)
+#define CEPH_CAP_ANY_WR   (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
+#define CEPH_CAP_ANY      (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
+                          CEPH_CAP_ANY_FILE_WR | CEPH_CAP_PIN)
+
+#define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
+                       CEPH_LOCK_IXATTR)
+
+int ceph_caps_for_mode(int mode);
+
+enum {
+       CEPH_CAP_OP_GRANT,         /* mds->client grant */
+       CEPH_CAP_OP_REVOKE,        /* mds->client revoke */
+       CEPH_CAP_OP_TRUNC,         /* mds->client trunc notify */
+       CEPH_CAP_OP_EXPORT,        /* mds has exported the cap */
+       CEPH_CAP_OP_IMPORT,        /* mds has imported the cap */
+       CEPH_CAP_OP_UPDATE,        /* client->mds update */
+       CEPH_CAP_OP_DROP,          /* client->mds drop cap bits */
+       CEPH_CAP_OP_FLUSH,         /* client->mds cap writeback */
+       CEPH_CAP_OP_FLUSH_ACK,     /* mds->client flushed */
+       CEPH_CAP_OP_FLUSHSNAP,     /* client->mds flush snapped metadata */
+       CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
+       CEPH_CAP_OP_RELEASE,       /* client->mds release (clean) cap */
+       CEPH_CAP_OP_RENEW,         /* client->mds renewal request */
+};
+
+extern const char *ceph_cap_op_name(int op);
+
+/*
+ * caps message, used for capability callbacks, acks, requests, etc.
+ */
+struct ceph_mds_caps {
+       __le32 op;                  /* CEPH_CAP_OP_* */
+       __le64 ino, realm;
+       __le64 cap_id;
+       __le32 seq, issue_seq;
+       __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
+       __le32 migrate_seq;
+       __le64 snap_follows;
+       __le32 snap_trace_len;
+
+       /* authlock */
+       __le32 uid, gid, mode;
+
+       /* linklock */
+       __le32 nlink;
+
+       /* xattrlock */
+       __le32 xattr_len;
+       __le64 xattr_version;
+
+       /* filelock */
+       __le64 size, max_size, truncate_size;
+       __le32 truncate_seq;
+       struct ceph_timespec mtime, atime, ctime;
+       struct ceph_file_layout layout;
+       __le32 time_warp_seq;
+} __attribute__ ((packed));
+
+/* cap release msg head */
+struct ceph_mds_cap_release {
+       __le32 num;                /* number of cap_items that follow */
+} __attribute__ ((packed));
+
+struct ceph_mds_cap_item {
+       __le64 ino;
+       __le64 cap_id;
+       __le32 migrate_seq, seq;
+} __attribute__ ((packed));
+
+#define CEPH_MDS_LEASE_REVOKE           1  /*    mds  -> client */
+#define CEPH_MDS_LEASE_RELEASE          2  /* client  -> mds    */
+#define CEPH_MDS_LEASE_RENEW            3  /* client <-> mds    */
+#define CEPH_MDS_LEASE_REVOKE_ACK       4  /* client  -> mds    */
+
+extern const char *ceph_lease_op_name(int o);
+
+/* lease msg header */
+struct ceph_mds_lease {
+       __u8 action;            /* CEPH_MDS_LEASE_* */
+       __le16 mask;            /* which lease */
+       __le64 ino;
+       __le64 first, last;     /* snap range */
+       __le32 seq;
+       __le32 duration_ms;     /* duration of renewal */
+} __attribute__ ((packed));
+/* followed by a __le32+string for dname */
+
+/* client reconnect */
+struct ceph_mds_cap_reconnect {
+       __le64 cap_id;
+       __le32 wanted;
+       __le32 issued;
+       __le64 size;
+       struct ceph_timespec mtime, atime;
+       __le64 snaprealm;
+       __le64 pathbase;        /* base ino for our path to this ino */
+} __attribute__ ((packed));
+/* followed by encoded string */
+
+struct ceph_mds_snaprealm_reconnect {
+       __le64 ino;     /* snap realm base */
+       __le64 seq;     /* snap seq for this snap realm */
+       __le64 parent;  /* parent realm */
+} __attribute__ ((packed));
+
+/*
+ * snaps
+ */
+enum {
+       CEPH_SNAP_OP_UPDATE,  /* CREATE or DESTROY */
+       CEPH_SNAP_OP_CREATE,
+       CEPH_SNAP_OP_DESTROY,
+       CEPH_SNAP_OP_SPLIT,
+};
+
+extern const char *ceph_snap_op_name(int o);
+
+/* snap msg header */
+struct ceph_mds_snap_head {
+       __le32 op;                /* CEPH_SNAP_OP_* */
+       __le64 split;             /* ino to split off, if any */
+       __le32 num_split_inos;    /* # inos belonging to new child realm */
+       __le32 num_split_realms;  /* # child realms udner new child realm */
+       __le32 trace_len;         /* size of snap trace blob */
+} __attribute__ ((packed));
+/* followed by split ino list, then split realms, then the trace blob */
+
+/*
+ * encode info about a snaprealm, as viewed by a client
+ */
+struct ceph_mds_snap_realm {
+       __le64 ino;           /* ino */
+       __le64 created;       /* snap: when created */
+       __le64 parent;        /* ino: parent realm */
+       __le64 parent_since;  /* snap: same parent since */
+       __le64 seq;           /* snap: version */
+       __le32 num_snaps;
+       __le32 num_prior_parent_snaps;
+} __attribute__ ((packed));
+/* followed by my snap list, then prior parent snap list */
+
+#endif
diff --git a/fs/ceph/ceph_hash.c b/fs/ceph/ceph_hash.c
new file mode 100644 (file)
index 0000000..bd57001
--- /dev/null
@@ -0,0 +1,118 @@
+
+#include "types.h"
+
+/*
+ * Robert Jenkin's hash function.
+ * http://burtleburtle.net/bob/hash/evahash.html
+ * This is in the public domain.
+ */
+#define mix(a, b, c)                                           \
+       do {                                                    \
+               a = a - b;  a = a - c;  a = a ^ (c >> 13);      \
+               b = b - c;  b = b - a;  b = b ^ (a << 8);       \
+               c = c - a;  c = c - b;  c = c ^ (b >> 13);      \
+               a = a - b;  a = a - c;  a = a ^ (c >> 12);      \
+               b = b - c;  b = b - a;  b = b ^ (a << 16);      \
+               c = c - a;  c = c - b;  c = c ^ (b >> 5);       \
+               a = a - b;  a = a - c;  a = a ^ (c >> 3);       \
+               b = b - c;  b = b - a;  b = b ^ (a << 10);      \
+               c = c - a;  c = c - b;  c = c ^ (b >> 15);      \
+       } while (0)
+
+unsigned ceph_str_hash_rjenkins(const char *str, unsigned length)
+{
+       const unsigned char *k = (const unsigned char *)str;
+       __u32 a, b, c;  /* the internal state */
+       __u32 len;      /* how many key bytes still need mixing */
+
+       /* Set up the internal state */
+       len = length;
+       a = 0x9e3779b9;      /* the golden ratio; an arbitrary value */
+       b = a;
+       c = 0;               /* variable initialization of internal state */
+
+       /* handle most of the key */
+       while (len >= 12) {
+               a = a + (k[0] + ((__u32)k[1] << 8) + ((__u32)k[2] << 16) +
+                        ((__u32)k[3] << 24));
+               b = b + (k[4] + ((__u32)k[5] << 8) + ((__u32)k[6] << 16) +
+                        ((__u32)k[7] << 24));
+               c = c + (k[8] + ((__u32)k[9] << 8) + ((__u32)k[10] << 16) +
+                        ((__u32)k[11] << 24));
+               mix(a, b, c);
+               k = k + 12;
+               len = len - 12;
+       }
+
+       /* handle the last 11 bytes */
+       c = c + length;
+       switch (len) {            /* all the case statements fall through */
+       case 11:
+               c = c + ((__u32)k[10] << 24);
+       case 10:
+               c = c + ((__u32)k[9] << 16);
+       case 9:
+               c = c + ((__u32)k[8] << 8);
+               /* the first byte of c is reserved for the length */
+       case 8:
+               b = b + ((__u32)k[7] << 24);
+       case 7:
+               b = b + ((__u32)k[6] << 16);
+       case 6:
+               b = b + ((__u32)k[5] << 8);
+       case 5:
+               b = b + k[4];
+       case 4:
+               a = a + ((__u32)k[3] << 24);
+       case 3:
+               a = a + ((__u32)k[2] << 16);
+       case 2:
+               a = a + ((__u32)k[1] << 8);
+       case 1:
+               a = a + k[0];
+               /* case 0: nothing left to add */
+       }
+       mix(a, b, c);
+
+       return c;
+}
+
+/*
+ * linux dcache hash
+ */
+unsigned ceph_str_hash_linux(const char *str, unsigned length)
+{
+       unsigned long hash = 0;
+       unsigned char c;
+
+       while (length--) {
+               c = *str++;
+               hash = (hash + (c << 4) + (c >> 4)) * 11;
+       }
+       return hash;
+}
+
+
+unsigned ceph_str_hash(int type, const char *s, unsigned len)
+{
+       switch (type) {
+       case CEPH_STR_HASH_LINUX:
+               return ceph_str_hash_linux(s, len);
+       case CEPH_STR_HASH_RJENKINS:
+               return ceph_str_hash_rjenkins(s, len);
+       default:
+               return -1;
+       }
+}
+
+const char *ceph_str_hash_name(int type)
+{
+       switch (type) {
+       case CEPH_STR_HASH_LINUX:
+               return "linux";
+       case CEPH_STR_HASH_RJENKINS:
+               return "rjenkins";
+       default:
+               return "unknown";
+       }
+}
diff --git a/fs/ceph/ceph_hash.h b/fs/ceph/ceph_hash.h
new file mode 100644 (file)
index 0000000..5ac470c
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _FS_CEPH_HASH_H
+#define _FS_CEPH_HASH_H
+
+#define CEPH_STR_HASH_LINUX      0x1  /* linux dcache hash */
+#define CEPH_STR_HASH_RJENKINS   0x2  /* robert jenkins' */
+
+extern unsigned ceph_str_hash_linux(const char *s, unsigned len);
+extern unsigned ceph_str_hash_rjenkins(const char *s, unsigned len);
+
+extern unsigned ceph_str_hash(int type, const char *s, unsigned len);
+extern const char *ceph_str_hash_name(int type);
+
+#endif
diff --git a/fs/ceph/ceph_strings.c b/fs/ceph/ceph_strings.c
new file mode 100644 (file)
index 0000000..8e4be6a
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * Ceph string constants
+ */
+#include "types.h"
+
+const char *ceph_entity_type_name(int type)
+{
+       switch (type) {
+       case CEPH_ENTITY_TYPE_MDS: return "mds";
+       case CEPH_ENTITY_TYPE_OSD: return "osd";
+       case CEPH_ENTITY_TYPE_MON: return "mon";
+       case CEPH_ENTITY_TYPE_CLIENT: return "client";
+       case CEPH_ENTITY_TYPE_ADMIN: return "admin";
+       case CEPH_ENTITY_TYPE_AUTH: return "auth";
+       default: return "unknown";
+       }
+}
+
+const char *ceph_osd_op_name(int op)
+{
+       switch (op) {
+       case CEPH_OSD_OP_READ: return "read";
+       case CEPH_OSD_OP_STAT: return "stat";
+
+       case CEPH_OSD_OP_MASKTRUNC: return "masktrunc";
+
+       case CEPH_OSD_OP_WRITE: return "write";
+       case CEPH_OSD_OP_DELETE: return "delete";
+       case CEPH_OSD_OP_TRUNCATE: return "truncate";
+       case CEPH_OSD_OP_ZERO: return "zero";
+       case CEPH_OSD_OP_WRITEFULL: return "writefull";
+
+       case CEPH_OSD_OP_APPEND: return "append";
+       case CEPH_OSD_OP_STARTSYNC: return "startsync";
+       case CEPH_OSD_OP_SETTRUNC: return "settrunc";
+       case CEPH_OSD_OP_TRIMTRUNC: return "trimtrunc";
+
+       case CEPH_OSD_OP_TMAPUP: return "tmapup";
+       case CEPH_OSD_OP_TMAPGET: return "tmapget";
+       case CEPH_OSD_OP_TMAPPUT: return "tmapput";
+
+       case CEPH_OSD_OP_GETXATTR: return "getxattr";
+       case CEPH_OSD_OP_GETXATTRS: return "getxattrs";
+       case CEPH_OSD_OP_SETXATTR: return "setxattr";
+       case CEPH_OSD_OP_SETXATTRS: return "setxattrs";
+       case CEPH_OSD_OP_RESETXATTRS: return "resetxattrs";
+       case CEPH_OSD_OP_RMXATTR: return "rmxattr";
+
+       case CEPH_OSD_OP_PULL: return "pull";
+       case CEPH_OSD_OP_PUSH: return "push";
+       case CEPH_OSD_OP_BALANCEREADS: return "balance-reads";
+       case CEPH_OSD_OP_UNBALANCEREADS: return "unbalance-reads";
+       case CEPH_OSD_OP_SCRUB: return "scrub";
+
+       case CEPH_OSD_OP_WRLOCK: return "wrlock";
+       case CEPH_OSD_OP_WRUNLOCK: return "wrunlock";
+       case CEPH_OSD_OP_RDLOCK: return "rdlock";
+       case CEPH_OSD_OP_RDUNLOCK: return "rdunlock";
+       case CEPH_OSD_OP_UPLOCK: return "uplock";
+       case CEPH_OSD_OP_DNLOCK: return "dnlock";
+
+       case CEPH_OSD_OP_CALL: return "call";
+
+       case CEPH_OSD_OP_PGLS: return "pgls";
+       }
+       return "???";
+}
+
+const char *ceph_mds_state_name(int s)
+{
+       switch (s) {
+               /* down and out */
+       case CEPH_MDS_STATE_DNE:        return "down:dne";
+       case CEPH_MDS_STATE_STOPPED:    return "down:stopped";
+               /* up and out */
+       case CEPH_MDS_STATE_BOOT:       return "up:boot";
+       case CEPH_MDS_STATE_STANDBY:    return "up:standby";
+       case CEPH_MDS_STATE_STANDBY_REPLAY:    return "up:standby-replay";
+       case CEPH_MDS_STATE_CREATING:   return "up:creating";
+       case CEPH_MDS_STATE_STARTING:   return "up:starting";
+               /* up and in */
+       case CEPH_MDS_STATE_REPLAY:     return "up:replay";
+       case CEPH_MDS_STATE_RESOLVE:    return "up:resolve";
+       case CEPH_MDS_STATE_RECONNECT:  return "up:reconnect";
+       case CEPH_MDS_STATE_REJOIN:     return "up:rejoin";
+       case CEPH_MDS_STATE_CLIENTREPLAY: return "up:clientreplay";
+       case CEPH_MDS_STATE_ACTIVE:     return "up:active";
+       case CEPH_MDS_STATE_STOPPING:   return "up:stopping";
+       }
+       return "???";
+}
+
+const char *ceph_session_op_name(int op)
+{
+       switch (op) {
+       case CEPH_SESSION_REQUEST_OPEN: return "request_open";
+       case CEPH_SESSION_OPEN: return "open";
+       case CEPH_SESSION_REQUEST_CLOSE: return "request_close";
+       case CEPH_SESSION_CLOSE: return "close";
+       case CEPH_SESSION_REQUEST_RENEWCAPS: return "request_renewcaps";
+       case CEPH_SESSION_RENEWCAPS: return "renewcaps";
+       case CEPH_SESSION_STALE: return "stale";
+       case CEPH_SESSION_RECALL_STATE: return "recall_state";
+       }
+       return "???";
+}
+
+const char *ceph_mds_op_name(int op)
+{
+       switch (op) {
+       case CEPH_MDS_OP_LOOKUP:  return "lookup";
+       case CEPH_MDS_OP_LOOKUPHASH:  return "lookuphash";
+       case CEPH_MDS_OP_LOOKUPPARENT:  return "lookupparent";
+       case CEPH_MDS_OP_GETATTR:  return "getattr";
+       case CEPH_MDS_OP_SETXATTR: return "setxattr";
+       case CEPH_MDS_OP_SETATTR: return "setattr";
+       case CEPH_MDS_OP_RMXATTR: return "rmxattr";
+       case CEPH_MDS_OP_READDIR: return "readdir";
+       case CEPH_MDS_OP_MKNOD: return "mknod";
+       case CEPH_MDS_OP_LINK: return "link";
+       case CEPH_MDS_OP_UNLINK: return "unlink";
+       case CEPH_MDS_OP_RENAME: return "rename";
+       case CEPH_MDS_OP_MKDIR: return "mkdir";
+       case CEPH_MDS_OP_RMDIR: return "rmdir";
+       case CEPH_MDS_OP_SYMLINK: return "symlink";
+       case CEPH_MDS_OP_CREATE: return "create";
+       case CEPH_MDS_OP_OPEN: return "open";
+       case CEPH_MDS_OP_LOOKUPSNAP: return "lookupsnap";
+       case CEPH_MDS_OP_LSSNAP: return "lssnap";
+       case CEPH_MDS_OP_MKSNAP: return "mksnap";
+       case CEPH_MDS_OP_RMSNAP: return "rmsnap";
+       }
+       return "???";
+}
+
+const char *ceph_cap_op_name(int op)
+{
+       switch (op) {
+       case CEPH_CAP_OP_GRANT: return "grant";
+       case CEPH_CAP_OP_REVOKE: return "revoke";
+       case CEPH_CAP_OP_TRUNC: return "trunc";
+       case CEPH_CAP_OP_EXPORT: return "export";
+       case CEPH_CAP_OP_IMPORT: return "import";
+       case CEPH_CAP_OP_UPDATE: return "update";
+       case CEPH_CAP_OP_DROP: return "drop";
+       case CEPH_CAP_OP_FLUSH: return "flush";
+       case CEPH_CAP_OP_FLUSH_ACK: return "flush_ack";
+       case CEPH_CAP_OP_FLUSHSNAP: return "flushsnap";
+       case CEPH_CAP_OP_FLUSHSNAP_ACK: return "flushsnap_ack";
+       case CEPH_CAP_OP_RELEASE: return "release";
+       case CEPH_CAP_OP_RENEW: return "renew";
+       }
+       return "???";
+}
+
+const char *ceph_lease_op_name(int o)
+{
+       switch (o) {
+       case CEPH_MDS_LEASE_REVOKE: return "revoke";
+       case CEPH_MDS_LEASE_RELEASE: return "release";
+       case CEPH_MDS_LEASE_RENEW: return "renew";
+       case CEPH_MDS_LEASE_REVOKE_ACK: return "revoke_ack";
+       }
+       return "???";
+}
+
+const char *ceph_snap_op_name(int o)
+{
+       switch (o) {
+       case CEPH_SNAP_OP_UPDATE: return "update";
+       case CEPH_SNAP_OP_CREATE: return "create";
+       case CEPH_SNAP_OP_DESTROY: return "destroy";
+       case CEPH_SNAP_OP_SPLIT: return "split";
+       }
+       return "???";
+}
diff --git a/fs/ceph/crush/crush.c b/fs/ceph/crush/crush.c
new file mode 100644 (file)
index 0000000..fabd302
--- /dev/null
@@ -0,0 +1,151 @@
+
+#ifdef __KERNEL__
+# include <linux/slab.h>
+#else
+# include <stdlib.h>
+# include <assert.h>
+# define kfree(x) do { if (x) free(x); } while (0)
+# define BUG_ON(x) assert(!(x))
+#endif
+
+#include "crush.h"
+
+const char *crush_bucket_alg_name(int alg)
+{
+       switch (alg) {
+       case CRUSH_BUCKET_UNIFORM: return "uniform";
+       case CRUSH_BUCKET_LIST: return "list";
+       case CRUSH_BUCKET_TREE: return "tree";
+       case CRUSH_BUCKET_STRAW: return "straw";
+       default: return "unknown";
+       }
+}
+
+/**
+ * crush_get_bucket_item_weight - Get weight of an item in given bucket
+ * @b: bucket pointer
+ * @p: item index in bucket
+ */
+int crush_get_bucket_item_weight(struct crush_bucket *b, int p)
+{
+       if (p >= b->size)
+               return 0;
+
+       switch (b->alg) {
+       case CRUSH_BUCKET_UNIFORM:
+               return ((struct crush_bucket_uniform *)b)->item_weight;
+       case CRUSH_BUCKET_LIST:
+               return ((struct crush_bucket_list *)b)->item_weights[p];
+       case CRUSH_BUCKET_TREE:
+               if (p & 1)
+                       return ((struct crush_bucket_tree *)b)->node_weights[p];
+               return 0;
+       case CRUSH_BUCKET_STRAW:
+               return ((struct crush_bucket_straw *)b)->item_weights[p];
+       }
+       return 0;
+}
+
+/**
+ * crush_calc_parents - Calculate parent vectors for the given crush map.
+ * @map: crush_map pointer
+ */
+void crush_calc_parents(struct crush_map *map)
+{
+       int i, b, c;
+
+       for (b = 0; b < map->max_buckets; b++) {
+               if (map->buckets[b] == NULL)
+                       continue;
+               for (i = 0; i < map->buckets[b]->size; i++) {
+                       c = map->buckets[b]->items[i];
+                       BUG_ON(c >= map->max_devices ||
+                              c < -map->max_buckets);
+                       if (c >= 0)
+                               map->device_parents[c] = map->buckets[b]->id;
+                       else
+                               map->bucket_parents[-1-c] = map->buckets[b]->id;
+               }
+       }
+}
+
+void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b)
+{
+       kfree(b->h.perm);
+       kfree(b->h.items);
+       kfree(b);
+}
+
+void crush_destroy_bucket_list(struct crush_bucket_list *b)
+{
+       kfree(b->item_weights);
+       kfree(b->sum_weights);
+       kfree(b->h.perm);
+       kfree(b->h.items);
+       kfree(b);
+}
+
+void crush_destroy_bucket_tree(struct crush_bucket_tree *b)
+{
+       kfree(b->node_weights);
+       kfree(b);
+}
+
+void crush_destroy_bucket_straw(struct crush_bucket_straw *b)
+{
+       kfree(b->straws);
+       kfree(b->item_weights);
+       kfree(b->h.perm);
+       kfree(b->h.items);
+       kfree(b);
+}
+
+void crush_destroy_bucket(struct crush_bucket *b)
+{
+       switch (b->alg) {
+       case CRUSH_BUCKET_UNIFORM:
+               crush_destroy_bucket_uniform((struct crush_bucket_uniform *)b);
+               break;
+       case CRUSH_BUCKET_LIST:
+               crush_destroy_bucket_list((struct crush_bucket_list *)b);
+               break;
+       case CRUSH_BUCKET_TREE:
+               crush_destroy_bucket_tree((struct crush_bucket_tree *)b);
+               break;
+       case CRUSH_BUCKET_STRAW:
+               crush_destroy_bucket_straw((struct crush_bucket_straw *)b);
+               break;
+       }
+}
+
+/**
+ * crush_destroy - Destroy a crush_map
+ * @map: crush_map pointer
+ */
+void crush_destroy(struct crush_map *map)
+{
+       int b;
+
+       /* buckets */
+       if (map->buckets) {
+               for (b = 0; b < map->max_buckets; b++) {
+                       if (map->buckets[b] == NULL)
+                               continue;
+                       crush_destroy_bucket(map->buckets[b]);
+               }
+               kfree(map->buckets);
+       }
+
+       /* rules */
+       if (map->rules) {
+               for (b = 0; b < map->max_rules; b++)
+                       kfree(map->rules[b]);
+               kfree(map->rules);
+       }
+
+       kfree(map->bucket_parents);
+       kfree(map->device_parents);
+       kfree(map);
+}
+
+
diff --git a/fs/ceph/crush/crush.h b/fs/ceph/crush/crush.h
new file mode 100644 (file)
index 0000000..dcd7e75
--- /dev/null
@@ -0,0 +1,180 @@
+#ifndef _CRUSH_CRUSH_H
+#define _CRUSH_CRUSH_H
+
+#include <linux/types.h>
+
+/*
+ * CRUSH is a pseudo-random data distribution algorithm that
+ * efficiently distributes input values (typically, data objects)
+ * across a heterogeneous, structured storage cluster.
+ *
+ * The algorithm was originally described in detail in this paper
+ * (although the algorithm has evolved somewhat since then):
+ *
+ *     http://www.ssrc.ucsc.edu/Papers/weil-sc06.pdf
+ *
+ * LGPL2
+ */
+
+
+#define CRUSH_MAGIC 0x00010000ul   /* for detecting algorithm revisions */
+
+
+#define CRUSH_MAX_DEPTH 10  /* max crush hierarchy depth */
+#define CRUSH_MAX_SET   10  /* max size of a mapping result */
+
+
+/*
+ * CRUSH uses user-defined "rules" to describe how inputs should be
+ * mapped to devices.  A rule consists of sequence of steps to perform
+ * to generate the set of output devices.
+ */
+struct crush_rule_step {
+       __u32 op;
+       __s32 arg1;
+       __s32 arg2;
+};
+
+/* step op codes */
+enum {
+       CRUSH_RULE_NOOP = 0,
+       CRUSH_RULE_TAKE = 1,          /* arg1 = value to start with */
+       CRUSH_RULE_CHOOSE_FIRSTN = 2, /* arg1 = num items to pick */
+                                     /* arg2 = type */
+       CRUSH_RULE_CHOOSE_INDEP = 3,  /* same */
+       CRUSH_RULE_EMIT = 4,          /* no args */
+       CRUSH_RULE_CHOOSE_LEAF_FIRSTN = 6,
+       CRUSH_RULE_CHOOSE_LEAF_INDEP = 7,
+};
+
+/*
+ * for specifying choose num (arg1) relative to the max parameter
+ * passed to do_rule
+ */
+#define CRUSH_CHOOSE_N            0
+#define CRUSH_CHOOSE_N_MINUS(x)   (-(x))
+
+/*
+ * The rule mask is used to describe what the rule is intended for.
+ * Given a ruleset and size of output set, we search through the
+ * rule list for a matching rule_mask.
+ */
+struct crush_rule_mask {
+       __u8 ruleset;
+       __u8 type;
+       __u8 min_size;
+       __u8 max_size;
+};
+
+struct crush_rule {
+       __u32 len;
+       struct crush_rule_mask mask;
+       struct crush_rule_step steps[0];
+};
+
+#define crush_rule_size(len) (sizeof(struct crush_rule) + \
+                             (len)*sizeof(struct crush_rule_step))
+
+
+
+/*
+ * A bucket is a named container of other items (either devices or
+ * other buckets).  Items within a bucket are chosen using one of a
+ * few different algorithms.  The table summarizes how the speed of
+ * each option measures up against mapping stability when items are
+ * added or removed.
+ *
+ *  Bucket Alg     Speed       Additions    Removals
+ *  ------------------------------------------------
+ *  uniform         O(1)       poor         poor
+ *  list            O(n)       optimal      poor
+ *  tree            O(log n)   good         good
+ *  straw           O(n)       optimal      optimal
+ */
+enum {
+       CRUSH_BUCKET_UNIFORM = 1,
+       CRUSH_BUCKET_LIST = 2,
+       CRUSH_BUCKET_TREE = 3,
+       CRUSH_BUCKET_STRAW = 4
+};
+extern const char *crush_bucket_alg_name(int alg);
+
+struct crush_bucket {
+       __s32 id;        /* this'll be negative */
+       __u16 type;      /* non-zero; type=0 is reserved for devices */
+       __u8 alg;        /* one of CRUSH_BUCKET_* */
+       __u8 hash;       /* which hash function to use, CRUSH_HASH_* */
+       __u32 weight;    /* 16-bit fixed point */
+       __u32 size;      /* num items */
+       __s32 *items;
+
+       /*
+        * cached random permutation: used for uniform bucket and for
+        * the linear search fallback for the other bucket types.
+        */
+       __u32 perm_x;  /* @x for which *perm is defined */
+       __u32 perm_n;  /* num elements of *perm that are permuted/defined */
+       __u32 *perm;
+};
+
+struct crush_bucket_uniform {
+       struct crush_bucket h;
+       __u32 item_weight;  /* 16-bit fixed point; all items equally weighted */
+};
+
+struct crush_bucket_list {
+       struct crush_bucket h;
+       __u32 *item_weights;  /* 16-bit fixed point */
+       __u32 *sum_weights;   /* 16-bit fixed point.  element i is sum
+                                of weights 0..i, inclusive */
+};
+
+struct crush_bucket_tree {
+       struct crush_bucket h;  /* note: h.size is _tree_ size, not number of
+                                  actual items */
+       __u8 num_nodes;
+       __u32 *node_weights;
+};
+
+struct crush_bucket_straw {
+       struct crush_bucket h;
+       __u32 *item_weights;   /* 16-bit fixed point */
+       __u32 *straws;         /* 16-bit fixed point */
+};
+
+
+
+/*
+ * CRUSH map includes all buckets, rules, etc.
+ */
+struct crush_map {
+       struct crush_bucket **buckets;
+       struct crush_rule **rules;
+
+       /*
+        * Parent pointers to identify the parent bucket a device or
+        * bucket in the hierarchy.  If an item appears more than
+        * once, this is the _last_ time it appeared (where buckets
+        * are processed in bucket id order, from -1 on down to
+        * -max_buckets.
+        */
+       __u32 *bucket_parents;
+       __u32 *device_parents;
+
+       __s32 max_buckets;
+       __u32 max_rules;
+       __s32 max_devices;
+};
+
+
+/* crush.c */
+extern int crush_get_bucket_item_weight(struct crush_bucket *b, int pos);
+extern void crush_calc_parents(struct crush_map *map);
+extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
+extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
+extern void crush_destroy_bucket_tree(struct crush_bucket_tree *b);
+extern void crush_destroy_bucket_straw(struct crush_bucket_straw *b);
+extern void crush_destroy_bucket(struct crush_bucket *b);
+extern void crush_destroy(struct crush_map *map);
+
+#endif
diff --git a/fs/ceph/crush/hash.c b/fs/ceph/crush/hash.c
new file mode 100644 (file)
index 0000000..5873aed
--- /dev/null
@@ -0,0 +1,149 @@
+
+#include <linux/types.h>
+#include "hash.h"
+
+/*
+ * Robert Jenkins' function for mixing 32-bit values
+ * http://burtleburtle.net/bob/hash/evahash.html
+ * a, b = random bits, c = input and output
+ */
+#define crush_hashmix(a, b, c) do {                    \
+               a = a-b;  a = a-c;  a = a^(c>>13);      \
+               b = b-c;  b = b-a;  b = b^(a<<8);       \
+               c = c-a;  c = c-b;  c = c^(b>>13);      \
+               a = a-b;  a = a-c;  a = a^(c>>12);      \
+               b = b-c;  b = b-a;  b = b^(a<<16);      \
+               c = c-a;  c = c-b;  c = c^(b>>5);       \
+               a = a-b;  a = a-c;  a = a^(c>>3);       \
+               b = b-c;  b = b-a;  b = b^(a<<10);      \
+               c = c-a;  c = c-b;  c = c^(b>>15);      \
+       } while (0)
+
+#define crush_hash_seed 1315423911
+
+static __u32 crush_hash32_rjenkins1(__u32 a)
+{
+       __u32 hash = crush_hash_seed ^ a;
+       __u32 b = a;
+       __u32 x = 231232;
+       __u32 y = 1232;
+       crush_hashmix(b, x, hash);
+       crush_hashmix(y, a, hash);
+       return hash;
+}
+
+static __u32 crush_hash32_rjenkins1_2(__u32 a, __u32 b)
+{
+       __u32 hash = crush_hash_seed ^ a ^ b;
+       __u32 x = 231232;
+       __u32 y = 1232;
+       crush_hashmix(a, b, hash);
+       crush_hashmix(x, a, hash);
+       crush_hashmix(b, y, hash);
+       return hash;
+}
+
+static __u32 crush_hash32_rjenkins1_3(__u32 a, __u32 b, __u32 c)
+{
+       __u32 hash = crush_hash_seed ^ a ^ b ^ c;
+       __u32 x = 231232;
+       __u32 y = 1232;
+       crush_hashmix(a, b, hash);
+       crush_hashmix(c, x, hash);
+       crush_hashmix(y, a, hash);
+       crush_hashmix(b, x, hash);
+       crush_hashmix(y, c, hash);
+       return hash;
+}
+
+static __u32 crush_hash32_rjenkins1_4(__u32 a, __u32 b, __u32 c, __u32 d)
+{
+       __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d;
+       __u32 x = 231232;
+       __u32 y = 1232;
+       crush_hashmix(a, b, hash);
+       crush_hashmix(c, d, hash);
+       crush_hashmix(a, x, hash);
+       crush_hashmix(y, b, hash);
+       crush_hashmix(c, x, hash);
+       crush_hashmix(y, d, hash);
+       return hash;
+}
+
+static __u32 crush_hash32_rjenkins1_5(__u32 a, __u32 b, __u32 c, __u32 d,
+                                     __u32 e)
+{
+       __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d ^ e;
+       __u32 x = 231232;
+       __u32 y = 1232;
+       crush_hashmix(a, b, hash);
+       crush_hashmix(c, d, hash);
+       crush_hashmix(e, x, hash);
+       crush_hashmix(y, a, hash);
+       crush_hashmix(b, x, hash);
+       crush_hashmix(y, c, hash);
+       crush_hashmix(d, x, hash);
+       crush_hashmix(y, e, hash);
+       return hash;
+}
+
+
+__u32 crush_hash32(int type, __u32 a)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return crush_hash32_rjenkins1(a);
+       default:
+               return 0;
+       }
+}
+
+__u32 crush_hash32_2(int type, __u32 a, __u32 b)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return crush_hash32_rjenkins1_2(a, b);
+       default:
+               return 0;
+       }
+}
+
+__u32 crush_hash32_3(int type, __u32 a, __u32 b, __u32 c)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return crush_hash32_rjenkins1_3(a, b, c);
+       default:
+               return 0;
+       }
+}
+
+__u32 crush_hash32_4(int type, __u32 a, __u32 b, __u32 c, __u32 d)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return crush_hash32_rjenkins1_4(a, b, c, d);
+       default:
+               return 0;
+       }
+}
+
+__u32 crush_hash32_5(int type, __u32 a, __u32 b, __u32 c, __u32 d, __u32 e)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return crush_hash32_rjenkins1_5(a, b, c, d, e);
+       default:
+               return 0;
+       }
+}
+
+const char *crush_hash_name(int type)
+{
+       switch (type) {
+       case CRUSH_HASH_RJENKINS1:
+               return "rjenkins1";
+       default:
+               return "unknown";
+       }
+}
diff --git a/fs/ceph/crush/hash.h b/fs/ceph/crush/hash.h
new file mode 100644 (file)
index 0000000..ff48e11
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _CRUSH_HASH_H
+#define _CRUSH_HASH_H
+
+#define CRUSH_HASH_RJENKINS1   0
+
+#define CRUSH_HASH_DEFAULT CRUSH_HASH_RJENKINS1
+
+extern const char *crush_hash_name(int type);
+
+extern __u32 crush_hash32(int type, __u32 a);
+extern __u32 crush_hash32_2(int type, __u32 a, __u32 b);
+extern __u32 crush_hash32_3(int type, __u32 a, __u32 b, __u32 c);
+extern __u32 crush_hash32_4(int type, __u32 a, __u32 b, __u32 c, __u32 d);
+extern __u32 crush_hash32_5(int type, __u32 a, __u32 b, __u32 c, __u32 d,
+                           __u32 e);
+
+#endif
diff --git a/fs/ceph/crush/mapper.c b/fs/ceph/crush/mapper.c
new file mode 100644 (file)
index 0000000..9ba54ef
--- /dev/null
@@ -0,0 +1,596 @@
+
+#ifdef __KERNEL__
+# include <linux/string.h>
+# include <linux/slab.h>
+# include <linux/bug.h>
+# include <linux/kernel.h>
+# ifndef dprintk
+#  define dprintk(args...)
+# endif
+#else
+# include <string.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <assert.h>
+# define BUG_ON(x) assert(!(x))
+# define dprintk(args...) /* printf(args) */
+# define kmalloc(x, f) malloc(x)
+# define kfree(x) free(x)
+#endif
+
+#include "crush.h"
+#include "hash.h"
+
+/*
+ * Implement the core CRUSH mapping algorithm.
+ */
+
+/**
+ * crush_find_rule - find a crush_rule id for a given ruleset, type, and size.
+ * @map: the crush_map
+ * @ruleset: the storage ruleset id (user defined)
+ * @type: storage ruleset type (user defined)
+ * @size: output set size
+ */
+int crush_find_rule(struct crush_map *map, int ruleset, int type, int size)
+{
+       int i;
+
+       for (i = 0; i < map->max_rules; i++) {
+               if (map->rules[i] &&
+                   map->rules[i]->mask.ruleset == ruleset &&
+                   map->rules[i]->mask.type == type &&
+                   map->rules[i]->mask.min_size <= size &&
+                   map->rules[i]->mask.max_size >= size)
+                       return i;
+       }
+       return -1;
+}
+
+
+/*
+ * bucket choose methods
+ *
+ * For each bucket algorithm, we have a "choose" method that, given a
+ * crush input @x and replica position (usually, position in output set) @r,
+ * will produce an item in the bucket.
+ */
+
+/*
+ * Choose based on a random permutation of the bucket.
+ *
+ * We used to use some prime number arithmetic to do this, but it
+ * wasn't very random, and had some other bad behaviors.  Instead, we
+ * calculate an actual random permutation of the bucket members.
+ * Since this is expensive, we optimize for the r=0 case, which
+ * captures the vast majority of calls.
+ */
+static int bucket_perm_choose(struct crush_bucket *bucket,
+                             int x, int r)
+{
+       unsigned pr = r % bucket->size;
+       unsigned i, s;
+
+       /* start a new permutation if @x has changed */
+       if (bucket->perm_x != x || bucket->perm_n == 0) {
+               dprintk("bucket %d new x=%d\n", bucket->id, x);
+               bucket->perm_x = x;
+
+               /* optimize common r=0 case */
+               if (pr == 0) {
+                       s = crush_hash32_3(bucket->hash, x, bucket->id, 0) %
+                               bucket->size;
+                       bucket->perm[0] = s;
+                       bucket->perm_n = 0xffff;   /* magic value, see below */
+                       goto out;
+               }
+
+               for (i = 0; i < bucket->size; i++)
+                       bucket->perm[i] = i;
+               bucket->perm_n = 0;
+       } else if (bucket->perm_n == 0xffff) {
+               /* clean up after the r=0 case above */
+               for (i = 1; i < bucket->size; i++)
+                       bucket->perm[i] = i;
+               bucket->perm[bucket->perm[0]] = 0;
+               bucket->perm_n = 1;
+       }
+
+       /* calculate permutation up to pr */
+       for (i = 0; i < bucket->perm_n; i++)
+               dprintk(" perm_choose have %d: %d\n", i, bucket->perm[i]);
+       while (bucket->perm_n <= pr) {
+               unsigned p = bucket->perm_n;
+               /* no point in swapping the final entry */
+               if (p < bucket->size - 1) {
+                       i = crush_hash32_3(bucket->hash, x, bucket->id, p) %
+                               (bucket->size - p);
+                       if (i) {
+                               unsigned t = bucket->perm[p + i];
+                               bucket->perm[p + i] = bucket->perm[p];
+                               bucket->perm[p] = t;
+                       }
+                       dprintk(" perm_choose swap %d with %d\n", p, p+i);
+               }
+               bucket->perm_n++;
+       }
+       for (i = 0; i < bucket->size; i++)
+               dprintk(" perm_choose  %d: %d\n", i, bucket->perm[i]);
+
+       s = bucket->perm[pr];
+out:
+       dprintk(" perm_choose %d sz=%d x=%d r=%d (%d) s=%d\n", bucket->id,
+               bucket->size, x, r, pr, s);
+       return bucket->items[s];
+}
+
+/* uniform */
+static int bucket_uniform_choose(struct crush_bucket_uniform *bucket,
+                                int x, int r)
+{
+       return bucket_perm_choose(&bucket->h, x, r);
+}
+
+/* list */
+static int bucket_list_choose(struct crush_bucket_list *bucket,
+                             int x, int r)
+{
+       int i;
+
+       for (i = bucket->h.size-1; i >= 0; i--) {
+               __u64 w = crush_hash32_4(bucket->h.hash,x, bucket->h.items[i],
+                                        r, bucket->h.id);
+               w &= 0xffff;
+               dprintk("list_choose i=%d x=%d r=%d item %d weight %x "
+                       "sw %x rand %llx",
+                       i, x, r, bucket->h.items[i], bucket->item_weights[i],
+                       bucket->sum_weights[i], w);
+               w *= bucket->sum_weights[i];
+               w = w >> 16;
+               /*dprintk(" scaled %llx\n", w);*/
+               if (w < bucket->item_weights[i])
+                       return bucket->h.items[i];
+       }
+
+       BUG_ON(1);
+       return 0;
+}
+
+
+/* (binary) tree */
+static int height(int n)
+{
+       int h = 0;
+       while ((n & 1) == 0) {
+               h++;
+               n = n >> 1;
+       }
+       return h;
+}
+
+static int left(int x)
+{
+       int h = height(x);
+       return x - (1 << (h-1));
+}
+
+static int right(int x)
+{
+       int h = height(x);
+       return x + (1 << (h-1));
+}
+
+static int terminal(int x)
+{
+       return x & 1;
+}
+
+static int bucket_tree_choose(struct crush_bucket_tree *bucket,
+                             int x, int r)
+{
+       int n, l;
+       __u32 w;
+       __u64 t;
+
+       /* start at root */
+       n = bucket->num_nodes >> 1;
+
+       while (!terminal(n)) {
+               /* pick point in [0, w) */
+               w = bucket->node_weights[n];
+               t = (__u64)crush_hash32_4(bucket->h.hash, x, n, r,
+                                         bucket->h.id) * (__u64)w;
+               t = t >> 32;
+
+               /* descend to the left or right? */
+               l = left(n);
+               if (t < bucket->node_weights[l])
+                       n = l;
+               else
+                       n = right(n);
+       }
+
+       return bucket->h.items[n >> 1];
+}
+
+
+/* straw */
+
+static int bucket_straw_choose(struct crush_bucket_straw *bucket,
+                              int x, int r)
+{
+       int i;
+       int high = 0;
+       __u64 high_draw = 0;
+       __u64 draw;
+
+       for (i = 0; i < bucket->h.size; i++) {
+               draw = crush_hash32_3(bucket->h.hash, x, bucket->h.items[i], r);
+               draw &= 0xffff;
+               draw *= bucket->straws[i];
+               if (i == 0 || draw > high_draw) {
+                       high = i;
+                       high_draw = draw;
+               }
+       }
+       return bucket->h.items[high];
+}
+
+static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
+{
+       dprintk("choose %d x=%d r=%d\n", in->id, x, r);
+       switch (in->alg) {
+       case CRUSH_BUCKET_UNIFORM:
+               return bucket_uniform_choose((struct crush_bucket_uniform *)in,
+                                         x, r);
+       case CRUSH_BUCKET_LIST:
+               return bucket_list_choose((struct crush_bucket_list *)in,
+                                         x, r);
+       case CRUSH_BUCKET_TREE:
+               return bucket_tree_choose((struct crush_bucket_tree *)in,
+                                         x, r);
+       case CRUSH_BUCKET_STRAW:
+               return bucket_straw_choose((struct crush_bucket_straw *)in,
+                                          x, r);
+       default:
+               BUG_ON(1);
+               return in->items[0];
+       }
+}
+
+/*
+ * true if device is marked "out" (failed, fully offloaded)
+ * of the cluster
+ */
+static int is_out(struct crush_map *map, __u32 *weight, int item, int x)
+{
+       if (weight[item] >= 0x1000)
+               return 0;
+       if (weight[item] == 0)
+               return 1;
+       if ((crush_hash32_2(CRUSH_HASH_RJENKINS1, x, item) & 0xffff)
+           < weight[item])
+               return 0;
+       return 1;
+}
+
+/**
+ * crush_choose - choose numrep distinct items of given type
+ * @map: the crush_map
+ * @bucket: the bucket we are choose an item from
+ * @x: crush input value
+ * @numrep: the number of items to choose
+ * @type: the type of item to choose
+ * @out: pointer to output vector
+ * @outpos: our position in that vector
+ * @firstn: true if choosing "first n" items, false if choosing "indep"
+ * @recurse_to_leaf: true if we want one device under each item of given type
+ * @out2: second output vector for leaf items (if @recurse_to_leaf)
+ */
+static int crush_choose(struct crush_map *map,
+                       struct crush_bucket *bucket,
+                       __u32 *weight,
+                       int x, int numrep, int type,
+                       int *out, int outpos,
+                       int firstn, int recurse_to_leaf,
+                       int *out2)
+{
+       int rep;
+       int ftotal, flocal;
+       int retry_descent, retry_bucket, skip_rep;
+       struct crush_bucket *in = bucket;
+       int r;
+       int i;
+       int item = 0;
+       int itemtype;
+       int collide, reject;
+       const int orig_tries = 5; /* attempts before we fall back to search */
+       dprintk("choose bucket %d x %d outpos %d\n", bucket->id, x, outpos);
+
+       for (rep = outpos; rep < numrep; rep++) {
+               /* keep trying until we get a non-out, non-colliding item */
+               ftotal = 0;
+               skip_rep = 0;
+               do {
+                       retry_descent = 0;
+                       in = bucket;               /* initial bucket */
+
+                       /* choose through intervening buckets */
+                       flocal = 0;
+                       do {
+                               collide = 0;
+                               retry_bucket = 0;
+                               r = rep;
+                               if (in->alg == CRUSH_BUCKET_UNIFORM) {
+                                       /* be careful */
+                                       if (firstn || numrep >= in->size)
+                                               /* r' = r + f_total */
+                                               r += ftotal;
+                                       else if (in->size % numrep == 0)
+                                               /* r'=r+(n+1)*f_local */
+                                               r += (numrep+1) *
+                                                       (flocal+ftotal);
+                                       else
+                                               /* r' = r + n*f_local */
+                                               r += numrep * (flocal+ftotal);
+                               } else {
+                                       if (firstn)
+                                               /* r' = r + f_total */
+                                               r += ftotal;
+                                       else
+                                               /* r' = r + n*f_local */
+                                               r += numrep * (flocal+ftotal);
+                               }
+
+                               /* bucket choose */
+                               if (in->size == 0) {
+                                       reject = 1;
+                                       goto reject;
+                               }
+                               if (flocal >= (in->size>>1) &&
+                                   flocal > orig_tries)
+                                       item = bucket_perm_choose(in, x, r);
+                               else
+                                       item = crush_bucket_choose(in, x, r);
+                               BUG_ON(item >= map->max_devices);
+
+                               /* desired type? */
+                               if (item < 0)
+                                       itemtype = map->buckets[-1-item]->type;
+                               else
+                                       itemtype = 0;
+                               dprintk("  item %d type %d\n", item, itemtype);
+
+                               /* keep going? */
+                               if (itemtype != type) {
+                                       BUG_ON(item >= 0 ||
+                                              (-1-item) >= map->max_buckets);
+                                       in = map->buckets[-1-item];
+                                       continue;
+                               }
+
+                               /* collision? */
+                               for (i = 0; i < outpos; i++) {
+                                       if (out[i] == item) {
+                                               collide = 1;
+                                               break;
+                                       }
+                               }
+
+                               if (recurse_to_leaf &&
+                                   item < 0 &&
+                                   crush_choose(map, map->buckets[-1-item],
+                                                weight,
+                                                x, outpos+1, 0,
+                                                out2, outpos,
+                                                firstn, 0, NULL) <= outpos) {
+                                       reject = 1;
+                               } else {
+                                       /* out? */
+                                       if (itemtype == 0)
+                                               reject = is_out(map, weight,
+                                                               item, x);
+                                       else
+                                               reject = 0;
+                               }
+
+reject:
+                               if (reject || collide) {
+                                       ftotal++;
+                                       flocal++;
+
+                                       if (collide && flocal < 3)
+                                               /* retry locally a few times */
+                                               retry_bucket = 1;
+                                       else if (flocal < in->size + orig_tries)
+                                               /* exhaustive bucket search */
+                                               retry_bucket = 1;
+                                       else if (ftotal < 20)
+                                               /* then retry descent */
+                                               retry_descent = 1;
+                                       else
+                                               /* else give up */
+                                               skip_rep = 1;
+                                       dprintk("  reject %d  collide %d  "
+                                               "ftotal %d  flocal %d\n",
+                                               reject, collide, ftotal,
+                                               flocal);
+                               }
+                       } while (retry_bucket);
+               } while (retry_descent);
+
+               if (skip_rep) {
+                       dprintk("skip rep\n");
+                       continue;
+               }
+
+               dprintk("choose got %d\n", item);
+               out[outpos] = item;
+               outpos++;
+       }
+
+       dprintk("choose returns %d\n", outpos);
+       return outpos;
+}
+
+
+/**
+ * crush_do_rule - calculate a mapping with the given input and rule
+ * @map: the crush_map
+ * @ruleno: the rule id
+ * @x: hash input
+ * @result: pointer to result vector
+ * @result_max: maximum result size
+ * @force: force initial replica choice; -1 for none
+ */
+int crush_do_rule(struct crush_map *map,
+                 int ruleno, int x, int *result, int result_max,
+                 int force, __u32 *weight)
+{
+       int result_len;
+       int force_context[CRUSH_MAX_DEPTH];
+       int force_pos = -1;
+       int a[CRUSH_MAX_SET];
+       int b[CRUSH_MAX_SET];
+       int c[CRUSH_MAX_SET];
+       int recurse_to_leaf;
+       int *w;
+       int wsize = 0;
+       int *o;
+       int osize;
+       int *tmp;
+       struct crush_rule *rule;
+       int step;
+       int i, j;
+       int numrep;
+       int firstn;
+       int rc = -1;
+
+       BUG_ON(ruleno >= map->max_rules);
+
+       rule = map->rules[ruleno];
+       result_len = 0;
+       w = a;
+       o = b;
+
+       /*
+        * determine hierarchical context of force, if any.  note
+        * that this may or may not correspond to the specific types
+        * referenced by the crush rule.
+        */
+       if (force >= 0) {
+               if (force >= map->max_devices ||
+                   map->device_parents[force] == 0) {
+                       /*dprintk("CRUSH: forcefed device dne\n");*/
+                       rc = -1;  /* force fed device dne */
+                       goto out;
+               }
+               if (!is_out(map, weight, force, x)) {
+                       while (1) {
+                               force_context[++force_pos] = force;
+                               if (force >= 0)
+                                       force = map->device_parents[force];
+                               else
+                                       force = map->bucket_parents[-1-force];
+                               if (force == 0)
+                                       break;
+                       }
+               }
+       }
+
+       for (step = 0; step < rule->len; step++) {
+               firstn = 0;
+               switch (rule->steps[step].op) {
+               case CRUSH_RULE_TAKE:
+                       w[0] = rule->steps[step].arg1;
+                       if (force_pos >= 0) {
+                               BUG_ON(force_context[force_pos] != w[0]);
+                               force_pos--;
+                       }
+                       wsize = 1;
+                       break;
+
+               case CRUSH_RULE_CHOOSE_LEAF_FIRSTN:
+               case CRUSH_RULE_CHOOSE_FIRSTN:
+                       firstn = 1;
+               case CRUSH_RULE_CHOOSE_LEAF_INDEP:
+               case CRUSH_RULE_CHOOSE_INDEP:
+                       BUG_ON(wsize == 0);
+
+                       recurse_to_leaf =
+                               rule->steps[step].op ==
+                                CRUSH_RULE_CHOOSE_LEAF_FIRSTN ||
+                               rule->steps[step].op ==
+                               CRUSH_RULE_CHOOSE_LEAF_INDEP;
+
+                       /* reset output */
+                       osize = 0;
+
+                       for (i = 0; i < wsize; i++) {
+                               /*
+                                * see CRUSH_N, CRUSH_N_MINUS macros.
+                                * basically, numrep <= 0 means relative to
+                                * the provided result_max
+                                */
+                               numrep = rule->steps[step].arg1;
+                               if (numrep <= 0) {
+                                       numrep += result_max;
+                                       if (numrep <= 0)
+                                               continue;
+                               }
+                               j = 0;
+                               if (osize == 0 && force_pos >= 0) {
+                                       /* skip any intermediate types */
+                                       while (force_pos &&
+                                              force_context[force_pos] < 0 &&
+                                              rule->steps[step].arg2 !=
+                                              map->buckets[-1 -
+                                              force_context[force_pos]]->type)
+                                               force_pos--;
+                                       o[osize] = force_context[force_pos];
+                                       if (recurse_to_leaf)
+                                               c[osize] = force_context[0];
+                                       j++;
+                                       force_pos--;
+                               }
+                               osize += crush_choose(map,
+                                                     map->buckets[-1-w[i]],
+                                                     weight,
+                                                     x, numrep,
+                                                     rule->steps[step].arg2,
+                                                     o+osize, j,
+                                                     firstn,
+                                                     recurse_to_leaf, c+osize);
+                       }
+
+                       if (recurse_to_leaf)
+                               /* copy final _leaf_ values to output set */
+                               memcpy(o, c, osize*sizeof(*o));
+
+                       /* swap t and w arrays */
+                       tmp = o;
+                       o = w;
+                       w = tmp;
+                       wsize = osize;
+                       break;
+
+
+               case CRUSH_RULE_EMIT:
+                       for (i = 0; i < wsize && result_len < result_max; i++) {
+                               result[result_len] = w[i];
+                               result_len++;
+                       }
+                       wsize = 0;
+                       break;
+
+               default:
+                       BUG_ON(1);
+               }
+       }
+       rc = result_len;
+
+out:
+       return rc;
+}
+
+
diff --git a/fs/ceph/crush/mapper.h b/fs/ceph/crush/mapper.h
new file mode 100644 (file)
index 0000000..98e9004
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _CRUSH_MAPPER_H
+#define _CRUSH_MAPPER_H
+
+/*
+ * CRUSH functions for find rules and then mapping an input to an
+ * output set.
+ *
+ * LGPL2
+ */
+
+#include "crush.h"
+
+extern int crush_find_rule(struct crush_map *map, int pool, int type, int size);
+extern int crush_do_rule(struct crush_map *map,
+                        int ruleno,
+                        int x, int *result, int result_max,
+                        int forcefeed,    /* -1 for none */
+                        __u32 *weights);
+
+#endif
diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
new file mode 100644 (file)
index 0000000..f704b3b
--- /dev/null
@@ -0,0 +1,409 @@
+
+#include "ceph_debug.h"
+
+#include <linux/err.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <crypto/hash.h>
+
+#include "crypto.h"
+#include "decode.h"
+
+int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end)
+{
+       if (*p + sizeof(u16) + sizeof(key->created) +
+           sizeof(u16) + key->len > end)
+               return -ERANGE;
+       ceph_encode_16(p, key->type);
+       ceph_encode_copy(p, &key->created, sizeof(key->created));
+       ceph_encode_16(p, key->len);
+       ceph_encode_copy(p, key->key, key->len);
+       return 0;
+}
+
+int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end)
+{
+       ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
+       key->type = ceph_decode_16(p);
+       ceph_decode_copy(p, &key->created, sizeof(key->created));
+       key->len = ceph_decode_16(p);
+       ceph_decode_need(p, end, key->len, bad);
+       key->key = kmalloc(key->len, GFP_NOFS);
+       if (!key->key)
+               return -ENOMEM;
+       ceph_decode_copy(p, key->key, key->len);
+       return 0;
+
+bad:
+       dout("failed to decode crypto key\n");
+       return -EINVAL;
+}
+
+int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
+{
+       int inlen = strlen(inkey);
+       int blen = inlen * 3 / 4;
+       void *buf, *p;
+       int ret;
+
+       dout("crypto_key_unarmor %s\n", inkey);
+       buf = kmalloc(blen, GFP_NOFS);
+       if (!buf)
+               return -ENOMEM;
+       blen = ceph_unarmor(buf, inkey, inkey+inlen);
+       if (blen < 0) {
+               kfree(buf);
+               return blen;
+       }
+
+       p = buf;
+       ret = ceph_crypto_key_decode(key, &p, p + blen);
+       kfree(buf);
+       if (ret)
+               return ret;
+       dout("crypto_key_unarmor key %p type %d len %d\n", key,
+            key->type, key->len);
+       return 0;
+}
+
+
+
+#define AES_KEY_SIZE 16
+
+static struct crypto_blkcipher *ceph_crypto_alloc_cipher(void)
+{
+       return crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC);
+}
+
+const u8 *aes_iv = "cephsageyudagreg";
+
+int ceph_aes_encrypt(const void *key, int key_len, void *dst, size_t *dst_len,
+                    const void *src, size_t src_len)
+{
+       struct scatterlist sg_in[2], sg_out[1];
+       struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
+       struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 };
+       int ret;
+       void *iv;
+       int ivsize;
+       size_t zero_padding = (0x10 - (src_len & 0x0f));
+       char pad[16];
+
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       memset(pad, zero_padding, zero_padding);
+
+       *dst_len = src_len + zero_padding;
+
+       crypto_blkcipher_setkey((void *)tfm, key, key_len);
+       sg_init_table(sg_in, 2);
+       sg_set_buf(&sg_in[0], src, src_len);
+       sg_set_buf(&sg_in[1], pad, zero_padding);
+       sg_init_table(sg_out, 1);
+       sg_set_buf(sg_out, dst, *dst_len);
+       iv = crypto_blkcipher_crt(tfm)->iv;
+       ivsize = crypto_blkcipher_ivsize(tfm);
+
+       memcpy(iv, aes_iv, ivsize);
+       /*
+       print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1,
+                      key, key_len, 1);
+       print_hex_dump(KERN_ERR, "enc src: ", DUMP_PREFIX_NONE, 16, 1,
+                       src, src_len, 1);
+       print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1,
+                       pad, zero_padding, 1);
+       */
+       ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
+                                    src_len + zero_padding);
+       crypto_free_blkcipher(tfm);
+       if (ret < 0)
+               pr_err("ceph_aes_crypt failed %d\n", ret);
+       /*
+       print_hex_dump(KERN_ERR, "enc out: ", DUMP_PREFIX_NONE, 16, 1,
+                      dst, *dst_len, 1);
+       */
+       return 0;
+}
+
+int ceph_aes_encrypt2(const void *key, int key_len, void *dst, size_t *dst_len,
+                     const void *src1, size_t src1_len,
+                     const void *src2, size_t src2_len)
+{
+       struct scatterlist sg_in[3], sg_out[1];
+       struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
+       struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 };
+       int ret;
+       void *iv;
+       int ivsize;
+       size_t zero_padding = (0x10 - ((src1_len + src2_len) & 0x0f));
+       char pad[16];
+
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       memset(pad, zero_padding, zero_padding);
+
+       *dst_len = src1_len + src2_len + zero_padding;
+
+       crypto_blkcipher_setkey((void *)tfm, key, key_len);
+       sg_init_table(sg_in, 3);
+       sg_set_buf(&sg_in[0], src1, src1_len);
+       sg_set_buf(&sg_in[1], src2, src2_len);
+       sg_set_buf(&sg_in[2], pad, zero_padding);
+       sg_init_table(sg_out, 1);
+       sg_set_buf(sg_out, dst, *dst_len);
+       iv = crypto_blkcipher_crt(tfm)->iv;
+       ivsize = crypto_blkcipher_ivsize(tfm);
+
+       memcpy(iv, aes_iv, ivsize);
+       /*
+       print_hex_dump(KERN_ERR, "enc  key: ", DUMP_PREFIX_NONE, 16, 1,
+                      key, key_len, 1);
+       print_hex_dump(KERN_ERR, "enc src1: ", DUMP_PREFIX_NONE, 16, 1,
+                       src1, src1_len, 1);
+       print_hex_dump(KERN_ERR, "enc src2: ", DUMP_PREFIX_NONE, 16, 1,
+                       src2, src2_len, 1);
+       print_hex_dump(KERN_ERR, "enc  pad: ", DUMP_PREFIX_NONE, 16, 1,
+                       pad, zero_padding, 1);
+       */
+       ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
+                                    src1_len + src2_len + zero_padding);
+       crypto_free_blkcipher(tfm);
+       if (ret < 0)
+               pr_err("ceph_aes_crypt2 failed %d\n", ret);
+       /*
+       print_hex_dump(KERN_ERR, "enc  out: ", DUMP_PREFIX_NONE, 16, 1,
+                      dst, *dst_len, 1);
+       */
+       return 0;
+}
+
+int ceph_aes_decrypt(const void *key, int key_len, void *dst, size_t *dst_len,
+                    const void *src, size_t src_len)
+{
+       struct scatterlist sg_in[1], sg_out[2];
+       struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
+       struct blkcipher_desc desc = { .tfm = tfm };
+       char pad[16];
+       void *iv;
+       int ivsize;
+       int ret;
+       int last_byte;
+
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       crypto_blkcipher_setkey((void *)tfm, key, key_len);
+       sg_init_table(sg_in, 1);
+       sg_init_table(sg_out, 2);
+       sg_set_buf(sg_in, src, src_len);
+       sg_set_buf(&sg_out[0], dst, *dst_len);
+       sg_set_buf(&sg_out[1], pad, sizeof(pad));
+
+       iv = crypto_blkcipher_crt(tfm)->iv;
+       ivsize = crypto_blkcipher_ivsize(tfm);
+
+       memcpy(iv, aes_iv, ivsize);
+
+       /*
+       print_hex_dump(KERN_ERR, "dec key: ", DUMP_PREFIX_NONE, 16, 1,
+                      key, key_len, 1);
+       print_hex_dump(KERN_ERR, "dec  in: ", DUMP_PREFIX_NONE, 16, 1,
+                      src, src_len, 1);
+       */
+
+       ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, src_len);
+       crypto_free_blkcipher(tfm);
+       if (ret < 0) {
+               pr_err("ceph_aes_decrypt failed %d\n", ret);
+               return ret;
+       }
+
+       if (src_len <= *dst_len)
+               last_byte = ((char *)dst)[src_len - 1];
+       else
+               last_byte = pad[src_len - *dst_len - 1];
+       if (last_byte <= 16 && src_len >= last_byte) {
+               *dst_len = src_len - last_byte;
+       } else {
+               pr_err("ceph_aes_decrypt got bad padding %d on src len %d\n",
+                      last_byte, (int)src_len);
+               return -EPERM;  /* bad padding */
+       }
+       /*
+       print_hex_dump(KERN_ERR, "dec out: ", DUMP_PREFIX_NONE, 16, 1,
+                      dst, *dst_len, 1);
+       */
+       return 0;
+}
+
+int ceph_aes_decrypt2(const void *key, int key_len,
+                     void *dst1, size_t *dst1_len,
+                     void *dst2, size_t *dst2_len,
+                     const void *src, size_t src_len)
+{
+       struct scatterlist sg_in[1], sg_out[3];
+       struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
+       struct blkcipher_desc desc = { .tfm = tfm };
+       char pad[16];
+       void *iv;
+       int ivsize;
+       int ret;
+       int last_byte;
+
+       if (IS_ERR(tfm))
+               return PTR_ERR(tfm);
+
+       sg_init_table(sg_in, 1);
+       sg_set_buf(sg_in, src, src_len);
+       sg_init_table(sg_out, 3);
+       sg_set_buf(&sg_out[0], dst1, *dst1_len);
+       sg_set_buf(&sg_out[1], dst2, *dst2_len);
+       sg_set_buf(&sg_out[2], pad, sizeof(pad));
+
+       crypto_blkcipher_setkey((void *)tfm, key, key_len);
+       iv = crypto_blkcipher_crt(tfm)->iv;
+       ivsize = crypto_blkcipher_ivsize(tfm);
+
+       memcpy(iv, aes_iv, ivsize);
+
+       /*
+       print_hex_dump(KERN_ERR, "dec  key: ", DUMP_PREFIX_NONE, 16, 1,
+                      key, key_len, 1);
+       print_hex_dump(KERN_ERR, "dec   in: ", DUMP_PREFIX_NONE, 16, 1,
+                      src, src_len, 1);
+       */
+
+       ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, src_len);
+       crypto_free_blkcipher(tfm);
+       if (ret < 0) {
+               pr_err("ceph_aes_decrypt failed %d\n", ret);
+               return ret;
+       }
+
+       if (src_len <= *dst1_len)
+               last_byte = ((char *)dst1)[src_len - 1];
+       else if (src_len <= *dst1_len + *dst2_len)
+               last_byte = ((char *)dst2)[src_len - *dst1_len - 1];
+       else
+               last_byte = pad[src_len - *dst1_len - *dst2_len - 1];
+       if (last_byte <= 16 && src_len >= last_byte) {
+               src_len -= last_byte;
+       } else {
+               pr_err("ceph_aes_decrypt got bad padding %d on src len %d\n",
+                      last_byte, (int)src_len);
+               return -EPERM;  /* bad padding */
+       }
+
+       if (src_len < *dst1_len) {
+               *dst1_len = src_len;
+               *dst2_len = 0;
+       } else {
+               *dst2_len = src_len - *dst1_len;
+       }
+       /*
+       print_hex_dump(KERN_ERR, "dec  out1: ", DUMP_PREFIX_NONE, 16, 1,
+                      dst1, *dst1_len, 1);
+       print_hex_dump(KERN_ERR, "dec  out2: ", DUMP_PREFIX_NONE, 16, 1,
+                      dst2, *dst2_len, 1);
+       */
+
+       return 0;
+}
+
+
+int ceph_decrypt(struct ceph_crypto_key *secret, void *dst, size_t *dst_len,
+                const void *src, size_t src_len)
+{
+       switch (secret->type) {
+       case CEPH_CRYPTO_NONE:
+               if (*dst_len < src_len)
+                       return -ERANGE;
+               memcpy(dst, src, src_len);
+               *dst_len = src_len;
+               return 0;
+
+       case CEPH_CRYPTO_AES:
+               return ceph_aes_decrypt(secret->key, secret->len, dst,
+                                       dst_len, src, src_len);
+
+       default:
+               return -EINVAL;
+       }
+}
+
+int ceph_decrypt2(struct ceph_crypto_key *secret,
+                       void *dst1, size_t *dst1_len,
+                       void *dst2, size_t *dst2_len,
+                       const void *src, size_t src_len)
+{
+       size_t t;
+
+       switch (secret->type) {
+       case CEPH_CRYPTO_NONE:
+               if (*dst1_len + *dst2_len < src_len)
+                       return -ERANGE;
+               t = min(*dst1_len, src_len);
+               memcpy(dst1, src, t);
+               *dst1_len = t;
+               src += t;
+               src_len -= t;
+               if (src_len) {
+                       t = min(*dst2_len, src_len);
+                       memcpy(dst2, src, t);
+                       *dst2_len = t;
+               }
+               return 0;
+
+       case CEPH_CRYPTO_AES:
+               return ceph_aes_decrypt2(secret->key, secret->len,
+                                        dst1, dst1_len, dst2, dst2_len,
+                                        src, src_len);
+
+       default:
+               return -EINVAL;
+       }
+}
+
+int ceph_encrypt(struct ceph_crypto_key *secret, void *dst, size_t *dst_len,
+                const void *src, size_t src_len)
+{
+       switch (secret->type) {
+       case CEPH_CRYPTO_NONE:
+               if (*dst_len < src_len)
+                       return -ERANGE;
+               memcpy(dst, src, src_len);
+               *dst_len = src_len;
+               return 0;
+
+       case CEPH_CRYPTO_AES:
+               return ceph_aes_encrypt(secret->key, secret->len, dst,
+                                       dst_len, src, src_len);
+
+       default:
+               return -EINVAL;
+       }
+}
+
+int ceph_encrypt2(struct ceph_crypto_key *secret, void *dst, size_t *dst_len,
+                 const void *src1, size_t src1_len,
+                 const void *src2, size_t src2_len)
+{
+       switch (secret->type) {
+       case CEPH_CRYPTO_NONE:
+               if (*dst_len < src1_len + src2_len)
+                       return -ERANGE;
+               memcpy(dst, src1, src1_len);
+               memcpy(dst + src1_len, src2, src2_len);
+               *dst_len = src1_len + src2_len;
+               return 0;
+
+       case CEPH_CRYPTO_AES:
+               return ceph_aes_encrypt2(secret->key, secret->len, dst, dst_len,
+                                        src1, src1_len, src2, src2_len);
+
+       default:
+               return -EINVAL;
+       }
+}
diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h
new file mode 100644 (file)
index 0000000..40b502e
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef _FS_CEPH_CRYPTO_H
+#define _FS_CEPH_CRYPTO_H
+
+#include "types.h"
+#include "buffer.h"
+
+/*
+ * cryptographic secret
+ */
+struct ceph_crypto_key {
+       int type;
+       struct ceph_timespec created;
+       int len;
+       void *key;
+};
+
+static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key)
+{
+       kfree(key->key);
+}
+
+extern int ceph_crypto_key_encode(struct ceph_crypto_key *key,
+                                 void **p, void *end);
+extern int ceph_crypto_key_decode(struct ceph_crypto_key *key,
+                                 void **p, void *end);
+extern int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
+
+/* crypto.c */
+extern int ceph_decrypt(struct ceph_crypto_key *secret,
+                       void *dst, size_t *dst_len,
+                       const void *src, size_t src_len);
+extern int ceph_encrypt(struct ceph_crypto_key *secret,
+                       void *dst, size_t *dst_len,
+                       const void *src, size_t src_len);
+extern int ceph_decrypt2(struct ceph_crypto_key *secret,
+                       void *dst1, size_t *dst1_len,
+                       void *dst2, size_t *dst2_len,
+                       const void *src, size_t src_len);
+extern int ceph_encrypt2(struct ceph_crypto_key *secret,
+                        void *dst, size_t *dst_len,
+                        const void *src1, size_t src1_len,
+                        const void *src2, size_t src2_len);
+
+/* armor.c */
+extern int ceph_armor(char *dst, const void *src, const void *end);
+extern int ceph_unarmor(void *dst, const char *src, const char *end);
+
+#endif
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c
new file mode 100644 (file)
index 0000000..f7048da
--- /dev/null
@@ -0,0 +1,484 @@
+#include "ceph_debug.h"
+
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+#include "super.h"
+#include "mds_client.h"
+#include "mon_client.h"
+#include "auth.h"
+
+#ifdef CONFIG_DEBUG_FS
+
+/*
+ * Implement /sys/kernel/debug/ceph fun
+ *
+ * /sys/kernel/debug/ceph/client*  - an instance of the ceph client
+ *      .../osdmap      - current osdmap
+ *      .../mdsmap      - current mdsmap
+ *      .../monmap      - current monmap
+ *      .../osdc        - active osd requests
+ *      .../mdsc        - active mds requests
+ *      .../monc        - mon client state
+ *      .../dentry_lru  - dump contents of dentry lru
+ *      .../caps        - expose cap (reservation) stats
+ *      .../bdi         - symlink to ../../bdi/something
+ */
+
+static struct dentry *ceph_debugfs_dir;
+
+static int monmap_show(struct seq_file *s, void *p)
+{
+       int i;
+       struct ceph_client *client = s->private;
+
+       if (client->monc.monmap == NULL)
+               return 0;
+
+       seq_printf(s, "epoch %d\n", client->monc.monmap->epoch);
+       for (i = 0; i < client->monc.monmap->num_mon; i++) {
+               struct ceph_entity_inst *inst =
+                       &client->monc.monmap->mon_inst[i];
+
+               seq_printf(s, "\t%s%lld\t%s\n",
+                          ENTITY_NAME(inst->name),
+                          pr_addr(&inst->addr.in_addr));
+       }
+       return 0;
+}
+
+static int mdsmap_show(struct seq_file *s, void *p)
+{
+       int i;
+       struct ceph_client *client = s->private;
+
+       if (client->mdsc.mdsmap == NULL)
+               return 0;
+       seq_printf(s, "epoch %d\n", client->mdsc.mdsmap->m_epoch);
+       seq_printf(s, "root %d\n", client->mdsc.mdsmap->m_root);
+       seq_printf(s, "session_timeout %d\n",
+                      client->mdsc.mdsmap->m_session_timeout);
+       seq_printf(s, "session_autoclose %d\n",
+                      client->mdsc.mdsmap->m_session_autoclose);
+       for (i = 0; i < client->mdsc.mdsmap->m_max_mds; i++) {
+               struct ceph_entity_addr *addr =
+                       &client->mdsc.mdsmap->m_info[i].addr;
+               int state = client->mdsc.mdsmap->m_info[i].state;
+
+               seq_printf(s, "\tmds%d\t%s\t(%s)\n", i, pr_addr(&addr->in_addr),
+                              ceph_mds_state_name(state));
+       }
+       return 0;
+}
+
+static int osdmap_show(struct seq_file *s, void *p)
+{
+       int i;
+       struct ceph_client *client = s->private;
+       struct rb_node *n;
+
+       if (client->osdc.osdmap == NULL)
+               return 0;
+       seq_printf(s, "epoch %d\n", client->osdc.osdmap->epoch);
+       seq_printf(s, "flags%s%s\n",
+                  (client->osdc.osdmap->flags & CEPH_OSDMAP_NEARFULL) ?
+                  " NEARFULL" : "",
+                  (client->osdc.osdmap->flags & CEPH_OSDMAP_FULL) ?
+                  " FULL" : "");
+       for (n = rb_first(&client->osdc.osdmap->pg_pools); n; n = rb_next(n)) {
+               struct ceph_pg_pool_info *pool =
+                       rb_entry(n, struct ceph_pg_pool_info, node);
+               seq_printf(s, "pg_pool %d pg_num %d / %d, lpg_num %d / %d\n",
+                          pool->id, pool->v.pg_num, pool->pg_num_mask,
+                          pool->v.lpg_num, pool->lpg_num_mask);
+       }
+       for (i = 0; i < client->osdc.osdmap->max_osd; i++) {
+               struct ceph_entity_addr *addr =
+                       &client->osdc.osdmap->osd_addr[i];
+               int state = client->osdc.osdmap->osd_state[i];
+               char sb[64];
+
+               seq_printf(s, "\tosd%d\t%s\t%3d%%\t(%s)\n",
+                          i, pr_addr(&addr->in_addr),
+                          ((client->osdc.osdmap->osd_weight[i]*100) >> 16),
+                          ceph_osdmap_state_str(sb, sizeof(sb), state));
+       }
+       return 0;
+}
+
+static int monc_show(struct seq_file *s, void *p)
+{
+       struct ceph_client *client = s->private;
+       struct ceph_mon_statfs_request *req;
+       struct ceph_mon_client *monc = &client->monc;
+       struct rb_node *rp;
+
+       mutex_lock(&monc->mutex);
+
+       if (monc->have_mdsmap)
+               seq_printf(s, "have mdsmap %u\n", (unsigned)monc->have_mdsmap);
+       if (monc->have_osdmap)
+               seq_printf(s, "have osdmap %u\n", (unsigned)monc->have_osdmap);
+       if (monc->want_next_osdmap)
+               seq_printf(s, "want next osdmap\n");
+
+       for (rp = rb_first(&monc->statfs_request_tree); rp; rp = rb_next(rp)) {
+               req = rb_entry(rp, struct ceph_mon_statfs_request, node);
+               seq_printf(s, "%lld statfs\n", req->tid);
+       }
+
+       mutex_unlock(&monc->mutex);
+       return 0;
+}
+
+static int mdsc_show(struct seq_file *s, void *p)
+{
+       struct ceph_client *client = s->private;
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       struct rb_node *rp;
+       int pathlen;
+       u64 pathbase;
+       char *path;
+
+       mutex_lock(&mdsc->mutex);
+       for (rp = rb_first(&mdsc->request_tree); rp; rp = rb_next(rp)) {
+               req = rb_entry(rp, struct ceph_mds_request, r_node);
+
+               if (req->r_request)
+                       seq_printf(s, "%lld\tmds%d\t", req->r_tid, req->r_mds);
+               else
+                       seq_printf(s, "%lld\t(no request)\t", req->r_tid);
+
+               seq_printf(s, "%s", ceph_mds_op_name(req->r_op));
+
+               if (req->r_got_unsafe)
+                       seq_printf(s, "\t(unsafe)");
+               else
+                       seq_printf(s, "\t");
+
+               if (req->r_inode) {
+                       seq_printf(s, " #%llx", ceph_ino(req->r_inode));
+               } else if (req->r_dentry) {
+                       path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
+                                                   &pathbase, 0);
+                       spin_lock(&req->r_dentry->d_lock);
+                       seq_printf(s, " #%llx/%.*s (%s)",
+                                  ceph_ino(req->r_dentry->d_parent->d_inode),
+                                  req->r_dentry->d_name.len,
+                                  req->r_dentry->d_name.name,
+                                  path ? path : "");
+                       spin_unlock(&req->r_dentry->d_lock);
+                       kfree(path);
+               } else if (req->r_path1) {
+                       seq_printf(s, " #%llx/%s", req->r_ino1.ino,
+                                  req->r_path1);
+               }
+
+               if (req->r_old_dentry) {
+                       path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen,
+                                                   &pathbase, 0);
+                       spin_lock(&req->r_old_dentry->d_lock);
+                       seq_printf(s, " #%llx/%.*s (%s)",
+                          ceph_ino(req->r_old_dentry->d_parent->d_inode),
+                                  req->r_old_dentry->d_name.len,
+                                  req->r_old_dentry->d_name.name,
+                                  path ? path : "");
+                       spin_unlock(&req->r_old_dentry->d_lock);
+                       kfree(path);
+               } else if (req->r_path2) {
+                       if (req->r_ino2.ino)
+                               seq_printf(s, " #%llx/%s", req->r_ino2.ino,
+                                          req->r_path2);
+                       else
+                               seq_printf(s, " %s", req->r_path2);
+               }
+
+               seq_printf(s, "\n");
+       }
+       mutex_unlock(&mdsc->mutex);
+
+       return 0;
+}
+
+static int osdc_show(struct seq_file *s, void *pp)
+{
+       struct ceph_client *client = s->private;
+       struct ceph_osd_client *osdc = &client->osdc;
+       struct rb_node *p;
+
+       mutex_lock(&osdc->request_mutex);
+       for (p = rb_first(&osdc->requests); p; p = rb_next(p)) {
+               struct ceph_osd_request *req;
+               struct ceph_osd_request_head *head;
+               struct ceph_osd_op *op;
+               int num_ops;
+               int opcode, olen;
+               int i;
+
+               req = rb_entry(p, struct ceph_osd_request, r_node);
+
+               seq_printf(s, "%lld\tosd%d\t%d.%x\t", req->r_tid,
+                          req->r_osd ? req->r_osd->o_osd : -1,
+                          le32_to_cpu(req->r_pgid.pool),
+                          le16_to_cpu(req->r_pgid.ps));
+
+               head = req->r_request->front.iov_base;
+               op = (void *)(head + 1);
+
+               num_ops = le16_to_cpu(head->num_ops);
+               olen = le32_to_cpu(head->object_len);
+               seq_printf(s, "%.*s", olen,
+                          (const char *)(head->ops + num_ops));
+
+               if (req->r_reassert_version.epoch)
+                       seq_printf(s, "\t%u'%llu",
+                          (unsigned)le32_to_cpu(req->r_reassert_version.epoch),
+                          le64_to_cpu(req->r_reassert_version.version));
+               else
+                       seq_printf(s, "\t");
+
+               for (i = 0; i < num_ops; i++) {
+                       opcode = le16_to_cpu(op->op);
+                       seq_printf(s, "\t%s", ceph_osd_op_name(opcode));
+                       op++;
+               }
+
+               seq_printf(s, "\n");
+       }
+       mutex_unlock(&osdc->request_mutex);
+       return 0;
+}
+
+static int caps_show(struct seq_file *s, void *p)
+{
+       struct ceph_client *client = p;
+       int total, avail, used, reserved, min;
+
+       ceph_reservation_status(client, &total, &avail, &used, &reserved, &min);
+       seq_printf(s, "total\t\t%d\n"
+                  "avail\t\t%d\n"
+                  "used\t\t%d\n"
+                  "reserved\t%d\n"
+                  "min\t%d\n",
+                  total, avail, used, reserved, min);
+       return 0;
+}
+
+static int dentry_lru_show(struct seq_file *s, void *ptr)
+{
+       struct ceph_client *client = s->private;
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_dentry_info *di;
+
+       spin_lock(&mdsc->dentry_lru_lock);
+       list_for_each_entry(di, &mdsc->dentry_lru, lru) {
+               struct dentry *dentry = di->dentry;
+               seq_printf(s, "%p %p\t%.*s\n",
+                          di, dentry, dentry->d_name.len, dentry->d_name.name);
+       }
+       spin_unlock(&mdsc->dentry_lru_lock);
+
+       return 0;
+}
+
+#define DEFINE_SHOW_FUNC(name)                                                 \
+static int name##_open(struct inode *inode, struct file *file)         \
+{                                                                      \
+       struct seq_file *sf;                                            \
+       int ret;                                                        \
+                                                                       \
+       ret = single_open(file, name, NULL);                            \
+       sf = file->private_data;                                        \
+       sf->private = inode->i_private;                                 \
+       return ret;                                                     \
+}                                                                      \
+                                                                       \
+static const struct file_operations name##_fops = {                    \
+       .open           = name##_open,                                  \
+       .read           = seq_read,                                     \
+       .llseek         = seq_lseek,                                    \
+       .release        = single_release,                               \
+};
+
+DEFINE_SHOW_FUNC(monmap_show)
+DEFINE_SHOW_FUNC(mdsmap_show)
+DEFINE_SHOW_FUNC(osdmap_show)
+DEFINE_SHOW_FUNC(monc_show)
+DEFINE_SHOW_FUNC(mdsc_show)
+DEFINE_SHOW_FUNC(osdc_show)
+DEFINE_SHOW_FUNC(dentry_lru_show)
+DEFINE_SHOW_FUNC(caps_show)
+
+static int congestion_kb_set(void *data, u64 val)
+{
+       struct ceph_client *client = (struct ceph_client *)data;
+
+       if (client)
+               client->mount_args->congestion_kb = (int)val;
+
+       return 0;
+}
+
+static int congestion_kb_get(void *data, u64 *val)
+{
+       struct ceph_client *client = (struct ceph_client *)data;
+
+       if (client)
+               *val = (u64)client->mount_args->congestion_kb;
+
+       return 0;
+}
+
+
+DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get,
+                       congestion_kb_set, "%llu\n");
+
+int __init ceph_debugfs_init(void)
+{
+       ceph_debugfs_dir = debugfs_create_dir("ceph", NULL);
+       if (!ceph_debugfs_dir)
+               return -ENOMEM;
+       return 0;
+}
+
+void ceph_debugfs_cleanup(void)
+{
+       debugfs_remove(ceph_debugfs_dir);
+}
+
+int ceph_debugfs_client_init(struct ceph_client *client)
+{
+       int ret = 0;
+       char name[80];
+
+       snprintf(name, sizeof(name), FSID_FORMAT ".client%lld",
+                PR_FSID(&client->fsid), client->monc.auth->global_id);
+
+       client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir);
+       if (!client->debugfs_dir)
+               goto out;
+
+       client->monc.debugfs_file = debugfs_create_file("monc",
+                                                     0600,
+                                                     client->debugfs_dir,
+                                                     client,
+                                                     &monc_show_fops);
+       if (!client->monc.debugfs_file)
+               goto out;
+
+       client->mdsc.debugfs_file = debugfs_create_file("mdsc",
+                                                     0600,
+                                                     client->debugfs_dir,
+                                                     client,
+                                                     &mdsc_show_fops);
+       if (!client->mdsc.debugfs_file)
+               goto out;
+
+       client->osdc.debugfs_file = debugfs_create_file("osdc",
+                                                     0600,
+                                                     client->debugfs_dir,
+                                                     client,
+                                                     &osdc_show_fops);
+       if (!client->osdc.debugfs_file)
+               goto out;
+
+       client->debugfs_monmap = debugfs_create_file("monmap",
+                                       0600,
+                                       client->debugfs_dir,
+                                       client,
+                                       &monmap_show_fops);
+       if (!client->debugfs_monmap)
+               goto out;
+
+       client->debugfs_mdsmap = debugfs_create_file("mdsmap",
+                                       0600,
+                                       client->debugfs_dir,
+                                       client,
+                                       &mdsmap_show_fops);
+       if (!client->debugfs_mdsmap)
+               goto out;
+
+       client->debugfs_osdmap = debugfs_create_file("osdmap",
+                                       0600,
+                                       client->debugfs_dir,
+                                       client,
+                                       &osdmap_show_fops);
+       if (!client->debugfs_osdmap)
+               goto out;
+
+       client->debugfs_dentry_lru = debugfs_create_file("dentry_lru",
+                                       0600,
+                                       client->debugfs_dir,
+                                       client,
+                                       &dentry_lru_show_fops);
+       if (!client->debugfs_dentry_lru)
+               goto out;
+
+       client->debugfs_caps = debugfs_create_file("caps",
+                                                  0400,
+                                                  client->debugfs_dir,
+                                                  client,
+                                                  &caps_show_fops);
+       if (!client->debugfs_caps)
+               goto out;
+
+       client->debugfs_congestion_kb = debugfs_create_file("writeback_congestion_kb",
+                                                  0600,
+                                                  client->debugfs_dir,
+                                                  client,
+                                                  &congestion_kb_fops);
+       if (!client->debugfs_congestion_kb)
+               goto out;
+
+       sprintf(name, "../../bdi/%s", dev_name(client->sb->s_bdi->dev));
+       client->debugfs_bdi = debugfs_create_symlink("bdi", client->debugfs_dir,
+                                                    name);
+
+       return 0;
+
+out:
+       ceph_debugfs_client_cleanup(client);
+       return ret;
+}
+
+void ceph_debugfs_client_cleanup(struct ceph_client *client)
+{
+       debugfs_remove(client->debugfs_bdi);
+       debugfs_remove(client->debugfs_caps);
+       debugfs_remove(client->debugfs_dentry_lru);
+       debugfs_remove(client->debugfs_osdmap);
+       debugfs_remove(client->debugfs_mdsmap);
+       debugfs_remove(client->debugfs_monmap);
+       debugfs_remove(client->osdc.debugfs_file);
+       debugfs_remove(client->mdsc.debugfs_file);
+       debugfs_remove(client->monc.debugfs_file);
+       debugfs_remove(client->debugfs_congestion_kb);
+       debugfs_remove(client->debugfs_dir);
+}
+
+#else  // CONFIG_DEBUG_FS
+
+int __init ceph_debugfs_init(void)
+{
+       return 0;
+}
+
+void ceph_debugfs_cleanup(void)
+{
+}
+
+int ceph_debugfs_client_init(struct ceph_client *client)
+{
+       return 0;
+}
+
+void ceph_debugfs_client_cleanup(struct ceph_client *client)
+{
+}
+
+#endif  // CONFIG_DEBUG_FS
diff --git a/fs/ceph/decode.h b/fs/ceph/decode.h
new file mode 100644 (file)
index 0000000..65b3e02
--- /dev/null
@@ -0,0 +1,194 @@
+#ifndef __CEPH_DECODE_H
+#define __CEPH_DECODE_H
+
+#include <asm/unaligned.h>
+#include <linux/time.h>
+
+#include "types.h"
+
+/*
+ * in all cases,
+ *   void **p     pointer to position pointer
+ *   void *end    pointer to end of buffer (last byte + 1)
+ */
+
+static inline u64 ceph_decode_64(void **p)
+{
+       u64 v = get_unaligned_le64(*p);
+       *p += sizeof(u64);
+       return v;
+}
+static inline u32 ceph_decode_32(void **p)
+{
+       u32 v = get_unaligned_le32(*p);
+       *p += sizeof(u32);
+       return v;
+}
+static inline u16 ceph_decode_16(void **p)
+{
+       u16 v = get_unaligned_le16(*p);
+       *p += sizeof(u16);
+       return v;
+}
+static inline u8 ceph_decode_8(void **p)
+{
+       u8 v = *(u8 *)*p;
+       (*p)++;
+       return v;
+}
+static inline void ceph_decode_copy(void **p, void *pv, size_t n)
+{
+       memcpy(pv, *p, n);
+       *p += n;
+}
+
+/*
+ * bounds check input.
+ */
+#define ceph_decode_need(p, end, n, bad)               \
+       do {                                            \
+               if (unlikely(*(p) + (n) > (end)))       \
+                       goto bad;                       \
+       } while (0)
+
+#define ceph_decode_64_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_decode_need(p, end, sizeof(u64), bad);     \
+               v = ceph_decode_64(p);                          \
+       } while (0)
+#define ceph_decode_32_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_decode_need(p, end, sizeof(u32), bad);     \
+               v = ceph_decode_32(p);                          \
+       } while (0)
+#define ceph_decode_16_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_decode_need(p, end, sizeof(u16), bad);     \
+               v = ceph_decode_16(p);                          \
+       } while (0)
+#define ceph_decode_8_safe(p, end, v, bad)                     \
+       do {                                                    \
+               ceph_decode_need(p, end, sizeof(u8), bad);      \
+               v = ceph_decode_8(p);                           \
+       } while (0)
+
+#define ceph_decode_copy_safe(p, end, pv, n, bad)              \
+       do {                                                    \
+               ceph_decode_need(p, end, n, bad);               \
+               ceph_decode_copy(p, pv, n);                     \
+       } while (0)
+
+/*
+ * struct ceph_timespec <-> struct timespec
+ */
+static inline void ceph_decode_timespec(struct timespec *ts,
+                                       const struct ceph_timespec *tv)
+{
+       ts->tv_sec = le32_to_cpu(tv->tv_sec);
+       ts->tv_nsec = le32_to_cpu(tv->tv_nsec);
+}
+static inline void ceph_encode_timespec(struct ceph_timespec *tv,
+                                       const struct timespec *ts)
+{
+       tv->tv_sec = cpu_to_le32(ts->tv_sec);
+       tv->tv_nsec = cpu_to_le32(ts->tv_nsec);
+}
+
+/*
+ * sockaddr_storage <-> ceph_sockaddr
+ */
+static inline void ceph_encode_addr(struct ceph_entity_addr *a)
+{
+       a->in_addr.ss_family = htons(a->in_addr.ss_family);
+}
+static inline void ceph_decode_addr(struct ceph_entity_addr *a)
+{
+       a->in_addr.ss_family = ntohs(a->in_addr.ss_family);
+       WARN_ON(a->in_addr.ss_family == 512);
+}
+
+/*
+ * encoders
+ */
+static inline void ceph_encode_64(void **p, u64 v)
+{
+       put_unaligned_le64(v, (__le64 *)*p);
+       *p += sizeof(u64);
+}
+static inline void ceph_encode_32(void **p, u32 v)
+{
+       put_unaligned_le32(v, (__le32 *)*p);
+       *p += sizeof(u32);
+}
+static inline void ceph_encode_16(void **p, u16 v)
+{
+       put_unaligned_le16(v, (__le16 *)*p);
+       *p += sizeof(u16);
+}
+static inline void ceph_encode_8(void **p, u8 v)
+{
+       *(u8 *)*p = v;
+       (*p)++;
+}
+static inline void ceph_encode_copy(void **p, const void *s, int len)
+{
+       memcpy(*p, s, len);
+       *p += len;
+}
+
+/*
+ * filepath, string encoders
+ */
+static inline void ceph_encode_filepath(void **p, void *end,
+                                       u64 ino, const char *path)
+{
+       u32 len = path ? strlen(path) : 0;
+       BUG_ON(*p + sizeof(ino) + sizeof(len) + len > end);
+       ceph_encode_8(p, 1);
+       ceph_encode_64(p, ino);
+       ceph_encode_32(p, len);
+       if (len)
+               memcpy(*p, path, len);
+       *p += len;
+}
+
+static inline void ceph_encode_string(void **p, void *end,
+                                     const char *s, u32 len)
+{
+       BUG_ON(*p + sizeof(len) + len > end);
+       ceph_encode_32(p, len);
+       if (len)
+               memcpy(*p, s, len);
+       *p += len;
+}
+
+#define ceph_encode_need(p, end, n, bad)               \
+       do {                                            \
+               if (unlikely(*(p) + (n) > (end)))       \
+                       goto bad;                       \
+       } while (0)
+
+#define ceph_encode_64_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_encode_need(p, end, sizeof(u64), bad);     \
+               ceph_encode_64(p, v);                           \
+       } while (0)
+#define ceph_encode_32_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_encode_need(p, end, sizeof(u32), bad);     \
+               ceph_encode_32(p, v);                   \
+       } while (0)
+#define ceph_encode_16_safe(p, end, v, bad)                    \
+       do {                                                    \
+               ceph_encode_need(p, end, sizeof(u16), bad);     \
+               ceph_encode_16(p, v);                   \
+       } while (0)
+
+#define ceph_encode_copy_safe(p, end, pv, n, bad)              \
+       do {                                                    \
+               ceph_encode_need(p, end, n, bad);               \
+               ceph_encode_copy(p, pv, n);                     \
+       } while (0)
+
+
+#endif
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
new file mode 100644 (file)
index 0000000..7261dc6
--- /dev/null
@@ -0,0 +1,1223 @@
+#include "ceph_debug.h"
+
+#include <linux/spinlock.h>
+#include <linux/fs_struct.h>
+#include <linux/namei.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+
+#include "super.h"
+
+/*
+ * Directory operations: readdir, lookup, create, link, unlink,
+ * rename, etc.
+ */
+
+/*
+ * Ceph MDS operations are specified in terms of a base ino and
+ * relative path.  Thus, the client can specify an operation on a
+ * specific inode (e.g., a getattr due to fstat(2)), or as a path
+ * relative to, say, the root directory.
+ *
+ * Normally, we limit ourselves to strict inode ops (no path component)
+ * or dentry operations (a single path component relative to an ino).  The
+ * exception to this is open_root_dentry(), which will open the mount
+ * point by name.
+ */
+
+const struct inode_operations ceph_dir_iops;
+const struct file_operations ceph_dir_fops;
+struct dentry_operations ceph_dentry_ops;
+
+/*
+ * Initialize ceph dentry state.
+ */
+int ceph_init_dentry(struct dentry *dentry)
+{
+       struct ceph_dentry_info *di;
+
+       if (dentry->d_fsdata)
+               return 0;
+
+       if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)
+               dentry->d_op = &ceph_dentry_ops;
+       else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR)
+               dentry->d_op = &ceph_snapdir_dentry_ops;
+       else
+               dentry->d_op = &ceph_snap_dentry_ops;
+
+       di = kmem_cache_alloc(ceph_dentry_cachep, GFP_NOFS);
+       if (!di)
+               return -ENOMEM;          /* oh well */
+
+       spin_lock(&dentry->d_lock);
+       if (dentry->d_fsdata) /* lost a race */
+               goto out_unlock;
+       di->dentry = dentry;
+       di->lease_session = NULL;
+       dentry->d_fsdata = di;
+       dentry->d_time = jiffies;
+       ceph_dentry_lru_add(dentry);
+out_unlock:
+       spin_unlock(&dentry->d_lock);
+       return 0;
+}
+
+
+
+/*
+ * for readdir, we encode the directory frag and offset within that
+ * frag into f_pos.
+ */
+static unsigned fpos_frag(loff_t p)
+{
+       return p >> 32;
+}
+static unsigned fpos_off(loff_t p)
+{
+       return p & 0xffffffff;
+}
+
+/*
+ * When possible, we try to satisfy a readdir by peeking at the
+ * dcache.  We make this work by carefully ordering dentries on
+ * d_u.d_child when we initially get results back from the MDS, and
+ * falling back to a "normal" sync readdir if any dentries in the dir
+ * are dropped.
+ *
+ * I_COMPLETE tells indicates we have all dentries in the dir.  It is
+ * defined IFF we hold CEPH_CAP_FILE_SHARED (which will be revoked by
+ * the MDS if/when the directory is modified).
+ */
+static int __dcache_readdir(struct file *filp,
+                           void *dirent, filldir_t filldir)
+{
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct ceph_file_info *fi = filp->private_data;
+       struct dentry *parent = filp->f_dentry;
+       struct inode *dir = parent->d_inode;
+       struct list_head *p;
+       struct dentry *dentry, *last;
+       struct ceph_dentry_info *di;
+       int err = 0;
+
+       /* claim ref on last dentry we returned */
+       last = fi->dentry;
+       fi->dentry = NULL;
+
+       dout("__dcache_readdir %p at %llu (last %p)\n", dir, filp->f_pos,
+            last);
+
+       spin_lock(&dcache_lock);
+
+       /* start at beginning? */
+       if (filp->f_pos == 2 || (last &&
+                                filp->f_pos < ceph_dentry(last)->offset)) {
+               if (list_empty(&parent->d_subdirs))
+                       goto out_unlock;
+               p = parent->d_subdirs.prev;
+               dout(" initial p %p/%p\n", p->prev, p->next);
+       } else {
+               p = last->d_u.d_child.prev;
+       }
+
+more:
+       dentry = list_entry(p, struct dentry, d_u.d_child);
+       di = ceph_dentry(dentry);
+       while (1) {
+               dout(" p %p/%p d_subdirs %p/%p\n", p->prev, p->next,
+                    parent->d_subdirs.prev, parent->d_subdirs.next);
+               if (p == &parent->d_subdirs) {
+                       fi->at_end = 1;
+                       goto out_unlock;
+               }
+               if (!d_unhashed(dentry) && dentry->d_inode &&
+                   ceph_snap(dentry->d_inode) != CEPH_SNAPDIR &&
+                   ceph_ino(dentry->d_inode) != CEPH_INO_CEPH &&
+                   filp->f_pos <= di->offset)
+                       break;
+               dout(" skipping %p %.*s at %llu (%llu)%s%s\n", dentry,
+                    dentry->d_name.len, dentry->d_name.name, di->offset,
+                    filp->f_pos, d_unhashed(dentry) ? " unhashed" : "",
+                    !dentry->d_inode ? " null" : "");
+               p = p->prev;
+               dentry = list_entry(p, struct dentry, d_u.d_child);
+               di = ceph_dentry(dentry);
+       }
+
+       atomic_inc(&dentry->d_count);
+       spin_unlock(&dcache_lock);
+       spin_unlock(&inode->i_lock);
+
+       dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, filp->f_pos,
+            dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
+       filp->f_pos = di->offset;
+       err = filldir(dirent, dentry->d_name.name,
+                     dentry->d_name.len, di->offset,
+                     dentry->d_inode->i_ino,
+                     dentry->d_inode->i_mode >> 12);
+
+       if (last) {
+               if (err < 0) {
+                       /* remember our position */
+                       fi->dentry = last;
+                       fi->next_offset = di->offset;
+               } else {
+                       dput(last);
+               }
+               last = NULL;
+       }
+
+       spin_lock(&inode->i_lock);
+       spin_lock(&dcache_lock);
+
+       if (err < 0)
+               goto out_unlock;
+
+       last = dentry;
+
+       p = p->prev;
+       filp->f_pos++;
+
+       /* make sure a dentry wasn't dropped while we didn't have dcache_lock */
+       if ((ceph_inode(dir)->i_ceph_flags & CEPH_I_COMPLETE))
+               goto more;
+       dout(" lost I_COMPLETE on %p; falling back to mds\n", dir);
+       err = -EAGAIN;
+
+out_unlock:
+       spin_unlock(&dcache_lock);
+
+       if (last) {
+               spin_unlock(&inode->i_lock);
+               dput(last);
+               spin_lock(&inode->i_lock);
+       }
+
+       return err;
+}
+
+/*
+ * make note of the last dentry we read, so we can
+ * continue at the same lexicographical point,
+ * regardless of what dir changes take place on the
+ * server.
+ */
+static int note_last_dentry(struct ceph_file_info *fi, const char *name,
+                           int len)
+{
+       kfree(fi->last_name);
+       fi->last_name = kmalloc(len+1, GFP_NOFS);
+       if (!fi->last_name)
+               return -ENOMEM;
+       memcpy(fi->last_name, name, len);
+       fi->last_name[len] = 0;
+       dout("note_last_dentry '%s'\n", fi->last_name);
+       return 0;
+}
+
+static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
+{
+       struct ceph_file_info *fi = filp->private_data;
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_client *client = ceph_inode_to_client(inode);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       unsigned frag = fpos_frag(filp->f_pos);
+       int off = fpos_off(filp->f_pos);
+       int err;
+       u32 ftype;
+       struct ceph_mds_reply_info_parsed *rinfo;
+       const int max_entries = client->mount_args->max_readdir;
+
+       dout("readdir %p filp %p frag %u off %u\n", inode, filp, frag, off);
+       if (fi->at_end)
+               return 0;
+
+       /* always start with . and .. */
+       if (filp->f_pos == 0) {
+               /* note dir version at start of readdir so we can tell
+                * if any dentries get dropped */
+               fi->dir_release_count = ci->i_release_count;
+
+               dout("readdir off 0 -> '.'\n");
+               if (filldir(dirent, ".", 1, ceph_make_fpos(0, 0),
+                           inode->i_ino, inode->i_mode >> 12) < 0)
+                       return 0;
+               filp->f_pos = 1;
+               off = 1;
+       }
+       if (filp->f_pos == 1) {
+               dout("readdir off 1 -> '..'\n");
+               if (filldir(dirent, "..", 2, ceph_make_fpos(0, 1),
+                           filp->f_dentry->d_parent->d_inode->i_ino,
+                           inode->i_mode >> 12) < 0)
+                       return 0;
+               filp->f_pos = 2;
+               off = 2;
+       }
+
+       /* can we use the dcache? */
+       spin_lock(&inode->i_lock);
+       if ((filp->f_pos == 2 || fi->dentry) &&
+           !ceph_test_opt(client, NOASYNCREADDIR) &&
+           (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
+           __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1)) {
+               err = __dcache_readdir(filp, dirent, filldir);
+               if (err != -EAGAIN) {
+                       spin_unlock(&inode->i_lock);
+                       return err;
+               }
+       }
+       spin_unlock(&inode->i_lock);
+       if (fi->dentry) {
+               err = note_last_dentry(fi, fi->dentry->d_name.name,
+                                      fi->dentry->d_name.len);
+               if (err)
+                       return err;
+               dput(fi->dentry);
+               fi->dentry = NULL;
+       }
+
+       /* proceed with a normal readdir */
+
+more:
+       /* do we have the correct frag content buffered? */
+       if (fi->frag != frag || fi->last_readdir == NULL) {
+               struct ceph_mds_request *req;
+               int op = ceph_snap(inode) == CEPH_SNAPDIR ?
+                       CEPH_MDS_OP_LSSNAP : CEPH_MDS_OP_READDIR;
+
+               /* discard old result, if any */
+               if (fi->last_readdir) {
+                       ceph_mdsc_put_request(fi->last_readdir);
+                       fi->last_readdir = NULL;
+               }
+
+               /* requery frag tree, as the frag topology may have changed */
+               frag = ceph_choose_frag(ceph_inode(inode), frag, NULL, NULL);
+
+               dout("readdir fetching %llx.%llx frag %x offset '%s'\n",
+                    ceph_vinop(inode), frag, fi->last_name);
+               req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
+               if (IS_ERR(req))
+                       return PTR_ERR(req);
+               req->r_inode = igrab(inode);
+               req->r_dentry = dget(filp->f_dentry);
+               /* hints to request -> mds selection code */
+               req->r_direct_mode = USE_AUTH_MDS;
+               req->r_direct_hash = ceph_frag_value(frag);
+               req->r_direct_is_hash = true;
+               req->r_path2 = kstrdup(fi->last_name, GFP_NOFS);
+               req->r_readdir_offset = fi->next_offset;
+               req->r_args.readdir.frag = cpu_to_le32(frag);
+               req->r_args.readdir.max_entries = cpu_to_le32(max_entries);
+               req->r_num_caps = max_entries;
+               err = ceph_mdsc_do_request(mdsc, NULL, req);
+               if (err < 0) {
+                       ceph_mdsc_put_request(req);
+                       return err;
+               }
+               dout("readdir got and parsed readdir result=%d"
+                    " on frag %x, end=%d, complete=%d\n", err, frag,
+                    (int)req->r_reply_info.dir_end,
+                    (int)req->r_reply_info.dir_complete);
+
+               if (!req->r_did_prepopulate) {
+                       dout("readdir !did_prepopulate");
+                       fi->dir_release_count--;    /* preclude I_COMPLETE */
+               }
+
+               /* note next offset and last dentry name */
+               fi->offset = fi->next_offset;
+               fi->last_readdir = req;
+
+               if (req->r_reply_info.dir_end) {
+                       kfree(fi->last_name);
+                       fi->last_name = NULL;
+                       fi->next_offset = 0;
+               } else {
+                       rinfo = &req->r_reply_info;
+                       err = note_last_dentry(fi,
+                                      rinfo->dir_dname[rinfo->dir_nr-1],
+                                      rinfo->dir_dname_len[rinfo->dir_nr-1]);
+                       if (err)
+                               return err;
+                       fi->next_offset += rinfo->dir_nr;
+               }
+       }
+
+       rinfo = &fi->last_readdir->r_reply_info;
+       dout("readdir frag %x num %d off %d chunkoff %d\n", frag,
+            rinfo->dir_nr, off, fi->offset);
+       while (off - fi->offset >= 0 && off - fi->offset < rinfo->dir_nr) {
+               u64 pos = ceph_make_fpos(frag, off);
+               struct ceph_mds_reply_inode *in =
+                       rinfo->dir_in[off - fi->offset].in;
+               dout("readdir off %d (%d/%d) -> %lld '%.*s' %p\n",
+                    off, off - fi->offset, rinfo->dir_nr, pos,
+                    rinfo->dir_dname_len[off - fi->offset],
+                    rinfo->dir_dname[off - fi->offset], in);
+               BUG_ON(!in);
+               ftype = le32_to_cpu(in->mode) >> 12;
+               if (filldir(dirent,
+                           rinfo->dir_dname[off - fi->offset],
+                           rinfo->dir_dname_len[off - fi->offset],
+                           pos,
+                           le64_to_cpu(in->ino),
+                           ftype) < 0) {
+                       dout("filldir stopping us...\n");
+                       return 0;
+               }
+               off++;
+               filp->f_pos = pos + 1;
+       }
+
+       if (fi->last_name) {
+               ceph_mdsc_put_request(fi->last_readdir);
+               fi->last_readdir = NULL;
+               goto more;
+       }
+
+       /* more frags? */
+       if (!ceph_frag_is_rightmost(frag)) {
+               frag = ceph_frag_next(frag);
+               off = 0;
+               filp->f_pos = ceph_make_fpos(frag, off);
+               dout("readdir next frag is %x\n", frag);
+               goto more;
+       }
+       fi->at_end = 1;
+
+       /*
+        * if dir_release_count still matches the dir, no dentries
+        * were released during the whole readdir, and we should have
+        * the complete dir contents in our cache.
+        */
+       spin_lock(&inode->i_lock);
+       if (ci->i_release_count == fi->dir_release_count) {
+               dout(" marking %p complete\n", inode);
+               ci->i_ceph_flags |= CEPH_I_COMPLETE;
+               ci->i_max_offset = filp->f_pos;
+       }
+       spin_unlock(&inode->i_lock);
+
+       dout("readdir %p filp %p done.\n", inode, filp);
+       return 0;
+}
+
+static void reset_readdir(struct ceph_file_info *fi)
+{
+       if (fi->last_readdir) {
+               ceph_mdsc_put_request(fi->last_readdir);
+               fi->last_readdir = NULL;
+       }
+       kfree(fi->last_name);
+       fi->next_offset = 2;  /* compensate for . and .. */
+       if (fi->dentry) {
+               dput(fi->dentry);
+               fi->dentry = NULL;
+       }
+       fi->at_end = 0;
+}
+
+static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int origin)
+{
+       struct ceph_file_info *fi = file->private_data;
+       struct inode *inode = file->f_mapping->host;
+       loff_t old_offset = offset;
+       loff_t retval;
+
+       mutex_lock(&inode->i_mutex);
+       switch (origin) {
+       case SEEK_END:
+               offset += inode->i_size + 2;   /* FIXME */
+               break;
+       case SEEK_CUR:
+               offset += file->f_pos;
+       }
+       retval = -EINVAL;
+       if (offset >= 0 && offset <= inode->i_sb->s_maxbytes) {
+               if (offset != file->f_pos) {
+                       file->f_pos = offset;
+                       file->f_version = 0;
+                       fi->at_end = 0;
+               }
+               retval = offset;
+
+               /*
+                * discard buffered readdir content on seekdir(0), or
+                * seek to new frag, or seek prior to current chunk.
+                */
+               if (offset == 0 ||
+                   fpos_frag(offset) != fpos_frag(old_offset) ||
+                   fpos_off(offset) < fi->offset) {
+                       dout("dir_llseek dropping %p content\n", file);
+                       reset_readdir(fi);
+               }
+
+               /* bump dir_release_count if we did a forward seek */
+               if (offset > old_offset)
+                       fi->dir_release_count--;
+       }
+       mutex_unlock(&inode->i_mutex);
+       return retval;
+}
+
+/*
+ * Process result of a lookup/open request.
+ *
+ * Mainly, make sure we return the final req->r_dentry (if it already
+ * existed) in place of the original VFS-provided dentry when they
+ * differ.
+ *
+ * Gracefully handle the case where the MDS replies with -ENOENT and
+ * no trace (which it may do, at its discretion, e.g., if it doesn't
+ * care to issue a lease on the negative dentry).
+ */
+struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
+                                 struct dentry *dentry, int err)
+{
+       struct ceph_client *client = ceph_client(dentry->d_sb);
+       struct inode *parent = dentry->d_parent->d_inode;
+
+       /* .snap dir? */
+       if (err == -ENOENT &&
+           ceph_vino(parent).ino != CEPH_INO_ROOT && /* no .snap in root dir */
+           strcmp(dentry->d_name.name,
+                  client->mount_args->snapdir_name) == 0) {
+               struct inode *inode = ceph_get_snapdir(parent);
+               dout("ENOENT on snapdir %p '%.*s', linking to snapdir %p\n",
+                    dentry, dentry->d_name.len, dentry->d_name.name, inode);
+               d_add(dentry, inode);
+               err = 0;
+       }
+
+       if (err == -ENOENT) {
+               /* no trace? */
+               err = 0;
+               if (!req->r_reply_info.head->is_dentry) {
+                       dout("ENOENT and no trace, dentry %p inode %p\n",
+                            dentry, dentry->d_inode);
+                       if (dentry->d_inode) {
+                               d_drop(dentry);
+                               err = -ENOENT;
+                       } else {
+                               d_add(dentry, NULL);
+                       }
+               }
+       }
+       if (err)
+               dentry = ERR_PTR(err);
+       else if (dentry != req->r_dentry)
+               dentry = dget(req->r_dentry);   /* we got spliced */
+       else
+               dentry = NULL;
+       return dentry;
+}
+
+static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry)
+{
+       return ceph_ino(inode) == CEPH_INO_ROOT &&
+               strncmp(dentry->d_name.name, ".ceph", 5) == 0;
+}
+
+/*
+ * Look up a single dir entry.  If there is a lookup intent, inform
+ * the MDS so that it gets our 'caps wanted' value in a single op.
+ */
+static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
+                                 struct nameidata *nd)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int op;
+       int err;
+
+       dout("lookup %p dentry %p '%.*s'\n",
+            dir, dentry, dentry->d_name.len, dentry->d_name.name);
+
+       if (dentry->d_name.len > NAME_MAX)
+               return ERR_PTR(-ENAMETOOLONG);
+
+       err = ceph_init_dentry(dentry);
+       if (err < 0)
+               return ERR_PTR(err);
+
+       /* open (but not create!) intent? */
+       if (nd &&
+           (nd->flags & LOOKUP_OPEN) &&
+           (nd->flags & LOOKUP_CONTINUE) == 0 && /* only open last component */
+           !(nd->intent.open.flags & O_CREAT)) {
+               int mode = nd->intent.open.create_mode & ~current->fs->umask;
+               return ceph_lookup_open(dir, dentry, nd, mode, 1);
+       }
+
+       /* can we conclude ENOENT locally? */
+       if (dentry->d_inode == NULL) {
+               struct ceph_inode_info *ci = ceph_inode(dir);
+               struct ceph_dentry_info *di = ceph_dentry(dentry);
+
+               spin_lock(&dir->i_lock);
+               dout(" dir %p flags are %d\n", dir, ci->i_ceph_flags);
+               if (strncmp(dentry->d_name.name,
+                           client->mount_args->snapdir_name,
+                           dentry->d_name.len) &&
+                   !is_root_ceph_dentry(dir, dentry) &&
+                   (ci->i_ceph_flags & CEPH_I_COMPLETE) &&
+                   (__ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1))) {
+                       di->offset = ci->i_max_offset++;
+                       spin_unlock(&dir->i_lock);
+                       dout(" dir %p complete, -ENOENT\n", dir);
+                       d_add(dentry, NULL);
+                       di->lease_shared_gen = ci->i_shared_gen;
+                       return NULL;
+               }
+               spin_unlock(&dir->i_lock);
+       }
+
+       op = ceph_snap(dir) == CEPH_SNAPDIR ?
+               CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP;
+       req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
+       if (IS_ERR(req))
+               return ERR_PTR(PTR_ERR(req));
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       /* we only need inode linkage */
+       req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
+       req->r_locked_dir = dir;
+       err = ceph_mdsc_do_request(mdsc, NULL, req);
+       dentry = ceph_finish_lookup(req, dentry, err);
+       ceph_mdsc_put_request(req);  /* will dput(dentry) */
+       dout("lookup result=%p\n", dentry);
+       return dentry;
+}
+
+/*
+ * If we do a create but get no trace back from the MDS, follow up with
+ * a lookup (the VFS expects us to link up the provided dentry).
+ */
+int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
+{
+       struct dentry *result = ceph_lookup(dir, dentry, NULL);
+
+       if (result && !IS_ERR(result)) {
+               /*
+                * We created the item, then did a lookup, and found
+                * it was already linked to another inode we already
+                * had in our cache (and thus got spliced).  Link our
+                * dentry to that inode, but don't hash it, just in
+                * case the VFS wants to dereference it.
+                */
+               BUG_ON(!result->d_inode);
+               d_instantiate(dentry, result->d_inode);
+               return 0;
+       }
+       return PTR_ERR(result);
+}
+
+static int ceph_mknod(struct inode *dir, struct dentry *dentry,
+                     int mode, dev_t rdev)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err;
+
+       if (ceph_snap(dir) != CEPH_NOSNAP)
+               return -EROFS;
+
+       dout("mknod in dir %p dentry %p mode 0%o rdev %d\n",
+            dir, dentry, mode, rdev);
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_MKNOD, USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               d_drop(dentry);
+               return PTR_ERR(req);
+       }
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       req->r_locked_dir = dir;
+       req->r_args.mknod.mode = cpu_to_le32(mode);
+       req->r_args.mknod.rdev = cpu_to_le32(rdev);
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       err = ceph_mdsc_do_request(mdsc, dir, req);
+       if (!err && !req->r_reply_info.head->is_dentry)
+               err = ceph_handle_notrace_create(dir, dentry);
+       ceph_mdsc_put_request(req);
+       if (err)
+               d_drop(dentry);
+       return err;
+}
+
+static int ceph_create(struct inode *dir, struct dentry *dentry, int mode,
+                      struct nameidata *nd)
+{
+       dout("create in dir %p dentry %p name '%.*s'\n",
+            dir, dentry, dentry->d_name.len, dentry->d_name.name);
+
+       if (ceph_snap(dir) != CEPH_NOSNAP)
+               return -EROFS;
+
+       if (nd) {
+               BUG_ON((nd->flags & LOOKUP_OPEN) == 0);
+               dentry = ceph_lookup_open(dir, dentry, nd, mode, 0);
+               /* hrm, what should i do here if we get aliased? */
+               if (IS_ERR(dentry))
+                       return PTR_ERR(dentry);
+               return 0;
+       }
+
+       /* fall back to mknod */
+       return ceph_mknod(dir, dentry, (mode & ~S_IFMT) | S_IFREG, 0);
+}
+
+static int ceph_symlink(struct inode *dir, struct dentry *dentry,
+                           const char *dest)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err;
+
+       if (ceph_snap(dir) != CEPH_NOSNAP)
+               return -EROFS;
+
+       dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest);
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SYMLINK, USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               d_drop(dentry);
+               return PTR_ERR(req);
+       }
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       req->r_path2 = kstrdup(dest, GFP_NOFS);
+       req->r_locked_dir = dir;
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       err = ceph_mdsc_do_request(mdsc, dir, req);
+       if (!err && !req->r_reply_info.head->is_dentry)
+               err = ceph_handle_notrace_create(dir, dentry);
+       ceph_mdsc_put_request(req);
+       if (err)
+               d_drop(dentry);
+       return err;
+}
+
+static int ceph_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err = -EROFS;
+       int op;
+
+       if (ceph_snap(dir) == CEPH_SNAPDIR) {
+               /* mkdir .snap/foo is a MKSNAP */
+               op = CEPH_MDS_OP_MKSNAP;
+               dout("mksnap dir %p snap '%.*s' dn %p\n", dir,
+                    dentry->d_name.len, dentry->d_name.name, dentry);
+       } else if (ceph_snap(dir) == CEPH_NOSNAP) {
+               dout("mkdir dir %p dn %p mode 0%o\n", dir, dentry, mode);
+               op = CEPH_MDS_OP_MKDIR;
+       } else {
+               goto out;
+       }
+       req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto out;
+       }
+
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       req->r_locked_dir = dir;
+       req->r_args.mkdir.mode = cpu_to_le32(mode);
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       err = ceph_mdsc_do_request(mdsc, dir, req);
+       if (!err && !req->r_reply_info.head->is_dentry)
+               err = ceph_handle_notrace_create(dir, dentry);
+       ceph_mdsc_put_request(req);
+out:
+       if (err < 0)
+               d_drop(dentry);
+       return err;
+}
+
+static int ceph_link(struct dentry *old_dentry, struct inode *dir,
+                    struct dentry *dentry)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err;
+
+       if (ceph_snap(dir) != CEPH_NOSNAP)
+               return -EROFS;
+
+       dout("link in dir %p old_dentry %p dentry %p\n", dir,
+            old_dentry, dentry);
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               d_drop(dentry);
+               return PTR_ERR(req);
+       }
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       req->r_old_dentry = dget(old_dentry); /* or inode? hrm. */
+       req->r_locked_dir = dir;
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       err = ceph_mdsc_do_request(mdsc, dir, req);
+       if (err)
+               d_drop(dentry);
+       else if (!req->r_reply_info.head->is_dentry)
+               d_instantiate(dentry, igrab(old_dentry->d_inode));
+       ceph_mdsc_put_request(req);
+       return err;
+}
+
+/*
+ * For a soon-to-be unlinked file, drop the AUTH_RDCACHE caps.  If it
+ * looks like the link count will hit 0, drop any other caps (other
+ * than PIN) we don't specifically want (due to the file still being
+ * open).
+ */
+static int drop_caps_for_unlink(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
+
+       spin_lock(&inode->i_lock);
+       if (inode->i_nlink == 1) {
+               drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN);
+               ci->i_ceph_flags |= CEPH_I_NODELAY;
+       }
+       spin_unlock(&inode->i_lock);
+       return drop;
+}
+
+/*
+ * rmdir and unlink are differ only by the metadata op code
+ */
+static int ceph_unlink(struct inode *dir, struct dentry *dentry)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct inode *inode = dentry->d_inode;
+       struct ceph_mds_request *req;
+       int err = -EROFS;
+       int op;
+
+       if (ceph_snap(dir) == CEPH_SNAPDIR) {
+               /* rmdir .snap/foo is RMSNAP */
+               dout("rmsnap dir %p '%.*s' dn %p\n", dir, dentry->d_name.len,
+                    dentry->d_name.name, dentry);
+               op = CEPH_MDS_OP_RMSNAP;
+       } else if (ceph_snap(dir) == CEPH_NOSNAP) {
+               dout("unlink/rmdir dir %p dn %p inode %p\n",
+                    dir, dentry, inode);
+               op = ((dentry->d_inode->i_mode & S_IFMT) == S_IFDIR) ?
+                       CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK;
+       } else
+               goto out;
+       req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto out;
+       }
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       req->r_locked_dir = dir;
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       req->r_inode_drop = drop_caps_for_unlink(inode);
+       err = ceph_mdsc_do_request(mdsc, dir, req);
+       if (!err && !req->r_reply_info.head->is_dentry)
+               d_delete(dentry);
+       ceph_mdsc_put_request(req);
+out:
+       return err;
+}
+
+static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
+                      struct inode *new_dir, struct dentry *new_dentry)
+{
+       struct ceph_client *client = ceph_sb_to_client(old_dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err;
+
+       if (ceph_snap(old_dir) != ceph_snap(new_dir))
+               return -EXDEV;
+       if (ceph_snap(old_dir) != CEPH_NOSNAP ||
+           ceph_snap(new_dir) != CEPH_NOSNAP)
+               return -EROFS;
+       dout("rename dir %p dentry %p to dir %p dentry %p\n",
+            old_dir, old_dentry, new_dir, new_dentry);
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_RENAME, USE_AUTH_MDS);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+       req->r_dentry = dget(new_dentry);
+       req->r_num_caps = 2;
+       req->r_old_dentry = dget(old_dentry);
+       req->r_locked_dir = new_dir;
+       req->r_old_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL;
+       req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+       req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       /* release LINK_RDCACHE on source inode (mds will lock it) */
+       req->r_old_inode_drop = CEPH_CAP_LINK_SHARED;
+       if (new_dentry->d_inode)
+               req->r_inode_drop = drop_caps_for_unlink(new_dentry->d_inode);
+       err = ceph_mdsc_do_request(mdsc, old_dir, req);
+       if (!err && !req->r_reply_info.head->is_dentry) {
+               /*
+                * Normally d_move() is done by fill_trace (called by
+                * do_request, above).  If there is no trace, we need
+                * to do it here.
+                */
+               d_move(old_dentry, new_dentry);
+       }
+       ceph_mdsc_put_request(req);
+       return err;
+}
+
+
+/*
+ * Check if dentry lease is valid.  If not, delete the lease.  Try to
+ * renew if the least is more than half up.
+ */
+static int dentry_lease_is_valid(struct dentry *dentry)
+{
+       struct ceph_dentry_info *di;
+       struct ceph_mds_session *s;
+       int valid = 0;
+       u32 gen;
+       unsigned long ttl;
+       struct ceph_mds_session *session = NULL;
+       struct inode *dir = NULL;
+       u32 seq = 0;
+
+       spin_lock(&dentry->d_lock);
+       di = ceph_dentry(dentry);
+       if (di && di->lease_session) {
+               s = di->lease_session;
+               spin_lock(&s->s_cap_lock);
+               gen = s->s_cap_gen;
+               ttl = s->s_cap_ttl;
+               spin_unlock(&s->s_cap_lock);
+
+               if (di->lease_gen == gen &&
+                   time_before(jiffies, dentry->d_time) &&
+                   time_before(jiffies, ttl)) {
+                       valid = 1;
+                       if (di->lease_renew_after &&
+                           time_after(jiffies, di->lease_renew_after)) {
+                               /* we should renew */
+                               dir = dentry->d_parent->d_inode;
+                               session = ceph_get_mds_session(s);
+                               seq = di->lease_seq;
+                               di->lease_renew_after = 0;
+                               di->lease_renew_from = jiffies;
+                       }
+               }
+       }
+       spin_unlock(&dentry->d_lock);
+
+       if (session) {
+               ceph_mdsc_lease_send_msg(session, dir, dentry,
+                                        CEPH_MDS_LEASE_RENEW, seq);
+               ceph_put_mds_session(session);
+       }
+       dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid);
+       return valid;
+}
+
+/*
+ * Check if directory-wide content lease/cap is valid.
+ */
+static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
+{
+       struct ceph_inode_info *ci = ceph_inode(dir);
+       struct ceph_dentry_info *di = ceph_dentry(dentry);
+       int valid = 0;
+
+       spin_lock(&dir->i_lock);
+       if (ci->i_shared_gen == di->lease_shared_gen)
+               valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1);
+       spin_unlock(&dir->i_lock);
+       dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n",
+            dir, (unsigned)ci->i_shared_gen, dentry,
+            (unsigned)di->lease_shared_gen, valid);
+       return valid;
+}
+
+/*
+ * Check if cached dentry can be trusted.
+ */
+static int ceph_d_revalidate(struct dentry *dentry, struct nameidata *nd)
+{
+       struct inode *dir = dentry->d_parent->d_inode;
+
+       dout("d_revalidate %p '%.*s' inode %p\n", dentry,
+            dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
+
+       /* always trust cached snapped dentries, snapdir dentry */
+       if (ceph_snap(dir) != CEPH_NOSNAP) {
+               dout("d_revalidate %p '%.*s' inode %p is SNAPPED\n", dentry,
+                    dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
+               goto out_touch;
+       }
+       if (dentry->d_inode && ceph_snap(dentry->d_inode) == CEPH_SNAPDIR)
+               goto out_touch;
+
+       if (dentry_lease_is_valid(dentry) ||
+           dir_lease_is_valid(dir, dentry))
+               goto out_touch;
+
+       dout("d_revalidate %p invalid\n", dentry);
+       d_drop(dentry);
+       return 0;
+out_touch:
+       ceph_dentry_lru_touch(dentry);
+       return 1;
+}
+
+/*
+ * When a dentry is released, clear the dir I_COMPLETE if it was part
+ * of the current dir gen.
+ */
+static void ceph_dentry_release(struct dentry *dentry)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dentry);
+       struct inode *parent_inode = dentry->d_parent->d_inode;
+
+       if (parent_inode) {
+               struct ceph_inode_info *ci = ceph_inode(parent_inode);
+
+               spin_lock(&parent_inode->i_lock);
+               if (ci->i_shared_gen == di->lease_shared_gen) {
+                       dout(" clearing %p complete (d_release)\n",
+                            parent_inode);
+                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+                       ci->i_release_count++;
+               }
+               spin_unlock(&parent_inode->i_lock);
+       }
+       if (di) {
+               ceph_dentry_lru_del(dentry);
+               if (di->lease_session)
+                       ceph_put_mds_session(di->lease_session);
+               kmem_cache_free(ceph_dentry_cachep, di);
+               dentry->d_fsdata = NULL;
+       }
+}
+
+static int ceph_snapdir_d_revalidate(struct dentry *dentry,
+                                         struct nameidata *nd)
+{
+       /*
+        * Eventually, we'll want to revalidate snapped metadata
+        * too... probably...
+        */
+       return 1;
+}
+
+
+
+/*
+ * read() on a dir.  This weird interface hack only works if mounted
+ * with '-o dirstat'.
+ */
+static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
+                            loff_t *ppos)
+{
+       struct ceph_file_info *cf = file->private_data;
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int left;
+
+       if (!ceph_test_opt(ceph_client(inode->i_sb), DIRSTAT))
+               return -EISDIR;
+
+       if (!cf->dir_info) {
+               cf->dir_info = kmalloc(1024, GFP_NOFS);
+               if (!cf->dir_info)
+                       return -ENOMEM;
+               cf->dir_info_len =
+                       sprintf(cf->dir_info,
+                               "entries:   %20lld\n"
+                               " files:    %20lld\n"
+                               " subdirs:  %20lld\n"
+                               "rentries:  %20lld\n"
+                               " rfiles:   %20lld\n"
+                               " rsubdirs: %20lld\n"
+                               "rbytes:    %20lld\n"
+                               "rctime:    %10ld.%09ld\n",
+                               ci->i_files + ci->i_subdirs,
+                               ci->i_files,
+                               ci->i_subdirs,
+                               ci->i_rfiles + ci->i_rsubdirs,
+                               ci->i_rfiles,
+                               ci->i_rsubdirs,
+                               ci->i_rbytes,
+                               (long)ci->i_rctime.tv_sec,
+                               (long)ci->i_rctime.tv_nsec);
+       }
+
+       if (*ppos >= cf->dir_info_len)
+               return 0;
+       size = min_t(unsigned, size, cf->dir_info_len-*ppos);
+       left = copy_to_user(buf, cf->dir_info + *ppos, size);
+       if (left == size)
+               return -EFAULT;
+       *ppos += (size - left);
+       return size - left;
+}
+
+/*
+ * an fsync() on a dir will wait for any uncommitted directory
+ * operations to commit.
+ */
+static int ceph_dir_fsync(struct file *file, struct dentry *dentry,
+                         int datasync)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct list_head *head = &ci->i_unsafe_dirops;
+       struct ceph_mds_request *req;
+       u64 last_tid;
+       int ret = 0;
+
+       dout("dir_fsync %p\n", inode);
+       spin_lock(&ci->i_unsafe_lock);
+       if (list_empty(head))
+               goto out;
+
+       req = list_entry(head->prev,
+                        struct ceph_mds_request, r_unsafe_dir_item);
+       last_tid = req->r_tid;
+
+       do {
+               ceph_mdsc_get_request(req);
+               spin_unlock(&ci->i_unsafe_lock);
+               dout("dir_fsync %p wait on tid %llu (until %llu)\n",
+                    inode, req->r_tid, last_tid);
+               if (req->r_timeout) {
+                       ret = wait_for_completion_timeout(
+                               &req->r_safe_completion, req->r_timeout);
+                       if (ret > 0)
+                               ret = 0;
+                       else if (ret == 0)
+                               ret = -EIO;  /* timed out */
+               } else {
+                       wait_for_completion(&req->r_safe_completion);
+               }
+               spin_lock(&ci->i_unsafe_lock);
+               ceph_mdsc_put_request(req);
+
+               if (ret || list_empty(head))
+                       break;
+               req = list_entry(head->next,
+                                struct ceph_mds_request, r_unsafe_dir_item);
+       } while (req->r_tid < last_tid);
+out:
+       spin_unlock(&ci->i_unsafe_lock);
+       return ret;
+}
+
+/*
+ * We maintain a private dentry LRU.
+ *
+ * FIXME: this needs to be changed to a per-mds lru to be useful.
+ */
+void ceph_dentry_lru_add(struct dentry *dn)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dn);
+       struct ceph_mds_client *mdsc;
+
+       dout("dentry_lru_add %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
+       if (di) {
+               mdsc = &ceph_client(dn->d_sb)->mdsc;
+               spin_lock(&mdsc->dentry_lru_lock);
+               list_add_tail(&di->lru, &mdsc->dentry_lru);
+               mdsc->num_dentry++;
+               spin_unlock(&mdsc->dentry_lru_lock);
+       }
+}
+
+void ceph_dentry_lru_touch(struct dentry *dn)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dn);
+       struct ceph_mds_client *mdsc;
+
+       dout("dentry_lru_touch %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
+       if (di) {
+               mdsc = &ceph_client(dn->d_sb)->mdsc;
+               spin_lock(&mdsc->dentry_lru_lock);
+               list_move_tail(&di->lru, &mdsc->dentry_lru);
+               spin_unlock(&mdsc->dentry_lru_lock);
+       }
+}
+
+void ceph_dentry_lru_del(struct dentry *dn)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dn);
+       struct ceph_mds_client *mdsc;
+
+       dout("dentry_lru_del %p %p '%.*s'\n", di, dn,
+            dn->d_name.len, dn->d_name.name);
+       if (di) {
+               mdsc = &ceph_client(dn->d_sb)->mdsc;
+               spin_lock(&mdsc->dentry_lru_lock);
+               list_del_init(&di->lru);
+               mdsc->num_dentry--;
+               spin_unlock(&mdsc->dentry_lru_lock);
+       }
+}
+
+const struct file_operations ceph_dir_fops = {
+       .read = ceph_read_dir,
+       .readdir = ceph_readdir,
+       .llseek = ceph_dir_llseek,
+       .open = ceph_open,
+       .release = ceph_release,
+       .unlocked_ioctl = ceph_ioctl,
+       .fsync = ceph_dir_fsync,
+};
+
+const struct inode_operations ceph_dir_iops = {
+       .lookup = ceph_lookup,
+       .permission = ceph_permission,
+       .getattr = ceph_getattr,
+       .setattr = ceph_setattr,
+       .setxattr = ceph_setxattr,
+       .getxattr = ceph_getxattr,
+       .listxattr = ceph_listxattr,
+       .removexattr = ceph_removexattr,
+       .mknod = ceph_mknod,
+       .symlink = ceph_symlink,
+       .mkdir = ceph_mkdir,
+       .link = ceph_link,
+       .unlink = ceph_unlink,
+       .rmdir = ceph_unlink,
+       .rename = ceph_rename,
+       .create = ceph_create,
+};
+
+struct dentry_operations ceph_dentry_ops = {
+       .d_revalidate = ceph_d_revalidate,
+       .d_release = ceph_dentry_release,
+};
+
+struct dentry_operations ceph_snapdir_dentry_ops = {
+       .d_revalidate = ceph_snapdir_d_revalidate,
+};
+
+struct dentry_operations ceph_snap_dentry_ops = {
+};
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
new file mode 100644 (file)
index 0000000..9d67572
--- /dev/null
@@ -0,0 +1,224 @@
+#include "ceph_debug.h"
+
+#include <linux/exportfs.h>
+#include <linux/slab.h>
+#include <asm/unaligned.h>
+
+#include "super.h"
+
+/*
+ * NFS export support
+ *
+ * NFS re-export of a ceph mount is, at present, only semireliable.
+ * The basic issue is that the Ceph architectures doesn't lend itself
+ * well to generating filehandles that will remain valid forever.
+ *
+ * So, we do our best.  If you're lucky, your inode will be in the
+ * client's cache.  If it's not, and you have a connectable fh, then
+ * the MDS server may be able to find it for you.  Otherwise, you get
+ * ESTALE.
+ *
+ * There are ways to this more reliable, but in the non-connectable fh
+ * case, we won't every work perfectly, and in the connectable case,
+ * some changes are needed on the MDS side to work better.
+ */
+
+/*
+ * Basic fh
+ */
+struct ceph_nfs_fh {
+       u64 ino;
+} __attribute__ ((packed));
+
+/*
+ * Larger 'connectable' fh that includes parent ino and name hash.
+ * Use this whenever possible, as it works more reliably.
+ */
+struct ceph_nfs_confh {
+       u64 ino, parent_ino;
+       u32 parent_name_hash;
+} __attribute__ ((packed));
+
+static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
+                         int connectable)
+{
+       struct ceph_nfs_fh *fh = (void *)rawfh;
+       struct ceph_nfs_confh *cfh = (void *)rawfh;
+       struct dentry *parent = dentry->d_parent;
+       struct inode *inode = dentry->d_inode;
+       int type;
+
+       /* don't re-export snaps */
+       if (ceph_snap(inode) != CEPH_NOSNAP)
+               return -EINVAL;
+
+       if (*max_len >= sizeof(*cfh)) {
+               dout("encode_fh %p connectable\n", dentry);
+               cfh->ino = ceph_ino(dentry->d_inode);
+               cfh->parent_ino = ceph_ino(parent->d_inode);
+               cfh->parent_name_hash = parent->d_name.hash;
+               *max_len = sizeof(*cfh);
+               type = 2;
+       } else if (*max_len > sizeof(*fh)) {
+               if (connectable)
+                       return -ENOSPC;
+               dout("encode_fh %p\n", dentry);
+               fh->ino = ceph_ino(dentry->d_inode);
+               *max_len = sizeof(*fh);
+               type = 1;
+       } else {
+               return -ENOSPC;
+       }
+       return type;
+}
+
+/*
+ * convert regular fh to dentry
+ *
+ * FIXME: we should try harder by querying the mds for the ino.
+ */
+static struct dentry *__fh_to_dentry(struct super_block *sb,
+                                    struct ceph_nfs_fh *fh)
+{
+       struct inode *inode;
+       struct dentry *dentry;
+       struct ceph_vino vino;
+       int err;
+
+       dout("__fh_to_dentry %llx\n", fh->ino);
+       vino.ino = fh->ino;
+       vino.snap = CEPH_NOSNAP;
+       inode = ceph_find_inode(sb, vino);
+       if (!inode)
+               return ERR_PTR(-ESTALE);
+
+       dentry = d_obtain_alias(inode);
+       if (!dentry) {
+               pr_err("fh_to_dentry %llx -- inode %p but ENOMEM\n",
+                      fh->ino, inode);
+               iput(inode);
+               return ERR_PTR(-ENOMEM);
+       }
+       err = ceph_init_dentry(dentry);
+
+       if (err < 0) {
+               iput(inode);
+               return ERR_PTR(err);
+       }
+       dout("__fh_to_dentry %llx %p dentry %p\n", fh->ino, inode, dentry);
+       return dentry;
+}
+
+/*
+ * convert connectable fh to dentry
+ */
+static struct dentry *__cfh_to_dentry(struct super_block *sb,
+                                     struct ceph_nfs_confh *cfh)
+{
+       struct ceph_mds_client *mdsc = &ceph_client(sb)->mdsc;
+       struct inode *inode;
+       struct dentry *dentry;
+       struct ceph_vino vino;
+       int err;
+
+       dout("__cfh_to_dentry %llx (%llx/%x)\n",
+            cfh->ino, cfh->parent_ino, cfh->parent_name_hash);
+
+       vino.ino = cfh->ino;
+       vino.snap = CEPH_NOSNAP;
+       inode = ceph_find_inode(sb, vino);
+       if (!inode) {
+               struct ceph_mds_request *req;
+
+               req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPHASH,
+                                              USE_ANY_MDS);
+               if (IS_ERR(req))
+                       return ERR_PTR(PTR_ERR(req));
+
+               req->r_ino1 = vino;
+               req->r_ino2.ino = cfh->parent_ino;
+               req->r_ino2.snap = CEPH_NOSNAP;
+               req->r_path2 = kmalloc(16, GFP_NOFS);
+               snprintf(req->r_path2, 16, "%d", cfh->parent_name_hash);
+               req->r_num_caps = 1;
+               err = ceph_mdsc_do_request(mdsc, NULL, req);
+               ceph_mdsc_put_request(req);
+               inode = ceph_find_inode(sb, vino);
+               if (!inode)
+                       return ERR_PTR(err ? err : -ESTALE);
+       }
+
+       dentry = d_obtain_alias(inode);
+       if (!dentry) {
+               pr_err("cfh_to_dentry %llx -- inode %p but ENOMEM\n",
+                      cfh->ino, inode);
+               iput(inode);
+               return ERR_PTR(-ENOMEM);
+       }
+       err = ceph_init_dentry(dentry);
+       if (err < 0) {
+               iput(inode);
+               return ERR_PTR(err);
+       }
+       dout("__cfh_to_dentry %llx %p dentry %p\n", cfh->ino, inode, dentry);
+       return dentry;
+}
+
+static struct dentry *ceph_fh_to_dentry(struct super_block *sb, struct fid *fid,
+                                       int fh_len, int fh_type)
+{
+       if (fh_type == 1)
+               return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw);
+       else
+               return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw);
+}
+
+/*
+ * get parent, if possible.
+ *
+ * FIXME: we could do better by querying the mds to discover the
+ * parent.
+ */
+static struct dentry *ceph_fh_to_parent(struct super_block *sb,
+                                        struct fid *fid,
+                                       int fh_len, int fh_type)
+{
+       struct ceph_nfs_confh *cfh = (void *)fid->raw;
+       struct ceph_vino vino;
+       struct inode *inode;
+       struct dentry *dentry;
+       int err;
+
+       if (fh_type == 1)
+               return ERR_PTR(-ESTALE);
+
+       pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino,
+                cfh->parent_name_hash);
+
+       vino.ino = cfh->ino;
+       vino.snap = CEPH_NOSNAP;
+       inode = ceph_find_inode(sb, vino);
+       if (!inode)
+               return ERR_PTR(-ESTALE);
+
+       dentry = d_obtain_alias(inode);
+       if (!dentry) {
+               pr_err("fh_to_parent %llx -- inode %p but ENOMEM\n",
+                      cfh->ino, inode);
+               iput(inode);
+               return ERR_PTR(-ENOMEM);
+       }
+       err = ceph_init_dentry(dentry);
+       if (err < 0) {
+               iput(inode);
+               return ERR_PTR(err);
+       }
+       dout("fh_to_parent %llx %p dentry %p\n", cfh->ino, inode, dentry);
+       return dentry;
+}
+
+const struct export_operations ceph_export_ops = {
+       .encode_fh = ceph_encode_fh,
+       .fh_to_dentry = ceph_fh_to_dentry,
+       .fh_to_parent = ceph_fh_to_parent,
+};
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
new file mode 100644 (file)
index 0000000..4add3d5
--- /dev/null
@@ -0,0 +1,938 @@
+#include "ceph_debug.h"
+
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/file.h>
+#include <linux/namei.h>
+#include <linux/writeback.h>
+
+#include "super.h"
+#include "mds_client.h"
+
+/*
+ * Ceph file operations
+ *
+ * Implement basic open/close functionality, and implement
+ * read/write.
+ *
+ * We implement three modes of file I/O:
+ *  - buffered uses the generic_file_aio_{read,write} helpers
+ *
+ *  - synchronous is used when there is multi-client read/write
+ *    sharing, avoids the page cache, and synchronously waits for an
+ *    ack from the OSD.
+ *
+ *  - direct io takes the variant of the sync path that references
+ *    user pages directly.
+ *
+ * fsync() flushes and waits on dirty pages, but just queues metadata
+ * for writeback: since the MDS can recover size and mtime there is no
+ * need to wait for MDS acknowledgement.
+ */
+
+
+/*
+ * Prepare an open request.  Preallocate ceph_cap to avoid an
+ * inopportune ENOMEM later.
+ */
+static struct ceph_mds_request *
+prepare_open_request(struct super_block *sb, int flags, int create_mode)
+{
+       struct ceph_client *client = ceph_sb_to_client(sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int want_auth = USE_ANY_MDS;
+       int op = (flags & O_CREAT) ? CEPH_MDS_OP_CREATE : CEPH_MDS_OP_OPEN;
+
+       if (flags & (O_WRONLY|O_RDWR|O_CREAT|O_TRUNC))
+               want_auth = USE_AUTH_MDS;
+
+       req = ceph_mdsc_create_request(mdsc, op, want_auth);
+       if (IS_ERR(req))
+               goto out;
+       req->r_fmode = ceph_flags_to_mode(flags);
+       req->r_args.open.flags = cpu_to_le32(flags);
+       req->r_args.open.mode = cpu_to_le32(create_mode);
+       req->r_args.open.preferred = cpu_to_le32(-1);
+out:
+       return req;
+}
+
+/*
+ * initialize private struct file data.
+ * if we fail, clean up by dropping fmode reference on the ceph_inode
+ */
+static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
+{
+       struct ceph_file_info *cf;
+       int ret = 0;
+
+       switch (inode->i_mode & S_IFMT) {
+       case S_IFREG:
+       case S_IFDIR:
+               dout("init_file %p %p 0%o (regular)\n", inode, file,
+                    inode->i_mode);
+               cf = kmem_cache_alloc(ceph_file_cachep, GFP_NOFS | __GFP_ZERO);
+               if (cf == NULL) {
+                       ceph_put_fmode(ceph_inode(inode), fmode); /* clean up */
+                       return -ENOMEM;
+               }
+               cf->fmode = fmode;
+               cf->next_offset = 2;
+               file->private_data = cf;
+               BUG_ON(inode->i_fop->release != ceph_release);
+               break;
+
+       case S_IFLNK:
+               dout("init_file %p %p 0%o (symlink)\n", inode, file,
+                    inode->i_mode);
+               ceph_put_fmode(ceph_inode(inode), fmode); /* clean up */
+               break;
+
+       default:
+               dout("init_file %p %p 0%o (special)\n", inode, file,
+                    inode->i_mode);
+               /*
+                * we need to drop the open ref now, since we don't
+                * have .release set to ceph_release.
+                */
+               ceph_put_fmode(ceph_inode(inode), fmode); /* clean up */
+               BUG_ON(inode->i_fop->release == ceph_release);
+
+               /* call the proper open fop */
+               ret = inode->i_fop->open(inode, file);
+       }
+       return ret;
+}
+
+/*
+ * If the filp already has private_data, that means the file was
+ * already opened by intent during lookup, and we do nothing.
+ *
+ * If we already have the requisite capabilities, we can satisfy
+ * the open request locally (no need to request new caps from the
+ * MDS).  We do, however, need to inform the MDS (asynchronously)
+ * if our wanted caps set expands.
+ */
+int ceph_open(struct inode *inode, struct file *file)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_client *client = ceph_sb_to_client(inode->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       struct ceph_file_info *cf = file->private_data;
+       struct inode *parent_inode = file->f_dentry->d_parent->d_inode;
+       int err;
+       int flags, fmode, wanted;
+
+       if (cf) {
+               dout("open file %p is already opened\n", file);
+               return 0;
+       }
+
+       /* filter out O_CREAT|O_EXCL; vfs did that already.  yuck. */
+       flags = file->f_flags & ~(O_CREAT|O_EXCL);
+       if (S_ISDIR(inode->i_mode))
+               flags = O_DIRECTORY;  /* mds likes to know */
+
+       dout("open inode %p ino %llx.%llx file %p flags %d (%d)\n", inode,
+            ceph_vinop(inode), file, flags, file->f_flags);
+       fmode = ceph_flags_to_mode(flags);
+       wanted = ceph_caps_for_mode(fmode);
+
+       /* snapped files are read-only */
+       if (ceph_snap(inode) != CEPH_NOSNAP && (file->f_mode & FMODE_WRITE))
+               return -EROFS;
+
+       /* trivially open snapdir */
+       if (ceph_snap(inode) == CEPH_SNAPDIR) {
+               spin_lock(&inode->i_lock);
+               __ceph_get_fmode(ci, fmode);
+               spin_unlock(&inode->i_lock);
+               return ceph_init_file(inode, file, fmode);
+       }
+
+       /*
+        * No need to block if we have any caps.  Update wanted set
+        * asynchronously.
+        */
+       spin_lock(&inode->i_lock);
+       if (__ceph_is_any_real_caps(ci)) {
+               int mds_wanted = __ceph_caps_mds_wanted(ci);
+               int issued = __ceph_caps_issued(ci, NULL);
+
+               dout("open %p fmode %d want %s issued %s using existing\n",
+                    inode, fmode, ceph_cap_string(wanted),
+                    ceph_cap_string(issued));
+               __ceph_get_fmode(ci, fmode);
+               spin_unlock(&inode->i_lock);
+
+               /* adjust wanted? */
+               if ((issued & wanted) != wanted &&
+                   (mds_wanted & wanted) != wanted &&
+                   ceph_snap(inode) != CEPH_SNAPDIR)
+                       ceph_check_caps(ci, 0, NULL);
+
+               return ceph_init_file(inode, file, fmode);
+       } else if (ceph_snap(inode) != CEPH_NOSNAP &&
+                  (ci->i_snap_caps & wanted) == wanted) {
+               __ceph_get_fmode(ci, fmode);
+               spin_unlock(&inode->i_lock);
+               return ceph_init_file(inode, file, fmode);
+       }
+       spin_unlock(&inode->i_lock);
+
+       dout("open fmode %d wants %s\n", fmode, ceph_cap_string(wanted));
+       req = prepare_open_request(inode->i_sb, flags, 0);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto out;
+       }
+       req->r_inode = igrab(inode);
+       req->r_num_caps = 1;
+       err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       if (!err)
+               err = ceph_init_file(inode, file, req->r_fmode);
+       ceph_mdsc_put_request(req);
+       dout("open result=%d on %llx.%llx\n", err, ceph_vinop(inode));
+out:
+       return err;
+}
+
+
+/*
+ * Do a lookup + open with a single request.
+ *
+ * If this succeeds, but some subsequent check in the vfs
+ * may_open() fails, the struct *file gets cleaned up (i.e.
+ * ceph_release gets called).  So fear not!
+ */
+/*
+ * flags
+ *  path_lookup_open   -> LOOKUP_OPEN
+ *  path_lookup_create -> LOOKUP_OPEN|LOOKUP_CREATE
+ */
+struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
+                               struct nameidata *nd, int mode,
+                               int locked_dir)
+{
+       struct ceph_client *client = ceph_sb_to_client(dir->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct file *file = nd->intent.open.file;
+       struct inode *parent_inode = get_dentry_parent_inode(file->f_dentry);
+       struct ceph_mds_request *req;
+       int err;
+       int flags = nd->intent.open.flags - 1;  /* silly vfs! */
+
+       dout("ceph_lookup_open dentry %p '%.*s' flags %d mode 0%o\n",
+            dentry, dentry->d_name.len, dentry->d_name.name, flags, mode);
+
+       /* do the open */
+       req = prepare_open_request(dir->i_sb, flags, mode);
+       if (IS_ERR(req))
+               return ERR_PTR(PTR_ERR(req));
+       req->r_dentry = dget(dentry);
+       req->r_num_caps = 2;
+       if (flags & O_CREAT) {
+               req->r_dentry_drop = CEPH_CAP_FILE_SHARED;
+               req->r_dentry_unless = CEPH_CAP_FILE_EXCL;
+       }
+       req->r_locked_dir = dir;           /* caller holds dir->i_mutex */
+       err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       dentry = ceph_finish_lookup(req, dentry, err);
+       if (!err && (flags & O_CREAT) && !req->r_reply_info.head->is_dentry)
+               err = ceph_handle_notrace_create(dir, dentry);
+       if (!err)
+               err = ceph_init_file(req->r_dentry->d_inode, file,
+                                    req->r_fmode);
+       ceph_mdsc_put_request(req);
+       dout("ceph_lookup_open result=%p\n", dentry);
+       return dentry;
+}
+
+int ceph_release(struct inode *inode, struct file *file)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_file_info *cf = file->private_data;
+
+       dout("release inode %p file %p\n", inode, file);
+       ceph_put_fmode(ci, cf->fmode);
+       if (cf->last_readdir)
+               ceph_mdsc_put_request(cf->last_readdir);
+       kfree(cf->last_name);
+       kfree(cf->dir_info);
+       dput(cf->dentry);
+       kmem_cache_free(ceph_file_cachep, cf);
+
+       /* wake up anyone waiting for caps on this inode */
+       wake_up(&ci->i_cap_wq);
+       return 0;
+}
+
+/*
+ * build a vector of user pages
+ */
+static struct page **get_direct_page_vector(const char __user *data,
+                                           int num_pages,
+                                           loff_t off, size_t len)
+{
+       struct page **pages;
+       int rc;
+
+       pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
+       if (!pages)
+               return ERR_PTR(-ENOMEM);
+
+       down_read(&current->mm->mmap_sem);
+       rc = get_user_pages(current, current->mm, (unsigned long)data,
+                           num_pages, 0, 0, pages, NULL);
+       up_read(&current->mm->mmap_sem);
+       if (rc < 0)
+               goto fail;
+       return pages;
+
+fail:
+       kfree(pages);
+       return ERR_PTR(rc);
+}
+
+static void put_page_vector(struct page **pages, int num_pages)
+{
+       int i;
+
+       for (i = 0; i < num_pages; i++)
+               put_page(pages[i]);
+       kfree(pages);
+}
+
+void ceph_release_page_vector(struct page **pages, int num_pages)
+{
+       int i;
+
+       for (i = 0; i < num_pages; i++)
+               __free_pages(pages[i], 0);
+       kfree(pages);
+}
+
+/*
+ * allocate a vector new pages
+ */
+static struct page **alloc_page_vector(int num_pages)
+{
+       struct page **pages;
+       int i;
+
+       pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
+       if (!pages)
+               return ERR_PTR(-ENOMEM);
+       for (i = 0; i < num_pages; i++) {
+               pages[i] = alloc_page(GFP_NOFS);
+               if (pages[i] == NULL) {
+                       ceph_release_page_vector(pages, i);
+                       return ERR_PTR(-ENOMEM);
+               }
+       }
+       return pages;
+}
+
+/*
+ * copy user data into a page vector
+ */
+static int copy_user_to_page_vector(struct page **pages,
+                                   const char __user *data,
+                                   loff_t off, size_t len)
+{
+       int i = 0;
+       int po = off & ~PAGE_CACHE_MASK;
+       int left = len;
+       int l, bad;
+
+       while (left > 0) {
+               l = min_t(int, PAGE_CACHE_SIZE-po, left);
+               bad = copy_from_user(page_address(pages[i]) + po, data, l);
+               if (bad == l)
+                       return -EFAULT;
+               data += l - bad;
+               left -= l - bad;
+               po += l - bad;
+               if (po == PAGE_CACHE_SIZE) {
+                       po = 0;
+                       i++;
+               }
+       }
+       return len;
+}
+
+/*
+ * copy user data from a page vector into a user pointer
+ */
+static int copy_page_vector_to_user(struct page **pages, char __user *data,
+                                   loff_t off, size_t len)
+{
+       int i = 0;
+       int po = off & ~PAGE_CACHE_MASK;
+       int left = len;
+       int l, bad;
+
+       while (left > 0) {
+               l = min_t(int, left, PAGE_CACHE_SIZE-po);
+               bad = copy_to_user(data, page_address(pages[i]) + po, l);
+               if (bad == l)
+                       return -EFAULT;
+               data += l - bad;
+               left -= l - bad;
+               if (po) {
+                       po += l - bad;
+                       if (po == PAGE_CACHE_SIZE)
+                               po = 0;
+               }
+               i++;
+       }
+       return len;
+}
+
+/*
+ * Zero an extent within a page vector.  Offset is relative to the
+ * start of the first page.
+ */
+static void zero_page_vector_range(int off, int len, struct page **pages)
+{
+       int i = off >> PAGE_CACHE_SHIFT;
+
+       off &= ~PAGE_CACHE_MASK;
+
+       dout("zero_page_vector_page %u~%u\n", off, len);
+
+       /* leading partial page? */
+       if (off) {
+               int end = min((int)PAGE_CACHE_SIZE, off + len);
+               dout("zeroing %d %p head from %d\n", i, pages[i],
+                    (int)off);
+               zero_user_segment(pages[i], off, end);
+               len -= (end - off);
+               i++;
+       }
+       while (len >= PAGE_CACHE_SIZE) {
+               dout("zeroing %d %p len=%d\n", i, pages[i], len);
+               zero_user_segment(pages[i], 0, PAGE_CACHE_SIZE);
+               len -= PAGE_CACHE_SIZE;
+               i++;
+       }
+       /* trailing partial page? */
+       if (len) {
+               dout("zeroing %d %p tail to %d\n", i, pages[i], (int)len);
+               zero_user_segment(pages[i], 0, len);
+       }
+}
+
+
+/*
+ * Read a range of bytes striped over one or more objects.  Iterate over
+ * objects we stripe over.  (That's not atomic, but good enough for now.)
+ *
+ * If we get a short result from the OSD, check against i_size; we need to
+ * only return a short read to the caller if we hit EOF.
+ */
+static int striped_read(struct inode *inode,
+                       u64 off, u64 len,
+                       struct page **pages, int num_pages,
+                       int *checkeof)
+{
+       struct ceph_client *client = ceph_inode_to_client(inode);
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       u64 pos, this_len;
+       int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */
+       int left, pages_left;
+       int read;
+       struct page **page_pos;
+       int ret;
+       bool hit_stripe, was_short;
+
+       /*
+        * we may need to do multiple reads.  not atomic, unfortunately.
+        */
+       pos = off;
+       left = len;
+       page_pos = pages;
+       pages_left = num_pages;
+       read = 0;
+
+more:
+       this_len = left;
+       ret = ceph_osdc_readpages(&client->osdc, ceph_vino(inode),
+                                 &ci->i_layout, pos, &this_len,
+                                 ci->i_truncate_seq,
+                                 ci->i_truncate_size,
+                                 page_pos, pages_left);
+       hit_stripe = this_len < left;
+       was_short = ret >= 0 && ret < this_len;
+       if (ret == -ENOENT)
+               ret = 0;
+       dout("striped_read %llu~%u (read %u) got %d%s%s\n", pos, left, read,
+            ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : "");
+
+       if (ret > 0) {
+               int didpages =
+                       ((pos & ~PAGE_CACHE_MASK) + ret) >> PAGE_CACHE_SHIFT;
+
+               if (read < pos - off) {
+                       dout(" zero gap %llu to %llu\n", off + read, pos);
+                       zero_page_vector_range(page_off + read,
+                                              pos - off - read, pages);
+               }
+               pos += ret;
+               read = pos - off;
+               left -= ret;
+               page_pos += didpages;
+               pages_left -= didpages;
+
+               /* hit stripe? */
+               if (left && hit_stripe)
+                       goto more;
+       }
+
+       if (was_short) {
+               /* was original extent fully inside i_size? */
+               if (pos + left <= inode->i_size) {
+                       dout("zero tail\n");
+                       zero_page_vector_range(page_off + read, len - read,
+                                              pages);
+                       read = len;
+                       goto out;
+               }
+
+               /* check i_size */
+               *checkeof = 1;
+       }
+
+out:
+       if (ret >= 0)
+               ret = read;
+       dout("striped_read returns %d\n", ret);
+       return ret;
+}
+
+/*
+ * Completely synchronous read and write methods.  Direct from __user
+ * buffer to osd, or directly to user pages (if O_DIRECT).
+ *
+ * If the read spans object boundary, just do multiple reads.
+ */
+static ssize_t ceph_sync_read(struct file *file, char __user *data,
+                             unsigned len, loff_t *poff, int *checkeof)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct page **pages;
+       u64 off = *poff;
+       int num_pages = calc_pages_for(off, len);
+       int ret;
+
+       dout("sync_read on file %p %llu~%u %s\n", file, off, len,
+            (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");
+
+       if (file->f_flags & O_DIRECT) {
+               pages = get_direct_page_vector(data, num_pages, off, len);
+
+               /*
+                * flush any page cache pages in this range.  this
+                * will make concurrent normal and O_DIRECT io slow,
+                * but it will at least behave sensibly when they are
+                * in sequence.
+                */
+       } else {
+               pages = alloc_page_vector(num_pages);
+       }
+       if (IS_ERR(pages))
+               return PTR_ERR(pages);
+
+       ret = filemap_write_and_wait(inode->i_mapping);
+       if (ret < 0)
+               goto done;
+
+       ret = striped_read(inode, off, len, pages, num_pages, checkeof);
+
+       if (ret >= 0 && (file->f_flags & O_DIRECT) == 0)
+               ret = copy_page_vector_to_user(pages, data, off, ret);
+       if (ret >= 0)
+               *poff = off + ret;
+
+done:
+       if (file->f_flags & O_DIRECT)
+               put_page_vector(pages, num_pages);
+       else
+               ceph_release_page_vector(pages, num_pages);
+       dout("sync_read result %d\n", ret);
+       return ret;
+}
+
+/*
+ * Write commit callback, called if we requested both an ACK and
+ * ONDISK commit reply from the OSD.
+ */
+static void sync_write_commit(struct ceph_osd_request *req,
+                             struct ceph_msg *msg)
+{
+       struct ceph_inode_info *ci = ceph_inode(req->r_inode);
+
+       dout("sync_write_commit %p tid %llu\n", req, req->r_tid);
+       spin_lock(&ci->i_unsafe_lock);
+       list_del_init(&req->r_unsafe_item);
+       spin_unlock(&ci->i_unsafe_lock);
+       ceph_put_cap_refs(ci, CEPH_CAP_FILE_WR);
+}
+
+/*
+ * Synchronous write, straight from __user pointer or user pages (if
+ * O_DIRECT).
+ *
+ * If write spans object boundary, just do multiple writes.  (For a
+ * correct atomic write, we should e.g. take write locks on all
+ * objects, rollback on failure, etc.)
+ */
+static ssize_t ceph_sync_write(struct file *file, const char __user *data,
+                              size_t left, loff_t *offset)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_client *client = ceph_inode_to_client(inode);
+       struct ceph_osd_request *req;
+       struct page **pages;
+       int num_pages;
+       long long unsigned pos;
+       u64 len;
+       int written = 0;
+       int flags;
+       int do_sync = 0;
+       int check_caps = 0;
+       int ret;
+       struct timespec mtime = CURRENT_TIME;
+
+       if (ceph_snap(file->f_dentry->d_inode) != CEPH_NOSNAP)
+               return -EROFS;
+
+       dout("sync_write on file %p %lld~%u %s\n", file, *offset,
+            (unsigned)left, (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");
+
+       if (file->f_flags & O_APPEND)
+               pos = i_size_read(inode);
+       else
+               pos = *offset;
+
+       ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left);
+       if (ret < 0)
+               return ret;
+
+       ret = invalidate_inode_pages2_range(inode->i_mapping,
+                                           pos >> PAGE_CACHE_SHIFT,
+                                           (pos + left) >> PAGE_CACHE_SHIFT);
+       if (ret < 0)
+               dout("invalidate_inode_pages2_range returned %d\n", ret);
+
+       flags = CEPH_OSD_FLAG_ORDERSNAP |
+               CEPH_OSD_FLAG_ONDISK |
+               CEPH_OSD_FLAG_WRITE;
+       if ((file->f_flags & (O_SYNC|O_DIRECT)) == 0)
+               flags |= CEPH_OSD_FLAG_ACK;
+       else
+               do_sync = 1;
+
+       /*
+        * we may need to do multiple writes here if we span an object
+        * boundary.  this isn't atomic, unfortunately.  :(
+        */
+more:
+       len = left;
+       req = ceph_osdc_new_request(&client->osdc, &ci->i_layout,
+                                   ceph_vino(inode), pos, &len,
+                                   CEPH_OSD_OP_WRITE, flags,
+                                   ci->i_snap_realm->cached_context,
+                                   do_sync,
+                                   ci->i_truncate_seq, ci->i_truncate_size,
+                                   &mtime, false, 2);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+
+       num_pages = calc_pages_for(pos, len);
+
+       if (file->f_flags & O_DIRECT) {
+               pages = get_direct_page_vector(data, num_pages, pos, len);
+               if (IS_ERR(pages)) {
+                       ret = PTR_ERR(pages);
+                       goto out;
+               }
+
+               /*
+                * throw out any page cache pages in this range. this
+                * may block.
+                */
+               truncate_inode_pages_range(inode->i_mapping, pos, pos+len);
+       } else {
+               pages = alloc_page_vector(num_pages);
+               if (IS_ERR(pages)) {
+                       ret = PTR_ERR(pages);
+                       goto out;
+               }
+               ret = copy_user_to_page_vector(pages, data, pos, len);
+               if (ret < 0) {
+                       ceph_release_page_vector(pages, num_pages);
+                       goto out;
+               }
+
+               if ((file->f_flags & O_SYNC) == 0) {
+                       /* get a second commit callback */
+                       req->r_safe_callback = sync_write_commit;
+                       req->r_own_pages = 1;
+               }
+       }
+       req->r_pages = pages;
+       req->r_num_pages = num_pages;
+       req->r_inode = inode;
+
+       ret = ceph_osdc_start_request(&client->osdc, req, false);
+       if (!ret) {
+               if (req->r_safe_callback) {
+                       /*
+                        * Add to inode unsafe list only after we
+                        * start_request so that a tid has been assigned.
+                        */
+                       spin_lock(&ci->i_unsafe_lock);
+                       list_add(&ci->i_unsafe_writes, &req->r_unsafe_item);
+                       spin_unlock(&ci->i_unsafe_lock);
+                       ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR);
+               }
+               ret = ceph_osdc_wait_request(&client->osdc, req);
+       }
+
+       if (file->f_flags & O_DIRECT)
+               put_page_vector(pages, num_pages);
+       else if (file->f_flags & O_SYNC)
+               ceph_release_page_vector(pages, num_pages);
+
+out:
+       ceph_osdc_put_request(req);
+       if (ret == 0) {
+               pos += len;
+               written += len;
+               left -= len;
+               if (left)
+                       goto more;
+
+               ret = written;
+               *offset = pos;
+               if (pos > i_size_read(inode))
+                       check_caps = ceph_inode_set_size(inode, pos);
+               if (check_caps)
+                       ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY,
+                                       NULL);
+       }
+       return ret;
+}
+
+/*
+ * Wrap generic_file_aio_read with checks for cap bits on the inode.
+ * Atomically grab references, so that those bits are not released
+ * back to the MDS mid-read.
+ *
+ * Hmm, the sync read case isn't actually async... should it be?
+ */
+static ssize_t ceph_aio_read(struct kiocb *iocb, const struct iovec *iov,
+                            unsigned long nr_segs, loff_t pos)
+{
+       struct file *filp = iocb->ki_filp;
+       loff_t *ppos = &iocb->ki_pos;
+       size_t len = iov->iov_len;
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       void *base = iov->iov_base;
+       ssize_t ret;
+       int got = 0;
+       int checkeof = 0, read = 0;
+
+       dout("aio_read %p %llx.%llx %llu~%u trying to get caps on %p\n",
+            inode, ceph_vinop(inode), pos, (unsigned)len, inode);
+again:
+       __ceph_do_pending_vmtruncate(inode);
+       ret = ceph_get_caps(ci, CEPH_CAP_FILE_RD, CEPH_CAP_FILE_CACHE,
+                           &got, -1);
+       if (ret < 0)
+               goto out;
+       dout("aio_read %p %llx.%llx %llu~%u got cap refs on %s\n",
+            inode, ceph_vinop(inode), pos, (unsigned)len,
+            ceph_cap_string(got));
+
+       if ((got & CEPH_CAP_FILE_CACHE) == 0 ||
+           (iocb->ki_filp->f_flags & O_DIRECT) ||
+           (inode->i_sb->s_flags & MS_SYNCHRONOUS))
+               /* hmm, this isn't really async... */
+               ret = ceph_sync_read(filp, base, len, ppos, &checkeof);
+       else
+               ret = generic_file_aio_read(iocb, iov, nr_segs, pos);
+
+out:
+       dout("aio_read %p %llx.%llx dropping cap refs on %s = %d\n",
+            inode, ceph_vinop(inode), ceph_cap_string(got), (int)ret);
+       ceph_put_cap_refs(ci, got);
+
+       if (checkeof && ret >= 0) {
+               int statret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
+
+               /* hit EOF or hole? */
+               if (statret == 0 && *ppos < inode->i_size) {
+                       dout("aio_read sync_read hit hole, reading more\n");
+                       read += ret;
+                       base += ret;
+                       len -= ret;
+                       checkeof = 0;
+                       goto again;
+               }
+       }
+       if (ret >= 0)
+               ret += read;
+
+       return ret;
+}
+
+/*
+ * Take cap references to avoid releasing caps to MDS mid-write.
+ *
+ * If we are synchronous, and write with an old snap context, the OSD
+ * may return EOLDSNAPC.  In that case, retry the write.. _after_
+ * dropping our cap refs and allowing the pending snap to logically
+ * complete _before_ this write occurs.
+ *
+ * If we are near ENOSPC, write synchronously.
+ */
+static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
+                      unsigned long nr_segs, loff_t pos)
+{
+       struct file *file = iocb->ki_filp;
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_osd_client *osdc = &ceph_client(inode->i_sb)->osdc;
+       loff_t endoff = pos + iov->iov_len;
+       int got = 0;
+       int ret, err;
+
+       if (ceph_snap(inode) != CEPH_NOSNAP)
+               return -EROFS;
+
+retry_snap:
+       if (ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_FULL))
+               return -ENOSPC;
+       __ceph_do_pending_vmtruncate(inode);
+       dout("aio_write %p %llx.%llx %llu~%u getting caps. i_size %llu\n",
+            inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len,
+            inode->i_size);
+       ret = ceph_get_caps(ci, CEPH_CAP_FILE_WR, CEPH_CAP_FILE_BUFFER,
+                           &got, endoff);
+       if (ret < 0)
+               goto out;
+
+       dout("aio_write %p %llx.%llx %llu~%u  got cap refs on %s\n",
+            inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len,
+            ceph_cap_string(got));
+
+       if ((got & CEPH_CAP_FILE_BUFFER) == 0 ||
+           (iocb->ki_filp->f_flags & O_DIRECT) ||
+           (inode->i_sb->s_flags & MS_SYNCHRONOUS)) {
+               ret = ceph_sync_write(file, iov->iov_base, iov->iov_len,
+                       &iocb->ki_pos);
+       } else {
+               ret = generic_file_aio_write(iocb, iov, nr_segs, pos);
+
+               if ((ret >= 0 || ret == -EIOCBQUEUED) &&
+                   ((file->f_flags & O_SYNC) || IS_SYNC(file->f_mapping->host)
+                    || ceph_osdmap_flag(osdc->osdmap, CEPH_OSDMAP_NEARFULL))) {
+                       err = vfs_fsync_range(file, file->f_path.dentry,
+                                             pos, pos + ret - 1, 1);
+                       if (err < 0)
+                               ret = err;
+               }
+       }
+       if (ret >= 0) {
+               spin_lock(&inode->i_lock);
+               __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR);
+               spin_unlock(&inode->i_lock);
+       }
+
+out:
+       dout("aio_write %p %llx.%llx %llu~%u  dropping cap refs on %s\n",
+            inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len,
+            ceph_cap_string(got));
+       ceph_put_cap_refs(ci, got);
+
+       if (ret == -EOLDSNAPC) {
+               dout("aio_write %p %llx.%llx %llu~%u got EOLDSNAPC, retrying\n",
+                    inode, ceph_vinop(inode), pos, (unsigned)iov->iov_len);
+               goto retry_snap;
+       }
+
+       return ret;
+}
+
+/*
+ * llseek.  be sure to verify file size on SEEK_END.
+ */
+static loff_t ceph_llseek(struct file *file, loff_t offset, int origin)
+{
+       struct inode *inode = file->f_mapping->host;
+       int ret;
+
+       mutex_lock(&inode->i_mutex);
+       __ceph_do_pending_vmtruncate(inode);
+       switch (origin) {
+       case SEEK_END:
+               ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
+               if (ret < 0) {
+                       offset = ret;
+                       goto out;
+               }
+               offset += inode->i_size;
+               break;
+       case SEEK_CUR:
+               /*
+                * Here we special-case the lseek(fd, 0, SEEK_CUR)
+                * position-querying operation.  Avoid rewriting the "same"
+                * f_pos value back to the file because a concurrent read(),
+                * write() or lseek() might have altered it
+                */
+               if (offset == 0) {
+                       offset = file->f_pos;
+                       goto out;
+               }
+               offset += file->f_pos;
+               break;
+       }
+
+       if (offset < 0 || offset > inode->i_sb->s_maxbytes) {
+               offset = -EINVAL;
+               goto out;
+       }
+
+       /* Special lock needed here? */
+       if (offset != file->f_pos) {
+               file->f_pos = offset;
+               file->f_version = 0;
+       }
+
+out:
+       mutex_unlock(&inode->i_mutex);
+       return offset;
+}
+
+const struct file_operations ceph_file_fops = {
+       .open = ceph_open,
+       .release = ceph_release,
+       .llseek = ceph_llseek,
+       .read = do_sync_read,
+       .write = do_sync_write,
+       .aio_read = ceph_aio_read,
+       .aio_write = ceph_aio_write,
+       .mmap = ceph_mmap,
+       .fsync = ceph_fsync,
+       .splice_read = generic_file_splice_read,
+       .splice_write = generic_file_splice_write,
+       .unlocked_ioctl = ceph_ioctl,
+       .compat_ioctl   = ceph_ioctl,
+};
+
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
new file mode 100644 (file)
index 0000000..aca82d5
--- /dev/null
@@ -0,0 +1,1766 @@
+#include "ceph_debug.h"
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/smp_lock.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/uaccess.h>
+#include <linux/kernel.h>
+#include <linux/namei.h>
+#include <linux/writeback.h>
+#include <linux/vmalloc.h>
+#include <linux/pagevec.h>
+
+#include "super.h"
+#include "decode.h"
+
+/*
+ * Ceph inode operations
+ *
+ * Implement basic inode helpers (get, alloc) and inode ops (getattr,
+ * setattr, etc.), xattr helpers, and helpers for assimilating
+ * metadata returned by the MDS into our cache.
+ *
+ * Also define helpers for doing asynchronous writeback, invalidation,
+ * and truncation for the benefit of those who can't afford to block
+ * (typically because they are in the message handler path).
+ */
+
+static const struct inode_operations ceph_symlink_iops;
+
+static void ceph_invalidate_work(struct work_struct *work);
+static void ceph_writeback_work(struct work_struct *work);
+static void ceph_vmtruncate_work(struct work_struct *work);
+
+/*
+ * find or create an inode, given the ceph ino number
+ */
+struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
+{
+       struct inode *inode;
+       ino_t t = ceph_vino_to_ino(vino);
+
+       inode = iget5_locked(sb, t, ceph_ino_compare, ceph_set_ino_cb, &vino);
+       if (inode == NULL)
+               return ERR_PTR(-ENOMEM);
+       if (inode->i_state & I_NEW) {
+               dout("get_inode created new inode %p %llx.%llx ino %llx\n",
+                    inode, ceph_vinop(inode), (u64)inode->i_ino);
+               unlock_new_inode(inode);
+       }
+
+       dout("get_inode on %lu=%llx.%llx got %p\n", inode->i_ino, vino.ino,
+            vino.snap, inode);
+       return inode;
+}
+
+/*
+ * get/constuct snapdir inode for a given directory
+ */
+struct inode *ceph_get_snapdir(struct inode *parent)
+{
+       struct ceph_vino vino = {
+               .ino = ceph_ino(parent),
+               .snap = CEPH_SNAPDIR,
+       };
+       struct inode *inode = ceph_get_inode(parent->i_sb, vino);
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       BUG_ON(!S_ISDIR(parent->i_mode));
+       if (IS_ERR(inode))
+               return ERR_PTR(PTR_ERR(inode));
+       inode->i_mode = parent->i_mode;
+       inode->i_uid = parent->i_uid;
+       inode->i_gid = parent->i_gid;
+       inode->i_op = &ceph_dir_iops;
+       inode->i_fop = &ceph_dir_fops;
+       ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
+       ci->i_rbytes = 0;
+       return inode;
+}
+
+const struct inode_operations ceph_file_iops = {
+       .permission = ceph_permission,
+       .setattr = ceph_setattr,
+       .getattr = ceph_getattr,
+       .setxattr = ceph_setxattr,
+       .getxattr = ceph_getxattr,
+       .listxattr = ceph_listxattr,
+       .removexattr = ceph_removexattr,
+};
+
+
+/*
+ * We use a 'frag tree' to keep track of the MDS's directory fragments
+ * for a given inode (usually there is just a single fragment).  We
+ * need to know when a child frag is delegated to a new MDS, or when
+ * it is flagged as replicated, so we can direct our requests
+ * accordingly.
+ */
+
+/*
+ * find/create a frag in the tree
+ */
+static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,
+                                                   u32 f)
+{
+       struct rb_node **p;
+       struct rb_node *parent = NULL;
+       struct ceph_inode_frag *frag;
+       int c;
+
+       p = &ci->i_fragtree.rb_node;
+       while (*p) {
+               parent = *p;
+               frag = rb_entry(parent, struct ceph_inode_frag, node);
+               c = ceph_frag_compare(f, frag->frag);
+               if (c < 0)
+                       p = &(*p)->rb_left;
+               else if (c > 0)
+                       p = &(*p)->rb_right;
+               else
+                       return frag;
+       }
+
+       frag = kmalloc(sizeof(*frag), GFP_NOFS);
+       if (!frag) {
+               pr_err("__get_or_create_frag ENOMEM on %p %llx.%llx "
+                      "frag %x\n", &ci->vfs_inode,
+                      ceph_vinop(&ci->vfs_inode), f);
+               return ERR_PTR(-ENOMEM);
+       }
+       frag->frag = f;
+       frag->split_by = 0;
+       frag->mds = -1;
+       frag->ndist = 0;
+
+       rb_link_node(&frag->node, parent, p);
+       rb_insert_color(&frag->node, &ci->i_fragtree);
+
+       dout("get_or_create_frag added %llx.%llx frag %x\n",
+            ceph_vinop(&ci->vfs_inode), f);
+       return frag;
+}
+
+/*
+ * find a specific frag @f
+ */
+struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci, u32 f)
+{
+       struct rb_node *n = ci->i_fragtree.rb_node;
+
+       while (n) {
+               struct ceph_inode_frag *frag =
+                       rb_entry(n, struct ceph_inode_frag, node);
+               int c = ceph_frag_compare(f, frag->frag);
+               if (c < 0)
+                       n = n->rb_left;
+               else if (c > 0)
+                       n = n->rb_right;
+               else
+                       return frag;
+       }
+       return NULL;
+}
+
+/*
+ * Choose frag containing the given value @v.  If @pfrag is
+ * specified, copy the frag delegation info to the caller if
+ * it is present.
+ */
+u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v,
+                    struct ceph_inode_frag *pfrag,
+                    int *found)
+{
+       u32 t = ceph_frag_make(0, 0);
+       struct ceph_inode_frag *frag;
+       unsigned nway, i;
+       u32 n;
+
+       if (found)
+               *found = 0;
+
+       mutex_lock(&ci->i_fragtree_mutex);
+       while (1) {
+               WARN_ON(!ceph_frag_contains_value(t, v));
+               frag = __ceph_find_frag(ci, t);
+               if (!frag)
+                       break; /* t is a leaf */
+               if (frag->split_by == 0) {
+                       if (pfrag)
+                               memcpy(pfrag, frag, sizeof(*pfrag));
+                       if (found)
+                               *found = 1;
+                       break;
+               }
+
+               /* choose child */
+               nway = 1 << frag->split_by;
+               dout("choose_frag(%x) %x splits by %d (%d ways)\n", v, t,
+                    frag->split_by, nway);
+               for (i = 0; i < nway; i++) {
+                       n = ceph_frag_make_child(t, frag->split_by, i);
+                       if (ceph_frag_contains_value(n, v)) {
+                               t = n;
+                               break;
+                       }
+               }
+               BUG_ON(i == nway);
+       }
+       dout("choose_frag(%x) = %x\n", v, t);
+
+       mutex_unlock(&ci->i_fragtree_mutex);
+       return t;
+}
+
+/*
+ * Process dirfrag (delegation) info from the mds.  Include leaf
+ * fragment in tree ONLY if ndist > 0.  Otherwise, only
+ * branches/splits are included in i_fragtree)
+ */
+static int ceph_fill_dirfrag(struct inode *inode,
+                            struct ceph_mds_reply_dirfrag *dirinfo)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_inode_frag *frag;
+       u32 id = le32_to_cpu(dirinfo->frag);
+       int mds = le32_to_cpu(dirinfo->auth);
+       int ndist = le32_to_cpu(dirinfo->ndist);
+       int i;
+       int err = 0;
+
+       mutex_lock(&ci->i_fragtree_mutex);
+       if (ndist == 0) {
+               /* no delegation info needed. */
+               frag = __ceph_find_frag(ci, id);
+               if (!frag)
+                       goto out;
+               if (frag->split_by == 0) {
+                       /* tree leaf, remove */
+                       dout("fill_dirfrag removed %llx.%llx frag %x"
+                            " (no ref)\n", ceph_vinop(inode), id);
+                       rb_erase(&frag->node, &ci->i_fragtree);
+                       kfree(frag);
+               } else {
+                       /* tree branch, keep and clear */
+                       dout("fill_dirfrag cleared %llx.%llx frag %x"
+                            " referral\n", ceph_vinop(inode), id);
+                       frag->mds = -1;
+                       frag->ndist = 0;
+               }
+               goto out;
+       }
+
+
+       /* find/add this frag to store mds delegation info */
+       frag = __get_or_create_frag(ci, id);
+       if (IS_ERR(frag)) {
+               /* this is not the end of the world; we can continue
+                  with bad/inaccurate delegation info */
+               pr_err("fill_dirfrag ENOMEM on mds ref %llx.%llx fg %x\n",
+                      ceph_vinop(inode), le32_to_cpu(dirinfo->frag));
+               err = -ENOMEM;
+               goto out;
+       }
+
+       frag->mds = mds;
+       frag->ndist = min_t(u32, ndist, CEPH_MAX_DIRFRAG_REP);
+       for (i = 0; i < frag->ndist; i++)
+               frag->dist[i] = le32_to_cpu(dirinfo->dist[i]);
+       dout("fill_dirfrag %llx.%llx frag %x ndist=%d\n",
+            ceph_vinop(inode), frag->frag, frag->ndist);
+
+out:
+       mutex_unlock(&ci->i_fragtree_mutex);
+       return err;
+}
+
+
+/*
+ * initialize a newly allocated inode.
+ */
+struct inode *ceph_alloc_inode(struct super_block *sb)
+{
+       struct ceph_inode_info *ci;
+       int i;
+
+       ci = kmem_cache_alloc(ceph_inode_cachep, GFP_NOFS);
+       if (!ci)
+               return NULL;
+
+       dout("alloc_inode %p\n", &ci->vfs_inode);
+
+       ci->i_version = 0;
+       ci->i_time_warp_seq = 0;
+       ci->i_ceph_flags = 0;
+       ci->i_release_count = 0;
+       ci->i_symlink = NULL;
+
+       ci->i_fragtree = RB_ROOT;
+       mutex_init(&ci->i_fragtree_mutex);
+
+       ci->i_xattrs.blob = NULL;
+       ci->i_xattrs.prealloc_blob = NULL;
+       ci->i_xattrs.dirty = false;
+       ci->i_xattrs.index = RB_ROOT;
+       ci->i_xattrs.count = 0;
+       ci->i_xattrs.names_size = 0;
+       ci->i_xattrs.vals_size = 0;
+       ci->i_xattrs.version = 0;
+       ci->i_xattrs.index_version = 0;
+
+       ci->i_caps = RB_ROOT;
+       ci->i_auth_cap = NULL;
+       ci->i_dirty_caps = 0;
+       ci->i_flushing_caps = 0;
+       INIT_LIST_HEAD(&ci->i_dirty_item);
+       INIT_LIST_HEAD(&ci->i_flushing_item);
+       ci->i_cap_flush_seq = 0;
+       ci->i_cap_flush_last_tid = 0;
+       memset(&ci->i_cap_flush_tid, 0, sizeof(ci->i_cap_flush_tid));
+       init_waitqueue_head(&ci->i_cap_wq);
+       ci->i_hold_caps_min = 0;
+       ci->i_hold_caps_max = 0;
+       INIT_LIST_HEAD(&ci->i_cap_delay_list);
+       ci->i_cap_exporting_mds = 0;
+       ci->i_cap_exporting_mseq = 0;
+       ci->i_cap_exporting_issued = 0;
+       INIT_LIST_HEAD(&ci->i_cap_snaps);
+       ci->i_head_snapc = NULL;
+       ci->i_snap_caps = 0;
+
+       for (i = 0; i < CEPH_FILE_MODE_NUM; i++)
+               ci->i_nr_by_mode[i] = 0;
+
+       ci->i_truncate_seq = 0;
+       ci->i_truncate_size = 0;
+       ci->i_truncate_pending = 0;
+
+       ci->i_max_size = 0;
+       ci->i_reported_size = 0;
+       ci->i_wanted_max_size = 0;
+       ci->i_requested_max_size = 0;
+
+       ci->i_pin_ref = 0;
+       ci->i_rd_ref = 0;
+       ci->i_rdcache_ref = 0;
+       ci->i_wr_ref = 0;
+       ci->i_wrbuffer_ref = 0;
+       ci->i_wrbuffer_ref_head = 0;
+       ci->i_shared_gen = 0;
+       ci->i_rdcache_gen = 0;
+       ci->i_rdcache_revoking = 0;
+
+       INIT_LIST_HEAD(&ci->i_unsafe_writes);
+       INIT_LIST_HEAD(&ci->i_unsafe_dirops);
+       spin_lock_init(&ci->i_unsafe_lock);
+
+       ci->i_snap_realm = NULL;
+       INIT_LIST_HEAD(&ci->i_snap_realm_item);
+       INIT_LIST_HEAD(&ci->i_snap_flush_item);
+
+       INIT_WORK(&ci->i_wb_work, ceph_writeback_work);
+       INIT_WORK(&ci->i_pg_inv_work, ceph_invalidate_work);
+
+       INIT_WORK(&ci->i_vmtruncate_work, ceph_vmtruncate_work);
+
+       return &ci->vfs_inode;
+}
+
+void ceph_destroy_inode(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_inode_frag *frag;
+       struct rb_node *n;
+
+       dout("destroy_inode %p ino %llx.%llx\n", inode, ceph_vinop(inode));
+
+       ceph_queue_caps_release(inode);
+
+       /*
+        * we may still have a snap_realm reference if there are stray
+        * caps in i_cap_exporting_issued or i_snap_caps.
+        */
+       if (ci->i_snap_realm) {
+               struct ceph_mds_client *mdsc =
+                       &ceph_client(ci->vfs_inode.i_sb)->mdsc;
+               struct ceph_snap_realm *realm = ci->i_snap_realm;
+
+               dout(" dropping residual ref to snap realm %p\n", realm);
+               spin_lock(&realm->inodes_with_caps_lock);
+               list_del_init(&ci->i_snap_realm_item);
+               spin_unlock(&realm->inodes_with_caps_lock);
+               ceph_put_snap_realm(mdsc, realm);
+       }
+
+       kfree(ci->i_symlink);
+       while ((n = rb_first(&ci->i_fragtree)) != NULL) {
+               frag = rb_entry(n, struct ceph_inode_frag, node);
+               rb_erase(n, &ci->i_fragtree);
+               kfree(frag);
+       }
+
+       __ceph_destroy_xattrs(ci);
+       if (ci->i_xattrs.blob)
+               ceph_buffer_put(ci->i_xattrs.blob);
+       if (ci->i_xattrs.prealloc_blob)
+               ceph_buffer_put(ci->i_xattrs.prealloc_blob);
+
+       kmem_cache_free(ceph_inode_cachep, ci);
+}
+
+
+/*
+ * Helpers to fill in size, ctime, mtime, and atime.  We have to be
+ * careful because either the client or MDS may have more up to date
+ * info, depending on which capabilities are held, and whether
+ * time_warp_seq or truncate_seq have increased.  (Ordinarily, mtime
+ * and size are monotonically increasing, except when utimes() or
+ * truncate() increments the corresponding _seq values.)
+ */
+int ceph_fill_file_size(struct inode *inode, int issued,
+                       u32 truncate_seq, u64 truncate_size, u64 size)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int queue_trunc = 0;
+
+       if (ceph_seq_cmp(truncate_seq, ci->i_truncate_seq) > 0 ||
+           (truncate_seq == ci->i_truncate_seq && size > inode->i_size)) {
+               dout("size %lld -> %llu\n", inode->i_size, size);
+               inode->i_size = size;
+               inode->i_blocks = (size + (1<<9) - 1) >> 9;
+               ci->i_reported_size = size;
+               if (truncate_seq != ci->i_truncate_seq) {
+                       dout("truncate_seq %u -> %u\n",
+                            ci->i_truncate_seq, truncate_seq);
+                       ci->i_truncate_seq = truncate_seq;
+                       /*
+                        * If we hold relevant caps, or in the case where we're
+                        * not the only client referencing this file and we
+                        * don't hold those caps, then we need to check whether
+                        * the file is either opened or mmaped
+                        */
+                       if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_RD|
+                                     CEPH_CAP_FILE_WR|CEPH_CAP_FILE_BUFFER|
+                                     CEPH_CAP_FILE_EXCL)) ||
+                           mapping_mapped(inode->i_mapping) ||
+                           __ceph_caps_file_wanted(ci)) {
+                               ci->i_truncate_pending++;
+                               queue_trunc = 1;
+                       }
+               }
+       }
+       if (ceph_seq_cmp(truncate_seq, ci->i_truncate_seq) >= 0 &&
+           ci->i_truncate_size != truncate_size) {
+               dout("truncate_size %lld -> %llu\n", ci->i_truncate_size,
+                    truncate_size);
+               ci->i_truncate_size = truncate_size;
+       }
+       return queue_trunc;
+}
+
+void ceph_fill_file_time(struct inode *inode, int issued,
+                        u64 time_warp_seq, struct timespec *ctime,
+                        struct timespec *mtime, struct timespec *atime)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int warn = 0;
+
+       if (issued & (CEPH_CAP_FILE_EXCL|
+                     CEPH_CAP_FILE_WR|
+                     CEPH_CAP_FILE_BUFFER)) {
+               if (timespec_compare(ctime, &inode->i_ctime) > 0) {
+                       dout("ctime %ld.%09ld -> %ld.%09ld inc w/ cap\n",
+                            inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                            ctime->tv_sec, ctime->tv_nsec);
+                       inode->i_ctime = *ctime;
+               }
+               if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) {
+                       /* the MDS did a utimes() */
+                       dout("mtime %ld.%09ld -> %ld.%09ld "
+                            "tw %d -> %d\n",
+                            inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                            mtime->tv_sec, mtime->tv_nsec,
+                            ci->i_time_warp_seq, (int)time_warp_seq);
+
+                       inode->i_mtime = *mtime;
+                       inode->i_atime = *atime;
+                       ci->i_time_warp_seq = time_warp_seq;
+               } else if (time_warp_seq == ci->i_time_warp_seq) {
+                       /* nobody did utimes(); take the max */
+                       if (timespec_compare(mtime, &inode->i_mtime) > 0) {
+                               dout("mtime %ld.%09ld -> %ld.%09ld inc\n",
+                                    inode->i_mtime.tv_sec,
+                                    inode->i_mtime.tv_nsec,
+                                    mtime->tv_sec, mtime->tv_nsec);
+                               inode->i_mtime = *mtime;
+                       }
+                       if (timespec_compare(atime, &inode->i_atime) > 0) {
+                               dout("atime %ld.%09ld -> %ld.%09ld inc\n",
+                                    inode->i_atime.tv_sec,
+                                    inode->i_atime.tv_nsec,
+                                    atime->tv_sec, atime->tv_nsec);
+                               inode->i_atime = *atime;
+                       }
+               } else if (issued & CEPH_CAP_FILE_EXCL) {
+                       /* we did a utimes(); ignore mds values */
+               } else {
+                       warn = 1;
+               }
+       } else {
+               /* we have no write caps; whatever the MDS says is true */
+               if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) {
+                       inode->i_ctime = *ctime;
+                       inode->i_mtime = *mtime;
+                       inode->i_atime = *atime;
+                       ci->i_time_warp_seq = time_warp_seq;
+               } else {
+                       warn = 1;
+               }
+       }
+       if (warn) /* time_warp_seq shouldn't go backwards */
+               dout("%p mds time_warp_seq %llu < %u\n",
+                    inode, time_warp_seq, ci->i_time_warp_seq);
+}
+
+/*
+ * Populate an inode based on info from mds.  May be called on new or
+ * existing inodes.
+ */
+static int fill_inode(struct inode *inode,
+                     struct ceph_mds_reply_info_in *iinfo,
+                     struct ceph_mds_reply_dirfrag *dirinfo,
+                     struct ceph_mds_session *session,
+                     unsigned long ttl_from, int cap_fmode,
+                     struct ceph_cap_reservation *caps_reservation)
+{
+       struct ceph_mds_reply_inode *info = iinfo->in;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int i;
+       int issued, implemented;
+       struct timespec mtime, atime, ctime;
+       u32 nsplits;
+       struct ceph_buffer *xattr_blob = NULL;
+       int err = 0;
+       int queue_trunc = 0;
+
+       dout("fill_inode %p ino %llx.%llx v %llu had %llu\n",
+            inode, ceph_vinop(inode), le64_to_cpu(info->version),
+            ci->i_version);
+
+       /*
+        * prealloc xattr data, if it looks like we'll need it.  only
+        * if len > 4 (meaning there are actually xattrs; the first 4
+        * bytes are the xattr count).
+        */
+       if (iinfo->xattr_len > 4) {
+               xattr_blob = ceph_buffer_new(iinfo->xattr_len, GFP_NOFS);
+               if (!xattr_blob)
+                       pr_err("fill_inode ENOMEM xattr blob %d bytes\n",
+                              iinfo->xattr_len);
+       }
+
+       spin_lock(&inode->i_lock);
+
+       /*
+        * provided version will be odd if inode value is projected,
+        * even if stable.  skip the update if we have a newer info
+        * (e.g., due to inode info racing form multiple MDSs), or if
+        * we are getting projected (unstable) inode info.
+        */
+       if (le64_to_cpu(info->version) > 0 &&
+           (ci->i_version & ~1) > le64_to_cpu(info->version))
+               goto no_change;
+
+       issued = __ceph_caps_issued(ci, &implemented);
+       issued |= implemented | __ceph_caps_dirty(ci);
+
+       /* update inode */
+       ci->i_version = le64_to_cpu(info->version);
+       inode->i_version++;
+       inode->i_rdev = le32_to_cpu(info->rdev);
+
+       if ((issued & CEPH_CAP_AUTH_EXCL) == 0) {
+               inode->i_mode = le32_to_cpu(info->mode);
+               inode->i_uid = le32_to_cpu(info->uid);
+               inode->i_gid = le32_to_cpu(info->gid);
+               dout("%p mode 0%o uid.gid %d.%d\n", inode, inode->i_mode,
+                    inode->i_uid, inode->i_gid);
+       }
+
+       if ((issued & CEPH_CAP_LINK_EXCL) == 0)
+               inode->i_nlink = le32_to_cpu(info->nlink);
+
+       /* be careful with mtime, atime, size */
+       ceph_decode_timespec(&atime, &info->atime);
+       ceph_decode_timespec(&mtime, &info->mtime);
+       ceph_decode_timespec(&ctime, &info->ctime);
+       queue_trunc = ceph_fill_file_size(inode, issued,
+                                         le32_to_cpu(info->truncate_seq),
+                                         le64_to_cpu(info->truncate_size),
+                                         le64_to_cpu(info->size));
+       ceph_fill_file_time(inode, issued,
+                           le32_to_cpu(info->time_warp_seq),
+                           &ctime, &mtime, &atime);
+
+       ci->i_max_size = le64_to_cpu(info->max_size);
+       ci->i_layout = info->layout;
+       inode->i_blkbits = fls(le32_to_cpu(info->layout.fl_stripe_unit)) - 1;
+
+       /* xattrs */
+       /* note that if i_xattrs.len <= 4, i_xattrs.data will still be NULL. */
+       if ((issued & CEPH_CAP_XATTR_EXCL) == 0 &&
+           le64_to_cpu(info->xattr_version) > ci->i_xattrs.version) {
+               if (ci->i_xattrs.blob)
+                       ceph_buffer_put(ci->i_xattrs.blob);
+               ci->i_xattrs.blob = xattr_blob;
+               if (xattr_blob)
+                       memcpy(ci->i_xattrs.blob->vec.iov_base,
+                              iinfo->xattr_data, iinfo->xattr_len);
+               ci->i_xattrs.version = le64_to_cpu(info->xattr_version);
+       }
+
+       inode->i_mapping->a_ops = &ceph_aops;
+       inode->i_mapping->backing_dev_info =
+               &ceph_client(inode->i_sb)->backing_dev_info;
+
+       switch (inode->i_mode & S_IFMT) {
+       case S_IFIFO:
+       case S_IFBLK:
+       case S_IFCHR:
+       case S_IFSOCK:
+               init_special_inode(inode, inode->i_mode, inode->i_rdev);
+               inode->i_op = &ceph_file_iops;
+               break;
+       case S_IFREG:
+               inode->i_op = &ceph_file_iops;
+               inode->i_fop = &ceph_file_fops;
+               break;
+       case S_IFLNK:
+               inode->i_op = &ceph_symlink_iops;
+               if (!ci->i_symlink) {
+                       int symlen = iinfo->symlink_len;
+                       char *sym;
+
+                       BUG_ON(symlen != inode->i_size);
+                       spin_unlock(&inode->i_lock);
+
+                       err = -ENOMEM;
+                       sym = kmalloc(symlen+1, GFP_NOFS);
+                       if (!sym)
+                               goto out;
+                       memcpy(sym, iinfo->symlink, symlen);
+                       sym[symlen] = 0;
+
+                       spin_lock(&inode->i_lock);
+                       if (!ci->i_symlink)
+                               ci->i_symlink = sym;
+                       else
+                               kfree(sym); /* lost a race */
+               }
+               break;
+       case S_IFDIR:
+               inode->i_op = &ceph_dir_iops;
+               inode->i_fop = &ceph_dir_fops;
+
+               ci->i_files = le64_to_cpu(info->files);
+               ci->i_subdirs = le64_to_cpu(info->subdirs);
+               ci->i_rbytes = le64_to_cpu(info->rbytes);
+               ci->i_rfiles = le64_to_cpu(info->rfiles);
+               ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
+               ceph_decode_timespec(&ci->i_rctime, &info->rctime);
+
+               /* set dir completion flag? */
+               if (ci->i_files == 0 && ci->i_subdirs == 0 &&
+                   ceph_snap(inode) == CEPH_NOSNAP &&
+                   (le32_to_cpu(info->cap.caps) & CEPH_CAP_FILE_SHARED)) {
+                       dout(" marking %p complete (empty)\n", inode);
+                       ci->i_ceph_flags |= CEPH_I_COMPLETE;
+                       ci->i_max_offset = 2;
+               }
+
+               /* it may be better to set st_size in getattr instead? */
+               if (ceph_test_opt(ceph_client(inode->i_sb), RBYTES))
+                       inode->i_size = ci->i_rbytes;
+               break;
+       default:
+               pr_err("fill_inode %llx.%llx BAD mode 0%o\n",
+                      ceph_vinop(inode), inode->i_mode);
+       }
+
+no_change:
+       spin_unlock(&inode->i_lock);
+
+       /* queue truncate if we saw i_size decrease */
+       if (queue_trunc)
+               ceph_queue_vmtruncate(inode);
+
+       /* populate frag tree */
+       /* FIXME: move me up, if/when version reflects fragtree changes */
+       nsplits = le32_to_cpu(info->fragtree.nsplits);
+       mutex_lock(&ci->i_fragtree_mutex);
+       for (i = 0; i < nsplits; i++) {
+               u32 id = le32_to_cpu(info->fragtree.splits[i].frag);
+               struct ceph_inode_frag *frag = __get_or_create_frag(ci, id);
+
+               if (IS_ERR(frag))
+                       continue;
+               frag->split_by = le32_to_cpu(info->fragtree.splits[i].by);
+               dout(" frag %x split by %d\n", frag->frag, frag->split_by);
+       }
+       mutex_unlock(&ci->i_fragtree_mutex);
+
+       /* were we issued a capability? */
+       if (info->cap.caps) {
+               if (ceph_snap(inode) == CEPH_NOSNAP) {
+                       ceph_add_cap(inode, session,
+                                    le64_to_cpu(info->cap.cap_id),
+                                    cap_fmode,
+                                    le32_to_cpu(info->cap.caps),
+                                    le32_to_cpu(info->cap.wanted),
+                                    le32_to_cpu(info->cap.seq),
+                                    le32_to_cpu(info->cap.mseq),
+                                    le64_to_cpu(info->cap.realm),
+                                    info->cap.flags,
+                                    caps_reservation);
+               } else {
+                       spin_lock(&inode->i_lock);
+                       dout(" %p got snap_caps %s\n", inode,
+                            ceph_cap_string(le32_to_cpu(info->cap.caps)));
+                       ci->i_snap_caps |= le32_to_cpu(info->cap.caps);
+                       if (cap_fmode >= 0)
+                               __ceph_get_fmode(ci, cap_fmode);
+                       spin_unlock(&inode->i_lock);
+               }
+       }
+
+       /* update delegation info? */
+       if (dirinfo)
+               ceph_fill_dirfrag(inode, dirinfo);
+
+       err = 0;
+
+out:
+       if (xattr_blob)
+               ceph_buffer_put(xattr_blob);
+       return err;
+}
+
+/*
+ * caller should hold session s_mutex.
+ */
+static void update_dentry_lease(struct dentry *dentry,
+                               struct ceph_mds_reply_lease *lease,
+                               struct ceph_mds_session *session,
+                               unsigned long from_time)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dentry);
+       long unsigned duration = le32_to_cpu(lease->duration_ms);
+       long unsigned ttl = from_time + (duration * HZ) / 1000;
+       long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000;
+       struct inode *dir;
+
+       /* only track leases on regular dentries */
+       if (dentry->d_op != &ceph_dentry_ops)
+               return;
+
+       spin_lock(&dentry->d_lock);
+       dout("update_dentry_lease %p mask %d duration %lu ms ttl %lu\n",
+            dentry, le16_to_cpu(lease->mask), duration, ttl);
+
+       /* make lease_rdcache_gen match directory */
+       dir = dentry->d_parent->d_inode;
+       di->lease_shared_gen = ceph_inode(dir)->i_shared_gen;
+
+       if (lease->mask == 0)
+               goto out_unlock;
+
+       if (di->lease_gen == session->s_cap_gen &&
+           time_before(ttl, dentry->d_time))
+               goto out_unlock;  /* we already have a newer lease. */
+
+       if (di->lease_session && di->lease_session != session)
+               goto out_unlock;
+
+       ceph_dentry_lru_touch(dentry);
+
+       if (!di->lease_session)
+               di->lease_session = ceph_get_mds_session(session);
+       di->lease_gen = session->s_cap_gen;
+       di->lease_seq = le32_to_cpu(lease->seq);
+       di->lease_renew_after = half_ttl;
+       di->lease_renew_from = 0;
+       dentry->d_time = ttl;
+out_unlock:
+       spin_unlock(&dentry->d_lock);
+       return;
+}
+
+/*
+ * splice a dentry to an inode.
+ * caller must hold directory i_mutex for this to be safe.
+ *
+ * we will only rehash the resulting dentry if @prehash is
+ * true; @prehash will be set to false (for the benefit of
+ * the caller) if we fail.
+ */
+static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
+                                   bool *prehash)
+{
+       struct dentry *realdn;
+
+       /* dn must be unhashed */
+       if (!d_unhashed(dn))
+               d_drop(dn);
+       realdn = d_materialise_unique(dn, in);
+       if (IS_ERR(realdn)) {
+               pr_err("splice_dentry error %p inode %p ino %llx.%llx\n",
+                      dn, in, ceph_vinop(in));
+               if (prehash)
+                       *prehash = false; /* don't rehash on error */
+               dn = realdn; /* note realdn contains the error */
+               goto out;
+       } else if (realdn) {
+               dout("dn %p (%d) spliced with %p (%d) "
+                    "inode %p ino %llx.%llx\n",
+                    dn, atomic_read(&dn->d_count),
+                    realdn, atomic_read(&realdn->d_count),
+                    realdn->d_inode, ceph_vinop(realdn->d_inode));
+               dput(dn);
+               dn = realdn;
+       } else {
+               BUG_ON(!ceph_dentry(dn));
+
+               dout("dn %p attached to %p ino %llx.%llx\n",
+                    dn, dn->d_inode, ceph_vinop(dn->d_inode));
+       }
+       if ((!prehash || *prehash) && d_unhashed(dn))
+               d_rehash(dn);
+out:
+       return dn;
+}
+
+/*
+ * Set dentry's directory position based on the current dir's max, and
+ * order it in d_subdirs, so that dcache_readdir behaves.
+ */
+static void ceph_set_dentry_offset(struct dentry *dn)
+{
+       struct dentry *dir = dn->d_parent;
+       struct inode *inode = dn->d_parent->d_inode;
+       struct ceph_dentry_info *di;
+
+       BUG_ON(!inode);
+
+       di = ceph_dentry(dn);
+
+       spin_lock(&inode->i_lock);
+       di->offset = ceph_inode(inode)->i_max_offset++;
+       spin_unlock(&inode->i_lock);
+
+       spin_lock(&dcache_lock);
+       spin_lock(&dn->d_lock);
+       list_move_tail(&dir->d_subdirs, &dn->d_u.d_child);
+       dout("set_dentry_offset %p %lld (%p %p)\n", dn, di->offset,
+            dn->d_u.d_child.prev, dn->d_u.d_child.next);
+       spin_unlock(&dn->d_lock);
+       spin_unlock(&dcache_lock);
+}
+
+/*
+ * Incorporate results into the local cache.  This is either just
+ * one inode, or a directory, dentry, and possibly linked-to inode (e.g.,
+ * after a lookup).
+ *
+ * A reply may contain
+ *         a directory inode along with a dentry.
+ *  and/or a target inode
+ *
+ * Called with snap_rwsem (read).
+ */
+int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
+                   struct ceph_mds_session *session)
+{
+       struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
+       struct inode *in = NULL;
+       struct ceph_mds_reply_inode *ininfo;
+       struct ceph_vino vino;
+       int i = 0;
+       int err = 0;
+
+       dout("fill_trace %p is_dentry %d is_target %d\n", req,
+            rinfo->head->is_dentry, rinfo->head->is_target);
+
+#if 0
+       /*
+        * Debugging hook:
+        *
+        * If we resend completed ops to a recovering mds, we get no
+        * trace.  Since that is very rare, pretend this is the case
+        * to ensure the 'no trace' handlers in the callers behave.
+        *
+        * Fill in inodes unconditionally to avoid breaking cap
+        * invariants.
+        */
+       if (rinfo->head->op & CEPH_MDS_OP_WRITE) {
+               pr_info("fill_trace faking empty trace on %lld %s\n",
+                       req->r_tid, ceph_mds_op_name(rinfo->head->op));
+               if (rinfo->head->is_dentry) {
+                       rinfo->head->is_dentry = 0;
+                       err = fill_inode(req->r_locked_dir,
+                                        &rinfo->diri, rinfo->dirfrag,
+                                        session, req->r_request_started, -1);
+               }
+               if (rinfo->head->is_target) {
+                       rinfo->head->is_target = 0;
+                       ininfo = rinfo->targeti.in;
+                       vino.ino = le64_to_cpu(ininfo->ino);
+                       vino.snap = le64_to_cpu(ininfo->snapid);
+                       in = ceph_get_inode(sb, vino);
+                       err = fill_inode(in, &rinfo->targeti, NULL,
+                                        session, req->r_request_started,
+                                        req->r_fmode);
+                       iput(in);
+               }
+       }
+#endif
+
+       if (!rinfo->head->is_target && !rinfo->head->is_dentry) {
+               dout("fill_trace reply is empty!\n");
+               if (rinfo->head->result == 0 && req->r_locked_dir) {
+                       struct ceph_inode_info *ci =
+                               ceph_inode(req->r_locked_dir);
+                       dout(" clearing %p complete (empty trace)\n",
+                            req->r_locked_dir);
+                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+                       ci->i_release_count++;
+               }
+               return 0;
+       }
+
+       if (rinfo->head->is_dentry) {
+               struct inode *dir = req->r_locked_dir;
+
+               err = fill_inode(dir, &rinfo->diri, rinfo->dirfrag,
+                                session, req->r_request_started, -1,
+                                &req->r_caps_reservation);
+               if (err < 0)
+                       return err;
+       }
+
+       if (rinfo->head->is_dentry && !req->r_aborted) {
+               /*
+                * lookup link rename   : null -> possibly existing inode
+                * mknod symlink mkdir  : null -> new inode
+                * unlink               : linked -> null
+                */
+               struct inode *dir = req->r_locked_dir;
+               struct dentry *dn = req->r_dentry;
+               bool have_dir_cap, have_lease;
+
+               BUG_ON(!dn);
+               BUG_ON(!dir);
+               BUG_ON(dn->d_parent->d_inode != dir);
+               BUG_ON(ceph_ino(dir) !=
+                      le64_to_cpu(rinfo->diri.in->ino));
+               BUG_ON(ceph_snap(dir) !=
+                      le64_to_cpu(rinfo->diri.in->snapid));
+
+               /* do we have a lease on the whole dir? */
+               have_dir_cap =
+                       (le32_to_cpu(rinfo->diri.in->cap.caps) &
+                        CEPH_CAP_FILE_SHARED);
+
+               /* do we have a dn lease? */
+               have_lease = have_dir_cap ||
+                       (le16_to_cpu(rinfo->dlease->mask) &
+                        CEPH_LOCK_DN);
+
+               if (!have_lease)
+                       dout("fill_trace  no dentry lease or dir cap\n");
+
+               /* rename? */
+               if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) {
+                       dout(" src %p '%.*s' dst %p '%.*s'\n",
+                            req->r_old_dentry,
+                            req->r_old_dentry->d_name.len,
+                            req->r_old_dentry->d_name.name,
+                            dn, dn->d_name.len, dn->d_name.name);
+                       dout("fill_trace doing d_move %p -> %p\n",
+                            req->r_old_dentry, dn);
+                       d_move(req->r_old_dentry, dn);
+                       dout(" src %p '%.*s' dst %p '%.*s'\n",
+                            req->r_old_dentry,
+                            req->r_old_dentry->d_name.len,
+                            req->r_old_dentry->d_name.name,
+                            dn, dn->d_name.len, dn->d_name.name);
+                       /* ensure target dentry is invalidated, despite
+                          rehashing bug in vfs_rename_dir */
+                       dn->d_time = jiffies;
+                       ceph_dentry(dn)->lease_shared_gen = 0;
+                       /* take overwritten dentry's readdir offset */
+                       ceph_dentry(req->r_old_dentry)->offset =
+                               ceph_dentry(dn)->offset;
+                       dn = req->r_old_dentry;  /* use old_dentry */
+                       in = dn->d_inode;
+               }
+
+               /* null dentry? */
+               if (!rinfo->head->is_target) {
+                       dout("fill_trace null dentry\n");
+                       if (dn->d_inode) {
+                               dout("d_delete %p\n", dn);
+                               d_delete(dn);
+                       } else {
+                               dout("d_instantiate %p NULL\n", dn);
+                               d_instantiate(dn, NULL);
+                               if (have_lease && d_unhashed(dn))
+                                       d_rehash(dn);
+                               update_dentry_lease(dn, rinfo->dlease,
+                                                   session,
+                                                   req->r_request_started);
+                       }
+                       goto done;
+               }
+
+               /* attach proper inode */
+               ininfo = rinfo->targeti.in;
+               vino.ino = le64_to_cpu(ininfo->ino);
+               vino.snap = le64_to_cpu(ininfo->snapid);
+               if (!dn->d_inode) {
+                       in = ceph_get_inode(sb, vino);
+                       if (IS_ERR(in)) {
+                               pr_err("fill_trace bad get_inode "
+                                      "%llx.%llx\n", vino.ino, vino.snap);
+                               err = PTR_ERR(in);
+                               d_delete(dn);
+                               goto done;
+                       }
+                       dn = splice_dentry(dn, in, &have_lease);
+                       if (IS_ERR(dn)) {
+                               err = PTR_ERR(dn);
+                               goto done;
+                       }
+                       req->r_dentry = dn;  /* may have spliced */
+                       ceph_set_dentry_offset(dn);
+                       igrab(in);
+               } else if (ceph_ino(in) == vino.ino &&
+                          ceph_snap(in) == vino.snap) {
+                       igrab(in);
+               } else {
+                       dout(" %p links to %p %llx.%llx, not %llx.%llx\n",
+                            dn, in, ceph_ino(in), ceph_snap(in),
+                            vino.ino, vino.snap);
+                       have_lease = false;
+                       in = NULL;
+               }
+
+               if (have_lease)
+                       update_dentry_lease(dn, rinfo->dlease, session,
+                                           req->r_request_started);
+               dout(" final dn %p\n", dn);
+               i++;
+       } else if (req->r_op == CEPH_MDS_OP_LOOKUPSNAP ||
+                  req->r_op == CEPH_MDS_OP_MKSNAP) {
+               struct dentry *dn = req->r_dentry;
+
+               /* fill out a snapdir LOOKUPSNAP dentry */
+               BUG_ON(!dn);
+               BUG_ON(!req->r_locked_dir);
+               BUG_ON(ceph_snap(req->r_locked_dir) != CEPH_SNAPDIR);
+               ininfo = rinfo->targeti.in;
+               vino.ino = le64_to_cpu(ininfo->ino);
+               vino.snap = le64_to_cpu(ininfo->snapid);
+               in = ceph_get_inode(sb, vino);
+               if (IS_ERR(in)) {
+                       pr_err("fill_inode get_inode badness %llx.%llx\n",
+                              vino.ino, vino.snap);
+                       err = PTR_ERR(in);
+                       d_delete(dn);
+                       goto done;
+               }
+               dout(" linking snapped dir %p to dn %p\n", in, dn);
+               dn = splice_dentry(dn, in, NULL);
+               if (IS_ERR(dn)) {
+                       err = PTR_ERR(dn);
+                       goto done;
+               }
+               ceph_set_dentry_offset(dn);
+               req->r_dentry = dn;  /* may have spliced */
+               igrab(in);
+               rinfo->head->is_dentry = 1;  /* fool notrace handlers */
+       }
+
+       if (rinfo->head->is_target) {
+               vino.ino = le64_to_cpu(rinfo->targeti.in->ino);
+               vino.snap = le64_to_cpu(rinfo->targeti.in->snapid);
+
+               if (in == NULL || ceph_ino(in) != vino.ino ||
+                   ceph_snap(in) != vino.snap) {
+                       in = ceph_get_inode(sb, vino);
+                       if (IS_ERR(in)) {
+                               err = PTR_ERR(in);
+                               goto done;
+                       }
+               }
+               req->r_target_inode = in;
+
+               err = fill_inode(in,
+                                &rinfo->targeti, NULL,
+                                session, req->r_request_started,
+                                (le32_to_cpu(rinfo->head->result) == 0) ?
+                                req->r_fmode : -1,
+                                &req->r_caps_reservation);
+               if (err < 0) {
+                       pr_err("fill_inode badness %p %llx.%llx\n",
+                              in, ceph_vinop(in));
+                       goto done;
+               }
+       }
+
+done:
+       dout("fill_trace done err=%d\n", err);
+       return err;
+}
+
+/*
+ * Prepopulate our cache with readdir results, leases, etc.
+ */
+int ceph_readdir_prepopulate(struct ceph_mds_request *req,
+                            struct ceph_mds_session *session)
+{
+       struct dentry *parent = req->r_dentry;
+       struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
+       struct qstr dname;
+       struct dentry *dn;
+       struct inode *in;
+       int err = 0, i;
+       struct inode *snapdir = NULL;
+       struct ceph_mds_request_head *rhead = req->r_request->front.iov_base;
+       u64 frag = le32_to_cpu(rhead->args.readdir.frag);
+       struct ceph_dentry_info *di;
+
+       if (le32_to_cpu(rinfo->head->op) == CEPH_MDS_OP_LSSNAP) {
+               snapdir = ceph_get_snapdir(parent->d_inode);
+               parent = d_find_alias(snapdir);
+               dout("readdir_prepopulate %d items under SNAPDIR dn %p\n",
+                    rinfo->dir_nr, parent);
+       } else {
+               dout("readdir_prepopulate %d items under dn %p\n",
+                    rinfo->dir_nr, parent);
+               if (rinfo->dir_dir)
+                       ceph_fill_dirfrag(parent->d_inode, rinfo->dir_dir);
+       }
+
+       for (i = 0; i < rinfo->dir_nr; i++) {
+               struct ceph_vino vino;
+
+               dname.name = rinfo->dir_dname[i];
+               dname.len = rinfo->dir_dname_len[i];
+               dname.hash = full_name_hash(dname.name, dname.len);
+
+               vino.ino = le64_to_cpu(rinfo->dir_in[i].in->ino);
+               vino.snap = le64_to_cpu(rinfo->dir_in[i].in->snapid);
+
+retry_lookup:
+               dn = d_lookup(parent, &dname);
+               dout("d_lookup on parent=%p name=%.*s got %p\n",
+                    parent, dname.len, dname.name, dn);
+
+               if (!dn) {
+                       dn = d_alloc(parent, &dname);
+                       dout("d_alloc %p '%.*s' = %p\n", parent,
+                            dname.len, dname.name, dn);
+                       if (dn == NULL) {
+                               dout("d_alloc badness\n");
+                               err = -ENOMEM;
+                               goto out;
+                       }
+                       err = ceph_init_dentry(dn);
+                       if (err < 0)
+                               goto out;
+               } else if (dn->d_inode &&
+                          (ceph_ino(dn->d_inode) != vino.ino ||
+                           ceph_snap(dn->d_inode) != vino.snap)) {
+                       dout(" dn %p points to wrong inode %p\n",
+                            dn, dn->d_inode);
+                       d_delete(dn);
+                       dput(dn);
+                       goto retry_lookup;
+               } else {
+                       /* reorder parent's d_subdirs */
+                       spin_lock(&dcache_lock);
+                       spin_lock(&dn->d_lock);
+                       list_move(&dn->d_u.d_child, &parent->d_subdirs);
+                       spin_unlock(&dn->d_lock);
+                       spin_unlock(&dcache_lock);
+               }
+
+               di = dn->d_fsdata;
+               di->offset = ceph_make_fpos(frag, i + req->r_readdir_offset);
+
+               /* inode */
+               if (dn->d_inode) {
+                       in = dn->d_inode;
+               } else {
+                       in = ceph_get_inode(parent->d_sb, vino);
+                       if (in == NULL) {
+                               dout("new_inode badness\n");
+                               d_delete(dn);
+                               dput(dn);
+                               err = -ENOMEM;
+                               goto out;
+                       }
+                       dn = splice_dentry(dn, in, NULL);
+               }
+
+               if (fill_inode(in, &rinfo->dir_in[i], NULL, session,
+                              req->r_request_started, -1,
+                              &req->r_caps_reservation) < 0) {
+                       pr_err("fill_inode badness on %p\n", in);
+                       dput(dn);
+                       continue;
+               }
+               update_dentry_lease(dn, rinfo->dir_dlease[i],
+                                   req->r_session, req->r_request_started);
+               dput(dn);
+       }
+       req->r_did_prepopulate = true;
+
+out:
+       if (snapdir) {
+               iput(snapdir);
+               dput(parent);
+       }
+       dout("readdir_prepopulate done\n");
+       return err;
+}
+
+int ceph_inode_set_size(struct inode *inode, loff_t size)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int ret = 0;
+
+       spin_lock(&inode->i_lock);
+       dout("set_size %p %llu -> %llu\n", inode, inode->i_size, size);
+       inode->i_size = size;
+       inode->i_blocks = (size + (1 << 9) - 1) >> 9;
+
+       /* tell the MDS if we are approaching max_size */
+       if ((size << 1) >= ci->i_max_size &&
+           (ci->i_reported_size << 1) < ci->i_max_size)
+               ret = 1;
+
+       spin_unlock(&inode->i_lock);
+       return ret;
+}
+
+/*
+ * Write back inode data in a worker thread.  (This can't be done
+ * in the message handler context.)
+ */
+void ceph_queue_writeback(struct inode *inode)
+{
+       if (queue_work(ceph_inode_to_client(inode)->wb_wq,
+                      &ceph_inode(inode)->i_wb_work)) {
+               dout("ceph_queue_writeback %p\n", inode);
+               igrab(inode);
+       } else {
+               dout("ceph_queue_writeback %p failed\n", inode);
+       }
+}
+
+static void ceph_writeback_work(struct work_struct *work)
+{
+       struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info,
+                                                 i_wb_work);
+       struct inode *inode = &ci->vfs_inode;
+
+       dout("writeback %p\n", inode);
+       filemap_fdatawrite(&inode->i_data);
+       iput(inode);
+}
+
+/*
+ * queue an async invalidation
+ */
+void ceph_queue_invalidate(struct inode *inode)
+{
+       if (queue_work(ceph_inode_to_client(inode)->pg_inv_wq,
+                      &ceph_inode(inode)->i_pg_inv_work)) {
+               dout("ceph_queue_invalidate %p\n", inode);
+               igrab(inode);
+       } else {
+               dout("ceph_queue_invalidate %p failed\n", inode);
+       }
+}
+
+/*
+ * invalidate any pages that are not dirty or under writeback.  this
+ * includes pages that are clean and mapped.
+ */
+static void ceph_invalidate_nondirty_pages(struct address_space *mapping)
+{
+       struct pagevec pvec;
+       pgoff_t next = 0;
+       int i;
+
+       pagevec_init(&pvec, 0);
+       while (pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
+               for (i = 0; i < pagevec_count(&pvec); i++) {
+                       struct page *page = pvec.pages[i];
+                       pgoff_t index;
+                       int skip_page =
+                               (PageDirty(page) || PageWriteback(page));
+
+                       if (!skip_page)
+                               skip_page = !trylock_page(page);
+
+                       /*
+                        * We really shouldn't be looking at the ->index of an
+                        * unlocked page.  But we're not allowed to lock these
+                        * pages.  So we rely upon nobody altering the ->index
+                        * of this (pinned-by-us) page.
+                        */
+                       index = page->index;
+                       if (index > next)
+                               next = index;
+                       next++;
+
+                       if (skip_page)
+                               continue;
+
+                       generic_error_remove_page(mapping, page);
+                       unlock_page(page);
+               }
+               pagevec_release(&pvec);
+               cond_resched();
+       }
+}
+
+/*
+ * Invalidate inode pages in a worker thread.  (This can't be done
+ * in the message handler context.)
+ */
+static void ceph_invalidate_work(struct work_struct *work)
+{
+       struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info,
+                                                 i_pg_inv_work);
+       struct inode *inode = &ci->vfs_inode;
+       u32 orig_gen;
+       int check = 0;
+
+       spin_lock(&inode->i_lock);
+       dout("invalidate_pages %p gen %d revoking %d\n", inode,
+            ci->i_rdcache_gen, ci->i_rdcache_revoking);
+       if (ci->i_rdcache_gen == 0 ||
+           ci->i_rdcache_revoking != ci->i_rdcache_gen) {
+               BUG_ON(ci->i_rdcache_revoking > ci->i_rdcache_gen);
+               /* nevermind! */
+               ci->i_rdcache_revoking = 0;
+               spin_unlock(&inode->i_lock);
+               goto out;
+       }
+       orig_gen = ci->i_rdcache_gen;
+       spin_unlock(&inode->i_lock);
+
+       ceph_invalidate_nondirty_pages(inode->i_mapping);
+
+       spin_lock(&inode->i_lock);
+       if (orig_gen == ci->i_rdcache_gen) {
+               dout("invalidate_pages %p gen %d successful\n", inode,
+                    ci->i_rdcache_gen);
+               ci->i_rdcache_gen = 0;
+               ci->i_rdcache_revoking = 0;
+               check = 1;
+       } else {
+               dout("invalidate_pages %p gen %d raced, gen now %d\n",
+                    inode, orig_gen, ci->i_rdcache_gen);
+       }
+       spin_unlock(&inode->i_lock);
+
+       if (check)
+               ceph_check_caps(ci, 0, NULL);
+out:
+       iput(inode);
+}
+
+
+/*
+ * called by trunc_wq; take i_mutex ourselves
+ *
+ * We also truncate in a separate thread as well.
+ */
+static void ceph_vmtruncate_work(struct work_struct *work)
+{
+       struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info,
+                                                 i_vmtruncate_work);
+       struct inode *inode = &ci->vfs_inode;
+
+       dout("vmtruncate_work %p\n", inode);
+       mutex_lock(&inode->i_mutex);
+       __ceph_do_pending_vmtruncate(inode);
+       mutex_unlock(&inode->i_mutex);
+       iput(inode);
+}
+
+/*
+ * Queue an async vmtruncate.  If we fail to queue work, we will handle
+ * the truncation the next time we call __ceph_do_pending_vmtruncate.
+ */
+void ceph_queue_vmtruncate(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       if (queue_work(ceph_client(inode->i_sb)->trunc_wq,
+                      &ci->i_vmtruncate_work)) {
+               dout("ceph_queue_vmtruncate %p\n", inode);
+               igrab(inode);
+       } else {
+               dout("ceph_queue_vmtruncate %p failed, pending=%d\n",
+                    inode, ci->i_truncate_pending);
+       }
+}
+
+/*
+ * called with i_mutex held.
+ *
+ * Make sure any pending truncation is applied before doing anything
+ * that may depend on it.
+ */
+void __ceph_do_pending_vmtruncate(struct inode *inode)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       u64 to;
+       int wrbuffer_refs, wake = 0;
+
+retry:
+       spin_lock(&inode->i_lock);
+       if (ci->i_truncate_pending == 0) {
+               dout("__do_pending_vmtruncate %p none pending\n", inode);
+               spin_unlock(&inode->i_lock);
+               return;
+       }
+
+       /*
+        * make sure any dirty snapped pages are flushed before we
+        * possibly truncate them.. so write AND block!
+        */
+       if (ci->i_wrbuffer_ref_head < ci->i_wrbuffer_ref) {
+               dout("__do_pending_vmtruncate %p flushing snaps first\n",
+                    inode);
+               spin_unlock(&inode->i_lock);
+               filemap_write_and_wait_range(&inode->i_data, 0,
+                                            inode->i_sb->s_maxbytes);
+               goto retry;
+       }
+
+       to = ci->i_truncate_size;
+       wrbuffer_refs = ci->i_wrbuffer_ref;
+       dout("__do_pending_vmtruncate %p (%d) to %lld\n", inode,
+            ci->i_truncate_pending, to);
+       spin_unlock(&inode->i_lock);
+
+       truncate_inode_pages(inode->i_mapping, to);
+
+       spin_lock(&inode->i_lock);
+       ci->i_truncate_pending--;
+       if (ci->i_truncate_pending == 0)
+               wake = 1;
+       spin_unlock(&inode->i_lock);
+
+       if (wrbuffer_refs == 0)
+               ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
+       if (wake)
+               wake_up(&ci->i_cap_wq);
+}
+
+
+/*
+ * symlinks
+ */
+static void *ceph_sym_follow_link(struct dentry *dentry, struct nameidata *nd)
+{
+       struct ceph_inode_info *ci = ceph_inode(dentry->d_inode);
+       nd_set_link(nd, ci->i_symlink);
+       return NULL;
+}
+
+static const struct inode_operations ceph_symlink_iops = {
+       .readlink = generic_readlink,
+       .follow_link = ceph_sym_follow_link,
+};
+
+/*
+ * setattr
+ */
+int ceph_setattr(struct dentry *dentry, struct iattr *attr)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct inode *parent_inode = dentry->d_parent->d_inode;
+       const unsigned int ia_valid = attr->ia_valid;
+       struct ceph_mds_request *req;
+       struct ceph_mds_client *mdsc = &ceph_client(dentry->d_sb)->mdsc;
+       int issued;
+       int release = 0, dirtied = 0;
+       int mask = 0;
+       int err = 0;
+
+       if (ceph_snap(inode) != CEPH_NOSNAP)
+               return -EROFS;
+
+       __ceph_do_pending_vmtruncate(inode);
+
+       err = inode_change_ok(inode, attr);
+       if (err != 0)
+               return err;
+
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETATTR,
+                                      USE_AUTH_MDS);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+
+       spin_lock(&inode->i_lock);
+       issued = __ceph_caps_issued(ci, NULL);
+       dout("setattr %p issued %s\n", inode, ceph_cap_string(issued));
+
+       if (ia_valid & ATTR_UID) {
+               dout("setattr %p uid %d -> %d\n", inode,
+                    inode->i_uid, attr->ia_uid);
+               if (issued & CEPH_CAP_AUTH_EXCL) {
+                       inode->i_uid = attr->ia_uid;
+                       dirtied |= CEPH_CAP_AUTH_EXCL;
+               } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 ||
+                          attr->ia_uid != inode->i_uid) {
+                       req->r_args.setattr.uid = cpu_to_le32(attr->ia_uid);
+                       mask |= CEPH_SETATTR_UID;
+                       release |= CEPH_CAP_AUTH_SHARED;
+               }
+       }
+       if (ia_valid & ATTR_GID) {
+               dout("setattr %p gid %d -> %d\n", inode,
+                    inode->i_gid, attr->ia_gid);
+               if (issued & CEPH_CAP_AUTH_EXCL) {
+                       inode->i_gid = attr->ia_gid;
+                       dirtied |= CEPH_CAP_AUTH_EXCL;
+               } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 ||
+                          attr->ia_gid != inode->i_gid) {
+                       req->r_args.setattr.gid = cpu_to_le32(attr->ia_gid);
+                       mask |= CEPH_SETATTR_GID;
+                       release |= CEPH_CAP_AUTH_SHARED;
+               }
+       }
+       if (ia_valid & ATTR_MODE) {
+               dout("setattr %p mode 0%o -> 0%o\n", inode, inode->i_mode,
+                    attr->ia_mode);
+               if (issued & CEPH_CAP_AUTH_EXCL) {
+                       inode->i_mode = attr->ia_mode;
+                       dirtied |= CEPH_CAP_AUTH_EXCL;
+               } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 ||
+                          attr->ia_mode != inode->i_mode) {
+                       req->r_args.setattr.mode = cpu_to_le32(attr->ia_mode);
+                       mask |= CEPH_SETATTR_MODE;
+                       release |= CEPH_CAP_AUTH_SHARED;
+               }
+       }
+
+       if (ia_valid & ATTR_ATIME) {
+               dout("setattr %p atime %ld.%ld -> %ld.%ld\n", inode,
+                    inode->i_atime.tv_sec, inode->i_atime.tv_nsec,
+                    attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec);
+               if (issued & CEPH_CAP_FILE_EXCL) {
+                       ci->i_time_warp_seq++;
+                       inode->i_atime = attr->ia_atime;
+                       dirtied |= CEPH_CAP_FILE_EXCL;
+               } else if ((issued & CEPH_CAP_FILE_WR) &&
+                          timespec_compare(&inode->i_atime,
+                                           &attr->ia_atime) < 0) {
+                       inode->i_atime = attr->ia_atime;
+                       dirtied |= CEPH_CAP_FILE_WR;
+               } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
+                          !timespec_equal(&inode->i_atime, &attr->ia_atime)) {
+                       ceph_encode_timespec(&req->r_args.setattr.atime,
+                                            &attr->ia_atime);
+                       mask |= CEPH_SETATTR_ATIME;
+                       release |= CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD |
+                               CEPH_CAP_FILE_WR;
+               }
+       }
+       if (ia_valid & ATTR_MTIME) {
+               dout("setattr %p mtime %ld.%ld -> %ld.%ld\n", inode,
+                    inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                    attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec);
+               if (issued & CEPH_CAP_FILE_EXCL) {
+                       ci->i_time_warp_seq++;
+                       inode->i_mtime = attr->ia_mtime;
+                       dirtied |= CEPH_CAP_FILE_EXCL;
+               } else if ((issued & CEPH_CAP_FILE_WR) &&
+                          timespec_compare(&inode->i_mtime,
+                                           &attr->ia_mtime) < 0) {
+                       inode->i_mtime = attr->ia_mtime;
+                       dirtied |= CEPH_CAP_FILE_WR;
+               } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
+                          !timespec_equal(&inode->i_mtime, &attr->ia_mtime)) {
+                       ceph_encode_timespec(&req->r_args.setattr.mtime,
+                                            &attr->ia_mtime);
+                       mask |= CEPH_SETATTR_MTIME;
+                       release |= CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_RD |
+                               CEPH_CAP_FILE_WR;
+               }
+       }
+       if (ia_valid & ATTR_SIZE) {
+               dout("setattr %p size %lld -> %lld\n", inode,
+                    inode->i_size, attr->ia_size);
+               if (attr->ia_size > inode->i_sb->s_maxbytes) {
+                       err = -EINVAL;
+                       goto out;
+               }
+               if ((issued & CEPH_CAP_FILE_EXCL) &&
+                   attr->ia_size > inode->i_size) {
+                       inode->i_size = attr->ia_size;
+                       inode->i_blocks =
+                               (attr->ia_size + (1 << 9) - 1) >> 9;
+                       inode->i_ctime = attr->ia_ctime;
+                       ci->i_reported_size = attr->ia_size;
+                       dirtied |= CEPH_CAP_FILE_EXCL;
+               } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
+                          attr->ia_size != inode->i_size) {
+                       req->r_args.setattr.size = cpu_to_le64(attr->ia_size);
+                       req->r_args.setattr.old_size =
+                               cpu_to_le64(inode->i_size);
+                       mask |= CEPH_SETATTR_SIZE;
+                       release |= CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_RD |
+                               CEPH_CAP_FILE_WR;
+               }
+       }
+
+       /* these do nothing */
+       if (ia_valid & ATTR_CTIME) {
+               bool only = (ia_valid & (ATTR_SIZE|ATTR_MTIME|ATTR_ATIME|
+                                        ATTR_MODE|ATTR_UID|ATTR_GID)) == 0;
+               dout("setattr %p ctime %ld.%ld -> %ld.%ld (%s)\n", inode,
+                    inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                    attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec,
+                    only ? "ctime only" : "ignored");
+               inode->i_ctime = attr->ia_ctime;
+               if (only) {
+                       /*
+                        * if kernel wants to dirty ctime but nothing else,
+                        * we need to choose a cap to dirty under, or do
+                        * a almost-no-op setattr
+                        */
+                       if (issued & CEPH_CAP_AUTH_EXCL)
+                               dirtied |= CEPH_CAP_AUTH_EXCL;
+                       else if (issued & CEPH_CAP_FILE_EXCL)
+                               dirtied |= CEPH_CAP_FILE_EXCL;
+                       else if (issued & CEPH_CAP_XATTR_EXCL)
+                               dirtied |= CEPH_CAP_XATTR_EXCL;
+                       else
+                               mask |= CEPH_SETATTR_CTIME;
+               }
+       }
+       if (ia_valid & ATTR_FILE)
+               dout("setattr %p ATTR_FILE ... hrm!\n", inode);
+
+       if (dirtied) {
+               __ceph_mark_dirty_caps(ci, dirtied);
+               inode->i_ctime = CURRENT_TIME;
+       }
+
+       release &= issued;
+       spin_unlock(&inode->i_lock);
+
+       if (mask) {
+               req->r_inode = igrab(inode);
+               req->r_inode_drop = release;
+               req->r_args.setattr.mask = cpu_to_le32(mask);
+               req->r_num_caps = 1;
+               err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       }
+       dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err,
+            ceph_cap_string(dirtied), mask);
+
+       ceph_mdsc_put_request(req);
+       __ceph_do_pending_vmtruncate(inode);
+       return err;
+out:
+       spin_unlock(&inode->i_lock);
+       ceph_mdsc_put_request(req);
+       return err;
+}
+
+/*
+ * Verify that we have a lease on the given mask.  If not,
+ * do a getattr against an mds.
+ */
+int ceph_do_getattr(struct inode *inode, int mask)
+{
+       struct ceph_client *client = ceph_sb_to_client(inode->i_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req;
+       int err;
+
+       if (ceph_snap(inode) == CEPH_SNAPDIR) {
+               dout("do_getattr inode %p SNAPDIR\n", inode);
+               return 0;
+       }
+
+       dout("do_getattr inode %p mask %s\n", inode, ceph_cap_string(mask));
+       if (ceph_caps_issued_mask(ceph_inode(inode), mask, 1))
+               return 0;
+
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+       req->r_inode = igrab(inode);
+       req->r_num_caps = 1;
+       req->r_args.getattr.mask = cpu_to_le32(mask);
+       err = ceph_mdsc_do_request(mdsc, NULL, req);
+       ceph_mdsc_put_request(req);
+       dout("do_getattr result=%d\n", err);
+       return err;
+}
+
+
+/*
+ * Check inode permissions.  We verify we have a valid value for
+ * the AUTH cap, then call the generic handler.
+ */
+int ceph_permission(struct inode *inode, int mask)
+{
+       int err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED);
+
+       if (!err)
+               err = generic_permission(inode, mask, NULL);
+       return err;
+}
+
+/*
+ * Get all attributes.  Hopefully somedata we'll have a statlite()
+ * and can limit the fields we require to be accurate.
+ */
+int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
+                struct kstat *stat)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int err;
+
+       err = ceph_do_getattr(inode, CEPH_STAT_CAP_INODE_ALL);
+       if (!err) {
+               generic_fillattr(inode, stat);
+               stat->ino = inode->i_ino;
+               if (ceph_snap(inode) != CEPH_NOSNAP)
+                       stat->dev = ceph_snap(inode);
+               else
+                       stat->dev = 0;
+               if (S_ISDIR(inode->i_mode)) {
+                       stat->size = ci->i_rbytes;
+                       stat->blocks = 0;
+                       stat->blksize = 65536;
+               }
+       }
+       return err;
+}
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
new file mode 100644 (file)
index 0000000..8a5bcae
--- /dev/null
@@ -0,0 +1,160 @@
+#include <linux/in.h>
+
+#include "ioctl.h"
+#include "super.h"
+#include "ceph_debug.h"
+
+
+/*
+ * ioctls
+ */
+
+/*
+ * get and set the file layout
+ */
+static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
+{
+       struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode);
+       struct ceph_ioctl_layout l;
+       int err;
+
+       err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
+       if (!err) {
+               l.stripe_unit = ceph_file_layout_su(ci->i_layout);
+               l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
+               l.object_size = ceph_file_layout_object_size(ci->i_layout);
+               l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
+               l.preferred_osd =
+                       (s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
+               if (copy_to_user(arg, &l, sizeof(l)))
+                       return -EFAULT;
+       }
+
+       return err;
+}
+
+static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
+{
+       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *parent_inode = file->f_dentry->d_parent->d_inode;
+       struct ceph_mds_client *mdsc = &ceph_sb_to_client(inode->i_sb)->mdsc;
+       struct ceph_mds_request *req;
+       struct ceph_ioctl_layout l;
+       int err, i;
+
+       /* copy and validate */
+       if (copy_from_user(&l, arg, sizeof(l)))
+               return -EFAULT;
+
+       if ((l.object_size & ~PAGE_MASK) ||
+           (l.stripe_unit & ~PAGE_MASK) ||
+           !l.stripe_unit ||
+           (l.object_size &&
+            (unsigned)l.object_size % (unsigned)l.stripe_unit))
+               return -EINVAL;
+
+       /* make sure it's a valid data pool */
+       if (l.data_pool > 0) {
+               mutex_lock(&mdsc->mutex);
+               err = -EINVAL;
+               for (i = 0; i < mdsc->mdsmap->m_num_data_pg_pools; i++)
+                       if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) {
+                               err = 0;
+                               break;
+                       }
+               mutex_unlock(&mdsc->mutex);
+               if (err)
+                       return err;
+       }
+
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETLAYOUT,
+                                      USE_AUTH_MDS);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+       req->r_inode = igrab(inode);
+       req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL;
+
+       req->r_args.setlayout.layout.fl_stripe_unit =
+               cpu_to_le32(l.stripe_unit);
+       req->r_args.setlayout.layout.fl_stripe_count =
+               cpu_to_le32(l.stripe_count);
+       req->r_args.setlayout.layout.fl_object_size =
+               cpu_to_le32(l.object_size);
+       req->r_args.setlayout.layout.fl_pg_pool = cpu_to_le32(l.data_pool);
+       req->r_args.setlayout.layout.fl_pg_preferred =
+               cpu_to_le32(l.preferred_osd);
+
+       err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       ceph_mdsc_put_request(req);
+       return err;
+}
+
+/*
+ * Return object name, size/offset information, and location (OSD
+ * number, network address) for a given file offset.
+ */
+static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
+{
+       struct ceph_ioctl_dataloc dl;
+       struct inode *inode = file->f_dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_osd_client *osdc = &ceph_client(inode->i_sb)->osdc;
+       u64 len = 1, olen;
+       u64 tmp;
+       struct ceph_object_layout ol;
+       struct ceph_pg pgid;
+
+       /* copy and validate */
+       if (copy_from_user(&dl, arg, sizeof(dl)))
+               return -EFAULT;
+
+       down_read(&osdc->map_sem);
+       ceph_calc_file_object_mapping(&ci->i_layout, dl.file_offset, &len,
+                                     &dl.object_no, &dl.object_offset, &olen);
+       dl.file_offset -= dl.object_offset;
+       dl.object_size = ceph_file_layout_object_size(ci->i_layout);
+       dl.block_size = ceph_file_layout_su(ci->i_layout);
+
+       /* block_offset = object_offset % block_size */
+       tmp = dl.object_offset;
+       dl.block_offset = do_div(tmp, dl.block_size);
+
+       snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
+                ceph_ino(inode), dl.object_no);
+       ceph_calc_object_layout(&ol, dl.object_name, &ci->i_layout,
+                               osdc->osdmap);
+
+       pgid = ol.ol_pgid;
+       dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid);
+       if (dl.osd >= 0) {
+               struct ceph_entity_addr *a =
+                       ceph_osd_addr(osdc->osdmap, dl.osd);
+               if (a)
+                       memcpy(&dl.osd_addr, &a->in_addr, sizeof(dl.osd_addr));
+       } else {
+               memset(&dl.osd_addr, 0, sizeof(dl.osd_addr));
+       }
+       up_read(&osdc->map_sem);
+
+       /* send result back to user */
+       if (copy_to_user(arg, &dl, sizeof(dl)))
+               return -EFAULT;
+
+       return 0;
+}
+
+long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg);
+       switch (cmd) {
+       case CEPH_IOC_GET_LAYOUT:
+               return ceph_ioctl_get_layout(file, (void __user *)arg);
+
+       case CEPH_IOC_SET_LAYOUT:
+               return ceph_ioctl_set_layout(file, (void __user *)arg);
+
+       case CEPH_IOC_GET_DATALOC:
+               return ceph_ioctl_get_dataloc(file, (void __user *)arg);
+       }
+       return -ENOTTY;
+}
diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h
new file mode 100644 (file)
index 0000000..25e4f1a
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef FS_CEPH_IOCTL_H
+#define FS_CEPH_IOCTL_H
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+#define CEPH_IOCTL_MAGIC 0x97
+
+/* just use u64 to align sanely on all archs */
+struct ceph_ioctl_layout {
+       __u64 stripe_unit, stripe_count, object_size;
+       __u64 data_pool;
+       __s64 preferred_osd;
+};
+
+#define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1,          \
+                                  struct ceph_ioctl_layout)
+#define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2,          \
+                                  struct ceph_ioctl_layout)
+
+/*
+ * Extract identity, address of the OSD and object storing a given
+ * file offset.
+ */
+struct ceph_ioctl_dataloc {
+       __u64 file_offset;           /* in+out: file offset */
+       __u64 object_offset;         /* out: offset in object */
+       __u64 object_no;             /* out: object # */
+       __u64 object_size;           /* out: object size */
+       char object_name[64];        /* out: object name */
+       __u64 block_offset;          /* out: offset in block */
+       __u64 block_size;            /* out: block length */
+       __s64 osd;                   /* out: osd # */
+       struct sockaddr_storage osd_addr; /* out: osd address */
+};
+
+#define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3,        \
+                                  struct ceph_ioctl_dataloc)
+
+#endif
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
new file mode 100644 (file)
index 0000000..60a9a4a
--- /dev/null
@@ -0,0 +1,3043 @@
+#include "ceph_debug.h"
+
+#include <linux/wait.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+
+#include "mds_client.h"
+#include "mon_client.h"
+#include "super.h"
+#include "messenger.h"
+#include "decode.h"
+#include "auth.h"
+#include "pagelist.h"
+
+/*
+ * A cluster of MDS (metadata server) daemons is responsible for
+ * managing the file system namespace (the directory hierarchy and
+ * inodes) and for coordinating shared access to storage.  Metadata is
+ * partitioning hierarchically across a number of servers, and that
+ * partition varies over time as the cluster adjusts the distribution
+ * in order to balance load.
+ *
+ * The MDS client is primarily responsible to managing synchronous
+ * metadata requests for operations like open, unlink, and so forth.
+ * If there is a MDS failure, we find out about it when we (possibly
+ * request and) receive a new MDS map, and can resubmit affected
+ * requests.
+ *
+ * For the most part, though, we take advantage of a lossless
+ * communications channel to the MDS, and do not need to worry about
+ * timing out or resubmitting requests.
+ *
+ * We maintain a stateful "session" with each MDS we interact with.
+ * Within each session, we sent periodic heartbeat messages to ensure
+ * any capabilities or leases we have been issues remain valid.  If
+ * the session times out and goes stale, our leases and capabilities
+ * are no longer valid.
+ */
+
+static void __wake_requests(struct ceph_mds_client *mdsc,
+                           struct list_head *head);
+
+const static struct ceph_connection_operations mds_con_ops;
+
+
+/*
+ * mds reply parsing
+ */
+
+/*
+ * parse individual inode info
+ */
+static int parse_reply_info_in(void **p, void *end,
+                              struct ceph_mds_reply_info_in *info)
+{
+       int err = -EIO;
+
+       info->in = *p;
+       *p += sizeof(struct ceph_mds_reply_inode) +
+               sizeof(*info->in->fragtree.splits) *
+               le32_to_cpu(info->in->fragtree.nsplits);
+
+       ceph_decode_32_safe(p, end, info->symlink_len, bad);
+       ceph_decode_need(p, end, info->symlink_len, bad);
+       info->symlink = *p;
+       *p += info->symlink_len;
+
+       ceph_decode_32_safe(p, end, info->xattr_len, bad);
+       ceph_decode_need(p, end, info->xattr_len, bad);
+       info->xattr_data = *p;
+       *p += info->xattr_len;
+       return 0;
+bad:
+       return err;
+}
+
+/*
+ * parse a normal reply, which may contain a (dir+)dentry and/or a
+ * target inode.
+ */
+static int parse_reply_info_trace(void **p, void *end,
+                                 struct ceph_mds_reply_info_parsed *info)
+{
+       int err;
+
+       if (info->head->is_dentry) {
+               err = parse_reply_info_in(p, end, &info->diri);
+               if (err < 0)
+                       goto out_bad;
+
+               if (unlikely(*p + sizeof(*info->dirfrag) > end))
+                       goto bad;
+               info->dirfrag = *p;
+               *p += sizeof(*info->dirfrag) +
+                       sizeof(u32)*le32_to_cpu(info->dirfrag->ndist);
+               if (unlikely(*p > end))
+                       goto bad;
+
+               ceph_decode_32_safe(p, end, info->dname_len, bad);
+               ceph_decode_need(p, end, info->dname_len, bad);
+               info->dname = *p;
+               *p += info->dname_len;
+               info->dlease = *p;
+               *p += sizeof(*info->dlease);
+       }
+
+       if (info->head->is_target) {
+               err = parse_reply_info_in(p, end, &info->targeti);
+               if (err < 0)
+                       goto out_bad;
+       }
+
+       if (unlikely(*p != end))
+               goto bad;
+       return 0;
+
+bad:
+       err = -EIO;
+out_bad:
+       pr_err("problem parsing mds trace %d\n", err);
+       return err;
+}
+
+/*
+ * parse readdir results
+ */
+static int parse_reply_info_dir(void **p, void *end,
+                               struct ceph_mds_reply_info_parsed *info)
+{
+       u32 num, i = 0;
+       int err;
+
+       info->dir_dir = *p;
+       if (*p + sizeof(*info->dir_dir) > end)
+               goto bad;
+       *p += sizeof(*info->dir_dir) +
+               sizeof(u32)*le32_to_cpu(info->dir_dir->ndist);
+       if (*p > end)
+               goto bad;
+
+       ceph_decode_need(p, end, sizeof(num) + 2, bad);
+       num = ceph_decode_32(p);
+       info->dir_end = ceph_decode_8(p);
+       info->dir_complete = ceph_decode_8(p);
+       if (num == 0)
+               goto done;
+
+       /* alloc large array */
+       info->dir_nr = num;
+       info->dir_in = kcalloc(num, sizeof(*info->dir_in) +
+                              sizeof(*info->dir_dname) +
+                              sizeof(*info->dir_dname_len) +
+                              sizeof(*info->dir_dlease),
+                              GFP_NOFS);
+       if (info->dir_in == NULL) {
+               err = -ENOMEM;
+               goto out_bad;
+       }
+       info->dir_dname = (void *)(info->dir_in + num);
+       info->dir_dname_len = (void *)(info->dir_dname + num);
+       info->dir_dlease = (void *)(info->dir_dname_len + num);
+
+       while (num) {
+               /* dentry */
+               ceph_decode_need(p, end, sizeof(u32)*2, bad);
+               info->dir_dname_len[i] = ceph_decode_32(p);
+               ceph_decode_need(p, end, info->dir_dname_len[i], bad);
+               info->dir_dname[i] = *p;
+               *p += info->dir_dname_len[i];
+               dout("parsed dir dname '%.*s'\n", info->dir_dname_len[i],
+                    info->dir_dname[i]);
+               info->dir_dlease[i] = *p;
+               *p += sizeof(struct ceph_mds_reply_lease);
+
+               /* inode */
+               err = parse_reply_info_in(p, end, &info->dir_in[i]);
+               if (err < 0)
+                       goto out_bad;
+               i++;
+               num--;
+       }
+
+done:
+       if (*p != end)
+               goto bad;
+       return 0;
+
+bad:
+       err = -EIO;
+out_bad:
+       pr_err("problem parsing dir contents %d\n", err);
+       return err;
+}
+
+/*
+ * parse entire mds reply
+ */
+static int parse_reply_info(struct ceph_msg *msg,
+                           struct ceph_mds_reply_info_parsed *info)
+{
+       void *p, *end;
+       u32 len;
+       int err;
+
+       info->head = msg->front.iov_base;
+       p = msg->front.iov_base + sizeof(struct ceph_mds_reply_head);
+       end = p + msg->front.iov_len - sizeof(struct ceph_mds_reply_head);
+
+       /* trace */
+       ceph_decode_32_safe(&p, end, len, bad);
+       if (len > 0) {
+               err = parse_reply_info_trace(&p, p+len, info);
+               if (err < 0)
+                       goto out_bad;
+       }
+
+       /* dir content */
+       ceph_decode_32_safe(&p, end, len, bad);
+       if (len > 0) {
+               err = parse_reply_info_dir(&p, p+len, info);
+               if (err < 0)
+                       goto out_bad;
+       }
+
+       /* snap blob */
+       ceph_decode_32_safe(&p, end, len, bad);
+       info->snapblob_len = len;
+       info->snapblob = p;
+       p += len;
+
+       if (p != end)
+               goto bad;
+       return 0;
+
+bad:
+       err = -EIO;
+out_bad:
+       pr_err("mds parse_reply err %d\n", err);
+       return err;
+}
+
+static void destroy_reply_info(struct ceph_mds_reply_info_parsed *info)
+{
+       kfree(info->dir_in);
+}
+
+
+/*
+ * sessions
+ */
+static const char *session_state_name(int s)
+{
+       switch (s) {
+       case CEPH_MDS_SESSION_NEW: return "new";
+       case CEPH_MDS_SESSION_OPENING: return "opening";
+       case CEPH_MDS_SESSION_OPEN: return "open";
+       case CEPH_MDS_SESSION_HUNG: return "hung";
+       case CEPH_MDS_SESSION_CLOSING: return "closing";
+       case CEPH_MDS_SESSION_RESTARTING: return "restarting";
+       case CEPH_MDS_SESSION_RECONNECTING: return "reconnecting";
+       default: return "???";
+       }
+}
+
+static struct ceph_mds_session *get_session(struct ceph_mds_session *s)
+{
+       if (atomic_inc_not_zero(&s->s_ref)) {
+               dout("mdsc get_session %p %d -> %d\n", s,
+                    atomic_read(&s->s_ref)-1, atomic_read(&s->s_ref));
+               return s;
+       } else {
+               dout("mdsc get_session %p 0 -- FAIL", s);
+               return NULL;
+       }
+}
+
+void ceph_put_mds_session(struct ceph_mds_session *s)
+{
+       dout("mdsc put_session %p %d -> %d\n", s,
+            atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1);
+       if (atomic_dec_and_test(&s->s_ref)) {
+               if (s->s_authorizer)
+                       s->s_mdsc->client->monc.auth->ops->destroy_authorizer(
+                               s->s_mdsc->client->monc.auth, s->s_authorizer);
+               kfree(s);
+       }
+}
+
+/*
+ * called under mdsc->mutex
+ */
+struct ceph_mds_session *__ceph_lookup_mds_session(struct ceph_mds_client *mdsc,
+                                                  int mds)
+{
+       struct ceph_mds_session *session;
+
+       if (mds >= mdsc->max_sessions || mdsc->sessions[mds] == NULL)
+               return NULL;
+       session = mdsc->sessions[mds];
+       dout("lookup_mds_session %p %d\n", session,
+            atomic_read(&session->s_ref));
+       get_session(session);
+       return session;
+}
+
+static bool __have_session(struct ceph_mds_client *mdsc, int mds)
+{
+       if (mds >= mdsc->max_sessions)
+               return false;
+       return mdsc->sessions[mds];
+}
+
+static int __verify_registered_session(struct ceph_mds_client *mdsc,
+                                      struct ceph_mds_session *s)
+{
+       if (s->s_mds >= mdsc->max_sessions ||
+           mdsc->sessions[s->s_mds] != s)
+               return -ENOENT;
+       return 0;
+}
+
+/*
+ * create+register a new session for given mds.
+ * called under mdsc->mutex.
+ */
+static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
+                                                int mds)
+{
+       struct ceph_mds_session *s;
+
+       s = kzalloc(sizeof(*s), GFP_NOFS);
+       if (!s)
+               return ERR_PTR(-ENOMEM);
+       s->s_mdsc = mdsc;
+       s->s_mds = mds;
+       s->s_state = CEPH_MDS_SESSION_NEW;
+       s->s_ttl = 0;
+       s->s_seq = 0;
+       mutex_init(&s->s_mutex);
+
+       ceph_con_init(mdsc->client->msgr, &s->s_con);
+       s->s_con.private = s;
+       s->s_con.ops = &mds_con_ops;
+       s->s_con.peer_name.type = CEPH_ENTITY_TYPE_MDS;
+       s->s_con.peer_name.num = cpu_to_le64(mds);
+
+       spin_lock_init(&s->s_cap_lock);
+       s->s_cap_gen = 0;
+       s->s_cap_ttl = 0;
+       s->s_renew_requested = 0;
+       s->s_renew_seq = 0;
+       INIT_LIST_HEAD(&s->s_caps);
+       s->s_nr_caps = 0;
+       s->s_trim_caps = 0;
+       atomic_set(&s->s_ref, 1);
+       INIT_LIST_HEAD(&s->s_waiting);
+       INIT_LIST_HEAD(&s->s_unsafe);
+       s->s_num_cap_releases = 0;
+       s->s_cap_iterator = NULL;
+       INIT_LIST_HEAD(&s->s_cap_releases);
+       INIT_LIST_HEAD(&s->s_cap_releases_done);
+       INIT_LIST_HEAD(&s->s_cap_flushing);
+       INIT_LIST_HEAD(&s->s_cap_snaps_flushing);
+
+       dout("register_session mds%d\n", mds);
+       if (mds >= mdsc->max_sessions) {
+               int newmax = 1 << get_count_order(mds+1);
+               struct ceph_mds_session **sa;
+
+               dout("register_session realloc to %d\n", newmax);
+               sa = kcalloc(newmax, sizeof(void *), GFP_NOFS);
+               if (sa == NULL)
+                       goto fail_realloc;
+               if (mdsc->sessions) {
+                       memcpy(sa, mdsc->sessions,
+                              mdsc->max_sessions * sizeof(void *));
+                       kfree(mdsc->sessions);
+               }
+               mdsc->sessions = sa;
+               mdsc->max_sessions = newmax;
+       }
+       mdsc->sessions[mds] = s;
+       atomic_inc(&s->s_ref);  /* one ref to sessions[], one to caller */
+
+       ceph_con_open(&s->s_con, ceph_mdsmap_get_addr(mdsc->mdsmap, mds));
+
+       return s;
+
+fail_realloc:
+       kfree(s);
+       return ERR_PTR(-ENOMEM);
+}
+
+/*
+ * called under mdsc->mutex
+ */
+static void __unregister_session(struct ceph_mds_client *mdsc,
+                              struct ceph_mds_session *s)
+{
+       dout("__unregister_session mds%d %p\n", s->s_mds, s);
+       BUG_ON(mdsc->sessions[s->s_mds] != s);
+       mdsc->sessions[s->s_mds] = NULL;
+       ceph_con_close(&s->s_con);
+       ceph_put_mds_session(s);
+}
+
+/*
+ * drop session refs in request.
+ *
+ * should be last request ref, or hold mdsc->mutex
+ */
+static void put_request_session(struct ceph_mds_request *req)
+{
+       if (req->r_session) {
+               ceph_put_mds_session(req->r_session);
+               req->r_session = NULL;
+       }
+}
+
+void ceph_mdsc_release_request(struct kref *kref)
+{
+       struct ceph_mds_request *req = container_of(kref,
+                                                   struct ceph_mds_request,
+                                                   r_kref);
+       if (req->r_request)
+               ceph_msg_put(req->r_request);
+       if (req->r_reply) {
+               ceph_msg_put(req->r_reply);
+               destroy_reply_info(&req->r_reply_info);
+       }
+       if (req->r_inode) {
+               ceph_put_cap_refs(ceph_inode(req->r_inode),
+                                 CEPH_CAP_PIN);
+               iput(req->r_inode);
+       }
+       if (req->r_locked_dir)
+               ceph_put_cap_refs(ceph_inode(req->r_locked_dir),
+                                 CEPH_CAP_PIN);
+       if (req->r_target_inode)
+               iput(req->r_target_inode);
+       if (req->r_dentry)
+               dput(req->r_dentry);
+       if (req->r_old_dentry) {
+               ceph_put_cap_refs(
+                       ceph_inode(req->r_old_dentry->d_parent->d_inode),
+                       CEPH_CAP_PIN);
+               dput(req->r_old_dentry);
+       }
+       kfree(req->r_path1);
+       kfree(req->r_path2);
+       put_request_session(req);
+       ceph_unreserve_caps(&req->r_caps_reservation);
+       kfree(req);
+}
+
+/*
+ * lookup session, bump ref if found.
+ *
+ * called under mdsc->mutex.
+ */
+static struct ceph_mds_request *__lookup_request(struct ceph_mds_client *mdsc,
+                                            u64 tid)
+{
+       struct ceph_mds_request *req;
+       struct rb_node *n = mdsc->request_tree.rb_node;
+
+       while (n) {
+               req = rb_entry(n, struct ceph_mds_request, r_node);
+               if (tid < req->r_tid)
+                       n = n->rb_left;
+               else if (tid > req->r_tid)
+                       n = n->rb_right;
+               else {
+                       ceph_mdsc_get_request(req);
+                       return req;
+               }
+       }
+       return NULL;
+}
+
+static void __insert_request(struct ceph_mds_client *mdsc,
+                            struct ceph_mds_request *new)
+{
+       struct rb_node **p = &mdsc->request_tree.rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_mds_request *req = NULL;
+
+       while (*p) {
+               parent = *p;
+               req = rb_entry(parent, struct ceph_mds_request, r_node);
+               if (new->r_tid < req->r_tid)
+                       p = &(*p)->rb_left;
+               else if (new->r_tid > req->r_tid)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->r_node, parent, p);
+       rb_insert_color(&new->r_node, &mdsc->request_tree);
+}
+
+/*
+ * Register an in-flight request, and assign a tid.  Link to directory
+ * are modifying (if any).
+ *
+ * Called under mdsc->mutex.
+ */
+static void __register_request(struct ceph_mds_client *mdsc,
+                              struct ceph_mds_request *req,
+                              struct inode *dir)
+{
+       req->r_tid = ++mdsc->last_tid;
+       if (req->r_num_caps)
+               ceph_reserve_caps(&req->r_caps_reservation, req->r_num_caps);
+       dout("__register_request %p tid %lld\n", req, req->r_tid);
+       ceph_mdsc_get_request(req);
+       __insert_request(mdsc, req);
+
+       if (dir) {
+               struct ceph_inode_info *ci = ceph_inode(dir);
+
+               spin_lock(&ci->i_unsafe_lock);
+               req->r_unsafe_dir = dir;
+               list_add_tail(&req->r_unsafe_dir_item, &ci->i_unsafe_dirops);
+               spin_unlock(&ci->i_unsafe_lock);
+       }
+}
+
+static void __unregister_request(struct ceph_mds_client *mdsc,
+                                struct ceph_mds_request *req)
+{
+       dout("__unregister_request %p tid %lld\n", req, req->r_tid);
+       rb_erase(&req->r_node, &mdsc->request_tree);
+       RB_CLEAR_NODE(&req->r_node);
+
+       if (req->r_unsafe_dir) {
+               struct ceph_inode_info *ci = ceph_inode(req->r_unsafe_dir);
+
+               spin_lock(&ci->i_unsafe_lock);
+               list_del_init(&req->r_unsafe_dir_item);
+               spin_unlock(&ci->i_unsafe_lock);
+       }
+
+       ceph_mdsc_put_request(req);
+}
+
+/*
+ * Choose mds to send request to next.  If there is a hint set in the
+ * request (e.g., due to a prior forward hint from the mds), use that.
+ * Otherwise, consult frag tree and/or caps to identify the
+ * appropriate mds.  If all else fails, choose randomly.
+ *
+ * Called under mdsc->mutex.
+ */
+static int __choose_mds(struct ceph_mds_client *mdsc,
+                       struct ceph_mds_request *req)
+{
+       struct inode *inode;
+       struct ceph_inode_info *ci;
+       struct ceph_cap *cap;
+       int mode = req->r_direct_mode;
+       int mds = -1;
+       u32 hash = req->r_direct_hash;
+       bool is_hash = req->r_direct_is_hash;
+
+       /*
+        * is there a specific mds we should try?  ignore hint if we have
+        * no session and the mds is not up (active or recovering).
+        */
+       if (req->r_resend_mds >= 0 &&
+           (__have_session(mdsc, req->r_resend_mds) ||
+            ceph_mdsmap_get_state(mdsc->mdsmap, req->r_resend_mds) > 0)) {
+               dout("choose_mds using resend_mds mds%d\n",
+                    req->r_resend_mds);
+               return req->r_resend_mds;
+       }
+
+       if (mode == USE_RANDOM_MDS)
+               goto random;
+
+       inode = NULL;
+       if (req->r_inode) {
+               inode = req->r_inode;
+       } else if (req->r_dentry) {
+               if (req->r_dentry->d_inode) {
+                       inode = req->r_dentry->d_inode;
+               } else {
+                       inode = req->r_dentry->d_parent->d_inode;
+                       hash = req->r_dentry->d_name.hash;
+                       is_hash = true;
+               }
+       }
+       dout("__choose_mds %p is_hash=%d (%d) mode %d\n", inode, (int)is_hash,
+            (int)hash, mode);
+       if (!inode)
+               goto random;
+       ci = ceph_inode(inode);
+
+       if (is_hash && S_ISDIR(inode->i_mode)) {
+               struct ceph_inode_frag frag;
+               int found;
+
+               ceph_choose_frag(ci, hash, &frag, &found);
+               if (found) {
+                       if (mode == USE_ANY_MDS && frag.ndist > 0) {
+                               u8 r;
+
+                               /* choose a random replica */
+                               get_random_bytes(&r, 1);
+                               r %= frag.ndist;
+                               mds = frag.dist[r];
+                               dout("choose_mds %p %llx.%llx "
+                                    "frag %u mds%d (%d/%d)\n",
+                                    inode, ceph_vinop(inode),
+                                    frag.frag, frag.mds,
+                                    (int)r, frag.ndist);
+                               return mds;
+                       }
+
+                       /* since this file/dir wasn't known to be
+                        * replicated, then we want to look for the
+                        * authoritative mds. */
+                       mode = USE_AUTH_MDS;
+                       if (frag.mds >= 0) {
+                               /* choose auth mds */
+                               mds = frag.mds;
+                               dout("choose_mds %p %llx.%llx "
+                                    "frag %u mds%d (auth)\n",
+                                    inode, ceph_vinop(inode), frag.frag, mds);
+                               return mds;
+                       }
+               }
+       }
+
+       spin_lock(&inode->i_lock);
+       cap = NULL;
+       if (mode == USE_AUTH_MDS)
+               cap = ci->i_auth_cap;
+       if (!cap && !RB_EMPTY_ROOT(&ci->i_caps))
+               cap = rb_entry(rb_first(&ci->i_caps), struct ceph_cap, ci_node);
+       if (!cap) {
+               spin_unlock(&inode->i_lock);
+               goto random;
+       }
+       mds = cap->session->s_mds;
+       dout("choose_mds %p %llx.%llx mds%d (%scap %p)\n",
+            inode, ceph_vinop(inode), mds,
+            cap == ci->i_auth_cap ? "auth " : "", cap);
+       spin_unlock(&inode->i_lock);
+       return mds;
+
+random:
+       mds = ceph_mdsmap_get_random_mds(mdsc->mdsmap);
+       dout("choose_mds chose random mds%d\n", mds);
+       return mds;
+}
+
+
+/*
+ * session messages
+ */
+static struct ceph_msg *create_session_msg(u32 op, u64 seq)
+{
+       struct ceph_msg *msg;
+       struct ceph_mds_session_head *h;
+
+       msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), 0, 0, NULL);
+       if (IS_ERR(msg)) {
+               pr_err("create_session_msg ENOMEM creating msg\n");
+               return ERR_PTR(PTR_ERR(msg));
+       }
+       h = msg->front.iov_base;
+       h->op = cpu_to_le32(op);
+       h->seq = cpu_to_le64(seq);
+       return msg;
+}
+
+/*
+ * send session open request.
+ *
+ * called under mdsc->mutex
+ */
+static int __open_session(struct ceph_mds_client *mdsc,
+                         struct ceph_mds_session *session)
+{
+       struct ceph_msg *msg;
+       int mstate;
+       int mds = session->s_mds;
+       int err = 0;
+
+       /* wait for mds to go active? */
+       mstate = ceph_mdsmap_get_state(mdsc->mdsmap, mds);
+       dout("open_session to mds%d (%s)\n", mds,
+            ceph_mds_state_name(mstate));
+       session->s_state = CEPH_MDS_SESSION_OPENING;
+       session->s_renew_requested = jiffies;
+
+       /* send connect message */
+       msg = create_session_msg(CEPH_SESSION_REQUEST_OPEN, session->s_seq);
+       if (IS_ERR(msg)) {
+               err = PTR_ERR(msg);
+               goto out;
+       }
+       ceph_con_send(&session->s_con, msg);
+
+out:
+       return 0;
+}
+
+/*
+ * session caps
+ */
+
+/*
+ * Free preallocated cap messages assigned to this session
+ */
+static void cleanup_cap_releases(struct ceph_mds_session *session)
+{
+       struct ceph_msg *msg;
+
+       spin_lock(&session->s_cap_lock);
+       while (!list_empty(&session->s_cap_releases)) {
+               msg = list_first_entry(&session->s_cap_releases,
+                                      struct ceph_msg, list_head);
+               list_del_init(&msg->list_head);
+               ceph_msg_put(msg);
+       }
+       while (!list_empty(&session->s_cap_releases_done)) {
+               msg = list_first_entry(&session->s_cap_releases_done,
+                                      struct ceph_msg, list_head);
+               list_del_init(&msg->list_head);
+               ceph_msg_put(msg);
+       }
+       spin_unlock(&session->s_cap_lock);
+}
+
+/*
+ * Helper to safely iterate over all caps associated with a session.
+ *
+ * caller must hold session s_mutex
+ */
+static int iterate_session_caps(struct ceph_mds_session *session,
+                                int (*cb)(struct inode *, struct ceph_cap *,
+                                           void *), void *arg)
+{
+       struct list_head *p;
+       struct ceph_cap *cap;
+       struct inode *inode, *last_inode = NULL;
+       struct ceph_cap *old_cap = NULL;
+       int ret;
+
+       dout("iterate_session_caps %p mds%d\n", session, session->s_mds);
+       spin_lock(&session->s_cap_lock);
+       p = session->s_caps.next;
+       while (p != &session->s_caps) {
+               cap = list_entry(p, struct ceph_cap, session_caps);
+               inode = igrab(&cap->ci->vfs_inode);
+               if (!inode) {
+                       p = p->next;
+                       continue;
+               }
+               session->s_cap_iterator = cap;
+               spin_unlock(&session->s_cap_lock);
+
+               if (last_inode) {
+                       iput(last_inode);
+                       last_inode = NULL;
+               }
+               if (old_cap) {
+                       ceph_put_cap(old_cap);
+                       old_cap = NULL;
+               }
+
+               ret = cb(inode, cap, arg);
+               last_inode = inode;
+
+               spin_lock(&session->s_cap_lock);
+               p = p->next;
+               if (cap->ci == NULL) {
+                       dout("iterate_session_caps  finishing cap %p removal\n",
+                            cap);
+                       BUG_ON(cap->session != session);
+                       list_del_init(&cap->session_caps);
+                       session->s_nr_caps--;
+                       cap->session = NULL;
+                       old_cap = cap;  /* put_cap it w/o locks held */
+               }
+               if (ret < 0)
+                       goto out;
+       }
+       ret = 0;
+out:
+       session->s_cap_iterator = NULL;
+       spin_unlock(&session->s_cap_lock);
+
+       if (last_inode)
+               iput(last_inode);
+       if (old_cap)
+               ceph_put_cap(old_cap);
+
+       return ret;
+}
+
+static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
+                                  void *arg)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       dout("removing cap %p, ci is %p, inode is %p\n",
+            cap, ci, &ci->vfs_inode);
+       ceph_remove_cap(cap);
+       return 0;
+}
+
+/*
+ * caller must hold session s_mutex
+ */
+static void remove_session_caps(struct ceph_mds_session *session)
+{
+       dout("remove_session_caps on %p\n", session);
+       iterate_session_caps(session, remove_session_caps_cb, NULL);
+       BUG_ON(session->s_nr_caps > 0);
+       cleanup_cap_releases(session);
+}
+
+/*
+ * wake up any threads waiting on this session's caps.  if the cap is
+ * old (didn't get renewed on the client reconnect), remove it now.
+ *
+ * caller must hold s_mutex.
+ */
+static int wake_up_session_cb(struct inode *inode, struct ceph_cap *cap,
+                             void *arg)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       wake_up(&ci->i_cap_wq);
+       if (arg) {
+               spin_lock(&inode->i_lock);
+               ci->i_wanted_max_size = 0;
+               ci->i_requested_max_size = 0;
+               spin_unlock(&inode->i_lock);
+       }
+       return 0;
+}
+
+static void wake_up_session_caps(struct ceph_mds_session *session,
+                                int reconnect)
+{
+       dout("wake_up_session_caps %p mds%d\n", session, session->s_mds);
+       iterate_session_caps(session, wake_up_session_cb,
+                            (void *)(unsigned long)reconnect);
+}
+
+/*
+ * Send periodic message to MDS renewing all currently held caps.  The
+ * ack will reset the expiration for all caps from this session.
+ *
+ * caller holds s_mutex
+ */
+static int send_renew_caps(struct ceph_mds_client *mdsc,
+                          struct ceph_mds_session *session)
+{
+       struct ceph_msg *msg;
+       int state;
+
+       if (time_after_eq(jiffies, session->s_cap_ttl) &&
+           time_after_eq(session->s_cap_ttl, session->s_renew_requested))
+               pr_info("mds%d caps stale\n", session->s_mds);
+       session->s_renew_requested = jiffies;
+
+       /* do not try to renew caps until a recovering mds has reconnected
+        * with its clients. */
+       state = ceph_mdsmap_get_state(mdsc->mdsmap, session->s_mds);
+       if (state < CEPH_MDS_STATE_RECONNECT) {
+               dout("send_renew_caps ignoring mds%d (%s)\n",
+                    session->s_mds, ceph_mds_state_name(state));
+               return 0;
+       }
+
+       dout("send_renew_caps to mds%d (%s)\n", session->s_mds,
+               ceph_mds_state_name(state));
+       msg = create_session_msg(CEPH_SESSION_REQUEST_RENEWCAPS,
+                                ++session->s_renew_seq);
+       if (IS_ERR(msg))
+               return PTR_ERR(msg);
+       ceph_con_send(&session->s_con, msg);
+       return 0;
+}
+
+/*
+ * Note new cap ttl, and any transition from stale -> not stale (fresh?).
+ *
+ * Called under session->s_mutex
+ */
+static void renewed_caps(struct ceph_mds_client *mdsc,
+                        struct ceph_mds_session *session, int is_renew)
+{
+       int was_stale;
+       int wake = 0;
+
+       spin_lock(&session->s_cap_lock);
+       was_stale = is_renew && (session->s_cap_ttl == 0 ||
+                                time_after_eq(jiffies, session->s_cap_ttl));
+
+       session->s_cap_ttl = session->s_renew_requested +
+               mdsc->mdsmap->m_session_timeout*HZ;
+
+       if (was_stale) {
+               if (time_before(jiffies, session->s_cap_ttl)) {
+                       pr_info("mds%d caps renewed\n", session->s_mds);
+                       wake = 1;
+               } else {
+                       pr_info("mds%d caps still stale\n", session->s_mds);
+               }
+       }
+       dout("renewed_caps mds%d ttl now %lu, was %s, now %s\n",
+            session->s_mds, session->s_cap_ttl, was_stale ? "stale" : "fresh",
+            time_before(jiffies, session->s_cap_ttl) ? "stale" : "fresh");
+       spin_unlock(&session->s_cap_lock);
+
+       if (wake)
+               wake_up_session_caps(session, 0);
+}
+
+/*
+ * send a session close request
+ */
+static int request_close_session(struct ceph_mds_client *mdsc,
+                                struct ceph_mds_session *session)
+{
+       struct ceph_msg *msg;
+       int err = 0;
+
+       dout("request_close_session mds%d state %s seq %lld\n",
+            session->s_mds, session_state_name(session->s_state),
+            session->s_seq);
+       msg = create_session_msg(CEPH_SESSION_REQUEST_CLOSE, session->s_seq);
+       if (IS_ERR(msg))
+               err = PTR_ERR(msg);
+       else
+               ceph_con_send(&session->s_con, msg);
+       return err;
+}
+
+/*
+ * Called with s_mutex held.
+ */
+static int __close_session(struct ceph_mds_client *mdsc,
+                        struct ceph_mds_session *session)
+{
+       if (session->s_state >= CEPH_MDS_SESSION_CLOSING)
+               return 0;
+       session->s_state = CEPH_MDS_SESSION_CLOSING;
+       return request_close_session(mdsc, session);
+}
+
+/*
+ * Trim old(er) caps.
+ *
+ * Because we can't cache an inode without one or more caps, we do
+ * this indirectly: if a cap is unused, we prune its aliases, at which
+ * point the inode will hopefully get dropped to.
+ *
+ * Yes, this is a bit sloppy.  Our only real goal here is to respond to
+ * memory pressure from the MDS, though, so it needn't be perfect.
+ */
+static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg)
+{
+       struct ceph_mds_session *session = arg;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int used, oissued, mine;
+
+       if (session->s_trim_caps <= 0)
+               return -1;
+
+       spin_lock(&inode->i_lock);
+       mine = cap->issued | cap->implemented;
+       used = __ceph_caps_used(ci);
+       oissued = __ceph_caps_issued_other(ci, cap);
+
+       dout("trim_caps_cb %p cap %p mine %s oissued %s used %s\n",
+            inode, cap, ceph_cap_string(mine), ceph_cap_string(oissued),
+            ceph_cap_string(used));
+       if (ci->i_dirty_caps)
+               goto out;   /* dirty caps */
+       if ((used & ~oissued) & mine)
+               goto out;   /* we need these caps */
+
+       session->s_trim_caps--;
+       if (oissued) {
+               /* we aren't the only cap.. just remove us */
+               __ceph_remove_cap(cap);
+       } else {
+               /* try to drop referring dentries */
+               spin_unlock(&inode->i_lock);
+               d_prune_aliases(inode);
+               dout("trim_caps_cb %p cap %p  pruned, count now %d\n",
+                    inode, cap, atomic_read(&inode->i_count));
+               return 0;
+       }
+
+out:
+       spin_unlock(&inode->i_lock);
+       return 0;
+}
+
+/*
+ * Trim session cap count down to some max number.
+ */
+static int trim_caps(struct ceph_mds_client *mdsc,
+                    struct ceph_mds_session *session,
+                    int max_caps)
+{
+       int trim_caps = session->s_nr_caps - max_caps;
+
+       dout("trim_caps mds%d start: %d / %d, trim %d\n",
+            session->s_mds, session->s_nr_caps, max_caps, trim_caps);
+       if (trim_caps > 0) {
+               session->s_trim_caps = trim_caps;
+               iterate_session_caps(session, trim_caps_cb, session);
+               dout("trim_caps mds%d done: %d / %d, trimmed %d\n",
+                    session->s_mds, session->s_nr_caps, max_caps,
+                       trim_caps - session->s_trim_caps);
+               session->s_trim_caps = 0;
+       }
+       return 0;
+}
+
+/*
+ * Allocate cap_release messages.  If there is a partially full message
+ * in the queue, try to allocate enough to cover it's remainder, so that
+ * we can send it immediately.
+ *
+ * Called under s_mutex.
+ */
+static int add_cap_releases(struct ceph_mds_client *mdsc,
+                           struct ceph_mds_session *session,
+                           int extra)
+{
+       struct ceph_msg *msg;
+       struct ceph_mds_cap_release *head;
+       int err = -ENOMEM;
+
+       if (extra < 0)
+               extra = mdsc->client->mount_args->cap_release_safety;
+
+       spin_lock(&session->s_cap_lock);
+
+       if (!list_empty(&session->s_cap_releases)) {
+               msg = list_first_entry(&session->s_cap_releases,
+                                      struct ceph_msg,
+                                list_head);
+               head = msg->front.iov_base;
+               extra += CEPH_CAPS_PER_RELEASE - le32_to_cpu(head->num);
+       }
+
+       while (session->s_num_cap_releases < session->s_nr_caps + extra) {
+               spin_unlock(&session->s_cap_lock);
+               msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE,
+                                  0, 0, NULL);
+               if (!msg)
+                       goto out_unlocked;
+               dout("add_cap_releases %p msg %p now %d\n", session, msg,
+                    (int)msg->front.iov_len);
+               head = msg->front.iov_base;
+               head->num = cpu_to_le32(0);
+               msg->front.iov_len = sizeof(*head);
+               spin_lock(&session->s_cap_lock);
+               list_add(&msg->list_head, &session->s_cap_releases);
+               session->s_num_cap_releases += CEPH_CAPS_PER_RELEASE;
+       }
+
+       if (!list_empty(&session->s_cap_releases)) {
+               msg = list_first_entry(&session->s_cap_releases,
+                                      struct ceph_msg,
+                                      list_head);
+               head = msg->front.iov_base;
+               if (head->num) {
+                       dout(" queueing non-full %p (%d)\n", msg,
+                            le32_to_cpu(head->num));
+                       list_move_tail(&msg->list_head,
+                                     &session->s_cap_releases_done);
+                       session->s_num_cap_releases -=
+                               CEPH_CAPS_PER_RELEASE - le32_to_cpu(head->num);
+               }
+       }
+       err = 0;
+       spin_unlock(&session->s_cap_lock);
+out_unlocked:
+       return err;
+}
+
+/*
+ * flush all dirty inode data to disk.
+ *
+ * returns true if we've flushed through want_flush_seq
+ */
+static int check_cap_flush(struct ceph_mds_client *mdsc, u64 want_flush_seq)
+{
+       int mds, ret = 1;
+
+       dout("check_cap_flush want %lld\n", want_flush_seq);
+       mutex_lock(&mdsc->mutex);
+       for (mds = 0; ret && mds < mdsc->max_sessions; mds++) {
+               struct ceph_mds_session *session = mdsc->sessions[mds];
+
+               if (!session)
+                       continue;
+               get_session(session);
+               mutex_unlock(&mdsc->mutex);
+
+               mutex_lock(&session->s_mutex);
+               if (!list_empty(&session->s_cap_flushing)) {
+                       struct ceph_inode_info *ci =
+                               list_entry(session->s_cap_flushing.next,
+                                          struct ceph_inode_info,
+                                          i_flushing_item);
+                       struct inode *inode = &ci->vfs_inode;
+
+                       spin_lock(&inode->i_lock);
+                       if (ci->i_cap_flush_seq <= want_flush_seq) {
+                               dout("check_cap_flush still flushing %p "
+                                    "seq %lld <= %lld to mds%d\n", inode,
+                                    ci->i_cap_flush_seq, want_flush_seq,
+                                    session->s_mds);
+                               ret = 0;
+                       }
+                       spin_unlock(&inode->i_lock);
+               }
+               mutex_unlock(&session->s_mutex);
+               ceph_put_mds_session(session);
+
+               if (!ret)
+                       return ret;
+               mutex_lock(&mdsc->mutex);
+       }
+
+       mutex_unlock(&mdsc->mutex);
+       dout("check_cap_flush ok, flushed thru %lld\n", want_flush_seq);
+       return ret;
+}
+
+/*
+ * called under s_mutex
+ */
+static void send_cap_releases(struct ceph_mds_client *mdsc,
+                      struct ceph_mds_session *session)
+{
+       struct ceph_msg *msg;
+
+       dout("send_cap_releases mds%d\n", session->s_mds);
+       while (1) {
+               spin_lock(&session->s_cap_lock);
+               if (list_empty(&session->s_cap_releases_done))
+                       break;
+               msg = list_first_entry(&session->s_cap_releases_done,
+                                struct ceph_msg, list_head);
+               list_del_init(&msg->list_head);
+               spin_unlock(&session->s_cap_lock);
+               msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
+               dout("send_cap_releases mds%d %p\n", session->s_mds, msg);
+               ceph_con_send(&session->s_con, msg);
+       }
+       spin_unlock(&session->s_cap_lock);
+}
+
+/*
+ * requests
+ */
+
+/*
+ * Create an mds request.
+ */
+struct ceph_mds_request *
+ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode)
+{
+       struct ceph_mds_request *req = kzalloc(sizeof(*req), GFP_NOFS);
+
+       if (!req)
+               return ERR_PTR(-ENOMEM);
+
+       req->r_started = jiffies;
+       req->r_resend_mds = -1;
+       INIT_LIST_HEAD(&req->r_unsafe_dir_item);
+       req->r_fmode = -1;
+       kref_init(&req->r_kref);
+       INIT_LIST_HEAD(&req->r_wait);
+       init_completion(&req->r_completion);
+       init_completion(&req->r_safe_completion);
+       INIT_LIST_HEAD(&req->r_unsafe_item);
+
+       req->r_op = op;
+       req->r_direct_mode = mode;
+       return req;
+}
+
+/*
+ * return oldest (lowest) request, tid in request tree, 0 if none.
+ *
+ * called under mdsc->mutex.
+ */
+static struct ceph_mds_request *__get_oldest_req(struct ceph_mds_client *mdsc)
+{
+       if (RB_EMPTY_ROOT(&mdsc->request_tree))
+               return NULL;
+       return rb_entry(rb_first(&mdsc->request_tree),
+                       struct ceph_mds_request, r_node);
+}
+
+static u64 __get_oldest_tid(struct ceph_mds_client *mdsc)
+{
+       struct ceph_mds_request *req = __get_oldest_req(mdsc);
+
+       if (req)
+               return req->r_tid;
+       return 0;
+}
+
+/*
+ * Build a dentry's path.  Allocate on heap; caller must kfree.  Based
+ * on build_path_from_dentry in fs/cifs/dir.c.
+ *
+ * If @stop_on_nosnap, generate path relative to the first non-snapped
+ * inode.
+ *
+ * Encode hidden .snap dirs as a double /, i.e.
+ *   foo/.snap/bar -> foo//bar
+ */
+char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
+                          int stop_on_nosnap)
+{
+       struct dentry *temp;
+       char *path;
+       int len, pos;
+
+       if (dentry == NULL)
+               return ERR_PTR(-EINVAL);
+
+retry:
+       len = 0;
+       for (temp = dentry; !IS_ROOT(temp);) {
+               struct inode *inode = temp->d_inode;
+               if (inode && ceph_snap(inode) == CEPH_SNAPDIR)
+                       len++;  /* slash only */
+               else if (stop_on_nosnap && inode &&
+                        ceph_snap(inode) == CEPH_NOSNAP)
+                       break;
+               else
+                       len += 1 + temp->d_name.len;
+               temp = temp->d_parent;
+               if (temp == NULL) {
+                       pr_err("build_path_dentry corrupt dentry %p\n", dentry);
+                       return ERR_PTR(-EINVAL);
+               }
+       }
+       if (len)
+               len--;  /* no leading '/' */
+
+       path = kmalloc(len+1, GFP_NOFS);
+       if (path == NULL)
+               return ERR_PTR(-ENOMEM);
+       pos = len;
+       path[pos] = 0;  /* trailing null */
+       for (temp = dentry; !IS_ROOT(temp) && pos != 0; ) {
+               struct inode *inode = temp->d_inode;
+
+               if (inode && ceph_snap(inode) == CEPH_SNAPDIR) {
+                       dout("build_path_dentry path+%d: %p SNAPDIR\n",
+                            pos, temp);
+               } else if (stop_on_nosnap && inode &&
+                          ceph_snap(inode) == CEPH_NOSNAP) {
+                       break;
+               } else {
+                       pos -= temp->d_name.len;
+                       if (pos < 0)
+                               break;
+                       strncpy(path + pos, temp->d_name.name,
+                               temp->d_name.len);
+                       dout("build_path_dentry path+%d: %p '%.*s'\n",
+                            pos, temp, temp->d_name.len, path + pos);
+               }
+               if (pos)
+                       path[--pos] = '/';
+               temp = temp->d_parent;
+               if (temp == NULL) {
+                       pr_err("build_path_dentry corrupt dentry\n");
+                       kfree(path);
+                       return ERR_PTR(-EINVAL);
+               }
+       }
+       if (pos != 0) {
+               pr_err("build_path_dentry did not end path lookup where "
+                      "expected, namelen is %d, pos is %d\n", len, pos);
+               /* presumably this is only possible if racing with a
+                  rename of one of the parent directories (we can not
+                  lock the dentries above us to prevent this, but
+                  retrying should be harmless) */
+               kfree(path);
+               goto retry;
+       }
+
+       *base = ceph_ino(temp->d_inode);
+       *plen = len;
+       dout("build_path_dentry on %p %d built %llx '%.*s'\n",
+            dentry, atomic_read(&dentry->d_count), *base, len, path);
+       return path;
+}
+
+static int build_dentry_path(struct dentry *dentry,
+                            const char **ppath, int *ppathlen, u64 *pino,
+                            int *pfreepath)
+{
+       char *path;
+
+       if (ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP) {
+               *pino = ceph_ino(dentry->d_parent->d_inode);
+               *ppath = dentry->d_name.name;
+               *ppathlen = dentry->d_name.len;
+               return 0;
+       }
+       path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
+       if (IS_ERR(path))
+               return PTR_ERR(path);
+       *ppath = path;
+       *pfreepath = 1;
+       return 0;
+}
+
+static int build_inode_path(struct inode *inode,
+                           const char **ppath, int *ppathlen, u64 *pino,
+                           int *pfreepath)
+{
+       struct dentry *dentry;
+       char *path;
+
+       if (ceph_snap(inode) == CEPH_NOSNAP) {
+               *pino = ceph_ino(inode);
+               *ppathlen = 0;
+               return 0;
+       }
+       dentry = d_find_alias(inode);
+       path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
+       dput(dentry);
+       if (IS_ERR(path))
+               return PTR_ERR(path);
+       *ppath = path;
+       *pfreepath = 1;
+       return 0;
+}
+
+/*
+ * request arguments may be specified via an inode *, a dentry *, or
+ * an explicit ino+path.
+ */
+static int set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
+                                 const char *rpath, u64 rino,
+                                 const char **ppath, int *pathlen,
+                                 u64 *ino, int *freepath)
+{
+       int r = 0;
+
+       if (rinode) {
+               r = build_inode_path(rinode, ppath, pathlen, ino, freepath);
+               dout(" inode %p %llx.%llx\n", rinode, ceph_ino(rinode),
+                    ceph_snap(rinode));
+       } else if (rdentry) {
+               r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath);
+               dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen,
+                    *ppath);
+       } else if (rpath) {
+               *ino = rino;
+               *ppath = rpath;
+               *pathlen = strlen(rpath);
+               dout(" path %.*s\n", *pathlen, rpath);
+       }
+
+       return r;
+}
+
+/*
+ * called under mdsc->mutex
+ */
+static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
+                                              struct ceph_mds_request *req,
+                                              int mds)
+{
+       struct ceph_msg *msg;
+       struct ceph_mds_request_head *head;
+       const char *path1 = NULL;
+       const char *path2 = NULL;
+       u64 ino1 = 0, ino2 = 0;
+       int pathlen1 = 0, pathlen2 = 0;
+       int freepath1 = 0, freepath2 = 0;
+       int len;
+       u16 releases;
+       void *p, *end;
+       int ret;
+
+       ret = set_request_path_attr(req->r_inode, req->r_dentry,
+                             req->r_path1, req->r_ino1.ino,
+                             &path1, &pathlen1, &ino1, &freepath1);
+       if (ret < 0) {
+               msg = ERR_PTR(ret);
+               goto out;
+       }
+
+       ret = set_request_path_attr(NULL, req->r_old_dentry,
+                             req->r_path2, req->r_ino2.ino,
+                             &path2, &pathlen2, &ino2, &freepath2);
+       if (ret < 0) {
+               msg = ERR_PTR(ret);
+               goto out_free1;
+       }
+
+       len = sizeof(*head) +
+               pathlen1 + pathlen2 + 2*(1 + sizeof(u32) + sizeof(u64));
+
+       /* calculate (max) length for cap releases */
+       len += sizeof(struct ceph_mds_request_release) *
+               (!!req->r_inode_drop + !!req->r_dentry_drop +
+                !!req->r_old_inode_drop + !!req->r_old_dentry_drop);
+       if (req->r_dentry_drop)
+               len += req->r_dentry->d_name.len;
+       if (req->r_old_dentry_drop)
+               len += req->r_old_dentry->d_name.len;
+
+       msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, 0, 0, NULL);
+       if (IS_ERR(msg))
+               goto out_free2;
+
+       msg->hdr.tid = cpu_to_le64(req->r_tid);
+
+       head = msg->front.iov_base;
+       p = msg->front.iov_base + sizeof(*head);
+       end = msg->front.iov_base + msg->front.iov_len;
+
+       head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch);
+       head->op = cpu_to_le32(req->r_op);
+       head->caller_uid = cpu_to_le32(current_fsuid());
+       head->caller_gid = cpu_to_le32(current_fsgid());
+       head->args = req->r_args;
+
+       ceph_encode_filepath(&p, end, ino1, path1);
+       ceph_encode_filepath(&p, end, ino2, path2);
+
+       /* cap releases */
+       releases = 0;
+       if (req->r_inode_drop)
+               releases += ceph_encode_inode_release(&p,
+                     req->r_inode ? req->r_inode : req->r_dentry->d_inode,
+                     mds, req->r_inode_drop, req->r_inode_unless, 0);
+       if (req->r_dentry_drop)
+               releases += ceph_encode_dentry_release(&p, req->r_dentry,
+                      mds, req->r_dentry_drop, req->r_dentry_unless);
+       if (req->r_old_dentry_drop)
+               releases += ceph_encode_dentry_release(&p, req->r_old_dentry,
+                      mds, req->r_old_dentry_drop, req->r_old_dentry_unless);
+       if (req->r_old_inode_drop)
+               releases += ceph_encode_inode_release(&p,
+                     req->r_old_dentry->d_inode,
+                     mds, req->r_old_inode_drop, req->r_old_inode_unless, 0);
+       head->num_releases = cpu_to_le16(releases);
+
+       BUG_ON(p > end);
+       msg->front.iov_len = p - msg->front.iov_base;
+       msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
+
+       msg->pages = req->r_pages;
+       msg->nr_pages = req->r_num_pages;
+       msg->hdr.data_len = cpu_to_le32(req->r_data_len);
+       msg->hdr.data_off = cpu_to_le16(0);
+
+out_free2:
+       if (freepath2)
+               kfree((char *)path2);
+out_free1:
+       if (freepath1)
+               kfree((char *)path1);
+out:
+       return msg;
+}
+
+/*
+ * called under mdsc->mutex if error, under no mutex if
+ * success.
+ */
+static void complete_request(struct ceph_mds_client *mdsc,
+                            struct ceph_mds_request *req)
+{
+       if (req->r_callback)
+               req->r_callback(mdsc, req);
+       else
+               complete(&req->r_completion);
+}
+
+/*
+ * called under mdsc->mutex
+ */
+static int __prepare_send_request(struct ceph_mds_client *mdsc,
+                                 struct ceph_mds_request *req,
+                                 int mds)
+{
+       struct ceph_mds_request_head *rhead;
+       struct ceph_msg *msg;
+       int flags = 0;
+
+       req->r_mds = mds;
+       req->r_attempts++;
+       dout("prepare_send_request %p tid %lld %s (attempt %d)\n", req,
+            req->r_tid, ceph_mds_op_name(req->r_op), req->r_attempts);
+
+       if (req->r_request) {
+               ceph_msg_put(req->r_request);
+               req->r_request = NULL;
+       }
+       msg = create_request_message(mdsc, req, mds);
+       if (IS_ERR(msg)) {
+               req->r_reply = ERR_PTR(PTR_ERR(msg));
+               complete_request(mdsc, req);
+               return -PTR_ERR(msg);
+       }
+       req->r_request = msg;
+
+       rhead = msg->front.iov_base;
+       rhead->oldest_client_tid = cpu_to_le64(__get_oldest_tid(mdsc));
+       if (req->r_got_unsafe)
+               flags |= CEPH_MDS_FLAG_REPLAY;
+       if (req->r_locked_dir)
+               flags |= CEPH_MDS_FLAG_WANT_DENTRY;
+       rhead->flags = cpu_to_le32(flags);
+       rhead->num_fwd = req->r_num_fwd;
+       rhead->num_retry = req->r_attempts - 1;
+
+       dout(" r_locked_dir = %p\n", req->r_locked_dir);
+
+       if (req->r_target_inode && req->r_got_unsafe)
+               rhead->ino = cpu_to_le64(ceph_ino(req->r_target_inode));
+       else
+               rhead->ino = 0;
+       return 0;
+}
+
+/*
+ * send request, or put it on the appropriate wait list.
+ */
+static int __do_request(struct ceph_mds_client *mdsc,
+                       struct ceph_mds_request *req)
+{
+       struct ceph_mds_session *session = NULL;
+       int mds = -1;
+       int err = -EAGAIN;
+
+       if (req->r_reply)
+               goto out;
+
+       if (req->r_timeout &&
+           time_after_eq(jiffies, req->r_started + req->r_timeout)) {
+               dout("do_request timed out\n");
+               err = -EIO;
+               goto finish;
+       }
+
+       mds = __choose_mds(mdsc, req);
+       if (mds < 0 ||
+           ceph_mdsmap_get_state(mdsc->mdsmap, mds) < CEPH_MDS_STATE_ACTIVE) {
+               dout("do_request no mds or not active, waiting for map\n");
+               list_add(&req->r_wait, &mdsc->waiting_for_map);
+               goto out;
+       }
+
+       /* get, open session */
+       session = __ceph_lookup_mds_session(mdsc, mds);
+       if (!session) {
+               session = register_session(mdsc, mds);
+               if (IS_ERR(session)) {
+                       err = PTR_ERR(session);
+                       goto finish;
+               }
+       }
+       dout("do_request mds%d session %p state %s\n", mds, session,
+            session_state_name(session->s_state));
+       if (session->s_state != CEPH_MDS_SESSION_OPEN &&
+           session->s_state != CEPH_MDS_SESSION_HUNG) {
+               if (session->s_state == CEPH_MDS_SESSION_NEW ||
+                   session->s_state == CEPH_MDS_SESSION_CLOSING)
+                       __open_session(mdsc, session);
+               list_add(&req->r_wait, &session->s_waiting);
+               goto out_session;
+       }
+
+       /* send request */
+       req->r_session = get_session(session);
+       req->r_resend_mds = -1;   /* forget any previous mds hint */
+
+       if (req->r_request_started == 0)   /* note request start time */
+               req->r_request_started = jiffies;
+
+       err = __prepare_send_request(mdsc, req, mds);
+       if (!err) {
+               ceph_msg_get(req->r_request);
+               ceph_con_send(&session->s_con, req->r_request);
+       }
+
+out_session:
+       ceph_put_mds_session(session);
+out:
+       return err;
+
+finish:
+       req->r_reply = ERR_PTR(err);
+       complete_request(mdsc, req);
+       goto out;
+}
+
+/*
+ * called under mdsc->mutex
+ */
+static void __wake_requests(struct ceph_mds_client *mdsc,
+                           struct list_head *head)
+{
+       struct ceph_mds_request *req, *nreq;
+
+       list_for_each_entry_safe(req, nreq, head, r_wait) {
+               list_del_init(&req->r_wait);
+               __do_request(mdsc, req);
+       }
+}
+
+/*
+ * Wake up threads with requests pending for @mds, so that they can
+ * resubmit their requests to a possibly different mds.  If @all is set,
+ * wake up if their requests has been forwarded to @mds, too.
+ */
+static void kick_requests(struct ceph_mds_client *mdsc, int mds, int all)
+{
+       struct ceph_mds_request *req;
+       struct rb_node *p;
+
+       dout("kick_requests mds%d\n", mds);
+       for (p = rb_first(&mdsc->request_tree); p; p = rb_next(p)) {
+               req = rb_entry(p, struct ceph_mds_request, r_node);
+               if (req->r_got_unsafe)
+                       continue;
+               if (req->r_session &&
+                   req->r_session->s_mds == mds) {
+                       dout(" kicking tid %llu\n", req->r_tid);
+                       put_request_session(req);
+                       __do_request(mdsc, req);
+               }
+       }
+}
+
+void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
+                             struct ceph_mds_request *req)
+{
+       dout("submit_request on %p\n", req);
+       mutex_lock(&mdsc->mutex);
+       __register_request(mdsc, req, NULL);
+       __do_request(mdsc, req);
+       mutex_unlock(&mdsc->mutex);
+}
+
+/*
+ * Synchrously perform an mds request.  Take care of all of the
+ * session setup, forwarding, retry details.
+ */
+int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
+                        struct inode *dir,
+                        struct ceph_mds_request *req)
+{
+       int err;
+
+       dout("do_request on %p\n", req);
+
+       /* take CAP_PIN refs for r_inode, r_locked_dir, r_old_dentry */
+       if (req->r_inode)
+               ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN);
+       if (req->r_locked_dir)
+               ceph_get_cap_refs(ceph_inode(req->r_locked_dir), CEPH_CAP_PIN);
+       if (req->r_old_dentry)
+               ceph_get_cap_refs(
+                       ceph_inode(req->r_old_dentry->d_parent->d_inode),
+                       CEPH_CAP_PIN);
+
+       /* issue */
+       mutex_lock(&mdsc->mutex);
+       __register_request(mdsc, req, dir);
+       __do_request(mdsc, req);
+
+       /* wait */
+       if (!req->r_reply) {
+               mutex_unlock(&mdsc->mutex);
+               if (req->r_timeout) {
+                       err = (long)wait_for_completion_interruptible_timeout(
+                               &req->r_completion, req->r_timeout);
+                       if (err == 0)
+                               req->r_reply = ERR_PTR(-EIO);
+                       else if (err < 0)
+                               req->r_reply = ERR_PTR(err);
+               } else {
+                        err = wait_for_completion_interruptible(
+                                &req->r_completion);
+                        if (err)
+                                req->r_reply = ERR_PTR(err);
+               }
+               mutex_lock(&mdsc->mutex);
+       }
+
+       if (IS_ERR(req->r_reply)) {
+               err = PTR_ERR(req->r_reply);
+               req->r_reply = NULL;
+
+               if (err == -ERESTARTSYS) {
+                       /* aborted */
+                       req->r_aborted = true;
+
+                       if (req->r_locked_dir &&
+                           (req->r_op & CEPH_MDS_OP_WRITE)) {
+                               struct ceph_inode_info *ci =
+                                       ceph_inode(req->r_locked_dir);
+
+                               dout("aborted, clearing I_COMPLETE on %p\n", 
+                                    req->r_locked_dir);
+                               spin_lock(&req->r_locked_dir->i_lock);
+                               ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+                               ci->i_release_count++;
+                               spin_unlock(&req->r_locked_dir->i_lock);
+                       }
+               } else {
+                       /* clean up this request */
+                       __unregister_request(mdsc, req);
+                       if (!list_empty(&req->r_unsafe_item))
+                               list_del_init(&req->r_unsafe_item);
+                       complete(&req->r_safe_completion);
+               }
+       } else if (req->r_err) {
+               err = req->r_err;
+       } else {
+               err = le32_to_cpu(req->r_reply_info.head->result);
+       }
+       mutex_unlock(&mdsc->mutex);
+
+       dout("do_request %p done, result %d\n", req, err);
+       return err;
+}
+
+/*
+ * Handle mds reply.
+ *
+ * We take the session mutex and parse and process the reply immediately.
+ * This preserves the logical ordering of replies, capabilities, etc., sent
+ * by the MDS as they are applied to our local cache.
+ */
+static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
+{
+       struct ceph_mds_client *mdsc = session->s_mdsc;
+       struct ceph_mds_request *req;
+       struct ceph_mds_reply_head *head = msg->front.iov_base;
+       struct ceph_mds_reply_info_parsed *rinfo;  /* parsed reply info */
+       u64 tid;
+       int err, result;
+       int mds = session->s_mds;
+
+       if (msg->front.iov_len < sizeof(*head)) {
+               pr_err("mdsc_handle_reply got corrupt (short) reply\n");
+               ceph_msg_dump(msg);
+               return;
+       }
+
+       /* get request, session */
+       tid = le64_to_cpu(msg->hdr.tid);
+       mutex_lock(&mdsc->mutex);
+       req = __lookup_request(mdsc, tid);
+       if (!req) {
+               dout("handle_reply on unknown tid %llu\n", tid);
+               mutex_unlock(&mdsc->mutex);
+               return;
+       }
+       dout("handle_reply %p\n", req);
+
+       /* correct session? */
+       if (req->r_session != session) {
+               pr_err("mdsc_handle_reply got %llu on session mds%d"
+                      " not mds%d\n", tid, session->s_mds,
+                      req->r_session ? req->r_session->s_mds : -1);
+               mutex_unlock(&mdsc->mutex);
+               goto out;
+       }
+
+       /* dup? */
+       if ((req->r_got_unsafe && !head->safe) ||
+           (req->r_got_safe && head->safe)) {
+               pr_warning("got a dup %s reply on %llu from mds%d\n",
+                          head->safe ? "safe" : "unsafe", tid, mds);
+               mutex_unlock(&mdsc->mutex);
+               goto out;
+       }
+
+       result = le32_to_cpu(head->result);
+
+       /*
+        * Tolerate 2 consecutive ESTALEs from the same mds.
+        * FIXME: we should be looking at the cap migrate_seq.
+        */
+       if (result == -ESTALE) {
+               req->r_direct_mode = USE_AUTH_MDS;
+               req->r_num_stale++;
+               if (req->r_num_stale <= 2) {
+                       __do_request(mdsc, req);
+                       mutex_unlock(&mdsc->mutex);
+                       goto out;
+               }
+       } else {
+               req->r_num_stale = 0;
+       }
+
+       if (head->safe) {
+               req->r_got_safe = true;
+               __unregister_request(mdsc, req);
+               complete(&req->r_safe_completion);
+
+               if (req->r_got_unsafe) {
+                       /*
+                        * We already handled the unsafe response, now do the
+                        * cleanup.  No need to examine the response; the MDS
+                        * doesn't include any result info in the safe
+                        * response.  And even if it did, there is nothing
+                        * useful we could do with a revised return value.
+                        */
+                       dout("got safe reply %llu, mds%d\n", tid, mds);
+                       list_del_init(&req->r_unsafe_item);
+
+                       /* last unsafe request during umount? */
+                       if (mdsc->stopping && !__get_oldest_req(mdsc))
+                               complete(&mdsc->safe_umount_waiters);
+                       mutex_unlock(&mdsc->mutex);
+                       goto out;
+               }
+       }
+
+       BUG_ON(req->r_reply);
+
+       if (!head->safe) {
+               req->r_got_unsafe = true;
+               list_add_tail(&req->r_unsafe_item, &req->r_session->s_unsafe);
+       }
+
+       dout("handle_reply tid %lld result %d\n", tid, result);
+       rinfo = &req->r_reply_info;
+       err = parse_reply_info(msg, rinfo);
+       mutex_unlock(&mdsc->mutex);
+
+       mutex_lock(&session->s_mutex);
+       if (err < 0) {
+               pr_err("mdsc_handle_reply got corrupt reply mds%d\n", mds);
+               ceph_msg_dump(msg);
+               goto out_err;
+       }
+
+       /* snap trace */
+       if (rinfo->snapblob_len) {
+               down_write(&mdsc->snap_rwsem);
+               ceph_update_snap_trace(mdsc, rinfo->snapblob,
+                              rinfo->snapblob + rinfo->snapblob_len,
+                              le32_to_cpu(head->op) == CEPH_MDS_OP_RMSNAP);
+               downgrade_write(&mdsc->snap_rwsem);
+       } else {
+               down_read(&mdsc->snap_rwsem);
+       }
+
+       /* insert trace into our cache */
+       err = ceph_fill_trace(mdsc->client->sb, req, req->r_session);
+       if (err == 0) {
+               if (result == 0 && rinfo->dir_nr)
+                       ceph_readdir_prepopulate(req, req->r_session);
+               ceph_unreserve_caps(&req->r_caps_reservation);
+       }
+
+       up_read(&mdsc->snap_rwsem);
+out_err:
+       if (err) {
+               req->r_err = err;
+       } else {
+               req->r_reply = msg;
+               ceph_msg_get(msg);
+       }
+
+       add_cap_releases(mdsc, req->r_session, -1);
+       mutex_unlock(&session->s_mutex);
+
+       /* kick calling process */
+       complete_request(mdsc, req);
+out:
+       ceph_mdsc_put_request(req);
+       return;
+}
+
+
+
+/*
+ * handle mds notification that our request has been forwarded.
+ */
+static void handle_forward(struct ceph_mds_client *mdsc,
+                          struct ceph_mds_session *session,
+                          struct ceph_msg *msg)
+{
+       struct ceph_mds_request *req;
+       u64 tid = le64_to_cpu(msg->hdr.tid);
+       u32 next_mds;
+       u32 fwd_seq;
+       int err = -EINVAL;
+       void *p = msg->front.iov_base;
+       void *end = p + msg->front.iov_len;
+
+       ceph_decode_need(&p, end, 2*sizeof(u32), bad);
+       next_mds = ceph_decode_32(&p);
+       fwd_seq = ceph_decode_32(&p);
+
+       mutex_lock(&mdsc->mutex);
+       req = __lookup_request(mdsc, tid);
+       if (!req) {
+               dout("forward %llu to mds%d - req dne\n", tid, next_mds);
+               goto out;  /* dup reply? */
+       }
+
+       if (fwd_seq <= req->r_num_fwd) {
+               dout("forward %llu to mds%d - old seq %d <= %d\n",
+                    tid, next_mds, req->r_num_fwd, fwd_seq);
+       } else {
+               /* resend. forward race not possible; mds would drop */
+               dout("forward %llu to mds%d (we resend)\n", tid, next_mds);
+               req->r_num_fwd = fwd_seq;
+               req->r_resend_mds = next_mds;
+               put_request_session(req);
+               __do_request(mdsc, req);
+       }
+       ceph_mdsc_put_request(req);
+out:
+       mutex_unlock(&mdsc->mutex);
+       return;
+
+bad:
+       pr_err("mdsc_handle_forward decode error err=%d\n", err);
+}
+
+/*
+ * handle a mds session control message
+ */
+static void handle_session(struct ceph_mds_session *session,
+                          struct ceph_msg *msg)
+{
+       struct ceph_mds_client *mdsc = session->s_mdsc;
+       u32 op;
+       u64 seq;
+       int mds = session->s_mds;
+       struct ceph_mds_session_head *h = msg->front.iov_base;
+       int wake = 0;
+
+       /* decode */
+       if (msg->front.iov_len != sizeof(*h))
+               goto bad;
+       op = le32_to_cpu(h->op);
+       seq = le64_to_cpu(h->seq);
+
+       mutex_lock(&mdsc->mutex);
+       if (op == CEPH_SESSION_CLOSE)
+               __unregister_session(mdsc, session);
+       /* FIXME: this ttl calculation is generous */
+       session->s_ttl = jiffies + HZ*mdsc->mdsmap->m_session_autoclose;
+       mutex_unlock(&mdsc->mutex);
+
+       mutex_lock(&session->s_mutex);
+
+       dout("handle_session mds%d %s %p state %s seq %llu\n",
+            mds, ceph_session_op_name(op), session,
+            session_state_name(session->s_state), seq);
+
+       if (session->s_state == CEPH_MDS_SESSION_HUNG) {
+               session->s_state = CEPH_MDS_SESSION_OPEN;
+               pr_info("mds%d came back\n", session->s_mds);
+       }
+
+       switch (op) {
+       case CEPH_SESSION_OPEN:
+               session->s_state = CEPH_MDS_SESSION_OPEN;
+               renewed_caps(mdsc, session, 0);
+               wake = 1;
+               if (mdsc->stopping)
+                       __close_session(mdsc, session);
+               break;
+
+       case CEPH_SESSION_RENEWCAPS:
+               if (session->s_renew_seq == seq)
+                       renewed_caps(mdsc, session, 1);
+               break;
+
+       case CEPH_SESSION_CLOSE:
+               remove_session_caps(session);
+               wake = 1; /* for good measure */
+               complete(&mdsc->session_close_waiters);
+               kick_requests(mdsc, mds, 0);      /* cur only */
+               break;
+
+       case CEPH_SESSION_STALE:
+               pr_info("mds%d caps went stale, renewing\n",
+                       session->s_mds);
+               spin_lock(&session->s_cap_lock);
+               session->s_cap_gen++;
+               session->s_cap_ttl = 0;
+               spin_unlock(&session->s_cap_lock);
+               send_renew_caps(mdsc, session);
+               break;
+
+       case CEPH_SESSION_RECALL_STATE:
+               trim_caps(mdsc, session, le32_to_cpu(h->max_caps));
+               break;
+
+       default:
+               pr_err("mdsc_handle_session bad op %d mds%d\n", op, mds);
+               WARN_ON(1);
+       }
+
+       mutex_unlock(&session->s_mutex);
+       if (wake) {
+               mutex_lock(&mdsc->mutex);
+               __wake_requests(mdsc, &session->s_waiting);
+               mutex_unlock(&mdsc->mutex);
+       }
+       return;
+
+bad:
+       pr_err("mdsc_handle_session corrupt message mds%d len %d\n", mds,
+              (int)msg->front.iov_len);
+       ceph_msg_dump(msg);
+       return;
+}
+
+
+/*
+ * called under session->mutex.
+ */
+static void replay_unsafe_requests(struct ceph_mds_client *mdsc,
+                                  struct ceph_mds_session *session)
+{
+       struct ceph_mds_request *req, *nreq;
+       int err;
+
+       dout("replay_unsafe_requests mds%d\n", session->s_mds);
+
+       mutex_lock(&mdsc->mutex);
+       list_for_each_entry_safe(req, nreq, &session->s_unsafe, r_unsafe_item) {
+               err = __prepare_send_request(mdsc, req, session->s_mds);
+               if (!err) {
+                       ceph_msg_get(req->r_request);
+                       ceph_con_send(&session->s_con, req->r_request);
+               }
+       }
+       mutex_unlock(&mdsc->mutex);
+}
+
+/*
+ * Encode information about a cap for a reconnect with the MDS.
+ */
+static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
+                         void *arg)
+{
+       struct ceph_mds_cap_reconnect rec;
+       struct ceph_inode_info *ci;
+       struct ceph_pagelist *pagelist = arg;
+       char *path;
+       int pathlen, err;
+       u64 pathbase;
+       struct dentry *dentry;
+
+       ci = cap->ci;
+
+       dout(" adding %p ino %llx.%llx cap %p %lld %s\n",
+            inode, ceph_vinop(inode), cap, cap->cap_id,
+            ceph_cap_string(cap->issued));
+       err = ceph_pagelist_encode_64(pagelist, ceph_ino(inode));
+       if (err)
+               return err;
+
+       dentry = d_find_alias(inode);
+       if (dentry) {
+               path = ceph_mdsc_build_path(dentry, &pathlen, &pathbase, 0);
+               if (IS_ERR(path)) {
+                       err = PTR_ERR(path);
+                       BUG_ON(err);
+               }
+       } else {
+               path = NULL;
+               pathlen = 0;
+       }
+       err = ceph_pagelist_encode_string(pagelist, path, pathlen);
+       if (err)
+               goto out;
+
+       spin_lock(&inode->i_lock);
+       cap->seq = 0;        /* reset cap seq */
+       cap->issue_seq = 0;  /* and issue_seq */
+       rec.cap_id = cpu_to_le64(cap->cap_id);
+       rec.pathbase = cpu_to_le64(pathbase);
+       rec.wanted = cpu_to_le32(__ceph_caps_wanted(ci));
+       rec.issued = cpu_to_le32(cap->issued);
+       rec.size = cpu_to_le64(inode->i_size);
+       ceph_encode_timespec(&rec.mtime, &inode->i_mtime);
+       ceph_encode_timespec(&rec.atime, &inode->i_atime);
+       rec.snaprealm = cpu_to_le64(ci->i_snap_realm->ino);
+       spin_unlock(&inode->i_lock);
+
+       err = ceph_pagelist_append(pagelist, &rec, sizeof(rec));
+
+out:
+       kfree(path);
+       dput(dentry);
+       return err;
+}
+
+
+/*
+ * If an MDS fails and recovers, clients need to reconnect in order to
+ * reestablish shared state.  This includes all caps issued through
+ * this session _and_ the snap_realm hierarchy.  Because it's not
+ * clear which snap realms the mds cares about, we send everything we
+ * know about.. that ensures we'll then get any new info the
+ * recovering MDS might have.
+ *
+ * This is a relatively heavyweight operation, but it's rare.
+ *
+ * called with mdsc->mutex held.
+ */
+static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds)
+{
+       struct ceph_mds_session *session = NULL;
+       struct ceph_msg *reply;
+       struct rb_node *p;
+       int err;
+       struct ceph_pagelist *pagelist;
+
+       pr_info("reconnect to recovering mds%d\n", mds);
+
+       pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS);
+       if (!pagelist)
+               goto fail_nopagelist;
+       ceph_pagelist_init(pagelist);
+
+       reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, 0, 0, NULL);
+       if (IS_ERR(reply)) {
+               err = PTR_ERR(reply);
+               goto fail_nomsg;
+       }
+
+       /* find session */
+       session = __ceph_lookup_mds_session(mdsc, mds);
+       mutex_unlock(&mdsc->mutex);    /* drop lock for duration */
+
+       if (session) {
+               mutex_lock(&session->s_mutex);
+
+               session->s_state = CEPH_MDS_SESSION_RECONNECTING;
+               session->s_seq = 0;
+
+               ceph_con_open(&session->s_con,
+                             ceph_mdsmap_get_addr(mdsc->mdsmap, mds));
+
+               /* replay unsafe requests */
+               replay_unsafe_requests(mdsc, session);
+       } else {
+               dout("no session for mds%d, will send short reconnect\n",
+                    mds);
+       }
+
+       down_read(&mdsc->snap_rwsem);
+
+       if (!session)
+               goto send;
+       dout("session %p state %s\n", session,
+            session_state_name(session->s_state));
+
+       /* traverse this session's caps */
+       err = ceph_pagelist_encode_32(pagelist, session->s_nr_caps);
+       if (err)
+               goto fail;
+       err = iterate_session_caps(session, encode_caps_cb, pagelist);
+       if (err < 0)
+               goto out;
+
+       /*
+        * snaprealms.  we provide mds with the ino, seq (version), and
+        * parent for all of our realms.  If the mds has any newer info,
+        * it will tell us.
+        */
+       for (p = rb_first(&mdsc->snap_realms); p; p = rb_next(p)) {
+               struct ceph_snap_realm *realm =
+                       rb_entry(p, struct ceph_snap_realm, node);
+               struct ceph_mds_snaprealm_reconnect sr_rec;
+
+               dout(" adding snap realm %llx seq %lld parent %llx\n",
+                    realm->ino, realm->seq, realm->parent_ino);
+               sr_rec.ino = cpu_to_le64(realm->ino);
+               sr_rec.seq = cpu_to_le64(realm->seq);
+               sr_rec.parent = cpu_to_le64(realm->parent_ino);
+               err = ceph_pagelist_append(pagelist, &sr_rec, sizeof(sr_rec));
+               if (err)
+                       goto fail;
+       }
+
+send:
+       reply->pagelist = pagelist;
+       reply->hdr.data_len = cpu_to_le32(pagelist->length);
+       reply->nr_pages = calc_pages_for(0, pagelist->length);
+       ceph_con_send(&session->s_con, reply);
+
+       if (session) {
+               session->s_state = CEPH_MDS_SESSION_OPEN;
+               __wake_requests(mdsc, &session->s_waiting);
+       }
+
+out:
+       up_read(&mdsc->snap_rwsem);
+       if (session) {
+               mutex_unlock(&session->s_mutex);
+               ceph_put_mds_session(session);
+       }
+       mutex_lock(&mdsc->mutex);
+       return;
+
+fail:
+       ceph_msg_put(reply);
+fail_nomsg:
+       ceph_pagelist_release(pagelist);
+       kfree(pagelist);
+fail_nopagelist:
+       pr_err("ENOMEM preparing reconnect for mds%d\n", mds);
+       goto out;
+}
+
+
+/*
+ * compare old and new mdsmaps, kicking requests
+ * and closing out old connections as necessary
+ *
+ * called under mdsc->mutex.
+ */
+static void check_new_map(struct ceph_mds_client *mdsc,
+                         struct ceph_mdsmap *newmap,
+                         struct ceph_mdsmap *oldmap)
+{
+       int i;
+       int oldstate, newstate;
+       struct ceph_mds_session *s;
+
+       dout("check_new_map new %u old %u\n",
+            newmap->m_epoch, oldmap->m_epoch);
+
+       for (i = 0; i < oldmap->m_max_mds && i < mdsc->max_sessions; i++) {
+               if (mdsc->sessions[i] == NULL)
+                       continue;
+               s = mdsc->sessions[i];
+               oldstate = ceph_mdsmap_get_state(oldmap, i);
+               newstate = ceph_mdsmap_get_state(newmap, i);
+
+               dout("check_new_map mds%d state %s -> %s (session %s)\n",
+                    i, ceph_mds_state_name(oldstate),
+                    ceph_mds_state_name(newstate),
+                    session_state_name(s->s_state));
+
+               if (memcmp(ceph_mdsmap_get_addr(oldmap, i),
+                          ceph_mdsmap_get_addr(newmap, i),
+                          sizeof(struct ceph_entity_addr))) {
+                       if (s->s_state == CEPH_MDS_SESSION_OPENING) {
+                               /* the session never opened, just close it
+                                * out now */
+                               __wake_requests(mdsc, &s->s_waiting);
+                               __unregister_session(mdsc, s);
+                       } else {
+                               /* just close it */
+                               mutex_unlock(&mdsc->mutex);
+                               mutex_lock(&s->s_mutex);
+                               mutex_lock(&mdsc->mutex);
+                               ceph_con_close(&s->s_con);
+                               mutex_unlock(&s->s_mutex);
+                               s->s_state = CEPH_MDS_SESSION_RESTARTING;
+                       }
+
+                       /* kick any requests waiting on the recovering mds */
+                       kick_requests(mdsc, i, 1);
+               } else if (oldstate == newstate) {
+                       continue;  /* nothing new with this mds */
+               }
+
+               /*
+                * send reconnect?
+                */
+               if (s->s_state == CEPH_MDS_SESSION_RESTARTING &&
+                   newstate >= CEPH_MDS_STATE_RECONNECT)
+                       send_mds_reconnect(mdsc, i);
+
+               /*
+                * kick requests on any mds that has gone active.
+                *
+                * kick requests on cur or forwarder: we may have sent
+                * the request to mds1, mds1 told us it forwarded it
+                * to mds2, but then we learn mds1 failed and can't be
+                * sure it successfully forwarded our request before
+                * it died.
+                */
+               if (oldstate < CEPH_MDS_STATE_ACTIVE &&
+                   newstate >= CEPH_MDS_STATE_ACTIVE) {
+                       pr_info("mds%d reconnect completed\n", s->s_mds);
+                       kick_requests(mdsc, i, 1);
+                       ceph_kick_flushing_caps(mdsc, s);
+                       wake_up_session_caps(s, 1);
+               }
+       }
+}
+
+
+
+/*
+ * leases
+ */
+
+/*
+ * caller must hold session s_mutex, dentry->d_lock
+ */
+void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry)
+{
+       struct ceph_dentry_info *di = ceph_dentry(dentry);
+
+       ceph_put_mds_session(di->lease_session);
+       di->lease_session = NULL;
+}
+
+static void handle_lease(struct ceph_mds_client *mdsc,
+                        struct ceph_mds_session *session,
+                        struct ceph_msg *msg)
+{
+       struct super_block *sb = mdsc->client->sb;
+       struct inode *inode;
+       struct ceph_inode_info *ci;
+       struct dentry *parent, *dentry;
+       struct ceph_dentry_info *di;
+       int mds = session->s_mds;
+       struct ceph_mds_lease *h = msg->front.iov_base;
+       struct ceph_vino vino;
+       int mask;
+       struct qstr dname;
+       int release = 0;
+
+       dout("handle_lease from mds%d\n", mds);
+
+       /* decode */
+       if (msg->front.iov_len < sizeof(*h) + sizeof(u32))
+               goto bad;
+       vino.ino = le64_to_cpu(h->ino);
+       vino.snap = CEPH_NOSNAP;
+       mask = le16_to_cpu(h->mask);
+       dname.name = (void *)h + sizeof(*h) + sizeof(u32);
+       dname.len = msg->front.iov_len - sizeof(*h) - sizeof(u32);
+       if (dname.len != get_unaligned_le32(h+1))
+               goto bad;
+
+       mutex_lock(&session->s_mutex);
+       session->s_seq++;
+
+       /* lookup inode */
+       inode = ceph_find_inode(sb, vino);
+       dout("handle_lease '%s', mask %d, ino %llx %p\n",
+            ceph_lease_op_name(h->action), mask, vino.ino, inode);
+       if (inode == NULL) {
+               dout("handle_lease no inode %llx\n", vino.ino);
+               goto release;
+       }
+       ci = ceph_inode(inode);
+
+       /* dentry */
+       parent = d_find_alias(inode);
+       if (!parent) {
+               dout("no parent dentry on inode %p\n", inode);
+               WARN_ON(1);
+               goto release;  /* hrm... */
+       }
+       dname.hash = full_name_hash(dname.name, dname.len);
+       dentry = d_lookup(parent, &dname);
+       dput(parent);
+       if (!dentry)
+               goto release;
+
+       spin_lock(&dentry->d_lock);
+       di = ceph_dentry(dentry);
+       switch (h->action) {
+       case CEPH_MDS_LEASE_REVOKE:
+               if (di && di->lease_session == session) {
+                       h->seq = cpu_to_le32(di->lease_seq);
+                       __ceph_mdsc_drop_dentry_lease(dentry);
+               }
+               release = 1;
+               break;
+
+       case CEPH_MDS_LEASE_RENEW:
+               if (di && di->lease_session == session &&
+                   di->lease_gen == session->s_cap_gen &&
+                   di->lease_renew_from &&
+                   di->lease_renew_after == 0) {
+                       unsigned long duration =
+                               le32_to_cpu(h->duration_ms) * HZ / 1000;
+
+                       di->lease_seq = le32_to_cpu(h->seq);
+                       dentry->d_time = di->lease_renew_from + duration;
+                       di->lease_renew_after = di->lease_renew_from +
+                               (duration >> 1);
+                       di->lease_renew_from = 0;
+               }
+               break;
+       }
+       spin_unlock(&dentry->d_lock);
+       dput(dentry);
+
+       if (!release)
+               goto out;
+
+release:
+       /* let's just reuse the same message */
+       h->action = CEPH_MDS_LEASE_REVOKE_ACK;
+       ceph_msg_get(msg);
+       ceph_con_send(&session->s_con, msg);
+
+out:
+       iput(inode);
+       mutex_unlock(&session->s_mutex);
+       return;
+
+bad:
+       pr_err("corrupt lease message\n");
+       ceph_msg_dump(msg);
+}
+
+void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
+                             struct inode *inode,
+                             struct dentry *dentry, char action,
+                             u32 seq)
+{
+       struct ceph_msg *msg;
+       struct ceph_mds_lease *lease;
+       int len = sizeof(*lease) + sizeof(u32);
+       int dnamelen = 0;
+
+       dout("lease_send_msg inode %p dentry %p %s to mds%d\n",
+            inode, dentry, ceph_lease_op_name(action), session->s_mds);
+       dnamelen = dentry->d_name.len;
+       len += dnamelen;
+
+       msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, 0, 0, NULL);
+       if (IS_ERR(msg))
+               return;
+       lease = msg->front.iov_base;
+       lease->action = action;
+       lease->mask = cpu_to_le16(CEPH_LOCK_DN);
+       lease->ino = cpu_to_le64(ceph_vino(inode).ino);
+       lease->first = lease->last = cpu_to_le64(ceph_vino(inode).snap);
+       lease->seq = cpu_to_le32(seq);
+       put_unaligned_le32(dnamelen, lease + 1);
+       memcpy((void *)(lease + 1) + 4, dentry->d_name.name, dnamelen);
+
+       /*
+        * if this is a preemptive lease RELEASE, no need to
+        * flush request stream, since the actual request will
+        * soon follow.
+        */
+       msg->more_to_follow = (action == CEPH_MDS_LEASE_RELEASE);
+
+       ceph_con_send(&session->s_con, msg);
+}
+
+/*
+ * Preemptively release a lease we expect to invalidate anyway.
+ * Pass @inode always, @dentry is optional.
+ */
+void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc, struct inode *inode,
+                            struct dentry *dentry, int mask)
+{
+       struct ceph_dentry_info *di;
+       struct ceph_mds_session *session;
+       u32 seq;
+
+       BUG_ON(inode == NULL);
+       BUG_ON(dentry == NULL);
+       BUG_ON(mask != CEPH_LOCK_DN);
+
+       /* is dentry lease valid? */
+       spin_lock(&dentry->d_lock);
+       di = ceph_dentry(dentry);
+       if (!di || !di->lease_session ||
+           di->lease_session->s_mds < 0 ||
+           di->lease_gen != di->lease_session->s_cap_gen ||
+           !time_before(jiffies, dentry->d_time)) {
+               dout("lease_release inode %p dentry %p -- "
+                    "no lease on %d\n",
+                    inode, dentry, mask);
+               spin_unlock(&dentry->d_lock);
+               return;
+       }
+
+       /* we do have a lease on this dentry; note mds and seq */
+       session = ceph_get_mds_session(di->lease_session);
+       seq = di->lease_seq;
+       __ceph_mdsc_drop_dentry_lease(dentry);
+       spin_unlock(&dentry->d_lock);
+
+       dout("lease_release inode %p dentry %p mask %d to mds%d\n",
+            inode, dentry, mask, session->s_mds);
+       ceph_mdsc_lease_send_msg(session, inode, dentry,
+                                CEPH_MDS_LEASE_RELEASE, seq);
+       ceph_put_mds_session(session);
+}
+
+/*
+ * drop all leases (and dentry refs) in preparation for umount
+ */
+static void drop_leases(struct ceph_mds_client *mdsc)
+{
+       int i;
+
+       dout("drop_leases\n");
+       mutex_lock(&mdsc->mutex);
+       for (i = 0; i < mdsc->max_sessions; i++) {
+               struct ceph_mds_session *s = __ceph_lookup_mds_session(mdsc, i);
+               if (!s)
+                       continue;
+               mutex_unlock(&mdsc->mutex);
+               mutex_lock(&s->s_mutex);
+               mutex_unlock(&s->s_mutex);
+               ceph_put_mds_session(s);
+               mutex_lock(&mdsc->mutex);
+       }
+       mutex_unlock(&mdsc->mutex);
+}
+
+
+
+/*
+ * delayed work -- periodically trim expired leases, renew caps with mds
+ */
+static void schedule_delayed(struct ceph_mds_client *mdsc)
+{
+       int delay = 5;
+       unsigned hz = round_jiffies_relative(HZ * delay);
+       schedule_delayed_work(&mdsc->delayed_work, hz);
+}
+
+static void delayed_work(struct work_struct *work)
+{
+       int i;
+       struct ceph_mds_client *mdsc =
+               container_of(work, struct ceph_mds_client, delayed_work.work);
+       int renew_interval;
+       int renew_caps;
+
+       dout("mdsc delayed_work\n");
+       ceph_check_delayed_caps(mdsc);
+
+       mutex_lock(&mdsc->mutex);
+       renew_interval = mdsc->mdsmap->m_session_timeout >> 2;
+       renew_caps = time_after_eq(jiffies, HZ*renew_interval +
+                                  mdsc->last_renew_caps);
+       if (renew_caps)
+               mdsc->last_renew_caps = jiffies;
+
+       for (i = 0; i < mdsc->max_sessions; i++) {
+               struct ceph_mds_session *s = __ceph_lookup_mds_session(mdsc, i);
+               if (s == NULL)
+                       continue;
+               if (s->s_state == CEPH_MDS_SESSION_CLOSING) {
+                       dout("resending session close request for mds%d\n",
+                            s->s_mds);
+                       request_close_session(mdsc, s);
+                       ceph_put_mds_session(s);
+                       continue;
+               }
+               if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
+                       if (s->s_state == CEPH_MDS_SESSION_OPEN) {
+                               s->s_state = CEPH_MDS_SESSION_HUNG;
+                               pr_info("mds%d hung\n", s->s_mds);
+                       }
+               }
+               if (s->s_state < CEPH_MDS_SESSION_OPEN) {
+                       /* this mds is failed or recovering, just wait */
+                       ceph_put_mds_session(s);
+                       continue;
+               }
+               mutex_unlock(&mdsc->mutex);
+
+               mutex_lock(&s->s_mutex);
+               if (renew_caps)
+                       send_renew_caps(mdsc, s);
+               else
+                       ceph_con_keepalive(&s->s_con);
+               add_cap_releases(mdsc, s, -1);
+               send_cap_releases(mdsc, s);
+               mutex_unlock(&s->s_mutex);
+               ceph_put_mds_session(s);
+
+               mutex_lock(&mdsc->mutex);
+       }
+       mutex_unlock(&mdsc->mutex);
+
+       schedule_delayed(mdsc);
+}
+
+
+int ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client)
+{
+       mdsc->client = client;
+       mutex_init(&mdsc->mutex);
+       mdsc->mdsmap = kzalloc(sizeof(*mdsc->mdsmap), GFP_NOFS);
+       init_completion(&mdsc->safe_umount_waiters);
+       init_completion(&mdsc->session_close_waiters);
+       INIT_LIST_HEAD(&mdsc->waiting_for_map);
+       mdsc->sessions = NULL;
+       mdsc->max_sessions = 0;
+       mdsc->stopping = 0;
+       init_rwsem(&mdsc->snap_rwsem);
+       mdsc->snap_realms = RB_ROOT;
+       INIT_LIST_HEAD(&mdsc->snap_empty);
+       spin_lock_init(&mdsc->snap_empty_lock);
+       mdsc->last_tid = 0;
+       mdsc->request_tree = RB_ROOT;
+       INIT_DELAYED_WORK(&mdsc->delayed_work, delayed_work);
+       mdsc->last_renew_caps = jiffies;
+       INIT_LIST_HEAD(&mdsc->cap_delay_list);
+       spin_lock_init(&mdsc->cap_delay_lock);
+       INIT_LIST_HEAD(&mdsc->snap_flush_list);
+       spin_lock_init(&mdsc->snap_flush_lock);
+       mdsc->cap_flush_seq = 0;
+       INIT_LIST_HEAD(&mdsc->cap_dirty);
+       mdsc->num_cap_flushing = 0;
+       spin_lock_init(&mdsc->cap_dirty_lock);
+       init_waitqueue_head(&mdsc->cap_flushing_wq);
+       spin_lock_init(&mdsc->dentry_lru_lock);
+       INIT_LIST_HEAD(&mdsc->dentry_lru);
+       return 0;
+}
+
+/*
+ * Wait for safe replies on open mds requests.  If we time out, drop
+ * all requests from the tree to avoid dangling dentry refs.
+ */
+static void wait_requests(struct ceph_mds_client *mdsc)
+{
+       struct ceph_mds_request *req;
+       struct ceph_client *client = mdsc->client;
+
+       mutex_lock(&mdsc->mutex);
+       if (__get_oldest_req(mdsc)) {
+               mutex_unlock(&mdsc->mutex);
+
+               dout("wait_requests waiting for requests\n");
+               wait_for_completion_timeout(&mdsc->safe_umount_waiters,
+                                   client->mount_args->mount_timeout * HZ);
+
+               /* tear down remaining requests */
+               mutex_lock(&mdsc->mutex);
+               while ((req = __get_oldest_req(mdsc))) {
+                       dout("wait_requests timed out on tid %llu\n",
+                            req->r_tid);
+                       __unregister_request(mdsc, req);
+               }
+       }
+       mutex_unlock(&mdsc->mutex);
+       dout("wait_requests done\n");
+}
+
+/*
+ * called before mount is ro, and before dentries are torn down.
+ * (hmm, does this still race with new lookups?)
+ */
+void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc)
+{
+       dout("pre_umount\n");
+       mdsc->stopping = 1;
+
+       drop_leases(mdsc);
+       ceph_flush_dirty_caps(mdsc);
+       wait_requests(mdsc);
+}
+
+/*
+ * wait for all write mds requests to flush.
+ */
+static void wait_unsafe_requests(struct ceph_mds_client *mdsc, u64 want_tid)
+{
+       struct ceph_mds_request *req = NULL, *nextreq;
+       struct rb_node *n;
+
+       mutex_lock(&mdsc->mutex);
+       dout("wait_unsafe_requests want %lld\n", want_tid);
+restart:
+       req = __get_oldest_req(mdsc);
+       while (req && req->r_tid <= want_tid) {
+               /* find next request */
+               n = rb_next(&req->r_node);
+               if (n)
+                       nextreq = rb_entry(n, struct ceph_mds_request, r_node);
+               else
+                       nextreq = NULL;
+               if ((req->r_op & CEPH_MDS_OP_WRITE)) {
+                       /* write op */
+                       ceph_mdsc_get_request(req);
+                       if (nextreq)
+                               ceph_mdsc_get_request(nextreq);
+                       mutex_unlock(&mdsc->mutex);
+                       dout("wait_unsafe_requests  wait on %llu (want %llu)\n",
+                            req->r_tid, want_tid);
+                       wait_for_completion(&req->r_safe_completion);
+                       mutex_lock(&mdsc->mutex);
+                       ceph_mdsc_put_request(req);
+                       if (!nextreq)
+                               break;  /* next dne before, so we're done! */
+                       if (RB_EMPTY_NODE(&nextreq->r_node)) {
+                               /* next request was removed from tree */
+                               ceph_mdsc_put_request(nextreq);
+                               goto restart;
+                       }
+                       ceph_mdsc_put_request(nextreq);  /* won't go away */
+               }
+               req = nextreq;
+       }
+       mutex_unlock(&mdsc->mutex);
+       dout("wait_unsafe_requests done\n");
+}
+
+void ceph_mdsc_sync(struct ceph_mds_client *mdsc)
+{
+       u64 want_tid, want_flush;
+
+       dout("sync\n");
+       mutex_lock(&mdsc->mutex);
+       want_tid = mdsc->last_tid;
+       want_flush = mdsc->cap_flush_seq;
+       mutex_unlock(&mdsc->mutex);
+       dout("sync want tid %lld flush_seq %lld\n", want_tid, want_flush);
+
+       ceph_flush_dirty_caps(mdsc);
+
+       wait_unsafe_requests(mdsc, want_tid);
+       wait_event(mdsc->cap_flushing_wq, check_cap_flush(mdsc, want_flush));
+}
+
+
+/*
+ * called after sb is ro.
+ */
+void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc)
+{
+       struct ceph_mds_session *session;
+       int i;
+       int n;
+       struct ceph_client *client = mdsc->client;
+       unsigned long started, timeout = client->mount_args->mount_timeout * HZ;
+
+       dout("close_sessions\n");
+
+       mutex_lock(&mdsc->mutex);
+
+       /* close sessions */
+       started = jiffies;
+       while (time_before(jiffies, started + timeout)) {
+               dout("closing sessions\n");
+               n = 0;
+               for (i = 0; i < mdsc->max_sessions; i++) {
+                       session = __ceph_lookup_mds_session(mdsc, i);
+                       if (!session)
+                               continue;
+                       mutex_unlock(&mdsc->mutex);
+                       mutex_lock(&session->s_mutex);
+                       __close_session(mdsc, session);
+                       mutex_unlock(&session->s_mutex);
+                       ceph_put_mds_session(session);
+                       mutex_lock(&mdsc->mutex);
+                       n++;
+               }
+               if (n == 0)
+                       break;
+
+               if (client->mount_state == CEPH_MOUNT_SHUTDOWN)
+                       break;
+
+               dout("waiting for sessions to close\n");
+               mutex_unlock(&mdsc->mutex);
+               wait_for_completion_timeout(&mdsc->session_close_waiters,
+                                           timeout);
+               mutex_lock(&mdsc->mutex);
+       }
+
+       /* tear down remaining sessions */
+       for (i = 0; i < mdsc->max_sessions; i++) {
+               if (mdsc->sessions[i]) {
+                       session = get_session(mdsc->sessions[i]);
+                       __unregister_session(mdsc, session);
+                       mutex_unlock(&mdsc->mutex);
+                       mutex_lock(&session->s_mutex);
+                       remove_session_caps(session);
+                       mutex_unlock(&session->s_mutex);
+                       ceph_put_mds_session(session);
+                       mutex_lock(&mdsc->mutex);
+               }
+       }
+
+       WARN_ON(!list_empty(&mdsc->cap_delay_list));
+
+       mutex_unlock(&mdsc->mutex);
+
+       ceph_cleanup_empty_realms(mdsc);
+
+       cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */
+
+       dout("stopped\n");
+}
+
+void ceph_mdsc_stop(struct ceph_mds_client *mdsc)
+{
+       dout("stop\n");
+       cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */
+       if (mdsc->mdsmap)
+               ceph_mdsmap_destroy(mdsc->mdsmap);
+       kfree(mdsc->sessions);
+}
+
+
+/*
+ * handle mds map update.
+ */
+void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
+{
+       u32 epoch;
+       u32 maplen;
+       void *p = msg->front.iov_base;
+       void *end = p + msg->front.iov_len;
+       struct ceph_mdsmap *newmap, *oldmap;
+       struct ceph_fsid fsid;
+       int err = -EINVAL;
+
+       ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(u32), bad);
+       ceph_decode_copy(&p, &fsid, sizeof(fsid));
+       if (ceph_check_fsid(mdsc->client, &fsid) < 0)
+               return;
+       epoch = ceph_decode_32(&p);
+       maplen = ceph_decode_32(&p);
+       dout("handle_map epoch %u len %d\n", epoch, (int)maplen);
+
+       /* do we need it? */
+       ceph_monc_got_mdsmap(&mdsc->client->monc, epoch);
+       mutex_lock(&mdsc->mutex);
+       if (mdsc->mdsmap && epoch <= mdsc->mdsmap->m_epoch) {
+               dout("handle_map epoch %u <= our %u\n",
+                    epoch, mdsc->mdsmap->m_epoch);
+               mutex_unlock(&mdsc->mutex);
+               return;
+       }
+
+       newmap = ceph_mdsmap_decode(&p, end);
+       if (IS_ERR(newmap)) {
+               err = PTR_ERR(newmap);
+               goto bad_unlock;
+       }
+
+       /* swap into place */
+       if (mdsc->mdsmap) {
+               oldmap = mdsc->mdsmap;
+               mdsc->mdsmap = newmap;
+               check_new_map(mdsc, newmap, oldmap);
+               ceph_mdsmap_destroy(oldmap);
+       } else {
+               mdsc->mdsmap = newmap;  /* first mds map */
+       }
+       mdsc->client->sb->s_maxbytes = mdsc->mdsmap->m_max_file_size;
+
+       __wake_requests(mdsc, &mdsc->waiting_for_map);
+
+       mutex_unlock(&mdsc->mutex);
+       schedule_delayed(mdsc);
+       return;
+
+bad_unlock:
+       mutex_unlock(&mdsc->mutex);
+bad:
+       pr_err("error decoding mdsmap %d\n", err);
+       return;
+}
+
+static struct ceph_connection *con_get(struct ceph_connection *con)
+{
+       struct ceph_mds_session *s = con->private;
+
+       if (get_session(s)) {
+               dout("mdsc con_get %p ok (%d)\n", s, atomic_read(&s->s_ref));
+               return con;
+       }
+       dout("mdsc con_get %p FAIL\n", s);
+       return NULL;
+}
+
+static void con_put(struct ceph_connection *con)
+{
+       struct ceph_mds_session *s = con->private;
+
+       ceph_put_mds_session(s);
+       dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref));
+}
+
+/*
+ * if the client is unresponsive for long enough, the mds will kill
+ * the session entirely.
+ */
+static void peer_reset(struct ceph_connection *con)
+{
+       struct ceph_mds_session *s = con->private;
+
+       pr_err("mds%d gave us the boot.  IMPLEMENT RECONNECT.\n",
+              s->s_mds);
+}
+
+static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_client *mdsc = s->s_mdsc;
+       int type = le16_to_cpu(msg->hdr.type);
+
+       mutex_lock(&mdsc->mutex);
+       if (__verify_registered_session(mdsc, s) < 0) {
+               mutex_unlock(&mdsc->mutex);
+               goto out;
+       }
+       mutex_unlock(&mdsc->mutex);
+
+       switch (type) {
+       case CEPH_MSG_MDS_MAP:
+               ceph_mdsc_handle_map(mdsc, msg);
+               break;
+       case CEPH_MSG_CLIENT_SESSION:
+               handle_session(s, msg);
+               break;
+       case CEPH_MSG_CLIENT_REPLY:
+               handle_reply(s, msg);
+               break;
+       case CEPH_MSG_CLIENT_REQUEST_FORWARD:
+               handle_forward(mdsc, s, msg);
+               break;
+       case CEPH_MSG_CLIENT_CAPS:
+               ceph_handle_caps(s, msg);
+               break;
+       case CEPH_MSG_CLIENT_SNAP:
+               ceph_handle_snap(mdsc, s, msg);
+               break;
+       case CEPH_MSG_CLIENT_LEASE:
+               handle_lease(mdsc, s, msg);
+               break;
+
+       default:
+               pr_err("received unknown message type %d %s\n", type,
+                      ceph_msg_type_name(type));
+       }
+out:
+       ceph_msg_put(msg);
+}
+
+/*
+ * authentication
+ */
+static int get_authorizer(struct ceph_connection *con,
+                         void **buf, int *len, int *proto,
+                         void **reply_buf, int *reply_len, int force_new)
+{
+       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_client *mdsc = s->s_mdsc;
+       struct ceph_auth_client *ac = mdsc->client->monc.auth;
+       int ret = 0;
+
+       if (force_new && s->s_authorizer) {
+               ac->ops->destroy_authorizer(ac, s->s_authorizer);
+               s->s_authorizer = NULL;
+       }
+       if (s->s_authorizer == NULL) {
+               if (ac->ops->create_authorizer) {
+                       ret = ac->ops->create_authorizer(
+                               ac, CEPH_ENTITY_TYPE_MDS,
+                               &s->s_authorizer,
+                               &s->s_authorizer_buf,
+                               &s->s_authorizer_buf_len,
+                               &s->s_authorizer_reply_buf,
+                               &s->s_authorizer_reply_buf_len);
+                       if (ret)
+                               return ret;
+               }
+       }
+
+       *proto = ac->protocol;
+       *buf = s->s_authorizer_buf;
+       *len = s->s_authorizer_buf_len;
+       *reply_buf = s->s_authorizer_reply_buf;
+       *reply_len = s->s_authorizer_reply_buf_len;
+       return 0;
+}
+
+
+static int verify_authorizer_reply(struct ceph_connection *con, int len)
+{
+       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_client *mdsc = s->s_mdsc;
+       struct ceph_auth_client *ac = mdsc->client->monc.auth;
+
+       return ac->ops->verify_authorizer_reply(ac, s->s_authorizer, len);
+}
+
+static int invalidate_authorizer(struct ceph_connection *con)
+{
+       struct ceph_mds_session *s = con->private;
+       struct ceph_mds_client *mdsc = s->s_mdsc;
+       struct ceph_auth_client *ac = mdsc->client->monc.auth;
+
+       if (ac->ops->invalidate_authorizer)
+               ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_MDS);
+
+       return ceph_monc_validate_auth(&mdsc->client->monc);
+}
+
+const static struct ceph_connection_operations mds_con_ops = {
+       .get = con_get,
+       .put = con_put,
+       .dispatch = dispatch,
+       .get_authorizer = get_authorizer,
+       .verify_authorizer_reply = verify_authorizer_reply,
+       .invalidate_authorizer = invalidate_authorizer,
+       .peer_reset = peer_reset,
+};
+
+
+
+
+/* eof */
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
new file mode 100644 (file)
index 0000000..961cc6f
--- /dev/null
@@ -0,0 +1,335 @@
+#ifndef _FS_CEPH_MDS_CLIENT_H
+#define _FS_CEPH_MDS_CLIENT_H
+
+#include <linux/completion.h>
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/rbtree.h>
+#include <linux/spinlock.h>
+
+#include "types.h"
+#include "messenger.h"
+#include "mdsmap.h"
+
+/*
+ * Some lock dependencies:
+ *
+ * session->s_mutex
+ *         mdsc->mutex
+ *
+ *         mdsc->snap_rwsem
+ *
+ *         inode->i_lock
+ *                 mdsc->snap_flush_lock
+ *                 mdsc->cap_delay_lock
+ *
+ */
+
+struct ceph_client;
+struct ceph_cap;
+
+/*
+ * parsed info about a single inode.  pointers are into the encoded
+ * on-wire structures within the mds reply message payload.
+ */
+struct ceph_mds_reply_info_in {
+       struct ceph_mds_reply_inode *in;
+       u32 symlink_len;
+       char *symlink;
+       u32 xattr_len;
+       char *xattr_data;
+};
+
+/*
+ * parsed info about an mds reply, including information about the
+ * target inode and/or its parent directory and dentry, and directory
+ * contents (for readdir results).
+ */
+struct ceph_mds_reply_info_parsed {
+       struct ceph_mds_reply_head    *head;
+
+       struct ceph_mds_reply_info_in diri, targeti;
+       struct ceph_mds_reply_dirfrag *dirfrag;
+       char                          *dname;
+       u32                           dname_len;
+       struct ceph_mds_reply_lease   *dlease;
+
+       struct ceph_mds_reply_dirfrag *dir_dir;
+       int                           dir_nr;
+       char                          **dir_dname;
+       u32                           *dir_dname_len;
+       struct ceph_mds_reply_lease   **dir_dlease;
+       struct ceph_mds_reply_info_in *dir_in;
+       u8                            dir_complete, dir_end;
+
+       /* encoded blob describing snapshot contexts for certain
+          operations (e.g., open) */
+       void *snapblob;
+       int snapblob_len;
+};
+
+
+/*
+ * cap releases are batched and sent to the MDS en masse.
+ */
+#define CEPH_CAPS_PER_RELEASE ((PAGE_CACHE_SIZE -                      \
+                               sizeof(struct ceph_mds_cap_release)) /  \
+                              sizeof(struct ceph_mds_cap_item))
+
+
+/*
+ * state associated with each MDS<->client session
+ */
+enum {
+       CEPH_MDS_SESSION_NEW = 1,
+       CEPH_MDS_SESSION_OPENING = 2,
+       CEPH_MDS_SESSION_OPEN = 3,
+       CEPH_MDS_SESSION_HUNG = 4,
+       CEPH_MDS_SESSION_CLOSING = 5,
+       CEPH_MDS_SESSION_RESTARTING = 6,
+       CEPH_MDS_SESSION_RECONNECTING = 7,
+};
+
+struct ceph_mds_session {
+       struct ceph_mds_client *s_mdsc;
+       int               s_mds;
+       int               s_state;
+       unsigned long     s_ttl;      /* time until mds kills us */
+       u64               s_seq;      /* incoming msg seq # */
+       struct mutex      s_mutex;    /* serialize session messages */
+
+       struct ceph_connection s_con;
+
+       struct ceph_authorizer *s_authorizer;
+       void             *s_authorizer_buf, *s_authorizer_reply_buf;
+       size_t            s_authorizer_buf_len, s_authorizer_reply_buf_len;
+
+       /* protected by s_cap_lock */
+       spinlock_t        s_cap_lock;
+       u32               s_cap_gen;  /* inc each time we get mds stale msg */
+       unsigned long     s_cap_ttl;  /* when session caps expire */
+       struct list_head  s_caps;     /* all caps issued by this session */
+       int               s_nr_caps, s_trim_caps;
+       int               s_num_cap_releases;
+       struct list_head  s_cap_releases; /* waiting cap_release messages */
+       struct list_head  s_cap_releases_done; /* ready to send */
+       struct ceph_cap  *s_cap_iterator;
+
+       /* protected by mutex */
+       struct list_head  s_cap_flushing;     /* inodes w/ flushing caps */
+       struct list_head  s_cap_snaps_flushing;
+       unsigned long     s_renew_requested; /* last time we sent a renew req */
+       u64               s_renew_seq;
+
+       atomic_t          s_ref;
+       struct list_head  s_waiting;  /* waiting requests */
+       struct list_head  s_unsafe;   /* unsafe requests */
+};
+
+/*
+ * modes of choosing which MDS to send a request to
+ */
+enum {
+       USE_ANY_MDS,
+       USE_RANDOM_MDS,
+       USE_AUTH_MDS,   /* prefer authoritative mds for this metadata item */
+};
+
+struct ceph_mds_request;
+struct ceph_mds_client;
+
+/*
+ * request completion callback
+ */
+typedef void (*ceph_mds_request_callback_t) (struct ceph_mds_client *mdsc,
+                                            struct ceph_mds_request *req);
+
+/*
+ * an in-flight mds request
+ */
+struct ceph_mds_request {
+       u64 r_tid;                   /* transaction id */
+       struct rb_node r_node;
+
+       int r_op;                    /* mds op code */
+       int r_mds;
+
+       /* operation on what? */
+       struct inode *r_inode;              /* arg1 */
+       struct dentry *r_dentry;            /* arg1 */
+       struct dentry *r_old_dentry;        /* arg2: rename from or link from */
+       char *r_path1, *r_path2;
+       struct ceph_vino r_ino1, r_ino2;
+
+       struct inode *r_locked_dir; /* dir (if any) i_mutex locked by vfs */
+       struct inode *r_target_inode;       /* resulting inode */
+
+       union ceph_mds_request_args r_args;
+       int r_fmode;        /* file mode, if expecting cap */
+
+       /* for choosing which mds to send this request to */
+       int r_direct_mode;
+       u32 r_direct_hash;      /* choose dir frag based on this dentry hash */
+       bool r_direct_is_hash;  /* true if r_direct_hash is valid */
+
+       /* data payload is used for xattr ops */
+       struct page **r_pages;
+       int r_num_pages;
+       int r_data_len;
+
+       /* what caps shall we drop? */
+       int r_inode_drop, r_inode_unless;
+       int r_dentry_drop, r_dentry_unless;
+       int r_old_dentry_drop, r_old_dentry_unless;
+       struct inode *r_old_inode;
+       int r_old_inode_drop, r_old_inode_unless;
+
+       struct ceph_msg  *r_request;  /* original request */
+       struct ceph_msg  *r_reply;
+       struct ceph_mds_reply_info_parsed r_reply_info;
+       int r_err;
+       bool r_aborted;
+
+       unsigned long r_timeout;  /* optional.  jiffies */
+       unsigned long r_started;  /* start time to measure timeout against */
+       unsigned long r_request_started; /* start time for mds request only,
+                                           used to measure lease durations */
+
+       /* link unsafe requests to parent directory, for fsync */
+       struct inode    *r_unsafe_dir;
+       struct list_head r_unsafe_dir_item;
+
+       struct ceph_mds_session *r_session;
+
+       int               r_attempts;   /* resend attempts */
+       int               r_num_fwd;    /* number of forward attempts */
+       int               r_num_stale;
+       int               r_resend_mds; /* mds to resend to next, if any*/
+
+       struct kref       r_kref;
+       struct list_head  r_wait;
+       struct completion r_completion;
+       struct completion r_safe_completion;
+       ceph_mds_request_callback_t r_callback;
+       struct list_head  r_unsafe_item;  /* per-session unsafe list item */
+       bool              r_got_unsafe, r_got_safe;
+
+       bool              r_did_prepopulate;
+       u32               r_readdir_offset;
+
+       struct ceph_cap_reservation r_caps_reservation;
+       int r_num_caps;
+};
+
+/*
+ * mds client state
+ */
+struct ceph_mds_client {
+       struct ceph_client      *client;
+       struct mutex            mutex;         /* all nested structures */
+
+       struct ceph_mdsmap      *mdsmap;
+       struct completion       safe_umount_waiters, session_close_waiters;
+       struct list_head        waiting_for_map;
+
+       struct ceph_mds_session **sessions;    /* NULL for mds if no session */
+       int                     max_sessions;  /* len of s_mds_sessions */
+       int                     stopping;      /* true if shutting down */
+
+       /*
+        * snap_rwsem will cover cap linkage into snaprealms, and
+        * realm snap contexts.  (later, we can do per-realm snap
+        * contexts locks..)  the empty list contains realms with no
+        * references (implying they contain no inodes with caps) that
+        * should be destroyed.
+        */
+       struct rw_semaphore     snap_rwsem;
+       struct rb_root          snap_realms;
+       struct list_head        snap_empty;
+       spinlock_t              snap_empty_lock;  /* protect snap_empty */
+
+       u64                    last_tid;      /* most recent mds request */
+       struct rb_root         request_tree;  /* pending mds requests */
+       struct delayed_work    delayed_work;  /* delayed work */
+       unsigned long    last_renew_caps;  /* last time we renewed our caps */
+       struct list_head cap_delay_list;   /* caps with delayed release */
+       spinlock_t       cap_delay_lock;   /* protects cap_delay_list */
+       struct list_head snap_flush_list;  /* cap_snaps ready to flush */
+       spinlock_t       snap_flush_lock;
+
+       u64               cap_flush_seq;
+       struct list_head  cap_dirty;        /* inodes with dirty caps */
+       int               num_cap_flushing; /* # caps we are flushing */
+       spinlock_t        cap_dirty_lock;   /* protects above items */
+       wait_queue_head_t cap_flushing_wq;
+
+#ifdef CONFIG_DEBUG_FS
+       struct dentry     *debugfs_file;
+#endif
+
+       spinlock_t        dentry_lru_lock;
+       struct list_head  dentry_lru;
+       int               num_dentry;
+};
+
+extern const char *ceph_mds_op_name(int op);
+
+extern struct ceph_mds_session *
+__ceph_lookup_mds_session(struct ceph_mds_client *, int mds);
+
+static inline struct ceph_mds_session *
+ceph_get_mds_session(struct ceph_mds_session *s)
+{
+       atomic_inc(&s->s_ref);
+       return s;
+}
+
+extern void ceph_put_mds_session(struct ceph_mds_session *s);
+
+extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
+                            struct ceph_msg *msg, int mds);
+
+extern int ceph_mdsc_init(struct ceph_mds_client *mdsc,
+                          struct ceph_client *client);
+extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc);
+extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc);
+
+extern void ceph_mdsc_sync(struct ceph_mds_client *mdsc);
+
+extern void ceph_mdsc_lease_release(struct ceph_mds_client *mdsc,
+                                   struct inode *inode,
+                                   struct dentry *dn, int mask);
+
+extern struct ceph_mds_request *
+ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode);
+extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
+                                    struct ceph_mds_request *req);
+extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
+                               struct inode *dir,
+                               struct ceph_mds_request *req);
+static inline void ceph_mdsc_get_request(struct ceph_mds_request *req)
+{
+       kref_get(&req->r_kref);
+}
+extern void ceph_mdsc_release_request(struct kref *kref);
+static inline void ceph_mdsc_put_request(struct ceph_mds_request *req)
+{
+       kref_put(&req->r_kref, ceph_mdsc_release_request);
+}
+
+extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);
+
+extern char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
+                                 int stop_on_nosnap);
+
+extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);
+extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
+                                    struct inode *inode,
+                                    struct dentry *dentry, char action,
+                                    u32 seq);
+
+extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc,
+                                struct ceph_msg *msg);
+
+#endif
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
new file mode 100644 (file)
index 0000000..c4c498e
--- /dev/null
@@ -0,0 +1,174 @@
+#include "ceph_debug.h"
+
+#include <linux/bug.h>
+#include <linux/err.h>
+#include <linux/random.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include "mdsmap.h"
+#include "messenger.h"
+#include "decode.h"
+
+#include "super.h"
+
+
+/*
+ * choose a random mds that is "up" (i.e. has a state > 0), or -1.
+ */
+int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m)
+{
+       int n = 0;
+       int i;
+       char r;
+
+       /* count */
+       for (i = 0; i < m->m_max_mds; i++)
+               if (m->m_info[i].state > 0)
+                       n++;
+       if (n == 0)
+               return -1;
+
+       /* pick */
+       get_random_bytes(&r, 1);
+       n = r % n;
+       i = 0;
+       for (i = 0; n > 0; i++, n--)
+               while (m->m_info[i].state <= 0)
+                       i++;
+
+       return i;
+}
+
+/*
+ * Decode an MDS map
+ *
+ * Ignore any fields we don't care about (there are quite a few of
+ * them).
+ */
+struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
+{
+       struct ceph_mdsmap *m;
+       const void *start = *p;
+       int i, j, n;
+       int err = -EINVAL;
+       u16 version;
+
+       m = kzalloc(sizeof(*m), GFP_NOFS);
+       if (m == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       ceph_decode_16_safe(p, end, version, bad);
+
+       ceph_decode_need(p, end, 8*sizeof(u32) + sizeof(u64), bad);
+       m->m_epoch = ceph_decode_32(p);
+       m->m_client_epoch = ceph_decode_32(p);
+       m->m_last_failure = ceph_decode_32(p);
+       m->m_root = ceph_decode_32(p);
+       m->m_session_timeout = ceph_decode_32(p);
+       m->m_session_autoclose = ceph_decode_32(p);
+       m->m_max_file_size = ceph_decode_64(p);
+       m->m_max_mds = ceph_decode_32(p);
+
+       m->m_info = kcalloc(m->m_max_mds, sizeof(*m->m_info), GFP_NOFS);
+       if (m->m_info == NULL)
+               goto badmem;
+
+       /* pick out active nodes from mds_info (state > 0) */
+       n = ceph_decode_32(p);
+       for (i = 0; i < n; i++) {
+               u64 global_id;
+               u32 namelen;
+               s32 mds, inc, state;
+               u64 state_seq;
+               u8 infoversion;
+               struct ceph_entity_addr addr;
+               u32 num_export_targets;
+               void *pexport_targets = NULL;
+
+               ceph_decode_need(p, end, sizeof(u64)*2 + 1 + sizeof(u32), bad);
+               global_id = ceph_decode_64(p);
+               infoversion = ceph_decode_8(p);
+               *p += sizeof(u64);
+               namelen = ceph_decode_32(p);  /* skip mds name */
+               *p += namelen;
+
+               ceph_decode_need(p, end,
+                                4*sizeof(u32) + sizeof(u64) +
+                                sizeof(addr) + sizeof(struct ceph_timespec),
+                                bad);
+               mds = ceph_decode_32(p);
+               inc = ceph_decode_32(p);
+               state = ceph_decode_32(p);
+               state_seq = ceph_decode_64(p);
+               ceph_decode_copy(p, &addr, sizeof(addr));
+               ceph_decode_addr(&addr);
+               *p += sizeof(struct ceph_timespec);
+               *p += sizeof(u32);
+               ceph_decode_32_safe(p, end, namelen, bad);
+               *p += namelen;
+               if (infoversion >= 2) {
+                       ceph_decode_32_safe(p, end, num_export_targets, bad);
+                       pexport_targets = *p;
+                       *p += num_export_targets * sizeof(u32);
+               } else {
+                       num_export_targets = 0;
+               }
+
+               dout("mdsmap_decode %d/%d %lld mds%d.%d %s %s\n",
+                    i+1, n, global_id, mds, inc, pr_addr(&addr.in_addr),
+                    ceph_mds_state_name(state));
+               if (mds >= 0 && mds < m->m_max_mds && state > 0) {
+                       m->m_info[mds].global_id = global_id;
+                       m->m_info[mds].state = state;
+                       m->m_info[mds].addr = addr;
+                       m->m_info[mds].num_export_targets = num_export_targets;
+                       if (num_export_targets) {
+                               m->m_info[mds].export_targets =
+                                       kcalloc(num_export_targets, sizeof(u32),
+                                               GFP_NOFS);
+                               for (j = 0; j < num_export_targets; j++)
+                                       m->m_info[mds].export_targets[j] =
+                                              ceph_decode_32(&pexport_targets);
+                       } else {
+                               m->m_info[mds].export_targets = NULL;
+                       }
+               }
+       }
+
+       /* pg_pools */
+       ceph_decode_32_safe(p, end, n, bad);
+       m->m_num_data_pg_pools = n;
+       m->m_data_pg_pools = kcalloc(n, sizeof(u32), GFP_NOFS);
+       if (!m->m_data_pg_pools)
+               goto badmem;
+       ceph_decode_need(p, end, sizeof(u32)*(n+1), bad);
+       for (i = 0; i < n; i++)
+               m->m_data_pg_pools[i] = ceph_decode_32(p);
+       m->m_cas_pg_pool = ceph_decode_32(p);
+
+       /* ok, we don't care about the rest. */
+       dout("mdsmap_decode success epoch %u\n", m->m_epoch);
+       return m;
+
+badmem:
+       err = -ENOMEM;
+bad:
+       pr_err("corrupt mdsmap\n");
+       print_hex_dump(KERN_DEBUG, "mdsmap: ",
+                      DUMP_PREFIX_OFFSET, 16, 1,
+                      start, end - start, true);
+       ceph_mdsmap_destroy(m);
+       return ERR_PTR(-EINVAL);
+}
+
+void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
+{
+       int i;
+
+       for (i = 0; i < m->m_max_mds; i++)
+               kfree(m->m_info[i].export_targets);
+       kfree(m->m_info);
+       kfree(m->m_data_pg_pools);
+       kfree(m);
+}
diff --git a/fs/ceph/mdsmap.h b/fs/ceph/mdsmap.h
new file mode 100644 (file)
index 0000000..eacc131
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _FS_CEPH_MDSMAP_H
+#define _FS_CEPH_MDSMAP_H
+
+#include "types.h"
+
+/*
+ * mds map - describe servers in the mds cluster.
+ *
+ * we limit fields to those the client actually xcares about
+ */
+struct ceph_mds_info {
+       u64 global_id;
+       struct ceph_entity_addr addr;
+       s32 state;
+       int num_export_targets;
+       u32 *export_targets;
+};
+
+struct ceph_mdsmap {
+       u32 m_epoch, m_client_epoch, m_last_failure;
+       u32 m_root;
+       u32 m_session_timeout;          /* seconds */
+       u32 m_session_autoclose;        /* seconds */
+       u64 m_max_file_size;
+       u32 m_max_mds;                  /* size of m_addr, m_state arrays */
+       struct ceph_mds_info *m_info;
+
+       /* which object pools file data can be stored in */
+       int m_num_data_pg_pools;
+       u32 *m_data_pg_pools;
+       u32 m_cas_pg_pool;
+};
+
+static inline struct ceph_entity_addr *
+ceph_mdsmap_get_addr(struct ceph_mdsmap *m, int w)
+{
+       if (w >= m->m_max_mds)
+               return NULL;
+       return &m->m_info[w].addr;
+}
+
+static inline int ceph_mdsmap_get_state(struct ceph_mdsmap *m, int w)
+{
+       BUG_ON(w < 0);
+       if (w >= m->m_max_mds)
+               return CEPH_MDS_STATE_DNE;
+       return m->m_info[w].state;
+}
+
+extern int ceph_mdsmap_get_random_mds(struct ceph_mdsmap *m);
+extern struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end);
+extern void ceph_mdsmap_destroy(struct ceph_mdsmap *m);
+
+#endif
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
new file mode 100644 (file)
index 0000000..8f1715f
--- /dev/null
@@ -0,0 +1,2240 @@
+#include "ceph_debug.h"
+
+#include <linux/crc32c.h>
+#include <linux/ctype.h>
+#include <linux/highmem.h>
+#include <linux/inet.h>
+#include <linux/kthread.h>
+#include <linux/net.h>
+#include <linux/slab.h>
+#include <linux/socket.h>
+#include <linux/string.h>
+#include <net/tcp.h>
+
+#include "super.h"
+#include "messenger.h"
+#include "decode.h"
+#include "pagelist.h"
+
+/*
+ * Ceph uses the messenger to exchange ceph_msg messages with other
+ * hosts in the system.  The messenger provides ordered and reliable
+ * delivery.  We tolerate TCP disconnects by reconnecting (with
+ * exponential backoff) in the case of a fault (disconnection, bad
+ * crc, protocol error).  Acks allow sent messages to be discarded by
+ * the sender.
+ */
+
+/* static tag bytes (protocol control messages) */
+static char tag_msg = CEPH_MSGR_TAG_MSG;
+static char tag_ack = CEPH_MSGR_TAG_ACK;
+static char tag_keepalive = CEPH_MSGR_TAG_KEEPALIVE;
+
+
+static void queue_con(struct ceph_connection *con);
+static void con_work(struct work_struct *);
+static void ceph_fault(struct ceph_connection *con);
+
+const char *ceph_name_type_str(int t)
+{
+       switch (t) {
+       case CEPH_ENTITY_TYPE_MON: return "mon";
+       case CEPH_ENTITY_TYPE_MDS: return "mds";
+       case CEPH_ENTITY_TYPE_OSD: return "osd";
+       case CEPH_ENTITY_TYPE_CLIENT: return "client";
+       case CEPH_ENTITY_TYPE_ADMIN: return "admin";
+       default: return "???";
+       }
+}
+
+/*
+ * nicely render a sockaddr as a string.
+ */
+#define MAX_ADDR_STR 20
+static char addr_str[MAX_ADDR_STR][40];
+static DEFINE_SPINLOCK(addr_str_lock);
+static int last_addr_str;
+
+const char *pr_addr(const struct sockaddr_storage *ss)
+{
+       int i;
+       char *s;
+       struct sockaddr_in *in4 = (void *)ss;
+       unsigned char *quad = (void *)&in4->sin_addr.s_addr;
+       struct sockaddr_in6 *in6 = (void *)ss;
+
+       spin_lock(&addr_str_lock);
+       i = last_addr_str++;
+       if (last_addr_str == MAX_ADDR_STR)
+               last_addr_str = 0;
+       spin_unlock(&addr_str_lock);
+       s = addr_str[i];
+
+       switch (ss->ss_family) {
+       case AF_INET:
+               sprintf(s, "%u.%u.%u.%u:%u",
+                       (unsigned int)quad[0],
+                       (unsigned int)quad[1],
+                       (unsigned int)quad[2],
+                       (unsigned int)quad[3],
+                       (unsigned int)ntohs(in4->sin_port));
+               break;
+
+       case AF_INET6:
+               sprintf(s, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x:%u",
+                       in6->sin6_addr.s6_addr16[0],
+                       in6->sin6_addr.s6_addr16[1],
+                       in6->sin6_addr.s6_addr16[2],
+                       in6->sin6_addr.s6_addr16[3],
+                       in6->sin6_addr.s6_addr16[4],
+                       in6->sin6_addr.s6_addr16[5],
+                       in6->sin6_addr.s6_addr16[6],
+                       in6->sin6_addr.s6_addr16[7],
+                       (unsigned int)ntohs(in6->sin6_port));
+               break;
+
+       default:
+               sprintf(s, "(unknown sockaddr family %d)", (int)ss->ss_family);
+       }
+
+       return s;
+}
+
+static void encode_my_addr(struct ceph_messenger *msgr)
+{
+       memcpy(&msgr->my_enc_addr, &msgr->inst.addr, sizeof(msgr->my_enc_addr));
+       ceph_encode_addr(&msgr->my_enc_addr);
+}
+
+/*
+ * work queue for all reading and writing to/from the socket.
+ */
+struct workqueue_struct *ceph_msgr_wq;
+
+int __init ceph_msgr_init(void)
+{
+       ceph_msgr_wq = create_workqueue("ceph-msgr");
+       if (IS_ERR(ceph_msgr_wq)) {
+               int ret = PTR_ERR(ceph_msgr_wq);
+               pr_err("msgr_init failed to create workqueue: %d\n", ret);
+               ceph_msgr_wq = NULL;
+               return ret;
+       }
+       return 0;
+}
+
+void ceph_msgr_exit(void)
+{
+       destroy_workqueue(ceph_msgr_wq);
+}
+
+/*
+ * socket callback functions
+ */
+
+/* data available on socket, or listen socket received a connect */
+static void ceph_data_ready(struct sock *sk, int count_unused)
+{
+       struct ceph_connection *con =
+               (struct ceph_connection *)sk->sk_user_data;
+       if (sk->sk_state != TCP_CLOSE_WAIT) {
+               dout("ceph_data_ready on %p state = %lu, queueing work\n",
+                    con, con->state);
+               queue_con(con);
+       }
+}
+
+/* socket has buffer space for writing */
+static void ceph_write_space(struct sock *sk)
+{
+       struct ceph_connection *con =
+               (struct ceph_connection *)sk->sk_user_data;
+
+       /* only queue to workqueue if there is data we want to write. */
+       if (test_bit(WRITE_PENDING, &con->state)) {
+               dout("ceph_write_space %p queueing write work\n", con);
+               queue_con(con);
+       } else {
+               dout("ceph_write_space %p nothing to write\n", con);
+       }
+
+       /* since we have our own write_space, clear the SOCK_NOSPACE flag */
+       clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+}
+
+/* socket's state has changed */
+static void ceph_state_change(struct sock *sk)
+{
+       struct ceph_connection *con =
+               (struct ceph_connection *)sk->sk_user_data;
+
+       dout("ceph_state_change %p state = %lu sk_state = %u\n",
+            con, con->state, sk->sk_state);
+
+       if (test_bit(CLOSED, &con->state))
+               return;
+
+       switch (sk->sk_state) {
+       case TCP_CLOSE:
+               dout("ceph_state_change TCP_CLOSE\n");
+       case TCP_CLOSE_WAIT:
+               dout("ceph_state_change TCP_CLOSE_WAIT\n");
+               if (test_and_set_bit(SOCK_CLOSED, &con->state) == 0) {
+                       if (test_bit(CONNECTING, &con->state))
+                               con->error_msg = "connection failed";
+                       else
+                               con->error_msg = "socket closed";
+                       queue_con(con);
+               }
+               break;
+       case TCP_ESTABLISHED:
+               dout("ceph_state_change TCP_ESTABLISHED\n");
+               queue_con(con);
+               break;
+       }
+}
+
+/*
+ * set up socket callbacks
+ */
+static void set_sock_callbacks(struct socket *sock,
+                              struct ceph_connection *con)
+{
+       struct sock *sk = sock->sk;
+       sk->sk_user_data = (void *)con;
+       sk->sk_data_ready = ceph_data_ready;
+       sk->sk_write_space = ceph_write_space;
+       sk->sk_state_change = ceph_state_change;
+}
+
+
+/*
+ * socket helpers
+ */
+
+/*
+ * initiate connection to a remote socket.
+ */
+static struct socket *ceph_tcp_connect(struct ceph_connection *con)
+{
+       struct sockaddr *paddr = (struct sockaddr *)&con->peer_addr.in_addr;
+       struct socket *sock;
+       int ret;
+
+       BUG_ON(con->sock);
+       ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
+       if (ret)
+               return ERR_PTR(ret);
+       con->sock = sock;
+       sock->sk->sk_allocation = GFP_NOFS;
+
+       set_sock_callbacks(sock, con);
+
+       dout("connect %s\n", pr_addr(&con->peer_addr.in_addr));
+
+       ret = sock->ops->connect(sock, paddr, sizeof(*paddr), O_NONBLOCK);
+       if (ret == -EINPROGRESS) {
+               dout("connect %s EINPROGRESS sk_state = %u\n",
+                    pr_addr(&con->peer_addr.in_addr),
+                    sock->sk->sk_state);
+               ret = 0;
+       }
+       if (ret < 0) {
+               pr_err("connect %s error %d\n",
+                      pr_addr(&con->peer_addr.in_addr), ret);
+               sock_release(sock);
+               con->sock = NULL;
+               con->error_msg = "connect error";
+       }
+
+       if (ret < 0)
+               return ERR_PTR(ret);
+       return sock;
+}
+
+static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
+{
+       struct kvec iov = {buf, len};
+       struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
+
+       return kernel_recvmsg(sock, &msg, &iov, 1, len, msg.msg_flags);
+}
+
+/*
+ * write something.  @more is true if caller will be sending more data
+ * shortly.
+ */
+static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov,
+                    size_t kvlen, size_t len, int more)
+{
+       struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
+
+       if (more)
+               msg.msg_flags |= MSG_MORE;
+       else
+               msg.msg_flags |= MSG_EOR;  /* superfluous, but what the hell */
+
+       return kernel_sendmsg(sock, &msg, iov, kvlen, len);
+}
+
+
+/*
+ * Shutdown/close the socket for the given connection.
+ */
+static int con_close_socket(struct ceph_connection *con)
+{
+       int rc;
+
+       dout("con_close_socket on %p sock %p\n", con, con->sock);
+       if (!con->sock)
+               return 0;
+       set_bit(SOCK_CLOSED, &con->state);
+       rc = con->sock->ops->shutdown(con->sock, SHUT_RDWR);
+       sock_release(con->sock);
+       con->sock = NULL;
+       clear_bit(SOCK_CLOSED, &con->state);
+       return rc;
+}
+
+/*
+ * Reset a connection.  Discard all incoming and outgoing messages
+ * and clear *_seq state.
+ */
+static void ceph_msg_remove(struct ceph_msg *msg)
+{
+       list_del_init(&msg->list_head);
+       ceph_msg_put(msg);
+}
+static void ceph_msg_remove_list(struct list_head *head)
+{
+       while (!list_empty(head)) {
+               struct ceph_msg *msg = list_first_entry(head, struct ceph_msg,
+                                                       list_head);
+               ceph_msg_remove(msg);
+       }
+}
+
+static void reset_connection(struct ceph_connection *con)
+{
+       /* reset connection, out_queue, msg_ and connect_seq */
+       /* discard existing out_queue and msg_seq */
+       ceph_msg_remove_list(&con->out_queue);
+       ceph_msg_remove_list(&con->out_sent);
+
+       if (con->in_msg) {
+               ceph_msg_put(con->in_msg);
+               con->in_msg = NULL;
+       }
+
+       con->connect_seq = 0;
+       con->out_seq = 0;
+       if (con->out_msg) {
+               ceph_msg_put(con->out_msg);
+               con->out_msg = NULL;
+       }
+       con->in_seq = 0;
+}
+
+/*
+ * mark a peer down.  drop any open connections.
+ */
+void ceph_con_close(struct ceph_connection *con)
+{
+       dout("con_close %p peer %s\n", con, pr_addr(&con->peer_addr.in_addr));
+       set_bit(CLOSED, &con->state);  /* in case there's queued work */
+       clear_bit(STANDBY, &con->state);  /* avoid connect_seq bump */
+       clear_bit(LOSSYTX, &con->state);  /* so we retry next connect */
+       clear_bit(KEEPALIVE_PENDING, &con->state);
+       clear_bit(WRITE_PENDING, &con->state);
+       mutex_lock(&con->mutex);
+       reset_connection(con);
+       cancel_delayed_work(&con->work);
+       mutex_unlock(&con->mutex);
+       queue_con(con);
+}
+
+/*
+ * Reopen a closed connection, with a new peer address.
+ */
+void ceph_con_open(struct ceph_connection *con, struct ceph_entity_addr *addr)
+{
+       dout("con_open %p %s\n", con, pr_addr(&addr->in_addr));
+       set_bit(OPENING, &con->state);
+       clear_bit(CLOSED, &con->state);
+       memcpy(&con->peer_addr, addr, sizeof(*addr));
+       con->delay = 0;      /* reset backoff memory */
+       queue_con(con);
+}
+
+/*
+ * return true if this connection ever successfully opened
+ */
+bool ceph_con_opened(struct ceph_connection *con)
+{
+       return con->connect_seq > 0;
+}
+
+/*
+ * generic get/put
+ */
+struct ceph_connection *ceph_con_get(struct ceph_connection *con)
+{
+       dout("con_get %p nref = %d -> %d\n", con,
+            atomic_read(&con->nref), atomic_read(&con->nref) + 1);
+       if (atomic_inc_not_zero(&con->nref))
+               return con;
+       return NULL;
+}
+
+void ceph_con_put(struct ceph_connection *con)
+{
+       dout("con_put %p nref = %d -> %d\n", con,
+            atomic_read(&con->nref), atomic_read(&con->nref) - 1);
+       BUG_ON(atomic_read(&con->nref) == 0);
+       if (atomic_dec_and_test(&con->nref)) {
+               BUG_ON(con->sock);
+               kfree(con);
+       }
+}
+
+/*
+ * initialize a new connection.
+ */
+void ceph_con_init(struct ceph_messenger *msgr, struct ceph_connection *con)
+{
+       dout("con_init %p\n", con);
+       memset(con, 0, sizeof(*con));
+       atomic_set(&con->nref, 1);
+       con->msgr = msgr;
+       mutex_init(&con->mutex);
+       INIT_LIST_HEAD(&con->out_queue);
+       INIT_LIST_HEAD(&con->out_sent);
+       INIT_DELAYED_WORK(&con->work, con_work);
+}
+
+
+/*
+ * We maintain a global counter to order connection attempts.  Get
+ * a unique seq greater than @gt.
+ */
+static u32 get_global_seq(struct ceph_messenger *msgr, u32 gt)
+{
+       u32 ret;
+
+       spin_lock(&msgr->global_seq_lock);
+       if (msgr->global_seq < gt)
+               msgr->global_seq = gt;
+       ret = ++msgr->global_seq;
+       spin_unlock(&msgr->global_seq_lock);
+       return ret;
+}
+
+
+/*
+ * Prepare footer for currently outgoing message, and finish things
+ * off.  Assumes out_kvec* are already valid.. we just add on to the end.
+ */
+static void prepare_write_message_footer(struct ceph_connection *con, int v)
+{
+       struct ceph_msg *m = con->out_msg;
+
+       dout("prepare_write_message_footer %p\n", con);
+       con->out_kvec_is_msg = true;
+       con->out_kvec[v].iov_base = &m->footer;
+       con->out_kvec[v].iov_len = sizeof(m->footer);
+       con->out_kvec_bytes += sizeof(m->footer);
+       con->out_kvec_left++;
+       con->out_more = m->more_to_follow;
+       con->out_msg_done = true;
+}
+
+/*
+ * Prepare headers for the next outgoing message.
+ */
+static void prepare_write_message(struct ceph_connection *con)
+{
+       struct ceph_msg *m;
+       int v = 0;
+
+       con->out_kvec_bytes = 0;
+       con->out_kvec_is_msg = true;
+       con->out_msg_done = false;
+
+       /* Sneak an ack in there first?  If we can get it into the same
+        * TCP packet that's a good thing. */
+       if (con->in_seq > con->in_seq_acked) {
+               con->in_seq_acked = con->in_seq;
+               con->out_kvec[v].iov_base = &tag_ack;
+               con->out_kvec[v++].iov_len = 1;
+               con->out_temp_ack = cpu_to_le64(con->in_seq_acked);
+               con->out_kvec[v].iov_base = &con->out_temp_ack;
+               con->out_kvec[v++].iov_len = sizeof(con->out_temp_ack);
+               con->out_kvec_bytes = 1 + sizeof(con->out_temp_ack);
+       }
+
+       m = list_first_entry(&con->out_queue,
+                      struct ceph_msg, list_head);
+       con->out_msg = m;
+       if (test_bit(LOSSYTX, &con->state)) {
+               list_del_init(&m->list_head);
+       } else {
+               /* put message on sent list */
+               ceph_msg_get(m);
+               list_move_tail(&m->list_head, &con->out_sent);
+       }
+
+       m->hdr.seq = cpu_to_le64(++con->out_seq);
+
+       dout("prepare_write_message %p seq %lld type %d len %d+%d+%d %d pgs\n",
+            m, con->out_seq, le16_to_cpu(m->hdr.type),
+            le32_to_cpu(m->hdr.front_len), le32_to_cpu(m->hdr.middle_len),
+            le32_to_cpu(m->hdr.data_len),
+            m->nr_pages);
+       BUG_ON(le32_to_cpu(m->hdr.front_len) != m->front.iov_len);
+
+       /* tag + hdr + front + middle */
+       con->out_kvec[v].iov_base = &tag_msg;
+       con->out_kvec[v++].iov_len = 1;
+       con->out_kvec[v].iov_base = &m->hdr;
+       con->out_kvec[v++].iov_len = sizeof(m->hdr);
+       con->out_kvec[v++] = m->front;
+       if (m->middle)
+               con->out_kvec[v++] = m->middle->vec;
+       con->out_kvec_left = v;
+       con->out_kvec_bytes += 1 + sizeof(m->hdr) + m->front.iov_len +
+               (m->middle ? m->middle->vec.iov_len : 0);
+       con->out_kvec_cur = con->out_kvec;
+
+       /* fill in crc (except data pages), footer */
+       con->out_msg->hdr.crc =
+               cpu_to_le32(crc32c(0, (void *)&m->hdr,
+                                     sizeof(m->hdr) - sizeof(m->hdr.crc)));
+       con->out_msg->footer.flags = CEPH_MSG_FOOTER_COMPLETE;
+       con->out_msg->footer.front_crc =
+               cpu_to_le32(crc32c(0, m->front.iov_base, m->front.iov_len));
+       if (m->middle)
+               con->out_msg->footer.middle_crc =
+                       cpu_to_le32(crc32c(0, m->middle->vec.iov_base,
+                                          m->middle->vec.iov_len));
+       else
+               con->out_msg->footer.middle_crc = 0;
+       con->out_msg->footer.data_crc = 0;
+       dout("prepare_write_message front_crc %u data_crc %u\n",
+            le32_to_cpu(con->out_msg->footer.front_crc),
+            le32_to_cpu(con->out_msg->footer.middle_crc));
+
+       /* is there a data payload? */
+       if (le32_to_cpu(m->hdr.data_len) > 0) {
+               /* initialize page iterator */
+               con->out_msg_pos.page = 0;
+               con->out_msg_pos.page_pos =
+                       le16_to_cpu(m->hdr.data_off) & ~PAGE_MASK;
+               con->out_msg_pos.data_pos = 0;
+               con->out_msg_pos.did_page_crc = 0;
+               con->out_more = 1;  /* data + footer will follow */
+       } else {
+               /* no, queue up footer too and be done */
+               prepare_write_message_footer(con, v);
+       }
+
+       set_bit(WRITE_PENDING, &con->state);
+}
+
+/*
+ * Prepare an ack.
+ */
+static void prepare_write_ack(struct ceph_connection *con)
+{
+       dout("prepare_write_ack %p %llu -> %llu\n", con,
+            con->in_seq_acked, con->in_seq);
+       con->in_seq_acked = con->in_seq;
+
+       con->out_kvec[0].iov_base = &tag_ack;
+       con->out_kvec[0].iov_len = 1;
+       con->out_temp_ack = cpu_to_le64(con->in_seq_acked);
+       con->out_kvec[1].iov_base = &con->out_temp_ack;
+       con->out_kvec[1].iov_len = sizeof(con->out_temp_ack);
+       con->out_kvec_left = 2;
+       con->out_kvec_bytes = 1 + sizeof(con->out_temp_ack);
+       con->out_kvec_cur = con->out_kvec;
+       con->out_more = 1;  /* more will follow.. eventually.. */
+       set_bit(WRITE_PENDING, &con->state);
+}
+
+/*
+ * Prepare to write keepalive byte.
+ */
+static void prepare_write_keepalive(struct ceph_connection *con)
+{
+       dout("prepare_write_keepalive %p\n", con);
+       con->out_kvec[0].iov_base = &tag_keepalive;
+       con->out_kvec[0].iov_len = 1;
+       con->out_kvec_left = 1;
+       con->out_kvec_bytes = 1;
+       con->out_kvec_cur = con->out_kvec;
+       set_bit(WRITE_PENDING, &con->state);
+}
+
+/*
+ * Connection negotiation.
+ */
+
+static void prepare_connect_authorizer(struct ceph_connection *con)
+{
+       void *auth_buf;
+       int auth_len = 0;
+       int auth_protocol = 0;
+
+       mutex_unlock(&con->mutex);
+       if (con->ops->get_authorizer)
+               con->ops->get_authorizer(con, &auth_buf, &auth_len,
+                                        &auth_protocol, &con->auth_reply_buf,
+                                        &con->auth_reply_buf_len,
+                                        con->auth_retry);
+       mutex_lock(&con->mutex);
+
+       con->out_connect.authorizer_protocol = cpu_to_le32(auth_protocol);
+       con->out_connect.authorizer_len = cpu_to_le32(auth_len);
+
+       con->out_kvec[con->out_kvec_left].iov_base = auth_buf;
+       con->out_kvec[con->out_kvec_left].iov_len = auth_len;
+       con->out_kvec_left++;
+       con->out_kvec_bytes += auth_len;
+}
+
+/*
+ * We connected to a peer and are saying hello.
+ */
+static void prepare_write_banner(struct ceph_messenger *msgr,
+                                struct ceph_connection *con)
+{
+       int len = strlen(CEPH_BANNER);
+
+       con->out_kvec[0].iov_base = CEPH_BANNER;
+       con->out_kvec[0].iov_len = len;
+       con->out_kvec[1].iov_base = &msgr->my_enc_addr;
+       con->out_kvec[1].iov_len = sizeof(msgr->my_enc_addr);
+       con->out_kvec_left = 2;
+       con->out_kvec_bytes = len + sizeof(msgr->my_enc_addr);
+       con->out_kvec_cur = con->out_kvec;
+       con->out_more = 0;
+       set_bit(WRITE_PENDING, &con->state);
+}
+
+static void prepare_write_connect(struct ceph_messenger *msgr,
+                                 struct ceph_connection *con,
+                                 int after_banner)
+{
+       unsigned global_seq = get_global_seq(con->msgr, 0);
+       int proto;
+
+       switch (con->peer_name.type) {
+       case CEPH_ENTITY_TYPE_MON:
+               proto = CEPH_MONC_PROTOCOL;
+               break;
+       case CEPH_ENTITY_TYPE_OSD:
+               proto = CEPH_OSDC_PROTOCOL;
+               break;
+       case CEPH_ENTITY_TYPE_MDS:
+               proto = CEPH_MDSC_PROTOCOL;
+               break;
+       default:
+               BUG();
+       }
+
+       dout("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n", con,
+            con->connect_seq, global_seq, proto);
+
+       con->out_connect.features = CEPH_FEATURE_SUPPORTED;
+       con->out_connect.host_type = cpu_to_le32(CEPH_ENTITY_TYPE_CLIENT);
+       con->out_connect.connect_seq = cpu_to_le32(con->connect_seq);
+       con->out_connect.global_seq = cpu_to_le32(global_seq);
+       con->out_connect.protocol_version = cpu_to_le32(proto);
+       con->out_connect.flags = 0;
+
+       if (!after_banner) {
+               con->out_kvec_left = 0;
+               con->out_kvec_bytes = 0;
+       }
+       con->out_kvec[con->out_kvec_left].iov_base = &con->out_connect;
+       con->out_kvec[con->out_kvec_left].iov_len = sizeof(con->out_connect);
+       con->out_kvec_left++;
+       con->out_kvec_bytes += sizeof(con->out_connect);
+       con->out_kvec_cur = con->out_kvec;
+       con->out_more = 0;
+       set_bit(WRITE_PENDING, &con->state);
+
+       prepare_connect_authorizer(con);
+}
+
+
+/*
+ * write as much of pending kvecs to the socket as we can.
+ *  1 -> done
+ *  0 -> socket full, but more to do
+ * <0 -> error
+ */
+static int write_partial_kvec(struct ceph_connection *con)
+{
+       int ret;
+
+       dout("write_partial_kvec %p %d left\n", con, con->out_kvec_bytes);
+       while (con->out_kvec_bytes > 0) {
+               ret = ceph_tcp_sendmsg(con->sock, con->out_kvec_cur,
+                                      con->out_kvec_left, con->out_kvec_bytes,
+                                      con->out_more);
+               if (ret <= 0)
+                       goto out;
+               con->out_kvec_bytes -= ret;
+               if (con->out_kvec_bytes == 0)
+                       break;            /* done */
+               while (ret > 0) {
+                       if (ret >= con->out_kvec_cur->iov_len) {
+                               ret -= con->out_kvec_cur->iov_len;
+                               con->out_kvec_cur++;
+                               con->out_kvec_left--;
+                       } else {
+                               con->out_kvec_cur->iov_len -= ret;
+                               con->out_kvec_cur->iov_base += ret;
+                               ret = 0;
+                               break;
+                       }
+               }
+       }
+       con->out_kvec_left = 0;
+       con->out_kvec_is_msg = false;
+       ret = 1;
+out:
+       dout("write_partial_kvec %p %d left in %d kvecs ret = %d\n", con,
+            con->out_kvec_bytes, con->out_kvec_left, ret);
+       return ret;  /* done! */
+}
+
+/*
+ * Write as much message data payload as we can.  If we finish, queue
+ * up the footer.
+ *  1 -> done, footer is now queued in out_kvec[].
+ *  0 -> socket full, but more to do
+ * <0 -> error
+ */
+static int write_partial_msg_pages(struct ceph_connection *con)
+{
+       struct ceph_msg *msg = con->out_msg;
+       unsigned data_len = le32_to_cpu(msg->hdr.data_len);
+       size_t len;
+       int crc = con->msgr->nocrc;
+       int ret;
+
+       dout("write_partial_msg_pages %p msg %p page %d/%d offset %d\n",
+            con, con->out_msg, con->out_msg_pos.page, con->out_msg->nr_pages,
+            con->out_msg_pos.page_pos);
+
+       while (con->out_msg_pos.page < con->out_msg->nr_pages) {
+               struct page *page = NULL;
+               void *kaddr = NULL;
+
+               /*
+                * if we are calculating the data crc (the default), we need
+                * to map the page.  if our pages[] has been revoked, use the
+                * zero page.
+                */
+               if (msg->pages) {
+                       page = msg->pages[con->out_msg_pos.page];
+                       if (crc)
+                               kaddr = kmap(page);
+               } else if (msg->pagelist) {
+                       page = list_first_entry(&msg->pagelist->head,
+                                               struct page, lru);
+                       if (crc)
+                               kaddr = kmap(page);
+               } else {
+                       page = con->msgr->zero_page;
+                       if (crc)
+                               kaddr = page_address(con->msgr->zero_page);
+               }
+               len = min((int)(PAGE_SIZE - con->out_msg_pos.page_pos),
+                         (int)(data_len - con->out_msg_pos.data_pos));
+               if (crc && !con->out_msg_pos.did_page_crc) {
+                       void *base = kaddr + con->out_msg_pos.page_pos;
+                       u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc);
+
+                       BUG_ON(kaddr == NULL);
+                       con->out_msg->footer.data_crc =
+                               cpu_to_le32(crc32c(tmpcrc, base, len));
+                       con->out_msg_pos.did_page_crc = 1;
+               }
+
+               ret = kernel_sendpage(con->sock, page,
+                                     con->out_msg_pos.page_pos, len,
+                                     MSG_DONTWAIT | MSG_NOSIGNAL |
+                                     MSG_MORE);
+
+               if (crc && (msg->pages || msg->pagelist))
+                       kunmap(page);
+
+               if (ret <= 0)
+                       goto out;
+
+               con->out_msg_pos.data_pos += ret;
+               con->out_msg_pos.page_pos += ret;
+               if (ret == len) {
+                       con->out_msg_pos.page_pos = 0;
+                       con->out_msg_pos.page++;
+                       con->out_msg_pos.did_page_crc = 0;
+                       if (msg->pagelist)
+                               list_move_tail(&page->lru,
+                                              &msg->pagelist->head);
+               }
+       }
+
+       dout("write_partial_msg_pages %p msg %p done\n", con, msg);
+
+       /* prepare and queue up footer, too */
+       if (!crc)
+               con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC;
+       con->out_kvec_bytes = 0;
+       con->out_kvec_left = 0;
+       con->out_kvec_cur = con->out_kvec;
+       prepare_write_message_footer(con, 0);
+       ret = 1;
+out:
+       return ret;
+}
+
+/*
+ * write some zeros
+ */
+static int write_partial_skip(struct ceph_connection *con)
+{
+       int ret;
+
+       while (con->out_skip > 0) {
+               struct kvec iov = {
+                       .iov_base = page_address(con->msgr->zero_page),
+                       .iov_len = min(con->out_skip, (int)PAGE_CACHE_SIZE)
+               };
+
+               ret = ceph_tcp_sendmsg(con->sock, &iov, 1, iov.iov_len, 1);
+               if (ret <= 0)
+                       goto out;
+               con->out_skip -= ret;
+       }
+       ret = 1;
+out:
+       return ret;
+}
+
+/*
+ * Prepare to read connection handshake, or an ack.
+ */
+static void prepare_read_banner(struct ceph_connection *con)
+{
+       dout("prepare_read_banner %p\n", con);
+       con->in_base_pos = 0;
+}
+
+static void prepare_read_connect(struct ceph_connection *con)
+{
+       dout("prepare_read_connect %p\n", con);
+       con->in_base_pos = 0;
+}
+
+static void prepare_read_ack(struct ceph_connection *con)
+{
+       dout("prepare_read_ack %p\n", con);
+       con->in_base_pos = 0;
+}
+
+static void prepare_read_tag(struct ceph_connection *con)
+{
+       dout("prepare_read_tag %p\n", con);
+       con->in_base_pos = 0;
+       con->in_tag = CEPH_MSGR_TAG_READY;
+}
+
+/*
+ * Prepare to read a message.
+ */
+static int prepare_read_message(struct ceph_connection *con)
+{
+       dout("prepare_read_message %p\n", con);
+       BUG_ON(con->in_msg != NULL);
+       con->in_base_pos = 0;
+       con->in_front_crc = con->in_middle_crc = con->in_data_crc = 0;
+       return 0;
+}
+
+
+static int read_partial(struct ceph_connection *con,
+                       int *to, int size, void *object)
+{
+       *to += size;
+       while (con->in_base_pos < *to) {
+               int left = *to - con->in_base_pos;
+               int have = size - left;
+               int ret = ceph_tcp_recvmsg(con->sock, object + have, left);
+               if (ret <= 0)
+                       return ret;
+               con->in_base_pos += ret;
+       }
+       return 1;
+}
+
+
+/*
+ * Read all or part of the connect-side handshake on a new connection
+ */
+static int read_partial_banner(struct ceph_connection *con)
+{
+       int ret, to = 0;
+
+       dout("read_partial_banner %p at %d\n", con, con->in_base_pos);
+
+       /* peer's banner */
+       ret = read_partial(con, &to, strlen(CEPH_BANNER), con->in_banner);
+       if (ret <= 0)
+               goto out;
+       ret = read_partial(con, &to, sizeof(con->actual_peer_addr),
+                          &con->actual_peer_addr);
+       if (ret <= 0)
+               goto out;
+       ret = read_partial(con, &to, sizeof(con->peer_addr_for_me),
+                          &con->peer_addr_for_me);
+       if (ret <= 0)
+               goto out;
+out:
+       return ret;
+}
+
+static int read_partial_connect(struct ceph_connection *con)
+{
+       int ret, to = 0;
+
+       dout("read_partial_connect %p at %d\n", con, con->in_base_pos);
+
+       ret = read_partial(con, &to, sizeof(con->in_reply), &con->in_reply);
+       if (ret <= 0)
+               goto out;
+       ret = read_partial(con, &to, le32_to_cpu(con->in_reply.authorizer_len),
+                          con->auth_reply_buf);
+       if (ret <= 0)
+               goto out;
+
+       dout("read_partial_connect %p tag %d, con_seq = %u, g_seq = %u\n",
+            con, (int)con->in_reply.tag,
+            le32_to_cpu(con->in_reply.connect_seq),
+            le32_to_cpu(con->in_reply.global_seq));
+out:
+       return ret;
+
+}
+
+/*
+ * Verify the hello banner looks okay.
+ */
+static int verify_hello(struct ceph_connection *con)
+{
+       if (memcmp(con->in_banner, CEPH_BANNER, strlen(CEPH_BANNER))) {
+               pr_err("connect to %s got bad banner\n",
+                      pr_addr(&con->peer_addr.in_addr));
+               con->error_msg = "protocol error, bad banner";
+               return -1;
+       }
+       return 0;
+}
+
+static bool addr_is_blank(struct sockaddr_storage *ss)
+{
+       switch (ss->ss_family) {
+       case AF_INET:
+               return ((struct sockaddr_in *)ss)->sin_addr.s_addr == 0;
+       case AF_INET6:
+               return
+                    ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[0] == 0 &&
+                    ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[1] == 0 &&
+                    ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[2] == 0 &&
+                    ((struct sockaddr_in6 *)ss)->sin6_addr.s6_addr32[3] == 0;
+       }
+       return false;
+}
+
+static int addr_port(struct sockaddr_storage *ss)
+{
+       switch (ss->ss_family) {
+       case AF_INET:
+               return ntohs(((struct sockaddr_in *)ss)->sin_port);
+       case AF_INET6:
+               return ntohs(((struct sockaddr_in6 *)ss)->sin6_port);
+       }
+       return 0;
+}
+
+static void addr_set_port(struct sockaddr_storage *ss, int p)
+{
+       switch (ss->ss_family) {
+       case AF_INET:
+               ((struct sockaddr_in *)ss)->sin_port = htons(p);
+       case AF_INET6:
+               ((struct sockaddr_in6 *)ss)->sin6_port = htons(p);
+       }
+}
+
+/*
+ * Parse an ip[:port] list into an addr array.  Use the default
+ * monitor port if a port isn't specified.
+ */
+int ceph_parse_ips(const char *c, const char *end,
+                  struct ceph_entity_addr *addr,
+                  int max_count, int *count)
+{
+       int i;
+       const char *p = c;
+
+       dout("parse_ips on '%.*s'\n", (int)(end-c), c);
+       for (i = 0; i < max_count; i++) {
+               const char *ipend;
+               struct sockaddr_storage *ss = &addr[i].in_addr;
+               struct sockaddr_in *in4 = (void *)ss;
+               struct sockaddr_in6 *in6 = (void *)ss;
+               int port;
+
+               memset(ss, 0, sizeof(*ss));
+               if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr,
+                            ',', &ipend)) {
+                       ss->ss_family = AF_INET;
+               } else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr,
+                                   ',', &ipend)) {
+                       ss->ss_family = AF_INET6;
+               } else {
+                       goto bad;
+               }
+               p = ipend;
+
+               /* port? */
+               if (p < end && *p == ':') {
+                       port = 0;
+                       p++;
+                       while (p < end && *p >= '0' && *p <= '9') {
+                               port = (port * 10) + (*p - '0');
+                               p++;
+                       }
+                       if (port > 65535 || port == 0)
+                               goto bad;
+               } else {
+                       port = CEPH_MON_PORT;
+               }
+
+               addr_set_port(ss, port);
+
+               dout("parse_ips got %s\n", pr_addr(ss));
+
+               if (p == end)
+                       break;
+               if (*p != ',')
+                       goto bad;
+               p++;
+       }
+
+       if (p != end)
+               goto bad;
+
+       if (count)
+               *count = i + 1;
+       return 0;
+
+bad:
+       pr_err("parse_ips bad ip '%s'\n", c);
+       return -EINVAL;
+}
+
+static int process_banner(struct ceph_connection *con)
+{
+       dout("process_banner on %p\n", con);
+
+       if (verify_hello(con) < 0)
+               return -1;
+
+       ceph_decode_addr(&con->actual_peer_addr);
+       ceph_decode_addr(&con->peer_addr_for_me);
+
+       /*
+        * Make sure the other end is who we wanted.  note that the other
+        * end may not yet know their ip address, so if it's 0.0.0.0, give
+        * them the benefit of the doubt.
+        */
+       if (memcmp(&con->peer_addr, &con->actual_peer_addr,
+                  sizeof(con->peer_addr)) != 0 &&
+           !(addr_is_blank(&con->actual_peer_addr.in_addr) &&
+             con->actual_peer_addr.nonce == con->peer_addr.nonce)) {
+               pr_warning("wrong peer, want %s/%lld, got %s/%lld\n",
+                          pr_addr(&con->peer_addr.in_addr),
+                          le64_to_cpu(con->peer_addr.nonce),
+                          pr_addr(&con->actual_peer_addr.in_addr),
+                          le64_to_cpu(con->actual_peer_addr.nonce));
+               con->error_msg = "wrong peer at address";
+               return -1;
+       }
+
+       /*
+        * did we learn our address?
+        */
+       if (addr_is_blank(&con->msgr->inst.addr.in_addr)) {
+               int port = addr_port(&con->msgr->inst.addr.in_addr);
+
+               memcpy(&con->msgr->inst.addr.in_addr,
+                      &con->peer_addr_for_me.in_addr,
+                      sizeof(con->peer_addr_for_me.in_addr));
+               addr_set_port(&con->msgr->inst.addr.in_addr, port);
+               encode_my_addr(con->msgr);
+               dout("process_banner learned my addr is %s\n",
+                    pr_addr(&con->msgr->inst.addr.in_addr));
+       }
+
+       set_bit(NEGOTIATING, &con->state);
+       prepare_read_connect(con);
+       return 0;
+}
+
+static void fail_protocol(struct ceph_connection *con)
+{
+       reset_connection(con);
+       set_bit(CLOSED, &con->state);  /* in case there's queued work */
+
+       mutex_unlock(&con->mutex);
+       if (con->ops->bad_proto)
+               con->ops->bad_proto(con);
+       mutex_lock(&con->mutex);
+}
+
+static int process_connect(struct ceph_connection *con)
+{
+       u64 sup_feat = CEPH_FEATURE_SUPPORTED;
+       u64 req_feat = CEPH_FEATURE_REQUIRED;
+       u64 server_feat = le64_to_cpu(con->in_reply.features);
+
+       dout("process_connect on %p tag %d\n", con, (int)con->in_tag);
+
+       switch (con->in_reply.tag) {
+       case CEPH_MSGR_TAG_FEATURES:
+               pr_err("%s%lld %s feature set mismatch,"
+                      " my %llx < server's %llx, missing %llx\n",
+                      ENTITY_NAME(con->peer_name),
+                      pr_addr(&con->peer_addr.in_addr),
+                      sup_feat, server_feat, server_feat & ~sup_feat);
+               con->error_msg = "missing required protocol features";
+               fail_protocol(con);
+               return -1;
+
+       case CEPH_MSGR_TAG_BADPROTOVER:
+               pr_err("%s%lld %s protocol version mismatch,"
+                      " my %d != server's %d\n",
+                      ENTITY_NAME(con->peer_name),
+                      pr_addr(&con->peer_addr.in_addr),
+                      le32_to_cpu(con->out_connect.protocol_version),
+                      le32_to_cpu(con->in_reply.protocol_version));
+               con->error_msg = "protocol version mismatch";
+               fail_protocol(con);
+               return -1;
+
+       case CEPH_MSGR_TAG_BADAUTHORIZER:
+               con->auth_retry++;
+               dout("process_connect %p got BADAUTHORIZER attempt %d\n", con,
+                    con->auth_retry);
+               if (con->auth_retry == 2) {
+                       con->error_msg = "connect authorization failure";
+                       reset_connection(con);
+                       set_bit(CLOSED, &con->state);
+                       return -1;
+               }
+               con->auth_retry = 1;
+               prepare_write_connect(con->msgr, con, 0);
+               prepare_read_connect(con);
+               break;
+
+       case CEPH_MSGR_TAG_RESETSESSION:
+               /*
+                * If we connected with a large connect_seq but the peer
+                * has no record of a session with us (no connection, or
+                * connect_seq == 0), they will send RESETSESION to indicate
+                * that they must have reset their session, and may have
+                * dropped messages.
+                */
+               dout("process_connect got RESET peer seq %u\n",
+                    le32_to_cpu(con->in_connect.connect_seq));
+               pr_err("%s%lld %s connection reset\n",
+                      ENTITY_NAME(con->peer_name),
+                      pr_addr(&con->peer_addr.in_addr));
+               reset_connection(con);
+               prepare_write_connect(con->msgr, con, 0);
+               prepare_read_connect(con);
+
+               /* Tell ceph about it. */
+               mutex_unlock(&con->mutex);
+               pr_info("reset on %s%lld\n", ENTITY_NAME(con->peer_name));
+               if (con->ops->peer_reset)
+                       con->ops->peer_reset(con);
+               mutex_lock(&con->mutex);
+               break;
+
+       case CEPH_MSGR_TAG_RETRY_SESSION:
+               /*
+                * If we sent a smaller connect_seq than the peer has, try
+                * again with a larger value.
+                */
+               dout("process_connect got RETRY my seq = %u, peer_seq = %u\n",
+                    le32_to_cpu(con->out_connect.connect_seq),
+                    le32_to_cpu(con->in_connect.connect_seq));
+               con->connect_seq = le32_to_cpu(con->in_connect.connect_seq);
+               prepare_write_connect(con->msgr, con, 0);
+               prepare_read_connect(con);
+               break;
+
+       case CEPH_MSGR_TAG_RETRY_GLOBAL:
+               /*
+                * If we sent a smaller global_seq than the peer has, try
+                * again with a larger value.
+                */
+               dout("process_connect got RETRY_GLOBAL my %u peer_gseq %u\n",
+                    con->peer_global_seq,
+                    le32_to_cpu(con->in_connect.global_seq));
+               get_global_seq(con->msgr,
+                              le32_to_cpu(con->in_connect.global_seq));
+               prepare_write_connect(con->msgr, con, 0);
+               prepare_read_connect(con);
+               break;
+
+       case CEPH_MSGR_TAG_READY:
+               if (req_feat & ~server_feat) {
+                       pr_err("%s%lld %s protocol feature mismatch,"
+                              " my required %llx > server's %llx, need %llx\n",
+                              ENTITY_NAME(con->peer_name),
+                              pr_addr(&con->peer_addr.in_addr),
+                              req_feat, server_feat, req_feat & ~server_feat);
+                       con->error_msg = "missing required protocol features";
+                       fail_protocol(con);
+                       return -1;
+               }
+               clear_bit(CONNECTING, &con->state);
+               con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);
+               con->connect_seq++;
+               dout("process_connect got READY gseq %d cseq %d (%d)\n",
+                    con->peer_global_seq,
+                    le32_to_cpu(con->in_reply.connect_seq),
+                    con->connect_seq);
+               WARN_ON(con->connect_seq !=
+                       le32_to_cpu(con->in_reply.connect_seq));
+
+               if (con->in_reply.flags & CEPH_MSG_CONNECT_LOSSY)
+                       set_bit(LOSSYTX, &con->state);
+
+               prepare_read_tag(con);
+               break;
+
+       case CEPH_MSGR_TAG_WAIT:
+               /*
+                * If there is a connection race (we are opening
+                * connections to each other), one of us may just have
+                * to WAIT.  This shouldn't happen if we are the
+                * client.
+                */
+               pr_err("process_connect peer connecting WAIT\n");
+
+       default:
+               pr_err("connect protocol error, will retry\n");
+               con->error_msg = "protocol error, garbage tag during connect";
+               return -1;
+       }
+       return 0;
+}
+
+
+/*
+ * read (part of) an ack
+ */
+static int read_partial_ack(struct ceph_connection *con)
+{
+       int to = 0;
+
+       return read_partial(con, &to, sizeof(con->in_temp_ack),
+                           &con->in_temp_ack);
+}
+
+
+/*
+ * We can finally discard anything that's been acked.
+ */
+static void process_ack(struct ceph_connection *con)
+{
+       struct ceph_msg *m;
+       u64 ack = le64_to_cpu(con->in_temp_ack);
+       u64 seq;
+
+       while (!list_empty(&con->out_sent)) {
+               m = list_first_entry(&con->out_sent, struct ceph_msg,
+                                    list_head);
+               seq = le64_to_cpu(m->hdr.seq);
+               if (seq > ack)
+                       break;
+               dout("got ack for seq %llu type %d at %p\n", seq,
+                    le16_to_cpu(m->hdr.type), m);
+               ceph_msg_remove(m);
+       }
+       prepare_read_tag(con);
+}
+
+
+
+
+static int read_partial_message_section(struct ceph_connection *con,
+                                       struct kvec *section, unsigned int sec_len,
+                                       u32 *crc)
+{
+       int left;
+       int ret;
+
+       BUG_ON(!section);
+
+       while (section->iov_len < sec_len) {
+               BUG_ON(section->iov_base == NULL);
+               left = sec_len - section->iov_len;
+               ret = ceph_tcp_recvmsg(con->sock, (char *)section->iov_base +
+                                      section->iov_len, left);
+               if (ret <= 0)
+                       return ret;
+               section->iov_len += ret;
+               if (section->iov_len == sec_len)
+                       *crc = crc32c(0, section->iov_base,
+                                     section->iov_len);
+       }
+
+       return 1;
+}
+
+static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
+                               struct ceph_msg_header *hdr,
+                               int *skip);
+/*
+ * read (part of) a message.
+ */
+static int read_partial_message(struct ceph_connection *con)
+{
+       struct ceph_msg *m = con->in_msg;
+       void *p;
+       int ret;
+       int to, left;
+       unsigned front_len, middle_len, data_len, data_off;
+       int datacrc = con->msgr->nocrc;
+       int skip;
+
+       dout("read_partial_message con %p msg %p\n", con, m);
+
+       /* header */
+       while (con->in_base_pos < sizeof(con->in_hdr)) {
+               left = sizeof(con->in_hdr) - con->in_base_pos;
+               ret = ceph_tcp_recvmsg(con->sock,
+                                      (char *)&con->in_hdr + con->in_base_pos,
+                                      left);
+               if (ret <= 0)
+                       return ret;
+               con->in_base_pos += ret;
+               if (con->in_base_pos == sizeof(con->in_hdr)) {
+                       u32 crc = crc32c(0, (void *)&con->in_hdr,
+                                sizeof(con->in_hdr) - sizeof(con->in_hdr.crc));
+                       if (crc != le32_to_cpu(con->in_hdr.crc)) {
+                               pr_err("read_partial_message bad hdr "
+                                      " crc %u != expected %u\n",
+                                      crc, con->in_hdr.crc);
+                               return -EBADMSG;
+                       }
+               }
+       }
+       front_len = le32_to_cpu(con->in_hdr.front_len);
+       if (front_len > CEPH_MSG_MAX_FRONT_LEN)
+               return -EIO;
+       middle_len = le32_to_cpu(con->in_hdr.middle_len);
+       if (middle_len > CEPH_MSG_MAX_DATA_LEN)
+               return -EIO;
+       data_len = le32_to_cpu(con->in_hdr.data_len);
+       if (data_len > CEPH_MSG_MAX_DATA_LEN)
+               return -EIO;
+       data_off = le16_to_cpu(con->in_hdr.data_off);
+
+       /* allocate message? */
+       if (!con->in_msg) {
+               dout("got hdr type %d front %d data %d\n", con->in_hdr.type,
+                    con->in_hdr.front_len, con->in_hdr.data_len);
+               con->in_msg = ceph_alloc_msg(con, &con->in_hdr, &skip);
+               if (skip) {
+                       /* skip this message */
+                       dout("alloc_msg returned NULL, skipping message\n");
+                       con->in_base_pos = -front_len - middle_len - data_len -
+                               sizeof(m->footer);
+                       con->in_tag = CEPH_MSGR_TAG_READY;
+                       return 0;
+               }
+               if (IS_ERR(con->in_msg)) {
+                       ret = PTR_ERR(con->in_msg);
+                       con->in_msg = NULL;
+                       con->error_msg =
+                               "error allocating memory for incoming message";
+                       return ret;
+               }
+               m = con->in_msg;
+               m->front.iov_len = 0;    /* haven't read it yet */
+               if (m->middle)
+                       m->middle->vec.iov_len = 0;
+
+               con->in_msg_pos.page = 0;
+               con->in_msg_pos.page_pos = data_off & ~PAGE_MASK;
+               con->in_msg_pos.data_pos = 0;
+       }
+
+       /* front */
+       ret = read_partial_message_section(con, &m->front, front_len,
+                                          &con->in_front_crc);
+       if (ret <= 0)
+               return ret;
+
+       /* middle */
+       if (m->middle) {
+               ret = read_partial_message_section(con, &m->middle->vec, middle_len,
+                                                  &con->in_middle_crc);
+               if (ret <= 0)
+                       return ret;
+       }
+
+       /* (page) data */
+       while (con->in_msg_pos.data_pos < data_len) {
+               left = min((int)(data_len - con->in_msg_pos.data_pos),
+                          (int)(PAGE_SIZE - con->in_msg_pos.page_pos));
+               BUG_ON(m->pages == NULL);
+               p = kmap(m->pages[con->in_msg_pos.page]);
+               ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos,
+                                      left);
+               if (ret > 0 && datacrc)
+                       con->in_data_crc =
+                               crc32c(con->in_data_crc,
+                                         p + con->in_msg_pos.page_pos, ret);
+               kunmap(m->pages[con->in_msg_pos.page]);
+               if (ret <= 0)
+                       return ret;
+               con->in_msg_pos.data_pos += ret;
+               con->in_msg_pos.page_pos += ret;
+               if (con->in_msg_pos.page_pos == PAGE_SIZE) {
+                       con->in_msg_pos.page_pos = 0;
+                       con->in_msg_pos.page++;
+               }
+       }
+
+       /* footer */
+       to = sizeof(m->hdr) + sizeof(m->footer);
+       while (con->in_base_pos < to) {
+               left = to - con->in_base_pos;
+               ret = ceph_tcp_recvmsg(con->sock, (char *)&m->footer +
+                                      (con->in_base_pos - sizeof(m->hdr)),
+                                      left);
+               if (ret <= 0)
+                       return ret;
+               con->in_base_pos += ret;
+       }
+       dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n",
+            m, front_len, m->footer.front_crc, middle_len,
+            m->footer.middle_crc, data_len, m->footer.data_crc);
+
+       /* crc ok? */
+       if (con->in_front_crc != le32_to_cpu(m->footer.front_crc)) {
+               pr_err("read_partial_message %p front crc %u != exp. %u\n",
+                      m, con->in_front_crc, m->footer.front_crc);
+               return -EBADMSG;
+       }
+       if (con->in_middle_crc != le32_to_cpu(m->footer.middle_crc)) {
+               pr_err("read_partial_message %p middle crc %u != exp %u\n",
+                      m, con->in_middle_crc, m->footer.middle_crc);
+               return -EBADMSG;
+       }
+       if (datacrc &&
+           (m->footer.flags & CEPH_MSG_FOOTER_NOCRC) == 0 &&
+           con->in_data_crc != le32_to_cpu(m->footer.data_crc)) {
+               pr_err("read_partial_message %p data crc %u != exp. %u\n", m,
+                      con->in_data_crc, le32_to_cpu(m->footer.data_crc));
+               return -EBADMSG;
+       }
+
+       return 1; /* done! */
+}
+
+/*
+ * Process message.  This happens in the worker thread.  The callback should
+ * be careful not to do anything that waits on other incoming messages or it
+ * may deadlock.
+ */
+static void process_message(struct ceph_connection *con)
+{
+       struct ceph_msg *msg;
+
+       msg = con->in_msg;
+       con->in_msg = NULL;
+
+       /* if first message, set peer_name */
+       if (con->peer_name.type == 0)
+               con->peer_name = msg->hdr.src.name;
+
+       con->in_seq++;
+       mutex_unlock(&con->mutex);
+
+       dout("===== %p %llu from %s%lld %d=%s len %d+%d (%u %u %u) =====\n",
+            msg, le64_to_cpu(msg->hdr.seq),
+            ENTITY_NAME(msg->hdr.src.name),
+            le16_to_cpu(msg->hdr.type),
+            ceph_msg_type_name(le16_to_cpu(msg->hdr.type)),
+            le32_to_cpu(msg->hdr.front_len),
+            le32_to_cpu(msg->hdr.data_len),
+            con->in_front_crc, con->in_middle_crc, con->in_data_crc);
+       con->ops->dispatch(con, msg);
+
+       mutex_lock(&con->mutex);
+       prepare_read_tag(con);
+}
+
+
+/*
+ * Write something to the socket.  Called in a worker thread when the
+ * socket appears to be writeable and we have something ready to send.
+ */
+static int try_write(struct ceph_connection *con)
+{
+       struct ceph_messenger *msgr = con->msgr;
+       int ret = 1;
+
+       dout("try_write start %p state %lu nref %d\n", con, con->state,
+            atomic_read(&con->nref));
+
+       mutex_lock(&con->mutex);
+more:
+       dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);
+
+       /* open the socket first? */
+       if (con->sock == NULL) {
+               /*
+                * if we were STANDBY and are reconnecting _this_
+                * connection, bump connect_seq now.  Always bump
+                * global_seq.
+                */
+               if (test_and_clear_bit(STANDBY, &con->state))
+                       con->connect_seq++;
+
+               prepare_write_banner(msgr, con);
+               prepare_write_connect(msgr, con, 1);
+               prepare_read_banner(con);
+               set_bit(CONNECTING, &con->state);
+               clear_bit(NEGOTIATING, &con->state);
+
+               BUG_ON(con->in_msg);
+               con->in_tag = CEPH_MSGR_TAG_READY;
+               dout("try_write initiating connect on %p new state %lu\n",
+                    con, con->state);
+               con->sock = ceph_tcp_connect(con);
+               if (IS_ERR(con->sock)) {
+                       con->sock = NULL;
+                       con->error_msg = "connect error";
+                       ret = -1;
+                       goto out;
+               }
+       }
+
+more_kvec:
+       /* kvec data queued? */
+       if (con->out_skip) {
+               ret = write_partial_skip(con);
+               if (ret <= 0)
+                       goto done;
+               if (ret < 0) {
+                       dout("try_write write_partial_skip err %d\n", ret);
+                       goto done;
+               }
+       }
+       if (con->out_kvec_left) {
+               ret = write_partial_kvec(con);
+               if (ret <= 0)
+                       goto done;
+       }
+
+       /* msg pages? */
+       if (con->out_msg) {
+               if (con->out_msg_done) {
+                       ceph_msg_put(con->out_msg);
+                       con->out_msg = NULL;   /* we're done with this one */
+                       goto do_next;
+               }
+
+               ret = write_partial_msg_pages(con);
+               if (ret == 1)
+                       goto more_kvec;  /* we need to send the footer, too! */
+               if (ret == 0)
+                       goto done;
+               if (ret < 0) {
+                       dout("try_write write_partial_msg_pages err %d\n",
+                            ret);
+                       goto done;
+               }
+       }
+
+do_next:
+       if (!test_bit(CONNECTING, &con->state)) {
+               /* is anything else pending? */
+               if (!list_empty(&con->out_queue)) {
+                       prepare_write_message(con);
+                       goto more;
+               }
+               if (con->in_seq > con->in_seq_acked) {
+                       prepare_write_ack(con);
+                       goto more;
+               }
+               if (test_and_clear_bit(KEEPALIVE_PENDING, &con->state)) {
+                       prepare_write_keepalive(con);
+                       goto more;
+               }
+       }
+
+       /* Nothing to do! */
+       clear_bit(WRITE_PENDING, &con->state);
+       dout("try_write nothing else to write.\n");
+done:
+       ret = 0;
+out:
+       mutex_unlock(&con->mutex);
+       dout("try_write done on %p\n", con);
+       return ret;
+}
+
+
+
+/*
+ * Read what we can from the socket.
+ */
+static int try_read(struct ceph_connection *con)
+{
+       struct ceph_messenger *msgr;
+       int ret = -1;
+
+       if (!con->sock)
+               return 0;
+
+       if (test_bit(STANDBY, &con->state))
+               return 0;
+
+       dout("try_read start on %p\n", con);
+       msgr = con->msgr;
+
+       mutex_lock(&con->mutex);
+
+more:
+       dout("try_read tag %d in_base_pos %d\n", (int)con->in_tag,
+            con->in_base_pos);
+       if (test_bit(CONNECTING, &con->state)) {
+               if (!test_bit(NEGOTIATING, &con->state)) {
+                       dout("try_read connecting\n");
+                       ret = read_partial_banner(con);
+                       if (ret <= 0)
+                               goto done;
+                       if (process_banner(con) < 0) {
+                               ret = -1;
+                               goto out;
+                       }
+               }
+               ret = read_partial_connect(con);
+               if (ret <= 0)
+                       goto done;
+               if (process_connect(con) < 0) {
+                       ret = -1;
+                       goto out;
+               }
+               goto more;
+       }
+
+       if (con->in_base_pos < 0) {
+               /*
+                * skipping + discarding content.
+                *
+                * FIXME: there must be a better way to do this!
+                */
+               static char buf[1024];
+               int skip = min(1024, -con->in_base_pos);
+               dout("skipping %d / %d bytes\n", skip, -con->in_base_pos);
+               ret = ceph_tcp_recvmsg(con->sock, buf, skip);
+               if (ret <= 0)
+                       goto done;
+               con->in_base_pos += ret;
+               if (con->in_base_pos)
+                       goto more;
+       }
+       if (con->in_tag == CEPH_MSGR_TAG_READY) {
+               /*
+                * what's next?
+                */
+               ret = ceph_tcp_recvmsg(con->sock, &con->in_tag, 1);
+               if (ret <= 0)
+                       goto done;
+               dout("try_read got tag %d\n", (int)con->in_tag);
+               switch (con->in_tag) {
+               case CEPH_MSGR_TAG_MSG:
+                       prepare_read_message(con);
+                       break;
+               case CEPH_MSGR_TAG_ACK:
+                       prepare_read_ack(con);
+                       break;
+               case CEPH_MSGR_TAG_CLOSE:
+                       set_bit(CLOSED, &con->state);   /* fixme */
+                       goto done;
+               default:
+                       goto bad_tag;
+               }
+       }
+       if (con->in_tag == CEPH_MSGR_TAG_MSG) {
+               ret = read_partial_message(con);
+               if (ret <= 0) {
+                       switch (ret) {
+                       case -EBADMSG:
+                               con->error_msg = "bad crc";
+                               ret = -EIO;
+                               goto out;
+                       case -EIO:
+                               con->error_msg = "io error";
+                               goto out;
+                       default:
+                               goto done;
+                       }
+               }
+               if (con->in_tag == CEPH_MSGR_TAG_READY)
+                       goto more;
+               process_message(con);
+               goto more;
+       }
+       if (con->in_tag == CEPH_MSGR_TAG_ACK) {
+               ret = read_partial_ack(con);
+               if (ret <= 0)
+                       goto done;
+               process_ack(con);
+               goto more;
+       }
+
+done:
+       ret = 0;
+out:
+       mutex_unlock(&con->mutex);
+       dout("try_read done on %p\n", con);
+       return ret;
+
+bad_tag:
+       pr_err("try_read bad con->in_tag = %d\n", (int)con->in_tag);
+       con->error_msg = "protocol error, garbage tag";
+       ret = -1;
+       goto out;
+}
+
+
+/*
+ * Atomically queue work on a connection.  Bump @con reference to
+ * avoid races with connection teardown.
+ *
+ * There is some trickery going on with QUEUED and BUSY because we
+ * only want a _single_ thread operating on each connection at any
+ * point in time, but we want to use all available CPUs.
+ *
+ * The worker thread only proceeds if it can atomically set BUSY.  It
+ * clears QUEUED and does it's thing.  When it thinks it's done, it
+ * clears BUSY, then rechecks QUEUED.. if it's set again, it loops
+ * (tries again to set BUSY).
+ *
+ * To queue work, we first set QUEUED, _then_ if BUSY isn't set, we
+ * try to queue work.  If that fails (work is already queued, or BUSY)
+ * we give up (work also already being done or is queued) but leave QUEUED
+ * set so that the worker thread will loop if necessary.
+ */
+static void queue_con(struct ceph_connection *con)
+{
+       if (test_bit(DEAD, &con->state)) {
+               dout("queue_con %p ignoring: DEAD\n",
+                    con);
+               return;
+       }
+
+       if (!con->ops->get(con)) {
+               dout("queue_con %p ref count 0\n", con);
+               return;
+       }
+
+       set_bit(QUEUED, &con->state);
+       if (test_bit(BUSY, &con->state)) {
+               dout("queue_con %p - already BUSY\n", con);
+               con->ops->put(con);
+       } else if (!queue_work(ceph_msgr_wq, &con->work.work)) {
+               dout("queue_con %p - already queued\n", con);
+               con->ops->put(con);
+       } else {
+               dout("queue_con %p\n", con);
+       }
+}
+
+/*
+ * Do some work on a connection.  Drop a connection ref when we're done.
+ */
+static void con_work(struct work_struct *work)
+{
+       struct ceph_connection *con = container_of(work, struct ceph_connection,
+                                                  work.work);
+       int backoff = 0;
+
+more:
+       if (test_and_set_bit(BUSY, &con->state) != 0) {
+               dout("con_work %p BUSY already set\n", con);
+               goto out;
+       }
+       dout("con_work %p start, clearing QUEUED\n", con);
+       clear_bit(QUEUED, &con->state);
+
+       if (test_bit(CLOSED, &con->state)) { /* e.g. if we are replaced */
+               dout("con_work CLOSED\n");
+               con_close_socket(con);
+               goto done;
+       }
+       if (test_and_clear_bit(OPENING, &con->state)) {
+               /* reopen w/ new peer */
+               dout("con_work OPENING\n");
+               con_close_socket(con);
+       }
+
+       if (test_and_clear_bit(SOCK_CLOSED, &con->state) ||
+           try_read(con) < 0 ||
+           try_write(con) < 0) {
+               backoff = 1;
+               ceph_fault(con);     /* error/fault path */
+       }
+
+done:
+       clear_bit(BUSY, &con->state);
+       dout("con->state=%lu\n", con->state);
+       if (test_bit(QUEUED, &con->state)) {
+               if (!backoff || test_bit(OPENING, &con->state)) {
+                       dout("con_work %p QUEUED reset, looping\n", con);
+                       goto more;
+               }
+               dout("con_work %p QUEUED reset, but just faulted\n", con);
+               clear_bit(QUEUED, &con->state);
+       }
+       dout("con_work %p done\n", con);
+
+out:
+       con->ops->put(con);
+}
+
+
+/*
+ * Generic error/fault handler.  A retry mechanism is used with
+ * exponential backoff
+ */
+static void ceph_fault(struct ceph_connection *con)
+{
+       pr_err("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
+              pr_addr(&con->peer_addr.in_addr), con->error_msg);
+       dout("fault %p state %lu to peer %s\n",
+            con, con->state, pr_addr(&con->peer_addr.in_addr));
+
+       if (test_bit(LOSSYTX, &con->state)) {
+               dout("fault on LOSSYTX channel\n");
+               goto out;
+       }
+
+       mutex_lock(&con->mutex);
+       if (test_bit(CLOSED, &con->state))
+               goto out_unlock;
+
+       con_close_socket(con);
+
+       if (con->in_msg) {
+               ceph_msg_put(con->in_msg);
+               con->in_msg = NULL;
+       }
+
+       /* Requeue anything that hasn't been acked */
+       list_splice_init(&con->out_sent, &con->out_queue);
+
+       /* If there are no messages in the queue, place the connection
+        * in a STANDBY state (i.e., don't try to reconnect just yet). */
+       if (list_empty(&con->out_queue) && !con->out_keepalive_pending) {
+               dout("fault setting STANDBY\n");
+               set_bit(STANDBY, &con->state);
+       } else {
+               /* retry after a delay. */
+               if (con->delay == 0)
+                       con->delay = BASE_DELAY_INTERVAL;
+               else if (con->delay < MAX_DELAY_INTERVAL)
+                       con->delay *= 2;
+               dout("fault queueing %p delay %lu\n", con, con->delay);
+               con->ops->get(con);
+               if (queue_delayed_work(ceph_msgr_wq, &con->work,
+                                      round_jiffies_relative(con->delay)) == 0)
+                       con->ops->put(con);
+       }
+
+out_unlock:
+       mutex_unlock(&con->mutex);
+out:
+       /*
+        * in case we faulted due to authentication, invalidate our
+        * current tickets so that we can get new ones.
+         */
+       if (con->auth_retry && con->ops->invalidate_authorizer) {
+               dout("calling invalidate_authorizer()\n");
+               con->ops->invalidate_authorizer(con);
+       }
+
+       if (con->ops->fault)
+               con->ops->fault(con);
+}
+
+
+
+/*
+ * create a new messenger instance
+ */
+struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr)
+{
+       struct ceph_messenger *msgr;
+
+       msgr = kzalloc(sizeof(*msgr), GFP_KERNEL);
+       if (msgr == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       spin_lock_init(&msgr->global_seq_lock);
+
+       /* the zero page is needed if a request is "canceled" while the message
+        * is being written over the socket */
+       msgr->zero_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+       if (!msgr->zero_page) {
+               kfree(msgr);
+               return ERR_PTR(-ENOMEM);
+       }
+       kmap(msgr->zero_page);
+
+       if (myaddr)
+               msgr->inst.addr = *myaddr;
+
+       /* select a random nonce */
+       msgr->inst.addr.type = 0;
+       get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce));
+       encode_my_addr(msgr);
+
+       dout("messenger_create %p\n", msgr);
+       return msgr;
+}
+
+void ceph_messenger_destroy(struct ceph_messenger *msgr)
+{
+       dout("destroy %p\n", msgr);
+       kunmap(msgr->zero_page);
+       __free_page(msgr->zero_page);
+       kfree(msgr);
+       dout("destroyed messenger %p\n", msgr);
+}
+
+/*
+ * Queue up an outgoing message on the given connection.
+ */
+void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       if (test_bit(CLOSED, &con->state)) {
+               dout("con_send %p closed, dropping %p\n", con, msg);
+               ceph_msg_put(msg);
+               return;
+       }
+
+       /* set src+dst */
+       msg->hdr.src.name = con->msgr->inst.name;
+       msg->hdr.src.addr = con->msgr->my_enc_addr;
+       msg->hdr.orig_src = msg->hdr.src;
+
+       BUG_ON(msg->front.iov_len != le32_to_cpu(msg->hdr.front_len));
+
+       /* queue */
+       mutex_lock(&con->mutex);
+       BUG_ON(!list_empty(&msg->list_head));
+       list_add_tail(&msg->list_head, &con->out_queue);
+       dout("----- %p to %s%lld %d=%s len %d+%d+%d -----\n", msg,
+            ENTITY_NAME(con->peer_name), le16_to_cpu(msg->hdr.type),
+            ceph_msg_type_name(le16_to_cpu(msg->hdr.type)),
+            le32_to_cpu(msg->hdr.front_len),
+            le32_to_cpu(msg->hdr.middle_len),
+            le32_to_cpu(msg->hdr.data_len));
+       mutex_unlock(&con->mutex);
+
+       /* if there wasn't anything waiting to send before, queue
+        * new work */
+       if (test_and_set_bit(WRITE_PENDING, &con->state) == 0)
+               queue_con(con);
+}
+
+/*
+ * Revoke a message that was previously queued for send
+ */
+void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       mutex_lock(&con->mutex);
+       if (!list_empty(&msg->list_head)) {
+               dout("con_revoke %p msg %p\n", con, msg);
+               list_del_init(&msg->list_head);
+               ceph_msg_put(msg);
+               msg->hdr.seq = 0;
+               if (con->out_msg == msg) {
+                       ceph_msg_put(con->out_msg);
+                       con->out_msg = NULL;
+               }
+               if (con->out_kvec_is_msg) {
+                       con->out_skip = con->out_kvec_bytes;
+                       con->out_kvec_is_msg = false;
+               }
+       } else {
+               dout("con_revoke %p msg %p - not queued (sent?)\n", con, msg);
+       }
+       mutex_unlock(&con->mutex);
+}
+
+/*
+ * Revoke a message that we may be reading data into
+ */
+void ceph_con_revoke_message(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       mutex_lock(&con->mutex);
+       if (con->in_msg && con->in_msg == msg) {
+               unsigned front_len = le32_to_cpu(con->in_hdr.front_len);
+               unsigned middle_len = le32_to_cpu(con->in_hdr.middle_len);
+               unsigned data_len = le32_to_cpu(con->in_hdr.data_len);
+
+               /* skip rest of message */
+               dout("con_revoke_pages %p msg %p revoked\n", con, msg);
+                       con->in_base_pos = con->in_base_pos -
+                               sizeof(struct ceph_msg_header) -
+                               front_len -
+                               middle_len -
+                               data_len -
+                               sizeof(struct ceph_msg_footer);
+               ceph_msg_put(con->in_msg);
+               con->in_msg = NULL;
+               con->in_tag = CEPH_MSGR_TAG_READY;
+       } else {
+               dout("con_revoke_pages %p msg %p pages %p no-op\n",
+                    con, con->in_msg, msg);
+       }
+       mutex_unlock(&con->mutex);
+}
+
+/*
+ * Queue a keepalive byte to ensure the tcp connection is alive.
+ */
+void ceph_con_keepalive(struct ceph_connection *con)
+{
+       if (test_and_set_bit(KEEPALIVE_PENDING, &con->state) == 0 &&
+           test_and_set_bit(WRITE_PENDING, &con->state) == 0)
+               queue_con(con);
+}
+
+
+/*
+ * construct a new message with given type, size
+ * the new msg has a ref count of 1.
+ */
+struct ceph_msg *ceph_msg_new(int type, int front_len,
+                             int page_len, int page_off, struct page **pages)
+{
+       struct ceph_msg *m;
+
+       m = kmalloc(sizeof(*m), GFP_NOFS);
+       if (m == NULL)
+               goto out;
+       kref_init(&m->kref);
+       INIT_LIST_HEAD(&m->list_head);
+
+       m->hdr.type = cpu_to_le16(type);
+       m->hdr.front_len = cpu_to_le32(front_len);
+       m->hdr.middle_len = 0;
+       m->hdr.data_len = cpu_to_le32(page_len);
+       m->hdr.data_off = cpu_to_le16(page_off);
+       m->hdr.priority = cpu_to_le16(CEPH_MSG_PRIO_DEFAULT);
+       m->footer.front_crc = 0;
+       m->footer.middle_crc = 0;
+       m->footer.data_crc = 0;
+       m->front_max = front_len;
+       m->front_is_vmalloc = false;
+       m->more_to_follow = false;
+       m->pool = NULL;
+
+       /* front */
+       if (front_len) {
+               if (front_len > PAGE_CACHE_SIZE) {
+                       m->front.iov_base = __vmalloc(front_len, GFP_NOFS,
+                                                     PAGE_KERNEL);
+                       m->front_is_vmalloc = true;
+               } else {
+                       m->front.iov_base = kmalloc(front_len, GFP_NOFS);
+               }
+               if (m->front.iov_base == NULL) {
+                       pr_err("msg_new can't allocate %d bytes\n",
+                            front_len);
+                       goto out2;
+               }
+       } else {
+               m->front.iov_base = NULL;
+       }
+       m->front.iov_len = front_len;
+
+       /* middle */
+       m->middle = NULL;
+
+       /* data */
+       m->nr_pages = calc_pages_for(page_off, page_len);
+       m->pages = pages;
+       m->pagelist = NULL;
+
+       dout("ceph_msg_new %p page %d~%d -> %d\n", m, page_off, page_len,
+            m->nr_pages);
+       return m;
+
+out2:
+       ceph_msg_put(m);
+out:
+       pr_err("msg_new can't create type %d len %d\n", type, front_len);
+       return ERR_PTR(-ENOMEM);
+}
+
+/*
+ * Allocate "middle" portion of a message, if it is needed and wasn't
+ * allocated by alloc_msg.  This allows us to read a small fixed-size
+ * per-type header in the front and then gracefully fail (i.e.,
+ * propagate the error to the caller based on info in the front) when
+ * the middle is too large.
+ */
+static int ceph_alloc_middle(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       int type = le16_to_cpu(msg->hdr.type);
+       int middle_len = le32_to_cpu(msg->hdr.middle_len);
+
+       dout("alloc_middle %p type %d %s middle_len %d\n", msg, type,
+            ceph_msg_type_name(type), middle_len);
+       BUG_ON(!middle_len);
+       BUG_ON(msg->middle);
+
+       msg->middle = ceph_buffer_new(middle_len, GFP_NOFS);
+       if (!msg->middle)
+               return -ENOMEM;
+       return 0;
+}
+
+/*
+ * Generic message allocator, for incoming messages.
+ */
+static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
+                               struct ceph_msg_header *hdr,
+                               int *skip)
+{
+       int type = le16_to_cpu(hdr->type);
+       int front_len = le32_to_cpu(hdr->front_len);
+       int middle_len = le32_to_cpu(hdr->middle_len);
+       struct ceph_msg *msg = NULL;
+       int ret;
+
+       if (con->ops->alloc_msg) {
+               mutex_unlock(&con->mutex);
+               msg = con->ops->alloc_msg(con, hdr, skip);
+               mutex_lock(&con->mutex);
+               if (IS_ERR(msg))
+                       return msg;
+
+               if (*skip)
+                       return NULL;
+       }
+       if (!msg) {
+               *skip = 0;
+               msg = ceph_msg_new(type, front_len, 0, 0, NULL);
+               if (!msg) {
+                       pr_err("unable to allocate msg type %d len %d\n",
+                              type, front_len);
+                       return ERR_PTR(-ENOMEM);
+               }
+       }
+       memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr));
+
+       if (middle_len) {
+               ret = ceph_alloc_middle(con, msg);
+
+               if (ret < 0) {
+                       ceph_msg_put(msg);
+                       return msg;
+               }
+       }
+
+       return msg;
+}
+
+
+/*
+ * Free a generically kmalloc'd message.
+ */
+void ceph_msg_kfree(struct ceph_msg *m)
+{
+       dout("msg_kfree %p\n", m);
+       if (m->front_is_vmalloc)
+               vfree(m->front.iov_base);
+       else
+               kfree(m->front.iov_base);
+       kfree(m);
+}
+
+/*
+ * Drop a msg ref.  Destroy as needed.
+ */
+void ceph_msg_last_put(struct kref *kref)
+{
+       struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
+
+       dout("ceph_msg_put last one on %p\n", m);
+       WARN_ON(!list_empty(&m->list_head));
+
+       /* drop middle, data, if any */
+       if (m->middle) {
+               ceph_buffer_put(m->middle);
+               m->middle = NULL;
+       }
+       m->nr_pages = 0;
+       m->pages = NULL;
+
+       if (m->pagelist) {
+               ceph_pagelist_release(m->pagelist);
+               kfree(m->pagelist);
+               m->pagelist = NULL;
+       }
+
+       if (m->pool)
+               ceph_msgpool_put(m->pool, m);
+       else
+               ceph_msg_kfree(m);
+}
+
+void ceph_msg_dump(struct ceph_msg *msg)
+{
+       pr_debug("msg_dump %p (front_max %d nr_pages %d)\n", msg,
+                msg->front_max, msg->nr_pages);
+       print_hex_dump(KERN_DEBUG, "header: ",
+                      DUMP_PREFIX_OFFSET, 16, 1,
+                      &msg->hdr, sizeof(msg->hdr), true);
+       print_hex_dump(KERN_DEBUG, " front: ",
+                      DUMP_PREFIX_OFFSET, 16, 1,
+                      msg->front.iov_base, msg->front.iov_len, true);
+       if (msg->middle)
+               print_hex_dump(KERN_DEBUG, "middle: ",
+                              DUMP_PREFIX_OFFSET, 16, 1,
+                              msg->middle->vec.iov_base,
+                              msg->middle->vec.iov_len, true);
+       print_hex_dump(KERN_DEBUG, "footer: ",
+                      DUMP_PREFIX_OFFSET, 16, 1,
+                      &msg->footer, sizeof(msg->footer), true);
+}
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h
new file mode 100644 (file)
index 0000000..a343dae
--- /dev/null
@@ -0,0 +1,255 @@
+#ifndef __FS_CEPH_MESSENGER_H
+#define __FS_CEPH_MESSENGER_H
+
+#include <linux/kref.h>
+#include <linux/mutex.h>
+#include <linux/net.h>
+#include <linux/radix-tree.h>
+#include <linux/uio.h>
+#include <linux/version.h>
+#include <linux/workqueue.h>
+
+#include "types.h"
+#include "buffer.h"
+
+struct ceph_msg;
+struct ceph_connection;
+
+extern struct workqueue_struct *ceph_msgr_wq;       /* receive work queue */
+
+/*
+ * Ceph defines these callbacks for handling connection events.
+ */
+struct ceph_connection_operations {
+       struct ceph_connection *(*get)(struct ceph_connection *);
+       void (*put)(struct ceph_connection *);
+
+       /* handle an incoming message. */
+       void (*dispatch) (struct ceph_connection *con, struct ceph_msg *m);
+
+       /* authorize an outgoing connection */
+       int (*get_authorizer) (struct ceph_connection *con,
+                              void **buf, int *len, int *proto,
+                              void **reply_buf, int *reply_len, int force_new);
+       int (*verify_authorizer_reply) (struct ceph_connection *con, int len);
+       int (*invalidate_authorizer)(struct ceph_connection *con);
+
+       /* protocol version mismatch */
+       void (*bad_proto) (struct ceph_connection *con);
+
+       /* there was some error on the socket (disconnect, whatever) */
+       void (*fault) (struct ceph_connection *con);
+
+       /* a remote host as terminated a message exchange session, and messages
+        * we sent (or they tried to send us) may be lost. */
+       void (*peer_reset) (struct ceph_connection *con);
+
+       struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,
+                                       struct ceph_msg_header *hdr,
+                                       int *skip);
+};
+
+extern const char *ceph_name_type_str(int t);
+
+/* use format string %s%d */
+#define ENTITY_NAME(n) ceph_name_type_str((n).type), le64_to_cpu((n).num)
+
+struct ceph_messenger {
+       struct ceph_entity_inst inst;    /* my name+address */
+       struct ceph_entity_addr my_enc_addr;
+       struct page *zero_page;          /* used in certain error cases */
+
+       bool nocrc;
+
+       /*
+        * the global_seq counts connections i (attempt to) initiate
+        * in order to disambiguate certain connect race conditions.
+        */
+       u32 global_seq;
+       spinlock_t global_seq_lock;
+};
+
+/*
+ * a single message.  it contains a header (src, dest, message type, etc.),
+ * footer (crc values, mainly), a "front" message body, and possibly a
+ * data payload (stored in some number of pages).
+ */
+struct ceph_msg {
+       struct ceph_msg_header hdr;     /* header */
+       struct ceph_msg_footer footer;  /* footer */
+       struct kvec front;              /* unaligned blobs of message */
+       struct ceph_buffer *middle;
+       struct page **pages;            /* data payload.  NOT OWNER. */
+       unsigned nr_pages;              /* size of page array */
+       struct ceph_pagelist *pagelist; /* instead of pages */
+       struct list_head list_head;
+       struct kref kref;
+       bool front_is_vmalloc;
+       bool more_to_follow;
+       int front_max;
+
+       struct ceph_msgpool *pool;
+};
+
+struct ceph_msg_pos {
+       int page, page_pos;  /* which page; offset in page */
+       int data_pos;        /* offset in data payload */
+       int did_page_crc;    /* true if we've calculated crc for current page */
+};
+
+/* ceph connection fault delay defaults, for exponential backoff */
+#define BASE_DELAY_INTERVAL    (HZ/2)
+#define MAX_DELAY_INTERVAL     (5 * 60 * HZ)
+
+/*
+ * ceph_connection state bit flags
+ *
+ * QUEUED and BUSY are used together to ensure that only a single
+ * thread is currently opening, reading or writing data to the socket.
+ */
+#define LOSSYTX         0  /* we can close channel or drop messages on errors */
+#define CONNECTING     1
+#define NEGOTIATING    2
+#define KEEPALIVE_PENDING      3
+#define WRITE_PENDING  4  /* we have data ready to send */
+#define QUEUED          5  /* there is work queued on this connection */
+#define BUSY            6  /* work is being done */
+#define STANDBY                8  /* no outgoing messages, socket closed.  we keep
+                           * the ceph_connection around to maintain shared
+                           * state with the peer. */
+#define CLOSED         10 /* we've closed the connection */
+#define SOCK_CLOSED    11 /* socket state changed to closed */
+#define OPENING         13 /* open connection w/ (possibly new) peer */
+#define DEAD            14 /* dead, about to kfree */
+
+/*
+ * A single connection with another host.
+ *
+ * We maintain a queue of outgoing messages, and some session state to
+ * ensure that we can preserve the lossless, ordered delivery of
+ * messages in the case of a TCP disconnect.
+ */
+struct ceph_connection {
+       void *private;
+       atomic_t nref;
+
+       const struct ceph_connection_operations *ops;
+
+       struct ceph_messenger *msgr;
+       struct socket *sock;
+       unsigned long state;    /* connection state (see flags above) */
+       const char *error_msg;  /* error message, if any */
+
+       struct ceph_entity_addr peer_addr; /* peer address */
+       struct ceph_entity_name peer_name; /* peer name */
+       struct ceph_entity_addr peer_addr_for_me;
+       u32 connect_seq;      /* identify the most recent connection
+                                attempt for this connection, client */
+       u32 peer_global_seq;  /* peer's global seq for this connection */
+
+       int auth_retry;       /* true if we need a newer authorizer */
+       void *auth_reply_buf;   /* where to put the authorizer reply */
+       int auth_reply_buf_len;
+
+       struct mutex mutex;
+
+       /* out queue */
+       struct list_head out_queue;
+       struct list_head out_sent;   /* sending or sent but unacked */
+       u64 out_seq;                 /* last message queued for send */
+       u64 out_seq_sent;            /* last message sent */
+       bool out_keepalive_pending;
+
+       u64 in_seq, in_seq_acked;  /* last message received, acked */
+
+       /* connection negotiation temps */
+       char in_banner[CEPH_BANNER_MAX_LEN];
+       union {
+               struct {  /* outgoing connection */
+                       struct ceph_msg_connect out_connect;
+                       struct ceph_msg_connect_reply in_reply;
+               };
+               struct {  /* incoming */
+                       struct ceph_msg_connect in_connect;
+                       struct ceph_msg_connect_reply out_reply;
+               };
+       };
+       struct ceph_entity_addr actual_peer_addr;
+
+       /* message out temps */
+       struct ceph_msg *out_msg;        /* sending message (== tail of
+                                           out_sent) */
+       bool out_msg_done;
+       struct ceph_msg_pos out_msg_pos;
+
+       struct kvec out_kvec[8],         /* sending header/footer data */
+               *out_kvec_cur;
+       int out_kvec_left;   /* kvec's left in out_kvec */
+       int out_skip;        /* skip this many bytes */
+       int out_kvec_bytes;  /* total bytes left */
+       bool out_kvec_is_msg; /* kvec refers to out_msg */
+       int out_more;        /* there is more data after the kvecs */
+       __le64 out_temp_ack; /* for writing an ack */
+
+       /* message in temps */
+       struct ceph_msg_header in_hdr;
+       struct ceph_msg *in_msg;
+       struct ceph_msg_pos in_msg_pos;
+       u32 in_front_crc, in_middle_crc, in_data_crc;  /* calculated crc */
+
+       char in_tag;         /* protocol control byte */
+       int in_base_pos;     /* bytes read */
+       __le64 in_temp_ack;  /* for reading an ack */
+
+       struct delayed_work work;           /* send|recv work */
+       unsigned long       delay;          /* current delay interval */
+};
+
+
+extern const char *pr_addr(const struct sockaddr_storage *ss);
+extern int ceph_parse_ips(const char *c, const char *end,
+                         struct ceph_entity_addr *addr,
+                         int max_count, int *count);
+
+
+extern int ceph_msgr_init(void);
+extern void ceph_msgr_exit(void);
+
+extern struct ceph_messenger *ceph_messenger_create(
+       struct ceph_entity_addr *myaddr);
+extern void ceph_messenger_destroy(struct ceph_messenger *);
+
+extern void ceph_con_init(struct ceph_messenger *msgr,
+                         struct ceph_connection *con);
+extern void ceph_con_open(struct ceph_connection *con,
+                         struct ceph_entity_addr *addr);
+extern bool ceph_con_opened(struct ceph_connection *con);
+extern void ceph_con_close(struct ceph_connection *con);
+extern void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg);
+extern void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg);
+extern void ceph_con_revoke_message(struct ceph_connection *con,
+                                 struct ceph_msg *msg);
+extern void ceph_con_keepalive(struct ceph_connection *con);
+extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
+extern void ceph_con_put(struct ceph_connection *con);
+
+extern struct ceph_msg *ceph_msg_new(int type, int front_len,
+                                    int page_len, int page_off,
+                                    struct page **pages);
+extern void ceph_msg_kfree(struct ceph_msg *m);
+
+
+static inline struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
+{
+       kref_get(&msg->kref);
+       return msg;
+}
+extern void ceph_msg_last_put(struct kref *kref);
+static inline void ceph_msg_put(struct ceph_msg *msg)
+{
+       kref_put(&msg->kref, ceph_msg_last_put);
+}
+
+extern void ceph_msg_dump(struct ceph_msg *msg);
+
+#endif
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
new file mode 100644 (file)
index 0000000..8fdc011
--- /dev/null
@@ -0,0 +1,835 @@
+#include "ceph_debug.h"
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/sched.h>
+
+#include "mon_client.h"
+#include "super.h"
+#include "auth.h"
+#include "decode.h"
+
+/*
+ * Interact with Ceph monitor cluster.  Handle requests for new map
+ * versions, and periodically resend as needed.  Also implement
+ * statfs() and umount().
+ *
+ * A small cluster of Ceph "monitors" are responsible for managing critical
+ * cluster configuration and state information.  An odd number (e.g., 3, 5)
+ * of cmon daemons use a modified version of the Paxos part-time parliament
+ * algorithm to manage the MDS map (mds cluster membership), OSD map, and
+ * list of clients who have mounted the file system.
+ *
+ * We maintain an open, active session with a monitor at all times in order to
+ * receive timely MDSMap updates.  We periodically send a keepalive byte on the
+ * TCP socket to ensure we detect a failure.  If the connection does break, we
+ * randomly hunt for a new monitor.  Once the connection is reestablished, we
+ * resend any outstanding requests.
+ */
+
+const static struct ceph_connection_operations mon_con_ops;
+
+static int __validate_auth(struct ceph_mon_client *monc);
+
+/*
+ * Decode a monmap blob (e.g., during mount).
+ */
+struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
+{
+       struct ceph_monmap *m = NULL;
+       int i, err = -EINVAL;
+       struct ceph_fsid fsid;
+       u32 epoch, num_mon;
+       u16 version;
+       u32 len;
+
+       ceph_decode_32_safe(&p, end, len, bad);
+       ceph_decode_need(&p, end, len, bad);
+
+       dout("monmap_decode %p %p len %d\n", p, end, (int)(end-p));
+
+       ceph_decode_16_safe(&p, end, version, bad);
+
+       ceph_decode_need(&p, end, sizeof(fsid) + 2*sizeof(u32), bad);
+       ceph_decode_copy(&p, &fsid, sizeof(fsid));
+       epoch = ceph_decode_32(&p);
+
+       num_mon = ceph_decode_32(&p);
+       ceph_decode_need(&p, end, num_mon*sizeof(m->mon_inst[0]), bad);
+
+       if (num_mon >= CEPH_MAX_MON)
+               goto bad;
+       m = kmalloc(sizeof(*m) + sizeof(m->mon_inst[0])*num_mon, GFP_NOFS);
+       if (m == NULL)
+               return ERR_PTR(-ENOMEM);
+       m->fsid = fsid;
+       m->epoch = epoch;
+       m->num_mon = num_mon;
+       ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0]));
+       for (i = 0; i < num_mon; i++)
+               ceph_decode_addr(&m->mon_inst[i].addr);
+
+       dout("monmap_decode epoch %d, num_mon %d\n", m->epoch,
+            m->num_mon);
+       for (i = 0; i < m->num_mon; i++)
+               dout("monmap_decode  mon%d is %s\n", i,
+                    pr_addr(&m->mon_inst[i].addr.in_addr));
+       return m;
+
+bad:
+       dout("monmap_decode failed with %d\n", err);
+       kfree(m);
+       return ERR_PTR(err);
+}
+
+/*
+ * return true if *addr is included in the monmap.
+ */
+int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *addr)
+{
+       int i;
+
+       for (i = 0; i < m->num_mon; i++)
+               if (memcmp(addr, &m->mon_inst[i].addr, sizeof(*addr)) == 0)
+                       return 1;
+       return 0;
+}
+
+/*
+ * Send an auth request.
+ */
+static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
+{
+       monc->pending_auth = 1;
+       monc->m_auth->front.iov_len = len;
+       monc->m_auth->hdr.front_len = cpu_to_le32(len);
+       ceph_msg_get(monc->m_auth);  /* keep our ref */
+       ceph_con_send(monc->con, monc->m_auth);
+}
+
+/*
+ * Close monitor session, if any.
+ */
+static void __close_session(struct ceph_mon_client *monc)
+{
+       if (monc->con) {
+               dout("__close_session closing mon%d\n", monc->cur_mon);
+               ceph_con_revoke(monc->con, monc->m_auth);
+               ceph_con_close(monc->con);
+               monc->cur_mon = -1;
+               monc->pending_auth = 0;
+               ceph_auth_reset(monc->auth);
+       }
+}
+
+/*
+ * Open a session with a (new) monitor.
+ */
+static int __open_session(struct ceph_mon_client *monc)
+{
+       char r;
+       int ret;
+
+       if (monc->cur_mon < 0) {
+               get_random_bytes(&r, 1);
+               monc->cur_mon = r % monc->monmap->num_mon;
+               dout("open_session num=%d r=%d -> mon%d\n",
+                    monc->monmap->num_mon, r, monc->cur_mon);
+               monc->sub_sent = 0;
+               monc->sub_renew_after = jiffies;  /* i.e., expired */
+               monc->want_next_osdmap = !!monc->want_next_osdmap;
+
+               dout("open_session mon%d opening\n", monc->cur_mon);
+               monc->con->peer_name.type = CEPH_ENTITY_TYPE_MON;
+               monc->con->peer_name.num = cpu_to_le64(monc->cur_mon);
+               ceph_con_open(monc->con,
+                             &monc->monmap->mon_inst[monc->cur_mon].addr);
+
+               /* initiatiate authentication handshake */
+               ret = ceph_auth_build_hello(monc->auth,
+                                           monc->m_auth->front.iov_base,
+                                           monc->m_auth->front_max);
+               __send_prepared_auth_request(monc, ret);
+       } else {
+               dout("open_session mon%d already open\n", monc->cur_mon);
+       }
+       return 0;
+}
+
+static bool __sub_expired(struct ceph_mon_client *monc)
+{
+       return time_after_eq(jiffies, monc->sub_renew_after);
+}
+
+/*
+ * Reschedule delayed work timer.
+ */
+static void __schedule_delayed(struct ceph_mon_client *monc)
+{
+       unsigned delay;
+
+       if (monc->cur_mon < 0 || __sub_expired(monc))
+               delay = 10 * HZ;
+       else
+               delay = 20 * HZ;
+       dout("__schedule_delayed after %u\n", delay);
+       schedule_delayed_work(&monc->delayed_work, delay);
+}
+
+/*
+ * Send subscribe request for mdsmap and/or osdmap.
+ */
+static void __send_subscribe(struct ceph_mon_client *monc)
+{
+       dout("__send_subscribe sub_sent=%u exp=%u want_osd=%d\n",
+            (unsigned)monc->sub_sent, __sub_expired(monc),
+            monc->want_next_osdmap);
+       if ((__sub_expired(monc) && !monc->sub_sent) ||
+           monc->want_next_osdmap == 1) {
+               struct ceph_msg *msg;
+               struct ceph_mon_subscribe_item *i;
+               void *p, *end;
+
+               msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, 0, 0, NULL);
+               if (!msg)
+                       return;
+
+               p = msg->front.iov_base;
+               end = p + msg->front.iov_len;
+
+               dout("__send_subscribe to 'mdsmap' %u+\n",
+                    (unsigned)monc->have_mdsmap);
+               if (monc->want_next_osdmap) {
+                       dout("__send_subscribe to 'osdmap' %u\n",
+                            (unsigned)monc->have_osdmap);
+                       ceph_encode_32(&p, 3);
+                       ceph_encode_string(&p, end, "osdmap", 6);
+                       i = p;
+                       i->have = cpu_to_le64(monc->have_osdmap);
+                       i->onetime = 1;
+                       p += sizeof(*i);
+                       monc->want_next_osdmap = 2;  /* requested */
+               } else {
+                       ceph_encode_32(&p, 2);
+               }
+               ceph_encode_string(&p, end, "mdsmap", 6);
+               i = p;
+               i->have = cpu_to_le64(monc->have_mdsmap);
+               i->onetime = 0;
+               p += sizeof(*i);
+               ceph_encode_string(&p, end, "monmap", 6);
+               i = p;
+               i->have = 0;
+               i->onetime = 0;
+               p += sizeof(*i);
+
+               msg->front.iov_len = p - msg->front.iov_base;
+               msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
+               ceph_con_send(monc->con, msg);
+
+               monc->sub_sent = jiffies | 1;  /* never 0 */
+       }
+}
+
+static void handle_subscribe_ack(struct ceph_mon_client *monc,
+                                struct ceph_msg *msg)
+{
+       unsigned seconds;
+       struct ceph_mon_subscribe_ack *h = msg->front.iov_base;
+
+       if (msg->front.iov_len < sizeof(*h))
+               goto bad;
+       seconds = le32_to_cpu(h->duration);
+
+       mutex_lock(&monc->mutex);
+       if (monc->hunting) {
+               pr_info("mon%d %s session established\n",
+                       monc->cur_mon, pr_addr(&monc->con->peer_addr.in_addr));
+               monc->hunting = false;
+       }
+       dout("handle_subscribe_ack after %d seconds\n", seconds);
+       monc->sub_renew_after = monc->sub_sent + (seconds >> 1)*HZ - 1;
+       monc->sub_sent = 0;
+       mutex_unlock(&monc->mutex);
+       return;
+bad:
+       pr_err("got corrupt subscribe-ack msg\n");
+       ceph_msg_dump(msg);
+}
+
+/*
+ * Keep track of which maps we have
+ */
+int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 got)
+{
+       mutex_lock(&monc->mutex);
+       monc->have_mdsmap = got;
+       mutex_unlock(&monc->mutex);
+       return 0;
+}
+
+int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 got)
+{
+       mutex_lock(&monc->mutex);
+       monc->have_osdmap = got;
+       monc->want_next_osdmap = 0;
+       mutex_unlock(&monc->mutex);
+       return 0;
+}
+
+/*
+ * Register interest in the next osdmap
+ */
+void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc)
+{
+       dout("request_next_osdmap have %u\n", monc->have_osdmap);
+       mutex_lock(&monc->mutex);
+       if (!monc->want_next_osdmap)
+               monc->want_next_osdmap = 1;
+       if (monc->want_next_osdmap < 2)
+               __send_subscribe(monc);
+       mutex_unlock(&monc->mutex);
+}
+
+/*
+ *
+ */
+int ceph_monc_open_session(struct ceph_mon_client *monc)
+{
+       if (!monc->con) {
+               monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL);
+               if (!monc->con)
+                       return -ENOMEM;
+               ceph_con_init(monc->client->msgr, monc->con);
+               monc->con->private = monc;
+               monc->con->ops = &mon_con_ops;
+       }
+
+       mutex_lock(&monc->mutex);
+       __open_session(monc);
+       __schedule_delayed(monc);
+       mutex_unlock(&monc->mutex);
+       return 0;
+}
+
+/*
+ * The monitor responds with mount ack indicate mount success.  The
+ * included client ticket allows the client to talk to MDSs and OSDs.
+ */
+static void ceph_monc_handle_map(struct ceph_mon_client *monc,
+                                struct ceph_msg *msg)
+{
+       struct ceph_client *client = monc->client;
+       struct ceph_monmap *monmap = NULL, *old = monc->monmap;
+       void *p, *end;
+
+       mutex_lock(&monc->mutex);
+
+       dout("handle_monmap\n");
+       p = msg->front.iov_base;
+       end = p + msg->front.iov_len;
+
+       monmap = ceph_monmap_decode(p, end);
+       if (IS_ERR(monmap)) {
+               pr_err("problem decoding monmap, %d\n",
+                      (int)PTR_ERR(monmap));
+               goto out;
+       }
+
+       if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) {
+               kfree(monmap);
+               goto out;
+       }
+
+       client->monc.monmap = monmap;
+       kfree(old);
+
+out:
+       mutex_unlock(&monc->mutex);
+       wake_up(&client->auth_wq);
+}
+
+/*
+ * statfs
+ */
+static struct ceph_mon_statfs_request *__lookup_statfs(
+       struct ceph_mon_client *monc, u64 tid)
+{
+       struct ceph_mon_statfs_request *req;
+       struct rb_node *n = monc->statfs_request_tree.rb_node;
+
+       while (n) {
+               req = rb_entry(n, struct ceph_mon_statfs_request, node);
+               if (tid < req->tid)
+                       n = n->rb_left;
+               else if (tid > req->tid)
+                       n = n->rb_right;
+               else
+                       return req;
+       }
+       return NULL;
+}
+
+static void __insert_statfs(struct ceph_mon_client *monc,
+                           struct ceph_mon_statfs_request *new)
+{
+       struct rb_node **p = &monc->statfs_request_tree.rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_mon_statfs_request *req = NULL;
+
+       while (*p) {
+               parent = *p;
+               req = rb_entry(parent, struct ceph_mon_statfs_request, node);
+               if (new->tid < req->tid)
+                       p = &(*p)->rb_left;
+               else if (new->tid > req->tid)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->node, parent, p);
+       rb_insert_color(&new->node, &monc->statfs_request_tree);
+}
+
+static void handle_statfs_reply(struct ceph_mon_client *monc,
+                               struct ceph_msg *msg)
+{
+       struct ceph_mon_statfs_request *req;
+       struct ceph_mon_statfs_reply *reply = msg->front.iov_base;
+       u64 tid;
+
+       if (msg->front.iov_len != sizeof(*reply))
+               goto bad;
+       tid = le64_to_cpu(msg->hdr.tid);
+       dout("handle_statfs_reply %p tid %llu\n", msg, tid);
+
+       mutex_lock(&monc->mutex);
+       req = __lookup_statfs(monc, tid);
+       if (req) {
+               *req->buf = reply->st;
+               req->result = 0;
+       }
+       mutex_unlock(&monc->mutex);
+       if (req)
+               complete(&req->completion);
+       return;
+
+bad:
+       pr_err("corrupt statfs reply, no tid\n");
+       ceph_msg_dump(msg);
+}
+
+/*
+ * (re)send a statfs request
+ */
+static int send_statfs(struct ceph_mon_client *monc,
+                      struct ceph_mon_statfs_request *req)
+{
+       struct ceph_msg *msg;
+       struct ceph_mon_statfs *h;
+
+       dout("send_statfs tid %llu\n", req->tid);
+       msg = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), 0, 0, NULL);
+       if (IS_ERR(msg))
+               return PTR_ERR(msg);
+       req->request = msg;
+       msg->hdr.tid = cpu_to_le64(req->tid);
+       h = msg->front.iov_base;
+       h->monhdr.have_version = 0;
+       h->monhdr.session_mon = cpu_to_le16(-1);
+       h->monhdr.session_mon_tid = 0;
+       h->fsid = monc->monmap->fsid;
+       ceph_con_send(monc->con, msg);
+       return 0;
+}
+
+/*
+ * Do a synchronous statfs().
+ */
+int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
+{
+       struct ceph_mon_statfs_request req;
+       int err;
+
+       req.buf = buf;
+       init_completion(&req.completion);
+
+       /* allocate memory for reply */
+       err = ceph_msgpool_resv(&monc->msgpool_statfs_reply, 1);
+       if (err)
+               return err;
+
+       /* register request */
+       mutex_lock(&monc->mutex);
+       req.tid = ++monc->last_tid;
+       req.last_attempt = jiffies;
+       req.delay = BASE_DELAY_INTERVAL;
+       __insert_statfs(monc, &req);
+       monc->num_statfs_requests++;
+       mutex_unlock(&monc->mutex);
+
+       /* send request and wait */
+       err = send_statfs(monc, &req);
+       if (!err)
+               err = wait_for_completion_interruptible(&req.completion);
+
+       mutex_lock(&monc->mutex);
+       rb_erase(&req.node, &monc->statfs_request_tree);
+       monc->num_statfs_requests--;
+       ceph_msgpool_resv(&monc->msgpool_statfs_reply, -1);
+       mutex_unlock(&monc->mutex);
+
+       if (!err)
+               err = req.result;
+       return err;
+}
+
+/*
+ * Resend pending statfs requests.
+ */
+static void __resend_statfs(struct ceph_mon_client *monc)
+{
+       struct ceph_mon_statfs_request *req;
+       struct rb_node *p;
+
+       for (p = rb_first(&monc->statfs_request_tree); p; p = rb_next(p)) {
+               req = rb_entry(p, struct ceph_mon_statfs_request, node);
+               send_statfs(monc, req);
+       }
+}
+
+/*
+ * Delayed work.  If we haven't mounted yet, retry.  Otherwise,
+ * renew/retry subscription as needed (in case it is timing out, or we
+ * got an ENOMEM).  And keep the monitor connection alive.
+ */
+static void delayed_work(struct work_struct *work)
+{
+       struct ceph_mon_client *monc =
+               container_of(work, struct ceph_mon_client, delayed_work.work);
+
+       dout("monc delayed_work\n");
+       mutex_lock(&monc->mutex);
+       if (monc->hunting) {
+               __close_session(monc);
+               __open_session(monc);  /* continue hunting */
+       } else {
+               ceph_con_keepalive(monc->con);
+
+               __validate_auth(monc);
+
+               if (monc->auth->ops->is_authenticated(monc->auth))
+                       __send_subscribe(monc);
+       }
+       __schedule_delayed(monc);
+       mutex_unlock(&monc->mutex);
+}
+
+/*
+ * On startup, we build a temporary monmap populated with the IPs
+ * provided by mount(2).
+ */
+static int build_initial_monmap(struct ceph_mon_client *monc)
+{
+       struct ceph_mount_args *args = monc->client->mount_args;
+       struct ceph_entity_addr *mon_addr = args->mon_addr;
+       int num_mon = args->num_mon;
+       int i;
+
+       /* build initial monmap */
+       monc->monmap = kzalloc(sizeof(*monc->monmap) +
+                              num_mon*sizeof(monc->monmap->mon_inst[0]),
+                              GFP_KERNEL);
+       if (!monc->monmap)
+               return -ENOMEM;
+       for (i = 0; i < num_mon; i++) {
+               monc->monmap->mon_inst[i].addr = mon_addr[i];
+               monc->monmap->mon_inst[i].addr.nonce = 0;
+               monc->monmap->mon_inst[i].name.type =
+                       CEPH_ENTITY_TYPE_MON;
+               monc->monmap->mon_inst[i].name.num = cpu_to_le64(i);
+       }
+       monc->monmap->num_mon = num_mon;
+       monc->have_fsid = false;
+
+       /* release addr memory */
+       kfree(args->mon_addr);
+       args->mon_addr = NULL;
+       args->num_mon = 0;
+       return 0;
+}
+
+int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
+{
+       int err = 0;
+
+       dout("init\n");
+       memset(monc, 0, sizeof(*monc));
+       monc->client = cl;
+       monc->monmap = NULL;
+       mutex_init(&monc->mutex);
+
+       err = build_initial_monmap(monc);
+       if (err)
+               goto out;
+
+       monc->con = NULL;
+
+       /* authentication */
+       monc->auth = ceph_auth_init(cl->mount_args->name,
+                                   cl->mount_args->secret);
+       if (IS_ERR(monc->auth))
+               return PTR_ERR(monc->auth);
+       monc->auth->want_keys =
+               CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
+               CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS;
+
+       /* msg pools */
+       err = ceph_msgpool_init(&monc->msgpool_subscribe_ack,
+                              sizeof(struct ceph_mon_subscribe_ack), 1, false);
+       if (err < 0)
+               goto out_monmap;
+       err = ceph_msgpool_init(&monc->msgpool_statfs_reply,
+                               sizeof(struct ceph_mon_statfs_reply), 0, false);
+       if (err < 0)
+               goto out_pool1;
+       err = ceph_msgpool_init(&monc->msgpool_auth_reply, 4096, 1, false);
+       if (err < 0)
+               goto out_pool2;
+
+       monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, 0, 0, NULL);
+       monc->pending_auth = 0;
+       if (IS_ERR(monc->m_auth)) {
+               err = PTR_ERR(monc->m_auth);
+               monc->m_auth = NULL;
+               goto out_pool3;
+       }
+
+       monc->cur_mon = -1;
+       monc->hunting = true;
+       monc->sub_renew_after = jiffies;
+       monc->sub_sent = 0;
+
+       INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
+       monc->statfs_request_tree = RB_ROOT;
+       monc->num_statfs_requests = 0;
+       monc->last_tid = 0;
+
+       monc->have_mdsmap = 0;
+       monc->have_osdmap = 0;
+       monc->want_next_osdmap = 1;
+       return 0;
+
+out_pool3:
+       ceph_msgpool_destroy(&monc->msgpool_auth_reply);
+out_pool2:
+       ceph_msgpool_destroy(&monc->msgpool_subscribe_ack);
+out_pool1:
+       ceph_msgpool_destroy(&monc->msgpool_statfs_reply);
+out_monmap:
+       kfree(monc->monmap);
+out:
+       return err;
+}
+
+void ceph_monc_stop(struct ceph_mon_client *monc)
+{
+       dout("stop\n");
+       cancel_delayed_work_sync(&monc->delayed_work);
+
+       mutex_lock(&monc->mutex);
+       __close_session(monc);
+       if (monc->con) {
+               monc->con->private = NULL;
+               monc->con->ops->put(monc->con);
+               monc->con = NULL;
+       }
+       mutex_unlock(&monc->mutex);
+
+       ceph_auth_destroy(monc->auth);
+
+       ceph_msg_put(monc->m_auth);
+       ceph_msgpool_destroy(&monc->msgpool_subscribe_ack);
+       ceph_msgpool_destroy(&monc->msgpool_statfs_reply);
+       ceph_msgpool_destroy(&monc->msgpool_auth_reply);
+
+       kfree(monc->monmap);
+}
+
+static void handle_auth_reply(struct ceph_mon_client *monc,
+                             struct ceph_msg *msg)
+{
+       int ret;
+
+       mutex_lock(&monc->mutex);
+       monc->pending_auth = 0;
+       ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base,
+                                    msg->front.iov_len,
+                                    monc->m_auth->front.iov_base,
+                                    monc->m_auth->front_max);
+       if (ret < 0) {
+               monc->client->auth_err = ret;
+               wake_up(&monc->client->auth_wq);
+       } else if (ret > 0) {
+               __send_prepared_auth_request(monc, ret);
+       } else if (monc->auth->ops->is_authenticated(monc->auth)) {
+               dout("authenticated, starting session\n");
+
+               monc->client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT;
+               monc->client->msgr->inst.name.num = monc->auth->global_id;
+
+               __send_subscribe(monc);
+               __resend_statfs(monc);
+       }
+       mutex_unlock(&monc->mutex);
+}
+
+static int __validate_auth(struct ceph_mon_client *monc)
+{
+       int ret;
+
+       if (monc->pending_auth)
+               return 0;
+
+       ret = ceph_build_auth(monc->auth, monc->m_auth->front.iov_base,
+                             monc->m_auth->front_max);
+       if (ret <= 0)
+               return ret; /* either an error, or no need to authenticate */
+       __send_prepared_auth_request(monc, ret);
+       return 0;
+}
+
+int ceph_monc_validate_auth(struct ceph_mon_client *monc)
+{
+       int ret;
+
+       mutex_lock(&monc->mutex);
+       ret = __validate_auth(monc);
+       mutex_unlock(&monc->mutex);
+       return ret;
+}
+
+/*
+ * handle incoming message
+ */
+static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       struct ceph_mon_client *monc = con->private;
+       int type = le16_to_cpu(msg->hdr.type);
+
+       if (!monc)
+               return;
+
+       switch (type) {
+       case CEPH_MSG_AUTH_REPLY:
+               handle_auth_reply(monc, msg);
+               break;
+
+       case CEPH_MSG_MON_SUBSCRIBE_ACK:
+               handle_subscribe_ack(monc, msg);
+               break;
+
+       case CEPH_MSG_STATFS_REPLY:
+               handle_statfs_reply(monc, msg);
+               break;
+
+       case CEPH_MSG_MON_MAP:
+               ceph_monc_handle_map(monc, msg);
+               break;
+
+       case CEPH_MSG_MDS_MAP:
+               ceph_mdsc_handle_map(&monc->client->mdsc, msg);
+               break;
+
+       case CEPH_MSG_OSD_MAP:
+               ceph_osdc_handle_map(&monc->client->osdc, msg);
+               break;
+
+       default:
+               pr_err("received unknown message type %d %s\n", type,
+                      ceph_msg_type_name(type));
+       }
+       ceph_msg_put(msg);
+}
+
+/*
+ * Allocate memory for incoming message
+ */
+static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
+                                     struct ceph_msg_header *hdr,
+                                     int *skip)
+{
+       struct ceph_mon_client *monc = con->private;
+       int type = le16_to_cpu(hdr->type);
+       int front_len = le32_to_cpu(hdr->front_len);
+       struct ceph_msg *m = NULL;
+
+       *skip = 0;
+
+       switch (type) {
+       case CEPH_MSG_MON_SUBSCRIBE_ACK:
+               m = ceph_msgpool_get(&monc->msgpool_subscribe_ack, front_len);
+               break;
+       case CEPH_MSG_STATFS_REPLY:
+               m = ceph_msgpool_get(&monc->msgpool_statfs_reply, front_len);
+               break;
+       case CEPH_MSG_AUTH_REPLY:
+               m = ceph_msgpool_get(&monc->msgpool_auth_reply, front_len);
+               break;
+       case CEPH_MSG_MON_MAP:
+       case CEPH_MSG_MDS_MAP:
+       case CEPH_MSG_OSD_MAP:
+               m = ceph_msg_new(type, front_len, 0, 0, NULL);
+               break;
+       }
+
+       if (!m) {
+               pr_info("alloc_msg unknown type %d\n", type);
+               *skip = 1;
+       }
+       return m;
+}
+
+/*
+ * If the monitor connection resets, pick a new monitor and resubmit
+ * any pending requests.
+ */
+static void mon_fault(struct ceph_connection *con)
+{
+       struct ceph_mon_client *monc = con->private;
+
+       if (!monc)
+               return;
+
+       dout("mon_fault\n");
+       mutex_lock(&monc->mutex);
+       if (!con->private)
+               goto out;
+
+       if (monc->con && !monc->hunting)
+               pr_info("mon%d %s session lost, "
+                       "hunting for new mon\n", monc->cur_mon,
+                       pr_addr(&monc->con->peer_addr.in_addr));
+
+       __close_session(monc);
+       if (!monc->hunting) {
+               /* start hunting */
+               monc->hunting = true;
+               __open_session(monc);
+       } else {
+               /* already hunting, let's wait a bit */
+               __schedule_delayed(monc);
+       }
+out:
+       mutex_unlock(&monc->mutex);
+}
+
+const static struct ceph_connection_operations mon_con_ops = {
+       .get = ceph_con_get,
+       .put = ceph_con_put,
+       .dispatch = dispatch,
+       .fault = mon_fault,
+       .alloc_msg = mon_alloc_msg,
+};
diff --git a/fs/ceph/mon_client.h b/fs/ceph/mon_client.h
new file mode 100644 (file)
index 0000000..b958ad5
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef _FS_CEPH_MON_CLIENT_H
+#define _FS_CEPH_MON_CLIENT_H
+
+#include <linux/completion.h>
+#include <linux/rbtree.h>
+
+#include "messenger.h"
+#include "msgpool.h"
+
+struct ceph_client;
+struct ceph_mount_args;
+struct ceph_auth_client;
+
+/*
+ * The monitor map enumerates the set of all monitors.
+ */
+struct ceph_monmap {
+       struct ceph_fsid fsid;
+       u32 epoch;
+       u32 num_mon;
+       struct ceph_entity_inst mon_inst[0];
+};
+
+struct ceph_mon_client;
+struct ceph_mon_statfs_request;
+
+
+/*
+ * Generic mechanism for resending monitor requests.
+ */
+typedef void (*ceph_monc_request_func_t)(struct ceph_mon_client *monc,
+                                        int newmon);
+
+/* a pending monitor request */
+struct ceph_mon_request {
+       struct ceph_mon_client *monc;
+       struct delayed_work delayed_work;
+       unsigned long delay;
+       ceph_monc_request_func_t do_request;
+};
+
+/*
+ * statfs() is done a bit differently because we need to get data back
+ * to the caller
+ */
+struct ceph_mon_statfs_request {
+       u64 tid;
+       struct rb_node node;
+       int result;
+       struct ceph_statfs *buf;
+       struct completion completion;
+       unsigned long last_attempt, delay; /* jiffies */
+       struct ceph_msg *request;  /* original request */
+};
+
+struct ceph_mon_client {
+       struct ceph_client *client;
+       struct ceph_monmap *monmap;
+
+       struct mutex mutex;
+       struct delayed_work delayed_work;
+
+       struct ceph_auth_client *auth;
+       struct ceph_msg *m_auth;
+       int pending_auth;
+
+       bool hunting;
+       int cur_mon;                       /* last monitor i contacted */
+       unsigned long sub_sent, sub_renew_after;
+       struct ceph_connection *con;
+       bool have_fsid;
+
+       /* msg pools */
+       struct ceph_msgpool msgpool_subscribe_ack;
+       struct ceph_msgpool msgpool_statfs_reply;
+       struct ceph_msgpool msgpool_auth_reply;
+
+       /* pending statfs requests */
+       struct rb_root statfs_request_tree;
+       int num_statfs_requests;
+       u64 last_tid;
+
+       /* mds/osd map */
+       int want_next_osdmap; /* 1 = want, 2 = want+asked */
+       u32 have_osdmap, have_mdsmap;
+
+#ifdef CONFIG_DEBUG_FS
+       struct dentry *debugfs_file;
+#endif
+};
+
+extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
+extern int ceph_monmap_contains(struct ceph_monmap *m,
+                               struct ceph_entity_addr *addr);
+
+extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
+extern void ceph_monc_stop(struct ceph_mon_client *monc);
+
+/*
+ * The model here is to indicate that we need a new map of at least
+ * epoch @want, and also call in when we receive a map.  We will
+ * periodically rerequest the map from the monitor cluster until we
+ * get what we want.
+ */
+extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, u32 have);
+extern int ceph_monc_got_osdmap(struct ceph_mon_client *monc, u32 have);
+
+extern void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc);
+
+extern int ceph_monc_do_statfs(struct ceph_mon_client *monc,
+                              struct ceph_statfs *buf);
+
+extern int ceph_monc_open_session(struct ceph_mon_client *monc);
+
+extern int ceph_monc_validate_auth(struct ceph_mon_client *monc);
+
+
+
+#endif
diff --git a/fs/ceph/msgpool.c b/fs/ceph/msgpool.c
new file mode 100644 (file)
index 0000000..ca3b44a
--- /dev/null
@@ -0,0 +1,186 @@
+#include "ceph_debug.h"
+
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/vmalloc.h>
+
+#include "msgpool.h"
+
+/*
+ * We use msg pools to preallocate memory for messages we expect to
+ * receive over the wire, to avoid getting ourselves into OOM
+ * conditions at unexpected times.  We take use a few different
+ * strategies:
+ *
+ *  - for request/response type interactions, we preallocate the
+ * memory needed for the response when we generate the request.
+ *
+ *  - for messages we can receive at any time from the MDS, we preallocate
+ * a pool of messages we can re-use.
+ *
+ *  - for writeback, we preallocate some number of messages to use for
+ * requests and their replies, so that we always make forward
+ * progress.
+ *
+ * The msgpool behaves like a mempool_t, but keeps preallocated
+ * ceph_msgs strung together on a list_head instead of using a pointer
+ * vector.  This avoids vector reallocation when we adjust the number
+ * of preallocated items (which happens frequently).
+ */
+
+
+/*
+ * Allocate or release as necessary to meet our target pool size.
+ */
+static int __fill_msgpool(struct ceph_msgpool *pool)
+{
+       struct ceph_msg *msg;
+
+       while (pool->num < pool->min) {
+               dout("fill_msgpool %p %d/%d allocating\n", pool, pool->num,
+                    pool->min);
+               spin_unlock(&pool->lock);
+               msg = ceph_msg_new(0, pool->front_len, 0, 0, NULL);
+               spin_lock(&pool->lock);
+               if (IS_ERR(msg))
+                       return PTR_ERR(msg);
+               msg->pool = pool;
+               list_add(&msg->list_head, &pool->msgs);
+               pool->num++;
+       }
+       while (pool->num > pool->min) {
+               msg = list_first_entry(&pool->msgs, struct ceph_msg, list_head);
+               dout("fill_msgpool %p %d/%d releasing %p\n", pool, pool->num,
+                    pool->min, msg);
+               list_del_init(&msg->list_head);
+               pool->num--;
+               ceph_msg_kfree(msg);
+       }
+       return 0;
+}
+
+int ceph_msgpool_init(struct ceph_msgpool *pool,
+                     int front_len, int min, bool blocking)
+{
+       int ret;
+
+       dout("msgpool_init %p front_len %d min %d\n", pool, front_len, min);
+       spin_lock_init(&pool->lock);
+       pool->front_len = front_len;
+       INIT_LIST_HEAD(&pool->msgs);
+       pool->num = 0;
+       pool->min = min;
+       pool->blocking = blocking;
+       init_waitqueue_head(&pool->wait);
+
+       spin_lock(&pool->lock);
+       ret = __fill_msgpool(pool);
+       spin_unlock(&pool->lock);
+       return ret;
+}
+
+void ceph_msgpool_destroy(struct ceph_msgpool *pool)
+{
+       dout("msgpool_destroy %p\n", pool);
+       spin_lock(&pool->lock);
+       pool->min = 0;
+       __fill_msgpool(pool);
+       spin_unlock(&pool->lock);
+}
+
+int ceph_msgpool_resv(struct ceph_msgpool *pool, int delta)
+{
+       int ret;
+
+       spin_lock(&pool->lock);
+       dout("msgpool_resv %p delta %d\n", pool, delta);
+       pool->min += delta;
+       ret = __fill_msgpool(pool);
+       spin_unlock(&pool->lock);
+       return ret;
+}
+
+struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *pool, int front_len)
+{
+       wait_queue_t wait;
+       struct ceph_msg *msg;
+
+       if (front_len && front_len > pool->front_len) {
+               pr_err("msgpool_get pool %p need front %d, pool size is %d\n",
+                      pool, front_len, pool->front_len);
+               WARN_ON(1);
+
+               /* try to alloc a fresh message */
+               msg = ceph_msg_new(0, front_len, 0, 0, NULL);
+               if (!IS_ERR(msg))
+                       return msg;
+       }
+
+       if (!front_len)
+               front_len = pool->front_len;
+
+       if (pool->blocking) {
+               /* mempool_t behavior; first try to alloc */
+               msg = ceph_msg_new(0, front_len, 0, 0, NULL);
+               if (!IS_ERR(msg))
+                       return msg;
+       }
+
+       while (1) {
+               spin_lock(&pool->lock);
+               if (likely(pool->num)) {
+                       msg = list_entry(pool->msgs.next, struct ceph_msg,
+                                        list_head);
+                       list_del_init(&msg->list_head);
+                       pool->num--;
+                       dout("msgpool_get %p got %p, now %d/%d\n", pool, msg,
+                            pool->num, pool->min);
+                       spin_unlock(&pool->lock);
+                       return msg;
+               }
+               pr_err("msgpool_get %p now %d/%d, %s\n", pool, pool->num,
+                      pool->min, pool->blocking ? "waiting" : "may fail");
+               spin_unlock(&pool->lock);
+
+               if (!pool->blocking) {
+                       WARN_ON(1);
+
+                       /* maybe we can allocate it now? */
+                       msg = ceph_msg_new(0, front_len, 0, 0, NULL);
+                       if (!IS_ERR(msg))
+                               return msg;
+
+                       pr_err("msgpool_get %p empty + alloc failed\n", pool);
+                       return ERR_PTR(-ENOMEM);
+               }
+
+               init_wait(&wait);
+               prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
+               schedule();
+               finish_wait(&pool->wait, &wait);
+       }
+}
+
+void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg)
+{
+       spin_lock(&pool->lock);
+       if (pool->num < pool->min) {
+               /* reset msg front_len; user may have changed it */
+               msg->front.iov_len = pool->front_len;
+               msg->hdr.front_len = cpu_to_le32(pool->front_len);
+
+               kref_set(&msg->kref, 1);  /* retake a single ref */
+               list_add(&msg->list_head, &pool->msgs);
+               pool->num++;
+               dout("msgpool_put %p reclaim %p, now %d/%d\n", pool, msg,
+                    pool->num, pool->min);
+               spin_unlock(&pool->lock);
+               wake_up(&pool->wait);
+       } else {
+               dout("msgpool_put %p drop %p, at %d/%d\n", pool, msg,
+                    pool->num, pool->min);
+               spin_unlock(&pool->lock);
+               ceph_msg_kfree(msg);
+       }
+}
diff --git a/fs/ceph/msgpool.h b/fs/ceph/msgpool.h
new file mode 100644 (file)
index 0000000..bc834bf
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _FS_CEPH_MSGPOOL
+#define _FS_CEPH_MSGPOOL
+
+#include "messenger.h"
+
+/*
+ * we use memory pools for preallocating messages we may receive, to
+ * avoid unexpected OOM conditions.
+ */
+struct ceph_msgpool {
+       spinlock_t lock;
+       int front_len;          /* preallocated payload size */
+       struct list_head msgs;  /* msgs in the pool; each has 1 ref */
+       int num, min;           /* cur, min # msgs in the pool */
+       bool blocking;
+       wait_queue_head_t wait;
+};
+
+extern int ceph_msgpool_init(struct ceph_msgpool *pool,
+                            int front_len, int size, bool blocking);
+extern void ceph_msgpool_destroy(struct ceph_msgpool *pool);
+extern int ceph_msgpool_resv(struct ceph_msgpool *, int delta);
+extern struct ceph_msg *ceph_msgpool_get(struct ceph_msgpool *,
+                                        int front_len);
+extern void ceph_msgpool_put(struct ceph_msgpool *, struct ceph_msg *);
+
+#endif
diff --git a/fs/ceph/msgr.h b/fs/ceph/msgr.h
new file mode 100644 (file)
index 0000000..8aaab41
--- /dev/null
@@ -0,0 +1,158 @@
+#ifndef __MSGR_H
+#define __MSGR_H
+
+/*
+ * Data types for message passing layer used by Ceph.
+ */
+
+#define CEPH_MON_PORT    6789  /* default monitor port */
+
+/*
+ * client-side processes will try to bind to ports in this
+ * range, simply for the benefit of tools like nmap or wireshark
+ * that would like to identify the protocol.
+ */
+#define CEPH_PORT_FIRST  6789
+#define CEPH_PORT_START  6800  /* non-monitors start here */
+#define CEPH_PORT_LAST   6900
+
+/*
+ * tcp connection banner.  include a protocol version. and adjust
+ * whenever the wire protocol changes.  try to keep this string length
+ * constant.
+ */
+#define CEPH_BANNER "ceph v027"
+#define CEPH_BANNER_MAX_LEN 30
+
+
+/*
+ * Rollover-safe type and comparator for 32-bit sequence numbers.
+ * Comparator returns -1, 0, or 1.
+ */
+typedef __u32 ceph_seq_t;
+
+static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
+{
+       return (__s32)a - (__s32)b;
+}
+
+
+/*
+ * entity_name -- logical name for a process participating in the
+ * network, e.g. 'mds0' or 'osd3'.
+ */
+struct ceph_entity_name {
+       __u8 type;      /* CEPH_ENTITY_TYPE_* */
+       __le64 num;
+} __attribute__ ((packed));
+
+#define CEPH_ENTITY_TYPE_MON    0x01
+#define CEPH_ENTITY_TYPE_MDS    0x02
+#define CEPH_ENTITY_TYPE_OSD    0x04
+#define CEPH_ENTITY_TYPE_CLIENT 0x08
+#define CEPH_ENTITY_TYPE_ADMIN  0x10
+#define CEPH_ENTITY_TYPE_AUTH   0x20
+
+#define CEPH_ENTITY_TYPE_ANY    0xFF
+
+extern const char *ceph_entity_type_name(int type);
+
+/*
+ * entity_addr -- network address
+ */
+struct ceph_entity_addr {
+       __le32 type;
+       __le32 nonce;  /* unique id for process (e.g. pid) */
+       struct sockaddr_storage in_addr;
+} __attribute__ ((packed));
+
+struct ceph_entity_inst {
+       struct ceph_entity_name name;
+       struct ceph_entity_addr addr;
+} __attribute__ ((packed));
+
+
+/* used by message exchange protocol */
+#define CEPH_MSGR_TAG_READY         1  /* server->client: ready for messages */
+#define CEPH_MSGR_TAG_RESETSESSION  2  /* server->client: reset, try again */
+#define CEPH_MSGR_TAG_WAIT          3  /* server->client: wait for racing
+                                         incoming connection */
+#define CEPH_MSGR_TAG_RETRY_SESSION 4  /* server->client + cseq: try again
+                                         with higher cseq */
+#define CEPH_MSGR_TAG_RETRY_GLOBAL  5  /* server->client + gseq: try again
+                                         with higher gseq */
+#define CEPH_MSGR_TAG_CLOSE         6  /* closing pipe */
+#define CEPH_MSGR_TAG_MSG           7  /* message */
+#define CEPH_MSGR_TAG_ACK           8  /* message ack */
+#define CEPH_MSGR_TAG_KEEPALIVE     9  /* just a keepalive byte! */
+#define CEPH_MSGR_TAG_BADPROTOVER  10  /* bad protocol version */
+#define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
+#define CEPH_MSGR_TAG_FEATURES      12 /* insufficient features */
+
+
+/*
+ * connection negotiation
+ */
+struct ceph_msg_connect {
+       __le64 features;     /* supported feature bits */
+       __le32 host_type;    /* CEPH_ENTITY_TYPE_* */
+       __le32 global_seq;   /* count connections initiated by this host */
+       __le32 connect_seq;  /* count connections initiated in this session */
+       __le32 protocol_version;
+       __le32 authorizer_protocol;
+       __le32 authorizer_len;
+       __u8  flags;         /* CEPH_MSG_CONNECT_* */
+} __attribute__ ((packed));
+
+struct ceph_msg_connect_reply {
+       __u8 tag;
+       __le64 features;     /* feature bits for this session */
+       __le32 global_seq;
+       __le32 connect_seq;
+       __le32 protocol_version;
+       __le32 authorizer_len;
+       __u8 flags;
+} __attribute__ ((packed));
+
+#define CEPH_MSG_CONNECT_LOSSY  1  /* messages i send may be safely dropped */
+
+
+/*
+ * message header
+ */
+struct ceph_msg_header {
+       __le64 seq;       /* message seq# for this session */
+       __le64 tid;       /* transaction id */
+       __le16 type;      /* message type */
+       __le16 priority;  /* priority.  higher value == higher priority */
+       __le16 version;   /* version of message encoding */
+
+       __le32 front_len; /* bytes in main payload */
+       __le32 middle_len;/* bytes in middle payload */
+       __le32 data_len;  /* bytes of data payload */
+       __le16 data_off;  /* sender: include full offset;
+                            receiver: mask against ~PAGE_MASK */
+
+       struct ceph_entity_inst src, orig_src;
+       __le32 reserved;
+       __le32 crc;       /* header crc32c */
+} __attribute__ ((packed));
+
+#define CEPH_MSG_PRIO_LOW     64
+#define CEPH_MSG_PRIO_DEFAULT 127
+#define CEPH_MSG_PRIO_HIGH    196
+#define CEPH_MSG_PRIO_HIGHEST 255
+
+/*
+ * follows data payload
+ */
+struct ceph_msg_footer {
+       __le32 front_crc, middle_crc, data_crc;
+       __u8 flags;
+} __attribute__ ((packed));
+
+#define CEPH_MSG_FOOTER_COMPLETE  (1<<0)   /* msg wasn't aborted */
+#define CEPH_MSG_FOOTER_NOCRC     (1<<1)   /* no data crc */
+
+
+#endif
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c
new file mode 100644 (file)
index 0000000..c7b4ded
--- /dev/null
@@ -0,0 +1,1550 @@
+#include "ceph_debug.h"
+
+#include <linux/err.h>
+#include <linux/highmem.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#include "super.h"
+#include "osd_client.h"
+#include "messenger.h"
+#include "decode.h"
+#include "auth.h"
+
+#define OSD_OP_FRONT_LEN       4096
+#define OSD_OPREPLY_FRONT_LEN  512
+
+const static struct ceph_connection_operations osd_con_ops;
+static int __kick_requests(struct ceph_osd_client *osdc,
+                         struct ceph_osd *kickosd);
+
+static void kick_requests(struct ceph_osd_client *osdc, struct ceph_osd *osd);
+
+/*
+ * Implement client access to distributed object storage cluster.
+ *
+ * All data objects are stored within a cluster/cloud of OSDs, or
+ * "object storage devices."  (Note that Ceph OSDs have _nothing_ to
+ * do with the T10 OSD extensions to SCSI.)  Ceph OSDs are simply
+ * remote daemons serving up and coordinating consistent and safe
+ * access to storage.
+ *
+ * Cluster membership and the mapping of data objects onto storage devices
+ * are described by the osd map.
+ *
+ * We keep track of pending OSD requests (read, write), resubmit
+ * requests to different OSDs when the cluster topology/data layout
+ * change, or retry the affected requests when the communications
+ * channel with an OSD is reset.
+ */
+
+/*
+ * calculate the mapping of a file extent onto an object, and fill out the
+ * request accordingly.  shorten extent as necessary if it crosses an
+ * object boundary.
+ *
+ * fill osd op in request message.
+ */
+static void calc_layout(struct ceph_osd_client *osdc,
+                       struct ceph_vino vino, struct ceph_file_layout *layout,
+                       u64 off, u64 *plen,
+                       struct ceph_osd_request *req)
+{
+       struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base;
+       struct ceph_osd_op *op = (void *)(reqhead + 1);
+       u64 orig_len = *plen;
+       u64 objoff, objlen;    /* extent in object */
+       u64 bno;
+
+       reqhead->snapid = cpu_to_le64(vino.snap);
+
+       /* object extent? */
+       ceph_calc_file_object_mapping(layout, off, plen, &bno,
+                                     &objoff, &objlen);
+       if (*plen < orig_len)
+               dout(" skipping last %llu, final file extent %llu~%llu\n",
+                    orig_len - *plen, off, *plen);
+
+       sprintf(req->r_oid, "%llx.%08llx", vino.ino, bno);
+       req->r_oid_len = strlen(req->r_oid);
+
+       op->extent.offset = cpu_to_le64(objoff);
+       op->extent.length = cpu_to_le64(objlen);
+       req->r_num_pages = calc_pages_for(off, *plen);
+
+       dout("calc_layout %s (%d) %llu~%llu (%d pages)\n",
+            req->r_oid, req->r_oid_len, objoff, objlen, req->r_num_pages);
+}
+
+/*
+ * requests
+ */
+void ceph_osdc_release_request(struct kref *kref)
+{
+       struct ceph_osd_request *req = container_of(kref,
+                                                   struct ceph_osd_request,
+                                                   r_kref);
+
+       if (req->r_request)
+               ceph_msg_put(req->r_request);
+       if (req->r_reply)
+               ceph_msg_put(req->r_reply);
+       if (req->r_con_filling_msg) {
+               dout("release_request revoking pages %p from con %p\n",
+                    req->r_pages, req->r_con_filling_msg);
+               ceph_con_revoke_message(req->r_con_filling_msg,
+                                     req->r_reply);
+               ceph_con_put(req->r_con_filling_msg);
+       }
+       if (req->r_own_pages)
+               ceph_release_page_vector(req->r_pages,
+                                        req->r_num_pages);
+       ceph_put_snap_context(req->r_snapc);
+       if (req->r_mempool)
+               mempool_free(req, req->r_osdc->req_mempool);
+       else
+               kfree(req);
+}
+
+/*
+ * build new request AND message, calculate layout, and adjust file
+ * extent as needed.
+ *
+ * if the file was recently truncated, we include information about its
+ * old and new size so that the object can be updated appropriately.  (we
+ * avoid synchronously deleting truncated objects because it's slow.)
+ *
+ * if @do_sync, include a 'startsync' command so that the osd will flush
+ * data quickly.
+ */
+struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
+                                              struct ceph_file_layout *layout,
+                                              struct ceph_vino vino,
+                                              u64 off, u64 *plen,
+                                              int opcode, int flags,
+                                              struct ceph_snap_context *snapc,
+                                              int do_sync,
+                                              u32 truncate_seq,
+                                              u64 truncate_size,
+                                              struct timespec *mtime,
+                                              bool use_mempool, int num_reply)
+{
+       struct ceph_osd_request *req;
+       struct ceph_msg *msg;
+       struct ceph_osd_request_head *head;
+       struct ceph_osd_op *op;
+       void *p;
+       int num_op = 1 + do_sync;
+       size_t msg_size = sizeof(*head) + num_op*sizeof(*op);
+       int i;
+
+       if (use_mempool) {
+               req = mempool_alloc(osdc->req_mempool, GFP_NOFS);
+               memset(req, 0, sizeof(*req));
+       } else {
+               req = kzalloc(sizeof(*req), GFP_NOFS);
+       }
+       if (req == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       req->r_osdc = osdc;
+       req->r_mempool = use_mempool;
+       kref_init(&req->r_kref);
+       init_completion(&req->r_completion);
+       init_completion(&req->r_safe_completion);
+       INIT_LIST_HEAD(&req->r_unsafe_item);
+       req->r_flags = flags;
+
+       WARN_ON((flags & (CEPH_OSD_FLAG_READ|CEPH_OSD_FLAG_WRITE)) == 0);
+
+       /* create reply message */
+       if (use_mempool)
+               msg = ceph_msgpool_get(&osdc->msgpool_op_reply, 0);
+       else
+               msg = ceph_msg_new(CEPH_MSG_OSD_OPREPLY,
+                                  OSD_OPREPLY_FRONT_LEN, 0, 0, NULL);
+       if (IS_ERR(msg)) {
+               ceph_osdc_put_request(req);
+               return ERR_PTR(PTR_ERR(msg));
+       }
+       req->r_reply = msg;
+
+       /* create request message; allow space for oid */
+       msg_size += 40;
+       if (snapc)
+               msg_size += sizeof(u64) * snapc->num_snaps;
+       if (use_mempool)
+               msg = ceph_msgpool_get(&osdc->msgpool_op, 0);
+       else
+               msg = ceph_msg_new(CEPH_MSG_OSD_OP, msg_size, 0, 0, NULL);
+       if (IS_ERR(msg)) {
+               ceph_osdc_put_request(req);
+               return ERR_PTR(PTR_ERR(msg));
+       }
+       msg->hdr.type = cpu_to_le16(CEPH_MSG_OSD_OP);
+       memset(msg->front.iov_base, 0, msg->front.iov_len);
+       head = msg->front.iov_base;
+       op = (void *)(head + 1);
+       p = (void *)(op + num_op);
+
+       req->r_request = msg;
+       req->r_snapc = ceph_get_snap_context(snapc);
+
+       head->client_inc = cpu_to_le32(1); /* always, for now. */
+       head->flags = cpu_to_le32(flags);
+       if (flags & CEPH_OSD_FLAG_WRITE)
+               ceph_encode_timespec(&head->mtime, mtime);
+       head->num_ops = cpu_to_le16(num_op);
+       op->op = cpu_to_le16(opcode);
+
+       /* calculate max write size */
+       calc_layout(osdc, vino, layout, off, plen, req);
+       req->r_file_layout = *layout;  /* keep a copy */
+
+       if (flags & CEPH_OSD_FLAG_WRITE) {
+               req->r_request->hdr.data_off = cpu_to_le16(off);
+               req->r_request->hdr.data_len = cpu_to_le32(*plen);
+               op->payload_len = cpu_to_le32(*plen);
+       }
+       op->extent.truncate_size = cpu_to_le64(truncate_size);
+       op->extent.truncate_seq = cpu_to_le32(truncate_seq);
+
+       /* fill in oid */
+       head->object_len = cpu_to_le32(req->r_oid_len);
+       memcpy(p, req->r_oid, req->r_oid_len);
+       p += req->r_oid_len;
+
+       if (do_sync) {
+               op++;
+               op->op = cpu_to_le16(CEPH_OSD_OP_STARTSYNC);
+       }
+       if (snapc) {
+               head->snap_seq = cpu_to_le64(snapc->seq);
+               head->num_snaps = cpu_to_le32(snapc->num_snaps);
+               for (i = 0; i < snapc->num_snaps; i++) {
+                       put_unaligned_le64(snapc->snaps[i], p);
+                       p += sizeof(u64);
+               }
+       }
+
+       BUG_ON(p > msg->front.iov_base + msg->front.iov_len);
+       msg_size = p - msg->front.iov_base;
+       msg->front.iov_len = msg_size;
+       msg->hdr.front_len = cpu_to_le32(msg_size);
+       return req;
+}
+
+/*
+ * We keep osd requests in an rbtree, sorted by ->r_tid.
+ */
+static void __insert_request(struct ceph_osd_client *osdc,
+                            struct ceph_osd_request *new)
+{
+       struct rb_node **p = &osdc->requests.rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_osd_request *req = NULL;
+
+       while (*p) {
+               parent = *p;
+               req = rb_entry(parent, struct ceph_osd_request, r_node);
+               if (new->r_tid < req->r_tid)
+                       p = &(*p)->rb_left;
+               else if (new->r_tid > req->r_tid)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->r_node, parent, p);
+       rb_insert_color(&new->r_node, &osdc->requests);
+}
+
+static struct ceph_osd_request *__lookup_request(struct ceph_osd_client *osdc,
+                                                u64 tid)
+{
+       struct ceph_osd_request *req;
+       struct rb_node *n = osdc->requests.rb_node;
+
+       while (n) {
+               req = rb_entry(n, struct ceph_osd_request, r_node);
+               if (tid < req->r_tid)
+                       n = n->rb_left;
+               else if (tid > req->r_tid)
+                       n = n->rb_right;
+               else
+                       return req;
+       }
+       return NULL;
+}
+
+static struct ceph_osd_request *
+__lookup_request_ge(struct ceph_osd_client *osdc,
+                   u64 tid)
+{
+       struct ceph_osd_request *req;
+       struct rb_node *n = osdc->requests.rb_node;
+
+       while (n) {
+               req = rb_entry(n, struct ceph_osd_request, r_node);
+               if (tid < req->r_tid) {
+                       if (!n->rb_left)
+                               return req;
+                       n = n->rb_left;
+               } else if (tid > req->r_tid) {
+                       n = n->rb_right;
+               } else {
+                       return req;
+               }
+       }
+       return NULL;
+}
+
+
+/*
+ * If the osd connection drops, we need to resubmit all requests.
+ */
+static void osd_reset(struct ceph_connection *con)
+{
+       struct ceph_osd *osd = con->private;
+       struct ceph_osd_client *osdc;
+
+       if (!osd)
+               return;
+       dout("osd_reset osd%d\n", osd->o_osd);
+       osdc = osd->o_osdc;
+       down_read(&osdc->map_sem);
+       kick_requests(osdc, osd);
+       up_read(&osdc->map_sem);
+}
+
+/*
+ * Track open sessions with osds.
+ */
+static struct ceph_osd *create_osd(struct ceph_osd_client *osdc)
+{
+       struct ceph_osd *osd;
+
+       osd = kzalloc(sizeof(*osd), GFP_NOFS);
+       if (!osd)
+               return NULL;
+
+       atomic_set(&osd->o_ref, 1);
+       osd->o_osdc = osdc;
+       INIT_LIST_HEAD(&osd->o_requests);
+       INIT_LIST_HEAD(&osd->o_osd_lru);
+       osd->o_incarnation = 1;
+
+       ceph_con_init(osdc->client->msgr, &osd->o_con);
+       osd->o_con.private = osd;
+       osd->o_con.ops = &osd_con_ops;
+       osd->o_con.peer_name.type = CEPH_ENTITY_TYPE_OSD;
+
+       INIT_LIST_HEAD(&osd->o_keepalive_item);
+       return osd;
+}
+
+static struct ceph_osd *get_osd(struct ceph_osd *osd)
+{
+       if (atomic_inc_not_zero(&osd->o_ref)) {
+               dout("get_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref)-1,
+                    atomic_read(&osd->o_ref));
+               return osd;
+       } else {
+               dout("get_osd %p FAIL\n", osd);
+               return NULL;
+       }
+}
+
+static void put_osd(struct ceph_osd *osd)
+{
+       dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
+            atomic_read(&osd->o_ref) - 1);
+       if (atomic_dec_and_test(&osd->o_ref))
+               kfree(osd);
+}
+
+/*
+ * remove an osd from our map
+ */
+static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
+{
+       dout("__remove_osd %p\n", osd);
+       BUG_ON(!list_empty(&osd->o_requests));
+       rb_erase(&osd->o_node, &osdc->osds);
+       list_del_init(&osd->o_osd_lru);
+       ceph_con_close(&osd->o_con);
+       put_osd(osd);
+}
+
+static void __move_osd_to_lru(struct ceph_osd_client *osdc,
+                             struct ceph_osd *osd)
+{
+       dout("__move_osd_to_lru %p\n", osd);
+       BUG_ON(!list_empty(&osd->o_osd_lru));
+       list_add_tail(&osd->o_osd_lru, &osdc->osd_lru);
+       osd->lru_ttl = jiffies + osdc->client->mount_args->osd_idle_ttl * HZ;
+}
+
+static void __remove_osd_from_lru(struct ceph_osd *osd)
+{
+       dout("__remove_osd_from_lru %p\n", osd);
+       if (!list_empty(&osd->o_osd_lru))
+               list_del_init(&osd->o_osd_lru);
+}
+
+static void remove_old_osds(struct ceph_osd_client *osdc, int remove_all)
+{
+       struct ceph_osd *osd, *nosd;
+
+       dout("__remove_old_osds %p\n", osdc);
+       mutex_lock(&osdc->request_mutex);
+       list_for_each_entry_safe(osd, nosd, &osdc->osd_lru, o_osd_lru) {
+               if (!remove_all && time_before(jiffies, osd->lru_ttl))
+                       break;
+               __remove_osd(osdc, osd);
+       }
+       mutex_unlock(&osdc->request_mutex);
+}
+
+/*
+ * reset osd connect
+ */
+static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
+{
+       struct ceph_osd_request *req;
+       int ret = 0;
+
+       dout("__reset_osd %p osd%d\n", osd, osd->o_osd);
+       if (list_empty(&osd->o_requests)) {
+               __remove_osd(osdc, osd);
+       } else if (memcmp(&osdc->osdmap->osd_addr[osd->o_osd],
+                         &osd->o_con.peer_addr,
+                         sizeof(osd->o_con.peer_addr)) == 0 &&
+                  !ceph_con_opened(&osd->o_con)) {
+               dout(" osd addr hasn't changed and connection never opened,"
+                    " letting msgr retry");
+               /* touch each r_stamp for handle_timeout()'s benfit */
+               list_for_each_entry(req, &osd->o_requests, r_osd_item)
+                       req->r_stamp = jiffies;
+               ret = -EAGAIN;
+       } else {
+               ceph_con_close(&osd->o_con);
+               ceph_con_open(&osd->o_con, &osdc->osdmap->osd_addr[osd->o_osd]);
+               osd->o_incarnation++;
+       }
+       return ret;
+}
+
+static void __insert_osd(struct ceph_osd_client *osdc, struct ceph_osd *new)
+{
+       struct rb_node **p = &osdc->osds.rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_osd *osd = NULL;
+
+       while (*p) {
+               parent = *p;
+               osd = rb_entry(parent, struct ceph_osd, o_node);
+               if (new->o_osd < osd->o_osd)
+                       p = &(*p)->rb_left;
+               else if (new->o_osd > osd->o_osd)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->o_node, parent, p);
+       rb_insert_color(&new->o_node, &osdc->osds);
+}
+
+static struct ceph_osd *__lookup_osd(struct ceph_osd_client *osdc, int o)
+{
+       struct ceph_osd *osd;
+       struct rb_node *n = osdc->osds.rb_node;
+
+       while (n) {
+               osd = rb_entry(n, struct ceph_osd, o_node);
+               if (o < osd->o_osd)
+                       n = n->rb_left;
+               else if (o > osd->o_osd)
+                       n = n->rb_right;
+               else
+                       return osd;
+       }
+       return NULL;
+}
+
+static void __schedule_osd_timeout(struct ceph_osd_client *osdc)
+{
+       schedule_delayed_work(&osdc->timeout_work,
+                       osdc->client->mount_args->osd_keepalive_timeout * HZ);
+}
+
+static void __cancel_osd_timeout(struct ceph_osd_client *osdc)
+{
+       cancel_delayed_work(&osdc->timeout_work);
+}
+
+/*
+ * Register request, assign tid.  If this is the first request, set up
+ * the timeout event.
+ */
+static void register_request(struct ceph_osd_client *osdc,
+                            struct ceph_osd_request *req)
+{
+       mutex_lock(&osdc->request_mutex);
+       req->r_tid = ++osdc->last_tid;
+       req->r_request->hdr.tid = cpu_to_le64(req->r_tid);
+       INIT_LIST_HEAD(&req->r_req_lru_item);
+
+       dout("register_request %p tid %lld\n", req, req->r_tid);
+       __insert_request(osdc, req);
+       ceph_osdc_get_request(req);
+       osdc->num_requests++;
+
+       if (osdc->num_requests == 1) {
+               dout(" first request, scheduling timeout\n");
+               __schedule_osd_timeout(osdc);
+       }
+       mutex_unlock(&osdc->request_mutex);
+}
+
+/*
+ * called under osdc->request_mutex
+ */
+static void __unregister_request(struct ceph_osd_client *osdc,
+                                struct ceph_osd_request *req)
+{
+       dout("__unregister_request %p tid %lld\n", req, req->r_tid);
+       rb_erase(&req->r_node, &osdc->requests);
+       osdc->num_requests--;
+
+       if (req->r_osd) {
+               /* make sure the original request isn't in flight. */
+               ceph_con_revoke(&req->r_osd->o_con, req->r_request);
+
+               list_del_init(&req->r_osd_item);
+               if (list_empty(&req->r_osd->o_requests))
+                       __move_osd_to_lru(osdc, req->r_osd);
+               req->r_osd = NULL;
+       }
+
+       ceph_osdc_put_request(req);
+
+       list_del_init(&req->r_req_lru_item);
+       if (osdc->num_requests == 0) {
+               dout(" no requests, canceling timeout\n");
+               __cancel_osd_timeout(osdc);
+       }
+}
+
+/*
+ * Cancel a previously queued request message
+ */
+static void __cancel_request(struct ceph_osd_request *req)
+{
+       if (req->r_sent) {
+               ceph_con_revoke(&req->r_osd->o_con, req->r_request);
+               req->r_sent = 0;
+       }
+       list_del_init(&req->r_req_lru_item);
+}
+
+/*
+ * Pick an osd (the first 'up' osd in the pg), allocate the osd struct
+ * (as needed), and set the request r_osd appropriately.  If there is
+ * no up osd, set r_osd to NULL.
+ *
+ * Return 0 if unchanged, 1 if changed, or negative on error.
+ *
+ * Caller should hold map_sem for read and request_mutex.
+ */
+static int __map_osds(struct ceph_osd_client *osdc,
+                     struct ceph_osd_request *req)
+{
+       struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base;
+       struct ceph_pg pgid;
+       int o = -1;
+       int err;
+
+       dout("map_osds %p tid %lld\n", req, req->r_tid);
+       err = ceph_calc_object_layout(&reqhead->layout, req->r_oid,
+                                     &req->r_file_layout, osdc->osdmap);
+       if (err)
+               return err;
+       pgid = reqhead->layout.ol_pgid;
+       req->r_pgid = pgid;
+
+       o = ceph_calc_pg_primary(osdc->osdmap, pgid);
+
+       if ((req->r_osd && req->r_osd->o_osd == o &&
+            req->r_sent >= req->r_osd->o_incarnation) ||
+           (req->r_osd == NULL && o == -1))
+               return 0;  /* no change */
+
+       dout("map_osds tid %llu pgid %d.%x osd%d (was osd%d)\n",
+            req->r_tid, le32_to_cpu(pgid.pool), le16_to_cpu(pgid.ps), o,
+            req->r_osd ? req->r_osd->o_osd : -1);
+
+       if (req->r_osd) {
+               __cancel_request(req);
+               list_del_init(&req->r_osd_item);
+               req->r_osd = NULL;
+       }
+
+       req->r_osd = __lookup_osd(osdc, o);
+       if (!req->r_osd && o >= 0) {
+               err = -ENOMEM;
+               req->r_osd = create_osd(osdc);
+               if (!req->r_osd)
+                       goto out;
+
+               dout("map_osds osd %p is osd%d\n", req->r_osd, o);
+               req->r_osd->o_osd = o;
+               req->r_osd->o_con.peer_name.num = cpu_to_le64(o);
+               __insert_osd(osdc, req->r_osd);
+
+               ceph_con_open(&req->r_osd->o_con, &osdc->osdmap->osd_addr[o]);
+       }
+
+       if (req->r_osd) {
+               __remove_osd_from_lru(req->r_osd);
+               list_add(&req->r_osd_item, &req->r_osd->o_requests);
+       }
+       err = 1;   /* osd changed */
+
+out:
+       return err;
+}
+
+/*
+ * caller should hold map_sem (for read) and request_mutex
+ */
+static int __send_request(struct ceph_osd_client *osdc,
+                         struct ceph_osd_request *req)
+{
+       struct ceph_osd_request_head *reqhead;
+       int err;
+
+       err = __map_osds(osdc, req);
+       if (err < 0)
+               return err;
+       if (req->r_osd == NULL) {
+               dout("send_request %p no up osds in pg\n", req);
+               ceph_monc_request_next_osdmap(&osdc->client->monc);
+               return 0;
+       }
+
+       dout("send_request %p tid %llu to osd%d flags %d\n",
+            req, req->r_tid, req->r_osd->o_osd, req->r_flags);
+
+       reqhead = req->r_request->front.iov_base;
+       reqhead->osdmap_epoch = cpu_to_le32(osdc->osdmap->epoch);
+       reqhead->flags |= cpu_to_le32(req->r_flags);  /* e.g., RETRY */
+       reqhead->reassert_version = req->r_reassert_version;
+
+       req->r_stamp = jiffies;
+       list_move_tail(&osdc->req_lru, &req->r_req_lru_item);
+
+       ceph_msg_get(req->r_request); /* send consumes a ref */
+       ceph_con_send(&req->r_osd->o_con, req->r_request);
+       req->r_sent = req->r_osd->o_incarnation;
+       return 0;
+}
+
+/*
+ * Timeout callback, called every N seconds when 1 or more osd
+ * requests has been active for more than N seconds.  When this
+ * happens, we ping all OSDs with requests who have timed out to
+ * ensure any communications channel reset is detected.  Reset the
+ * request timeouts another N seconds in the future as we go.
+ * Reschedule the timeout event another N seconds in future (unless
+ * there are no open requests).
+ */
+static void handle_timeout(struct work_struct *work)
+{
+       struct ceph_osd_client *osdc =
+               container_of(work, struct ceph_osd_client, timeout_work.work);
+       struct ceph_osd_request *req, *last_req = NULL;
+       struct ceph_osd *osd;
+       unsigned long timeout = osdc->client->mount_args->osd_timeout * HZ;
+       unsigned long keepalive =
+               osdc->client->mount_args->osd_keepalive_timeout * HZ;
+       unsigned long last_stamp = 0;
+       struct rb_node *p;
+       struct list_head slow_osds;
+
+       dout("timeout\n");
+       down_read(&osdc->map_sem);
+
+       ceph_monc_request_next_osdmap(&osdc->client->monc);
+
+       mutex_lock(&osdc->request_mutex);
+       for (p = rb_first(&osdc->requests); p; p = rb_next(p)) {
+               req = rb_entry(p, struct ceph_osd_request, r_node);
+
+               if (req->r_resend) {
+                       int err;
+
+                       dout("osdc resending prev failed %lld\n", req->r_tid);
+                       err = __send_request(osdc, req);
+                       if (err)
+                               dout("osdc failed again on %lld\n", req->r_tid);
+                       else
+                               req->r_resend = false;
+                       continue;
+               }
+       }
+
+       /*
+        * reset osds that appear to be _really_ unresponsive.  this
+        * is a failsafe measure.. we really shouldn't be getting to
+        * this point if the system is working properly.  the monitors
+        * should mark the osd as failed and we should find out about
+        * it from an updated osd map.
+        */
+       while (!list_empty(&osdc->req_lru)) {
+               req = list_entry(osdc->req_lru.next, struct ceph_osd_request,
+                                r_req_lru_item);
+
+               if (time_before(jiffies, req->r_stamp + timeout))
+                       break;
+
+               BUG_ON(req == last_req && req->r_stamp == last_stamp);
+               last_req = req;
+               last_stamp = req->r_stamp;
+
+               osd = req->r_osd;
+               BUG_ON(!osd);
+               pr_warning(" tid %llu timed out on osd%d, will reset osd\n",
+                          req->r_tid, osd->o_osd);
+               __kick_requests(osdc, osd);
+       }
+
+       /*
+        * ping osds that are a bit slow.  this ensures that if there
+        * is a break in the TCP connection we will notice, and reopen
+        * a connection with that osd (from the fault callback).
+        */
+       INIT_LIST_HEAD(&slow_osds);
+       list_for_each_entry(req, &osdc->req_lru, r_req_lru_item) {
+               if (time_before(jiffies, req->r_stamp + keepalive))
+                       break;
+
+               osd = req->r_osd;
+               BUG_ON(!osd);
+               dout(" tid %llu is slow, will send keepalive on osd%d\n",
+                    req->r_tid, osd->o_osd);
+               list_move_tail(&osd->o_keepalive_item, &slow_osds);
+       }
+       while (!list_empty(&slow_osds)) {
+               osd = list_entry(slow_osds.next, struct ceph_osd,
+                                o_keepalive_item);
+               list_del_init(&osd->o_keepalive_item);
+               ceph_con_keepalive(&osd->o_con);
+       }
+
+       __schedule_osd_timeout(osdc);
+       mutex_unlock(&osdc->request_mutex);
+
+       up_read(&osdc->map_sem);
+}
+
+static void handle_osds_timeout(struct work_struct *work)
+{
+       struct ceph_osd_client *osdc =
+               container_of(work, struct ceph_osd_client,
+                            osds_timeout_work.work);
+       unsigned long delay =
+               osdc->client->mount_args->osd_idle_ttl * HZ >> 2;
+
+       dout("osds timeout\n");
+       down_read(&osdc->map_sem);
+       remove_old_osds(osdc, 0);
+       up_read(&osdc->map_sem);
+
+       schedule_delayed_work(&osdc->osds_timeout_work,
+                             round_jiffies_relative(delay));
+}
+
+/*
+ * handle osd op reply.  either call the callback if it is specified,
+ * or do the completion to wake up the waiting thread.
+ */
+static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
+                        struct ceph_connection *con)
+{
+       struct ceph_osd_reply_head *rhead = msg->front.iov_base;
+       struct ceph_osd_request *req;
+       u64 tid;
+       int numops, object_len, flags;
+
+       tid = le64_to_cpu(msg->hdr.tid);
+       if (msg->front.iov_len < sizeof(*rhead))
+               goto bad;
+       numops = le32_to_cpu(rhead->num_ops);
+       object_len = le32_to_cpu(rhead->object_len);
+       if (msg->front.iov_len != sizeof(*rhead) + object_len +
+           numops * sizeof(struct ceph_osd_op))
+               goto bad;
+       dout("handle_reply %p tid %llu\n", msg, tid);
+
+       /* lookup */
+       mutex_lock(&osdc->request_mutex);
+       req = __lookup_request(osdc, tid);
+       if (req == NULL) {
+               dout("handle_reply tid %llu dne\n", tid);
+               mutex_unlock(&osdc->request_mutex);
+               return;
+       }
+       ceph_osdc_get_request(req);
+       flags = le32_to_cpu(rhead->flags);
+
+       /*
+        * if this connection filled our message, drop our reference now, to
+        * avoid a (safe but slower) revoke later.
+        */
+       if (req->r_con_filling_msg == con && req->r_reply == msg) {
+               dout(" dropping con_filling_msg ref %p\n", con);
+               req->r_con_filling_msg = NULL;
+               ceph_con_put(con);
+       }
+
+       if (!req->r_got_reply) {
+               unsigned bytes;
+
+               req->r_result = le32_to_cpu(rhead->result);
+               bytes = le32_to_cpu(msg->hdr.data_len);
+               dout("handle_reply result %d bytes %d\n", req->r_result,
+                    bytes);
+               if (req->r_result == 0)
+                       req->r_result = bytes;
+
+               /* in case this is a write and we need to replay, */
+               req->r_reassert_version = rhead->reassert_version;
+
+               req->r_got_reply = 1;
+       } else if ((flags & CEPH_OSD_FLAG_ONDISK) == 0) {
+               dout("handle_reply tid %llu dup ack\n", tid);
+               mutex_unlock(&osdc->request_mutex);
+               goto done;
+       }
+
+       dout("handle_reply tid %llu flags %d\n", tid, flags);
+
+       /* either this is a read, or we got the safe response */
+       if ((flags & CEPH_OSD_FLAG_ONDISK) ||
+           ((flags & CEPH_OSD_FLAG_WRITE) == 0))
+               __unregister_request(osdc, req);
+
+       mutex_unlock(&osdc->request_mutex);
+
+       if (req->r_callback)
+               req->r_callback(req, msg);
+       else
+               complete(&req->r_completion);
+
+       if (flags & CEPH_OSD_FLAG_ONDISK) {
+               if (req->r_safe_callback)
+                       req->r_safe_callback(req, msg);
+               complete(&req->r_safe_completion);  /* fsync waiter */
+       }
+
+done:
+       ceph_osdc_put_request(req);
+       return;
+
+bad:
+       pr_err("corrupt osd_op_reply got %d %d expected %d\n",
+              (int)msg->front.iov_len, le32_to_cpu(msg->hdr.front_len),
+              (int)sizeof(*rhead));
+       ceph_msg_dump(msg);
+}
+
+
+static int __kick_requests(struct ceph_osd_client *osdc,
+                         struct ceph_osd *kickosd)
+{
+       struct ceph_osd_request *req;
+       struct rb_node *p, *n;
+       int needmap = 0;
+       int err;
+
+       dout("kick_requests osd%d\n", kickosd ? kickosd->o_osd : -1);
+       if (kickosd) {
+               err = __reset_osd(osdc, kickosd);
+               if (err == -EAGAIN)
+                       return 1;
+       } else {
+               for (p = rb_first(&osdc->osds); p; p = n) {
+                       struct ceph_osd *osd =
+                               rb_entry(p, struct ceph_osd, o_node);
+
+                       n = rb_next(p);
+                       if (!ceph_osd_is_up(osdc->osdmap, osd->o_osd) ||
+                           memcmp(&osd->o_con.peer_addr,
+                                  ceph_osd_addr(osdc->osdmap,
+                                                osd->o_osd),
+                                  sizeof(struct ceph_entity_addr)) != 0)
+                               __reset_osd(osdc, osd);
+               }
+       }
+
+       for (p = rb_first(&osdc->requests); p; p = rb_next(p)) {
+               req = rb_entry(p, struct ceph_osd_request, r_node);
+
+               if (req->r_resend) {
+                       dout(" r_resend set on tid %llu\n", req->r_tid);
+                       __cancel_request(req);
+                       goto kick;
+               }
+               if (req->r_osd && kickosd == req->r_osd) {
+                       __cancel_request(req);
+                       goto kick;
+               }
+
+               err = __map_osds(osdc, req);
+               if (err == 0)
+                       continue;  /* no change */
+               if (err < 0) {
+                       /*
+                        * FIXME: really, we should set the request
+                        * error and fail if this isn't a 'nofail'
+                        * request, but that's a fair bit more
+                        * complicated to do.  So retry!
+                        */
+                       dout(" setting r_resend on %llu\n", req->r_tid);
+                       req->r_resend = true;
+                       continue;
+               }
+               if (req->r_osd == NULL) {
+                       dout("tid %llu maps to no valid osd\n", req->r_tid);
+                       needmap++;  /* request a newer map */
+                       continue;
+               }
+
+kick:
+               dout("kicking %p tid %llu osd%d\n", req, req->r_tid,
+                    req->r_osd ? req->r_osd->o_osd : -1);
+               req->r_flags |= CEPH_OSD_FLAG_RETRY;
+               err = __send_request(osdc, req);
+               if (err) {
+                       dout(" setting r_resend on %llu\n", req->r_tid);
+                       req->r_resend = true;
+               }
+       }
+
+       return needmap;
+}
+
+/*
+ * Resubmit osd requests whose osd or osd address has changed.  Request
+ * a new osd map if osds are down, or we are otherwise unable to determine
+ * how to direct a request.
+ *
+ * Close connections to down osds.
+ *
+ * If @who is specified, resubmit requests for that specific osd.
+ *
+ * Caller should hold map_sem for read and request_mutex.
+ */
+static void kick_requests(struct ceph_osd_client *osdc,
+                         struct ceph_osd *kickosd)
+{
+       int needmap;
+
+       mutex_lock(&osdc->request_mutex);
+       needmap = __kick_requests(osdc, kickosd);
+       mutex_unlock(&osdc->request_mutex);
+
+       if (needmap) {
+               dout("%d requests for down osds, need new map\n", needmap);
+               ceph_monc_request_next_osdmap(&osdc->client->monc);
+       }
+
+}
+/*
+ * Process updated osd map.
+ *
+ * The message contains any number of incremental and full maps, normally
+ * indicating some sort of topology change in the cluster.  Kick requests
+ * off to different OSDs as needed.
+ */
+void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
+{
+       void *p, *end, *next;
+       u32 nr_maps, maplen;
+       u32 epoch;
+       struct ceph_osdmap *newmap = NULL, *oldmap;
+       int err;
+       struct ceph_fsid fsid;
+
+       dout("handle_map have %u\n", osdc->osdmap ? osdc->osdmap->epoch : 0);
+       p = msg->front.iov_base;
+       end = p + msg->front.iov_len;
+
+       /* verify fsid */
+       ceph_decode_need(&p, end, sizeof(fsid), bad);
+       ceph_decode_copy(&p, &fsid, sizeof(fsid));
+       if (ceph_check_fsid(osdc->client, &fsid) < 0)
+               return;
+
+       down_write(&osdc->map_sem);
+
+       /* incremental maps */
+       ceph_decode_32_safe(&p, end, nr_maps, bad);
+       dout(" %d inc maps\n", nr_maps);
+       while (nr_maps > 0) {
+               ceph_decode_need(&p, end, 2*sizeof(u32), bad);
+               epoch = ceph_decode_32(&p);
+               maplen = ceph_decode_32(&p);
+               ceph_decode_need(&p, end, maplen, bad);
+               next = p + maplen;
+               if (osdc->osdmap && osdc->osdmap->epoch+1 == epoch) {
+                       dout("applying incremental map %u len %d\n",
+                            epoch, maplen);
+                       newmap = osdmap_apply_incremental(&p, next,
+                                                         osdc->osdmap,
+                                                         osdc->client->msgr);
+                       if (IS_ERR(newmap)) {
+                               err = PTR_ERR(newmap);
+                               goto bad;
+                       }
+                       BUG_ON(!newmap);
+                       if (newmap != osdc->osdmap) {
+                               ceph_osdmap_destroy(osdc->osdmap);
+                               osdc->osdmap = newmap;
+                       }
+               } else {
+                       dout("ignoring incremental map %u len %d\n",
+                            epoch, maplen);
+               }
+               p = next;
+               nr_maps--;
+       }
+       if (newmap)
+               goto done;
+
+       /* full maps */
+       ceph_decode_32_safe(&p, end, nr_maps, bad);
+       dout(" %d full maps\n", nr_maps);
+       while (nr_maps) {
+               ceph_decode_need(&p, end, 2*sizeof(u32), bad);
+               epoch = ceph_decode_32(&p);
+               maplen = ceph_decode_32(&p);
+               ceph_decode_need(&p, end, maplen, bad);
+               if (nr_maps > 1) {
+                       dout("skipping non-latest full map %u len %d\n",
+                            epoch, maplen);
+               } else if (osdc->osdmap && osdc->osdmap->epoch >= epoch) {
+                       dout("skipping full map %u len %d, "
+                            "older than our %u\n", epoch, maplen,
+                            osdc->osdmap->epoch);
+               } else {
+                       dout("taking full map %u len %d\n", epoch, maplen);
+                       newmap = osdmap_decode(&p, p+maplen);
+                       if (IS_ERR(newmap)) {
+                               err = PTR_ERR(newmap);
+                               goto bad;
+                       }
+                       BUG_ON(!newmap);
+                       oldmap = osdc->osdmap;
+                       osdc->osdmap = newmap;
+                       if (oldmap)
+                               ceph_osdmap_destroy(oldmap);
+               }
+               p += maplen;
+               nr_maps--;
+       }
+
+done:
+       downgrade_write(&osdc->map_sem);
+       ceph_monc_got_osdmap(&osdc->client->monc, osdc->osdmap->epoch);
+       if (newmap)
+               kick_requests(osdc, NULL);
+       up_read(&osdc->map_sem);
+       return;
+
+bad:
+       pr_err("osdc handle_map corrupt msg\n");
+       ceph_msg_dump(msg);
+       up_write(&osdc->map_sem);
+       return;
+}
+
+
+/*
+ * A read request prepares specific pages that data is to be read into.
+ * When a message is being read off the wire, we call prepare_pages to
+ * find those pages.
+ *  0 = success, -1 failure.
+ */
+static int __prepare_pages(struct ceph_connection *con,
+                        struct ceph_msg_header *hdr,
+                        struct ceph_osd_request *req,
+                        u64 tid,
+                        struct ceph_msg *m)
+{
+       struct ceph_osd *osd = con->private;
+       struct ceph_osd_client *osdc;
+       int ret = -1;
+       int data_len = le32_to_cpu(hdr->data_len);
+       unsigned data_off = le16_to_cpu(hdr->data_off);
+
+       int want = calc_pages_for(data_off & ~PAGE_MASK, data_len);
+
+       if (!osd)
+               return -1;
+
+       osdc = osd->o_osdc;
+
+       dout("__prepare_pages on msg %p tid %llu, has %d pages, want %d\n", m,
+            tid, req->r_num_pages, want);
+       if (unlikely(req->r_num_pages < want))
+               goto out;
+       m->pages = req->r_pages;
+       m->nr_pages = req->r_num_pages;
+       ret = 0; /* success */
+out:
+       BUG_ON(ret < 0 || m->nr_pages < want);
+
+       return ret;
+}
+
+/*
+ * Register request, send initial attempt.
+ */
+int ceph_osdc_start_request(struct ceph_osd_client *osdc,
+                           struct ceph_osd_request *req,
+                           bool nofail)
+{
+       int rc = 0;
+
+       req->r_request->pages = req->r_pages;
+       req->r_request->nr_pages = req->r_num_pages;
+
+       register_request(osdc, req);
+
+       down_read(&osdc->map_sem);
+       mutex_lock(&osdc->request_mutex);
+       /*
+        * a racing kick_requests() may have sent the message for us
+        * while we dropped request_mutex above, so only send now if
+        * the request still han't been touched yet.
+        */
+       if (req->r_sent == 0) {
+               rc = __send_request(osdc, req);
+               if (rc) {
+                       if (nofail) {
+                               dout("osdc_start_request failed send, "
+                                    " marking %lld\n", req->r_tid);
+                               req->r_resend = true;
+                               rc = 0;
+                       } else {
+                               __unregister_request(osdc, req);
+                       }
+               }
+       }
+       mutex_unlock(&osdc->request_mutex);
+       up_read(&osdc->map_sem);
+       return rc;
+}
+
+/*
+ * wait for a request to complete
+ */
+int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
+                          struct ceph_osd_request *req)
+{
+       int rc;
+
+       rc = wait_for_completion_interruptible(&req->r_completion);
+       if (rc < 0) {
+               mutex_lock(&osdc->request_mutex);
+               __cancel_request(req);
+               __unregister_request(osdc, req);
+               mutex_unlock(&osdc->request_mutex);
+               dout("wait_request tid %llu canceled/timed out\n", req->r_tid);
+               return rc;
+       }
+
+       dout("wait_request tid %llu result %d\n", req->r_tid, req->r_result);
+       return req->r_result;
+}
+
+/*
+ * sync - wait for all in-flight requests to flush.  avoid starvation.
+ */
+void ceph_osdc_sync(struct ceph_osd_client *osdc)
+{
+       struct ceph_osd_request *req;
+       u64 last_tid, next_tid = 0;
+
+       mutex_lock(&osdc->request_mutex);
+       last_tid = osdc->last_tid;
+       while (1) {
+               req = __lookup_request_ge(osdc, next_tid);
+               if (!req)
+                       break;
+               if (req->r_tid > last_tid)
+                       break;
+
+               next_tid = req->r_tid + 1;
+               if ((req->r_flags & CEPH_OSD_FLAG_WRITE) == 0)
+                       continue;
+
+               ceph_osdc_get_request(req);
+               mutex_unlock(&osdc->request_mutex);
+               dout("sync waiting on tid %llu (last is %llu)\n",
+                    req->r_tid, last_tid);
+               wait_for_completion(&req->r_safe_completion);
+               mutex_lock(&osdc->request_mutex);
+               ceph_osdc_put_request(req);
+       }
+       mutex_unlock(&osdc->request_mutex);
+       dout("sync done (thru tid %llu)\n", last_tid);
+}
+
+/*
+ * init, shutdown
+ */
+int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
+{
+       int err;
+
+       dout("init\n");
+       osdc->client = client;
+       osdc->osdmap = NULL;
+       init_rwsem(&osdc->map_sem);
+       init_completion(&osdc->map_waiters);
+       osdc->last_requested_map = 0;
+       mutex_init(&osdc->request_mutex);
+       osdc->last_tid = 0;
+       osdc->osds = RB_ROOT;
+       INIT_LIST_HEAD(&osdc->osd_lru);
+       osdc->requests = RB_ROOT;
+       INIT_LIST_HEAD(&osdc->req_lru);
+       osdc->num_requests = 0;
+       INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout);
+       INIT_DELAYED_WORK(&osdc->osds_timeout_work, handle_osds_timeout);
+
+       schedule_delayed_work(&osdc->osds_timeout_work,
+          round_jiffies_relative(osdc->client->mount_args->osd_idle_ttl * HZ));
+
+       err = -ENOMEM;
+       osdc->req_mempool = mempool_create_kmalloc_pool(10,
+                                       sizeof(struct ceph_osd_request));
+       if (!osdc->req_mempool)
+               goto out;
+
+       err = ceph_msgpool_init(&osdc->msgpool_op, OSD_OP_FRONT_LEN, 10, true);
+       if (err < 0)
+               goto out_mempool;
+       err = ceph_msgpool_init(&osdc->msgpool_op_reply,
+                               OSD_OPREPLY_FRONT_LEN, 10, true);
+       if (err < 0)
+               goto out_msgpool;
+       return 0;
+
+out_msgpool:
+       ceph_msgpool_destroy(&osdc->msgpool_op);
+out_mempool:
+       mempool_destroy(osdc->req_mempool);
+out:
+       return err;
+}
+
+void ceph_osdc_stop(struct ceph_osd_client *osdc)
+{
+       cancel_delayed_work_sync(&osdc->timeout_work);
+       cancel_delayed_work_sync(&osdc->osds_timeout_work);
+       if (osdc->osdmap) {
+               ceph_osdmap_destroy(osdc->osdmap);
+               osdc->osdmap = NULL;
+       }
+       remove_old_osds(osdc, 1);
+       mempool_destroy(osdc->req_mempool);
+       ceph_msgpool_destroy(&osdc->msgpool_op);
+       ceph_msgpool_destroy(&osdc->msgpool_op_reply);
+}
+
+/*
+ * Read some contiguous pages.  If we cross a stripe boundary, shorten
+ * *plen.  Return number of bytes read, or error.
+ */
+int ceph_osdc_readpages(struct ceph_osd_client *osdc,
+                       struct ceph_vino vino, struct ceph_file_layout *layout,
+                       u64 off, u64 *plen,
+                       u32 truncate_seq, u64 truncate_size,
+                       struct page **pages, int num_pages)
+{
+       struct ceph_osd_request *req;
+       int rc = 0;
+
+       dout("readpages on ino %llx.%llx on %llu~%llu\n", vino.ino,
+            vino.snap, off, *plen);
+       req = ceph_osdc_new_request(osdc, layout, vino, off, plen,
+                                   CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
+                                   NULL, 0, truncate_seq, truncate_size, NULL,
+                                   false, 1);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+
+       /* it may be a short read due to an object boundary */
+       req->r_pages = pages;
+       num_pages = calc_pages_for(off, *plen);
+       req->r_num_pages = num_pages;
+
+       dout("readpages  final extent is %llu~%llu (%d pages)\n",
+            off, *plen, req->r_num_pages);
+
+       rc = ceph_osdc_start_request(osdc, req, false);
+       if (!rc)
+               rc = ceph_osdc_wait_request(osdc, req);
+
+       ceph_osdc_put_request(req);
+       dout("readpages result %d\n", rc);
+       return rc;
+}
+
+/*
+ * do a synchronous write on N pages
+ */
+int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
+                        struct ceph_file_layout *layout,
+                        struct ceph_snap_context *snapc,
+                        u64 off, u64 len,
+                        u32 truncate_seq, u64 truncate_size,
+                        struct timespec *mtime,
+                        struct page **pages, int num_pages,
+                        int flags, int do_sync, bool nofail)
+{
+       struct ceph_osd_request *req;
+       int rc = 0;
+
+       BUG_ON(vino.snap != CEPH_NOSNAP);
+       req = ceph_osdc_new_request(osdc, layout, vino, off, &len,
+                                   CEPH_OSD_OP_WRITE,
+                                   flags | CEPH_OSD_FLAG_ONDISK |
+                                           CEPH_OSD_FLAG_WRITE,
+                                   snapc, do_sync,
+                                   truncate_seq, truncate_size, mtime,
+                                   nofail, 1);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+
+       /* it may be a short write due to an object boundary */
+       req->r_pages = pages;
+       req->r_num_pages = calc_pages_for(off, len);
+       dout("writepages %llu~%llu (%d pages)\n", off, len,
+            req->r_num_pages);
+
+       rc = ceph_osdc_start_request(osdc, req, nofail);
+       if (!rc)
+               rc = ceph_osdc_wait_request(osdc, req);
+
+       ceph_osdc_put_request(req);
+       if (rc == 0)
+               rc = len;
+       dout("writepages result %d\n", rc);
+       return rc;
+}
+
+/*
+ * handle incoming message
+ */
+static void dispatch(struct ceph_connection *con, struct ceph_msg *msg)
+{
+       struct ceph_osd *osd = con->private;
+       struct ceph_osd_client *osdc;
+       int type = le16_to_cpu(msg->hdr.type);
+
+       if (!osd)
+               return;
+       osdc = osd->o_osdc;
+
+       switch (type) {
+       case CEPH_MSG_OSD_MAP:
+               ceph_osdc_handle_map(osdc, msg);
+               break;
+       case CEPH_MSG_OSD_OPREPLY:
+               handle_reply(osdc, msg, con);
+               break;
+
+       default:
+               pr_err("received unknown message type %d %s\n", type,
+                      ceph_msg_type_name(type));
+       }
+       ceph_msg_put(msg);
+}
+
+/*
+ * lookup and return message for incoming reply
+ */
+static struct ceph_msg *get_reply(struct ceph_connection *con,
+                                 struct ceph_msg_header *hdr,
+                                 int *skip)
+{
+       struct ceph_osd *osd = con->private;
+       struct ceph_osd_client *osdc = osd->o_osdc;
+       struct ceph_msg *m;
+       struct ceph_osd_request *req;
+       int front = le32_to_cpu(hdr->front_len);
+       int data_len = le32_to_cpu(hdr->data_len);
+       u64 tid;
+       int err;
+
+       tid = le64_to_cpu(hdr->tid);
+       mutex_lock(&osdc->request_mutex);
+       req = __lookup_request(osdc, tid);
+       if (!req) {
+               *skip = 1;
+               m = NULL;
+               pr_info("get_reply unknown tid %llu from osd%d\n", tid,
+                       osd->o_osd);
+               goto out;
+       }
+
+       if (req->r_con_filling_msg) {
+               dout("get_reply revoking msg %p from old con %p\n",
+                    req->r_reply, req->r_con_filling_msg);
+               ceph_con_revoke_message(req->r_con_filling_msg, req->r_reply);
+               ceph_con_put(req->r_con_filling_msg);
+       }
+
+       if (front > req->r_reply->front.iov_len) {
+               pr_warning("get_reply front %d > preallocated %d\n",
+                          front, (int)req->r_reply->front.iov_len);
+               m = ceph_msg_new(CEPH_MSG_OSD_OPREPLY, front, 0, 0, NULL);
+               if (IS_ERR(m))
+                       goto out;
+               ceph_msg_put(req->r_reply);
+               req->r_reply = m;
+       }
+       m = ceph_msg_get(req->r_reply);
+
+       if (data_len > 0) {
+               err = __prepare_pages(con, hdr, req, tid, m);
+               if (err < 0) {
+                       *skip = 1;
+                       ceph_msg_put(m);
+                       m = ERR_PTR(err);
+               }
+       }
+       *skip = 0;
+       req->r_con_filling_msg = ceph_con_get(con);
+       dout("get_reply tid %lld %p\n", tid, m);
+
+out:
+       mutex_unlock(&osdc->request_mutex);
+       return m;
+
+}
+
+static struct ceph_msg *alloc_msg(struct ceph_connection *con,
+                                 struct ceph_msg_header *hdr,
+                                 int *skip)
+{
+       struct ceph_osd *osd = con->private;
+       int type = le16_to_cpu(hdr->type);
+       int front = le32_to_cpu(hdr->front_len);
+
+       switch (type) {
+       case CEPH_MSG_OSD_MAP:
+               return ceph_msg_new(type, front, 0, 0, NULL);
+       case CEPH_MSG_OSD_OPREPLY:
+               return get_reply(con, hdr, skip);
+       default:
+               pr_info("alloc_msg unexpected msg type %d from osd%d\n", type,
+                       osd->o_osd);
+               *skip = 1;
+               return NULL;
+       }
+}
+
+/*
+ * Wrappers to refcount containing ceph_osd struct
+ */
+static struct ceph_connection *get_osd_con(struct ceph_connection *con)
+{
+       struct ceph_osd *osd = con->private;
+       if (get_osd(osd))
+               return con;
+       return NULL;
+}
+
+static void put_osd_con(struct ceph_connection *con)
+{
+       struct ceph_osd *osd = con->private;
+       put_osd(osd);
+}
+
+/*
+ * authentication
+ */
+static int get_authorizer(struct ceph_connection *con,
+                         void **buf, int *len, int *proto,
+                         void **reply_buf, int *reply_len, int force_new)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_osd_client *osdc = o->o_osdc;
+       struct ceph_auth_client *ac = osdc->client->monc.auth;
+       int ret = 0;
+
+       if (force_new && o->o_authorizer) {
+               ac->ops->destroy_authorizer(ac, o->o_authorizer);
+               o->o_authorizer = NULL;
+       }
+       if (o->o_authorizer == NULL) {
+               ret = ac->ops->create_authorizer(
+                       ac, CEPH_ENTITY_TYPE_OSD,
+                       &o->o_authorizer,
+                       &o->o_authorizer_buf,
+                       &o->o_authorizer_buf_len,
+                       &o->o_authorizer_reply_buf,
+                       &o->o_authorizer_reply_buf_len);
+               if (ret)
+               return ret;
+       }
+
+       *proto = ac->protocol;
+       *buf = o->o_authorizer_buf;
+       *len = o->o_authorizer_buf_len;
+       *reply_buf = o->o_authorizer_reply_buf;
+       *reply_len = o->o_authorizer_reply_buf_len;
+       return 0;
+}
+
+
+static int verify_authorizer_reply(struct ceph_connection *con, int len)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_osd_client *osdc = o->o_osdc;
+       struct ceph_auth_client *ac = osdc->client->monc.auth;
+
+       return ac->ops->verify_authorizer_reply(ac, o->o_authorizer, len);
+}
+
+static int invalidate_authorizer(struct ceph_connection *con)
+{
+       struct ceph_osd *o = con->private;
+       struct ceph_osd_client *osdc = o->o_osdc;
+       struct ceph_auth_client *ac = osdc->client->monc.auth;
+
+       if (ac->ops->invalidate_authorizer)
+               ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD);
+
+       return ceph_monc_validate_auth(&osdc->client->monc);
+}
+
+const static struct ceph_connection_operations osd_con_ops = {
+       .get = get_osd_con,
+       .put = put_osd_con,
+       .dispatch = dispatch,
+       .get_authorizer = get_authorizer,
+       .verify_authorizer_reply = verify_authorizer_reply,
+       .invalidate_authorizer = invalidate_authorizer,
+       .alloc_msg = alloc_msg,
+       .fault = osd_reset,
+};
diff --git a/fs/ceph/osd_client.h b/fs/ceph/osd_client.h
new file mode 100644 (file)
index 0000000..b075991
--- /dev/null
@@ -0,0 +1,166 @@
+#ifndef _FS_CEPH_OSD_CLIENT_H
+#define _FS_CEPH_OSD_CLIENT_H
+
+#include <linux/completion.h>
+#include <linux/kref.h>
+#include <linux/mempool.h>
+#include <linux/rbtree.h>
+
+#include "types.h"
+#include "osdmap.h"
+#include "messenger.h"
+
+struct ceph_msg;
+struct ceph_snap_context;
+struct ceph_osd_request;
+struct ceph_osd_client;
+struct ceph_authorizer;
+
+/*
+ * completion callback for async writepages
+ */
+typedef void (*ceph_osdc_callback_t)(struct ceph_osd_request *,
+                                    struct ceph_msg *);
+
+/* a given osd we're communicating with */
+struct ceph_osd {
+       atomic_t o_ref;
+       struct ceph_osd_client *o_osdc;
+       int o_osd;
+       int o_incarnation;
+       struct rb_node o_node;
+       struct ceph_connection o_con;
+       struct list_head o_requests;
+       struct list_head o_osd_lru;
+       struct ceph_authorizer *o_authorizer;
+       void *o_authorizer_buf, *o_authorizer_reply_buf;
+       size_t o_authorizer_buf_len, o_authorizer_reply_buf_len;
+       unsigned long lru_ttl;
+       int o_marked_for_keepalive;
+       struct list_head o_keepalive_item;
+};
+
+/* an in-flight request */
+struct ceph_osd_request {
+       u64             r_tid;              /* unique for this client */
+       struct rb_node  r_node;
+       struct list_head r_req_lru_item;
+       struct list_head r_osd_item;
+       struct ceph_osd *r_osd;
+       struct ceph_pg   r_pgid;
+
+       struct ceph_connection *r_con_filling_msg;
+
+       struct ceph_msg  *r_request, *r_reply;
+       int               r_result;
+       int               r_flags;     /* any additional flags for the osd */
+       u32               r_sent;      /* >0 if r_request is sending/sent */
+       int               r_got_reply;
+
+       struct ceph_osd_client *r_osdc;
+       struct kref       r_kref;
+       bool              r_mempool;
+       struct completion r_completion, r_safe_completion;
+       ceph_osdc_callback_t r_callback, r_safe_callback;
+       struct ceph_eversion r_reassert_version;
+       struct list_head  r_unsafe_item;
+
+       struct inode *r_inode;                /* for use by callbacks */
+       struct writeback_control *r_wbc;      /* ditto */
+
+       char              r_oid[40];          /* object name */
+       int               r_oid_len;
+       unsigned long     r_stamp;            /* send OR check time */
+       bool              r_resend;           /* msg send failed, needs retry */
+
+       struct ceph_file_layout r_file_layout;
+       struct ceph_snap_context *r_snapc;    /* snap context for writes */
+       unsigned          r_num_pages;        /* size of page array (follows) */
+       struct page     **r_pages;            /* pages for data payload */
+       int               r_pages_from_pool;
+       int               r_own_pages;        /* if true, i own page list */
+};
+
+struct ceph_osd_client {
+       struct ceph_client     *client;
+
+       struct ceph_osdmap     *osdmap;       /* current map */
+       struct rw_semaphore    map_sem;
+       struct completion      map_waiters;
+       u64                    last_requested_map;
+
+       struct mutex           request_mutex;
+       struct rb_root         osds;          /* osds */
+       struct list_head       osd_lru;       /* idle osds */
+       u64                    timeout_tid;   /* tid of timeout triggering rq */
+       u64                    last_tid;      /* tid of last request */
+       struct rb_root         requests;      /* pending requests */
+       struct list_head       req_lru;       /* pending requests lru */
+       int                    num_requests;
+       struct delayed_work    timeout_work;
+       struct delayed_work    osds_timeout_work;
+#ifdef CONFIG_DEBUG_FS
+       struct dentry          *debugfs_file;
+#endif
+
+       mempool_t              *req_mempool;
+
+       struct ceph_msgpool     msgpool_op;
+       struct ceph_msgpool     msgpool_op_reply;
+};
+
+extern int ceph_osdc_init(struct ceph_osd_client *osdc,
+                         struct ceph_client *client);
+extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
+
+extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
+                                  struct ceph_msg *msg);
+extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
+                                struct ceph_msg *msg);
+
+extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
+                                     struct ceph_file_layout *layout,
+                                     struct ceph_vino vino,
+                                     u64 offset, u64 *len, int op, int flags,
+                                     struct ceph_snap_context *snapc,
+                                     int do_sync, u32 truncate_seq,
+                                     u64 truncate_size,
+                                     struct timespec *mtime,
+                                     bool use_mempool, int num_reply);
+
+static inline void ceph_osdc_get_request(struct ceph_osd_request *req)
+{
+       kref_get(&req->r_kref);
+}
+extern void ceph_osdc_release_request(struct kref *kref);
+static inline void ceph_osdc_put_request(struct ceph_osd_request *req)
+{
+       kref_put(&req->r_kref, ceph_osdc_release_request);
+}
+
+extern int ceph_osdc_start_request(struct ceph_osd_client *osdc,
+                                  struct ceph_osd_request *req,
+                                  bool nofail);
+extern int ceph_osdc_wait_request(struct ceph_osd_client *osdc,
+                                 struct ceph_osd_request *req);
+extern void ceph_osdc_sync(struct ceph_osd_client *osdc);
+
+extern int ceph_osdc_readpages(struct ceph_osd_client *osdc,
+                              struct ceph_vino vino,
+                              struct ceph_file_layout *layout,
+                              u64 off, u64 *plen,
+                              u32 truncate_seq, u64 truncate_size,
+                              struct page **pages, int nr_pages);
+
+extern int ceph_osdc_writepages(struct ceph_osd_client *osdc,
+                               struct ceph_vino vino,
+                               struct ceph_file_layout *layout,
+                               struct ceph_snap_context *sc,
+                               u64 off, u64 len,
+                               u32 truncate_seq, u64 truncate_size,
+                               struct timespec *mtime,
+                               struct page **pages, int nr_pages,
+                               int flags, int do_sync, bool nofail);
+
+#endif
+
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
new file mode 100644 (file)
index 0000000..21c6623
--- /dev/null
@@ -0,0 +1,1024 @@
+
+#include "ceph_debug.h"
+
+#include <linux/slab.h>
+#include <asm/div64.h>
+
+#include "super.h"
+#include "osdmap.h"
+#include "crush/hash.h"
+#include "crush/mapper.h"
+#include "decode.h"
+
+char *ceph_osdmap_state_str(char *str, int len, int state)
+{
+       int flag = 0;
+
+       if (!len)
+               goto done;
+
+       *str = '\0';
+       if (state) {
+               if (state & CEPH_OSD_EXISTS) {
+                       snprintf(str, len, "exists");
+                       flag = 1;
+               }
+               if (state & CEPH_OSD_UP) {
+                       snprintf(str, len, "%s%s%s", str, (flag ? ", " : ""),
+                                "up");
+                       flag = 1;
+               }
+       } else {
+               snprintf(str, len, "doesn't exist");
+       }
+done:
+       return str;
+}
+
+/* maps */
+
+static int calc_bits_of(unsigned t)
+{
+       int b = 0;
+       while (t) {
+               t = t >> 1;
+               b++;
+       }
+       return b;
+}
+
+/*
+ * the foo_mask is the smallest value 2^n-1 that is >= foo.
+ */
+static void calc_pg_masks(struct ceph_pg_pool_info *pi)
+{
+       pi->pg_num_mask = (1 << calc_bits_of(le32_to_cpu(pi->v.pg_num)-1)) - 1;
+       pi->pgp_num_mask =
+               (1 << calc_bits_of(le32_to_cpu(pi->v.pgp_num)-1)) - 1;
+       pi->lpg_num_mask =
+               (1 << calc_bits_of(le32_to_cpu(pi->v.lpg_num)-1)) - 1;
+       pi->lpgp_num_mask =
+               (1 << calc_bits_of(le32_to_cpu(pi->v.lpgp_num)-1)) - 1;
+}
+
+/*
+ * decode crush map
+ */
+static int crush_decode_uniform_bucket(void **p, void *end,
+                                      struct crush_bucket_uniform *b)
+{
+       dout("crush_decode_uniform_bucket %p to %p\n", *p, end);
+       ceph_decode_need(p, end, (1+b->h.size) * sizeof(u32), bad);
+       b->item_weight = ceph_decode_32(p);
+       return 0;
+bad:
+       return -EINVAL;
+}
+
+static int crush_decode_list_bucket(void **p, void *end,
+                                   struct crush_bucket_list *b)
+{
+       int j;
+       dout("crush_decode_list_bucket %p to %p\n", *p, end);
+       b->item_weights = kcalloc(b->h.size, sizeof(u32), GFP_NOFS);
+       if (b->item_weights == NULL)
+               return -ENOMEM;
+       b->sum_weights = kcalloc(b->h.size, sizeof(u32), GFP_NOFS);
+       if (b->sum_weights == NULL)
+               return -ENOMEM;
+       ceph_decode_need(p, end, 2 * b->h.size * sizeof(u32), bad);
+       for (j = 0; j < b->h.size; j++) {
+               b->item_weights[j] = ceph_decode_32(p);
+               b->sum_weights[j] = ceph_decode_32(p);
+       }
+       return 0;
+bad:
+       return -EINVAL;
+}
+
+static int crush_decode_tree_bucket(void **p, void *end,
+                                   struct crush_bucket_tree *b)
+{
+       int j;
+       dout("crush_decode_tree_bucket %p to %p\n", *p, end);
+       ceph_decode_32_safe(p, end, b->num_nodes, bad);
+       b->node_weights = kcalloc(b->num_nodes, sizeof(u32), GFP_NOFS);
+       if (b->node_weights == NULL)
+               return -ENOMEM;
+       ceph_decode_need(p, end, b->num_nodes * sizeof(u32), bad);
+       for (j = 0; j < b->num_nodes; j++)
+               b->node_weights[j] = ceph_decode_32(p);
+       return 0;
+bad:
+       return -EINVAL;
+}
+
+static int crush_decode_straw_bucket(void **p, void *end,
+                                    struct crush_bucket_straw *b)
+{
+       int j;
+       dout("crush_decode_straw_bucket %p to %p\n", *p, end);
+       b->item_weights = kcalloc(b->h.size, sizeof(u32), GFP_NOFS);
+       if (b->item_weights == NULL)
+               return -ENOMEM;
+       b->straws = kcalloc(b->h.size, sizeof(u32), GFP_NOFS);
+       if (b->straws == NULL)
+               return -ENOMEM;
+       ceph_decode_need(p, end, 2 * b->h.size * sizeof(u32), bad);
+       for (j = 0; j < b->h.size; j++) {
+               b->item_weights[j] = ceph_decode_32(p);
+               b->straws[j] = ceph_decode_32(p);
+       }
+       return 0;
+bad:
+       return -EINVAL;
+}
+
+static struct crush_map *crush_decode(void *pbyval, void *end)
+{
+       struct crush_map *c;
+       int err = -EINVAL;
+       int i, j;
+       void **p = &pbyval;
+       void *start = pbyval;
+       u32 magic;
+
+       dout("crush_decode %p to %p len %d\n", *p, end, (int)(end - *p));
+
+       c = kzalloc(sizeof(*c), GFP_NOFS);
+       if (c == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       ceph_decode_need(p, end, 4*sizeof(u32), bad);
+       magic = ceph_decode_32(p);
+       if (magic != CRUSH_MAGIC) {
+               pr_err("crush_decode magic %x != current %x\n",
+                      (unsigned)magic, (unsigned)CRUSH_MAGIC);
+               goto bad;
+       }
+       c->max_buckets = ceph_decode_32(p);
+       c->max_rules = ceph_decode_32(p);
+       c->max_devices = ceph_decode_32(p);
+
+       c->device_parents = kcalloc(c->max_devices, sizeof(u32), GFP_NOFS);
+       if (c->device_parents == NULL)
+               goto badmem;
+       c->bucket_parents = kcalloc(c->max_buckets, sizeof(u32), GFP_NOFS);
+       if (c->bucket_parents == NULL)
+               goto badmem;
+
+       c->buckets = kcalloc(c->max_buckets, sizeof(*c->buckets), GFP_NOFS);
+       if (c->buckets == NULL)
+               goto badmem;
+       c->rules = kcalloc(c->max_rules, sizeof(*c->rules), GFP_NOFS);
+       if (c->rules == NULL)
+               goto badmem;
+
+       /* buckets */
+       for (i = 0; i < c->max_buckets; i++) {
+               int size = 0;
+               u32 alg;
+               struct crush_bucket *b;
+
+               ceph_decode_32_safe(p, end, alg, bad);
+               if (alg == 0) {
+                       c->buckets[i] = NULL;
+                       continue;
+               }
+               dout("crush_decode bucket %d off %x %p to %p\n",
+                    i, (int)(*p-start), *p, end);
+
+               switch (alg) {
+               case CRUSH_BUCKET_UNIFORM:
+                       size = sizeof(struct crush_bucket_uniform);
+                       break;
+               case CRUSH_BUCKET_LIST:
+                       size = sizeof(struct crush_bucket_list);
+                       break;
+               case CRUSH_BUCKET_TREE:
+                       size = sizeof(struct crush_bucket_tree);
+                       break;
+               case CRUSH_BUCKET_STRAW:
+                       size = sizeof(struct crush_bucket_straw);
+                       break;
+               default:
+                       err = -EINVAL;
+                       goto bad;
+               }
+               BUG_ON(size == 0);
+               b = c->buckets[i] = kzalloc(size, GFP_NOFS);
+               if (b == NULL)
+                       goto badmem;
+
+               ceph_decode_need(p, end, 4*sizeof(u32), bad);
+               b->id = ceph_decode_32(p);
+               b->type = ceph_decode_16(p);
+               b->alg = ceph_decode_8(p);
+               b->hash = ceph_decode_8(p);
+               b->weight = ceph_decode_32(p);
+               b->size = ceph_decode_32(p);
+
+               dout("crush_decode bucket size %d off %x %p to %p\n",
+                    b->size, (int)(*p-start), *p, end);
+
+               b->items = kcalloc(b->size, sizeof(__s32), GFP_NOFS);
+               if (b->items == NULL)
+                       goto badmem;
+               b->perm = kcalloc(b->size, sizeof(u32), GFP_NOFS);
+               if (b->perm == NULL)
+                       goto badmem;
+               b->perm_n = 0;
+
+               ceph_decode_need(p, end, b->size*sizeof(u32), bad);
+               for (j = 0; j < b->size; j++)
+                       b->items[j] = ceph_decode_32(p);
+
+               switch (b->alg) {
+               case CRUSH_BUCKET_UNIFORM:
+                       err = crush_decode_uniform_bucket(p, end,
+                                 (struct crush_bucket_uniform *)b);
+                       if (err < 0)
+                               goto bad;
+                       break;
+               case CRUSH_BUCKET_LIST:
+                       err = crush_decode_list_bucket(p, end,
+                              (struct crush_bucket_list *)b);
+                       if (err < 0)
+                               goto bad;
+                       break;
+               case CRUSH_BUCKET_TREE:
+                       err = crush_decode_tree_bucket(p, end,
+                               (struct crush_bucket_tree *)b);
+                       if (err < 0)
+                               goto bad;
+                       break;
+               case CRUSH_BUCKET_STRAW:
+                       err = crush_decode_straw_bucket(p, end,
+                               (struct crush_bucket_straw *)b);
+                       if (err < 0)
+                               goto bad;
+                       break;
+               }
+       }
+
+       /* rules */
+       dout("rule vec is %p\n", c->rules);
+       for (i = 0; i < c->max_rules; i++) {
+               u32 yes;
+               struct crush_rule *r;
+
+               ceph_decode_32_safe(p, end, yes, bad);
+               if (!yes) {
+                       dout("crush_decode NO rule %d off %x %p to %p\n",
+                            i, (int)(*p-start), *p, end);
+                       c->rules[i] = NULL;
+                       continue;
+               }
+
+               dout("crush_decode rule %d off %x %p to %p\n",
+                    i, (int)(*p-start), *p, end);
+
+               /* len */
+               ceph_decode_32_safe(p, end, yes, bad);
+#if BITS_PER_LONG == 32
+               err = -EINVAL;
+               if (yes > ULONG_MAX / sizeof(struct crush_rule_step))
+                       goto bad;
+#endif
+               r = c->rules[i] = kmalloc(sizeof(*r) +
+                                         yes*sizeof(struct crush_rule_step),
+                                         GFP_NOFS);
+               if (r == NULL)
+                       goto badmem;
+               dout(" rule %d is at %p\n", i, r);
+               r->len = yes;
+               ceph_decode_copy_safe(p, end, &r->mask, 4, bad); /* 4 u8's */
+               ceph_decode_need(p, end, r->len*3*sizeof(u32), bad);
+               for (j = 0; j < r->len; j++) {
+                       r->steps[j].op = ceph_decode_32(p);
+                       r->steps[j].arg1 = ceph_decode_32(p);
+                       r->steps[j].arg2 = ceph_decode_32(p);
+               }
+       }
+
+       /* ignore trailing name maps. */
+
+       dout("crush_decode success\n");
+       return c;
+
+badmem:
+       err = -ENOMEM;
+bad:
+       dout("crush_decode fail %d\n", err);
+       crush_destroy(c);
+       return ERR_PTR(err);
+}
+
+
+/*
+ * osd map
+ */
+void ceph_osdmap_destroy(struct ceph_osdmap *map)
+{
+       dout("osdmap_destroy %p\n", map);
+       if (map->crush)
+               crush_destroy(map->crush);
+       while (!RB_EMPTY_ROOT(&map->pg_temp)) {
+               struct ceph_pg_mapping *pg =
+                       rb_entry(rb_first(&map->pg_temp),
+                                struct ceph_pg_mapping, node);
+               rb_erase(&pg->node, &map->pg_temp);
+               kfree(pg);
+       }
+       while (!RB_EMPTY_ROOT(&map->pg_pools)) {
+               struct ceph_pg_pool_info *pi =
+                       rb_entry(rb_first(&map->pg_pools),
+                                struct ceph_pg_pool_info, node);
+               rb_erase(&pi->node, &map->pg_pools);
+               kfree(pi);
+       }
+       kfree(map->osd_state);
+       kfree(map->osd_weight);
+       kfree(map->osd_addr);
+       kfree(map);
+}
+
+/*
+ * adjust max osd value.  reallocate arrays.
+ */
+static int osdmap_set_max_osd(struct ceph_osdmap *map, int max)
+{
+       u8 *state;
+       struct ceph_entity_addr *addr;
+       u32 *weight;
+
+       state = kcalloc(max, sizeof(*state), GFP_NOFS);
+       addr = kcalloc(max, sizeof(*addr), GFP_NOFS);
+       weight = kcalloc(max, sizeof(*weight), GFP_NOFS);
+       if (state == NULL || addr == NULL || weight == NULL) {
+               kfree(state);
+               kfree(addr);
+               kfree(weight);
+               return -ENOMEM;
+       }
+
+       /* copy old? */
+       if (map->osd_state) {
+               memcpy(state, map->osd_state, map->max_osd*sizeof(*state));
+               memcpy(addr, map->osd_addr, map->max_osd*sizeof(*addr));
+               memcpy(weight, map->osd_weight, map->max_osd*sizeof(*weight));
+               kfree(map->osd_state);
+               kfree(map->osd_addr);
+               kfree(map->osd_weight);
+       }
+
+       map->osd_state = state;
+       map->osd_weight = weight;
+       map->osd_addr = addr;
+       map->max_osd = max;
+       return 0;
+}
+
+/*
+ * rbtree of pg_mapping for handling pg_temp (explicit mapping of pgid
+ * to a set of osds)
+ */
+static int pgid_cmp(struct ceph_pg l, struct ceph_pg r)
+{
+       u64 a = *(u64 *)&l;
+       u64 b = *(u64 *)&r;
+
+       if (a < b)
+               return -1;
+       if (a > b)
+               return 1;
+       return 0;
+}
+
+static int __insert_pg_mapping(struct ceph_pg_mapping *new,
+                              struct rb_root *root)
+{
+       struct rb_node **p = &root->rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_pg_mapping *pg = NULL;
+       int c;
+
+       while (*p) {
+               parent = *p;
+               pg = rb_entry(parent, struct ceph_pg_mapping, node);
+               c = pgid_cmp(new->pgid, pg->pgid);
+               if (c < 0)
+                       p = &(*p)->rb_left;
+               else if (c > 0)
+                       p = &(*p)->rb_right;
+               else
+                       return -EEXIST;
+       }
+
+       rb_link_node(&new->node, parent, p);
+       rb_insert_color(&new->node, root);
+       return 0;
+}
+
+static struct ceph_pg_mapping *__lookup_pg_mapping(struct rb_root *root,
+                                                  struct ceph_pg pgid)
+{
+       struct rb_node *n = root->rb_node;
+       struct ceph_pg_mapping *pg;
+       int c;
+
+       while (n) {
+               pg = rb_entry(n, struct ceph_pg_mapping, node);
+               c = pgid_cmp(pgid, pg->pgid);
+               if (c < 0)
+                       n = n->rb_left;
+               else if (c > 0)
+                       n = n->rb_right;
+               else
+                       return pg;
+       }
+       return NULL;
+}
+
+/*
+ * rbtree of pg pool info
+ */
+static int __insert_pg_pool(struct rb_root *root, struct ceph_pg_pool_info *new)
+{
+       struct rb_node **p = &root->rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_pg_pool_info *pi = NULL;
+
+       while (*p) {
+               parent = *p;
+               pi = rb_entry(parent, struct ceph_pg_pool_info, node);
+               if (new->id < pi->id)
+                       p = &(*p)->rb_left;
+               else if (new->id > pi->id)
+                       p = &(*p)->rb_right;
+               else
+                       return -EEXIST;
+       }
+
+       rb_link_node(&new->node, parent, p);
+       rb_insert_color(&new->node, root);
+       return 0;
+}
+
+static struct ceph_pg_pool_info *__lookup_pg_pool(struct rb_root *root, int id)
+{
+       struct ceph_pg_pool_info *pi;
+       struct rb_node *n = root->rb_node;
+
+       while (n) {
+               pi = rb_entry(n, struct ceph_pg_pool_info, node);
+               if (id < pi->id)
+                       n = n->rb_left;
+               else if (id > pi->id)
+                       n = n->rb_right;
+               else
+                       return pi;
+       }
+       return NULL;
+}
+
+void __decode_pool(void **p, struct ceph_pg_pool_info *pi)
+{
+       ceph_decode_copy(p, &pi->v, sizeof(pi->v));
+       calc_pg_masks(pi);
+       *p += le32_to_cpu(pi->v.num_snaps) * sizeof(u64);
+       *p += le32_to_cpu(pi->v.num_removed_snap_intervals) * sizeof(u64) * 2;
+}
+
+/*
+ * decode a full map.
+ */
+struct ceph_osdmap *osdmap_decode(void **p, void *end)
+{
+       struct ceph_osdmap *map;
+       u16 version;
+       u32 len, max, i;
+       u8 ev;
+       int err = -EINVAL;
+       void *start = *p;
+       struct ceph_pg_pool_info *pi;
+
+       dout("osdmap_decode %p to %p len %d\n", *p, end, (int)(end - *p));
+
+       map = kzalloc(sizeof(*map), GFP_NOFS);
+       if (map == NULL)
+               return ERR_PTR(-ENOMEM);
+       map->pg_temp = RB_ROOT;
+
+       ceph_decode_16_safe(p, end, version, bad);
+       if (version > CEPH_OSDMAP_VERSION) {
+               pr_warning("got unknown v %d > %d of osdmap\n", version,
+                          CEPH_OSDMAP_VERSION);
+               goto bad;
+       }
+
+       ceph_decode_need(p, end, 2*sizeof(u64)+6*sizeof(u32), bad);
+       ceph_decode_copy(p, &map->fsid, sizeof(map->fsid));
+       map->epoch = ceph_decode_32(p);
+       ceph_decode_copy(p, &map->created, sizeof(map->created));
+       ceph_decode_copy(p, &map->modified, sizeof(map->modified));
+
+       ceph_decode_32_safe(p, end, max, bad);
+       while (max--) {
+               ceph_decode_need(p, end, 4 + 1 + sizeof(pi->v), bad);
+               pi = kmalloc(sizeof(*pi), GFP_NOFS);
+               if (!pi)
+                       goto bad;
+               pi->id = ceph_decode_32(p);
+               ev = ceph_decode_8(p); /* encoding version */
+               if (ev > CEPH_PG_POOL_VERSION) {
+                       pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
+                                  ev, CEPH_PG_POOL_VERSION);
+                       goto bad;
+               }
+               __decode_pool(p, pi);
+               __insert_pg_pool(&map->pg_pools, pi);
+       }
+       ceph_decode_32_safe(p, end, map->pool_max, bad);
+
+       ceph_decode_32_safe(p, end, map->flags, bad);
+
+       max = ceph_decode_32(p);
+
+       /* (re)alloc osd arrays */
+       err = osdmap_set_max_osd(map, max);
+       if (err < 0)
+               goto bad;
+       dout("osdmap_decode max_osd = %d\n", map->max_osd);
+
+       /* osds */
+       err = -EINVAL;
+       ceph_decode_need(p, end, 3*sizeof(u32) +
+                        map->max_osd*(1 + sizeof(*map->osd_weight) +
+                                      sizeof(*map->osd_addr)), bad);
+       *p += 4; /* skip length field (should match max) */
+       ceph_decode_copy(p, map->osd_state, map->max_osd);
+
+       *p += 4; /* skip length field (should match max) */
+       for (i = 0; i < map->max_osd; i++)
+               map->osd_weight[i] = ceph_decode_32(p);
+
+       *p += 4; /* skip length field (should match max) */
+       ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr));
+       for (i = 0; i < map->max_osd; i++)
+               ceph_decode_addr(&map->osd_addr[i]);
+
+       /* pg_temp */
+       ceph_decode_32_safe(p, end, len, bad);
+       for (i = 0; i < len; i++) {
+               int n, j;
+               struct ceph_pg pgid;
+               struct ceph_pg_mapping *pg;
+
+               ceph_decode_need(p, end, sizeof(u32) + sizeof(u64), bad);
+               ceph_decode_copy(p, &pgid, sizeof(pgid));
+               n = ceph_decode_32(p);
+               ceph_decode_need(p, end, n * sizeof(u32), bad);
+               err = -ENOMEM;
+               pg = kmalloc(sizeof(*pg) + n*sizeof(u32), GFP_NOFS);
+               if (!pg)
+                       goto bad;
+               pg->pgid = pgid;
+               pg->len = n;
+               for (j = 0; j < n; j++)
+                       pg->osds[j] = ceph_decode_32(p);
+
+               err = __insert_pg_mapping(pg, &map->pg_temp);
+               if (err)
+                       goto bad;
+               dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid, len);
+       }
+
+       /* crush */
+       ceph_decode_32_safe(p, end, len, bad);
+       dout("osdmap_decode crush len %d from off 0x%x\n", len,
+            (int)(*p - start));
+       ceph_decode_need(p, end, len, bad);
+       map->crush = crush_decode(*p, end);
+       *p += len;
+       if (IS_ERR(map->crush)) {
+               err = PTR_ERR(map->crush);
+               map->crush = NULL;
+               goto bad;
+       }
+
+       /* ignore the rest of the map */
+       *p = end;
+
+       dout("osdmap_decode done %p %p\n", *p, end);
+       return map;
+
+bad:
+       dout("osdmap_decode fail\n");
+       ceph_osdmap_destroy(map);
+       return ERR_PTR(err);
+}
+
+/*
+ * decode and apply an incremental map update.
+ */
+struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
+                                            struct ceph_osdmap *map,
+                                            struct ceph_messenger *msgr)
+{
+       struct crush_map *newcrush = NULL;
+       struct ceph_fsid fsid;
+       u32 epoch = 0;
+       struct ceph_timespec modified;
+       u32 len, pool;
+       __s32 new_pool_max, new_flags, max;
+       void *start = *p;
+       int err = -EINVAL;
+       u16 version;
+       struct rb_node *rbp;
+
+       ceph_decode_16_safe(p, end, version, bad);
+       if (version > CEPH_OSDMAP_INC_VERSION) {
+               pr_warning("got unknown v %d > %d of inc osdmap\n", version,
+                          CEPH_OSDMAP_INC_VERSION);
+               goto bad;
+       }
+
+       ceph_decode_need(p, end, sizeof(fsid)+sizeof(modified)+2*sizeof(u32),
+                        bad);
+       ceph_decode_copy(p, &fsid, sizeof(fsid));
+       epoch = ceph_decode_32(p);
+       BUG_ON(epoch != map->epoch+1);
+       ceph_decode_copy(p, &modified, sizeof(modified));
+       new_pool_max = ceph_decode_32(p);
+       new_flags = ceph_decode_32(p);
+
+       /* full map? */
+       ceph_decode_32_safe(p, end, len, bad);
+       if (len > 0) {
+               dout("apply_incremental full map len %d, %p to %p\n",
+                    len, *p, end);
+               return osdmap_decode(p, min(*p+len, end));
+       }
+
+       /* new crush? */
+       ceph_decode_32_safe(p, end, len, bad);
+       if (len > 0) {
+               dout("apply_incremental new crush map len %d, %p to %p\n",
+                    len, *p, end);
+               newcrush = crush_decode(*p, min(*p+len, end));
+               if (IS_ERR(newcrush))
+                       return ERR_PTR(PTR_ERR(newcrush));
+       }
+
+       /* new flags? */
+       if (new_flags >= 0)
+               map->flags = new_flags;
+       if (new_pool_max >= 0)
+               map->pool_max = new_pool_max;
+
+       ceph_decode_need(p, end, 5*sizeof(u32), bad);
+
+       /* new max? */
+       max = ceph_decode_32(p);
+       if (max >= 0) {
+               err = osdmap_set_max_osd(map, max);
+               if (err < 0)
+                       goto bad;
+       }
+
+       map->epoch++;
+       map->modified = map->modified;
+       if (newcrush) {
+               if (map->crush)
+                       crush_destroy(map->crush);
+               map->crush = newcrush;
+               newcrush = NULL;
+       }
+
+       /* new_pool */
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               __u8 ev;
+               struct ceph_pg_pool_info *pi;
+
+               ceph_decode_32_safe(p, end, pool, bad);
+               ceph_decode_need(p, end, 1 + sizeof(pi->v), bad);
+               ev = ceph_decode_8(p);  /* encoding version */
+               if (ev > CEPH_PG_POOL_VERSION) {
+                       pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
+                                  ev, CEPH_PG_POOL_VERSION);
+                       goto bad;
+               }
+               pi = __lookup_pg_pool(&map->pg_pools, pool);
+               if (!pi) {
+                       pi = kmalloc(sizeof(*pi), GFP_NOFS);
+                       if (!pi) {
+                               err = -ENOMEM;
+                               goto bad;
+                       }
+                       pi->id = pool;
+                       __insert_pg_pool(&map->pg_pools, pi);
+               }
+               __decode_pool(p, pi);
+       }
+
+       /* old_pool */
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               struct ceph_pg_pool_info *pi;
+
+               ceph_decode_32_safe(p, end, pool, bad);
+               pi = __lookup_pg_pool(&map->pg_pools, pool);
+               if (pi) {
+                       rb_erase(&pi->node, &map->pg_pools);
+                       kfree(pi);
+               }
+       }
+
+       /* new_up */
+       err = -EINVAL;
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               u32 osd;
+               struct ceph_entity_addr addr;
+               ceph_decode_32_safe(p, end, osd, bad);
+               ceph_decode_copy_safe(p, end, &addr, sizeof(addr), bad);
+               ceph_decode_addr(&addr);
+               pr_info("osd%d up\n", osd);
+               BUG_ON(osd >= map->max_osd);
+               map->osd_state[osd] |= CEPH_OSD_UP;
+               map->osd_addr[osd] = addr;
+       }
+
+       /* new_down */
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               u32 osd;
+               ceph_decode_32_safe(p, end, osd, bad);
+               (*p)++;  /* clean flag */
+               pr_info("osd%d down\n", osd);
+               if (osd < map->max_osd)
+                       map->osd_state[osd] &= ~CEPH_OSD_UP;
+       }
+
+       /* new_weight */
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               u32 osd, off;
+               ceph_decode_need(p, end, sizeof(u32)*2, bad);
+               osd = ceph_decode_32(p);
+               off = ceph_decode_32(p);
+               pr_info("osd%d weight 0x%x %s\n", osd, off,
+                    off == CEPH_OSD_IN ? "(in)" :
+                    (off == CEPH_OSD_OUT ? "(out)" : ""));
+               if (osd < map->max_osd)
+                       map->osd_weight[osd] = off;
+       }
+
+       /* new_pg_temp */
+       rbp = rb_first(&map->pg_temp);
+       ceph_decode_32_safe(p, end, len, bad);
+       while (len--) {
+               struct ceph_pg_mapping *pg;
+               int j;
+               struct ceph_pg pgid;
+               u32 pglen;
+               ceph_decode_need(p, end, sizeof(u64) + sizeof(u32), bad);
+               ceph_decode_copy(p, &pgid, sizeof(pgid));
+               pglen = ceph_decode_32(p);
+
+               /* remove any? */
+               while (rbp && pgid_cmp(rb_entry(rbp, struct ceph_pg_mapping,
+                                               node)->pgid, pgid) <= 0) {
+                       struct rb_node *cur = rbp;
+                       rbp = rb_next(rbp);
+                       dout(" removed pg_temp %llx\n",
+                            *(u64 *)&rb_entry(cur, struct ceph_pg_mapping,
+                                              node)->pgid);
+                       rb_erase(cur, &map->pg_temp);
+               }
+
+               if (pglen) {
+                       /* insert */
+                       ceph_decode_need(p, end, pglen*sizeof(u32), bad);
+                       pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS);
+                       if (!pg) {
+                               err = -ENOMEM;
+                               goto bad;
+                       }
+                       pg->pgid = pgid;
+                       pg->len = pglen;
+                       for (j = 0; j < pglen; j++)
+                               pg->osds[j] = ceph_decode_32(p);
+                       err = __insert_pg_mapping(pg, &map->pg_temp);
+                       if (err)
+                               goto bad;
+                       dout(" added pg_temp %llx len %d\n", *(u64 *)&pgid,
+                            pglen);
+               }
+       }
+       while (rbp) {
+               struct rb_node *cur = rbp;
+               rbp = rb_next(rbp);
+               dout(" removed pg_temp %llx\n",
+                    *(u64 *)&rb_entry(cur, struct ceph_pg_mapping,
+                                      node)->pgid);
+               rb_erase(cur, &map->pg_temp);
+       }
+
+       /* ignore the rest */
+       *p = end;
+       return map;
+
+bad:
+       pr_err("corrupt inc osdmap epoch %d off %d (%p of %p-%p)\n",
+              epoch, (int)(*p - start), *p, start, end);
+       print_hex_dump(KERN_DEBUG, "osdmap: ",
+                      DUMP_PREFIX_OFFSET, 16, 1,
+                      start, end - start, true);
+       if (newcrush)
+               crush_destroy(newcrush);
+       return ERR_PTR(err);
+}
+
+
+
+
+/*
+ * calculate file layout from given offset, length.
+ * fill in correct oid, logical length, and object extent
+ * offset, length.
+ *
+ * for now, we write only a single su, until we can
+ * pass a stride back to the caller.
+ */
+void ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
+                                  u64 off, u64 *plen,
+                                  u64 *ono,
+                                  u64 *oxoff, u64 *oxlen)
+{
+       u32 osize = le32_to_cpu(layout->fl_object_size);
+       u32 su = le32_to_cpu(layout->fl_stripe_unit);
+       u32 sc = le32_to_cpu(layout->fl_stripe_count);
+       u32 bl, stripeno, stripepos, objsetno;
+       u32 su_per_object;
+       u64 t, su_offset;
+
+       dout("mapping %llu~%llu  osize %u fl_su %u\n", off, *plen,
+            osize, su);
+       su_per_object = osize / su;
+       dout("osize %u / su %u = su_per_object %u\n", osize, su,
+            su_per_object);
+
+       BUG_ON((su & ~PAGE_MASK) != 0);
+       /* bl = *off / su; */
+       t = off;
+       do_div(t, su);
+       bl = t;
+       dout("off %llu / su %u = bl %u\n", off, su, bl);
+
+       stripeno = bl / sc;
+       stripepos = bl % sc;
+       objsetno = stripeno / su_per_object;
+
+       *ono = objsetno * sc + stripepos;
+       dout("objset %u * sc %u = ono %u\n", objsetno, sc, (unsigned)*ono);
+
+       /* *oxoff = *off % layout->fl_stripe_unit;  # offset in su */
+       t = off;
+       su_offset = do_div(t, su);
+       *oxoff = su_offset + (stripeno % su_per_object) * su;
+
+       /*
+        * Calculate the length of the extent being written to the selected
+        * object. This is the minimum of the full length requested (plen) or
+        * the remainder of the current stripe being written to.
+        */
+       *oxlen = min_t(u64, *plen, su - su_offset);
+       *plen = *oxlen;
+
+       dout(" obj extent %llu~%llu\n", *oxoff, *oxlen);
+}
+
+/*
+ * calculate an object layout (i.e. pgid) from an oid,
+ * file_layout, and osdmap
+ */
+int ceph_calc_object_layout(struct ceph_object_layout *ol,
+                           const char *oid,
+                           struct ceph_file_layout *fl,
+                           struct ceph_osdmap *osdmap)
+{
+       unsigned num, num_mask;
+       struct ceph_pg pgid;
+       s32 preferred = (s32)le32_to_cpu(fl->fl_pg_preferred);
+       int poolid = le32_to_cpu(fl->fl_pg_pool);
+       struct ceph_pg_pool_info *pool;
+       unsigned ps;
+
+       BUG_ON(!osdmap);
+
+       pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
+       if (!pool)
+               return -EIO;
+       ps = ceph_str_hash(pool->v.object_hash, oid, strlen(oid));
+       if (preferred >= 0) {
+               ps += preferred;
+               num = le32_to_cpu(pool->v.lpg_num);
+               num_mask = pool->lpg_num_mask;
+       } else {
+               num = le32_to_cpu(pool->v.pg_num);
+               num_mask = pool->pg_num_mask;
+       }
+
+       pgid.ps = cpu_to_le16(ps);
+       pgid.preferred = cpu_to_le16(preferred);
+       pgid.pool = fl->fl_pg_pool;
+       if (preferred >= 0)
+               dout("calc_object_layout '%s' pgid %d.%xp%d\n", oid, poolid, ps,
+                    (int)preferred);
+       else
+               dout("calc_object_layout '%s' pgid %d.%x\n", oid, poolid, ps);
+
+       ol->ol_pgid = pgid;
+       ol->ol_stripe_unit = fl->fl_object_stripe_unit;
+       return 0;
+}
+
+/*
+ * Calculate raw osd vector for the given pgid.  Return pointer to osd
+ * array, or NULL on failure.
+ */
+static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
+                       int *osds, int *num)
+{
+       struct ceph_pg_mapping *pg;
+       struct ceph_pg_pool_info *pool;
+       int ruleno;
+       unsigned poolid, ps, pps;
+       int preferred;
+
+       /* pg_temp? */
+       pg = __lookup_pg_mapping(&osdmap->pg_temp, pgid);
+       if (pg) {
+               *num = pg->len;
+               return pg->osds;
+       }
+
+       /* crush */
+       poolid = le32_to_cpu(pgid.pool);
+       ps = le16_to_cpu(pgid.ps);
+       preferred = (s16)le16_to_cpu(pgid.preferred);
+
+       /* don't forcefeed bad device ids to crush */
+       if (preferred >= osdmap->max_osd ||
+           preferred >= osdmap->crush->max_devices)
+               preferred = -1;
+
+       pool = __lookup_pg_pool(&osdmap->pg_pools, poolid);
+       if (!pool)
+               return NULL;
+       ruleno = crush_find_rule(osdmap->crush, pool->v.crush_ruleset,
+                                pool->v.type, pool->v.size);
+       if (ruleno < 0) {
+               pr_err("no crush rule pool %d type %d size %d\n",
+                      poolid, pool->v.type, pool->v.size);
+               return NULL;
+       }
+
+       if (preferred >= 0)
+               pps = ceph_stable_mod(ps,
+                                     le32_to_cpu(pool->v.lpgp_num),
+                                     pool->lpgp_num_mask);
+       else
+               pps = ceph_stable_mod(ps,
+                                     le32_to_cpu(pool->v.pgp_num),
+                                     pool->pgp_num_mask);
+       pps += poolid;
+       *num = crush_do_rule(osdmap->crush, ruleno, pps, osds,
+                            min_t(int, pool->v.size, *num),
+                            preferred, osdmap->osd_weight);
+       return osds;
+}
+
+/*
+ * Return primary osd for given pgid, or -1 if none.
+ */
+int ceph_calc_pg_primary(struct ceph_osdmap *osdmap, struct ceph_pg pgid)
+{
+       int rawosds[10], *osds;
+       int i, num = ARRAY_SIZE(rawosds);
+
+       osds = calc_pg_raw(osdmap, pgid, rawosds, &num);
+       if (!osds)
+               return -1;
+
+       /* primary is first up osd */
+       for (i = 0; i < num; i++)
+               if (ceph_osd_is_up(osdmap, osds[i])) {
+                       return osds[i];
+                       break;
+               }
+       return -1;
+}
diff --git a/fs/ceph/osdmap.h b/fs/ceph/osdmap.h
new file mode 100644 (file)
index 0000000..1fb55af
--- /dev/null
@@ -0,0 +1,125 @@
+#ifndef _FS_CEPH_OSDMAP_H
+#define _FS_CEPH_OSDMAP_H
+
+#include <linux/rbtree.h>
+#include "types.h"
+#include "ceph_fs.h"
+#include "crush/crush.h"
+
+/*
+ * The osd map describes the current membership of the osd cluster and
+ * specifies the mapping of objects to placement groups and placement
+ * groups to (sets of) osds.  That is, it completely specifies the
+ * (desired) distribution of all data objects in the system at some
+ * point in time.
+ *
+ * Each map version is identified by an epoch, which increases monotonically.
+ *
+ * The map can be updated either via an incremental map (diff) describing
+ * the change between two successive epochs, or as a fully encoded map.
+ */
+struct ceph_pg_pool_info {
+       struct rb_node node;
+       int id;
+       struct ceph_pg_pool v;
+       int pg_num_mask, pgp_num_mask, lpg_num_mask, lpgp_num_mask;
+};
+
+struct ceph_pg_mapping {
+       struct rb_node node;
+       struct ceph_pg pgid;
+       int len;
+       int osds[];
+};
+
+struct ceph_osdmap {
+       struct ceph_fsid fsid;
+       u32 epoch;
+       u32 mkfs_epoch;
+       struct ceph_timespec created, modified;
+
+       u32 flags;         /* CEPH_OSDMAP_* */
+
+       u32 max_osd;       /* size of osd_state, _offload, _addr arrays */
+       u8 *osd_state;     /* CEPH_OSD_* */
+       u32 *osd_weight;   /* 0 = failed, 0x10000 = 100% normal */
+       struct ceph_entity_addr *osd_addr;
+
+       struct rb_root pg_temp;
+       struct rb_root pg_pools;
+       u32 pool_max;
+
+       /* the CRUSH map specifies the mapping of placement groups to
+        * the list of osds that store+replicate them. */
+       struct crush_map *crush;
+};
+
+/*
+ * file layout helpers
+ */
+#define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
+#define ceph_file_layout_stripe_count(l) \
+       ((__s32)le32_to_cpu((l).fl_stripe_count))
+#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
+#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
+#define ceph_file_layout_object_su(l) \
+       ((__s32)le32_to_cpu((l).fl_object_stripe_unit))
+#define ceph_file_layout_pg_preferred(l) \
+       ((__s32)le32_to_cpu((l).fl_pg_preferred))
+#define ceph_file_layout_pg_pool(l) \
+       ((__s32)le32_to_cpu((l).fl_pg_pool))
+
+static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout *l)
+{
+       return le32_to_cpu(l->fl_stripe_unit) *
+               le32_to_cpu(l->fl_stripe_count);
+}
+
+/* "period" == bytes before i start on a new set of objects */
+static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
+{
+       return le32_to_cpu(l->fl_object_size) *
+               le32_to_cpu(l->fl_stripe_count);
+}
+
+
+static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
+{
+       return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP);
+}
+
+static inline bool ceph_osdmap_flag(struct ceph_osdmap *map, int flag)
+{
+       return map && (map->flags & flag);
+}
+
+extern char *ceph_osdmap_state_str(char *str, int len, int state);
+
+static inline struct ceph_entity_addr *ceph_osd_addr(struct ceph_osdmap *map,
+                                                    int osd)
+{
+       if (osd >= map->max_osd)
+               return NULL;
+       return &map->osd_addr[osd];
+}
+
+extern struct ceph_osdmap *osdmap_decode(void **p, void *end);
+extern struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
+                                           struct ceph_osdmap *map,
+                                           struct ceph_messenger *msgr);
+extern void ceph_osdmap_destroy(struct ceph_osdmap *map);
+
+/* calculate mapping of a file extent to an object */
+extern void ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
+                                         u64 off, u64 *plen,
+                                         u64 *bno, u64 *oxoff, u64 *oxlen);
+
+/* calculate mapping of object to a placement group */
+extern int ceph_calc_object_layout(struct ceph_object_layout *ol,
+                                  const char *oid,
+                                  struct ceph_file_layout *fl,
+                                  struct ceph_osdmap *osdmap);
+extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap,
+                               struct ceph_pg pgid);
+
+#endif
diff --git a/fs/ceph/pagelist.c b/fs/ceph/pagelist.c
new file mode 100644 (file)
index 0000000..5f8dbf7
--- /dev/null
@@ -0,0 +1,55 @@
+
+#include <linux/gfp.h>
+#include <linux/pagemap.h>
+#include <linux/highmem.h>
+
+#include "pagelist.h"
+
+int ceph_pagelist_release(struct ceph_pagelist *pl)
+{
+       if (pl->mapped_tail)
+               kunmap(pl->mapped_tail);
+       while (!list_empty(&pl->head)) {
+               struct page *page = list_first_entry(&pl->head, struct page,
+                                                    lru);
+               list_del(&page->lru);
+               __free_page(page);
+       }
+       return 0;
+}
+
+static int ceph_pagelist_addpage(struct ceph_pagelist *pl)
+{
+       struct page *page = alloc_page(GFP_NOFS);
+       if (!page)
+               return -ENOMEM;
+       pl->room += PAGE_SIZE;
+       list_add_tail(&page->lru, &pl->head);
+       if (pl->mapped_tail)
+               kunmap(pl->mapped_tail);
+       pl->mapped_tail = kmap(page);
+       return 0;
+}
+
+int ceph_pagelist_append(struct ceph_pagelist *pl, void *buf, size_t len)
+{
+       while (pl->room < len) {
+               size_t bit = pl->room;
+               int ret;
+
+               memcpy(pl->mapped_tail + (pl->length & ~PAGE_CACHE_MASK),
+                      buf, bit);
+               pl->length += bit;
+               pl->room -= bit;
+               buf += bit;
+               len -= bit;
+               ret = ceph_pagelist_addpage(pl);
+               if (ret)
+                       return ret;
+       }
+
+       memcpy(pl->mapped_tail + (pl->length & ~PAGE_CACHE_MASK), buf, len);
+       pl->length += len;
+       pl->room -= len;
+       return 0;
+}
diff --git a/fs/ceph/pagelist.h b/fs/ceph/pagelist.h
new file mode 100644 (file)
index 0000000..e8a4187
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef __FS_CEPH_PAGELIST_H
+#define __FS_CEPH_PAGELIST_H
+
+#include <linux/list.h>
+
+struct ceph_pagelist {
+       struct list_head head;
+       void *mapped_tail;
+       size_t length;
+       size_t room;
+};
+
+static inline void ceph_pagelist_init(struct ceph_pagelist *pl)
+{
+       INIT_LIST_HEAD(&pl->head);
+       pl->mapped_tail = NULL;
+       pl->length = 0;
+       pl->room = 0;
+}
+extern int ceph_pagelist_release(struct ceph_pagelist *pl);
+
+extern int ceph_pagelist_append(struct ceph_pagelist *pl, void *d, size_t l);
+
+static inline int ceph_pagelist_encode_64(struct ceph_pagelist *pl, u64 v)
+{
+       __le64 ev = cpu_to_le64(v);
+       return ceph_pagelist_append(pl, &ev, sizeof(ev));
+}
+static inline int ceph_pagelist_encode_32(struct ceph_pagelist *pl, u32 v)
+{
+       __le32 ev = cpu_to_le32(v);
+       return ceph_pagelist_append(pl, &ev, sizeof(ev));
+}
+static inline int ceph_pagelist_encode_16(struct ceph_pagelist *pl, u16 v)
+{
+       __le16 ev = cpu_to_le16(v);
+       return ceph_pagelist_append(pl, &ev, sizeof(ev));
+}
+static inline int ceph_pagelist_encode_8(struct ceph_pagelist *pl, u8 v)
+{
+       return ceph_pagelist_append(pl, &v, 1);
+}
+static inline int ceph_pagelist_encode_string(struct ceph_pagelist *pl,
+                                             char *s, size_t len)
+{
+       int ret = ceph_pagelist_encode_32(pl, len);
+       if (ret)
+               return ret;
+       if (len)
+               return ceph_pagelist_append(pl, s, len);
+       return 0;
+}
+
+#endif
diff --git a/fs/ceph/rados.h b/fs/ceph/rados.h
new file mode 100644 (file)
index 0000000..26ac8b8
--- /dev/null
@@ -0,0 +1,374 @@
+#ifndef __RADOS_H
+#define __RADOS_H
+
+/*
+ * Data types for the Ceph distributed object storage layer RADOS
+ * (Reliable Autonomic Distributed Object Store).
+ */
+
+#include "msgr.h"
+
+/*
+ * osdmap encoding versions
+ */
+#define CEPH_OSDMAP_INC_VERSION 4
+#define CEPH_OSDMAP_VERSION     4
+
+/*
+ * fs id
+ */
+struct ceph_fsid {
+       unsigned char fsid[16];
+};
+
+static inline int ceph_fsid_compare(const struct ceph_fsid *a,
+                                   const struct ceph_fsid *b)
+{
+       return memcmp(a, b, sizeof(*a));
+}
+
+/*
+ * ino, object, etc.
+ */
+typedef __le64 ceph_snapid_t;
+#define CEPH_SNAPDIR ((__u64)(-1))  /* reserved for hidden .snap dir */
+#define CEPH_NOSNAP  ((__u64)(-2))  /* "head", "live" revision */
+#define CEPH_MAXSNAP ((__u64)(-3))  /* largest valid snapid */
+
+struct ceph_timespec {
+       __le32 tv_sec;
+       __le32 tv_nsec;
+} __attribute__ ((packed));
+
+
+/*
+ * object layout - how objects are mapped into PGs
+ */
+#define CEPH_OBJECT_LAYOUT_HASH     1
+#define CEPH_OBJECT_LAYOUT_LINEAR   2
+#define CEPH_OBJECT_LAYOUT_HASHINO  3
+
+/*
+ * pg layout -- how PGs are mapped onto (sets of) OSDs
+ */
+#define CEPH_PG_LAYOUT_CRUSH  0
+#define CEPH_PG_LAYOUT_HASH   1
+#define CEPH_PG_LAYOUT_LINEAR 2
+#define CEPH_PG_LAYOUT_HYBRID 3
+
+
+/*
+ * placement group.
+ * we encode this into one __le64.
+ */
+struct ceph_pg {
+       __le16 preferred; /* preferred primary osd */
+       __le16 ps;        /* placement seed */
+       __le32 pool;      /* object pool */
+} __attribute__ ((packed));
+
+/*
+ * pg_pool is a set of pgs storing a pool of objects
+ *
+ *  pg_num -- base number of pseudorandomly placed pgs
+ *
+ *  pgp_num -- effective number when calculating pg placement.  this
+ * is used for pg_num increases.  new pgs result in data being "split"
+ * into new pgs.  for this to proceed smoothly, new pgs are intiially
+ * colocated with their parents; that is, pgp_num doesn't increase
+ * until the new pgs have successfully split.  only _then_ are the new
+ * pgs placed independently.
+ *
+ *  lpg_num -- localized pg count (per device).  replicas are randomly
+ * selected.
+ *
+ *  lpgp_num -- as above.
+ */
+#define CEPH_PG_TYPE_REP     1
+#define CEPH_PG_TYPE_RAID4   2
+#define CEPH_PG_POOL_VERSION 2
+struct ceph_pg_pool {
+       __u8 type;                /* CEPH_PG_TYPE_* */
+       __u8 size;                /* number of osds in each pg */
+       __u8 crush_ruleset;       /* crush placement rule */
+       __u8 object_hash;         /* hash mapping object name to ps */
+       __le32 pg_num, pgp_num;   /* number of pg's */
+       __le32 lpg_num, lpgp_num; /* number of localized pg's */
+       __le32 last_change;       /* most recent epoch changed */
+       __le64 snap_seq;          /* seq for per-pool snapshot */
+       __le32 snap_epoch;        /* epoch of last snap */
+       __le32 num_snaps;
+       __le32 num_removed_snap_intervals;
+       __le64 uid;
+} __attribute__ ((packed));
+
+/*
+ * stable_mod func is used to control number of placement groups.
+ * similar to straight-up modulo, but produces a stable mapping as b
+ * increases over time.  b is the number of bins, and bmask is the
+ * containing power of 2 minus 1.
+ *
+ * b <= bmask and bmask=(2**n)-1
+ * e.g., b=12 -> bmask=15, b=123 -> bmask=127
+ */
+static inline int ceph_stable_mod(int x, int b, int bmask)
+{
+       if ((x & bmask) < b)
+               return x & bmask;
+       else
+               return x & (bmask >> 1);
+}
+
+/*
+ * object layout - how a given object should be stored.
+ */
+struct ceph_object_layout {
+       struct ceph_pg ol_pgid;   /* raw pg, with _full_ ps precision. */
+       __le32 ol_stripe_unit;    /* for per-object parity, if any */
+} __attribute__ ((packed));
+
+/*
+ * compound epoch+version, used by storage layer to serialize mutations
+ */
+struct ceph_eversion {
+       __le32 epoch;
+       __le64 version;
+} __attribute__ ((packed));
+
+/*
+ * osd map bits
+ */
+
+/* status bits */
+#define CEPH_OSD_EXISTS 1
+#define CEPH_OSD_UP     2
+
+/* osd weights.  fixed point value: 0x10000 == 1.0 ("in"), 0 == "out" */
+#define CEPH_OSD_IN  0x10000
+#define CEPH_OSD_OUT 0
+
+
+/*
+ * osd map flag bits
+ */
+#define CEPH_OSDMAP_NEARFULL (1<<0)  /* sync writes (near ENOSPC) */
+#define CEPH_OSDMAP_FULL     (1<<1)  /* no data writes (ENOSPC) */
+#define CEPH_OSDMAP_PAUSERD  (1<<2)  /* pause all reads */
+#define CEPH_OSDMAP_PAUSEWR  (1<<3)  /* pause all writes */
+#define CEPH_OSDMAP_PAUSEREC (1<<4)  /* pause recovery */
+
+/*
+ * osd ops
+ */
+#define CEPH_OSD_OP_MODE       0xf000
+#define CEPH_OSD_OP_MODE_RD    0x1000
+#define CEPH_OSD_OP_MODE_WR    0x2000
+#define CEPH_OSD_OP_MODE_RMW   0x3000
+#define CEPH_OSD_OP_MODE_SUB   0x4000
+
+#define CEPH_OSD_OP_TYPE       0x0f00
+#define CEPH_OSD_OP_TYPE_LOCK  0x0100
+#define CEPH_OSD_OP_TYPE_DATA  0x0200
+#define CEPH_OSD_OP_TYPE_ATTR  0x0300
+#define CEPH_OSD_OP_TYPE_EXEC  0x0400
+#define CEPH_OSD_OP_TYPE_PG    0x0500
+
+enum {
+       /** data **/
+       /* read */
+       CEPH_OSD_OP_READ      = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 1,
+       CEPH_OSD_OP_STAT      = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 2,
+
+       /* fancy read */
+       CEPH_OSD_OP_MASKTRUNC = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 4,
+
+       /* write */
+       CEPH_OSD_OP_WRITE     = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 1,
+       CEPH_OSD_OP_WRITEFULL = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 2,
+       CEPH_OSD_OP_TRUNCATE  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 3,
+       CEPH_OSD_OP_ZERO      = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 4,
+       CEPH_OSD_OP_DELETE    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 5,
+
+       /* fancy write */
+       CEPH_OSD_OP_APPEND    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 6,
+       CEPH_OSD_OP_STARTSYNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 7,
+       CEPH_OSD_OP_SETTRUNC  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 8,
+       CEPH_OSD_OP_TRIMTRUNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 9,
+
+       CEPH_OSD_OP_TMAPUP  = CEPH_OSD_OP_MODE_RMW | CEPH_OSD_OP_TYPE_DATA | 10,
+       CEPH_OSD_OP_TMAPPUT = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 11,
+       CEPH_OSD_OP_TMAPGET = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_DATA | 12,
+
+       CEPH_OSD_OP_CREATE  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 13,
+
+       /** attrs **/
+       /* read */
+       CEPH_OSD_OP_GETXATTR  = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 1,
+       CEPH_OSD_OP_GETXATTRS = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_ATTR | 2,
+
+       /* write */
+       CEPH_OSD_OP_SETXATTR  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 1,
+       CEPH_OSD_OP_SETXATTRS = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 2,
+       CEPH_OSD_OP_RESETXATTRS = CEPH_OSD_OP_MODE_WR|CEPH_OSD_OP_TYPE_ATTR | 3,
+       CEPH_OSD_OP_RMXATTR   = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_ATTR | 4,
+
+       /** subop **/
+       CEPH_OSD_OP_PULL           = CEPH_OSD_OP_MODE_SUB | 1,
+       CEPH_OSD_OP_PUSH           = CEPH_OSD_OP_MODE_SUB | 2,
+       CEPH_OSD_OP_BALANCEREADS   = CEPH_OSD_OP_MODE_SUB | 3,
+       CEPH_OSD_OP_UNBALANCEREADS = CEPH_OSD_OP_MODE_SUB | 4,
+       CEPH_OSD_OP_SCRUB          = CEPH_OSD_OP_MODE_SUB | 5,
+
+       /** lock **/
+       CEPH_OSD_OP_WRLOCK    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 1,
+       CEPH_OSD_OP_WRUNLOCK  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 2,
+       CEPH_OSD_OP_RDLOCK    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 3,
+       CEPH_OSD_OP_RDUNLOCK  = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 4,
+       CEPH_OSD_OP_UPLOCK    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 5,
+       CEPH_OSD_OP_DNLOCK    = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_LOCK | 6,
+
+       /** exec **/
+       CEPH_OSD_OP_CALL    = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_EXEC | 1,
+
+       /** pg **/
+       CEPH_OSD_OP_PGLS      = CEPH_OSD_OP_MODE_RD | CEPH_OSD_OP_TYPE_PG | 1,
+};
+
+static inline int ceph_osd_op_type_lock(int op)
+{
+       return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_LOCK;
+}
+static inline int ceph_osd_op_type_data(int op)
+{
+       return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_DATA;
+}
+static inline int ceph_osd_op_type_attr(int op)
+{
+       return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_ATTR;
+}
+static inline int ceph_osd_op_type_exec(int op)
+{
+       return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_EXEC;
+}
+static inline int ceph_osd_op_type_pg(int op)
+{
+       return (op & CEPH_OSD_OP_TYPE) == CEPH_OSD_OP_TYPE_PG;
+}
+
+static inline int ceph_osd_op_mode_subop(int op)
+{
+       return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_SUB;
+}
+static inline int ceph_osd_op_mode_read(int op)
+{
+       return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_RD;
+}
+static inline int ceph_osd_op_mode_modify(int op)
+{
+       return (op & CEPH_OSD_OP_MODE) == CEPH_OSD_OP_MODE_WR;
+}
+
+#define CEPH_OSD_TMAP_HDR 'h'
+#define CEPH_OSD_TMAP_SET 's'
+#define CEPH_OSD_TMAP_RM  'r'
+
+extern const char *ceph_osd_op_name(int op);
+
+
+/*
+ * osd op flags
+ *
+ * An op may be READ, WRITE, or READ|WRITE.
+ */
+enum {
+       CEPH_OSD_FLAG_ACK = 1,          /* want (or is) "ack" ack */
+       CEPH_OSD_FLAG_ONNVRAM = 2,      /* want (or is) "onnvram" ack */
+       CEPH_OSD_FLAG_ONDISK = 4,       /* want (or is) "ondisk" ack */
+       CEPH_OSD_FLAG_RETRY = 8,        /* resend attempt */
+       CEPH_OSD_FLAG_READ = 16,        /* op may read */
+       CEPH_OSD_FLAG_WRITE = 32,       /* op may write */
+       CEPH_OSD_FLAG_ORDERSNAP = 64,   /* EOLDSNAP if snapc is out of order */
+       CEPH_OSD_FLAG_PEERSTAT = 128,   /* msg includes osd_peer_stat */
+       CEPH_OSD_FLAG_BALANCE_READS = 256,
+       CEPH_OSD_FLAG_PARALLELEXEC = 512, /* execute op in parallel */
+       CEPH_OSD_FLAG_PGOP = 1024,      /* pg op, no object */
+       CEPH_OSD_FLAG_EXEC = 2048,      /* op may exec */
+};
+
+enum {
+       CEPH_OSD_OP_FLAG_EXCL = 1,      /* EXCL object create */
+};
+
+#define EOLDSNAPC    ERESTART  /* ORDERSNAP flag set; writer has old snapc*/
+#define EBLACKLISTED ESHUTDOWN /* blacklisted */
+
+/*
+ * an individual object operation.  each may be accompanied by some data
+ * payload
+ */
+struct ceph_osd_op {
+       __le16 op;           /* CEPH_OSD_OP_* */
+       __le32 flags;        /* CEPH_OSD_FLAG_* */
+       union {
+               struct {
+                       __le64 offset, length;
+                       __le64 truncate_size;
+                       __le32 truncate_seq;
+               } __attribute__ ((packed)) extent;
+               struct {
+                       __le32 name_len;
+                       __le32 value_len;
+               } __attribute__ ((packed)) xattr;
+               struct {
+                       __u8 class_len;
+                       __u8 method_len;
+                       __u8 argc;
+                       __le32 indata_len;
+               } __attribute__ ((packed)) cls;
+               struct {
+                       __le64 cookie, count;
+               } __attribute__ ((packed)) pgls;
+       };
+       __le32 payload_len;
+} __attribute__ ((packed));
+
+/*
+ * osd request message header.  each request may include multiple
+ * ceph_osd_op object operations.
+ */
+struct ceph_osd_request_head {
+       __le32 client_inc;                 /* client incarnation */
+       struct ceph_object_layout layout;  /* pgid */
+       __le32 osdmap_epoch;               /* client's osdmap epoch */
+
+       __le32 flags;
+
+       struct ceph_timespec mtime;        /* for mutations only */
+       struct ceph_eversion reassert_version; /* if we are replaying op */
+
+       __le32 object_len;     /* length of object name */
+
+       __le64 snapid;         /* snapid to read */
+       __le64 snap_seq;       /* writer's snap context */
+       __le32 num_snaps;
+
+       __le16 num_ops;
+       struct ceph_osd_op ops[];  /* followed by ops[], obj, ticket, snaps */
+} __attribute__ ((packed));
+
+struct ceph_osd_reply_head {
+       __le32 client_inc;                /* client incarnation */
+       __le32 flags;
+       struct ceph_object_layout layout;
+       __le32 osdmap_epoch;
+       struct ceph_eversion reassert_version; /* for replaying uncommitted */
+
+       __le32 result;                    /* result code */
+
+       __le32 object_len;                /* length of object name */
+       __le32 num_ops;
+       struct ceph_osd_op ops[0];  /* ops[], object */
+} __attribute__ ((packed));
+
+
+#endif
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
new file mode 100644 (file)
index 0000000..e6f9bc5
--- /dev/null
@@ -0,0 +1,907 @@
+#include "ceph_debug.h"
+
+#include <linux/sort.h>
+#include <linux/slab.h>
+
+#include "super.h"
+#include "decode.h"
+
+/*
+ * Snapshots in ceph are driven in large part by cooperation from the
+ * client.  In contrast to local file systems or file servers that
+ * implement snapshots at a single point in the system, ceph's
+ * distributed access to storage requires clients to help decide
+ * whether a write logically occurs before or after a recently created
+ * snapshot.
+ *
+ * This provides a perfect instantanous client-wide snapshot.  Between
+ * clients, however, snapshots may appear to be applied at slightly
+ * different points in time, depending on delays in delivering the
+ * snapshot notification.
+ *
+ * Snapshots are _not_ file system-wide.  Instead, each snapshot
+ * applies to the subdirectory nested beneath some directory.  This
+ * effectively divides the hierarchy into multiple "realms," where all
+ * of the files contained by each realm share the same set of
+ * snapshots.  An individual realm's snap set contains snapshots
+ * explicitly created on that realm, as well as any snaps in its
+ * parent's snap set _after_ the point at which the parent became it's
+ * parent (due to, say, a rename).  Similarly, snaps from prior parents
+ * during the time intervals during which they were the parent are included.
+ *
+ * The client is spared most of this detail, fortunately... it must only
+ * maintains a hierarchy of realms reflecting the current parent/child
+ * realm relationship, and for each realm has an explicit list of snaps
+ * inherited from prior parents.
+ *
+ * A snap_realm struct is maintained for realms containing every inode
+ * with an open cap in the system.  (The needed snap realm information is
+ * provided by the MDS whenever a cap is issued, i.e., on open.)  A 'seq'
+ * version number is used to ensure that as realm parameters change (new
+ * snapshot, new parent, etc.) the client's realm hierarchy is updated.
+ *
+ * The realm hierarchy drives the generation of a 'snap context' for each
+ * realm, which simply lists the resulting set of snaps for the realm.  This
+ * is attached to any writes sent to OSDs.
+ */
+/*
+ * Unfortunately error handling is a bit mixed here.  If we get a snap
+ * update, but don't have enough memory to update our realm hierarchy,
+ * it's not clear what we can do about it (besides complaining to the
+ * console).
+ */
+
+
+/*
+ * increase ref count for the realm
+ *
+ * caller must hold snap_rwsem for write.
+ */
+void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
+                        struct ceph_snap_realm *realm)
+{
+       dout("get_realm %p %d -> %d\n", realm,
+            atomic_read(&realm->nref), atomic_read(&realm->nref)+1);
+       /*
+        * since we _only_ increment realm refs or empty the empty
+        * list with snap_rwsem held, adjusting the empty list here is
+        * safe.  we do need to protect against concurrent empty list
+        * additions, however.
+        */
+       if (atomic_read(&realm->nref) == 0) {
+               spin_lock(&mdsc->snap_empty_lock);
+               list_del_init(&realm->empty_item);
+               spin_unlock(&mdsc->snap_empty_lock);
+       }
+
+       atomic_inc(&realm->nref);
+}
+
+static void __insert_snap_realm(struct rb_root *root,
+                               struct ceph_snap_realm *new)
+{
+       struct rb_node **p = &root->rb_node;
+       struct rb_node *parent = NULL;
+       struct ceph_snap_realm *r = NULL;
+
+       while (*p) {
+               parent = *p;
+               r = rb_entry(parent, struct ceph_snap_realm, node);
+               if (new->ino < r->ino)
+                       p = &(*p)->rb_left;
+               else if (new->ino > r->ino)
+                       p = &(*p)->rb_right;
+               else
+                       BUG();
+       }
+
+       rb_link_node(&new->node, parent, p);
+       rb_insert_color(&new->node, root);
+}
+
+/*
+ * create and get the realm rooted at @ino and bump its ref count.
+ *
+ * caller must hold snap_rwsem for write.
+ */
+static struct ceph_snap_realm *ceph_create_snap_realm(
+       struct ceph_mds_client *mdsc,
+       u64 ino)
+{
+       struct ceph_snap_realm *realm;
+
+       realm = kzalloc(sizeof(*realm), GFP_NOFS);
+       if (!realm)
+               return ERR_PTR(-ENOMEM);
+
+       atomic_set(&realm->nref, 0);    /* tree does not take a ref */
+       realm->ino = ino;
+       INIT_LIST_HEAD(&realm->children);
+       INIT_LIST_HEAD(&realm->child_item);
+       INIT_LIST_HEAD(&realm->empty_item);
+       INIT_LIST_HEAD(&realm->inodes_with_caps);
+       spin_lock_init(&realm->inodes_with_caps_lock);
+       __insert_snap_realm(&mdsc->snap_realms, realm);
+       dout("create_snap_realm %llx %p\n", realm->ino, realm);
+       return realm;
+}
+
+/*
+ * lookup the realm rooted at @ino.
+ *
+ * caller must hold snap_rwsem for write.
+ */
+struct ceph_snap_realm *ceph_lookup_snap_realm(struct ceph_mds_client *mdsc,
+                                              u64 ino)
+{
+       struct rb_node *n = mdsc->snap_realms.rb_node;
+       struct ceph_snap_realm *r;
+
+       while (n) {
+               r = rb_entry(n, struct ceph_snap_realm, node);
+               if (ino < r->ino)
+                       n = n->rb_left;
+               else if (ino > r->ino)
+                       n = n->rb_right;
+               else {
+                       dout("lookup_snap_realm %llx %p\n", r->ino, r);
+                       return r;
+               }
+       }
+       return NULL;
+}
+
+static void __put_snap_realm(struct ceph_mds_client *mdsc,
+                            struct ceph_snap_realm *realm);
+
+/*
+ * called with snap_rwsem (write)
+ */
+static void __destroy_snap_realm(struct ceph_mds_client *mdsc,
+                                struct ceph_snap_realm *realm)
+{
+       dout("__destroy_snap_realm %p %llx\n", realm, realm->ino);
+
+       rb_erase(&realm->node, &mdsc->snap_realms);
+
+       if (realm->parent) {
+               list_del_init(&realm->child_item);
+               __put_snap_realm(mdsc, realm->parent);
+       }
+
+       kfree(realm->prior_parent_snaps);
+       kfree(realm->snaps);
+       ceph_put_snap_context(realm->cached_context);
+       kfree(realm);
+}
+
+/*
+ * caller holds snap_rwsem (write)
+ */
+static void __put_snap_realm(struct ceph_mds_client *mdsc,
+                            struct ceph_snap_realm *realm)
+{
+       dout("__put_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
+            atomic_read(&realm->nref), atomic_read(&realm->nref)-1);
+       if (atomic_dec_and_test(&realm->nref))
+               __destroy_snap_realm(mdsc, realm);
+}
+
+/*
+ * caller needn't hold any locks
+ */
+void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
+                        struct ceph_snap_realm *realm)
+{
+       dout("put_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
+            atomic_read(&realm->nref), atomic_read(&realm->nref)-1);
+       if (!atomic_dec_and_test(&realm->nref))
+               return;
+
+       if (down_write_trylock(&mdsc->snap_rwsem)) {
+               __destroy_snap_realm(mdsc, realm);
+               up_write(&mdsc->snap_rwsem);
+       } else {
+               spin_lock(&mdsc->snap_empty_lock);
+               list_add(&mdsc->snap_empty, &realm->empty_item);
+               spin_unlock(&mdsc->snap_empty_lock);
+       }
+}
+
+/*
+ * Clean up any realms whose ref counts have dropped to zero.  Note
+ * that this does not include realms who were created but not yet
+ * used.
+ *
+ * Called under snap_rwsem (write)
+ */
+static void __cleanup_empty_realms(struct ceph_mds_client *mdsc)
+{
+       struct ceph_snap_realm *realm;
+
+       spin_lock(&mdsc->snap_empty_lock);
+       while (!list_empty(&mdsc->snap_empty)) {
+               realm = list_first_entry(&mdsc->snap_empty,
+                                  struct ceph_snap_realm, empty_item);
+               list_del(&realm->empty_item);
+               spin_unlock(&mdsc->snap_empty_lock);
+               __destroy_snap_realm(mdsc, realm);
+               spin_lock(&mdsc->snap_empty_lock);
+       }
+       spin_unlock(&mdsc->snap_empty_lock);
+}
+
+void ceph_cleanup_empty_realms(struct ceph_mds_client *mdsc)
+{
+       down_write(&mdsc->snap_rwsem);
+       __cleanup_empty_realms(mdsc);
+       up_write(&mdsc->snap_rwsem);
+}
+
+/*
+ * adjust the parent realm of a given @realm.  adjust child list, and parent
+ * pointers, and ref counts appropriately.
+ *
+ * return true if parent was changed, 0 if unchanged, <0 on error.
+ *
+ * caller must hold snap_rwsem for write.
+ */
+static int adjust_snap_realm_parent(struct ceph_mds_client *mdsc,
+                                   struct ceph_snap_realm *realm,
+                                   u64 parentino)
+{
+       struct ceph_snap_realm *parent;
+
+       if (realm->parent_ino == parentino)
+               return 0;
+
+       parent = ceph_lookup_snap_realm(mdsc, parentino);
+       if (!parent) {
+               parent = ceph_create_snap_realm(mdsc, parentino);
+               if (IS_ERR(parent))
+                       return PTR_ERR(parent);
+       }
+       dout("adjust_snap_realm_parent %llx %p: %llx %p -> %llx %p\n",
+            realm->ino, realm, realm->parent_ino, realm->parent,
+            parentino, parent);
+       if (realm->parent) {
+               list_del_init(&realm->child_item);
+               ceph_put_snap_realm(mdsc, realm->parent);
+       }
+       realm->parent_ino = parentino;
+       realm->parent = parent;
+       ceph_get_snap_realm(mdsc, parent);
+       list_add(&realm->child_item, &parent->children);
+       return 1;
+}
+
+
+static int cmpu64_rev(const void *a, const void *b)
+{
+       if (*(u64 *)a < *(u64 *)b)
+               return 1;
+       if (*(u64 *)a > *(u64 *)b)
+               return -1;
+       return 0;
+}
+
+/*
+ * build the snap context for a given realm.
+ */
+static int build_snap_context(struct ceph_snap_realm *realm)
+{
+       struct ceph_snap_realm *parent = realm->parent;
+       struct ceph_snap_context *snapc;
+       int err = 0;
+       int i;
+       int num = realm->num_prior_parent_snaps + realm->num_snaps;
+
+       /*
+        * build parent context, if it hasn't been built.
+        * conservatively estimate that all parent snaps might be
+        * included by us.
+        */
+       if (parent) {
+               if (!parent->cached_context) {
+                       err = build_snap_context(parent);
+                       if (err)
+                               goto fail;
+               }
+               num += parent->cached_context->num_snaps;
+       }
+
+       /* do i actually need to update?  not if my context seq
+          matches realm seq, and my parents' does to.  (this works
+          because we rebuild_snap_realms() works _downward_ in
+          hierarchy after each update.) */
+       if (realm->cached_context &&
+           realm->cached_context->seq == realm->seq &&
+           (!parent ||
+            realm->cached_context->seq >= parent->cached_context->seq)) {
+               dout("build_snap_context %llx %p: %p seq %lld (%d snaps)"
+                    " (unchanged)\n",
+                    realm->ino, realm, realm->cached_context,
+                    realm->cached_context->seq,
+                    realm->cached_context->num_snaps);
+               return 0;
+       }
+
+       /* alloc new snap context */
+       err = -ENOMEM;
+       if (num > ULONG_MAX / sizeof(u64) - sizeof(*snapc))
+               goto fail;
+       snapc = kzalloc(sizeof(*snapc) + num*sizeof(u64), GFP_NOFS);
+       if (!snapc)
+               goto fail;
+       atomic_set(&snapc->nref, 1);
+
+       /* build (reverse sorted) snap vector */
+       num = 0;
+       snapc->seq = realm->seq;
+       if (parent) {
+               /* include any of parent's snaps occuring _after_ my
+                  parent became my parent */
+               for (i = 0; i < parent->cached_context->num_snaps; i++)
+                       if (parent->cached_context->snaps[i] >=
+                           realm->parent_since)
+                               snapc->snaps[num++] =
+                                       parent->cached_context->snaps[i];
+               if (parent->cached_context->seq > snapc->seq)
+                       snapc->seq = parent->cached_context->seq;
+       }
+       memcpy(snapc->snaps + num, realm->snaps,
+              sizeof(u64)*realm->num_snaps);
+       num += realm->num_snaps;
+       memcpy(snapc->snaps + num, realm->prior_parent_snaps,
+              sizeof(u64)*realm->num_prior_parent_snaps);
+       num += realm->num_prior_parent_snaps;
+
+       sort(snapc->snaps, num, sizeof(u64), cmpu64_rev, NULL);
+       snapc->num_snaps = num;
+       dout("build_snap_context %llx %p: %p seq %lld (%d snaps)\n",
+            realm->ino, realm, snapc, snapc->seq, snapc->num_snaps);
+
+       if (realm->cached_context)
+               ceph_put_snap_context(realm->cached_context);
+       realm->cached_context = snapc;
+       return 0;
+
+fail:
+       /*
+        * if we fail, clear old (incorrect) cached_context... hopefully
+        * we'll have better luck building it later
+        */
+       if (realm->cached_context) {
+               ceph_put_snap_context(realm->cached_context);
+               realm->cached_context = NULL;
+       }
+       pr_err("build_snap_context %llx %p fail %d\n", realm->ino,
+              realm, err);
+       return err;
+}
+
+/*
+ * rebuild snap context for the given realm and all of its children.
+ */
+static void rebuild_snap_realms(struct ceph_snap_realm *realm)
+{
+       struct ceph_snap_realm *child;
+
+       dout("rebuild_snap_realms %llx %p\n", realm->ino, realm);
+       build_snap_context(realm);
+
+       list_for_each_entry(child, &realm->children, child_item)
+               rebuild_snap_realms(child);
+}
+
+
+/*
+ * helper to allocate and decode an array of snapids.  free prior
+ * instance, if any.
+ */
+static int dup_array(u64 **dst, __le64 *src, int num)
+{
+       int i;
+
+       kfree(*dst);
+       if (num) {
+               *dst = kcalloc(num, sizeof(u64), GFP_NOFS);
+               if (!*dst)
+                       return -ENOMEM;
+               for (i = 0; i < num; i++)
+                       (*dst)[i] = get_unaligned_le64(src + i);
+       } else {
+               *dst = NULL;
+       }
+       return 0;
+}
+
+
+/*
+ * When a snapshot is applied, the size/mtime inode metadata is queued
+ * in a ceph_cap_snap (one for each snapshot) until writeback
+ * completes and the metadata can be flushed back to the MDS.
+ *
+ * However, if a (sync) write is currently in-progress when we apply
+ * the snapshot, we have to wait until the write succeeds or fails
+ * (and a final size/mtime is known).  In this case the
+ * cap_snap->writing = 1, and is said to be "pending."  When the write
+ * finishes, we __ceph_finish_cap_snap().
+ *
+ * Caller must hold snap_rwsem for read (i.e., the realm topology won't
+ * change).
+ */
+void ceph_queue_cap_snap(struct ceph_inode_info *ci,
+                        struct ceph_snap_context *snapc)
+{
+       struct inode *inode = &ci->vfs_inode;
+       struct ceph_cap_snap *capsnap;
+       int used;
+
+       capsnap = kzalloc(sizeof(*capsnap), GFP_NOFS);
+       if (!capsnap) {
+               pr_err("ENOMEM allocating ceph_cap_snap on %p\n", inode);
+               return;
+       }
+
+       spin_lock(&inode->i_lock);
+       used = __ceph_caps_used(ci);
+       if (__ceph_have_pending_cap_snap(ci)) {
+               /* there is no point in queuing multiple "pending" cap_snaps,
+                  as no new writes are allowed to start when pending, so any
+                  writes in progress now were started before the previous
+                  cap_snap.  lucky us. */
+               dout("queue_cap_snap %p snapc %p seq %llu used %d"
+                    " already pending\n", inode, snapc, snapc->seq, used);
+               kfree(capsnap);
+       } else if (ci->i_wrbuffer_ref_head || (used & CEPH_CAP_FILE_WR)) {
+               igrab(inode);
+
+               atomic_set(&capsnap->nref, 1);
+               capsnap->ci = ci;
+               INIT_LIST_HEAD(&capsnap->ci_item);
+               INIT_LIST_HEAD(&capsnap->flushing_item);
+
+               capsnap->follows = snapc->seq - 1;
+               capsnap->context = ceph_get_snap_context(snapc);
+               capsnap->issued = __ceph_caps_issued(ci, NULL);
+               capsnap->dirty = __ceph_caps_dirty(ci);
+
+               capsnap->mode = inode->i_mode;
+               capsnap->uid = inode->i_uid;
+               capsnap->gid = inode->i_gid;
+
+               /* fixme? */
+               capsnap->xattr_blob = NULL;
+               capsnap->xattr_len = 0;
+
+               /* dirty page count moved from _head to this cap_snap;
+                  all subsequent writes page dirties occur _after_ this
+                  snapshot. */
+               capsnap->dirty_pages = ci->i_wrbuffer_ref_head;
+               ci->i_wrbuffer_ref_head = 0;
+               ceph_put_snap_context(ci->i_head_snapc);
+               ci->i_head_snapc = NULL;
+               list_add_tail(&capsnap->ci_item, &ci->i_cap_snaps);
+
+               if (used & CEPH_CAP_FILE_WR) {
+                       dout("queue_cap_snap %p cap_snap %p snapc %p"
+                            " seq %llu used WR, now pending\n", inode,
+                            capsnap, snapc, snapc->seq);
+                       capsnap->writing = 1;
+               } else {
+                       /* note mtime, size NOW. */
+                       __ceph_finish_cap_snap(ci, capsnap);
+               }
+       } else {
+               dout("queue_cap_snap %p nothing dirty|writing\n", inode);
+               kfree(capsnap);
+       }
+
+       spin_unlock(&inode->i_lock);
+}
+
+/*
+ * Finalize the size, mtime for a cap_snap.. that is, settle on final values
+ * to be used for the snapshot, to be flushed back to the mds.
+ *
+ * If capsnap can now be flushed, add to snap_flush list, and return 1.
+ *
+ * Caller must hold i_lock.
+ */
+int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
+                           struct ceph_cap_snap *capsnap)
+{
+       struct inode *inode = &ci->vfs_inode;
+       struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc;
+
+       BUG_ON(capsnap->writing);
+       capsnap->size = inode->i_size;
+       capsnap->mtime = inode->i_mtime;
+       capsnap->atime = inode->i_atime;
+       capsnap->ctime = inode->i_ctime;
+       capsnap->time_warp_seq = ci->i_time_warp_seq;
+       if (capsnap->dirty_pages) {
+               dout("finish_cap_snap %p cap_snap %p snapc %p %llu s=%llu "
+                    "still has %d dirty pages\n", inode, capsnap,
+                    capsnap->context, capsnap->context->seq,
+                    capsnap->size, capsnap->dirty_pages);
+               return 0;
+       }
+       dout("finish_cap_snap %p cap_snap %p snapc %p %llu s=%llu clean\n",
+            inode, capsnap, capsnap->context,
+            capsnap->context->seq, capsnap->size);
+
+       spin_lock(&mdsc->snap_flush_lock);
+       list_add_tail(&ci->i_snap_flush_item, &mdsc->snap_flush_list);
+       spin_unlock(&mdsc->snap_flush_lock);
+       return 1;  /* caller may want to ceph_flush_snaps */
+}
+
+
+/*
+ * Parse and apply a snapblob "snap trace" from the MDS.  This specifies
+ * the snap realm parameters from a given realm and all of its ancestors,
+ * up to the root.
+ *
+ * Caller must hold snap_rwsem for write.
+ */
+int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
+                          void *p, void *e, bool deletion)
+{
+       struct ceph_mds_snap_realm *ri;    /* encoded */
+       __le64 *snaps;                     /* encoded */
+       __le64 *prior_parent_snaps;        /* encoded */
+       struct ceph_snap_realm *realm;
+       int invalidate = 0;
+       int err = -ENOMEM;
+
+       dout("update_snap_trace deletion=%d\n", deletion);
+more:
+       ceph_decode_need(&p, e, sizeof(*ri), bad);
+       ri = p;
+       p += sizeof(*ri);
+       ceph_decode_need(&p, e, sizeof(u64)*(le32_to_cpu(ri->num_snaps) +
+                           le32_to_cpu(ri->num_prior_parent_snaps)), bad);
+       snaps = p;
+       p += sizeof(u64) * le32_to_cpu(ri->num_snaps);
+       prior_parent_snaps = p;
+       p += sizeof(u64) * le32_to_cpu(ri->num_prior_parent_snaps);
+
+       realm = ceph_lookup_snap_realm(mdsc, le64_to_cpu(ri->ino));
+       if (!realm) {
+               realm = ceph_create_snap_realm(mdsc, le64_to_cpu(ri->ino));
+               if (IS_ERR(realm)) {
+                       err = PTR_ERR(realm);
+                       goto fail;
+               }
+       }
+
+       if (le64_to_cpu(ri->seq) > realm->seq) {
+               dout("update_snap_trace updating %llx %p %lld -> %lld\n",
+                    realm->ino, realm, realm->seq, le64_to_cpu(ri->seq));
+               /*
+                * if the realm seq has changed, queue a cap_snap for every
+                * inode with open caps.  we do this _before_ we update
+                * the realm info so that we prepare for writeback under the
+                * _previous_ snap context.
+                *
+                * ...unless it's a snap deletion!
+                */
+               if (!deletion) {
+                       struct ceph_inode_info *ci;
+                       struct inode *lastinode = NULL;
+
+                       spin_lock(&realm->inodes_with_caps_lock);
+                       list_for_each_entry(ci, &realm->inodes_with_caps,
+                                           i_snap_realm_item) {
+                               struct inode *inode = igrab(&ci->vfs_inode);
+                               if (!inode)
+                                       continue;
+                               spin_unlock(&realm->inodes_with_caps_lock);
+                               if (lastinode)
+                                       iput(lastinode);
+                               lastinode = inode;
+                               ceph_queue_cap_snap(ci, realm->cached_context);
+                               spin_lock(&realm->inodes_with_caps_lock);
+                       }
+                       spin_unlock(&realm->inodes_with_caps_lock);
+                       if (lastinode)
+                               iput(lastinode);
+                       dout("update_snap_trace cap_snaps queued\n");
+               }
+
+       } else {
+               dout("update_snap_trace %llx %p seq %lld unchanged\n",
+                    realm->ino, realm, realm->seq);
+       }
+
+       /* ensure the parent is correct */
+       err = adjust_snap_realm_parent(mdsc, realm, le64_to_cpu(ri->parent));
+       if (err < 0)
+               goto fail;
+       invalidate += err;
+
+       if (le64_to_cpu(ri->seq) > realm->seq) {
+               /* update realm parameters, snap lists */
+               realm->seq = le64_to_cpu(ri->seq);
+               realm->created = le64_to_cpu(ri->created);
+               realm->parent_since = le64_to_cpu(ri->parent_since);
+
+               realm->num_snaps = le32_to_cpu(ri->num_snaps);
+               err = dup_array(&realm->snaps, snaps, realm->num_snaps);
+               if (err < 0)
+                       goto fail;
+
+               realm->num_prior_parent_snaps =
+                       le32_to_cpu(ri->num_prior_parent_snaps);
+               err = dup_array(&realm->prior_parent_snaps, prior_parent_snaps,
+                               realm->num_prior_parent_snaps);
+               if (err < 0)
+                       goto fail;
+
+               invalidate = 1;
+       } else if (!realm->cached_context) {
+               invalidate = 1;
+       }
+
+       dout("done with %llx %p, invalidated=%d, %p %p\n", realm->ino,
+            realm, invalidate, p, e);
+
+       if (p < e)
+               goto more;
+
+       /* invalidate when we reach the _end_ (root) of the trace */
+       if (invalidate)
+               rebuild_snap_realms(realm);
+
+       __cleanup_empty_realms(mdsc);
+       return 0;
+
+bad:
+       err = -EINVAL;
+fail:
+       pr_err("update_snap_trace error %d\n", err);
+       return err;
+}
+
+
+/*
+ * Send any cap_snaps that are queued for flush.  Try to carry
+ * s_mutex across multiple snap flushes to avoid locking overhead.
+ *
+ * Caller holds no locks.
+ */
+static void flush_snaps(struct ceph_mds_client *mdsc)
+{
+       struct ceph_inode_info *ci;
+       struct inode *inode;
+       struct ceph_mds_session *session = NULL;
+
+       dout("flush_snaps\n");
+       spin_lock(&mdsc->snap_flush_lock);
+       while (!list_empty(&mdsc->snap_flush_list)) {
+               ci = list_first_entry(&mdsc->snap_flush_list,
+                               struct ceph_inode_info, i_snap_flush_item);
+               inode = &ci->vfs_inode;
+               igrab(inode);
+               spin_unlock(&mdsc->snap_flush_lock);
+               spin_lock(&inode->i_lock);
+               __ceph_flush_snaps(ci, &session);
+               spin_unlock(&inode->i_lock);
+               iput(inode);
+               spin_lock(&mdsc->snap_flush_lock);
+       }
+       spin_unlock(&mdsc->snap_flush_lock);
+
+       if (session) {
+               mutex_unlock(&session->s_mutex);
+               ceph_put_mds_session(session);
+       }
+       dout("flush_snaps done\n");
+}
+
+
+/*
+ * Handle a snap notification from the MDS.
+ *
+ * This can take two basic forms: the simplest is just a snap creation
+ * or deletion notification on an existing realm.  This should update the
+ * realm and its children.
+ *
+ * The more difficult case is realm creation, due to snap creation at a
+ * new point in the file hierarchy, or due to a rename that moves a file or
+ * directory into another realm.
+ */
+void ceph_handle_snap(struct ceph_mds_client *mdsc,
+                     struct ceph_mds_session *session,
+                     struct ceph_msg *msg)
+{
+       struct super_block *sb = mdsc->client->sb;
+       int mds = session->s_mds;
+       u64 split;
+       int op;
+       int trace_len;
+       struct ceph_snap_realm *realm = NULL;
+       void *p = msg->front.iov_base;
+       void *e = p + msg->front.iov_len;
+       struct ceph_mds_snap_head *h;
+       int num_split_inos, num_split_realms;
+       __le64 *split_inos = NULL, *split_realms = NULL;
+       int i;
+       int locked_rwsem = 0;
+
+       /* decode */
+       if (msg->front.iov_len < sizeof(*h))
+               goto bad;
+       h = p;
+       op = le32_to_cpu(h->op);
+       split = le64_to_cpu(h->split);   /* non-zero if we are splitting an
+                                         * existing realm */
+       num_split_inos = le32_to_cpu(h->num_split_inos);
+       num_split_realms = le32_to_cpu(h->num_split_realms);
+       trace_len = le32_to_cpu(h->trace_len);
+       p += sizeof(*h);
+
+       dout("handle_snap from mds%d op %s split %llx tracelen %d\n", mds,
+            ceph_snap_op_name(op), split, trace_len);
+
+       mutex_lock(&session->s_mutex);
+       session->s_seq++;
+       mutex_unlock(&session->s_mutex);
+
+       down_write(&mdsc->snap_rwsem);
+       locked_rwsem = 1;
+
+       if (op == CEPH_SNAP_OP_SPLIT) {
+               struct ceph_mds_snap_realm *ri;
+
+               /*
+                * A "split" breaks part of an existing realm off into
+                * a new realm.  The MDS provides a list of inodes
+                * (with caps) and child realms that belong to the new
+                * child.
+                */
+               split_inos = p;
+               p += sizeof(u64) * num_split_inos;
+               split_realms = p;
+               p += sizeof(u64) * num_split_realms;
+               ceph_decode_need(&p, e, sizeof(*ri), bad);
+               /* we will peek at realm info here, but will _not_
+                * advance p, as the realm update will occur below in
+                * ceph_update_snap_trace. */
+               ri = p;
+
+               realm = ceph_lookup_snap_realm(mdsc, split);
+               if (!realm) {
+                       realm = ceph_create_snap_realm(mdsc, split);
+                       if (IS_ERR(realm))
+                               goto out;
+               }
+               ceph_get_snap_realm(mdsc, realm);
+
+               dout("splitting snap_realm %llx %p\n", realm->ino, realm);
+               for (i = 0; i < num_split_inos; i++) {
+                       struct ceph_vino vino = {
+                               .ino = le64_to_cpu(split_inos[i]),
+                               .snap = CEPH_NOSNAP,
+                       };
+                       struct inode *inode = ceph_find_inode(sb, vino);
+                       struct ceph_inode_info *ci;
+
+                       if (!inode)
+                               continue;
+                       ci = ceph_inode(inode);
+
+                       spin_lock(&inode->i_lock);
+                       if (!ci->i_snap_realm)
+                               goto skip_inode;
+                       /*
+                        * If this inode belongs to a realm that was
+                        * created after our new realm, we experienced
+                        * a race (due to another split notifications
+                        * arriving from a different MDS).  So skip
+                        * this inode.
+                        */
+                       if (ci->i_snap_realm->created >
+                           le64_to_cpu(ri->created)) {
+                               dout(" leaving %p in newer realm %llx %p\n",
+                                    inode, ci->i_snap_realm->ino,
+                                    ci->i_snap_realm);
+                               goto skip_inode;
+                       }
+                       dout(" will move %p to split realm %llx %p\n",
+                            inode, realm->ino, realm);
+                       /*
+                        * Remove the inode from the realm's inode
+                        * list, but don't add it to the new realm
+                        * yet.  We don't want the cap_snap to be
+                        * queued (again) by ceph_update_snap_trace()
+                        * below.  Queue it _now_, under the old context.
+                        */
+                       spin_lock(&realm->inodes_with_caps_lock);
+                       list_del_init(&ci->i_snap_realm_item);
+                       spin_unlock(&realm->inodes_with_caps_lock);
+                       spin_unlock(&inode->i_lock);
+
+                       ceph_queue_cap_snap(ci,
+                                           ci->i_snap_realm->cached_context);
+
+                       iput(inode);
+                       continue;
+
+skip_inode:
+                       spin_unlock(&inode->i_lock);
+                       iput(inode);
+               }
+
+               /* we may have taken some of the old realm's children. */
+               for (i = 0; i < num_split_realms; i++) {
+                       struct ceph_snap_realm *child =
+                               ceph_lookup_snap_realm(mdsc,
+                                          le64_to_cpu(split_realms[i]));
+                       if (!child)
+                               continue;
+                       adjust_snap_realm_parent(mdsc, child, realm->ino);
+               }
+       }
+
+       /*
+        * update using the provided snap trace. if we are deleting a
+        * snap, we can avoid queueing cap_snaps.
+        */
+       ceph_update_snap_trace(mdsc, p, e,
+                              op == CEPH_SNAP_OP_DESTROY);
+
+       if (op == CEPH_SNAP_OP_SPLIT) {
+               /*
+                * ok, _now_ add the inodes into the new realm.
+                */
+               for (i = 0; i < num_split_inos; i++) {
+                       struct ceph_vino vino = {
+                               .ino = le64_to_cpu(split_inos[i]),
+                               .snap = CEPH_NOSNAP,
+                       };
+                       struct inode *inode = ceph_find_inode(sb, vino);
+                       struct ceph_inode_info *ci;
+
+                       if (!inode)
+                               continue;
+                       ci = ceph_inode(inode);
+                       spin_lock(&inode->i_lock);
+                       if (!ci->i_snap_realm)
+                               goto split_skip_inode;
+                       ceph_put_snap_realm(mdsc, ci->i_snap_realm);
+                       spin_lock(&realm->inodes_with_caps_lock);
+                       list_add(&ci->i_snap_realm_item,
+                                &realm->inodes_with_caps);
+                       ci->i_snap_realm = realm;
+                       spin_unlock(&realm->inodes_with_caps_lock);
+                       ceph_get_snap_realm(mdsc, realm);
+split_skip_inode:
+                       spin_unlock(&inode->i_lock);
+                       iput(inode);
+               }
+
+               /* we took a reference when we created the realm, above */
+               ceph_put_snap_realm(mdsc, realm);
+       }
+
+       __cleanup_empty_realms(mdsc);
+
+       up_write(&mdsc->snap_rwsem);
+
+       flush_snaps(mdsc);
+       return;
+
+bad:
+       pr_err("corrupt snap message from mds%d\n", mds);
+       ceph_msg_dump(msg);
+out:
+       if (locked_rwsem)
+               up_write(&mdsc->snap_rwsem);
+       return;
+}
+
+
+
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
new file mode 100644 (file)
index 0000000..75d02ea
--- /dev/null
@@ -0,0 +1,1031 @@
+
+#include "ceph_debug.h"
+
+#include <linux/backing-dev.h>
+#include <linux/fs.h>
+#include <linux/inet.h>
+#include <linux/in6.h>
+#include <linux/module.h>
+#include <linux/mount.h>
+#include <linux/parser.h>
+#include <linux/rwsem.h>
+#include <linux/sched.h>
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+#include <linux/statfs.h>
+#include <linux/string.h>
+#include <linux/version.h>
+#include <linux/vmalloc.h>
+
+#include "decode.h"
+#include "super.h"
+#include "mon_client.h"
+#include "auth.h"
+
+/*
+ * Ceph superblock operations
+ *
+ * Handle the basics of mounting, unmounting.
+ */
+
+
+/*
+ * find filename portion of a path (/foo/bar/baz -> baz)
+ */
+const char *ceph_file_part(const char *s, int len)
+{
+       const char *e = s + len;
+
+       while (e != s && *(e-1) != '/')
+               e--;
+       return e;
+}
+
+
+/*
+ * super ops
+ */
+static void ceph_put_super(struct super_block *s)
+{
+       struct ceph_client *cl = ceph_client(s);
+
+       dout("put_super\n");
+       ceph_mdsc_close_sessions(&cl->mdsc);
+       return;
+}
+
+static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
+{
+       struct ceph_client *client = ceph_inode_to_client(dentry->d_inode);
+       struct ceph_monmap *monmap = client->monc.monmap;
+       struct ceph_statfs st;
+       u64 fsid;
+       int err;
+
+       dout("statfs\n");
+       err = ceph_monc_do_statfs(&client->monc, &st);
+       if (err < 0)
+               return err;
+
+       /* fill in kstatfs */
+       buf->f_type = CEPH_SUPER_MAGIC;  /* ?? */
+
+       /*
+        * express utilization in terms of large blocks to avoid
+        * overflow on 32-bit machines.
+        */
+       buf->f_bsize = 1 << CEPH_BLOCK_SHIFT;
+       buf->f_blocks = le64_to_cpu(st.kb) >> (CEPH_BLOCK_SHIFT-10);
+       buf->f_bfree = (le64_to_cpu(st.kb) - le64_to_cpu(st.kb_used)) >>
+               (CEPH_BLOCK_SHIFT-10);
+       buf->f_bavail = le64_to_cpu(st.kb_avail) >> (CEPH_BLOCK_SHIFT-10);
+
+       buf->f_files = le64_to_cpu(st.num_objects);
+       buf->f_ffree = -1;
+       buf->f_namelen = PATH_MAX;
+       buf->f_frsize = PAGE_CACHE_SIZE;
+
+       /* leave fsid little-endian, regardless of host endianness */
+       fsid = *(u64 *)(&monmap->fsid) ^ *((u64 *)&monmap->fsid + 1);
+       buf->f_fsid.val[0] = fsid & 0xffffffff;
+       buf->f_fsid.val[1] = fsid >> 32;
+
+       return 0;
+}
+
+
+static int ceph_syncfs(struct super_block *sb, int wait)
+{
+       dout("sync_fs %d\n", wait);
+       ceph_osdc_sync(&ceph_client(sb)->osdc);
+       ceph_mdsc_sync(&ceph_client(sb)->mdsc);
+       dout("sync_fs %d done\n", wait);
+       return 0;
+}
+
+
+/**
+ * ceph_show_options - Show mount options in /proc/mounts
+ * @m: seq_file to write to
+ * @mnt: mount descriptor
+ */
+static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
+{
+       struct ceph_client *client = ceph_sb_to_client(mnt->mnt_sb);
+       struct ceph_mount_args *args = client->mount_args;
+
+       if (args->flags & CEPH_OPT_FSID)
+               seq_printf(m, ",fsidmajor=%llu,fsidminor%llu",
+                          le64_to_cpu(*(__le64 *)&args->fsid.fsid[0]),
+                          le64_to_cpu(*(__le64 *)&args->fsid.fsid[8]));
+       if (args->flags & CEPH_OPT_NOSHARE)
+               seq_puts(m, ",noshare");
+       if (args->flags & CEPH_OPT_DIRSTAT)
+               seq_puts(m, ",dirstat");
+       if ((args->flags & CEPH_OPT_RBYTES) == 0)
+               seq_puts(m, ",norbytes");
+       if (args->flags & CEPH_OPT_NOCRC)
+               seq_puts(m, ",nocrc");
+       if (args->flags & CEPH_OPT_NOASYNCREADDIR)
+               seq_puts(m, ",noasyncreaddir");
+       if (strcmp(args->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT))
+               seq_printf(m, ",snapdirname=%s", args->snapdir_name);
+       if (args->name)
+               seq_printf(m, ",name=%s", args->name);
+       if (args->secret)
+               seq_puts(m, ",secret=<hidden>");
+       return 0;
+}
+
+/*
+ * caches
+ */
+struct kmem_cache *ceph_inode_cachep;
+struct kmem_cache *ceph_cap_cachep;
+struct kmem_cache *ceph_dentry_cachep;
+struct kmem_cache *ceph_file_cachep;
+
+static void ceph_inode_init_once(void *foo)
+{
+       struct ceph_inode_info *ci = foo;
+       inode_init_once(&ci->vfs_inode);
+}
+
+static int default_congestion_kb(void)
+{
+       int congestion_kb;
+
+       /*
+        * Copied from NFS
+        *
+        * congestion size, scale with available memory.
+        *
+        *  64MB:    8192k
+        * 128MB:   11585k
+        * 256MB:   16384k
+        * 512MB:   23170k
+        *   1GB:   32768k
+        *   2GB:   46340k
+        *   4GB:   65536k
+        *   8GB:   92681k
+        *  16GB:  131072k
+        *
+        * This allows larger machines to have larger/more transfers.
+        * Limit the default to 256M
+        */
+       congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
+       if (congestion_kb > 256*1024)
+               congestion_kb = 256*1024;
+
+       return congestion_kb;
+}
+
+static int __init init_caches(void)
+{
+       ceph_inode_cachep = kmem_cache_create("ceph_inode_info",
+                                     sizeof(struct ceph_inode_info),
+                                     __alignof__(struct ceph_inode_info),
+                                     (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD),
+                                     ceph_inode_init_once);
+       if (ceph_inode_cachep == NULL)
+               return -ENOMEM;
+
+       ceph_cap_cachep = KMEM_CACHE(ceph_cap,
+                                    SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
+       if (ceph_cap_cachep == NULL)
+               goto bad_cap;
+
+       ceph_dentry_cachep = KMEM_CACHE(ceph_dentry_info,
+                                       SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
+       if (ceph_dentry_cachep == NULL)
+               goto bad_dentry;
+
+       ceph_file_cachep = KMEM_CACHE(ceph_file_info,
+                                     SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD);
+       if (ceph_file_cachep == NULL)
+               goto bad_file;
+
+       return 0;
+
+bad_file:
+       kmem_cache_destroy(ceph_dentry_cachep);
+bad_dentry:
+       kmem_cache_destroy(ceph_cap_cachep);
+bad_cap:
+       kmem_cache_destroy(ceph_inode_cachep);
+       return -ENOMEM;
+}
+
+static void destroy_caches(void)
+{
+       kmem_cache_destroy(ceph_inode_cachep);
+       kmem_cache_destroy(ceph_cap_cachep);
+       kmem_cache_destroy(ceph_dentry_cachep);
+       kmem_cache_destroy(ceph_file_cachep);
+}
+
+
+/*
+ * ceph_umount_begin - initiate forced umount.  Tear down down the
+ * mount, skipping steps that may hang while waiting for server(s).
+ */
+static void ceph_umount_begin(struct super_block *sb)
+{
+       struct ceph_client *client = ceph_sb_to_client(sb);
+
+       dout("ceph_umount_begin - starting forced umount\n");
+       if (!client)
+               return;
+       client->mount_state = CEPH_MOUNT_SHUTDOWN;
+       return;
+}
+
+static const struct super_operations ceph_super_ops = {
+       .alloc_inode    = ceph_alloc_inode,
+       .destroy_inode  = ceph_destroy_inode,
+       .write_inode    = ceph_write_inode,
+       .sync_fs        = ceph_syncfs,
+       .put_super      = ceph_put_super,
+       .show_options   = ceph_show_options,
+       .statfs         = ceph_statfs,
+       .umount_begin   = ceph_umount_begin,
+};
+
+
+const char *ceph_msg_type_name(int type)
+{
+       switch (type) {
+       case CEPH_MSG_SHUTDOWN: return "shutdown";
+       case CEPH_MSG_PING: return "ping";
+       case CEPH_MSG_AUTH: return "auth";
+       case CEPH_MSG_AUTH_REPLY: return "auth_reply";
+       case CEPH_MSG_MON_MAP: return "mon_map";
+       case CEPH_MSG_MON_GET_MAP: return "mon_get_map";
+       case CEPH_MSG_MON_SUBSCRIBE: return "mon_subscribe";
+       case CEPH_MSG_MON_SUBSCRIBE_ACK: return "mon_subscribe_ack";
+       case CEPH_MSG_STATFS: return "statfs";
+       case CEPH_MSG_STATFS_REPLY: return "statfs_reply";
+       case CEPH_MSG_MDS_MAP: return "mds_map";
+       case CEPH_MSG_CLIENT_SESSION: return "client_session";
+       case CEPH_MSG_CLIENT_RECONNECT: return "client_reconnect";
+       case CEPH_MSG_CLIENT_REQUEST: return "client_request";
+       case CEPH_MSG_CLIENT_REQUEST_FORWARD: return "client_request_forward";
+       case CEPH_MSG_CLIENT_REPLY: return "client_reply";
+       case CEPH_MSG_CLIENT_CAPS: return "client_caps";
+       case CEPH_MSG_CLIENT_CAPRELEASE: return "client_cap_release";
+       case CEPH_MSG_CLIENT_SNAP: return "client_snap";
+       case CEPH_MSG_CLIENT_LEASE: return "client_lease";
+       case CEPH_MSG_OSD_MAP: return "osd_map";
+       case CEPH_MSG_OSD_OP: return "osd_op";
+       case CEPH_MSG_OSD_OPREPLY: return "osd_opreply";
+       default: return "unknown";
+       }
+}
+
+
+/*
+ * mount options
+ */
+enum {
+       Opt_fsidmajor,
+       Opt_fsidminor,
+       Opt_monport,
+       Opt_wsize,
+       Opt_rsize,
+       Opt_osdtimeout,
+       Opt_osdkeepalivetimeout,
+       Opt_mount_timeout,
+       Opt_osd_idle_ttl,
+       Opt_caps_wanted_delay_min,
+       Opt_caps_wanted_delay_max,
+       Opt_readdir_max_entries,
+       Opt_congestion_kb,
+       Opt_last_int,
+       /* int args above */
+       Opt_snapdirname,
+       Opt_name,
+       Opt_secret,
+       Opt_last_string,
+       /* string args above */
+       Opt_ip,
+       Opt_noshare,
+       Opt_dirstat,
+       Opt_nodirstat,
+       Opt_rbytes,
+       Opt_norbytes,
+       Opt_nocrc,
+       Opt_noasyncreaddir,
+};
+
+static match_table_t arg_tokens = {
+       {Opt_fsidmajor, "fsidmajor=%ld"},
+       {Opt_fsidminor, "fsidminor=%ld"},
+       {Opt_monport, "monport=%d"},
+       {Opt_wsize, "wsize=%d"},
+       {Opt_rsize, "rsize=%d"},
+       {Opt_osdtimeout, "osdtimeout=%d"},
+       {Opt_osdkeepalivetimeout, "osdkeepalive=%d"},
+       {Opt_mount_timeout, "mount_timeout=%d"},
+       {Opt_osd_idle_ttl, "osd_idle_ttl=%d"},
+       {Opt_caps_wanted_delay_min, "caps_wanted_delay_min=%d"},
+       {Opt_caps_wanted_delay_max, "caps_wanted_delay_max=%d"},
+       {Opt_readdir_max_entries, "readdir_max_entries=%d"},
+       {Opt_congestion_kb, "write_congestion_kb=%d"},
+       /* int args above */
+       {Opt_snapdirname, "snapdirname=%s"},
+       {Opt_name, "name=%s"},
+       {Opt_secret, "secret=%s"},
+       /* string args above */
+       {Opt_ip, "ip=%s"},
+       {Opt_noshare, "noshare"},
+       {Opt_dirstat, "dirstat"},
+       {Opt_nodirstat, "nodirstat"},
+       {Opt_rbytes, "rbytes"},
+       {Opt_norbytes, "norbytes"},
+       {Opt_nocrc, "nocrc"},
+       {Opt_noasyncreaddir, "noasyncreaddir"},
+       {-1, NULL}
+};
+
+
+static struct ceph_mount_args *parse_mount_args(int flags, char *options,
+                                               const char *dev_name,
+                                               const char **path)
+{
+       struct ceph_mount_args *args;
+       const char *c;
+       int err = -ENOMEM;
+       substring_t argstr[MAX_OPT_ARGS];
+
+       args = kzalloc(sizeof(*args), GFP_KERNEL);
+       if (!args)
+               return ERR_PTR(-ENOMEM);
+       args->mon_addr = kcalloc(CEPH_MAX_MON, sizeof(*args->mon_addr),
+                                GFP_KERNEL);
+       if (!args->mon_addr)
+               goto out;
+
+       dout("parse_mount_args %p, dev_name '%s'\n", args, dev_name);
+
+       /* start with defaults */
+       args->sb_flags = flags;
+       args->flags = CEPH_OPT_DEFAULT;
+       args->osd_timeout = CEPH_OSD_TIMEOUT_DEFAULT;
+       args->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT;
+       args->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; /* seconds */
+       args->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT;   /* seconds */
+       args->caps_wanted_delay_min = CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT;
+       args->caps_wanted_delay_max = CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT;
+       args->rsize = CEPH_MOUNT_RSIZE_DEFAULT;
+       args->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
+       args->cap_release_safety = CEPH_CAPS_PER_RELEASE * 4;
+       args->max_readdir = 1024;
+       args->congestion_kb = default_congestion_kb();
+
+       /* ip1[:port1][,ip2[:port2]...]:/subdir/in/fs */
+       err = -EINVAL;
+       if (!dev_name)
+               goto out;
+       *path = strstr(dev_name, ":/");
+       if (*path == NULL) {
+               pr_err("device name is missing path (no :/ in %s)\n",
+                      dev_name);
+               goto out;
+       }
+
+       /* get mon ip(s) */
+       err = ceph_parse_ips(dev_name, *path, args->mon_addr,
+                            CEPH_MAX_MON, &args->num_mon);
+       if (err < 0)
+               goto out;
+
+       /* path on server */
+       *path += 2;
+       dout("server path '%s'\n", *path);
+
+       /* parse mount options */
+       while ((c = strsep(&options, ",")) != NULL) {
+               int token, intval, ret;
+               if (!*c)
+                       continue;
+               err = -EINVAL;
+               token = match_token((char *)c, arg_tokens, argstr);
+               if (token < 0) {
+                       pr_err("bad mount option at '%s'\n", c);
+                       goto out;
+               }
+               if (token < Opt_last_int) {
+                       ret = match_int(&argstr[0], &intval);
+                       if (ret < 0) {
+                               pr_err("bad mount option arg (not int) "
+                                      "at '%s'\n", c);
+                               continue;
+                       }
+                       dout("got int token %d val %d\n", token, intval);
+               } else if (token > Opt_last_int && token < Opt_last_string) {
+                       dout("got string token %d val %s\n", token,
+                            argstr[0].from);
+               } else {
+                       dout("got token %d\n", token);
+               }
+               switch (token) {
+               case Opt_fsidmajor:
+                       *(__le64 *)&args->fsid.fsid[0] = cpu_to_le64(intval);
+                       break;
+               case Opt_fsidminor:
+                       *(__le64 *)&args->fsid.fsid[8] = cpu_to_le64(intval);
+                       break;
+               case Opt_ip:
+                       err = ceph_parse_ips(argstr[0].from,
+                                            argstr[0].to,
+                                            &args->my_addr,
+                                            1, NULL);
+                       if (err < 0)
+                               goto out;
+                       args->flags |= CEPH_OPT_MYIP;
+                       break;
+
+               case Opt_snapdirname:
+                       kfree(args->snapdir_name);
+                       args->snapdir_name = kstrndup(argstr[0].from,
+                                             argstr[0].to-argstr[0].from,
+                                             GFP_KERNEL);
+                       break;
+               case Opt_name:
+                       args->name = kstrndup(argstr[0].from,
+                                             argstr[0].to-argstr[0].from,
+                                             GFP_KERNEL);
+                       break;
+               case Opt_secret:
+                       args->secret = kstrndup(argstr[0].from,
+                                               argstr[0].to-argstr[0].from,
+                                               GFP_KERNEL);
+                       break;
+
+                       /* misc */
+               case Opt_wsize:
+                       args->wsize = intval;
+                       break;
+               case Opt_rsize:
+                       args->rsize = intval;
+                       break;
+               case Opt_osdtimeout:
+                       args->osd_timeout = intval;
+                       break;
+               case Opt_osdkeepalivetimeout:
+                       args->osd_keepalive_timeout = intval;
+                       break;
+               case Opt_mount_timeout:
+                       args->mount_timeout = intval;
+                       break;
+               case Opt_caps_wanted_delay_min:
+                       args->caps_wanted_delay_min = intval;
+                       break;
+               case Opt_caps_wanted_delay_max:
+                       args->caps_wanted_delay_max = intval;
+                       break;
+               case Opt_readdir_max_entries:
+                       args->max_readdir = intval;
+                       break;
+               case Opt_congestion_kb:
+                       args->congestion_kb = intval;
+                       break;
+
+               case Opt_noshare:
+                       args->flags |= CEPH_OPT_NOSHARE;
+                       break;
+
+               case Opt_dirstat:
+                       args->flags |= CEPH_OPT_DIRSTAT;
+                       break;
+               case Opt_nodirstat:
+                       args->flags &= ~CEPH_OPT_DIRSTAT;
+                       break;
+               case Opt_rbytes:
+                       args->flags |= CEPH_OPT_RBYTES;
+                       break;
+               case Opt_norbytes:
+                       args->flags &= ~CEPH_OPT_RBYTES;
+                       break;
+               case Opt_nocrc:
+                       args->flags |= CEPH_OPT_NOCRC;
+                       break;
+               case Opt_noasyncreaddir:
+                       args->flags |= CEPH_OPT_NOASYNCREADDIR;
+                       break;
+
+               default:
+                       BUG_ON(token);
+               }
+       }
+       return args;
+
+out:
+       kfree(args->mon_addr);
+       kfree(args);
+       return ERR_PTR(err);
+}
+
+static void destroy_mount_args(struct ceph_mount_args *args)
+{
+       dout("destroy_mount_args %p\n", args);
+       kfree(args->snapdir_name);
+       args->snapdir_name = NULL;
+       kfree(args->name);
+       args->name = NULL;
+       kfree(args->secret);
+       args->secret = NULL;
+       kfree(args);
+}
+
+/*
+ * create a fresh client instance
+ */
+static struct ceph_client *ceph_create_client(struct ceph_mount_args *args)
+{
+       struct ceph_client *client;
+       int err = -ENOMEM;
+
+       client = kzalloc(sizeof(*client), GFP_KERNEL);
+       if (client == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       mutex_init(&client->mount_mutex);
+
+       init_waitqueue_head(&client->auth_wq);
+
+       client->sb = NULL;
+       client->mount_state = CEPH_MOUNT_MOUNTING;
+       client->mount_args = args;
+
+       client->msgr = NULL;
+
+       client->auth_err = 0;
+       atomic_long_set(&client->writeback_count, 0);
+
+       err = bdi_init(&client->backing_dev_info);
+       if (err < 0)
+               goto fail;
+
+       err = -ENOMEM;
+       client->wb_wq = create_workqueue("ceph-writeback");
+       if (client->wb_wq == NULL)
+               goto fail_bdi;
+       client->pg_inv_wq = create_singlethread_workqueue("ceph-pg-invalid");
+       if (client->pg_inv_wq == NULL)
+               goto fail_wb_wq;
+       client->trunc_wq = create_singlethread_workqueue("ceph-trunc");
+       if (client->trunc_wq == NULL)
+               goto fail_pg_inv_wq;
+
+       /* set up mempools */
+       err = -ENOMEM;
+       client->wb_pagevec_pool = mempool_create_kmalloc_pool(10,
+                             client->mount_args->wsize >> PAGE_CACHE_SHIFT);
+       if (!client->wb_pagevec_pool)
+               goto fail_trunc_wq;
+
+       /* caps */
+       client->min_caps = args->max_readdir;
+       ceph_adjust_min_caps(client->min_caps);
+
+       /* subsystems */
+       err = ceph_monc_init(&client->monc, client);
+       if (err < 0)
+               goto fail_mempool;
+       err = ceph_osdc_init(&client->osdc, client);
+       if (err < 0)
+               goto fail_monc;
+       err = ceph_mdsc_init(&client->mdsc, client);
+       if (err < 0)
+               goto fail_osdc;
+       return client;
+
+fail_osdc:
+       ceph_osdc_stop(&client->osdc);
+fail_monc:
+       ceph_monc_stop(&client->monc);
+fail_mempool:
+       mempool_destroy(client->wb_pagevec_pool);
+fail_trunc_wq:
+       destroy_workqueue(client->trunc_wq);
+fail_pg_inv_wq:
+       destroy_workqueue(client->pg_inv_wq);
+fail_wb_wq:
+       destroy_workqueue(client->wb_wq);
+fail_bdi:
+       bdi_destroy(&client->backing_dev_info);
+fail:
+       kfree(client);
+       return ERR_PTR(err);
+}
+
+static void ceph_destroy_client(struct ceph_client *client)
+{
+       dout("destroy_client %p\n", client);
+
+       /* unmount */
+       ceph_mdsc_stop(&client->mdsc);
+       ceph_monc_stop(&client->monc);
+       ceph_osdc_stop(&client->osdc);
+
+       ceph_adjust_min_caps(-client->min_caps);
+
+       ceph_debugfs_client_cleanup(client);
+       destroy_workqueue(client->wb_wq);
+       destroy_workqueue(client->pg_inv_wq);
+       destroy_workqueue(client->trunc_wq);
+
+       if (client->msgr)
+               ceph_messenger_destroy(client->msgr);
+       mempool_destroy(client->wb_pagevec_pool);
+
+       destroy_mount_args(client->mount_args);
+
+       kfree(client);
+       dout("destroy_client %p done\n", client);
+}
+
+/*
+ * Initially learn our fsid, or verify an fsid matches.
+ */
+int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid)
+{
+       if (client->have_fsid) {
+               if (ceph_fsid_compare(&client->fsid, fsid)) {
+                       pr_err("bad fsid, had " FSID_FORMAT " got " FSID_FORMAT,
+                              PR_FSID(&client->fsid), PR_FSID(fsid));
+                       return -1;
+               }
+       } else {
+               pr_info("client%lld fsid " FSID_FORMAT "\n",
+                       client->monc.auth->global_id, PR_FSID(fsid));
+               memcpy(&client->fsid, fsid, sizeof(*fsid));
+               ceph_debugfs_client_init(client);
+               client->have_fsid = true;
+       }
+       return 0;
+}
+
+/*
+ * true if we have the mon map (and have thus joined the cluster)
+ */
+static int have_mon_map(struct ceph_client *client)
+{
+       return client->monc.monmap && client->monc.monmap->epoch;
+}
+
+/*
+ * Bootstrap mount by opening the root directory.  Note the mount
+ * @started time from caller, and time out if this takes too long.
+ */
+static struct dentry *open_root_dentry(struct ceph_client *client,
+                                      const char *path,
+                                      unsigned long started)
+{
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct ceph_mds_request *req = NULL;
+       int err;
+       struct dentry *root;
+
+       /* open dir */
+       dout("open_root_inode opening '%s'\n", path);
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
+       if (IS_ERR(req))
+               return ERR_PTR(PTR_ERR(req));
+       req->r_path1 = kstrdup(path, GFP_NOFS);
+       req->r_ino1.ino = CEPH_INO_ROOT;
+       req->r_ino1.snap = CEPH_NOSNAP;
+       req->r_started = started;
+       req->r_timeout = client->mount_args->mount_timeout * HZ;
+       req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INODE);
+       req->r_num_caps = 2;
+       err = ceph_mdsc_do_request(mdsc, NULL, req);
+       if (err == 0) {
+               dout("open_root_inode success\n");
+               if (ceph_ino(req->r_target_inode) == CEPH_INO_ROOT &&
+                   client->sb->s_root == NULL)
+                       root = d_alloc_root(req->r_target_inode);
+               else
+                       root = d_obtain_alias(req->r_target_inode);
+               req->r_target_inode = NULL;
+               dout("open_root_inode success, root dentry is %p\n", root);
+       } else {
+               root = ERR_PTR(err);
+       }
+       ceph_mdsc_put_request(req);
+       return root;
+}
+
+/*
+ * mount: join the ceph cluster, and open root directory.
+ */
+static int ceph_mount(struct ceph_client *client, struct vfsmount *mnt,
+                     const char *path)
+{
+       struct ceph_entity_addr *myaddr = NULL;
+       int err;
+       unsigned long timeout = client->mount_args->mount_timeout * HZ;
+       unsigned long started = jiffies;  /* note the start time */
+       struct dentry *root;
+
+       dout("mount start\n");
+       mutex_lock(&client->mount_mutex);
+
+       /* initialize the messenger */
+       if (client->msgr == NULL) {
+               if (ceph_test_opt(client, MYIP))
+                       myaddr = &client->mount_args->my_addr;
+               client->msgr = ceph_messenger_create(myaddr);
+               if (IS_ERR(client->msgr)) {
+                       err = PTR_ERR(client->msgr);
+                       client->msgr = NULL;
+                       goto out;
+               }
+               client->msgr->nocrc = ceph_test_opt(client, NOCRC);
+       }
+
+       /* open session, and wait for mon, mds, and osd maps */
+       err = ceph_monc_open_session(&client->monc);
+       if (err < 0)
+               goto out;
+
+       while (!have_mon_map(client)) {
+               err = -EIO;
+               if (timeout && time_after_eq(jiffies, started + timeout))
+                       goto out;
+
+               /* wait */
+               dout("mount waiting for mon_map\n");
+               err = wait_event_interruptible_timeout(client->auth_wq,
+                              have_mon_map(client) || (client->auth_err < 0),
+                              timeout);
+               if (err == -EINTR || err == -ERESTARTSYS)
+                       goto out;
+               if (client->auth_err < 0) {
+                       err = client->auth_err;
+                       goto out;
+               }
+       }
+
+       dout("mount opening root\n");
+       root = open_root_dentry(client, "", started);
+       if (IS_ERR(root)) {
+               err = PTR_ERR(root);
+               goto out;
+       }
+       if (client->sb->s_root)
+               dput(root);
+       else
+               client->sb->s_root = root;
+
+       if (path[0] == 0) {
+               dget(root);
+       } else {
+               dout("mount opening base mountpoint\n");
+               root = open_root_dentry(client, path, started);
+               if (IS_ERR(root)) {
+                       err = PTR_ERR(root);
+                       dput(client->sb->s_root);
+                       client->sb->s_root = NULL;
+                       goto out;
+               }
+       }
+
+       mnt->mnt_root = root;
+       mnt->mnt_sb = client->sb;
+
+       client->mount_state = CEPH_MOUNT_MOUNTED;
+       dout("mount success\n");
+       err = 0;
+
+out:
+       mutex_unlock(&client->mount_mutex);
+       return err;
+}
+
+static int ceph_set_super(struct super_block *s, void *data)
+{
+       struct ceph_client *client = data;
+       int ret;
+
+       dout("set_super %p data %p\n", s, data);
+
+       s->s_flags = client->mount_args->sb_flags;
+       s->s_maxbytes = 1ULL << 40;  /* temp value until we get mdsmap */
+
+       s->s_fs_info = client;
+       client->sb = s;
+
+       s->s_op = &ceph_super_ops;
+       s->s_export_op = &ceph_export_ops;
+
+       s->s_time_gran = 1000;  /* 1000 ns == 1 us */
+
+       ret = set_anon_super(s, NULL);  /* what is that second arg for? */
+       if (ret != 0)
+               goto fail;
+
+       return ret;
+
+fail:
+       s->s_fs_info = NULL;
+       client->sb = NULL;
+       return ret;
+}
+
+/*
+ * share superblock if same fs AND options
+ */
+static int ceph_compare_super(struct super_block *sb, void *data)
+{
+       struct ceph_client *new = data;
+       struct ceph_mount_args *args = new->mount_args;
+       struct ceph_client *other = ceph_sb_to_client(sb);
+       int i;
+
+       dout("ceph_compare_super %p\n", sb);
+       if (args->flags & CEPH_OPT_FSID) {
+               if (ceph_fsid_compare(&args->fsid, &other->fsid)) {
+                       dout("fsid doesn't match\n");
+                       return 0;
+               }
+       } else {
+               /* do we share (a) monitor? */
+               for (i = 0; i < new->monc.monmap->num_mon; i++)
+                       if (ceph_monmap_contains(other->monc.monmap,
+                                        &new->monc.monmap->mon_inst[i].addr))
+                               break;
+               if (i == new->monc.monmap->num_mon) {
+                       dout("mon ip not part of monmap\n");
+                       return 0;
+               }
+               dout("mon ip matches existing sb %p\n", sb);
+       }
+       if (args->sb_flags != other->mount_args->sb_flags) {
+               dout("flags differ\n");
+               return 0;
+       }
+       return 1;
+}
+
+/*
+ * construct our own bdi so we can control readahead, etc.
+ */
+static int ceph_register_bdi(struct super_block *sb, struct ceph_client *client)
+{
+       int err;
+
+       sb->s_bdi = &client->backing_dev_info;
+
+       /* set ra_pages based on rsize mount option? */
+       if (client->mount_args->rsize >= PAGE_CACHE_SIZE)
+               client->backing_dev_info.ra_pages =
+                       (client->mount_args->rsize + PAGE_CACHE_SIZE - 1)
+                       >> PAGE_SHIFT;
+       err = bdi_register_dev(&client->backing_dev_info, sb->s_dev);
+       return err;
+}
+
+static int ceph_get_sb(struct file_system_type *fs_type,
+                      int flags, const char *dev_name, void *data,
+                      struct vfsmount *mnt)
+{
+       struct super_block *sb;
+       struct ceph_client *client;
+       int err;
+       int (*compare_super)(struct super_block *, void *) = ceph_compare_super;
+       const char *path = NULL;
+       struct ceph_mount_args *args;
+
+       dout("ceph_get_sb\n");
+       args = parse_mount_args(flags, data, dev_name, &path);
+       if (IS_ERR(args)) {
+               err = PTR_ERR(args);
+               goto out_final;
+       }
+
+       /* create client (which we may/may not use) */
+       client = ceph_create_client(args);
+       if (IS_ERR(client)) {
+               err = PTR_ERR(client);
+               goto out_final;
+       }
+
+       if (client->mount_args->flags & CEPH_OPT_NOSHARE)
+               compare_super = NULL;
+       sb = sget(fs_type, compare_super, ceph_set_super, client);
+       if (IS_ERR(sb)) {
+               err = PTR_ERR(sb);
+               goto out;
+       }
+
+       if (ceph_client(sb) != client) {
+               ceph_destroy_client(client);
+               client = ceph_client(sb);
+               dout("get_sb got existing client %p\n", client);
+       } else {
+               dout("get_sb using new client %p\n", client);
+               err = ceph_register_bdi(sb, client);
+               if (err < 0)
+                       goto out_splat;
+       }
+
+       err = ceph_mount(client, mnt, path);
+       if (err < 0)
+               goto out_splat;
+       dout("root %p inode %p ino %llx.%llx\n", mnt->mnt_root,
+            mnt->mnt_root->d_inode, ceph_vinop(mnt->mnt_root->d_inode));
+       return 0;
+
+out_splat:
+       ceph_mdsc_close_sessions(&client->mdsc);
+       up_write(&sb->s_umount);
+       deactivate_super(sb);
+       goto out_final;
+
+out:
+       ceph_destroy_client(client);
+out_final:
+       dout("ceph_get_sb fail %d\n", err);
+       return err;
+}
+
+static void ceph_kill_sb(struct super_block *s)
+{
+       struct ceph_client *client = ceph_sb_to_client(s);
+       dout("kill_sb %p\n", s);
+       ceph_mdsc_pre_umount(&client->mdsc);
+       kill_anon_super(s);    /* will call put_super after sb is r/o */
+       if (s->s_bdi == &client->backing_dev_info)
+               bdi_unregister(&client->backing_dev_info);
+       bdi_destroy(&client->backing_dev_info);
+       ceph_destroy_client(client);
+}
+
+static struct file_system_type ceph_fs_type = {
+       .owner          = THIS_MODULE,
+       .name           = "ceph",
+       .get_sb         = ceph_get_sb,
+       .kill_sb        = ceph_kill_sb,
+       .fs_flags       = FS_RENAME_DOES_D_MOVE,
+};
+
+#define _STRINGIFY(x) #x
+#define STRINGIFY(x) _STRINGIFY(x)
+
+static int __init init_ceph(void)
+{
+       int ret = 0;
+
+       ret = ceph_debugfs_init();
+       if (ret < 0)
+               goto out;
+
+       ret = ceph_msgr_init();
+       if (ret < 0)
+               goto out_debugfs;
+
+       ret = init_caches();
+       if (ret)
+               goto out_msgr;
+
+       ceph_caps_init();
+
+       ret = register_filesystem(&ceph_fs_type);
+       if (ret)
+               goto out_icache;
+
+       pr_info("loaded %d.%d.%d (mon/mds/osd proto %d/%d/%d)\n",
+               CEPH_VERSION_MAJOR, CEPH_VERSION_MINOR, CEPH_VERSION_PATCH,
+               CEPH_MONC_PROTOCOL, CEPH_MDSC_PROTOCOL, CEPH_OSDC_PROTOCOL);
+       return 0;
+
+out_icache:
+       destroy_caches();
+out_msgr:
+       ceph_msgr_exit();
+out_debugfs:
+       ceph_debugfs_cleanup();
+out:
+       return ret;
+}
+
+static void __exit exit_ceph(void)
+{
+       dout("exit_ceph\n");
+       unregister_filesystem(&ceph_fs_type);
+       ceph_caps_finalize();
+       destroy_caches();
+       ceph_msgr_exit();
+       ceph_debugfs_cleanup();
+}
+
+module_init(init_ceph);
+module_exit(exit_ceph);
+
+MODULE_AUTHOR("Sage Weil <sage@newdream.net>");
+MODULE_AUTHOR("Yehuda Sadeh <yehuda@hq.newdream.net>");
+MODULE_AUTHOR("Patience Warnick <patience@newdream.net>");
+MODULE_DESCRIPTION("Ceph filesystem for Linux");
+MODULE_LICENSE("GPL");
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
new file mode 100644 (file)
index 0000000..ca702c6
--- /dev/null
@@ -0,0 +1,902 @@
+#ifndef _FS_CEPH_SUPER_H
+#define _FS_CEPH_SUPER_H
+
+#include "ceph_debug.h"
+
+#include <asm/unaligned.h>
+#include <linux/backing-dev.h>
+#include <linux/completion.h>
+#include <linux/exportfs.h>
+#include <linux/fs.h>
+#include <linux/mempool.h>
+#include <linux/pagemap.h>
+#include <linux/wait.h>
+#include <linux/writeback.h>
+#include <linux/slab.h>
+
+#include "types.h"
+#include "messenger.h"
+#include "msgpool.h"
+#include "mon_client.h"
+#include "mds_client.h"
+#include "osd_client.h"
+#include "ceph_fs.h"
+
+/* f_type in struct statfs */
+#define CEPH_SUPER_MAGIC 0x00c36400
+
+/* large granularity for statfs utilization stats to facilitate
+ * large volume sizes on 32-bit machines. */
+#define CEPH_BLOCK_SHIFT   20  /* 1 MB */
+#define CEPH_BLOCK         (1 << CEPH_BLOCK_SHIFT)
+
+/*
+ * mount options
+ */
+#define CEPH_OPT_FSID             (1<<0)
+#define CEPH_OPT_NOSHARE          (1<<1) /* don't share client with other sbs */
+#define CEPH_OPT_MYIP             (1<<2) /* specified my ip */
+#define CEPH_OPT_DIRSTAT          (1<<4) /* funky `cat dirname` for stats */
+#define CEPH_OPT_RBYTES           (1<<5) /* dir st_bytes = rbytes */
+#define CEPH_OPT_NOCRC            (1<<6) /* no data crc on writes */
+#define CEPH_OPT_NOASYNCREADDIR   (1<<7) /* no dcache readdir */
+
+#define CEPH_OPT_DEFAULT   (CEPH_OPT_RBYTES)
+
+#define ceph_set_opt(client, opt) \
+       (client)->mount_args->flags |= CEPH_OPT_##opt;
+#define ceph_test_opt(client, opt) \
+       (!!((client)->mount_args->flags & CEPH_OPT_##opt))
+
+
+struct ceph_mount_args {
+       int sb_flags;
+       int num_mon;
+       struct ceph_entity_addr *mon_addr;
+       int flags;
+       int mount_timeout;
+       int osd_idle_ttl;
+       int caps_wanted_delay_min, caps_wanted_delay_max;
+       struct ceph_fsid fsid;
+       struct ceph_entity_addr my_addr;
+       int wsize;
+       int rsize;            /* max readahead */
+       int max_readdir;      /* max readdir size */
+       int congestion_kb;      /* max readdir size */
+       int osd_timeout;
+       int osd_keepalive_timeout;
+       char *snapdir_name;   /* default ".snap" */
+       char *name;
+       char *secret;
+       int cap_release_safety;
+};
+
+/*
+ * defaults
+ */
+#define CEPH_MOUNT_TIMEOUT_DEFAULT  60
+#define CEPH_OSD_TIMEOUT_DEFAULT    60  /* seconds */
+#define CEPH_OSD_KEEPALIVE_DEFAULT  5
+#define CEPH_OSD_IDLE_TTL_DEFAULT    60
+#define CEPH_MOUNT_RSIZE_DEFAULT    (512*1024) /* readahead */
+
+#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024)
+#define CEPH_MSG_MAX_DATA_LEN  (16*1024*1024)
+
+#define CEPH_SNAPDIRNAME_DEFAULT ".snap"
+#define CEPH_AUTH_NAME_DEFAULT   "guest"
+
+/*
+ * Delay telling the MDS we no longer want caps, in case we reopen
+ * the file.  Delay a minimum amount of time, even if we send a cap
+ * message for some other reason.  Otherwise, take the oppotunity to
+ * update the mds to avoid sending another message later.
+ */
+#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT      5  /* cap release delay */
+#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT     60  /* cap release delay */
+
+
+/* mount state */
+enum {
+       CEPH_MOUNT_MOUNTING,
+       CEPH_MOUNT_MOUNTED,
+       CEPH_MOUNT_UNMOUNTING,
+       CEPH_MOUNT_UNMOUNTED,
+       CEPH_MOUNT_SHUTDOWN,
+};
+
+/*
+ * subtract jiffies
+ */
+static inline unsigned long time_sub(unsigned long a, unsigned long b)
+{
+       BUG_ON(time_after(b, a));
+       return (long)a - (long)b;
+}
+
+/*
+ * per-filesystem client state
+ *
+ * possibly shared by multiple mount points, if they are
+ * mounting the same ceph filesystem/cluster.
+ */
+struct ceph_client {
+       struct ceph_fsid fsid;
+       bool have_fsid;
+
+       struct mutex mount_mutex;       /* serialize mount attempts */
+       struct ceph_mount_args *mount_args;
+
+       struct super_block *sb;
+
+       unsigned long mount_state;
+       wait_queue_head_t auth_wq;
+
+       int auth_err;
+
+       int min_caps;                  /* min caps i added */
+
+       struct ceph_messenger *msgr;   /* messenger instance */
+       struct ceph_mon_client monc;
+       struct ceph_mds_client mdsc;
+       struct ceph_osd_client osdc;
+
+       /* writeback */
+       mempool_t *wb_pagevec_pool;
+       struct workqueue_struct *wb_wq;
+       struct workqueue_struct *pg_inv_wq;
+       struct workqueue_struct *trunc_wq;
+       atomic_long_t writeback_count;
+
+       struct backing_dev_info backing_dev_info;
+
+#ifdef CONFIG_DEBUG_FS
+       struct dentry *debugfs_monmap;
+       struct dentry *debugfs_mdsmap, *debugfs_osdmap;
+       struct dentry *debugfs_dir, *debugfs_dentry_lru, *debugfs_caps;
+       struct dentry *debugfs_congestion_kb;
+       struct dentry *debugfs_bdi;
+#endif
+};
+
+static inline struct ceph_client *ceph_client(struct super_block *sb)
+{
+       return sb->s_fs_info;
+}
+
+
+/*
+ * File i/o capability.  This tracks shared state with the metadata
+ * server that allows us to cache or writeback attributes or to read
+ * and write data.  For any given inode, we should have one or more
+ * capabilities, one issued by each metadata server, and our
+ * cumulative access is the OR of all issued capabilities.
+ *
+ * Each cap is referenced by the inode's i_caps rbtree and by per-mds
+ * session capability lists.
+ */
+struct ceph_cap {
+       struct ceph_inode_info *ci;
+       struct rb_node ci_node;          /* per-ci cap tree */
+       struct ceph_mds_session *session;
+       struct list_head session_caps;   /* per-session caplist */
+       int mds;
+       u64 cap_id;       /* unique cap id (mds provided) */
+       int issued;       /* latest, from the mds */
+       int implemented;  /* implemented superset of issued (for revocation) */
+       int mds_wanted;
+       u32 seq, issue_seq, mseq;
+       u32 cap_gen;      /* active/stale cycle */
+       unsigned long last_used;
+       struct list_head caps_item;
+};
+
+#define CHECK_CAPS_NODELAY    1  /* do not delay any further */
+#define CHECK_CAPS_AUTHONLY   2  /* only check auth cap */
+#define CHECK_CAPS_FLUSH      4  /* flush any dirty caps */
+
+/*
+ * Snapped cap state that is pending flush to mds.  When a snapshot occurs,
+ * we first complete any in-process sync writes and writeback any dirty
+ * data before flushing the snapped state (tracked here) back to the MDS.
+ */
+struct ceph_cap_snap {
+       atomic_t nref;
+       struct ceph_inode_info *ci;
+       struct list_head ci_item, flushing_item;
+
+       u64 follows, flush_tid;
+       int issued, dirty;
+       struct ceph_snap_context *context;
+
+       mode_t mode;
+       uid_t uid;
+       gid_t gid;
+
+       void *xattr_blob;
+       int xattr_len;
+       u64 xattr_version;
+
+       u64 size;
+       struct timespec mtime, atime, ctime;
+       u64 time_warp_seq;
+       int writing;   /* a sync write is still in progress */
+       int dirty_pages;     /* dirty pages awaiting writeback */
+};
+
+static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap)
+{
+       if (atomic_dec_and_test(&capsnap->nref))
+               kfree(capsnap);
+}
+
+/*
+ * The frag tree describes how a directory is fragmented, potentially across
+ * multiple metadata servers.  It is also used to indicate points where
+ * metadata authority is delegated, and whether/where metadata is replicated.
+ *
+ * A _leaf_ frag will be present in the i_fragtree IFF there is
+ * delegation info.  That is, if mds >= 0 || ndist > 0.
+ */
+#define CEPH_MAX_DIRFRAG_REP 4
+
+struct ceph_inode_frag {
+       struct rb_node node;
+
+       /* fragtree state */
+       u32 frag;
+       int split_by;         /* i.e. 2^(split_by) children */
+
+       /* delegation and replication info */
+       int mds;              /* -1 if same authority as parent */
+       int ndist;            /* >0 if replicated */
+       int dist[CEPH_MAX_DIRFRAG_REP];
+};
+
+/*
+ * We cache inode xattrs as an encoded blob until they are first used,
+ * at which point we parse them into an rbtree.
+ */
+struct ceph_inode_xattr {
+       struct rb_node node;
+
+       const char *name;
+       int name_len;
+       const char *val;
+       int val_len;
+       int dirty;
+
+       int should_free_name;
+       int should_free_val;
+};
+
+struct ceph_inode_xattrs_info {
+       /*
+        * (still encoded) xattr blob. we avoid the overhead of parsing
+        * this until someone actually calls getxattr, etc.
+        *
+        * blob->vec.iov_len == 4 implies there are no xattrs; blob ==
+        * NULL means we don't know.
+       */
+       struct ceph_buffer *blob, *prealloc_blob;
+
+       struct rb_root index;
+       bool dirty;
+       int count;
+       int names_size;
+       int vals_size;
+       u64 version, index_version;
+};
+
+/*
+ * Ceph inode.
+ */
+#define CEPH_I_COMPLETE  1  /* we have complete directory cached */
+#define CEPH_I_NODELAY   4  /* do not delay cap release */
+#define CEPH_I_FLUSH     8  /* do not delay flush of dirty metadata */
+#define CEPH_I_NOFLUSH  16  /* do not flush dirty caps */
+
+struct ceph_inode_info {
+       struct ceph_vino i_vino;   /* ceph ino + snap */
+
+       u64 i_version;
+       u32 i_time_warp_seq;
+
+       unsigned i_ceph_flags;
+       unsigned long i_release_count;
+
+       struct ceph_file_layout i_layout;
+       char *i_symlink;
+
+       /* for dirs */
+       struct timespec i_rctime;
+       u64 i_rbytes, i_rfiles, i_rsubdirs;
+       u64 i_files, i_subdirs;
+       u64 i_max_offset;  /* largest readdir offset, set with I_COMPLETE */
+
+       struct rb_root i_fragtree;
+       struct mutex i_fragtree_mutex;
+
+       struct ceph_inode_xattrs_info i_xattrs;
+
+       /* capabilities.  protected _both_ by i_lock and cap->session's
+        * s_mutex. */
+       struct rb_root i_caps;           /* cap list */
+       struct ceph_cap *i_auth_cap;     /* authoritative cap, if any */
+       unsigned i_dirty_caps, i_flushing_caps;     /* mask of dirtied fields */
+       struct list_head i_dirty_item, i_flushing_item;
+       u64 i_cap_flush_seq;
+       /* we need to track cap writeback on a per-cap-bit basis, to allow
+        * overlapping, pipelined cap flushes to the mds.  we can probably
+        * reduce the tid to 8 bits if we're concerned about inode size. */
+       u16 i_cap_flush_last_tid, i_cap_flush_tid[CEPH_CAP_BITS];
+       wait_queue_head_t i_cap_wq;      /* threads waiting on a capability */
+       unsigned long i_hold_caps_min; /* jiffies */
+       unsigned long i_hold_caps_max; /* jiffies */
+       struct list_head i_cap_delay_list;  /* for delayed cap release to mds */
+       int i_cap_exporting_mds;         /* to handle cap migration between */
+       unsigned i_cap_exporting_mseq;   /*  mds's. */
+       unsigned i_cap_exporting_issued;
+       struct ceph_cap_reservation i_cap_migration_resv;
+       struct list_head i_cap_snaps;   /* snapped state pending flush to mds */
+       struct ceph_snap_context *i_head_snapc;  /* set if wr_buffer_head > 0 */
+       unsigned i_snap_caps;           /* cap bits for snapped files */
+
+       int i_nr_by_mode[CEPH_FILE_MODE_NUM];  /* open file counts */
+
+       u32 i_truncate_seq;        /* last truncate to smaller size */
+       u64 i_truncate_size;       /*  and the size we last truncated down to */
+       int i_truncate_pending;    /*  still need to call vmtruncate */
+
+       u64 i_max_size;            /* max file size authorized by mds */
+       u64 i_reported_size; /* (max_)size reported to or requested of mds */
+       u64 i_wanted_max_size;     /* offset we'd like to write too */
+       u64 i_requested_max_size;  /* max_size we've requested */
+
+       /* held references to caps */
+       int i_pin_ref;
+       int i_rd_ref, i_rdcache_ref, i_wr_ref;
+       int i_wrbuffer_ref, i_wrbuffer_ref_head;
+       u32 i_shared_gen;       /* increment each time we get FILE_SHARED */
+       u32 i_rdcache_gen;      /* we increment this each time we get
+                                  FILE_CACHE.  If it's non-zero, we
+                                  _may_ have cached pages. */
+       u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */
+
+       struct list_head i_unsafe_writes; /* uncommitted sync writes */
+       struct list_head i_unsafe_dirops; /* uncommitted mds dir ops */
+       spinlock_t i_unsafe_lock;
+
+       struct ceph_snap_realm *i_snap_realm; /* snap realm (if caps) */
+       int i_snap_realm_counter; /* snap realm (if caps) */
+       struct list_head i_snap_realm_item;
+       struct list_head i_snap_flush_item;
+
+       struct work_struct i_wb_work;  /* writeback work */
+       struct work_struct i_pg_inv_work;  /* page invalidation work */
+
+       struct work_struct i_vmtruncate_work;
+
+       struct inode vfs_inode; /* at end */
+};
+
+static inline struct ceph_inode_info *ceph_inode(struct inode *inode)
+{
+       return container_of(inode, struct ceph_inode_info, vfs_inode);
+}
+
+static inline void ceph_i_clear(struct inode *inode, unsigned mask)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       spin_lock(&inode->i_lock);
+       ci->i_ceph_flags &= ~mask;
+       spin_unlock(&inode->i_lock);
+}
+
+static inline void ceph_i_set(struct inode *inode, unsigned mask)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       spin_lock(&inode->i_lock);
+       ci->i_ceph_flags |= mask;
+       spin_unlock(&inode->i_lock);
+}
+
+static inline bool ceph_i_test(struct inode *inode, unsigned mask)
+{
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       bool r;
+
+       smp_mb();
+       r = (ci->i_ceph_flags & mask) == mask;
+       return r;
+}
+
+
+/* find a specific frag @f */
+extern struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci,
+                                               u32 f);
+
+/*
+ * choose fragment for value @v.  copy frag content to pfrag, if leaf
+ * exists
+ */
+extern u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v,
+                           struct ceph_inode_frag *pfrag,
+                           int *found);
+
+/*
+ * Ceph dentry state
+ */
+struct ceph_dentry_info {
+       struct ceph_mds_session *lease_session;
+       u32 lease_gen, lease_shared_gen;
+       u32 lease_seq;
+       unsigned long lease_renew_after, lease_renew_from;
+       struct list_head lru;
+       struct dentry *dentry;
+       u64 time;
+       u64 offset;
+};
+
+static inline struct ceph_dentry_info *ceph_dentry(struct dentry *dentry)
+{
+       return (struct ceph_dentry_info *)dentry->d_fsdata;
+}
+
+static inline loff_t ceph_make_fpos(unsigned frag, unsigned off)
+{
+       return ((loff_t)frag << 32) | (loff_t)off;
+}
+
+/*
+ * ino_t is <64 bits on many architectures, blech.
+ *
+ * don't include snap in ino hash, at least for now.
+ */
+static inline ino_t ceph_vino_to_ino(struct ceph_vino vino)
+{
+       ino_t ino = (ino_t)vino.ino;  /* ^ (vino.snap << 20); */
+#if BITS_PER_LONG == 32
+       ino ^= vino.ino >> (sizeof(u64)-sizeof(ino_t)) * 8;
+       if (!ino)
+               ino = 1;
+#endif
+       return ino;
+}
+
+static inline int ceph_set_ino_cb(struct inode *inode, void *data)
+{
+       ceph_inode(inode)->i_vino = *(struct ceph_vino *)data;
+       inode->i_ino = ceph_vino_to_ino(*(struct ceph_vino *)data);
+       return 0;
+}
+
+static inline struct ceph_vino ceph_vino(struct inode *inode)
+{
+       return ceph_inode(inode)->i_vino;
+}
+
+/* for printf-style formatting */
+#define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap
+
+static inline u64 ceph_ino(struct inode *inode)
+{
+       return ceph_inode(inode)->i_vino.ino;
+}
+static inline u64 ceph_snap(struct inode *inode)
+{
+       return ceph_inode(inode)->i_vino.snap;
+}
+
+static inline int ceph_ino_compare(struct inode *inode, void *data)
+{
+       struct ceph_vino *pvino = (struct ceph_vino *)data;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       return ci->i_vino.ino == pvino->ino &&
+               ci->i_vino.snap == pvino->snap;
+}
+
+static inline struct inode *ceph_find_inode(struct super_block *sb,
+                                           struct ceph_vino vino)
+{
+       ino_t t = ceph_vino_to_ino(vino);
+       return ilookup5(sb, t, ceph_ino_compare, &vino);
+}
+
+
+/*
+ * caps helpers
+ */
+static inline bool __ceph_is_any_real_caps(struct ceph_inode_info *ci)
+{
+       return !RB_EMPTY_ROOT(&ci->i_caps);
+}
+
+extern int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented);
+extern int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int t);
+extern int __ceph_caps_issued_other(struct ceph_inode_info *ci,
+                                   struct ceph_cap *cap);
+
+static inline int ceph_caps_issued(struct ceph_inode_info *ci)
+{
+       int issued;
+       spin_lock(&ci->vfs_inode.i_lock);
+       issued = __ceph_caps_issued(ci, NULL);
+       spin_unlock(&ci->vfs_inode.i_lock);
+       return issued;
+}
+
+static inline int ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask,
+                                       int touch)
+{
+       int r;
+       spin_lock(&ci->vfs_inode.i_lock);
+       r = __ceph_caps_issued_mask(ci, mask, touch);
+       spin_unlock(&ci->vfs_inode.i_lock);
+       return r;
+}
+
+static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
+{
+       return ci->i_dirty_caps | ci->i_flushing_caps;
+}
+extern void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
+
+extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
+extern int __ceph_caps_used(struct ceph_inode_info *ci);
+
+extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci);
+
+/*
+ * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
+ */
+static inline int __ceph_caps_wanted(struct ceph_inode_info *ci)
+{
+       int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci);
+       if (w & CEPH_CAP_FILE_BUFFER)
+               w |= CEPH_CAP_FILE_EXCL;  /* we want EXCL if dirty data */
+       return w;
+}
+
+/* what the mds thinks we want */
+extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci);
+
+extern void ceph_caps_init(void);
+extern void ceph_caps_finalize(void);
+extern void ceph_adjust_min_caps(int delta);
+extern int ceph_reserve_caps(struct ceph_cap_reservation *ctx, int need);
+extern int ceph_unreserve_caps(struct ceph_cap_reservation *ctx);
+extern void ceph_reservation_status(struct ceph_client *client,
+                                   int *total, int *avail, int *used,
+                                   int *reserved, int *min);
+
+static inline struct ceph_client *ceph_inode_to_client(struct inode *inode)
+{
+       return (struct ceph_client *)inode->i_sb->s_fs_info;
+}
+
+static inline struct ceph_client *ceph_sb_to_client(struct super_block *sb)
+{
+       return (struct ceph_client *)sb->s_fs_info;
+}
+
+
+/*
+ * we keep buffered readdir results attached to file->private_data
+ */
+struct ceph_file_info {
+       int fmode;     /* initialized on open */
+
+       /* readdir: position within the dir */
+       u32 frag;
+       struct ceph_mds_request *last_readdir;
+       int at_end;
+
+       /* readdir: position within a frag */
+       unsigned offset;       /* offset of last chunk, adjusted for . and .. */
+       u64 next_offset;       /* offset of next chunk (last_name's + 1) */
+       char *last_name;       /* last entry in previous chunk */
+       struct dentry *dentry; /* next dentry (for dcache readdir) */
+       unsigned long dir_release_count;
+
+       /* used for -o dirstat read() on directory thing */
+       char *dir_info;
+       int dir_info_len;
+};
+
+
+
+/*
+ * snapshots
+ */
+
+/*
+ * A "snap context" is the set of existing snapshots when we
+ * write data.  It is used by the OSD to guide its COW behavior.
+ *
+ * The ceph_snap_context is refcounted, and attached to each dirty
+ * page, indicating which context the dirty data belonged when it was
+ * dirtied.
+ */
+struct ceph_snap_context {
+       atomic_t nref;
+       u64 seq;
+       int num_snaps;
+       u64 snaps[];
+};
+
+static inline struct ceph_snap_context *
+ceph_get_snap_context(struct ceph_snap_context *sc)
+{
+       /*
+       printk("get_snap_context %p %d -> %d\n", sc, atomic_read(&sc->nref),
+              atomic_read(&sc->nref)+1);
+       */
+       if (sc)
+               atomic_inc(&sc->nref);
+       return sc;
+}
+
+static inline void ceph_put_snap_context(struct ceph_snap_context *sc)
+{
+       if (!sc)
+               return;
+       /*
+       printk("put_snap_context %p %d -> %d\n", sc, atomic_read(&sc->nref),
+              atomic_read(&sc->nref)-1);
+       */
+       if (atomic_dec_and_test(&sc->nref)) {
+               /*printk(" deleting snap_context %p\n", sc);*/
+               kfree(sc);
+       }
+}
+
+/*
+ * A "snap realm" describes a subset of the file hierarchy sharing
+ * the same set of snapshots that apply to it.  The realms themselves
+ * are organized into a hierarchy, such that children inherit (some of)
+ * the snapshots of their parents.
+ *
+ * All inodes within the realm that have capabilities are linked into a
+ * per-realm list.
+ */
+struct ceph_snap_realm {
+       u64 ino;
+       atomic_t nref;
+       struct rb_node node;
+
+       u64 created, seq;
+       u64 parent_ino;
+       u64 parent_since;   /* snapid when our current parent became so */
+
+       u64 *prior_parent_snaps;      /* snaps inherited from any parents we */
+       int num_prior_parent_snaps;   /*  had prior to parent_since */
+       u64 *snaps;                   /* snaps specific to this realm */
+       int num_snaps;
+
+       struct ceph_snap_realm *parent;
+       struct list_head children;       /* list of child realms */
+       struct list_head child_item;
+
+       struct list_head empty_item;     /* if i have ref==0 */
+
+       /* the current set of snaps for this realm */
+       struct ceph_snap_context *cached_context;
+
+       struct list_head inodes_with_caps;
+       spinlock_t inodes_with_caps_lock;
+};
+
+
+
+/*
+ * calculate the number of pages a given length and offset map onto,
+ * if we align the data.
+ */
+static inline int calc_pages_for(u64 off, u64 len)
+{
+       return ((off+len+PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT) -
+               (off >> PAGE_CACHE_SHIFT);
+}
+
+
+
+/* snap.c */
+struct ceph_snap_realm *ceph_lookup_snap_realm(struct ceph_mds_client *mdsc,
+                                              u64 ino);
+extern void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
+                               struct ceph_snap_realm *realm);
+extern void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
+                               struct ceph_snap_realm *realm);
+extern int ceph_update_snap_trace(struct ceph_mds_client *m,
+                                 void *p, void *e, bool deletion);
+extern void ceph_handle_snap(struct ceph_mds_client *mdsc,
+                            struct ceph_mds_session *session,
+                            struct ceph_msg *msg);
+extern void ceph_queue_cap_snap(struct ceph_inode_info *ci,
+                               struct ceph_snap_context *snapc);
+extern int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
+                                 struct ceph_cap_snap *capsnap);
+extern void ceph_cleanup_empty_realms(struct ceph_mds_client *mdsc);
+
+/*
+ * a cap_snap is "pending" if it is still awaiting an in-progress
+ * sync write (that may/may not still update size, mtime, etc.).
+ */
+static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
+{
+       return !list_empty(&ci->i_cap_snaps) &&
+               list_entry(ci->i_cap_snaps.prev, struct ceph_cap_snap,
+                          ci_item)->writing;
+}
+
+
+/* super.c */
+extern struct kmem_cache *ceph_inode_cachep;
+extern struct kmem_cache *ceph_cap_cachep;
+extern struct kmem_cache *ceph_dentry_cachep;
+extern struct kmem_cache *ceph_file_cachep;
+
+extern const char *ceph_msg_type_name(int type);
+extern int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid);
+
+#define FSID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \
+       "%02x%02x%02x%02x%02x%02x"
+#define PR_FSID(f) (f)->fsid[0], (f)->fsid[1], (f)->fsid[2], (f)->fsid[3], \
+               (f)->fsid[4], (f)->fsid[5], (f)->fsid[6], (f)->fsid[7],    \
+               (f)->fsid[8], (f)->fsid[9], (f)->fsid[10], (f)->fsid[11],  \
+               (f)->fsid[12], (f)->fsid[13], (f)->fsid[14], (f)->fsid[15]
+
+/* inode.c */
+extern const struct inode_operations ceph_file_iops;
+
+extern struct inode *ceph_alloc_inode(struct super_block *sb);
+extern void ceph_destroy_inode(struct inode *inode);
+
+extern struct inode *ceph_get_inode(struct super_block *sb,
+                                   struct ceph_vino vino);
+extern struct inode *ceph_get_snapdir(struct inode *parent);
+extern int ceph_fill_file_size(struct inode *inode, int issued,
+                              u32 truncate_seq, u64 truncate_size, u64 size);
+extern void ceph_fill_file_time(struct inode *inode, int issued,
+                               u64 time_warp_seq, struct timespec *ctime,
+                               struct timespec *mtime, struct timespec *atime);
+extern int ceph_fill_trace(struct super_block *sb,
+                          struct ceph_mds_request *req,
+                          struct ceph_mds_session *session);
+extern int ceph_readdir_prepopulate(struct ceph_mds_request *req,
+                                   struct ceph_mds_session *session);
+
+extern int ceph_inode_holds_cap(struct inode *inode, int mask);
+
+extern int ceph_inode_set_size(struct inode *inode, loff_t size);
+extern void __ceph_do_pending_vmtruncate(struct inode *inode);
+extern void ceph_queue_vmtruncate(struct inode *inode);
+
+extern void ceph_queue_invalidate(struct inode *inode);
+extern void ceph_queue_writeback(struct inode *inode);
+
+extern int ceph_do_getattr(struct inode *inode, int mask);
+extern int ceph_permission(struct inode *inode, int mask);
+extern int ceph_setattr(struct dentry *dentry, struct iattr *attr);
+extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
+                       struct kstat *stat);
+
+/* xattr.c */
+extern int ceph_setxattr(struct dentry *, const char *, const void *,
+                        size_t, int);
+extern ssize_t ceph_getxattr(struct dentry *, const char *, void *, size_t);
+extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
+extern int ceph_removexattr(struct dentry *, const char *);
+extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci);
+extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
+
+/* caps.c */
+extern const char *ceph_cap_string(int c);
+extern void ceph_handle_caps(struct ceph_mds_session *session,
+                            struct ceph_msg *msg);
+extern int ceph_add_cap(struct inode *inode,
+                       struct ceph_mds_session *session, u64 cap_id,
+                       int fmode, unsigned issued, unsigned wanted,
+                       unsigned cap, unsigned seq, u64 realmino, int flags,
+                       struct ceph_cap_reservation *caps_reservation);
+extern void __ceph_remove_cap(struct ceph_cap *cap);
+static inline void ceph_remove_cap(struct ceph_cap *cap)
+{
+       struct inode *inode = &cap->ci->vfs_inode;
+       spin_lock(&inode->i_lock);
+       __ceph_remove_cap(cap);
+       spin_unlock(&inode->i_lock);
+}
+extern void ceph_put_cap(struct ceph_cap *cap);
+
+extern void ceph_queue_caps_release(struct inode *inode);
+extern int ceph_write_inode(struct inode *inode, struct writeback_control *wbc);
+extern int ceph_fsync(struct file *file, struct dentry *dentry, int datasync);
+extern void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc,
+                                   struct ceph_mds_session *session);
+extern int ceph_get_cap_mds(struct inode *inode);
+extern void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps);
+extern void ceph_put_cap_refs(struct ceph_inode_info *ci, int had);
+extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
+                                      struct ceph_snap_context *snapc);
+extern void __ceph_flush_snaps(struct ceph_inode_info *ci,
+                              struct ceph_mds_session **psession);
+extern void ceph_check_caps(struct ceph_inode_info *ci, int flags,
+                           struct ceph_mds_session *session);
+extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
+extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc);
+
+extern int ceph_encode_inode_release(void **p, struct inode *inode,
+                                    int mds, int drop, int unless, int force);
+extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
+                                     int mds, int drop, int unless);
+
+extern int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
+                        int *got, loff_t endoff);
+
+/* for counting open files by mode */
+static inline void __ceph_get_fmode(struct ceph_inode_info *ci, int mode)
+{
+       ci->i_nr_by_mode[mode]++;
+}
+extern void ceph_put_fmode(struct ceph_inode_info *ci, int mode);
+
+/* addr.c */
+extern const struct address_space_operations ceph_aops;
+extern int ceph_mmap(struct file *file, struct vm_area_struct *vma);
+
+/* file.c */
+extern const struct file_operations ceph_file_fops;
+extern const struct address_space_operations ceph_aops;
+extern int ceph_open(struct inode *inode, struct file *file);
+extern struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
+                                      struct nameidata *nd, int mode,
+                                      int locked_dir);
+extern int ceph_release(struct inode *inode, struct file *filp);
+extern void ceph_release_page_vector(struct page **pages, int num_pages);
+
+/* dir.c */
+extern const struct file_operations ceph_dir_fops;
+extern const struct inode_operations ceph_dir_iops;
+extern struct dentry_operations ceph_dentry_ops, ceph_snap_dentry_ops,
+       ceph_snapdir_dentry_ops;
+
+extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);
+extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
+                                        struct dentry *dentry, int err);
+
+extern void ceph_dentry_lru_add(struct dentry *dn);
+extern void ceph_dentry_lru_touch(struct dentry *dn);
+extern void ceph_dentry_lru_del(struct dentry *dn);
+
+/*
+ * our d_ops vary depending on whether the inode is live,
+ * snapshotted (read-only), or a virtual ".snap" directory.
+ */
+int ceph_init_dentry(struct dentry *dentry);
+
+
+/* ioctl.c */
+extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+
+/* export.c */
+extern const struct export_operations ceph_export_ops;
+
+/* debugfs.c */
+extern int ceph_debugfs_init(void);
+extern void ceph_debugfs_cleanup(void);
+extern int ceph_debugfs_client_init(struct ceph_client *client);
+extern void ceph_debugfs_client_cleanup(struct ceph_client *client);
+
+static inline struct inode *get_dentry_parent_inode(struct dentry *dentry)
+{
+       if (dentry && dentry->d_parent)
+               return dentry->d_parent->d_inode;
+
+       return NULL;
+}
+
+#endif /* _FS_CEPH_SUPER_H */
diff --git a/fs/ceph/types.h b/fs/ceph/types.h
new file mode 100644 (file)
index 0000000..28b35a0
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef _FS_CEPH_TYPES_H
+#define _FS_CEPH_TYPES_H
+
+/* needed before including ceph_fs.h */
+#include <linux/in.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/string.h>
+
+#include "ceph_fs.h"
+#include "ceph_frag.h"
+#include "ceph_hash.h"
+
+/*
+ * Identify inodes by both their ino AND snapshot id (a u64).
+ */
+struct ceph_vino {
+       u64 ino;
+       u64 snap;
+};
+
+
+/* context for the caps reservation mechanism */
+struct ceph_cap_reservation {
+       int count;
+};
+
+
+#endif
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
new file mode 100644 (file)
index 0000000..2845422
--- /dev/null
@@ -0,0 +1,845 @@
+#include "ceph_debug.h"
+#include "super.h"
+#include "decode.h"
+
+#include <linux/xattr.h>
+#include <linux/slab.h>
+
+static bool ceph_is_valid_xattr(const char *name)
+{
+       return !strncmp(name, XATTR_SECURITY_PREFIX,
+                       XATTR_SECURITY_PREFIX_LEN) ||
+              !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) ||
+              !strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
+}
+
+/*
+ * These define virtual xattrs exposing the recursive directory
+ * statistics and layout metadata.
+ */
+struct ceph_vxattr_cb {
+       bool readonly;
+       char *name;
+       size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
+                             size_t size);
+};
+
+/* directories */
+
+static size_t ceph_vxattrcb_entries(struct ceph_inode_info *ci, char *val,
+                                       size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_files + ci->i_subdirs);
+}
+
+static size_t ceph_vxattrcb_files(struct ceph_inode_info *ci, char *val,
+                                     size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_files);
+}
+
+static size_t ceph_vxattrcb_subdirs(struct ceph_inode_info *ci, char *val,
+                                       size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_subdirs);
+}
+
+static size_t ceph_vxattrcb_rentries(struct ceph_inode_info *ci, char *val,
+                                        size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_rfiles + ci->i_rsubdirs);
+}
+
+static size_t ceph_vxattrcb_rfiles(struct ceph_inode_info *ci, char *val,
+                                      size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_rfiles);
+}
+
+static size_t ceph_vxattrcb_rsubdirs(struct ceph_inode_info *ci, char *val,
+                                        size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_rsubdirs);
+}
+
+static size_t ceph_vxattrcb_rbytes(struct ceph_inode_info *ci, char *val,
+                                      size_t size)
+{
+       return snprintf(val, size, "%lld", ci->i_rbytes);
+}
+
+static size_t ceph_vxattrcb_rctime(struct ceph_inode_info *ci, char *val,
+                                      size_t size)
+{
+       return snprintf(val, size, "%ld.%ld", (long)ci->i_rctime.tv_sec,
+                       (long)ci->i_rctime.tv_nsec);
+}
+
+static struct ceph_vxattr_cb ceph_dir_vxattrs[] = {
+       { true, "user.ceph.dir.entries", ceph_vxattrcb_entries},
+       { true, "user.ceph.dir.files", ceph_vxattrcb_files},
+       { true, "user.ceph.dir.subdirs", ceph_vxattrcb_subdirs},
+       { true, "user.ceph.dir.rentries", ceph_vxattrcb_rentries},
+       { true, "user.ceph.dir.rfiles", ceph_vxattrcb_rfiles},
+       { true, "user.ceph.dir.rsubdirs", ceph_vxattrcb_rsubdirs},
+       { true, "user.ceph.dir.rbytes", ceph_vxattrcb_rbytes},
+       { true, "user.ceph.dir.rctime", ceph_vxattrcb_rctime},
+       { true, NULL, NULL }
+};
+
+/* files */
+
+static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
+                                  size_t size)
+{
+       int ret;
+
+       ret = snprintf(val, size,
+               "chunk_bytes=%lld\nstripe_count=%lld\nobject_size=%lld\n",
+               (unsigned long long)ceph_file_layout_su(ci->i_layout),
+               (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
+               (unsigned long long)ceph_file_layout_object_size(ci->i_layout));
+       if (ceph_file_layout_pg_preferred(ci->i_layout))
+               ret += snprintf(val + ret, size, "preferred_osd=%lld\n",
+                           (unsigned long long)ceph_file_layout_pg_preferred(
+                                   ci->i_layout));
+       return ret;
+}
+
+static struct ceph_vxattr_cb ceph_file_vxattrs[] = {
+       { true, "user.ceph.layout", ceph_vxattrcb_layout},
+       { NULL, NULL }
+};
+
+static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)
+{
+       if (S_ISDIR(inode->i_mode))
+               return ceph_dir_vxattrs;
+       else if (S_ISREG(inode->i_mode))
+               return ceph_file_vxattrs;
+       return NULL;
+}
+
+static struct ceph_vxattr_cb *ceph_match_vxattr(struct ceph_vxattr_cb *vxattr,
+                                               const char *name)
+{
+       do {
+               if (strcmp(vxattr->name, name) == 0)
+                       return vxattr;
+               vxattr++;
+       } while (vxattr->name);
+       return NULL;
+}
+
+static int __set_xattr(struct ceph_inode_info *ci,
+                          const char *name, int name_len,
+                          const char *val, int val_len,
+                          int dirty,
+                          int should_free_name, int should_free_val,
+                          struct ceph_inode_xattr **newxattr)
+{
+       struct rb_node **p;
+       struct rb_node *parent = NULL;
+       struct ceph_inode_xattr *xattr = NULL;
+       int c;
+       int new = 0;
+
+       p = &ci->i_xattrs.index.rb_node;
+       while (*p) {
+               parent = *p;
+               xattr = rb_entry(parent, struct ceph_inode_xattr, node);
+               c = strncmp(name, xattr->name, min(name_len, xattr->name_len));
+               if (c < 0)
+                       p = &(*p)->rb_left;
+               else if (c > 0)
+                       p = &(*p)->rb_right;
+               else {
+                       if (name_len == xattr->name_len)
+                               break;
+                       else if (name_len < xattr->name_len)
+                               p = &(*p)->rb_left;
+                       else
+                               p = &(*p)->rb_right;
+               }
+               xattr = NULL;
+       }
+
+       if (!xattr) {
+               new = 1;
+               xattr = *newxattr;
+               xattr->name = name;
+               xattr->name_len = name_len;
+               xattr->should_free_name = should_free_name;
+
+               ci->i_xattrs.count++;
+               dout("__set_xattr count=%d\n", ci->i_xattrs.count);
+       } else {
+               kfree(*newxattr);
+               *newxattr = NULL;
+               if (xattr->should_free_val)
+                       kfree((void *)xattr->val);
+
+               if (should_free_name) {
+                       kfree((void *)name);
+                       name = xattr->name;
+               }
+               ci->i_xattrs.names_size -= xattr->name_len;
+               ci->i_xattrs.vals_size -= xattr->val_len;
+       }
+       if (!xattr) {
+               pr_err("__set_xattr ENOMEM on %p %llx.%llx xattr %s=%s\n",
+                      &ci->vfs_inode, ceph_vinop(&ci->vfs_inode), name,
+                      xattr->val);
+               return -ENOMEM;
+       }
+       ci->i_xattrs.names_size += name_len;
+       ci->i_xattrs.vals_size += val_len;
+       if (val)
+               xattr->val = val;
+       else
+               xattr->val = "";
+
+       xattr->val_len = val_len;
+       xattr->dirty = dirty;
+       xattr->should_free_val = (val && should_free_val);
+
+       if (new) {
+               rb_link_node(&xattr->node, parent, p);
+               rb_insert_color(&xattr->node, &ci->i_xattrs.index);
+               dout("__set_xattr_val p=%p\n", p);
+       }
+
+       dout("__set_xattr_val added %llx.%llx xattr %p %s=%.*s\n",
+            ceph_vinop(&ci->vfs_inode), xattr, name, val_len, val);
+
+       return 0;
+}
+
+static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
+                          const char *name)
+{
+       struct rb_node **p;
+       struct rb_node *parent = NULL;
+       struct ceph_inode_xattr *xattr = NULL;
+       int c;
+
+       p = &ci->i_xattrs.index.rb_node;
+       while (*p) {
+               parent = *p;
+               xattr = rb_entry(parent, struct ceph_inode_xattr, node);
+               c = strncmp(name, xattr->name, xattr->name_len);
+               if (c < 0)
+                       p = &(*p)->rb_left;
+               else if (c > 0)
+                       p = &(*p)->rb_right;
+               else {
+                       dout("__get_xattr %s: found %.*s\n", name,
+                            xattr->val_len, xattr->val);
+                       return xattr;
+               }
+       }
+
+       dout("__get_xattr %s: not found\n", name);
+
+       return NULL;
+}
+
+static void __free_xattr(struct ceph_inode_xattr *xattr)
+{
+       BUG_ON(!xattr);
+
+       if (xattr->should_free_name)
+               kfree((void *)xattr->name);
+       if (xattr->should_free_val)
+               kfree((void *)xattr->val);
+
+       kfree(xattr);
+}
+
+static int __remove_xattr(struct ceph_inode_info *ci,
+                         struct ceph_inode_xattr *xattr)
+{
+       if (!xattr)
+               return -EOPNOTSUPP;
+
+       rb_erase(&xattr->node, &ci->i_xattrs.index);
+
+       if (xattr->should_free_name)
+               kfree((void *)xattr->name);
+       if (xattr->should_free_val)
+               kfree((void *)xattr->val);
+
+       ci->i_xattrs.names_size -= xattr->name_len;
+       ci->i_xattrs.vals_size -= xattr->val_len;
+       ci->i_xattrs.count--;
+       kfree(xattr);
+
+       return 0;
+}
+
+static int __remove_xattr_by_name(struct ceph_inode_info *ci,
+                          const char *name)
+{
+       struct rb_node **p;
+       struct ceph_inode_xattr *xattr;
+       int err;
+
+       p = &ci->i_xattrs.index.rb_node;
+       xattr = __get_xattr(ci, name);
+       err = __remove_xattr(ci, xattr);
+       return err;
+}
+
+static char *__copy_xattr_names(struct ceph_inode_info *ci,
+                               char *dest)
+{
+       struct rb_node *p;
+       struct ceph_inode_xattr *xattr = NULL;
+
+       p = rb_first(&ci->i_xattrs.index);
+       dout("__copy_xattr_names count=%d\n", ci->i_xattrs.count);
+
+       while (p) {
+               xattr = rb_entry(p, struct ceph_inode_xattr, node);
+               memcpy(dest, xattr->name, xattr->name_len);
+               dest[xattr->name_len] = '\0';
+
+               dout("dest=%s %p (%s) (%d/%d)\n", dest, xattr, xattr->name,
+                    xattr->name_len, ci->i_xattrs.names_size);
+
+               dest += xattr->name_len + 1;
+               p = rb_next(p);
+       }
+
+       return dest;
+}
+
+void __ceph_destroy_xattrs(struct ceph_inode_info *ci)
+{
+       struct rb_node *p, *tmp;
+       struct ceph_inode_xattr *xattr = NULL;
+
+       p = rb_first(&ci->i_xattrs.index);
+
+       dout("__ceph_destroy_xattrs p=%p\n", p);
+
+       while (p) {
+               xattr = rb_entry(p, struct ceph_inode_xattr, node);
+               tmp = p;
+               p = rb_next(tmp);
+               dout("__ceph_destroy_xattrs next p=%p (%.*s)\n", p,
+                    xattr->name_len, xattr->name);
+               rb_erase(tmp, &ci->i_xattrs.index);
+
+               __free_xattr(xattr);
+       }
+
+       ci->i_xattrs.names_size = 0;
+       ci->i_xattrs.vals_size = 0;
+       ci->i_xattrs.index_version = 0;
+       ci->i_xattrs.count = 0;
+       ci->i_xattrs.index = RB_ROOT;
+}
+
+static int __build_xattrs(struct inode *inode)
+{
+       u32 namelen;
+       u32 numattr = 0;
+       void *p, *end;
+       u32 len;
+       const char *name, *val;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       int xattr_version;
+       struct ceph_inode_xattr **xattrs = NULL;
+       int err = 0;
+       int i;
+
+       dout("__build_xattrs() len=%d\n",
+            ci->i_xattrs.blob ? (int)ci->i_xattrs.blob->vec.iov_len : 0);
+
+       if (ci->i_xattrs.index_version >= ci->i_xattrs.version)
+               return 0; /* already built */
+
+       __ceph_destroy_xattrs(ci);
+
+start:
+       /* updated internal xattr rb tree */
+       if (ci->i_xattrs.blob && ci->i_xattrs.blob->vec.iov_len > 4) {
+               p = ci->i_xattrs.blob->vec.iov_base;
+               end = p + ci->i_xattrs.blob->vec.iov_len;
+               ceph_decode_32_safe(&p, end, numattr, bad);
+               xattr_version = ci->i_xattrs.version;
+               spin_unlock(&inode->i_lock);
+
+               xattrs = kcalloc(numattr, sizeof(struct ceph_xattr *),
+                                GFP_NOFS);
+               err = -ENOMEM;
+               if (!xattrs)
+                       goto bad_lock;
+               memset(xattrs, 0, numattr*sizeof(struct ceph_xattr *));
+               for (i = 0; i < numattr; i++) {
+                       xattrs[i] = kmalloc(sizeof(struct ceph_inode_xattr),
+                                           GFP_NOFS);
+                       if (!xattrs[i])
+                               goto bad_lock;
+               }
+
+               spin_lock(&inode->i_lock);
+               if (ci->i_xattrs.version != xattr_version) {
+                       /* lost a race, retry */
+                       for (i = 0; i < numattr; i++)
+                               kfree(xattrs[i]);
+                       kfree(xattrs);
+                       goto start;
+               }
+               err = -EIO;
+               while (numattr--) {
+                       ceph_decode_32_safe(&p, end, len, bad);
+                       namelen = len;
+                       name = p;
+                       p += len;
+                       ceph_decode_32_safe(&p, end, len, bad);
+                       val = p;
+                       p += len;
+
+                       err = __set_xattr(ci, name, namelen, val, len,
+                                         0, 0, 0, &xattrs[numattr]);
+
+                       if (err < 0)
+                               goto bad;
+               }
+               kfree(xattrs);
+       }
+       ci->i_xattrs.index_version = ci->i_xattrs.version;
+       ci->i_xattrs.dirty = false;
+
+       return err;
+bad_lock:
+       spin_lock(&inode->i_lock);
+bad:
+       if (xattrs) {
+               for (i = 0; i < numattr; i++)
+                       kfree(xattrs[i]);
+               kfree(xattrs);
+       }
+       ci->i_xattrs.names_size = 0;
+       return err;
+}
+
+static int __get_required_blob_size(struct ceph_inode_info *ci, int name_size,
+                                   int val_size)
+{
+       /*
+        * 4 bytes for the length, and additional 4 bytes per each xattr name,
+        * 4 bytes per each value
+        */
+       int size = 4 + ci->i_xattrs.count*(4 + 4) +
+                            ci->i_xattrs.names_size +
+                            ci->i_xattrs.vals_size;
+       dout("__get_required_blob_size c=%d names.size=%d vals.size=%d\n",
+            ci->i_xattrs.count, ci->i_xattrs.names_size,
+            ci->i_xattrs.vals_size);
+
+       if (name_size)
+               size += 4 + 4 + name_size + val_size;
+
+       return size;
+}
+
+/*
+ * If there are dirty xattrs, reencode xattrs into the prealloc_blob
+ * and swap into place.
+ */
+void __ceph_build_xattrs_blob(struct ceph_inode_info *ci)
+{
+       struct rb_node *p;
+       struct ceph_inode_xattr *xattr = NULL;
+       void *dest;
+
+       dout("__build_xattrs_blob %p\n", &ci->vfs_inode);
+       if (ci->i_xattrs.dirty) {
+               int need = __get_required_blob_size(ci, 0, 0);
+
+               BUG_ON(need > ci->i_xattrs.prealloc_blob->alloc_len);
+
+               p = rb_first(&ci->i_xattrs.index);
+               dest = ci->i_xattrs.prealloc_blob->vec.iov_base;
+
+               ceph_encode_32(&dest, ci->i_xattrs.count);
+               while (p) {
+                       xattr = rb_entry(p, struct ceph_inode_xattr, node);
+
+                       ceph_encode_32(&dest, xattr->name_len);
+                       memcpy(dest, xattr->name, xattr->name_len);
+                       dest += xattr->name_len;
+                       ceph_encode_32(&dest, xattr->val_len);
+                       memcpy(dest, xattr->val, xattr->val_len);
+                       dest += xattr->val_len;
+
+                       p = rb_next(p);
+               }
+
+               /* adjust buffer len; it may be larger than we need */
+               ci->i_xattrs.prealloc_blob->vec.iov_len =
+                       dest - ci->i_xattrs.prealloc_blob->vec.iov_base;
+
+               if (ci->i_xattrs.blob)
+                       ceph_buffer_put(ci->i_xattrs.blob);
+               ci->i_xattrs.blob = ci->i_xattrs.prealloc_blob;
+               ci->i_xattrs.prealloc_blob = NULL;
+               ci->i_xattrs.dirty = false;
+       }
+}
+
+ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
+                     size_t size)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
+       int err;
+       struct ceph_inode_xattr *xattr;
+       struct ceph_vxattr_cb *vxattr = NULL;
+
+       if (!ceph_is_valid_xattr(name))
+               return -ENODATA;
+
+       /* let's see if a virtual xattr was requested */
+       if (vxattrs)
+               vxattr = ceph_match_vxattr(vxattrs, name);
+
+       spin_lock(&inode->i_lock);
+       dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
+            ci->i_xattrs.version, ci->i_xattrs.index_version);
+
+       if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1) &&
+           (ci->i_xattrs.index_version >= ci->i_xattrs.version)) {
+               goto get_xattr;
+       } else {
+               spin_unlock(&inode->i_lock);
+               /* get xattrs from mds (if we don't already have them) */
+               err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR);
+               if (err)
+                       return err;
+       }
+
+       spin_lock(&inode->i_lock);
+
+       if (vxattr && vxattr->readonly) {
+               err = vxattr->getxattr_cb(ci, value, size);
+               goto out;
+       }
+
+       err = __build_xattrs(inode);
+       if (err < 0)
+               goto out;
+
+get_xattr:
+       err = -ENODATA;  /* == ENOATTR */
+       xattr = __get_xattr(ci, name);
+       if (!xattr) {
+               if (vxattr)
+                       err = vxattr->getxattr_cb(ci, value, size);
+               goto out;
+       }
+
+       err = -ERANGE;
+       if (size && size < xattr->val_len)
+               goto out;
+
+       err = xattr->val_len;
+       if (size == 0)
+               goto out;
+
+       memcpy(value, xattr->val, xattr->val_len);
+
+out:
+       spin_unlock(&inode->i_lock);
+       return err;
+}
+
+ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
+       u32 vir_namelen = 0;
+       u32 namelen;
+       int err;
+       u32 len;
+       int i;
+
+       spin_lock(&inode->i_lock);
+       dout("listxattr %p ver=%lld index_ver=%lld\n", inode,
+            ci->i_xattrs.version, ci->i_xattrs.index_version);
+
+       if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1) &&
+           (ci->i_xattrs.index_version > ci->i_xattrs.version)) {
+               goto list_xattr;
+       } else {
+               spin_unlock(&inode->i_lock);
+               err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR);
+               if (err)
+                       return err;
+       }
+
+       spin_lock(&inode->i_lock);
+
+       err = __build_xattrs(inode);
+       if (err < 0)
+               goto out;
+
+list_xattr:
+       vir_namelen = 0;
+       /* include virtual dir xattrs */
+       if (vxattrs)
+               for (i = 0; vxattrs[i].name; i++)
+                       vir_namelen += strlen(vxattrs[i].name) + 1;
+       /* adding 1 byte per each variable due to the null termination */
+       namelen = vir_namelen + ci->i_xattrs.names_size + ci->i_xattrs.count;
+       err = -ERANGE;
+       if (size && namelen > size)
+               goto out;
+
+       err = namelen;
+       if (size == 0)
+               goto out;
+
+       names = __copy_xattr_names(ci, names);
+
+       /* virtual xattr names, too */
+       if (vxattrs)
+               for (i = 0; vxattrs[i].name; i++) {
+                       len = sprintf(names, "%s", vxattrs[i].name);
+                       names += len + 1;
+               }
+
+out:
+       spin_unlock(&inode->i_lock);
+       return err;
+}
+
+static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
+                             const char *value, size_t size, int flags)
+{
+       struct ceph_client *client = ceph_client(dentry->d_sb);
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct inode *parent_inode = dentry->d_parent->d_inode;
+       struct ceph_mds_request *req;
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       int err;
+       int i, nr_pages;
+       struct page **pages = NULL;
+       void *kaddr;
+
+       /* copy value into some pages */
+       nr_pages = calc_pages_for(0, size);
+       if (nr_pages) {
+               pages = kmalloc(sizeof(pages[0])*nr_pages, GFP_NOFS);
+               if (!pages)
+                       return -ENOMEM;
+               err = -ENOMEM;
+               for (i = 0; i < nr_pages; i++) {
+                       pages[i] = alloc_page(GFP_NOFS);
+                       if (!pages[i]) {
+                               nr_pages = i;
+                               goto out;
+                       }
+                       kaddr = kmap(pages[i]);
+                       memcpy(kaddr, value + i*PAGE_CACHE_SIZE,
+                              min(PAGE_CACHE_SIZE, size-i*PAGE_CACHE_SIZE));
+               }
+       }
+
+       dout("setxattr value=%.*s\n", (int)size, value);
+
+       /* do request */
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR,
+                                      USE_AUTH_MDS);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto out;
+       }
+       req->r_inode = igrab(inode);
+       req->r_inode_drop = CEPH_CAP_XATTR_SHARED;
+       req->r_num_caps = 1;
+       req->r_args.setxattr.flags = cpu_to_le32(flags);
+       req->r_path2 = kstrdup(name, GFP_NOFS);
+
+       req->r_pages = pages;
+       req->r_num_pages = nr_pages;
+       req->r_data_len = size;
+
+       dout("xattr.ver (before): %lld\n", ci->i_xattrs.version);
+       err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       ceph_mdsc_put_request(req);
+       dout("xattr.ver (after): %lld\n", ci->i_xattrs.version);
+
+out:
+       if (pages) {
+               for (i = 0; i < nr_pages; i++)
+                       __free_page(pages[i]);
+               kfree(pages);
+       }
+       return err;
+}
+
+int ceph_setxattr(struct dentry *dentry, const char *name,
+                 const void *value, size_t size, int flags)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
+       int err;
+       int name_len = strlen(name);
+       int val_len = size;
+       char *newname = NULL;
+       char *newval = NULL;
+       struct ceph_inode_xattr *xattr = NULL;
+       int issued;
+       int required_blob_size;
+
+       if (ceph_snap(inode) != CEPH_NOSNAP)
+               return -EROFS;
+
+       if (!ceph_is_valid_xattr(name))
+               return -EOPNOTSUPP;
+
+       if (vxattrs) {
+               struct ceph_vxattr_cb *vxattr =
+                       ceph_match_vxattr(vxattrs, name);
+               if (vxattr && vxattr->readonly)
+                       return -EOPNOTSUPP;
+       }
+
+       /* preallocate memory for xattr name, value, index node */
+       err = -ENOMEM;
+       newname = kmalloc(name_len + 1, GFP_NOFS);
+       if (!newname)
+               goto out;
+       memcpy(newname, name, name_len + 1);
+
+       if (val_len) {
+               newval = kmalloc(val_len + 1, GFP_NOFS);
+               if (!newval)
+                       goto out;
+               memcpy(newval, value, val_len);
+               newval[val_len] = '\0';
+       }
+
+       xattr = kmalloc(sizeof(struct ceph_inode_xattr), GFP_NOFS);
+       if (!xattr)
+               goto out;
+
+       spin_lock(&inode->i_lock);
+retry:
+       issued = __ceph_caps_issued(ci, NULL);
+       if (!(issued & CEPH_CAP_XATTR_EXCL))
+               goto do_sync;
+       __build_xattrs(inode);
+
+       required_blob_size = __get_required_blob_size(ci, name_len, val_len);
+
+       if (!ci->i_xattrs.prealloc_blob ||
+           required_blob_size > ci->i_xattrs.prealloc_blob->alloc_len) {
+               struct ceph_buffer *blob = NULL;
+
+               spin_unlock(&inode->i_lock);
+               dout(" preaallocating new blob size=%d\n", required_blob_size);
+               blob = ceph_buffer_new(required_blob_size, GFP_NOFS);
+               if (!blob)
+                       goto out;
+               spin_lock(&inode->i_lock);
+               if (ci->i_xattrs.prealloc_blob)
+                       ceph_buffer_put(ci->i_xattrs.prealloc_blob);
+               ci->i_xattrs.prealloc_blob = blob;
+               goto retry;
+       }
+
+       dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
+       err = __set_xattr(ci, newname, name_len, newval,
+                         val_len, 1, 1, 1, &xattr);
+       __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
+       ci->i_xattrs.dirty = true;
+       inode->i_ctime = CURRENT_TIME;
+       spin_unlock(&inode->i_lock);
+
+       return err;
+
+do_sync:
+       spin_unlock(&inode->i_lock);
+       err = ceph_sync_setxattr(dentry, name, value, size, flags);
+out:
+       kfree(newname);
+       kfree(newval);
+       kfree(xattr);
+       return err;
+}
+
+static int ceph_send_removexattr(struct dentry *dentry, const char *name)
+{
+       struct ceph_client *client = ceph_client(dentry->d_sb);
+       struct ceph_mds_client *mdsc = &client->mdsc;
+       struct inode *inode = dentry->d_inode;
+       struct inode *parent_inode = dentry->d_parent->d_inode;
+       struct ceph_mds_request *req;
+       int err;
+
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_RMXATTR,
+                                      USE_AUTH_MDS);
+       if (IS_ERR(req))
+               return PTR_ERR(req);
+       req->r_inode = igrab(inode);
+       req->r_inode_drop = CEPH_CAP_XATTR_SHARED;
+       req->r_num_caps = 1;
+       req->r_path2 = kstrdup(name, GFP_NOFS);
+
+       err = ceph_mdsc_do_request(mdsc, parent_inode, req);
+       ceph_mdsc_put_request(req);
+       return err;
+}
+
+int ceph_removexattr(struct dentry *dentry, const char *name)
+{
+       struct inode *inode = dentry->d_inode;
+       struct ceph_inode_info *ci = ceph_inode(inode);
+       struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
+       int issued;
+       int err;
+
+       if (ceph_snap(inode) != CEPH_NOSNAP)
+               return -EROFS;
+
+       if (!ceph_is_valid_xattr(name))
+               return -EOPNOTSUPP;
+
+       if (vxattrs) {
+               struct ceph_vxattr_cb *vxattr =
+                       ceph_match_vxattr(vxattrs, name);
+               if (vxattr && vxattr->readonly)
+                       return -EOPNOTSUPP;
+       }
+
+       spin_lock(&inode->i_lock);
+       __build_xattrs(inode);
+       issued = __ceph_caps_issued(ci, NULL);
+       dout("removexattr %p issued %s\n", inode, ceph_cap_string(issued));
+
+       if (!(issued & CEPH_CAP_XATTR_EXCL))
+               goto do_sync;
+
+       err = __remove_xattr_by_name(ceph_inode(inode), name);
+       __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
+       ci->i_xattrs.dirty = true;
+       inode->i_ctime = CURRENT_TIME;
+
+       spin_unlock(&inode->i_lock);
+
+       return err;
+do_sync:
+       spin_unlock(&inode->i_lock);
+       err = ceph_send_removexattr(dentry, name);
+       return err;
+}
+
index b1d61d0bdfc778943fb50a6f2a8ff586201ff44b..78e4d2a3a68b7b3ef49921fba13d1475f4e9b5b3 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/dcache.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 #include <linux/vfs.h>
 #include <linux/fs.h>
 #include "cifsglob.h"
index 8ec7736ce954cd63cbe7a1cea7c368d248ad20ba..310d12f69a921c8817decd5198105dbde851d015 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <keys/user-type.h>
 #include <linux/key-type.h>
index 714a542cbafce7f3efbe242339bec3d99a0c929f..d07676bd76d29ee13909ceedccf166faeae68340 100644 (file)
@@ -19,6 +19,7 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include "cifs_unicode.h"
 #include "cifs_uniupr.h"
 #include "cifspdu.h"
index 7dfe0842a6f6046ac590ebdb6b7762b6aad91315..9b716d044bbdcfdf27ea3e9883d47fd47f01f45b 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsacl.h"
index 7efe1745494d10a4968ef09f308af577d6ccc1c9..fbe986430d0c51e8ffd257f4be39348240414355 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifs_debug.h"
index 8c6a03627176bbce7dd94641455111a736b78458..5183bc2a19167690d1b77fbcea0ec21b8518072f 100644 (file)
@@ -312,6 +312,7 @@ cifs_alloc_inode(struct super_block *sb)
        cifs_inode->clientCanCacheRead = false;
        cifs_inode->clientCanCacheAll = false;
        cifs_inode->delete_pending = false;
+       cifs_inode->invalid_mapping = false;
        cifs_inode->vfs_inode.i_blkbits = 14;  /* 2**14 = CIFS_MAX_MSGSIZE */
        cifs_inode->server_eof = 0;
 
@@ -638,7 +639,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
                   setting the revalidate time to zero */
                CIFS_I(file->f_path.dentry->d_inode)->time = 0;
 
-               retval = cifs_revalidate(file->f_path.dentry);
+               retval = cifs_revalidate_file(file);
                if (retval < 0)
                        return (loff_t)retval;
        }
index 78c1b86d55f6fcf3a42eeec70968e9f7efc69b3b..7aa57ecdc43760c798afa5cdd39fe59544ee4cce 100644 (file)
@@ -61,7 +61,8 @@ extern int cifs_mkdir(struct inode *, struct dentry *, int);
 extern int cifs_rmdir(struct inode *, struct dentry *);
 extern int cifs_rename(struct inode *, struct dentry *, struct inode *,
                       struct dentry *);
-extern int cifs_revalidate(struct dentry *);
+extern int cifs_revalidate_file(struct file *filp);
+extern int cifs_revalidate_dentry(struct dentry *);
 extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
 extern int cifs_setattr(struct dentry *, struct iattr *);
 
index a1c817eb291aa6ca2b2fb20ced21f9d9c991ac8c..ecf0ffbe2b6420799149a7721c92a1111c4fa9ba 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include <linux/in.h>
 #include <linux/in6.h>
+#include <linux/slab.h>
 #include <linux/slow-work.h>
 #include "cifs_fs_sb.h"
 #include "cifsacl.h"
@@ -389,6 +390,7 @@ struct cifsInodeInfo {
        bool clientCanCacheRead:1;      /* read oplock */
        bool clientCanCacheAll:1;       /* read and writebehind oplock */
        bool delete_pending:1;          /* DELETE_ON_CLOSE is set */
+       bool invalid_mapping:1;         /* pagecache is invalid */
        u64  server_eof;                /* current file size on server */
        u64  uniqueid;                  /* server inode number */
        struct inode vfs_inode;
index 88e2bc44ac583860e15391041e4c0659e885094f..39e47f46dea5f844b083c2b0a376d6f51112a69b 100644 (file)
@@ -104,10 +104,12 @@ extern void cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr);
 extern struct inode *cifs_iget(struct super_block *sb,
                               struct cifs_fattr *fattr);
 
+extern int cifs_get_file_info(struct file *filp);
 extern int cifs_get_inode_info(struct inode **pinode,
                        const unsigned char *search_path,
                        FILE_ALL_INFO *pfile_info,
                        struct super_block *sb, int xid, const __u16 *pfid);
+extern int cifs_get_file_info_unix(struct file *filp);
 extern int cifs_get_inode_info_unix(struct inode **pinode,
                        const unsigned char *search_path,
                        struct super_block *sb, int xid);
@@ -142,6 +144,8 @@ extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
 extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
                        const __u16 search_handle);
 
+extern int CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon,
+                       u16 netfid, FILE_ALL_INFO *pFindData);
 extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
                        const unsigned char *searchName,
                        FILE_ALL_INFO *findData,
@@ -152,6 +156,8 @@ extern int SMBQueryInformation(const int xid, struct cifsTconInfo *tcon,
                        FILE_ALL_INFO *findData,
                        const struct nls_table *nls_codepage, int remap);
 
+extern int CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon,
+                       u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
 extern int CIFSSMBUnixQPathInfo(const int xid,
                        struct cifsTconInfo *tcon,
                        const unsigned char *searchName,
index 6118358998440791183ce19bd6ead2e7cf0c1d1b..3f4fbd670507dffd3eec9bd3c609ef4aff6429ca 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/vfs.h>
+#include <linux/slab.h>
 #include <linux/posix_acl_xattr.h>
 #include <asm/uaccess.h>
 #include "cifspdu.h"
@@ -500,7 +501,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
        } else if (pSMBr->hdr.WordCount == 13) {
                cERROR(1, ("mount failed, cifs module not built "
                          "with CIFS_WEAK_PW_HASH support"));
-                       rc = -EOPNOTSUPP;
+               rc = -EOPNOTSUPP;
 #endif /* WEAK_PW_HASH */
                goto neg_err_exit;
        } else if (pSMBr->hdr.WordCount != 17) {
@@ -3230,8 +3231,72 @@ QInfRetry:
        return rc;
 }
 
+int
+CIFSSMBQFileInfo(const int xid, struct cifsTconInfo *tcon,
+                u16 netfid, FILE_ALL_INFO *pFindData)
+{
+       struct smb_t2_qfi_req *pSMB = NULL;
+       struct smb_t2_qfi_rsp *pSMBr = NULL;
+       int rc = 0;
+       int bytes_returned;
+       __u16 params, byte_count;
 
+QFileInfoRetry:
+       rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+                     (void **) &pSMBr);
+       if (rc)
+               return rc;
 
+       params = 2 /* level */ + 2 /* fid */;
+       pSMB->t2.TotalDataCount = 0;
+       pSMB->t2.MaxParameterCount = cpu_to_le16(4);
+       /* BB find exact max data count below from sess structure BB */
+       pSMB->t2.MaxDataCount = cpu_to_le16(CIFSMaxBufSize);
+       pSMB->t2.MaxSetupCount = 0;
+       pSMB->t2.Reserved = 0;
+       pSMB->t2.Flags = 0;
+       pSMB->t2.Timeout = 0;
+       pSMB->t2.Reserved2 = 0;
+       pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req,
+                                              Fid) - 4);
+       pSMB->t2.DataCount = 0;
+       pSMB->t2.DataOffset = 0;
+       pSMB->t2.SetupCount = 1;
+       pSMB->t2.Reserved3 = 0;
+       pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
+       byte_count = params + 1 /* pad */ ;
+       pSMB->t2.TotalParameterCount = cpu_to_le16(params);
+       pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount;
+       pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO);
+       pSMB->Pad = 0;
+       pSMB->Fid = netfid;
+       pSMB->hdr.smb_buf_length += byte_count;
+
+       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
+       if (rc) {
+               cFYI(1, ("Send error in QPathInfo = %d", rc));
+       } else {                /* decode response */
+               rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+               if (rc) /* BB add auto retry on EOPNOTSUPP? */
+                       rc = -EIO;
+               else if (pSMBr->ByteCount < 40)
+                       rc = -EIO;      /* bad smb */
+               else if (pFindData) {
+                       __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+                       memcpy((char *) pFindData,
+                              (char *) &pSMBr->hdr.Protocol +
+                              data_offset, sizeof(FILE_ALL_INFO));
+               } else
+                   rc = -ENOMEM;
+       }
+       cifs_buf_release(pSMB);
+       if (rc == -EAGAIN)
+               goto QFileInfoRetry;
+
+       return rc;
+}
 
 int
 CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
@@ -3334,6 +3399,75 @@ QPathInfoRetry:
        return rc;
 }
 
+int
+CIFSSMBUnixQFileInfo(const int xid, struct cifsTconInfo *tcon,
+                u16 netfid, FILE_UNIX_BASIC_INFO *pFindData)
+{
+       struct smb_t2_qfi_req *pSMB = NULL;
+       struct smb_t2_qfi_rsp *pSMBr = NULL;
+       int rc = 0;
+       int bytes_returned;
+       __u16 params, byte_count;
+
+UnixQFileInfoRetry:
+       rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
+                     (void **) &pSMBr);
+       if (rc)
+               return rc;
+
+       params = 2 /* level */ + 2 /* fid */;
+       pSMB->t2.TotalDataCount = 0;
+       pSMB->t2.MaxParameterCount = cpu_to_le16(4);
+       /* BB find exact max data count below from sess structure BB */
+       pSMB->t2.MaxDataCount = cpu_to_le16(CIFSMaxBufSize);
+       pSMB->t2.MaxSetupCount = 0;
+       pSMB->t2.Reserved = 0;
+       pSMB->t2.Flags = 0;
+       pSMB->t2.Timeout = 0;
+       pSMB->t2.Reserved2 = 0;
+       pSMB->t2.ParameterOffset = cpu_to_le16(offsetof(struct smb_t2_qfi_req,
+                                              Fid) - 4);
+       pSMB->t2.DataCount = 0;
+       pSMB->t2.DataOffset = 0;
+       pSMB->t2.SetupCount = 1;
+       pSMB->t2.Reserved3 = 0;
+       pSMB->t2.SubCommand = cpu_to_le16(TRANS2_QUERY_FILE_INFORMATION);
+       byte_count = params + 1 /* pad */ ;
+       pSMB->t2.TotalParameterCount = cpu_to_le16(params);
+       pSMB->t2.ParameterCount = pSMB->t2.TotalParameterCount;
+       pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC);
+       pSMB->Pad = 0;
+       pSMB->Fid = netfid;
+       pSMB->hdr.smb_buf_length += byte_count;
+
+       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
+                        (struct smb_hdr *) pSMBr, &bytes_returned, 0);
+       if (rc) {
+               cFYI(1, ("Send error in QPathInfo = %d", rc));
+       } else {                /* decode response */
+               rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+
+               if (rc || (pSMBr->ByteCount < sizeof(FILE_UNIX_BASIC_INFO))) {
+                       cERROR(1, ("Malformed FILE_UNIX_BASIC_INFO response.\n"
+                                  "Unix Extensions can be disabled on mount "
+                                  "by specifying the nosfu mount option."));
+                       rc = -EIO;      /* bad smb */
+               } else {
+                       __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
+                       memcpy((char *) pFindData,
+                              (char *) &pSMBr->hdr.Protocol +
+                              data_offset,
+                              sizeof(FILE_UNIX_BASIC_INFO));
+               }
+       }
+
+       cifs_buf_release(pSMB);
+       if (rc == -EAGAIN)
+               goto UnixQFileInfoRetry;
+
+       return rc;
+}
+
 int
 CIFSSMBUnixQPathInfo(const int xid, struct cifsTconInfo *tcon,
                     const unsigned char *searchName,
index 45eb6cba793fe70287da57a533275027d8e4053a..d9566bf8f917d00e565038477d59150188474618 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/string.h>
 #include <linux/list.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/ctype.h>
 #include <linux/utsname.h>
index 6ccf7262d1b7c78267263ca7dd1eb6ce3b3b86e2..e9f7ecc2714baf0f16e5ba1dc078b6f399a15dbd 100644 (file)
@@ -739,7 +739,7 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
        int isValid = 1;
 
        if (direntry->d_inode) {
-               if (cifs_revalidate(direntry))
+               if (cifs_revalidate_dentry(direntry))
                        return 0;
        } else {
                cFYI(1, ("neg dentry 0x%p name = %s",
index 87948147d7ece68d64e7218c8331624410ac2196..6f8a0e3fb25b7b4326e6635204ebd8b3b6f5a10f 100644 (file)
@@ -23,6 +23,7 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <linux/slab.h>
 #include <keys/user-type.h>
 #include "dns_resolve.h"
 #include "cifsglob.h"
index 3d8f8a96f5a350a96e732cc65f45bc843ab6f08e..058b390d3da8d02c758f33c6bccddcc7080344f2 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/task_io_accounting_ops.h>
 #include <linux/delay.h>
 #include <linux/mount.h>
+#include <linux/slab.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -219,8 +220,8 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,
                cFYI(1, ("inode unchanged on server"));
        } else {
                if (file->f_path.dentry->d_inode->i_mapping) {
-               /* BB no need to lock inode until after invalidate
-                  since namei code should already have it locked? */
+                       /* BB no need to lock inode until after invalidate
+                       since namei code should already have it locked? */
                        rc = filemap_write_and_wait(file->f_path.dentry->d_inode->i_mapping);
                        if (rc != 0)
                                CIFS_I(file->f_path.dentry->d_inode)->write_behind_rc = rc;
@@ -1890,11 +1891,10 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
 
 int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       struct dentry *dentry = file->f_path.dentry;
        int rc, xid;
 
        xid = GetXid();
-       rc = cifs_revalidate(dentry);
+       rc = cifs_revalidate_file(file);
        if (rc) {
                cFYI(1, ("Validation prior to mmap failed, error=%d", rc));
                FreeXid(xid);
index 8bdbc818164cbc87df5455c92b1d61ac2f915c90..35ec117162134da1e04e31aa58525d88232e1af3 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/fs.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
@@ -77,6 +78,41 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)
        }
 }
 
+/* check inode attributes against fattr. If they don't match, tag the
+ * inode for cache invalidation
+ */
+static void
+cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
+{
+       struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+
+       cFYI(1, ("%s: revalidating inode %llu", __func__, cifs_i->uniqueid));
+
+       if (inode->i_state & I_NEW) {
+               cFYI(1, ("%s: inode %llu is new", __func__, cifs_i->uniqueid));
+               return;
+       }
+
+       /* don't bother with revalidation if we have an oplock */
+       if (cifs_i->clientCanCacheRead) {
+               cFYI(1, ("%s: inode %llu is oplocked", __func__,
+                        cifs_i->uniqueid));
+               return;
+       }
+
+        /* revalidate if mtime or size have changed */
+       if (timespec_equal(&inode->i_mtime, &fattr->cf_mtime) &&
+           cifs_i->server_eof == fattr->cf_eof) {
+               cFYI(1, ("%s: inode %llu is unchanged", __func__,
+                        cifs_i->uniqueid));
+               return;
+       }
+
+       cFYI(1, ("%s: invalidating inode %llu mapping", __func__,
+                cifs_i->uniqueid));
+       cifs_i->invalid_mapping = true;
+}
+
 /* populate an inode with info from a cifs_fattr struct */
 void
 cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
@@ -85,6 +121,8 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
        unsigned long oldtime = cifs_i->time;
 
+       cifs_revalidate_cache(inode, fattr);
+
        inode->i_atime = fattr->cf_atime;
        inode->i_mtime = fattr->cf_mtime;
        inode->i_ctime = fattr->cf_ctime;
@@ -231,6 +269,31 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
        fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
 }
 
+int cifs_get_file_info_unix(struct file *filp)
+{
+       int rc;
+       int xid;
+       FILE_UNIX_BASIC_INFO find_data;
+       struct cifs_fattr fattr;
+       struct inode *inode = filp->f_path.dentry->d_inode;
+       struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+       struct cifsTconInfo *tcon = cifs_sb->tcon;
+       struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
+
+       xid = GetXid();
+       rc = CIFSSMBUnixQFileInfo(xid, tcon, cfile->netfid, &find_data);
+       if (!rc) {
+               cifs_unix_basic_to_fattr(&fattr, &find_data, cifs_sb);
+       } else if (rc == -EREMOTE) {
+               cifs_create_dfs_fattr(&fattr, inode->i_sb);
+               rc = 0;
+       }
+
+       cifs_fattr_to_inode(inode, &fattr);
+       FreeXid(xid);
+       return rc;
+}
+
 int cifs_get_inode_info_unix(struct inode **pinode,
                             const unsigned char *full_path,
                             struct super_block *sb, int xid)
@@ -432,6 +495,47 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
        fattr->cf_gid = cifs_sb->mnt_gid;
 }
 
+int cifs_get_file_info(struct file *filp)
+{
+       int rc;
+       int xid;
+       FILE_ALL_INFO find_data;
+       struct cifs_fattr fattr;
+       struct inode *inode = filp->f_path.dentry->d_inode;
+       struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+       struct cifsTconInfo *tcon = cifs_sb->tcon;
+       struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
+
+       xid = GetXid();
+       rc = CIFSSMBQFileInfo(xid, tcon, cfile->netfid, &find_data);
+       if (rc == -EOPNOTSUPP || rc == -EINVAL) {
+               /*
+                * FIXME: legacy server -- fall back to path-based call?
+                * for now, just skip revalidating and mark inode for
+                * immediate reval.
+                */
+               rc = 0;
+               CIFS_I(inode)->time = 0;
+               goto cgfi_exit;
+       } else if (rc == -EREMOTE) {
+               cifs_create_dfs_fattr(&fattr, inode->i_sb);
+               rc = 0;
+       } else if (rc)
+               goto cgfi_exit;
+
+       /*
+        * don't bother with SFU junk here -- just mark inode as needing
+        * revalidation.
+        */
+       cifs_all_info_to_fattr(&fattr, &find_data, cifs_sb, false);
+       fattr.cf_uniqueid = CIFS_I(inode)->uniqueid;
+       fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
+       cifs_fattr_to_inode(inode, &fattr);
+cgfi_exit:
+       FreeXid(xid);
+       return rc;
+}
+
 int cifs_get_inode_info(struct inode **pinode,
        const unsigned char *full_path, FILE_ALL_INFO *pfindData,
        struct super_block *sb, int xid, const __u16 *pfid)
@@ -1389,135 +1493,103 @@ cifs_rename_exit:
        return rc;
 }
 
-int cifs_revalidate(struct dentry *direntry)
+static bool
+cifs_inode_needs_reval(struct inode *inode)
 {
-       int xid;
-       int rc = 0, wbrc = 0;
-       char *full_path;
-       struct cifs_sb_info *cifs_sb;
-       struct cifsInodeInfo *cifsInode;
-       loff_t local_size;
-       struct timespec local_mtime;
-       bool invalidate_inode = false;
+       struct cifsInodeInfo *cifs_i = CIFS_I(inode);
 
-       if (direntry->d_inode == NULL)
-               return -ENOENT;
+       if (cifs_i->clientCanCacheRead)
+               return false;
 
-       cifsInode = CIFS_I(direntry->d_inode);
+       if (!lookupCacheEnabled)
+               return true;
 
-       if (cifsInode == NULL)
-               return -ENOENT;
+       if (cifs_i->time == 0)
+               return true;
 
-       /* no sense revalidating inode info on file that no one can write */
-       if (CIFS_I(direntry->d_inode)->clientCanCacheRead)
-               return rc;
+       /* FIXME: the actimeo should be tunable */
+       if (time_after_eq(jiffies, cifs_i->time + HZ))
+               return true;
+
+       return false;
+}
+
+/* check invalid_mapping flag and zap the cache if it's set */
+static void
+cifs_invalidate_mapping(struct inode *inode)
+{
+       int rc;
+       struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+
+       cifs_i->invalid_mapping = false;
+
+       /* write back any cached data */
+       if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
+               rc = filemap_write_and_wait(inode->i_mapping);
+               if (rc)
+                       cifs_i->write_behind_rc = rc;
+       }
+       invalidate_remote_inode(inode);
+}
+
+int cifs_revalidate_file(struct file *filp)
+{
+       int rc = 0;
+       struct inode *inode = filp->f_path.dentry->d_inode;
+
+       if (!cifs_inode_needs_reval(inode))
+               goto check_inval;
+
+       if (CIFS_SB(inode->i_sb)->tcon->unix_ext)
+               rc = cifs_get_file_info_unix(filp);
+       else
+               rc = cifs_get_file_info(filp);
+
+check_inval:
+       if (CIFS_I(inode)->invalid_mapping)
+               cifs_invalidate_mapping(inode);
+
+       return rc;
+}
+
+/* revalidate a dentry's inode attributes */
+int cifs_revalidate_dentry(struct dentry *dentry)
+{
+       int xid;
+       int rc = 0;
+       char *full_path = NULL;
+       struct inode *inode = dentry->d_inode;
+       struct super_block *sb = dentry->d_sb;
+
+       if (inode == NULL)
+               return -ENOENT;
 
        xid = GetXid();
 
-       cifs_sb = CIFS_SB(direntry->d_sb);
+       if (!cifs_inode_needs_reval(inode))
+               goto check_inval;
 
        /* can not safely grab the rename sem here if rename calls revalidate
           since that would deadlock */
-       full_path = build_path_from_dentry(direntry);
+       full_path = build_path_from_dentry(dentry);
        if (full_path == NULL) {
                rc = -ENOMEM;
-               FreeXid(xid);
-               return rc;
-       }
-       cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
-                "jiffies %ld", full_path, direntry->d_inode,
-                direntry->d_inode->i_count.counter, direntry,
-                direntry->d_time, jiffies));
-
-       if (cifsInode->time == 0) {
-               /* was set to zero previously to force revalidate */
-       } else if (time_before(jiffies, cifsInode->time + HZ) &&
-                  lookupCacheEnabled) {
-               if ((S_ISREG(direntry->d_inode->i_mode) == 0) ||
-                   (direntry->d_inode->i_nlink == 1)) {
-                       kfree(full_path);
-                       FreeXid(xid);
-                       return rc;
-               } else {
-                       cFYI(1, ("Have to revalidate file due to hardlinks"));
-               }
-       }
-
-       /* save mtime and size */
-       local_mtime = direntry->d_inode->i_mtime;
-       local_size = direntry->d_inode->i_size;
-
-       if (cifs_sb->tcon->unix_ext) {
-               rc = cifs_get_inode_info_unix(&direntry->d_inode, full_path,
-                                             direntry->d_sb, xid);
-               if (rc) {
-                       cFYI(1, ("error on getting revalidate info %d", rc));
-/*                     if (rc != -ENOENT)
-                               rc = 0; */      /* BB should we cache info on
-                                                  certain errors? */
-               }
-       } else {
-               rc = cifs_get_inode_info(&direntry->d_inode, full_path, NULL,
-                                        direntry->d_sb, xid, NULL);
-               if (rc) {
-                       cFYI(1, ("error on getting revalidate info %d", rc));
-/*                     if (rc != -ENOENT)
-                               rc = 0; */      /* BB should we cache info on
-                                                  certain errors? */
-               }
+               goto check_inval;
        }
-       /* should we remap certain errors, access denied?, to zero */
 
-       /* if not oplocked, we invalidate inode pages if mtime or file size
-          had changed on server */
+       cFYI(1, ("Revalidate: %s inode 0x%p count %d dentry: 0x%p d_time %ld "
+                "jiffies %ld", full_path, inode, inode->i_count.counter,
+                dentry, dentry->d_time, jiffies));
 
-       if (timespec_equal(&local_mtime, &direntry->d_inode->i_mtime) &&
-           (local_size == direntry->d_inode->i_size)) {
-               cFYI(1, ("cifs_revalidate - inode unchanged"));
-       } else {
-               /* file may have changed on server */
-               if (cifsInode->clientCanCacheRead) {
-                       /* no need to invalidate inode pages since we were the
-                          only ones who could have modified the file and the
-                          server copy is staler than ours */
-               } else {
-                       invalidate_inode = true;
-               }
-       }
+       if (CIFS_SB(sb)->tcon->unix_ext)
+               rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
+       else
+               rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
+                                        xid, NULL);
 
-       /* can not grab this sem since kernel filesys locking documentation
-          indicates i_mutex may be taken by the kernel on lookup and rename
-          which could deadlock if we grab the i_mutex here as well */
-/*     mutex_lock(&direntry->d_inode->i_mutex);*/
-       /* need to write out dirty pages here  */
-       if (direntry->d_inode->i_mapping) {
-               /* do we need to lock inode until after invalidate completes
-                  below? */
-               wbrc = filemap_fdatawrite(direntry->d_inode->i_mapping);
-               if (wbrc)
-                       CIFS_I(direntry->d_inode)->write_behind_rc = wbrc;
-       }
-       if (invalidate_inode) {
-       /* shrink_dcache not necessary now that cifs dentry ops
-       are exported for negative dentries */
-/*             if (S_ISDIR(direntry->d_inode->i_mode))
-                       shrink_dcache_parent(direntry); */
-               if (S_ISREG(direntry->d_inode->i_mode)) {
-                       if (direntry->d_inode->i_mapping) {
-                               wbrc = filemap_fdatawait(direntry->d_inode->i_mapping);
-                               if (wbrc)
-                                       CIFS_I(direntry->d_inode)->write_behind_rc = wbrc;
-                       }
-                       /* may eventually have to do this for open files too */
-                       if (list_empty(&(cifsInode->openFileList))) {
-                               /* changed on server - flush read ahead pages */
-                               cFYI(1, ("Invalidating read ahead data on "
-                                        "closed file"));
-                               invalidate_remote_inode(direntry->d_inode);
-                       }
-               }
-       }
-/*     mutex_unlock(&direntry->d_inode->i_mutex); */
+check_inval:
+       if (CIFS_I(inode)->invalid_mapping)
+               cifs_invalidate_mapping(inode);
 
        kfree(full_path);
        FreeXid(xid);
@@ -1527,7 +1599,7 @@ int cifs_revalidate(struct dentry *direntry)
 int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
        struct kstat *stat)
 {
-       int err = cifs_revalidate(dentry);
+       int err = cifs_revalidate_dentry(dentry);
        if (!err) {
                generic_fillattr(dentry->d_inode, stat);
                stat->blksize = CIFS_MAX_MSGSIZE;
index fc1e0487eaee3c5a2b0c4fba34e4c532e930e06b..c1a9d4236a8c01493d631391101b78f3ace6fb0e 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/fs.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
index c343b14ba2d3eea99e7de45c7eed87311668e873..18e0bc1fb5931b43796d6276c8fdea6e52c60c75 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <linux/fs.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/stat.h>
 #include "cifspdu.h"
 #include "cifsglob.h"
index aaa9c1c5a5bd243e398b96fe6a278c85595c64c9..7c3fd7463f4415bc64dfc95dfd8e4cfbb1b49f21 100644 (file)
@@ -29,6 +29,7 @@
 #include "ntlmssp.h"
 #include "nterr.h"
 #include <linux/utsname.h>
+#include <linux/slab.h>
 #include "cifs_spnego.h"
 
 extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
index 93fb09a99c690285f466a1d1734b38dd4ef80f46..192ea51af20f49c8976fa734ca44f79e988d7f6b 100644 (file)
@@ -24,6 +24,7 @@
 */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
index 07b8e71544ee254e8941b03680cc8eaf62a20847..ad081fe7eb18b5442a1e1c8289c175e42596bc14 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/fs.h>
 #include <linux/list.h>
+#include <linux/gfp.h>
 #include <linux/wait.h>
 #include <linux/net.h>
 #include <linux/delay.h>
index 3e2ef0de120968e8e8012486f188e2b537590950..f555ce077d4fb759c204c15e6f5c6a833b131603 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/fs.h>
 #include <linux/posix_acl_xattr.h>
+#include <linux/slab.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
 #include "cifsglob.h"
index 4bb9d0a5decc2a7f168a1886a01ef72cec5a5351..ccd98b0f2b0b9c3d37f10b101a86b36572054240 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/time.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
index ffd42815fda1e6a528030c13712a5c7455e28f21..4c813f2cdc52dcaa7074322ffaeb11d34e4c8726 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #include <linux/coda.h>
index 830f51abb97138d20d8dc07c8bc9ffb5e325659e..a1695dcadd999b981b7da03d6226c148a90a46d0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/smp_lock.h>
 #include <linux/file.h>
 #include <linux/vfs.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index c274d949179de383ea86f284e13fa5cd396e77db..f09c5ed76f6cdcafd715ee0c759af45290073094 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/stat.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/vmalloc.h>
 #include <linux/vfs.h>
index 030602d453b76a0a371880a63990a08cd17fd5b0..4b6ed03cc4781b38352846206875cc5ffdfb992d 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/mm.h>
 #include <linux/eventpoll.h>
 #include <linux/fs_struct.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
index 6d55b61bfa7942252944cabf02d90e9418d2d325..c32a1b6a856b483edbbc8c99fdf43ea827186102 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/ioctl.h>
 #include <linux/if.h>
 #include <linux/if_bridge.h>
-#include <linux/slab.h>
 #include <linux/raid/md_u.h>
 #include <linux/kd.h>
 #include <linux/route.h>
@@ -60,6 +59,7 @@
 #include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 #include <linux/atalk.h>
+#include <linux/gfp.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci.h>
index a2f746066c5da12fc8dc3623d47c04592141a055..c8af2d91174b42b6ce33f0bfac759910589be268 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/capability.h>
 #include <linux/sched.h>
 #include <linux/lockdep.h>
+#include <linux/slab.h>
 
 #include <linux/configfs.h>
 #include "configfs_internal.h"
index 8421cea7d8c7b1460b0cfdf90e831a3012ddf803..8c8d64230c2d040d1946444eb33c6533288f6019 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/mount.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <linux/configfs.h>
 #include "configfs_internal.h"
index 32a5f46b11578d2f0b319379cc8f2b940508a2f4..0f3eb41d9201e6884db26cc8cedf6f3b8328dd25 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 
 #include <linux/configfs.h>
 #include "configfs_internal.h"
index 049d6c36da0992eb0e7bbf1938ff5ff2a8d35156..30a87b3dbcac1286de7fa400f6855b2937796d5b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/fsnotify.h>
 #include <linux/string.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 
 static struct vfsmount *debugfs_mount;
 static int debugfs_mount_count;
index 8882ecc0f1bfbec879c7b9c27795ac8b5dd9f63a..0120247b41c0d6661e112fa4e0c34f7eade0a887 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/tty.h>
 #include <linux/mutex.h>
index 0df243850818340c4423fa56ae9264151285c0a1..b54bca03d92f467da2d0e09ef74a341c1cdaa5ce 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/configfs.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <net/ipv6.h>
index 29d6139c35fcc1b3b51f62082a778ec3c5018038..c6cf251587467dc9af1c12c7391c6e529fa4249a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/ctype.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include "dlm_internal.h"
 #include "lock.h"
index 46ffd3eeaaf7350cf1b9b5969722abfe2f9a89b7..17903b491298521839ebfe9c3d6100d225fd6e64 100644 (file)
@@ -56,6 +56,7 @@
    L: receive_xxxx_reply()     <-  R: send_xxxx_reply()
 */
 #include <linux/types.h>
+#include <linux/slab.h>
 #include "dlm_internal.h"
 #include <linux/dlm_device.h>
 #include "memory.h"
index 52cab160893ce0d095e771dd1abe72a4b170162f..c0d35c620526bc0d202dd843867e05b8dbf44c7b 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/file.h>
 #include <linux/mutex.h>
 #include <linux/sctp.h>
+#include <linux/slab.h>
 #include <net/sctp/user.h>
 #include <net/ipv6.h>
 
index 052095cd592f3787ed20f525e1c7c08e0e30378b..2c6ad518100d509d2d0013ff466370a585559986 100644 (file)
@@ -9,6 +9,7 @@
 #include <net/genetlink.h>
 #include <linux/dlm.h>
 #include <linux/dlm_netlink.h>
+#include <linux/gfp.h>
 
 #include "dlm_internal.h"
 
index b5f89aef3b29c88a1447201504a797eb16e93dcb..d45c02db694393a1989119ec510709b653dd76e9 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/poll.h>
 #include <linux/dlm.h>
 #include <linux/dlm_plock.h>
+#include <linux/slab.h>
 
 #include "dlm_internal.h"
 #include "lockspace.h"
index a4bfd31ac45bec4ad5e1010e0ad6a386a338f18b..8b6e73c47435611127ea73ba58d1d8df1fd4ae28 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/spinlock.h>
 #include <linux/dlm.h>
 #include <linux/dlm_device.h>
+#include <linux/slab.h>
 
 #include "dlm_internal.h"
 #include "lockspace.h"
index 7cb0a59f4b9d2e7e6576be83d4787e599f9dd834..efb2b9400391f26c2ebfe242893b5b85adcead0c 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/crypto.h>
 #include <linux/file.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
 
index 8f006a0d6076f3dbe61ce9d2dd956e7b853d0132..906e803f7f79fd5e7e8bc542f5b4be2e91064d67 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/namei.h>
 #include <linux/mount.h>
 #include <linux/fs_stack.h>
+#include <linux/slab.h>
 #include "ecryptfs_kernel.h"
 
 /**
index 678172b61be2a676de90fa8d7e5101e04f566ed4..e7440a6f5ebf0cffb9e9bee7a770b80553e72b15 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/file.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/pagemap.h>
 #include <linux/security.h>
index 4a430ab4115c056851a9a98788417a44751e6205..d3362faf3852e85275ee8cd76ba895c583bc3b88 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/mount.h>
 #include <linux/crypto.h>
 #include <linux/fs_stack.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
 
index a0a7847567e902284d828d53a4731cd5d6326078..89c5476506ef36c8c3de7520565b8360d70eb83b 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/random.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include "ecryptfs_kernel.h"
 
 /**
index e14cf7e588db665d84ee50c10db6323e465d3eb9..d8c3a373aafa40547090427c0ae1e96b73f49dbe 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
+#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/mount.h>
 #include "ecryptfs_kernel.h"
index ea2f92101dfedab1101d98d5a4a8b88010d35897..af1a8f01ebacd854789283267c9ce80688f48b64 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/key.h>
 #include <linux/parser.h>
 #include <linux/fs_stack.h>
+#include <linux/slab.h>
 #include "ecryptfs_kernel.h"
 
 /**
index f1c17e87c5fbc852443f01da834f256f3c33262b..2d8dbce9d485e4a453903eb1f93473c5942155cc 100644 (file)
@@ -20,6 +20,7 @@
  * 02111-1307, USA.
  */
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/user_namespace.h>
 #include <linux/nsproxy.h>
 #include "ecryptfs_kernel.h"
index 4ec8f61ccf5a09d82bd84a67a68aa9e1b25c91d1..3745f612bcd438cb477f8bb245afeb5f47495f89 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/random.h>
 #include <linux/miscdevice.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/module.h>
 #include "ecryptfs_kernel.h"
index df4ce99d0597bb2743dfd3c6b2fccfc807ec55d7..d491237c98e7ee444a8eba24f6ff9b245518a0d1 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/file.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
 
index b15a43a80ab78cc7dbb9e05dedef0dbb0dd0e6ee..fcef41c1d2cf9f129faea2da9837c4f2dd4ac271 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/fs.h>
 #include <linux/mount.h>
 #include <linux/key.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/smp_lock.h>
 #include <linux/file.h>
index 7758cc382ef0a80b56dc6e9687838f3a5d5468c0..6bd3f76fdf881ffc4973bc2d7a0d8346a3464bba 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/anon_inodes.h>
index a17e4b733e35116f2c6bb83960a03680e714efe8..76d2a79ef93e887900928f4dc8115ada961a0e29 100644 (file)
@@ -31,6 +31,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <linux/slab.h>
 #include <linux/writeback.h>
 #include <linux/buffer_head.h>
 #include <scsi/scsi_device.h>
index 5293bc411d17735fcfed8b685e7d3ab9d0e80da4..4337cad7777b13f98c1d428942387d61a8503c4e 100644 (file)
@@ -22,6 +22,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <linux/slab.h>
 #include <scsi/scsi_device.h>
 #include <asm/div64.h>
 
index 6cf5e4e84d6162dcb461eb4a0521023e2142c00a..18e57ea1e5b433b7f99d2cd20387ae111a390fd5 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/vfs.h>
 #include <linux/random.h>
 #include <linux/exportfs.h>
+#include <linux/slab.h>
 
 #include "exofs.h"
 
index 1d081f0cfec2ce13dac7422ad514aaf92c44969e..3cf038c055d7b587290b05bd659624985e9d1056 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "ext2.h"
 #include <linux/quotaops.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
 #include <linux/capability.h>
index c8155845ac0518e8665e122be57fcfe988a9fa56..b118c6383c6d0d05647cf66011eeec4298b1f927 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
index 161da2d3f890e4f2cb854ee7c16b6feb00d27d4a..a177122a1b2584170d609b0282bf1fd094bd86b9 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/time.h>
 #include <linux/capability.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/jbd.h>
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
index ef9008b885b57b81c757f0e79ddf55d0e520a857..0d0e97ed3ff6029659837f1394a4827506eb1704 100644 (file)
@@ -582,7 +582,9 @@ got:
        inode->i_generation = sbi->s_next_generation++;
        spin_unlock(&sbi->s_next_gen_lock);
 
-       ei->i_state = EXT3_STATE_NEW;
+       ei->i_state_flags = 0;
+       ext3_set_inode_state(inode, EXT3_STATE_NEW);
+
        ei->i_extra_isize =
                (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
                sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
index 7f920b7263a4056612d05fea439c5b7c93c7cfe8..ea33bdf0a3004b927c10be9289b21125dcf53c38 100644 (file)
@@ -2811,7 +2811,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
        inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
        inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
 
-       ei->i_state = 0;
+       ei->i_state_flags = 0;
        ei->i_dir_start_lookup = 0;
        ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
        /* We now have enough fields to check if the inode was active or not.
index 474348788dd96ed35fb8ac771509a930212d11c2..3af91f476dff738f36eb5949c6d40487de4386f9 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/ext3_jbd.h>
index 983f0e1274939b4506c91ea23c3c7d38ae624a88..538c48655084594482d94c3ff38e949f4cb6ffd7 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include "ext4.h"
 
 struct ext4_system_zone {
index 361c0b9962a8142b38823e8e9202d0d070c0130b..57f6eef6ccd6c03afbd4c35d0fa364f4e350bbf8 100644 (file)
@@ -263,7 +263,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
                                        ext4_group_t f;
 
                                        f = ext4_flex_group(sbi, block_group);
-                                       atomic_dec(&sbi->s_flex_groups[f].free_inodes);
+                                       atomic_dec(&sbi->s_flex_groups[f].used_dirs);
                                }
 
                        }
@@ -773,7 +773,7 @@ static int ext4_claim_inode(struct super_block *sb,
                if (sbi->s_log_groups_per_flex) {
                        ext4_group_t f = ext4_flex_group(sbi, group);
 
-                       atomic_inc(&sbi->s_flex_groups[f].free_inodes);
+                       atomic_inc(&sbi->s_flex_groups[f].used_dirs);
                }
        }
        gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
index 986120f30066c68b68f7b40906a489cc2870810b..5381802d60523417b25b5885ee90f097e0a23575 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/bio.h>
 #include <linux/workqueue.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "ext4_jbd2.h"
 #include "xattr.h"
@@ -1035,7 +1036,7 @@ static int ext4_indirect_calc_metadata_amount(struct inode *inode,
                                              sector_t lblock)
 {
        struct ext4_inode_info *ei = EXT4_I(inode);
-       int dind_mask = EXT4_ADDR_PER_BLOCK(inode->i_sb) - 1;
+       sector_t dind_mask = ~((sector_t)EXT4_ADDR_PER_BLOCK(inode->i_sb) - 1);
        int blk_bits;
 
        if (lblock < EXT4_NDIR_BLOCKS)
@@ -1050,7 +1051,7 @@ static int ext4_indirect_calc_metadata_amount(struct inode *inode,
        }
        ei->i_da_metadata_calc_last_lblock = lblock & dind_mask;
        ei->i_da_metadata_calc_len = 1;
-       blk_bits = roundup_pow_of_two(lblock + 1);
+       blk_bits = order_base_2(lblock);
        return (blk_bits / EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb)) + 1;
 }
 
index 54df209d2eed5a4d840e2b4b1ee21adff3322eb2..bde9d0b170c2a09dfec9f8d81b6ffe9406c9f384 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "mballoc.h"
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <trace/events/ext4.h>
 
 /*
index 8b87bd0eac954fc292b8644bebe758e03b0ca023..34dcfc52ef44b4f228fc6403460f294dbc13a95b 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include "ext4_jbd2.h"
 #include "ext4_extents.h"
 
index aa5fe28d180f2dedc3950a1e54b0b372462c8d32..d1fc662cc311070c19742a5cb7522f167c8a4774 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/fs.h>
 #include <linux/quotaops.h>
+#include <linux/slab.h>
 #include "ext4_jbd2.h"
 #include "ext4_extents.h"
 #include "ext4.h"
index ba191dae87304e9106940dfe25e8af41573181ca..e14d22c170d542f3d65b7b50065f0256e0c940b3 100644 (file)
@@ -68,7 +68,21 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
 static int ext4_unfreeze(struct super_block *sb);
 static void ext4_write_super(struct super_block *sb);
 static int ext4_freeze(struct super_block *sb);
+static int ext4_get_sb(struct file_system_type *fs_type, int flags,
+                      const char *dev_name, void *data, struct vfsmount *mnt);
 
+#if !defined(CONFIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23)
+static struct file_system_type ext3_fs_type = {
+       .owner          = THIS_MODULE,
+       .name           = "ext3",
+       .get_sb         = ext4_get_sb,
+       .kill_sb        = kill_block_super,
+       .fs_flags       = FS_REQUIRES_DEV,
+};
+#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
+#else
+#define IS_EXT3_SB(sb) (0)
+#endif
 
 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
                               struct ext4_group_desc *bg)
@@ -2539,7 +2553,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
         * enable delayed allocation by default
         * Use -o nodelalloc to turn it off
         */
-       set_opt(sbi->s_mount_opt, DELALLOC);
+       if (!IS_EXT3_SB(sb))
+               set_opt(sbi->s_mount_opt, DELALLOC);
 
        if (!parse_options((char *) data, sb, &journal_devnum,
                           &journal_ioprio, NULL, 0))
@@ -4068,7 +4083,7 @@ static int ext4_get_sb(struct file_system_type *fs_type, int flags,
        return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
 }
 
-#if !defined(CONTIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23)
+#if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23)
 static struct file_system_type ext2_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "ext2",
@@ -4095,15 +4110,7 @@ static inline void register_as_ext2(void) { }
 static inline void unregister_as_ext2(void) { }
 #endif
 
-#if !defined(CONTIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23)
-static struct file_system_type ext3_fs_type = {
-       .owner          = THIS_MODULE,
-       .name           = "ext3",
-       .get_sb         = ext4_get_sb,
-       .kill_sb        = kill_block_super,
-       .fs_flags       = FS_REQUIRES_DEV,
-};
-
+#if !defined(CONFIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23)
 static inline void register_as_ext3(void)
 {
        int err = register_filesystem(&ext3_fs_type);
index 983c253999a7f32965a384ae116aa856f25011ed..8b145e98df0771efc2735e38a151fa605f5a8b6f 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/string.h>
 #include <linux/fs.h>
 #include <linux/security.h>
+#include <linux/slab.h>
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include "xattr.h"
index 923990e4f16e13b4ebc2f9f9435aee64b24633f8..113f0a1e565d17cb1fc4500496f84e966d89fd91 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/buffer_head.h>
 #include "fat.h"
 
index c1ef50154868efd0ce58c3ddca97c04e1a7f1371..6fcc7e71fbaaf0c8f1d21b3cf50fab86d67f50ee 100644 (file)
@@ -309,7 +309,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
 {
        struct fat_mount_options *opts = &MSDOS_SB(dir->i_sb)->options;
        wchar_t *ip, *ext_start, *end, *name_start;
-       unsigned char base[9], ext[4], buf[8], *p;
+       unsigned char base[9], ext[4], buf[5], *p;
        unsigned char charbuf[NLS_MAX_CHARSET_SIZE];
        int chl, chi;
        int sz = 0, extlen, baselen, i, numtail_baselen, numtail2_baselen;
@@ -467,7 +467,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
                        return 0;
        }
 
-       i = jiffies & 0xffff;
+       i = jiffies;
        sz = (jiffies >> 16) & 0x7;
        if (baselen > 2) {
                baselen = numtail2_baselen;
@@ -476,7 +476,7 @@ static int vfat_create_shortname(struct inode *dir, struct nls_table *nls,
        name_res[baselen + 4] = '~';
        name_res[baselen + 5] = '1' + sz;
        while (1) {
-               sprintf(buf, "%04X", i);
+               snprintf(buf, sizeof(buf), "%04X", i & 0xffff);
                memcpy(&name_res[baselen], buf, 4);
                if (vfat_find_form(dir, name_res) < 0)
                        break;
index f8f97b8b6d44c82056a970b549eb3272d457263d..5d6606ffc2d28de7b94c4dc3bb04367ac6a57f93 100644 (file)
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -10,7 +10,6 @@
  */
 
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/pipe_fs_i.h>
index a24c58e181db1624b9df3ba2493f48b7652a8418..68ba492d8eeff968ddecdc1c2fd7c5974961e6d7 100644 (file)
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <linux/slab.h>
 #include <linux/kmod.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 /*
index ed8f0b0dd880087a5cb1135a725b151d4bcd099b..1429f3ae1e868f2cb6f066542c3675d1d09134cd 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 
 #include "vxfs_extern.h"
index 76fc4d594acb4a3c8091531df7ee37f974f192b6..781a322ccb456b926ff2906526645fd8dcd7cfec 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
index 3221a0c7944e32fbe02c5d8c6c759b5766d6ce69..1e1f286dd70eeb0ea7e98b46012e378280e0cf58 100644 (file)
@@ -12,6 +12,7 @@
 #define FSCACHE_DEBUG_LEVEL COOKIE
 #include <linux/module.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/key.h>
 #include <keys/user-type.h>
 #include "internal.h"
index e513ac599c8e9b587c8646e33485be20d2ce1c4e..0b589a9b4ffcf623b9b1544cff596ee24b52cbb0 100644 (file)
@@ -53,7 +53,7 @@ const char fscache_object_states_short[FSCACHE_OBJECT__NSTATES][5] = {
 static void fscache_object_slow_work_put_ref(struct slow_work *);
 static int  fscache_object_slow_work_get_ref(struct slow_work *);
 static void fscache_object_slow_work_execute(struct slow_work *);
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 static void fscache_object_slow_work_desc(struct slow_work *, struct seq_file *);
 #endif
 static void fscache_initialise_object(struct fscache_object *);
@@ -69,7 +69,7 @@ const struct slow_work_ops fscache_object_slow_work_ops = {
        .get_ref        = fscache_object_slow_work_get_ref,
        .put_ref        = fscache_object_slow_work_put_ref,
        .execute        = fscache_object_slow_work_execute,
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        .desc           = fscache_object_slow_work_desc,
 #endif
 };
@@ -364,7 +364,7 @@ static void fscache_object_slow_work_execute(struct slow_work *work)
 /*
  * describe an object for slow-work debugging
  */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 static void fscache_object_slow_work_desc(struct slow_work *work,
                                          struct seq_file *m)
 {
index 313e79a14266e69e2a47aafdffefc89b29f510df..f17cecafae44c1a49665c7e0b865c98693d61f89 100644 (file)
@@ -14,6 +14,7 @@
 #define FSCACHE_DEBUG_LEVEL OPERATION
 #include <linux/module.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 atomic_t fscache_op_debug_id;
@@ -500,7 +501,7 @@ static void fscache_op_execute(struct slow_work *work)
 /*
  * describe an operation for slow-work debugging
  */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 static void fscache_op_desc(struct slow_work *work, struct seq_file *m)
 {
        struct fscache_operation *op =
@@ -517,7 +518,7 @@ const struct slow_work_ops fscache_op_slow_work_ops = {
        .get_ref        = fscache_op_get_ref,
        .put_ref        = fscache_op_put_ref,
        .execute        = fscache_op_execute,
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        .desc           = fscache_op_desc,
 #endif
 };
index c598ea4c4e7d580d9046e1cb8ccb42e1d14db6c6..47aefd376e54060341d15a31ab5cf96a2755a13e 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/fscache-cache.h>
 #include <linux/buffer_head.h>
 #include <linux/pagevec.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 /*
@@ -881,6 +882,7 @@ submit_failed:
        goto nobufs;
 
 nobufs_unlock_obj:
+       spin_unlock(&cookie->stores_lock);
        spin_unlock(&object->lock);
 nobufs:
        spin_unlock(&cookie->lock);
index de792dcf327484c8cf5d8a97e50763d9a5164aeb..e1f8171278bdeac8b5ba7f5b71abfe1d9984c307 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/magic.h>
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/stat.h>
 
index 55458031e501405b06371b04f958323d44e12549..fe5df5457656e43fa2757a37b322c106b63af17f 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/generic_acl.h>
 #include <linux/posix_acl.h>
index 583e823307ae7a17cd58b34027f11cea4e3f6437..5e411d5f4697a2ce2912aa917106a47acc3829b6 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index 91beddadd38876367d5163ad0b73617d023b158c..bb7907bde3d81b63b6ae5b198283a52db36e97b0 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index d15876e9aa26c42292ab9b836661a8b692c89c2a..c22c2117483365abed04aba0165df3b2d03b65f3 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index 38e3749d476ce04afa59bd416e3ff190388afcb7..49f97d3bb690c512cb0f338d85938e622d501a49 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index 569b46240f613c1a17e4ff0653c1bb53dc59cfe1..0e0470ed34c273a341aed5860191bfadf42b41e5 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/fs.h>
 #include <linux/dlm.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/gfs2_ondisk.h>
 
index b4106ddaaa98219362c23addea091d2ea582d53f..f07119d89557855fc9a8673b32e9119cad921570 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __RGRP_DOT_H__
 #define __RGRP_DOT_H__
 
+#include <linux/slab.h>
+
 struct gfs2_rgrpd;
 struct gfs2_sbd;
 struct gfs2_holder;
index 419042f7f0b6d14d21da858504775856657e58ea..54fd9842599169a3551d8b57d292164406a74480 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index 226f2bfbf16abe9dbc6d6bf972f2c88014f3da48..53511291fe3661363144b55156c7f4eac4312c58 100644 (file)
@@ -7,7 +7,6 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
index 0d200068d0afaff014db5279d46c74dab06332bb..cdb41a1f6a646bd957fdfa2cf2b835d2078d9731 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 
 #include "btree.h"
index 052f214ea6f0c39657d4cfb84e3eb96f7a391818..38a0a9917d7f3a67b0eaad49a75246430eef7d76 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/log2.h>
 
 #include "btree.h"
index 8bbe03c3f6d54e5286ff3c0c0cce4e6c5f653134..86428f5ac991c59dd46a088b25cffe12b5a13dee 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/cdrom.h>
 #include <linux/genhd.h>
 #include <linux/nls.h>
+#include <linux/slab.h>
 
 #include "hfs_fs.h"
 #include "btree.h"
index 5ed7252b7b23246aabdb015341ba19cbb101379a..0a81eb7111f3505600b626e1c88145692aa8c725 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/nls.h>
 #include <linux/parser.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/vfs.h>
 
index 3fcbb0e1f6fc09ea43f1918d4099f695937b0db1..572628b4b07d23af08f98ca7b757c85acfbcbc0c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/nls.h>
 #include <linux/mount.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "hfsplus_fs.h"
 
 enum {
index 032604e5ef2ca36b1f9171d4fc2a775e9bcd7074..3a029d8f4cf1d564f0e64c7f1ead796a193769d5 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/statfs.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/mount.h>
 #include "hostfs.h"
index b6fca543544c5acd63907d9227331178489d8256..eac5f96323e3d9640a197ee5eb10acdbf6046591 100644 (file)
@@ -6,6 +6,7 @@
  *  general buffer i/o
  */
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include "hpfs_fn.h"
 
 void hpfs_lock_creation(struct super_block *s)
index 26e3964a4b8c19a7075d0ef623ab041392c78b53..2338130ccebaab85c33ba86f1d2d0c16b1f6a76d 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include "hpfs_fn.h"
 
 static int hpfs_dir_release(struct inode *inode, struct file *filp)
index ff90affb94e16ebdd2b2a76156dab515d4a0a050..1042a9bc97f3710c0930c80333afd303ae10a8d5 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include "hpfs_fn.h"
 
 void hpfs_init_inode(struct inode *i)
index cadc4ce48656674358e44eeb62e16f4f5bdc9b01..aa53842c599c2eec917086af4d2c8b1d2fea1384 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
 #include <linux/bitmap.h>
+#include <linux/slab.h>
 
 /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
 
index c7c0b28d7d2177c7c88d32f3f62856e97cfc7ff5..748cfb92dcc6203897c62d87ee113876f197a28b 100644 (file)
@@ -19,6 +19,7 @@
  * See also Documentation/block/ioprio.txt
  *
  */
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/ioprio.h>
 #include <linux/blkdev.h>
index 8ba5441063be82c37af8477b90b9eabf7b1d34c0..b9ab69b3a482ce86bcbefd9f7703d0079f516bce 100644 (file)
@@ -11,6 +11,7 @@
  *  isofs directory handling functions
  */
 #include <linux/smp_lock.h>
+#include <linux/gfp.h>
 #include "isofs.h"
 
 int isofs_name_translate(struct iso_directory_record *de, char *new, struct inode *inode)
index eaa831311c9cb49b243d5f5426ee9479f26885ac..ab438beb867cca718bcedf66e0355f09168b8669 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/smp_lock.h>
+#include <linux/gfp.h>
 #include "isofs.h"
 
 /*
index 2c90e3ef625f35ae0bfdfa74270273c9d35a1695..ecb44c94ba8de4251de699bd6e35a317ecee8a85 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/bio.h>
index cb1a49ae605e0a0c7b01c706a743e912dfe70ea1..54c9bc9e1b17e01487cca2eb81d5bfdf7a649585 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #endif
 
 /*
index 73063285b13f7c7d868fb8553690bb2d0cbe5a03..049281b7cb8966ab236f8085c65f5230f891aaae 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/fs.h>
 #include <linux/jbd2.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/crc32.h>
 #endif
 
index 90cb60d0978767c305ce1ed888e712471b72b0d3..cd02acafde8a3352a8fd639704b924b86c9e0160 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/lzo.h>
index cfd301a5edfc2db804cb1b3ab008543211c0c4aa..b46661a4275866e95f0cd174cd82e498db13532d 100644 (file)
@@ -14,7 +14,6 @@
 #endif
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/zlib.h>
 #include <linux/zutil.h>
 #include "nodelist.h"
index 5544d31c066be22fb25cc857df3691de8e420ea6..ec3538413926f677feb3d763df9a7ebaa5d7a07d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/crc32.h>
 #include <linux/jffs2.h>
 #include <linux/mtd/mtd.h>
+#include <linux/slab.h>
 #include "nodelist.h"
 #include "debug.h"
 
index b7b74e299142bd964330ca2b88570b381420ad8b..e7291c161a1989c2abeb55659eb67b80fdc1a8d0 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/time.h>
 #include <linux/pagemap.h>
index 87c6f555e1a0a696ee2fe52e57c9b3978bc8716f..af02bd13846967a8d9288358e1e3979c89520fe7 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/mtd/mtd.h>
 #include <linux/rbtree.h>
 #include <linux/crc32.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include "nodelist.h"
 
index 21a052915aa9363acb0cd1e2b34567ef782b57f5..191359dde4e1a3f9e34d64eaf43626466ffc3333 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <linux/compiler.h>
 #include <linux/sched.h> /* For cond_resched() */
index 4ec11e8bda8c75a33336cba971128c2cd5ca073e..b955626071c28acb8be9728b88399f8c9cdd7ab4 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/namei.h>
 #include "nodelist.h"
index ca29440e9435867650514303b256c54528b8c1ef..c819eb0e982d8b95a216a09ab9398c9bd7e3ea58 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/crc32.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
index 213169780b6cb7292fda108700056ec02f5758bd..1057a4998e4e793f7a5706dbd4026916c7f3e9b6 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/posix_acl_xattr.h>
 #include "jfs_incore.h"
index d9b031cf69f56581eedd4870a2c8321823575465..6c4dfcbf3f5509bd7ea5ee85b89caf9eff44119d 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include "jfs_incore.h"
 #include "jfs_superblock.h"
 #include "jfs_dmap.h"
index 0e4623be70ceb6dcee419d1c392c8e92cf1bfac3..9197a1b0d02db05943ed3bc646e53109253044e3 100644 (file)
 
 #include <linux/fs.h>
 #include <linux/quotaops.h>
+#include <linux/slab.h>
 #include "jfs_incore.h"
 #include "jfs_superblock.h"
 #include "jfs_filsys.h"
index 0fc30407f03912e98a41cadd345afb88282b36f0..f8332dc8eeb2111430d2a16ae716b6d1925fde99 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
+#include <linux/slab.h>
 
 #include "jfs_incore.h"
 #include "jfs_inode.h"
index 335c4de6552d1a8fb7b1450fd5c20bd9ac5dc29e..c51af2a14516b88ba4aad33fc6fa28c64c8fb15a 100644 (file)
@@ -70,6 +70,7 @@
 #include <linux/delay.h>
 #include <linux/mutex.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include "jfs_incore.h"
 #include "jfs_filsys.h"
 #include "jfs_metapage.h"
index 07b6c5dfb4b6e641cda09581c4fff8abb8603ea5..48b44bd8267b960e7e5bd330521f9da93d6d1a6f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/bio.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/buffer_head.h>
 #include <linux/mempool.h>
index 3fbb3a22559077e0fbfd21ae4a44cb91ebd7605e..8f0f02cb6ca6285831be3966c2e1ee655ec30f50 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef _H_JFS_UNICODE
 #define _H_JFS_UNICODE
 
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 #include "jfs_types.h"
 
index 266699deb1c68825d29eee529d0109dcf9ce50a0..157382fa625625f46213205c25087f7af6203188 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/buffer_head.h>
 #include <linux/exportfs.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/seq_file.h>
 #include <linux/smp_lock.h>
index 1f594ab21895cb28c81f3b0238a434147d485198..fa96bbb263434618e1c3bc050a2208ccbe3c8fc0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
+#include <linux/slab.h>
 #include <linux/quotaops.h>
 #include <linux/security.h>
 #include "jfs_incore.h"
index 9e50bcf55857eaebd8fc4106f21bae8ad69afbf1..ea9a6cc9b35c6b08ef1517837d1c05a4d2da47e1 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/module.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/vfs.h>
 #include <linux/mutex.h>
index fc9032dc8862df3408a56e7208aef0fb446e3a5e..64fd427c993cce81eb5246ba9717a975575c0017 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/nfs_fs.h>
 #include <linux/sunrpc/clnt.h>
index c81249fef11f9a3f48b02d772e4d09d3216a2557..7932c399fab41421095fbb0f98f0b21819e96514 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
index fefa4df3f005bd9cdf0e1a10b0ab0bfce72f976e..e3015464fbab8ac1a9a48f0ea5465080923731bb 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/utsname.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
+#include <linux/slab.h>
 
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/xprtsock.h>
index 7d150517ddf0445943ed58e2625494deef712d4e..f1bacf1a03912bb52939e5d0595b9c71f70ff8d6 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/errno.h>
 #include <linux/in.h>
 #include <linux/uio.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/mutex.h>
index a7966eed3c17a2bfe34ec4bb6ed6ea492e1b9021..031c6569a134aa7efcfc776d1cab5ef03bc742b8 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <linux/types.h>
 #include <linux/time.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/lockd/lockd.h>
 #include <linux/lockd/share.h>
index d1001790fa9ac77569ede0eae646b7b116f2211f..84055d31bfc5e427a87c2412eea17f6ea59e2fc4 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
index 56c9519d900a32ea203112f24b4866227b1bdd33..0f2ab741ae7c8205edeed842e7bbf6f89d6d482f 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <linux/types.h>
 #include <linux/time.h>
-#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/lockd/lockd.h>
 #include <linux/lockd/share.h>
index ad478da7ca63138e6dda728ed6640c4630c5e02e..d0ef94cfb3da4d218b66a0a4046d96ab30506f3b 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/string.h>
 #include <linux/time.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/clnt.h>
index 9718c22f186d04ff309614dbeee6337a8d5ec185..243c00071f760d14c84e2ffca6979e7442a054d2 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/buffer_head.h>
+#include <linux/gfp.h>
 
 #define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1))
 
@@ -80,6 +81,7 @@ static void writeseg_end_io(struct bio *bio, int err)
                        prefetchw(&bvec->bv_page->flags);
 
                end_page_writeback(page);
+               page_cache_release(page);
        } while (bvec >= bio->bi_io_vec);
        bio_put(bio);
        if (atomic_dec_and_test(&super->s_pending_writes))
@@ -97,8 +99,10 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
        unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
        int i;
 
+       if (max_pages > BIO_MAX_PAGES)
+               max_pages = BIO_MAX_PAGES;
        bio = bio_alloc(GFP_NOFS, max_pages);
-       BUG_ON(!bio); /* FIXME: handle this */
+       BUG_ON(!bio);
 
        for (i = 0; i < nr_pages; i++) {
                if (i >= max_pages) {
@@ -191,8 +195,10 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index,
        unsigned int max_pages = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
        int i;
 
+       if (max_pages > BIO_MAX_PAGES)
+               max_pages = BIO_MAX_PAGES;
        bio = bio_alloc(GFP_NOFS, max_pages);
-       BUG_ON(!bio); /* FIXME: handle this */
+       BUG_ON(!bio);
 
        for (i = 0; i < nr_pages; i++) {
                if (i >= max_pages) {
index 56a8bfbb012041be7279216ff334831ea911edbe..2396a85c0f55ab9de07faf6687ae6d4433a9c348 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
  */
 #include "logfs.h"
-
+#include <linux/slab.h>
 
 /*
  * Atomic dir operations
@@ -303,12 +303,12 @@ static int __logfs_readdir(struct file *file, void *buf, filldir_t filldir)
                                (filler_t *)logfs_readpage, NULL);
                if (IS_ERR(page))
                        return PTR_ERR(page);
-               dd = kmap_atomic(page, KM_USER0);
+               dd = kmap(page);
                BUG_ON(dd->namelen == 0);
 
                full = filldir(buf, (char *)dd->name, be16_to_cpu(dd->namelen),
                                pos, be64_to_cpu(dd->ino), dd->type);
-               kunmap_atomic(dd, KM_USER0);
+               kunmap(page);
                page_cache_release(page);
                if (full)
                        break;
index 92949f95a901079ec6a0c72464b09d588ce2b85d..84e36f52fe9519a5481ca47e576d24f329a0c4d1 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include "logfs.h"
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 /*
  * Wear leveling needs to kick in when the difference between low erase
index 33ec1aeaeec4f9d614a75140042753d441558f1a..14ed27274da26954bcc451bfb022aa92e0761aa7 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
  */
 #include "logfs.h"
+#include <linux/slab.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
 
index 6ad30a4c9052179b4fe56da98a81f381b7a531a7..33bd260b8309427b6deb889a973813063a9448b2 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
  */
 #include "logfs.h"
+#include <linux/slab.h>
 
 static void logfs_calc_free(struct super_block *sb)
 {
@@ -800,6 +801,7 @@ void do_logfs_journal_wl_pass(struct super_block *sb)
 {
        struct logfs_super *super = logfs_super(sb);
        struct logfs_area *area = super->s_journal_area;
+       struct btree_head32 *head = &super->s_reserved_segments;
        u32 segno, ec;
        int i, err;
 
@@ -807,6 +809,7 @@ void do_logfs_journal_wl_pass(struct super_block *sb)
        /* Drop old segments */
        journal_for_each(i)
                if (super->s_journal_seg[i]) {
+                       btree_remove32(head, super->s_journal_seg[i]);
                        logfs_set_segment_unreserved(sb,
                                        super->s_journal_seg[i],
                                        super->s_journal_ec[i]);
@@ -819,8 +822,13 @@ void do_logfs_journal_wl_pass(struct super_block *sb)
                super->s_journal_seg[i] = segno;
                super->s_journal_ec[i] = ec;
                logfs_set_segment_reserved(sb, segno);
+               err = btree_insert32(head, segno, (void *)1, GFP_KERNEL);
+               BUG_ON(err); /* mempool should prevent this */
+               err = logfs_erase_segment(sb, segno, 1);
+               BUG_ON(err); /* FIXME: remount-ro would be nicer */
        }
        /* Manually move journal_area */
+       freeseg(sb, area->a_segno);
        area->a_segno = super->s_journal_seg[0];
        area->a_is_open = 0;
        area->a_used_bytes = 0;
index 129779431373adfbf5f674b48e26913f80986f19..b84b0eec6024d87b17079229e249668f07418400 100644 (file)
@@ -587,6 +587,7 @@ void move_page_to_btree(struct page *page);
 int logfs_init_mapping(struct super_block *sb);
 void logfs_sync_area(struct logfs_area *area);
 void logfs_sync_segments(struct super_block *sb);
+void freeseg(struct super_block *sb, u32 segno);
 
 /* area handling */
 int logfs_init_areas(struct super_block *sb);
index 7a23b3e7c0a798c3b750d96f08cf1351950cefde..bff40253dfb244df0ece0ddf95407988494f6364 100644 (file)
@@ -18,6 +18,7 @@
  */
 #include "logfs.h"
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 static u64 adjust_bix(u64 bix, level_t level)
 {
@@ -1594,7 +1595,6 @@ int logfs_delete(struct inode *inode, pgoff_t index,
        return ret;
 }
 
-/* Rewrite cannot mark the inode dirty but has to write it immediatly. */
 int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
                gc_level_t gc_level, long flags)
 {
@@ -1611,6 +1611,18 @@ int logfs_rewrite_block(struct inode *inode, u64 bix, u64 ofs,
                if (level != 0)
                        alloc_indirect_block(inode, page, 0);
                err = logfs_write_buf(inode, page, flags);
+               if (!err && shrink_level(gc_level) == 0) {
+                       /* Rewrite cannot mark the inode dirty but has to
+                        * write it immediatly.
+                        * Q: Can't we just create an alias for the inode
+                        * instead?  And if not, why not?
+                        */
+                       if (inode->i_ino == LOGFS_INO_MASTER)
+                               logfs_write_anchor(inode->i_sb);
+                       else {
+                               err = __logfs_write_inode(inode, flags);
+                       }
+               }
        }
        logfs_put_write_page(page);
        return err;
index 1a14f9910d55ef94a46c64ba910caa1d92bbfdec..801a3a141625463cda2b5ee1ef29bdd8cdf5ab2f 100644 (file)
@@ -10,6 +10,7 @@
  * three kinds of objects: inodes, dentries and blocks, both data and indirect.
  */
 #include "logfs.h"
+#include <linux/slab.h>
 
 static int logfs_mark_segment_bad(struct super_block *sb, u32 segno)
 {
@@ -93,49 +94,57 @@ void __logfs_buf_write(struct logfs_area *area, u64 ofs, void *buf, size_t len,
        } while (len);
 }
 
-/*
- * bdev_writeseg will write full pages.  Memset the tail to prevent data leaks.
- */
-static void pad_wbuf(struct logfs_area *area, int final)
+static void pad_partial_page(struct logfs_area *area)
 {
        struct super_block *sb = area->a_sb;
-       struct logfs_super *super = logfs_super(sb);
        struct page *page;
        u64 ofs = dev_ofs(sb, area->a_segno, area->a_used_bytes);
        pgoff_t index = ofs >> PAGE_SHIFT;
        long offset = ofs & (PAGE_SIZE-1);
        u32 len = PAGE_SIZE - offset;
 
-       if (len == PAGE_SIZE) {
-               /* The math in this function can surely use some love */
-               len = 0;
-       }
-       if (len) {
-               BUG_ON(area->a_used_bytes >= super->s_segsize);
-
-               page = get_mapping_page(area->a_sb, index, 0);
+       if (len % PAGE_SIZE) {
+               page = get_mapping_page(sb, index, 0);
                BUG_ON(!page); /* FIXME: reserve a pool */
                memset(page_address(page) + offset, 0xff, len);
                SetPagePrivate(page);
                page_cache_release(page);
        }
+}
 
-       if (!final)
-               return;
+static void pad_full_pages(struct logfs_area *area)
+{
+       struct super_block *sb = area->a_sb;
+       struct logfs_super *super = logfs_super(sb);
+       u64 ofs = dev_ofs(sb, area->a_segno, area->a_used_bytes);
+       u32 len = super->s_segsize - area->a_used_bytes;
+       pgoff_t index = PAGE_CACHE_ALIGN(ofs) >> PAGE_CACHE_SHIFT;
+       pgoff_t no_indizes = len >> PAGE_CACHE_SHIFT;
+       struct page *page;
 
-       area->a_used_bytes += len;
-       for ( ; area->a_used_bytes < super->s_segsize;
-                       area->a_used_bytes += PAGE_SIZE) {
-               /* Memset another page */
-               index++;
-               page = get_mapping_page(area->a_sb, index, 0);
+       while (no_indizes) {
+               page = get_mapping_page(sb, index, 0);
                BUG_ON(!page); /* FIXME: reserve a pool */
-               memset(page_address(page), 0xff, PAGE_SIZE);
+               SetPageUptodate(page);
+               memset(page_address(page), 0xff, PAGE_CACHE_SIZE);
                SetPagePrivate(page);
                page_cache_release(page);
+               index++;
+               no_indizes--;
        }
 }
 
+/*
+ * bdev_writeseg will write full pages.  Memset the tail to prevent data leaks.
+ * Also make sure we allocate (and memset) all pages for final writeout.
+ */
+static void pad_wbuf(struct logfs_area *area, int final)
+{
+       pad_partial_page(area);
+       if (final)
+               pad_full_pages(area);
+}
+
 /*
  * We have to be careful with the alias tree.  Since lookup is done by bix,
  * it needs to be normalized, so 14, 15, 16, etc. all match when dealing with
@@ -683,7 +692,7 @@ int logfs_segment_delete(struct inode *inode, struct logfs_shadow *shadow)
        return 0;
 }
 
-static void freeseg(struct super_block *sb, u32 segno)
+void freeseg(struct super_block *sb, u32 segno)
 {
        struct logfs_super *super = logfs_super(sb);
        struct address_space *mapping = super->s_mapping_inode->i_mapping;
index c66beab78deedb5efd8fa5d7dfb27a7f4d78b95b..b60bfac3263c71d688532ef5d434e04220d87aa2 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include "logfs.h"
 #include <linux/bio.h>
+#include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <linux/statfs.h>
 #include <linux/buffer_head.h>
@@ -277,7 +278,7 @@ static int logfs_recover_sb(struct super_block *sb)
        }
        if (valid0 && valid1 && ds_cmp(ds0, ds1)) {
                printk(KERN_INFO"Superblocks don't match - fixing.\n");
-               return write_one_sb(sb, super->s_devops->find_last_sb);
+               return logfs_write_sb(sb);
        }
        /* If neither is valid now, something's wrong.  Didn't we properly
         * check them before?!? */
@@ -289,6 +290,10 @@ static int logfs_make_writeable(struct super_block *sb)
 {
        int err;
 
+       err = logfs_open_segfile(sb);
+       if (err)
+               return err;
+
        /* Repair any broken superblock copies */
        err = logfs_recover_sb(sb);
        if (err)
@@ -299,10 +304,6 @@ static int logfs_make_writeable(struct super_block *sb)
        if (err)
                return err;
 
-       err = logfs_open_segfile(sb);
-       if (err)
-               return err;
-
        /* Do one GC pass before any data gets dirtied */
        logfs_gc_pass(sb);
 
@@ -328,7 +329,7 @@ static int logfs_get_sb_final(struct super_block *sb, struct vfsmount *mnt)
 
        sb->s_root = d_alloc_root(rootdir);
        if (!sb->s_root)
-               goto fail;
+               goto fail2;
 
        super->s_erase_page = alloc_pages(GFP_KERNEL, 0);
        if (!super->s_erase_page)
@@ -572,8 +573,7 @@ int logfs_get_sb_device(struct file_system_type *type, int flags,
        return 0;
 
 err1:
-       up_write(&sb->s_umount);
-       deactivate_super(sb);
+       deactivate_locked_super(sb);
        return err;
 err0:
        kfree(super);
index 82d6554b02fec5a9f813ee9c026831c9db310455..282e15ad8cd8c8ce24da286263acbd284985ed17 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/buffer_head.h>
+#include <linux/slab.h>
 #include "minix.h"
 
 enum {DEPTH = 3, DIRECT = 7};  /* Only double indirect */
index 598d54e200ebea1e64d1a54f0416db04d2365aa0..fd56ca2ea55611314a841c9a65abba0c88b6ffa6 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/kdev_t.h>
+#include <linux/gfp.h>
 #include <linux/bio.h>
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
index 1c0fca6e899eef7aa768ed704e2216c3d024c7df..a7dce91a7e4244c3dab9bbb10644fd31ec371bee 100644 (file)
@@ -1610,8 +1610,7 @@ exit:
 
 static struct file *do_last(struct nameidata *nd, struct path *path,
                            int open_flag, int acc_mode,
-                           int mode, const char *pathname,
-                           int *want_dir)
+                           int mode, const char *pathname)
 {
        struct dentry *dir = nd->path.dentry;
        struct file *filp;
@@ -1642,7 +1641,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
        if (nd->last.name[nd->last.len]) {
                if (open_flag & O_CREAT)
                        goto exit;
-               *want_dir = 1;
+               nd->flags |= LOOKUP_DIRECTORY;
        }
 
        /* just plain open? */
@@ -1656,8 +1655,10 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
                if (path->dentry->d_inode->i_op->follow_link)
                        return NULL;
                error = -ENOTDIR;
-               if (*want_dir && !path->dentry->d_inode->i_op->lookup)
-                       goto exit_dput;
+               if (nd->flags & LOOKUP_DIRECTORY) {
+                       if (!path->dentry->d_inode->i_op->lookup)
+                               goto exit_dput;
+               }
                path_to_nameidata(path, nd);
                audit_inode(pathname, nd->path.dentry);
                goto ok;
@@ -1766,7 +1767,6 @@ struct file *do_filp_open(int dfd, const char *pathname,
        int count = 0;
        int flag = open_to_namei_flags(open_flag);
        int force_reval = 0;
-       int want_dir = open_flag & O_DIRECTORY;
 
        if (!(open_flag & O_CREAT))
                mode = 0;
@@ -1828,7 +1828,9 @@ reval:
                if (open_flag & O_EXCL)
                        nd.flags |= LOOKUP_EXCL;
        }
-       filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname, &want_dir);
+       if (open_flag & O_DIRECTORY)
+               nd.flags |= LOOKUP_DIRECTORY;
+       filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
        while (unlikely(!filp)) { /* trailing symlink */
                struct path holder;
                struct inode *inode = path.dentry->d_inode;
@@ -1866,7 +1868,7 @@ reval:
                }
                holder = path;
                nd.flags &= ~LOOKUP_PARENT;
-               filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname, &want_dir);
+               filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
                if (inode->i_op->put_link)
                        inode->i_op->put_link(holder.dentry, &nd, cookie);
                path_put(&holder);
index b8b5b30d53f0c03a8c11c580bf29470225246293..7edfcd4d5e524b5ad1ace0f64a11f508437ef5c9 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/errno.h>
 #include <linux/stat.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
 #include <asm/uaccess.h>
index 6a7d901f1936e555a530981c6fc6e53bab000f00..1daabb90e0a54bba1a3c65146fb7098b3fdb8218 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/fcntl.h>
 #include <linux/stat.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
index ec8f45f12e058ff7ee73869b2c1a425ce6f45f16..60a5e2864ea8b9b97e41de53875480959e17400f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/mount.h>
+#include <linux/slab.h>
 #include <linux/highuid.h>
 #include <linux/smp_lock.h>
 #include <linux/vmalloc.h>
index 15458decdb8a33b547f7f3fb401e2ca4ac169d71..56f5b3a0e1ee3c4c5383f858fd297c6e787ba57b 100644 (file)
@@ -9,12 +9,12 @@
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/shm.h>
 #include <linux/errno.h>
 #include <linux/mman.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/ncp_fs.h>
 
index e37df8d5fe707968d0720de94b45c6a4bf5d8f2e..c7ff6c700a6efdca195b43a18414e221ecafc824 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mm.h>
 #include <linux/netdevice.h>
 #include <linux/signal.h>
+#include <linux/slab.h>
 #include <net/scm.h>
 #include <net/sock.h>
 #include <linux/ipx.h>
index e3d26c1bd105a388cf032c3586b192e6b5e56907..c634fd17b337ceffdb4e21c1a143955dd166f66a 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/fs.h>
 #include <linux/ncp_fs.h>
 #include <linux/time.h>
+#include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/stat.h>
 #include "ncplib_kernel.h"
index b4ffd0146ea61cb2c4ff80fa098d7f1a45200976..84690319e625d5ef35aadeee5d9535291f9ffd5e 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/moduleparam.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 #include <linux/sunrpc/cache.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
 
index 84761b5bb8e22142fd8eaefa82e48d1af927ee3c..a08770a7e857bf10ef5f21f9e10d1465c2c9ce88 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include <linux/nfs4.h>
 #include <linux/nfs_fs.h>
+#include <linux/slab.h>
 #include "nfs4_fs.h"
 #include "callback.h"
 #include "delegation.h"
index a2b8b4df125d3eea8bd928970e7b4b940de7b886..05af212f0edfb1558e238bb0ce95a5ef7688987f 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/nfs4.h>
 #include <linux/nfs_fs.h>
+#include <linux/slab.h>
 #include "nfs4_fs.h"
 #include "callback.h"
 
index 2274f1737336485f30fcfd7fdfab841e9bc39600..2a3d352c0bffdba569e76cc50318a3d619ef3877 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/vfs.h>
 #include <linux/inet.h>
 #include <linux/in6.h>
+#include <linux/slab.h>
 #include <net/ipv6.h>
 #include <linux/nfs_xdr.h>
 #include <linux/sunrpc/bc_xprt.h>
index 2563bebc4c670915f73de93625411062a52f3582..15671245c6eec62c14fcdce139bd3ea9823664d5 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kthread.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 
index 0d289823e8564b49969710e4c16688abbc61b15d..ad4cd31d6050d22c2a6267b005bab48b84f70f66 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/file.h>
 #include <linux/pagemap.h>
 #include <linux/kref.h>
+#include <linux/slab.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_page.h>
index 3f0cd4dfddaf809d710dd1f53d19dae987105615..76fd235d0024e1970d44044536d2d929c02b9256 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/seq_file.h>
index ae8d02294e462283eb2c421048dc381c8d87bf36..8d965bddb87e6f5c8d340eec081ac03d88084047 100644 (file)
@@ -24,9 +24,9 @@
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/aio.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -491,7 +491,8 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
 {
        dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page);
 
-       if (gfp & __GFP_WAIT)
+       /* Only do I/O if gfp is a superset of GFP_KERNEL */
+       if ((gfp & GFP_KERNEL) == GFP_KERNEL)
                nfs_wb_page(page->mapping->host, page);
        /* If PagePrivate() is set, then the page is not freeable */
        if (PagePrivate(page))
index 237874f1af23697d3d092147eaa39bcf25958006..a6b16ed932291cb524d90feb49ae4ab48f878032 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/nfs_fs_sb.h>
 #include <linux/in6.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include "internal.h"
 #include "iostat.h"
index e358df75a6ad2e4f64361298fa335bed78c5c6ab..737128f777f366190a1e82aa1371ee8d75d5fe8d 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/vfs.h>
 #include <linux/inet.h>
 #include <linux/nfs_xdr.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 40c76678289168ed0cbbe3e653f58485a56003eb..7888cf36022d2dee78b983ff216a8371ee89164c 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/dcache.h>
+#include <linux/gfp.h>
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/nfs_fs.h>
index 7bc2da8efd4a352a962d8aac259cd6279fe3f6eb..81cf142579167e9654b3332348e92e3eee48c37b 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/in.h>
index bac60515a4b35437c95b9cbd3ebfd8e01f177d89..d150ae0c5ecd5ccfef5260bc2985f0a446a9a803 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/nfs.h>
 #include <linux/nfs3.h>
 #include <linux/nfs_fs.h>
index 24992f0a29f22b12c753004c065f23f34d19df36..e701002694e5687fa43f0ae5b2e3daaa5569df13 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/sunrpc/clnt.h>
+#include <linux/slab.h>
 #include <linux/nfs.h>
 #include <linux/nfs3.h>
 #include <linux/nfs_fs.h>
index 5fe5492fbd29e51fab41de8930b29f6863e76747..56a86f6ac8b5cc3c4b79cd5f2fbe1c6d9874a4f8 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/in.h>
index fa3408f201126790eb66ac42db7eff3b12f345e4..f071d12c613b621433dab4b0e498f0b8c979575f 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/nfs_fs.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/vfs.h>
index f9254fb0c9d0c11750ab8406edb4b1774604a63b..d79a7b37e56c41bd196af57548d9865b7514acc0 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/nfs.h>
 #include <linux/nfs4.h>
index 4d338be492cb28f6e91ae9eecfe30af64555154d..38f3b582e7c246c4552b2b1b11a618b8eff93f26 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/in.h>
@@ -5552,6 +5551,8 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nf
        if (status != 0)
                goto out;
        status = decode_delegreturn(&xdr);
+       if (status != 0)
+               goto out;
        decode_getfattr(&xdr, res->fattr, res->server,
                        !RPC_IS_ASYNC(rqstp->rq_task));
 out:
index c752d944fe9e93e2cf1759b49e6c671a1caaa7b7..0288be80444fc6b3e1e29f2b504cf55acc294740 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <linux/types.h>
 #include <linux/param.h>
-#include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/errno.h>
index 6baf9a3934660d9fa3721ee963743c90c8ebd3e8..e01637240eeb59fb4032b926e3c709c771fdcedd 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/vfs.h>
 #include <linux/inet.h>
 #include <linux/in6.h>
+#include <linux/slab.h>
 #include <net/ipv6.h>
 #include <linux/netdevice.h>
 #include <linux/nfs_xdr.h>
index 2ea9e5c27e5521d10b82d893b316c43c85ccad57..05c9e02f4153e340d94035bfdef6cc8db34b5a06 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/pagemap.h>
 #include <linux/stat.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/namei.h>
 
index 04133aacb1e519efe83d9ebe41d7ffe187616845..fc1c52571c03ea9eaf0d4e96a4026f119cd026e9 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/sunrpc/xdr.h>
 #include <linux/nfsacl.h>
 #include <linux/nfs3.h>
index a0c4016413f16117c1c5141fd01d3b27eabf871e..872a5ef550c7733c79650180ed453aaec25e7752 100644 (file)
@@ -12,6 +12,7 @@
  * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de>
  */
 
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/module.h>
 #include <linux/exportfs.h>
index f20589d2ae27be2aab0379b7d0ba1e2674490182..6aa5590c3679135279d2731b2af79fd8804b44a2 100644 (file)
@@ -7,6 +7,7 @@
 #include "nfsd.h"
 /* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
+#include <linux/gfp.h>
 #include "cache.h"
 #include "xdr3.h"
 #include "vfs.h"
index e0c4846bad922be3307add94510a9b96330f691b..a596e9d987e46abb499ee8ac6dcd44472d02bc71 100644 (file)
@@ -7,6 +7,7 @@
 #include "nfsd.h"
 /* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
+#include <linux/gfp.h>
 #include "cache.h"
 #include "xdr3.h"
 #include "vfs.h"
index 88150685df349e6abbc44d57d75c1d65fcc9649f..e48052615159c24689989b5ebe0a803e0946755f 100644 (file)
@@ -34,6 +34,7 @@
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <linux/slab.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs4_acl.h>
 
index 4bc22c763de7b433b4a37f2affdf75cc560d3908..7e32bd394e8696afac48c56bc27c768155c9db7e 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <linux/sunrpc/clnt.h>
+#include <linux/slab.h>
 #include "nfsd.h"
 #include "state.h"
 
index 6e2983b27f3ca4e6db8529da74adfeaffe09f4a4..c78dbf4934247e101d6fee19dd1e3ee150957e80 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/nfsd_idmap.h>
 #include <linux/seq_file.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 /*
  * Cache entry
index 37514c46984611467c95f89b82c2aa097779311b..2ab9e8501bfead1a451fb75cd7441407b412019b 100644 (file)
@@ -33,6 +33,7 @@
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <linux/file.h>
+#include <linux/slab.h>
 
 #include "cache.h"
 #include "xdr4.h"
index 98fb98e330b4004907d899937e13e2f1c32368ee..7a9ae3254a4b2f858bce392ed5f719ae2ef126e7 100644 (file)
@@ -32,6 +32,7 @@
 */
 
 #include <linux/file.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/crypto.h>
 #include <linux/sched.h>
index c97fddbd17db8d15f0ce5a21d1ec6580a1be603c..6a8fedaa4f55a8ad0f6236296063e385d8eb1a17 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <linux/file.h>
 #include <linux/smp_lock.h>
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/swap.h>
 #include <linux/sunrpc/svcauth_gss.h>
index c47b4d7bafa72d400b6249d0b0c7cd6908f0fd85..e1703175ee2868781945054965ac24eebc4c415f 100644 (file)
@@ -40,6 +40,7 @@
  * at the end of nfs4svc_decode_compoundargs.
  */
 
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/statfs.h>
 #include <linux/utsname.h>
index da08560c4818defa358feb7b75e88b4d33dee70b..4666a209678a4d88ee0b1aea08078407df9b0938 100644 (file)
@@ -8,6 +8,8 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/slab.h>
+
 #include "nfsd.h"
 #include "cache.h"
 
index 0f0e77f2012f64951d9b8c1fc54f19156fab6f62..e3591073098f769e2d3658e1fa17a1abb30661ad 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/ctype.h>
 
index a11b0e8678eeff6585687afe1d0701663e11144a..6dd5f1970e01dedc3da245d8d26d87236dfadaf4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/xattr.h>
 #include <linux/jhash.h>
 #include <linux/ima.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/exportfs.h>
 #include <linux/writeback.h>
index 3f959f1879d8b813a0ce775af216c5e5cd8df617..8d6356a804f355258d4f04475295afe4f7166fd3 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include "mdt.h"
 #include "alloc.h"
 
index 471e269536ae1f24e07d84c9d412abcd5068d17d..447ce47a3306f6635a0512a8e25580ae93c0620b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/buffer_head.h>
 #include <linux/mm.h>
 #include <linux/backing-dev.h>
+#include <linux/gfp.h>
 #include "nilfs.h"
 #include "mdt.h"
 #include "dat.h"
index 8880a9e281e7bd11fd1c4ea7c9cc7974ec81d02a..145f03cd7d3e0299cda6786313804f1f1bf009ce 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/buffer_head.h>
 #include <linux/mpage.h>
 #include <linux/hash.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 #include "nilfs.h"
 #include "page.h"
index 7868cc122ac764dba74d6d55f0305239ff91ed8f..0957b58f909dc414348ea4b2529da54a468aabd4 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/buffer_head.h>
+#include <linux/gfp.h>
 #include <linux/mpage.h>
 #include <linux/writeback.h>
 #include <linux/uio.h>
index 313d0a21da480afc05afacfb46bec6f74e34b76a..c2ff1b30601207531d3c5a6a1dde6cd7e689ae2e 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/fs.h>
 #include <linux/wait.h>
 #include <linux/smp_lock.h>    /* lock_kernel(), unlock_kernel() */
+#include <linux/slab.h>
 #include <linux/capability.h>  /* capable() */
 #include <linux/uaccess.h>     /* copy_from_user(), copy_to_user() */
 #include <linux/vmalloc.h>
index 06713ffcc7f2dc2f6a668e35c46e97e64be15884..024be8c35bb65bef3ef5e1daf8f05da5fbb1b7b2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
 #include <linux/swap.h>
+#include <linux/slab.h>
 #include "nilfs.h"
 #include "segment.h"
 #include "page.h"
index fc246dba112af8cbbb20c79e8885194713f76f4d..8de3e1e48130ff6e042e3ba7c7d10b218e1d1268 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/list.h>
 #include <linux/highmem.h>
 #include <linux/pagevec.h>
+#include <linux/gfp.h>
 #include "nilfs.h"
 #include "page.h"
 #include "mdt.h"
index 017bedc761a048c66b538008ef4b561163f474e0..ba43146f3c309308cfd8505382570906f971ee57 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/buffer_head.h>
 #include <linux/blkdev.h>
 #include <linux/swap.h>
+#include <linux/slab.h>
 #include <linux/crc32.h>
 #include "nilfs.h"
 #include "segment.h"
index 636eaafd6ea257c7bfaf53dc7b7ce8399f81a103..17851f77f739d1942c8f0aad04d78fd82b8347e4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/writeback.h>
 #include <linux/crc32.h>
 #include <linux/backing-dev.h>
+#include <linux/slab.h>
 #include "page.h"
 #include "segbuf.h"
 
@@ -323,14 +324,14 @@ int nilfs_write_logs(struct list_head *logs, struct the_nilfs *nilfs)
 int nilfs_wait_on_logs(struct list_head *logs)
 {
        struct nilfs_segment_buffer *segbuf;
-       int err;
+       int err, ret = 0;
 
        list_for_each_entry(segbuf, logs, sb_list) {
                err = nilfs_segbuf_wait(segbuf);
-               if (err)
-                       return err;
+               if (err && !ret)
+                       ret = err;
        }
-       return 0;
+       return ret;
 }
 
 /*
index 69576a95e13f918b340c51b1ffdc701d1053fc2f..6a7dbd8451db73d40080156ff325c82183437f51 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kthread.h>
 #include <linux/crc32.h>
 #include <linux/pagevec.h>
+#include <linux/slab.h>
 #include "nilfs.h"
 #include "btnode.h"
 #include "page.h"
@@ -1510,6 +1511,12 @@ static int nilfs_segctor_collect(struct nilfs_sc_info *sci,
                if (mode != SC_LSEG_SR || sci->sc_stage.scnt < NILFS_ST_CPFILE)
                        break;
 
+               nilfs_clear_logs(&sci->sc_segbufs);
+
+               err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
+               if (unlikely(err))
+                       return err;
+
                if (sci->sc_stage.flags & NILFS_CF_SUFREED) {
                        err = nilfs_sufile_cancel_freev(nilfs->ns_sufile,
                                                        sci->sc_freesegs,
@@ -1517,12 +1524,6 @@ static int nilfs_segctor_collect(struct nilfs_sc_info *sci,
                                                        NULL);
                        WARN_ON(err); /* do not happen */
                }
-               nilfs_clear_logs(&sci->sc_segbufs);
-
-               err = nilfs_segctor_extend_segments(sci, nilfs, nadd);
-               if (unlikely(err))
-                       return err;
-
                nadd = min_t(int, nadd << 1, SC_MAX_SEGDELTA);
                sci->sc_stage = prev_stage;
        }
@@ -1897,8 +1898,7 @@ static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci,
 
        list_splice_tail_init(&sci->sc_write_logs, &logs);
        ret = nilfs_wait_on_logs(&logs);
-       if (ret)
-               nilfs_abort_logs(&logs, NULL, sci->sc_super_root, ret);
+       nilfs_abort_logs(&logs, NULL, sci->sc_super_root, ret ? : err);
 
        list_splice_tail_init(&sci->sc_segbufs, &logs);
        nilfs_cancel_segusage(&logs, nilfs->ns_sufile);
index e9795f1724d7f0cc487729fd1e7cc2bb982a3b7a..1ab974533697ea91609386da13e88c323ee8157e 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/fs.h>
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
+#include <linux/slab.h>
 #include "sb.h"
 
 /* the_nilfs struct */
index 037e878e03fcac70005fd6da12f776c76d89b38f..fcc2f064af8305b49c2387196bdb24bcc2f15d1e 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/dcache.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/srcu.h>
index 3165d85aada2d5ee14a7e46dee6f0c8d07ee8686..0399bcbe09c83f02bdf1627b1dcfc6b12c316d5f 100644 (file)
@@ -87,7 +87,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/writeback.h> /* for inode_lock */
 
index cfce53cb65d76e0177601b129d972b8365d7d892..c3c2c7ac9020402d28dd0d2357ae2828c6e639a5 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
index 50d3b0c258e37cd0413568aef6d4216086a6bb02..f5094ee224c1fc1fbba40c4eddcb6f9480eea819 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/buffer_head.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/writeback.h>
 
index 08f7530e9341cf06f55a17b1fabef30a64e12363..6551c7cbad92954202258d8715a3d44e06bc7d4b 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/buffer_head.h>
 #include <linux/blkdev.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 
 #include "attrib.h"
 #include "inode.h"
index 9173e82a45d132f92caa4b066b762ee608e95e79..fe44d3feee4a1b06222600e6028abfca4d5c0df0 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/buffer_head.h>
+#include <linux/slab.h>
 
 #include "dir.h"
 #include "aops.h"
index b681c71d70698f3b8df25e2d06cfe52e77aa4bc5..8804f093ba7512d309f6b94e7080cb0eb561ef74 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/buffer_head.h>
+#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/pagevec.h>
 #include <linux/sched.h>
index 2194eff4974379062c1d19578228766555da2519..096c135691aeda354c553fdb622286ea7f048e06 100644 (file)
@@ -19,6 +19,8 @@
  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/slab.h>
+
 #include "aops.h"
 #include "collate.h"
 #include "debug.h"
index 1caa0ef0b2bba8c0e27fe2154d8e633210feb0e7..b572b672718110e317a6895698bdf612b2e8eced 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/buffer_head.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 
 #include "attrib.h"
index 2ca00153b6ece6ea51de28d8eb3925eb86be36bc..358273e59aded3d416dea0f1e67627731d9d0d8f 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/dcache.h>
 #include <linux/exportfs.h>
 #include <linux/security.h>
+#include <linux/slab.h>
 
 #include "attrib.h"
 #include "debug.h"
index 0501974bedd0d3b96764b48b5725054fbe7ca412..e13fc9e8fcdc02bc55964f673b51d228cb6811cc 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 
 #define MLOG_MASK_PREFIX ML_INODE
@@ -30,6 +31,8 @@
 #include "alloc.h"
 #include "dlmglue.h"
 #include "file.h"
+#include "inode.h"
+#include "journal.h"
 #include "ocfs2_fs.h"
 
 #include "xattr.h"
@@ -165,6 +168,60 @@ static struct posix_acl *ocfs2_get_acl(struct inode *inode, int type)
        return acl;
 }
 
+/*
+ * Helper function to set i_mode in memory and disk. Some call paths
+ * will not have di_bh or a journal handle to pass, in which case it
+ * will create it's own.
+ */
+static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
+                             handle_t *handle, umode_t new_mode)
+{
+       int ret, commit_handle = 0;
+       struct ocfs2_dinode *di;
+
+       if (di_bh == NULL) {
+               ret = ocfs2_read_inode_block(inode, &di_bh);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
+       } else
+               get_bh(di_bh);
+
+       if (handle == NULL) {
+               handle = ocfs2_start_trans(OCFS2_SB(inode->i_sb),
+                                          OCFS2_INODE_UPDATE_CREDITS);
+               if (IS_ERR(handle)) {
+                       ret = PTR_ERR(handle);
+                       mlog_errno(ret);
+                       goto out_brelse;
+               }
+
+               commit_handle = 1;
+       }
+
+       di = (struct ocfs2_dinode *)di_bh->b_data;
+       ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
+                                     OCFS2_JOURNAL_ACCESS_WRITE);
+       if (ret) {
+               mlog_errno(ret);
+               goto out_commit;
+       }
+
+       inode->i_mode = new_mode;
+       di->i_mode = cpu_to_le16(inode->i_mode);
+
+       ocfs2_journal_dirty(handle, di_bh);
+
+out_commit:
+       if (commit_handle)
+               ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
+out_brelse:
+       brelse(di_bh);
+out:
+       return ret;
+}
+
 /*
  * Set the access or default ACL of an inode.
  */
@@ -193,9 +250,14 @@ static int ocfs2_set_acl(handle_t *handle,
                        if (ret < 0)
                                return ret;
                        else {
-                               inode->i_mode = mode;
                                if (ret == 0)
                                        acl = NULL;
+
+                               ret = ocfs2_acl_set_mode(inode, di_bh,
+                                                        handle, mode);
+                               if (ret)
+                                       return ret;
+
                        }
                }
                break;
@@ -283,6 +345,7 @@ int ocfs2_init_acl(handle_t *handle,
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct posix_acl *acl = NULL;
        int ret = 0;
+       mode_t mode;
 
        if (!S_ISLNK(inode->i_mode)) {
                if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
@@ -291,12 +354,17 @@ int ocfs2_init_acl(handle_t *handle,
                        if (IS_ERR(acl))
                                return PTR_ERR(acl);
                }
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
+               if (!acl) {
+                       mode = inode->i_mode & ~current_umask();
+                       ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
+                       if (ret) {
+                               mlog_errno(ret);
+                               goto cleanup;
+                       }
+               }
        }
        if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
                struct posix_acl *clone;
-               mode_t mode;
 
                if (S_ISDIR(inode->i_mode)) {
                        ret = ocfs2_set_acl(handle, inode, di_bh,
@@ -313,7 +381,7 @@ int ocfs2_init_acl(handle_t *handle,
                mode = inode->i_mode;
                ret = posix_acl_create_masq(clone, &mode);
                if (ret >= 0) {
-                       inode->i_mode = mode;
+                       ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
                        if (ret > 0) {
                                ret = ocfs2_set_acl(handle, inode,
                                                    di_bh, ACL_TYPE_ACCESS,
index 21c808f752d8dc42381ce556547d7ae60c4c82bb..ecebb2276790af6155c746106d2cd8ae758f3c56 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 
 #include <cluster/masklog.h>
index 5c98900067082d6066b26e50cc33dec31e7a769d..41d5f1f92d56f60a45f6066d875598bda7caddf2 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/crc32.h>
 #include <linux/time.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 #include "heartbeat.h"
 #include "tcp.h"
index c81142e3ef844def09ef96725f2ebb68247aaecc..ed0c9f367fed03fe0114b6956b6bb4a34ade5b77 100644 (file)
@@ -19,6 +19,7 @@
  * Boston, MA 021110-1307, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/configfs.h>
index 639024033fceeea6cc5978bcdcf3c3a65f216986..cf3e16696216d4fa95f30c0247ee58e608f54047 100644 (file)
@@ -44,7 +44,6 @@
  * and if they're the last, they fire off the decision.
  */
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/reboot.h>
 
index dccc439fa087ce65a202ed7a5aa994dd79fa6e9e..a795eb91f4ea396c1a4614e155cff885bc6770c4 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
index f283bce776b48e4d916cd4a6b4d84c7b38775c69..90803b47cd8cfb71945908c4fe120a2a0641429a 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
index a659606dcb9592f1d0c719ed7167b1fe158296f2..9289b4357d27dcf0559a5b6f438e0ca4205e359b 100644 (file)
@@ -1875,7 +1875,6 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
 ok:
                spin_unlock(&res->spinlock);
        }
-       spin_unlock(&dlm->spinlock);
 
        // mlog(0, "woo!  got an assert_master from node %u!\n",
        //           assert->node_idx);
@@ -1926,7 +1925,6 @@ ok:
                /* master is known, detach if not already detached.
                 * ensures that only one assert_master call will happen
                 * on this mle. */
-               spin_lock(&dlm->spinlock);
                spin_lock(&dlm->master_lock);
 
                rr = atomic_read(&mle->mle_refs.refcount);
@@ -1959,7 +1957,6 @@ ok:
                        __dlm_put_mle(mle);
                }
                spin_unlock(&dlm->master_lock);
-               spin_unlock(&dlm->spinlock);
        } else if (res) {
                if (res->owner != assert->node_idx) {
                        mlog(0, "assert_master from %u, but current "
@@ -1967,6 +1964,7 @@ ok:
                             res->owner, namelen, name);
                }
        }
+       spin_unlock(&dlm->spinlock);
 
 done:
        ret = 0;
index 52ec020ea78b42f11ad83b3a2632dbcf08a20dde..11a6d1fd1d35ad71670515efcc204cc3170eb3a6 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
index 49e29ecd02017be2144c2f50df76b8b0f761ad2d..b47c1b92b82b6d6065abc6e9145def26b0a2e829 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
index c562a7581cf93b709e79d70be22034f1e5be7a63..09e3fdfa6d33f603f6fe2a9bcdade3f979565e61 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/fiemap.h>
 
index c6e7213db8688744bdd21d05d5f6296a5e7dcc91..1aa863dd901f783d71e54f19b37e78440fe46693 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 
 #define MLOG_MASK_PREFIX ML_SUPER
index 278a223aae14b8a2d347890735c729567e3840cc..07cc8bb68b6d3228daa7352e90733d68ecce639c 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
@@ -891,6 +890,21 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
        /* Do some basic inode verification... */
        di = (struct ocfs2_dinode *) di_bh->b_data;
        if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL))) {
+               /*
+                * Inodes in the orphan dir must have ORPHANED_FL.  The only
+                * inodes that come back out of the orphan dir are reflink
+                * targets. A reflink target may be moved out of the orphan
+                * dir between the time we scan the directory and the time we
+                * process it. This would lead to HAS_REFCOUNT_FL being set but
+                * ORPHANED_FL not.
+                */
+               if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) {
+                       mlog(0, "Reflinked inode %llu is no longer orphaned.  "
+                            "it shouldn't be deleted\n",
+                            (unsigned long long)oi->ip_blkno);
+                       goto bail;
+               }
+
                /* for lack of a better error? */
                status = -EEXIST;
                mlog(ML_ERROR,
index ca992d91f5110e9a376ca4a0f71a5101f4294e29..c983715d8d8c3d7d734ade4ae339f39439d82aa0 100644 (file)
@@ -872,8 +872,10 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
                             (unsigned long long)la_start_blk,
                             (unsigned long long)blkno);
 
-                       status = ocfs2_free_clusters(handle, main_bm_inode,
-                                                    main_bm_bh, blkno, count);
+                       status = ocfs2_release_clusters(handle,
+                                                       main_bm_inode,
+                                                       main_bm_bh, blkno,
+                                                       count);
                        if (status < 0) {
                                mlog_errno(status);
                                goto bail;
@@ -984,8 +986,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
        }
 
 retry_enospc:
-       (*ac)->ac_bits_wanted = osb->local_alloc_bits;
-
+       (*ac)->ac_bits_wanted = osb->local_alloc_default_bits;
        status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
        if (status == -ENOSPC) {
                if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_ENOSPC) ==
@@ -1061,6 +1062,7 @@ retry_enospc:
                    OCFS2_LA_DISABLED)
                        goto bail;
 
+               ac->ac_bits_wanted = osb->local_alloc_default_bits;
                status = ocfs2_claim_clusters(osb, handle, ac,
                                              osb->local_alloc_bits,
                                              &cluster_off,
index 544ac6245175f26c23249cf916c5001ae8f5d067..b5cb3ede9408944d99abc7c7c3b28c01b1ddadeb 100644 (file)
@@ -133,7 +133,7 @@ int ocfs2_lock(struct file *file, int cmd, struct file_lock *fl)
 
        if (!(fl->fl_flags & FL_POSIX))
                return -ENOLCK;
-       if (__mandatory_lock(inode))
+       if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
                return -ENOLCK;
 
        return ocfs2_plock(osb->cconn, OCFS2_I(inode)->ip_blkno, file, cmd, fl);
index 39737613424a2c073c21c540e7b022b96e344da9..7898bd3a99f54a50de060af137d996b699ac8952 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/uio.h>
index d9cd4e373a5309e24602b5dab9899f208a756523..b1eb50ae40979a6451cbc5db003313a013868d54 100644 (file)
@@ -84,7 +84,7 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
 static int ocfs2_orphan_add(struct ocfs2_super *osb,
                            handle_t *handle,
                            struct inode *inode,
-                           struct ocfs2_dinode *fe,
+                           struct buffer_head *fe_bh,
                            char *name,
                            struct ocfs2_dir_lookup_result *lookup,
                            struct inode *orphan_dir_inode);
@@ -879,7 +879,7 @@ static int ocfs2_unlink(struct inode *dir,
        fe = (struct ocfs2_dinode *) fe_bh->b_data;
 
        if (inode_is_unlinkable(inode)) {
-               status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name,
+               status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name,
                                          &orphan_insert, orphan_dir);
                if (status < 0) {
                        mlog_errno(status);
@@ -1300,7 +1300,7 @@ static int ocfs2_rename(struct inode *old_dir,
                if (S_ISDIR(new_inode->i_mode) ||
                    (ocfs2_read_links_count(newfe) == 1)) {
                        status = ocfs2_orphan_add(osb, handle, new_inode,
-                                                 newfe, orphan_name,
+                                                 newfe_bh, orphan_name,
                                                  &orphan_insert, orphan_dir);
                        if (status < 0) {
                                mlog_errno(status);
@@ -1911,7 +1911,7 @@ leave:
 static int ocfs2_orphan_add(struct ocfs2_super *osb,
                            handle_t *handle,
                            struct inode *inode,
-                           struct ocfs2_dinode *fe,
+                           struct buffer_head *fe_bh,
                            char *name,
                            struct ocfs2_dir_lookup_result *lookup,
                            struct inode *orphan_dir_inode)
@@ -1919,6 +1919,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
        struct buffer_head *orphan_dir_bh = NULL;
        int status = 0;
        struct ocfs2_dinode *orphan_fe;
+       struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
 
        mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
 
@@ -1959,6 +1960,21 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
                goto leave;
        }
 
+       /*
+        * We're going to journal the change of i_flags and i_orphaned_slot.
+        * It's safe anyway, though some callers may duplicate the journaling.
+        * Journaling within the func just make the logic look more
+        * straightforward.
+        */
+       status = ocfs2_journal_access_di(handle,
+                                        INODE_CACHE(inode),
+                                        fe_bh,
+                                        OCFS2_JOURNAL_ACCESS_WRITE);
+       if (status < 0) {
+               mlog_errno(status);
+               goto leave;
+       }
+
        le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL);
 
        /* Record which orphan dir our inode now resides
@@ -1966,6 +1982,8 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
         * dir to lock. */
        fe->i_orphaned_slot = cpu_to_le16(osb->slot_num);
 
+       ocfs2_journal_dirty(handle, fe_bh);
+
        mlog(0, "Inode %llu orphaned in slot %d\n",
             (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
 
@@ -2123,7 +2141,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
        }
 
        di = (struct ocfs2_dinode *)new_di_bh->b_data;
-       status = ocfs2_orphan_add(osb, handle, inode, di, orphan_name,
+       status = ocfs2_orphan_add(osb, handle, inode, new_di_bh, orphan_name,
                                  &orphan_insert, orphan_dir);
        if (status < 0) {
                mlog_errno(status);
index 1238b491db90d5635059f07a44178b8a7e9a1571..adf5e2ebc2c436b60992dfc39ae506327aaf9054 100644 (file)
@@ -763,8 +763,18 @@ static inline unsigned int ocfs2_megabytes_to_clusters(struct super_block *sb,
        return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits);
 }
 
-#define ocfs2_set_bit ext2_set_bit
-#define ocfs2_clear_bit ext2_clear_bit
+static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap)
+{
+       ext2_set_bit(bit, bitmap);
+}
+#define ocfs2_set_bit(bit, addr) _ocfs2_set_bit((bit), (unsigned long *)(addr))
+
+static inline void _ocfs2_clear_bit(unsigned int bit, unsigned long *bitmap)
+{
+       ext2_clear_bit(bit, bitmap);
+}
+#define ocfs2_clear_bit(bit, addr) _ocfs2_clear_bit((bit), (unsigned long *)(addr))
+
 #define ocfs2_test_bit ext2_test_bit
 #define ocfs2_find_next_zero_bit ext2_find_next_zero_bit
 #define ocfs2_find_next_bit ext2_find_next_bit
index 355f41d1d520742b7ebb650333c705515c72f01e..ab42a74c7539246a5adfaf4d4412e06e7fbfd6f1 100644 (file)
@@ -3,6 +3,7 @@
  */
 #include <linux/spinlock.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/quota.h>
 #include <linux/quotaops.h>
 #include <linux/dqblk_qtree.h>
index a6467f3d262ee6bd720a732d396e23b3e4637ade..9ad49305f4505d57b04271ab56a91d7f238d5739 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/quota.h>
 #include <linux/quotaops.h>
 #include <linux/module.h>
index 9e96921dffda4f9f9b32970c142bacc59984802a..bd96f6c7877ed89766ae07ddd616d3f2f0ac344f 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <linux/bio.h>
 #include <linux/blkdev.h>
-#include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/writeback.h>
 #include <linux/pagevec.h>
@@ -4075,6 +4074,7 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
        OCFS2_I(t_inode)->ip_dyn_features = OCFS2_I(s_inode)->ip_dyn_features;
        spin_unlock(&OCFS2_I(t_inode)->ip_lock);
        i_size_write(t_inode, size);
+       t_inode->i_blocks = s_inode->i_blocks;
 
        di->i_xattr_inline_size = s_di->i_xattr_inline_size;
        di->i_clusters = s_di->i_clusters;
index 7020e1253ffae91c5aa359f51405a8c99ee60061..0d3049f696c5418448173ed3538020bd5d51b9d0 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/kernel.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 
 /* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
index 5ae8812b28647975bdba323cd09997f6c6213d5c..2dc57bca0688165366364d88448d1e884ef6dd9f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/reboot.h>
 #include <asm/uaccess.h>
index c3c60bc3e0729a5fb55f99254dc5babd150ae6ff..19ba00f28547bcf0d31fc8bc69ed34c340660c85 100644 (file)
@@ -95,13 +95,6 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle,
                                             struct buffer_head *group_bh,
                                             unsigned int bit_off,
                                             unsigned int num_bits);
-static inline int ocfs2_block_group_clear_bits(handle_t *handle,
-                                              struct inode *alloc_inode,
-                                              struct ocfs2_group_desc *bg,
-                                              struct buffer_head *group_bh,
-                                              unsigned int bit_off,
-                                              unsigned int num_bits);
-
 static int ocfs2_relink_block_group(handle_t *handle,
                                    struct inode *alloc_inode,
                                    struct buffer_head *fe_bh,
@@ -152,7 +145,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
 
 #define do_error(fmt, ...)                                             \
        do{                                                             \
-               if (clean_error)                                        \
+               if (resize)                                     \
                        mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__);        \
                else                                                    \
                        ocfs2_error(sb, fmt, ##__VA_ARGS__);            \
@@ -160,7 +153,7 @@ static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
 
 static int ocfs2_validate_gd_self(struct super_block *sb,
                                  struct buffer_head *bh,
-                                 int clean_error)
+                                 int resize)
 {
        struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
 
@@ -211,7 +204,7 @@ static int ocfs2_validate_gd_self(struct super_block *sb,
 static int ocfs2_validate_gd_parent(struct super_block *sb,
                                    struct ocfs2_dinode *di,
                                    struct buffer_head *bh,
-                                   int clean_error)
+                                   int resize)
 {
        unsigned int max_bits;
        struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
@@ -233,8 +226,11 @@ static int ocfs2_validate_gd_parent(struct super_block *sb,
                return -EINVAL;
        }
 
-       if (le16_to_cpu(gd->bg_chain) >=
-           le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
+       /* In resize, we may meet the case bg_chain == cl_next_free_rec. */
+       if ((le16_to_cpu(gd->bg_chain) >
+            le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) ||
+           ((le16_to_cpu(gd->bg_chain) ==
+            le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) && !resize)) {
                do_error("Group descriptor #%llu has bad chain %u",
                         (unsigned long long)bh->b_blocknr,
                         le16_to_cpu(gd->bg_chain));
@@ -1975,18 +1971,18 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
                                      bits_wanted, cluster_start, num_clusters);
 }
 
-static inline int ocfs2_block_group_clear_bits(handle_t *handle,
-                                              struct inode *alloc_inode,
-                                              struct ocfs2_group_desc *bg,
-                                              struct buffer_head *group_bh,
-                                              unsigned int bit_off,
-                                              unsigned int num_bits)
+static int ocfs2_block_group_clear_bits(handle_t *handle,
+                                       struct inode *alloc_inode,
+                                       struct ocfs2_group_desc *bg,
+                                       struct buffer_head *group_bh,
+                                       unsigned int bit_off,
+                                       unsigned int num_bits,
+                                       void (*undo_fn)(unsigned int bit,
+                                                       unsigned long *bmap))
 {
        int status;
        unsigned int tmp;
-       int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
        struct ocfs2_group_desc *undo_bg = NULL;
-       int cluster_bitmap = 0;
 
        mlog_entry_void();
 
@@ -1996,20 +1992,18 @@ static inline int ocfs2_block_group_clear_bits(handle_t *handle,
 
        mlog(0, "off = %u, num = %u\n", bit_off, num_bits);
 
-       if (ocfs2_is_cluster_bitmap(alloc_inode))
-               journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
-
+       BUG_ON(undo_fn && !ocfs2_is_cluster_bitmap(alloc_inode));
        status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode),
-                                        group_bh, journal_type);
+                                        group_bh,
+                                        undo_fn ?
+                                        OCFS2_JOURNAL_ACCESS_UNDO :
+                                        OCFS2_JOURNAL_ACCESS_WRITE);
        if (status < 0) {
                mlog_errno(status);
                goto bail;
        }
 
-       if (ocfs2_is_cluster_bitmap(alloc_inode))
-               cluster_bitmap = 1;
-
-       if (cluster_bitmap) {
+       if (undo_fn) {
                jbd_lock_bh_state(group_bh);
                undo_bg = (struct ocfs2_group_desc *)
                                        bh2jh(group_bh)->b_committed_data;
@@ -2020,13 +2014,13 @@ static inline int ocfs2_block_group_clear_bits(handle_t *handle,
        while(tmp--) {
                ocfs2_clear_bit((bit_off + tmp),
                                (unsigned long *) bg->bg_bitmap);
-               if (cluster_bitmap)
-                       ocfs2_set_bit(bit_off + tmp,
-                                     (unsigned long *) undo_bg->bg_bitmap);
+               if (undo_fn)
+                       undo_fn(bit_off + tmp,
+                               (unsigned long *) undo_bg->bg_bitmap);
        }
        le16_add_cpu(&bg->bg_free_bits_count, num_bits);
 
-       if (cluster_bitmap)
+       if (undo_fn)
                jbd_unlock_bh_state(group_bh);
 
        status = ocfs2_journal_dirty(handle, group_bh);
@@ -2039,12 +2033,14 @@ bail:
 /*
  * expects the suballoc inode to already be locked.
  */
-int ocfs2_free_suballoc_bits(handle_t *handle,
-                            struct inode *alloc_inode,
-                            struct buffer_head *alloc_bh,
-                            unsigned int start_bit,
-                            u64 bg_blkno,
-                            unsigned int count)
+static int _ocfs2_free_suballoc_bits(handle_t *handle,
+                                    struct inode *alloc_inode,
+                                    struct buffer_head *alloc_bh,
+                                    unsigned int start_bit,
+                                    u64 bg_blkno,
+                                    unsigned int count,
+                                    void (*undo_fn)(unsigned int bit,
+                                                    unsigned long *bitmap))
 {
        int status = 0;
        u32 tmp_used;
@@ -2079,7 +2075,7 @@ int ocfs2_free_suballoc_bits(handle_t *handle,
 
        status = ocfs2_block_group_clear_bits(handle, alloc_inode,
                                              group, group_bh,
-                                             start_bit, count);
+                                             start_bit, count, undo_fn);
        if (status < 0) {
                mlog_errno(status);
                goto bail;
@@ -2110,6 +2106,17 @@ bail:
        return status;
 }
 
+int ocfs2_free_suballoc_bits(handle_t *handle,
+                            struct inode *alloc_inode,
+                            struct buffer_head *alloc_bh,
+                            unsigned int start_bit,
+                            u64 bg_blkno,
+                            unsigned int count)
+{
+       return _ocfs2_free_suballoc_bits(handle, alloc_inode, alloc_bh,
+                                        start_bit, bg_blkno, count, NULL);
+}
+
 int ocfs2_free_dinode(handle_t *handle,
                      struct inode *inode_alloc_inode,
                      struct buffer_head *inode_alloc_bh,
@@ -2123,11 +2130,13 @@ int ocfs2_free_dinode(handle_t *handle,
                                        inode_alloc_bh, bit, bg_blkno, 1);
 }
 
-int ocfs2_free_clusters(handle_t *handle,
-                      struct inode *bitmap_inode,
-                      struct buffer_head *bitmap_bh,
-                      u64 start_blk,
-                      unsigned int num_clusters)
+static int _ocfs2_free_clusters(handle_t *handle,
+                               struct inode *bitmap_inode,
+                               struct buffer_head *bitmap_bh,
+                               u64 start_blk,
+                               unsigned int num_clusters,
+                               void (*undo_fn)(unsigned int bit,
+                                               unsigned long *bitmap))
 {
        int status;
        u16 bg_start_bit;
@@ -2154,9 +2163,9 @@ int ocfs2_free_clusters(handle_t *handle,
        mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n",
             (unsigned long long)bg_blkno, bg_start_bit);
 
-       status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh,
-                                         bg_start_bit, bg_blkno,
-                                         num_clusters);
+       status = _ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh,
+                                          bg_start_bit, bg_blkno,
+                                          num_clusters, undo_fn);
        if (status < 0) {
                mlog_errno(status);
                goto out;
@@ -2170,6 +2179,32 @@ out:
        return status;
 }
 
+int ocfs2_free_clusters(handle_t *handle,
+                       struct inode *bitmap_inode,
+                       struct buffer_head *bitmap_bh,
+                       u64 start_blk,
+                       unsigned int num_clusters)
+{
+       return _ocfs2_free_clusters(handle, bitmap_inode, bitmap_bh,
+                                   start_blk, num_clusters,
+                                   _ocfs2_set_bit);
+}
+
+/*
+ * Give never-used clusters back to the global bitmap.  We don't need
+ * to protect these bits in the undo buffer.
+ */
+int ocfs2_release_clusters(handle_t *handle,
+                          struct inode *bitmap_inode,
+                          struct buffer_head *bitmap_bh,
+                          u64 start_blk,
+                          unsigned int num_clusters)
+{
+       return _ocfs2_free_clusters(handle, bitmap_inode, bitmap_bh,
+                                   start_blk, num_clusters,
+                                   _ocfs2_clear_bit);
+}
+
 static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg)
 {
        printk("Block Group:\n");
index fa60723c43e82b0a6d766e8ea439af393a7ce7bd..e0f46df357e664cc7b8c883b1d509fe884fcb950 100644 (file)
@@ -127,6 +127,11 @@ int ocfs2_free_clusters(handle_t *handle,
                        struct buffer_head *bitmap_bh,
                        u64 start_blk,
                        unsigned int num_clusters);
+int ocfs2_release_clusters(handle_t *handle,
+                          struct inode *bitmap_inode,
+                          struct buffer_head *bitmap_bh,
+                          u64 start_blk,
+                          unsigned int num_clusters);
 
 static inline u64 ocfs2_which_suballoc_group(u64 block, unsigned int bit)
 {
index 40e53702948cdbc2ed92ce1e22f0827f76017417..bfe7190cdbf1b0969cc5e2ade3096a9cea16e9ad 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/highmem.h>
 
 #define MLOG_MASK_PREFIX ML_INODE
index d1b0d386f6d1c43c58b8e0016530f7830ea6eddf..3e7773089b968d7f29a0986fd65731646d0a382d 100644 (file)
@@ -1622,7 +1622,7 @@ static void ocfs2_xa_block_wipe_namevalue(struct ocfs2_xa_loc *loc)
        /* Now tell xh->xh_entries about it */
        for (i = 0; i < count; i++) {
                offset = le16_to_cpu(xh->xh_entries[i].xe_name_offset);
-               if (offset < namevalue_offset)
+               if (offset <= namevalue_offset)
                        le16_add_cpu(&xh->xh_entries[i].xe_name_offset,
                                     namevalue_size);
        }
@@ -6528,13 +6528,11 @@ static int ocfs2_create_empty_xattr_block(struct inode *inode,
                                          int indexed)
 {
        int ret;
-       struct ocfs2_alloc_context *meta_ac;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       struct ocfs2_xattr_set_ctxt ctxt = {
-               .meta_ac = meta_ac,
-       };
+       struct ocfs2_xattr_set_ctxt ctxt;
 
-       ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &meta_ac);
+       memset(&ctxt, 0, sizeof(ctxt));
+       ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &ctxt.meta_ac);
        if (ret < 0) {
                mlog_errno(ret);
                return ret;
@@ -6556,7 +6554,7 @@ static int ocfs2_create_empty_xattr_block(struct inode *inode,
 
        ocfs2_commit_trans(osb, ctxt.handle);
 out:
-       ocfs2_free_alloc_context(meta_ac);
+       ocfs2_free_alloc_context(ctxt.meta_ac);
        return ret;
 }
 
index 75d9b5ba1d451c9bbdb40fc0baeb49bcd825cf78..c82af6acc2e7250d56db070b549e33e2a2787b50 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/vfs.h>
 #include <linux/parser.h>
index e17f54454b5076b231e37c023abd31a1237445d5..74e5cd9f718e8b43eb17e8dad2f28074591fbaaf 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -10,7 +10,6 @@
 #include <linux/fdtable.h>
 #include <linux/fsnotify.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/tty.h>
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
@@ -20,6 +19,7 @@
 #include <linux/mount.h>
 #include <linux/vfs.h>
 #include <linux/fcntl.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/fs.h>
 #include <linux/personality.h>
index e8865c11777f726a9622f7f7835a6c0ac8551021..e238ab23a9e7ff50f712847e3660f4f67a5912d2 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/kmod.h>
 #include <linux/ctype.h>
 #include <linux/genhd.h>
index 49cfd5f5423894df4c2f52ac48bac1f82a9b43a3..91babdae75875bc0e7510c9594529cca1247e20c 100644 (file)
@@ -95,6 +95,7 @@
  ************************************************************/
 #include <linux/crc32.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 #include "check.h"
 #include "efi.h"
 
index 0028d2ef0662b0f01fd21b7685754d9939ebbd51..90be97f1f5a8c8ce5cf737c3e52020e0e516a291 100644 (file)
  */
 #include <asm/unaligned.h>
 
-#define SYS_IND(p)     (get_unaligned(&p->sys_ind))
-#define NR_SECTS(p)    ({ __le32 __a = get_unaligned(&p->nr_sects);    \
-                               le32_to_cpu(__a); \
-                       })
+#define SYS_IND(p)     get_unaligned(&p->sys_ind)
 
-#define START_SECT(p)  ({ __le32 __a = get_unaligned(&p->start_sect);  \
-                               le32_to_cpu(__a); \
-                       })
+static inline sector_t nr_sects(struct partition *p)
+{
+       return (sector_t)get_unaligned_le32(&p->nr_sects);
+}
+
+static inline sector_t start_sect(struct partition *p)
+{
+       return (sector_t)get_unaligned_le32(&p->start_sect);
+}
 
 static inline int is_extended_partition(struct partition *p)
 {
@@ -104,13 +107,13 @@ static int aix_magic_present(unsigned char *p, struct block_device *bdev)
 
 static void
 parse_extended(struct parsed_partitions *state, struct block_device *bdev,
-                       u32 first_sector, u32 first_size)
+                       sector_t first_sector, sector_t first_size)
 {
        struct partition *p;
        Sector sect;
        unsigned char *data;
-       u32 this_sector, this_size;
-       int sector_size = bdev_logical_block_size(bdev) / 512;
+       sector_t this_sector, this_size;
+       sector_t sector_size = bdev_logical_block_size(bdev) / 512;
        int loopct = 0;         /* number of links followed
                                   without finding a data partition */
        int i;
@@ -145,14 +148,14 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev,
                 * First process the data partition(s)
                 */
                for (i=0; i<4; i++, p++) {
-                       u32 offs, size, next;
-                       if (!NR_SECTS(p) || is_extended_partition(p))
+                       sector_t offs, size, next;
+                       if (!nr_sects(p) || is_extended_partition(p))
                                continue;
 
                        /* Check the 3rd and 4th entries -
                           these sometimes contain random garbage */
-                       offs = START_SECT(p)*sector_size;
-                       size = NR_SECTS(p)*sector_size;
+                       offs = start_sect(p)*sector_size;
+                       size = nr_sects(p)*sector_size;
                        next = this_sector + offs;
                        if (i >= 2) {
                                if (offs + size > this_size)
@@ -179,13 +182,13 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev,
                 */
                p -= 4;
                for (i=0; i<4; i++, p++)
-                       if (NR_SECTS(p) && is_extended_partition(p))
+                       if (nr_sects(p) && is_extended_partition(p))
                                break;
                if (i == 4)
                        goto done;       /* nothing left to do */
 
-               this_sector = first_sector + START_SECT(p) * sector_size;
-               this_size = NR_SECTS(p) * sector_size;
+               this_sector = first_sector + start_sect(p) * sector_size;
+               this_size = nr_sects(p) * sector_size;
                put_dev_sector(sect);
        }
 done:
@@ -197,7 +200,7 @@ done:
 
 static void
 parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,
-                       u32 offset, u32 size, int origin)
+                       sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_SOLARIS_X86_PARTITION
        Sector sect;
@@ -244,7 +247,7 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,
  */
 static void
 parse_bsd(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin, char *flavour,
+               sector_t offset, sector_t size, int origin, char *flavour,
                int max_partitions)
 {
        Sector sect;
@@ -263,7 +266,7 @@ parse_bsd(struct parsed_partitions *state, struct block_device *bdev,
        if (le16_to_cpu(l->d_npartitions) < max_partitions)
                max_partitions = le16_to_cpu(l->d_npartitions);
        for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) {
-               u32 bsd_start, bsd_size;
+               sector_t bsd_start, bsd_size;
 
                if (state->next == state->limit)
                        break;
@@ -290,7 +293,7 @@ parse_bsd(struct parsed_partitions *state, struct block_device *bdev,
 
 static void
 parse_freebsd(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin)
+               sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_BSD_DISKLABEL
        parse_bsd(state, bdev, offset, size, origin,
@@ -300,7 +303,7 @@ parse_freebsd(struct parsed_partitions *state, struct block_device *bdev,
 
 static void
 parse_netbsd(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin)
+               sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_BSD_DISKLABEL
        parse_bsd(state, bdev, offset, size, origin,
@@ -310,7 +313,7 @@ parse_netbsd(struct parsed_partitions *state, struct block_device *bdev,
 
 static void
 parse_openbsd(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin)
+               sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_BSD_DISKLABEL
        parse_bsd(state, bdev, offset, size, origin,
@@ -324,7 +327,7 @@ parse_openbsd(struct parsed_partitions *state, struct block_device *bdev,
  */
 static void
 parse_unixware(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin)
+               sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_UNIXWARE_DISKLABEL
        Sector sect;
@@ -348,7 +351,8 @@ parse_unixware(struct parsed_partitions *state, struct block_device *bdev,
 
                if (p->s_label != UNIXWARE_FS_UNUSED)
                        put_partition(state, state->next++,
-                                               START_SECT(p), NR_SECTS(p));
+                                     le32_to_cpu(p->start_sect),
+                                     le32_to_cpu(p->nr_sects));
                p++;
        }
        put_dev_sector(sect);
@@ -363,7 +367,7 @@ parse_unixware(struct parsed_partitions *state, struct block_device *bdev,
  */
 static void
 parse_minix(struct parsed_partitions *state, struct block_device *bdev,
-               u32 offset, u32 size, int origin)
+               sector_t offset, sector_t size, int origin)
 {
 #ifdef CONFIG_MINIX_SUBPARTITION
        Sector sect;
@@ -390,7 +394,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev,
                        /* add each partition in use */
                        if (SYS_IND(p) == MINIX_PARTITION)
                                put_partition(state, state->next++,
-                                             START_SECT(p), NR_SECTS(p));
+                                             start_sect(p), nr_sects(p));
                }
                printk(" >\n");
        }
@@ -401,7 +405,7 @@ parse_minix(struct parsed_partitions *state, struct block_device *bdev,
 static struct {
        unsigned char id;
        void (*parse)(struct parsed_partitions *, struct block_device *,
-                       u32, u32, int);
+                       sector_t, sector_t, int);
 } subtypes[] = {
        {FREEBSD_PARTITION, parse_freebsd},
        {NETBSD_PARTITION, parse_netbsd},
@@ -415,7 +419,7 @@ static struct {
  
 int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
-       int sector_size = bdev_logical_block_size(bdev) / 512;
+       sector_t sector_size = bdev_logical_block_size(bdev) / 512;
        Sector sect;
        unsigned char *data;
        struct partition *p;
@@ -483,14 +487,21 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
 
        state->next = 5;
        for (slot = 1 ; slot <= 4 ; slot++, p++) {
-               u32 start = START_SECT(p)*sector_size;
-               u32 size = NR_SECTS(p)*sector_size;
+               sector_t start = start_sect(p)*sector_size;
+               sector_t size = nr_sects(p)*sector_size;
                if (!size)
                        continue;
                if (is_extended_partition(p)) {
-                       /* prevent someone doing mkfs or mkswap on an
-                          extended partition, but leave room for LILO */
-                       put_partition(state, slot, start, size == 1 ? 1 : 2);
+                       /*
+                        * prevent someone doing mkfs or mkswap on an
+                        * extended partition, but leave room for LILO
+                        * FIXME: this uses one logical sector for > 512b
+                        * sector, although it may not be enough/proper.
+                        */
+                       sector_t n = 2;
+                       n = min(size, max(sector_size, n));
+                       put_partition(state, slot, start, n);
+
                        printk(" <");
                        parse_extended(state, bdev, start, size);
                        printk(" >");
@@ -513,7 +524,7 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
                unsigned char id = SYS_IND(p);
                int n;
 
-               if (!NR_SECTS(p))
+               if (!nr_sects(p))
                        continue;
 
                for (n = 0; subtypes[n].parse && id != subtypes[n].id; n++)
@@ -521,8 +532,8 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
 
                if (!subtypes[n].parse)
                        continue;
-               subtypes[n].parse(state, bdev, START_SECT(p)*sector_size,
-                                               NR_SECTS(p)*sector_size, slot);
+               subtypes[n].parse(state, bdev, start_sect(p)*sector_size,
+                                               nr_sects(p)*sector_size, slot);
        }
        put_dev_sector(sect);
        return 1;
index aa8637b81028b573c4feb395541be560aab5a1a3..e51f2ec2c5e5c53809cacac73c544daaec76a579 100644 (file)
@@ -68,7 +68,6 @@
 #include <linux/hugetlb.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/signal.h>
 #include <linux/highmem.h>
index a7310841c83149e406c1089d30a8c27b2c1e67fb..7621db800a74b85d440055f590acf10daeb67550 100644 (file)
@@ -81,6 +81,7 @@
 #include <linux/elf.h>
 #include <linux/pid_namespace.h>
 #include <linux/fs_struct.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 /* NOTE:
@@ -442,12 +443,13 @@ static const struct file_operations proc_lstats_operations = {
 unsigned long badness(struct task_struct *p, unsigned long uptime);
 static int proc_oom_score(struct task_struct *task, char *buffer)
 {
-       unsigned long points;
+       unsigned long points = 0;
        struct timespec uptime;
 
        do_posix_clock_monotonic_gettime(&uptime);
        read_lock(&tasklist_lock);
-       points = badness(task->group_leader, uptime.tv_sec);
+       if (pid_alive(task))
+               points = badness(task, uptime.tv_sec);
        read_unlock(&tasklist_lock);
        return sprintf(buffer, "%lu\n", points);
 }
index 08f4d71dacd7fba3e9a704cb77c9131b6d0c5d69..43c127490606d1a3ab3c47bee8309b92176d5f3c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/init.h>
 #include <linux/idr.h>
index 445a02bcaab31d88963e1d0c7deeeb25572efb97..d35b23238fb1902416ff953f87c9edd2a636899c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/smp_lock.h>
 #include <linux/sysctl.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index a44a7897fd4d20988aa933a89fab2d9c1600d53a..19979a2ce27204d1851c96bc3126fd201a68651f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/highmem.h>
 #include <linux/bootmem.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <linux/list.h>
@@ -490,7 +491,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                }
                read_unlock(&kclist_lock);
 
-               if (m == NULL) {
+               if (&m->list == &kclist_head) {
                        if (clear_user(buffer, tsz))
                                return -EFAULT;
                } else if (is_vmalloc_or_module_addr((void *)start)) {
index 9fe7d7ebe1157864561a8cb3d0166eb827e5839a..b1822dde55c2a992cb1cfb16c3dd0b56d0ed1e4e 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/mmzone.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/seq_file.h>
 #include <linux/hugetlb.h>
index f8650dce74fb069c6a66a497c4933cc50e630539..ce94801f48cafefce01dcc37da6f0037b77de3e5 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/string.h>
 #include <linux/of.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/prom.h>
 #include <asm/uaccess.h>
 #include "internal.h"
index 04d1270f1c38687da3e925ef395e73dfcdd79022..9020ac15baaaf4d3791fb190a50654e557851e95 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/time.h>
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/module.h>
index b9b7aad2003d10f757e048a6b1dc1564c2c8e8c1..bf31b03fc275295e576554abdbea4f5264b99a23 100644 (file)
@@ -1,6 +1,5 @@
 #include <linux/cpumask.h>
 #include <linux/fs.h>
-#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
index 183f8ff5f400b90d8b128465551d8157004f20d2..a05a669510a44c1d52540a520e7dc809b610cb95 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/seq_file.h>
 #include <linux/highmem.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/mempolicy.h>
 #include <linux/swap.h>
@@ -406,6 +407,7 @@ static int show_smap(struct seq_file *m, void *v)
 
        memset(&mss, 0, sizeof mss);
        mss.vma = vma;
+       /* mmap_sem is held in m_start */
        if (vma->vm_mm && !is_vm_hugetlb_page(vma))
                walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
 
@@ -552,7 +554,8 @@ const struct file_operations proc_clear_refs_operations = {
 };
 
 struct pagemapread {
-       u64 __user *out, *end;
+       int pos, len;
+       u64 *buffer;
 };
 
 #define PM_ENTRY_BYTES      sizeof(u64)
@@ -575,10 +578,8 @@ struct pagemapread {
 static int add_to_pagemap(unsigned long addr, u64 pfn,
                          struct pagemapread *pm)
 {
-       if (put_user(pfn, pm->out))
-               return -EFAULT;
-       pm->out++;
-       if (pm->out >= pm->end)
+       pm->buffer[pm->pos++] = pfn;
+       if (pm->pos >= pm->len)
                return PM_END_OF_BUFFER;
        return 0;
 }
@@ -720,21 +721,20 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long addr,
  * determine which areas of memory are actually mapped and llseek to
  * skip over unmapped regions.
  */
+#define PAGEMAP_WALK_SIZE      (PMD_SIZE)
 static ssize_t pagemap_read(struct file *file, char __user *buf,
                            size_t count, loff_t *ppos)
 {
        struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
-       struct page **pages, *page;
-       unsigned long uaddr, uend;
        struct mm_struct *mm;
        struct pagemapread pm;
-       int pagecount;
        int ret = -ESRCH;
        struct mm_walk pagemap_walk = {};
        unsigned long src;
        unsigned long svpfn;
        unsigned long start_vaddr;
        unsigned long end_vaddr;
+       int copied = 0;
 
        if (!task)
                goto out;
@@ -757,35 +757,12 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        if (!mm)
                goto out_task;
 
-
-       uaddr = (unsigned long)buf & PAGE_MASK;
-       uend = (unsigned long)(buf + count);
-       pagecount = (PAGE_ALIGN(uend) - uaddr) / PAGE_SIZE;
-       ret = 0;
-       if (pagecount == 0)
-               goto out_mm;
-       pages = kcalloc(pagecount, sizeof(struct page *), GFP_KERNEL);
+       pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
+       pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
        ret = -ENOMEM;
-       if (!pages)
+       if (!pm.buffer)
                goto out_mm;
 
-       down_read(&current->mm->mmap_sem);
-       ret = get_user_pages(current, current->mm, uaddr, pagecount,
-                            1, 0, pages, NULL);
-       up_read(&current->mm->mmap_sem);
-
-       if (ret < 0)
-               goto out_free;
-
-       if (ret != pagecount) {
-               pagecount = ret;
-               ret = -EFAULT;
-               goto out_pages;
-       }
-
-       pm.out = (u64 __user *)buf;
-       pm.end = (u64 __user *)(buf + count);
-
        pagemap_walk.pmd_entry = pagemap_pte_range;
        pagemap_walk.pte_hole = pagemap_pte_hole;
        pagemap_walk.hugetlb_entry = pagemap_hugetlb_range;
@@ -807,23 +784,36 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
         * user buffer is tracked in "pm", and the walk
         * will stop when we hit the end of the buffer.
         */
-       ret = walk_page_range(start_vaddr, end_vaddr, &pagemap_walk);
-       if (ret == PM_END_OF_BUFFER)
-               ret = 0;
-       /* don't need mmap_sem for these, but this looks cleaner */
-       *ppos += (char __user *)pm.out - buf;
-       if (!ret)
-               ret = (char __user *)pm.out - buf;
-
-out_pages:
-       for (; pagecount; pagecount--) {
-               page = pages[pagecount-1];
-               if (!PageReserved(page))
-                       SetPageDirty(page);
-               page_cache_release(page);
+       ret = 0;
+       while (count && (start_vaddr < end_vaddr)) {
+               int len;
+               unsigned long end;
+
+               pm.pos = 0;
+               end = start_vaddr + PAGEMAP_WALK_SIZE;
+               /* overflow ? */
+               if (end < start_vaddr || end > end_vaddr)
+                       end = end_vaddr;
+               down_read(&mm->mmap_sem);
+               ret = walk_page_range(start_vaddr, end, &pagemap_walk);
+               up_read(&mm->mmap_sem);
+               start_vaddr = end;
+
+               len = min(count, PM_ENTRY_BYTES * pm.pos);
+               if (copy_to_user(buf, pm.buffer, len)) {
+                       ret = -EFAULT;
+                       goto out_free;
+               }
+               copied += len;
+               buf += len;
+               count -= len;
        }
+       *ppos += copied;
+       if (!ret || ret == PM_END_OF_BUFFER)
+               ret = copied;
+
 out_free:
-       kfree(pages);
+       kfree(pm.buffer);
 out_mm:
        mmput(mm);
 out_task:
index 5d9fd64ef81a9ad76b1525943cc34a79b0a6a33d..46d4b5d72bd33d2e01b9c5e731e8842e616f70f9 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/fs_struct.h>
 #include <linux/mount.h>
 #include <linux/ptrace.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include "internal.h"
 
index 0872afa58d3987682bbdb4afdfdf5e24a95669f7..9fbc99ec799a5636e455cc1982b5196ad3096690 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/user.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
+#include <linux/slab.h>
 #include <linux/highmem.h>
 #include <linux/bootmem.h>
 #include <linux/init.h>
index 2663ed90fb0340d54c8d863014b4258352837a7c..d67908b407d99dbad1f3f91a1e0c561cbab60768 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/quotaops.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
 
index 1739a4aba25fc02cee3bbbec52354940fb0166dd..5ea4ad81a429c24e5be49fbb1fc7317b4431d91f 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/pagevec.h>
 #include <linux/mman.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include "internal.h"
index a6090aa1a7c138e31fd71eb3b99b8f9c3cbc6ab4..c94853473ca993d134f84df734791c8d4715e588 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/sched.h>
 #include <linux/parser.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include "internal.h"
 
index b7f4a1f94d48eff7711d8d2761b019385142d7f7..113386d6fd2de0bdd12721e65b85a0fcbe8ab7b1 100644 (file)
@@ -258,6 +258,7 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
        init_sync_kiocb(&kiocb, filp);
        kiocb.ki_pos = *ppos;
        kiocb.ki_left = len;
+       kiocb.ki_nbytes = len;
 
        for (;;) {
                ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
@@ -313,6 +314,7 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
        init_sync_kiocb(&kiocb, filp);
        kiocb.ki_pos = *ppos;
        kiocb.ki_left = len;
+       kiocb.ki_nbytes = len;
 
        for (;;) {
                ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
index c094f58c7448b06d1da88d87ebbbeb4e27dd7872..f8a6075abf50c6bd83f245b1532b4c5352370a77 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/reiserfs_fs.h>
 #include <linux/stat.h>
 #include <linux/buffer_head.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 extern const struct reiserfs_key MIN_KEY;
index 6591cb21edf6597fbd04d3bbd31695745dfc1b38..1e4250bc3a6f168d49ab2ead734e1e16726dedc7 100644 (file)
@@ -35,6 +35,7 @@
  **/
 
 #include <linux/time.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/buffer_head.h>
index d1da94b82d8f77115a714f1cc75ab36f9a84ba6c..dc2c65e04853b8750d0a1fad38ea5521daa185af 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 #include <linux/buffer_head.h>
index ba98546fabbd1921beedc54074f7399115f14f54..19fbc810e8e74f951a33e3f6611ca7ec2ee2f6e1 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 
@@ -2217,6 +2218,15 @@ static int journal_read_transaction(struct super_block *sb,
                brelse(d_bh);
                return 1;
        }
+
+       if (bdev_read_only(sb->s_bdev)) {
+               reiserfs_warning(sb, "clm-2076",
+                                "device is readonly, unable to replay log");
+               brelse(c_bh);
+               brelse(d_bh);
+               return -EROFS;
+       }
+
        trans_id = get_desc_trans_id(desc);
        /* now we know we've got a good transaction, and it was inside the valid time ranges */
        log_blocks = kmalloc(get_desc_trans_len(desc) *
@@ -2459,12 +2469,6 @@ static int journal_read(struct super_block *sb)
                goto start_log_replay;
        }
 
-       if (continue_replay && bdev_read_only(sb->s_bdev)) {
-               reiserfs_warning(sb, "clm-2076",
-                                "device is readonly, unable to replay log");
-               return -1;
-       }
-
        /* ok, there are transactions that need to be replayed.  start with the first log block, find
         ** all the valid transactions, and pick out the oldest.
         */
index 96e4cbbfaa1887337660ce65b1795f125dec6623..d0c43cb99ffc3b87da5e68fbe6d94b5b20970e63 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/time.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <linux/reiserfs_fs.h>
 #include <linux/reiserfs_acl.h>
 #include <linux/reiserfs_xattr.h>
index 04bf5d791bdad8b9fea4c6eecc6d7772035d7144..59125fb36d42482fd8fc3b6cfc9d63576890ca8e 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <asm/uaccess.h>
@@ -1618,10 +1619,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
        save_mount_options(s, data);
 
        sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
-       if (!sbi) {
-               errval = -ENOMEM;
-               goto error_alloc;
-       }
+       if (!sbi)
+               return -ENOMEM;
        s->s_fs_info = sbi;
        /* Set default values for options: non-aggressive tails, RO on errors */
        REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
@@ -1878,12 +1877,12 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
        return (0);
 
 error:
-       reiserfs_write_unlock(s);
-error_alloc:
        if (jinit_done) {       /* kill the commit thread, free journal ram */
                journal_release_error(NULL, s);
        }
 
+       reiserfs_write_unlock(s);
+
        reiserfs_free_bitmap_cache(s);
        if (SB_BUFFER_WITH_SB(s))
                brelse(SB_BUFFER_WITH_SB(s));
index 37d034ca7d994a8c84496dde7d9d88c54a3f441b..4f9586bb7631e7e2be77e70d34c9e7248c1af418 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/dcache.h>
 #include <linux/namei.h>
 #include <linux/errno.h>
+#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/pagemap.h>
index dd20a7883f0f3a2606d3b4d8bf9ca2a65f274fbb..9cdb759645a958405f054aef790d574bc2f006a2 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/errno.h>
 #include <linux/pagemap.h>
 #include <linux/xattr.h>
+#include <linux/slab.h>
 #include <linux/posix_acl_xattr.h>
 #include <linux/reiserfs_xattr.h>
 #include <linux/reiserfs_acl.h>
index d8b5bfcbdd30b027aae6c9eae937b566b7b2043d..7271a477c041de88251e0a9faa0286ce539eb392 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/xattr.h>
+#include <linux/slab.h>
 #include <linux/reiserfs_xattr.h>
 #include <linux/security.h>
 #include <asm/uaccess.h>
@@ -76,7 +77,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
                return error;
        }
 
-       if (sec->length) {
+       if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) {
                blocks = reiserfs_xattr_jcreate_nblocks(inode) +
                         reiserfs_xattr_nblocks(inode, sec->length);
                /* We don't want to count the directories twice if we have
index 1dabe4ee02fe93931ae741344405bee1daca3cd0..f329849ce3c0d36fc268a1ae9b56638035d76361 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
 #include <linux/list.h>
index 92d5e8ffb63923062680d09906f8baa7ad53d8c8..dbf6548bbf06b6bc761a38d05232d928ce61b866 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/fcntl.h>
 #include <linux/stat.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/net.h>
index 6bd9b691a463f783058b03a84d6de28b49813ee7..0e39a924f10af29fc90697353501b9f6a18008eb 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/string.h>
 #include <linux/stat.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/dcache.h>
index 00b2909bd469e30fc9c074029cd1d2789515f2b8..54350b59046ba26ccf4a4d339ec1fc793b960e69 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/pagemap.h>
 #include <linux/net.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
index 39208663aaf177f56b3e500fd33d8a56a5ecb500..9313b6124a2e40c7824e6f03b4fc5af72c1cd00a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/syscalls.h>
 #include <linux/uio.h>
 #include <linux/security.h>
+#include <linux/gfp.h>
 
 /*
  * Attempt to steal a page from a pipe buffer. This should perhaps go into
index e80be2022a7fceebfbd37383c65f3b032b45ed00..32b911f4ee39e859d9a03d7b68b8ef7e33e11552 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/fs.h>
 #include <linux/vfs.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/pagemap.h>
 
index 4dd70e04333bdd8bd1347dbbaaed97cf72eab838..15a03d0fb9f3a08d64bc85e7b53042757ad9c975 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/mutex.h>
 #include <linux/buffer_head.h>
+#include <linux/slab.h>
 #include <linux/zlib.h>
 
 #include "squashfs_fs.h"
index f557d71cb0971692b5337cefad5db272f10b6a78..fc5c3d75cf3c736a7255b2101d1169786753f634 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/file.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/writeback.h>
index 082daaecac1b44bf2b76e70536a01b703dcee8f3..a4a0a9419711be52782e7afa4f9c81f9cb587658 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/xattr.h>
 #include <linux/security.h>
 #include "sysfs.h"
index 0cb10884a2fc26a8ab40726efd810c3f7682d8c8..776137828dcaf6587bed86fb7cf16c7a3c89ffe0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 
 #include "sysfs.h"
 
index 1b9a3a1e8a17a1e3951980b3b4179d06a2b0a916..b93ec51fa7ace3ee4a9931512761ba7dcf0207ed 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/mount.h>
 #include <linux/module.h>
 #include <linux/kobject.h>
index 1bfc95ad5f716a70dda692a250aee1231b4f608e..98158de91d24a89146b4a0cbe45c0120e511a914 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/time.h>
index 4775af401167d71471c4e6035f4aa4ce1d5f6200..37fa7ed062d8624fdfe6810aaacda6a6503bcd6a 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <linux/freezer.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include "ubifs.h"
 
 /**
index 90492327b3835c476eb52ba0399c20c581e1e19f..c2a68baa782f8d4b4331f689c594a2db640e6d0f 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/moduleparam.h>
 #include <linux/debugfs.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_UBIFS_FS_DEBUG
 
index e26c02ab6cd5578ae663e777749e74fa2772111a..5692cf72b80737e0b87da9a22c58dbe2e52b371b 100644 (file)
@@ -52,6 +52,7 @@
 #include "ubifs.h"
 #include <linux/mount.h>
 #include <linux/namei.h>
+#include <linux/slab.h>
 
 static int read_block(struct inode *inode, void *addr, unsigned int block,
                      struct ubifs_data_node *dn)
index e5a3d8e96bb706d1d03ab393cb9e84d5855f4e51..918d1582ca05ce4a43f884b75fbf5e2522156275 100644 (file)
@@ -53,6 +53,7 @@
  * good, and GC takes extra care when moving them.
  */
 
+#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/list_sort.h>
 #include "ubifs.h"
index e589fedaf1ef747f7b5fe702065a48007d0fd5db..77d5cf4a75477055117e6f98529a4a7bdeea004b 100644 (file)
@@ -51,6 +51,7 @@
  */
 
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include "ubifs.h"
 
 /**
index b2792e84d2452fd37e27991b42c1ab5754044de4..ad7f67b827ea3b568d571685c42dfc50fc721920 100644 (file)
@@ -46,6 +46,7 @@
 #include "ubifs.h"
 #include <linux/crc16.h>
 #include <linux/math64.h>
+#include <linux/slab.h>
 
 /**
  * do_calc_lpt_geom - calculate sizes for the LPT area.
index 8cbfb82480252d3f3abebf0d3a14beb3cc2a9b4a..13cb7a4237bf474fa19a9161edd838c214c07c28 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include <linux/crc16.h>
+#include <linux/slab.h>
 #include "ubifs.h"
 
 /**
index 868a55ee080f193a6c8d6743f44d8cff36c57f2d..109c6ea03bb5d0cb86982a42d6ef9030e28b3e55 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include "ubifs.h"
 
 /**
index 57085e43320fdaf1925fd293f999978e8373077c..96cb62c8a9ddaa7cbcd432dc15442830632d3995 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include "ubifs.h"
+#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/math64.h>
 
index e5b1a7d00fa018f732bcbd84c336a5ef7eaaeea8..2194915220e56c75bc9894724496dc19c797b908 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include "ubifs.h"
 
 /*
index b2d976366a46dcbbceb57a5a8de7183351aebf76..bd2542dad014c947f27c0145b7985bc8fdcee4e1 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/fs.h>
 #include <linux/err.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
index 195830f47569988d1b6ce815c15ce576e5d3cdea..c74400f88fe0eb4882c79586fe09922bf8bd15b4 100644 (file)
@@ -56,6 +56,7 @@
  */
 
 #include "ubifs.h"
+#include <linux/slab.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
 
index 4b540ee632d5ba919ee93a5ef2689794c4935bb5..745eb209be0cf97998cd5ccb85be386557ba9075 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <linux/fs.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/buffer_head.h>
 
 uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
index 852e91845688f24be5b1fa464b70a4d65a044b2a..16064787d2b7e19bfa397ccba348c55cdcc70d86 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/stat.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
index cefa8c8913e68a77100d2bdb5cf377b323483ec0..d03a90b6ad69c5850b6e6a3b5ba0b64726df0418 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/string.h>      /* for memset */
 #include <linux/nls.h>
 #include <linux/crc-itu-t.h>
+#include <linux/slab.h>
 
 #include "udf_sb.h"
 
index 05ac0fe9c4d3cb7e62dab0510c398e5e026935eb..8d5a506c82eb0a16978c4b8065011b412dace2a6 100644 (file)
@@ -6,9 +6,9 @@
  */
 
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/posix_acl_xattr.h>
+#include <linux/gfp.h>
 
 
 /*
index bc7405585defce739ac13a6668aadf33856305da..666c9db48eb63893cc3da777c44478ccd4d6942b 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
index bf85bbe4a9aedd8b43ac57829024fc94095ac91f..a7bc925c4d603e68b1bc0697be51fcd74a6f44f6 100644 (file)
@@ -22,6 +22,7 @@
 #include "xfs_inode.h"
 #include "xfs_vnodeops.h"
 #include "xfs_trace.h"
+#include <linux/slab.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
 
index 99628508cb11f640abd9bb9e919a17699e1c4e11..0f8b9968a8036d7574155e22b894ea6717a045ae 100644 (file)
@@ -40,6 +40,7 @@
 #include "xfs_vnodeops.h"
 #include "xfs_trace.h"
 #include "xfs_bmap.h"
+#include <linux/gfp.h>
 #include <linux/mpage.h>
 #include <linux/pagevec.h>
 #include <linux/writeback.h>
index bd111b7e1daa5812b8b1d68907ecc390caecd8e0..44c2b0ef9a411e69524d3bbb7beb786f696d4026 100644 (file)
@@ -18,7 +18,7 @@
 #include "xfs.h"
 #include <linux/stddef.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
 #include <linux/vmalloc.h>
index 4ea1ee18adede8a266504f970c1db3d8b26f5065..7b26cc2fd2844bf1d768e65be90ceeca9eb85e72 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/exportfs.h>
 
 /*
index 0bf6d61f0528510249fe0de99b5ec3053744b83f..593c05b4df8dea614b13c0ee0f13613a9dcbc1e1 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/compat.h>
 #include <linux/ioctl.h>
 #include <linux/mount.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include "xfs.h"
 #include "xfs_fs.h"
index 61a99608731e641fde3aac01c0c38c2fbcb51cea..e65a7937f3a4aaaee198d09f34a7442165a55f18 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/security.h>
 #include <linux/falloc.h>
 #include <linux/fiemap.h>
+#include <linux/slab.h>
 
 /*
  * Bring the timestamps in the XFS inode uptodate.
index 71345a370d9f7ad0f7d6561bf860ed5b08593fbd..52e06b487ced9467d83bc28c01376e67c1c49749 100644 (file)
@@ -61,6 +61,7 @@
 
 #include <linux/namei.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/mempool.h>
 #include <linux/writeback.h>
index 3a4767c01c5fd6ecee67d409fdf4a906bbe5da5f..4f7b44866b762351ca4bfacdbcb65cacec13d010 100644 (file)
@@ -65,6 +65,8 @@
 #define ACPI_VIDEO_HID                 "LNXVIDEO"
 #define ACPI_BAY_HID                   "LNXIOBAY"
 #define ACPI_DOCK_HID                  "LNXDOCK"
+/* Quirk for broken IBM BIOSes */
+#define ACPI_SMBUS_IBM_HID             "SMBUSIBM"
 
 /*
  * For fixed hardware buttons, we fabricate acpi_devices with HID
index 4a3c4e441027be39da3d37b8a817ff9f918661dd..2f3b3a00b7a39ccf97ff839f0eb9034a1873a6af 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/mm.h>
 #include <linux/cdev.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #if defined(__alpha__) || defined(__powerpc__)
 #include <asm/pgtable.h>       /* For pte_wrprotect */
 #endif
@@ -1545,39 +1546,7 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
 {
 }
 
-
-static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
-{
-       if (size != 0 && nmemb > ULONG_MAX / size)
-               return NULL;
-
-       if (size * nmemb <= PAGE_SIZE)
-           return kcalloc(nmemb, size, GFP_KERNEL);
-
-       return __vmalloc(size * nmemb,
-                        GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-}
-
-/* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */
-static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
-{
-       if (size != 0 && nmemb > ULONG_MAX / size)
-               return NULL;
-
-       if (size * nmemb <= PAGE_SIZE)
-           return kmalloc(nmemb * size, GFP_KERNEL);
-
-       return __vmalloc(size * nmemb,
-                        GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
-}
-
-static __inline void drm_free_large(void *ptr)
-{
-       if (!is_vmalloc_addr(ptr))
-               return kfree(ptr);
-
-       vfree(ptr);
-}
+#include "drm_mem_util.h"
 /*@}*/
 
 #endif                         /* __KERNEL__ */
diff --git a/include/drm/drm_mem_util.h b/include/drm/drm_mem_util.h
new file mode 100644 (file)
index 0000000..6bd325f
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright Â© 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Jesse Barnes <jbarnes@virtuousgeek.org>
+ *
+ */
+#ifndef _DRM_MEM_UTIL_H_
+#define _DRM_MEM_UTIL_H_
+
+#include <linux/vmalloc.h>
+
+static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
+{
+       if (size != 0 && nmemb > ULONG_MAX / size)
+               return NULL;
+
+       if (size * nmemb <= PAGE_SIZE)
+           return kcalloc(nmemb, size, GFP_KERNEL);
+
+       return __vmalloc(size * nmemb,
+                        GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
+}
+
+/* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */
+static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
+{
+       if (size != 0 && nmemb > ULONG_MAX / size)
+               return NULL;
+
+       if (size * nmemb <= PAGE_SIZE)
+           return kmalloc(nmemb * size, GFP_KERNEL);
+
+       return __vmalloc(size * nmemb,
+                        GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
+}
+
+static __inline void drm_free_large(void *ptr)
+{
+       if (!is_vmalloc_addr(ptr))
+               return kfree(ptr);
+
+       vfree(ptr);
+}
+
+#endif
index 676104b7818c0d35cc69f6b60105891f29df63ee..04a6ebc27b966879c3592d510b8e231b5b276ad0 100644 (file)
        {0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
        {0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
        {0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
+       {0x1002, 0x9715, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
        {0, 0, 0}
 
 #define r128_PCI_IDS \
index e3f1b4a4b601aa5cb909030d733dad50f5c074cc..e929c27ede2229b2e3f656619464e4cb7cc0d47e 100644 (file)
@@ -115,7 +115,6 @@ struct ttm_backend {
        struct ttm_backend_func *func;
 };
 
-#define TTM_PAGE_FLAG_VMALLOC         (1 << 0)
 #define TTM_PAGE_FLAG_USER            (1 << 1)
 #define TTM_PAGE_FLAG_USER_DIRTY      (1 << 2)
 #define TTM_PAGE_FLAG_WRITE           (1 << 3)
index 6816be6c3f7798bd64ec1d05a27d95f4b9e27c80..8b1038607831360ed621ddb5542c9f686338758e 100644 (file)
@@ -14,6 +14,9 @@
 #ifndef ASMARM_AMBA_H
 #define ASMARM_AMBA_H
 
+#include <linux/device.h>
+#include <linux/resource.h>
+
 #define AMBA_NR_IRQS   2
 
 struct amba_device {
index b4fbd9862606c76fc8accc05c18d0f2a1d4ab6ec..5ddd9ad4b19c9c381d77ab5c24a01031b4127ba3 100644 (file)
@@ -1,3 +1,5 @@
+#include <linux/types.h>
+
 /* platform data for the PL061 GPIO driver */
 
 struct pl061_platform_data {
index a2ed0591fb19c57f5544f74f6233afe7cda60d35..90f2471dc6f2382d9f522d0c80287a09069c9ed8 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * See Documentation/circular-buffers.txt for more information.
+ */
+
 #ifndef _LINUX_CIRC_BUF_H
 #define _LINUX_CIRC_BUF_H 1
 
index 0cf725bdd2a1a76d2f9da0d6855268cf7a97955d..fc53492b6ad7fb67e904e88d2f02d184771a326e 100644 (file)
@@ -73,6 +73,7 @@ enum clock_event_nofitiers {
  * @list:              list head for the management code
  * @mode:              operating mode assigned by the management code
  * @next_event:                local storage for the next event in oneshot mode
+ * @retries:           number of forced programming retries
  */
 struct clock_event_device {
        const char              *name;
@@ -93,6 +94,7 @@ struct clock_event_device {
        struct list_head        list;
        enum clock_event_mode   mode;
        ktime_t                 next_event;
+       unsigned long           retries;
 };
 
 /*
index 5076fe0c8a96a0f55b9992a21ff6d11a50ca56d5..6cee17c2231384cdaaad3fac1792cc9ca6e798b7 100644 (file)
@@ -18,6 +18,7 @@
 #define _LINUX_DELAYACCT_H
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 /*
  * Per-task flags relevant to delay accounting
index cac84b006667a42ee3296a3301e37f37978ec23f..5f494b4650977fcb9aac65aa7153320fb1c6f487 100644 (file)
@@ -565,17 +565,17 @@ enum {
 
 static inline int ext3_test_inode_state(struct inode *inode, int bit)
 {
-       return test_bit(bit, &EXT3_I(inode)->i_state);
+       return test_bit(bit, &EXT3_I(inode)->i_state_flags);
 }
 
 static inline void ext3_set_inode_state(struct inode *inode, int bit)
 {
-       set_bit(bit, &EXT3_I(inode)->i_state);
+       set_bit(bit, &EXT3_I(inode)->i_state_flags);
 }
 
 static inline void ext3_clear_inode_state(struct inode *inode, int bit)
 {
-       clear_bit(bit, &EXT3_I(inode)->i_state);
+       clear_bit(bit, &EXT3_I(inode)->i_state_flags);
 }
 #else
 /* Assume that user mode programs are passing in an ext3fs superblock, not
index 7679acdb519a14ae540f421a9d664b65914a5cfb..f42c098aed8d8a38c13849d5ef0940f6394b9594 100644 (file)
@@ -87,7 +87,7 @@ struct ext3_inode_info {
         * near to their parent directory's inode.
         */
        __u32   i_block_group;
-       unsigned long   i_state;        /* Dynamic state flags for ext3 */
+       unsigned long   i_state_flags;  /* Dynamic state flags for ext3 */
 
        /* block reservation info */
        struct ext3_block_alloc_info *i_block_alloc_info;
index 5a361f85cfec483e0a595dcb2f4c2ee632ac56d9..da7e52b099f3221cf723f008aa2ac627d276e11b 100644 (file)
@@ -64,9 +64,12 @@ extern bool freeze_task(struct task_struct *p, bool sig_only);
 extern void cancel_freezing(struct task_struct *p);
 
 #ifdef CONFIG_CGROUP_FREEZER
-extern int cgroup_frozen(struct task_struct *task);
+extern int cgroup_freezing_or_frozen(struct task_struct *task);
 #else /* !CONFIG_CGROUP_FREEZER */
-static inline int cgroup_frozen(struct task_struct *task) { return 0; }
+static inline int cgroup_freezing_or_frozen(struct task_struct *task)
+{
+       return 0;
+}
 #endif /* !CONFIG_CGROUP_FREEZER */
 
 /*
index 7be0c6fbe8808be086d884939c7c621e3f5d78cf..c57db27ac86140ba13798e1736b31d9254162a82 100644 (file)
@@ -105,7 +105,7 @@ struct fscache_operation {
        /* operation releaser */
        fscache_operation_release_t release;
 
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        const char *name;               /* operation name */
        const char *state;              /* operation state */
 #define fscache_set_op_name(OP, N)     do { (OP)->name  = (N); } while(0)
index df8fd9a3b214b5afde8a1368b327358117e6fbdb..01755909ce8167fade2220fb503435652bd71c44 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/inotify.h>
 #include <linux/fsnotify_backend.h>
 #include <linux/audit.h>
+#include <linux/slab.h>
 
 /*
  * fsnotify_d_instantiate - instantiate a dentry for inode
index 48e68da097f6f50000b80e8dd10a82581233179b..361d1cc288d03cc690fbac6638d1e865df289556 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 
 struct gameport {
 
index b1344ec4b7fc9fe93305eaf2d96cfed494bb3de7..069e587ae8e65793900b035e692722635896f9da 100644 (file)
@@ -589,6 +589,9 @@ struct hid_usage_id {
  * @report_fixup: called before report descriptor parsing (NULL means nop)
  * @input_mapping: invoked on input registering before mapping an usage
  * @input_mapped: invoked on input registering after mapping an usage
+ * @suspend: invoked on suspend (NULL means nop)
+ * @resume: invoked on resume if device was not reset (NULL means nop)
+ * @reset_resume: invoked on resume if device was reset (NULL means nop)
  *
  * raw_event and event should return 0 on no action performed, 1 when no
  * further processing should be done and negative on error
@@ -629,6 +632,11 @@ struct hid_driver {
        int (*input_mapped)(struct hid_device *hdev,
                        struct hid_input *hidinput, struct hid_field *field,
                        struct hid_usage *usage, unsigned long **bit, int *max);
+#ifdef CONFIG_PM
+       int (*suspend)(struct hid_device *hdev, pm_message_t message);
+       int (*resume)(struct hid_device *hdev);
+       int (*reset_resume)(struct hid_device *hdev);
+#endif
 /* private: */
        struct device_driver driver;
 };
index 1822d635be6b461124e659cfaa0861474a25e0bf..16b92d008bed842e141f77664e94446cbe652dcf 100644 (file)
@@ -2,6 +2,7 @@
 #define _IF_TUNNEL_H_
 
 #include <linux/types.h>
+#include <asm/byteorder.h>
 
 #ifdef __KERNEL__
 #include <linux/ip.h>
index 97eb928b49243076d89f634b06a1ab4802f49847..25085ddd955fda5516b4b8a73958246ba4044e41 100644 (file)
@@ -19,6 +19,7 @@
 #define _LINUX_IO_MAPPING_H
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/iomap.h>
index 71ab79da7e7f6b3a12019849978e2da58a00b61c..26fad187d6610f3179dc3bf6b4b1b43820e1783a 100644 (file)
@@ -112,12 +112,14 @@ struct resource_list {
 extern struct resource ioport_resource;
 extern struct resource iomem_resource;
 
+extern struct resource *request_resource_conflict(struct resource *root, struct resource *new);
 extern int request_resource(struct resource *root, struct resource *new);
 extern int release_resource(struct resource *new);
 void release_child_resources(struct resource *new);
 extern void reserve_region_with_split(struct resource *root,
                             resource_size_t start, resource_size_t end,
                             const char *name);
+extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
 extern int insert_resource(struct resource *parent, struct resource *new);
 extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
 extern int allocate_resource(struct resource *root, struct resource *new,
index f3aa59cb675d84cc92308bf038661826679cf5f0..516a2a27e87a3ce4c7ed3eeeedb12219aa28faec 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/mutex.h>
 #include <linux/timer.h>
 #include <linux/lockdep.h>
+#include <linux/slab.h>
 
 #define journal_oom_retry 1
 
index 1ec876358180ecd72ec00f06de81af9d6e4bba71..a4d2e9f7088ada70d8b1357f418c32cd09a5bf1a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/bit_spinlock.h>
 #include <linux/mutex.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #endif
 
 #define journal_oom_retry 1
index bc0fc795bd3536c90feb50b0ce4226c6461447e5..ece0b1c33816d414e79b7d6046d17230fe71bf28 100644 (file)
@@ -102,8 +102,6 @@ union { \
        unsigned char name##kfifo_buffer[size]; \
        struct kfifo name = __kfifo_initializer(size, name##kfifo_buffer)
 
-#undef __kfifo_initializer
-
 extern void kfifo_init(struct kfifo *fifo, void *buffer,
                        unsigned int size);
 extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
index f8ea71e6d0e2f52c4811d14de18ea7d231b37959..b2f2003b92e5e727f9e5388f100bac66afd99e35 100644 (file)
@@ -146,6 +146,7 @@ enum {
        ATA_DFLAG_SLEEPING      = (1 << 15), /* device is sleeping */
        ATA_DFLAG_DUBIOUS_XFER  = (1 << 16), /* data transfer not verified */
        ATA_DFLAG_NO_UNLOAD     = (1 << 17), /* device doesn't support unload */
+       ATA_DFLAG_UNLOCK_HPA    = (1 << 18), /* unlock HPA */
        ATA_DFLAG_INIT_MASK     = (1 << 24) - 1,
 
        ATA_DFLAG_DETACH        = (1 << 24),
index c02c8db737011c848499c43580b64632980ff404..8a49cbf0376de0f42409ca1a5a1a71dd00104201 100644 (file)
@@ -268,6 +268,7 @@ struct _mmc_csd {
 
 #define EXT_CSD_CARD_TYPE_26   (1<<0)  /* Card can run at 26MHz */
 #define EXT_CSD_CARD_TYPE_52   (1<<1)  /* Card can run at 52MHz */
+#define EXT_CSD_CARD_TYPE_MASK 0x3     /* Mask out reserved and DDR bits */
 
 #define EXT_CSD_BUS_WIDTH_1    0       /* Card is in 1 bit mode */
 #define EXT_CSD_BUS_WIDTH_4    1       /* Card is in 4 bit mode */
index 5e869ffd34aa0203438c7136b681a276140bb48c..515d53ae6a795e9b73bbf0388aa8966be1014924 100644 (file)
@@ -330,8 +330,11 @@ struct module
        struct module_notes_attrs *notes_attrs;
 #endif
 
+#ifdef CONFIG_SMP
        /* Per-cpu data. */
-       void *percpu;
+       void __percpu *percpu;
+       unsigned int percpu_size;
+#endif
 
        /* The command line arguments (may be mangled).  People like
           keeping pointers to this stuff */
@@ -365,7 +368,8 @@ struct module
        void (*exit)(void);
 
        struct module_ref {
-               int count;
+               unsigned int incs;
+               unsigned int decs;
        } __percpu *refptr;
 #endif
 
@@ -392,6 +396,7 @@ static inline int module_is_live(struct module *mod)
 struct module *__module_text_address(unsigned long addr);
 struct module *__module_address(unsigned long addr);
 bool is_module_address(unsigned long addr);
+bool is_module_percpu_address(unsigned long addr);
 bool is_module_text_address(unsigned long addr);
 
 static inline int within_module_core(unsigned long addr, struct module *mod)
@@ -459,9 +464,9 @@ static inline void __module_get(struct module *module)
 {
        if (module) {
                preempt_disable();
-               __this_cpu_inc(module->refptr->count);
+               __this_cpu_inc(module->refptr->incs);
                trace_module_get(module, _THIS_IP_,
-                                __this_cpu_read(module->refptr->count));
+                                __this_cpu_read(module->refptr->incs));
                preempt_enable();
        }
 }
@@ -474,11 +479,10 @@ static inline int try_module_get(struct module *module)
                preempt_disable();
 
                if (likely(module_is_live(module))) {
-                       __this_cpu_inc(module->refptr->count);
+                       __this_cpu_inc(module->refptr->incs);
                        trace_module_get(module, _THIS_IP_,
-                               __this_cpu_read(module->refptr->count));
-               }
-               else
+                               __this_cpu_read(module->refptr->incs));
+               } else
                        ret = 0;
 
                preempt_enable();
@@ -563,6 +567,11 @@ static inline bool is_module_address(unsigned long addr)
        return false;
 }
 
+static inline bool is_module_percpu_address(unsigned long addr)
+{
+       return false;
+}
+
 static inline bool is_module_text_address(unsigned long addr)
 {
        return false;
index c79a88be7c33813c494bc3694229b943f2fc4d9e..fa8b47637997cd4eef3f0e791ce8bf5b48b34a85 100644 (file)
@@ -2059,12 +2059,12 @@ static inline void skb_bond_set_mac_by_master(struct sk_buff *skb,
  * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
  * ARP on active-backup slaves with arp_validate enabled.
  */
-static inline int skb_bond_should_drop(struct sk_buff *skb)
+static inline int skb_bond_should_drop(struct sk_buff *skb,
+                                      struct net_device *master)
 {
-       struct net_device *dev = skb->dev;
-       struct net_device *master = dev->master;
-
        if (master) {
+               struct net_device *dev = skb->dev;
+
                if (master->priv_flags & IFF_MASTER_ARPMON)
                        dev->last_rx = jiffies;
 
index 53923868c9bddf8ab63a21019056b6858af5dbd9..361d6b5630ee8105e407477308bed1ab6f03ccf0 100644 (file)
@@ -76,7 +76,7 @@ extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
 extern int nfnetlink_has_listeners(struct net *net, unsigned int group);
 extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned group,
                          int echo, gfp_t flags);
-extern void nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error);
+extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error);
 extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u_int32_t pid, int flags);
 
 extern void nfnl_lock(void);
index d654873aa25afdaae0fe2ac921b2cd58db16bf04..1f7e300094cd4777ffe98600cc5319bcf5bb406f 100644 (file)
@@ -59,6 +59,7 @@
 enum nf_ip6_hook_priorities {
        NF_IP6_PRI_FIRST = INT_MIN,
        NF_IP6_PRI_CONNTRACK_DEFRAG = -400,
+       NF_IP6_PRI_RAW = -300,
        NF_IP6_PRI_SELINUX_FIRST = -225,
        NF_IP6_PRI_CONNTRACK = -200,
        NF_IP6_PRI_MANGLE = -150,
index fde27c0173266852787c4d15613f7116b10f3d21..6eaca5e1e8ca595fbfa388815c1b69675baaf314 100644 (file)
@@ -188,7 +188,7 @@ extern int netlink_has_listeners(struct sock *sk, unsigned int group);
 extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
 extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
                             __u32 group, gfp_t allocation);
-extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
+extern int netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
 extern int netlink_register_notifier(struct notifier_block *nb);
 extern int netlink_unregister_notifier(struct notifier_block *nb);
 
index a93e5bfdccb8e8b825006776f4afb77ebc975e90..d3a38d687104c4cc76700da32f8e97bd6f94dd60 100644 (file)
@@ -2,10 +2,10 @@
 #define __LINUX_PERCPU_H
 
 #include <linux/preempt.h>
-#include <linux/slab.h> /* For kmalloc() */
 #include <linux/smp.h>
 #include <linux/cpumask.h>
 #include <linux/pfn.h>
+#include <linux/init.h>
 
 #include <asm/percpu.h>
 
@@ -135,9 +135,7 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size,
 #define per_cpu_ptr(ptr, cpu)  SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu)))
 
 extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align);
-extern void __percpu *__alloc_percpu(size_t size, size_t align);
-extern void free_percpu(void __percpu *__pdata);
-extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
+extern bool is_kernel_percpu_address(unsigned long addr);
 
 #ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
 extern void __init setup_per_cpu_areas(void);
@@ -147,25 +145,10 @@ extern void __init setup_per_cpu_areas(void);
 
 #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
 
-static inline void __percpu *__alloc_percpu(size_t size, size_t align)
+/* can't distinguish from other static vars, always false */
+static inline bool is_kernel_percpu_address(unsigned long addr)
 {
-       /*
-        * Can't easily make larger alignment work with kmalloc.  WARN
-        * on it.  Larger alignment should only be used for module
-        * percpu sections on SMP for which this path isn't used.
-        */
-       WARN_ON_ONCE(align > SMP_CACHE_BYTES);
-       return kzalloc(size, GFP_KERNEL);
-}
-
-static inline void free_percpu(void __percpu *p)
-{
-       kfree(p);
-}
-
-static inline phys_addr_t per_cpu_ptr_to_phys(void *addr)
-{
-       return __pa(addr);
+       return false;
 }
 
 static inline void __init setup_per_cpu_areas(void) { }
@@ -177,6 +160,10 @@ static inline void *pcpu_lpage_remapped(void *kaddr)
 
 #endif /* CONFIG_SMP */
 
+extern void __percpu *__alloc_percpu(size_t size, size_t align);
+extern void free_percpu(void __percpu *__pdata);
+extern phys_addr_t per_cpu_ptr_to_phys(void *addr);
+
 #define alloc_percpu(type)     \
        (typeof(type) __percpu *)__alloc_percpu(sizeof(type), __alignof__(type))
 
index 95477038a72ad479b2c1b5d19138e9ff675ee62c..c8e375440403de53f6deb7be5e5ad3d0b0bb84e6 100644 (file)
@@ -842,13 +842,6 @@ extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX];
 
 extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64);
 
-static inline void
-perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
-{
-       if (atomic_read(&perf_swevent_enabled[event_id]))
-               __perf_sw_event(event_id, nr, nmi, regs, addr);
-}
-
 extern void
 perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip);
 
@@ -887,6 +880,20 @@ static inline void perf_fetch_caller_regs(struct pt_regs *regs, int skip)
        return perf_arch_fetch_caller_regs(regs, ip, skip);
 }
 
+static inline void
+perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr)
+{
+       if (atomic_read(&perf_swevent_enabled[event_id])) {
+               struct pt_regs hot_regs;
+
+               if (!regs) {
+                       perf_fetch_caller_regs(&hot_regs, 1);
+                       regs = &hot_regs;
+               }
+               __perf_sw_event(event_id, nr, nmi, regs, addr);
+       }
+}
+
 extern void __perf_event_mmap(struct vm_area_struct *vma);
 
 static inline void perf_event_mmap(struct vm_area_struct *vma)
index 3024050c82a12610222a1b5e7d1c40d44e339b5a..872a98e13d6ab7ce2b833cf073925048c43807f9 100644 (file)
@@ -123,22 +123,11 @@ static inline int rcu_read_lock_held(void)
        return lock_is_held(&rcu_lock_map);
 }
 
-/**
- * rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section?
- *
- * If CONFIG_PROVE_LOCKING is selected and enabled, returns nonzero iff in
- * an RCU-bh read-side critical section.  In absence of CONFIG_PROVE_LOCKING,
- * this assumes we are in an RCU-bh read-side critical section unless it can
- * prove otherwise.
- *
- * Check rcu_scheduler_active to prevent false positives during boot.
+/*
+ * rcu_read_lock_bh_held() is defined out of line to avoid #include-file
+ * hell.
  */
-static inline int rcu_read_lock_bh_held(void)
-{
-       if (!debug_lockdep_rcu_enabled())
-               return 1;
-       return lock_is_held(&rcu_bh_lock_map);
-}
+extern int rcu_read_lock_bh_held(void);
 
 /**
  * rcu_read_lock_sched_held - might we be in RCU-sched read-side critical section?
@@ -160,7 +149,7 @@ static inline int rcu_read_lock_sched_held(void)
                return 1;
        if (debug_locks)
                lockdep_opinion = lock_is_held(&rcu_sched_lock_map);
-       return lockdep_opinion || preempt_count() != 0;
+       return lockdep_opinion || preempt_count() != 0 || irqs_disabled();
 }
 #else /* #ifdef CONFIG_PREEMPT */
 static inline int rcu_read_lock_sched_held(void)
@@ -191,7 +180,7 @@ static inline int rcu_read_lock_bh_held(void)
 #ifdef CONFIG_PREEMPT
 static inline int rcu_read_lock_sched_held(void)
 {
-       return !rcu_scheduler_active || preempt_count() != 0;
+       return !rcu_scheduler_active || preempt_count() != 0 || irqs_disabled();
 }
 #else /* #ifdef CONFIG_PREEMPT */
 static inline int rcu_read_lock_sched_held(void)
index 99928dce37ea927bde2f515df93ad9a2bab2a239..7fa02b4af838513b9a609122db0772654cdc2f91 100644 (file)
@@ -70,6 +70,11 @@ int reiserfs_security_write(struct reiserfs_transaction_handle *th,
 void reiserfs_security_free(struct reiserfs_security_handle *sec);
 #endif
 
+static inline int reiserfs_xattrs_initialized(struct super_block *sb)
+{
+       return REISERFS_SB(sb)->priv_root != NULL;
+}
+
 #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
 static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
 {
index 233d20b52c1b2506debd5a0585f9a7810329c9fd..3158dd982d2756aaf0ab5cee2f6c166b47575adf 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/sched.h>
 #include <linux/key.h>
 #include <linux/xfrm.h>
-#include <linux/gfp.h>
+#include <linux/slab.h>
 #include <net/flow.h>
 
 /* Maximum number of letters for an LSM name string */
index 1b177d29a7f0fdac7c2483431abb0ec92e3a2a2d..193d4bfe42ffd5ae030bb4357a64de0da00a0ebc 100644 (file)
@@ -2,7 +2,9 @@
 #define __LINUX_SERIAL_SCI_H
 
 #include <linux/serial_core.h>
+#ifdef CONFIG_SERIAL_SH_SCI_DMA
 #include <asm/dmaengine.h>
+#endif
 
 /*
  * Generic header for SuperH SCI(F) (used by sh/sh64/h8300 and related parts)
@@ -30,8 +32,10 @@ struct plat_sci_port {
        upf_t           flags;                  /* UPF_* flags */
        char            *clk;                   /* clock string */
        struct device   *dma_dev;
+#ifdef CONFIG_SERIAL_SH_SCI_DMA
        enum sh_dmae_slave_chan_id dma_slave_tx;
        enum sh_dmae_slave_chan_id dma_slave_rx;
+#endif
 };
 
 #endif /* __LINUX_SERIAL_SCI_H */
index 03f816a9b65950ba998b00aaf5f3352f25be0c7f..124f90cd5a38bd39ab88af0563aa0d0ff9aa06d2 100644 (file)
@@ -190,9 +190,6 @@ struct skb_shared_info {
        atomic_t        dataref;
        unsigned short  nr_frags;
        unsigned short  gso_size;
-#ifdef CONFIG_HAS_DMA
-       dma_addr_t      dma_head;
-#endif
        /* Warning: this field is not always filled in (UFO)! */
        unsigned short  gso_segs;
        unsigned short  gso_type;
@@ -201,9 +198,6 @@ struct skb_shared_info {
        struct sk_buff  *frag_list;
        struct skb_shared_hwtstamps hwtstamps;
        skb_frag_t      frags[MAX_SKB_FRAGS];
-#ifdef CONFIG_HAS_DMA
-       dma_addr_t      dma_maps[MAX_SKB_FRAGS];
-#endif
        /* Intermediate layers must ensure that destructor_arg
         * remains valid until skb destructor */
        void *          destructor_arg;
index 7b3aae2052a6e37340ed04548487333141d925cd..354cc5617f8b87304b97eebeec2c4b3e8a52428a 100644 (file)
@@ -255,6 +255,7 @@ struct ucred {
 #define MSG_ERRQUEUE   0x2000  /* Fetch message from error queue */
 #define MSG_NOSIGNAL   0x4000  /* Do not generate SIGPIPE */
 #define MSG_MORE       0x8000  /* Sender will send more */
+#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
 
 #define MSG_EOF         MSG_FIN
 
index 97b60b37f445dca6cad09959e5838b2206280149..af56071b06f92ea23368947a4daffad12e03e660 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/device.h>
 #include <linux/mod_devicetable.h>
+#include <linux/slab.h>
 
 /*
  * INTERFACES between SPI master-side drivers and SPI infrastructure.
index d7152b451e21d7fb2bb84fcd3ffc33afa8ace8e9..7c91260c44a93ef8870f6c0cd2620cb0619e113f 100644 (file)
@@ -36,7 +36,6 @@ struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt);
 void xprt_free_bc_request(struct rpc_rqst *req);
 int xprt_setup_backchannel(struct rpc_xprt *, unsigned int min_reqs);
 void xprt_destroy_backchannel(struct rpc_xprt *, int max_reqs);
-void bc_release_request(struct rpc_task *);
 int bc_send(struct rpc_rqst *req);
 
 /*
@@ -59,6 +58,10 @@ static inline int svc_is_backchannel(const struct svc_rqst *rqstp)
 {
        return 0;
 }
+
+static inline void xprt_free_bc_request(struct rpc_rqst *req)
+{
+}
 #endif /* CONFIG_NFS_V4_1 */
 #endif /* _LINUX_SUNRPC_BC_XPRT_H */
 
index f994ae58a002a59bc45db3a5cd36fae0df75e17e..057929b0a6514963b66098e9f3ff58129937ffa5 100644 (file)
@@ -688,7 +688,7 @@ asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
 asmlinkage long sys_shmdt(char __user *shmaddr);
 asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
-asmlinkage long sys_ipc(unsigned int call, int first, int second,
+asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
                unsigned long third, void __user *ptr, long fifth);
 
 asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr);
index b6523c1427ce09f17b4827072e614ab2e34c64ed..58de6edf751f5e0a6c4c13517785674200d6a9c0 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/taskstats.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_TASKSTATS
 extern struct kmem_cache *taskstats_cache;
index f59604ed0ec606c75449d6b2cd8416abf6f7f38f..78b4bd3be496c22f96fb6bc6400d2e831b6ce210 100644 (file)
@@ -49,7 +49,7 @@ struct tracepoint {
                void **it_func;                                         \
                                                                        \
                rcu_read_lock_sched_notrace();                          \
-               it_func = rcu_dereference((tp)->funcs);                 \
+               it_func = rcu_dereference_sched((tp)->funcs);           \
                if (it_func) {                                          \
                        do {                                            \
                                ((void(*)(proto))(*it_func))(args);     \
index 568369a86306e5e80b5db3974db85dce56360f80..4409967db0c45e8e0a5568b5596e4b42bffe659c 100644 (file)
@@ -70,12 +70,13 @@ struct tty_buffer {
 
 /*
  * We default to dicing tty buffer allocations to this many characters
- * in order to avoid multiple page allocations. We assume tty_buffer itself
- * is under 256 bytes. See tty_buffer_find for the allocation logic this
- * must match
+ * in order to avoid multiple page allocations. We know the size of
+ * tty_buffer itself but it must also be taken into account that the
+ * the buffer is 256 byte aligned. See tty_buffer_find for the allocation
+ * logic this must match
  */
 
-#define TTY_BUFFER_PAGE                ((PAGE_SIZE  - 256) / 2)
+#define TTY_BUFFER_PAGE        (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF)
 
 
 struct tty_bufhead {
@@ -223,6 +224,7 @@ struct tty_port {
        wait_queue_head_t       close_wait;     /* Close waiters */
        wait_queue_head_t       delta_msr_wait; /* Modem status change */
        unsigned long           flags;          /* TTY flags ASY_*/
+       unsigned char           console:1;      /* port is a console */
        struct mutex            mutex;          /* Locking */
        struct mutex            buf_mutex;      /* Buffer alloc lock */
        unsigned char           *xmit_buf;      /* Optional buffer */
index 8c9f053111bb8002d332749a36403cef7b7bb0a0..ce1323c4e47cdc8879c8832ffac99dee4682994e 100644 (file)
@@ -1055,7 +1055,8 @@ typedef void (*usb_complete_t)(struct urb *);
  * @number_of_packets: Lists the number of ISO transfer buffers.
  * @interval: Specifies the polling interval for interrupt or isochronous
  *     transfers.  The units are frames (milliseconds) for full and low
- *     speed devices, and microframes (1/8 millisecond) for highspeed ones.
+ *     speed devices, and microframes (1/8 millisecond) for highspeed
+ *     and SuperSpeed devices.
  * @error_count: Returns the number of ISO transfers that reported errors.
  * @context: For use in completion functions.  This normally points to
  *     request-specific driver context.
@@ -1286,9 +1287,16 @@ static inline void usb_fill_bulk_urb(struct urb *urb,
  *
  * Initializes a interrupt urb with the proper information needed to submit
  * it to a device.
- * Note that high speed interrupt endpoints use a logarithmic encoding of
- * the endpoint interval, and express polling intervals in microframes
- * (eight per millisecond) rather than in frames (one per millisecond).
+ *
+ * Note that High Speed and SuperSpeed interrupt endpoints use a logarithmic
+ * encoding of the endpoint interval, and express polling intervals in
+ * microframes (eight per millisecond) rather than in frames (one per
+ * millisecond).
+ *
+ * Wireless USB also uses the logarithmic encoding, but specifies it in units of
+ * 128us instead of 125us.  For Wireless USB devices, the interval is passed
+ * through to the host controller, rather than being translated into microframe
+ * units.
  */
 static inline void usb_fill_int_urb(struct urb *urb,
                                    struct usb_device *dev,
@@ -1305,7 +1313,7 @@ static inline void usb_fill_int_urb(struct urb *urb,
        urb->transfer_buffer_length = buffer_length;
        urb->complete = complete_fn;
        urb->context = context;
-       if (dev->speed == USB_SPEED_HIGH)
+       if (dev->speed == USB_SPEED_HIGH || dev->speed == USB_SPEED_SUPER)
                urb->interval = 1 << (interval - 1);
        else
                urb->interval = interval;
index bbf45d500b6dd547535bd2c6523ac84a0438e110..f4b7ca516cdd76c4b72691a0cdc1d4feb2f70349 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef __LINUX_USB_GADGET_H
 #define __LINUX_USB_GADGET_H
 
+#include <linux/slab.h>
+
 struct usb_ep;
 
 /**
index 778b7b2a47d4afc36e81c8516124acbc850e2f07..d5dd0bc408fd4e7b1e79ea8326841a8a187f2738 100644 (file)
@@ -27,7 +27,7 @@ struct vt_mode {
 #define VT_SETMODE     0x5602  /* set mode of active vt */
 #define                VT_AUTO         0x00    /* auto vt switching */
 #define                VT_PROCESS      0x01    /* process controls switching */
-#define                VT_PROCESS_AUTO 0x02    /* process is notified of switching */
+#define                VT_ACKACQ       0x02    /* acknowledge switch */
 
 struct vt_stat {
        unsigned short v_active;        /* active vt */
@@ -38,7 +38,6 @@ struct vt_stat {
 #define VT_SENDSIG     0x5604  /* signal to send to bitmask of vts */
 
 #define VT_RELDISP     0x5605  /* release display */
-#define                VT_ACKACQ       0x02    /* acknowledge switch */
 
 #define VT_ACTIVATE    0x5606  /* make vt active */
 #define VT_WAITACTIVE  0x5607  /* wait for vt active */
index db8096e8853331ac7b615fa0f41cd99d7998b791..57031b4d12f2a51f352524ba765f43d41f261415 100644 (file)
 
 #include <linux/types.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 
 
 /* Backend stuff */
index f076dfa75ae8b28eec5aefc5233a12c55ed459de..4f3760afc20fb52d19a09f679f3e16313fed707d 100644 (file)
@@ -54,6 +54,7 @@ enum p9_proto_versions{
 
 enum p9_trans_status {
        Connected,
+       BeginDisconnect,
        Disconnected,
        Hung,
 };
@@ -198,6 +199,7 @@ int p9_client_version(struct p9_client *);
 struct p9_client *p9_client_create(const char *dev_name, char *options);
 void p9_client_destroy(struct p9_client *clnt);
 void p9_client_disconnect(struct p9_client *clnt);
+void p9_client_begin_disconnect(struct p9_client *clnt);
 struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
                                        char *uname, u32 n_uname, char *aname);
 struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname,
index 717e2192d521ee014ed415ad51d29d296576dba5..206d22297ac36345e5912472cd14ab9c3f51bc10 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/spinlock.h>
 #include <linux/timer.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 
 #define        AX25_T1CLAMPLO                  1
index 04a6908e38d2883a136a60c92ddb1405e1d1ff60..ff77e8f882f13fdc8545662b3543685e661de0f4 100644 (file)
@@ -176,6 +176,6 @@ extern void hci_sock_cleanup(void);
 extern int bt_sysfs_init(void);
 extern void bt_sysfs_cleanup(void);
 
-extern struct class *bt_class;
+extern struct dentry *bt_debugfs;
 
 #endif /* __BLUETOOTH_H */
index c07ac9650ebc00219418dcca80abf828e30dbcd8..c49086d2bc7da380c9ef18873e88bc6a709ce9e6 100644 (file)
@@ -2,6 +2,7 @@
 #define __NET_FIB_RULES_H
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/fib_rules.h>
 #include <net/flow.h>
index a14121dd19320365a54f9bb62ee88af23b00b11e..ef51a668ba191b6c2d3d4a62df21a6b47482c363 100644 (file)
@@ -13,6 +13,7 @@
 #include <net/datalink.h>
 #include <linux/ipx.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 struct ipx_address {
        __be32  net;
index 5e310c8d8e2f96209913711863abff8e7389f358..205a3360156ed46d43a077e3cfabac1647ce236f 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <asm/debug.h>
 
 /*
index 2d2a1f9a61d868acb94b6e3bd92f47e074ccef8e..32d15bd6efa3c573030e899bb979d98dcc811ee9 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _NF_CONNTRACK_EXTEND_H
 #define _NF_CONNTRACK_EXTEND_H
 
+#include <linux/slab.h>
+
 #include <net/netfilter/nf_conntrack.h>
 
 enum nf_ct_ext_id {
index 60ebbc1fef46a157cdb4393f123b21b07a7e0dc5..9db401a8b4d982db3a97a214b73788d1111d88f7 100644 (file)
@@ -31,6 +31,7 @@
 #define _NETLABEL_H
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
 #include <linux/in.h>
index f82e463c875a51600ad0055c86c164d12e3e16ed..4fc05b58503eb4beab8fc20b3ab0b762f9f3d293 100644 (file)
@@ -945,7 +945,11 @@ static inline u64 nla_get_u64(const struct nlattr *nla)
  */
 static inline __be64 nla_get_be64(const struct nlattr *nla)
 {
-       return *(__be64 *) nla_data(nla);
+       __be64 tmp;
+
+       nla_memcpy(&tmp, nla, sizeof(tmp));
+
+       return tmp;
 }
 
 /**
index ab170a60e7d31a6a72b2f88fd7e3696007abb039..f0793c1cb5f8c2d89cd3f5dbb4fe31afbef4c026 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/netrom.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #define        NR_NETWORK_LEN                  15
index 092b0551e77f28a08387d687592366ee4467a678..b4603cd54fcd3271096d30c8debaf96ee391243e 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/skbuff.h>      /* struct sk_buff */
 #include <linux/mm.h>
 #include <linux/security.h>
+#include <linux/slab.h>
 
 #include <linux/filter.h>
 #include <linux/rculist_nulls.h>
index 9baa07dc7d17e31546407e91e2875a8960861cd8..15ef9624ab753c7be2b28cb338f9ede729962594 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef _X25_H
 #define _X25_H 
 #include <linux/x25.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #define        X25_ADDR_LEN                    16
index d74e080ba6c9c0a0ff14be2019eed6aeef659c68..ac52f33f3e4af06113dc060fd4a8282e6f837c94 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/in6.h>
 #include <linux/mutex.h>
 #include <linux/audit.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <net/dst.h>
index 32896a77391054babaeb60482ad121a4864329af..2e488b60bc7603668de714acc570e3c463db28d4 100644 (file)
@@ -277,12 +277,6 @@ extern struct pccard_resource_ops pccard_nonstatic_ops;
 #endif
 
 
-/* socket drivers are expected to use these callbacks in their .drv struct */
-extern int pcmcia_socket_dev_suspend(struct device *dev);
-extern void pcmcia_socket_dev_early_resume(struct device *dev);
-extern void pcmcia_socket_dev_late_resume(struct device *dev);
-extern int pcmcia_socket_dev_resume(struct device *dev);
-
 /* socket drivers use this callback in their IRQ handler */
 extern void pcmcia_parse_events(struct pcmcia_socket *socket,
                                unsigned int events);
index 9eaa3f05f9544621463c1c172d71c16f40ed42fb..3b586859669cf4a161166263c4eac2a8e2519400 100644 (file)
@@ -36,6 +36,7 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_transport_sas.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 
 struct block_device;
 
index b9763badbd77da07813dae421f20a90a08df2e11..43e2d7d33976dc982364f599f7336d87ee26dbea 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mutex.h>
 #include <linux/completion.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/grant_table.h>
 #include <xen/interface/io/xenbus.h>
index bb008d064c1a53c711bc9c0b7ae21e26797a9b24..02e3ca4fc5271f33c4384d3ba8a77c8c4e5e306e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/initrd.h>
 #include <linux/async.h>
 #include <linux/fs_struct.h>
+#include <linux/slab.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
index 027a402708de6c7fa505f989b6151f5ea5bf1935..bf3ef667bf3669d4332fbaa5fdd65784823c0f54 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/cramfs_fs.h>
 #include <linux/initrd.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 
 #include "do_mounts.h"
 #include "../fs/squashfs/squashfs_fs.h"
index a1ab78ceb4b62abf17551bc990a3298d1c95a320..5c8540271529ba49400037cf5abfae5cc5ec1486 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/bootmem.h>
 #include <linux/acpi.h>
 #include <linux/tty.h>
-#include <linux/gfp.h>
 #include <linux/percpu.h>
 #include <linux/kmod.h>
 #include <linux/vmalloc.h>
@@ -69,6 +68,7 @@
 #include <linux/kmemtrace.h>
 #include <linux/sfi.h>
 #include <linux/shmem_fs.h>
+#include <linux/slab.h>
 #include <trace/boot.h>
 
 #include <asm/io.h>
@@ -858,7 +858,7 @@ static int __init kernel_init(void * unused)
        /*
         * init can allocate pages on any node
         */
-       set_mems_allowed(node_possible_map);
+       set_mems_allowed(node_states[N_HIGH_MEMORY]);
        /*
         * init can run on any cpu.
         */
index ab76fb0ef8443e373c845b4a82510f09d64a1e79..9dc2c7d3c9e6de04732f79e113e73e1e6d52b368 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/init.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
-#include <linux/slab.h>
 #include <linux/syscalls.h>
 
 #include <linux/mutex.h>
index e4e3f04803ca9ec103da18837104042cc303e908..722b0130aa9444150ce2f55b1b1c7597094c1bf4 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/nsproxy.h>
 #include <linux/pid.h>
 #include <linux/ipc_namespace.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include "util.h"
index af42ef8900a6418e3dce715316800e1bbb6da4df..9547cb7ac3135b9ba8964d13018f5ab6340552c9 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -23,7 +23,6 @@
  */
 
 #include <linux/capability.h>
-#include <linux/slab.h>
 #include <linux/msg.h>
 #include <linux/spinlock.h>
 #include <linux/init.h>
index 355a3da9ec73dd8bba5f596c1e1d026e53d881ea..1d6f53f6b562441bcf5ef99c85067275eecf6c5a 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/syscalls.h>
 #include <linux/uaccess.h>
 
-SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, int, second,
+SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
                unsigned long, third, void __user *, ptr, long, fifth)
 {
        int version, ret;
index 27235f5de198997180d4a293adc932d48c6101c7..15319d6c18fe05a3b3bbb8c91e0c654e58356bb2 100644 (file)
@@ -56,6 +56,7 @@ asynchronous and synchronous parts of the kernel.
 #include <linux/init.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 
 static async_cookie_t next_cookie = 1;
index 78f7f86aa2387a391cdbc2a91c364d1a41932deb..c71bd26631a28ccf3ecb1d90319b7b35f5e6f227 100644 (file)
@@ -46,6 +46,7 @@
 #include <asm/atomic.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/kthread.h>
 
index 028e85663f273d1d1cab2d75cde3ef76b22d3d48..46a57b57a335226d43ed662e1e8ff1fbe33ac7d4 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/namei.h>
 #include <linux/mount.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 struct audit_tree;
 struct audit_chunk;
index cc7e87936cbc57f7a2eebebbd212fe297c530154..8df43696f4ba6edff44f194398dd1baf59f4af92 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/namei.h>
 #include <linux/netlink.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/inotify.h>
 #include <linux/security.h>
 #include "audit.h"
index a70604047f3c9061e81622a3b399b085fe5ac815..ce08041f578d85d0d304fec4f8b28112cd598101 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/namei.h>
 #include <linux/netlink.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/security.h>
 #include "audit.h"
 
index f3a461c0970a32b44fd8db7da5b50778b728ab88..3828ad5fb8f16fad0221209515ee6120e54aaeea 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/namei.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/socket.h>
 #include <linux/mqueue.h>
@@ -1893,7 +1894,7 @@ static int audit_inc_name_count(struct audit_context *context,
 {
        if (context->name_count >= AUDIT_NAMES) {
                if (inode)
-                       printk(KERN_DEBUG "name_count maxed, losing inode data: "
+                       printk(KERN_DEBUG "audit: name_count maxed, losing inode data: "
                               "dev=%02x:%02x, inode=%lu\n",
                               MAJOR(inode->i_sb->s_dev),
                               MINOR(inode->i_sb->s_dev),
index ef909a32975006eafd43ce7693314eef5c5ffa4d..e2769e13980c49b2546d0bb2c6cef1e0065f6ca7 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 #include <linux/cgroup.h>
-#include <linux/module.h>
 #include <linux/ctype.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
index 59e9ef6aab4002e1d99170f50156e733e8f46343..da5e139755319aa9a554a57ac699470144dcf055 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/cgroup.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
@@ -47,17 +48,20 @@ static inline struct freezer *task_freezer(struct task_struct *task)
                            struct freezer, css);
 }
 
-int cgroup_frozen(struct task_struct *task)
+int cgroup_freezing_or_frozen(struct task_struct *task)
 {
        struct freezer *freezer;
        enum freezer_state state;
 
        task_lock(task);
        freezer = task_freezer(task);
-       state = freezer->state;
+       if (!freezer->css.cgroup->parent)
+               state = CGROUP_THAWED; /* root cgroup can't be frozen */
+       else
+               state = freezer->state;
        task_unlock(task);
 
-       return state == CGROUP_FROZEN;
+       return (state == CGROUP_FREEZING) || (state == CGROUP_FROZEN);
 }
 
 /*
index f6c204f07ea6084c4849d52358d6b1b2aab1f0da..7f40e9275fd9602d8fb8c4669227e5dd6156b0ff 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/posix-timers.h>
 #include <linux/times.h>
 #include <linux/ptrace.h>
+#include <linux/gfp.h>
 
 #include <asm/uaccess.h>
 
index f8cced2692b3799e26710ccbde3bc8f0f8b654e9..25bba73b1be3a67fe1ce0f932f9d833c81b245f5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kthread.h>
 #include <linux/stop_machine.h>
 #include <linux/mutex.h>
+#include <linux/gfp.h>
 
 #ifdef CONFIG_SMP
 /* Serializes the updates to cpu_online_mask, cpu_present_mask */
index ba401fab459f94a42010f6175b2b69c490920645..d10946748ec2a3c9a070301f4af78c5f4dd18845 100644 (file)
@@ -920,9 +920,6 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
  *    call to guarantee_online_mems(), as we know no one is changing
  *    our task's cpuset.
  *
- *    Hold callback_mutex around the two modifications of our tasks
- *    mems_allowed to synchronize with cpuset_mems_allowed().
- *
  *    While the mm_struct we are migrating is typically from some
  *    other task, the task_struct mems_allowed that we are hacking
  *    is for our current task, which must allocate new pages for that
@@ -973,15 +970,20 @@ static void cpuset_change_nodemask(struct task_struct *p,
        struct cpuset *cs;
        int migrate;
        const nodemask_t *oldmem = scan->data;
-       nodemask_t newmems;
+       NODEMASK_ALLOC(nodemask_t, newmems, GFP_KERNEL);
+
+       if (!newmems)
+               return;
 
        cs = cgroup_cs(scan->cg);
-       guarantee_online_mems(cs, &newmems);
+       guarantee_online_mems(cs, newmems);
 
        task_lock(p);
-       cpuset_change_task_nodemask(p, &newmems);
+       cpuset_change_task_nodemask(p, newmems);
        task_unlock(p);
 
+       NODEMASK_FREE(newmems);
+
        mm = get_task_mm(p);
        if (!mm)
                return;
@@ -1051,16 +1053,21 @@ static void update_tasks_nodemask(struct cpuset *cs, const nodemask_t *oldmem,
 static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
                           const char *buf)
 {
-       nodemask_t oldmem;
+       NODEMASK_ALLOC(nodemask_t, oldmem, GFP_KERNEL);
        int retval;
        struct ptr_heap heap;
 
+       if (!oldmem)
+               return -ENOMEM;
+
        /*
         * top_cpuset.mems_allowed tracks node_stats[N_HIGH_MEMORY];
         * it's read-only
         */
-       if (cs == &top_cpuset)
-               return -EACCES;
+       if (cs == &top_cpuset) {
+               retval = -EACCES;
+               goto done;
+       }
 
        /*
         * An empty mems_allowed is ok iff there are no tasks in the cpuset.
@@ -1076,11 +1083,13 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
                        goto done;
 
                if (!nodes_subset(trialcs->mems_allowed,
-                               node_states[N_HIGH_MEMORY]))
-                       return -EINVAL;
+                               node_states[N_HIGH_MEMORY])) {
+                       retval =  -EINVAL;
+                       goto done;
+               }
        }
-       oldmem = cs->mems_allowed;
-       if (nodes_equal(oldmem, trialcs->mems_allowed)) {
+       *oldmem = cs->mems_allowed;
+       if (nodes_equal(*oldmem, trialcs->mems_allowed)) {
                retval = 0;             /* Too easy - nothing to do */
                goto done;
        }
@@ -1096,10 +1105,11 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
        cs->mems_allowed = trialcs->mems_allowed;
        mutex_unlock(&callback_mutex);
 
-       update_tasks_nodemask(cs, &oldmem, &heap);
+       update_tasks_nodemask(cs, oldmem, &heap);
 
        heap_free(&heap);
 done:
+       NODEMASK_FREE(oldmem);
        return retval;
 }
 
@@ -1384,40 +1394,47 @@ static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont,
                          struct cgroup *oldcont, struct task_struct *tsk,
                          bool threadgroup)
 {
-       nodemask_t from, to;
        struct mm_struct *mm;
        struct cpuset *cs = cgroup_cs(cont);
        struct cpuset *oldcs = cgroup_cs(oldcont);
+       NODEMASK_ALLOC(nodemask_t, from, GFP_KERNEL);
+       NODEMASK_ALLOC(nodemask_t, to, GFP_KERNEL);
+
+       if (from == NULL || to == NULL)
+               goto alloc_fail;
 
        if (cs == &top_cpuset) {
                cpumask_copy(cpus_attach, cpu_possible_mask);
-               to = node_possible_map;
        } else {
                guarantee_online_cpus(cs, cpus_attach);
-               guarantee_online_mems(cs, &to);
        }
+       guarantee_online_mems(cs, to);
 
        /* do per-task migration stuff possibly for each in the threadgroup */
-       cpuset_attach_task(tsk, &to, cs);
+       cpuset_attach_task(tsk, to, cs);
        if (threadgroup) {
                struct task_struct *c;
                rcu_read_lock();
                list_for_each_entry_rcu(c, &tsk->thread_group, thread_group) {
-                       cpuset_attach_task(c, &to, cs);
+                       cpuset_attach_task(c, to, cs);
                }
                rcu_read_unlock();
        }
 
        /* change mm; only needs to be done once even if threadgroup */
-       from = oldcs->mems_allowed;
-       to = cs->mems_allowed;
+       *from = oldcs->mems_allowed;
+       *to = cs->mems_allowed;
        mm = get_task_mm(tsk);
        if (mm) {
-               mpol_rebind_mm(mm, &to);
+               mpol_rebind_mm(mm, to);
                if (is_memory_migrate(cs))
-                       cpuset_migrate_mm(mm, &from, &to);
+                       cpuset_migrate_mm(mm, from, to);
                mmput(mm);
        }
+
+alloc_fail:
+       NODEMASK_FREE(from);
+       NODEMASK_FREE(to);
 }
 
 /* The various types of files and directories in a cpuset file system */
@@ -1562,13 +1579,21 @@ static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs)
 
 static int cpuset_sprintf_memlist(char *page, struct cpuset *cs)
 {
-       nodemask_t mask;
+       NODEMASK_ALLOC(nodemask_t, mask, GFP_KERNEL);
+       int retval;
+
+       if (mask == NULL)
+               return -ENOMEM;
 
        mutex_lock(&callback_mutex);
-       mask = cs->mems_allowed;
+       *mask = cs->mems_allowed;
        mutex_unlock(&callback_mutex);
 
-       return nodelist_scnprintf(page, PAGE_SIZE, mask);
+       retval = nodelist_scnprintf(page, PAGE_SIZE, *mask);
+
+       NODEMASK_FREE(mask);
+
+       return retval;
 }
 
 static ssize_t cpuset_common_file_read(struct cgroup *cont,
@@ -1997,7 +2022,10 @@ static void scan_for_empty_cpusets(struct cpuset *root)
        struct cpuset *cp;      /* scans cpusets being updated */
        struct cpuset *child;   /* scans child cpusets of cp */
        struct cgroup *cont;
-       nodemask_t oldmems;
+       NODEMASK_ALLOC(nodemask_t, oldmems, GFP_KERNEL);
+
+       if (oldmems == NULL)
+               return;
 
        list_add_tail((struct list_head *)&root->stack_list, &queue);
 
@@ -2014,7 +2042,7 @@ static void scan_for_empty_cpusets(struct cpuset *root)
                    nodes_subset(cp->mems_allowed, node_states[N_HIGH_MEMORY]))
                        continue;
 
-               oldmems = cp->mems_allowed;
+               *oldmems = cp->mems_allowed;
 
                /* Remove offline cpus and mems from this cpuset. */
                mutex_lock(&callback_mutex);
@@ -2030,9 +2058,10 @@ static void scan_for_empty_cpusets(struct cpuset *root)
                        remove_tasks_in_empty_cpuset(cp);
                else {
                        update_tasks_cpumask(cp, NULL);
-                       update_tasks_nodemask(cp, &oldmems, NULL);
+                       update_tasks_nodemask(cp, oldmems, NULL);
                }
        }
+       NODEMASK_FREE(oldmems);
 }
 
 /*
@@ -2090,20 +2119,33 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
 static int cpuset_track_online_nodes(struct notifier_block *self,
                                unsigned long action, void *arg)
 {
+       NODEMASK_ALLOC(nodemask_t, oldmems, GFP_KERNEL);
+
+       if (oldmems == NULL)
+               return NOTIFY_DONE;
+
        cgroup_lock();
        switch (action) {
        case MEM_ONLINE:
-       case MEM_OFFLINE:
+               *oldmems = top_cpuset.mems_allowed;
                mutex_lock(&callback_mutex);
                top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
                mutex_unlock(&callback_mutex);
-               if (action == MEM_OFFLINE)
-                       scan_for_empty_cpusets(&top_cpuset);
+               update_tasks_nodemask(&top_cpuset, oldmems, NULL);
+               break;
+       case MEM_OFFLINE:
+               /*
+                * needn't update top_cpuset.mems_allowed explicitly because
+                * scan_for_empty_cpusets() will update it.
+                */
+               scan_for_empty_cpusets(&top_cpuset);
                break;
        default:
                break;
        }
        cgroup_unlock();
+
+       NODEMASK_FREE(oldmems);
        return NOTIFY_OK;
 }
 #endif
index 1ed8ca18790c1e937208af47bed6695f4218858b..e1dbe9eef800b8be745650d095334df6be4ab433 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/module.h>
 #include <linux/cred.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/key.h>
 #include <linux/keyctl.h>
@@ -364,7 +365,7 @@ struct cred *prepare_usermodehelper_creds(void)
 
        new = kmem_cache_alloc(cred_jar, GFP_ATOMIC);
        if (!new)
-               return NULL;
+               goto free_tgcred;
 
        kdebug("prepare_usermodehelper_creds() alloc %p", new);
 
@@ -397,6 +398,10 @@ struct cred *prepare_usermodehelper_creds(void)
 
 error:
        put_cred(new);
+free_tgcred:
+#ifdef CONFIG_KEYS
+       kfree(tgcred);
+#endif
        return NULL;
 }
 
index 3cb2c661bb781ab5468a54e58a106cdb14269a7b..31aa9332ef3f8d4f5447f72a3989cbfd0dc7c6df 100644 (file)
@@ -333,6 +333,12 @@ void __init free_early_partial(u64 start, u64 end)
        struct early_res *r;
        int i;
 
+       if (start == end)
+               return;
+
+       if (WARN_ONCE(start > end, "  wrong range [%#llx, %#llx]\n", start, end))
+               return;
+
 try_next:
        i = find_overlapped_early(start, end);
        if (i >= max_early_res)
index 42ec11b2af8af5205c09523a9b18b3bf6fdd98ef..b7091d5ca2f829ae61f0140ae6b1901213bfab62 100644 (file)
@@ -359,6 +359,23 @@ static inline void mask_ack_irq(struct irq_desc *desc, int irq)
                if (desc->chip->ack)
                        desc->chip->ack(irq);
        }
+       desc->status |= IRQ_MASKED;
+}
+
+static inline void mask_irq(struct irq_desc *desc, int irq)
+{
+       if (desc->chip->mask) {
+               desc->chip->mask(irq);
+               desc->status |= IRQ_MASKED;
+       }
+}
+
+static inline void unmask_irq(struct irq_desc *desc, int irq)
+{
+       if (desc->chip->unmask) {
+               desc->chip->unmask(irq);
+               desc->status &= ~IRQ_MASKED;
+       }
 }
 
 /*
@@ -484,10 +501,8 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
        raw_spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 
-       if (unlikely(desc->status & IRQ_ONESHOT))
-               desc->status |= IRQ_MASKED;
-       else if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
-               desc->chip->unmask(irq);
+       if (!(desc->status & (IRQ_DISABLED | IRQ_ONESHOT)))
+               unmask_irq(desc, irq);
 out_unlock:
        raw_spin_unlock(&desc->lock);
 }
@@ -524,8 +539,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
        action = desc->action;
        if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
                desc->status |= IRQ_PENDING;
-               if (desc->chip->mask)
-                       desc->chip->mask(irq);
+               mask_irq(desc, irq);
                goto out;
        }
 
@@ -593,7 +607,7 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
                irqreturn_t action_ret;
 
                if (unlikely(!action)) {
-                       desc->chip->mask(irq);
+                       mask_irq(desc, irq);
                        goto out_unlock;
                }
 
@@ -605,8 +619,7 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
                if (unlikely((desc->status &
                               (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
                              (IRQ_PENDING | IRQ_MASKED))) {
-                       desc->chip->unmask(irq);
-                       desc->status &= ~IRQ_MASKED;
+                       unmask_irq(desc, irq);
                }
 
                desc->status &= ~IRQ_PENDING;
@@ -716,7 +729,7 @@ set_irq_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
        __set_irq_handler(irq, handle, 0, name);
 }
 
-void __init set_irq_noprobe(unsigned int irq)
+void set_irq_noprobe(unsigned int irq)
 {
        struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
@@ -731,7 +744,7 @@ void __init set_irq_noprobe(unsigned int irq)
        raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
-void __init set_irq_probe(unsigned int irq)
+void set_irq_probe(unsigned int irq)
 {
        struct irq_desc *desc = irq_to_desc(irq);
        unsigned long flags;
index eb6078ca60c7f548a052aa42c247dbb8b24d9620..398fda155f6e26dd72dd1fa00805b1383c156a5d 100644 (file)
@@ -382,6 +382,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
 {
        struct irq_desc *desc = irq_to_desc(irq);
        struct irqaction *action;
+       unsigned long flags;
 
        if (!desc)
                return 0;
@@ -389,11 +390,14 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
        if (desc->status & IRQ_NOREQUEST)
                return 0;
 
+       raw_spin_lock_irqsave(&desc->lock, flags);
        action = desc->action;
        if (action)
                if (irqflags & action->flags & IRQF_SHARED)
                        action = NULL;
 
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
+
        return !action;
 }
 
@@ -483,8 +487,26 @@ static int irq_wait_for_interrupt(struct irqaction *action)
  */
 static void irq_finalize_oneshot(unsigned int irq, struct irq_desc *desc)
 {
+again:
        chip_bus_lock(irq, desc);
        raw_spin_lock_irq(&desc->lock);
+
+       /*
+        * Implausible though it may be we need to protect us against
+        * the following scenario:
+        *
+        * The thread is faster done than the hard interrupt handler
+        * on the other CPU. If we unmask the irq line then the
+        * interrupt can come in again and masks the line, leaves due
+        * to IRQ_INPROGRESS and the irq line is masked forever.
+        */
+       if (unlikely(desc->status & IRQ_INPROGRESS)) {
+               raw_spin_unlock_irq(&desc->lock);
+               chip_bus_sync_unlock(irq, desc);
+               cpu_relax();
+               goto again;
+       }
+
        if (!(desc->status & IRQ_DISABLED) && (desc->status & IRQ_MASKED)) {
                desc->status &= ~IRQ_MASKED;
                desc->chip->unmask(irq);
index 963559dbd858a4968913ea8d5790867630714668..65d3845665acad7ac0ad540c6f6f08805abf88eb 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/irq.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/random.h>
 #include <linux/interrupt.h>
index 6f50eccc79c01e4f7b80a0a107d9a1adb183328d..7a6eb04ef6b587b37ca97a127186adfcc812886d 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/irq.h>
+#include <linux/gfp.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
index 8e5288a8a3555c419f477e0925f3210e3863cef6..13aff293f4def468c250a5215a0314162fa7deee 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/sched.h>       /* for cond_resched */
 #include <linux/mm.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 
 #include <asm/sections.h>
 
index 761fdd2b3034ae87272578fe1314680af5c0d71f..11f3515ca83f6af2b4614d11ac429c2fdf56bb4f 100644 (file)
@@ -69,9 +69,16 @@ struct kgdb_state {
        struct pt_regs          *linux_regs;
 };
 
+/* Exception state values */
+#define DCPU_WANT_MASTER 0x1 /* Waiting to become a master kgdb cpu */
+#define DCPU_NEXT_MASTER 0x2 /* Transition from one master cpu to another */
+#define DCPU_IS_SLAVE    0x4 /* Slave cpu enter exception */
+#define DCPU_SSTEP       0x8 /* CPU is single stepping */
+
 static struct debuggerinfo_struct {
        void                    *debuggerinfo;
        struct task_struct      *task;
+       int                     exception_state;
 } kgdb_info[NR_CPUS];
 
 /**
@@ -391,27 +398,22 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
 
 /*
  * Copy the binary array pointed to by buf into mem.  Fix $, #, and
- * 0x7d escaped with 0x7d.  Return a pointer to the character after
- * the last byte written.
+ * 0x7d escaped with 0x7d. Return -EFAULT on failure or 0 on success.
+ * The input buf is overwitten with the result to write to mem.
  */
 static int kgdb_ebin2mem(char *buf, char *mem, int count)
 {
-       int err = 0;
-       char c;
+       int size = 0;
+       char *c = buf;
 
        while (count-- > 0) {
-               c = *buf++;
-               if (c == 0x7d)
-                       c = *buf++ ^ 0x20;
-
-               err = probe_kernel_write(mem, &c, 1);
-               if (err)
-                       break;
-
-               mem++;
+               c[size] = *buf++;
+               if (c[size] == 0x7d)
+                       c[size] = *buf++ ^ 0x20;
+               size++;
        }
 
-       return err;
+       return probe_kernel_write(mem, c, size);
 }
 
 /*
@@ -562,49 +564,6 @@ static struct task_struct *getthread(struct pt_regs *regs, int tid)
        return find_task_by_pid_ns(tid, &init_pid_ns);
 }
 
-/*
- * CPU debug state control:
- */
-
-#ifdef CONFIG_SMP
-static void kgdb_wait(struct pt_regs *regs)
-{
-       unsigned long flags;
-       int cpu;
-
-       local_irq_save(flags);
-       cpu = raw_smp_processor_id();
-       kgdb_info[cpu].debuggerinfo = regs;
-       kgdb_info[cpu].task = current;
-       /*
-        * Make sure the above info reaches the primary CPU before
-        * our cpu_in_kgdb[] flag setting does:
-        */
-       smp_wmb();
-       atomic_set(&cpu_in_kgdb[cpu], 1);
-
-       /* Disable any cpu specific hw breakpoints */
-       kgdb_disable_hw_debug(regs);
-
-       /* Wait till primary CPU is done with debugging */
-       while (atomic_read(&passive_cpu_wait[cpu]))
-               cpu_relax();
-
-       kgdb_info[cpu].debuggerinfo = NULL;
-       kgdb_info[cpu].task = NULL;
-
-       /* fix up hardware debug registers on local cpu */
-       if (arch_kgdb_ops.correct_hw_break)
-               arch_kgdb_ops.correct_hw_break();
-
-       /* Signal the primary CPU that we are done: */
-       atomic_set(&cpu_in_kgdb[cpu], 0);
-       touch_softlockup_watchdog_sync();
-       clocksource_touch_watchdog();
-       local_irq_restore(flags);
-}
-#endif
-
 /*
  * Some architectures need cache flushes when we set/clear a
  * breakpoint:
@@ -1400,34 +1359,13 @@ static int kgdb_reenter_check(struct kgdb_state *ks)
        return 1;
 }
 
-/*
- * kgdb_handle_exception() - main entry point from a kernel exception
- *
- * Locking hierarchy:
- *     interface locks, if any (begin_session)
- *     kgdb lock (kgdb_active)
- */
-int
-kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
+static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs)
 {
-       struct kgdb_state kgdb_var;
-       struct kgdb_state *ks = &kgdb_var;
        unsigned long flags;
        int sstep_tries = 100;
        int error = 0;
        int i, cpu;
-
-       ks->cpu                 = raw_smp_processor_id();
-       ks->ex_vector           = evector;
-       ks->signo               = signo;
-       ks->ex_vector           = evector;
-       ks->err_code            = ecode;
-       ks->kgdb_usethreadid    = 0;
-       ks->linux_regs          = regs;
-
-       if (kgdb_reenter_check(ks))
-               return 0; /* Ouch, double exception ! */
-
+       int trace_on = 0;
 acquirelock:
        /*
         * Interrupts will be restored by the 'trap return' code, except when
@@ -1435,13 +1373,43 @@ acquirelock:
         */
        local_irq_save(flags);
 
-       cpu = raw_smp_processor_id();
+       cpu = ks->cpu;
+       kgdb_info[cpu].debuggerinfo = regs;
+       kgdb_info[cpu].task = current;
+       /*
+        * Make sure the above info reaches the primary CPU before
+        * our cpu_in_kgdb[] flag setting does:
+        */
+       atomic_inc(&cpu_in_kgdb[cpu]);
 
        /*
-        * Acquire the kgdb_active lock:
+        * CPU will loop if it is a slave or request to become a kgdb
+        * master cpu and acquire the kgdb_active lock:
         */
-       while (atomic_cmpxchg(&kgdb_active, -1, cpu) != -1)
+       while (1) {
+               if (kgdb_info[cpu].exception_state & DCPU_WANT_MASTER) {
+                       if (atomic_cmpxchg(&kgdb_active, -1, cpu) == cpu)
+                               break;
+               } else if (kgdb_info[cpu].exception_state & DCPU_IS_SLAVE) {
+                       if (!atomic_read(&passive_cpu_wait[cpu]))
+                               goto return_normal;
+               } else {
+return_normal:
+                       /* Return to normal operation by executing any
+                        * hw breakpoint fixup.
+                        */
+                       if (arch_kgdb_ops.correct_hw_break)
+                               arch_kgdb_ops.correct_hw_break();
+                       if (trace_on)
+                               tracing_on();
+                       atomic_dec(&cpu_in_kgdb[cpu]);
+                       touch_softlockup_watchdog_sync();
+                       clocksource_touch_watchdog();
+                       local_irq_restore(flags);
+                       return 0;
+               }
                cpu_relax();
+       }
 
        /*
         * For single stepping, try to only enter on the processor
@@ -1475,9 +1443,6 @@ acquirelock:
        if (kgdb_io_ops->pre_exception)
                kgdb_io_ops->pre_exception();
 
-       kgdb_info[ks->cpu].debuggerinfo = ks->linux_regs;
-       kgdb_info[ks->cpu].task = current;
-
        kgdb_disable_hw_debug(ks->linux_regs);
 
        /*
@@ -1486,15 +1451,9 @@ acquirelock:
         */
        if (!kgdb_single_step) {
                for (i = 0; i < NR_CPUS; i++)
-                       atomic_set(&passive_cpu_wait[i], 1);
+                       atomic_inc(&passive_cpu_wait[i]);
        }
 
-       /*
-        * spin_lock code is good enough as a barrier so we don't
-        * need one here:
-        */
-       atomic_set(&cpu_in_kgdb[ks->cpu], 1);
-
 #ifdef CONFIG_SMP
        /* Signal the other CPUs to enter kgdb_wait() */
        if ((!kgdb_single_step) && kgdb_do_roundup)
@@ -1518,6 +1477,9 @@ acquirelock:
        kgdb_single_step = 0;
        kgdb_contthread = current;
        exception_level = 0;
+       trace_on = tracing_is_on();
+       if (trace_on)
+               tracing_off();
 
        /* Talk to debugger with gdbserial protocol */
        error = gdb_serial_stub(ks);
@@ -1526,13 +1488,11 @@ acquirelock:
        if (kgdb_io_ops->post_exception)
                kgdb_io_ops->post_exception();
 
-       kgdb_info[ks->cpu].debuggerinfo = NULL;
-       kgdb_info[ks->cpu].task = NULL;
-       atomic_set(&cpu_in_kgdb[ks->cpu], 0);
+       atomic_dec(&cpu_in_kgdb[ks->cpu]);
 
        if (!kgdb_single_step) {
                for (i = NR_CPUS-1; i >= 0; i--)
-                       atomic_set(&passive_cpu_wait[i], 0);
+                       atomic_dec(&passive_cpu_wait[i]);
                /*
                 * Wait till all the CPUs have quit
                 * from the debugger.
@@ -1551,6 +1511,8 @@ kgdb_restore:
                else
                        kgdb_sstep_pid = 0;
        }
+       if (trace_on)
+               tracing_on();
        /* Free kgdb_active */
        atomic_set(&kgdb_active, -1);
        touch_softlockup_watchdog_sync();
@@ -1560,13 +1522,52 @@ kgdb_restore:
        return error;
 }
 
+/*
+ * kgdb_handle_exception() - main entry point from a kernel exception
+ *
+ * Locking hierarchy:
+ *     interface locks, if any (begin_session)
+ *     kgdb lock (kgdb_active)
+ */
+int
+kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
+{
+       struct kgdb_state kgdb_var;
+       struct kgdb_state *ks = &kgdb_var;
+       int ret;
+
+       ks->cpu                 = raw_smp_processor_id();
+       ks->ex_vector           = evector;
+       ks->signo               = signo;
+       ks->ex_vector           = evector;
+       ks->err_code            = ecode;
+       ks->kgdb_usethreadid    = 0;
+       ks->linux_regs          = regs;
+
+       if (kgdb_reenter_check(ks))
+               return 0; /* Ouch, double exception ! */
+       kgdb_info[ks->cpu].exception_state |= DCPU_WANT_MASTER;
+       ret = kgdb_cpu_enter(ks, regs);
+       kgdb_info[ks->cpu].exception_state &= ~DCPU_WANT_MASTER;
+       return ret;
+}
+
 int kgdb_nmicallback(int cpu, void *regs)
 {
 #ifdef CONFIG_SMP
+       struct kgdb_state kgdb_var;
+       struct kgdb_state *ks = &kgdb_var;
+
+       memset(ks, 0, sizeof(struct kgdb_state));
+       ks->cpu                 = cpu;
+       ks->linux_regs          = regs;
+
        if (!atomic_read(&cpu_in_kgdb[cpu]) &&
-                       atomic_read(&kgdb_active) != cpu &&
-                       atomic_read(&cpu_in_kgdb[atomic_read(&kgdb_active)])) {
-               kgdb_wait((struct pt_regs *)regs);
+           atomic_read(&kgdb_active) != -1 &&
+           atomic_read(&kgdb_active) != cpu) {
+               kgdb_info[cpu].exception_state |= DCPU_IS_SLAVE;
+               kgdb_cpu_enter(ks, regs);
+               kgdb_info[cpu].exception_state &= ~DCPU_IS_SLAVE;
                return 0;
        }
 #endif
@@ -1742,11 +1743,11 @@ EXPORT_SYMBOL_GPL(kgdb_unregister_io_module);
  */
 void kgdb_breakpoint(void)
 {
-       atomic_set(&kgdb_setting_breakpoint, 1);
+       atomic_inc(&kgdb_setting_breakpoint);
        wmb(); /* Sync point before breakpoint */
        arch_kgdb_breakpoint();
        wmb(); /* Sync point after breakpoint */
-       atomic_set(&kgdb_setting_breakpoint, 0);
+       atomic_dec(&kgdb_setting_breakpoint);
 }
 EXPORT_SYMBOL_GPL(kgdb_breakpoint);
 
index 82ed0ea15194caf27c72dd3a40d459731eb718df..83911c7801751dd847348145db20f4e3e40e33b6 100644 (file)
@@ -219,7 +219,7 @@ int kthreadd(void *unused)
        set_task_comm(tsk, "kthreadd");
        ignore_signals(tsk);
        set_cpus_allowed_ptr(tsk, cpu_all_mask);
-       set_mems_allowed(node_possible_map);
+       set_mems_allowed(node_states[N_HIGH_MEMORY]);
 
        current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG;
 
index ca07c5c0c914186de89fb26e7323193375051178..877fb306d4154465e184e19b73ca1984a179aece 100644 (file)
@@ -56,7 +56,6 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/list.h>
-#include <linux/slab.h>
 #include <linux/stacktrace.h>
 
 static DEFINE_SPINLOCK(latency_lock);
index c927a549db2c73ce36377643e9fe761295bf7f21..2594e1ce41cbf12889b44deb3fc202c0a5c30fa2 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/ftrace.h>
 #include <linux/stringify.h>
 #include <linux/bitops.h>
+#include <linux/gfp.h>
 
 #include <asm/sections.h>
 
@@ -582,9 +583,6 @@ static int static_obj(void *obj)
        unsigned long start = (unsigned long) &_stext,
                      end   = (unsigned long) &_end,
                      addr  = (unsigned long) obj;
-#ifdef CONFIG_SMP
-       int i;
-#endif
 
        /*
         * static variable?
@@ -595,24 +593,16 @@ static int static_obj(void *obj)
        if (arch_is_kernel_data(addr))
                return 1;
 
-#ifdef CONFIG_SMP
        /*
-        * percpu var?
+        * in-kernel percpu var?
         */
-       for_each_possible_cpu(i) {
-               start = (unsigned long) &__per_cpu_start + per_cpu_offset(i);
-               end   = (unsigned long) &__per_cpu_start + PERCPU_ENOUGH_ROOM
-                                       + per_cpu_offset(i);
-
-               if ((addr >= start) && (addr < end))
-                       return 1;
-       }
-#endif
+       if (is_kernel_percpu_address(addr))
+               return 1;
 
        /*
-        * module var?
+        * module static or percpu var?
         */
-       return is_module_address(addr);
+       return is_module_address(addr) || is_module_percpu_address(addr);
 }
 
 /*
index c968d3606dca8cbf9d4e3ba04bcb0a48091024e9..1016b75b026ab61b7ef0ee233915c3b1adeaf64d 100644 (file)
@@ -370,27 +370,33 @@ EXPORT_SYMBOL_GPL(find_module);
 
 #ifdef CONFIG_SMP
 
-static void *percpu_modalloc(unsigned long size, unsigned long align,
-                            const char *name)
+static inline void __percpu *mod_percpu(struct module *mod)
 {
-       void *ptr;
+       return mod->percpu;
+}
 
+static int percpu_modalloc(struct module *mod,
+                          unsigned long size, unsigned long align)
+{
        if (align > PAGE_SIZE) {
                printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
-                      name, align, PAGE_SIZE);
+                      mod->name, align, PAGE_SIZE);
                align = PAGE_SIZE;
        }
 
-       ptr = __alloc_reserved_percpu(size, align);
-       if (!ptr)
+       mod->percpu = __alloc_reserved_percpu(size, align);
+       if (!mod->percpu) {
                printk(KERN_WARNING
                       "Could not allocate %lu bytes percpu data\n", size);
-       return ptr;
+               return -ENOMEM;
+       }
+       mod->percpu_size = size;
+       return 0;
 }
 
-static void percpu_modfree(void *freeme)
+static void percpu_modfree(struct module *mod)
 {
-       free_percpu(freeme);
+       free_percpu(mod->percpu);
 }
 
 static unsigned int find_pcpusec(Elf_Ehdr *hdr,
@@ -400,24 +406,62 @@ static unsigned int find_pcpusec(Elf_Ehdr *hdr,
        return find_sec(hdr, sechdrs, secstrings, ".data.percpu");
 }
 
-static void percpu_modcopy(void *pcpudest, const void *from, unsigned long size)
+static void percpu_modcopy(struct module *mod,
+                          const void *from, unsigned long size)
 {
        int cpu;
 
        for_each_possible_cpu(cpu)
-               memcpy(pcpudest + per_cpu_offset(cpu), from, size);
+               memcpy(per_cpu_ptr(mod->percpu, cpu), from, size);
+}
+
+/**
+ * is_module_percpu_address - test whether address is from module static percpu
+ * @addr: address to test
+ *
+ * Test whether @addr belongs to module static percpu area.
+ *
+ * RETURNS:
+ * %true if @addr is from module static percpu area
+ */
+bool is_module_percpu_address(unsigned long addr)
+{
+       struct module *mod;
+       unsigned int cpu;
+
+       preempt_disable();
+
+       list_for_each_entry_rcu(mod, &modules, list) {
+               if (!mod->percpu_size)
+                       continue;
+               for_each_possible_cpu(cpu) {
+                       void *start = per_cpu_ptr(mod->percpu, cpu);
+
+                       if ((void *)addr >= start &&
+                           (void *)addr < start + mod->percpu_size) {
+                               preempt_enable();
+                               return true;
+                       }
+               }
+       }
+
+       preempt_enable();
+       return false;
 }
 
 #else /* ... !CONFIG_SMP */
 
-static inline void *percpu_modalloc(unsigned long size, unsigned long align,
-                                   const char *name)
+static inline void __percpu *mod_percpu(struct module *mod)
 {
        return NULL;
 }
-static inline void percpu_modfree(void *pcpuptr)
+static inline int percpu_modalloc(struct module *mod,
+                                 unsigned long size, unsigned long align)
+{
+       return -ENOMEM;
+}
+static inline void percpu_modfree(struct module *mod)
 {
-       BUG();
 }
 static inline unsigned int find_pcpusec(Elf_Ehdr *hdr,
                                        Elf_Shdr *sechdrs,
@@ -425,12 +469,16 @@ static inline unsigned int find_pcpusec(Elf_Ehdr *hdr,
 {
        return 0;
 }
-static inline void percpu_modcopy(void *pcpudst, const void *src,
-                                 unsigned long size)
+static inline void percpu_modcopy(struct module *mod,
+                                 const void *from, unsigned long size)
 {
        /* pcpusec should be 0, and size of that section should be 0. */
        BUG_ON(size != 0);
 }
+bool is_module_percpu_address(unsigned long addr)
+{
+       return false;
+}
 
 #endif /* CONFIG_SMP */
 
@@ -473,11 +521,13 @@ static void module_unload_init(struct module *mod)
        int cpu;
 
        INIT_LIST_HEAD(&mod->modules_which_use_me);
-       for_each_possible_cpu(cpu)
-               per_cpu_ptr(mod->refptr, cpu)->count = 0;
+       for_each_possible_cpu(cpu) {
+               per_cpu_ptr(mod->refptr, cpu)->incs = 0;
+               per_cpu_ptr(mod->refptr, cpu)->decs = 0;
+       }
 
        /* Hold reference count during initialization. */
-       __this_cpu_write(mod->refptr->count, 1);
+       __this_cpu_write(mod->refptr->incs, 1);
        /* Backwards compatibility macros put refcount during init. */
        mod->waiter = current;
 }
@@ -616,12 +666,28 @@ static int try_stop_module(struct module *mod, int flags, int *forced)
 
 unsigned int module_refcount(struct module *mod)
 {
-       unsigned int total = 0;
+       unsigned int incs = 0, decs = 0;
        int cpu;
 
        for_each_possible_cpu(cpu)
-               total += per_cpu_ptr(mod->refptr, cpu)->count;
-       return total;
+               decs += per_cpu_ptr(mod->refptr, cpu)->decs;
+       /*
+        * ensure the incs are added up after the decs.
+        * module_put ensures incs are visible before decs with smp_wmb.
+        *
+        * This 2-count scheme avoids the situation where the refcount
+        * for CPU0 is read, then CPU0 increments the module refcount,
+        * then CPU1 drops that refcount, then the refcount for CPU1 is
+        * read. We would record a decrement but not its corresponding
+        * increment so we would see a low count (disaster).
+        *
+        * Rare situation? But module_refcount can be preempted, and we
+        * might be tallying up 4096+ CPUs. So it is not impossible.
+        */
+       smp_rmb();
+       for_each_possible_cpu(cpu)
+               incs += per_cpu_ptr(mod->refptr, cpu)->incs;
+       return incs - decs;
 }
 EXPORT_SYMBOL(module_refcount);
 
@@ -798,10 +864,11 @@ void module_put(struct module *module)
 {
        if (module) {
                preempt_disable();
-               __this_cpu_dec(module->refptr->count);
+               smp_wmb(); /* see comment in module_refcount */
+               __this_cpu_inc(module->refptr->decs);
 
                trace_module_put(module, _RET_IP_,
-                                __this_cpu_read(module->refptr->count));
+                                __this_cpu_read(module->refptr->decs));
                /* Maybe they're waiting for us to drop reference? */
                if (unlikely(!module_is_live(module)))
                        wake_up_process(module->waiter);
@@ -1400,8 +1467,7 @@ static void free_module(struct module *mod)
        /* This may be NULL, but that's OK */
        module_free(mod, mod->module_init);
        kfree(mod->args);
-       if (mod->percpu)
-               percpu_modfree(mod->percpu);
+       percpu_modfree(mod);
 #if defined(CONFIG_MODULE_UNLOAD)
        if (mod->refptr)
                free_percpu(mod->refptr);
@@ -1520,7 +1586,7 @@ static int simplify_symbols(Elf_Shdr *sechdrs,
                default:
                        /* Divert to percpu allocation if a percpu var. */
                        if (sym[i].st_shndx == pcpuindex)
-                               secbase = (unsigned long)mod->percpu;
+                               secbase = (unsigned long)mod_percpu(mod);
                        else
                                secbase = sechdrs[sym[i].st_shndx].sh_addr;
                        sym[i].st_value += secbase;
@@ -1954,7 +2020,7 @@ static noinline struct module *load_module(void __user *umod,
        unsigned int modindex, versindex, infoindex, pcpuindex;
        struct module *mod;
        long err = 0;
-       void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
+       void *ptr = NULL; /* Stops spurious gcc warning */
        unsigned long symoffs, stroffs, *strmap;
 
        mm_segment_t old_fs;
@@ -2094,15 +2160,11 @@ static noinline struct module *load_module(void __user *umod,
 
        if (pcpuindex) {
                /* We have a special allocation for this section. */
-               percpu = percpu_modalloc(sechdrs[pcpuindex].sh_size,
-                                        sechdrs[pcpuindex].sh_addralign,
-                                        mod->name);
-               if (!percpu) {
-                       err = -ENOMEM;
+               err = percpu_modalloc(mod, sechdrs[pcpuindex].sh_size,
+                                     sechdrs[pcpuindex].sh_addralign);
+               if (err)
                        goto free_mod;
-               }
                sechdrs[pcpuindex].sh_flags &= ~(unsigned long)SHF_ALLOC;
-               mod->percpu = percpu;
        }
 
        /* Determine total sizes, and put offsets in sh_entsize.  For now
@@ -2317,7 +2379,7 @@ static noinline struct module *load_module(void __user *umod,
        sort_extable(mod->extable, mod->extable + mod->num_exentries);
 
        /* Finally, copy percpu area over. */
-       percpu_modcopy(mod->percpu, (void *)sechdrs[pcpuindex].sh_addr,
+       percpu_modcopy(mod, (void *)sechdrs[pcpuindex].sh_addr,
                       sechdrs[pcpuindex].sh_size);
 
        add_kallsyms(mod, sechdrs, hdr->e_shnum, symindex, strindex,
@@ -2409,8 +2471,7 @@ static noinline struct module *load_module(void __user *umod,
        module_free(mod, mod->module_core);
        /* mod will be freed with core. Don't access it beyond this line! */
  free_percpu:
-       if (percpu)
-               percpu_modfree(percpu);
+       percpu_modfree(mod);
  free_mod:
        kfree(args);
        kfree(strmap);
index 2ab67233ee8f71bf43fd7f746438c652c891419f..f74e6c00e26d1f50fb1c404b2a6e5505354882bf 100644 (file)
@@ -13,6 +13,7 @@
  *             Pavel Emelianov <xemul@openvz.org>
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/nsproxy.h>
 #include <linux/init_task.h>
index 93caf65ff57c80cf52ce215e51c65694060d95af..fd03513c7327f548c9eb990bfa94e78196fbefe8 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/padata.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/rcupdate.h>
 
 #define MAX_SEQ_NR INT_MAX - NR_CPUS
index 574ee58a3046a4bff950aa9051e73a2d5dfd7d8b..2f3fbf84215a940cc40eccef9c8304964d10906f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/smp.h>
 #include <linux/file.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/dcache.h>
 #include <linux/percpu.h>
@@ -1164,11 +1165,9 @@ void perf_event_task_sched_out(struct task_struct *task,
        struct perf_event_context *ctx = task->perf_event_ctxp;
        struct perf_event_context *next_ctx;
        struct perf_event_context *parent;
-       struct pt_regs *regs;
        int do_switch = 1;
 
-       regs = task_pt_regs(task);
-       perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, regs, 0);
+       perf_sw_event(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 1, NULL, 0);
 
        if (likely(!ctx || !cpuctx->task_ctx))
                return;
@@ -2786,12 +2785,11 @@ __weak struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
        return NULL;
 }
 
-#ifdef CONFIG_EVENT_TRACING
 __weak
 void perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip, int skip)
 {
 }
-#endif
+
 
 /*
  * Output
@@ -3378,15 +3376,23 @@ static void perf_event_task_output(struct perf_event *event,
                                     struct perf_task_event *task_event)
 {
        struct perf_output_handle handle;
-       int size;
        struct task_struct *task = task_event->task;
-       int ret;
+       unsigned long flags;
+       int size, ret;
+
+       /*
+        * If this CPU attempts to acquire an rq lock held by a CPU spinning
+        * in perf_output_lock() from interrupt context, it's game over.
+        */
+       local_irq_save(flags);
 
        size  = task_event->event_id.header.size;
        ret = perf_output_begin(&handle, event, size, 0, 0);
 
-       if (ret)
+       if (ret) {
+               local_irq_restore(flags);
                return;
+       }
 
        task_event->event_id.pid = perf_event_pid(event, task);
        task_event->event_id.ppid = perf_event_pid(event, current);
@@ -3397,6 +3403,7 @@ static void perf_event_task_output(struct perf_event *event,
        perf_output_put(&handle, task_event->event_id);
 
        perf_output_end(&handle);
+       local_irq_restore(flags);
 }
 
 static int perf_event_task_match(struct perf_event *event)
index 79aac93acf99813d3abf89967089832cc272572c..a5aff94e1f0b49d30eb77ff056dd6712d5687e5e 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/syscalls.h>
 #include <linux/err.h>
 #include <linux/acct.h>
+#include <linux/slab.h>
 
 #define BITS_PER_PAGE          (PAGE_SIZE*8)
 
index 1a22dfd42df9b4089e9630f2635a425a26d4959b..bc7704b3a4431434e15bacb3127cfb9a5e1517a9 100644 (file)
@@ -1061,9 +1061,9 @@ static void check_thread_timers(struct task_struct *tsk,
        }
 }
 
-static void stop_process_timers(struct task_struct *tsk)
+static void stop_process_timers(struct signal_struct *sig)
 {
-       struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
+       struct thread_group_cputimer *cputimer = &sig->cputimer;
        unsigned long flags;
 
        if (!cputimer->running)
@@ -1072,6 +1072,10 @@ static void stop_process_timers(struct task_struct *tsk)
        spin_lock_irqsave(&cputimer->lock, flags);
        cputimer->running = 0;
        spin_unlock_irqrestore(&cputimer->lock, flags);
+
+       sig->cputime_expires.prof_exp = cputime_zero;
+       sig->cputime_expires.virt_exp = cputime_zero;
+       sig->cputime_expires.sched_exp = 0;
 }
 
 static u32 onecputick;
@@ -1133,7 +1137,7 @@ static void check_process_timers(struct task_struct *tsk,
            list_empty(&timers[CPUCLOCK_VIRT]) &&
            cputime_eq(sig->it[CPUCLOCK_VIRT].expires, cputime_zero) &&
            list_empty(&timers[CPUCLOCK_SCHED])) {
-               stop_process_timers(tsk);
+               stop_process_timers(sig);
                return;
        }
 
index da5288ec239286d9c2ae3f62b75a32ff3ed60f8b..aa9e916da4d53051eed6e7d12e9ddd37baaab3cd 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/console.h>
 #include <linux/cpu.h>
 #include <linux/freezer.h>
+#include <linux/gfp.h>
 #include <scsi/scsi_scan.h>
 #include <asm/suspend.h>
 
index 39ac698ef8361e43b769aa7b1b6256370b7018d3..fdcad9ed5a7b00bc0de3ca4a54b1cdd0b6759a1b 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/suspend.h>
 
 /*
index 5ade1bdcf366a9e93789097ea99ba8aba9dceccc..71ae29052ab6c2275c6f48239b56cdd4be4cba33 100644 (file)
@@ -88,12 +88,11 @@ static int try_to_freeze_tasks(bool sig_only)
                printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "
                                "(%d tasks refusing to freeze):\n",
                                elapsed_csecs / 100, elapsed_csecs % 100, todo);
-               show_state();
                read_lock(&tasklist_lock);
                do_each_thread(g, p) {
                        task_lock(p);
                        if (freezing(p) && !freezer_should_skip(p))
-                               printk(KERN_ERR " %s\n", p->comm);
+                               sched_show_task(p);
                        cancel_freezing(p);
                        task_unlock(p);
                } while_each_thread(g, p);
@@ -145,7 +144,7 @@ static void thaw_tasks(bool nosig_only)
                if (nosig_only && should_send_signal(p))
                        continue;
 
-               if (cgroup_frozen(p))
+               if (cgroup_freezing_or_frozen(p))
                        continue;
 
                thaw_process(p);
index 830cadecbdfcf2c9f7adedeca5cb6e1f169f8e87..be861c26dda7c70a35e775b5cb93756c7077754b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/console.h>
 #include <linux/highmem.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
index 44cce10b582dc06c4d0d326b95fe25631e49f251..56e7dbb8b996db295b4fc7cdf1b5f11a0409cb0c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/console.h>
 #include <linux/cpu.h>
 #include <linux/syscalls.h>
+#include <linux/gfp.h>
 
 #include "power.h"
 
index 1d575733d4e142f68ee3a43ea033ccb1882111c7..66824d71983a6f9cbf56c3e5c4ac77dc981070e8 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/pm.h>
+#include <linux/slab.h>
 
 #include "power.h"
 
index f1125c1a6321950030c42e8e5e2df2689d068a94..63fe25433980a943096634841d0ce5ff0ed33f7f 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/kernel_stat.h>
+#include <linux/hardirq.h>
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 static struct lock_class_key rcu_lock_key;
@@ -66,6 +67,28 @@ EXPORT_SYMBOL_GPL(rcu_sched_lock_map);
 int rcu_scheduler_active __read_mostly;
 EXPORT_SYMBOL_GPL(rcu_scheduler_active);
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+
+/**
+ * rcu_read_lock_bh_held - might we be in RCU-bh read-side critical section?
+ *
+ * Check for bottom half being disabled, which covers both the
+ * CONFIG_PROVE_RCU and not cases.  Note that if someone uses
+ * rcu_read_lock_bh(), but then later enables BH, lockdep (if enabled)
+ * will show the situation.
+ *
+ * Check debug_lockdep_rcu_enabled() to prevent false positives during boot.
+ */
+int rcu_read_lock_bh_held(void)
+{
+       if (!debug_lockdep_rcu_enabled())
+               return 1;
+       return in_softirq();
+}
+EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held);
+
+#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
+
 /*
  * This function is invoked towards the end of the scheduler's initialization
  * process.  Before this is called, the idle task might contain
index bcdabf37c40b58165d29a2e7dc33b41ef9a6d547..c7eaa37a768b785cf69cd2eb64ab3fb75c052124 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/types.h>
 #include <linux/parser.h>
 #include <linux/fs.h>
-#include <linux/slab.h>
 #include <linux/res_counter.h>
 #include <linux/uaccess.h>
 #include <linux/mm.h>
index 2d5be5d9bf5f2937fecaf881236cd48f13078fab..9c358e26353427b5a553e900014359c80c4eced2 100644 (file)
@@ -219,19 +219,34 @@ void release_child_resources(struct resource *r)
 }
 
 /**
- * request_resource - request and reserve an I/O or memory resource
+ * request_resource_conflict - request and reserve an I/O or memory resource
  * @root: root resource descriptor
  * @new: resource descriptor desired by caller
  *
- * Returns 0 for success, negative error code on error.
+ * Returns 0 for success, conflict resource on error.
  */
-int request_resource(struct resource *root, struct resource *new)
+struct resource *request_resource_conflict(struct resource *root, struct resource *new)
 {
        struct resource *conflict;
 
        write_lock(&resource_lock);
        conflict = __request_resource(root, new);
        write_unlock(&resource_lock);
+       return conflict;
+}
+
+/**
+ * request_resource - request and reserve an I/O or memory resource
+ * @root: root resource descriptor
+ * @new: resource descriptor desired by caller
+ *
+ * Returns 0 for success, negative error code on error.
+ */
+int request_resource(struct resource *root, struct resource *new)
+{
+       struct resource *conflict;
+
+       conflict = request_resource_conflict(root, new);
        return conflict ? -EBUSY : 0;
 }
 
@@ -474,25 +489,40 @@ static struct resource * __insert_resource(struct resource *parent, struct resou
 }
 
 /**
- * insert_resource - Inserts a resource in the resource tree
+ * insert_resource_conflict - Inserts resource in the resource tree
  * @parent: parent of the new resource
  * @new: new resource to insert
  *
- * Returns 0 on success, -EBUSY if the resource can't be inserted.
+ * Returns 0 on success, conflict resource if the resource can't be inserted.
  *
- * This function is equivalent to request_resource when no conflict
+ * This function is equivalent to request_resource_conflict when no conflict
  * happens. If a conflict happens, and the conflicting resources
  * entirely fit within the range of the new resource, then the new
  * resource is inserted and the conflicting resources become children of
  * the new resource.
  */
-int insert_resource(struct resource *parent, struct resource *new)
+struct resource *insert_resource_conflict(struct resource *parent, struct resource *new)
 {
        struct resource *conflict;
 
        write_lock(&resource_lock);
        conflict = __insert_resource(parent, new);
        write_unlock(&resource_lock);
+       return conflict;
+}
+
+/**
+ * insert_resource - Inserts a resource in the resource tree
+ * @parent: parent of the new resource
+ * @new: new resource to insert
+ *
+ * Returns 0 on success, -EBUSY if the resource can't be inserted.
+ */
+int insert_resource(struct resource *parent, struct resource *new)
+{
+       struct resource *conflict;
+
+       conflict = insert_resource_conflict(parent, new);
        return conflict ? -EBUSY : 0;
 }
 
index 9ab3cd7858d38001cc4ed0586bf187438e685cd7..a3dff1f3f9b0c32070d3ade21f3d2da63708d099 100644 (file)
@@ -71,6 +71,7 @@
 #include <linux/debugfs.h>
 #include <linux/ctype.h>
 #include <linux/ftrace.h>
+#include <linux/slab.h>
 
 #include <asm/tlb.h>
 #include <asm/irq_regs.h>
@@ -2650,7 +2651,7 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
 {
        unsigned long flags;
        struct rq *rq;
-       int cpu = get_cpu();
+       int cpu __maybe_unused = get_cpu();
 
 #ifdef CONFIG_SMP
        /*
@@ -4902,7 +4903,9 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
        int ret;
        cpumask_var_t mask;
 
-       if (len < cpumask_size())
+       if (len < nr_cpu_ids)
+               return -EINVAL;
+       if (len & (sizeof(unsigned long)-1))
                return -EINVAL;
 
        if (!alloc_cpumask_var(&mask, GFP_KERNEL))
@@ -4910,10 +4913,12 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 
        ret = sched_getaffinity(pid, mask);
        if (ret == 0) {
-               if (copy_to_user(user_mask_ptr, mask, cpumask_size()))
+               size_t retlen = min_t(size_t, len, cpumask_size());
+
+               if (copy_to_user(user_mask_ptr, mask, retlen))
                        ret = -EFAULT;
                else
-                       ret = cpumask_size();
+                       ret = retlen;
        }
        free_cpumask_var(mask);
 
@@ -5383,7 +5388,7 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
 
                get_task_struct(mt);
                task_rq_unlock(rq, &flags);
-               wake_up_process(rq->migration_thread);
+               wake_up_process(mt);
                put_task_struct(mt);
                wait_for_completion(&req.done);
                tlb_migrate_finish(p->mm);
index fccf9fbb0d7bc9bd6c2ca6dceadd8560d2dbc492..e6871cb3fc83dde1901b62c6355edc30ea55a64e 100644 (file)
@@ -27,6 +27,7 @@
  *  of the License.
  */
 
+#include <linux/gfp.h>
 #include "sched_cpupri.h"
 
 /* Convert between a 140 based task->prio, and our 102 based cpupri */
index 67f95aada4b95637b75432278b9d7391401a62d6..9b49db1440372bd6227e7e4258a0a6d78903e230 100644 (file)
@@ -518,8 +518,4 @@ void proc_sched_set_task(struct task_struct *p)
        p->se.nr_wakeups_idle                   = 0;
        p->sched_info.bkl_count                 = 0;
 #endif
-       p->se.sum_exec_runtime                  = 0;
-       p->se.prev_sum_exec_runtime             = 0;
-       p->nvcsw                                = 0;
-       p->nivcsw                               = 0;
 }
index 7494bbf5a27035fcd80cb7b9bf4814452e37e9a8..7d3f4fa9ef4f3b15eeee03b4ed3f3684819c8cf8 100644 (file)
@@ -637,7 +637,7 @@ int delayed_slow_work_enqueue(struct delayed_slow_work *dwork,
                        goto cancelled;
 
                /* the timer holds a reference whilst it is pending */
-               ret = work->ops->get_ref(work);
+               ret = slow_work_get_ref(work);
                if (ret < 0)
                        goto cant_get_ref;
 
index 321f3c59d7324f4100629b55111bb02b05c70161..a29ebd1ef41df7a4295e3173848e5239c05caa60 100644 (file)
@@ -43,28 +43,28 @@ extern void slow_work_new_thread_desc(struct slow_work *, struct seq_file *);
  */
 static inline void slow_work_set_thread_pid(int id, pid_t pid)
 {
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        slow_work_pids[id] = pid;
 #endif
 }
 
 static inline void slow_work_mark_time(struct slow_work *work)
 {
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        work->mark = CURRENT_TIME;
 #endif
 }
 
 static inline void slow_work_begin_exec(int id, struct slow_work *work)
 {
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        slow_work_execs[id] = work;
 #endif
 }
 
 static inline void slow_work_end_exec(int id, struct slow_work *work)
 {
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
        write_lock(&slow_work_execs_lock);
        slow_work_execs[id] = NULL;
        write_unlock(&slow_work_execs_lock);
index 9867b6bfefce7f1d20d342149984ca40e0dbd3ab..3fc697336183a79bffd175efdd98a7663ecf3691 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
 
index 0d4c7898ab805dd868880e7deca2d0d69d88fc67..4b493f67dcb562c183258115619539f3a68cd62a 100644 (file)
@@ -155,11 +155,11 @@ void softlockup_tick(void)
         * Wake up the high-prio watchdog task twice per
         * threshold timespan.
         */
-       if (now > touch_ts + softlockup_thresh/2)
+       if (time_after(now - softlockup_thresh/2, touch_ts))
                wake_up_process(per_cpu(softlockup_watchdog, this_cpu));
 
        /* Warn about unreasonable delays: */
-       if (now <= (touch_ts + softlockup_thresh))
+       if (time_before_eq(now - softlockup_thresh, touch_ts))
                return;
 
        per_cpu(softlockup_print_ts, this_cpu) = touch_ts;
index bde4295774c8f921f235fd4d2efebbd726132b38..2980da3fd50925f7902a5ba42e64934f6c4b0650 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/preempt.h>
 #include <linux/rcupdate.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/srcu.h>
 
index 8298878f4f7116ec8b04d6babbd016cfa2edb026..6d1a7e0f9d5be28bbfa9206c836fdee06672769a 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/personality.h>
 #include <linux/ptrace.h>
 #include <linux/fs_struct.h>
+#include <linux/gfp.h>
 
 #include <linux/compat.h>
 #include <linux/syscalls.h>
index 8cd50d8f9bde4c2d2ce403736aa33c9b769f35c9..59030570f5ca4970283d24aea52f4e06fa849b4f 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/file.h>
 #include <linux/ctype.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_SYSCTL_SYSCALL
 
index 899ca51be5e87849dee68145e59d86f4cc9077b7..11281d5792bd5b4d0eb7d5b86034ca4b2a4d256a 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delayacct.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
+#include <linux/slab.h>
 #include <linux/cgroupstats.h>
 #include <linux/cgroup.h>
 #include <linux/fs.h>
index 804798005d19846d449fcb5b2b81439135c6c62a..656dccfe1cbbc322ab44b0b398618297186bf118 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/syscalls.h>
 #include <linux/security.h>
 #include <linux/fs.h>
-#include <linux/slab.h>
 #include <linux/math64.h>
 #include <linux/ptrace.h>
 
index 0a8a213016f005bfc51632b22b668f037a75c3f2..aada0e52680ace6cc7d5e09a111a3879c1c6bda3 100644 (file)
 
 #include "tick-internal.h"
 
+/* Limit min_delta to a jiffie */
+#define MIN_DELTA_LIMIT                (NSEC_PER_SEC / HZ)
+
+static int tick_increase_min_delta(struct clock_event_device *dev)
+{
+       /* Nothing to do if we already reached the limit */
+       if (dev->min_delta_ns >= MIN_DELTA_LIMIT)
+               return -ETIME;
+
+       if (dev->min_delta_ns < 5000)
+               dev->min_delta_ns = 5000;
+       else
+               dev->min_delta_ns += dev->min_delta_ns >> 1;
+
+       if (dev->min_delta_ns > MIN_DELTA_LIMIT)
+               dev->min_delta_ns = MIN_DELTA_LIMIT;
+
+       printk(KERN_WARNING "CE: %s increased min_delta_ns to %llu nsec\n",
+              dev->name ? dev->name : "?",
+              (unsigned long long) dev->min_delta_ns);
+       return 0;
+}
+
 /**
  * tick_program_event internal worker function
  */
@@ -37,23 +60,28 @@ int tick_dev_program_event(struct clock_event_device *dev, ktime_t expires,
                if (!ret || !force)
                        return ret;
 
+               dev->retries++;
                /*
-                * We tried 2 times to program the device with the given
-                * min_delta_ns. If that's not working then we double it
+                * We tried 3 times to program the device with the given
+                * min_delta_ns. If that's not working then we increase it
                 * and emit a warning.
                 */
                if (++i > 2) {
                        /* Increase the min. delta and try again */
-                       if (!dev->min_delta_ns)
-                               dev->min_delta_ns = 5000;
-                       else
-                               dev->min_delta_ns += dev->min_delta_ns >> 1;
-
-                       printk(KERN_WARNING
-                              "CE: %s increasing min_delta_ns to %llu nsec\n",
-                              dev->name ? dev->name : "?",
-                              (unsigned long long) dev->min_delta_ns << 1);
-
+                       if (tick_increase_min_delta(dev)) {
+                               /*
+                                * Get out of the loop if min_delta_ns
+                                * hit the limit already. That's
+                                * better than staying here forever.
+                                *
+                                * We clear next_event so we have a
+                                * chance that the box survives.
+                                */
+                               printk(KERN_WARNING
+                                      "CE: Reprogramming failure. Giving up\n");
+                               dev->next_event.tv64 = KTIME_MAX;
+                               return -ETIME;
+                       }
                        i = 0;
                }
 
index 12f5c55090bea159652c299d0db1a0a2969a3424..ac38fbb176ccd0bb598b1eaaa7f2a703b17ec565 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/timecompare.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/math64.h>
 
 /*
index 16736379a9caaba6320f32f3df6e94cb5a9abbda..39f6177fafac110d342d2cedcd093b7a736bfdc8 100644 (file)
@@ -818,7 +818,8 @@ void update_wall_time(void)
        shift = min(shift, maxshift);
        while (offset >= timekeeper.cycle_interval) {
                offset = logarithmic_accumulation(offset, shift);
-               shift--;
+               if(offset < timekeeper.cycle_interval<<shift)
+                       shift--;
        }
 
        /* correct the clock when NTP error is too big */
index bdfb8dd1050cfb64f4cca35f22b749b06a294dd1..1a4a7dd787779345eafb02bc5781973cf68a1d6a 100644 (file)
@@ -228,6 +228,7 @@ print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu)
        SEQ_printf(m, " event_handler:  ");
        print_name_offset(m, dev->event_handler);
        SEQ_printf(m, "\n");
+       SEQ_printf(m, " retries:        %lu\n", dev->retries);
 }
 
 static void timer_list_show_tickdevices(struct seq_file *m)
@@ -257,7 +258,7 @@ static int timer_list_show(struct seq_file *m, void *v)
        u64 now = ktime_to_ns(ktime_get());
        int cpu;
 
-       SEQ_printf(m, "Timer List Version: v0.5\n");
+       SEQ_printf(m, "Timer List Version: v0.6\n");
        SEQ_printf(m, "HRTIMER_MAX_CLOCK_BASES: %d\n", HRTIMER_MAX_CLOCK_BASES);
        SEQ_printf(m, "now at %Ld nsecs\n", (unsigned long long)now);
 
index c61a7949387f93e69b1a4979eff1a03c7e7131b4..aeb6a54f2771691499ab474c3bf57d8e3e7d092f 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/kallsyms.h>
 #include <linux/perf_event.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -880,6 +881,7 @@ int try_to_del_timer_sync(struct timer_list *timer)
        if (base->running_timer == timer)
                goto out;
 
+       timer_stats_timer_clear_start_info(timer);
        ret = 0;
        if (timer_pending(timer)) {
                detach_timer(timer, 1);
index 07f945a99430bfe58fd1dde80365a7e6e663147d..b3bc91a3f510d089d7ce69ad4b294655dce53ac7 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/percpu.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <linux/smp_lock.h>
 #include <linux/time.h>
index d9062f5cc0c01e598670d651fba80b87ccb68a57..2404b59b3097e09f1db4c15a1a8cf5240dbe4c51 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
 #include <linux/sysctl.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/list.h>
 #include <linux/hash.h>
index 9f4f565b01e67e59bfd906f950ebea9f863252a6..a22582a061618cea52acee544d9e783ef1d9868e 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/workqueue.h>
 #include <linux/sched.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/power.h>
index 05a9f83b8819c39dcc03c76f737eaaf5ae7bbfe7..41ca394feb22f4e920cbbf711e201b8e1f5ee903 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/hash.h>
 #include <linux/list.h>
@@ -207,6 +208,14 @@ EXPORT_SYMBOL_GPL(tracing_is_on);
 #define RB_MAX_SMALL_DATA      (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
 #define RB_EVNT_MIN_SIZE       8U      /* two 32bit words */
 
+#if !defined(CONFIG_64BIT) || defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+# define RB_FORCE_8BYTE_ALIGNMENT      0
+# define RB_ARCH_ALIGNMENT             RB_ALIGNMENT
+#else
+# define RB_FORCE_8BYTE_ALIGNMENT      1
+# define RB_ARCH_ALIGNMENT             8U
+#endif
+
 /* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
 #define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX
 
@@ -1201,18 +1210,19 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
 
        for (i = 0; i < nr_pages; i++) {
                if (RB_WARN_ON(cpu_buffer, list_empty(cpu_buffer->pages)))
-                       return;
+                       goto out;
                p = cpu_buffer->pages->next;
                bpage = list_entry(p, struct buffer_page, list);
                list_del_init(&bpage->list);
                free_buffer_page(bpage);
        }
        if (RB_WARN_ON(cpu_buffer, list_empty(cpu_buffer->pages)))
-               return;
+               goto out;
 
        rb_reset_cpu(cpu_buffer);
        rb_check_pages(cpu_buffer);
 
+out:
        spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
@@ -1229,7 +1239,7 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
 
        for (i = 0; i < nr_pages; i++) {
                if (RB_WARN_ON(cpu_buffer, list_empty(pages)))
-                       return;
+                       goto out;
                p = pages->next;
                bpage = list_entry(p, struct buffer_page, list);
                list_del_init(&bpage->list);
@@ -1238,6 +1248,7 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
        rb_reset_cpu(cpu_buffer);
        rb_check_pages(cpu_buffer);
 
+out:
        spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
@@ -1547,7 +1558,7 @@ rb_update_event(struct ring_buffer_event *event,
 
        case 0:
                length -= RB_EVNT_HDR_SIZE;
-               if (length > RB_MAX_SMALL_DATA)
+               if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
                        event->array[0] = length;
                else
                        event->type_len = DIV_ROUND_UP(length, RB_ALIGNMENT);
@@ -1722,11 +1733,11 @@ static unsigned rb_calculate_event_length(unsigned length)
        if (!length)
                length = 1;
 
-       if (length > RB_MAX_SMALL_DATA)
+       if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT)
                length += sizeof(event.array[0]);
 
        length += RB_EVNT_HDR_SIZE;
-       length = ALIGN(length, RB_ALIGNMENT);
+       length = ALIGN(length, RB_ARCH_ALIGNMENT);
 
        return length;
 }
index 3ec2ee6f65602fde8cf701432a18b8c7b2fef11e..44f916a04065d9025f82e5e6228f11b0629df3dd 100644 (file)
 #include <linux/kdebug.h>
 #include <linux/string.h>
 #include <linux/rwsem.h>
+#include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/poll.h>
-#include <linux/gfp.h>
 #include <linux/fs.h>
 
 #include "trace.h"
index 6fbfb8f417b9cd9d60d72ff6b6a0c9c54c520ce1..9d589d8dcd1aa7e9470b6868980a20c4aeaf6160 100644 (file)
@@ -84,7 +84,7 @@ u64 notrace trace_clock_global(void)
        int this_cpu;
        u64 now;
 
-       raw_local_irq_save(flags);
+       local_irq_save(flags);
 
        this_cpu = raw_smp_processor_id();
        now = cpu_clock(this_cpu);
@@ -110,7 +110,7 @@ u64 notrace trace_clock_global(void)
        arch_spin_unlock(&trace_clock_struct.lock);
 
  out:
-       raw_local_irq_restore(flags);
+       local_irq_restore(flags);
 
        return now;
 }
index 81f691eb3a30a508706afa874415a6343042adfb..0565bb42566f6982d6d197857e0b7e07511ab8a7 100644 (file)
@@ -17,7 +17,12 @@ EXPORT_SYMBOL_GPL(perf_arch_fetch_caller_regs);
 static char *perf_trace_buf;
 static char *perf_trace_buf_nmi;
 
-typedef typeof(char [PERF_MAX_TRACE_SIZE]) perf_trace_t ;
+/*
+ * Force it to be aligned to unsigned long to avoid misaligned accesses
+ * suprises
+ */
+typedef typeof(unsigned long [PERF_MAX_TRACE_SIZE / sizeof(unsigned long)])
+       perf_trace_t;
 
 /* Count the events in use (per event id, not per instance) */
 static int     total_ref_count;
@@ -130,6 +135,8 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
        char *trace_buf, *raw_data;
        int pc, cpu;
 
+       BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
+
        pc = preempt_count();
 
        /* Protect the per cpu buffer, begin the rcu read side */
@@ -152,7 +159,7 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
        raw_data = per_cpu_ptr(trace_buf, cpu);
 
        /* zero the dead bytes from align to not leak stack to user */
-       *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+       memset(&raw_data[size - sizeof(u64)], 0, sizeof(u64));
 
        entry = (struct trace_entry *)raw_data;
        tracing_generic_entry_update(entry, *irq_flags, pc);
index beab8bf2f3108d06208c4d291cf8360e2a5e3c9f..c697c70433494d6e41e51656a767c9f575cdccba 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 
 #include <asm/setup.h>
index 4615f62a04f185bf5d38b89162ca223884954385..88c0b6dbd7fe3828b2742fb53bceda6367443f34 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/ctype.h>
 #include <linux/mutex.h>
 #include <linux/perf_event.h>
+#include <linux/slab.h>
 
 #include "trace.h"
 #include "trace_output.h"
index e6989d9b44dae8a23a60bcdb669f226329ef1025..9aed1a5cf553a720e1568de57cec3610ae88c415 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 
 #include "trace.h"
index 94103cdcf9d86aa5f48c1f50c46c4b4366aaf770..d59cd687947731c1c27de38947f3e0ee057e33f0 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/debugfs.h>
 #include <linux/ftrace.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 
 #include "trace_output.h"
index 0acd834659ed9f9306165d40b81d34a563604095..017fa376505d29a43fe1d69103047fe0365accb4 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/mmiotrace.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 
 #include <asm/atomic.h>
index 280fea470d67ea603f230d8bfc7868d5d48e62b2..81003b4d617fad5a966c2ed89fba1e5b47ddffdd 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/stringify.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 static inline int trace_valid_entry(struct trace_entry *entry)
 {
index a4bb239eb9874a1a6efe7703a303a7e103c4c977..96cffb269e7360e131e445c8c0013c90419f0921 100644 (file)
@@ -10,6 +10,7 @@
 
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/rbtree.h>
 #include <linux/debugfs.h>
 #include "trace_stat.h"
index 33c2a5b769dc45ea69f61ec79b865e5bf93fad93..4d6d711717f2958a9c502f0e53bbb8a89ee41ff7 100644 (file)
@@ -1,5 +1,6 @@
 #include <trace/syscall.h>
 #include <trace/events/syscalls.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
index 40cafb07dffd11e533b17ef5c7fcf6546aef00f5..cc2d2faa7d9e037734f1e4c11e87418c4a3a5400 100644 (file)
@@ -9,6 +9,7 @@
 #include <trace/events/workqueue.h>
 #include <linux/list.h>
 #include <linux/percpu.h>
+#include <linux/slab.h>
 #include <linux/kref.h>
 #include "trace_stat.h"
 #include "trace.h"
index 8e5ec5e1ab91f11505ac1a7589bb196ff10e1147..1fafb4b99c9bb30c37e151a2db441e3cc9c5fb5f 100644 (file)
@@ -103,7 +103,8 @@ config HEADERS_CHECK
 
 config DEBUG_SECTION_MISMATCH
        bool "Enable full Section mismatch analysis"
-       depends on UNDEFINED
+       depends on UNDEFINED || (BLACKFIN)
+       default y
        # This option is on purpose disabled for now.
        # It will be enabled when we are down to a reasonable number
        # of section mismatch warnings (< 10 for an allyesconfig build)
index 7bb4142a502f3a8ceb57fb9e24d24d8bfe81332d..05d6aca7fc1905defed315f2f14df86d231741b6 100644 (file)
@@ -1,3 +1,4 @@
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <linux/cpumask.h>
index 0f45fbff34cb970b68dd4642eb30b67d3857a31e..bc5b936e9142c51eb7c3be5bef8a2e2f7fa3e09b 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/module.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/init.h>
 #include <asm/atomic.h>
 #include "crc32defs.h"
index a9a8996d286a8e64f5ac23aec220b7645356cfac..b862b30369ffe5afa25c471263964d62321a2872 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <linux/hash.h>
 
 #define ODEBUG_HASH_BITS       14
index 72c8909006da156a41c4a70a1de2562198b45103..49368608f988872da20525722d1406ef3a94a520 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/pci.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
 
 void devm_ioremap_release(struct device *dev, void *res)
index f9350291598825a214068eb338e41f07edffb8c8..d6b8b9b1abfedf5ca023164b76d81ca06d0622a2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/uaccess.h>
 #include <linux/dynamic_debug.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 
 extern struct _ddebug __start___verbose[];
 extern struct _ddebug __stop___verbose[];
index e67f97495dd53c6a479f0a7a0ac3f2f68814f2e1..736c3b06398e522a7ad3d0ee846d77163436a334 100644 (file)
@@ -10,6 +10,7 @@
  * Version 2.  See the file COPYING for more details.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/bitmap.h>
 #include <linux/genalloc.h>
index d10255973a9fc8b79df675c684a6532da26694a8..677b738c220458827f2765525739021b9219770d 100644 (file)
       the two sets of lengths.
  */
 #include <linux/compiler.h>
+#include <linux/slab.h>
 
 #ifdef RCSID
 static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #";
index c5ff1fd1003025a64ce1ce25ef901c7185d2c6c5..9c4233b23783db47322abd1ff7235c764e0cb7f4 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <stdarg.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 
index c9d3a3e8405d884c80eeb6e15a7379f48fd333f6..7b48d44ced6ec2972fdd45cbc2c0d084dcf22f82 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/string.h>
 #include <linux/kobject.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/socket.h>
 #include <linux/skbuff.h>
index 9ecd6e86561034f2a097bcc027765704e124f7df..6d19f690380b8e3020b3a74e8fac3d2713055d0e 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kref.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 /**
  * kref_set - initialize object and set refcount to requested number.
index 6b9670d6bbf9e669c5e833514ccb41cb83f014da..0871582aa29de45fa8ff6f372cd8e8622c3fcc46 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/slab.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
-#include <linux/gfp.h>
 #include <linux/string.h>
 #include <linux/bitops.h>
 #include <linux/rcupdate.h>
index 0d475d8167bfd7f4f9909424ea29a72653b581fe..9afa25b52a83f33f0685d94306f1df4def372db4 100644 (file)
@@ -7,6 +7,7 @@
  * Version 2. See the file COPYING for more details.
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/highmem.h>
 
index 437eedb5a53ba1feae04f98b5def86798462f920..5fddf720da73e42b6568b80f64234e47033bc142 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/types.h>
 #include <linux/ctype.h>
 #include <linux/highmem.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
index 9fbcb44c554f9edbb2b2b439c20d5e18362cdc6d..d608331b3e4798c23607471dea52bbc483c69760 100644 (file)
 #include <linux/rcupdate.h>
 #include <linux/err.h>
 #include <linux/textsearch.h>
+#include <linux/slab.h>
 
 static LIST_HEAD(ts_ops);
 static DEFINE_SPINLOCK(ts_mod_lock);
index 7a68d2ab556093ab3398cbb95d8386c65357e07a..6c2a73a54a43c2bb6b412ebf7af56d622315a329 100644 (file)
@@ -33,7 +33,11 @@ obj-$(CONFIG_FAILSLAB) += failslab.o
 obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
 obj-$(CONFIG_FS_XIP) += filemap_xip.o
 obj-$(CONFIG_MIGRATION) += migrate.o
-obj-$(CONFIG_SMP) += percpu.o
+ifdef CONFIG_SMP
+obj-y += percpu.o
+else
+obj-y += percpu_up.o
+endif
 obj-$(CONFIG_QUICKLIST) += quicklist.o
 obj-$(CONFIG_CGROUP_MEM_RES_CTLR) += memcontrol.o page_cgroup.o
 obj-$(CONFIG_MEMORY_FAILURE) += memory-failure.o
index d7c791ef00367e27ac65f4a51da946abbd45d271..eff2242205711f0e46fb6c936c26ea36b69b6044 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/init.h>
 #include <linux/pfn.h>
+#include <linux/slab.h>
 #include <linux/bootmem.h>
 #include <linux/module.h>
 #include <linux/kmemleak.h>
@@ -180,19 +181,12 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
        end_aligned = end & ~(BITS_PER_LONG - 1);
 
        if (end_aligned <= start_aligned) {
-#if 1
-               printk(KERN_DEBUG " %lx - %lx\n", start, end);
-#endif
                for (i = start; i < end; i++)
                        __free_pages_bootmem(pfn_to_page(i), 0);
 
                return;
        }
 
-#if 1
-       printk(KERN_DEBUG " %lx %lx - %lx %lx\n",
-                start, start_aligned, end_aligned, end);
-#endif
        for (i = start; i < start_aligned; i++)
                __free_pages_bootmem(pfn_to_page(i), 0);
 
@@ -428,9 +422,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 {
 #ifdef CONFIG_NO_BOOTMEM
        free_early(physaddr, physaddr + size);
-#if 0
-       printk(KERN_DEBUG "free %lx %lx\n", physaddr, size);
-#endif
 #else
        unsigned long start, end;
 
@@ -456,9 +447,6 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
 {
 #ifdef CONFIG_NO_BOOTMEM
        free_early(addr, addr + size);
-#if 0
-       printk(KERN_DEBUG "free %lx %lx\n", addr, size);
-#endif
 #else
        unsigned long start, end;
 
index a2b76a588e348e0d46f2bfed4131af6ac3eea86b..13b6dad1eed272bec61a388d17f116be62cb1bb5 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/swap.h>
+#include <linux/gfp.h>
 #include <linux/bio.h>
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
index bb41f98dd8b700d7ecf1765aa7e76e6cbd6ad97a..c5f88f240ddcfc26a8cb2b2fadf66a3345102a5f 100644 (file)
@@ -1,5 +1,4 @@
 #include <linux/fault-inject.h>
-#include <linux/gfp.h>
 #include <linux/slab.h>
 
 static struct {
index 045b31c37653d133394146c8b49db671ea016591..140ebda9640f64a7f05b58a5d31156cb874a6eb9 100644 (file)
  * the NFS filesystem used to do this differently, for example)
  */
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/compiler.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
 #include <linux/aio.h>
 #include <linux/capability.h>
 #include <linux/kernel_stat.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/mman.h>
index 78b94f0b6d5dbd6e95ac1c5cb44937fc45d13e45..83364df74a33811ea7aea971412bfe91d4fe9c17 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/seqlock.h>
 #include <linux/mutex.h>
+#include <linux/gfp.h>
 #include <asm/tlbflush.h>
 #include <asm/io.h>
 
index 3a5aeb37c1107ed9735b2e0e943db3212bacaf3c..6034dc9e97967e122dff8987148b8897904ec2d5 100644 (file)
@@ -2,7 +2,6 @@
  * Generic hugetlb support.
  * (C) William Irwin, April 2004
  */
-#include <linux/gfp.h>
 #include <linux/list.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -18,6 +17,7 @@
 #include <linux/mutex.h>
 #include <linux/bootmem.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 
 #include <asm/page.h>
 #include <asm/pgtable.h>
index 5b069e4f5e485ac8f5906c4a0cad7dbdeef75f7e..2c0d032ac8983b8e59919019e07a97d9f25adad9 100644 (file)
@@ -72,7 +72,6 @@
 #include <linux/module.h>
 #include <linux/kthread.h>
 #include <linux/prio_tree.h>
-#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
index a93f1b7f508cde17cb0b41f7183641dcfdb7a26f..8cdfc2a1e8bffbdfed7e7d92842552e3ee41aa6f 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -751,7 +751,7 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
                 * page
                 */
                if (page_mapcount(page) + 1 + swapped != page_count(page)) {
-                       set_pte_at_notify(mm, addr, ptep, entry);
+                       set_pte_at(mm, addr, ptep, entry);
                        goto out_unlock;
                }
                entry = pte_wrprotect(entry);
index 7973b5221fb8e86b816c8e9667aff5f6c5fa7e21..9ed760dc74481a7436e3ab7b084ff8abd233ee01 100644 (file)
@@ -3691,8 +3691,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
        else
                mem = vmalloc(size);
 
-       if (mem)
-               memset(mem, 0, size);
+       if (!mem)
+               return NULL;
+
+       memset(mem, 0, size);
        mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
        if (!mem->stat) {
                if (size < PAGE_SIZE)
@@ -3946,28 +3948,6 @@ one_by_one:
        }
        return ret;
 }
-#else  /* !CONFIG_MMU */
-static int mem_cgroup_can_attach(struct cgroup_subsys *ss,
-                               struct cgroup *cgroup,
-                               struct task_struct *p,
-                               bool threadgroup)
-{
-       return 0;
-}
-static void mem_cgroup_cancel_attach(struct cgroup_subsys *ss,
-                               struct cgroup *cgroup,
-                               struct task_struct *p,
-                               bool threadgroup)
-{
-}
-static void mem_cgroup_move_task(struct cgroup_subsys *ss,
-                               struct cgroup *cont,
-                               struct cgroup *old_cont,
-                               struct task_struct *p,
-                               bool threadgroup)
-{
-}
-#endif
 
 /**
  * is_target_pte_for_mc - check a pte whether it is valid for move charge
@@ -4330,6 +4310,28 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
        }
        mem_cgroup_clear_mc();
 }
+#else  /* !CONFIG_MMU */
+static int mem_cgroup_can_attach(struct cgroup_subsys *ss,
+                               struct cgroup *cgroup,
+                               struct task_struct *p,
+                               bool threadgroup)
+{
+       return 0;
+}
+static void mem_cgroup_cancel_attach(struct cgroup_subsys *ss,
+                               struct cgroup *cgroup,
+                               struct task_struct *p,
+                               bool threadgroup)
+{
+}
+static void mem_cgroup_move_task(struct cgroup_subsys *ss,
+                               struct cgroup *cont,
+                               struct cgroup *old_cont,
+                               struct task_struct *p,
+                               bool threadgroup)
+{
+}
+#endif
 
 struct cgroup_subsys mem_cgroup_subsys = {
        .name = "memory",
index d1f3351629766ffe112e3f904565ed3035412774..620b0b461593afb124fc3174508b55993fe1f782 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/migrate.h>
 #include <linux/page-isolation.h>
 #include <linux/suspend.h>
+#include <linux/slab.h>
 #include "internal.h"
 
 int sysctl_memory_failure_early_kill __read_mostly = 0;
index 5b7f2002e54b17e8d9b67e75cff0aaa06c9296b4..1d2ea39260e530f4ed69e6638b1ce1e04b6091cd 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/kallsyms.h>
 #include <linux/swapops.h>
 #include <linux/elf.h>
+#include <linux/gfp.h>
 
 #include <asm/io.h>
 #include <asm/pgalloc.h>
@@ -130,6 +131,7 @@ void __sync_task_rss_stat(struct task_struct *task, struct mm_struct *mm)
 
        for (i = 0; i < NR_MM_COUNTERS; i++) {
                if (task->rss_stat.count[i]) {
+                       BUG_ON(!mm);
                        add_mm_counter(mm, i, task->rss_stat.count[i]);
                        task->rss_stat.count[i] = 0;
                }
index 643f66e101878015cbea8b3dc9ac1eb948d2d702..08f40a2f3fe0aef1819636d5983b3242758463e9 100644 (file)
@@ -73,7 +73,6 @@
 #include <linux/sched.h>
 #include <linux/nodemask.h>
 #include <linux/cpuset.h>
-#include <linux/gfp.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/module.h>
@@ -806,9 +805,13 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
 
        err = 0;
        if (nmask) {
-               task_lock(current);
-               get_policy_nodemask(pol, nmask);
-               task_unlock(current);
+               if (mpol_store_user_nodemask(pol)) {
+                       *nmask = pol->w.user_nodemask;
+               } else {
+                       task_lock(current);
+                       get_policy_nodemask(pol, nmask);
+                       task_unlock(current);
+               }
        }
 
  out:
@@ -2195,8 +2198,8 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
                        char *rest = nodelist;
                        while (isdigit(*rest))
                                rest++;
-                       if (!*rest)
-                               err = 0;
+                       if (*rest)
+                               goto out;
                }
                break;
        case MPOL_INTERLEAVE:
@@ -2205,7 +2208,6 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
                 */
                if (!nodelist)
                        nodes = node_states[N_HIGH_MEMORY];
-               err = 0;
                break;
        case MPOL_LOCAL:
                /*
@@ -2215,11 +2217,19 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
                        goto out;
                mode = MPOL_PREFERRED;
                break;
-
-       /*
-        * case MPOL_BIND:    mpol_new() enforces non-empty nodemask.
-        * case MPOL_DEFAULT: mpol_new() enforces empty nodemask, ignores flags.
-        */
+       case MPOL_DEFAULT:
+               /*
+                * Insist on a empty nodelist
+                */
+               if (!nodelist)
+                       err = 0;
+               goto out;
+       case MPOL_BIND:
+               /*
+                * Insist on a nodelist
+                */
+               if (!nodelist)
+                       goto out;
        }
 
        mode_flags = 0;
@@ -2233,13 +2243,14 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
                else if (!strcmp(flags, "relative"))
                        mode_flags |= MPOL_F_RELATIVE_NODES;
                else
-                       err = 1;
+                       goto out;
        }
 
        new = mpol_new(mode, mode_flags, &nodes);
        if (IS_ERR(new))
-               err = 1;
-       else {
+               goto out;
+
+       {
                int ret;
                NODEMASK_SCRATCH(scratch);
                if (scratch) {
@@ -2250,13 +2261,15 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
                        ret = -ENOMEM;
                NODEMASK_SCRATCH_FREE(scratch);
                if (ret) {
-                       err = 1;
                        mpol_put(new);
-               } else if (no_context) {
-                       /* save for contextualization */
-                       new->w.user_nodemask = nodes;
+                       goto out;
                }
        }
+       err = 0;
+       if (no_context) {
+               /* save for contextualization */
+               new->w.user_nodemask = nodes;
+       }
 
 out:
        /* Restore string for error message */
index 88000b89fc9a567768509926b7baf5dc44d2d7d7..d3f3f7f81075eb1eb2e7f5dbe2c0f292a489dacf 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/security.h>
 #include <linux/memcontrol.h>
 #include <linux/syscalls.h>
+#include <linux/gfp.h>
 
 #include "internal.h"
 
index 7a3436ef39eba1ace01efca158e93599aaea5bb7..f77433c20279d95c2a87ce7117888e63580c8922 100644 (file)
@@ -7,8 +7,8 @@
 /*
  * The mincore() system call.
  */
-#include <linux/slab.h>
 #include <linux/pagemap.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/syscalls.h>
index 0777654147c9d0e3fd0b676771dc5052bcab9455..9e82e937000e19f8210b10886457a3d82ee0870b 100644 (file)
@@ -53,6 +53,7 @@ void unuse_mm(struct mm_struct *mm)
        struct task_struct *tsk = current;
 
        task_lock(tsk);
+       sync_mm_rss(tsk, mm);
        tsk->mm = NULL;
        /* active_mm is still 'mm' */
        enter_lazy_tlb(mm, tsk);
index 7e33f2cb3c774ee960630032c4797c872f598ba8..438951d366f27cb449d7872f40ced3f791186f07 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/err.h>
 #include <linux/rcupdate.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 /*
  * This function can't run concurrently against mmu_notifier_register
index 8bc969d8112d28adb32b3754d339820739e2ba8c..2d1bf7cf885179af5144f41998d95dc2d2b72981 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
-#include <linux/slab.h>
 #include <linux/shm.h>
 #include <linux/mman.h>
 #include <linux/fs.h>
index e9c75efce60938a82821d24dedf0702ea5d0a50b..cde56ee51ef7a6b10e18f860bd7be08df07f2407 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
-#include <linux/slab.h>
 #include <linux/shm.h>
 #include <linux/ksm.h>
 #include <linux/mman.h>
index 605ace8982a8dcbc14ac061ab824166a16220180..63fa17d121f027ca5c75f09eab994db346316d2b 100644 (file)
@@ -146,7 +146,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                        (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
 
        for (i = 0; i < nr_pages; i++) {
-               vma = find_extend_vma(mm, start);
+               vma = find_vma(mm, start);
                if (!vma)
                        goto finish_or_fault;
 
@@ -162,7 +162,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                }
                if (vmas)
                        vmas[i] = vma;
-               start += PAGE_SIZE;
+               start = (start + PAGE_SIZE) & PAGE_MASK;
        }
 
        return i;
@@ -764,7 +764,7 @@ EXPORT_SYMBOL(find_vma);
  */
 struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
 {
-       return find_vma(mm, addr & PAGE_MASK);
+       return find_vma(mm, addr);
 }
 
 /*
@@ -1040,10 +1040,9 @@ static int do_mmap_shared_file(struct vm_area_struct *vma)
        if (ret != -ENOSYS)
                return ret;
 
-       /* getting an ENOSYS error indicates that direct mmap isn't
-        * possible (as opposed to tried but failed) so we'll fall
-        * through to making a private copy of the data and mapping
-        * that if we can */
+       /* getting -ENOSYS indicates that direct mmap isn't possible (as
+        * opposed to tried but failed) so we can only give a suitable error as
+        * it's not possible to make a private copy if MAP_SHARED was given */
        return -ENODEV;
 }
 
index 9b223af6a147f6fc82b22c58d1d878f09fb80053..b68e802a7a7d6961a0c1f7709a9cc606d022371c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/oom.h>
 #include <linux/mm.h>
 #include <linux/err.h>
+#include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/swap.h>
 #include <linux/timex.h>
index a19af956ee1bb6f55d87df3a3905a486820a49a7..31a3b962230a930cecab5d223f43d6d790f2610a 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/mm.h>
 #include <linux/kernel_stat.h>
+#include <linux/gfp.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/bio.h>
index 768419d44ad7b2b80e38b49927965b191a2f7704..6e09741ddc628bf53f4efc338fb4d2636b1b473e 100644 (file)
@@ -1303,6 +1303,32 @@ void free_percpu(void __percpu *ptr)
 }
 EXPORT_SYMBOL_GPL(free_percpu);
 
+/**
+ * is_kernel_percpu_address - test whether address is from static percpu area
+ * @addr: address to test
+ *
+ * Test whether @addr belongs to in-kernel static percpu area.  Module
+ * static percpu areas are not considered.  For those, use
+ * is_module_percpu_address().
+ *
+ * RETURNS:
+ * %true if @addr is from in-kernel static percpu area, %false otherwise.
+ */
+bool is_kernel_percpu_address(unsigned long addr)
+{
+       const size_t static_size = __per_cpu_end - __per_cpu_start;
+       void __percpu *base = __addr_to_pcpu_ptr(pcpu_base_addr);
+       unsigned int cpu;
+
+       for_each_possible_cpu(cpu) {
+               void *start = per_cpu_ptr(base, cpu);
+
+               if ((void *)addr >= start && (void *)addr < start + static_size)
+                       return true;
+        }
+       return false;
+}
+
 /**
  * per_cpu_ptr_to_phys - convert translated percpu address to physical address
  * @addr: the address to be converted to physical address
diff --git a/mm/percpu_up.c b/mm/percpu_up.c
new file mode 100644 (file)
index 0000000..c4351c7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * mm/percpu_up.c - dummy percpu memory allocator implementation for UP
+ */
+
+#include <linux/module.h>
+#include <linux/percpu.h>
+#include <linux/slab.h>
+
+void __percpu *__alloc_percpu(size_t size, size_t align)
+{
+       /*
+        * Can't easily make larger alignment work with kmalloc.  WARN
+        * on it.  Larger alignment should only be used for module
+        * percpu sections on SMP for which this path isn't used.
+        */
+       WARN_ON_ONCE(align > SMP_CACHE_BYTES);
+       return kzalloc(size, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(__alloc_percpu);
+
+void free_percpu(void __percpu *p)
+{
+       kfree(p);
+}
+EXPORT_SYMBOL_GPL(free_percpu);
+
+phys_addr_t per_cpu_ptr_to_phys(void *addr)
+{
+       return __pa(addr);
+}
index 6633965bb27bcb609be4578dcb8bcd30cd3e39c8..2876349339a7c275a940ea16c688885d13caa29d 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/kernel.h>
 
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/module.h>
index 337b20e946f6891ed9ae322d22c8e24a1b27f40e..999b54bb462f3ad24ec83b8997aec7c7780bc469 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
index fcd593c9c997153e78737fc9243d84499205590a..eaa7a09eb72e85b8f48911c8b3bf35e38d0e213c 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -232,6 +232,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
  out_error_free_anon_vma:
        anon_vma_free(anon_vma);
  out_error:
+       unlink_anon_vmas(vma);
        return -ENOMEM;
 }
 
index 392b9bb5bc015edfb1a2ce538a1cecbc39c3af94..aa33fd67fa412bee2cef32e18c163d626e88bd00 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
index 22896d5891330ea7d9756a8e5a28f25eefbd9a81..dc0cc4d43ff3ee37f36d70fbde28feef9d56d62e 100644 (file)
@@ -2,6 +2,7 @@
  * sparse memory mappings.
  */
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/mmzone.h>
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
index 9036b89813aca85fabc8df912760747d14b40ad5..7cd60bf0a972a2f8371774135eb204b7692821cf 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -30,6 +30,7 @@
 #include <linux/notifier.h>
 #include <linux/backing-dev.h>
 #include <linux/memcontrol.h>
+#include <linux/gfp.h>
 
 #include "internal.h"
 
index 6d1daeb1cb4a3dfbcf522919312a67f861085b74..e10f5833167f6d5b564a534484985dc3c7dee745 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include <linux/kernel_stat.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
index e87e37244829ce03abc22673cda7eeb37f6fff0a..f42675a3615d81ab59e722cc3e3d18b1e1e0525f 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/backing-dev.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/module.h>
index 79c809895fba777d6069ae3778046def74a29b81..e0e5f15bb726c921d40b22258c310f8247c6212a 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <linux/mm.h>
 #include <linux/module.h>
-#include <linux/slab.h>
+#include <linux/gfp.h>
 #include <linux/kernel_stat.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
index 7f760cbc73f35a7b49944fe86f046e5269850b31..fa12ea3051fb109c18f66ee41da49fd2f7ff4fdb 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mm.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/cpu.h>
 #include <linux/vmstat.h>
 #include <linux/sched.h>
index 1dcb0660c49dea6bc2b7ec7402eed68629d2e896..9ed7c0e7dc1759972f6c323085a0f10f1d38d31d 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/etherdevice.h>
 #include <linux/rtnetlink.h>
 #include <linux/llc.h>
+#include <linux/slab.h>
 #include <net/llc.h>
 #include <net/llc_pdu.h>
 #include <net/garp.h>
index 2530f35241cde096a08a748790d74b75f8b22884..7f353c4f437ac1bcf0f3ec3646a134fc6e425038 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/datalink.h>
 #include <linux/mm.h>
 #include <linux/in.h>
index 6ab1835041a7485f1d4e23cadb7e3b35f6fcc631..1256a40da43cbcb9ff45a748b7945a016ac0ff95 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/datalink.h>
 #include <net/p8022.h>
index 6fea0750662b847d048587e423618b8e4fa8b8b8..21cde8fd5795310a823367783cc3f4cd9eb92d0c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/datalink.h>
 #include <net/llc.h>
 #include <net/psnap.h>
index 0b7a24452d111accb3da25c95806025a32a07f61..53c8f77f0ccd1025a7061568b551a1d9631c0dd1 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/skbuff.h>
 #include <linux/etherdevice.h>
 #include <linux/llc.h>
+#include <linux/slab.h>
 #include <net/llc.h>
 #include <net/llc_pdu.h>
 #include <net/stp.h>
index 44acce47fcdc9a581deb37942c9a89fefecd48c3..1c6e596074dff99fe4571ff4df1d40c081186f01 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/seq_file.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/net_namespace.h>
 
index 453512266ea1dd783dbc68f5e6b511dd64ec5ac5..97da977c2a23338e57fb8b8a11db3f2a4d47965d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rculist.h>
 #include <net/p8022.h>
@@ -378,6 +379,8 @@ static void vlan_transfer_features(struct net_device *dev,
 #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
        vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
 #endif
+       vlandev->real_num_tx_queues = dev->real_num_tx_queues;
+       BUG_ON(vlandev->real_num_tx_queues > vlandev->num_tx_queues);
 
        if (old_features != vlandev->features)
                netdev_features_change(vlandev);
index c0316e0ca6e854724ccb6dc07e1441dd697e7277..c584a0af77d3efaf436a1cc07413fcfa31f442e1 100644 (file)
@@ -11,7 +11,7 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
        if (netpoll_rx(skb))
                return NET_RX_DROP;
 
-       if (skb_bond_should_drop(skb))
+       if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
                goto drop;
 
        skb->skb_iif = skb->dev->ifindex;
@@ -83,7 +83,7 @@ vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
 {
        struct sk_buff *p;
 
-       if (skb_bond_should_drop(skb))
+       if (skb_bond_should_drop(skb, ACCESS_ONCE(skb->dev->master)))
                goto drop;
 
        skb->skb_iif = skb->dev->ifindex;
index 9e83272fc5b022e6a4b765888f06647ce0d92f67..29b6348c8d4d6f280c3e349a6518c6b5ce3d75c1 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -361,6 +362,14 @@ static netdev_tx_t vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
        return ret;
 }
 
+static u16 vlan_dev_select_queue(struct net_device *dev, struct sk_buff *skb)
+{
+       struct net_device *rdev = vlan_dev_info(dev)->real_dev;
+       const struct net_device_ops *ops = rdev->netdev_ops;
+
+       return ops->ndo_select_queue(rdev, skb);
+}
+
 static int vlan_dev_change_mtu(struct net_device *dev, int new_mtu)
 {
        /* TODO: gotta make sure the underlying layer can handle it,
@@ -688,7 +697,8 @@ static const struct header_ops vlan_header_ops = {
        .parse   = eth_header_parse,
 };
 
-static const struct net_device_ops vlan_netdev_ops, vlan_netdev_accel_ops;
+static const struct net_device_ops vlan_netdev_ops, vlan_netdev_accel_ops,
+                   vlan_netdev_ops_sq, vlan_netdev_accel_ops_sq;
 
 static int vlan_dev_init(struct net_device *dev)
 {
@@ -722,11 +732,17 @@ static int vlan_dev_init(struct net_device *dev)
        if (real_dev->features & NETIF_F_HW_VLAN_TX) {
                dev->header_ops      = real_dev->header_ops;
                dev->hard_header_len = real_dev->hard_header_len;
-               dev->netdev_ops         = &vlan_netdev_accel_ops;
+               if (real_dev->netdev_ops->ndo_select_queue)
+                       dev->netdev_ops = &vlan_netdev_accel_ops_sq;
+               else
+                       dev->netdev_ops = &vlan_netdev_accel_ops;
        } else {
                dev->header_ops      = &vlan_header_ops;
                dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
-               dev->netdev_ops         = &vlan_netdev_ops;
+               if (real_dev->netdev_ops->ndo_select_queue)
+                       dev->netdev_ops = &vlan_netdev_ops_sq;
+               else
+                       dev->netdev_ops = &vlan_netdev_ops;
        }
 
        if (is_vlan_dev(real_dev))
@@ -865,6 +881,56 @@ static const struct net_device_ops vlan_netdev_accel_ops = {
 #endif
 };
 
+static const struct net_device_ops vlan_netdev_ops_sq = {
+       .ndo_select_queue       = vlan_dev_select_queue,
+       .ndo_change_mtu         = vlan_dev_change_mtu,
+       .ndo_init               = vlan_dev_init,
+       .ndo_uninit             = vlan_dev_uninit,
+       .ndo_open               = vlan_dev_open,
+       .ndo_stop               = vlan_dev_stop,
+       .ndo_start_xmit =  vlan_dev_hard_start_xmit,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = vlan_dev_set_mac_address,
+       .ndo_set_rx_mode        = vlan_dev_set_rx_mode,
+       .ndo_set_multicast_list = vlan_dev_set_rx_mode,
+       .ndo_change_rx_flags    = vlan_dev_change_rx_flags,
+       .ndo_do_ioctl           = vlan_dev_ioctl,
+       .ndo_neigh_setup        = vlan_dev_neigh_setup,
+       .ndo_get_stats          = vlan_dev_get_stats,
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+       .ndo_fcoe_ddp_setup     = vlan_dev_fcoe_ddp_setup,
+       .ndo_fcoe_ddp_done      = vlan_dev_fcoe_ddp_done,
+       .ndo_fcoe_enable        = vlan_dev_fcoe_enable,
+       .ndo_fcoe_disable       = vlan_dev_fcoe_disable,
+       .ndo_fcoe_get_wwn       = vlan_dev_fcoe_get_wwn,
+#endif
+};
+
+static const struct net_device_ops vlan_netdev_accel_ops_sq = {
+       .ndo_select_queue       = vlan_dev_select_queue,
+       .ndo_change_mtu         = vlan_dev_change_mtu,
+       .ndo_init               = vlan_dev_init,
+       .ndo_uninit             = vlan_dev_uninit,
+       .ndo_open               = vlan_dev_open,
+       .ndo_stop               = vlan_dev_stop,
+       .ndo_start_xmit =  vlan_dev_hwaccel_hard_start_xmit,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = vlan_dev_set_mac_address,
+       .ndo_set_rx_mode        = vlan_dev_set_rx_mode,
+       .ndo_set_multicast_list = vlan_dev_set_rx_mode,
+       .ndo_change_rx_flags    = vlan_dev_change_rx_flags,
+       .ndo_do_ioctl           = vlan_dev_ioctl,
+       .ndo_neigh_setup        = vlan_dev_neigh_setup,
+       .ndo_get_stats          = vlan_dev_get_stats,
+#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
+       .ndo_fcoe_ddp_setup     = vlan_dev_fcoe_ddp_setup,
+       .ndo_fcoe_ddp_done      = vlan_dev_fcoe_ddp_done,
+       .ndo_fcoe_enable        = vlan_dev_fcoe_enable,
+       .ndo_fcoe_disable       = vlan_dev_fcoe_disable,
+       .ndo_fcoe_get_wwn       = vlan_dev_fcoe_get_wwn,
+#endif
+};
+
 void vlan_setup(struct net_device *dev)
 {
        ether_setup(dev);
index e3e5bf4469ced27351e467b9d3bde3b11291c894..0aa79faa98509a1d91f71cec5c307f3522c2a58d 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/poll.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
 #include <net/9p/9p.h>
@@ -71,9 +72,10 @@ inline int p9_is_proto_dotu(struct p9_client *clnt)
 EXPORT_SYMBOL(p9_is_proto_dotu);
 
 /* Interpret mount option for protocol version */
-static unsigned char get_protocol_version(const substring_t *name)
+static int get_protocol_version(const substring_t *name)
 {
-       unsigned char version = -EINVAL;
+       int version = -EINVAL;
+
        if (!strncmp("9p2000", name->from, name->to-name->from)) {
                version = p9_proto_legacy;
                P9_DPRINTK(P9_DEBUG_9P, "Protocol version: Legacy\n");
@@ -533,7 +535,12 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
 
        P9_DPRINTK(P9_DEBUG_MUX, "client %p op %d\n", c, type);
 
-       if (c->status != Connected)
+       /* we allow for any status other than disconnected */
+       if (c->status == Disconnected)
+               return ERR_PTR(-EIO);
+
+       /* if status is begin_disconnected we allow only clunk request */
+       if ((c->status == BeginDisconnect) && (type != P9_TCLUNK))
                return ERR_PTR(-EIO);
 
        if (signal_pending(current)) {
@@ -799,8 +806,10 @@ void p9_client_destroy(struct p9_client *clnt)
 
        v9fs_put_trans(clnt->trans_mod);
 
-       list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist)
+       list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) {
+               printk(KERN_INFO "Found fid %d not clunked\n", fid->fid);
                p9_fid_destroy(fid);
+       }
 
        if (clnt->fidpool)
                p9_idpool_destroy(clnt->fidpool);
@@ -818,6 +827,13 @@ void p9_client_disconnect(struct p9_client *clnt)
 }
 EXPORT_SYMBOL(p9_client_disconnect);
 
+void p9_client_begin_disconnect(struct p9_client *clnt)
+{
+       P9_DPRINTK(P9_DEBUG_9P, "clnt %p\n", clnt);
+       clnt->status = BeginDisconnect;
+}
+EXPORT_SYMBOL(p9_client_begin_disconnect);
+
 struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
        char *uname, u32 n_uname, char *aname)
 {
index 94f5a8f65e9c3649c8417a62c0c87b1e1ef708cd..e7541d5b011831e6c945d9cfb9163c90f9b1d1fd 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <net/9p/9p.h>
index 31d0b05582a970e9c35b5e01e7d90d36ac25fd6b..98ce9bcb0e15da4443ce08cd654576c2b235b69f 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/idr.h>
 #include <linux/file.h>
 #include <linux/parser.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 #include <net/9p/transport.h>
index 2c95a89c0f46464e379bb15ca79622149e9f051e..041101ab4aa55b6ceec057e40c007ae57ff409ba 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/file.h>
 #include <linux/parser.h>
 #include <linux/semaphore.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 #include <net/9p/transport.h>
index afde1a89fbb328d1dbda695c6824e205c7997e1a..7eb78ecc16181cb6d6fc697ac50812882d0c9c8d 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/inet.h>
 #include <linux/idr.h>
 #include <linux/file.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <linux/parser.h>
 #include <net/9p/client.h>
index dc4ec05ad93d5324b3a7d6b81c63ae1c7815af39..e048701a72d230821f6e23eeddd89f5a14fc2f9b 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/parser.h>
 #include <linux/idr.h>
+#include <linux/slab.h>
 #include <net/9p/9p.h>
 
 /**
index f2b3b56aa779305623fc4c919bae37a7a24c0b41..50dce7981321709e5aa095c233234ca83e69d034 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/datalink.h>
 #include <net/psnap.h>
index 9fc4da56fb1dbcc8cfca2e0714059355e0630c92..7b02967fbbe7dcf0a2138059b44967c4f0cc9375 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/smp_lock.h>
 #include <linux/termios.h>     /* For TIOCOUTQ/INQ */
 #include <linux/compat.h>
+#include <linux/slab.h>
 #include <net/datalink.h>
 #include <net/psnap.h>
 #include <net/sock.h>
index cf3ae8b475728df8668ce90ce14f5622e65c2388..dcda35c66f152015d99e916e4c869637c2ecd08a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/atm.h>
 #include <linux/atmdev.h>
+#include <linux/slab.h>
 #include <linux/uaccess.h>
 
 #include "signaling.h"
index f693b78eb4678d79b8a4f4786a4fffba47461ade..799c631f0fed0c1e8210d2d61e3fdf3afd27aea9 100644 (file)
@@ -1,6 +1,7 @@
 /* ATM driver model support. */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kobject.h>
 #include <linux/atmdev.h>
index 4d64d87e7578a26aa6bd89bfa425dea14fb13f77..d6c7ceaf13e969171eb96fb54e5a7ea2ed03844e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/ip.h>
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <linux/atm.h>
 #include <linux/atmdev.h>
index ebfa022008f79aff20202c2c13ae0b04ee117d81..313aba11316b5764e759fa7356f5f8286d69ceb5 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/seq_file.h>
 #include <linux/rcupdate.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 #include <net/route.h> /* for struct rtable and routing */
 #include <net/icmp.h> /* icmp_send */
 #include <linux/param.h> /* for HZ */
index 74d095a081e3ed0a667ab6805b2c361d51cf81d3..97ed94aa0cbceb3623b91e918fd886f353793aab 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/sock.h>          /* struct sock */
 #include <linux/uaccess.h>
 #include <linux/poll.h>
index 5da5753157f9d8da1799e93649e52e9f258d85dd..feeaf5718472ec076bfd01c866f04f0e9e3b83ea 100644 (file)
@@ -6,6 +6,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <linux/capability.h>
index a6521c8aa88b58b9ceedb410d5807cdff1cd9127..436f2e177657e7b184c7afe5c467f97cbcc420cd 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
index 4c141810eb6dc210935f9c12cba875e0912f318d..e773d8336918b021eeeea82e409fba657f564ab1 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/types.h>
 #include <linux/atmmpc.h>
+#include <linux/slab.h>
 #include <linux/time.h>
 
 #include "mpoa_caches.h"
index b9bdb98427e4475151685c016c395f92bfd66240..53e500292271803ade21c6f0bfac00dcce7ab3ac 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/uaccess.h>
 #include <linux/atmmpc.h>
 #include <linux/atm.h>
+#include <linux/gfp.h>
 #include "mpc.h"
 #include "mpoa_caches.h"
 
index 400839273c67503e6fa4207c2d2949a5f99e351f..e49bb6d948a1b1ec1a195f9952a2f0063640c7ce 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/atm.h>
 #include <linux/atmdev.h>
 #include <linux/capability.h>
index 7a96b2376bd7223ad951e66a4ad441fccbb32d0d..696e218436e5ec3de66b9bb63e06d70c31ab427d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/netdevice.h>
 #include <linux/atmclip.h>
 #include <linux/init.h> /* for __init */
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/atmclip.h>
 #include <linux/uaccess.h>
index d0c4bd047dc453990d45cead53fcdbb57b27fc25..b4f7b9ff3c741880e1f587f8f27a939ab62c25dd 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 
 #include "common.h"
 #include "protocols.h"
index 90082904f20d55df42fc83903f569d08db3e6e93..d29e582615116a68e1f476091c6475d589401878 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/capability.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>   /* for struct sock */
 
index ad1d28ae512bcfc66a89f693c4e855ad0580783f..6ba6e466ee545af605264c45eea340cb9b27e1cd 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/atmsvc.h>
 #include <linux/atmdev.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #include "resources.h"
 #include "signaling.h"
index a5beedf43e2df8738f9f3ce35fb00636ca2f471a..65c5801261f949b206d242e65f0c36ff7265cb54 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index a7a0e0c9698b0c59de7b553fdda73e947864a027..c1cb982f6e86954018c7311d17016cb2189f9bf1 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
index b5e59787be2f145084dfe15a6189e2f0923222b2..85816e612dc0a83cd76b56a5d81448d90cd28b20 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/sockios.h>
 #include <linux/spinlock.h>
 #include <linux/net.h>
+#include <linux/gfp.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 71338f112108a06ee9b3734d19c7146c54fea7a9..5a0dda8df492424b4e0c24255a625373b5cacf09 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index de56d3983de098b11d64f8971d85b8ded8187bf2..9bb7765412036dc19001ea412c346e12990148c3 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index f047a57aa95c151be44c41a92d9e834a8c35cfb5..cf0c47a265304bc94cc391c7c92a10be16de14ed 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 14912600ec57e6e961ee7de20dc2eebbb9a4013c..37507d806f65f64d6b1740dc055fea80845ff644 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/sockios.h>
 #include <linux/spinlock.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index c833ba4c45a585514eee55835c5ce61880594c6d..7805945a5fd6d311f54f26a66dc5ad9c0e83ece1 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 034aa10a5198bd6dd88ba9eb431f9f3088600d98..c6715ee4ab8f6099e25a58421998127df1a96dda 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 9f13f6eefcba68cdf779121b9749b66044c26b41..d349be9578f5bce47be0d42243ca1c7ea34dbcdb 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/sockios.h>
 #include <linux/net.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 5159be6b2625a91894a1c388e1cae3e1ade7e725..ebe0ef3f1d839c1715dcf3784e8d9148b62820e2 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
  */
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/spinlock.h>
 #include <net/ax25.h>
index 087cc51f592733fba6557d5456801dc75a6b69a0..404a8500fd031b254b0049a6c97b8ff6f7805675 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/poll.h>
index ef09c7b3a8585451a9a1f1ec4ec29b5650988019..8062dad6d10d0c83afd345d1f4c0ea8532d41b9a 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/freezer.h>
 #include <linux/errno.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #include <linux/socket.h>
index b6234b73c4cfb6fc5a752917baf75f0f1c53f883..5643a2391e76979e6de26e589debb2580555612f 100644 (file)
@@ -26,6 +26,7 @@
 */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/socket.h>
 #include <linux/netdevice.h>
index 2ff6ac7b2ed494b8ffcac277d0e067b92d408734..2862f53b66b15b8b680322b32c5196f502adc7f0 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/fcntl.h>
 #include <linux/skbuff.h>
@@ -39,6 +38,7 @@
 #include <linux/file.h>
 #include <linux/init.h>
 #include <linux/compat.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 
 #include <asm/system.h>
index 978cc3a718ad1726de639fd93762b5d926a1592f..7ea1979a8e4f1aab1ef895eb61ffc06cab848536 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/fcntl.h>
 #include <linux/skbuff.h>
@@ -34,6 +33,7 @@
 #include <linux/ioctl.h>
 #include <linux/file.h>
 #include <linux/compat.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 
 #include <linux/isdn/capilli.h>
index cafb55b0cea5ca290f0a2ac4fc5e73eac200ba5e..0e8e1a59856c40ffe5b1cde05d6bd6321febc24a 100644 (file)
@@ -1,6 +1,7 @@
 /* Bluetooth HCI driver model support. */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
@@ -8,8 +9,7 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
-struct class *bt_class = NULL;
-EXPORT_SYMBOL_GPL(bt_class);
+static struct class *bt_class;
 
 struct dentry *bt_debugfs = NULL;
 EXPORT_SYMBOL_GPL(bt_debugfs);
index 9cfef68b9feceaacf6165faafcc120fe99c9bfa1..250dfd46237d284a0c587ad7e3da35e9dcb81f80 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/fcntl.h>
 #include <linux/skbuff.h>
@@ -35,6 +34,7 @@
 #include <linux/file.h>
 #include <linux/init.h>
 #include <linux/compat.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 
 #include "hidp.h"
index 4db7ae2fe07dea0fcc12d142f072b8ebef5c6a58..99d68c34e4f11d4de5e2b7822f07b0384798eb78 100644 (file)
@@ -40,6 +40,8 @@
 #include <linux/skbuff.h>
 #include <linux/list.h>
 #include <linux/device.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/uaccess.h>
 #include <linux/crc16.h>
 #include <net/sock.h>
@@ -1000,7 +1002,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
 
        BT_DBG("sk %p", sk);
 
-       if (!addr || addr->sa_family != AF_BLUETOOTH)
+       if (!addr || alen < sizeof(addr->sa_family) ||
+           addr->sa_family != AF_BLUETOOTH)
                return -EINVAL;
 
        memset(&la, 0, sizeof(la));
@@ -2830,6 +2833,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
                        int len = cmd->len - sizeof(*rsp);
                        char req[64];
 
+                       if (len > sizeof(req) - sizeof(struct l2cap_conf_req)) {
+                               l2cap_send_disconn_req(conn, sk);
+                               goto done;
+                       }
+
                        /* throw out any old stored conf requests */
                        result = L2CAP_CONF_SUCCESS;
                        len = l2cap_parse_conf_rsp(sk, rsp->data,
@@ -3937,31 +3945,42 @@ drop:
        return 0;
 }
 
-static ssize_t l2cap_sysfs_show(struct class *dev,
-                               struct class_attribute *attr,
-                               char *buf)
+static int l2cap_debugfs_show(struct seq_file *f, void *p)
 {
        struct sock *sk;
        struct hlist_node *node;
-       char *str = buf;
 
        read_lock_bh(&l2cap_sk_list.lock);
 
        sk_for_each(sk, node, &l2cap_sk_list.head) {
                struct l2cap_pinfo *pi = l2cap_pi(sk);
 
-               str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
-                               batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
-                               sk->sk_state, __le16_to_cpu(pi->psm), pi->scid,
-                               pi->dcid, pi->imtu, pi->omtu, pi->sec_level);
+               seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
+                                       batostr(&bt_sk(sk)->src),
+                                       batostr(&bt_sk(sk)->dst),
+                                       sk->sk_state, __le16_to_cpu(pi->psm),
+                                       pi->scid, pi->dcid,
+                                       pi->imtu, pi->omtu, pi->sec_level);
        }
 
        read_unlock_bh(&l2cap_sk_list.lock);
 
-       return str - buf;
+       return 0;
+}
+
+static int l2cap_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, l2cap_debugfs_show, inode->i_private);
 }
 
-static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
+static const struct file_operations l2cap_debugfs_fops = {
+       .open           = l2cap_debugfs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static struct dentry *l2cap_debugfs;
 
 static const struct proto_ops l2cap_sock_ops = {
        .family         = PF_BLUETOOTH,
@@ -4021,8 +4040,12 @@ static int __init l2cap_init(void)
                goto error;
        }
 
-       if (class_create_file(bt_class, &class_attr_l2cap) < 0)
-               BT_ERR("Failed to create L2CAP info file");
+       if (bt_debugfs) {
+               l2cap_debugfs = debugfs_create_file("l2cap", 0444,
+                                       bt_debugfs, NULL, &l2cap_debugfs_fops);
+               if (!l2cap_debugfs)
+                       BT_ERR("Failed to create L2CAP debug file");
+       }
 
        BT_INFO("L2CAP ver %s", VERSION);
        BT_INFO("L2CAP socket layer initialized");
@@ -4036,7 +4059,7 @@ error:
 
 static void __exit l2cap_exit(void)
 {
-       class_remove_file(bt_class, &class_attr_l2cap);
+       debugfs_remove(l2cap_debugfs);
 
        if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
                BT_ERR("L2CAP socket unregistration failed");
index db8a68e1a5ba835c11eff1f4d1f0525642e9ab41..7dca91bb8c576397e571994655efbe9d1832d7b6 100644 (file)
 #include <linux/init.h>
 #include <linux/wait.h>
 #include <linux/device.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/net.h>
 #include <linux/mutex.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <asm/uaccess.h>
@@ -2098,13 +2101,10 @@ static struct hci_cb rfcomm_cb = {
        .security_cfm   = rfcomm_security_cfm
 };
 
-static ssize_t rfcomm_dlc_sysfs_show(struct class *dev,
-                                    struct class_attribute *attr,
-                                    char *buf)
+static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
 {
        struct rfcomm_session *s;
        struct list_head *pp, *p;
-       char *str = buf;
 
        rfcomm_lock();
 
@@ -2114,18 +2114,32 @@ static ssize_t rfcomm_dlc_sysfs_show(struct class *dev,
                        struct sock *sk = s->sock->sk;
                        struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
 
-                       str += sprintf(str, "%s %s %ld %d %d %d %d\n",
-                                       batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
-                                       d->state, d->dlci, d->mtu, d->rx_credits, d->tx_credits);
+                       seq_printf(f, "%s %s %ld %d %d %d %d\n",
+                                               batostr(&bt_sk(sk)->src),
+                                               batostr(&bt_sk(sk)->dst),
+                                               d->state, d->dlci, d->mtu,
+                                               d->rx_credits, d->tx_credits);
                }
        }
 
        rfcomm_unlock();
 
-       return (str - buf);
+       return 0;
 }
 
-static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL);
+static int rfcomm_dlc_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, rfcomm_dlc_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations rfcomm_dlc_debugfs_fops = {
+       .open           = rfcomm_dlc_debugfs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static struct dentry *rfcomm_dlc_debugfs;
 
 /* ---- Initialization ---- */
 static int __init rfcomm_init(void)
@@ -2142,8 +2156,12 @@ static int __init rfcomm_init(void)
                goto unregister;
        }
 
-       if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0)
-               BT_ERR("Failed to create RFCOMM info file");
+       if (bt_debugfs) {
+               rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
+                               bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
+               if (!rfcomm_dlc_debugfs)
+                       BT_ERR("Failed to create RFCOMM debug file");
+       }
 
        err = rfcomm_init_ttys();
        if (err < 0)
@@ -2171,7 +2189,7 @@ unregister:
 
 static void __exit rfcomm_exit(void)
 {
-       class_remove_file(bt_class, &class_attr_rfcomm_dlc);
+       debugfs_remove(rfcomm_dlc_debugfs);
 
        hci_unregister_cb(&rfcomm_cb);
 
index ca87d6ac6a2036dd7030c334c133e4326edcda62..8ed3c37684fa345326366239d719a1b1a100458b 100644 (file)
@@ -40,6 +40,8 @@
 #include <linux/skbuff.h>
 #include <linux/list.h>
 #include <linux/device.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <net/sock.h>
 
 #include <asm/system.h>
@@ -395,7 +397,8 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
 
        BT_DBG("sk %p", sk);
 
-       if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc))
+       if (alen < sizeof(struct sockaddr_rc) ||
+           addr->sa_family != AF_BLUETOOTH)
                return -EINVAL;
 
        lock_sock(sk);
@@ -1061,28 +1064,38 @@ done:
        return result;
 }
 
-static ssize_t rfcomm_sock_sysfs_show(struct class *dev,
-                                     struct class_attribute *attr,
-                                     char *buf)
+static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
 {
        struct sock *sk;
        struct hlist_node *node;
-       char *str = buf;
 
        read_lock_bh(&rfcomm_sk_list.lock);
 
        sk_for_each(sk, node, &rfcomm_sk_list.head) {
-               str += sprintf(str, "%s %s %d %d\n",
-                               batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
+               seq_printf(f, "%s %s %d %d\n",
+                               batostr(&bt_sk(sk)->src),
+                               batostr(&bt_sk(sk)->dst),
                                sk->sk_state, rfcomm_pi(sk)->channel);
        }
 
        read_unlock_bh(&rfcomm_sk_list.lock);
 
-       return (str - buf);
+       return 0;
 }
 
-static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL);
+static int rfcomm_sock_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, rfcomm_sock_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations rfcomm_sock_debugfs_fops = {
+       .open           = rfcomm_sock_debugfs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static struct dentry *rfcomm_sock_debugfs;
 
 static const struct proto_ops rfcomm_sock_ops = {
        .family         = PF_BLUETOOTH,
@@ -1122,8 +1135,12 @@ int __init rfcomm_init_sockets(void)
        if (err < 0)
                goto error;
 
-       if (class_create_file(bt_class, &class_attr_rfcomm) < 0)
-               BT_ERR("Failed to create RFCOMM info file");
+       if (bt_debugfs) {
+               rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
+                               bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
+               if (!rfcomm_sock_debugfs)
+                       BT_ERR("Failed to create RFCOMM debug file");
+       }
 
        BT_INFO("RFCOMM socket layer initialized");
 
@@ -1137,7 +1154,7 @@ error:
 
 void rfcomm_cleanup_sockets(void)
 {
-       class_remove_file(bt_class, &class_attr_rfcomm);
+       debugfs_remove(rfcomm_sock_debugfs);
 
        if (bt_sock_unregister(BTPROTO_RFCOMM) < 0)
                BT_ERR("RFCOMM socket layer unregistration failed");
index f93b939539bc121da4448ce68e0e785b55b08416..ca6b2ad1c3fc02a6bcbf16a034aa253e05b1a456 100644 (file)
@@ -38,6 +38,8 @@
 #include <linux/socket.h>
 #include <linux/skbuff.h>
 #include <linux/device.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 #include <linux/list.h>
 #include <net/sock.h>
 
@@ -497,7 +499,8 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
 
        BT_DBG("sk %p", sk);
 
-       if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_sco))
+       if (alen < sizeof(struct sockaddr_sco) ||
+           addr->sa_family != AF_BLUETOOTH)
                return -EINVAL;
 
        if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
@@ -953,28 +956,36 @@ drop:
        return 0;
 }
 
-static ssize_t sco_sysfs_show(struct class *dev,
-                               struct class_attribute *attr,
-                               char *buf)
+static int sco_debugfs_show(struct seq_file *f, void *p)
 {
        struct sock *sk;
        struct hlist_node *node;
-       char *str = buf;
 
        read_lock_bh(&sco_sk_list.lock);
 
        sk_for_each(sk, node, &sco_sk_list.head) {
-               str += sprintf(str, "%s %s %d\n",
-                               batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
-                               sk->sk_state);
+               seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
+                               batostr(&bt_sk(sk)->dst), sk->sk_state);
        }
 
        read_unlock_bh(&sco_sk_list.lock);
 
-       return (str - buf);
+       return 0;
 }
 
-static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL);
+static int sco_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, sco_debugfs_show, inode->i_private);
+}
+
+static const struct file_operations sco_debugfs_fops = {
+       .open           = sco_debugfs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static struct dentry *sco_debugfs;
 
 static const struct proto_ops sco_sock_ops = {
        .family         = PF_BLUETOOTH,
@@ -1032,8 +1043,12 @@ static int __init sco_init(void)
                goto error;
        }
 
-       if (class_create_file(bt_class, &class_attr_sco) < 0)
-               BT_ERR("Failed to create SCO info file");
+       if (bt_debugfs) {
+               sco_debugfs = debugfs_create_file("sco", 0444,
+                                       bt_debugfs, NULL, &sco_debugfs_fops);
+               if (!sco_debugfs)
+                       BT_ERR("Failed to create SCO debug file");
+       }
 
        BT_INFO("SCO (Voice Link) ver %s", VERSION);
        BT_INFO("SCO socket layer initialized");
@@ -1047,7 +1062,7 @@ error:
 
 static void __exit sco_exit(void)
 {
-       class_remove_file(bt_class, &class_attr_sco);
+       debugfs_remove(sco_debugfs);
 
        if (bt_sock_unregister(BTPROTO_SCO) < 0)
                BT_ERR("SCO socket unregistration failed");
index 3b8e038ab32c537cd36657edd39d506a1891118b..9101a4e5620129fa4d29df1a7e2cbde264cf88f2 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/etherdevice.h>
 #include <linux/jhash.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <asm/atomic.h>
 #include <asm/unaligned.h>
 #include "br_private.h"
index 8dbec83e50ca2cd8b43fe466e578a68d6eb7c7b2..7a241c396981eebb9ee1357daf88e7d18f3f8db8 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
index b6a3872f5681de09a8d67a8fe0ec99cf4ad4dbd1..0b6b1f2ff7acb4000892dd08e1e9834844d188e7 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #include "br_private.h"
index d74d570fc848537b437b24aa696285afef90543c..a82dde2d2ead34d32af8ecd3829ee5563d8cf710 100644 (file)
@@ -11,6 +11,7 @@
  *     2 of the License, or (at your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
index 2af6e4a902628ca8e1132e51bdeeee971f078a1d..995afc4b04dc58bf46d0ca4b5b7d650247b37282 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/if_bridge.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <linux/times.h>
 #include <net/net_namespace.h>
 #include <asm/uaccess.h>
index 268e2e7258881addf26214bb4418382ba3228c97..4c4977d12fd64d81a0c0281cd166346b81e65da1 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/ip.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
index fcffb3fb1177aa57352f4fdbcc0247944d1959ac..aa56ac2c88293ad7717c62c256eaea185a638cd1 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <net/rtnetlink.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
index 81ae40b3f6550c70b01b8d88a5266e14647a2d11..d66cce11f3bf93475b85d827dbf6b11de8897886 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/netfilter_bridge.h>
 #include <linux/etherdevice.h>
 #include <linux/llc.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/llc.h>
 #include <net/llc_pdu.h>
index c6ac657074a6b6471a1bb554fe7bb123ed676944..f9560f3dbdc7c9ba538a12b1b637766ecf981db8 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/socket.h>
 #include <linux/skbuff.h>
index dfb58056a89ae7f6e3538124197ba3d175c77edd..f0865fd1e3eca770f2218e576093a139b9676243 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/netfilter_bridge/ebtables.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/cpumask.h>
index e32af52238a2a437787b4adaa7a7616e195b0e57..907dc871fac8bcf5e6d3cbce2c79f9a53706ccfa 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/can.h>
 #include <linux/can/core.h>
 #include <linux/can/bcm.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/net_namespace.h>
 
@@ -1478,6 +1479,9 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
        struct sock *sk = sock->sk;
        struct bcm_sock *bo = bcm_sk(sk);
 
+       if (len < sizeof(*addr))
+               return -EINVAL;
+
        if (bo->bound)
                return -EISCONN;
 
index abca920440b50cdf51e539fc18c6ea15f7ef698b..3a7dffb6519ce9083b876b64f823cffcb1020c3d 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/init.h>
 #include <linux/uio.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/socket.h>
 #include <linux/if_arp.h>
index a1fb1b079a82b00bd269fa208984de34010bf7f4..ec24d9edb0258ecda760deaf80eaa211f844feef 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/types.h>
 #include <linux/file.h>
index 95c2e0840d0d7571ed799a1d17006db05c4bd6eb..2dccd4ee591b3a755242c05b8889489a380dc8bd 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/poll.h>
 #include <linux/highmem.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include <net/protocol.h>
 #include <linux/skbuff.h>
index bcc490cc9452f3e87273836ef406c54608c49084..1c8a0ce473a860a28a19e4fd9b3943a1f2752a7b 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/hash.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/mutex.h>
 #include <linux/string.h>
@@ -2483,6 +2484,7 @@ int netif_receive_skb(struct sk_buff *skb)
 {
        struct packet_type *ptype, *pt_prev;
        struct net_device *orig_dev;
+       struct net_device *master;
        struct net_device *null_or_orig;
        struct net_device *null_or_bond;
        int ret = NET_RX_DROP;
@@ -2503,11 +2505,12 @@ int netif_receive_skb(struct sk_buff *skb)
 
        null_or_orig = NULL;
        orig_dev = skb->dev;
-       if (orig_dev->master) {
-               if (skb_bond_should_drop(skb))
+       master = ACCESS_ONCE(orig_dev->master);
+       if (master) {
+               if (skb_bond_should_drop(skb, master))
                        null_or_orig = orig_dev; /* deliver only exact match */
                else
-                       skb->dev = orig_dev->master;
+                       skb->dev = master;
        }
 
        __get_cpu_var(netdev_rx_stat).total++;
index f8c8749753506c00f8a843679c7522de255302b5..cf208d8042b198d962a8ccfbd81c0b70acca28c2 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/percpu.h>
 #include <linux/timer.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <net/genetlink.h>
 #include <net/netevent.h>
 
index cb1b3488b739837fcff71c10d36694f2ea3ab393..f307bc18f6a0002a0a1f7d1c2268a8cc260e0805 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/workqueue.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <linux/string.h>
index f4cb6b6299d9ad833c442455944133c5c55868dd..9d55c57f318a7ac93f9362ee5245f07c473c906c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 /*
index 9a24377146bf0dc25163e96bfb3c9b6c0701ab40..d2c3e7dc2e5f17baedd875cdd805186a7678b2aa 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
index d38ef7fd50f0c70397e487f254c81ff1248782bd..ff943bed21afe0b90cc797628ff76795c79981f4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/inet.h>
 #include <linux/netdevice.h>
 #include <linux/if_packet.h>
+#include <linux/gfp.h>
 #include <net/ip.h>
 #include <net/protocol.h>
 #include <net/netlink.h>
index 493775f4f2f1d7c19b618640e186aae7195ded53..cf8e70392fe0938acb4b8b88fa8bc74dbeaed584 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
 #include <linux/rbtree.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/gen_stats.h>
 
index 16ad45d4882b56a2c531a0a944bc31c690ff5a4b..1e7f4e91a935f65b8fbb1ff60efd1663a39686cc 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/net.h>
 #include <linux/in6.h>
 #include <asm/uaccess.h>
index 5910b555a54afbe603322756d39d9fb9898d4830..bdbce2f5875be574cf367a2493bf290e9b99bcd8 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/rtnetlink.h>
 #include <linux/jiffies.h>
 #include <linux/spinlock.h>
-#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/bitops.h>
 #include <asm/types.h>
index 6cee6434da677a393d218a4c50e069d80932a594..bff37908bd55683012353bde62015722f8c515e9 100644 (file)
@@ -15,6 +15,7 @@
  *     Harald Welte            Add neighbour cache statistics like rtstat
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
index 099c753c4213ae814b51bf4e149eeb4f79836224..59cfc7d8fc450c26a17b094280dec7a2842461e9 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/rtnetlink.h>
 #include <linux/wireless.h>
index f1e982c508bb16df812024014d953c184e777247..afa6380ed88ac2ee0b5cd8c8a731dcb9f3dcb809 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/workqueue.h>
 #include <linux/netlink.h>
 #include <linux/net_dropmon.h>
+#include <linux/slab.h>
 
 #include <asm/unaligned.h>
 #include <asm/bitops.h>
index d4ec38fa64e6df2742c9c79e7551d6f996f9a600..a58f59b975974ec6d0daf13bbe71aecc1d2e0bd2 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/rcupdate.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include <net/tcp.h>
 #include <net/udp.h>
 #include <asm/unaligned.h>
@@ -614,7 +615,7 @@ void netpoll_print_options(struct netpoll *np)
                         np->name, np->local_port);
        printk(KERN_INFO "%s: local IP %pI4\n",
                         np->name, &np->local_ip);
-       printk(KERN_INFO "%s: interface %s\n",
+       printk(KERN_INFO "%s: interface '%s'\n",
                         np->name, np->dev_name);
        printk(KERN_INFO "%s: remote port %d\n",
                         np->name, np->remote_port);
@@ -661,6 +662,9 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
                if ((delim = strchr(cur, '@')) == NULL)
                        goto parse_failed;
                *delim = 0;
+               if (*cur == ' ' || *cur == '\t')
+                       printk(KERN_INFO "%s: warning: whitespace"
+                                       "is not allowed\n", np->name);
                np->remote_port = simple_strtol(cur, NULL, 10);
                cur = delim;
        }
@@ -708,7 +712,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
        return 0;
 
  parse_failed:
-       printk(KERN_INFO "%s: couldn't parse config at %s!\n",
+       printk(KERN_INFO "%s: couldn't parse config at '%s'!\n",
               np->name, cur);
        return -1;
 }
index 9b264634acfd6233ebfa7369cc4537638377d06d..b88f6f9d0b97503ddd353e163e73680704cde79a 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/security.h>
 #include <linux/pid.h>
 #include <linux/nsproxy.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 06124872af5ba017d71e6817c9e0f4c9d8ac21ea..b7b6b8208f755ceb6f64c0f7a90a0673e172410a 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/netdevice.h>
 #include <linux/ratelimit.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <net/ip.h>
 #include <net/sock.h>
index 813e399220a746701c1da057bbbe61d32d2d0f93..19ac2b985485f0e7ef4b408197ffb10434143c78 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/netdevice.h>
 #include <linux/netlink.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/rtnetlink.h>
 #include <linux/dcbnl.h>
index 49d27c556becbb3423fcff11a1561a2b864319cc..36479ca61e0392572ef46a5a39d14c9091b387b4 100644 (file)
@@ -11,6 +11,8 @@
  *     published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
+
 #include "ccid.h"
 #include "ccids/lib/tfrc.h"
 
index a47a8c918ee89e0ea2402b76f7133afd2c2eb69f..9b3ae9922be1aa446f8b57973356d216de9f82ee 100644 (file)
@@ -23,6 +23,7 @@
 /*
  * This implementation should follow RFC 4341
  */
+#include <linux/slab.h>
 #include "../feat.h"
 #include "../ccid.h"
 #include "../dccp.h"
index 972b8dc918d6ab90d5d11f55f2e2e7c585def32a..df7dd26cf07eb8c5fa131f2ce7aee8eb87f065e9 100644 (file)
@@ -22,6 +22,7 @@
  *  2 of the License, or (at your option) any later version.
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 #include "ccid.h"
 #include "feat.h"
 
index 7648f316310fbe668342915d82995d833eb71a91..9ec717426024d0ab01a927653e4dd85134b72ef0 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/dccp.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 
index 4071eaf2b361225a846780fe44e12b77476323f4..52ffa1cde15a07f597470a15d7fd5ad25bd1e695 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/dccp.h>
 #include <linux/icmp.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/random.h>
index af3394df63b7ea388922b2f33f04324be21421af..3b11e41a2929e717ded1865c864a6f7b1b5fb7e0 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/module.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/xfrm.h>
 
 #include <net/addrconf.h>
index 0d508c359fa97f053831f15a76ea764236ca9887..128b089d3aefb0d05f7899a240ad3ced0a708d33 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/dccp.h>
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/timer.h>
index d6bb753bf6ad8485552bea39107a59afa0eb971a..fc3f436440b48980f01a05cb97f80960e4f5fd5a 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/dccp.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/inet_sock.h>
 #include <net/sock.h>
index f5b3464f124292ef26dcbaf7562355e7ab5d5a63..078e48d442fd2df6c5e500b2db4958df7a82a534 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/module.h>
 #include <linux/kfifo.h>
 #include <linux/vmalloc.h>
+#include <linux/gfp.h>
 #include <net/net_namespace.h>
 
 #include "dccp.h"
index aa4cef374fd0d49685731e7698f1f725363ddc9a..a0e38d8018f55f9c7387136a3889d568d2bdfa92 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/if_arp.h>
 #include <linux/init.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 
 #include <net/inet_sock.h>
index 238af093495b2448e140fbf3366c0ad45ef8d1f0..cead68eb254c1370928ae37078a4df8b36fcd5a7 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/skbuff.h>
 #include <linux/sysctl.h>
 #include <linux/notifier.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <net/net_namespace.h>
index e9d48700e83a3a5d5bdc3dcd2c80f7fe9aea45d1..4ab96c15166d4930dd49772e41734f3eca3968f5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/string.h>
 #include <linux/net.h>
 #include <linux/socket.h>
+#include <linux/slab.h>
 #include <linux/sockios.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
index 794b5bf95af1af0512ee10f2b4884a056ddae9ab..deb723dba44b62d8aca89aa15d9ea332001f004a 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <linux/if_ether.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
index 932408dca86da3de19a371469f1ea4d54dac1403..25a37299bc65c0fd8652c886758a372c1bdcf66a 100644 (file)
@@ -57,6 +57,7 @@
 #include <linux/netdevice.h>
 #include <linux/inet.h>
 #include <linux/route.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/tcp_states.h>
 #include <asm/system.h>
index a65e929ce76cc67b01b35642584fbf7b80b37355..baeb1eaf011be83a0dff59717f54e30241e4f0ad 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/netdevice.h>
 #include <linux/inet.h>
 #include <linux/route.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <asm/system.h>
 #include <linux/fcntl.h>
index a7bf03ca0a36a7566c3e3c8c934f819131b34ea0..70ebe74027d558750218c8bc9974d0a02f2de3c8 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/inet.h>
 #include <linux/route.h>
 #include <linux/in_route.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
index b9a33bb5e9cce34cc82bd897e959d9c395ec4ac8..f2abd37556905923097b0f203358a785b6f722ba 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/net.h>
 #include <linux/socket.h>
+#include <linux/slab.h>
 #include <linux/sockios.h>
 #include <linux/init.h>
 #include <linux/skbuff.h>
index 6d2bd3202048a8c8b36e17ef707278cc806d89e4..64a7f39e069fbc82e7e4a1bf2a50981e92d30949 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
 #include <linux/netfilter.h>
index 71489f69a42c1e38f59b5c61dfe6c2d2b557242d..6112a12578b26441c69038aaffa1cf90bd2f9b91 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <net/dsa.h>
 #include "dsa_priv.h"
 
index cdf2d28a0297e84e7582301d56902573965b983e..98dfe80b45381f1c5b4bea6459f8d1b5e932c870 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/etherdevice.h>
 #include <linux/list.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include "dsa_priv.h"
 
 #define DSA_HLEN       4
index 8f53948cff4fcabe1577a805ec8af8125f8acf85..6f383322ad2508570d793f3c6bd8078c4152c0b4 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/etherdevice.h>
 #include <linux/list.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include "dsa_priv.h"
 
 #define DSA_HLEN       4
index a85c829853c00ec9e1ec4aeee2f05013d5c73c0b..d6d7d0add3cb4634fd00d61fb983973a4e5a4551 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/etherdevice.h>
 #include <linux/list.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include "dsa_priv.h"
 
 netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev)
index 29b4931aae520e254e61e655f6d71b9ba76730be..2a5a8053e0004fb1523bb7d21436eefd618a907a 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/wireless.h>
 #include <linux/skbuff.h>
 #include <linux/udp.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/inet_common.h>
 #include <linux/stat.h>
index d60e15d9365e720b56f823c1842170d12de8a218..eb00796758c312a8eb6be570977c508e3dbb48ec 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/datalink.h>
 
index bad1c49fd9607ab5e70ee95a3134a28aa6a7bdbd..c7da600750bb862e9204b7cae10e6d776d6e2ba4 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/if.h>
 #include <linux/termios.h>     /* For TIOCOUTQ/INQ */
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/datalink.h>
 #include <net/psnap.h>
 #include <net/sock.h>
@@ -126,6 +127,9 @@ static int ieee802154_sock_connect(struct socket *sock, struct sockaddr *uaddr,
 {
        struct sock *sk = sock->sk;
 
+       if (addr_len < sizeof(uaddr->sa_family))
+               return -EINVAL;
+
        if (uaddr->sa_family == AF_UNSPEC)
                return sk->sk_prot->disconnect(sk, flags);
 
index 9aac5aee157548d663114661d945a3188611f0d4..1a3334c2609a194015eec5b6b85c943fccc1ca92 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/if_arp.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_ieee802154.h>
 #include <net/ieee802154.h>
index 33137b99e47137b8b589c8efbcf6d6912e4573f1..c8097ae2482fc83c71ecf8ecced5e5657406f890 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <net/genetlink.h>
 #include <linux/nl802154.h>
 
index 135c1678fb11cea06d69d705255332a41137b9fb..71ee1108d4f86d9509a8f3ba011d066d1a41ef7c 100644 (file)
@@ -22,6 +22,7 @@
  * Maxim Osipov <maxim.osipov@siemens.com>
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
 #include <linux/netdevice.h>
index 199a2d9d12f9ec7f526c981789f096f2292df33e..ed0eab39f531f028e96deaa5f61755c46c4e5855 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
 #include <net/wpan-phy.h>
index 9c9b85c00033718a5a4f7bf8e879869631f2b08b..10970ca85748a2a0835b2a9ac17bf26c66c1e9e2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/if_arp.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_ieee802154.h>
 
index 268691256a6d2b915caeb7a951cce97aed98ecdf..3d803a1b9fb69a046205a57be9dcbe2bfb141e72 100644 (file)
@@ -16,6 +16,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/device.h>
index 33b7dffa773240a1d017a03a2f606988f4ef4e30..f71357422380b640153b004968e7cf2b0d9a5444 100644 (file)
@@ -86,6 +86,7 @@
 #include <linux/poll.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -530,6 +531,8 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr * uaddr,
 {
        struct sock *sk = sock->sk;
 
+       if (addr_len < sizeof(uaddr->sa_family))
+               return -EINVAL;
        if (uaddr->sa_family == AF_UNSPEC)
                return sk->sk_prot->disconnect(sk, flags);
 
@@ -573,6 +576,9 @@ int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
        int err;
        long timeo;
 
+       if (addr_len < sizeof(uaddr->sa_family))
+               return -EINVAL;
+
        lock_sock(sk);
 
        if (uaddr->sa_family == AF_UNSPEC) {
index 987b47dc69ade1dc1b5e768fc92da16b1674be11..880a5ec6dce0e35805aa5abfb4a4cc4809698579 100644 (file)
@@ -1,6 +1,7 @@
 #include <crypto/hash.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
 #include <net/ah.h>
index c4dd135428021e92e9023ac7379ac59b371fe6a5..6e747065c2021071d82ba21123c9b87f9c725426 100644 (file)
@@ -98,6 +98,7 @@
 #include <linux/net.h>
 #include <linux/rcupdate.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
index 1e029dc754550b76576521331170bcd069fbd8c2..c97cd9ff697ee1cba4f373333190126c57970f28 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/string.h>
 #include <linux/jhash.h>
 #include <linux/audit.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <net/icmp.h>
 #include <net/tcp.h>
index 51ca946e339268b58181870695906e1f29257d85..90e3d6379a42ae369ceeba06c783978858e96e71 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/notifier.h>
 #include <linux/inetdevice.h>
 #include <linux/igmp.h>
+#include <linux/slab.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
@@ -1194,7 +1195,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
                hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
                        if (idx < s_idx)
                                goto cont;
-                       if (idx > s_idx)
+                       if (h > s_h || idx > s_idx)
                                s_ip_idx = 0;
                        in_dev = __in_dev_get_rcu(dev);
                        if (!in_dev)
index 9b3e28ed524077860c8925894646163fe241f608..4f0ed458c883658c37265fe6537bde2ac8b88429 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #include <net/ip.h>
 #include <net/protocol.h>
index 14972017b9c2ad727369a124f95116ff95af430d..4ed7e0dea1bc0e8b33bb1f094e712b59fb6715ad 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/ip.h>
index 1af0ea0fb6a20227c941e8ad910d3634ff2a1319..20f09c5b31e8bba5e3580255fe5f8d541c14d374 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/proc_fs.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <net/arp.h>
 #include <net/ip.h>
index af5d897928606df52c3f97483f860c934d2bf6fd..59a838795e3e6cf93ba919676ae68804c8b8a00a 100644 (file)
@@ -71,6 +71,7 @@
 #include <linux/netlink.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/protocol.h>
@@ -961,7 +962,9 @@ fib_find_node(struct trie *t, u32 key)
        struct node *n;
 
        pos = 0;
-       n = rcu_dereference(t->trie);
+       n = rcu_dereference_check(t->trie,
+                                 rcu_read_lock_held() ||
+                                 lockdep_rtnl_is_held());
 
        while (n != NULL &&  NODE_TYPE(n) == T_TNODE) {
                tn = (struct tnode *) n;
index 4b4c2bcd15db4b4464be428a954ee8686769b68b..ac4dec1327354020b35f7404f5f47f4d463aba3f 100644 (file)
@@ -74,6 +74,7 @@
 #include <linux/netdevice.h>
 #include <linux/string.h>
 #include <linux/netfilter_ipv4.h>
+#include <linux/slab.h>
 #include <net/snmp.h>
 #include <net/ip.h>
 #include <net/route.h>
index 63bf298ca109f6bffba83bc8ba835d2d96e52cf8..15d3eeda92f5c7876698dac44048ff1c4bbc09b7 100644 (file)
@@ -71,6 +71,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <linux/types.h>
index 1aaa8110d84be07d51d0bff955056e33db34e001..e5fa2ddce320adafac68cdbf19bfefdae534cf2c 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/cache.h>
 #include <linux/init.h>
 #include <linux/time.h>
index eaf3e2c8646a438a938f341151c04920746a3c5f..a2ca6aed763bad1e0c449d32e79786512b553ef7 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/random.h>
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 
 #include <net/inet_frag.h>
 
index cc94cc2d8b2d8825d909266b501afb1c6ea03cab..c5af909cf701c37dfb2afecf078de854349c2950 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/kernel.h>
 #include <linux/kmemcheck.h>
+#include <linux/slab.h>
 #include <net/inet_hashtables.h>
 #include <net/inet_timewait_sock.h>
 #include <net/ip.h>
index a2991bc8e32e5e0b89727086fb1484dfe65ffdc4..af10942b326c4f51cdd49c61411a009e2d80a026 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ip.h>
 #include <linux/icmp.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/tcp.h>
index b59430bc041ca99d4d653e5a1791bd279392ffc5..75347ea70ea071d6fef5223535b6bb83973b602b 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/netdevice.h>
 #include <linux/jhash.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <net/route.h>
 #include <net/dst.h>
 #include <net/sock.h>
index f47c9f76754b2f03d900bf2cabe9907f93907bd3..fe381d12ecdd4227e785ff54f6e0b97162914f55 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
@@ -810,11 +811,13 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
                        tunnel->err_count = 0;
        }
 
-       max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen;
+       max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + rt->u.dst.header_len;
 
        if (skb_headroom(skb) < max_headroom || skb_shared(skb)||
            (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
                struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
+               if (max_headroom > dev->needed_headroom)
+                       dev->needed_headroom = max_headroom;
                if (!new_skb) {
                        ip_rt_put(rt);
                        txq->tx_dropped++;
index c29de9879fdae1e56d1ac2a2572159aab1b31854..f8ab7a380d4a64b12696eeab5c5f23ab5ca332db 100644 (file)
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 
 #include <linux/net.h>
 #include <linux/socket.h>
index 94bf105ef3c9b7e593df4b8aee0a016d0a9022e7..4c09a31fd140c115a6f9cb4469d3f62aa10e56ae 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/capability.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/uaccess.h>
 #include <linux/skbuff.h>
index 3451799e3dbf78253d70995d37697a1b546f143d..c65f18e0936e7b93ede848398648f8174a669f35 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/highmem.h>
+#include <linux/slab.h>
 
 #include <linux/socket.h>
 #include <linux/sockios.h>
index 644dc43a55dec954dc7232b3edb58c3412951540..1e64dabbd232ea41bdbf6825b9358dc18b741931 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/icmp.h>
 #include <linux/inetdevice.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/icmp.h>
index 6789092816487ee51220502282371d7939e9a6e5..067ce9e043dc2e6d5013681815e6da46ef8cc060 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/root_dev.h>
 #include <linux/delay.h>
 #include <linux/nfs_fs.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/arp.h>
 #include <net/ip.h>
index 2f302d3ac9a3c27e4f29dd1f1c71811353db73d5..0b27b14dcc9d65e6545327ef98a3ece61419214f 100644 (file)
@@ -95,6 +95,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
index 8582e12e4a62a8b11ec53d129aabbf16842fcc8e..9d4f6d1340a438b2f8004d3906b52e6bfe069756 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/protocol.h>
@@ -802,6 +803,9 @@ static int ipmr_mfc_add(struct net *net, struct mfcctl *mfc, int mrtsock)
        int line;
        struct mfc_cache *uc, *c, **cp;
 
+       if (mfc->mfcc_parent >= MAXVIFS)
+               return -ENFILE;
+
        line = MFC_HASH(mfc->mfcc_mcastgrp.s_addr, mfc->mfcc_origin.s_addr);
 
        for (cp = &net->ipv4.mfc_cache_array[line];
@@ -1613,17 +1617,20 @@ ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm)
        int ct;
        struct rtnexthop *nhp;
        struct net *net = mfc_net(c);
-       struct net_device *dev = net->ipv4.vif_table[c->mfc_parent].dev;
        u8 *b = skb_tail_pointer(skb);
        struct rtattr *mp_head;
 
-       if (dev)
-               RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex);
+       /* If cache is unresolved, don't try to parse IIF and OIF */
+       if (c->mfc_parent > MAXVIFS)
+               return -ENOENT;
+
+       if (VIF_EXISTS(net, c->mfc_parent))
+               RTA_PUT(skb, RTA_IIF, 4, &net->ipv4.vif_table[c->mfc_parent].dev->ifindex);
 
        mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
 
        for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
-               if (c->mfc_un.res.ttls[ct] < 255) {
+               if (VIF_EXISTS(net, ct) && c->mfc_un.res.ttls[ct] < 255) {
                        if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
                                goto rtattr_failure;
                        nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
index c14623fc4d5eab4f9203580e67a29161583358fa..82fb43c5c59ef9cf058646516521406437b70b87 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/netfilter_ipv4.h>
 #include <linux/ip.h>
 #include <linux/skbuff.h>
+#include <linux/gfp.h>
 #include <net/route.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
index bfe26f32b93069fc478cc559973b0b2cf743154f..79ca5e70d49774e074613fe2c55cee941386542a 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_arp/arp_tables.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
index 2855f1f38cbc2b2278197c3d6522db7883f8a076..e2787048aa0a4f9008cb8389e89baaaa45717fce 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/security.h>
 #include <linux/net.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/route.h>
index 0886f96c736b12b1ddcc50bbb365a3d4e68d1a0d..ab828400ed7160c146f8dc058edf9b17dc81ab96 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/jhash.h>
 #include <linux/bitops.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
index 5113b8f1a379e5210ca7358aa74b77671e3225b1..a0e8bcf041592cac88b9a623cb001e22cd0b55cd 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
 #include <linux/icmp.h>
index 09a5d3f7cc41e5588febe4fbc6be1e085ce35212..0dbe697f164fd38487a6a8a09e56d83cc00a2352 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/socket.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/kernel.h>
 #include <linux/timer.h>
index c8dc9800d62066d593a4392ccb30fa1d9bbbd0cf..55392466daa49fd455a4c28d6b168c388db2eff2 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 
 MODULE_LICENSE("GPL");
index b9b83464cbf4bf91d745c01e25b1d45bbc12546d..294a2a32f29345e1ceb39f13afbcc605e586bc4f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/netfilter_ipv4/ip_tables.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/route.h>
 #include <linux/ip.h>
index 06fb9d11953cadbcf76b6d6ccbf0edaaf78d425a..07fb710cd722f329ea297b764f50cfeb0ad8175e 100644 (file)
@@ -5,6 +5,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 
 #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
index cce2f64e6f21ee61822adf28f0fcc988dffe4239..be45bdc4c60251a0936e8e5f7d0c6ea56d0e6eec 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 
 MODULE_LICENSE("GPL");
index 4595281c28635b30d4522d75aafdc57e82828b4a..4f8bddb760c9cb47d6931647d8b03ece5fef5fc0 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/types.h>
 #include <linux/timer.h>
 #include <linux/skbuff.h>
+#include <linux/gfp.h>
 #include <net/checksum.h>
 #include <net/icmp.h>
 #include <net/ip.h>
index 4b6af4bb1f500f4e1ed309c305b94111088d12f4..4a0c6b548eee22f1dfc0e6d01187f209319f10d7 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/kmod.h>
 #include <linux/types.h>
 #include <linux/timer.h>
index ab74cc0535e26843d1c50a9e050f841ce4cd40bc..26de2c1f7fabd1a0e1b135fd487595311aa1793a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kmod.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
+#include <linux/slab.h>
 #include <net/checksum.h>
 #include <net/route.h>
 #include <linux/bitops.h>
index 0b9c7ce3d6c584a90fa012a96e9baa7a6deab317..4d85b6e55f2978f31cbe2aa85d2fbbf95d9bbdb4 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
index 5678e9562c15b706f930799419ae76297c4a4775..c39c9cf6bee67f9f853f7a8f7c3faa00a440fbba 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include <linux/types.h>
 #include <linux/icmp.h>
+#include <linux/gfp.h>
 #include <linux/ip.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
index ce154b47f1da08fd5c0ef874920bbb70aa1e90bb..cc6f097fbd5fb9a24ce0b80737f6973ee48e3b7a 100644 (file)
@@ -60,7 +60,6 @@
 #include <net/net_namespace.h>
 #include <net/dst.h>
 #include <net/sock.h>
-#include <linux/gfp.h>
 #include <linux/ip.h>
 #include <linux/net.h>
 #include <net/ip.h>
index a770df2493d23652fa5640517b59d9e2f47e7893..cb562fdd9b9a5342cee41f2cc642a8b4af9e30ce 100644 (file)
@@ -90,6 +90,7 @@
 #include <linux/jhash.h>
 #include <linux/rcupdate.h>
 #include <linux/times.h>
+#include <linux/slab.h>
 #include <net/dst.h>
 #include <net/net_namespace.h>
 #include <net/protocol.h>
@@ -1097,7 +1098,7 @@ static int slow_chain_length(const struct rtable *head)
 }
 
 static int rt_intern_hash(unsigned hash, struct rtable *rt,
-                         struct rtable **rp, struct sk_buff *skb)
+                         struct rtable **rp, struct sk_buff *skb, int ifindex)
 {
        struct rtable   *rth, **rthp;
        unsigned long   now;
@@ -1212,11 +1213,16 @@ restart:
                    slow_chain_length(rt_hash_table[hash].chain) > rt_chain_length_max) {
                        struct net *net = dev_net(rt->u.dst.dev);
                        int num = ++net->ipv4.current_rt_cache_rebuild_count;
-                       if (!rt_caching(dev_net(rt->u.dst.dev))) {
+                       if (!rt_caching(net)) {
                                printk(KERN_WARNING "%s: %d rebuilds is over limit, route caching disabled\n",
                                        rt->u.dst.dev->name, num);
                        }
-                       rt_emergency_hash_rebuild(dev_net(rt->u.dst.dev));
+                       rt_emergency_hash_rebuild(net);
+                       spin_unlock_bh(rt_hash_lock_addr(hash));
+
+                       hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
+                                       ifindex, rt_genid(net));
+                       goto restart;
                }
        }
 
@@ -1441,7 +1447,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
                                        dev_hold(rt->u.dst.dev);
                                if (rt->idev)
                                        in_dev_hold(rt->idev);
-                               rt->u.dst.obsolete      = 0;
+                               rt->u.dst.obsolete      = -1;
                                rt->u.dst.lastuse       = jiffies;
                                rt->u.dst.path          = &rt->u.dst;
                                rt->u.dst.neighbour     = NULL;
@@ -1477,7 +1483,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
                                                        &netevent);
 
                                rt_del(hash, rth);
-                               if (!rt_intern_hash(hash, rt, &rt, NULL))
+                               if (!rt_intern_hash(hash, rt, &rt, NULL, rt->fl.oif))
                                        ip_rt_put(rt);
                                goto do_next;
                        }
@@ -1506,11 +1512,12 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
        struct dst_entry *ret = dst;
 
        if (rt) {
-               if (dst->obsolete) {
+               if (dst->obsolete > 0) {
                        ip_rt_put(rt);
                        ret = NULL;
                } else if ((rt->rt_flags & RTCF_REDIRECTED) ||
-                          rt->u.dst.expires) {
+                          (rt->u.dst.expires &&
+                           time_after_eq(jiffies, rt->u.dst.expires))) {
                        unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
                                                rt->fl.oif,
                                                rt_genid(dev_net(dst->dev)));
@@ -1726,7 +1733,9 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
 
 static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie)
 {
-       return NULL;
+       if (rt_is_expired((struct rtable *)dst))
+               return NULL;
+       return dst;
 }
 
 static void ipv4_dst_destroy(struct dst_entry *dst)
@@ -1888,7 +1897,8 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
        if (!rth)
                goto e_nobufs;
 
-       rth->u.dst.output= ip_rt_bug;
+       rth->u.dst.output = ip_rt_bug;
+       rth->u.dst.obsolete = -1;
 
        atomic_set(&rth->u.dst.__refcnt, 1);
        rth->u.dst.flags= DST_HOST;
@@ -1927,7 +1937,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 
        in_dev_put(in_dev);
        hash = rt_hash(daddr, saddr, dev->ifindex, rt_genid(dev_net(dev)));
-       return rt_intern_hash(hash, rth, NULL, skb);
+       return rt_intern_hash(hash, rth, NULL, skb, dev->ifindex);
 
 e_nobufs:
        in_dev_put(in_dev);
@@ -2054,6 +2064,7 @@ static int __mkroute_input(struct sk_buff *skb,
        rth->fl.oif     = 0;
        rth->rt_spec_dst= spec_dst;
 
+       rth->u.dst.obsolete = -1;
        rth->u.dst.input = ip_forward;
        rth->u.dst.output = ip_output;
        rth->rt_genid = rt_genid(dev_net(rth->u.dst.dev));
@@ -2093,7 +2104,7 @@ static int ip_mkroute_input(struct sk_buff *skb,
        /* put it into the cache */
        hash = rt_hash(daddr, saddr, fl->iif,
                       rt_genid(dev_net(rth->u.dst.dev)));
-       return rt_intern_hash(hash, rth, NULL, skb);
+       return rt_intern_hash(hash, rth, NULL, skb, fl->iif);
 }
 
 /*
@@ -2218,6 +2229,7 @@ local_input:
                goto e_nobufs;
 
        rth->u.dst.output= ip_rt_bug;
+       rth->u.dst.obsolete = -1;
        rth->rt_genid = rt_genid(net);
 
        atomic_set(&rth->u.dst.__refcnt, 1);
@@ -2249,7 +2261,7 @@ local_input:
        }
        rth->rt_type    = res.type;
        hash = rt_hash(daddr, saddr, fl.iif, rt_genid(net));
-       err = rt_intern_hash(hash, rth, NULL, skb);
+       err = rt_intern_hash(hash, rth, NULL, skb, fl.iif);
        goto done;
 
 no_route:
@@ -2444,6 +2456,7 @@ static int __mkroute_output(struct rtable **result,
        rth->rt_spec_dst= fl->fl4_src;
 
        rth->u.dst.output=ip_output;
+       rth->u.dst.obsolete = -1;
        rth->rt_genid = rt_genid(dev_net(dev_out));
 
        RT_CACHE_STAT_INC(out_slow_tot);
@@ -2495,7 +2508,7 @@ static int ip_mkroute_output(struct rtable **rp,
        if (err == 0) {
                hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
                               rt_genid(dev_net(dev_out)));
-               err = rt_intern_hash(hash, rth, rp, NULL);
+               err = rt_intern_hash(hash, rth, rp, NULL, oldflp->oif);
        }
 
        return err;
index c1bc074f61b7dd53181fe3952ffdce7bf71ce2a5..1cd5c15174b8a0f286fd9d7a92100841dd341ecd 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/inetdevice.h>
 #include <linux/seqlock.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/snmp.h>
 #include <net/icmp.h>
 #include <net/ip.h>
index 5901010fad55bc969fe509ae8d3fde0aef443b2d..0f8caf64caa3a8db1c1f3641782fa04682aac8ea 100644 (file)
 #include <linux/err.h>
 #include <linux/crypto.h>
 #include <linux/time.h>
+#include <linux/slab.h>
 
 #include <net/icmp.h>
 #include <net/tcp.h>
@@ -429,7 +430,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
                if (tp->urg_seq == tp->copied_seq &&
                    !sock_flag(sk, SOCK_URGINLINE) &&
                    tp->urg_data)
-                       target--;
+                       target++;
 
                /* Potential race condition. If read of tp below will
                 * escape above sk->sk_state, we can be illegally awaken
@@ -1254,6 +1255,39 @@ static void tcp_prequeue_process(struct sock *sk)
        tp->ucopy.memory = 0;
 }
 
+#ifdef CONFIG_NET_DMA
+static void tcp_service_net_dma(struct sock *sk, bool wait)
+{
+       dma_cookie_t done, used;
+       dma_cookie_t last_issued;
+       struct tcp_sock *tp = tcp_sk(sk);
+
+       if (!tp->ucopy.dma_chan)
+               return;
+
+       last_issued = tp->ucopy.dma_cookie;
+       dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
+
+       do {
+               if (dma_async_memcpy_complete(tp->ucopy.dma_chan,
+                                             last_issued, &done,
+                                             &used) == DMA_SUCCESS) {
+                       /* Safe to free early-copied skbs now */
+                       __skb_queue_purge(&sk->sk_async_wait_queue);
+                       break;
+               } else {
+                       struct sk_buff *skb;
+                       while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
+                              (dma_async_is_complete(skb->dma_cookie, done,
+                                                     used) == DMA_SUCCESS)) {
+                               __skb_dequeue(&sk->sk_async_wait_queue);
+                               kfree_skb(skb);
+                       }
+               }
+       } while (wait);
+}
+#endif
+
 static inline struct sk_buff *tcp_recv_skb(struct sock *sk, u32 seq, u32 *off)
 {
        struct sk_buff *skb;
@@ -1335,6 +1369,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
                sk_eat_skb(sk, skb, 0);
                if (!desc->count)
                        break;
+               tp->copied_seq = seq;
        }
        tp->copied_seq = seq;
 
@@ -1546,6 +1581,10 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                        /* __ Set realtime policy in scheduler __ */
                }
 
+#ifdef CONFIG_NET_DMA
+               if (tp->ucopy.dma_chan)
+                       dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
+#endif
                if (copied >= target) {
                        /* Do not sleep, just process backlog. */
                        release_sock(sk);
@@ -1554,6 +1593,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                        sk_wait_data(sk, &timeo);
 
 #ifdef CONFIG_NET_DMA
+               tcp_service_net_dma(sk, false);  /* Don't block */
                tp->ucopy.wakeup = 0;
 #endif
 
@@ -1633,6 +1673,9 @@ do_prequeue:
                                                copied = -EFAULT;
                                        break;
                                }
+
+                               dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
+
                                if ((offset + used) == skb->len)
                                        copied_early = 1;
 
@@ -1702,27 +1745,9 @@ skip_copy:
        }
 
 #ifdef CONFIG_NET_DMA
-       if (tp->ucopy.dma_chan) {
-               dma_cookie_t done, used;
-
-               dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
-
-               while (dma_async_memcpy_complete(tp->ucopy.dma_chan,
-                                                tp->ucopy.dma_cookie, &done,
-                                                &used) == DMA_IN_PROGRESS) {
-                       /* do partial cleanup of sk_async_wait_queue */
-                       while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
-                              (dma_async_is_complete(skb->dma_cookie, done,
-                                                     used) == DMA_SUCCESS)) {
-                               __skb_dequeue(&sk->sk_async_wait_queue);
-                               kfree_skb(skb);
-                       }
-               }
+       tcp_service_net_dma(sk, true);  /* Wait for queue to drain */
+       tp->ucopy.dma_chan = NULL;
 
-               /* Safe to free early-copied skbs now */
-               __skb_queue_purge(&sk->sk_async_wait_queue);
-               tp->ucopy.dma_chan = NULL;
-       }
        if (tp->ucopy.pinned_list) {
                dma_unpin_iovec_pages(tp->ucopy.pinned_list);
                tp->ucopy.pinned_list = NULL;
index 6428b342b16442d48864c53ee7d4f8b25fc6a42c..0ec9bd0ae94f2ef37024ac11c5e411f0179c816a 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/mm.h>
 #include <linux/types.h>
 #include <linux/list.h>
+#include <linux/gfp.h>
 #include <net/tcp.h>
 
 int sysctl_tcp_max_ssthresh = 0;
index 788851ca8c5d10578afceb8be921638f1ed8254d..f240f57b2199e0e7e801212742b152dae2060608 100644 (file)
@@ -62,6 +62,7 @@
  */
 
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/sysctl.h>
 #include <linux/kernel.h>
@@ -2511,6 +2512,9 @@ static void tcp_mark_head_lost(struct sock *sk, int packets)
        int err;
        unsigned int mss;
 
+       if (packets == 0)
+               return;
+
        WARN_ON(packets > tp->packets_out);
        if (tp->lost_skb_hint) {
                skb = tp->lost_skb_hint;
index 70df40980a87a201e79f036aebabcfcc9dbb68c4..3c23e70885f41b2eb486731b708867b2000c408e 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/jhash.h>
 #include <linux/init.h>
 #include <linux/times.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/icmp.h>
@@ -370,6 +371,11 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
        if (sk->sk_state == TCP_CLOSE)
                goto out;
 
+       if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
+               NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
+               goto out;
+       }
+
        icsk = inet_csk(sk);
        tp = tcp_sk(sk);
        seq = ntohl(th->seq);
index 4199bc6915c549231f481aeef9f3f7fd1f435464..5fabff9ac6d6b42596fcc96727598e087b455ceb 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/workqueue.h>
 #include <net/tcp.h>
index f181b78f2385b962588f262befeb8d597570faa4..0dda86e72ad8b6d60e24d62128ccadf7ae65a0fe 100644 (file)
@@ -37,6 +37,7 @@
 #include <net/tcp.h>
 
 #include <linux/compiler.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
 
 /* People can turn this off for buggy TCP's found in printers etc. */
index 9bc805df95d2374369e7dd3d2f1f526f581996f5..f8efada580e8fed87b33ea52f27f415034a4d62e 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/kprobes.h>
 #include <linux/socket.h>
 #include <linux/tcp.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/module.h>
 #include <linux/ktime.h>
index b2e6bbccaee17eef52a3aca0466db51f89ea0d48..8a0ab2977f1fd8be8c4bf9f27d21efa9c214418e 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <net/tcp.h>
 
 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
index 3959e0ca456a09ce2457e120e2244358629ee428..3b3813cc80b9cb7e1c5afcf2f7acfb9dce32f50b 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/icmp.h>
 #include <net/ip.h>
 #include <net/protocol.h>
index 7af756d0f93174416a341d4fb1717adbda9b6794..954bbfb39dff52706301feb45182728b0b4bcc5a 100644 (file)
@@ -95,6 +95,7 @@
 #include <linux/mm.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/tcp_states.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
index f9f922a0ba88754d86d920b8417b4098d47d082a..c791bb63203f2895a629d26b4734e152d17295cd 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/netfilter.h>
index 3444f3b34ecae4cb964f0fa84b1627bed1573b06..6f368413eb0e6b35bdb4500f175372809f43a18d 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
index 3381b4317c270230a7c44ee7d57daf6ac4345897..413054f02aab3dbfe5773f9a81b1589cd21d5027 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/route.h>
 #include <linux/inetdevice.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
@@ -3610,7 +3611,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
                hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
                        if (idx < s_idx)
                                goto cont;
-                       if (idx > s_idx)
+                       if (h > s_h || idx > s_idx)
                                s_ip_idx = 0;
                        ip_idx = 0;
                        if ((idev = __in6_dev_get(dev)) == NULL)
index 6ff73c4c126aeabc14e102df05d879f4463825e9..ae404c9a746c3fe088144b16aca92b84108a5b37 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/list.h>
 #include <linux/rcupdate.h>
 #include <linux/in6.h>
+#include <linux/slab.h>
 #include <net/addrconf.h>
 #include <linux/if_addrlabel.h>
 #include <linux/netlink.h>
index 37d14e735c273438bdd6a3361f551be7b82c4de8..3192aa02ba5d3f55271ab2e804bc00776172cb0b 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/proc_fs.h>
 #include <linux/stat.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 5ac89025f9de15f20e8a9a3b2639df31897cd234..ee82d4ef26ce8d81146bf769572dbf4d728a9bf3 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <crypto/hash.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <net/ah.h>
 #include <linux/crypto.h>
index c4f6ca32fa749f74d8e327488911113f9d0b9084..b5b07054508a5154315c99f0da67b903e9ce46ee 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/sock.h>
index e6f9cdf780fe4083dca668d25b495ab80fc34d66..622dc7939a1b3fd1f759a6740eff7d01562c1a00 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/in6.h>
 #include <linux/ipv6.h>
 #include <linux/route.h>
+#include <linux/slab.h>
 
 #include <net/ipv6.h>
 #include <net/ndisc.h>
index 074f2c084f9fdf536212298e3864d20b8f3ca1a2..8a659f92d17af2a271f1c4a0ba6e72af6f6bbea1 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/netdevice.h>
 #include <linux/in6.h>
 #include <linux/icmpv6.h>
+#include <linux/slab.h>
 
 #include <net/dst.h>
 #include <net/sock.h>
index eb9abe24bdf0b1e277724958cfd113280936048e..3330a4bd6157e86d9e951f0d7833531fd10b0872 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
index 3516e6fe2e560894ae87ee06f4040f52e18069d6..628db24bcf22bceff783384ea7779a87c4cb0ab7 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/in6.h>
 #include <linux/ipv6.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 
 #include <net/addrconf.h>
 #include <net/inet_connection_sock.h>
index 2f9847924fa51c95a342ab7bff4c54ea60552342..6b82e02158c6d9c80b2e26dce09497441eed92f3 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/in6.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 #ifdef         CONFIG_PROC_FS
 #include <linux/proc_fs.h>
index e41eba8aacf15ce25eb3c7cca1d3baac1f1c884d..14e23216eb28c7332fc67afe6a855ee9a98936a4 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/route.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/sock.h>
index e28f9203deca46ecaf03958ea3c0483c79f54849..6aa7ee1295c2f5d7f467a71dcb74a0a8e029cef2 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/in6.h>
 #include <linux/icmpv6.h>
 #include <linux/mroute6.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv6.h>
index dabf108ad81131138a5923268231809ebdb51494..16c4391f952b5a2bbe6eaa4a66ca0c7a31a86062 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/tcp.h>
 #include <linux/route.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv6.h>
index 138980eec214df5aca51a2933a9b901f6606e231..2599870747ec88e82101fde1c1d42eb393c01898 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/route.h>
 #include <linux/rtnetlink.h>
 #include <linux/netfilter_ipv6.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/atomic.h>
index 52e0f74fdfe0cdfa2c8b8dc515244a64f0dc1010..3e333268db897eeeee23895e3dc764f82f401391 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/protocol.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
@@ -1113,6 +1114,9 @@ static int ip6mr_mfc_add(struct net *net, struct mf6cctl *mfc, int mrtsock)
        unsigned char ttls[MAXMIFS];
        int i;
 
+       if (mfc->mf6cc_parent >= MAXMIFS)
+               return -ENFILE;
+
        memset(ttls, 255, MAXMIFS);
        for (i = 0; i < MAXMIFS; i++) {
                if (IF_ISSET(i, &mfc->mf6cc_ifset))
@@ -1692,17 +1696,20 @@ ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm)
        int ct;
        struct rtnexthop *nhp;
        struct net *net = mfc6_net(c);
-       struct net_device *dev = net->ipv6.vif6_table[c->mf6c_parent].dev;
        u8 *b = skb_tail_pointer(skb);
        struct rtattr *mp_head;
 
-       if (dev)
-               RTA_PUT(skb, RTA_IIF, 4, &dev->ifindex);
+       /* If cache is unresolved, don't try to parse IIF and OIF */
+       if (c->mf6c_parent > MAXMIFS)
+               return -ENOENT;
+
+       if (MIF_EXISTS(net, c->mf6c_parent))
+               RTA_PUT(skb, RTA_IIF, 4, &net->ipv6.vif6_table[c->mf6c_parent].dev->ifindex);
 
        mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0));
 
        for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
-               if (c->mfc_un.res.ttls[ct] < 255) {
+               if (MIF_EXISTS(net, ct) && c->mfc_un.res.ttls[ct] < 255) {
                        if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
                                goto rtattr_failure;
                        nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
index 430454ee5ead4413de26d5607606d86ad11ecd94..33f60fca7aa775e36082c65171a10e10a4ec49bb 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/init.h>
 #include <linux/sysctl.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
index bcd971915969f1eea6672925dbba349da01bc7e8..c483ab9fd67b494286f2dfd7574fed4fa91792a3 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv6.h>
index 8bcc4b7db3bf8593d74b491d869a48f4d9fcc9a0..da0a4d2adc69ac531eba98783de78f8b570d4717 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/route.h>
 #include <linux/init.h>
 #include <linux/rcupdate.h>
+#include <linux/slab.h>
 #ifdef CONFIG_SYSCTL
 #include <linux/sysctl.h>
 #endif
index 7854052be60be862833541c8cfd624ac2b4f53ba..6a68a74d14a3a451775ae2f046518b5d119d8f3e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/ipv6.h>
index dd8afbaf00a8fe84ee317087e1c4e7dc3703ee34..39b50c3768e8b5c22f293e72c465d4b2aeea2bf2 100644 (file)
@@ -15,6 +15,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/icmpv6.h>
index 36b72cafc2276899d5a296236a9c9dba34f9fc08..d6fc9aff3163eb417c6aeadffe481e643d55566d 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
index 7844e557c0ec717731f2fcfa4b932ae7ae6349b2..6a102b57f35623c055c1eca22fd80995427ff428 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
index aef31a29de9ed37f3cf48ab12b738ddf9856882b..5b9926a011bd99faff714042746f161ee58a152a 100644 (file)
@@ -5,6 +5,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/slab.h>
 
 #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
 
@@ -13,7 +14,7 @@ static const struct xt_table packet_raw = {
        .valid_hooks = RAW_VALID_HOOKS,
        .me = THIS_MODULE,
        .af = NFPROTO_IPV6,
-       .priority = NF_IP6_PRI_FIRST,
+       .priority = NF_IP6_PRI_RAW,
 };
 
 /* The work comes in here from netfilter.c. */
index 0824d865aa9bb76314ea61a66a340b7d66cbb271..91aa2b4d83c9c1571d4538ad380dfae5296a180b 100644 (file)
@@ -17,6 +17,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/slab.h>
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("James Morris <jmorris <at> redhat.com>");
index f1171b744650e07f1e979a9575e5792ebaa10a9b..dd5b9bd61c6298474af25539617809428ed45418 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
index ed31c37c6e3906a817e751bfd86115f2246c7ca3..8763b1a0814a44b150e4c7f9e075f6e684f09243 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
+#include <linux/slab.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
 #include <linux/in6.h>
index a555156e9779edd2b3ea89314689d5c2e54de1af..6d4292ff585463178885153cdd2fe6e044b962a9 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/random.h>
 #include <linux/jhash.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
index 52cd3eff31dcccf7f79abed6d2860ceb73b09780..c2438e8cb9d0eb6aec41f9c329fedbbdedcc5be8 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/nsproxy.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/snmp.h>
 #include <net/ipv6.h>
@@ -879,7 +880,7 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
 
        rt = (struct rt6_info *) dst;
 
-       if (rt && rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie))
+       if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie))
                return dst;
 
        return NULL;
@@ -890,12 +891,17 @@ static struct dst_entry *ip6_negative_advice(struct dst_entry *dst)
        struct rt6_info *rt = (struct rt6_info *) dst;
 
        if (rt) {
-               if (rt->rt6i_flags & RTF_CACHE)
-                       ip6_del_rt(rt);
-               else
+               if (rt->rt6i_flags & RTF_CACHE) {
+                       if (rt6_check_expired(rt)) {
+                               ip6_del_rt(rt);
+                               dst = NULL;
+                       }
+               } else {
                        dst_release(dst);
+                       dst = NULL;
+               }
        }
-       return NULL;
+       return dst;
 }
 
 static void ip6_link_failure(struct sk_buff *skb)
index b1eea811be48c1f73b3a6e727193a3a04435245e..5abae10cd8844c8d2acb30ceced10055dbdf3856 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/icmp.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 #include <linux/init.h>
 #include <linux/netfilter_ipv4.h>
index f841d93bf987eb07ce03864be359be91b656583a..fa1d8f4e0051a3210b8bfb760ca1a99d0ac1ead5 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sysctl.h>
 #include <linux/in6.h>
 #include <linux/ipv6.h>
+#include <linux/slab.h>
 #include <net/ndisc.h>
 #include <net/ipv6.h>
 #include <net/addrconf.h>
index 9b6dbba80d312913278f50e059b1d19b4a554cfe..c92ebe8f80d555c4ae9a54074f10faed3865cb22 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/jhash.h>
 #include <linux/ipsec.h>
 #include <linux/times.h>
+#include <linux/slab.h>
 
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
index e17bc1dfc1a4c7597dc15886a8d285f362066e22..fc3c86a474526ee1c3b9c3f644fbe1d14c458f0e 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/mutex.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/ipv6.h>
 #include <net/protocol.h>
 #include <net/xfrm.h>
index 3c0c9c755c928f74b84b6cfb72332c96c8fbf53d..c177aea88c0b6490ee5e6684a83de3fe02a91a2a 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <asm/uaccess.h>
 
 #include <net/ndisc.h>
index 3927832227b933d3fd55218e0bdb15c6369a7e0f..b809812c8d30a85b13732fd2071d524da6a81807 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
index fa85a7d22dc495d005047a0c7a78bd7f96a25f97..2ce3a8278f26576668ffafd178891451e2b5fc87 100644 (file)
@@ -23,6 +23,7 @@
  */
 #include <linux/module.h>
 #include <linux/xfrm.h>
+#include <linux/slab.h>
 #include <linux/rculist.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
index f9759b54a6debfca3d86830bb223fd250f7426ba..da3d21c41d9064cb691342dfe23df37460766b84 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/net.h>
 #include <linux/netdevice.h>
 #include <linux/uio.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/smp_lock.h>
 #include <linux/socket.h>
index e16c11423527df9832485de4479eb019d51d9c1b..30f4519b092f546aad806520280bec883165a9c2 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/list.h>
 #include <linux/route.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <net/ipx.h>
index 10093aab6173e48a0a69faf775d1fa78f3367fdc..2a4efcea342389ef054f1c3f42558448e8fa22bf 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/smp_lock.h>
 #include <linux/socket.h>
 #include <linux/sockios.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/net.h>
 #include <linux/irda.h>
index a6f99b5a14995ff62e5620f042ca0821f3552cc3..c1c8ae939126027c5d3ddb6192d2da88677da419 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/socket.h>
 #include <linux/fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irlmp.h>
index 018c92941aba4ef3f8a1fd31866f32f499e03504..e97082017f4fabfd05ed2c3823f31c5e9fa1ee7e 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irmod.h>
index 7ba96618660e349de2253473d6701ab8bbad9613..08fb54dc8c412cbcb04721ca7df9f034ff06dcbf 100644 (file)
@@ -31,6 +31,7 @@
  ********************************************************************/
 
 #include <linux/init.h>
+#include <linux/gfp.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irlmp.h>
index d57aefd9fe7780c53a2ae4e0698d135e963e6261..e2e893b474e92b356454e8b7c674196ac465e7ee 100644 (file)
@@ -28,6 +28,7 @@
  *
  ********************************************************************/
 
+#include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 
index 8b85d774e47fe5dbe2d526eaff6bdf7215a2057b..faa82ca2dfdcf9c8cff71b486434997d832c87cf 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/termios.h>
index bf92e147344736bd39a4fce6b3977bc5c8ee1739..25cc2e6951589b3bced6d14118ec6414d27eb947 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/tty.h>
 #include <linux/kmod.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include <asm/ioctls.h>
 #include <asm/uaccess.h>
index 294e34d3517cb87cc191c1cfec9d7b39de30245d..79a1e5a23e10e6e0aa1b14837bdfbe29cf7d7000 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
index a301cbd9378511a9b947d3c38b4f40b100c7dd83..703774e29e322966ec4de6cf990bbc427c3ff221 100644 (file)
@@ -24,6 +24,8 @@
  *
  ********************************************************************/
 
+#include <linux/slab.h>
+
 #include <net/irda/irda.h>
 #include <net/irda/irlmp.h>
 #include <net/irda/iriap.h>
index 99ebb96f13869868bba080779354390c3284f5a9..f07ed9fd5792fabe7e1cffc1016330ee01a0fab8 100644 (file)
@@ -22,6 +22,7 @@
  *
  ********************************************************************/
 
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/socket.h>
 #include <linux/module.h>
index 42f7d960d055ca7d8ab0784ddde43ad183943dd2..7ed3af95793548c4941313f7ce195d286252f601 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/netdevice.h>
index e486dc89ea595e94d9973e5a0ef18c6f1b410099..a788f9e9427d2c1c127d411adc8b06eb9d19ba87 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/proc_fs.h>
index 3f81f81b2dfaba760a93f70bd6492f3ab32d4c27..5cf5e6c872bb361a1be8a919e5092c68135fa009 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/byteorder.h>
index 94a9884d7146137b56665f20cc8ea078a86596b7..d434c888074509f37d414bb93c30664f1d678cc3 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irlap_event.h>
index 7af2e74deda823bf587d298d1f7bab58d8484dd3..688222cbf55be317ecf187cc15d6a4144bded236 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/if_ether.h>
 #include <linux/netdevice.h>
 #include <linux/irda.h>
+#include <linux/slab.h>
 
 #include <net/pkt_sched.h>
 #include <net/sock.h>
index b26dee784aba87be8eb2688567dfc31652173055..df18ab4b6c5e8dffd4ec2532851a88cd3d6eb9f2 100644 (file)
@@ -11,6 +11,7 @@
 #include "irnet_irda.h"                /* Private header */
 #include <linux/sched.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 /*
index 6b3602de359ae556761ec10effa42151c0a92817..6a1a202710c51203597fc291244d1a5d9b5df1d6 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include "irnet_ppp.h"         /* Private header */
 /* Please put other headers in irnet.h - Thanks */
index 69b5b75f5431c85f81312edf9b66fde090085231..6c7c4b92e4f8ec0e5a2aad62b33a6ada0d813c0e 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/socket.h>
 #include <linux/irda.h>
+#include <linux/gfp.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/irda/irda.h>
index ba01938becb5b08bf5c258df54f513392e8cd2ce..849aaf0dabb5ec8a1be02ab471a84d6d736b5f06 100644 (file)
  * Jean II
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <net/irda/irda.h>
 #include <net/irda/irqueue.h>
index 9cb79f95bf63953c9bcdf2b379b4ccbb37089ff5..47db1d8a0d92088a5982b2db471c9fce05001de2 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
index 368707882647bb83293a5be6536b00d6ccca2982..ba9a3fcc2fedff60c23b3cae9e394dca5890bdf0 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/in6.h>
 #include <linux/proc_fs.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 #include <net/xfrm.h>
@@ -2129,10 +2130,9 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
        int err;
 
        out_skb = pfkey_xfrm_policy2msg_prep(xp);
-       if (IS_ERR(out_skb)) {
-               err = PTR_ERR(out_skb);
-               goto out;
-       }
+       if (IS_ERR(out_skb))
+               return PTR_ERR(out_skb);
+
        err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
        if (err < 0)
                return err;
@@ -2148,7 +2148,6 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
        out_hdr->sadb_msg_seq = c->seq;
        out_hdr->sadb_msg_pid = c->pid;
        pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
-out:
        return 0;
 
 }
index bda96d18fd98388e87e8aef8a61bbcbeb7ff9798..d5d8d555c410dbe68b2b05a6a21284e1c2a44b1a 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/inet.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
index 6762e7c751ebe7342fb96cdaca6ee0f8f629d2e1..21904a002449ca797fb02bf9603d92a73cbfd331 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/inet.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
index 339cc5f2684f1008d930c0c2ecf943d537d9294f..c75a79540f9f476b2247a4c96d6004625f528201 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/net.h>
 #include <linux/inet.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
index b827f47ac133c64f71e9934b5acc086505a88a79..43a2a7fb327b3888dd726dc3325408c24255a16a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/net.h>
 #include <linux/inet.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
index e35d907fba2c20e5b931751584ecacd68f0c4c9e..2db6a9f759130f4277739619018713c521b4522f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/llc.h>
 #include <net/llc_sap.h>
 #include <net/llc_pdu.h>
index 86d6985b9d49790e9e4ec5302602b0ef8c025130..ea225bd2672c03947dcc01b581a14e1a2b792e68 100644 (file)
@@ -18,6 +18,7 @@
  * See the GNU General Public License for more details.
  */
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/llc_conn.h>
 #include <net/llc_sap.h>
 #include <net/sock.h>
index a12144da7974df50ae457dcda84d028f26965f85..ba137a6a224de73f2dc671ff93de11ab291520ee 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/llc_sap.h>
 #include <net/llc_conn.h>
 #include <net/sock.h>
index a89917130a7bd76e4aa9e64c4b2c8a1b78b6723a..25c31c0a3fdbeab3bbf2e2cb6604594bfa758298 100644 (file)
@@ -11,6 +11,7 @@
  *
  * See the GNU General Public License for more details.
  */
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
index 57ad974e4d9490b84cca490e2a42d4150f30c81d..f99687439139faf68f2464a39bd48d6100481dca 100644 (file)
@@ -12,6 +12,7 @@
  * See the GNU General Public License for more details.
  */
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/llc.h>
 #include <net/llc_pdu.h>
index ad6e6e1cf22fce1eefa43d1726537d3b5bf644dc..a432f0ec051cb25a000d11e2e7e868cd8ff5dc3b 100644 (file)
@@ -23,6 +23,7 @@
 #include <net/sock.h>
 #include <net/tcp_states.h>
 #include <linux/llc.h>
+#include <linux/slab.h>
 
 static int llc_mac_header_len(unsigned short devtype)
 {
index 83da1333949011d8ae4ac877181365795e6d67fa..e4dae0244d76b677ee89ef0b35dd51ccf7807e06 100644 (file)
@@ -13,6 +13,7 @@
  */
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <net/llc.h>
 #include <net/llc_sap.h>
 #include <net/llc_conn.h>
index a978e666ed6f06a79fa4b7529feec540a7ab2908..f9516a27e233ba09ebf1d69a81968552d47902ee 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
index 5538e1b4a697740535b0be966a90719cec3dafc5..96d25348aa59dcd830a03f521b3dc817397d7d5c 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
index b7116ef84a3b019898ddbe6bc5a64cac3e34bcae..edc872e22c9b6211fcd32342296462d871e64f88 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/ieee80211.h>
 #include <linux/nl80211.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <linux/rcupdate.h>
 #include <net/cfg80211.h>
index d12e743cb4e1b7716ddd5beeed9954d43e75c9cb..97c9e46e859e9dbd081d5964437c9db73440441a 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/kobject.h>
+#include <linux/slab.h>
 #include "ieee80211_i.h"
 #include "key.h"
 #include "debugfs.h"
index b4ddb2f839146a2b48a62a5e3df2b9f6c44dc1df..83d4289d954bfacd1db317ec71b709623b44fa82 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <linux/notifier.h>
 #include <net/mac80211.h>
 #include <net/cfg80211.h>
index f3e94248674948afc3c1b29be81c9b1ce1f234f3..e2976da4e0d9c7e86b21557c1571e2dd7e449db6 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/if_ether.h>
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
index 0793d7a8d74323f348abce62003471cdb8ac6e59..e08fa8eda1b36aabfda2b591b31ac4f2fe641817 100644 (file)
@@ -10,6 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
 #include <linux/netdevice.h>
index 8160d9c5372ea09e8fbc6c01b54c3e00703d3188..e8f6e3b252d8b8ee3ef4210695dfc44283534bc4 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/list.h>
 #include <linux/rcupdate.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "ieee80211_i.h"
 #include "driver-ops.h"
index 162a643f16b69b92d039c9216d9147c0194ca735..063aad944246678d7ebaa4392b42abbb07a4a055 100644 (file)
@@ -8,6 +8,7 @@
 
 /* just for IFNAMSIZ */
 #include <linux/if.h>
+#include <linux/slab.h>
 #include "led.h"
 
 void ieee80211_led_rx(struct ieee80211_local *local)
index 61080c5fad50f2ef859ac6461d6168d69cddaaa6..58e3e3a61d99eb254763607b1a98fcde26219669 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include "ieee80211_i.h"
 #include "mesh.h"
index ce84237ebad3b493d5c5d8dc3ea18662395dbfb7..fefc45c4b4e8cad4a792d9f6787284270f3510bd 100644 (file)
@@ -7,6 +7,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include "mesh.h"
 
 #ifdef CONFIG_MAC80211_VERBOSE_MHWMP_DEBUG
@@ -391,7 +392,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
                                if (SN_GT(mpath->sn, orig_sn) ||
                                    (mpath->sn == orig_sn &&
                                     action == MPATH_PREQ &&
-                                    new_metric > mpath->metric)) {
+                                    new_metric >= mpath->metric)) {
                                        process = false;
                                        fresh_info = false;
                                }
@@ -611,7 +612,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
 
        mesh_path_sel_frame_tx(MPATH_PREP, flags, orig_addr,
                cpu_to_le32(orig_sn), 0, target_addr,
-               cpu_to_le32(target_sn), mpath->next_hop->sta.addr, hopcount,
+               cpu_to_le32(target_sn), next_hop, hopcount,
                ttl, cpu_to_le32(lifetime), cpu_to_le32(metric),
                0, sdata);
        rcu_read_unlock();
index 2312efe04c62ea7116ca6de8302fa76f47b3e56a..181ffd6efd816e859d92274d459da41ab749c1b3 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/etherdevice.h>
 #include <linux/list.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <net/mac80211.h>
index 1a29c4a8139e0ce7d3338a887e5d50836004ae1d..7b7080e2b49f47a1dcac316432341b89b3a9a5cb 100644 (file)
@@ -6,6 +6,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/random.h>
 #include "ieee80211_i.h"
index be5f723d643acbb4146edd3bc7fbbcdd7f943b6d..c8cd169fc10ec7abb114fa566ff18d335efe78da 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/pm_qos_params.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include <asm/unaligned.h>
 
index 0b299d236fa1a3bbd74256e7386ecc2d92e7e940..6d0bd198af19d949841eaa94489c301e75f4cfa8 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/kernel.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include "rate.h"
 #include "ieee80211_i.h"
 #include "debugfs.h"
index 6e5d68b4e427a232dfeebcfe98f666bb2618bb1c..818abfae900773f27f39045a8163469bc8fed82f 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/debugfs.h>
 #include <linux/random.h>
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "rate.h"
 #include "rc80211_minstrel.h"
index a715d9454f640846ccb24cc055d89eb448267840..0e1f12b1b6dd1ee9971df741cbc8855e6bf05e16 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/skbuff.h>
 #include <linux/debugfs.h>
 #include <linux/ieee80211.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "rc80211_minstrel.h"
 
index 2652a374974eb786cb80cd90ae42e5293840e054..aeda65466f3eb60a4dcb37cd8a2cae152ffe794c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include "rate.h"
 #include "mesh.h"
index 45667054a5f305308a8bf1faff8b9def3b8b0749..47438b4a9af52d33589e9cc1a695f77a8461d987 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/netdevice.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 
 #include <net/mac80211.h>
 #include "rate.h"
index b5c48de81d8b89009b4cb0fa427e165431221958..f0accf622cd71c023c222487065c998dc0ff85b7 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/jiffies.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
index b822dce9786706e65a30480aa97b1cfd031211e6..85507bd9e34109d3f06bb9248322b3b1ad7f615a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/if_arp.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 
 #include "ieee80211_i.h"
index cbe53ed4fb0b14b9f95a8db5b21e73d673d9b09a..cfc473e1b0509ca1850d61a49b5dd59b23ecee55 100644 (file)
@@ -1991,6 +1991,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
 void ieee80211_tx_pending(unsigned long data)
 {
        struct ieee80211_local *local = (struct ieee80211_local *)data;
+       struct ieee80211_sub_if_data *sdata;
        unsigned long flags;
        int i;
        bool txok;
@@ -2029,6 +2030,11 @@ void ieee80211_tx_pending(unsigned long data)
                        if (!txok)
                                break;
                }
+
+               if (skb_queue_empty(&local->pending[i]))
+                       list_for_each_entry_rcu(sdata, &local->interfaces, list)
+                               netif_tx_wake_queue(
+                                       netdev_get_tx_queue(sdata->dev, i));
        }
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 
index c453226f06b2758377132ddb83e179c4c61ff921..53af570474351d69bbe7e18f15d60be377f4b159 100644 (file)
@@ -279,13 +279,13 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
                /* someone still has this queue stopped */
                return;
 
-       if (!skb_queue_empty(&local->pending[queue]))
+       if (skb_queue_empty(&local->pending[queue])) {
+               rcu_read_lock();
+               list_for_each_entry_rcu(sdata, &local->interfaces, list)
+                       netif_tx_wake_queue(netdev_get_tx_queue(sdata->dev, queue));
+               rcu_read_unlock();
+       } else
                tasklet_schedule(&local->tx_pending_tasklet);
-
-       rcu_read_lock();
-       list_for_each_entry_rcu(sdata, &local->interfaces, list)
-               netif_tx_wake_queue(netdev_get_tx_queue(sdata->dev, queue));
-       rcu_read_unlock();
 }
 
 void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
@@ -1097,9 +1097,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
                 */
                res = drv_start(local);
                if (res) {
-                       WARN(local->suspended, "Harware became unavailable "
-                            "upon resume. This is could be a software issue"
-                            "prior to suspend or a hardware issue\n");
+                       WARN(local->suspended, "Hardware became unavailable "
+                            "upon resume. This could be a software issue "
+                            "prior to suspend or a hardware issue.\n");
                        return res;
                }
 
index 5d745f2d72364fcc8289cd104856c2150d7ec61d..5f3a4113bda1682bb0d30f0eaebd6f153037e3b5 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/err.h>
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include <net/mac80211.h>
index 1e1ea3007b06d8939cebd9992d266f463a07555b..15e1ba931b87616ab1303ff50eb13f2b3c120fc2 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
 #include <linux/crc32.h>
+#include <linux/slab.h>
 #include <net/mac80211.h>
 #include <asm/unaligned.h>
 
index f4971cd45c64f53eaa248680ca965a471abb7564..0adbcc941ac917952d9eb7ed9308e23c4644c720 100644 (file)
@@ -9,10 +9,10 @@
 
 #include <linux/netdevice.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/compiler.h>
 #include <linux/ieee80211.h>
+#include <linux/gfp.h>
 #include <asm/unaligned.h>
 #include <net/mac80211.h>
 
index 60ec4e4badaa3b48bb680b215f8795925225e5f3..78b505d33bfb42cdf1033be323c2fdb1a359a833 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/inetdevice.h>
 #include <linux/proc_fs.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 
index 3c7e42735b60006584ab8748fc224662f954fbff..1cb0e834f8ff36c784e735eab7c3aae36ea7329f 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/protocol.h>
 #include <net/tcp.h>
index 60bb41a8d8d456829ae5b50d33c88a348aef97e5..d8f7e8ef67b41e2bedb7b47cf81070d9cd5cb390 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/proc_fs.h>             /* for proc_net_* */
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/jhash.h>
 #include <linux/random.h>
index 44590887a92cfdfb7ed662d47b532456d68ceb3d..1cd6e3fd058b71b6f49a51589a52451944e177e0 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/tcp.h>
 #include <linux/sctp.h>
 #include <linux/icmp.h>
+#include <linux/slab.h>
 
 #include <net/ip.h>
 #include <net/tcp.h>
index 7ee9c3426f44a24b141492b266223b319e8a3f95..36dc1d88c2fa56cff3f29566965de8c80e9e9d99 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/workqueue.h>
 #include <linux/swap.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
index fe3e18834b911c1b388d253d76eeaa68dfa464d7..95fd0d14200b338a41e0a580e890e85ea5ec5e1e 100644 (file)
@@ -39,6 +39,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
index 702b53ca937ccc4277c8dfee736616bb018772f3..ff28801962e05883d1a469ac3b2848b51e4429fd 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/sysctl.h>
index 73f38ea98f254734aa9da2931d4d93713f45fd38..2c7f185dfae464c09bf4c2146dda87063ad00314 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/netfilter.h>
+#include <linux/gfp.h>
 #include <net/protocol.h>
 #include <net/tcp.h>
 #include <asm/unaligned.h>
index 1b9370db23054b963d5c97555005a818efb6812f..94a45213faa6853a87b75d6143bdb99a3c5521f4 100644 (file)
@@ -43,6 +43,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
index caa58fa1438a4d081257367782c9860f7b3514f3..535dc2b419d81f33f18fd7eea98d80bae07ba9cb 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/skbuff.h>
 #include <linux/jiffies.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 
 /* for sysctl */
 #include <linux/fs.h>
index 0e584553819da8ce77e888369b0912a6b1ba0780..7fc49f4cf5ad63905f4cb0a175b3e5124765002e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
+#include <linux/gfp.h>
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <net/protocol.h>
index 8e6cfd36e6f0d7370ef817b7da8ffae070bc201e..e6cc174fbc06d4410a54c1e09021811e5773e81c 100644 (file)
@@ -36,6 +36,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
index 3c115fc197843287d9bf0dff379e6fbdc4f37c02..30db633f88f10c948e3e15c01ffb2b37bd0c4d13 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/net.h>
 #include <linux/gcd.h>
 
index 223b5018c7dc658d876f4b3c749d1377b57931b4..e450cd6f4eb5794c385bc0f63fbe76cf61393fa3 100644 (file)
@@ -17,6 +17,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/tcp.h>                  /* for tcphdr */
 #include <net/ip.h>
 #include <net/tcp.h>                    /* for csum_tcpudp_magic */
index 018f90db511c673fa633eff0023e888be049d2f3..ab81b380eae6814934de4318c67e6cd4d886ca1f 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
 
index 07d9d8857e5db50b2d80bca709e137c4472b8724..372e80f07a8160636a9f8530bbd6e05a0ec5664f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/in.h>
 #include <linux/udp.h>
 #include <linux/netfilter.h>
+#include <linux/gfp.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_expect.h>
index d5a9bcd7d61b9695569bddd5a62b1874978da493..f516961a83b44f9a2795dae259be5af3cf399abf 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/percpu.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
index f0732aa18e4fdd7e68fe7f791e12f9790a8fc7bd..2ae3169e76330d6565d9f21e8a99f452e07ea8e8 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/moduleparam.h>
 #include <linux/netfilter.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <linux/ipv6.h>
 #include <linux/ctype.h>
 #include <linux/inet.h>
index a1c8dd917e1202b375f1a6d4f788880035b78a41..a487c80380445a1c718c0f89cb984d62f987abaa 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/inet.h>
 #include <linux/in.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <linux/udp.h>
 #include <linux/tcp.h>
 #include <linux/skbuff.h>
index 4509fa6726f8739f642f6127c2fd8ba59c6e896e..59e1a4cd4e8b8b115c77e788fe2b821d50f32f65 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/skbuff.h>
 #include <linux/vmalloc.h>
 #include <linux/stddef.h>
-#include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
index 8bd98c84f77e7962c55dee04084c8ee05128f1bd..7673930ca3423fadd838d4f17d26aceda27061e7 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_expect.h>
index 2b2af631d2b870d3c9f4f81146833fd4a93f2cf9..afc52f2ee4ac1f906b1daf2166faf9cff9256399 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/netlink.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <net/netlink.h>
@@ -582,7 +583,9 @@ nla_put_failure:
 nlmsg_failure:
        kfree_skb(skb);
 errout:
-       nfnetlink_set_err(net, 0, group, -ENOBUFS);
+       if (nfnetlink_set_err(net, 0, group, -ENOBUFS) > 0)
+               return -ENOBUFS;
+
        return 0;
 }
 #endif /* CONFIG_NF_CONNTRACK_EVENTS */
index 1a4568bf7ea515ee790b700dfe85a31c38b8bdc6..a44fa75b51783beefa9c44c93b70fba619df5d78 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/types.h>
 #include <linux/netfilter.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/skbuff.h>
 #include <linux/vmalloc.h>
index 9a281554937530d2b2b7817472c95c32586ad18f..5292560d6d4aedbfa33c1369a66fc2d72657df8f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/spinlock.h>
 #include <linux/skbuff.h>
 #include <linux/dccp.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
index d899b1a699403f300ee895f359f51b901d84c7bf..cf616e55ca4193a54c6f949755428649306cfa5f 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/in.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/dst.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
index dcfecbb81c4617784178009bc02de37b9a32cb00..d9e27734b2a223adab2f73b199431df97e022b70 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <linux/tcp.h>
 #include <net/netfilter/nf_conntrack.h>
index 24a42efe62ef630ba48496b20a3a2bdfdb482d9e..faa8eb3722b96572edfd82298e275f10053e697d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <linux/netfilter.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/proc_fs.h>
index ba095fd014e571f554567766a034df237a1bdbe1..c49ef219899edd130cad88524bf7efdf73efe916 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
index 8eb0cc23ada3760a79a0eaefa76ada8745acd4f2..6afa3d52ea5f1d7af8d2be47db8ece008429eeb6 100644 (file)
@@ -113,9 +113,9 @@ int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid,
 }
 EXPORT_SYMBOL_GPL(nfnetlink_send);
 
-void nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error)
+int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error)
 {
-       netlink_set_err(net->nfnl, pid, group, error);
+       return netlink_set_err(net->nfnl, pid, group, error);
 }
 EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 
index d9b8fb8ab340b5a97e57073abdfe611f7b0c1c74..203643fb2c524ade67aedd22bc5f3ee8221ee884 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/list.h>
 #include <linux/jhash.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netfilter/nf_log.h>
 #include <net/netfilter/nfnetlink_log.h>
index 7ba4abc405c9d342ce7cd4bd76bd294e554ae6dc..e70a6ef1f4f2dfa81cc6e4121d429771933f4bc5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/notifier.h>
 #include <linux/netdevice.h>
 #include <linux/netfilter.h>
index 0a12cedfe9e3da547981cb6b5251a72a663ece2a..665f5beef6ad73d2caee6cd882611b4ce5dfee61 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/vmalloc.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 
 #include <linux/netfilter/x_tables.h>
index 61c50fa8470374c9b76580e3dfbee045ee090837..ee18b231b9508826af1fd70e6003c4b22d695ec9 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/skbuff.h>
 #include <linux/selinux.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
index 8ff7843bb92169b9fa2f9dbb65c90074c329c2f6..3271c8e52153c929f0d1da15dcff7d6ba6f70f87 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/netfilter/x_tables.h>
+#include <linux/slab.h>
 #include <linux/leds.h>
 #include <linux/mutex.h>
 
index 87ae97e5516f91413c7ca7decdffc976263787b1..d16d55df4f616444b3fb7368cf0c91a1a2021459 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/jhash.h>
 #include <linux/rtnetlink.h>
 #include <linux/random.h>
+#include <linux/slab.h>
 #include <net/gen_stats.h>
 #include <net/netlink.h>
 
index 0e357ac9a2a831b85fee911847b4c2427d8255d6..c5f4b9919e9a016ef3f3428440e2446571293920 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/ip.h>
+#include <linux/gfp.h>
 #include <linux/ipv6.h>
 #include <linux/tcp.h>
 #include <net/dst.h>
index 26997ce90e48bf861b1cf3fcac712b6889b9f8e7..388ca459609846e9f0f92b84771331c1e58bd206 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/random.h>
index 0989f29ade2ea0e559b53e7afac854a2bb09d54a..395af5943ffdef6c888bbe5e87fb225e60ec02cd 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <net/ip.h>
 #include <linux/dccp.h>
index 9e9c48963942ad39b722be5790c8a4b01750b1d4..215a64835de82748af7db9682ba69aa3104fde39 100644 (file)
@@ -493,6 +493,7 @@ static void hashlimit_ipv6_mask(__be32 *i, unsigned int p)
        case 64 ... 95:
                i[2] = maskl(i[2], p - 64);
                i[3] = 0;
+               break;
        case 96 ... 127:
                i[3] = maskl(i[3], p - 96);
                break;
@@ -879,7 +880,8 @@ static void dl_seq_stop(struct seq_file *s, void *v)
        struct xt_hashlimit_htable *htable = s->private;
        unsigned int *bucket = (unsigned int *)v;
 
-       kfree(bucket);
+       if (!IS_ERR(bucket))
+               kfree(bucket);
        spin_unlock_bh(&htable->lock);
 }
 
index a0ca5339af41523a174f117a7307e46833711c42..e5d7e1ffb1a46be8b7a0a21897f4da1a3e1df6cd 100644 (file)
@@ -6,6 +6,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
index 390b7d09fe512f2957769ace3b8a579b64f64086..2d5562498c435007efec01d0bc8fd82fe074d63b 100644 (file)
@@ -4,6 +4,7 @@
  * Sam Johnston <samj@samj.net>
  */
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 
 #include <linux/netfilter/x_tables.h>
index 7073dbb8100c83fb163498453d814beed8fd2dbe..834b736857cb2160b54951234b7f62609903f6fc 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/bitops.h>
 #include <linux/skbuff.h>
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 
@@ -267,7 +268,7 @@ recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
                for (i = 0; i < e->nstamps; i++) {
                        if (info->seconds && time_after(time, e->stamps[i]))
                                continue;
-                       if (info->hit_count && ++hits >= info->hit_count) {
+                       if (!info->hit_count || ++hits >= info->hit_count) {
                                ret = !ret;
                                break;
                        }
index d8c0f8f1a78e3a2c5c6ae96edb94f76258a410cf..937ce0633e99c7c926144a882fea550d2b232a3a 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/spinlock.h>
 #include <linux/skbuff.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter/xt_statistic.h>
 #include <linux/netfilter/x_tables.h>
index b4d7741113115330bc4ae6d5a6df35d6ae14f4cd..96801ffd8af8d79c33e2d30fdd62c39ade795265 100644 (file)
@@ -7,6 +7,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
index e639298bc9c810a77961113b67a5078fee9bbd6f..5f14c8462e30182a8fd5ad7577d5e3e37d9b31d9 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/string.h>
 #include <linux/skbuff.h>
 #include <linux/audit.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
index 0bfeaab88ef556852766c2c355f28233bff47bef..d37b7f80fa374a648e20a50d83b95f033dd9aebe 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/audit.h>
+#include <linux/slab.h>
 #include <net/netlabel.h>
 #include <net/cipso_ipv4.h>
 #include <asm/bug.h>
@@ -50,9 +51,12 @@ struct netlbl_domhsh_tbl {
 };
 
 /* Domain hash table */
-/* XXX - updates should be so rare that having one spinlock for the entire
- * hash table should be okay */
+/* updates should be so rare that having one spinlock for the entire hash table
+ * should be okay */
 static DEFINE_SPINLOCK(netlbl_domhsh_lock);
+#define netlbl_domhsh_rcu_deref(p) \
+       rcu_dereference_check(p, rcu_read_lock_held() || \
+                                lockdep_is_held(&netlbl_domhsh_lock))
 static struct netlbl_domhsh_tbl *netlbl_domhsh = NULL;
 static struct netlbl_dom_map *netlbl_domhsh_def = NULL;
 
@@ -106,7 +110,8 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
  * Description:
  * This is the hashing function for the domain hash table, it returns the
  * correct bucket number for the domain.  The caller is responsibile for
- * calling the rcu_read_[un]lock() functions.
+ * ensuring that the hash table is protected with either a RCU read lock or the
+ * hash table lock.
  *
  */
 static u32 netlbl_domhsh_hash(const char *key)
@@ -120,7 +125,7 @@ static u32 netlbl_domhsh_hash(const char *key)
 
        for (iter = 0, val = 0, len = strlen(key); iter < len; iter++)
                val = (val << 4 | (val >> (8 * sizeof(u32) - 4))) ^ key[iter];
-       return val & (rcu_dereference(netlbl_domhsh)->size - 1);
+       return val & (netlbl_domhsh_rcu_deref(netlbl_domhsh)->size - 1);
 }
 
 /**
@@ -130,7 +135,8 @@ static u32 netlbl_domhsh_hash(const char *key)
  * Description:
  * Searches the domain hash table and returns a pointer to the hash table
  * entry if found, otherwise NULL is returned.  The caller is responsibile for
- * the rcu hash table locks (i.e. the caller much call rcu_read_[un]lock()).
+ * ensuring that the hash table is protected with either a RCU read lock or the
+ * hash table lock.
  *
  */
 static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
@@ -141,7 +147,7 @@ static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
 
        if (domain != NULL) {
                bkt = netlbl_domhsh_hash(domain);
-               bkt_list = &rcu_dereference(netlbl_domhsh)->tbl[bkt];
+               bkt_list = &netlbl_domhsh_rcu_deref(netlbl_domhsh)->tbl[bkt];
                list_for_each_entry_rcu(iter, bkt_list, list)
                        if (iter->valid && strcmp(iter->domain, domain) == 0)
                                return iter;
@@ -159,8 +165,8 @@ static struct netlbl_dom_map *netlbl_domhsh_search(const char *domain)
  * Searches the domain hash table and returns a pointer to the hash table
  * entry if an exact match is found, if an exact match is not present in the
  * hash table then the default entry is returned if valid otherwise NULL is
- * returned.  The caller is responsibile for the rcu hash table locks
- * (i.e. the caller much call rcu_read_[un]lock()).
+ * returned.  The caller is responsibile ensuring that the hash table is
+ * protected with either a RCU read lock or the hash table lock.
  *
  */
 static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain)
@@ -169,7 +175,7 @@ static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain)
 
        entry = netlbl_domhsh_search(domain);
        if (entry == NULL) {
-               entry = rcu_dereference(netlbl_domhsh_def);
+               entry = netlbl_domhsh_rcu_deref(netlbl_domhsh_def);
                if (entry != NULL && !entry->valid)
                        entry = NULL;
        }
@@ -306,8 +312,11 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
        struct netlbl_af6list *tmp6;
 #endif /* IPv6 */
 
+       /* XXX - we can remove this RCU read lock as the spinlock protects the
+        *       entire function, but before we do we need to fixup the
+        *       netlbl_af[4,6]list RCU functions to do "the right thing" with
+        *       respect to rcu_dereference() when only a spinlock is held. */
        rcu_read_lock();
-
        spin_lock(&netlbl_domhsh_lock);
        if (entry->domain != NULL)
                entry_old = netlbl_domhsh_search(entry->domain);
index 6ce00205f3425cd079b7a64526db259f9ae58d47..1b83e0009d8d4b7fa965dc21552699b905a2ca04 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/audit.h>
 #include <linux/in.h>
 #include <linux/in6.h>
index 8203623e65ad3c09f94869d6c8b9358d7f04c4bf..998e85e895d04e1fc2b26cc856d09fb141cd35a0 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/skbuff.h>
 #include <linux/in.h>
 #include <linux/in6.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
index 852d9d7976b9553073973bbba983807e52d1bdf6..a3d64aabe2f73d6bbd90b12fbbdb6ae908d34447 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/notifier.h>
 #include <linux/netdevice.h>
 #include <linux/security.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
@@ -114,6 +115,9 @@ struct netlbl_unlhsh_walk_arg {
 /* updates should be so rare that having one spinlock for the entire
  * hash table should be okay */
 static DEFINE_SPINLOCK(netlbl_unlhsh_lock);
+#define netlbl_unlhsh_rcu_deref(p) \
+       rcu_dereference_check(p, rcu_read_lock_held() || \
+                                lockdep_is_held(&netlbl_unlhsh_lock))
 static struct netlbl_unlhsh_tbl *netlbl_unlhsh = NULL;
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_def = NULL;
 
@@ -235,15 +239,13 @@ static void netlbl_unlhsh_free_iface(struct rcu_head *entry)
  * Description:
  * This is the hashing function for the unlabeled hash table, it returns the
  * bucket number for the given device/interface.  The caller is responsible for
- * calling the rcu_read_[un]lock() functions.
+ * ensuring that the hash table is protected with either a RCU read lock or
+ * the hash table lock.
  *
  */
 static u32 netlbl_unlhsh_hash(int ifindex)
 {
-       /* this is taken _almost_ directly from
-        * security/selinux/netif.c:sel_netif_hasfn() as they do pretty much
-        * the same thing */
-       return ifindex & (rcu_dereference(netlbl_unlhsh)->size - 1);
+       return ifindex & (netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->size - 1);
 }
 
 /**
@@ -253,7 +255,8 @@ static u32 netlbl_unlhsh_hash(int ifindex)
  * Description:
  * Searches the unlabeled connection hash table and returns a pointer to the
  * interface entry which matches @ifindex, otherwise NULL is returned.  The
- * caller is responsible for calling the rcu_read_[un]lock() functions.
+ * caller is responsible for ensuring that the hash table is protected with
+ * either a RCU read lock or the hash table lock.
  *
  */
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
@@ -263,7 +266,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
        struct netlbl_unlhsh_iface *iter;
 
        bkt = netlbl_unlhsh_hash(ifindex);
-       bkt_list = &rcu_dereference(netlbl_unlhsh)->tbl[bkt];
+       bkt_list = &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt];
        list_for_each_entry_rcu(iter, bkt_list, list)
                if (iter->valid && iter->ifindex == ifindex)
                        return iter;
@@ -271,33 +274,6 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
        return NULL;
 }
 
-/**
- * netlbl_unlhsh_search_iface_def - Search for a matching interface entry
- * @ifindex: the network interface
- *
- * Description:
- * Searches the unlabeled connection hash table and returns a pointer to the
- * interface entry which matches @ifindex.  If an exact match can not be found
- * and there is a valid default entry, the default entry is returned, otherwise
- * NULL is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
- *
- */
-static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface_def(int ifindex)
-{
-       struct netlbl_unlhsh_iface *entry;
-
-       entry = netlbl_unlhsh_search_iface(ifindex);
-       if (entry != NULL)
-               return entry;
-
-       entry = rcu_dereference(netlbl_unlhsh_def);
-       if (entry != NULL && entry->valid)
-               return entry;
-
-       return NULL;
-}
-
 /**
  * netlbl_unlhsh_add_addr4 - Add a new IPv4 address entry to the hash table
  * @iface: the associated interface entry
@@ -308,8 +284,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface_def(int ifindex)
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
  * interface entry specified by @iface.  On success zero is returned, otherwise
- * a negative value is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
+ * a negative value is returned.
  *
  */
 static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
@@ -349,8 +324,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
  * interface entry specified by @iface.  On success zero is returned, otherwise
- * a negative value is returned.  The caller is responsible for calling the
- * rcu_read_[un]lock() functions.
+ * a negative value is returned.
  *
  */
 static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
@@ -391,8 +365,7 @@ static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
  * Description:
  * Add a new, empty, interface entry into the unlabeled connection hash table.
  * On success a pointer to the new interface entry is returned, on failure NULL
- * is returned.  The caller is responsible for calling the rcu_read_[un]lock()
- * functions.
+ * is returned.
  *
  */
 static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
@@ -415,10 +388,10 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
                if (netlbl_unlhsh_search_iface(ifindex) != NULL)
                        goto add_iface_failure;
                list_add_tail_rcu(&iface->list,
-                                 &rcu_dereference(netlbl_unlhsh)->tbl[bkt]);
+                            &netlbl_unlhsh_rcu_deref(netlbl_unlhsh)->tbl[bkt]);
        } else {
                INIT_LIST_HEAD(&iface->list);
-               if (rcu_dereference(netlbl_unlhsh_def) != NULL)
+               if (netlbl_unlhsh_rcu_deref(netlbl_unlhsh_def) != NULL)
                        goto add_iface_failure;
                rcu_assign_pointer(netlbl_unlhsh_def, iface);
        }
@@ -548,8 +521,7 @@ unlhsh_add_return:
  *
  * Description:
  * Remove an IP address entry from the unlabeled connection hash table.
- * Returns zero on success, negative values on failure.  The caller is
- * responsible for calling the rcu_read_[un]lock() functions.
+ * Returns zero on success, negative values on failure.
  *
  */
 static int netlbl_unlhsh_remove_addr4(struct net *net,
@@ -611,8 +583,7 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
  *
  * Description:
  * Remove an IP address entry from the unlabeled connection hash table.
- * Returns zero on success, negative values on failure.  The caller is
- * responsible for calling the rcu_read_[un]lock() functions.
+ * Returns zero on success, negative values on failure.
  *
  */
 static int netlbl_unlhsh_remove_addr6(struct net *net,
@@ -1547,8 +1518,10 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
        struct netlbl_unlhsh_iface *iface;
 
        rcu_read_lock();
-       iface = netlbl_unlhsh_search_iface_def(skb->skb_iif);
+       iface = netlbl_unlhsh_search_iface(skb->skb_iif);
        if (iface == NULL)
+               iface = rcu_dereference(netlbl_unlhsh_def);
+       if (iface == NULL || !iface->valid)
                goto unlabel_getattr_nolabel;
        switch (family) {
        case PF_INET: {
index 68706b4e3bf8a5d800510854a074537c762cf73d..a3fd75ac3fa50187bd7ff6924700569b2b1cebc4 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/audit.h>
 #include <linux/tty.h>
 #include <linux/security.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
index 320d0423a24062fd58aaf6340b021f7be587f581..795424396aff62fba6971aaff0eb6631965ce481 100644 (file)
@@ -683,6 +683,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
        struct netlink_sock *nlk = nlk_sk(sk);
        struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
 
+       if (alen < sizeof(addr->sa_family))
+               return -EINVAL;
+
        if (addr->sa_family == AF_UNSPEC) {
                sk->sk_state    = NETLINK_UNCONNECTED;
                nlk->dst_pid    = 0;
@@ -1093,6 +1096,7 @@ static inline int do_one_set_err(struct sock *sk,
                                 struct netlink_set_err_data *p)
 {
        struct netlink_sock *nlk = nlk_sk(sk);
+       int ret = 0;
 
        if (sk == p->exclude_sk)
                goto out;
@@ -1104,10 +1108,15 @@ static inline int do_one_set_err(struct sock *sk,
            !test_bit(p->group - 1, nlk->groups))
                goto out;
 
+       if (p->code == ENOBUFS && nlk->flags & NETLINK_RECV_NO_ENOBUFS) {
+               ret = 1;
+               goto out;
+       }
+
        sk->sk_err = p->code;
        sk->sk_error_report(sk);
 out:
-       return 0;
+       return ret;
 }
 
 /**
@@ -1116,12 +1125,16 @@ out:
  * @pid: the PID of a process that we want to skip (if any)
  * @groups: the broadcast group that will notice the error
  * @code: error code, must be negative (as usual in kernelspace)
+ *
+ * This function returns the number of broadcast listeners that have set the
+ * NETLINK_RECV_NO_ENOBUFS socket option.
  */
-void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
+int netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
 {
        struct netlink_set_err_data info;
        struct hlist_node *node;
        struct sock *sk;
+       int ret = 0;
 
        info.exclude_sk = ssk;
        info.pid = pid;
@@ -1132,9 +1145,10 @@ void netlink_set_err(struct sock *ssk, u32 pid, u32 group, int code)
        read_lock(&nl_table_lock);
 
        sk_for_each_bound(sk, node, &nl_table[ssk->sk_protocol].mc_list)
-               do_one_set_err(sk, &info);
+               ret += do_one_set_err(sk, &info);
 
        read_unlock(&nl_table_lock);
+       return ret;
 }
 EXPORT_SYMBOL(netlink_set_err);
 
index a4b6e148c5dec4ceba8a4aa5ef964353433e2d6a..06438fa2b1e5d1bfcef02b274941e0553a533bd2 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
index a249127020a50eea96aba8dd0cb594ca86e73e15..fa07f044b59977af946049b8a03fe64be5994966 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/timer.h>
index 7aa11b01b2e240890fef4d8503142011d8d3f33b..64e6dde9749d5e713d15ac23914e3928211aa395 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fcntl.h>
 #include <linux/in.h>
 #include <linux/if_ether.h>    /* For the statistics structure. */
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
index 68176483617f36c6c83df1bf5978753c4ab2755f..6d4ef6d65b3df789d3eb4b3449df1fd1f2a5ced3 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index f324d5df4186f2c69cae6e39aeb1941dd167d421..94d4e922af53c0fb5e1c34508dbad6a76f46d96f 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright Tomi Manninen OH2BNS (oh2bns@sral.fi)
  */
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/timer.h>
 #include <net/ax25.h>
index e3e6c44e1890cee8246a6d94dfae7181a2e75c19..607fddb4fdbbd944b1dad88400061455f03909a4 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 5cc648012f50bc8923d4d8dd29a93d7750777518..44059d0c8dd1dceb831a60a71447aa6e8aacb6df 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 04e7d0d2fd8f1c4aa2f6ba249d3b68ea73b16910..6a947ae50dbdd9865e2607041a4b12f2a7e13fcc 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 1612d417d10c5b631c4aeea78207cd8e34a0a305..cc90363d7e7a86936bacbc26b50da0092bceb93b 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/wireless.h>
 #include <linux/kernel.h>
 #include <linux/kmod.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/protocol.h>
index 526d0273991a5c99ee2bb2e664bf394640f7a25f..73aee7f2fcdccd56b77f19f818d95085b89e2843 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <net/sock.h>
 
index 387197b579b1c430bd511b695740c7724fb4c9c7..1bd38db4fe1e996df47396d43acd296e9811fa1b 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/socket.h>
 #include <asm/ioctls.h>
 #include <net/sock.h>
index 360cf377693eeee42008d6f0e5f1e34f12259b25..e2a95762abd37685c6b10a63795df539ffe0b295 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/socket.h>
 #include <net/sock.h>
 #include <net/tcp_states.h>
index 5c6ae0c701c047866bae808b77db22e8fc8ddad0..9b4ced6e0968dc99ecf198bbdfba1b4201aed0a4 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/phonet.h>
 #include <linux/proc_fs.h>
index fe2e7088ee07b10d387aa5db7b6bc9e7d369853a..58b3b1f991ed2db16d78d2d192eefb4b4d3ad80e 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/netlink.h>
 #include <linux/phonet.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/phonet/pn_dev.h>
 
index 69c8b826a0cef427e3c1e00c1216af5a014f4c32..c785bfd0744f149b753506f8f2f754329410f8ad 100644 (file)
@@ -23,6 +23,7 @@
  * 02110-1301 USA
  */
 
+#include <linux/gfp.h>
 #include <linux/kernel.h>
 #include <linux/net.h>
 #include <linux/poll.h>
index 853c52be781f7992a850ef2229b6c61b6a3e6f74..f81862baf4d080be3aa507e21e96fba2edd90a7a 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/in.h>
 #include <linux/poll.h>
 #include <net/sock.h>
index 6d06cac2649cd6bc62cdbb71975612c338185e08..f1da27ceb064e5a2d4095414c65e1fbf547d063e 100644 (file)
@@ -30,6 +30,7 @@
  * SOFTWARE.
  *
  */
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/rbtree.h>
 
index 278f607ab603ff90d243472c1efc0a1735742558..7619b671ca2829f0e197a93f6abd06df2f108229 100644 (file)
@@ -32,6 +32,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/inet_hashtables.h>
 
 #include "rds.h"
index 3b8992361042f62c0deca22b542e458670667782..8f2d6dd7700a8a0e20192b521c30dc7bc2df553b 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/inetdevice.h>
 #include <linux/if_arp.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "rds.h"
 #include "ib.h"
index 647cb8ffc39bfe96c6953185518844ec1d7a1983..88d0856cb797d3bd41ffc0fc29f0b51618424d6d 100644 (file)
@@ -32,6 +32,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "rds.h"
index 4b0da865a72c2ee323999b1810a3a19a3a07709d..059989fdb7d784592eef3f873b808d1b88a16afa 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "rds.h"
 #include "rdma.h"
index 04dc0d3f3c955c00449d67a17951b86ac0f08573..c7dd11b835f04447cb2e63d013e0b49fd9a384b2 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <rdma/rdma_cm.h>
index 814a91a6f4a79dd97422bded809a0e67778a4bd5..c45c4173a44d44eb9ceee633e0cec271f2182411 100644 (file)
@@ -32,6 +32,7 @@
  */
 #include <linux/percpu.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/proc_fs.h>
 
 #include "rds.h"
index b28fa8525b24029ffdfb026ee19a76d3597fc668..c8f3d3525cb9b187daeca402f71cb5b88356ce41 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/inetdevice.h>
 #include <linux/if_arp.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "rds.h"
 #include "iw.h"
index 394cf6b4d0aad63c4dbb7bb51ecdd4b0b69b2dbc..3e9460f935d84f6ebafca6d5592b8f8527185fb7 100644 (file)
@@ -32,6 +32,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 #include "rds.h"
index 9eda11cca9566fbeb96e56e6f3ae9566fa152d99..13dc1862d86264288eb0455056d289008d072234 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "rds.h"
 #include "rdma.h"
index 54af7d6b92da073ad9305d67eb04a48acb0b6e7e..da43ee840ca3bb89d44d5031b5acf5887fcf1069 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
 #include <rdma/rdma_cm.h>
index 4a61997f554db1108c69cd619662526d80079f0a..0d7a159158b81c0b18af5df5f37a7c2356f9a6eb 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 
 #include "rds.h"
index 73e600ffd87ff533d5091b866ab7f5bff586663b..9a1d67e001ba60a79608275ecfa3ed452f373b19 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "rds.h"
 #include "rdma.h"
index 36790122dfd4c3cb869960ddb2141cd235973e16..595a952d4b17f069c60a457701d6e207f68e621b 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/highmem.h>
+#include <linux/gfp.h>
 
 #include "rds.h"
 
index 4c64daa1f5d52b0eb72b6920bd7f4a39a3a756b9..5ce9437cad672168825e78f43fb1fe38e8ce2b20 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/pagemap.h>
+#include <linux/slab.h>
 #include <linux/rbtree.h>
 #include <linux/dma-mapping.h> /* for DMA_*_DEVICE */
 
index b426d67f760c61f77717a40057d71fd0090da46e..e2a2b9344f7b576be4d06ca02f23c072acd9f904 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/in.h>
 
index b2fccfc207690f5bfa231af389031a7dce8a218b..f04b929ded926d48b0fd326f5c5d916895b3f9b5 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <linux/in.h>
 #include <linux/list.h>
index b5198aee45d3a3469100f44bfed4fef9dddac56b..babf4577ff7d3f06835e073e48733edeceb97db3 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <net/tcp.h>
 
index 53cb1b54165d81f0145dbef5b3bc173058383963..975183fe6950a34b242ef55db011e6f04c1c6772 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/in.h>
 #include <net/tcp.h>
 
index c00dafffbb5acf3d844716b49d5fe434e710d006..e08ec912d8b0f3f3181e32365a567abb2d916ebe 100644 (file)
@@ -31,6 +31,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <net/tcp.h>
 
 #include "rds.h"
index c218e07e5cafe80bb65ef86dfec1b27a9cdfb986..a9fa86f65983a65ebbcc9a04e65f053df2f70afc 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/wait.h>
 #include <linux/poll.h>
 #include <linux/fs.h>
+#include <linux/slab.h>
 
 #include "rfkill.h"
 
index e90b9b6c16ae8130b1f9993b6b5991743663dd61..4fb711a035f43f34ee5490fb5ab9ed17e93a98af 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
index 424b893d14502b95d8f61aecf74fd9df3c14ac7f..178ff4f73c85102518025fa3d4e20f647a389743 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/fcntl.h>
 #include <linux/in.h>
 #include <linux/if_ether.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
index 5ef5f6988a2e1aa892539e0c7c53364d7f796808..a750a28e02219770539fcfe08b0010fe9cca0cdd 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 968e8bac1b5dfd8f33578633c1f4338a5fe66624..ae4a9d99aec70da821722a4e204ee6eacf1df872 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
  */
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/timer.h>
 #include <net/ax25.h>
index 69820f93414b1ca7f98fb62b5570d8d0bfbca0aa..4ebf33afbe473c31098ab6e80674ef3d6198892e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/gfp.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 70a0b3b4b4d2903b7bd74d1e783e819a561c32ce..cbc244a128bd1611829f6e943ae7a669cc81f2d3 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index b05108f382da4a757b0381a106bfcbc3598dd51e..1734abba26a29bf1a9d156747b97d0d8c5f1fe84 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
index 287b1415cee93fae57a830fdd74ef9144b00c7d7..c060095b27ce9c6b1f565461345836d38a154f6c 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/net.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
index 77228f28fa363240fce7da4e32d0b81bd8ea3951..6d79310fcaaeead0d6d0953f791e18385c794c03 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/icmp.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <net/ip.h>
@@ -88,6 +89,11 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local,
 
        /* get a notification message to send to the server app */
        notification = alloc_skb(0, GFP_NOFS);
+       if (!notification) {
+               _debug("no memory");
+               ret = -ENOMEM;
+               goto error_nofree;
+       }
        rxrpc_new_skb(notification);
        notification->mark = RXRPC_SKB_MARK_NEW_CALL;
 
@@ -189,6 +195,7 @@ invalid_service:
        ret = -ECONNREFUSED;
 error:
        rxrpc_free_skb(notification);
+error_nofree:
        _leave(" = %d", ret);
        return ret;
 }
index b4a2209770311a4fdce0757c9857bbdd6fdf2f39..2714da167fb8980fd7a43f3485e25e2bdcfc7feb 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/circ_buf.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/udp.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
index bc0019f704fecb433b369798a064aaf7230a6a6c..909d092de9f43c9e4320e465711d2d1a36fb692a 100644 (file)
@@ -9,6 +9,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/circ_buf.h>
 #include <net/sock.h>
index 9f1ce841a0bbcd348e83c7ad518649079e95c357..4106ca95ec86f43b8c235dd5d94e9fc016ea06f5 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
 #include <linux/crypto.h>
index f98c8027e5c12970f959144309d5d44f4677ee9a..89315009bab11f2f6c32db1bd50d0505d8210c46 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/icmp.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <net/ip.h>
index 74697b2004962059857c6b42e84a5490befce23d..5ee16f0353febe4d195daaa6ca29ace62a79c06a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/key-type.h>
 #include <linux/crypto.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <keys/rxrpc-type.h>
index 807535ff29b52d0ebdb85ac6ba4fa5e4c5d18805..87f7135d238b498f9208543cf4608c1cb78a59d3 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include "ar-internal.h"
index cc9102c5b588319e09b9769302bd5704e9bfb8e3..5f22e263eda748ffdbe06f802626588a70776004 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/net.h>
+#include <linux/gfp.h>
 #include <linux/skbuff.h>
 #include <linux/circ_buf.h>
 #include <net/sock.h>
index edc026c1eb763aeaf837d27ab9692374a4a7653b..f0f85b0123f7b58f3d9e34048af2bcf49fcf4fa5 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/icmp.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <net/ip.h>
index 0936e1acc30ece6110313c01fb0ee78c0e5dd91e..5e0226fe587e738157d58471f6a603d003780484 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include "ar-internal.h"
index 713ac593e2e96d5a21b43958ff3ebb67816a8a3c..7635107726ce76b66be2e28877bec91f9286ae96 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/af_rxrpc.h>
 #include <keys/rxrpc-type.h>
index 21f9c7678aa3ea903a9741305c22b6157e8637c3..2f691fb180d127751877003af00e624334da474c 100644 (file)
@@ -328,13 +328,16 @@ config NET_CLS_FLOW
          module will be called cls_flow.
 
 config NET_CLS_CGROUP
-       bool "Control Group Classifier"
+       tristate "Control Group Classifier"
        select NET_CLS
        depends on CGROUPS
        ---help---
          Say Y here if you want to classify packets based on the control
          cgroup of their process.
 
+         To compile this code as a module, choose M here: the
+         module will be called cls_cgroup.
+
 config NET_EMATCH
        bool "Extended Matches"
        select NET_CLS
index 64f5e328cee99025d58b477902bcdb78fc7a8d46..d8e0171d9a4b8a14cd2c7241c173d3647164430e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/kmod.h>
index 082c520b0def5d85f8ca8dc830d3ec20250cd758..da27a170b6b7bcd42372a651668cba3f72034ab0 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_ipt.h>
index d329170243cb858de314d018ce085728b28e638a..c046682054ebdffbba3f71e439d140ac5c3155c1 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
index 6b0359a500e603510cf30f1a66767dcb3f62b42c..b7dcfedc802ea5c54a096efe3921f1fe4dd30aa5 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_pedit.h>
index 723964c3ee4ff78c4e442db790d960b261fd04df..654f73dff7c1c8d7f9d5fb6541174299c4b32f05 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/act_api.h>
 #include <net/netlink.h>
 
index 8daa1ebc7413b971dafde75606af039d52a7e83e..622ca809c15ca3cf595e0d721e1d70171c3c2fbe 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
index 3725d8fa29db7c02185636336bba3cd59922d124..f082b27ff46d90fe80d85ab051511e43acb915c1 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kmod.h>
 #include <linux/netlink.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/netlink.h>
index 4e2bda854119bf87391dc89a3cda8ce44810c5a0..efd4f95fd0507d1d114db3683805cf08a61762f7 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index e4877ca6727c4b098ef1b6f08163fd7702d3eea2..221180384fd7d466bc0864ae6eca5aee9a6f0e95 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/errno.h>
@@ -24,6 +25,25 @@ struct cgroup_cls_state
        u32 classid;
 };
 
+static struct cgroup_subsys_state *cgrp_create(struct cgroup_subsys *ss,
+                                              struct cgroup *cgrp);
+static void cgrp_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp);
+static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp);
+
+struct cgroup_subsys net_cls_subsys = {
+       .name           = "net_cls",
+       .create         = cgrp_create,
+       .destroy        = cgrp_destroy,
+       .populate       = cgrp_populate,
+#ifdef CONFIG_NET_CLS_CGROUP
+       .subsys_id      = net_cls_subsys_id,
+#else
+#define net_cls_subsys_id net_cls_subsys.subsys_id
+#endif
+       .module         = THIS_MODULE,
+};
+
+
 static inline struct cgroup_cls_state *cgrp_cls_state(struct cgroup *cgrp)
 {
        return container_of(cgroup_subsys_state(cgrp, net_cls_subsys_id),
@@ -79,14 +99,6 @@ static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
        return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files));
 }
 
-struct cgroup_subsys net_cls_subsys = {
-       .name           = "net_cls",
-       .create         = cgrp_create,
-       .destroy        = cgrp_destroy,
-       .populate       = cgrp_populate,
-       .subsys_id      = net_cls_subsys_id,
-};
-
 struct cls_cgroup_head
 {
        u32                     handle;
@@ -277,12 +289,19 @@ static struct tcf_proto_ops cls_cgroup_ops __read_mostly = {
 
 static int __init init_cgroup_cls(void)
 {
-       return register_tcf_proto_ops(&cls_cgroup_ops);
+       int ret = register_tcf_proto_ops(&cls_cgroup_ops);
+       if (ret)
+               return ret;
+       ret = cgroup_load_subsys(&net_cls_subsys);
+       if (ret)
+               unregister_tcf_proto_ops(&cls_cgroup_ops);
+       return ret;
 }
 
 static void __exit exit_cgroup_cls(void)
 {
        unregister_tcf_proto_ops(&cls_cgroup_ops);
+       cgroup_unload_subsys(&net_cls_subsys);
 }
 
 module_init(init_cgroup_cls);
index e054c62857e19ef29826857aabad4d5a5fcf8ac4..6ed61b10e0020d657c4531d501adf155292c486a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/if_vlan.h>
+#include <linux/slab.h>
 
 #include <net/pkt_cls.h>
 #include <net/ip.h>
index 6d6e87585fb1a5028285210cd404ebc67547daa3..93b0a7b6f9b474641595d4f093b79330bd0d05f9 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index dd872d5383efe371fa4333dcc1af724039b047b5..694dcd85dec83bda586f8a96843a1f8fac6a4259 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index e806f2314b5e24281dd4bfbe3f442d1c1ee51d41..20ef330bb918b552f91c3795d67a2c6f9d407c3b 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
 #include <linux/errno.h>
+#include <linux/slab.h>
 #include <net/act_api.h>
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
index 07372f60bee3364588cb94fcfcad1cc7bee514e5..17c5dfc673209d68670aee8bfb5cbf099a4f0a51 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index 24dce8b648a425b39f877bfe4935b0602ee16c9b..3bcac8aa333c2a322fb7283ce0803480e893d5d4 100644 (file)
@@ -58,6 +58,7 @@
  *           only available if that subsystem is enabled in the kernel.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
index 370a1b2ea31770b4ce08196f146d43da12f31f4e..1a4176aee6e5c181749d522ebd2a258dbbf59762 100644 (file)
@@ -9,6 +9,7 @@
  * Authors:    Thomas Graf <tgraf@suug.ch>
  */
 
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
index 853c5ead87fd3691c4e699eebb9c6b34bc64f9aa..763253257411af1db91b3e25a78af8e687523342 100644 (file)
@@ -9,6 +9,7 @@
  * Authors:    Thomas Graf <tgraf@suug.ch>
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
index aab59409728b4c50c4c45bc233570c10b8844980..e782bdeedc584254ecf8b544d85a449039016a92 100644 (file)
@@ -82,6 +82,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
index 6cd491013b503f264fe210545a118f45cb8df0d0..145268ca57cfeffdfea5751e19c738964b2637db 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/list.h>
 #include <linux/hrtimer.h>
 #include <linux/lockdep.h>
+#include <linux/slab.h>
 
 #include <net/net_namespace.h>
 #include <net/sock.h>
index ab82f145f68937a9c722322517fd2dd479550db0..fcbb86a486a21ab3c9a51a63bd248f809817dbd0 100644 (file)
@@ -3,6 +3,7 @@
 /* Written 1998-2000 by Werner Almesberger, EPFL ICA */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/errno.h>
index 3846d65bc03ec7a7de7e6ca674dc6c2b255dc570..28c01ef5abc815ae5429e29c34bba8b97b7d50f6 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index a65604f8f2b8f8aaa6dce6a2a13ee76e73b295be..b74046a95397c6d2e3d9a90e648c3414dd18c50f 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
index d303daa45d49e54f34bc11d698d309253c5e77b2..63d41f86679c0653951090c81f189665c5deaa00 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/errno.h>
index 4b0a6cc44c77b6c50e02247333f8b9ed42ae4e3c..5948bafa8ce29de97bf4a824139ee2f033579810 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
index 5173c1e1b19c3c0756310dae69785b6b1456c25f..ff4dd53eeff013f875330d8fbeb24e3a6e299e5a 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <net/pkt_sched.h>
 
 /* Main transmission queue. */
index 40408d595c08da0163e9a2c4c358e0293d4cebce..51dcc2aa5c926b735fa683135bddaf3c66114355 100644 (file)
@@ -18,6 +18,7 @@
  *  For all the glorious comments look at include/net/red.h
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
index 508cf5f3a6d5c4a2b0555e08273555590b97957f..0b52b8de562c40db1bd4541a08389885af621cb2 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/compiler.h>
 #include <linux/rbtree.h>
 #include <linux/workqueue.h>
+#include <linux/slab.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 
index d1dea3d5dc929f1dc2051b2ed42f65168c88aa09..b2aba3f5e6fa5cd8bdf127c86d96fd7ab21ebf32 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
index 7db2c88ce585f04a7361b87dec3aa2760d65f1f3..c50876cd87047bace522be68375d193687108ade 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index d8b10e054627a8aea17fe2818833587e11ef63af..4714ff162bbd2cdf42eb77c7b629e0331391bfeb 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
index 93285cecb246942b5640809d34e7d17d9ee1d63a..81672e0c1b253558a77f6ead32dfd6bfbb995c4e 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index cb21380c0605fe813b4a4ff0f489d9fdc08c2428..c5a9ac5660079581ad81b61bef4039da621cf2ad 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/ipv6.h>
 #include <linux/skbuff.h>
 #include <linux/jhash.h>
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
index db69637069c458443793f5d4d08a17c7225ff87e..3415b6ce1c0a5b1116a4e23cc710c0b8f5b0f8d5 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
index 56935bbc1496f535e646d2e8ef03c9bddb3a2634..86366390038a1cae0b536874fd037464f2a1678f 100644 (file)
@@ -34,6 +34,7 @@
  * be incorporated into the next SCTP release.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
index bef1337316837c8dce7b97bdd89560ecee23cbdd..faf71d179e4641137f8d8d477e4a9773321d4bdd 100644 (file)
@@ -43,6 +43,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/in.h>
 #include <net/sock.h>
 #include <net/ipv6.h>
index 8e4320040f058ebbd0f7d7ca64b1749f9ec9df12..3eab6db59a37e5e5a9d40b6afabac39d421af2e3 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/net.h>
 #include <linux/inet.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
index 3d74b264ea2256442eb336e1e333269b8cdbe128..2a570184e5a9176c07291eb7ab6f8771c2dd95c0 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/socket.h>
 #include <linux/ip.h>
 #include <linux/time.h> /* For struct timeval */
+#include <linux/slab.h>
 #include <net/ip.h>
 #include <net/icmp.h>
 #include <net/snmp.h>
index bbf5dd2a97c42d0ac49d7ad0f1e0fd6b0955f63a..ccb6dc48d15b6ecf123887cd23d00ffec1ec3c4a 100644 (file)
@@ -46,6 +46,7 @@
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 /* Initialize an SCTP inqueue.  */
 void sctp_inq_init(struct sctp_inq *queue)
index 1d7ac70ba39f611dae6fa8e932369705c81d47be..9fb5d37c37ad0785fcd2e56b3912baa1a9087de3 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/netdevice.h>
 #include <linux/init.h>
 #include <linux/ipsec.h>
+#include <linux/slab.h>
 
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
index 7c5589363433c38d6c63a344f36d5e9d61befc45..fad261d41ec2f6fdbb1eb3d323b1a0445f29305a 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/icmp.h>
index 229690f02a1da7131811114f47b7cf3e7c35e5ca..abfc0b8dee74ea171c9f974e7a10fe4b9c66b2b9 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/list.h>   /* For struct list_head */
 #include <linux/socket.h>
 #include <linux/ip.h>
+#include <linux/slab.h>
 #include <net/sock.h>    /* For skb_set_owner_w */
 
 #include <net/sctp/sctp.h>
index 8cb4f060bce68298d2f3d59ff67bf97fab276dbc..534c7eae9d15f9b0371b7cd2963f74e7cbf18e7c 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/socket.h>
 #include <linux/ip.h>
 #include <linux/time.h> /* For struct timeval */
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
index e771690f6d5d90d05111d981d55404cef66d737f..a56f98e82f92f0a0dbd53d2045ab7d8053ab1454 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/bootmem.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/protocol.h>
 #include <net/ip.h>
index 9e732916b671bde5893681f2e6690244260f0da2..17cb400ecd6aa73421635af1835501b27a6f58a8 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/inet.h>
 #include <linux/scatterlist.h>
 #include <linux/crypto.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 
 #include <linux/skbuff.h>
index 500886bda9b4acb8d600b5ce622923dab68b9486..4c5bed9af4e33057abd447455e768afc3c7c2e05 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/ip.h>
+#include <linux/gfp.h>
 #include <net/sock.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
index 47bc20d3a85b714f2d4d5730b4effccbc4f4c080..abf601a1b84732fe9a9749e60015673814194033 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/ipv6.h>
 #include <linux/net.h>
 #include <linux/inet.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/inet_ecn.h>
 #include <linux/skbuff.h>
index dfc5c127efd47d5cfca1a5541d3e91dff898c1b3..007e8baba0891c1c5b52e6e8bc2fadcc6edd96e5 100644 (file)
@@ -67,6 +67,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/crypto.h>
+#include <linux/slab.h>
 
 #include <net/ip.h>
 #include <net/icmp.h>
index 737d330e5ffc6a4fdeb4d8b64cccc53e34b619f0..442ad4ed6315fab99ec5b78d012e65a8236e2fae 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
 
index b827d21dbe54451582c61a4758b7063e794cfd7d..be4d63d5a5cc050d782a2355a3eb1b9ae61bda07 100644 (file)
@@ -48,6 +48,7 @@
  * be incorporated into the next SCTP release.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/random.h>
 #include <net/sctp/sctp.h>
index 9bd64565021a91ed890e27313c7ce364f474c749..747d5412c463ee1492f37485bb7bf4e4181e1b4e 100644 (file)
@@ -42,6 +42,7 @@
  * be incorporated into the next SCTP release.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/bitmap.h>
 #include <net/sctp/sctp.h>
index 8b3560fd876d2b95b361460b16fa3d92291a3160..aa72e89c3ee1685ad6d4096c76072daf80937f16 100644 (file)
@@ -43,6 +43,7 @@
  * be incorporated into the next SCTP release.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <net/sctp/structs.h>
index 7b23803343cc66e39c6b6214d9b96ff2a0d4877a..3a448536f0b6b4c98d3ae2966c51f686ee068760 100644 (file)
@@ -41,6 +41,7 @@
  * be incorporated into the next SCTP release.
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
index 769c386bd4288758635acde6ca77c401a49c61a8..5e8d0af3c0e73b3537c1852eee2c15a917e4a605 100644 (file)
@@ -87,6 +87,7 @@
 #include <linux/wireless.h>
 #include <linux/nsproxy.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -2135,6 +2136,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
                        break;
                ++datagrams;
 
+               /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */
+               if (flags & MSG_WAITFORONE)
+                       flags |= MSG_DONTWAIT;
+
                if (timeout) {
                        ktime_get_ts(timeout);
                        *timeout = timespec_sub(end_time, *timeout);
index f845d9d72f7307e3910fe39d0b32fbb95491114f..1419d0cdbbaccd494051caada325112320a657ec 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <net/ipv6.h>
 #include <linux/sunrpc/clnt.h>
+#include <linux/slab.h>
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 
index bf88bf8e9365a0746eda3d0153135280b759bd3e..8f623b0f03dd3880bb57a96fce0b7951b572294c 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/sched.h>
index 0cfccc2a02979c4844c63dffbbdd47312a0139e6..c389ccf6437d5870868ec49f489b3f07f131ed46 100644 (file)
@@ -1280,9 +1280,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
        rqstp->rq_release_snd_buf = priv_release_snd_buf;
        return 0;
 out_free:
-       for (i--; i >= 0; i--) {
-               __free_page(rqstp->rq_enc_pages[i]);
-       }
+       rqstp->rq_enc_pages_num = i;
+       priv_release_snd_buf(rqstp);
 out:
        return -EAGAIN;
 }
index c0ba39c4f5f220de70711e92e350c6aa64002e9a..310b78e994567e961984debbe99b0092b551cc94 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <linux/types.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/sunrpc/sched.h>
 #include <linux/sunrpc/gss_asn1.h>
index c93fca204558cbca50b54fcc7cf7de6542a7b7be..e9b63617668763c6162df5152dc72b6f84c049f5 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/err.h>
 #include <linux/types.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/crypto.h>
 #include <linux/highmem.h>
index b8f42ef7178e89b4dc62b587888db4f1479788a4..88fe6e75ed7e4166ef8991a3e435a1a4553a956c 100644 (file)
@@ -59,7 +59,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/sunrpc/gss_krb5.h>
 #include <linux/random.h>
index 17562b4c35f65e03ab7e7115ef8ce543c086b651..6331cd6866ec9f6ddb807153644b28a4bde19fc7 100644 (file)
@@ -32,7 +32,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/sunrpc/gss_krb5.h>
 #include <linux/crypto.h>
 
index 066ec73c84d682e2caa83ab4f44f61e5497a7649..ce6c247edad02d54f29a11a851fc677f269a4ec0 100644 (file)
@@ -58,7 +58,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/sunrpc/gss_krb5.h>
 #include <linux/crypto.h>
index ae8e69b59c4c35c1eb23f2501174f3ba4d26b85e..a6e905637e035f54a3414321825ad97a2582b000 100644 (file)
@@ -1,5 +1,4 @@
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/sunrpc/gss_krb5.h>
 #include <linux/random.h>
index c832712f8d55484c30144c2232730a3c60dc339b..5a3a65a0e2b4b41c7b0558b1b5a33807d5e53564 100644 (file)
@@ -34,7 +34,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/slab.h>
 #include <linux/jiffies.h>
 #include <linux/sunrpc/gss_spkm3.h>
 #include <linux/random.h>
index e34bc531fcb9c3d8754046df05aefe253f15542a..b81e790ef9f4197477c6eef889e1f315afd2c8a1 100644 (file)
@@ -37,6 +37,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
index 46b2647c5bd28bb253394e96c39823d401d6d473..aac2f8b4ee214290796bf76c97aae6051b4fed47 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/module.h>
index 553621fb2c41f2063630b83fd74d03cd71d9b7ab..cf06af3b63c676068343b46941bc1dd59380440a 100644 (file)
@@ -22,6 +22,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ******************************************************************************/
 
 #include <linux/tcp.h>
+#include <linux/slab.h>
 #include <linux/sunrpc/xprt.h>
 
 #ifdef RPC_DEBUG
index 13f214f531208603a0e8f2b7cfe8ff0cfbc79bea..f0c05d3311c1a1ac3dca0d19ab701cd5e00a9559 100644 (file)
@@ -37,21 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #define RPCDBG_FACILITY        RPCDBG_SVCDSP
 
-void bc_release_request(struct rpc_task *task)
-{
-       struct rpc_rqst *req = task->tk_rqstp;
-
-       dprintk("RPC:       bc_release_request: task= %p\n", task);
-
-       /*
-        * Release this request only if it's a backchannel
-        * preallocated request
-        */
-       if (!bc_prealloc(req))
-               return;
-       xprt_free_bc_request(req);
-}
-
 /* Empty callback ops */
 static const struct rpc_call_ops nfs41_callback_ops = {
 };
index 154034b675bd90de493d1438ff46a2b230178742..19c9983d53607483cce29654b8e589dca6da539d 100644 (file)
@@ -659,6 +659,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
        task = rpc_new_task(&task_setup_data);
        if (!task) {
                xprt_free_bc_request(req);
+               task = ERR_PTR(-ENOMEM);
                goto out;
        }
        task->tk_rqstp = req;
index 8d63f8fd29b7e3ff0e940d7457d45203f99c56b1..20e30c6f8355dc0bc612bffb44abefee7c3536df 100644 (file)
@@ -587,6 +587,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
        struct dentry *dentry;
 
        dentry = __rpc_lookup_create(parent, name);
+       if (IS_ERR(dentry))
+               return dentry;
        if (dentry->d_inode == NULL)
                return dentry;
        dput(dentry);
index 3e3772d8eb921ce00af629ad11627ad3677ea613..121105355f60e4a90dcb9906e878ea255499358d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/ipv6.h>
 
 #include <linux/sunrpc/clnt.h>
index a661a3acb37e682dba442b98ec1c9729a75f7f5f..10b4319ebbca5816f02b4719f923852ea0301025 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/compiler.h>
 #include <linux/netdevice.h>
+#include <linux/gfp.h>
 #include <linux/skbuff.h>
 #include <linux/types.h>
 #include <linux/pagemap.h>
index 1b4e6791ecf3d3a036347150708fb0e345c26198..5785d2037f45ea72bd065c1b93a0f22e16ec5526 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include <linux/init.h>
 #include <linux/kernel.h>
index 8420a4205b76bc9278e247ee299d10314c68558a..d9017d64597e2beabb7f2edb9147018613d7c412 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include <linux/sunrpc/types.h>
 #include <linux/sunrpc/xdr.h>
index 8f0f1fb3dc5259419a1e823f522d9e5792538831..061b2e0f9118833bcc93facef2cb8bc40f655a01 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/errno.h>
 #include <linux/freezer.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/sunrpc/stats.h>
 #include <linux/sunrpc/svc_xprt.h>
index afdcb0459a8319660443b0130dc000d65e0f5449..207311610988a3c3f29a2bf3ce2ea37320d237f1 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/seq_file.h>
 #include <linux/hash.h>
 #include <linux/string.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/ipv6.h>
 #include <linux/kernel.h>
index 8bd690c48b69d55862b49a35bd53ffa324a8061b..2763fde88499866084bf4782e597ce78d1086be4 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
index 469de292c23c34b8ba9a0f9ea24e07d4b77d5e09..42f09ade00445289c22a51f88550af7b7dadb85a 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/metrics.h>
+#include <linux/sunrpc/bc_xprt.h>
 
 #include "sunrpc.h"
 
@@ -1032,21 +1033,16 @@ void xprt_release(struct rpc_task *task)
        if (req->rq_release_snd_buf)
                req->rq_release_snd_buf(req);
 
-       /*
-        * Early exit if this is a backchannel preallocated request.
-        * There is no need to have it added to the RPC slot list.
-        */
-       if (is_bc_request)
-               return;
-
-       memset(req, 0, sizeof(*req));   /* mark unused */
-
        dprintk("RPC: %5u release request %p\n", task->tk_pid, req);
+       if (likely(!is_bc_request)) {
+               memset(req, 0, sizeof(*req));   /* mark unused */
 
-       spin_lock(&xprt->reserve_lock);
-       list_add(&req->rq_list, &xprt->free);
-       rpc_wake_up_next(&xprt->backlog);
-       spin_unlock(&xprt->reserve_lock);
+               spin_lock(&xprt->reserve_lock);
+               list_add(&req->rq_list, &xprt->free);
+               rpc_wake_up_next(&xprt->backlog);
+               spin_unlock(&xprt->reserve_lock);
+       } else
+               xprt_free_bc_request(req);
 }
 
 /**
index 5b8a8ff93a2591b3b3b162a7e5ca60f7cdf89f94..d718b8fa95253c61d0e0adedd0bccf5cd84d89ed 100644 (file)
@@ -40,6 +40,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/sysctl.h>
 #include <linux/sunrpc/clnt.h>
index 3fa5751af0ecca4b03002d19a804f969b7011096..fd90eb89842bc47e88904ae05e835817e7542d05 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/sunrpc/debug.h>
 #include <linux/sunrpc/rpc_rdma.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
index f96c2fe6137b87f11d7155d96441600012c984a3..187257b1d88070d5adba6f03074c56b044cd0f37 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/seq_file.h>
 
 #include "xprt_rdma.h"
index 2209aa87d899819152572e9ae87957d2b223d29d..27015c6d8eb58311ed88264e86313fc3879ad0c2 100644 (file)
@@ -48,6 +48,7 @@
  */
 
 #include <linux/pci.h> /* for Tavor hack below */
+#include <linux/slab.h>
 
 #include "xprt_rdma.h"
 
index e4839c07c913a38253959a942d7111611a507fa2..9847c30b5001ce5d4e3cd9e1b5828e80cdd7ef24 100644 (file)
@@ -2251,9 +2251,6 @@ static struct rpc_xprt_ops xs_tcp_ops = {
        .buf_free               = rpc_free,
        .send_request           = xs_tcp_send_request,
        .set_retrans_timeout    = xprt_set_retrans_timeout_def,
-#if defined(CONFIG_NFS_V4_1)
-       .release_request        = bc_release_request,
-#endif /* CONFIG_NFS_V4_1 */
        .close                  = xs_tcp_close,
        .destroy                = xs_destroy,
        .print_stats            = xs_tcp_print_stats,
index a881f92a8537c71531ca7eda1421c3766c7601db..c58a1d16563a6ab3bd9b51740a8520cef997bf45 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/netdevice.h>
 #include <linux/in.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 
 /*
index 524ba5696d4d6530c1cf7cea80832cb8158cfaa9..6230d16020c49917f5f28e06b514d379f698205d 100644 (file)
@@ -38,6 +38,7 @@
 #include <net/tipc/tipc_bearer.h>
 #include <net/tipc/tipc_msg.h>
 #include <linux/netdevice.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 
 #define MAX_ETH_BEARERS                2
index 4b235fc1c70ff7948c372a6c0d36e7ca9b5ad39a..cfb20b80b3a1758061d446e60fa92de17299559c 100644 (file)
@@ -40,9 +40,9 @@
 #include <linux/socket.h>
 #include <linux/errno.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/fcntl.h>
+#include <linux/gfp.h>
 #include <asm/string.h>
 #include <asm/atomic.h>
 #include <net/sock.h>
index 19c17e4a0c8b96d0468a7652661f8b5ff34b9b86..14c22c3768da8875955e72836830057eb5f7db13 100644 (file)
@@ -74,7 +74,6 @@
 #include <linux/un.h>
 #include <linux/net.h>
 #include <linux/fs.h>
-#include <linux/slab.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/file.h>
index d095c7be10d03bd1514e8fae584a3b31cc30d5ce..397cffebb3b655546043a540067ac81be99fa42c 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/sysctl.h>
 
 #include <net/af_unix.h>
index 7718657e93dcea7951abaeecaaeb3a91d484b734..d5b7c3779c431b66520d7584ac5a31faa34b765b 100644 (file)
@@ -72,6 +72,7 @@
  *   wimax_msg_send()
  */
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <net/genetlink.h>
 #include <linux/netdevice.h>
 #include <linux/wimax.h>
index 813e1eaea29bb2ef71b2e6b4292248837fcef93a..1ed65dbdab03df1bab0a008a7ca0277ce143bfdb 100644 (file)
@@ -51,6 +51,7 @@
  *   wimax_rfkill_rm()
  */
 #include <linux/device.h>
+#include <linux/gfp.h>
 #include <net/genetlink.h>
 #include <linux/netdevice.h>
 #include <linux/wimax.h>
index 7fdb9409ad2ab251cefe2699f3abbc6bb4c8bee5..6ac70c1015235448fe79ebd3b25664b5f47479e3 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/nl80211.h>
 #include <linux/debugfs.h>
 #include <linux/notifier.h>
index 2e4895615037c18a8b6360d17947e5c4a7096194..a4991a3efec0249ac5dea20424628388652072fa 100644 (file)
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include "core.h"
 #include "debugfs.h"
 
index 6ef5a491fb4b018b866ff22f19b6e717fb90d4f7..6a5acf7501740a1da95520f8f867cd2187b46c18 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/etherdevice.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/cfg80211.h>
 #include "wext-compat.h"
 #include "nl80211.h"
index 62bc8855e1237db6b7d83f7a19c79e5c3976a0f7..22139fa4611598810ae0d4c4a462996aeaa61583 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/nl80211.h>
+#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <net/cfg80211.h>
 #include <net/iw_handler.h>
index e447db04cf76dee4f178c3f8b98ac7c2be8393cb..030cf153bea252e28893e7d976f776faa355aa14 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/if.h>
 #include <linux/module.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/if_ether.h>
 #include <linux/ieee80211.h>
index ed89c59bb431ab9c320c5f300123b501628f6c64..422da20d1e5b8a0bad63c8677b2631612905be9e 100644 (file)
@@ -33,6 +33,7 @@
  *
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/random.h>
 #include <linux/nl80211.h>
@@ -324,7 +325,7 @@ struct reg_regdb_search_request {
 };
 
 static LIST_HEAD(reg_regdb_search_list);
-static DEFINE_SPINLOCK(reg_regdb_search_lock);
+static DEFINE_MUTEX(reg_regdb_search_mutex);
 
 static void reg_regdb_search(struct work_struct *work)
 {
@@ -332,7 +333,7 @@ static void reg_regdb_search(struct work_struct *work)
        const struct ieee80211_regdomain *curdom, *regdom;
        int i, r;
 
-       spin_lock(&reg_regdb_search_lock);
+       mutex_lock(&reg_regdb_search_mutex);
        while (!list_empty(&reg_regdb_search_list)) {
                request = list_first_entry(&reg_regdb_search_list,
                                           struct reg_regdb_search_request,
@@ -346,18 +347,16 @@ static void reg_regdb_search(struct work_struct *work)
                                r = reg_copy_regd(&regdom, curdom);
                                if (r)
                                        break;
-                               spin_unlock(&reg_regdb_search_lock);
                                mutex_lock(&cfg80211_mutex);
                                set_regdom(regdom);
                                mutex_unlock(&cfg80211_mutex);
-                               spin_lock(&reg_regdb_search_lock);
                                break;
                        }
                }
 
                kfree(request);
        }
-       spin_unlock(&reg_regdb_search_lock);
+       mutex_unlock(&reg_regdb_search_mutex);
 }
 
 static DECLARE_WORK(reg_regdb_work, reg_regdb_search);
@@ -375,9 +374,9 @@ static void reg_regdb_query(const char *alpha2)
 
        memcpy(request->alpha2, alpha2, 2);
 
-       spin_lock(&reg_regdb_search_lock);
+       mutex_lock(&reg_regdb_search_mutex);
        list_add_tail(&request->list, &reg_regdb_search_list);
-       spin_unlock(&reg_regdb_search_lock);
+       mutex_unlock(&reg_regdb_search_mutex);
 
        schedule_work(&reg_regdb_work);
 }
index 978cac3414b558fd80bc41e3c87aa56510584beb..a026c6d56bd3347898cb1486301aedba37119b03 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright 2008 Johannes Berg <johannes@sipsolutions.net>
  */
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/wireless.h>
index 17fde0da1b08658db9882f000a51928dbd9ad339..f4dfd5f5f2ea429cb3a6e1d541f419813063ef45 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/etherdevice.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
index be2ab8c59e3a9806425b2b958d87dfe50d80111d..d3574a4eb3ba1ab837d564c819c50c328aaf2f7e 100644 (file)
@@ -5,6 +5,7 @@
  */
 #include <linux/bitops.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/cfg80211.h>
 #include <net/ip.h>
 #include "core.h"
index 9ab51838849eee380faeceb52772aa128420fd02..a60a2773b49726b01fc86b58a74a432a8f54fc26 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/nl80211.h>
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
+#include <linux/slab.h>
 #include <net/iw_handler.h>
 #include <net/cfg80211.h>
 #include "wext-compat.h"
index 5e1656bdf23b21779214088ca16b9efaa88d252c..4f5a47091fde623abc20e9ad8abfaea0fc224da3 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
+#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <linux/uaccess.h>
 #include <net/cfg80211.h>
index a3c2277de9e5d6eb54397e74dd45fad789052fcc..3feb28e41c5347b85175f57daf223918620723b2 100644 (file)
@@ -7,6 +7,7 @@
  *
  * (As all part of the Linux kernel, this file is GPL)
  */
+#include <linux/slab.h>
 #include <linux/wireless.h>
 #include <linux/netdevice.h>
 #include <net/iw_handler.h>
index 5615a88025367f5beaee4e90e9040d5e4deb9f15..d5c6140f4cb8ee25b80da910b4884b351c0b87c5 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/etherdevice.h>
 #include <linux/if_arp.h>
+#include <linux/slab.h>
 #include <net/cfg80211.h>
 #include "wext-compat.h"
 #include "nl80211.h"
index 9796f3ed1edbc5dce941f449aa235276628a3d86..e56f711bacccc21aa7ece74905d486c8f2dd1e5a 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <net/tcp_states.h>
 #include <asm/uaccess.h>
index 52e304212241055b32bf382960308afd5fea8079..b9ef682230a0cbe675cf42367608ac88ee050a6f 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <net/sock.h>
 #include <linux/if_arp.h>
 #include <net/x25.h>
index 056a55f3a8719f9bc6e7ff2336b16cc5e6994292..25a81079396863af36ac7e2eedb27c1d43c00b1d 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/if_arp.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/x25.h>
 
 LIST_HEAD(x25_forward_list);
index 96d9227835479474e6cedaeef6704f619c1683e8..a31b3b9e59663b4ee09e0bd3ae5a0afe8365e5c4 100644 (file)
@@ -23,6 +23,7 @@
  *                                       i-frames.
  */
 
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index e4e1b6e495386c6cb1673a9e29143e1681bea6f6..73e7b954ad288229df4d03bc164f07da183444cc 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/jiffies.h>
 #include <linux/timer.h>
+#include <linux/slab.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
 #include <asm/uaccess.h>
index 2b96b52114d6235980325df17ef92f8adb6c8dfd..52351a26b6fc4b713f034e9b2d7a1990247ca419 100644 (file)
@@ -22,6 +22,7 @@
  *                                     needed cleaned seq-number fields.
  */
 
+#include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
index b95fae9ab393976e682b245b537e8b9b6251e2d5..97d77c532d8c95550711c915cb2b02d65d99828f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/if_arp.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <net/x25.h>
 
 LIST_HEAD(x25_route_list);
index 352b32d216fc1ed2876fb51356f2af393fb19f8b..dc20cf12f39b59a16794ea49a3a11a01168c13d3 100644 (file)
@@ -23,6 +23,7 @@
  *                                             restriction on response.
  */
 
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/skbuff.h>
index 0fc5ff66d1faad83f205ac34884d882582d48260..fc91ad7ee26e7e8baa9b3f9f3b332425c55e5427 100644 (file)
 
 #include <linux/crypto.h>
 #include <linux/err.h>
-#include <linux/gfp.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/percpu.h>
+#include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/vmalloc.h>
 #include <net/ip.h>
index b9fe13138c070858980f8fa60334ca9b5990073f..6a329158bdfaa14de3891194e0c98ae70f4f1834 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/netdevice.h>
 #include <linux/netfilter.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <net/dst.h>
 #include <net/xfrm.h>
index 17d5b96f2fc8b6d8b7f290abbd67906526393a53..add77ecb8ac43cd85e6ebb1f57de839434dbb389 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/audit.h>
 #include <asm/uaccess.h>
 #include <linux/ktime.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 
index 2c4d6cdcba492cd2f70ac32a3e71b5b0abd17691..05640bc9594b7b5dc61b6e0dcd3b850e993af582 100644 (file)
@@ -1,4 +1,5 @@
 #include <linux/sysctl.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/xfrm.h>
 
index 3b126d1f8599198e6930ff7bd3c5690fb52ec138..d0c687fd9802220bd558303f54ccd683e77a3803 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/kobject.h>
 #include <linux/string.h>
 #include <linux/sysfs.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/init.h>
 
index f76f3d13276dd114c880e13ec45cad7452f992b9..6f97a13bcee4131aedbbf97a4f9db49c50e519e5 100755 (executable)
@@ -284,7 +284,7 @@ foreach my $file (@ARGV) {
        my $file_cnt = @files;
        my $lastfile;
 
-       open(my $patch, '<', $file)
+       open(my $patch, "< $file")
            or die "$P: Can't open $file: $!\n";
        while (<$patch>) {
            my $patch_line = $_;
index c7865c362d28fdbe160c94bfdd54e40bf34f8dd5..fcdfb245a5755d3bc534ac25d35728c214e8d03d 100755 (executable)
@@ -1424,6 +1424,8 @@ sub dump_struct($$) {
        $nested =~ s/\/\*.*?\*\///gos;
        # strip kmemcheck_bitfield_{begin,end}.*;
        $members =~ s/kmemcheck_bitfield_.*?;//gos;
+       # strip attributes
+       $members =~ s/__aligned\s*\(\d+\)//gos;
 
        create_parameterlist($members, ';', $file);
        check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1728,6 +1730,7 @@ sub dump_function($$) {
     $prototype =~ s/^noinline +//;
     $prototype =~ s/__devinit +//;
     $prototype =~ s/__init +//;
+    $prototype =~ s/__init_or_module +//;
     $prototype =~ s/^#\s*define\s+//; #ak added
     $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
 
index 6cf8fd2b79e80df26e142aa94e6fed9d4c3e7015..f77c604239926d464fb2d309675a5e6771ed53a6 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/list.h>
 #include <linux/uaccess.h>
 #include <linux/seq_file.h>
+#include <linux/slab.h>
 #include <linux/rcupdate.h>
 #include <linux/mutex.h>
 
index 2a5e0bcf38873f85188b75c75252e343cf2db12c..52015d098fdfd6d1823cf44ccfef1e754605884f 100644 (file)
@@ -13,6 +13,7 @@
  *     and store_template.
  */
 #include <linux/module.h>
+#include <linux/slab.h>
 
 #include "ima.h"
 static const char *IMA_TEMPLATE_NAME = "ima";
index ff513ff737f5c62861ff20e181567c195d126357..5af76340470c387401889530298c619ddcb0ec6c 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/gfp.h>
 #include <linux/audit.h>
 #include "ima.h"
 
index 46642a19bc78928759aaf753429c10c07e1bcb54..952e51373f5810ac43aef5615c0e6ee166e4eb04 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
 #include <linux/err.h>
+#include <linux/slab.h>
 #include "ima.h"
 
 static int init_desc(struct hash_desc *desc)
index 0c72c9c38956f1ac949f049db87fc17a3d8eed39..07cb9c338cc43a27c794efab3a565415901539c8 100644 (file)
@@ -16,6 +16,7 @@
  *     current measurement list and IMA statistics
  */
 #include <linux/fcntl.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/seq_file.h>
 #include <linux/rculist.h>
index 2d4d05d92fdacf01048ac9857541e8d17a3f0855..2c744d4880148605b13f5a9f5ed8a5d300581afc 100644 (file)
@@ -14,6 +14,7 @@
  *     - cache integrity information associated with an inode
  *       using a radix tree.
  */
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/radix-tree.h>
index a40da7ae590021933bbb2d5982fc7a61494947ff..b1bcb702a27c7a6db1a5360fafee0bedc5bda5a1 100644 (file)
@@ -16,6 +16,7 @@
  */
 #include <linux/module.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 #include "ima.h"
 
index 294b005d65206edb7219989c033c4bbe34eb3cbd..b2c89d9de2a475b790dbc1b804deca430714813a 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/binfmts.h>
 #include <linux/mount.h>
 #include <linux/mman.h>
+#include <linux/slab.h>
 
 #include "ima.h"
 
index 4759d0f99335c5d8e06d44fa4993f4b65f061bb8..8643a93c5963b174853140ef9e90d23e145141cc 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/security.h>
 #include <linux/magic.h>
 #include <linux/parser.h>
+#include <linux/slab.h>
 
 #include "ima.h"
 
index a0880e9c8e054695c757818b7991b2c37daf38ab..46ba62b1adf5813f341a317f4fbd982392076ac5 100644 (file)
@@ -20,6 +20,7 @@
  */
 #include <linux/module.h>
 #include <linux/rculist.h>
+#include <linux/slab.h>
 #include "ima.h"
 
 LIST_HEAD(ima_measurements);   /* list of all measurements */
index 9d01021ca0c8cdd9c25c8292daff990204ecf466..706d63f4f1855c89ed2df4d369d98cf3bb0a722c 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
index 5c23afb31ece464ad0165e1a3fb052a8969244c5..06c2ccf26ed3e36158b1e594192e9e06b376617d 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/keyctl.h>
 #include <linux/fs.h>
 #include <linux/err.h>
index acba3dfc8d297dfcd7a787839dac3cfff11663c6..893365b79a292dac685f344100460d057265be86 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <net/sock.h>
index b4e14bc0bf32bf6d0a9ae948d697912ca11e8769..d6095d63d831a63999f1921fbed460a94140fc39 100644 (file)
@@ -16,6 +16,7 @@
  */
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
index 2534400317c5554dff0fcc2b4bb68be3f61dc9fd..628da72ee76353f347e55b22c1162b0b2cda0441 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
+#include <linux/gfp.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
 #include <net/sock.h>
index 1ae556446e65a745f9caf670ea591f1ea3613ea5..0e147b6914ad1c9d1f7bb66967e8cabc39f2f94c 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
index 7100072bb1b0c88f56f4b9e50a48fa675338e297..dc92792271f1d8e59e01e9f4e9000d4f0090b2c0 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/in.h>
 #include <linux/in6.h>
index fe7fba67f19f0dd2c0b2c96c5a736ecb15bd362d..cfe2d72d3fb76b0f36a61471244dc1c8ec84b729 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/types.h>
 #include <linux/rcupdate.h>
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/in.h>
 #include <linux/in6.h>
index 837658a98a5418080d9e7264c450e780ee939b7c..bcf9f620426e04dfd102895bcf89b7f5d6b761bc 100644 (file)
@@ -4,7 +4,6 @@
  * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
  */
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/errno.h>
 #include "symtab.h"
index f3cb9ed731a9d927319c37bfc3a2e0d63f330db9..fff78d3b51a2ecddd1f18dd959ad99c80c090742 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv6.h>
+#include <linux/slab.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/skbuff.h>
index 0f9ac81469001d30d91a05af27974b116823d330..f4fac64c4da8b153aef2d4cb817d31348bab4110 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/types.h>
+#include <linux/slab.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include "smack.h"
index 5225e668dbf046fbe17ea105b23eb18cd11590d4..fdfeaa2f28ec641bc5b86f24c765d6ff49d2d702 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
+#include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/pipe_fs_i.h>
 #include <net/netlabel.h>
index aeead7585093a301c20826b9f316776fc295f4ce..a2b72d77f9265f7553c4bffb225644baf4bd44d0 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/vmalloc.h>
 #include <linux/security.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 #include <net/net_namespace.h>
 #include <net/netlabel.h>
 #include <net/cipso_ipv4.h>
index ef89947a774bbf419aadc0ba6b942985b75b5b50..975c45d88baad581d77dbc88be9048854c44ad83 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/uaccess.h>
+#include <linux/slab.h>
 #include <linux/security.h>
 #include <linux/hardirq.h>
 #include "common.h"
index 66caaa1b842a2a7e102313a2dcc199bd69debec2..acb8c397d5cfc93909087fbb2354aa4b7dc7f328 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "common.h"
 #include <linux/binfmts.h>
+#include <linux/slab.h>
 
 /* Variables definitions.*/
 
index 1b24304edb7de3135a2febcd0b15f35d66582dd9..6f3fe76a1fde6aabdd84a7998258e6b9e539aaa0 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include "common.h"
+#include <linux/slab.h>
 
 /* Keyword array for single path operations. */
 static const char *tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = {
index 9645525ccdd45cdc50ef9d915dd27642aa4a233f..d9ad35bc7fa823b7d2078cfa76ba6d7fa6736fb9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "common.h"
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 enum tomoyo_gc_id {
        TOMOYO_ID_DOMAIN_INITIALIZER,
index cf7d61f781b9768cc8691cd3b4fc4c234a313b55..c225c65ce426a682b587b9e0b96b25cfa4e09cf8 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/fs_struct.h>
 #include <linux/hash.h>
 #include <linux/magic.h>
+#include <linux/slab.h>
 #include "common.h"
 
 /**
index 84bb07d39a7fc29766fb1d0d019e0d08e392e664..91852e49910e24d9bee395e7dea36277edd08922 100644 (file)
@@ -33,6 +33,7 @@
  */
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
index 1dd66ddffcaf6b97cf46ef2fe2f055a7ca317d37..fd2188c3df2b4c436c9a6112cbc577c309d2898e 100644 (file)
@@ -66,6 +66,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
 MODULE_LICENSE("GPL");
index f13827e17562959d178d92edd76db44e545b84bc..69d2cb601f2a4daa7d32d6abda14c5095b56de01 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("toonie codec driver for snd-aoa");
index 1dd0c28d1fb72c6bfb85858afc1f665917b94f86..6776d1c12b63a30fafa4b16b52ddc638c1e0dcb2 100644 (file)
@@ -6,6 +6,7 @@
  * GPL v2, can be found in COPYING.
  */
 
+#include <linux/slab.h>
 #include <asm/pmac_feature.h>
 #include <asm/pmac_pfunc.h>
 #include "../aoa.h"
index 7a437da056465dc189619231d63dc1d0b6fb79dc..1cd9b301df0357dd7802626c93731d22c5efc73b 100644 (file)
@@ -12,6 +12,7 @@
 #include <asm/prom.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include "../aoa.h"
 #include "../soundbus/soundbus.h"
 
index 87beb4ad4d63a3b7f2521b8820941a6a44631c91..47f854c2001facf5f19f2df68686007972bb7d3f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
index 4e3b819d49930f07b7ce641c1de0a32b878f8bcd..9d6f3b176ed1ac73f20c4e8427403a9970ca0156 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
index 59bacd365733f869513df9cdb81797ad7389cfba..be838993926d74d0f1682ffdeda183ac8e8acd6e 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <asm/io.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <asm/macio.h>
 #include <linux/pci.h>
index 743ac6a2906598fdbd70a04f6a3c6910fd86fdfe..8808b82311b1eb207a2fb3306548666ad6dd6a8b 100644 (file)
@@ -4,6 +4,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
 
@@ -205,6 +206,7 @@ int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
        if (!rtd->dma_desc_array)
                goto err1;
 
+       rtd->dma_ch = -1;
        runtime->private_data = rtd;
        return 0;
 
index 368dc9c4aef8d905eff9eb4fb780abedf53fca04..426874429a5e088cf50414f6ab1f76dd7f8d1fd2 100644 (file)
@@ -21,6 +21,7 @@
 /* this file included from control.c */
 
 #include <linux/compat.h>
+#include <linux/slab.h>
 
 struct snd_ctl_elem_list32 {
        u32 offset;
index 7f4d744ae40ae7ce8102e1c6439fc306a5abb174..7730575bfadd93bc12d6d441c63098aa1238477d 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/hrtimer.h>
index d749a0d394a7fb5d2327e4e659dc42d194edd9b5..cc4a53d4b7f87155386697318d037671e75dab55 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/time.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/string.h>
 #include <sound/core.h>
index f705eec7372a32aad6187651cc393c69c2ce7e78..14b8a4ee690dfb4b5b8df9c5159f396c1677a171 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/input.h>
+#include <linux/slab.h>
 #include <sound/jack.h>
 #include <sound/core.h>
 
index 3da4f92427d8acc129bfba67d2ca29ea0fe56fb1..2c41825c836ec028c4725c2e038eb3937723c543 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/time.h>
+#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <sound/core.h>
 
index 0dcc2870d537752c98de1014df65330f051e9dfe..bbe25d8c450ad5e9e3d653b94215fc050fab521c 100644 (file)
@@ -19,7 +19,6 @@
  *
  */
 
-#include <linux/slab.h>
 #include <linux/time.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
index 08bfed594a83bfcf323472edbde17003f6fdeb28..5fb2e28e796f6a2766146dbdc5234a1de9a71680 100644 (file)
@@ -21,6 +21,7 @@
 /* This file included from pcm_native.c */
 
 #include <linux/compat.h>
+#include <linux/slab.h>
 
 static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
                                      s32 __user *src)
index b546ac2660f9f64b8436e3efe836cfa0f298afee..a2ff86189d2a583ad208c8e61beed816d3f23a67 100644 (file)
@@ -148,6 +148,9 @@ static void pcm_debug_name(struct snd_pcm_substream *substream,
 
 #define xrun_debug(substream, mask) \
                        ((substream)->pstr->xrun_debug & (mask))
+#else
+#define xrun_debug(substream, mask)    0
+#endif
 
 #define dump_stack_on_xrun(substream) do {                     \
                if (xrun_debug(substream, XRUN_DEBUG_STACK))    \
@@ -169,6 +172,7 @@ static void xrun(struct snd_pcm_substream *substream)
        }
 }
 
+#ifdef CONFIG_SND_PCM_XRUN_DEBUG
 #define hw_ptr_error(substream, fmt, args...)                          \
        do {                                                            \
                if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {          \
@@ -255,8 +259,6 @@ static void xrun_log_show(struct snd_pcm_substream *substream)
 
 #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */
 
-#define xrun_debug(substream, mask)    0
-#define xrun(substream)                        do { } while (0)
 #define hw_ptr_error(substream, fmt, args...) do { } while (0)
 #define xrun_log(substream, pos)       do { } while (0)
 #define xrun_log_show(substream)       do { } while (0)
index d6d49d6651f9122a389572db10d4f2ff078bbec2..917e4055ee30fdc37d6726e8af2f8d4d07506410 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/io.h>
 #include <linux/time.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/vmalloc.h>
 #include <sound/core.h>
index d0d721c22eacca6d4379dab12f9fc4dd57238eaa..685712276ac95ab0d57985489b86f4f840bcf9b1 100644 (file)
@@ -29,6 +29,7 @@
 #include "seq_oss_event.h"
 #include <linux/init.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 
 /*
  * common variables
index 9dfb2f77be608368ff897c948742dbf806fa52cd..677dc84590c79ae49dca0fb569fe4c98a44c068c 100644 (file)
@@ -28,6 +28,7 @@
 #include <sound/seq_midi_event.h>
 #include "../seq_lock.h"
 #include <linux/init.h>
+#include <linux/slab.h>
 
 
 /*
index f5de79f29f1e1a2aae91ede5d1bec3a65675fbdd..73661c4ab82aabefc2f26382db55854c704c8534 100644 (file)
@@ -25,6 +25,7 @@
 #include <sound/seq_oss_legacy.h>
 #include "../seq_lock.h"
 #include <linux/wait.h>
+#include <linux/slab.h>
 
 /*
  * constants
index 945a27c34a9d1b2e5a9ed993930c26357fca2c60..ee44ab9593c01819cc5f7fd0278801ca2cab0343 100644 (file)
@@ -24,6 +24,7 @@
 #include "seq_oss_midi.h"
 #include "../seq_lock.h"
 #include <linux/init.h>
+#include <linux/slab.h>
 
 /*
  * constants
index c440fdacec93dc752caff10a0c312f343e0e98b2..ab59cbfbcaf20b4263faebb55d092ef93c2a4923 100644 (file)
@@ -23,6 +23,7 @@
 #include "seq_oss_timer.h"
 #include "seq_oss_event.h"
 #include <sound/seq_oss_legacy.h>
+#include <linux/slab.h>
 
 /*
  */
index 217424858191e63bcd16b49e0f4d98c34192e6f5..d50338bbc21f1dbc2637ae9b2938716679b919c9 100644 (file)
@@ -27,6 +27,7 @@
 #include "../seq_lock.h"
 #include "../seq_clientmgr.h"
 #include <linux/wait.h>
+#include <linux/slab.h>
 
 
 /*
index c956fe462569238e1a396e69a86f73eb65200d45..81f7c109dc46e1b8ef9b4a2a67477fdf72940ef6 100644 (file)
@@ -21,6 +21,7 @@
 /* This file included from seq.c */
 
 #include <linux/compat.h>
+#include <linux/slab.h>
 
 struct snd_seq_port_info32 {
        struct snd_seq_addr addr;       /* client/port numbers */
index 77884e62b6483216981c0d2a9da553ac86b9f138..c38b90cf3cb07ac6c74514cfa807590dd6c92bcf 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include "seq_system.h"
 #include "seq_timer.h"
index 1950ffce2b545cdff262daae280128134259fa20..a1282c1c059130f0cae4c48473e9376c11227d11 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/platform_device.h>
 
 #include <linux/ioport.h>
+#include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
 
index 2f8f295d6b0cc731885c82d6907172a1a577788d..da03597fc893d0393869415f607f6ddbcaad31cb 100644 (file)
@@ -54,7 +54,6 @@
 #include <linux/interrupt.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
index 9284829bf9275e9c2afabbbe8e2026c35c2dfb60..8539ab0a0893db2933e39732f7073be3d2c1f166 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/parport.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/rawmidi.h>
index a54b1dc5cc7859f7b10316aed9fce1af5b9c391f..ade3ca52422ef81ca639698c739dee6863185670 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include "opl3_voice.h"
-#include <linux/slab.h>
 
 static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure);
 static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg);
index 6d57b6441dec53312de691a6caeb835ae2ef607d..301acb6b9cf9af792ddc33160989dcb8dbcc8769 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/slab.h>
 #include <sound/opl3.h>
 #include <sound/asound_fm.h>
 
index 01997f24c895708f19a4851061b42bce57c88b1d..f07e38da59b852748d31e3dfaf91140e943d57d6 100644 (file)
@@ -20,6 +20,7 @@
 #include "opl4_local.h"
 #include <sound/initval.h>
 #include <linux/ioport.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <asm/io.h>
 
index e1145ac6e9086d15ee14179b4b53493bec21ad91..d77ffa9a9387282ca077f199e367c0a5897152b4 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/moduleparam.h>
 #include <linux/interrupt.h>
 #include <sound/pcm.h>
index 60158e2e0eafb529e00013b4a9997d325b1b7fa2..f2b0ba22d9cec1b2de13c0b184e30f0f035e610f 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/parport.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/rawmidi.h>
index 46df8817c18f7b79faa466eb01fbb12af3149921..f7a6fbd313e31aa9059570d3b6c64a8471b97fe6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/device.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <sound/core.h>
 #include <sound/hwdep.h>
index c4c6ef73f9bf5ee32ee1f97ee62251b51d6339a1..ee538f1ae8462f0de200d66fa861009fae537a43 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/version.h>
 #include <sound/core.h>
 #include <sound/tea575x-tuner.h>
index 8246aae32ab436b8967f986753b955de747d1e0c..fe79a169acb52e794e9e33b74c5851b84659da70 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/isa.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
index cc15d1d65a22396276000862f28970eb6c5e8263..999dc1e0fdbd5fb95546ef0403a85b5715162c05 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/isa.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
index 9a43baae72503598e19eb483991aafa18d29cb8b..fb4d6b34bbca5c3e9dce8caeb7c885efd3f6e256 100644 (file)
@@ -80,7 +80,6 @@
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/isa.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/isapnp.h>
 #include <linux/moduleparam.h>
index 534a6eced2b810882a4676834926b3703fddf1d4..c7b80e4730fc280f7b3a24698bba5b1b59e503a2 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/err.h>
 #include <linux/isa.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/moduleparam.h>
 #include <asm/dma.h>
index 4be562b2cf219bd12402ddb7778fd50f4f684abe..787495674235ecf2e5b9708d2b98d585282b0a77 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/errno.h>
index 0481a55334b9aca8cc8717a9c5161502d80a16ad..265abcce9dba24ec1953101cfc721f5ad51c3241 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/isa.h>
 #include <linux/interrupt.h>
 #include <linux/pm.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
index 5913717c1be6e9768e3492cca53682682c64d23d..8c24102d0d9389aeca007de307f38fe836e38b53 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/isa.h>
 #include <linux/pnp.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/moduleparam.h>
 #include <asm/io.h>
index 4d2d0405bdc7bda05f0eb6a23a58d8d37e6da372..c35dc68930dc52ddd3ca0990aa2870995f84e753 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/err.h>
 #include <linux/isa.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/moduleparam.h>
 #include <asm/io.h>
index 91dc3d83e2cf8e9d1f01a4a92c20ad1865ccc2c7..ccedbfed061a3b290a92cba575868a18ae37462a 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "emu8000_local.h"
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
 
index 519c36346dec5e232ed162bb7a9552a777acc068..4d1c5a300ff84de4e75854dcfd17d2540ed4b453 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <asm/dma.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/pnp.h>
 #include <linux/err.h>
 #include <linux/isa.h>
index 3cd57ee54660716a8182d9c33e2771b4263500f6..81284a8fa0ceb56db3fc246638a792fffadba88f 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/isa.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
index a34ae7b1f7d0b71c2db484bccfb2294ee6e7d578..711670e4a4251e9cdc91a3b48350ec81a6c03a5c 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/isa.h>
 #include <linux/pnp.h>
index 2bb1cee092555df10d6f445a288b554ddbdfc0f1..657e2d6c01ac55fcf56f047b71632139304aad22 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/time.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <linux/firmware.h>
 #include <sound/core.h>
 #include <sound/snd_wavefront.h>
index 5d4ff48c4345418a4a2fb4fe4d8f782472484143..4fb7b19ff393292480da357a845f8420919bd161 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/wait.h>
 #include <linux/firmware.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/snd_wavefront.h>
 #include <sound/initval.h>
index 9a88cdfd952a0c609847442b24da8746d8aee51e..453d343550a880ae2480337a3ab7c055e001959a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/sgi/hpc3.h>
 #include <asm/sgi/ip22.h>
index 6aff217379d910d2a333bec3c4c950a8ffe593d3..717604c00f0add6bcab218e9b17e4de9dc6efcf7 100644 (file)
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
-#include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/ip32/ip32_ints.h>
 #include <asm/ip32/mace.h>
index d12bd98a37ba6f207190df984ae113be1e5e8dcd..24793c5b65ac186ab7b54815a5696f564881b99b 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/stddef.h>
+#include <linux/slab.h>
 #include <linux/isapnp.h>
 #include <linux/pnp.h>
 #include <linux/spinlock.h>
index 1bfcf7e8854632a7b395f9143b9fb3c3d0408545..bcc3e8e071229db29775632dc6a7380aeda0f6f5 100644 (file)
@@ -26,6 +26,7 @@
 #define SAMPLE_ROUNDUP 0
 
 #include <linux/mm.h>
+#include <linux/gfp.h>
 #include "sound_config.h"
 
 #define DMAP_FREE_ON_CLOSE      0
index 24d152ccf80d21ac6b751a85839bcaa8bedaa651..52d06a334e8f1a20ca43da9cc7dd8a347680b646 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 
 #include "sound_config.h"
 
index 0af9d24feb8fbbb47e8cfa41312a0aeff6f3ac4c..25e4609f83398128986537de66dd87fb1646006f 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
index 21eb6dce46df28bf17d2aa160244ac29db911425..c0cc951ba97d99d52fb0a067754380ba44ed905c 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/types.h>
 #include <linux/delay.h>
index bf27e008f465f29aed345549b583c3e7dcb75213..a1e3f9671beaffa9ff315f86d6af839102875e27 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/smp_lock.h>
+#include <linux/gfp.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 #include "sound_config.h"
index 7781c13c147635b53b06756e31b0daae50b583c0..938c48c43585ea88fa0be036b0765e24f3221ff0 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 
index 7de18b58f2cd8b3e05895ff33bd27aba607102db..84ef4d06c1c287e5ee77b641291c229d244cc0f0 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include "sound_config.h"
 #include "sb_mixer.h"
index ce4db49291f7862427fc74902970d8f78174049e..7d42c5418d1bb42ea6407ca284a6a0b498e7ec61 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include "sound_config.h"
 #include "sound_firmware.h"
index 8b796704e1120a15caaed0c96edffa67a34e8006..f139028e85c0dda9f30f9b3406f0e945f5d1bc70 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 
 #include "sound_config.h"
 
index fad1a4f25ad6db0402de24f24f0c21e1be301c54..2039d31b7e2248f25fdf3b38c81f264e1669ed4e 100644 (file)
@@ -16,6 +16,8 @@
  * Stanislav Voronyi <stas@esc.kharkov.com>    : Support for AWE 3DSE device (Jun 7 1999)
  */
 
+#include <linux/slab.h>
+
 #include "sound_config.h"
 
 #define __SB_MIXER_C__
index fde7c12fe5da9eac43384068c7c761b14cee193c..2d9c51312622fe4a10ea0bf202f24fb092a895ac 100644 (file)
@@ -36,7 +36,6 @@
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <linux/wait.h>
-#include <linux/slab.h>
 #include <linux/ioport.h>
 #include <linux/major.h>
 #include <linux/delay.h>
index a446b826d5fc87645738dacae9fbe3b31378b4ce..8e514a676a0d00df1dcff0ce71a57119b456b254 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include "sound_config.h"
 
index 103940fd5b4f46e9e2ae7c8435acf64938679faa..f0b4151d9b17c4abfe0dfff99bbce86759aea939 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include "sound_config.h"
 
index 725fef0f59a379d5dd8e2a71e1993dcf151046fb..ac39a531df19ef697eeb1e904d5677273d3f87c8 100644 (file)
@@ -17,6 +17,7 @@
  * We currently support a mixer device, but it is currently non-functional.
  */
 
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -363,13 +364,13 @@ static void vidc_audio_trigger(int dev, int enable_bits)
        struct audio_operations *adev = audio_devs[dev];
 
        if (enable_bits & PCM_ENABLE_OUTPUT) {
-               if (!(adev->flags & DMA_ACTIVE)) {
+               if (!(adev->dmap_out->flags & DMA_ACTIVE)) {
                        unsigned long flags;
 
                        local_irq_save(flags);
 
                        /* prevent recusion */
-                       adev->flags |= DMA_ACTIVE;
+                       adev->dmap_out->flags |= DMA_ACTIVE;
 
                        dma_interrupt = vidc_audio_dma_interrupt;
                        vidc_sound_dma_irq(0, NULL);
index 6713110bdc7506ed3b05a0259d626936c440a51b..20b3b325aa800d2e015799a093a53d7038a067cb 100644 (file)
 #include <linux/wait.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <asm/visws/cobalt.h>
 
index 2c63bb9da74a019a5df655e7960aa0c4b893b670..e688dde6bbdeb0b54ae26c761eaba38b1ede5a95 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
index 1caf5e3c1f6ad481064ea70cced23293333de96a..e68c98ef4041508c2f9a2361172ab592be3ec90c 100644 (file)
@@ -1852,12 +1852,14 @@ static unsigned int ad1981_jacks_blacklist[] = {
        0x10140523, /* Thinkpad R40 */
        0x10140534, /* Thinkpad X31 */
        0x10140537, /* Thinkpad T41p */
+       0x1014053e, /* Thinkpad R40e */
        0x10140554, /* Thinkpad T42p/R50p */
        0x10140567, /* Thinkpad T43p 2668-G7U */
        0x10140581, /* Thinkpad X41-2527 */
        0x10280160, /* Dell Dimension 2400 */
        0x104380b0, /* Asus A7V8X-MX */
        0x11790241, /* Toshiba Satellite A-15 S127 */
+       0x1179ff10, /* Toshiba P500 */
        0x144dc01a, /* Samsung NP-X20C004/SEG */
        0 /* end */
 };
index 73b17d526c8bb2cce8420d6f79f4ac88aae402b6..6320bf084e476a48d1a0bac92542337f3173f411 100644 (file)
@@ -22,7 +22,6 @@
  *
  */
 
-#include <linux/slab.h>
 #include <linux/mutex.h>
 
 #include <sound/core.h>
index d75cf7b0642684a8d2f7a6ebde3ee1296ece0ea4..6cf1de8042e80c400eebdc88691b5c16a86eb1d1 100644 (file)
@@ -68,7 +68,6 @@
 #include <asm/io.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/gameport.h>
 #include <linux/moduleparam.h>
 #include <linux/dma-mapping.h>
index 296123ab74f7e94b6c911fc52eb852a760e26b6b..8afd8b5d1ac73420e408427fb8536f96d0384db7 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <asm/system.h>
index 8f443a9d61ec92628dc17316719e447cab8f1c1b..85fd315d99990d6cba86001840d5cd7389975e2a 100644 (file)
@@ -63,7 +63,6 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/initval.h>
index 0470461cc03eb8887e9f79459e206cad99b9b5e2..ba96428c9f4cfc8dfa468b37b6098cd171fc6ec8 100644 (file)
@@ -63,7 +63,6 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/initval.h>
index 1ded64e056433e22f8e96d8b0fbeb6dbf2c557d4..329968edca9b840fc622602535b0088cdb73bd6c 100644 (file)
@@ -941,13 +941,21 @@ static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci
                                                struct snd_pcm_substream *substream)
 {
        size_t ptr;
-       unsigned int reg;
+       unsigned int reg, rem, tries;
+
        if (!rec->running)
                return 0;
 #if 1 // this seems better..
        reg = rec->ch ? CM_REG_CH1_FRAME2 : CM_REG_CH0_FRAME2;
-       ptr = rec->dma_size - (snd_cmipci_read_w(cm, reg) + 1);
-       ptr >>= rec->shift;
+       for (tries = 0; tries < 3; tries++) {
+               rem = snd_cmipci_read_w(cm, reg);
+               if (rem < rec->dma_size)
+                       goto ok;
+       } 
+       printk(KERN_ERR "cmipci: invalid PCM pointer: %#x\n", rem);
+       return SNDRV_PCM_POS_XRUN;
+ok:
+       ptr = (rec->dma_size - (rem + 1)) >> rec->shift;
 #else
        reg = rec->ch ? CM_REG_CH1_FRAME1 : CM_REG_CH0_FRAME1;
        ptr = snd_cmipci_read(cm, reg) - rec->offset;
index 207479a641cff3fb115ff75f0cd861ec56227fe4..bc07e275d4d4237879f03cbb80eaa78ff233b087 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/delay.h>
 #include <linux/moduleparam.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/sb.h>
 #include <sound/initval.h>
index 0f48a871f17bf756ac05cde5d408ed8cae36b37d..f16bc8aad6ed205a7f7b983e9486e4437090c875 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <sound/core.h>
 #include <sound/control.h>
index 564c33b60953964129619309e4a39090ca47fb97..a3301cc4ab822e640a30d80dee10e9222adb66a3 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <sound/core.h>
index 480cb1e905b61af9a5c3c12aaed35da17376ecd5..1bff80cde0a2f88000eaa1711867b882adcae433 100644 (file)
@@ -24,6 +24,7 @@
 #include "ctdaio.h"
 #include "cttimer.h"
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/pcm.h>
 #include <sound/control.h>
 #include <sound/asoundef.h>
index d0dc227fbdd3ceaeccc72cbcb6b7191ff037e662..85ab43e89212c6724c1e70f3cad3de33e9816935 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "ctpcm.h"
 #include "cttimer.h"
+#include <linux/slab.h>
 #include <sound/pcm.h>
 
 /* Hardware descriptions for playback */
index a65bafe0800f8c727569024e699f395231d4a46a..fe7ad64dccd7361a2a4f88df437d7a84de4a0743 100644 (file)
@@ -40,9 +40,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 0a6c50bcd758073c0a7ba0de4043c886c71a2351..d1fd34b1a8e35971a06fe943247d23aa96de12f1 100644 (file)
@@ -44,9 +44,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index f5142796989b074480949b61a39c73c55f4ce7a3..1dffdc54416d3e1fbe33c3d876e9d0fb4a1d1c0e 100644 (file)
@@ -51,9 +51,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 2364f8a1bc21509e678c6d09eab207f2efa0e0c7..050e54aa693f5e90f6b0b87ffb61b1f994a37a02 100644 (file)
@@ -44,9 +44,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 616b55825a194af53d8bee426987422bd07ba0f1..5748fc6d29d627b2a3dd6c9c03548aa1a74b109e 100644 (file)
@@ -50,9 +50,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 776175c0bdad10c4bb86b014274dc349aac5db02..4ae5e35cb5f17e76f64d329760ae2db5f0fd43ce 100644 (file)
@@ -42,9 +42,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 8816b0bd2ba61102ea2b922d88f61efcccfb56c2..3550715bab1c101b7a78e8923fba782d7cfb6b23 100644 (file)
@@ -42,9 +42,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index b1e3652f2f485669874130be56287e97080133f7..19b191fd0120d62dfca64fa9559c5adc0dd86177 100644 (file)
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 1035125336d6f89a0f36bc63d1bd5c8e67fae735..a9fcedf317a4007a18249e9882244165bcbc98dc 100644 (file)
@@ -43,9 +43,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 60b7cb2753cfd2fd1968bc6f978e95b542f62cfc..bcdfac63212c78a8ee2017e8f9406eba31237e24 100644 (file)
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 8c3f5c5b53013a879b5848663d7aadab209e2023..d3a98c5dac86e32261c9d47101f8f9633942e800 100644 (file)
@@ -49,9 +49,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index ed1cc0abc2b82cf2a8523ad4711c3b8cfce90f0b..2a1dca6dce17832d5a6d3c30607e1591fd395ac1 100644 (file)
@@ -51,9 +51,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index cc2bbfc65327f23284a3000257aa261e497f2189..9cdf14cfdd741d2147acb9a47e9986f54a523df6 100644 (file)
@@ -50,9 +50,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 3e7e01824b4073febd740144f906a460d77670c9..1047be405ebe03dcd2df3eb4a6be1e4e90db6621 100644 (file)
@@ -48,9 +48,9 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
index 6a47672f930aedfe67163ce56a0e5a726470e734..ffb1ddb8dc28ea1d3fbdf574d0c4efbef9772c98 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/gfp.h>
 #include <linux/time.h>
 #include <linux/mutex.h>
 
index e4581a42ace56e62ba0e530f5a6cbd360f43b2d3..29714c818b53b9387609b67b409e7b15bf9ea2ef 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/input.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <sound/core.h>
 #include "hda_beep.h"
index dcd22446cfc7103bba5339097adae355b8a33b2c..d8da18a9e98b9051a05c15d426f964c29fcf9b21 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <asm/unaligned.h>
 #include "hda_codec.h"
index 8b2915631cc38bcde8e6490cc9947de4c6110684..4bb90675f70fced63e22fe1f9b70283b2094e673 100644 (file)
@@ -2269,6 +2269,7 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
        SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB),
        SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB),
        SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
+       SND_PCI_QUIRK(0x1458, 0xa022, "ga-ma770-ud3", POS_FIX_LPIB),
        SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB),
        SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB),
        SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB),
index 194a28c5499219b99d3b10ed2ae357cde7707679..61682e1d09da9388048b3a1d95fce96a44001175 100644 (file)
@@ -1591,6 +1591,21 @@ static int patch_cxt5047(struct hda_codec *codec)
 #endif 
        }
        spec->vmaster_nid = 0x13;
+
+       switch (codec->subsystem_id >> 16) {
+       case 0x103c:
+               /* HP laptops have really bad sound over 0 dB on NID 0x10.
+                * Fix max PCM level to 0 dB (originally it has 0x1e steps
+                * with 0 dB offset 0x17)
+                */
+               snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
+                                         (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
+                                         (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                         (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                         (1 << AC_AMPCAP_MUTE_SHIFT));
+               break;
+       }
+
        return 0;
 }
 
index 70669a246902570de791822919fecba4fc0d5f19..3c10c0b149f4c682d683a6ae21ae837b3fe18f4d 100644 (file)
@@ -538,8 +538,6 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec)
  * patch entries
  */
 static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
-       { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
-       { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
        { .id = 0x10de0002, .name = "MCP77/78 HDMI",
          .patch = patch_nvhdmi_8ch_7x },
        { .id = 0x10de0003, .name = "MCP77/78 HDMI",
@@ -550,12 +548,16 @@ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = {
          .patch = patch_nvhdmi_8ch_7x },
        { .id = 0x10de0007, .name = "MCP79/7A HDMI",
          .patch = patch_nvhdmi_8ch_7x },
-       { .id = 0x10de000c, .name = "MCP89 HDMI",
+       { .id = 0x10de000a, .name = "GT220 HDMI",
          .patch = patch_nvhdmi_8ch_89 },
        { .id = 0x10de000b, .name = "GT21x HDMI",
          .patch = patch_nvhdmi_8ch_89 },
+       { .id = 0x10de000c, .name = "MCP89 HDMI",
+         .patch = patch_nvhdmi_8ch_89 },
        { .id = 0x10de000d, .name = "GT240 HDMI",
          .patch = patch_nvhdmi_8ch_89 },
+       { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
+       { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
        {} /* terminator */
 };
 
@@ -564,11 +566,12 @@ MODULE_ALIAS("snd-hda-codec-id:10de0003");
 MODULE_ALIAS("snd-hda-codec-id:10de0005");
 MODULE_ALIAS("snd-hda-codec-id:10de0006");
 MODULE_ALIAS("snd-hda-codec-id:10de0007");
-MODULE_ALIAS("snd-hda-codec-id:10de0067");
-MODULE_ALIAS("snd-hda-codec-id:10de8001");
-MODULE_ALIAS("snd-hda-codec-id:10de000c");
+MODULE_ALIAS("snd-hda-codec-id:10de000a");
 MODULE_ALIAS("snd-hda-codec-id:10de000b");
+MODULE_ALIAS("snd-hda-codec-id:10de000c");
 MODULE_ALIAS("snd-hda-codec-id:10de000d");
+MODULE_ALIAS("snd-hda-codec-id:10de0067");
+MODULE_ALIAS("snd-hda-codec-id:10de8001");
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec");
index 4ec57633af88efb14ce5a632d2dbf1c67d91b7cf..9a23444e9e7ac2ee609678c6fb8a8f9a91ee1e1d 100644 (file)
@@ -2532,8 +2532,6 @@ static int alc_build_controls(struct hda_codec *codec)
                        return err;
        }
 
-       alc_free_kctls(codec); /* no longer needed */
-
        /* assign Capture Source enums to NID */
        kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
        if (!kctl)
@@ -2602,6 +2600,9 @@ static int alc_build_controls(struct hda_codec *codec)
                        }
                }
        }
+
+       alc_free_kctls(codec); /* no longer needed */
+
        return 0;
 }
 
@@ -10042,8 +10043,11 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
        alc_set_pin_output(codec, nid, pin_type);
        if (spec->multiout.dac_nids[dac_idx] == 0x25)
                idx = 4;
-       else
+       else {
+               if (spec->multiout.num_dacs >= dac_idx)
+                       return;
                idx = spec->multiout.dac_nids[dac_idx] - 2;
+       }
        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
 
 }
index 8c416bb18a57cef781249611bdbae060212b924d..c4be3fab94e58c44e50d9218279c632b490378e4 100644 (file)
@@ -1730,6 +1730,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
                      "HP HDX", STAC_HP_HDX),  /* HDX16 */
        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
                      "HP dv6", STAC_HP_DV5),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
+                     "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
                      "HP", STAC_HP_DV5),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
index 03391da8c8c7741304fff11f4e8ccc044393e984..90d560c3df13c4a3e92268809d5435177fdfebb3 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <sound/core.h>
 #include <sound/initval.h>
index 6da21a2bcade940c9104bdcbd5ad85972d5eb468..e328cfb7620c77bd80d1c3788c373f6ababfc520 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <sound/core.h>
 
 #include "ice1712.h"
index 7f9674b641c0c8e98e171c6bfcc5e80bd370d213..4c551e147c089d8186db424d6bc630ddeead58b1 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <sound/core.h>
 
 #include "ice1712.h"
index 5af9e84456d1c801be959f1053d01c4a6a57b3cc..e618f789026ea7dc4ff2ddddf4fc46a3e1328a39 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <sound/core.h>
 
 #include "ice1712.h"
index 0cca56038cd94d406fc4150f5494855916677afc..ef9af3f4ace2f6fda837a89e4ea46ff8821fd86c 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <sound/initval.h>
 #include <sound/control.h>
index 7e8e7da592a98e01faf4804e6983dba9fc07878c..55e9315d4ccd0385d5d3ea4c0d9d813f7200c9a0 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
index 4cf4cd8c939c518629200903123ede9d7eec94d2..bf2696aa5d49021db7c1b37bdbf5a7968c16ae93 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci.h>
 #include <linux/firmware.h>
 #include <linux/vmalloc.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 #include <sound/core.h>
 #include "mixart.h"
index 9c5e6450eebbec3c1d11deef24053193f75ceb41..fad03d64e3ad0c936aca79a257f6c484b067f657 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
 #include <linux/pci.h>
+#include <linux/slab.h>
 #include <sound/ac97_codec.h>
 #include <sound/asoundef.h>
 #include <sound/core.h>
index d5e1c6eb7b7bba56f7a57e4b34229290d466a529..3c04524de37c06afbc341809a67e14659edfa975 100644 (file)
 
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 
 #include <sound/core.h>
index 9d5252bc870c15e2d86a4558a5ffb24124eda574..d19dc052c3912f0aa235f8fae0344b5f241833fa 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 
 #include <sound/core.h>
index 52c6eb57cc3f51fafa7f39c165543e046dd52016..b92adef8e81e7ae61eef5681925610b87f03a502 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/firmware.h>
 #include <linux/moduleparam.h>
index 44a3e2d8c5563e757fe437c569a45658ce471b41..c492af5b25f3e43a9530b69e5c6f7fc591ea30be 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/slab.h>
 #include <linux/moduleparam.h>
 
 #include <sound/core.h>
index 7e3e8fbc90fefca268bde1a8ec27361b8889ac78..9cc1b5aa0148f92445986601b6399ca1eb9a8306 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/time.h>
+#include <linux/slab.h>
 #include <linux/moduleparam.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
index 5d2afa0b0ce430012f48d0c038b455a6dce41a04..9dce0bde5c05b078ba32ffb5e18b775353c9a7d3 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include "pdaudiocf.h"
index 0d668f471620cc81283142cc16cc0d1159cb84f9..43f995a3f96033c081499dd41002541279252b95 100644 (file)
@@ -20,7 +20,6 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <sound/core.h>
 #include <sound/asoundef.h>
index 7be3b335704597d0a7808e8cc4eae1356ded7f73..cfd1438bcc644a2658845d38cd015d207e023eca 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/init.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include "vxpocket.h"
 #include <pcmcia/ciscode.h>
index 1f72e1c786bf2f389e18788bd3b304287312617a..00e2d5166d0a2fc277da60e02bebb1206608a5d3 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <asm/io.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <sound/core.h>
 #include "pmac.h"
index d06f780bd7e84ad088163eb52e134c8c57188956..8f064c7ce74569348d0af6a035f97c353af9ac71 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
-#include <linux/slab.h>
 #include <sound/core.h>
 #include "pmac.h"
 
index 53c81a547613ee0482c8dd64b9c3bb0a7b88f2e6..2f12da4da561f6eeec98a028d7163c68e112b5dd 100644 (file)
 
 #include <linux/dma-mapping.h>
 #include <linux/dmapool.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/slab.h>
 
 #include <sound/asound.h>
 #include <sound/control.h>
index 76d9ad27d91cd73d76a3a3b2d75d56594162409a..68e0dee4ff0593a0ad56fc4f2583c2c13c4312de 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
index 340311d7fed55055c44fa58520878920ffba3dfe..a61ccd2d505f010fd9720a29c8ce318e7d27819e 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
index 0cf2ca61c7764bf38a2df63f088a675fee317265..495be6e7193169fcdf22400a682915d4966c3cc9 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/suspend.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
index 67cbfe7283da1c481cbaafad4c731de17b670a76..5e7aacf3bb5a2027c2decfe98e3b49919c04a207 100644 (file)
@@ -29,8 +29,8 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index e69322978739d760e27bf47aaf61021cbf958deb..523b7fc33f4e7f94b5d1f6f6ffd89f9e904479c5 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/wait.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index c6c6a4a7d948feb34402bd0d332d84f738a529bd..1d2a1adf25759070cfa96a3cab81c89c31630b30 100644 (file)
@@ -29,8 +29,8 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 5e03bb2f3cd7db4ddc9f72337709b4f56d07c8a4..6bac1ac1a315b72ee8b9fe134f4b94665a2cb47b 100644 (file)
@@ -29,8 +29,8 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index a1bbe16b7f9613e3129ebdb8819125c2b7c7463a..fd101d450d56d0f89bbb906cdf6744c8690008e7 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <sound/core.h>
index 3c80137d59382198138af20ef2050338a6b9a73d..11b62dee842cecd84c57cb94642fff41e2e091d2 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index c233810d463df1c4e50c866dd277b94d3b9bd81a..240cd155b313315fe4fbd9b03cf51fcb6402f7f1 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index 39c0f7584e656ab78f71d6d70e28abac9ec6d131..042072738cdcf6d3edf051b097d6ab13b1a64a0a 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index d2fcc601722c17b23d24d144a502009063d7d728..475807bea2c229d04e4e3ed91dd8647ffa26d259 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index cc96411ca3e6ec0547202f06a0db55dab6e885a0..f8e75edb27b7ec793f21f32e10200db2d734148c 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <sound/core.h>
index b68d99fb6af0a41ce8b3f55781c82cda336f07ae..bdeb10dfd88728bb17ad68f45353d15e290a2ef8 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/soc.h>
 #include <sound/initval.h>
index ff966567e2bad1e2f5a3ae39b782205cb7122399..352d1d08dbd95ae10bb47e571392e641245c9db3 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 3ef16bbc8c8397a3e808f63901c12fddd3135ad8..729859cf6ca8696b0c4f6218d167c9e04fcdbfef 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 82fca284d00761c67ed920c000236b4e9fbd5bf8..926797a014c75716f069db87d03a1f7dbd3e43ba 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
index dfbeb2db61b3e25011c24276cab47a58425aa788..81a62d198b7002b92f9df5d82c7cdd30b625b7c0 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/soc.h>
 #include <sound/initval.h>
index e000cdfec1ec20550abe154c2939bad4365e0e7b..9f169c4771080c43a06f509771619339589dedad 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/tty.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
index cf2975a7294af95ec306851c92785d64d0e8199c..366daf1d044e04959489c71f161c5aad376b17b7 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 2afcd0a8669d308a1ab658cbbfa7f823961fdf8a..5a5f187a265738283cb4f05049f78d12430d9789 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/initval.h>
index d2ff1cde6883c31412559540c7f3a37dcc2d06f8..29d0906a924a89e4da8c3ffbe65830acbcdf7ce6 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 81b8c9dfe7fc3253034c034afd288d500cd26848..3293629dcb3b65bc862b4ab008cffb3d6c90437f 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <sound/core.h>
index da589d8664d0d52ce44d6cc0efc7f57981cfdd69..776b79cde90402bbbde5784fec34f415e7637ecc 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 357b609196e35aecf223be365a383591bec5cd7a..b5b7d6a03844d2834cca44c9fb5f54c364f3faa7 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/device.h>
 #include <linux/sysfs.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index e4b946a19ea3e958b46969be2561e03764c1096d..4a6d56c3fed9f6fa740dc63dbe1ece1201f5bfd4 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index f9f367d29a9095e8bc5a44be2da0da9b45f4ba7e..d1e0e81ef30c6bf0da79e8fb3a6354a0c78cf81a 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -778,7 +779,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream)
        if (dac33->fifo_mode) {
                /* Generic for all FIFO modes */
                /* 50-51 : ASRC Control registers */
-               dac33_write(codec, DAC33_ASRC_CTRL_A, (1 << 4)); /* div=2 */
+               dac33_write(codec, DAC33_ASRC_CTRL_A, DAC33_SRCLKDIV(1));
                dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */
 
                /* Write registers 0x34 and 0x35 (MSB, LSB) */
@@ -1038,11 +1039,7 @@ static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai,
        case SND_SOC_DAIFMT_DSP_A:
                aictrl_a |= DAC33_AFMT_DSP;
                aictrl_b &= ~DAC33_DATA_DELAY_MASK;
-               aictrl_b |= DAC33_DATA_DELAY(1); /* 1 bit delay */
-               break;
-       case SND_SOC_DAIFMT_DSP_B:
-               aictrl_a |= DAC33_AFMT_DSP;
-               aictrl_b &= ~DAC33_DATA_DELAY_MASK; /* No delay */
+               aictrl_b |= DAC33_DATA_DELAY(0);
                break;
        case SND_SOC_DAIFMT_RIGHT_J:
                aictrl_a |= DAC33_AFMT_RIGHT_J;
@@ -1066,7 +1063,7 @@ static void dac33_init_chip(struct snd_soc_codec *codec)
 {
        /* 44-46: DAC Control Registers */
        /* A : DAC sample rate Fsref/1.5 */
-       dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(1));
+       dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(0));
        /* B : DAC src=normal, not muted */
        dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT |
                                             DAC33_DACSRCL_LEFT);
index 958d49c969ac3d78696f2276f131d9b13ba71d9f..569ad8758a84bcbe0f02dd3b27bdd28d959b8285 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/i2c.h>
 #include <linux/gpio.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/tpa6130a2-plat.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
index 6f5d4af200526ed5477f1870b9c48a048aa2865b..520ffd6536c3c44a46fcff4cc811d4408f234fc2 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/i2c/twl.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 3e99fe5131ddff15fe308968412c7da8977b2ba6..a8dcd5a5bbcb2e0ac743e95a731ecb4c7e1c123f 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/module.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
index 217b02680597ef14b7eabd2771e17e528c84345b..a34cbcf7904ff2067b807d6991c347871b81ea5c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index df2c6d9617fb78d07b2bc3b4edec741f8b808339..2e0772f9c456fe63d6cb8c5ae0f17bffbb6a1cf4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/platform_device.h>
index b432f4d4a3247bb4df2763bcc5c00a97779a7ed1..6acc885cf9b7489741a354f3f83ccdfb93dd5e78 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
index af8cb6995a1f5d053ffda2e348c6cf489270d5f2..9000b1d19afbc2ab18f03ca6dab0227cdd472d49 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index d3a61d7ea0c509414e4a113def31b547fba33d6b..19cd47293424b19965a50ff4ca7388ed30e81585 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index d077df6f5e7515a6cb98ab727bf83d4529b05274..8cc9042965eb070afeba101cdd3e578e31519bff 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 24a35603bcf732d563034f4cd2491a78a76a0d20..8ca3812f2f2f1e77eb6e4872d3e7ad4c39e43d93 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 63a254e293cae381d3f9c6c2d27ec985fd1d35ad..1072621e93fdee9de08476cfcd915fed2c792999 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index 3fb653ba363a1da03ab8d702ab6add9b45e4cb34..07adc375a706f4c14cee3ca4effbe74944ccc00b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 5a2619dbf283b8a6195eb912dae6fb2c9ae96149..e7c6bf163185e3810425cf42c723d499f2e02bf6 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
index 475c67ac7818e39e417d21c9a43fb96ab0833841..2916ed4d384449a55da18a294ec2259cb9845683 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index c2444e7c848025524ada66f2ef8631112d15f908..613199a0f799e60bc8327017c9c7aaf09558b2dc 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 44e7d9d82f87d7b7e658272fc7fcedd67129c832..60b1b3e1094b55aca16f04d474e3dc072a0a7d32 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index dbc368c08263adab922dfbbd62570cb73409926f..b7fd96adac643043a3e4bfe0b45c984112bdbc77 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 3595bd57c4eb8911bf7a63a8122028a746aaf931..fa5f99fde68bfcc7ca19b62e874589742acd0c2b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 593e47d0e0eb87e8e97d384eb434a456242e842c..c6f0abcc57113449228f6a4ac7c754f96c3d0a23 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 31e39ffd1d8e84f27ae1f0daf5ca17e22c14331a..0c04b476487f40f85cb1358ad7ba829c8b89b772 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 615dab2b62ef46a09841b0f5cf5edea2f379fa72..c8d7a809af4d157ba9711362aa86160db8033ead 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index d07bcc1e1c603ed9a86e06c2e293bdb51358d271..f1e63e01b04d3621ef2124946b954d92cac7f525 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index d2342c5e0425f2e861d8861d80cffd2a3b81ef1a..50634ab76a5cde6be72d09070415d1a329c3698e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index d9540d55fc89b6b96ec108f896cc7572f8c74176..a65b781af512b1d1c794fdd2c5a5ac22c2f442ca 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index ee637af4737a039c252c82c287f5c37e22b4ee37..69708c4cc004c9de2abb1f6bdd781c0634307d93 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 28bb59ea6ea1597cae32396fd18e65f8bcbe2338..526f56b0906663fe681ec970bcd3d24a44a4b7a6 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 2862e4dced27fc2ff20a338c3f4461674a4dcf21..bb18c3ecfeb931f314262ea77945810f13a3d09c 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 056b787b6ee09d1f9948c67d0d7acb2d9abbf887..831f4730bfd5bff798ee60e63d54e8f0b0b5f9ff 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index bf022f68b84f114ccc44835910df1315bca3fe70..03e8b1a6a56ca48645b0986ac5afbfd4dc16565b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/i2c.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 29f3771c33a4448838b3934b9f7a430be737e142..8d1c63754be4fecba0c6b95bded9d8fc8f5ecabd 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index c468497314ba4291314e856e26d3bb50c9c9b5b7..3a184fcb702b513cadc18969cc0387f2b246da2d 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index ec54c6da9856e58dab9d34163f0d57565b9d511f..8793341849d1bafdc2e13f1c7564bd655cf440fe 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index e237bf615129cb7e32799f85762842bd683898a4..2f48a8aae22c0c5f72410a20f691b07345fb678b 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
index ceb86b4ddb25286076d00fb5fc7aeffce9e234bc..2fca514fde5851ea5d7462962b41ef7776ea40e8 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <sound/core.h>
index 0ad9f5d536c67bf89afe1172ef863cff2fdfd6d0..486bdd21a98ab9115f6ee6e37133491079d0ca4d 100644 (file)
@@ -74,7 +74,7 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec)
                msleep(1);
                reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_0);
                dev_dbg(codec->dev, "DC servo: %x\n", reg);
-       } while (reg & WM8993_DCS_DATAPATH_BUSY);
+       } while (reg & WM8993_DCS_DATAPATH_BUSY && count < 400);
 
        if (reg & WM8993_DCS_DATAPATH_BUSY)
                dev_err(codec->dev, "Timed out waiting for DC Servo\n");
index 6362ca05506e0e011312ff023446b2eb0a7da440..62af7e025e7f9a286d4c05dba37e67f5938fd918 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/clk.h>
index ab6518d86f1886c14b18fe4c436cba2a9d6c2f07..6c80cc35ecadeb5df31c90ee03c0a375933050fc 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
+#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/clk.h>
index b1a3a278819fe6fa16a1a14d38b02221a05517e2..410c7496a18dd295cec46770176ba960ca46686b 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/gfp.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 93f0f38a32c99fb26299c288d3ce0ca442f55914..762c1b8e8e4e078e48efede6dfc52b5a81eb4fc4 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 30ed568afb2ef5c24316e1fe1ae24c34a795adac..d639e55c51241dad15eb984815c69f9461a26797 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/slab.h>
 
 #include <sound/soc.h>
 
index ef67d1cdffe7e4409c28f889a660351c8bfc2da9..83de1c81c8c410e580ae9b2b286cf8a99faca4b0 100644 (file)
@@ -9,6 +9,7 @@
  * express or implied.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/of_device.h>
index 8bc5cd9e972fc89a2223dc32f01c42cbffd15fea..3bc13fd890969efda650ada0d28a68d72b934b3e 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index c7d0fd9b7de884522ee02f1ef838dccd8ed53269..7174b4c710de4451f974214558af0dc27516457d 100644 (file)
@@ -1,6 +1,6 @@
 config SND_IMX_SOC
        tristate "SoC Audio for Freescale i.MX CPUs"
-       depends on ARCH_MXC && BROKEN
+       depends on ARCH_MXC
        select SND_PCM
        select FIQ
        select SND_SOC_AC97_BUS
index 19452e44afdc7190c4ba7995d4a3c802f6d35bde..86668ab3f4d4cc01974a2b12c48adc09c1c1ecab 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
index d9cb9849b033e04100125c50b47fa3ebb2362feb..f96a373699cf4a1e628365bf261dbf551b2ef173 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
index 56f46a75d2972515f19e3bb89c8bf6f50960375d..6546b06cbd2a5984709eca74450fee6b7dfba083 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/initval.h>
index ad8df6cfae883120daa6c2b7389aec22ccd72e0b..1dab4c14874d45289b2a601a001f9c5fbb2ebf5a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/wait.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
 #include <linux/clk.h>
index 825db385f01f16d3b0f64a21fbfc3238c801e873..ba8acbb0a7fac51027da0f8181ef4488e1b44c78 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 9e95e5117c88f8c6a95cbfe25e60cd66f22c92e2..d5fc52d0a3c4127a526d07de96bdaaf8ecdbe1e1 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
index c5cda187ecab6d5f72285959e39e525d34f3ffb9..0664fac7612a311b7703958cbc3885bdff55b979 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/clk.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 106674979b535a54110ba0b1a0e47048178bb9e9..f07f6d8b93e14cf8f038416154361bc7b8038aee 100644 (file)
@@ -32,6 +32,7 @@ config SND_SOC_SH4_SIU
        select DMA_ENGINE
        select DMADEVICES
        select SH_DMAE
+       select FW_LOADER
 
 ##
 ## Boards
index baddb1242c715d26dfdfe08aeec0557a6f22fe7e..0d8bdf07729c559daaf7bc861f379c7b3bbddf0d 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
index 993abb730dfaf92c9d9546045eafcf448148de3c..8dc966f45c36ac3786c1506d1041a98532221425 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/list.h>
 #include <linux/pm_runtime.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/initval.h>
index 5452d19607e11adf0fe3c6361ee1769600a29656..d86ee1bfc03ae2bc4fbc5843f359c7901591d7bf 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/firmware.h>
 #include <linux/pm_runtime.h>
+#include <linux/slab.h>
 
 #include <asm/clock.h>
 #include <asm/siu.h>
index ba7f8d05d9775b8427381220dc33a3f3292e026e..8f85719212f96283351a9381a2419afc8adf2d96 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 
 #include <sound/control.h>
 #include <sound/core.h>
index c8b0556ef4316a0030a4b392226fc733dbf48877..2320153bd923fc46ff2d313d936174bc15125979 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/ac97_codec.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
index 6c3351095786f224448f62277d61aa583dfe000a..7c28f401f436a8a6fb499c6f788c1488b5c91512 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/platform_device.h>
 #include <linux/jiffies.h>
 #include <linux/debugfs.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 0f83bdb9b16fdf96270b6c8c3b936d2538cae260..612e18b4bf4edbe8d1c7acaee6fcb735a0cc8556 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/gfp.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
index efed64b8b026c18117b6b58a49d8cfb1dd467955..49cc7ea9a51891ee5cc0de690ae368de00d030e2 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
index 96deaefaa89756058eb68ac38ca89d9224f12f60..340a0bc5303e9264622a50e3d9d6dcf40d984310 100644 (file)
@@ -2,7 +2,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/sched.h>
 #include <asm/uaccess.h>
 #include "oss/sound_firmware.h"
index 8d13d933087dee455186d568e2ba4364988225ba..7dcc06512e8684c60c738f6eb7fe9eeeff499070 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
index 1d2e51b3f9184cc66881e370d73b8452ae42266c..2eab6ce48852233dbf58a44b227e7e522d8bd352 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
index 687e6a13689e7cd912ac99ca79b9a14883931a56..58a32a10d115863661dea284024fae49102c889a 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 #include <linux/wait.h>
-#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <sound/info.h>
index 86b2c3b92df53abafa8188560c4e034ce987ea97..4328cad6c3a24cd7f5887eb6d825d52f0ad6091b 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include <linux/spinlock.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/usb.h>
 #include <sound/core.h>
index a3f02dd974406bb60b2f10f9d7bd4108b80b589e..afc5aeb680059b6d69681bb6d5f3951d23c64102 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/gfp.h>
 #include <linux/usb.h>
 #include <sound/initval.h>
 #include <sound/core.h>
index 538e8c00d31aadac2c8555df958c1312051265b5..2f218c77fff2dd2249811a9d99141468e885dbce 100644 (file)
@@ -17,6 +17,7 @@
 */
 
 #include <linux/usb.h>
+#include <linux/gfp.h>
 #include <sound/rawmidi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
index 44deb21b17770b8d063793c979fdab72a5b0ecd1..9ca9a13a78da196f62acaae7010623b14045809b 100644 (file)
@@ -16,6 +16,7 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <linux/usb/audio.h>
 #include <sound/core.h>
index 1879b72c40f8d0695bd98883021a84be5477f050..04aafb43a13c9fbdc5eca982cdc6d13718d5245d 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <sound/core.h>
 #include <sound/memalloc.h>
index 12ae0340adc0b37d826661bff498ed5ab954b766..c400ade3ff08b8c18d8225a9688b38f9e1c487cc 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include <linux/usb.h>
+#include <linux/gfp.h>
 
 #include "usb_stream.h"
 
index c42350eed2eb48f9963dc053a60594895f953c85..cbd37f2c76d0c6e301854dbdcdc7e00df224b1dc 100644 (file)
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/usb.h>
 #include <sound/core.h>
index 74a67a85aa81382e4f113f9ce557dbc5121ab327..5d37d1ccf813c3ff25206f0517eb87cfa4d7bf72 100644 (file)
@@ -32,6 +32,7 @@
 
 
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/usb.h>
 #include <sound/core.h>
 #include <sound/info.h>
index 9ed6c3956ca790e7afe83a5a8cb4d7cff56993d1..2a528e56afd50db1c7f7cb309e1734c826cef3c2 100644 (file)
@@ -51,6 +51,7 @@
 */
 
 #include <linux/delay.h>
+#include <linux/gfp.h>
 #include "usbusx2yaudio.c"
 
 #if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) &&  USX2Y_NRPACKS == 1)
index 8a8f52db7e385c28b2092f255ea07fb532fa5607..bc0f670a8338ac971d7836aaaae27a122a486b6e 100644 (file)
@@ -200,7 +200,7 @@ endif
 
 CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
 EXTLIBS = -lpthread -lrt -lelf -lm
-ALL_CFLAGS = $(CFLAGS)
+ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
@@ -492,19 +492,19 @@ ifeq ($(uname_S),Darwin)
        PTHREAD_LIBS =
 endif
 
-ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
-ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifeq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
        msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
 endif
 
-       ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+       ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
                BASIC_CFLAGS += -DLIBELF_NO_MMAP
        endif
 else
        msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
 endif
 
-ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#include <dwarf.h>'; echo '\#include <libdw.h>'; echo 'int main(void) { Dwarf *dbg; dbg = dwarf_begin(0, DWARF_C_READ); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -I/usr/include/elfutils -ldw -lelf -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
        msg := $(warning No libdw.h found or old libdw.h found, disables dwarf support. Please install elfutils-devel/elfutils-dev);
        BASIC_CFLAGS += -DNO_DWARF_SUPPORT
 else
index 924a9518931ade8eb51e17eb36fc38024c556c79..7d9e3a7e34d36f0d98b7d432d3e9755b66530c37 100644 (file)
@@ -14,6 +14,7 @@
 #include "util/debug.h"
 
 #include <linux/rbtree.h>
+#include <linux/slab.h>
 
 struct alloc_stat;
 typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
index c30a33592340e4977c4d82cfb7dabd618370be2c..152d6c9b1fa4a07619c7cd3d11a7f45b7777a1ff 100644 (file)
@@ -47,7 +47,6 @@
 #include "util/probe-event.h"
 
 #define MAX_PATH_LEN 256
-#define MAX_PROBES 128
 
 /* Session management structure */
 static struct {
index 0b719e3dde050611c282b0c21dccbd91f507ad70..1f529321607eb2c2c852bb481982f1287fc86ef9 100644 (file)
@@ -455,7 +455,7 @@ static void print_sym_table(void)
        struct sym_entry *syme, *n;
        struct rb_root tmp = RB_ROOT;
        struct rb_node *nd;
-       int sym_width = 0, dso_width = 0, max_dso_width;
+       int sym_width = 0, dso_width = 0, dso_short_width = 0;
        const int win_width = winsize.ws_col - 1;
 
        samples = userspace_samples = 0;
@@ -545,15 +545,20 @@ static void print_sym_table(void)
                if (syme->map->dso->long_name_len > dso_width)
                        dso_width = syme->map->dso->long_name_len;
 
+               if (syme->map->dso->short_name_len > dso_short_width)
+                       dso_short_width = syme->map->dso->short_name_len;
+
                if (syme->name_len > sym_width)
                        sym_width = syme->name_len;
        }
 
        printed = 0;
 
-       max_dso_width = winsize.ws_col - sym_width - 29;
-       if (dso_width > max_dso_width)
-               dso_width = max_dso_width;
+       if (sym_width + dso_width > winsize.ws_col - 29) {
+               dso_width = dso_short_width;
+               if (sym_width + dso_width > winsize.ws_col - 29)
+                       sym_width = winsize.ws_col - dso_width - 29;
+       }
        putchar('\n');
        if (nr_counters == 1)
                printf("             samples  pcnt");
index 53181dbfe4a8dae101a279a40f10654865c90796..7c004b6ef24ffe725730564cb9418adfcc808be4 100644 (file)
@@ -242,7 +242,7 @@ void parse_perf_probe_event(const char *str, struct probe_point *pp,
 
        /* Parse probe point */
        parse_perf_probe_probepoint(argv[0], pp);
-       if (pp->file || pp->line)
+       if (pp->file || pp->line || pp->lazy_line)
                *need_dwarf = true;
 
        /* Copy arguments and ensure return probe has no C argument */
index 1e6c65ebbd80f6f1954ffec13715a21ab9f53ed2..c171a243d05b721b7cfdc9b743a73cbbf75099a3 100644 (file)
@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf)
                die("%u exceeds max register number.", regn);
 
        if (deref)
-               ret = snprintf(pf->buf, pf->len, " %s=+%ju(%s)",
-                              pf->var, (uintmax_t)offs, regs);
+               ret = snprintf(pf->buf, pf->len, " %s=%+jd(%s)",
+                              pf->var, (intmax_t)offs, regs);
        else
                ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs);
        DIE_IF(ret < 0);
@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
        if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL)
                goto error;
        /* TODO: handle more than 1 exprs */
-       ret = dwarf_getlocation_addr(&attr, (pf->addr - pf->cu_base),
-                                    &expr, &nexpr, 1);
+       ret = dwarf_getlocation_addr(&attr, pf->addr, &expr, &nexpr, 1);
        if (ret <= 0 || nexpr == 0)
                goto error;
 
@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
 
        /* Get the frame base attribute/ops */
        dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr);
-       ret = dwarf_getlocation_addr(&fb_attr, (pf->addr - pf->cu_base),
-                                    &pf->fb_ops, &nops, 1);
+       ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
        if (ret <= 0 || nops == 0)
                pf->fb_ops = NULL;
 
@@ -455,6 +453,9 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
        /* *pf->fb_ops will be cached in libdw. Don't free it. */
        pf->fb_ops = NULL;
 
+       if (pp->found == MAX_PROBES)
+               die("Too many( > %d) probe point found.\n", MAX_PROBES);
+
        pp->probes[pp->found] = strdup(tmp);
        pp->found++;
 }
@@ -641,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf)
 int find_probe_point(int fd, struct probe_point *pp)
 {
        struct probe_finder pf = {.pp = pp};
-       int ret;
        Dwarf_Off off, noff;
        size_t cuhl;
        Dwarf_Die *diep;
@@ -668,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp)
                        pf.fname = NULL;
 
                if (!pp->file || pf.fname) {
-                       /* Save CU base address (for frame_base) */
-                       ret = dwarf_lowpc(&pf.cu_die, &pf.cu_base);
-                       if (ret != 0)
-                               pf.cu_base = 0;
                        if (pp->function)
                                find_probe_point_by_func(&pf);
                        else if (pp->lazy_line)
index d1a651793ba6661bf88684e62978f697d5cbd9f6..21f7354397b459414bcc438813411fa901fe19ff 100644 (file)
@@ -71,7 +71,6 @@ struct probe_finder {
 
        /* For variable searching */
        Dwarf_Op                *fb_ops;        /* Frame base attribute */
-       Dwarf_Addr              cu_base;        /* Current CU base address */
        const char              *var;           /* Current variable name */
        char                    *buf;           /* Current output buffer */
        int                     len;            /* Length of output buffer */
index 33a414bbba3e1e1bbf410d9f984e401dc555e2b9..6a72f14c5986806dc3bcd4fad1cf0b92ba19b7b0 100644 (file)
@@ -208,7 +208,7 @@ static void python_process_event(int cpu, void *data,
                                 int size __unused,
                                 unsigned long long nsecs, char *comm)
 {
-       PyObject *handler, *retval, *context, *t;
+       PyObject *handler, *retval, *context, *t, *obj;
        static char handler_name[256];
        struct format_field *field;
        unsigned long long val;
@@ -256,16 +256,23 @@ static void python_process_event(int cpu, void *data,
                                offset &= 0xffff;
                        } else
                                offset = field->offset;
-                       PyTuple_SetItem(t, n++,
-                               PyString_FromString((char *)data + offset));
+                       obj = PyString_FromString((char *)data + offset);
                } else { /* FIELD_IS_NUMERIC */
                        val = read_size(data + field->offset, field->size);
                        if (field->flags & FIELD_IS_SIGNED) {
-                               PyTuple_SetItem(t, n++, PyInt_FromLong(val));
+                               if ((long long)val >= LONG_MIN &&
+                                   (long long)val <= LONG_MAX)
+                                       obj = PyInt_FromLong(val);
+                               else
+                                       obj = PyLong_FromLongLong(val);
                        } else {
-                               PyTuple_SetItem(t, n++, PyInt_FromLong(val));
+                               if (val <= LONG_MAX)
+                                       obj = PyInt_FromLong(val);
+                               else
+                                       obj = PyLong_FromUnsignedLongLong(val);
                        }
                }
+               PyTuple_SetItem(t, n++, obj);
        }
 
        if (_PyTuple_Resize(&t, n) == -1)
index 323c0aea0a91172cced9261cdfd966cd2c0aa57d..c458c4a371d11ea11715f3937111843234739462 100644 (file)
@@ -163,9 +163,17 @@ void dso__set_long_name(struct dso *self, char *name)
        self->long_name_len = strlen(name);
 }
 
+static void dso__set_short_name(struct dso *self, const char *name)
+{
+       if (name == NULL)
+               return;
+       self->short_name = name;
+       self->short_name_len = strlen(name);
+}
+
 static void dso__set_basename(struct dso *self)
 {
-       self->short_name = basename(self->long_name);
+       dso__set_short_name(self, basename(self->long_name));
 }
 
 struct dso *dso__new(const char *name)
@@ -176,7 +184,7 @@ struct dso *dso__new(const char *name)
                int i;
                strcpy(self->name, name);
                dso__set_long_name(self, self->name);
-               self->short_name = self->name;
+               dso__set_short_name(self, self->name);
                for (i = 0; i < MAP__NR_TYPES; ++i)
                        self->symbols[i] = self->symbol_names[i] = RB_ROOT;
                self->slen_calculated = 0;
@@ -897,7 +905,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
        struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
        struct map *curr_map = map;
        struct dso *curr_dso = self;
-       size_t dso_name_len = strlen(self->short_name);
        Elf_Data *symstrs, *secstrs;
        uint32_t nr_syms;
        int err = -1;
@@ -987,7 +994,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
                        char dso_name[PATH_MAX];
 
                        if (strcmp(section_name,
-                                  curr_dso->short_name + dso_name_len) == 0)
+                                  (curr_dso->short_name +
+                                   self->short_name_len)) == 0)
                                goto new_symbol;
 
                        if (strcmp(section_name, ".text") == 0) {
@@ -1782,7 +1790,7 @@ struct dso *dso__new_kernel(const char *name)
        struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
 
        if (self != NULL) {
-               self->short_name = "[kernel]";
+               dso__set_short_name(self, "[kernel]");
                self->kernel     = 1;
        }
 
index 280dadd32a08972f59bde677d4f7bc6c14a0da36..f30a37428919b6d959eba0811cf0489ed4d8e5b2 100644 (file)
@@ -110,9 +110,10 @@ struct dso {
        u8               sorted_by_name;
        u8               loaded;
        u8               build_id[BUILD_ID_SIZE];
-       u16              long_name_len;
        const char       *short_name;
        char             *long_name;
+       u16              long_name_len;
+       u16              short_name_len;
        char             name[0];
 };
 
index 057e2cca6af5ed7a8c8cbdf4aa7c236713b3bf8f..02ff2b19dbe242a5033da435998a19f1fc4e52ed 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/spinlock.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include "irq.h"
 
 static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head,
index 5169736377a3b88cb6d2c7abc7639e2da439cf64..36e258029649c719fec91a1feb7306604ae90ab9 100644 (file)
@@ -10,6 +10,7 @@
 #include "iodev.h"
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include <linux/kvm.h>
 
 #include "coalesced_mmio.h"
index 7016319b1ec0590513ba1886ede37982c39e71b4..b81f0ebbaaadb6db5c62ef3d8078117630152b35 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/list.h>
 #include <linux/eventfd.h>
 #include <linux/kernel.h>
+#include <linux/slab.h>
 
 #include "iodev.h"
 
index 3db15a807f8064149a8b3bf5f4fcdd349697cdc5..03a5eb22da2bfa27f5404bee3e5fff626facc42e 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/smp.h>
 #include <linux/hrtimer.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 #include <asm/current.h>
index 9fd5b3ebc5175b193e083e45d594dcf34c4e04ab..a0e88809e45e7468d9c2439d638f2dc18502d128 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include <trace/events/kvm.h>
 
 #include <asm/msidef.h>
index 548f9253c1957f2d0088b74c01c015fee1e79b45..5a0cd194dce00ee75b40b73d146ee478db1e4d38 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/percpu.h>
-#include <linux/gfp.h>
 #include <linux/mm.h>
 #include <linux/miscdevice.h>
 #include <linux/vmalloc.h>
@@ -46,6 +45,7 @@
 #include <linux/compat.h>
 #include <linux/srcu.h>
 #include <linux/hugetlb.h>
+#include <linux/slab.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>