aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/debugging-via-ohci1394.txt17
-rw-r--r--Documentation/feature-removal-schedule.txt22
-rw-r--r--Documentation/i2c/busses/i2c-i8013
-rw-r--r--Documentation/ide.txt49
-rw-r--r--MAINTAINERS23
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig3
-rw-r--r--arch/arm/mach-omap1/board-sx1.c2
-rw-r--r--arch/arm/mach-pxa/cpu-pxa.c2
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c8
-rw-r--r--arch/arm/mach-pxa/zylonite.c2
-rw-r--r--arch/arm/mm/mmap.c2
-rw-r--r--arch/avr32/boards/atstk1000/atstk1004.c2
-rw-r--r--arch/avr32/kernel/process.c4
-rw-r--r--arch/avr32/mm/fault.c2
-rw-r--r--arch/blackfin/Makefile5
-rw-r--r--arch/blackfin/configs/BF527-EZKIT_defconfig18
-rw-r--r--arch/blackfin/configs/BF533-EZKIT_defconfig6
-rw-r--r--arch/blackfin/configs/BF533-STAMP_defconfig6
-rw-r--r--arch/blackfin/configs/BF537-STAMP_defconfig6
-rw-r--r--arch/blackfin/configs/BF548-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF561-EZKIT_defconfig1
-rw-r--r--arch/blackfin/kernel/bfin_dma_5xx.c15
-rw-r--r--arch/blackfin/kernel/gptimers.c8
-rw-r--r--arch/blackfin/kernel/setup.c5
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S34
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c60
-rw-r--r--arch/blackfin/mach-bf533/boards/ezkit.c21
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c43
-rw-r--r--arch/blackfin/mach-bf537/boards/generic_board.c18
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c45
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c25
-rw-r--r--arch/blackfin/mach-bf548/dma.c2
-rw-r--r--arch/blackfin/mach-bf548/head.S9
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c16
-rw-r--r--arch/blackfin/mach-common/dpmc.S137
-rw-r--r--arch/blackfin/mach-common/ints-priority.c174
-rw-r--r--arch/blackfin/mm/init.c4
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c2
-rw-r--r--arch/powerpc/platforms/cell/iommu.c151
-rw-r--r--arch/powerpc/platforms/cell/setup.c7
-rw-r--r--arch/powerpc/platforms/celleb/beat.h3
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/drivers/dma/dma-sh.c2
-rw-r--r--arch/sh/drivers/heartbeat.c2
-rw-r--r--arch/sh/drivers/pci/ops-dreamcast.c44
-rw-r--r--arch/sh/kernel/cpu/sh2/setup-sh7619.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7203.c4
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7203.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7206.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/probe.c4
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7705.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c8
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7710.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7720.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh4-202.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7760.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7343.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7366.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7763.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7770.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7780.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7785.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-shx3.c2
-rw-r--r--arch/sparc/kernel/led.c3
-rw-r--r--arch/sparc64/kernel/ds.c14
-rw-r--r--arch/sparc64/kernel/hvtramp.S4
-rw-r--r--arch/sparc64/kernel/iommu.c3
-rw-r--r--arch/sparc64/kernel/kprobes.c2
-rw-r--r--arch/sparc64/kernel/mdesc.c2
-rw-r--r--arch/sparc64/kernel/power.c3
-rw-r--r--arch/sparc64/kernel/process.c77
-rw-r--r--arch/sparc64/kernel/smp.c2
-rw-r--r--arch/sparc64/kernel/trampoline.S4
-rw-r--r--arch/sparc64/kernel/traps.c2
-rw-r--r--arch/sparc64/mm/fault.c14
-rw-r--r--arch/sparc64/mm/init.c3
-rw-r--r--arch/um/kernel/process.c2
-rw-r--r--arch/x86/Kconfig.cpu14
-rw-r--r--arch/x86/boot/memory.c9
-rw-r--r--arch/x86/kernel/asm-offsets_32.c4
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c9
-rw-r--r--arch/x86/kernel/cpu/transmeta.c7
-rw-r--r--arch/x86/kernel/entry_64.S6
-rw-r--r--arch/x86/kernel/head_32.S2
-rw-r--r--arch/x86/kernel/head_64.S22
-rw-r--r--arch/x86/kernel/hpet.c4
-rw-r--r--arch/x86/kernel/init_task.c1
-rw-r--r--arch/x86/kernel/process_32.c2
-rw-r--r--arch/x86/kernel/process_64.c8
-rw-r--r--arch/x86/kernel/ptrace.c12
-rw-r--r--arch/x86/kernel/setup_64.c2
-rw-r--r--arch/x86/kernel/smpboot_64.c2
-rw-r--r--arch/x86/kernel/stacktrace.c4
-rw-r--r--arch/x86/kernel/tls.c8
-rw-r--r--arch/x86/kernel/tsc_32.c3
-rw-r--r--arch/x86/kernel/vsyscall_64.c49
-rw-r--r--arch/x86/lguest/boot.c12
-rw-r--r--arch/x86/mm/init_64.c13
-rw-r--r--arch/x86/mm/ioremap.c2
-rw-r--r--arch/x86/mm/pageattr.c105
-rw-r--r--arch/x86/vdso/Makefile4
-rw-r--r--arch/x86/xen/enlighten.c1
-rw-r--r--drivers/ata/ahci.c23
-rw-r--r--drivers/ata/libata-core.c15
-rw-r--r--drivers/ata/libata-pmp.c4
-rw-r--r--drivers/ata/libata-scsi.c13
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_atiixp.c4
-rw-r--r--drivers/ata/sata_fsl.c8
-rw-r--r--drivers/ata/sata_svw.c77
-rw-r--r--drivers/char/rtc.c4
-rw-r--r--drivers/connector/connector.c2
-rw-r--r--drivers/firewire/fw-card.c61
-rw-r--r--drivers/firewire/fw-cdev.c17
-rw-r--r--drivers/firewire/fw-device.c69
-rw-r--r--drivers/firewire/fw-device.h18
-rw-r--r--drivers/firewire/fw-sbp2.c392
-rw-r--r--drivers/firewire/fw-topology.c1
-rw-r--r--drivers/firewire/fw-transaction.h2
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-i801.c10
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c7
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c4
-rw-r--r--drivers/i2c/busses/i2c-pxa.c25
-rw-r--r--drivers/ide/ide-cd.c30
-rw-r--r--drivers/ide/ide-disk.c5
-rw-r--r--drivers/ide/ide-dma.c52
-rw-r--r--drivers/ide/ide-probe.c3
-rw-r--r--drivers/ide/ide-tape.c5
-rw-r--r--drivers/ide/ide.c20
-rw-r--r--drivers/ide/legacy/qd65xx.c43
-rw-r--r--drivers/ide/pci/cmd640.c3
-rw-r--r--drivers/ide/pci/hpt366.c12
-rw-r--r--drivers/ieee1394/sbp2.c15
-rw-r--r--drivers/ieee1394/sbp2.h2
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_mem.c10
-rw-r--r--drivers/infiniband/hw/nes/nes.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.h15
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c15
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c13
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c10
-rw-r--r--drivers/net/Kconfig6
-rw-r--r--drivers/net/bnx2.c50
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/net/bnx2x.c2663
-rw-r--r--drivers/net/bnx2x.h56
-rw-r--r--drivers/net/bnx2x_fw_defs.h2
-rw-r--r--drivers/net/bnx2x_hsi.h428
-rw-r--r--drivers/net/bnx2x_init.h12
-rw-r--r--drivers/net/bnx2x_reg.h212
-rw-r--r--drivers/net/cs89x0.c12
-rw-r--r--drivers/net/e1000e/82571.c22
-rw-r--r--drivers/net/e1000e/defines.h10
-rw-r--r--drivers/net/e1000e/e1000.h3
-rw-r--r--drivers/net/e1000e/hw.h4
-rw-r--r--drivers/net/e1000e/ich8lan.c24
-rw-r--r--drivers/net/e1000e/lib.c50
-rw-r--r--drivers/net/e1000e/netdev.c18
-rw-r--r--drivers/net/e1000e/phy.c10
-rw-r--r--drivers/net/ehea/ehea.h34
-rw-r--r--drivers/net/ehea/ehea_main.c281
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c7
-rw-r--r--drivers/net/gianfar.c14
-rw-r--r--drivers/net/igb/igb_main.c15
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c1
-rw-r--r--drivers/net/macb.c2
-rw-r--r--drivers/net/niu.c9
-rw-r--r--drivers/net/niu.h2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c10
-rw-r--r--drivers/net/phy/mdio_bus.c4
-rw-r--r--drivers/net/ps3_gelic_wireless.c1
-rw-r--r--drivers/net/sis190.c15
-rw-r--r--drivers/net/sky2.c123
-rw-r--r--drivers/net/sky2.h27
-rw-r--r--drivers/net/tg3.c2
-rw-r--r--drivers/net/tlan.c64
-rw-r--r--drivers/net/tulip/uli526x.c12
-rw-r--r--drivers/net/veth.c53
-rw-r--r--drivers/net/via-rhine.c2
-rw-r--r--drivers/net/virtio_net.c2
-rw-r--r--drivers/net/wireless/ath5k/ath5k.h2
-rw-r--r--drivers/net/wireless/ath5k/base.c20
-rw-r--r--drivers/net/wireless/ath5k/hw.c8
-rw-r--r--drivers/net/wireless/b43/Kconfig1
-rw-r--r--drivers/net/wireless/b43legacy/Kconfig1
-rw-r--r--drivers/net/wireless/bcm43xx/Kconfig2
-rw-r--r--drivers/net/wireless/libertas/cmd.c2
-rw-r--r--drivers/net/wireless/libertas/decl.h1
-rw-r--r--drivers/net/wireless/libertas/main.c17
-rw-r--r--drivers/net/wireless/p54usb.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c14
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c73
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00reg.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c6
-rw-r--r--drivers/net/wireless/rtl8180_dev.c4
-rw-r--r--drivers/net/wireless/rtl8187_dev.c4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c12
-rw-r--r--drivers/s390/net/claw.c39
-rw-r--r--drivers/serial/Kconfig6
-rw-r--r--drivers/serial/bfin_5xx.c281
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/sh/maple/maple.c66
-rw-r--r--drivers/ssb/Kconfig11
-rw-r--r--drivers/ssb/Makefile3
-rw-r--r--drivers/ssb/driver_chipcommon.c65
-rw-r--r--drivers/ssb/driver_extif.c25
-rw-r--r--drivers/ssb/driver_pcicore.c47
-rw-r--r--drivers/ssb/embedded.c132
-rw-r--r--drivers/ssb/main.c4
-rw-r--r--drivers/ssb/ssb_private.h4
-rw-r--r--drivers/usb/host/u132-hcd.c4
-rw-r--r--fs/ext4/dir.c2
-rw-r--r--fs/ext4/extents.c59
-rw-r--r--fs/ext4/ialloc.c22
-rw-r--r--fs/ext4/inode.c56
-rw-r--r--fs/ext4/mballoc.c80
-rw-r--r--fs/ext4/migrate.c5
-rw-r--r--fs/ext4/namei.c18
-rw-r--r--fs/ext4/resize.c1
-rw-r--r--fs/proc/base.c27
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c14
-rw-r--r--fs/xfs/xfs_bit.c103
-rw-r--r--fs/xfs/xfs_bit.h27
-rw-r--r--fs/xfs/xfs_clnt.h2
-rw-r--r--fs/xfs/xfs_ialloc.c2
-rw-r--r--fs/xfs/xfs_mount.h2
-rw-r--r--fs/xfs/xfs_rtalloc.c19
-rw-r--r--fs/xfs/xfs_vfsops.c4
-rw-r--r--include/asm-arm/arch-pxa/entry-macro.S2
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h3
-rw-r--r--include/asm-arm/kexec.h2
-rw-r--r--include/asm-arm/unaligned.h8
-rw-r--r--include/asm-avr32/pgtable.h1
-rw-r--r--include/asm-blackfin/gptimers.h7
-rw-r--r--include/asm-blackfin/irq.h2
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_serial_5xx.h22
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_serial_5xx.h24
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_serial_5xx.h22
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_serial_5xx.h7
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_serial_5xx.h24
-rw-r--r--include/asm-blackfin/mach-bf561/blackfin.h3
-rw-r--r--include/asm-blackfin/mach-bf561/cdefBF561.h2
-rw-r--r--include/asm-mips/mach-db1x00/db1200.h1
-rw-r--r--include/asm-mips/mach-db1x00/db1x00.h1
-rw-r--r--include/asm-mips/mach-pb1x00/pb1200.h1
-rw-r--r--include/asm-mips/mach-pb1x00/pb1550.h1
-rw-r--r--include/asm-powerpc/reg.h3
-rw-r--r--include/asm-sh/cpu-sh3/cache.h2
-rw-r--r--include/asm-sh/entry-macros.S4
-rw-r--r--include/asm-sparc64/ptrace.h1
-rw-r--r--include/asm-sparc64/reboot.h6
-rw-r--r--include/asm-sparc64/syscalls.h13
-rw-r--r--include/asm-sparc64/system.h1
-rw-r--r--include/asm-x86/futex.h7
-rw-r--r--include/asm-x86/lguest.h11
-rw-r--r--include/asm-x86/nops.h66
-rw-r--r--include/asm-x86/page_64.h8
-rw-r--r--include/asm-x86/pgtable_32.h4
-rw-r--r--include/asm-x86/pgtable_64.h6
-rw-r--r--include/asm-x86/ptrace-abi.h8
-rw-r--r--include/linux/ata.h5
-rw-r--r--include/linux/connector.h2
-rw-r--r--include/linux/elfcore-compat.h4
-rw-r--r--include/linux/ext4_fs_extents.h1
-rw-r--r--include/linux/hardirq.h10
-rw-r--r--include/linux/i2c.h11
-rw-r--r--include/linux/if_ether.h3
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/maple.h1
-rw-r--r--include/linux/netfilter.h4
-rw-r--r--include/linux/netfilter/Kbuild2
-rw-r--r--include/linux/netfilter/xt_hashlimit.h1
-rw-r--r--include/linux/rcuclassic.h3
-rw-r--r--include/linux/rcupreempt.h22
-rw-r--r--include/linux/sched.h3
-rw-r--r--include/linux/serial_sci.h (renamed from include/asm-sh/sci.h)10
-rw-r--r--include/linux/ssb/ssb.h12
-rw-r--r--include/linux/ssb/ssb_driver_chipcommon.h18
-rw-r--r--include/linux/ssb/ssb_driver_extif.h18
-rw-r--r--include/linux/ssb/ssb_driver_pci.h5
-rw-r--r--include/linux/ssb/ssb_embedded.h18
-rw-r--r--include/linux/vmstat.h3
-rw-r--r--include/net/ip6_tunnel.h2
-rw-r--r--include/net/sctp/user.h10
-rw-r--r--kernel/audit.c19
-rw-r--r--kernel/auditsc.c2
-rw-r--r--kernel/lockdep.c8
-rw-r--r--kernel/printk.c2
-rw-r--r--kernel/rcupreempt.c233
-rw-r--r--kernel/sched.c16
-rw-r--r--kernel/sched_fair.c13
-rw-r--r--kernel/softirq.c1
-rw-r--r--kernel/softlockup.c13
-rw-r--r--kernel/time/tick-sched.c3
-rw-r--r--net/8021q/vlan_dev.c10
-rw-r--r--net/8021q/vlanproc.c11
-rw-r--r--net/9p/trans_virtio.c2
-rw-r--r--net/appletalk/atalk_proc.c15
-rw-r--r--net/atm/br2684.c4
-rw-r--r--net/atm/clip.c4
-rw-r--r--net/atm/lec.c4
-rw-r--r--net/atm/mpoa_proc.c3
-rw-r--r--net/atm/proc.c8
-rw-r--r--net/bluetooth/l2cap.c2
-rw-r--r--net/bridge/netfilter/ebt_dnat.c4
-rw-r--r--net/bridge/netfilter/ebt_redirect.c4
-rw-r--r--net/bridge/netfilter/ebt_snat.c4
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/neighbour.c11
-rw-r--r--net/core/pktgen.c10
-rw-r--r--net/core/rtnetlink.c27
-rw-r--r--net/ipv4/devinet.c1
-rw-r--r--net/ipv4/fib_hash.c10
-rw-r--r--net/ipv4/ip_gre.c26
-rw-r--r--net/ipv4/ipcomp.c5
-rw-r--r--net/ipv4/ipip.c26
-rw-r--r--net/ipv4/netfilter/arpt_mangle.c2
-rw-r--r--net/ipv4/netfilter/ip_queue.c12
-rw-r--r--net/ipv4/route.c5
-rw-r--r--net/ipv6/addrconf.c3
-rw-r--r--net/ipv6/ip6_tunnel.c30
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/ipv6/netfilter/ip6_queue.c10
-rw-r--r--net/ipv6/proc.c4
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/sit.c25
-rw-r--r--net/ipv6/sysctl_net_ipv6.c3
-rw-r--r--net/ipx/ipx_proc.c11
-rw-r--r--net/key/af_key.c5
-rw-r--r--net/llc/llc_proc.c8
-rw-r--r--net/mac80211/ieee80211_sta.c7
-rw-r--r--net/netfilter/nf_conntrack_core.c15
-rw-r--r--net/netfilter/nfnetlink_queue.c10
-rw-r--r--net/netfilter/xt_conntrack.c4
-rw-r--r--net/netfilter/xt_hashlimit.c3
-rw-r--r--net/netfilter/xt_iprange.c2
-rw-r--r--net/netfilter/xt_u32.c11
-rw-r--r--net/sctp/auth.c4
-rw-r--r--net/sctp/ipv6.c12
-rw-r--r--net/sctp/objcnt.c5
-rw-r--r--net/sctp/proc.c4
-rw-r--r--net/sctp/protocol.c12
-rw-r--r--net/sctp/socket.c20
-rw-r--r--net/sctp/ulpevent.c2
-rw-r--r--net/sunrpc/cache.c14
-rw-r--r--net/sunrpc/stats.c3
-rw-r--r--net/tipc/cluster.c2
-rw-r--r--net/tipc/link.c2
-rw-r--r--net/tipc/ref.c2
-rw-r--r--net/tipc/zone.c2
-rw-r--r--net/wanrouter/wanproc.c10
-rw-r--r--net/x25/x25_proc.c10
-rw-r--r--sound/isa/sb/sb8_main.c2
-rw-r--r--sound/pci/hda/patch_analog.c8
-rw-r--r--sound/pci/hda/patch_conexant.c5
-rw-r--r--sound/pci/hda/patch_realtek.c22
-rw-r--r--sound/pci/ice1712/phase.c2
-rw-r--r--sound/pci/ice1712/revo.c2
-rw-r--r--sound/pci/intel8x0.c12
-rw-r--r--sound/pci/oxygen/hifier.c1
-rw-r--r--sound/pci/oxygen/virtuoso.c1
-rw-r--r--sound/soc/codecs/tlv320aic3x.c4
-rw-r--r--sound/soc/codecs/wm9712.c3
-rw-r--r--sound/soc/pxa/corgi.c6
-rw-r--r--sound/soc/pxa/poodle.c3
-rw-r--r--sound/soc/pxa/spitz.c3
-rw-r--r--sound/soc/pxa/tosa.c3
-rw-r--r--sound/usb/usbaudio.c38
378 files changed, 6066 insertions, 3393 deletions
diff --git a/Documentation/debugging-via-ohci1394.txt b/Documentation/debugging-via-ohci1394.txt
index de4804e8b396..c360d4e91b48 100644
--- a/Documentation/debugging-via-ohci1394.txt
+++ b/Documentation/debugging-via-ohci1394.txt
@@ -36,14 +36,15 @@ available (notebooks) or too slow for extensive debug information (like ACPI).
36Drivers 36Drivers
37------- 37-------
38 38
39The OHCI-1394 drivers in drivers/firewire and drivers/ieee1394 initialize 39The ohci1394 driver in drivers/ieee1394 initializes the OHCI-1394 controllers
40the OHCI-1394 controllers to a working state and can be used to enable 40to a working state and enables physical DMA by default for all remote nodes.
41physical DMA. By default you only have to load the driver, and physical 41This can be turned off by ohci1394's module parameter phys_dma=0.
42DMA access will be granted to all remote nodes, but it can be turned off 42
43when using the ohci1394 driver. 43The alternative firewire-ohci driver in drivers/firewire uses filtered physical
44 44DMA, hence is not yet suitable for remote debugging.
45Because these drivers depend on the PCI enumeration to be completed, an 45
46initialization routine which can runs pretty early (long before console_init(), 46Because ohci1394 depends on the PCI enumeration to be completed, an
47initialization routine which runs pretty early (long before console_init()
47which makes the printk buffer appear on the console can be called) was written. 48which makes the printk buffer appear on the console can be called) was written.
48 49
49To activate it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu: 50To activate it, enable CONFIG_PROVIDE_OHCI1394_DMA_INIT (Kernel hacking menu:
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 4d3aa519eadf..c1d1fd0c299b 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -172,6 +172,16 @@ Who: Len Brown <len.brown@intel.com>
172 172
173--------------------------- 173---------------------------
174 174
175What: ide-tape driver
176When: July 2008
177Files: drivers/ide/ide-tape.c
178Why: This driver might not have any users anymore and maintaining it for no
179 reason is an effort no one wants to make.
180Who: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>, Borislav Petkov
181 <petkovbb@googlemail.com>
182
183---------------------------
184
175What: libata spindown skipping and warning 185What: libata spindown skipping and warning
176When: Dec 2008 186When: Dec 2008
177Why: Some halt(8) implementations synchronize caches for and spin 187Why: Some halt(8) implementations synchronize caches for and spin
@@ -306,3 +316,15 @@ Why: Largely unmaintained and almost entirely unused. File system
306 is largely pointless as without a lot of work only the most 316 is largely pointless as without a lot of work only the most
307 trivial of Solaris binaries can work with the emulation code. 317 trivial of Solaris binaries can work with the emulation code.
308Who: David S. Miller <davem@davemloft.net> 318Who: David S. Miller <davem@davemloft.net>
319
320---------------------------
321
322What: init_mm export
323When: 2.6.26
324Why: Not used in-tree. The current out-of-tree users used it to
325 work around problems in the CPA code which should be resolved
326 by now. One usecase was described to provide verification code
327 of the CPA operation. That's a good idea in general, but such
328 code / infrastructure should be in the kernel and not in some
329 out-of-tree driver.
330Who: Thomas Gleixner <tglx@linutronix.de>
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index 3bd958360159..c31e0291e167 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -12,8 +12,9 @@ Supported adapters:
12 * Intel 82801G (ICH7) 12 * Intel 82801G (ICH7)
13 * Intel 631xESB/632xESB (ESB2) 13 * Intel 631xESB/632xESB (ESB2)
14 * Intel 82801H (ICH8) 14 * Intel 82801H (ICH8)
15 * Intel ICH9 15 * Intel 82801I (ICH9)
16 * Intel Tolapai 16 * Intel Tolapai
17 * Intel ICH10
17 Datasheets: Publicly available at the Intel website 18 Datasheets: Publicly available at the Intel website
18 19
19Authors: 20Authors:
diff --git a/Documentation/ide.txt b/Documentation/ide.txt
index 94e2e3b9e77f..bcd7cd1278ef 100644
--- a/Documentation/ide.txt
+++ b/Documentation/ide.txt
@@ -258,8 +258,6 @@ Summary of ide driver parameters for kernel command line
258 As for VLB, it is safest to not specify it. 258 As for VLB, it is safest to not specify it.
259 Bigger values are safer than smaller ones. 259 Bigger values are safer than smaller ones.
260 260
261 "idex=noprobe" : do not attempt to access/use this interface
262
263 "idex=base" : probe for an interface at the addr specified, 261 "idex=base" : probe for an interface at the addr specified,
264 where "base" is usually 0x1f0 or 0x170 262 where "base" is usually 0x1f0 or 0x170
265 and "ctl" is assumed to be "base"+0x206 263 and "ctl" is assumed to be "base"+0x206
@@ -309,53 +307,6 @@ are detected automatically).
309 307
310================================================================================ 308================================================================================
311 309
312IDE ATAPI streaming tape driver
313-------------------------------
314
315This driver is a part of the Linux ide driver and works in co-operation
316with linux/drivers/block/ide.c.
317
318The driver, in co-operation with ide.c, basically traverses the
319request-list for the block device interface. The character device
320interface, on the other hand, creates new requests, adds them
321to the request-list of the block device, and waits for their completion.
322
323Pipelined operation mode is now supported on both reads and writes.
324
325The block device major and minor numbers are determined from the
326tape's relative position in the ide interfaces, as explained in ide.c.
327
328The character device interface consists of the following devices:
329
330 ht0 major 37, minor 0 first IDE tape, rewind on close.
331 ht1 major 37, minor 1 second IDE tape, rewind on close.
332 ...
333 nht0 major 37, minor 128 first IDE tape, no rewind on close.
334 nht1 major 37, minor 129 second IDE tape, no rewind on close.
335 ...
336
337Run /dev/MAKEDEV to create the above entries.
338
339The general magnetic tape commands compatible interface, as defined by
340include/linux/mtio.h, is accessible through the character device.
341
342General ide driver configuration options, such as the interrupt-unmask
343flag, can be configured by issuing an ioctl to the block device interface,
344as any other ide device.
345
346Our own ide-tape ioctl's can be issued to either the block device or
347the character device interface.
348
349Maximal throughput with minimal bus load will usually be achieved in the
350following scenario:
351
352 1. ide-tape is operating in the pipelined operation mode.
353 2. No buffering is performed by the user backup program.
354
355
356
357================================================================================
358
359Some Terminology 310Some Terminology
360---------------- 311----------------
361IDE = Integrated Drive Electronics, meaning that each drive has a built-in 312IDE = Integrated Drive Electronics, meaning that each drive has a built-in
diff --git a/MAINTAINERS b/MAINTAINERS
index 36c7bc641dba..fed09b547336 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -767,14 +767,14 @@ S: Maintained
767 767
768BLACKFIN ARCHITECTURE 768BLACKFIN ARCHITECTURE
769P: Bryan Wu 769P: Bryan Wu
770M: bryan.wu@analog.com 770M: cooloney@kernel.org
771L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only) 771L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only)
772W: http://blackfin.uclinux.org 772W: http://blackfin.uclinux.org
773S: Supported 773S: Supported
774 774
775BLACKFIN EMAC DRIVER 775BLACKFIN EMAC DRIVER
776P: Bryan Wu 776P: Bryan Wu
777M: bryan.wu@analog.com 777M: cooloney@kernel.org
778L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only) 778L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only)
779W: http://blackfin.uclinux.org 779W: http://blackfin.uclinux.org
780S: Supported 780S: Supported
@@ -982,6 +982,12 @@ M: mchan@broadcom.com
982L: netdev@vger.kernel.org 982L: netdev@vger.kernel.org
983S: Supported 983S: Supported
984 984
985BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER
986P: Eliezer Tamir
987M: eliezert@broadcom.com
988L: netdev@vger.kernel.org
989S: Supported
990
985BROADCOM TG3 GIGABIT ETHERNET DRIVER 991BROADCOM TG3 GIGABIT ETHERNET DRIVER
986P: Michael Chan 992P: Michael Chan
987M: mchan@broadcom.com 993M: mchan@broadcom.com
@@ -2744,6 +2750,8 @@ S: Maintained
2744NETEFFECT IWARP RNIC DRIVER (IW_NES) 2750NETEFFECT IWARP RNIC DRIVER (IW_NES)
2745P: Faisal Latif 2751P: Faisal Latif
2746M: flatif@neteffect.com 2752M: flatif@neteffect.com
2753P: Nishi Gupta
2754M: ngupta@neteffect.com
2747P: Glenn Streiff 2755P: Glenn Streiff
2748M: gstreiff@neteffect.com 2756M: gstreiff@neteffect.com
2749L: general@lists.openfabrics.org 2757L: general@lists.openfabrics.org
@@ -3884,10 +3892,13 @@ M: trivial@kernel.org
3884L: linux-kernel@vger.kernel.org 3892L: linux-kernel@vger.kernel.org
3885S: Maintained 3893S: Maintained
3886 3894
3887TULIP NETWORK DRIVER 3895TULIP NETWORK DRIVERS
3888L: tulip-users@lists.sourceforge.net 3896P: Grant Grundler
3889W: http://sourceforge.net/projects/tulip/ 3897M: grundler@parisc-linux.org
3890S: Orphan 3898P: Kyle McMartin
3899M: kyle@parisc-linux.org
3900L: netdev@vger.kernel.org
3901S: Maintained
3891 3902
3892TUN/TAP driver 3903TUN/TAP driver
3893P: Maxim Krasnyansky 3904P: Maxim Krasnyansky
diff --git a/Makefile b/Makefile
index 99300dc680e9..a22978413b65 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 25 3SUBLEVEL = 25
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc3
5NAME = Funky Weasel is Jiggy wit it 5NAME = Funky Weasel is Jiggy wit it
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9619c43783ff..16b82e1272b0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -939,7 +939,8 @@ config KEXEC
939 939
940config ATAGS_PROC 940config ATAGS_PROC
941 bool "Export atags in procfs" 941 bool "Export atags in procfs"
942 default n 942 depends on KEXEC
943 default y
943 help 944 help
944 Should the atags used to boot the kernel be exported in an "atags" 945 Should the atags used to boot the kernel be exported in an "atags"
945 file in procfs. Useful with kexec. 946 file in procfs. Useful with kexec.
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 1c7f09aedf07..e473fa6d4a5f 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -61,6 +61,7 @@ int sx1_i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
61 data[0] = regoffset; /* register num */ 61 data[0] = regoffset; /* register num */
62 data[1] = value; /* register data */ 62 data[1] = value; /* register data */
63 err = i2c_transfer(adap, msg, 1); 63 err = i2c_transfer(adap, msg, 1);
64 i2c_put_adapter(adap);
64 if (err >= 0) 65 if (err >= 0)
65 return 0; 66 return 0;
66 return err; 67 return err;
@@ -91,6 +92,7 @@ int sx1_i2c_read_byte(u8 devaddr, u8 regoffset, u8 *value)
91 msg->buf = data; 92 msg->buf = data;
92 err = i2c_transfer(adap, msg, 1); 93 err = i2c_transfer(adap, msg, 1);
93 *value = data[0]; 94 *value = data[0];
95 i2c_put_adapter(adap);
94 96
95 if (err >= 0) 97 if (err >= 0)
96 return 0; 98 return 0;
diff --git a/arch/arm/mach-pxa/cpu-pxa.c b/arch/arm/mach-pxa/cpu-pxa.c
index 939a3867f77c..4b21479332ae 100644
--- a/arch/arm/mach-pxa/cpu-pxa.c
+++ b/arch/arm/mach-pxa/cpu-pxa.c
@@ -43,7 +43,7 @@
43 43
44#ifdef DEBUG 44#ifdef DEBUG
45static unsigned int freq_debug; 45static unsigned int freq_debug;
46MODULE_PARM(freq_debug, "i"); 46module_param(freq_debug, uint, 0);
47MODULE_PARM_DESC(freq_debug, "Set the debug messages to on=1/off=0"); 47MODULE_PARM_DESC(freq_debug, "Set the debug messages to on=1/off=0");
48#else 48#else
49#define freq_debug 0 49#define freq_debug 0
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index 7cd9ef8deb02..35f25fdaeba3 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -129,28 +129,20 @@ static void clk_pxa3xx_cken_enable(struct clk *clk)
129{ 129{
130 unsigned long mask = 1ul << (clk->cken & 0x1f); 130 unsigned long mask = 1ul << (clk->cken & 0x1f);
131 131
132 local_irq_disable();
133
134 if (clk->cken < 32) 132 if (clk->cken < 32)
135 CKENA |= mask; 133 CKENA |= mask;
136 else 134 else
137 CKENB |= mask; 135 CKENB |= mask;
138
139 local_irq_enable();
140} 136}
141 137
142static void clk_pxa3xx_cken_disable(struct clk *clk) 138static void clk_pxa3xx_cken_disable(struct clk *clk)
143{ 139{
144 unsigned long mask = 1ul << (clk->cken & 0x1f); 140 unsigned long mask = 1ul << (clk->cken & 0x1f);
145 141
146 local_irq_disable();
147
148 if (clk->cken < 32) 142 if (clk->cken < 32)
149 CKENA &= ~mask; 143 CKENA &= ~mask;
150 else 144 else
151 CKENB &= ~mask; 145 CKENB &= ~mask;
152
153 local_irq_enable();
154} 146}
155 147
156static const struct clkops clk_pxa3xx_cken_ops = { 148static const struct clkops clk_pxa3xx_cken_ops = {
diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index 7731d50dd86c..afd2cbfca0d9 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -58,7 +58,7 @@ static struct platform_device smc91x_device = {
58 .resource = smc91x_resources, 58 .resource = smc91x_resources,
59}; 59};
60 60
61#if defined(CONFIG_FB_PXA) || (CONFIG_FB_PXA_MODULES) 61#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
62static void zylonite_backlight_power(int on) 62static void zylonite_backlight_power(int on)
63{ 63{
64 gpio_set_value(gpio_backlight, on); 64 gpio_set_value(gpio_backlight, on);
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 2728b0e7d2bb..3f6dc40b8353 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -120,6 +120,8 @@ full_search:
120 */ 120 */
121int valid_phys_addr_range(unsigned long addr, size_t size) 121int valid_phys_addr_range(unsigned long addr, size_t size)
122{ 122{
123 if (addr < PHYS_OFFSET)
124 return 0;
123 if (addr + size > __pa(high_memory)) 125 if (addr + size > __pa(high_memory))
124 return 0; 126 return 0;
125 127
diff --git a/arch/avr32/boards/atstk1000/atstk1004.c b/arch/avr32/boards/atstk1000/atstk1004.c
index 5a77030e07a0..e765a8652b3e 100644
--- a/arch/avr32/boards/atstk1000/atstk1004.c
+++ b/arch/avr32/boards/atstk1000/atstk1004.c
@@ -129,7 +129,7 @@ static int __init atstk1004_init(void)
129#ifdef CONFIG_BOARD_ATSTK100X_SPI1 129#ifdef CONFIG_BOARD_ATSTK100X_SPI1
130 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 130 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
131#endif 131#endif
132#ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM 132#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
133 at32_add_device_mci(0); 133 at32_add_device_mci(0);
134#endif 134#endif
135 at32_add_device_lcdc(0, &atstk1000_lcdc_data, 135 at32_add_device_lcdc(0, &atstk1000_lcdc_data,
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index eaaa69bbdc38..7f4af0b1e111 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -11,6 +11,7 @@
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/ptrace.h> 12#include <linux/ptrace.h>
13#include <linux/reboot.h> 13#include <linux/reboot.h>
14#include <linux/tick.h>
14#include <linux/uaccess.h> 15#include <linux/uaccess.h>
15#include <linux/unistd.h> 16#include <linux/unistd.h>
16 17
@@ -30,8 +31,10 @@ void cpu_idle(void)
30{ 31{
31 /* endless idle loop with no priority at all */ 32 /* endless idle loop with no priority at all */
32 while (1) { 33 while (1) {
34 tick_nohz_stop_sched_tick();
33 while (!need_resched()) 35 while (!need_resched())
34 cpu_idle_sleep(); 36 cpu_idle_sleep();
37 tick_nohz_restart_sched_tick();
35 preempt_enable_no_resched(); 38 preempt_enable_no_resched();
36 schedule(); 39 schedule();
37 preempt_disable(); 40 preempt_disable();
@@ -345,6 +348,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
345 p->thread.cpu_context.ksp = (unsigned long)childregs; 348 p->thread.cpu_context.ksp = (unsigned long)childregs;
346 p->thread.cpu_context.pc = (unsigned long)ret_from_fork; 349 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
347 350
351 clear_tsk_thread_flag(p, TIF_DEBUG);
348 if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG)) 352 if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG))
349 ocd_enable(p); 353 ocd_enable(p);
350 354
diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
index 6560cb18b4e3..ce4e4296b954 100644
--- a/arch/avr32/mm/fault.c
+++ b/arch/avr32/mm/fault.c
@@ -189,6 +189,8 @@ no_context:
189 189
190 page = sysreg_read(PTBR); 190 page = sysreg_read(PTBR);
191 printk(KERN_ALERT "ptbr = %08lx", page); 191 printk(KERN_ALERT "ptbr = %08lx", page);
192 if (address >= TASK_SIZE)
193 page = (unsigned long)swapper_pg_dir;
192 if (page) { 194 if (page) {
193 page = ((unsigned long *)page)[address >> 22]; 195 page = ((unsigned long *)page)[address >> 22];
194 printk(" pgd = %08lx", page); 196 printk(" pgd = %08lx", page);
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index fe254f886a6e..75eba2ca7881 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -98,8 +98,11 @@ drivers-$(CONFIG_OPROFILE) += arch/$(ARCH)/oprofile/
98# them changed. We use .mach to indicate when they were updated 98# them changed. We use .mach to indicate when they were updated
99# last, otherwise make uses the target directory mtime. 99# last, otherwise make uses the target directory mtime.
100 100
101 show_mach_symlink = :
102 quiet_show_mach_symlink = echo ' SYMLINK include/asm-$(ARCH)/mach-$(MACHINE) -> include/asm-$(ARCH)/mach'
103silent_show_mach_symlink = :
101include/asm-blackfin/.mach: $(wildcard include/config/arch/*.h) include/config/auto.conf 104include/asm-blackfin/.mach: $(wildcard include/config/arch/*.h) include/config/auto.conf
102 @echo ' SYMLINK include/asm-$(ARCH)/mach-$(MACHINE) -> include/asm-$(ARCH)/mach' 105 @$($(quiet)show_mach_symlink)
103ifneq ($(KBUILD_SRC),) 106ifneq ($(KBUILD_SRC),)
104 $(Q)mkdir -p include/asm-$(ARCH) 107 $(Q)mkdir -p include/asm-$(ARCH)
105 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH)/mach-$(MACHINE) include/asm-$(ARCH)/mach 108 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH)/mach-$(MACHINE) include/asm-$(ARCH)/mach
diff --git a/arch/blackfin/configs/BF527-EZKIT_defconfig b/arch/blackfin/configs/BF527-EZKIT_defconfig
index d59ee1530bd4..ae320dcfedef 100644
--- a/arch/blackfin/configs/BF527-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT_defconfig
@@ -1,7 +1,6 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22.14 3# Linux kernel version: 2.6.22.16
4# Thu Nov 29 17:32:47 2007
5# 4#
6# CONFIG_MMU is not set 5# CONFIG_MMU is not set
7# CONFIG_FPU is not set 6# CONFIG_FPU is not set
@@ -116,7 +115,10 @@ CONFIG_PREEMPT_VOLUNTARY=y
116# Processor and Board Settings 115# Processor and Board Settings
117# 116#
118# CONFIG_BF522 is not set 117# CONFIG_BF522 is not set
118# CONFIG_BF523 is not set
119# CONFIG_BF524 is not set
119# CONFIG_BF525 is not set 120# CONFIG_BF525 is not set
121# CONFIG_BF526 is not set
120CONFIG_BF527=y 122CONFIG_BF527=y
121# CONFIG_BF531 is not set 123# CONFIG_BF531 is not set
122# CONFIG_BF532 is not set 124# CONFIG_BF532 is not set
@@ -306,6 +308,7 @@ CONFIG_BFIN_DCACHE=y
306# CONFIG_BFIN_WB is not set 308# CONFIG_BFIN_WB is not set
307CONFIG_BFIN_WT=y 309CONFIG_BFIN_WT=y
308CONFIG_L1_MAX_PIECE=16 310CONFIG_L1_MAX_PIECE=16
311# CONFIG_MPU is not set
309 312
310# 313#
311# Asynchonous Memory Configuration 314# Asynchonous Memory Configuration
@@ -354,6 +357,7 @@ CONFIG_BINFMT_ZFLAT=y
354# Power management options 357# Power management options
355# 358#
356# CONFIG_PM is not set 359# CONFIG_PM is not set
360# CONFIG_PM_WAKEUP_BY_GPIO is not set
357 361
358# 362#
359# Networking 363# Networking
@@ -496,7 +500,6 @@ CONFIG_MTD_CFI_I2=y
496# CONFIG_MTD_CFI_INTELEXT is not set 500# CONFIG_MTD_CFI_INTELEXT is not set
497# CONFIG_MTD_CFI_AMDSTD is not set 501# CONFIG_MTD_CFI_AMDSTD is not set
498# CONFIG_MTD_CFI_STAA is not set 502# CONFIG_MTD_CFI_STAA is not set
499CONFIG_MTD_MW320D=m
500CONFIG_MTD_RAM=y 503CONFIG_MTD_RAM=y
501CONFIG_MTD_ROM=m 504CONFIG_MTD_ROM=m
502# CONFIG_MTD_ABSENT is not set 505# CONFIG_MTD_ABSENT is not set
@@ -506,9 +509,6 @@ CONFIG_MTD_ROM=m
506# 509#
507CONFIG_MTD_COMPLEX_MAPPINGS=y 510CONFIG_MTD_COMPLEX_MAPPINGS=y
508# CONFIG_MTD_PHYSMAP is not set 511# CONFIG_MTD_PHYSMAP is not set
509CONFIG_MTD_BF5xx=m
510CONFIG_BFIN_FLASH_SIZE=0x400000
511CONFIG_EBIU_FLASH_BASE=0x20000000
512# CONFIG_MTD_UCLINUX is not set 512# CONFIG_MTD_UCLINUX is not set
513# CONFIG_MTD_PLATRAM is not set 513# CONFIG_MTD_PLATRAM is not set
514 514
@@ -684,7 +684,6 @@ CONFIG_INPUT_MISC=y
684# CONFIG_INPUT_POWERMATE is not set 684# CONFIG_INPUT_POWERMATE is not set
685# CONFIG_INPUT_YEALINK is not set 685# CONFIG_INPUT_YEALINK is not set
686# CONFIG_INPUT_UINPUT is not set 686# CONFIG_INPUT_UINPUT is not set
687# CONFIG_BF53X_PFBUTTONS is not set
688# CONFIG_TWI_KEYPAD is not set 687# CONFIG_TWI_KEYPAD is not set
689 688
690# 689#
@@ -702,12 +701,12 @@ CONFIG_INPUT_MISC=y
702# CONFIG_BF5xx_PPIFCD is not set 701# CONFIG_BF5xx_PPIFCD is not set
703# CONFIG_BFIN_SIMPLE_TIMER is not set 702# CONFIG_BFIN_SIMPLE_TIMER is not set
704# CONFIG_BF5xx_PPI is not set 703# CONFIG_BF5xx_PPI is not set
704CONFIG_BFIN_OTP=y
705# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
705# CONFIG_BFIN_SPORT is not set 706# CONFIG_BFIN_SPORT is not set
706# CONFIG_BFIN_TIMER_LATENCY is not set 707# CONFIG_BFIN_TIMER_LATENCY is not set
707# CONFIG_TWI_LCD is not set 708# CONFIG_TWI_LCD is not set
708# CONFIG_AD5304 is not set 709# CONFIG_AD5304 is not set
709# CONFIG_BF5xx_TEA5764 is not set
710# CONFIG_BF5xx_FBDMA is not set
711# CONFIG_VT is not set 710# CONFIG_VT is not set
712# CONFIG_SERIAL_NONSTANDARD is not set 711# CONFIG_SERIAL_NONSTANDARD is not set
713 712
@@ -772,7 +771,6 @@ CONFIG_I2C_CHARDEV=m
772# 771#
773# I2C Hardware Bus support 772# I2C Hardware Bus support
774# 773#
775# CONFIG_I2C_BLACKFIN_GPIO is not set
776CONFIG_I2C_BLACKFIN_TWI=m 774CONFIG_I2C_BLACKFIN_TWI=m
777CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50 775CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50
778# CONFIG_I2C_GPIO is not set 776# CONFIG_I2C_GPIO is not set
diff --git a/arch/blackfin/configs/BF533-EZKIT_defconfig b/arch/blackfin/configs/BF533-EZKIT_defconfig
index 811711f59a25..9621caa60b5f 100644
--- a/arch/blackfin/configs/BF533-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF533-EZKIT_defconfig
@@ -322,10 +322,9 @@ CONFIG_PM=y
322# CONFIG_PM_LEGACY is not set 322# CONFIG_PM_LEGACY is not set
323# CONFIG_PM_DEBUG is not set 323# CONFIG_PM_DEBUG is not set
324# CONFIG_PM_SYSFS_DEPRECATED is not set 324# CONFIG_PM_SYSFS_DEPRECATED is not set
325CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR=y 325CONFIG_PM_BFIN_SLEEP_DEEPER=y
326# CONFIG_PM_BFIN_SLEEP is not set
326# CONFIG_PM_WAKEUP_BY_GPIO is not set 327# CONFIG_PM_WAKEUP_BY_GPIO is not set
327# CONFIG_PM_WAKEUP_GPIO_API is not set
328CONFIG_PM_WAKEUP_SIC_IWR=0x80
329 328
330# 329#
331# CPU Frequency scaling 330# CPU Frequency scaling
@@ -697,7 +696,6 @@ CONFIG_SERIAL_BFIN_DMA=y
697# CONFIG_SERIAL_BFIN_PIO is not set 696# CONFIG_SERIAL_BFIN_PIO is not set
698CONFIG_SERIAL_BFIN_UART0=y 697CONFIG_SERIAL_BFIN_UART0=y
699# CONFIG_BFIN_UART0_CTSRTS is not set 698# CONFIG_BFIN_UART0_CTSRTS is not set
700# CONFIG_SERIAL_BFIN_UART1 is not set
701CONFIG_SERIAL_CORE=y 699CONFIG_SERIAL_CORE=y
702CONFIG_SERIAL_CORE_CONSOLE=y 700CONFIG_SERIAL_CORE_CONSOLE=y
703# CONFIG_SERIAL_BFIN_SPORT is not set 701# CONFIG_SERIAL_BFIN_SPORT is not set
diff --git a/arch/blackfin/configs/BF533-STAMP_defconfig b/arch/blackfin/configs/BF533-STAMP_defconfig
index 198f4123af4b..b51e76ce7f4f 100644
--- a/arch/blackfin/configs/BF533-STAMP_defconfig
+++ b/arch/blackfin/configs/BF533-STAMP_defconfig
@@ -323,10 +323,9 @@ CONFIG_PM=y
323# CONFIG_PM_LEGACY is not set 323# CONFIG_PM_LEGACY is not set
324# CONFIG_PM_DEBUG is not set 324# CONFIG_PM_DEBUG is not set
325# CONFIG_PM_SYSFS_DEPRECATED is not set 325# CONFIG_PM_SYSFS_DEPRECATED is not set
326CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR=y 326CONFIG_PM_BFIN_SLEEP_DEEPER=y
327# CONFIG_PM_BFIN_SLEEP is not set
327# CONFIG_PM_WAKEUP_BY_GPIO is not set 328# CONFIG_PM_WAKEUP_BY_GPIO is not set
328# CONFIG_PM_WAKEUP_GPIO_API is not set
329CONFIG_PM_WAKEUP_SIC_IWR=0x80
330 329
331# 330#
332# CPU Frequency scaling 331# CPU Frequency scaling
@@ -714,7 +713,6 @@ CONFIG_SERIAL_BFIN_DMA=y
714# CONFIG_SERIAL_BFIN_PIO is not set 713# CONFIG_SERIAL_BFIN_PIO is not set
715CONFIG_SERIAL_BFIN_UART0=y 714CONFIG_SERIAL_BFIN_UART0=y
716# CONFIG_BFIN_UART0_CTSRTS is not set 715# CONFIG_BFIN_UART0_CTSRTS is not set
717# CONFIG_SERIAL_BFIN_UART1 is not set
718CONFIG_SERIAL_CORE=y 716CONFIG_SERIAL_CORE=y
719CONFIG_SERIAL_CORE_CONSOLE=y 717CONFIG_SERIAL_CORE_CONSOLE=y
720# CONFIG_SERIAL_BFIN_SPORT is not set 718# CONFIG_SERIAL_BFIN_SPORT is not set
diff --git a/arch/blackfin/configs/BF537-STAMP_defconfig b/arch/blackfin/configs/BF537-STAMP_defconfig
index b37ccc681e7a..d45fa535dad7 100644
--- a/arch/blackfin/configs/BF537-STAMP_defconfig
+++ b/arch/blackfin/configs/BF537-STAMP_defconfig
@@ -330,10 +330,9 @@ CONFIG_PM=y
330# CONFIG_PM_LEGACY is not set 330# CONFIG_PM_LEGACY is not set
331# CONFIG_PM_DEBUG is not set 331# CONFIG_PM_DEBUG is not set
332# CONFIG_PM_SYSFS_DEPRECATED is not set 332# CONFIG_PM_SYSFS_DEPRECATED is not set
333CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR=y 333CONFIG_PM_BFIN_SLEEP_DEEPER=y
334# CONFIG_PM_BFIN_SLEEP is not set
334# CONFIG_PM_WAKEUP_BY_GPIO is not set 335# CONFIG_PM_WAKEUP_BY_GPIO is not set
335# CONFIG_PM_WAKEUP_GPIO_API is not set
336CONFIG_PM_WAKEUP_SIC_IWR=0x8
337 336
338# 337#
339# CPU Frequency scaling 338# CPU Frequency scaling
@@ -1013,6 +1012,7 @@ CONFIG_SND_BFIN_AD73311_SE=4
1013CONFIG_SND_SOC_AC97_BUS=y 1012CONFIG_SND_SOC_AC97_BUS=y
1014CONFIG_SND_SOC=m 1013CONFIG_SND_SOC=m
1015CONFIG_SND_BF5XX_SOC=m 1014CONFIG_SND_BF5XX_SOC=m
1015CONFIG_SND_MMAP_SUPPORT=y
1016CONFIG_SND_BF5XX_SOC_AC97=m 1016CONFIG_SND_BF5XX_SOC_AC97=m
1017# CONFIG_SND_BF5XX_SOC_WM8750 is not set 1017# CONFIG_SND_BF5XX_SOC_WM8750 is not set
1018# CONFIG_SND_BF5XX_SOC_WM8731 is not set 1018# CONFIG_SND_BF5XX_SOC_WM8731 is not set
diff --git a/arch/blackfin/configs/BF548-EZKIT_defconfig b/arch/blackfin/configs/BF548-EZKIT_defconfig
index fd702161ef59..c9707f7665ad 100644
--- a/arch/blackfin/configs/BF548-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF548-EZKIT_defconfig
@@ -396,6 +396,7 @@ CONFIG_BINFMT_ZFLAT=y
396# Power management options 396# Power management options
397# 397#
398# CONFIG_PM is not set 398# CONFIG_PM is not set
399# CONFIG_PM_WAKEUP_BY_GPIO is not set
399 400
400# 401#
401# CPU Frequency scaling 402# CPU Frequency scaling
@@ -1075,6 +1076,7 @@ CONFIG_SND_VERBOSE_PROCFS=y
1075CONFIG_SND_SOC_AC97_BUS=y 1076CONFIG_SND_SOC_AC97_BUS=y
1076CONFIG_SND_SOC=y 1077CONFIG_SND_SOC=y
1077CONFIG_SND_BF5XX_SOC=y 1078CONFIG_SND_BF5XX_SOC=y
1079CONFIG_SND_MMAP_SUPPORT=y
1078CONFIG_SND_BF5XX_SOC_AC97=y 1080CONFIG_SND_BF5XX_SOC_AC97=y
1079CONFIG_SND_BF5XX_SOC_BF548_EZKIT=y 1081CONFIG_SND_BF5XX_SOC_BF548_EZKIT=y
1080# CONFIG_SND_BF5XX_SOC_WM8750 is not set 1082# CONFIG_SND_BF5XX_SOC_WM8750 is not set
diff --git a/arch/blackfin/configs/BF561-EZKIT_defconfig b/arch/blackfin/configs/BF561-EZKIT_defconfig
index 8546994939fb..4d8a63331309 100644
--- a/arch/blackfin/configs/BF561-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF561-EZKIT_defconfig
@@ -367,6 +367,7 @@ CONFIG_BINFMT_ZFLAT=y
367# Power management options 367# Power management options
368# 368#
369# CONFIG_PM is not set 369# CONFIG_PM is not set
370# CONFIG_PM_WAKEUP_BY_GPIO is not set
370 371
371# 372#
372# Networking 373# Networking
diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c
index 5453bc3664fc..8fd5d22cec34 100644
--- a/arch/blackfin/kernel/bfin_dma_5xx.c
+++ b/arch/blackfin/kernel/bfin_dma_5xx.c
@@ -105,13 +105,14 @@ int request_dma(unsigned int channel, char *device_id)
105 mutex_unlock(&(dma_ch[channel].dmalock)); 105 mutex_unlock(&(dma_ch[channel].dmalock));
106 106
107#ifdef CONFIG_BF54x 107#ifdef CONFIG_BF54x
108 if (channel >= CH_UART2_RX && channel <= CH_UART3_TX && 108 if (channel >= CH_UART2_RX && channel <= CH_UART3_TX) {
109 strncmp(device_id, "BFIN_UART", 9) == 0) 109 if (strncmp(device_id, "BFIN_UART", 9) == 0)
110 dma_ch[channel].regs->peripheral_map |= 110 dma_ch[channel].regs->peripheral_map |=
111 (channel - CH_UART2_RX + 0xC); 111 (channel - CH_UART2_RX + 0xC);
112 else 112 else
113 dma_ch[channel].regs->peripheral_map |= 113 dma_ch[channel].regs->peripheral_map |=
114 (channel - CH_UART2_RX + 0x6); 114 (channel - CH_UART2_RX + 0x6);
115 }
115#endif 116#endif
116 117
117 dma_ch[channel].device_id = device_id; 118 dma_ch[channel].device_id = device_id;
diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c
index 5cf4bdb1df3b..1904d8b53328 100644
--- a/arch/blackfin/kernel/gptimers.c
+++ b/arch/blackfin/kernel/gptimers.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * bfin_gptimers.c - derived from bf53x_timers.c 2 * gptimers.c - Blackfin General Purpose Timer core API
3 * Driver for General Purpose Timer functions on the Blackfin processor
4 * 3 *
5 * Copyright (C) 2005 John DeHority 4 * Copyright (c) 2005-2008 Analog Devices Inc.
6 * Copyright (C) 2006 Hella Aglaia GmbH (awe@aglaia-gmbh.de) 5 * Copyright (C) 2005 John DeHority
6 * Copyright (C) 2006 Hella Aglaia GmbH (awe@aglaia-gmbh.de)
7 * 7 *
8 * Licensed under the GPLv2. 8 * Licensed under the GPLv2.
9 */ 9 */
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index 8229b1090eb9..2255c289a714 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -32,6 +32,7 @@
32static DEFINE_PER_CPU(struct cpu, cpu_devices); 32static DEFINE_PER_CPU(struct cpu, cpu_devices);
33 33
34u16 _bfin_swrst; 34u16 _bfin_swrst;
35EXPORT_SYMBOL(_bfin_swrst);
35 36
36unsigned long memory_start, memory_end, physical_mem_end; 37unsigned long memory_start, memory_end, physical_mem_end;
37unsigned long reserved_mem_dcache_on; 38unsigned long reserved_mem_dcache_on;
@@ -514,6 +515,7 @@ static __init void memory_setup(void)
514 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20); 515 printk(KERN_INFO "Kernel Managed Memory: %ldMB\n", _ramend >> 20);
515 516
516 printk(KERN_INFO "Memory map:\n" 517 printk(KERN_INFO "Memory map:\n"
518 KERN_INFO " fixedcode = 0x%p-0x%p\n"
517 KERN_INFO " text = 0x%p-0x%p\n" 519 KERN_INFO " text = 0x%p-0x%p\n"
518 KERN_INFO " rodata = 0x%p-0x%p\n" 520 KERN_INFO " rodata = 0x%p-0x%p\n"
519 KERN_INFO " bss = 0x%p-0x%p\n" 521 KERN_INFO " bss = 0x%p-0x%p\n"
@@ -527,7 +529,8 @@ static __init void memory_setup(void)
527#if DMA_UNCACHED_REGION > 0 529#if DMA_UNCACHED_REGION > 0
528 KERN_INFO " DMA Zone = 0x%p-0x%p\n" 530 KERN_INFO " DMA Zone = 0x%p-0x%p\n"
529#endif 531#endif
530 , _stext, _etext, 532 , (void *)FIXED_CODE_START, (void *)FIXED_CODE_END,
533 _stext, _etext,
531 __start_rodata, __end_rodata, 534 __start_rodata, __end_rodata,
532 __bss_start, __bss_stop, 535 __bss_start, __bss_stop,
533 _sdata, _edata, 536 _sdata, _edata,
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index aed832540b3b..cb01a9de2680 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -147,44 +147,64 @@ SECTIONS
147 147
148 __l1_lma_start = .; 148 __l1_lma_start = .;
149 149
150#if L1_CODE_LENGTH
151# define LDS_L1_CODE *(.l1.text)
152#else
153# define LDS_L1_CODE
154#endif
150 .text_l1 L1_CODE_START : AT(LOADADDR(.init.ramfs) + SIZEOF(.init.ramfs)) 155 .text_l1 L1_CODE_START : AT(LOADADDR(.init.ramfs) + SIZEOF(.init.ramfs))
151 { 156 {
152 . = ALIGN(4); 157 . = ALIGN(4);
153 __stext_l1 = .; 158 __stext_l1 = .;
154 *(.l1.text) 159 LDS_L1_CODE
155
156 . = ALIGN(4); 160 . = ALIGN(4);
157 __etext_l1 = .; 161 __etext_l1 = .;
158 } 162 }
159 163
164#if L1_DATA_A_LENGTH
165# define LDS_L1_A_DATA *(.l1.data)
166# define LDS_L1_A_BSS *(.l1.bss)
167# define LDS_L1_A_CACHE *(.data_l1.cacheline_aligned)
168#else
169# define LDS_L1_A_DATA
170# define LDS_L1_A_BSS
171# define LDS_L1_A_CACHE
172#endif
160 .data_l1 L1_DATA_A_START : AT(LOADADDR(.text_l1) + SIZEOF(.text_l1)) 173 .data_l1 L1_DATA_A_START : AT(LOADADDR(.text_l1) + SIZEOF(.text_l1))
161 { 174 {
162 . = ALIGN(4); 175 . = ALIGN(4);
163 __sdata_l1 = .; 176 __sdata_l1 = .;
164 *(.l1.data) 177 LDS_L1_A_DATA
165 __edata_l1 = .; 178 __edata_l1 = .;
166 179
167 . = ALIGN(4); 180 . = ALIGN(4);
168 __sbss_l1 = .; 181 __sbss_l1 = .;
169 *(.l1.bss) 182 LDS_L1_A_BSS
170 183
171 . = ALIGN(32); 184 . = ALIGN(32);
172 *(.data_l1.cacheline_aligned) 185 LDS_L1_A_CACHE
173 186
174 . = ALIGN(4); 187 . = ALIGN(4);
175 __ebss_l1 = .; 188 __ebss_l1 = .;
176 } 189 }
177 190
191#if L1_DATA_B_LENGTH
192# define LDS_L1_B_DATA *(.l1.data.B)
193# define LDS_L1_B_BSS *(.l1.bss.B)
194#else
195# define LDS_L1_B_DATA
196# define LDS_L1_B_BSS
197#endif
178 .data_b_l1 L1_DATA_B_START : AT(LOADADDR(.data_l1) + SIZEOF(.data_l1)) 198 .data_b_l1 L1_DATA_B_START : AT(LOADADDR(.data_l1) + SIZEOF(.data_l1))
179 { 199 {
180 . = ALIGN(4); 200 . = ALIGN(4);
181 __sdata_b_l1 = .; 201 __sdata_b_l1 = .;
182 *(.l1.data.B) 202 LDS_L1_B_DATA
183 __edata_b_l1 = .; 203 __edata_b_l1 = .;
184 204
185 . = ALIGN(4); 205 . = ALIGN(4);
186 __sbss_b_l1 = .; 206 __sbss_b_l1 = .;
187 *(.l1.bss.B) 207 LDS_L1_B_BSS
188 208
189 . = ALIGN(4); 209 . = ALIGN(4);
190 __ebss_b_l1 = .; 210 __ebss_b_l1 = .;
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 337515fba612..cf4bc0d83355 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -180,8 +180,8 @@ static struct mtd_partition partition_info[] = {
180 }, 180 },
181 { 181 {
182 .name = "File System", 182 .name = "File System",
183 .offset = 4 * SIZE_1M, 183 .offset = MTDPART_OFS_APPEND,
184 .size = (256 - 4) * SIZE_1M, 184 .size = MTDPART_SIZ_FULL,
185 }, 185 },
186}; 186};
187 187
@@ -422,11 +422,11 @@ static struct mtd_partition bfin_spi_flash_partitions[] = {
422 }, { 422 }, {
423 .name = "kernel", 423 .name = "kernel",
424 .size = 0xe0000, 424 .size = 0xe0000,
425 .offset = 0x20000 425 .offset = MTDPART_OFS_APPEND,
426 }, { 426 }, {
427 .name = "file system", 427 .name = "file system",
428 .size = 0x700000, 428 .size = MTDPART_SIZ_FULL,
429 .offset = 0x00100000, 429 .offset = MTDPART_OFS_APPEND,
430 } 430 }
431}; 431};
432 432
@@ -484,13 +484,6 @@ static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
484}; 484};
485#endif 485#endif
486 486
487#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
488static struct bfin5xx_spi_chip ad5304_chip_info = {
489 .enable_dma = 0,
490 .bits_per_word = 16,
491};
492#endif
493
494#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 487#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
495static struct bfin5xx_spi_chip spi_ad7877_chip_info = { 488static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
496 .enable_dma = 0, 489 .enable_dma = 0,
@@ -611,17 +604,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
611 .mode = SPI_MODE_3, 604 .mode = SPI_MODE_3,
612 }, 605 },
613#endif 606#endif
614#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
615 {
616 .modalias = "ad5304_spi",
617 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
618 .bus_num = 0,
619 .chip_select = 2,
620 .platform_data = NULL,
621 .controller_data = &ad5304_chip_info,
622 .mode = SPI_MODE_2,
623 },
624#endif
625#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 607#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
626 { 608 {
627 .modalias = "ad7877", 609 .modalias = "ad7877",
@@ -818,6 +800,19 @@ static struct platform_device bfin_device_gpiokeys = {
818}; 800};
819#endif 801#endif
820 802
803static struct resource bfin_gpios_resources = {
804 .start = 0,
805 .end = MAX_BLACKFIN_GPIOS - 1,
806 .flags = IORESOURCE_IRQ,
807};
808
809static struct platform_device bfin_gpios_device = {
810 .name = "simple-gpio",
811 .id = -1,
812 .num_resources = 1,
813 .resource = &bfin_gpios_resources,
814};
815
821static struct platform_device *stamp_devices[] __initdata = { 816static struct platform_device *stamp_devices[] __initdata = {
822#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 817#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
823 &bf5xx_nand_device, 818 &bf5xx_nand_device,
@@ -895,6 +890,8 @@ static struct platform_device *stamp_devices[] __initdata = {
895#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 890#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
896 &bfin_device_gpiokeys, 891 &bfin_device_gpiokeys,
897#endif 892#endif
893
894 &bfin_gpios_device,
898}; 895};
899 896
900static int __init stamp_init(void) 897static int __init stamp_init(void)
@@ -921,13 +918,18 @@ void native_machine_restart(char *cmd)
921 bfin_gpio_reset_spi0_ssel1(); 918 bfin_gpio_reset_spi0_ssel1();
922} 919}
923 920
924/*
925 * Currently the MAC address is saved in Flash by U-Boot
926 */
927#define FLASH_MAC 0x203f0000
928void bfin_get_ether_addr(char *addr) 921void bfin_get_ether_addr(char *addr)
929{ 922{
930 *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC); 923 /* the MAC is stored in OTP memory page 0xDF */
931 *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4); 924 u32 ret;
925 u64 otp_mac;
926 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
927
928 ret = otp_read(0xDF, 0x00, &otp_mac);
929 if (!(ret & 0x1)) {
930 char *otp_mac_p = (char *)&otp_mac;
931 for (ret = 0; ret < 6; ++ret)
932 addr[ret] = otp_mac_p[5 - ret];
933 }
932} 934}
933EXPORT_SYMBOL(bfin_get_ether_addr); 935EXPORT_SYMBOL(bfin_get_ether_addr);
diff --git a/arch/blackfin/mach-bf533/boards/ezkit.c b/arch/blackfin/mach-bf533/boards/ezkit.c
index 2b09aa39f565..241b5a20a36a 100644
--- a/arch/blackfin/mach-bf533/boards/ezkit.c
+++ b/arch/blackfin/mach-bf533/boards/ezkit.c
@@ -99,11 +99,11 @@ static struct mtd_partition bfin_spi_flash_partitions[] = {
99 }, { 99 }, {
100 .name = "kernel", 100 .name = "kernel",
101 .size = 0xe0000, 101 .size = 0xe0000,
102 .offset = 0x20000 102 .offset = MTDPART_OFS_APPEND,
103 }, { 103 }, {
104 .name = "file system", 104 .name = "file system",
105 .size = 0x700000, 105 .size = MTDPART_SIZ_FULL,
106 .offset = 0x00100000, 106 .offset = MTDPART_OFS_APPEND,
107 } 107 }
108}; 108};
109 109
@@ -298,6 +298,19 @@ static struct platform_device bfin_device_gpiokeys = {
298}; 298};
299#endif 299#endif
300 300
301static struct resource bfin_gpios_resources = {
302 .start = 0,
303 .end = MAX_BLACKFIN_GPIOS - 1,
304 .flags = IORESOURCE_IRQ,
305};
306
307static struct platform_device bfin_gpios_device = {
308 .name = "simple-gpio",
309 .id = -1,
310 .num_resources = 1,
311 .resource = &bfin_gpios_resources,
312};
313
301#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 314#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
302#include <linux/i2c-gpio.h> 315#include <linux/i2c-gpio.h>
303 316
@@ -350,6 +363,8 @@ static struct platform_device *ezkit_devices[] __initdata = {
350#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 363#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
351 &i2c_gpio_device, 364 &i2c_gpio_device,
352#endif 365#endif
366
367 &bfin_gpios_device,
353}; 368};
354 369
355static int __init ezkit_init(void) 370static int __init ezkit_init(void)
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index a645f6fd091b..b2ac4816ae62 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -112,7 +112,7 @@ static struct platform_device net2272_bfin_device = {
112static struct mtd_partition stamp_partitions[] = { 112static struct mtd_partition stamp_partitions[] = {
113 { 113 {
114 .name = "Bootloader", 114 .name = "Bootloader",
115 .size = 0x20000, 115 .size = 0x40000,
116 .offset = 0, 116 .offset = 0,
117 }, { 117 }, {
118 .name = "Kernel", 118 .name = "Kernel",
@@ -160,17 +160,17 @@ static struct platform_device stamp_flash_device = {
160static struct mtd_partition bfin_spi_flash_partitions[] = { 160static struct mtd_partition bfin_spi_flash_partitions[] = {
161 { 161 {
162 .name = "bootloader", 162 .name = "bootloader",
163 .size = 0x00020000, 163 .size = 0x00040000,
164 .offset = 0, 164 .offset = 0,
165 .mask_flags = MTD_CAP_ROM 165 .mask_flags = MTD_CAP_ROM
166 }, { 166 }, {
167 .name = "kernel", 167 .name = "kernel",
168 .size = 0xe0000, 168 .size = 0xe0000,
169 .offset = 0x20000 169 .offset = MTDPART_OFS_APPEND,
170 }, { 170 }, {
171 .name = "file system", 171 .name = "file system",
172 .size = 0x700000, 172 .size = MTDPART_SIZ_FULL,
173 .offset = 0x00100000, 173 .offset = MTDPART_OFS_APPEND,
174 } 174 }
175}; 175};
176 176
@@ -212,13 +212,6 @@ static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
212}; 212};
213#endif 213#endif
214 214
215#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
216static struct bfin5xx_spi_chip ad5304_chip_info = {
217 .enable_dma = 0,
218 .bits_per_word = 16,
219};
220#endif
221
222#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE) 215#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
223static struct bfin5xx_spi_chip spi_mmc_chip_info = { 216static struct bfin5xx_spi_chip spi_mmc_chip_info = {
224 .enable_dma = 1, 217 .enable_dma = 1,
@@ -308,17 +301,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
308 }, 301 },
309#endif 302#endif
310 303
311#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
312 {
313 .modalias = "ad5304_spi",
314 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
315 .bus_num = 0,
316 .chip_select = 2,
317 .platform_data = NULL,
318 .controller_data = &ad5304_chip_info,
319 .mode = SPI_MODE_2,
320 },
321#endif
322#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 304#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
323 { 305 {
324 .modalias = "spidev", 306 .modalias = "spidev",
@@ -457,6 +439,19 @@ static struct platform_device bfin_device_gpiokeys = {
457}; 439};
458#endif 440#endif
459 441
442static struct resource bfin_gpios_resources = {
443 .start = 0,
444 .end = MAX_BLACKFIN_GPIOS - 1,
445 .flags = IORESOURCE_IRQ,
446};
447
448static struct platform_device bfin_gpios_device = {
449 .name = "simple-gpio",
450 .id = -1,
451 .num_resources = 1,
452 .resource = &bfin_gpios_resources,
453};
454
460#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 455#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
461#include <linux/i2c-gpio.h> 456#include <linux/i2c-gpio.h>
462 457
@@ -518,6 +513,8 @@ static struct platform_device *stamp_devices[] __initdata = {
518#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 513#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
519 &i2c_gpio_device, 514 &i2c_gpio_device,
520#endif 515#endif
516
517 &bfin_gpios_device,
521 &stamp_flash_device, 518 &stamp_flash_device,
522}; 519};
523 520
diff --git a/arch/blackfin/mach-bf537/boards/generic_board.c b/arch/blackfin/mach-bf537/boards/generic_board.c
index 8a3397db1d21..c95395ba7bfa 100644
--- a/arch/blackfin/mach-bf537/boards/generic_board.c
+++ b/arch/blackfin/mach-bf537/boards/generic_board.c
@@ -371,13 +371,6 @@ static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
371}; 371};
372#endif 372#endif
373 373
374#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
375static struct bfin5xx_spi_chip ad5304_chip_info = {
376 .enable_dma = 0,
377 .bits_per_word = 16,
378};
379#endif
380
381#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 374#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
382static struct bfin5xx_spi_chip spi_ad7877_chip_info = { 375static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
383 .enable_dma = 0, 376 .enable_dma = 0,
@@ -483,17 +476,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
483 .mode = SPI_MODE_3, 476 .mode = SPI_MODE_3,
484 }, 477 },
485#endif 478#endif
486#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
487 {
488 .modalias = "ad5304_spi",
489 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
490 .bus_num = 0,
491 .chip_select = 2,
492 .platform_data = NULL,
493 .controller_data = &ad5304_chip_info,
494 .mode = SPI_MODE_2,
495 },
496#endif
497#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 479#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
498 { 480 {
499 .modalias = "ad7877", 481 .modalias = "ad7877",
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 9e2277e0d25c..ea83148993da 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -128,6 +128,19 @@ static struct platform_device bfin_device_gpiokeys = {
128}; 128};
129#endif 129#endif
130 130
131static struct resource bfin_gpios_resources = {
132 .start = 0,
133 .end = MAX_BLACKFIN_GPIOS - 1,
134 .flags = IORESOURCE_IRQ,
135};
136
137static struct platform_device bfin_gpios_device = {
138 .name = "simple-gpio",
139 .id = -1,
140 .num_resources = 1,
141 .resource = &bfin_gpios_resources,
142};
143
131#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 144#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
132static struct resource bfin_pcmcia_cf_resources[] = { 145static struct resource bfin_pcmcia_cf_resources[] = {
133 { 146 {
@@ -343,7 +356,7 @@ static struct platform_device net2272_bfin_device = {
343static struct mtd_partition stamp_partitions[] = { 356static struct mtd_partition stamp_partitions[] = {
344 { 357 {
345 .name = "Bootloader", 358 .name = "Bootloader",
346 .size = 0x20000, 359 .size = 0x40000,
347 .offset = 0, 360 .offset = 0,
348 }, { 361 }, {
349 .name = "Kernel", 362 .name = "Kernel",
@@ -351,7 +364,7 @@ static struct mtd_partition stamp_partitions[] = {
351 .offset = MTDPART_OFS_APPEND, 364 .offset = MTDPART_OFS_APPEND,
352 }, { 365 }, {
353 .name = "RootFS", 366 .name = "RootFS",
354 .size = 0x400000 - 0x20000 - 0xE0000 - 0x10000, 367 .size = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
355 .offset = MTDPART_OFS_APPEND, 368 .offset = MTDPART_OFS_APPEND,
356 }, { 369 }, {
357 .name = "MAC Address", 370 .name = "MAC Address",
@@ -391,17 +404,17 @@ static struct platform_device stamp_flash_device = {
391static struct mtd_partition bfin_spi_flash_partitions[] = { 404static struct mtd_partition bfin_spi_flash_partitions[] = {
392 { 405 {
393 .name = "bootloader", 406 .name = "bootloader",
394 .size = 0x00020000, 407 .size = 0x00040000,
395 .offset = 0, 408 .offset = 0,
396 .mask_flags = MTD_CAP_ROM 409 .mask_flags = MTD_CAP_ROM
397 }, { 410 }, {
398 .name = "kernel", 411 .name = "kernel",
399 .size = 0xe0000, 412 .size = 0xe0000,
400 .offset = 0x20000 413 .offset = MTDPART_OFS_APPEND,
401 }, { 414 }, {
402 .name = "file system", 415 .name = "file system",
403 .size = 0x700000, 416 .size = MTDPART_SIZ_FULL,
404 .offset = 0x00100000, 417 .offset = MTDPART_OFS_APPEND,
405 } 418 }
406}; 419};
407 420
@@ -459,13 +472,6 @@ static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
459}; 472};
460#endif 473#endif
461 474
462#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
463static struct bfin5xx_spi_chip ad5304_chip_info = {
464 .enable_dma = 0,
465 .bits_per_word = 16,
466};
467#endif
468
469#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 475#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
470static struct bfin5xx_spi_chip spi_ad7877_chip_info = { 476static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
471 .enable_dma = 0, 477 .enable_dma = 0,
@@ -578,17 +584,6 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
578 .mode = SPI_MODE_3, 584 .mode = SPI_MODE_3,
579 }, 585 },
580#endif 586#endif
581#if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
582 {
583 .modalias = "ad5304_spi",
584 .max_speed_hz = 1250000, /* max spi clock (SCK) speed in HZ */
585 .bus_num = 0,
586 .chip_select = 2,
587 .platform_data = NULL,
588 .controller_data = &ad5304_chip_info,
589 .mode = SPI_MODE_2,
590 },
591#endif
592#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) 587#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
593 { 588 {
594 .modalias = "ad7877", 589 .modalias = "ad7877",
@@ -821,6 +816,8 @@ static struct platform_device *stamp_devices[] __initdata = {
821#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 816#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
822 &bfin_device_gpiokeys, 817 &bfin_device_gpiokeys,
823#endif 818#endif
819
820 &bfin_gpios_device,
824 &stamp_flash_device, 821 &stamp_flash_device,
825}; 822};
826 823
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index 916e963e83ba..a0950c1fd800 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -285,8 +285,8 @@ static struct mtd_partition partition_info[] = {
285 }, 285 },
286 { 286 {
287 .name = "File System", 287 .name = "File System",
288 .offset = 4 * SIZE_1M, 288 .offset = MTDPART_OFS_APPEND,
289 .size = (256 - 4) * SIZE_1M, 289 .size = MTDPART_SIZ_FULL,
290 }, 290 },
291}; 291};
292 292
@@ -333,7 +333,7 @@ static struct platform_device bf54x_sdh_device = {
333static struct mtd_partition ezkit_partitions[] = { 333static struct mtd_partition ezkit_partitions[] = {
334 { 334 {
335 .name = "Bootloader", 335 .name = "Bootloader",
336 .size = 0x20000, 336 .size = 0x40000,
337 .offset = 0, 337 .offset = 0,
338 }, { 338 }, {
339 .name = "Kernel", 339 .name = "Kernel",
@@ -381,8 +381,8 @@ static struct mtd_partition bfin_spi_flash_partitions[] = {
381 .mask_flags = MTD_CAP_ROM 381 .mask_flags = MTD_CAP_ROM
382 }, { 382 }, {
383 .name = "linux kernel", 383 .name = "linux kernel",
384 .size = 0x1c0000, 384 .size = MTDPART_SIZ_FULL,
385 .offset = 0x40000 385 .offset = MTDPART_OFS_APPEND,
386 } 386 }
387}; 387};
388 388
@@ -594,6 +594,19 @@ static struct platform_device bfin_device_gpiokeys = {
594}; 594};
595#endif 595#endif
596 596
597static struct resource bfin_gpios_resources = {
598 .start = 0,
599 .end = MAX_BLACKFIN_GPIOS - 1,
600 .flags = IORESOURCE_IRQ,
601};
602
603static struct platform_device bfin_gpios_device = {
604 .name = "simple-gpio",
605 .id = -1,
606 .num_resources = 1,
607 .resource = &bfin_gpios_resources,
608};
609
597static struct platform_device *ezkit_devices[] __initdata = { 610static struct platform_device *ezkit_devices[] __initdata = {
598#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 611#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
599 &rtc_device, 612 &rtc_device,
@@ -646,6 +659,8 @@ static struct platform_device *ezkit_devices[] __initdata = {
646#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 659#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
647 &bfin_device_gpiokeys, 660 &bfin_device_gpiokeys,
648#endif 661#endif
662
663 &bfin_gpios_device,
649 &ezkit_flash_device, 664 &ezkit_flash_device,
650}; 665};
651 666
diff --git a/arch/blackfin/mach-bf548/dma.c b/arch/blackfin/mach-bf548/dma.c
index 374803a8d2e8..f5479298bb79 100644
--- a/arch/blackfin/mach-bf548/dma.c
+++ b/arch/blackfin/mach-bf548/dma.c
@@ -27,6 +27,8 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30#include <linux/module.h>
31
30#include <asm/blackfin.h> 32#include <asm/blackfin.h>
31#include <asm/dma.h> 33#include <asm/dma.h>
32 34
diff --git a/arch/blackfin/mach-bf548/head.S b/arch/blackfin/mach-bf548/head.S
index 74fe258421a5..46222a75321a 100644
--- a/arch/blackfin/mach-bf548/head.S
+++ b/arch/blackfin/mach-bf548/head.S
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/linkage.h> 30#include <linux/linkage.h>
31#include <linux/init.h>
31#include <asm/blackfin.h> 32#include <asm/blackfin.h>
32#include <asm/trace.h> 33#include <asm/trace.h>
33#if CONFIG_BFIN_KERNEL_CLOCK 34#if CONFIG_BFIN_KERNEL_CLOCK
@@ -44,10 +45,9 @@
44 45
45#define INITIAL_STACK 0xFFB01000 46#define INITIAL_STACK 0xFFB01000
46 47
47.text 48__INIT
48 49
49ENTRY(__start) 50ENTRY(__start)
50ENTRY(__stext)
51 /* R0: argument of command line string, passed from uboot, save it */ 51 /* R0: argument of command line string, passed from uboot, save it */
52 R7 = R0; 52 R7 = R0;
53 /* Enable Cycle Counter and Nesting Of Interrupts */ 53 /* Enable Cycle Counter and Nesting Of Interrupts */
@@ -213,6 +213,7 @@ ENTRY(__stext)
213 213
214.LWAIT_HERE: 214.LWAIT_HERE:
215 jump .LWAIT_HERE; 215 jump .LWAIT_HERE;
216ENDPROC(__start)
216 217
217ENTRY(_real_start) 218ENTRY(_real_start)
218 [ -- sp ] = reti; 219 [ -- sp ] = reti;
@@ -285,6 +286,9 @@ ENTRY(_real_start)
285 call _start_kernel; 286 call _start_kernel;
286.L_exit: 287.L_exit:
287 jump.s .L_exit; 288 jump.s .L_exit;
289ENDPROC(_real_start)
290
291__FINIT
288 292
289.section .l1.text 293.section .l1.text
290#if CONFIG_BFIN_KERNEL_CLOCK 294#if CONFIG_BFIN_KERNEL_CLOCK
@@ -450,6 +454,7 @@ ENTRY(_start_dma_code)
450 SSYNC; 454 SSYNC;
451 455
452 RTS; 456 RTS;
457ENDPROC(_start_dma_code)
453#endif /* CONFIG_BFIN_KERNEL_CLOCK */ 458#endif /* CONFIG_BFIN_KERNEL_CLOCK */
454 459
455.data 460.data
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 43c1b0982819..d357f648d963 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -223,7 +223,7 @@ static struct platform_device bfin_uart_device = {
223static struct mtd_partition ezkit_partitions[] = { 223static struct mtd_partition ezkit_partitions[] = {
224 { 224 {
225 .name = "Bootloader", 225 .name = "Bootloader",
226 .size = 0x20000, 226 .size = 0x40000,
227 .offset = 0, 227 .offset = 0,
228 }, { 228 }, {
229 .name = "Kernel", 229 .name = "Kernel",
@@ -389,6 +389,19 @@ static struct platform_device bfin_device_gpiokeys = {
389}; 389};
390#endif 390#endif
391 391
392static struct resource bfin_gpios_resources = {
393 .start = 0,
394 .end = MAX_BLACKFIN_GPIOS - 1,
395 .flags = IORESOURCE_IRQ,
396};
397
398static struct platform_device bfin_gpios_device = {
399 .name = "simple-gpio",
400 .id = -1,
401 .num_resources = 1,
402 .resource = &bfin_gpios_resources,
403};
404
392#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) 405#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
393#include <linux/i2c-gpio.h> 406#include <linux/i2c-gpio.h>
394 407
@@ -446,6 +459,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
446 &isp1362_hcd_device, 459 &isp1362_hcd_device,
447#endif 460#endif
448 461
462 &bfin_gpios_device,
449 &ezkit_flash_device, 463 &ezkit_flash_device,
450}; 464};
451 465
diff --git a/arch/blackfin/mach-common/dpmc.S b/arch/blackfin/mach-common/dpmc.S
index b80ddd8b232d..9d45aa3265b1 100644
--- a/arch/blackfin/mach-common/dpmc.S
+++ b/arch/blackfin/mach-common/dpmc.S
@@ -31,140 +31,6 @@
31#include <asm/blackfin.h> 31#include <asm/blackfin.h>
32#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33 33
34.text
35
36ENTRY(_unmask_wdog_wakeup_evt)
37 [--SP] = ( R7:0, P5:0 );
38#if defined(CONFIG_BF561)
39 P0.H = hi(SICA_IWR1);
40 P0.L = lo(SICA_IWR1);
41#elif defined(CONFIG_BF54x) || defined(CONFIG_BF52x)
42 P0.h = HI(SIC_IWR0);
43 P0.l = LO(SIC_IWR0);
44#else
45 P0.h = HI(SIC_IWR);
46 P0.l = LO(SIC_IWR);
47#endif
48 R7 = [P0];
49#if defined(CONFIG_BF561)
50 BITSET(R7, 27);
51#else
52 BITSET(R7,(IRQ_WATCH - IVG7));
53#endif
54 [P0] = R7;
55 SSYNC;
56
57 ( R7:0, P5:0 ) = [SP++];
58 RTS;
59
60.LWRITE_TO_STAT:
61 /* When watch dog timer is enabled, a write to STAT will load the
62 * contents of CNT to STAT
63 */
64 R7 = 0x0000(z);
65#if defined(CONFIG_BF561)
66 P0.h = HI(WDOGA_STAT);
67 P0.l = LO(WDOGA_STAT);
68#else
69 P0.h = HI(WDOG_STAT);
70 P0.l = LO(WDOG_STAT);
71#endif
72 [P0] = R7;
73 SSYNC;
74 JUMP .LSKIP_WRITE_TO_STAT;
75
76ENTRY(_program_wdog_timer)
77 [--SP] = ( R7:0, P5:0 );
78#if defined(CONFIG_BF561)
79 P0.h = HI(WDOGA_CNT);
80 P0.l = LO(WDOGA_CNT);
81#else
82 P0.h = HI(WDOG_CNT);
83 P0.l = LO(WDOG_CNT);
84#endif
85 [P0] = R0;
86 SSYNC;
87
88#if defined(CONFIG_BF561)
89 P0.h = HI(WDOGA_CTL);
90 P0.l = LO(WDOGA_CTL);
91#else
92 P0.h = HI(WDOG_CTL);
93 P0.l = LO(WDOG_CTL);
94#endif
95 R7 = W[P0](Z);
96 CC = BITTST(R7,1);
97 if !CC JUMP .LWRITE_TO_STAT;
98 CC = BITTST(R7,2);
99 if !CC JUMP .LWRITE_TO_STAT;
100
101.LSKIP_WRITE_TO_STAT:
102#if defined(CONFIG_BF561)
103 P0.h = HI(WDOGA_CTL);
104 P0.l = LO(WDOGA_CTL);
105#else
106 P0.h = HI(WDOG_CTL);
107 P0.l = LO(WDOG_CTL);
108#endif
109 R7 = W[P0](Z);
110 BITCLR(R7,1); /* Enable GP event */
111 BITSET(R7,2);
112 W[P0] = R7.L;
113 SSYNC;
114 NOP;
115
116 R7 = W[P0](Z);
117 BITCLR(R7,4); /* Enable the wdog counter */
118 W[P0] = R7.L;
119 SSYNC;
120
121 ( R7:0, P5:0 ) = [SP++];
122 RTS;
123
124ENTRY(_clear_wdog_wakeup_evt)
125 [--SP] = ( R7:0, P5:0 );
126
127#if defined(CONFIG_BF561)
128 P0.h = HI(WDOGA_CTL);
129 P0.l = LO(WDOGA_CTL);
130#else
131 P0.h = HI(WDOG_CTL);
132 P0.l = LO(WDOG_CTL);
133#endif
134 R7 = 0x0AD6(Z);
135 W[P0] = R7.L;
136 SSYNC;
137
138 R7 = W[P0](Z);
139 BITSET(R7,15);
140 W[P0] = R7.L;
141 SSYNC;
142
143 R7 = W[P0](Z);
144 BITSET(R7,1);
145 BITSET(R7,2);
146 W[P0] = R7.L;
147 SSYNC;
148
149 ( R7:0, P5:0 ) = [SP++];
150 RTS;
151
152ENTRY(_disable_wdog_timer)
153 [--SP] = ( R7:0, P5:0 );
154#if defined(CONFIG_BF561)
155 P0.h = HI(WDOGA_CTL);
156 P0.l = LO(WDOGA_CTL);
157#else
158 P0.h = HI(WDOG_CTL);
159 P0.l = LO(WDOG_CTL);
160#endif
161 R7 = 0xAD6(Z);
162 W[P0] = R7.L;
163 SSYNC;
164 ( R7:0, P5:0 ) = [SP++];
165 RTS;
166
167#if !defined(CONFIG_BF561)
168 34
169.section .l1.text 35.section .l1.text
170 36
@@ -459,10 +325,12 @@ ENTRY(_set_sic_iwr)
459 RTS; 325 RTS;
460 326
461ENTRY(_set_rtc_istat) 327ENTRY(_set_rtc_istat)
328#ifndef CONFIG_BF561
462 P0.H = hi(RTC_ISTAT); 329 P0.H = hi(RTC_ISTAT);
463 P0.L = lo(RTC_ISTAT); 330 P0.L = lo(RTC_ISTAT);
464 w[P0] = R0.L; 331 w[P0] = R0.L;
465 SSYNC; 332 SSYNC;
333#endif
466 RTS; 334 RTS;
467 335
468ENTRY(_test_pll_locked) 336ENTRY(_test_pll_locked)
@@ -473,4 +341,3 @@ ENTRY(_test_pll_locked)
473 CC = BITTST(R0,5); 341 CC = BITTST(R0,5);
474 IF !CC JUMP 1b; 342 IF !CC JUMP 1b;
475 RTS; 343 RTS;
476#endif
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 880595afe98d..225ef14af75e 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -74,7 +74,7 @@ unsigned long bfin_sic_iwr[3]; /* Up to 3 SIC_IWRx registers */
74#endif 74#endif
75 75
76struct ivgx { 76struct ivgx {
77 /* irq number for request_irq, available in mach-bf533/irq.h */ 77 /* irq number for request_irq, available in mach-bf5xx/irq.h */
78 unsigned int irqno; 78 unsigned int irqno;
79 /* corresponding bit in the SIC_ISR register */ 79 /* corresponding bit in the SIC_ISR register */
80 unsigned int isrflag; 80 unsigned int isrflag;
@@ -86,7 +86,6 @@ struct ivg_slice {
86 struct ivgx *istop; 86 struct ivgx *istop;
87} ivg7_13[IVG13 - IVG7 + 1]; 87} ivg7_13[IVG13 - IVG7 + 1];
88 88
89static void search_IAR(void);
90 89
91/* 90/*
92 * Search SIC_IAR and fill tables with the irqvalues 91 * Search SIC_IAR and fill tables with the irqvalues
@@ -120,10 +119,10 @@ static void __init search_IAR(void)
120} 119}
121 120
122/* 121/*
123 * This is for BF533 internal IRQs 122 * This is for core internal IRQs
124 */ 123 */
125 124
126static void ack_noop(unsigned int irq) 125static void bfin_ack_noop(unsigned int irq)
127{ 126{
128 /* Dummy function. */ 127 /* Dummy function. */
129} 128}
@@ -156,11 +155,11 @@ static void bfin_internal_mask_irq(unsigned int irq)
156{ 155{
157#ifdef CONFIG_BF53x 156#ifdef CONFIG_BF53x
158 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() & 157 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
159 ~(1 << (irq - (IRQ_CORETMR + 1)))); 158 ~(1 << SIC_SYSIRQ(irq)));
160#else 159#else
161 unsigned mask_bank, mask_bit; 160 unsigned mask_bank, mask_bit;
162 mask_bank = (irq - (IRQ_CORETMR + 1)) / 32; 161 mask_bank = SIC_SYSIRQ(irq) / 32;
163 mask_bit = (irq - (IRQ_CORETMR + 1)) % 32; 162 mask_bit = SIC_SYSIRQ(irq) % 32;
164 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) & 163 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) &
165 ~(1 << mask_bit)); 164 ~(1 << mask_bit));
166#endif 165#endif
@@ -171,11 +170,11 @@ static void bfin_internal_unmask_irq(unsigned int irq)
171{ 170{
172#ifdef CONFIG_BF53x 171#ifdef CONFIG_BF53x
173 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 172 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() |
174 (1 << (irq - (IRQ_CORETMR + 1)))); 173 (1 << SIC_SYSIRQ(irq)));
175#else 174#else
176 unsigned mask_bank, mask_bit; 175 unsigned mask_bank, mask_bit;
177 mask_bank = (irq - (IRQ_CORETMR + 1)) / 32; 176 mask_bank = SIC_SYSIRQ(irq) / 32;
178 mask_bit = (irq - (IRQ_CORETMR + 1)) % 32; 177 mask_bit = SIC_SYSIRQ(irq) % 32;
179 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) | 178 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) |
180 (1 << mask_bit)); 179 (1 << mask_bit));
181#endif 180#endif
@@ -187,8 +186,8 @@ int bfin_internal_set_wake(unsigned int irq, unsigned int state)
187{ 186{
188 unsigned bank, bit; 187 unsigned bank, bit;
189 unsigned long flags; 188 unsigned long flags;
190 bank = (irq - (IRQ_CORETMR + 1)) / 32; 189 bank = SIC_SYSIRQ(irq) / 32;
191 bit = (irq - (IRQ_CORETMR + 1)) % 32; 190 bit = SIC_SYSIRQ(irq) % 32;
192 191
193 local_irq_save(flags); 192 local_irq_save(flags);
194 193
@@ -204,15 +203,18 @@ int bfin_internal_set_wake(unsigned int irq, unsigned int state)
204#endif 203#endif
205 204
206static struct irq_chip bfin_core_irqchip = { 205static struct irq_chip bfin_core_irqchip = {
207 .ack = ack_noop, 206 .ack = bfin_ack_noop,
208 .mask = bfin_core_mask_irq, 207 .mask = bfin_core_mask_irq,
209 .unmask = bfin_core_unmask_irq, 208 .unmask = bfin_core_unmask_irq,
210}; 209};
211 210
212static struct irq_chip bfin_internal_irqchip = { 211static struct irq_chip bfin_internal_irqchip = {
213 .ack = ack_noop, 212 .ack = bfin_ack_noop,
214 .mask = bfin_internal_mask_irq, 213 .mask = bfin_internal_mask_irq,
215 .unmask = bfin_internal_unmask_irq, 214 .unmask = bfin_internal_unmask_irq,
215 .mask_ack = bfin_internal_mask_irq,
216 .disable = bfin_internal_mask_irq,
217 .enable = bfin_internal_unmask_irq,
216#ifdef CONFIG_PM 218#ifdef CONFIG_PM
217 .set_wake = bfin_internal_set_wake, 219 .set_wake = bfin_internal_set_wake,
218#endif 220#endif
@@ -221,38 +223,23 @@ static struct irq_chip bfin_internal_irqchip = {
221#ifdef BF537_GENERIC_ERROR_INT_DEMUX 223#ifdef BF537_GENERIC_ERROR_INT_DEMUX
222static int error_int_mask; 224static int error_int_mask;
223 225
224static void bfin_generic_error_ack_irq(unsigned int irq)
225{
226
227}
228
229static void bfin_generic_error_mask_irq(unsigned int irq) 226static void bfin_generic_error_mask_irq(unsigned int irq)
230{ 227{
231 error_int_mask &= ~(1L << (irq - IRQ_PPI_ERROR)); 228 error_int_mask &= ~(1L << (irq - IRQ_PPI_ERROR));
232 229
233 if (!error_int_mask) { 230 if (!error_int_mask)
234 local_irq_disable(); 231 bfin_internal_mask_irq(IRQ_GENERIC_ERROR);
235 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
236 ~(1 << (IRQ_GENERIC_ERROR -
237 (IRQ_CORETMR + 1))));
238 SSYNC();
239 local_irq_enable();
240 }
241} 232}
242 233
243static void bfin_generic_error_unmask_irq(unsigned int irq) 234static void bfin_generic_error_unmask_irq(unsigned int irq)
244{ 235{
245 local_irq_disable(); 236 bfin_internal_unmask_irq(IRQ_GENERIC_ERROR);
246 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 1 <<
247 (IRQ_GENERIC_ERROR - (IRQ_CORETMR + 1)));
248 SSYNC();
249 local_irq_enable();
250
251 error_int_mask |= 1L << (irq - IRQ_PPI_ERROR); 237 error_int_mask |= 1L << (irq - IRQ_PPI_ERROR);
252} 238}
253 239
254static struct irq_chip bfin_generic_error_irqchip = { 240static struct irq_chip bfin_generic_error_irqchip = {
255 .ack = bfin_generic_error_ack_irq, 241 .ack = bfin_ack_noop,
242 .mask_ack = bfin_generic_error_mask_irq,
256 .mask = bfin_generic_error_mask_irq, 243 .mask = bfin_generic_error_mask_irq,
257 .unmask = bfin_generic_error_unmask_irq, 244 .unmask = bfin_generic_error_unmask_irq,
258}; 245};
@@ -608,7 +595,7 @@ static struct pin_int_t *pint[NR_PINT_SYS_IRQS] = {
608 (struct pin_int_t *)PINT3_MASK_SET, 595 (struct pin_int_t *)PINT3_MASK_SET,
609}; 596};
610 597
611unsigned short get_irq_base(u8 bank, u8 bmap) 598inline unsigned short get_irq_base(u8 bank, u8 bmap)
612{ 599{
613 600
614 u16 irq_base; 601 u16 irq_base;
@@ -969,17 +956,12 @@ int __init init_arch_irq(void)
969#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) 956#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
970 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL); 957 bfin_write_SIC_IMASK0(SIC_UNMASK_ALL);
971 bfin_write_SIC_IMASK1(SIC_UNMASK_ALL); 958 bfin_write_SIC_IMASK1(SIC_UNMASK_ALL);
972 bfin_write_SIC_IWR0(IWR_ENABLE_ALL);
973 bfin_write_SIC_IWR1(IWR_ENABLE_ALL);
974# ifdef CONFIG_BF54x 959# ifdef CONFIG_BF54x
975 bfin_write_SIC_IMASK2(SIC_UNMASK_ALL); 960 bfin_write_SIC_IMASK2(SIC_UNMASK_ALL);
976 bfin_write_SIC_IWR2(IWR_ENABLE_ALL);
977# endif 961# endif
978#else 962#else
979 bfin_write_SIC_IMASK(SIC_UNMASK_ALL); 963 bfin_write_SIC_IMASK(SIC_UNMASK_ALL);
980 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
981#endif 964#endif
982 SSYNC();
983 965
984 local_irq_disable(); 966 local_irq_disable();
985 967
@@ -1001,90 +983,53 @@ int __init init_arch_irq(void)
1001 set_irq_chip(irq, &bfin_core_irqchip); 983 set_irq_chip(irq, &bfin_core_irqchip);
1002 else 984 else
1003 set_irq_chip(irq, &bfin_internal_irqchip); 985 set_irq_chip(irq, &bfin_internal_irqchip);
1004#ifdef BF537_GENERIC_ERROR_INT_DEMUX
1005 if (irq != IRQ_GENERIC_ERROR) {
1006#endif
1007 986
1008 switch (irq) { 987 switch (irq) {
1009#if defined(CONFIG_BF53x) 988#if defined(CONFIG_BF53x)
1010 case IRQ_PROG_INTA: 989 case IRQ_PROG_INTA:
1011 set_irq_chained_handler(irq,
1012 bfin_demux_gpio_irq);
1013 break;
1014# if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)) 990# if defined(BF537_FAMILY) && !(defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE))
1015 case IRQ_MAC_RX: 991 case IRQ_MAC_RX:
1016 set_irq_chained_handler(irq,
1017 bfin_demux_gpio_irq);
1018 break;
1019# endif 992# endif
1020#elif defined(CONFIG_BF54x) 993#elif defined(CONFIG_BF54x)
1021 case IRQ_PINT0: 994 case IRQ_PINT0:
1022 set_irq_chained_handler(irq, 995 case IRQ_PINT1:
1023 bfin_demux_gpio_irq); 996 case IRQ_PINT2:
1024 break; 997 case IRQ_PINT3:
1025 case IRQ_PINT1:
1026 set_irq_chained_handler(irq,
1027 bfin_demux_gpio_irq);
1028 break;
1029 case IRQ_PINT2:
1030 set_irq_chained_handler(irq,
1031 bfin_demux_gpio_irq);
1032 break;
1033 case IRQ_PINT3:
1034 set_irq_chained_handler(irq,
1035 bfin_demux_gpio_irq);
1036 break;
1037#elif defined(CONFIG_BF52x) 998#elif defined(CONFIG_BF52x)
1038 case IRQ_PORTF_INTA: 999 case IRQ_PORTF_INTA:
1039 set_irq_chained_handler(irq, 1000 case IRQ_PORTG_INTA:
1040 bfin_demux_gpio_irq); 1001 case IRQ_PORTH_INTA:
1041 break;
1042 case IRQ_PORTG_INTA:
1043 set_irq_chained_handler(irq,
1044 bfin_demux_gpio_irq);
1045 break;
1046 case IRQ_PORTH_INTA:
1047 set_irq_chained_handler(irq,
1048 bfin_demux_gpio_irq);
1049 break;
1050#elif defined(CONFIG_BF561) 1002#elif defined(CONFIG_BF561)
1051 case IRQ_PROG0_INTA: 1003 case IRQ_PROG0_INTA:
1052 set_irq_chained_handler(irq, 1004 case IRQ_PROG1_INTA:
1053 bfin_demux_gpio_irq); 1005 case IRQ_PROG2_INTA:
1054 break;
1055 case IRQ_PROG1_INTA:
1056 set_irq_chained_handler(irq,
1057 bfin_demux_gpio_irq);
1058 break;
1059 case IRQ_PROG2_INTA:
1060 set_irq_chained_handler(irq,
1061 bfin_demux_gpio_irq);
1062 break;
1063#endif 1006#endif
1064 default: 1007 set_irq_chained_handler(irq,
1065 set_irq_handler(irq, handle_simple_irq); 1008 bfin_demux_gpio_irq);
1066 break; 1009 break;
1067 }
1068
1069#ifdef BF537_GENERIC_ERROR_INT_DEMUX 1010#ifdef BF537_GENERIC_ERROR_INT_DEMUX
1070 } else { 1011 case IRQ_GENERIC_ERROR:
1071 set_irq_handler(irq, bfin_demux_error_irq); 1012 set_irq_handler(irq, bfin_demux_error_irq);
1072 } 1013
1014 break;
1073#endif 1015#endif
1016 default:
1017 set_irq_handler(irq, handle_simple_irq);
1018 break;
1019 }
1074 } 1020 }
1021
1075#ifdef BF537_GENERIC_ERROR_INT_DEMUX 1022#ifdef BF537_GENERIC_ERROR_INT_DEMUX
1076 for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++) { 1023 for (irq = IRQ_PPI_ERROR; irq <= IRQ_UART1_ERROR; irq++)
1077 set_irq_chip(irq, &bfin_generic_error_irqchip); 1024 set_irq_chip_and_handler(irq, &bfin_generic_error_irqchip,
1078 set_irq_handler(irq, handle_level_irq); 1025 handle_level_irq);
1079 }
1080#endif 1026#endif
1081 1027
1082 for (irq = GPIO_IRQ_BASE; irq < NR_IRQS; irq++) { 1028 /* if configured as edge, then will be changed to do_edge_IRQ */
1029 for (irq = GPIO_IRQ_BASE; irq < NR_IRQS; irq++)
1030 set_irq_chip_and_handler(irq, &bfin_gpio_irqchip,
1031 handle_level_irq);
1083 1032
1084 set_irq_chip(irq, &bfin_gpio_irqchip);
1085 /* if configured as edge, then will be changed to do_edge_IRQ */
1086 set_irq_handler(irq, handle_level_irq);
1087 }
1088 1033
1089 bfin_write_IMASK(0); 1034 bfin_write_IMASK(0);
1090 CSYNC(); 1035 CSYNC();
@@ -1106,6 +1051,16 @@ int __init init_arch_irq(void)
1106 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | 1051 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
1107 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW; 1052 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
1108 1053
1054#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
1055 bfin_write_SIC_IWR0(IWR_ENABLE_ALL);
1056 bfin_write_SIC_IWR1(IWR_ENABLE_ALL);
1057# ifdef CONFIG_BF54x
1058 bfin_write_SIC_IWR2(IWR_ENABLE_ALL);
1059# endif
1060#else
1061 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
1062#endif
1063
1109 return 0; 1064 return 0;
1110} 1065}
1111 1066
@@ -1122,7 +1077,6 @@ void do_irq(int vec, struct pt_regs *fp)
1122#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561) 1077#if defined(CONFIG_BF54x) || defined(CONFIG_BF52x) || defined(CONFIG_BF561)
1123 unsigned long sic_status[3]; 1078 unsigned long sic_status[3];
1124 1079
1125 SSYNC();
1126 sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0(); 1080 sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0();
1127 sic_status[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1(); 1081 sic_status[1] = bfin_read_SIC_ISR1() & bfin_read_SIC_IMASK1();
1128#ifdef CONFIG_BF54x 1082#ifdef CONFIG_BF54x
@@ -1138,7 +1092,7 @@ void do_irq(int vec, struct pt_regs *fp)
1138 } 1092 }
1139#else 1093#else
1140 unsigned long sic_status; 1094 unsigned long sic_status;
1141 SSYNC(); 1095
1142 sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR(); 1096 sic_status = bfin_read_SIC_IMASK() & bfin_read_SIC_ISR();
1143 1097
1144 for (;; ivg++) { 1098 for (;; ivg++) {
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index 1f516c55bde6..ec3141fefd20 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -181,7 +181,7 @@ void __init mem_init(void)
181 } 181 }
182} 182}
183 183
184static __init void free_init_pages(const char *what, unsigned long begin, unsigned long end) 184static void __init free_init_pages(const char *what, unsigned long begin, unsigned long end)
185{ 185{
186 unsigned long addr; 186 unsigned long addr;
187 /* next to check that the page we free is not a partial page */ 187 /* next to check that the page we free is not a partial page */
@@ -203,7 +203,7 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)
203} 203}
204#endif 204#endif
205 205
206void __init free_initmem(void) 206void __init_refok free_initmem(void)
207{ 207{
208#if defined CONFIG_RAMKERNEL && !defined CONFIG_MPU 208#if defined CONFIG_RAMKERNEL && !defined CONFIG_MPU
209 free_init_pages("unused kernel memory", 209 free_init_pages("unused kernel memory",
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index 13929771bee7..9eed1f68fcab 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -1151,7 +1151,7 @@ static void cell_handle_interrupt(struct pt_regs *regs,
1151 for (i = 0; i < num_counters; ++i) { 1151 for (i = 0; i < num_counters; ++i) {
1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i)) 1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i))
1153 && ctr[i].enabled) { 1153 && ctr[i].enabled) {
1154 oprofile_add_pc(pc, is_kernel, i); 1154 oprofile_add_ext_sample(pc, regs, i, is_kernel);
1155 cbe_write_ctr(cpu, i, reset_value[i]); 1155 cbe_write_ctr(cpu, i, reset_value[i]);
1156 } 1156 }
1157 } 1157 }
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index edab631a8dcb..20ea0e118f24 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -113,7 +113,7 @@
113 113
114/* IOMMU sizing */ 114/* IOMMU sizing */
115#define IO_SEGMENT_SHIFT 28 115#define IO_SEGMENT_SHIFT 28
116#define IO_PAGENO_BITS (IO_SEGMENT_SHIFT - IOMMU_PAGE_SHIFT) 116#define IO_PAGENO_BITS(shift) (IO_SEGMENT_SHIFT - (shift))
117 117
118/* The high bit needs to be set on every DMA address */ 118/* The high bit needs to be set on every DMA address */
119#define SPIDER_DMA_OFFSET 0x80000000ul 119#define SPIDER_DMA_OFFSET 0x80000000ul
@@ -123,7 +123,6 @@ struct iommu_window {
123 struct cbe_iommu *iommu; 123 struct cbe_iommu *iommu;
124 unsigned long offset; 124 unsigned long offset;
125 unsigned long size; 125 unsigned long size;
126 unsigned long pte_offset;
127 unsigned int ioid; 126 unsigned int ioid;
128 struct iommu_table table; 127 struct iommu_table table;
129}; 128};
@@ -200,7 +199,7 @@ static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
200 (window->ioid & IOPTE_IOID_Mask); 199 (window->ioid & IOPTE_IOID_Mask);
201#endif 200#endif
202 201
203 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 202 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
204 203
205 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE) 204 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE)
206 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 205 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask);
@@ -232,7 +231,7 @@ static void tce_free_cell(struct iommu_table *tbl, long index, long npages)
232 | (window->ioid & IOPTE_IOID_Mask); 231 | (window->ioid & IOPTE_IOID_Mask);
233#endif 232#endif
234 233
235 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 234 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
236 235
237 for (i = 0; i < npages; i++) 236 for (i = 0; i < npages; i++)
238 io_pte[i] = pte; 237 io_pte[i] = pte;
@@ -307,76 +306,84 @@ static int cell_iommu_find_ioc(int nid, unsigned long *base)
307 return -ENODEV; 306 return -ENODEV;
308} 307}
309 308
310static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu, 309static void cell_iommu_setup_stab(struct cbe_iommu *iommu,
311 unsigned long dbase, unsigned long dsize, 310 unsigned long dbase, unsigned long dsize,
312 unsigned long fbase, unsigned long fsize) 311 unsigned long fbase, unsigned long fsize)
313{ 312{
314 struct page *page; 313 struct page *page;
315 int i; 314 unsigned long segments, stab_size;
316 unsigned long reg, segments, pages_per_segment, ptab_size, stab_size,
317 n_pte_pages, base;
318
319 base = dbase;
320 if (fsize != 0)
321 base = min(fbase, dbase);
322 315
323 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT; 316 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT;
324 pages_per_segment = 1ull << IO_PAGENO_BITS;
325 317
326 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n", 318 pr_debug("%s: iommu[%d]: segments: %lu\n",
327 __FUNCTION__, iommu->nid, segments, pages_per_segment); 319 __FUNCTION__, iommu->nid, segments);
328 320
329 /* set up the segment table */ 321 /* set up the segment table */
330 stab_size = segments * sizeof(unsigned long); 322 stab_size = segments * sizeof(unsigned long);
331 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size)); 323 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size));
332 BUG_ON(!page); 324 BUG_ON(!page);
333 iommu->stab = page_address(page); 325 iommu->stab = page_address(page);
334 clear_page(iommu->stab); 326 memset(iommu->stab, 0, stab_size);
327}
328
329static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
330 unsigned long base, unsigned long size, unsigned long gap_base,
331 unsigned long gap_size, unsigned long page_shift)
332{
333 struct page *page;
334 int i;
335 unsigned long reg, segments, pages_per_segment, ptab_size,
336 n_pte_pages, start_seg, *ptab;
337
338 start_seg = base >> IO_SEGMENT_SHIFT;
339 segments = size >> IO_SEGMENT_SHIFT;
340 pages_per_segment = 1ull << IO_PAGENO_BITS(page_shift);
341 /* PTEs for each segment must start on a 4K bounday */
342 pages_per_segment = max(pages_per_segment,
343 (1 << 12) / sizeof(unsigned long));
335 344
336 /* ... and the page tables. Since these are contiguous, we can treat
337 * the page tables as one array of ptes, like pSeries does.
338 */
339 ptab_size = segments * pages_per_segment * sizeof(unsigned long); 345 ptab_size = segments * pages_per_segment * sizeof(unsigned long);
340 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__, 346 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__,
341 iommu->nid, ptab_size, get_order(ptab_size)); 347 iommu->nid, ptab_size, get_order(ptab_size));
342 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size)); 348 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size));
343 BUG_ON(!page); 349 BUG_ON(!page);
344 350
345 iommu->ptab = page_address(page); 351 ptab = page_address(page);
346 memset(iommu->ptab, 0, ptab_size); 352 memset(ptab, 0, ptab_size);
347 353
348 /* allocate a bogus page for the end of each mapping */ 354 /* number of 4K pages needed for a page table */
349 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0); 355 n_pte_pages = (pages_per_segment * sizeof(unsigned long)) >> 12;
350 BUG_ON(!page);
351 iommu->pad_page = page_address(page);
352 clear_page(iommu->pad_page);
353
354 /* number of pages needed for a page table */
355 n_pte_pages = (pages_per_segment *
356 sizeof(unsigned long)) >> IOMMU_PAGE_SHIFT;
357 356
358 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n", 357 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n",
359 __FUNCTION__, iommu->nid, iommu->stab, iommu->ptab, 358 __FUNCTION__, iommu->nid, iommu->stab, ptab,
360 n_pte_pages); 359 n_pte_pages);
361 360
362 /* initialise the STEs */ 361 /* initialise the STEs */
363 reg = IOSTE_V | ((n_pte_pages - 1) << 5); 362 reg = IOSTE_V | ((n_pte_pages - 1) << 5);
364 363
365 if (IOMMU_PAGE_SIZE == 0x1000) 364 switch (page_shift) {
366 reg |= IOSTE_PS_4K; 365 case 12: reg |= IOSTE_PS_4K; break;
367 else if (IOMMU_PAGE_SIZE == 0x10000) 366 case 16: reg |= IOSTE_PS_64K; break;
368 reg |= IOSTE_PS_64K; 367 case 20: reg |= IOSTE_PS_1M; break;
369 else { 368 case 24: reg |= IOSTE_PS_16M; break;
370 extern void __unknown_page_size_error(void); 369 default: BUG();
371 __unknown_page_size_error();
372 } 370 }
373 371
372 gap_base = gap_base >> IO_SEGMENT_SHIFT;
373 gap_size = gap_size >> IO_SEGMENT_SHIFT;
374
374 pr_debug("Setting up IOMMU stab:\n"); 375 pr_debug("Setting up IOMMU stab:\n");
375 for (i = base >> IO_SEGMENT_SHIFT; i < segments; i++) { 376 for (i = start_seg; i < (start_seg + segments); i++) {
376 iommu->stab[i] = reg | 377 if (i >= gap_base && i < (gap_base + gap_size)) {
377 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i); 378 pr_debug("\toverlap at %d, skipping\n", i);
379 continue;
380 }
381 iommu->stab[i] = reg | (__pa(ptab) + (n_pte_pages << 12) *
382 (i - start_seg));
378 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]); 383 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]);
379 } 384 }
385
386 return ptab;
380} 387}
381 388
382static void cell_iommu_enable_hardware(struct cbe_iommu *iommu) 389static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
@@ -423,7 +430,9 @@ static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
423static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, 430static void cell_iommu_setup_hardware(struct cbe_iommu *iommu,
424 unsigned long base, unsigned long size) 431 unsigned long base, unsigned long size)
425{ 432{
426 cell_iommu_setup_page_tables(iommu, base, size, 0, 0); 433 cell_iommu_setup_stab(iommu, base, size, 0, 0);
434 iommu->ptab = cell_iommu_alloc_ptab(iommu, base, size, 0, 0,
435 IOMMU_PAGE_SHIFT);
427 cell_iommu_enable_hardware(iommu); 436 cell_iommu_enable_hardware(iommu);
428} 437}
429 438
@@ -464,6 +473,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
464 unsigned long pte_offset) 473 unsigned long pte_offset)
465{ 474{
466 struct iommu_window *window; 475 struct iommu_window *window;
476 struct page *page;
467 u32 ioid; 477 u32 ioid;
468 478
469 ioid = cell_iommu_get_ioid(np); 479 ioid = cell_iommu_get_ioid(np);
@@ -475,13 +485,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
475 window->size = size; 485 window->size = size;
476 window->ioid = ioid; 486 window->ioid = ioid;
477 window->iommu = iommu; 487 window->iommu = iommu;
478 window->pte_offset = pte_offset;
479 488
480 window->table.it_blocksize = 16; 489 window->table.it_blocksize = 16;
481 window->table.it_base = (unsigned long)iommu->ptab; 490 window->table.it_base = (unsigned long)iommu->ptab;
482 window->table.it_index = iommu->nid; 491 window->table.it_index = iommu->nid;
483 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + 492 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + pte_offset;
484 window->pte_offset;
485 window->table.it_size = size >> IOMMU_PAGE_SHIFT; 493 window->table.it_size = size >> IOMMU_PAGE_SHIFT;
486 494
487 iommu_init_table(&window->table, iommu->nid); 495 iommu_init_table(&window->table, iommu->nid);
@@ -504,6 +512,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
504 * This code also assumes that we have a window that starts at 0, 512 * This code also assumes that we have a window that starts at 0,
505 * which is the case on all spider based blades. 513 * which is the case on all spider based blades.
506 */ 514 */
515 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0);
516 BUG_ON(!page);
517 iommu->pad_page = page_address(page);
518 clear_page(iommu->pad_page);
519
507 __set_bit(0, window->table.it_map); 520 __set_bit(0, window->table.it_map);
508 tce_build_cell(&window->table, window->table.it_offset, 1, 521 tce_build_cell(&window->table, window->table.it_offset, 1,
509 (unsigned long)iommu->pad_page, DMA_TO_DEVICE); 522 (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
@@ -549,7 +562,7 @@ static void cell_dma_dev_setup_iommu(struct device *dev)
549 archdata->dma_data = &window->table; 562 archdata->dma_data = &window->table;
550} 563}
551 564
552static void cell_dma_dev_setup_static(struct device *dev); 565static void cell_dma_dev_setup_fixed(struct device *dev);
553 566
554static void cell_dma_dev_setup(struct device *dev) 567static void cell_dma_dev_setup(struct device *dev)
555{ 568{
@@ -557,7 +570,7 @@ static void cell_dma_dev_setup(struct device *dev)
557 570
558 /* Order is important here, these are not mutually exclusive */ 571 /* Order is important here, these are not mutually exclusive */
559 if (get_dma_ops(dev) == &dma_iommu_fixed_ops) 572 if (get_dma_ops(dev) == &dma_iommu_fixed_ops)
560 cell_dma_dev_setup_static(dev); 573 cell_dma_dev_setup_fixed(dev);
561 else if (get_pci_dma_ops() == &dma_iommu_ops) 574 else if (get_pci_dma_ops() == &dma_iommu_ops)
562 cell_dma_dev_setup_iommu(dev); 575 cell_dma_dev_setup_iommu(dev);
563 else if (get_pci_dma_ops() == &dma_direct_ops) 576 else if (get_pci_dma_ops() == &dma_direct_ops)
@@ -858,7 +871,7 @@ static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask)
858 return 0; 871 return 0;
859} 872}
860 873
861static void cell_dma_dev_setup_static(struct device *dev) 874static void cell_dma_dev_setup_fixed(struct device *dev)
862{ 875{
863 struct dev_archdata *archdata = &dev->archdata; 876 struct dev_archdata *archdata = &dev->archdata;
864 u64 addr; 877 u64 addr;
@@ -869,35 +882,45 @@ static void cell_dma_dev_setup_static(struct device *dev)
869 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr); 882 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr);
870} 883}
871 884
885static void insert_16M_pte(unsigned long addr, unsigned long *ptab,
886 unsigned long base_pte)
887{
888 unsigned long segment, offset;
889
890 segment = addr >> IO_SEGMENT_SHIFT;
891 offset = (addr >> 24) - (segment << IO_PAGENO_BITS(24));
892 ptab = ptab + (segment * (1 << 12) / sizeof(unsigned long));
893
894 pr_debug("iommu: addr %lx ptab %p segment %lx offset %lx\n",
895 addr, ptab, segment, offset);
896
897 ptab[offset] = base_pte | (__pa(addr) & IOPTE_RPN_Mask);
898}
899
872static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu, 900static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu,
873 struct device_node *np, unsigned long dbase, unsigned long dsize, 901 struct device_node *np, unsigned long dbase, unsigned long dsize,
874 unsigned long fbase, unsigned long fsize) 902 unsigned long fbase, unsigned long fsize)
875{ 903{
876 unsigned long base_pte, uaddr, *io_pte; 904 unsigned long base_pte, uaddr, ioaddr, *ptab;
877 int i;
878 905
879 dma_iommu_fixed_base = fbase; 906 ptab = cell_iommu_alloc_ptab(iommu, fbase, fsize, dbase, dsize, 24);
880 907
881 /* convert from bytes into page table indices */ 908 dma_iommu_fixed_base = fbase;
882 dbase = dbase >> IOMMU_PAGE_SHIFT;
883 dsize = dsize >> IOMMU_PAGE_SHIFT;
884 fbase = fbase >> IOMMU_PAGE_SHIFT;
885 fsize = fsize >> IOMMU_PAGE_SHIFT;
886 909
887 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase); 910 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase);
888 911
889 io_pte = iommu->ptab;
890 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW 912 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW
891 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask); 913 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask);
892 914
893 uaddr = 0; 915 for (uaddr = 0; uaddr < fsize; uaddr += (1 << 24)) {
894 for (i = fbase; i < fbase + fsize; i++, uaddr += IOMMU_PAGE_SIZE) {
895 /* Don't touch the dynamic region */ 916 /* Don't touch the dynamic region */
896 if (i >= dbase && i < (dbase + dsize)) { 917 ioaddr = uaddr + fbase;
897 pr_debug("iommu: static/dynamic overlap, skipping\n"); 918 if (ioaddr >= dbase && ioaddr < (dbase + dsize)) {
919 pr_debug("iommu: fixed/dynamic overlap, skipping\n");
898 continue; 920 continue;
899 } 921 }
900 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 922
923 insert_16M_pte(uaddr, ptab, base_pte);
901 } 924 }
902 925
903 mb(); 926 mb();
@@ -995,7 +1018,9 @@ static int __init cell_iommu_fixed_mapping_init(void)
995 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase, 1018 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase,
996 dbase + dsize, fbase, fbase + fsize); 1019 dbase + dsize, fbase, fbase + fsize);
997 1020
998 cell_iommu_setup_page_tables(iommu, dbase, dsize, fbase, fsize); 1021 cell_iommu_setup_stab(iommu, dbase, dsize, fbase, fsize);
1022 iommu->ptab = cell_iommu_alloc_ptab(iommu, dbase, dsize, 0, 0,
1023 IOMMU_PAGE_SHIFT);
999 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize, 1024 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize,
1000 fbase, fsize); 1025 fbase, fsize);
1001 cell_iommu_enable_hardware(iommu); 1026 cell_iommu_enable_hardware(iommu);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index a7f609b3b876..dda34650cb07 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -149,6 +149,11 @@ static void __init cell_init_irq(void)
149 mpic_init_IRQ(); 149 mpic_init_IRQ();
150} 150}
151 151
152static void __init cell_set_dabrx(void)
153{
154 mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER);
155}
156
152static void __init cell_setup_arch(void) 157static void __init cell_setup_arch(void)
153{ 158{
154#ifdef CONFIG_SPU_BASE 159#ifdef CONFIG_SPU_BASE
@@ -158,6 +163,8 @@ static void __init cell_setup_arch(void)
158 163
159 cbe_regs_init(); 164 cbe_regs_init();
160 165
166 cell_set_dabrx();
167
161#ifdef CONFIG_CBE_RAS 168#ifdef CONFIG_CBE_RAS
162 cbe_ras_init(); 169 cbe_ras_init();
163#endif 170#endif
diff --git a/arch/powerpc/platforms/celleb/beat.h b/arch/powerpc/platforms/celleb/beat.h
index b2e292df13ca..ac82ac35b991 100644
--- a/arch/powerpc/platforms/celleb/beat.h
+++ b/arch/powerpc/platforms/celleb/beat.h
@@ -21,9 +21,6 @@
21#ifndef _CELLEB_BEAT_H 21#ifndef _CELLEB_BEAT_H
22#define _CELLEB_BEAT_H 22#define _CELLEB_BEAT_H
23 23
24#define DABRX_KERNEL (1UL<<1)
25#define DABRX_USER (1UL<<0)
26
27int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*); 24int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*);
28int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t); 25int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t);
29int64_t beat_repository_encode(int, const char *, uint64_t[4]); 26int64_t beat_repository_encode(int, const char *, uint64_t[4]);
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index b3400b5ad5c6..783cfbbf87ca 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -330,6 +330,7 @@ config CPU_SUBTYPE_SH5_101
330 330
331config CPU_SUBTYPE_SH5_103 331config CPU_SUBTYPE_SH5_103
332 bool "Support SH5-103 processor" 332 bool "Support SH5-103 processor"
333 select CPU_SH5
333 334
334endchoice 335endchoice
335 336
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 5c3359756a92..71ff3d6f26e2 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -90,7 +90,7 @@ static irqreturn_t dma_tei(int irq, void *dev_id)
90 90
91static int sh_dmac_request_dma(struct dma_channel *chan) 91static int sh_dmac_request_dma(struct dma_channel *chan)
92{ 92{
93 if (unlikely(!chan->flags & DMA_TEI_CAPABLE)) 93 if (unlikely(!(chan->flags & DMA_TEI_CAPABLE)))
94 return 0; 94 return 0;
95 95
96 return request_irq(get_dmte_irq(chan->chan), dma_tei, 96 return request_irq(get_dmte_irq(chan->chan), dma_tei,
diff --git a/arch/sh/drivers/heartbeat.c b/arch/sh/drivers/heartbeat.c
index b76a14f12ce2..ab77b0e0fa0e 100644
--- a/arch/sh/drivers/heartbeat.c
+++ b/arch/sh/drivers/heartbeat.c
@@ -93,7 +93,7 @@ static int heartbeat_drv_probe(struct platform_device *pdev)
93 } 93 }
94 94
95 hd->base = ioremap_nocache(res->start, res->end - res->start + 1); 95 hd->base = ioremap_nocache(res->start, res->end - res->start + 1);
96 if (!unlikely(hd->base)) { 96 if (unlikely(!hd->base)) {
97 dev_err(&pdev->dev, "ioremap failed\n"); 97 dev_err(&pdev->dev, "ioremap failed\n");
98 98
99 if (!pdev->dev.platform_data) 99 if (!pdev->dev.platform_data)
diff --git a/arch/sh/drivers/pci/ops-dreamcast.c b/arch/sh/drivers/pci/ops-dreamcast.c
index 0dac87b19624..e1284fc69361 100644
--- a/arch/sh/drivers/pci/ops-dreamcast.c
+++ b/arch/sh/drivers/pci/ops-dreamcast.c
@@ -83,9 +83,9 @@ static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int
83 return PCIBIOS_DEVICE_NOT_FOUND; 83 return PCIBIOS_DEVICE_NOT_FOUND;
84 84
85 switch (size) { 85 switch (size) {
86 case 1: *val = ctrl_inb(GAPSPCI_BBA_CONFIG+where); break; 86 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;
87 case 2: *val = ctrl_inw(GAPSPCI_BBA_CONFIG+where); break; 87 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;
88 case 4: *val = ctrl_inl(GAPSPCI_BBA_CONFIG+where); break; 88 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;
89 } 89 }
90 90
91 return PCIBIOS_SUCCESSFUL; 91 return PCIBIOS_SUCCESSFUL;
@@ -97,9 +97,9 @@ static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int
97 return PCIBIOS_DEVICE_NOT_FOUND; 97 return PCIBIOS_DEVICE_NOT_FOUND;
98 98
99 switch (size) { 99 switch (size) {
100 case 1: ctrl_outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break; 100 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
101 case 2: ctrl_outw((u16)val, GAPSPCI_BBA_CONFIG+where); break; 101 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
102 case 4: ctrl_outl((u32)val, GAPSPCI_BBA_CONFIG+where); break; 102 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
103 } 103 }
104 104
105 return PCIBIOS_SUCCESSFUL; 105 return PCIBIOS_SUCCESSFUL;
@@ -127,36 +127,36 @@ int __init gapspci_init(void)
127 */ 127 */
128 128
129 for (i=0; i<16; i++) 129 for (i=0; i<16; i++)
130 idbuf[i] = ctrl_inb(GAPSPCI_REGS+i); 130 idbuf[i] = inb(GAPSPCI_REGS+i);
131 131
132 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16)) 132 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
133 return -ENODEV; 133 return -ENODEV;
134 134
135 ctrl_outl(0x5a14a501, GAPSPCI_REGS+0x18); 135 outl(0x5a14a501, GAPSPCI_REGS+0x18);
136 136
137 for (i=0; i<1000000; i++) 137 for (i=0; i<1000000; i++)
138 ; 138 ;
139 139
140 if (ctrl_inl(GAPSPCI_REGS+0x18) != 1) 140 if (inl(GAPSPCI_REGS+0x18) != 1)
141 return -EINVAL; 141 return -EINVAL;
142 142
143 ctrl_outl(0x01000000, GAPSPCI_REGS+0x20); 143 outl(0x01000000, GAPSPCI_REGS+0x20);
144 ctrl_outl(0x01000000, GAPSPCI_REGS+0x24); 144 outl(0x01000000, GAPSPCI_REGS+0x24);
145 145
146 ctrl_outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28); 146 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
147 ctrl_outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c); 147 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
148 148
149 ctrl_outl(1, GAPSPCI_REGS+0x14); 149 outl(1, GAPSPCI_REGS+0x14);
150 ctrl_outl(1, GAPSPCI_REGS+0x34); 150 outl(1, GAPSPCI_REGS+0x34);
151 151
152 /* Setting Broadband Adapter */ 152 /* Setting Broadband Adapter */
153 ctrl_outw(0xf900, GAPSPCI_BBA_CONFIG+0x06); 153 outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
154 ctrl_outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30); 154 outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
155 ctrl_outb(0x00, GAPSPCI_BBA_CONFIG+0x3c); 155 outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
156 ctrl_outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d); 156 outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
157 ctrl_outw(0x0006, GAPSPCI_BBA_CONFIG+0x04); 157 outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
158 ctrl_outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10); 158 outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
159 ctrl_outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14); 159 outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
160 160
161 return 0; 161 return 0;
162} 162}
diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
index b230eb278cef..cc530f4d84d6 100644
--- a/arch/sh/kernel/cpu/sh2/setup-sh7619.c
+++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15enum { 15enum {
16 UNUSED = 0, 16 UNUSED = 0,
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7203.c b/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
index 3feb95a4fcbc..fb781329848a 100644
--- a/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
@@ -21,8 +21,8 @@
21#include <asm/freq.h> 21#include <asm/freq.h>
22#include <asm/io.h> 22#include <asm/io.h>
23 23
24const static int pll1rate[]={8,12,16,0}; 24static const int pll1rate[]={8,12,16,0};
25const static int pfc_divisors[]={1,2,3,4,6,8,12}; 25static const int pfc_divisors[]={1,2,3,4,6,8,12};
26#define ifc_divisors pfc_divisors 26#define ifc_divisors pfc_divisors
27 27
28#if (CONFIG_SH_CLK_MD == 0) 28#if (CONFIG_SH_CLK_MD == 0)
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
index db6ef5cecde1..e98dc4450352 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15enum { 15enum {
16 UNUSED = 0, 16 UNUSED = 0,
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
index a564425b905f..e6d4ec445dd8 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15enum { 15enum {
16 UNUSED = 0, 16 UNUSED = 0,
diff --git a/arch/sh/kernel/cpu/sh3/probe.c b/arch/sh/kernel/cpu/sh3/probe.c
index fcc80bb7bee7..10f2a760c5ee 100644
--- a/arch/sh/kernel/cpu/sh3/probe.c
+++ b/arch/sh/kernel/cpu/sh3/probe.c
@@ -94,9 +94,9 @@ int __uses_jump_to_uncached detect_cpu_and_cache_system(void)
94 boot_cpu_data.dcache.way_incr = (1 << 13); 94 boot_cpu_data.dcache.way_incr = (1 << 13);
95 boot_cpu_data.dcache.entry_mask = 0x1ff0; 95 boot_cpu_data.dcache.entry_mask = 0x1ff0;
96 boot_cpu_data.dcache.sets = 512; 96 boot_cpu_data.dcache.sets = 512;
97 ctrl_outl(CCR_CACHE_32KB, CCR3); 97 ctrl_outl(CCR_CACHE_32KB, CCR3_REG);
98#else 98#else
99 ctrl_outl(CCR_CACHE_16KB, CCR3); 99 ctrl_outl(CCR_CACHE_16KB, CCR3_REG);
100#endif 100#endif
101#endif 101#endif
102 } 102 }
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7705.c b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
index dd0a20a685f7..f581534cb732 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7705.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <asm/sci.h> 15#include <linux/serial_sci.h>
16#include <asm/rtc.h> 16#include <asm/rtc.h>
17 17
18enum { 18enum {
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
index 969804bb523b..d3733b13ea52 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -16,7 +16,7 @@
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/serial.h> 18#include <linux/serial.h>
19#include <asm/sci.h> 19#include <linux/serial_sci.h>
20 20
21enum { 21enum {
22 UNUSED = 0, 22 UNUSED = 0,
@@ -123,15 +123,15 @@ static struct resource rtc_resources[] = {
123 .flags = IORESOURCE_IO, 123 .flags = IORESOURCE_IO,
124 }, 124 },
125 [1] = { 125 [1] = {
126 .start = 20, 126 .start = 21,
127 .flags = IORESOURCE_IRQ, 127 .flags = IORESOURCE_IRQ,
128 }, 128 },
129 [2] = { 129 [2] = {
130 .start = 21, 130 .start = 22,
131 .flags = IORESOURCE_IRQ, 131 .flags = IORESOURCE_IRQ,
132 }, 132 },
133 [3] = { 133 [3] = {
134 .start = 22, 134 .start = 20,
135 .flags = IORESOURCE_IRQ, 135 .flags = IORESOURCE_IRQ,
136 }, 136 },
137}; 137};
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7710.c b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
index 0cc0e2bf135d..7406c9ad9259 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7710.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <asm/sci.h> 15#include <linux/serial_sci.h>
16#include <asm/rtc.h> 16#include <asm/rtc.h>
17 17
18enum { 18enum {
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
index 3855ea4c21c8..8028082527c5 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
@@ -16,7 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/serial.h> 17#include <linux/serial.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <asm/sci.h> 19#include <linux/serial_sci.h>
20#include <asm/rtc.h> 20#include <asm/rtc.h>
21 21
22#define INTC_ICR1 0xA4140010UL 22#define INTC_ICR1 0xA4140010UL
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
index dab193293f20..7371abf64f80 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15static struct plat_sci_port sci_platform_data[] = { 15static struct plat_sci_port sci_platform_data[] = {
16 { 16 {
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
index ae3603aca615..ec884039b914 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/serial.h> 13#include <linux/serial.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <asm/sci.h> 15#include <linux/serial_sci.h>
16 16
17static struct resource rtc_resources[] = { 17static struct resource rtc_resources[] = {
18 [0] = { 18 [0] = {
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
index 85f81579b97e..254c5c55ab91 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15enum { 15enum {
16 UNUSED = 0, 16 UNUSED = 0,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
index c0a3f079dfdc..6d4f50cd4aaf 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15static struct plat_sci_port sci_platform_data[] = { 15static struct plat_sci_port sci_platform_data[] = {
16 { 16 {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
index 967e8b69a2f8..f26b5cdad0d1 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
@@ -12,7 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <asm/sci.h> 15#include <linux/serial_sci.h>
16 16
17static struct plat_sci_port sci_platform_data[] = { 17static struct plat_sci_port sci_platform_data[] = {
18 { 18 {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index 73c778d40d13..b98b4bc93ec9 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -10,9 +10,9 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h>
13#include <linux/mm.h> 14#include <linux/mm.h>
14#include <asm/mmzone.h> 15#include <asm/mmzone.h>
15#include <asm/sci.h>
16 16
17static struct resource usbf_resources[] = { 17static struct resource usbf_resources[] = {
18 [0] = { 18 [0] = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
index eabd5386812d..07c988dc9de6 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/serial.h> 13#include <linux/serial.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <asm/sci.h> 15#include <linux/serial_sci.h>
16 16
17static struct resource rtc_resources[] = { 17static struct resource rtc_resources[] = {
18 [0] = { 18 [0] = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
index 32f4f59a837b..b9cec48b1808 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <asm/sci.h> 13#include <linux/serial_sci.h>
14 14
15static struct plat_sci_port sci_platform_data[] = { 15static struct plat_sci_port sci_platform_data[] = {
16 { 16 {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
index 293004b526ff..18dbbe23fea1 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
@@ -11,7 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <asm/sci.h> 14#include <linux/serial_sci.h>
15 15
16static struct resource rtc_resources[] = { 16static struct resource rtc_resources[] = {
17 [0] = { 17 [0] = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
index 74b60e96cdf4..621e7329ec63 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
@@ -10,10 +10,10 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h>
13#include <linux/io.h> 14#include <linux/io.h>
14#include <linux/mm.h> 15#include <linux/mm.h>
15#include <asm/mmzone.h> 16#include <asm/mmzone.h>
16#include <asm/sci.h>
17 17
18static struct plat_sci_port sci_platform_data[] = { 18static struct plat_sci_port sci_platform_data[] = {
19 { 19 {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-shx3.c b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
index 4dc958b6b314..bd35f32534b9 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
@@ -10,9 +10,9 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h>
13#include <linux/io.h> 14#include <linux/io.h>
14#include <asm/mmzone.h> 15#include <asm/mmzone.h>
15#include <asm/sci.h>
16 16
17static struct plat_sci_port sci_platform_data[] = { 17static struct plat_sci_port sci_platform_data[] = {
18 { 18 {
diff --git a/arch/sparc/kernel/led.c b/arch/sparc/kernel/led.c
index 313d1620ae8e..59e9344e7a0d 100644
--- a/arch/sparc/kernel/led.c
+++ b/arch/sparc/kernel/led.c
@@ -3,6 +3,9 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/proc_fs.h> 4#include <linux/proc_fs.h>
5#include <linux/string.h> 5#include <linux/string.h>
6#include <linux/jiffies.h>
7#include <linux/timer.h>
8#include <linux/uaccess.h>
6 9
7#include <asm/auxio.h> 10#include <asm/auxio.h>
8 11
diff --git a/arch/sparc64/kernel/ds.c b/arch/sparc64/kernel/ds.c
index eeb5a2fc788d..bd76482077be 100644
--- a/arch/sparc64/kernel/ds.c
+++ b/arch/sparc64/kernel/ds.c
@@ -525,10 +525,10 @@ static void dr_cpu_mark(struct ds_data *resp, int cpu, int ncpus,
525 } 525 }
526} 526}
527 527
528static int dr_cpu_configure(struct ds_info *dp, 528static int __cpuinit dr_cpu_configure(struct ds_info *dp,
529 struct ds_cap_state *cp, 529 struct ds_cap_state *cp,
530 u64 req_num, 530 u64 req_num,
531 cpumask_t *mask) 531 cpumask_t *mask)
532{ 532{
533 struct ds_data *resp; 533 struct ds_data *resp;
534 int resp_len, ncpus, cpu; 534 int resp_len, ncpus, cpu;
@@ -623,9 +623,9 @@ static int dr_cpu_unconfigure(struct ds_info *dp,
623 return 0; 623 return 0;
624} 624}
625 625
626static void dr_cpu_data(struct ds_info *dp, 626static void __cpuinit dr_cpu_data(struct ds_info *dp,
627 struct ds_cap_state *cp, 627 struct ds_cap_state *cp,
628 void *buf, int len) 628 void *buf, int len)
629{ 629{
630 struct ds_data *data = buf; 630 struct ds_data *data = buf;
631 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1); 631 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1);
diff --git a/arch/sparc64/kernel/hvtramp.S b/arch/sparc64/kernel/hvtramp.S
index b692e044a463..0236c43772fa 100644
--- a/arch/sparc64/kernel/hvtramp.S
+++ b/arch/sparc64/kernel/hvtramp.S
@@ -3,6 +3,8 @@
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net> 3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */ 4 */
5 5
6#include <linux/init.h>
7
6#include <asm/thread_info.h> 8#include <asm/thread_info.h>
7#include <asm/hypervisor.h> 9#include <asm/hypervisor.h>
8#include <asm/scratchpad.h> 10#include <asm/scratchpad.h>
@@ -13,7 +15,7 @@
13#include <asm/head.h> 15#include <asm/head.h>
14#include <asm/asi.h> 16#include <asm/asi.h>
15 17
16 .text 18 __CPUINIT
17 .align 8 19 .align 8
18 .globl hv_cpu_startup, hv_cpu_startup_end 20 .globl hv_cpu_startup, hv_cpu_startup_end
19 21
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index 0e347ff812a3..fbaab3497bfd 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -134,7 +134,8 @@ unsigned long iommu_range_alloc(struct device *dev,
134 else 134 else
135 boundary_size = ALIGN(1UL << 32, 1 << IO_PAGE_SHIFT); 135 boundary_size = ALIGN(1UL << 32, 1 << IO_PAGE_SHIFT);
136 136
137 n = iommu_area_alloc(arena->map, limit, start, npages, 0, 137 n = iommu_area_alloc(arena->map, limit, start, npages,
138 iommu->page_table_map_base >> IO_PAGE_SHIFT,
138 boundary_size >> IO_PAGE_SHIFT, 0); 139 boundary_size >> IO_PAGE_SHIFT, 0);
139 if (n == -1) { 140 if (n == -1) {
140 if (likely(pass < 1)) { 141 if (likely(pass < 1)) {
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index 34fc3ddd5002..f43b5d755354 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -465,8 +465,6 @@ void __kprobes jprobe_return(void)
465 465
466extern void jprobe_return_trap_instruction(void); 466extern void jprobe_return_trap_instruction(void);
467 467
468extern void __show_regs(struct pt_regs * regs);
469
470int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) 468int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
471{ 469{
472 u32 *addr = (u32 *) regs->tpc; 470 u32 *addr = (u32 *) regs->tpc;
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
index 856659bb1311..910083589569 100644
--- a/arch/sparc64/kernel/mdesc.c
+++ b/arch/sparc64/kernel/mdesc.c
@@ -758,7 +758,7 @@ static void __devinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
758 get_one_mondo_bits(val, &tb->nonresum_qmask, 2); 758 get_one_mondo_bits(val, &tb->nonresum_qmask, 2);
759} 759}
760 760
761void __devinit mdesc_fill_in_cpu_data(cpumask_t mask) 761void __cpuinit mdesc_fill_in_cpu_data(cpumask_t mask)
762{ 762{
763 struct mdesc_handle *hp = mdesc_grab(); 763 struct mdesc_handle *hp = mdesc_grab();
764 u64 mp; 764 u64 mp;
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
index 850cdffdd69c..eae8ca2a6ba5 100644
--- a/arch/sparc64/kernel/power.c
+++ b/arch/sparc64/kernel/power.c
@@ -20,6 +20,7 @@
20#include <asm/of_device.h> 20#include <asm/of_device.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/sstate.h> 22#include <asm/sstate.h>
23#include <asm/reboot.h>
23 24
24#include <linux/unistd.h> 25#include <linux/unistd.h>
25 26
@@ -39,8 +40,6 @@ static irqreturn_t power_handler(int irq, void *dev_id)
39 return IRQ_HANDLED; 40 return IRQ_HANDLED;
40} 41}
41 42
42extern void machine_halt(void);
43extern void machine_alt_power_off(void);
44static void (*poweroff_method)(void) = machine_alt_power_off; 43static void (*poweroff_method)(void) = machine_alt_power_off;
45 44
46void machine_power_off(void) 45void machine_power_off(void)
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 6eceac51ae62..2aafce7dfc0e 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -30,6 +30,7 @@
30#include <linux/tick.h> 30#include <linux/tick.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpu.h> 32#include <linux/cpu.h>
33#include <linux/elfcore.h>
33 34
34#include <asm/oplib.h> 35#include <asm/oplib.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
@@ -47,6 +48,8 @@
47#include <asm/unistd.h> 48#include <asm/unistd.h>
48#include <asm/hypervisor.h> 49#include <asm/hypervisor.h>
49#include <asm/sstate.h> 50#include <asm/sstate.h>
51#include <asm/reboot.h>
52#include <asm/syscalls.h>
50 53
51/* #define VERBOSE_SHOWREGS */ 54/* #define VERBOSE_SHOWREGS */
52 55
@@ -211,62 +214,6 @@ static void show_regwindow(struct pt_regs *regs)
211 print_symbol("I7: <%s>\n", rwk->ins[7]); 214 print_symbol("I7: <%s>\n", rwk->ins[7]);
212} 215}
213 216
214void show_stackframe(struct sparc_stackf *sf)
215{
216 unsigned long size;
217 unsigned long *stk;
218 int i;
219
220 printk("l0: %016lx l1: %016lx l2: %016lx l3: %016lx\n"
221 "l4: %016lx l5: %016lx l6: %016lx l7: %016lx\n",
222 sf->locals[0], sf->locals[1], sf->locals[2], sf->locals[3],
223 sf->locals[4], sf->locals[5], sf->locals[6], sf->locals[7]);
224 printk("i0: %016lx i1: %016lx i2: %016lx i3: %016lx\n"
225 "i4: %016lx i5: %016lx fp: %016lx ret_pc: %016lx\n",
226 sf->ins[0], sf->ins[1], sf->ins[2], sf->ins[3],
227 sf->ins[4], sf->ins[5], (unsigned long)sf->fp, sf->callers_pc);
228 printk("sp: %016lx x0: %016lx x1: %016lx x2: %016lx\n"
229 "x3: %016lx x4: %016lx x5: %016lx xx: %016lx\n",
230 (unsigned long)sf->structptr, sf->xargs[0], sf->xargs[1],
231 sf->xargs[2], sf->xargs[3], sf->xargs[4], sf->xargs[5],
232 sf->xxargs[0]);
233 size = ((unsigned long)sf->fp) - ((unsigned long)sf);
234 size -= STACKFRAME_SZ;
235 stk = (unsigned long *)((unsigned long)sf + STACKFRAME_SZ);
236 i = 0;
237 do {
238 printk("s%d: %016lx\n", i++, *stk++);
239 } while ((size -= sizeof(unsigned long)));
240}
241
242void show_stackframe32(struct sparc_stackf32 *sf)
243{
244 unsigned long size;
245 unsigned *stk;
246 int i;
247
248 printk("l0: %08x l1: %08x l2: %08x l3: %08x\n",
249 sf->locals[0], sf->locals[1], sf->locals[2], sf->locals[3]);
250 printk("l4: %08x l5: %08x l6: %08x l7: %08x\n",
251 sf->locals[4], sf->locals[5], sf->locals[6], sf->locals[7]);
252 printk("i0: %08x i1: %08x i2: %08x i3: %08x\n",
253 sf->ins[0], sf->ins[1], sf->ins[2], sf->ins[3]);
254 printk("i4: %08x i5: %08x fp: %08x ret_pc: %08x\n",
255 sf->ins[4], sf->ins[5], sf->fp, sf->callers_pc);
256 printk("sp: %08x x0: %08x x1: %08x x2: %08x\n"
257 "x3: %08x x4: %08x x5: %08x xx: %08x\n",
258 sf->structptr, sf->xargs[0], sf->xargs[1],
259 sf->xargs[2], sf->xargs[3], sf->xargs[4], sf->xargs[5],
260 sf->xxargs[0]);
261 size = ((unsigned long)sf->fp) - ((unsigned long)sf);
262 size -= STACKFRAME32_SZ;
263 stk = (unsigned *)((unsigned long)sf + STACKFRAME32_SZ);
264 i = 0;
265 do {
266 printk("s%d: %08x\n", i++, *stk++);
267 } while ((size -= sizeof(unsigned)));
268}
269
270#ifdef CONFIG_SMP 217#ifdef CONFIG_SMP
271static DEFINE_SPINLOCK(regdump_lock); 218static DEFINE_SPINLOCK(regdump_lock);
272#endif 219#endif
@@ -354,24 +301,6 @@ void show_regs(struct pt_regs *regs)
354#endif 301#endif
355} 302}
356 303
357void show_regs32(struct pt_regs32 *regs)
358{
359 printk("PSR: %08x PC: %08x NPC: %08x Y: %08x %s\n", regs->psr,
360 regs->pc, regs->npc, regs->y, print_tainted());
361 printk("g0: %08x g1: %08x g2: %08x g3: %08x ",
362 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
363 regs->u_regs[3]);
364 printk("g4: %08x g5: %08x g6: %08x g7: %08x\n",
365 regs->u_regs[4], regs->u_regs[5], regs->u_regs[6],
366 regs->u_regs[7]);
367 printk("o0: %08x o1: %08x o2: %08x o3: %08x ",
368 regs->u_regs[8], regs->u_regs[9], regs->u_regs[10],
369 regs->u_regs[11]);
370 printk("o4: %08x o5: %08x sp: %08x ret_pc: %08x\n",
371 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
372 regs->u_regs[15]);
373}
374
375unsigned long thread_saved_pc(struct task_struct *tsk) 304unsigned long thread_saved_pc(struct task_struct *tsk)
376{ 305{
377 struct thread_info *ti = task_thread_info(tsk); 306 struct thread_info *ti = task_thread_info(tsk);
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index a8052b76df41..cc454731d879 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -86,7 +86,7 @@ extern void setup_sparc64_timer(void);
86 86
87static volatile unsigned long callin_flag = 0; 87static volatile unsigned long callin_flag = 0;
88 88
89void __devinit smp_callin(void) 89void __cpuinit smp_callin(void)
90{ 90{
91 int cpuid = hard_smp_processor_id(); 91 int cpuid = hard_smp_processor_id();
92 92
diff --git a/arch/sparc64/kernel/trampoline.S b/arch/sparc64/kernel/trampoline.S
index 04e81dda13d0..4ae2e525d68b 100644
--- a/arch/sparc64/kernel/trampoline.S
+++ b/arch/sparc64/kernel/trampoline.S
@@ -4,6 +4,8 @@
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) 4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
5 */ 5 */
6 6
7#include <linux/init.h>
8
7#include <asm/head.h> 9#include <asm/head.h>
8#include <asm/asi.h> 10#include <asm/asi.h>
9#include <asm/lsu.h> 11#include <asm/lsu.h>
@@ -36,7 +38,7 @@ dtlb_load:
36tramp_stack: 38tramp_stack:
37 .skip TRAMP_STACK_SIZE 39 .skip TRAMP_STACK_SIZE
38 40
39 .text 41 __CPUINIT
40 .align 8 42 .align 8
41 .globl sparc64_cpu_startup, sparc64_cpu_startup_end 43 .globl sparc64_cpu_startup, sparc64_cpu_startup_end
42sparc64_cpu_startup: 44sparc64_cpu_startup:
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 2b6abf633343..007f5317c0de 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -1791,8 +1791,6 @@ static const char *sun4v_err_type_to_str(u32 type)
1791 }; 1791 };
1792} 1792}
1793 1793
1794extern void __show_regs(struct pt_regs * regs);
1795
1796static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, int cpu, const char *pfx, atomic_t *ocnt) 1794static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, int cpu, const char *pfx, atomic_t *ocnt)
1797{ 1795{
1798 int cnt; 1796 int cnt;
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index e2027f27c0fe..2650d0d33ac2 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -244,16 +244,8 @@ static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
244 if (regs->tstate & TSTATE_PRIV) { 244 if (regs->tstate & TSTATE_PRIV) {
245 const struct exception_table_entry *entry; 245 const struct exception_table_entry *entry;
246 246
247 if (asi == ASI_P && (insn & 0xc0800000) == 0xc0800000) { 247 entry = search_exception_tables(regs->tpc);
248 if (insn & 0x2000) 248 if (entry) {
249 asi = (regs->tstate >> 24);
250 else
251 asi = (insn >> 5);
252 }
253
254 /* Look in asi.h: All _S asis have LS bit set */
255 if ((asi & 0x1) &&
256 (entry = search_exception_tables(regs->tpc))) {
257 regs->tpc = entry->fixup; 249 regs->tpc = entry->fixup;
258 regs->tnpc = regs->tpc + 4; 250 regs->tnpc = regs->tpc + 4;
259 return; 251 return;
@@ -294,7 +286,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
294 unsigned long tpc = regs->tpc; 286 unsigned long tpc = regs->tpc;
295 287
296 /* Sanity check the PC. */ 288 /* Sanity check the PC. */
297 if ((tpc >= KERNBASE && tpc < (unsigned long) _etext) || 289 if ((tpc >= KERNBASE && tpc < (unsigned long) __init_end) ||
298 (tpc >= MODULES_VADDR && tpc < MODULES_END)) { 290 (tpc >= MODULES_VADDR && tpc < MODULES_END)) {
299 /* Valid, no problems... */ 291 /* Valid, no problems... */
300 } else { 292 } else {
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 9e6bca266d88..b5c30416fdac 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1010,7 +1010,8 @@ static struct linux_prom64_registers pall[MAX_BANKS] __initdata;
1010static int pall_ents __initdata; 1010static int pall_ents __initdata;
1011 1011
1012#ifdef CONFIG_DEBUG_PAGEALLOC 1012#ifdef CONFIG_DEBUG_PAGEALLOC
1013static unsigned long kernel_map_range(unsigned long pstart, unsigned long pend, pgprot_t prot) 1013static unsigned long __ref kernel_map_range(unsigned long pstart,
1014 unsigned long pend, pgprot_t prot)
1014{ 1015{
1015 unsigned long vstart = PAGE_OFFSET + pstart; 1016 unsigned long vstart = PAGE_OFFSET + pstart;
1016 unsigned long vend = PAGE_OFFSET + pend; 1017 unsigned long vend = PAGE_OFFSET + pend;
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index fc50d2f959d1..e8cb9ff183e9 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -128,8 +128,6 @@ void *get_current(void)
128 return current; 128 return current;
129} 129}
130 130
131extern void schedule_tail(struct task_struct *prev);
132
133/* 131/*
134 * This is called magically, by its address being stuffed in a jmp_buf 132 * This is called magically, by its address being stuffed in a jmp_buf
135 * and being longjmp-d to. 133 * and being longjmp-d to.
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index e09a6b73a1aa..6d50064db182 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -377,6 +377,19 @@ config X86_OOSTORE
377 def_bool y 377 def_bool y
378 depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6) && MTRR 378 depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6) && MTRR
379 379
380#
381# P6_NOPs are a relatively minor optimization that require a family >=
382# 6 processor, except that it is broken on certain VIA chips.
383# Furthermore, AMD chips prefer a totally different sequence of NOPs
384# (which work on all CPUs). As a result, disallow these if we're
385# compiling X86_GENERIC but not X86_64 (these NOPs do work on all
386# x86-64 capable chips); the list of processors in the right-hand clause
387# are the cores that benefit from this optimization.
388#
389config X86_P6_NOP
390 def_bool y
391 depends on (X86_64 || !X86_GENERIC) && (M686 || MPENTIUMII || MPENTIUMIII || MPENTIUMM || MCORE2 || PENTIUM4)
392
380config X86_TSC 393config X86_TSC
381 def_bool y 394 def_bool y
382 depends on ((MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ) || X86_64 395 depends on ((MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ) || X86_64
@@ -390,6 +403,7 @@ config X86_CMOV
390config X86_MINIMUM_CPU_FAMILY 403config X86_MINIMUM_CPU_FAMILY
391 int 404 int
392 default "64" if X86_64 405 default "64" if X86_64
406 default "6" if X86_32 && X86_P6_NOP
393 default "4" if X86_32 && (X86_XADD || X86_CMPXCHG || X86_BSWAP || X86_WP_WORKS_OK) 407 default "4" if X86_32 && (X86_XADD || X86_CMPXCHG || X86_BSWAP || X86_WP_WORKS_OK)
394 default "3" 408 default "3"
395 409
diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
index 378353956b5d..e77d89f9e8aa 100644
--- a/arch/x86/boot/memory.c
+++ b/arch/x86/boot/memory.c
@@ -37,6 +37,12 @@ static int detect_memory_e820(void)
37 "=m" (*desc) 37 "=m" (*desc)
38 : "D" (desc), "d" (SMAP), "a" (0xe820)); 38 : "D" (desc), "d" (SMAP), "a" (0xe820));
39 39
40 /* BIOSes which terminate the chain with CF = 1 as opposed
41 to %ebx = 0 don't always report the SMAP signature on
42 the final, failing, probe. */
43 if (err)
44 break;
45
40 /* Some BIOSes stop returning SMAP in the middle of 46 /* Some BIOSes stop returning SMAP in the middle of
41 the search loop. We don't know exactly how the BIOS 47 the search loop. We don't know exactly how the BIOS
42 screwed up the map at that point, we might have a 48 screwed up the map at that point, we might have a
@@ -47,9 +53,6 @@ static int detect_memory_e820(void)
47 break; 53 break;
48 } 54 }
49 55
50 if (err)
51 break;
52
53 count++; 56 count++;
54 desc++; 57 desc++;
55 } while (next && count < E820MAX); 58 } while (next && count < E820MAX);
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index a33d53017997..8ea040124f7d 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -128,13 +128,11 @@ void foo(void)
128 OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending); 128 OFFSET(XEN_vcpu_info_pending, vcpu_info, evtchn_upcall_pending);
129#endif 129#endif
130 130
131#ifdef CONFIG_LGUEST_GUEST 131#if defined(CONFIG_LGUEST) || defined(CONFIG_LGUEST_GUEST) || defined(CONFIG_LGUEST_MODULE)
132 BLANK(); 132 BLANK();
133 OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled); 133 OFFSET(LGUEST_DATA_irq_enabled, lguest_data, irq_enabled);
134 OFFSET(LGUEST_DATA_pgdir, lguest_data, pgdir); 134 OFFSET(LGUEST_DATA_pgdir, lguest_data, pgdir);
135#endif
136 135
137#ifdef CONFIG_LGUEST
138 BLANK(); 136 BLANK();
139 OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc); 137 OFFSET(LGUEST_PAGES_host_gdt_desc, lguest_pages, state.host_gdt_desc);
140 OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc); 138 OFFSET(LGUEST_PAGES_host_idt_desc, lguest_pages, state.host_idt_desc);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f86a3c4a2669..a38aafaefc23 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -504,7 +504,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
504 504
505 /* Clear all flags overriden by options */ 505 /* Clear all flags overriden by options */
506 for (i = 0; i < NCAPINTS; i++) 506 for (i = 0; i < NCAPINTS; i++)
507 c->x86_capability[i] ^= cleared_cpu_caps[i]; 507 c->x86_capability[i] &= ~cleared_cpu_caps[i];
508 508
509 /* Init Machine Check Exception if available. */ 509 /* Init Machine Check Exception if available. */
510 mcheck_init(c); 510 mcheck_init(c);
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index b6e136f23d3d..be83336fddba 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -43,6 +43,7 @@
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <asm/processor.h> 44#include <asm/processor.h>
45#include <asm/msr.h> 45#include <asm/msr.h>
46#include <asm/kvm_para.h>
46#include "mtrr.h" 47#include "mtrr.h"
47 48
48u32 num_var_ranges = 0; 49u32 num_var_ranges = 0;
@@ -649,6 +650,7 @@ static __init int amd_special_default_mtrr(void)
649 650
650/** 651/**
651 * mtrr_trim_uncached_memory - trim RAM not covered by MTRRs 652 * mtrr_trim_uncached_memory - trim RAM not covered by MTRRs
653 * @end_pfn: ending page frame number
652 * 654 *
653 * Some buggy BIOSes don't setup the MTRRs properly for systems with certain 655 * Some buggy BIOSes don't setup the MTRRs properly for systems with certain
654 * memory configurations. This routine checks that the highest MTRR matches 656 * memory configurations. This routine checks that the highest MTRR matches
@@ -688,8 +690,11 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
688 690
689 /* kvm/qemu doesn't have mtrr set right, don't trim them all */ 691 /* kvm/qemu doesn't have mtrr set right, don't trim them all */
690 if (!highest_pfn) { 692 if (!highest_pfn) {
691 printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n"); 693 if (!kvm_para_available()) {
692 WARN_ON(1); 694 printk(KERN_WARNING
695 "WARNING: strange, CPU MTRRs all blank?\n");
696 WARN_ON(1);
697 }
693 return 0; 698 return 0;
694 } 699 }
695 700
diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c
index 200fb3f9ebfb..e8b422c1c512 100644
--- a/arch/x86/kernel/cpu/transmeta.c
+++ b/arch/x86/kernel/cpu/transmeta.c
@@ -76,13 +76,6 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
76 /* All Transmeta CPUs have a constant TSC */ 76 /* All Transmeta CPUs have a constant TSC */
77 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability); 77 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
78 78
79 /* If we can run i686 user-space code, call us an i686 */
80#define USER686 ((1 << X86_FEATURE_TSC)|\
81 (1 << X86_FEATURE_CX8)|\
82 (1 << X86_FEATURE_CMOV))
83 if (c->x86 == 5 && (c->x86_capability[0] & USER686) == USER686)
84 c->x86 = 6;
85
86#ifdef CONFIG_SYSCTL 79#ifdef CONFIG_SYSCTL
87 /* randomize_va_space slows us down enormously; 80 /* randomize_va_space slows us down enormously;
88 it probably triggers retranslation of x86->native bytecode */ 81 it probably triggers retranslation of x86->native bytecode */
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 2ad9a1bc6a73..c20c9e7e08dd 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -453,6 +453,7 @@ ENTRY(stub_execve)
453 CFI_REGISTER rip, r11 453 CFI_REGISTER rip, r11
454 SAVE_REST 454 SAVE_REST
455 FIXUP_TOP_OF_STACK %r11 455 FIXUP_TOP_OF_STACK %r11
456 movq %rsp, %rcx
456 call sys_execve 457 call sys_execve
457 RESTORE_TOP_OF_STACK %r11 458 RESTORE_TOP_OF_STACK %r11
458 movq %rax,RAX(%rsp) 459 movq %rax,RAX(%rsp)
@@ -1036,15 +1037,16 @@ ENDPROC(child_rip)
1036 * rdi: name, rsi: argv, rdx: envp 1037 * rdi: name, rsi: argv, rdx: envp
1037 * 1038 *
1038 * We want to fallback into: 1039 * We want to fallback into:
1039 * extern long sys_execve(char *name, char **argv,char **envp, struct pt_regs regs) 1040 * extern long sys_execve(char *name, char **argv,char **envp, struct pt_regs *regs)
1040 * 1041 *
1041 * do_sys_execve asm fallback arguments: 1042 * do_sys_execve asm fallback arguments:
1042 * rdi: name, rsi: argv, rdx: envp, fake frame on the stack 1043 * rdi: name, rsi: argv, rdx: envp, rcx: fake frame on the stack
1043 */ 1044 */
1044ENTRY(kernel_execve) 1045ENTRY(kernel_execve)
1045 CFI_STARTPROC 1046 CFI_STARTPROC
1046 FAKE_STACK_FRAME $0 1047 FAKE_STACK_FRAME $0
1047 SAVE_ALL 1048 SAVE_ALL
1049 movq %rsp,%rcx
1048 call sys_execve 1050 call sys_execve
1049 movq %rax, RAX(%rsp) 1051 movq %rax, RAX(%rsp)
1050 RESTORE_REST 1052 RESTORE_REST
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 25eb98540a41..fd8ca53943a8 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -606,7 +606,7 @@ ENTRY(_stext)
606.section ".bss.page_aligned","wa" 606.section ".bss.page_aligned","wa"
607 .align PAGE_SIZE_asm 607 .align PAGE_SIZE_asm
608#ifdef CONFIG_X86_PAE 608#ifdef CONFIG_X86_PAE
609ENTRY(swapper_pg_pmd) 609swapper_pg_pmd:
610 .fill 1024*KPMDS,4,0 610 .fill 1024*KPMDS,4,0
611#else 611#else
612ENTRY(swapper_pg_dir) 612ENTRY(swapper_pg_dir)
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index eb415043a929..a007454133a3 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -379,18 +379,24 @@ NEXT_PAGE(level2_ident_pgt)
379 /* Since I easily can, map the first 1G. 379 /* Since I easily can, map the first 1G.
380 * Don't set NX because code runs from these pages. 380 * Don't set NX because code runs from these pages.
381 */ 381 */
382 PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD) 382 PMDS(0, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD)
383 383
384NEXT_PAGE(level2_kernel_pgt) 384NEXT_PAGE(level2_kernel_pgt)
385 /* 40MB kernel mapping. The kernel code cannot be bigger than that. 385 /*
386 When you change this change KERNEL_TEXT_SIZE in page.h too. */ 386 * 128 MB kernel mapping. We spend a full page on this pagetable
387 /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ 387 * anyway.
388 PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL, KERNEL_TEXT_SIZE/PMD_SIZE) 388 *
389 /* Module mapping starts here */ 389 * The kernel code+data+bss must not be bigger than that.
390 .fill (PTRS_PER_PMD - (KERNEL_TEXT_SIZE/PMD_SIZE)),8,0 390 *
391 * (NOTE: at +128MB starts the module area, see MODULES_VADDR.
392 * If you want to increase this then increase MODULES_VADDR
393 * too.)
394 */
395 PMDS(0, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL,
396 KERNEL_IMAGE_SIZE/PMD_SIZE)
391 397
392NEXT_PAGE(level2_spare_pgt) 398NEXT_PAGE(level2_spare_pgt)
393 .fill 512,8,0 399 .fill 512, 8, 0
394 400
395#undef PMDS 401#undef PMDS
396#undef NEXT_PAGE 402#undef NEXT_PAGE
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 429d084e014d..235fd6c77504 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -368,8 +368,8 @@ static int hpet_clocksource_register(void)
368 return 0; 368 return 0;
369} 369}
370 370
371/* 371/**
372 * Try to setup the HPET timer 372 * hpet_enable - Try to setup the HPET timer. Returns 1 on success.
373 */ 373 */
374int __init hpet_enable(void) 374int __init hpet_enable(void)
375{ 375{
diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c
index 5b3ce7934363..3d01e47777db 100644
--- a/arch/x86/kernel/init_task.c
+++ b/arch/x86/kernel/init_task.c
@@ -15,6 +15,7 @@ static struct files_struct init_files = INIT_FILES;
15static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 15static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
16static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 16static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
17struct mm_struct init_mm = INIT_MM(init_mm); 17struct mm_struct init_mm = INIT_MM(init_mm);
18EXPORT_UNUSED_SYMBOL(init_mm); /* will be removed in 2.6.26 */
18 19
19/* 20/*
20 * Initial thread structure. 21 * Initial thread structure.
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index a7d50a547dc2..be3c7a299f02 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -603,11 +603,13 @@ __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
603 } 603 }
604#endif 604#endif
605 605
606#ifdef X86_BTS
606 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS)) 607 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS))
607 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS); 608 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS);
608 609
609 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS)) 610 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS))
610 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES); 611 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES);
612#endif
611 613
612 614
613 if (!test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) { 615 if (!test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b0cc8f0136d8..3baf9b9f4c87 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -604,11 +604,13 @@ static inline void __switch_to_xtra(struct task_struct *prev_p,
604 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max); 604 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
605 } 605 }
606 606
607#ifdef X86_BTS
607 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS)) 608 if (test_tsk_thread_flag(prev_p, TIF_BTS_TRACE_TS))
608 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS); 609 ptrace_bts_take_timestamp(prev_p, BTS_TASK_DEPARTS);
609 610
610 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS)) 611 if (test_tsk_thread_flag(next_p, TIF_BTS_TRACE_TS))
611 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES); 612 ptrace_bts_take_timestamp(next_p, BTS_TASK_ARRIVES);
613#endif
612} 614}
613 615
614/* 616/*
@@ -730,16 +732,16 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
730 */ 732 */
731asmlinkage 733asmlinkage
732long sys_execve(char __user *name, char __user * __user *argv, 734long sys_execve(char __user *name, char __user * __user *argv,
733 char __user * __user *envp, struct pt_regs regs) 735 char __user * __user *envp, struct pt_regs *regs)
734{ 736{
735 long error; 737 long error;
736 char * filename; 738 char * filename;
737 739
738 filename = getname(name); 740 filename = getname(name);
739 error = PTR_ERR(filename); 741 error = PTR_ERR(filename);
740 if (IS_ERR(filename)) 742 if (IS_ERR(filename))
741 return error; 743 return error;
742 error = do_execve(filename, argv, envp, &regs); 744 error = do_execve(filename, argv, envp, regs);
743 putname(filename); 745 putname(filename);
744 return error; 746 return error;
745} 747}
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index d862e396b099..f41fdc98efb1 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -544,6 +544,8 @@ static int ptrace_set_debugreg(struct task_struct *child,
544 return 0; 544 return 0;
545} 545}
546 546
547#ifdef X86_BTS
548
547static int ptrace_bts_get_size(struct task_struct *child) 549static int ptrace_bts_get_size(struct task_struct *child)
548{ 550{
549 if (!child->thread.ds_area_msr) 551 if (!child->thread.ds_area_msr)
@@ -826,6 +828,7 @@ void ptrace_bts_take_timestamp(struct task_struct *tsk,
826 828
827 ptrace_bts_write_record(tsk, &rec); 829 ptrace_bts_write_record(tsk, &rec);
828} 830}
831#endif /* X86_BTS */
829 832
830/* 833/*
831 * Called by kernel/ptrace.c when detaching.. 834 * Called by kernel/ptrace.c when detaching..
@@ -839,7 +842,9 @@ void ptrace_disable(struct task_struct *child)
839 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); 842 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
840#endif 843#endif
841 if (child->thread.ds_area_msr) { 844 if (child->thread.ds_area_msr) {
845#ifdef X86_BTS
842 ptrace_bts_realloc(child, 0, 0); 846 ptrace_bts_realloc(child, 0, 0);
847#endif
843 child->thread.debugctlmsr &= ~ds_debugctl_mask(); 848 child->thread.debugctlmsr &= ~ds_debugctl_mask();
844 if (!child->thread.debugctlmsr) 849 if (!child->thread.debugctlmsr)
845 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR); 850 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
@@ -961,6 +966,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
961 break; 966 break;
962#endif 967#endif
963 968
969 /*
970 * These bits need more cooking - not enabled yet:
971 */
972#ifdef X86_BTS
964 case PTRACE_BTS_CONFIG: 973 case PTRACE_BTS_CONFIG:
965 ret = ptrace_bts_config 974 ret = ptrace_bts_config
966 (child, data, (struct ptrace_bts_config __user *)addr); 975 (child, data, (struct ptrace_bts_config __user *)addr);
@@ -988,6 +997,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
988 ret = ptrace_bts_drain 997 ret = ptrace_bts_drain
989 (child, data, (struct bts_struct __user *) addr); 998 (child, data, (struct bts_struct __user *) addr);
990 break; 999 break;
1000#endif
991 1001
992 default: 1002 default:
993 ret = ptrace_request(child, request, addr, data); 1003 ret = ptrace_request(child, request, addr, data);
@@ -1226,12 +1236,14 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
1226 case PTRACE_SETOPTIONS: 1236 case PTRACE_SETOPTIONS:
1227 case PTRACE_SET_THREAD_AREA: 1237 case PTRACE_SET_THREAD_AREA:
1228 case PTRACE_GET_THREAD_AREA: 1238 case PTRACE_GET_THREAD_AREA:
1239#ifdef X86_BTS
1229 case PTRACE_BTS_CONFIG: 1240 case PTRACE_BTS_CONFIG:
1230 case PTRACE_BTS_STATUS: 1241 case PTRACE_BTS_STATUS:
1231 case PTRACE_BTS_SIZE: 1242 case PTRACE_BTS_SIZE:
1232 case PTRACE_BTS_GET: 1243 case PTRACE_BTS_GET:
1233 case PTRACE_BTS_CLEAR: 1244 case PTRACE_BTS_CLEAR:
1234 case PTRACE_BTS_DRAIN: 1245 case PTRACE_BTS_DRAIN:
1246#endif
1235 return sys_ptrace(request, pid, addr, data); 1247 return sys_ptrace(request, pid, addr, data);
1236 1248
1237 default: 1249 default:
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 6fd804f07821..7637dc91c79b 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -1021,7 +1021,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
1021 1021
1022 /* Clear all flags overriden by options */ 1022 /* Clear all flags overriden by options */
1023 for (i = 0; i < NCAPINTS; i++) 1023 for (i = 0; i < NCAPINTS; i++)
1024 c->x86_capability[i] ^= cleared_cpu_caps[i]; 1024 c->x86_capability[i] &= ~cleared_cpu_caps[i];
1025 1025
1026#ifdef CONFIG_X86_MCE 1026#ifdef CONFIG_X86_MCE
1027 mcheck_init(c); 1027 mcheck_init(c);
diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index d53bd6fcb428..0880f2c388a9 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -554,10 +554,10 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
554 int timeout; 554 int timeout;
555 unsigned long start_rip; 555 unsigned long start_rip;
556 struct create_idle c_idle = { 556 struct create_idle c_idle = {
557 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
558 .cpu = cpu, 557 .cpu = cpu,
559 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done), 558 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
560 }; 559 };
560 INIT_WORK(&c_idle.work, do_fork_idle);
561 561
562 /* allocate memory for gdts of secondary cpus. Hotplug is considered */ 562 /* allocate memory for gdts of secondary cpus. Hotplug is considered */
563 if (!cpu_gdt_descr[cpu].address && 563 if (!cpu_gdt_descr[cpu].address &&
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 02f0f61f5b11..c28c342c162f 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -25,6 +25,8 @@ static int save_stack_stack(void *data, char *name)
25static void save_stack_address(void *data, unsigned long addr, int reliable) 25static void save_stack_address(void *data, unsigned long addr, int reliable)
26{ 26{
27 struct stack_trace *trace = data; 27 struct stack_trace *trace = data;
28 if (!reliable)
29 return;
28 if (trace->skip > 0) { 30 if (trace->skip > 0) {
29 trace->skip--; 31 trace->skip--;
30 return; 32 return;
@@ -37,6 +39,8 @@ static void
37save_stack_address_nosched(void *data, unsigned long addr, int reliable) 39save_stack_address_nosched(void *data, unsigned long addr, int reliable)
38{ 40{
39 struct stack_trace *trace = (struct stack_trace *)data; 41 struct stack_trace *trace = (struct stack_trace *)data;
42 if (!reliable)
43 return;
40 if (in_sched_functions(addr)) 44 if (in_sched_functions(addr))
41 return; 45 return;
42 if (trace->skip > 0) { 46 if (trace->skip > 0) {
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 6dfd4e76661a..022bcaa3b42e 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -91,7 +91,9 @@ int do_set_thread_area(struct task_struct *p, int idx,
91 91
92asmlinkage int sys_set_thread_area(struct user_desc __user *u_info) 92asmlinkage int sys_set_thread_area(struct user_desc __user *u_info)
93{ 93{
94 return do_set_thread_area(current, -1, u_info, 1); 94 int ret = do_set_thread_area(current, -1, u_info, 1);
95 prevent_tail_call(ret);
96 return ret;
95} 97}
96 98
97 99
@@ -139,7 +141,9 @@ int do_get_thread_area(struct task_struct *p, int idx,
139 141
140asmlinkage int sys_get_thread_area(struct user_desc __user *u_info) 142asmlinkage int sys_get_thread_area(struct user_desc __user *u_info)
141{ 143{
142 return do_get_thread_area(current, -1, u_info); 144 int ret = do_get_thread_area(current, -1, u_info);
145 prevent_tail_call(ret);
146 return ret;
143} 147}
144 148
145int regset_tls_active(struct task_struct *target, 149int regset_tls_active(struct task_struct *target,
diff --git a/arch/x86/kernel/tsc_32.c b/arch/x86/kernel/tsc_32.c
index 43517e324be8..f14cfd9d1f94 100644
--- a/arch/x86/kernel/tsc_32.c
+++ b/arch/x86/kernel/tsc_32.c
@@ -28,7 +28,8 @@ EXPORT_SYMBOL_GPL(tsc_khz);
28static int __init tsc_setup(char *str) 28static int __init tsc_setup(char *str)
29{ 29{
30 printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, " 30 printk(KERN_WARNING "notsc: Kernel compiled with CONFIG_X86_TSC, "
31 "cannot disable TSC.\n"); 31 "cannot disable TSC completely.\n");
32 mark_tsc_unstable("user disabled TSC");
32 return 1; 33 return 1;
33} 34}
34#else 35#else
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 3f8242774580..edff4c985485 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -44,11 +44,6 @@
44 44
45#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 45#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
46#define __syscall_clobber "r11","cx","memory" 46#define __syscall_clobber "r11","cx","memory"
47#define __pa_vsymbol(x) \
48 ({unsigned long v; \
49 extern char __vsyscall_0; \
50 asm("" : "=r" (v) : "0" (x)); \
51 ((v - VSYSCALL_START) + __pa_symbol(&__vsyscall_0)); })
52 47
53/* 48/*
54 * vsyscall_gtod_data contains data that is : 49 * vsyscall_gtod_data contains data that is :
@@ -102,7 +97,7 @@ static __always_inline void do_get_tz(struct timezone * tz)
102static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz) 97static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
103{ 98{
104 int ret; 99 int ret;
105 asm volatile("vsysc2: syscall" 100 asm volatile("syscall"
106 : "=a" (ret) 101 : "=a" (ret)
107 : "0" (__NR_gettimeofday),"D" (tv),"S" (tz) 102 : "0" (__NR_gettimeofday),"D" (tv),"S" (tz)
108 : __syscall_clobber ); 103 : __syscall_clobber );
@@ -112,7 +107,7 @@ static __always_inline int gettimeofday(struct timeval *tv, struct timezone *tz)
112static __always_inline long time_syscall(long *t) 107static __always_inline long time_syscall(long *t)
113{ 108{
114 long secs; 109 long secs;
115 asm volatile("vsysc1: syscall" 110 asm volatile("syscall"
116 : "=a" (secs) 111 : "=a" (secs)
117 : "0" (__NR_time),"D" (t) : __syscall_clobber); 112 : "0" (__NR_time),"D" (t) : __syscall_clobber);
118 return secs; 113 return secs;
@@ -228,42 +223,11 @@ long __vsyscall(3) venosys_1(void)
228 223
229#ifdef CONFIG_SYSCTL 224#ifdef CONFIG_SYSCTL
230 225
231#define SYSCALL 0x050f 226static int
232#define NOP2 0x9090 227vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * filp,
233 228 void __user *buffer, size_t *lenp, loff_t *ppos)
234/*
235 * NOP out syscall in vsyscall page when not needed.
236 */
237static int vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * filp,
238 void __user *buffer, size_t *lenp, loff_t *ppos)
239{ 229{
240 extern u16 vsysc1, vsysc2; 230 return proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
241 u16 __iomem *map1;
242 u16 __iomem *map2;
243 int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
244 if (!write)
245 return ret;
246 /* gcc has some trouble with __va(__pa()), so just do it this
247 way. */
248 map1 = ioremap(__pa_vsymbol(&vsysc1), 2);
249 if (!map1)
250 return -ENOMEM;
251 map2 = ioremap(__pa_vsymbol(&vsysc2), 2);
252 if (!map2) {
253 ret = -ENOMEM;
254 goto out;
255 }
256 if (!vsyscall_gtod_data.sysctl_enabled) {
257 writew(SYSCALL, map1);
258 writew(SYSCALL, map2);
259 } else {
260 writew(NOP2, map1);
261 writew(NOP2, map2);
262 }
263 iounmap(map2);
264out:
265 iounmap(map1);
266 return ret;
267} 231}
268 232
269static ctl_table kernel_table2[] = { 233static ctl_table kernel_table2[] = {
@@ -279,7 +243,6 @@ static ctl_table kernel_root_table2[] = {
279 .child = kernel_table2 }, 243 .child = kernel_table2 },
280 {} 244 {}
281}; 245};
282
283#endif 246#endif
284 247
285/* Assume __initcall executes before all user space. Hopefully kmod 248/* Assume __initcall executes before all user space. Hopefully kmod
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 5afdde4895dc..cccb38a59653 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -57,6 +57,7 @@
57#include <linux/lguest_launcher.h> 57#include <linux/lguest_launcher.h>
58#include <linux/virtio_console.h> 58#include <linux/virtio_console.h>
59#include <linux/pm.h> 59#include <linux/pm.h>
60#include <asm/lguest.h>
60#include <asm/paravirt.h> 61#include <asm/paravirt.h>
61#include <asm/param.h> 62#include <asm/param.h>
62#include <asm/page.h> 63#include <asm/page.h>
@@ -75,15 +76,6 @@
75 * behaving in simplified but equivalent ways. In particular, the Guest is the 76 * behaving in simplified but equivalent ways. In particular, the Guest is the
76 * same kernel as the Host (or at least, built from the same source code). :*/ 77 * same kernel as the Host (or at least, built from the same source code). :*/
77 78
78/* Declarations for definitions in lguest_guest.S */
79extern char lguest_noirq_start[], lguest_noirq_end[];
80extern const char lgstart_cli[], lgend_cli[];
81extern const char lgstart_sti[], lgend_sti[];
82extern const char lgstart_popf[], lgend_popf[];
83extern const char lgstart_pushf[], lgend_pushf[];
84extern const char lgstart_iret[], lgend_iret[];
85extern void lguest_iret(void);
86
87struct lguest_data lguest_data = { 79struct lguest_data lguest_data = {
88 .hcall_status = { [0 ... LHCALL_RING_SIZE-1] = 0xFF }, 80 .hcall_status = { [0 ... LHCALL_RING_SIZE-1] = 0xFF },
89 .noirq_start = (u32)lguest_noirq_start, 81 .noirq_start = (u32)lguest_noirq_start,
@@ -489,7 +481,7 @@ static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
489{ 481{
490 *pmdp = pmdval; 482 *pmdp = pmdval;
491 lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK, 483 lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK,
492 (__pa(pmdp)&(PAGE_SIZE-1))/4, 0); 484 (__pa(pmdp)&(PAGE_SIZE-1)), 0);
493} 485}
494 486
495/* There are a couple of legacy places where the kernel sets a PTE, but we 487/* There are a couple of legacy places where the kernel sets a PTE, but we
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index bb652f5a93fb..a02a14f0f324 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -172,8 +172,9 @@ set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot)
172} 172}
173 173
174/* 174/*
175 * The head.S code sets up the kernel high mapping from: 175 * The head.S code sets up the kernel high mapping:
176 * __START_KERNEL_map to __START_KERNEL_map + KERNEL_TEXT_SIZE 176 *
177 * from __START_KERNEL_map to __START_KERNEL_map + size (== _end-_text)
177 * 178 *
178 * phys_addr holds the negative offset to the kernel, which is added 179 * phys_addr holds the negative offset to the kernel, which is added
179 * to the compile time generated pmds. This results in invalid pmds up 180 * to the compile time generated pmds. This results in invalid pmds up
@@ -515,14 +516,6 @@ void __init mem_init(void)
515 516
516 /* clear_bss() already clear the empty_zero_page */ 517 /* clear_bss() already clear the empty_zero_page */
517 518
518 /* temporary debugging - double check it's true: */
519 {
520 int i;
521
522 for (i = 0; i < 1024; i++)
523 WARN_ON_ONCE(empty_zero_page[i]);
524 }
525
526 reservedpages = 0; 519 reservedpages = 0;
527 520
528 /* this will put all low memory onto the freelists */ 521 /* this will put all low memory onto the freelists */
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 882328efc3db..ac3c959e271d 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -162,7 +162,7 @@ static void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
162 area->phys_addr = phys_addr; 162 area->phys_addr = phys_addr;
163 vaddr = (unsigned long) area->addr; 163 vaddr = (unsigned long) area->addr;
164 if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) { 164 if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) {
165 remove_vm_area((void *)(vaddr & PAGE_MASK)); 165 free_vm_area(area);
166 return NULL; 166 return NULL;
167 } 167 }
168 168
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 464d8fc21ce6..7049294fb469 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -26,6 +26,7 @@ struct cpa_data {
26 pgprot_t mask_set; 26 pgprot_t mask_set;
27 pgprot_t mask_clr; 27 pgprot_t mask_clr;
28 int numpages; 28 int numpages;
29 int processed;
29 int flushtlb; 30 int flushtlb;
30 unsigned long pfn; 31 unsigned long pfn;
31}; 32};
@@ -44,6 +45,12 @@ static inline unsigned long highmap_end_pfn(void)
44 45
45#endif 46#endif
46 47
48#ifdef CONFIG_DEBUG_PAGEALLOC
49# define debug_pagealloc 1
50#else
51# define debug_pagealloc 0
52#endif
53
47static inline int 54static inline int
48within(unsigned long addr, unsigned long start, unsigned long end) 55within(unsigned long addr, unsigned long start, unsigned long end)
49{ 56{
@@ -284,8 +291,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
284 */ 291 */
285 nextpage_addr = (address + psize) & pmask; 292 nextpage_addr = (address + psize) & pmask;
286 numpages = (nextpage_addr - address) >> PAGE_SHIFT; 293 numpages = (nextpage_addr - address) >> PAGE_SHIFT;
287 if (numpages < cpa->numpages) 294 if (numpages < cpa->processed)
288 cpa->numpages = numpages; 295 cpa->processed = numpages;
289 296
290 /* 297 /*
291 * We are safe now. Check whether the new pgprot is the same: 298 * We are safe now. Check whether the new pgprot is the same:
@@ -312,7 +319,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
312 */ 319 */
313 addr = address + PAGE_SIZE; 320 addr = address + PAGE_SIZE;
314 pfn++; 321 pfn++;
315 for (i = 1; i < cpa->numpages; i++, addr += PAGE_SIZE, pfn++) { 322 for (i = 1; i < cpa->processed; i++, addr += PAGE_SIZE, pfn++) {
316 pgprot_t chk_prot = static_protections(new_prot, addr, pfn); 323 pgprot_t chk_prot = static_protections(new_prot, addr, pfn);
317 324
318 if (pgprot_val(chk_prot) != pgprot_val(new_prot)) 325 if (pgprot_val(chk_prot) != pgprot_val(new_prot))
@@ -336,7 +343,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
336 * that we limited the number of possible pages already to 343 * that we limited the number of possible pages already to
337 * the number of pages in the large page. 344 * the number of pages in the large page.
338 */ 345 */
339 if (address == (nextpage_addr - psize) && cpa->numpages == numpages) { 346 if (address == (nextpage_addr - psize) && cpa->processed == numpages) {
340 /* 347 /*
341 * The address is aligned and the number of pages 348 * The address is aligned and the number of pages
342 * covers the full page. 349 * covers the full page.
@@ -355,45 +362,48 @@ out_unlock:
355 362
356static LIST_HEAD(page_pool); 363static LIST_HEAD(page_pool);
357static unsigned long pool_size, pool_pages, pool_low; 364static unsigned long pool_size, pool_pages, pool_low;
358static unsigned long pool_used, pool_failed, pool_refill; 365static unsigned long pool_used, pool_failed;
359 366
360static void cpa_fill_pool(void) 367static void cpa_fill_pool(struct page **ret)
361{ 368{
362 struct page *p;
363 gfp_t gfp = GFP_KERNEL; 369 gfp_t gfp = GFP_KERNEL;
370 unsigned long flags;
371 struct page *p;
364 372
365 /* Do not allocate from interrupt context */
366 if (in_irq() || irqs_disabled())
367 return;
368 /* 373 /*
369 * Check unlocked. I does not matter when we have one more 374 * Avoid recursion (on debug-pagealloc) and also signal
370 * page in the pool. The bit lock avoids recursive pool 375 * our priority to get to these pagetables:
371 * allocations:
372 */ 376 */
373 if (pool_pages >= pool_size || test_and_set_bit_lock(0, &pool_refill)) 377 if (current->flags & PF_MEMALLOC)
374 return; 378 return;
379 current->flags |= PF_MEMALLOC;
375 380
376#ifdef CONFIG_DEBUG_PAGEALLOC
377 /* 381 /*
378 * We could do: 382 * Allocate atomically from atomic contexts:
379 * gfp = in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
380 * but this fails on !PREEMPT kernels
381 */ 383 */
382 gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN; 384 if (in_atomic() || irqs_disabled() || debug_pagealloc)
383#endif 385 gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
384 386
385 while (pool_pages < pool_size) { 387 while (pool_pages < pool_size || (ret && !*ret)) {
386 p = alloc_pages(gfp, 0); 388 p = alloc_pages(gfp, 0);
387 if (!p) { 389 if (!p) {
388 pool_failed++; 390 pool_failed++;
389 break; 391 break;
390 } 392 }
391 spin_lock_irq(&pgd_lock); 393 /*
394 * If the call site needs a page right now, provide it:
395 */
396 if (ret && !*ret) {
397 *ret = p;
398 continue;
399 }
400 spin_lock_irqsave(&pgd_lock, flags);
392 list_add(&p->lru, &page_pool); 401 list_add(&p->lru, &page_pool);
393 pool_pages++; 402 pool_pages++;
394 spin_unlock_irq(&pgd_lock); 403 spin_unlock_irqrestore(&pgd_lock, flags);
395 } 404 }
396 clear_bit_unlock(0, &pool_refill); 405
406 current->flags &= ~PF_MEMALLOC;
397} 407}
398 408
399#define SHIFT_MB (20 - PAGE_SHIFT) 409#define SHIFT_MB (20 - PAGE_SHIFT)
@@ -414,11 +424,15 @@ void __init cpa_init(void)
414 * GiB. Shift MiB to Gib and multiply the result by 424 * GiB. Shift MiB to Gib and multiply the result by
415 * POOL_PAGES_PER_GB: 425 * POOL_PAGES_PER_GB:
416 */ 426 */
417 gb = ((si.totalram >> SHIFT_MB) + ROUND_MB_GB) >> SHIFT_MB_GB; 427 if (debug_pagealloc) {
418 pool_size = POOL_PAGES_PER_GB * gb; 428 gb = ((si.totalram >> SHIFT_MB) + ROUND_MB_GB) >> SHIFT_MB_GB;
429 pool_size = POOL_PAGES_PER_GB * gb;
430 } else {
431 pool_size = 1;
432 }
419 pool_low = pool_size; 433 pool_low = pool_size;
420 434
421 cpa_fill_pool(); 435 cpa_fill_pool(NULL);
422 printk(KERN_DEBUG 436 printk(KERN_DEBUG
423 "CPA: page pool initialized %lu of %lu pages preallocated\n", 437 "CPA: page pool initialized %lu of %lu pages preallocated\n",
424 pool_pages, pool_size); 438 pool_pages, pool_size);
@@ -440,16 +454,20 @@ static int split_large_page(pte_t *kpte, unsigned long address)
440 spin_lock_irqsave(&pgd_lock, flags); 454 spin_lock_irqsave(&pgd_lock, flags);
441 if (list_empty(&page_pool)) { 455 if (list_empty(&page_pool)) {
442 spin_unlock_irqrestore(&pgd_lock, flags); 456 spin_unlock_irqrestore(&pgd_lock, flags);
443 return -ENOMEM; 457 base = NULL;
458 cpa_fill_pool(&base);
459 if (!base)
460 return -ENOMEM;
461 spin_lock_irqsave(&pgd_lock, flags);
462 } else {
463 base = list_first_entry(&page_pool, struct page, lru);
464 list_del(&base->lru);
465 pool_pages--;
466
467 if (pool_pages < pool_low)
468 pool_low = pool_pages;
444 } 469 }
445 470
446 base = list_first_entry(&page_pool, struct page, lru);
447 list_del(&base->lru);
448 pool_pages--;
449
450 if (pool_pages < pool_low)
451 pool_low = pool_pages;
452
453 /* 471 /*
454 * Check for races, another CPU might have split this page 472 * Check for races, another CPU might have split this page
455 * up for us already: 473 * up for us already:
@@ -555,7 +573,7 @@ repeat:
555 set_pte_atomic(kpte, new_pte); 573 set_pte_atomic(kpte, new_pte);
556 cpa->flushtlb = 1; 574 cpa->flushtlb = 1;
557 } 575 }
558 cpa->numpages = 1; 576 cpa->processed = 1;
559 return 0; 577 return 0;
560 } 578 }
561 579
@@ -566,7 +584,7 @@ repeat:
566 do_split = try_preserve_large_page(kpte, address, cpa); 584 do_split = try_preserve_large_page(kpte, address, cpa);
567 /* 585 /*
568 * When the range fits into the existing large page, 586 * When the range fits into the existing large page,
569 * return. cp->numpages and cpa->tlbflush have been updated in 587 * return. cp->processed and cpa->tlbflush have been updated in
570 * try_large_page: 588 * try_large_page:
571 */ 589 */
572 if (do_split <= 0) 590 if (do_split <= 0)
@@ -645,7 +663,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
645 * Store the remaining nr of pages for the large page 663 * Store the remaining nr of pages for the large page
646 * preservation check. 664 * preservation check.
647 */ 665 */
648 cpa->numpages = numpages; 666 cpa->numpages = cpa->processed = numpages;
649 667
650 ret = __change_page_attr(cpa, checkalias); 668 ret = __change_page_attr(cpa, checkalias);
651 if (ret) 669 if (ret)
@@ -662,9 +680,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
662 * CPA operation. Either a large page has been 680 * CPA operation. Either a large page has been
663 * preserved or a single page update happened. 681 * preserved or a single page update happened.
664 */ 682 */
665 BUG_ON(cpa->numpages > numpages); 683 BUG_ON(cpa->processed > numpages);
666 numpages -= cpa->numpages; 684 numpages -= cpa->processed;
667 cpa->vaddr += cpa->numpages * PAGE_SIZE; 685 cpa->vaddr += cpa->processed * PAGE_SIZE;
668 } 686 }
669 return 0; 687 return 0;
670} 688}
@@ -734,7 +752,8 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
734 cpa_flush_all(cache); 752 cpa_flush_all(cache);
735 753
736out: 754out:
737 cpa_fill_pool(); 755 cpa_fill_pool(NULL);
756
738 return ret; 757 return ret;
739} 758}
740 759
@@ -897,7 +916,7 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
897 * Try to refill the page pool here. We can do this only after 916 * Try to refill the page pool here. We can do this only after
898 * the tlb flush. 917 * the tlb flush.
899 */ 918 */
900 cpa_fill_pool(); 919 cpa_fill_pool(NULL);
901} 920}
902 921
903#ifdef CONFIG_HIBERNATION 922#ifdef CONFIG_HIBERNATION
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index f385a4b4a484..0a8f4742ef51 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -50,7 +50,9 @@ obj-$(VDSO64-y) += vdso-syms.lds
50sed-vdsosym := -e 's/^00*/0/' \ 50sed-vdsosym := -e 's/^00*/0/' \
51 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p' 51 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
52quiet_cmd_vdsosym = VDSOSYM $@ 52quiet_cmd_vdsosym = VDSOSYM $@
53 cmd_vdsosym = $(NM) $< | sed -n $(sed-vdsosym) | LC_ALL=C sort > $@ 53define cmd_vdsosym
54 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
55endef
54 56
55$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE 57$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
56 $(call if_changed,vdsosym) 58 $(call if_changed,vdsosym)
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 49e5358f481a..8b9ee27805fd 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -153,6 +153,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
153 if (*ax == 1) 153 if (*ax == 1)
154 maskedx = ~((1 << X86_FEATURE_APIC) | /* disable APIC */ 154 maskedx = ~((1 << X86_FEATURE_APIC) | /* disable APIC */
155 (1 << X86_FEATURE_ACPI) | /* disable ACPI */ 155 (1 << X86_FEATURE_ACPI) | /* disable ACPI */
156 (1 << X86_FEATURE_SEP) | /* disable SEP */
156 (1 << X86_FEATURE_ACC)); /* thermal monitoring */ 157 (1 << X86_FEATURE_ACC)); /* thermal monitoring */
157 158
158 asm(XEN_EMULATE_PREFIX "cpuid" 159 asm(XEN_EMULATE_PREFIX "cpuid"
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6dd12f7019a0..1db93b619074 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -85,6 +85,7 @@ enum {
85 board_ahci_ign_iferr = 2, 85 board_ahci_ign_iferr = 2,
86 board_ahci_sb600 = 3, 86 board_ahci_sb600 = 3,
87 board_ahci_mv = 4, 87 board_ahci_mv = 4,
88 board_ahci_sb700 = 5,
88 89
89 /* global controller registers */ 90 /* global controller registers */
90 HOST_CAP = 0x00, /* host capabilities */ 91 HOST_CAP = 0x00, /* host capabilities */
@@ -442,6 +443,16 @@ static const struct ata_port_info ahci_port_info[] = {
442 .udma_mask = ATA_UDMA6, 443 .udma_mask = ATA_UDMA6,
443 .port_ops = &ahci_ops, 444 .port_ops = &ahci_ops,
444 }, 445 },
446 /* board_ahci_sb700 */
447 {
448 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
449 AHCI_HFLAG_NO_PMP),
450 .flags = AHCI_FLAG_COMMON,
451 .link_flags = AHCI_LFLAG_COMMON,
452 .pio_mask = 0x1f, /* pio0-4 */
453 .udma_mask = ATA_UDMA6,
454 .port_ops = &ahci_ops,
455 },
445}; 456};
446 457
447static const struct pci_device_id ahci_pci_tbl[] = { 458static const struct pci_device_id ahci_pci_tbl[] = {
@@ -484,12 +495,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
484 495
485 /* ATI */ 496 /* ATI */
486 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ 497 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
487 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700/800 */ 498 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb700 }, /* ATI SB700/800 */
488 { PCI_VDEVICE(ATI, 0x4391), board_ahci_sb600 }, /* ATI SB700/800 */ 499 { PCI_VDEVICE(ATI, 0x4391), board_ahci_sb700 }, /* ATI SB700/800 */
489 { PCI_VDEVICE(ATI, 0x4392), board_ahci_sb600 }, /* ATI SB700/800 */ 500 { PCI_VDEVICE(ATI, 0x4392), board_ahci_sb700 }, /* ATI SB700/800 */
490 { PCI_VDEVICE(ATI, 0x4393), board_ahci_sb600 }, /* ATI SB700/800 */ 501 { PCI_VDEVICE(ATI, 0x4393), board_ahci_sb700 }, /* ATI SB700/800 */
491 { PCI_VDEVICE(ATI, 0x4394), board_ahci_sb600 }, /* ATI SB700/800 */ 502 { PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */
492 { PCI_VDEVICE(ATI, 0x4395), board_ahci_sb600 }, /* ATI SB700/800 */ 503 { PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */
493 504
494 /* VIA */ 505 /* VIA */
495 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ 506 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4cf8662df99e..4fbcce758b04 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -113,7 +113,7 @@ int atapi_enabled = 1;
113module_param(atapi_enabled, int, 0444); 113module_param(atapi_enabled, int, 0444);
114MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); 114MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
115 115
116int atapi_dmadir = 0; 116static int atapi_dmadir = 0;
117module_param(atapi_dmadir, int, 0444); 117module_param(atapi_dmadir, int, 0444);
118MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)"); 118MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)");
119 119
@@ -153,7 +153,7 @@ MODULE_VERSION(DRV_VERSION);
153 153
154/** 154/**
155 * ata_force_cbl - force cable type according to libata.force 155 * ata_force_cbl - force cable type according to libata.force
156 * @link: ATA link of interest 156 * @ap: ATA port of interest
157 * 157 *
158 * Force cable type according to libata.force and whine about it. 158 * Force cable type according to libata.force and whine about it.
159 * The last entry which has matching port number is used, so it 159 * The last entry which has matching port number is used, so it
@@ -2396,6 +2396,7 @@ int ata_dev_configure(struct ata_device *dev)
2396 else if (dev->class == ATA_DEV_ATAPI) { 2396 else if (dev->class == ATA_DEV_ATAPI) {
2397 const char *cdb_intr_string = ""; 2397 const char *cdb_intr_string = "";
2398 const char *atapi_an_string = ""; 2398 const char *atapi_an_string = "";
2399 const char *dma_dir_string = "";
2399 u32 sntf; 2400 u32 sntf;
2400 2401
2401 rc = atapi_cdb_len(id); 2402 rc = atapi_cdb_len(id);
@@ -2436,13 +2437,19 @@ int ata_dev_configure(struct ata_device *dev)
2436 cdb_intr_string = ", CDB intr"; 2437 cdb_intr_string = ", CDB intr";
2437 } 2438 }
2438 2439
2440 if (atapi_dmadir || atapi_id_dmadir(dev->id)) {
2441 dev->flags |= ATA_DFLAG_DMADIR;
2442 dma_dir_string = ", DMADIR";
2443 }
2444
2439 /* print device info to dmesg */ 2445 /* print device info to dmesg */
2440 if (ata_msg_drv(ap) && print_info) 2446 if (ata_msg_drv(ap) && print_info)
2441 ata_dev_printk(dev, KERN_INFO, 2447 ata_dev_printk(dev, KERN_INFO,
2442 "ATAPI: %s, %s, max %s%s%s\n", 2448 "ATAPI: %s, %s, max %s%s%s%s\n",
2443 modelbuf, fwrevbuf, 2449 modelbuf, fwrevbuf,
2444 ata_mode_string(xfer_mask), 2450 ata_mode_string(xfer_mask),
2445 cdb_intr_string, atapi_an_string); 2451 cdb_intr_string, atapi_an_string,
2452 dma_dir_string);
2446 } 2453 }
2447 2454
2448 /* determine max_sectors */ 2455 /* determine max_sectors */
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index caef2bbd4a8a..d91f5090ba9d 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -35,7 +35,7 @@ static unsigned int sata_pmp_read(struct ata_link *link, int reg, u32 *r_val)
35 ata_tf_init(pmp_dev, &tf); 35 ata_tf_init(pmp_dev, &tf);
36 tf.command = ATA_CMD_PMP_READ; 36 tf.command = ATA_CMD_PMP_READ;
37 tf.protocol = ATA_PROT_NODATA; 37 tf.protocol = ATA_PROT_NODATA;
38 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 38 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
39 tf.feature = reg; 39 tf.feature = reg;
40 tf.device = link->pmp; 40 tf.device = link->pmp;
41 41
@@ -71,7 +71,7 @@ static unsigned int sata_pmp_write(struct ata_link *link, int reg, u32 val)
71 ata_tf_init(pmp_dev, &tf); 71 ata_tf_init(pmp_dev, &tf);
72 tf.command = ATA_CMD_PMP_WRITE; 72 tf.command = ATA_CMD_PMP_WRITE;
73 tf.protocol = ATA_PROT_NODATA; 73 tf.protocol = ATA_PROT_NODATA;
74 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 74 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
75 tf.feature = reg; 75 tf.feature = reg;
76 tf.device = link->pmp; 76 tf.device = link->pmp;
77 tf.nsect = val & 0xff; 77 tf.nsect = val & 0xff;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index f888babc8283..7b1f1ee8131d 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1694,12 +1694,17 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1694 u8 *rbuf; 1694 u8 *rbuf;
1695 unsigned int buflen, rc; 1695 unsigned int buflen, rc;
1696 struct scsi_cmnd *cmd = args->cmd; 1696 struct scsi_cmnd *cmd = args->cmd;
1697 unsigned long flags;
1698
1699 local_irq_save(flags);
1697 1700
1698 buflen = ata_scsi_rbuf_get(cmd, &rbuf); 1701 buflen = ata_scsi_rbuf_get(cmd, &rbuf);
1699 memset(rbuf, 0, buflen); 1702 memset(rbuf, 0, buflen);
1700 rc = actor(args, rbuf, buflen); 1703 rc = actor(args, rbuf, buflen);
1701 ata_scsi_rbuf_put(cmd, rbuf); 1704 ata_scsi_rbuf_put(cmd, rbuf);
1702 1705
1706 local_irq_restore(flags);
1707
1703 if (rc == 0) 1708 if (rc == 0)
1704 cmd->result = SAM_STAT_GOOD; 1709 cmd->result = SAM_STAT_GOOD;
1705 args->done(cmd); 1710 args->done(cmd);
@@ -2473,6 +2478,9 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2473 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { 2478 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
2474 u8 *buf = NULL; 2479 u8 *buf = NULL;
2475 unsigned int buflen; 2480 unsigned int buflen;
2481 unsigned long flags;
2482
2483 local_irq_save(flags);
2476 2484
2477 buflen = ata_scsi_rbuf_get(cmd, &buf); 2485 buflen = ata_scsi_rbuf_get(cmd, &buf);
2478 2486
@@ -2490,6 +2498,8 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2490 } 2498 }
2491 2499
2492 ata_scsi_rbuf_put(cmd, buf); 2500 ata_scsi_rbuf_put(cmd, buf);
2501
2502 local_irq_restore(flags);
2493 } 2503 }
2494 2504
2495 cmd->result = SAM_STAT_GOOD; 2505 cmd->result = SAM_STAT_GOOD;
@@ -2582,7 +2592,8 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2582 qc->tf.protocol = ATAPI_PROT_DMA; 2592 qc->tf.protocol = ATAPI_PROT_DMA;
2583 qc->tf.feature |= ATAPI_PKT_DMA; 2593 qc->tf.feature |= ATAPI_PKT_DMA;
2584 2594
2585 if (atapi_dmadir && (scmd->sc_data_direction != DMA_TO_DEVICE)) 2595 if ((dev->flags & ATA_DFLAG_DMADIR) &&
2596 (scmd->sc_data_direction != DMA_TO_DEVICE))
2586 /* some SATA bridges need us to indicate data xfer direction */ 2597 /* some SATA bridges need us to indicate data xfer direction */
2587 qc->tf.feature |= ATAPI_DMADIR; 2598 qc->tf.feature |= ATAPI_DMADIR;
2588 } 2599 }
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 6036dedfe377..aa884f71a12a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -56,7 +56,6 @@ enum {
56extern unsigned int ata_print_id; 56extern unsigned int ata_print_id;
57extern struct workqueue_struct *ata_aux_wq; 57extern struct workqueue_struct *ata_aux_wq;
58extern int atapi_enabled; 58extern int atapi_enabled;
59extern int atapi_dmadir;
60extern int atapi_passthru16; 59extern int atapi_passthru16;
61extern int libata_fua; 60extern int libata_fua;
62extern int libata_noacpi; 61extern int libata_noacpi;
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 9623f5295530..408bdc1a9776 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -227,7 +227,7 @@ static struct scsi_host_template atiixp_sht = {
227 .queuecommand = ata_scsi_queuecmd, 227 .queuecommand = ata_scsi_queuecmd,
228 .can_queue = ATA_DEF_QUEUE, 228 .can_queue = ATA_DEF_QUEUE,
229 .this_id = ATA_SHT_THIS_ID, 229 .this_id = ATA_SHT_THIS_ID,
230 .sg_tablesize = LIBATA_MAX_PRD, 230 .sg_tablesize = LIBATA_DUMB_MAX_PRD,
231 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 231 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
232 .emulated = ATA_SHT_EMULATED, 232 .emulated = ATA_SHT_EMULATED,
233 .use_clustering = ATA_SHT_USE_CLUSTERING, 233 .use_clustering = ATA_SHT_USE_CLUSTERING,
@@ -259,7 +259,7 @@ static struct ata_port_operations atiixp_port_ops = {
259 .bmdma_stop = atiixp_bmdma_stop, 259 .bmdma_stop = atiixp_bmdma_stop,
260 .bmdma_status = ata_bmdma_status, 260 .bmdma_status = ata_bmdma_status,
261 261
262 .qc_prep = ata_qc_prep, 262 .qc_prep = ata_dumb_qc_prep,
263 .qc_issue = ata_qc_issue_prot, 263 .qc_issue = ata_qc_issue_prot,
264 264
265 .data_xfer = ata_data_xfer, 265 .data_xfer = ata_data_xfer,
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 9323dd0c7d8d..07791a7a48a5 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -335,7 +335,7 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
335 dma_addr_t indirect_ext_segment_paddr; 335 dma_addr_t indirect_ext_segment_paddr;
336 unsigned int si; 336 unsigned int si;
337 337
338 VPRINTK("SATA FSL : cd = 0x%x, prd = 0x%x\n", cmd_desc, prd); 338 VPRINTK("SATA FSL : cd = 0x%p, prd = 0x%p\n", cmd_desc, prd);
339 339
340 indirect_ext_segment_paddr = cmd_desc_paddr + 340 indirect_ext_segment_paddr = cmd_desc_paddr +
341 SATA_FSL_CMD_DESC_OFFSET_TO_PRDT + SATA_FSL_MAX_PRD_DIRECT * 16; 341 SATA_FSL_CMD_DESC_OFFSET_TO_PRDT + SATA_FSL_MAX_PRD_DIRECT * 16;
@@ -459,7 +459,8 @@ static unsigned int sata_fsl_qc_issue(struct ata_queued_cmd *qc)
459 VPRINTK("CE=0x%x, DE=0x%x, CC=0x%x, CmdStat = 0x%x\n", 459 VPRINTK("CE=0x%x, DE=0x%x, CC=0x%x, CmdStat = 0x%x\n",
460 ioread32(CE + hcr_base), 460 ioread32(CE + hcr_base),
461 ioread32(DE + hcr_base), 461 ioread32(DE + hcr_base),
462 ioread32(CC + hcr_base), ioread32(COMMANDSTAT + csr_base)); 462 ioread32(CC + hcr_base),
463 ioread32(COMMANDSTAT + host_priv->csr_base));
463 464
464 return 0; 465 return 0;
465} 466}
@@ -522,7 +523,8 @@ static void sata_fsl_freeze(struct ata_port *ap)
522 ioread32(CQ + hcr_base), 523 ioread32(CQ + hcr_base),
523 ioread32(CA + hcr_base), 524 ioread32(CA + hcr_base),
524 ioread32(CE + hcr_base), ioread32(DE + hcr_base)); 525 ioread32(CE + hcr_base), ioread32(DE + hcr_base));
525 VPRINTK("CmdStat = 0x%x\n", ioread32(csr_base + COMMANDSTAT)); 526 VPRINTK("CmdStat = 0x%x\n",
527 ioread32(host_priv->csr_base + COMMANDSTAT));
526 528
527 /* disable interrupts on the controller/port */ 529 /* disable interrupts on the controller/port */
528 temp = ioread32(hcr_base + HCONTROL); 530 temp = ioread32(hcr_base + HCONTROL);
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 69f651e0bc98..840d1c4a7850 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -45,6 +45,8 @@
45#include <linux/interrupt.h> 45#include <linux/interrupt.h>
46#include <linux/device.h> 46#include <linux/device.h>
47#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
48#include <scsi/scsi_cmnd.h>
49#include <scsi/scsi.h>
48#include <linux/libata.h> 50#include <linux/libata.h>
49 51
50#ifdef CONFIG_PPC_OF 52#ifdef CONFIG_PPC_OF
@@ -59,6 +61,7 @@ enum {
59 /* ap->flags bits */ 61 /* ap->flags bits */
60 K2_FLAG_SATA_8_PORTS = (1 << 24), 62 K2_FLAG_SATA_8_PORTS = (1 << 24),
61 K2_FLAG_NO_ATAPI_DMA = (1 << 25), 63 K2_FLAG_NO_ATAPI_DMA = (1 << 25),
64 K2_FLAG_BAR_POS_3 = (1 << 26),
62 65
63 /* Taskfile registers offsets */ 66 /* Taskfile registers offsets */
64 K2_SATA_TF_CMD_OFFSET = 0x00, 67 K2_SATA_TF_CMD_OFFSET = 0x00,
@@ -88,8 +91,10 @@ enum {
88 /* Port stride */ 91 /* Port stride */
89 K2_SATA_PORT_OFFSET = 0x100, 92 K2_SATA_PORT_OFFSET = 0x100,
90 93
91 board_svw4 = 0, 94 chip_svw4 = 0,
92 board_svw8 = 1, 95 chip_svw8 = 1,
96 chip_svw42 = 2, /* bar 3 */
97 chip_svw43 = 3, /* bar 5 */
93}; 98};
94 99
95static u8 k2_stat_check_status(struct ata_port *ap); 100static u8 k2_stat_check_status(struct ata_port *ap);
@@ -97,10 +102,25 @@ static u8 k2_stat_check_status(struct ata_port *ap);
97 102
98static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc) 103static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc)
99{ 104{
105 u8 cmnd = qc->scsicmd->cmnd[0];
106
100 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA) 107 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA)
101 return -1; /* ATAPI DMA not supported */ 108 return -1; /* ATAPI DMA not supported */
109 else {
110 switch (cmnd) {
111 case READ_10:
112 case READ_12:
113 case READ_16:
114 case WRITE_10:
115 case WRITE_12:
116 case WRITE_16:
117 return 0;
118
119 default:
120 return -1;
121 }
102 122
103 return 0; 123 }
104} 124}
105 125
106static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 126static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
@@ -354,7 +374,7 @@ static const struct ata_port_operations k2_sata_ops = {
354}; 374};
355 375
356static const struct ata_port_info k2_port_info[] = { 376static const struct ata_port_info k2_port_info[] = {
357 /* board_svw4 */ 377 /* chip_svw4 */
358 { 378 {
359 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 379 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
360 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA, 380 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA,
@@ -363,7 +383,7 @@ static const struct ata_port_info k2_port_info[] = {
363 .udma_mask = ATA_UDMA6, 383 .udma_mask = ATA_UDMA6,
364 .port_ops = &k2_sata_ops, 384 .port_ops = &k2_sata_ops,
365 }, 385 },
366 /* board_svw8 */ 386 /* chip_svw8 */
367 { 387 {
368 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 388 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
369 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA | 389 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA |
@@ -373,6 +393,24 @@ static const struct ata_port_info k2_port_info[] = {
373 .udma_mask = ATA_UDMA6, 393 .udma_mask = ATA_UDMA6,
374 .port_ops = &k2_sata_ops, 394 .port_ops = &k2_sata_ops,
375 }, 395 },
396 /* chip_svw42 */
397 {
398 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
399 ATA_FLAG_MMIO | K2_FLAG_BAR_POS_3,
400 .pio_mask = 0x1f,
401 .mwdma_mask = 0x07,
402 .udma_mask = ATA_UDMA6,
403 .port_ops = &k2_sata_ops,
404 },
405 /* chip_svw43 */
406 {
407 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
408 ATA_FLAG_MMIO,
409 .pio_mask = 0x1f,
410 .mwdma_mask = 0x07,
411 .udma_mask = ATA_UDMA6,
412 .port_ops = &k2_sata_ops,
413 },
376}; 414};
377 415
378static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) 416static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
@@ -402,7 +440,7 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
402 { &k2_port_info[ent->driver_data], NULL }; 440 { &k2_port_info[ent->driver_data], NULL };
403 struct ata_host *host; 441 struct ata_host *host;
404 void __iomem *mmio_base; 442 void __iomem *mmio_base;
405 int n_ports, i, rc; 443 int n_ports, i, rc, bar_pos;
406 444
407 if (!printed_version++) 445 if (!printed_version++)
408 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 446 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
@@ -416,6 +454,9 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
416 if (!host) 454 if (!host)
417 return -ENOMEM; 455 return -ENOMEM;
418 456
457 bar_pos = 5;
458 if (ppi[0]->flags & K2_FLAG_BAR_POS_3)
459 bar_pos = 3;
419 /* 460 /*
420 * If this driver happens to only be useful on Apple's K2, then 461 * If this driver happens to only be useful on Apple's K2, then
421 * we should check that here as it has a normal Serverworks ID 462 * we should check that here as it has a normal Serverworks ID
@@ -428,17 +469,23 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
428 * Check if we have resources mapped at all (second function may 469 * Check if we have resources mapped at all (second function may
429 * have been disabled by firmware) 470 * have been disabled by firmware)
430 */ 471 */
431 if (pci_resource_len(pdev, 5) == 0) 472 if (pci_resource_len(pdev, bar_pos) == 0) {
473 /* In IDE mode we need to pin the device to ensure that
474 pcim_release does not clear the busmaster bit in config
475 space, clearing causes busmaster DMA to fail on
476 ports 3 & 4 */
477 pcim_pin_device(pdev);
432 return -ENODEV; 478 return -ENODEV;
479 }
433 480
434 /* Request and iomap PCI regions */ 481 /* Request and iomap PCI regions */
435 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); 482 rc = pcim_iomap_regions(pdev, 1 << bar_pos, DRV_NAME);
436 if (rc == -EBUSY) 483 if (rc == -EBUSY)
437 pcim_pin_device(pdev); 484 pcim_pin_device(pdev);
438 if (rc) 485 if (rc)
439 return rc; 486 return rc;
440 host->iomap = pcim_iomap_table(pdev); 487 host->iomap = pcim_iomap_table(pdev);
441 mmio_base = host->iomap[5]; 488 mmio_base = host->iomap[bar_pos];
442 489
443 /* different controllers have different number of ports - currently 4 or 8 */ 490 /* different controllers have different number of ports - currently 4 or 8 */
444 /* All ports are on the same function. Multi-function device is no 491 /* All ports are on the same function. Multi-function device is no
@@ -483,11 +530,13 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
483 * controller 530 * controller
484 * */ 531 * */
485static const struct pci_device_id k2_sata_pci_tbl[] = { 532static const struct pci_device_id k2_sata_pci_tbl[] = {
486 { PCI_VDEVICE(SERVERWORKS, 0x0240), board_svw4 }, 533 { PCI_VDEVICE(SERVERWORKS, 0x0240), chip_svw4 },
487 { PCI_VDEVICE(SERVERWORKS, 0x0241), board_svw4 }, 534 { PCI_VDEVICE(SERVERWORKS, 0x0241), chip_svw4 },
488 { PCI_VDEVICE(SERVERWORKS, 0x0242), board_svw8 }, 535 { PCI_VDEVICE(SERVERWORKS, 0x0242), chip_svw8 },
489 { PCI_VDEVICE(SERVERWORKS, 0x024a), board_svw4 }, 536 { PCI_VDEVICE(SERVERWORKS, 0x024a), chip_svw4 },
490 { PCI_VDEVICE(SERVERWORKS, 0x024b), board_svw4 }, 537 { PCI_VDEVICE(SERVERWORKS, 0x024b), chip_svw4 },
538 { PCI_VDEVICE(SERVERWORKS, 0x0410), chip_svw42 },
539 { PCI_VDEVICE(SERVERWORKS, 0x0411), chip_svw43 },
491 540
492 { } 541 { }
493}; 542};
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 78b151c4d20f..5c3142b6f1fc 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -110,8 +110,8 @@ static int rtc_has_irq = 1;
110#define hpet_set_rtc_irq_bit(arg) 0 110#define hpet_set_rtc_irq_bit(arg) 0
111#define hpet_rtc_timer_init() do { } while (0) 111#define hpet_rtc_timer_init() do { } while (0)
112#define hpet_rtc_dropped_irq() 0 112#define hpet_rtc_dropped_irq() 0
113#define hpet_register_irq_handler(h) 0 113#define hpet_register_irq_handler(h) ({ 0; })
114#define hpet_unregister_irq_handler(h) 0 114#define hpet_unregister_irq_handler(h) ({ 0; })
115#ifdef RTC_IRQ 115#ifdef RTC_IRQ
116static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) 116static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
117{ 117{
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index fea2d3ed9cbd..85e2ba7fcfba 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -47,7 +47,7 @@ static LIST_HEAD(notify_list);
47 47
48static struct cn_dev cdev; 48static struct cn_dev cdev;
49 49
50int cn_already_initialized = 0; 50static int cn_already_initialized;
51 51
52/* 52/*
53 * msg->seq and msg->ack are used to determine message genealogy. 53 * msg->seq and msg->ack are used to determine message genealogy.
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 3e9719948a8e..a03462750b95 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/delay.h>
21#include <linux/device.h> 22#include <linux/device.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23#include <linux/crc-itu-t.h> 24#include <linux/crc-itu-t.h>
@@ -214,17 +215,29 @@ static void
214fw_card_bm_work(struct work_struct *work) 215fw_card_bm_work(struct work_struct *work)
215{ 216{
216 struct fw_card *card = container_of(work, struct fw_card, work.work); 217 struct fw_card *card = container_of(work, struct fw_card, work.work);
217 struct fw_device *root; 218 struct fw_device *root_device;
219 struct fw_node *root_node, *local_node;
218 struct bm_data bmd; 220 struct bm_data bmd;
219 unsigned long flags; 221 unsigned long flags;
220 int root_id, new_root_id, irm_id, gap_count, generation, grace; 222 int root_id, new_root_id, irm_id, gap_count, generation, grace;
221 int do_reset = 0; 223 int do_reset = 0;
222 224
223 spin_lock_irqsave(&card->lock, flags); 225 spin_lock_irqsave(&card->lock, flags);
226 local_node = card->local_node;
227 root_node = card->root_node;
228
229 if (local_node == NULL) {
230 spin_unlock_irqrestore(&card->lock, flags);
231 return;
232 }
233 fw_node_get(local_node);
234 fw_node_get(root_node);
224 235
225 generation = card->generation; 236 generation = card->generation;
226 root = card->root_node->data; 237 root_device = root_node->data;
227 root_id = card->root_node->node_id; 238 if (root_device)
239 fw_device_get(root_device);
240 root_id = root_node->node_id;
228 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 241 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
229 242
230 if (card->bm_generation + 1 == generation || 243 if (card->bm_generation + 1 == generation ||
@@ -243,14 +256,14 @@ fw_card_bm_work(struct work_struct *work)
243 256
244 irm_id = card->irm_node->node_id; 257 irm_id = card->irm_node->node_id;
245 if (!card->irm_node->link_on) { 258 if (!card->irm_node->link_on) {
246 new_root_id = card->local_node->node_id; 259 new_root_id = local_node->node_id;
247 fw_notify("IRM has link off, making local node (%02x) root.\n", 260 fw_notify("IRM has link off, making local node (%02x) root.\n",
248 new_root_id); 261 new_root_id);
249 goto pick_me; 262 goto pick_me;
250 } 263 }
251 264
252 bmd.lock.arg = cpu_to_be32(0x3f); 265 bmd.lock.arg = cpu_to_be32(0x3f);
253 bmd.lock.data = cpu_to_be32(card->local_node->node_id); 266 bmd.lock.data = cpu_to_be32(local_node->node_id);
254 267
255 spin_unlock_irqrestore(&card->lock, flags); 268 spin_unlock_irqrestore(&card->lock, flags);
256 269
@@ -267,12 +280,12 @@ fw_card_bm_work(struct work_struct *work)
267 * Another bus reset happened. Just return, 280 * Another bus reset happened. Just return,
268 * the BM work has been rescheduled. 281 * the BM work has been rescheduled.
269 */ 282 */
270 return; 283 goto out;
271 } 284 }
272 285
273 if (bmd.rcode == RCODE_COMPLETE && bmd.old != 0x3f) 286 if (bmd.rcode == RCODE_COMPLETE && bmd.old != 0x3f)
274 /* Somebody else is BM, let them do the work. */ 287 /* Somebody else is BM, let them do the work. */
275 return; 288 goto out;
276 289
277 spin_lock_irqsave(&card->lock, flags); 290 spin_lock_irqsave(&card->lock, flags);
278 if (bmd.rcode != RCODE_COMPLETE) { 291 if (bmd.rcode != RCODE_COMPLETE) {
@@ -282,7 +295,7 @@ fw_card_bm_work(struct work_struct *work)
282 * do a bus reset and pick the local node as 295 * do a bus reset and pick the local node as
283 * root, and thus, IRM. 296 * root, and thus, IRM.
284 */ 297 */
285 new_root_id = card->local_node->node_id; 298 new_root_id = local_node->node_id;
286 fw_notify("BM lock failed, making local node (%02x) root.\n", 299 fw_notify("BM lock failed, making local node (%02x) root.\n",
287 new_root_id); 300 new_root_id);
288 goto pick_me; 301 goto pick_me;
@@ -295,7 +308,7 @@ fw_card_bm_work(struct work_struct *work)
295 */ 308 */
296 spin_unlock_irqrestore(&card->lock, flags); 309 spin_unlock_irqrestore(&card->lock, flags);
297 schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10)); 310 schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10));
298 return; 311 goto out;
299 } 312 }
300 313
301 /* 314 /*
@@ -305,20 +318,20 @@ fw_card_bm_work(struct work_struct *work)
305 */ 318 */
306 card->bm_generation = generation; 319 card->bm_generation = generation;
307 320
308 if (root == NULL) { 321 if (root_device == NULL) {
309 /* 322 /*
310 * Either link_on is false, or we failed to read the 323 * Either link_on is false, or we failed to read the
311 * config rom. In either case, pick another root. 324 * config rom. In either case, pick another root.
312 */ 325 */
313 new_root_id = card->local_node->node_id; 326 new_root_id = local_node->node_id;
314 } else if (atomic_read(&root->state) != FW_DEVICE_RUNNING) { 327 } else if (atomic_read(&root_device->state) != FW_DEVICE_RUNNING) {
315 /* 328 /*
316 * If we haven't probed this device yet, bail out now 329 * If we haven't probed this device yet, bail out now
317 * and let's try again once that's done. 330 * and let's try again once that's done.
318 */ 331 */
319 spin_unlock_irqrestore(&card->lock, flags); 332 spin_unlock_irqrestore(&card->lock, flags);
320 return; 333 goto out;
321 } else if (root->config_rom[2] & BIB_CMC) { 334 } else if (root_device->config_rom[2] & BIB_CMC) {
322 /* 335 /*
323 * FIXME: I suppose we should set the cmstr bit in the 336 * FIXME: I suppose we should set the cmstr bit in the
324 * STATE_CLEAR register of this node, as described in 337 * STATE_CLEAR register of this node, as described in
@@ -332,7 +345,7 @@ fw_card_bm_work(struct work_struct *work)
332 * successfully read the config rom, but it's not 345 * successfully read the config rom, but it's not
333 * cycle master capable. 346 * cycle master capable.
334 */ 347 */
335 new_root_id = card->local_node->node_id; 348 new_root_id = local_node->node_id;
336 } 349 }
337 350
338 pick_me: 351 pick_me:
@@ -341,8 +354,8 @@ fw_card_bm_work(struct work_struct *work)
341 * the typically much larger 1394b beta repeater delays though. 354 * the typically much larger 1394b beta repeater delays though.
342 */ 355 */
343 if (!card->beta_repeaters_present && 356 if (!card->beta_repeaters_present &&
344 card->root_node->max_hops < ARRAY_SIZE(gap_count_table)) 357 root_node->max_hops < ARRAY_SIZE(gap_count_table))
345 gap_count = gap_count_table[card->root_node->max_hops]; 358 gap_count = gap_count_table[root_node->max_hops];
346 else 359 else
347 gap_count = 63; 360 gap_count = 63;
348 361
@@ -364,6 +377,11 @@ fw_card_bm_work(struct work_struct *work)
364 fw_send_phy_config(card, new_root_id, generation, gap_count); 377 fw_send_phy_config(card, new_root_id, generation, gap_count);
365 fw_core_initiate_bus_reset(card, 1); 378 fw_core_initiate_bus_reset(card, 1);
366 } 379 }
380 out:
381 if (root_device)
382 fw_device_put(root_device);
383 fw_node_put(root_node);
384 fw_node_put(local_node);
367} 385}
368 386
369static void 387static void
@@ -381,6 +399,7 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
381 static atomic_t index = ATOMIC_INIT(-1); 399 static atomic_t index = ATOMIC_INIT(-1);
382 400
383 kref_init(&card->kref); 401 kref_init(&card->kref);
402 atomic_set(&card->device_count, 0);
384 card->index = atomic_inc_return(&index); 403 card->index = atomic_inc_return(&index);
385 card->driver = driver; 404 card->driver = driver;
386 card->device = device; 405 card->device = device;
@@ -511,8 +530,14 @@ fw_core_remove_card(struct fw_card *card)
511 card->driver = &dummy_driver; 530 card->driver = &dummy_driver;
512 531
513 fw_destroy_nodes(card); 532 fw_destroy_nodes(card);
514 flush_scheduled_work(); 533 /*
534 * Wait for all device workqueue jobs to finish. Otherwise the
535 * firewire-core module could be unloaded before the jobs ran.
536 */
537 while (atomic_read(&card->device_count) > 0)
538 msleep(100);
515 539
540 cancel_delayed_work_sync(&card->work);
516 fw_flush_transactions(card); 541 fw_flush_transactions(card);
517 del_timer_sync(&card->flush_timer); 542 del_timer_sync(&card->flush_timer);
518 543
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 7e73cbaa4121..46bc197a047f 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -109,15 +109,17 @@ static int fw_device_op_open(struct inode *inode, struct file *file)
109 struct client *client; 109 struct client *client;
110 unsigned long flags; 110 unsigned long flags;
111 111
112 device = fw_device_from_devt(inode->i_rdev); 112 device = fw_device_get_by_devt(inode->i_rdev);
113 if (device == NULL) 113 if (device == NULL)
114 return -ENODEV; 114 return -ENODEV;
115 115
116 client = kzalloc(sizeof(*client), GFP_KERNEL); 116 client = kzalloc(sizeof(*client), GFP_KERNEL);
117 if (client == NULL) 117 if (client == NULL) {
118 fw_device_put(device);
118 return -ENOMEM; 119 return -ENOMEM;
120 }
119 121
120 client->device = fw_device_get(device); 122 client->device = device;
121 INIT_LIST_HEAD(&client->event_list); 123 INIT_LIST_HEAD(&client->event_list);
122 INIT_LIST_HEAD(&client->resource_list); 124 INIT_LIST_HEAD(&client->resource_list);
123 spin_lock_init(&client->lock); 125 spin_lock_init(&client->lock);
@@ -644,6 +646,10 @@ static int ioctl_create_iso_context(struct client *client, void *buffer)
644 struct fw_cdev_create_iso_context *request = buffer; 646 struct fw_cdev_create_iso_context *request = buffer;
645 struct fw_iso_context *context; 647 struct fw_iso_context *context;
646 648
649 /* We only support one context at this time. */
650 if (client->iso_context != NULL)
651 return -EBUSY;
652
647 if (request->channel > 63) 653 if (request->channel > 63)
648 return -EINVAL; 654 return -EINVAL;
649 655
@@ -790,8 +796,9 @@ static int ioctl_start_iso(struct client *client, void *buffer)
790{ 796{
791 struct fw_cdev_start_iso *request = buffer; 797 struct fw_cdev_start_iso *request = buffer;
792 798
793 if (request->handle != 0) 799 if (client->iso_context == NULL || request->handle != 0)
794 return -EINVAL; 800 return -EINVAL;
801
795 if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE) { 802 if (client->iso_context->type == FW_ISO_CONTEXT_RECEIVE) {
796 if (request->tags == 0 || request->tags > 15) 803 if (request->tags == 0 || request->tags > 15)
797 return -EINVAL; 804 return -EINVAL;
@@ -808,7 +815,7 @@ static int ioctl_stop_iso(struct client *client, void *buffer)
808{ 815{
809 struct fw_cdev_stop_iso *request = buffer; 816 struct fw_cdev_stop_iso *request = buffer;
810 817
811 if (request->handle != 0) 818 if (client->iso_context == NULL || request->handle != 0)
812 return -EINVAL; 819 return -EINVAL;
813 820
814 return fw_iso_context_stop(client->iso_context); 821 return fw_iso_context_stop(client->iso_context);
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index de9066e69adf..870125a3638e 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -150,21 +150,10 @@ struct bus_type fw_bus_type = {
150}; 150};
151EXPORT_SYMBOL(fw_bus_type); 151EXPORT_SYMBOL(fw_bus_type);
152 152
153struct fw_device *fw_device_get(struct fw_device *device)
154{
155 get_device(&device->device);
156
157 return device;
158}
159
160void fw_device_put(struct fw_device *device)
161{
162 put_device(&device->device);
163}
164
165static void fw_device_release(struct device *dev) 153static void fw_device_release(struct device *dev)
166{ 154{
167 struct fw_device *device = fw_device(dev); 155 struct fw_device *device = fw_device(dev);
156 struct fw_card *card = device->card;
168 unsigned long flags; 157 unsigned long flags;
169 158
170 /* 159 /*
@@ -176,9 +165,9 @@ static void fw_device_release(struct device *dev)
176 spin_unlock_irqrestore(&device->card->lock, flags); 165 spin_unlock_irqrestore(&device->card->lock, flags);
177 166
178 fw_node_put(device->node); 167 fw_node_put(device->node);
179 fw_card_put(device->card);
180 kfree(device->config_rom); 168 kfree(device->config_rom);
181 kfree(device); 169 kfree(device);
170 atomic_dec(&card->device_count);
182} 171}
183 172
184int fw_device_enable_phys_dma(struct fw_device *device) 173int fw_device_enable_phys_dma(struct fw_device *device)
@@ -358,12 +347,9 @@ static ssize_t
358guid_show(struct device *dev, struct device_attribute *attr, char *buf) 347guid_show(struct device *dev, struct device_attribute *attr, char *buf)
359{ 348{
360 struct fw_device *device = fw_device(dev); 349 struct fw_device *device = fw_device(dev);
361 u64 guid;
362
363 guid = ((u64)device->config_rom[3] << 32) | device->config_rom[4];
364 350
365 return snprintf(buf, PAGE_SIZE, "0x%016llx\n", 351 return snprintf(buf, PAGE_SIZE, "0x%08x%08x\n",
366 (unsigned long long)guid); 352 device->config_rom[3], device->config_rom[4]);
367} 353}
368 354
369static struct device_attribute fw_device_attributes[] = { 355static struct device_attribute fw_device_attributes[] = {
@@ -610,12 +596,14 @@ static DECLARE_RWSEM(idr_rwsem);
610static DEFINE_IDR(fw_device_idr); 596static DEFINE_IDR(fw_device_idr);
611int fw_cdev_major; 597int fw_cdev_major;
612 598
613struct fw_device *fw_device_from_devt(dev_t devt) 599struct fw_device *fw_device_get_by_devt(dev_t devt)
614{ 600{
615 struct fw_device *device; 601 struct fw_device *device;
616 602
617 down_read(&idr_rwsem); 603 down_read(&idr_rwsem);
618 device = idr_find(&fw_device_idr, MINOR(devt)); 604 device = idr_find(&fw_device_idr, MINOR(devt));
605 if (device)
606 fw_device_get(device);
619 up_read(&idr_rwsem); 607 up_read(&idr_rwsem);
620 608
621 return device; 609 return device;
@@ -627,13 +615,14 @@ static void fw_device_shutdown(struct work_struct *work)
627 container_of(work, struct fw_device, work.work); 615 container_of(work, struct fw_device, work.work);
628 int minor = MINOR(device->device.devt); 616 int minor = MINOR(device->device.devt);
629 617
630 down_write(&idr_rwsem);
631 idr_remove(&fw_device_idr, minor);
632 up_write(&idr_rwsem);
633
634 fw_device_cdev_remove(device); 618 fw_device_cdev_remove(device);
635 device_for_each_child(&device->device, NULL, shutdown_unit); 619 device_for_each_child(&device->device, NULL, shutdown_unit);
636 device_unregister(&device->device); 620 device_unregister(&device->device);
621
622 down_write(&idr_rwsem);
623 idr_remove(&fw_device_idr, minor);
624 up_write(&idr_rwsem);
625 fw_device_put(device);
637} 626}
638 627
639static struct device_type fw_device_type = { 628static struct device_type fw_device_type = {
@@ -668,7 +657,8 @@ static void fw_device_init(struct work_struct *work)
668 */ 657 */
669 658
670 if (read_bus_info_block(device, device->generation) < 0) { 659 if (read_bus_info_block(device, device->generation) < 0) {
671 if (device->config_rom_retries < MAX_RETRIES) { 660 if (device->config_rom_retries < MAX_RETRIES &&
661 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
672 device->config_rom_retries++; 662 device->config_rom_retries++;
673 schedule_delayed_work(&device->work, RETRY_DELAY); 663 schedule_delayed_work(&device->work, RETRY_DELAY);
674 } else { 664 } else {
@@ -682,10 +672,13 @@ static void fw_device_init(struct work_struct *work)
682 } 672 }
683 673
684 err = -ENOMEM; 674 err = -ENOMEM;
675
676 fw_device_get(device);
685 down_write(&idr_rwsem); 677 down_write(&idr_rwsem);
686 if (idr_pre_get(&fw_device_idr, GFP_KERNEL)) 678 if (idr_pre_get(&fw_device_idr, GFP_KERNEL))
687 err = idr_get_new(&fw_device_idr, device, &minor); 679 err = idr_get_new(&fw_device_idr, device, &minor);
688 up_write(&idr_rwsem); 680 up_write(&idr_rwsem);
681
689 if (err < 0) 682 if (err < 0)
690 goto error; 683 goto error;
691 684
@@ -717,13 +710,22 @@ static void fw_device_init(struct work_struct *work)
717 */ 710 */
718 if (atomic_cmpxchg(&device->state, 711 if (atomic_cmpxchg(&device->state,
719 FW_DEVICE_INITIALIZING, 712 FW_DEVICE_INITIALIZING,
720 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) 713 FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) {
721 fw_device_shutdown(&device->work.work); 714 fw_device_shutdown(&device->work.work);
722 else 715 } else {
723 fw_notify("created new fw device %s " 716 if (device->config_rom_retries)
724 "(%d config rom retries, S%d00)\n", 717 fw_notify("created device %s: GUID %08x%08x, S%d00, "
725 device->device.bus_id, device->config_rom_retries, 718 "%d config ROM retries\n",
726 1 << device->max_speed); 719 device->device.bus_id,
720 device->config_rom[3], device->config_rom[4],
721 1 << device->max_speed,
722 device->config_rom_retries);
723 else
724 fw_notify("created device %s: GUID %08x%08x, S%d00\n",
725 device->device.bus_id,
726 device->config_rom[3], device->config_rom[4],
727 1 << device->max_speed);
728 }
727 729
728 /* 730 /*
729 * Reschedule the IRM work if we just finished reading the 731 * Reschedule the IRM work if we just finished reading the
@@ -741,7 +743,9 @@ static void fw_device_init(struct work_struct *work)
741 idr_remove(&fw_device_idr, minor); 743 idr_remove(&fw_device_idr, minor);
742 up_write(&idr_rwsem); 744 up_write(&idr_rwsem);
743 error: 745 error:
744 put_device(&device->device); 746 fw_device_put(device); /* fw_device_idr's reference */
747
748 put_device(&device->device); /* our reference */
745} 749}
746 750
747static int update_unit(struct device *dev, void *data) 751static int update_unit(struct device *dev, void *data)
@@ -791,7 +795,8 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
791 */ 795 */
792 device_initialize(&device->device); 796 device_initialize(&device->device);
793 atomic_set(&device->state, FW_DEVICE_INITIALIZING); 797 atomic_set(&device->state, FW_DEVICE_INITIALIZING);
794 device->card = fw_card_get(card); 798 atomic_inc(&card->device_count);
799 device->card = card;
795 device->node = fw_node_get(node); 800 device->node = fw_node_get(node);
796 device->node_id = node->node_id; 801 device->node_id = node->node_id;
797 device->generation = card->generation; 802 device->generation = card->generation;
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 0854fe2bc110..78ecd3991b7f 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -76,14 +76,26 @@ fw_device_is_shutdown(struct fw_device *device)
76 return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; 76 return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN;
77} 77}
78 78
79struct fw_device *fw_device_get(struct fw_device *device); 79static inline struct fw_device *
80void fw_device_put(struct fw_device *device); 80fw_device_get(struct fw_device *device)
81{
82 get_device(&device->device);
83
84 return device;
85}
86
87static inline void
88fw_device_put(struct fw_device *device)
89{
90 put_device(&device->device);
91}
92
93struct fw_device *fw_device_get_by_devt(dev_t devt);
81int fw_device_enable_phys_dma(struct fw_device *device); 94int fw_device_enable_phys_dma(struct fw_device *device);
82 95
83void fw_device_cdev_update(struct fw_device *device); 96void fw_device_cdev_update(struct fw_device *device);
84void fw_device_cdev_remove(struct fw_device *device); 97void fw_device_cdev_remove(struct fw_device *device);
85 98
86struct fw_device *fw_device_from_devt(dev_t devt);
87extern int fw_cdev_major; 99extern int fw_cdev_major;
88 100
89struct fw_unit { 101struct fw_unit {
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 19ece9b6d742..03069a454c07 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -28,14 +28,15 @@
28 * and many others. 28 * and many others.
29 */ 29 */
30 30
31#include <linux/blkdev.h>
32#include <linux/delay.h>
33#include <linux/device.h>
34#include <linux/dma-mapping.h>
31#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/mod_devicetable.h>
32#include <linux/module.h> 37#include <linux/module.h>
33#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
34#include <linux/mod_devicetable.h>
35#include <linux/device.h>
36#include <linux/scatterlist.h> 39#include <linux/scatterlist.h>
37#include <linux/dma-mapping.h>
38#include <linux/blkdev.h>
39#include <linux/string.h> 40#include <linux/string.h>
40#include <linux/stringify.h> 41#include <linux/stringify.h>
41#include <linux/timer.h> 42#include <linux/timer.h>
@@ -47,9 +48,9 @@
47#include <scsi/scsi_device.h> 48#include <scsi/scsi_device.h>
48#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
49 50
50#include "fw-transaction.h"
51#include "fw-topology.h"
52#include "fw-device.h" 51#include "fw-device.h"
52#include "fw-topology.h"
53#include "fw-transaction.h"
53 54
54/* 55/*
55 * So far only bridges from Oxford Semiconductor are known to support 56 * So far only bridges from Oxford Semiconductor are known to support
@@ -82,6 +83,9 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
82 * Avoids access beyond actual disk limits on devices with an off-by-one bug. 83 * Avoids access beyond actual disk limits on devices with an off-by-one bug.
83 * Don't use this with devices which don't have this bug. 84 * Don't use this with devices which don't have this bug.
84 * 85 *
86 * - delay inquiry
87 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
88 *
85 * - override internal blacklist 89 * - override internal blacklist
86 * Instead of adding to the built-in blacklist, use only the workarounds 90 * Instead of adding to the built-in blacklist, use only the workarounds
87 * specified in the module load parameter. 91 * specified in the module load parameter.
@@ -91,6 +95,8 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
91#define SBP2_WORKAROUND_INQUIRY_36 0x2 95#define SBP2_WORKAROUND_INQUIRY_36 0x2
92#define SBP2_WORKAROUND_MODE_SENSE_8 0x4 96#define SBP2_WORKAROUND_MODE_SENSE_8 0x4
93#define SBP2_WORKAROUND_FIX_CAPACITY 0x8 97#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
98#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10
99#define SBP2_INQUIRY_DELAY 12
94#define SBP2_WORKAROUND_OVERRIDE 0x100 100#define SBP2_WORKAROUND_OVERRIDE 0x100
95 101
96static int sbp2_param_workarounds; 102static int sbp2_param_workarounds;
@@ -100,6 +106,7 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
100 ", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36) 106 ", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36)
101 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8) 107 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
102 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY) 108 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
109 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
103 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 110 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
104 ", or a combination)"); 111 ", or a combination)");
105 112
@@ -115,7 +122,6 @@ static const char sbp2_driver_name[] = "sbp2";
115struct sbp2_logical_unit { 122struct sbp2_logical_unit {
116 struct sbp2_target *tgt; 123 struct sbp2_target *tgt;
117 struct list_head link; 124 struct list_head link;
118 struct scsi_device *sdev;
119 struct fw_address_handler address_handler; 125 struct fw_address_handler address_handler;
120 struct list_head orb_list; 126 struct list_head orb_list;
121 127
@@ -132,6 +138,8 @@ struct sbp2_logical_unit {
132 int generation; 138 int generation;
133 int retries; 139 int retries;
134 struct delayed_work work; 140 struct delayed_work work;
141 bool has_sdev;
142 bool blocked;
135}; 143};
136 144
137/* 145/*
@@ -141,16 +149,18 @@ struct sbp2_logical_unit {
141struct sbp2_target { 149struct sbp2_target {
142 struct kref kref; 150 struct kref kref;
143 struct fw_unit *unit; 151 struct fw_unit *unit;
152 const char *bus_id;
153 struct list_head lu_list;
144 154
145 u64 management_agent_address; 155 u64 management_agent_address;
146 int directory_id; 156 int directory_id;
147 int node_id; 157 int node_id;
148 int address_high; 158 int address_high;
149 159 unsigned int workarounds;
150 unsigned workarounds;
151 struct list_head lu_list;
152
153 unsigned int mgt_orb_timeout; 160 unsigned int mgt_orb_timeout;
161
162 int dont_block; /* counter for each logical unit */
163 int blocked; /* ditto */
154}; 164};
155 165
156/* 166/*
@@ -160,7 +170,7 @@ struct sbp2_target {
160 */ 170 */
161#define SBP2_MIN_LOGIN_ORB_TIMEOUT 5000U /* Timeout in ms */ 171#define SBP2_MIN_LOGIN_ORB_TIMEOUT 5000U /* Timeout in ms */
162#define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */ 172#define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */
163#define SBP2_ORB_TIMEOUT 2000 /* Timeout in ms */ 173#define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */
164#define SBP2_ORB_NULL 0x80000000 174#define SBP2_ORB_NULL 0x80000000
165#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 175#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
166 176
@@ -297,7 +307,7 @@ struct sbp2_command_orb {
297static const struct { 307static const struct {
298 u32 firmware_revision; 308 u32 firmware_revision;
299 u32 model; 309 u32 model;
300 unsigned workarounds; 310 unsigned int workarounds;
301} sbp2_workarounds_table[] = { 311} sbp2_workarounds_table[] = {
302 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ { 312 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
303 .firmware_revision = 0x002800, 313 .firmware_revision = 0x002800,
@@ -305,6 +315,11 @@ static const struct {
305 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 315 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
306 SBP2_WORKAROUND_MODE_SENSE_8, 316 SBP2_WORKAROUND_MODE_SENSE_8,
307 }, 317 },
318 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
319 .firmware_revision = 0x002800,
320 .model = 0x000000,
321 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY,
322 },
308 /* Initio bridges, actually only needed for some older ones */ { 323 /* Initio bridges, actually only needed for some older ones */ {
309 .firmware_revision = 0x000200, 324 .firmware_revision = 0x000200,
310 .model = ~0, 325 .model = ~0,
@@ -501,6 +516,9 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
501 unsigned int timeout; 516 unsigned int timeout;
502 int retval = -ENOMEM; 517 int retval = -ENOMEM;
503 518
519 if (function == SBP2_LOGOUT_REQUEST && fw_device_is_shutdown(device))
520 return 0;
521
504 orb = kzalloc(sizeof(*orb), GFP_ATOMIC); 522 orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
505 if (orb == NULL) 523 if (orb == NULL)
506 return -ENOMEM; 524 return -ENOMEM;
@@ -553,20 +571,20 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
553 571
554 retval = -EIO; 572 retval = -EIO;
555 if (sbp2_cancel_orbs(lu) == 0) { 573 if (sbp2_cancel_orbs(lu) == 0) {
556 fw_error("orb reply timed out, rcode=0x%02x\n", 574 fw_error("%s: orb reply timed out, rcode=0x%02x\n",
557 orb->base.rcode); 575 lu->tgt->bus_id, orb->base.rcode);
558 goto out; 576 goto out;
559 } 577 }
560 578
561 if (orb->base.rcode != RCODE_COMPLETE) { 579 if (orb->base.rcode != RCODE_COMPLETE) {
562 fw_error("management write failed, rcode 0x%02x\n", 580 fw_error("%s: management write failed, rcode 0x%02x\n",
563 orb->base.rcode); 581 lu->tgt->bus_id, orb->base.rcode);
564 goto out; 582 goto out;
565 } 583 }
566 584
567 if (STATUS_GET_RESPONSE(orb->status) != 0 || 585 if (STATUS_GET_RESPONSE(orb->status) != 0 ||
568 STATUS_GET_SBP_STATUS(orb->status) != 0) { 586 STATUS_GET_SBP_STATUS(orb->status) != 0) {
569 fw_error("error status: %d:%d\n", 587 fw_error("%s: error status: %d:%d\n", lu->tgt->bus_id,
570 STATUS_GET_RESPONSE(orb->status), 588 STATUS_GET_RESPONSE(orb->status),
571 STATUS_GET_SBP_STATUS(orb->status)); 589 STATUS_GET_SBP_STATUS(orb->status));
572 goto out; 590 goto out;
@@ -590,29 +608,158 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
590 608
591static void 609static void
592complete_agent_reset_write(struct fw_card *card, int rcode, 610complete_agent_reset_write(struct fw_card *card, int rcode,
593 void *payload, size_t length, void *data) 611 void *payload, size_t length, void *done)
594{ 612{
595 struct fw_transaction *t = data; 613 complete(done);
614}
596 615
597 kfree(t); 616static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
617{
618 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
619 DECLARE_COMPLETION_ONSTACK(done);
620 struct fw_transaction t;
621 static u32 z;
622
623 fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST,
624 lu->tgt->node_id, lu->generation, device->max_speed,
625 lu->command_block_agent_address + SBP2_AGENT_RESET,
626 &z, sizeof(z), complete_agent_reset_write, &done);
627 wait_for_completion(&done);
628}
629
630static void
631complete_agent_reset_write_no_wait(struct fw_card *card, int rcode,
632 void *payload, size_t length, void *data)
633{
634 kfree(data);
598} 635}
599 636
600static int sbp2_agent_reset(struct sbp2_logical_unit *lu) 637static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
601{ 638{
602 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 639 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
603 struct fw_transaction *t; 640 struct fw_transaction *t;
604 static u32 zero; 641 static u32 z;
605 642
606 t = kzalloc(sizeof(*t), GFP_ATOMIC); 643 t = kmalloc(sizeof(*t), GFP_ATOMIC);
607 if (t == NULL) 644 if (t == NULL)
608 return -ENOMEM; 645 return;
609 646
610 fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, 647 fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
611 lu->tgt->node_id, lu->generation, device->max_speed, 648 lu->tgt->node_id, lu->generation, device->max_speed,
612 lu->command_block_agent_address + SBP2_AGENT_RESET, 649 lu->command_block_agent_address + SBP2_AGENT_RESET,
613 &zero, sizeof(zero), complete_agent_reset_write, t); 650 &z, sizeof(z), complete_agent_reset_write_no_wait, t);
651}
614 652
615 return 0; 653static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation)
654{
655 struct fw_card *card = fw_device(lu->tgt->unit->device.parent)->card;
656 unsigned long flags;
657
658 /* serialize with comparisons of lu->generation and card->generation */
659 spin_lock_irqsave(&card->lock, flags);
660 lu->generation = generation;
661 spin_unlock_irqrestore(&card->lock, flags);
662}
663
664static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
665{
666 /*
667 * We may access dont_block without taking card->lock here:
668 * All callers of sbp2_allow_block() and all callers of sbp2_unblock()
669 * are currently serialized against each other.
670 * And a wrong result in sbp2_conditionally_block()'s access of
671 * dont_block is rather harmless, it simply misses its first chance.
672 */
673 --lu->tgt->dont_block;
674}
675
676/*
677 * Blocks lu->tgt if all of the following conditions are met:
678 * - Login, INQUIRY, and high-level SCSI setup of all of the target's
679 * logical units have been finished (indicated by dont_block == 0).
680 * - lu->generation is stale.
681 *
682 * Note, scsi_block_requests() must be called while holding card->lock,
683 * otherwise it might foil sbp2_[conditionally_]unblock()'s attempt to
684 * unblock the target.
685 */
686static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
687{
688 struct sbp2_target *tgt = lu->tgt;
689 struct fw_card *card = fw_device(tgt->unit->device.parent)->card;
690 struct Scsi_Host *shost =
691 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
692 unsigned long flags;
693
694 spin_lock_irqsave(&card->lock, flags);
695 if (!tgt->dont_block && !lu->blocked &&
696 lu->generation != card->generation) {
697 lu->blocked = true;
698 if (++tgt->blocked == 1) {
699 scsi_block_requests(shost);
700 fw_notify("blocked %s\n", lu->tgt->bus_id);
701 }
702 }
703 spin_unlock_irqrestore(&card->lock, flags);
704}
705
706/*
707 * Unblocks lu->tgt as soon as all its logical units can be unblocked.
708 * Note, it is harmless to run scsi_unblock_requests() outside the
709 * card->lock protected section. On the other hand, running it inside
710 * the section might clash with shost->host_lock.
711 */
712static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
713{
714 struct sbp2_target *tgt = lu->tgt;
715 struct fw_card *card = fw_device(tgt->unit->device.parent)->card;
716 struct Scsi_Host *shost =
717 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
718 unsigned long flags;
719 bool unblock = false;
720
721 spin_lock_irqsave(&card->lock, flags);
722 if (lu->blocked && lu->generation == card->generation) {
723 lu->blocked = false;
724 unblock = --tgt->blocked == 0;
725 }
726 spin_unlock_irqrestore(&card->lock, flags);
727
728 if (unblock) {
729 scsi_unblock_requests(shost);
730 fw_notify("unblocked %s\n", lu->tgt->bus_id);
731 }
732}
733
734/*
735 * Prevents future blocking of tgt and unblocks it.
736 * Note, it is harmless to run scsi_unblock_requests() outside the
737 * card->lock protected section. On the other hand, running it inside
738 * the section might clash with shost->host_lock.
739 */
740static void sbp2_unblock(struct sbp2_target *tgt)
741{
742 struct fw_card *card = fw_device(tgt->unit->device.parent)->card;
743 struct Scsi_Host *shost =
744 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
745 unsigned long flags;
746
747 spin_lock_irqsave(&card->lock, flags);
748 ++tgt->dont_block;
749 spin_unlock_irqrestore(&card->lock, flags);
750
751 scsi_unblock_requests(shost);
752}
753
754static int sbp2_lun2int(u16 lun)
755{
756 struct scsi_lun eight_bytes_lun;
757
758 memset(&eight_bytes_lun, 0, sizeof(eight_bytes_lun));
759 eight_bytes_lun.scsi_lun[0] = (lun >> 8) & 0xff;
760 eight_bytes_lun.scsi_lun[1] = lun & 0xff;
761
762 return scsilun_to_int(&eight_bytes_lun);
616} 763}
617 764
618static void sbp2_release_target(struct kref *kref) 765static void sbp2_release_target(struct kref *kref)
@@ -621,26 +768,31 @@ static void sbp2_release_target(struct kref *kref)
621 struct sbp2_logical_unit *lu, *next; 768 struct sbp2_logical_unit *lu, *next;
622 struct Scsi_Host *shost = 769 struct Scsi_Host *shost =
623 container_of((void *)tgt, struct Scsi_Host, hostdata[0]); 770 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
771 struct scsi_device *sdev;
624 struct fw_device *device = fw_device(tgt->unit->device.parent); 772 struct fw_device *device = fw_device(tgt->unit->device.parent);
625 773
626 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) { 774 /* prevent deadlocks */
627 if (lu->sdev) 775 sbp2_unblock(tgt);
628 scsi_remove_device(lu->sdev);
629 776
630 if (!fw_device_is_shutdown(device)) 777 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
631 sbp2_send_management_orb(lu, tgt->node_id, 778 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun));
632 lu->generation, SBP2_LOGOUT_REQUEST, 779 if (sdev) {
633 lu->login_id, NULL); 780 scsi_remove_device(sdev);
781 scsi_device_put(sdev);
782 }
783 sbp2_send_management_orb(lu, tgt->node_id, lu->generation,
784 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
634 785
635 fw_core_remove_address_handler(&lu->address_handler); 786 fw_core_remove_address_handler(&lu->address_handler);
636 list_del(&lu->link); 787 list_del(&lu->link);
637 kfree(lu); 788 kfree(lu);
638 } 789 }
639 scsi_remove_host(shost); 790 scsi_remove_host(shost);
640 fw_notify("released %s\n", tgt->unit->device.bus_id); 791 fw_notify("released %s\n", tgt->bus_id);
641 792
642 put_device(&tgt->unit->device); 793 put_device(&tgt->unit->device);
643 scsi_host_put(shost); 794 scsi_host_put(shost);
795 fw_device_put(device);
644} 796}
645 797
646static struct workqueue_struct *sbp2_wq; 798static struct workqueue_struct *sbp2_wq;
@@ -666,33 +818,42 @@ static void sbp2_login(struct work_struct *work)
666{ 818{
667 struct sbp2_logical_unit *lu = 819 struct sbp2_logical_unit *lu =
668 container_of(work, struct sbp2_logical_unit, work.work); 820 container_of(work, struct sbp2_logical_unit, work.work);
669 struct Scsi_Host *shost = 821 struct sbp2_target *tgt = lu->tgt;
670 container_of((void *)lu->tgt, struct Scsi_Host, hostdata[0]); 822 struct fw_device *device = fw_device(tgt->unit->device.parent);
823 struct Scsi_Host *shost;
671 struct scsi_device *sdev; 824 struct scsi_device *sdev;
672 struct scsi_lun eight_bytes_lun;
673 struct fw_unit *unit = lu->tgt->unit;
674 struct fw_device *device = fw_device(unit->device.parent);
675 struct sbp2_login_response response; 825 struct sbp2_login_response response;
676 int generation, node_id, local_node_id; 826 int generation, node_id, local_node_id;
677 827
828 if (fw_device_is_shutdown(device))
829 goto out;
830
678 generation = device->generation; 831 generation = device->generation;
679 smp_rmb(); /* node_id must not be older than generation */ 832 smp_rmb(); /* node_id must not be older than generation */
680 node_id = device->node_id; 833 node_id = device->node_id;
681 local_node_id = device->card->node_id; 834 local_node_id = device->card->node_id;
682 835
836 /* If this is a re-login attempt, log out, or we might be rejected. */
837 if (lu->has_sdev)
838 sbp2_send_management_orb(lu, device->node_id, generation,
839 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
840
683 if (sbp2_send_management_orb(lu, node_id, generation, 841 if (sbp2_send_management_orb(lu, node_id, generation,
684 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) { 842 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
685 if (lu->retries++ < 5) 843 if (lu->retries++ < 5) {
686 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); 844 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
687 else 845 } else {
688 fw_error("failed to login to %s LUN %04x\n", 846 fw_error("%s: failed to login to LUN %04x\n",
689 unit->device.bus_id, lu->lun); 847 tgt->bus_id, lu->lun);
848 /* Let any waiting I/O fail from now on. */
849 sbp2_unblock(lu->tgt);
850 }
690 goto out; 851 goto out;
691 } 852 }
692 853
693 lu->generation = generation; 854 tgt->node_id = node_id;
694 lu->tgt->node_id = node_id; 855 tgt->address_high = local_node_id << 16;
695 lu->tgt->address_high = local_node_id << 16; 856 sbp2_set_generation(lu, generation);
696 857
697 /* Get command block agent offset and login id. */ 858 /* Get command block agent offset and login id. */
698 lu->command_block_agent_address = 859 lu->command_block_agent_address =
@@ -700,8 +861,8 @@ static void sbp2_login(struct work_struct *work)
700 response.command_block_agent.low; 861 response.command_block_agent.low;
701 lu->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response); 862 lu->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
702 863
703 fw_notify("logged in to %s LUN %04x (%d retries)\n", 864 fw_notify("%s: logged in to LUN %04x (%d retries)\n",
704 unit->device.bus_id, lu->lun, lu->retries); 865 tgt->bus_id, lu->lun, lu->retries);
705 866
706#if 0 867#if 0
707 /* FIXME: The linux1394 sbp2 does this last step. */ 868 /* FIXME: The linux1394 sbp2 does this last step. */
@@ -711,26 +872,58 @@ static void sbp2_login(struct work_struct *work)
711 PREPARE_DELAYED_WORK(&lu->work, sbp2_reconnect); 872 PREPARE_DELAYED_WORK(&lu->work, sbp2_reconnect);
712 sbp2_agent_reset(lu); 873 sbp2_agent_reset(lu);
713 874
714 memset(&eight_bytes_lun, 0, sizeof(eight_bytes_lun)); 875 /* This was a re-login. */
715 eight_bytes_lun.scsi_lun[0] = (lu->lun >> 8) & 0xff; 876 if (lu->has_sdev) {
716 eight_bytes_lun.scsi_lun[1] = lu->lun & 0xff; 877 sbp2_cancel_orbs(lu);
878 sbp2_conditionally_unblock(lu);
879 goto out;
880 }
717 881
718 sdev = __scsi_add_device(shost, 0, 0, 882 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
719 scsilun_to_int(&eight_bytes_lun), lu); 883 ssleep(SBP2_INQUIRY_DELAY);
720 if (IS_ERR(sdev)) { 884
721 sbp2_send_management_orb(lu, node_id, generation, 885 shost = container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
722 SBP2_LOGOUT_REQUEST, lu->login_id, NULL); 886 sdev = __scsi_add_device(shost, 0, 0, sbp2_lun2int(lu->lun), lu);
723 /* 887 /*
724 * Set this back to sbp2_login so we fall back and 888 * FIXME: We are unable to perform reconnects while in sbp2_login().
725 * retry login on bus reset. 889 * Therefore __scsi_add_device() will get into trouble if a bus reset
726 */ 890 * happens in parallel. It will either fail or leave us with an
727 PREPARE_DELAYED_WORK(&lu->work, sbp2_login); 891 * unusable sdev. As a workaround we check for this and retry the
728 } else { 892 * whole login and SCSI probing.
729 lu->sdev = sdev; 893 */
894
895 /* Reported error during __scsi_add_device() */
896 if (IS_ERR(sdev))
897 goto out_logout_login;
898
899 /* Unreported error during __scsi_add_device() */
900 smp_rmb(); /* get current card generation */
901 if (generation != device->card->generation) {
902 scsi_remove_device(sdev);
730 scsi_device_put(sdev); 903 scsi_device_put(sdev);
904 goto out_logout_login;
731 } 905 }
906
907 /* No error during __scsi_add_device() */
908 lu->has_sdev = true;
909 scsi_device_put(sdev);
910 sbp2_allow_block(lu);
911 goto out;
912
913 out_logout_login:
914 smp_rmb(); /* generation may have changed */
915 generation = device->generation;
916 smp_rmb(); /* node_id must not be older than generation */
917
918 sbp2_send_management_orb(lu, device->node_id, generation,
919 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
920 /*
921 * If a bus reset happened, sbp2_update will have requeued
922 * lu->work already. Reset the work from reconnect to login.
923 */
924 PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
732 out: 925 out:
733 sbp2_target_put(lu->tgt); 926 sbp2_target_put(tgt);
734} 927}
735 928
736static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry) 929static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry)
@@ -751,10 +944,12 @@ static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry)
751 return -ENOMEM; 944 return -ENOMEM;
752 } 945 }
753 946
754 lu->tgt = tgt; 947 lu->tgt = tgt;
755 lu->sdev = NULL; 948 lu->lun = lun_entry & 0xffff;
756 lu->lun = lun_entry & 0xffff; 949 lu->retries = 0;
757 lu->retries = 0; 950 lu->has_sdev = false;
951 lu->blocked = false;
952 ++tgt->dont_block;
758 INIT_LIST_HEAD(&lu->orb_list); 953 INIT_LIST_HEAD(&lu->orb_list);
759 INIT_DELAYED_WORK(&lu->work, sbp2_login); 954 INIT_DELAYED_WORK(&lu->work, sbp2_login);
760 955
@@ -813,7 +1008,7 @@ static int sbp2_scan_unit_dir(struct sbp2_target *tgt, u32 *directory,
813 if (timeout > tgt->mgt_orb_timeout) 1008 if (timeout > tgt->mgt_orb_timeout)
814 fw_notify("%s: config rom contains %ds " 1009 fw_notify("%s: config rom contains %ds "
815 "management ORB timeout, limiting " 1010 "management ORB timeout, limiting "
816 "to %ds\n", tgt->unit->device.bus_id, 1011 "to %ds\n", tgt->bus_id,
817 timeout / 1000, 1012 timeout / 1000,
818 tgt->mgt_orb_timeout / 1000); 1013 tgt->mgt_orb_timeout / 1000);
819 break; 1014 break;
@@ -836,12 +1031,12 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
836 u32 firmware_revision) 1031 u32 firmware_revision)
837{ 1032{
838 int i; 1033 int i;
839 unsigned w = sbp2_param_workarounds; 1034 unsigned int w = sbp2_param_workarounds;
840 1035
841 if (w) 1036 if (w)
842 fw_notify("Please notify linux1394-devel@lists.sourceforge.net " 1037 fw_notify("Please notify linux1394-devel@lists.sourceforge.net "
843 "if you need the workarounds parameter for %s\n", 1038 "if you need the workarounds parameter for %s\n",
844 tgt->unit->device.bus_id); 1039 tgt->bus_id);
845 1040
846 if (w & SBP2_WORKAROUND_OVERRIDE) 1041 if (w & SBP2_WORKAROUND_OVERRIDE)
847 goto out; 1042 goto out;
@@ -863,8 +1058,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
863 if (w) 1058 if (w)
864 fw_notify("Workarounds for %s: 0x%x " 1059 fw_notify("Workarounds for %s: 0x%x "
865 "(firmware_revision 0x%06x, model_id 0x%06x)\n", 1060 "(firmware_revision 0x%06x, model_id 0x%06x)\n",
866 tgt->unit->device.bus_id, 1061 tgt->bus_id, w, firmware_revision, model);
867 w, firmware_revision, model);
868 tgt->workarounds = w; 1062 tgt->workarounds = w;
869} 1063}
870 1064
@@ -888,6 +1082,7 @@ static int sbp2_probe(struct device *dev)
888 tgt->unit = unit; 1082 tgt->unit = unit;
889 kref_init(&tgt->kref); 1083 kref_init(&tgt->kref);
890 INIT_LIST_HEAD(&tgt->lu_list); 1084 INIT_LIST_HEAD(&tgt->lu_list);
1085 tgt->bus_id = unit->device.bus_id;
891 1086
892 if (fw_device_enable_phys_dma(device) < 0) 1087 if (fw_device_enable_phys_dma(device) < 0)
893 goto fail_shost_put; 1088 goto fail_shost_put;
@@ -895,6 +1090,8 @@ static int sbp2_probe(struct device *dev)
895 if (scsi_add_host(shost, &unit->device) < 0) 1090 if (scsi_add_host(shost, &unit->device) < 0)
896 goto fail_shost_put; 1091 goto fail_shost_put;
897 1092
1093 fw_device_get(device);
1094
898 /* Initialize to values that won't match anything in our table. */ 1095 /* Initialize to values that won't match anything in our table. */
899 firmware_revision = 0xff000000; 1096 firmware_revision = 0xff000000;
900 model = 0xff000000; 1097 model = 0xff000000;
@@ -938,10 +1135,13 @@ static void sbp2_reconnect(struct work_struct *work)
938{ 1135{
939 struct sbp2_logical_unit *lu = 1136 struct sbp2_logical_unit *lu =
940 container_of(work, struct sbp2_logical_unit, work.work); 1137 container_of(work, struct sbp2_logical_unit, work.work);
941 struct fw_unit *unit = lu->tgt->unit; 1138 struct sbp2_target *tgt = lu->tgt;
942 struct fw_device *device = fw_device(unit->device.parent); 1139 struct fw_device *device = fw_device(tgt->unit->device.parent);
943 int generation, node_id, local_node_id; 1140 int generation, node_id, local_node_id;
944 1141
1142 if (fw_device_is_shutdown(device))
1143 goto out;
1144
945 generation = device->generation; 1145 generation = device->generation;
946 smp_rmb(); /* node_id must not be older than generation */ 1146 smp_rmb(); /* node_id must not be older than generation */
947 node_id = device->node_id; 1147 node_id = device->node_id;
@@ -950,10 +1150,17 @@ static void sbp2_reconnect(struct work_struct *work)
950 if (sbp2_send_management_orb(lu, node_id, generation, 1150 if (sbp2_send_management_orb(lu, node_id, generation,
951 SBP2_RECONNECT_REQUEST, 1151 SBP2_RECONNECT_REQUEST,
952 lu->login_id, NULL) < 0) { 1152 lu->login_id, NULL) < 0) {
953 if (lu->retries++ >= 5) { 1153 /*
954 fw_error("failed to reconnect to %s\n", 1154 * If reconnect was impossible even though we are in the
955 unit->device.bus_id); 1155 * current generation, fall back and try to log in again.
956 /* Fall back and try to log in again. */ 1156 *
1157 * We could check for "Function rejected" status, but
1158 * looking at the bus generation as simpler and more general.
1159 */
1160 smp_rmb(); /* get current card generation */
1161 if (generation == device->card->generation ||
1162 lu->retries++ >= 5) {
1163 fw_error("%s: failed to reconnect\n", tgt->bus_id);
957 lu->retries = 0; 1164 lu->retries = 0;
958 PREPARE_DELAYED_WORK(&lu->work, sbp2_login); 1165 PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
959 } 1166 }
@@ -961,17 +1168,18 @@ static void sbp2_reconnect(struct work_struct *work)
961 goto out; 1168 goto out;
962 } 1169 }
963 1170
964 lu->generation = generation; 1171 tgt->node_id = node_id;
965 lu->tgt->node_id = node_id; 1172 tgt->address_high = local_node_id << 16;
966 lu->tgt->address_high = local_node_id << 16; 1173 sbp2_set_generation(lu, generation);
967 1174
968 fw_notify("reconnected to %s LUN %04x (%d retries)\n", 1175 fw_notify("%s: reconnected to LUN %04x (%d retries)\n",
969 unit->device.bus_id, lu->lun, lu->retries); 1176 tgt->bus_id, lu->lun, lu->retries);
970 1177
971 sbp2_agent_reset(lu); 1178 sbp2_agent_reset(lu);
972 sbp2_cancel_orbs(lu); 1179 sbp2_cancel_orbs(lu);
1180 sbp2_conditionally_unblock(lu);
973 out: 1181 out:
974 sbp2_target_put(lu->tgt); 1182 sbp2_target_put(tgt);
975} 1183}
976 1184
977static void sbp2_update(struct fw_unit *unit) 1185static void sbp2_update(struct fw_unit *unit)
@@ -986,6 +1194,7 @@ static void sbp2_update(struct fw_unit *unit)
986 * Iteration over tgt->lu_list is therefore safe here. 1194 * Iteration over tgt->lu_list is therefore safe here.
987 */ 1195 */
988 list_for_each_entry(lu, &tgt->lu_list, link) { 1196 list_for_each_entry(lu, &tgt->lu_list, link) {
1197 sbp2_conditionally_block(lu);
989 lu->retries = 0; 1198 lu->retries = 0;
990 sbp2_queue_work(lu, 0); 1199 sbp2_queue_work(lu, 0);
991 } 1200 }
@@ -1063,7 +1272,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
1063 1272
1064 if (status != NULL) { 1273 if (status != NULL) {
1065 if (STATUS_GET_DEAD(*status)) 1274 if (STATUS_GET_DEAD(*status))
1066 sbp2_agent_reset(orb->lu); 1275 sbp2_agent_reset_no_wait(orb->lu);
1067 1276
1068 switch (STATUS_GET_RESPONSE(*status)) { 1277 switch (STATUS_GET_RESPONSE(*status)) {
1069 case SBP2_STATUS_REQUEST_COMPLETE: 1278 case SBP2_STATUS_REQUEST_COMPLETE:
@@ -1089,6 +1298,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
1089 * or when sending the write (less likely). 1298 * or when sending the write (less likely).
1090 */ 1299 */
1091 result = DID_BUS_BUSY << 16; 1300 result = DID_BUS_BUSY << 16;
1301 sbp2_conditionally_block(orb->lu);
1092 } 1302 }
1093 1303
1094 dma_unmap_single(device->card->device, orb->base.request_bus, 1304 dma_unmap_single(device->card->device, orb->base.request_bus,
@@ -1197,7 +1407,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1197 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1407 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1198 struct fw_device *device = fw_device(lu->tgt->unit->device.parent); 1408 struct fw_device *device = fw_device(lu->tgt->unit->device.parent);
1199 struct sbp2_command_orb *orb; 1409 struct sbp2_command_orb *orb;
1200 unsigned max_payload; 1410 unsigned int max_payload;
1201 int retval = SCSI_MLQUEUE_HOST_BUSY; 1411 int retval = SCSI_MLQUEUE_HOST_BUSY;
1202 1412
1203 /* 1413 /*
@@ -1275,6 +1485,10 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
1275{ 1485{
1276 struct sbp2_logical_unit *lu = sdev->hostdata; 1486 struct sbp2_logical_unit *lu = sdev->hostdata;
1277 1487
1488 /* (Re-)Adding logical units via the SCSI stack is not supported. */
1489 if (!lu)
1490 return -ENOSYS;
1491
1278 sdev->allow_restart = 1; 1492 sdev->allow_restart = 1;
1279 1493
1280 /* 1494 /*
@@ -1319,7 +1533,7 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
1319{ 1533{
1320 struct sbp2_logical_unit *lu = cmd->device->hostdata; 1534 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1321 1535
1322 fw_notify("sbp2_scsi_abort\n"); 1536 fw_notify("%s: sbp2_scsi_abort\n", lu->tgt->bus_id);
1323 sbp2_agent_reset(lu); 1537 sbp2_agent_reset(lu);
1324 sbp2_cancel_orbs(lu); 1538 sbp2_cancel_orbs(lu);
1325 1539
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index 172c1867e9aa..e47bb040197a 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -383,6 +383,7 @@ void fw_destroy_nodes(struct fw_card *card)
383 card->color++; 383 card->color++;
384 if (card->local_node != NULL) 384 if (card->local_node != NULL)
385 for_each_fw_node(card, card->local_node, report_lost_node); 385 for_each_fw_node(card, card->local_node, report_lost_node);
386 card->local_node = NULL;
386 spin_unlock_irqrestore(&card->lock, flags); 387 spin_unlock_irqrestore(&card->lock, flags);
387} 388}
388 389
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index fa7967b57408..09cb72870454 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -26,6 +26,7 @@
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/firewire-constants.h> 28#include <linux/firewire-constants.h>
29#include <asm/atomic.h>
29 30
30#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) 31#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
31#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) 32#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0)
@@ -219,6 +220,7 @@ extern struct bus_type fw_bus_type;
219struct fw_card { 220struct fw_card {
220 const struct fw_card_driver *driver; 221 const struct fw_card_driver *driver;
221 struct device *device; 222 struct device *device;
223 atomic_t device_count;
222 struct kref kref; 224 struct kref kref;
223 225
224 int node_id; 226 int node_id;
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index b61f56b6f311..476b0bb72d6c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -177,6 +177,8 @@ config I2C_I801
177 ESB2 177 ESB2
178 ICH8 178 ICH8
179 ICH9 179 ICH9
180 Tolapai
181 ICH10
180 182
181 This driver can also be built as a module. If so, the module 183 This driver can also be built as a module. If so, the module
182 will be called i2c-i801. 184 will be called i2c-i801.
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index aa9157913b9a..b0f771fe4326 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -40,7 +40,9 @@
40 82801G (ICH7) 0x27da 32 hard yes yes yes 40 82801G (ICH7) 0x27da 32 hard yes yes yes
41 82801H (ICH8) 0x283e 32 hard yes yes yes 41 82801H (ICH8) 0x283e 32 hard yes yes yes
42 82801I (ICH9) 0x2930 32 hard yes yes yes 42 82801I (ICH9) 0x2930 32 hard yes yes yes
43 Tolapai 0x5032 32 hard yes ? ? 43 Tolapai 0x5032 32 hard yes yes yes
44 ICH10 0x3a30 32 hard yes yes yes
45 ICH10 0x3a60 32 hard yes yes yes
44 46
45 Features supported by this driver: 47 Features supported by this driver:
46 Software PEC no 48 Software PEC no
@@ -588,6 +590,8 @@ static struct pci_device_id i801_ids[] = {
588 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, 590 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) },
589 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) }, 591 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) },
590 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) }, 592 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) },
593 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) },
594 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) },
591 { 0, } 595 { 0, }
592}; 596};
593 597
@@ -608,10 +612,12 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
608 case PCI_DEVICE_ID_INTEL_ESB2_17: 612 case PCI_DEVICE_ID_INTEL_ESB2_17:
609 case PCI_DEVICE_ID_INTEL_ICH8_5: 613 case PCI_DEVICE_ID_INTEL_ICH8_5:
610 case PCI_DEVICE_ID_INTEL_ICH9_6: 614 case PCI_DEVICE_ID_INTEL_ICH9_6:
615 case PCI_DEVICE_ID_INTEL_TOLAPAI_1:
616 case PCI_DEVICE_ID_INTEL_ICH10_4:
617 case PCI_DEVICE_ID_INTEL_ICH10_5:
611 i801_features |= FEATURE_I2C_BLOCK_READ; 618 i801_features |= FEATURE_I2C_BLOCK_READ;
612 /* fall through */ 619 /* fall through */
613 case PCI_DEVICE_ID_INTEL_82801DB_3: 620 case PCI_DEVICE_ID_INTEL_82801DB_3:
614 case PCI_DEVICE_ID_INTEL_TOLAPAI_1:
615 i801_features |= FEATURE_SMBUS_PEC; 621 i801_features |= FEATURE_SMBUS_PEC;
616 i801_features |= FEATURE_BLOCK_BUFFER; 622 i801_features |= FEATURE_BLOCK_BUFFER;
617 break; 623 break;
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 5161aaf9341b..496ee875eb4f 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -125,6 +125,13 @@ static int __devinit pca_isa_probe(struct device *dev, unsigned int id)
125 125
126 dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq); 126 dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq);
127 127
128#ifdef CONFIG_PPC_MERGE
129 if (check_legacy_ioport(base)) {
130 dev_err(dev, "I/O address %#08lx is not available\n", base);
131 goto out;
132 }
133#endif
134
128 if (!request_region(base, IO_SIZE, "i2c-pca-isa")) { 135 if (!request_region(base, IO_SIZE, "i2c-pca-isa")) {
129 dev_err(dev, "I/O address %#08lx is in use\n", base); 136 dev_err(dev, "I/O address %#08lx is in use\n", base);
130 goto out; 137 goto out;
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index be99c02ecac5..b03af5653c65 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -122,7 +122,7 @@ struct pmcmsptwi_data {
122}; 122};
123 123
124/* The default settings */ 124/* The default settings */
125const static struct pmcmsptwi_clockcfg pmcmsptwi_defclockcfg = { 125static const struct pmcmsptwi_clockcfg pmcmsptwi_defclockcfg = {
126 .standard = { 126 .standard = {
127 .filter = 0x3, 127 .filter = 0x3,
128 .clock = 0x1f, 128 .clock = 0x1f,
@@ -133,7 +133,7 @@ const static struct pmcmsptwi_clockcfg pmcmsptwi_defclockcfg = {
133 }, 133 },
134}; 134};
135 135
136const static struct pmcmsptwi_cfg pmcmsptwi_defcfg = { 136static const struct pmcmsptwi_cfg pmcmsptwi_defcfg = {
137 .arbf = 0x03, 137 .arbf = 0x03,
138 .nak = 0x03, 138 .nak = 0x03,
139 .add10 = 0x00, 139 .add10 = 0x00,
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 2b557bfd7f70..2d2087ad708f 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -999,7 +999,14 @@ static int i2c_pxa_probe(struct platform_device *dev)
999 spin_lock_init(&i2c->lock); 999 spin_lock_init(&i2c->lock);
1000 init_waitqueue_head(&i2c->wait); 1000 init_waitqueue_head(&i2c->wait);
1001 1001
1002 sprintf(i2c->adap.name, "pxa_i2c-i2c.%u", dev->id); 1002 /*
1003 * If "dev->id" is negative we consider it as zero.
1004 * The reason to do so is to avoid sysfs names that only make
1005 * sense when there are multiple adapters.
1006 */
1007 i2c->adap.nr = dev->id != -1 ? dev->id : 0;
1008 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa_i2c-i2c.%u",
1009 i2c->adap.nr);
1003 1010
1004 i2c->clk = clk_get(&dev->dev, "I2CCLK"); 1011 i2c->clk = clk_get(&dev->dev, "I2CCLK");
1005 if (IS_ERR(i2c->clk)) { 1012 if (IS_ERR(i2c->clk)) {
@@ -1050,13 +1057,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
1050 i2c->adap.algo_data = i2c; 1057 i2c->adap.algo_data = i2c;
1051 i2c->adap.dev.parent = &dev->dev; 1058 i2c->adap.dev.parent = &dev->dev;
1052 1059
1053 /*
1054 * If "dev->id" is negative we consider it as zero.
1055 * The reason to do so is to avoid sysfs names that only make
1056 * sense when there are multiple adapters.
1057 */
1058 i2c->adap.nr = dev->id != -1 ? dev->id : 0;
1059
1060 ret = i2c_add_numbered_adapter(&i2c->adap); 1060 ret = i2c_add_numbered_adapter(&i2c->adap);
1061 if (ret < 0) { 1061 if (ret < 0) {
1062 printk(KERN_INFO "I2C: Failed to add bus\n"); 1062 printk(KERN_INFO "I2C: Failed to add bus\n");
@@ -1080,6 +1080,7 @@ eadapt:
1080ereqirq: 1080ereqirq:
1081 clk_disable(i2c->clk); 1081 clk_disable(i2c->clk);
1082 i2c_pxa_disable(dev); 1082 i2c_pxa_disable(dev);
1083 iounmap(i2c->reg_base);
1083eremap: 1084eremap:
1084 clk_put(i2c->clk); 1085 clk_put(i2c->clk);
1085eclk: 1086eclk:
@@ -1089,7 +1090,7 @@ emalloc:
1089 return ret; 1090 return ret;
1090} 1091}
1091 1092
1092static int i2c_pxa_remove(struct platform_device *dev) 1093static int __exit i2c_pxa_remove(struct platform_device *dev)
1093{ 1094{
1094 struct pxa_i2c *i2c = platform_get_drvdata(dev); 1095 struct pxa_i2c *i2c = platform_get_drvdata(dev);
1095 1096
@@ -1103,6 +1104,7 @@ static int i2c_pxa_remove(struct platform_device *dev)
1103 clk_put(i2c->clk); 1104 clk_put(i2c->clk);
1104 i2c_pxa_disable(dev); 1105 i2c_pxa_disable(dev);
1105 1106
1107 iounmap(i2c->reg_base);
1106 release_mem_region(i2c->iobase, i2c->iosize); 1108 release_mem_region(i2c->iobase, i2c->iosize);
1107 kfree(i2c); 1109 kfree(i2c);
1108 1110
@@ -1111,9 +1113,10 @@ static int i2c_pxa_remove(struct platform_device *dev)
1111 1113
1112static struct platform_driver i2c_pxa_driver = { 1114static struct platform_driver i2c_pxa_driver = {
1113 .probe = i2c_pxa_probe, 1115 .probe = i2c_pxa_probe,
1114 .remove = i2c_pxa_remove, 1116 .remove = __exit_p(i2c_pxa_remove),
1115 .driver = { 1117 .driver = {
1116 .name = "pxa2xx-i2c", 1118 .name = "pxa2xx-i2c",
1119 .owner = THIS_MODULE,
1117 }, 1120 },
1118}; 1121};
1119 1122
@@ -1122,7 +1125,7 @@ static int __init i2c_adap_pxa_init(void)
1122 return platform_driver_register(&i2c_pxa_driver); 1125 return platform_driver_register(&i2c_pxa_driver);
1123} 1126}
1124 1127
1125static void i2c_adap_pxa_exit(void) 1128static void __exit i2c_adap_pxa_exit(void)
1126{ 1129{
1127 platform_driver_unregister(&i2c_pxa_driver); 1130 platform_driver_unregister(&i2c_pxa_driver);
1128} 1131}
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 310e497b5838..c8d0e8715997 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -670,8 +670,8 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
670 * and attempt to recover if there are problems. Returns 0 if everything's 670 * and attempt to recover if there are problems. Returns 0 if everything's
671 * ok; nonzero if the request has been terminated. 671 * ok; nonzero if the request has been terminated.
672 */ 672 */
673static 673static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
674int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw) 674 int len, int ireason, int rw)
675{ 675{
676 /* 676 /*
677 * ireason == 0: the drive wants to receive data from us 677 * ireason == 0: the drive wants to receive data from us
@@ -701,6 +701,9 @@ int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw)
701 drive->name, __FUNCTION__, ireason); 701 drive->name, __FUNCTION__, ireason);
702 } 702 }
703 703
704 if (rq->cmd_type == REQ_TYPE_ATA_PC)
705 rq->cmd_flags |= REQ_FAILED;
706
704 cdrom_end_request(drive, 0); 707 cdrom_end_request(drive, 0);
705 return -1; 708 return -1;
706} 709}
@@ -1071,11 +1074,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1071 /* 1074 /*
1072 * check which way to transfer data 1075 * check which way to transfer data
1073 */ 1076 */
1074 if (blk_fs_request(rq) || blk_pc_request(rq)) { 1077 if (ide_cd_check_ireason(drive, rq, len, ireason, write))
1075 if (ide_cd_check_ireason(drive, len, ireason, write)) 1078 return ide_stopped;
1076 return ide_stopped;
1077 1079
1078 if (blk_fs_request(rq) && write == 0) { 1080 if (blk_fs_request(rq)) {
1081 if (write == 0) {
1079 int nskip; 1082 int nskip;
1080 1083
1081 if (ide_cd_check_transfer_size(drive, len)) { 1084 if (ide_cd_check_transfer_size(drive, len)) {
@@ -1101,16 +1104,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1101 if (ireason == 0) { 1104 if (ireason == 0) {
1102 write = 1; 1105 write = 1;
1103 xferfunc = HWIF(drive)->atapi_output_bytes; 1106 xferfunc = HWIF(drive)->atapi_output_bytes;
1104 } else if (ireason == 2 || (ireason == 1 && 1107 } else {
1105 (blk_fs_request(rq) || blk_pc_request(rq)))) {
1106 write = 0; 1108 write = 0;
1107 xferfunc = HWIF(drive)->atapi_input_bytes; 1109 xferfunc = HWIF(drive)->atapi_input_bytes;
1108 } else {
1109 printk(KERN_ERR "%s: %s: The drive "
1110 "appears confused (ireason = 0x%02x). "
1111 "Trying to recover by ending request.\n",
1112 drive->name, __FUNCTION__, ireason);
1113 goto end_request;
1114 } 1110 }
1115 1111
1116 /* 1112 /*
@@ -1182,11 +1178,10 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1182 else 1178 else
1183 rq->data += blen; 1179 rq->data += blen;
1184 } 1180 }
1181 if (!write && blk_sense_request(rq))
1182 rq->sense_len += blen;
1185 } 1183 }
1186 1184
1187 if (write && blk_sense_request(rq))
1188 rq->sense_len += thislen;
1189
1190 /* 1185 /*
1191 * pad, if necessary 1186 * pad, if necessary
1192 */ 1187 */
@@ -1931,6 +1926,7 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
1931 { "MATSHITADVD-ROM SR-8186", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 1926 { "MATSHITADVD-ROM SR-8186", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK },
1932 { "MATSHITADVD-ROM SR-8176", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 1927 { "MATSHITADVD-ROM SR-8176", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK },
1933 { "MATSHITADVD-ROM SR-8174", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 1928 { "MATSHITADVD-ROM SR-8174", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK },
1929 { "Optiarc DVD RW AD-5200A", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK },
1934 { NULL, NULL, 0 } 1930 { NULL, NULL, 0 }
1935}; 1931};
1936 1932
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 8f5bed471050..39501d130256 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -867,7 +867,7 @@ static void idedisk_setup (ide_drive_t *drive)
867 867
868 /* Only print cache size when it was specified */ 868 /* Only print cache size when it was specified */
869 if (id->buf_size) 869 if (id->buf_size)
870 printk (" w/%dKiB Cache", id->buf_size/2); 870 printk(KERN_CONT " w/%dKiB Cache", id->buf_size / 2);
871 871
872 printk(KERN_CONT ", CHS=%d/%d/%d\n", 872 printk(KERN_CONT ", CHS=%d/%d/%d\n",
873 drive->bios_cyl, drive->bios_head, drive->bios_sect); 873 drive->bios_cyl, drive->bios_head, drive->bios_sect);
@@ -949,7 +949,8 @@ static void ide_device_shutdown(ide_drive_t *drive)
949 return; 949 return;
950 } 950 }
951 951
952 printk("Shutdown: %s\n", drive->name); 952 printk(KERN_INFO "Shutdown: %s\n", drive->name);
953
953 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND); 954 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
954} 955}
955 956
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index d0e7b537353e..2de99e4be5c9 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -1,9 +1,13 @@
1/* 1/*
2 * IDE DMA support (including IDE PCI BM-DMA).
3 *
2 * Copyright (C) 1995-1998 Mark Lord 4 * Copyright (C) 1995-1998 Mark Lord
3 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org>
4 * Copyright (C) 2004, 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (C) 2004, 2007 Bartlomiej Zolnierkiewicz
5 * 7 *
6 * May be copied or modified under the terms of the GNU General Public License 8 * May be copied or modified under the terms of the GNU General Public License
9 *
10 * DMA is supported for all IDE devices (disk drives, cdroms, tapes, floppies).
7 */ 11 */
8 12
9/* 13/*
@@ -11,49 +15,6 @@
11 */ 15 */
12 16
13/* 17/*
14 * This module provides support for the bus-master IDE DMA functions
15 * of various PCI chipsets, including the Intel PIIX (i82371FB for
16 * the 430 FX chipset), the PIIX3 (i82371SB for the 430 HX/VX and
17 * 440 chipsets), and the PIIX4 (i82371AB for the 430 TX chipset)
18 * ("PIIX" stands for "PCI ISA IDE Xcellerator").
19 *
20 * Pretty much the same code works for other IDE PCI bus-mastering chipsets.
21 *
22 * DMA is supported for all IDE devices (disk drives, cdroms, tapes, floppies).
23 *
24 * By default, DMA support is prepared for use, but is currently enabled only
25 * for drives which already have DMA enabled (UltraDMA or mode 2 multi/single),
26 * or which are recognized as "good" (see table below). Drives with only mode0
27 * or mode1 (multi/single) DMA should also work with this chipset/driver
28 * (eg. MC2112A) but are not enabled by default.
29 *
30 * Use "hdparm -i" to view modes supported by a given drive.
31 *
32 * The hdparm-3.5 (or later) utility can be used for manually enabling/disabling
33 * DMA support, but must be (re-)compiled against this kernel version or later.
34 *
35 * To enable DMA, use "hdparm -d1 /dev/hd?" on a per-drive basis after booting.
36 * If problems arise, ide.c will disable DMA operation after a few retries.
37 * This error recovery mechanism works and has been extremely well exercised.
38 *
39 * IDE drives, depending on their vintage, may support several different modes
40 * of DMA operation. The boot-time modes are indicated with a "*" in
41 * the "hdparm -i" listing, and can be changed with *knowledgeable* use of
42 * the "hdparm -X" feature. There is seldom a need to do this, as drives
43 * normally power-up with their "best" PIO/DMA modes enabled.
44 *
45 * Testing has been done with a rather extensive number of drives,
46 * with Quantum & Western Digital models generally outperforming the pack,
47 * and Fujitsu & Conner (and some Seagate which are really Conner) drives
48 * showing more lackluster throughput.
49 *
50 * Keep an eye on /var/adm/messages for "DMA disabled" messages.
51 *
52 * Some people have reported trouble with Intel Zappa motherboards.
53 * This can be fixed by upgrading the AMI BIOS to version 1.00.04.BS0,
54 * available from ftp://ftp.intel.com/pub/bios/10004bs0.exe
55 * (thanks to Glen Morrell <glen@spin.Stanford.edu> for researching this).
56 *
57 * Thanks to "Christopher J. Reimer" <reimer@doe.carleton.ca> for 18 * Thanks to "Christopher J. Reimer" <reimer@doe.carleton.ca> for
58 * fixing the problem with the BIOS on some Acer motherboards. 19 * fixing the problem with the BIOS on some Acer motherboards.
59 * 20 *
@@ -65,11 +26,6 @@
65 * 26 *
66 * Most importantly, thanks to Robert Bringman <rob@mars.trion.com> 27 * Most importantly, thanks to Robert Bringman <rob@mars.trion.com>
67 * for supplying a Promise UDMA board & WD UDMA drive for this work! 28 * for supplying a Promise UDMA board & WD UDMA drive for this work!
68 *
69 * And, yes, Intel Zappa boards really *do* use both PIIX IDE ports.
70 *
71 * ATA-66/100 and recovery functions, I forgot the rest......
72 *
73 */ 29 */
74 30
75#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 4a2cb2868226..194ecb0049eb 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -756,7 +756,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
756 756
757 BUG_ON(hwif->present); 757 BUG_ON(hwif->present);
758 758
759 if (hwif->noprobe) 759 if (hwif->noprobe ||
760 (hwif->drives[0].noprobe && hwif->drives[1].noprobe))
760 return -EACCES; 761 return -EACCES;
761 762
762 /* 763 /*
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0598ecfd5f37..43e0e0557776 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3765,6 +3765,11 @@ static int ide_tape_probe(ide_drive_t *drive)
3765 g->fops = &idetape_block_ops; 3765 g->fops = &idetape_block_ops;
3766 ide_register_region(g); 3766 ide_register_region(g);
3767 3767
3768 printk(KERN_WARNING "It is possible that this driver does not have any"
3769 " users anymore and, as a result, it will be REMOVED soon."
3770 " Please notify Bart <bzolnier@gmail.com> or Boris"
3771 " <petkovbb@gmail.com> in case you still need it.\n");
3772
3768 return 0; 3773 return 0;
3769 3774
3770out_free_tape: 3775out_free_tape:
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 477833f0daf5..fa16bc30bbc9 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -590,11 +590,6 @@ void ide_unregister(unsigned int index, int init_default, int restore)
590 hwif->extra_ports = 0; 590 hwif->extra_ports = 0;
591 } 591 }
592 592
593 /*
594 * Note that we only release the standard ports,
595 * and do not even try to handle any extra ports
596 * allocated for weird IDE interface chipsets.
597 */
598 ide_hwif_release_regions(hwif); 593 ide_hwif_release_regions(hwif);
599 594
600 /* copy original settings */ 595 /* copy original settings */
@@ -1036,10 +1031,9 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1036 drive->nice1 = (arg >> IDE_NICE_1) & 1; 1031 drive->nice1 = (arg >> IDE_NICE_1) & 1;
1037 return 0; 1032 return 0;
1038 case HDIO_DRIVE_RESET: 1033 case HDIO_DRIVE_RESET:
1039 { 1034 if (!capable(CAP_SYS_ADMIN))
1040 unsigned long flags; 1035 return -EACCES;
1041 if (!capable(CAP_SYS_ADMIN)) return -EACCES; 1036
1042
1043 /* 1037 /*
1044 * Abort the current command on the 1038 * Abort the current command on the
1045 * group if there is one, taking 1039 * group if there is one, taking
@@ -1058,17 +1052,15 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1058 ide_abort(drive, "drive reset"); 1052 ide_abort(drive, "drive reset");
1059 1053
1060 BUG_ON(HWGROUP(drive)->handler); 1054 BUG_ON(HWGROUP(drive)->handler);
1061 1055
1062 /* Ensure nothing gets queued after we 1056 /* Ensure nothing gets queued after we
1063 drop the lock. Reset will clear the busy */ 1057 drop the lock. Reset will clear the busy */
1064 1058
1065 HWGROUP(drive)->busy = 1; 1059 HWGROUP(drive)->busy = 1;
1066 spin_unlock_irqrestore(&ide_lock, flags); 1060 spin_unlock_irqrestore(&ide_lock, flags);
1067 (void) ide_do_reset(drive); 1061 (void) ide_do_reset(drive);
1068 1062
1069 return 0; 1063 return 0;
1070 }
1071
1072 case HDIO_GET_BUSSTATE: 1064 case HDIO_GET_BUSSTATE:
1073 if (!capable(CAP_SYS_ADMIN)) 1065 if (!capable(CAP_SYS_ADMIN))
1074 return -EACCES; 1066 return -EACCES;
@@ -1449,7 +1441,7 @@ static int __init ide_setup(char *s)
1449 1441
1450 case -1: /* "noprobe" */ 1442 case -1: /* "noprobe" */
1451 hwif->noprobe = 1; 1443 hwif->noprobe = 1;
1452 goto done; 1444 goto obsolete_option;
1453 1445
1454 case 1: /* base */ 1446 case 1: /* base */
1455 vals[1] = vals[0] + 0x206; /* default ctl */ 1447 vals[1] = vals[0] + 0x206; /* default ctl */
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index bba29df5f21d..2f4f47ad602f 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -334,43 +334,6 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif)
334 hwif->drives[1].drive_data = t2; 334 hwif->drives[1].drive_data = t2;
335} 335}
336 336
337/*
338 * qd_unsetup:
339 *
340 * called to unsetup an ata channel : back to default values, unlinks tuning
341 */
342/*
343static void __exit qd_unsetup(ide_hwif_t *hwif)
344{
345 u8 config = hwif->config_data;
346 int base = hwif->select_data;
347 void *set_pio_mode = (void *)hwif->set_pio_mode;
348
349 if (hwif->chipset != ide_qd65xx)
350 return;
351
352 printk(KERN_NOTICE "%s: back to defaults\n", hwif->name);
353
354 hwif->selectproc = NULL;
355 hwif->set_pio_mode = NULL;
356
357 if (set_pio_mode == (void *)qd6500_set_pio_mode) {
358 // will do it for both
359 outb(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
360 } else if (set_pio_mode == (void *)qd6580_set_pio_mode) {
361 if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) {
362 outb(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
363 outb(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1]));
364 } else {
365 outb(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0]));
366 }
367 } else {
368 printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n");
369 printk(KERN_WARNING "keeping settings !\n");
370 }
371}
372*/
373
374static const struct ide_port_info qd65xx_port_info __initdata = { 337static const struct ide_port_info qd65xx_port_info __initdata = {
375 .chipset = ide_qd65xx, 338 .chipset = ide_qd65xx,
376 .host_flags = IDE_HFLAG_IO_32BIT | 339 .host_flags = IDE_HFLAG_IO_32BIT |
@@ -444,6 +407,8 @@ static int __init qd_probe(int base)
444 printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", 407 printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n",
445 config, control, QD_ID3); 408 config, control, QD_ID3);
446 409
410 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
411
447 if (control & QD_CONTR_SEC_DISABLED) { 412 if (control & QD_CONTR_SEC_DISABLED) {
448 /* secondary disabled */ 413 /* secondary disabled */
449 414
@@ -460,8 +425,6 @@ static int __init qd_probe(int base)
460 425
461 ide_device_add(idx, &qd65xx_port_info); 426 ide_device_add(idx, &qd65xx_port_info);
462 427
463 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
464
465 return 1; 428 return 1;
466 } else { 429 } else {
467 ide_hwif_t *mate; 430 ide_hwif_t *mate;
@@ -487,8 +450,6 @@ static int __init qd_probe(int base)
487 450
488 ide_device_add(idx, &qd65xx_port_info); 451 ide_device_add(idx, &qd65xx_port_info);
489 452
490 outb(QD_DEF_CONTR, QD_CONTROL_PORT);
491
492 return 0; /* no other qd65xx possible */ 453 return 0; /* no other qd65xx possible */
493 } 454 }
494 } 455 }
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index bd24dad3cfc6..ec667982809c 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -787,7 +787,8 @@ static int __init cmd640x_init(void)
787 /* 787 /*
788 * Try to enable the secondary interface, if not already enabled 788 * Try to enable the secondary interface, if not already enabled
789 */ 789 */
790 if (cmd_hwif1->noprobe) { 790 if (cmd_hwif1->noprobe ||
791 (cmd_hwif1->drives[0].noprobe && cmd_hwif1->drives[1].noprobe)) {
791 port2 = "not probed"; 792 port2 = "not probed";
792 } else { 793 } else {
793 b = get_cmd640_reg(CNTRL); 794 b = get_cmd640_reg(CNTRL);
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index d0f7bb8b8adf..6357bb6269ab 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1570,10 +1570,12 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
1570 if (rev < 3) 1570 if (rev < 3)
1571 info = &hpt36x; 1571 info = &hpt36x;
1572 else { 1572 else {
1573 static const struct hpt_info *hpt37x_info[] = 1573 switch (min_t(u8, rev, 6)) {
1574 { &hpt370, &hpt370a, &hpt372, &hpt372n }; 1574 case 3: info = &hpt370; break;
1575 1575 case 4: info = &hpt370a; break;
1576 info = hpt37x_info[min_t(u8, rev, 6) - 3]; 1576 case 5: info = &hpt372; break;
1577 case 6: info = &hpt372n; break;
1578 }
1577 idx++; 1579 idx++;
1578 } 1580 }
1579 break; 1581 break;
@@ -1626,7 +1628,7 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
1626 return ide_setup_pci_device(dev, &d); 1628 return ide_setup_pci_device(dev, &d);
1627} 1629}
1628 1630
1629static const struct pci_device_id hpt366_pci_tbl[] = { 1631static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
1630 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), 0 }, 1632 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), 0 },
1631 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), 1 }, 1633 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), 1 },
1632 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), 2 }, 1634 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), 2 },
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 28e155a9e2a5..9e2b1964d71a 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -183,6 +183,9 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
183 * Avoids access beyond actual disk limits on devices with an off-by-one bug. 183 * Avoids access beyond actual disk limits on devices with an off-by-one bug.
184 * Don't use this with devices which don't have this bug. 184 * Don't use this with devices which don't have this bug.
185 * 185 *
186 * - delay inquiry
187 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
188 *
186 * - override internal blacklist 189 * - override internal blacklist
187 * Instead of adding to the built-in blacklist, use only the workarounds 190 * Instead of adding to the built-in blacklist, use only the workarounds
188 * specified in the module load parameter. 191 * specified in the module load parameter.
@@ -195,6 +198,7 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
195 ", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36) 198 ", 36 byte inquiry = " __stringify(SBP2_WORKAROUND_INQUIRY_36)
196 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8) 199 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
197 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY) 200 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
201 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
198 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 202 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
199 ", or a combination)"); 203 ", or a combination)");
200 204
@@ -357,6 +361,11 @@ static const struct {
357 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 361 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
358 SBP2_WORKAROUND_MODE_SENSE_8, 362 SBP2_WORKAROUND_MODE_SENSE_8,
359 }, 363 },
364 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
365 .firmware_revision = 0x002800,
366 .model_id = 0x000000,
367 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY,
368 },
360 /* Initio bridges, actually only needed for some older ones */ { 369 /* Initio bridges, actually only needed for some older ones */ {
361 .firmware_revision = 0x000200, 370 .firmware_revision = 0x000200,
362 .model_id = SBP2_ROM_VALUE_WILDCARD, 371 .model_id = SBP2_ROM_VALUE_WILDCARD,
@@ -914,6 +923,9 @@ static int sbp2_start_device(struct sbp2_lu *lu)
914 sbp2_agent_reset(lu, 1); 923 sbp2_agent_reset(lu, 1);
915 sbp2_max_speed_and_size(lu); 924 sbp2_max_speed_and_size(lu);
916 925
926 if (lu->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
927 ssleep(SBP2_INQUIRY_DELAY);
928
917 error = scsi_add_device(lu->shost, 0, lu->ud->id, 0); 929 error = scsi_add_device(lu->shost, 0, lu->ud->id, 0);
918 if (error) { 930 if (error) {
919 SBP2_ERR("scsi_add_device failed"); 931 SBP2_ERR("scsi_add_device failed");
@@ -1962,6 +1974,9 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
1962{ 1974{
1963 struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0]; 1975 struct sbp2_lu *lu = (struct sbp2_lu *)sdev->host->hostdata[0];
1964 1976
1977 if (sdev->lun != 0 || sdev->id != lu->ud->id || sdev->channel != 0)
1978 return -ENODEV;
1979
1965 lu->sdev = sdev; 1980 lu->sdev = sdev;
1966 sdev->allow_restart = 1; 1981 sdev->allow_restart = 1;
1967 1982
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index d2ecb0d8a1bb..80d8e097b065 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -343,6 +343,8 @@ enum sbp2lu_state_types {
343#define SBP2_WORKAROUND_INQUIRY_36 0x2 343#define SBP2_WORKAROUND_INQUIRY_36 0x2
344#define SBP2_WORKAROUND_MODE_SENSE_8 0x4 344#define SBP2_WORKAROUND_MODE_SENSE_8 0x4
345#define SBP2_WORKAROUND_FIX_CAPACITY 0x8 345#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
346#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10
347#define SBP2_INQUIRY_DELAY 12
346#define SBP2_WORKAROUND_OVERRIDE 0x100 348#define SBP2_WORKAROUND_OVERRIDE 0x100
347 349
348#endif /* SBP2_H */ 350#endif /* SBP2_H */
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c
index 73bfd1656f86..b8797c66676d 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_mem.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c
@@ -136,14 +136,8 @@ int build_phys_page_list(struct ib_phys_buf *buffer_list,
136 136
137 /* Find largest page shift we can use to cover buffers */ 137 /* Find largest page shift we can use to cover buffers */
138 for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift)) 138 for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift))
139 if (num_phys_buf > 1) { 139 if ((1ULL << *shift) & mask)
140 if ((1ULL << *shift) & mask) 140 break;
141 break;
142 } else
143 if (1ULL << *shift >=
144 buffer_list[0].size +
145 (buffer_list[0].addr & ((1ULL << *shift) - 1)))
146 break;
147 141
148 buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1); 142 buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1);
149 buffer_list[0].addr &= ~0ull << *shift; 143 buffer_list[0].addr &= ~0ull << *shift;
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 7f8853b44ee1..b2112f5a422f 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -567,12 +567,12 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
567 567
568 /* Init the adapter */ 568 /* Init the adapter */
569 nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev); 569 nesdev->nesadapter = nes_init_adapter(nesdev, hw_rev);
570 nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
571 if (!nesdev->nesadapter) { 570 if (!nesdev->nesadapter) {
572 printk(KERN_ERR PFX "Unable to initialize adapter.\n"); 571 printk(KERN_ERR PFX "Unable to initialize adapter.\n");
573 ret = -ENOMEM; 572 ret = -ENOMEM;
574 goto bail5; 573 goto bail5;
575 } 574 }
575 nesdev->nesadapter->et_rx_coalesce_usecs_irq = interrupt_mod_interval;
576 576
577 /* nesdev->base_doorbell_index = 577 /* nesdev->base_doorbell_index =
578 nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */ 578 nesdev->nesadapter->pd_config_base[PCI_FUNC(nesdev->pcidev->devfn)]; */
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index fd57e8a1582f..a48b288618ec 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -285,6 +285,21 @@ struct nes_device {
285}; 285};
286 286
287 287
288static inline __le32 get_crc_value(struct nes_v4_quad *nes_quad)
289{
290 u32 crc_value;
291 crc_value = crc32c(~0, (void *)nes_quad, sizeof (struct nes_v4_quad));
292
293 /*
294 * With commit ef19454b ("[LIB] crc32c: Keep intermediate crc
295 * state in cpu order"), behavior of crc32c changes on
296 * big-endian platforms. Our algorithm expects the previous
297 * behavior; otherwise we have RDMA connection establishment
298 * issue on big-endian.
299 */
300 return cpu_to_le32(crc_value);
301}
302
288static inline void 303static inline void
289set_wqe_64bit_value(__le32 *wqe_words, u32 index, u64 value) 304set_wqe_64bit_value(__le32 *wqe_words, u32 index, u64 value)
290{ 305{
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index bd5cfeaac203..39adb267fb15 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -370,11 +370,11 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb,
370 int ret = 0; 370 int ret = 0;
371 u32 was_timer_set; 371 u32 was_timer_set;
372 372
373 if (!cm_node)
374 return -EINVAL;
373 new_send = kzalloc(sizeof(*new_send), GFP_ATOMIC); 375 new_send = kzalloc(sizeof(*new_send), GFP_ATOMIC);
374 if (!new_send) 376 if (!new_send)
375 return -1; 377 return -1;
376 if (!cm_node)
377 return -EINVAL;
378 378
379 /* new_send->timetosend = currenttime */ 379 /* new_send->timetosend = currenttime */
380 new_send->retrycount = NES_DEFAULT_RETRYS; 380 new_send->retrycount = NES_DEFAULT_RETRYS;
@@ -947,6 +947,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
947 nes_debug(NES_DBG_CM, "destroying listener (%p)\n", listener); 947 nes_debug(NES_DBG_CM, "destroying listener (%p)\n", listener);
948 948
949 kfree(listener); 949 kfree(listener);
950 listener = NULL;
950 ret = 0; 951 ret = 0;
951 cm_listens_destroyed++; 952 cm_listens_destroyed++;
952 } else { 953 } else {
@@ -2319,6 +2320,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2319 struct iw_cm_event cm_event; 2320 struct iw_cm_event cm_event;
2320 struct nes_hw_qp_wqe *wqe; 2321 struct nes_hw_qp_wqe *wqe;
2321 struct nes_v4_quad nes_quad; 2322 struct nes_v4_quad nes_quad;
2323 u32 crc_value;
2322 int ret; 2324 int ret;
2323 2325
2324 ibqp = nes_get_qp(cm_id->device, conn_param->qpn); 2326 ibqp = nes_get_qp(cm_id->device, conn_param->qpn);
@@ -2435,8 +2437,8 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2435 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2437 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2436 2438
2437 /* Produce hash key */ 2439 /* Produce hash key */
2438 nesqp->hte_index = cpu_to_be32( 2440 crc_value = get_crc_value(&nes_quad);
2439 crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff); 2441 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
2440 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n", 2442 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n",
2441 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask); 2443 nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask);
2442 2444
@@ -2750,6 +2752,7 @@ void cm_event_connected(struct nes_cm_event *event)
2750 struct iw_cm_event cm_event; 2752 struct iw_cm_event cm_event;
2751 struct nes_hw_qp_wqe *wqe; 2753 struct nes_hw_qp_wqe *wqe;
2752 struct nes_v4_quad nes_quad; 2754 struct nes_v4_quad nes_quad;
2755 u32 crc_value;
2753 int ret; 2756 int ret;
2754 2757
2755 /* get all our handles */ 2758 /* get all our handles */
@@ -2827,8 +2830,8 @@ void cm_event_connected(struct nes_cm_event *event)
2827 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port; 2830 nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
2828 2831
2829 /* Produce hash key */ 2832 /* Produce hash key */
2830 nesqp->hte_index = cpu_to_be32( 2833 crc_value = get_crc_value(&nes_quad);
2831 crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff); 2834 nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
2832 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, After CRC = 0x%08X\n", 2835 nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, After CRC = 0x%08X\n",
2833 nesqp->hte_index, nesqp->hte_index & nesadapter->hte_index_mask); 2836 nesqp->hte_index, nesqp->hte_index & nesadapter->hte_index_mask);
2834 2837
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 7c4c0fbf0abd..49e53e4c1ebe 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -156,15 +156,14 @@ static void nes_nic_tune_timer(struct nes_device *nesdev)
156 156
157 spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags); 157 spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags);
158 158
159 if (shared_timer->cq_count_old < cq_count) { 159 if (shared_timer->cq_count_old <= cq_count)
160 if (cq_count > shared_timer->threshold_low) 160 shared_timer->cq_direction_downward = 0;
161 shared_timer->cq_direction_downward=0; 161 else
162 }
163 if (shared_timer->cq_count_old >= cq_count)
164 shared_timer->cq_direction_downward++; 162 shared_timer->cq_direction_downward++;
165 shared_timer->cq_count_old = cq_count; 163 shared_timer->cq_count_old = cq_count;
166 if (shared_timer->cq_direction_downward > NES_NIC_CQ_DOWNWARD_TREND) { 164 if (shared_timer->cq_direction_downward > NES_NIC_CQ_DOWNWARD_TREND) {
167 if (cq_count <= shared_timer->threshold_low) { 165 if (cq_count <= shared_timer->threshold_low &&
166 shared_timer->threshold_low > 4) {
168 shared_timer->threshold_low = shared_timer->threshold_low/2; 167 shared_timer->threshold_low = shared_timer->threshold_low/2;
169 shared_timer->cq_direction_downward=0; 168 shared_timer->cq_direction_downward=0;
170 nesdev->currcq_count = 0; 169 nesdev->currcq_count = 0;
@@ -1728,7 +1727,6 @@ int nes_napi_isr(struct nes_device *nesdev)
1728 nesdev->int_req &= ~NES_INT_TIMER; 1727 nesdev->int_req &= ~NES_INT_TIMER;
1729 nes_write32(nesdev->regs+NES_INTF_INT_MASK, ~(nesdev->intf_int_req)); 1728 nes_write32(nesdev->regs+NES_INTF_INT_MASK, ~(nesdev->intf_int_req));
1730 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req); 1729 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
1731 nesadapter->tune_timer.timer_in_use_old = 0;
1732 } 1730 }
1733 nesdev->deepcq_count = 0; 1731 nesdev->deepcq_count = 0;
1734 return 1; 1732 return 1;
@@ -1867,7 +1865,6 @@ void nes_dpc(unsigned long param)
1867 nesdev->int_req &= ~NES_INT_TIMER; 1865 nesdev->int_req &= ~NES_INT_TIMER;
1868 nes_write32(nesdev->regs + NES_INTF_INT_MASK, ~(nesdev->intf_int_req)); 1866 nes_write32(nesdev->regs + NES_INTF_INT_MASK, ~(nesdev->intf_int_req));
1869 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req); 1867 nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req);
1870 nesdev->nesadapter->tune_timer.timer_in_use_old = 0;
1871 } else { 1868 } else {
1872 nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req)); 1869 nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req));
1873 } 1870 }
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 1e10df550c9e..b7e2844f096b 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -962,7 +962,7 @@ struct nes_arp_entry {
962#define DEFAULT_JUMBO_NES_QL_LOW 12 962#define DEFAULT_JUMBO_NES_QL_LOW 12
963#define DEFAULT_JUMBO_NES_QL_TARGET 40 963#define DEFAULT_JUMBO_NES_QL_TARGET 40
964#define DEFAULT_JUMBO_NES_QL_HIGH 128 964#define DEFAULT_JUMBO_NES_QL_HIGH 128
965#define NES_NIC_CQ_DOWNWARD_TREND 8 965#define NES_NIC_CQ_DOWNWARD_TREND 16
966 966
967struct nes_hw_tune_timer { 967struct nes_hw_tune_timer {
968 //u16 cq_count; 968 //u16 cq_count;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 4dafbe16e82a..a651e9d9f0ef 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -929,7 +929,7 @@ static struct ib_pd *nes_alloc_pd(struct ib_device *ibdev,
929 NES_MAX_USER_DB_REGIONS, nesucontext->first_free_db); 929 NES_MAX_USER_DB_REGIONS, nesucontext->first_free_db);
930 nes_debug(NES_DBG_PD, "find_first_zero_biton doorbells returned %u, mapping pd_id %u.\n", 930 nes_debug(NES_DBG_PD, "find_first_zero_biton doorbells returned %u, mapping pd_id %u.\n",
931 nespd->mmap_db_index, nespd->pd_id); 931 nespd->mmap_db_index, nespd->pd_id);
932 if (nespd->mmap_db_index > NES_MAX_USER_DB_REGIONS) { 932 if (nespd->mmap_db_index >= NES_MAX_USER_DB_REGIONS) {
933 nes_debug(NES_DBG_PD, "mmap_db_index > MAX\n"); 933 nes_debug(NES_DBG_PD, "mmap_db_index > MAX\n");
934 nes_free_resource(nesadapter, nesadapter->allocated_pds, pd_num); 934 nes_free_resource(nesadapter, nesadapter->allocated_pds, pd_num);
935 kfree(nespd); 935 kfree(nespd);
@@ -1327,7 +1327,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1327 (long long unsigned int)req.user_wqe_buffers); 1327 (long long unsigned int)req.user_wqe_buffers);
1328 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); 1328 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1329 kfree(nesqp->allocated_buffer); 1329 kfree(nesqp->allocated_buffer);
1330 return ERR_PTR(-ENOMEM); 1330 return ERR_PTR(-EFAULT);
1331 } 1331 }
1332 } 1332 }
1333 1333
@@ -1674,6 +1674,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1674 } 1674 }
1675 nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n", 1675 nes_debug(NES_DBG_CQ, "CQ Virtual Address = %08lX, size = %u.\n",
1676 (unsigned long)req.user_cq_buffer, entries); 1676 (unsigned long)req.user_cq_buffer, entries);
1677 err = 1;
1677 list_for_each_entry(nespbl, &nes_ucontext->cq_reg_mem_list, list) { 1678 list_for_each_entry(nespbl, &nes_ucontext->cq_reg_mem_list, list) {
1678 if (nespbl->user_base == (unsigned long )req.user_cq_buffer) { 1679 if (nespbl->user_base == (unsigned long )req.user_cq_buffer) {
1679 list_del(&nespbl->list); 1680 list_del(&nespbl->list);
@@ -1686,7 +1687,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1686 if (err) { 1687 if (err) {
1687 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); 1688 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
1688 kfree(nescq); 1689 kfree(nescq);
1689 return ERR_PTR(err); 1690 return ERR_PTR(-EFAULT);
1690 } 1691 }
1691 1692
1692 pbl_entries = nespbl->pbl_size >> 3; 1693 pbl_entries = nespbl->pbl_size >> 3;
@@ -1831,9 +1832,6 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1831 spin_unlock_irqrestore(&nesdev->cqp.lock, flags); 1832 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1832 } 1833 }
1833 } 1834 }
1834 nes_debug(NES_DBG_CQ, "iWARP CQ%u create timeout expired, major code = 0x%04X,"
1835 " minor code = 0x%04X\n",
1836 nescq->hw_cq.cq_number, cqp_request->major_code, cqp_request->minor_code);
1837 if (!context) 1835 if (!context)
1838 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, 1836 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem,
1839 nescq->hw_cq.cq_pbase); 1837 nescq->hw_cq.cq_pbase);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f337800076c0..a0f0e605d630 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -90,6 +90,11 @@ config MACVLAN
90 This allows one to create virtual interfaces that map packets to 90 This allows one to create virtual interfaces that map packets to
91 or from specific MAC addresses to a particular interface. 91 or from specific MAC addresses to a particular interface.
92 92
93 Macvlan devices can be added using the "ip" command from the
94 iproute2 package starting with the iproute2-2.6.23 release:
95
96 "ip link add link <real dev> [ address MAC ] [ NAME ] type macvlan"
97
93 To compile this driver as a module, choose M here: the module 98 To compile this driver as a module, choose M here: the module
94 will be called macvlan. 99 will be called macvlan.
95 100
@@ -2363,6 +2368,7 @@ config GELIC_NET
2363config GELIC_WIRELESS 2368config GELIC_WIRELESS
2364 bool "PS3 Wireless support" 2369 bool "PS3 Wireless support"
2365 depends on GELIC_NET 2370 depends on GELIC_NET
2371 select WIRELESS_EXT
2366 help 2372 help
2367 This option adds the support for the wireless feature of PS3. 2373 This option adds the support for the wireless feature of PS3.
2368 If you have the wireless-less model of PS3 or have no plan to 2374 If you have the wireless-less model of PS3 or have no plan to
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 471c7f3e8a4a..15853be4680a 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -56,8 +56,8 @@
56 56
57#define DRV_MODULE_NAME "bnx2" 57#define DRV_MODULE_NAME "bnx2"
58#define PFX DRV_MODULE_NAME ": " 58#define PFX DRV_MODULE_NAME ": "
59#define DRV_MODULE_VERSION "1.7.3" 59#define DRV_MODULE_VERSION "1.7.4"
60#define DRV_MODULE_RELDATE "January 29, 2008" 60#define DRV_MODULE_RELDATE "February 18, 2008"
61 61
62#define RUN_AT(x) (jiffies + (x)) 62#define RUN_AT(x) (jiffies + (x))
63 63
@@ -1273,14 +1273,20 @@ bnx2_set_link(struct bnx2 *bp)
1273 1273
1274 if ((bp->phy_flags & BNX2_PHY_FLAG_SERDES) && 1274 if ((bp->phy_flags & BNX2_PHY_FLAG_SERDES) &&
1275 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 1275 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
1276 u32 val; 1276 u32 val, an_dbg;
1277 1277
1278 if (bp->phy_flags & BNX2_PHY_FLAG_FORCED_DOWN) { 1278 if (bp->phy_flags & BNX2_PHY_FLAG_FORCED_DOWN) {
1279 bnx2_5706s_force_link_dn(bp, 0); 1279 bnx2_5706s_force_link_dn(bp, 0);
1280 bp->phy_flags &= ~BNX2_PHY_FLAG_FORCED_DOWN; 1280 bp->phy_flags &= ~BNX2_PHY_FLAG_FORCED_DOWN;
1281 } 1281 }
1282 val = REG_RD(bp, BNX2_EMAC_STATUS); 1282 val = REG_RD(bp, BNX2_EMAC_STATUS);
1283 if (val & BNX2_EMAC_STATUS_LINK) 1283
1284 bnx2_write_phy(bp, MII_BNX2_MISC_SHADOW, MISC_SHDW_AN_DBG);
1285 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &an_dbg);
1286 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &an_dbg);
1287
1288 if ((val & BNX2_EMAC_STATUS_LINK) &&
1289 !(an_dbg & MISC_SHDW_AN_DBG_NOSYNC))
1284 bmsr |= BMSR_LSTATUS; 1290 bmsr |= BMSR_LSTATUS;
1285 else 1291 else
1286 bmsr &= ~BMSR_LSTATUS; 1292 bmsr &= ~BMSR_LSTATUS;
@@ -5356,11 +5362,15 @@ bnx2_test_intr(struct bnx2 *bp)
5356 return -ENODEV; 5362 return -ENODEV;
5357} 5363}
5358 5364
5365/* Determining link for parallel detection. */
5359static int 5366static int
5360bnx2_5706_serdes_has_link(struct bnx2 *bp) 5367bnx2_5706_serdes_has_link(struct bnx2 *bp)
5361{ 5368{
5362 u32 mode_ctl, an_dbg, exp; 5369 u32 mode_ctl, an_dbg, exp;
5363 5370
5371 if (bp->phy_flags & BNX2_PHY_FLAG_NO_PARALLEL)
5372 return 0;
5373
5364 bnx2_write_phy(bp, MII_BNX2_MISC_SHADOW, MISC_SHDW_MODE_CTL); 5374 bnx2_write_phy(bp, MII_BNX2_MISC_SHADOW, MISC_SHDW_MODE_CTL);
5365 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &mode_ctl); 5375 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &mode_ctl);
5366 5376
@@ -5390,13 +5400,6 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
5390 int check_link = 1; 5400 int check_link = 1;
5391 5401
5392 spin_lock(&bp->phy_lock); 5402 spin_lock(&bp->phy_lock);
5393 if (bp->phy_flags & BNX2_PHY_FLAG_FORCED_DOWN) {
5394 bnx2_5706s_force_link_dn(bp, 0);
5395 bp->phy_flags &= ~BNX2_PHY_FLAG_FORCED_DOWN;
5396 spin_unlock(&bp->phy_lock);
5397 return;
5398 }
5399
5400 if (bp->serdes_an_pending) { 5403 if (bp->serdes_an_pending) {
5401 bp->serdes_an_pending--; 5404 bp->serdes_an_pending--;
5402 check_link = 0; 5405 check_link = 0;
@@ -5420,7 +5423,6 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
5420 (bp->phy_flags & BNX2_PHY_FLAG_PARALLEL_DETECT)) { 5423 (bp->phy_flags & BNX2_PHY_FLAG_PARALLEL_DETECT)) {
5421 u32 phy2; 5424 u32 phy2;
5422 5425
5423 check_link = 0;
5424 bnx2_write_phy(bp, 0x17, 0x0f01); 5426 bnx2_write_phy(bp, 0x17, 0x0f01);
5425 bnx2_read_phy(bp, 0x15, &phy2); 5427 bnx2_read_phy(bp, 0x15, &phy2);
5426 if (phy2 & 0x20) { 5428 if (phy2 & 0x20) {
@@ -5435,17 +5437,21 @@ bnx2_5706_serdes_timer(struct bnx2 *bp)
5435 } else 5437 } else
5436 bp->current_interval = bp->timer_interval; 5438 bp->current_interval = bp->timer_interval;
5437 5439
5438 if (bp->link_up && (bp->autoneg & AUTONEG_SPEED) && check_link) { 5440 if (check_link) {
5439 u32 val; 5441 u32 val;
5440 5442
5441 bnx2_write_phy(bp, MII_BNX2_MISC_SHADOW, MISC_SHDW_AN_DBG); 5443 bnx2_write_phy(bp, MII_BNX2_MISC_SHADOW, MISC_SHDW_AN_DBG);
5442 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &val); 5444 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &val);
5443 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &val); 5445 bnx2_read_phy(bp, MII_BNX2_MISC_SHADOW, &val);
5444 5446
5445 if (val & MISC_SHDW_AN_DBG_NOSYNC) { 5447 if (bp->link_up && (val & MISC_SHDW_AN_DBG_NOSYNC)) {
5446 bnx2_5706s_force_link_dn(bp, 1); 5448 if (!(bp->phy_flags & BNX2_PHY_FLAG_FORCED_DOWN)) {
5447 bp->phy_flags |= BNX2_PHY_FLAG_FORCED_DOWN; 5449 bnx2_5706s_force_link_dn(bp, 1);
5448 } 5450 bp->phy_flags |= BNX2_PHY_FLAG_FORCED_DOWN;
5451 } else
5452 bnx2_set_link(bp);
5453 } else if (!bp->link_up && !(val & MISC_SHDW_AN_DBG_NOSYNC))
5454 bnx2_set_link(bp);
5449 } 5455 }
5450 spin_unlock(&bp->phy_lock); 5456 spin_unlock(&bp->phy_lock);
5451} 5457}
@@ -7326,7 +7332,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7326 bp->flags |= BNX2_FLAG_NO_WOL; 7332 bp->flags |= BNX2_FLAG_NO_WOL;
7327 bp->wol = 0; 7333 bp->wol = 0;
7328 } 7334 }
7329 if (CHIP_NUM(bp) != CHIP_NUM_5706) { 7335 if (CHIP_NUM(bp) == CHIP_NUM_5706) {
7336 /* Don't do parallel detect on this board because of
7337 * some board problems. The link will not go down
7338 * if we do parallel detect.
7339 */
7340 if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
7341 pdev->subsystem_device == 0x310c)
7342 bp->phy_flags |= BNX2_PHY_FLAG_NO_PARALLEL;
7343 } else {
7330 bp->phy_addr = 2; 7344 bp->phy_addr = 2;
7331 if (reg & BNX2_SHARED_HW_CFG_PHY_2_5G) 7345 if (reg & BNX2_SHARED_HW_CFG_PHY_2_5G)
7332 bp->phy_flags |= BNX2_PHY_FLAG_2_5G_CAPABLE; 7346 bp->phy_flags |= BNX2_PHY_FLAG_2_5G_CAPABLE;
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 3aa0364942e2..1eaf5bb3d9c2 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6673,6 +6673,7 @@ struct bnx2 {
6673#define BNX2_PHY_FLAG_DIS_EARLY_DAC 0x00000400 6673#define BNX2_PHY_FLAG_DIS_EARLY_DAC 0x00000400
6674#define BNX2_PHY_FLAG_REMOTE_PHY_CAP 0x00000800 6674#define BNX2_PHY_FLAG_REMOTE_PHY_CAP 0x00000800
6675#define BNX2_PHY_FLAG_FORCED_DOWN 0x00001000 6675#define BNX2_PHY_FLAG_FORCED_DOWN 0x00001000
6676#define BNX2_PHY_FLAG_NO_PARALLEL 0x00002000
6676 6677
6677 u32 mii_bmcr; 6678 u32 mii_bmcr;
6678 u32 mii_bmsr; 6679 u32 mii_bmsr;
diff --git a/drivers/net/bnx2x.c b/drivers/net/bnx2x.c
index afc7f34b1dcf..8af142ccf373 100644
--- a/drivers/net/bnx2x.c
+++ b/drivers/net/bnx2x.c
@@ -1,6 +1,6 @@
1/* bnx2x.c: Broadcom Everest network driver. 1/* bnx2x.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -10,13 +10,13 @@
10 * Based on code from Michael Chan's bnx2 driver 10 * Based on code from Michael Chan's bnx2 driver
11 * UDP CSUM errata workaround by Arik Gendelman 11 * UDP CSUM errata workaround by Arik Gendelman
12 * Slowpath rework by Vladislav Zolotarov 12 * Slowpath rework by Vladislav Zolotarov
13 * Statistics and Link managment by Yitchak Gertner 13 * Statistics and Link management by Yitchak Gertner
14 * 14 *
15 */ 15 */
16 16
17/* define this to make the driver freeze on error 17/* define this to make the driver freeze on error
18 * to allow getting debug info 18 * to allow getting debug info
19 * (you will need to reboot afterwords) 19 * (you will need to reboot afterwards)
20 */ 20 */
21/*#define BNX2X_STOP_ON_ERROR*/ 21/*#define BNX2X_STOP_ON_ERROR*/
22 22
@@ -63,22 +63,21 @@
63#include "bnx2x.h" 63#include "bnx2x.h"
64#include "bnx2x_init.h" 64#include "bnx2x_init.h"
65 65
66#define DRV_MODULE_VERSION "0.40.15" 66#define DRV_MODULE_VERSION "1.40.22"
67#define DRV_MODULE_RELDATE "$DateTime: 2007/11/15 07:28:37 $" 67#define DRV_MODULE_RELDATE "2007/11/27"
68#define BNX2X_BC_VER 0x040009 68#define BNX2X_BC_VER 0x040200
69 69
70/* Time in jiffies before concluding the transmitter is hung. */ 70/* Time in jiffies before concluding the transmitter is hung. */
71#define TX_TIMEOUT (5*HZ) 71#define TX_TIMEOUT (5*HZ)
72 72
73static char version[] __devinitdata = 73static char version[] __devinitdata =
74 "Broadcom NetXtreme II 577xx 10Gigabit Ethernet Driver " 74 "Broadcom NetXtreme II 5771X 10Gigabit Ethernet Driver "
75 DRV_MODULE_NAME " " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 75 DRV_MODULE_NAME " " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
76 76
77MODULE_AUTHOR("Eliezer Tamir <eliezert@broadcom.com>"); 77MODULE_AUTHOR("Eliezer Tamir <eliezert@broadcom.com>");
78MODULE_DESCRIPTION("Broadcom NetXtreme II BCM57710 Driver"); 78MODULE_DESCRIPTION("Broadcom NetXtreme II BCM57710 Driver");
79MODULE_LICENSE("GPL"); 79MODULE_LICENSE("GPL");
80MODULE_VERSION(DRV_MODULE_VERSION); 80MODULE_VERSION(DRV_MODULE_VERSION);
81MODULE_INFO(cvs_version, "$Revision: #356 $");
82 81
83static int use_inta; 82static int use_inta;
84static int poll; 83static int poll;
@@ -94,8 +93,8 @@ module_param(debug, int, 0);
94MODULE_PARM_DESC(use_inta, "use INT#A instead of MSI-X"); 93MODULE_PARM_DESC(use_inta, "use INT#A instead of MSI-X");
95MODULE_PARM_DESC(poll, "use polling (for debug)"); 94MODULE_PARM_DESC(poll, "use polling (for debug)");
96MODULE_PARM_DESC(onefunc, "enable only first function"); 95MODULE_PARM_DESC(onefunc, "enable only first function");
97MODULE_PARM_DESC(nomcp, "ignore managment CPU (Implies onefunc)"); 96MODULE_PARM_DESC(nomcp, "ignore management CPU (Implies onefunc)");
98MODULE_PARM_DESC(debug, "defualt debug msglevel"); 97MODULE_PARM_DESC(debug, "default debug msglevel");
99 98
100#ifdef BNX2X_MULTI 99#ifdef BNX2X_MULTI
101module_param(use_multi, int, 0); 100module_param(use_multi, int, 0);
@@ -298,8 +297,7 @@ static void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
298 297
299static int bnx2x_mc_assert(struct bnx2x *bp) 298static int bnx2x_mc_assert(struct bnx2x *bp)
300{ 299{
301 int i, j; 300 int i, j, rc = 0;
302 int rc = 0;
303 char last_idx; 301 char last_idx;
304 const char storm[] = {"XTCU"}; 302 const char storm[] = {"XTCU"};
305 const u32 intmem_base[] = { 303 const u32 intmem_base[] = {
@@ -313,8 +311,9 @@ static int bnx2x_mc_assert(struct bnx2x *bp)
313 for (i = 0; i < 4; i++) { 311 for (i = 0; i < 4; i++) {
314 last_idx = REG_RD8(bp, XSTORM_ASSERT_LIST_INDEX_OFFSET + 312 last_idx = REG_RD8(bp, XSTORM_ASSERT_LIST_INDEX_OFFSET +
315 intmem_base[i]); 313 intmem_base[i]);
316 BNX2X_ERR("DATA %cSTORM_ASSERT_LIST_INDEX 0x%x\n", 314 if (last_idx)
317 storm[i], last_idx); 315 BNX2X_LOG("DATA %cSTORM_ASSERT_LIST_INDEX 0x%x\n",
316 storm[i], last_idx);
318 317
319 /* print the asserts */ 318 /* print the asserts */
320 for (j = 0; j < STROM_ASSERT_ARRAY_SIZE; j++) { 319 for (j = 0; j < STROM_ASSERT_ARRAY_SIZE; j++) {
@@ -330,7 +329,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp)
330 intmem_base[i]); 329 intmem_base[i]);
331 330
332 if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) { 331 if (row0 != COMMON_ASM_INVALID_ASSERT_OPCODE) {
333 BNX2X_ERR("DATA %cSTORM_ASSERT_INDEX 0x%x =" 332 BNX2X_LOG("DATA %cSTORM_ASSERT_INDEX 0x%x ="
334 " 0x%08x 0x%08x 0x%08x 0x%08x\n", 333 " 0x%08x 0x%08x 0x%08x 0x%08x\n",
335 storm[i], j, row3, row2, row1, row0); 334 storm[i], j, row3, row2, row1, row0);
336 rc++; 335 rc++;
@@ -341,6 +340,7 @@ static int bnx2x_mc_assert(struct bnx2x *bp)
341 } 340 }
342 return rc; 341 return rc;
343} 342}
343
344static void bnx2x_fw_dump(struct bnx2x *bp) 344static void bnx2x_fw_dump(struct bnx2x *bp)
345{ 345{
346 u32 mark, offset; 346 u32 mark, offset;
@@ -348,21 +348,22 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
348 int word; 348 int word;
349 349
350 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104); 350 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104);
351 printk(KERN_ERR PFX "begin fw dump (mark 0x%x)\n", mark); 351 mark = ((mark + 0x3) & ~0x3);
352 printk(KERN_ERR PFX "begin fw dump (mark 0x%x)\n" KERN_ERR, mark);
352 353
353 for (offset = mark - 0x08000000; offset <= 0xF900; offset += 0x8*4) { 354 for (offset = mark - 0x08000000; offset <= 0xF900; offset += 0x8*4) {
354 for (word = 0; word < 8; word++) 355 for (word = 0; word < 8; word++)
355 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH + 356 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH +
356 offset + 4*word)); 357 offset + 4*word));
357 data[8] = 0x0; 358 data[8] = 0x0;
358 printk(KERN_ERR PFX "%s", (char *)data); 359 printk(KERN_CONT "%s", (char *)data);
359 } 360 }
360 for (offset = 0xF108; offset <= mark - 0x08000000; offset += 0x8*4) { 361 for (offset = 0xF108; offset <= mark - 0x08000000; offset += 0x8*4) {
361 for (word = 0; word < 8; word++) 362 for (word = 0; word < 8; word++)
362 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH + 363 data[word] = htonl(REG_RD(bp, MCP_REG_MCPR_SCRATCH +
363 offset + 4*word)); 364 offset + 4*word));
364 data[8] = 0x0; 365 data[8] = 0x0;
365 printk(KERN_ERR PFX "%s", (char *)data); 366 printk(KERN_CONT "%s", (char *)data);
366 } 367 }
367 printk("\n" KERN_ERR PFX "end of fw dump\n"); 368 printk("\n" KERN_ERR PFX "end of fw dump\n");
368} 369}
@@ -427,10 +428,10 @@ static void bnx2x_panic_dump(struct bnx2x *bp)
427 } 428 }
428 } 429 }
429 430
430 BNX2X_ERR("def_c_idx(%u) def_u_idx(%u) def_t_idx(%u)" 431 BNX2X_ERR("def_c_idx(%u) def_u_idx(%u) def_x_idx(%u)"
431 " def_x_idx(%u) def_att_idx(%u) attn_state(%u)" 432 " def_t_idx(%u) def_att_idx(%u) attn_state(%u)"
432 " spq_prod_idx(%u)\n", 433 " spq_prod_idx(%u)\n",
433 bp->def_c_idx, bp->def_u_idx, bp->def_t_idx, bp->def_x_idx, 434 bp->def_c_idx, bp->def_u_idx, bp->def_x_idx, bp->def_t_idx,
434 bp->def_att_idx, bp->attn_state, bp->spq_prod_idx); 435 bp->def_att_idx, bp->attn_state, bp->spq_prod_idx);
435 436
436 437
@@ -441,7 +442,7 @@ static void bnx2x_panic_dump(struct bnx2x *bp)
441 DP(BNX2X_MSG_STATS, "stats_state - DISABLE\n"); 442 DP(BNX2X_MSG_STATS, "stats_state - DISABLE\n");
442} 443}
443 444
444static void bnx2x_enable_int(struct bnx2x *bp) 445static void bnx2x_int_enable(struct bnx2x *bp)
445{ 446{
446 int port = bp->port; 447 int port = bp->port;
447 u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; 448 u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0;
@@ -454,18 +455,26 @@ static void bnx2x_enable_int(struct bnx2x *bp)
454 HC_CONFIG_0_REG_ATTN_BIT_EN_0); 455 HC_CONFIG_0_REG_ATTN_BIT_EN_0);
455 } else { 456 } else {
456 val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | 457 val |= (HC_CONFIG_0_REG_SINGLE_ISR_EN_0 |
458 HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 |
457 HC_CONFIG_0_REG_INT_LINE_EN_0 | 459 HC_CONFIG_0_REG_INT_LINE_EN_0 |
458 HC_CONFIG_0_REG_ATTN_BIT_EN_0); 460 HC_CONFIG_0_REG_ATTN_BIT_EN_0);
461
462 /* Errata A0.158 workaround */
463 DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) MSI-X %d\n",
464 val, port, addr, msix);
465
466 REG_WR(bp, addr, val);
467
459 val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0; 468 val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0;
460 } 469 }
461 470
462 DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) msi %d\n", 471 DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) MSI-X %d\n",
463 val, port, addr, msix); 472 val, port, addr, msix);
464 473
465 REG_WR(bp, addr, val); 474 REG_WR(bp, addr, val);
466} 475}
467 476
468static void bnx2x_disable_int(struct bnx2x *bp) 477static void bnx2x_int_disable(struct bnx2x *bp)
469{ 478{
470 int port = bp->port; 479 int port = bp->port;
471 u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; 480 u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0;
@@ -484,15 +493,15 @@ static void bnx2x_disable_int(struct bnx2x *bp)
484 BNX2X_ERR("BUG! proper val not read from IGU!\n"); 493 BNX2X_ERR("BUG! proper val not read from IGU!\n");
485} 494}
486 495
487static void bnx2x_disable_int_sync(struct bnx2x *bp) 496static void bnx2x_int_disable_sync(struct bnx2x *bp)
488{ 497{
489 498
490 int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0; 499 int msix = (bp->flags & USING_MSIX_FLAG) ? 1 : 0;
491 int i; 500 int i;
492 501
493 atomic_inc(&bp->intr_sem); 502 atomic_inc(&bp->intr_sem);
494 /* prevent the HW from sending interrupts*/ 503 /* prevent the HW from sending interrupts */
495 bnx2x_disable_int(bp); 504 bnx2x_int_disable(bp);
496 505
497 /* make sure all ISRs are done */ 506 /* make sure all ISRs are done */
498 if (msix) { 507 if (msix) {
@@ -775,6 +784,7 @@ static void bnx2x_sp_event(struct bnx2x_fastpath *fp,
775 mb(); /* force bnx2x_wait_ramrod to see the change */ 784 mb(); /* force bnx2x_wait_ramrod to see the change */
776 return; 785 return;
777 } 786 }
787
778 switch (command | bp->state) { 788 switch (command | bp->state) {
779 case (RAMROD_CMD_ID_ETH_PORT_SETUP | BNX2X_STATE_OPENING_WAIT4_PORT): 789 case (RAMROD_CMD_ID_ETH_PORT_SETUP | BNX2X_STATE_OPENING_WAIT4_PORT):
780 DP(NETIF_MSG_IFUP, "got setup ramrod\n"); 790 DP(NETIF_MSG_IFUP, "got setup ramrod\n");
@@ -787,20 +797,20 @@ static void bnx2x_sp_event(struct bnx2x_fastpath *fp,
787 fp->state = BNX2X_FP_STATE_HALTED; 797 fp->state = BNX2X_FP_STATE_HALTED;
788 break; 798 break;
789 799
790 case (RAMROD_CMD_ID_ETH_PORT_DEL | BNX2X_STATE_CLOSING_WAIT4_DELETE):
791 DP(NETIF_MSG_IFDOWN, "got delete ramrod\n");
792 bp->state = BNX2X_STATE_CLOSING_WAIT4_UNLOAD;
793 break;
794
795 case (RAMROD_CMD_ID_ETH_CFC_DEL | BNX2X_STATE_CLOSING_WAIT4_HALT): 800 case (RAMROD_CMD_ID_ETH_CFC_DEL | BNX2X_STATE_CLOSING_WAIT4_HALT):
796 DP(NETIF_MSG_IFDOWN, "got delete ramrod for MULTI[%d]\n", cid); 801 DP(NETIF_MSG_IFDOWN, "got delete ramrod for MULTI[%d]\n",
797 bnx2x_fp(bp, cid, state) = BNX2X_FP_STATE_DELETED; 802 cid);
803 bnx2x_fp(bp, cid, state) = BNX2X_FP_STATE_CLOSED;
798 break; 804 break;
799 805
800 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_OPEN): 806 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_OPEN):
801 DP(NETIF_MSG_IFUP, "got set mac ramrod\n"); 807 DP(NETIF_MSG_IFUP, "got set mac ramrod\n");
802 break; 808 break;
803 809
810 case (RAMROD_CMD_ID_ETH_SET_MAC | BNX2X_STATE_CLOSING_WAIT4_HALT):
811 DP(NETIF_MSG_IFUP, "got (un)set mac ramrod\n");
812 break;
813
804 default: 814 default:
805 BNX2X_ERR("unexpected ramrod (%d) state is %x\n", 815 BNX2X_ERR("unexpected ramrod (%d) state is %x\n",
806 command, bp->state); 816 command, bp->state);
@@ -1179,12 +1189,175 @@ static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits)
1179 return val; 1189 return val;
1180} 1190}
1181 1191
1192static int bnx2x_hw_lock(struct bnx2x *bp, u32 resource)
1193{
1194 u32 cnt;
1195 u32 lock_status;
1196 u32 resource_bit = (1 << resource);
1197 u8 func = bp->port;
1198
1199 /* Validating that the resource is within range */
1200 if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
1201 DP(NETIF_MSG_HW,
1202 "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n",
1203 resource, HW_LOCK_MAX_RESOURCE_VALUE);
1204 return -EINVAL;
1205 }
1206
1207 /* Validating that the resource is not already taken */
1208 lock_status = REG_RD(bp, MISC_REG_DRIVER_CONTROL_1 + func*8);
1209 if (lock_status & resource_bit) {
1210 DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n",
1211 lock_status, resource_bit);
1212 return -EEXIST;
1213 }
1214
1215 /* Try for 1 second every 5ms */
1216 for (cnt = 0; cnt < 200; cnt++) {
1217 /* Try to acquire the lock */
1218 REG_WR(bp, MISC_REG_DRIVER_CONTROL_1 + func*8 + 4,
1219 resource_bit);
1220 lock_status = REG_RD(bp, MISC_REG_DRIVER_CONTROL_1 + func*8);
1221 if (lock_status & resource_bit)
1222 return 0;
1223
1224 msleep(5);
1225 }
1226 DP(NETIF_MSG_HW, "Timeout\n");
1227 return -EAGAIN;
1228}
1229
1230static int bnx2x_hw_unlock(struct bnx2x *bp, u32 resource)
1231{
1232 u32 lock_status;
1233 u32 resource_bit = (1 << resource);
1234 u8 func = bp->port;
1235
1236 /* Validating that the resource is within range */
1237 if (resource > HW_LOCK_MAX_RESOURCE_VALUE) {
1238 DP(NETIF_MSG_HW,
1239 "resource(0x%x) > HW_LOCK_MAX_RESOURCE_VALUE(0x%x)\n",
1240 resource, HW_LOCK_MAX_RESOURCE_VALUE);
1241 return -EINVAL;
1242 }
1243
1244 /* Validating that the resource is currently taken */
1245 lock_status = REG_RD(bp, MISC_REG_DRIVER_CONTROL_1 + func*8);
1246 if (!(lock_status & resource_bit)) {
1247 DP(NETIF_MSG_HW, "lock_status 0x%x resource_bit 0x%x\n",
1248 lock_status, resource_bit);
1249 return -EFAULT;
1250 }
1251
1252 REG_WR(bp, MISC_REG_DRIVER_CONTROL_1 + func*8, resource_bit);
1253 return 0;
1254}
1255
1256static int bnx2x_set_gpio(struct bnx2x *bp, int gpio_num, u32 mode)
1257{
1258 /* The GPIO should be swapped if swap register is set and active */
1259 int gpio_port = (REG_RD(bp, NIG_REG_PORT_SWAP) &&
1260 REG_RD(bp, NIG_REG_STRAP_OVERRIDE)) ^ bp->port;
1261 int gpio_shift = gpio_num +
1262 (gpio_port ? MISC_REGISTERS_GPIO_PORT_SHIFT : 0);
1263 u32 gpio_mask = (1 << gpio_shift);
1264 u32 gpio_reg;
1265
1266 if (gpio_num > MISC_REGISTERS_GPIO_3) {
1267 BNX2X_ERR("Invalid GPIO %d\n", gpio_num);
1268 return -EINVAL;
1269 }
1270
1271 bnx2x_hw_lock(bp, HW_LOCK_RESOURCE_GPIO);
1272 /* read GPIO and mask except the float bits */
1273 gpio_reg = (REG_RD(bp, MISC_REG_GPIO) & MISC_REGISTERS_GPIO_FLOAT);
1274
1275 switch (mode) {
1276 case MISC_REGISTERS_GPIO_OUTPUT_LOW:
1277 DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output low\n",
1278 gpio_num, gpio_shift);
1279 /* clear FLOAT and set CLR */
1280 gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
1281 gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_CLR_POS);
1282 break;
1283
1284 case MISC_REGISTERS_GPIO_OUTPUT_HIGH:
1285 DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> output high\n",
1286 gpio_num, gpio_shift);
1287 /* clear FLOAT and set SET */
1288 gpio_reg &= ~(gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
1289 gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_SET_POS);
1290 break;
1291
1292 case MISC_REGISTERS_GPIO_INPUT_HI_Z :
1293 DP(NETIF_MSG_LINK, "Set GPIO %d (shift %d) -> input\n",
1294 gpio_num, gpio_shift);
1295 /* set FLOAT */
1296 gpio_reg |= (gpio_mask << MISC_REGISTERS_GPIO_FLOAT_POS);
1297 break;
1298
1299 default:
1300 break;
1301 }
1302
1303 REG_WR(bp, MISC_REG_GPIO, gpio_reg);
1304 bnx2x_hw_unlock(bp, HW_LOCK_RESOURCE_GPIO);
1305
1306 return 0;
1307}
1308
1309static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode)
1310{
1311 u32 spio_mask = (1 << spio_num);
1312 u32 spio_reg;
1313
1314 if ((spio_num < MISC_REGISTERS_SPIO_4) ||
1315 (spio_num > MISC_REGISTERS_SPIO_7)) {
1316 BNX2X_ERR("Invalid SPIO %d\n", spio_num);
1317 return -EINVAL;
1318 }
1319
1320 bnx2x_hw_lock(bp, HW_LOCK_RESOURCE_SPIO);
1321 /* read SPIO and mask except the float bits */
1322 spio_reg = (REG_RD(bp, MISC_REG_SPIO) & MISC_REGISTERS_SPIO_FLOAT);
1323
1324 switch (mode) {
1325 case MISC_REGISTERS_SPIO_OUTPUT_LOW :
1326 DP(NETIF_MSG_LINK, "Set SPIO %d -> output low\n", spio_num);
1327 /* clear FLOAT and set CLR */
1328 spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS);
1329 spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_CLR_POS);
1330 break;
1331
1332 case MISC_REGISTERS_SPIO_OUTPUT_HIGH :
1333 DP(NETIF_MSG_LINK, "Set SPIO %d -> output high\n", spio_num);
1334 /* clear FLOAT and set SET */
1335 spio_reg &= ~(spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS);
1336 spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_SET_POS);
1337 break;
1338
1339 case MISC_REGISTERS_SPIO_INPUT_HI_Z:
1340 DP(NETIF_MSG_LINK, "Set SPIO %d -> input\n", spio_num);
1341 /* set FLOAT */
1342 spio_reg |= (spio_mask << MISC_REGISTERS_SPIO_FLOAT_POS);
1343 break;
1344
1345 default:
1346 break;
1347 }
1348
1349 REG_WR(bp, MISC_REG_SPIO, spio_reg);
1350 bnx2x_hw_unlock(bp, HW_LOCK_RESOURCE_SPIO);
1351
1352 return 0;
1353}
1354
1182static int bnx2x_mdio22_write(struct bnx2x *bp, u32 reg, u32 val) 1355static int bnx2x_mdio22_write(struct bnx2x *bp, u32 reg, u32 val)
1183{ 1356{
1184 int rc;
1185 u32 tmp, i;
1186 int port = bp->port; 1357 int port = bp->port;
1187 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; 1358 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1359 u32 tmp;
1360 int i, rc;
1188 1361
1189/* DP(NETIF_MSG_HW, "phy_addr 0x%x reg 0x%x val 0x%08x\n", 1362/* DP(NETIF_MSG_HW, "phy_addr 0x%x reg 0x%x val 0x%08x\n",
1190 bp->phy_addr, reg, val); */ 1363 bp->phy_addr, reg, val); */
@@ -1236,8 +1409,8 @@ static int bnx2x_mdio22_read(struct bnx2x *bp, u32 reg, u32 *ret_val)
1236{ 1409{
1237 int port = bp->port; 1410 int port = bp->port;
1238 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0; 1411 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1239 u32 val, i; 1412 u32 val;
1240 int rc; 1413 int i, rc;
1241 1414
1242 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) { 1415 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
1243 1416
@@ -1286,58 +1459,54 @@ static int bnx2x_mdio22_read(struct bnx2x *bp, u32 reg, u32 *ret_val)
1286 return rc; 1459 return rc;
1287} 1460}
1288 1461
1289static int bnx2x_mdio45_write(struct bnx2x *bp, u32 reg, u32 addr, u32 val) 1462static int bnx2x_mdio45_ctrl_write(struct bnx2x *bp, u32 mdio_ctrl,
1463 u32 phy_addr, u32 reg, u32 addr, u32 val)
1290{ 1464{
1291 int rc = 0; 1465 u32 tmp;
1292 u32 tmp, i; 1466 int i, rc = 0;
1293 int port = bp->port;
1294 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1295
1296 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) {
1297
1298 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE);
1299 tmp &= ~EMAC_MDIO_MODE_AUTO_POLL;
1300 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, tmp);
1301 REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE);
1302 udelay(40);
1303 }
1304 1467
1305 /* set clause 45 mode */ 1468 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
1306 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1469 * (a value of 49==0x31) and make sure that the AUTO poll is off
1307 tmp |= EMAC_MDIO_MODE_CLAUSE_45; 1470 */
1308 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, tmp); 1471 tmp = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1472 tmp &= ~(EMAC_MDIO_MODE_AUTO_POLL | EMAC_MDIO_MODE_CLOCK_CNT);
1473 tmp |= (EMAC_MDIO_MODE_CLAUSE_45 |
1474 (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT));
1475 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, tmp);
1476 REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1477 udelay(40);
1309 1478
1310 /* address */ 1479 /* address */
1311 tmp = ((bp->phy_addr << 21) | (reg << 16) | addr | 1480 tmp = ((phy_addr << 21) | (reg << 16) | addr |
1312 EMAC_MDIO_COMM_COMMAND_ADDRESS | 1481 EMAC_MDIO_COMM_COMMAND_ADDRESS |
1313 EMAC_MDIO_COMM_START_BUSY); 1482 EMAC_MDIO_COMM_START_BUSY);
1314 EMAC_WR(EMAC_REG_EMAC_MDIO_COMM, tmp); 1483 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp);
1315 1484
1316 for (i = 0; i < 50; i++) { 1485 for (i = 0; i < 50; i++) {
1317 udelay(10); 1486 udelay(10);
1318 1487
1319 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM); 1488 tmp = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM);
1320 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { 1489 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) {
1321 udelay(5); 1490 udelay(5);
1322 break; 1491 break;
1323 } 1492 }
1324 } 1493 }
1325
1326 if (tmp & EMAC_MDIO_COMM_START_BUSY) { 1494 if (tmp & EMAC_MDIO_COMM_START_BUSY) {
1327 BNX2X_ERR("write phy register failed\n"); 1495 BNX2X_ERR("write phy register failed\n");
1328 1496
1329 rc = -EBUSY; 1497 rc = -EBUSY;
1498
1330 } else { 1499 } else {
1331 /* data */ 1500 /* data */
1332 tmp = ((bp->phy_addr << 21) | (reg << 16) | val | 1501 tmp = ((phy_addr << 21) | (reg << 16) | val |
1333 EMAC_MDIO_COMM_COMMAND_WRITE_45 | 1502 EMAC_MDIO_COMM_COMMAND_WRITE_45 |
1334 EMAC_MDIO_COMM_START_BUSY); 1503 EMAC_MDIO_COMM_START_BUSY);
1335 EMAC_WR(EMAC_REG_EMAC_MDIO_COMM, tmp); 1504 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, tmp);
1336 1505
1337 for (i = 0; i < 50; i++) { 1506 for (i = 0; i < 50; i++) {
1338 udelay(10); 1507 udelay(10);
1339 1508
1340 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM); 1509 tmp = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM);
1341 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) { 1510 if (!(tmp & EMAC_MDIO_COMM_START_BUSY)) {
1342 udelay(5); 1511 udelay(5);
1343 break; 1512 break;
@@ -1351,75 +1520,78 @@ static int bnx2x_mdio45_write(struct bnx2x *bp, u32 reg, u32 addr, u32 val)
1351 } 1520 }
1352 } 1521 }
1353 1522
1354 /* unset clause 45 mode */ 1523 /* unset clause 45 mode, set the MDIO clock to a faster value
1355 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1524 * (0x13 => 6.25Mhz) and restore the AUTO poll if needed
1356 tmp &= ~EMAC_MDIO_MODE_CLAUSE_45; 1525 */
1357 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, tmp); 1526 tmp = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1358 1527 tmp &= ~(EMAC_MDIO_MODE_CLAUSE_45 | EMAC_MDIO_MODE_CLOCK_CNT);
1359 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) { 1528 tmp |= (0x13 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT);
1360 1529 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG)
1361 tmp = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE);
1362 tmp |= EMAC_MDIO_MODE_AUTO_POLL; 1530 tmp |= EMAC_MDIO_MODE_AUTO_POLL;
1363 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, tmp); 1531 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, tmp);
1364 }
1365 1532
1366 return rc; 1533 return rc;
1367} 1534}
1368 1535
1369static int bnx2x_mdio45_read(struct bnx2x *bp, u32 reg, u32 addr, 1536static int bnx2x_mdio45_write(struct bnx2x *bp, u32 phy_addr, u32 reg,
1370 u32 *ret_val) 1537 u32 addr, u32 val)
1371{ 1538{
1372 int port = bp->port; 1539 u32 emac_base = bp->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1373 u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1374 u32 val, i;
1375 int rc = 0;
1376 1540
1377 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) { 1541 return bnx2x_mdio45_ctrl_write(bp, emac_base, phy_addr,
1542 reg, addr, val);
1543}
1378 1544
1379 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1545static int bnx2x_mdio45_ctrl_read(struct bnx2x *bp, u32 mdio_ctrl,
1380 val &= ~EMAC_MDIO_MODE_AUTO_POLL; 1546 u32 phy_addr, u32 reg, u32 addr,
1381 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, val); 1547 u32 *ret_val)
1382 REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1548{
1383 udelay(40); 1549 u32 val;
1384 } 1550 int i, rc = 0;
1385 1551
1386 /* set clause 45 mode */ 1552 /* set clause 45 mode, slow down the MDIO clock to 2.5MHz
1387 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1553 * (a value of 49==0x31) and make sure that the AUTO poll is off
1388 val |= EMAC_MDIO_MODE_CLAUSE_45; 1554 */
1389 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, val); 1555 val = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1556 val &= ~(EMAC_MDIO_MODE_AUTO_POLL | EMAC_MDIO_MODE_CLOCK_CNT);
1557 val |= (EMAC_MDIO_MODE_CLAUSE_45 |
1558 (49 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT));
1559 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, val);
1560 REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1561 udelay(40);
1390 1562
1391 /* address */ 1563 /* address */
1392 val = ((bp->phy_addr << 21) | (reg << 16) | addr | 1564 val = ((phy_addr << 21) | (reg << 16) | addr |
1393 EMAC_MDIO_COMM_COMMAND_ADDRESS | 1565 EMAC_MDIO_COMM_COMMAND_ADDRESS |
1394 EMAC_MDIO_COMM_START_BUSY); 1566 EMAC_MDIO_COMM_START_BUSY);
1395 EMAC_WR(EMAC_REG_EMAC_MDIO_COMM, val); 1567 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val);
1396 1568
1397 for (i = 0; i < 50; i++) { 1569 for (i = 0; i < 50; i++) {
1398 udelay(10); 1570 udelay(10);
1399 1571
1400 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM); 1572 val = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM);
1401 if (!(val & EMAC_MDIO_COMM_START_BUSY)) { 1573 if (!(val & EMAC_MDIO_COMM_START_BUSY)) {
1402 udelay(5); 1574 udelay(5);
1403 break; 1575 break;
1404 } 1576 }
1405 } 1577 }
1406
1407 if (val & EMAC_MDIO_COMM_START_BUSY) { 1578 if (val & EMAC_MDIO_COMM_START_BUSY) {
1408 BNX2X_ERR("read phy register failed\n"); 1579 BNX2X_ERR("read phy register failed\n");
1409 1580
1410 *ret_val = 0; 1581 *ret_val = 0;
1411 rc = -EBUSY; 1582 rc = -EBUSY;
1583
1412 } else { 1584 } else {
1413 /* data */ 1585 /* data */
1414 val = ((bp->phy_addr << 21) | (reg << 16) | 1586 val = ((phy_addr << 21) | (reg << 16) |
1415 EMAC_MDIO_COMM_COMMAND_READ_45 | 1587 EMAC_MDIO_COMM_COMMAND_READ_45 |
1416 EMAC_MDIO_COMM_START_BUSY); 1588 EMAC_MDIO_COMM_START_BUSY);
1417 EMAC_WR(EMAC_REG_EMAC_MDIO_COMM, val); 1589 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM, val);
1418 1590
1419 for (i = 0; i < 50; i++) { 1591 for (i = 0; i < 50; i++) {
1420 udelay(10); 1592 udelay(10);
1421 1593
1422 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_COMM); 1594 val = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_COMM);
1423 if (!(val & EMAC_MDIO_COMM_START_BUSY)) { 1595 if (!(val & EMAC_MDIO_COMM_START_BUSY)) {
1424 val &= EMAC_MDIO_COMM_DATA; 1596 val &= EMAC_MDIO_COMM_DATA;
1425 break; 1597 break;
@@ -1436,31 +1608,39 @@ static int bnx2x_mdio45_read(struct bnx2x *bp, u32 reg, u32 addr,
1436 *ret_val = val; 1608 *ret_val = val;
1437 } 1609 }
1438 1610
1439 /* unset clause 45 mode */ 1611 /* unset clause 45 mode, set the MDIO clock to a faster value
1440 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE); 1612 * (0x13 => 6.25Mhz) and restore the AUTO poll if needed
1441 val &= ~EMAC_MDIO_MODE_CLAUSE_45; 1613 */
1442 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, val); 1614 val = REG_RD(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE);
1443 1615 val &= ~(EMAC_MDIO_MODE_CLAUSE_45 | EMAC_MDIO_MODE_CLOCK_CNT);
1444 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG) { 1616 val |= (0x13 << EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT);
1445 1617 if (bp->phy_flags & PHY_INT_MODE_AUTO_POLLING_FLAG)
1446 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_MDIO_MODE);
1447 val |= EMAC_MDIO_MODE_AUTO_POLL; 1618 val |= EMAC_MDIO_MODE_AUTO_POLL;
1448 EMAC_WR(EMAC_REG_EMAC_MDIO_MODE, val); 1619 REG_WR(bp, mdio_ctrl + EMAC_REG_EMAC_MDIO_MODE, val);
1449 }
1450 1620
1451 return rc; 1621 return rc;
1452} 1622}
1453 1623
1454static int bnx2x_mdio45_vwrite(struct bnx2x *bp, u32 reg, u32 addr, u32 val) 1624static int bnx2x_mdio45_read(struct bnx2x *bp, u32 phy_addr, u32 reg,
1625 u32 addr, u32 *ret_val)
1626{
1627 u32 emac_base = bp->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
1628
1629 return bnx2x_mdio45_ctrl_read(bp, emac_base, phy_addr,
1630 reg, addr, ret_val);
1631}
1632
1633static int bnx2x_mdio45_vwrite(struct bnx2x *bp, u32 phy_addr, u32 reg,
1634 u32 addr, u32 val)
1455{ 1635{
1456 int i; 1636 int i;
1457 u32 rd_val; 1637 u32 rd_val;
1458 1638
1459 might_sleep(); 1639 might_sleep();
1460 for (i = 0; i < 10; i++) { 1640 for (i = 0; i < 10; i++) {
1461 bnx2x_mdio45_write(bp, reg, addr, val); 1641 bnx2x_mdio45_write(bp, phy_addr, reg, addr, val);
1462 msleep(5); 1642 msleep(5);
1463 bnx2x_mdio45_read(bp, reg, addr, &rd_val); 1643 bnx2x_mdio45_read(bp, phy_addr, reg, addr, &rd_val);
1464 /* if the read value is not the same as the value we wrote, 1644 /* if the read value is not the same as the value we wrote,
1465 we should write it again */ 1645 we should write it again */
1466 if (rd_val == val) 1646 if (rd_val == val)
@@ -1471,18 +1651,81 @@ static int bnx2x_mdio45_vwrite(struct bnx2x *bp, u32 reg, u32 addr, u32 val)
1471} 1651}
1472 1652
1473/* 1653/*
1474 * link managment 1654 * link management
1475 */ 1655 */
1476 1656
1657static void bnx2x_pause_resolve(struct bnx2x *bp, u32 pause_result)
1658{
1659 switch (pause_result) { /* ASYM P ASYM P */
1660 case 0xb: /* 1 0 1 1 */
1661 bp->flow_ctrl = FLOW_CTRL_TX;
1662 break;
1663
1664 case 0xe: /* 1 1 1 0 */
1665 bp->flow_ctrl = FLOW_CTRL_RX;
1666 break;
1667
1668 case 0x5: /* 0 1 0 1 */
1669 case 0x7: /* 0 1 1 1 */
1670 case 0xd: /* 1 1 0 1 */
1671 case 0xf: /* 1 1 1 1 */
1672 bp->flow_ctrl = FLOW_CTRL_BOTH;
1673 break;
1674
1675 default:
1676 break;
1677 }
1678}
1679
1680static u8 bnx2x_ext_phy_resove_fc(struct bnx2x *bp)
1681{
1682 u32 ext_phy_addr;
1683 u32 ld_pause; /* local */
1684 u32 lp_pause; /* link partner */
1685 u32 an_complete; /* AN complete */
1686 u32 pause_result;
1687 u8 ret = 0;
1688
1689 ext_phy_addr = ((bp->ext_phy_config &
1690 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
1691 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
1692
1693 /* read twice */
1694 bnx2x_mdio45_read(bp, ext_phy_addr,
1695 EXT_PHY_KR_AUTO_NEG_DEVAD,
1696 EXT_PHY_KR_STATUS, &an_complete);
1697 bnx2x_mdio45_read(bp, ext_phy_addr,
1698 EXT_PHY_KR_AUTO_NEG_DEVAD,
1699 EXT_PHY_KR_STATUS, &an_complete);
1700
1701 if (an_complete & EXT_PHY_KR_AUTO_NEG_COMPLETE) {
1702 ret = 1;
1703 bnx2x_mdio45_read(bp, ext_phy_addr,
1704 EXT_PHY_KR_AUTO_NEG_DEVAD,
1705 EXT_PHY_KR_AUTO_NEG_ADVERT, &ld_pause);
1706 bnx2x_mdio45_read(bp, ext_phy_addr,
1707 EXT_PHY_KR_AUTO_NEG_DEVAD,
1708 EXT_PHY_KR_LP_AUTO_NEG, &lp_pause);
1709 pause_result = (ld_pause &
1710 EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_MASK) >> 8;
1711 pause_result |= (lp_pause &
1712 EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_MASK) >> 10;
1713 DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x \n",
1714 pause_result);
1715 bnx2x_pause_resolve(bp, pause_result);
1716 }
1717 return ret;
1718}
1719
1477static void bnx2x_flow_ctrl_resolve(struct bnx2x *bp, u32 gp_status) 1720static void bnx2x_flow_ctrl_resolve(struct bnx2x *bp, u32 gp_status)
1478{ 1721{
1479 u32 ld_pause; /* local driver */ 1722 u32 ld_pause; /* local driver */
1480 u32 lp_pause; /* link partner */ 1723 u32 lp_pause; /* link partner */
1481 u32 pause_result; 1724 u32 pause_result;
1482 1725
1483 bp->flow_ctrl = 0; 1726 bp->flow_ctrl = 0;
1484 1727
1485 /* reolve from gp_status in case of AN complete and not sgmii */ 1728 /* resolve from gp_status in case of AN complete and not sgmii */
1486 if ((bp->req_autoneg & AUTONEG_FLOW_CTRL) && 1729 if ((bp->req_autoneg & AUTONEG_FLOW_CTRL) &&
1487 (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) && 1730 (gp_status & MDIO_AN_CL73_OR_37_COMPLETE) &&
1488 (!(bp->phy_flags & PHY_SGMII_FLAG)) && 1731 (!(bp->phy_flags & PHY_SGMII_FLAG)) &&
@@ -1499,45 +1742,57 @@ static void bnx2x_flow_ctrl_resolve(struct bnx2x *bp, u32 gp_status)
1499 pause_result |= (lp_pause & 1742 pause_result |= (lp_pause &
1500 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7; 1743 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK)>>7;
1501 DP(NETIF_MSG_LINK, "pause_result 0x%x\n", pause_result); 1744 DP(NETIF_MSG_LINK, "pause_result 0x%x\n", pause_result);
1745 bnx2x_pause_resolve(bp, pause_result);
1746 } else if (!(bp->req_autoneg & AUTONEG_FLOW_CTRL) ||
1747 !(bnx2x_ext_phy_resove_fc(bp))) {
1748 /* forced speed */
1749 if (bp->req_autoneg & AUTONEG_FLOW_CTRL) {
1750 switch (bp->req_flow_ctrl) {
1751 case FLOW_CTRL_AUTO:
1752 if (bp->dev->mtu <= 4500)
1753 bp->flow_ctrl = FLOW_CTRL_BOTH;
1754 else
1755 bp->flow_ctrl = FLOW_CTRL_TX;
1756 break;
1502 1757
1503 switch (pause_result) { /* ASYM P ASYM P */ 1758 case FLOW_CTRL_TX:
1504 case 0xb: /* 1 0 1 1 */ 1759 bp->flow_ctrl = FLOW_CTRL_TX;
1505 bp->flow_ctrl = FLOW_CTRL_TX; 1760 break;
1506 break;
1507
1508 case 0xe: /* 1 1 1 0 */
1509 bp->flow_ctrl = FLOW_CTRL_RX;
1510 break;
1511 1761
1512 case 0x5: /* 0 1 0 1 */ 1762 case FLOW_CTRL_RX:
1513 case 0x7: /* 0 1 1 1 */ 1763 if (bp->dev->mtu <= 4500)
1514 case 0xd: /* 1 1 0 1 */ 1764 bp->flow_ctrl = FLOW_CTRL_RX;
1515 case 0xf: /* 1 1 1 1 */ 1765 break;
1516 bp->flow_ctrl = FLOW_CTRL_BOTH;
1517 break;
1518 1766
1519 default: 1767 case FLOW_CTRL_BOTH:
1520 break; 1768 if (bp->dev->mtu <= 4500)
1521 } 1769 bp->flow_ctrl = FLOW_CTRL_BOTH;
1770 else
1771 bp->flow_ctrl = FLOW_CTRL_TX;
1772 break;
1522 1773
1523 } else { /* forced mode */ 1774 case FLOW_CTRL_NONE:
1524 switch (bp->req_flow_ctrl) { 1775 default:
1525 case FLOW_CTRL_AUTO: 1776 break;
1526 if (bp->dev->mtu <= 4500) 1777 }
1527 bp->flow_ctrl = FLOW_CTRL_BOTH; 1778 } else { /* forced mode */
1528 else 1779 switch (bp->req_flow_ctrl) {
1529 bp->flow_ctrl = FLOW_CTRL_TX; 1780 case FLOW_CTRL_AUTO:
1530 break; 1781 DP(NETIF_MSG_LINK, "req_flow_ctrl 0x%x while"
1782 " req_autoneg 0x%x\n",
1783 bp->req_flow_ctrl, bp->req_autoneg);
1784 break;
1531 1785
1532 case FLOW_CTRL_TX: 1786 case FLOW_CTRL_TX:
1533 case FLOW_CTRL_RX: 1787 case FLOW_CTRL_RX:
1534 case FLOW_CTRL_BOTH: 1788 case FLOW_CTRL_BOTH:
1535 bp->flow_ctrl = bp->req_flow_ctrl; 1789 bp->flow_ctrl = bp->req_flow_ctrl;
1536 break; 1790 break;
1537 1791
1538 case FLOW_CTRL_NONE: 1792 case FLOW_CTRL_NONE:
1539 default: 1793 default:
1540 break; 1794 break;
1795 }
1541 } 1796 }
1542 } 1797 }
1543 DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", bp->flow_ctrl); 1798 DP(NETIF_MSG_LINK, "flow_ctrl 0x%x\n", bp->flow_ctrl);
@@ -1548,9 +1803,9 @@ static void bnx2x_link_settings_status(struct bnx2x *bp, u32 gp_status)
1548 bp->link_status = 0; 1803 bp->link_status = 0;
1549 1804
1550 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) { 1805 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_LINK_STATUS) {
1551 DP(NETIF_MSG_LINK, "link up\n"); 1806 DP(NETIF_MSG_LINK, "phy link up\n");
1552 1807
1553 bp->link_up = 1; 1808 bp->phy_link_up = 1;
1554 bp->link_status |= LINK_STATUS_LINK_UP; 1809 bp->link_status |= LINK_STATUS_LINK_UP;
1555 1810
1556 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS) 1811 if (gp_status & MDIO_GP_STATUS_TOP_AN_STATUS1_DUPLEX_STATUS)
@@ -1659,20 +1914,20 @@ static void bnx2x_link_settings_status(struct bnx2x *bp, u32 gp_status)
1659 bp->link_status |= LINK_STATUS_RX_FLOW_CONTROL_ENABLED; 1914 bp->link_status |= LINK_STATUS_RX_FLOW_CONTROL_ENABLED;
1660 1915
1661 } else { /* link_down */ 1916 } else { /* link_down */
1662 DP(NETIF_MSG_LINK, "link down\n"); 1917 DP(NETIF_MSG_LINK, "phy link down\n");
1663 1918
1664 bp->link_up = 0; 1919 bp->phy_link_up = 0;
1665 1920
1666 bp->line_speed = 0; 1921 bp->line_speed = 0;
1667 bp->duplex = DUPLEX_FULL; 1922 bp->duplex = DUPLEX_FULL;
1668 bp->flow_ctrl = 0; 1923 bp->flow_ctrl = 0;
1669 } 1924 }
1670 1925
1671 DP(NETIF_MSG_LINK, "gp_status 0x%x link_up %d\n" 1926 DP(NETIF_MSG_LINK, "gp_status 0x%x phy_link_up %d\n"
1672 DP_LEVEL " line_speed %d duplex %d flow_ctrl 0x%x" 1927 DP_LEVEL " line_speed %d duplex %d flow_ctrl 0x%x"
1673 " link_status 0x%x\n", 1928 " link_status 0x%x\n",
1674 gp_status, bp->link_up, bp->line_speed, bp->duplex, bp->flow_ctrl, 1929 gp_status, bp->phy_link_up, bp->line_speed, bp->duplex,
1675 bp->link_status); 1930 bp->flow_ctrl, bp->link_status);
1676} 1931}
1677 1932
1678static void bnx2x_link_int_ack(struct bnx2x *bp, int is_10g) 1933static void bnx2x_link_int_ack(struct bnx2x *bp, int is_10g)
@@ -1680,40 +1935,40 @@ static void bnx2x_link_int_ack(struct bnx2x *bp, int is_10g)
1680 int port = bp->port; 1935 int port = bp->port;
1681 1936
1682 /* first reset all status 1937 /* first reset all status
1683 * we asume only one line will be change at a time */ 1938 * we assume only one line will be change at a time */
1684 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 1939 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4,
1685 (NIG_XGXS0_LINK_STATUS | 1940 (NIG_STATUS_XGXS0_LINK10G |
1686 NIG_SERDES0_LINK_STATUS | 1941 NIG_STATUS_XGXS0_LINK_STATUS |
1687 NIG_STATUS_INTERRUPT_XGXS0_LINK10G)); 1942 NIG_STATUS_SERDES0_LINK_STATUS));
1688 if (bp->link_up) { 1943 if (bp->phy_link_up) {
1689 if (is_10g) { 1944 if (is_10g) {
1690 /* Disable the 10G link interrupt 1945 /* Disable the 10G link interrupt
1691 * by writing 1 to the status register 1946 * by writing 1 to the status register
1692 */ 1947 */
1693 DP(NETIF_MSG_LINK, "10G XGXS link up\n"); 1948 DP(NETIF_MSG_LINK, "10G XGXS phy link up\n");
1694 bnx2x_bits_en(bp, 1949 bnx2x_bits_en(bp,
1695 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 1950 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4,
1696 NIG_STATUS_INTERRUPT_XGXS0_LINK10G); 1951 NIG_STATUS_XGXS0_LINK10G);
1697 1952
1698 } else if (bp->phy_flags & PHY_XGXS_FLAG) { 1953 } else if (bp->phy_flags & PHY_XGXS_FLAG) {
1699 /* Disable the link interrupt 1954 /* Disable the link interrupt
1700 * by writing 1 to the relevant lane 1955 * by writing 1 to the relevant lane
1701 * in the status register 1956 * in the status register
1702 */ 1957 */
1703 DP(NETIF_MSG_LINK, "1G XGXS link up\n"); 1958 DP(NETIF_MSG_LINK, "1G XGXS phy link up\n");
1704 bnx2x_bits_en(bp, 1959 bnx2x_bits_en(bp,
1705 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 1960 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4,
1706 ((1 << bp->ser_lane) << 1961 ((1 << bp->ser_lane) <<
1707 NIG_XGXS0_LINK_STATUS_SIZE)); 1962 NIG_STATUS_XGXS0_LINK_STATUS_SIZE));
1708 1963
1709 } else { /* SerDes */ 1964 } else { /* SerDes */
1710 DP(NETIF_MSG_LINK, "SerDes link up\n"); 1965 DP(NETIF_MSG_LINK, "SerDes phy link up\n");
1711 /* Disable the link interrupt 1966 /* Disable the link interrupt
1712 * by writing 1 to the status register 1967 * by writing 1 to the status register
1713 */ 1968 */
1714 bnx2x_bits_en(bp, 1969 bnx2x_bits_en(bp,
1715 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 1970 NIG_REG_STATUS_INTERRUPT_PORT0 + port*4,
1716 NIG_SERDES0_LINK_STATUS); 1971 NIG_STATUS_SERDES0_LINK_STATUS);
1717 } 1972 }
1718 1973
1719 } else { /* link_down */ 1974 } else { /* link_down */
@@ -1724,91 +1979,182 @@ static int bnx2x_ext_phy_is_link_up(struct bnx2x *bp)
1724{ 1979{
1725 u32 ext_phy_type; 1980 u32 ext_phy_type;
1726 u32 ext_phy_addr; 1981 u32 ext_phy_addr;
1727 u32 local_phy; 1982 u32 val1 = 0, val2;
1728 u32 val = 0;
1729 u32 rx_sd, pcs_status; 1983 u32 rx_sd, pcs_status;
1730 1984
1731 if (bp->phy_flags & PHY_XGXS_FLAG) { 1985 if (bp->phy_flags & PHY_XGXS_FLAG) {
1732 local_phy = bp->phy_addr;
1733 ext_phy_addr = ((bp->ext_phy_config & 1986 ext_phy_addr = ((bp->ext_phy_config &
1734 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >> 1987 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
1735 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT); 1988 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
1736 bp->phy_addr = (u8)ext_phy_addr;
1737 1989
1738 ext_phy_type = XGXS_EXT_PHY_TYPE(bp); 1990 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
1739 switch (ext_phy_type) { 1991 switch (ext_phy_type) {
1740 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: 1992 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT:
1741 DP(NETIF_MSG_LINK, "XGXS Direct\n"); 1993 DP(NETIF_MSG_LINK, "XGXS Direct\n");
1742 val = 1; 1994 val1 = 1;
1743 break; 1995 break;
1744 1996
1745 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: 1997 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705:
1746 DP(NETIF_MSG_LINK, "XGXS 8705\n"); 1998 DP(NETIF_MSG_LINK, "XGXS 8705\n");
1747 bnx2x_mdio45_read(bp, EXT_PHY_OPT_WIS_DEVAD, 1999 bnx2x_mdio45_read(bp, ext_phy_addr,
1748 EXT_PHY_OPT_LASI_STATUS, &val); 2000 EXT_PHY_OPT_WIS_DEVAD,
1749 DP(NETIF_MSG_LINK, "8705 LASI status is %d\n", val); 2001 EXT_PHY_OPT_LASI_STATUS, &val1);
1750 2002 DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1);
1751 bnx2x_mdio45_read(bp, EXT_PHY_OPT_WIS_DEVAD, 2003
1752 EXT_PHY_OPT_LASI_STATUS, &val); 2004 bnx2x_mdio45_read(bp, ext_phy_addr,
1753 DP(NETIF_MSG_LINK, "8705 LASI status is %d\n", val); 2005 EXT_PHY_OPT_WIS_DEVAD,
1754 2006 EXT_PHY_OPT_LASI_STATUS, &val1);
1755 bnx2x_mdio45_read(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 2007 DP(NETIF_MSG_LINK, "8705 LASI status 0x%x\n", val1);
2008
2009 bnx2x_mdio45_read(bp, ext_phy_addr,
2010 EXT_PHY_OPT_PMA_PMD_DEVAD,
1756 EXT_PHY_OPT_PMD_RX_SD, &rx_sd); 2011 EXT_PHY_OPT_PMD_RX_SD, &rx_sd);
1757 val = (rx_sd & 0x1); 2012 DP(NETIF_MSG_LINK, "8705 rx_sd 0x%x\n", rx_sd);
2013 val1 = (rx_sd & 0x1);
1758 break; 2014 break;
1759 2015
1760 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: 2016 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706:
1761 DP(NETIF_MSG_LINK, "XGXS 8706\n"); 2017 DP(NETIF_MSG_LINK, "XGXS 8706\n");
1762 bnx2x_mdio45_read(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 2018 bnx2x_mdio45_read(bp, ext_phy_addr,
1763 EXT_PHY_OPT_LASI_STATUS, &val); 2019 EXT_PHY_OPT_PMA_PMD_DEVAD,
1764 DP(NETIF_MSG_LINK, "8706 LASI status is %d\n", val); 2020 EXT_PHY_OPT_LASI_STATUS, &val1);
1765 2021 DP(NETIF_MSG_LINK, "8706 LASI status 0x%x\n", val1);
1766 bnx2x_mdio45_read(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 2022
1767 EXT_PHY_OPT_LASI_STATUS, &val); 2023 bnx2x_mdio45_read(bp, ext_phy_addr,
1768 DP(NETIF_MSG_LINK, "8706 LASI status is %d\n", val); 2024 EXT_PHY_OPT_PMA_PMD_DEVAD,
1769 2025 EXT_PHY_OPT_LASI_STATUS, &val1);
1770 bnx2x_mdio45_read(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 2026 DP(NETIF_MSG_LINK, "8706 LASI status 0x%x\n", val1);
2027
2028 bnx2x_mdio45_read(bp, ext_phy_addr,
2029 EXT_PHY_OPT_PMA_PMD_DEVAD,
1771 EXT_PHY_OPT_PMD_RX_SD, &rx_sd); 2030 EXT_PHY_OPT_PMD_RX_SD, &rx_sd);
1772 bnx2x_mdio45_read(bp, EXT_PHY_OPT_PCS_DEVAD, 2031 bnx2x_mdio45_read(bp, ext_phy_addr,
1773 EXT_PHY_OPT_PCS_STATUS, &pcs_status); 2032 EXT_PHY_OPT_PCS_DEVAD,
2033 EXT_PHY_OPT_PCS_STATUS, &pcs_status);
2034 bnx2x_mdio45_read(bp, ext_phy_addr,
2035 EXT_PHY_AUTO_NEG_DEVAD,
2036 EXT_PHY_OPT_AN_LINK_STATUS, &val2);
2037
1774 DP(NETIF_MSG_LINK, "8706 rx_sd 0x%x" 2038 DP(NETIF_MSG_LINK, "8706 rx_sd 0x%x"
1775 " pcs_status 0x%x\n", rx_sd, pcs_status); 2039 " pcs_status 0x%x 1Gbps link_status 0x%x 0x%x\n",
1776 /* link is up if both bit 0 of pmd_rx and 2040 rx_sd, pcs_status, val2, (val2 & (1<<1)));
1777 * bit 0 of pcs_status are set 2041 /* link is up if both bit 0 of pmd_rx_sd and
2042 * bit 0 of pcs_status are set, or if the autoneg bit
2043 1 is set
1778 */ 2044 */
1779 val = (rx_sd & pcs_status); 2045 val1 = ((rx_sd & pcs_status & 0x1) || (val2 & (1<<1)));
2046 break;
2047
2048 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072:
2049 bnx2x_hw_lock(bp, HW_LOCK_RESOURCE_8072_MDIO);
2050
2051 /* clear the interrupt LASI status register */
2052 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2053 ext_phy_addr,
2054 EXT_PHY_KR_PCS_DEVAD,
2055 EXT_PHY_KR_LASI_STATUS, &val2);
2056 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2057 ext_phy_addr,
2058 EXT_PHY_KR_PCS_DEVAD,
2059 EXT_PHY_KR_LASI_STATUS, &val1);
2060 DP(NETIF_MSG_LINK, "KR LASI status 0x%x->0x%x\n",
2061 val2, val1);
2062 /* Check the LASI */
2063 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2064 ext_phy_addr,
2065 EXT_PHY_KR_PMA_PMD_DEVAD,
2066 0x9003, &val2);
2067 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2068 ext_phy_addr,
2069 EXT_PHY_KR_PMA_PMD_DEVAD,
2070 0x9003, &val1);
2071 DP(NETIF_MSG_LINK, "KR 0x9003 0x%x->0x%x\n",
2072 val2, val1);
2073 /* Check the link status */
2074 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2075 ext_phy_addr,
2076 EXT_PHY_KR_PCS_DEVAD,
2077 EXT_PHY_KR_PCS_STATUS, &val2);
2078 DP(NETIF_MSG_LINK, "KR PCS status 0x%x\n", val2);
2079 /* Check the link status on 1.1.2 */
2080 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2081 ext_phy_addr,
2082 EXT_PHY_OPT_PMA_PMD_DEVAD,
2083 EXT_PHY_KR_STATUS, &val2);
2084 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
2085 ext_phy_addr,
2086 EXT_PHY_OPT_PMA_PMD_DEVAD,
2087 EXT_PHY_KR_STATUS, &val1);
2088 DP(NETIF_MSG_LINK,
2089 "KR PMA status 0x%x->0x%x\n", val2, val1);
2090 val1 = ((val1 & 4) == 4);
2091 /* If 1G was requested assume the link is up */
2092 if (!(bp->req_autoneg & AUTONEG_SPEED) &&
2093 (bp->req_line_speed == SPEED_1000))
2094 val1 = 1;
2095 bnx2x_hw_unlock(bp, HW_LOCK_RESOURCE_8072_MDIO);
2096 break;
2097
2098 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101:
2099 bnx2x_mdio45_read(bp, ext_phy_addr,
2100 EXT_PHY_OPT_PMA_PMD_DEVAD,
2101 EXT_PHY_OPT_LASI_STATUS, &val2);
2102 bnx2x_mdio45_read(bp, ext_phy_addr,
2103 EXT_PHY_OPT_PMA_PMD_DEVAD,
2104 EXT_PHY_OPT_LASI_STATUS, &val1);
2105 DP(NETIF_MSG_LINK,
2106 "10G-base-T LASI status 0x%x->0x%x\n", val2, val1);
2107 bnx2x_mdio45_read(bp, ext_phy_addr,
2108 EXT_PHY_OPT_PMA_PMD_DEVAD,
2109 EXT_PHY_KR_STATUS, &val2);
2110 bnx2x_mdio45_read(bp, ext_phy_addr,
2111 EXT_PHY_OPT_PMA_PMD_DEVAD,
2112 EXT_PHY_KR_STATUS, &val1);
2113 DP(NETIF_MSG_LINK,
2114 "10G-base-T PMA status 0x%x->0x%x\n", val2, val1);
2115 val1 = ((val1 & 4) == 4);
2116 /* if link is up
2117 * print the AN outcome of the SFX7101 PHY
2118 */
2119 if (val1) {
2120 bnx2x_mdio45_read(bp, ext_phy_addr,
2121 EXT_PHY_KR_AUTO_NEG_DEVAD,
2122 0x21, &val2);
2123 DP(NETIF_MSG_LINK,
2124 "SFX7101 AN status 0x%x->%s\n", val2,
2125 (val2 & (1<<14)) ? "Master" : "Slave");
2126 }
1780 break; 2127 break;
1781 2128
1782 default: 2129 default:
1783 DP(NETIF_MSG_LINK, "BAD XGXS ext_phy_config 0x%x\n", 2130 DP(NETIF_MSG_LINK, "BAD XGXS ext_phy_config 0x%x\n",
1784 bp->ext_phy_config); 2131 bp->ext_phy_config);
1785 val = 0; 2132 val1 = 0;
1786 break; 2133 break;
1787 } 2134 }
1788 bp->phy_addr = local_phy;
1789 2135
1790 } else { /* SerDes */ 2136 } else { /* SerDes */
1791 ext_phy_type = SERDES_EXT_PHY_TYPE(bp); 2137 ext_phy_type = SERDES_EXT_PHY_TYPE(bp);
1792 switch (ext_phy_type) { 2138 switch (ext_phy_type) {
1793 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT: 2139 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT:
1794 DP(NETIF_MSG_LINK, "SerDes Direct\n"); 2140 DP(NETIF_MSG_LINK, "SerDes Direct\n");
1795 val = 1; 2141 val1 = 1;
1796 break; 2142 break;
1797 2143
1798 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482: 2144 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482:
1799 DP(NETIF_MSG_LINK, "SerDes 5482\n"); 2145 DP(NETIF_MSG_LINK, "SerDes 5482\n");
1800 val = 1; 2146 val1 = 1;
1801 break; 2147 break;
1802 2148
1803 default: 2149 default:
1804 DP(NETIF_MSG_LINK, "BAD SerDes ext_phy_config 0x%x\n", 2150 DP(NETIF_MSG_LINK, "BAD SerDes ext_phy_config 0x%x\n",
1805 bp->ext_phy_config); 2151 bp->ext_phy_config);
1806 val = 0; 2152 val1 = 0;
1807 break; 2153 break;
1808 } 2154 }
1809 } 2155 }
1810 2156
1811 return val; 2157 return val1;
1812} 2158}
1813 2159
1814static void bnx2x_bmac_enable(struct bnx2x *bp, int is_lb) 2160static void bnx2x_bmac_enable(struct bnx2x *bp, int is_lb)
@@ -1819,7 +2165,7 @@ static void bnx2x_bmac_enable(struct bnx2x *bp, int is_lb)
1819 u32 wb_write[2]; 2165 u32 wb_write[2];
1820 u32 val; 2166 u32 val;
1821 2167
1822 DP(NETIF_MSG_LINK, "enableing BigMAC\n"); 2168 DP(NETIF_MSG_LINK, "enabling BigMAC\n");
1823 /* reset and unreset the BigMac */ 2169 /* reset and unreset the BigMac */
1824 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, 2170 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
1825 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)); 2171 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port));
@@ -1933,6 +2279,35 @@ static void bnx2x_bmac_enable(struct bnx2x *bp, int is_lb)
1933 bp->stats_state = STATS_STATE_ENABLE; 2279 bp->stats_state = STATS_STATE_ENABLE;
1934} 2280}
1935 2281
2282static void bnx2x_bmac_rx_disable(struct bnx2x *bp)
2283{
2284 int port = bp->port;
2285 u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM :
2286 NIG_REG_INGRESS_BMAC0_MEM;
2287 u32 wb_write[2];
2288
2289 /* Only if the bmac is out of reset */
2290 if (REG_RD(bp, MISC_REG_RESET_REG_2) &
2291 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port)) {
2292 /* Clear Rx Enable bit in BMAC_CONTROL register */
2293#ifdef BNX2X_DMAE_RD
2294 bnx2x_read_dmae(bp, bmac_addr +
2295 BIGMAC_REGISTER_BMAC_CONTROL, 2);
2296 wb_write[0] = *bnx2x_sp(bp, wb_data[0]);
2297 wb_write[1] = *bnx2x_sp(bp, wb_data[1]);
2298#else
2299 wb_write[0] = REG_RD(bp,
2300 bmac_addr + BIGMAC_REGISTER_BMAC_CONTROL);
2301 wb_write[1] = REG_RD(bp,
2302 bmac_addr + BIGMAC_REGISTER_BMAC_CONTROL + 4);
2303#endif
2304 wb_write[0] &= ~BMAC_CONTROL_RX_ENABLE;
2305 REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_BMAC_CONTROL,
2306 wb_write, 2);
2307 msleep(1);
2308 }
2309}
2310
1936static void bnx2x_emac_enable(struct bnx2x *bp) 2311static void bnx2x_emac_enable(struct bnx2x *bp)
1937{ 2312{
1938 int port = bp->port; 2313 int port = bp->port;
@@ -1940,7 +2315,7 @@ static void bnx2x_emac_enable(struct bnx2x *bp)
1940 u32 val; 2315 u32 val;
1941 int timeout; 2316 int timeout;
1942 2317
1943 DP(NETIF_MSG_LINK, "enableing EMAC\n"); 2318 DP(NETIF_MSG_LINK, "enabling EMAC\n");
1944 /* reset and unreset the emac core */ 2319 /* reset and unreset the emac core */
1945 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, 2320 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
1946 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port)); 2321 (MISC_REGISTERS_RESET_REG_2_RST_EMAC0_HARD_CORE << port));
@@ -2033,7 +2408,7 @@ static void bnx2x_emac_enable(struct bnx2x *bp)
2033 EMAC_TX_MODE_EXT_PAUSE_EN); 2408 EMAC_TX_MODE_EXT_PAUSE_EN);
2034 } 2409 }
2035 2410
2036 /* KEEP_VLAN_TAG, promiscous */ 2411 /* KEEP_VLAN_TAG, promiscuous */
2037 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE); 2412 val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE);
2038 val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS; 2413 val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS;
2039 EMAC_WR(EMAC_REG_EMAC_RX_MODE, val); 2414 EMAC_WR(EMAC_REG_EMAC_RX_MODE, val);
@@ -2161,7 +2536,6 @@ static void bnx2x_pbf_update(struct bnx2x *bp)
2161 u32 count = 1000; 2536 u32 count = 1000;
2162 u32 pause = 0; 2537 u32 pause = 0;
2163 2538
2164
2165 /* disable port */ 2539 /* disable port */
2166 REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1); 2540 REG_WR(bp, PBF_REG_DISABLE_NEW_TASK_PROC_P0 + port*4, 0x1);
2167 2541
@@ -2232,7 +2606,7 @@ static void bnx2x_pbf_update(struct bnx2x *bp)
2232static void bnx2x_update_mng(struct bnx2x *bp) 2606static void bnx2x_update_mng(struct bnx2x *bp)
2233{ 2607{
2234 if (!nomcp) 2608 if (!nomcp)
2235 SHMEM_WR(bp, drv_fw_mb[bp->port].link_status, 2609 SHMEM_WR(bp, port_mb[bp->port].link_status,
2236 bp->link_status); 2610 bp->link_status);
2237} 2611}
2238 2612
@@ -2294,19 +2668,19 @@ static void bnx2x_link_down(struct bnx2x *bp)
2294 DP(BNX2X_MSG_STATS, "stats_state - STOP\n"); 2668 DP(BNX2X_MSG_STATS, "stats_state - STOP\n");
2295 } 2669 }
2296 2670
2297 /* indicate link down */ 2671 /* indicate no mac active */
2298 bp->phy_flags &= ~(PHY_BMAC_FLAG | PHY_EMAC_FLAG); 2672 bp->phy_flags &= ~(PHY_BMAC_FLAG | PHY_EMAC_FLAG);
2299 2673
2300 /* reset BigMac */ 2674 /* update shared memory */
2301 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR, 2675 bnx2x_update_mng(bp);
2302 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port));
2303 2676
2304 /* ignore drain flag interrupt */
2305 /* activate nig drain */ 2677 /* activate nig drain */
2306 NIG_WR(NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); 2678 NIG_WR(NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1);
2307 2679
2308 /* update shared memory */ 2680 /* reset BigMac */
2309 bnx2x_update_mng(bp); 2681 bnx2x_bmac_rx_disable(bp);
2682 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
2683 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port));
2310 2684
2311 /* indicate link down */ 2685 /* indicate link down */
2312 bnx2x_link_report(bp); 2686 bnx2x_link_report(bp);
@@ -2317,14 +2691,15 @@ static void bnx2x_init_mac_stats(struct bnx2x *bp);
2317/* This function is called upon link interrupt */ 2691/* This function is called upon link interrupt */
2318static void bnx2x_link_update(struct bnx2x *bp) 2692static void bnx2x_link_update(struct bnx2x *bp)
2319{ 2693{
2320 u32 gp_status;
2321 int port = bp->port; 2694 int port = bp->port;
2322 int i; 2695 int i;
2696 u32 gp_status;
2323 int link_10g; 2697 int link_10g;
2324 2698
2325 DP(NETIF_MSG_LINK, "port %x, is xgxs %x, stat_mask 0x%x," 2699 DP(NETIF_MSG_LINK, "port %x, %s, int_status 0x%x,"
2326 " int_mask 0x%x, saved_mask 0x%x, MI_INT %x, SERDES_LINK %x," 2700 " int_mask 0x%x, saved_mask 0x%x, MI_INT %x, SERDES_LINK %x,"
2327 " 10G %x, XGXS_LINK %x\n", port, (bp->phy_flags & PHY_XGXS_FLAG), 2701 " 10G %x, XGXS_LINK %x\n", port,
2702 (bp->phy_flags & PHY_XGXS_FLAG)? "XGXS":"SerDes",
2328 REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4), 2703 REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4),
2329 REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), bp->nig_mask, 2704 REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4), bp->nig_mask,
2330 REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18), 2705 REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18),
@@ -2336,7 +2711,7 @@ static void bnx2x_link_update(struct bnx2x *bp)
2336 might_sleep(); 2711 might_sleep();
2337 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_GP_STATUS); 2712 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_GP_STATUS);
2338 /* avoid fast toggling */ 2713 /* avoid fast toggling */
2339 for (i = 0 ; i < 10 ; i++) { 2714 for (i = 0; i < 10; i++) {
2340 msleep(10); 2715 msleep(10);
2341 bnx2x_mdio22_read(bp, MDIO_GP_STATUS_TOP_AN_STATUS1, 2716 bnx2x_mdio22_read(bp, MDIO_GP_STATUS_TOP_AN_STATUS1,
2342 &gp_status); 2717 &gp_status);
@@ -2351,7 +2726,8 @@ static void bnx2x_link_update(struct bnx2x *bp)
2351 bnx2x_link_int_ack(bp, link_10g); 2726 bnx2x_link_int_ack(bp, link_10g);
2352 2727
2353 /* link is up only if both local phy and external phy are up */ 2728 /* link is up only if both local phy and external phy are up */
2354 if (bp->link_up && bnx2x_ext_phy_is_link_up(bp)) { 2729 bp->link_up = (bp->phy_link_up && bnx2x_ext_phy_is_link_up(bp));
2730 if (bp->link_up) {
2355 if (link_10g) { 2731 if (link_10g) {
2356 bnx2x_bmac_enable(bp, 0); 2732 bnx2x_bmac_enable(bp, 0);
2357 bnx2x_leds_set(bp, SPEED_10000); 2733 bnx2x_leds_set(bp, SPEED_10000);
@@ -2427,7 +2803,9 @@ static void bnx2x_reset_unicore(struct bnx2x *bp)
2427 } 2803 }
2428 } 2804 }
2429 2805
2430 BNX2X_ERR("BUG! unicore is still in reset!\n"); 2806 BNX2X_ERR("BUG! %s (0x%x) is still in reset!\n",
2807 (bp->phy_flags & PHY_XGXS_FLAG)? "XGXS":"SerDes",
2808 bp->phy_addr);
2431} 2809}
2432 2810
2433static void bnx2x_set_swap_lanes(struct bnx2x *bp) 2811static void bnx2x_set_swap_lanes(struct bnx2x *bp)
@@ -2475,12 +2853,12 @@ static void bnx2x_set_parallel_detection(struct bnx2x *bp)
2475 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_10G_PARALLEL_DETECT); 2853 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_10G_PARALLEL_DETECT);
2476 2854
2477 bnx2x_mdio22_write(bp, 2855 bnx2x_mdio22_write(bp,
2478 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK, 2856 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK,
2479 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT); 2857 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_LINK_CNT);
2480 2858
2481 bnx2x_mdio22_read(bp, 2859 bnx2x_mdio22_read(bp,
2482 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, 2860 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL,
2483 &control2); 2861 &control2);
2484 2862
2485 if (bp->autoneg & AUTONEG_PARALLEL) { 2863 if (bp->autoneg & AUTONEG_PARALLEL) {
2486 control2 |= 2864 control2 |=
@@ -2490,8 +2868,14 @@ static void bnx2x_set_parallel_detection(struct bnx2x *bp)
2490 ~MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN; 2868 ~MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL_PARDET10G_EN;
2491 } 2869 }
2492 bnx2x_mdio22_write(bp, 2870 bnx2x_mdio22_write(bp,
2493 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL, 2871 MDIO_10G_PARALLEL_DETECT_PAR_DET_10G_CONTROL,
2494 control2); 2872 control2);
2873
2874 /* Disable parallel detection of HiG */
2875 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_XGXS_BLOCK2);
2876 bnx2x_mdio22_write(bp, MDIO_XGXS_BLOCK2_UNICORE_MODE_10G,
2877 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS |
2878 MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS);
2495 } 2879 }
2496} 2880}
2497 2881
@@ -2625,7 +3009,7 @@ static void bnx2x_set_brcm_cl37_advertisment(struct bnx2x *bp)
2625 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_OVER_1G); 3009 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_OVER_1G);
2626 3010
2627 /* set extended capabilities */ 3011 /* set extended capabilities */
2628 if (bp->advertising & ADVERTISED_2500baseT_Full) 3012 if (bp->advertising & ADVERTISED_2500baseX_Full)
2629 val |= MDIO_OVER_1G_UP1_2_5G; 3013 val |= MDIO_OVER_1G_UP1_2_5G;
2630 if (bp->advertising & ADVERTISED_10000baseT_Full) 3014 if (bp->advertising & ADVERTISED_10000baseT_Full)
2631 val |= MDIO_OVER_1G_UP1_10G; 3015 val |= MDIO_OVER_1G_UP1_10G;
@@ -2641,20 +3025,91 @@ static void bnx2x_set_ieee_aneg_advertisment(struct bnx2x *bp)
2641 /* for AN, we are always publishing full duplex */ 3025 /* for AN, we are always publishing full duplex */
2642 an_adv = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX; 3026 an_adv = MDIO_COMBO_IEEE0_AUTO_NEG_ADV_FULL_DUPLEX;
2643 3027
2644 /* set pause */ 3028 /* resolve pause mode and advertisement
2645 switch (bp->pause_mode) { 3029 * Please refer to Table 28B-3 of the 802.3ab-1999 spec */
2646 case PAUSE_SYMMETRIC: 3030 if (bp->req_autoneg & AUTONEG_FLOW_CTRL) {
2647 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_SYMMETRIC; 3031 switch (bp->req_flow_ctrl) {
2648 break; 3032 case FLOW_CTRL_AUTO:
2649 case PAUSE_ASYMMETRIC: 3033 if (bp->dev->mtu <= 4500) {
2650 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC; 3034 an_adv |=
2651 break; 3035 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH;
2652 case PAUSE_BOTH: 3036 bp->advertising |= (ADVERTISED_Pause |
2653 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH; 3037 ADVERTISED_Asym_Pause);
2654 break; 3038 } else {
2655 case PAUSE_NONE: 3039 an_adv |=
2656 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE; 3040 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC;
2657 break; 3041 bp->advertising |= ADVERTISED_Asym_Pause;
3042 }
3043 break;
3044
3045 case FLOW_CTRL_TX:
3046 an_adv |=
3047 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC;
3048 bp->advertising |= ADVERTISED_Asym_Pause;
3049 break;
3050
3051 case FLOW_CTRL_RX:
3052 if (bp->dev->mtu <= 4500) {
3053 an_adv |=
3054 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH;
3055 bp->advertising |= (ADVERTISED_Pause |
3056 ADVERTISED_Asym_Pause);
3057 } else {
3058 an_adv |=
3059 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE;
3060 bp->advertising &= ~(ADVERTISED_Pause |
3061 ADVERTISED_Asym_Pause);
3062 }
3063 break;
3064
3065 case FLOW_CTRL_BOTH:
3066 if (bp->dev->mtu <= 4500) {
3067 an_adv |=
3068 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH;
3069 bp->advertising |= (ADVERTISED_Pause |
3070 ADVERTISED_Asym_Pause);
3071 } else {
3072 an_adv |=
3073 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC;
3074 bp->advertising |= ADVERTISED_Asym_Pause;
3075 }
3076 break;
3077
3078 case FLOW_CTRL_NONE:
3079 default:
3080 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE;
3081 bp->advertising &= ~(ADVERTISED_Pause |
3082 ADVERTISED_Asym_Pause);
3083 break;
3084 }
3085 } else { /* forced mode */
3086 switch (bp->req_flow_ctrl) {
3087 case FLOW_CTRL_AUTO:
3088 DP(NETIF_MSG_LINK, "req_flow_ctrl 0x%x while"
3089 " req_autoneg 0x%x\n",
3090 bp->req_flow_ctrl, bp->req_autoneg);
3091 break;
3092
3093 case FLOW_CTRL_TX:
3094 an_adv |=
3095 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_ASYMMETRIC;
3096 bp->advertising |= ADVERTISED_Asym_Pause;
3097 break;
3098
3099 case FLOW_CTRL_RX:
3100 case FLOW_CTRL_BOTH:
3101 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH;
3102 bp->advertising |= (ADVERTISED_Pause |
3103 ADVERTISED_Asym_Pause);
3104 break;
3105
3106 case FLOW_CTRL_NONE:
3107 default:
3108 an_adv |= MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE;
3109 bp->advertising &= ~(ADVERTISED_Pause |
3110 ADVERTISED_Asym_Pause);
3111 break;
3112 }
2658 } 3113 }
2659 3114
2660 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_COMBO_IEEE0); 3115 MDIO_SET_REG_BANK(bp, MDIO_REG_BANK_COMBO_IEEE0);
@@ -2752,47 +3207,162 @@ static void bnx2x_initialize_sgmii_process(struct bnx2x *bp)
2752static void bnx2x_link_int_enable(struct bnx2x *bp) 3207static void bnx2x_link_int_enable(struct bnx2x *bp)
2753{ 3208{
2754 int port = bp->port; 3209 int port = bp->port;
3210 u32 ext_phy_type;
3211 u32 mask;
2755 3212
2756 /* setting the status to report on link up 3213 /* setting the status to report on link up
2757 for either XGXS or SerDes */ 3214 for either XGXS or SerDes */
2758 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4, 3215 bnx2x_bits_dis(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4,
2759 (NIG_XGXS0_LINK_STATUS | 3216 (NIG_STATUS_XGXS0_LINK10G |
2760 NIG_STATUS_INTERRUPT_XGXS0_LINK10G | 3217 NIG_STATUS_XGXS0_LINK_STATUS |
2761 NIG_SERDES0_LINK_STATUS)); 3218 NIG_STATUS_SERDES0_LINK_STATUS));
2762 3219
2763 if (bp->phy_flags & PHY_XGXS_FLAG) { 3220 if (bp->phy_flags & PHY_XGXS_FLAG) {
2764 /* TBD - 3221 mask = (NIG_MASK_XGXS0_LINK10G |
2765 * in force mode (not AN) we can enable just the relevant 3222 NIG_MASK_XGXS0_LINK_STATUS);
2766 * interrupt 3223 DP(NETIF_MSG_LINK, "enabled XGXS interrupt\n");
2767 * Even in AN we might enable only one according to the AN 3224 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
2768 * speed mask 3225 if ((ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) &&
2769 */ 3226 (ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) &&
2770 bnx2x_bits_en(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 3227 (ext_phy_type !=
2771 (NIG_MASK_XGXS0_LINK_STATUS | 3228 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN)) {
2772 NIG_MASK_XGXS0_LINK10G)); 3229 mask |= NIG_MASK_MI_INT;
2773 DP(NETIF_MSG_LINK, "enable XGXS interrupt\n"); 3230 DP(NETIF_MSG_LINK, "enabled external phy int\n");
3231 }
2774 3232
2775 } else { /* SerDes */ 3233 } else { /* SerDes */
2776 bnx2x_bits_en(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 3234 mask = NIG_MASK_SERDES0_LINK_STATUS;
2777 NIG_MASK_SERDES0_LINK_STATUS); 3235 DP(NETIF_MSG_LINK, "enabled SerDes interrupt\n");
2778 DP(NETIF_MSG_LINK, "enable SerDes interrupt\n"); 3236 ext_phy_type = SERDES_EXT_PHY_TYPE(bp);
3237 if ((ext_phy_type !=
3238 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_DIRECT) &&
3239 (ext_phy_type !=
3240 PORT_HW_CFG_SERDES_EXT_PHY_TYPE_NOT_CONN)) {
3241 mask |= NIG_MASK_MI_INT;
3242 DP(NETIF_MSG_LINK, "enabled external phy int\n");
3243 }
2779 } 3244 }
3245 bnx2x_bits_en(bp,
3246 NIG_REG_MASK_INTERRUPT_PORT0 + port*4,
3247 mask);
3248 DP(NETIF_MSG_LINK, "port %x, %s, int_status 0x%x,"
3249 " int_mask 0x%x, MI_INT %x, SERDES_LINK %x,"
3250 " 10G %x, XGXS_LINK %x\n", port,
3251 (bp->phy_flags & PHY_XGXS_FLAG)? "XGXS":"SerDes",
3252 REG_RD(bp, NIG_REG_STATUS_INTERRUPT_PORT0 + port*4),
3253 REG_RD(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4),
3254 REG_RD(bp, NIG_REG_EMAC0_STATUS_MISC_MI_INT + port*0x18),
3255 REG_RD(bp, NIG_REG_SERDES0_STATUS_LINK_STATUS + port*0x3c),
3256 REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK10G + port*0x68),
3257 REG_RD(bp, NIG_REG_XGXS0_STATUS_LINK_STATUS + port*0x68)
3258 );
3259}
3260
3261static void bnx2x_bcm8072_external_rom_boot(struct bnx2x *bp)
3262{
3263 u32 ext_phy_addr = ((bp->ext_phy_config &
3264 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
3265 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
3266 u32 fw_ver1, fw_ver2;
3267
3268 /* Need to wait 200ms after reset */
3269 msleep(200);
3270 /* Boot port from external ROM
3271 * Set ser_boot_ctl bit in the MISC_CTRL1 register
3272 */
3273 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3274 EXT_PHY_KR_PMA_PMD_DEVAD,
3275 EXT_PHY_KR_MISC_CTRL1, 0x0001);
3276
3277 /* Reset internal microprocessor */
3278 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3279 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_GEN_CTRL,
3280 EXT_PHY_KR_ROM_RESET_INTERNAL_MP);
3281 /* set micro reset = 0 */
3282 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3283 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_GEN_CTRL,
3284 EXT_PHY_KR_ROM_MICRO_RESET);
3285 /* Reset internal microprocessor */
3286 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3287 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_GEN_CTRL,
3288 EXT_PHY_KR_ROM_RESET_INTERNAL_MP);
3289 /* wait for 100ms for code download via SPI port */
3290 msleep(100);
3291
3292 /* Clear ser_boot_ctl bit */
3293 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3294 EXT_PHY_KR_PMA_PMD_DEVAD,
3295 EXT_PHY_KR_MISC_CTRL1, 0x0000);
3296 /* Wait 100ms */
3297 msleep(100);
3298
3299 /* Print the PHY FW version */
3300 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0, ext_phy_addr,
3301 EXT_PHY_KR_PMA_PMD_DEVAD,
3302 0xca19, &fw_ver1);
3303 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0, ext_phy_addr,
3304 EXT_PHY_KR_PMA_PMD_DEVAD,
3305 0xca1a, &fw_ver2);
3306 DP(NETIF_MSG_LINK,
3307 "8072 FW version 0x%x:0x%x\n", fw_ver1, fw_ver2);
3308}
3309
3310static void bnx2x_bcm8072_force_10G(struct bnx2x *bp)
3311{
3312 u32 ext_phy_addr = ((bp->ext_phy_config &
3313 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
3314 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
3315
3316 /* Force KR or KX */
3317 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3318 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_CTRL,
3319 0x2040);
3320 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3321 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_CTRL2,
3322 0x000b);
3323 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3324 EXT_PHY_KR_PMA_PMD_DEVAD, EXT_PHY_KR_PMD_CTRL,
3325 0x0000);
3326 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0, ext_phy_addr,
3327 EXT_PHY_KR_AUTO_NEG_DEVAD, EXT_PHY_KR_CTRL,
3328 0x0000);
2780} 3329}
2781 3330
2782static void bnx2x_ext_phy_init(struct bnx2x *bp) 3331static void bnx2x_ext_phy_init(struct bnx2x *bp)
2783{ 3332{
2784 int port = bp->port;
2785 u32 ext_phy_type; 3333 u32 ext_phy_type;
2786 u32 ext_phy_addr; 3334 u32 ext_phy_addr;
2787 u32 local_phy; 3335 u32 cnt;
3336 u32 ctrl;
3337 u32 val = 0;
2788 3338
2789 if (bp->phy_flags & PHY_XGXS_FLAG) { 3339 if (bp->phy_flags & PHY_XGXS_FLAG) {
2790 local_phy = bp->phy_addr;
2791 ext_phy_addr = ((bp->ext_phy_config & 3340 ext_phy_addr = ((bp->ext_phy_config &
2792 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >> 3341 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
2793 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT); 3342 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
2794 3343
2795 ext_phy_type = XGXS_EXT_PHY_TYPE(bp); 3344 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
3345 /* Make sure that the soft reset is off (expect for the 8072:
3346 * due to the lock, it will be done inside the specific
3347 * handling)
3348 */
3349 if ((ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT) &&
3350 (ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE) &&
3351 (ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN) &&
3352 (ext_phy_type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072)) {
3353 /* Wait for soft reset to get cleared upto 1 sec */
3354 for (cnt = 0; cnt < 1000; cnt++) {
3355 bnx2x_mdio45_read(bp, ext_phy_addr,
3356 EXT_PHY_OPT_PMA_PMD_DEVAD,
3357 EXT_PHY_OPT_CNTL, &ctrl);
3358 if (!(ctrl & (1<<15)))
3359 break;
3360 msleep(1);
3361 }
3362 DP(NETIF_MSG_LINK,
3363 "control reg 0x%x (after %d ms)\n", ctrl, cnt);
3364 }
3365
2796 switch (ext_phy_type) { 3366 switch (ext_phy_type) {
2797 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: 3367 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT:
2798 DP(NETIF_MSG_LINK, "XGXS Direct\n"); 3368 DP(NETIF_MSG_LINK, "XGXS Direct\n");
@@ -2800,49 +3370,235 @@ static void bnx2x_ext_phy_init(struct bnx2x *bp)
2800 3370
2801 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: 3371 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705:
2802 DP(NETIF_MSG_LINK, "XGXS 8705\n"); 3372 DP(NETIF_MSG_LINK, "XGXS 8705\n");
2803 bnx2x_bits_en(bp,
2804 NIG_REG_MASK_INTERRUPT_PORT0 + port*4,
2805 NIG_MASK_MI_INT);
2806 DP(NETIF_MSG_LINK, "enabled extenal phy int\n");
2807 3373
2808 bp->phy_addr = ext_phy_type; 3374 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
2809 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 3375 EXT_PHY_OPT_PMA_PMD_DEVAD,
2810 EXT_PHY_OPT_PMD_MISC_CNTL, 3376 EXT_PHY_OPT_PMD_MISC_CNTL,
2811 0x8288); 3377 0x8288);
2812 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 3378 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3379 EXT_PHY_OPT_PMA_PMD_DEVAD,
2813 EXT_PHY_OPT_PHY_IDENTIFIER, 3380 EXT_PHY_OPT_PHY_IDENTIFIER,
2814 0x7fbf); 3381 0x7fbf);
2815 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 3382 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3383 EXT_PHY_OPT_PMA_PMD_DEVAD,
2816 EXT_PHY_OPT_CMU_PLL_BYPASS, 3384 EXT_PHY_OPT_CMU_PLL_BYPASS,
2817 0x0100); 3385 0x0100);
2818 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_WIS_DEVAD, 3386 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3387 EXT_PHY_OPT_WIS_DEVAD,
2819 EXT_PHY_OPT_LASI_CNTL, 0x1); 3388 EXT_PHY_OPT_LASI_CNTL, 0x1);
2820 break; 3389 break;
2821 3390
2822 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: 3391 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706:
2823 DP(NETIF_MSG_LINK, "XGXS 8706\n"); 3392 DP(NETIF_MSG_LINK, "XGXS 8706\n");
2824 bnx2x_bits_en(bp, 3393
2825 NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 3394 if (!(bp->req_autoneg & AUTONEG_SPEED)) {
2826 NIG_MASK_MI_INT); 3395 /* Force speed */
2827 DP(NETIF_MSG_LINK, "enabled extenal phy int\n"); 3396 if (bp->req_line_speed == SPEED_10000) {
2828 3397 DP(NETIF_MSG_LINK,
2829 bp->phy_addr = ext_phy_type; 3398 "XGXS 8706 force 10Gbps\n");
2830 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 3399 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
2831 EXT_PHY_OPT_PMD_DIGITAL_CNT, 3400 EXT_PHY_OPT_PMA_PMD_DEVAD,
2832 0x400); 3401 EXT_PHY_OPT_PMD_DIGITAL_CNT,
2833 bnx2x_mdio45_vwrite(bp, EXT_PHY_OPT_PMA_PMD_DEVAD, 3402 0x400);
3403 } else {
3404 /* Force 1Gbps */
3405 DP(NETIF_MSG_LINK,
3406 "XGXS 8706 force 1Gbps\n");
3407
3408 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3409 EXT_PHY_OPT_PMA_PMD_DEVAD,
3410 EXT_PHY_OPT_CNTL,
3411 0x0040);
3412
3413 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3414 EXT_PHY_OPT_PMA_PMD_DEVAD,
3415 EXT_PHY_OPT_CNTL2,
3416 0x000D);
3417 }
3418
3419 /* Enable LASI */
3420 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3421 EXT_PHY_OPT_PMA_PMD_DEVAD,
3422 EXT_PHY_OPT_LASI_CNTL,
3423 0x1);
3424 } else {
3425 /* AUTONEG */
3426 /* Allow CL37 through CL73 */
3427 DP(NETIF_MSG_LINK, "XGXS 8706 AutoNeg\n");
3428 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3429 EXT_PHY_AUTO_NEG_DEVAD,
3430 EXT_PHY_OPT_AN_CL37_CL73,
3431 0x040c);
3432
3433 /* Enable Full-Duplex advertisment on CL37 */
3434 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3435 EXT_PHY_AUTO_NEG_DEVAD,
3436 EXT_PHY_OPT_AN_CL37_FD,
3437 0x0020);
3438 /* Enable CL37 AN */
3439 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3440 EXT_PHY_AUTO_NEG_DEVAD,
3441 EXT_PHY_OPT_AN_CL37_AN,
3442 0x1000);
3443 /* Advertise 10G/1G support */
3444 if (bp->advertising &
3445 ADVERTISED_1000baseT_Full)
3446 val = (1<<5);
3447 if (bp->advertising &
3448 ADVERTISED_10000baseT_Full)
3449 val |= (1<<7);
3450
3451 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3452 EXT_PHY_AUTO_NEG_DEVAD,
3453 EXT_PHY_OPT_AN_ADV, val);
3454 /* Enable LASI */
3455 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3456 EXT_PHY_OPT_PMA_PMD_DEVAD,
3457 EXT_PHY_OPT_LASI_CNTL,
3458 0x1);
3459
3460 /* Enable clause 73 AN */
3461 bnx2x_mdio45_write(bp, ext_phy_addr,
3462 EXT_PHY_AUTO_NEG_DEVAD,
3463 EXT_PHY_OPT_CNTL,
3464 0x1200);
3465 }
3466 break;
3467
3468 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072:
3469 bnx2x_hw_lock(bp, HW_LOCK_RESOURCE_8072_MDIO);
3470 /* Wait for soft reset to get cleared upto 1 sec */
3471 for (cnt = 0; cnt < 1000; cnt++) {
3472 bnx2x_mdio45_ctrl_read(bp, GRCBASE_EMAC0,
3473 ext_phy_addr,
3474 EXT_PHY_OPT_PMA_PMD_DEVAD,
3475 EXT_PHY_OPT_CNTL, &ctrl);
3476 if (!(ctrl & (1<<15)))
3477 break;
3478 msleep(1);
3479 }
3480 DP(NETIF_MSG_LINK,
3481 "8072 control reg 0x%x (after %d ms)\n",
3482 ctrl, cnt);
3483
3484 bnx2x_bcm8072_external_rom_boot(bp);
3485 DP(NETIF_MSG_LINK, "Finshed loading 8072 KR ROM\n");
3486
3487 /* enable LASI */
3488 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3489 ext_phy_addr,
3490 EXT_PHY_KR_PMA_PMD_DEVAD,
3491 0x9000, 0x0400);
3492 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3493 ext_phy_addr,
3494 EXT_PHY_KR_PMA_PMD_DEVAD,
3495 EXT_PHY_KR_LASI_CNTL, 0x0004);
3496
3497 /* If this is forced speed, set to KR or KX
3498 * (all other are not supported)
3499 */
3500 if (!(bp->req_autoneg & AUTONEG_SPEED)) {
3501 if (bp->req_line_speed == SPEED_10000) {
3502 bnx2x_bcm8072_force_10G(bp);
3503 DP(NETIF_MSG_LINK,
3504 "Forced speed 10G on 8072\n");
3505 /* unlock */
3506 bnx2x_hw_unlock(bp,
3507 HW_LOCK_RESOURCE_8072_MDIO);
3508 break;
3509 } else
3510 val = (1<<5);
3511 } else {
3512
3513 /* Advertise 10G/1G support */
3514 if (bp->advertising &
3515 ADVERTISED_1000baseT_Full)
3516 val = (1<<5);
3517 if (bp->advertising &
3518 ADVERTISED_10000baseT_Full)
3519 val |= (1<<7);
3520 }
3521 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3522 ext_phy_addr,
3523 EXT_PHY_KR_AUTO_NEG_DEVAD,
3524 0x11, val);
3525 /* Add support for CL37 ( passive mode ) I */
3526 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3527 ext_phy_addr,
3528 EXT_PHY_KR_AUTO_NEG_DEVAD,
3529 0x8370, 0x040c);
3530 /* Add support for CL37 ( passive mode ) II */
3531 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3532 ext_phy_addr,
3533 EXT_PHY_KR_AUTO_NEG_DEVAD,
3534 0xffe4, 0x20);
3535 /* Add support for CL37 ( passive mode ) III */
3536 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3537 ext_phy_addr,
3538 EXT_PHY_KR_AUTO_NEG_DEVAD,
3539 0xffe0, 0x1000);
3540 /* Restart autoneg */
3541 msleep(500);
3542 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3543 ext_phy_addr,
3544 EXT_PHY_KR_AUTO_NEG_DEVAD,
3545 EXT_PHY_KR_CTRL, 0x1200);
3546 DP(NETIF_MSG_LINK, "8072 Autoneg Restart: "
3547 "1G %ssupported 10G %ssupported\n",
3548 (val & (1<<5)) ? "" : "not ",
3549 (val & (1<<7)) ? "" : "not ");
3550
3551 /* unlock */
3552 bnx2x_hw_unlock(bp, HW_LOCK_RESOURCE_8072_MDIO);
3553 break;
3554
3555 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101:
3556 DP(NETIF_MSG_LINK,
3557 "Setting the SFX7101 LASI indication\n");
3558 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3559 EXT_PHY_OPT_PMA_PMD_DEVAD,
2834 EXT_PHY_OPT_LASI_CNTL, 0x1); 3560 EXT_PHY_OPT_LASI_CNTL, 0x1);
3561 DP(NETIF_MSG_LINK,
3562 "Setting the SFX7101 LED to blink on traffic\n");
3563 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3564 EXT_PHY_OPT_PMA_PMD_DEVAD,
3565 0xC007, (1<<3));
3566
3567 /* read modify write pause advertizing */
3568 bnx2x_mdio45_read(bp, ext_phy_addr,
3569 EXT_PHY_KR_AUTO_NEG_DEVAD,
3570 EXT_PHY_KR_AUTO_NEG_ADVERT, &val);
3571 val &= ~EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_BOTH;
3572 /* Please refer to Table 28B-3 of 802.3ab-1999 spec. */
3573 if (bp->advertising & ADVERTISED_Pause)
3574 val |= EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE;
3575
3576 if (bp->advertising & ADVERTISED_Asym_Pause) {
3577 val |=
3578 EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_ASYMMETRIC;
3579 }
3580 DP(NETIF_MSG_LINK, "SFX7101 AN advertize 0x%x\n", val);
3581 bnx2x_mdio45_vwrite(bp, ext_phy_addr,
3582 EXT_PHY_KR_AUTO_NEG_DEVAD,
3583 EXT_PHY_KR_AUTO_NEG_ADVERT, val);
3584 /* Restart autoneg */
3585 bnx2x_mdio45_read(bp, ext_phy_addr,
3586 EXT_PHY_KR_AUTO_NEG_DEVAD,
3587 EXT_PHY_KR_CTRL, &val);
3588 val |= 0x200;
3589 bnx2x_mdio45_write(bp, ext_phy_addr,
3590 EXT_PHY_KR_AUTO_NEG_DEVAD,
3591 EXT_PHY_KR_CTRL, val);
2835 break; 3592 break;
2836 3593
2837 default: 3594 default:
2838 DP(NETIF_MSG_LINK, "BAD XGXS ext_phy_config 0x%x\n", 3595 BNX2X_ERR("BAD XGXS ext_phy_config 0x%x\n",
2839 bp->ext_phy_config); 3596 bp->ext_phy_config);
2840 break; 3597 break;
2841 } 3598 }
2842 bp->phy_addr = local_phy;
2843 3599
2844 } else { /* SerDes */ 3600 } else { /* SerDes */
2845/* ext_phy_addr = ((bp->ext_phy_config & 3601/* ext_phy_addr = ((bp->ext_phy_config &
2846 PORT_HW_CFG_SERDES_EXT_PHY_ADDR_MASK) >> 3602 PORT_HW_CFG_SERDES_EXT_PHY_ADDR_MASK) >>
2847 PORT_HW_CFG_SERDES_EXT_PHY_ADDR_SHIFT); 3603 PORT_HW_CFG_SERDES_EXT_PHY_ADDR_SHIFT);
2848*/ 3604*/
@@ -2854,10 +3610,6 @@ static void bnx2x_ext_phy_init(struct bnx2x *bp)
2854 3610
2855 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482: 3611 case PORT_HW_CFG_SERDES_EXT_PHY_TYPE_BCM5482:
2856 DP(NETIF_MSG_LINK, "SerDes 5482\n"); 3612 DP(NETIF_MSG_LINK, "SerDes 5482\n");
2857 bnx2x_bits_en(bp,
2858 NIG_REG_MASK_INTERRUPT_PORT0 + port*4,
2859 NIG_MASK_MI_INT);
2860 DP(NETIF_MSG_LINK, "enabled extenal phy int\n");
2861 break; 3613 break;
2862 3614
2863 default: 3615 default:
@@ -2871,8 +3623,22 @@ static void bnx2x_ext_phy_init(struct bnx2x *bp)
2871static void bnx2x_ext_phy_reset(struct bnx2x *bp) 3623static void bnx2x_ext_phy_reset(struct bnx2x *bp)
2872{ 3624{
2873 u32 ext_phy_type; 3625 u32 ext_phy_type;
2874 u32 ext_phy_addr; 3626 u32 ext_phy_addr = ((bp->ext_phy_config &
2875 u32 local_phy; 3627 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
3628 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
3629 u32 board = (bp->board & SHARED_HW_CFG_BOARD_TYPE_MASK);
3630
3631 /* The PHY reset is controled by GPIO 1
3632 * Give it 1ms of reset pulse
3633 */
3634 if ((board != SHARED_HW_CFG_BOARD_TYPE_BCM957710T1002G) &&
3635 (board != SHARED_HW_CFG_BOARD_TYPE_BCM957710T1003G)) {
3636 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1,
3637 MISC_REGISTERS_GPIO_OUTPUT_LOW);
3638 msleep(1);
3639 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1,
3640 MISC_REGISTERS_GPIO_OUTPUT_HIGH);
3641 }
2876 3642
2877 if (bp->phy_flags & PHY_XGXS_FLAG) { 3643 if (bp->phy_flags & PHY_XGXS_FLAG) {
2878 ext_phy_type = XGXS_EXT_PHY_TYPE(bp); 3644 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
@@ -2883,15 +3649,24 @@ static void bnx2x_ext_phy_reset(struct bnx2x *bp)
2883 3649
2884 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: 3650 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705:
2885 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: 3651 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706:
2886 DP(NETIF_MSG_LINK, "XGXS 8705/6\n"); 3652 DP(NETIF_MSG_LINK, "XGXS 8705/8706\n");
2887 local_phy = bp->phy_addr; 3653 bnx2x_mdio45_write(bp, ext_phy_addr,
2888 ext_phy_addr = ((bp->ext_phy_config & 3654 EXT_PHY_OPT_PMA_PMD_DEVAD,
2889 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK) >>
2890 PORT_HW_CFG_XGXS_EXT_PHY_ADDR_SHIFT);
2891 bp->phy_addr = (u8)ext_phy_addr;
2892 bnx2x_mdio45_write(bp, EXT_PHY_OPT_PMA_PMD_DEVAD,
2893 EXT_PHY_OPT_CNTL, 0xa040); 3655 EXT_PHY_OPT_CNTL, 0xa040);
2894 bp->phy_addr = local_phy; 3656 break;
3657
3658 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072:
3659 DP(NETIF_MSG_LINK, "XGXS 8072\n");
3660 bnx2x_hw_lock(bp, HW_LOCK_RESOURCE_8072_MDIO);
3661 bnx2x_mdio45_ctrl_write(bp, GRCBASE_EMAC0,
3662 ext_phy_addr,
3663 EXT_PHY_KR_PMA_PMD_DEVAD,
3664 0, 1<<15);
3665 bnx2x_hw_unlock(bp, HW_LOCK_RESOURCE_8072_MDIO);
3666 break;
3667
3668 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101:
3669 DP(NETIF_MSG_LINK, "XGXS SFX7101\n");
2895 break; 3670 break;
2896 3671
2897 default: 3672 default:
@@ -2930,6 +3705,7 @@ static void bnx2x_link_initialize(struct bnx2x *bp)
2930 NIG_MASK_SERDES0_LINK_STATUS | 3705 NIG_MASK_SERDES0_LINK_STATUS |
2931 NIG_MASK_MI_INT)); 3706 NIG_MASK_MI_INT));
2932 3707
3708 /* Activate the external PHY */
2933 bnx2x_ext_phy_reset(bp); 3709 bnx2x_ext_phy_reset(bp);
2934 3710
2935 bnx2x_set_aer_mmd(bp); 3711 bnx2x_set_aer_mmd(bp);
@@ -2994,13 +3770,13 @@ static void bnx2x_link_initialize(struct bnx2x *bp)
2994 /* AN enabled */ 3770 /* AN enabled */
2995 bnx2x_set_brcm_cl37_advertisment(bp); 3771 bnx2x_set_brcm_cl37_advertisment(bp);
2996 3772
2997 /* program duplex & pause advertisment (for aneg) */ 3773 /* program duplex & pause advertisement (for aneg) */
2998 bnx2x_set_ieee_aneg_advertisment(bp); 3774 bnx2x_set_ieee_aneg_advertisment(bp);
2999 3775
3000 /* enable autoneg */ 3776 /* enable autoneg */
3001 bnx2x_set_autoneg(bp); 3777 bnx2x_set_autoneg(bp);
3002 3778
3003 /* enalbe and restart AN */ 3779 /* enable and restart AN */
3004 bnx2x_restart_autoneg(bp); 3780 bnx2x_restart_autoneg(bp);
3005 } 3781 }
3006 3782
@@ -3010,11 +3786,11 @@ static void bnx2x_link_initialize(struct bnx2x *bp)
3010 bnx2x_initialize_sgmii_process(bp); 3786 bnx2x_initialize_sgmii_process(bp);
3011 } 3787 }
3012 3788
3013 /* enable the interrupt */
3014 bnx2x_link_int_enable(bp);
3015
3016 /* init ext phy and enable link state int */ 3789 /* init ext phy and enable link state int */
3017 bnx2x_ext_phy_init(bp); 3790 bnx2x_ext_phy_init(bp);
3791
3792 /* enable the interrupt */
3793 bnx2x_link_int_enable(bp);
3018} 3794}
3019 3795
3020static void bnx2x_phy_deassert(struct bnx2x *bp) 3796static void bnx2x_phy_deassert(struct bnx2x *bp)
@@ -3073,6 +3849,11 @@ static int bnx2x_phy_init(struct bnx2x *bp)
3073static void bnx2x_link_reset(struct bnx2x *bp) 3849static void bnx2x_link_reset(struct bnx2x *bp)
3074{ 3850{
3075 int port = bp->port; 3851 int port = bp->port;
3852 u32 board = (bp->board & SHARED_HW_CFG_BOARD_TYPE_MASK);
3853
3854 /* update shared memory */
3855 bp->link_status = 0;
3856 bnx2x_update_mng(bp);
3076 3857
3077 /* disable attentions */ 3858 /* disable attentions */
3078 bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4, 3859 bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + port*4,
@@ -3081,21 +3862,45 @@ static void bnx2x_link_reset(struct bnx2x *bp)
3081 NIG_MASK_SERDES0_LINK_STATUS | 3862 NIG_MASK_SERDES0_LINK_STATUS |
3082 NIG_MASK_MI_INT)); 3863 NIG_MASK_MI_INT));
3083 3864
3084 bnx2x_ext_phy_reset(bp); 3865 /* activate nig drain */
3866 NIG_WR(NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1);
3867
3868 /* disable nig egress interface */
3869 NIG_WR(NIG_REG_BMAC0_OUT_EN + port*4, 0);
3870 NIG_WR(NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0);
3871
3872 /* Stop BigMac rx */
3873 bnx2x_bmac_rx_disable(bp);
3874
3875 /* disable emac */
3876 NIG_WR(NIG_REG_NIG_EMAC0_EN + port*4, 0);
3877
3878 msleep(10);
3879
3880 /* The PHY reset is controled by GPIO 1
3881 * Hold it as output low
3882 */
3883 if ((board != SHARED_HW_CFG_BOARD_TYPE_BCM957710T1002G) &&
3884 (board != SHARED_HW_CFG_BOARD_TYPE_BCM957710T1003G)) {
3885 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1,
3886 MISC_REGISTERS_GPIO_OUTPUT_LOW);
3887 DP(NETIF_MSG_LINK, "reset external PHY\n");
3888 }
3085 3889
3086 /* reset the SerDes/XGXS */ 3890 /* reset the SerDes/XGXS */
3087 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, 3891 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR,
3088 (0x1ff << (port*16))); 3892 (0x1ff << (port*16)));
3089 3893
3090 /* reset EMAC / BMAC and disable NIG interfaces */ 3894 /* reset BigMac */
3091 NIG_WR(NIG_REG_BMAC0_IN_EN + port*4, 0); 3895 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_CLEAR,
3092 NIG_WR(NIG_REG_BMAC0_OUT_EN + port*4, 0); 3896 (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port));
3093 3897
3094 NIG_WR(NIG_REG_NIG_EMAC0_EN + port*4, 0); 3898 /* disable nig ingress interface */
3899 NIG_WR(NIG_REG_BMAC0_IN_EN + port*4, 0);
3095 NIG_WR(NIG_REG_EMAC0_IN_EN + port*4, 0); 3900 NIG_WR(NIG_REG_EMAC0_IN_EN + port*4, 0);
3096 NIG_WR(NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0);
3097 3901
3098 NIG_WR(NIG_REG_EGRESS_DRAIN0_MODE + port*4, 1); 3902 /* set link down */
3903 bp->link_up = 0;
3099} 3904}
3100 3905
3101#ifdef BNX2X_XGXS_LB 3906#ifdef BNX2X_XGXS_LB
@@ -3158,7 +3963,7 @@ static int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
3158 int port = bp->port; 3963 int port = bp->port;
3159 3964
3160 DP(NETIF_MSG_TIMER, 3965 DP(NETIF_MSG_TIMER,
3161 "spe (%x:%x) command %x hw_cid %x data (%x:%x) left %x\n", 3966 "spe (%x:%x) command %d hw_cid %x data (%x:%x) left %x\n",
3162 (u32)U64_HI(bp->spq_mapping), (u32)(U64_LO(bp->spq_mapping) + 3967 (u32)U64_HI(bp->spq_mapping), (u32)(U64_LO(bp->spq_mapping) +
3163 (void *)bp->spq_prod_bd - (void *)bp->spq), command, 3968 (void *)bp->spq_prod_bd - (void *)bp->spq), command,
3164 HW_CID(bp, cid), data_hi, data_lo, bp->spq_left); 3969 HW_CID(bp, cid), data_hi, data_lo, bp->spq_left);
@@ -3176,6 +3981,7 @@ static int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
3176 bnx2x_panic(); 3981 bnx2x_panic();
3177 return -EBUSY; 3982 return -EBUSY;
3178 } 3983 }
3984
3179 /* CID needs port number to be encoded int it */ 3985 /* CID needs port number to be encoded int it */
3180 bp->spq_prod_bd->hdr.conn_and_cmd_data = 3986 bp->spq_prod_bd->hdr.conn_and_cmd_data =
3181 cpu_to_le32(((command << SPE_HDR_CMD_ID_SHIFT) | 3987 cpu_to_le32(((command << SPE_HDR_CMD_ID_SHIFT) |
@@ -3282,8 +4088,8 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
3282 u32 igu_addr = (IGU_ADDR_ATTN_BITS_SET + IGU_PORT_BASE * port) * 8; 4088 u32 igu_addr = (IGU_ADDR_ATTN_BITS_SET + IGU_PORT_BASE * port) * 8;
3283 u32 aeu_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 : 4089 u32 aeu_addr = port ? MISC_REG_AEU_MASK_ATTN_FUNC_1 :
3284 MISC_REG_AEU_MASK_ATTN_FUNC_0; 4090 MISC_REG_AEU_MASK_ATTN_FUNC_0;
3285 u32 nig_mask_addr = port ? NIG_REG_MASK_INTERRUPT_PORT1 : 4091 u32 nig_int_mask_addr = port ? NIG_REG_MASK_INTERRUPT_PORT1 :
3286 NIG_REG_MASK_INTERRUPT_PORT0; 4092 NIG_REG_MASK_INTERRUPT_PORT0;
3287 4093
3288 if (~bp->aeu_mask & (asserted & 0xff)) 4094 if (~bp->aeu_mask & (asserted & 0xff))
3289 BNX2X_ERR("IGU ERROR\n"); 4095 BNX2X_ERR("IGU ERROR\n");
@@ -3301,15 +4107,11 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
3301 4107
3302 if (asserted & ATTN_HARD_WIRED_MASK) { 4108 if (asserted & ATTN_HARD_WIRED_MASK) {
3303 if (asserted & ATTN_NIG_FOR_FUNC) { 4109 if (asserted & ATTN_NIG_FOR_FUNC) {
3304 u32 nig_status_port;
3305 u32 nig_int_addr = port ?
3306 NIG_REG_STATUS_INTERRUPT_PORT1 :
3307 NIG_REG_STATUS_INTERRUPT_PORT0;
3308 4110
3309 bp->nig_mask = REG_RD(bp, nig_mask_addr); 4111 /* save nig interrupt mask */
3310 REG_WR(bp, nig_mask_addr, 0); 4112 bp->nig_mask = REG_RD(bp, nig_int_mask_addr);
4113 REG_WR(bp, nig_int_mask_addr, 0);
3311 4114
3312 nig_status_port = REG_RD(bp, nig_int_addr);
3313 bnx2x_link_update(bp); 4115 bnx2x_link_update(bp);
3314 4116
3315 /* handle unicore attn? */ 4117 /* handle unicore attn? */
@@ -3362,15 +4164,132 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
3362 4164
3363 /* now set back the mask */ 4165 /* now set back the mask */
3364 if (asserted & ATTN_NIG_FOR_FUNC) 4166 if (asserted & ATTN_NIG_FOR_FUNC)
3365 REG_WR(bp, nig_mask_addr, bp->nig_mask); 4167 REG_WR(bp, nig_int_mask_addr, bp->nig_mask);
3366} 4168}
3367 4169
3368static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted) 4170static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn)
3369{ 4171{
3370 int port = bp->port; 4172 int port = bp->port;
3371 int index; 4173 int reg_offset;
4174 u32 val;
4175
4176 if (attn & AEU_INPUTS_ATTN_BITS_SPIO5) {
4177
4178 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
4179 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
4180
4181 val = REG_RD(bp, reg_offset);
4182 val &= ~AEU_INPUTS_ATTN_BITS_SPIO5;
4183 REG_WR(bp, reg_offset, val);
4184
4185 BNX2X_ERR("SPIO5 hw attention\n");
4186
4187 switch (bp->board & SHARED_HW_CFG_BOARD_TYPE_MASK) {
4188 case SHARED_HW_CFG_BOARD_TYPE_BCM957710A1022G:
4189 /* Fan failure attention */
4190
4191 /* The PHY reset is controled by GPIO 1 */
4192 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_1,
4193 MISC_REGISTERS_GPIO_OUTPUT_LOW);
4194 /* Low power mode is controled by GPIO 2 */
4195 bnx2x_set_gpio(bp, MISC_REGISTERS_GPIO_2,
4196 MISC_REGISTERS_GPIO_OUTPUT_LOW);
4197 /* mark the failure */
4198 bp->ext_phy_config &=
4199 ~PORT_HW_CFG_XGXS_EXT_PHY_TYPE_MASK;
4200 bp->ext_phy_config |=
4201 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE;
4202 SHMEM_WR(bp,
4203 dev_info.port_hw_config[port].
4204 external_phy_config,
4205 bp->ext_phy_config);
4206 /* log the failure */
4207 printk(KERN_ERR PFX "Fan Failure on Network"
4208 " Controller %s has caused the driver to"
4209 " shutdown the card to prevent permanent"
4210 " damage. Please contact Dell Support for"
4211 " assistance\n", bp->dev->name);
4212 break;
4213
4214 default:
4215 break;
4216 }
4217 }
4218}
4219
4220static inline void bnx2x_attn_int_deasserted1(struct bnx2x *bp, u32 attn)
4221{
4222 u32 val;
4223
4224 if (attn & BNX2X_DOORQ_ASSERT) {
4225
4226 val = REG_RD(bp, DORQ_REG_DORQ_INT_STS_CLR);
4227 BNX2X_ERR("DB hw attention 0x%x\n", val);
4228 /* DORQ discard attention */
4229 if (val & 0x2)
4230 BNX2X_ERR("FATAL error from DORQ\n");
4231 }
4232}
4233
4234static inline void bnx2x_attn_int_deasserted2(struct bnx2x *bp, u32 attn)
4235{
4236 u32 val;
4237
4238 if (attn & AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) {
4239
4240 val = REG_RD(bp, CFC_REG_CFC_INT_STS_CLR);
4241 BNX2X_ERR("CFC hw attention 0x%x\n", val);
4242 /* CFC error attention */
4243 if (val & 0x2)
4244 BNX2X_ERR("FATAL error from CFC\n");
4245 }
4246
4247 if (attn & AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) {
4248
4249 val = REG_RD(bp, PXP_REG_PXP_INT_STS_CLR_0);
4250 BNX2X_ERR("PXP hw attention 0x%x\n", val);
4251 /* RQ_USDMDP_FIFO_OVERFLOW */
4252 if (val & 0x18000)
4253 BNX2X_ERR("FATAL error from PXP\n");
4254 }
4255}
4256
4257static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn)
4258{
4259 if (attn & EVEREST_GEN_ATTN_IN_USE_MASK) {
4260
4261 if (attn & BNX2X_MC_ASSERT_BITS) {
4262
4263 BNX2X_ERR("MC assert!\n");
4264 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_10, 0);
4265 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_9, 0);
4266 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_8, 0);
4267 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_7, 0);
4268 bnx2x_panic();
4269
4270 } else if (attn & BNX2X_MCP_ASSERT) {
4271
4272 BNX2X_ERR("MCP assert!\n");
4273 REG_WR(bp, MISC_REG_AEU_GENERAL_ATTN_11, 0);
4274 bnx2x_mc_assert(bp);
4275
4276 } else
4277 BNX2X_ERR("Unknown HW assert! (attn 0x%x)\n", attn);
4278 }
4279
4280 if (attn & EVEREST_LATCHED_ATTN_IN_USE_MASK) {
4281
4282 REG_WR(bp, MISC_REG_AEU_CLR_LATCH_SIGNAL, 0x7ff);
4283 BNX2X_ERR("LATCHED attention 0x%x (masked)\n", attn);
4284 }
4285}
4286
4287static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
4288{
3372 struct attn_route attn; 4289 struct attn_route attn;
3373 struct attn_route group_mask; 4290 struct attn_route group_mask;
4291 int port = bp->port;
4292 int index;
3374 u32 reg_addr; 4293 u32 reg_addr;
3375 u32 val; 4294 u32 val;
3376 4295
@@ -3391,64 +4310,14 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
3391 DP(NETIF_MSG_HW, "group[%d]: %llx\n", index, 4310 DP(NETIF_MSG_HW, "group[%d]: %llx\n", index,
3392 (unsigned long long)group_mask.sig[0]); 4311 (unsigned long long)group_mask.sig[0]);
3393 4312
3394 if (attn.sig[3] & group_mask.sig[3] & 4313 bnx2x_attn_int_deasserted3(bp,
3395 EVEREST_GEN_ATTN_IN_USE_MASK) { 4314 attn.sig[3] & group_mask.sig[3]);
3396 4315 bnx2x_attn_int_deasserted1(bp,
3397 if (attn.sig[3] & BNX2X_MC_ASSERT_BITS) { 4316 attn.sig[1] & group_mask.sig[1]);
3398 4317 bnx2x_attn_int_deasserted2(bp,
3399 BNX2X_ERR("MC assert!\n"); 4318 attn.sig[2] & group_mask.sig[2]);
3400 bnx2x_panic(); 4319 bnx2x_attn_int_deasserted0(bp,
3401 4320 attn.sig[0] & group_mask.sig[0]);
3402 } else if (attn.sig[3] & BNX2X_MCP_ASSERT) {
3403
3404 BNX2X_ERR("MCP assert!\n");
3405 REG_WR(bp,
3406 MISC_REG_AEU_GENERAL_ATTN_11, 0);
3407 bnx2x_mc_assert(bp);
3408
3409 } else {
3410 BNX2X_ERR("UNKOWEN HW ASSERT!\n");
3411 }
3412 }
3413
3414 if (attn.sig[1] & group_mask.sig[1] &
3415 BNX2X_DOORQ_ASSERT) {
3416
3417 val = REG_RD(bp, DORQ_REG_DORQ_INT_STS_CLR);
3418 BNX2X_ERR("DB hw attention 0x%x\n", val);
3419 /* DORQ discard attention */
3420 if (val & 0x2)
3421 BNX2X_ERR("FATAL error from DORQ\n");
3422 }
3423
3424 if (attn.sig[2] & group_mask.sig[2] &
3425 AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT) {
3426
3427 val = REG_RD(bp, CFC_REG_CFC_INT_STS_CLR);
3428 BNX2X_ERR("CFC hw attention 0x%x\n", val);
3429 /* CFC error attention */
3430 if (val & 0x2)
3431 BNX2X_ERR("FATAL error from CFC\n");
3432 }
3433
3434 if (attn.sig[2] & group_mask.sig[2] &
3435 AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT) {
3436
3437 val = REG_RD(bp, PXP_REG_PXP_INT_STS_CLR_0);
3438 BNX2X_ERR("PXP hw attention 0x%x\n", val);
3439 /* RQ_USDMDP_FIFO_OVERFLOW */
3440 if (val & 0x18000)
3441 BNX2X_ERR("FATAL error from PXP\n");
3442 }
3443
3444 if (attn.sig[3] & group_mask.sig[3] &
3445 EVEREST_LATCHED_ATTN_IN_USE_MASK) {
3446
3447 REG_WR(bp, MISC_REG_AEU_CLR_LATCH_SIGNAL,
3448 0x7ff);
3449 DP(NETIF_MSG_HW, "got latched bits 0x%x\n",
3450 attn.sig[3]);
3451 }
3452 4321
3453 if ((attn.sig[0] & group_mask.sig[0] & 4322 if ((attn.sig[0] & group_mask.sig[0] &
3454 HW_INTERRUT_ASSERT_SET_0) || 4323 HW_INTERRUT_ASSERT_SET_0) ||
@@ -3456,7 +4325,15 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
3456 HW_INTERRUT_ASSERT_SET_1) || 4325 HW_INTERRUT_ASSERT_SET_1) ||
3457 (attn.sig[2] & group_mask.sig[2] & 4326 (attn.sig[2] & group_mask.sig[2] &
3458 HW_INTERRUT_ASSERT_SET_2)) 4327 HW_INTERRUT_ASSERT_SET_2))
3459 BNX2X_ERR("FATAL HW block attention\n"); 4328 BNX2X_ERR("FATAL HW block attention"
4329 " set0 0x%x set1 0x%x"
4330 " set2 0x%x\n",
4331 (attn.sig[0] & group_mask.sig[0] &
4332 HW_INTERRUT_ASSERT_SET_0),
4333 (attn.sig[1] & group_mask.sig[1] &
4334 HW_INTERRUT_ASSERT_SET_1),
4335 (attn.sig[2] & group_mask.sig[2] &
4336 HW_INTERRUT_ASSERT_SET_2));
3460 4337
3461 if ((attn.sig[0] & group_mask.sig[0] & 4338 if ((attn.sig[0] & group_mask.sig[0] &
3462 HW_PRTY_ASSERT_SET_0) || 4339 HW_PRTY_ASSERT_SET_0) ||
@@ -3464,7 +4341,7 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
3464 HW_PRTY_ASSERT_SET_1) || 4341 HW_PRTY_ASSERT_SET_1) ||
3465 (attn.sig[2] & group_mask.sig[2] & 4342 (attn.sig[2] & group_mask.sig[2] &
3466 HW_PRTY_ASSERT_SET_2)) 4343 HW_PRTY_ASSERT_SET_2))
3467 BNX2X_ERR("FATAL HW block parity atention\n"); 4344 BNX2X_ERR("FATAL HW block parity attention\n");
3468 } 4345 }
3469 } 4346 }
3470 4347
@@ -3529,7 +4406,7 @@ static void bnx2x_sp_task(struct work_struct *work)
3529 4406
3530 /* Return here if interrupt is disabled */ 4407 /* Return here if interrupt is disabled */
3531 if (unlikely(atomic_read(&bp->intr_sem) != 0)) { 4408 if (unlikely(atomic_read(&bp->intr_sem) != 0)) {
3532 DP(NETIF_MSG_INTR, "called but intr_sem not 0, returning\n"); 4409 DP(BNX2X_MSG_SP, "called but intr_sem not 0, returning\n");
3533 return; 4410 return;
3534 } 4411 }
3535 4412
@@ -3539,12 +4416,11 @@ static void bnx2x_sp_task(struct work_struct *work)
3539 4416
3540 DP(NETIF_MSG_INTR, "got a slowpath interrupt (updated %x)\n", status); 4417 DP(NETIF_MSG_INTR, "got a slowpath interrupt (updated %x)\n", status);
3541 4418
3542 if (status & 0x1) { 4419 /* HW attentions */
3543 /* HW attentions */ 4420 if (status & 0x1)
3544 bnx2x_attn_int(bp); 4421 bnx2x_attn_int(bp);
3545 }
3546 4422
3547 /* CStorm events: query_stats, cfc delete ramrods */ 4423 /* CStorm events: query_stats, port delete ramrod */
3548 if (status & 0x2) 4424 if (status & 0x2)
3549 bp->stat_pending = 0; 4425 bp->stat_pending = 0;
3550 4426
@@ -3558,6 +4434,7 @@ static void bnx2x_sp_task(struct work_struct *work)
3558 IGU_INT_NOP, 1); 4434 IGU_INT_NOP, 1);
3559 bnx2x_ack_sb(bp, DEF_SB_ID, TSTORM_ID, le16_to_cpu(bp->def_t_idx), 4435 bnx2x_ack_sb(bp, DEF_SB_ID, TSTORM_ID, le16_to_cpu(bp->def_t_idx),
3560 IGU_INT_ENABLE, 1); 4436 IGU_INT_ENABLE, 1);
4437
3561} 4438}
3562 4439
3563static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance) 4440static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
@@ -3567,11 +4444,11 @@ static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
3567 4444
3568 /* Return here if interrupt is disabled */ 4445 /* Return here if interrupt is disabled */
3569 if (unlikely(atomic_read(&bp->intr_sem) != 0)) { 4446 if (unlikely(atomic_read(&bp->intr_sem) != 0)) {
3570 DP(NETIF_MSG_INTR, "called but intr_sem not 0, returning\n"); 4447 DP(BNX2X_MSG_SP, "called but intr_sem not 0, returning\n");
3571 return IRQ_HANDLED; 4448 return IRQ_HANDLED;
3572 } 4449 }
3573 4450
3574 bnx2x_ack_sb(bp, 16, XSTORM_ID, 0, IGU_INT_DISABLE, 0); 4451 bnx2x_ack_sb(bp, DEF_SB_ID, XSTORM_ID, 0, IGU_INT_DISABLE, 0);
3575 4452
3576#ifdef BNX2X_STOP_ON_ERROR 4453#ifdef BNX2X_STOP_ON_ERROR
3577 if (unlikely(bp->panic)) 4454 if (unlikely(bp->panic))
@@ -3906,7 +4783,7 @@ static void bnx2x_stop_stats(struct bnx2x *bp)
3906 4783
3907 while (bp->stats_state != STATS_STATE_DISABLE) { 4784 while (bp->stats_state != STATS_STATE_DISABLE) {
3908 if (!timeout) { 4785 if (!timeout) {
3909 BNX2X_ERR("timeout wating for stats stop\n"); 4786 BNX2X_ERR("timeout waiting for stats stop\n");
3910 break; 4787 break;
3911 } 4788 }
3912 timeout--; 4789 timeout--;
@@ -4173,39 +5050,37 @@ static void bnx2x_update_net_stats(struct bnx2x *bp)
4173 5050
4174 nstats->rx_bytes = bnx2x_hilo(&estats->total_bytes_received_hi); 5051 nstats->rx_bytes = bnx2x_hilo(&estats->total_bytes_received_hi);
4175 5052
4176 nstats->tx_bytes = 5053 nstats->tx_bytes = bnx2x_hilo(&estats->total_bytes_transmitted_hi);
4177 bnx2x_hilo(&estats->total_bytes_transmitted_hi);
4178 5054
4179 nstats->rx_dropped = estats->checksum_discard + 5055 nstats->rx_dropped = estats->checksum_discard + estats->mac_discard;
4180 estats->mac_discard;
4181 nstats->tx_dropped = 0; 5056 nstats->tx_dropped = 0;
4182 5057
4183 nstats->multicast = 5058 nstats->multicast =
4184 bnx2x_hilo(&estats->total_multicast_packets_transmitted_hi); 5059 bnx2x_hilo(&estats->total_multicast_packets_transmitted_hi);
4185 5060
4186 nstats->collisions = 5061 nstats->collisions = estats->single_collision_transmit_frames +
4187 estats->single_collision_transmit_frames + 5062 estats->multiple_collision_transmit_frames +
4188 estats->multiple_collision_transmit_frames + 5063 estats->late_collision_frames +
4189 estats->late_collision_frames + 5064 estats->excessive_collision_frames;
4190 estats->excessive_collision_frames;
4191 5065
4192 nstats->rx_length_errors = estats->runt_packets_received + 5066 nstats->rx_length_errors = estats->runt_packets_received +
4193 estats->jabber_packets_received; 5067 estats->jabber_packets_received;
4194 nstats->rx_over_errors = estats->no_buff_discard; 5068 nstats->rx_over_errors = estats->brb_discard +
5069 estats->brb_truncate_discard;
4195 nstats->rx_crc_errors = estats->crc_receive_errors; 5070 nstats->rx_crc_errors = estats->crc_receive_errors;
4196 nstats->rx_frame_errors = estats->alignment_errors; 5071 nstats->rx_frame_errors = estats->alignment_errors;
4197 nstats->rx_fifo_errors = estats->brb_discard + 5072 nstats->rx_fifo_errors = estats->no_buff_discard;
4198 estats->brb_truncate_discard;
4199 nstats->rx_missed_errors = estats->xxoverflow_discard; 5073 nstats->rx_missed_errors = estats->xxoverflow_discard;
4200 5074
4201 nstats->rx_errors = nstats->rx_length_errors + 5075 nstats->rx_errors = nstats->rx_length_errors +
4202 nstats->rx_over_errors + 5076 nstats->rx_over_errors +
4203 nstats->rx_crc_errors + 5077 nstats->rx_crc_errors +
4204 nstats->rx_frame_errors + 5078 nstats->rx_frame_errors +
4205 nstats->rx_fifo_errors; 5079 nstats->rx_fifo_errors +
5080 nstats->rx_missed_errors;
4206 5081
4207 nstats->tx_aborted_errors = estats->late_collision_frames + 5082 nstats->tx_aborted_errors = estats->late_collision_frames +
4208 estats->excessive_collision_frames; 5083 estats->excessive_collision_frames;
4209 nstats->tx_carrier_errors = estats->false_carrier_detections; 5084 nstats->tx_carrier_errors = estats->false_carrier_detections;
4210 nstats->tx_fifo_errors = 0; 5085 nstats->tx_fifo_errors = 0;
4211 nstats->tx_heartbeat_errors = 0; 5086 nstats->tx_heartbeat_errors = 0;
@@ -4334,7 +5209,7 @@ static void bnx2x_timer(unsigned long data)
4334 return; 5209 return;
4335 5210
4336 if (atomic_read(&bp->intr_sem) != 0) 5211 if (atomic_read(&bp->intr_sem) != 0)
4337 goto bnx2x_restart_timer; 5212 goto timer_restart;
4338 5213
4339 if (poll) { 5214 if (poll) {
4340 struct bnx2x_fastpath *fp = &bp->fp[0]; 5215 struct bnx2x_fastpath *fp = &bp->fp[0];
@@ -4344,7 +5219,7 @@ static void bnx2x_timer(unsigned long data)
4344 rc = bnx2x_rx_int(fp, 1000); 5219 rc = bnx2x_rx_int(fp, 1000);
4345 } 5220 }
4346 5221
4347 if (!nomcp && (bp->bc_ver >= 0x040003)) { 5222 if (!nomcp) {
4348 int port = bp->port; 5223 int port = bp->port;
4349 u32 drv_pulse; 5224 u32 drv_pulse;
4350 u32 mcp_pulse; 5225 u32 mcp_pulse;
@@ -4353,9 +5228,9 @@ static void bnx2x_timer(unsigned long data)
4353 bp->fw_drv_pulse_wr_seq &= DRV_PULSE_SEQ_MASK; 5228 bp->fw_drv_pulse_wr_seq &= DRV_PULSE_SEQ_MASK;
4354 /* TBD - add SYSTEM_TIME */ 5229 /* TBD - add SYSTEM_TIME */
4355 drv_pulse = bp->fw_drv_pulse_wr_seq; 5230 drv_pulse = bp->fw_drv_pulse_wr_seq;
4356 SHMEM_WR(bp, drv_fw_mb[port].drv_pulse_mb, drv_pulse); 5231 SHMEM_WR(bp, func_mb[port].drv_pulse_mb, drv_pulse);
4357 5232
4358 mcp_pulse = (SHMEM_RD(bp, drv_fw_mb[port].mcp_pulse_mb) & 5233 mcp_pulse = (SHMEM_RD(bp, func_mb[port].mcp_pulse_mb) &
4359 MCP_PULSE_SEQ_MASK); 5234 MCP_PULSE_SEQ_MASK);
4360 /* The delta between driver pulse and mcp response 5235 /* The delta between driver pulse and mcp response
4361 * should be 1 (before mcp response) or 0 (after mcp response) 5236 * should be 1 (before mcp response) or 0 (after mcp response)
@@ -4369,11 +5244,11 @@ static void bnx2x_timer(unsigned long data)
4369 } 5244 }
4370 5245
4371 if (bp->stats_state == STATS_STATE_DISABLE) 5246 if (bp->stats_state == STATS_STATE_DISABLE)
4372 goto bnx2x_restart_timer; 5247 goto timer_restart;
4373 5248
4374 bnx2x_update_stats(bp); 5249 bnx2x_update_stats(bp);
4375 5250
4376bnx2x_restart_timer: 5251timer_restart:
4377 mod_timer(&bp->timer, jiffies + bp->current_interval); 5252 mod_timer(&bp->timer, jiffies + bp->current_interval);
4378} 5253}
4379 5254
@@ -4438,6 +5313,9 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4438 atten_status_block); 5313 atten_status_block);
4439 def_sb->atten_status_block.status_block_id = id; 5314 def_sb->atten_status_block.status_block_id = id;
4440 5315
5316 bp->def_att_idx = 0;
5317 bp->attn_state = 0;
5318
4441 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 : 5319 reg_offset = (port ? MISC_REG_AEU_ENABLE1_FUNC_1_OUT_0 :
4442 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0); 5320 MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
4443 5321
@@ -4472,6 +5350,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4472 u_def_status_block); 5350 u_def_status_block);
4473 def_sb->u_def_status_block.status_block_id = id; 5351 def_sb->u_def_status_block.status_block_id = id;
4474 5352
5353 bp->def_u_idx = 0;
5354
4475 REG_WR(bp, BAR_USTRORM_INTMEM + 5355 REG_WR(bp, BAR_USTRORM_INTMEM +
4476 USTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section)); 5356 USTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section));
4477 REG_WR(bp, BAR_USTRORM_INTMEM + 5357 REG_WR(bp, BAR_USTRORM_INTMEM +
@@ -4489,6 +5369,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4489 c_def_status_block); 5369 c_def_status_block);
4490 def_sb->c_def_status_block.status_block_id = id; 5370 def_sb->c_def_status_block.status_block_id = id;
4491 5371
5372 bp->def_c_idx = 0;
5373
4492 REG_WR(bp, BAR_CSTRORM_INTMEM + 5374 REG_WR(bp, BAR_CSTRORM_INTMEM +
4493 CSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section)); 5375 CSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section));
4494 REG_WR(bp, BAR_CSTRORM_INTMEM + 5376 REG_WR(bp, BAR_CSTRORM_INTMEM +
@@ -4506,6 +5388,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4506 t_def_status_block); 5388 t_def_status_block);
4507 def_sb->t_def_status_block.status_block_id = id; 5389 def_sb->t_def_status_block.status_block_id = id;
4508 5390
5391 bp->def_t_idx = 0;
5392
4509 REG_WR(bp, BAR_TSTRORM_INTMEM + 5393 REG_WR(bp, BAR_TSTRORM_INTMEM +
4510 TSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section)); 5394 TSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section));
4511 REG_WR(bp, BAR_TSTRORM_INTMEM + 5395 REG_WR(bp, BAR_TSTRORM_INTMEM +
@@ -4523,6 +5407,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4523 x_def_status_block); 5407 x_def_status_block);
4524 def_sb->x_def_status_block.status_block_id = id; 5408 def_sb->x_def_status_block.status_block_id = id;
4525 5409
5410 bp->def_x_idx = 0;
5411
4526 REG_WR(bp, BAR_XSTRORM_INTMEM + 5412 REG_WR(bp, BAR_XSTRORM_INTMEM +
4527 XSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section)); 5413 XSTORM_DEF_SB_HOST_SB_ADDR_OFFSET(port), U64_LO(section));
4528 REG_WR(bp, BAR_XSTRORM_INTMEM + 5414 REG_WR(bp, BAR_XSTRORM_INTMEM +
@@ -4535,6 +5421,8 @@ static void bnx2x_init_def_sb(struct bnx2x *bp,
4535 REG_WR16(bp, BAR_XSTRORM_INTMEM + 5421 REG_WR16(bp, BAR_XSTRORM_INTMEM +
4536 XSTORM_DEF_SB_HC_DISABLE_OFFSET(port, index), 0x1); 5422 XSTORM_DEF_SB_HC_DISABLE_OFFSET(port, index), 0x1);
4537 5423
5424 bp->stat_pending = 0;
5425
4538 bnx2x_ack_sb(bp, id, CSTORM_ID, 0, IGU_INT_ENABLE, 0); 5426 bnx2x_ack_sb(bp, id, CSTORM_ID, 0, IGU_INT_ENABLE, 0);
4539} 5427}
4540 5428
@@ -4626,7 +5514,7 @@ static void bnx2x_init_rx_rings(struct bnx2x *bp)
4626 fp->rx_bd_prod = fp->rx_comp_prod = ring_prod; 5514 fp->rx_bd_prod = fp->rx_comp_prod = ring_prod;
4627 fp->rx_pkt = fp->rx_calls = 0; 5515 fp->rx_pkt = fp->rx_calls = 0;
4628 5516
4629 /* Warning! this will genrate an interrupt (to the TSTORM) */ 5517 /* Warning! this will generate an interrupt (to the TSTORM) */
4630 /* must only be done when chip is initialized */ 5518 /* must only be done when chip is initialized */
4631 REG_WR(bp, BAR_TSTRORM_INTMEM + 5519 REG_WR(bp, BAR_TSTRORM_INTMEM +
4632 TSTORM_RCQ_PROD_OFFSET(port, j), ring_prod); 5520 TSTORM_RCQ_PROD_OFFSET(port, j), ring_prod);
@@ -4678,7 +5566,6 @@ static void bnx2x_init_sp_ring(struct bnx2x *bp)
4678 5566
4679 bp->spq_left = MAX_SPQ_PENDING; 5567 bp->spq_left = MAX_SPQ_PENDING;
4680 bp->spq_prod_idx = 0; 5568 bp->spq_prod_idx = 0;
4681 bp->dsb_sp_prod_idx = 0;
4682 bp->dsb_sp_prod = BNX2X_SP_DSB_INDEX; 5569 bp->dsb_sp_prod = BNX2X_SP_DSB_INDEX;
4683 bp->spq_prod_bd = bp->spq; 5570 bp->spq_prod_bd = bp->spq;
4684 bp->spq_last_bd = bp->spq_prod_bd + MAX_SP_DESC_CNT; 5571 bp->spq_last_bd = bp->spq_prod_bd + MAX_SP_DESC_CNT;
@@ -4755,6 +5642,42 @@ static void bnx2x_init_ind_table(struct bnx2x *bp)
4755 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf); 5642 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
4756} 5643}
4757 5644
5645static void bnx2x_set_client_config(struct bnx2x *bp)
5646{
5647#ifdef BCM_VLAN
5648 int mode = bp->rx_mode;
5649#endif
5650 int i, port = bp->port;
5651 struct tstorm_eth_client_config tstorm_client = {0};
5652
5653 tstorm_client.mtu = bp->dev->mtu;
5654 tstorm_client.statistics_counter_id = 0;
5655 tstorm_client.config_flags =
5656 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
5657#ifdef BCM_VLAN
5658 if (mode && bp->vlgrp) {
5659 tstorm_client.config_flags |=
5660 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE;
5661 DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
5662 }
5663#endif
5664 if (mode != BNX2X_RX_MODE_PROMISC)
5665 tstorm_client.drop_flags =
5666 TSTORM_ETH_CLIENT_CONFIG_DROP_MAC_ERR;
5667
5668 for_each_queue(bp, i) {
5669 REG_WR(bp, BAR_TSTRORM_INTMEM +
5670 TSTORM_CLIENT_CONFIG_OFFSET(port, i),
5671 ((u32 *)&tstorm_client)[0]);
5672 REG_WR(bp, BAR_TSTRORM_INTMEM +
5673 TSTORM_CLIENT_CONFIG_OFFSET(port, i) + 4,
5674 ((u32 *)&tstorm_client)[1]);
5675 }
5676
5677/* DP(NETIF_MSG_IFUP, "tstorm_client: 0x%08x 0x%08x\n",
5678 ((u32 *)&tstorm_client)[0], ((u32 *)&tstorm_client)[1]); */
5679}
5680
4758static void bnx2x_set_storm_rx_mode(struct bnx2x *bp) 5681static void bnx2x_set_storm_rx_mode(struct bnx2x *bp)
4759{ 5682{
4760 int mode = bp->rx_mode; 5683 int mode = bp->rx_mode;
@@ -4794,41 +5717,9 @@ static void bnx2x_set_storm_rx_mode(struct bnx2x *bp)
4794/* DP(NETIF_MSG_IFUP, "tstorm_mac_filter[%d]: 0x%08x\n", i, 5717/* DP(NETIF_MSG_IFUP, "tstorm_mac_filter[%d]: 0x%08x\n", i,
4795 ((u32 *)&tstorm_mac_filter)[i]); */ 5718 ((u32 *)&tstorm_mac_filter)[i]); */
4796 } 5719 }
4797}
4798 5720
4799static void bnx2x_set_client_config(struct bnx2x *bp, int client_id) 5721 if (mode != BNX2X_RX_MODE_NONE)
4800{ 5722 bnx2x_set_client_config(bp);
4801#ifdef BCM_VLAN
4802 int mode = bp->rx_mode;
4803#endif
4804 int port = bp->port;
4805 struct tstorm_eth_client_config tstorm_client = {0};
4806
4807 tstorm_client.mtu = bp->dev->mtu;
4808 tstorm_client.statistics_counter_id = 0;
4809 tstorm_client.config_flags =
4810 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
4811#ifdef BCM_VLAN
4812 if (mode && bp->vlgrp) {
4813 tstorm_client.config_flags |=
4814 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE;
4815 DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
4816 }
4817#endif
4818 tstorm_client.drop_flags = (TSTORM_ETH_CLIENT_CONFIG_DROP_IP_CS_ERR |
4819 TSTORM_ETH_CLIENT_CONFIG_DROP_TCP_CS_ERR |
4820 TSTORM_ETH_CLIENT_CONFIG_DROP_UDP_CS_ERR |
4821 TSTORM_ETH_CLIENT_CONFIG_DROP_MAC_ERR);
4822
4823 REG_WR(bp, BAR_TSTRORM_INTMEM +
4824 TSTORM_CLIENT_CONFIG_OFFSET(port, client_id),
4825 ((u32 *)&tstorm_client)[0]);
4826 REG_WR(bp, BAR_TSTRORM_INTMEM +
4827 TSTORM_CLIENT_CONFIG_OFFSET(port, client_id) + 4,
4828 ((u32 *)&tstorm_client)[1]);
4829
4830/* DP(NETIF_MSG_IFUP, "tstorm_client: 0x%08x 0x%08x\n",
4831 ((u32 *)&tstorm_client)[0], ((u32 *)&tstorm_client)[1]); */
4832} 5723}
4833 5724
4834static void bnx2x_init_internal(struct bnx2x *bp) 5725static void bnx2x_init_internal(struct bnx2x *bp)
@@ -4836,7 +5727,6 @@ static void bnx2x_init_internal(struct bnx2x *bp)
4836 int port = bp->port; 5727 int port = bp->port;
4837 struct tstorm_eth_function_common_config tstorm_config = {0}; 5728 struct tstorm_eth_function_common_config tstorm_config = {0};
4838 struct stats_indication_flags stats_flags = {0}; 5729 struct stats_indication_flags stats_flags = {0};
4839 int i;
4840 5730
4841 if (is_multi(bp)) { 5731 if (is_multi(bp)) {
4842 tstorm_config.config_flags = MULTI_FLAGS; 5732 tstorm_config.config_flags = MULTI_FLAGS;
@@ -4850,13 +5740,9 @@ static void bnx2x_init_internal(struct bnx2x *bp)
4850/* DP(NETIF_MSG_IFUP, "tstorm_config: 0x%08x\n", 5740/* DP(NETIF_MSG_IFUP, "tstorm_config: 0x%08x\n",
4851 (*(u32 *)&tstorm_config)); */ 5741 (*(u32 *)&tstorm_config)); */
4852 5742
4853 bp->rx_mode = BNX2X_RX_MODE_NONE; /* no rx untill link is up */ 5743 bp->rx_mode = BNX2X_RX_MODE_NONE; /* no rx until link is up */
4854 bnx2x_set_storm_rx_mode(bp); 5744 bnx2x_set_storm_rx_mode(bp);
4855 5745
4856 for_each_queue(bp, i)
4857 bnx2x_set_client_config(bp, i);
4858
4859
4860 stats_flags.collect_eth = cpu_to_le32(1); 5746 stats_flags.collect_eth = cpu_to_le32(1);
4861 5747
4862 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(port), 5748 REG_WR(bp, BAR_XSTRORM_INTMEM + XSTORM_STATS_FLAGS_OFFSET(port),
@@ -4902,7 +5788,7 @@ static void bnx2x_nic_init(struct bnx2x *bp)
4902 bnx2x_init_internal(bp); 5788 bnx2x_init_internal(bp);
4903 bnx2x_init_stats(bp); 5789 bnx2x_init_stats(bp);
4904 bnx2x_init_ind_table(bp); 5790 bnx2x_init_ind_table(bp);
4905 bnx2x_enable_int(bp); 5791 bnx2x_int_enable(bp);
4906 5792
4907} 5793}
4908 5794
@@ -5265,8 +6151,10 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5265 if (mode & 0x1) { /* init common */ 6151 if (mode & 0x1) { /* init common */
5266 DP(BNX2X_MSG_MCP, "starting common init func %d mode %x\n", 6152 DP(BNX2X_MSG_MCP, "starting common init func %d mode %x\n",
5267 func, mode); 6153 func, mode);
5268 REG_WR(bp, MISC_REG_RESET_REG_1, 0xffffffff); 6154 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET,
5269 REG_WR(bp, MISC_REG_RESET_REG_2, 0xfffc); 6155 0xffffffff);
6156 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET,
6157 0xfffc);
5270 bnx2x_init_block(bp, MISC_COMMON_START, MISC_COMMON_END); 6158 bnx2x_init_block(bp, MISC_COMMON_START, MISC_COMMON_END);
5271 6159
5272 REG_WR(bp, MISC_REG_LCPLL_CTRL_REG_2, 0x100); 6160 REG_WR(bp, MISC_REG_LCPLL_CTRL_REG_2, 0x100);
@@ -5359,7 +6247,7 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5359 REG_RD(bp, USEM_REG_PASSIVE_BUFFER + 8); 6247 REG_RD(bp, USEM_REG_PASSIVE_BUFFER + 8);
5360#endif 6248#endif
5361 bnx2x_init_block(bp, QM_COMMON_START, QM_COMMON_END); 6249 bnx2x_init_block(bp, QM_COMMON_START, QM_COMMON_END);
5362 /* softrest pulse */ 6250 /* soft reset pulse */
5363 REG_WR(bp, QM_REG_SOFT_RESET, 1); 6251 REG_WR(bp, QM_REG_SOFT_RESET, 1);
5364 REG_WR(bp, QM_REG_SOFT_RESET, 0); 6252 REG_WR(bp, QM_REG_SOFT_RESET, 0);
5365 6253
@@ -5413,7 +6301,7 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5413 REG_WR(bp, SRC_REG_SOFT_RST, 1); 6301 REG_WR(bp, SRC_REG_SOFT_RST, 1);
5414 for (i = SRC_REG_KEYRSS0_0; i <= SRC_REG_KEYRSS1_9; i += 4) { 6302 for (i = SRC_REG_KEYRSS0_0; i <= SRC_REG_KEYRSS1_9; i += 4) {
5415 REG_WR(bp, i, 0xc0cac01a); 6303 REG_WR(bp, i, 0xc0cac01a);
5416 /* TODO: repleace with something meaningfull */ 6304 /* TODO: replace with something meaningful */
5417 } 6305 }
5418 /* SRCH COMMON comes here */ 6306 /* SRCH COMMON comes here */
5419 REG_WR(bp, SRC_REG_SOFT_RST, 0); 6307 REG_WR(bp, SRC_REG_SOFT_RST, 0);
@@ -5486,6 +6374,28 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5486 enable_blocks_attention(bp); 6374 enable_blocks_attention(bp);
5487 /* enable_blocks_parity(bp); */ 6375 /* enable_blocks_parity(bp); */
5488 6376
6377 switch (bp->board & SHARED_HW_CFG_BOARD_TYPE_MASK) {
6378 case SHARED_HW_CFG_BOARD_TYPE_BCM957710A1022G:
6379 /* Fan failure is indicated by SPIO 5 */
6380 bnx2x_set_spio(bp, MISC_REGISTERS_SPIO_5,
6381 MISC_REGISTERS_SPIO_INPUT_HI_Z);
6382
6383 /* set to active low mode */
6384 val = REG_RD(bp, MISC_REG_SPIO_INT);
6385 val |= ((1 << MISC_REGISTERS_SPIO_5) <<
6386 MISC_REGISTERS_SPIO_INT_OLD_SET_POS);
6387 REG_WR(bp, MISC_REG_SPIO_INT, val);
6388
6389 /* enable interrupt to signal the IGU */
6390 val = REG_RD(bp, MISC_REG_SPIO_EVENT_EN);
6391 val |= (1 << MISC_REGISTERS_SPIO_5);
6392 REG_WR(bp, MISC_REG_SPIO_EVENT_EN, val);
6393 break;
6394
6395 default:
6396 break;
6397 }
6398
5489 } /* end of common init */ 6399 } /* end of common init */
5490 6400
5491 /* per port init */ 6401 /* per port init */
@@ -5645,9 +6555,21 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5645 /* Port MCP comes here */ 6555 /* Port MCP comes here */
5646 /* Port DMAE comes here */ 6556 /* Port DMAE comes here */
5647 6557
6558 switch (bp->board & SHARED_HW_CFG_BOARD_TYPE_MASK) {
6559 case SHARED_HW_CFG_BOARD_TYPE_BCM957710A1022G:
6560 /* add SPIO 5 to group 0 */
6561 val = REG_RD(bp, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0);
6562 val |= AEU_INPUTS_ATTN_BITS_SPIO5;
6563 REG_WR(bp, MISC_REG_AEU_ENABLE1_FUNC_0_OUT_0, val);
6564 break;
6565
6566 default:
6567 break;
6568 }
6569
5648 bnx2x_link_reset(bp); 6570 bnx2x_link_reset(bp);
5649 6571
5650 /* Reset pciex errors for debug */ 6572 /* Reset PCIE errors for debug */
5651 REG_WR(bp, 0x2114, 0xffffffff); 6573 REG_WR(bp, 0x2114, 0xffffffff);
5652 REG_WR(bp, 0x2120, 0xffffffff); 6574 REG_WR(bp, 0x2120, 0xffffffff);
5653 REG_WR(bp, 0x2814, 0xffffffff); 6575 REG_WR(bp, 0x2814, 0xffffffff);
@@ -5669,9 +6591,9 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5669 port = bp->port; 6591 port = bp->port;
5670 6592
5671 bp->fw_drv_pulse_wr_seq = 6593 bp->fw_drv_pulse_wr_seq =
5672 (SHMEM_RD(bp, drv_fw_mb[port].drv_pulse_mb) & 6594 (SHMEM_RD(bp, func_mb[port].drv_pulse_mb) &
5673 DRV_PULSE_SEQ_MASK); 6595 DRV_PULSE_SEQ_MASK);
5674 bp->fw_mb = SHMEM_RD(bp, drv_fw_mb[port].fw_mb_param); 6596 bp->fw_mb = SHMEM_RD(bp, func_mb[port].fw_mb_param);
5675 DP(BNX2X_MSG_MCP, "drv_pulse 0x%x fw_mb 0x%x\n", 6597 DP(BNX2X_MSG_MCP, "drv_pulse 0x%x fw_mb 0x%x\n",
5676 bp->fw_drv_pulse_wr_seq, bp->fw_mb); 6598 bp->fw_drv_pulse_wr_seq, bp->fw_mb);
5677 } else { 6599 } else {
@@ -5681,16 +6603,15 @@ static int bnx2x_function_init(struct bnx2x *bp, int mode)
5681 return 0; 6603 return 0;
5682} 6604}
5683 6605
5684 6606/* send the MCP a request, block until there is a reply */
5685/* send the MCP a request, block untill there is a reply */
5686static u32 bnx2x_fw_command(struct bnx2x *bp, u32 command) 6607static u32 bnx2x_fw_command(struct bnx2x *bp, u32 command)
5687{ 6608{
5688 u32 rc = 0;
5689 u32 seq = ++bp->fw_seq;
5690 int port = bp->port; 6609 int port = bp->port;
6610 u32 seq = ++bp->fw_seq;
6611 u32 rc = 0;
5691 6612
5692 SHMEM_WR(bp, drv_fw_mb[port].drv_mb_header, command|seq); 6613 SHMEM_WR(bp, func_mb[port].drv_mb_header, (command | seq));
5693 DP(BNX2X_MSG_MCP, "wrote command (%x) to FW MB\n", command|seq); 6614 DP(BNX2X_MSG_MCP, "wrote command (%x) to FW MB\n", (command | seq));
5694 6615
5695 /* let the FW do it's magic ... */ 6616 /* let the FW do it's magic ... */
5696 msleep(100); /* TBD */ 6617 msleep(100); /* TBD */
@@ -5698,19 +6619,20 @@ static u32 bnx2x_fw_command(struct bnx2x *bp, u32 command)
5698 if (CHIP_REV_IS_SLOW(bp)) 6619 if (CHIP_REV_IS_SLOW(bp))
5699 msleep(900); 6620 msleep(900);
5700 6621
5701 rc = SHMEM_RD(bp, drv_fw_mb[port].fw_mb_header); 6622 rc = SHMEM_RD(bp, func_mb[port].fw_mb_header);
5702
5703 DP(BNX2X_MSG_MCP, "read (%x) seq is (%x) from FW MB\n", rc, seq); 6623 DP(BNX2X_MSG_MCP, "read (%x) seq is (%x) from FW MB\n", rc, seq);
5704 6624
5705 /* is this a reply to our command? */ 6625 /* is this a reply to our command? */
5706 if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK)) { 6626 if (seq == (rc & FW_MSG_SEQ_NUMBER_MASK)) {
5707 rc &= FW_MSG_CODE_MASK; 6627 rc &= FW_MSG_CODE_MASK;
6628
5708 } else { 6629 } else {
5709 /* FW BUG! */ 6630 /* FW BUG! */
5710 BNX2X_ERR("FW failed to respond!\n"); 6631 BNX2X_ERR("FW failed to respond!\n");
5711 bnx2x_fw_dump(bp); 6632 bnx2x_fw_dump(bp);
5712 rc = 0; 6633 rc = 0;
5713 } 6634 }
6635
5714 return rc; 6636 return rc;
5715} 6637}
5716 6638
@@ -5869,7 +6791,7 @@ static int bnx2x_alloc_mem(struct bnx2x *bp)
5869 for (i = 0; i < 16*1024; i += 64) 6791 for (i = 0; i < 16*1024; i += 64)
5870 * (u64 *)((char *)bp->t2 + i + 56) = bp->t2_mapping + i + 64; 6792 * (u64 *)((char *)bp->t2 + i + 56) = bp->t2_mapping + i + 64;
5871 6793
5872 /* now sixup the last line in the block to point to the next block */ 6794 /* now fixup the last line in the block to point to the next block */
5873 *(u64 *)((char *)bp->t2 + 1024*16-8) = bp->t2_mapping; 6795 *(u64 *)((char *)bp->t2 + 1024*16-8) = bp->t2_mapping;
5874 6796
5875 /* Timer block array (MAX_CONN*8) phys uncached for now 1024 conns */ 6797 /* Timer block array (MAX_CONN*8) phys uncached for now 1024 conns */
@@ -5950,22 +6872,19 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp)
5950 int i; 6872 int i;
5951 6873
5952 free_irq(bp->msix_table[0].vector, bp->dev); 6874 free_irq(bp->msix_table[0].vector, bp->dev);
5953 DP(NETIF_MSG_IFDOWN, "rleased sp irq (%d)\n", 6875 DP(NETIF_MSG_IFDOWN, "released sp irq (%d)\n",
5954 bp->msix_table[0].vector); 6876 bp->msix_table[0].vector);
5955 6877
5956 for_each_queue(bp, i) { 6878 for_each_queue(bp, i) {
5957 DP(NETIF_MSG_IFDOWN, "about to rlease fp #%d->%d irq " 6879 DP(NETIF_MSG_IFDOWN, "about to release fp #%d->%d irq "
5958 "state(%x)\n", i, bp->msix_table[i + 1].vector, 6880 "state(%x)\n", i, bp->msix_table[i + 1].vector,
5959 bnx2x_fp(bp, i, state)); 6881 bnx2x_fp(bp, i, state));
5960 6882
5961 if (bnx2x_fp(bp, i, state) != BNX2X_FP_STATE_CLOSED) { 6883 if (bnx2x_fp(bp, i, state) != BNX2X_FP_STATE_CLOSED)
5962 6884 BNX2X_ERR("IRQ of fp #%d being freed while "
5963 free_irq(bp->msix_table[i + 1].vector, &bp->fp[i]); 6885 "state != closed\n", i);
5964 bnx2x_fp(bp, i, state) = BNX2X_FP_STATE_CLOSED;
5965
5966 } else
5967 DP(NETIF_MSG_IFDOWN, "irq not freed\n");
5968 6886
6887 free_irq(bp->msix_table[i + 1].vector, &bp->fp[i]);
5969 } 6888 }
5970 6889
5971} 6890}
@@ -5995,7 +6914,7 @@ static int bnx2x_enable_msix(struct bnx2x *bp)
5995 6914
5996 if (pci_enable_msix(bp->pdev, &bp->msix_table[0], 6915 if (pci_enable_msix(bp->pdev, &bp->msix_table[0],
5997 bp->num_queues + 1)){ 6916 bp->num_queues + 1)){
5998 BNX2X_ERR("failed to enable msix\n"); 6917 BNX2X_LOG("failed to enable MSI-X\n");
5999 return -1; 6918 return -1;
6000 6919
6001 } 6920 }
@@ -6010,11 +6929,8 @@ static int bnx2x_enable_msix(struct bnx2x *bp)
6010static int bnx2x_req_msix_irqs(struct bnx2x *bp) 6929static int bnx2x_req_msix_irqs(struct bnx2x *bp)
6011{ 6930{
6012 6931
6013
6014 int i, rc; 6932 int i, rc;
6015 6933
6016 DP(NETIF_MSG_IFUP, "about to request sp irq\n");
6017
6018 rc = request_irq(bp->msix_table[0].vector, bnx2x_msix_sp_int, 0, 6934 rc = request_irq(bp->msix_table[0].vector, bnx2x_msix_sp_int, 0,
6019 bp->dev->name, bp->dev); 6935 bp->dev->name, bp->dev);
6020 6936
@@ -6029,7 +6945,8 @@ static int bnx2x_req_msix_irqs(struct bnx2x *bp)
6029 bp->dev->name, &bp->fp[i]); 6945 bp->dev->name, &bp->fp[i]);
6030 6946
6031 if (rc) { 6947 if (rc) {
6032 BNX2X_ERR("request fp #%d irq failed\n", i); 6948 BNX2X_ERR("request fp #%d irq failed "
6949 "rc %d\n", i, rc);
6033 bnx2x_free_msix_irqs(bp); 6950 bnx2x_free_msix_irqs(bp);
6034 return -EBUSY; 6951 return -EBUSY;
6035 } 6952 }
@@ -6109,8 +7026,8 @@ static int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
6109 /* can take a while if any port is running */ 7026 /* can take a while if any port is running */
6110 int timeout = 500; 7027 int timeout = 500;
6111 7028
6112 /* DP("waiting for state to become %d on IDX [%d]\n", 7029 DP(NETIF_MSG_IFUP, "%s for state to become %x on IDX [%d]\n",
6113 state, sb_idx); */ 7030 poll ? "polling" : "waiting", state, idx);
6114 7031
6115 might_sleep(); 7032 might_sleep();
6116 7033
@@ -6128,7 +7045,7 @@ static int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
6128 7045
6129 mb(); /* state is changed by bnx2x_sp_event()*/ 7046 mb(); /* state is changed by bnx2x_sp_event()*/
6130 7047
6131 if (*state_p != state) 7048 if (*state_p == state)
6132 return 0; 7049 return 0;
6133 7050
6134 timeout--; 7051 timeout--;
@@ -6136,17 +7053,17 @@ static int bnx2x_wait_ramrod(struct bnx2x *bp, int state, int idx,
6136 7053
6137 } 7054 }
6138 7055
6139
6140 /* timeout! */ 7056 /* timeout! */
6141 BNX2X_ERR("timeout waiting for ramrod %d on %d\n", state, idx); 7057 BNX2X_ERR("timeout %s for state %x on IDX [%d]\n",
6142 return -EBUSY; 7058 poll ? "polling" : "waiting", state, idx);
6143 7059
7060 return -EBUSY;
6144} 7061}
6145 7062
6146static int bnx2x_setup_leading(struct bnx2x *bp) 7063static int bnx2x_setup_leading(struct bnx2x *bp)
6147{ 7064{
6148 7065
6149 /* reset IGU staae */ 7066 /* reset IGU state */
6150 bnx2x_ack_sb(bp, DEF_SB_ID, CSTORM_ID, 0, IGU_INT_ENABLE, 0); 7067 bnx2x_ack_sb(bp, DEF_SB_ID, CSTORM_ID, 0, IGU_INT_ENABLE, 0);
6151 7068
6152 /* SETUP ramrod */ 7069 /* SETUP ramrod */
@@ -6162,12 +7079,13 @@ static int bnx2x_setup_multi(struct bnx2x *bp, int index)
6162 /* reset IGU state */ 7079 /* reset IGU state */
6163 bnx2x_ack_sb(bp, index, CSTORM_ID, 0, IGU_INT_ENABLE, 0); 7080 bnx2x_ack_sb(bp, index, CSTORM_ID, 0, IGU_INT_ENABLE, 0);
6164 7081
7082 /* SETUP ramrod */
6165 bp->fp[index].state = BNX2X_FP_STATE_OPENING; 7083 bp->fp[index].state = BNX2X_FP_STATE_OPENING;
6166 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_CLIENT_SETUP, index, 0, index, 0); 7084 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_CLIENT_SETUP, index, 0, index, 0);
6167 7085
6168 /* Wait for completion */ 7086 /* Wait for completion */
6169 return bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_OPEN, index, 7087 return bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_OPEN, index,
6170 &(bp->fp[index].state), 1); 7088 &(bp->fp[index].state), 0);
6171 7089
6172} 7090}
6173 7091
@@ -6177,8 +7095,8 @@ static void bnx2x_set_rx_mode(struct net_device *dev);
6177 7095
6178static int bnx2x_nic_load(struct bnx2x *bp, int req_irq) 7096static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6179{ 7097{
6180 int rc; 7098 u32 load_code;
6181 int i = 0; 7099 int i;
6182 7100
6183 bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD; 7101 bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD;
6184 7102
@@ -6188,26 +7106,28 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6188 initialized, otherwise - not. 7106 initialized, otherwise - not.
6189 */ 7107 */
6190 if (!nomcp) { 7108 if (!nomcp) {
6191 rc = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ); 7109 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ);
6192 if (rc == FW_MSG_CODE_DRV_LOAD_REFUSED) { 7110 if (!load_code) {
7111 BNX2X_ERR("MCP response failure, unloading\n");
7112 return -EBUSY;
7113 }
7114 if (load_code == FW_MSG_CODE_DRV_LOAD_REFUSED) {
7115 BNX2X_ERR("MCP refused load request, unloading\n");
6193 return -EBUSY; /* other port in diagnostic mode */ 7116 return -EBUSY; /* other port in diagnostic mode */
6194 } 7117 }
6195 } else { 7118 } else {
6196 rc = FW_MSG_CODE_DRV_LOAD_COMMON; 7119 load_code = FW_MSG_CODE_DRV_LOAD_COMMON;
6197 } 7120 }
6198 7121
6199 DP(NETIF_MSG_IFUP, "set number of queues to %d\n", bp->num_queues);
6200
6201 /* if we can't use msix we only need one fp, 7122 /* if we can't use msix we only need one fp,
6202 * so try to enable msix with the requested number of fp's 7123 * so try to enable msix with the requested number of fp's
6203 * and fallback to inta with one fp 7124 * and fallback to inta with one fp
6204 */ 7125 */
6205 if (req_irq) { 7126 if (req_irq) {
6206
6207 if (use_inta) { 7127 if (use_inta) {
6208 bp->num_queues = 1; 7128 bp->num_queues = 1;
6209 } else { 7129 } else {
6210 if (use_multi > 1 && use_multi <= 16) 7130 if ((use_multi > 1) && (use_multi <= 16))
6211 /* user requested number */ 7131 /* user requested number */
6212 bp->num_queues = use_multi; 7132 bp->num_queues = use_multi;
6213 else if (use_multi == 1) 7133 else if (use_multi == 1)
@@ -6216,15 +7136,17 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6216 bp->num_queues = 1; 7136 bp->num_queues = 1;
6217 7137
6218 if (bnx2x_enable_msix(bp)) { 7138 if (bnx2x_enable_msix(bp)) {
6219 /* faild to enable msix */ 7139 /* failed to enable msix */
6220 bp->num_queues = 1; 7140 bp->num_queues = 1;
6221 if (use_multi) 7141 if (use_multi)
6222 BNX2X_ERR("Muti requested but failed" 7142 BNX2X_ERR("Multi requested but failed"
6223 " to enable MSI-X\n"); 7143 " to enable MSI-X\n");
6224 } 7144 }
6225 } 7145 }
6226 } 7146 }
6227 7147
7148 DP(NETIF_MSG_IFUP, "set number of queues to %d\n", bp->num_queues);
7149
6228 if (bnx2x_alloc_mem(bp)) 7150 if (bnx2x_alloc_mem(bp))
6229 return -ENOMEM; 7151 return -ENOMEM;
6230 7152
@@ -6232,13 +7154,13 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6232 if (bp->flags & USING_MSIX_FLAG) { 7154 if (bp->flags & USING_MSIX_FLAG) {
6233 if (bnx2x_req_msix_irqs(bp)) { 7155 if (bnx2x_req_msix_irqs(bp)) {
6234 pci_disable_msix(bp->pdev); 7156 pci_disable_msix(bp->pdev);
6235 goto out_error; 7157 goto load_error;
6236 } 7158 }
6237 7159
6238 } else { 7160 } else {
6239 if (bnx2x_req_irq(bp)) { 7161 if (bnx2x_req_irq(bp)) {
6240 BNX2X_ERR("IRQ request failed, aborting\n"); 7162 BNX2X_ERR("IRQ request failed, aborting\n");
6241 goto out_error; 7163 goto load_error;
6242 } 7164 }
6243 } 7165 }
6244 } 7166 }
@@ -6249,31 +7171,25 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6249 7171
6250 7172
6251 /* Initialize HW */ 7173 /* Initialize HW */
6252 if (bnx2x_function_init(bp, (rc == FW_MSG_CODE_DRV_LOAD_COMMON))) { 7174 if (bnx2x_function_init(bp,
7175 (load_code == FW_MSG_CODE_DRV_LOAD_COMMON))) {
6253 BNX2X_ERR("HW init failed, aborting\n"); 7176 BNX2X_ERR("HW init failed, aborting\n");
6254 goto out_error; 7177 goto load_error;
6255 } 7178 }
6256 7179
6257 7180
6258 atomic_set(&bp->intr_sem, 0); 7181 atomic_set(&bp->intr_sem, 0);
6259 7182
6260 /* Reenable SP tasklet */
6261 /*if (bp->sp_task_en) { */
6262 /* tasklet_enable(&bp->sp_task);*/
6263 /*} else { */
6264 /* bp->sp_task_en = 1; */
6265 /*} */
6266 7183
6267 /* Setup NIC internals and enable interrupts */ 7184 /* Setup NIC internals and enable interrupts */
6268 bnx2x_nic_init(bp); 7185 bnx2x_nic_init(bp);
6269 7186
6270 /* Send LOAD_DONE command to MCP */ 7187 /* Send LOAD_DONE command to MCP */
6271 if (!nomcp) { 7188 if (!nomcp) {
6272 rc = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE); 7189 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE);
6273 DP(NETIF_MSG_IFUP, "rc = 0x%x\n", rc); 7190 if (!load_code) {
6274 if (!rc) {
6275 BNX2X_ERR("MCP response failure, unloading\n"); 7191 BNX2X_ERR("MCP response failure, unloading\n");
6276 goto int_disable; 7192 goto load_int_disable;
6277 } 7193 }
6278 } 7194 }
6279 7195
@@ -6285,11 +7201,11 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6285 napi_enable(&bnx2x_fp(bp, i, napi)); 7201 napi_enable(&bnx2x_fp(bp, i, napi));
6286 7202
6287 if (bnx2x_setup_leading(bp)) 7203 if (bnx2x_setup_leading(bp))
6288 goto stop_netif; 7204 goto load_stop_netif;
6289 7205
6290 for_each_nondefault_queue(bp, i) 7206 for_each_nondefault_queue(bp, i)
6291 if (bnx2x_setup_multi(bp, i)) 7207 if (bnx2x_setup_multi(bp, i))
6292 goto stop_netif; 7208 goto load_stop_netif;
6293 7209
6294 bnx2x_set_mac_addr(bp); 7210 bnx2x_set_mac_addr(bp);
6295 7211
@@ -6313,42 +7229,24 @@ static int bnx2x_nic_load(struct bnx2x *bp, int req_irq)
6313 7229
6314 return 0; 7230 return 0;
6315 7231
6316stop_netif: 7232load_stop_netif:
6317 for_each_queue(bp, i) 7233 for_each_queue(bp, i)
6318 napi_disable(&bnx2x_fp(bp, i, napi)); 7234 napi_disable(&bnx2x_fp(bp, i, napi));
6319 7235
6320int_disable: 7236load_int_disable:
6321 bnx2x_disable_int_sync(bp); 7237 bnx2x_int_disable_sync(bp);
6322 7238
6323 bnx2x_free_skbs(bp); 7239 bnx2x_free_skbs(bp);
6324 bnx2x_free_irq(bp); 7240 bnx2x_free_irq(bp);
6325 7241
6326out_error: 7242load_error:
6327 bnx2x_free_mem(bp); 7243 bnx2x_free_mem(bp);
6328 7244
6329 /* TBD we really need to reset the chip 7245 /* TBD we really need to reset the chip
6330 if we want to recover from this */ 7246 if we want to recover from this */
6331 return rc; 7247 return -EBUSY;
6332} 7248}
6333 7249
6334static void bnx2x_netif_stop(struct bnx2x *bp)
6335{
6336 int i;
6337
6338 bp->rx_mode = BNX2X_RX_MODE_NONE;
6339 bnx2x_set_storm_rx_mode(bp);
6340
6341 bnx2x_disable_int_sync(bp);
6342 bnx2x_link_reset(bp);
6343
6344 for_each_queue(bp, i)
6345 napi_disable(&bnx2x_fp(bp, i, napi));
6346
6347 if (netif_running(bp->dev)) {
6348 netif_tx_disable(bp->dev);
6349 bp->dev->trans_start = jiffies; /* prevent tx timeout */
6350 }
6351}
6352 7250
6353static void bnx2x_reset_chip(struct bnx2x *bp, u32 reset_code) 7251static void bnx2x_reset_chip(struct bnx2x *bp, u32 reset_code)
6354{ 7252{
@@ -6401,20 +7299,20 @@ static int bnx2x_stop_multi(struct bnx2x *bp, int index)
6401 7299
6402 int rc; 7300 int rc;
6403 7301
6404 /* halt the connnection */ 7302 /* halt the connection */
6405 bp->fp[index].state = BNX2X_FP_STATE_HALTING; 7303 bp->fp[index].state = BNX2X_FP_STATE_HALTING;
6406 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_HALT, index, 0, 0, 0); 7304 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_HALT, index, 0, 0, 0);
6407 7305
6408 7306
6409 rc = bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_HALTED, index, 7307 rc = bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_HALTED, index,
6410 &(bp->fp[index].state), 1); 7308 &(bp->fp[index].state), 1);
6411 if (rc) /* timout */ 7309 if (rc) /* timeout */
6412 return rc; 7310 return rc;
6413 7311
6414 /* delete cfc entry */ 7312 /* delete cfc entry */
6415 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_CFC_DEL, index, 0, 0, 1); 7313 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_CFC_DEL, index, 0, 0, 1);
6416 7314
6417 return bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_DELETED, index, 7315 return bnx2x_wait_ramrod(bp, BNX2X_FP_STATE_CLOSED, index,
6418 &(bp->fp[index].state), 1); 7316 &(bp->fp[index].state), 1);
6419 7317
6420} 7318}
@@ -6422,8 +7320,8 @@ static int bnx2x_stop_multi(struct bnx2x *bp, int index)
6422 7320
6423static void bnx2x_stop_leading(struct bnx2x *bp) 7321static void bnx2x_stop_leading(struct bnx2x *bp)
6424{ 7322{
6425 7323 u16 dsb_sp_prod_idx;
6426 /* if the other port is hadling traffic, 7324 /* if the other port is handling traffic,
6427 this can take a lot of time */ 7325 this can take a lot of time */
6428 int timeout = 500; 7326 int timeout = 500;
6429 7327
@@ -6437,52 +7335,71 @@ static void bnx2x_stop_leading(struct bnx2x *bp)
6437 &(bp->fp[0].state), 1)) 7335 &(bp->fp[0].state), 1))
6438 return; 7336 return;
6439 7337
6440 bp->dsb_sp_prod_idx = *bp->dsb_sp_prod; 7338 dsb_sp_prod_idx = *bp->dsb_sp_prod;
6441 7339
6442 /* Send CFC_DELETE ramrod */ 7340 /* Send PORT_DELETE ramrod */
6443 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_PORT_DEL, 0, 0, 0, 1); 7341 bnx2x_sp_post(bp, RAMROD_CMD_ID_ETH_PORT_DEL, 0, 0, 0, 1);
6444 7342
6445 /* 7343 /* Wait for completion to arrive on default status block
6446 Wait for completion.
6447 we are going to reset the chip anyway 7344 we are going to reset the chip anyway
6448 so there is not much to do if this times out 7345 so there is not much to do if this times out
6449 */ 7346 */
6450 while (bp->dsb_sp_prod_idx == *bp->dsb_sp_prod && timeout) { 7347 while ((dsb_sp_prod_idx == *bp->dsb_sp_prod) && timeout) {
6451 timeout--; 7348 timeout--;
6452 msleep(1); 7349 msleep(1);
6453 } 7350 }
6454 7351 if (!timeout) {
7352 DP(NETIF_MSG_IFDOWN, "timeout polling for completion "
7353 "dsb_sp_prod 0x%x != dsb_sp_prod_idx 0x%x\n",
7354 *bp->dsb_sp_prod, dsb_sp_prod_idx);
7355 }
7356 bp->state = BNX2X_STATE_CLOSING_WAIT4_UNLOAD;
7357 bp->fp[0].state = BNX2X_FP_STATE_CLOSED;
6455} 7358}
6456 7359
6457static int bnx2x_nic_unload(struct bnx2x *bp, int fre_irq) 7360
7361static int bnx2x_nic_unload(struct bnx2x *bp, int free_irq)
6458{ 7362{
6459 u32 reset_code = 0; 7363 u32 reset_code = 0;
6460 int rc; 7364 int i, timeout;
6461 int i;
6462 7365
6463 bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT; 7366 bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
6464 7367
6465 /* Calling flush_scheduled_work() may deadlock because 7368 del_timer_sync(&bp->timer);
6466 * linkwatch_event() may be on the workqueue and it will try to get
6467 * the rtnl_lock which we are holding.
6468 */
6469 7369
6470 while (bp->in_reset_task) 7370 bp->rx_mode = BNX2X_RX_MODE_NONE;
6471 msleep(1); 7371 bnx2x_set_storm_rx_mode(bp);
6472 7372
6473 /* Delete the timer: do it before disabling interrupts, as it 7373 if (netif_running(bp->dev)) {
6474 may be stil STAT_QUERY ramrod pending after stopping the timer */ 7374 netif_tx_disable(bp->dev);
6475 del_timer_sync(&bp->timer); 7375 bp->dev->trans_start = jiffies; /* prevent tx timeout */
7376 }
7377
7378 /* Wait until all fast path tasks complete */
7379 for_each_queue(bp, i) {
7380 struct bnx2x_fastpath *fp = &bp->fp[i];
7381
7382 timeout = 1000;
7383 while (bnx2x_has_work(fp) && (timeout--))
7384 msleep(1);
7385 if (!timeout)
7386 BNX2X_ERR("timeout waiting for queue[%d]\n", i);
7387 }
6476 7388
6477 /* Wait until stat ramrod returns and all SP tasks complete */ 7389 /* Wait until stat ramrod returns and all SP tasks complete */
6478 while (bp->stat_pending && (bp->spq_left != MAX_SPQ_PENDING)) 7390 timeout = 1000;
7391 while ((bp->stat_pending || (bp->spq_left != MAX_SPQ_PENDING)) &&
7392 (timeout--))
6479 msleep(1); 7393 msleep(1);
6480 7394
6481 /* Stop fast path, disable MAC, disable interrupts, disable napi */ 7395 for_each_queue(bp, i)
6482 bnx2x_netif_stop(bp); 7396 napi_disable(&bnx2x_fp(bp, i, napi));
7397 /* Disable interrupts after Tx and Rx are disabled on stack level */
7398 bnx2x_int_disable_sync(bp);
6483 7399
6484 if (bp->flags & NO_WOL_FLAG) 7400 if (bp->flags & NO_WOL_FLAG)
6485 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP; 7401 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP;
7402
6486 else if (bp->wol) { 7403 else if (bp->wol) {
6487 u32 emac_base = bp->port ? GRCBASE_EMAC0 : GRCBASE_EMAC1; 7404 u32 emac_base = bp->port ? GRCBASE_EMAC0 : GRCBASE_EMAC1;
6488 u8 *mac_addr = bp->dev->dev_addr; 7405 u8 *mac_addr = bp->dev->dev_addr;
@@ -6499,28 +7416,37 @@ static int bnx2x_nic_unload(struct bnx2x *bp, int fre_irq)
6499 EMAC_WR(EMAC_REG_EMAC_MAC_MATCH + 4, val); 7416 EMAC_WR(EMAC_REG_EMAC_MAC_MATCH + 4, val);
6500 7417
6501 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_EN; 7418 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_EN;
7419
6502 } else 7420 } else
6503 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS; 7421 reset_code = DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS;
6504 7422
7423 /* Close multi and leading connections */
6505 for_each_nondefault_queue(bp, i) 7424 for_each_nondefault_queue(bp, i)
6506 if (bnx2x_stop_multi(bp, i)) 7425 if (bnx2x_stop_multi(bp, i))
6507 goto error; 7426 goto unload_error;
6508
6509 7427
6510 bnx2x_stop_leading(bp); 7428 bnx2x_stop_leading(bp);
7429 if ((bp->state != BNX2X_STATE_CLOSING_WAIT4_UNLOAD) ||
7430 (bp->fp[0].state != BNX2X_FP_STATE_CLOSED)) {
7431 DP(NETIF_MSG_IFDOWN, "failed to close leading properly!"
7432 "state 0x%x fp[0].state 0x%x",
7433 bp->state, bp->fp[0].state);
7434 }
7435
7436unload_error:
7437 bnx2x_link_reset(bp);
6511 7438
6512error:
6513 if (!nomcp) 7439 if (!nomcp)
6514 rc = bnx2x_fw_command(bp, reset_code); 7440 reset_code = bnx2x_fw_command(bp, reset_code);
6515 else 7441 else
6516 rc = FW_MSG_CODE_DRV_UNLOAD_COMMON; 7442 reset_code = FW_MSG_CODE_DRV_UNLOAD_COMMON;
6517 7443
6518 /* Release IRQs */ 7444 /* Release IRQs */
6519 if (fre_irq) 7445 if (free_irq)
6520 bnx2x_free_irq(bp); 7446 bnx2x_free_irq(bp);
6521 7447
6522 /* Reset the chip */ 7448 /* Reset the chip */
6523 bnx2x_reset_chip(bp, rc); 7449 bnx2x_reset_chip(bp, reset_code);
6524 7450
6525 /* Report UNLOAD_DONE to MCP */ 7451 /* Report UNLOAD_DONE to MCP */
6526 if (!nomcp) 7452 if (!nomcp)
@@ -6531,8 +7457,7 @@ error:
6531 bnx2x_free_mem(bp); 7457 bnx2x_free_mem(bp);
6532 7458
6533 bp->state = BNX2X_STATE_CLOSED; 7459 bp->state = BNX2X_STATE_CLOSED;
6534 /* Set link down */ 7460
6535 bp->link_up = 0;
6536 netif_carrier_off(bp->dev); 7461 netif_carrier_off(bp->dev);
6537 7462
6538 return 0; 7463 return 0;
@@ -6568,7 +7493,7 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
6568 SUPPORTED_100baseT_Half | 7493 SUPPORTED_100baseT_Half |
6569 SUPPORTED_100baseT_Full | 7494 SUPPORTED_100baseT_Full |
6570 SUPPORTED_1000baseT_Full | 7495 SUPPORTED_1000baseT_Full |
6571 SUPPORTED_2500baseT_Full | 7496 SUPPORTED_2500baseX_Full |
6572 SUPPORTED_TP | SUPPORTED_FIBRE | 7497 SUPPORTED_TP | SUPPORTED_FIBRE |
6573 SUPPORTED_Autoneg | 7498 SUPPORTED_Autoneg |
6574 SUPPORTED_Pause | 7499 SUPPORTED_Pause |
@@ -6581,10 +7506,10 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
6581 7506
6582 bp->phy_flags |= PHY_SGMII_FLAG; 7507 bp->phy_flags |= PHY_SGMII_FLAG;
6583 7508
6584 bp->supported |= (/* SUPPORTED_10baseT_Half | 7509 bp->supported |= (SUPPORTED_10baseT_Half |
6585 SUPPORTED_10baseT_Full | 7510 SUPPORTED_10baseT_Full |
6586 SUPPORTED_100baseT_Half | 7511 SUPPORTED_100baseT_Half |
6587 SUPPORTED_100baseT_Full |*/ 7512 SUPPORTED_100baseT_Full |
6588 SUPPORTED_1000baseT_Full | 7513 SUPPORTED_1000baseT_Full |
6589 SUPPORTED_TP | SUPPORTED_FIBRE | 7514 SUPPORTED_TP | SUPPORTED_FIBRE |
6590 SUPPORTED_Autoneg | 7515 SUPPORTED_Autoneg |
@@ -6620,7 +7545,7 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
6620 SUPPORTED_100baseT_Half | 7545 SUPPORTED_100baseT_Half |
6621 SUPPORTED_100baseT_Full | 7546 SUPPORTED_100baseT_Full |
6622 SUPPORTED_1000baseT_Full | 7547 SUPPORTED_1000baseT_Full |
6623 SUPPORTED_2500baseT_Full | 7548 SUPPORTED_2500baseX_Full |
6624 SUPPORTED_10000baseT_Full | 7549 SUPPORTED_10000baseT_Full |
6625 SUPPORTED_TP | SUPPORTED_FIBRE | 7550 SUPPORTED_TP | SUPPORTED_FIBRE |
6626 SUPPORTED_Autoneg | 7551 SUPPORTED_Autoneg |
@@ -6629,12 +7554,46 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
6629 break; 7554 break;
6630 7555
6631 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705: 7556 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705:
7557 BNX2X_DEV_INFO("ext_phy_type 0x%x (8705)\n",
7558 ext_phy_type);
7559
7560 bp->supported |= (SUPPORTED_10000baseT_Full |
7561 SUPPORTED_FIBRE |
7562 SUPPORTED_Pause |
7563 SUPPORTED_Asym_Pause);
7564 break;
7565
6632 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706: 7566 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706:
6633 BNX2X_DEV_INFO("ext_phy_type 0x%x (8705/6)\n", 7567 BNX2X_DEV_INFO("ext_phy_type 0x%x (8706)\n",
7568 ext_phy_type);
7569
7570 bp->supported |= (SUPPORTED_10000baseT_Full |
7571 SUPPORTED_1000baseT_Full |
7572 SUPPORTED_Autoneg |
7573 SUPPORTED_FIBRE |
7574 SUPPORTED_Pause |
7575 SUPPORTED_Asym_Pause);
7576 break;
7577
7578 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072:
7579 BNX2X_DEV_INFO("ext_phy_type 0x%x (8072)\n",
6634 ext_phy_type); 7580 ext_phy_type);
6635 7581
6636 bp->supported |= (SUPPORTED_10000baseT_Full | 7582 bp->supported |= (SUPPORTED_10000baseT_Full |
7583 SUPPORTED_1000baseT_Full |
6637 SUPPORTED_FIBRE | 7584 SUPPORTED_FIBRE |
7585 SUPPORTED_Autoneg |
7586 SUPPORTED_Pause |
7587 SUPPORTED_Asym_Pause);
7588 break;
7589
7590 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101:
7591 BNX2X_DEV_INFO("ext_phy_type 0x%x (SFX7101)\n",
7592 ext_phy_type);
7593
7594 bp->supported |= (SUPPORTED_10000baseT_Full |
7595 SUPPORTED_TP |
7596 SUPPORTED_Autoneg |
6638 SUPPORTED_Pause | 7597 SUPPORTED_Pause |
6639 SUPPORTED_Asym_Pause); 7598 SUPPORTED_Asym_Pause);
6640 break; 7599 break;
@@ -6691,7 +7650,7 @@ static void bnx2x_link_settings_supported(struct bnx2x *bp, u32 switch_cfg)
6691 SUPPORTED_1000baseT_Full); 7650 SUPPORTED_1000baseT_Full);
6692 7651
6693 if (!(bp->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G)) 7652 if (!(bp->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G))
6694 bp->supported &= ~SUPPORTED_2500baseT_Full; 7653 bp->supported &= ~SUPPORTED_2500baseX_Full;
6695 7654
6696 if (!(bp->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) 7655 if (!(bp->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G))
6697 bp->supported &= ~SUPPORTED_10000baseT_Full; 7656 bp->supported &= ~SUPPORTED_10000baseT_Full;
@@ -6711,13 +7670,8 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6711 bp->req_line_speed = 0; 7670 bp->req_line_speed = 0;
6712 bp->advertising = bp->supported; 7671 bp->advertising = bp->supported;
6713 } else { 7672 } else {
6714 u32 ext_phy_type; 7673 if (XGXS_EXT_PHY_TYPE(bp) ==
6715 7674 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705) {
6716 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
6717 if ((ext_phy_type ==
6718 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705) ||
6719 (ext_phy_type ==
6720 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706)) {
6721 /* force 10G, no AN */ 7675 /* force 10G, no AN */
6722 bp->req_line_speed = SPEED_10000; 7676 bp->req_line_speed = SPEED_10000;
6723 bp->advertising = 7677 bp->advertising =
@@ -6734,8 +7688,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6734 break; 7688 break;
6735 7689
6736 case PORT_FEATURE_LINK_SPEED_10M_FULL: 7690 case PORT_FEATURE_LINK_SPEED_10M_FULL:
6737 if (bp->speed_cap_mask & 7691 if (bp->supported & SUPPORTED_10baseT_Full) {
6738 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL) {
6739 bp->req_line_speed = SPEED_10; 7692 bp->req_line_speed = SPEED_10;
6740 bp->advertising = (ADVERTISED_10baseT_Full | 7693 bp->advertising = (ADVERTISED_10baseT_Full |
6741 ADVERTISED_TP); 7694 ADVERTISED_TP);
@@ -6749,8 +7702,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6749 break; 7702 break;
6750 7703
6751 case PORT_FEATURE_LINK_SPEED_10M_HALF: 7704 case PORT_FEATURE_LINK_SPEED_10M_HALF:
6752 if (bp->speed_cap_mask & 7705 if (bp->supported & SUPPORTED_10baseT_Half) {
6753 PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF) {
6754 bp->req_line_speed = SPEED_10; 7706 bp->req_line_speed = SPEED_10;
6755 bp->req_duplex = DUPLEX_HALF; 7707 bp->req_duplex = DUPLEX_HALF;
6756 bp->advertising = (ADVERTISED_10baseT_Half | 7708 bp->advertising = (ADVERTISED_10baseT_Half |
@@ -6765,8 +7717,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6765 break; 7717 break;
6766 7718
6767 case PORT_FEATURE_LINK_SPEED_100M_FULL: 7719 case PORT_FEATURE_LINK_SPEED_100M_FULL:
6768 if (bp->speed_cap_mask & 7720 if (bp->supported & SUPPORTED_100baseT_Full) {
6769 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL) {
6770 bp->req_line_speed = SPEED_100; 7721 bp->req_line_speed = SPEED_100;
6771 bp->advertising = (ADVERTISED_100baseT_Full | 7722 bp->advertising = (ADVERTISED_100baseT_Full |
6772 ADVERTISED_TP); 7723 ADVERTISED_TP);
@@ -6780,8 +7731,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6780 break; 7731 break;
6781 7732
6782 case PORT_FEATURE_LINK_SPEED_100M_HALF: 7733 case PORT_FEATURE_LINK_SPEED_100M_HALF:
6783 if (bp->speed_cap_mask & 7734 if (bp->supported & SUPPORTED_100baseT_Half) {
6784 PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF) {
6785 bp->req_line_speed = SPEED_100; 7735 bp->req_line_speed = SPEED_100;
6786 bp->req_duplex = DUPLEX_HALF; 7736 bp->req_duplex = DUPLEX_HALF;
6787 bp->advertising = (ADVERTISED_100baseT_Half | 7737 bp->advertising = (ADVERTISED_100baseT_Half |
@@ -6796,8 +7746,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6796 break; 7746 break;
6797 7747
6798 case PORT_FEATURE_LINK_SPEED_1G: 7748 case PORT_FEATURE_LINK_SPEED_1G:
6799 if (bp->speed_cap_mask & 7749 if (bp->supported & SUPPORTED_1000baseT_Full) {
6800 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G) {
6801 bp->req_line_speed = SPEED_1000; 7750 bp->req_line_speed = SPEED_1000;
6802 bp->advertising = (ADVERTISED_1000baseT_Full | 7751 bp->advertising = (ADVERTISED_1000baseT_Full |
6803 ADVERTISED_TP); 7752 ADVERTISED_TP);
@@ -6811,10 +7760,9 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6811 break; 7760 break;
6812 7761
6813 case PORT_FEATURE_LINK_SPEED_2_5G: 7762 case PORT_FEATURE_LINK_SPEED_2_5G:
6814 if (bp->speed_cap_mask & 7763 if (bp->supported & SUPPORTED_2500baseX_Full) {
6815 PORT_HW_CFG_SPEED_CAPABILITY_D0_2_5G) {
6816 bp->req_line_speed = SPEED_2500; 7764 bp->req_line_speed = SPEED_2500;
6817 bp->advertising = (ADVERTISED_2500baseT_Full | 7765 bp->advertising = (ADVERTISED_2500baseX_Full |
6818 ADVERTISED_TP); 7766 ADVERTISED_TP);
6819 } else { 7767 } else {
6820 BNX2X_ERR("NVRAM config error. " 7768 BNX2X_ERR("NVRAM config error. "
@@ -6828,15 +7776,7 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6828 case PORT_FEATURE_LINK_SPEED_10G_CX4: 7776 case PORT_FEATURE_LINK_SPEED_10G_CX4:
6829 case PORT_FEATURE_LINK_SPEED_10G_KX4: 7777 case PORT_FEATURE_LINK_SPEED_10G_KX4:
6830 case PORT_FEATURE_LINK_SPEED_10G_KR: 7778 case PORT_FEATURE_LINK_SPEED_10G_KR:
6831 if (!(bp->phy_flags & PHY_XGXS_FLAG)) { 7779 if (bp->supported & SUPPORTED_10000baseT_Full) {
6832 BNX2X_ERR("NVRAM config error. "
6833 "Invalid link_config 0x%x"
6834 " phy_flags 0x%x\n",
6835 bp->link_config, bp->phy_flags);
6836 return;
6837 }
6838 if (bp->speed_cap_mask &
6839 PORT_HW_CFG_SPEED_CAPABILITY_D0_10G) {
6840 bp->req_line_speed = SPEED_10000; 7780 bp->req_line_speed = SPEED_10000;
6841 bp->advertising = (ADVERTISED_10000baseT_Full | 7781 bp->advertising = (ADVERTISED_10000baseT_Full |
6842 ADVERTISED_FIBRE); 7782 ADVERTISED_FIBRE);
@@ -6863,43 +7803,13 @@ static void bnx2x_link_settings_requested(struct bnx2x *bp)
6863 7803
6864 bp->req_flow_ctrl = (bp->link_config & 7804 bp->req_flow_ctrl = (bp->link_config &
6865 PORT_FEATURE_FLOW_CONTROL_MASK); 7805 PORT_FEATURE_FLOW_CONTROL_MASK);
6866 /* Please refer to Table 28B-3 of the 802.3ab-1999 spec */ 7806 if ((bp->req_flow_ctrl == FLOW_CTRL_AUTO) &&
6867 switch (bp->req_flow_ctrl) { 7807 (bp->supported & SUPPORTED_Autoneg))
6868 case FLOW_CTRL_AUTO:
6869 bp->req_autoneg |= AUTONEG_FLOW_CTRL; 7808 bp->req_autoneg |= AUTONEG_FLOW_CTRL;
6870 if (bp->dev->mtu <= 4500) {
6871 bp->pause_mode = PAUSE_BOTH;
6872 bp->advertising |= (ADVERTISED_Pause |
6873 ADVERTISED_Asym_Pause);
6874 } else {
6875 bp->pause_mode = PAUSE_ASYMMETRIC;
6876 bp->advertising |= ADVERTISED_Asym_Pause;
6877 }
6878 break;
6879
6880 case FLOW_CTRL_TX:
6881 bp->pause_mode = PAUSE_ASYMMETRIC;
6882 bp->advertising |= ADVERTISED_Asym_Pause;
6883 break;
6884
6885 case FLOW_CTRL_RX:
6886 case FLOW_CTRL_BOTH:
6887 bp->pause_mode = PAUSE_BOTH;
6888 bp->advertising |= (ADVERTISED_Pause |
6889 ADVERTISED_Asym_Pause);
6890 break;
6891 7809
6892 case FLOW_CTRL_NONE: 7810 BNX2X_DEV_INFO("req_autoneg 0x%x req_flow_ctrl 0x%x"
6893 default: 7811 " advertising 0x%x\n",
6894 bp->pause_mode = PAUSE_NONE; 7812 bp->req_autoneg, bp->req_flow_ctrl, bp->advertising);
6895 bp->advertising &= ~(ADVERTISED_Pause |
6896 ADVERTISED_Asym_Pause);
6897 break;
6898 }
6899 BNX2X_DEV_INFO("req_autoneg 0x%x req_flow_ctrl 0x%x\n"
6900 KERN_INFO " pause_mode %d advertising 0x%x\n",
6901 bp->req_autoneg, bp->req_flow_ctrl,
6902 bp->pause_mode, bp->advertising);
6903} 7813}
6904 7814
6905static void bnx2x_get_hwinfo(struct bnx2x *bp) 7815static void bnx2x_get_hwinfo(struct bnx2x *bp)
@@ -6933,15 +7843,15 @@ static void bnx2x_get_hwinfo(struct bnx2x *bp)
6933 val = SHMEM_RD(bp, validity_map[port]); 7843 val = SHMEM_RD(bp, validity_map[port]);
6934 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) 7844 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
6935 != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) 7845 != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
6936 BNX2X_ERR("MCP validity signature bad\n"); 7846 BNX2X_ERR("BAD MCP validity signature\n");
6937 7847
6938 bp->fw_seq = (SHMEM_RD(bp, drv_fw_mb[port].drv_mb_header) & 7848 bp->fw_seq = (SHMEM_RD(bp, func_mb[port].drv_mb_header) &
6939 DRV_MSG_SEQ_NUMBER_MASK); 7849 DRV_MSG_SEQ_NUMBER_MASK);
6940 7850
6941 bp->hw_config = SHMEM_RD(bp, dev_info.shared_hw_config.config); 7851 bp->hw_config = SHMEM_RD(bp, dev_info.shared_hw_config.config);
6942 7852 bp->board = SHMEM_RD(bp, dev_info.shared_hw_config.board);
6943 bp->serdes_config = 7853 bp->serdes_config =
6944 SHMEM_RD(bp, dev_info.port_hw_config[bp->port].serdes_config); 7854 SHMEM_RD(bp, dev_info.port_hw_config[port].serdes_config);
6945 bp->lane_config = 7855 bp->lane_config =
6946 SHMEM_RD(bp, dev_info.port_hw_config[port].lane_config); 7856 SHMEM_RD(bp, dev_info.port_hw_config[port].lane_config);
6947 bp->ext_phy_config = 7857 bp->ext_phy_config =
@@ -6954,13 +7864,13 @@ static void bnx2x_get_hwinfo(struct bnx2x *bp)
6954 bp->link_config = 7864 bp->link_config =
6955 SHMEM_RD(bp, dev_info.port_feature_config[port].link_config); 7865 SHMEM_RD(bp, dev_info.port_feature_config[port].link_config);
6956 7866
6957 BNX2X_DEV_INFO("hw_config (%08x) serdes_config (%08x)\n" 7867 BNX2X_DEV_INFO("hw_config (%08x) board (%08x) serdes_config (%08x)\n"
6958 KERN_INFO " lane_config (%08x) ext_phy_config (%08x)\n" 7868 KERN_INFO " lane_config (%08x) ext_phy_config (%08x)\n"
6959 KERN_INFO " speed_cap_mask (%08x) link_config (%08x)" 7869 KERN_INFO " speed_cap_mask (%08x) link_config (%08x)"
6960 " fw_seq (%08x)\n", 7870 " fw_seq (%08x)\n",
6961 bp->hw_config, bp->serdes_config, bp->lane_config, 7871 bp->hw_config, bp->board, bp->serdes_config,
6962 bp->ext_phy_config, bp->speed_cap_mask, 7872 bp->lane_config, bp->ext_phy_config,
6963 bp->link_config, bp->fw_seq); 7873 bp->speed_cap_mask, bp->link_config, bp->fw_seq);
6964 7874
6965 switch_cfg = (bp->link_config & PORT_FEATURE_CONNECTED_SWITCH_MASK); 7875 switch_cfg = (bp->link_config & PORT_FEATURE_CONNECTED_SWITCH_MASK);
6966 bnx2x_link_settings_supported(bp, switch_cfg); 7876 bnx2x_link_settings_supported(bp, switch_cfg);
@@ -7014,14 +7924,8 @@ static void bnx2x_get_hwinfo(struct bnx2x *bp)
7014 return; 7924 return;
7015 7925
7016set_mac: /* only supposed to happen on emulation/FPGA */ 7926set_mac: /* only supposed to happen on emulation/FPGA */
7017 BNX2X_ERR("warning constant MAC workaround active\n"); 7927 BNX2X_ERR("warning rendom MAC workaround active\n");
7018 bp->dev->dev_addr[0] = 0; 7928 random_ether_addr(bp->dev->dev_addr);
7019 bp->dev->dev_addr[1] = 0x50;
7020 bp->dev->dev_addr[2] = 0xc2;
7021 bp->dev->dev_addr[3] = 0x2c;
7022 bp->dev->dev_addr[4] = 0x71;
7023 bp->dev->dev_addr[5] = port ? 0x0d : 0x0e;
7024
7025 memcpy(bp->dev->perm_addr, bp->dev->dev_addr, 6); 7929 memcpy(bp->dev->perm_addr, bp->dev->dev_addr, 6);
7026 7930
7027} 7931}
@@ -7048,19 +7952,34 @@ static int bnx2x_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7048 } 7952 }
7049 7953
7050 if (bp->phy_flags & PHY_XGXS_FLAG) { 7954 if (bp->phy_flags & PHY_XGXS_FLAG) {
7051 cmd->port = PORT_FIBRE; 7955 u32 ext_phy_type = XGXS_EXT_PHY_TYPE(bp);
7052 } else { 7956
7957 switch (ext_phy_type) {
7958 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT:
7959 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8705:
7960 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706:
7961 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8072:
7962 cmd->port = PORT_FIBRE;
7963 break;
7964
7965 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101:
7966 cmd->port = PORT_TP;
7967 break;
7968
7969 default:
7970 DP(NETIF_MSG_LINK, "BAD XGXS ext_phy_config 0x%x\n",
7971 bp->ext_phy_config);
7972 }
7973 } else
7053 cmd->port = PORT_TP; 7974 cmd->port = PORT_TP;
7054 }
7055 7975
7056 cmd->phy_address = bp->phy_addr; 7976 cmd->phy_address = bp->phy_addr;
7057 cmd->transceiver = XCVR_INTERNAL; 7977 cmd->transceiver = XCVR_INTERNAL;
7058 7978
7059 if (bp->req_autoneg & AUTONEG_SPEED) { 7979 if (bp->req_autoneg & AUTONEG_SPEED)
7060 cmd->autoneg = AUTONEG_ENABLE; 7980 cmd->autoneg = AUTONEG_ENABLE;
7061 } else { 7981 else
7062 cmd->autoneg = AUTONEG_DISABLE; 7982 cmd->autoneg = AUTONEG_DISABLE;
7063 }
7064 7983
7065 cmd->maxtxpkt = 0; 7984 cmd->maxtxpkt = 0;
7066 cmd->maxrxpkt = 0; 7985 cmd->maxrxpkt = 0;
@@ -7091,8 +8010,10 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7091 8010
7092 switch (cmd->port) { 8011 switch (cmd->port) {
7093 case PORT_TP: 8012 case PORT_TP:
7094 if (!(bp->supported & SUPPORTED_TP)) 8013 if (!(bp->supported & SUPPORTED_TP)) {
8014 DP(NETIF_MSG_LINK, "TP not supported\n");
7095 return -EINVAL; 8015 return -EINVAL;
8016 }
7096 8017
7097 if (bp->phy_flags & PHY_XGXS_FLAG) { 8018 if (bp->phy_flags & PHY_XGXS_FLAG) {
7098 bnx2x_link_reset(bp); 8019 bnx2x_link_reset(bp);
@@ -7102,8 +8023,10 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7102 break; 8023 break;
7103 8024
7104 case PORT_FIBRE: 8025 case PORT_FIBRE:
7105 if (!(bp->supported & SUPPORTED_FIBRE)) 8026 if (!(bp->supported & SUPPORTED_FIBRE)) {
8027 DP(NETIF_MSG_LINK, "FIBRE not supported\n");
7106 return -EINVAL; 8028 return -EINVAL;
8029 }
7107 8030
7108 if (!(bp->phy_flags & PHY_XGXS_FLAG)) { 8031 if (!(bp->phy_flags & PHY_XGXS_FLAG)) {
7109 bnx2x_link_reset(bp); 8032 bnx2x_link_reset(bp);
@@ -7113,12 +8036,15 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7113 break; 8036 break;
7114 8037
7115 default: 8038 default:
8039 DP(NETIF_MSG_LINK, "Unknown port type\n");
7116 return -EINVAL; 8040 return -EINVAL;
7117 } 8041 }
7118 8042
7119 if (cmd->autoneg == AUTONEG_ENABLE) { 8043 if (cmd->autoneg == AUTONEG_ENABLE) {
7120 if (!(bp->supported & SUPPORTED_Autoneg)) 8044 if (!(bp->supported & SUPPORTED_Autoneg)) {
8045 DP(NETIF_MSG_LINK, "Aotoneg not supported\n");
7121 return -EINVAL; 8046 return -EINVAL;
8047 }
7122 8048
7123 /* advertise the requested speed and duplex if supported */ 8049 /* advertise the requested speed and duplex if supported */
7124 cmd->advertising &= bp->supported; 8050 cmd->advertising &= bp->supported;
@@ -7133,14 +8059,22 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7133 switch (cmd->speed) { 8059 switch (cmd->speed) {
7134 case SPEED_10: 8060 case SPEED_10:
7135 if (cmd->duplex == DUPLEX_FULL) { 8061 if (cmd->duplex == DUPLEX_FULL) {
7136 if (!(bp->supported & SUPPORTED_10baseT_Full)) 8062 if (!(bp->supported &
8063 SUPPORTED_10baseT_Full)) {
8064 DP(NETIF_MSG_LINK,
8065 "10M full not supported\n");
7137 return -EINVAL; 8066 return -EINVAL;
8067 }
7138 8068
7139 advertising = (ADVERTISED_10baseT_Full | 8069 advertising = (ADVERTISED_10baseT_Full |
7140 ADVERTISED_TP); 8070 ADVERTISED_TP);
7141 } else { 8071 } else {
7142 if (!(bp->supported & SUPPORTED_10baseT_Half)) 8072 if (!(bp->supported &
8073 SUPPORTED_10baseT_Half)) {
8074 DP(NETIF_MSG_LINK,
8075 "10M half not supported\n");
7143 return -EINVAL; 8076 return -EINVAL;
8077 }
7144 8078
7145 advertising = (ADVERTISED_10baseT_Half | 8079 advertising = (ADVERTISED_10baseT_Half |
7146 ADVERTISED_TP); 8080 ADVERTISED_TP);
@@ -7150,15 +8084,21 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7150 case SPEED_100: 8084 case SPEED_100:
7151 if (cmd->duplex == DUPLEX_FULL) { 8085 if (cmd->duplex == DUPLEX_FULL) {
7152 if (!(bp->supported & 8086 if (!(bp->supported &
7153 SUPPORTED_100baseT_Full)) 8087 SUPPORTED_100baseT_Full)) {
8088 DP(NETIF_MSG_LINK,
8089 "100M full not supported\n");
7154 return -EINVAL; 8090 return -EINVAL;
8091 }
7155 8092
7156 advertising = (ADVERTISED_100baseT_Full | 8093 advertising = (ADVERTISED_100baseT_Full |
7157 ADVERTISED_TP); 8094 ADVERTISED_TP);
7158 } else { 8095 } else {
7159 if (!(bp->supported & 8096 if (!(bp->supported &
7160 SUPPORTED_100baseT_Half)) 8097 SUPPORTED_100baseT_Half)) {
8098 DP(NETIF_MSG_LINK,
8099 "100M half not supported\n");
7161 return -EINVAL; 8100 return -EINVAL;
8101 }
7162 8102
7163 advertising = (ADVERTISED_100baseT_Half | 8103 advertising = (ADVERTISED_100baseT_Half |
7164 ADVERTISED_TP); 8104 ADVERTISED_TP);
@@ -7166,39 +8106,54 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
7166 break; 8106 break;
7167 8107
7168 case SPEED_1000: 8108 case SPEED_1000:
7169 if (cmd->duplex != DUPLEX_FULL) 8109 if (cmd->duplex != DUPLEX_FULL) {
8110 DP(NETIF_MSG_LINK, "1G half not supported\n");
7170 return -EINVAL; 8111 return -EINVAL;
8112 }
7171 8113
7172 if (!(bp->supported & SUPPORTED_1000baseT_Full)) 8114 if (!(bp->supported & SUPPORTED_1000baseT_Full)) {
8115 DP(NETIF_MSG_LINK, "1G full not supported\n");
7173 return -EINVAL; 8116 return -EINVAL;
8117 }
7174 8118
7175 advertising = (ADVERTISED_1000baseT_Full | 8119 advertising = (ADVERTISED_1000baseT_Full |
7176 ADVERTISED_TP); 8120 ADVERTISED_TP);
7177 break; 8121 break;
7178 8122
7179 case SPEED_2500: 8123 case SPEED_2500:
7180 if (cmd->duplex != DUPLEX_FULL) 8124 if (cmd->duplex != DUPLEX_FULL) {
8125 DP(NETIF_MSG_LINK,
8126 "2.5G half not supported\n");
7181 return -EINVAL; 8127 return -EINVAL;
8128 }
7182 8129
7183 if (!(bp->supported & SUPPORTED_2500baseT_Full)) 8130 if (!(bp->supported & SUPPORTED_2500baseX_Full)) {
8131 DP(NETIF_MSG_LINK,
8132 "2.5G full not supported\n");
7184 return -EINVAL; 8133 return -EINVAL;
8134 }
7185 8135
7186 advertising = (ADVERTISED_2500baseT_Full | 8136 advertising = (ADVERTISED_2500baseX_Full |
7187 ADVERTISED_TP); 8137 ADVERTISED_TP);
7188 break; 8138 break;
7189 8139
7190 case SPEED_10000: 8140 case SPEED_10000:
7191 if (cmd->duplex != DUPLEX_FULL) 8141 if (cmd->duplex != DUPLEX_FULL) {
8142 DP(NETIF_MSG_LINK, "10G half not supported\n");
7192 return -EINVAL; 8143 return -EINVAL;
8144 }
7193 8145
7194 if (!(bp->supported & SUPPORTED_10000baseT_Full)) 8146 if (!(bp->supported & SUPPORTED_10000baseT_Full)) {
8147 DP(NETIF_MSG_LINK, "10G full not supported\n");
7195 return -EINVAL; 8148 return -EINVAL;
8149 }
7196 8150
7197 advertising = (ADVERTISED_10000baseT_Full | 8151 advertising = (ADVERTISED_10000baseT_Full |
7198 ADVERTISED_FIBRE); 8152 ADVERTISED_FIBRE);
7199 break; 8153 break;
7200 8154
7201 default: 8155 default:
8156 DP(NETIF_MSG_LINK, "Unsupported speed\n");
7202 return -EINVAL; 8157 return -EINVAL;
7203 } 8158 }
7204 8159
@@ -7398,8 +8353,7 @@ static void bnx2x_disable_nvram_access(struct bnx2x *bp)
7398static int bnx2x_nvram_read_dword(struct bnx2x *bp, u32 offset, u32 *ret_val, 8353static int bnx2x_nvram_read_dword(struct bnx2x *bp, u32 offset, u32 *ret_val,
7399 u32 cmd_flags) 8354 u32 cmd_flags)
7400{ 8355{
7401 int rc; 8356 int count, i, rc;
7402 int count, i;
7403 u32 val; 8357 u32 val;
7404 8358
7405 /* build the command word */ 8359 /* build the command word */
@@ -7452,13 +8406,13 @@ static int bnx2x_nvram_read(struct bnx2x *bp, u32 offset, u8 *ret_buf,
7452 8406
7453 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) { 8407 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
7454 DP(NETIF_MSG_NVM, 8408 DP(NETIF_MSG_NVM,
7455 "Invalid paramter: offset 0x%x buf_size 0x%x\n", 8409 "Invalid parameter: offset 0x%x buf_size 0x%x\n",
7456 offset, buf_size); 8410 offset, buf_size);
7457 return -EINVAL; 8411 return -EINVAL;
7458 } 8412 }
7459 8413
7460 if (offset + buf_size > bp->flash_size) { 8414 if (offset + buf_size > bp->flash_size) {
7461 DP(NETIF_MSG_NVM, "Invalid paramter: offset (0x%x) +" 8415 DP(NETIF_MSG_NVM, "Invalid parameter: offset (0x%x) +"
7462 " buf_size (0x%x) > flash_size (0x%x)\n", 8416 " buf_size (0x%x) > flash_size (0x%x)\n",
7463 offset, buf_size, bp->flash_size); 8417 offset, buf_size, bp->flash_size);
7464 return -EINVAL; 8418 return -EINVAL;
@@ -7519,8 +8473,7 @@ static int bnx2x_get_eeprom(struct net_device *dev,
7519static int bnx2x_nvram_write_dword(struct bnx2x *bp, u32 offset, u32 val, 8473static int bnx2x_nvram_write_dword(struct bnx2x *bp, u32 offset, u32 val,
7520 u32 cmd_flags) 8474 u32 cmd_flags)
7521{ 8475{
7522 int rc; 8476 int count, i, rc;
7523 int count, i;
7524 8477
7525 /* build the command word */ 8478 /* build the command word */
7526 cmd_flags |= MCPR_NVM_COMMAND_DOIT | MCPR_NVM_COMMAND_WR; 8479 cmd_flags |= MCPR_NVM_COMMAND_DOIT | MCPR_NVM_COMMAND_WR;
@@ -7557,7 +8510,7 @@ static int bnx2x_nvram_write_dword(struct bnx2x *bp, u32 offset, u32 val,
7557 return rc; 8510 return rc;
7558} 8511}
7559 8512
7560#define BYTE_OFFSET(offset) (8 * (offset & 0x03)) 8513#define BYTE_OFFSET(offset) (8 * (offset & 0x03))
7561 8514
7562static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf, 8515static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf,
7563 int buf_size) 8516 int buf_size)
@@ -7568,7 +8521,7 @@ static int bnx2x_nvram_write1(struct bnx2x *bp, u32 offset, u8 *data_buf,
7568 u32 val; 8521 u32 val;
7569 8522
7570 if (offset + buf_size > bp->flash_size) { 8523 if (offset + buf_size > bp->flash_size) {
7571 DP(NETIF_MSG_NVM, "Invalid paramter: offset (0x%x) +" 8524 DP(NETIF_MSG_NVM, "Invalid parameter: offset (0x%x) +"
7572 " buf_size (0x%x) > flash_size (0x%x)\n", 8525 " buf_size (0x%x) > flash_size (0x%x)\n",
7573 offset, buf_size, bp->flash_size); 8526 offset, buf_size, bp->flash_size);
7574 return -EINVAL; 8527 return -EINVAL;
@@ -7621,13 +8574,13 @@ static int bnx2x_nvram_write(struct bnx2x *bp, u32 offset, u8 *data_buf,
7621 8574
7622 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) { 8575 if ((offset & 0x03) || (buf_size & 0x03) || (buf_size == 0)) {
7623 DP(NETIF_MSG_NVM, 8576 DP(NETIF_MSG_NVM,
7624 "Invalid paramter: offset 0x%x buf_size 0x%x\n", 8577 "Invalid parameter: offset 0x%x buf_size 0x%x\n",
7625 offset, buf_size); 8578 offset, buf_size);
7626 return -EINVAL; 8579 return -EINVAL;
7627 } 8580 }
7628 8581
7629 if (offset + buf_size > bp->flash_size) { 8582 if (offset + buf_size > bp->flash_size) {
7630 DP(NETIF_MSG_NVM, "Invalid paramter: offset (0x%x) +" 8583 DP(NETIF_MSG_NVM, "Invalid parameter: offset (0x%x) +"
7631 " buf_size (0x%x) > flash_size (0x%x)\n", 8584 " buf_size (0x%x) > flash_size (0x%x)\n",
7632 offset, buf_size, bp->flash_size); 8585 offset, buf_size, bp->flash_size);
7633 return -EINVAL; 8586 return -EINVAL;
@@ -7788,52 +8741,29 @@ static int bnx2x_set_pauseparam(struct net_device *dev,
7788 DP_LEVEL " autoneg %d rx_pause %d tx_pause %d\n", 8741 DP_LEVEL " autoneg %d rx_pause %d tx_pause %d\n",
7789 epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause); 8742 epause->cmd, epause->autoneg, epause->rx_pause, epause->tx_pause);
7790 8743
7791 bp->req_flow_ctrl = FLOW_CTRL_AUTO;
7792 if (epause->autoneg) { 8744 if (epause->autoneg) {
7793 bp->req_autoneg |= AUTONEG_FLOW_CTRL; 8745 if (!(bp->supported & SUPPORTED_Autoneg)) {
7794 if (bp->dev->mtu <= 4500) { 8746 DP(NETIF_MSG_LINK, "Aotoneg not supported\n");
7795 bp->pause_mode = PAUSE_BOTH; 8747 return -EINVAL;
7796 bp->advertising |= (ADVERTISED_Pause |
7797 ADVERTISED_Asym_Pause);
7798 } else {
7799 bp->pause_mode = PAUSE_ASYMMETRIC;
7800 bp->advertising |= ADVERTISED_Asym_Pause;
7801 } 8748 }
7802 8749
7803 } else { 8750 bp->req_autoneg |= AUTONEG_FLOW_CTRL;
8751 } else
7804 bp->req_autoneg &= ~AUTONEG_FLOW_CTRL; 8752 bp->req_autoneg &= ~AUTONEG_FLOW_CTRL;
7805 8753
7806 if (epause->rx_pause) 8754 bp->req_flow_ctrl = FLOW_CTRL_AUTO;
7807 bp->req_flow_ctrl |= FLOW_CTRL_RX;
7808 if (epause->tx_pause)
7809 bp->req_flow_ctrl |= FLOW_CTRL_TX;
7810
7811 switch (bp->req_flow_ctrl) {
7812 case FLOW_CTRL_AUTO:
7813 bp->req_flow_ctrl = FLOW_CTRL_NONE;
7814 bp->pause_mode = PAUSE_NONE;
7815 bp->advertising &= ~(ADVERTISED_Pause |
7816 ADVERTISED_Asym_Pause);
7817 break;
7818 8755
7819 case FLOW_CTRL_TX: 8756 if (epause->rx_pause)
7820 bp->pause_mode = PAUSE_ASYMMETRIC; 8757 bp->req_flow_ctrl |= FLOW_CTRL_RX;
7821 bp->advertising |= ADVERTISED_Asym_Pause; 8758 if (epause->tx_pause)
7822 break; 8759 bp->req_flow_ctrl |= FLOW_CTRL_TX;
7823 8760
7824 case FLOW_CTRL_RX: 8761 if (!(bp->req_autoneg & AUTONEG_FLOW_CTRL) &&
7825 case FLOW_CTRL_BOTH: 8762 (bp->req_flow_ctrl == FLOW_CTRL_AUTO))
7826 bp->pause_mode = PAUSE_BOTH; 8763 bp->req_flow_ctrl = FLOW_CTRL_NONE;
7827 bp->advertising |= (ADVERTISED_Pause |
7828 ADVERTISED_Asym_Pause);
7829 break;
7830 }
7831 }
7832 8764
7833 DP(NETIF_MSG_LINK, "req_autoneg 0x%x req_flow_ctrl 0x%x\n" 8765 DP(NETIF_MSG_LINK, "req_autoneg 0x%x req_flow_ctrl 0x%x\n",
7834 DP_LEVEL " pause_mode %d advertising 0x%x\n", 8766 bp->req_autoneg, bp->req_flow_ctrl);
7835 bp->req_autoneg, bp->req_flow_ctrl, bp->pause_mode,
7836 bp->advertising);
7837 8767
7838 bnx2x_stop_stats(bp); 8768 bnx2x_stop_stats(bp);
7839 bnx2x_link_initialize(bp); 8769 bnx2x_link_initialize(bp);
@@ -7906,81 +8836,87 @@ static void bnx2x_self_test(struct net_device *dev,
7906static struct { 8836static struct {
7907 char string[ETH_GSTRING_LEN]; 8837 char string[ETH_GSTRING_LEN];
7908} bnx2x_stats_str_arr[BNX2X_NUM_STATS] = { 8838} bnx2x_stats_str_arr[BNX2X_NUM_STATS] = {
7909 { "rx_bytes"}, /* 0 */ 8839 { "rx_bytes"},
7910 { "rx_error_bytes"}, /* 1 */ 8840 { "rx_error_bytes"},
7911 { "tx_bytes"}, /* 2 */ 8841 { "tx_bytes"},
7912 { "tx_error_bytes"}, /* 3 */ 8842 { "tx_error_bytes"},
7913 { "rx_ucast_packets"}, /* 4 */ 8843 { "rx_ucast_packets"},
7914 { "rx_mcast_packets"}, /* 5 */ 8844 { "rx_mcast_packets"},
7915 { "rx_bcast_packets"}, /* 6 */ 8845 { "rx_bcast_packets"},
7916 { "tx_ucast_packets"}, /* 7 */ 8846 { "tx_ucast_packets"},
7917 { "tx_mcast_packets"}, /* 8 */ 8847 { "tx_mcast_packets"},
7918 { "tx_bcast_packets"}, /* 9 */ 8848 { "tx_bcast_packets"},
7919 { "tx_mac_errors"}, /* 10 */ 8849 { "tx_mac_errors"}, /* 10 */
7920 { "tx_carrier_errors"}, /* 11 */ 8850 { "tx_carrier_errors"},
7921 { "rx_crc_errors"}, /* 12 */ 8851 { "rx_crc_errors"},
7922 { "rx_align_errors"}, /* 13 */ 8852 { "rx_align_errors"},
7923 { "tx_single_collisions"}, /* 14 */ 8853 { "tx_single_collisions"},
7924 { "tx_multi_collisions"}, /* 15 */ 8854 { "tx_multi_collisions"},
7925 { "tx_deferred"}, /* 16 */ 8855 { "tx_deferred"},
7926 { "tx_excess_collisions"}, /* 17 */ 8856 { "tx_excess_collisions"},
7927 { "tx_late_collisions"}, /* 18 */ 8857 { "tx_late_collisions"},
7928 { "tx_total_collisions"}, /* 19 */ 8858 { "tx_total_collisions"},
7929 { "rx_fragments"}, /* 20 */ 8859 { "rx_fragments"}, /* 20 */
7930 { "rx_jabbers"}, /* 21 */ 8860 { "rx_jabbers"},
7931 { "rx_undersize_packets"}, /* 22 */ 8861 { "rx_undersize_packets"},
7932 { "rx_oversize_packets"}, /* 23 */ 8862 { "rx_oversize_packets"},
7933 { "rx_xon_frames"}, /* 24 */ 8863 { "rx_xon_frames"},
7934 { "rx_xoff_frames"}, /* 25 */ 8864 { "rx_xoff_frames"},
7935 { "tx_xon_frames"}, /* 26 */ 8865 { "tx_xon_frames"},
7936 { "tx_xoff_frames"}, /* 27 */ 8866 { "tx_xoff_frames"},
7937 { "rx_mac_ctrl_frames"}, /* 28 */ 8867 { "rx_mac_ctrl_frames"},
7938 { "rx_filtered_packets"}, /* 29 */ 8868 { "rx_filtered_packets"},
7939 { "rx_discards"}, /* 30 */ 8869 { "rx_discards"}, /* 30 */
8870 { "brb_discard"},
8871 { "brb_truncate"},
8872 { "xxoverflow"}
7940}; 8873};
7941 8874
7942#define STATS_OFFSET32(offset_name) \ 8875#define STATS_OFFSET32(offset_name) \
7943 (offsetof(struct bnx2x_eth_stats, offset_name) / 4) 8876 (offsetof(struct bnx2x_eth_stats, offset_name) / 4)
7944 8877
7945static unsigned long bnx2x_stats_offset_arr[BNX2X_NUM_STATS] = { 8878static unsigned long bnx2x_stats_offset_arr[BNX2X_NUM_STATS] = {
7946 STATS_OFFSET32(total_bytes_received_hi), /* 0 */ 8879 STATS_OFFSET32(total_bytes_received_hi),
7947 STATS_OFFSET32(stat_IfHCInBadOctets_hi), /* 1 */ 8880 STATS_OFFSET32(stat_IfHCInBadOctets_hi),
7948 STATS_OFFSET32(total_bytes_transmitted_hi), /* 2 */ 8881 STATS_OFFSET32(total_bytes_transmitted_hi),
7949 STATS_OFFSET32(stat_IfHCOutBadOctets_hi), /* 3 */ 8882 STATS_OFFSET32(stat_IfHCOutBadOctets_hi),
7950 STATS_OFFSET32(total_unicast_packets_received_hi), /* 4 */ 8883 STATS_OFFSET32(total_unicast_packets_received_hi),
7951 STATS_OFFSET32(total_multicast_packets_received_hi), /* 5 */ 8884 STATS_OFFSET32(total_multicast_packets_received_hi),
7952 STATS_OFFSET32(total_broadcast_packets_received_hi), /* 6 */ 8885 STATS_OFFSET32(total_broadcast_packets_received_hi),
7953 STATS_OFFSET32(total_unicast_packets_transmitted_hi), /* 7 */ 8886 STATS_OFFSET32(total_unicast_packets_transmitted_hi),
7954 STATS_OFFSET32(total_multicast_packets_transmitted_hi), /* 8 */ 8887 STATS_OFFSET32(total_multicast_packets_transmitted_hi),
7955 STATS_OFFSET32(total_broadcast_packets_transmitted_hi), /* 9 */ 8888 STATS_OFFSET32(total_broadcast_packets_transmitted_hi),
7956 STATS_OFFSET32(stat_Dot3statsInternalMacTransmitErrors), /* 10 */ 8889 STATS_OFFSET32(stat_Dot3statsInternalMacTransmitErrors), /* 10 */
7957 STATS_OFFSET32(stat_Dot3StatsCarrierSenseErrors), /* 11 */ 8890 STATS_OFFSET32(stat_Dot3StatsCarrierSenseErrors),
7958 STATS_OFFSET32(crc_receive_errors), /* 12 */ 8891 STATS_OFFSET32(crc_receive_errors),
7959 STATS_OFFSET32(alignment_errors), /* 13 */ 8892 STATS_OFFSET32(alignment_errors),
7960 STATS_OFFSET32(single_collision_transmit_frames), /* 14 */ 8893 STATS_OFFSET32(single_collision_transmit_frames),
7961 STATS_OFFSET32(multiple_collision_transmit_frames), /* 15 */ 8894 STATS_OFFSET32(multiple_collision_transmit_frames),
7962 STATS_OFFSET32(stat_Dot3StatsDeferredTransmissions), /* 16 */ 8895 STATS_OFFSET32(stat_Dot3StatsDeferredTransmissions),
7963 STATS_OFFSET32(excessive_collision_frames), /* 17 */ 8896 STATS_OFFSET32(excessive_collision_frames),
7964 STATS_OFFSET32(late_collision_frames), /* 18 */ 8897 STATS_OFFSET32(late_collision_frames),
7965 STATS_OFFSET32(number_of_bugs_found_in_stats_spec), /* 19 */ 8898 STATS_OFFSET32(number_of_bugs_found_in_stats_spec),
7966 STATS_OFFSET32(runt_packets_received), /* 20 */ 8899 STATS_OFFSET32(runt_packets_received), /* 20 */
7967 STATS_OFFSET32(jabber_packets_received), /* 21 */ 8900 STATS_OFFSET32(jabber_packets_received),
7968 STATS_OFFSET32(error_runt_packets_received), /* 22 */ 8901 STATS_OFFSET32(error_runt_packets_received),
7969 STATS_OFFSET32(error_jabber_packets_received), /* 23 */ 8902 STATS_OFFSET32(error_jabber_packets_received),
7970 STATS_OFFSET32(pause_xon_frames_received), /* 24 */ 8903 STATS_OFFSET32(pause_xon_frames_received),
7971 STATS_OFFSET32(pause_xoff_frames_received), /* 25 */ 8904 STATS_OFFSET32(pause_xoff_frames_received),
7972 STATS_OFFSET32(pause_xon_frames_transmitted), /* 26 */ 8905 STATS_OFFSET32(pause_xon_frames_transmitted),
7973 STATS_OFFSET32(pause_xoff_frames_transmitted), /* 27 */ 8906 STATS_OFFSET32(pause_xoff_frames_transmitted),
7974 STATS_OFFSET32(control_frames_received), /* 28 */ 8907 STATS_OFFSET32(control_frames_received),
7975 STATS_OFFSET32(mac_filter_discard), /* 29 */ 8908 STATS_OFFSET32(mac_filter_discard),
7976 STATS_OFFSET32(no_buff_discard), /* 30 */ 8909 STATS_OFFSET32(no_buff_discard), /* 30 */
8910 STATS_OFFSET32(brb_discard),
8911 STATS_OFFSET32(brb_truncate_discard),
8912 STATS_OFFSET32(xxoverflow_discard)
7977}; 8913};
7978 8914
7979static u8 bnx2x_stats_len_arr[BNX2X_NUM_STATS] = { 8915static u8 bnx2x_stats_len_arr[BNX2X_NUM_STATS] = {
7980 8, 0, 8, 0, 8, 8, 8, 8, 8, 8, 8916 8, 0, 8, 0, 8, 8, 8, 8, 8, 8,
7981 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 8917 4, 0, 4, 4, 4, 4, 4, 4, 4, 4,
7982 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8918 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
7983 4, 8919 4, 4, 4, 4
7984}; 8920};
7985 8921
7986static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf) 8922static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
@@ -8138,9 +9074,7 @@ static int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state)
8138 * net_device service functions 9074 * net_device service functions
8139 */ 9075 */
8140 9076
8141/* Called with rtnl_lock from vlan functions and also netif_tx_lock 9077/* called with netif_tx_lock from set_multicast */
8142 * from set_multicast.
8143 */
8144static void bnx2x_set_rx_mode(struct net_device *dev) 9078static void bnx2x_set_rx_mode(struct net_device *dev)
8145{ 9079{
8146 struct bnx2x *bp = netdev_priv(dev); 9080 struct bnx2x *bp = netdev_priv(dev);
@@ -8314,7 +9248,7 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8314 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT); 9248 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT);
8315 tx_bd->general_data |= 1; /* header nbd */ 9249 tx_bd->general_data |= 1; /* header nbd */
8316 9250
8317 /* remeber the first bd of the packet */ 9251 /* remember the first bd of the packet */
8318 tx_buf->first_bd = bd_prod; 9252 tx_buf->first_bd = bd_prod;
8319 9253
8320 DP(NETIF_MSG_TX_QUEUED, 9254 DP(NETIF_MSG_TX_QUEUED,
@@ -8334,7 +9268,7 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8334 9268
8335 /* for now NS flag is not used in Linux */ 9269 /* for now NS flag is not used in Linux */
8336 pbd->global_data = (len | 9270 pbd->global_data = (len |
8337 ((skb->protocol == ETH_P_8021Q) << 9271 ((skb->protocol == ntohs(ETH_P_8021Q)) <<
8338 ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT)); 9272 ETH_TX_PARSE_BD_LLC_SNAP_EN_SHIFT));
8339 pbd->ip_hlen = ip_hdrlen(skb) / 2; 9273 pbd->ip_hlen = ip_hdrlen(skb) / 2;
8340 pbd->total_hlen = cpu_to_le16(len + pbd->ip_hlen); 9274 pbd->total_hlen = cpu_to_le16(len + pbd->ip_hlen);
@@ -8343,7 +9277,7 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8343 9277
8344 tx_bd->bd_flags.as_bitfield |= 9278 tx_bd->bd_flags.as_bitfield |=
8345 ETH_TX_BD_FLAGS_TCP_CSUM; 9279 ETH_TX_BD_FLAGS_TCP_CSUM;
8346 pbd->tcp_flags = htonl(tcp_flag_word(skb)) & 0xFFFF; 9280 pbd->tcp_flags = pbd_tcp_flags(skb);
8347 pbd->total_hlen += cpu_to_le16(tcp_hdrlen(skb) / 2); 9281 pbd->total_hlen += cpu_to_le16(tcp_hdrlen(skb) / 2);
8348 pbd->tcp_pseudo_csum = swab16(th->check); 9282 pbd->tcp_pseudo_csum = swab16(th->check);
8349 9283
@@ -8387,7 +9321,7 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8387 9321
8388 if (skb_shinfo(skb)->gso_size && 9322 if (skb_shinfo(skb)->gso_size &&
8389 (skb->len > (bp->dev->mtu + ETH_HLEN))) { 9323 (skb->len > (bp->dev->mtu + ETH_HLEN))) {
8390 int hlen = 2 * le32_to_cpu(pbd->total_hlen); 9324 int hlen = 2 * le16_to_cpu(pbd->total_hlen);
8391 9325
8392 DP(NETIF_MSG_TX_QUEUED, 9326 DP(NETIF_MSG_TX_QUEUED,
8393 "TSO packet len %d hlen %d total len %d tso size %d\n", 9327 "TSO packet len %d hlen %d total len %d tso size %d\n",
@@ -8427,7 +9361,7 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8427 tx_bd->vlan = cpu_to_le16(pkt_prod); 9361 tx_bd->vlan = cpu_to_le16(pkt_prod);
8428 /* this marks the bd 9362 /* this marks the bd
8429 * as one that has no individual mapping 9363 * as one that has no individual mapping
8430 * the FW ignors this flag in a bd not maked start 9364 * the FW ignores this flag in a bd not marked start
8431 */ 9365 */
8432 tx_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_SW_LSO; 9366 tx_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_SW_LSO;
8433 DP(NETIF_MSG_TX_QUEUED, 9367 DP(NETIF_MSG_TX_QUEUED,
@@ -8504,9 +9438,11 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8504 9438
8505 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %u bd %d\n", nbd, bd_prod); 9439 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %u bd %d\n", nbd, bd_prod);
8506 9440
8507 fp->hw_tx_prods->bds_prod += cpu_to_le16(nbd); 9441 fp->hw_tx_prods->bds_prod =
9442 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd);
8508 mb(); /* FW restriction: must not reorder writing nbd and packets */ 9443 mb(); /* FW restriction: must not reorder writing nbd and packets */
8509 fp->hw_tx_prods->packets_prod += cpu_to_le32(1); 9444 fp->hw_tx_prods->packets_prod =
9445 cpu_to_le32(le32_to_cpu(fp->hw_tx_prods->packets_prod) + 1);
8510 DOORBELL(bp, fp_index, 0); 9446 DOORBELL(bp, fp_index, 0);
8511 9447
8512 mmiowb(); 9448 mmiowb();
@@ -8525,11 +9461,6 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
8525 return NETDEV_TX_OK; 9461 return NETDEV_TX_OK;
8526} 9462}
8527 9463
8528static struct net_device_stats *bnx2x_get_stats(struct net_device *dev)
8529{
8530 return &dev->stats;
8531}
8532
8533/* Called with rtnl_lock */ 9464/* Called with rtnl_lock */
8534static int bnx2x_open(struct net_device *dev) 9465static int bnx2x_open(struct net_device *dev)
8535{ 9466{
@@ -8543,16 +9474,13 @@ static int bnx2x_open(struct net_device *dev)
8543/* Called with rtnl_lock */ 9474/* Called with rtnl_lock */
8544static int bnx2x_close(struct net_device *dev) 9475static int bnx2x_close(struct net_device *dev)
8545{ 9476{
8546 int rc;
8547 struct bnx2x *bp = netdev_priv(dev); 9477 struct bnx2x *bp = netdev_priv(dev);
8548 9478
8549 /* Unload the driver, release IRQs */ 9479 /* Unload the driver, release IRQs */
8550 rc = bnx2x_nic_unload(bp, 1); 9480 bnx2x_nic_unload(bp, 1);
8551 if (rc) { 9481
8552 BNX2X_ERR("bnx2x_nic_unload failed: %d\n", rc); 9482 if (!CHIP_REV_IS_SLOW(bp))
8553 return rc; 9483 bnx2x_set_power_state(bp, PCI_D3hot);
8554 }
8555 bnx2x_set_power_state(bp, PCI_D3hot);
8556 9484
8557 return 0; 9485 return 0;
8558} 9486}
@@ -8584,7 +9512,7 @@ static int bnx2x_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
8584 case SIOCGMIIPHY: 9512 case SIOCGMIIPHY:
8585 data->phy_id = bp->phy_addr; 9513 data->phy_id = bp->phy_addr;
8586 9514
8587 /* fallthru */ 9515 /* fallthrough */
8588 case SIOCGMIIREG: { 9516 case SIOCGMIIREG: {
8589 u32 mii_regval; 9517 u32 mii_regval;
8590 9518
@@ -8633,7 +9561,7 @@ static int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
8633 return -EINVAL; 9561 return -EINVAL;
8634 9562
8635 /* This does not race with packet allocation 9563 /* This does not race with packet allocation
8636 * because the actuall alloc size is 9564 * because the actual alloc size is
8637 * only updated as part of load 9565 * only updated as part of load
8638 */ 9566 */
8639 dev->mtu = new_mtu; 9567 dev->mtu = new_mtu;
@@ -8666,7 +9594,7 @@ static void bnx2x_vlan_rx_register(struct net_device *dev,
8666 9594
8667 bp->vlgrp = vlgrp; 9595 bp->vlgrp = vlgrp;
8668 if (netif_running(dev)) 9596 if (netif_running(dev))
8669 bnx2x_set_rx_mode(dev); 9597 bnx2x_set_client_config(bp);
8670} 9598}
8671#endif 9599#endif
8672 9600
@@ -8695,14 +9623,18 @@ static void bnx2x_reset_task(struct work_struct *work)
8695 if (!netif_running(bp->dev)) 9623 if (!netif_running(bp->dev))
8696 return; 9624 return;
8697 9625
8698 bp->in_reset_task = 1; 9626 rtnl_lock();
8699 9627
8700 bnx2x_netif_stop(bp); 9628 if (bp->state != BNX2X_STATE_OPEN) {
9629 DP(NETIF_MSG_TX_ERR, "state is %x, returning\n", bp->state);
9630 goto reset_task_exit;
9631 }
8701 9632
8702 bnx2x_nic_unload(bp, 0); 9633 bnx2x_nic_unload(bp, 0);
8703 bnx2x_nic_load(bp, 0); 9634 bnx2x_nic_load(bp, 0);
8704 9635
8705 bp->in_reset_task = 0; 9636reset_task_exit:
9637 rtnl_unlock();
8706} 9638}
8707 9639
8708static int __devinit bnx2x_init_board(struct pci_dev *pdev, 9640static int __devinit bnx2x_init_board(struct pci_dev *pdev,
@@ -8783,8 +9715,6 @@ static int __devinit bnx2x_init_board(struct pci_dev *pdev,
8783 9715
8784 spin_lock_init(&bp->phy_lock); 9716 spin_lock_init(&bp->phy_lock);
8785 9717
8786 bp->in_reset_task = 0;
8787
8788 INIT_WORK(&bp->reset_task, bnx2x_reset_task); 9718 INIT_WORK(&bp->reset_task, bnx2x_reset_task);
8789 INIT_WORK(&bp->sp_task, bnx2x_sp_task); 9719 INIT_WORK(&bp->sp_task, bnx2x_sp_task);
8790 9720
@@ -8813,7 +9743,7 @@ static int __devinit bnx2x_init_board(struct pci_dev *pdev,
8813 bnx2x_get_hwinfo(bp); 9743 bnx2x_get_hwinfo(bp);
8814 9744
8815 if (CHIP_REV(bp) == CHIP_REV_FPGA) { 9745 if (CHIP_REV(bp) == CHIP_REV_FPGA) {
8816 printk(KERN_ERR PFX "FPGA detacted. MCP disabled," 9746 printk(KERN_ERR PFX "FPGA detected. MCP disabled,"
8817 " will only init first device\n"); 9747 " will only init first device\n");
8818 onefunc = 1; 9748 onefunc = 1;
8819 nomcp = 1; 9749 nomcp = 1;
@@ -8882,14 +9812,32 @@ err_out:
8882 return rc; 9812 return rc;
8883} 9813}
8884 9814
9815static int __devinit bnx2x_get_pcie_width(struct bnx2x *bp)
9816{
9817 u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);
9818
9819 val = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT;
9820 return val;
9821}
9822
9823/* return value of 1=2.5GHz 2=5GHz */
9824static int __devinit bnx2x_get_pcie_speed(struct bnx2x *bp)
9825{
9826 u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);
9827
9828 val = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
9829 return val;
9830}
9831
8885static int __devinit bnx2x_init_one(struct pci_dev *pdev, 9832static int __devinit bnx2x_init_one(struct pci_dev *pdev,
8886 const struct pci_device_id *ent) 9833 const struct pci_device_id *ent)
8887{ 9834{
8888 static int version_printed; 9835 static int version_printed;
8889 struct net_device *dev = NULL; 9836 struct net_device *dev = NULL;
8890 struct bnx2x *bp; 9837 struct bnx2x *bp;
8891 int rc, i; 9838 int rc;
8892 int port = PCI_FUNC(pdev->devfn); 9839 int port = PCI_FUNC(pdev->devfn);
9840 DECLARE_MAC_BUF(mac);
8893 9841
8894 if (version_printed++ == 0) 9842 if (version_printed++ == 0)
8895 printk(KERN_INFO "%s", version); 9843 printk(KERN_INFO "%s", version);
@@ -8906,6 +9854,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
8906 9854
8907 if (port && onefunc) { 9855 if (port && onefunc) {
8908 printk(KERN_ERR PFX "second function disabled. exiting\n"); 9856 printk(KERN_ERR PFX "second function disabled. exiting\n");
9857 free_netdev(dev);
8909 return 0; 9858 return 0;
8910 } 9859 }
8911 9860
@@ -8918,7 +9867,6 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
8918 dev->hard_start_xmit = bnx2x_start_xmit; 9867 dev->hard_start_xmit = bnx2x_start_xmit;
8919 dev->watchdog_timeo = TX_TIMEOUT; 9868 dev->watchdog_timeo = TX_TIMEOUT;
8920 9869
8921 dev->get_stats = bnx2x_get_stats;
8922 dev->ethtool_ops = &bnx2x_ethtool_ops; 9870 dev->ethtool_ops = &bnx2x_ethtool_ops;
8923 dev->open = bnx2x_open; 9871 dev->open = bnx2x_open;
8924 dev->stop = bnx2x_close; 9872 dev->stop = bnx2x_close;
@@ -8944,7 +9892,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
8944 9892
8945 rc = register_netdev(dev); 9893 rc = register_netdev(dev);
8946 if (rc) { 9894 if (rc) {
8947 printk(KERN_ERR PFX "Cannot register net device\n"); 9895 dev_err(&pdev->dev, "Cannot register net device\n");
8948 if (bp->regview) 9896 if (bp->regview)
8949 iounmap(bp->regview); 9897 iounmap(bp->regview);
8950 if (bp->doorbells) 9898 if (bp->doorbells)
@@ -8959,32 +9907,30 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
8959 pci_set_drvdata(pdev, dev); 9907 pci_set_drvdata(pdev, dev);
8960 9908
8961 bp->name = board_info[ent->driver_data].name; 9909 bp->name = board_info[ent->driver_data].name;
8962 printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz " 9910 printk(KERN_INFO "%s: %s (%c%d) PCI-E x%d %s found at mem %lx,"
8963 "found at mem %lx, IRQ %d, ", 9911 " IRQ %d, ", dev->name, bp->name,
8964 dev->name, bp->name,
8965 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A', 9912 ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
8966 ((CHIP_ID(bp) & 0x0ff0) >> 4), 9913 ((CHIP_ID(bp) & 0x0ff0) >> 4),
8967 ((bp->flags & PCIX_FLAG) ? "-X" : ""), 9914 bnx2x_get_pcie_width(bp),
8968 ((bp->flags & PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), 9915 (bnx2x_get_pcie_speed(bp) == 2) ? "5GHz (Gen2)" : "2.5GHz",
8969 bp->bus_speed_mhz, 9916 dev->base_addr, bp->pdev->irq);
8970 dev->base_addr, 9917 printk(KERN_CONT "node addr %s\n", print_mac(mac, dev->dev_addr));
8971 bp->pdev->irq);
8972
8973 printk("node addr ");
8974 for (i = 0; i < 6; i++)
8975 printk("%2.2x", dev->dev_addr[i]);
8976 printk("\n");
8977
8978 return 0; 9918 return 0;
8979} 9919}
8980 9920
8981static void __devexit bnx2x_remove_one(struct pci_dev *pdev) 9921static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
8982{ 9922{
8983 struct net_device *dev = pci_get_drvdata(pdev); 9923 struct net_device *dev = pci_get_drvdata(pdev);
8984 struct bnx2x *bp = netdev_priv(dev); 9924 struct bnx2x *bp;
9925
9926 if (!dev) {
9927 /* we get here if init_one() fails */
9928 printk(KERN_ERR PFX "BAD net device from bnx2x_init_one\n");
9929 return;
9930 }
9931
9932 bp = netdev_priv(dev);
8985 9933
8986 flush_scheduled_work();
8987 /*tasklet_kill(&bp->sp_task);*/
8988 unregister_netdev(dev); 9934 unregister_netdev(dev);
8989 9935
8990 if (bp->regview) 9936 if (bp->regview)
@@ -9002,34 +9948,43 @@ static void __devexit bnx2x_remove_one(struct pci_dev *pdev)
9002static int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state) 9948static int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state)
9003{ 9949{
9004 struct net_device *dev = pci_get_drvdata(pdev); 9950 struct net_device *dev = pci_get_drvdata(pdev);
9005 struct bnx2x *bp = netdev_priv(dev); 9951 struct bnx2x *bp;
9006 int rc; 9952
9953 if (!dev)
9954 return 0;
9007 9955
9008 if (!netif_running(dev)) 9956 if (!netif_running(dev))
9009 return 0; 9957 return 0;
9010 9958
9011 rc = bnx2x_nic_unload(bp, 0); 9959 bp = netdev_priv(dev);
9012 if (!rc) 9960
9013 return rc; 9961 bnx2x_nic_unload(bp, 0);
9014 9962
9015 netif_device_detach(dev); 9963 netif_device_detach(dev);
9016 pci_save_state(pdev);
9017 9964
9965 pci_save_state(pdev);
9018 bnx2x_set_power_state(bp, pci_choose_state(pdev, state)); 9966 bnx2x_set_power_state(bp, pci_choose_state(pdev, state));
9967
9019 return 0; 9968 return 0;
9020} 9969}
9021 9970
9022static int bnx2x_resume(struct pci_dev *pdev) 9971static int bnx2x_resume(struct pci_dev *pdev)
9023{ 9972{
9024 struct net_device *dev = pci_get_drvdata(pdev); 9973 struct net_device *dev = pci_get_drvdata(pdev);
9025 struct bnx2x *bp = netdev_priv(dev); 9974 struct bnx2x *bp;
9026 int rc; 9975 int rc;
9027 9976
9977 if (!dev) {
9978 printk(KERN_ERR PFX "BAD net device from bnx2x_init_one\n");
9979 return -ENODEV;
9980 }
9981
9028 if (!netif_running(dev)) 9982 if (!netif_running(dev))
9029 return 0; 9983 return 0;
9030 9984
9031 pci_restore_state(pdev); 9985 bp = netdev_priv(dev);
9032 9986
9987 pci_restore_state(pdev);
9033 bnx2x_set_power_state(bp, PCI_D0); 9988 bnx2x_set_power_state(bp, PCI_D0);
9034 netif_device_attach(dev); 9989 netif_device_attach(dev);
9035 9990
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index 4f7ae6f77452..4f0c0d31e7c1 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -1,6 +1,6 @@
1/* bnx2x.h: Broadcom Everest network driver. 1/* bnx2x.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
24#define BNX2X_MSG_STATS 0x20000 /* was: NETIF_MSG_TIMER */ 24#define BNX2X_MSG_STATS 0x20000 /* was: NETIF_MSG_TIMER */
25#define NETIF_MSG_NVM 0x40000 /* was: NETIF_MSG_HW */ 25#define NETIF_MSG_NVM 0x40000 /* was: NETIF_MSG_HW */
26#define NETIF_MSG_DMAE 0x80000 /* was: NETIF_MSG_HW */ 26#define NETIF_MSG_DMAE 0x80000 /* was: NETIF_MSG_HW */
27#define BNX2X_MSG_SP 0x100000 /* was: NETIF_MSG_INTR */
28#define BNX2X_MSG_FP 0x200000 /* was: NETIF_MSG_INTR */
27 29
28#define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */ 30#define DP_LEVEL KERN_NOTICE /* was: KERN_DEBUG */
29 31
@@ -40,6 +42,12 @@
40 __LINE__, bp->dev?(bp->dev->name):"?", ##__args); \ 42 __LINE__, bp->dev?(bp->dev->name):"?", ##__args); \
41 } while (0) 43 } while (0)
42 44
45/* for logging (never masked) */
46#define BNX2X_LOG(__fmt, __args...) do { \
47 printk(KERN_NOTICE "[%s:%d(%s)]" __fmt, __FUNCTION__, \
48 __LINE__, bp->dev?(bp->dev->name):"?", ##__args); \
49 } while (0)
50
43/* before we have a dev->name use dev_info() */ 51/* before we have a dev->name use dev_info() */
44#define BNX2X_DEV_INFO(__fmt, __args...) do { \ 52#define BNX2X_DEV_INFO(__fmt, __args...) do { \
45 if (bp->msglevel & NETIF_MSG_PROBE) \ 53 if (bp->msglevel & NETIF_MSG_PROBE) \
@@ -423,8 +431,6 @@ struct bnx2x_fastpath {
423#define BNX2X_FP_STATE_OPEN 0xa0000 431#define BNX2X_FP_STATE_OPEN 0xa0000
424#define BNX2X_FP_STATE_HALTING 0xb0000 432#define BNX2X_FP_STATE_HALTING 0xb0000
425#define BNX2X_FP_STATE_HALTED 0xc0000 433#define BNX2X_FP_STATE_HALTED 0xc0000
426#define BNX2X_FP_STATE_DELETED 0xd0000
427#define BNX2X_FP_STATE_CLOSE_IRQ 0xe0000
428 434
429 int index; 435 int index;
430 436
@@ -505,7 +511,6 @@ struct bnx2x {
505 struct eth_spe *spq; 511 struct eth_spe *spq;
506 dma_addr_t spq_mapping; 512 dma_addr_t spq_mapping;
507 u16 spq_prod_idx; 513 u16 spq_prod_idx;
508 u16 dsb_sp_prod_idx;
509 struct eth_spe *spq_prod_bd; 514 struct eth_spe *spq_prod_bd;
510 struct eth_spe *spq_last_bd; 515 struct eth_spe *spq_last_bd;
511 u16 *dsb_sp_prod; 516 u16 *dsb_sp_prod;
@@ -517,7 +522,7 @@ struct bnx2x {
517 */ 522 */
518 u8 stat_pending; 523 u8 stat_pending;
519 524
520 /* End of fileds used in the performance code paths */ 525 /* End of fields used in the performance code paths */
521 526
522 int panic; 527 int panic;
523 int msglevel; 528 int msglevel;
@@ -540,8 +545,6 @@ struct bnx2x {
540 spinlock_t phy_lock; 545 spinlock_t phy_lock;
541 546
542 struct work_struct reset_task; 547 struct work_struct reset_task;
543 u16 in_reset_task;
544
545 struct work_struct sp_task; 548 struct work_struct sp_task;
546 549
547 struct timer_list timer; 550 struct timer_list timer;
@@ -555,7 +558,6 @@ struct bnx2x {
555#define CHIP_ID(bp) (((bp)->chip_id) & 0xfffffff0) 558#define CHIP_ID(bp) (((bp)->chip_id) & 0xfffffff0)
556 559
557#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000) 560#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
558#define CHIP_NUM_5710 0x57100000
559 561
560#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000) 562#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000)
561#define CHIP_REV_Ax 0x00000000 563#define CHIP_REV_Ax 0x00000000
@@ -574,7 +576,8 @@ struct bnx2x {
574 u32 fw_mb; 576 u32 fw_mb;
575 577
576 u32 hw_config; 578 u32 hw_config;
577 u32 serdes_config; 579 u32 board;
580 u32 serdes_config;
578 u32 lane_config; 581 u32 lane_config;
579 u32 ext_phy_config; 582 u32 ext_phy_config;
580#define XGXS_EXT_PHY_TYPE(bp) (bp->ext_phy_config & \ 583#define XGXS_EXT_PHY_TYPE(bp) (bp->ext_phy_config & \
@@ -595,11 +598,11 @@ struct bnx2x {
595 u8 tx_lane_swap; 598 u8 tx_lane_swap;
596 599
597 u8 link_up; 600 u8 link_up;
601 u8 phy_link_up;
598 602
599 u32 supported; 603 u32 supported;
600/* link settings - missing defines */ 604/* link settings - missing defines */
601#define SUPPORTED_2500baseT_Full (1 << 15) 605#define SUPPORTED_2500baseT_Full (1 << 15)
602#define SUPPORTED_CX4 (1 << 16)
603 606
604 u32 phy_flags; 607 u32 phy_flags;
605/*#define PHY_SERDES_FLAG 0x1*/ 608/*#define PHY_SERDES_FLAG 0x1*/
@@ -644,16 +647,9 @@ struct bnx2x {
644#define FLOW_CTRL_BOTH PORT_FEATURE_FLOW_CONTROL_BOTH 647#define FLOW_CTRL_BOTH PORT_FEATURE_FLOW_CONTROL_BOTH
645#define FLOW_CTRL_NONE PORT_FEATURE_FLOW_CONTROL_NONE 648#define FLOW_CTRL_NONE PORT_FEATURE_FLOW_CONTROL_NONE
646 649
647 u32 pause_mode;
648#define PAUSE_NONE 0
649#define PAUSE_SYMMETRIC 1
650#define PAUSE_ASYMMETRIC 2
651#define PAUSE_BOTH 3
652
653 u32 advertising; 650 u32 advertising;
654/* link settings - missing defines */ 651/* link settings - missing defines */
655#define ADVERTISED_2500baseT_Full (1 << 15) 652#define ADVERTISED_2500baseT_Full (1 << 15)
656#define ADVERTISED_CX4 (1 << 16)
657 653
658 u32 link_status; 654 u32 link_status;
659 u32 line_speed; 655 u32 line_speed;
@@ -667,6 +663,8 @@ struct bnx2x {
667#define NVRAM_TIMEOUT_COUNT 30000 663#define NVRAM_TIMEOUT_COUNT 30000
668#define NVRAM_PAGE_SIZE 256 664#define NVRAM_PAGE_SIZE 256
669 665
666 u8 wol;
667
670 int rx_ring_size; 668 int rx_ring_size;
671 669
672 u16 tx_quick_cons_trip_int; 670 u16 tx_quick_cons_trip_int;
@@ -718,9 +716,6 @@ struct bnx2x {
718#endif 716#endif
719 717
720 char *name; 718 char *name;
721 u16 bus_speed_mhz;
722 u8 wol;
723 u8 pad;
724 719
725 /* used to synchronize stats collecting */ 720 /* used to synchronize stats collecting */
726 int stats_state; 721 int stats_state;
@@ -856,8 +851,8 @@ struct bnx2x {
856#define MAX_SPQ_PENDING 8 851#define MAX_SPQ_PENDING 8
857 852
858 853
859#define BNX2X_NUM_STATS 31 854#define BNX2X_NUM_STATS 34
860#define BNX2X_NUM_TESTS 2 855#define BNX2X_NUM_TESTS 1
861 856
862 857
863#define DPM_TRIGER_TYPE 0x40 858#define DPM_TRIGER_TYPE 0x40
@@ -867,6 +862,15 @@ struct bnx2x {
867 DPM_TRIGER_TYPE); \ 862 DPM_TRIGER_TYPE); \
868 } while (0) 863 } while (0)
869 864
865/* PCIE link and speed */
866#define PCICFG_LINK_WIDTH 0x1f00000
867#define PCICFG_LINK_WIDTH_SHIFT 20
868#define PCICFG_LINK_SPEED 0xf0000
869#define PCICFG_LINK_SPEED_SHIFT 16
870
871#define BMAC_CONTROL_RX_ENABLE 2
872
873#define pbd_tcp_flags(skb) (ntohl(tcp_flag_word(tcp_hdr(skb)))>>16 & 0xff)
870 874
871/* stuff added to make the code fit 80Col */ 875/* stuff added to make the code fit 80Col */
872 876
@@ -939,13 +943,13 @@ struct bnx2x {
939#define LINK_16GTFD LINK_STATUS_SPEED_AND_DUPLEX_16GTFD 943#define LINK_16GTFD LINK_STATUS_SPEED_AND_DUPLEX_16GTFD
940#define LINK_16GXFD LINK_STATUS_SPEED_AND_DUPLEX_16GXFD 944#define LINK_16GXFD LINK_STATUS_SPEED_AND_DUPLEX_16GXFD
941 945
942#define NIG_STATUS_INTERRUPT_XGXS0_LINK10G \ 946#define NIG_STATUS_XGXS0_LINK10G \
943 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G 947 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK10G
944#define NIG_XGXS0_LINK_STATUS \ 948#define NIG_STATUS_XGXS0_LINK_STATUS \
945 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS 949 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS
946#define NIG_XGXS0_LINK_STATUS_SIZE \ 950#define NIG_STATUS_XGXS0_LINK_STATUS_SIZE \
947 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE 951 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_XGXS0_LINK_STATUS_SIZE
948#define NIG_SERDES0_LINK_STATUS \ 952#define NIG_STATUS_SERDES0_LINK_STATUS \
949 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS 953 NIG_STATUS_INTERRUPT_PORT0_REG_STATUS_SERDES0_LINK_STATUS
950#define NIG_MASK_MI_INT \ 954#define NIG_MASK_MI_INT \
951 NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT 955 NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT
diff --git a/drivers/net/bnx2x_fw_defs.h b/drivers/net/bnx2x_fw_defs.h
index 62a6eb81025a..3b968904ca65 100644
--- a/drivers/net/bnx2x_fw_defs.h
+++ b/drivers/net/bnx2x_fw_defs.h
@@ -1,6 +1,6 @@
1/* bnx2x_fw_defs.h: Broadcom Everest network driver. 1/* bnx2x_fw_defs.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x_hsi.h b/drivers/net/bnx2x_hsi.h
index 6fd959c34d1f..b21075ccb52e 100644
--- a/drivers/net/bnx2x_hsi.h
+++ b/drivers/net/bnx2x_hsi.h
@@ -1,6 +1,6 @@
1/* bnx2x_hsi.h: Broadcom Everest network driver. 1/* bnx2x_hsi.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -8,169 +8,9 @@
8 */ 8 */
9 9
10 10
11#define FUNC_0 0 11#define PORT_0 0
12#define FUNC_1 1 12#define PORT_1 1
13#define FUNC_MAX 2 13#define PORT_MAX 2
14
15
16/* This value (in milliseconds) determines the frequency of the driver
17 * issuing the PULSE message code. The firmware monitors this periodic
18 * pulse to determine when to switch to an OS-absent mode. */
19#define DRV_PULSE_PERIOD_MS 250
20
21/* This value (in milliseconds) determines how long the driver should
22 * wait for an acknowledgement from the firmware before timing out. Once
23 * the firmware has timed out, the driver will assume there is no firmware
24 * running and there won't be any firmware-driver synchronization during a
25 * driver reset. */
26#define FW_ACK_TIME_OUT_MS 5000
27
28#define FW_ACK_POLL_TIME_MS 1
29
30#define FW_ACK_NUM_OF_POLL (FW_ACK_TIME_OUT_MS/FW_ACK_POLL_TIME_MS)
31
32/* LED Blink rate that will achieve ~15.9Hz */
33#define LED_BLINK_RATE_VAL 480
34
35/****************************************************************************
36 * Driver <-> FW Mailbox *
37 ****************************************************************************/
38struct drv_fw_mb {
39 u32 drv_mb_header;
40#define DRV_MSG_CODE_MASK 0xffff0000
41#define DRV_MSG_CODE_LOAD_REQ 0x10000000
42#define DRV_MSG_CODE_LOAD_DONE 0x11000000
43#define DRV_MSG_CODE_UNLOAD_REQ_WOL_EN 0x20000000
44#define DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS 0x20010000
45#define DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP 0x20020000
46#define DRV_MSG_CODE_UNLOAD_DONE 0x21000000
47#define DRV_MSG_CODE_DIAG_ENTER_REQ 0x50000000
48#define DRV_MSG_CODE_DIAG_EXIT_REQ 0x60000000
49#define DRV_MSG_CODE_VALIDATE_KEY 0x70000000
50#define DRV_MSG_CODE_GET_CURR_KEY 0x80000000
51#define DRV_MSG_CODE_GET_UPGRADE_KEY 0x81000000
52#define DRV_MSG_CODE_GET_MANUF_KEY 0x82000000
53#define DRV_MSG_CODE_LOAD_L2B_PRAM 0x90000000
54
55#define DRV_MSG_SEQ_NUMBER_MASK 0x0000ffff
56
57 u32 drv_mb_param;
58
59 u32 fw_mb_header;
60#define FW_MSG_CODE_MASK 0xffff0000
61#define FW_MSG_CODE_DRV_LOAD_COMMON 0x11000000
62#define FW_MSG_CODE_DRV_LOAD_PORT 0x12000000
63#define FW_MSG_CODE_DRV_LOAD_REFUSED 0x13000000
64#define FW_MSG_CODE_DRV_LOAD_DONE 0x14000000
65#define FW_MSG_CODE_DRV_UNLOAD_COMMON 0x21000000
66#define FW_MSG_CODE_DRV_UNLOAD_PORT 0x22000000
67#define FW_MSG_CODE_DRV_UNLOAD_DONE 0x23000000
68#define FW_MSG_CODE_DIAG_ENTER_DONE 0x50000000
69#define FW_MSG_CODE_DIAG_REFUSE 0x51000000
70#define FW_MSG_CODE_VALIDATE_KEY_SUCCESS 0x70000000
71#define FW_MSG_CODE_VALIDATE_KEY_FAILURE 0x71000000
72#define FW_MSG_CODE_GET_KEY_DONE 0x80000000
73#define FW_MSG_CODE_NO_KEY 0x8f000000
74#define FW_MSG_CODE_LIC_INFO_NOT_READY 0x8f800000
75#define FW_MSG_CODE_L2B_PRAM_LOADED 0x90000000
76#define FW_MSG_CODE_L2B_PRAM_T_LOAD_FAILURE 0x91000000
77#define FW_MSG_CODE_L2B_PRAM_C_LOAD_FAILURE 0x92000000
78#define FW_MSG_CODE_L2B_PRAM_X_LOAD_FAILURE 0x93000000
79#define FW_MSG_CODE_L2B_PRAM_U_LOAD_FAILURE 0x94000000
80
81#define FW_MSG_SEQ_NUMBER_MASK 0x0000ffff
82
83 u32 fw_mb_param;
84
85 u32 link_status;
86 /* Driver should update this field on any link change event */
87
88#define LINK_STATUS_LINK_FLAG_MASK 0x00000001
89#define LINK_STATUS_LINK_UP 0x00000001
90#define LINK_STATUS_SPEED_AND_DUPLEX_MASK 0x0000001E
91#define LINK_STATUS_SPEED_AND_DUPLEX_AN_NOT_COMPLETE (0<<1)
92#define LINK_STATUS_SPEED_AND_DUPLEX_10THD (1<<1)
93#define LINK_STATUS_SPEED_AND_DUPLEX_10TFD (2<<1)
94#define LINK_STATUS_SPEED_AND_DUPLEX_100TXHD (3<<1)
95#define LINK_STATUS_SPEED_AND_DUPLEX_100T4 (4<<1)
96#define LINK_STATUS_SPEED_AND_DUPLEX_100TXFD (5<<1)
97#define LINK_STATUS_SPEED_AND_DUPLEX_1000THD (6<<1)
98#define LINK_STATUS_SPEED_AND_DUPLEX_1000TFD (7<<1)
99#define LINK_STATUS_SPEED_AND_DUPLEX_1000XFD (7<<1)
100#define LINK_STATUS_SPEED_AND_DUPLEX_2500THD (8<<1)
101#define LINK_STATUS_SPEED_AND_DUPLEX_2500TFD (9<<1)
102#define LINK_STATUS_SPEED_AND_DUPLEX_2500XFD (9<<1)
103#define LINK_STATUS_SPEED_AND_DUPLEX_10GTFD (10<<1)
104#define LINK_STATUS_SPEED_AND_DUPLEX_10GXFD (10<<1)
105#define LINK_STATUS_SPEED_AND_DUPLEX_12GTFD (11<<1)
106#define LINK_STATUS_SPEED_AND_DUPLEX_12GXFD (11<<1)
107#define LINK_STATUS_SPEED_AND_DUPLEX_12_5GTFD (12<<1)
108#define LINK_STATUS_SPEED_AND_DUPLEX_12_5GXFD (12<<1)
109#define LINK_STATUS_SPEED_AND_DUPLEX_13GTFD (13<<1)
110#define LINK_STATUS_SPEED_AND_DUPLEX_13GXFD (13<<1)
111#define LINK_STATUS_SPEED_AND_DUPLEX_15GTFD (14<<1)
112#define LINK_STATUS_SPEED_AND_DUPLEX_15GXFD (14<<1)
113#define LINK_STATUS_SPEED_AND_DUPLEX_16GTFD (15<<1)
114#define LINK_STATUS_SPEED_AND_DUPLEX_16GXFD (15<<1)
115
116#define LINK_STATUS_AUTO_NEGOTIATE_FLAG_MASK 0x00000020
117#define LINK_STATUS_AUTO_NEGOTIATE_ENABLED 0x00000020
118
119#define LINK_STATUS_AUTO_NEGOTIATE_COMPLETE 0x00000040
120#define LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK 0x00000080
121#define LINK_STATUS_PARALLEL_DETECTION_USED 0x00000080
122
123#define LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE 0x00000200
124#define LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE 0x00000400
125#define LINK_STATUS_LINK_PARTNER_100T4_CAPABLE 0x00000800
126#define LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE 0x00001000
127#define LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE 0x00002000
128#define LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE 0x00004000
129#define LINK_STATUS_LINK_PARTNER_10THD_CAPABLE 0x00008000
130
131#define LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK 0x00010000
132#define LINK_STATUS_TX_FLOW_CONTROL_ENABLED 0x00010000
133
134#define LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK 0x00020000
135#define LINK_STATUS_RX_FLOW_CONTROL_ENABLED 0x00020000
136
137#define LINK_STATUS_LINK_PARTNER_FLOW_CONTROL_MASK 0x000C0000
138#define LINK_STATUS_LINK_PARTNER_NOT_PAUSE_CAPABLE (0<<18)
139#define LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE (1<<18)
140#define LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE (2<<18)
141#define LINK_STATUS_LINK_PARTNER_BOTH_PAUSE (3<<18)
142
143#define LINK_STATUS_SERDES_LINK 0x00100000
144
145#define LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE 0x00200000
146#define LINK_STATUS_LINK_PARTNER_2500XHD_CAPABLE 0x00400000
147#define LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE 0x00800000
148#define LINK_STATUS_LINK_PARTNER_12GXFD_CAPABLE 0x01000000
149#define LINK_STATUS_LINK_PARTNER_12_5GXFD_CAPABLE 0x02000000
150#define LINK_STATUS_LINK_PARTNER_13GXFD_CAPABLE 0x04000000
151#define LINK_STATUS_LINK_PARTNER_15GXFD_CAPABLE 0x08000000
152#define LINK_STATUS_LINK_PARTNER_16GXFD_CAPABLE 0x10000000
153
154 u32 drv_pulse_mb;
155#define DRV_PULSE_SEQ_MASK 0x00007fff
156#define DRV_PULSE_SYSTEM_TIME_MASK 0xffff0000
157 /* The system time is in the format of
158 * (year-2001)*12*32 + month*32 + day. */
159#define DRV_PULSE_ALWAYS_ALIVE 0x00008000
160 /* Indicate to the firmware not to go into the
161 * OS-absent when it is not getting driver pulse.
162 * This is used for debugging as well for PXE(MBA). */
163
164 u32 mcp_pulse_mb;
165#define MCP_PULSE_SEQ_MASK 0x00007fff
166#define MCP_PULSE_ALWAYS_ALIVE 0x00008000
167 /* Indicates to the driver not to assert due to lack
168 * of MCP response */
169#define MCP_EVENT_MASK 0xffff0000
170#define MCP_EVENT_OTHER_DRIVER_RESET_REQ 0x00010000
171
172};
173
174 14
175/**************************************************************************** 15/****************************************************************************
176 * Shared HW configuration * 16 * Shared HW configuration *
@@ -249,7 +89,7 @@ struct shared_hw_cfg { /* NVRAM Offset */
249#define SHARED_HW_CFG_SMBUS_TIMING_100KHZ 0x00000000 89#define SHARED_HW_CFG_SMBUS_TIMING_100KHZ 0x00000000
250#define SHARED_HW_CFG_SMBUS_TIMING_400KHZ 0x00001000 90#define SHARED_HW_CFG_SMBUS_TIMING_400KHZ 0x00001000
251 91
252#define SHARED_HW_CFG_HIDE_FUNC1 0x00002000 92#define SHARED_HW_CFG_HIDE_PORT1 0x00002000
253 93
254 u32 power_dissipated; /* 0x11c */ 94 u32 power_dissipated; /* 0x11c */
255#define SHARED_HW_CFG_POWER_DIS_CMN_MASK 0xff000000 95#define SHARED_HW_CFG_POWER_DIS_CMN_MASK 0xff000000
@@ -290,6 +130,8 @@ struct shared_hw_cfg { /* NVRAM Offset */
290#define SHARED_HW_CFG_BOARD_TYPE_BCM957710T1015G 0x00000006 130#define SHARED_HW_CFG_BOARD_TYPE_BCM957710T1015G 0x00000006
291#define SHARED_HW_CFG_BOARD_TYPE_BCM957710A1020G 0x00000007 131#define SHARED_HW_CFG_BOARD_TYPE_BCM957710A1020G 0x00000007
292#define SHARED_HW_CFG_BOARD_TYPE_BCM957710T1003G 0x00000008 132#define SHARED_HW_CFG_BOARD_TYPE_BCM957710T1003G 0x00000008
133#define SHARED_HW_CFG_BOARD_TYPE_BCM957710A1022G 0x00000009
134#define SHARED_HW_CFG_BOARD_TYPE_BCM957710A1021G 0x0000000a
293 135
294#define SHARED_HW_CFG_BOARD_VER_MASK 0xffff0000 136#define SHARED_HW_CFG_BOARD_VER_MASK 0xffff0000
295#define SHARED_HW_CFG_BOARD_VER_SHIFT 16 137#define SHARED_HW_CFG_BOARD_VER_SHIFT 16
@@ -304,13 +146,12 @@ struct shared_hw_cfg { /* NVRAM Offset */
304 146
305}; 147};
306 148
149
307/**************************************************************************** 150/****************************************************************************
308 * Port HW configuration * 151 * Port HW configuration *
309 ****************************************************************************/ 152 ****************************************************************************/
310struct port_hw_cfg { /* function 0: 0x12c-0x2bb, function 1: 0x2bc-0x44b */ 153struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */
311 154
312 /* Fields below are port specific (in anticipation of dual port
313 devices */
314 u32 pci_id; 155 u32 pci_id;
315#define PORT_HW_CFG_PCI_VENDOR_ID_MASK 0xffff0000 156#define PORT_HW_CFG_PCI_VENDOR_ID_MASK 0xffff0000
316#define PORT_HW_CFG_PCI_DEVICE_ID_MASK 0x0000ffff 157#define PORT_HW_CFG_PCI_DEVICE_ID_MASK 0x0000ffff
@@ -420,6 +261,8 @@ struct port_hw_cfg { /* function 0: 0x12c-0x2bb, function 1: 0x2bc-0x44b */
420#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706 0x00000500 261#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8706 0x00000500
421#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8276 0x00000600 262#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8276 0x00000600
422#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481 0x00000700 263#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8481 0x00000700
264#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101 0x00000800
265#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE 0x0000fd00
423#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN 0x0000ff00 266#define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_NOT_CONN 0x0000ff00
424 267
425#define PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK 0x000000ff 268#define PORT_HW_CFG_XGXS_EXT_PHY_ADDR_MASK 0x000000ff
@@ -462,11 +305,13 @@ struct port_hw_cfg { /* function 0: 0x12c-0x2bb, function 1: 0x2bc-0x44b */
462 305
463}; 306};
464 307
308
465/**************************************************************************** 309/****************************************************************************
466 * Shared Feature configuration * 310 * Shared Feature configuration *
467 ****************************************************************************/ 311 ****************************************************************************/
468struct shared_feat_cfg { /* NVRAM Offset */ 312struct shared_feat_cfg { /* NVRAM Offset */
469 u32 bmc_common; /* 0x450 */ 313
314 u32 config; /* 0x450 */
470#define SHARED_FEATURE_BMC_ECHO_MODE_EN 0x00000001 315#define SHARED_FEATURE_BMC_ECHO_MODE_EN 0x00000001
471 316
472}; 317};
@@ -475,7 +320,8 @@ struct shared_feat_cfg { /* NVRAM Offset */
475/**************************************************************************** 320/****************************************************************************
476 * Port Feature configuration * 321 * Port Feature configuration *
477 ****************************************************************************/ 322 ****************************************************************************/
478struct port_feat_cfg { /* function 0: 0x454-0x4c7, function 1: 0x4c8-0x53b */ 323struct port_feat_cfg { /* port 0: 0x454 port 1: 0x4c8 */
324
479 u32 config; 325 u32 config;
480#define PORT_FEATURE_BAR1_SIZE_MASK 0x0000000f 326#define PORT_FEATURE_BAR1_SIZE_MASK 0x0000000f
481#define PORT_FEATURE_BAR1_SIZE_SHIFT 0 327#define PORT_FEATURE_BAR1_SIZE_SHIFT 0
@@ -609,8 +455,7 @@ struct port_feat_cfg { /* function 0: 0x454-0x4c7, function 1: 0x4c8-0x53b */
609#define PORT_FEATURE_SMBUS_ADDR_MASK 0x000000fe 455#define PORT_FEATURE_SMBUS_ADDR_MASK 0x000000fe
610#define PORT_FEATURE_SMBUS_ADDR_SHIFT 1 456#define PORT_FEATURE_SMBUS_ADDR_SHIFT 1
611 457
612 u32 iscsib_boot_cfg; 458 u32 reserved1;
613#define PORT_FEATURE_ISCSIB_SKIP_TARGET_BOOT 0x00000001
614 459
615 u32 link_config; /* Used as HW defaults for the driver */ 460 u32 link_config; /* Used as HW defaults for the driver */
616#define PORT_FEATURE_CONNECTED_SWITCH_MASK 0x03000000 461#define PORT_FEATURE_CONNECTED_SWITCH_MASK 0x03000000
@@ -657,20 +502,201 @@ struct port_feat_cfg { /* function 0: 0x454-0x4c7, function 1: 0x4c8-0x53b */
657}; 502};
658 503
659 504
505/*****************************************************************************
506 * Device Information *
507 *****************************************************************************/
508struct dev_info { /* size */
509
510 u32 bc_rev; /* 8 bits each: major, minor, build */ /* 4 */
511
512 struct shared_hw_cfg shared_hw_config; /* 40 */
513
514 struct port_hw_cfg port_hw_config[PORT_MAX]; /* 400*2=800 */
515
516 struct shared_feat_cfg shared_feature_config; /* 4 */
517
518 struct port_feat_cfg port_feature_config[PORT_MAX]; /* 116*2=232 */
519
520};
521
522
523#define FUNC_0 0
524#define FUNC_1 1
525#define E1_FUNC_MAX 2
526#define FUNC_MAX E1_FUNC_MAX
527
528
529/* This value (in milliseconds) determines the frequency of the driver
530 * issuing the PULSE message code. The firmware monitors this periodic
531 * pulse to determine when to switch to an OS-absent mode. */
532#define DRV_PULSE_PERIOD_MS 250
533
534/* This value (in milliseconds) determines how long the driver should
535 * wait for an acknowledgement from the firmware before timing out. Once
536 * the firmware has timed out, the driver will assume there is no firmware
537 * running and there won't be any firmware-driver synchronization during a
538 * driver reset. */
539#define FW_ACK_TIME_OUT_MS 5000
540
541#define FW_ACK_POLL_TIME_MS 1
542
543#define FW_ACK_NUM_OF_POLL (FW_ACK_TIME_OUT_MS/FW_ACK_POLL_TIME_MS)
544
545/* LED Blink rate that will achieve ~15.9Hz */
546#define LED_BLINK_RATE_VAL 480
547
660/**************************************************************************** 548/****************************************************************************
661 * Device Information * 549 * Driver <-> FW Mailbox *
662 ****************************************************************************/ 550 ****************************************************************************/
663struct dev_info { /* size */ 551struct drv_port_mb {
552
553 u32 link_status;
554 /* Driver should update this field on any link change event */
555
556#define LINK_STATUS_LINK_FLAG_MASK 0x00000001
557#define LINK_STATUS_LINK_UP 0x00000001
558#define LINK_STATUS_SPEED_AND_DUPLEX_MASK 0x0000001E
559#define LINK_STATUS_SPEED_AND_DUPLEX_AN_NOT_COMPLETE (0<<1)
560#define LINK_STATUS_SPEED_AND_DUPLEX_10THD (1<<1)
561#define LINK_STATUS_SPEED_AND_DUPLEX_10TFD (2<<1)
562#define LINK_STATUS_SPEED_AND_DUPLEX_100TXHD (3<<1)
563#define LINK_STATUS_SPEED_AND_DUPLEX_100T4 (4<<1)
564#define LINK_STATUS_SPEED_AND_DUPLEX_100TXFD (5<<1)
565#define LINK_STATUS_SPEED_AND_DUPLEX_1000THD (6<<1)
566#define LINK_STATUS_SPEED_AND_DUPLEX_1000TFD (7<<1)
567#define LINK_STATUS_SPEED_AND_DUPLEX_1000XFD (7<<1)
568#define LINK_STATUS_SPEED_AND_DUPLEX_2500THD (8<<1)
569#define LINK_STATUS_SPEED_AND_DUPLEX_2500TFD (9<<1)
570#define LINK_STATUS_SPEED_AND_DUPLEX_2500XFD (9<<1)
571#define LINK_STATUS_SPEED_AND_DUPLEX_10GTFD (10<<1)
572#define LINK_STATUS_SPEED_AND_DUPLEX_10GXFD (10<<1)
573#define LINK_STATUS_SPEED_AND_DUPLEX_12GTFD (11<<1)
574#define LINK_STATUS_SPEED_AND_DUPLEX_12GXFD (11<<1)
575#define LINK_STATUS_SPEED_AND_DUPLEX_12_5GTFD (12<<1)
576#define LINK_STATUS_SPEED_AND_DUPLEX_12_5GXFD (12<<1)
577#define LINK_STATUS_SPEED_AND_DUPLEX_13GTFD (13<<1)
578#define LINK_STATUS_SPEED_AND_DUPLEX_13GXFD (13<<1)
579#define LINK_STATUS_SPEED_AND_DUPLEX_15GTFD (14<<1)
580#define LINK_STATUS_SPEED_AND_DUPLEX_15GXFD (14<<1)
581#define LINK_STATUS_SPEED_AND_DUPLEX_16GTFD (15<<1)
582#define LINK_STATUS_SPEED_AND_DUPLEX_16GXFD (15<<1)
583
584#define LINK_STATUS_AUTO_NEGOTIATE_FLAG_MASK 0x00000020
585#define LINK_STATUS_AUTO_NEGOTIATE_ENABLED 0x00000020
586
587#define LINK_STATUS_AUTO_NEGOTIATE_COMPLETE 0x00000040
588#define LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK 0x00000080
589#define LINK_STATUS_PARALLEL_DETECTION_USED 0x00000080
590
591#define LINK_STATUS_LINK_PARTNER_1000TFD_CAPABLE 0x00000200
592#define LINK_STATUS_LINK_PARTNER_1000THD_CAPABLE 0x00000400
593#define LINK_STATUS_LINK_PARTNER_100T4_CAPABLE 0x00000800
594#define LINK_STATUS_LINK_PARTNER_100TXFD_CAPABLE 0x00001000
595#define LINK_STATUS_LINK_PARTNER_100TXHD_CAPABLE 0x00002000
596#define LINK_STATUS_LINK_PARTNER_10TFD_CAPABLE 0x00004000
597#define LINK_STATUS_LINK_PARTNER_10THD_CAPABLE 0x00008000
598
599#define LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK 0x00010000
600#define LINK_STATUS_TX_FLOW_CONTROL_ENABLED 0x00010000
601
602#define LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK 0x00020000
603#define LINK_STATUS_RX_FLOW_CONTROL_ENABLED 0x00020000
604
605#define LINK_STATUS_LINK_PARTNER_FLOW_CONTROL_MASK 0x000C0000
606#define LINK_STATUS_LINK_PARTNER_NOT_PAUSE_CAPABLE (0<<18)
607#define LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE (1<<18)
608#define LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE (2<<18)
609#define LINK_STATUS_LINK_PARTNER_BOTH_PAUSE (3<<18)
610
611#define LINK_STATUS_SERDES_LINK 0x00100000
612
613#define LINK_STATUS_LINK_PARTNER_2500XFD_CAPABLE 0x00200000
614#define LINK_STATUS_LINK_PARTNER_2500XHD_CAPABLE 0x00400000
615#define LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE 0x00800000
616#define LINK_STATUS_LINK_PARTNER_12GXFD_CAPABLE 0x01000000
617#define LINK_STATUS_LINK_PARTNER_12_5GXFD_CAPABLE 0x02000000
618#define LINK_STATUS_LINK_PARTNER_13GXFD_CAPABLE 0x04000000
619#define LINK_STATUS_LINK_PARTNER_15GXFD_CAPABLE 0x08000000
620#define LINK_STATUS_LINK_PARTNER_16GXFD_CAPABLE 0x10000000
664 621
665 u32 bc_rev; /* 8 bits each: major, minor, build */ /* 4 */ 622 u32 reserved[3];
666 623
667 struct shared_hw_cfg shared_hw_config; /* 40 */ 624};
625
626
627struct drv_func_mb {
628
629 u32 drv_mb_header;
630#define DRV_MSG_CODE_MASK 0xffff0000
631#define DRV_MSG_CODE_LOAD_REQ 0x10000000
632#define DRV_MSG_CODE_LOAD_DONE 0x11000000
633#define DRV_MSG_CODE_UNLOAD_REQ_WOL_EN 0x20000000
634#define DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS 0x20010000
635#define DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP 0x20020000
636#define DRV_MSG_CODE_UNLOAD_DONE 0x21000000
637#define DRV_MSG_CODE_DIAG_ENTER_REQ 0x50000000
638#define DRV_MSG_CODE_DIAG_EXIT_REQ 0x60000000
639#define DRV_MSG_CODE_VALIDATE_KEY 0x70000000
640#define DRV_MSG_CODE_GET_CURR_KEY 0x80000000
641#define DRV_MSG_CODE_GET_UPGRADE_KEY 0x81000000
642#define DRV_MSG_CODE_GET_MANUF_KEY 0x82000000
643#define DRV_MSG_CODE_LOAD_L2B_PRAM 0x90000000
644
645#define DRV_MSG_SEQ_NUMBER_MASK 0x0000ffff
646
647 u32 drv_mb_param;
648
649 u32 fw_mb_header;
650#define FW_MSG_CODE_MASK 0xffff0000
651#define FW_MSG_CODE_DRV_LOAD_COMMON 0x10100000
652#define FW_MSG_CODE_DRV_LOAD_PORT 0x10110000
653#define FW_MSG_CODE_DRV_LOAD_FUNCTION 0x10120000
654#define FW_MSG_CODE_DRV_LOAD_REFUSED 0x10200000
655#define FW_MSG_CODE_DRV_LOAD_DONE 0x11100000
656#define FW_MSG_CODE_DRV_UNLOAD_COMMON 0x20100000
657#define FW_MSG_CODE_DRV_UNLOAD_PORT 0x20110000
658#define FW_MSG_CODE_DRV_UNLOAD_FUNCTION 0x20120000
659#define FW_MSG_CODE_DRV_UNLOAD_DONE 0x21100000
660#define FW_MSG_CODE_DIAG_ENTER_DONE 0x50100000
661#define FW_MSG_CODE_DIAG_REFUSE 0x50200000
662#define FW_MSG_CODE_DIAG_EXIT_DONE 0x60100000
663#define FW_MSG_CODE_VALIDATE_KEY_SUCCESS 0x70100000
664#define FW_MSG_CODE_VALIDATE_KEY_FAILURE 0x70200000
665#define FW_MSG_CODE_GET_KEY_DONE 0x80100000
666#define FW_MSG_CODE_NO_KEY 0x80f00000
667#define FW_MSG_CODE_LIC_INFO_NOT_READY 0x80f80000
668#define FW_MSG_CODE_L2B_PRAM_LOADED 0x90100000
669#define FW_MSG_CODE_L2B_PRAM_T_LOAD_FAILURE 0x90210000
670#define FW_MSG_CODE_L2B_PRAM_C_LOAD_FAILURE 0x90220000
671#define FW_MSG_CODE_L2B_PRAM_X_LOAD_FAILURE 0x90230000
672#define FW_MSG_CODE_L2B_PRAM_U_LOAD_FAILURE 0x90240000
673
674#define FW_MSG_SEQ_NUMBER_MASK 0x0000ffff
675
676 u32 fw_mb_param;
677
678 u32 drv_pulse_mb;
679#define DRV_PULSE_SEQ_MASK 0x00007fff
680#define DRV_PULSE_SYSTEM_TIME_MASK 0xffff0000
681 /* The system time is in the format of
682 * (year-2001)*12*32 + month*32 + day. */
683#define DRV_PULSE_ALWAYS_ALIVE 0x00008000
684 /* Indicate to the firmware not to go into the
685 * OS-absent when it is not getting driver pulse.
686 * This is used for debugging as well for PXE(MBA). */
668 687
669 struct port_hw_cfg port_hw_config[FUNC_MAX]; /* 400*2=800 */ 688 u32 mcp_pulse_mb;
689#define MCP_PULSE_SEQ_MASK 0x00007fff
690#define MCP_PULSE_ALWAYS_ALIVE 0x00008000
691 /* Indicates to the driver not to assert due to lack
692 * of MCP response */
693#define MCP_EVENT_MASK 0xffff0000
694#define MCP_EVENT_OTHER_DRIVER_RESET_REQ 0x00010000
670 695
671 struct shared_feat_cfg shared_feature_config; /* 4 */ 696 u32 iscsi_boot_signature;
697 u32 iscsi_boot_block_offset;
672 698
673 struct port_feat_cfg port_feature_config[FUNC_MAX];/* 116*2=232 */ 699 u32 reserved[3];
674 700
675}; 701};
676 702
@@ -678,9 +704,8 @@ struct dev_info { /* size */
678/**************************************************************************** 704/****************************************************************************
679 * Management firmware state * 705 * Management firmware state *
680 ****************************************************************************/ 706 ****************************************************************************/
681/* Allocate 320 bytes for management firmware: still not known exactly 707/* Allocate 440 bytes for management firmware */
682 * how much IMD needs. */ 708#define MGMTFW_STATE_WORD_SIZE 110
683#define MGMTFW_STATE_WORD_SIZE 80
684 709
685struct mgmtfw_state { 710struct mgmtfw_state {
686 u32 opaque[MGMTFW_STATE_WORD_SIZE]; 711 u32 opaque[MGMTFW_STATE_WORD_SIZE];
@@ -691,31 +716,40 @@ struct mgmtfw_state {
691 * Shared Memory Region * 716 * Shared Memory Region *
692 ****************************************************************************/ 717 ****************************************************************************/
693struct shmem_region { /* SharedMem Offset (size) */ 718struct shmem_region { /* SharedMem Offset (size) */
694 u32 validity_map[FUNC_MAX]; /* 0x0 (4 * 2 = 0x8) */ 719
695#define SHR_MEM_VALIDITY_PCI_CFG 0x00000001 720 u32 validity_map[PORT_MAX]; /* 0x0 (4*2 = 0x8) */
696#define SHR_MEM_VALIDITY_MB 0x00000002 721#define SHR_MEM_FORMAT_REV_ID ('A'<<24)
697#define SHR_MEM_VALIDITY_DEV_INFO 0x00000004 722#define SHR_MEM_FORMAT_REV_MASK 0xff000000
723 /* validity bits */
724#define SHR_MEM_VALIDITY_PCI_CFG 0x00100000
725#define SHR_MEM_VALIDITY_MB 0x00200000
726#define SHR_MEM_VALIDITY_DEV_INFO 0x00400000
727#define SHR_MEM_VALIDITY_RESERVED 0x00000007
698 /* One licensing bit should be set */ 728 /* One licensing bit should be set */
699#define SHR_MEM_VALIDITY_LIC_KEY_IN_EFFECT_MASK 0x00000038 729#define SHR_MEM_VALIDITY_LIC_KEY_IN_EFFECT_MASK 0x00000038
700#define SHR_MEM_VALIDITY_LIC_MANUF_KEY_IN_EFFECT 0x00000008 730#define SHR_MEM_VALIDITY_LIC_MANUF_KEY_IN_EFFECT 0x00000008
701#define SHR_MEM_VALIDITY_LIC_UPGRADE_KEY_IN_EFFECT 0x00000010 731#define SHR_MEM_VALIDITY_LIC_UPGRADE_KEY_IN_EFFECT 0x00000010
702#define SHR_MEM_VALIDITY_LIC_NO_KEY_IN_EFFECT 0x00000020 732#define SHR_MEM_VALIDITY_LIC_NO_KEY_IN_EFFECT 0x00000020
733 /* Active MFW */
734#define SHR_MEM_VALIDITY_ACTIVE_MFW_UNKNOWN 0x00000000
735#define SHR_MEM_VALIDITY_ACTIVE_MFW_IPMI 0x00000040
736#define SHR_MEM_VALIDITY_ACTIVE_MFW_UMP 0x00000080
737#define SHR_MEM_VALIDITY_ACTIVE_MFW_NCSI 0x000000c0
738#define SHR_MEM_VALIDITY_ACTIVE_MFW_NONE 0x000001c0
739#define SHR_MEM_VALIDITY_ACTIVE_MFW_MASK 0x000001c0
703 740
704 struct drv_fw_mb drv_fw_mb[FUNC_MAX]; /* 0x8 (28 * 2 = 0x38) */ 741 struct dev_info dev_info; /* 0x8 (0x438) */
705
706 struct dev_info dev_info; /* 0x40 (0x438) */
707 742
708#ifdef _LICENSE_H 743 u8 reserved[52*PORT_MAX];
709 license_key_t drv_lic_key[FUNC_MAX]; /* 0x478 (52 * 2 = 0x68) */
710#else /* Linux! */
711 u8 reserved[52*FUNC_MAX];
712#endif
713 744
714 /* FW information (for internal FW use) */ 745 /* FW information (for internal FW use) */
715 u32 fw_info_fio_offset; /* 0x4e0 (0x4) */ 746 u32 fw_info_fio_offset; /* 0x4a8 (0x4) */
716 struct mgmtfw_state mgmtfw_state; /* 0x4e4 (0x140) */ 747 struct mgmtfw_state mgmtfw_state; /* 0x4ac (0x1b8) */
748
749 struct drv_port_mb port_mb[PORT_MAX]; /* 0x664 (16*2=0x20) */
750 struct drv_func_mb func_mb[FUNC_MAX]; /* 0x684 (44*2=0x58) */
717 751
718}; /* 0x624 */ 752}; /* 0x6dc */
719 753
720 754
721#define BCM_5710_FW_MAJOR_VERSION 4 755#define BCM_5710_FW_MAJOR_VERSION 4
diff --git a/drivers/net/bnx2x_init.h b/drivers/net/bnx2x_init.h
index 04f93bff2ef4..dcaecc53bdb1 100644
--- a/drivers/net/bnx2x_init.h
+++ b/drivers/net/bnx2x_init.h
@@ -1,6 +1,6 @@
1/* bnx2x_init.h: Broadcom Everest network driver. 1/* bnx2x_init.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -409,7 +409,7 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
409 409
410 pci_read_config_word(bp->pdev, 410 pci_read_config_word(bp->pdev,
411 bp->pcie_cap + PCI_EXP_DEVCTL, (u16 *)&val); 411 bp->pcie_cap + PCI_EXP_DEVCTL, (u16 *)&val);
412 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", val); 412 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", (u16)val);
413 w_order = ((val & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 413 w_order = ((val & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
414 r_order = ((val & PCI_EXP_DEVCTL_READRQ) >> 12); 414 r_order = ((val & PCI_EXP_DEVCTL_READRQ) >> 12);
415 415
@@ -472,10 +472,14 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
472 REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val); 472 REG_WR(bp, PXP2_REG_PSWRQ_BW_WR, val);
473 473
474 REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order); 474 REG_WR(bp, PXP2_REG_RQ_WR_MBS0, w_order);
475 REG_WR(bp, PXP2_REG_RQ_WR_MBS0 + 8, w_order); 475 REG_WR(bp, PXP2_REG_RQ_WR_MBS1, w_order);
476 REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order); 476 REG_WR(bp, PXP2_REG_RQ_RD_MBS0, r_order);
477 REG_WR(bp, PXP2_REG_RQ_RD_MBS0 + 8, r_order); 477 REG_WR(bp, PXP2_REG_RQ_RD_MBS1, r_order);
478 478
479 if (r_order == MAX_RD_ORD)
480 REG_WR(bp, PXP2_REG_RQ_PDR_LIMIT, 0xe00);
481
482 REG_WR(bp, PXP2_REG_WR_USDMDP_TH, (0x18 << w_order));
479 REG_WR(bp, PXP2_REG_WR_DMAE_TH, (128 << w_order)/16); 483 REG_WR(bp, PXP2_REG_WR_DMAE_TH, (128 << w_order)/16);
480} 484}
481 485
diff --git a/drivers/net/bnx2x_reg.h b/drivers/net/bnx2x_reg.h
index 86055297ab02..5a1aa0b55044 100644
--- a/drivers/net/bnx2x_reg.h
+++ b/drivers/net/bnx2x_reg.h
@@ -1,6 +1,6 @@
1/* bnx2x_reg.h: Broadcom Everest network driver. 1/* bnx2x_reg.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007 Broadcom Corporation 3 * Copyright (c) 2007-2008 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,8 @@
24#define BRB1_REG_BRB1_INT_STS 0x6011c 24#define BRB1_REG_BRB1_INT_STS 0x6011c
25/* [RW 4] Parity mask register #0 read/write */ 25/* [RW 4] Parity mask register #0 read/write */
26#define BRB1_REG_BRB1_PRTY_MASK 0x60138 26#define BRB1_REG_BRB1_PRTY_MASK 0x60138
27/* [R 4] Parity register #0 read */
28#define BRB1_REG_BRB1_PRTY_STS 0x6012c
27/* [RW 10] At address BRB1_IND_FREE_LIST_PRS_CRDT initialize free head. At 29/* [RW 10] At address BRB1_IND_FREE_LIST_PRS_CRDT initialize free head. At
28 address BRB1_IND_FREE_LIST_PRS_CRDT+1 initialize free tail. At address 30 address BRB1_IND_FREE_LIST_PRS_CRDT+1 initialize free tail. At address
29 BRB1_IND_FREE_LIST_PRS_CRDT+2 initialize parser initial credit. */ 31 BRB1_IND_FREE_LIST_PRS_CRDT+2 initialize parser initial credit. */
@@ -281,6 +283,8 @@
281#define CDU_REG_CDU_INT_STS 0x101030 283#define CDU_REG_CDU_INT_STS 0x101030
282/* [RW 5] Parity mask register #0 read/write */ 284/* [RW 5] Parity mask register #0 read/write */
283#define CDU_REG_CDU_PRTY_MASK 0x10104c 285#define CDU_REG_CDU_PRTY_MASK 0x10104c
286/* [R 5] Parity register #0 read */
287#define CDU_REG_CDU_PRTY_STS 0x101040
284/* [RC 32] logging of error data in case of a CDU load error: 288/* [RC 32] logging of error data in case of a CDU load error:
285 {expected_cid[15:0]; xpected_type[2:0]; xpected_region[2:0]; ctive_error; 289 {expected_cid[15:0]; xpected_type[2:0]; xpected_region[2:0]; ctive_error;
286 ype_error; ctual_active; ctual_compressed_context}; */ 290 ype_error; ctual_active; ctual_compressed_context}; */
@@ -308,6 +312,8 @@
308#define CFC_REG_CFC_INT_STS_CLR 0x104100 312#define CFC_REG_CFC_INT_STS_CLR 0x104100
309/* [RW 4] Parity mask register #0 read/write */ 313/* [RW 4] Parity mask register #0 read/write */
310#define CFC_REG_CFC_PRTY_MASK 0x104118 314#define CFC_REG_CFC_PRTY_MASK 0x104118
315/* [R 4] Parity register #0 read */
316#define CFC_REG_CFC_PRTY_STS 0x10410c
311/* [RW 21] CID cam access (21:1 - Data; alid - 0) */ 317/* [RW 21] CID cam access (21:1 - Data; alid - 0) */
312#define CFC_REG_CID_CAM 0x104800 318#define CFC_REG_CID_CAM 0x104800
313#define CFC_REG_CONTROL0 0x104028 319#define CFC_REG_CONTROL0 0x104028
@@ -354,6 +360,8 @@
354#define CSDM_REG_CSDM_INT_MASK_1 0xc22ac 360#define CSDM_REG_CSDM_INT_MASK_1 0xc22ac
355/* [RW 11] Parity mask register #0 read/write */ 361/* [RW 11] Parity mask register #0 read/write */
356#define CSDM_REG_CSDM_PRTY_MASK 0xc22bc 362#define CSDM_REG_CSDM_PRTY_MASK 0xc22bc
363/* [R 11] Parity register #0 read */
364#define CSDM_REG_CSDM_PRTY_STS 0xc22b0
357#define CSDM_REG_ENABLE_IN1 0xc2238 365#define CSDM_REG_ENABLE_IN1 0xc2238
358#define CSDM_REG_ENABLE_IN2 0xc223c 366#define CSDM_REG_ENABLE_IN2 0xc223c
359#define CSDM_REG_ENABLE_OUT1 0xc2240 367#define CSDM_REG_ENABLE_OUT1 0xc2240
@@ -438,6 +446,9 @@
438/* [RW 32] Parity mask register #0 read/write */ 446/* [RW 32] Parity mask register #0 read/write */
439#define CSEM_REG_CSEM_PRTY_MASK_0 0x200130 447#define CSEM_REG_CSEM_PRTY_MASK_0 0x200130
440#define CSEM_REG_CSEM_PRTY_MASK_1 0x200140 448#define CSEM_REG_CSEM_PRTY_MASK_1 0x200140
449/* [R 32] Parity register #0 read */
450#define CSEM_REG_CSEM_PRTY_STS_0 0x200124
451#define CSEM_REG_CSEM_PRTY_STS_1 0x200134
441#define CSEM_REG_ENABLE_IN 0x2000a4 452#define CSEM_REG_ENABLE_IN 0x2000a4
442#define CSEM_REG_ENABLE_OUT 0x2000a8 453#define CSEM_REG_ENABLE_OUT 0x2000a8
443/* [RW 32] This address space contains all registers and memories that are 454/* [RW 32] This address space contains all registers and memories that are
@@ -526,6 +537,8 @@
526#define CSEM_REG_TS_9_AS 0x20005c 537#define CSEM_REG_TS_9_AS 0x20005c
527/* [RW 1] Parity mask register #0 read/write */ 538/* [RW 1] Parity mask register #0 read/write */
528#define DBG_REG_DBG_PRTY_MASK 0xc0a8 539#define DBG_REG_DBG_PRTY_MASK 0xc0a8
540/* [R 1] Parity register #0 read */
541#define DBG_REG_DBG_PRTY_STS 0xc09c
529/* [RW 2] debug only: These bits indicate the credit for PCI request type 4 542/* [RW 2] debug only: These bits indicate the credit for PCI request type 4
530 interface; MUST be configured AFTER pci_ext_buffer_strt_addr_lsb/msb are 543 interface; MUST be configured AFTER pci_ext_buffer_strt_addr_lsb/msb are
531 configured */ 544 configured */
@@ -543,6 +556,8 @@
543#define DMAE_REG_DMAE_INT_MASK 0x102054 556#define DMAE_REG_DMAE_INT_MASK 0x102054
544/* [RW 4] Parity mask register #0 read/write */ 557/* [RW 4] Parity mask register #0 read/write */
545#define DMAE_REG_DMAE_PRTY_MASK 0x102064 558#define DMAE_REG_DMAE_PRTY_MASK 0x102064
559/* [R 4] Parity register #0 read */
560#define DMAE_REG_DMAE_PRTY_STS 0x102058
546/* [RW 1] Command 0 go. */ 561/* [RW 1] Command 0 go. */
547#define DMAE_REG_GO_C0 0x102080 562#define DMAE_REG_GO_C0 0x102080
548/* [RW 1] Command 1 go. */ 563/* [RW 1] Command 1 go. */
@@ -623,6 +638,8 @@
623#define DORQ_REG_DORQ_INT_STS_CLR 0x170178 638#define DORQ_REG_DORQ_INT_STS_CLR 0x170178
624/* [RW 2] Parity mask register #0 read/write */ 639/* [RW 2] Parity mask register #0 read/write */
625#define DORQ_REG_DORQ_PRTY_MASK 0x170190 640#define DORQ_REG_DORQ_PRTY_MASK 0x170190
641/* [R 2] Parity register #0 read */
642#define DORQ_REG_DORQ_PRTY_STS 0x170184
626/* [RW 8] The address to write the DPM CID to STORM. */ 643/* [RW 8] The address to write the DPM CID to STORM. */
627#define DORQ_REG_DPM_CID_ADDR 0x170044 644#define DORQ_REG_DPM_CID_ADDR 0x170044
628/* [RW 5] The DPM mode CID extraction offset. */ 645/* [RW 5] The DPM mode CID extraction offset. */
@@ -692,6 +709,8 @@
692#define HC_REG_CONFIG_1 0x108004 709#define HC_REG_CONFIG_1 0x108004
693/* [RW 3] Parity mask register #0 read/write */ 710/* [RW 3] Parity mask register #0 read/write */
694#define HC_REG_HC_PRTY_MASK 0x1080a0 711#define HC_REG_HC_PRTY_MASK 0x1080a0
712/* [R 3] Parity register #0 read */
713#define HC_REG_HC_PRTY_STS 0x108094
695/* [RW 17] status block interrupt mask; one in each bit means unmask; zerow 714/* [RW 17] status block interrupt mask; one in each bit means unmask; zerow
696 in each bit means mask; bit 0 - default SB; bit 1 - SB_0; bit 2 - SB_1... 715 in each bit means mask; bit 0 - default SB; bit 1 - SB_0; bit 2 - SB_1...
697 bit 16- SB_15; addr 0 - port 0; addr 1 - port 1 */ 716 bit 16- SB_15; addr 0 - port 0; addr 1 - port 1 */
@@ -1127,6 +1146,7 @@
1127#define MISC_REG_AEU_GENERAL_ATTN_17 0xa044 1146#define MISC_REG_AEU_GENERAL_ATTN_17 0xa044
1128#define MISC_REG_AEU_GENERAL_ATTN_18 0xa048 1147#define MISC_REG_AEU_GENERAL_ATTN_18 0xa048
1129#define MISC_REG_AEU_GENERAL_ATTN_19 0xa04c 1148#define MISC_REG_AEU_GENERAL_ATTN_19 0xa04c
1149#define MISC_REG_AEU_GENERAL_ATTN_10 0xa028
1130#define MISC_REG_AEU_GENERAL_ATTN_11 0xa02c 1150#define MISC_REG_AEU_GENERAL_ATTN_11 0xa02c
1131#define MISC_REG_AEU_GENERAL_ATTN_2 0xa008 1151#define MISC_REG_AEU_GENERAL_ATTN_2 0xa008
1132#define MISC_REG_AEU_GENERAL_ATTN_20 0xa050 1152#define MISC_REG_AEU_GENERAL_ATTN_20 0xa050
@@ -1135,6 +1155,9 @@
1135#define MISC_REG_AEU_GENERAL_ATTN_4 0xa010 1155#define MISC_REG_AEU_GENERAL_ATTN_4 0xa010
1136#define MISC_REG_AEU_GENERAL_ATTN_5 0xa014 1156#define MISC_REG_AEU_GENERAL_ATTN_5 0xa014
1137#define MISC_REG_AEU_GENERAL_ATTN_6 0xa018 1157#define MISC_REG_AEU_GENERAL_ATTN_6 0xa018
1158#define MISC_REG_AEU_GENERAL_ATTN_7 0xa01c
1159#define MISC_REG_AEU_GENERAL_ATTN_8 0xa020
1160#define MISC_REG_AEU_GENERAL_ATTN_9 0xa024
1138/* [RW 32] first 32b for inverting the input for function 0; for each bit: 1161/* [RW 32] first 32b for inverting the input for function 0; for each bit:
1139 0= do not invert; 1= invert; mapped as follows: [0] NIG attention for 1162 0= do not invert; 1= invert; mapped as follows: [0] NIG attention for
1140 function0; [1] NIG attention for function1; [2] GPIO1 mcp; [3] GPIO2 mcp; 1163 function0; [1] NIG attention for function1; [2] GPIO1 mcp; [3] GPIO2 mcp;
@@ -1183,6 +1206,40 @@
1183 starts at 0x0 for the A0 tape-out and increments by one for each 1206 starts at 0x0 for the A0 tape-out and increments by one for each
1184 all-layer tape-out. */ 1207 all-layer tape-out. */
1185#define MISC_REG_CHIP_REV 0xa40c 1208#define MISC_REG_CHIP_REV 0xa40c
1209/* [RW 32] The following driver registers(1..6) represent 6 drivers and 32
1210 clients. Each client can be controlled by one driver only. One in each
1211 bit represent that this driver control the appropriate client (Ex: bit 5
1212 is set means this driver control client number 5). addr1 = set; addr0 =
1213 clear; read from both addresses will give the same result = status. write
1214 to address 1 will set a request to control all the clients that their
1215 appropriate bit (in the write command) is set. if the client is free (the
1216 appropriate bit in all the other drivers is clear) one will be written to
1217 that driver register; if the client isn't free the bit will remain zero.
1218 if the appropriate bit is set (the driver request to gain control on a
1219 client it already controls the ~MISC_REGISTERS_INT_STS.GENERIC_SW
1220 interrupt will be asserted). write to address 0 will set a request to
1221 free all the clients that their appropriate bit (in the write command) is
1222 set. if the appropriate bit is clear (the driver request to free a client
1223 it doesn't controls the ~MISC_REGISTERS_INT_STS.GENERIC_SW interrupt will
1224 be asserted). */
1225#define MISC_REG_DRIVER_CONTROL_1 0xa510
1226/* [RW 32] GPIO. [31-28] FLOAT port 0; [27-24] FLOAT port 0; When any of
1227 these bits is written as a '1'; the corresponding SPIO bit will turn off
1228 it's drivers and become an input. This is the reset state of all GPIO
1229 pins. The read value of these bits will be a '1' if that last command
1230 (#SET; #CLR; or #FLOAT) for this bit was a #FLOAT. (reset value 0xff).
1231 [23-20] CLR port 1; 19-16] CLR port 0; When any of these bits is written
1232 as a '1'; the corresponding GPIO bit will drive low. The read value of
1233 these bits will be a '1' if that last command (#SET; #CLR; or #FLOAT) for
1234 this bit was a #CLR. (reset value 0). [15-12] SET port 1; 11-8] port 0;
1235 SET When any of these bits is written as a '1'; the corresponding GPIO
1236 bit will drive high (if it has that capability). The read value of these
1237 bits will be a '1' if that last command (#SET; #CLR; or #FLOAT) for this
1238 bit was a #SET. (reset value 0). [7-4] VALUE port 1; [3-0] VALUE port 0;
1239 RO; These bits indicate the read value of each of the eight GPIO pins.
1240 This is the result value of the pin; not the drive value. Writing these
1241 bits will have not effect. */
1242#define MISC_REG_GPIO 0xa490
1186/* [RW 1] Setting this bit enables a timer in the GRC block to timeout any 1243/* [RW 1] Setting this bit enables a timer in the GRC block to timeout any
1187 access that does not finish within 1244 access that does not finish within
1188 ~misc_registers_grc_timout_val.grc_timeout_val cycles. When this bit is 1245 ~misc_registers_grc_timout_val.grc_timeout_val cycles. When this bit is
@@ -1223,6 +1280,8 @@
1223#define MISC_REG_MISC_INT_MASK 0xa388 1280#define MISC_REG_MISC_INT_MASK 0xa388
1224/* [RW 1] Parity mask register #0 read/write */ 1281/* [RW 1] Parity mask register #0 read/write */
1225#define MISC_REG_MISC_PRTY_MASK 0xa398 1282#define MISC_REG_MISC_PRTY_MASK 0xa398
1283/* [R 1] Parity register #0 read */
1284#define MISC_REG_MISC_PRTY_STS 0xa38c
1226/* [RW 32] 32 LSB of storm PLL first register; reset val = 0x 071d2911. 1285/* [RW 32] 32 LSB of storm PLL first register; reset val = 0x 071d2911.
1227 inside order of the bits is: [0] P1 divider[0] (reset value 1); [1] P1 1286 inside order of the bits is: [0] P1 divider[0] (reset value 1); [1] P1
1228 divider[1] (reset value 0); [2] P1 divider[2] (reset value 0); [3] P1 1287 divider[1] (reset value 0); [2] P1 divider[2] (reset value 0); [3] P1
@@ -1264,6 +1323,55 @@
1264/* [RW 20] 20 bit GRC address where the scratch-pad of the MCP that is 1323/* [RW 20] 20 bit GRC address where the scratch-pad of the MCP that is
1265 shared with the driver resides */ 1324 shared with the driver resides */
1266#define MISC_REG_SHARED_MEM_ADDR 0xa2b4 1325#define MISC_REG_SHARED_MEM_ADDR 0xa2b4
1326/* [RW 32] SPIO. [31-24] FLOAT When any of these bits is written as a '1';
1327 the corresponding SPIO bit will turn off it's drivers and become an
1328 input. This is the reset state of all SPIO pins. The read value of these
1329 bits will be a '1' if that last command (#SET; #CL; or #FLOAT) for this
1330 bit was a #FLOAT. (reset value 0xff). [23-16] CLR When any of these bits
1331 is written as a '1'; the corresponding SPIO bit will drive low. The read
1332 value of these bits will be a '1' if that last command (#SET; #CLR; or
1333#FLOAT) for this bit was a #CLR. (reset value 0). [15-8] SET When any of
1334 these bits is written as a '1'; the corresponding SPIO bit will drive
1335 high (if it has that capability). The read value of these bits will be a
1336 '1' if that last command (#SET; #CLR; or #FLOAT) for this bit was a #SET.
1337 (reset value 0). [7-0] VALUE RO; These bits indicate the read value of
1338 each of the eight SPIO pins. This is the result value of the pin; not the
1339 drive value. Writing these bits will have not effect. Each 8 bits field
1340 is divided as follows: [0] VAUX Enable; when pulsed low; enables supply
1341 from VAUX. (This is an output pin only; the FLOAT field is not applicable
1342 for this pin); [1] VAUX Disable; when pulsed low; disables supply form
1343 VAUX. (This is an output pin only; FLOAT field is not applicable for this
1344 pin); [2] SEL_VAUX_B - Control to power switching logic. Drive low to
1345 select VAUX supply. (This is an output pin only; it is not controlled by
1346 the SET and CLR fields; it is controlled by the Main Power SM; the FLOAT
1347 field is not applicable for this pin; only the VALUE fields is relevant -
1348 it reflects the output value); [3] reserved; [4] spio_4; [5] spio_5; [6]
1349 Bit 0 of UMP device ID select; read by UMP firmware; [7] Bit 1 of UMP
1350 device ID select; read by UMP firmware. */
1351#define MISC_REG_SPIO 0xa4fc
1352/* [RW 8] These bits enable the SPIO_INTs to signals event to the IGU/MC.
1353 according to the following map: [3:0] reserved; [4] spio_4 [5] spio_5;
1354 [7:0] reserved */
1355#define MISC_REG_SPIO_EVENT_EN 0xa2b8
1356/* [RW 32] SPIO INT. [31-24] OLD_CLR Writing a '1' to these bit clears the
1357 corresponding bit in the #OLD_VALUE register. This will acknowledge an
1358 interrupt on the falling edge of corresponding SPIO input (reset value
1359 0). [23-16] OLD_SET Writing a '1' to these bit sets the corresponding bit
1360 in the #OLD_VALUE register. This will acknowledge an interrupt on the
1361 rising edge of corresponding SPIO input (reset value 0). [15-8] OLD_VALUE
1362 RO; These bits indicate the old value of the SPIO input value. When the
1363 ~INT_STATE bit is set; this bit indicates the OLD value of the pin such
1364 that if ~INT_STATE is set and this bit is '0'; then the interrupt is due
1365 to a low to high edge. If ~INT_STATE is set and this bit is '1'; then the
1366 interrupt is due to a high to low edge (reset value 0). [7-0] INT_STATE
1367 RO; These bits indicate the current SPIO interrupt state for each SPIO
1368 pin. This bit is cleared when the appropriate #OLD_SET or #OLD_CLR
1369 command bit is written. This bit is set when the SPIO input does not
1370 match the current value in #OLD_VALUE (reset value 0). */
1371#define MISC_REG_SPIO_INT 0xa500
1372/* [RW 1] Set by the MCP to remember if one or more of the drivers is/are
1373 loaded; 0-prepare; -unprepare */
1374#define MISC_REG_UNPREPARED 0xa424
1267#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT (0x1<<0) 1375#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_EMAC0_MISC_MI_INT (0x1<<0)
1268#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS (0x1<<9) 1376#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_SERDES0_LINK_STATUS (0x1<<9)
1269#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G (0x1<<15) 1377#define NIG_MASK_INTERRUPT_PORT0_REG_MASK_XGXS0_LINK10G (0x1<<15)
@@ -1392,6 +1500,9 @@
1392#define NIG_REG_NIG_INGRESS_EMAC0_NO_CRC 0x10044 1500#define NIG_REG_NIG_INGRESS_EMAC0_NO_CRC 0x10044
1393/* [RW 1] Input enable for RX PBF LP IF */ 1501/* [RW 1] Input enable for RX PBF LP IF */
1394#define NIG_REG_PBF_LB_IN_EN 0x100b4 1502#define NIG_REG_PBF_LB_IN_EN 0x100b4
1503/* [RW 1] Value of this register will be transmitted to port swap when
1504 ~nig_registers_strap_override.strap_override =1 */
1505#define NIG_REG_PORT_SWAP 0x10394
1395/* [RW 1] output enable for RX parser descriptor IF */ 1506/* [RW 1] output enable for RX parser descriptor IF */
1396#define NIG_REG_PRS_EOP_OUT_EN 0x10104 1507#define NIG_REG_PRS_EOP_OUT_EN 0x10104
1397/* [RW 1] Input enable for RX parser request IF */ 1508/* [RW 1] Input enable for RX parser request IF */
@@ -1410,6 +1521,10 @@
1410#define NIG_REG_STAT2_BRB_OCTET 0x107e0 1521#define NIG_REG_STAT2_BRB_OCTET 0x107e0
1411#define NIG_REG_STATUS_INTERRUPT_PORT0 0x10328 1522#define NIG_REG_STATUS_INTERRUPT_PORT0 0x10328
1412#define NIG_REG_STATUS_INTERRUPT_PORT1 0x1032c 1523#define NIG_REG_STATUS_INTERRUPT_PORT1 0x1032c
1524/* [RW 1] port swap mux selection. If this register equal to 0 then port
1525 swap is equal to SPIO pin that inputs from ifmux_serdes_swap. If 1 then
1526 ort swap is equal to ~nig_registers_port_swap.port_swap */
1527#define NIG_REG_STRAP_OVERRIDE 0x10398
1413/* [RW 1] output enable for RX_XCM0 IF */ 1528/* [RW 1] output enable for RX_XCM0 IF */
1414#define NIG_REG_XCM0_OUT_EN 0x100f0 1529#define NIG_REG_XCM0_OUT_EN 0x100f0
1415/* [RW 1] output enable for RX_XCM1 IF */ 1530/* [RW 1] output enable for RX_XCM1 IF */
@@ -1499,6 +1614,8 @@
1499#define PB_REG_PB_INT_STS 0x1c 1614#define PB_REG_PB_INT_STS 0x1c
1500/* [RW 4] Parity mask register #0 read/write */ 1615/* [RW 4] Parity mask register #0 read/write */
1501#define PB_REG_PB_PRTY_MASK 0x38 1616#define PB_REG_PB_PRTY_MASK 0x38
1617/* [R 4] Parity register #0 read */
1618#define PB_REG_PB_PRTY_STS 0x2c
1502#define PRS_REG_A_PRSU_20 0x40134 1619#define PRS_REG_A_PRSU_20 0x40134
1503/* [R 8] debug only: CFC load request current credit. Transaction based. */ 1620/* [R 8] debug only: CFC load request current credit. Transaction based. */
1504#define PRS_REG_CFC_LD_CURRENT_CREDIT 0x40164 1621#define PRS_REG_CFC_LD_CURRENT_CREDIT 0x40164
@@ -1590,6 +1707,8 @@
1590#define PRS_REG_PRS_INT_STS 0x40188 1707#define PRS_REG_PRS_INT_STS 0x40188
1591/* [RW 8] Parity mask register #0 read/write */ 1708/* [RW 8] Parity mask register #0 read/write */
1592#define PRS_REG_PRS_PRTY_MASK 0x401a4 1709#define PRS_REG_PRS_PRTY_MASK 0x401a4
1710/* [R 8] Parity register #0 read */
1711#define PRS_REG_PRS_PRTY_STS 0x40198
1593/* [RW 8] Context region for pure acknowledge packets. Used in CFC load 1712/* [RW 8] Context region for pure acknowledge packets. Used in CFC load
1594 request message */ 1713 request message */
1595#define PRS_REG_PURE_REGIONS 0x40024 1714#define PRS_REG_PURE_REGIONS 0x40024
@@ -1718,6 +1837,9 @@
1718/* [RW 32] Parity mask register #0 read/write */ 1837/* [RW 32] Parity mask register #0 read/write */
1719#define PXP2_REG_PXP2_PRTY_MASK_0 0x120588 1838#define PXP2_REG_PXP2_PRTY_MASK_0 0x120588
1720#define PXP2_REG_PXP2_PRTY_MASK_1 0x120598 1839#define PXP2_REG_PXP2_PRTY_MASK_1 0x120598
1840/* [R 32] Parity register #0 read */
1841#define PXP2_REG_PXP2_PRTY_STS_0 0x12057c
1842#define PXP2_REG_PXP2_PRTY_STS_1 0x12058c
1721/* [R 1] Debug only: The 'almost full' indication from each fifo (gives 1843/* [R 1] Debug only: The 'almost full' indication from each fifo (gives
1722 indication about backpressure) */ 1844 indication about backpressure) */
1723#define PXP2_REG_RD_ALMOST_FULL_0 0x120424 1845#define PXP2_REG_RD_ALMOST_FULL_0 0x120424
@@ -1911,6 +2033,8 @@
1911#define PXP2_REG_RQ_HC_ENDIAN_M 0x1201a8 2033#define PXP2_REG_RQ_HC_ENDIAN_M 0x1201a8
1912/* [WB 53] Onchip address table */ 2034/* [WB 53] Onchip address table */
1913#define PXP2_REG_RQ_ONCHIP_AT 0x122000 2035#define PXP2_REG_RQ_ONCHIP_AT 0x122000
2036/* [RW 13] Pending read limiter threshold; in Dwords */
2037#define PXP2_REG_RQ_PDR_LIMIT 0x12033c
1914/* [RW 2] Endian mode for qm */ 2038/* [RW 2] Endian mode for qm */
1915#define PXP2_REG_RQ_QM_ENDIAN_M 0x120194 2039#define PXP2_REG_RQ_QM_ENDIAN_M 0x120194
1916/* [RW 3] page size in L2P table for QM module; -4k; -8k; -16k; -32k; -64k; 2040/* [RW 3] page size in L2P table for QM module; -4k; -8k; -16k; -32k; -64k;
@@ -1921,6 +2045,9 @@
1921/* [RW 3] Max burst size filed for read requests port 0; 000 - 128B; 2045/* [RW 3] Max burst size filed for read requests port 0; 000 - 128B;
1922 001:256B; 010: 512B; 11:1K:100:2K; 01:4K */ 2046 001:256B; 010: 512B; 11:1K:100:2K; 01:4K */
1923#define PXP2_REG_RQ_RD_MBS0 0x120160 2047#define PXP2_REG_RQ_RD_MBS0 0x120160
2048/* [RW 3] Max burst size filed for read requests port 1; 000 - 128B;
2049 001:256B; 010: 512B; 11:1K:100:2K; 01:4K */
2050#define PXP2_REG_RQ_RD_MBS1 0x120168
1924/* [RW 2] Endian mode for src */ 2051/* [RW 2] Endian mode for src */
1925#define PXP2_REG_RQ_SRC_ENDIAN_M 0x12019c 2052#define PXP2_REG_RQ_SRC_ENDIAN_M 0x12019c
1926/* [RW 3] page size in L2P table for SRC module; -4k; -8k; -16k; -32k; -64k; 2053/* [RW 3] page size in L2P table for SRC module; -4k; -8k; -16k; -32k; -64k;
@@ -2000,10 +2127,17 @@
2000/* [RW 3] Max burst size filed for write requests port 0; 000 - 128B; 2127/* [RW 3] Max burst size filed for write requests port 0; 000 - 128B;
2001 001:256B; 010: 512B; */ 2128 001:256B; 010: 512B; */
2002#define PXP2_REG_RQ_WR_MBS0 0x12015c 2129#define PXP2_REG_RQ_WR_MBS0 0x12015c
2130/* [RW 3] Max burst size filed for write requests port 1; 000 - 128B;
2131 001:256B; 010: 512B; */
2132#define PXP2_REG_RQ_WR_MBS1 0x120164
2003/* [RW 10] if Number of entries in dmae fifo will be higer than this 2133/* [RW 10] if Number of entries in dmae fifo will be higer than this
2004 threshold then has_payload indication will be asserted; the default value 2134 threshold then has_payload indication will be asserted; the default value
2005 should be equal to &gt; write MBS size! */ 2135 should be equal to &gt; write MBS size! */
2006#define PXP2_REG_WR_DMAE_TH 0x120368 2136#define PXP2_REG_WR_DMAE_TH 0x120368
2137/* [RW 10] if Number of entries in usdmdp fifo will be higer than this
2138 threshold then has_payload indication will be asserted; the default value
2139 should be equal to &gt; write MBS size! */
2140#define PXP2_REG_WR_USDMDP_TH 0x120348
2007/* [R 1] debug only: Indication if PSWHST arbiter is idle */ 2141/* [R 1] debug only: Indication if PSWHST arbiter is idle */
2008#define PXP_REG_HST_ARB_IS_IDLE 0x103004 2142#define PXP_REG_HST_ARB_IS_IDLE 0x103004
2009/* [R 8] debug only: A bit mask for all PSWHST arbiter clients. '1' means 2143/* [R 8] debug only: A bit mask for all PSWHST arbiter clients. '1' means
@@ -2021,6 +2155,8 @@
2021#define PXP_REG_PXP_INT_STS_CLR_0 0x10306c 2155#define PXP_REG_PXP_INT_STS_CLR_0 0x10306c
2022/* [RW 26] Parity mask register #0 read/write */ 2156/* [RW 26] Parity mask register #0 read/write */
2023#define PXP_REG_PXP_PRTY_MASK 0x103094 2157#define PXP_REG_PXP_PRTY_MASK 0x103094
2158/* [R 26] Parity register #0 read */
2159#define PXP_REG_PXP_PRTY_STS 0x103088
2024/* [RW 4] The activity counter initial increment value sent in the load 2160/* [RW 4] The activity counter initial increment value sent in the load
2025 request */ 2161 request */
2026#define QM_REG_ACTCTRINITVAL_0 0x168040 2162#define QM_REG_ACTCTRINITVAL_0 0x168040
@@ -2127,6 +2263,8 @@
2127#define QM_REG_QM_INT_STS 0x168438 2263#define QM_REG_QM_INT_STS 0x168438
2128/* [RW 9] Parity mask register #0 read/write */ 2264/* [RW 9] Parity mask register #0 read/write */
2129#define QM_REG_QM_PRTY_MASK 0x168454 2265#define QM_REG_QM_PRTY_MASK 0x168454
2266/* [R 9] Parity register #0 read */
2267#define QM_REG_QM_PRTY_STS 0x168448
2130/* [R 32] Current queues in pipeline: Queues from 32 to 63 */ 2268/* [R 32] Current queues in pipeline: Queues from 32 to 63 */
2131#define QM_REG_QSTATUS_HIGH 0x16802c 2269#define QM_REG_QSTATUS_HIGH 0x16802c
2132/* [R 32] Current queues in pipeline: Queues from 0 to 31 */ 2270/* [R 32] Current queues in pipeline: Queues from 0 to 31 */
@@ -2410,6 +2548,8 @@
2410#define SRC_REG_SRC_INT_STS 0x404ac 2548#define SRC_REG_SRC_INT_STS 0x404ac
2411/* [RW 3] Parity mask register #0 read/write */ 2549/* [RW 3] Parity mask register #0 read/write */
2412#define SRC_REG_SRC_PRTY_MASK 0x404c8 2550#define SRC_REG_SRC_PRTY_MASK 0x404c8
2551/* [R 3] Parity register #0 read */
2552#define SRC_REG_SRC_PRTY_STS 0x404bc
2413/* [R 4] Used to read the value of the XX protection CAM occupancy counter. */ 2553/* [R 4] Used to read the value of the XX protection CAM occupancy counter. */
2414#define TCM_REG_CAM_OCCUP 0x5017c 2554#define TCM_REG_CAM_OCCUP 0x5017c
2415/* [RW 1] CDU AG read Interface enable. If 0 - the request input is 2555/* [RW 1] CDU AG read Interface enable. If 0 - the request input is
@@ -2730,6 +2870,8 @@
2730#define TSDM_REG_TSDM_INT_MASK_1 0x422ac 2870#define TSDM_REG_TSDM_INT_MASK_1 0x422ac
2731/* [RW 11] Parity mask register #0 read/write */ 2871/* [RW 11] Parity mask register #0 read/write */
2732#define TSDM_REG_TSDM_PRTY_MASK 0x422bc 2872#define TSDM_REG_TSDM_PRTY_MASK 0x422bc
2873/* [R 11] Parity register #0 read */
2874#define TSDM_REG_TSDM_PRTY_STS 0x422b0
2733/* [RW 5] The number of time_slots in the arbitration cycle */ 2875/* [RW 5] The number of time_slots in the arbitration cycle */
2734#define TSEM_REG_ARB_CYCLE_SIZE 0x180034 2876#define TSEM_REG_ARB_CYCLE_SIZE 0x180034
2735/* [RW 3] The source that is associated with arbitration element 0. Source 2877/* [RW 3] The source that is associated with arbitration element 0. Source
@@ -2854,6 +2996,9 @@
2854/* [RW 32] Parity mask register #0 read/write */ 2996/* [RW 32] Parity mask register #0 read/write */
2855#define TSEM_REG_TSEM_PRTY_MASK_0 0x180120 2997#define TSEM_REG_TSEM_PRTY_MASK_0 0x180120
2856#define TSEM_REG_TSEM_PRTY_MASK_1 0x180130 2998#define TSEM_REG_TSEM_PRTY_MASK_1 0x180130
2999/* [R 32] Parity register #0 read */
3000#define TSEM_REG_TSEM_PRTY_STS_0 0x180114
3001#define TSEM_REG_TSEM_PRTY_STS_1 0x180124
2857/* [R 5] Used to read the XX protection CAM occupancy counter. */ 3002/* [R 5] Used to read the XX protection CAM occupancy counter. */
2858#define UCM_REG_CAM_OCCUP 0xe0170 3003#define UCM_REG_CAM_OCCUP 0xe0170
2859/* [RW 1] CDU AG read Interface enable. If 0 - the request input is 3004/* [RW 1] CDU AG read Interface enable. If 0 - the request input is
@@ -3155,6 +3300,8 @@
3155#define USDM_REG_USDM_INT_MASK_1 0xc42b0 3300#define USDM_REG_USDM_INT_MASK_1 0xc42b0
3156/* [RW 11] Parity mask register #0 read/write */ 3301/* [RW 11] Parity mask register #0 read/write */
3157#define USDM_REG_USDM_PRTY_MASK 0xc42c0 3302#define USDM_REG_USDM_PRTY_MASK 0xc42c0
3303/* [R 11] Parity register #0 read */
3304#define USDM_REG_USDM_PRTY_STS 0xc42b4
3158/* [RW 5] The number of time_slots in the arbitration cycle */ 3305/* [RW 5] The number of time_slots in the arbitration cycle */
3159#define USEM_REG_ARB_CYCLE_SIZE 0x300034 3306#define USEM_REG_ARB_CYCLE_SIZE 0x300034
3160/* [RW 3] The source that is associated with arbitration element 0. Source 3307/* [RW 3] The source that is associated with arbitration element 0. Source
@@ -3279,6 +3426,9 @@
3279/* [RW 32] Parity mask register #0 read/write */ 3426/* [RW 32] Parity mask register #0 read/write */
3280#define USEM_REG_USEM_PRTY_MASK_0 0x300130 3427#define USEM_REG_USEM_PRTY_MASK_0 0x300130
3281#define USEM_REG_USEM_PRTY_MASK_1 0x300140 3428#define USEM_REG_USEM_PRTY_MASK_1 0x300140
3429/* [R 32] Parity register #0 read */
3430#define USEM_REG_USEM_PRTY_STS_0 0x300124
3431#define USEM_REG_USEM_PRTY_STS_1 0x300134
3282/* [RW 2] The queue index for registration on Aux1 counter flag. */ 3432/* [RW 2] The queue index for registration on Aux1 counter flag. */
3283#define XCM_REG_AUX1_Q 0x20134 3433#define XCM_REG_AUX1_Q 0x20134
3284/* [RW 2] Per each decision rule the queue index to register to. */ 3434/* [RW 2] Per each decision rule the queue index to register to. */
@@ -3684,6 +3834,8 @@
3684#define XSDM_REG_XSDM_INT_MASK_1 0x1662ac 3834#define XSDM_REG_XSDM_INT_MASK_1 0x1662ac
3685/* [RW 11] Parity mask register #0 read/write */ 3835/* [RW 11] Parity mask register #0 read/write */
3686#define XSDM_REG_XSDM_PRTY_MASK 0x1662bc 3836#define XSDM_REG_XSDM_PRTY_MASK 0x1662bc
3837/* [R 11] Parity register #0 read */
3838#define XSDM_REG_XSDM_PRTY_STS 0x1662b0
3687/* [RW 5] The number of time_slots in the arbitration cycle */ 3839/* [RW 5] The number of time_slots in the arbitration cycle */
3688#define XSEM_REG_ARB_CYCLE_SIZE 0x280034 3840#define XSEM_REG_ARB_CYCLE_SIZE 0x280034
3689/* [RW 3] The source that is associated with arbitration element 0. Source 3841/* [RW 3] The source that is associated with arbitration element 0. Source
@@ -3808,6 +3960,9 @@
3808/* [RW 32] Parity mask register #0 read/write */ 3960/* [RW 32] Parity mask register #0 read/write */
3809#define XSEM_REG_XSEM_PRTY_MASK_0 0x280130 3961#define XSEM_REG_XSEM_PRTY_MASK_0 0x280130
3810#define XSEM_REG_XSEM_PRTY_MASK_1 0x280140 3962#define XSEM_REG_XSEM_PRTY_MASK_1 0x280140
3963/* [R 32] Parity register #0 read */
3964#define XSEM_REG_XSEM_PRTY_STS_0 0x280124
3965#define XSEM_REG_XSEM_PRTY_STS_1 0x280134
3811#define MCPR_NVM_ACCESS_ENABLE_EN (1L<<0) 3966#define MCPR_NVM_ACCESS_ENABLE_EN (1L<<0)
3812#define MCPR_NVM_ACCESS_ENABLE_WR_EN (1L<<1) 3967#define MCPR_NVM_ACCESS_ENABLE_WR_EN (1L<<1)
3813#define MCPR_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0) 3968#define MCPR_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0)
@@ -3847,6 +4002,8 @@
3847#define EMAC_MDIO_COMM_START_BUSY (1L<<29) 4002#define EMAC_MDIO_COMM_START_BUSY (1L<<29)
3848#define EMAC_MDIO_MODE_AUTO_POLL (1L<<4) 4003#define EMAC_MDIO_MODE_AUTO_POLL (1L<<4)
3849#define EMAC_MDIO_MODE_CLAUSE_45 (1L<<31) 4004#define EMAC_MDIO_MODE_CLAUSE_45 (1L<<31)
4005#define EMAC_MDIO_MODE_CLOCK_CNT (0x3fL<<16)
4006#define EMAC_MDIO_MODE_CLOCK_CNT_BITSHIFT 16
3850#define EMAC_MODE_25G_MODE (1L<<5) 4007#define EMAC_MODE_25G_MODE (1L<<5)
3851#define EMAC_MODE_ACPI_RCVD (1L<<20) 4008#define EMAC_MODE_ACPI_RCVD (1L<<20)
3852#define EMAC_MODE_HALF_DUPLEX (1L<<1) 4009#define EMAC_MODE_HALF_DUPLEX (1L<<1)
@@ -3874,6 +4031,17 @@
3874#define EMAC_RX_MTU_SIZE_JUMBO_ENA (1L<<31) 4031#define EMAC_RX_MTU_SIZE_JUMBO_ENA (1L<<31)
3875#define EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3) 4032#define EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3)
3876#define EMAC_TX_MODE_RESET (1L<<0) 4033#define EMAC_TX_MODE_RESET (1L<<0)
4034#define MISC_REGISTERS_GPIO_1 1
4035#define MISC_REGISTERS_GPIO_2 2
4036#define MISC_REGISTERS_GPIO_3 3
4037#define MISC_REGISTERS_GPIO_CLR_POS 16
4038#define MISC_REGISTERS_GPIO_FLOAT (0xffL<<24)
4039#define MISC_REGISTERS_GPIO_FLOAT_POS 24
4040#define MISC_REGISTERS_GPIO_INPUT_HI_Z 2
4041#define MISC_REGISTERS_GPIO_OUTPUT_HIGH 1
4042#define MISC_REGISTERS_GPIO_OUTPUT_LOW 0
4043#define MISC_REGISTERS_GPIO_PORT_SHIFT 4
4044#define MISC_REGISTERS_GPIO_SET_POS 8
3877#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588 4045#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588
3878#define MISC_REGISTERS_RESET_REG_1_SET 0x584 4046#define MISC_REGISTERS_RESET_REG_1_SET 0x584
3879#define MISC_REGISTERS_RESET_REG_2_CLEAR 0x598 4047#define MISC_REGISTERS_RESET_REG_2_CLEAR 0x598
@@ -3891,6 +4059,25 @@
3891#define MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW (0x1<<4) 4059#define MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_RSTB_HW (0x1<<4)
3892#define MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB (0x1<<8) 4060#define MISC_REGISTERS_RESET_REG_3_MISC_NIG_MUX_XGXS0_TXD_FIFO_RSTB (0x1<<8)
3893#define MISC_REGISTERS_RESET_REG_3_SET 0x5a4 4061#define MISC_REGISTERS_RESET_REG_3_SET 0x5a4
4062#define MISC_REGISTERS_SPIO_4 4
4063#define MISC_REGISTERS_SPIO_5 5
4064#define MISC_REGISTERS_SPIO_7 7
4065#define MISC_REGISTERS_SPIO_CLR_POS 16
4066#define MISC_REGISTERS_SPIO_FLOAT (0xffL<<24)
4067#define GRC_MISC_REGISTERS_SPIO_FLOAT7 0x80000000
4068#define GRC_MISC_REGISTERS_SPIO_FLOAT6 0x40000000
4069#define GRC_MISC_REGISTERS_SPIO_FLOAT5 0x20000000
4070#define GRC_MISC_REGISTERS_SPIO_FLOAT4 0x10000000
4071#define MISC_REGISTERS_SPIO_FLOAT_POS 24
4072#define MISC_REGISTERS_SPIO_INPUT_HI_Z 2
4073#define MISC_REGISTERS_SPIO_INT_OLD_SET_POS 16
4074#define MISC_REGISTERS_SPIO_OUTPUT_HIGH 1
4075#define MISC_REGISTERS_SPIO_OUTPUT_LOW 0
4076#define MISC_REGISTERS_SPIO_SET_POS 8
4077#define HW_LOCK_MAX_RESOURCE_VALUE 31
4078#define HW_LOCK_RESOURCE_8072_MDIO 0
4079#define HW_LOCK_RESOURCE_GPIO 1
4080#define HW_LOCK_RESOURCE_SPIO 2
3894#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR (1<<18) 4081#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR (1<<18)
3895#define AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT (1<<31) 4082#define AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT (1<<31)
3896#define AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT (1<<9) 4083#define AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT (1<<9)
@@ -3918,6 +4105,7 @@
3918#define AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT (1<<3) 4105#define AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT (1<<3)
3919#define AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR (1<<2) 4106#define AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR (1<<2)
3920#define AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR (1<<22) 4107#define AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR (1<<22)
4108#define AEU_INPUTS_ATTN_BITS_SPIO5 (1<<15)
3921#define AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT (1<<27) 4109#define AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT (1<<27)
3922#define AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT (1<<5) 4110#define AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT (1<<5)
3923#define AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT (1<<25) 4111#define AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT (1<<25)
@@ -4206,6 +4394,9 @@
4206#define MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE 0x4000 4394#define MDIO_XGXS_BLOCK2_RX_LN_SWAP_FORCE_ENABLE 0x4000
4207#define MDIO_XGXS_BLOCK2_TX_LN_SWAP 0x11 4395#define MDIO_XGXS_BLOCK2_TX_LN_SWAP 0x11
4208#define MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE 0x8000 4396#define MDIO_XGXS_BLOCK2_TX_LN_SWAP_ENABLE 0x8000
4397#define MDIO_XGXS_BLOCK2_UNICORE_MODE_10G 0x14
4398#define MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_CX4_XGXS 0x0001
4399#define MDIO_XGXS_BLOCK2_UNICORE_MODE_10G_HIGIG_XGXS 0x0010
4209#define MDIO_XGXS_BLOCK2_TEST_MODE_LANE 0x15 4400#define MDIO_XGXS_BLOCK2_TEST_MODE_LANE 0x15
4210 4401
4211#define MDIO_REG_BANK_GP_STATUS 0x8120 4402#define MDIO_REG_BANK_GP_STATUS 0x8120
@@ -4362,11 +4553,13 @@
4362#define MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1_SGMII_MODE 0x0001 4553#define MDIO_COMBO_IEEE0_AUTO_NEG_LINK_PARTNER_ABILITY1_SGMII_MODE 0x0001
4363 4554
4364 4555
4556#define EXT_PHY_AUTO_NEG_DEVAD 0x7
4365#define EXT_PHY_OPT_PMA_PMD_DEVAD 0x1 4557#define EXT_PHY_OPT_PMA_PMD_DEVAD 0x1
4366#define EXT_PHY_OPT_WIS_DEVAD 0x2 4558#define EXT_PHY_OPT_WIS_DEVAD 0x2
4367#define EXT_PHY_OPT_PCS_DEVAD 0x3 4559#define EXT_PHY_OPT_PCS_DEVAD 0x3
4368#define EXT_PHY_OPT_PHY_XS_DEVAD 0x4 4560#define EXT_PHY_OPT_PHY_XS_DEVAD 0x4
4369#define EXT_PHY_OPT_CNTL 0x0 4561#define EXT_PHY_OPT_CNTL 0x0
4562#define EXT_PHY_OPT_CNTL2 0x7
4370#define EXT_PHY_OPT_PMD_RX_SD 0xa 4563#define EXT_PHY_OPT_PMD_RX_SD 0xa
4371#define EXT_PHY_OPT_PMD_MISC_CNTL 0xca0a 4564#define EXT_PHY_OPT_PMD_MISC_CNTL 0xca0a
4372#define EXT_PHY_OPT_PHY_IDENTIFIER 0xc800 4565#define EXT_PHY_OPT_PHY_IDENTIFIER 0xc800
@@ -4378,11 +4571,24 @@
4378#define EXT_PHY_OPT_LASI_STATUS 0x9005 4571#define EXT_PHY_OPT_LASI_STATUS 0x9005
4379#define EXT_PHY_OPT_PCS_STATUS 0x0020 4572#define EXT_PHY_OPT_PCS_STATUS 0x0020
4380#define EXT_PHY_OPT_XGXS_LANE_STATUS 0x0018 4573#define EXT_PHY_OPT_XGXS_LANE_STATUS 0x0018
4574#define EXT_PHY_OPT_AN_LINK_STATUS 0x8304
4575#define EXT_PHY_OPT_AN_CL37_CL73 0x8370
4576#define EXT_PHY_OPT_AN_CL37_FD 0xffe4
4577#define EXT_PHY_OPT_AN_CL37_AN 0xffe0
4578#define EXT_PHY_OPT_AN_ADV 0x11
4381 4579
4382#define EXT_PHY_KR_PMA_PMD_DEVAD 0x1 4580#define EXT_PHY_KR_PMA_PMD_DEVAD 0x1
4383#define EXT_PHY_KR_PCS_DEVAD 0x3 4581#define EXT_PHY_KR_PCS_DEVAD 0x3
4384#define EXT_PHY_KR_AUTO_NEG_DEVAD 0x7 4582#define EXT_PHY_KR_AUTO_NEG_DEVAD 0x7
4385#define EXT_PHY_KR_CTRL 0x0000 4583#define EXT_PHY_KR_CTRL 0x0000
4584#define EXT_PHY_KR_STATUS 0x0001
4585#define EXT_PHY_KR_AUTO_NEG_COMPLETE 0x0020
4586#define EXT_PHY_KR_AUTO_NEG_ADVERT 0x0010
4587#define EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE 0x0400
4588#define EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_ASYMMETRIC 0x0800
4589#define EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_BOTH 0x0C00
4590#define EXT_PHY_KR_AUTO_NEG_ADVERT_PAUSE_MASK 0x0C00
4591#define EXT_PHY_KR_LP_AUTO_NEG 0x0013
4386#define EXT_PHY_KR_CTRL2 0x0007 4592#define EXT_PHY_KR_CTRL2 0x0007
4387#define EXT_PHY_KR_PCS_STATUS 0x0020 4593#define EXT_PHY_KR_PCS_STATUS 0x0020
4388#define EXT_PHY_KR_PMD_CTRL 0x0096 4594#define EXT_PHY_KR_PMD_CTRL 0x0096
@@ -4391,4 +4597,8 @@
4391#define EXT_PHY_KR_MISC_CTRL1 0xca85 4597#define EXT_PHY_KR_MISC_CTRL1 0xca85
4392#define EXT_PHY_KR_GEN_CTRL 0xca10 4598#define EXT_PHY_KR_GEN_CTRL 0xca10
4393#define EXT_PHY_KR_ROM_CODE 0xca19 4599#define EXT_PHY_KR_ROM_CODE 0xca19
4600#define EXT_PHY_KR_ROM_RESET_INTERNAL_MP 0x0188
4601#define EXT_PHY_KR_ROM_MICRO_RESET 0x018a
4602
4603#define EXT_PHY_SFX7101_XGXS_TEST1 0xc00a
4394 4604
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 571750975137..348371fda597 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -172,30 +172,30 @@ static char version[] __initdata =
172 them to system IRQ numbers. This mapping is card specific and is set to 172 them to system IRQ numbers. This mapping is card specific and is set to
173 the configuration of the Cirrus Eval board for this chip. */ 173 the configuration of the Cirrus Eval board for this chip. */
174#ifdef CONFIG_ARCH_CLPS7500 174#ifdef CONFIG_ARCH_CLPS7500
175static unsigned int netcard_portlist[] __initdata = 175static unsigned int netcard_portlist[] __used __initdata =
176 { 0x80090303, 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; 176 { 0x80090303, 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
177static unsigned int cs8900_irq_map[] = {12,0,0,0}; 177static unsigned int cs8900_irq_map[] = {12,0,0,0};
178#elif defined(CONFIG_SH_HICOSH4) 178#elif defined(CONFIG_SH_HICOSH4)
179static unsigned int netcard_portlist[] __initdata = 179static unsigned int netcard_portlist[] __used __initdata =
180 { 0x0300, 0}; 180 { 0x0300, 0};
181static unsigned int cs8900_irq_map[] = {1,0,0,0}; 181static unsigned int cs8900_irq_map[] = {1,0,0,0};
182#elif defined(CONFIG_MACH_IXDP2351) 182#elif defined(CONFIG_MACH_IXDP2351)
183static unsigned int netcard_portlist[] __initdata = {IXDP2351_VIRT_CS8900_BASE, 0}; 183static unsigned int netcard_portlist[] __used __initdata = {IXDP2351_VIRT_CS8900_BASE, 0};
184static unsigned int cs8900_irq_map[] = {IRQ_IXDP2351_CS8900, 0, 0, 0}; 184static unsigned int cs8900_irq_map[] = {IRQ_IXDP2351_CS8900, 0, 0, 0};
185#include <asm/irq.h> 185#include <asm/irq.h>
186#elif defined(CONFIG_ARCH_IXDP2X01) 186#elif defined(CONFIG_ARCH_IXDP2X01)
187#include <asm/irq.h> 187#include <asm/irq.h>
188static unsigned int netcard_portlist[] __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0}; 188static unsigned int netcard_portlist[] __used __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0};
189static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0}; 189static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0};
190#elif defined(CONFIG_ARCH_PNX010X) 190#elif defined(CONFIG_ARCH_PNX010X)
191#include <asm/irq.h> 191#include <asm/irq.h>
192#include <asm/arch/gpio.h> 192#include <asm/arch/gpio.h>
193#define CIRRUS_DEFAULT_BASE IO_ADDRESS(EXT_STATIC2_s0_BASE + 0x200000) /* = Physical address 0x48200000 */ 193#define CIRRUS_DEFAULT_BASE IO_ADDRESS(EXT_STATIC2_s0_BASE + 0x200000) /* = Physical address 0x48200000 */
194#define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */ 194#define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */
195static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0}; 195static unsigned int netcard_portlist[] __used __initdata = {CIRRUS_DEFAULT_BASE, 0};
196static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0}; 196static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0};
197#else 197#else
198static unsigned int netcard_portlist[] __initdata = 198static unsigned int netcard_portlist[] __used __initdata =
199 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; 199 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
200static unsigned int cs8900_irq_map[] = {10,11,12,5}; 200static unsigned int cs8900_irq_map[] = {10,11,12,5};
201#endif 201#endif
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 3beace55b58d..7fe20310eb5f 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -438,7 +438,7 @@ static void e1000_release_nvm_82571(struct e1000_hw *hw)
438 * For non-82573 silicon, write data to EEPROM at offset using SPI interface. 438 * For non-82573 silicon, write data to EEPROM at offset using SPI interface.
439 * 439 *
440 * If e1000e_update_nvm_checksum is not called after this function, the 440 * If e1000e_update_nvm_checksum is not called after this function, the
441 * EEPROM will most likley contain an invalid checksum. 441 * EEPROM will most likely contain an invalid checksum.
442 **/ 442 **/
443static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words, 443static s32 e1000_write_nvm_82571(struct e1000_hw *hw, u16 offset, u16 words,
444 u16 *data) 444 u16 *data)
@@ -547,7 +547,7 @@ static s32 e1000_validate_nvm_checksum_82571(struct e1000_hw *hw)
547 * poll for completion. 547 * poll for completion.
548 * 548 *
549 * If e1000e_update_nvm_checksum is not called after this function, the 549 * If e1000e_update_nvm_checksum is not called after this function, the
550 * EEPROM will most likley contain an invalid checksum. 550 * EEPROM will most likely contain an invalid checksum.
551 **/ 551 **/
552static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset, 552static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,
553 u16 words, u16 *data) 553 u16 words, u16 *data)
@@ -1053,7 +1053,7 @@ static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw)
1053 /* If SerDes loopback mode is entered, there is no form 1053 /* If SerDes loopback mode is entered, there is no form
1054 * of reset to take the adapter out of that mode. So we 1054 * of reset to take the adapter out of that mode. So we
1055 * have to explicitly take the adapter out of loopback 1055 * have to explicitly take the adapter out of loopback
1056 * mode. This prevents drivers from twidling their thumbs 1056 * mode. This prevents drivers from twiddling their thumbs
1057 * if another tool failed to take it out of loopback mode. 1057 * if another tool failed to take it out of loopback mode.
1058 */ 1058 */
1059 ew32(SCTL, 1059 ew32(SCTL,
@@ -1098,7 +1098,7 @@ static s32 e1000_valid_led_default_82571(struct e1000_hw *hw, u16 *data)
1098 * e1000e_get_laa_state_82571 - Get locally administered address state 1098 * e1000e_get_laa_state_82571 - Get locally administered address state
1099 * @hw: pointer to the HW structure 1099 * @hw: pointer to the HW structure
1100 * 1100 *
1101 * Retrieve and return the current locally administed address state. 1101 * Retrieve and return the current locally administered address state.
1102 **/ 1102 **/
1103bool e1000e_get_laa_state_82571(struct e1000_hw *hw) 1103bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1104{ 1104{
@@ -1113,7 +1113,7 @@ bool e1000e_get_laa_state_82571(struct e1000_hw *hw)
1113 * @hw: pointer to the HW structure 1113 * @hw: pointer to the HW structure
1114 * @state: enable/disable locally administered address 1114 * @state: enable/disable locally administered address
1115 * 1115 *
1116 * Enable/Disable the current locally administed address state. 1116 * Enable/Disable the current locally administers address state.
1117 **/ 1117 **/
1118void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state) 1118void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state)
1119{ 1119{
@@ -1281,16 +1281,6 @@ static struct e1000_phy_operations e82_phy_ops_m88 = {
1281 1281
1282static struct e1000_nvm_operations e82571_nvm_ops = { 1282static struct e1000_nvm_operations e82571_nvm_ops = {
1283 .acquire_nvm = e1000_acquire_nvm_82571, 1283 .acquire_nvm = e1000_acquire_nvm_82571,
1284 .read_nvm = e1000e_read_nvm_spi,
1285 .release_nvm = e1000_release_nvm_82571,
1286 .update_nvm = e1000_update_nvm_checksum_82571,
1287 .valid_led_default = e1000_valid_led_default_82571,
1288 .validate_nvm = e1000_validate_nvm_checksum_82571,
1289 .write_nvm = e1000_write_nvm_82571,
1290};
1291
1292static struct e1000_nvm_operations e82573_nvm_ops = {
1293 .acquire_nvm = e1000_acquire_nvm_82571,
1294 .read_nvm = e1000e_read_nvm_eerd, 1284 .read_nvm = e1000e_read_nvm_eerd,
1295 .release_nvm = e1000_release_nvm_82571, 1285 .release_nvm = e1000_release_nvm_82571,
1296 .update_nvm = e1000_update_nvm_checksum_82571, 1286 .update_nvm = e1000_update_nvm_checksum_82571,
@@ -1355,6 +1345,6 @@ struct e1000_info e1000_82573_info = {
1355 .get_invariants = e1000_get_invariants_82571, 1345 .get_invariants = e1000_get_invariants_82571,
1356 .mac_ops = &e82571_mac_ops, 1346 .mac_ops = &e82571_mac_ops,
1357 .phy_ops = &e82_phy_ops_m88, 1347 .phy_ops = &e82_phy_ops_m88,
1358 .nvm_ops = &e82573_nvm_ops, 1348 .nvm_ops = &e82571_nvm_ops,
1359}; 1349};
1360 1350
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 6232c3e96689..a4f511f549f7 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -66,7 +66,7 @@
66#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */ 66#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */
67 67
68/* Extended Device Control */ 68/* Extended Device Control */
69#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */ 69#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Definable Pin 7 */
70#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */ 70#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */
71#define E1000_CTRL_EXT_RO_DIS 0x00020000 /* Relaxed Ordering disable */ 71#define E1000_CTRL_EXT_RO_DIS 0x00020000 /* Relaxed Ordering disable */
72#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 72#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
@@ -75,12 +75,12 @@
75#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */ 75#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */
76#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */ 76#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */
77 77
78/* Receive Decriptor bit definitions */ 78/* Receive Descriptor bit definitions */
79#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */ 79#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */
80#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */ 80#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */
81#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */ 81#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */
82#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */ 82#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */
83#define E1000_RXD_STAT_UDPCS 0x10 /* UDP xsum caculated */ 83#define E1000_RXD_STAT_UDPCS 0x10 /* UDP xsum calculated */
84#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */ 84#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
85#define E1000_RXD_ERR_CE 0x01 /* CRC Error */ 85#define E1000_RXD_ERR_CE 0x01 /* CRC Error */
86#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */ 86#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */
@@ -223,7 +223,7 @@
223#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */ 223#define E1000_STATUS_LAN_INIT_DONE 0x00000200 /* Lan Init Completion by NVM */
224#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */ 224#define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */
225 225
226/* Constants used to intrepret the masked PCI-X bus speed. */ 226/* Constants used to interpret the masked PCI-X bus speed. */
227 227
228#define HALF_DUPLEX 1 228#define HALF_DUPLEX 1
229#define FULL_DUPLEX 2 229#define FULL_DUPLEX 2
@@ -517,7 +517,7 @@
517/* PHY 1000 MII Register/Bit Definitions */ 517/* PHY 1000 MII Register/Bit Definitions */
518/* PHY Registers defined by IEEE */ 518/* PHY Registers defined by IEEE */
519#define PHY_CONTROL 0x00 /* Control Register */ 519#define PHY_CONTROL 0x00 /* Control Register */
520#define PHY_STATUS 0x01 /* Status Regiser */ 520#define PHY_STATUS 0x01 /* Status Register */
521#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */ 521#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */
522#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */ 522#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */
523#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */ 523#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 8b88c226e858..327c0620da31 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -42,8 +42,7 @@
42struct e1000_info; 42struct e1000_info;
43 43
44#define ndev_printk(level, netdev, format, arg...) \ 44#define ndev_printk(level, netdev, format, arg...) \
45 printk(level "%s: %s: " format, (netdev)->dev.parent->bus_id, \ 45 printk(level "%s: " format, (netdev)->name, ## arg)
46 (netdev)->name, ## arg)
47 46
48#ifdef DEBUG 47#ifdef DEBUG
49#define ndev_dbg(netdev, format, arg...) \ 48#define ndev_dbg(netdev, format, arg...) \
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index 3c5862f97dbf..916025b30fc3 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -184,7 +184,7 @@ enum e1e_registers {
184 E1000_ICRXDMTC = 0x04120, /* Irq Cause Rx Desc MinThreshold Count */ 184 E1000_ICRXDMTC = 0x04120, /* Irq Cause Rx Desc MinThreshold Count */
185 E1000_ICRXOC = 0x04124, /* Irq Cause Receiver Overrun Count */ 185 E1000_ICRXOC = 0x04124, /* Irq Cause Receiver Overrun Count */
186 E1000_RXCSUM = 0x05000, /* RX Checksum Control - RW */ 186 E1000_RXCSUM = 0x05000, /* RX Checksum Control - RW */
187 E1000_RFCTL = 0x05008, /* Receive Filter Control*/ 187 E1000_RFCTL = 0x05008, /* Receive Filter Control */
188 E1000_MTA = 0x05200, /* Multicast Table Array - RW Array */ 188 E1000_MTA = 0x05200, /* Multicast Table Array - RW Array */
189 E1000_RA = 0x05400, /* Receive Address - RW Array */ 189 E1000_RA = 0x05400, /* Receive Address - RW Array */
190 E1000_VFTA = 0x05600, /* VLAN Filter Table Array - RW Array */ 190 E1000_VFTA = 0x05600, /* VLAN Filter Table Array - RW Array */
@@ -202,7 +202,7 @@ enum e1e_registers {
202 E1000_FACTPS = 0x05B30, /* Function Active and Power State to MNG */ 202 E1000_FACTPS = 0x05B30, /* Function Active and Power State to MNG */
203 E1000_SWSM = 0x05B50, /* SW Semaphore */ 203 E1000_SWSM = 0x05B50, /* SW Semaphore */
204 E1000_FWSM = 0x05B54, /* FW Semaphore */ 204 E1000_FWSM = 0x05B54, /* FW Semaphore */
205 E1000_HICR = 0x08F00, /* Host Inteface Control */ 205 E1000_HICR = 0x08F00, /* Host Interface Control */
206}; 206};
207 207
208/* RSS registers */ 208/* RSS registers */
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 8f8139de1f48..0ae39550768d 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -671,7 +671,7 @@ static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw)
671 * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY 671 * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY
672 * @hw: pointer to the HW structure 672 * @hw: pointer to the HW structure
673 * 673 *
674 * Polarity is determined on the polarity reveral feature being enabled. 674 * Polarity is determined on the polarity reversal feature being enabled.
675 * This function is only called by other family-specific 675 * This function is only called by other family-specific
676 * routines. 676 * routines.
677 **/ 677 **/
@@ -947,7 +947,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
947 /* Either we should have a hardware SPI cycle in progress 947 /* Either we should have a hardware SPI cycle in progress
948 * bit to check against, in order to start a new cycle or 948 * bit to check against, in order to start a new cycle or
949 * FDONE bit should be changed in the hardware so that it 949 * FDONE bit should be changed in the hardware so that it
950 * is 1 after harware reset, which can then be used as an 950 * is 1 after hardware reset, which can then be used as an
951 * indication whether a cycle is in progress or has been 951 * indication whether a cycle is in progress or has been
952 * completed. 952 * completed.
953 */ 953 */
@@ -1155,7 +1155,7 @@ static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1155 * which writes the checksum to the shadow ram. The changes in the shadow 1155 * which writes the checksum to the shadow ram. The changes in the shadow
1156 * ram are then committed to the EEPROM by processing each bank at a time 1156 * ram are then committed to the EEPROM by processing each bank at a time
1157 * checking for the modified bit and writing only the pending changes. 1157 * checking for the modified bit and writing only the pending changes.
1158 * After a succesful commit, the shadow ram is cleared and is ready for 1158 * After a successful commit, the shadow ram is cleared and is ready for
1159 * future writes. 1159 * future writes.
1160 **/ 1160 **/
1161static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) 1161static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
@@ -1680,7 +1680,7 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
1680 * - initialize LED identification 1680 * - initialize LED identification
1681 * - setup receive address registers 1681 * - setup receive address registers
1682 * - setup flow control 1682 * - setup flow control
1683 * - setup transmit discriptors 1683 * - setup transmit descriptors
1684 * - clear statistics 1684 * - clear statistics
1685 **/ 1685 **/
1686static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) 1686static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
@@ -1961,7 +1961,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
1961 E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 1961 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
1962 ew32(PHY_CTRL, phy_ctrl); 1962 ew32(PHY_CTRL, phy_ctrl);
1963 1963
1964 /* Call gig speed drop workaround on Giga disable before accessing 1964 /* Call gig speed drop workaround on Gig disable before accessing
1965 * any PHY registers */ 1965 * any PHY registers */
1966 e1000e_gig_downshift_workaround_ich8lan(hw); 1966 e1000e_gig_downshift_workaround_ich8lan(hw);
1967 1967
@@ -1972,7 +1972,7 @@ static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
1972/** 1972/**
1973 * e1000_set_kmrn_lock_loss_workaound_ich8lan - Set Kumeran workaround state 1973 * e1000_set_kmrn_lock_loss_workaound_ich8lan - Set Kumeran workaround state
1974 * @hw: pointer to the HW structure 1974 * @hw: pointer to the HW structure
1975 * @state: boolean value used to set the current Kumaran workaround state 1975 * @state: boolean value used to set the current Kumeran workaround state
1976 * 1976 *
1977 * If ICH8, set the current Kumeran workaround state (enabled - TRUE 1977 * If ICH8, set the current Kumeran workaround state (enabled - TRUE
1978 * /disabled - FALSE). 1978 * /disabled - FALSE).
@@ -2017,7 +2017,7 @@ void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
2017 E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 2017 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
2018 ew32(PHY_CTRL, reg); 2018 ew32(PHY_CTRL, reg);
2019 2019
2020 /* Call gig speed drop workaround on Giga disable before 2020 /* Call gig speed drop workaround on Gig disable before
2021 * accessing any PHY registers */ 2021 * accessing any PHY registers */
2022 if (hw->mac.type == e1000_ich8lan) 2022 if (hw->mac.type == e1000_ich8lan)
2023 e1000e_gig_downshift_workaround_ich8lan(hw); 2023 e1000e_gig_downshift_workaround_ich8lan(hw);
@@ -2045,7 +2045,7 @@ void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
2045 * @hw: pointer to the HW structure 2045 * @hw: pointer to the HW structure
2046 * 2046 *
2047 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC), 2047 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
2048 * LPLU, Giga disable, MDIC PHY reset): 2048 * LPLU, Gig disable, MDIC PHY reset):
2049 * 1) Set Kumeran Near-end loopback 2049 * 1) Set Kumeran Near-end loopback
2050 * 2) Clear Kumeran Near-end loopback 2050 * 2) Clear Kumeran Near-end loopback
2051 * Should only be called for ICH8[m] devices with IGP_3 Phy. 2051 * Should only be called for ICH8[m] devices with IGP_3 Phy.
@@ -2089,10 +2089,10 @@ static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
2089} 2089}
2090 2090
2091/** 2091/**
2092 * e1000_led_on_ich8lan - Turn LED's on 2092 * e1000_led_on_ich8lan - Turn LEDs on
2093 * @hw: pointer to the HW structure 2093 * @hw: pointer to the HW structure
2094 * 2094 *
2095 * Turn on the LED's. 2095 * Turn on the LEDs.
2096 **/ 2096 **/
2097static s32 e1000_led_on_ich8lan(struct e1000_hw *hw) 2097static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
2098{ 2098{
@@ -2105,10 +2105,10 @@ static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
2105} 2105}
2106 2106
2107/** 2107/**
2108 * e1000_led_off_ich8lan - Turn LED's off 2108 * e1000_led_off_ich8lan - Turn LEDs off
2109 * @hw: pointer to the HW structure 2109 * @hw: pointer to the HW structure
2110 * 2110 *
2111 * Turn off the LED's. 2111 * Turn off the LEDs.
2112 **/ 2112 **/
2113static s32 e1000_led_off_ich8lan(struct e1000_hw *hw) 2113static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
2114{ 2114{
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 16f35fadb74b..95f75a43c9f9 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -589,9 +589,6 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
589 s32 ret_val; 589 s32 ret_val;
590 u16 nvm_data; 590 u16 nvm_data;
591 591
592 if (mac->fc != e1000_fc_default)
593 return 0;
594
595 /* Read and store word 0x0F of the EEPROM. This word contains bits 592 /* Read and store word 0x0F of the EEPROM. This word contains bits
596 * that determine the hardware's default PAUSE (flow control) mode, 593 * that determine the hardware's default PAUSE (flow control) mode,
597 * a bit that determines whether the HW defaults to enabling or 594 * a bit that determines whether the HW defaults to enabling or
@@ -1107,34 +1104,13 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1107 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { 1104 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
1108 mac->fc = e1000_fc_rx_pause; 1105 mac->fc = e1000_fc_rx_pause;
1109 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n"); 1106 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
1110 } 1107 } else {
1111 /* Per the IEEE spec, at this point flow control should be 1108 /*
1112 * disabled. However, we want to consider that we could 1109 * Per the IEEE spec, at this point flow control
1113 * be connected to a legacy switch that doesn't advertise 1110 * should be disabled.
1114 * desired flow control, but can be forced on the link 1111 */
1115 * partner. So if we advertised no flow control, that is
1116 * what we will resolve to. If we advertised some kind of
1117 * receive capability (Rx Pause Only or Full Flow Control)
1118 * and the link partner advertised none, we will configure
1119 * ourselves to enable Rx Flow Control only. We can do
1120 * this safely for two reasons: If the link partner really
1121 * didn't want flow control enabled, and we enable Rx, no
1122 * harm done since we won't be receiving any PAUSE frames
1123 * anyway. If the intent on the link partner was to have
1124 * flow control enabled, then by us enabling RX only, we
1125 * can at least receive pause frames and process them.
1126 * This is a good idea because in most cases, since we are
1127 * predominantly a server NIC, more times than not we will
1128 * be asked to delay transmission of packets than asking
1129 * our link partner to pause transmission of frames.
1130 */
1131 else if ((mac->original_fc == e1000_fc_none) ||
1132 (mac->original_fc == e1000_fc_tx_pause)) {
1133 mac->fc = e1000_fc_none; 1112 mac->fc = e1000_fc_none;
1134 hw_dbg(hw, "Flow Control = NONE.\r\n"); 1113 hw_dbg(hw, "Flow Control = NONE.\r\n");
1135 } else {
1136 mac->fc = e1000_fc_rx_pause;
1137 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n");
1138 } 1114 }
1139 1115
1140 /* Now we need to do one last check... If we auto- 1116 /* Now we need to do one last check... If we auto-
@@ -1164,7 +1140,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1164} 1140}
1165 1141
1166/** 1142/**
1167 * e1000e_get_speed_and_duplex_copper - Retreive current speed/duplex 1143 * e1000e_get_speed_and_duplex_copper - Retrieve current speed/duplex
1168 * @hw: pointer to the HW structure 1144 * @hw: pointer to the HW structure
1169 * @speed: stores the current speed 1145 * @speed: stores the current speed
1170 * @duplex: stores the current duplex 1146 * @duplex: stores the current duplex
@@ -1200,7 +1176,7 @@ s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dup
1200} 1176}
1201 1177
1202/** 1178/**
1203 * e1000e_get_speed_and_duplex_fiber_serdes - Retreive current speed/duplex 1179 * e1000e_get_speed_and_duplex_fiber_serdes - Retrieve current speed/duplex
1204 * @hw: pointer to the HW structure 1180 * @hw: pointer to the HW structure
1205 * @speed: stores the current speed 1181 * @speed: stores the current speed
1206 * @duplex: stores the current duplex 1182 * @duplex: stores the current duplex
@@ -1410,7 +1386,7 @@ s32 e1000e_cleanup_led_generic(struct e1000_hw *hw)
1410 * e1000e_blink_led - Blink LED 1386 * e1000e_blink_led - Blink LED
1411 * @hw: pointer to the HW structure 1387 * @hw: pointer to the HW structure
1412 * 1388 *
1413 * Blink the led's which are set to be on. 1389 * Blink the LEDs which are set to be on.
1414 **/ 1390 **/
1415s32 e1000e_blink_led(struct e1000_hw *hw) 1391s32 e1000e_blink_led(struct e1000_hw *hw)
1416{ 1392{
@@ -1515,7 +1491,7 @@ void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop)
1515 * @hw: pointer to the HW structure 1491 * @hw: pointer to the HW structure
1516 * 1492 *
1517 * Returns 0 if successful, else returns -10 1493 * Returns 0 if successful, else returns -10
1518 * (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not casued 1494 * (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not caused
1519 * the master requests to be disabled. 1495 * the master requests to be disabled.
1520 * 1496 *
1521 * Disables PCI-Express master access and verifies there are no pending 1497 * Disables PCI-Express master access and verifies there are no pending
@@ -1876,7 +1852,7 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
1876} 1852}
1877 1853
1878/** 1854/**
1879 * e1000e_read_nvm_spi - Read EEPROM's using SPI 1855 * e1000e_read_nvm_spi - Reads EEPROM using SPI
1880 * @hw: pointer to the HW structure 1856 * @hw: pointer to the HW structure
1881 * @offset: offset of word in the EEPROM to read 1857 * @offset: offset of word in the EEPROM to read
1882 * @words: number of words to read 1858 * @words: number of words to read
@@ -1980,7 +1956,7 @@ s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1980 * Writes data to EEPROM at offset using SPI interface. 1956 * Writes data to EEPROM at offset using SPI interface.
1981 * 1957 *
1982 * If e1000e_update_nvm_checksum is not called after this function , the 1958 * If e1000e_update_nvm_checksum is not called after this function , the
1983 * EEPROM will most likley contain an invalid checksum. 1959 * EEPROM will most likely contain an invalid checksum.
1984 **/ 1960 **/
1985s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 1961s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
1986{ 1962{
@@ -2222,7 +2198,7 @@ static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
2222 * 2198 *
2223 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND 2199 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
2224 * 2200 *
2225 * This function checks whether the HOST IF is enabled for command operaton 2201 * This function checks whether the HOST IF is enabled for command operation
2226 * and also checks whether the previous command is completed. It busy waits 2202 * and also checks whether the previous command is completed. It busy waits
2227 * in case of previous command is not completed. 2203 * in case of previous command is not completed.
2228 **/ 2204 **/
@@ -2254,7 +2230,7 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
2254} 2230}
2255 2231
2256/** 2232/**
2257 * e1000e_check_mng_mode - check managament mode 2233 * e1000e_check_mng_mode - check management mode
2258 * @hw: pointer to the HW structure 2234 * @hw: pointer to the HW structure
2259 * 2235 *
2260 * Reads the firmware semaphore register and returns true (>0) if 2236 * Reads the firmware semaphore register and returns true (>0) if
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 3031d6d16247..fc5c63f4f578 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1006,7 +1006,7 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)
1006 * e1000_get_hw_control - get control of the h/w from f/w 1006 * e1000_get_hw_control - get control of the h/w from f/w
1007 * @adapter: address of board private structure 1007 * @adapter: address of board private structure
1008 * 1008 *
1009 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit. 1009 * e1000_get_hw_control sets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1010 * For ASF and Pass Through versions of f/w this means that 1010 * For ASF and Pass Through versions of f/w this means that
1011 * the driver is loaded. For AMT version (only with 82573) 1011 * the driver is loaded. For AMT version (only with 82573)
1012 * of the f/w this means that the network i/f is open. 1012 * of the f/w this means that the network i/f is open.
@@ -1032,7 +1032,7 @@ static void e1000_get_hw_control(struct e1000_adapter *adapter)
1032 * e1000_release_hw_control - release control of the h/w to f/w 1032 * e1000_release_hw_control - release control of the h/w to f/w
1033 * @adapter: address of board private structure 1033 * @adapter: address of board private structure
1034 * 1034 *
1035 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit. 1035 * e1000_release_hw_control resets {CTRL_EXT|SWSM}:DRV_LOAD bit.
1036 * For ASF and Pass Through versions of f/w this means that the 1036 * For ASF and Pass Through versions of f/w this means that the
1037 * driver is no longer loaded. For AMT version (only with 82573) i 1037 * driver is no longer loaded. For AMT version (only with 82573) i
1038 * of the f/w this means that the network i/f is closed. 1038 * of the f/w this means that the network i/f is closed.
@@ -1241,6 +1241,11 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter)
1241 1241
1242/** 1242/**
1243 * e1000_update_itr - update the dynamic ITR value based on statistics 1243 * e1000_update_itr - update the dynamic ITR value based on statistics
1244 * @adapter: pointer to adapter
1245 * @itr_setting: current adapter->itr
1246 * @packets: the number of packets during this measurement interval
1247 * @bytes: the number of bytes during this measurement interval
1248 *
1244 * Stores a new ITR value based on packets and byte 1249 * Stores a new ITR value based on packets and byte
1245 * counts during the last interrupt. The advantage of per interrupt 1250 * counts during the last interrupt. The advantage of per interrupt
1246 * computation is faster updates and more accurate ITR for the current 1251 * computation is faster updates and more accurate ITR for the current
@@ -1250,10 +1255,6 @@ void e1000e_free_rx_resources(struct e1000_adapter *adapter)
1250 * while increasing bulk throughput. 1255 * while increasing bulk throughput.
1251 * this functionality is controlled by the InterruptThrottleRate module 1256 * this functionality is controlled by the InterruptThrottleRate module
1252 * parameter (see e1000_param.c) 1257 * parameter (see e1000_param.c)
1253 * @adapter: pointer to adapter
1254 * @itr_setting: current adapter->itr
1255 * @packets: the number of packets during this measurement interval
1256 * @bytes: the number of bytes during this measurement interval
1257 **/ 1258 **/
1258static unsigned int e1000_update_itr(struct e1000_adapter *adapter, 1259static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
1259 u16 itr_setting, int packets, 1260 u16 itr_setting, int packets,
@@ -1366,6 +1367,7 @@ set_itr_now:
1366/** 1367/**
1367 * e1000_clean - NAPI Rx polling callback 1368 * e1000_clean - NAPI Rx polling callback
1368 * @adapter: board private structure 1369 * @adapter: board private structure
1370 * @budget: amount of packets driver is allowed to process this poll
1369 **/ 1371 **/
1370static int e1000_clean(struct napi_struct *napi, int budget) 1372static int e1000_clean(struct napi_struct *napi, int budget)
1371{ 1373{
@@ -2000,7 +2002,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
2000 e1000_check_reset_block(hw)) 2002 e1000_check_reset_block(hw))
2001 return; 2003 return;
2002 2004
2003 /* managebility (AMT) is enabled */ 2005 /* manageability (AMT) is enabled */
2004 if (er32(MANC) & E1000_MANC_SMBUS_EN) 2006 if (er32(MANC) & E1000_MANC_SMBUS_EN)
2005 return; 2007 return;
2006 2008
@@ -3488,7 +3490,6 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
3488static void e1000e_disable_l1aspm(struct pci_dev *pdev) 3490static void e1000e_disable_l1aspm(struct pci_dev *pdev)
3489{ 3491{
3490 int pos; 3492 int pos;
3491 u32 cap;
3492 u16 val; 3493 u16 val;
3493 3494
3494 /* 3495 /*
@@ -3503,7 +3504,6 @@ static void e1000e_disable_l1aspm(struct pci_dev *pdev)
3503 * active. 3504 * active.
3504 */ 3505 */
3505 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 3506 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
3506 pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &cap);
3507 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); 3507 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val);
3508 if (val & 0x2) { 3508 if (val & 0x2) {
3509 dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); 3509 dev_warn(&pdev->dev, "Disabling L1 ASPM\n");
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index fc6fee112f1c..dab3c468a768 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -121,7 +121,7 @@ s32 e1000e_phy_reset_dsp(struct e1000_hw *hw)
121 * @offset: register offset to be read 121 * @offset: register offset to be read
122 * @data: pointer to the read data 122 * @data: pointer to the read data
123 * 123 *
124 * Reads the MDI control regsiter in the PHY at offset and stores the 124 * Reads the MDI control register in the PHY at offset and stores the
125 * information read to data. 125 * information read to data.
126 **/ 126 **/
127static s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) 127static s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
@@ -1172,7 +1172,7 @@ s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active)
1172} 1172}
1173 1173
1174/** 1174/**
1175 * e1000e_check_downshift - Checks whether a downshift in speed occured 1175 * e1000e_check_downshift - Checks whether a downshift in speed occurred
1176 * @hw: pointer to the HW structure 1176 * @hw: pointer to the HW structure
1177 * 1177 *
1178 * Success returns 0, Failure returns 1 1178 * Success returns 0, Failure returns 1
@@ -1388,8 +1388,8 @@ s32 e1000e_get_cable_length_m88(struct e1000_hw *hw)
1388 * 1388 *
1389 * The automatic gain control (agc) normalizes the amplitude of the 1389 * The automatic gain control (agc) normalizes the amplitude of the
1390 * received signal, adjusting for the attenuation produced by the 1390 * received signal, adjusting for the attenuation produced by the
1391 * cable. By reading the AGC registers, which reperesent the 1391 * cable. By reading the AGC registers, which represent the
1392 * cobination of course and fine gain value, the value can be put 1392 * combination of course and fine gain value, the value can be put
1393 * into a lookup table to obtain the approximate cable length 1393 * into a lookup table to obtain the approximate cable length
1394 * for each channel. 1394 * for each channel.
1395 **/ 1395 **/
@@ -1619,7 +1619,7 @@ s32 e1000e_phy_sw_reset(struct e1000_hw *hw)
1619 * Verify the reset block is not blocking us from resetting. Acquire 1619 * Verify the reset block is not blocking us from resetting. Acquire
1620 * semaphore (if necessary) and read/set/write the device control reset 1620 * semaphore (if necessary) and read/set/write the device control reset
1621 * bit in the PHY. Wait the appropriate delay time for the device to 1621 * bit in the PHY. Wait the appropriate delay time for the device to
1622 * reset and relase the semaphore (if necessary). 1622 * reset and release the semaphore (if necessary).
1623 **/ 1623 **/
1624s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw) 1624s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw)
1625{ 1625{
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 88fb53eba715..7c4ead35cfa2 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0083" 43#define DRV_VERSION "EHEA_0087"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
@@ -386,6 +386,13 @@ struct ehea_port_res {
386 386
387 387
388#define EHEA_MAX_PORTS 16 388#define EHEA_MAX_PORTS 16
389
390#define EHEA_NUM_PORTRES_FW_HANDLES 6 /* QP handle, SendCQ handle,
391 RecvCQ handle, EQ handle,
392 SendMR handle, RecvMR handle */
393#define EHEA_NUM_PORT_FW_HANDLES 1 /* EQ handle */
394#define EHEA_NUM_ADAPTER_FW_HANDLES 2 /* MR handle, NEQ handle */
395
389struct ehea_adapter { 396struct ehea_adapter {
390 u64 handle; 397 u64 handle;
391 struct of_device *ofdev; 398 struct of_device *ofdev;
@@ -405,6 +412,31 @@ struct ehea_mc_list {
405 u64 macaddr; 412 u64 macaddr;
406}; 413};
407 414
415/* kdump support */
416struct ehea_fw_handle_entry {
417 u64 adh; /* Adapter Handle */
418 u64 fwh; /* Firmware Handle */
419};
420
421struct ehea_fw_handle_array {
422 struct ehea_fw_handle_entry *arr;
423 int num_entries;
424 struct semaphore lock;
425};
426
427struct ehea_bcmc_reg_entry {
428 u64 adh; /* Adapter Handle */
429 u32 port_id; /* Logical Port Id */
430 u8 reg_type; /* Registration Type */
431 u64 macaddr;
432};
433
434struct ehea_bcmc_reg_array {
435 struct ehea_bcmc_reg_entry *arr;
436 int num_entries;
437 struct semaphore lock;
438};
439
408#define EHEA_PORT_UP 1 440#define EHEA_PORT_UP 1
409#define EHEA_PORT_DOWN 0 441#define EHEA_PORT_DOWN 0
410#define EHEA_PHY_LINK_UP 1 442#define EHEA_PHY_LINK_UP 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index c051c7e09b9a..21af674b764e 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -35,6 +35,7 @@
35#include <linux/if_ether.h> 35#include <linux/if_ether.h>
36#include <linux/notifier.h> 36#include <linux/notifier.h>
37#include <linux/reboot.h> 37#include <linux/reboot.h>
38#include <asm/kexec.h>
38 39
39#include <net/ip.h> 40#include <net/ip.h>
40 41
@@ -98,8 +99,10 @@ static int port_name_cnt;
98static LIST_HEAD(adapter_list); 99static LIST_HEAD(adapter_list);
99u64 ehea_driver_flags; 100u64 ehea_driver_flags;
100struct work_struct ehea_rereg_mr_task; 101struct work_struct ehea_rereg_mr_task;
101
102struct semaphore dlpar_mem_lock; 102struct semaphore dlpar_mem_lock;
103struct ehea_fw_handle_array ehea_fw_handles;
104struct ehea_bcmc_reg_array ehea_bcmc_regs;
105
103 106
104static int __devinit ehea_probe_adapter(struct of_device *dev, 107static int __devinit ehea_probe_adapter(struct of_device *dev,
105 const struct of_device_id *id); 108 const struct of_device_id *id);
@@ -132,6 +135,160 @@ void ehea_dump(void *adr, int len, char *msg)
132 } 135 }
133} 136}
134 137
138static void ehea_update_firmware_handles(void)
139{
140 struct ehea_fw_handle_entry *arr = NULL;
141 struct ehea_adapter *adapter;
142 int num_adapters = 0;
143 int num_ports = 0;
144 int num_portres = 0;
145 int i = 0;
146 int num_fw_handles, k, l;
147
148 /* Determine number of handles */
149 list_for_each_entry(adapter, &adapter_list, list) {
150 num_adapters++;
151
152 for (k = 0; k < EHEA_MAX_PORTS; k++) {
153 struct ehea_port *port = adapter->port[k];
154
155 if (!port || (port->state != EHEA_PORT_UP))
156 continue;
157
158 num_ports++;
159 num_portres += port->num_def_qps + port->num_add_tx_qps;
160 }
161 }
162
163 num_fw_handles = num_adapters * EHEA_NUM_ADAPTER_FW_HANDLES +
164 num_ports * EHEA_NUM_PORT_FW_HANDLES +
165 num_portres * EHEA_NUM_PORTRES_FW_HANDLES;
166
167 if (num_fw_handles) {
168 arr = kzalloc(num_fw_handles * sizeof(*arr), GFP_KERNEL);
169 if (!arr)
170 return; /* Keep the existing array */
171 } else
172 goto out_update;
173
174 list_for_each_entry(adapter, &adapter_list, list) {
175 for (k = 0; k < EHEA_MAX_PORTS; k++) {
176 struct ehea_port *port = adapter->port[k];
177
178 if (!port || (port->state != EHEA_PORT_UP))
179 continue;
180
181 for (l = 0;
182 l < port->num_def_qps + port->num_add_tx_qps;
183 l++) {
184 struct ehea_port_res *pr = &port->port_res[l];
185
186 arr[i].adh = adapter->handle;
187 arr[i++].fwh = pr->qp->fw_handle;
188 arr[i].adh = adapter->handle;
189 arr[i++].fwh = pr->send_cq->fw_handle;
190 arr[i].adh = adapter->handle;
191 arr[i++].fwh = pr->recv_cq->fw_handle;
192 arr[i].adh = adapter->handle;
193 arr[i++].fwh = pr->eq->fw_handle;
194 arr[i].adh = adapter->handle;
195 arr[i++].fwh = pr->send_mr.handle;
196 arr[i].adh = adapter->handle;
197 arr[i++].fwh = pr->recv_mr.handle;
198 }
199 arr[i].adh = adapter->handle;
200 arr[i++].fwh = port->qp_eq->fw_handle;
201 }
202
203 arr[i].adh = adapter->handle;
204 arr[i++].fwh = adapter->neq->fw_handle;
205
206 if (adapter->mr.handle) {
207 arr[i].adh = adapter->handle;
208 arr[i++].fwh = adapter->mr.handle;
209 }
210 }
211
212out_update:
213 kfree(ehea_fw_handles.arr);
214 ehea_fw_handles.arr = arr;
215 ehea_fw_handles.num_entries = i;
216}
217
218static void ehea_update_bcmc_registrations(void)
219{
220 struct ehea_bcmc_reg_entry *arr = NULL;
221 struct ehea_adapter *adapter;
222 struct ehea_mc_list *mc_entry;
223 int num_registrations = 0;
224 int i = 0;
225 int k;
226
227 /* Determine number of registrations */
228 list_for_each_entry(adapter, &adapter_list, list)
229 for (k = 0; k < EHEA_MAX_PORTS; k++) {
230 struct ehea_port *port = adapter->port[k];
231
232 if (!port || (port->state != EHEA_PORT_UP))
233 continue;
234
235 num_registrations += 2; /* Broadcast registrations */
236
237 list_for_each_entry(mc_entry, &port->mc_list->list,list)
238 num_registrations += 2;
239 }
240
241 if (num_registrations) {
242 arr = kzalloc(num_registrations * sizeof(*arr), GFP_KERNEL);
243 if (!arr)
244 return; /* Keep the existing array */
245 } else
246 goto out_update;
247
248 list_for_each_entry(adapter, &adapter_list, list) {
249 for (k = 0; k < EHEA_MAX_PORTS; k++) {
250 struct ehea_port *port = adapter->port[k];
251
252 if (!port || (port->state != EHEA_PORT_UP))
253 continue;
254
255 arr[i].adh = adapter->handle;
256 arr[i].port_id = port->logical_port_id;
257 arr[i].reg_type = EHEA_BCMC_BROADCAST |
258 EHEA_BCMC_UNTAGGED;
259 arr[i++].macaddr = port->mac_addr;
260
261 arr[i].adh = adapter->handle;
262 arr[i].port_id = port->logical_port_id;
263 arr[i].reg_type = EHEA_BCMC_BROADCAST |
264 EHEA_BCMC_VLANID_ALL;
265 arr[i++].macaddr = port->mac_addr;
266
267 list_for_each_entry(mc_entry,
268 &port->mc_list->list, list) {
269 arr[i].adh = adapter->handle;
270 arr[i].port_id = port->logical_port_id;
271 arr[i].reg_type = EHEA_BCMC_SCOPE_ALL |
272 EHEA_BCMC_MULTICAST |
273 EHEA_BCMC_UNTAGGED;
274 arr[i++].macaddr = mc_entry->macaddr;
275
276 arr[i].adh = adapter->handle;
277 arr[i].port_id = port->logical_port_id;
278 arr[i].reg_type = EHEA_BCMC_SCOPE_ALL |
279 EHEA_BCMC_MULTICAST |
280 EHEA_BCMC_VLANID_ALL;
281 arr[i++].macaddr = mc_entry->macaddr;
282 }
283 }
284 }
285
286out_update:
287 kfree(ehea_bcmc_regs.arr);
288 ehea_bcmc_regs.arr = arr;
289 ehea_bcmc_regs.num_entries = i;
290}
291
135static struct net_device_stats *ehea_get_stats(struct net_device *dev) 292static struct net_device_stats *ehea_get_stats(struct net_device *dev)
136{ 293{
137 struct ehea_port *port = netdev_priv(dev); 294 struct ehea_port *port = netdev_priv(dev);
@@ -1601,19 +1758,25 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1601 1758
1602 memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); 1759 memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
1603 1760
1761 down(&ehea_bcmc_regs.lock);
1762
1604 /* Deregister old MAC in pHYP */ 1763 /* Deregister old MAC in pHYP */
1605 ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC); 1764 ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
1606 if (ret) 1765 if (ret)
1607 goto out_free; 1766 goto out_upregs;
1608 1767
1609 port->mac_addr = cb0->port_mac_addr << 16; 1768 port->mac_addr = cb0->port_mac_addr << 16;
1610 1769
1611 /* Register new MAC in pHYP */ 1770 /* Register new MAC in pHYP */
1612 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); 1771 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
1613 if (ret) 1772 if (ret)
1614 goto out_free; 1773 goto out_upregs;
1615 1774
1616 ret = 0; 1775 ret = 0;
1776
1777out_upregs:
1778 ehea_update_bcmc_registrations();
1779 up(&ehea_bcmc_regs.lock);
1617out_free: 1780out_free:
1618 kfree(cb0); 1781 kfree(cb0);
1619out: 1782out:
@@ -1775,9 +1938,11 @@ static void ehea_set_multicast_list(struct net_device *dev)
1775 } 1938 }
1776 ehea_promiscuous(dev, 0); 1939 ehea_promiscuous(dev, 0);
1777 1940
1941 down(&ehea_bcmc_regs.lock);
1942
1778 if (dev->flags & IFF_ALLMULTI) { 1943 if (dev->flags & IFF_ALLMULTI) {
1779 ehea_allmulti(dev, 1); 1944 ehea_allmulti(dev, 1);
1780 return; 1945 goto out;
1781 } 1946 }
1782 ehea_allmulti(dev, 0); 1947 ehea_allmulti(dev, 0);
1783 1948
@@ -1803,6 +1968,8 @@ static void ehea_set_multicast_list(struct net_device *dev)
1803 1968
1804 } 1969 }
1805out: 1970out:
1971 ehea_update_bcmc_registrations();
1972 up(&ehea_bcmc_regs.lock);
1806 return; 1973 return;
1807} 1974}
1808 1975
@@ -2285,6 +2452,8 @@ static int ehea_up(struct net_device *dev)
2285 if (port->state == EHEA_PORT_UP) 2452 if (port->state == EHEA_PORT_UP)
2286 return 0; 2453 return 0;
2287 2454
2455 down(&ehea_fw_handles.lock);
2456
2288 ret = ehea_port_res_setup(port, port->num_def_qps, 2457 ret = ehea_port_res_setup(port, port->num_def_qps,
2289 port->num_add_tx_qps); 2458 port->num_add_tx_qps);
2290 if (ret) { 2459 if (ret) {
@@ -2321,8 +2490,17 @@ static int ehea_up(struct net_device *dev)
2321 } 2490 }
2322 } 2491 }
2323 2492
2324 ret = 0; 2493 down(&ehea_bcmc_regs.lock);
2494
2495 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
2496 if (ret) {
2497 ret = -EIO;
2498 goto out_free_irqs;
2499 }
2500
2325 port->state = EHEA_PORT_UP; 2501 port->state = EHEA_PORT_UP;
2502
2503 ret = 0;
2326 goto out; 2504 goto out;
2327 2505
2328out_free_irqs: 2506out_free_irqs:
@@ -2334,6 +2512,12 @@ out:
2334 if (ret) 2512 if (ret)
2335 ehea_info("Failed starting %s. ret=%i", dev->name, ret); 2513 ehea_info("Failed starting %s. ret=%i", dev->name, ret);
2336 2514
2515 ehea_update_bcmc_registrations();
2516 up(&ehea_bcmc_regs.lock);
2517
2518 ehea_update_firmware_handles();
2519 up(&ehea_fw_handles.lock);
2520
2337 return ret; 2521 return ret;
2338} 2522}
2339 2523
@@ -2382,16 +2566,27 @@ static int ehea_down(struct net_device *dev)
2382 if (port->state == EHEA_PORT_DOWN) 2566 if (port->state == EHEA_PORT_DOWN)
2383 return 0; 2567 return 0;
2384 2568
2569 down(&ehea_bcmc_regs.lock);
2385 ehea_drop_multicast_list(dev); 2570 ehea_drop_multicast_list(dev);
2571 ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
2572
2386 ehea_free_interrupts(dev); 2573 ehea_free_interrupts(dev);
2387 2574
2575 down(&ehea_fw_handles.lock);
2576
2388 port->state = EHEA_PORT_DOWN; 2577 port->state = EHEA_PORT_DOWN;
2389 2578
2579 ehea_update_bcmc_registrations();
2580 up(&ehea_bcmc_regs.lock);
2581
2390 ret = ehea_clean_all_portres(port); 2582 ret = ehea_clean_all_portres(port);
2391 if (ret) 2583 if (ret)
2392 ehea_info("Failed freeing resources for %s. ret=%i", 2584 ehea_info("Failed freeing resources for %s. ret=%i",
2393 dev->name, ret); 2585 dev->name, ret);
2394 2586
2587 ehea_update_firmware_handles();
2588 up(&ehea_fw_handles.lock);
2589
2395 return ret; 2590 return ret;
2396} 2591}
2397 2592
@@ -2920,19 +3115,12 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
2920 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; 3115 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
2921 3116
2922 INIT_WORK(&port->reset_task, ehea_reset_port); 3117 INIT_WORK(&port->reset_task, ehea_reset_port);
2923
2924 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
2925 if (ret) {
2926 ret = -EIO;
2927 goto out_unreg_port;
2928 }
2929
2930 ehea_set_ethtool_ops(dev); 3118 ehea_set_ethtool_ops(dev);
2931 3119
2932 ret = register_netdev(dev); 3120 ret = register_netdev(dev);
2933 if (ret) { 3121 if (ret) {
2934 ehea_error("register_netdev failed. ret=%d", ret); 3122 ehea_error("register_netdev failed. ret=%d", ret);
2935 goto out_dereg_bc; 3123 goto out_unreg_port;
2936 } 3124 }
2937 3125
2938 port->lro_max_aggr = lro_max_aggr; 3126 port->lro_max_aggr = lro_max_aggr;
@@ -2949,9 +3137,6 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
2949 3137
2950 return port; 3138 return port;
2951 3139
2952out_dereg_bc:
2953 ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
2954
2955out_unreg_port: 3140out_unreg_port:
2956 ehea_unregister_port(port); 3141 ehea_unregister_port(port);
2957 3142
@@ -2971,7 +3156,6 @@ static void ehea_shutdown_single_port(struct ehea_port *port)
2971{ 3156{
2972 unregister_netdev(port->netdev); 3157 unregister_netdev(port->netdev);
2973 ehea_unregister_port(port); 3158 ehea_unregister_port(port);
2974 ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
2975 kfree(port->mc_list); 3159 kfree(port->mc_list);
2976 free_netdev(port->netdev); 3160 free_netdev(port->netdev);
2977 port->adapter->active_ports--; 3161 port->adapter->active_ports--;
@@ -3014,7 +3198,6 @@ static int ehea_setup_ports(struct ehea_adapter *adapter)
3014 3198
3015 i++; 3199 i++;
3016 }; 3200 };
3017
3018 return 0; 3201 return 0;
3019} 3202}
3020 3203
@@ -3159,6 +3342,7 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
3159 ehea_error("Invalid ibmebus device probed"); 3342 ehea_error("Invalid ibmebus device probed");
3160 return -EINVAL; 3343 return -EINVAL;
3161 } 3344 }
3345 down(&ehea_fw_handles.lock);
3162 3346
3163 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); 3347 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
3164 if (!adapter) { 3348 if (!adapter) {
@@ -3239,7 +3423,10 @@ out_kill_eq:
3239 3423
3240out_free_ad: 3424out_free_ad:
3241 kfree(adapter); 3425 kfree(adapter);
3426
3242out: 3427out:
3428 ehea_update_firmware_handles();
3429 up(&ehea_fw_handles.lock);
3243 return ret; 3430 return ret;
3244} 3431}
3245 3432
@@ -3258,18 +3445,41 @@ static int __devexit ehea_remove(struct of_device *dev)
3258 3445
3259 flush_scheduled_work(); 3446 flush_scheduled_work();
3260 3447
3448 down(&ehea_fw_handles.lock);
3449
3261 ibmebus_free_irq(adapter->neq->attr.ist1, adapter); 3450 ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
3262 tasklet_kill(&adapter->neq_tasklet); 3451 tasklet_kill(&adapter->neq_tasklet);
3263 3452
3264 ehea_destroy_eq(adapter->neq); 3453 ehea_destroy_eq(adapter->neq);
3265 ehea_remove_adapter_mr(adapter); 3454 ehea_remove_adapter_mr(adapter);
3266 list_del(&adapter->list); 3455 list_del(&adapter->list);
3267
3268 kfree(adapter); 3456 kfree(adapter);
3269 3457
3458 ehea_update_firmware_handles();
3459 up(&ehea_fw_handles.lock);
3460
3270 return 0; 3461 return 0;
3271} 3462}
3272 3463
3464void ehea_crash_handler(void)
3465{
3466 int i;
3467
3468 if (ehea_fw_handles.arr)
3469 for (i = 0; i < ehea_fw_handles.num_entries; i++)
3470 ehea_h_free_resource(ehea_fw_handles.arr[i].adh,
3471 ehea_fw_handles.arr[i].fwh,
3472 FORCE_FREE);
3473
3474 if (ehea_bcmc_regs.arr)
3475 for (i = 0; i < ehea_bcmc_regs.num_entries; i++)
3476 ehea_h_reg_dereg_bcmc(ehea_bcmc_regs.arr[i].adh,
3477 ehea_bcmc_regs.arr[i].port_id,
3478 ehea_bcmc_regs.arr[i].reg_type,
3479 ehea_bcmc_regs.arr[i].macaddr,
3480 0, H_DEREG_BCMC);
3481}
3482
3273static int ehea_reboot_notifier(struct notifier_block *nb, 3483static int ehea_reboot_notifier(struct notifier_block *nb,
3274 unsigned long action, void *unused) 3484 unsigned long action, void *unused)
3275{ 3485{
@@ -3330,7 +3540,12 @@ int __init ehea_module_init(void)
3330 3540
3331 3541
3332 INIT_WORK(&ehea_rereg_mr_task, ehea_rereg_mrs); 3542 INIT_WORK(&ehea_rereg_mr_task, ehea_rereg_mrs);
3543 memset(&ehea_fw_handles, 0, sizeof(ehea_fw_handles));
3544 memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs));
3545
3333 sema_init(&dlpar_mem_lock, 1); 3546 sema_init(&dlpar_mem_lock, 1);
3547 sema_init(&ehea_fw_handles.lock, 1);
3548 sema_init(&ehea_bcmc_regs.lock, 1);
3334 3549
3335 ret = check_module_parm(); 3550 ret = check_module_parm();
3336 if (ret) 3551 if (ret)
@@ -3340,12 +3555,18 @@ int __init ehea_module_init(void)
3340 if (ret) 3555 if (ret)
3341 goto out; 3556 goto out;
3342 3557
3343 register_reboot_notifier(&ehea_reboot_nb); 3558 ret = register_reboot_notifier(&ehea_reboot_nb);
3559 if (ret)
3560 ehea_info("failed registering reboot notifier");
3561
3562 ret = crash_shutdown_register(&ehea_crash_handler);
3563 if (ret)
3564 ehea_info("failed registering crash handler");
3344 3565
3345 ret = ibmebus_register_driver(&ehea_driver); 3566 ret = ibmebus_register_driver(&ehea_driver);
3346 if (ret) { 3567 if (ret) {
3347 ehea_error("failed registering eHEA device driver on ebus"); 3568 ehea_error("failed registering eHEA device driver on ebus");
3348 goto out; 3569 goto out2;
3349 } 3570 }
3350 3571
3351 ret = driver_create_file(&ehea_driver.driver, 3572 ret = driver_create_file(&ehea_driver.driver,
@@ -3353,21 +3574,33 @@ int __init ehea_module_init(void)
3353 if (ret) { 3574 if (ret) {
3354 ehea_error("failed to register capabilities attribute, ret=%d", 3575 ehea_error("failed to register capabilities attribute, ret=%d",
3355 ret); 3576 ret);
3356 unregister_reboot_notifier(&ehea_reboot_nb); 3577 goto out3;
3357 ibmebus_unregister_driver(&ehea_driver);
3358 goto out;
3359 } 3578 }
3360 3579
3580 return ret;
3581
3582out3:
3583 ibmebus_unregister_driver(&ehea_driver);
3584out2:
3585 unregister_reboot_notifier(&ehea_reboot_nb);
3586 crash_shutdown_unregister(&ehea_crash_handler);
3361out: 3587out:
3362 return ret; 3588 return ret;
3363} 3589}
3364 3590
3365static void __exit ehea_module_exit(void) 3591static void __exit ehea_module_exit(void)
3366{ 3592{
3593 int ret;
3594
3367 flush_scheduled_work(); 3595 flush_scheduled_work();
3368 driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); 3596 driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities);
3369 ibmebus_unregister_driver(&ehea_driver); 3597 ibmebus_unregister_driver(&ehea_driver);
3370 unregister_reboot_notifier(&ehea_reboot_nb); 3598 unregister_reboot_notifier(&ehea_reboot_nb);
3599 ret = crash_shutdown_unregister(&ehea_crash_handler);
3600 if (ret)
3601 ehea_info("failed unregistering crash handler");
3602 kfree(ehea_fw_handles.arr);
3603 kfree(ehea_bcmc_regs.arr);
3371 ehea_destroy_busmap(); 3604 ehea_destroy_busmap();
3372} 3605}
3373 3606
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 42d94edeee26..af869cf9ae7d 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -946,16 +946,11 @@ static int fs_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
946{ 946{
947 struct fs_enet_private *fep = netdev_priv(dev); 947 struct fs_enet_private *fep = netdev_priv(dev);
948 struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&rq->ifr_data; 948 struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&rq->ifr_data;
949 unsigned long flags;
950 int rc;
951 949
952 if (!netif_running(dev)) 950 if (!netif_running(dev))
953 return -EINVAL; 951 return -EINVAL;
954 952
955 spin_lock_irqsave(&fep->lock, flags); 953 return phy_mii_ioctl(fep->phydev, mii, cmd);
956 rc = phy_mii_ioctl(fep->phydev, mii, cmd);
957 spin_unlock_irqrestore(&fep->lock, flags);
958 return rc;
959} 954}
960 955
961extern int fs_mii_connect(struct net_device *dev); 956extern int fs_mii_connect(struct net_device *dev);
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 4244fc282f21..718cf77e345a 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -605,7 +605,7 @@ void stop_gfar(struct net_device *dev)
605 605
606 free_skb_resources(priv); 606 free_skb_resources(priv);
607 607
608 dma_free_coherent(NULL, 608 dma_free_coherent(&dev->dev,
609 sizeof(struct txbd8)*priv->tx_ring_size 609 sizeof(struct txbd8)*priv->tx_ring_size
610 + sizeof(struct rxbd8)*priv->rx_ring_size, 610 + sizeof(struct rxbd8)*priv->rx_ring_size,
611 priv->tx_bd_base, 611 priv->tx_bd_base,
@@ -626,7 +626,7 @@ static void free_skb_resources(struct gfar_private *priv)
626 for (i = 0; i < priv->tx_ring_size; i++) { 626 for (i = 0; i < priv->tx_ring_size; i++) {
627 627
628 if (priv->tx_skbuff[i]) { 628 if (priv->tx_skbuff[i]) {
629 dma_unmap_single(NULL, txbdp->bufPtr, 629 dma_unmap_single(&priv->dev->dev, txbdp->bufPtr,
630 txbdp->length, 630 txbdp->length,
631 DMA_TO_DEVICE); 631 DMA_TO_DEVICE);
632 dev_kfree_skb_any(priv->tx_skbuff[i]); 632 dev_kfree_skb_any(priv->tx_skbuff[i]);
@@ -643,7 +643,7 @@ static void free_skb_resources(struct gfar_private *priv)
643 if(priv->rx_skbuff != NULL) { 643 if(priv->rx_skbuff != NULL) {
644 for (i = 0; i < priv->rx_ring_size; i++) { 644 for (i = 0; i < priv->rx_ring_size; i++) {
645 if (priv->rx_skbuff[i]) { 645 if (priv->rx_skbuff[i]) {
646 dma_unmap_single(NULL, rxbdp->bufPtr, 646 dma_unmap_single(&priv->dev->dev, rxbdp->bufPtr,
647 priv->rx_buffer_size, 647 priv->rx_buffer_size,
648 DMA_FROM_DEVICE); 648 DMA_FROM_DEVICE);
649 649
@@ -708,7 +708,7 @@ int startup_gfar(struct net_device *dev)
708 gfar_write(&regs->imask, IMASK_INIT_CLEAR); 708 gfar_write(&regs->imask, IMASK_INIT_CLEAR);
709 709
710 /* Allocate memory for the buffer descriptors */ 710 /* Allocate memory for the buffer descriptors */
711 vaddr = (unsigned long) dma_alloc_coherent(NULL, 711 vaddr = (unsigned long) dma_alloc_coherent(&dev->dev,
712 sizeof (struct txbd8) * priv->tx_ring_size + 712 sizeof (struct txbd8) * priv->tx_ring_size +
713 sizeof (struct rxbd8) * priv->rx_ring_size, 713 sizeof (struct rxbd8) * priv->rx_ring_size,
714 &addr, GFP_KERNEL); 714 &addr, GFP_KERNEL);
@@ -919,7 +919,7 @@ err_irq_fail:
919rx_skb_fail: 919rx_skb_fail:
920 free_skb_resources(priv); 920 free_skb_resources(priv);
921tx_skb_fail: 921tx_skb_fail:
922 dma_free_coherent(NULL, 922 dma_free_coherent(&dev->dev,
923 sizeof(struct txbd8)*priv->tx_ring_size 923 sizeof(struct txbd8)*priv->tx_ring_size
924 + sizeof(struct rxbd8)*priv->rx_ring_size, 924 + sizeof(struct rxbd8)*priv->rx_ring_size,
925 priv->tx_bd_base, 925 priv->tx_bd_base,
@@ -1053,7 +1053,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1053 1053
1054 /* Set buffer length and pointer */ 1054 /* Set buffer length and pointer */
1055 txbdp->length = skb->len; 1055 txbdp->length = skb->len;
1056 txbdp->bufPtr = dma_map_single(NULL, skb->data, 1056 txbdp->bufPtr = dma_map_single(&dev->dev, skb->data,
1057 skb->len, DMA_TO_DEVICE); 1057 skb->len, DMA_TO_DEVICE);
1058 1058
1059 /* Save the skb pointer so we can free it later */ 1059 /* Save the skb pointer so we can free it later */
@@ -1332,7 +1332,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1332 */ 1332 */
1333 skb_reserve(skb, alignamount); 1333 skb_reserve(skb, alignamount);
1334 1334
1335 bdp->bufPtr = dma_map_single(NULL, skb->data, 1335 bdp->bufPtr = dma_map_single(&dev->dev, skb->data,
1336 priv->rx_buffer_size, DMA_FROM_DEVICE); 1336 priv->rx_buffer_size, DMA_FROM_DEVICE);
1337 1337
1338 bdp->length = 0; 1338 bdp->length = 0;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index bff280eff5e3..6a1f23092099 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -439,7 +439,7 @@ static int igb_request_irq(struct igb_adapter *adapter)
439 err = igb_request_msix(adapter); 439 err = igb_request_msix(adapter);
440 if (!err) { 440 if (!err) {
441 /* enable IAM, auto-mask, 441 /* enable IAM, auto-mask,
442 * DO NOT USE EIAME or IAME in legacy mode */ 442 * DO NOT USE EIAM or IAM in legacy mode */
443 wr32(E1000_IAM, IMS_ENABLE_MASK); 443 wr32(E1000_IAM, IMS_ENABLE_MASK);
444 goto request_done; 444 goto request_done;
445 } 445 }
@@ -465,14 +465,9 @@ static int igb_request_irq(struct igb_adapter *adapter)
465 err = request_irq(adapter->pdev->irq, &igb_intr, IRQF_SHARED, 465 err = request_irq(adapter->pdev->irq, &igb_intr, IRQF_SHARED,
466 netdev->name, netdev); 466 netdev->name, netdev);
467 467
468 if (err) { 468 if (err)
469 dev_err(&adapter->pdev->dev, "Error %d getting interrupt\n", 469 dev_err(&adapter->pdev->dev, "Error %d getting interrupt\n",
470 err); 470 err);
471 goto request_done;
472 }
473
474 /* enable IAM, auto-mask */
475 wr32(E1000_IAM, IMS_ENABLE_MASK);
476 471
477request_done: 472request_done:
478 return err; 473 return err;
@@ -821,7 +816,8 @@ void igb_reset(struct igb_adapter *adapter)
821 wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE); 816 wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
822 817
823 igb_reset_adaptive(&adapter->hw); 818 igb_reset_adaptive(&adapter->hw);
824 adapter->hw.phy.ops.get_phy_info(&adapter->hw); 819 if (adapter->hw.phy.ops.get_phy_info)
820 adapter->hw.phy.ops.get_phy_info(&adapter->hw);
825} 821}
826 822
827/** 823/**
@@ -2057,7 +2053,8 @@ static void igb_set_multi(struct net_device *netdev)
2057static void igb_update_phy_info(unsigned long data) 2053static void igb_update_phy_info(unsigned long data)
2058{ 2054{
2059 struct igb_adapter *adapter = (struct igb_adapter *) data; 2055 struct igb_adapter *adapter = (struct igb_adapter *) data;
2060 adapter->hw.phy.ops.get_phy_info(&adapter->hw); 2056 if (adapter->hw.phy.ops.get_phy_info)
2057 adapter->hw.phy.ops.get_phy_info(&adapter->hw);
2061} 2058}
2062 2059
2063/** 2060/**
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index 53a9fd086f96..75f3a68ee354 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -67,6 +67,7 @@ static struct ixgb_stats ixgb_gstrings_stats[] = {
67 {"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)}, 67 {"rx_over_errors", IXGB_STAT(net_stats.rx_over_errors)},
68 {"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)}, 68 {"rx_crc_errors", IXGB_STAT(net_stats.rx_crc_errors)},
69 {"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)}, 69 {"rx_frame_errors", IXGB_STAT(net_stats.rx_frame_errors)},
70 {"rx_no_buffer_count", IXGB_STAT(stats.rnbc)},
70 {"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)}, 71 {"rx_fifo_errors", IXGB_STAT(net_stats.rx_fifo_errors)},
71 {"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)}, 72 {"rx_missed_errors", IXGB_STAT(net_stats.rx_missed_errors)},
72 {"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)}, 73 {"tx_aborted_errors", IXGB_STAT(net_stats.tx_aborted_errors)},
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 81bf005ff280..1d210ed46130 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -148,7 +148,7 @@ static void macb_handle_link_change(struct net_device *dev)
148 148
149 if (phydev->duplex) 149 if (phydev->duplex)
150 reg |= MACB_BIT(FD); 150 reg |= MACB_BIT(FD);
151 if (phydev->speed) 151 if (phydev->speed == SPEED_100)
152 reg |= MACB_BIT(SPD); 152 reg |= MACB_BIT(SPD);
153 153
154 macb_writel(bp, NCFGR, reg); 154 macb_writel(bp, NCFGR, reg);
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index e98ce1e4965b..d11ba61baa4f 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -1616,12 +1616,13 @@ static int niu_enable_alt_mac(struct niu *np, int index, int on)
1616 if (index >= niu_num_alt_addr(np)) 1616 if (index >= niu_num_alt_addr(np))
1617 return -EINVAL; 1617 return -EINVAL;
1618 1618
1619 if (np->flags & NIU_FLAGS_XMAC) 1619 if (np->flags & NIU_FLAGS_XMAC) {
1620 reg = XMAC_ADDR_CMPEN; 1620 reg = XMAC_ADDR_CMPEN;
1621 else 1621 mask = 1 << index;
1622 } else {
1622 reg = BMAC_ADDR_CMPEN; 1623 reg = BMAC_ADDR_CMPEN;
1623 1624 mask = 1 << (index + 1);
1624 mask = 1 << index; 1625 }
1625 1626
1626 val = nr64_mac(reg); 1627 val = nr64_mac(reg);
1627 if (on) 1628 if (on)
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 0e8626adc573..59dc05fcd371 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -499,7 +499,7 @@
499#define BMAC_ADDR2 0x00110UL 499#define BMAC_ADDR2 0x00110UL
500#define BMAC_ADDR2_ADDR2 0x000000000000ffffULL 500#define BMAC_ADDR2_ADDR2 0x000000000000ffffULL
501 501
502#define BMAC_NUM_ALT_ADDR 7 502#define BMAC_NUM_ALT_ADDR 6
503 503
504#define BMAC_ALT_ADDR0(NUM) (0x00118UL + (NUM)*0x18UL) 504#define BMAC_ALT_ADDR0(NUM) (0x00118UL + (NUM)*0x18UL)
505#define BMAC_ALT_ADDR0_ADDR0 0x000000000000ffffULL 505#define BMAC_ALT_ADDR0_ADDR0 0x000000000000ffffULL
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 6323988dfa1d..fd8158a86f64 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -590,6 +590,13 @@ static int pcnet_config(struct pcmcia_device *link)
590 dev->if_port = 0; 590 dev->if_port = 0;
591 } 591 }
592 592
593 if ((link->conf.ConfigBase == 0x03c0)
594 && (link->manf_id == 0x149) && (link->card_id = 0xc1ab)) {
595 printk(KERN_INFO "pcnet_cs: this is an AX88190 card!\n");
596 printk(KERN_INFO "pcnet_cs: use axnet_cs instead.\n");
597 goto failed;
598 }
599
593 local_hw_info = get_hwinfo(link); 600 local_hw_info = get_hwinfo(link);
594 if (local_hw_info == NULL) 601 if (local_hw_info == NULL)
595 local_hw_info = get_prom(link); 602 local_hw_info = get_prom(link);
@@ -1567,12 +1574,11 @@ static struct pcmcia_device_id pcnet_ids[] = {
1567 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0145), 1574 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0145),
1568 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x0230), 1575 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x0230),
1569 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x4530), 1576 PCMCIA_DEVICE_MANF_CARD(0x0149, 0x4530),
1570/* PCMCIA_DEVICE_MANF_CARD(0x0149, 0xc1ab), conflict with axnet_cs */ 1577 PCMCIA_DEVICE_MANF_CARD(0x0149, 0xc1ab),
1571 PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0110), 1578 PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0110),
1572 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x2328), 1579 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x2328),
1573 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x8041), 1580 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x8041),
1574 PCMCIA_DEVICE_MANF_CARD(0x0213, 0x2452), 1581 PCMCIA_DEVICE_MANF_CARD(0x0213, 0x2452),
1575/* PCMCIA_DEVICE_MANF_CARD(0x021b, 0x0202), conflict with axnet_cs */
1576 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0300), 1582 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0300),
1577 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0307), 1583 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0307),
1578 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030a), 1584 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030a),
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6e9f619c491f..963630c65ca9 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -49,13 +49,13 @@ int mdiobus_register(struct mii_bus *bus)
49 int i; 49 int i;
50 int err = 0; 50 int err = 0;
51 51
52 mutex_init(&bus->mdio_lock);
53
54 if (NULL == bus || NULL == bus->name || 52 if (NULL == bus || NULL == bus->name ||
55 NULL == bus->read || 53 NULL == bus->read ||
56 NULL == bus->write) 54 NULL == bus->write)
57 return -EINVAL; 55 return -EINVAL;
58 56
57 mutex_init(&bus->mdio_lock);
58
59 if (bus->reset) 59 if (bus->reset)
60 bus->reset(bus); 60 bus->reset(bus);
61 61
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 750d2a99cb4f..daf5abab9534 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -2690,6 +2690,7 @@ int gelic_wl_driver_probe(struct gelic_card *card)
2690 return -ENOMEM; 2690 return -ENOMEM;
2691 2691
2692 /* setup net_device structure */ 2692 /* setup net_device structure */
2693 SET_NETDEV_DEV(netdev, &card->dev->core);
2693 gelic_wl_setup_netdev_ops(netdev); 2694 gelic_wl_setup_netdev_ops(netdev);
2694 2695
2695 /* setup some of net_device and register it */ 2696 /* setup some of net_device and register it */
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 202fdf356621..20745fd4e973 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -1633,13 +1633,18 @@ static inline void sis190_init_rxfilter(struct net_device *dev)
1633static int __devinit sis190_get_mac_addr(struct pci_dev *pdev, 1633static int __devinit sis190_get_mac_addr(struct pci_dev *pdev,
1634 struct net_device *dev) 1634 struct net_device *dev)
1635{ 1635{
1636 u8 from; 1636 int rc;
1637
1638 rc = sis190_get_mac_addr_from_eeprom(pdev, dev);
1639 if (rc < 0) {
1640 u8 reg;
1637 1641
1638 pci_read_config_byte(pdev, 0x73, &from); 1642 pci_read_config_byte(pdev, 0x73, &reg);
1639 1643
1640 return (from & 0x00000001) ? 1644 if (reg & 0x00000001)
1641 sis190_get_mac_addr_from_apc(pdev, dev) : 1645 rc = sis190_get_mac_addr_from_apc(pdev, dev);
1642 sis190_get_mac_addr_from_eeprom(pdev, dev); 1646 }
1647 return rc;
1643} 1648}
1644 1649
1645static void sis190_set_speed_auto(struct net_device *dev) 1650static void sis190_set_speed_auto(struct net_device *dev)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 9a6295909e43..54c662690f65 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -572,8 +572,9 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
572 default: 572 default:
573 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ 573 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
574 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; 574 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
575
575 /* turn off the Rx LED (LED_RX) */ 576 /* turn off the Rx LED (LED_RX) */
576 ledover &= ~PHY_M_LED_MO_RX; 577 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
577 } 578 }
578 579
579 if (hw->chip_id == CHIP_ID_YUKON_EC_U && 580 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
@@ -602,7 +603,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
602 603
603 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { 604 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
604 /* turn on 100 Mbps LED (LED_LINK100) */ 605 /* turn on 100 Mbps LED (LED_LINK100) */
605 ledover |= PHY_M_LED_MO_100; 606 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
606 } 607 }
607 608
608 if (ledover) 609 if (ledover)
@@ -3322,82 +3323,80 @@ static void sky2_set_multicast(struct net_device *dev)
3322/* Can have one global because blinking is controlled by 3323/* Can have one global because blinking is controlled by
3323 * ethtool and that is always under RTNL mutex 3324 * ethtool and that is always under RTNL mutex
3324 */ 3325 */
3325static void sky2_led(struct sky2_hw *hw, unsigned port, int on) 3326static void sky2_led(struct sky2_port *sky2, enum led_mode mode)
3326{ 3327{
3327 u16 pg; 3328 struct sky2_hw *hw = sky2->hw;
3329 unsigned port = sky2->port;
3328 3330
3329 switch (hw->chip_id) { 3331 spin_lock_bh(&sky2->phy_lock);
3330 case CHIP_ID_YUKON_XL: 3332 if (hw->chip_id == CHIP_ID_YUKON_EC_U ||
3333 hw->chip_id == CHIP_ID_YUKON_EX ||
3334 hw->chip_id == CHIP_ID_YUKON_SUPR) {
3335 u16 pg;
3331 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); 3336 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
3332 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); 3337 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
3333 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
3334 on ? (PHY_M_LEDC_LOS_CTRL(1) |
3335 PHY_M_LEDC_INIT_CTRL(7) |
3336 PHY_M_LEDC_STA1_CTRL(7) |
3337 PHY_M_LEDC_STA0_CTRL(7))
3338 : 0);
3339 3338
3340 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 3339 switch (mode) {
3341 break; 3340 case MO_LED_OFF:
3341 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
3342 PHY_M_LEDC_LOS_CTRL(8) |
3343 PHY_M_LEDC_INIT_CTRL(8) |
3344 PHY_M_LEDC_STA1_CTRL(8) |
3345 PHY_M_LEDC_STA0_CTRL(8));
3346 break;
3347 case MO_LED_ON:
3348 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
3349 PHY_M_LEDC_LOS_CTRL(9) |
3350 PHY_M_LEDC_INIT_CTRL(9) |
3351 PHY_M_LEDC_STA1_CTRL(9) |
3352 PHY_M_LEDC_STA0_CTRL(9));
3353 break;
3354 case MO_LED_BLINK:
3355 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
3356 PHY_M_LEDC_LOS_CTRL(0xa) |
3357 PHY_M_LEDC_INIT_CTRL(0xa) |
3358 PHY_M_LEDC_STA1_CTRL(0xa) |
3359 PHY_M_LEDC_STA0_CTRL(0xa));
3360 break;
3361 case MO_LED_NORM:
3362 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
3363 PHY_M_LEDC_LOS_CTRL(1) |
3364 PHY_M_LEDC_INIT_CTRL(8) |
3365 PHY_M_LEDC_STA1_CTRL(7) |
3366 PHY_M_LEDC_STA0_CTRL(7));
3367 }
3342 3368
3343 default: 3369 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
3344 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); 3370 } else
3345 gm_phy_write(hw, port, PHY_MARV_LED_OVER, 3371 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
3346 on ? PHY_M_LED_ALL : 0); 3372 PHY_M_LED_MO_DUP(mode) |
3347 } 3373 PHY_M_LED_MO_10(mode) |
3374 PHY_M_LED_MO_100(mode) |
3375 PHY_M_LED_MO_1000(mode) |
3376 PHY_M_LED_MO_RX(mode) |
3377 PHY_M_LED_MO_TX(mode));
3378
3379 spin_unlock_bh(&sky2->phy_lock);
3348} 3380}
3349 3381
3350/* blink LED's for finding board */ 3382/* blink LED's for finding board */
3351static int sky2_phys_id(struct net_device *dev, u32 data) 3383static int sky2_phys_id(struct net_device *dev, u32 data)
3352{ 3384{
3353 struct sky2_port *sky2 = netdev_priv(dev); 3385 struct sky2_port *sky2 = netdev_priv(dev);
3354 struct sky2_hw *hw = sky2->hw; 3386 unsigned int i;
3355 unsigned port = sky2->port;
3356 u16 ledctrl, ledover = 0;
3357 long ms;
3358 int interrupted;
3359 int onoff = 1;
3360 3387
3361 if (!data || data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)) 3388 if (data == 0)
3362 ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT); 3389 data = UINT_MAX;
3363 else
3364 ms = data * 1000;
3365
3366 /* save initial values */
3367 spin_lock_bh(&sky2->phy_lock);
3368 if (hw->chip_id == CHIP_ID_YUKON_XL) {
3369 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
3370 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
3371 ledctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
3372 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
3373 } else {
3374 ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL);
3375 ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER);
3376 }
3377
3378 interrupted = 0;
3379 while (!interrupted && ms > 0) {
3380 sky2_led(hw, port, onoff);
3381 onoff = !onoff;
3382
3383 spin_unlock_bh(&sky2->phy_lock);
3384 interrupted = msleep_interruptible(250);
3385 spin_lock_bh(&sky2->phy_lock);
3386
3387 ms -= 250;
3388 }
3389 3390
3390 /* resume regularly scheduled programming */ 3391 for (i = 0; i < data; i++) {
3391 if (hw->chip_id == CHIP_ID_YUKON_XL) { 3392 sky2_led(sky2, MO_LED_ON);
3392 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); 3393 if (msleep_interruptible(500))
3393 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); 3394 break;
3394 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ledctrl); 3395 sky2_led(sky2, MO_LED_OFF);
3395 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 3396 if (msleep_interruptible(500))
3396 } else { 3397 break;
3397 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
3398 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
3399 } 3398 }
3400 spin_unlock_bh(&sky2->phy_lock); 3399 sky2_led(sky2, MO_LED_NORM);
3401 3400
3402 return 0; 3401 return 0;
3403} 3402}
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 5ab5c1c7c5aa..7bb3ba9bcbd8 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1318,18 +1318,21 @@ enum {
1318 BLINK_670MS = 4,/* 670 ms */ 1318 BLINK_670MS = 4,/* 670 ms */
1319}; 1319};
1320 1320
1321/**** PHY_MARV_LED_OVER 16 bit r/w LED control */ 1321/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/
1322enum { 1322#define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */
1323 PHY_M_LED_MO_DUP = 3<<10,/* Bit 11..10: Duplex */ 1323
1324 PHY_M_LED_MO_10 = 3<<8, /* Bit 9.. 8: Link 10 */ 1324#define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */
1325 PHY_M_LED_MO_100 = 3<<6, /* Bit 7.. 6: Link 100 */ 1325#define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */
1326 PHY_M_LED_MO_1000 = 3<<4, /* Bit 5.. 4: Link 1000 */ 1326#define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */
1327 PHY_M_LED_MO_RX = 3<<2, /* Bit 3.. 2: Rx */ 1327#define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */
1328 PHY_M_LED_MO_TX = 3<<0, /* Bit 1.. 0: Tx */ 1328#define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */
1329 1329#define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */
1330 PHY_M_LED_ALL = PHY_M_LED_MO_DUP | PHY_M_LED_MO_10 1330
1331 | PHY_M_LED_MO_100 | PHY_M_LED_MO_1000 1331enum led_mode {
1332 | PHY_M_LED_MO_RX, 1332 MO_LED_NORM = 0,
1333 MO_LED_BLINK = 1,
1334 MO_LED_OFF = 2,
1335 MO_LED_ON = 3,
1333}; 1336};
1334 1337
1335/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ 1338/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index db606b603884..26ffb67f1da2 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -8781,7 +8781,7 @@ static int tg3_phys_id(struct net_device *dev, u32 data)
8781 return -EAGAIN; 8781 return -EAGAIN;
8782 8782
8783 if (data == 0) 8783 if (data == 0)
8784 data = 2; 8784 data = UINT_MAX / 2;
8785 8785
8786 for (i = 0; i < (data * 2); i++) { 8786 for (i = 0; i < (data * 2); i++) {
8787 if ((i % 2) == 0) 8787 if ((i % 2) == 0)
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 3af5b92b48c8..0166407d7061 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -1400,7 +1400,7 @@ static void TLan_SetMulticastList( struct net_device *dev )
1400 * 1400 *
1401 **************************************************************/ 1401 **************************************************************/
1402 1402
1403u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int ) 1403static u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
1404{ 1404{
1405 /* printk( "TLAN: Invalid interrupt on %s.\n", dev->name ); */ 1405 /* printk( "TLAN: Invalid interrupt on %s.\n", dev->name ); */
1406 return 0; 1406 return 0;
@@ -1432,7 +1432,7 @@ u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
1432 * 1432 *
1433 **************************************************************/ 1433 **************************************************************/
1434 1434
1435u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int ) 1435static u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
1436{ 1436{
1437 TLanPrivateInfo *priv = netdev_priv(dev); 1437 TLanPrivateInfo *priv = netdev_priv(dev);
1438 int eoc = 0; 1438 int eoc = 0;
@@ -1518,7 +1518,7 @@ u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
1518 * 1518 *
1519 **************************************************************/ 1519 **************************************************************/
1520 1520
1521u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int ) 1521static u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
1522{ 1522{
1523 TLan_ReadAndClearStats( dev, TLAN_RECORD ); 1523 TLan_ReadAndClearStats( dev, TLAN_RECORD );
1524 1524
@@ -1554,7 +1554,7 @@ u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
1554 * 1554 *
1555 **************************************************************/ 1555 **************************************************************/
1556 1556
1557u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int ) 1557static u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
1558{ 1558{
1559 TLanPrivateInfo *priv = netdev_priv(dev); 1559 TLanPrivateInfo *priv = netdev_priv(dev);
1560 u32 ack = 0; 1560 u32 ack = 0;
@@ -1689,7 +1689,7 @@ u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
1689 * 1689 *
1690 **************************************************************/ 1690 **************************************************************/
1691 1691
1692u32 TLan_HandleDummy( struct net_device *dev, u16 host_int ) 1692static u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
1693{ 1693{
1694 printk( "TLAN: Test interrupt on %s.\n", dev->name ); 1694 printk( "TLAN: Test interrupt on %s.\n", dev->name );
1695 return 1; 1695 return 1;
@@ -1719,7 +1719,7 @@ u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
1719 * 1719 *
1720 **************************************************************/ 1720 **************************************************************/
1721 1721
1722u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int ) 1722static u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
1723{ 1723{
1724 TLanPrivateInfo *priv = netdev_priv(dev); 1724 TLanPrivateInfo *priv = netdev_priv(dev);
1725 TLanList *head_list; 1725 TLanList *head_list;
@@ -1767,7 +1767,7 @@ u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
1767 * 1767 *
1768 **************************************************************/ 1768 **************************************************************/
1769 1769
1770u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int ) 1770static u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
1771{ 1771{
1772 TLanPrivateInfo *priv = netdev_priv(dev); 1772 TLanPrivateInfo *priv = netdev_priv(dev);
1773 u32 ack; 1773 u32 ack;
@@ -1842,7 +1842,7 @@ u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
1842 * 1842 *
1843 **************************************************************/ 1843 **************************************************************/
1844 1844
1845u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int ) 1845static u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
1846{ 1846{
1847 TLanPrivateInfo *priv = netdev_priv(dev); 1847 TLanPrivateInfo *priv = netdev_priv(dev);
1848 dma_addr_t head_list_phys; 1848 dma_addr_t head_list_phys;
@@ -1902,7 +1902,7 @@ u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
1902 * 1902 *
1903 **************************************************************/ 1903 **************************************************************/
1904 1904
1905void TLan_Timer( unsigned long data ) 1905static void TLan_Timer( unsigned long data )
1906{ 1906{
1907 struct net_device *dev = (struct net_device *) data; 1907 struct net_device *dev = (struct net_device *) data;
1908 TLanPrivateInfo *priv = netdev_priv(dev); 1908 TLanPrivateInfo *priv = netdev_priv(dev);
@@ -1983,7 +1983,7 @@ void TLan_Timer( unsigned long data )
1983 * 1983 *
1984 **************************************************************/ 1984 **************************************************************/
1985 1985
1986void TLan_ResetLists( struct net_device *dev ) 1986static void TLan_ResetLists( struct net_device *dev )
1987{ 1987{
1988 TLanPrivateInfo *priv = netdev_priv(dev); 1988 TLanPrivateInfo *priv = netdev_priv(dev);
1989 int i; 1989 int i;
@@ -2043,7 +2043,7 @@ void TLan_ResetLists( struct net_device *dev )
2043} /* TLan_ResetLists */ 2043} /* TLan_ResetLists */
2044 2044
2045 2045
2046void TLan_FreeLists( struct net_device *dev ) 2046static void TLan_FreeLists( struct net_device *dev )
2047{ 2047{
2048 TLanPrivateInfo *priv = netdev_priv(dev); 2048 TLanPrivateInfo *priv = netdev_priv(dev);
2049 int i; 2049 int i;
@@ -2092,7 +2092,7 @@ void TLan_FreeLists( struct net_device *dev )
2092 * 2092 *
2093 **************************************************************/ 2093 **************************************************************/
2094 2094
2095void TLan_PrintDio( u16 io_base ) 2095static void TLan_PrintDio( u16 io_base )
2096{ 2096{
2097 u32 data0, data1; 2097 u32 data0, data1;
2098 int i; 2098 int i;
@@ -2127,7 +2127,7 @@ void TLan_PrintDio( u16 io_base )
2127 * 2127 *
2128 **************************************************************/ 2128 **************************************************************/
2129 2129
2130void TLan_PrintList( TLanList *list, char *type, int num) 2130static void TLan_PrintList( TLanList *list, char *type, int num)
2131{ 2131{
2132 int i; 2132 int i;
2133 2133
@@ -2163,7 +2163,7 @@ void TLan_PrintList( TLanList *list, char *type, int num)
2163 * 2163 *
2164 **************************************************************/ 2164 **************************************************************/
2165 2165
2166void TLan_ReadAndClearStats( struct net_device *dev, int record ) 2166static void TLan_ReadAndClearStats( struct net_device *dev, int record )
2167{ 2167{
2168 TLanPrivateInfo *priv = netdev_priv(dev); 2168 TLanPrivateInfo *priv = netdev_priv(dev);
2169 u32 tx_good, tx_under; 2169 u32 tx_good, tx_under;
@@ -2238,7 +2238,7 @@ void TLan_ReadAndClearStats( struct net_device *dev, int record )
2238 * 2238 *
2239 **************************************************************/ 2239 **************************************************************/
2240 2240
2241void 2241static void
2242TLan_ResetAdapter( struct net_device *dev ) 2242TLan_ResetAdapter( struct net_device *dev )
2243{ 2243{
2244 TLanPrivateInfo *priv = netdev_priv(dev); 2244 TLanPrivateInfo *priv = netdev_priv(dev);
@@ -2324,7 +2324,7 @@ TLan_ResetAdapter( struct net_device *dev )
2324 2324
2325 2325
2326 2326
2327void 2327static void
2328TLan_FinishReset( struct net_device *dev ) 2328TLan_FinishReset( struct net_device *dev )
2329{ 2329{
2330 TLanPrivateInfo *priv = netdev_priv(dev); 2330 TLanPrivateInfo *priv = netdev_priv(dev);
@@ -2448,7 +2448,7 @@ TLan_FinishReset( struct net_device *dev )
2448 * 2448 *
2449 **************************************************************/ 2449 **************************************************************/
2450 2450
2451void TLan_SetMac( struct net_device *dev, int areg, char *mac ) 2451static void TLan_SetMac( struct net_device *dev, int areg, char *mac )
2452{ 2452{
2453 int i; 2453 int i;
2454 2454
@@ -2490,7 +2490,7 @@ void TLan_SetMac( struct net_device *dev, int areg, char *mac )
2490 * 2490 *
2491 ********************************************************************/ 2491 ********************************************************************/
2492 2492
2493void TLan_PhyPrint( struct net_device *dev ) 2493static void TLan_PhyPrint( struct net_device *dev )
2494{ 2494{
2495 TLanPrivateInfo *priv = netdev_priv(dev); 2495 TLanPrivateInfo *priv = netdev_priv(dev);
2496 u16 i, data0, data1, data2, data3, phy; 2496 u16 i, data0, data1, data2, data3, phy;
@@ -2539,7 +2539,7 @@ void TLan_PhyPrint( struct net_device *dev )
2539 * 2539 *
2540 ********************************************************************/ 2540 ********************************************************************/
2541 2541
2542void TLan_PhyDetect( struct net_device *dev ) 2542static void TLan_PhyDetect( struct net_device *dev )
2543{ 2543{
2544 TLanPrivateInfo *priv = netdev_priv(dev); 2544 TLanPrivateInfo *priv = netdev_priv(dev);
2545 u16 control; 2545 u16 control;
@@ -2586,7 +2586,7 @@ void TLan_PhyDetect( struct net_device *dev )
2586 2586
2587 2587
2588 2588
2589void TLan_PhyPowerDown( struct net_device *dev ) 2589static void TLan_PhyPowerDown( struct net_device *dev )
2590{ 2590{
2591 TLanPrivateInfo *priv = netdev_priv(dev); 2591 TLanPrivateInfo *priv = netdev_priv(dev);
2592 u16 value; 2592 u16 value;
@@ -2611,7 +2611,7 @@ void TLan_PhyPowerDown( struct net_device *dev )
2611 2611
2612 2612
2613 2613
2614void TLan_PhyPowerUp( struct net_device *dev ) 2614static void TLan_PhyPowerUp( struct net_device *dev )
2615{ 2615{
2616 TLanPrivateInfo *priv = netdev_priv(dev); 2616 TLanPrivateInfo *priv = netdev_priv(dev);
2617 u16 value; 2617 u16 value;
@@ -2632,7 +2632,7 @@ void TLan_PhyPowerUp( struct net_device *dev )
2632 2632
2633 2633
2634 2634
2635void TLan_PhyReset( struct net_device *dev ) 2635static void TLan_PhyReset( struct net_device *dev )
2636{ 2636{
2637 TLanPrivateInfo *priv = netdev_priv(dev); 2637 TLanPrivateInfo *priv = netdev_priv(dev);
2638 u16 phy; 2638 u16 phy;
@@ -2660,7 +2660,7 @@ void TLan_PhyReset( struct net_device *dev )
2660 2660
2661 2661
2662 2662
2663void TLan_PhyStartLink( struct net_device *dev ) 2663static void TLan_PhyStartLink( struct net_device *dev )
2664{ 2664{
2665 TLanPrivateInfo *priv = netdev_priv(dev); 2665 TLanPrivateInfo *priv = netdev_priv(dev);
2666 u16 ability; 2666 u16 ability;
@@ -2747,7 +2747,7 @@ void TLan_PhyStartLink( struct net_device *dev )
2747 2747
2748 2748
2749 2749
2750void TLan_PhyFinishAutoNeg( struct net_device *dev ) 2750static void TLan_PhyFinishAutoNeg( struct net_device *dev )
2751{ 2751{
2752 TLanPrivateInfo *priv = netdev_priv(dev); 2752 TLanPrivateInfo *priv = netdev_priv(dev);
2753 u16 an_adv; 2753 u16 an_adv;
@@ -2903,7 +2903,7 @@ void TLan_PhyMonitor( struct net_device *dev )
2903 * 2903 *
2904 **************************************************************/ 2904 **************************************************************/
2905 2905
2906int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val ) 2906static int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
2907{ 2907{
2908 u8 nack; 2908 u8 nack;
2909 u16 sio, tmp; 2909 u16 sio, tmp;
@@ -2993,7 +2993,7 @@ int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
2993 * 2993 *
2994 **************************************************************/ 2994 **************************************************************/
2995 2995
2996void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits ) 2996static void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
2997{ 2997{
2998 u16 sio; 2998 u16 sio;
2999 u32 i; 2999 u32 i;
@@ -3035,7 +3035,7 @@ void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
3035 * 3035 *
3036 **************************************************************/ 3036 **************************************************************/
3037 3037
3038void TLan_MiiSync( u16 base_port ) 3038static void TLan_MiiSync( u16 base_port )
3039{ 3039{
3040 int i; 3040 int i;
3041 u16 sio; 3041 u16 sio;
@@ -3074,7 +3074,7 @@ void TLan_MiiSync( u16 base_port )
3074 * 3074 *
3075 **************************************************************/ 3075 **************************************************************/
3076 3076
3077void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val ) 3077static void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
3078{ 3078{
3079 u16 sio; 3079 u16 sio;
3080 int minten; 3080 int minten;
@@ -3144,7 +3144,7 @@ void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
3144 * 3144 *
3145 **************************************************************/ 3145 **************************************************************/
3146 3146
3147void TLan_EeSendStart( u16 io_base ) 3147static void TLan_EeSendStart( u16 io_base )
3148{ 3148{
3149 u16 sio; 3149 u16 sio;
3150 3150
@@ -3184,7 +3184,7 @@ void TLan_EeSendStart( u16 io_base )
3184 * 3184 *
3185 **************************************************************/ 3185 **************************************************************/
3186 3186
3187int TLan_EeSendByte( u16 io_base, u8 data, int stop ) 3187static int TLan_EeSendByte( u16 io_base, u8 data, int stop )
3188{ 3188{
3189 int err; 3189 int err;
3190 u8 place; 3190 u8 place;
@@ -3245,7 +3245,7 @@ int TLan_EeSendByte( u16 io_base, u8 data, int stop )
3245 * 3245 *
3246 **************************************************************/ 3246 **************************************************************/
3247 3247
3248void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop ) 3248static void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
3249{ 3249{
3250 u8 place; 3250 u8 place;
3251 u16 sio; 3251 u16 sio;
@@ -3303,7 +3303,7 @@ void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
3303 * 3303 *
3304 **************************************************************/ 3304 **************************************************************/
3305 3305
3306int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data ) 3306static int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data )
3307{ 3307{
3308 int err; 3308 int err;
3309 TLanPrivateInfo *priv = netdev_priv(dev); 3309 TLanPrivateInfo *priv = netdev_priv(dev);
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index a7afeea156bd..a59c1f224aa8 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -482,9 +482,11 @@ static void uli526x_init(struct net_device *dev)
482 struct uli526x_board_info *db = netdev_priv(dev); 482 struct uli526x_board_info *db = netdev_priv(dev);
483 unsigned long ioaddr = db->ioaddr; 483 unsigned long ioaddr = db->ioaddr;
484 u8 phy_tmp; 484 u8 phy_tmp;
485 u8 timeout;
485 u16 phy_value; 486 u16 phy_value;
486 u16 phy_reg_reset; 487 u16 phy_reg_reset;
487 488
489
488 ULI526X_DBUG(0, "uli526x_init()", 0); 490 ULI526X_DBUG(0, "uli526x_init()", 0);
489 491
490 /* Reset M526x MAC controller */ 492 /* Reset M526x MAC controller */
@@ -509,11 +511,19 @@ static void uli526x_init(struct net_device *dev)
509 /* Parser SROM and media mode */ 511 /* Parser SROM and media mode */
510 db->media_mode = uli526x_media_mode; 512 db->media_mode = uli526x_media_mode;
511 513
512 /* Phyxcer capability setting */ 514 /* phyxcer capability setting */
513 phy_reg_reset = phy_read(db->ioaddr, db->phy_addr, 0, db->chip_id); 515 phy_reg_reset = phy_read(db->ioaddr, db->phy_addr, 0, db->chip_id);
514 phy_reg_reset = (phy_reg_reset | 0x8000); 516 phy_reg_reset = (phy_reg_reset | 0x8000);
515 phy_write(db->ioaddr, db->phy_addr, 0, phy_reg_reset, db->chip_id); 517 phy_write(db->ioaddr, db->phy_addr, 0, phy_reg_reset, db->chip_id);
518
519 /* See IEEE 802.3-2002.pdf (Section 2, Chapter "22.2.4 Management
520 * functions") or phy data sheet for details on phy reset
521 */
516 udelay(500); 522 udelay(500);
523 timeout = 10;
524 while (timeout-- &&
525 phy_read(db->ioaddr, db->phy_addr, 0, db->chip_id) & 0x8000)
526 udelay(100);
517 527
518 /* Process Phyxcer Media Mode */ 528 /* Process Phyxcer Media Mode */
519 uli526x_set_phyxcer(db); 529 uli526x_set_phyxcer(db);
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 3f67a29593bc..e2ad98bee6e7 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -244,18 +244,6 @@ static int veth_open(struct net_device *dev)
244 return 0; 244 return 0;
245} 245}
246 246
247static int veth_close(struct net_device *dev)
248{
249 struct veth_priv *priv;
250
251 if (netif_carrier_ok(dev)) {
252 priv = netdev_priv(dev);
253 netif_carrier_off(dev);
254 netif_carrier_off(priv->peer);
255 }
256 return 0;
257}
258
259static int veth_dev_init(struct net_device *dev) 247static int veth_dev_init(struct net_device *dev)
260{ 248{
261 struct veth_net_stats *stats; 249 struct veth_net_stats *stats;
@@ -286,13 +274,50 @@ static void veth_setup(struct net_device *dev)
286 dev->hard_start_xmit = veth_xmit; 274 dev->hard_start_xmit = veth_xmit;
287 dev->get_stats = veth_get_stats; 275 dev->get_stats = veth_get_stats;
288 dev->open = veth_open; 276 dev->open = veth_open;
289 dev->stop = veth_close;
290 dev->ethtool_ops = &veth_ethtool_ops; 277 dev->ethtool_ops = &veth_ethtool_ops;
291 dev->features |= NETIF_F_LLTX; 278 dev->features |= NETIF_F_LLTX;
292 dev->init = veth_dev_init; 279 dev->init = veth_dev_init;
293 dev->destructor = veth_dev_free; 280 dev->destructor = veth_dev_free;
294} 281}
295 282
283static void veth_change_state(struct net_device *dev)
284{
285 struct net_device *peer;
286 struct veth_priv *priv;
287
288 priv = netdev_priv(dev);
289 peer = priv->peer;
290
291 if (netif_carrier_ok(peer)) {
292 if (!netif_carrier_ok(dev))
293 netif_carrier_on(dev);
294 } else {
295 if (netif_carrier_ok(dev))
296 netif_carrier_off(dev);
297 }
298}
299
300static int veth_device_event(struct notifier_block *unused,
301 unsigned long event, void *ptr)
302{
303 struct net_device *dev = ptr;
304
305 if (dev->open != veth_open)
306 goto out;
307
308 switch (event) {
309 case NETDEV_CHANGE:
310 veth_change_state(dev);
311 break;
312 }
313out:
314 return NOTIFY_DONE;
315}
316
317static struct notifier_block veth_notifier_block __read_mostly = {
318 .notifier_call = veth_device_event,
319};
320
296/* 321/*
297 * netlink interface 322 * netlink interface
298 */ 323 */
@@ -454,12 +479,14 @@ static struct rtnl_link_ops veth_link_ops = {
454 479
455static __init int veth_init(void) 480static __init int veth_init(void)
456{ 481{
482 register_netdevice_notifier(&veth_notifier_block);
457 return rtnl_link_register(&veth_link_ops); 483 return rtnl_link_register(&veth_link_ops);
458} 484}
459 485
460static __exit void veth_exit(void) 486static __exit void veth_exit(void)
461{ 487{
462 rtnl_link_unregister(&veth_link_ops); 488 rtnl_link_unregister(&veth_link_ops);
489 unregister_netdevice_notifier(&veth_notifier_block);
463} 490}
464 491
465module_init(veth_init); 492module_init(veth_init);
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 7c851b1e6daa..8c9d6ae2bb31 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -1893,7 +1893,7 @@ static void rhine_shutdown (struct pci_dev *pdev)
1893 1893
1894 /* Make sure we use pattern 0, 1 and not 4, 5 */ 1894 /* Make sure we use pattern 0, 1 and not 4, 5 */
1895 if (rp->quirks & rq6patterns) 1895 if (rp->quirks & rq6patterns)
1896 iowrite8(0x04, ioaddr + 0xA7); 1896 iowrite8(0x04, ioaddr + WOLcgClr);
1897 1897
1898 if (rp->wolopts & WAKE_MAGIC) { 1898 if (rp->wolopts & WAKE_MAGIC) {
1899 iowrite8(WOLmagic, ioaddr + WOLcrSet); 1899 iowrite8(WOLmagic, ioaddr + WOLcrSet);
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fdc23678117b..19fd4cb0ddf8 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -361,6 +361,7 @@ static int virtnet_probe(struct virtio_device *vdev)
361 netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight); 361 netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight);
362 vi->dev = dev; 362 vi->dev = dev;
363 vi->vdev = vdev; 363 vi->vdev = vdev;
364 vdev->priv = vi;
364 365
365 /* We expect two virtqueues, receive then send. */ 366 /* We expect two virtqueues, receive then send. */
366 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); 367 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
@@ -395,7 +396,6 @@ static int virtnet_probe(struct virtio_device *vdev)
395 } 396 }
396 397
397 pr_debug("virtnet: registered device %s\n", dev->name); 398 pr_debug("virtnet: registered device %s\n", dev->name);
398 vdev->priv = vi;
399 return 0; 399 return 0;
400 400
401unregister: 401unregister:
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h
index c79066b38d3b..69dea3392612 100644
--- a/drivers/net/wireless/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath5k/ath5k.h
@@ -1035,7 +1035,7 @@ struct ath5k_hw {
1035 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, 1035 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int,
1036 unsigned int, unsigned int, unsigned int, unsigned int, 1036 unsigned int, unsigned int, unsigned int, unsigned int,
1037 unsigned int, unsigned int, unsigned int); 1037 unsigned int, unsigned int, unsigned int);
1038 bool (*ah_setup_xtx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1038 int (*ah_setup_xtx_desc)(struct ath5k_hw *, struct ath5k_desc *,
1039 unsigned int, unsigned int, unsigned int, unsigned int, 1039 unsigned int, unsigned int, unsigned int, unsigned int,
1040 unsigned int, unsigned int); 1040 unsigned int, unsigned int);
1041 int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *); 1041 int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *);
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index dfdaec020739..bef967ce34a6 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -668,7 +668,10 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)
668 * return false w/o doing anything. MAC's that do 668 * return false w/o doing anything. MAC's that do
669 * support it will return true w/o doing anything. 669 * support it will return true w/o doing anything.
670 */ 670 */
671 if (ah->ah_setup_xtx_desc(ah, NULL, 0, 0, 0, 0, 0, 0)) 671 ret = ah->ah_setup_xtx_desc(ah, NULL, 0, 0, 0, 0, 0, 0);
672 if (ret < 0)
673 goto err;
674 if (ret > 0)
672 __set_bit(ATH_STAT_MRRETRY, sc->status); 675 __set_bit(ATH_STAT_MRRETRY, sc->status);
673 676
674 /* 677 /*
@@ -1715,6 +1718,7 @@ ath5k_tasklet_rx(unsigned long data)
1715 break; 1718 break;
1716 else if (unlikely(ret)) { 1719 else if (unlikely(ret)) {
1717 ATH5K_ERR(sc, "error in processing rx descriptor\n"); 1720 ATH5K_ERR(sc, "error in processing rx descriptor\n");
1721 spin_unlock(&sc->rxbuflock);
1718 return; 1722 return;
1719 } 1723 }
1720 1724
@@ -2126,8 +2130,9 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
2126 "updated timers based on beacon TSF\n"); 2130 "updated timers based on beacon TSF\n");
2127 2131
2128 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, 2132 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON,
2129 "bc_tsf %llx hw_tsf %llx bc_tu %u hw_tu %u nexttbtt %u\n", 2133 "bc_tsf %llx hw_tsf %llx bc_tu %u hw_tu %u nexttbtt %u\n",
2130 bc_tsf, hw_tsf, bc_tu, hw_tu, nexttbtt); 2134 (unsigned long long) bc_tsf,
2135 (unsigned long long) hw_tsf, bc_tu, hw_tu, nexttbtt);
2131 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "intval %u %s %s\n", 2136 ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "intval %u %s %s\n",
2132 intval & AR5K_BEACON_PERIOD, 2137 intval & AR5K_BEACON_PERIOD,
2133 intval & AR5K_BEACON_ENA ? "AR5K_BEACON_ENA" : "", 2138 intval & AR5K_BEACON_ENA ? "AR5K_BEACON_ENA" : "",
@@ -2385,10 +2390,11 @@ ath5k_intr(int irq, void *dev_id)
2385 u64 tsf = ath5k_hw_get_tsf64(ah); 2390 u64 tsf = ath5k_hw_get_tsf64(ah);
2386 sc->nexttbtt += sc->bintval; 2391 sc->nexttbtt += sc->bintval;
2387 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 2392 ATH5K_DBG(sc, ATH5K_DEBUG_BEACON,
2388 "SWBA nexttbtt: %x hw_tu: %x " 2393 "SWBA nexttbtt: %x hw_tu: %x "
2389 "TSF: %llx\n", 2394 "TSF: %llx\n",
2390 sc->nexttbtt, 2395 sc->nexttbtt,
2391 TSF_TO_TU(tsf), tsf); 2396 TSF_TO_TU(tsf),
2397 (unsigned long long) tsf);
2392 } else { 2398 } else {
2393 ath5k_beacon_send(sc); 2399 ath5k_beacon_send(sc);
2394 } 2400 }
diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
index 1ab57aa6e4dc..c2de2d958e8e 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -45,7 +45,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *, struct ath5k_desc *,
45 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, 45 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int,
46 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, 46 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int,
47 unsigned int, unsigned int); 47 unsigned int, unsigned int);
48static bool ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *, struct ath5k_desc *, 48static int ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *, struct ath5k_desc *,
49 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, 49 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int,
50 unsigned int); 50 unsigned int);
51static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *, struct ath5k_desc *); 51static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *, struct ath5k_desc *);
@@ -3743,7 +3743,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3743/* 3743/*
3744 * Initialize a 4-word multirate tx descriptor on 5212 3744 * Initialize a 4-word multirate tx descriptor on 5212
3745 */ 3745 */
3746static bool 3746static int
3747ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 3747ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3748 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, u_int tx_tries2, 3748 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, u_int tx_tries2,
3749 unsigned int tx_rate3, u_int tx_tries3) 3749 unsigned int tx_rate3, u_int tx_tries3)
@@ -3783,10 +3783,10 @@ ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3783 3783
3784#undef _XTX_TRIES 3784#undef _XTX_TRIES
3785 3785
3786 return true; 3786 return 1;
3787 } 3787 }
3788 3788
3789 return false; 3789 return 0;
3790} 3790}
3791 3791
3792/* 3792/*
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index 1a2141dabdc7..8bc4bc4c330e 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -32,6 +32,7 @@ config B43_PCI_AUTOSELECT
32 bool 32 bool
33 depends on B43 && SSB_PCIHOST_POSSIBLE 33 depends on B43 && SSB_PCIHOST_POSSIBLE
34 select SSB_PCIHOST 34 select SSB_PCIHOST
35 select SSB_B43_PCI_BRIDGE
35 default y 36 default y
36 37
37# Auto-select SSB PCICORE driver, if possible 38# Auto-select SSB PCICORE driver, if possible
diff --git a/drivers/net/wireless/b43legacy/Kconfig b/drivers/net/wireless/b43legacy/Kconfig
index 6745579ba96d..13c65faf0247 100644
--- a/drivers/net/wireless/b43legacy/Kconfig
+++ b/drivers/net/wireless/b43legacy/Kconfig
@@ -25,6 +25,7 @@ config B43LEGACY_PCI_AUTOSELECT
25 bool 25 bool
26 depends on B43LEGACY && SSB_PCIHOST_POSSIBLE 26 depends on B43LEGACY && SSB_PCIHOST_POSSIBLE
27 select SSB_PCIHOST 27 select SSB_PCIHOST
28 select SSB_B43_PCI_BRIDGE
28 default y 29 default y
29 30
30# Auto-select SSB PCICORE driver, if possible 31# Auto-select SSB PCICORE driver, if possible
diff --git a/drivers/net/wireless/bcm43xx/Kconfig b/drivers/net/wireless/bcm43xx/Kconfig
index 0159701e8456..afb8f4305c24 100644
--- a/drivers/net/wireless/bcm43xx/Kconfig
+++ b/drivers/net/wireless/bcm43xx/Kconfig
@@ -1,6 +1,6 @@
1config BCM43XX 1config BCM43XX
2 tristate "Broadcom BCM43xx wireless support (DEPRECATED)" 2 tristate "Broadcom BCM43xx wireless support (DEPRECATED)"
3 depends on PCI && IEEE80211 && IEEE80211_SOFTMAC && WLAN_80211 && EXPERIMENTAL 3 depends on PCI && IEEE80211 && IEEE80211_SOFTMAC && WLAN_80211 && (!SSB_B43_PCI_BRIDGE || SSB != y) && EXPERIMENTAL
4 select WIRELESS_EXT 4 select WIRELESS_EXT
5 select FW_LOADER 5 select FW_LOADER
6 select HW_RANDOM 6 select HW_RANDOM
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index eab020338fde..b3c1acbcc655 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1040,7 +1040,6 @@ int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action,
1040 lbs_deb_leave(LBS_DEB_CMD); 1040 lbs_deb_leave(LBS_DEB_CMD);
1041 return ret; 1041 return ret;
1042} 1042}
1043EXPORT_SYMBOL_GPL(lbs_mesh_access);
1044 1043
1045int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan) 1044int lbs_mesh_config(struct lbs_private *priv, uint16_t enable, uint16_t chan)
1046{ 1045{
@@ -1576,7 +1575,6 @@ done:
1576 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); 1575 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
1577 return ret; 1576 return ret;
1578} 1577}
1579EXPORT_SYMBOL_GPL(lbs_prepare_and_send_command);
1580 1578
1581/** 1579/**
1582 * @brief This function allocates the command buffer and link 1580 * @brief This function allocates the command buffer and link
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index aaacd9bd6bd2..4e22341b4f3d 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -69,7 +69,6 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev);
69int lbs_remove_card(struct lbs_private *priv); 69int lbs_remove_card(struct lbs_private *priv);
70int lbs_start_card(struct lbs_private *priv); 70int lbs_start_card(struct lbs_private *priv);
71int lbs_stop_card(struct lbs_private *priv); 71int lbs_stop_card(struct lbs_private *priv);
72int lbs_reset_device(struct lbs_private *priv);
73void lbs_host_to_card_done(struct lbs_private *priv); 72void lbs_host_to_card_done(struct lbs_private *priv);
74 73
75int lbs_update_channel(struct lbs_private *priv); 74int lbs_update_channel(struct lbs_private *priv);
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 84fb49ca0fae..4d4e2f3b66ac 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1351,8 +1351,6 @@ done:
1351 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret); 1351 lbs_deb_leave_args(LBS_DEB_MESH, "ret %d", ret);
1352 return ret; 1352 return ret;
1353} 1353}
1354EXPORT_SYMBOL_GPL(lbs_add_mesh);
1355
1356 1354
1357static void lbs_remove_mesh(struct lbs_private *priv) 1355static void lbs_remove_mesh(struct lbs_private *priv)
1358{ 1356{
@@ -1372,7 +1370,6 @@ static void lbs_remove_mesh(struct lbs_private *priv)
1372 free_netdev(mesh_dev); 1370 free_netdev(mesh_dev);
1373 lbs_deb_leave(LBS_DEB_MESH); 1371 lbs_deb_leave(LBS_DEB_MESH);
1374} 1372}
1375EXPORT_SYMBOL_GPL(lbs_remove_mesh);
1376 1373
1377/** 1374/**
1378 * @brief This function finds the CFP in 1375 * @brief This function finds the CFP in
@@ -1458,20 +1455,6 @@ void lbs_interrupt(struct lbs_private *priv)
1458} 1455}
1459EXPORT_SYMBOL_GPL(lbs_interrupt); 1456EXPORT_SYMBOL_GPL(lbs_interrupt);
1460 1457
1461int lbs_reset_device(struct lbs_private *priv)
1462{
1463 int ret;
1464
1465 lbs_deb_enter(LBS_DEB_MAIN);
1466 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RESET,
1467 CMD_ACT_HALT, 0, 0, NULL);
1468 msleep_interruptible(10);
1469
1470 lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
1471 return ret;
1472}
1473EXPORT_SYMBOL_GPL(lbs_reset_device);
1474
1475static int __init lbs_init_module(void) 1458static int __init lbs_init_module(void)
1476{ 1459{
1477 lbs_deb_enter(LBS_DEB_MAIN); 1460 lbs_deb_enter(LBS_DEB_MAIN);
diff --git a/drivers/net/wireless/p54usb.c b/drivers/net/wireless/p54usb.c
index 60d286eb0b8b..e7d4aee8799e 100644
--- a/drivers/net/wireless/p54usb.c
+++ b/drivers/net/wireless/p54usb.c
@@ -35,6 +35,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
35 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */ 35 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
36 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */ 36 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */
37 {USB_DEVICE(0x083a, 0x4502)}, /* Siemens Gigaset USB Adapter */ 37 {USB_DEVICE(0x083a, 0x4502)}, /* Siemens Gigaset USB Adapter */
38 {USB_DEVICE(0x083a, 0x5501)}, /* Phillips CPWUA054 */
38 {USB_DEVICE(0x0846, 0x4200)}, /* Netgear WG121 */ 39 {USB_DEVICE(0x0846, 0x4200)}, /* Netgear WG121 */
39 {USB_DEVICE(0x0846, 0x4210)}, /* Netgear WG121 the second ? */ 40 {USB_DEVICE(0x0846, 0x4210)}, /* Netgear WG121 the second ? */
40 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */ 41 {USB_DEVICE(0x0846, 0x4220)}, /* Netgear WG111 */
@@ -62,6 +63,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
62 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */ 63 {USB_DEVICE(0x0cde, 0x0008)}, /* Sagem XG703A */
63 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */ 64 {USB_DEVICE(0x0d8e, 0x3762)}, /* DLink DWL-G120 Cohiba */
64 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */ 65 {USB_DEVICE(0x09aa, 0x1000)}, /* Spinnaker Proto board */
66 {USB_DEVICE(0x13b1, 0x000a)}, /* Linksys WUSB54G ver 2 */
65 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */ 67 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
66 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */ 68 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
67 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */ 69 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 8ce2ddf8024f..d9460aed1f22 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -228,9 +228,9 @@ struct NDIS_WLAN_BSSID_EX {
228 struct NDIS_802_11_SSID Ssid; 228 struct NDIS_802_11_SSID Ssid;
229 __le32 Privacy; 229 __le32 Privacy;
230 __le32 Rssi; 230 __le32 Rssi;
231 enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse; 231 __le32 NetworkTypeInUse;
232 struct NDIS_802_11_CONFIGURATION Configuration; 232 struct NDIS_802_11_CONFIGURATION Configuration;
233 enum NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode; 233 __le32 InfrastructureMode;
234 u8 SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; 234 u8 SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
235 __le32 IELength; 235 __le32 IELength;
236 u8 IEs[0]; 236 u8 IEs[0];
@@ -279,11 +279,11 @@ struct RNDIS_CONFIG_PARAMETER_INFOBUFFER {
279} __attribute__((packed)); 279} __attribute__((packed));
280 280
281/* these have to match what is in wpa_supplicant */ 281/* these have to match what is in wpa_supplicant */
282enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg; 282enum wpa_alg { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP };
283enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, CIPHER_WEP104 } 283enum wpa_cipher { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP,
284 wpa_cipher; 284 CIPHER_WEP104 };
285enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE, KEY_MGMT_802_1X_NO_WPA, 285enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
286 KEY_MGMT_WPA_NONE } wpa_key_mgmt; 286 KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE };
287 287
288/* 288/*
289 * private data 289 * private data
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index d6cba138c7ab..c69f85ed7669 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -960,8 +960,12 @@ static int rt2400pci_set_device_state(struct rt2x00_dev *rt2x00dev,
960 rt2400pci_disable_radio(rt2x00dev); 960 rt2400pci_disable_radio(rt2x00dev);
961 break; 961 break;
962 case STATE_RADIO_RX_ON: 962 case STATE_RADIO_RX_ON:
963 case STATE_RADIO_RX_ON_LINK:
964 rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
965 break;
963 case STATE_RADIO_RX_OFF: 966 case STATE_RADIO_RX_OFF:
964 rt2400pci_toggle_rx(rt2x00dev, state); 967 case STATE_RADIO_RX_OFF_LINK:
968 rt2400pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
965 break; 969 break;
966 case STATE_DEEP_SLEEP: 970 case STATE_DEEP_SLEEP:
967 case STATE_SLEEP: 971 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index e874fdcae204..91e87b53374f 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1112,8 +1112,12 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1112 rt2500pci_disable_radio(rt2x00dev); 1112 rt2500pci_disable_radio(rt2x00dev);
1113 break; 1113 break;
1114 case STATE_RADIO_RX_ON: 1114 case STATE_RADIO_RX_ON:
1115 case STATE_RADIO_RX_ON_LINK:
1116 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1117 break;
1115 case STATE_RADIO_RX_OFF: 1118 case STATE_RADIO_RX_OFF:
1116 rt2500pci_toggle_rx(rt2x00dev, state); 1119 case STATE_RADIO_RX_OFF_LINK:
1120 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1117 break; 1121 break;
1118 case STATE_DEEP_SLEEP: 1122 case STATE_DEEP_SLEEP:
1119 case STATE_SLEEP: 1123 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 4ca9730e5e92..638c3d243108 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1001,8 +1001,12 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1001 rt2500usb_disable_radio(rt2x00dev); 1001 rt2500usb_disable_radio(rt2x00dev);
1002 break; 1002 break;
1003 case STATE_RADIO_RX_ON: 1003 case STATE_RADIO_RX_ON:
1004 case STATE_RADIO_RX_ON_LINK:
1005 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1006 break;
1004 case STATE_RADIO_RX_OFF: 1007 case STATE_RADIO_RX_OFF:
1005 rt2500usb_toggle_rx(rt2x00dev, state); 1008 case STATE_RADIO_RX_OFF_LINK:
1009 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1006 break; 1010 break;
1007 case STATE_DEEP_SLEEP: 1011 case STATE_DEEP_SLEEP:
1008 case STATE_SLEEP: 1012 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 72cfe00c1ed7..07adc576db49 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -97,12 +97,16 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
97 libconf.ant.rx = rx; 97 libconf.ant.rx = rx;
98 libconf.ant.tx = tx; 98 libconf.ant.tx = tx;
99 99
100 if (rx == rt2x00dev->link.ant.active.rx &&
101 tx == rt2x00dev->link.ant.active.tx)
102 return;
103
100 /* 104 /*
101 * Antenna setup changes require the RX to be disabled, 105 * Antenna setup changes require the RX to be disabled,
102 * else the changes will be ignored by the device. 106 * else the changes will be ignored by the device.
103 */ 107 */
104 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 108 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
105 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 109 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK);
106 110
107 /* 111 /*
108 * Write new antenna setup to device and reset the link tuner. 112 * Write new antenna setup to device and reset the link tuner.
@@ -116,7 +120,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
116 rt2x00dev->link.ant.active.tx = libconf.ant.tx; 120 rt2x00dev->link.ant.active.tx = libconf.ant.tx;
117 121
118 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 122 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
119 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 123 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);
120} 124}
121 125
122void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 126void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index c4be2ac4d7a4..0d51f478bcdf 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -61,11 +61,33 @@ EXPORT_SYMBOL_GPL(rt2x00lib_get_ring);
61/* 61/*
62 * Link tuning handlers 62 * Link tuning handlers
63 */ 63 */
64static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev) 64void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev)
65{ 65{
66 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
67 return;
68
69 /*
70 * Reset link information.
71 * Both the currently active vgc level as well as
72 * the link tuner counter should be reset. Resetting
73 * the counter is important for devices where the
74 * device should only perform link tuning during the
75 * first minute after being enabled.
76 */
66 rt2x00dev->link.count = 0; 77 rt2x00dev->link.count = 0;
67 rt2x00dev->link.vgc_level = 0; 78 rt2x00dev->link.vgc_level = 0;
68 79
80 /*
81 * Reset the link tuner.
82 */
83 rt2x00dev->ops->lib->reset_tuner(rt2x00dev);
84}
85
86static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev)
87{
88 /*
89 * Clear all (possibly) pre-existing quality statistics.
90 */
69 memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual)); 91 memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual));
70 92
71 /* 93 /*
@@ -79,10 +101,7 @@ static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev)
79 rt2x00dev->link.qual.rx_percentage = 50; 101 rt2x00dev->link.qual.rx_percentage = 50;
80 rt2x00dev->link.qual.tx_percentage = 50; 102 rt2x00dev->link.qual.tx_percentage = 50;
81 103
82 /* 104 rt2x00lib_reset_link_tuner(rt2x00dev);
83 * Reset the link tuner.
84 */
85 rt2x00dev->ops->lib->reset_tuner(rt2x00dev);
86 105
87 queue_delayed_work(rt2x00dev->hw->workqueue, 106 queue_delayed_work(rt2x00dev->hw->workqueue,
88 &rt2x00dev->link.work, LINK_TUNE_INTERVAL); 107 &rt2x00dev->link.work, LINK_TUNE_INTERVAL);
@@ -93,15 +112,6 @@ static void rt2x00lib_stop_link_tuner(struct rt2x00_dev *rt2x00dev)
93 cancel_delayed_work_sync(&rt2x00dev->link.work); 112 cancel_delayed_work_sync(&rt2x00dev->link.work);
94} 113}
95 114
96void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev)
97{
98 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
99 return;
100
101 rt2x00lib_stop_link_tuner(rt2x00dev);
102 rt2x00lib_start_link_tuner(rt2x00dev);
103}
104
105/* 115/*
106 * Ring initialization 116 * Ring initialization
107 */ 117 */
@@ -260,19 +270,11 @@ static void rt2x00lib_evaluate_antenna_sample(struct rt2x00_dev *rt2x00dev)
260 if (sample_a == sample_b) 270 if (sample_a == sample_b)
261 return; 271 return;
262 272
263 if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) { 273 if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY)
264 if (sample_a > sample_b && rx == ANTENNA_B) 274 rx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B;
265 rx = ANTENNA_A;
266 else if (rx == ANTENNA_A)
267 rx = ANTENNA_B;
268 }
269 275
270 if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) { 276 if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)
271 if (sample_a > sample_b && tx == ANTENNA_B) 277 tx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B;
272 tx = ANTENNA_A;
273 else if (tx == ANTENNA_A)
274 tx = ANTENNA_B;
275 }
276 278
277 rt2x00lib_config_antenna(rt2x00dev, rx, tx); 279 rt2x00lib_config_antenna(rt2x00dev, rx, tx);
278} 280}
@@ -293,7 +295,7 @@ static void rt2x00lib_evaluate_antenna_eval(struct rt2x00_dev *rt2x00dev)
293 * sample the rssi from the other antenna to make a valid 295 * sample the rssi from the other antenna to make a valid
294 * comparison between the 2 antennas. 296 * comparison between the 2 antennas.
295 */ 297 */
296 if ((rssi_curr - rssi_old) > -5 || (rssi_curr - rssi_old) < 5) 298 if (abs(rssi_curr - rssi_old) < 5)
297 return; 299 return;
298 300
299 rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE; 301 rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE;
@@ -319,15 +321,15 @@ static void rt2x00lib_evaluate_antenna(struct rt2x00_dev *rt2x00dev)
319 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY; 321 rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY;
320 322
321 if (rt2x00dev->hw->conf.antenna_sel_rx == 0 && 323 if (rt2x00dev->hw->conf.antenna_sel_rx == 0 &&
322 rt2x00dev->default_ant.rx != ANTENNA_SW_DIVERSITY) 324 rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
323 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY; 325 rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY;
324 if (rt2x00dev->hw->conf.antenna_sel_tx == 0 && 326 if (rt2x00dev->hw->conf.antenna_sel_tx == 0 &&
325 rt2x00dev->default_ant.tx != ANTENNA_SW_DIVERSITY) 327 rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
326 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY; 328 rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY;
327 329
328 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) && 330 if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) &&
329 !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) { 331 !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) {
330 rt2x00dev->link.ant.flags &= ~ANTENNA_MODE_SAMPLE; 332 rt2x00dev->link.ant.flags = 0;
331 return; 333 return;
332 } 334 }
333 335
@@ -441,17 +443,18 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
441 rt2x00dev->ops->lib->link_tuner(rt2x00dev); 443 rt2x00dev->ops->lib->link_tuner(rt2x00dev);
442 444
443 /* 445 /*
444 * Evaluate antenna setup.
445 */
446 rt2x00lib_evaluate_antenna(rt2x00dev);
447
448 /*
449 * Precalculate a portion of the link signal which is 446 * Precalculate a portion of the link signal which is
450 * in based on the tx/rx success/failure counters. 447 * in based on the tx/rx success/failure counters.
451 */ 448 */
452 rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual); 449 rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual);
453 450
454 /* 451 /*
452 * Evaluate antenna setup, make this the last step since this could
453 * possibly reset some statistics.
454 */
455 rt2x00lib_evaluate_antenna(rt2x00dev);
456
457 /*
455 * Increase tuner counter, and reschedule the next link tuner run. 458 * Increase tuner counter, and reschedule the next link tuner run.
456 */ 459 */
457 rt2x00dev->link.count++; 460 rt2x00dev->link.count++;
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
index 838421216da0..b1915dc7dda1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00reg.h
+++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
@@ -85,6 +85,8 @@ enum dev_state {
85 STATE_RADIO_OFF, 85 STATE_RADIO_OFF,
86 STATE_RADIO_RX_ON, 86 STATE_RADIO_RX_ON,
87 STATE_RADIO_RX_OFF, 87 STATE_RADIO_RX_OFF,
88 STATE_RADIO_RX_ON_LINK,
89 STATE_RADIO_RX_OFF_LINK,
88 STATE_RADIO_IRQ_ON, 90 STATE_RADIO_IRQ_ON,
89 STATE_RADIO_IRQ_OFF, 91 STATE_RADIO_IRQ_OFF,
90}; 92};
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index b31f0c26c32b..e808db98f2f5 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1482,8 +1482,12 @@ static int rt61pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1482 rt61pci_disable_radio(rt2x00dev); 1482 rt61pci_disable_radio(rt2x00dev);
1483 break; 1483 break;
1484 case STATE_RADIO_RX_ON: 1484 case STATE_RADIO_RX_ON:
1485 case STATE_RADIO_RX_ON_LINK:
1486 rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1487 break;
1485 case STATE_RADIO_RX_OFF: 1488 case STATE_RADIO_RX_OFF:
1486 rt61pci_toggle_rx(rt2x00dev, state); 1489 case STATE_RADIO_RX_OFF_LINK:
1490 rt61pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1487 break; 1491 break;
1488 case STATE_DEEP_SLEEP: 1492 case STATE_DEEP_SLEEP:
1489 case STATE_SLEEP: 1493 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 4d576ab3e7f9..4fac2d414d84 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1208,8 +1208,12 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1208 rt73usb_disable_radio(rt2x00dev); 1208 rt73usb_disable_radio(rt2x00dev);
1209 break; 1209 break;
1210 case STATE_RADIO_RX_ON: 1210 case STATE_RADIO_RX_ON:
1211 case STATE_RADIO_RX_ON_LINK:
1212 rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1213 break;
1211 case STATE_RADIO_RX_OFF: 1214 case STATE_RADIO_RX_OFF:
1212 rt73usb_toggle_rx(rt2x00dev, state); 1215 case STATE_RADIO_RX_OFF_LINK:
1216 rt73usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
1213 break; 1217 break;
1214 case STATE_DEEP_SLEEP: 1218 case STATE_DEEP_SLEEP:
1215 case STATE_SLEEP: 1219 case STATE_SLEEP:
diff --git a/drivers/net/wireless/rtl8180_dev.c b/drivers/net/wireless/rtl8180_dev.c
index 27ebd689aa21..5e9a8ace0d81 100644
--- a/drivers/net/wireless/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl8180_dev.c
@@ -135,13 +135,15 @@ static void rtl8180_handle_tx(struct ieee80211_hw *dev, unsigned int prio)
135 while (skb_queue_len(&ring->queue)) { 135 while (skb_queue_len(&ring->queue)) {
136 struct rtl8180_tx_desc *entry = &ring->desc[ring->idx]; 136 struct rtl8180_tx_desc *entry = &ring->desc[ring->idx];
137 struct sk_buff *skb; 137 struct sk_buff *skb;
138 struct ieee80211_tx_status status = { {0} }; 138 struct ieee80211_tx_status status;
139 struct ieee80211_tx_control *control; 139 struct ieee80211_tx_control *control;
140 u32 flags = le32_to_cpu(entry->flags); 140 u32 flags = le32_to_cpu(entry->flags);
141 141
142 if (flags & RTL8180_TX_DESC_FLAG_OWN) 142 if (flags & RTL8180_TX_DESC_FLAG_OWN)
143 return; 143 return;
144 144
145 memset(&status, 0, sizeof(status));
146
145 ring->idx = (ring->idx + 1) % ring->entries; 147 ring->idx = (ring->idx + 1) % ring->entries;
146 skb = __skb_dequeue(&ring->queue); 148 skb = __skb_dequeue(&ring->queue);
147 pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf), 149 pci_unmap_single(priv->pdev, le32_to_cpu(entry->tx_buf),
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 0d71716d750d..f44505994a0e 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -113,10 +113,12 @@ void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
113 113
114static void rtl8187_tx_cb(struct urb *urb) 114static void rtl8187_tx_cb(struct urb *urb)
115{ 115{
116 struct ieee80211_tx_status status = { {0} }; 116 struct ieee80211_tx_status status;
117 struct sk_buff *skb = (struct sk_buff *)urb->context; 117 struct sk_buff *skb = (struct sk_buff *)urb->context;
118 struct rtl8187_tx_info *info = (struct rtl8187_tx_info *)skb->cb; 118 struct rtl8187_tx_info *info = (struct rtl8187_tx_info *)skb->cb;
119 119
120 memset(&status, 0, sizeof(status));
121
120 usb_free_urb(info->urb); 122 usb_free_urb(info->urb);
121 if (info->control) 123 if (info->control)
122 memcpy(&status.control, info->control, sizeof(status.control)); 124 memcpy(&status.control, info->control, sizeof(status.control));
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 49127e4b42c2..76ef2d83919d 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -360,11 +360,14 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw)
360{ 360{
361 struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue; 361 struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue;
362 struct sk_buff *skb; 362 struct sk_buff *skb;
363 struct ieee80211_tx_status status = {{0}}; 363 struct ieee80211_tx_status status;
364 364
365 skb = skb_dequeue(q); 365 skb = skb_dequeue(q);
366 if (skb == NULL) 366 if (skb == NULL)
367 return; 367 return;
368
369 memset(&status, 0, sizeof(status));
370
368 tx_status(hw, skb, &status, 0); 371 tx_status(hw, skb, &status, 0);
369} 372}
370 373
@@ -389,7 +392,8 @@ void zd_mac_tx_to_dev(struct sk_buff *skb, int error)
389 if (unlikely(error || 392 if (unlikely(error ||
390 (cb->control->flags & IEEE80211_TXCTL_NO_ACK))) 393 (cb->control->flags & IEEE80211_TXCTL_NO_ACK)))
391 { 394 {
392 struct ieee80211_tx_status status = {{0}}; 395 struct ieee80211_tx_status status;
396 memset(&status, 0, sizeof(status));
393 tx_status(hw, skb, &status, !error); 397 tx_status(hw, skb, &status, !error);
394 } else { 398 } else {
395 struct sk_buff_head *q = 399 struct sk_buff_head *q =
@@ -603,7 +607,9 @@ static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr,
603 tx_hdr = (struct ieee80211_hdr *)skb->data; 607 tx_hdr = (struct ieee80211_hdr *)skb->data;
604 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) 608 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1)))
605 { 609 {
606 struct ieee80211_tx_status status = {{0}}; 610 struct ieee80211_tx_status status;
611
612 memset(&status, 0, sizeof(status));
607 status.flags = IEEE80211_TX_STATUS_ACK; 613 status.flags = IEEE80211_TX_STATUS_ACK;
608 status.ack_signal = stats->ssi; 614 status.ack_signal = stats->ssi;
609 __skb_unlink(skb, q); 615 __skb_unlink(skb, q);
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index c3076217871e..d8a5c229c5a7 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -1851,8 +1851,7 @@ claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid)
1851 } 1851 }
1852 } 1852 }
1853 /* See how many write buffers are required to hold this data */ 1853 /* See how many write buffers are required to hold this data */
1854 numBuffers= ( skb->len + privptr->p_env->write_size - 1) / 1854 numBuffers = DIV_ROUND_UP(skb->len, privptr->p_env->write_size);
1855 ( privptr->p_env->write_size);
1856 1855
1857 /* If that number of buffers isn't available, give up for now */ 1856 /* If that number of buffers isn't available, give up for now */
1858 if (privptr->write_free_count < numBuffers || 1857 if (privptr->write_free_count < numBuffers ||
@@ -2114,8 +2113,7 @@ init_ccw_bk(struct net_device *dev)
2114 */ 2113 */
2115 ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE; 2114 ccw_blocks_perpage= PAGE_SIZE / CCWBK_SIZE;
2116 ccw_pages_required= 2115 ccw_pages_required=
2117 (ccw_blocks_required+ccw_blocks_perpage -1) / 2116 DIV_ROUND_UP(ccw_blocks_required, ccw_blocks_perpage);
2118 ccw_blocks_perpage;
2119 2117
2120#ifdef DEBUGMSG 2118#ifdef DEBUGMSG
2121 printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n", 2119 printk(KERN_INFO "%s: %s() > ccw_blocks_perpage=%d\n",
@@ -2131,30 +2129,29 @@ init_ccw_bk(struct net_device *dev)
2131 * provide good performance. With packing buffers support 32k 2129 * provide good performance. With packing buffers support 32k
2132 * buffers are used. 2130 * buffers are used.
2133 */ 2131 */
2134 if (privptr->p_env->read_size < PAGE_SIZE) { 2132 if (privptr->p_env->read_size < PAGE_SIZE) {
2135 claw_reads_perpage= PAGE_SIZE / privptr->p_env->read_size; 2133 claw_reads_perpage = PAGE_SIZE / privptr->p_env->read_size;
2136 claw_read_pages= (privptr->p_env->read_buffers + 2134 claw_read_pages = DIV_ROUND_UP(privptr->p_env->read_buffers,
2137 claw_reads_perpage -1) / claw_reads_perpage; 2135 claw_reads_perpage);
2138 } 2136 }
2139 else { /* > or equal */ 2137 else { /* > or equal */
2140 privptr->p_buff_pages_perread= 2138 privptr->p_buff_pages_perread =
2141 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE; 2139 DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
2142 claw_read_pages= 2140 claw_read_pages = privptr->p_env->read_buffers *
2143 privptr->p_env->read_buffers * privptr->p_buff_pages_perread; 2141 privptr->p_buff_pages_perread;
2144 } 2142 }
2145 if (privptr->p_env->write_size < PAGE_SIZE) { 2143 if (privptr->p_env->write_size < PAGE_SIZE) {
2146 claw_writes_perpage= 2144 claw_writes_perpage =
2147 PAGE_SIZE / privptr->p_env->write_size; 2145 PAGE_SIZE / privptr->p_env->write_size;
2148 claw_write_pages= 2146 claw_write_pages = DIV_ROUND_UP(privptr->p_env->write_buffers,
2149 (privptr->p_env->write_buffers + claw_writes_perpage -1) / 2147 claw_writes_perpage);
2150 claw_writes_perpage;
2151 2148
2152 } 2149 }
2153 else { /* > or equal */ 2150 else { /* > or equal */
2154 privptr->p_buff_pages_perwrite= 2151 privptr->p_buff_pages_perwrite =
2155 (privptr->p_env->read_size + PAGE_SIZE - 1) / PAGE_SIZE; 2152 DIV_ROUND_UP(privptr->p_env->read_size, PAGE_SIZE);
2156 claw_write_pages= 2153 claw_write_pages = privptr->p_env->write_buffers *
2157 privptr->p_env->write_buffers * privptr->p_buff_pages_perwrite; 2154 privptr->p_buff_pages_perwrite;
2158 } 2155 }
2159#ifdef DEBUGMSG 2156#ifdef DEBUGMSG
2160 if (privptr->p_env->read_size < PAGE_SIZE) { 2157 if (privptr->p_env->read_size < PAGE_SIZE) {
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b82595cf13e8..cf627cd1b4c8 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -686,7 +686,7 @@ config UART0_RTS_PIN
686 686
687config SERIAL_BFIN_UART1 687config SERIAL_BFIN_UART1
688 bool "Enable UART1" 688 bool "Enable UART1"
689 depends on SERIAL_BFIN && (BF534 || BF536 || BF537 || BF54x) 689 depends on SERIAL_BFIN && (!BF531 && !BF532 && !BF533 && !BF561)
690 help 690 help
691 Enable UART1 691 Enable UART1
692 692
@@ -699,14 +699,14 @@ config BFIN_UART1_CTSRTS
699 699
700config UART1_CTS_PIN 700config UART1_CTS_PIN
701 int "UART1 CTS pin" 701 int "UART1 CTS pin"
702 depends on BFIN_UART1_CTSRTS && (BF53x || BF561) 702 depends on BFIN_UART1_CTSRTS && !BF54x
703 default -1 703 default -1
704 help 704 help
705 Refer to ./include/asm-blackfin/gpio.h to see the GPIO map. 705 Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
706 706
707config UART1_RTS_PIN 707config UART1_RTS_PIN
708 int "UART1 RTS pin" 708 int "UART1 RTS pin"
709 depends on BFIN_UART1_CTSRTS && (BF53x || BF561) 709 depends on BFIN_UART1_CTSRTS && !BF54x
710 default -1 710 default -1
711 help 711 help
712 Refer to ./include/asm-blackfin/gpio.h to see the GPIO map. 712 Refer to ./include/asm-blackfin/gpio.h to see the GPIO map.
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index ac2a3ef28d55..0aa345b9a38b 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -1,30 +1,11 @@
1/* 1/*
2 * File: drivers/serial/bfin_5xx.c 2 * Blackfin On-Chip Serial Driver
3 * Based on: Based on drivers/serial/sa1100.c
4 * Author: Aubrey Li <aubrey.li@analog.com>
5 * 3 *
6 * Created: 4 * Copyright 2006-2007 Analog Devices Inc.
7 * Description: Driver for blackfin 5xx serial ports
8 * 5 *
9 * Modified: 6 * Enter bugs at http://blackfin.uclinux.org/
10 * Copyright 2006 Analog Devices Inc.
11 * 7 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 8 * Licensed under the GPL-2 or later.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 9 */
29 10
30#if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 11#if defined(CONFIG_SERIAL_BFIN_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -67,14 +48,12 @@
67#define DMA_RX_XCOUNT 512 48#define DMA_RX_XCOUNT 512
68#define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT) 49#define DMA_RX_YCOUNT (PAGE_SIZE / DMA_RX_XCOUNT)
69 50
70#define DMA_RX_FLUSH_JIFFIES 5 51#define DMA_RX_FLUSH_JIFFIES (HZ / 50)
71 52
72#ifdef CONFIG_SERIAL_BFIN_DMA 53#ifdef CONFIG_SERIAL_BFIN_DMA
73static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart); 54static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart);
74#else 55#else
75static void bfin_serial_do_work(struct work_struct *work);
76static void bfin_serial_tx_chars(struct bfin_serial_port *uart); 56static void bfin_serial_tx_chars(struct bfin_serial_port *uart);
77static void local_put_char(struct bfin_serial_port *uart, char ch);
78#endif 57#endif
79 58
80static void bfin_serial_mctrl_check(struct bfin_serial_port *uart); 59static void bfin_serial_mctrl_check(struct bfin_serial_port *uart);
@@ -85,23 +64,26 @@ static void bfin_serial_mctrl_check(struct bfin_serial_port *uart);
85static void bfin_serial_stop_tx(struct uart_port *port) 64static void bfin_serial_stop_tx(struct uart_port *port)
86{ 65{
87 struct bfin_serial_port *uart = (struct bfin_serial_port *)port; 66 struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
67 struct circ_buf *xmit = &uart->port.info->xmit;
68#if !defined(CONFIG_BF54x) && !defined(CONFIG_SERIAL_BFIN_DMA)
69 unsigned short ier;
70#endif
88 71
89 while (!(UART_GET_LSR(uart) & TEMT)) 72 while (!(UART_GET_LSR(uart) & TEMT))
90 continue; 73 cpu_relax();
91 74
92#ifdef CONFIG_SERIAL_BFIN_DMA 75#ifdef CONFIG_SERIAL_BFIN_DMA
93 disable_dma(uart->tx_dma_channel); 76 disable_dma(uart->tx_dma_channel);
77 xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
78 uart->port.icount.tx += uart->tx_count;
79 uart->tx_count = 0;
80 uart->tx_done = 1;
94#else 81#else
95#ifdef CONFIG_BF54x 82#ifdef CONFIG_BF54x
96 /* Waiting for Transmission Finished */
97 while (!(UART_GET_LSR(uart) & TFI))
98 continue;
99 /* Clear TFI bit */ 83 /* Clear TFI bit */
100 UART_PUT_LSR(uart, TFI); 84 UART_PUT_LSR(uart, TFI);
101 UART_CLEAR_IER(uart, ETBEI); 85 UART_CLEAR_IER(uart, ETBEI);
102#else 86#else
103 unsigned short ier;
104
105 ier = UART_GET_IER(uart); 87 ier = UART_GET_IER(uart);
106 ier &= ~ETBEI; 88 ier &= ~ETBEI;
107 UART_PUT_IER(uart, ier); 89 UART_PUT_IER(uart, ier);
@@ -117,7 +99,8 @@ static void bfin_serial_start_tx(struct uart_port *port)
117 struct bfin_serial_port *uart = (struct bfin_serial_port *)port; 99 struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
118 100
119#ifdef CONFIG_SERIAL_BFIN_DMA 101#ifdef CONFIG_SERIAL_BFIN_DMA
120 bfin_serial_dma_tx_chars(uart); 102 if (uart->tx_done)
103 bfin_serial_dma_tx_chars(uart);
121#else 104#else
122#ifdef CONFIG_BF54x 105#ifdef CONFIG_BF54x
123 UART_SET_IER(uart, ETBEI); 106 UART_SET_IER(uart, ETBEI);
@@ -209,34 +192,27 @@ int kgdb_get_debug_char(void)
209} 192}
210#endif 193#endif
211 194
212#ifdef CONFIG_SERIAL_BFIN_PIO 195#if ANOMALY_05000230 && defined(CONFIG_SERIAL_BFIN_PIO)
213static void local_put_char(struct bfin_serial_port *uart, char ch) 196# define UART_GET_ANOMALY_THRESHOLD(uart) ((uart)->anomaly_threshold)
214{ 197# define UART_SET_ANOMALY_THRESHOLD(uart, v) ((uart)->anomaly_threshold = (v))
215 unsigned short status; 198#else
216 int flags = 0; 199# define UART_GET_ANOMALY_THRESHOLD(uart) 0
217 200# define UART_SET_ANOMALY_THRESHOLD(uart, v)
218 spin_lock_irqsave(&uart->port.lock, flags); 201#endif
219
220 do {
221 status = UART_GET_LSR(uart);
222 } while (!(status & THRE));
223
224 UART_PUT_CHAR(uart, ch);
225 SSYNC();
226
227 spin_unlock_irqrestore(&uart->port.lock, flags);
228}
229 202
203#ifdef CONFIG_SERIAL_BFIN_PIO
230static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 204static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
231{ 205{
232 struct tty_struct *tty = uart->port.info->tty; 206 struct tty_struct *tty = uart->port.info->tty;
233 unsigned int status, ch, flg; 207 unsigned int status, ch, flg;
234 static int in_break = 0; 208 static struct timeval anomaly_start = { .tv_sec = 0 };
235#ifdef CONFIG_KGDB_UART 209#ifdef CONFIG_KGDB_UART
236 struct pt_regs *regs = get_irq_regs(); 210 struct pt_regs *regs = get_irq_regs();
237#endif 211#endif
238 212
239 status = UART_GET_LSR(uart); 213 status = UART_GET_LSR(uart);
214 UART_CLEAR_LSR(uart);
215
240 ch = UART_GET_CHAR(uart); 216 ch = UART_GET_CHAR(uart);
241 uart->port.icount.rx++; 217 uart->port.icount.rx++;
242 218
@@ -262,28 +238,56 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
262#endif 238#endif
263 239
264 if (ANOMALY_05000230) { 240 if (ANOMALY_05000230) {
265 /* The BF533 family of processors have a nice misbehavior where 241 /* The BF533 (and BF561) family of processors have a nice anomaly
266 * they continuously generate characters for a "single" break. 242 * where they continuously generate characters for a "single" break.
267 * We have to basically ignore this flood until the "next" valid 243 * We have to basically ignore this flood until the "next" valid
268 * character comes across. All other Blackfin families operate 244 * character comes across. Due to the nature of the flood, it is
269 * properly though. 245 * not possible to reliably catch bytes that are sent too quickly
246 * after this break. So application code talking to the Blackfin
247 * which sends a break signal must allow at least 1.5 character
248 * times after the end of the break for things to stabilize. This
249 * timeout was picked as it must absolutely be larger than 1
250 * character time +/- some percent. So 1.5 sounds good. All other
251 * Blackfin families operate properly. Woo.
270 * Note: While Anomaly 05000230 does not directly address this, 252 * Note: While Anomaly 05000230 does not directly address this,
271 * the changes that went in for it also fixed this issue. 253 * the changes that went in for it also fixed this issue.
254 * That anomaly was fixed in 0.5+ silicon. I like bunnies.
272 */ 255 */
273 if (in_break) { 256 if (anomaly_start.tv_sec) {
274 if (ch != 0) { 257 struct timeval curr;
275 in_break = 0; 258 suseconds_t usecs;
276 ch = UART_GET_CHAR(uart); 259
277 if (bfin_revid() < 5) 260 if ((~ch & (~ch + 1)) & 0xff)
278 return; 261 goto known_good_char;
279 } else 262
280 return; 263 do_gettimeofday(&curr);
264 if (curr.tv_sec - anomaly_start.tv_sec > 1)
265 goto known_good_char;
266
267 usecs = 0;
268 if (curr.tv_sec != anomaly_start.tv_sec)
269 usecs += USEC_PER_SEC;
270 usecs += curr.tv_usec - anomaly_start.tv_usec;
271
272 if (usecs > UART_GET_ANOMALY_THRESHOLD(uart))
273 goto known_good_char;
274
275 if (ch)
276 anomaly_start.tv_sec = 0;
277 else
278 anomaly_start = curr;
279
280 return;
281
282 known_good_char:
283 anomaly_start.tv_sec = 0;
281 } 284 }
282 } 285 }
283 286
284 if (status & BI) { 287 if (status & BI) {
285 if (ANOMALY_05000230) 288 if (ANOMALY_05000230)
286 in_break = 1; 289 if (bfin_revid() < 5)
290 do_gettimeofday(&anomaly_start);
287 uart->port.icount.brk++; 291 uart->port.icount.brk++;
288 if (uart_handle_break(&uart->port)) 292 if (uart_handle_break(&uart->port))
289 goto ignore_char; 293 goto ignore_char;
@@ -324,7 +328,6 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
324 UART_PUT_CHAR(uart, uart->port.x_char); 328 UART_PUT_CHAR(uart, uart->port.x_char);
325 uart->port.icount.tx++; 329 uart->port.icount.tx++;
326 uart->port.x_char = 0; 330 uart->port.x_char = 0;
327 return;
328 } 331 }
329 /* 332 /*
330 * Check the modem control lines before 333 * Check the modem control lines before
@@ -337,9 +340,12 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart)
337 return; 340 return;
338 } 341 }
339 342
340 local_put_char(uart, xmit->buf[xmit->tail]); 343 while ((UART_GET_LSR(uart) & THRE) && xmit->tail != xmit->head) {
341 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 344 UART_PUT_CHAR(uart, xmit->buf[xmit->tail]);
342 uart->port.icount.tx++; 345 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
346 uart->port.icount.tx++;
347 SSYNC();
348 }
343 349
344 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 350 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
345 uart_write_wakeup(&uart->port); 351 uart_write_wakeup(&uart->port);
@@ -352,21 +358,11 @@ static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id)
352{ 358{
353 struct bfin_serial_port *uart = dev_id; 359 struct bfin_serial_port *uart = dev_id;
354 360
355#ifdef CONFIG_BF54x
356 unsigned short status;
357 spin_lock(&uart->port.lock);
358 status = UART_GET_LSR(uart);
359 while ((UART_GET_IER(uart) & ERBFI) && (status & DR)) {
360 bfin_serial_rx_chars(uart);
361 status = UART_GET_LSR(uart);
362 }
363 spin_unlock(&uart->port.lock);
364#else
365 spin_lock(&uart->port.lock); 361 spin_lock(&uart->port.lock);
366 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_RX_READY) 362 while (UART_GET_LSR(uart) & DR)
367 bfin_serial_rx_chars(uart); 363 bfin_serial_rx_chars(uart);
368 spin_unlock(&uart->port.lock); 364 spin_unlock(&uart->port.lock);
369#endif 365
370 return IRQ_HANDLED; 366 return IRQ_HANDLED;
371} 367}
372 368
@@ -374,25 +370,16 @@ static irqreturn_t bfin_serial_tx_int(int irq, void *dev_id)
374{ 370{
375 struct bfin_serial_port *uart = dev_id; 371 struct bfin_serial_port *uart = dev_id;
376 372
377#ifdef CONFIG_BF54x
378 unsigned short status;
379 spin_lock(&uart->port.lock); 373 spin_lock(&uart->port.lock);
380 status = UART_GET_LSR(uart); 374 if (UART_GET_LSR(uart) & THRE)
381 while ((UART_GET_IER(uart) & ETBEI) && (status & THRE)) {
382 bfin_serial_tx_chars(uart); 375 bfin_serial_tx_chars(uart);
383 status = UART_GET_LSR(uart);
384 }
385 spin_unlock(&uart->port.lock); 376 spin_unlock(&uart->port.lock);
386#else 377
387 spin_lock(&uart->port.lock);
388 while ((UART_GET_IIR(uart) & IIR_STATUS) == IIR_TX_READY)
389 bfin_serial_tx_chars(uart);
390 spin_unlock(&uart->port.lock);
391#endif
392 return IRQ_HANDLED; 378 return IRQ_HANDLED;
393} 379}
380#endif
394 381
395 382#ifdef CONFIG_SERIAL_BFIN_CTSRTS
396static void bfin_serial_do_work(struct work_struct *work) 383static void bfin_serial_do_work(struct work_struct *work)
397{ 384{
398 struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue); 385 struct bfin_serial_port *uart = container_of(work, struct bfin_serial_port, cts_workqueue);
@@ -406,33 +393,27 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
406{ 393{
407 struct circ_buf *xmit = &uart->port.info->xmit; 394 struct circ_buf *xmit = &uart->port.info->xmit;
408 unsigned short ier; 395 unsigned short ier;
409 int flags = 0;
410
411 if (!uart->tx_done)
412 return;
413 396
414 uart->tx_done = 0; 397 uart->tx_done = 0;
415 398
399 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
400 uart->tx_count = 0;
401 uart->tx_done = 1;
402 return;
403 }
404
416 if (uart->port.x_char) { 405 if (uart->port.x_char) {
417 UART_PUT_CHAR(uart, uart->port.x_char); 406 UART_PUT_CHAR(uart, uart->port.x_char);
418 uart->port.icount.tx++; 407 uart->port.icount.tx++;
419 uart->port.x_char = 0; 408 uart->port.x_char = 0;
420 uart->tx_done = 1;
421 return;
422 } 409 }
410
423 /* 411 /*
424 * Check the modem control lines before 412 * Check the modem control lines before
425 * transmitting anything. 413 * transmitting anything.
426 */ 414 */
427 bfin_serial_mctrl_check(uart); 415 bfin_serial_mctrl_check(uart);
428 416
429 if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) {
430 bfin_serial_stop_tx(&uart->port);
431 uart->tx_done = 1;
432 return;
433 }
434
435 spin_lock_irqsave(&uart->port.lock, flags);
436 uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); 417 uart->tx_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE);
437 if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail)) 418 if (uart->tx_count > (UART_XMIT_SIZE - xmit->tail))
438 uart->tx_count = UART_XMIT_SIZE - xmit->tail; 419 uart->tx_count = UART_XMIT_SIZE - xmit->tail;
@@ -448,6 +429,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
448 set_dma_x_count(uart->tx_dma_channel, uart->tx_count); 429 set_dma_x_count(uart->tx_dma_channel, uart->tx_count);
449 set_dma_x_modify(uart->tx_dma_channel, 1); 430 set_dma_x_modify(uart->tx_dma_channel, 1);
450 enable_dma(uart->tx_dma_channel); 431 enable_dma(uart->tx_dma_channel);
432
451#ifdef CONFIG_BF54x 433#ifdef CONFIG_BF54x
452 UART_SET_IER(uart, ETBEI); 434 UART_SET_IER(uart, ETBEI);
453#else 435#else
@@ -455,7 +437,6 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
455 ier |= ETBEI; 437 ier |= ETBEI;
456 UART_PUT_IER(uart, ier); 438 UART_PUT_IER(uart, ier);
457#endif 439#endif
458 spin_unlock_irqrestore(&uart->port.lock, flags);
459} 440}
460 441
461static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) 442static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
@@ -464,7 +445,11 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
464 int i, flg, status; 445 int i, flg, status;
465 446
466 status = UART_GET_LSR(uart); 447 status = UART_GET_LSR(uart);
467 uart->port.icount.rx += CIRC_CNT(uart->rx_dma_buf.head, uart->rx_dma_buf.tail, UART_XMIT_SIZE);; 448 UART_CLEAR_LSR(uart);
449
450 uart->port.icount.rx +=
451 CIRC_CNT(uart->rx_dma_buf.head, uart->rx_dma_buf.tail,
452 UART_XMIT_SIZE);
468 453
469 if (status & BI) { 454 if (status & BI) {
470 uart->port.icount.brk++; 455 uart->port.icount.brk++;
@@ -490,10 +475,12 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
490 else 475 else
491 flg = TTY_NORMAL; 476 flg = TTY_NORMAL;
492 477
493 for (i = uart->rx_dma_buf.head; i < uart->rx_dma_buf.tail; i++) { 478 for (i = uart->rx_dma_buf.tail; i != uart->rx_dma_buf.head; i++) {
494 if (uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i])) 479 if (i >= UART_XMIT_SIZE)
495 goto dma_ignore_char; 480 i = 0;
496 uart_insert_char(&uart->port, status, OE, uart->rx_dma_buf.buf[i], flg); 481 if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
482 uart_insert_char(&uart->port, status, OE,
483 uart->rx_dma_buf.buf[i], flg);
497 } 484 }
498 485
499 dma_ignore_char: 486 dma_ignore_char:
@@ -503,23 +490,23 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
503void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) 490void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
504{ 491{
505 int x_pos, pos; 492 int x_pos, pos;
506 int flags = 0;
507
508 bfin_serial_dma_tx_chars(uart);
509 493
510 spin_lock_irqsave(&uart->port.lock, flags); 494 uart->rx_dma_nrows = get_dma_curr_ycount(uart->rx_dma_channel);
511 x_pos = DMA_RX_XCOUNT - get_dma_curr_xcount(uart->rx_dma_channel); 495 x_pos = get_dma_curr_xcount(uart->rx_dma_channel);
496 uart->rx_dma_nrows = DMA_RX_YCOUNT - uart->rx_dma_nrows;
497 if (uart->rx_dma_nrows == DMA_RX_YCOUNT)
498 uart->rx_dma_nrows = 0;
499 x_pos = DMA_RX_XCOUNT - x_pos;
512 if (x_pos == DMA_RX_XCOUNT) 500 if (x_pos == DMA_RX_XCOUNT)
513 x_pos = 0; 501 x_pos = 0;
514 502
515 pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos; 503 pos = uart->rx_dma_nrows * DMA_RX_XCOUNT + x_pos;
516 504 if (pos != uart->rx_dma_buf.tail) {
517 if (pos>uart->rx_dma_buf.tail) { 505 uart->rx_dma_buf.head = pos;
518 uart->rx_dma_buf.tail = pos;
519 bfin_serial_dma_rx_chars(uart); 506 bfin_serial_dma_rx_chars(uart);
520 uart->rx_dma_buf.head = uart->rx_dma_buf.tail; 507 uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
521 } 508 }
522 spin_unlock_irqrestore(&uart->port.lock, flags); 509
523 uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES; 510 uart->rx_dma_timer.expires = jiffies + DMA_RX_FLUSH_JIFFIES;
524 add_timer(&(uart->rx_dma_timer)); 511 add_timer(&(uart->rx_dma_timer));
525} 512}
@@ -532,8 +519,8 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
532 519
533 spin_lock(&uart->port.lock); 520 spin_lock(&uart->port.lock);
534 if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) { 521 if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) {
535 clear_dma_irqstat(uart->tx_dma_channel);
536 disable_dma(uart->tx_dma_channel); 522 disable_dma(uart->tx_dma_channel);
523 clear_dma_irqstat(uart->tx_dma_channel);
537#ifdef CONFIG_BF54x 524#ifdef CONFIG_BF54x
538 UART_CLEAR_IER(uart, ETBEI); 525 UART_CLEAR_IER(uart, ETBEI);
539#else 526#else
@@ -541,15 +528,13 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
541 ier &= ~ETBEI; 528 ier &= ~ETBEI;
542 UART_PUT_IER(uart, ier); 529 UART_PUT_IER(uart, ier);
543#endif 530#endif
544 xmit->tail = (xmit->tail+uart->tx_count) &(UART_XMIT_SIZE -1); 531 xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
545 uart->port.icount.tx+=uart->tx_count; 532 uart->port.icount.tx += uart->tx_count;
546 533
547 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 534 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
548 uart_write_wakeup(&uart->port); 535 uart_write_wakeup(&uart->port);
549 536
550 if (uart_circ_empty(xmit)) 537 bfin_serial_dma_tx_chars(uart);
551 bfin_serial_stop_tx(&uart->port);
552 uart->tx_done = 1;
553 } 538 }
554 539
555 spin_unlock(&uart->port.lock); 540 spin_unlock(&uart->port.lock);
@@ -561,18 +546,15 @@ static irqreturn_t bfin_serial_dma_rx_int(int irq, void *dev_id)
561 struct bfin_serial_port *uart = dev_id; 546 struct bfin_serial_port *uart = dev_id;
562 unsigned short irqstat; 547 unsigned short irqstat;
563 548
564 uart->rx_dma_nrows++;
565 if (uart->rx_dma_nrows == DMA_RX_YCOUNT) {
566 uart->rx_dma_nrows = 0;
567 uart->rx_dma_buf.tail = DMA_RX_XCOUNT*DMA_RX_YCOUNT;
568 bfin_serial_dma_rx_chars(uart);
569 uart->rx_dma_buf.head = uart->rx_dma_buf.tail = 0;
570 }
571 spin_lock(&uart->port.lock); 549 spin_lock(&uart->port.lock);
572 irqstat = get_dma_curr_irqstat(uart->rx_dma_channel); 550 irqstat = get_dma_curr_irqstat(uart->rx_dma_channel);
573 clear_dma_irqstat(uart->rx_dma_channel); 551 clear_dma_irqstat(uart->rx_dma_channel);
574
575 spin_unlock(&uart->port.lock); 552 spin_unlock(&uart->port.lock);
553
554 del_timer(&(uart->rx_dma_timer));
555 uart->rx_dma_timer.expires = jiffies;
556 add_timer(&(uart->rx_dma_timer));
557
576 return IRQ_HANDLED; 558 return IRQ_HANDLED;
577} 559}
578#endif 560#endif
@@ -599,7 +581,11 @@ static unsigned int bfin_serial_get_mctrl(struct uart_port *port)
599 if (uart->cts_pin < 0) 581 if (uart->cts_pin < 0)
600 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 582 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
601 583
584# ifdef BF54x
585 if (UART_GET_MSR(uart) & CTS)
586# else
602 if (gpio_get_value(uart->cts_pin)) 587 if (gpio_get_value(uart->cts_pin))
588# endif
603 return TIOCM_DSR | TIOCM_CAR; 589 return TIOCM_DSR | TIOCM_CAR;
604 else 590 else
605#endif 591#endif
@@ -614,9 +600,17 @@ static void bfin_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
614 return; 600 return;
615 601
616 if (mctrl & TIOCM_RTS) 602 if (mctrl & TIOCM_RTS)
603# ifdef BF54x
604 UART_PUT_MCR(uart, UART_GET_MCR(uart) & ~MRTS);
605# else
617 gpio_set_value(uart->rts_pin, 0); 606 gpio_set_value(uart->rts_pin, 0);
607# endif
618 else 608 else
609# ifdef BF54x
610 UART_PUT_MCR(uart, UART_GET_MCR(uart) | MRTS);
611# else
619 gpio_set_value(uart->rts_pin, 1); 612 gpio_set_value(uart->rts_pin, 1);
613# endif
620#endif 614#endif
621} 615}
622 616
@@ -627,22 +621,17 @@ static void bfin_serial_mctrl_check(struct bfin_serial_port *uart)
627{ 621{
628#ifdef CONFIG_SERIAL_BFIN_CTSRTS 622#ifdef CONFIG_SERIAL_BFIN_CTSRTS
629 unsigned int status; 623 unsigned int status;
630# ifdef CONFIG_SERIAL_BFIN_DMA
631 struct uart_info *info = uart->port.info; 624 struct uart_info *info = uart->port.info;
632 struct tty_struct *tty = info->tty; 625 struct tty_struct *tty = info->tty;
633 626
634 status = bfin_serial_get_mctrl(&uart->port); 627 status = bfin_serial_get_mctrl(&uart->port);
628 uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
635 if (!(status & TIOCM_CTS)) { 629 if (!(status & TIOCM_CTS)) {
636 tty->hw_stopped = 1; 630 tty->hw_stopped = 1;
631 schedule_work(&uart->cts_workqueue);
637 } else { 632 } else {
638 tty->hw_stopped = 0; 633 tty->hw_stopped = 0;
639 } 634 }
640# else
641 status = bfin_serial_get_mctrl(&uart->port);
642 uart_handle_cts_change(&uart->port, status & TIOCM_CTS);
643 if (!(status & TIOCM_CTS))
644 schedule_work(&uart->cts_workqueue);
645# endif
646#endif 635#endif
647} 636}
648 637
@@ -743,6 +732,7 @@ static void bfin_serial_shutdown(struct uart_port *port)
743 disable_dma(uart->rx_dma_channel); 732 disable_dma(uart->rx_dma_channel);
744 free_dma(uart->rx_dma_channel); 733 free_dma(uart->rx_dma_channel);
745 del_timer(&(uart->rx_dma_timer)); 734 del_timer(&(uart->rx_dma_timer));
735 dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0);
746#else 736#else
747#ifdef CONFIG_KGDB_UART 737#ifdef CONFIG_KGDB_UART
748 if (uart->port.line != CONFIG_KGDB_UART_PORT) 738 if (uart->port.line != CONFIG_KGDB_UART_PORT)
@@ -814,6 +804,8 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
814 quot = uart_get_divisor(port, baud); 804 quot = uart_get_divisor(port, baud);
815 spin_lock_irqsave(&uart->port.lock, flags); 805 spin_lock_irqsave(&uart->port.lock, flags);
816 806
807 UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
808
817 do { 809 do {
818 lsr = UART_GET_LSR(uart); 810 lsr = UART_GET_LSR(uart);
819 } while (!(lsr & TEMT)); 811 } while (!(lsr & TEMT));
@@ -956,10 +948,9 @@ static void __init bfin_serial_init_ports(void)
956 bfin_serial_ports[i].rx_dma_channel = 948 bfin_serial_ports[i].rx_dma_channel =
957 bfin_serial_resource[i].uart_rx_dma_channel; 949 bfin_serial_resource[i].uart_rx_dma_channel;
958 init_timer(&(bfin_serial_ports[i].rx_dma_timer)); 950 init_timer(&(bfin_serial_ports[i].rx_dma_timer));
959#else
960 INIT_WORK(&bfin_serial_ports[i].cts_workqueue, bfin_serial_do_work);
961#endif 951#endif
962#ifdef CONFIG_SERIAL_BFIN_CTSRTS 952#ifdef CONFIG_SERIAL_BFIN_CTSRTS
953 INIT_WORK(&bfin_serial_ports[i].cts_workqueue, bfin_serial_do_work);
963 bfin_serial_ports[i].cts_pin = 954 bfin_serial_ports[i].cts_pin =
964 bfin_serial_resource[i].uart_cts_pin; 955 bfin_serial_resource[i].uart_cts_pin;
965 bfin_serial_ports[i].rts_pin = 956 bfin_serial_ports[i].rts_pin =
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 9ce12cb2cebc..a8c116b80bff 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -41,6 +41,7 @@
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/console.h> 42#include <linux/console.h>
43#include <linux/platform_device.h> 43#include <linux/platform_device.h>
44#include <linux/serial_sci.h>
44 45
45#ifdef CONFIG_CPU_FREQ 46#ifdef CONFIG_CPU_FREQ
46#include <linux/notifier.h> 47#include <linux/notifier.h>
@@ -54,7 +55,6 @@
54#include <asm/kgdb.h> 55#include <asm/kgdb.h>
55#endif 56#endif
56 57
57#include <asm/sci.h>
58#include "sh-sci.h" 58#include "sh-sci.h"
59 59
60struct sci_port { 60struct sci_port {
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index 9cfcfd8dad5e..617efb1640b1 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Core maple bus functionality 2 * Core maple bus functionality
3 * 3 *
4 * Copyright (C) 2007 Adrian McMenamin 4 * Copyright (C) 2007, 2008 Adrian McMenamin
5 * 5 *
6 * Based on 2.4 code by: 6 * Based on 2.4 code by:
7 * 7 *
@@ -18,7 +18,6 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/module.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/list.h> 22#include <linux/list.h>
24#include <linux/io.h> 23#include <linux/io.h>
@@ -54,7 +53,7 @@ static struct device maple_bus;
54static int subdevice_map[MAPLE_PORTS]; 53static int subdevice_map[MAPLE_PORTS];
55static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
56static unsigned long maple_pnp_time; 55static unsigned long maple_pnp_time;
57static int started, scanning, liststatus, realscan; 56static int started, scanning, liststatus, fullscan;
58static struct kmem_cache *maple_queue_cache; 57static struct kmem_cache *maple_queue_cache;
59 58
60struct maple_device_specify { 59struct maple_device_specify {
@@ -62,6 +61,9 @@ struct maple_device_specify {
62 int unit; 61 int unit;
63}; 62};
64 63
64static bool checked[4];
65static struct maple_device *baseunits[4];
66
65/** 67/**
66 * maple_driver_register - register a device driver 68 * maple_driver_register - register a device driver
67 * automatically makes the driver bus a maple bus 69 * automatically makes the driver bus a maple bus
@@ -309,11 +311,9 @@ static void maple_attach_driver(struct maple_device *mdev)
309 else 311 else
310 break; 312 break;
311 313
312 if (realscan) { 314 printk(KERN_INFO "Maple device detected: %s\n",
313 printk(KERN_INFO "Maple device detected: %s\n", 315 mdev->product_name);
314 mdev->product_name); 316 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
315 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
316 }
317 317
318 function = be32_to_cpu(mdev->devinfo.function); 318 function = be32_to_cpu(mdev->devinfo.function);
319 319
@@ -323,10 +323,9 @@ static void maple_attach_driver(struct maple_device *mdev)
323 mdev->driver = &maple_dummy_driver; 323 mdev->driver = &maple_dummy_driver;
324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port); 324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port);
325 } else { 325 } else {
326 if (realscan) 326 printk(KERN_INFO
327 printk(KERN_INFO 327 "Maple bus at (%d, %d): Function 0x%lX\n",
328 "Maple bus at (%d, %d): Function 0x%lX\n", 328 mdev->port, mdev->unit, function);
329 mdev->port, mdev->unit, function);
330 329
331 matched = 330 matched =
332 bus_for_each_drv(&maple_bus_type, NULL, mdev, 331 bus_for_each_drv(&maple_bus_type, NULL, mdev,
@@ -334,9 +333,8 @@ static void maple_attach_driver(struct maple_device *mdev)
334 333
335 if (matched == 0) { 334 if (matched == 0) {
336 /* Driver does not exist yet */ 335 /* Driver does not exist yet */
337 if (realscan) 336 printk(KERN_INFO
338 printk(KERN_INFO 337 "No maple driver found.\n");
339 "No maple driver found.\n");
340 mdev->driver = &maple_dummy_driver; 338 mdev->driver = &maple_dummy_driver;
341 } 339 }
342 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port, 340 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port,
@@ -472,9 +470,12 @@ static void maple_response_none(struct maple_device *mdev,
472 maple_detach_driver(mdev); 470 maple_detach_driver(mdev);
473 return; 471 return;
474 } 472 }
475 if (!started) { 473 if (!started || !fullscan) {
476 printk(KERN_INFO "No maple devices attached to port %d\n", 474 if (checked[mdev->port] == false) {
477 mdev->port); 475 checked[mdev->port] = true;
476 printk(KERN_INFO "No maple devices attached"
477 " to port %d\n", mdev->port);
478 }
478 return; 479 return;
479 } 480 }
480 maple_clean_submap(mdev); 481 maple_clean_submap(mdev);
@@ -485,8 +486,14 @@ static void maple_response_devinfo(struct maple_device *mdev,
485 char *recvbuf) 486 char *recvbuf)
486{ 487{
487 char submask; 488 char submask;
488 if ((!started) || (scanning == 2)) { 489 if (!started || (scanning == 2) || !fullscan) {
489 maple_attach_driver(mdev); 490 if ((mdev->unit == 0) && (checked[mdev->port] == false)) {
491 checked[mdev->port] = true;
492 maple_attach_driver(mdev);
493 } else {
494 if (mdev->unit != 0)
495 maple_attach_driver(mdev);
496 }
490 return; 497 return;
491 } 498 }
492 if (mdev->unit == 0) { 499 if (mdev->unit == 0) {
@@ -505,6 +512,7 @@ static void maple_dma_handler(struct work_struct *work)
505 struct maple_device *dev; 512 struct maple_device *dev;
506 char *recvbuf; 513 char *recvbuf;
507 enum maple_code code; 514 enum maple_code code;
515 int i;
508 516
509 if (!maple_dma_done()) 517 if (!maple_dma_done())
510 return; 518 return;
@@ -557,6 +565,19 @@ static void maple_dma_handler(struct work_struct *work)
557 } else 565 } else
558 scanning = 0; 566 scanning = 0;
559 567
568 if (!fullscan) {
569 fullscan = 1;
570 for (i = 0; i < MAPLE_PORTS; i++) {
571 if (checked[i] == false) {
572 fullscan = 0;
573 dev = baseunits[i];
574 dev->mq->command =
575 MAPLE_COMMAND_DEVINFO;
576 dev->mq->length = 0;
577 maple_add_packet(dev->mq);
578 }
579 }
580 }
560 if (started == 0) 581 if (started == 0)
561 started = 1; 582 started = 1;
562 } 583 }
@@ -694,7 +715,9 @@ static int __init maple_bus_init(void)
694 715
695 /* setup maple ports */ 716 /* setup maple ports */
696 for (i = 0; i < MAPLE_PORTS; i++) { 717 for (i = 0; i < MAPLE_PORTS; i++) {
718 checked[i] = false;
697 mdev[i] = maple_alloc_dev(i, 0); 719 mdev[i] = maple_alloc_dev(i, 0);
720 baseunits[i] = mdev[i];
698 if (!mdev[i]) { 721 if (!mdev[i]) {
699 while (i-- > 0) 722 while (i-- > 0)
700 maple_free_dev(mdev[i]); 723 maple_free_dev(mdev[i]);
@@ -703,12 +726,9 @@ static int __init maple_bus_init(void)
703 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; 726 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO;
704 mdev[i]->mq->length = 0; 727 mdev[i]->mq->length = 0;
705 maple_add_packet(mdev[i]->mq); 728 maple_add_packet(mdev[i]->mq);
706 /* delay aids hardware detection */
707 mdelay(5);
708 subdevice_map[i] = 0; 729 subdevice_map[i] = 0;
709 } 730 }
710 731
711 realscan = 1;
712 /* setup maplebus hardware */ 732 /* setup maplebus hardware */
713 maplebus_dma_reset(); 733 maplebus_dma_reset();
714 /* initial detection */ 734 /* initial detection */
diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
index d976660cb7f0..adea792fb675 100644
--- a/drivers/ssb/Kconfig
+++ b/drivers/ssb/Kconfig
@@ -35,6 +35,11 @@ config SSB_PCIHOST
35 35
36 If unsure, say Y 36 If unsure, say Y
37 37
38config SSB_B43_PCI_BRIDGE
39 bool
40 depends on SSB_PCIHOST
41 default n
42
38config SSB_PCMCIAHOST_POSSIBLE 43config SSB_PCMCIAHOST_POSSIBLE
39 bool 44 bool
40 depends on SSB && (PCMCIA = y || PCMCIA = SSB) && EXPERIMENTAL 45 depends on SSB && (PCMCIA = y || PCMCIA = SSB) && EXPERIMENTAL
@@ -105,6 +110,12 @@ config SSB_DRIVER_MIPS
105 110
106 If unsure, say N 111 If unsure, say N
107 112
113# Assumption: We are on embedded, if we compile the MIPS core.
114config SSB_EMBEDDED
115 bool
116 depends on SSB_DRIVER_MIPS
117 default y
118
108config SSB_DRIVER_EXTIF 119config SSB_DRIVER_EXTIF
109 bool "SSB Broadcom EXTIF core driver (EXPERIMENTAL)" 120 bool "SSB Broadcom EXTIF core driver (EXPERIMENTAL)"
110 depends on SSB_DRIVER_MIPS && EXPERIMENTAL 121 depends on SSB_DRIVER_MIPS && EXPERIMENTAL
diff --git a/drivers/ssb/Makefile b/drivers/ssb/Makefile
index 7be397595805..de94c2eb7a37 100644
--- a/drivers/ssb/Makefile
+++ b/drivers/ssb/Makefile
@@ -1,5 +1,6 @@
1# core 1# core
2ssb-y += main.o scan.o 2ssb-y += main.o scan.o
3ssb-$(CONFIG_SSB_EMBEDDED) += embedded.o
3 4
4# host support 5# host support
5ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o 6ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o
@@ -13,6 +14,6 @@ ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
13 14
14# b43 pci-ssb-bridge driver 15# b43 pci-ssb-bridge driver
15# Not strictly a part of SSB, but kept here for convenience 16# Not strictly a part of SSB, but kept here for convenience
16ssb-$(CONFIG_SSB_PCIHOST) += b43_pci_bridge.o 17ssb-$(CONFIG_SSB_B43_PCI_BRIDGE) += b43_pci_bridge.o
17 18
18obj-$(CONFIG_SSB) += ssb.o 19obj-$(CONFIG_SSB) += ssb.o
diff --git a/drivers/ssb/driver_chipcommon.c b/drivers/ssb/driver_chipcommon.c
index 6fbf1c53b6f2..e586321a473a 100644
--- a/drivers/ssb/driver_chipcommon.c
+++ b/drivers/ssb/driver_chipcommon.c
@@ -39,12 +39,14 @@ static inline void chipco_write32(struct ssb_chipcommon *cc,
39 ssb_write32(cc->dev, offset, value); 39 ssb_write32(cc->dev, offset, value);
40} 40}
41 41
42static inline void chipco_write32_masked(struct ssb_chipcommon *cc, u16 offset, 42static inline u32 chipco_write32_masked(struct ssb_chipcommon *cc, u16 offset,
43 u32 mask, u32 value) 43 u32 mask, u32 value)
44{ 44{
45 value &= mask; 45 value &= mask;
46 value |= chipco_read32(cc, offset) & ~mask; 46 value |= chipco_read32(cc, offset) & ~mask;
47 chipco_write32(cc, offset, value); 47 chipco_write32(cc, offset, value);
48
49 return value;
48} 50}
49 51
50void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc, 52void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc,
@@ -356,14 +358,29 @@ u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask)
356 return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask; 358 return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask;
357} 359}
358 360
359void ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value) 361u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value)
362{
363 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
364}
365
366u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value)
367{
368 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
369}
370
371u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
372{
373 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
374}
375
376u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
360{ 377{
361 chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value); 378 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
362} 379}
363 380
364void ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value) 381u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value)
365{ 382{
366 chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value); 383 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
367} 384}
368 385
369#ifdef CONFIG_SSB_SERIAL 386#ifdef CONFIG_SSB_SERIAL
@@ -376,6 +393,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
376 unsigned int irq; 393 unsigned int irq;
377 u32 baud_base, div; 394 u32 baud_base, div;
378 u32 i, n; 395 u32 i, n;
396 unsigned int ccrev = cc->dev->id.revision;
379 397
380 plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT); 398 plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT);
381 irq = ssb_mips_irq(cc->dev); 399 irq = ssb_mips_irq(cc->dev);
@@ -387,14 +405,39 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
387 chipco_read32(cc, SSB_CHIPCO_CLOCK_M2)); 405 chipco_read32(cc, SSB_CHIPCO_CLOCK_M2));
388 div = 1; 406 div = 1;
389 } else { 407 } else {
390 if (cc->dev->id.revision >= 11) { 408 if (ccrev == 20) {
409 /* BCM5354 uses constant 25MHz clock */
410 baud_base = 25000000;
411 div = 48;
412 /* Set the override bit so we don't divide it */
413 chipco_write32(cc, SSB_CHIPCO_CORECTL,
414 chipco_read32(cc, SSB_CHIPCO_CORECTL)
415 | SSB_CHIPCO_CORECTL_UARTCLK0);
416 } else if ((ccrev >= 11) && (ccrev != 15)) {
391 /* Fixed ALP clock */ 417 /* Fixed ALP clock */
392 baud_base = 20000000; 418 baud_base = 20000000;
419 if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
420 /* FIXME: baud_base is different for devices with a PMU */
421 SSB_WARN_ON(1);
422 }
393 div = 1; 423 div = 1;
424 if (ccrev >= 21) {
425 /* Turn off UART clock before switching clocksource. */
426 chipco_write32(cc, SSB_CHIPCO_CORECTL,
427 chipco_read32(cc, SSB_CHIPCO_CORECTL)
428 & ~SSB_CHIPCO_CORECTL_UARTCLKEN);
429 }
394 /* Set the override bit so we don't divide it */ 430 /* Set the override bit so we don't divide it */
395 chipco_write32(cc, SSB_CHIPCO_CORECTL, 431 chipco_write32(cc, SSB_CHIPCO_CORECTL,
396 SSB_CHIPCO_CORECTL_UARTCLK0); 432 chipco_read32(cc, SSB_CHIPCO_CORECTL)
397 } else if (cc->dev->id.revision >= 3) { 433 | SSB_CHIPCO_CORECTL_UARTCLK0);
434 if (ccrev >= 21) {
435 /* Re-enable the UART clock. */
436 chipco_write32(cc, SSB_CHIPCO_CORECTL,
437 chipco_read32(cc, SSB_CHIPCO_CORECTL)
438 | SSB_CHIPCO_CORECTL_UARTCLKEN);
439 }
440 } else if (ccrev >= 3) {
398 /* Internal backplane clock */ 441 /* Internal backplane clock */
399 baud_base = ssb_clockspeed(bus); 442 baud_base = ssb_clockspeed(bus);
400 div = chipco_read32(cc, SSB_CHIPCO_CLKDIV) 443 div = chipco_read32(cc, SSB_CHIPCO_CLKDIV)
@@ -406,7 +449,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
406 } 449 }
407 450
408 /* Clock source depends on strapping if UartClkOverride is unset */ 451 /* Clock source depends on strapping if UartClkOverride is unset */
409 if ((cc->dev->id.revision > 0) && 452 if ((ccrev > 0) &&
410 !(chipco_read32(cc, SSB_CHIPCO_CORECTL) & SSB_CHIPCO_CORECTL_UARTCLK0)) { 453 !(chipco_read32(cc, SSB_CHIPCO_CORECTL) & SSB_CHIPCO_CORECTL_UARTCLK0)) {
411 if ((cc->capabilities & SSB_CHIPCO_CAP_UARTCLK) == 454 if ((cc->capabilities & SSB_CHIPCO_CAP_UARTCLK) ==
412 SSB_CHIPCO_CAP_UARTCLK_INT) { 455 SSB_CHIPCO_CAP_UARTCLK_INT) {
@@ -428,7 +471,7 @@ int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
428 cc_mmio = cc->dev->bus->mmio + (cc->dev->core_index * SSB_CORE_SIZE); 471 cc_mmio = cc->dev->bus->mmio + (cc->dev->core_index * SSB_CORE_SIZE);
429 uart_regs = cc_mmio + SSB_CHIPCO_UART0_DATA; 472 uart_regs = cc_mmio + SSB_CHIPCO_UART0_DATA;
430 /* Offset changed at after rev 0 */ 473 /* Offset changed at after rev 0 */
431 if (cc->dev->id.revision == 0) 474 if (ccrev == 0)
432 uart_regs += (i * 8); 475 uart_regs += (i * 8);
433 else 476 else
434 uart_regs += (i * 256); 477 uart_regs += (i * 256);
diff --git a/drivers/ssb/driver_extif.c b/drivers/ssb/driver_extif.c
index fe55eb8b038a..c3e1d3e6d610 100644
--- a/drivers/ssb/driver_extif.c
+++ b/drivers/ssb/driver_extif.c
@@ -27,12 +27,14 @@ static inline void extif_write32(struct ssb_extif *extif, u16 offset, u32 value)
27 ssb_write32(extif->dev, offset, value); 27 ssb_write32(extif->dev, offset, value);
28} 28}
29 29
30static inline void extif_write32_masked(struct ssb_extif *extif, u16 offset, 30static inline u32 extif_write32_masked(struct ssb_extif *extif, u16 offset,
31 u32 mask, u32 value) 31 u32 mask, u32 value)
32{ 32{
33 value &= mask; 33 value &= mask;
34 value |= extif_read32(extif, offset) & ~mask; 34 value |= extif_read32(extif, offset) & ~mask;
35 extif_write32(extif, offset, value); 35 extif_write32(extif, offset, value);
36
37 return value;
36} 38}
37 39
38#ifdef CONFIG_SSB_SERIAL 40#ifdef CONFIG_SSB_SERIAL
@@ -110,20 +112,35 @@ void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
110 *m = extif_read32(extif, SSB_EXTIF_CLOCK_SB); 112 *m = extif_read32(extif, SSB_EXTIF_CLOCK_SB);
111} 113}
112 114
115void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
116 u32 ticks)
117{
118 extif_write32(extif, SSB_EXTIF_WATCHDOG, ticks);
119}
120
113u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask) 121u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
114{ 122{
115 return extif_read32(extif, SSB_EXTIF_GPIO_IN) & mask; 123 return extif_read32(extif, SSB_EXTIF_GPIO_IN) & mask;
116} 124}
117 125
118void ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value) 126u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value)
119{ 127{
120 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0), 128 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUT(0),
121 mask, value); 129 mask, value);
122} 130}
123 131
124void ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value) 132u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value)
125{ 133{
126 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0), 134 return extif_write32_masked(extif, SSB_EXTIF_GPIO_OUTEN(0),
127 mask, value); 135 mask, value);
128} 136}
129 137
138u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value)
139{
140 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTPOL, mask, value);
141}
142
143u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value)
144{
145 return extif_write32_masked(extif, SSB_EXTIF_GPIO_INTMASK, mask, value);
146}
diff --git a/drivers/ssb/driver_pcicore.c b/drivers/ssb/driver_pcicore.c
index 2faaa906d5d6..07ab48d9ceab 100644
--- a/drivers/ssb/driver_pcicore.c
+++ b/drivers/ssb/driver_pcicore.c
@@ -11,6 +11,7 @@
11#include <linux/ssb/ssb.h> 11#include <linux/ssb/ssb.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/ssb/ssb_embedded.h>
14 15
15#include "ssb_private.h" 16#include "ssb_private.h"
16 17
@@ -27,6 +28,18 @@ void pcicore_write32(struct ssb_pcicore *pc, u16 offset, u32 value)
27 ssb_write32(pc->dev, offset, value); 28 ssb_write32(pc->dev, offset, value);
28} 29}
29 30
31static inline
32u16 pcicore_read16(struct ssb_pcicore *pc, u16 offset)
33{
34 return ssb_read16(pc->dev, offset);
35}
36
37static inline
38void pcicore_write16(struct ssb_pcicore *pc, u16 offset, u16 value)
39{
40 ssb_write16(pc->dev, offset, value);
41}
42
30/************************************************** 43/**************************************************
31 * Code for hostmode operation. 44 * Code for hostmode operation.
32 **************************************************/ 45 **************************************************/
@@ -66,6 +79,7 @@ int pcibios_plat_dev_init(struct pci_dev *d)
66 base = &ssb_pcicore_pcibus_iobase; 79 base = &ssb_pcicore_pcibus_iobase;
67 else 80 else
68 base = &ssb_pcicore_pcibus_membase; 81 base = &ssb_pcicore_pcibus_membase;
82 res->flags |= IORESOURCE_PCI_FIXED;
69 if (res->end) { 83 if (res->end) {
70 size = res->end - res->start + 1; 84 size = res->end - res->start + 1;
71 if (*base & (size - 1)) 85 if (*base & (size - 1))
@@ -88,10 +102,12 @@ int pcibios_plat_dev_init(struct pci_dev *d)
88 102
89static void __init ssb_fixup_pcibridge(struct pci_dev *dev) 103static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
90{ 104{
105 u8 lat;
106
91 if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0) 107 if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
92 return; 108 return;
93 109
94 ssb_printk(KERN_INFO "PCI: fixing up bridge\n"); 110 ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
95 111
96 /* Enable PCI bridge bus mastering and memory space */ 112 /* Enable PCI bridge bus mastering and memory space */
97 pci_set_master(dev); 113 pci_set_master(dev);
@@ -101,7 +117,10 @@ static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
101 pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3); 117 pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
102 118
103 /* Make sure our latency is high enough to handle the devices behind us */ 119 /* Make sure our latency is high enough to handle the devices behind us */
104 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xa8); 120 lat = 168;
121 ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
122 pci_name(dev), lat);
123 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
105} 124}
106DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge); 125DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge);
107 126
@@ -117,8 +136,10 @@ static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
117 u32 addr = 0; 136 u32 addr = 0;
118 u32 tmp; 137 u32 tmp;
119 138
120 if (unlikely(pc->cardbusmode && dev > 1)) 139 /* We do only have one cardbus device behind the bridge. */
140 if (pc->cardbusmode && (dev >= 1))
121 goto out; 141 goto out;
142
122 if (bus == 0) { 143 if (bus == 0) {
123 /* Type 0 transaction */ 144 /* Type 0 transaction */
124 if (unlikely(dev >= SSB_PCI_SLOT_MAX)) 145 if (unlikely(dev >= SSB_PCI_SLOT_MAX))
@@ -279,14 +300,14 @@ static struct resource ssb_pcicore_mem_resource = {
279 .name = "SSB PCIcore external memory", 300 .name = "SSB PCIcore external memory",
280 .start = SSB_PCI_DMA, 301 .start = SSB_PCI_DMA,
281 .end = SSB_PCI_DMA + SSB_PCI_DMA_SZ - 1, 302 .end = SSB_PCI_DMA + SSB_PCI_DMA_SZ - 1,
282 .flags = IORESOURCE_MEM, 303 .flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED,
283}; 304};
284 305
285static struct resource ssb_pcicore_io_resource = { 306static struct resource ssb_pcicore_io_resource = {
286 .name = "SSB PCIcore external I/O", 307 .name = "SSB PCIcore external I/O",
287 .start = 0x100, 308 .start = 0x100,
288 .end = 0x7FF, 309 .end = 0x7FF,
289 .flags = IORESOURCE_IO, 310 .flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED,
290}; 311};
291 312
292static struct pci_controller ssb_pcicore_controller = { 313static struct pci_controller ssb_pcicore_controller = {
@@ -318,7 +339,16 @@ static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
318 pcicore_write32(pc, SSB_PCICORE_ARBCTL, val); 339 pcicore_write32(pc, SSB_PCICORE_ARBCTL, val);
319 udelay(1); /* Assertion time demanded by the PCI standard */ 340 udelay(1); /* Assertion time demanded by the PCI standard */
320 341
321 /*TODO cardbus mode */ 342 if (pc->dev->bus->has_cardbus_slot) {
343 ssb_dprintk(KERN_INFO PFX "CardBus slot detected\n");
344 pc->cardbusmode = 1;
345 /* GPIO 1 resets the bridge */
346 ssb_gpio_out(pc->dev->bus, 1, 1);
347 ssb_gpio_outen(pc->dev->bus, 1, 1);
348 pcicore_write16(pc, SSB_PCICORE_SPROM(0),
349 pcicore_read16(pc, SSB_PCICORE_SPROM(0))
350 | 0x0400);
351 }
322 352
323 /* 64MB I/O window */ 353 /* 64MB I/O window */
324 pcicore_write32(pc, SSB_PCICORE_SBTOPCI0, 354 pcicore_write32(pc, SSB_PCICORE_SBTOPCI0,
@@ -344,7 +374,8 @@ static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
344 /* Ok, ready to run, register it to the system. 374 /* Ok, ready to run, register it to the system.
345 * The following needs change, if we want to port hostmode 375 * The following needs change, if we want to port hostmode
346 * to non-MIPS platform. */ 376 * to non-MIPS platform. */
347 set_io_port_base((unsigned long)ioremap_nocache(SSB_PCI_MEM, 0x04000000)); 377 ssb_pcicore_controller.io_map_base = (unsigned long)ioremap_nocache(SSB_PCI_MEM, 0x04000000);
378 set_io_port_base(ssb_pcicore_controller.io_map_base);
348 /* Give some time to the PCI controller to configure itself with the new 379 /* Give some time to the PCI controller to configure itself with the new
349 * values. Not waiting at this point causes crashes of the machine. */ 380 * values. Not waiting at this point causes crashes of the machine. */
350 mdelay(10); 381 mdelay(10);
@@ -362,7 +393,7 @@ static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
362 chipid_top != 0x5300) 393 chipid_top != 0x5300)
363 return 0; 394 return 0;
364 395
365 if (bus->sprom.r1.boardflags_lo & SSB_PCICORE_BFL_NOPCI) 396 if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
366 return 0; 397 return 0;
367 398
368 /* The 200-pin BCM4712 package does not bond out PCI. Even when 399 /* The 200-pin BCM4712 package does not bond out PCI. Even when
diff --git a/drivers/ssb/embedded.c b/drivers/ssb/embedded.c
new file mode 100644
index 000000000000..d3ade821555c
--- /dev/null
+++ b/drivers/ssb/embedded.c
@@ -0,0 +1,132 @@
1/*
2 * Sonics Silicon Backplane
3 * Embedded systems support code
4 *
5 * Copyright 2005-2008, Broadcom Corporation
6 * Copyright 2006-2008, Michael Buesch <mb@bu3sch.de>
7 *
8 * Licensed under the GNU/GPL. See COPYING for details.
9 */
10
11#include <linux/ssb/ssb.h>
12#include <linux/ssb/ssb_embedded.h>
13
14#include "ssb_private.h"
15
16
17int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
18{
19 if (ssb_chipco_available(&bus->chipco)) {
20 ssb_chipco_watchdog_timer_set(&bus->chipco, ticks);
21 return 0;
22 }
23 if (ssb_extif_available(&bus->extif)) {
24 ssb_extif_watchdog_timer_set(&bus->extif, ticks);
25 return 0;
26 }
27 return -ENODEV;
28}
29
30u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
31{
32 unsigned long flags;
33 u32 res = 0;
34
35 spin_lock_irqsave(&bus->gpio_lock, flags);
36 if (ssb_chipco_available(&bus->chipco))
37 res = ssb_chipco_gpio_in(&bus->chipco, mask);
38 else if (ssb_extif_available(&bus->extif))
39 res = ssb_extif_gpio_in(&bus->extif, mask);
40 else
41 SSB_WARN_ON(1);
42 spin_unlock_irqrestore(&bus->gpio_lock, flags);
43
44 return res;
45}
46EXPORT_SYMBOL(ssb_gpio_in);
47
48u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value)
49{
50 unsigned long flags;
51 u32 res = 0;
52
53 spin_lock_irqsave(&bus->gpio_lock, flags);
54 if (ssb_chipco_available(&bus->chipco))
55 res = ssb_chipco_gpio_out(&bus->chipco, mask, value);
56 else if (ssb_extif_available(&bus->extif))
57 res = ssb_extif_gpio_out(&bus->extif, mask, value);
58 else
59 SSB_WARN_ON(1);
60 spin_unlock_irqrestore(&bus->gpio_lock, flags);
61
62 return res;
63}
64EXPORT_SYMBOL(ssb_gpio_out);
65
66u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value)
67{
68 unsigned long flags;
69 u32 res = 0;
70
71 spin_lock_irqsave(&bus->gpio_lock, flags);
72 if (ssb_chipco_available(&bus->chipco))
73 res = ssb_chipco_gpio_outen(&bus->chipco, mask, value);
74 else if (ssb_extif_available(&bus->extif))
75 res = ssb_extif_gpio_outen(&bus->extif, mask, value);
76 else
77 SSB_WARN_ON(1);
78 spin_unlock_irqrestore(&bus->gpio_lock, flags);
79
80 return res;
81}
82EXPORT_SYMBOL(ssb_gpio_outen);
83
84u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value)
85{
86 unsigned long flags;
87 u32 res = 0;
88
89 spin_lock_irqsave(&bus->gpio_lock, flags);
90 if (ssb_chipco_available(&bus->chipco))
91 res = ssb_chipco_gpio_control(&bus->chipco, mask, value);
92 spin_unlock_irqrestore(&bus->gpio_lock, flags);
93
94 return res;
95}
96EXPORT_SYMBOL(ssb_gpio_control);
97
98u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value)
99{
100 unsigned long flags;
101 u32 res = 0;
102
103 spin_lock_irqsave(&bus->gpio_lock, flags);
104 if (ssb_chipco_available(&bus->chipco))
105 res = ssb_chipco_gpio_intmask(&bus->chipco, mask, value);
106 else if (ssb_extif_available(&bus->extif))
107 res = ssb_extif_gpio_intmask(&bus->extif, mask, value);
108 else
109 SSB_WARN_ON(1);
110 spin_unlock_irqrestore(&bus->gpio_lock, flags);
111
112 return res;
113}
114EXPORT_SYMBOL(ssb_gpio_intmask);
115
116u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value)
117{
118 unsigned long flags;
119 u32 res = 0;
120
121 spin_lock_irqsave(&bus->gpio_lock, flags);
122 if (ssb_chipco_available(&bus->chipco))
123 res = ssb_chipco_gpio_polarity(&bus->chipco, mask, value);
124 else if (ssb_extif_available(&bus->extif))
125 res = ssb_extif_gpio_polarity(&bus->extif, mask, value);
126 else
127 SSB_WARN_ON(1);
128 spin_unlock_irqrestore(&bus->gpio_lock, flags);
129
130 return res;
131}
132EXPORT_SYMBOL(ssb_gpio_polarity);
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 9028ed5715a1..bedb2b4ee9d2 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -557,6 +557,7 @@ static int ssb_fetch_invariants(struct ssb_bus *bus,
557 goto out; 557 goto out;
558 memcpy(&bus->boardinfo, &iv.boardinfo, sizeof(iv.boardinfo)); 558 memcpy(&bus->boardinfo, &iv.boardinfo, sizeof(iv.boardinfo));
559 memcpy(&bus->sprom, &iv.sprom, sizeof(iv.sprom)); 559 memcpy(&bus->sprom, &iv.sprom, sizeof(iv.sprom));
560 bus->has_cardbus_slot = iv.has_cardbus_slot;
560out: 561out:
561 return err; 562 return err;
562} 563}
@@ -569,6 +570,9 @@ static int ssb_bus_register(struct ssb_bus *bus,
569 570
570 spin_lock_init(&bus->bar_lock); 571 spin_lock_init(&bus->bar_lock);
571 INIT_LIST_HEAD(&bus->list); 572 INIT_LIST_HEAD(&bus->list);
573#ifdef CONFIG_SSB_EMBEDDED
574 spin_lock_init(&bus->gpio_lock);
575#endif
572 576
573 /* Powerup the bus */ 577 /* Powerup the bus */
574 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1); 578 err = ssb_pci_xtal(bus, SSB_GPIO_XTAL | SSB_GPIO_PLL, 1);
diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
index a789364264a6..21eca2b5118b 100644
--- a/drivers/ssb/ssb_private.h
+++ b/drivers/ssb/ssb_private.h
@@ -120,10 +120,10 @@ extern int ssb_devices_thaw(struct ssb_bus *bus);
120extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev); 120extern struct ssb_bus *ssb_pci_dev_to_bus(struct pci_dev *pdev);
121 121
122/* b43_pci_bridge.c */ 122/* b43_pci_bridge.c */
123#ifdef CONFIG_SSB_PCIHOST 123#ifdef CONFIG_SSB_B43_PCI_BRIDGE
124extern int __init b43_pci_ssb_bridge_init(void); 124extern int __init b43_pci_ssb_bridge_init(void);
125extern void __exit b43_pci_ssb_bridge_exit(void); 125extern void __exit b43_pci_ssb_bridge_exit(void);
126#else /* CONFIG_SSB_PCIHOST */ 126#else /* CONFIG_SSB_B43_PCI_BRIDGR */
127static inline int b43_pci_ssb_bridge_init(void) 127static inline int b43_pci_ssb_bridge_init(void)
128{ 128{
129 return 0; 129 return 0;
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 6fca06961559..3033d6945202 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3213,7 +3213,7 @@ static int u132_suspend(struct platform_device *pdev, pm_message_t state)
3213 dev_err(&u132->platform_dev->dev, "device is being removed\n"); 3213 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3214 return -ESHUTDOWN; 3214 return -ESHUTDOWN;
3215 } else { 3215 } else {
3216 int retval = 0; 3216 int retval = 0, ports;
3217 3217
3218 switch (state.event) { 3218 switch (state.event) {
3219 case PM_EVENT_FREEZE: 3219 case PM_EVENT_FREEZE:
@@ -3221,7 +3221,7 @@ static int u132_suspend(struct platform_device *pdev, pm_message_t state)
3221 break; 3221 break;
3222 case PM_EVENT_SUSPEND: 3222 case PM_EVENT_SUSPEND:
3223 case PM_EVENT_HIBERNATE: 3223 case PM_EVENT_HIBERNATE:
3224 int ports = MAX_U132_PORTS; 3224 ports = MAX_U132_PORTS;
3225 while (ports-- > 0) { 3225 while (ports-- > 0) {
3226 port_power(u132, ports, 0); 3226 port_power(u132, ports, 0);
3227 } 3227 }
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 33888bb58144..2c23bade9aa6 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -46,7 +46,7 @@ const struct file_operations ext4_dir_operations = {
46#ifdef CONFIG_COMPAT 46#ifdef CONFIG_COMPAT
47 .compat_ioctl = ext4_compat_ioctl, 47 .compat_ioctl = ext4_compat_ioctl,
48#endif 48#endif
49 .fsync = ext4_sync_file, /* BKL held */ 49 .fsync = ext4_sync_file,
50 .release = ext4_release_dir, 50 .release = ext4_release_dir,
51}; 51};
52 52
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index bc7081f1fbe8..9ae6e67090cd 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -148,6 +148,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
148{ 148{
149 struct ext4_inode_info *ei = EXT4_I(inode); 149 struct ext4_inode_info *ei = EXT4_I(inode);
150 ext4_fsblk_t bg_start; 150 ext4_fsblk_t bg_start;
151 ext4_fsblk_t last_block;
151 ext4_grpblk_t colour; 152 ext4_grpblk_t colour;
152 int depth; 153 int depth;
153 154
@@ -169,8 +170,13 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
169 /* OK. use inode's group */ 170 /* OK. use inode's group */
170 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) + 171 bg_start = (ei->i_block_group * EXT4_BLOCKS_PER_GROUP(inode->i_sb)) +
171 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block); 172 le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_first_data_block);
172 colour = (current->pid % 16) * 173 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
174
175 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
176 colour = (current->pid % 16) *
173 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 177 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
178 else
179 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
174 return bg_start + colour + block; 180 return bg_start + colour + block;
175} 181}
176 182
@@ -349,7 +355,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path)
349#define ext4_ext_show_leaf(inode,path) 355#define ext4_ext_show_leaf(inode,path)
350#endif 356#endif
351 357
352static void ext4_ext_drop_refs(struct ext4_ext_path *path) 358void ext4_ext_drop_refs(struct ext4_ext_path *path)
353{ 359{
354 int depth = path->p_depth; 360 int depth = path->p_depth;
355 int i; 361 int i;
@@ -2168,6 +2174,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2168 newblock = iblock - ee_block + ext_pblock(ex); 2174 newblock = iblock - ee_block + ext_pblock(ex);
2169 ex2 = ex; 2175 ex2 = ex;
2170 2176
2177 err = ext4_ext_get_access(handle, inode, path + depth);
2178 if (err)
2179 goto out;
2180
2171 /* ex1: ee_block to iblock - 1 : uninitialized */ 2181 /* ex1: ee_block to iblock - 1 : uninitialized */
2172 if (iblock > ee_block) { 2182 if (iblock > ee_block) {
2173 ex1 = ex; 2183 ex1 = ex;
@@ -2200,16 +2210,20 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2200 newdepth = ext_depth(inode); 2210 newdepth = ext_depth(inode);
2201 if (newdepth != depth) { 2211 if (newdepth != depth) {
2202 depth = newdepth; 2212 depth = newdepth;
2203 path = ext4_ext_find_extent(inode, iblock, NULL); 2213 ext4_ext_drop_refs(path);
2214 path = ext4_ext_find_extent(inode, iblock, path);
2204 if (IS_ERR(path)) { 2215 if (IS_ERR(path)) {
2205 err = PTR_ERR(path); 2216 err = PTR_ERR(path);
2206 path = NULL;
2207 goto out; 2217 goto out;
2208 } 2218 }
2209 eh = path[depth].p_hdr; 2219 eh = path[depth].p_hdr;
2210 ex = path[depth].p_ext; 2220 ex = path[depth].p_ext;
2211 if (ex2 != &newex) 2221 if (ex2 != &newex)
2212 ex2 = ex; 2222 ex2 = ex;
2223
2224 err = ext4_ext_get_access(handle, inode, path + depth);
2225 if (err)
2226 goto out;
2213 } 2227 }
2214 allocated = max_blocks; 2228 allocated = max_blocks;
2215 } 2229 }
@@ -2230,9 +2244,6 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
2230 ex2->ee_len = cpu_to_le16(allocated); 2244 ex2->ee_len = cpu_to_le16(allocated);
2231 if (ex2 != ex) 2245 if (ex2 != ex)
2232 goto insert; 2246 goto insert;
2233 err = ext4_ext_get_access(handle, inode, path + depth);
2234 if (err)
2235 goto out;
2236 /* 2247 /*
2237 * New (initialized) extent starts from the first block 2248 * New (initialized) extent starts from the first block
2238 * in the current extent. i.e., ex2 == ex 2249 * in the current extent. i.e., ex2 == ex
@@ -2276,9 +2287,22 @@ out:
2276} 2287}
2277 2288
2278/* 2289/*
2290 * Block allocation/map/preallocation routine for extents based files
2291 *
2292 *
2279 * Need to be called with 2293 * Need to be called with
2280 * down_read(&EXT4_I(inode)->i_data_sem) if not allocating file system block 2294 * down_read(&EXT4_I(inode)->i_data_sem) if not allocating file system block
2281 * (ie, create is zero). Otherwise down_write(&EXT4_I(inode)->i_data_sem) 2295 * (ie, create is zero). Otherwise down_write(&EXT4_I(inode)->i_data_sem)
2296 *
2297 * return > 0, number of of blocks already mapped/allocated
2298 * if create == 0 and these are pre-allocated blocks
2299 * buffer head is unmapped
2300 * otherwise blocks are mapped
2301 *
2302 * return = 0, if plain look up failed (blocks have not been allocated)
2303 * buffer head is unmapped
2304 *
2305 * return < 0, error case.
2282 */ 2306 */
2283int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, 2307int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2284 ext4_lblk_t iblock, 2308 ext4_lblk_t iblock,
@@ -2623,7 +2647,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t offset, loff_t len)
2623 * modify 1 super block, 1 block bitmap and 1 group descriptor. 2647 * modify 1 super block, 1 block bitmap and 1 group descriptor.
2624 */ 2648 */
2625 credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3; 2649 credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + 3;
2626 down_write((&EXT4_I(inode)->i_data_sem)); 2650 mutex_lock(&inode->i_mutex);
2627retry: 2651retry:
2628 while (ret >= 0 && ret < max_blocks) { 2652 while (ret >= 0 && ret < max_blocks) {
2629 block = block + ret; 2653 block = block + ret;
@@ -2634,16 +2658,17 @@ retry:
2634 break; 2658 break;
2635 } 2659 }
2636 2660
2637 ret = ext4_ext_get_blocks(handle, inode, block, 2661 ret = ext4_get_blocks_wrap(handle, inode, block,
2638 max_blocks, &map_bh, 2662 max_blocks, &map_bh,
2639 EXT4_CREATE_UNINITIALIZED_EXT, 0); 2663 EXT4_CREATE_UNINITIALIZED_EXT, 0);
2640 WARN_ON(ret <= 0);
2641 if (ret <= 0) { 2664 if (ret <= 0) {
2642 ext4_error(inode->i_sb, "ext4_fallocate", 2665#ifdef EXT4FS_DEBUG
2643 "ext4_ext_get_blocks returned error: " 2666 WARN_ON(ret <= 0);
2644 "inode#%lu, block=%u, max_blocks=%lu", 2667 printk(KERN_ERR "%s: ext4_ext_get_blocks "
2668 "returned error inode#%lu, block=%u, "
2669 "max_blocks=%lu", __func__,
2645 inode->i_ino, block, max_blocks); 2670 inode->i_ino, block, max_blocks);
2646 ret = -EIO; 2671#endif
2647 ext4_mark_inode_dirty(handle, inode); 2672 ext4_mark_inode_dirty(handle, inode);
2648 ret2 = ext4_journal_stop(handle); 2673 ret2 = ext4_journal_stop(handle);
2649 break; 2674 break;
@@ -2680,7 +2705,6 @@ retry:
2680 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 2705 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
2681 goto retry; 2706 goto retry;
2682 2707
2683 up_write((&EXT4_I(inode)->i_data_sem));
2684 /* 2708 /*
2685 * Time to update the file size. 2709 * Time to update the file size.
2686 * Update only when preallocation was requested beyond the file size. 2710 * Update only when preallocation was requested beyond the file size.
@@ -2692,21 +2716,18 @@ retry:
2692 * if no error, we assume preallocation succeeded 2716 * if no error, we assume preallocation succeeded
2693 * completely 2717 * completely
2694 */ 2718 */
2695 mutex_lock(&inode->i_mutex);
2696 i_size_write(inode, offset + len); 2719 i_size_write(inode, offset + len);
2697 EXT4_I(inode)->i_disksize = i_size_read(inode); 2720 EXT4_I(inode)->i_disksize = i_size_read(inode);
2698 mutex_unlock(&inode->i_mutex);
2699 } else if (ret < 0 && nblocks) { 2721 } else if (ret < 0 && nblocks) {
2700 /* Handle partial allocation scenario */ 2722 /* Handle partial allocation scenario */
2701 loff_t newsize; 2723 loff_t newsize;
2702 2724
2703 mutex_lock(&inode->i_mutex);
2704 newsize = (nblocks << blkbits) + i_size_read(inode); 2725 newsize = (nblocks << blkbits) + i_size_read(inode);
2705 i_size_write(inode, EXT4_BLOCK_ALIGN(newsize, blkbits)); 2726 i_size_write(inode, EXT4_BLOCK_ALIGN(newsize, blkbits));
2706 EXT4_I(inode)->i_disksize = i_size_read(inode); 2727 EXT4_I(inode)->i_disksize = i_size_read(inode);
2707 mutex_unlock(&inode->i_mutex);
2708 } 2728 }
2709 } 2729 }
2710 2730
2731 mutex_unlock(&inode->i_mutex);
2711 return ret > 0 ? ret2 : ret; 2732 return ret > 0 ? ret2 : ret;
2712} 2733}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index da18a74b966a..8036b9b5376b 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -702,7 +702,12 @@ got:
702 ei->i_dir_start_lookup = 0; 702 ei->i_dir_start_lookup = 0;
703 ei->i_disksize = 0; 703 ei->i_disksize = 0;
704 704
705 ei->i_flags = EXT4_I(dir)->i_flags & ~EXT4_INDEX_FL; 705 /*
706 * Don't inherit extent flag from directory. We set extent flag on
707 * newly created directory and file only if -o extent mount option is
708 * specified
709 */
710 ei->i_flags = EXT4_I(dir)->i_flags & ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
706 if (S_ISLNK(mode)) 711 if (S_ISLNK(mode))
707 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL); 712 ei->i_flags &= ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
708 /* dirsync only applies to directories */ 713 /* dirsync only applies to directories */
@@ -745,12 +750,15 @@ got:
745 goto fail_free_drop; 750 goto fail_free_drop;
746 } 751 }
747 if (test_opt(sb, EXTENTS)) { 752 if (test_opt(sb, EXTENTS)) {
748 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL; 753 /* set extent flag only for directory and file */
749 ext4_ext_tree_init(handle, inode); 754 if (S_ISDIR(mode) || S_ISREG(mode)) {
750 err = ext4_update_incompat_feature(handle, sb, 755 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
751 EXT4_FEATURE_INCOMPAT_EXTENTS); 756 ext4_ext_tree_init(handle, inode);
752 if (err) 757 err = ext4_update_incompat_feature(handle, sb,
753 goto fail; 758 EXT4_FEATURE_INCOMPAT_EXTENTS);
759 if (err)
760 goto fail;
761 }
754 } 762 }
755 763
756 ext4_debug("allocating inode %lu\n", inode->i_ino); 764 ext4_debug("allocating inode %lu\n", inode->i_ino);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7dd9b50d5ebc..945cbf6cb1fc 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -403,6 +403,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data; 403 __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
404 __le32 *p; 404 __le32 *p;
405 ext4_fsblk_t bg_start; 405 ext4_fsblk_t bg_start;
406 ext4_fsblk_t last_block;
406 ext4_grpblk_t colour; 407 ext4_grpblk_t colour;
407 408
408 /* Try to find previous block */ 409 /* Try to find previous block */
@@ -420,8 +421,13 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind)
420 * into the same cylinder group then. 421 * into the same cylinder group then.
421 */ 422 */
422 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group); 423 bg_start = ext4_group_first_block_no(inode->i_sb, ei->i_block_group);
423 colour = (current->pid % 16) * 424 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1;
425
426 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block)
427 colour = (current->pid % 16) *
424 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 428 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16);
429 else
430 colour = (current->pid % 16) * ((last_block - bg_start) / 16);
425 return bg_start + colour; 431 return bg_start + colour;
426} 432}
427 433
@@ -768,7 +774,6 @@ err_out:
768 * 774 *
769 * `handle' can be NULL if create == 0. 775 * `handle' can be NULL if create == 0.
770 * 776 *
771 * The BKL may not be held on entry here. Be sure to take it early.
772 * return > 0, # of blocks mapped or allocated. 777 * return > 0, # of blocks mapped or allocated.
773 * return = 0, if plain lookup failed. 778 * return = 0, if plain lookup failed.
774 * return < 0, error case. 779 * return < 0, error case.
@@ -903,11 +908,38 @@ out:
903 */ 908 */
904#define DIO_CREDITS 25 909#define DIO_CREDITS 25
905 910
911
912/*
913 *
914 *
915 * ext4_ext4 get_block() wrapper function
916 * It will do a look up first, and returns if the blocks already mapped.
917 * Otherwise it takes the write lock of the i_data_sem and allocate blocks
918 * and store the allocated blocks in the result buffer head and mark it
919 * mapped.
920 *
921 * If file type is extents based, it will call ext4_ext_get_blocks(),
922 * Otherwise, call with ext4_get_blocks_handle() to handle indirect mapping
923 * based files
924 *
925 * On success, it returns the number of blocks being mapped or allocate.
926 * if create==0 and the blocks are pre-allocated and uninitialized block,
927 * the result buffer head is unmapped. If the create ==1, it will make sure
928 * the buffer head is mapped.
929 *
930 * It returns 0 if plain look up failed (blocks have not been allocated), in
931 * that casem, buffer head is unmapped
932 *
933 * It returns the error in case of allocation failure.
934 */
906int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, 935int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
907 unsigned long max_blocks, struct buffer_head *bh, 936 unsigned long max_blocks, struct buffer_head *bh,
908 int create, int extend_disksize) 937 int create, int extend_disksize)
909{ 938{
910 int retval; 939 int retval;
940
941 clear_buffer_mapped(bh);
942
911 /* 943 /*
912 * Try to see if we can get the block without requesting 944 * Try to see if we can get the block without requesting
913 * for new file system block. 945 * for new file system block.
@@ -921,12 +953,26 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
921 inode, block, max_blocks, bh, 0, 0); 953 inode, block, max_blocks, bh, 0, 0);
922 } 954 }
923 up_read((&EXT4_I(inode)->i_data_sem)); 955 up_read((&EXT4_I(inode)->i_data_sem));
924 if (!create || (retval > 0)) 956
957 /* If it is only a block(s) look up */
958 if (!create)
959 return retval;
960
961 /*
962 * Returns if the blocks have already allocated
963 *
964 * Note that if blocks have been preallocated
965 * ext4_ext_get_block() returns th create = 0
966 * with buffer head unmapped.
967 */
968 if (retval > 0 && buffer_mapped(bh))
925 return retval; 969 return retval;
926 970
927 /* 971 /*
928 * We need to allocate new blocks which will result 972 * New blocks allocate and/or writing to uninitialized extent
929 * in i_data update 973 * will possibly result in updating i_data, so we take
974 * the write lock of i_data_sem, and call get_blocks()
975 * with create == 1 flag.
930 */ 976 */
931 down_write((&EXT4_I(inode)->i_data_sem)); 977 down_write((&EXT4_I(inode)->i_data_sem));
932 /* 978 /*
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dd0fcfcb35ce..ef97f19c2f9d 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -627,21 +627,19 @@ static ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb,
627 return block; 627 return block;
628} 628}
629 629
630static inline void *mb_correct_addr_and_bit(int *bit, void *addr)
631{
630#if BITS_PER_LONG == 64 632#if BITS_PER_LONG == 64
631#define mb_correct_addr_and_bit(bit, addr) \ 633 *bit += ((unsigned long) addr & 7UL) << 3;
632{ \ 634 addr = (void *) ((unsigned long) addr & ~7UL);
633 bit += ((unsigned long) addr & 7UL) << 3; \
634 addr = (void *) ((unsigned long) addr & ~7UL); \
635}
636#elif BITS_PER_LONG == 32 635#elif BITS_PER_LONG == 32
637#define mb_correct_addr_and_bit(bit, addr) \ 636 *bit += ((unsigned long) addr & 3UL) << 3;
638{ \ 637 addr = (void *) ((unsigned long) addr & ~3UL);
639 bit += ((unsigned long) addr & 3UL) << 3; \
640 addr = (void *) ((unsigned long) addr & ~3UL); \
641}
642#else 638#else
643#error "how many bits you are?!" 639#error "how many bits you are?!"
644#endif 640#endif
641 return addr;
642}
645 643
646static inline int mb_test_bit(int bit, void *addr) 644static inline int mb_test_bit(int bit, void *addr)
647{ 645{
@@ -649,34 +647,54 @@ static inline int mb_test_bit(int bit, void *addr)
649 * ext4_test_bit on architecture like powerpc 647 * ext4_test_bit on architecture like powerpc
650 * needs unsigned long aligned address 648 * needs unsigned long aligned address
651 */ 649 */
652 mb_correct_addr_and_bit(bit, addr); 650 addr = mb_correct_addr_and_bit(&bit, addr);
653 return ext4_test_bit(bit, addr); 651 return ext4_test_bit(bit, addr);
654} 652}
655 653
656static inline void mb_set_bit(int bit, void *addr) 654static inline void mb_set_bit(int bit, void *addr)
657{ 655{
658 mb_correct_addr_and_bit(bit, addr); 656 addr = mb_correct_addr_and_bit(&bit, addr);
659 ext4_set_bit(bit, addr); 657 ext4_set_bit(bit, addr);
660} 658}
661 659
662static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr) 660static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr)
663{ 661{
664 mb_correct_addr_and_bit(bit, addr); 662 addr = mb_correct_addr_and_bit(&bit, addr);
665 ext4_set_bit_atomic(lock, bit, addr); 663 ext4_set_bit_atomic(lock, bit, addr);
666} 664}
667 665
668static inline void mb_clear_bit(int bit, void *addr) 666static inline void mb_clear_bit(int bit, void *addr)
669{ 667{
670 mb_correct_addr_and_bit(bit, addr); 668 addr = mb_correct_addr_and_bit(&bit, addr);
671 ext4_clear_bit(bit, addr); 669 ext4_clear_bit(bit, addr);
672} 670}
673 671
674static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr) 672static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
675{ 673{
676 mb_correct_addr_and_bit(bit, addr); 674 addr = mb_correct_addr_and_bit(&bit, addr);
677 ext4_clear_bit_atomic(lock, bit, addr); 675 ext4_clear_bit_atomic(lock, bit, addr);
678} 676}
679 677
678static inline int mb_find_next_zero_bit(void *addr, int max, int start)
679{
680 int fix = 0;
681 addr = mb_correct_addr_and_bit(&fix, addr);
682 max += fix;
683 start += fix;
684
685 return ext4_find_next_zero_bit(addr, max, start) - fix;
686}
687
688static inline int mb_find_next_bit(void *addr, int max, int start)
689{
690 int fix = 0;
691 addr = mb_correct_addr_and_bit(&fix, addr);
692 max += fix;
693 start += fix;
694
695 return ext4_find_next_bit(addr, max, start) - fix;
696}
697
680static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) 698static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
681{ 699{
682 char *bb; 700 char *bb;
@@ -906,7 +924,7 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
906 unsigned short chunk; 924 unsigned short chunk;
907 unsigned short border; 925 unsigned short border;
908 926
909 BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb)); 927 BUG_ON(len > EXT4_BLOCKS_PER_GROUP(sb));
910 928
911 border = 2 << sb->s_blocksize_bits; 929 border = 2 << sb->s_blocksize_bits;
912 930
@@ -946,12 +964,12 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
946 964
947 /* initialize buddy from bitmap which is aggregation 965 /* initialize buddy from bitmap which is aggregation
948 * of on-disk bitmap and preallocations */ 966 * of on-disk bitmap and preallocations */
949 i = ext4_find_next_zero_bit(bitmap, max, 0); 967 i = mb_find_next_zero_bit(bitmap, max, 0);
950 grp->bb_first_free = i; 968 grp->bb_first_free = i;
951 while (i < max) { 969 while (i < max) {
952 fragments++; 970 fragments++;
953 first = i; 971 first = i;
954 i = ext4_find_next_bit(bitmap, max, i); 972 i = mb_find_next_bit(bitmap, max, i);
955 len = i - first; 973 len = i - first;
956 free += len; 974 free += len;
957 if (len > 1) 975 if (len > 1)
@@ -959,7 +977,7 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
959 else 977 else
960 grp->bb_counters[0]++; 978 grp->bb_counters[0]++;
961 if (i < max) 979 if (i < max)
962 i = ext4_find_next_zero_bit(bitmap, max, i); 980 i = mb_find_next_zero_bit(bitmap, max, i);
963 } 981 }
964 grp->bb_fragments = fragments; 982 grp->bb_fragments = fragments;
965 983
@@ -967,6 +985,10 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
967 ext4_error(sb, __FUNCTION__, 985 ext4_error(sb, __FUNCTION__,
968 "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n", 986 "EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n",
969 group, free, grp->bb_free); 987 group, free, grp->bb_free);
988 /*
989 * If we intent to continue, we consider group descritor
990 * corrupt and update bb_free using bitmap value
991 */
970 grp->bb_free = free; 992 grp->bb_free = free;
971 } 993 }
972 994
@@ -1778,7 +1800,7 @@ static void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
1778 buddy = mb_find_buddy(e4b, i, &max); 1800 buddy = mb_find_buddy(e4b, i, &max);
1779 BUG_ON(buddy == NULL); 1801 BUG_ON(buddy == NULL);
1780 1802
1781 k = ext4_find_next_zero_bit(buddy, max, 0); 1803 k = mb_find_next_zero_bit(buddy, max, 0);
1782 BUG_ON(k >= max); 1804 BUG_ON(k >= max);
1783 1805
1784 ac->ac_found++; 1806 ac->ac_found++;
@@ -1818,11 +1840,11 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1818 i = e4b->bd_info->bb_first_free; 1840 i = e4b->bd_info->bb_first_free;
1819 1841
1820 while (free && ac->ac_status == AC_STATUS_CONTINUE) { 1842 while (free && ac->ac_status == AC_STATUS_CONTINUE) {
1821 i = ext4_find_next_zero_bit(bitmap, 1843 i = mb_find_next_zero_bit(bitmap,
1822 EXT4_BLOCKS_PER_GROUP(sb), i); 1844 EXT4_BLOCKS_PER_GROUP(sb), i);
1823 if (i >= EXT4_BLOCKS_PER_GROUP(sb)) { 1845 if (i >= EXT4_BLOCKS_PER_GROUP(sb)) {
1824 /* 1846 /*
1825 * IF we corrupt the bitmap we won't find any 1847 * IF we have corrupt bitmap, we won't find any
1826 * free blocks even though group info says we 1848 * free blocks even though group info says we
1827 * we have free blocks 1849 * we have free blocks
1828 */ 1850 */
@@ -1838,6 +1860,12 @@ static void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
1838 ext4_error(sb, __FUNCTION__, "%d free blocks as per " 1860 ext4_error(sb, __FUNCTION__, "%d free blocks as per "
1839 "group info. But got %d blocks\n", 1861 "group info. But got %d blocks\n",
1840 free, ex.fe_len); 1862 free, ex.fe_len);
1863 /*
1864 * The number of free blocks differs. This mostly
1865 * indicate that the bitmap is corrupt. So exit
1866 * without claiming the space.
1867 */
1868 break;
1841 } 1869 }
1842 1870
1843 ext4_mb_measure_extent(ac, &ex, e4b); 1871 ext4_mb_measure_extent(ac, &ex, e4b);
@@ -3740,10 +3768,10 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b,
3740 } 3768 }
3741 3769
3742 while (bit < end) { 3770 while (bit < end) {
3743 bit = ext4_find_next_zero_bit(bitmap_bh->b_data, end, bit); 3771 bit = mb_find_next_zero_bit(bitmap_bh->b_data, end, bit);
3744 if (bit >= end) 3772 if (bit >= end)
3745 break; 3773 break;
3746 next = ext4_find_next_bit(bitmap_bh->b_data, end, bit); 3774 next = mb_find_next_bit(bitmap_bh->b_data, end, bit);
3747 if (next > end) 3775 if (next > end)
3748 next = end; 3776 next = end;
3749 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit + 3777 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit +
@@ -3771,6 +3799,10 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy *e4b,
3771 (unsigned long) pa->pa_len); 3799 (unsigned long) pa->pa_len);
3772 ext4_error(sb, __FUNCTION__, "free %u, pa_free %u\n", 3800 ext4_error(sb, __FUNCTION__, "free %u, pa_free %u\n",
3773 free, pa->pa_free); 3801 free, pa->pa_free);
3802 /*
3803 * pa is already deleted so we use the value obtained
3804 * from the bitmap and continue.
3805 */
3774 } 3806 }
3775 atomic_add(free, &sbi->s_mb_discarded); 3807 atomic_add(free, &sbi->s_mb_discarded);
3776 if (ac) 3808 if (ac)
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 8c6c685b9d22..5c1e27de7755 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -43,6 +43,7 @@ static int finish_range(handle_t *handle, struct inode *inode,
43 43
44 if (IS_ERR(path)) { 44 if (IS_ERR(path)) {
45 retval = PTR_ERR(path); 45 retval = PTR_ERR(path);
46 path = NULL;
46 goto err_out; 47 goto err_out;
47 } 48 }
48 49
@@ -74,6 +75,10 @@ static int finish_range(handle_t *handle, struct inode *inode,
74 } 75 }
75 retval = ext4_ext_insert_extent(handle, inode, path, &newext); 76 retval = ext4_ext_insert_extent(handle, inode, path, &newext);
76err_out: 77err_out:
78 if (path) {
79 ext4_ext_drop_refs(path);
80 kfree(path);
81 }
77 lb->first_pblock = 0; 82 lb->first_pblock = 0;
78 return retval; 83 return retval;
79} 84}
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a9347fb43bcc..28aa2ed4297e 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1804,12 +1804,8 @@ retry:
1804 inode->i_fop = &ext4_dir_operations; 1804 inode->i_fop = &ext4_dir_operations;
1805 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize; 1805 inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
1806 dir_block = ext4_bread (handle, inode, 0, 1, &err); 1806 dir_block = ext4_bread (handle, inode, 0, 1, &err);
1807 if (!dir_block) { 1807 if (!dir_block)
1808 ext4_dec_count(handle, inode); /* is this nlink == 0? */ 1808 goto out_clear_inode;
1809 ext4_mark_inode_dirty(handle, inode);
1810 iput (inode);
1811 goto out_stop;
1812 }
1813 BUFFER_TRACE(dir_block, "get_write_access"); 1809 BUFFER_TRACE(dir_block, "get_write_access");
1814 ext4_journal_get_write_access(handle, dir_block); 1810 ext4_journal_get_write_access(handle, dir_block);
1815 de = (struct ext4_dir_entry_2 *) dir_block->b_data; 1811 de = (struct ext4_dir_entry_2 *) dir_block->b_data;
@@ -1832,7 +1828,8 @@ retry:
1832 ext4_mark_inode_dirty(handle, inode); 1828 ext4_mark_inode_dirty(handle, inode);
1833 err = ext4_add_entry (handle, dentry, inode); 1829 err = ext4_add_entry (handle, dentry, inode);
1834 if (err) { 1830 if (err) {
1835 inode->i_nlink = 0; 1831out_clear_inode:
1832 clear_nlink(inode);
1836 ext4_mark_inode_dirty(handle, inode); 1833 ext4_mark_inode_dirty(handle, inode);
1837 iput (inode); 1834 iput (inode);
1838 goto out_stop; 1835 goto out_stop;
@@ -2164,7 +2161,7 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
2164 dir->i_ctime = dir->i_mtime = ext4_current_time(dir); 2161 dir->i_ctime = dir->i_mtime = ext4_current_time(dir);
2165 ext4_update_dx_flag(dir); 2162 ext4_update_dx_flag(dir);
2166 ext4_mark_inode_dirty(handle, dir); 2163 ext4_mark_inode_dirty(handle, dir);
2167 ext4_dec_count(handle, inode); 2164 drop_nlink(inode);
2168 if (!inode->i_nlink) 2165 if (!inode->i_nlink)
2169 ext4_orphan_add(handle, inode); 2166 ext4_orphan_add(handle, inode);
2170 inode->i_ctime = ext4_current_time(inode); 2167 inode->i_ctime = ext4_current_time(inode);
@@ -2214,7 +2211,7 @@ retry:
2214 err = __page_symlink(inode, symname, l, 2211 err = __page_symlink(inode, symname, l,
2215 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2212 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
2216 if (err) { 2213 if (err) {
2217 ext4_dec_count(handle, inode); 2214 clear_nlink(inode);
2218 ext4_mark_inode_dirty(handle, inode); 2215 ext4_mark_inode_dirty(handle, inode);
2219 iput (inode); 2216 iput (inode);
2220 goto out_stop; 2217 goto out_stop;
@@ -2223,7 +2220,6 @@ retry:
2223 inode->i_op = &ext4_fast_symlink_inode_operations; 2220 inode->i_op = &ext4_fast_symlink_inode_operations;
2224 memcpy((char*)&EXT4_I(inode)->i_data,symname,l); 2221 memcpy((char*)&EXT4_I(inode)->i_data,symname,l);
2225 inode->i_size = l-1; 2222 inode->i_size = l-1;
2226 EXT4_I(inode)->i_flags &= ~EXT4_EXTENTS_FL;
2227 } 2223 }
2228 EXT4_I(inode)->i_disksize = inode->i_size; 2224 EXT4_I(inode)->i_disksize = inode->i_size;
2229 err = ext4_add_nondir(handle, dentry, inode); 2225 err = ext4_add_nondir(handle, dentry, inode);
@@ -2407,7 +2403,7 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
2407 ext4_dec_count(handle, old_dir); 2403 ext4_dec_count(handle, old_dir);
2408 if (new_inode) { 2404 if (new_inode) {
2409 /* checked empty_dir above, can't have another parent, 2405 /* checked empty_dir above, can't have another parent,
2410 * ext3_dec_count() won't work for many-linked dirs */ 2406 * ext4_dec_count() won't work for many-linked dirs */
2411 new_inode->i_nlink = 0; 2407 new_inode->i_nlink = 0;
2412 } else { 2408 } else {
2413 ext4_inc_count(handle, new_dir); 2409 ext4_inc_count(handle, new_dir);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9477a2bd6ff2..e29efa0f9d62 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1037,6 +1037,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1037 ext4_warning(sb, __FUNCTION__, 1037 ext4_warning(sb, __FUNCTION__,
1038 "multiple resizers run on filesystem!"); 1038 "multiple resizers run on filesystem!");
1039 unlock_super(sb); 1039 unlock_super(sb);
1040 ext4_journal_stop(handle);
1040 err = -EBUSY; 1041 err = -EBUSY;
1041 goto exit_put; 1042 goto exit_put;
1042 } 1043 }
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 96ee899d6502..91a1bd67ac1d 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -314,9 +314,12 @@ static int proc_pid_schedstat(struct task_struct *task, char *buffer)
314static int lstats_show_proc(struct seq_file *m, void *v) 314static int lstats_show_proc(struct seq_file *m, void *v)
315{ 315{
316 int i; 316 int i;
317 struct task_struct *task = m->private; 317 struct inode *inode = m->private;
318 seq_puts(m, "Latency Top version : v0.1\n"); 318 struct task_struct *task = get_proc_task(inode);
319 319
320 if (!task)
321 return -ESRCH;
322 seq_puts(m, "Latency Top version : v0.1\n");
320 for (i = 0; i < 32; i++) { 323 for (i = 0; i < 32; i++) {
321 if (task->latency_record[i].backtrace[0]) { 324 if (task->latency_record[i].backtrace[0]) {
322 int q; 325 int q;
@@ -341,32 +344,24 @@ static int lstats_show_proc(struct seq_file *m, void *v)
341 } 344 }
342 345
343 } 346 }
347 put_task_struct(task);
344 return 0; 348 return 0;
345} 349}
346 350
347static int lstats_open(struct inode *inode, struct file *file) 351static int lstats_open(struct inode *inode, struct file *file)
348{ 352{
349 int ret; 353 return single_open(file, lstats_show_proc, inode);
350 struct seq_file *m;
351 struct task_struct *task = get_proc_task(inode);
352
353 ret = single_open(file, lstats_show_proc, NULL);
354 if (!ret) {
355 m = file->private_data;
356 m->private = task;
357 }
358 return ret;
359} 354}
360 355
361static ssize_t lstats_write(struct file *file, const char __user *buf, 356static ssize_t lstats_write(struct file *file, const char __user *buf,
362 size_t count, loff_t *offs) 357 size_t count, loff_t *offs)
363{ 358{
364 struct seq_file *m; 359 struct task_struct *task = get_proc_task(file->f_dentry->d_inode);
365 struct task_struct *task;
366 360
367 m = file->private_data; 361 if (!task)
368 task = m->private; 362 return -ESRCH;
369 clear_all_latency_tracing(task); 363 clear_all_latency_tracing(task);
364 put_task_struct(task);
370 365
371 return count; 366 return count;
372} 367}
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 21dfc9da235e..8831d9518790 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -171,7 +171,7 @@ xfs_parseargs(
171 char *this_char, *value, *eov; 171 char *this_char, *value, *eov;
172 int dsunit, dswidth, vol_dsunit, vol_dswidth; 172 int dsunit, dswidth, vol_dsunit, vol_dswidth;
173 int iosize; 173 int iosize;
174 int ikeep = 0; 174 int dmapi_implies_ikeep = 1;
175 175
176 args->flags |= XFSMNT_BARRIER; 176 args->flags |= XFSMNT_BARRIER;
177 args->flags2 |= XFSMNT2_COMPAT_IOSIZE; 177 args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
@@ -302,10 +302,10 @@ xfs_parseargs(
302 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) { 302 } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
303 args->flags &= ~XFSMNT_BARRIER; 303 args->flags &= ~XFSMNT_BARRIER;
304 } else if (!strcmp(this_char, MNTOPT_IKEEP)) { 304 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
305 ikeep = 1; 305 args->flags |= XFSMNT_IKEEP;
306 args->flags &= ~XFSMNT_IDELETE;
307 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) { 306 } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
308 args->flags |= XFSMNT_IDELETE; 307 dmapi_implies_ikeep = 0;
308 args->flags &= ~XFSMNT_IKEEP;
309 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) { 309 } else if (!strcmp(this_char, MNTOPT_LARGEIO)) {
310 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE; 310 args->flags2 &= ~XFSMNT2_COMPAT_IOSIZE;
311 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) { 311 } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
@@ -410,8 +410,8 @@ xfs_parseargs(
410 * Note that if "ikeep" or "noikeep" mount options are 410 * Note that if "ikeep" or "noikeep" mount options are
411 * supplied, then they are honored. 411 * supplied, then they are honored.
412 */ 412 */
413 if (!(args->flags & XFSMNT_DMAPI) && !ikeep) 413 if ((args->flags & XFSMNT_DMAPI) && dmapi_implies_ikeep)
414 args->flags |= XFSMNT_IDELETE; 414 args->flags |= XFSMNT_IKEEP;
415 415
416 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) { 416 if ((args->flags & XFSMNT_NOALIGN) != XFSMNT_NOALIGN) {
417 if (dsunit) { 417 if (dsunit) {
@@ -446,6 +446,7 @@ xfs_showargs(
446{ 446{
447 static struct proc_xfs_info xfs_info_set[] = { 447 static struct proc_xfs_info xfs_info_set[] = {
448 /* the few simple ones we can get from the mount struct */ 448 /* the few simple ones we can get from the mount struct */
449 { XFS_MOUNT_IKEEP, "," MNTOPT_IKEEP },
449 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC }, 450 { XFS_MOUNT_WSYNC, "," MNTOPT_WSYNC },
450 { XFS_MOUNT_INO64, "," MNTOPT_INO64 }, 451 { XFS_MOUNT_INO64, "," MNTOPT_INO64 },
451 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN }, 452 { XFS_MOUNT_NOALIGN, "," MNTOPT_NOALIGN },
@@ -461,7 +462,6 @@ xfs_showargs(
461 }; 462 };
462 static struct proc_xfs_info xfs_info_unset[] = { 463 static struct proc_xfs_info xfs_info_unset[] = {
463 /* the few simple ones we can get from the mount struct */ 464 /* the few simple ones we can get from the mount struct */
464 { XFS_MOUNT_IDELETE, "," MNTOPT_IKEEP },
465 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO }, 465 { XFS_MOUNT_COMPAT_IOSIZE, "," MNTOPT_LARGEIO },
466 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER }, 466 { XFS_MOUNT_BARRIER, "," MNTOPT_NOBARRIER },
467 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE }, 467 { XFS_MOUNT_SMALL_INUMS, "," MNTOPT_64BITINODE },
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 48228848f5ae..fab0b6d5a41b 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -25,6 +25,109 @@
25 * XFS bit manipulation routines, used in non-realtime code. 25 * XFS bit manipulation routines, used in non-realtime code.
26 */ 26 */
27 27
28#ifndef HAVE_ARCH_HIGHBIT
29/*
30 * Index of high bit number in byte, -1 for none set, 0..7 otherwise.
31 */
32static const char xfs_highbit[256] = {
33 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */
34 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */
35 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */
36 4, 4, 4, 4, 4, 4, 4, 4, /* 18 .. 1f */
37 5, 5, 5, 5, 5, 5, 5, 5, /* 20 .. 27 */
38 5, 5, 5, 5, 5, 5, 5, 5, /* 28 .. 2f */
39 5, 5, 5, 5, 5, 5, 5, 5, /* 30 .. 37 */
40 5, 5, 5, 5, 5, 5, 5, 5, /* 38 .. 3f */
41 6, 6, 6, 6, 6, 6, 6, 6, /* 40 .. 47 */
42 6, 6, 6, 6, 6, 6, 6, 6, /* 48 .. 4f */
43 6, 6, 6, 6, 6, 6, 6, 6, /* 50 .. 57 */
44 6, 6, 6, 6, 6, 6, 6, 6, /* 58 .. 5f */
45 6, 6, 6, 6, 6, 6, 6, 6, /* 60 .. 67 */
46 6, 6, 6, 6, 6, 6, 6, 6, /* 68 .. 6f */
47 6, 6, 6, 6, 6, 6, 6, 6, /* 70 .. 77 */
48 6, 6, 6, 6, 6, 6, 6, 6, /* 78 .. 7f */
49 7, 7, 7, 7, 7, 7, 7, 7, /* 80 .. 87 */
50 7, 7, 7, 7, 7, 7, 7, 7, /* 88 .. 8f */
51 7, 7, 7, 7, 7, 7, 7, 7, /* 90 .. 97 */
52 7, 7, 7, 7, 7, 7, 7, 7, /* 98 .. 9f */
53 7, 7, 7, 7, 7, 7, 7, 7, /* a0 .. a7 */
54 7, 7, 7, 7, 7, 7, 7, 7, /* a8 .. af */
55 7, 7, 7, 7, 7, 7, 7, 7, /* b0 .. b7 */
56 7, 7, 7, 7, 7, 7, 7, 7, /* b8 .. bf */
57 7, 7, 7, 7, 7, 7, 7, 7, /* c0 .. c7 */
58 7, 7, 7, 7, 7, 7, 7, 7, /* c8 .. cf */
59 7, 7, 7, 7, 7, 7, 7, 7, /* d0 .. d7 */
60 7, 7, 7, 7, 7, 7, 7, 7, /* d8 .. df */
61 7, 7, 7, 7, 7, 7, 7, 7, /* e0 .. e7 */
62 7, 7, 7, 7, 7, 7, 7, 7, /* e8 .. ef */
63 7, 7, 7, 7, 7, 7, 7, 7, /* f0 .. f7 */
64 7, 7, 7, 7, 7, 7, 7, 7, /* f8 .. ff */
65};
66#endif
67
68/*
69 * xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set.
70 */
71inline int
72xfs_highbit32(
73 __uint32_t v)
74{
75#ifdef HAVE_ARCH_HIGHBIT
76 return highbit32(v);
77#else
78 int i;
79
80 if (v & 0xffff0000)
81 if (v & 0xff000000)
82 i = 24;
83 else
84 i = 16;
85 else if (v & 0x0000ffff)
86 if (v & 0x0000ff00)
87 i = 8;
88 else
89 i = 0;
90 else
91 return -1;
92 return i + xfs_highbit[(v >> i) & 0xff];
93#endif
94}
95
96/*
97 * xfs_lowbit64: get low bit set out of 64-bit argument, -1 if none set.
98 */
99int
100xfs_lowbit64(
101 __uint64_t v)
102{
103 __uint32_t w = (__uint32_t)v;
104 int n = 0;
105
106 if (w) { /* lower bits */
107 n = ffs(w);
108 } else { /* upper bits */
109 w = (__uint32_t)(v >> 32);
110 if (w && (n = ffs(w)))
111 n += 32;
112 }
113 return n - 1;
114}
115
116/*
117 * xfs_highbit64: get high bit set out of 64-bit argument, -1 if none set.
118 */
119int
120xfs_highbit64(
121 __uint64_t v)
122{
123 __uint32_t h = (__uint32_t)(v >> 32);
124
125 if (h)
126 return xfs_highbit32(h) + 32;
127 return xfs_highbit32((__uint32_t)v);
128}
129
130
28/* 131/*
29 * Return whether bitmap is empty. 132 * Return whether bitmap is empty.
30 * Size is number of words in the bitmap, which is padded to word boundary 133 * Size is number of words in the bitmap, which is padded to word boundary
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 325a007dec91..082641a9782c 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -47,30 +47,13 @@ static inline __uint64_t xfs_mask64lo(int n)
47} 47}
48 48
49/* Get high bit set out of 32-bit argument, -1 if none set */ 49/* Get high bit set out of 32-bit argument, -1 if none set */
50static inline int xfs_highbit32(__uint32_t v) 50extern int xfs_highbit32(__uint32_t v);
51{
52 return fls(v) - 1;
53}
54
55/* Get high bit set out of 64-bit argument, -1 if none set */
56static inline int xfs_highbit64(__uint64_t v)
57{
58 return fls64(v) - 1;
59}
60
61/* Get low bit set out of 32-bit argument, -1 if none set */
62static inline int xfs_lowbit32(__uint32_t v)
63{
64 __uint32_t t = v;
65 return (t) ? find_first_bit((unsigned long *)&t, 32) : -1;
66}
67 51
68/* Get low bit set out of 64-bit argument, -1 if none set */ 52/* Get low bit set out of 64-bit argument, -1 if none set */
69static inline int xfs_lowbit64(__uint64_t v) 53extern int xfs_lowbit64(__uint64_t v);
70{ 54
71 __uint64_t t = v; 55/* Get high bit set out of 64-bit argument, -1 if none set */
72 return (t) ? find_first_bit((unsigned long *)&t, 64) : -1; 56extern int xfs_highbit64(__uint64_t);
73}
74 57
75/* Return whether bitmap is empty (1 == empty) */ 58/* Return whether bitmap is empty (1 == empty) */
76extern int xfs_bitmap_empty(uint *map, uint size); 59extern int xfs_bitmap_empty(uint *map, uint size);
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h
index d16c1b971074..d5d1e60ee224 100644
--- a/fs/xfs/xfs_clnt.h
+++ b/fs/xfs/xfs_clnt.h
@@ -86,7 +86,7 @@ struct xfs_mount_args {
86#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */ 86#define XFSMNT_NOUUID 0x01000000 /* Ignore fs uuid */
87#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */ 87#define XFSMNT_DMAPI 0x02000000 /* enable dmapi/xdsm */
88#define XFSMNT_BARRIER 0x04000000 /* use write barriers */ 88#define XFSMNT_BARRIER 0x04000000 /* use write barriers */
89#define XFSMNT_IDELETE 0x08000000 /* inode cluster delete */ 89#define XFSMNT_IKEEP 0x08000000 /* inode cluster delete */
90#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width 90#define XFSMNT_SWALLOC 0x10000000 /* turn on stripe width
91 * allocation */ 91 * allocation */
92#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename 92#define XFSMNT_DIRSYNC 0x40000000 /* sync creat,link,unlink,rename
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index c5836b951d0c..db9d5fa600af 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -1053,7 +1053,7 @@ xfs_difree(
1053 /* 1053 /*
1054 * When an inode cluster is free, it becomes eligible for removal 1054 * When an inode cluster is free, it becomes eligible for removal
1055 */ 1055 */
1056 if ((mp->m_flags & XFS_MOUNT_IDELETE) && 1056 if (!(mp->m_flags & XFS_MOUNT_IKEEP) &&
1057 (rec.ir_freecount == XFS_IALLOC_INODES(mp))) { 1057 (rec.ir_freecount == XFS_IALLOC_INODES(mp))) {
1058 1058
1059 *delete = 1; 1059 *delete = 1;
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index f7c620ec6e69..1d8a4728d847 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -366,7 +366,7 @@ typedef struct xfs_mount {
366#define XFS_MOUNT_SMALL_INUMS (1ULL << 15) /* users wants 32bit inodes */ 366#define XFS_MOUNT_SMALL_INUMS (1ULL << 15) /* users wants 32bit inodes */
367#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */ 367#define XFS_MOUNT_NOUUID (1ULL << 16) /* ignore uuid during mount */
368#define XFS_MOUNT_BARRIER (1ULL << 17) 368#define XFS_MOUNT_BARRIER (1ULL << 17)
369#define XFS_MOUNT_IDELETE (1ULL << 18) /* delete empty inode clusters*/ 369#define XFS_MOUNT_IKEEP (1ULL << 18) /* keep empty inode clusters*/
370#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width 370#define XFS_MOUNT_SWALLOC (1ULL << 19) /* turn on stripe width
371 * allocation */ 371 * allocation */
372#define XFS_MOUNT_RDONLY (1ULL << 20) /* read-only fs */ 372#define XFS_MOUNT_RDONLY (1ULL << 20) /* read-only fs */
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index ca83ddf72af4..47082c01872d 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -73,6 +73,18 @@ STATIC int xfs_rtmodify_summary(xfs_mount_t *, xfs_trans_t *, int,
73 */ 73 */
74 74
75/* 75/*
76 * xfs_lowbit32: get low bit set out of 32-bit argument, -1 if none set.
77 */
78STATIC int
79xfs_lowbit32(
80 __uint32_t v)
81{
82 if (v)
83 return ffs(v) - 1;
84 return -1;
85}
86
87/*
76 * Allocate space to the bitmap or summary file, and zero it, for growfs. 88 * Allocate space to the bitmap or summary file, and zero it, for growfs.
77 */ 89 */
78STATIC int /* error */ 90STATIC int /* error */
@@ -432,7 +444,6 @@ xfs_rtallocate_extent_near(
432 } 444 }
433 bbno = XFS_BITTOBLOCK(mp, bno); 445 bbno = XFS_BITTOBLOCK(mp, bno);
434 i = 0; 446 i = 0;
435 ASSERT(minlen != 0);
436 log2len = xfs_highbit32(minlen); 447 log2len = xfs_highbit32(minlen);
437 /* 448 /*
438 * Loop over all bitmap blocks (bbno + i is current block). 449 * Loop over all bitmap blocks (bbno + i is current block).
@@ -601,8 +612,6 @@ xfs_rtallocate_extent_size(
601 xfs_suminfo_t sum; /* summary information for extents */ 612 xfs_suminfo_t sum; /* summary information for extents */
602 613
603 ASSERT(minlen % prod == 0 && maxlen % prod == 0); 614 ASSERT(minlen % prod == 0 && maxlen % prod == 0);
604 ASSERT(maxlen != 0);
605
606 /* 615 /*
607 * Loop over all the levels starting with maxlen. 616 * Loop over all the levels starting with maxlen.
608 * At each level, look at all the bitmap blocks, to see if there 617 * At each level, look at all the bitmap blocks, to see if there
@@ -660,9 +669,6 @@ xfs_rtallocate_extent_size(
660 *rtblock = NULLRTBLOCK; 669 *rtblock = NULLRTBLOCK;
661 return 0; 670 return 0;
662 } 671 }
663 ASSERT(minlen != 0);
664 ASSERT(maxlen != 0);
665
666 /* 672 /*
667 * Loop over sizes, from maxlen down to minlen. 673 * Loop over sizes, from maxlen down to minlen.
668 * This time, when we do the allocations, allow smaller ones 674 * This time, when we do the allocations, allow smaller ones
@@ -1948,7 +1954,6 @@ xfs_growfs_rt(
1948 nsbp->sb_blocksize * nsbp->sb_rextsize); 1954 nsbp->sb_blocksize * nsbp->sb_rextsize);
1949 nsbp->sb_rextents = nsbp->sb_rblocks; 1955 nsbp->sb_rextents = nsbp->sb_rblocks;
1950 do_div(nsbp->sb_rextents, nsbp->sb_rextsize); 1956 do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
1951 ASSERT(nsbp->sb_rextents != 0);
1952 nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents); 1957 nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
1953 nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1; 1958 nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;
1954 nrsumsize = 1959 nrsumsize =
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 413587f02155..7321304a69cc 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -281,8 +281,8 @@ xfs_start_flags(
281 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog; 281 mp->m_readio_log = mp->m_writeio_log = ap->iosizelog;
282 } 282 }
283 283
284 if (ap->flags & XFSMNT_IDELETE) 284 if (ap->flags & XFSMNT_IKEEP)
285 mp->m_flags |= XFS_MOUNT_IDELETE; 285 mp->m_flags |= XFS_MOUNT_IKEEP;
286 if (ap->flags & XFSMNT_DIRSYNC) 286 if (ap->flags & XFSMNT_DIRSYNC)
287 mp->m_flags |= XFS_MOUNT_DIRSYNC; 287 mp->m_flags |= XFS_MOUNT_DIRSYNC;
288 if (ap->flags & XFSMNT_ATTR2) 288 if (ap->flags & XFSMNT_ATTR2)
diff --git a/include/asm-arm/arch-pxa/entry-macro.S b/include/asm-arm/arch-pxa/entry-macro.S
index b7e730851461..c145bb01bc8f 100644
--- a/include/asm-arm/arch-pxa/entry-macro.S
+++ b/include/asm-arm/arch-pxa/entry-macro.S
@@ -35,7 +35,7 @@
351004: 351004:
36 mrc p6, 0, \irqstat, c6, c0, 0 @ ICIP2 36 mrc p6, 0, \irqstat, c6, c0, 0 @ ICIP2
37 mrc p6, 0, \irqnr, c7, c0, 0 @ ICMR2 37 mrc p6, 0, \irqnr, c7, c0, 0 @ ICMR2
38 ands \irqstat, \irqstat, \irqnr 38 ands \irqnr, \irqstat, \irqnr
39 beq 1003f 39 beq 1003f
40 rsb \irqstat, \irqnr, #0 40 rsb \irqstat, \irqnr, #0
41 and \irqstat, \irqstat, \irqnr 41 and \irqstat, \irqstat, \irqnr
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index ac175b4d10cb..2357a73340d4 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -520,6 +520,9 @@
520#define MCCR_FSRIE (1 << 1) /* FIFO Service Request Interrupt Enable */ 520#define MCCR_FSRIE (1 << 1) /* FIFO Service Request Interrupt Enable */
521 521
522#define GCR __REG(0x4050000C) /* Global Control Register */ 522#define GCR __REG(0x4050000C) /* Global Control Register */
523#ifdef CONFIG_PXA3xx
524#define GCR_CLKBPB (1 << 31) /* Internal clock enable */
525#endif
523#define GCR_nDMAEN (1 << 24) /* non DMA Enable */ 526#define GCR_nDMAEN (1 << 24) /* non DMA Enable */
524#define GCR_CDONE_IE (1 << 19) /* Command Done Interrupt Enable */ 527#define GCR_CDONE_IE (1 << 19) /* Command Done Interrupt Enable */
525#define GCR_SDONE_IE (1 << 18) /* Status Done Interrupt Enable */ 528#define GCR_SDONE_IE (1 << 18) /* Status Done Interrupt Enable */
diff --git a/include/asm-arm/kexec.h b/include/asm-arm/kexec.h
index 1ee17b6951d0..47fe34d692da 100644
--- a/include/asm-arm/kexec.h
+++ b/include/asm-arm/kexec.h
@@ -8,7 +8,7 @@
8/* Maximum address we can reach in physical address mode */ 8/* Maximum address we can reach in physical address mode */
9#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL) 9#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
10/* Maximum address we can use for the control code buffer */ 10/* Maximum address we can use for the control code buffer */
11#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE 11#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
12 12
13#define KEXEC_CONTROL_CODE_SIZE 4096 13#define KEXEC_CONTROL_CODE_SIZE 4096
14 14
diff --git a/include/asm-arm/unaligned.h b/include/asm-arm/unaligned.h
index 8431f6eed5c6..5db03cf3b905 100644
--- a/include/asm-arm/unaligned.h
+++ b/include/asm-arm/unaligned.h
@@ -40,16 +40,16 @@ extern int __bug_unaligned_x(const void *ptr);
40 */ 40 */
41 41
42#define __get_unaligned_2_le(__p) \ 42#define __get_unaligned_2_le(__p) \
43 (__p[0] | __p[1] << 8) 43 (unsigned int)(__p[0] | __p[1] << 8)
44 44
45#define __get_unaligned_2_be(__p) \ 45#define __get_unaligned_2_be(__p) \
46 (__p[0] << 8 | __p[1]) 46 (unsigned int)(__p[0] << 8 | __p[1])
47 47
48#define __get_unaligned_4_le(__p) \ 48#define __get_unaligned_4_le(__p) \
49 (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24) 49 (unsigned int)(__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24)
50 50
51#define __get_unaligned_4_be(__p) \ 51#define __get_unaligned_4_be(__p) \
52 (__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3]) 52 (unsigned int)(__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3])
53 53
54#define __get_unaligned_8_le(__p) \ 54#define __get_unaligned_8_le(__p) \
55 ((unsigned long long)__get_unaligned_4_le((__p+4)) << 32 | \ 55 ((unsigned long long)__get_unaligned_4_le((__p+4)) << 32 | \
diff --git a/include/asm-avr32/pgtable.h b/include/asm-avr32/pgtable.h
index 018f6e2a0242..3ae7b548fce7 100644
--- a/include/asm-avr32/pgtable.h
+++ b/include/asm-avr32/pgtable.h
@@ -157,6 +157,7 @@ extern struct page *empty_zero_page;
157#define _PAGE_S(x) _PAGE_NORMAL(x) 157#define _PAGE_S(x) _PAGE_NORMAL(x)
158 158
159#define PAGE_COPY _PAGE_P(PAGE_WRITE | PAGE_READ) 159#define PAGE_COPY _PAGE_P(PAGE_WRITE | PAGE_READ)
160#define PAGE_SHARED _PAGE_S(PAGE_WRITE | PAGE_READ)
160 161
161#ifndef __ASSEMBLY__ 162#ifndef __ASSEMBLY__
162/* 163/*
diff --git a/include/asm-blackfin/gptimers.h b/include/asm-blackfin/gptimers.h
index 8265ea473d5b..4f318f1fd2d9 100644
--- a/include/asm-blackfin/gptimers.h
+++ b/include/asm-blackfin/gptimers.h
@@ -1,12 +1,11 @@
1/* 1/*
2 * include/asm/bf5xx_timers.h 2 * gptimers.h - Blackfin General Purpose Timer structs/defines/prototypes
3 *
4 * This file contains the major Data structures and constants
5 * used for General Purpose Timer Implementation in BF5xx
6 * 3 *
4 * Copyright (c) 2005-2008 Analog Devices Inc.
7 * Copyright (C) 2005 John DeHority 5 * Copyright (C) 2005 John DeHority
8 * Copyright (C) 2006 Hella Aglaia GmbH (awe@aglaia-gmbh.de) 6 * Copyright (C) 2006 Hella Aglaia GmbH (awe@aglaia-gmbh.de)
9 * 7 *
8 * Licensed under the GPL-2.
10 */ 9 */
11 10
12#ifndef _BLACKFIN_TIMERS_H_ 11#ifndef _BLACKFIN_TIMERS_H_
diff --git a/include/asm-blackfin/irq.h b/include/asm-blackfin/irq.h
index 65480dab244e..86b67834354d 100644
--- a/include/asm-blackfin/irq.h
+++ b/include/asm-blackfin/irq.h
@@ -67,4 +67,6 @@ static __inline__ int irq_canonicalize(int irq)
67#define NO_IRQ ((unsigned int)(-1)) 67#define NO_IRQ ((unsigned int)(-1))
68#endif 68#endif
69 69
70#define SIC_SYSIRQ(irq) (irq - (IRQ_CORETMR + 1))
71
70#endif /* _BFIN_IRQ_H_ */ 72#endif /* _BFIN_IRQ_H_ */
diff --git a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
index 15dbc21eed8b..c0694ecd2ecd 100644
--- a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
@@ -23,7 +23,6 @@
23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH)) 23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR)) 24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR))
25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR)) 25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
26#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
27#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL)) 26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
28 27
29#define UART_PUT_CHAR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_THR), v) 28#define UART_PUT_CHAR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_THR), v)
@@ -58,6 +57,7 @@
58struct bfin_serial_port { 57struct bfin_serial_port {
59 struct uart_port port; 58 struct uart_port port;
60 unsigned int old_status; 59 unsigned int old_status;
60 unsigned int lsr;
61#ifdef CONFIG_SERIAL_BFIN_DMA 61#ifdef CONFIG_SERIAL_BFIN_DMA
62 int tx_done; 62 int tx_done;
63 int tx_count; 63 int tx_count;
@@ -67,15 +67,31 @@ struct bfin_serial_port {
67 unsigned int tx_dma_channel; 67 unsigned int tx_dma_channel;
68 unsigned int rx_dma_channel; 68 unsigned int rx_dma_channel;
69 struct work_struct tx_dma_workqueue; 69 struct work_struct tx_dma_workqueue;
70#else
71 struct work_struct cts_workqueue;
72#endif 70#endif
73#ifdef CONFIG_SERIAL_BFIN_CTSRTS 71#ifdef CONFIG_SERIAL_BFIN_CTSRTS
72 struct work_struct cts_workqueue;
74 int cts_pin; 73 int cts_pin;
75 int rts_pin; 74 int rts_pin;
76#endif 75#endif
77}; 76};
78 77
78/* The hardware clears the LSR bits upon read, so we need to cache
79 * some of the more fun bits in software so they don't get lost
80 * when checking the LSR in other code paths (TX).
81 */
82static inline unsigned int UART_GET_LSR(struct bfin_serial_port *uart)
83{
84 unsigned int lsr = bfin_read16(uart->port.membase + OFFSET_LSR);
85 uart->lsr |= (lsr & (BI|FE|PE|OE));
86 return lsr | uart->lsr;
87}
88
89static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
90{
91 uart->lsr = 0;
92 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
93}
94
79struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 95struct bfin_serial_port bfin_serial_ports[NR_PORTS];
80struct bfin_serial_res { 96struct bfin_serial_res {
81 unsigned long uart_base_addr; 97 unsigned long uart_base_addr;
diff --git a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
index 7871d4313f49..b6f513bee56e 100644
--- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
@@ -23,7 +23,6 @@
23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH)) 23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR)) 24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR))
25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR)) 25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
26#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
27#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL)) 26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
28 27
29#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 28#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
@@ -46,6 +45,7 @@
46struct bfin_serial_port { 45struct bfin_serial_port {
47 struct uart_port port; 46 struct uart_port port;
48 unsigned int old_status; 47 unsigned int old_status;
48 unsigned int lsr;
49#ifdef CONFIG_SERIAL_BFIN_DMA 49#ifdef CONFIG_SERIAL_BFIN_DMA
50 int tx_done; 50 int tx_done;
51 int tx_count; 51 int tx_count;
@@ -56,14 +56,34 @@ struct bfin_serial_port {
56 unsigned int rx_dma_channel; 56 unsigned int rx_dma_channel;
57 struct work_struct tx_dma_workqueue; 57 struct work_struct tx_dma_workqueue;
58#else 58#else
59 struct work_struct cts_workqueue; 59# if ANOMALY_05000230
60 unsigned int anomaly_threshold;
61# endif
60#endif 62#endif
61#ifdef CONFIG_SERIAL_BFIN_CTSRTS 63#ifdef CONFIG_SERIAL_BFIN_CTSRTS
64 struct work_struct cts_workqueue;
62 int cts_pin; 65 int cts_pin;
63 int rts_pin; 66 int rts_pin;
64#endif 67#endif
65}; 68};
66 69
70/* The hardware clears the LSR bits upon read, so we need to cache
71 * some of the more fun bits in software so they don't get lost
72 * when checking the LSR in other code paths (TX).
73 */
74static inline unsigned int UART_GET_LSR(struct bfin_serial_port *uart)
75{
76 unsigned int lsr = bfin_read16(uart->port.membase + OFFSET_LSR);
77 uart->lsr |= (lsr & (BI|FE|PE|OE));
78 return lsr | uart->lsr;
79}
80
81static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
82{
83 uart->lsr = 0;
84 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
85}
86
67struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 87struct bfin_serial_port bfin_serial_ports[NR_PORTS];
68struct bfin_serial_res { 88struct bfin_serial_res {
69 unsigned long uart_base_addr; 89 unsigned long uart_base_addr;
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
index 86e45c379838..8fc672d31057 100644
--- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
@@ -23,7 +23,6 @@
23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH)) 23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR)) 24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR))
25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR)) 25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
26#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
27#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL)) 26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
28 27
29#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 28#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
@@ -58,6 +57,7 @@
58struct bfin_serial_port { 57struct bfin_serial_port {
59 struct uart_port port; 58 struct uart_port port;
60 unsigned int old_status; 59 unsigned int old_status;
60 unsigned int lsr;
61#ifdef CONFIG_SERIAL_BFIN_DMA 61#ifdef CONFIG_SERIAL_BFIN_DMA
62 int tx_done; 62 int tx_done;
63 int tx_count; 63 int tx_count;
@@ -67,15 +67,31 @@ struct bfin_serial_port {
67 unsigned int tx_dma_channel; 67 unsigned int tx_dma_channel;
68 unsigned int rx_dma_channel; 68 unsigned int rx_dma_channel;
69 struct work_struct tx_dma_workqueue; 69 struct work_struct tx_dma_workqueue;
70#else
71 struct work_struct cts_workqueue;
72#endif 70#endif
73#ifdef CONFIG_SERIAL_BFIN_CTSRTS 71#ifdef CONFIG_SERIAL_BFIN_CTSRTS
72 struct work_struct cts_workqueue;
74 int cts_pin; 73 int cts_pin;
75 int rts_pin; 74 int rts_pin;
76#endif 75#endif
77}; 76};
78 77
78/* The hardware clears the LSR bits upon read, so we need to cache
79 * some of the more fun bits in software so they don't get lost
80 * when checking the LSR in other code paths (TX).
81 */
82static inline unsigned int UART_GET_LSR(struct bfin_serial_port *uart)
83{
84 unsigned int lsr = bfin_read16(uart->port.membase + OFFSET_LSR);
85 uart->lsr |= (lsr & (BI|FE|PE|OE));
86 return lsr | uart->lsr;
87}
88
89static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
90{
91 uart->lsr = 0;
92 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
93}
94
79struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 95struct bfin_serial_port bfin_serial_ports[NR_PORTS];
80struct bfin_serial_res { 96struct bfin_serial_res {
81 unsigned long uart_base_addr; 97 unsigned long uart_base_addr;
diff --git a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
index 3770aa38ee9f..7e6339f62a50 100644
--- a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
@@ -24,6 +24,8 @@
24#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR)) 24#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
25#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR)) 25#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL)) 26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
27#define UART_GET_MSR(uart) bfin_read16(((uart)->port.membase + OFFSET_MSR))
28#define UART_GET_MCR(uart) bfin_read16(((uart)->port.membase + OFFSET_MCR))
27 29
28#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 30#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
29#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v) 31#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
@@ -32,7 +34,9 @@
32#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v) 34#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
33#define UART_PUT_LSR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LSR),v) 35#define UART_PUT_LSR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LSR),v)
34#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v) 36#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
37#define UART_CLEAR_LSR(uart) bfin_write16(((uart)->port.membase + OFFSET_LSR), -1)
35#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v) 38#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
39#define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
36 40
37#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) 41#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
38# define CONFIG_SERIAL_BFIN_CTSRTS 42# define CONFIG_SERIAL_BFIN_CTSRTS
@@ -68,10 +72,9 @@ struct bfin_serial_port {
68 unsigned int tx_dma_channel; 72 unsigned int tx_dma_channel;
69 unsigned int rx_dma_channel; 73 unsigned int rx_dma_channel;
70 struct work_struct tx_dma_workqueue; 74 struct work_struct tx_dma_workqueue;
71#else
72 struct work_struct cts_workqueue;
73#endif 75#endif
74#ifdef CONFIG_SERIAL_BFIN_CTSRTS 76#ifdef CONFIG_SERIAL_BFIN_CTSRTS
77 struct work_struct cts_workqueue;
75 int cts_pin; 78 int cts_pin;
76 int rts_pin; 79 int rts_pin;
77#endif 80#endif
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
index 7871d4313f49..b6f513bee56e 100644
--- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
@@ -23,7 +23,6 @@
23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH)) 23#define UART_GET_DLH(uart) bfin_read16(((uart)->port.membase + OFFSET_DLH))
24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR)) 24#define UART_GET_IIR(uart) bfin_read16(((uart)->port.membase + OFFSET_IIR))
25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR)) 25#define UART_GET_LCR(uart) bfin_read16(((uart)->port.membase + OFFSET_LCR))
26#define UART_GET_LSR(uart) bfin_read16(((uart)->port.membase + OFFSET_LSR))
27#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL)) 26#define UART_GET_GCTL(uart) bfin_read16(((uart)->port.membase + OFFSET_GCTL))
28 27
29#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 28#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
@@ -46,6 +45,7 @@
46struct bfin_serial_port { 45struct bfin_serial_port {
47 struct uart_port port; 46 struct uart_port port;
48 unsigned int old_status; 47 unsigned int old_status;
48 unsigned int lsr;
49#ifdef CONFIG_SERIAL_BFIN_DMA 49#ifdef CONFIG_SERIAL_BFIN_DMA
50 int tx_done; 50 int tx_done;
51 int tx_count; 51 int tx_count;
@@ -56,14 +56,34 @@ struct bfin_serial_port {
56 unsigned int rx_dma_channel; 56 unsigned int rx_dma_channel;
57 struct work_struct tx_dma_workqueue; 57 struct work_struct tx_dma_workqueue;
58#else 58#else
59 struct work_struct cts_workqueue; 59# if ANOMALY_05000230
60 unsigned int anomaly_threshold;
61# endif
60#endif 62#endif
61#ifdef CONFIG_SERIAL_BFIN_CTSRTS 63#ifdef CONFIG_SERIAL_BFIN_CTSRTS
64 struct work_struct cts_workqueue;
62 int cts_pin; 65 int cts_pin;
63 int rts_pin; 66 int rts_pin;
64#endif 67#endif
65}; 68};
66 69
70/* The hardware clears the LSR bits upon read, so we need to cache
71 * some of the more fun bits in software so they don't get lost
72 * when checking the LSR in other code paths (TX).
73 */
74static inline unsigned int UART_GET_LSR(struct bfin_serial_port *uart)
75{
76 unsigned int lsr = bfin_read16(uart->port.membase + OFFSET_LSR);
77 uart->lsr |= (lsr & (BI|FE|PE|OE));
78 return lsr | uart->lsr;
79}
80
81static inline void UART_CLEAR_LSR(struct bfin_serial_port *uart)
82{
83 uart->lsr = 0;
84 bfin_write16(uart->port.membase + OFFSET_LSR, -1);
85}
86
67struct bfin_serial_port bfin_serial_ports[NR_PORTS]; 87struct bfin_serial_port bfin_serial_ports[NR_PORTS];
68struct bfin_serial_res { 88struct bfin_serial_res {
69 unsigned long uart_base_addr; 89 unsigned long uart_base_addr;
diff --git a/include/asm-blackfin/mach-bf561/blackfin.h b/include/asm-blackfin/mach-bf561/blackfin.h
index 362617f93845..3a16df2c86d8 100644
--- a/include/asm-blackfin/mach-bf561/blackfin.h
+++ b/include/asm-blackfin/mach-bf561/blackfin.h
@@ -49,7 +49,8 @@
49#define bfin_read_FIO_INEN() bfin_read_FIO0_INEN() 49#define bfin_read_FIO_INEN() bfin_read_FIO0_INEN()
50#define bfin_write_FIO_INEN(val) bfin_write_FIO0_INEN(val) 50#define bfin_write_FIO_INEN(val) bfin_write_FIO0_INEN(val)
51 51
52 52#define SIC_IWR0 SICA_IWR0
53#define SIC_IWR1 SICA_IWR1
53#define SIC_IAR0 SICA_IAR0 54#define SIC_IAR0 SICA_IAR0
54#define bfin_write_SIC_IMASK0 bfin_write_SICA_IMASK0 55#define bfin_write_SIC_IMASK0 bfin_write_SICA_IMASK0
55#define bfin_write_SIC_IMASK1 bfin_write_SICA_IMASK1 56#define bfin_write_SIC_IMASK1 bfin_write_SICA_IMASK1
diff --git a/include/asm-blackfin/mach-bf561/cdefBF561.h b/include/asm-blackfin/mach-bf561/cdefBF561.h
index d667816486c0..1bc8d2f89ccc 100644
--- a/include/asm-blackfin/mach-bf561/cdefBF561.h
+++ b/include/asm-blackfin/mach-bf561/cdefBF561.h
@@ -559,6 +559,7 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
559#define bfin_write_PPI0_CONTROL(val) bfin_write16(PPI0_CONTROL,val) 559#define bfin_write_PPI0_CONTROL(val) bfin_write16(PPI0_CONTROL,val)
560#define bfin_read_PPI0_STATUS() bfin_read16(PPI0_STATUS) 560#define bfin_read_PPI0_STATUS() bfin_read16(PPI0_STATUS)
561#define bfin_write_PPI0_STATUS(val) bfin_write16(PPI0_STATUS,val) 561#define bfin_write_PPI0_STATUS(val) bfin_write16(PPI0_STATUS,val)
562#define bfin_clear_PPI0_STATUS() bfin_read_PPI0_STATUS()
562#define bfin_read_PPI0_COUNT() bfin_read16(PPI0_COUNT) 563#define bfin_read_PPI0_COUNT() bfin_read16(PPI0_COUNT)
563#define bfin_write_PPI0_COUNT(val) bfin_write16(PPI0_COUNT,val) 564#define bfin_write_PPI0_COUNT(val) bfin_write16(PPI0_COUNT,val)
564#define bfin_read_PPI0_DELAY() bfin_read16(PPI0_DELAY) 565#define bfin_read_PPI0_DELAY() bfin_read16(PPI0_DELAY)
@@ -570,6 +571,7 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
570#define bfin_write_PPI1_CONTROL(val) bfin_write16(PPI1_CONTROL,val) 571#define bfin_write_PPI1_CONTROL(val) bfin_write16(PPI1_CONTROL,val)
571#define bfin_read_PPI1_STATUS() bfin_read16(PPI1_STATUS) 572#define bfin_read_PPI1_STATUS() bfin_read16(PPI1_STATUS)
572#define bfin_write_PPI1_STATUS(val) bfin_write16(PPI1_STATUS,val) 573#define bfin_write_PPI1_STATUS(val) bfin_write16(PPI1_STATUS,val)
574#define bfin_clear_PPI1_STATUS() bfin_read_PPI1_STATUS()
573#define bfin_read_PPI1_COUNT() bfin_read16(PPI1_COUNT) 575#define bfin_read_PPI1_COUNT() bfin_read16(PPI1_COUNT)
574#define bfin_write_PPI1_COUNT(val) bfin_write16(PPI1_COUNT,val) 576#define bfin_write_PPI1_COUNT(val) bfin_write16(PPI1_COUNT,val)
575#define bfin_read_PPI1_DELAY() bfin_read16(PPI1_DELAY) 577#define bfin_read_PPI1_DELAY() bfin_read16(PPI1_DELAY)
diff --git a/include/asm-mips/mach-db1x00/db1200.h b/include/asm-mips/mach-db1x00/db1200.h
index 050eae87ff01..a6bdac61ab49 100644
--- a/include/asm-mips/mach-db1x00/db1200.h
+++ b/include/asm-mips/mach-db1x00/db1200.h
@@ -25,6 +25,7 @@
25#define __ASM_DB1200_H 25#define __ASM_DB1200_H
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h>
28 29
29// This is defined in au1000.h with bogus value 30// This is defined in au1000.h with bogus value
30#undef AU1X00_EXTERNAL_INT 31#undef AU1X00_EXTERNAL_INT
diff --git a/include/asm-mips/mach-db1x00/db1x00.h b/include/asm-mips/mach-db1x00/db1x00.h
index 0f5f4c29f4e8..e7a88ba35833 100644
--- a/include/asm-mips/mach-db1x00/db1x00.h
+++ b/include/asm-mips/mach-db1x00/db1x00.h
@@ -28,6 +28,7 @@
28#ifndef __ASM_DB1X00_H 28#ifndef __ASM_DB1X00_H
29#define __ASM_DB1X00_H 29#define __ASM_DB1X00_H
30 30
31#include <asm/mach-au1x00/au1xxx_psc.h>
31 32
32#ifdef CONFIG_MIPS_DB1550 33#ifdef CONFIG_MIPS_DB1550
33 34
diff --git a/include/asm-mips/mach-pb1x00/pb1200.h b/include/asm-mips/mach-pb1x00/pb1200.h
index d9f384acfea9..ed5fd7390678 100644
--- a/include/asm-mips/mach-pb1x00/pb1200.h
+++ b/include/asm-mips/mach-pb1x00/pb1200.h
@@ -25,6 +25,7 @@
25#define __ASM_PB1200_H 25#define __ASM_PB1200_H
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h>
28 29
29// This is defined in au1000.h with bogus value 30// This is defined in au1000.h with bogus value
30#undef AU1X00_EXTERNAL_INT 31#undef AU1X00_EXTERNAL_INT
diff --git a/include/asm-mips/mach-pb1x00/pb1550.h b/include/asm-mips/mach-pb1x00/pb1550.h
index 9a4955ce3b4a..c2ab0e2df4ae 100644
--- a/include/asm-mips/mach-pb1x00/pb1550.h
+++ b/include/asm-mips/mach-pb1x00/pb1550.h
@@ -28,6 +28,7 @@
28#define __ASM_PB1550_H 28#define __ASM_PB1550_H
29 29
30#include <linux/types.h> 30#include <linux/types.h>
31#include <asm/mach-au1x00/au1xxx_psc.h>
31 32
32#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX 33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
33#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX 34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 0d6238987df8..edc0cfd7f6e2 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -153,6 +153,9 @@
153#define CTRL_RUNLATCH 0x1 153#define CTRL_RUNLATCH 0x1
154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ 154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
155#define DABR_TRANSLATION (1UL << 2) 155#define DABR_TRANSLATION (1UL << 2)
156#define SPRN_DABRX 0x3F7 /* Data Address Breakpoint Register Extension */
157#define DABRX_USER (1UL << 0)
158#define DABRX_KERNEL (1UL << 1)
156#define SPRN_DAR 0x013 /* Data Address Register */ 159#define SPRN_DAR 0x013 /* Data Address Register */
157#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ 160#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
158#define DSISR_NOHPTE 0x40000000 /* no translation found */ 161#define DSISR_NOHPTE 0x40000000 /* no translation found */
diff --git a/include/asm-sh/cpu-sh3/cache.h b/include/asm-sh/cpu-sh3/cache.h
index 56bd838b7db4..bee2d81c56bf 100644
--- a/include/asm-sh/cpu-sh3/cache.h
+++ b/include/asm-sh/cpu-sh3/cache.h
@@ -35,7 +35,7 @@
35 defined(CONFIG_CPU_SUBTYPE_SH7710) || \ 35 defined(CONFIG_CPU_SUBTYPE_SH7710) || \
36 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 36 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
37 defined(CONFIG_CPU_SUBTYPE_SH7721) 37 defined(CONFIG_CPU_SUBTYPE_SH7721)
38#define CCR3 0xa40000b4 38#define CCR3_REG 0xa40000b4
39#define CCR_CACHE_16KB 0x00010000 39#define CCR_CACHE_16KB 0x00010000
40#define CCR_CACHE_32KB 0x00020000 40#define CCR_CACHE_32KB 0x00020000
41#endif 41#endif
diff --git a/include/asm-sh/entry-macros.S b/include/asm-sh/entry-macros.S
index 500030eae7aa..2dab0b8d9454 100644
--- a/include/asm-sh/entry-macros.S
+++ b/include/asm-sh/entry-macros.S
@@ -12,7 +12,7 @@
12 not r11, r11 12 not r11, r11
13 stc sr, r10 13 stc sr, r10
14 and r11, r10 14 and r11, r10
15#ifdef CONFIG_HAS_SR_RB 15#ifdef CONFIG_CPU_HAS_SR_RB
16 stc k_g_imask, r11 16 stc k_g_imask, r11
17 or r11, r10 17 or r11, r10
18#endif 18#endif
@@ -20,7 +20,7 @@
20 .endm 20 .endm
21 21
22 .macro get_current_thread_info, ti, tmp 22 .macro get_current_thread_info, ti, tmp
23#ifdef CONFIG_HAS_SR_RB 23#ifdef CONFIG_CPU_HAS_SR_RB
24 stc r7_bank, \ti 24 stc r7_bank, \ti
25#else 25#else
26 mov #((THREAD_SIZE - 1) >> 10) ^ 0xff, \tmp 26 mov #((THREAD_SIZE - 1) >> 10) ^ 0xff, \tmp
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
index 67341cff2e6b..6da197803efc 100644
--- a/include/asm-sparc64/ptrace.h
+++ b/include/asm-sparc64/ptrace.h
@@ -109,6 +109,7 @@ extern unsigned long profile_pc(struct pt_regs *);
109#define profile_pc(regs) instruction_pointer(regs) 109#define profile_pc(regs) instruction_pointer(regs)
110#endif 110#endif
111extern void show_regs(struct pt_regs *); 111extern void show_regs(struct pt_regs *);
112extern void __show_regs(struct pt_regs *);
112#endif 113#endif
113 114
114#else /* __ASSEMBLY__ */ 115#else /* __ASSEMBLY__ */
diff --git a/include/asm-sparc64/reboot.h b/include/asm-sparc64/reboot.h
new file mode 100644
index 000000000000..3f3f43f5be5e
--- /dev/null
+++ b/include/asm-sparc64/reboot.h
@@ -0,0 +1,6 @@
1#ifndef _SPARC64_REBOOT_H
2#define _SPARC64_REBOOT_H
3
4extern void machine_alt_power_off(void);
5
6#endif /* _SPARC64_REBOOT_H */
diff --git a/include/asm-sparc64/syscalls.h b/include/asm-sparc64/syscalls.h
new file mode 100644
index 000000000000..45a43f637a14
--- /dev/null
+++ b/include/asm-sparc64/syscalls.h
@@ -0,0 +1,13 @@
1#ifndef _SPARC64_SYSCALLS_H
2#define _SPARC64_SYSCALLS_H
3
4struct pt_regs;
5
6extern asmlinkage long sparc_do_fork(unsigned long clone_flags,
7 unsigned long stack_start,
8 struct pt_regs *regs,
9 unsigned long stack_size);
10
11extern asmlinkage int sparc_execve(struct pt_regs *regs);
12
13#endif /* _SPARC64_SYSCALLS_H */
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index 1faefa6d3708..ed91a5d8d4f0 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -117,6 +117,7 @@ do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
117extern void sun_do_break(void); 117extern void sun_do_break(void);
118extern int stop_a_enabled; 118extern int stop_a_enabled;
119 119
120extern void fault_in_user_windows(void);
120extern void synchronize_user_stack(void); 121extern void synchronize_user_stack(void);
121 122
122extern void __flushw_user(void); 123extern void __flushw_user(void);
diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h
index cd9f894dd2d7..c9952ea9f698 100644
--- a/include/asm-x86/futex.h
+++ b/include/asm-x86/futex.h
@@ -102,6 +102,13 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
102static inline int 102static inline int
103futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 103futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
104{ 104{
105
106#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP)
107 /* Real i386 machines have no cmpxchg instruction */
108 if (boot_cpu_data.x86 == 3)
109 return -ENOSYS;
110#endif
111
105 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 112 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
106 return -EFAULT; 113 return -EFAULT;
107 114
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
index 4d9367b72976..9b17571e9bc3 100644
--- a/include/asm-x86/lguest.h
+++ b/include/asm-x86/lguest.h
@@ -23,6 +23,17 @@
23/* Found in switcher.S */ 23/* Found in switcher.S */
24extern unsigned long default_idt_entries[]; 24extern unsigned long default_idt_entries[];
25 25
26/* Declarations for definitions in lguest_guest.S */
27extern char lguest_noirq_start[], lguest_noirq_end[];
28extern const char lgstart_cli[], lgend_cli[];
29extern const char lgstart_sti[], lgend_sti[];
30extern const char lgstart_popf[], lgend_popf[];
31extern const char lgstart_pushf[], lgend_pushf[];
32extern const char lgstart_iret[], lgend_iret[];
33
34extern void lguest_iret(void);
35extern void lguest_init(void);
36
26struct lguest_regs 37struct lguest_regs
27{ 38{
28 /* Manually saved part. */ 39 /* Manually saved part. */
diff --git a/include/asm-x86/nops.h b/include/asm-x86/nops.h
index fec025c7f58c..e3b2bce0aff8 100644
--- a/include/asm-x86/nops.h
+++ b/include/asm-x86/nops.h
@@ -3,17 +3,29 @@
3 3
4/* Define nops for use with alternative() */ 4/* Define nops for use with alternative() */
5 5
6/* generic versions from gas */ 6/* generic versions from gas
7#define GENERIC_NOP1 ".byte 0x90\n" 7 1: nop
8#define GENERIC_NOP2 ".byte 0x89,0xf6\n" 8 2: movl %esi,%esi
9#define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n" 9 3: leal 0x00(%esi),%esi
10#define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n" 10 4: leal 0x00(,%esi,1),%esi
11#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4 11 6: leal 0x00000000(%esi),%esi
12#define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n" 12 7: leal 0x00000000(,%esi,1),%esi
13#define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n" 13*/
14#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7 14#define GENERIC_NOP1 ".byte 0x90\n"
15#define GENERIC_NOP2 ".byte 0x89,0xf6\n"
16#define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n"
17#define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n"
18#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4
19#define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
20#define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
21#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
15 22
16/* Opteron 64bit nops */ 23/* Opteron 64bit nops
24 1: nop
25 2: osp nop
26 3: osp osp nop
27 4: osp osp osp nop
28*/
17#define K8_NOP1 GENERIC_NOP1 29#define K8_NOP1 GENERIC_NOP1
18#define K8_NOP2 ".byte 0x66,0x90\n" 30#define K8_NOP2 ".byte 0x66,0x90\n"
19#define K8_NOP3 ".byte 0x66,0x66,0x90\n" 31#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
@@ -23,19 +35,35 @@
23#define K8_NOP7 K8_NOP4 K8_NOP3 35#define K8_NOP7 K8_NOP4 K8_NOP3
24#define K8_NOP8 K8_NOP4 K8_NOP4 36#define K8_NOP8 K8_NOP4 K8_NOP4
25 37
26/* K7 nops */ 38/* K7 nops
27/* uses eax dependencies (arbitary choice) */ 39 uses eax dependencies (arbitary choice)
28#define K7_NOP1 GENERIC_NOP1 40 1: nop
41 2: movl %eax,%eax
42 3: leal (,%eax,1),%eax
43 4: leal 0x00(,%eax,1),%eax
44 6: leal 0x00000000(%eax),%eax
45 7: leal 0x00000000(,%eax,1),%eax
46*/
47#define K7_NOP1 GENERIC_NOP1
29#define K7_NOP2 ".byte 0x8b,0xc0\n" 48#define K7_NOP2 ".byte 0x8b,0xc0\n"
30#define K7_NOP3 ".byte 0x8d,0x04,0x20\n" 49#define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
31#define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n" 50#define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
32#define K7_NOP5 K7_NOP4 ASM_NOP1 51#define K7_NOP5 K7_NOP4 ASM_NOP1
33#define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n" 52#define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
34#define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n" 53#define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n"
35#define K7_NOP8 K7_NOP7 ASM_NOP1 54#define K7_NOP8 K7_NOP7 ASM_NOP1
36 55
37/* P6 nops */ 56/* P6 nops
38/* uses eax dependencies (Intel-recommended choice) */ 57 uses eax dependencies (Intel-recommended choice)
58 1: nop
59 2: osp nop
60 3: nopl (%eax)
61 4: nopl 0x00(%eax)
62 5: nopl 0x00(%eax,%eax,1)
63 6: osp nopl 0x00(%eax,%eax,1)
64 7: nopl 0x00000000(%eax)
65 8: nopl 0x00000000(%eax,%eax,1)
66*/
39#define P6_NOP1 GENERIC_NOP1 67#define P6_NOP1 GENERIC_NOP1
40#define P6_NOP2 ".byte 0x66,0x90\n" 68#define P6_NOP2 ".byte 0x66,0x90\n"
41#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n" 69#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
@@ -63,9 +91,7 @@
63#define ASM_NOP6 K7_NOP6 91#define ASM_NOP6 K7_NOP6
64#define ASM_NOP7 K7_NOP7 92#define ASM_NOP7 K7_NOP7
65#define ASM_NOP8 K7_NOP8 93#define ASM_NOP8 K7_NOP8
66#elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \ 94#elif defined(CONFIG_X86_P6_NOP)
67 defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
68 defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
69#define ASM_NOP1 P6_NOP1 95#define ASM_NOP1 P6_NOP1
70#define ASM_NOP2 P6_NOP2 96#define ASM_NOP2 P6_NOP2
71#define ASM_NOP3 P6_NOP3 97#define ASM_NOP3 P6_NOP3
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index f7393bc516ef..143546073b95 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -47,8 +47,12 @@
47#define __PHYSICAL_MASK_SHIFT 46 47#define __PHYSICAL_MASK_SHIFT 46
48#define __VIRTUAL_MASK_SHIFT 48 48#define __VIRTUAL_MASK_SHIFT 48
49 49
50#define KERNEL_TEXT_SIZE (40*1024*1024) 50/*
51#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL) 51 * Kernel image size is limited to 128 MB (see level2_kernel_pgt in
52 * arch/x86/kernel/head_64.S), and it is mapped here:
53 */
54#define KERNEL_IMAGE_SIZE (128*1024*1024)
55#define KERNEL_IMAGE_START _AC(0xffffffff80000000, UL)
52 56
53#ifndef __ASSEMBLY__ 57#ifndef __ASSEMBLY__
54void clear_page(void *page); 58void clear_page(void *page);
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index a842c7222b1e..b478efa971e0 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -91,7 +91,9 @@ extern unsigned long pg0[];
91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ 91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
92#define pmd_none(x) (!(unsigned long)pmd_val(x)) 92#define pmd_none(x) (!(unsigned long)pmd_val(x))
93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
94#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 94#define pmd_bad(x) ((pmd_val(x) \
95 & ~(PAGE_MASK | _PAGE_USER | _PAGE_PSE | _PAGE_NX)) \
96 != _KERNPG_TABLE)
95 97
96 98
97#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 99#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 0a0b77bc736a..0a9258333cbd 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -153,12 +153,14 @@ static inline unsigned long pgd_bad(pgd_t pgd)
153 153
154static inline unsigned long pud_bad(pud_t pud) 154static inline unsigned long pud_bad(pud_t pud)
155{ 155{
156 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); 156 return pud_val(pud) &
157 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
157} 158}
158 159
159static inline unsigned long pmd_bad(pmd_t pmd) 160static inline unsigned long pmd_bad(pmd_t pmd)
160{ 161{
161 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER); 162 return pmd_val(pmd) &
163 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
162} 164}
163 165
164#define pte_none(x) (!pte_val(x)) 166#define pte_none(x) (!pte_val(x))
diff --git a/include/asm-x86/ptrace-abi.h b/include/asm-x86/ptrace-abi.h
index 81a8ee4c55fc..f224eb3c3157 100644
--- a/include/asm-x86/ptrace-abi.h
+++ b/include/asm-x86/ptrace-abi.h
@@ -89,13 +89,13 @@
89*/ 89*/
90struct ptrace_bts_config { 90struct ptrace_bts_config {
91 /* requested or actual size of BTS buffer in bytes */ 91 /* requested or actual size of BTS buffer in bytes */
92 u32 size; 92 __u32 size;
93 /* bitmask of below flags */ 93 /* bitmask of below flags */
94 u32 flags; 94 __u32 flags;
95 /* buffer overflow signal */ 95 /* buffer overflow signal */
96 u32 signal; 96 __u32 signal;
97 /* actual size of bts_struct in bytes */ 97 /* actual size of bts_struct in bytes */
98 u32 bts_size; 98 __u32 bts_size;
99}; 99};
100#endif 100#endif
101 101
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 78bbacaed8c4..1c622e2b0504 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -659,6 +659,11 @@ static inline int atapi_command_packet_set(const u16 *dev_id)
659 return (dev_id[0] >> 8) & 0x1f; 659 return (dev_id[0] >> 8) & 0x1f;
660} 660}
661 661
662static inline int atapi_id_dmadir(const u16 *dev_id)
663{
664 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000);
665}
666
662static inline int is_multi_taskfile(struct ata_taskfile *tf) 667static inline int is_multi_taskfile(struct ata_taskfile *tf)
663{ 668{
664 return (tf->command == ATA_CMD_READ_MULTI) || 669 return (tf->command == ATA_CMD_READ_MULTI) ||
diff --git a/include/linux/connector.h b/include/linux/connector.h
index da6dd957f908..96a89d3d6727 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -170,7 +170,5 @@ int cn_cb_equal(struct cb_id *, struct cb_id *);
170 170
171void cn_queue_wrapper(struct work_struct *work); 171void cn_queue_wrapper(struct work_struct *work);
172 172
173extern int cn_already_initialized;
174
175#endif /* __KERNEL__ */ 173#endif /* __KERNEL__ */
176#endif /* __CONNECTOR_H */ 174#endif /* __CONNECTOR_H */
diff --git a/include/linux/elfcore-compat.h b/include/linux/elfcore-compat.h
index 532d13adabc4..0a90e1c3a422 100644
--- a/include/linux/elfcore-compat.h
+++ b/include/linux/elfcore-compat.h
@@ -45,8 +45,8 @@ struct compat_elf_prpsinfo
45 char pr_zomb; 45 char pr_zomb;
46 char pr_nice; 46 char pr_nice;
47 compat_ulong_t pr_flag; 47 compat_ulong_t pr_flag;
48 compat_uid_t pr_uid; 48 __compat_uid_t pr_uid;
49 compat_gid_t pr_gid; 49 __compat_gid_t pr_gid;
50 compat_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; 50 compat_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
51 char pr_fname[16]; 51 char pr_fname[16];
52 char pr_psargs[ELF_PRARGSZ]; 52 char pr_psargs[ELF_PRARGSZ];
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
index 697da4bce6c5..1285c583b2d8 100644
--- a/include/linux/ext4_fs_extents.h
+++ b/include/linux/ext4_fs_extents.h
@@ -227,5 +227,6 @@ extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
227 ext4_lblk_t *, ext4_fsblk_t *); 227 ext4_lblk_t *, ext4_fsblk_t *);
228extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *, 228extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
229 ext4_lblk_t *, ext4_fsblk_t *); 229 ext4_lblk_t *, ext4_fsblk_t *);
230extern void ext4_ext_drop_refs(struct ext4_ext_path *);
230#endif /* _LINUX_EXT4_EXTENTS */ 231#endif /* _LINUX_EXT4_EXTENTS */
231 232
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 2961ec788046..49829988bfa0 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -109,6 +109,14 @@ static inline void account_system_vtime(struct task_struct *tsk)
109} 109}
110#endif 110#endif
111 111
112#if defined(CONFIG_PREEMPT_RCU) && defined(CONFIG_NO_HZ)
113extern void rcu_irq_enter(void);
114extern void rcu_irq_exit(void);
115#else
116# define rcu_irq_enter() do { } while (0)
117# define rcu_irq_exit() do { } while (0)
118#endif /* CONFIG_PREEMPT_RCU */
119
112/* 120/*
113 * It is safe to do non-atomic ops on ->hardirq_context, 121 * It is safe to do non-atomic ops on ->hardirq_context,
114 * because NMI handlers may not preempt and the ops are 122 * because NMI handlers may not preempt and the ops are
@@ -117,6 +125,7 @@ static inline void account_system_vtime(struct task_struct *tsk)
117 */ 125 */
118#define __irq_enter() \ 126#define __irq_enter() \
119 do { \ 127 do { \
128 rcu_irq_enter(); \
120 account_system_vtime(current); \ 129 account_system_vtime(current); \
121 add_preempt_count(HARDIRQ_OFFSET); \ 130 add_preempt_count(HARDIRQ_OFFSET); \
122 trace_hardirq_enter(); \ 131 trace_hardirq_enter(); \
@@ -135,6 +144,7 @@ extern void irq_enter(void);
135 trace_hardirq_exit(); \ 144 trace_hardirq_exit(); \
136 account_system_vtime(current); \ 145 account_system_vtime(current); \
137 sub_preempt_count(HARDIRQ_OFFSET); \ 146 sub_preempt_count(HARDIRQ_OFFSET); \
147 rcu_irq_exit(); \
138 } while (0) 148 } while (0)
139 149
140/* 150/*
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 76014f8f3c60..365e0df3646b 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -271,9 +271,16 @@ extern void i2c_unregister_device(struct i2c_client *);
271 * This is done at arch_initcall time, before declaring any i2c adapters. 271 * This is done at arch_initcall time, before declaring any i2c adapters.
272 * Modules for add-on boards must use other calls. 272 * Modules for add-on boards must use other calls.
273 */ 273 */
274#ifdef CONFIG_I2C_BOARDINFO
274extern int 275extern int
275i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n); 276i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
276 277#else
278static inline int
279i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n)
280{
281 return 0;
282}
283#endif
277 284
278/* 285/*
279 * The following structs are for those who like to implement new bus drivers: 286 * The following structs are for those who like to implement new bus drivers:
@@ -598,7 +605,7 @@ I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
598 "additionally"); \ 605 "additionally"); \
599I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ 606I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
600 "scan"); \ 607 "scan"); \
601const static struct i2c_client_address_data addr_data = { \ 608static const struct i2c_client_address_data addr_data = { \
602 .normal_i2c = normal_i2c, \ 609 .normal_i2c = normal_i2c, \
603 .probe = probe, \ 610 .probe = probe, \
604 .ignore = ignore, \ 611 .ignore = ignore, \
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 42dc6a3571ec..e157c1399b61 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -129,7 +129,8 @@ extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
129/* 129/*
130 * Display a 6 byte device address (MAC) in a readable format. 130 * Display a 6 byte device address (MAC) in a readable format.
131 */ 131 */
132extern __pure char *print_mac(char *buf, const unsigned char *addr); 132extern char *print_mac(char *buf, const unsigned char *addr);
133#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
133#define MAC_BUF_SIZE 18 134#define MAC_BUF_SIZE 18
134#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused 135#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused
135 136
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ce7603a73156..a05f60013642 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -138,6 +138,7 @@ enum {
138 ATA_DFLAG_AN = (1 << 7), /* AN configured */ 138 ATA_DFLAG_AN = (1 << 7), /* AN configured */
139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */ 139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */
140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */ 140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */
141 ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */
141 ATA_DFLAG_CFG_MASK = (1 << 12) - 1, 142 ATA_DFLAG_CFG_MASK = (1 << 12) - 1,
142 143
143 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ 144 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */
diff --git a/include/linux/maple.h b/include/linux/maple.h
index 3f01e2bae1a1..d31e36ebb436 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -64,7 +64,6 @@ struct maple_driver {
64 int (*connect) (struct maple_device * dev); 64 int (*connect) (struct maple_device * dev);
65 void (*disconnect) (struct maple_device * dev); 65 void (*disconnect) (struct maple_device * dev);
66 struct device_driver drv; 66 struct device_driver drv;
67 int registered;
68}; 67};
69 68
70void maple_getcond_callback(struct maple_device *dev, 69void maple_getcond_callback(struct maple_device *dev,
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index d74e79bacd2d..f0680c2bee73 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -31,7 +31,7 @@
31#define NF_VERDICT_QMASK 0xffff0000 31#define NF_VERDICT_QMASK 0xffff0000
32#define NF_VERDICT_QBITS 16 32#define NF_VERDICT_QBITS 16
33 33
34#define NF_QUEUE_NR(x) (((x << NF_VERDICT_QBITS) & NF_VERDICT_QMASK) | NF_QUEUE) 34#define NF_QUEUE_NR(x) ((((x) << NF_VERDICT_BITS) & NF_VERDICT_QMASK) | NF_QUEUE)
35 35
36/* only for userspace compatibility */ 36/* only for userspace compatibility */
37#ifndef __KERNEL__ 37#ifndef __KERNEL__
@@ -51,7 +51,7 @@ enum nf_inet_hooks {
51}; 51};
52 52
53union nf_inet_addr { 53union nf_inet_addr {
54 u_int32_t all[4]; 54 __u32 all[4];
55 __be32 ip; 55 __be32 ip;
56 __be32 ip6[4]; 56 __be32 ip6[4];
57 struct in_addr in; 57 struct in_addr in;
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
index 91fef0cae42f..3aff513d12c8 100644
--- a/include/linux/netfilter/Kbuild
+++ b/include/linux/netfilter/Kbuild
@@ -30,7 +30,6 @@ header-y += xt_mark.h
30header-y += xt_multiport.h 30header-y += xt_multiport.h
31header-y += xt_owner.h 31header-y += xt_owner.h
32header-y += xt_pkttype.h 32header-y += xt_pkttype.h
33header-y += xt_policy.h
34header-y += xt_rateest.h 33header-y += xt_rateest.h
35header-y += xt_realm.h 34header-y += xt_realm.h
36header-y += xt_sctp.h 35header-y += xt_sctp.h
@@ -47,3 +46,4 @@ unifdef-y += nfnetlink.h
47unifdef-y += nfnetlink_compat.h 46unifdef-y += nfnetlink_compat.h
48unifdef-y += x_tables.h 47unifdef-y += x_tables.h
49unifdef-y += xt_physdev.h 48unifdef-y += xt_physdev.h
49unifdef-y += xt_policy.h
diff --git a/include/linux/netfilter/xt_hashlimit.h b/include/linux/netfilter/xt_hashlimit.h
index 58b818ee41ca..51b18d83b477 100644
--- a/include/linux/netfilter/xt_hashlimit.h
+++ b/include/linux/netfilter/xt_hashlimit.h
@@ -61,7 +61,6 @@ struct xt_hashlimit_mtinfo1 {
61 61
62 /* Used internally by the kernel */ 62 /* Used internally by the kernel */
63 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8))); 63 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
64 struct xt_hashlimit_mtinfo1 *master __attribute__((aligned(8)));
65}; 64};
66 65
67#endif /*_XT_HASHLIMIT_H*/ 66#endif /*_XT_HASHLIMIT_H*/
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index 4d6624260b4c..b3dccd68629e 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -160,5 +160,8 @@ extern void rcu_restart_cpu(int cpu);
160extern long rcu_batches_completed(void); 160extern long rcu_batches_completed(void);
161extern long rcu_batches_completed_bh(void); 161extern long rcu_batches_completed_bh(void);
162 162
163#define rcu_enter_nohz() do { } while (0)
164#define rcu_exit_nohz() do { } while (0)
165
163#endif /* __KERNEL__ */ 166#endif /* __KERNEL__ */
164#endif /* __LINUX_RCUCLASSIC_H */ 167#endif /* __LINUX_RCUCLASSIC_H */
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
index 60c2a033b19e..01152ed532c8 100644
--- a/include/linux/rcupreempt.h
+++ b/include/linux/rcupreempt.h
@@ -82,5 +82,27 @@ extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu);
82 82
83struct softirq_action; 83struct softirq_action;
84 84
85#ifdef CONFIG_NO_HZ
86DECLARE_PER_CPU(long, dynticks_progress_counter);
87
88static inline void rcu_enter_nohz(void)
89{
90 __get_cpu_var(dynticks_progress_counter)++;
91 WARN_ON(__get_cpu_var(dynticks_progress_counter) & 0x1);
92 mb();
93}
94
95static inline void rcu_exit_nohz(void)
96{
97 mb();
98 __get_cpu_var(dynticks_progress_counter)++;
99 WARN_ON(!(__get_cpu_var(dynticks_progress_counter) & 0x1));
100}
101
102#else /* CONFIG_NO_HZ */
103#define rcu_enter_nohz() do { } while (0)
104#define rcu_exit_nohz() do { } while (0)
105#endif /* CONFIG_NO_HZ */
106
85#endif /* __KERNEL__ */ 107#endif /* __KERNEL__ */
86#endif /* __LINUX_RCUPREEMPT_H */ 108#endif /* __LINUX_RCUPREEMPT_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e217d188a102..2c9621f8bf87 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -242,6 +242,7 @@ struct task_struct;
242 242
243extern void sched_init(void); 243extern void sched_init(void);
244extern void sched_init_smp(void); 244extern void sched_init_smp(void);
245extern asmlinkage void schedule_tail(struct task_struct *prev);
245extern void init_idle(struct task_struct *idle, int cpu); 246extern void init_idle(struct task_struct *idle, int cpu);
246extern void init_idle_bootup_task(struct task_struct *idle); 247extern void init_idle_bootup_task(struct task_struct *idle);
247 248
@@ -1189,7 +1190,7 @@ struct task_struct {
1189 int softirq_context; 1190 int softirq_context;
1190#endif 1191#endif
1191#ifdef CONFIG_LOCKDEP 1192#ifdef CONFIG_LOCKDEP
1192# define MAX_LOCK_DEPTH 30UL 1193# define MAX_LOCK_DEPTH 48UL
1193 u64 curr_chain_key; 1194 u64 curr_chain_key;
1194 int lockdep_depth; 1195 int lockdep_depth;
1195 struct held_lock held_locks[MAX_LOCK_DEPTH]; 1196 struct held_lock held_locks[MAX_LOCK_DEPTH];
diff --git a/include/asm-sh/sci.h b/include/linux/serial_sci.h
index 52e73660c129..893cc53486bc 100644
--- a/include/asm-sh/sci.h
+++ b/include/linux/serial_sci.h
@@ -1,12 +1,10 @@
1#ifndef __ASM_SH_SCI_H 1#ifndef __LINUX_SERIAL_SCI_H
2#define __ASM_SH_SCI_H 2#define __LINUX_SERIAL_SCI_H
3 3
4#include <linux/serial_core.h> 4#include <linux/serial_core.h>
5 5
6/* 6/*
7 * Generic header for SuperH SCI(F) 7 * Generic header for SuperH SCI(F) (used by sh/sh64/h8300 and related parts)
8 *
9 * Do not place SH-specific parts in here, sh64 and h8300 depend on this too.
10 */ 8 */
11 9
12/* Offsets into the sci_port->irqs array */ 10/* Offsets into the sci_port->irqs array */
@@ -31,4 +29,4 @@ struct plat_sci_port {
31 29
32int early_sci_setup(struct uart_port *port); 30int early_sci_setup(struct uart_port *port);
33 31
34#endif /* __ASM_SH_SCI_H */ 32#endif /* __LINUX_SERIAL_SCI_H */
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 9d5da8b2ccf9..20add65215af 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -282,6 +282,13 @@ struct ssb_bus {
282 struct ssb_boardinfo boardinfo; 282 struct ssb_boardinfo boardinfo;
283 /* Contents of the SPROM. */ 283 /* Contents of the SPROM. */
284 struct ssb_sprom sprom; 284 struct ssb_sprom sprom;
285 /* If the board has a cardbus slot, this is set to true. */
286 bool has_cardbus_slot;
287
288#ifdef CONFIG_SSB_EMBEDDED
289 /* Lock for GPIO register access. */
290 spinlock_t gpio_lock;
291#endif /* EMBEDDED */
285 292
286 /* Internal-only stuff follows. Do not touch. */ 293 /* Internal-only stuff follows. Do not touch. */
287 struct list_head list; 294 struct list_head list;
@@ -294,8 +301,13 @@ struct ssb_bus {
294 301
295/* The initialization-invariants. */ 302/* The initialization-invariants. */
296struct ssb_init_invariants { 303struct ssb_init_invariants {
304 /* Versioning information about the PCB. */
297 struct ssb_boardinfo boardinfo; 305 struct ssb_boardinfo boardinfo;
306 /* The SPROM information. That's either stored in an
307 * EEPROM or NVRAM on the board. */
298 struct ssb_sprom sprom; 308 struct ssb_sprom sprom;
309 /* If the board has a cardbus slot, this is set to true. */
310 bool has_cardbus_slot;
299}; 311};
300/* Type of function to fetch the invariants. */ 312/* Type of function to fetch the invariants. */
301typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus, 313typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
diff --git a/include/linux/ssb/ssb_driver_chipcommon.h b/include/linux/ssb/ssb_driver_chipcommon.h
index 4cb995494662..536851b946f6 100644
--- a/include/linux/ssb/ssb_driver_chipcommon.h
+++ b/include/linux/ssb/ssb_driver_chipcommon.h
@@ -51,9 +51,12 @@
51#define SSB_CHIPCO_CAP_JTAGM 0x00400000 /* JTAG master present */ 51#define SSB_CHIPCO_CAP_JTAGM 0x00400000 /* JTAG master present */
52#define SSB_CHIPCO_CAP_BROM 0x00800000 /* Internal boot ROM active */ 52#define SSB_CHIPCO_CAP_BROM 0x00800000 /* Internal boot ROM active */
53#define SSB_CHIPCO_CAP_64BIT 0x08000000 /* 64-bit Backplane */ 53#define SSB_CHIPCO_CAP_64BIT 0x08000000 /* 64-bit Backplane */
54#define SSB_CHIPCO_CAP_PMU 0x10000000 /* PMU available (rev >= 20) */
55#define SSB_CHIPCO_CAP_ECI 0x20000000 /* ECI available (rev >= 20) */
54#define SSB_CHIPCO_CORECTL 0x0008 56#define SSB_CHIPCO_CORECTL 0x0008
55#define SSB_CHIPCO_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */ 57#define SSB_CHIPCO_CORECTL_UARTCLK0 0x00000001 /* Drive UART with internal clock */
56#define SSB_CHIPCO_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */ 58#define SSB_CHIPCO_CORECTL_SE 0x00000002 /* sync clk out enable (corerev >= 3) */
59#define SSB_CHIPCO_CORECTL_UARTCLKEN 0x00000008 /* UART clock enable (rev >= 21) */
57#define SSB_CHIPCO_BIST 0x000C 60#define SSB_CHIPCO_BIST 0x000C
58#define SSB_CHIPCO_OTPS 0x0010 /* OTP status */ 61#define SSB_CHIPCO_OTPS 0x0010 /* OTP status */
59#define SSB_CHIPCO_OTPS_PROGFAIL 0x80000000 62#define SSB_CHIPCO_OTPS_PROGFAIL 0x80000000
@@ -357,6 +360,11 @@ struct ssb_chipcommon {
357 u16 fast_pwrup_delay; 360 u16 fast_pwrup_delay;
358}; 361};
359 362
363static inline bool ssb_chipco_available(struct ssb_chipcommon *cc)
364{
365 return (cc->dev != NULL);
366}
367
360extern void ssb_chipcommon_init(struct ssb_chipcommon *cc); 368extern void ssb_chipcommon_init(struct ssb_chipcommon *cc);
361 369
362#include <linux/pm.h> 370#include <linux/pm.h>
@@ -382,11 +390,13 @@ extern void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc,
382extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, 390extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc,
383 u32 ticks); 391 u32 ticks);
384 392
393/* Chipcommon GPIO pin access. */
385u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask); 394u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask);
386 395u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value);
387void ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value); 396u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value);
388 397u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value);
389void ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value); 398u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value);
399u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value);
390 400
391#ifdef CONFIG_SSB_SERIAL 401#ifdef CONFIG_SSB_SERIAL
392extern int ssb_chipco_serial_init(struct ssb_chipcommon *cc, 402extern int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
diff --git a/include/linux/ssb/ssb_driver_extif.h b/include/linux/ssb/ssb_driver_extif.h
index a9164357b5ae..91161f0aa22b 100644
--- a/include/linux/ssb/ssb_driver_extif.h
+++ b/include/linux/ssb/ssb_driver_extif.h
@@ -171,11 +171,15 @@ extern void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
171extern void ssb_extif_timing_init(struct ssb_extif *extif, 171extern void ssb_extif_timing_init(struct ssb_extif *extif,
172 unsigned long ns); 172 unsigned long ns);
173 173
174u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask); 174extern void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
175 175 u32 ticks);
176void ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value);
177 176
178void ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value); 177/* Extif GPIO pin access */
178u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask);
179u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value);
180u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value);
181u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value);
182u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value);
179 183
180#ifdef CONFIG_SSB_SERIAL 184#ifdef CONFIG_SSB_SERIAL
181extern int ssb_extif_serial_init(struct ssb_extif *extif, 185extern int ssb_extif_serial_init(struct ssb_extif *extif,
@@ -200,5 +204,11 @@ void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
200{ 204{
201} 205}
202 206
207static inline
208void ssb_extif_watchdog_timer_set(struct ssb_extif *extif,
209 u32 ticks)
210{
211}
212
203#endif /* CONFIG_SSB_DRIVER_EXTIF */ 213#endif /* CONFIG_SSB_DRIVER_EXTIF */
204#endif /* LINUX_SSB_EXTIFCORE_H_ */ 214#endif /* LINUX_SSB_EXTIFCORE_H_ */
diff --git a/include/linux/ssb/ssb_driver_pci.h b/include/linux/ssb/ssb_driver_pci.h
index 9cfffb7b1a27..5e25bac4ed31 100644
--- a/include/linux/ssb/ssb_driver_pci.h
+++ b/include/linux/ssb/ssb_driver_pci.h
@@ -51,6 +51,11 @@
51#define SSB_PCICORE_SBTOPCI1_MASK 0xFC000000 51#define SSB_PCICORE_SBTOPCI1_MASK 0xFC000000
52#define SSB_PCICORE_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */ 52#define SSB_PCICORE_SBTOPCI2 0x0108 /* Backplane to PCI translation 2 (sbtopci2) */
53#define SSB_PCICORE_SBTOPCI2_MASK 0xC0000000 53#define SSB_PCICORE_SBTOPCI2_MASK 0xC0000000
54#define SSB_PCICORE_PCICFG0 0x0400 /* PCI config space 0 (rev >= 8) */
55#define SSB_PCICORE_PCICFG1 0x0500 /* PCI config space 1 (rev >= 8) */
56#define SSB_PCICORE_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
57#define SSB_PCICORE_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
58#define SSB_PCICORE_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
54 59
55/* SBtoPCIx */ 60/* SBtoPCIx */
56#define SSB_PCICORE_SBTOPCI_MEM 0x00000000 61#define SSB_PCICORE_SBTOPCI_MEM 0x00000000
diff --git a/include/linux/ssb/ssb_embedded.h b/include/linux/ssb/ssb_embedded.h
new file mode 100644
index 000000000000..8d8dedff059d
--- /dev/null
+++ b/include/linux/ssb/ssb_embedded.h
@@ -0,0 +1,18 @@
1#ifndef LINUX_SSB_EMBEDDED_H_
2#define LINUX_SSB_EMBEDDED_H_
3
4#include <linux/types.h>
5#include <linux/ssb/ssb.h>
6
7
8extern int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks);
9
10/* Generic GPIO API */
11u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask);
12u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value);
13u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value);
14u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value);
15u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value);
16u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value);
17
18#endif /* LINUX_SSB_EMBEDDED_H_ */
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 75370ec0923e..9f1b4b46151e 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -246,8 +246,7 @@ static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
246static inline void __dec_zone_page_state(struct page *page, 246static inline void __dec_zone_page_state(struct page *page,
247 enum zone_stat_item item) 247 enum zone_stat_item item)
248{ 248{
249 atomic_long_dec(&page_zone(page)->vm_stat[item]); 249 __dec_zone_state(page_zone(page), item);
250 atomic_long_dec(&vm_stat[item]);
251} 250}
252 251
253/* 252/*
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index c17fa1fdc356..6512d85f11b3 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -14,8 +14,6 @@
14/* capable of receiving packets */ 14/* capable of receiving packets */
15#define IP6_TNL_F_CAP_RCV 0x20000 15#define IP6_TNL_F_CAP_RCV 0x20000
16 16
17#define IP6_TNL_MAX 128
18
19/* IPv6 tunnel */ 17/* IPv6 tunnel */
20 18
21struct ip6_tnl { 19struct ip6_tnl {
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 9462d6ae2f37..9619b9d35c9e 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -411,6 +411,7 @@ struct sctp_event_subscribe {
411 __u8 sctp_shutdown_event; 411 __u8 sctp_shutdown_event;
412 __u8 sctp_partial_delivery_event; 412 __u8 sctp_partial_delivery_event;
413 __u8 sctp_adaptation_layer_event; 413 __u8 sctp_adaptation_layer_event;
414 __u8 sctp_authentication_event;
414}; 415};
415 416
416/* 417/*
@@ -587,7 +588,7 @@ struct sctp_authchunk {
587 * endpoint requires the peer to use. 588 * endpoint requires the peer to use.
588*/ 589*/
589struct sctp_hmacalgo { 590struct sctp_hmacalgo {
590 __u16 shmac_num_idents; 591 __u32 shmac_num_idents;
591 __u16 shmac_idents[]; 592 __u16 shmac_idents[];
592}; 593};
593 594
@@ -600,7 +601,7 @@ struct sctp_hmacalgo {
600struct sctp_authkey { 601struct sctp_authkey {
601 sctp_assoc_t sca_assoc_id; 602 sctp_assoc_t sca_assoc_id;
602 __u16 sca_keynumber; 603 __u16 sca_keynumber;
603 __u16 sca_keylen; 604 __u16 sca_keylength;
604 __u8 sca_key[]; 605 __u8 sca_key[];
605}; 606};
606 607
@@ -693,8 +694,9 @@ struct sctp_status {
693 * the peer requires to be received authenticated only. 694 * the peer requires to be received authenticated only.
694 */ 695 */
695struct sctp_authchunks { 696struct sctp_authchunks {
696 sctp_assoc_t gauth_assoc_id; 697 sctp_assoc_t gauth_assoc_id;
697 uint8_t gauth_chunks[]; 698 __u32 gauth_number_of_chunks;
699 uint8_t gauth_chunks[];
698}; 700};
699 701
700/* 702/*
diff --git a/kernel/audit.c b/kernel/audit.c
index 2eeea9a14240..10c4930c2bbf 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -170,7 +170,9 @@ void audit_panic(const char *message)
170 printk(KERN_ERR "audit: %s\n", message); 170 printk(KERN_ERR "audit: %s\n", message);
171 break; 171 break;
172 case AUDIT_FAIL_PANIC: 172 case AUDIT_FAIL_PANIC:
173 panic("audit: %s\n", message); 173 /* test audit_pid since printk is always losey, why bother? */
174 if (audit_pid)
175 panic("audit: %s\n", message);
174 break; 176 break;
175 } 177 }
176} 178}
@@ -352,6 +354,7 @@ static int kauditd_thread(void *dummy)
352 if (err < 0) { 354 if (err < 0) {
353 BUG_ON(err != -ECONNREFUSED); /* Shoudn't happen */ 355 BUG_ON(err != -ECONNREFUSED); /* Shoudn't happen */
354 printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid); 356 printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid);
357 audit_log_lost("auditd dissapeared\n");
355 audit_pid = 0; 358 audit_pid = 0;
356 } 359 }
357 } else { 360 } else {
@@ -1350,17 +1353,19 @@ void audit_log_end(struct audit_buffer *ab)
1350 if (!audit_rate_check()) { 1353 if (!audit_rate_check()) {
1351 audit_log_lost("rate limit exceeded"); 1354 audit_log_lost("rate limit exceeded");
1352 } else { 1355 } else {
1356 struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
1353 if (audit_pid) { 1357 if (audit_pid) {
1354 struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
1355 nlh->nlmsg_len = ab->skb->len - NLMSG_SPACE(0); 1358 nlh->nlmsg_len = ab->skb->len - NLMSG_SPACE(0);
1356 skb_queue_tail(&audit_skb_queue, ab->skb); 1359 skb_queue_tail(&audit_skb_queue, ab->skb);
1357 ab->skb = NULL; 1360 ab->skb = NULL;
1358 wake_up_interruptible(&kauditd_wait); 1361 wake_up_interruptible(&kauditd_wait);
1359 } else if (printk_ratelimit()) { 1362 } else if (nlh->nlmsg_type != AUDIT_EOE) {
1360 struct nlmsghdr *nlh = nlmsg_hdr(ab->skb); 1363 if (printk_ratelimit()) {
1361 printk(KERN_NOTICE "type=%d %s\n", nlh->nlmsg_type, ab->skb->data + NLMSG_SPACE(0)); 1364 printk(KERN_NOTICE "type=%d %s\n",
1362 } else { 1365 nlh->nlmsg_type,
1363 audit_log_lost("printk limit exceeded\n"); 1366 ab->skb->data + NLMSG_SPACE(0));
1367 } else
1368 audit_log_lost("printk limit exceeded\n");
1364 } 1369 }
1365 } 1370 }
1366 audit_buffer_free(ab); 1371 audit_buffer_free(ab);
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 2087d6de67ea..782262e4107d 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1070,7 +1070,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
1070 * so we can be sure nothing was lost. 1070 * so we can be sure nothing was lost.
1071 */ 1071 */
1072 if ((i == 0) && (too_long)) 1072 if ((i == 0) && (too_long))
1073 audit_log_format(*ab, "a%d_len=%ld ", arg_num, 1073 audit_log_format(*ab, "a%d_len=%zu ", arg_num,
1074 has_cntl ? 2*len : len); 1074 has_cntl ? 2*len : len);
1075 1075
1076 /* 1076 /*
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 3574379f4d62..81a4e4a3f087 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -779,6 +779,10 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
779 * parallel walking of the hash-list safe: 779 * parallel walking of the hash-list safe:
780 */ 780 */
781 list_add_tail_rcu(&class->hash_entry, hash_head); 781 list_add_tail_rcu(&class->hash_entry, hash_head);
782 /*
783 * Add it to the global list of classes:
784 */
785 list_add_tail_rcu(&class->lock_entry, &all_lock_classes);
782 786
783 if (verbose(class)) { 787 if (verbose(class)) {
784 graph_unlock(); 788 graph_unlock();
@@ -2282,10 +2286,6 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
2282 return 0; 2286 return 0;
2283 break; 2287 break;
2284 case LOCK_USED: 2288 case LOCK_USED:
2285 /*
2286 * Add it to the global list of classes:
2287 */
2288 list_add_tail_rcu(&this->class->lock_entry, &all_lock_classes);
2289 debug_atomic_dec(&nr_unused_locks); 2289 debug_atomic_dec(&nr_unused_locks);
2290 break; 2290 break;
2291 default: 2291 default:
diff --git a/kernel/printk.c b/kernel/printk.c
index bee36100f110..9adc2a473e6e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -666,7 +666,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
666 } 666 }
667 /* Emit the output into the temporary buffer */ 667 /* Emit the output into the temporary buffer */
668 printed_len += vscnprintf(printk_buf + printed_len, 668 printed_len += vscnprintf(printk_buf + printed_len,
669 sizeof(printk_buf), fmt, args); 669 sizeof(printk_buf) - printed_len, fmt, args);
670 670
671 /* 671 /*
672 * Copy the output into log_buf. If the caller didn't provide 672 * Copy the output into log_buf. If the caller didn't provide
diff --git a/kernel/rcupreempt.c b/kernel/rcupreempt.c
index 987cfb7ade89..e9517014b57c 100644
--- a/kernel/rcupreempt.c
+++ b/kernel/rcupreempt.c
@@ -23,6 +23,10 @@
23 * to Suparna Bhattacharya for pushing me completely away 23 * to Suparna Bhattacharya for pushing me completely away
24 * from atomic instructions on the read side. 24 * from atomic instructions on the read side.
25 * 25 *
26 * - Added handling of Dynamic Ticks
27 * Copyright 2007 - Paul E. Mckenney <paulmck@us.ibm.com>
28 * - Steven Rostedt <srostedt@redhat.com>
29 *
26 * Papers: http://www.rdrop.com/users/paulmck/RCU 30 * Papers: http://www.rdrop.com/users/paulmck/RCU
27 * 31 *
28 * Design Document: http://lwn.net/Articles/253651/ 32 * Design Document: http://lwn.net/Articles/253651/
@@ -409,6 +413,212 @@ static void __rcu_advance_callbacks(struct rcu_data *rdp)
409 } 413 }
410} 414}
411 415
416#ifdef CONFIG_NO_HZ
417
418DEFINE_PER_CPU(long, dynticks_progress_counter) = 1;
419static DEFINE_PER_CPU(long, rcu_dyntick_snapshot);
420static DEFINE_PER_CPU(int, rcu_update_flag);
421
422/**
423 * rcu_irq_enter - Called from Hard irq handlers and NMI/SMI.
424 *
425 * If the CPU was idle with dynamic ticks active, this updates the
426 * dynticks_progress_counter to let the RCU handling know that the
427 * CPU is active.
428 */
429void rcu_irq_enter(void)
430{
431 int cpu = smp_processor_id();
432
433 if (per_cpu(rcu_update_flag, cpu))
434 per_cpu(rcu_update_flag, cpu)++;
435
436 /*
437 * Only update if we are coming from a stopped ticks mode
438 * (dynticks_progress_counter is even).
439 */
440 if (!in_interrupt() &&
441 (per_cpu(dynticks_progress_counter, cpu) & 0x1) == 0) {
442 /*
443 * The following might seem like we could have a race
444 * with NMI/SMIs. But this really isn't a problem.
445 * Here we do a read/modify/write, and the race happens
446 * when an NMI/SMI comes in after the read and before
447 * the write. But NMI/SMIs will increment this counter
448 * twice before returning, so the zero bit will not
449 * be corrupted by the NMI/SMI which is the most important
450 * part.
451 *
452 * The only thing is that we would bring back the counter
453 * to a postion that it was in during the NMI/SMI.
454 * But the zero bit would be set, so the rest of the
455 * counter would again be ignored.
456 *
457 * On return from the IRQ, the counter may have the zero
458 * bit be 0 and the counter the same as the return from
459 * the NMI/SMI. If the state machine was so unlucky to
460 * see that, it still doesn't matter, since all
461 * RCU read-side critical sections on this CPU would
462 * have already completed.
463 */
464 per_cpu(dynticks_progress_counter, cpu)++;
465 /*
466 * The following memory barrier ensures that any
467 * rcu_read_lock() primitives in the irq handler
468 * are seen by other CPUs to follow the above
469 * increment to dynticks_progress_counter. This is
470 * required in order for other CPUs to correctly
471 * determine when it is safe to advance the RCU
472 * grace-period state machine.
473 */
474 smp_mb(); /* see above block comment. */
475 /*
476 * Since we can't determine the dynamic tick mode from
477 * the dynticks_progress_counter after this routine,
478 * we use a second flag to acknowledge that we came
479 * from an idle state with ticks stopped.
480 */
481 per_cpu(rcu_update_flag, cpu)++;
482 /*
483 * If we take an NMI/SMI now, they will also increment
484 * the rcu_update_flag, and will not update the
485 * dynticks_progress_counter on exit. That is for
486 * this IRQ to do.
487 */
488 }
489}
490
491/**
492 * rcu_irq_exit - Called from exiting Hard irq context.
493 *
494 * If the CPU was idle with dynamic ticks active, update the
495 * dynticks_progress_counter to put let the RCU handling be
496 * aware that the CPU is going back to idle with no ticks.
497 */
498void rcu_irq_exit(void)
499{
500 int cpu = smp_processor_id();
501
502 /*
503 * rcu_update_flag is set if we interrupted the CPU
504 * when it was idle with ticks stopped.
505 * Once this occurs, we keep track of interrupt nesting
506 * because a NMI/SMI could also come in, and we still
507 * only want the IRQ that started the increment of the
508 * dynticks_progress_counter to be the one that modifies
509 * it on exit.
510 */
511 if (per_cpu(rcu_update_flag, cpu)) {
512 if (--per_cpu(rcu_update_flag, cpu))
513 return;
514
515 /* This must match the interrupt nesting */
516 WARN_ON(in_interrupt());
517
518 /*
519 * If an NMI/SMI happens now we are still
520 * protected by the dynticks_progress_counter being odd.
521 */
522
523 /*
524 * The following memory barrier ensures that any
525 * rcu_read_unlock() primitives in the irq handler
526 * are seen by other CPUs to preceed the following
527 * increment to dynticks_progress_counter. This
528 * is required in order for other CPUs to determine
529 * when it is safe to advance the RCU grace-period
530 * state machine.
531 */
532 smp_mb(); /* see above block comment. */
533 per_cpu(dynticks_progress_counter, cpu)++;
534 WARN_ON(per_cpu(dynticks_progress_counter, cpu) & 0x1);
535 }
536}
537
538static void dyntick_save_progress_counter(int cpu)
539{
540 per_cpu(rcu_dyntick_snapshot, cpu) =
541 per_cpu(dynticks_progress_counter, cpu);
542}
543
544static inline int
545rcu_try_flip_waitack_needed(int cpu)
546{
547 long curr;
548 long snap;
549
550 curr = per_cpu(dynticks_progress_counter, cpu);
551 snap = per_cpu(rcu_dyntick_snapshot, cpu);
552 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */
553
554 /*
555 * If the CPU remained in dynticks mode for the entire time
556 * and didn't take any interrupts, NMIs, SMIs, or whatever,
557 * then it cannot be in the middle of an rcu_read_lock(), so
558 * the next rcu_read_lock() it executes must use the new value
559 * of the counter. So we can safely pretend that this CPU
560 * already acknowledged the counter.
561 */
562
563 if ((curr == snap) && ((curr & 0x1) == 0))
564 return 0;
565
566 /*
567 * If the CPU passed through or entered a dynticks idle phase with
568 * no active irq handlers, then, as above, we can safely pretend
569 * that this CPU already acknowledged the counter.
570 */
571
572 if ((curr - snap) > 2 || (snap & 0x1) == 0)
573 return 0;
574
575 /* We need this CPU to explicitly acknowledge the counter flip. */
576
577 return 1;
578}
579
580static inline int
581rcu_try_flip_waitmb_needed(int cpu)
582{
583 long curr;
584 long snap;
585
586 curr = per_cpu(dynticks_progress_counter, cpu);
587 snap = per_cpu(rcu_dyntick_snapshot, cpu);
588 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */
589
590 /*
591 * If the CPU remained in dynticks mode for the entire time
592 * and didn't take any interrupts, NMIs, SMIs, or whatever,
593 * then it cannot have executed an RCU read-side critical section
594 * during that time, so there is no need for it to execute a
595 * memory barrier.
596 */
597
598 if ((curr == snap) && ((curr & 0x1) == 0))
599 return 0;
600
601 /*
602 * If the CPU either entered or exited an outermost interrupt,
603 * SMI, NMI, or whatever handler, then we know that it executed
604 * a memory barrier when doing so. So we don't need another one.
605 */
606 if (curr != snap)
607 return 0;
608
609 /* We need the CPU to execute a memory barrier. */
610
611 return 1;
612}
613
614#else /* !CONFIG_NO_HZ */
615
616# define dyntick_save_progress_counter(cpu) do { } while (0)
617# define rcu_try_flip_waitack_needed(cpu) (1)
618# define rcu_try_flip_waitmb_needed(cpu) (1)
619
620#endif /* CONFIG_NO_HZ */
621
412/* 622/*
413 * Get here when RCU is idle. Decide whether we need to 623 * Get here when RCU is idle. Decide whether we need to
414 * move out of idle state, and return non-zero if so. 624 * move out of idle state, and return non-zero if so.
@@ -447,8 +657,10 @@ rcu_try_flip_idle(void)
447 657
448 /* Now ask each CPU for acknowledgement of the flip. */ 658 /* Now ask each CPU for acknowledgement of the flip. */
449 659
450 for_each_cpu_mask(cpu, rcu_cpu_online_map) 660 for_each_cpu_mask(cpu, rcu_cpu_online_map) {
451 per_cpu(rcu_flip_flag, cpu) = rcu_flipped; 661 per_cpu(rcu_flip_flag, cpu) = rcu_flipped;
662 dyntick_save_progress_counter(cpu);
663 }
452 664
453 return 1; 665 return 1;
454} 666}
@@ -464,7 +676,8 @@ rcu_try_flip_waitack(void)
464 676
465 RCU_TRACE_ME(rcupreempt_trace_try_flip_a1); 677 RCU_TRACE_ME(rcupreempt_trace_try_flip_a1);
466 for_each_cpu_mask(cpu, rcu_cpu_online_map) 678 for_each_cpu_mask(cpu, rcu_cpu_online_map)
467 if (per_cpu(rcu_flip_flag, cpu) != rcu_flip_seen) { 679 if (rcu_try_flip_waitack_needed(cpu) &&
680 per_cpu(rcu_flip_flag, cpu) != rcu_flip_seen) {
468 RCU_TRACE_ME(rcupreempt_trace_try_flip_ae1); 681 RCU_TRACE_ME(rcupreempt_trace_try_flip_ae1);
469 return 0; 682 return 0;
470 } 683 }
@@ -509,8 +722,10 @@ rcu_try_flip_waitzero(void)
509 smp_mb(); /* ^^^^^^^^^^^^ */ 722 smp_mb(); /* ^^^^^^^^^^^^ */
510 723
511 /* Call for a memory barrier from each CPU. */ 724 /* Call for a memory barrier from each CPU. */
512 for_each_cpu_mask(cpu, rcu_cpu_online_map) 725 for_each_cpu_mask(cpu, rcu_cpu_online_map) {
513 per_cpu(rcu_mb_flag, cpu) = rcu_mb_needed; 726 per_cpu(rcu_mb_flag, cpu) = rcu_mb_needed;
727 dyntick_save_progress_counter(cpu);
728 }
514 729
515 RCU_TRACE_ME(rcupreempt_trace_try_flip_z2); 730 RCU_TRACE_ME(rcupreempt_trace_try_flip_z2);
516 return 1; 731 return 1;
@@ -528,7 +743,8 @@ rcu_try_flip_waitmb(void)
528 743
529 RCU_TRACE_ME(rcupreempt_trace_try_flip_m1); 744 RCU_TRACE_ME(rcupreempt_trace_try_flip_m1);
530 for_each_cpu_mask(cpu, rcu_cpu_online_map) 745 for_each_cpu_mask(cpu, rcu_cpu_online_map)
531 if (per_cpu(rcu_mb_flag, cpu) != rcu_mb_done) { 746 if (rcu_try_flip_waitmb_needed(cpu) &&
747 per_cpu(rcu_mb_flag, cpu) != rcu_mb_done) {
532 RCU_TRACE_ME(rcupreempt_trace_try_flip_me1); 748 RCU_TRACE_ME(rcupreempt_trace_try_flip_me1);
533 return 0; 749 return 0;
534 } 750 }
@@ -702,8 +918,9 @@ void rcu_offline_cpu(int cpu)
702 * fix. 918 * fix.
703 */ 919 */
704 920
921 local_irq_save(flags);
705 rdp = RCU_DATA_ME(); 922 rdp = RCU_DATA_ME();
706 spin_lock_irqsave(&rdp->lock, flags); 923 spin_lock(&rdp->lock);
707 *rdp->nexttail = list; 924 *rdp->nexttail = list;
708 if (list) 925 if (list)
709 rdp->nexttail = tail; 926 rdp->nexttail = tail;
@@ -735,9 +952,11 @@ static void rcu_process_callbacks(struct softirq_action *unused)
735{ 952{
736 unsigned long flags; 953 unsigned long flags;
737 struct rcu_head *next, *list; 954 struct rcu_head *next, *list;
738 struct rcu_data *rdp = RCU_DATA_ME(); 955 struct rcu_data *rdp;
739 956
740 spin_lock_irqsave(&rdp->lock, flags); 957 local_irq_save(flags);
958 rdp = RCU_DATA_ME();
959 spin_lock(&rdp->lock);
741 list = rdp->donelist; 960 list = rdp->donelist;
742 if (list == NULL) { 961 if (list == NULL) {
743 spin_unlock_irqrestore(&rdp->lock, flags); 962 spin_unlock_irqrestore(&rdp->lock, flags);
diff --git a/kernel/sched.c b/kernel/sched.c
index b387a8de26a5..f06950c8a6ce 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -668,6 +668,8 @@ const_debug unsigned int sysctl_sched_nr_migrate = 32;
668 */ 668 */
669unsigned int sysctl_sched_rt_period = 1000000; 669unsigned int sysctl_sched_rt_period = 1000000;
670 670
671static __read_mostly int scheduler_running;
672
671/* 673/*
672 * part of the period that we allow rt tasks to run in us. 674 * part of the period that we allow rt tasks to run in us.
673 * default: 0.95s 675 * default: 0.95s
@@ -689,14 +691,16 @@ unsigned long long cpu_clock(int cpu)
689 unsigned long flags; 691 unsigned long flags;
690 struct rq *rq; 692 struct rq *rq;
691 693
692 local_irq_save(flags);
693 rq = cpu_rq(cpu);
694 /* 694 /*
695 * Only call sched_clock() if the scheduler has already been 695 * Only call sched_clock() if the scheduler has already been
696 * initialized (some code might call cpu_clock() very early): 696 * initialized (some code might call cpu_clock() very early):
697 */ 697 */
698 if (rq->idle) 698 if (unlikely(!scheduler_running))
699 update_rq_clock(rq); 699 return 0;
700
701 local_irq_save(flags);
702 rq = cpu_rq(cpu);
703 update_rq_clock(rq);
700 now = rq->clock; 704 now = rq->clock;
701 local_irq_restore(flags); 705 local_irq_restore(flags);
702 706
@@ -3885,7 +3889,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev)
3885asmlinkage void __sched schedule(void) 3889asmlinkage void __sched schedule(void)
3886{ 3890{
3887 struct task_struct *prev, *next; 3891 struct task_struct *prev, *next;
3888 long *switch_count; 3892 unsigned long *switch_count;
3889 struct rq *rq; 3893 struct rq *rq;
3890 int cpu; 3894 int cpu;
3891 3895
@@ -7284,6 +7288,8 @@ void __init sched_init(void)
7284 * During early bootup we pretend to be a normal task: 7288 * During early bootup we pretend to be a normal task:
7285 */ 7289 */
7286 current->sched_class = &fair_sched_class; 7290 current->sched_class = &fair_sched_class;
7291
7292 scheduler_running = 1;
7287} 7293}
7288 7294
7289#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 7295#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 6c091d6e159d..c8e6492c5925 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -202,17 +202,12 @@ static struct sched_entity *__pick_next_entity(struct cfs_rq *cfs_rq)
202 202
203static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) 203static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
204{ 204{
205 struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; 205 struct rb_node *last = rb_last(&cfs_rq->tasks_timeline);
206 struct sched_entity *se = NULL;
207 struct rb_node *parent;
208 206
209 while (*link) { 207 if (!last)
210 parent = *link; 208 return NULL;
211 se = rb_entry(parent, struct sched_entity, run_node);
212 link = &parent->rb_right;
213 }
214 209
215 return se; 210 return rb_entry(last, struct sched_entity, run_node);
216} 211}
217 212
218/************************************************************** 213/**************************************************************
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 5b3aea5f471e..31e9f2a47928 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -313,6 +313,7 @@ void irq_exit(void)
313 /* Make sure that timer wheel updates are propagated */ 313 /* Make sure that timer wheel updates are propagated */
314 if (!in_interrupt() && idle_cpu(smp_processor_id()) && !need_resched()) 314 if (!in_interrupt() && idle_cpu(smp_processor_id()) && !need_resched())
315 tick_nohz_stop_sched_tick(); 315 tick_nohz_stop_sched_tick();
316 rcu_irq_exit();
316#endif 317#endif
317 preempt_enable_no_resched(); 318 preempt_enable_no_resched();
318} 319}
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index 7c2da88db4ed..01b6522fd92b 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -216,26 +216,27 @@ static int watchdog(void *__bind_cpu)
216 /* initialize timestamp */ 216 /* initialize timestamp */
217 touch_softlockup_watchdog(); 217 touch_softlockup_watchdog();
218 218
219 set_current_state(TASK_INTERRUPTIBLE);
219 /* 220 /*
220 * Run briefly once per second to reset the softlockup timestamp. 221 * Run briefly once per second to reset the softlockup timestamp.
221 * If this gets delayed for more than 60 seconds then the 222 * If this gets delayed for more than 60 seconds then the
222 * debug-printout triggers in softlockup_tick(). 223 * debug-printout triggers in softlockup_tick().
223 */ 224 */
224 while (!kthread_should_stop()) { 225 while (!kthread_should_stop()) {
225 set_current_state(TASK_INTERRUPTIBLE);
226 touch_softlockup_watchdog(); 226 touch_softlockup_watchdog();
227 schedule(); 227 schedule();
228 228
229 if (kthread_should_stop()) 229 if (kthread_should_stop())
230 break; 230 break;
231 231
232 if (this_cpu != check_cpu) 232 if (this_cpu == check_cpu) {
233 continue; 233 if (sysctl_hung_task_timeout_secs)
234 234 check_hung_uninterruptible_tasks(this_cpu);
235 if (sysctl_hung_task_timeout_secs) 235 }
236 check_hung_uninterruptible_tasks(this_cpu);
237 236
237 set_current_state(TASK_INTERRUPTIBLE);
238 } 238 }
239 __set_current_state(TASK_RUNNING);
239 240
240 return 0; 241 return 0;
241} 242}
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index fa9bb73dbdb4..2968298f8f36 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -282,6 +282,7 @@ void tick_nohz_stop_sched_tick(void)
282 ts->idle_tick = ts->sched_timer.expires; 282 ts->idle_tick = ts->sched_timer.expires;
283 ts->tick_stopped = 1; 283 ts->tick_stopped = 1;
284 ts->idle_jiffies = last_jiffies; 284 ts->idle_jiffies = last_jiffies;
285 rcu_enter_nohz();
285 } 286 }
286 287
287 /* 288 /*
@@ -375,6 +376,8 @@ void tick_nohz_restart_sched_tick(void)
375 return; 376 return;
376 } 377 }
377 378
379 rcu_exit_nohz();
380
378 /* Update jiffies first */ 381 /* Update jiffies first */
379 select_nohz_load_balancer(0); 382 select_nohz_load_balancer(0);
380 now = ktime_get(); 383 now = ktime_get();
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index fc60c6d096b9..77f04e49a1a0 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -366,8 +366,7 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
366{ 366{
367 struct net_device_stats *stats = &dev->stats; 367 struct net_device_stats *stats = &dev->stats;
368 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data); 368 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data);
369 DECLARE_MAC_BUF(mac); 369
370 DECLARE_MAC_BUF(mac2);
371 /* Handle non-VLAN frames if they are sent to us, for example by DHCP. 370 /* Handle non-VLAN frames if they are sent to us, for example by DHCP.
372 * 371 *
373 * NOTE: THIS ASSUMES DIX ETHERNET, SPECIFICALLY NOT SUPPORTING 372 * NOTE: THIS ASSUMES DIX ETHERNET, SPECIFICALLY NOT SUPPORTING
@@ -405,8 +404,11 @@ static int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
405 404
406 pr_debug("%s: about to send skb: %p to dev: %s\n", 405 pr_debug("%s: about to send skb: %p to dev: %s\n",
407 __FUNCTION__, skb, skb->dev->name); 406 __FUNCTION__, skb, skb->dev->name);
408 pr_debug(" %s %s %4hx %4hx %4hx\n", 407 pr_debug(" " MAC_FMT " " MAC_FMT " %4hx %4hx %4hx\n",
409 print_mac(mac, veth->h_dest), print_mac(mac2, veth->h_source), 408 veth->h_dest[0], veth->h_dest[1], veth->h_dest[2],
409 veth->h_dest[3], veth->h_dest[4], veth->h_dest[5],
410 veth->h_source[0], veth->h_source[1], veth->h_source[2],
411 veth->h_source[3], veth->h_source[4], veth->h_source[5],
410 veth->h_vlan_proto, veth->h_vlan_TCI, 412 veth->h_vlan_proto, veth->h_vlan_TCI,
411 veth->h_vlan_encapsulated_proto); 413 veth->h_vlan_encapsulated_proto);
412 414
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index a0ec47925597..146cfb0e9882 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -161,11 +161,10 @@ int __init vlan_proc_init(void)
161 if (!proc_vlan_dir) 161 if (!proc_vlan_dir)
162 goto err; 162 goto err;
163 163
164 proc_vlan_conf = create_proc_entry(name_conf, S_IFREG|S_IRUSR|S_IWUSR, 164 proc_vlan_conf = proc_create(name_conf, S_IFREG|S_IRUSR|S_IWUSR,
165 proc_vlan_dir); 165 proc_vlan_dir, &vlan_fops);
166 if (!proc_vlan_conf) 166 if (!proc_vlan_conf)
167 goto err; 167 goto err;
168 proc_vlan_conf->proc_fops = &vlan_fops;
169 return 0; 168 return 0;
170 169
171err: 170err:
@@ -182,13 +181,11 @@ int vlan_proc_add_dev(struct net_device *vlandev)
182{ 181{
183 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev); 182 struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
184 183
185 dev_info->dent = create_proc_entry(vlandev->name, 184 dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
186 S_IFREG|S_IRUSR|S_IWUSR, 185 proc_vlan_dir, &vlandev_fops);
187 proc_vlan_dir);
188 if (!dev_info->dent) 186 if (!dev_info->dent)
189 return -ENOBUFS; 187 return -ENOBUFS;
190 188
191 dev_info->dent->proc_fops = &vlandev_fops;
192 dev_info->dent->data = vlandev; 189 dev_info->dent->data = vlandev;
193 return 0; 190 return 0;
194} 191}
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 9e3d81cb9f08..de7a9f532edc 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -110,7 +110,7 @@ static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag)
110 } 110 }
111 for (count = old_max; count < c->max_tag; count++) { 111 for (count = old_max; count < c->max_tag; count++) {
112 c->reqs[count].status = REQ_STATUS_IDLE; 112 c->reqs[count].status = REQ_STATUS_IDLE;
113 c->reqs[count].wq = kmalloc(sizeof(wait_queue_t), 113 c->reqs[count].wq = kmalloc(sizeof(wait_queue_head_t),
114 GFP_ATOMIC); 114 GFP_ATOMIC);
115 if (!c->reqs[count].wq) { 115 if (!c->reqs[count].wq) {
116 printk(KERN_ERR "Couldn't grow tag array\n"); 116 printk(KERN_ERR "Couldn't grow tag array\n");
diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index 8e8dcfd532db..162199a2d74f 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -283,25 +283,24 @@ int __init atalk_proc_init(void)
283 goto out; 283 goto out;
284 atalk_proc_dir->owner = THIS_MODULE; 284 atalk_proc_dir->owner = THIS_MODULE;
285 285
286 p = create_proc_entry("interface", S_IRUGO, atalk_proc_dir); 286 p = proc_create("interface", S_IRUGO, atalk_proc_dir,
287 &atalk_seq_interface_fops);
287 if (!p) 288 if (!p)
288 goto out_interface; 289 goto out_interface;
289 p->proc_fops = &atalk_seq_interface_fops;
290 290
291 p = create_proc_entry("route", S_IRUGO, atalk_proc_dir); 291 p = proc_create("route", S_IRUGO, atalk_proc_dir,
292 &atalk_seq_route_fops);
292 if (!p) 293 if (!p)
293 goto out_route; 294 goto out_route;
294 p->proc_fops = &atalk_seq_route_fops;
295 295
296 p = create_proc_entry("socket", S_IRUGO, atalk_proc_dir); 296 p = proc_create("socket", S_IRUGO, atalk_proc_dir,
297 &atalk_seq_socket_fops);
297 if (!p) 298 if (!p)
298 goto out_socket; 299 goto out_socket;
299 p->proc_fops = &atalk_seq_socket_fops;
300 300
301 p = create_proc_entry("arp", S_IRUGO, atalk_proc_dir); 301 p = proc_create("arp", S_IRUGO, atalk_proc_dir, &atalk_seq_arp_fops);
302 if (!p) 302 if (!p)
303 goto out_arp; 303 goto out_arp;
304 p->proc_fops = &atalk_seq_arp_fops;
305 304
306 rc = 0; 305 rc = 0;
307out: 306out:
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 574d9a964176..1b228065e745 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -742,9 +742,9 @@ static int __init br2684_init(void)
742{ 742{
743#ifdef CONFIG_PROC_FS 743#ifdef CONFIG_PROC_FS
744 struct proc_dir_entry *p; 744 struct proc_dir_entry *p;
745 if ((p = create_proc_entry("br2684", 0, atm_proc_root)) == NULL) 745 p = proc_create("br2684", 0, atm_proc_root, &br2684_proc_ops);
746 if (p == NULL)
746 return -ENOMEM; 747 return -ENOMEM;
747 p->proc_fops = &br2684_proc_ops;
748#endif 748#endif
749 register_atm_ioctl(&br2684_ioctl_ops); 749 register_atm_ioctl(&br2684_ioctl_ops);
750 return 0; 750 return 0;
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 86b885ec1cbd..d30167c0b48e 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -962,9 +962,7 @@ static int __init atm_clip_init(void)
962 { 962 {
963 struct proc_dir_entry *p; 963 struct proc_dir_entry *p;
964 964
965 p = create_proc_entry("arp", S_IRUGO, atm_proc_root); 965 p = proc_create("arp", S_IRUGO, atm_proc_root, &arp_seq_fops);
966 if (p)
967 p->proc_fops = &arp_seq_fops;
968 } 966 }
969#endif 967#endif
970 968
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 1a8c4c6c0cd0..0e450d12f035 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1249,9 +1249,7 @@ static int __init lane_module_init(void)
1249#ifdef CONFIG_PROC_FS 1249#ifdef CONFIG_PROC_FS
1250 struct proc_dir_entry *p; 1250 struct proc_dir_entry *p;
1251 1251
1252 p = create_proc_entry("lec", S_IRUGO, atm_proc_root); 1252 p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops);
1253 if (p)
1254 p->proc_fops = &lec_seq_fops;
1255#endif 1253#endif
1256 1254
1257 register_atm_ioctl(&lane_ioctl_ops); 1255 register_atm_ioctl(&lane_ioctl_ops);
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 91f3ffc90dbd..4990541ef5da 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -276,12 +276,11 @@ int mpc_proc_init(void)
276{ 276{
277 struct proc_dir_entry *p; 277 struct proc_dir_entry *p;
278 278
279 p = create_proc_entry(STAT_FILE_NAME, 0, atm_proc_root); 279 p = proc_create(STAT_FILE_NAME, 0, atm_proc_root, &mpc_file_operations);
280 if (!p) { 280 if (!p) {
281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME); 281 printk(KERN_ERR "Unable to initialize /proc/atm/%s\n", STAT_FILE_NAME);
282 return -ENOMEM; 282 return -ENOMEM;
283 } 283 }
284 p->proc_fops = &mpc_file_operations;
285 p->owner = THIS_MODULE; 284 p->owner = THIS_MODULE;
286 return 0; 285 return 0;
287} 286}
diff --git a/net/atm/proc.c b/net/atm/proc.c
index 49125110bb8b..e9693aed7ef8 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -435,11 +435,11 @@ int atm_proc_dev_register(struct atm_dev *dev)
435 goto err_out; 435 goto err_out;
436 sprintf(dev->proc_name,"%s:%d",dev->type, dev->number); 436 sprintf(dev->proc_name,"%s:%d",dev->type, dev->number);
437 437
438 dev->proc_entry = create_proc_entry(dev->proc_name, 0, atm_proc_root); 438 dev->proc_entry = proc_create(dev->proc_name, 0, atm_proc_root,
439 &proc_atm_dev_ops);
439 if (!dev->proc_entry) 440 if (!dev->proc_entry)
440 goto err_free_name; 441 goto err_free_name;
441 dev->proc_entry->data = dev; 442 dev->proc_entry->data = dev;
442 dev->proc_entry->proc_fops = &proc_atm_dev_ops;
443 dev->proc_entry->owner = THIS_MODULE; 443 dev->proc_entry->owner = THIS_MODULE;
444 return 0; 444 return 0;
445err_free_name: 445err_free_name:
@@ -492,10 +492,10 @@ int __init atm_proc_init(void)
492 for (e = atm_proc_ents; e->name; e++) { 492 for (e = atm_proc_ents; e->name; e++) {
493 struct proc_dir_entry *dirent; 493 struct proc_dir_entry *dirent;
494 494
495 dirent = create_proc_entry(e->name, S_IRUGO, atm_proc_root); 495 dirent = proc_create(e->name, S_IRUGO,
496 atm_proc_root, e->proc_fops);
496 if (!dirent) 497 if (!dirent)
497 goto err_out_remove; 498 goto err_out_remove;
498 dirent->proc_fops = e->proc_fops;
499 dirent->owner = THIS_MODULE; 499 dirent->owner = THIS_MODULE;
500 e->dirent = dirent; 500 e->dirent = dirent;
501 } 501 }
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index a8811c0a0cea..7c5459c8e8ef 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -417,6 +417,8 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
417 l2cap_sock_kill(sk); 417 l2cap_sock_kill(sk);
418 } 418 }
419 419
420 del_timer_sync(&conn->info_timer);
421
420 hcon->l2cap_data = NULL; 422 hcon->l2cap_data = NULL;
421 kfree(conn); 423 kfree(conn);
422} 424}
diff --git a/net/bridge/netfilter/ebt_dnat.c b/net/bridge/netfilter/ebt_dnat.c
index e700cbf634c2..ca64c1cc1b47 100644
--- a/net/bridge/netfilter/ebt_dnat.c
+++ b/net/bridge/netfilter/ebt_dnat.c
@@ -20,8 +20,8 @@ static int ebt_target_dnat(struct sk_buff *skb, unsigned int hooknr,
20{ 20{
21 const struct ebt_nat_info *info = data; 21 const struct ebt_nat_info *info = data;
22 22
23 if (skb_make_writable(skb, 0)) 23 if (!skb_make_writable(skb, 0))
24 return NF_DROP; 24 return EBT_DROP;
25 25
26 memcpy(eth_hdr(skb)->h_dest, info->mac, ETH_ALEN); 26 memcpy(eth_hdr(skb)->h_dest, info->mac, ETH_ALEN);
27 return info->target; 27 return info->target;
diff --git a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c
index bfdf2fb60b1f..b8afe850cf1e 100644
--- a/net/bridge/netfilter/ebt_redirect.c
+++ b/net/bridge/netfilter/ebt_redirect.c
@@ -21,8 +21,8 @@ static int ebt_target_redirect(struct sk_buff *skb, unsigned int hooknr,
21{ 21{
22 const struct ebt_redirect_info *info = data; 22 const struct ebt_redirect_info *info = data;
23 23
24 if (skb_make_writable(skb, 0)) 24 if (!skb_make_writable(skb, 0))
25 return NF_DROP; 25 return EBT_DROP;
26 26
27 if (hooknr != NF_BR_BROUTING) 27 if (hooknr != NF_BR_BROUTING)
28 memcpy(eth_hdr(skb)->h_dest, 28 memcpy(eth_hdr(skb)->h_dest,
diff --git a/net/bridge/netfilter/ebt_snat.c b/net/bridge/netfilter/ebt_snat.c
index e252dabbb143..5425333dda03 100644
--- a/net/bridge/netfilter/ebt_snat.c
+++ b/net/bridge/netfilter/ebt_snat.c
@@ -22,8 +22,8 @@ static int ebt_target_snat(struct sk_buff *skb, unsigned int hooknr,
22{ 22{
23 const struct ebt_nat_info *info = data; 23 const struct ebt_nat_info *info = data;
24 24
25 if (skb_make_writable(skb, 0)) 25 if (!skb_make_writable(skb, 0))
26 return NF_DROP; 26 return EBT_DROP;
27 27
28 memcpy(eth_hdr(skb)->h_source, info->mac, ETH_ALEN); 28 memcpy(eth_hdr(skb)->h_source, info->mac, ETH_ALEN);
29 if (!(info->target & NAT_ARP_BIT) && 29 if (!(info->target & NAT_ARP_BIT) &&
diff --git a/net/core/dev.c b/net/core/dev.c
index 908f07c3bd7d..fcdf03cf3b3f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2900,7 +2900,7 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,
2900 } 2900 }
2901 } 2901 }
2902 2902
2903 da = kmalloc(sizeof(*da), GFP_ATOMIC); 2903 da = kzalloc(sizeof(*da), GFP_ATOMIC);
2904 if (da == NULL) 2904 if (da == NULL)
2905 return -ENOMEM; 2905 return -ENOMEM;
2906 memcpy(da->da_addr, addr, alen); 2906 memcpy(da->da_addr, addr, alen);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index a16cf1ec5e5e..aef01533dfb6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -358,11 +358,12 @@ struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
358{ 358{
359 struct neighbour *n; 359 struct neighbour *n;
360 int key_len = tbl->key_len; 360 int key_len = tbl->key_len;
361 u32 hash_val = tbl->hash(pkey, dev); 361 u32 hash_val;
362 362
363 NEIGH_CACHE_STAT_INC(tbl, lookups); 363 NEIGH_CACHE_STAT_INC(tbl, lookups);
364 364
365 read_lock_bh(&tbl->lock); 365 read_lock_bh(&tbl->lock);
366 hash_val = tbl->hash(pkey, dev);
366 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { 367 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) {
367 if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) { 368 if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) {
368 neigh_hold(n); 369 neigh_hold(n);
@@ -379,11 +380,12 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net,
379{ 380{
380 struct neighbour *n; 381 struct neighbour *n;
381 int key_len = tbl->key_len; 382 int key_len = tbl->key_len;
382 u32 hash_val = tbl->hash(pkey, NULL); 383 u32 hash_val;
383 384
384 NEIGH_CACHE_STAT_INC(tbl, lookups); 385 NEIGH_CACHE_STAT_INC(tbl, lookups);
385 386
386 read_lock_bh(&tbl->lock); 387 read_lock_bh(&tbl->lock);
388 hash_val = tbl->hash(pkey, NULL);
387 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) { 389 for (n = tbl->hash_buckets[hash_val & tbl->hash_mask]; n; n = n->next) {
388 if (!memcmp(n->primary_key, pkey, key_len) && 390 if (!memcmp(n->primary_key, pkey, key_len) &&
389 (net == n->dev->nd_net)) { 391 (net == n->dev->nd_net)) {
@@ -507,6 +509,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
507 if (tbl->pconstructor && tbl->pconstructor(n)) { 509 if (tbl->pconstructor && tbl->pconstructor(n)) {
508 if (dev) 510 if (dev)
509 dev_put(dev); 511 dev_put(dev);
512 release_net(net);
510 kfree(n); 513 kfree(n);
511 n = NULL; 514 n = NULL;
512 goto out; 515 goto out;
@@ -1386,10 +1389,10 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1386 panic("cannot create neighbour cache statistics"); 1389 panic("cannot create neighbour cache statistics");
1387 1390
1388#ifdef CONFIG_PROC_FS 1391#ifdef CONFIG_PROC_FS
1389 tbl->pde = create_proc_entry(tbl->id, 0, init_net.proc_net_stat); 1392 tbl->pde = proc_create(tbl->id, 0, init_net.proc_net_stat,
1393 &neigh_stat_seq_fops);
1390 if (!tbl->pde) 1394 if (!tbl->pde)
1391 panic("cannot create neighbour proc dir entry"); 1395 panic("cannot create neighbour proc dir entry");
1392 tbl->pde->proc_fops = &neigh_stat_seq_fops;
1393 tbl->pde->data = tbl; 1396 tbl->pde->data = tbl;
1394#endif 1397#endif
1395 1398
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index bfcdfaebca5c..20e63b302ba6 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3570,14 +3570,14 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3570 if (err) 3570 if (err)
3571 goto out1; 3571 goto out1;
3572 3572
3573 pkt_dev->entry = create_proc_entry(ifname, 0600, pg_proc_dir); 3573 pkt_dev->entry = proc_create(ifname, 0600,
3574 pg_proc_dir, &pktgen_if_fops);
3574 if (!pkt_dev->entry) { 3575 if (!pkt_dev->entry) {
3575 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n", 3576 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
3576 PG_PROC_DIR, ifname); 3577 PG_PROC_DIR, ifname);
3577 err = -EINVAL; 3578 err = -EINVAL;
3578 goto out2; 3579 goto out2;
3579 } 3580 }
3580 pkt_dev->entry->proc_fops = &pktgen_if_fops;
3581 pkt_dev->entry->data = pkt_dev; 3581 pkt_dev->entry->data = pkt_dev;
3582#ifdef CONFIG_XFRM 3582#ifdef CONFIG_XFRM
3583 pkt_dev->ipsmode = XFRM_MODE_TRANSPORT; 3583 pkt_dev->ipsmode = XFRM_MODE_TRANSPORT;
@@ -3628,7 +3628,7 @@ static int __init pktgen_create_thread(int cpu)
3628 kthread_bind(p, cpu); 3628 kthread_bind(p, cpu);
3629 t->tsk = p; 3629 t->tsk = p;
3630 3630
3631 pe = create_proc_entry(t->tsk->comm, 0600, pg_proc_dir); 3631 pe = proc_create(t->tsk->comm, 0600, pg_proc_dir, &pktgen_thread_fops);
3632 if (!pe) { 3632 if (!pe) {
3633 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n", 3633 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
3634 PG_PROC_DIR, t->tsk->comm); 3634 PG_PROC_DIR, t->tsk->comm);
@@ -3638,7 +3638,6 @@ static int __init pktgen_create_thread(int cpu)
3638 return -EINVAL; 3638 return -EINVAL;
3639 } 3639 }
3640 3640
3641 pe->proc_fops = &pktgen_thread_fops;
3642 pe->data = t; 3641 pe->data = t;
3643 3642
3644 wake_up_process(p); 3643 wake_up_process(p);
@@ -3709,7 +3708,7 @@ static int __init pg_init(void)
3709 return -ENODEV; 3708 return -ENODEV;
3710 pg_proc_dir->owner = THIS_MODULE; 3709 pg_proc_dir->owner = THIS_MODULE;
3711 3710
3712 pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir); 3711 pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
3713 if (pe == NULL) { 3712 if (pe == NULL) {
3714 printk(KERN_ERR "pktgen: ERROR: cannot create %s " 3713 printk(KERN_ERR "pktgen: ERROR: cannot create %s "
3715 "procfs entry.\n", PGCTRL); 3714 "procfs entry.\n", PGCTRL);
@@ -3717,7 +3716,6 @@ static int __init pg_init(void)
3717 return -EINVAL; 3716 return -EINVAL;
3718 } 3717 }
3719 3718
3720 pe->proc_fops = &pktgen_fops;
3721 pe->data = NULL; 3719 pe->data = NULL;
3722 3720
3723 /* Register us to receive netdevice events */ 3721 /* Register us to receive netdevice events */
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 61ac8d06292c..2bd9c5f7627d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -689,10 +689,12 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
689 [IFLA_BROADCAST] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN }, 689 [IFLA_BROADCAST] = { .type = NLA_BINARY, .len = MAX_ADDR_LEN },
690 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, 690 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
691 [IFLA_MTU] = { .type = NLA_U32 }, 691 [IFLA_MTU] = { .type = NLA_U32 },
692 [IFLA_LINK] = { .type = NLA_U32 },
692 [IFLA_TXQLEN] = { .type = NLA_U32 }, 693 [IFLA_TXQLEN] = { .type = NLA_U32 },
693 [IFLA_WEIGHT] = { .type = NLA_U32 }, 694 [IFLA_WEIGHT] = { .type = NLA_U32 },
694 [IFLA_OPERSTATE] = { .type = NLA_U8 }, 695 [IFLA_OPERSTATE] = { .type = NLA_U8 },
695 [IFLA_LINKMODE] = { .type = NLA_U8 }, 696 [IFLA_LINKMODE] = { .type = NLA_U8 },
697 [IFLA_LINKINFO] = { .type = NLA_NESTED },
696 [IFLA_NET_NS_PID] = { .type = NLA_U32 }, 698 [IFLA_NET_NS_PID] = { .type = NLA_U32 },
697}; 699};
698 700
@@ -720,6 +722,21 @@ static struct net *get_net_ns_by_pid(pid_t pid)
720 return net; 722 return net;
721} 723}
722 724
725static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
726{
727 if (dev) {
728 if (tb[IFLA_ADDRESS] &&
729 nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
730 return -EINVAL;
731
732 if (tb[IFLA_BROADCAST] &&
733 nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
734 return -EINVAL;
735 }
736
737 return 0;
738}
739
723static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, 740static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
724 struct nlattr **tb, char *ifname, int modified) 741 struct nlattr **tb, char *ifname, int modified)
725{ 742{
@@ -892,12 +909,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
892 goto errout; 909 goto errout;
893 } 910 }
894 911
895 if (tb[IFLA_ADDRESS] && 912 if ((err = validate_linkmsg(dev, tb)) < 0)
896 nla_len(tb[IFLA_ADDRESS]) < dev->addr_len)
897 goto errout_dev;
898
899 if (tb[IFLA_BROADCAST] &&
900 nla_len(tb[IFLA_BROADCAST]) < dev->addr_len)
901 goto errout_dev; 913 goto errout_dev;
902 914
903 err = do_setlink(dev, ifm, tb, ifname, 0); 915 err = do_setlink(dev, ifm, tb, ifname, 0);
@@ -1018,6 +1030,9 @@ replay:
1018 else 1030 else
1019 dev = NULL; 1031 dev = NULL;
1020 1032
1033 if ((err = validate_linkmsg(dev, tb)) < 0)
1034 return err;
1035
1021 if (tb[IFLA_LINKINFO]) { 1036 if (tb[IFLA_LINKINFO]) {
1022 err = nla_parse_nested(linkinfo, IFLA_INFO_MAX, 1037 err = nla_parse_nested(linkinfo, IFLA_INFO_MAX,
1023 tb[IFLA_LINKINFO], ifla_info_policy); 1038 tb[IFLA_LINKINFO], ifla_info_policy);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index f282b26f63eb..87490f7bb0f7 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -752,6 +752,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
752 inet_del_ifa(in_dev, ifap, 0); 752 inet_del_ifa(in_dev, ifap, 0);
753 ifa->ifa_broadcast = 0; 753 ifa->ifa_broadcast = 0;
754 ifa->ifa_anycast = 0; 754 ifa->ifa_anycast = 0;
755 ifa->ifa_scope = 0;
755 } 756 }
756 757
757 ifa->ifa_address = ifa->ifa_local = sin->sin_addr.s_addr; 758 ifa->ifa_address = ifa->ifa_local = sin->sin_addr.s_addr;
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 76b9c684cccd..8d58d85dfac6 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -372,7 +372,8 @@ static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key)
372static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg) 372static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
373{ 373{
374 struct fn_hash *table = (struct fn_hash *) tb->tb_data; 374 struct fn_hash *table = (struct fn_hash *) tb->tb_data;
375 struct fib_node *new_f, *f; 375 struct fib_node *new_f = NULL;
376 struct fib_node *f;
376 struct fib_alias *fa, *new_fa; 377 struct fib_alias *fa, *new_fa;
377 struct fn_zone *fz; 378 struct fn_zone *fz;
378 struct fib_info *fi; 379 struct fib_info *fi;
@@ -496,7 +497,6 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
496 497
497 err = -ENOBUFS; 498 err = -ENOBUFS;
498 499
499 new_f = NULL;
500 if (!f) { 500 if (!f) {
501 new_f = kmem_cache_zalloc(fn_hash_kmem, GFP_KERNEL); 501 new_f = kmem_cache_zalloc(fn_hash_kmem, GFP_KERNEL);
502 if (new_f == NULL) 502 if (new_f == NULL)
@@ -512,7 +512,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
512 if (new_fa->fa_info != NULL) { 512 if (new_fa->fa_info != NULL) {
513 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL); 513 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
514 if (new_fa == NULL) 514 if (new_fa == NULL)
515 goto out_free_new_f; 515 goto out;
516 } 516 }
517 new_fa->fa_info = fi; 517 new_fa->fa_info = fi;
518 new_fa->fa_tos = tos; 518 new_fa->fa_tos = tos;
@@ -540,9 +540,9 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
540 &cfg->fc_nlinfo, 0); 540 &cfg->fc_nlinfo, 0);
541 return 0; 541 return 0;
542 542
543out_free_new_f:
544 kmem_cache_free(fn_hash_kmem, new_f);
545out: 543out:
544 if (new_f)
545 kmem_cache_free(fn_hash_kmem, new_f);
546 fib_release_info(fi); 546 fib_release_info(fi);
547 return err; 547 return err;
548} 548}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 63f691719353..e7821ba7a9a0 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -259,35 +259,31 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
259 259
260 if (parms->name[0]) 260 if (parms->name[0])
261 strlcpy(name, parms->name, IFNAMSIZ); 261 strlcpy(name, parms->name, IFNAMSIZ);
262 else { 262 else
263 int i; 263 sprintf(name, "gre%%d");
264 for (i=1; i<100; i++) {
265 sprintf(name, "gre%d", i);
266 if (__dev_get_by_name(&init_net, name) == NULL)
267 break;
268 }
269 if (i==100)
270 goto failed;
271 }
272 264
273 dev = alloc_netdev(sizeof(*t), name, ipgre_tunnel_setup); 265 dev = alloc_netdev(sizeof(*t), name, ipgre_tunnel_setup);
274 if (!dev) 266 if (!dev)
275 return NULL; 267 return NULL;
276 268
269 if (strchr(name, '%')) {
270 if (dev_alloc_name(dev, name) < 0)
271 goto failed_free;
272 }
273
277 dev->init = ipgre_tunnel_init; 274 dev->init = ipgre_tunnel_init;
278 nt = netdev_priv(dev); 275 nt = netdev_priv(dev);
279 nt->parms = *parms; 276 nt->parms = *parms;
280 277
281 if (register_netdevice(dev) < 0) { 278 if (register_netdevice(dev) < 0)
282 free_netdev(dev); 279 goto failed_free;
283 goto failed;
284 }
285 280
286 dev_hold(dev); 281 dev_hold(dev);
287 ipgre_tunnel_link(nt); 282 ipgre_tunnel_link(nt);
288 return nt; 283 return nt;
289 284
290failed: 285failed_free:
286 free_netdev(dev);
291 return NULL; 287 return NULL;
292} 288}
293 289
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index ae1f45fc23b9..58b60b2fb011 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -108,8 +108,11 @@ static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
108 const int cpu = get_cpu(); 108 const int cpu = get_cpu();
109 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); 109 u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
110 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); 110 struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
111 int err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); 111 int err;
112 112
113 local_bh_disable();
114 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
115 local_bh_enable();
113 if (err) 116 if (err)
114 goto out; 117 goto out;
115 118
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index da281581692c..dbaed69de06a 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -221,35 +221,31 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
221 221
222 if (parms->name[0]) 222 if (parms->name[0])
223 strlcpy(name, parms->name, IFNAMSIZ); 223 strlcpy(name, parms->name, IFNAMSIZ);
224 else { 224 else
225 int i; 225 sprintf(name, "tunl%%d");
226 for (i=1; i<100; i++) {
227 sprintf(name, "tunl%d", i);
228 if (__dev_get_by_name(&init_net, name) == NULL)
229 break;
230 }
231 if (i==100)
232 goto failed;
233 }
234 226
235 dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup); 227 dev = alloc_netdev(sizeof(*t), name, ipip_tunnel_setup);
236 if (dev == NULL) 228 if (dev == NULL)
237 return NULL; 229 return NULL;
238 230
231 if (strchr(name, '%')) {
232 if (dev_alloc_name(dev, name) < 0)
233 goto failed_free;
234 }
235
239 nt = netdev_priv(dev); 236 nt = netdev_priv(dev);
240 dev->init = ipip_tunnel_init; 237 dev->init = ipip_tunnel_init;
241 nt->parms = *parms; 238 nt->parms = *parms;
242 239
243 if (register_netdevice(dev) < 0) { 240 if (register_netdevice(dev) < 0)
244 free_netdev(dev); 241 goto failed_free;
245 goto failed;
246 }
247 242
248 dev_hold(dev); 243 dev_hold(dev);
249 ipip_tunnel_link(nt); 244 ipip_tunnel_link(nt);
250 return nt; 245 return nt;
251 246
252failed: 247failed_free:
248 free_netdev(dev);
253 return NULL; 249 return NULL;
254} 250}
255 251
diff --git a/net/ipv4/netfilter/arpt_mangle.c b/net/ipv4/netfilter/arpt_mangle.c
index 45fa4e20094a..3f4222b0a803 100644
--- a/net/ipv4/netfilter/arpt_mangle.c
+++ b/net/ipv4/netfilter/arpt_mangle.c
@@ -19,7 +19,7 @@ target(struct sk_buff *skb,
19 unsigned char *arpptr; 19 unsigned char *arpptr;
20 int pln, hln; 20 int pln, hln;
21 21
22 if (skb_make_writable(skb, skb->len)) 22 if (!skb_make_writable(skb, skb->len))
23 return NF_DROP; 23 return NF_DROP;
24 24
25 arp = arp_hdr(skb); 25 arp = arp_hdr(skb);
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 6bda1102851b..fe05da41d6ba 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -283,8 +283,8 @@ static int
283ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e) 283ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
284{ 284{
285 int diff; 285 int diff;
286 int err;
287 struct iphdr *user_iph = (struct iphdr *)v->payload; 286 struct iphdr *user_iph = (struct iphdr *)v->payload;
287 struct sk_buff *nskb;
288 288
289 if (v->data_len < sizeof(*user_iph)) 289 if (v->data_len < sizeof(*user_iph))
290 return 0; 290 return 0;
@@ -296,14 +296,16 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
296 if (v->data_len > 0xFFFF) 296 if (v->data_len > 0xFFFF)
297 return -EINVAL; 297 return -EINVAL;
298 if (diff > skb_tailroom(e->skb)) { 298 if (diff > skb_tailroom(e->skb)) {
299 err = pskb_expand_head(e->skb, 0, 299 nskb = skb_copy_expand(e->skb, 0,
300 diff - skb_tailroom(e->skb), 300 diff - skb_tailroom(e->skb),
301 GFP_ATOMIC); 301 GFP_ATOMIC);
302 if (err) { 302 if (!nskb) {
303 printk(KERN_WARNING "ip_queue: error " 303 printk(KERN_WARNING "ip_queue: error "
304 "in mangle, dropping packet: %d\n", -err); 304 "in mangle, dropping packet\n");
305 return err; 305 return -ENOMEM;
306 } 306 }
307 kfree_skb(e->skb);
308 e->skb = nskb;
307 } 309 }
308 skb_put(e->skb, diff); 310 skb_put(e->skb, diff);
309 } 311 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 525787b52b72..7b5e8e1d94be 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -542,12 +542,11 @@ static __init int ip_rt_proc_init(struct net *net)
542 if (!pde) 542 if (!pde)
543 goto err1; 543 goto err1;
544 544
545 pde = create_proc_entry("rt_cache", S_IRUGO, net->proc_net_stat); 545 pde = proc_create("rt_cache", S_IRUGO,
546 net->proc_net_stat, &rt_cpu_seq_fops);
546 if (!pde) 547 if (!pde)
547 goto err2; 548 goto err2;
548 549
549 pde->proc_fops = &rt_cpu_seq_fops;
550
551#ifdef CONFIG_NET_CLS_ROUTE 550#ifdef CONFIG_NET_CLS_ROUTE
552 pde = create_proc_read_entry("rt_acct", 0, net->proc_net, 551 pde = create_proc_read_entry("rt_acct", 0, net->proc_net,
553 ip_rt_acct_read, NULL); 552 ip_rt_acct_read, NULL);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e40213db9e4c..101e0e70ba27 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1557,6 +1557,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
1557 .fc_expires = expires, 1557 .fc_expires = expires,
1558 .fc_dst_len = plen, 1558 .fc_dst_len = plen,
1559 .fc_flags = RTF_UP | flags, 1559 .fc_flags = RTF_UP | flags,
1560 .fc_nlinfo.nl_net = &init_net,
1560 }; 1561 };
1561 1562
1562 ipv6_addr_copy(&cfg.fc_dst, pfx); 1563 ipv6_addr_copy(&cfg.fc_dst, pfx);
@@ -1583,6 +1584,7 @@ static void addrconf_add_mroute(struct net_device *dev)
1583 .fc_ifindex = dev->ifindex, 1584 .fc_ifindex = dev->ifindex,
1584 .fc_dst_len = 8, 1585 .fc_dst_len = 8,
1585 .fc_flags = RTF_UP, 1586 .fc_flags = RTF_UP,
1587 .fc_nlinfo.nl_net = &init_net,
1586 }; 1588 };
1587 1589
1588 ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0); 1590 ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0);
@@ -1599,6 +1601,7 @@ static void sit_route_add(struct net_device *dev)
1599 .fc_ifindex = dev->ifindex, 1601 .fc_ifindex = dev->ifindex,
1600 .fc_dst_len = 96, 1602 .fc_dst_len = 96,
1601 .fc_flags = RTF_UP | RTF_NONEXTHOP, 1603 .fc_flags = RTF_UP | RTF_NONEXTHOP,
1604 .fc_nlinfo.nl_net = &init_net,
1602 }; 1605 };
1603 1606
1604 /* prefix length - 96 bits "::d.d.d.d" */ 1607 /* prefix length - 96 bits "::d.d.d.d" */
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index cd940647bd12..78f438880923 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -229,33 +229,33 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
229 char name[IFNAMSIZ]; 229 char name[IFNAMSIZ];
230 int err; 230 int err;
231 231
232 if (p->name[0]) { 232 if (p->name[0])
233 strlcpy(name, p->name, IFNAMSIZ); 233 strlcpy(name, p->name, IFNAMSIZ);
234 } else { 234 else
235 int i; 235 sprintf(name, "ip6tnl%%d");
236 for (i = 1; i < IP6_TNL_MAX; i++) { 236
237 sprintf(name, "ip6tnl%d", i);
238 if (__dev_get_by_name(&init_net, name) == NULL)
239 break;
240 }
241 if (i == IP6_TNL_MAX)
242 goto failed;
243 }
244 dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup); 237 dev = alloc_netdev(sizeof (*t), name, ip6_tnl_dev_setup);
245 if (dev == NULL) 238 if (dev == NULL)
246 goto failed; 239 goto failed;
247 240
241 if (strchr(name, '%')) {
242 if (dev_alloc_name(dev, name) < 0)
243 goto failed_free;
244 }
245
248 t = netdev_priv(dev); 246 t = netdev_priv(dev);
249 dev->init = ip6_tnl_dev_init; 247 dev->init = ip6_tnl_dev_init;
250 t->parms = *p; 248 t->parms = *p;
251 249
252 if ((err = register_netdevice(dev)) < 0) { 250 if ((err = register_netdevice(dev)) < 0)
253 free_netdev(dev); 251 goto failed_free;
254 goto failed; 252
255 }
256 dev_hold(dev); 253 dev_hold(dev);
257 ip6_tnl_link(t); 254 ip6_tnl_link(t);
258 return t; 255 return t;
256
257failed_free:
258 free_netdev(dev);
259failed: 259failed:
260 return NULL; 260 return NULL;
261} 261}
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index b90039593a7f..e3dcfa2f436b 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -146,7 +146,9 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
146 scratch = *per_cpu_ptr(ipcomp6_scratches, cpu); 146 scratch = *per_cpu_ptr(ipcomp6_scratches, cpu);
147 tfm = *per_cpu_ptr(ipcd->tfms, cpu); 147 tfm = *per_cpu_ptr(ipcd->tfms, cpu);
148 148
149 local_bh_disable();
149 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); 150 err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
151 local_bh_enable();
150 if (err || (dlen + sizeof(*ipch)) >= plen) { 152 if (err || (dlen + sizeof(*ipch)) >= plen) {
151 put_cpu(); 153 put_cpu();
152 goto out_ok; 154 goto out_ok;
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index e869916b05f1..cc2f9afcf808 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -285,8 +285,8 @@ static int
285ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct nf_queue_entry *e) 285ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
286{ 286{
287 int diff; 287 int diff;
288 int err;
289 struct ipv6hdr *user_iph = (struct ipv6hdr *)v->payload; 288 struct ipv6hdr *user_iph = (struct ipv6hdr *)v->payload;
289 struct sk_buff *nskb;
290 290
291 if (v->data_len < sizeof(*user_iph)) 291 if (v->data_len < sizeof(*user_iph))
292 return 0; 292 return 0;
@@ -298,14 +298,16 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
298 if (v->data_len > 0xFFFF) 298 if (v->data_len > 0xFFFF)
299 return -EINVAL; 299 return -EINVAL;
300 if (diff > skb_tailroom(e->skb)) { 300 if (diff > skb_tailroom(e->skb)) {
301 err = pskb_expand_head(e->skb, 0, 301 nskb = skb_copy_expand(e->skb, 0,
302 diff - skb_tailroom(e->skb), 302 diff - skb_tailroom(e->skb),
303 GFP_ATOMIC); 303 GFP_ATOMIC);
304 if (err) { 304 if (!nskb) {
305 printk(KERN_WARNING "ip6_queue: OOM " 305 printk(KERN_WARNING "ip6_queue: OOM "
306 "in mangle, dropping packet\n"); 306 "in mangle, dropping packet\n");
307 return err; 307 return -ENOMEM;
308 } 308 }
309 kfree_skb(e->skb);
310 e->skb = nskb;
309 } 311 }
310 skb_put(e->skb, diff); 312 skb_put(e->skb, diff);
311 } 313 }
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 35e502a72495..199ef379e501 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -217,12 +217,12 @@ int snmp6_register_dev(struct inet6_dev *idev)
217 if (!proc_net_devsnmp6) 217 if (!proc_net_devsnmp6)
218 return -ENOENT; 218 return -ENOENT;
219 219
220 p = create_proc_entry(idev->dev->name, S_IRUGO, proc_net_devsnmp6); 220 p = proc_create(idev->dev->name, S_IRUGO,
221 proc_net_devsnmp6, &snmp6_seq_fops);
221 if (!p) 222 if (!p)
222 return -ENOMEM; 223 return -ENOMEM;
223 224
224 p->data = idev; 225 p->data = idev;
225 p->proc_fops = &snmp6_seq_fops;
226 226
227 idev->stats.proc_dir_entry = p; 227 idev->stats.proc_dir_entry = p;
228 return 0; 228 return 0;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6e7b56ef4449..e8b241cb60bc 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1719,6 +1719,8 @@ static void rtmsg_to_fib6_config(struct in6_rtmsg *rtmsg,
1719 cfg->fc_src_len = rtmsg->rtmsg_src_len; 1719 cfg->fc_src_len = rtmsg->rtmsg_src_len;
1720 cfg->fc_flags = rtmsg->rtmsg_flags; 1720 cfg->fc_flags = rtmsg->rtmsg_flags;
1721 1721
1722 cfg->fc_nlinfo.nl_net = &init_net;
1723
1722 ipv6_addr_copy(&cfg->fc_dst, &rtmsg->rtmsg_dst); 1724 ipv6_addr_copy(&cfg->fc_dst, &rtmsg->rtmsg_dst);
1723 ipv6_addr_copy(&cfg->fc_src, &rtmsg->rtmsg_src); 1725 ipv6_addr_copy(&cfg->fc_src, &rtmsg->rtmsg_src);
1724 ipv6_addr_copy(&cfg->fc_gateway, &rtmsg->rtmsg_gateway); 1726 ipv6_addr_copy(&cfg->fc_gateway, &rtmsg->rtmsg_gateway);
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index e77239d02bf5..1656c003b989 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -164,21 +164,18 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
164 164
165 if (parms->name[0]) 165 if (parms->name[0])
166 strlcpy(name, parms->name, IFNAMSIZ); 166 strlcpy(name, parms->name, IFNAMSIZ);
167 else { 167 else
168 int i; 168 sprintf(name, "sit%%d");
169 for (i=1; i<100; i++) {
170 sprintf(name, "sit%d", i);
171 if (__dev_get_by_name(&init_net, name) == NULL)
172 break;
173 }
174 if (i==100)
175 goto failed;
176 }
177 169
178 dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup); 170 dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);
179 if (dev == NULL) 171 if (dev == NULL)
180 return NULL; 172 return NULL;
181 173
174 if (strchr(name, '%')) {
175 if (dev_alloc_name(dev, name) < 0)
176 goto failed_free;
177 }
178
182 nt = netdev_priv(dev); 179 nt = netdev_priv(dev);
183 dev->init = ipip6_tunnel_init; 180 dev->init = ipip6_tunnel_init;
184 nt->parms = *parms; 181 nt->parms = *parms;
@@ -186,16 +183,16 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
186 if (parms->i_flags & SIT_ISATAP) 183 if (parms->i_flags & SIT_ISATAP)
187 dev->priv_flags |= IFF_ISATAP; 184 dev->priv_flags |= IFF_ISATAP;
188 185
189 if (register_netdevice(dev) < 0) { 186 if (register_netdevice(dev) < 0)
190 free_netdev(dev); 187 goto failed_free;
191 goto failed;
192 }
193 188
194 dev_hold(dev); 189 dev_hold(dev);
195 190
196 ipip6_tunnel_link(nt); 191 ipip6_tunnel_link(nt);
197 return nt; 192 return nt;
198 193
194failed_free:
195 free_netdev(dev);
199failed: 196failed:
200 return NULL; 197 return NULL;
201} 198}
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 408691b777c2..d6d3e68086f8 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -102,9 +102,6 @@ static int ipv6_sysctl_net_init(struct net *net)
102 net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path, 102 net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path,
103 ipv6_table); 103 ipv6_table);
104 if (!net->ipv6.sysctl.table) 104 if (!net->ipv6.sysctl.table)
105 return -ENOMEM;
106
107 if (!net->ipv6.sysctl.table)
108 goto out_ipv6_icmp_table; 105 goto out_ipv6_icmp_table;
109 106
110 err = 0; 107 err = 0;
diff --git a/net/ipx/ipx_proc.c b/net/ipx/ipx_proc.c
index d483a00dc427..5ed97ad0e2e3 100644
--- a/net/ipx/ipx_proc.c
+++ b/net/ipx/ipx_proc.c
@@ -358,22 +358,19 @@ int __init ipx_proc_init(void)
358 358
359 if (!ipx_proc_dir) 359 if (!ipx_proc_dir)
360 goto out; 360 goto out;
361 p = create_proc_entry("interface", S_IRUGO, ipx_proc_dir); 361 p = proc_create("interface", S_IRUGO,
362 ipx_proc_dir, &ipx_seq_interface_fops);
362 if (!p) 363 if (!p)
363 goto out_interface; 364 goto out_interface;
364 365
365 p->proc_fops = &ipx_seq_interface_fops; 366 p = proc_create("route", S_IRUGO, ipx_proc_dir, &ipx_seq_route_fops);
366 p = create_proc_entry("route", S_IRUGO, ipx_proc_dir);
367 if (!p) 367 if (!p)
368 goto out_route; 368 goto out_route;
369 369
370 p->proc_fops = &ipx_seq_route_fops; 370 p = proc_create("socket", S_IRUGO, ipx_proc_dir, &ipx_seq_socket_fops);
371 p = create_proc_entry("socket", S_IRUGO, ipx_proc_dir);
372 if (!p) 371 if (!p)
373 goto out_socket; 372 goto out_socket;
374 373
375 p->proc_fops = &ipx_seq_socket_fops;
376
377 rc = 0; 374 rc = 0;
378out: 375out:
379 return rc; 376 return rc;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 1c853927810a..8b5f486ac80f 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3807,17 +3807,16 @@ static int pfkey_init_proc(void)
3807{ 3807{
3808 struct proc_dir_entry *e; 3808 struct proc_dir_entry *e;
3809 3809
3810 e = create_proc_entry("pfkey", 0, init_net.proc_net); 3810 e = proc_net_fops_create(&init_net, "pfkey", 0, &pfkey_proc_ops);
3811 if (e == NULL) 3811 if (e == NULL)
3812 return -ENOMEM; 3812 return -ENOMEM;
3813 3813
3814 e->proc_fops = &pfkey_proc_ops;
3815 return 0; 3814 return 0;
3816} 3815}
3817 3816
3818static void pfkey_exit_proc(void) 3817static void pfkey_exit_proc(void)
3819{ 3818{
3820 remove_proc_entry("net/pfkey", NULL); 3819 proc_net_remove(&init_net, "pfkey");
3821} 3820}
3822#else 3821#else
3823static inline int pfkey_init_proc(void) 3822static inline int pfkey_init_proc(void)
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index cb34bc0518e8..48212c0a961c 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -239,18 +239,14 @@ int __init llc_proc_init(void)
239 goto out; 239 goto out;
240 llc_proc_dir->owner = THIS_MODULE; 240 llc_proc_dir->owner = THIS_MODULE;
241 241
242 p = create_proc_entry("socket", S_IRUGO, llc_proc_dir); 242 p = proc_create("socket", S_IRUGO, llc_proc_dir, &llc_seq_socket_fops);
243 if (!p) 243 if (!p)
244 goto out_socket; 244 goto out_socket;
245 245
246 p->proc_fops = &llc_seq_socket_fops; 246 p = proc_create("core", S_IRUGO, llc_proc_dir, &llc_seq_core_fops);
247
248 p = create_proc_entry("core", S_IRUGO, llc_proc_dir);
249 if (!p) 247 if (!p)
250 goto out_core; 248 goto out_core;
251 249
252 p->proc_fops = &llc_seq_core_fops;
253
254 rc = 0; 250 rc = 0;
255out: 251out:
256 return rc; 252 return rc;
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index 2019b4f0528d..9aeed5320228 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -1116,9 +1116,10 @@ static void ieee80211_sta_process_addba_request(struct net_device *dev,
1116 /* prepare reordering buffer */ 1116 /* prepare reordering buffer */
1117 tid_agg_rx->reorder_buf = 1117 tid_agg_rx->reorder_buf =
1118 kmalloc(buf_size * sizeof(struct sk_buf *), GFP_ATOMIC); 1118 kmalloc(buf_size * sizeof(struct sk_buf *), GFP_ATOMIC);
1119 if ((!tid_agg_rx->reorder_buf) && net_ratelimit()) { 1119 if (!tid_agg_rx->reorder_buf) {
1120 printk(KERN_ERR "can not allocate reordering buffer " 1120 if (net_ratelimit())
1121 "to tid %d\n", tid); 1121 printk(KERN_ERR "can not allocate reordering buffer "
1122 "to tid %d\n", tid);
1122 goto end; 1123 goto end;
1123 } 1124 }
1124 memset(tid_agg_rx->reorder_buf, 0, 1125 memset(tid_agg_rx->reorder_buf, 0,
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 327e847d2702..b77eb56a87e3 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -256,13 +256,19 @@ __nf_conntrack_find(const struct nf_conntrack_tuple *tuple)
256 struct hlist_node *n; 256 struct hlist_node *n;
257 unsigned int hash = hash_conntrack(tuple); 257 unsigned int hash = hash_conntrack(tuple);
258 258
259 /* Disable BHs the entire time since we normally need to disable them
260 * at least once for the stats anyway.
261 */
262 local_bh_disable();
259 hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) { 263 hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) {
260 if (nf_ct_tuple_equal(tuple, &h->tuple)) { 264 if (nf_ct_tuple_equal(tuple, &h->tuple)) {
261 NF_CT_STAT_INC(found); 265 NF_CT_STAT_INC(found);
266 local_bh_enable();
262 return h; 267 return h;
263 } 268 }
264 NF_CT_STAT_INC(searched); 269 NF_CT_STAT_INC(searched);
265 } 270 }
271 local_bh_enable();
266 272
267 return NULL; 273 return NULL;
268} 274}
@@ -400,17 +406,20 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
400 struct hlist_node *n; 406 struct hlist_node *n;
401 unsigned int hash = hash_conntrack(tuple); 407 unsigned int hash = hash_conntrack(tuple);
402 408
403 rcu_read_lock(); 409 /* Disable BHs the entire time since we need to disable them at
410 * least once for the stats anyway.
411 */
412 rcu_read_lock_bh();
404 hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) { 413 hlist_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnode) {
405 if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack && 414 if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack &&
406 nf_ct_tuple_equal(tuple, &h->tuple)) { 415 nf_ct_tuple_equal(tuple, &h->tuple)) {
407 NF_CT_STAT_INC(found); 416 NF_CT_STAT_INC(found);
408 rcu_read_unlock(); 417 rcu_read_unlock_bh();
409 return 1; 418 return 1;
410 } 419 }
411 NF_CT_STAT_INC(searched); 420 NF_CT_STAT_INC(searched);
412 } 421 }
413 rcu_read_unlock(); 422 rcu_read_unlock_bh();
414 423
415 return 0; 424 return 0;
416} 425}
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index a48b20fe9cd6..0043d3a9f87e 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -443,8 +443,8 @@ err_out:
443static int 443static int
444nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e) 444nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e)
445{ 445{
446 struct sk_buff *nskb;
446 int diff; 447 int diff;
447 int err;
448 448
449 diff = data_len - e->skb->len; 449 diff = data_len - e->skb->len;
450 if (diff < 0) { 450 if (diff < 0) {
@@ -454,14 +454,16 @@ nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e)
454 if (data_len > 0xFFFF) 454 if (data_len > 0xFFFF)
455 return -EINVAL; 455 return -EINVAL;
456 if (diff > skb_tailroom(e->skb)) { 456 if (diff > skb_tailroom(e->skb)) {
457 err = pskb_expand_head(e->skb, 0, 457 nskb = skb_copy_expand(e->skb, 0,
458 diff - skb_tailroom(e->skb), 458 diff - skb_tailroom(e->skb),
459 GFP_ATOMIC); 459 GFP_ATOMIC);
460 if (err) { 460 if (!nskb) {
461 printk(KERN_WARNING "nf_queue: OOM " 461 printk(KERN_WARNING "nf_queue: OOM "
462 "in mangle, dropping packet\n"); 462 "in mangle, dropping packet\n");
463 return err; 463 return -ENOMEM;
464 } 464 }
465 kfree_skb(e->skb);
466 e->skb = nskb;
465 } 467 }
466 skb_put(e->skb, diff); 468 skb_put(e->skb, diff);
467 } 469 }
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 85330856a29c..0c50b2894055 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -122,7 +122,7 @@ conntrack_addrcmp(const union nf_inet_addr *kaddr,
122 const union nf_inet_addr *umask, unsigned int l3proto) 122 const union nf_inet_addr *umask, unsigned int l3proto)
123{ 123{
124 if (l3proto == AF_INET) 124 if (l3proto == AF_INET)
125 return (kaddr->ip & umask->ip) == uaddr->ip; 125 return ((kaddr->ip ^ uaddr->ip) & umask->ip) == 0;
126 else if (l3proto == AF_INET6) 126 else if (l3proto == AF_INET6)
127 return ipv6_masked_addr_cmp(&kaddr->in6, &umask->in6, 127 return ipv6_masked_addr_cmp(&kaddr->in6, &umask->in6,
128 &uaddr->in6) == 0; 128 &uaddr->in6) == 0;
@@ -231,7 +231,7 @@ conntrack_mt(const struct sk_buff *skb, const struct net_device *in,
231 if (test_bit(IPS_DST_NAT_BIT, &ct->status)) 231 if (test_bit(IPS_DST_NAT_BIT, &ct->status))
232 statebit |= XT_CONNTRACK_STATE_DNAT; 232 statebit |= XT_CONNTRACK_STATE_DNAT;
233 } 233 }
234 if ((info->state_mask & statebit) ^ 234 if (!!(info->state_mask & statebit) ^
235 !(info->invert_flags & XT_CONNTRACK_STATE)) 235 !(info->invert_flags & XT_CONNTRACK_STATE))
236 return false; 236 return false;
237 } 237 }
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 744c7f2ab0b1..5418ce59ac3a 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -774,9 +774,6 @@ hashlimit_mt_check(const char *tablename, const void *inf,
774 return false; 774 return false;
775 } 775 }
776 mutex_unlock(&hlimit_mutex); 776 mutex_unlock(&hlimit_mutex);
777
778 /* Ugly hack: For SMP, we only want to use one set */
779 info->master = info;
780 return true; 777 return true;
781} 778}
782 779
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c
index 4f984dc60319..500528d60cd7 100644
--- a/net/netfilter/xt_iprange.c
+++ b/net/netfilter/xt_iprange.c
@@ -102,7 +102,7 @@ iprange_ipv6_sub(const struct in6_addr *a, const struct in6_addr *b)
102 int r; 102 int r;
103 103
104 for (i = 0; i < 4; ++i) { 104 for (i = 0; i < 4; ++i) {
105 r = (__force u32)a->s6_addr32[i] - (__force u32)b->s6_addr32[i]; 105 r = ntohl(a->s6_addr32[i]) - ntohl(b->s6_addr32[i]);
106 if (r != 0) 106 if (r != 0)
107 return r; 107 return r;
108 } 108 }
diff --git a/net/netfilter/xt_u32.c b/net/netfilter/xt_u32.c
index 9b8ed390a8e0..627e0f336d54 100644
--- a/net/netfilter/xt_u32.c
+++ b/net/netfilter/xt_u32.c
@@ -26,7 +26,6 @@ static bool u32_match_it(const struct xt_u32 *data,
26 u_int32_t pos; 26 u_int32_t pos;
27 u_int32_t val; 27 u_int32_t val;
28 u_int32_t at; 28 u_int32_t at;
29 int ret;
30 29
31 /* 30 /*
32 * Small example: "0 >> 28 == 4 && 8 & 0xFF0000 >> 16 = 6, 17" 31 * Small example: "0 >> 28 == 4 && 8 & 0xFF0000 >> 16 = 6, 17"
@@ -40,8 +39,8 @@ static bool u32_match_it(const struct xt_u32 *data,
40 if (skb->len < 4 || pos > skb->len - 4) 39 if (skb->len < 4 || pos > skb->len - 4)
41 return false; 40 return false;
42 41
43 ret = skb_copy_bits(skb, pos, &n, sizeof(n)); 42 if (skb_copy_bits(skb, pos, &n, sizeof(n)) < 0)
44 BUG_ON(ret < 0); 43 BUG();
45 val = ntohl(n); 44 val = ntohl(n);
46 nnums = ct->nnums; 45 nnums = ct->nnums;
47 46
@@ -67,9 +66,9 @@ static bool u32_match_it(const struct xt_u32 *data,
67 pos > skb->len - at - 4) 66 pos > skb->len - at - 4)
68 return false; 67 return false;
69 68
70 ret = skb_copy_bits(skb, at + pos, &n, 69 if (skb_copy_bits(skb, at + pos, &n,
71 sizeof(n)); 70 sizeof(n)) < 0)
72 BUG_ON(ret < 0); 71 BUG();
73 val = ntohl(n); 72 val = ntohl(n);
74 break; 73 break;
75 } 74 }
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 8bb79f281774..675a5c3e68a6 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -838,11 +838,11 @@ int sctp_auth_set_key(struct sctp_endpoint *ep,
838 } 838 }
839 839
840 /* Create a new key data based on the info passed in */ 840 /* Create a new key data based on the info passed in */
841 key = sctp_auth_create_key(auth_key->sca_keylen, GFP_KERNEL); 841 key = sctp_auth_create_key(auth_key->sca_keylength, GFP_KERNEL);
842 if (!key) 842 if (!key)
843 goto nomem; 843 goto nomem;
844 844
845 memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylen); 845 memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylength);
846 846
847 /* If we are replacing, remove the old keys data from the 847 /* If we are replacing, remove the old keys data from the
848 * key id. If we are adding new key id, add it to the 848 * key id. If we are adding new key id, add it to the
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 4d7ec961ae1d..87f940587d5f 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -966,7 +966,7 @@ static struct inet6_protocol sctpv6_protocol = {
966 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 966 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
967}; 967};
968 968
969static struct sctp_af sctp_ipv6_specific = { 969static struct sctp_af sctp_af_inet6 = {
970 .sa_family = AF_INET6, 970 .sa_family = AF_INET6,
971 .sctp_xmit = sctp_v6_xmit, 971 .sctp_xmit = sctp_v6_xmit,
972 .setsockopt = ipv6_setsockopt, 972 .setsockopt = ipv6_setsockopt,
@@ -998,7 +998,7 @@ static struct sctp_af sctp_ipv6_specific = {
998#endif 998#endif
999}; 999};
1000 1000
1001static struct sctp_pf sctp_pf_inet6_specific = { 1001static struct sctp_pf sctp_pf_inet6 = {
1002 .event_msgname = sctp_inet6_event_msgname, 1002 .event_msgname = sctp_inet6_event_msgname,
1003 .skb_msgname = sctp_inet6_skb_msgname, 1003 .skb_msgname = sctp_inet6_skb_msgname,
1004 .af_supported = sctp_inet6_af_supported, 1004 .af_supported = sctp_inet6_af_supported,
@@ -1008,7 +1008,7 @@ static struct sctp_pf sctp_pf_inet6_specific = {
1008 .supported_addrs = sctp_inet6_supported_addrs, 1008 .supported_addrs = sctp_inet6_supported_addrs,
1009 .create_accept_sk = sctp_v6_create_accept_sk, 1009 .create_accept_sk = sctp_v6_create_accept_sk,
1010 .addr_v4map = sctp_v6_addr_v4map, 1010 .addr_v4map = sctp_v6_addr_v4map,
1011 .af = &sctp_ipv6_specific, 1011 .af = &sctp_af_inet6,
1012}; 1012};
1013 1013
1014/* Initialize IPv6 support and register with socket layer. */ 1014/* Initialize IPv6 support and register with socket layer. */
@@ -1017,10 +1017,10 @@ int sctp_v6_init(void)
1017 int rc; 1017 int rc;
1018 1018
1019 /* Register the SCTP specific PF_INET6 functions. */ 1019 /* Register the SCTP specific PF_INET6 functions. */
1020 sctp_register_pf(&sctp_pf_inet6_specific, PF_INET6); 1020 sctp_register_pf(&sctp_pf_inet6, PF_INET6);
1021 1021
1022 /* Register the SCTP specific AF_INET6 functions. */ 1022 /* Register the SCTP specific AF_INET6 functions. */
1023 sctp_register_af(&sctp_ipv6_specific); 1023 sctp_register_af(&sctp_af_inet6);
1024 1024
1025 rc = proto_register(&sctpv6_prot, 1); 1025 rc = proto_register(&sctpv6_prot, 1);
1026 if (rc) 1026 if (rc)
@@ -1051,7 +1051,7 @@ void sctp_v6_exit(void)
1051 inet6_unregister_protosw(&sctpv6_seqpacket_protosw); 1051 inet6_unregister_protosw(&sctpv6_seqpacket_protosw);
1052 inet6_unregister_protosw(&sctpv6_stream_protosw); 1052 inet6_unregister_protosw(&sctpv6_stream_protosw);
1053 proto_unregister(&sctpv6_prot); 1053 proto_unregister(&sctpv6_prot);
1054 list_del(&sctp_ipv6_specific.list); 1054 list_del(&sctp_af_inet6.list);
1055} 1055}
1056 1056
1057/* Unregister with inet6 layer. */ 1057/* Unregister with inet6 layer. */
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c
index 14e294e37626..cfeb07ea1b04 100644
--- a/net/sctp/objcnt.c
+++ b/net/sctp/objcnt.c
@@ -132,12 +132,11 @@ void sctp_dbg_objcnt_init(void)
132{ 132{
133 struct proc_dir_entry *ent; 133 struct proc_dir_entry *ent;
134 134
135 ent = create_proc_entry("sctp_dbg_objcnt", 0, proc_net_sctp); 135 ent = proc_create("sctp_dbg_objcnt", 0,
136 proc_net_sctp, &sctp_objcnt_ops);
136 if (!ent) 137 if (!ent)
137 printk(KERN_WARNING 138 printk(KERN_WARNING
138 "sctp_dbg_objcnt: Unable to create /proc entry.\n"); 139 "sctp_dbg_objcnt: Unable to create /proc entry.\n");
139 else
140 ent->proc_fops = &sctp_objcnt_ops;
141} 140}
142 141
143/* Cleanup the objcount entry in the proc filesystem. */ 142/* Cleanup the objcount entry in the proc filesystem. */
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 69bb5a63fd8b..9e214da82d9e 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -108,12 +108,10 @@ int __init sctp_snmp_proc_init(void)
108{ 108{
109 struct proc_dir_entry *p; 109 struct proc_dir_entry *p;
110 110
111 p = create_proc_entry("snmp", S_IRUGO, proc_net_sctp); 111 p = proc_create("snmp", S_IRUGO, proc_net_sctp, &sctp_snmp_seq_fops);
112 if (!p) 112 if (!p)
113 return -ENOMEM; 113 return -ENOMEM;
114 114
115 p->proc_fops = &sctp_snmp_seq_fops;
116
117 return 0; 115 return 0;
118} 116}
119 117
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 22a16571499c..688546dccd82 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -832,7 +832,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
832 return ip_queue_xmit(skb, ipfragok); 832 return ip_queue_xmit(skb, ipfragok);
833} 833}
834 834
835static struct sctp_af sctp_ipv4_specific; 835static struct sctp_af sctp_af_inet;
836 836
837static struct sctp_pf sctp_pf_inet = { 837static struct sctp_pf sctp_pf_inet = {
838 .event_msgname = sctp_inet_event_msgname, 838 .event_msgname = sctp_inet_event_msgname,
@@ -844,7 +844,7 @@ static struct sctp_pf sctp_pf_inet = {
844 .supported_addrs = sctp_inet_supported_addrs, 844 .supported_addrs = sctp_inet_supported_addrs,
845 .create_accept_sk = sctp_v4_create_accept_sk, 845 .create_accept_sk = sctp_v4_create_accept_sk,
846 .addr_v4map = sctp_v4_addr_v4map, 846 .addr_v4map = sctp_v4_addr_v4map,
847 .af = &sctp_ipv4_specific, 847 .af = &sctp_af_inet
848}; 848};
849 849
850/* Notifier for inetaddr addition/deletion events. */ 850/* Notifier for inetaddr addition/deletion events. */
@@ -906,7 +906,7 @@ static struct net_protocol sctp_protocol = {
906}; 906};
907 907
908/* IPv4 address related functions. */ 908/* IPv4 address related functions. */
909static struct sctp_af sctp_ipv4_specific = { 909static struct sctp_af sctp_af_inet = {
910 .sa_family = AF_INET, 910 .sa_family = AF_INET,
911 .sctp_xmit = sctp_v4_xmit, 911 .sctp_xmit = sctp_v4_xmit,
912 .setsockopt = ip_setsockopt, 912 .setsockopt = ip_setsockopt,
@@ -1192,7 +1192,7 @@ SCTP_STATIC __init int sctp_init(void)
1192 sctp_sysctl_register(); 1192 sctp_sysctl_register();
1193 1193
1194 INIT_LIST_HEAD(&sctp_address_families); 1194 INIT_LIST_HEAD(&sctp_address_families);
1195 sctp_register_af(&sctp_ipv4_specific); 1195 sctp_register_af(&sctp_af_inet);
1196 1196
1197 status = proto_register(&sctp_prot, 1); 1197 status = proto_register(&sctp_prot, 1);
1198 if (status) 1198 if (status)
@@ -1249,7 +1249,7 @@ err_v6_init:
1249 proto_unregister(&sctp_prot); 1249 proto_unregister(&sctp_prot);
1250err_proto_register: 1250err_proto_register:
1251 sctp_sysctl_unregister(); 1251 sctp_sysctl_unregister();
1252 list_del(&sctp_ipv4_specific.list); 1252 list_del(&sctp_af_inet.list);
1253 free_pages((unsigned long)sctp_port_hashtable, 1253 free_pages((unsigned long)sctp_port_hashtable,
1254 get_order(sctp_port_hashsize * 1254 get_order(sctp_port_hashsize *
1255 sizeof(struct sctp_bind_hashbucket))); 1255 sizeof(struct sctp_bind_hashbucket)));
@@ -1299,7 +1299,7 @@ SCTP_STATIC __exit void sctp_exit(void)
1299 inet_unregister_protosw(&sctp_seqpacket_protosw); 1299 inet_unregister_protosw(&sctp_seqpacket_protosw);
1300 1300
1301 sctp_sysctl_unregister(); 1301 sctp_sysctl_unregister();
1302 list_del(&sctp_ipv4_specific.list); 1302 list_del(&sctp_af_inet.list);
1303 1303
1304 free_pages((unsigned long)sctp_assoc_hashtable, 1304 free_pages((unsigned long)sctp_assoc_hashtable,
1305 get_order(sctp_assoc_hashsize * 1305 get_order(sctp_assoc_hashsize *
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d47d5787e2e5..939892691a26 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1964,7 +1964,7 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk,
1964static int sctp_setsockopt_events(struct sock *sk, char __user *optval, 1964static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
1965 int optlen) 1965 int optlen)
1966{ 1966{
1967 if (optlen != sizeof(struct sctp_event_subscribe)) 1967 if (optlen > sizeof(struct sctp_event_subscribe))
1968 return -EINVAL; 1968 return -EINVAL;
1969 if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen)) 1969 if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
1970 return -EFAULT; 1970 return -EFAULT;
@@ -5070,6 +5070,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
5070 struct sctp_authchunks val; 5070 struct sctp_authchunks val;
5071 struct sctp_association *asoc; 5071 struct sctp_association *asoc;
5072 struct sctp_chunks_param *ch; 5072 struct sctp_chunks_param *ch;
5073 u32 num_chunks;
5073 char __user *to; 5074 char __user *to;
5074 5075
5075 if (len <= sizeof(struct sctp_authchunks)) 5076 if (len <= sizeof(struct sctp_authchunks))
@@ -5086,12 +5087,15 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
5086 ch = asoc->peer.peer_chunks; 5087 ch = asoc->peer.peer_chunks;
5087 5088
5088 /* See if the user provided enough room for all the data */ 5089 /* See if the user provided enough room for all the data */
5089 if (len < ntohs(ch->param_hdr.length)) 5090 num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
5091 if (len < num_chunks)
5090 return -EINVAL; 5092 return -EINVAL;
5091 5093
5092 len = ntohs(ch->param_hdr.length); 5094 len = num_chunks;
5093 if (put_user(len, optlen)) 5095 if (put_user(len, optlen))
5094 return -EFAULT; 5096 return -EFAULT;
5097 if (put_user(num_chunks, &p->gauth_number_of_chunks))
5098 return -EFAULT;
5095 if (copy_to_user(to, ch->chunks, len)) 5099 if (copy_to_user(to, ch->chunks, len))
5096 return -EFAULT; 5100 return -EFAULT;
5097 5101
@@ -5105,6 +5109,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
5105 struct sctp_authchunks val; 5109 struct sctp_authchunks val;
5106 struct sctp_association *asoc; 5110 struct sctp_association *asoc;
5107 struct sctp_chunks_param *ch; 5111 struct sctp_chunks_param *ch;
5112 u32 num_chunks;
5108 char __user *to; 5113 char __user *to;
5109 5114
5110 if (len <= sizeof(struct sctp_authchunks)) 5115 if (len <= sizeof(struct sctp_authchunks))
@@ -5123,12 +5128,15 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
5123 else 5128 else
5124 ch = sctp_sk(sk)->ep->auth_chunk_list; 5129 ch = sctp_sk(sk)->ep->auth_chunk_list;
5125 5130
5126 if (len < ntohs(ch->param_hdr.length)) 5131 num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t);
5132 if (len < num_chunks)
5127 return -EINVAL; 5133 return -EINVAL;
5128 5134
5129 len = ntohs(ch->param_hdr.length); 5135 len = num_chunks;
5130 if (put_user(len, optlen)) 5136 if (put_user(len, optlen))
5131 return -EFAULT; 5137 return -EFAULT;
5138 if (put_user(num_chunks, &p->gauth_number_of_chunks))
5139 return -EFAULT;
5132 if (copy_to_user(to, ch->chunks, len)) 5140 if (copy_to_user(to, ch->chunks, len))
5133 return -EFAULT; 5141 return -EFAULT;
5134 5142
@@ -6488,6 +6496,7 @@ struct proto sctp_prot = {
6488 .memory_pressure = &sctp_memory_pressure, 6496 .memory_pressure = &sctp_memory_pressure,
6489 .enter_memory_pressure = sctp_enter_memory_pressure, 6497 .enter_memory_pressure = sctp_enter_memory_pressure,
6490 .memory_allocated = &sctp_memory_allocated, 6498 .memory_allocated = &sctp_memory_allocated,
6499 .sockets_allocated = &sctp_sockets_allocated,
6491 REF_PROTO_INUSE(sctp) 6500 REF_PROTO_INUSE(sctp)
6492}; 6501};
6493 6502
@@ -6521,6 +6530,7 @@ struct proto sctpv6_prot = {
6521 .memory_pressure = &sctp_memory_pressure, 6530 .memory_pressure = &sctp_memory_pressure,
6522 .enter_memory_pressure = sctp_enter_memory_pressure, 6531 .enter_memory_pressure = sctp_enter_memory_pressure,
6523 .memory_allocated = &sctp_memory_allocated, 6532 .memory_allocated = &sctp_memory_allocated,
6533 .sockets_allocated = &sctp_sockets_allocated,
6524 REF_PROTO_INUSE(sctpv6) 6534 REF_PROTO_INUSE(sctpv6)
6525}; 6535};
6526#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 6536#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index e27b11f18b7f..b43f1f110f87 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -206,7 +206,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
206 * This field is the total length of the notification data, including 206 * This field is the total length of the notification data, including
207 * the notification header. 207 * the notification header.
208 */ 208 */
209 sac->sac_length = sizeof(struct sctp_assoc_change); 209 sac->sac_length = skb->len;
210 210
211 /* Socket Extensions for SCTP 211 /* Socket Extensions for SCTP
212 * 5.3.1.1 SCTP_ASSOC_CHANGE 212 * 5.3.1.1 SCTP_ASSOC_CHANGE
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 636c8e04e0be..b5f2786251b9 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -316,31 +316,29 @@ static int create_cache_proc_entries(struct cache_detail *cd)
316 cd->proc_ent->owner = cd->owner; 316 cd->proc_ent->owner = cd->owner;
317 cd->channel_ent = cd->content_ent = NULL; 317 cd->channel_ent = cd->content_ent = NULL;
318 318
319 p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent); 319 p = proc_create("flush", S_IFREG|S_IRUSR|S_IWUSR,
320 cd->proc_ent, &cache_flush_operations);
320 cd->flush_ent = p; 321 cd->flush_ent = p;
321 if (p == NULL) 322 if (p == NULL)
322 goto out_nomem; 323 goto out_nomem;
323 p->proc_fops = &cache_flush_operations;
324 p->owner = cd->owner; 324 p->owner = cd->owner;
325 p->data = cd; 325 p->data = cd;
326 326
327 if (cd->cache_request || cd->cache_parse) { 327 if (cd->cache_request || cd->cache_parse) {
328 p = create_proc_entry("channel", S_IFREG|S_IRUSR|S_IWUSR, 328 p = proc_create("channel", S_IFREG|S_IRUSR|S_IWUSR,
329 cd->proc_ent); 329 cd->proc_ent, &cache_file_operations);
330 cd->channel_ent = p; 330 cd->channel_ent = p;
331 if (p == NULL) 331 if (p == NULL)
332 goto out_nomem; 332 goto out_nomem;
333 p->proc_fops = &cache_file_operations;
334 p->owner = cd->owner; 333 p->owner = cd->owner;
335 p->data = cd; 334 p->data = cd;
336 } 335 }
337 if (cd->cache_show) { 336 if (cd->cache_show) {
338 p = create_proc_entry("content", S_IFREG|S_IRUSR|S_IWUSR, 337 p = proc_create("content", S_IFREG|S_IRUSR|S_IWUSR,
339 cd->proc_ent); 338 cd->proc_ent, &content_file_operations);
340 cd->content_ent = p; 339 cd->content_ent = p;
341 if (p == NULL) 340 if (p == NULL)
342 goto out_nomem; 341 goto out_nomem;
343 p->proc_fops = &content_file_operations;
344 p->owner = cd->owner; 342 p->owner = cd->owner;
345 p->data = cd; 343 p->data = cd;
346 } 344 }
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c
index 5a16875f5ac8..c6061a4346c8 100644
--- a/net/sunrpc/stats.c
+++ b/net/sunrpc/stats.c
@@ -229,9 +229,8 @@ do_register(const char *name, void *data, const struct file_operations *fops)
229 rpc_proc_init(); 229 rpc_proc_init();
230 dprintk("RPC: registering /proc/net/rpc/%s\n", name); 230 dprintk("RPC: registering /proc/net/rpc/%s\n", name);
231 231
232 ent = create_proc_entry(name, 0, proc_net_rpc); 232 ent = proc_create(name, 0, proc_net_rpc, fops);
233 if (ent) { 233 if (ent) {
234 ent->proc_fops = fops;
235 ent->data = data; 234 ent->data = data;
236 } 235 }
237 return ent; 236 return ent;
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c
index 95b373913aa0..4bb3404f610b 100644
--- a/net/tipc/cluster.c
+++ b/net/tipc/cluster.c
@@ -142,7 +142,7 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr)
142 max_n_num = tipc_highest_allowed_slave; 142 max_n_num = tipc_highest_allowed_slave;
143 assert(n_num > 0); 143 assert(n_num > 0);
144 assert(n_num <= max_n_num); 144 assert(n_num <= max_n_num);
145 assert(c_ptr->nodes[n_num] == 0); 145 assert(c_ptr->nodes[n_num] == NULL);
146 c_ptr->nodes[n_num] = n_ptr; 146 c_ptr->nodes[n_num] = n_ptr;
147 if (n_num > c_ptr->highest_node) 147 if (n_num > c_ptr->highest_node)
148 c_ptr->highest_node = n_num; 148 c_ptr->highest_node = n_num;
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 1b17fecee747..cefa99824c58 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -3251,7 +3251,7 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
3251 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - 3251 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
3252 msg_seqno(buf_msg(l_ptr->first_out))) 3252 msg_seqno(buf_msg(l_ptr->first_out)))
3253 != (l_ptr->out_queue_size - 1)) 3253 != (l_ptr->out_queue_size - 1))
3254 || (l_ptr->last_out->next != 0)) { 3254 || (l_ptr->last_out->next != NULL)) {
3255 tipc_printf(buf, "\nSend queue inconsistency\n"); 3255 tipc_printf(buf, "\nSend queue inconsistency\n");
3256 tipc_printf(buf, "first_out= %x ", l_ptr->first_out); 3256 tipc_printf(buf, "first_out= %x ", l_ptr->first_out);
3257 tipc_printf(buf, "next_out= %x ", l_ptr->next_out); 3257 tipc_printf(buf, "next_out= %x ", l_ptr->next_out);
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index 6704a58c7851..c38744c96ed1 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -148,7 +148,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
148 reference = (next_plus_upper & ~index_mask) + index; 148 reference = (next_plus_upper & ~index_mask) + index;
149 entry->data.reference = reference; 149 entry->data.reference = reference;
150 entry->object = object; 150 entry->object = object;
151 if (lock != 0) 151 if (lock != NULL)
152 *lock = &entry->lock; 152 *lock = &entry->lock;
153 spin_unlock_bh(&entry->lock); 153 spin_unlock_bh(&entry->lock);
154 } 154 }
diff --git a/net/tipc/zone.c b/net/tipc/zone.c
index 114e173f11a5..3506f8563441 100644
--- a/net/tipc/zone.c
+++ b/net/tipc/zone.c
@@ -82,7 +82,7 @@ void tipc_zone_attach_cluster(struct _zone *z_ptr, struct cluster *c_ptr)
82 82
83 assert(c_ptr->addr); 83 assert(c_ptr->addr);
84 assert(c_num <= tipc_max_clusters); 84 assert(c_num <= tipc_max_clusters);
85 assert(z_ptr->clusters[c_num] == 0); 85 assert(z_ptr->clusters[c_num] == NULL);
86 z_ptr->clusters[c_num] = c_ptr; 86 z_ptr->clusters[c_num] = c_ptr;
87} 87}
88 88
diff --git a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c
index f2e54c3f064e..5bebe40bf4e6 100644
--- a/net/wanrouter/wanproc.c
+++ b/net/wanrouter/wanproc.c
@@ -292,14 +292,12 @@ int __init wanrouter_proc_init(void)
292 if (!proc_router) 292 if (!proc_router)
293 goto fail; 293 goto fail;
294 294
295 p = create_proc_entry("config", S_IRUGO, proc_router); 295 p = proc_create("config", S_IRUGO, proc_router, &config_fops);
296 if (!p) 296 if (!p)
297 goto fail_config; 297 goto fail_config;
298 p->proc_fops = &config_fops; 298 p = proc_create("status", S_IRUGO, proc_router, &status_fops);
299 p = create_proc_entry("status", S_IRUGO, proc_router);
300 if (!p) 299 if (!p)
301 goto fail_stat; 300 goto fail_stat;
302 p->proc_fops = &status_fops;
303 return 0; 301 return 0;
304fail_stat: 302fail_stat:
305 remove_proc_entry("config", proc_router); 303 remove_proc_entry("config", proc_router);
@@ -329,10 +327,10 @@ int wanrouter_proc_add(struct wan_device* wandev)
329 if (wandev->magic != ROUTER_MAGIC) 327 if (wandev->magic != ROUTER_MAGIC)
330 return -EINVAL; 328 return -EINVAL;
331 329
332 wandev->dent = create_proc_entry(wandev->name, S_IRUGO, proc_router); 330 wandev->dent = proc_create(wandev->name, S_IRUGO,
331 proc_router, &wandev_fops);
333 if (!wandev->dent) 332 if (!wandev->dent)
334 return -ENOMEM; 333 return -ENOMEM;
335 wandev->dent->proc_fops = &wandev_fops;
336 wandev->dent->data = wandev; 334 wandev->dent->data = wandev;
337 return 0; 335 return 0;
338} 336}
diff --git a/net/x25/x25_proc.c b/net/x25/x25_proc.c
index 3f52b09bed03..1afa44d25beb 100644
--- a/net/x25/x25_proc.c
+++ b/net/x25/x25_proc.c
@@ -312,20 +312,18 @@ int __init x25_proc_init(void)
312 if (!x25_proc_dir) 312 if (!x25_proc_dir)
313 goto out; 313 goto out;
314 314
315 p = create_proc_entry("route", S_IRUGO, x25_proc_dir); 315 p = proc_create("route", S_IRUGO, x25_proc_dir, &x25_seq_route_fops);
316 if (!p) 316 if (!p)
317 goto out_route; 317 goto out_route;
318 p->proc_fops = &x25_seq_route_fops;
319 318
320 p = create_proc_entry("socket", S_IRUGO, x25_proc_dir); 319 p = proc_create("socket", S_IRUGO, x25_proc_dir, &x25_seq_socket_fops);
321 if (!p) 320 if (!p)
322 goto out_socket; 321 goto out_socket;
323 p->proc_fops = &x25_seq_socket_fops;
324 322
325 p = create_proc_entry("forward", S_IRUGO, x25_proc_dir); 323 p = proc_create("forward", S_IRUGO, x25_proc_dir,
324 &x25_seq_forward_fops);
326 if (!p) 325 if (!p)
327 goto out_forward; 326 goto out_forward;
328 p->proc_fops = &x25_seq_forward_fops;
329 rc = 0; 327 rc = 0;
330 328
331out: 329out:
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c
index 6304c3a89ba0..fe03bb820532 100644
--- a/sound/isa/sb/sb8_main.c
+++ b/sound/isa/sb/sb8_main.c
@@ -277,7 +277,7 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream)
277 } else { 277 } else {
278 snd_sbdsp_command(chip, 256 - runtime->rate_den); 278 snd_sbdsp_command(chip, 256 - runtime->rate_den);
279 } 279 }
280 if (chip->capture_format != SB_DSP_OUTPUT) { 280 if (chip->capture_format != SB_DSP_INPUT) {
281 count--; 281 count--;
282 snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); 282 snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE);
283 snd_sbdsp_command(chip, count & 0xff); 283 snd_sbdsp_command(chip, count & 0xff);
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 19f08846d6fc..c8649282c2cf 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1778,9 +1778,9 @@ static hda_nid_t ad1988_capsrc_nids[3] = {
1778static struct hda_input_mux ad1988_6stack_capture_source = { 1778static struct hda_input_mux ad1988_6stack_capture_source = {
1779 .num_items = 5, 1779 .num_items = 5,
1780 .items = { 1780 .items = {
1781 { "Front Mic", 0x0 }, 1781 { "Front Mic", 0x1 }, /* port-B */
1782 { "Line", 0x1 }, 1782 { "Line", 0x2 }, /* port-C */
1783 { "Mic", 0x4 }, 1783 { "Mic", 0x4 }, /* port-E */
1784 { "CD", 0x5 }, 1784 { "CD", 0x5 },
1785 { "Mix", 0x9 }, 1785 { "Mix", 0x9 },
1786 }, 1786 },
@@ -1789,7 +1789,7 @@ static struct hda_input_mux ad1988_6stack_capture_source = {
1789static struct hda_input_mux ad1988_laptop_capture_source = { 1789static struct hda_input_mux ad1988_laptop_capture_source = {
1790 .num_items = 3, 1790 .num_items = 3,
1791 .items = { 1791 .items = {
1792 { "Mic/Line", 0x0 }, 1792 { "Mic/Line", 0x1 }, /* port-B */
1793 { "CD", 0x5 }, 1793 { "CD", 0x5 },
1794 { "Mix", 0x9 }, 1794 { "Mix", 0x9 },
1795 }, 1795 },
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index f7cd3a804b11..7206b30cbf94 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -1230,6 +1230,11 @@ static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1230static struct hda_verb cxt5047_hp_init_verbs[] = { 1230static struct hda_verb cxt5047_hp_init_verbs[] = {
1231 /* pin sensing on HP jack */ 1231 /* pin sensing on HP jack */
1232 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 1232 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1233 /* 0x13 is actually shared by both HP and speaker;
1234 * setting the connection to 0 (=0x19) makes the master volume control
1235 * working mysteriouslly...
1236 */
1237 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1233 /* Record selector: Ext Mic */ 1238 /* Record selector: Ext Mic */
1234 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1239 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1235 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1240 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 777f8c01ca7a..33282f9c01c7 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3973,8 +3973,8 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3973 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 3973 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3974 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 3974 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3975 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 3975 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3976 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 3976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3977 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), 3977 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3978 { } /* end */ 3978 { } /* end */
3979}; 3979};
3980 3980
@@ -4005,9 +4005,9 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
4005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), 4005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), 4006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4007 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), 4007 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4008 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0, 4008 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4009 HDA_OUTPUT), 4009 HDA_OUTPUT),
4010 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2, 4010 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4011 HDA_INPUT), 4011 HDA_INPUT),
4012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
@@ -7639,6 +7639,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
7639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7640 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), 7640 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7641 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), 7641 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7642 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
7642 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), 7643 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7643 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 7644 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7644 {} 7645 {}
@@ -8102,7 +8103,7 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
8102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8103 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 8104 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8104 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8105 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8105 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 8106 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8106 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 8107 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 8108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8108 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 8109 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
@@ -8124,7 +8125,7 @@ static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8124 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 8125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 8126 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8126 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 8127 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8127 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 8128 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8128 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ 8129 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 8130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8130 { } /* end */ 8131 { } /* end */
@@ -9238,6 +9239,7 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
9238 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 9239 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9239 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 9240 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9240 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 9241 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9242 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9241 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 9243 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9242 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 9244 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9243 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), 9245 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
@@ -12993,8 +12995,8 @@ static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12993static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { 12995static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), 12996 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12995 12997
12996 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), 12998 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12997 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 12999 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12998 13000
12999 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), 13001 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13000 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 13002 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
@@ -13007,8 +13009,8 @@ static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
13007}; 13009};
13008 13010
13009static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { 13011static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13010 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT), 13012 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13011 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT), 13013 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13012 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), 13014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13013 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), 13015 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), 13016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 9ab4a9f383cb..5a158b73dcaa 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -51,7 +51,7 @@
51struct phase28_spec { 51struct phase28_spec {
52 unsigned short master[2]; 52 unsigned short master[2];
53 unsigned short vol[8]; 53 unsigned short vol[8];
54} phase28; 54};
55 55
56/* WM8770 registers */ 56/* WM8770 registers */
57#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */ 57#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index ddd5fc8d4fe1..301bf929acd9 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -36,7 +36,7 @@
36struct revo51_spec { 36struct revo51_spec {
37 struct snd_i2c_device *dev; 37 struct snd_i2c_device *dev;
38 struct snd_pt2258 *pt2258; 38 struct snd_pt2258 *pt2258;
39} revo51; 39};
40 40
41static void revo_i2s_mclk_changed(struct snd_ice1712 *ice) 41static void revo_i2s_mclk_changed(struct snd_ice1712 *ice)
42{ 42{
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 061072c7db03..c52abd0bf22e 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1708,6 +1708,12 @@ static struct ac97_pcm ac97_pcm_defs[] __devinitdata = {
1708}; 1708};
1709 1709
1710static struct ac97_quirk ac97_quirks[] __devinitdata = { 1710static struct ac97_quirk ac97_quirks[] __devinitdata = {
1711 {
1712 .subvendor = 0x0e11,
1713 .subdevice = 0x000e,
1714 .name = "Compaq Deskpro EN", /* AD1885 */
1715 .type = AC97_TUNE_HP_ONLY
1716 },
1711 { 1717 {
1712 .subvendor = 0x0e11, 1718 .subvendor = 0x0e11,
1713 .subdevice = 0x008a, 1719 .subdevice = 0x008a,
@@ -1740,6 +1746,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
1740 }, 1746 },
1741 { 1747 {
1742 .subvendor = 0x1025, 1748 .subvendor = 0x1025,
1749 .subdevice = 0x0082,
1750 .name = "Acer Travelmate 2310",
1751 .type = AC97_TUNE_HP_ONLY
1752 },
1753 {
1754 .subvendor = 0x1025,
1743 .subdevice = 0x0083, 1755 .subdevice = 0x0083,
1744 .name = "Acer Aspire 3003LCi", 1756 .name = "Acer Aspire 3003LCi",
1745 .type = AC97_TUNE_HP_ONLY 1757 .type = AC97_TUNE_HP_ONLY
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index 3ea1f05228a1..666f69a3312e 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -150,6 +150,7 @@ static const struct oxygen_model model_hifier = {
150 .shortname = "C-Media CMI8787", 150 .shortname = "C-Media CMI8787",
151 .longname = "C-Media Oxygen HD Audio", 151 .longname = "C-Media Oxygen HD Audio",
152 .chip = "CMI8788", 152 .chip = "CMI8788",
153 .owner = THIS_MODULE,
153 .init = hifier_init, 154 .init = hifier_init,
154 .control_filter = hifier_control_filter, 155 .control_filter = hifier_control_filter,
155 .mixer_init = hifier_mixer_init, 156 .mixer_init = hifier_mixer_init,
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 40e92f5cd69c..d163397b85cc 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -389,6 +389,7 @@ static const struct oxygen_model model_xonar = {
389 .shortname = "Asus AV200", 389 .shortname = "Asus AV200",
390 .longname = "Asus Virtuoso 200", 390 .longname = "Asus Virtuoso 200",
391 .chip = "AV200", 391 .chip = "AV200",
392 .owner = THIS_MODULE,
392 .init = xonar_init, 393 .init = xonar_init,
393 .control_filter = xonar_control_filter, 394 .control_filter = xonar_control_filter,
394 .mixer_init = xonar_mixer_init, 395 .mixer_init = xonar_mixer_init,
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 710e0287ef8c..569ecaca0e8b 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -681,8 +681,8 @@ static const struct aic3x_rate_divs aic3x_divs[] = {
681 {22579200, 48000, 48000, 0x0, 8, 7075}, 681 {22579200, 48000, 48000, 0x0, 8, 7075},
682 {33868800, 48000, 48000, 0x0, 5, 8049}, 682 {33868800, 48000, 48000, 0x0, 5, 8049},
683 /* 64k */ 683 /* 64k */
684 {22579200, 96000, 96000, 0x1, 8, 7075}, 684 {22579200, 64000, 96000, 0x1, 8, 7075},
685 {33868800, 96000, 96000, 0x1, 5, 8049}, 685 {33868800, 64000, 96000, 0x1, 5, 8049},
686 /* 88.2k */ 686 /* 88.2k */
687 {22579200, 88200, 88200, 0x0, 8, 0}, 687 {22579200, 88200, 88200, 0x0, 8, 0},
688 {33868800, 88200, 88200, 0x0, 5, 3333}, 688 {33868800, 88200, 88200, 0x0, 5, 3333},
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 590baea3c4c3..524f7450804f 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -176,7 +176,8 @@ static int wm9712_add_controls(struct snd_soc_codec *codec)
176 * the codec only has a single control that is shared by both channels. 176 * the codec only has a single control that is shared by both channels.
177 * This makes it impossible to determine the audio path. 177 * This makes it impossible to determine the audio path.
178 */ 178 */
179static int mixer_event (struct snd_soc_dapm_widget *w, int event) 179static int mixer_event(struct snd_soc_dapm_widget *w,
180 struct snd_kcontrol *k, int event)
180{ 181{
181 u16 l, r, beep, line, phone, mic, pcm, aux; 182 u16 l, r, beep, line, phone, mic, pcm, aux;
182 183
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c
index 3f34e531bebf..1a70a6ac98ce 100644
--- a/sound/soc/pxa/corgi.c
+++ b/sound/soc/pxa/corgi.c
@@ -215,7 +215,8 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol,
215 return 1; 215 return 1;
216} 216}
217 217
218static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event) 218static int corgi_amp_event(struct snd_soc_dapm_widget *w,
219 struct snd_kcontrol *k, int event)
219{ 220{
220 if (SND_SOC_DAPM_EVENT_ON(event)) 221 if (SND_SOC_DAPM_EVENT_ON(event))
221 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON); 222 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
@@ -225,7 +226,8 @@ static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
225 return 0; 226 return 0;
226} 227}
227 228
228static int corgi_mic_event(struct snd_soc_dapm_widget *w, int event) 229static int corgi_mic_event(struct snd_soc_dapm_widget *w,
230 struct snd_kcontrol *k, int event)
229{ 231{
230 if (SND_SOC_DAPM_EVENT_ON(event)) 232 if (SND_SOC_DAPM_EVENT_ON(event))
231 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS); 233 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_MIC_BIAS);
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c
index 5ae59bd309a3..4fbf8bba9627 100644
--- a/sound/soc/pxa/poodle.c
+++ b/sound/soc/pxa/poodle.c
@@ -196,7 +196,8 @@ static int poodle_set_spk(struct snd_kcontrol *kcontrol,
196 return 1; 196 return 1;
197} 197}
198 198
199static int poodle_amp_event(struct snd_soc_dapm_widget *w, int event) 199static int poodle_amp_event(struct snd_soc_dapm_widget *w,
200 struct snd_kcontrol *k, int event)
200{ 201{
201 if (SND_SOC_DAPM_EVENT_ON(event)) 202 if (SND_SOC_DAPM_EVENT_ON(event))
202 locomo_gpio_write(&poodle_locomo_device.dev, 203 locomo_gpio_write(&poodle_locomo_device.dev,
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index d56709e15435..ecca39033fcc 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -215,7 +215,8 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol,
215 return 1; 215 return 1;
216} 216}
217 217
218static int spitz_mic_bias(struct snd_soc_dapm_widget *w, int event) 218static int spitz_mic_bias(struct snd_soc_dapm_widget *w,
219 struct snd_kcontrol *k, int event)
219{ 220{
220 if (machine_is_borzoi() || machine_is_spitz()) { 221 if (machine_is_borzoi() || machine_is_spitz()) {
221 if (SND_SOC_DAPM_EVENT_ON(event)) 222 if (SND_SOC_DAPM_EVENT_ON(event))
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c
index e4d40b528ca4..7346d7e5d066 100644
--- a/sound/soc/pxa/tosa.c
+++ b/sound/soc/pxa/tosa.c
@@ -135,7 +135,8 @@ static int tosa_set_spk(struct snd_kcontrol *kcontrol,
135} 135}
136 136
137/* tosa dapm event handlers */ 137/* tosa dapm event handlers */
138static int tosa_hp_event(struct snd_soc_dapm_widget *w, int event) 138static int tosa_hp_event(struct snd_soc_dapm_widget *w,
139 struct snd_kcontrol *k, int event)
139{ 140{
140 if (SND_SOC_DAPM_EVENT_ON(event)) 141 if (SND_SOC_DAPM_EVENT_ON(event))
141 set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE); 142 set_tc6393_gpio(&tc6393_device.dev,TOSA_TC6393_L_MUTE);
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 8fa935665702..675672f313be 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -479,6 +479,33 @@ static int retire_playback_sync_urb_hs(struct snd_usb_substream *subs,
479 return 0; 479 return 0;
480} 480}
481 481
482/*
483 * process after E-Mu 0202/0404 high speed playback sync complete
484 *
485 * These devices return the number of samples per packet instead of the number
486 * of samples per microframe.
487 */
488static int retire_playback_sync_urb_hs_emu(struct snd_usb_substream *subs,
489 struct snd_pcm_runtime *runtime,
490 struct urb *urb)
491{
492 unsigned int f;
493 unsigned long flags;
494
495 if (urb->iso_frame_desc[0].status == 0 &&
496 urb->iso_frame_desc[0].actual_length == 4) {
497 f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff;
498 f >>= subs->datainterval;
499 if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
500 spin_lock_irqsave(&subs->lock, flags);
501 subs->freqm = f;
502 spin_unlock_irqrestore(&subs->lock, flags);
503 }
504 }
505
506 return 0;
507}
508
482/* determine the number of frames in the next packet */ 509/* determine the number of frames in the next packet */
483static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs) 510static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
484{ 511{
@@ -2219,10 +2246,17 @@ static void init_substream(struct snd_usb_stream *as, int stream, struct audiofo
2219 subs->stream = as; 2246 subs->stream = as;
2220 subs->direction = stream; 2247 subs->direction = stream;
2221 subs->dev = as->chip->dev; 2248 subs->dev = as->chip->dev;
2222 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 2249 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) {
2223 subs->ops = audio_urb_ops[stream]; 2250 subs->ops = audio_urb_ops[stream];
2224 else 2251 } else {
2225 subs->ops = audio_urb_ops_high_speed[stream]; 2252 subs->ops = audio_urb_ops_high_speed[stream];
2253 switch (as->chip->usb_id) {
2254 case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */
2255 case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */
2256 subs->ops.retire_sync = retire_playback_sync_urb_hs_emu;
2257 break;
2258 }
2259 }
2226 snd_pcm_set_ops(as->pcm, stream, 2260 snd_pcm_set_ops(as->pcm, stream,
2227 stream == SNDRV_PCM_STREAM_PLAYBACK ? 2261 stream == SNDRV_PCM_STREAM_PLAYBACK ?
2228 &snd_usb_playback_ops : &snd_usb_capture_ops); 2262 &snd_usb_playback_ops : &snd_usb_capture_ops);